class Sodium::Cipher::ChaCha20
- Sodium::Cipher::ChaCha20
- Sodium::Cipher::Chalsa
- Reference
- Object
Overview
These classes can be used to generate pseudo-random data from a key, or as building blocks for implementing custom constructions, but they are not alternatives to secretbox.
See https://libsodium.gitbook.io/doc/advanced/stream_ciphers for further information.
This class mimicks the OpenSSL::Cipher interface with minor differences.
See spec/sodium/cipher/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/chalsa.crConstant Summary
-
KEY_SIZE =
LibSodium.crypto_stream_chacha20_keybytes.to_i32
-
NONCE_SIZE =
LibSodium.crypto_stream_chacha20_noncebytes.to_i32
Instance Method Summary
- #key_size : Int32
- #nonce_size : Int32
-
#update(src : Bytes, dst : Bytes) : Bytes
Xor's src with the cipher output and places in dst.
Instance methods inherited from class Sodium::Cipher::Chalsa
dup
dup,
edible?
edible?,
final
final,
key
key,
key=(key : Bytes | SecureBuffer)
key=,
key? : Slice(UInt8) | Sodium::SecureBuffer | Nil
key?,
key_size : Int32
key_size,
nonce
nonce,
nonce=(nonce : Bytes)
nonce=,
nonce? : Slice(UInt8)?
nonce?,
nonce_size : Int32
nonce_size,
offset : Int32
offset,
offset=(offset)
offset=,
random_bytes(bytes : Bytes) : Bytesrandom_bytes(size : Int) : Bytes random_bytes, random_key random_key, random_nonce random_nonce, update(src : Bytes) : Bytes
update(src : Bytes, dst : Bytes) update
Constructor methods inherited from class Sodium::Cipher::Chalsa
new(key = nil, nonce = nil)
new
Instance Method Detail
def update(src : Bytes, dst : Bytes) : Bytes
#
Xor's src with the cipher output and places in dst.
src and dst may be the same object but should not overlap.