1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-17 14:07:03 +01:00

ready to release 0.4.3

This commit is contained in:
Werner Koch 1998-11-08 17:23:14 +00:00
parent aad7f1a0fc
commit 35c1054507
18 changed files with 344 additions and 135 deletions

View File

@ -1,3 +1,7 @@
Sun Nov 8 18:20:35 1998 Werner Koch (wk@isil.d.shuttle.de)
* VERSION: Set to 0.4.3
Sun Oct 25 19:49:37 1998 Werner Koch (wk@isil.d.shuttle.de) Sun Oct 25 19:49:37 1998 Werner Koch (wk@isil.d.shuttle.de)
* Makefile.am (g10defs.h): New macro GNUPG_DATADIR. * Makefile.am (g10defs.h): New macro GNUPG_DATADIR.

5
NEWS
View File

@ -1,3 +1,5 @@
Noteworthy changes in version 0.4.3
-----------------------------------
* Fixed the gettext configure bug. * Fixed the gettext configure bug.
@ -18,6 +20,9 @@
* commandline option processing now works as expected for GNU programs * commandline option processing now works as expected for GNU programs
with the execption that you can't mix options and normal arguments. with the execption that you can't mix options and normal arguments.
* Now --list-key lists all matching keys. This is needed in some
other places too.
Noteworthy changes in version 0.4.2 Noteworthy changes in version 0.4.2
----------------------------------- -----------------------------------

11
README
View File

@ -1,3 +1,5 @@
-----BEGIN PGP SIGNED MESSAGE-----
GnuPG - The GNU Privacy Guard GnuPG - The GNU Privacy Guard
------------------------------- -------------------------------
Version 0.4 Version 0.4
@ -331,3 +333,12 @@
please subscribe before posting, see above (~line 33)). please subscribe before posting, see above (~line 33)).
-----BEGIN PGP SIGNATURE-----
Version: GNUPG v0.4.2 (GNU/Linux)
Comment: For info finger gcrypt@ftp.guug.de
iQB1AwUBNkXLyx0Z9MEMmFelAQExuwMArLtkLI3vpxZ7tCoit6hELkpyEHe10Bo6
Ms72TXasJ8L0tKNKRE2kagV7Ie7wxl0dyENlumOxsZIKLq8DGSyjSoE7GmMQEEff
ZU+4xpO3KMw6XpJMvUWwlxpm2/WDpYTa
=Y10x
-----END PGP SIGNATURE-----

19
TODO
View File

@ -1,22 +1,17 @@
* rmove assert in random.c:160 4096 bit keys need more random.
* list all matching user ids
* use zlib 1.1.13 to avoid a bug with 13 bit windows * use zlib 1.1.13 to avoid a bug with 13 bit windows
* FreeBSD: * FreeBSD:
#define USE_DYNAMIC_LINKING #define USE_DYNAMIC_LINKING
#define HAVE_DL_DLOPEN #define HAVE_DL_DLOPEN
and the ld option -export-dynamic.
and the ld option -export-dynamic.
* *
Well, there was one thing extra I needed to do. While configure found the Well, there was one thing extra I needed to do. While configure found the
gdbm library, it didn't add the path the the include file list. I had to gdbm library, it didn't add the path the the include file list. I had to
re-run configure with CPPFLAGS set: re-run configure with CPPFLAGS set:
env CPPFLAGS='-I/usr/local/include' configure ... env CPPFLAGS='-I/usr/local/include' configure ...
* clearsig: keep lineendings as they are. Remember that trailings * clearsig: keep lineendings as they are. Remember that trailings

View File

@ -1 +1 @@
0.4.2a 0.4.3

View File

@ -1,3 +1,7 @@
Sun Nov 8 17:44:36 1998 Werner Koch (wk@isil.d.shuttle.de)
* radn-unix.c (read_random_source): Removed the assert.
Mon Oct 19 18:34:30 1998 me,,, (wk@tobold) Mon Oct 19 18:34:30 1998 me,,, (wk@tobold)
* pubkey.c: Hack to allow us to give some info about RSA keys back. * pubkey.c: Hack to allow us to give some info about RSA keys back.

View File

