HMAC key API.
More...
Go to the source code of this file.
|
| enum | zpc_hmacsecret_type_t { ZPC_HMAC_SECRET_TYPE_NOT_SET = -2
, ZPC_HMAC_SECRET_TYPE_INVALID = -1
, ZPC_HMAC_SECRET_HMAC_SHA_256 = 0x09
, ZPC_HMAC_SECRET_HMAC_SHA_512 = 0x0a
} |
| enum | zpc_hmac_hashfunc_t {
ZPC_HMAC_HASHFUNC_NOT_SET = -2
, ZPC_HMAC_HASHFUNC_INVALID = -1
, ZPC_HMAC_HASHFUNC_SHA_224 = 0
, ZPC_HMAC_HASHFUNC_SHA_256
,
ZPC_HMAC_HASHFUNC_SHA_384
, ZPC_HMAC_HASHFUNC_SHA_512
} |
HMAC key API.
Manage [7] keys.
Definition in file hmac_key.h.
◆ ZPC_HMAC_KEY_TYPE_PVSECRET
| #define ZPC_HMAC_KEY_TYPE_PVSECRET 9 |
◆ zpc_hmacsecret_type_t
| enum zpc_hmacsecret_type_t |
◆ zpc_hmac_hashfunc_t
◆ zpc_hmac_key_alloc()
| int zpc_hmac_key_alloc |
( |
struct zpc_hmac_key ** | key | ) |
|
Allocate a new HMAC key object with reference count 1.
- Parameters
-
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_hmac_key_set_type()
| int zpc_hmac_key_set_type |
( |
struct zpc_hmac_key * | key, |
|
|
int | type ) |
Set the HMAC key type.
- Parameters
-
| [in,out] | key | HMAC key |
| [in] | type | currently only one type ZPC_HMAC_KEY_TYPE_PVSECRET is supported. |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_hmac_key_set_hash_function()
| int zpc_hmac_key_set_hash_function |
( |
struct zpc_hmac_key * | key, |
|
|
zpc_hmac_hashfunc_t | func ) |
Set the hash function to be used in the context of an HMAC operation.
- Parameters
-
| [in,out] | key | HMAC key |
| [in] | func | HMAC hash function The size of the HMAC key (64 bytes or 128 bytes) is given by the block size of the hash function: for sha224 and sha256, the key size is set to 64 bytes, for sha384 and sha512, the key size is set to 128 bytes. |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_hmac_key_import()
| int zpc_hmac_key_import |
( |
struct zpc_hmac_key * | key, |
|
|
const unsigned char * | origin, |
|
|
size_t | originlen ) |
Import an HMAC protected key origin (secure key or retrievable secret ID).
- Parameters
-
| [in,out] | key | HMAC key |
| [in] | origin | HMAC protected key origin |
| [in] | originlen | HMAC key origin length [bytes] |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_hmac_key_import_clear()
| int zpc_hmac_key_import_clear |
( |
struct zpc_hmac_key * | key, |
|
|
const unsigned char * | clrkey, |
|
|
size_t | keylen ) |
Import an HMAC clear-key.
- Parameters
-
| [in,out] | key | HMAC key |
| [in] | clrkey | HMAC clear-key |
| [in] | keylen | HMAC clear-key size [bytes] |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_hmac_key_export()
| int zpc_hmac_key_export |
( |
struct zpc_hmac_key * | key, |
|
|
unsigned char * | origin, |
|
|
size_t * | originlen ) |
Export an HMAC protected key origin (secure key or retrievable secret ID).
- Parameters
-
| [in,out] | key | HMAC key |
| [out] | origin | HMAC protected key origin |
| [in,out] | originlen | origin length [bytes] |
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_hmac_key_generate()
| int zpc_hmac_key_generate |
( |
struct zpc_hmac_key * | key | ) |
|
Generate a random HMAC protected-key.
- Parameters
-
- Returns
- 0 on success. Otherwise, a non-zero error code is returned.
◆ zpc_hmac_key_free()
| void zpc_hmac_key_free |
( |
struct zpc_hmac_key ** | key | ) |
|
Decrease the reference count of an HMAC key object and free it the count reaches 0.
- Parameters
-