2006-12-21 Marcus Brinkmann <marcus@g10code.de>
[gnupg.git] / sm / keydb.h
blobe12afe1f6318e184138c3b26681d421aa4c3e0c6
1 /* keydb.h - Key database
2 * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 * USA.
22 #ifndef GNUPG_KEYDB_H
23 #define GNUPG_KEYDB_H
25 #include <ksba.h>
27 #include "../kbx/keybox-search-desc.h"
29 typedef struct keydb_handle *KEYDB_HANDLE;
31 /* Flag value used with KEYBOX_FLAG_VALIDITY. */
32 #define VALIDITY_REVOKED (1<<5)
35 /*-- keydb.c --*/
36 int keydb_add_resource (const char *url, int force, int secret,
37 int *auto_created);
38 KEYDB_HANDLE keydb_new (int secret);
39 void keydb_release (KEYDB_HANDLE hd);
40 int keydb_set_ephemeral (KEYDB_HANDLE hd, int yes);
41 const char *keydb_get_resource_name (KEYDB_HANDLE hd);
42 gpg_error_t keydb_lock (KEYDB_HANDLE hd);
44 #if 0 /* pgp stuff */
45 int keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb);
46 int keydb_update_keyblock (KEYDB_HANDLE hd, KBNODE kb);
47 int keydb_insert_keyblock (KEYDB_HANDLE hd, KBNODE kb);
48 #endif
50 gpg_error_t keydb_get_flags (KEYDB_HANDLE hd, int which, int idx,
51 unsigned int *value);
52 gpg_error_t keydb_set_flags (KEYDB_HANDLE hd, int which, int idx,
53 unsigned int value);
54 int keydb_get_cert (KEYDB_HANDLE hd, ksba_cert_t *r_cert);
55 int keydb_insert_cert (KEYDB_HANDLE hd, ksba_cert_t cert);
56 int keydb_update_cert (KEYDB_HANDLE hd, ksba_cert_t cert);
58 int keydb_delete (KEYDB_HANDLE hd, int unlock);
60 int keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved);
61 void keydb_rebuild_caches (void);
63 int keydb_search_reset (KEYDB_HANDLE hd);
64 int keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc);
65 int keydb_search_first (KEYDB_HANDLE hd);
66 int keydb_search_next (KEYDB_HANDLE hd);
67 int keydb_search_kid (KEYDB_HANDLE hd, u32 *kid);
68 int keydb_search_fpr (KEYDB_HANDLE hd, const byte *fpr);
69 int keydb_search_issuer (KEYDB_HANDLE hd, const char *issuer);
70 int keydb_search_issuer_sn (KEYDB_HANDLE hd,
71 const char *issuer, const unsigned char *serial);
72 int keydb_search_subject (KEYDB_HANDLE hd, const char *issuer);
74 int keydb_classify_name (const char *name, KEYDB_SEARCH_DESC *desc);
76 int keydb_store_cert (ksba_cert_t cert, int ephemeral, int *existed);
77 gpg_error_t keydb_set_cert_flags (ksba_cert_t cert, int which, int idx,
78 unsigned int value);
80 void keydb_clear_some_cert_flags (ctrl_t ctrl, strlist_t names);
83 #endif /*GNUPG_KEYDB_H*/