2 * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
10 #include <openssl/ossl_typ.h>
21 /* Supported key algorithms */
23 KEY_ALG_RSA
, /* RSA PSS as defined by PKCS#1 v2.1 (default) */
24 KEY_ALG_RSA_1_5
, /* RSA as defined by PKCS#1 v1.5 */
27 #endif /* OPENSSL_NO_EC */
31 /* Maximum number of valid key sizes per algorithm */
32 #define KEY_SIZE_MAX_NUM 4
34 /* Supported hash algorithms */
41 /* Supported key sizes */
42 /* NOTE: the first item in each array is the default key size */
43 static const unsigned int KEY_SIZES
[KEY_ALG_MAX_NUM
][KEY_SIZE_MAX_NUM
] = {
44 { 2048, 1024, 3072, 4096 }, /* KEY_ALG_RSA */
45 { 2048, 1024, 3072, 4096 }, /* KEY_ALG_RSA_1_5 */
47 {} /* KEY_ALG_ECDSA */
48 #endif /* OPENSSL_NO_EC */
52 * This structure contains the relevant information to create the keys
53 * required to sign the certificates.
55 * One instance of this structure must be created for each key, usually in an
56 * array fashion. The filename is obtained at run time from the command line
59 typedef struct key_s
{
61 const char *opt
; /* Command line option to specify a key */
62 const char *help_msg
; /* Help message */
63 const char *desc
; /* Key description (debug purposes) */
64 char *fn
; /* Filename to load/store the key */
65 EVP_PKEY
*key
; /* Key container */
70 key_t
*key_get_by_opt(const char *opt
);
71 int key_new(key_t
*key
);
72 int key_create(key_t
*key
, int type
, int key_bits
);
73 int key_load(key_t
*key
, unsigned int *err_code
);
74 int key_store(key_t
*key
);
76 /* Macro to register the keys used in the CoT */
77 #define REGISTER_KEYS(_keys) \
78 key_t *keys = &_keys[0]; \
79 const unsigned int num_keys = sizeof(_keys)/sizeof(_keys[0])
81 /* Exported variables */
83 extern const unsigned int num_keys
;