class Sodium::Cipher::Aead::XChaCha20Poly1305Ietf

Overview

Use like SecretBox with optional additional authenticated data.

See https://libsodium.gitbook.io/doc/secret-key_cryptography/aead

See spec/sodium/cipher/aead/chalsa_spec.cr for examples on how to use this class.

WARNING: Not validated against test vectors. You should probably write some before using this class.

Defined in:

sodium/cipher/aead/chalsa.cr

Constant Summary

KEY_SIZE = LibSodium.crypto_aead_xchacha20poly1305_ietf_keybytes.to_i32
MAC_SIZE = LibSodium.crypto_aead_xchacha20poly1305_ietf_abytes.to_i32
NONCE_SIZE = LibSodium.crypto_aead_xchacha20poly1305_ietf_npubbytes.to_i32

Instance Method Summary

Instance methods inherited from class Sodium::Cipher::Aead::Chalsa

decrypt(src, dst : Bytes? = nil, *, nonce : Nonce, additional = nil) : Bytes decrypt, decrypt_detached(src, dst : Bytes? = nil, *, nonce = nil, mac : Bytes? = nil, additional = nil) : Bytes
decrypt_detached(src : Bytes, dst : Bytes? = nil, *, nonce : Sodium::Nonce, mac : Bytes, additional : String | Bytes | Nil = nil) : Bytes
decrypt_detached
, decrypt_detached_string(src, dst : Bytes? = nil, *, nonce = nil, mac : Bytes? = nil, additional = nil) : String decrypt_detached_string, decrypt_string(src, dst : Bytes? = nil, *, nonce : Nonce, additional = nil) : String decrypt_string, dup dup, encrypt(src, dst : Bytes? = nil, *, nonce = nil, additional = nil) encrypt, encrypt_detached(src : Bytes, dst : Bytes? = nil, *, nonce : Sodium::Nonce? = nil, mac : Bytes? = nil, additional : String | Bytes | Nil = nil) : Tuple(Bytes, Bytes, Sodium::Nonce)
encrypt_detached(src, dst : Bytes? = nil, *, nonce = nil, mac : Bytes? = nil, additional = nil) : Tuple(Bytes, Bytes, Nonce)
encrypt_detached
, key : SecureBuffer key

Constructor methods inherited from class Sodium::Cipher::Aead::Chalsa

new(key : SecureBuffer)
new(bytes : Bytes, erase = false)
new
new

Instance Method Detail

def decrypt_detached(src : Bytes, dst : Bytes? = nil, *, nonce : Sodium::Nonce, mac : Bytes, additional : String | Bytes | Nil = nil) : Bytes #

src and dst may be the same object but should not overlap. Must supply mac and nonce Must supply additional if supplied to #encrypt_detached


[View source]
def encrypt_detached(src : Bytes, dst : Bytes? = nil, nonce : Sodium::Nonce? = nil, *, mac : Bytes? = nil, additional : String | Bytes | Nil = nil) : Tuple(Bytes, Bytes, Sodium::Nonce) #

src and dst may be the same object but should not overlap. May supply mac, otherwise a new one is returned. May supply additional


[View source]