semf
semf::app::AesCbc Class Referenceabstract

Abstract class for AES-CBC (Advanced Encryption Standard-Cipher Block Chaining) for symmetric encryption/decryption. More...

#include <aescbc.h>

Collaboration diagram for semf::app::AesCbc:
Collaboration graph

Public Types

enum  State : bool { Ok = true , Error = false }
 

Public Member Functions

virtual ~AesCbc ()=default
 
virtual void setKey (const uint8_t key[], size_t size)=0
 Sets the AES key. More...
 
virtual void setInitializationVector (const uint8_t initializationVector[])=0
 Sets the initialization vector. More...
 
virtual void resetInitializationVector ()=0
 
virtual State encrypt (const uint8_t dataIn[], uint8_t bufferOut[], size_t size)=0
 Encrypts the given data using AES-CBC algorithm. More...
 
virtual State decrypt (const uint8_t dataIn[], uint8_t bufferOut[], size_t size)=0
 Performs an AES-CBC decryption on the given (encrypted) data. More...
 

Detailed Description

Abstract class for AES-CBC (Advanced Encryption Standard-Cipher Block Chaining) for symmetric encryption/decryption.

Warning
The format of the keys (public and private), modular and the data are in big endian format, where the MSByte is placed at the byte with the minimum address.

Definition at line 26 of file aescbc.h.

Member Enumeration Documentation

◆ State

Enum for the output state of a method.

Enumerator
Ok 

Successful execution of a method.

Error 

Failed execution of a method.

Definition at line 30 of file aescbc.h.

Constructor & Destructor Documentation

◆ ~AesCbc()

virtual semf::app::AesCbc::~AesCbc ( )
virtualdefault

Member Function Documentation

◆ decrypt()

virtual State semf::app::AesCbc::decrypt ( const uint8_t  dataIn[],
uint8_t  bufferOut[],
size_t  size 
)
pure virtual

Performs an AES-CBC decryption on the given (encrypted) data.

Warning
The initialization vector has to be set before using this function.
Note
The content of the initialization vector is updated so that you can call the same function again on the next block(s) of data and get the same result as if it was encrypted in one call. This allows a "streaming" usage. If you need to retain the contents of the initialization vector, you should either save it manually or use the cipher module instead.
Parameters
dataInInput data which has to be decrypted.
bufferOutDecrypted data.
sizeSize of input data in bytes. It must be a multiple of the block size (16 Bytes).
Returns
State::Ok on success and State::Error on failure.

◆ encrypt()

virtual State semf::app::AesCbc::encrypt ( const uint8_t  dataIn[],
uint8_t  bufferOut[],
size_t  size 
)
pure virtual

Encrypts the given data using AES-CBC algorithm.

Warning
Initialization vector has to be set before using this function.
Note
The content of the initialization vector is updated so that you can call the same function again on the next block(s) of data and get the same result as if it is encrypted in one call. This allows a "streaming" usage. If you need to retain the contents of the initialization vector, you should either save it manually or use the cipher module instead.
Parameters
dataInInput data which has to be encrypted.
bufferOutEncrypted data.
sizeSize of input data in bytes. it must be a multiple of the block size (16 Bytes).
Returns
State::Ok on success and State::Error on failure.

◆ resetInitializationVector()

virtual void semf::app::AesCbc::resetInitializationVector ( )
pure virtual

Resets the initialization vector.

◆ setInitializationVector()

virtual void semf::app::AesCbc::setInitializationVector ( const uint8_t  initializationVector[])
pure virtual

Sets the initialization vector.

Attention
The initialization vector must have the same size as the key.
Parameters
initializationVectorPointer to the address of the initialization vector (as binary).

◆ setKey()

virtual void semf::app::AesCbc::setKey ( const uint8_t  key[],
size_t  size 
)
pure virtual

Sets the AES key.

Parameters
keyPointer to the address of the key (as binary).
sizeSize of the key in bytes.
Warning
Only sizes of 128, 192, or 256 bits are supported.