chiark / gitweb /
gpg agent lockup fix: Interrupt main loop when active_connections_value==0
[gnupg2.git] / dirmngr / certcache.h
1 /* certcache.h - Certificate caching
2  *      Copyright (C) 2004, 2008 g10 Code GmbH
3  *
4  * This file is part of DirMngr.
5  *
6  * DirMngr is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * DirMngr is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19  */
20
21 #ifndef CERTCACHE_H
22 #define CERTCACHE_H
23
24 /* First time initialization of the certificate cache.  */
25 void cert_cache_init (void);
26
27 /* Deinitialize the certificate cache.  */
28 void cert_cache_deinit (int full);
29
30 /* Print some statistics to the log file.  */
31 void cert_cache_print_stats (void);
32
33 /* Compute the fingerprint of the certificate CERT and put it into
34    the 20 bytes large buffer DIGEST.  Return address of this buffer.  */
35 unsigned char *cert_compute_fpr (ksba_cert_t cert, unsigned char *digest);
36
37 /* Put CERT into the certificate cache.  */
38 gpg_error_t cache_cert (ksba_cert_t cert);
39
40 /* Put CERT into the certificate cache and return the fingerprint. */
41 gpg_error_t cache_cert_silent (ksba_cert_t cert, void *fpr_buffer);
42
43 /* Return 0 if the certificate is a trusted certificate. Returns
44    GPG_ERR_NOT_TRUSTED if it is not trusted or other error codes in
45    case of systems errors. */
46 gpg_error_t is_trusted_cert (ksba_cert_t cert);
47
48
49 /* Return a certificate object for the given fingerprint.  FPR is
50    expected to be a 20 byte binary SHA-1 fingerprint.  If no matching
51    certificate is available in the cache NULL is returned.  The caller
52    must release a returned certificate.  */
53 ksba_cert_t get_cert_byfpr (const unsigned char *fpr);
54
55 /* Return a certificate object for the given fingerprint.  STRING is
56    expected to be a SHA-1 fingerprint in standard hex notation with or
57    without colons.  If no matching certificate is available in the
58    cache NULL is returned.  The caller must release a returned
59    certificate.  */
60 ksba_cert_t get_cert_byhexfpr (const char *string);
61
62 /* Return the certificate matching ISSUER_DN and SERIALNO.  */
63 ksba_cert_t get_cert_bysn (const char *issuer_dn, ksba_sexp_t serialno);
64
65 /* Return the certificate matching ISSUER_DN.  SEQ should initially be
66    set to 0 and bumped up to get the next issuer with that DN. */
67 ksba_cert_t get_cert_byissuer (const char *issuer_dn, unsigned int seq);
68
69 /* Return the certificate matching SUBJECT_DN.  SEQ should initially be
70    set to 0 and bumped up to get the next issuer with that DN. */
71 ksba_cert_t get_cert_bysubject (const char *subject_dn, unsigned int seq);
72
73 /* Given PATTERN, which is a string as used by GnuPG to specify a
74    certificate, return all matching certificates by calling the
75    supplied function RETFNC.  */
76 gpg_error_t get_certs_bypattern (const char *pattern,
77                                  gpg_error_t (*retfnc)(void*,ksba_cert_t),
78                                  void *retfnc_data);
79
80 /* Return the certificate matching ISSUER_DN and SERIALNO; if it is
81    not already in the cache, try to find it from other resources.  */
82 ksba_cert_t find_cert_bysn (ctrl_t ctrl,
83                             const char *issuer_dn, ksba_sexp_t serialno);
84
85
86 /* Return the certificate matching SUBJECT_DN and (if not NULL) KEYID. If
87    it is not already in the cache, try to find it from other
88    resources.  Note, that the external search does not work for user
89    certificates because the LDAP lookup is on the caCertificate
90    attribute. For our purposes this is just fine.  */
91 ksba_cert_t find_cert_bysubject (ctrl_t ctrl,
92                                  const char *subject_dn, ksba_sexp_t keyid);
93
94 /* Given the certificate CERT locate the issuer for this certificate
95    and return it at R_CERT.  Returns 0 on success or
96    GPG_ERR_NOT_FOUND.  */
97 gpg_error_t find_issuing_cert (ctrl_t ctrl,
98                                ksba_cert_t cert, ksba_cert_t *r_cert);
99
100
101
102
103 #endif /*CERTCACHE_H*/