Skinny-C
 All Data Structures Files Functions Variables Groups Pages
Public Member Functions
BlockCipher Class Referenceabstract

Abstract base class for block ciphers. More...

#include <BlockCipher.h>

Inheritance diagram for BlockCipher:
Mantis8 Skinny128 Skinny64 Skinny128_128 Skinny128_256 Skinny128_384 Skinny128_Tweaked Skinny64_128 Skinny64_192 Skinny64_64 Skinny64_Tweaked

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 ( )
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

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 Mantis8, Skinny128, and Skinny64.

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 Skinny128_Tweaked, Skinny64_Tweaked, Mantis8, Skinny128, and Skinny64.

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 Mantis8, Skinny128, and Skinny64.

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 Mantis8, Skinny128, and Skinny64.

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 Skinny128_384_Tweaked, Skinny64_192_Tweaked, Skinny128_384, Skinny64_192, Skinny128_256_Tweaked, Skinny64_128_Tweaked, Skinny128_256, Skinny64_128, Skinny128_128, Skinny64_64, and Mantis8.

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 Skinny128_384_Tweaked, Skinny64_192_Tweaked, Skinny128_384, Skinny64_192, Skinny128_256_Tweaked, Skinny64_128_Tweaked, Skinny128_256, Skinny64_128, Skinny128_128, Skinny64_64, and Mantis8.


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