class Crypto::AeadChacha20Poly1305

Overview

AEAD_CHACHA20_POLY1305 is an authenticated encryption with additional data algorithm.

Defined in:

crypto/aead.cr

Constructors

Instance Method Summary

Constructor Detail

def self.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

[View source]

Instance Method Detail

def 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.


[View source]
def 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.


[View source]
def final : Bytes #

write final footer


[View source]
def update(data : Bytes) #

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


[View source]