mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-31 11:41:32 +01:00
* getkey.c (key_byname): If namelist is NULL, return the first key in the
keyring.
This commit is contained in:
parent
732f049817
commit
7d74743c0e
@ -1,3 +1,8 @@
|
||||
2004-04-25 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* getkey.c (key_byname): If namelist is NULL, return the first key
|
||||
in the keyring.
|
||||
|
||||
2004-04-22 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* keygen.c (make_backsig): If DO_BACKSIGS is not defined, do not
|
||||
|
70
g10/getkey.c
70
g10/getkey.c
@ -779,11 +779,12 @@ skip_unusable(void *dummy,u32 *keyid,PKT_user_id *uid)
|
||||
|
||||
/****************
|
||||
* 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/sk has the pubkey algo set, the function will only return
|
||||
* a pubkey with that algo.
|
||||
* The caller should provide storage for either the pk or the sk.
|
||||
* If ret_kb is not NULL the function will return the keyblock there.
|
||||
* first pubkey certificate which has the given name in a user_id. if
|
||||
* pk/sk has the pubkey algo set, the function will only return a
|
||||
* pubkey with that algo. If namelist is NULL, the first key is
|
||||
* returned. The caller should provide storage for either the pk or
|
||||
* the sk. If ret_kb is not NULL the function will return the
|
||||
* keyblock there.
|
||||
*/
|
||||
|
||||
static int
|
||||
@ -806,29 +807,43 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist,
|
||||
if (ret_kdbhd)
|
||||
*ret_kdbhd = NULL;
|
||||
|
||||
/* build the search context */
|
||||
for(n=0, r=namelist; r; r = r->next )
|
||||
n++;
|
||||
ctx = m_alloc_clear (sizeof *ctx + (n-1)*sizeof ctx->items );
|
||||
ctx->nitems = n;
|
||||
if(!namelist)
|
||||
{
|
||||
ctx = m_alloc_clear (sizeof *ctx);
|
||||
ctx->nitems = 1;
|
||||
ctx->items[0].mode=KEYDB_SEARCH_MODE_FIRST;
|
||||
if(!include_unusable)
|
||||
ctx->items[0].skipfnc=skip_unusable;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* build the search context */
|
||||
for(n=0, r=namelist; r; r = r->next )
|
||||
n++;
|
||||
|
||||
for(n=0, r=namelist; r; r = r->next, n++ ) {
|
||||
classify_user_id (r->d, &ctx->items[n]);
|
||||
ctx = m_alloc_clear (sizeof *ctx + (n-1)*sizeof ctx->items );
|
||||
ctx->nitems = n;
|
||||
|
||||
for(n=0, r=namelist; r; r = r->next, n++ )
|
||||
{
|
||||
classify_user_id (r->d, &ctx->items[n]);
|
||||
|
||||
if (ctx->items[n].exact)
|
||||
ctx->exact = 1;
|
||||
if (!ctx->items[n].mode) {
|
||||
m_free (ctx);
|
||||
return G10ERR_INV_USER_ID;
|
||||
}
|
||||
if(!include_unusable
|
||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_SHORT_KID
|
||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_LONG_KID
|
||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR16
|
||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR20
|
||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR)
|
||||
ctx->items[n].skipfnc=skip_unusable;
|
||||
}
|
||||
if (ctx->items[n].exact)
|
||||
ctx->exact = 1;
|
||||
if (!ctx->items[n].mode)
|
||||
{
|
||||
m_free (ctx);
|
||||
return G10ERR_INV_USER_ID;
|
||||
}
|
||||
if(!include_unusable
|
||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_SHORT_KID
|
||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_LONG_KID
|
||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR16
|
||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR20
|
||||
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR)
|
||||
ctx->items[n].skipfnc=skip_unusable;
|
||||
}
|
||||
}
|
||||
|
||||
ctx->kr_handle = keydb_new (secmode);
|
||||
if ( !ret_kb )
|
||||
@ -909,7 +924,6 @@ get_pubkey_next( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock )
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
get_pubkey_end( GETKEY_CTX ctx )
|
||||
{
|
||||
@ -922,8 +936,6 @@ get_pubkey_end( GETKEY_CTX ctx )
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/****************
|
||||
* Search for a key with the given fingerprint.
|
||||
* FIXME:
|
||||
|
Loading…
x
Reference in New Issue
Block a user