Ejemplo n.º 1
0
func boxOpenDetached(messageOut []byte, message []byte, mac, nonce, pk, sk []byte) int {
	support.CheckSize(messageOut, BoxMacBytes()+len(message), "cipher text output")
	support.CheckSize(mac, BoxMacBytes(), "mac")
	support.CheckSize(nonce, BoxNonceBytes(), "nonce")
	support.CheckSize(pk, BoxPublicKeyBytes(), "public key")
	support.CheckSize(sk, BoxSecretKeyBytes(), "secret key")

	return int(C.crypto_box_detached(
		(*C.uchar)(&messageOut[0]),
		(*C.uchar)(&message[0]),
		(*C.uchar)(&mac[0]),
		(C.ulonglong)(len(message)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&pk[0]),
		(*C.uchar)(&sk[0])))
}
Ejemplo n.º 2
0
func CryptoBoxOpenDetached(c []byte, mac []byte, n []byte, pk []byte, sk []byte) ([]byte, int) {
	support.CheckSize(mac, CryptoBoxMacBytes(), "mac")
	support.CheckSize(n, CryptoBoxNonceBytes(), "nonce")
	support.CheckSize(pk, CryptoBoxPublicKeyBytes(), "public key")
	support.CheckSize(sk, CryptoBoxSecretKeyBytes(), "secret key")
	m := make([]byte, len(c)-CryptoBoxMacBytes())
	exit := int(C.crypto_box_detached(
		(*C.uchar)(&m[0]),
		(*C.uchar)(&c[0]),
		(*C.uchar)(&mac[0]),
		(C.ulonglong)(len(c)),
		(*C.uchar)(&n[0]),
		(*C.uchar)(&pk[0]),
		(*C.uchar)(&sk[0])))

	return m, exit
}