Arduino Cryptography Library
Public Member Functions | List of all members
BlockCipher Class Referenceabstract

Abstract base class for block ciphers. More...

#include <BlockCipher.h>

Inheritance diagram for BlockCipher:
AESCommon AESTiny128 AESTiny256 Speck SpeckTiny AES128 AES192 AES256 AESSmall128 AESSmall256 SpeckSmall

Public Member Functions

 BlockCipher ()
 Constructs a block cipher.
 
virtual ~BlockCipher ()
 Destroys this block cipher object. More...
 
virtual size_t blockSize () const =0
 Size of a single block processed by this cipher, in bytes. More...
 
virtual size_t keySize () const =0
 Default size of the key for this block cipher, in bytes. More...
 
virtual bool setKey (const uint8_t *key, size_t len)=0
 Sets the key to use for future encryption and decryption operations. More...
 
virtual void encryptBlock (uint8_t *output, const uint8_t *input)=0
 Encrypts a single block using this cipher. More...
 
virtual void decryptBlock (uint8_t *output, const uint8_t *input)=0
 Decrypts a single block using this cipher. More...
 
virtual void clear ()=0
 Clears all security-sensitive state from this block cipher. More...
 

Detailed Description

Abstract base class for block ciphers.

Block ciphers always operate in electronic codebook (ECB) mode. Higher-level classes such as CFB128 and CTR128 wrap the block cipher to create more useful classes for encryption and decryption of bulk data.

References: http://en.wikipedia.org/wiki/Block_cipher, http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29

Definition at line 29 of file BlockCipher.h.

Constructor & Destructor Documentation

◆ ~BlockCipher()

BlockCipher::~BlockCipher ( )
virtual

Destroys this block cipher object.

Subclasses are responsible for clearing temporary key schedules and other buffers so as to avoid leaking sensitive information.

See also
clear()

Definition at line 52 of file BlockCipher.cpp.

Member Function Documentation

◆ blockSize()

size_t BlockCipher::blockSize ( ) const
pure virtual

Size of a single block processed by this cipher, in bytes.

Returns
Returns the size of a block in bytes.
See also
keySize(), encryptBlock()

Implemented in SpeckTiny, Speck, AESTiny128, AESTiny256, and AESCommon.

◆ clear()

void BlockCipher::clear ( )
pure virtual

Clears all security-sensitive state from this block cipher.

Security-sensitive information includes key schedules and any temporary state that is used by encryptBlock() or decryptBlock() which is stored in the object itself.

See also
setKey(), encryptBlock(), decryptBlock()

Implemented in SpeckTiny, SpeckSmall, Speck, AESSmall128, AESTiny128, AESSmall256, AESTiny256, and AESCommon.

◆ decryptBlock()

void BlockCipher::decryptBlock ( uint8_t *  output,
const uint8_t *  input 
)
pure virtual

Decrypts a single block using this cipher.

Parameters
outputThe output buffer to put the plaintext into. Must be at least blockSize() bytes in length.
inputThe input buffer to read the ciphertext from which is allowed to overlap with output. Must be at least blockSize() bytes in length.
See also
encryptBlock(), blockSize()

Implemented in SpeckTiny, SpeckSmall, Speck, AESSmall128, AESTiny128, AESSmall256, AESTiny256, and AESCommon.

◆ encryptBlock()

void BlockCipher::encryptBlock ( uint8_t *  output,
const uint8_t *  input 
)
pure virtual

Encrypts a single block using this cipher.

Parameters
outputThe output buffer to put the ciphertext into. Must be at least blockSize() bytes in length.
inputThe input buffer to read the plaintext from which is allowed to overlap with output. Must be at least blockSize() bytes in length.
See also
decryptBlock(), blockSize()

Implemented in SpeckTiny, Speck, AESTiny128, AESTiny256, and AESCommon.

◆ keySize()

size_t BlockCipher::keySize ( ) const
pure virtual

Default size of the key for this block cipher, in bytes.

This value indicates the default, or recommended, size for the key.

See also
setKey(), blockSize()

Implemented in SpeckTiny, Speck, AESTiny128, AESTiny256, AES256, AES192, and AES128.

◆ setKey()

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

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

Parameters
keyThe key to use.
lenThe length of the key.
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.

See also
keySize(), clear()

Implemented in SpeckTiny, SpeckSmall, Speck, AESSmall128, AESTiny128, AESSmall256, AESTiny256, AES256, AES192, and AES128.


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