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
}
Esempio n. 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
}
Esempio n. 3
0
File: key.go Progetto: 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
}
Esempio n. 4
0
File: key.go Progetto: 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
}
Esempio n. 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])))
}
Esempio n. 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)
}