1 /* keybox.h - Keybox operations
2 * Copyright (C) 2001, 2003, 2012 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 3 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, see <http://www.gnu.org/licenses/>.
29 #include "../common/iobuf.h"
30 #include "keybox-search-desc.h"
32 #ifdef KEYBOX_WITH_X509
36 typedef struct keybox_handle *KEYBOX_HANDLE;
41 KEYBOX_FLAG_BLOB, /* The blob flags. */
42 KEYBOX_FLAG_VALIDITY, /* The validity of the entire key. */
43 KEYBOX_FLAG_OWNERTRUST, /* The assigned ownertrust. */
44 KEYBOX_FLAG_KEY, /* The key flags; requires a key index. */
45 KEYBOX_FLAG_UID, /* The user ID flags; requires an uid index. */
46 KEYBOX_FLAG_UID_VALIDITY,/* The validity of a specific uid, requires
48 KEYBOX_FLAG_CREATED_AT, /* The date the block was created. */
49 KEYBOX_FLAG_SIG_INFO, /* The signature info block. */
52 /* Flag values used with KEYBOX_FLAG_BLOB. */
53 #define KEYBOX_FLAG_BLOB_SECRET 1
54 #define KEYBOX_FLAG_BLOB_EPHEMERAL 2
56 /* The keybox blob types. */
59 KEYBOX_BLOBTYPE_EMPTY = 0,
60 KEYBOX_BLOBTYPE_HEADER = 1,
61 KEYBOX_BLOBTYPE_PGP = 2,
62 KEYBOX_BLOBTYPE_X509 = 3
66 /*-- keybox-init.c --*/
67 void *keybox_register_file (const char *fname, int secret);
68 int keybox_is_writable (void *token);
70 KEYBOX_HANDLE keybox_new_openpgp (void *token, int secret);
71 KEYBOX_HANDLE keybox_new_x509 (void *token, int secret);
72 void keybox_release (KEYBOX_HANDLE hd);
73 void keybox_push_found_state (KEYBOX_HANDLE hd);
74 void keybox_pop_found_state (KEYBOX_HANDLE hd);
75 const char *keybox_get_resource_name (KEYBOX_HANDLE hd);
76 int keybox_set_ephemeral (KEYBOX_HANDLE hd, int yes);
78 int keybox_lock (KEYBOX_HANDLE hd, int yes);
80 /*-- keybox-file.c --*/
81 /* Fixme: This function does not belong here: Provide a better
82 interface to create a new keybox file. */
83 int _keybox_write_header_blob (FILE *fp, int openpgp_flag);
85 /*-- keybox-search.c --*/
86 gpg_error_t keybox_get_keyblock (KEYBOX_HANDLE hd, iobuf_t *r_iobuf,
87 int *r_uid_no, int *r_pk_no, u32 **sigstatus);
88 #ifdef KEYBOX_WITH_X509
89 int keybox_get_cert (KEYBOX_HANDLE hd, ksba_cert_t *ret_cert);
90 #endif /*KEYBOX_WITH_X509*/
91 int keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value);
93 int keybox_search_reset (KEYBOX_HANDLE hd);
94 int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
95 keybox_blobtype_t want_blobtype,
96 size_t *r_descindex, unsigned long *r_skipped);
99 /*-- keybox-update.c --*/
100 gpg_error_t keybox_insert_keyblock (KEYBOX_HANDLE hd,
101 const void *image, size_t imagelen,
103 gpg_error_t keybox_update_keyblock (KEYBOX_HANDLE hd,
104 const void *image, size_t imagelen);
106 #ifdef KEYBOX_WITH_X509
107 int keybox_insert_cert (KEYBOX_HANDLE hd, ksba_cert_t cert,
108 unsigned char *sha1_digest);
109 int keybox_update_cert (KEYBOX_HANDLE hd, ksba_cert_t cert,
110 unsigned char *sha1_digest);
111 #endif /*KEYBOX_WITH_X509*/
112 int keybox_set_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int value);
114 int keybox_delete (KEYBOX_HANDLE hd);
115 int keybox_compress (KEYBOX_HANDLE hd);
121 int keybox_locate_writable (KEYBOX_HANDLE hd);
122 int keybox_rebuild_cache (void *);
126 /*-- keybox-util.c --*/
127 void keybox_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
128 void *(*new_realloc_func)(void *p, size_t n),
129 void (*new_free_func)(void*) );