Arduino Cryptography Library
Public Member Functions | List of all members
Acorn128 Class Reference

ACORN-128 authenticated cipher. More...

#include <Acorn128.h>

Inheritance diagram for Acorn128:
AuthenticatedCipher Cipher

Public Member Functions

 Acorn128 ()
 Constructs a new Acorn128 authenticated cipher.
 
virtual ~Acorn128 ()
 Destroys this Acorn128 authenticated cipher.
 
size_t keySize () const
 Gets the size of the Acorn128 key in bytes. More...
 
size_t ivSize () const
 Gets the size of the Acorn128 initialization vector in bytes. More...
 
size_t tagSize () const
 Gets the size of the Acorn128 authentication tag in bytes. More...
 
bool setKey (const uint8_t *key, size_t len)
 Sets the key to use for future encryption and decryption operations. More...
 
bool setIV (const uint8_t *iv, size_t len)
 Sets the initialization vector to use for future encryption and decryption operations. More...
 
void encrypt (uint8_t *output, const uint8_t *input, size_t len)
 Encrypts an input buffer and writes the ciphertext to an output buffer. More...
 
void decrypt (uint8_t *output, const uint8_t *input, size_t len)
 Decrypts an input buffer and writes the plaintext to an output buffer. More...
 
void addAuthData (const void *data, size_t len)
 Adds extra data that will be authenticated but not encrypted. More...
 
void computeTag (void *tag, size_t len)
 Finalizes the encryption process and computes the authentication tag. More...
 
bool checkTag (const void *tag, size_t len)
 Finalizes the decryption process and checks the authentication tag. More...
 
void clear ()
 Clears all security-sensitive state from this cipher object.
 
- Public Member Functions inherited from AuthenticatedCipher
 AuthenticatedCipher ()
 Constructs a new authenticated cipher.
 
virtual ~AuthenticatedCipher ()
 Destroys this authenticated cipher.
 
- Public Member Functions inherited from Cipher
 Cipher ()
 Constructs a new cipher object.
 
virtual ~Cipher ()
 Destroys this cipher object. More...
 

Detailed Description

ACORN-128 authenticated cipher.

Acorn128 is an authenticated cipher designed for memory-limited environments with a 128-bit key, a 128-bit initialization vector, and a 128-bit authentication tag. It was one of the finalists in the CAESAR AEAD competition.

References: http://competitions.cr.yp.to/round3/acornv3.pdf, http://competitions.cr.yp.to/caesar-submissions.html

See also
AuthenticatedCipher

Definition at line 67 of file Acorn128.h.

Member Function Documentation

◆ addAuthData()

void Acorn128::addAuthData ( const void *  data,
size_t  len 
)
virtual

Adds extra data that will be authenticated but not encrypted.

Parameters
dataThe extra data to be authenticated.
lenThe number of bytes of extra data to be authenticated.

This function must be called before the first call to encrypt() or decrypt(). That is, it is assumed that all extra data for authentication is available before the first payload data block and that it will be prepended to the payload for authentication. If the subclass needs to process the extra data after the payload, then it is responsible for saving data away until it is needed during computeTag() or checkTag().

This function can be called multiple times with separate extra data blocks for authentication. All such data will be concatenated into a single block for authentication purposes.

Implements AuthenticatedCipher.

Definition at line 606 of file Acorn128.cpp.

◆ checkTag()

bool Acorn128::checkTag ( const void *  tag,
size_t  len 
)
virtual

Finalizes the decryption process and checks the authentication tag.

Parameters
tagThe tag value from the incoming ciphertext to be checked.
lenThe length of the tag value in bytes, which may be less than tagSize().
Returns
Returns true if the tag is identical to the first len bytes of the authentication tag that was calculated during the decryption process. Returns false otherwise.

This function must be called after the final block of ciphertext is passed to decrypt() to determine if the data could be authenticated.

Note
Authenticated cipher modes usually require that if the tag could not be verified, then all of the data that was previously decrypted must be discarded. It is unwise to use the decrypted data for any purpose before it can be verified. Callers are responsible for ensuring that any data returned via previous calls to decrypt() is discarded if checkTag() returns false.
See also
computeTag()

