mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-28 22:49:59 +01:00
Fixes to the libgcrypt switch. Basically works now.
This commit is contained in:
parent
c0c2c58054
commit
b7bd5e8088
@ -1,3 +1,23 @@
|
|||||||
|
2003-06-23 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* keyid.c (do_fingerprint_md): Made it work again.
|
||||||
|
|
||||||
|
2003-06-19 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
Fixed all "==" comparisons against error code constants to use
|
||||||
|
gpg_err_code().
|
||||||
|
|
||||||
|
* import.c (import_secret_one):
|
||||||
|
(import_revoke_cert):
|
||||||
|
(chk_self_sigs):
|
||||||
|
|
||||||
|
* misc.c (openpgp_md_map_name): Check also for the Hx format.
|
||||||
|
(openpgp_cipher_map_name): Check also for the Sx format.
|
||||||
|
(pubkey_get_npkey): Adjusted for changed gcrypt API.
|
||||||
|
(pubkey_get_nskey): Ditto.
|
||||||
|
(pubkey_get_nsig): Ditto.
|
||||||
|
(pubkey_get_nenc): Ditto.
|
||||||
|
|
||||||
2003-06-18 Werner Koch <wk@gnupg.org>
|
2003-06-18 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
Finished the bulk of changes for gnupg 1.9. This included
|
Finished the bulk of changes for gnupg 1.9. This included
|
||||||
|
11
g10/import.c
11
g10/import.c
@ -906,7 +906,8 @@ import_secret_one( const char *fname, KBNODE keyblock,
|
|||||||
|
|
||||||
/* do we have this key already in one of our secrings ? */
|
/* do we have this key already in one of our secrings ? */
|
||||||
rc = seckey_available( keyid );
|
rc = seckey_available( keyid );
|
||||||
if( rc == GPG_ERR_NO_SECKEY && !opt.merge_only ) { /* simply insert this key */
|
if( gpg_err_code (rc) == GPG_ERR_NO_SECKEY && !opt.merge_only ) {
|
||||||
|
/* simply insert this key */
|
||||||
KEYDB_HANDLE hd = keydb_new (1);
|
KEYDB_HANDLE hd = keydb_new (1);
|
||||||
|
|
||||||
/* get default resource */
|
/* get default resource */
|
||||||
@ -977,7 +978,7 @@ import_revoke_cert( const char *fname, KBNODE node, struct stats_s *stats )
|
|||||||
|
|
||||||
pk = xcalloc (1, sizeof *pk );
|
pk = xcalloc (1, sizeof *pk );
|
||||||
rc = get_pubkey( pk, keyid );
|
rc = get_pubkey( pk, keyid );
|
||||||
if( rc == GPG_ERR_NO_PUBKEY ) {
|
if( gpg_err_code (rc) == GPG_ERR_NO_PUBKEY ) {
|
||||||
log_info( _("key %08lX: no public key - "
|
log_info( _("key %08lX: no public key - "
|
||||||
"can't apply revocation certificate\n"), (ulong)keyid[1]);
|
"can't apply revocation certificate\n"), (ulong)keyid[1]);
|
||||||
rc = 0;
|
rc = 0;
|
||||||
@ -1126,7 +1127,7 @@ chk_self_sigs( const char *fname, KBNODE keyblock,
|
|||||||
{
|
{
|
||||||
char *p=utf8_to_native(unode->pkt->pkt.user_id->name,
|
char *p=utf8_to_native(unode->pkt->pkt.user_id->name,
|
||||||
strlen(unode->pkt->pkt.user_id->name),0);
|
strlen(unode->pkt->pkt.user_id->name),0);
|
||||||
log_info( rc == GPG_ERR_PUBKEY_ALGO ?
|
log_info( gpg_err_code (rc) == GPG_ERR_PUBKEY_ALGO ?
|
||||||
_("key %08lX: unsupported public key "
|
_("key %08lX: unsupported public key "
|
||||||
"algorithm on user id \"%s\"\n"):
|
"algorithm on user id \"%s\"\n"):
|
||||||
_("key %08lX: invalid self-signature "
|
_("key %08lX: invalid self-signature "
|
||||||
@ -1151,7 +1152,7 @@ chk_self_sigs( const char *fname, KBNODE keyblock,
|
|||||||
else {
|
else {
|
||||||
rc = check_key_signature( keyblock, n, NULL);
|
rc = check_key_signature( keyblock, n, NULL);
|
||||||
if( rc ) {
|
if( rc ) {
|
||||||
log_info( rc == GPG_ERR_PUBKEY_ALGO ?
|
log_info( gpg_err_code (rc) == GPG_ERR_PUBKEY_ALGO ?
|
||||||
_("key %08lX: unsupported public key algorithm\n"):
|
_("key %08lX: unsupported public key algorithm\n"):
|
||||||
_("key %08lX: invalid subkey binding\n"),
|
_("key %08lX: invalid subkey binding\n"),
|
||||||
(ulong)keyid[1]);
|
(ulong)keyid[1]);
|
||||||
@ -1192,7 +1193,7 @@ chk_self_sigs( const char *fname, KBNODE keyblock,
|
|||||||
else {
|
else {
|
||||||
rc = check_key_signature( keyblock, n, NULL);
|
rc = check_key_signature( keyblock, n, NULL);
|
||||||
if( rc ) {
|
if( rc ) {
|
||||||
log_info( rc == GPG_ERR_PUBKEY_ALGO ?
|
log_info( gpg_err_code (rc) == GPG_ERR_PUBKEY_ALGO ?
|
||||||
_("key %08lX: unsupported public key algorithm\n"):
|
_("key %08lX: unsupported public key algorithm\n"):
|
||||||
_("key %08lX: invalid subkey revocation\n"),
|
_("key %08lX: invalid subkey revocation\n"),
|
||||||
(ulong)keyid[1]);
|
(ulong)keyid[1]);
|
||||||
|
10
g10/keyid.c
10
g10/keyid.c
@ -54,15 +54,15 @@ static gcry_md_hd_t
|
|||||||
do_fingerprint_md( PKT_public_key *pk )
|
do_fingerprint_md( PKT_public_key *pk )
|
||||||
{
|
{
|
||||||
gcry_md_hd_t md;
|
gcry_md_hd_t md;
|
||||||
unsigned n;
|
unsigned int n;
|
||||||
unsigned nb[PUBKEY_MAX_NPKEY];
|
unsigned int nn[PUBKEY_MAX_NPKEY];
|
||||||
unsigned nn[PUBKEY_MAX_NPKEY];
|
|
||||||
byte *pp[PUBKEY_MAX_NPKEY];
|
byte *pp[PUBKEY_MAX_NPKEY];
|
||||||
int i;
|
int i;
|
||||||
int npkey = pubkey_get_npkey( pk->pubkey_algo );
|
int npkey = pubkey_get_npkey( pk->pubkey_algo );
|
||||||
|
|
||||||
gcry_md_open (&md, pk->version < 4 ? DIGEST_ALGO_RMD160
|
gcry_md_open (&md, pk->version < 4 ? DIGEST_ALGO_RMD160
|
||||||
: DIGEST_ALGO_SHA1, 0);
|
: DIGEST_ALGO_SHA1, 0);
|
||||||
|
gcry_md_start_debug (md,"keyid");
|
||||||
n = pk->version < 4 ? 8 : 6;
|
n = pk->version < 4 ? 8 : 6;
|
||||||
for(i=0; i < npkey; i++ ) {
|
for(i=0; i < npkey; i++ ) {
|
||||||
size_t nbytes;
|
size_t nbytes;
|
||||||
@ -74,7 +74,7 @@ do_fingerprint_md( PKT_public_key *pk )
|
|||||||
if (gcry_mpi_print ( GCRYMPI_FMT_PGP, pp[i], &nbytes, pk->pkey[i] ))
|
if (gcry_mpi_print ( GCRYMPI_FMT_PGP, pp[i], &nbytes, pk->pkey[i] ))
|
||||||
BUG ();
|
BUG ();
|
||||||
nn[i] = nbytes;
|
nn[i] = nbytes;
|
||||||
n += 2 + nn[i];
|
n += nn[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
gcry_md_putc ( md, 0x99 ); /* ctb */
|
gcry_md_putc ( md, 0x99 ); /* ctb */
|
||||||
@ -103,8 +103,6 @@ do_fingerprint_md( PKT_public_key *pk )
|
|||||||
}
|
}
|
||||||
gcry_md_putc ( md, pk->pubkey_algo );
|
gcry_md_putc ( md, pk->pubkey_algo );
|
||||||
for(i=0; i < npkey; i++ ) {
|
for(i=0; i < npkey; i++ ) {
|
||||||
gcry_md_putc ( md, nb[i]>>8);
|
|
||||||
gcry_md_putc ( md, nb[i] );
|
|
||||||
gcry_md_write( md, pp[i], nn[i] );
|
gcry_md_write( md, pp[i], nn[i] );
|
||||||
xfree (pp[i]);
|
xfree (pp[i]);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ new_offset_hash_table (void)
|
|||||||
{
|
{
|
||||||
struct off_item **tbl;
|
struct off_item **tbl;
|
||||||
|
|
||||||
tbl = xcalloc (1,2048 * sizeof *tbl);
|
tbl = xcalloc (2048, sizeof *tbl);
|
||||||
return tbl;
|
return tbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
|
|||||||
save_mode = set_packet_list_mode(0);
|
save_mode = set_packet_list_mode(0);
|
||||||
while ((rc=parse_packet (a, pkt)) != -1) {
|
while ((rc=parse_packet (a, pkt)) != -1) {
|
||||||
hd->found.n_packets++;
|
hd->found.n_packets++;
|
||||||
if (rc == GPG_ERR_UNKNOWN_PACKET) {
|
if (gpg_err_code (rc) == GPG_ERR_UNKNOWN_PACKET) {
|
||||||
free_packet (pkt);
|
free_packet (pkt);
|
||||||
init_packet (pkt);
|
init_packet (pkt);
|
||||||
continue;
|
continue;
|
||||||
@ -478,7 +478,7 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
|
|||||||
/* Make sure that future search operations fail immediately when
|
/* Make sure that future search operations fail immediately when
|
||||||
* we know that we are working on a invalid keyring
|
* we know that we are working on a invalid keyring
|
||||||
*/
|
*/
|
||||||
if (rc == GPG_ERR_INV_KEYRING)
|
if (gpg_err_code (rc) == GPG_ERR_INV_KEYRING)
|
||||||
hd->current.error = rc;
|
hd->current.error = rc;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -428,7 +428,7 @@ print_pkenc_list( struct kidlist_item *list, int failed )
|
|||||||
}
|
}
|
||||||
free_public_key( pk );
|
free_public_key( pk );
|
||||||
|
|
||||||
if( list->reason == GPG_ERR_NO_SECKEY ) {
|
if( gpg_err_code (list->reason) == GPG_ERR_NO_SECKEY ) {
|
||||||
if( is_status_enabled() ) {
|
if( is_status_enabled() ) {
|
||||||
char buf[20];
|
char buf[20];
|
||||||
sprintf(buf,"%08lX%08lX", (ulong)list->kid[0],
|
sprintf(buf,"%08lX%08lX", (ulong)list->kid[0],
|
||||||
@ -1189,7 +1189,7 @@ do_proc_packets( CTX c, iobuf_t a )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( rc == GPG_ERR_INV_PACKET )
|
if( gpg_err_code (rc) == GPG_ERR_INV_PACKET )
|
||||||
write_status_text( STATUS_NODATA, "3" );
|
write_status_text( STATUS_NODATA, "3" );
|
||||||
if( any_data )
|
if( any_data )
|
||||||
rc = 0;
|
rc = 0;
|
||||||
@ -1280,7 +1280,8 @@ check_sig_and_print( CTX c, KBNODE node )
|
|||||||
(int)strlen(tstr), tstr, astr? astr: "?", (ulong)sig->keyid[1] );
|
(int)strlen(tstr), tstr, astr? astr: "?", (ulong)sig->keyid[1] );
|
||||||
|
|
||||||
rc = do_check_sig(c, node, NULL, &is_expkey );
|
rc = do_check_sig(c, node, NULL, &is_expkey );
|
||||||
if( rc == GPG_ERR_NO_PUBKEY && opt.keyserver_scheme && opt.keyserver_options.auto_key_retrieve) {
|
if( gpg_err_code (rc) == GPG_ERR_NO_PUBKEY
|
||||||
|
&& opt.keyserver_scheme && opt.keyserver_options.auto_key_retrieve) {
|
||||||
if( keyserver_import_keyid ( sig->keyid )==0 )
|
if( keyserver_import_keyid ( sig->keyid )==0 )
|
||||||
rc = do_check_sig(c, node, NULL, &is_expkey );
|
rc = do_check_sig(c, node, NULL, &is_expkey );
|
||||||
}
|
}
|
||||||
@ -1482,14 +1483,14 @@ check_sig_and_print( CTX c, KBNODE node )
|
|||||||
if( opt.batch && rc )
|
if( opt.batch && rc )
|
||||||
g10_exit(1);
|
g10_exit(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char buf[50];
|
char buf[50];
|
||||||
sprintf(buf, "%08lX%08lX %d %d %02x %lu %d",
|
sprintf(buf, "%08lX%08lX %d %d %02x %lu %d",
|
||||||
(ulong)sig->keyid[0], (ulong)sig->keyid[1],
|
(ulong)sig->keyid[0], (ulong)sig->keyid[1],
|
||||||
sig->pubkey_algo, sig->digest_algo,
|
sig->pubkey_algo, sig->digest_algo,
|
||||||
sig->sig_class, (ulong)sig->timestamp, rc );
|
sig->sig_class, (ulong)sig->timestamp, rc );
|
||||||
write_status_text( STATUS_ERRSIG, buf );
|
write_status_text( STATUS_ERRSIG, buf );
|
||||||
if( rc == GPG_ERR_NO_PUBKEY ) {
|
if( gpg_err_code (rc) == GPG_ERR_NO_PUBKEY ) {
|
||||||
buf[16] = 0;
|
buf[16] = 0;
|
||||||
write_status_text( STATUS_NO_PUBKEY, buf );
|
write_status_text( STATUS_NO_PUBKEY, buf );
|
||||||
}
|
}
|
||||||
|
65
g10/misc.c
65
g10/misc.c
@ -244,6 +244,9 @@ openpgp_pk_test_algo( int algo, unsigned int usage_flags )
|
|||||||
{
|
{
|
||||||
size_t value = usage_flags;
|
size_t value = usage_flags;
|
||||||
|
|
||||||
|
if (algo == GCRY_PK_ELG_E)
|
||||||
|
algo = GCRY_PK_ELG;
|
||||||
|
#warning need to handle the usage here?
|
||||||
if (algo < 0 || algo > 110)
|
if (algo < 0 || algo > 110)
|
||||||
return GPG_ERR_PUBKEY_ALGO;
|
return GPG_ERR_PUBKEY_ALGO;
|
||||||
return gcry_pk_algo_info (algo, GCRYCTL_TEST_ALGO, NULL, &value);
|
return gcry_pk_algo_info (algo, GCRYCTL_TEST_ALGO, NULL, &value);
|
||||||
@ -292,6 +295,18 @@ int
|
|||||||
openpgp_md_map_name (const char *string)
|
openpgp_md_map_name (const char *string)
|
||||||
{
|
{
|
||||||
int i = gcry_md_map_name (string);
|
int i = gcry_md_map_name (string);
|
||||||
|
|
||||||
|
if (!i && (string[0]=='H' || string[0]=='h'))
|
||||||
|
{ /* Didn't find it, so try the Hx format */
|
||||||
|
long val;
|
||||||
|
char *endptr;
|
||||||
|
|
||||||
|
string++;
|
||||||
|
|
||||||
|
val=strtol(string,&endptr,10);
|
||||||
|
if (*string!='\0' && *endptr=='\0' && !openpgp_md_test_algo(val))
|
||||||
|
i = val;
|
||||||
|
}
|
||||||
return i < 0 || i > 110? 0 : i;
|
return i < 0 || i > 110? 0 : i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,6 +314,18 @@ int
|
|||||||
openpgp_cipher_map_name (const char *string)
|
openpgp_cipher_map_name (const char *string)
|
||||||
{
|
{
|
||||||
int i = gcry_cipher_map_name (string);
|
int i = gcry_cipher_map_name (string);
|
||||||
|
|
||||||
|
if (!i && (string[0]=='S' || string[0]=='s'))
|
||||||
|
{ /* Didn't find it, so try the Sx format */
|
||||||
|
long val;
|
||||||
|
char *endptr;
|
||||||
|
|
||||||
|
string++;
|
||||||
|
|
||||||
|
val=strtol(string,&endptr,10);
|
||||||
|
if (*string!='\0' && *endptr=='\0' && !openpgp_cipher_test_algo(val))
|
||||||
|
i = val;
|
||||||
|
}
|
||||||
return i < 0 || i > 110? 0 : i;
|
return i < 0 || i > 110? 0 : i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,32 +730,52 @@ parse_options(char *str,unsigned int *options,struct parse_options *opts)
|
|||||||
int
|
int
|
||||||
pubkey_get_npkey( int algo )
|
pubkey_get_npkey( int algo )
|
||||||
{
|
{
|
||||||
int n = gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NPKEY, NULL, 0 );
|
size_t n;
|
||||||
return n > 0? n : 0;
|
|
||||||
|
if (algo == GCRY_PK_ELG_E)
|
||||||
|
algo = GCRY_PK_ELG;
|
||||||
|
if (gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NPKEY, NULL, &n))
|
||||||
|
n = 0;
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Temporary helper. */
|
/* Temporary helper. */
|
||||||
int
|
int
|
||||||
pubkey_get_nskey( int algo )
|
pubkey_get_nskey( int algo )
|
||||||
{
|
{
|
||||||
int n = gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NSKEY, NULL, 0 );
|
size_t n;
|
||||||
return n > 0? n : 0;
|
|
||||||
|
if (algo == GCRY_PK_ELG_E)
|
||||||
|
algo = GCRY_PK_ELG;
|
||||||
|
if (gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NSKEY, NULL, &n ))
|
||||||
|
n = 0;
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Temporary helper. */
|
/* Temporary helper. */
|
||||||
int
|
int
|
||||||
pubkey_get_nsig( int algo )
|
pubkey_get_nsig( int algo )
|
||||||
{
|
{
|
||||||
int n = gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NSIGN, NULL, 0 );
|
size_t n;
|
||||||
return n > 0? n : 0;
|
|
||||||
|
if (algo == GCRY_PK_ELG_E)
|
||||||
|
algo = GCRY_PK_ELG;
|
||||||
|
if (gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NSIGN, NULL, &n))
|
||||||
|
n = 0;
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Temporary helper. */
|
/* Temporary helper. */
|
||||||
int
|
int
|
||||||
pubkey_get_nenc( int algo )
|
pubkey_get_nenc( int algo )
|
||||||
{
|
{
|
||||||
int n = gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NENCR, NULL, 0 );
|
size_t n;
|
||||||
return n > 0? n : 0;
|
|
||||||
|
if (algo == GCRY_PK_ELG_E)
|
||||||
|
algo = GCRY_PK_ELG;
|
||||||
|
if (gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NENCR, NULL, &n ))
|
||||||
|
n = 0;
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -788,7 +835,7 @@ mpi_write( iobuf_t out, gcry_mpi_t a )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
* Writye a MPI to out, but in this case it is an opaque one,
|
* Writyeg a MPI to out, but in this case it is an opaque one,
|
||||||
* s used vor v3 protected keys.
|
* s used vor v3 protected keys.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
|
@ -190,7 +190,7 @@ get_it( PKT_pubkey_enc *enc, DEK *dek, PKT_secret_key *sk, u32 *keyid )
|
|||||||
write_status(STATUS_RSA_OR_IDEA);
|
write_status(STATUS_RSA_OR_IDEA);
|
||||||
rc = openpgp_cipher_test_algo (dek->algo);
|
rc = openpgp_cipher_test_algo (dek->algo);
|
||||||
if( rc ) {
|
if( rc ) {
|
||||||
if( !opt.quiet && rc == GPG_ERR_CIPHER_ALGO ) {
|
if( !opt.quiet && gpg_err_code (rc) == GPG_ERR_CIPHER_ALGO ) {
|
||||||
log_info(_("cipher algorithm %d%s is unknown or disabled\n"),
|
log_info(_("cipher algorithm %d%s is unknown or disabled\n"),
|
||||||
dek->algo, dek->algo == CIPHER_ALGO_IDEA? " (IDEA)":"");
|
dek->algo, dek->algo == CIPHER_ALGO_IDEA? " (IDEA)":"");
|
||||||
if(dek->algo==CIPHER_ALGO_IDEA)
|
if(dek->algo==CIPHER_ALGO_IDEA)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user