mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
gpgsm: Use a cache to speed up parent certificate lookup.
* sm/gpgsm.h (COMPAT_NO_CHAIN_CACHE): New. (struct cert_cache_item_s, cert_cache_item_t): New. (struct server_control_s): Add parent_cert_cache. * sm/gpgsm.c (compatibility_flags): Add "no-chain-cache". (parent_cache_stats): New. (gpgsm_exit): Print the stats with --debug=memstat. (gpgsm_deinit_default_ctrl): Release the cache. * sm/certchain.c (gpgsm_walk_cert_chain): Cache the certificates. (do_validate_chain): Ditto. -- This gives another boost of 30% (from 6.5 to 4.0 seconds in the test environment with ~1000 certs). do_validate_chain actually brings us the speedup becuase the gpgsm_walk_cert_chain is not used during a key listing. For the latter we actually cache all certificates because that was easier. GnuPG-bug-id: 7308 Adjusted for 2.2: - Add gpgsm_deinit_default_ctrl - Remove ctrl arg from keydb_new
This commit is contained in:
parent
9543b3567b
commit
dcee2db36b
4 changed files with 125 additions and 8 deletions
18
sm/gpgsm.h
18
sm/gpgsm.h
|
@ -183,11 +183,23 @@ struct
|
|||
* policies: 1.3.6.1.4.1.7924.1.1:N:
|
||||
*/
|
||||
#define COMPAT_ALLOW_KA_TO_ENCR 1
|
||||
|
||||
/* Not actually a compatibiliy flag but useful to limit the
|
||||
* required memory for a validated key listing. */
|
||||
#define COMPAT_NO_CHAIN_CACHE 2
|
||||
|
||||
/* Forward declaration for an object defined in server.c */
|
||||
struct server_local_s;
|
||||
|
||||
/* On object used to keep a track of already known certificates. */
|
||||
struct cert_cache_item_s
|
||||
{
|
||||
struct cert_cache_item_s *next;
|
||||
unsigned char fpr[20]; /* The certificate's fingerprint. */
|
||||
ksba_cert_t result; /* The resulting certificate (ie. the issuer). */
|
||||
};
|
||||
typedef struct cert_cache_item_s *cert_cache_item_t;
|
||||
|
||||
|
||||
/* Session control object. This object is passed down to most
|
||||
functions. Note that the default values for it are set by
|
||||
gpgsm_init_default_ctrl(). */
|
||||
|
@ -236,6 +248,9 @@ struct server_control_s
|
|||
|
||||
/* The current time. Used as a helper in certchain.c. */
|
||||
ksba_isotime_t current_time;
|
||||
|
||||
/* The cache used to find the parent cert. */
|
||||
cert_cache_item_t parent_cert_cache;
|
||||
};
|
||||
|
||||
|
||||
|
@ -271,6 +286,7 @@ extern int gpgsm_errors_seen;
|
|||
|
||||
void gpgsm_exit (int rc);
|
||||
void gpgsm_init_default_ctrl (struct server_control_s *ctrl);
|
||||
void gpgsm_deinit_default_ctrl (ctrl_t ctrl);
|
||||
int gpgsm_parse_validation_model (const char *model);
|
||||
|
||||
/*-- server.c --*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue