TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
Definition of a basic and non-secure implementation of a symmetric key table. More...
#include <tsKeyTable.h>
Public Member Functions | |
KeyTable ()=default | |
Constructor. | |
void | clear () |
Clear the content of the key table. | |
bool | empty () const |
Check if the key table is empty. | |
bool | getKey (const ByteBlock &id, ByteBlock &value) const |
Get the value of a key from the table. | |
bool | getKey (const UString &id, ByteBlock &value) const |
Get the value of a key from the table. | |
bool | hasKey (const ByteBlock &id) const |
Check the presence of a key in the table. | |
bool | hasKey (const UString &id) const |
Check the presence of a key in the table. | |
bool | loadFile (Report &report, const UString &filename, bool replace, size_t id_size, size_t value_size) |
Load all keys from an XML file and add them in the key table. | |
bool | loadXML (Report &report, const UString &text, bool replace, size_t id_size, size_t value_size) |
Load all keys from an XML string and add them in the key table. | |
bool | setKey (BlockCipher &cipher, const ByteBlock &id) const |
Retrieve a key in the table and initialize a block cipher engine. | |
bool | setKey (BlockCipher &cipher, const UString &id) const |
Retrieve a key in the table and initialize a block cipher engine. | |
size_t | size () const |
Get the number of keys in the table. | |
bool | storeKey (const ByteBlock &id, const ByteBlock &value, bool replace=true) |
Store a key in the table. | |
bool | storeKey (const UString &id, const UString &value, bool replace=true) |
Store a key in the table. | |
Definition of a basic and non-secure implementation of a symmetric key table.
Each key is identified using a binary key id. The key value is a byte block. There is no constraint on the key id and value sizes, it depends on the application.
A key table can be loaded from an XML file with the following structure as example:
|
inline |
Check if the key table is empty.
|
inline |
Get the number of keys in the table.
bool ts::KeyTable::hasKey | ( | const ByteBlock & | id | ) | const |
Check the presence of a key in the table.
[in] | id | The key id to search. |
bool ts::KeyTable::hasKey | ( | const UString & | id | ) | const |
Check the presence of a key in the table.
[in] | id | The key id to search as a string of hexadecimal digits. |
Store a key in the table.
[in] | id | The key id to load. |
[in] | value | The key value to load. |
[in] | replace | If true, allow the replacement of an existing key. |
Store a key in the table.
[in] | id | The key id to load as a string of hexadecimal digits. |
[in] | value | The key value to load as a string of hexadecimal digits. |
[in] | replace | If true, allow the replacement of an existing key. |
Get the value of a key from the table.
[in] | id | The key id to retrieve. |
[out] | value | The returned key value. |
Get the value of a key from the table.
[in] | id | The key id to retrieve as a string of hexadecimal digits. |
[out] | value | The returned key value. |
bool ts::KeyTable::setKey | ( | BlockCipher & | cipher, |
const ByteBlock & | id | ||
) | const |
Retrieve a key in the table and initialize a block cipher engine.
[in,out] | cipher | The block cipher engine into which the key shall be loaded. |
[in] | id | The key id to retrieve. |
bool ts::KeyTable::setKey | ( | BlockCipher & | cipher, |
const UString & | id | ||
) | const |
Retrieve a key in the table and initialize a block cipher engine.
[in,out] | cipher | The block cipher engine into which the key shall be loaded. |
[in] | id | The key id to retrieve as a string of hexadecimal digits. |
bool ts::KeyTable::loadFile | ( | Report & | report, |
const UString & | filename, | ||
bool | replace, | ||
size_t | id_size, | ||
size_t | value_size | ||
) |
Load all keys from an XML file and add them in the key table.
[in,out] | report | Where to report errors. |
[in] | filename | The name of the file to load. |
[in] | replace | If true, allow the replacement of existing keys. |
[in] | id_size | If not zero, all key ids must have this size in bytes. |
[in] | value_size | If not zero, all key values must have this size in bytes. |
bool ts::KeyTable::loadXML | ( | Report & | report, |
const UString & | text, | ||
bool | replace, | ||
size_t | id_size, | ||
size_t | value_size | ||
) |
Load all keys from an XML string and add them in the key table.
[in,out] | report | Where to report errors. |
[in] | text | The XML text to parse. |
[in] | replace | If true, allow the replacement of existing keys. |
[in] | id_size | If not zero, all key ids must have this size in bytes. |
[in] | value_size | If not zero, all key values must have this size in bytes. |