Ejemplo n.º 1
0
func BoxDetachedAfterNm(cipherTextOut []byte, mac []byte, message []byte, nonce, key []byte) int {
	support.CheckSize(cipherTextOut, BoxMacBytes()+len(message), "cypher text output")
	support.CheckSize(mac, BoxMacBytes(), "mac")
	support.CheckSize(nonce, BoxNonceBytes(), "nonce")
	support.CheckSize(key, BoxBeforeNmBytes(), "key")

	return int(C.crypto_box_detached_afternm(
		(*C.uchar)(&cipherTextOut[0]),
		(*C.uchar)(&mac[0]),
		(*C.uchar)(&message[0]),
		(C.ulonglong)(len(message)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&key[0])))
}
Ejemplo n.º 2
0
func CryptoBoxDetachedAfterNm(mac []byte, m []byte, n []byte, k []byte) ([]byte, int) {
	support.CheckSize(mac, CryptoBoxMacBytes(), "mac")
	support.CheckSize(n, CryptoBoxNonceBytes(), "nonce")
	support.CheckSize(k, CryptoBoxBeforeNmBytes(), "shared secret key")
	c := make([]byte, len(m)+CryptoBoxMacBytes())
	exit := int(C.crypto_box_detached_afternm(
		(*C.uchar)(&c[0]),
		(*C.uchar)(&mac[0]),
		(*C.uchar)(&m[0]),
		(C.ulonglong)(len(m)),
		(*C.uchar)(&n[0]),
		(*C.uchar)(&k[0])))

	return c, exit
}