DVS 042 cipher block chaining mode. More...
Public Member Functions | |
DVS042 () | |
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 | maxIVSize () const |
Get the maximum IV sizes in bytes. 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 | minIVSize () const |
Get the minimum IV sizes in bytes. More... | |
virtual size_t | minKeySize () const override |
Minimum key sizes in bytes. More... | |
virtual size_t | minMessageSize () const override |
Get the minimum message size. 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 | residueAllowed () const override |
Check if the chaining mode can process residue after the last multiple of the block size. 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... | |
virtual bool | setIV (const void *iv_data, size_t iv_length) override |
Set a new initialization vector. More... | |
bool | setKey (const void *key, size_t key_length, size_t rounds=0) |
Schedule a new key. More... | |
virtual bool | setShortIV (const void *iv_data, size_t iv_length) |
Set a new initialization vector for short blocks. More... | |
Static Public Attributes | |
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... | |
Protected Attributes | |
BlockCipher * | algo |
An instance of the block cipher. | |
const size_t | block_size |
Shortcut for algo->blockSize(). | |
ByteBlock | iv |
Current initialization vector. | |
const size_t | iv_max_size |
IV max size in bytes. | |
const size_t | iv_min_size |
IV min size in bytes. | |
ByteBlock | shortIV |
Current initialization vector for short blocks. | |
ByteBlock | work |
Temporary working buffer. | |
DVS 042 cipher block chaining mode.
DVS 042 has been renamed as "ANSI/SCTE 52 2003". It used to be available at http://www.scte.org/documents/pdf/ANSISCTE522003DVS042.pdf This file is no longer online. The next iteration of this standard is now "ANSI/SCTE 52 2008", available at http://www.scte.org/documents/pdf/Standards/ANSI_SCTE%2052%202008.pdf
The only noticeable difference between the two versions is the handling of messages shorter than the block size. In the 2003 (DVS 042) version, the same IV (called "whitener" in the standard) is used for long and short messages. In the 2008 version, a different "whitener2" must be used for messages shorter than the block size.
The ATIS-0800006 standard (IDSA) uses the same chaining mode and residue processing as DVS-042 but is based on AES instead of DES.
CIPHER | A subclass of ts::BlockCipher, the underlying block cipher. |
|
virtual |
Set a new initialization vector for short blocks.
The method setIV() sets the IV for long blocks (longer than the block size) and short blocks (shorter than the block size). The latter can then be overwritten using setShortIV().
[in] | iv_data | Address of IV. |
[in] | iv_length | IV length in bytes. |
|
overridevirtual |
Get the minimum message size.
Shorter data cannot be ciphered in this mode.
Implements ts::CipherChaining.
|
overridevirtual |
Check if the chaining mode can process residue after the last multiple of the block size.
Implements ts::CipherChaining.
|
overridevirtual |
Set a new initialization vector.
[in] | iv_data | Address of IV. |
[in] | iv_length | IV length in bytes. |
Reimplemented from ts::CipherChaining.
|
overridevirtual |
|
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.
|
overridevirtualinherited |
Size in bytes of the block used by the algorithm.
Implements ts::BlockCipher.
Reimplemented in ts::DVBCSA2.
|
overridevirtualinherited |
Minimum key sizes in bytes.
Implements ts::BlockCipher.
Reimplemented in ts::DVBCSA2.
|
overridevirtualinherited |
Maximum key sizes in bytes.
Implements ts::BlockCipher.
Reimplemented in ts::DVBCSA2.
|
overridevirtualinherited |
Check if a size in bytes is a valid key size.
[in] | size | Suggested key size in bytes. |
Implements ts::BlockCipher.
Reimplemented in ts::DVBCSA2.
|
overridevirtualinherited |
Minimum number of rounds for the algorithm.
Implements ts::BlockCipher.
Reimplemented in ts::DVBCSA2.
|
overridevirtualinherited |
Maximum number of rounds for the algorithm.
Implements ts::BlockCipher.
Reimplemented in ts::DVBCSA2.
|
overridevirtualinherited |
Default number of rounds for the algorithm.
Implements ts::BlockCipher.
Reimplemented in ts::DVBCSA2.
|
virtualinherited |
Get the minimum IV sizes in bytes.
Reimplemented in ts::DVBCSA2.
|
virtualinherited |
Get the maximum IV sizes in bytes.
Reimplemented in ts::DVBCSA2.
|
overrideprotectedvirtualinherited |
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.
Reimplemented in ts::DVBCSA2.
|
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.