- crypto_aead_xchacha20poly1305_ietf_decrypt
bool crypto_aead_xchacha20poly1305_ietf_decrypt(ubyte[] m, ubyte[] c, ubyte[] ad, ubyte[crypto_aead_xchacha20poly1305_ietf_NPUBBYTES] npub, ubyte[crypto_aead_xchacha20poly1305_ietf_KEYBYTES] k)
The function crypto_aead_xchacha20poly1305_ietf_decrypt()
verifies that the ciphertext c (as produced by crypto_aead_xchacha20poly1305_ietf_encrypt()),
includes a valid tag using a secret key k, a public nonce npub, and additional data ad. c.length is the ciphertext length
in bytes with the authenticator, so it has to be at least crypto_aead_xchacha20poly1305_ietf_ABYTES.
- crypto_aead_xchacha20poly1305_ietf_decrypt_detached
bool crypto_aead_xchacha20poly1305_ietf_decrypt_detached(ubyte[] m, ubyte[] c, ubyte[crypto_aead_xchacha20poly1305_ietf_ABYTES] mac, ubyte[] ad, ubyte[crypto_aead_xchacha20poly1305_ietf_NPUBBYTES] npub, ubyte[crypto_aead_xchacha20poly1305_ietf_KEYBYTES] k)
Undocumented in source. Be warned that the author may not have intended to support it.
- crypto_aead_xchacha20poly1305_ietf_encrypt
bool crypto_aead_xchacha20poly1305_ietf_encrypt(ubyte[] c, ubyte[] m, ubyte[] ad, ubyte[crypto_aead_xchacha20poly1305_ietf_NPUBBYTES] npub, ubyte[crypto_aead_xchacha20poly1305_ietf_KEYBYTES] k)
The function crypto_aead_xchacha20poly1305_ietf_encrypt()
encrypts a message m using a secret key k (crypto_aead_xchacha20poly1305_ietf_KEYBYTES bytes)
and a public nonce npub (crypto_aead_xchacha20poly1305_ietf_NPUBBYTES bytes).
The encrypted message, as well as a tag authenticating both the confidential message m and ad.length bytes of non-confidential data ad,
are put into c.
ad can also be an empty array if no additional data are required.
At most m.length + crypto_aead_xchacha20poly1305_ietf_ABYTES bytes are put into c, and the actual number of bytes is stored into clen_p.
The function always returns true.
The public nonce npub should never ever be reused with the same key. The recommended way to generate it is to use
randombytes_buf() for the first message, and then to increment it for each subsequent message using the same key.
- crypto_aead_xchacha20poly1305_ietf_encrypt_detached
bool crypto_aead_xchacha20poly1305_ietf_encrypt_detached(ubyte[] c, ubyte[crypto_aead_xchacha20poly1305_ietf_ABYTES] mac, ubyte[] m, ubyte[] ad, ubyte[crypto_aead_xchacha20poly1305_ietf_NPUBBYTES] npub, ubyte[crypto_aead_xchacha20poly1305_ietf_KEYBYTES] k)
Undocumented in source. Be warned that the author may not have intended to support it.