blob: 0c302962cc586ac1a8179880e59a2f2e8399da51 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file x509.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker37ca75d2011-01-06 12:28:03 +00004 * \brief X.509 certificate and private key decoding
5 *
Paul Bakker407a0da2013-06-27 14:29:21 +02006 * Copyright (C) 2006-2013, Brainspark B.V.
Paul Bakkerb96f1542010-07-18 20:36:00 +00007 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
Paul Bakker84f12b72010-07-18 10:13:04 +00009 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
Paul Bakkerb96f1542010-07-18 20:36:00 +000010 *
Paul Bakker77b385e2009-07-28 17:23:11 +000011 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000012 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000013 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Paul Bakker5121ce52009-01-03 21:22:43 +000026 */
Paul Bakker40e46942009-01-03 21:51:57 +000027#ifndef POLARSSL_X509_H
28#define POLARSSL_X509_H
Paul Bakker5121ce52009-01-03 21:22:43 +000029
Paul Bakkered27a042013-04-18 22:46:23 +020030#include "config.h"
31
32#if defined(POLARSSL_X509_PARSE_C) || defined(POLARSSL_X509_WRITE_C)
Paul Bakkerefc30292011-11-10 14:43:23 +000033#include "asn1.h"
Paul Bakker314052f2011-08-15 09:07:52 +000034#include "rsa.h"
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +020035#include "ecp.h"
Paul Bakker314052f2011-08-15 09:07:52 +000036#include "dhm.h"
Paul Bakkerc70b9822013-04-07 22:00:46 +020037#include "md.h"
Paul Bakkered27a042013-04-18 22:46:23 +020038#include "pk.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000039
Paul Bakker37ca75d2011-01-06 12:28:03 +000040/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +000041 * \addtogroup x509_module
42 * \{
Paul Bakker13e2dfe2009-07-28 07:18:38 +000043 */
Paul Bakker37ca75d2011-01-06 12:28:03 +000044
Paul Bakker37ca75d2011-01-06 12:28:03 +000045/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +000046 * \name X509 Error codes
47 * \{
Paul Bakker13e2dfe2009-07-28 07:18:38 +000048 */
Paul Bakker9d781402011-05-09 16:17:09 +000049#define POLARSSL_ERR_X509_FEATURE_UNAVAILABLE -0x2080 /**< Unavailable feature, e.g. RSA hashing/encryption combination. */
50#define POLARSSL_ERR_X509_CERT_INVALID_PEM -0x2100 /**< The PEM-encoded certificate contains invalid elements, e.g. invalid character. */
51#define POLARSSL_ERR_X509_CERT_INVALID_FORMAT -0x2180 /**< The certificate format is invalid, e.g. different type expected. */
52#define POLARSSL_ERR_X509_CERT_INVALID_VERSION -0x2200 /**< The certificate version element is invalid. */
53#define POLARSSL_ERR_X509_CERT_INVALID_SERIAL -0x2280 /**< The serial tag or value is invalid. */
54#define POLARSSL_ERR_X509_CERT_INVALID_ALG -0x2300 /**< The algorithm tag or value is invalid. */
55#define POLARSSL_ERR_X509_CERT_INVALID_NAME -0x2380 /**< The name tag or value is invalid. */
56#define POLARSSL_ERR_X509_CERT_INVALID_DATE -0x2400 /**< The date tag or value is invalid. */
Manuel Pégourié-Gonnard5151b452013-08-23 12:03:28 +020057#define POLARSSL_ERR_X509_CERT_INVALID_PUBKEY -0x2480 /**< The pubkey tag or value is invalid (only RSA and EC are supported). */
Paul Bakker9d781402011-05-09 16:17:09 +000058#define POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE -0x2500 /**< The signature tag or value invalid. */
59#define POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS -0x2580 /**< The extension tag or value is invalid. */
60#define POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION -0x2600 /**< Certificate or CRL has an unsupported version number. */
61#define POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG -0x2680 /**< Signature algorithm (oid) is unsupported. */
Manuel Pégourié-Gonnard5a9b82e2013-07-01 16:57:44 +020062#define POLARSSL_ERR_X509_UNKNOWN_PK_ALG -0x2700 /**< Key algorithm is unsupported (only RSA and EC are supported). */
Paul Bakker9d781402011-05-09 16:17:09 +000063#define POLARSSL_ERR_X509_CERT_SIG_MISMATCH -0x2780 /**< Certificate signature algorithms do not match. (see \c ::x509_cert sig_oid) */
64#define POLARSSL_ERR_X509_CERT_VERIFY_FAILED -0x2800 /**< Certificate verification failed, e.g. CRL, CA or signature check failed. */
65#define POLARSSL_ERR_X509_KEY_INVALID_VERSION -0x2880 /**< Unsupported RSA key version */
66#define POLARSSL_ERR_X509_KEY_INVALID_FORMAT -0x2900 /**< Invalid RSA key tag or value. */
Paul Bakker6c0ceb32011-12-04 12:24:18 +000067#define POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT -0x2980 /**< Format not recognized as DER or PEM. */
Paul Bakker69e095c2011-12-10 21:55:01 +000068#define POLARSSL_ERR_X509_INVALID_INPUT -0x2A00 /**< Input invalid. */
69#define POLARSSL_ERR_X509_MALLOC_FAILED -0x2A80 /**< Allocation of memory failed. */
70#define POLARSSL_ERR_X509_FILE_IO_ERROR -0x2B00 /**< Read/write of file failed. */
Paul Bakker28144de2013-06-24 19:28:55 +020071#define POLARSSL_ERR_X509_PASSWORD_REQUIRED -0x2B80 /**< Private key password can't be empty. */
72#define POLARSSL_ERR_X509_PASSWORD_MISMATCH -0x2C00 /**< Given private key password does not allow for correct decryption. */
Manuel Pégourié-Gonnardf838eed2013-07-02 14:56:43 +020073#define POLARSSL_ERR_X509_UNKNOWN_NAMED_CURVE -0x2C80 /**< Elliptic curve is unsupported (only NIST curves are supported). */
Paul Bakker0f5f72e2011-01-18 14:58:55 +000074/* \} name */
Paul Bakker5121ce52009-01-03 21:22:43 +000075
Paul Bakker37ca75d2011-01-06 12:28:03 +000076/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +000077 * \name X509 Verify codes
78 * \{
Paul Bakker37ca75d2011-01-06 12:28:03 +000079 */
Paul Bakkercdf07e92011-01-30 17:05:13 +000080#define BADCERT_EXPIRED 0x01 /**< The certificate validity has expired. */
81#define BADCERT_REVOKED 0x02 /**< The certificate has been revoked (is on a CRL). */
82#define BADCERT_CN_MISMATCH 0x04 /**< The certificate Common Name (CN) does not match with the expected CN. */
83#define BADCERT_NOT_TRUSTED 0x08 /**< The certificate is not correctly signed by the trusted CA. */
84#define BADCRL_NOT_TRUSTED 0x10 /**< CRL is not correctly signed by the trusted CA. */
85#define BADCRL_EXPIRED 0x20 /**< CRL is expired. */
86#define BADCERT_MISSING 0x40 /**< Certificate was missing. */
87#define BADCERT_SKIP_VERIFY 0x80 /**< Certificate verification was skipped. */
Paul Bakker915275b2012-09-28 07:10:55 +000088#define BADCERT_OTHER 0x0100 /**< Other reason (can be used by verify callback) */
Paul Bakker0f5f72e2011-01-18 14:58:55 +000089/* \} name */
Paul Bakker0f5f72e2011-01-18 14:58:55 +000090/* \} addtogroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +000091
92/*
Paul Bakker74111d32011-01-15 16:57:55 +000093 * X.509 v3 Key Usage Extension flags
94 */
95#define KU_DIGITAL_SIGNATURE (0x80) /* bit 0 */
96#define KU_NON_REPUDIATION (0x40) /* bit 1 */
97#define KU_KEY_ENCIPHERMENT (0x20) /* bit 2 */
98#define KU_DATA_ENCIPHERMENT (0x10) /* bit 3 */
99#define KU_KEY_AGREEMENT (0x08) /* bit 4 */
100#define KU_KEY_CERT_SIGN (0x04) /* bit 5 */
101#define KU_CRL_SIGN (0x02) /* bit 6 */
102
103/*
Paul Bakker74111d32011-01-15 16:57:55 +0000104 * Netscape certificate types
105 * (http://www.mozilla.org/projects/security/pki/nss/tech-notes/tn3.html)
106 */
107
108#define NS_CERT_TYPE_SSL_CLIENT (0x80) /* bit 0 */
109#define NS_CERT_TYPE_SSL_SERVER (0x40) /* bit 1 */
110#define NS_CERT_TYPE_EMAIL (0x20) /* bit 2 */
111#define NS_CERT_TYPE_OBJECT_SIGNING (0x10) /* bit 3 */
112#define NS_CERT_TYPE_RESERVED (0x08) /* bit 4 */
113#define NS_CERT_TYPE_SSL_CA (0x04) /* bit 5 */
114#define NS_CERT_TYPE_EMAIL_CA (0x02) /* bit 6 */
115#define NS_CERT_TYPE_OBJECT_SIGNING_CA (0x01) /* bit 7 */
116
Paul Bakkerc70b9822013-04-07 22:00:46 +0200117/*
118 * X.509 extension types
119 */
Paul Bakker74111d32011-01-15 16:57:55 +0000120#define EXT_AUTHORITY_KEY_IDENTIFIER (1 << 0)
121#define EXT_SUBJECT_KEY_IDENTIFIER (1 << 1)
122#define EXT_KEY_USAGE (1 << 2)
123#define EXT_CERTIFICATE_POLICIES (1 << 3)
124#define EXT_POLICY_MAPPINGS (1 << 4)
125#define EXT_SUBJECT_ALT_NAME (1 << 5)
126#define EXT_ISSUER_ALT_NAME (1 << 6)
127#define EXT_SUBJECT_DIRECTORY_ATTRS (1 << 7)
128#define EXT_BASIC_CONSTRAINTS (1 << 8)
129#define EXT_NAME_CONSTRAINTS (1 << 9)
130#define EXT_POLICY_CONSTRAINTS (1 << 10)
131#define EXT_EXTENDED_KEY_USAGE (1 << 11)
132#define EXT_CRL_DISTRIBUTION_POINTS (1 << 12)
133#define EXT_INIHIBIT_ANYPOLICY (1 << 13)
134#define EXT_FRESHEST_CRL (1 << 14)
135
136#define EXT_NS_CERT_TYPE (1 << 16)
Paul Bakker5121ce52009-01-03 21:22:43 +0000137
Paul Bakker6c0ceb32011-12-04 12:24:18 +0000138/*
139 * Storage format identifiers
140 * Recognized formats: PEM and DER
141 */
142#define X509_FORMAT_DER 1
143#define X509_FORMAT_PEM 2
144
Paul Bakker407a0da2013-06-27 14:29:21 +0200145#ifdef __cplusplus
146extern "C" {
147#endif
148
Paul Bakkere5eae762013-08-26 12:05:14 +0200149/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000150 * \addtogroup x509_module
151 * \{ */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000152
153/**
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200154 * \name Structures for parsing X.509 certificates, CRLs and CSRs
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000155 * \{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000156 */
Paul Bakkere5eae762013-08-26 12:05:14 +0200157
158/**
Paul Bakker37ca75d2011-01-06 12:28:03 +0000159 * Type-length-value structure that allows for ASN1 using DER.
Paul Bakker5121ce52009-01-03 21:22:43 +0000160 */
Paul Bakkerefc30292011-11-10 14:43:23 +0000161typedef asn1_buf x509_buf;
Paul Bakker5121ce52009-01-03 21:22:43 +0000162
Paul Bakker37ca75d2011-01-06 12:28:03 +0000163/**
Paul Bakker74111d32011-01-15 16:57:55 +0000164 * Container for ASN1 bit strings.
165 */
Paul Bakkerefc30292011-11-10 14:43:23 +0000166typedef asn1_bitstring x509_bitstring;
Paul Bakker74111d32011-01-15 16:57:55 +0000167
168/**
Paul Bakkere5eae762013-08-26 12:05:14 +0200169 * Container for ASN1 named information objects.
Paul Bakker37ca75d2011-01-06 12:28:03 +0000170 * It allows for Relative Distinguished Names (e.g. cn=polarssl,ou=code,etc.).
171 */
Paul Bakkere5eae762013-08-26 12:05:14 +0200172typedef asn1_named_data x509_name;
Paul Bakker5121ce52009-01-03 21:22:43 +0000173
Paul Bakker74111d32011-01-15 16:57:55 +0000174/**
175 * Container for a sequence of ASN.1 items
176 */
Paul Bakkerefc30292011-11-10 14:43:23 +0000177typedef asn1_sequence x509_sequence;
Paul Bakker74111d32011-01-15 16:57:55 +0000178
Paul Bakker37ca75d2011-01-06 12:28:03 +0000179/** Container for date and time (precision in seconds). */
Paul Bakker5121ce52009-01-03 21:22:43 +0000180typedef struct _x509_time
181{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000182 int year, mon, day; /**< Date. */
183 int hour, min, sec; /**< Time. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000184}
185x509_time;
186
Paul Bakkere5eae762013-08-26 12:05:14 +0200187/**
Paul Bakker37ca75d2011-01-06 12:28:03 +0000188 * Container for an X.509 certificate. The certificate may be chained.
189 */
Paul Bakker5121ce52009-01-03 21:22:43 +0000190typedef struct _x509_cert
191{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000192 x509_buf raw; /**< The raw certificate data (DER). */
193 x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000194
Paul Bakker37ca75d2011-01-06 12:28:03 +0000195 int version; /**< The X.509 version. (0=v1, 1=v2, 2=v3) */
196 x509_buf serial; /**< Unique id for certificate issued by a specific CA. */
197 x509_buf sig_oid1; /**< Signature algorithm, e.g. sha1RSA */
Paul Bakker5121ce52009-01-03 21:22:43 +0000198
Paul Bakker37ca75d2011-01-06 12:28:03 +0000199 x509_buf issuer_raw; /**< The raw issuer data (DER). Used for quick comparison. */
200 x509_buf subject_raw; /**< The raw subject data (DER). Used for quick comparison. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000201
Paul Bakker37ca75d2011-01-06 12:28:03 +0000202 x509_name issuer; /**< The parsed issuer data (named information object). */
203 x509_name subject; /**< The parsed subject data (named information object). */
Paul Bakker5121ce52009-01-03 21:22:43 +0000204
Paul Bakker37ca75d2011-01-06 12:28:03 +0000205 x509_time valid_from; /**< Start time of certificate validity. */
206 x509_time valid_to; /**< End time of certificate validity. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000207
Manuel Pégourié-Gonnard674b2242013-07-10 14:32:58 +0200208 pk_context pk; /**< Container for the public key context. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000209
Paul Bakker37ca75d2011-01-06 12:28:03 +0000210 x509_buf issuer_id; /**< Optional X.509 v2/v3 issuer unique identifier. */
211 x509_buf subject_id; /**< Optional X.509 v2/v3 subject unique identifier. */
212 x509_buf v3_ext; /**< Optional X.509 v3 extensions. Only Basic Contraints are supported at this time. */
Paul Bakkera8cd2392012-02-11 16:09:32 +0000213 x509_sequence subject_alt_names; /**< Optional list of Subject Alternative Names (Only dNSName supported). */
Paul Bakker5121ce52009-01-03 21:22:43 +0000214
Paul Bakker74111d32011-01-15 16:57:55 +0000215 int ext_types; /**< Bit string containing detected and parsed extensions */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000216 int ca_istrue; /**< Optional Basic Constraint extension value: 1 if this certificate belongs to a CA, 0 otherwise. */
Paul Bakker915275b2012-09-28 07:10:55 +0000217 int max_pathlen; /**< Optional Basic Constraint extension value: The maximum path length to the root certificate. Path length is 1 higher than RFC 5280 'meaning', so 1+ */
Paul Bakker5121ce52009-01-03 21:22:43 +0000218
Paul Bakker74111d32011-01-15 16:57:55 +0000219 unsigned char key_usage; /**< Optional key usage extension value: See the values below */
220
221 x509_sequence ext_key_usage; /**< Optional list of extended key usage OIDs. */
222
223 unsigned char ns_cert_type; /**< Optional Netscape certificate type extension value: See the values below */
224
Paul Bakker37ca75d2011-01-06 12:28:03 +0000225 x509_buf sig_oid2; /**< Signature algorithm. Must match sig_oid1. */
226 x509_buf sig; /**< Signature: hash of the tbs part signed with the private key. */
Paul Bakkerc70b9822013-04-07 22:00:46 +0200227 md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. POLARSSL_MD_SHA256 */
228 pk_type_t sig_pk /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. POLARSSL_PK_RSA */;
Paul Bakker5121ce52009-01-03 21:22:43 +0000229
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200230 struct _x509_cert *next; /**< Next certificate in the CA-chain. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000231}
232x509_cert;
233
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200234/**
235 * Certificate revocation list entry.
Paul Bakker37ca75d2011-01-06 12:28:03 +0000236 * Contains the CA-specific serial numbers and revocation dates.
237 */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000238typedef struct _x509_crl_entry
239{
240 x509_buf raw;
241
242 x509_buf serial;
243
244 x509_time revocation_date;
245
246 x509_buf entry_ext;
247
248 struct _x509_crl_entry *next;
249}
250x509_crl_entry;
251
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200252/**
253 * Certificate revocation list structure.
Paul Bakker37ca75d2011-01-06 12:28:03 +0000254 * Every CRL may have multiple entries.
255 */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000256typedef struct _x509_crl
257{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000258 x509_buf raw; /**< The raw certificate data (DER). */
259 x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000260
261 int version;
262 x509_buf sig_oid1;
263
Paul Bakker37ca75d2011-01-06 12:28:03 +0000264 x509_buf issuer_raw; /**< The raw issuer data (DER). */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000265
Paul Bakker37ca75d2011-01-06 12:28:03 +0000266 x509_name issuer; /**< The parsed issuer data (named information object). */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000267
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200268 x509_time this_update;
Paul Bakkerd98030e2009-05-02 15:13:40 +0000269 x509_time next_update;
270
Paul Bakker37ca75d2011-01-06 12:28:03 +0000271 x509_crl_entry entry; /**< The CRL entries containing the certificate revocation times for this CA. */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000272
273 x509_buf crl_ext;
274
275 x509_buf sig_oid2;
276 x509_buf sig;
Paul Bakkerc70b9822013-04-07 22:00:46 +0200277 md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. POLARSSL_MD_SHA256 */
278 pk_type_t sig_pk /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. POLARSSL_PK_RSA */;
Paul Bakkerd98030e2009-05-02 15:13:40 +0000279
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200280 struct _x509_crl *next;
Paul Bakkerd98030e2009-05-02 15:13:40 +0000281}
282x509_crl;
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200283
284/**
285 * Certificate Signing Request (CSR) structure.
286 */
287typedef struct _x509_csr
288{
289 x509_buf raw; /**< The raw CSR data (DER). */
290 x509_buf cri; /**< The raw CertificateRequestInfo body (DER). */
291
292 int version;
293
294 x509_buf subject_raw; /**< The raw subject data (DER). */
295 x509_name subject; /**< The parsed subject data (named information object). */
296
297 pk_context pk; /**< Container for the public key context. */
298
299 x509_buf sig_oid;
300 x509_buf sig;
301 md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. POLARSSL_MD_SHA256 */
302 pk_type_t sig_pk /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. POLARSSL_PK_RSA */;
303}
304x509_csr;
305/** \} name Structures for parsing X.509 certificates, CRLs and CSRs */
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000306/** \} addtogroup x509_module */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000307
Paul Bakker37ca75d2011-01-06 12:28:03 +0000308/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000309 * \name Functions to read in DHM parameters, a certificate, CRL or private RSA key
310 * \{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000311 */
312
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000313/** \ingroup x509_module */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000314/**
Paul Bakker89ecb2d2013-06-24 19:06:15 +0200315 * \brief Parse a single DER formatted certificate and add it
316 * to the chained list.
317 *
318 * \param chain points to the start of the chain
319 * \param buf buffer holding the certificate DER data
320 * \param buflen size of the buffer
321 *
322 * \return 0 if successful, or a specific X509 or PEM error code
323 */
324int x509parse_crt_der( x509_cert *chain, const unsigned char *buf, size_t buflen );
325
326/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000327 * \brief Parse one or more certificates and add them
Paul Bakker69e095c2011-12-10 21:55:01 +0000328 * to the chained list. Parses permissively. If some
329 * certificates can be parsed, the result is the number
330 * of failed certificates it encountered. If none complete
331 * correctly, the first error is returned.
Paul Bakker5121ce52009-01-03 21:22:43 +0000332 *
333 * \param chain points to the start of the chain
334 * \param buf buffer holding the certificate data
335 * \param buflen size of the buffer
336 *
Paul Bakker69e095c2011-12-10 21:55:01 +0000337 * \return 0 if all certificates parsed successfully, a positive number
338 * if partly successful or a specific X509 or PEM error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000339 */
Paul Bakker69e095c2011-12-10 21:55:01 +0000340int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen );
Paul Bakker5121ce52009-01-03 21:22:43 +0000341
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000342/** \ingroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000343/**
344 * \brief Load one or more certificates and add them
Paul Bakker69e095c2011-12-10 21:55:01 +0000345 * to the chained list. Parses permissively. If some
346 * certificates can be parsed, the result is the number
347 * of failed certificates it encountered. If none complete
348 * correctly, the first error is returned.
Paul Bakker5121ce52009-01-03 21:22:43 +0000349 *
350 * \param chain points to the start of the chain
351 * \param path filename to read the certificates from
352 *
Paul Bakker69e095c2011-12-10 21:55:01 +0000353 * \return 0 if all certificates parsed successfully, a positive number
354 * if partly successful or a specific X509 or PEM error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000355 */
Paul Bakker69e095c2011-12-10 21:55:01 +0000356int x509parse_crtfile( x509_cert *chain, const char *path );
Paul Bakker5121ce52009-01-03 21:22:43 +0000357
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000358/** \ingroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000359/**
Paul Bakker8d914582012-06-04 12:46:42 +0000360 * \brief Load one or more certificate files from a path and add them
361 * to the chained list. Parses permissively. If some
362 * certificates can be parsed, the result is the number
363 * of failed certificates it encountered. If none complete
364 * correctly, the first error is returned.
365 *
366 * \param chain points to the start of the chain
367 * \param path directory / folder to read the certificate files from
368 *
369 * \return 0 if all certificates parsed successfully, a positive number
370 * if partly successful or a specific X509 or PEM error code
371 */
372int x509parse_crtpath( x509_cert *chain, const char *path );
373
374/** \ingroup x509_module */
375/**
Paul Bakkerd98030e2009-05-02 15:13:40 +0000376 * \brief Parse one or more CRLs and add them
377 * to the chained list
378 *
379 * \param chain points to the start of the chain
380 * \param buf buffer holding the CRL data
381 * \param buflen size of the buffer
382 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000383 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakkerd98030e2009-05-02 15:13:40 +0000384 */
Paul Bakker23986e52011-04-24 08:57:21 +0000385int x509parse_crl( x509_crl *chain, const unsigned char *buf, size_t buflen );
Paul Bakkerd98030e2009-05-02 15:13:40 +0000386
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000387/** \ingroup x509_module */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000388/**
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200389 * \brief Load a Certificate Signing Request (CSR)
390 *
391 * \param csr CSR context to fill
392 * \param buf buffer holding the CRL data
393 * \param buflen size of the buffer
394 *
395 * \return 0 if successful, or a specific X509 or PEM error code
396 */
397int x509parse_csr( x509_csr *csr, const unsigned char *buf, size_t buflen );
398
399/** \ingroup x509_module */
400/**
Paul Bakkerd98030e2009-05-02 15:13:40 +0000401 * \brief Load one or more CRLs and add them
402 * to the chained list
403 *
404 * \param chain points to the start of the chain
405 * \param path filename to read the CRLs from
406 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000407 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakkerd98030e2009-05-02 15:13:40 +0000408 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000409int x509parse_crlfile( x509_crl *chain, const char *path );
Paul Bakkerd98030e2009-05-02 15:13:40 +0000410
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200411/** \ingroup x509_module */
412/**
413 * \brief Load a Certificate Signing Request (CSR)
414 *
415 * \param csr CSR context to fill
416 * \param path filename to read the CSR from
417 *
418 * \return 0 if successful, or a specific X509 or PEM error code
419 */
420int x509parse_csrfile( x509_csr *csr, const char *path );
421
Manuel Pégourié-Gonnardab2d9832013-07-11 16:17:23 +0200422#if defined(POLARSSL_RSA_C)
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000423/** \ingroup x509_module */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000424/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000425 * \brief Parse a private RSA key
426 *
427 * \param rsa RSA context to be initialized
Paul Bakkerff60ee62010-03-16 21:09:09 +0000428 * \param key input buffer
429 * \param keylen size of the buffer
Paul Bakker5121ce52009-01-03 21:22:43 +0000430 * \param pwd password for decryption (optional)
431 * \param pwdlen size of the password
432 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000433 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000434 */
Manuel Pégourié-Gonnardba4878a2013-06-27 10:51:01 +0200435int x509parse_key_rsa( rsa_context *rsa,
436 const unsigned char *key, size_t keylen,
437 const unsigned char *pwd, size_t pwdlen );
Paul Bakker5121ce52009-01-03 21:22:43 +0000438
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000439/** \ingroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000440/**
441 * \brief Load and parse a private RSA key
442 *
443 * \param rsa RSA context to be initialized
444 * \param path filename to read the private key from
Paul Bakker37ca75d2011-01-06 12:28:03 +0000445 * \param password password to decrypt the file (can be NULL)
Paul Bakker5121ce52009-01-03 21:22:43 +0000446 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000447 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000448 */
Manuel Pégourié-Gonnardba4878a2013-06-27 10:51:01 +0200449int x509parse_keyfile_rsa( rsa_context *rsa, const char *path,
450 const char *password );
Paul Bakker1b57b062011-01-06 15:48:19 +0000451
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000452/** \ingroup x509_module */
Paul Bakker1b57b062011-01-06 15:48:19 +0000453/**
Paul Bakker917e7542011-03-25 14:23:36 +0000454 * \brief Parse a public RSA key
455 *
456 * \param rsa RSA context to be initialized
457 * \param key input buffer
458 * \param keylen size of the buffer
459 *
460 * \return 0 if successful, or a specific X509 or PEM error code
461 */
Manuel Pégourié-Gonnardba4878a2013-06-27 10:51:01 +0200462int x509parse_public_key_rsa( rsa_context *rsa,
463 const unsigned char *key, size_t keylen );
Paul Bakker917e7542011-03-25 14:23:36 +0000464
465/** \ingroup x509_module */
466/**
467 * \brief Load and parse a public RSA key
468 *
469 * \param rsa RSA context to be initialized
470 * \param path filename to read the private key from
471 *
472 * \return 0 if successful, or a specific X509 or PEM error code
473 */
Manuel Pégourié-Gonnardba4878a2013-06-27 10:51:01 +0200474int x509parse_public_keyfile_rsa( rsa_context *rsa, const char *path );
Manuel Pégourié-Gonnardab2d9832013-07-11 16:17:23 +0200475#endif /* POLARSSL_RSA_C */
Paul Bakker917e7542011-03-25 14:23:36 +0000476
477/** \ingroup x509_module */
478/**
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200479 * \brief Parse a private key
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200480 *
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200481 * \param ctx key to be initialized
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200482 * \param key input buffer
483 * \param keylen size of the buffer
484 * \param pwd password for decryption (optional)
485 * \param pwdlen size of the password
486 *
487 * \return 0 if successful, or a specific X509 or PEM error code
488 */
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200489int x509parse_key( pk_context *ctx,
490 const unsigned char *key, size_t keylen,
491 const unsigned char *pwd, size_t pwdlen );
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200492
493/** \ingroup x509_module */
494/**
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200495 * \brief Load and parse a private key
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200496 *
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200497 * \param ctx key to be initialized
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200498 * \param path filename to read the private key from
499 * \param password password to decrypt the file (can be NULL)
500 *
501 * \return 0 if successful, or a specific X509 or PEM error code
502 */
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200503int x509parse_keyfile( pk_context *ctx,
504 const char *path, const char *password );
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200505
506/** \ingroup x509_module */
507/**
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200508 * \brief Parse a public key
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200509 *
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200510 * \param ctx key to be initialized
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200511 * \param key input buffer
512 * \param keylen size of the buffer
513 *
514 * \return 0 if successful, or a specific X509 or PEM error code
515 */
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200516int x509parse_public_key( pk_context *ctx,
517 const unsigned char *key, size_t keylen );
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200518
519/** \ingroup x509_module */
520/**
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200521 * \brief Load and parse a public key
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200522 *
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200523 * \param ctx key to be initialized
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200524 * \param path filename to read the private key from
525 *
526 * \return 0 if successful, or a specific X509 or PEM error code
527 */
Manuel Pégourié-Gonnard88380992013-07-04 14:09:57 +0200528int x509parse_public_keyfile( pk_context *ctx, const char *path );
Manuel Pégourié-Gonnard26833c22013-06-27 11:27:58 +0200529
530/** \ingroup x509_module */
531/**
Paul Bakker1b57b062011-01-06 15:48:19 +0000532 * \brief Parse DHM parameters
533 *
534 * \param dhm DHM context to be initialized
535 * \param dhmin input buffer
536 * \param dhminlen size of the buffer
537 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000538 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakker1b57b062011-01-06 15:48:19 +0000539 */
Paul Bakker23986e52011-04-24 08:57:21 +0000540int x509parse_dhm( dhm_context *dhm, const unsigned char *dhmin, size_t dhminlen );
Paul Bakker1b57b062011-01-06 15:48:19 +0000541
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000542/** \ingroup x509_module */
Paul Bakker1b57b062011-01-06 15:48:19 +0000543/**
544 * \brief Load and parse DHM parameters
545 *
546 * \param dhm DHM context to be initialized
547 * \param path filename to read the DHM Parameters from
548 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000549 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakker1b57b062011-01-06 15:48:19 +0000550 */
Paul Bakkerf3b86c12011-01-27 15:24:17 +0000551int x509parse_dhmfile( dhm_context *dhm, const char *path );
Paul Bakker1b57b062011-01-06 15:48:19 +0000552
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000553/** \} name Functions to read in DHM parameters, a certificate, CRL or private RSA key */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000554
Paul Bakker5121ce52009-01-03 21:22:43 +0000555/**
556 * \brief Store the certificate DN in printable form into buf;
Paul Bakkerd98030e2009-05-02 15:13:40 +0000557 * no more than size characters will be written.
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000558 *
559 * \param buf Buffer to write to
560 * \param size Maximum size of buffer
561 * \param dn The X509 name to represent
562 *
563 * \return The amount of data written to the buffer, or -1 in
564 * case of an error.
Paul Bakker5121ce52009-01-03 21:22:43 +0000565 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000566int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn );
Paul Bakker5121ce52009-01-03 21:22:43 +0000567
568/**
Paul Bakkerdd476992011-01-16 21:34:59 +0000569 * \brief Store the certificate serial in printable form into buf;
570 * no more than size characters will be written.
571 *
572 * \param buf Buffer to write to
573 * \param size Maximum size of buffer
574 * \param serial The X509 serial to represent
575 *
576 * \return The amount of data written to the buffer, or -1 in
577 * case of an error.
578 */
579int x509parse_serial_gets( char *buf, size_t size, const x509_buf *serial );
580
581/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000582 * \brief Returns an informational string about the
583 * certificate.
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000584 *
585 * \param buf Buffer to write to
586 * \param size Maximum size of buffer
587 * \param prefix A line prefix
588 * \param crt The X509 certificate to represent
589 *
590 * \return The amount of data written to the buffer, or -1 in
591 * case of an error.
Paul Bakker5121ce52009-01-03 21:22:43 +0000592 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000593int x509parse_cert_info( char *buf, size_t size, const char *prefix,
594 const x509_cert *crt );
Paul Bakkerd98030e2009-05-02 15:13:40 +0000595
596/**
597 * \brief Returns an informational string about the
598 * CRL.
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000599 *
600 * \param buf Buffer to write to
601 * \param size Maximum size of buffer
602 * \param prefix A line prefix
Paul Bakker37ca75d2011-01-06 12:28:03 +0000603 * \param crl The X509 CRL to represent
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000604 *
605 * \return The amount of data written to the buffer, or -1 in
606 * case of an error.
Paul Bakkerd98030e2009-05-02 15:13:40 +0000607 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000608int x509parse_crl_info( char *buf, size_t size, const char *prefix,
609 const x509_crl *crl );
Paul Bakker5121ce52009-01-03 21:22:43 +0000610
611/**
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200612 * \brief Returns an informational string about the
613 * CSR.
614 *
615 * \param buf Buffer to write to
616 * \param size Maximum size of buffer
617 * \param prefix A line prefix
618 * \param csr The X509 CSR to represent
619 *
620 * \return The amount of data written to the buffer, or -1 in
621 * case of an error.
622 */
623int x509parse_csr_info( char *buf, size_t size, const char *prefix,
624 const x509_csr *csr );
625
626/**
Paul Bakker74111d32011-01-15 16:57:55 +0000627 * \brief Give an known OID, return its descriptive string.
628 *
629 * \param oid buffer containing the oid
630 *
631 * \return Return a string if the OID is known,
632 * or NULL otherwise.
633 */
634const char *x509_oid_get_description( x509_buf *oid );
635
Paul Bakker9a736322012-11-14 12:39:52 +0000636/**
Paul Bakker74111d32011-01-15 16:57:55 +0000637 * \brief Give an OID, return a string version of its OID number.
Paul Bakkerd5c2b542013-04-07 22:34:26 +0200638 * (Deprecated. Use oid_get_numeric_string() instead)
Paul Bakker74111d32011-01-15 16:57:55 +0000639 *
640 * \param buf Buffer to write to
641 * \param size Maximum size of buffer
642 * \param oid Buffer containing the OID
643 *
644 * \return The amount of data written to the buffer, or -1 in
645 * case of an error.
646 */
647int x509_oid_get_numeric_string( char *buf, size_t size, x509_buf *oid );
648
649/**
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000650 * \brief Check a given x509_time against the system time and check
651 * if it is valid.
652 *
653 * \param time x509_time to check
654 *
655 * \return Return 0 if the x509_time is still valid,
Paul Bakker40ea7de2009-05-03 10:18:48 +0000656 * or 1 otherwise.
Paul Bakker5121ce52009-01-03 21:22:43 +0000657 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000658int x509parse_time_expired( const x509_time *time );
Paul Bakker5121ce52009-01-03 21:22:43 +0000659
660/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000661 * \name Functions to verify a certificate
662 * \{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000663 */
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000664/** \ingroup x509_module */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000665/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000666 * \brief Verify the certificate signature
667 *
Paul Bakker915275b2012-09-28 07:10:55 +0000668 * The verify callback is a user-supplied callback that
669 * can clear / modify / add flags for a certificate. If set,
670 * the verification callback is called for each
671 * certificate in the chain (from the trust-ca down to the
672 * presented crt). The parameters for the callback are:
673 * (void *parameter, x509_cert *crt, int certificate_depth,
674 * int *flags). With the flags representing current flags for
675 * that specific certificate and the certificate depth from
Paul Bakker9a736322012-11-14 12:39:52 +0000676 * the bottom (Peer cert depth = 0).
Paul Bakker915275b2012-09-28 07:10:55 +0000677 *
678 * All flags left after returning from the callback
679 * are also returned to the application. The function should
680 * return 0 for anything but a fatal error.
681 *
Paul Bakker5121ce52009-01-03 21:22:43 +0000682 * \param crt a certificate to be verified
683 * \param trust_ca the trusted CA chain
Paul Bakker40ea7de2009-05-03 10:18:48 +0000684 * \param ca_crl the CRL chain for trusted CA's
Paul Bakker5121ce52009-01-03 21:22:43 +0000685 * \param cn expected Common Name (can be set to
686 * NULL if the CN must not be verified)
687 * \param flags result of the verification
Paul Bakkerb63b0af2011-01-13 17:54:59 +0000688 * \param f_vrfy verification function
689 * \param p_vrfy verification parameter
Paul Bakker5121ce52009-01-03 21:22:43 +0000690 *
Paul Bakker40e46942009-01-03 21:51:57 +0000691 * \return 0 if successful or POLARSSL_ERR_X509_SIG_VERIFY_FAILED,
Paul Bakker5121ce52009-01-03 21:22:43 +0000692 * in which case *flags will have one or more of
693 * the following values set:
694 * BADCERT_EXPIRED --
695 * BADCERT_REVOKED --
696 * BADCERT_CN_MISMATCH --
697 * BADCERT_NOT_TRUSTED
Paul Bakker915275b2012-09-28 07:10:55 +0000698 * or another error in case of a fatal error encountered
699 * during the verification process.
Paul Bakker5121ce52009-01-03 21:22:43 +0000700 */
701int x509parse_verify( x509_cert *crt,
702 x509_cert *trust_ca,
Paul Bakker40ea7de2009-05-03 10:18:48 +0000703 x509_crl *ca_crl,
Paul Bakkerb63b0af2011-01-13 17:54:59 +0000704 const char *cn, int *flags,
Paul Bakker915275b2012-09-28 07:10:55 +0000705 int (*f_vrfy)(void *, x509_cert *, int, int *),
Paul Bakkerb63b0af2011-01-13 17:54:59 +0000706 void *p_vrfy );
Paul Bakker5121ce52009-01-03 21:22:43 +0000707
Paul Bakker74111d32011-01-15 16:57:55 +0000708/**
709 * \brief Verify the certificate signature
710 *
711 * \param crt a certificate to be verified
712 * \param crl the CRL to verify against
713 *
714 * \return 1 if the certificate is revoked, 0 otherwise
715 *
716 */
717int x509parse_revoked( const x509_cert *crt, const x509_crl *crl );
718
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000719/** \} name Functions to verify a certificate */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000720
721
722
723/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000724 * \name Functions to clear a certificate, CRL or private RSA key
725 * \{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000726 */
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000727/** \ingroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000728/**
729 * \brief Unallocate all certificate data
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000730 *
731 * \param crt Certificate chain to free
Paul Bakker5121ce52009-01-03 21:22:43 +0000732 */
733void x509_free( x509_cert *crt );
734
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000735/** \ingroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000736/**
Paul Bakkerd98030e2009-05-02 15:13:40 +0000737 * \brief Unallocate all CRL data
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000738 *
Paul Bakker37ca75d2011-01-06 12:28:03 +0000739 * \param crl CRL chain to free
Paul Bakkerd98030e2009-05-02 15:13:40 +0000740 */
741void x509_crl_free( x509_crl *crl );
742
Paul Bakkerf9f377e2013-09-09 15:35:10 +0200743/**
744 * \brief Unallocate all CSR data
745 *
746 * \param csr CSR to free
747 */
748void x509_csr_free( x509_csr *csr );
749
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000750/** \} name Functions to clear a certificate, CRL or private RSA key */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000751
752
Paul Bakkerd98030e2009-05-02 15:13:40 +0000753/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000754 * \brief Checkup routine
755 *
756 * \return 0 if successful, or 1 if the test failed
757 */
758int x509_self_test( int verbose );
759
760#ifdef __cplusplus
761}
762#endif
763
Paul Bakkered27a042013-04-18 22:46:23 +0200764#endif /* POLARSSL_X509_PARSE_C || POLARSSL_X509_WRITE_C */
Paul Bakker5121ce52009-01-03 21:22:43 +0000765#endif /* x509.h */