func Box(message []byte, nonce Nonce, pk PublicKey, sk SecretKey) []byte { result := make([]byte, C.crypto_box_ZEROBYTES+len(message)) copy(result[C.crypto_box_ZEROBYTES:], message) C.crypto_box(array(result), array(result), C.ulonglong(len(result)), array(nonce), array(pk), array(sk)) return result[C.crypto_box_BOXZEROBYTES:] }
func Box(cypherTextOut []byte, message []byte, nonce, pk, sk []byte) int { checkSize(cypherTextOut, len(message), "cypher text output") checkSize(nonce, BoxNonceBytes(), "nonce") checkSize(pk, BoxPublicKeyBytes(), "public key") checkSize(sk, BoxSecretKeyBytes(), "secret key") return int(C.crypto_box((*C.uchar)(&cypherTextOut[0]), (*C.uchar)(&message[0]), (C.ulonglong)(len(message)), (*C.uchar)(&nonce[0]), (*C.uchar)(&pk[0]), (*C.uchar)(&sk[0]))) }
func CryptoBox(m []byte, n []byte, pk []byte, sk []byte) ([]byte, int) { support.CheckSize(n, CryptoBoxNonceBytes(), "nonce") support.CheckSize(pk, CryptoBoxPublicKeyBytes(), "public key") support.CheckSize(sk, CryptoBoxSecretKeyBytes(), "sender's secret key") c := make([]byte, len(m)) exit := int(C.crypto_box( (*C.uchar)(&c[0]), (*C.uchar)(&m[0]), (C.ulonglong)(len(m)), (*C.uchar)(&n[0]), (*C.uchar)(&pk[0]), (*C.uchar)(&sk[0]))) return c, exit }