class

Crypto::AeadChacha20Poly1305

Inherits Reference < Object

AEAD_CHACHA20_POLY1305 is an authenticated encryption with additional data algorithm.

Constructors

new(key : Bytes, nonce : Bytes, io : IO)

The inputs to AEAD_CHACHA20_POLY1305 are:

  • key: A 256-bit key
  • nonce: A 96-bit nonce -- different for each invocation with the same key
  • io: the buffer to write the authenticated plain and ciphertext to
Source

Instance methods

aad(data : Bytes)

Arbitrary length additional authenticated data (AAD). Needs to be written before the plaintext. Can be called multiple times, but only the last block can be less then 16 bytes.

Source
decrypt(data : Bytes, tag : Bytes) : Bytes

decrpyt parses the data and verifies the data with the tag returns the additional authenticated data. The plaintext is written to the provided mem, in case the tag is not validating the data an exception is raised.

Source
final

write final footer

Source
update(data : Bytes)

An arbitrary length plaintext, has to be multiples of 16 bytes last call might be with less then 16 bytes

Source