TSDuck Version 3.16-1064 (TSDuck - The MPEG Transport Stream Toolkit)
ts::AES Class Reference

AES block cipher. More...

Inheritance diagram for ts::AES:
Collaboration diagram for ts::AES:

Public Member Functions

 AES ()
 Constructor.
 
virtual size_t blockSize () const override
 Size in bytes of the block used by the algorithm. More...
 
virtual bool decrypt (const void *cipher, size_t cipher_length, void *plain, size_t plain_maxsize, size_t *plain_length=nullptr) override
 Decrypt one block of data. More...
 
virtual bool decryptInPlace (void *data, size_t data_length, size_t *max_actual_length=nullptr)
 Decrypt one block of data in place. More...
 
virtual size_t defaultRounds () const override
 Default number of rounds for the algorithm. More...
 
virtual bool encrypt (const void *plain, size_t plain_length, void *cipher, size_t cipher_maxsize, size_t *cipher_length=nullptr) override
 Encrypt one block of data. More...
 
virtual bool encryptInPlace (void *data, size_t data_length, size_t *max_actual_length=nullptr)
 Encrypt one block of data in place. More...
 
virtual bool isValidKeySize (size_t size) const override
 Check if a size in bytes is a valid key size. More...
 
virtual size_t maxKeySize () const override
 Maximum key sizes in bytes. More...
 
virtual size_t maxRounds () const override
 Maximum number of rounds for the algorithm. More...
 
virtual size_t minKeySize () const override
 Minimum key sizes in bytes. More...
 
virtual size_t minRounds () const override
 Minimum number of rounds for the algorithm. More...
 
virtual UString name () const override
 Algorithm name (informational only). More...
 
virtual bool setKey (const void *key, size_t key_length, size_t rounds=0) override
 Schedule a new key. More...
 

Static Public Attributes

static const size_t BLOCK_SIZE = 16
 AES block size in bytes.
 
static const size_t DEFAULT_ROUNDS = 10
 AES default number of rounds, actually depends on key size.
 
static const size_t MAX_KEY_SIZE = 32
 AES maximum key size in bytes.
 
static const size_t MAX_ROUNDS = 14
 AES maximum number of rounds.
 
static const size_t MIN_KEY_SIZE = 16
 AES minimum key size in bytes.
 
static const size_t MIN_ROUNDS = 10
 AES minimum number of rounds.
 

Detailed Description

AES block cipher.

Member Function Documentation

◆ name()

virtual UString ts::AES::name ( ) const
inlineoverridevirtual

Algorithm name (informational only).

Returns
The algorithm name.

Implements ts::BlockCipher.

◆ blockSize()

virtual size_t ts::AES::blockSize ( ) const
inlineoverridevirtual

Size in bytes of the block used by the algorithm.

Returns
The size in bytes of the block used by the algorithm.

Implements ts::BlockCipher.

◆ minKeySize()

virtual size_t ts::AES::minKeySize ( ) const
inlineoverridevirtual

Minimum key sizes in bytes.

Returns
The minimum key sizes in bytes.

Implements ts::BlockCipher.

◆ maxKeySize()

virtual size_t ts::AES::maxKeySize ( ) const
inlineoverridevirtual

Maximum key sizes in bytes.

Returns
The maximum key sizes in bytes.

Implements ts::BlockCipher.

◆ isValidKeySize()

virtual bool ts::AES::isValidKeySize ( size_t  size) const
inlineoverridevirtual

Check if a size in bytes is a valid key size.

Parameters
[in]sizeSuggested key size in bytes.
Returns
True if size is a valid key size for the algorithm.

Implements ts::BlockCipher.

◆ minRounds()

virtual size_t ts::AES::minRounds ( ) const
inlineoverridevirtual

Minimum number of rounds for the algorithm.

Returns
The minimum number of rounds for the algorithm.

Implements ts::BlockCipher.

◆ maxRounds()

virtual size_t ts::AES::maxRounds ( ) const
inlineoverridevirtual

Maximum number of rounds for the algorithm.

Returns
The maximum number of rounds for the algorithm.