@ -157,7 +157,6 @@ read_random_source( byte *buffer, size_t length, int level )
continue; continue;
} }
assert( length < 500 );
do { do {
n = read(fd, buffer, length ); n = read(fd, buffer, length );
if( n >= 0 && n > length ) { if( n >= 0 && n > length ) {

View File

@ -1,3 +1,15 @@
Sun Nov 8 17:20:39 1998 Werner Koch (wk@isil.d.shuttle.de)
* mainproc.c (check_sig_and_print): Why did I use strlen()-1
in the printf? - This truncated the TZ.
Sat Nov 7 15:57:28 1998 me,,, (wk@tobold)
* getkey.c (lookup): Changes to support a read_next.
(get_pubkey): Fixed a memory leak.
* keylist.c (list_one): Now lists all matching user IDs.
Tue Nov 3 16:19:21 1998 Werner Koch (wk@isil.d.shuttle.de) Tue Nov 3 16:19:21 1998 Werner Koch (wk@isil.d.shuttle.de)
* keygen.c (ask_user_id): Now converted to UTF-8 * keygen.c (ask_user_id): Now converted to UTF-8
@ -10,7 +22,7 @@ Fri Oct 30 16:40:39 1998 me,,, (wk@tobold)
(unblock_all_signals): New (unblock_all_signals): New
* tdbio.c (tdbio_end_transaction): Now blocks all signals. * tdbio.c (tdbio_end_transaction): Now blocks all signals.
* trustdb.c (new_lid_table): Changed the represenation of the * trustdb.c (new_lid_table): Changed the representation of the
former local_lid_info stuff. former local_lid_info stuff.
* trustdb.c (update_trust_record): Reorganized the whole thing. * trustdb.c (update_trust_record): Reorganized the whole thing.

View File

@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#define DEFINES_GETKEY_CTX 1
#include <config.h> #include <config.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -33,10 +35,30 @@
#include "main.h" #include "main.h"
#include "i18n.h" #include "i18n.h"
#define MAX_UNK_CACHE_ENTRIES 1000 #define MAX_UNK_CACHE_ENTRIES 1000 /* we use a linked list - so I guess
* this is a reasonable limit */
#define MAX_PK_CACHE_ENTRIES 50 #define MAX_PK_CACHE_ENTRIES 50
#define MAX_UID_CACHE_ENTRIES 50 #define MAX_UID_CACHE_ENTRIES 50
struct getkey_ctx_s {
int mode;
int internal;
u32 keyid[2];
char *namebuf;
const char *name;
int primary;
KBNODE keyblock;
KBPOS kbpos;
int last_rc;
ulong count;
};
static struct { static struct {
int any; int any;
int okay_count; int okay_count;
@ -82,9 +104,12 @@ static int uid_cache_entries; /* number of entries in uid cache */
static int lookup( PKT_public_key *pk, static int lookup( GETKEY_CTX *ctx, PKT_public_key *pk,
int mode, u32 *keyid, const char *name, int mode, u32 *keyid, const char *name,
KBNODE *ret_keyblock, int primary ); KBNODE *ret_keyblock, int primary );
static void lookup_close( GETKEY_CTX ctx );
static int lookup_read( GETKEY_CTX ctx,
PKT_public_key *pk, KBNODE *ret_keyblock );
static int lookup_sk( PKT_secret_key *sk, static int lookup_sk( PKT_secret_key *sk,
int mode, u32 *keyid, const char *name, int primary ); int mode, u32 *keyid, const char *name, int primary );
@ -223,7 +248,7 @@ get_pubkey( PKT_public_key *pk, u32 *keyid )
/* do a lookup */ /* do a lookup */
rc = lookup( pk, 11, keyid, NULL, NULL, 0 ); rc = lookup( NULL, pk, 11, keyid, NULL, NULL, 0 );
if( !rc ) if( !rc )
goto leave; goto leave;
@ -251,7 +276,7 @@ get_pubkey( PKT_public_key *pk, u32 *keyid )
if( !rc ) if( !rc )
cache_public_key( pk ); cache_public_key( pk );
if( internal ) if( internal )
m_free(pk); free_public_key(pk);
return rc; return rc;
} }
@ -282,12 +307,24 @@ hextobyte( const byte *s )
} }
/**************** /****************
* Try to get the pubkey by the userid. This function looks for the * Return the type of the user id:
* first pubkey certificate which has the given name in a user_id.
* if pk has the pubkey algo set, the function will only return
* a pubkey with that algo.
* *
* 0 = Invalid user ID
* 1 = exact match
* 2 = match a substring
* 3 = match an email address
* 4 = match a substring of an email address
* 5 = match an email address, but compare from end
* 10 = it is a short KEYID (don't care about keyid[0])
* 11 = it is a long KEYID
* 16 = it is a 16 byte fingerprint
* 20 = it is a 20 byte fingerprint
*
* if fprint is not NULL, it should be an array of at least 20 bytes.
*
* Rules used:
* - If the username starts with 8,9,16 or 17 hex-digits (the first one * - If the username starts with 8,9,16 or 17 hex-digits (the first one
* must be in the range 0..9), this is considered a keyid; depending * must be in the range 0..9), this is considered a keyid; depending
* on the length a short or complete one. * on the length a short or complete one.
@ -301,19 +338,14 @@ hextobyte( const byte *s )
* email address * email address
* - If the userid start with an '=' an exact compare is done. * - If the userid start with an '=' an exact compare is done.
* - If the userid starts with a '*' a case insensitive substring search is * - If the userid starts with a '*' a case insensitive substring search is
* done (This is also the default). * done (This is the default).
*/ */
int
static int classify_user_id( const char *name, u32 *keyid, byte *fprint,
key_byname( int secret, const char **retstr, size_t *retlen )
PKT_public_key *pk, PKT_secret_key *sk, const char *name )
{ {
int internal = 0;
int rc = 0;
const char *s; const char *s;
u32 keyid[2] = {0}; /* init to avoid compiler warning */
byte fprint[20];
int mode = 0; int mode = 0;
/* check what kind of name it is */ /* check what kind of name it is */
@ -328,11 +360,14 @@ key_byname( int secret,
for(i=0; isxdigit(s[i]); i++ ) for(i=0; isxdigit(s[i]); i++ )
; ;
if( s[i] && !isspace(s[i]) ) /* not terminated by EOS or blank*/ if( s[i] && !isspace(s[i]) ) /* not terminated by EOS or blank*/
rc = G10ERR_INV_USER_ID; return 0;
else if( i == 8 || (i == 9 && *s == '0') ) { /* short keyid */ else if( i == 8 || (i == 9 && *s == '0') ) { /* short keyid */
if( i==9 ) if( i==9 )
s++; s++;
keyid[1] = strtoul( s, NULL, 16 ); if( keyid ) {
keyid[0] = 0;
keyid[1] = strtoul( s, NULL, 16 );
}
mode = 10; mode = 10;
} }
else if( i == 16 || (i == 17 && *s == '0') ) { /* complete keyid */ else if( i == 16 || (i == 17 && *s == '0') ) { /* complete keyid */
@ -347,29 +382,27 @@ key_byname( int secret,
if( i==33 ) if( i==33 )
s++; s++;
memset(fprint+16, 4, 0); memset(fprint+16, 4, 0);
for(j=0; !rc && j < 16; j++, s+=2 ) { for(j=0; j < 16; j++, s+=2 ) {
int c = hextobyte( s ); int c = hextobyte( s );
if( c == -1 ) if( c == -1 )
rc = G10ERR_INV_USER_ID; return 0;
else fprint[j] = c;
fprint[j] = c;
} }
mode = 16; mode = 16;
} }
else if( i == 40 || ( i == 41 && *s == '0' ) ) { /* sha1/rmd160 fprint*/ else if( i == 40 || ( i == 41 && *s == '0' ) ) { /* sha1/rmd160 fprint*/
if( i==33 ) if( i==33 )
s++; s++;
for(j=0; !rc && j < 20; j++, s+=2 ) { for(j=0; j < 20; j++, s+=2 ) {
int c = hextobyte( s ); int c = hextobyte( s );
if( c == -1 ) if( c == -1 )
rc = G10ERR_INV_USER_ID; return 0;
else fprint[j] = c;
fprint[j] = c;
} }
mode = 20; mode = 20;
} }
else else
rc = G10ERR_INV_USER_ID; return 0;
} }
else if( *s == '=' ) { /* exact search */ else if( *s == '=' ) { /* exact search */
mode = 1; mode = 1;
@ -391,15 +424,47 @@ key_byname( int secret,
s++; s++;
} }
else if( *s == '#' ) { /* use local id */ else if( *s == '#' ) { /* use local id */
rc = G10ERR_INV_USER_ID; /* not yet implemented */ return 0;
} }
else if( !*s ) /* empty string */ else if( !*s ) /* empty string */
rc = G10ERR_INV_USER_ID; return 0;
else else
mode = 2; mode = 2;
if( rc ) if( retstr )
*retstr = s;
if( retlen )
*retlen = strlen(s);
return mode;
}
/****************
* Try to get the pubkey by the userid. This function looks for the
* first pubkey certificate which has the given name in a user_id.
* if pk has the pubkey algo set, the function will only return
* a pubkey with that algo.
*/
static int
key_byname( int secret, GETKEY_CTX *retctx,
PKT_public_key *pk, PKT_secret_key *sk,
const char *name, KBNODE *ret_kb )
{
int internal = 0;
int rc = 0;
const char *s;
u32 keyid[2] = {0}; /* init to avoid compiler warning */
byte fprint[20];
int mode;
mode = classify_user_id( name, keyid, fprint, &s, NULL );
if( !mode ) {
rc = G10ERR_INV_USER_ID;
goto leave; goto leave;
}
if( secret ) { if( secret ) {
if( !sk ) { if( !sk ) {
@ -414,8 +479,8 @@ key_byname( int secret,
pk = m_alloc_clear( sizeof *pk ); pk = m_alloc_clear( sizeof *pk );
internal++; internal++;
} }
rc = mode < 16? lookup( pk, mode, keyid, s, NULL, 1 ) rc = mode < 16? lookup( retctx, pk, mode, keyid, s, ret_kb, 1 )
: lookup( pk, mode, keyid, fprint, NULL, 1 ); : lookup( retctx, pk, mode, keyid, fprint, ret_kb, 1 );
} }
@ -428,11 +493,46 @@ key_byname( int secret,
} }
int int
get_pubkey_byname( PKT_public_key *pk, const char *name ) get_pubkey_byname( GETKEY_CTX *retctx, PKT_public_key *pk,
const char *name, KBNODE *ret_keyblock )
{ {
return key_byname( 0, pk, NULL, name ); int rc;
if( !pk ) {
/* fixme: key_byname should not need a pk in this case */
pk = m_alloc_clear( sizeof *pk );
rc = key_byname( 0, retctx, pk, NULL, name, ret_keyblock );
free_public_key( pk );
}
else
rc = key_byname( 0, retctx, pk, NULL, name, ret_keyblock );
return rc;
} }
int
get_pubkey_next( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock )
{
int rc;
if( !pk ) {
/* fixme: lookup_read should not need a pk in this case */
pk = m_alloc_clear( sizeof *pk );
rc = lookup_read( ctx, pk, ret_keyblock );
free_public_key( pk );
}
else
rc = lookup_read( ctx, pk, ret_keyblock );
return rc;
}
void
get_pubkey_end( GETKEY_CTX ctx )
{
if( ctx ) {
lookup_close( ctx );
m_free( ctx );
}
}
/**************** /****************
* Search for a key with the given fingerprint. * Search for a key with the given fingerprint.
@ -443,7 +543,7 @@ get_pubkey_byfprint( PKT_public_key *pk, const byte *fprint, size_t fprint_len)
int rc; int rc;
if( fprint_len == 20 || fprint_len == 16 ) if( fprint_len == 20 || fprint_len == 16 )
rc = lookup( pk, fprint_len, NULL, fprint, NULL, 0 ); rc = lookup( NULL, pk, fprint_len, NULL, fprint, NULL, 0 );
else else
rc = G10ERR_GENERAL; /* Oops */ rc = G10ERR_GENERAL; /* Oops */
return rc; return rc;
@ -461,7 +561,7 @@ get_keyblock_byfprint( KBNODE *ret_keyblock, const byte *fprint,
PKT_public_key *pk = m_alloc_clear( sizeof *pk ); PKT_public_key *pk = m_alloc_clear( sizeof *pk );
if( fprint_len == 20 || fprint_len == 16 ) if( fprint_len == 20 || fprint_len == 16 )
rc = lookup( pk, fprint_len, NULL, fprint, ret_keyblock, 0 ); rc = lookup( NULL, pk, fprint_len, NULL, fprint, ret_keyblock, 0 );
else else
rc = G10ERR_GENERAL; /* Oops */ rc = G10ERR_GENERAL; /* Oops */
@ -517,11 +617,11 @@ get_seckey_byname( PKT_secret_key *sk, const char *name, int unprotect )
int rc; int rc;
if( !name && opt.def_secret_key && *opt.def_secret_key ) if( !name && opt.def_secret_key && *opt.def_secret_key )
rc = key_byname( 1, NULL, sk, opt.def_secret_key ); rc = key_byname( 1, NULL, NULL, sk, opt.def_secret_key, NULL );
else if( !name ) /* use the first one as default key */ else if( !name ) /* use the first one as default key */
rc = lookup_sk( sk, 15, NULL, NULL, 1 ); rc = lookup_sk( sk, 15, NULL, NULL, 1 );
else else
rc = key_byname( 1, NULL, sk, name ); rc = key_byname( 1, NULL, NULL, sk, name, NULL );
if( !rc && unprotect ) if( !rc && unprotect )
rc = check_secret_key( sk, 0 ); rc = check_secret_key( sk, 0 );
@ -860,8 +960,6 @@ finish_lookup( KBNODE keyblock, PKT_public_key *pk, KBNODE k, byte *namehash,
} }
} }
/**************** /****************
* Lookup a key by scanning all keyresources * Lookup a key by scanning all keyresources
* mode 1 = lookup by NAME (exact) * mode 1 = lookup by NAME (exact)
@ -880,93 +978,142 @@ finish_lookup( KBNODE keyblock, PKT_public_key *pk, KBNODE k, byte *namehash,
* and the caller must release it. * and the caller must release it.
*/ */
static int static int
lookup( PKT_public_key *pk, int mode, u32 *keyid, lookup( GETKEY_CTX *retctx, PKT_public_key *pk, int mode, u32 *keyid,
const char *name, KBNODE *ret_keyblock, int primary ) const char *name, KBNODE *ret_keyblock, int primary )
{
struct getkey_ctx_s help_ctx;
GETKEY_CTX ctx;
int rc;
if( !retctx )
ctx = &help_ctx;
else {
ctx = m_alloc( sizeof *ctx );
*retctx = ctx;
}
memset( ctx, 0, sizeof *ctx );
ctx->mode = mode;
if( keyid ) {
ctx->keyid[0] = keyid[0];
ctx->keyid[1] = keyid[1];
}
if( retctx ) {
ctx->namebuf = name? m_strdup(name) : NULL;
ctx->name = ctx->namebuf;
}
else
ctx->name = name;
ctx->primary = primary;
rc = lookup_read( ctx, pk, ret_keyblock );
if( !retctx )
lookup_close( ctx );
return rc;
}
static void
lookup_close( GETKEY_CTX ctx )
{
enum_keyblocks( 2, &ctx->kbpos, NULL ); /* close */
m_free( ctx->namebuf );
}
static int
lookup_read( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock )
{ {
int rc; int rc;
KBNODE keyblock = NULL;
KBNODE k; KBNODE k;
KBPOS kbpos;
int oldmode = set_packet_list_mode(0); int oldmode = set_packet_list_mode(0);
byte namehash[20]; byte namehash[20];
int use_namehash=0; int use_namehash=0;
/* try the quick functions */ /* try the quick functions */
k = NULL; if( !ctx->count ) {
switch( mode ) { k = NULL;
case 10: switch( ctx->mode ) {
case 11: case 10:
rc = locate_keyblock_by_keyid( &kbpos, keyid, mode==10, 0 ); case 11:
if( !rc ) rc = locate_keyblock_by_keyid( &ctx->kbpos, ctx->keyid,
rc = read_keyblock( &kbpos, &keyblock ); ctx->mode==10, 0 );
if( !rc ) if( !rc )
k = find_by_keyid( keyblock, pk, keyid, mode ); rc = read_keyblock( &ctx->kbpos, &ctx->keyblock );
break; if( !rc )
k = find_by_keyid( ctx->keyblock, pk, ctx->keyid, ctx->mode );
break;
case 16: case 16:
case 20: case 20:
rc = locate_keyblock_by_fpr( &kbpos, name, mode, 0 ); rc = locate_keyblock_by_fpr( &ctx->kbpos, ctx->name, ctx->mode, 0 );
if( !rc ) if( !rc )
rc = read_keyblock( &kbpos, &keyblock ); rc = read_keyblock( &ctx->kbpos, &ctx->keyblock );
if( !rc ) if( !rc )
k = find_by_fpr( keyblock, pk, name, mode ); k = find_by_fpr( ctx->keyblock, pk, ctx->name, ctx->mode );
break; break;
default: rc = G10ERR_UNSUPPORTED; default: rc = G10ERR_UNSUPPORTED;
} }
if( !rc ) { if( !rc ) {
if( !k ) { if( !k ) {
log_error("lookup: key has been located but was not found\n"); log_error("lookup: key has been located but was not found\n");
rc = G10ERR_INV_KEYRING; rc = G10ERR_INV_KEYRING;
}
else
finish_lookup( ctx->keyblock, pk, k, namehash, 0, ctx->primary );
} }
else
finish_lookup( keyblock, pk, k, namehash, 0, primary );
} }
else
rc = G10ERR_UNSUPPORTED;
/* if this was not possible, loop over all keyblocks /* if this was not possible, loop over all keyblocks
* fixme: If one of the resources in the quick functions above * fixme: If one of the resources in the quick functions above
* works, but the key was not found, we will not find it * works, but the key was not found, we will not find it
* in the other resources */ * in the other resources */
if( rc == G10ERR_UNSUPPORTED ) { if( rc == G10ERR_UNSUPPORTED ) {
rc = enum_keyblocks( 0, &kbpos, &keyblock ); if( !ctx->count )
rc = enum_keyblocks( 0, &ctx->kbpos, &ctx->keyblock );
else
rc = 0;
if( !rc ) { if( !rc ) {
while( !(rc = enum_keyblocks( 1, &kbpos, &keyblock )) ) { while( !(rc = enum_keyblocks( 1, &ctx->kbpos, &ctx->keyblock )) ) {
if( mode < 10 ) /* fixme: we don´t enum the complete keyblock, but
k = find_by_name( keyblock, pk, name, mode, * use the first match and that continue with the next keyblock
namehash, &use_namehash); */
else if( mode == 10 || mode == 11 ) if( ctx->mode < 10 )
k = find_by_keyid( keyblock, pk, keyid, mode ); k = find_by_name( ctx->keyblock, pk, ctx->name, ctx->mode,
else if( mode == 15 ) namehash, &use_namehash);
k = find_first( keyblock, pk ); else if( ctx->mode == 10 ||ctx-> mode == 11 )
else if( mode == 16 || mode == 20 ) k = find_by_keyid( ctx->keyblock, pk, ctx->keyid,
k = find_by_fpr( keyblock, pk, name, mode ); ctx->mode );
else if( ctx->mode == 15 )
k = find_first( ctx->keyblock, pk );
else if( ctx->mode == 16 || ctx->mode == 20 )
k = find_by_fpr( ctx->keyblock, pk, ctx->name, ctx->mode );
else else
BUG(); BUG();
if( k ) { if( k ) {
finish_lookup( keyblock, pk, k, namehash, finish_lookup( ctx->keyblock, pk, k, namehash,
use_namehash, primary ); use_namehash, ctx->primary );
break; /* found */ break; /* found */
} }
release_kbnode( keyblock ); release_kbnode( ctx->keyblock );
keyblock = NULL; ctx->keyblock = NULL;
} }
} }
enum_keyblocks( 2, &kbpos, &keyblock ); /* close */
if( rc && rc != -1 ) if( rc && rc != -1 )
log_error("enum_keyblocks failed: %s\n", g10_errstr(rc)); log_error("enum_keyblocks failed: %s\n", g10_errstr(rc));
} }
if( !rc ) { if( !rc ) {
if( ret_keyblock ) { if( ret_keyblock ) {
*ret_keyblock = keyblock; *ret_keyblock = ctx->keyblock;
keyblock = NULL; ctx->keyblock = NULL;
} }
} }
else if( rc == -1 ) else if( rc == -1 )
rc = G10ERR_NO_PUBKEY; rc = G10ERR_NO_PUBKEY;
release_kbnode( ctx->keyblock );
release_kbnode( keyblock ); ctx->keyblock = NULL;
set_packet_list_mode(oldmode); set_packet_list_mode(oldmode);
if( opt.debug & DBG_MEMSTAT_VALUE ) { if( opt.debug & DBG_MEMSTAT_VALUE ) {
static int initialized; static int initialized;
@ -976,19 +1123,22 @@ lookup( PKT_public_key *pk, int mode, u32 *keyid,
atexit( print_stats ); atexit( print_stats );
} }
assert( mode < DIM(lkup_stats) ); assert( ctx->mode < DIM(lkup_stats) );
lkup_stats[mode].any = 1; lkup_stats[ctx->mode].any = 1;
if( !rc ) if( !rc )
lkup_stats[mode].okay_count++; lkup_stats[ctx->mode].okay_count++;
else if ( rc == G10ERR_NO_PUBKEY ) else if ( rc == G10ERR_NO_PUBKEY )
lkup_stats[mode].nokey_count++; lkup_stats[ctx->mode].nokey_count++;
else else
lkup_stats[mode].error_count++; lkup_stats[ctx->mode].error_count++;
} }
ctx->last_rc = rc;
ctx->count++;
return rc; return rc;
} }
/**************** /****************
* Ditto for secret keys * Ditto for secret keys
*/ */

View File

@ -31,6 +31,10 @@
#define MAX_FINGERPRINT_LEN 20 #define MAX_FINGERPRINT_LEN 20
typedef struct getkey_ctx_s *GETKEY_CTX;
#ifndef DEFINES_GETKEY_CTX
struct getkey_ctx_s { char hidden[1]; };
#endif
/**************** /****************
* A Keyblock is all packets which form an entire certificate; * A Keyblock is all packets which form an entire certificate;
@ -124,8 +128,13 @@ void set_next_passphrase( const char *s );
char *get_last_passphrase(void); char *get_last_passphrase(void);
/*-- getkey.c --*/ /*-- getkey.c --*/
int classify_user_id( const char *name, u32 *keyid, byte *fprint,
const char **retstr, size_t *retlen );
int get_pubkey( PKT_public_key *pk, u32 *keyid ); int get_pubkey( PKT_public_key *pk, u32 *keyid );
int get_pubkey_byname( PKT_public_key *pk, const char *name ); int get_pubkey_byname( GETKEY_CTX *rx, PKT_public_key *pk,
const char *name, KBNODE *ret_keyblock );
int get_pubkey_next( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock );
void get_pubkey_end( GETKEY_CTX ctx );
int get_seckey( PKT_secret_key *sk, u32 *keyid ); int get_seckey( PKT_secret_key *sk, u32 *keyid );
int get_pubkey_byfprint( PKT_public_key *pk, const byte *fprint, int get_pubkey_byfprint( PKT_public_key *pk, const byte *fprint,
size_t fprint_len ); size_t fprint_len );

View File

@ -215,7 +215,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified )
SK_LIST sk_rover = NULL; SK_LIST sk_rover = NULL;
PKT_secret_key *sk = NULL; PKT_secret_key *sk = NULL;
KBNODE node, uidnode; KBNODE node, uidnode;
PKT_public_key *primary_pk; PKT_public_key *primary_pk=NULL;
int select_all = !count_selected_uids(keyblock); int select_all = !count_selected_uids(keyblock);
int upd_trust = 0; int upd_trust = 0;

View File

@ -115,23 +115,41 @@ list_one( const char *name, int secret )
{ {
int rc = 0; int rc = 0;
KBNODE keyblock = NULL; KBNODE keyblock = NULL;
KBPOS kbpos;
rc = secret? find_secret_keyblock_byname( &kbpos, name ) if( secret ) {
: find_keyblock_byname( &kbpos, name ); KBPOS kbpos;
if( rc ) {
log_error("%s: user not found\n", name );
return;
}
rc = read_keyblock( &kbpos, &keyblock ); rc = secret? find_secret_keyblock_byname( &kbpos, name )
if( rc ) { : find_keyblock_byname( &kbpos, name );
log_error("%s: keyblock read problem: %s\n", name, g10_errstr(rc) ); if( rc ) {
return; log_error("%s: user not found\n", name );
return;
}
rc = read_keyblock( &kbpos, &keyblock );
if( rc ) {
log_error("%s: keyblock read problem: %s\n", name, g10_errstr(rc) );
return;
}
merge_keys_and_selfsig( keyblock );
list_keyblock( keyblock, secret );
release_kbnode( keyblock );
}
else {
GETKEY_CTX ctx;
rc = get_pubkey_byname( &ctx, NULL, name, &keyblock );
if( rc ) {
log_error("%s: %s\n", name, g10_errstr(rc) );
get_pubkey_end( ctx );
return;
}
do {
list_keyblock( keyblock, 0 );
release_kbnode( keyblock );
} while( !get_pubkey_next( ctx, NULL, &keyblock ) );
get_pubkey_end( ctx );
} }
merge_keys_and_selfsig( keyblock );
list_keyblock( keyblock, secret );
release_kbnode( keyblock );
} }

View File

@ -130,5 +130,7 @@ int hash_datafiles( MD_HANDLE md, STRLIST files, const char *sigfilename,
/*-- signal.c --*/ /*-- signal.c --*/
void init_signals(void); void init_signals(void);
void pause_on_sigusr( int which ); void pause_on_sigusr( int which );
void block_all_signals(void);
void unblock_all_signals(void);
#endif /*G10_MAIN_H*/ #endif /*G10_MAIN_H*/

View File

@ -840,7 +840,7 @@ check_sig_and_print( CTX c, KBNODE node )
tstr = asctimestamp(sig->timestamp); tstr = asctimestamp(sig->timestamp);
astr = pubkey_algo_to_string( sig->pubkey_algo ); astr = pubkey_algo_to_string( sig->pubkey_algo );
log_info(_("Signature made %.*s using %s key ID %08lX\n"), log_info(_("Signature made %.*s using %s key ID %08lX\n"),
(int)strlen(tstr)-1, tstr, astr? astr: "?", (ulong)sig->keyid[1] ); (int)strlen(tstr), tstr, astr? astr: "?", (ulong)sig->keyid[1] );
rc = do_check_sig(c, node, NULL ); rc = do_check_sig(c, node, NULL );
if( !rc || rc == G10ERR_BAD_SIGN ) { if( !rc || rc == G10ERR_BAD_SIGN ) {

View File

@ -432,7 +432,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned usage )
free_public_key( pk ); free_public_key( pk );
pk = m_alloc_clear( sizeof *pk ); pk = m_alloc_clear( sizeof *pk );
pk->pubkey_usage = usage; pk->pubkey_usage = usage;
rc = get_pubkey_byname( pk, answer ); rc = get_pubkey_byname( NULL, pk, answer, NULL );
if( rc ) if( rc )
tty_printf(_("No such user ID.\n")); tty_printf(_("No such user ID.\n"));
else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, usage)) ) { else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, usage)) ) {
@ -466,7 +466,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned usage )
pk = m_alloc_clear( sizeof *pk ); pk = m_alloc_clear( sizeof *pk );
pk->pubkey_usage = usage; pk->pubkey_usage = usage;
if( (rc = get_pubkey_byname( pk, remusr->d )) ) { if( (rc = get_pubkey_byname( NULL, pk, remusr->d, NULL )) ) {
free_public_key( pk ); pk = NULL; free_public_key( pk ); pk = NULL;
log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) ); log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) );
} }

