mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
ready to release 0.4.3
This commit is contained in:
parent
aad7f1a0fc
commit
35c1054507
@ -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)
|
||||
|
||||
* Makefile.am (g10defs.h): New macro GNUPG_DATADIR.
|
||||
|
5
NEWS
5
NEWS
@ -1,3 +1,5 @@
|
||||
Noteworthy changes in version 0.4.3
|
||||
-----------------------------------
|
||||
|
||||
* Fixed the gettext configure bug.
|
||||
|
||||
@ -18,6 +20,9 @@
|
||||
* commandline option processing now works as expected for GNU programs
|
||||
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
|
||||
-----------------------------------
|
||||
|
11
README
11
README
@ -1,3 +1,5 @@
|
||||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
|
||||
GnuPG - The GNU Privacy Guard
|
||||
-------------------------------
|
||||
Version 0.4
|
||||
@ -331,3 +333,12 @@
|
||||
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-----
|
||||
|
5
TODO
5
TODO
@ -1,14 +1,9 @@
|
||||
|
||||
* 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
|
||||
|
||||
* FreeBSD:
|
||||
#define USE_DYNAMIC_LINKING
|
||||
#define HAVE_DL_DLOPEN
|
||||
|
||||
and the ld option -export-dynamic.
|
||||
|
||||
*
|
||||
|
@ -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)
|
||||
|
||||
* pubkey.c: Hack to allow us to give some info about RSA keys back.
|
||||
|
@ -157,7 +157,6 @@ read_random_source( byte *buffer, size_t length, int level )
|
||||
continue;
|
||||
}
|
||||
|
||||
assert( length < 500 );
|
||||
do {
|
||||
n = read(fd, buffer, length );
|
||||
if( n >= 0 && n > length ) {
|
||||
|
@ -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)
|
||||
|
||||
* 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
|
||||
* 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.
|
||||
|
||||
* trustdb.c (update_trust_record): Reorganized the whole thing.
|
||||
|
296
g10/getkey.c
296
g10/getkey.c
@ -18,6 +18,8 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#define DEFINES_GETKEY_CTX 1
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -33,10 +35,30 @@
|
||||
#include "main.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_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 {
|
||||
int any;
|
||||
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,
|
||||
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,
|
||||
int mode, u32 *keyid, const char *name, int primary );
|
||||
|
||||
@ -223,7 +248,7 @@ get_pubkey( PKT_public_key *pk, u32 *keyid )
|
||||
|
||||
|
||||
/* do a lookup */
|
||||
rc = lookup( pk, 11, keyid, NULL, NULL, 0 );
|
||||
rc = lookup( NULL, pk, 11, keyid, NULL, NULL, 0 );
|
||||
if( !rc )
|
||||
goto leave;
|
||||
|
||||
@ -251,7 +276,7 @@ get_pubkey( PKT_public_key *pk, u32 *keyid )
|
||||
if( !rc )
|
||||
cache_public_key( pk );
|
||||
if( internal )
|
||||
m_free(pk);
|
||||
free_public_key(pk);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -282,12 +307,24 @@ hextobyte( const byte *s )
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************
|
||||
* 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.
|
||||
* Return the type of the user id:
|
||||
*
|
||||
* 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
|
||||
* must be in the range 0..9), this is considered a keyid; depending
|
||||
* on the length a short or complete one.
|
||||
@ -301,19 +338,14 @@ hextobyte( const byte *s )
|
||||
* email address
|
||||
* - If the userid start with an '=' an exact compare is done.
|
||||
* - If the userid starts with a '*' a case insensitive substring search is
|
||||
* done (This is also the default).
|
||||
* done (This is the default).
|
||||
*/
|
||||
|
||||
|
||||
static int
|
||||
key_byname( int secret,
|
||||
PKT_public_key *pk, PKT_secret_key *sk, const char *name )
|
||||
int
|
||||
classify_user_id( const char *name, u32 *keyid, byte *fprint,
|
||||
const char **retstr, size_t *retlen )
|
||||
{
|
||||
int internal = 0;
|
||||
int rc = 0;
|
||||
const char *s;
|
||||
u32 keyid[2] = {0}; /* init to avoid compiler warning */
|
||||
byte fprint[20];
|
||||
int mode = 0;
|
||||
|
||||
/* check what kind of name it is */
|
||||
@ -328,11 +360,14 @@ key_byname( int secret,
|
||||
for(i=0; isxdigit(s[i]); i++ )
|
||||
;
|
||||
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 */
|
||||
if( i==9 )
|
||||
s++;
|
||||
if( keyid ) {
|
||||
keyid[0] = 0;
|
||||
keyid[1] = strtoul( s, NULL, 16 );
|
||||
}
|
||||
mode = 10;
|
||||
}
|
||||
else if( i == 16 || (i == 17 && *s == '0') ) { /* complete keyid */
|
||||
@ -347,11 +382,10 @@ key_byname( int secret,
|
||||
if( i==33 )
|
||||
s++;
|
||||
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 );
|
||||
if( c == -1 )
|
||||
rc = G10ERR_INV_USER_ID;
|
||||
else
|
||||
return 0;
|
||||
fprint[j] = c;
|
||||
}
|
||||
mode = 16;
|
||||
@ -359,17 +393,16 @@ key_byname( int secret,
|
||||
else if( i == 40 || ( i == 41 && *s == '0' ) ) { /* sha1/rmd160 fprint*/
|
||||
if( i==33 )
|
||||
s++;
|
||||
for(j=0; !rc && j < 20; j++, s+=2 ) {
|
||||
for(j=0; j < 20; j++, s+=2 ) {
|
||||
int c = hextobyte( s );
|
||||
if( c == -1 )
|
||||
rc = G10ERR_INV_USER_ID;
|
||||
else
|
||||
return 0;
|
||||
fprint[j] = c;
|
||||
}
|
||||
mode = 20;
|
||||
}
|
||||
else
|
||||
rc = G10ERR_INV_USER_ID;
|
||||
return 0;
|
||||
}
|
||||
else if( *s == '=' ) { /* exact search */
|
||||
mode = 1;
|
||||
@ -391,15 +424,47 @@ key_byname( int secret,
|
||||
s++;
|
||||
}
|
||||
else if( *s == '#' ) { /* use local id */
|
||||
rc = G10ERR_INV_USER_ID; /* not yet implemented */
|
||||
return 0;
|
||||
}
|
||||
else if( !*s ) /* empty string */
|
||||
rc = G10ERR_INV_USER_ID;
|
||||
return 0;
|
||||
else
|
||||
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;
|
||||
}
|
||||
|
||||
if( secret ) {
|
||||
if( !sk ) {
|
||||
@ -414,8 +479,8 @@ key_byname( int secret,
|
||||
pk = m_alloc_clear( sizeof *pk );
|
||||
internal++;
|
||||
}
|
||||
rc = mode < 16? lookup( pk, mode, keyid, s, NULL, 1 )
|
||||
: lookup( pk, mode, keyid, fprint, NULL, 1 );
|
||||
rc = mode < 16? lookup( retctx, pk, mode, keyid, s, ret_kb, 1 )
|
||||
: lookup( retctx, pk, mode, keyid, fprint, ret_kb, 1 );
|
||||
}
|
||||
|
||||
|
||||
@ -428,11 +493,46 @@ key_byname( int secret,
|
||||
}
|
||||
|
||||
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.
|
||||
@ -443,7 +543,7 @@ get_pubkey_byfprint( PKT_public_key *pk, const byte *fprint, size_t fprint_len)
|
||||
int rc;
|
||||
|
||||
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
|
||||
rc = G10ERR_GENERAL; /* Oops */
|
||||
return rc;
|
||||
@ -461,7 +561,7 @@ get_keyblock_byfprint( KBNODE *ret_keyblock, const byte *fprint,
|
||||
PKT_public_key *pk = m_alloc_clear( sizeof *pk );
|
||||
|
||||
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
|
||||
rc = G10ERR_GENERAL; /* Oops */
|
||||
|
||||
@ -517,11 +617,11 @@ get_seckey_byname( PKT_secret_key *sk, const char *name, int unprotect )
|
||||
int rc;
|
||||
|
||||
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 */
|
||||
rc = lookup_sk( sk, 15, NULL, NULL, 1 );
|
||||
else
|
||||
rc = key_byname( 1, NULL, sk, name );
|
||||
rc = key_byname( 1, NULL, NULL, sk, name, NULL );
|
||||
if( !rc && unprotect )
|
||||
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
|
||||
* mode 1 = lookup by NAME (exact)
|
||||
@ -880,36 +978,76 @@ finish_lookup( KBNODE keyblock, PKT_public_key *pk, KBNODE k, byte *namehash,
|
||||
* and the caller must release it.
|
||||
*/
|
||||
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 )
|
||||
{
|
||||
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;
|
||||
KBNODE keyblock = NULL;
|
||||
KBNODE k;
|
||||
KBPOS kbpos;
|
||||
int oldmode = set_packet_list_mode(0);
|
||||
byte namehash[20];
|
||||
int use_namehash=0;
|
||||
|
||||
/* try the quick functions */
|
||||
if( !ctx->count ) {
|
||||
k = NULL;
|
||||
switch( mode ) {
|
||||
switch( ctx->mode ) {
|
||||
case 10:
|
||||
case 11:
|
||||
rc = locate_keyblock_by_keyid( &kbpos, keyid, mode==10, 0 );
|
||||
rc = locate_keyblock_by_keyid( &ctx->kbpos, ctx->keyid,
|
||||
ctx->mode==10, 0 );
|
||||
if( !rc )
|
||||
rc = read_keyblock( &kbpos, &keyblock );
|
||||
rc = read_keyblock( &ctx->kbpos, &ctx->keyblock );
|
||||
if( !rc )
|
||||
k = find_by_keyid( keyblock, pk, keyid, mode );
|
||||
k = find_by_keyid( ctx->keyblock, pk, ctx->keyid, ctx->mode );
|
||||
break;
|
||||
|
||||
case 16:
|
||||
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 )
|
||||
rc = read_keyblock( &kbpos, &keyblock );
|
||||
rc = read_keyblock( &ctx->kbpos, &ctx->keyblock );
|
||||
if( !rc )
|
||||
k = find_by_fpr( keyblock, pk, name, mode );
|
||||
k = find_by_fpr( ctx->keyblock, pk, ctx->name, ctx->mode );
|
||||
break;
|
||||
|
||||
default: rc = G10ERR_UNSUPPORTED;
|
||||
@ -920,53 +1058,62 @@ lookup( PKT_public_key *pk, int mode, u32 *keyid,
|
||||
rc = G10ERR_INV_KEYRING;
|
||||
}
|
||||
else
|
||||
finish_lookup( keyblock, pk, k, namehash, 0, primary );
|
||||
finish_lookup( ctx->keyblock, pk, k, namehash, 0, ctx->primary );
|
||||
}
|
||||
}
|
||||
else
|
||||
rc = G10ERR_UNSUPPORTED;
|
||||
|
||||
/* if this was not possible, loop over all keyblocks
|
||||
* fixme: If one of the resources in the quick functions above
|
||||
* works, but the key was not found, we will not find it
|
||||
* in the other resources */
|
||||
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 ) {
|
||||
while( !(rc = enum_keyblocks( 1, &kbpos, &keyblock )) ) {
|
||||
if( mode < 10 )
|
||||
k = find_by_name( keyblock, pk, name, mode,
|
||||
while( !(rc = enum_keyblocks( 1, &ctx->kbpos, &ctx->keyblock )) ) {
|
||||
/* fixme: we don´t enum the complete keyblock, but
|
||||
* use the first match and that continue with the next keyblock
|
||||
*/
|
||||
if( ctx->mode < 10 )
|
||||
k = find_by_name( ctx->keyblock, pk, ctx->name, ctx->mode,
|
||||
namehash, &use_namehash);
|
||||
else if( mode == 10 || mode == 11 )
|
||||
k = find_by_keyid( keyblock, pk, keyid, mode );
|
||||
else if( mode == 15 )
|
||||
k = find_first( keyblock, pk );
|
||||
else if( mode == 16 || mode == 20 )
|
||||
k = find_by_fpr( keyblock, pk, name, mode );
|
||||
else if( ctx->mode == 10 ||ctx-> mode == 11 )
|
||||
k = find_by_keyid( ctx->keyblock, pk, ctx->keyid,
|
||||
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
|
||||
BUG();
|
||||
if( k ) {
|
||||
finish_lookup( keyblock, pk, k, namehash,
|
||||
use_namehash, primary );
|
||||
finish_lookup( ctx->keyblock, pk, k, namehash,
|
||||
use_namehash, ctx->primary );
|
||||
break; /* found */
|
||||
}
|
||||
release_kbnode( keyblock );
|
||||
keyblock = NULL;
|
||||
release_kbnode( ctx->keyblock );
|
||||
ctx->keyblock = NULL;
|
||||
}
|
||||
}
|
||||
enum_keyblocks( 2, &kbpos, &keyblock ); /* close */
|
||||
if( rc && rc != -1 )
|
||||
log_error("enum_keyblocks failed: %s\n", g10_errstr(rc));
|
||||
}
|
||||
|
||||
if( !rc ) {
|
||||
if( ret_keyblock ) {
|
||||
*ret_keyblock = keyblock;
|
||||
keyblock = NULL;
|
||||
*ret_keyblock = ctx->keyblock;
|
||||
ctx->keyblock = NULL;
|
||||
}
|
||||
}
|
||||
else if( rc == -1 )
|
||||
rc = G10ERR_NO_PUBKEY;
|
||||
|
||||
|
||||
release_kbnode( keyblock );
|
||||
release_kbnode( ctx->keyblock );
|
||||
ctx->keyblock = NULL;
|
||||
set_packet_list_mode(oldmode);
|
||||
if( opt.debug & DBG_MEMSTAT_VALUE ) {
|
||||
static int initialized;
|
||||
@ -976,19 +1123,22 @@ lookup( PKT_public_key *pk, int mode, u32 *keyid,
|
||||
atexit( print_stats );
|
||||
}
|
||||
|
||||
assert( mode < DIM(lkup_stats) );
|
||||
lkup_stats[mode].any = 1;
|
||||
assert( ctx->mode < DIM(lkup_stats) );
|
||||
lkup_stats[ctx->mode].any = 1;
|
||||
if( !rc )
|
||||
lkup_stats[mode].okay_count++;
|
||||
lkup_stats[ctx->mode].okay_count++;
|
||||
else if ( rc == G10ERR_NO_PUBKEY )
|
||||
lkup_stats[mode].nokey_count++;
|
||||
lkup_stats[ctx->mode].nokey_count++;
|
||||
else
|
||||
lkup_stats[mode].error_count++;
|
||||
lkup_stats[ctx->mode].error_count++;
|
||||
}
|
||||
|
||||
ctx->last_rc = rc;
|
||||
ctx->count++;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Ditto for secret keys
|
||||
*/
|
||||
|
11
g10/keydb.h
11
g10/keydb.h
@ -31,6 +31,10 @@
|
||||
|
||||
#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;
|
||||
@ -124,8 +128,13 @@ void set_next_passphrase( const char *s );
|
||||
char *get_last_passphrase(void);
|
||||
|
||||
/*-- 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_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_pubkey_byfprint( PKT_public_key *pk, const byte *fprint,
|
||||
size_t fprint_len );
|
||||
|
@ -215,7 +215,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified )
|
||||
SK_LIST sk_rover = NULL;
|
||||
PKT_secret_key *sk = NULL;
|
||||
KBNODE node, uidnode;
|
||||
PKT_public_key *primary_pk;
|
||||
PKT_public_key *primary_pk=NULL;
|
||||
int select_all = !count_selected_uids(keyblock);
|
||||
int upd_trust = 0;
|
||||
|
||||
|
@ -115,6 +115,8 @@ list_one( const char *name, int secret )
|
||||
{
|
||||
int rc = 0;
|
||||
KBNODE keyblock = NULL;
|
||||
|
||||
if( secret ) {
|
||||
KBPOS kbpos;
|
||||
|
||||
rc = secret? find_secret_keyblock_byname( &kbpos, name )
|
||||
@ -133,6 +135,22 @@ list_one( const char *name, int secret )
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
|
@ -130,5 +130,7 @@ int hash_datafiles( MD_HANDLE md, STRLIST files, const char *sigfilename,
|
||||
/*-- signal.c --*/
|
||||
void init_signals(void);
|
||||
void pause_on_sigusr( int which );
|
||||
void block_all_signals(void);
|
||||
void unblock_all_signals(void);
|
||||
|
||||
#endif /*G10_MAIN_H*/
|
||||
|
@ -840,7 +840,7 @@ check_sig_and_print( CTX c, KBNODE node )
|
||||
tstr = asctimestamp(sig->timestamp);
|
||||
astr = pubkey_algo_to_string( sig->pubkey_algo );
|
||||
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 );
|
||||
if( !rc || rc == G10ERR_BAD_SIGN ) {
|
||||
|
@ -432,7 +432,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned usage )
|
||||
free_public_key( pk );
|
||||
pk = m_alloc_clear( sizeof *pk );
|
||||
pk->pubkey_usage = usage;
|
||||
rc = get_pubkey_byname( pk, answer );
|
||||
rc = get_pubkey_byname( NULL, pk, answer, NULL );
|
||||
if( rc )
|
||||
tty_printf(_("No such user ID.\n"));
|
||||
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->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;
|
||||
log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) );
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ find_keyblock_byname( KBPOS *kbpos, const char *username )
|
||||
PKT_public_key *pk = m_alloc_clear( sizeof *pk );
|
||||
int rc;
|
||||
|
||||
rc = get_pubkey_byname( pk, username );
|
||||
rc = get_pubkey_byname( NULL, pk, username, NULL );
|
||||
if( rc ) {
|
||||
free_public_key(pk);
|
||||
return rc;
|
||||
|
@ -56,7 +56,7 @@ struct cache_ctrl_struct {
|
||||
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 */
|
||||
static CACHE_CTRL cache_list;
|
||||
static int cache_entries;
|
||||
|
@ -963,7 +963,7 @@ list_trustdb( const char *username )
|
||||
PKT_public_key *pk = m_alloc_clear( sizeof *pk );
|
||||
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) );
|
||||
else if( (rc=tdbio_search_dir_bypk( pk, &rec )) && rc != -1 )
|
||||
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;
|
||||
}
|
||||
|
||||
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) );
|
||||
else if( (rc=tdbio_search_dir_bypk( pk, &rec )) && rc != -1 )
|
||||
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;
|
||||
ulong recno, newlid;
|
||||
int tmpidx;
|
||||
int tmpidx=0; /* avoids gcc warnign - this is controlled by tmphlst */
|
||||
int rc;
|
||||
|
||||
/* first see whether we already have such a record */
|
||||
@ -2366,7 +2366,7 @@ upd_cert_record( KBNODE keyblock, KBNODE signode, u32 *keyid,
|
||||
TRUSTREC rec;
|
||||
ulong recno;
|
||||
TRUSTREC delrec;
|
||||
int delrecidx;
|
||||
int delrecidx=0;
|
||||
int newflag = 0;
|
||||
ulong newlid = 0;
|
||||
PKT_public_key *pk = m_alloc_clear( sizeof *pk );
|
||||
|
Loading…
x
Reference in New Issue
Block a user