#ifndef KEYBOX_DEFS_H
#define KEYBOX_DEFS_H 1
-#ifdef GPG_ERR_SOURCE_DEFAULT
-# if GPG_ERR_SOURCE_DEFAULT != GPG_ERR_SOURCE_KEYBOX
-# error GPG_ERR_SOURCE_DEFAULT already defined
-# endif
-#else
-# define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_KEYBOX
+#ifndef GPG_ERR_SOURCE_DEFAULT
+#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_KEYBOX
#endif
#include <gpg-error.h>
#define map_assuan_err(a) \
#include <sys/types.h> /* off_t */
-/* We include the type definitions from jnlib instead of defining our
- owns here. This will not allow us build KBX in a standalone way
- but there is currently no need for it anyway. Same goes for
- stringhelp.h which for example provides a replacement for stpcpy -
- fixme: Better use the LIBOBJ mechnism. */
-#include "../common/types.h"
-#include "../common/stringhelp.h"
-#include "../common/dotlock.h"
-#include "../common/logging.h"
-
+#include "../common/util.h"
#include "keybox.h"
struct keybox_handle {
KB_NAME kb;
int secret; /* this is for a secret keybox */
- FILE *fp;
+ estream_t fp;
int eof;
int error;
int ephemeral;
};
-/* Openpgp helper structures. */
+/* OpenPGP helper structures. */
struct _keybox_openpgp_key_info
{
struct _keybox_openpgp_key_info *next;
int algo;
+ int version;
+ unsigned char grip[20];
unsigned char keyid[8];
- int fprlen; /* Either 16 or 20 */
- unsigned char fpr[20];
+ int fprlen; /* Either 16, 20 or 32 */
+ unsigned char fpr[32];
};
struct _keybox_openpgp_uid_info
const unsigned char *image,
size_t imagelen,
int as_ephemeral);
+char *_keybox_x509_email_kludge (const char *name);
+
#ifdef KEYBOX_WITH_X509
int _keybox_create_x509_blob (KEYBOXBLOB *r_blob, ksba_cert_t cert,
unsigned char *sha1_digest, int as_ephemeral);
/*-- keybox-file.c --*/
-int _keybox_read_blob (KEYBOXBLOB *r_blob, FILE *fp, int *skipped_deleted);
-int _keybox_write_blob (KEYBOXBLOB blob, FILE *fp);
+int _keybox_read_blob (KEYBOXBLOB *r_blob, estream_t fp, int *skipped_deleted);
+int _keybox_write_blob (KEYBOXBLOB blob, estream_t fp, FILE *outfp);
/*-- keybox-search.c --*/
gpg_err_code_t _keybox_get_flag_location (const unsigned char *buffer,
/*-- keybox-util.c --*/
-void *_keybox_malloc (size_t n);
-void *_keybox_calloc (size_t n, size_t m);
-void *_keybox_realloc (void *p, size_t n);
-void _keybox_free (void *p);
-
-#define xtrymalloc(a) _keybox_malloc ((a))
-#define xtrycalloc(a,b) _keybox_calloc ((a),(b))
-#define xtryrealloc(a,b) _keybox_realloc((a),(b))
-#define xfree(a) _keybox_free ((a))
-
-
-#define DIM(v) (sizeof(v)/sizeof((v)[0]))
-#define DIMof(type,member) DIM(((type *)0)->member)
-#ifndef STR
-# define STR(v) #v
-#endif
-#define STR2(v) STR(v)
/*
- a couple of handy macros
-*/
-
-#define return_if_fail(expr) do { \
- if (!(expr)) { \
- fprintf (stderr, "%s:%d: assertion '%s' failed\n", \
- __FILE__, __LINE__, #expr ); \
- return; \
- } } while (0)
-#define return_null_if_fail(expr) do { \
- if (!(expr)) { \
- fprintf (stderr, "%s:%d: assertion '%s' failed\n", \
- __FILE__, __LINE__, #expr ); \
- return NULL; \
- } } while (0)
-#define return_val_if_fail(expr,val) do { \
- if (!(expr)) { \
- fprintf (stderr, "%s:%d: assertion '%s' failed\n", \
- __FILE__, __LINE__, #expr ); \
- return (val); \
- } } while (0)
-#define never_reached() do { \
- fprintf (stderr, "%s:%d: oops; should never get here\n", \
- __FILE__, __LINE__ ); \
- } while (0)
-
-
-/* some macros to replace ctype ones and avoid locale problems */
-#define digitp(p) (*(p) >= '0' && *(p) <= '9')
-#define hexdigitp(a) (digitp (a) \
- || (*(a) >= 'A' && *(a) <= 'F') \
- || (*(a) >= 'a' && *(a) <= 'f'))
-/* the atoi macros assume that the buffer has only valid digits */
-#define atoi_1(p) (*(p) - '0' )
-#define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1))
-#define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2))
-#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
- *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
-#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
+ * A couple of handy macros
+ */
#endif /*KEYBOX_DEFS_H*/