diff options
author | Werner Koch <wk@gnupg.org> | 2002-06-19 10:29:41 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2002-06-19 10:29:41 +0200 |
commit | 031a856a7e8ce850662ce6d16007549a1a5ee34f (patch) | |
tree | 3185f03d0cc830c8624238a75e9be4e073d3d2cb /kbx/keybox-search.c | |
parent | * certreqgen.c (read_parameters): Improved error handling. (diff) | |
download | gnupg2-031a856a7e8ce850662ce6d16007549a1a5ee34f.tar.xz gnupg2-031a856a7e8ce850662ce6d16007549a1a5ee34f.zip |
* keybox-init.c (keybox_set_ephemeral): New.
* keybox-blob.c (create_blob_header): Store epheermal flag.
(_keybox_create_x509_blob): Pass epheermal flag on.
* keybox-update.c (keybox_insert_cert): Ditto.
* keybox-search.c (blob_get_blob_flags): New.
(keybox_search): Ignore ephemeral blobs when not in ephemeral mode.
* keybox-dump.c (_keybox_dump_blob): Print blob flags as strings.
Diffstat (limited to 'kbx/keybox-search.c')
-rw-r--r-- | kbx/keybox-search.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c index c7434cd93..e57754344 100644 --- a/kbx/keybox-search.c +++ b/kbx/keybox-search.c @@ -1,5 +1,5 @@ /* keybox-search.c - Search operations - * Copyright (C) 2001 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -73,6 +73,19 @@ blob_get_type (KEYBOXBLOB blob) return buffer[4]; } +static unsigned int +blob_get_blob_flags (KEYBOXBLOB blob) +{ + const unsigned char *buffer; + size_t length; + + buffer = _keybox_get_blob_image (blob, &length); + if (length < 8) + return 0; /* oops */ + + return get16 (buffer + 6); +} + static int blob_cmp_sn (KEYBOXBLOB blob, const unsigned char *sn, int snlen) @@ -457,6 +470,9 @@ keybox_search_reset (KEYBOX_HANDLE hd) return 0; } + +/* Note: When in ephemeral mode the search function does visit all + blobs but in standard mode, blobs flagged as ephemeral are ignored. */ int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc) { @@ -578,11 +594,17 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc) for (;;) { + unsigned int blobflags; + _keybox_release_blob (blob); blob = NULL; rc = _keybox_read_blob (&blob, hd->fp); if (rc) break; + blobflags = blob_get_blob_flags (blob); + if (!hd->ephemeral && (blobflags & 2)) + continue; /* not in ephemeral mode but blob is flagged ephemeral */ + for (n=0; n < ndesc; n++) { switch (desc[n].mode) |