aboutsummaryrefslogtreecommitdiffstats
path: root/kbx/backend.h
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-01-02 13:21:12 +0000
committerWerner Koch <[email protected]>2020-01-02 13:21:12 +0000
commitf4da1455c7ab858ea9007d0813774c6d04cd4576 (patch)
tree0380bf55daa9295f2a650875a3eb7bde6b8072da /kbx/backend.h
parentUpdate wk's signing key (diff)
downloadgnupg-f4da1455c7ab858ea9007d0813774c6d04cd4576.tar.gz
gnupg-f4da1455c7ab858ea9007d0813774c6d04cd4576.zip
kbx: Initial support for an SQLite backend
* kbx/backend-sqlite.c: New. * kbx/Makefile.am (keyboxd_SOURCES): Add it. (keyboxd_CFLAGS, keyboxd_LDADD): Add SQLite flags. * kbx/backend.h (enum database_types): Add DB_TYPE_SQLITE. (be_sqlite_local_t): New typedef. (struct db_request_part_s): Add field besqlite. * kbx/backend-support.c (strdbtype): Add string for DB_TYPE_SQLITE. (be_generic_release_backend): Support SQLite. (be_release_request): Ditto. (be_find_request_part): Ditto. (is_x509_blob): Rename to ... (be_is_x509_blob): this and make global. * kbx/frontend.c (kbxd_set_database): Detect ".db" suffix and use that for SQLite. (kbxd_search): Support SQLite (kbxd_store): Ditto. (kbxd_delete): Ditto. * kbx/frontend.h (kbxd_store_modes): Move to ... * kbx/keyboxd.h (enum kbxd_store_modes): here. * kbx/keyboxd.c (main): USe pubring.db for now. This is a temporary hack. * kbx/backend-kbx.c (be_kbx_delete): Remove unused var cert. -- Take care: This is not finished and in particular filling the database takes quite long. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'kbx/backend.h')
-rw-r--r--kbx/backend.h34
1 files changed, 32 insertions, 2 deletions
diff --git a/kbx/backend.h b/kbx/backend.h
index 3aa848714..092f490bc 100644
--- a/kbx/backend.h
+++ b/kbx/backend.h
@@ -32,7 +32,8 @@ enum database_types
{
DB_TYPE_NONE, /* No database at all (unitialized etc.). */
DB_TYPE_CACHE, /* The cache backend (backend-cache.c). */
- DB_TYPE_KBX /* Keybox type database (backend-kbx.c). */
+ DB_TYPE_KBX, /* Keybox type database (backend-kbx.c). */
+ DB_TYPE_SQLITE /* SQLite type database (backend-sqlite.c).*/
};
@@ -43,6 +44,11 @@ struct backend_handle_s;
typedef struct backend_handle_s *backend_handle_t;
+/* Private data for sqlite requests. */
+struct be_sqlite_local_s;
+typedef struct be_sqlite_local_s *be_sqlite_local_t;
+
+
/* Object to store backend specific database information per database
* handle. */
struct db_request_part_s
@@ -52,9 +58,12 @@ struct db_request_part_s
/* Id of the backend instance this object pertains to. */
unsigned int backend_id;
- /* The handle used for a KBX backend or NULL. */
+ /* Local data for a KBX backend or NULL. */
KEYBOX_HANDLE kbx_hd;
+ /* Local data for a sqlite backend. */
+ be_sqlite_local_t besqlite;
+
/* For the CACHE backend the indices into the bloblist for each
* index type. */
struct {
@@ -106,6 +115,7 @@ gpg_error_t be_find_request_part (backend_handle_t backend_hd,
gpg_error_t be_return_pubkey (ctrl_t ctrl, const void *buffer, size_t buflen,
enum pubkey_types pubkey_type,
const unsigned char *ubid);
+int be_is_x509_blob (const unsigned char *blob, size_t bloblen);
gpg_error_t be_ubid_from_blob (const void *blob, size_t bloblen,
enum pubkey_types *r_pktype, char *r_ubid);
@@ -148,4 +158,24 @@ gpg_error_t be_kbx_delete (ctrl_t ctrl, backend_handle_t backend_hd,
db_request_t request);
+/*-- backend-sqlite.c --*/
+gpg_error_t be_sqlite_add_resource (ctrl_t ctrl, backend_handle_t *r_hd,
+ const char *filename, int readonly);
+void be_sqlite_release_resource (ctrl_t ctrl, backend_handle_t hd);
+
+gpg_error_t be_sqlite_init_local (backend_handle_t backend_hd,
+ db_request_part_t part);
+void be_sqlite_release_local (be_sqlite_local_t ctx);
+gpg_error_t be_sqlite_search (ctrl_t ctrl, backend_handle_t hd,
+ db_request_t request,
+ KEYDB_SEARCH_DESC *desc, unsigned int ndesc);
+gpg_error_t be_sqlite_store (ctrl_t ctrl, backend_handle_t backend_hd,
+ db_request_t request, enum kbxd_store_modes mode,
+ enum pubkey_types pktype,
+ const unsigned char *ubid,
+ const void *blob, size_t bloblen);
+gpg_error_t be_sqlite_delete (ctrl_t ctrl, backend_handle_t backend_hd,
+ db_request_t request, const unsigned char *ubid);
+
+
#endif /*KBX_BACKEND_H*/