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)
}