chiark / gitweb /
dirmngr: Fix for --disable-libdns usage.
[gnupg2.git] / sm / keydb.h
1 /* keydb.h - Key database
2  * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3  *
4  * This file is part of GnuPG.
5  *
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 3 of the License, or
9  * (at your option) any later version.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <https://www.gnu.org/licenses/>.
18  */
19
20 #ifndef GNUPG_KEYDB_H
21 #define GNUPG_KEYDB_H
22
23 #include <ksba.h>
24
25 #include "../common/userids.h"
26
27 typedef struct keydb_handle *KEYDB_HANDLE;
28
29 /* Flag value used with KEYBOX_FLAG_VALIDITY. */
30 #define VALIDITY_REVOKED (1<<5)
31
32
33 /*-- keydb.c --*/
34 gpg_error_t keydb_add_resource (ctrl_t ctrl, const char *url,
35                                 int force, int *auto_created);
36 KEYDB_HANDLE keydb_new (void);
37 void keydb_release (KEYDB_HANDLE hd);
38 int keydb_set_ephemeral (KEYDB_HANDLE hd, int yes);
39 const char *keydb_get_resource_name (KEYDB_HANDLE hd);
40 gpg_error_t keydb_lock (KEYDB_HANDLE hd);
41
42 gpg_error_t keydb_get_flags (KEYDB_HANDLE hd, int which, int idx,
43                              unsigned int *value);
44 gpg_error_t keydb_set_flags (KEYDB_HANDLE hd, int which, int idx,
45                              unsigned int value);
46 void keydb_push_found_state (KEYDB_HANDLE hd);
47 void keydb_pop_found_state (KEYDB_HANDLE hd);
48 int keydb_get_cert (KEYDB_HANDLE hd, ksba_cert_t *r_cert);
49 int keydb_insert_cert (KEYDB_HANDLE hd, ksba_cert_t cert);
50 int keydb_update_cert (KEYDB_HANDLE hd, ksba_cert_t cert);
51
52 int keydb_delete (KEYDB_HANDLE hd, int unlock);
53
54 int keydb_locate_writable (KEYDB_HANDLE hd, const char *reserved);
55 void keydb_rebuild_caches (void);
56
57 gpg_error_t keydb_search_reset (KEYDB_HANDLE hd);
58 int keydb_search (ctrl_t ctrl, KEYDB_HANDLE hd,
59                   KEYDB_SEARCH_DESC *desc, size_t ndesc);
60 int keydb_search_first (ctrl_t ctrl, KEYDB_HANDLE hd);
61 int keydb_search_next (ctrl_t ctrl, KEYDB_HANDLE hd);
62 int keydb_search_kid (ctrl_t ctrl, KEYDB_HANDLE hd, u32 *kid);
63 int keydb_search_fpr (ctrl_t ctrl, KEYDB_HANDLE hd, const byte *fpr);
64 int keydb_search_issuer (ctrl_t ctrl, KEYDB_HANDLE hd, const char *issuer);
65 int keydb_search_issuer_sn (ctrl_t ctrl, KEYDB_HANDLE hd,
66                             const char *issuer, const unsigned char *serial);
67 int keydb_search_subject (ctrl_t ctrl, KEYDB_HANDLE hd, const char *issuer);
68
69 int keydb_store_cert (ctrl_t ctrl, ksba_cert_t cert, int ephemeral,
70                       int *existed);
71 gpg_error_t keydb_set_cert_flags (ctrl_t ctrl, ksba_cert_t cert, int ephemeral,
72                                   int which, int idx,
73                                   unsigned int mask, unsigned int value);
74
75 void keydb_clear_some_cert_flags (ctrl_t ctrl, strlist_t names);
76
77
78 #endif /*GNUPG_KEYDB_H*/