2003-06-05 09:14:21 +02:00
|
|
|
/* keybox.h - Keybox operations
|
2012-12-28 14:03:16 +01:00
|
|
|
* Copyright (C) 2001, 2003, 2012 Free Software Foundation, Inc.
|
2003-06-05 09:14:21 +02:00
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-04 21:49:40 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-06-05 09:14:21 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-04 21:49:40 +02:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2003-06-05 09:14:21 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KEYBOX_H
|
|
|
|
#define KEYBOX_H 1
|
|
|
|
#ifdef __cplusplus
|
2011-02-04 12:57:53 +01:00
|
|
|
extern "C" {
|
2003-06-05 09:14:21 +02:00
|
|
|
#if 0
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2012-12-28 14:03:16 +01:00
|
|
|
#include "../common/iobuf.h"
|
2003-06-05 09:14:21 +02:00
|
|
|
#include "keybox-search-desc.h"
|
|
|
|
|
|
|
|
#ifdef KEYBOX_WITH_X509
|
|
|
|
# include <ksba.h>
|
|
|
|
#endif
|
|
|
|
|
2004-02-02 18:09:35 +01:00
|
|
|
typedef struct keybox_handle *KEYBOX_HANDLE;
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
|
2004-02-02 18:09:35 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
KEYBOX_FLAG_BLOB, /* The blob flags. */
|
|
|
|
KEYBOX_FLAG_VALIDITY, /* The validity of the entire key. */
|
|
|
|
KEYBOX_FLAG_OWNERTRUST, /* The assigned ownertrust. */
|
|
|
|
KEYBOX_FLAG_KEY, /* The key flags; requires a key index. */
|
|
|
|
KEYBOX_FLAG_UID, /* The user ID flags; requires an uid index. */
|
2004-04-26 10:09:25 +02:00
|
|
|
KEYBOX_FLAG_UID_VALIDITY,/* The validity of a specific uid, requires
|
2004-02-02 18:09:35 +01:00
|
|
|
an uid index. */
|
2012-12-28 17:17:56 +01:00
|
|
|
KEYBOX_FLAG_CREATED_AT, /* The date the block was created. */
|
|
|
|
KEYBOX_FLAG_SIG_INFO, /* The signature info block. */
|
2004-04-26 10:09:25 +02:00
|
|
|
} keybox_flag_t;
|
2003-06-05 09:14:21 +02:00
|
|
|
|
2007-03-20 17:57:40 +01:00
|
|
|
/* Flag values used with KEYBOX_FLAG_BLOB. */
|
|
|
|
#define KEYBOX_FLAG_BLOB_SECRET 1
|
|
|
|
#define KEYBOX_FLAG_BLOB_EPHEMERAL 2
|
|
|
|
|
2014-10-31 12:15:34 +01:00
|
|
|
/* The keybox blob types. */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
KEYBOX_BLOBTYPE_EMPTY = 0,
|
|
|
|
KEYBOX_BLOBTYPE_HEADER = 1,
|
|
|
|
KEYBOX_BLOBTYPE_PGP = 2,
|
|
|
|
KEYBOX_BLOBTYPE_X509 = 3
|
|
|
|
} keybox_blobtype_t;
|
2007-03-20 17:57:40 +01:00
|
|
|
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
/*-- keybox-init.c --*/
|
|
|
|
void *keybox_register_file (const char *fname, int secret);
|
|
|
|
int keybox_is_writable (void *token);
|
|
|
|
|
2014-10-09 19:10:32 +02:00
|
|
|
KEYBOX_HANDLE keybox_new_openpgp (void *token, int secret);
|
|
|
|
KEYBOX_HANDLE keybox_new_x509 (void *token, int secret);
|
2003-06-05 09:14:21 +02:00
|
|
|
void keybox_release (KEYBOX_HANDLE hd);
|
2014-06-02 15:55:00 +02:00
|
|
|
void keybox_push_found_state (KEYBOX_HANDLE hd);
|
|
|
|
void keybox_pop_found_state (KEYBOX_HANDLE hd);
|
2003-06-05 09:14:21 +02:00
|
|
|
const char *keybox_get_resource_name (KEYBOX_HANDLE hd);
|
|
|
|
int keybox_set_ephemeral (KEYBOX_HANDLE hd, int yes);
|
|
|
|
|
2012-12-27 15:04:29 +01:00
|
|
|
int keybox_lock (KEYBOX_HANDLE hd, int yes);
|
|
|
|
|
|
|
|
/*-- keybox-file.c --*/
|
|
|
|
/* Fixme: This function does not belong here: Provide a better
|
|
|
|
interface to create a new keybox file. */
|
2014-10-09 19:10:32 +02:00
|
|
|
int _keybox_write_header_blob (FILE *fp, int openpgp_flag);
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
/*-- keybox-search.c --*/
|
2013-01-07 21:14:52 +01:00
|
|
|
gpg_error_t keybox_get_keyblock (KEYBOX_HANDLE hd, iobuf_t *r_iobuf,
|
|
|
|
int *r_uid_no, int *r_pk_no, u32 **sigstatus);
|
2011-02-04 12:57:53 +01:00
|
|
|
#ifdef KEYBOX_WITH_X509
|
2003-12-17 13:27:21 +01:00
|
|
|
int keybox_get_cert (KEYBOX_HANDLE hd, ksba_cert_t *ret_cert);
|
2003-06-05 09:14:21 +02:00
|
|
|
#endif /*KEYBOX_WITH_X509*/
|
2004-02-02 18:09:35 +01:00
|
|
|
int keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value);
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
int keybox_search_reset (KEYBOX_HANDLE hd);
|
2014-05-14 16:32:49 +02:00
|
|
|
int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
|
2014-10-31 12:15:34 +01:00
|
|
|
keybox_blobtype_t want_blobtype,
|
2014-10-09 21:01:49 +02:00
|
|
|
size_t *r_descindex, unsigned long *r_skipped);
|
2003-06-05 09:14:21 +02:00
|
|
|
|
2015-12-15 13:09:27 +01:00
|
|
|
off_t keybox_offset (KEYBOX_HANDLE hd);
|
|
|
|
gpg_error_t keybox_seek (KEYBOX_HANDLE hd, off_t offset);
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
/*-- keybox-update.c --*/
|
2012-12-28 14:03:16 +01:00
|
|
|
gpg_error_t keybox_insert_keyblock (KEYBOX_HANDLE hd,
|
2012-12-28 17:17:56 +01:00
|
|
|
const void *image, size_t imagelen,
|
|
|
|
u32 *sigstatus);
|
2012-12-28 14:03:16 +01:00
|
|
|
gpg_error_t keybox_update_keyblock (KEYBOX_HANDLE hd,
|
|
|
|
const void *image, size_t imagelen);
|
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
#ifdef KEYBOX_WITH_X509
|
2003-12-17 13:27:21 +01:00
|
|
|
int keybox_insert_cert (KEYBOX_HANDLE hd, ksba_cert_t cert,
|
2003-06-05 09:14:21 +02:00
|
|
|
unsigned char *sha1_digest);
|
2003-12-17 13:27:21 +01:00
|
|
|
int keybox_update_cert (KEYBOX_HANDLE hd, ksba_cert_t cert,
|
2003-06-05 09:14:21 +02:00
|
|
|
unsigned char *sha1_digest);
|
|
|
|
#endif /*KEYBOX_WITH_X509*/
|
2004-02-02 18:09:35 +01:00
|
|
|
int keybox_set_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int value);
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
int keybox_delete (KEYBOX_HANDLE hd);
|
2004-04-26 10:09:25 +02:00
|
|
|
int keybox_compress (KEYBOX_HANDLE hd);
|
2003-06-05 09:14:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*-- --*/
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
int keybox_locate_writable (KEYBOX_HANDLE hd);
|
|
|
|
int keybox_rebuild_cache (void *);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*-- keybox-util.c --*/
|
|
|
|
void keybox_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
|
|
|
|
void *(*new_realloc_func)(void *p, size_t n),
|
|
|
|
void (*new_free_func)(void*) );
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /*KEYBOX_H*/
|