From 3fe99382027ed4b483e11dcef48cf5b5c17a4898 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 1 Jul 2011 10:33:43 +0200 Subject: [PATCH] Provide pubkey letters e and E This is only to print those letters instead of a question mark. It does not mean ECC is or will be supported in this branch. --- g10/ChangeLog | 4 ++++ g10/keyid.c | 41 +++++++++++++++++++++-------------------- include/ChangeLog | 12 +++++++----- include/cipher.h | 16 +++++++++------- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index a7bcf9d4a..55ba2b6ca 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,7 @@ +2011-07-01 Werner Koch + + * keyid.c (pubkey_letter): Add letters e and E. + 2011-06-13 Werner Koch * pkglue.c (mpi_from_sexp, pk_decrypt): Use GCRYMPI_FMT_USG for diff --git a/g10/keyid.c b/g10/keyid.c index 3ba7d4256..d7a877ba3 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -45,6 +45,8 @@ pubkey_letter( int algo ) 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) */ default: return '?'; } } @@ -102,7 +104,7 @@ hash_public_key( gcry_md_hd_t md, PKT_public_key *pk ) u16 days=0; if(pk->expiredate) days=(u16)((pk->expiredate - pk->timestamp) / 86400L); - + gcry_md_putc ( md, days >> 8 ); gcry_md_putc ( md, days ); } @@ -170,7 +172,7 @@ v3_keyid (gcry_mpi_t a, u32 *ki) BUG (); if (nbytes < 8) /* oops */ ki[0] = ki[1] = 0; - else + else { p = buffer + nbytes - 8; ki[0] = (p[0] << 24) | (p[1] <<16) | (p[2] << 8) | p[3]; @@ -206,7 +208,7 @@ keystrlen(void) const char * keystr(u32 *keyid) -{ +{ static char keyid_str[19]; switch(opt.keyid_format) @@ -452,13 +454,13 @@ namehash_from_uid(PKT_user_id *uid) if (!uid->namehash) { uid->namehash = xmalloc (20); - + if(uid->attrib_data) rmd160_hash_buffer (uid->namehash, uid->attrib_data, uid->attrib_len); else rmd160_hash_buffer (uid->namehash, uid->name, uid->len); } - + return uid->namehash; } @@ -636,7 +638,7 @@ const char * colon_datestr_from_sig (PKT_signature *sig) { static char buf[20]; - + snprintf (buf, sizeof buf, "%lu", (ulong)sig->timestamp); return buf; } @@ -667,21 +669,21 @@ fingerprint_from_pk( PKT_public_key *pk, byte *array, size_t *ret_len ) const byte *dp; size_t len, nbytes; int i; - + if ( pk->version < 4 ) { if ( is_RSA(pk->pubkey_algo) ) { /* RSA in version 3 packets is special. */ gcry_md_hd_t md; - + if (gcry_md_open (&md, DIGEST_ALGO_MD5, 0)) BUG (); - if ( pubkey_get_npkey (pk->pubkey_algo) > 1 ) + if ( pubkey_get_npkey (pk->pubkey_algo) > 1 ) { for (i=0; i < 2; i++) { - if (gcry_mpi_print (GCRYMPI_FMT_USG, NULL, 0, + if (gcry_mpi_print (GCRYMPI_FMT_USG, NULL, 0, &nbytes, pk->pkey[i])) BUG (); /* fixme: Better allocate BUF on the stack */ @@ -708,10 +710,10 @@ fingerprint_from_pk( PKT_public_key *pk, byte *array, size_t *ret_len ) memset (array,0,16); } } - else + else { gcry_md_hd_t md; - + md = do_fingerprint_md(pk); dp = gcry_md_read( md, 0 ); len = gcry_md_get_algo_dlen (gcry_md_get_algo (md)); @@ -723,7 +725,7 @@ fingerprint_from_pk( PKT_public_key *pk, byte *array, size_t *ret_len ) pk->keyid[1] = dp[16] << 24 | dp[17] << 16 | dp[18] << 8 | dp[19] ; gcry_md_close( md); } - + *ret_len = len; return array; } @@ -735,21 +737,21 @@ fingerprint_from_sk( PKT_secret_key *sk, byte *array, size_t *ret_len ) const char *dp; size_t len, nbytes; int i; - + if (sk->version < 4) { if ( is_RSA(sk->pubkey_algo) ) { /* RSA in version 3 packets is special. */ gcry_md_hd_t md; - + if (gcry_md_open (&md, DIGEST_ALGO_MD5, 0)) BUG (); if (pubkey_get_npkey( sk->pubkey_algo ) > 1) { for (i=0; i < 2; i++) { - if (gcry_mpi_print (GCRYMPI_FMT_USG, NULL, 0, + if (gcry_mpi_print (GCRYMPI_FMT_USG, NULL, 0, &nbytes, sk->skey[i])) BUG (); /* fixme: Better allocate BUF on the stack */ @@ -779,7 +781,7 @@ fingerprint_from_sk( PKT_secret_key *sk, byte *array, size_t *ret_len ) else { gcry_md_hd_t md; - + md = do_fingerprint_md_sk(sk); if (md) { @@ -799,7 +801,7 @@ fingerprint_from_sk( PKT_secret_key *sk, byte *array, size_t *ret_len ) memset (array, 0, len); } } - + *ret_len = len; return array; } @@ -816,7 +818,7 @@ serialno_and_fpr_from_sk (const unsigned char *sn, size_t snlen, size_t fprlen; char *buffer, *p; int i; - + fingerprint_from_sk (sk, fpr, &fprlen); buffer = p = xmalloc (snlen*2 + 1 + fprlen*2 + 1); for (i=0; i < snlen; i++, p+=2) @@ -827,4 +829,3 @@ serialno_and_fpr_from_sk (const unsigned char *sn, size_t snlen, *p = 0; return buffer; } - diff --git a/include/ChangeLog b/include/ChangeLog index 339800f37..97f491e20 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2011-07-01 Werner Koch + + * cipher.h (PUBKEY_ALGO_ECDH, PUBKEY_ALGO_ECDSA): New. + 2009-08-20 Daiki Ueno (wk) * cipher.h (struct DEK): Add field S2K_CACHEID. @@ -215,7 +219,7 @@ * KEYSERVER_SCHEME_NOT_FOUND should be 127 to match the POSIX system() (via /bin/sh) way of signaling this. - + * Added G10ERR_KEYSERVER 2001-12-27 Werner Koch @@ -245,7 +249,7 @@ 2001-08-24 Werner Koch - * cipher.h (md_write): Made buf arg const. + * cipher.h (md_write): Made buf arg const. 2001-08-20 Werner Koch @@ -255,7 +259,7 @@ never use __attribute__. * cipher.h, iobuf.h, memory.h, mpi.h [__riscos__]: extern hack. * i18n.h [__riscos__]: Use another include file - + 2001-05-30 Werner Koch * ttyio.h (tty_printf): Add missing parenthesis for non gcc. @@ -431,5 +435,3 @@ Tue Mar 3 15:11:21 1998 Werner Koch (wk@isil.d.shuttle.de) This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - diff --git a/include/cipher.h b/include/cipher.h index 8e198283d..f5caa8deb 100644 --- a/include/cipher.h +++ b/include/cipher.h @@ -1,4 +1,4 @@ -/* cipher.h - Definitions for OpenPGP +/* cipher.h - Definitions for OpenPGP * Copyright (C) 1998, 1999, 2000, 2001, 2006, * 2007 Free Software Foundation, Inc. * @@ -24,8 +24,8 @@ /* Macros for compatibility with older libgcrypt versions. */ #ifndef GCRY_PK_USAGE_CERT -# define GCRY_PK_USAGE_CERT 4 -# define GCRY_PK_USAGE_AUTH 8 +# define GCRY_PK_USAGE_CERT 4 +# define GCRY_PK_USAGE_AUTH 8 # define GCRY_PK_USAGE_UNKN 128 #endif @@ -51,11 +51,13 @@ #define CIPHER_ALGO_CAMELLIA256 13 #define CIPHER_ALGO_DUMMY 110 /* No encryption at all. */ -#define PUBKEY_ALGO_RSA /* 1 */ GCRY_PK_RSA -#define PUBKEY_ALGO_RSA_E /* 2 */ GCRY_PK_RSA_E /* RSA encrypt only. */ +#define PUBKEY_ALGO_RSA /* 1 */ GCRY_PK_RSA +#define PUBKEY_ALGO_RSA_E /* 2 */ GCRY_PK_RSA_E /* RSA encrypt only. */ #define PUBKEY_ALGO_RSA_S /* 3 */ GCRY_PK_RSA_S /* RSA sign only. */ #define PUBKEY_ALGO_ELGAMAL_E /* 16 */ GCRY_PK_ELG_E /* Elgamal encr only */ -#define PUBKEY_ALGO_DSA /* 17 */ GCRY_PK_DSA +#define PUBKEY_ALGO_DSA /* 17 */ GCRY_PK_DSA +#define PUBKEY_ALGO_ECDH 18 +#define PUBKEY_ALGO_ECDSA 19 #define PUBKEY_ALGO_ELGAMAL /* 20 */ GCRY_PK_ELG /* Elgamal encr+sign */ #define PUBKEY_USAGE_SIG GCRY_PK_USAGE_SIGN /* Good for signatures. */ @@ -86,7 +88,7 @@ #define is_DSA(a) ((a)==PUBKEY_ALGO_DSA) /* The data encryption key object. */ -typedef struct +typedef struct { int algo; int keylen;