Implements ts::BlockCipher.

◆ defaultRounds()

virtual size_t ts::AES::defaultRounds ( ) const
inlineoverridevirtual

Default number of rounds for the algorithm.

Returns
The default number of rounds for the algorithm.

Implements ts::BlockCipher.

◆ setKey()

virtual bool ts::AES::setKey ( const void *  key,
size_t  key_length,
size_t  rounds = 0 
)
overridevirtual

Schedule a new key.

Parameters
[in]keyAddress of key value.
[in]key_lengthKey length in bytes.
[in]roundsRequested number of rounds. If zero, the default is used.
Returns
True on success, false on error.

Implements ts::BlockCipher.

◆ encrypt()

virtual bool ts::AES::encrypt ( const void *  plain,
size_t  plain_length,
void *  cipher,
size_t  cipher_maxsize,
size_t *  cipher_length = nullptr 
)
overridevirtual

Encrypt one block of data.

For pure block ciphers such as AES or DES, the plain text and cipher text must have the block size of the algorithm. For cipher chainings, the acceptable message sizes depend on the chaining mode.

Parameters
[in]plainAddress of plain text.
[in]plain_lengthPlain text length in bytes.
[out]cipherAddress of buffer for cipher text.
[in]cipher_maxsizeSize of cipher buffer.
[out]cipher_lengthReturned actual size of cipher text. Ignored if zero.
Returns
True on success, false on error.

Implements ts::BlockCipher.

◆ decrypt()

virtual bool ts::AES::decrypt ( const void *  cipher,
size_t  cipher_length,
void *  plain,
size_t  plain_maxsize,
size_t *  plain_length = nullptr 
)
overridevirtual

Decrypt one block of data.

For pure block ciphers such as AES or DES, the plain text and cipher text must have the block size of the algorithm. For cipher chainings, the acceptable message sizes depend on the chaining mode.

Parameters
[in]cipherAddress of cipher text.
[in]cipher_lengthCipher text length in bytes.
[out]plainAddress of buffer for plain text.
[in]plain_maxsizeSize of plain buffer.
[out]plain_lengthReturned actual size of plain text. Ignored if zero.
Returns
True on success, false on error.

Implements ts::BlockCipher.

◆ encryptInPlace()

virtual bool ts::BlockCipher::encryptInPlace ( void *  data,
size_t  data_length,
size_t *  max_actual_length = nullptr 
)
virtualinherited

Encrypt one block of data in place.

The default implementation is to call encrypt() and copy the data. A subclass may provide a more efficient implementation.

For pure block ciphers such as AES or DES, the plain text and cipher text must have the block size of the algorithm. For cipher chainings, the acceptable message sizes depend on the chaining mode.

Parameters
[in,out]dataAddress of data buffer to encrypt.
[in]data_lengthInput plain text length in bytes.
[in,out]max_actual_lengthOptional, ignored if zero. On input, contain the maximum size of the data buffer, which can be larger than data_length. On output, receive the actual size of the encrypted data. For pure block ciphers, this is the same as data_length. For cipher chainings with padding, this can be larger.
Returns
True on success, false on error.

Reimplemented in ts::DVBCSA2.

◆ decryptInPlace()

virtual bool ts::BlockCipher::decryptInPlace ( void *  data,
size_t  data_length,
size_t *  max_actual_length = nullptr 
)
virtualinherited

Decrypt one block of data in place.

The default implementation is to call decrypt() and copy the data. A subclass may provide a more efficient implementation.

For pure block ciphers such as AES or DES, the plain text and cipher text must have the block size of the algorithm. For cipher chainings, the acceptable message sizes depend on the chaining mode.

Parameters
[in,out]dataAddress of data buffer to decrypt.
[in]data_lengthInput cipher text length in bytes.
[in,out]max_actual_lengthOptional, ignored if zero. On input, contain the maximum size of the data buffer, which can be larger than data_length. On output, receive the actual size of the decrypted data. For pure block ciphers, this is the same as data_length. For cipher chainings with padding, this can be smaller.
Returns
True on success, false on error.

Reimplemented in ts::DVBCSA2.


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