Lines Matching defs:key

56 #define DFL_FILENAME            "keyfile.key"
75 " filename=%%s default: keyfile.key\n" \
86 const char *filename; /* filename of the key file */
88 const char *output_file; /* where to store the constructed key file */
92 static int write_public_key(mbedtls_pk_context *key, const char *output_file)
104 if ((ret = mbedtls_pk_write_pubkey_pem(key, output_buf, 16000)) != 0) {
112 if ((ret = mbedtls_pk_write_pubkey_der(key, output_buf, 16000)) < 0) {
134 static int write_private_key(mbedtls_pk_context *key, const char *output_file)
146 if ((ret = mbedtls_pk_write_key_pem(key, output_buf, 16000)) != 0) {
154 if ((ret = mbedtls_pk_write_key_der(key, output_buf, 16000)) < 0) {
255 mbedtls_pk_context key;
266 mbedtls_pk_init(&key);
342 mbedtls_printf("\nCannot output a key without reading one.\n");
347 mbedtls_printf("\nCannot output a private key from a public key.\n");
353 * 1.1. Load the key
355 mbedtls_printf("\n . Loading the private key ...");
366 ret = mbedtls_pk_parse_keyfile(&key, opt.filename, NULL,
377 * 1.2 Print the key
382 if (mbedtls_pk_get_type(&key) == MBEDTLS_PK_RSA) {
383 mbedtls_rsa_context *rsa = mbedtls_pk_rsa(key);
402 if (mbedtls_pk_get_type(&key) == MBEDTLS_PK_ECKEY) {
403 if (show_ecp_key(mbedtls_pk_ec(key), 1) != 0) {
409 mbedtls_printf("key type not supported yet\n");
413 * 1.1. Load the key
415 mbedtls_printf("\n . Loading the public key ...");
418 ret = mbedtls_pk_parse_public_keyfile(&key, opt.filename);
429 * 1.2 Print the key
434 if (mbedtls_pk_get_type(&key) == MBEDTLS_PK_RSA) {
435 mbedtls_rsa_context *rsa = mbedtls_pk_rsa(key);
447 if (mbedtls_pk_get_type(&key) == MBEDTLS_PK_ECKEY) {
448 if (show_ecp_key(mbedtls_pk_ec(key), 0) != 0) {
454 mbedtls_printf("key type not supported yet\n");
460 write_public_key(&key, opt.output_file);
463 write_private_key(&key, opt.output_file);
485 mbedtls_pk_free(&key);