View File

@ -431,7 +431,7 @@ find_keyblock_byname( KBPOS *kbpos, const char *username )
PKT_public_key *pk = m_alloc_clear( sizeof *pk ); PKT_public_key *pk = m_alloc_clear( sizeof *pk );
int rc; int rc;
rc = get_pubkey_byname( pk, username ); rc = get_pubkey_byname( NULL, pk, username, NULL );
if( rc ) { if( rc ) {
free_public_key(pk); free_public_key(pk);
return rc; return rc;

View File

@ -56,7 +56,7 @@ struct cache_ctrl_struct {
char data[TRUST_RECORD_LEN]; char data[TRUST_RECORD_LEN];
}; };
#define MAX_CACHE_ENTRIES_SOFT 200 /* may be increased due while in a */ #define MAX_CACHE_ENTRIES_SOFT 200 /* may be increased while in a */
#define MAX_CACHE_ENTRIES_HARD 1000 /* transaction to this one */ #define MAX_CACHE_ENTRIES_HARD 1000 /* transaction to this one */
static CACHE_CTRL cache_list; static CACHE_CTRL cache_list;
static int cache_entries; static int cache_entries;

View File

@ -963,7 +963,7 @@ list_trustdb( const char *username )
PKT_public_key *pk = m_alloc_clear( sizeof *pk ); PKT_public_key *pk = m_alloc_clear( sizeof *pk );
int rc; int rc;
if( (rc = get_pubkey_byname( pk, username )) ) if( (rc = get_pubkey_byname( NULL, pk, username, NULL )) )
log_error("user '%s' not found: %s\n", username, g10_errstr(rc) ); log_error("user '%s' not found: %s\n", username, g10_errstr(rc) );
else if( (rc=tdbio_search_dir_bypk( pk, &rec )) && rc != -1 ) else if( (rc=tdbio_search_dir_bypk( pk, &rec )) && rc != -1 )
log_error("problem finding '%s' in trustdb: %s\n", log_error("problem finding '%s' in trustdb: %s\n",
@ -1165,7 +1165,7 @@ list_trust_path( int max_depth, const char *username )
max_depth = -max_depth; max_depth = -max_depth;
} }
if( (rc = get_pubkey_byname( pk, username )) ) if( (rc = get_pubkey_byname(NULL, pk, username, NULL )) )
log_error("user '%s' not found: %s\n", username, g10_errstr(rc) ); log_error("user '%s' not found: %s\n", username, g10_errstr(rc) );
else if( (rc=tdbio_search_dir_bypk( pk, &rec )) && rc != -1 ) else if( (rc=tdbio_search_dir_bypk( pk, &rec )) && rc != -1 )
log_error("problem finding '%s' in trustdb: %s\n", log_error("problem finding '%s' in trustdb: %s\n",
@ -1860,7 +1860,7 @@ create_shadow_dir( PKT_signature *sig, ulong lid )
{ {
TRUSTREC sdir, hlst, tmphlst; TRUSTREC sdir, hlst, tmphlst;
ulong recno, newlid; ulong recno, newlid;
int tmpidx; int tmpidx=0; /* avoids gcc warnign - this is controlled by tmphlst */
int rc; int rc;
/* first see whether we already have such a record */ /* first see whether we already have such a record */
@ -2366,7 +2366,7 @@ upd_cert_record( KBNODE keyblock, KBNODE signode, u32 *keyid,
TRUSTREC rec; TRUSTREC rec;
ulong recno; ulong recno;
TRUSTREC delrec; TRUSTREC delrec;
int delrecidx; int delrecidx=0;
int newflag = 0; int newflag = 0;
ulong newlid = 0; ulong newlid = 0;
PKT_public_key *pk = m_alloc_clear( sizeof *pk ); PKT_public_key *pk = m_alloc_clear( sizeof *pk );