aboutsummaryrefslogtreecommitdiffstats
path: root/kbx (follow)
Commit message (Collapse)AuthorAgeFilesLines
* kbx: For non-Windows use 64k buffers by default instead of 128k.Werner Koch2023-05-081-1/+7
| | | | | | | | | * kbx/keybox-init.c (DEFAULT_LL_BUFFER_SIZE): New. -- A simple gpg --check-sigs benchmark showed on Linux a small performance peak at around 64k (5m52 vs. 6m8 for 128k and 6m33 for system size).
* kbx: Use custom estream bufferingWerner Koch2023-05-082-3/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * kbx/keybox-init.c (ll_buffer_size): New var intialized to 128k (stream_buffers): New var. (keybox_set_buffersize): New. (_keybox_ll_open, _keybox_ll_close): Implement buffering. * sm/gpgsm.c (oKbxBufferSize): New. (opts): Add option --kbx-buffer-size. (main): Call keybox_set_buffersize. * g10/gpg.c: Include keybox.h. * (oKbxBufferSize): New. (opts): Add option --kbx-buffer-size. (main): Call keybox_set_buffersize. -- Running a test on Windows using a pubring.kbx with Total number of blobs: 2098 openpgp: 1294 x509: 803 and a size of 42MiB with gpgsm -k --with-validation --disable-dirmngr --kbx-buffer-size N >nul gives these performance figures using procmon | N(k) | file events | time(s) | |------+-------------+---------| | 0 | 4900000 | 86 | | 16 | 2456000 | 58 | | 32 | 1233000 | 43 | | 64 | 622000 | 37 | | 128 | 317000 | 32 | | 256 | 164000 | 31 | | 512 | 88000 | 30 | Using _open instead of CreateFile give the same number of file events but increased the time slight by one second for the measured buffer size of 64k and 128k. Benchmarks for gpg have not been conducted.
* kbx: Use wrapper functions for es_fclose and es_fopen.Werner Koch2023-05-054-88/+120
| | | | | | | | | | | | | * kbx/keybox-defs.h (KEYBOX_LL_OPEN_READ) (KEYBOX_LL_OPEN_UPDATE, KEYBOX_LL_OPEN_CREATE): New. * kbx/keybox-init.c (_keybox_ll_open): New. Replace all keybox use of es_fopen by this function. (_keybox_ll_close): New. Replace all keybox use of es_fclose by this function. -- Note that this has not been done for the utilities and the backend-kbx of keyboxd.
* kbx: Add extra flags to fopen for use by Windows.Werner Koch2023-05-042-7/+7
| | | | | | | | | | | | | | | | | | * kbx/keybox-search.c (open_file): Use sysopen and sequential. * kbx/keybox-update.c (create_tmp_file): Ditto. (blob_filecopy): Ditto. (keybox_set_flags): Ditto. (keybox_delete): Ditto. (keybox_compress): Ditto. -- Under Windows "sysopen" requests that direct API calls (CreateFile et al.) are used instead of the libc wrappers. This may or may not improve the performance. Using "sequential" is a hint to Windows to assume that a file is in general access in a sequential manner. This will have an affect only with a future libgpg-error.
* keyboxd: Allow import of v0 certificates.Werner Koch2023-03-081-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | * kbx/backend-support.c (be_is_x509_blob): Loose detection. -- Here is a sample v0 cert: -----BEGIN CERTIFICATE----- MIIDAzCCAmwCEQC5L2DMiJ+hekYJuFtwbIqvMA0GCSqGSIb3DQEBBQUAMIHBMQsw CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xPDA6BgNVBAsTM0Ns YXNzIDIgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH MjE6MDgGA1UECxMxKGMpIDE5OTggVmVyaVNpZ24sIEluYy4gLSBGb3IgYXV0aG9y aXplZCB1c2Ugb25seTEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0d29yazAe Fw05ODA1MTgwMDAwMDBaFw0yODA4MDEyMzU5NTlaMIHBMQswCQYDVQQGEwJVUzEX MBUGA1UEChMOVmVyaVNpZ24sIEluYy4xPDA6BgNVBAsTM0NsYXNzIDIgUHVibGlj IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjE6MDgGA1UECxMx KGMpIDE5OTggVmVyaVNpZ24sIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s eTEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0d29yazCBnzANBgkqhkiG9w0B AQEFAAOBjQAwgYkCgYEAp4gBIXQs5xoD8JjhlzwPIQjxnNuX6Zr8wgQGE75fUsjM HiwSViy4AWkszJkfrbCWrnkE8hM5wXuYuggs6MKEEyyqaekJ9MepAqRCwiNPStjw DqL7MWzJ5m+ZJwf15vRMeJ5t60aG+rmGyVTyssSv1EYcWskVMP8NbPUtDm3Of3cC AwEAATANBgkqhkiG9w0BAQUFAAOBgQByLvl/0fFx+8Se9sVeUYpAmLho+Jscg9ji nb3/7aHmZuovCfTK1+qlK5X2JGCGTUQug6XELaDTrnhpb3LabK4I8GOSN+a7xDAX rXfMSTWqz9iP0b63GJZHc2pUIjRkLbYWm1lbtFFZOrMLFPQS32eg9K0yZF6xRnIn jBJ7xUS0rg== -----END CERTIFICATE-----
* build: Remove Windows CE support.NIIBE Yutaka2022-12-091-8/+2
| | | | | | | | | | | | | | | | * agent/Makefile.am [HAVE_W32CE_SYSTEM]: Remove. * am/cmacros.am [HAVE_W32CE_SYSTEM]: Remove. * autogen.sh: Remove W32ce_ variables. * configure.ac: Likewise. * dirmngr/Makefile.am (extra_bin_ldflags): Remove. * g10/Makefile.am [HAVE_W32CE_SYSTEM]: Remove. * kbx/Makefile.am: Likewise. * sm/Makefile.am (extra_bin_ldflags): Remove. * tools/Makefile.am (extra_bin_ldflags): Remove. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* kbx: Fix for GPG_ERR_SOURCE_DEFAULT.NIIBE Yutaka2022-09-142-8/+3
| | | | | | | | | | | * kbx/keybox-defs.h (GPG_ERR_SOURCE_DEFAULT): Define here, when not defined. * kbx/kbxutil.c: Let keybox-defs.h include gpg-error.h. -- GnuPG-bug-id: 6200 Signed-off-by: NIIBE Yutaka <[email protected]>
* Remove remaining support for WindowsCEWerner Koch2022-06-031-15/+2
| | | | --
* kbx: Fix a race condition which results no status report.NIIBE Yutaka2022-04-273-11/+25
| | | | | | | | | | | | | | * kbx/keyboxd.h (kbxd_status_printf): New. * kbx/backend-support.c (be_return_pubkey): Use kbxd_status_printf. * kbx/kbxserver.c (kbxd_status_printf): New. * kbxd_start_command_handler (kbxd_start_command_handler): Don't use set_assuan_context_func, because the function pointer is shared by multiple threads. -- GnuPG-bug-id: 5948 Signed-off-by: NIIBE Yutaka <[email protected]>
* kbx: Fix searching for FPR20 in version 2 blob.NIIBE Yutaka2022-03-241-4/+2
| | | | | | | | | | | | * kbx/keybox-search.c (blob_cmp_fpr_part): Don't change FPROFF, since it's caller which tweaks the offset. (has_short_kid, has_long_kid): Examine the key flags to determine if fingerprint 32 or 20. -- GnuPG-bug-id: 5888 Signed-off-by: NIIBE Yutaka <[email protected]>
* kbx: Fix allocation checkJakub Jelen2021-11-241-1/+1
| | | | | | | | * kbx/kbxserver.c (cmd_search): Fix allocation check -- GnuPG-bug-id: 5393 Signed-off-by: Jakub Jelen <[email protected]>
* keyboxd: New option --steal-socket.Werner Koch2021-11-131-8/+20
| | | | | | | | | * kbx/keyboxd.c (oStealSocket): New const. (opts): Add option. (steal_socket): New file global flag. (main): Set option. (create_server_socket): Implement option. --
* kbx: Avoid use of uninitialized value.Jakub Jelen2021-11-121-2/+2
| | | | | | | | | | | | * kbx/backend-kbx.c (be_kbx_search): Initialize skipped_long_blobs value which is passed to keybox_search and incremented there. (be_kbx_seek): Likewise. -- GnuPG-bug-id: 5393 Co-authored-by: NIIBE Yutaka <[email protected]> Signed-off-by: Jakub Jelen <[email protected]>
* agent,dirmngr,kbx,scd,tpm2d: Use gnupg_sleep.NIIBE Yutaka2021-10-051-1/+1
| | | | | | | | | | | | | | | | * agent/findkey.c (unprotect): Use gnupg_sleep. * agent/gpg-agent.c (handle_connections): Likewise. * dirmngr/crlfetch.c (handle_connections): Likewise. * kbx/keyboxd.c (handle_connections): Likewise. * tpm2d/tpm3daemon.c (handle_connections): Likewise. * scd/scdaemon.c (handle_connections): Likewise. * scd/command.c (cmd_lock): Likewise. * dirmngr/ldap-wrapper.c (ldap_reaper_thread): Likewise. (ldap_wrapper_wait_connections): Use gnupg_usleep. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* kbx: Let it include keybox.h to avoid multiple typedefs.NIIBE Yutaka2021-09-301-6/+1
| | | | | | | | | * kbx/backend.h: Include keybox.h. -- GnuPG-bug-id: 5630 Signed-off-by: NIIBE Yutaka <[email protected]>
* kbx: A 20 byte fingerprint is right filled in version 2 blob.NIIBE Yutaka2021-09-281-0/+2
| | | | | | | | | | * kbx/keybox-blob.c (create_blob_header): Fix creating FPR20 key in blob with 32-byte fingerprint. -- GnuPG-bug-id: 5609 Signed-off-by: NIIBE Yutaka <[email protected]>
* build: Fix several "include file not found" problemsIngo Klöcker2021-09-201-2/+2
| | | | | | | | | | | | | * dirmngr/Makefile.am (t_ldap_parse_uri_CFLAGS): Add KSBA_CFLAGS. * kbx/Makefile.am (libkeybox_a_CFLAGS, libkeybox509_a_CFLAGS): Add NPTH_CFLAGS. * tools/Makefile.am (gpgtar_CFLAGS, gpg_wks_server_CFLAGS, gpg_wks_client_CFLAGS, gpg_pair_tool_CFLAGS): Add LIBGCRYPT_CFLAGS. -- The tools include gcrypt.h via common/util.h. GnuPG-bug-id: 5592
* kbx: Fix checksum computation for no UBID entry on disk.NIIBE Yutaka2021-08-271-2/+2
| | | | | | | | | | | | * kbx/keybox-blob.c (create_blob_header): Fix the flag to match no UBID entry, (create_blob_finish): Fix the length of data to be hashed. -- GnuPG-bug-id: 5573 Fixes-commit: 915297705af6f1db74dacf0d6665b83eb0a58459 Signed-off-by: NIIBE Yutaka <[email protected]>
* kbx: Improve debugging of the search descriptions in keyboxd.Werner Koch2021-07-081-3/+69
| | | | | | | * kbx/frontend.c (dump_search_desc): New. (kbxd_search): Actually log the search descriptions. Signed-off-by: Werner Koch <[email protected]>
* kbx: Fix keyboxd searching with multiple patterns.Werner Koch2021-07-082-10/+85
| | | | | | | | | | | | | | | | | | | | * kbx/keybox-search-desc.h (struct keydb_search_desc): New flag name_used. * common/userids.c (classify_user_id): Set flag. * kbx/kbxserver.c (struct search_backing_store_s): New. (cmd_search): use a backing store for the const pointers. (kbxd_start_command_handler): Release the backing store. -- Well, the search object partly uses buffers but also const pointers (for strings and the serial number). This when assigning such objects to an another one we should really take a deep copy and not just copy the pointer. The more clean solution would have been to provide a storage option the search object but that needs checking the code at too many places so that I decided to use a separate backing store array here. Signed-off-by: Werner Koch <[email protected]>
* kbx: Avoid uninitialized readJakub Jelen2021-05-204-4/+9
| | | | | | | | | | | | * kbx/kbx-client-util.c (datastream_thread): Initialize pointer * kbx/keybox-dump.c (_keybox_dump_cut_records): free blob * kbx/kbxserver.c (kbxd_start_command_handler): do not free passed ctrl * kbx/keyboxd.c (check_own_socket): free sockname -- Signed-off-by: Jakub Jelen <[email protected]> GnuPG-bug-id: 5393
* keyboxd: Fix searching for exact mail addresses.Werner Koch2021-04-212-2/+17
| | | | | | | | | | | | | | | | | | | * kbx/kbxserver.c (cmd_search): Use the openpgp hack for calling classify_user_id. * kbx/backend-sqlite.c (run_select_statement): Remove angle brackets in exact addrspec mode. * g10/call-keyboxd.c (keydb_search): Do not duplicate the left angle bracket. * sm/keydb.c (keydb_search): Ditto. -- Note that the openpgp hack flag of classify_user_id is actually a misnomer because we actually hack a round a problem in gpgsm. And it is only over there that we don't set it there. In keyboxd the flag should be set. And we need to remove the angle brackets of course because that is how we create the addrspec column values. Signed-off-by: Werner Koch <[email protected]>
* Support log-file option from common.conf for all daemon.Werner Koch2021-04-201-2/+29
| | | | | | | | | | | | | | | | * agent/gpg-agent.c: Include comopt.h. (main): Read log-file option from common.conf. (reread_configuration): Ditto. * dirmngr/dirmngr.c: Include comopt.h. (main): Read log-file option from common.conf. (reread_configuration): Ditto. * kbx/keyboxd.c: Include comopt.h. (main): Read log-file option from common.conf. (reread_configuration): Ditto. * scd/scdaemon.c: Include comopt.h. (main): Read log-file option from common.conf. Signed-off-by: Werner Koch <[email protected]>
* kbx: Fix memory leak.Jakub Jelen2021-04-131-2/+2
| | | | | | | | | * kbx/keybox-update.c (blob_filecopy): Goto leave instead of return. -- GnuPG-bug-id: 5393 Signed-off-by: Jakub Jelen <[email protected]>
* agent,kbx: Add LIBASSUAN_CLFAGS.Jakub Jelen2021-04-131-2/+2
| | | | | | | | | | | | * agent/Makefile.am (gpg_preset_passphrase_CFLAGS, t_protect_CFLAGS): Add LIBASSUAN_CFLAGS. * kbx/Makefile.am (libkeybox_a_CFLAGS, libkeybox509_a_CFLAGS): Likewise. -- GnuPG-bug-id: 5389 Signed-off-by: Jakub Jelen <[email protected]>
* kbxd: Group the options.Werner Koch2021-03-222-13/+11
| | | | | * kbx/keyboxd.h (opt): Remove unused field 'batch'. * kbx/keyboxd.c (opts): Remove --batch. Add group descriptions.
* kbx: Log debug fixesWerner Koch2021-02-251-2/+4
| | | | --
* Require GpgRT version 1.41.Werner Koch2021-02-101-16/+0
| | | | | | | | | | | | | | * configure.ac (NEED_GPG_ERROR_VERSION): Rename to NEED_GPGRT_VERSION and set to 1.41. * common/sysutils.c (gnupg_access): Remove code for older gpgrt versions. * kbx/backend-sqlite.c: Ditto. * sm/gpgsm.c (main): Ditto. -- We already have a requirement for a newer Libgcrypt and thus we can also require a more recent libgpgrt (aka libgpg-error) which was released before Libgcrypt.
* kbx: Better error message in case of a crippled Libgcrypt.Werner Koch2020-12-021-2/+10
| | | | * kbx/keybox-openpgp.c (keygrip_from_keyparm): Detect missing curve.
* w32: Replace some fopen by es_fopen.Werner Koch2020-11-111-10/+10
| | | | | | | | | | | * agent/protect-tool.c (read_file): Replace fopen by es_fopen. * dirmngr/dirmngr-client.c (read_pem_certificate): Ditto. (read_certificate): Ditto. * g10/keydb.c (rt_from_file): Ditto. * kbx/kbxutil.c (read_file): Ditto. * g10/plaintext.c (get_output_file) [__riscos__]: Remove code. Signed-off-by: Werner Koch <[email protected]>
* kbx: Don't put zero-byte for ECC.NIIBE Yutaka2020-11-021-17/+18
| | | | | | * kbx/keybox-openpgp.c (parse_key): Only put zero for non-ECC. Signed-off-by: NIIBE Yutaka <[email protected]>
* Replace all calls to stat by gnupg_stat.Werner Koch2020-10-201-3/+3
| | | | | | | | | | | * common/sysutils.c (gnupg_stat): New. * common/sysutils.h: Include sys/stat.h. -- Yet another wrapper for Unicode support on Windows. GnuPG-bug-id: 5098 Signed-off-by: Werner Koch <[email protected]>
* Replace most of the remaining stdio calls by estream calls.Werner Koch2020-10-209-123/+124
| | | | | | | | | | | | -- We need to use es_fopen on Windows to cope with non-ascii file names. This is quite a large but fortunately straightforward change. At a very few places we keep using stdio (for example due to the use of popen). GnuPG-bug-id: 5098 Signed-off-by: Werner Koch <[email protected]>
* Replace all calls to access by gnupg_accessWerner Koch2020-10-202-5/+8
| | | | | | | | | | | | | | | | * common/sysutils.c (gnupg_access): New. Replace all calls to access by this wrapper. * common/homedir.c (w32_shgetfolderpath): Change to return UTF-8 directory name. (standard_homedir): Adjust for change. (w32_commondir, gnupg_cachedir): Ditto. -- Also use SHGetFolderPathW instead of SHGetFolderPathA on Windows. This is required to correctly handle non-ascii filenames on Windows. GnuPG-bug-id: 5098
* keyboxd: Fix duplicates when listing keys by uid.Werner Koch2020-10-051-24/+53
| | | | | | | | | | | | | | | | * kbx/backend-sqlite.c (struct be_sqlite_local_s): Add fields lastubid_valid and lastubid. (run_sql_prepare): Add optional extra2 arg and chage callers. (run_select_statement): Add an ORDER BY clause to most SELECTs. (be_sqlite_search): Skip duplicated keyblocks in a search. -- See the comment in the code for the background. Beware: This change lets tests/openpgp/key-selection.scm fail. Needs to be fixed. Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Make use of the config tableWerner Koch2020-09-251-2/+119
| | | | | | | | | | | | | | * kbx/backend-sqlite.c (DATABASE_VERSION): New. (table_definitions): Make column name of table config unique. (create_or_open_database): Read and set the database version. (get_config_value, set_config_value): New. -- Well, kind of. For now we just store the database version. Note that for existing databases the config table should first be dropped so that the UNIQUE constraint can be used. Signed-off-by: Werner Koch <[email protected]>
* keyboxd: New command TRANSACTION.Werner Koch2020-09-246-10/+230
| | | | | | | | | | | | | | | | | | | | | | | * kbx/backend-sqlite.c (be_sqlite_rollback): New. (be_sqlite_commit): New. (be_sqlite_search): Take care of global transactions. (be_sqlite_store): Ditto. (be_sqlite_delete): Ditto. * kbx/frontend.c (kbxd_rollback, kbxd_commit): New. * kbx/keyboxd.h (opt): Add vars for transactions. * kbx/kbxserver.c (struct server_local_s): Add fields next_session and client_pid. (session_list): New var. (cmd_transaction): New. (register_commands): Register command. (kbxd_start_command_handler): Store pids and track sessions. Do a final rollback. -- This command is currently an experiment to allow a client to run everything in one session. Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Implement multiple search descriptions.Werner Koch2020-09-243-2/+22
| | | | | | | | | | | | * kbx/kbx-client-util.c (kbx_client_data_simple): New. * kbx/backend-sqlite.c (struct be_sqlite_local_s): Add field descidx. (be_sqlite_search): Use that. * g10/call-keyboxd.c (keydb_search): Implement multi mode. -- With that change the keyboxd is at par with the keybox code. Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Fix UDPATE keyblob SQL statementWerner Koch2020-09-241-14/+15
| | | | | | | | | | * kbx/backend-sqlite.c: Always use ?NNN for SQL parameters. -- Using :NNN is obviously wrong to get the parameters in the right order. Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Remove unused variables.Werner Koch2020-09-241-2/+0
| | | | | | | * kbx/kbx-client-util.c (datastream_thread): No need to set PK_NO and UID_NO. Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Extend PUBKEY_INFO status line with an uid ordinal.Werner Koch2020-09-225-29/+99
| | | | | | | | | | | | | | | | | | | | * kbx/backend-sqlite.c (table_definitions): Add column UINO to userids. (be_sqlite_local_s): Add fields select_col_uidno and select_col_subkey. (run_select_statement): Also select subkey or uidno column. (be_sqlite_search): Return their values. (store_into_userid): Store the UIDNO. * kbx/backend-support.c (be_return_pubkey): Extend PUBKEY_INFO. -- For an existing database adding the new column to the table userid is straightforward. However if the original version of the schema used an integer for the keyid column, that column has likely be renamed. Make sure that the NOT NULL constraint has also be removed; check the SQLite documentation on how this can be done. Signed-off-by: Werner Koch <[email protected]>
* kbx: Add bounds check to detect corrupt keyboxes.Werner Koch2020-09-221-6/+99
| | | | | | | | | | | | | * kbx/keybox-dump.c (_keybox_dump_blob): Fix the fixmes. -- kbxutil is a debug tool but nevertheless it should behave well and not read beyond allocated buffers and in turn crash. Vincent Ulitzsch and Dominik Maier were kind enough to report these crashes along with a couple of test keyboxes and crash analysis. Signed-off-by: Werner Koch <[email protected]>
* sm: Implement delete key in keyboxd modeWerner Koch2020-09-211-0/+3
| | | | | | | | | * sm/keydb.c (keydb_delete): Implement keyboxd mode. (keydb_update_cert): Disable unused function. * kbx/backend-sqlite.c (be_sqlite_delete): Delete from issuer. -- Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Implement lookup by short and long keyid.Werner Koch2020-09-111-53/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * kbx/backend-sqlite.c: Change definition of column KID. (kid_from_mem): Remove. (kid_from_u32): Rewrite. (run_sql_bind_int64): Remove. (run_select_statement): Implement lookup by short keyid. Fix lookup by long keyid. (store_into_fingerprint): Adjust kid arg. -- The original idea of using an INTEGER, which has the required 64 bits, didn't worked out due to problems with signed/unsigned mismatch and the required truncation in a short keyid lookup. Thus we change the definition to a blob. For a database currently in use the change can be done by hand: alter table fingerprint rename column kid to deletedkid; alter table fingerprint add column kid not null default X'0000000000000000'; update fingerprint set kid = substr (fpr, 13); The update does only work with 20 octet fingerprints; that is not with the new v5 OpenPGP keys. Note that sqlite does not allow to drip a column, thus we rename it. Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Add ephemeral and revoked flag to the sqlite backend.Werner Koch2020-09-115-22/+65
| | | | | | | | | | | | | | | | * kbx/backend-support.c (be_return_pubkey): Add args is_ephemeral and is_revoked. Adjust callers. * kbx/backend-sqlite.c: Alter table pubkey to add new columns. (run_select_statement): Add new column to all selects. (be_sqlite_search): Return the new flags. -- For existing test databases the new column can be added with: alter table pubkey add ephemeral integer not null default 0; alter table pubkey add revoked integer not null default 0; Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Add basic support for X.509.Werner Koch2020-09-105-67/+311
| | | | | | | | | | | | | | | * kbx/keybox-blob.c (x509_email_kludge): Rename to ... (_keybox_x509_email_kludge): this and make global. * kbx/backend.h: Include ksba.h. * kbx/backend-support.c (be_get_x509_serial): New. (be_get_x509_keygrip): New. * kbx/backend-sqlite.c (table_definitions): New table 'issuers'. (run_select_statement): Implements modes ISSUER, ISSUER_SN, SUBJECT. (store_into_userid): Add arg override_mbox. (store_into_issuer): New. (be_sqlite_store): Implement x509 part. Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Use D-lines instead of a separate thread.Werner Koch2020-09-102-4/+10
| | | | | | | | | | | | | | | * kbx/kbx-client-util.c (kbx_client_data_new): Add arg 'dlines'. * g10/call-keyboxd.c (open_context): Set DLINES to true. * sm/keydb.c (open_context): Ditto. -- This allows to compile time switch between the D-line and the fd-passing data communication between gpg/gpgsm and keyboxd. A quick test with about 3000 OpenPGP keys showed that D-lines are only 10% slower than the fd-passing based implementation. Given that the thread adds extra complexity we go for now with the D-line approach. Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Add options --openpgp and --x509 to SEARCH.Werner Koch2020-09-104-47/+112
| | | | | | | | | | | | | | | | | | | | | | | | * kbx/keyboxd.h (struct server_control_s): Replace the two request objects by just one. Add filter flags. * kbx/kbxserver.c (cmd_search): Add options --openpgp and --x509. (cmd_killkeyboxd): Do not return GPG_ERR_EOF. * kbx/frontend.c (kbxd_release_session_info): Adjust for the new request object. (kbxd_search, kbxd_store, kbxd_delete): Ditto. * kbx/backend-sqlite.c (struct be_sqlite_local_s): Add filter flags. (run_sql_prepare): Add optional arg 'extra'. Change callers. (run_sql_bind_ntext): New. (run_sql_bind_text): Just call run_sql_bind_ntext. (run_select_statement): Add ctrl arg. Implement the filter flags. * g10/call-keyboxd.c (keydb_search): Use the --openpgp option. -- As soon as we implement X.509 we need to have a way to return only openpgp or x.509 certificates. Gpg/gpgsm will then use the respective flag. Signed-off-by: Werner Koch <[email protected]>
* kbx: Change X.509 S/N search definition.Werner Koch2020-09-092-4/+5
| | | | | | | | | | | * kbx/keybox-search-desc.h (struct keydb_search_desc): Do not overload SNLLEN with a hex flag. Add SNHEX. * kbx/keybox-search.c (keybox_search): Adjust. * common/userids.c (classify_user_id): Adjust. * sm/keydb.c (keydb_search_desc_dump): Adjust. * g10/keydb.c (keydb_search_desc_dump): Adjust. Signed-off-by: Werner Koch <[email protected]>
* keyboxd: Restructure client access code.Werner Koch2020-09-023-2/+497
| | | | | | | | | | | | | | | | | | | | | | | | | | | * kbx/kbx-client-util.c: New. * kbx/kbx-client-util.h: New. * kbx/Makefile.am (client_sources): New. * g10/keydb.c (parse_keyblock_image): Rename to keydb_parse_keyblock and make global. * g10/call-keyboxd.c: Include kbx-client-util.h. (struct keyboxd_local_s): Remove struct datastream. Add field kcd. Remove per_session_init_done. (lock_datastream, unlock_datastream): Remove. (prepare_data_pipe, datastream_thread): Remove. (keydb_get_keyblock_do_parse): Remove. (gpg_keyboxd_deinit_session_data): Release the KCD object. (open_context): Use of kbx_client_data_new. (keydb_get_keyblock): Simplify. (keydb_search): Use kbx_client_data_cmd and _wait. -- The data specific part of the code has been moved from gpg to a new module in kbx/ so that it can also be used by gpgsm. The OpenPGP parsing while reading the data has been replaced by storing the data in memory and parse it later. That makes a nice interface and abstracts the fd-passing/D-lines handling away. Signed-off-by: Werner Koch <[email protected]>