NAME
Crypt::Bear::AEAD - AEAD encoder baseclass BearSSL
VERSION
version 0.002
SYNOPSIS
$aead->reset($iv);
$aead->aad_inject($aad);
$aead->flip;
my $ciphertext = $aead->run($plaintext, 1);
my $tag = $aead->get_tag;
$aead->reset($iv);
$aead->aad_inject($aad);
$aead->flip;
my $decoded = $aead->run($ciphertext, 0);
DESCRIPTION
This is a base-class for Authenticated encryption with additional data, such as GCM, CCM and EAX. These are typtically used with a block cipher such as AES
.
METHODS
reset($nonce)
Start a new AEAD computation. The nonce value is provided as parameter to this function.
aad_inject($data)
Inject some additional authenticated data. Additional data may be provided in several chunks of arbitrary length.
flip()
This method MUST be called after injecting all additional authenticated data, and before beginning to encrypt the plaintext (or decrypt the ciphertext).
run($data, $encrypt)
Process some plaintext to encrypt (if $encrypt
is true)) or ciphertext to decrypt (if it is false), returning the result. Data may be provided in several chunks of arbitrary length.
get_tag()
Compute the authentication tag. All message data (encrypted or decrypted) must have been injected at that point. Also, this call may modify internal context elements, so it may be called only once for a given AEAD computation.
check_tag($tag)
An alternative to get_tag
, meant to be used by the receiver: the authentication tag is internally recomputed, and compared with the one provided as parameter.
AUTHOR
Leon Timmermans <fawaka@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2024 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.