|
CXI
|
Key store for external (MBK encrypted) keys. More...
Public Types | |
| enum | modes { MODE_EQUAL = 0 , MODE_GTEQ , MODE_GREATER , MODE_EQUAL = 0 , MODE_GTEQ , MODE_GREATER } |
| enum | modes { MODE_EQUAL = 0 , MODE_GTEQ , MODE_GREATER , MODE_EQUAL = 0 , MODE_GTEQ , MODE_GREATER } |
Public Member Functions | |
| KeyStore (const char *filename, int idx_len) | |
| KeyStore (Config &config, int idx_len) | |
| virtual | ~KeyStore (void) |
| int | getIndexLength () const |
| bool | findKey (ByteArray &startIndex, int mode, PropertyList *keyTemplate=NULL) |
| Key | getKey (ByteArray &index) |
| void | insertKey (int flags, ByteArray *index, const Key *key) |
| void | deleteKey (const ByteArray &index) |
Key store for external (MBK encrypted) keys.
On creation or import of a key on the CryptoServer, it can either be stored on the CryptoServer or exported as an external key (flag CXI_KEY_FLAG_EXTERNAL). In the latter case the key is encrypted with the CryptoServer's Master Backup Key (MBK). Such external keys can be stored in an external key database provided by this class.
Each record in a key store database consists of two fields:
The index fields of all records have the same length. This length has to be defined on creation of the database and can't be changed later.
Most commonly the unique key name (MD5 hash over name, group and specifier) with a length of 16 bytes is used as index (see Key::getUName()).
But the application may use any other index (e.g. a continuous serial number) to identify a key.
The length of the data field is variable.
The following example illustrates the usage of the KeyStore class:
| enum modes |
Modes for KeyStore::findKey
| enum modes |
Modes for KeyStore::findKey
| KeyStore | ( | const char * | filename, |
| int | idx_len | ||
| ) |
Opens a local key store database or creates it if not existing.
| filename | filename (including path) of keystore database |
| idx_len | size of database index. If the database should be created a non-zero value has to be given. The maximum size of the database index is 100. If a value of zero is given an existing database is opened and the length of the index is read from the database. |
Note:
| cxi::Exception | if database can't be opened |
Opens a local key store database or creates it if not existing.
| config | Configuration object. The following key names will be recognized:
| ||||||||
| idx_len | size of database index. If the database should be created a non-zero value has to be given. The maximum size of the database index is 100. If a value of zero is given an existing database is opened and the length of the index is read from the database. |
Note:
| cxi::Exception | if configuration doesn't contain a KeyStore entry or if database can't be opened |
|
virtual |
Closes key store database
| int getIndexLength | ( | ) | const |
Returns the length of the database index.
| bool findKey | ( | ByteArray & | startIndex, |
| int | mode, | ||
| PropertyList * | keyTemplate = NULL |
||
| ) |
Finds a key with the given properties. Call the function multiple times to list all keys (with the desired properties).
| startIndex | Index to start search. |
| mode | Search mode:
|
| keyTemplate | Optional list of properties the desired key should match. |
| cxi::Exception |
Returns the key with the given index.
| index | Index of key to be retrieved. |
| cxi::Exception | if key does not exist. |
Inserts a key into the key store. The key will be stored under the given index.
| flags | CXI_KEY_FLAG_OVERWRITE, if an existing key should be overwritten. |
| index | Database index for the key to be inserted. If an empty ByteArray is given, the first free index will be used and the index value will be updated with the actual value. |
| key | Key to be inserted. |
| cxi::Exception |
| void deleteKey | ( | const ByteArray & | index | ) |
Deletes the key with the given index.
| index | Index of key to be deleted. |
| cxi::Exception | if key does not exist |