|
CXI
|
Command interface to CXI firmware module. Handles all communication with the CryptoServer. More...
Classes | |
| struct | CLUSTER_ERROR |
| Defines an additional error code/mask that causes the cluster to switch to another device instead of returning to the caller. More... | |
Construction / Destruction | |
| Cxi (std::vector< std::string > devices, int timeout, int ctimeout, int fallback_interval, cxi::ByteArray *vendorCert, cxi::ByteArray *operatorCert, cxi::ByteArray *customerCert) | |
| Opens a connection to a CryptoServer cluster. More... | |
| Cxi (const char *device, int timeout=60000, int ctimeout=5000) | |
| Cxi (const char **devices, int ndevs, int timeout=60000, int ctimeout=5000, int fallback_interval=0) | |
| Cxi (std::vector< std::string > devices, int timeout=60000, int ctimeout=5000, int fallback_interval=0) | |
| Cxi (Config &config) | |
| virtual | ~Cxi (void) |
| void | set_msg_handler (void(*p_msg_func)(unsigned char *p_msg, int l_msg)) |
| void | close (void) |
| Cxi (std::vector< std::string > devices, int timeout, int ctimeout, int fallback_interval, cxi::ByteArray *vendorCert, cxi::ByteArray *operatorCert, cxi::ByteArray *customerCert) | |
| Cxi (const char *device, int timeout=60000, int ctimeout=5000) | |
| Cxi (const char **devices, int ndevs, int timeout=60000, int ctimeout=5000, int fallback_interval=0) | |
| Cxi (std::vector< std::string > devices, int timeout=60000, int ctimeout=5000, int fallback_interval=0) | |
| Cxi (Config &config) | |
| virtual | ~Cxi (void) |
| void | set_msg_handler (void(*p_msg_func)(unsigned char *p_msg, int l_msg)) |
| void | close (void) |
Miscellaneous Functions | |
| void | exec (unsigned int fc, unsigned int sfc, unsigned char *p_cmd, unsigned int l_cmd, unsigned char **pp_answ, unsigned int *p_l_answ, CLUSTER_ERROR *errlist=NULL, unsigned int err_ct=0) |
| void | free_answ (unsigned char *&p_answ) |
| int | get_fw_version (void) |
| void | exec (unsigned int fc, unsigned int sfc, unsigned char *p_cmd, unsigned int l_cmd, unsigned char **pp_answ, unsigned int *p_l_answ, CLUSTER_ERROR *errlist=NULL, unsigned int err_ct=0) |
| void | free_answ (unsigned char *&p_answ) |
| int | get_fw_version (void) |
| static int | get_version (void) |
| static int | get_version (void) |
Authentication | |
| void | logon_sign (const char *user, const char *key, const char *password=0, bool keep_alive=false) |
| void | logon_pass (const char *user, const char *password, bool keep_alive=false) |
| void | logoff (void) |
| int | get_auth_state (void) |
| int | get_auth_state (const std::string &group) |
| void | logon_sign (const char *user, const char *key, const char *password=0, bool keep_alive=false) |
| void | logon_pass (const char *user, const char *password, bool keep_alive=false) |
| void | logoff (void) |
| int | get_auth_state (void) |
| int | get_auth_state (const std::string &group) |
Key Management | |
| KeyList | key_list (PropertyList *keyTemplate=NULL) |
| KeyList | key_list (PropertyList &keyTemplate) |
| Key | key_generate (int flags, const PropertyList &keyTemplate) |
| Key | key_generate (int flags, const PropertyList &keyTemplate, int mech) |
| Key | key_open (int flags, PropertyList &keyTemplate) |
| void | key_delete (const PropertyList &keyTemplate) |
| void | key_delete (Key &key) |
| PropertyList | key_prop_get (const Key &key, int properties[], int nprops) |
| Key | key_prop_set (const Key &key, const PropertyList &propList) |
| Key | key_set_fips_usage (const Key &key, unsigned int usage) |
| ByteArray | key_export (int type, Key &key, Key *exportKey, int mech=-1) |
| ByteArray | key_export (int type, Key &key, Key &exportKey, int mech=-1) |
| Key | key_import (int flags, int type, const PropertyList &keyTemplate, const ByteArray &keyBlob, Key *importKey, int mech=-1) |
| Key | key_import (int flags, int type, const PropertyList &keyTemplate, const ByteArray &keyBlob, Key &importKey, int mech=-1) |
| PropertyList | key_dsa_xgen (int psize, int qsize=160, int mech=-1) |
| PropertyList | key_dsa_pqgen (MechanismParameter &mechParam) |
| PropertyList | key_dsa_ggen (PropertyList &propList, const MechanismParameter &mechParam) |
| Key | key_backup (Key &key) |
| Key | key_restore (int flags, Key &key, PropertyList *keyTemplate=NULL) |
| Key | key_restore (int flags, Key &key, PropertyList &keyTemplate) |
| std::vector< ByteArray > | keystore_find (KeyStore &store, PropertyList *key_template=NULL) |
| Key | keystore_get (KeyStore &store, ByteArray &index) |
| void | keystore_insert (KeyStore &store, int flags, ByteArray *index, const Key *key) |
| void | keystore_delete (KeyStore &store, const ByteArray &index) |
| KeyList | key_list (PropertyList *keyTemplate=NULL) |
| KeyList | key_list (PropertyList &keyTemplate) |
| Key | key_generate (int flags, const PropertyList &keyTemplate) |
| Key | key_generate (int flags, const PropertyList &keyTemplate, int mech) |
| Key | key_open (int flags, PropertyList &keyTemplate) |
| void | key_delete (const PropertyList &keyTemplate) |
| void | key_delete (Key &key) |
| PropertyList | key_prop_get (const Key &key, int properties[], int nprops) |
| Key | key_prop_set (const Key &key, const PropertyList &propList) |
| Key | key_set_fips_usage (const Key &key, unsigned int usage) |
| ByteArray | key_export (int type, Key &key, Key *exportKey, int mech=-1) |
| ByteArray | key_export (int type, Key &key, Key &exportKey, int mech=-1) |
| Key | key_import (int flags, int type, const PropertyList &keyTemplate, const ByteArray &keyBlob, Key *importKey, int mech=-1) |
| Key | key_import (int flags, int type, const PropertyList &keyTemplate, const ByteArray &keyBlob, Key &importKey, int mech=-1) |
| PropertyList | key_dsa_xgen (int psize, int qsize=160, int mech=-1) |
| PropertyList | key_dsa_pqgen (MechanismParameter &mechParam) |
| PropertyList | key_dsa_ggen (PropertyList &propList, const MechanismParameter &mechParam) |
| Key | key_backup (Key &key) |
| Key | key_restore (int flags, Key &key, PropertyList *keyTemplate=NULL) |
| Key | key_restore (int flags, Key &key, PropertyList &keyTemplate) |
| std::vector< ByteArray > | keystore_find (KeyStore &store, PropertyList *key_template=NULL) |
| Key | keystore_get (KeyStore &store, ByteArray &index) |
| void | keystore_insert (KeyStore &store, int flags, ByteArray *index, const Key *key) |
| void | keystore_delete (KeyStore &store, const ByteArray &index) |
Cryptography | |
| ByteArray | crypt (int flags, const Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray *iv=NULL, ByteArray *tag=NULL, const ByteArray *tag_in=NULL) |
| ByteArray | crypt (int flags, const Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray &iv, ByteArray &tag, const ByteArray &tag_in) |
| ByteArray | crypt (int flags, const Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray &iv, ByteArray &tag) |
| ByteArray | crypt (int flags, const Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray &iv) |
| unsigned int | getBufferedDataSize (const ByteArray &iv) |
| std::vector< ByteArray > | bulk_crypt (const Key &key, const MechanismParameter &mechParam, const std::vector< ByteArray > &data) |
| ByteArray | sign (int flags, Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray *iv=NULL) |
| ByteArray | sign (int flags, Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray &iv) |
| std::vector< ByteArray > | bulk_sign (Key &key, const MechanismParameter &mechParam, const std::vector< ByteArray > &data) |
| bool | verify (int flags, Key &key, const MechanismParameter &mechParam, ByteArray &data, const ByteArray *signature, ByteArray *iv=NULL) |
| bool | verify (int flags, Key &key, const MechanismParameter &mechParam, ByteArray &data, const ByteArray &signature, ByteArray *iv=NULL) |
| bool | verify (int flags, Key &key, const MechanismParameter &mechParam, ByteArray &data, const ByteArray &signature, ByteArray &iv) |
| bool | verify (int flags, Key &key, const MechanismParameter &mechParam, ByteArray &data, const ByteArray *signature, ByteArray &iv) |
| ByteArray | rnd_gen (int len, int mech=-1) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray *data, const ByteArray *info=NULL, const Key *key=NULL) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray &data, const ByteArray &info, const Key &key) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray &data, const ByteArray *info, const Key &key) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray &data, const ByteArray &info) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray *data, const ByteArray &info) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray &data) |
| ByteArray | secret_agree (int flags, const Key &privateKey, const Key &publicKey, const MechanismParameter *mechParam=NULL) |
| ByteArray | secret_agree (int flags, const Key &privateKey, const Key &publicKey, const MechanismParameter &mechParam) |
| ByteArray | crypt (int flags, const Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray *iv=NULL, ByteArray *tag=NULL, const ByteArray *tag_in=NULL) |
| ByteArray | crypt (int flags, const Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray &iv, ByteArray &tag, const ByteArray &tag_in) |
| ByteArray | crypt (int flags, const Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray &iv, ByteArray &tag) |
| ByteArray | crypt (int flags, const Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray &iv) |
| unsigned int | getBufferedDataSize (const ByteArray &iv) |
| std::vector< ByteArray > | bulk_crypt (const Key &key, const MechanismParameter &mechParam, const std::vector< ByteArray > &data) |
| ByteArray | sign (int flags, Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray *iv=NULL) |
| ByteArray | sign (int flags, Key &key, const MechanismParameter &mechParam, const ByteArray &data, ByteArray &iv) |
| std::vector< ByteArray > | bulk_sign (Key &key, const MechanismParameter &mechParam, const std::vector< ByteArray > &data) |
| bool | verify (int flags, Key &key, const MechanismParameter &mechParam, ByteArray &data, const ByteArray *signature, ByteArray *iv=NULL) |
| bool | verify (int flags, Key &key, const MechanismParameter &mechParam, ByteArray &data, const ByteArray &signature, ByteArray *iv=NULL) |
| bool | verify (int flags, Key &key, const MechanismParameter &mechParam, ByteArray &data, const ByteArray &signature, ByteArray &iv) |
| bool | verify (int flags, Key &key, const MechanismParameter &mechParam, ByteArray &data, const ByteArray *signature, ByteArray &iv) |
| ByteArray | rnd_gen (int len, int mech=-1) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray *data, const ByteArray *info=NULL, const Key *key=NULL) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray &data, const ByteArray &info, const Key &key) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray &data, const ByteArray *info, const Key &key) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray &data, const ByteArray &info) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray *data, const ByteArray &info) |
| ByteArray | hash_compute (int flags, const MechanismParameter &mechParam, const ByteArray &data) |
| ByteArray | secret_agree (int flags, const Key &privateKey, const Key &publicKey, const MechanismParameter *mechParam=NULL) |
| ByteArray | secret_agree (int flags, const Key &privateKey, const Key &publicKey, const MechanismParameter &mechParam) |
Command interface to CXI firmware module. Handles all communication with the CryptoServer.
The following example illustrates the usage of the Cxi class:
| Cxi | ( | std::vector< std::string > | devices, |
| int | timeout, | ||
| int | ctimeout, | ||
| int | fallback_interval, | ||
| cxi::ByteArray * | vendorCert, | ||
| cxi::ByteArray * | operatorCert, | ||
| cxi::ByteArray * | customerCert | ||
| ) |
Opens a connection to a CryptoServer cluster.
| devices | list of device specifier of CryptoServer, e.g.:
|
| timeout | timeout in milliseconds the API waits for an answer on command execution |
| ctimeout | timeout the API waits on attempt to connect to a Cryptoserver |
| fallback_interval | time in seconds the API waits before it tries to reconnect to the primary device (first device in the list) after having switched to another device due to a communication error. |
| vendorCert | path to the vendor certificate |
| operatorCert | path to the operator certificate |
| customerCert | path to the customer certificate |
| cxi::Exception | if no connection to any device can be established. |
| Cxi | ( | const char * | device, |
| int | timeout = 60000, |
||
| int | ctimeout = 5000 |
||
| ) |
Opens a connection to the CryptoServer.
| device | device specifier of CryptoServer, e.g.:
|
| timeout | timeout in milliseconds the API waits for an answer on command execution |
| ctimeout | timeout the API waits on attempt to connect to a Cryptoserver |
| cxi::Exception | if connection can't be established. |
| Cxi | ( | const char ** | devices, |
| int | ndevs, | ||
| int | timeout = 60000, |
||
| int | ctimeout = 5000, |
||
| int | fallback_interval = 0 |
||
| ) |
Opens a connection to a CryptoServer cluster.
| devices | array of device specifier of CryptoServer, e.g.:
|
| ndevs | number of devices in given array |
| timeout | timeout in milliseconds the API waits for an answer on command execution |
| ctimeout | timeout the API waits on attempt to connect to a Cryptoserver |
| fallback_interval | time in seconds the API waits before it tries to reconnect to the primary device (first device in the list) after having switched to another device due to a communication error. |
| cxi::Exception | if no connection to any device can be established. |
| Cxi | ( | std::vector< std::string > | devices, |
| int | timeout = 60000, |
||
| int | ctimeout = 5000, |
||
| int | fallback_interval = 0 |
||
| ) |
Opens a connection to a CryptoServer cluster.
| devices | list of device specifier of CryptoServer, e.g.:
|
| timeout | timeout in milliseconds the API waits for an answer on command execution |
| ctimeout | timeout the API waits on attempt to connect to a Cryptoserver |
| fallback_interval | time in seconds the API waits before it tries to reconnect to the primary device (first device in the list) after having switched to another device due to a communication error. |
| cxi::Exception | if no connection to any device can be established. |
Opens a connection to a CryptoServer cluster according to the given configuration object.
| config | Configuration object. The following key names will be recognized:
|
| cxi::Exception | if configuration doesn't contain a device entry or if no connection to any device can be established. |
|
virtual |
Terminates secure messaging and closes connection to the Cryptoserver
| void exec | ( | unsigned int | fc, |
| unsigned int | sfc, | ||
| unsigned char * | p_cmd, | ||
| unsigned int | l_cmd, | ||
| unsigned char ** | pp_answ, | ||
| unsigned int * | p_l_answ, | ||
| CLUSTER_ERROR * | errlist = NULL, |
||
| unsigned int | err_ct = 0 |
||
| ) |
Sends a generic command to the CryptoServer and receives the answer.
| fc | Function Code (==Module ID) of the target firmware module |
| sfc | Sub Function Code of the function to be called |
| p_cmd | pointer to command to be send |
| l_cmd | length of command to be send |
| pp_answ | pointer to answer buffer (memory allocation) |
| p_l_answ | pointer to length of answer data |
| errlist | additional list of error codes the cluster should not reply to the API but switch to another device or 'NULL' |
| err_ct | dimension of error list or zero |
| cxi::Exception |
| void free_answ | ( | unsigned char *& | p_answ | ) |
Frees answer buffer allocated by a call to Cxi::exec.
| p_answ | pointer to buffer to be freed |
|
static |
Inquires version of CXI API library.
| int get_fw_version | ( | void | ) |
| void logon_sign | ( | const char * | user, |
| const char * | key, | ||
| const char * | password = 0, |
||
| bool | keep_alive = false |
||
| ) |
Authenticates to the CryptoServer and creates an encrypted messaging tunnel to the CryptoServer (secure messaging).
| user | name (C-string) of user to be logged on |
| key | key token (C-string) to be used for signature creation:
|
| password | password (C-string) of the key file |
| keep_alive | keep current session alive and prevent it from expiring after 15 minutes idle time. |
| cxi::Exception |
| void logon_pass | ( | const char * | user, |
| const char * | password, | ||
| bool | keep_alive = false |
||
| ) |
Authenticates to the CryptoServer and creates an encrypted messaging tunnel to the CryptoServer (secure messaging).
| user | name (C-string) of user to be logged on |
| password | password (C-string) |
| keep_alive | keep current session alive and prevent it from expiring after 15 minutes idle time. |
| cxi::Exception |
| void logoff | ( | void | ) |
Terminates secure messaging.
| int get_auth_state | ( | void | ) |
Inquires the resulting authentication state of the current secure messaging session.
This value is evaluated as the sum of all users currently logged on to the secure messaging session.
| cxi::Exception |
| KeyList key_list | ( | PropertyList * | keyTemplate = NULL | ) |
Enumerates the keys, which are currently stored in the CXI database on the CryptoServer.
The returned key list contains those keys that
(1) the user is allowed to access
(2) match the given search criteria
1)
The user is allowed to access keys according to his group membership and 'global' keys without a group property.
2)
A property list may be given to specify a partial set of keys to be listed. Thereby only those keys are listed that match the given property values. If no property list is given keys are not filtered.
| keyTemplate | List of properties that define search criteria for the keys to be listed. Keys that dont match the given criteria will not be listed. The following example illustrates how to list only RSA keys with 2048 bits: Property List := {
CXI_PROP_KEY_SIZE := 2048
}
Creates and parses property values of different types. Definition: sw/cxi_api_c/def/property.h:19 #define CXI_PROP_KEY_ALGO Algorithm specifier, see Algorithm Specifier [int]. Definition: fw/cxi/def/cxi_defs.h:42 #define CXI_PROP_KEY_SIZE Key size in bits [int]. Definition: fw/cxi/def/cxi_defs.h:43 |
| cxi::Exception |
| Key key_generate | ( | int | flags, |
| const PropertyList & | keyTemplate | ||
| ) |
Generates new keys or domain parameters according on the given template (property list).
Dependant on the given flags the key is either stored in the internal database and a key handle
is returned or the key is not stored in the database but a MBK encrypted key backup blob is returned.
| flags | XOR combination of:
|
| keyTemplate | Key properties to be set for the new key (see Key Properties). The following properties are mandatory for the key template:
|
| mech | XOR combination of:
|
| cxi::Exception |
| Key key_open | ( | int | flags, |
| PropertyList & | keyTemplate | ||
| ) |
Opens a key in the internal database of the CryptoServer and returns either a key handle or a key blob.
| flags | Command flags:
|
| keyTemplate | Property list, which specifies the key to be opened. The key is identified by the following properties:
|
The wildcards are not supported for the attributes listed above. If name and group are using default values (i.e. empty string) they have not to be set within provided property list (keyTemplate).
| cxi::Exception |
| void key_delete | ( | const PropertyList & | keyTemplate | ) |
Deletes the given key.
| keyTemplate | property list, which specifies the key to be opened. The key is identified by the following properties:
|
| cxi::Exception |
| void key_delete | ( | Key & | key | ) |
| PropertyList key_prop_get | ( | const Key & | key, |
| int | properties[], | ||
| int | nprops | ||
| ) |
Inquires one or more key property values.
| key | key, whose properties are to be inquired |
| properties | integer-array of property specifier, see Key Properties |
| nprops | number of property specifier |
| cxi::Exception |
| Key key_prop_set | ( | const Key & | key, |
| const PropertyList & | propList | ||
| ) |
Sets or modifies one or more properties of the given key.
| key | key whose properties are to be set |
| propList | list of property values to be set |
Note:
| cxi::Exception |
Sets fips specific usage and padding flag
| usage | signature calculation/verification w/ specific padding or other operation |
Exports the given key and returns a key blob of type 'Simple Blob' (see Format of Key Blobs).
| type | XOR combination of:
|
| key | Key to be exported |
| exportKey | Key Encryption Key to be used to encrypt key.
|
| mech | XOR combination of mechanism parameter used to encrypt key (see cxi::MechanismParameter):
|
| cxi::Exception |
| Key key_import | ( | int | flags, |
| int | type, | ||
| const PropertyList & | keyTemplate, | ||
| const ByteArray & | keyBlob, | ||
| Key * | importKey, | ||
| int | mech = -1 |
||
| ) |
Imports a key blob of type 'Simple Blob' (see Format of Key Blobs).
| flags | XOR combination of:
|
| type | Blob type (see Blob Types):
|
| keyTemplate | Key properties to be set for the new key.
|
| keyBlob | Key blob to be imported |
| importKey | Key Encryption Key to be used to encrypt key.
|
| mech | XOR combination of mechanism parameter used to decrypt key (see cxi::MechanismParameter):
|
| cxi::Exception |
| PropertyList key_dsa_xgen | ( | int | psize, |
| int | qsize = 160, |
||
| int | mech = -1 |
||
| ) |
Creates the domain parameter (P, Q and G), needed to create a DSA key (see Cxi::key_generate).
| psize | size in bits of the prime P |
| qsize | size in bits of the prime Q |
| mech | XOR combination of:
|
| cxi::Exception |
| PropertyList key_dsa_pqgen | ( | MechanismParameter & | mechParam | ) |
Creates the domain parameters (P and Q), needed to create a DSA key (see Cxi::key_generate) as described in FIPS 186-4.
| &mechParam |
|
| PropertyList key_dsa_ggen | ( | PropertyList & | propList, |
| const MechanismParameter & | mechParam | ||
| ) |
Creates the domain parameter G using the domain parameters (P and Q), needed to create a DSA key (see Cxi::key_generate), as described in FIPS 186-4.
| &propList |
|
| &mechParam |
|
Exports a key as key backup blob. The private or secret key parts within the blob
are encrypted with the CryptoServers Master Backup key (MBK).
| key | Key to be backed up |
| cxi::Exception |
| Key key_restore | ( | int | flags, |
| Key & | key, | ||
| PropertyList * | keyTemplate = NULL |
||
| ) |
Restores a key from a key backup blob.
| flags | XOR combination of:
|
| key | Key to be restored |
| keyTemplate | Key properties to be set or modified. If one or more of these properties are already present in the backup key blob, they will be overwritten, as long as the property value is not read-only, e.g. it is not possible to change the algorithm or key size property. Optionally, if no additional properties should be set, the reference value of keyTemplate can be set to NULL. |
| cxi::Exception |
| ByteArray crypt | ( | int | flags, |
| const Key & | key, | ||
| const MechanismParameter & | mechParam, | ||
| const ByteArray & | data, | ||
| ByteArray * | iv = NULL, |
||
| ByteArray * | tag = NULL, |
||
| const ByteArray * | tag_in = NULL |
||
| ) |
Encrypt or decrypt data.
The following algorithms are supported:
On symmetric algorithms the function may be called multiple times, each time with a different data chunk.
The following specifics have to be regarded on chunked operation:
| flags | Command flags:
|
| key | Key to be used for encryption or decryption |
| mechParam | XOR combination of mechanisms (see cxi::MechanismParameter):
|
| data | Data to be en- or decrypted. |
| iv | Initialization vector used to chain cipher blocks.
|
| tag | Authentication Tag (used in AES-GCM and AES-CCM modes)
|
| tag_in | Verification Tag (used in AES-GCM and AES-CCM modes when decrypting)
|
| cxi::Exception |
Encrypt data in DES CBC mode with PKCS5 padding applied:
Encrypt and decrypt data in AES GCM mode:
| unsigned int getBufferedDataSize | ( | const ByteArray & | iv | ) |
| std::vector< ByteArray > bulk_crypt | ( | const Key & | key, |
| const MechanismParameter & | mechParam, | ||
| const std::vector< ByteArray > & | data | ||
| ) |
Encrypt or decrypt multiple data items in one operation.
The function utilizes a cryptographic accelerator if present on the target hardware and therefore speeds up RSA calculations.
| key | Key to be used for encryption or decryption |
| mechParam | XOR combination of mechanisms (see cxi::MechanismParameter):
|
| data | Array (vector) of data items to be en- or decrypted |
| cxi::Exception |
| ByteArray sign | ( | int | flags, |
| Key & | key, | ||
| const MechanismParameter & | mechParam, | ||
| const ByteArray & | data, | ||
| ByteArray * | iv = NULL |
||
| ) |
Digitally signs the given hash value (asymmetric algorithms) or calculates a Message Authentication Code (MAC) or hash based MAC (HMAC) (symmetric algorithms).
The function supports cipher block chaining on MACs and multipart calculation on HMACs and asymmetric algorithms.
On MAC calculation the returned MAC can be used as input IV on the next block.
On HMAC calculation and asymmetric algorithms the function can be instructed not to finalize the hash but return intermediate digest information that can be used as input ('IV') for the next block.
| flags | Command flags:
|
| key | Key to be used to create the signature or calculate the MAC or HMAC. The key usage property has to contain the CXI_KEY_USAGE_SIGN value. |
| mechParam | XOR combination of mechanism parameter (see cxi::MechanismParameter):
|
| data | Hash value to be signed or data to be MAC'ed. |
| iv | Initialization vector used to chain cipher blocks or digest information to continue a multipart hash calculation. If no initialization vector is given (NULL) a vector of zeroized bytes is used. For GMAC on non-final calls, this parameter contains intermediate values. On GMAC's final signing call, if the CryptoServer generated an internal IV, that IV is returned in this parameter. |
| cxi::Exception |
| std::vector< ByteArray > bulk_sign | ( | Key & | key, |
| const MechanismParameter & | mechParam, | ||
| const std::vector< ByteArray > & | data | ||
| ) |
Digitally signs up to 16 hash values in one operation.
The function utilizes a cryptographic accelerator if present on the target hardware and therefore speeds up RSA and ECDSA calculations.
| key | RSA or ECDSA Key to be used to create the signature |
| mechParam | XOR combination of mechanism parameter (see Mechanism Parameter):
|
| data | Array (vector) of hash values to be signed |
| cxi::Exception |
| bool verify | ( | int | flags, |
| Key & | key, | ||
| const MechanismParameter & | mechParam, | ||
| ByteArray & | data, | ||
| const ByteArray * | signature, | ||
| ByteArray * | iv = NULL |
||
| ) |
Verifies a digital signature, Message Authentication Code (MAC) or hash based MAC (HMAC).
The function supports cipher block chaining on MACs and multipart calculation on HMACs.
On MAC verification the returned IV can be used as input IV on the next block.
On HMAC calculation the function can be instructed not to finalize the HMAC but return the intermediate HMAC digest information that can be used as input ('IV') for the next block.
| flags | Command flags:
|
| key | Key to be used to verify the signature, MAC or HMAC. The key usage property has to contain the CXI_KEY_USAGE_VERIFY value. |
| mechParam | XOR combination of mechanism parameter (see cxi::MechanismParameter):
|
| data | Reference hash to be compared (asym. algorithms) or data to be MAC'ed for comparison. |
| signature | Signature, MAC or HMAC to be verified In case of cipher block chaining (symmetric keys), the MAC to be compared has to be given with the last chaining block. In case of a multipart HMAC calculation the HMAC to be compared has to be given with the last part. If no MAC/HMAC is given, the updated MAC/HMAC is returned but no comparison takes place. |
| iv | Initialization vector used to chain cipher blocks or HMAC digest information used to calculate a multipart HMAC.
|
| cxi::Exception | in case of any other error than verification failure. |
| ByteArray rnd_gen | ( | int | len, |
| int | mech = -1 |
||
| ) |
Generates random bytes
| len | Number of random bytes to be generated |
| mech | Generation mode:
|
| cxi::Exception |
| ByteArray hash_compute | ( | int | flags, |
| const MechanismParameter & | mechParam, | ||
| const ByteArray * | data, | ||
| const ByteArray * | info = NULL, |
||
| const Key * | key = NULL |
||
| ) |
This function computes a hash or hash based MAC (HMAC) over the given data.
| flags | Command flags:
|
| mechParam | XOR combination of hash mode (see Mode Parameter) and hash algorithm (see Hash Algorithms). |
| data | Plain data to be hashed. |
| info | Optional hash digest information to continue a multipart hash calculation or NULL to start a new hash calculation. |
| key | Optional key:
|
| cxi::Exception |
| ByteArray secret_agree | ( | int | flags, |
| const Key & | privateKey, | ||
| const Key & | publicKey, | ||
| const MechanismParameter * | mechParam = NULL |
||
| ) |
This function calculates a shared secret from two ECDH or ECDSA keys as described in TR-03111.
The algorithm is based on a point multiplication, which takes the private part of the first key and the public part of the second key as input parameter. The returned secret consists either of the complete resulting point (x and y coordinate) or only of its x- coordinate in case CXI_MECH_FORMAT_X was given in the mechanism parameters. The function returns either the plain secret value or encrypts the secret with the CryptoServer's MBK in case CXI_FLAG_ENCRYPT_SECRET was given in the command flags.
| flags | Command flags:
|
| privateKey | Private part of key #1. The key usage property has to contain the CXI_KEY_USAGE_DERIVE value. |
| publicKey | Public part of key #2.
|
| mechParam | Mechanism Parameters:
|
| cxi::Exception |