diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2011-05-22 16:26:12 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2011-05-22 16:26:16 +0200 |
commit | f91665debbb2b044ef95b0676a41cbf9c8ba2e79 (patch) | |
tree | 059c9657907a640ae0b5c5f658ca28a0b5e80c70 /src | |
parent | 98aefa42a4f5ba83d4cb925debf3b3536c4060e7 (diff) | |
download | gnutls-f91665debbb2b044ef95b0676a41cbf9c8ba2e79.tar.gz |
Corrected bug in public key import.
print information on ECC public keys.
Diffstat (limited to 'src')
-rw-r--r-- | src/certtool-common.c | 2 | ||||
-rw-r--r-- | src/certtool.c | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/certtool-common.c b/src/certtool-common.c index a4cc71c92b..91fbbeb314 100644 --- a/src/certtool-common.c +++ b/src/certtool-common.c @@ -547,7 +547,7 @@ load_pubkey (int mand, common_info_st * info) if (info->pubkey == NULL) error (EXIT_FAILURE, 0, "missing --load-pubkey"); - if (strncmp(info->privkey, "pkcs11:", 7) == 0) + if (strncmp(info->pubkey, "pkcs11:", 7) == 0) return _load_pkcs11_pubkey(info->pubkey); ret = gnutls_pubkey_init (&key); diff --git a/src/certtool.c b/src/certtool.c index 83b7f53bec..17443cfb83 100644 --- a/src/certtool.c +++ b/src/certtool.c @@ -144,6 +144,21 @@ print_dsa_pkey (gnutls_datum_t * x, gnutls_datum_t * y, gnutls_datum_t * p, } static void +print_ecc_pkey (gnutls_ecc_curve_t curve, gnutls_datum_t* k, gnutls_datum_t * x, gnutls_datum_t * y) +{ + if (k) + { + fprintf (outfile, "private key:"); + print_hex_datum (k); + } + fprintf (outfile, "curve:\t%s\n", gnutls_ecc_curve_get_name(curve)); + fprintf (outfile, "x:"); + print_hex_datum (x); + fprintf (outfile, "y:"); + print_hex_datum (y); +} + +static void print_rsa_pkey (gnutls_datum_t * m, gnutls_datum_t * e, gnutls_datum_t * d, gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * u, gnutls_datum_t * exp1, gnutls_datum_t * exp2) @@ -2933,6 +2948,22 @@ pubkey_info (gnutls_x509_crt_t crt, common_info_st * cinfo) gnutls_free (g.data); } } + else if (ret == GNUTLS_PK_ECC) + { + gnutls_datum_t x, y; + gnutls_ecc_curve_t curve; + + ret = gnutls_pubkey_get_pk_ecc_raw (pubkey, &curve, &x, &y); + if (ret < 0) + fprintf (stderr, "Error in key ECC data export: %s\n", + gnutls_strerror (ret)); + else + { + print_ecc_pkey (curve, NULL, &y, &x); + gnutls_free (y.data); + gnutls_free (x.data); + } + } ret = gnutls_pubkey_get_key_usage (pubkey, &usage); if (ret < 0) |