2 * Copyright (C) 2003-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * The GnuTLS is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 /* This file contains the types and prototypes for the X.509
24 * certificate and CRL handling functions.
30 #include <gnutls/gnutls.h>
37 /* Some OIDs usually found in Distinguished names, or
38 * in Subject Directory Attribute extensions.
40 #define GNUTLS_OID_X520_COUNTRY_NAME "2.5.4.6"
41 #define GNUTLS_OID_X520_ORGANIZATION_NAME "2.5.4.10"
42 #define GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME "2.5.4.11"
43 #define GNUTLS_OID_X520_COMMON_NAME "2.5.4.3"
44 #define GNUTLS_OID_X520_LOCALITY_NAME "2.5.4.7"
45 #define GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME "2.5.4.8"
47 #define GNUTLS_OID_X520_INITIALS "2.5.4.43"
48 #define GNUTLS_OID_X520_GENERATION_QUALIFIER "2.5.4.44"
49 #define GNUTLS_OID_X520_SURNAME "2.5.4.4"
50 #define GNUTLS_OID_X520_GIVEN_NAME "2.5.4.42"
51 #define GNUTLS_OID_X520_TITLE "2.5.4.12"
52 #define GNUTLS_OID_X520_DN_QUALIFIER "2.5.4.46"
53 #define GNUTLS_OID_X520_PSEUDONYM "2.5.4.65"
54 #define GNUTLS_OID_X520_POSTALCODE "2.5.4.17"
55 #define GNUTLS_OID_X520_NAME "2.5.4.41"
57 #define GNUTLS_OID_LDAP_DC "0.9.2342.19200300.100.1.25"
58 #define GNUTLS_OID_LDAP_UID "0.9.2342.19200300.100.1.1"
60 /* The following should not be included in DN.
62 #define GNUTLS_OID_PKCS9_EMAIL "1.2.840.113549.1.9.1"
64 #define GNUTLS_OID_PKIX_DATE_OF_BIRTH "1.3.6.1.5.5.7.9.1"
65 #define GNUTLS_OID_PKIX_PLACE_OF_BIRTH "1.3.6.1.5.5.7.9.2"
66 #define GNUTLS_OID_PKIX_GENDER "1.3.6.1.5.5.7.9.3"
67 #define GNUTLS_OID_PKIX_COUNTRY_OF_CITIZENSHIP "1.3.6.1.5.5.7.9.4"
68 #define GNUTLS_OID_PKIX_COUNTRY_OF_RESIDENCE "1.3.6.1.5.5.7.9.5"
70 /* Key purpose Object Identifiers.
72 #define GNUTLS_KP_TLS_WWW_SERVER "1.3.6.1.5.5.7.3.1"
73 #define GNUTLS_KP_TLS_WWW_CLIENT "1.3.6.1.5.5.7.3.2"
74 #define GNUTLS_KP_CODE_SIGNING "1.3.6.1.5.5.7.3.3"
75 #define GNUTLS_KP_MS_SMART_CARD_LOGON "1.3.6.1.4.1.311.20.2.2"
76 #define GNUTLS_KP_EMAIL_PROTECTION "1.3.6.1.5.5.7.3.4"
77 #define GNUTLS_KP_TIME_STAMPING "1.3.6.1.5.5.7.3.8"
78 #define GNUTLS_KP_OCSP_SIGNING "1.3.6.1.5.5.7.3.9"
79 #define GNUTLS_KP_IPSEC_IKE "1.3.6.1.5.5.7.3.17"
80 #define GNUTLS_KP_ANY "2.5.29.37.0"
82 #define GNUTLS_OID_AIA "1.3.6.1.5.5.7.1.1"
83 #define GNUTLS_OID_AD_OCSP "1.3.6.1.5.5.7.48.1"
84 #define GNUTLS_OID_AD_CAISSUERS "1.3.6.1.5.5.7.48.2"
86 #define GNUTLS_FSAN_SET 0
87 #define GNUTLS_FSAN_APPEND 1
89 /* Certificate handling functions.
93 * gnutls_certificate_import_flags:
94 * @GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED: Fail if the
95 * certificates in the buffer are more than the space allocated for
96 * certificates. The error code will be %GNUTLS_E_SHORT_MEMORY_BUFFER.
97 * @GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED: Fail if the certificates
98 * in the buffer are not ordered starting from subject to issuer.
99 * The error code will be %GNUTLS_E_CERTIFICATE_LIST_UNSORTED.
101 * Enumeration of different certificate import flags.
103 typedef enum gnutls_certificate_import_flags
105 GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED = 1,
106 GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED = 2
107 } gnutls_certificate_import_flags;
109 int gnutls_x509_crt_init (gnutls_x509_crt_t * cert);
110 void gnutls_x509_crt_deinit (gnutls_x509_crt_t cert);
111 int gnutls_x509_crt_import (gnutls_x509_crt_t cert,
112 const gnutls_datum_t * data,
113 gnutls_x509_crt_fmt_t format);
114 int gnutls_x509_crt_list_import2 (gnutls_x509_crt_t ** certs,
116 const gnutls_datum_t * data,
117 gnutls_x509_crt_fmt_t format, unsigned int flags);
118 int gnutls_x509_crt_list_import (gnutls_x509_crt_t * certs,
119 unsigned int *cert_max,
120 const gnutls_datum_t * data,
121 gnutls_x509_crt_fmt_t format,
123 int gnutls_x509_crt_export (gnutls_x509_crt_t cert,
124 gnutls_x509_crt_fmt_t format,
125 void *output_data, size_t * output_data_size);
126 int gnutls_x509_crt_export2 (gnutls_x509_crt_t cert,
127 gnutls_x509_crt_fmt_t format,
128 gnutls_datum_t* out);
129 int gnutls_x509_crt_get_private_key_usage_period (gnutls_x509_crt_t cert, time_t* activation, time_t* expiration,
130 unsigned int *critical);
132 int gnutls_x509_crt_get_issuer_dn (gnutls_x509_crt_t cert, char *buf,
134 int gnutls_x509_crt_get_issuer_dn2 (gnutls_x509_crt_t cert, gnutls_datum_t* dn);
135 int gnutls_x509_crt_get_issuer_dn_oid (gnutls_x509_crt_t cert, int indx,
136 void *oid, size_t * oid_size);
137 int gnutls_x509_crt_get_issuer_dn_by_oid (gnutls_x509_crt_t cert,
138 const char *oid, int indx,
139 unsigned int raw_flag,
140 void *buf, size_t * buf_size);
141 int gnutls_x509_crt_get_dn (gnutls_x509_crt_t cert, char *buf,
143 int gnutls_x509_crt_get_dn2 (gnutls_x509_crt_t cert, gnutls_datum_t* dn);
144 int gnutls_x509_crt_get_dn_oid (gnutls_x509_crt_t cert, int indx,
145 void *oid, size_t * oid_size);
146 int gnutls_x509_crt_get_dn_by_oid (gnutls_x509_crt_t cert,
147 const char *oid, int indx,
148 unsigned int raw_flag, void *buf,
150 int gnutls_x509_crt_check_hostname (gnutls_x509_crt_t cert,
151 const char *hostname);
153 int gnutls_x509_crt_get_signature_algorithm (gnutls_x509_crt_t cert);
154 int gnutls_x509_crt_get_signature (gnutls_x509_crt_t cert,
155 char *sig, size_t * sizeof_sig);
156 int gnutls_x509_crt_get_version (gnutls_x509_crt_t cert);
157 int gnutls_x509_crt_get_key_id (gnutls_x509_crt_t crt,
159 unsigned char *output_data,
160 size_t * output_data_size);
162 int gnutls_x509_crt_set_private_key_usage_period (gnutls_x509_crt_t crt,
165 int gnutls_x509_crt_set_authority_key_id (gnutls_x509_crt_t cert,
166 const void *id, size_t id_size);
167 int gnutls_x509_crt_get_authority_key_id (gnutls_x509_crt_t cert,
168 void *id, size_t * id_size,
169 unsigned int *critical);
170 int gnutls_x509_crt_get_authority_key_gn_serial (gnutls_x509_crt_t cert,
174 unsigned int *alt_type,
177 unsigned int *critical);
179 int gnutls_x509_crt_get_subject_key_id (gnutls_x509_crt_t cert,
180 void *ret, size_t * ret_size,
181 unsigned int *critical);
183 int gnutls_x509_crt_get_subject_unique_id (gnutls_x509_crt_t crt, char *buf,
186 int gnutls_x509_crt_get_issuer_unique_id (gnutls_x509_crt_t crt, char *buf,
189 void gnutls_x509_crt_set_pin_function (gnutls_x509_crt_t crt,
190 gnutls_pin_callback_t fn, void *userdata);
193 * gnutls_info_access_what_t:
194 * @GNUTLS_IA_ACCESSMETHOD_OID: Get accessMethod OID.
195 * @GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE: Get accessLocation name type.
196 * @GNUTLS_IA_URI: Get accessLocation URI value.
197 * @GNUTLS_IA_OCSP_URI: get accessLocation URI value for OCSP.
198 * @GNUTLS_IA_CAISSUERS_URI: get accessLocation URI value for caIssuers.
200 * Enumeration of types for the @what parameter of
201 * gnutls_x509_crt_get_authority_info_access().
203 typedef enum gnutls_info_access_what_t
205 GNUTLS_IA_ACCESSMETHOD_OID = 1,
206 GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE = 2,
207 /* use 100-108 for the generalName types, populate as needed */
209 /* quick-access variants that match both OID and name type. */
210 GNUTLS_IA_OCSP_URI = 10006,
211 GNUTLS_IA_CAISSUERS_URI = 10106
212 } gnutls_info_access_what_t;
214 int gnutls_x509_crt_get_authority_info_access (gnutls_x509_crt_t crt,
217 gnutls_datum_t * data,
218 unsigned int *critical);
220 #define GNUTLS_CRL_REASON_SUPERSEEDED GNUTLS_CRL_REASON_SUPERSEDED,
222 * gnutls_x509_crl_reason_flags_t:
223 * @GNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN: The privileges were withdrawn from the owner.
224 * @GNUTLS_CRL_REASON_CERTIFICATE_HOLD: The certificate is on hold.
225 * @GNUTLS_CRL_REASON_CESSATION_OF_OPERATION: The end-entity is no longer operating.
226 * @GNUTLS_CRL_REASON_SUPERSEDED: There is a newer certificate of the owner.
227 * @GNUTLS_CRL_REASON_AFFILIATION_CHANGED: The end-entity affiliation has changed.
228 * @GNUTLS_CRL_REASON_CA_COMPROMISE: The CA was compromised.
229 * @GNUTLS_CRL_REASON_KEY_COMPROMISE: The certificate's key was compromised.
230 * @GNUTLS_CRL_REASON_UNUSED: The key was never used.
231 * @GNUTLS_CRL_REASON_AA_COMPROMISE: AA compromised.
233 * Enumeration of types for the CRL revocation reasons.
235 typedef enum gnutls_x509_crl_reason_flags_t
237 GNUTLS_CRL_REASON_UNSPECIFIED=0,
238 GNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN=1,
239 GNUTLS_CRL_REASON_CERTIFICATE_HOLD=2,
240 GNUTLS_CRL_REASON_CESSATION_OF_OPERATION=4,
241 GNUTLS_CRL_REASON_SUPERSEDED=8,
242 GNUTLS_CRL_REASON_AFFILIATION_CHANGED=16,
243 GNUTLS_CRL_REASON_CA_COMPROMISE=32,
244 GNUTLS_CRL_REASON_KEY_COMPROMISE=64,
245 GNUTLS_CRL_REASON_UNUSED=128,
246 GNUTLS_CRL_REASON_AA_COMPROMISE=32768
247 } gnutls_x509_crl_reason_flags_t;
249 int gnutls_x509_crt_get_crl_dist_points (gnutls_x509_crt_t cert,
250 unsigned int seq, void *ret,
252 unsigned int *reason_flags,
253 unsigned int *critical);
254 int gnutls_x509_crt_set_crl_dist_points2 (gnutls_x509_crt_t crt,
255 gnutls_x509_subject_alt_name_t
256 type, const void *data,
257 unsigned int data_size,
258 unsigned int reason_flags);
259 int gnutls_x509_crt_set_crl_dist_points (gnutls_x509_crt_t crt,
260 gnutls_x509_subject_alt_name_t
261 type, const void *data_string,
262 unsigned int reason_flags);
263 int gnutls_x509_crt_cpy_crl_dist_points (gnutls_x509_crt_t dst,
264 gnutls_x509_crt_t src);
266 int gnutls_x509_crl_sign2 (gnutls_x509_crl_t crl,
267 gnutls_x509_crt_t issuer,
268 gnutls_x509_privkey_t issuer_key,
269 gnutls_digest_algorithm_t dig,
272 time_t gnutls_x509_crt_get_activation_time (gnutls_x509_crt_t cert);
273 time_t gnutls_x509_crt_get_expiration_time (gnutls_x509_crt_t cert);
274 int gnutls_x509_crt_get_serial (gnutls_x509_crt_t cert, void *result,
275 size_t * result_size);
277 int gnutls_x509_crt_get_pk_algorithm (gnutls_x509_crt_t cert,
279 int gnutls_x509_crt_get_pk_rsa_raw (gnutls_x509_crt_t crt,
280 gnutls_datum_t * m, gnutls_datum_t * e);
281 int gnutls_x509_crt_get_pk_dsa_raw (gnutls_x509_crt_t crt,
284 gnutls_datum_t * g, gnutls_datum_t * y);
286 int gnutls_x509_crt_get_subject_alt_name (gnutls_x509_crt_t cert,
287 unsigned int seq, void *san,
289 unsigned int *critical);
290 int gnutls_x509_crt_get_subject_alt_name2 (gnutls_x509_crt_t cert,
291 unsigned int seq, void *san,
293 unsigned int *san_type,
294 unsigned int *critical);
296 int gnutls_x509_crt_get_subject_alt_othername_oid (gnutls_x509_crt_t cert,
301 int gnutls_x509_crt_get_issuer_alt_name (gnutls_x509_crt_t cert,
302 unsigned int seq, void *ian,
304 unsigned int *critical);
305 int gnutls_x509_crt_get_issuer_alt_name2 (gnutls_x509_crt_t cert,
306 unsigned int seq, void *ian,
308 unsigned int *ian_type,
309 unsigned int *critical);
311 int gnutls_x509_crt_get_issuer_alt_othername_oid (gnutls_x509_crt_t cert,
316 int gnutls_x509_crt_get_ca_status (gnutls_x509_crt_t cert,
317 unsigned int *critical);
318 int gnutls_x509_crt_get_basic_constraints (gnutls_x509_crt_t cert,
319 unsigned int *critical,
320 unsigned int *ca, int *pathlen);
322 /* The key_usage flags are defined in gnutls.h. They are the
323 * GNUTLS_KEY_* definitions.
325 int gnutls_x509_crt_get_key_usage (gnutls_x509_crt_t cert,
326 unsigned int *key_usage,
327 unsigned int *critical);
328 int gnutls_x509_crt_set_key_usage (gnutls_x509_crt_t crt,
330 int gnutls_x509_crt_set_authority_info_access (gnutls_x509_crt_t crt,
332 gnutls_datum_t * data);
334 int gnutls_x509_crt_get_proxy (gnutls_x509_crt_t cert,
335 unsigned int *critical,
337 char **policyLanguage,
338 char **policy, size_t * sizeof_policy);
340 #define GNUTLS_MAX_QUALIFIERS 8
343 * gnutls_x509_qualifier_t:
344 * @GNUTLS_X509_QUALIFIER_UNKNOWN: Unknown qualifier.
345 * @GNUTLS_X509_QUALIFIER_URI: A URL
346 * @GNUTLS_X509_QUALIFIER_NOICE: A text notice.
348 * Enumeration of types for the X.509 qualifiers, of the certificate policy extension.
350 typedef enum gnutls_x509_qualifier_t
352 GNUTLS_X509_QUALIFIER_UNKNOWN = 0, GNUTLS_X509_QUALIFIER_URI,
353 GNUTLS_X509_QUALIFIER_NOTICE
354 } gnutls_x509_qualifier_t;
356 typedef struct gnutls_x509_policy_st
359 unsigned int qualifiers;
361 gnutls_x509_qualifier_t type;
364 } qualifier[GNUTLS_MAX_QUALIFIERS];
365 } gnutls_x509_policy_st;
367 void gnutls_x509_policy_release(struct gnutls_x509_policy_st* policy);
368 int gnutls_x509_crt_get_policy (gnutls_x509_crt_t crt, int indx,
369 struct gnutls_x509_policy_st* policy,
370 unsigned int * critical);
371 int gnutls_x509_crt_set_policy (gnutls_x509_crt_t crt, struct gnutls_x509_policy_st* policy,
372 unsigned int critical);
374 int gnutls_x509_dn_oid_known (const char *oid);
376 #define GNUTLS_X509_DN_OID_RETURN_OID 1
377 const char* gnutls_x509_dn_oid_name (const char *oid, unsigned int flags);
379 /* Read extensions by OID. */
380 int gnutls_x509_crt_get_extension_oid (gnutls_x509_crt_t cert, int indx,
381 void *oid, size_t * oid_size);
382 int gnutls_x509_crt_get_extension_by_oid (gnutls_x509_crt_t cert,
383 const char *oid, int indx,
384 void *buf, size_t * buf_size,
385 unsigned int *critical);
387 /* Read extensions by sequence number. */
388 int gnutls_x509_crt_get_extension_info (gnutls_x509_crt_t cert, int indx,
389 void *oid, size_t * oid_size,
390 unsigned int *critical);
391 int gnutls_x509_crt_get_extension_data (gnutls_x509_crt_t cert, int indx,
392 void *data, size_t * sizeof_data);
394 int gnutls_x509_crt_set_extension_by_oid (gnutls_x509_crt_t crt,
398 unsigned int critical);
400 /* X.509 Certificate writing.
402 int gnutls_x509_crt_set_dn (gnutls_x509_crt_t crt, const char *dn, const char** err);
404 int gnutls_x509_crt_set_dn_by_oid (gnutls_x509_crt_t crt,
406 unsigned int raw_flag,
408 unsigned int sizeof_name);
409 int gnutls_x509_crt_set_issuer_dn_by_oid (gnutls_x509_crt_t crt,
411 unsigned int raw_flag,
413 unsigned int sizeof_name);
414 int gnutls_x509_crt_set_issuer_dn (gnutls_x509_crt_t crt, const char *dn, const char** err);
416 int gnutls_x509_crt_set_version (gnutls_x509_crt_t crt,
417 unsigned int version);
418 int gnutls_x509_crt_set_key (gnutls_x509_crt_t crt,
419 gnutls_x509_privkey_t key);
420 int gnutls_x509_crt_set_ca_status (gnutls_x509_crt_t crt, unsigned int ca);
421 int gnutls_x509_crt_set_basic_constraints (gnutls_x509_crt_t crt,
423 int pathLenConstraint);
424 int gnutls_x509_crt_set_subject_alternative_name (gnutls_x509_crt_t crt,
425 gnutls_x509_subject_alt_name_t
427 const char *data_string);
428 int gnutls_x509_crt_set_subject_alt_name (gnutls_x509_crt_t crt,
429 gnutls_x509_subject_alt_name_t
430 type, const void *data,
431 unsigned int data_size,
433 int gnutls_x509_crt_sign (gnutls_x509_crt_t crt, gnutls_x509_crt_t issuer,
434 gnutls_x509_privkey_t issuer_key);
435 int gnutls_x509_crt_sign2 (gnutls_x509_crt_t crt, gnutls_x509_crt_t issuer,
436 gnutls_x509_privkey_t issuer_key,
437 gnutls_digest_algorithm_t dig,
439 int gnutls_x509_crt_set_activation_time (gnutls_x509_crt_t cert,
441 int gnutls_x509_crt_set_expiration_time (gnutls_x509_crt_t cert,
443 int gnutls_x509_crt_set_serial (gnutls_x509_crt_t cert, const void *serial,
446 int gnutls_x509_crt_set_subject_key_id (gnutls_x509_crt_t cert,
447 const void *id, size_t id_size);
449 int gnutls_x509_crt_set_proxy_dn (gnutls_x509_crt_t crt,
450 gnutls_x509_crt_t eecrt,
451 unsigned int raw_flag,
453 unsigned int sizeof_name);
454 int gnutls_x509_crt_set_proxy (gnutls_x509_crt_t crt,
455 int pathLenConstraint,
456 const char *policyLanguage,
457 const char *policy, size_t sizeof_policy);
459 int gnutls_x509_crt_print (gnutls_x509_crt_t cert,
460 gnutls_certificate_print_formats_t format,
461 gnutls_datum_t * out);
462 int gnutls_x509_crl_print (gnutls_x509_crl_t crl,
463 gnutls_certificate_print_formats_t format,
464 gnutls_datum_t * out);
466 /* Access to internal Certificate fields.
468 int gnutls_x509_crt_get_raw_issuer_dn (gnutls_x509_crt_t cert,
469 gnutls_datum_t * start);
470 int gnutls_x509_crt_get_raw_dn (gnutls_x509_crt_t cert,
471 gnutls_datum_t * start);
475 int gnutls_x509_rdn_get (const gnutls_datum_t * idn,
476 char *buf, size_t * sizeof_buf);
477 int gnutls_x509_rdn_get_oid (const gnutls_datum_t * idn,
478 int indx, void *buf, size_t * sizeof_buf);
480 int gnutls_x509_rdn_get_by_oid (const gnutls_datum_t * idn,
481 const char *oid, int indx,
482 unsigned int raw_flag, void *buf,
483 size_t * sizeof_buf);
485 typedef void *gnutls_x509_dn_t;
487 typedef struct gnutls_x509_ava_st
490 gnutls_datum_t value;
491 unsigned long value_tag;
492 } gnutls_x509_ava_st;
494 int gnutls_x509_crt_get_subject (gnutls_x509_crt_t cert,
495 gnutls_x509_dn_t * dn);
496 int gnutls_x509_crt_get_issuer (gnutls_x509_crt_t cert,
497 gnutls_x509_dn_t * dn);
498 int gnutls_x509_dn_get_rdn_ava (gnutls_x509_dn_t dn, int irdn,
499 int iava, gnutls_x509_ava_st * ava);
501 int gnutls_x509_dn_init (gnutls_x509_dn_t * dn);
503 int gnutls_x509_dn_import (gnutls_x509_dn_t dn,
504 const gnutls_datum_t * data);
506 int gnutls_x509_dn_export (gnutls_x509_dn_t dn,
507 gnutls_x509_crt_fmt_t format, void *output_data,
508 size_t * output_data_size);
509 int gnutls_x509_dn_export2 (gnutls_x509_dn_t dn,
510 gnutls_x509_crt_fmt_t format,
511 gnutls_datum_t * out);
513 void gnutls_x509_dn_deinit (gnutls_x509_dn_t dn);
516 /* CRL handling functions.
518 int gnutls_x509_crl_init (gnutls_x509_crl_t * crl);
519 void gnutls_x509_crl_deinit (gnutls_x509_crl_t crl);
521 int gnutls_x509_crl_import (gnutls_x509_crl_t crl,
522 const gnutls_datum_t * data,
523 gnutls_x509_crt_fmt_t format);
524 int gnutls_x509_crl_export (gnutls_x509_crl_t crl,
525 gnutls_x509_crt_fmt_t format,
526 void *output_data, size_t * output_data_size);
527 int gnutls_x509_crl_export2 (gnutls_x509_crl_t crl,
528 gnutls_x509_crt_fmt_t format,
529 gnutls_datum_t *out);
532 gnutls_x509_crl_get_raw_issuer_dn (gnutls_x509_crl_t crl,
533 gnutls_datum_t * dn);
535 int gnutls_x509_crl_get_issuer_dn (gnutls_x509_crl_t crl,
536 char *buf, size_t * sizeof_buf);
537 int gnutls_x509_crl_get_issuer_dn2 (gnutls_x509_crl_t crl, gnutls_datum_t* dn);
538 int gnutls_x509_crl_get_issuer_dn_by_oid (gnutls_x509_crl_t crl,
539 const char *oid, int indx,
540 unsigned int raw_flag,
541 void *buf, size_t * sizeof_buf);
542 int gnutls_x509_crl_get_dn_oid (gnutls_x509_crl_t crl, int indx,
543 void *oid, size_t * sizeof_oid);
545 int gnutls_x509_crl_get_signature_algorithm (gnutls_x509_crl_t crl);
546 int gnutls_x509_crl_get_signature (gnutls_x509_crl_t crl,
547 char *sig, size_t * sizeof_sig);
548 int gnutls_x509_crl_get_version (gnutls_x509_crl_t crl);
550 time_t gnutls_x509_crl_get_this_update (gnutls_x509_crl_t crl);
551 time_t gnutls_x509_crl_get_next_update (gnutls_x509_crl_t crl);
553 int gnutls_x509_crl_get_crt_count (gnutls_x509_crl_t crl);
554 int gnutls_x509_crl_get_crt_serial (gnutls_x509_crl_t crl, int indx,
555 unsigned char *serial,
556 size_t * serial_size, time_t * t);
557 #define gnutls_x509_crl_get_certificate_count gnutls_x509_crl_get_crt_count
558 #define gnutls_x509_crl_get_certificate gnutls_x509_crl_get_crt_serial
560 int gnutls_x509_crl_check_issuer (gnutls_x509_crl_t crl,
561 gnutls_x509_crt_t issuer);
563 int gnutls_x509_crl_list_import2 (gnutls_x509_crl_t ** crls,
565 const gnutls_datum_t * data,
566 gnutls_x509_crt_fmt_t format, unsigned int flags);
568 int gnutls_x509_crl_list_import (gnutls_x509_crl_t * crls,
569 unsigned int *crl_max,
570 const gnutls_datum_t * data,
571 gnutls_x509_crt_fmt_t format,
575 int gnutls_x509_crl_set_version (gnutls_x509_crl_t crl,
576 unsigned int version);
577 int gnutls_x509_crl_set_this_update (gnutls_x509_crl_t crl,
579 int gnutls_x509_crl_set_next_update (gnutls_x509_crl_t crl,
581 int gnutls_x509_crl_set_crt_serial (gnutls_x509_crl_t crl,
584 time_t revocation_time);
585 int gnutls_x509_crl_set_crt (gnutls_x509_crl_t crl,
586 gnutls_x509_crt_t crt, time_t revocation_time);
588 int gnutls_x509_crl_get_authority_key_id (gnutls_x509_crl_t crl, void *id,
590 unsigned int *critical);
591 int gnutls_x509_crl_get_authority_key_gn_serial (gnutls_x509_crl_t crl,
595 unsigned int *alt_type,
598 unsigned int *critical);
600 int gnutls_x509_crl_get_number (gnutls_x509_crl_t crl, void *ret,
601 size_t * ret_size, unsigned int *critical);
603 int gnutls_x509_crl_get_extension_oid (gnutls_x509_crl_t crl, int indx,
604 void *oid, size_t * sizeof_oid);
606 int gnutls_x509_crl_get_extension_info (gnutls_x509_crl_t crl, int indx,
607 void *oid, size_t * sizeof_oid,
608 unsigned int *critical);
610 int gnutls_x509_crl_get_extension_data (gnutls_x509_crl_t crl, int indx,
611 void *data, size_t * sizeof_data);
613 int gnutls_x509_crl_set_authority_key_id (gnutls_x509_crl_t crl,
614 const void *id, size_t id_size);
616 int gnutls_x509_crl_set_number (gnutls_x509_crl_t crl,
617 const void *nr, size_t nr_size);
620 /* PKCS7 structures handling
622 struct gnutls_pkcs7_int;
623 typedef struct gnutls_pkcs7_int *gnutls_pkcs7_t;
625 int gnutls_pkcs7_init (gnutls_pkcs7_t * pkcs7);
626 void gnutls_pkcs7_deinit (gnutls_pkcs7_t pkcs7);
627 int gnutls_pkcs7_import (gnutls_pkcs7_t pkcs7,
628 const gnutls_datum_t * data,
629 gnutls_x509_crt_fmt_t format);
630 int gnutls_pkcs7_export (gnutls_pkcs7_t pkcs7,
631 gnutls_x509_crt_fmt_t format,
632 void *output_data, size_t * output_data_size);
633 int gnutls_pkcs7_export2 (gnutls_pkcs7_t pkcs7,
634 gnutls_x509_crt_fmt_t format,
635 gnutls_datum_t *out);
637 int gnutls_pkcs7_get_crt_count (gnutls_pkcs7_t pkcs7);
638 int gnutls_pkcs7_get_crt_raw (gnutls_pkcs7_t pkcs7, int indx,
639 void *certificate, size_t * certificate_size);
641 int gnutls_pkcs7_set_crt_raw (gnutls_pkcs7_t pkcs7,
642 const gnutls_datum_t * crt);
643 int gnutls_pkcs7_set_crt (gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt);
644 int gnutls_pkcs7_delete_crt (gnutls_pkcs7_t pkcs7, int indx);
646 int gnutls_pkcs7_get_crl_raw (gnutls_pkcs7_t pkcs7,
647 int indx, void *crl, size_t * crl_size);
648 int gnutls_pkcs7_get_crl_count (gnutls_pkcs7_t pkcs7);
650 int gnutls_pkcs7_set_crl_raw (gnutls_pkcs7_t pkcs7,
651 const gnutls_datum_t * crl);
652 int gnutls_pkcs7_set_crl (gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl);
653 int gnutls_pkcs7_delete_crl (gnutls_pkcs7_t pkcs7, int indx);
655 /* X.509 Certificate verification functions.
659 * gnutls_certificate_verify_flags:
660 * @GNUTLS_VERIFY_DISABLE_CA_SIGN: If set a signer does not have to be
661 * a certificate authority. This flag should normaly be disabled,
662 * unless you know what this means.
663 * @GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS: If set a signer in the trusted
664 * list is never checked for expiration or activation.
665 * @GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT: Allow trusted CA certificates
666 * with version 1. This is safer than %GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT,
667 * and should be used instead. That way only signers in your trusted list
668 * will be allowed to have certificates of version 1. This is the default.
669 * @GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT: Do not allow trusted CA
670 * certificates that have version 1. This option is to be used
671 * to deprecate all certificates of version 1.
672 * @GNUTLS_VERIFY_DO_NOT_ALLOW_SAME: If a certificate is not signed by
673 * anyone trusted but exists in the trusted CA list do not treat it
675 * @GNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN: A certificate chain is tolerated
676 * if unsorted (the case with many TLS servers out there). This is the
677 * default since GnuTLS 3.1.4.
678 * @GNUTLS_VERIFY_DO_NOT_ALLOW_UNSORTED_CHAIN: Do not tolerate an unsorted
680 * @GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT: Allow CA certificates that
681 * have version 1 (both root and intermediate). This might be
682 * dangerous since those haven't the basicConstraints
683 * extension. Must be used in combination with
684 * %GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT.
685 * @GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2: Allow certificates to be signed
686 * using the broken MD2 algorithm.
687 * @GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5: Allow certificates to be signed
688 * using the broken MD5 algorithm.
689 * @GNUTLS_VERIFY_DISABLE_TIME_CHECKS: Disable checking of activation
690 * and expiration validity periods of certificate chains. Don't set
691 * this unless you understand the security implications.
692 * @GNUTLS_VERIFY_DISABLE_CRL_CHECKS: Disable checking for validity
693 * using certificate revocation lists or the available OCSP data.
695 * Enumeration of different certificate verify flags.
697 typedef enum gnutls_certificate_verify_flags
699 GNUTLS_VERIFY_DISABLE_CA_SIGN = 1<<0,
700 GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT = 1<<1,
701 GNUTLS_VERIFY_DO_NOT_ALLOW_SAME = 1<<2,
702 GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT = 1<<3,
703 GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2 = 1<<4,
704 GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5 = 1<<5,
705 GNUTLS_VERIFY_DISABLE_TIME_CHECKS = 1<<6,
706 GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS = 1<<7,
707 GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT = 1<<8,
708 GNUTLS_VERIFY_DISABLE_CRL_CHECKS = 1<<9,
709 GNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN = 1<<10,
710 GNUTLS_VERIFY_DO_NOT_ALLOW_UNSORTED_CHAIN = 1<<11,
711 } gnutls_certificate_verify_flags;
713 int gnutls_x509_crt_check_issuer (gnutls_x509_crt_t cert,
714 gnutls_x509_crt_t issuer);
716 int gnutls_x509_crt_list_verify (const gnutls_x509_crt_t * cert_list,
717 int cert_list_length,
718 const gnutls_x509_crt_t * CA_list,
720 const gnutls_x509_crl_t * CRL_list,
722 unsigned int flags, unsigned int *verify);
724 int gnutls_x509_crt_verify (gnutls_x509_crt_t cert,
725 const gnutls_x509_crt_t * CA_list,
726 int CA_list_length, unsigned int flags,
727 unsigned int *verify);
728 int gnutls_x509_crl_verify (gnutls_x509_crl_t crl,
729 const gnutls_x509_crt_t * CA_list,
730 int CA_list_length, unsigned int flags,
731 unsigned int *verify);
733 int gnutls_x509_crt_check_revocation (gnutls_x509_crt_t cert,
734 const gnutls_x509_crl_t *
735 crl_list, int crl_list_length);
737 int gnutls_x509_crt_get_fingerprint (gnutls_x509_crt_t cert,
738 gnutls_digest_algorithm_t algo,
739 void *buf, size_t * buf_size);
741 int gnutls_x509_crt_get_key_purpose_oid (gnutls_x509_crt_t cert,
744 unsigned int *critical);
745 int gnutls_x509_crt_set_key_purpose_oid (gnutls_x509_crt_t cert,
747 unsigned int critical);
749 /* Private key handling.
752 /* Flags for the gnutls_x509_privkey_export_pkcs8() function.
755 #define GNUTLS_PKCS8_PLAIN GNUTLS_PKCS_PLAIN
756 #define GNUTLS_PKCS8_USE_PKCS12_3DES GNUTLS_PKCS_USE_PKCS12_3DES
757 #define GNUTLS_PKCS8_USE_PKCS12_ARCFOUR GNUTLS_PKCS_USE_PKCS12_ARCFOUR
758 #define GNUTLS_PKCS8_USE_PKCS12_RC2_40 GNUTLS_PKCS_USE_PKCS12_RC2_40
761 * gnutls_pkcs_encrypt_flags_t:
762 * @GNUTLS_PKCS_PLAIN: Unencrypted private key.
763 * @GNUTLS_PKCS_NULL_PASSWORD: Some schemas distinguish between an empty and a NULL password.
764 * @GNUTLS_PKCS_USE_PKCS12_3DES: PKCS-12 3DES.
765 * @GNUTLS_PKCS_USE_PKCS12_ARCFOUR: PKCS-12 ARCFOUR.
766 * @GNUTLS_PKCS_USE_PKCS12_RC2_40: PKCS-12 RC2-40.
767 * @GNUTLS_PKCS_USE_PBES2_3DES: PBES2 3DES.
768 * @GNUTLS_PKCS_USE_PBES2_AES_128: PBES2 AES-128.
769 * @GNUTLS_PKCS_USE_PBES2_AES_192: PBES2 AES-192.
770 * @GNUTLS_PKCS_USE_PBES2_AES_256: PBES2 AES-256.
772 * Enumeration of different PKCS encryption flags.
774 typedef enum gnutls_pkcs_encrypt_flags_t
776 GNUTLS_PKCS_PLAIN = 1,
777 GNUTLS_PKCS_USE_PKCS12_3DES = 2,
778 GNUTLS_PKCS_USE_PKCS12_ARCFOUR = 4,
779 GNUTLS_PKCS_USE_PKCS12_RC2_40 = 8,
780 GNUTLS_PKCS_USE_PBES2_3DES = 16,
781 GNUTLS_PKCS_USE_PBES2_AES_128 = 32,
782 GNUTLS_PKCS_USE_PBES2_AES_192 = 64,
783 GNUTLS_PKCS_USE_PBES2_AES_256 = 128,
784 GNUTLS_PKCS_NULL_PASSWORD = 256
785 } gnutls_pkcs_encrypt_flags_t;
787 int gnutls_x509_privkey_init (gnutls_x509_privkey_t * key);
788 void gnutls_x509_privkey_deinit (gnutls_x509_privkey_t key);
789 gnutls_sec_param_t gnutls_x509_privkey_sec_param (gnutls_x509_privkey_t
791 int gnutls_x509_privkey_cpy (gnutls_x509_privkey_t dst,
792 gnutls_x509_privkey_t src);
793 int gnutls_x509_privkey_import (gnutls_x509_privkey_t key,
794 const gnutls_datum_t * data,
795 gnutls_x509_crt_fmt_t format);
796 int gnutls_x509_privkey_import_pkcs8 (gnutls_x509_privkey_t key,
797 const gnutls_datum_t * data,
798 gnutls_x509_crt_fmt_t format,
799 const char *password,
801 int gnutls_x509_privkey_import_openssl (gnutls_x509_privkey_t key,
802 const gnutls_datum_t *data,
803 const char* password);
805 int gnutls_x509_privkey_import2 (gnutls_x509_privkey_t key,
806 const gnutls_datum_t * data,
807 gnutls_x509_crt_fmt_t format,
808 const char* password, unsigned int flags);
810 int gnutls_x509_privkey_import_rsa_raw (gnutls_x509_privkey_t key,
811 const gnutls_datum_t * m,
812 const gnutls_datum_t * e,
813 const gnutls_datum_t * d,
814 const gnutls_datum_t * p,
815 const gnutls_datum_t * q,
816 const gnutls_datum_t * u);
817 int gnutls_x509_privkey_import_rsa_raw2 (gnutls_x509_privkey_t key,
818 const gnutls_datum_t * m,
819 const gnutls_datum_t * e,
820 const gnutls_datum_t * d,
821 const gnutls_datum_t * p,
822 const gnutls_datum_t * q,
823 const gnutls_datum_t * u,
824 const gnutls_datum_t * e1,
825 const gnutls_datum_t * e2);
826 int gnutls_x509_privkey_import_ecc_raw (gnutls_x509_privkey_t key,
827 gnutls_ecc_curve_t curve,
828 const gnutls_datum_t * x,
829 const gnutls_datum_t * y,
830 const gnutls_datum_t * k);
832 int gnutls_x509_privkey_fix (gnutls_x509_privkey_t key);
834 int gnutls_x509_privkey_export_dsa_raw (gnutls_x509_privkey_t key,
840 int gnutls_x509_privkey_import_dsa_raw (gnutls_x509_privkey_t key,
841 const gnutls_datum_t * p,
842 const gnutls_datum_t * q,
843 const gnutls_datum_t * g,
844 const gnutls_datum_t * y,
845 const gnutls_datum_t * x);
847 int gnutls_x509_privkey_get_pk_algorithm (gnutls_x509_privkey_t key);
848 int gnutls_x509_privkey_get_pk_algorithm2 (gnutls_x509_privkey_t key, unsigned int *bits);
849 int gnutls_x509_privkey_get_key_id (gnutls_x509_privkey_t key,
851 unsigned char *output_data,
852 size_t * output_data_size);
854 int gnutls_x509_privkey_generate (gnutls_x509_privkey_t key,
855 gnutls_pk_algorithm_t algo,
856 unsigned int bits, unsigned int flags);
857 int gnutls_x509_privkey_verify_params (gnutls_x509_privkey_t key);
859 int gnutls_x509_privkey_export (gnutls_x509_privkey_t key,
860 gnutls_x509_crt_fmt_t format,
862 size_t * output_data_size);
863 int gnutls_x509_privkey_export2 (gnutls_x509_privkey_t key,
864 gnutls_x509_crt_fmt_t format,
865 gnutls_datum_t * out);
866 int gnutls_x509_privkey_export_pkcs8 (gnutls_x509_privkey_t key,
867 gnutls_x509_crt_fmt_t format,
868 const char *password,
871 size_t * output_data_size);
872 int gnutls_x509_privkey_export2_pkcs8 (gnutls_x509_privkey_t key,
873 gnutls_x509_crt_fmt_t format,
874 const char *password,
876 gnutls_datum_t * out);
877 int gnutls_x509_privkey_export_rsa_raw2 (gnutls_x509_privkey_t key,
885 gnutls_datum_t * e2);
886 int gnutls_x509_privkey_export_rsa_raw (gnutls_x509_privkey_t key,
893 int gnutls_x509_privkey_export_ecc_raw (gnutls_x509_privkey_t key,
894 gnutls_ecc_curve_t *curve,
895 gnutls_datum_t * x, gnutls_datum_t * y,
897 /* Certificate request stuff.
900 int gnutls_x509_crq_sign2 (gnutls_x509_crq_t crq,
901 gnutls_x509_privkey_t key,
902 gnutls_digest_algorithm_t dig,
905 int gnutls_x509_crq_print (gnutls_x509_crq_t crq,
906 gnutls_certificate_print_formats_t format,
907 gnutls_datum_t * out);
909 int gnutls_x509_crq_verify (gnutls_x509_crq_t crq, unsigned int flags);
911 int gnutls_x509_crq_init (gnutls_x509_crq_t * crq);
912 void gnutls_x509_crq_deinit (gnutls_x509_crq_t crq);
913 int gnutls_x509_crq_import (gnutls_x509_crq_t crq,
914 const gnutls_datum_t * data,
915 gnutls_x509_crt_fmt_t format);
917 int gnutls_x509_crq_get_private_key_usage_period (gnutls_x509_crq_t cert, time_t* activation, time_t* expiration,
918 unsigned int *critical);
920 int gnutls_x509_crq_get_dn (gnutls_x509_crq_t crq, char *buf,
921 size_t * sizeof_buf);
922 int gnutls_x509_crq_get_dn2 (gnutls_x509_crq_t crq, gnutls_datum_t* dn);
923 int gnutls_x509_crq_get_dn_oid (gnutls_x509_crq_t crq, int indx,
924 void *oid, size_t * sizeof_oid);
925 int gnutls_x509_crq_get_dn_by_oid (gnutls_x509_crq_t crq,
926 const char *oid, int indx,
927 unsigned int raw_flag, void *buf,
928 size_t * sizeof_buf);
929 int gnutls_x509_crq_set_dn (gnutls_x509_crq_t crq, const char *dn, const char** err);
930 int gnutls_x509_crq_set_dn_by_oid (gnutls_x509_crq_t crq,
932 unsigned int raw_flag,
934 unsigned int sizeof_data);
935 int gnutls_x509_crq_set_version (gnutls_x509_crq_t crq,
936 unsigned int version);
937 int gnutls_x509_crq_get_version (gnutls_x509_crq_t crq);
938 int gnutls_x509_crq_set_key (gnutls_x509_crq_t crq,
939 gnutls_x509_privkey_t key);
941 int gnutls_x509_crq_set_challenge_password (gnutls_x509_crq_t crq,
943 int gnutls_x509_crq_get_challenge_password (gnutls_x509_crq_t crq,
945 size_t * sizeof_pass);
947 int gnutls_x509_crq_set_attribute_by_oid (gnutls_x509_crq_t crq,
948 const char *oid, void *buf,
950 int gnutls_x509_crq_get_attribute_by_oid (gnutls_x509_crq_t crq,
951 const char *oid, int indx,
952 void *buf, size_t * sizeof_buf);
954 int gnutls_x509_crq_export (gnutls_x509_crq_t crq,
955 gnutls_x509_crt_fmt_t format,
956 void *output_data, size_t * output_data_size);
957 int gnutls_x509_crq_export2 (gnutls_x509_crq_t crq,
958 gnutls_x509_crt_fmt_t format,
959 gnutls_datum_t * out);
961 int gnutls_x509_crt_set_crq (gnutls_x509_crt_t crt, gnutls_x509_crq_t crq);
962 int gnutls_x509_crt_set_crq_extensions (gnutls_x509_crt_t crt,
963 gnutls_x509_crq_t crq);
965 int gnutls_x509_crq_set_private_key_usage_period (gnutls_x509_crq_t crq,
968 int gnutls_x509_crq_set_key_rsa_raw (gnutls_x509_crq_t crq,
969 const gnutls_datum_t * m,
970 const gnutls_datum_t * e);
971 int gnutls_x509_crq_set_subject_alt_name (gnutls_x509_crq_t crq,
972 gnutls_x509_subject_alt_name_t nt,
974 unsigned int data_size,
977 int gnutls_x509_crq_set_key_usage (gnutls_x509_crq_t crq,
979 int gnutls_x509_crq_set_basic_constraints (gnutls_x509_crq_t crq,
981 int pathLenConstraint);
982 int gnutls_x509_crq_set_key_purpose_oid (gnutls_x509_crq_t crq,
984 unsigned int critical);
985 int gnutls_x509_crq_get_key_purpose_oid (gnutls_x509_crq_t crq, int indx,
986 void *oid, size_t * sizeof_oid,
987 unsigned int *critical);
989 int gnutls_x509_crq_get_extension_data (gnutls_x509_crq_t crq, int indx,
990 void *data, size_t * sizeof_data);
991 int gnutls_x509_crq_get_extension_info (gnutls_x509_crq_t crq, int indx,
992 void *oid, size_t * sizeof_oid,
993 unsigned int *critical);
994 int gnutls_x509_crq_get_attribute_data (gnutls_x509_crq_t crq, int indx,
995 void *data, size_t * sizeof_data);
996 int gnutls_x509_crq_get_attribute_info (gnutls_x509_crq_t crq, int indx,
997 void *oid, size_t * sizeof_oid);
998 int gnutls_x509_crq_get_pk_algorithm (gnutls_x509_crq_t crq,
1001 int gnutls_x509_crq_get_key_id (gnutls_x509_crq_t crq, unsigned int flags,
1002 unsigned char *output_data,
1003 size_t * output_data_size);
1004 int gnutls_x509_crq_get_key_rsa_raw (gnutls_x509_crq_t crq,
1006 gnutls_datum_t * e);
1008 int gnutls_x509_crq_get_key_usage (gnutls_x509_crq_t crq,
1009 unsigned int *key_usage,
1010 unsigned int *critical);
1011 int gnutls_x509_crq_get_basic_constraints (gnutls_x509_crq_t crq,
1012 unsigned int *critical,
1013 unsigned int *ca, int *pathlen);
1014 int gnutls_x509_crq_get_subject_alt_name (gnutls_x509_crq_t crq,
1015 unsigned int seq, void *ret,
1017 unsigned int *ret_type,
1018 unsigned int *critical);
1019 int gnutls_x509_crq_get_subject_alt_othername_oid (gnutls_x509_crq_t crq,
1024 int gnutls_x509_crq_get_extension_by_oid (gnutls_x509_crq_t crq,
1025 const char *oid, int indx,
1026 void *buf, size_t * sizeof_buf,
1027 unsigned int *critical);
1029 typedef struct gnutls_x509_trust_list_st *gnutls_x509_trust_list_t;
1032 gnutls_x509_trust_list_init (gnutls_x509_trust_list_t * list, unsigned int size);
1035 gnutls_x509_trust_list_deinit (gnutls_x509_trust_list_t list, unsigned int all);
1037 int gnutls_x509_trust_list_get_issuer(gnutls_x509_trust_list_t list,
1038 gnutls_x509_crt_t cert, gnutls_x509_crt_t* issuer, unsigned int flags);
1041 gnutls_x509_trust_list_add_cas (gnutls_x509_trust_list_t list,
1042 const gnutls_x509_crt_t * clist, int clist_size, unsigned int flags);
1043 int gnutls_x509_trust_list_remove_cas(gnutls_x509_trust_list_t list,
1044 const gnutls_x509_crt_t * clist,
1047 int gnutls_x509_trust_list_add_named_crt (gnutls_x509_trust_list_t list,
1048 gnutls_x509_crt_t cert, const void* name, size_t name_size, unsigned int flags);
1050 #define GNUTLS_TL_VERIFY_CRL 1
1052 gnutls_x509_trust_list_add_crls (gnutls_x509_trust_list_t list,
1053 const gnutls_x509_crl_t * crl_list, int crl_size, unsigned int flags,
1054 unsigned int verification_flags);
1056 typedef int gnutls_verify_output_function (
1057 gnutls_x509_crt_t cert,
1058 gnutls_x509_crt_t issuer, /* The issuer if verification failed
1059 * because of him. might be null.
1061 gnutls_x509_crl_t crl, /* The CRL that caused verification failure
1062 * if any. Might be null.
1064 unsigned int verification_output);
1066 int gnutls_x509_trust_list_verify_named_crt (
1067 gnutls_x509_trust_list_t list,
1068 gnutls_x509_crt_t cert,
1069 const void * name, size_t name_size,
1071 unsigned int *verify,
1072 gnutls_verify_output_function func);
1075 gnutls_x509_trust_list_verify_crt (
1076 gnutls_x509_trust_list_t list,
1077 gnutls_x509_crt_t *cert_list,
1078 unsigned int cert_list_size,
1080 unsigned int *verify,
1081 gnutls_verify_output_function func);
1083 /* trust list convenience functions */
1085 gnutls_x509_trust_list_add_trust_mem(gnutls_x509_trust_list_t list,
1086 const gnutls_datum_t * cas,
1087 const gnutls_datum_t * crls,
1088 gnutls_x509_crt_fmt_t type,
1089 unsigned int tl_flags,
1090 unsigned int tl_vflags);
1093 gnutls_x509_trust_list_add_trust_file(gnutls_x509_trust_list_t list,
1094 const char* ca_file,
1095 const char* crl_file,
1096 gnutls_x509_crt_fmt_t type,
1097 unsigned int tl_flags,
1098 unsigned int tl_vflags);
1101 gnutls_x509_trust_list_remove_trust_file(gnutls_x509_trust_list_t list,
1102 const char* ca_file,
1103 gnutls_x509_crt_fmt_t type);
1106 gnutls_x509_trust_list_remove_trust_mem(gnutls_x509_trust_list_t list,
1107 const gnutls_datum_t * cas,
1108 gnutls_x509_crt_fmt_t type);
1111 gnutls_x509_trust_list_add_system_trust(gnutls_x509_trust_list_t list,
1112 unsigned int tl_flags, unsigned int tl_vflags);
1117 #endif /* GNUTLS_X509_H */