libzpc 1.5
IBM Z Protected-key Crypto library
Loading...
Searching...
No Matches
hmac_key.h File Reference

HMAC key API. More...

Go to the source code of this file.

Macros

#define ZPC_HMAC_KEY_TYPE_PVSECRET   9

Enumerations

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
}

Functions

int zpc_hmac_key_alloc (struct zpc_hmac_key **key)
int zpc_hmac_key_set_type (struct zpc_hmac_key *key, int type)
int zpc_hmac_key_set_hash_function (struct zpc_hmac_key *key, zpc_hmac_hashfunc_t func)
int zpc_hmac_key_import (struct zpc_hmac_key *key, const unsigned char *origin, size_t originlen)
int zpc_hmac_key_import_clear (struct zpc_hmac_key *key, const unsigned char *clrkey, size_t keylen)
int zpc_hmac_key_export (struct zpc_hmac_key *key, unsigned char *origin, size_t *originlen)
int zpc_hmac_key_generate (struct zpc_hmac_key *key)
void zpc_hmac_key_free (struct zpc_hmac_key **key)

Detailed Description

HMAC key API.

Manage [7] keys.

Definition in file hmac_key.h.

Macro Definition Documentation

◆ ZPC_HMAC_KEY_TYPE_PVSECRET

#define ZPC_HMAC_KEY_TYPE_PVSECRET   9

Definition at line 29 of file hmac_key.h.

Enumeration Type Documentation

◆ zpc_hmacsecret_type_t

enum zpc_hmacsecret_type_t

Definition at line 31 of file hmac_key.h.

◆ zpc_hmac_hashfunc_t

enum zpc_hmac_hashfunc_t

Definition at line 38 of file hmac_key.h.

Function Documentation

◆ 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
[in,out]keyHMAC key
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]keyHMAC key
[in]typecurrently 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]keyHMAC key
[in]funcHMAC 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]keyHMAC key
[in]originHMAC protected key origin
[in]originlenHMAC 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]keyHMAC key
[in]clrkeyHMAC clear-key
[in]keylenHMAC 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]keyHMAC key
[out]originHMAC protected key origin
[in,out]originlenorigin 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
[in,out]keyHMAC key
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
[in,out]keyHMAC key