2 Copyright (C) 2006-2021 Ben Kibbey <bjk@luxsci.net>
4 This file is part of pwmd.
6 Pwmd is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 Pwmd is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with Pwmd. If not, see <http://www.gnu.org/licenses/>.
22 #include <gpg-error.h>
24 #include <libxml/tree.h>
30 char **pubkey
; /* keyid's */
31 char *sigkey
; /* signing keyid */
32 void *doc
; /* AES-128 encrypted */
34 unsigned refcount
; /* for .plaintext */
36 unsigned char *crc
; /* Checksum of the data file. */
40 #define CACHE_FLAG_LOCKED 0x0001
44 char **grip
; /* Public keygrips. */
45 char *siggrip
; /* Signing keygrip. */
46 char *filename
; /* Associated filename. */
47 long timeout
; /* cache_timer_thread(). */
48 long reset
; /* To reset .timeout. */
49 int defer_clear
; /* Another thread wants to clear the cache
50 entry for this file. Prevent resetting the
51 timer until this flag is cleared. */
52 pthread_mutex_t
*mutex
; /* Data file mutex. */
53 struct cache_data_s
*data
;
58 gpg_error_t
cache_kill_scd ();
59 void cache_adjust_timeout ();
60 gpg_error_t
cache_set_timeout (const char *, long timeout
);
61 gpg_error_t
cache_iscached (const char *, int *defer
, int agent
, int sign
);
62 gpg_error_t
cache_clear (struct client_s
*, const char *, int agent
, int force
);
63 gpg_error_t
cache_add_file (const char *, struct cache_data_s
*, long timeout
);
65 gpg_error_t
cache_init ();
66 void cache_mutex_init ();
67 unsigned cache_file_count ();
68 gpg_error_t
cache_is_shadowed (const char *filename
);
69 struct cache_data_s
*cache_get_data (const char *, int *defer
);
70 gpg_error_t
cache_set_data (const char *, struct cache_data_s
*);
71 gpg_error_t
cache_lock_mutex (void *ctx
, const char *, long mutex_timeout
,
72 int add
, long timeout
);
73 gpg_error_t
cache_unlock_mutex (const char *, int remove
);
76 void cache_release_mutex ();
77 void cache_free_data_once (struct cache_data_s
*data
);
78 gpg_error_t
cache_defer_clear (const char *);
79 gpg_error_t
cache_encrypt (struct crypto_s
*);
80 gpg_error_t
cache_decrypt (struct crypto_s
*);
81 gpg_error_t
cache_clear_agent_keys (const char *, int decrypt
, int sign
);
82 gpg_error_t
cache_agent_command (const char *);
83 gpg_error_t
cache_plaintext_get (const char *filename
, xmlDocPtr
*plain
);
84 gpg_error_t
cache_plaintext_release (xmlDocPtr
*);
85 gpg_error_t
cache_plaintext_set (const char *filename
, xmlDocPtr doc
,