libzpc 1.5
IBM Z Protected-key Crypto library
Loading...
Searching...
No Matches
hmac_key.h
Go to the documentation of this file.
1/*
2 * Copyright IBM Corp. 2025
3 *
4 * libzpc is free software; you can redistribute it and/or modify
5 * it under the terms of the MIT license. See LICENSE for details.
6 */
7
8#ifndef ZPC_HMAC_KEY_H
9# define ZPC_HMAC_KEY_H
10# ifdef __cplusplus
11/* *INDENT-OFF* */
12extern "C" {
13/* *INDENT-ON* */
14# endif
15
23
24# include <stddef.h>
25
26/*
27 * These constants match with kernel's pkey.h, enum pkey_key_type.
28 */
29# define ZPC_HMAC_KEY_TYPE_PVSECRET 9
30
31typedef enum {
32 ZPC_HMAC_SECRET_TYPE_NOT_SET = -2,
33 ZPC_HMAC_SECRET_TYPE_INVALID = -1,
34 ZPC_HMAC_SECRET_HMAC_SHA_256 = 0x09, /* architected key types, also below */
35 ZPC_HMAC_SECRET_HMAC_SHA_512 = 0x0a,
36} zpc_hmacsecret_type_t;
37
38typedef enum {
39 ZPC_HMAC_HASHFUNC_NOT_SET = -2,
40 ZPC_HMAC_HASHFUNC_INVALID = -1,
41 ZPC_HMAC_HASHFUNC_SHA_224 = 0,
42 ZPC_HMAC_HASHFUNC_SHA_256,
43 ZPC_HMAC_HASHFUNC_SHA_384,
44 ZPC_HMAC_HASHFUNC_SHA_512,
45} zpc_hmac_hashfunc_t;
46
47struct zpc_hmac_key;
48
54__attribute__((visibility("default")))
55int zpc_hmac_key_alloc(struct zpc_hmac_key **key);
63__attribute__((visibility("default")))
64int zpc_hmac_key_set_type(struct zpc_hmac_key *key, int type);
74__attribute__((visibility("default")))
75int zpc_hmac_key_set_hash_function(struct zpc_hmac_key *key, zpc_hmac_hashfunc_t func);
83__attribute__((visibility("default")))
84int zpc_hmac_key_import(struct zpc_hmac_key *key, const unsigned char *origin,
85 size_t originlen);
93__attribute__((visibility("default")))
94int zpc_hmac_key_import_clear(struct zpc_hmac_key *key,
95 const unsigned char *clrkey, size_t keylen);
103__attribute__((visibility("default")))
104int zpc_hmac_key_export(struct zpc_hmac_key *key, unsigned char *origin,
105 size_t *originlen);
111__attribute__((visibility("default")))
112int zpc_hmac_key_generate(struct zpc_hmac_key *key);
118__attribute__((visibility("default")))
119void zpc_hmac_key_free(struct zpc_hmac_key **key);
120
121# ifdef __cplusplus
122/* *INDENT-OFF* */
123}
124/* *INDENT-ON* */
125# endif
126#endif
int zpc_hmac_key_import_clear(struct zpc_hmac_key *key, const unsigned char *clrkey, size_t keylen)
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)
void zpc_hmac_key_free(struct zpc_hmac_key **key)
int zpc_hmac_key_export(struct zpc_hmac_key *key, unsigned char *origin, size_t *originlen)
int zpc_hmac_key_set_type(struct zpc_hmac_key *key, int type)
int zpc_hmac_key_alloc(struct zpc_hmac_key **key)
int zpc_hmac_key_generate(struct zpc_hmac_key *key)