Implements AuthenticatedCipher.

Definition at line 660 of file Acorn128.cpp.

◆ computeTag()

void Acorn128::computeTag ( void *  tag,
size_t  len 
)
virtual

Finalizes the encryption process and computes the authentication tag.

Parameters
tagPoints to the buffer to write the tag to.
lenThe length of the tag, which may be less than tagSize() to truncate the tag to the first len bytes.
See also
checkTag()

Implements AuthenticatedCipher.

Definition at line 631 of file Acorn128.cpp.

◆ decrypt()

void Acorn128::decrypt ( uint8_t *  output,
const uint8_t *  input,
size_t  len 
)
virtual

Decrypts an input buffer and writes the plaintext to an output buffer.

Parameters
outputThe output buffer to write to, which may be the same buffer as input. The output buffer must have at least as many bytes as the input buffer.
inputThe input buffer to read from.
lenThe number of bytes to decrypt.

The decrypt() function can be called multiple times with different regions of the ciphertext data.

See also
encrypt()

Implements Cipher.

Definition at line 580 of file Acorn128.cpp.

◆ encrypt()

void Acorn128::encrypt ( uint8_t *  output,
const uint8_t *  input,
size_t  len 
)
virtual

Encrypts an input buffer and writes the ciphertext to an output buffer.

Parameters
outputThe output buffer to write to, which may be the same buffer as input. The output buffer must have at least as many bytes as the input buffer.
inputThe input buffer to read from.
lenThe number of bytes to encrypt.

The encrypt() function can be called multiple times with different regions of the plaintext data.

See also
decrypt()

Implements Cipher.

Definition at line 554 of file Acorn128.cpp.

◆ ivSize()

size_t Acorn128::ivSize ( ) const
virtual

Gets the size of the Acorn128 initialization vector in bytes.

Returns
Always returns 16, indicating a 128-bit IV.

Authentication tags may be truncated to 8 bytes, but the algorithm authors recommend using a full 16-byte tag.

Implements Cipher.

Definition at line 77 of file Acorn128.cpp.

◆ keySize()

size_t Acorn128::keySize ( ) const
virtual

Gets the size of the Acorn128 key in bytes.

Returns
Always returns 16, indicating a 128-bit key.

Implements Cipher.

Definition at line 64 of file Acorn128.cpp.

◆ setIV()

bool Acorn128::setIV ( const uint8_t *  iv,
size_t  len 
)
virtual

Sets the initialization vector to use for future encryption and decryption operations.

Parameters
ivThe initialization vector to use.
lenThe length of the initialization vector in bytes.
Returns
Returns false if the length is not supported.

Initialization vectors should be set before the first call to encrypt() or decrypt() after a setKey() call. If the initialization vector is changed after encryption or decryption begins, then the behaviour is undefined.

Note
The IV is not encoded into the output stream by encrypt(). The caller is responsible for communicating the IV to the other party.
See also
ivSize()

Implements Cipher.

Definition at line 495 of file Acorn128.cpp.

◆ setKey()

bool Acorn128::setKey ( const uint8_t *  key,
size_t  len 
)
virtual

Sets the key to use for future encryption and decryption operations.

Parameters
keyThe key to use.
lenThe length of the key in bytes.
Returns
Returns false if the key length is not supported, or the key is somehow "weak" and unusable by this cipher.

Use clear() or the destructor to remove the key and any other sensitive data from the object once encryption or decryption is complete.

Calling setKey() resets the cipher. Any temporary data that was being retained for encrypting partial blocks will be abandoned.

See also
keySize(), clear()

Implements Cipher.

Definition at line 477 of file Acorn128.cpp.

◆ tagSize()

size_t Acorn128::tagSize ( ) const
virtual

Gets the size of the Acorn128 authentication tag in bytes.

Returns
Always returns 16, indicating a 128-bit authentication tag.

Implements AuthenticatedCipher.

Definition at line 87 of file Acorn128.cpp.


The documentation for this class was generated from the following files: