Lines Matching refs:key

36 int key_new(key_t *key)  in key_new()  argument
39 key->key = EVP_PKEY_new(); in key_new()
40 if (key->key == NULL) { in key_new()
48 static int key_create_rsa(key_t *key, int key_bits) in key_create_rsa() argument
56 key->key = rsa; in key_create_rsa()
84 if (!EVP_PKEY_assign_RSA(key->key, rsa)) { in key_create_rsa()
102 static int key_create_ecdsa(key_t *key, int key_bits, const char *curve) in key_create_ecdsa() argument
110 key->key = ec; in key_create_ecdsa()
114 static int key_create_ecdsa_nist(key_t *key, int key_bits) in key_create_ecdsa_nist() argument
117 return key_create_ecdsa(key, key_bits, "secp384r1"); in key_create_ecdsa_nist()
120 return key_create_ecdsa(key, key_bits, "prime256v1"); in key_create_ecdsa_nist()
124 static int key_create_ecdsa_brainpool_r(key_t *key, int key_bits) in key_create_ecdsa_brainpool_r() argument
126 return key_create_ecdsa(key, key_bits, "brainpoolP256r1"); in key_create_ecdsa_brainpool_r()
129 static int key_create_ecdsa_brainpool_t(key_t *key, int key_bits) in key_create_ecdsa_brainpool_t() argument
131 return key_create_ecdsa(key, key_bits, "brainpoolP256t1"); in key_create_ecdsa_brainpool_t()
134 static int key_create_ecdsa(key_t *key, int key_bits, const int curve_id) in key_create_ecdsa() argument
149 if (!EVP_PKEY_assign_EC_KEY(key->key, ec)) { in key_create_ecdsa()
161 static int key_create_ecdsa_nist(key_t *key, int key_bits) in key_create_ecdsa_nist() argument
164 return key_create_ecdsa(key, key_bits, NID_secp384r1); in key_create_ecdsa_nist()
167 return key_create_ecdsa(key, key_bits, NID_X9_62_prime256v1); in key_create_ecdsa_nist()
171 static int key_create_ecdsa_brainpool_r(key_t *key, int key_bits) in key_create_ecdsa_brainpool_r() argument
173 return key_create_ecdsa(key, key_bits, NID_brainpoolP256r1); in key_create_ecdsa_brainpool_r()
176 static int key_create_ecdsa_brainpool_t(key_t *key, int key_bits) in key_create_ecdsa_brainpool_t() argument
178 return key_create_ecdsa(key, key_bits, NID_brainpoolP256t1); in key_create_ecdsa_brainpool_t()
183 typedef int (*key_create_fn_t)(key_t *key, int key_bits);
193 int key_create(key_t *key, int type, int key_bits) in key_create() argument
201 return key_create_fn[type](key, key_bits); in key_create()
242 unsigned int key_load(key_t *key) in key_load() argument
244 if (key->fn == NULL) { in key_load()
249 if (strncmp(key->fn, "pkcs11:", 7) == 0) { in key_load()
251 key->key = key_load_pkcs11(key->fn); in key_load()
254 FILE *fp = fopen(key->fn, "r"); in key_load()
256 WARN("Cannot open file %s\n", key->fn); in key_load()
260 key->key = PEM_read_PrivateKey(fp, NULL, NULL, NULL); in key_load()
264 if (key->key == NULL) { in key_load()
265 ERROR("Cannot load key from %s\n", key->fn); in key_load()
272 int key_store(key_t *key) in key_store() argument
276 if (key->fn) { in key_store()
277 if (!strncmp(key->fn, "pkcs11:", 7)) { in key_store()
281 fp = fopen(key->fn, "w"); in key_store()
283 PEM_write_PrivateKey(fp, key->key, in key_store()
288 ERROR("Cannot create file %s\n", key->fn); in key_store()
300 key_t *key; in key_init() local
326 key = &keys[i]; in key_init()
327 if (key->opt != NULL) { in key_init()
328 cmd_opt.long_opt.name = key->opt; in key_init()
332 cmd_opt.help_msg = key->help_msg; in key_init()
342 key_t *key; in key_get_by_opt() local
348 key = &keys[i]; in key_get_by_opt()
349 if (0 == strcmp(key->opt, opt)) { in key_get_by_opt()
350 return key; in key_get_by_opt()
362 EVP_PKEY_free(keys[i].key); in key_cleanup()