예제 #1
0
func BoxKeypair() (pk PublicKey, sk SecretKey) {
	pk = make([]byte, C.crypto_box_PUBLICKEYBYTES)
	sk = make([]byte, C.crypto_box_SECRETKEYBYTES)

	C.crypto_box_keypair(array(pk), array(sk))

	return
}
예제 #2
0
func CryptoBoxKeyPair() ([]byte, []byte, int) {
	sk := make([]byte, CryptoBoxSecretKeyBytes())
	pk := make([]byte, CryptoBoxPublicKeyBytes())
	exit := int(C.crypto_box_keypair(
		(*C.uchar)(&pk[0]),
		(*C.uchar)(&sk[0])))

	return sk, pk, exit
}
예제 #3
0
파일: key.go 프로젝트: ZiRo-/srndv2
func GenBoxKeypair() *KeyPair {
	sk_len := C.crypto_box_secretkeybytes()
	sk := malloc(sk_len)
	pk_len := C.crypto_box_publickeybytes()
	pk := malloc(pk_len)
	res := C.crypto_box_keypair(pk.uchar(), sk.uchar())
	if res == 0 {
		return &KeyPair{pk, sk}
	}
	pk.Free()
	sk.Free()
	return nil
}
예제 #4
0
파일: key.go 프로젝트: 4cdn/srndv2
func GenBoxKeypair() *KeyPair {
	sk_len := C.crypto_box_secretkeybytes()
	sk := malloc(sk_len)
	pk_len := C.crypto_box_publickeybytes()
	pk := malloc(pk_len)
	res := C.crypto_box_keypair(pk.uchar(), sk.uchar())
	if res == 0 {
		return &KeyPair{pk, sk}
	}
	log.Println("nacl.GenBoxKeyPair() failed to generate keypair")
	pk.Free()
	sk.Free()
	return nil
}
예제 #5
0
// BoxKeyPair generates a new public/secret key pair, returning them in the passed buffers.
func BoxKeyPair(pkOut, skOut []byte) int {
	checkSize(pkOut, BoxPublicKeyBytes(), "public key")
	checkSize(skOut, BoxSecretKeyBytes(), "secret key")

	return int(C.crypto_box_keypair((*C.uchar)(&pkOut[0]), (*C.uchar)(&skOut[0])))
}
예제 #6
0
func crypto_box_keypair(pk []byte, sk []byte) int {
	result := C.crypto_box_keypair((*C.uchar)(&pk[0]), (*C.uchar)(&sk[0]))
	return int(result)
}