libzpc 1.5
IBM Z Protected-key Crypto library
Loading...
Searching...
No Matches
aes_key.h
Go to the documentation of this file.
1/*
2 * Copyright IBM Corp. 2021
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_AES_KEY_H
9# define ZPC_AES_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_AES_KEY_TYPE_CCA_DATA 1
30# define ZPC_AES_KEY_TYPE_CCA_CIPHER 2
31# define ZPC_AES_KEY_TYPE_EP11 3
32# define ZPC_AES_KEY_TYPE_PVSECRET 9
33
34# define ZPC_AES_KEY_REENCIPHER_OLD_TO_CURRENT 1
35# define ZPC_AES_KEY_REENCIPHER_CURRENT_TO_NEW 2
36
37typedef enum {
38 ZPC_AES_SECRET_TYPE_NOT_SET = -2,
39 ZPC_AES_SECRET_TYPE_INVALID = -1,
40 ZPC_AES_SECRET_AES_128 = 0x04, /* architected key types, also below */
41 ZPC_AES_SECRET_AES_192 = 0x05,
42 ZPC_AES_SECRET_AES_256 = 0x06,
43} zpc_aessecret_type_t;
44
45struct zpc_aes_key;
46
52__attribute__((visibility("default")))
53int zpc_aes_key_alloc(struct zpc_aes_key **key);
60__attribute__((visibility("default")))
61int zpc_aes_key_set_size(struct zpc_aes_key *key, int size);
69__attribute__((visibility("default")))
70int zpc_aes_key_set_type(struct zpc_aes_key *key, int type);
77__attribute__((visibility("default")))
78int zpc_aes_key_set_flags(struct zpc_aes_key *key, unsigned int flags);
86__attribute__((visibility("default")))
87int zpc_aes_key_set_mkvp(struct zpc_aes_key *key, const char *mkvp);
95__attribute__((visibility("default")))
96int zpc_aes_key_set_apqns(struct zpc_aes_key *key, const char *apqns[]);
104__attribute__((visibility("default")))
105int zpc_aes_key_import(struct zpc_aes_key *key, const unsigned char *seckey,
106 size_t seckeylen);
113__attribute__((visibility("default")))
114int zpc_aes_key_import_clear(struct zpc_aes_key *key,
115 const unsigned char *clrkey);
123__attribute__((visibility("default")))
124int zpc_aes_key_export(struct zpc_aes_key *key, unsigned char *seckey,
125 size_t *seckeylen);
131__attribute__((visibility("default")))
132int zpc_aes_key_generate(struct zpc_aes_key *key);
142__attribute__((visibility("default")))
143int zpc_aes_key_reencipher(struct zpc_aes_key *key, int reenc);
149__attribute__((visibility("default")))
150void zpc_aes_key_free(struct zpc_aes_key **key);
151
152# ifdef __cplusplus
153/* *INDENT-OFF* */
154}
155/* *INDENT-ON* */
156# endif
157#endif
int zpc_aes_key_alloc(struct zpc_aes_key **key)
int zpc_aes_key_set_mkvp(struct zpc_aes_key *key, const char *mkvp)
int zpc_aes_key_export(struct zpc_aes_key *key, unsigned char *seckey, size_t *seckeylen)
int zpc_aes_key_set_apqns(struct zpc_aes_key *key, const char *apqns[])
int zpc_aes_key_generate(struct zpc_aes_key *key)
int zpc_aes_key_import(struct zpc_aes_key *key, const unsigned char *seckey, size_t seckeylen)
int zpc_aes_key_import_clear(struct zpc_aes_key *key, const unsigned char *clrkey)
void zpc_aes_key_free(struct zpc_aes_key **key)
int zpc_aes_key_set_flags(struct zpc_aes_key *key, unsigned int flags)
int zpc_aes_key_set_size(struct zpc_aes_key *key, int size)
int zpc_aes_key_reencipher(struct zpc_aes_key *key, int reenc)
int zpc_aes_key_set_type(struct zpc_aes_key *key, int type)