Example #1
0
func BoxOpenEasyAfterNm(messageOut []byte, cypherText []byte, nonce, key []byte) int {
	support.CheckSize(messageOut, BoxMacBytes()+len(cypherText), "message output")
	support.CheckSize(nonce, BoxNonceBytes(), "nonce")
	support.CheckSize(key, BoxBeforeNmBytes(), "key")

	return int(C.crypto_box_open_easy_afternm(
		(*C.uchar)(&messageOut[0]),
		(*C.uchar)(&cypherText[0]),
		(C.ulonglong)(len(cypherText)),
		(*C.uchar)(&nonce[0]),
		(*C.uchar)(&key[0])))
}
Example #2
0
func CryptoBoxOpenEasyAfterNm(c []byte, n []byte, k []byte) ([]byte, int) {
	support.CheckSize(n, CryptoBoxNonceBytes(), "nonce")
	support.CheckSize(k, CryptoBoxBeforeNmBytes(), "shared secret key")
	m := make([]byte, len(c)-CryptoBoxMacBytes())
	exit := int(C.crypto_box_open_easy_afternm(
		(*C.uchar)(&m[0]),
		(*C.uchar)(&c[0]),
		(C.ulonglong)(len(c)),
		(*C.uchar)(&n[0]),
		(*C.uchar)(&k[0])))

	return m, exit
}