libzpc 1.5
IBM Z Protected-key Crypto library
Loading...
Searching...
No Matches
ecc_key.h
Go to the documentation of this file.
1/*
2 * Copyright IBM Corp. 2022
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_ECC_KEY_H
9# define ZPC_ECC_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_EC_KEY_TYPE_CCA 0x1f
30#define ZPC_EC_KEY_TYPE_EP11 7
31#define ZPC_EC_KEY_TYPE_PVSECRET 9
32
33
34#define ZPC_EC_KEY_REENCIPHER_OLD_TO_CURRENT 1
35#define ZPC_EC_KEY_REENCIPHER_CURRENT_TO_NEW 2
36
37typedef enum {
38 ZPC_EC_CURVE_NOT_SET = -2,
39 ZPC_EC_CURVE_INVALID = -1,
40 ZPC_EC_CURVE_P256 = 0,
41 ZPC_EC_CURVE_P384,
42 ZPC_EC_CURVE_P521,
43 ZPC_EC_CURVE_ED25519,
44 ZPC_EC_CURVE_ED448
45} zpc_ec_curve_t;
46
47typedef enum {
48 ZPC_EC_SECRET_TYPE_NOT_SET = -2,
49 ZPC_EC_SECRET_TYPE_INVALID = -1,
50 ZPC_EC_SECRET_ECDSA_P256 = 0x0011, /* architected key types, also below */
51 ZPC_EC_SECRET_ECDSA_P384 = 0x0012,
52 ZPC_EC_SECRET_ECDSA_P521 = 0x0013,
53 ZPC_EC_SECRET_EDDSA_ED25519 = 0x0014,
54 ZPC_EC_SECRET_EDDSA_ED448 = 0x0015,
55} zpc_ecsecret_type_t;
56
57struct zpc_ec_key;
58
64__attribute__((visibility("default")))
65int zpc_ec_key_alloc(struct zpc_ec_key **key);
66
73__attribute__((visibility("default")))
74int zpc_ec_key_set_curve(struct zpc_ec_key *key, zpc_ec_curve_t curve);
75
82__attribute__((visibility("default")))
83int zpc_ec_key_set_type(struct zpc_ec_key *key, int type);
84
91__attribute__((visibility("default")))
92int zpc_ec_key_set_flags(struct zpc_ec_key *key, unsigned int flags);
93
102__attribute__((visibility("default")))
103int zpc_ec_key_set_mkvp(struct zpc_ec_key *key, const char *mkvp);
104
112__attribute__((visibility("default")))
113int zpc_ec_key_set_apqns(struct zpc_ec_key *key, const char *apqns[]);
114
126__attribute__((visibility("default")))
127int zpc_ec_key_import(struct zpc_ec_key *key, const unsigned char *seckey,
128 unsigned int seckeylen);
129
151__attribute__((visibility("default")))
152int zpc_ec_key_import_clear(struct zpc_ec_key *key,
153 const unsigned char *pubkey, unsigned int publen,
154 const unsigned char *privkey, unsigned int privlen);
155
167__attribute__((visibility("default")))
168int zpc_ec_key_export(struct zpc_ec_key *key, unsigned char *seckey,
169 unsigned int *seckeylen);
170
181__attribute__((visibility("default")))
182int zpc_ec_key_export_public(struct zpc_ec_key *key, unsigned char *pubkey,
183 unsigned int *pubkeylen);
184
190__attribute__((visibility("default")))
191int zpc_ec_key_generate(struct zpc_ec_key *key);
192
202__attribute__((visibility("default")))
203int zpc_ec_key_reencipher(struct zpc_ec_key *key, unsigned int reenc);
204
210__attribute__((visibility("default")))
211void zpc_ec_key_free(struct zpc_ec_key **key);
212
213# ifdef __cplusplus
214/* *INDENT-OFF* */
215}
216/* *INDENT-ON* */
217# endif
218#endif
int zpc_ec_key_generate(struct zpc_ec_key *key)
int zpc_ec_key_alloc(struct zpc_ec_key **key)
void zpc_ec_key_free(struct zpc_ec_key **key)
int zpc_ec_key_export(struct zpc_ec_key *key, unsigned char *seckey, unsigned int *seckeylen)
int zpc_ec_key_set_mkvp(struct zpc_ec_key *key, const char *mkvp)
int zpc_ec_key_import_clear(struct zpc_ec_key *key, const unsigned char *pubkey, unsigned int publen, const unsigned char *privkey, unsigned int privlen)
int zpc_ec_key_set_type(struct zpc_ec_key *key, int type)
int zpc_ec_key_set_apqns(struct zpc_ec_key *key, const char *apqns[])
int zpc_ec_key_set_flags(struct zpc_ec_key *key, unsigned int flags)
int zpc_ec_key_set_curve(struct zpc_ec_key *key, zpc_ec_curve_t curve)
int zpc_ec_key_export_public(struct zpc_ec_key *key, unsigned char *pubkey, unsigned int *pubkeylen)
int zpc_ec_key_import(struct zpc_ec_key *key, const unsigned char *seckey, unsigned int seckeylen)
int zpc_ec_key_reencipher(struct zpc_ec_key *key, unsigned int reenc)