示例#1
0
func boxSealOpen(messageOut []byte, cypherText []byte, pk, sk []byte) int {
	support.CheckSize(messageOut, BoxMacBytes()+len(cypherText), "message output")
	support.CheckSize(pk, BoxPublicKeyBytes(), "public key")
	support.CheckSize(sk, BoxSecretKeyBytes(), "secret key")

	return int(C.crypto_box_seal_open(
		(*C.uchar)(&messageOut[0]),
		(*C.uchar)(&cypherText[0]),
		(C.ulonglong)(len(cypherText)),
		(*C.uchar)(&pk[0]),
		(*C.uchar)(&sk[0])))
}
示例#2
0
func CryptoBoxSealOpen(c []byte, pk []byte, sk []byte) ([]byte, int) {
	support.CheckSize(pk, CryptoBoxPublicKeyBytes(), "public key")
	support.CheckSize(sk, CryptoBoxSecretKeyBytes(), "secret key")
	m := make([]byte, len(c)-CryptoBoxMacBytes())
	exit := int(C.crypto_box_seal_open(
		(*C.uchar)(&m[0]),
		(*C.uchar)(&c[0]),
		(C.ulonglong)(len(c)),
		(*C.uchar)(&pk[0]),
		(*C.uchar)(&sk[0])))

	return m, exit
}