Triple-DES block cipher. More...
Public Member Functions | |
TDES () | |
Constructor. | |
virtual size_t | blockSize () const override |
Size in bytes of the block used by the algorithm. More... | |
int | cipherId () const |
Get the "cipher id" value, as previously stored by the application. More... | |
bool | decrypt (const void *cipher, size_t cipher_length, void *plain, size_t plain_maxsize, size_t *plain_length=nullptr) |
Decrypt one block of data. More... | |
bool | decryptInPlace (void *data, size_t data_length, size_t *max_actual_length=nullptr) |
Decrypt one block of data in place. More... | |
size_t | decryptionCount () const |
Get the number of times the current key was used for decryption. More... | |
size_t | decryptionMax () const |
Get the maximum number of times a key should be used for decryption. More... | |
virtual size_t | defaultRounds () const override |
Default number of rounds for the algorithm. More... | |
bool | encrypt (const void *plain, size_t plain_length, void *cipher, size_t cipher_maxsize, size_t *cipher_length=nullptr) |
Encrypt one block of data. More... | |
bool | encryptInPlace (void *data, size_t data_length, size_t *max_actual_length=nullptr) |
Encrypt one block of data in place. More... | |
size_t | encryptionCount () const |
Get the number of times the current key was used for encryption. More... | |
size_t | encryptionMax () const |
Get the maximum number of times a key should be used for encryption. More... | |
bool | getKey (ByteBlock &key) const |
Get the current key. 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... | |
void | setAlertHandler (BlockCipherAlertInterface *handler) |
Set the handler to be notified on alert. More... | |
void | setCipherId (int id) |
Set some arbitrary "cipher id" value. More... | |
void | setDecryptionMax (size_t count) |
Set the maximum number of times a key should be used for decryption. More... | |
void | setEncryptionMax (size_t count) |
Set the maximum number of times a key should be used for encryption. More... | |
bool | setKey (const void *key, size_t key_length, size_t rounds=0) |
Schedule a new key. More... | |
Static Public Attributes | |
static constexpr size_t | BLOCK_SIZE = 8 |
TDES block size in bytes. | |
static constexpr size_t | KEY_SIZE = 24 |
TDES key size in bytes. | |
static constexpr size_t | ROUNDS = 16 |
TDES number of rounds. | |
static constexpr size_t | UNLIMITED = std::numeric_limits<size_t>::max() |
A constant meaning "may use a key an unlimited number of times". | |
Protected Member Functions | |
virtual bool | decryptImpl (const void *cipher, size_t cipher_length, void *plain, size_t plain_maxsize, size_t *plain_length) override |
Decrypt one block of data (implementation of algorithm-specific part). More... | |
virtual bool | decryptInPlaceImpl (void *data, size_t data_length, size_t *max_actual_length) |
Decrypt one block of data in place (implementation of algorithm-specific part). More... | |
virtual bool | encryptImpl (const void *plain, size_t plain_length, void *cipher, size_t cipher_maxsize, size_t *cipher_length) override |
Encrypt one block of data (implementation of algorithm-specific part). More... | |
virtual bool | encryptInPlaceImpl (void *data, size_t data_length, size_t *max_actual_length) |
Encrypt one block of data in place (implementation of algorithm-specific part). More... | |
virtual bool | setKeyImpl (const void *key, size_t key_length, size_t rounds) override |
Schedule a new key (implementation of algorithm-specific part). More... | |
Triple-DES block cipher.
|
overridevirtual |
|
overridevirtual |
Size in bytes of the block used by the algorithm.
Implements ts::BlockCipher.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Check if a size in bytes is a valid key size.
[in] | size | Suggested key size in bytes. |
Implements ts::BlockCipher.
|
overridevirtual |
Minimum number of rounds for the algorithm.
Implements ts::BlockCipher.
|
overridevirtual |
Maximum number of rounds for the algorithm.
Implements ts::BlockCipher.
|
overridevirtual |
Default number of rounds for the algorithm.
Implements ts::BlockCipher.
|
overrideprotectedvirtual |
Schedule a new key (implementation of algorithm-specific part).
[in] | key | Address of key value. |
[in] | key_length | Key length in bytes. |
[in] | rounds | Requested number of rounds. If zero, the default is used. |
Implements ts::BlockCipher.
|
overrideprotectedvirtual |
Encrypt one block of data (implementation of algorithm-specific part).
[in] | plain | Address of plain text. |
[in] | plain_length | Plain text length in bytes. |
[out] | cipher | Address of buffer for cipher text. |
[in] | cipher_maxsize | Size of cipher buffer. |
[out] | cipher_length | Returned actual size of cipher text. Ignored if zero. |
Implements ts::BlockCipher.
|
overrideprotectedvirtual |
Decrypt one block of data (implementation of algorithm-specific part).
[in] | cipher | Address of cipher text. |
[in] | cipher_length | Cipher text length in bytes. |
[out] | plain | Address of buffer for plain text. |
[in] | plain_maxsize | Size of plain buffer. |
[out] | plain_length | Returned actual size of plain text. Ignored if zero. |
Implements ts::BlockCipher.
|
inherited |
Schedule a new key.
[in] | key | Address of key value. |
[in] | key_length | Key length in bytes. |
[in] | rounds | Requested number of rounds. If zero, the default is used. |
|
inherited |
Get the current key.
[out] | key | Current key value. |
|
inherited |
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.
[in] | plain | Address of plain text. |
[in] | plain_length | Plain text length in bytes. |
[out] | cipher | Address of buffer for cipher text. |
[in] | cipher_maxsize | Size of cipher buffer. |
[out] | cipher_length | Returned actual size of cipher text. Ignored if zero. |
|
inherited |
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.
[in] | cipher | Address of cipher text. |
[in] | cipher_length | Cipher text length in bytes. |
[out] | plain | Address of buffer for plain text. |
[in] | plain_maxsize | Size of plain buffer. |
[out] | plain_length | Returned actual size of plain text. Ignored if zero. |
|
inherited |
Encrypt one block of data in place.
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.
[in,out] | data | Address of data buffer to encrypt. |
[in] | data_length | Input plain text length in bytes. |
[in,out] | max_actual_length | Optional, 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. |
|
inherited |
Decrypt one block of data in place.
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.
[in,out] | data | Address of data buffer to decrypt. |
[in] | data_length | Input cipher text length in bytes. |
[in,out] | max_actual_length | Optional, 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. |
|
inlineinherited |
Get the number of times the current key was used for encryption.
|
inlineinherited |
Get the number of times the current key was used for decryption.
|
inlineinherited |
Set the maximum number of times a key should be used for encryption.
The default initial value is UNLIMITED.
[in] | count | The maximum number of times a key should be used for encryption. |
|
inlineinherited |
Set the maximum number of times a key should be used for decryption.
The default initial value is UNLIMITED.
[in] | count | The maximum number of times a key should be used for decryption. |
|
inlineinherited |
Get the maximum number of times a key should be used for encryption.
|
inlineinherited |
Get the maximum number of times a key should be used for decryption.
|
inlineinherited |
Set the handler to be notified on alert.
Only one handler can be set at a time.
[in] | handler | Handler to set. Use a null pointer to remove the handler. |
|
inlineinherited |
Set some arbitrary "cipher id" value.
This value is chosen and set by the application and can be retrieved later. The cipher id is not interpreted by the block cipher engine, it is only stored for the application. The initial value of a cipher id is zero.
[in] | id | Application-defined cipher id to assign. |
|
inlineinherited |
Get the "cipher id" value, as previously stored by the application.
|
protectedvirtualinherited |
Encrypt one block of data in place (implementation of algorithm-specific part).
The default implementation is to call encryptImpl() and copy the data. A subclass may provide a more efficient implementation.
[in,out] | data | Address of data buffer to encrypt. |
[in] | data_length | Input plain text length in bytes. |
[in,out] | max_actual_length | Optional, 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. |
Reimplemented in ts::DVBCSA2.
|
protectedvirtualinherited |
Decrypt one block of data in place (implementation of algorithm-specific part).
The default implementation is to call decryptImpl() and copy the data. A subclass may provide a more efficient implementation.
[in,out] | data | Address of data buffer to decrypt. |
[in] | data_length | Input cipher text length in bytes. |
[in,out] | max_actual_length | Optional, 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. |
Reimplemented in ts::DVBCSA2.