aboutsummaryrefslogtreecommitdiffstats
path: root/g10/keyid.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2011-01-21 11:00:57 +0000
committerWerner Koch <[email protected]>2011-01-21 11:00:57 +0000
commit90b0ff23b7e51332592668e4034967c1aac1c593 (patch)
treea3ef4cbd4c679a954a2cceba218b54cc2e2e9be5 /g10/keyid.c
parentAdd ignore file (diff)
downloadgnupg-90b0ff23b7e51332592668e4034967c1aac1c593.tar.gz
gnupg-90b0ff23b7e51332592668e4034967c1aac1c593.zip
Editorial changes and allow building with old libgcrypts.
Changed order of some conditional to make to put the special case into the true branch. Indentation changes. Minor other changes to make the ECC code more similar to the rest of our code. It builds but many sefltests still fail. Need to fix that before using it with an ECDH enabled libgcrypt. [/] 2011-01-21 Werner Koch <[email protected]> * configure.ac: Need Libgcrypt 1.4.6 due to AESWRAP. (HAVE_GCRY_PK_ECDH): Add new test. [agent/] 2011-01-21 Werner Koch <[email protected]> * cvt-openpgp.c (GCRY_PK_ECDH) [!HAVE_GCRY_PK_ECDH]: New. [include/] 2011-01-21 Werner Koch <[email protected]> * cipher.h (GCRY_PK_USAGE_CERT): Remove compatibility macros because we now require libgcrypt 1.4.6. (GCRY_PK_ECDH): Add replacement.
Diffstat (limited to '')
-rw-r--r--g10/keyid.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/g10/keyid.c b/g10/keyid.c
index 2a9bd1988..0405b8b2f 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -54,11 +54,11 @@ pubkey_letter( int algo )
case PUBKEY_ALGO_RSA: return 'R' ;
case PUBKEY_ALGO_RSA_E: return 'r' ;
case PUBKEY_ALGO_RSA_S: return 's' ;
- case PUBKEY_ALGO_ELGAMAL_E: return 'g';
+ case PUBKEY_ALGO_ELGAMAL_E: return 'g' ;
case PUBKEY_ALGO_ELGAMAL: return 'G' ;
case PUBKEY_ALGO_DSA: return 'D' ;
- case PUBKEY_ALGO_ECDSA: return 'E' ; // ECC DSA (sign only)
- case PUBKEY_ALGO_ECDH: return 'e' ; // ECC DH (encrypt only)
+ case PUBKEY_ALGO_ECDSA: return 'E' ; /* ECC DSA (sign only) */
+ case PUBKEY_ALGO_ECDH: return 'e' ; /* ECC DH (encrypt only) */
default: return '?';
}
}
@@ -76,8 +76,6 @@ hash_public_key (gcry_md_hd_t md, PKT_public_key *pk)
unsigned int nbits;
size_t nbytes;
int npkey = pubkey_get_npkey (pk->pubkey_algo);
- /* name OID, MPI of public point, [for ECDH only: KEK params] */
- enum gcry_mpi_format ecc_pub_format[3] = {GCRYMPI_FMT_USG, GCRYMPI_FMT_PGP, GCRYMPI_FMT_USG};
/* Two extra bytes for the expiration date in v3 */
if(pk->version<4)
@@ -92,11 +90,17 @@ hash_public_key (gcry_md_hd_t md, PKT_public_key *pk)
}
else
{
- for(i=0; i < npkey; i++ )
+ for (i=0; i < npkey; i++ )
{
- const enum gcry_mpi_format fmt =
- ((pk->pubkey_algo==PUBKEY_ALGO_ECDSA || pk->pubkey_algo==PUBKEY_ALGO_ECDH) ? ecc_pub_format[i] : GCRYMPI_FMT_PGP);
-
+ enum gcry_mpi_format fmt;
+
+ if ((pk->pubkey_algo == PUBKEY_ALGO_ECDSA
+ || pk->pubkey_algo == PUBKEY_ALGO_ECDH)
+ && (i == 0 || i == 2))
+ fmt = GCRYMPI_FMT_USG; /* Name of OID or KEK parms. */
+ else
+ fmt = GCRYMPI_FMT_PGP;
+
if (gcry_mpi_print (fmt, NULL, 0, &nbytes, pk->pkey[i]))
BUG ();
pp[i] = xmalloc (nbytes);
@@ -106,7 +110,7 @@ hash_public_key (gcry_md_hd_t md, PKT_public_key *pk)
n += nn[i];
}
}
-
+
gcry_md_putc ( md, 0x99 ); /* ctb */
/* What does it mean if n is greater than than 0xFFFF ? */
gcry_md_putc ( md, n >> 8 ); /* 2 byte length header */
@@ -724,13 +728,12 @@ keygrip_from_pk (PKT_public_key *pk, unsigned char *array)
"(public-key(ecc(c%m)(q%m)))",
pk->pkey[0], pk->pkey[1]);
break;
-/*
- case PUBKEY_ALGO_ECDH:
- err = gcry_sexp_build (&s_pkey, NULL,
- "(public-key(ecdh(c%m)(q%m)(p%m)))",
- pk->pkey[0], pk->pkey[1], pk->pkey[2]);
- break;
-*/
+
+ /* case PUBKEY_ALGO_ECDH: */
+ /* err = gcry_sexp_build (&s_pkey, NULL, */
+ /* "(public-key(ecdh(c%m)(q%m)(p%m)))", */
+ /* pk->pkey[0], pk->pkey[1], pk->pkey[2]); */
+ /* break; */
default:
err = gpg_error (GPG_ERR_PUBKEY_ALGO);