|
CXI
|
Constructs mechanism parameter that are used on cryptographic operations. A mechanism parameter consists of a mechanism specifier and optional parameters. More...
Public Member Functions | |
| MechanismParameter (int mech) | |
| MechanismParameter (int mech, int mgf_algo, char *label) | |
| MechanismParameter (int mech, int mgf_algo, int salt_len) | |
| MechanismParameter (const MechanismParameter &mp) | |
| void | removeAAD () |
| void | set (int mech) |
| void | setVDM (int vdmMech, int mode) |
| void | setOAEP (int mech, int mgf_algo, const char *label) |
| void | setPSS (int mech, int mgf_algo, int salt_len) |
| void | setECIES (int mech, int hash_algo, int crypt_algo, int crypt_mech, int crypt_len, int mac_algo, int mac_mech, int mac_len, const char *p_secret1, int l_secret1, const char *p_secret2, int l_secret2) |
| void | setGCM (int mech, const char *p_iv_init, int l_iv_init, const char *p_ad, int l_ad, int tag_bits=128, int iv_gen_func=CXI_MECH_PARAM_IV_NO_GENERATE) |
| void | setGMAC (int mech, const char *p_iv_init, int l_iv_init, int iv_gen_func=CXI_MECH_PARAM_IV_NO_GENERATE) |
| void | setCCM (int mech, const char *p_nonce, unsigned int l_nonce, const char *p_ad, unsigned int l_ad, unsigned int l_data, unsigned int l_mac, int nonce_gen_func=CXI_MECH_PARAM_NONCE_NO_GENERATE) |
| void | operator|= (const int mech) |
Public Member Functions inherited from ByteArray | |
| ByteArray (void) | |
| ByteArray (int len) | |
| ByteArray (const char *data, int len) | |
| ByteArray (const char *str) | |
| ByteArray (int val, int len) | |
| ByteArray (const ByteArray &ba) | |
| virtual | ~ByteArray (void) |
| void | clear (void) |
| int | length (void) const |
| char * | get (void) |
| const char * | get (void) const |
| void | set (const char *data, int len) |
| void | append (const char *data, int len) |
| void | append (const ByteArray &ba) |
| void | insert (const char *data, int len, int offset) |
| void | fill (char value, int len, int offset) |
| int | getInt (int def_val=0) const |
| void | setInt (int val, int len) |
| void | appendInt (int val, int len) |
| void | getString (char *str, int max_size) const |
| void | setString (const char *str) |
| void | appendString (const char *str) |
| std::string | toString (void) const |
| std::string | toHexString (void) const |
| int | compare (const ByteArray &ba) const |
| ByteArray | sub (int offset, int len=-1) const |
| ByteArray | lstrip (void) const |
| ByteArray | rstrip (const std::set< char > &charsToBeStripped) const |
| void | read (const char *filename) |
| void | write (const char *filename) const |
| void | xtrace (const char *text=0) const |
| ByteArray & | operator= (const ByteArray &ba) |
| const ByteArray & | operator+= (const ByteArray &ba) |
| const ByteArray & | operator|= (const ByteArray &ba) |
| const ByteArray & | operator^= (const ByteArray &ba) |
| char & | operator[] (int idx) |
Constructs mechanism parameter that are used on cryptographic operations. A mechanism parameter consists of a mechanism specifier and optional parameters.
The following example illustrates the usage of the MechanismParameter class:
| MechanismParameter | ( | int | mech | ) |
Constructs a mechanism parameter that consists of a mechanism specifier without additional data.
| mech | mechanism specifier, see /tmp/ci_workspace/sw/cxi_api_c/src/mechparam.cpp |
| MechanismParameter | ( | int | mech, |
| int | mgf_algo, | ||
| char * | label | ||
| ) |
Constructs a mechanism specifier and parameter for PKCS#1, v2.1 RSAES-OAEP encryption / decryption padding scheme.
| mech | mechanism specifier, XOR combination of:
|
| mgf_algo | algorithm specifier for the MGF algorithm to be used, see Hash Algorithms |
| label | label string to be used |
| MechanismParameter | ( | int | mech, |
| int | mgf_algo, | ||
| int | salt_len | ||
| ) |
Constructs a mechanism specifier and parameters for PKCS#1, v2.1 RSAES-PSS signature creation / verification padding scheme.
| mech | mechanism specifier, XOR combination of:
|
| mgf_algo | algorithm specifier for the MGF algorithm to be used, see Hash Algorithms |
| salt_len | length of the random salt value to be generated |
| MechanismParameter | ( | const MechanismParameter & | mp | ) |
Copy constructor for MechanismParameter class.
| void removeAAD | ( | ) |
Removes any Additional Authenticated Data (AAD) from the mechanism parameter. This may be used to prepare an AEAD mode mechanism parameter for subsequent calls following the initial call, if the inital call carried AAD.
| void set | ( | int | mech | ) |
Constructs a mechanism parameter that consists of a mechanism specifier without additional data.
| mech | mechanism specifier, see Mechanism Parameter |
| void setVDM | ( | int | vdmMech, |
| int | mode | ||
| ) |
Constructs a mechanism parameter that consists of an VDM specifier without additional data.
| vdmMech | vendor defined mechanism (VDM) specifier |
| mode | crypt mode, see Mode Parameter |
| void setOAEP | ( | int | mech, |
| int | mgf_algo, | ||
| const char * | label | ||
| ) |
Constructs a mechanism specifier and parameter for PKCS#1, v2.1 RSAES-OAEP encryption / decryption padding scheme.
| mech | mechanism specifier, XOR combination of:
|
| mgf_algo | algorithm specifier for the MGF algorithm to be used, see Hash Algorithms |
| label | label string to be used |
| void setPSS | ( | int | mech, |
| int | mgf_algo, | ||
| int | salt_len | ||
| ) |
Constructs a mechanism specifier and parameters for PKCS#1, v2.1 RSAES-PSS signature creation / verification padding scheme.
| mech | mechanism specifier, XOR combination of:
|
| mgf_algo | algorithm specifier for the MGF algorithm to be used, see Hash Algorithms |
| salt_len | length of the random salt value to be generated |
| void setECIES | ( | int | mech, |
| int | hash_algo, | ||
| int | crypt_algo, | ||
| int | crypt_mech, | ||
| int | crypt_len, | ||
| int | mac_algo, | ||
| int | mac_mech, | ||
| int | mac_len, | ||
| const char * | p_secret1, | ||
| int | l_secret1, | ||
| const char * | p_secret2, | ||
| int | l_secret2 | ||
| ) |
Constructs a mechanism parameter for 'Elliptic Curve (Augmented) Encryption Scheme' (ECIES, see ANSI X9.63).
| mech | XOR combination of mechanism specifier:
|
| hash_algo | hash algorithm,see Hash Algorithms |
| crypt_algo | algorithm:
|
| crypt_mech | mechanism:
|
| crypt_len | AES key size (128,192 or 256) or zero on raw mode |
| mac_algo | algorithm:
|
| mac_mech | mechanism: Mechanism Parameter
|
| mac_len | AES key size (128,192 or 256) or zero on HMAC optional: mac size in byte for truncated macs when using CXI_MECH_MODE_MAC1. |
| p_secret1 | pointer to secret value #1 or NULL |
| l_secret1 | length of secret value #1 or 0 |
| p_secret2 | pointer to secret value #2 or NULL |
| l_secret2 | length of secret value #2 or 0 |
| void setGCM | ( | int | mech, |
| const char * | p_iv_init, | ||
| int | l_iv_init, | ||
| const char * | p_ad, | ||
| int | l_ad, | ||
| int | tag_bits = 128, |
||
| int | iv_gen_func = CXI_MECH_PARAM_IV_NO_GENERATE |
||
| ) |
Constructs a mechanism parameter for Galois Counter Mode (see NIST SP-800-38D).
| mech | XOR combination of mechanism specifier:
|
| p_iv_init | Pointer to Initialization Vector:
|
| l_iv_init | Length of the Initialization Vector:
|
| p_ad | Additional Authenticated Data:
|
| l_ad | Length of the Additional Authenticated Data. |
| tag_bits | Desired length of authentication tag in bits:
|
| iv_gen_func | IV generation function:
|
| std::bad_alloc | if allocation of AAD field fails, cxi::Exception if parameters are invalid. |
| void setGMAC | ( | int | mech, |
| const char * | p_iv_init, | ||
| int | l_iv_init, | ||
| int | iv_gen_func = CXI_MECH_PARAM_IV_NO_GENERATE |
||
| ) |
Constructs a mechanism parameter for Galois Counter MAC (see NIST SP-800-38D).
| mech | XOR combination of mechanism specifier:
|
| p_iv_init | Pointer to Initialization Vector:
|
| l_iv_init | Length of the Initialization Vector (< 2^16 - 1):
|
| iv_gen_func | IV generation function:
|
| void setCCM | ( | int | mech, |
| const char * | p_nonce, | ||
| unsigned int | l_nonce, | ||
| const char * | p_ad, | ||
| unsigned int | l_ad, | ||
| unsigned int | l_data, | ||
| unsigned int | l_mac, | ||
| int | nonce_gen_func = CXI_MECH_PARAM_NONCE_NO_GENERATE |
||
| ) |
Constructs a mechanism parameter for "Counter with Cipher Block Chaining - Message Authentication Code", abbreviated CCM (see NIST SP 800-38C).
| mech | XOR combination of mechanism specifier:
|
| p_nonce | pointer to the nonce |
| l_nonce | length of the nonce in bytes (range 7-13 for initial crypt call) |
| p_ad | Additional Authentication Data
|
| l_ad | length of the Additional Authentication Data |
| l_data | length total length of the data that will be passed to the crypt() call(s) later |
| l_mac | length of the MAC (range 4-16 for initial and final crypt call) |
| nonce_gen_func | nonce generation function:
|
| void operator|= | ( | const int | mech | ) |
ORs the given mechanism value to the existing mechanism parameter.
| mech | mechanism specifier to be ORed to the existing mechanism. Note:
|
| cxi::Exception | if existing MechanismParameter was not initialized. |