Abstract base class for block ciphers.
More...
#include <BlockCipher.h>
|
| 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...
|
|
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.
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.
size_t BlockCipher::blockSize |
( |
| ) |
const |
|
pure virtual |
void BlockCipher::clear |
( |
| ) |
|
|
pure virtual |
void BlockCipher::decryptBlock |
( |
uint8_t * |
output, |
|
|
const uint8_t * |
input |
|
) |
| |
|
pure virtual |
Decrypts a single block using this cipher.
- Parameters
-
output | The output buffer to put the plaintext into. Must be at least blockSize() bytes in length. |
input | The 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 Speck, and AESCommon.
void BlockCipher::encryptBlock |
( |
uint8_t * |
output, |
|
|
const uint8_t * |
input |
|
) |
| |
|
pure virtual |
Encrypts a single block using this cipher.
- Parameters
-
output | The output buffer to put the ciphertext into. Must be at least blockSize() bytes in length. |
input | The 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 Speck, and AESCommon.
size_t BlockCipher::keySize |
( |
| ) |
const |
|
pure virtual |
bool BlockCipher::setKey |
( |
const uint8_t * |
key, |
|
|
size_t |
len |
|
) |
| |
|
pure virtual |
Sets the key to use for future encryption and decryption operations.
- Parameters
-
key | The key to use. |
len | The 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 AES256, AES192, AES128, and Speck.
The documentation for this class was generated from the following files: