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

Concrete base class to assist with implementing CFB for 128-bit block ciphers. More...

#include <CFB.h>

Inheritance diagram for CFBCommon:
Cipher CFB< T >

Public Member Functions

virtual ~CFBCommon ()
 Destroys this cipher object after clearing sensitive information.
 
size_t keySize () const
 Default size of the key for this cipher, in bytes. More...
 
size_t ivSize () const
 Size of the initialization vector for this cipher, 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 clear ()
 Clears all security-sensitive state from this cipher. More...
 
- Public Member Functions inherited from Cipher
 Cipher ()
 Constructs a new cipher object.
 
virtual ~Cipher ()
 Destroys this cipher object. More...
 

Protected Member Functions

 CFBCommon ()
 Constructs a new cipher in CFB mode. More...
 
void setBlockCipher (BlockCipher *cipher)
 Sets the block cipher to use for this CFB object. More...
 

Detailed Description

Concrete base class to assist with implementing CFB for 128-bit block ciphers.

Reference: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation

See also
CFB

Definition at line 29 of file CFB.h.

Constructor & Destructor Documentation

◆ CFBCommon()

CFBCommon::CFBCommon ( )
protected

Constructs a new cipher in CFB mode.

This constructor should be followed by a call to setBlockCipher().

Definition at line 42 of file CFB.cpp.

Member Function Documentation

◆ clear()

void CFBCommon::clear ( )
virtual

Clears all security-sensitive state from this cipher.

Security-sensitive information includes key schedules, initialization vectors, and any temporary state that is used by encrypt() or decrypt() which is stored in the cipher itself.

Implements Cipher.

Definition at line 140 of file CFB.cpp.

◆ decrypt()

void CFBCommon::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 112 of file CFB.cpp.

◆ encrypt()

void CFBCommon::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 85 of file CFB.cpp.

◆ ivSize()

size_t CFBCommon::ivSize ( ) const
virtual

Size of the initialization vector for this cipher, in bytes.

If the cipher does not need an initialization vector, this function will return zero.

Implements Cipher.

Definition at line 61 of file CFB.cpp.

◆ keySize()

size_t CFBCommon::keySize ( ) const
virtual

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

If the cipher supports variable-sized keys, keySize() indicates the default or recommended key size. The cipher may support other key sizes.

See also
setKey(), ivSize()

Implements Cipher.

Definition at line 56 of file CFB.cpp.

◆ setBlockCipher()

void CFBCommon::setBlockCipher ( BlockCipher cipher)
inlineprotected

Sets the block cipher to use for this CFB object.

Parameters
cipherThe block cipher to use to implement CFB mode, which must have a block size of 16 bytes (128 bits).

Definition at line 47 of file CFB.h.

◆ setIV()

bool CFBCommon::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 76 of file CFB.cpp.

◆ setKey()

bool CFBCommon::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 66 of file CFB.cpp.


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