blob: a2d544084840c408fb3bfb336053d7c99449dc8f [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 Bakker84f12b72010-07-18 10:13:04 +00006 * Copyright (C) 2006-2010, 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 Bakker314052f2011-08-15 09:07:52 +000030#include "rsa.h"
31#include "dhm.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000032
Paul Bakker37ca75d2011-01-06 12:28:03 +000033/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +000034 * \addtogroup x509_module
35 * \{
Paul Bakker13e2dfe2009-07-28 07:18:38 +000036 */
Paul Bakker37ca75d2011-01-06 12:28:03 +000037
38/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +000039 * \name ASN1 Error codes
Paul Bakker37ca75d2011-01-06 12:28:03 +000040 * These error codes are OR'ed to X509 error codes for
41 * higher error granularity.
42 * ASN1 is a standard to specify data structures.
Paul Bakker0f5f72e2011-01-18 14:58:55 +000043 * \{
Paul Bakker13e2dfe2009-07-28 07:18:38 +000044 */
Paul Bakker9d781402011-05-09 16:17:09 +000045#define POLARSSL_ERR_ASN1_OUT_OF_DATA -0x0014 /**< Out of data when parsing an ASN1 data structure. */
46#define POLARSSL_ERR_ASN1_UNEXPECTED_TAG -0x0016 /**< ASN1 tag was of an unexpected value. */
47#define POLARSSL_ERR_ASN1_INVALID_LENGTH -0x0018 /**< Error when trying to determine the length or invalid length. */
48#define POLARSSL_ERR_ASN1_LENGTH_MISMATCH -0x001A /**< Actual length differs from expected length. */
49#define POLARSSL_ERR_ASN1_INVALID_DATA -0x001C /**< Data is invalid. (not used) */
Paul Bakker0f5f72e2011-01-18 14:58:55 +000050/* \} name */
Paul Bakker5121ce52009-01-03 21:22:43 +000051
Paul Bakker37ca75d2011-01-06 12:28:03 +000052/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +000053 * \name X509 Error codes
54 * \{
Paul Bakker13e2dfe2009-07-28 07:18:38 +000055 */
Paul Bakker9d781402011-05-09 16:17:09 +000056#define POLARSSL_ERR_X509_FEATURE_UNAVAILABLE -0x2080 /**< Unavailable feature, e.g. RSA hashing/encryption combination. */
57#define POLARSSL_ERR_X509_CERT_INVALID_PEM -0x2100 /**< The PEM-encoded certificate contains invalid elements, e.g. invalid character. */
58#define POLARSSL_ERR_X509_CERT_INVALID_FORMAT -0x2180 /**< The certificate format is invalid, e.g. different type expected. */
59#define POLARSSL_ERR_X509_CERT_INVALID_VERSION -0x2200 /**< The certificate version element is invalid. */
60#define POLARSSL_ERR_X509_CERT_INVALID_SERIAL -0x2280 /**< The serial tag or value is invalid. */
61#define POLARSSL_ERR_X509_CERT_INVALID_ALG -0x2300 /**< The algorithm tag or value is invalid. */
62#define POLARSSL_ERR_X509_CERT_INVALID_NAME -0x2380 /**< The name tag or value is invalid. */
63#define POLARSSL_ERR_X509_CERT_INVALID_DATE -0x2400 /**< The date tag or value is invalid. */
64#define POLARSSL_ERR_X509_CERT_INVALID_PUBKEY -0x2480 /**< The pubkey tag or value is invalid (only RSA is supported). */
65#define POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE -0x2500 /**< The signature tag or value invalid. */
66#define POLARSSL_ERR_X509_CERT_INVALID_EXTENSIONS -0x2580 /**< The extension tag or value is invalid. */
67#define POLARSSL_ERR_X509_CERT_UNKNOWN_VERSION -0x2600 /**< Certificate or CRL has an unsupported version number. */
68#define POLARSSL_ERR_X509_CERT_UNKNOWN_SIG_ALG -0x2680 /**< Signature algorithm (oid) is unsupported. */
Paul Bakkered56b222011-07-13 11:26:43 +000069#define POLARSSL_ERR_X509_UNKNOWN_PK_ALG -0x2700 /**< Key algorithm is unsupported (only RSA is supported). */
Paul Bakker9d781402011-05-09 16:17:09 +000070#define POLARSSL_ERR_X509_CERT_SIG_MISMATCH -0x2780 /**< Certificate signature algorithms do not match. (see \c ::x509_cert sig_oid) */
71#define POLARSSL_ERR_X509_CERT_VERIFY_FAILED -0x2800 /**< Certificate verification failed, e.g. CRL, CA or signature check failed. */
72#define POLARSSL_ERR_X509_KEY_INVALID_VERSION -0x2880 /**< Unsupported RSA key version */
73#define POLARSSL_ERR_X509_KEY_INVALID_FORMAT -0x2900 /**< Invalid RSA key tag or value. */
74#define POLARSSL_ERR_X509_POINT_ERROR -0x2980 /**< Not used. */
75#define POLARSSL_ERR_X509_VALUE_TO_LENGTH -0x2A00 /**< Not used. */
Paul Bakker0f5f72e2011-01-18 14:58:55 +000076/* \} name */
Paul Bakker5121ce52009-01-03 21:22:43 +000077
Paul Bakker37ca75d2011-01-06 12:28:03 +000078
79/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +000080 * \name X509 Verify codes
81 * \{
Paul Bakker37ca75d2011-01-06 12:28:03 +000082 */
Paul Bakkercdf07e92011-01-30 17:05:13 +000083#define BADCERT_EXPIRED 0x01 /**< The certificate validity has expired. */
84#define BADCERT_REVOKED 0x02 /**< The certificate has been revoked (is on a CRL). */
85#define BADCERT_CN_MISMATCH 0x04 /**< The certificate Common Name (CN) does not match with the expected CN. */
86#define BADCERT_NOT_TRUSTED 0x08 /**< The certificate is not correctly signed by the trusted CA. */
87#define BADCRL_NOT_TRUSTED 0x10 /**< CRL is not correctly signed by the trusted CA. */
88#define BADCRL_EXPIRED 0x20 /**< CRL is expired. */
89#define BADCERT_MISSING 0x40 /**< Certificate was missing. */
90#define BADCERT_SKIP_VERIFY 0x80 /**< Certificate verification was skipped. */
Paul Bakker0f5f72e2011-01-18 14:58:55 +000091/* \} name */
Paul Bakker37ca75d2011-01-06 12:28:03 +000092
93
94/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +000095 * \name DER constants
Paul Bakker37ca75d2011-01-06 12:28:03 +000096 * These constants comply with DER encoded the ANS1 type tags.
97 * DER encoding uses hexadecimal representation.
98 * An example DER sequence is:\n
99 * - 0x02 -- tag indicating INTEGER
100 * - 0x01 -- length in octets
101 * - 0x05 -- value
102 * Such sequences are typically read into \c ::x509_buf.
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000103 * \{
Paul Bakker5121ce52009-01-03 21:22:43 +0000104 */
105#define ASN1_BOOLEAN 0x01
106#define ASN1_INTEGER 0x02
107#define ASN1_BIT_STRING 0x03
108#define ASN1_OCTET_STRING 0x04
109#define ASN1_NULL 0x05
110#define ASN1_OID 0x06
111#define ASN1_UTF8_STRING 0x0C
112#define ASN1_SEQUENCE 0x10
113#define ASN1_SET 0x11
114#define ASN1_PRINTABLE_STRING 0x13
115#define ASN1_T61_STRING 0x14
116#define ASN1_IA5_STRING 0x16
117#define ASN1_UTC_TIME 0x17
Paul Bakker91200182010-02-18 21:26:15 +0000118#define ASN1_GENERALIZED_TIME 0x18
Paul Bakker5121ce52009-01-03 21:22:43 +0000119#define ASN1_UNIVERSAL_STRING 0x1C
120#define ASN1_BMP_STRING 0x1E
121#define ASN1_PRIMITIVE 0x00
122#define ASN1_CONSTRUCTED 0x20
123#define ASN1_CONTEXT_SPECIFIC 0x80
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000124/* \} name */
125/* \} addtogroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000126
127/*
128 * various object identifiers
129 */
130#define X520_COMMON_NAME 3
131#define X520_COUNTRY 6
132#define X520_LOCALITY 7
133#define X520_STATE 8
134#define X520_ORGANIZATION 10
135#define X520_ORG_UNIT 11
136#define PKCS9_EMAIL 1
137
138#define X509_OUTPUT_DER 0x01
139#define X509_OUTPUT_PEM 0x02
140#define PEM_LINE_LENGTH 72
141#define X509_ISSUER 0x01
142#define X509_SUBJECT 0x02
143
Paul Bakkerf3b86c12011-01-27 15:24:17 +0000144/** Returns the size of the binary string, without the trailing \\0 */
Paul Bakker74111d32011-01-15 16:57:55 +0000145#define OID_SIZE(x) (sizeof(x) - 1)
146
Paul Bakker5121ce52009-01-03 21:22:43 +0000147#define OID_X520 "\x55\x04"
Paul Bakker74111d32011-01-15 16:57:55 +0000148#define OID_CN OID_X520 "\x03"
149
Paul Bakker5121ce52009-01-03 21:22:43 +0000150#define OID_PKCS1 "\x2A\x86\x48\x86\xF7\x0D\x01\x01"
Paul Bakker74111d32011-01-15 16:57:55 +0000151#define OID_PKCS1_RSA OID_PKCS1 "\x01"
Paul Bakker400ff6f2011-02-20 10:40:16 +0000152
153#define OID_RSA_SHA_OBS "\x2B\x0E\x03\x02\x1D"
Paul Bakker74111d32011-01-15 16:57:55 +0000154
Paul Bakker5121ce52009-01-03 21:22:43 +0000155#define OID_PKCS9 "\x2A\x86\x48\x86\xF7\x0D\x01\x09"
Paul Bakker74111d32011-01-15 16:57:55 +0000156#define OID_PKCS9_EMAIL OID_PKCS9 "\x01"
157
158/** ISO arc for standard certificate and CRL extensions */
159#define OID_ID_CE "\x55\x1D" /**< id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29} */
160
161/**
162 * Private Internet Extensions
163 * { iso(1) identified-organization(3) dod(6) internet(1)
164 * security(5) mechanisms(5) pkix(7) }
165 */
166#define OID_PKIX "\x2B\x06\x01\x05\x05\x07"
167
168/*
169 * OIDs for standard certificate extensions
170 */
171#define OID_AUTHORITY_KEY_IDENTIFIER OID_ID_CE "\x23" /**< id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 35 } */
172#define OID_SUBJECT_KEY_IDENTIFIER OID_ID_CE "\x0E" /**< id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::= { id-ce 14 } */
173#define OID_KEY_USAGE OID_ID_CE "\x0F" /**< id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 } */
174#define OID_CERTIFICATE_POLICIES OID_ID_CE "\x20" /**< id-ce-certificatePolicies OBJECT IDENTIFIER ::= { id-ce 32 } */
175#define OID_POLICY_MAPPINGS OID_ID_CE "\x21" /**< id-ce-policyMappings OBJECT IDENTIFIER ::= { id-ce 33 } */
176#define OID_SUBJECT_ALT_NAME OID_ID_CE "\x11" /**< id-ce-subjectAltName OBJECT IDENTIFIER ::= { id-ce 17 } */
177#define OID_ISSUER_ALT_NAME OID_ID_CE "\x12" /**< id-ce-issuerAltName OBJECT IDENTIFIER ::= { id-ce 18 } */
178#define OID_SUBJECT_DIRECTORY_ATTRS OID_ID_CE "\x09" /**< id-ce-subjectDirectoryAttributes OBJECT IDENTIFIER ::= { id-ce 9 } */
179#define OID_BASIC_CONSTRAINTS OID_ID_CE "\x13" /**< id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 } */
180#define OID_NAME_CONSTRAINTS OID_ID_CE "\x1E" /**< id-ce-nameConstraints OBJECT IDENTIFIER ::= { id-ce 30 } */
181#define OID_POLICY_CONSTRAINTS OID_ID_CE "\x24" /**< id-ce-policyConstraints OBJECT IDENTIFIER ::= { id-ce 36 } */
182#define OID_EXTENDED_KEY_USAGE OID_ID_CE "\x25" /**< id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 } */
183#define OID_CRL_DISTRIBUTION_POINTS OID_ID_CE "\x1F" /**< id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::= { id-ce 31 } */
184#define OID_INIHIBIT_ANYPOLICY OID_ID_CE "\x36" /**< id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 } */
185#define OID_FRESHEST_CRL OID_ID_CE "\x2E" /**< id-ce-freshestCRL OBJECT IDENTIFIER ::= { id-ce 46 } */
186
187/*
188 * X.509 v3 Key Usage Extension flags
189 */
190#define KU_DIGITAL_SIGNATURE (0x80) /* bit 0 */
191#define KU_NON_REPUDIATION (0x40) /* bit 1 */
192#define KU_KEY_ENCIPHERMENT (0x20) /* bit 2 */
193#define KU_DATA_ENCIPHERMENT (0x10) /* bit 3 */
194#define KU_KEY_AGREEMENT (0x08) /* bit 4 */
195#define KU_KEY_CERT_SIGN (0x04) /* bit 5 */
196#define KU_CRL_SIGN (0x02) /* bit 6 */
197
198/*
199 * X.509 v3 Extended key usage OIDs
200 */
201#define OID_ANY_EXTENDED_KEY_USAGE OID_EXTENDED_KEY_USAGE "\x00" /**< anyExtendedKeyUsage OBJECT IDENTIFIER ::= { id-ce-extKeyUsage 0 } */
202
203#define OID_KP OID_PKIX "\x03" /**< id-kp OBJECT IDENTIFIER ::= { id-pkix 3 } */
204#define OID_SERVER_AUTH OID_KP "\x01" /**< id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 } */
205#define OID_CLIENT_AUTH OID_KP "\x02" /**< id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 } */
206#define OID_CODE_SIGNING OID_KP "\x03" /**< id-kp-codeSigning OBJECT IDENTIFIER ::= { id-kp 3 } */
207#define OID_EMAIL_PROTECTION OID_KP "\x04" /**< id-kp-emailProtection OBJECT IDENTIFIER ::= { id-kp 4 } */
208#define OID_TIME_STAMPING OID_KP "\x08" /**< id-kp-timeStamping OBJECT IDENTIFIER ::= { id-kp 8 } */
209#define OID_OCSP_SIGNING OID_KP "\x09" /**< id-kp-OCSPSigning OBJECT IDENTIFIER ::= { id-kp 9 } */
210
211#define STRING_SERVER_AUTH "TLS Web Server Authentication"
212#define STRING_CLIENT_AUTH "TLS Web Client Authentication"
213#define STRING_CODE_SIGNING "Code Signing"
214#define STRING_EMAIL_PROTECTION "E-mail Protection"
215#define STRING_TIME_STAMPING "Time Stamping"
216#define STRING_OCSP_SIGNING "OCSP Signing"
217
218/*
219 * OIDs for CRL extensions
220 */
221#define OID_PRIVATE_KEY_USAGE_PERIOD OID_ID_CE "\x10"
222#define OID_CRL_NUMBER OID_ID_CE "\x14" /**< id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 } */
223
224/*
225 * Netscape certificate extensions
226 */
227#define OID_NETSCAPE "\x60\x86\x48\x01\x86\xF8\x42" /**< Netscape OID */
228#define OID_NS_CERT OID_NETSCAPE "\x01"
229#define OID_NS_CERT_TYPE OID_NS_CERT "\x01"
230#define OID_NS_BASE_URL OID_NS_CERT "\x02"
231#define OID_NS_REVOCATION_URL OID_NS_CERT "\x03"
232#define OID_NS_CA_REVOCATION_URL OID_NS_CERT "\x04"
233#define OID_NS_RENEWAL_URL OID_NS_CERT "\x07"
234#define OID_NS_CA_POLICY_URL OID_NS_CERT "\x08"
235#define OID_NS_SSL_SERVER_NAME OID_NS_CERT "\x0C"
236#define OID_NS_COMMENT OID_NS_CERT "\x0D"
237#define OID_NS_DATA_TYPE OID_NETSCAPE "\x02"
238#define OID_NS_CERT_SEQUENCE OID_NS_DATA_TYPE "\x05"
239
240/*
241 * Netscape certificate types
242 * (http://www.mozilla.org/projects/security/pki/nss/tech-notes/tn3.html)
243 */
244
245#define NS_CERT_TYPE_SSL_CLIENT (0x80) /* bit 0 */
246#define NS_CERT_TYPE_SSL_SERVER (0x40) /* bit 1 */
247#define NS_CERT_TYPE_EMAIL (0x20) /* bit 2 */
248#define NS_CERT_TYPE_OBJECT_SIGNING (0x10) /* bit 3 */
249#define NS_CERT_TYPE_RESERVED (0x08) /* bit 4 */
250#define NS_CERT_TYPE_SSL_CA (0x04) /* bit 5 */
251#define NS_CERT_TYPE_EMAIL_CA (0x02) /* bit 6 */
252#define NS_CERT_TYPE_OBJECT_SIGNING_CA (0x01) /* bit 7 */
253
254#define EXT_AUTHORITY_KEY_IDENTIFIER (1 << 0)
255#define EXT_SUBJECT_KEY_IDENTIFIER (1 << 1)
256#define EXT_KEY_USAGE (1 << 2)
257#define EXT_CERTIFICATE_POLICIES (1 << 3)
258#define EXT_POLICY_MAPPINGS (1 << 4)
259#define EXT_SUBJECT_ALT_NAME (1 << 5)
260#define EXT_ISSUER_ALT_NAME (1 << 6)
261#define EXT_SUBJECT_DIRECTORY_ATTRS (1 << 7)
262#define EXT_BASIC_CONSTRAINTS (1 << 8)
263#define EXT_NAME_CONSTRAINTS (1 << 9)
264#define EXT_POLICY_CONSTRAINTS (1 << 10)
265#define EXT_EXTENDED_KEY_USAGE (1 << 11)
266#define EXT_CRL_DISTRIBUTION_POINTS (1 << 12)
267#define EXT_INIHIBIT_ANYPOLICY (1 << 13)
268#define EXT_FRESHEST_CRL (1 << 14)
269
270#define EXT_NS_CERT_TYPE (1 << 16)
Paul Bakker5121ce52009-01-03 21:22:43 +0000271
Paul Bakker37ca75d2011-01-06 12:28:03 +0000272/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000273 * \addtogroup x509_module
274 * \{ */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000275
276/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000277 * \name Structures for parsing X.509 certificates and CRLs
278 * \{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000279 */
280
281/**
282 * Type-length-value structure that allows for ASN1 using DER.
Paul Bakker5121ce52009-01-03 21:22:43 +0000283 */
284typedef struct _x509_buf
285{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000286 int tag; /**< ASN1 type, e.g. ASN1_UTF8_STRING. */
Paul Bakker23986e52011-04-24 08:57:21 +0000287 size_t len; /**< ASN1 length, e.g. in octets. */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000288 unsigned char *p; /**< ASN1 data, e.g. in ASCII. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000289}
290x509_buf;
291
Paul Bakker37ca75d2011-01-06 12:28:03 +0000292/**
Paul Bakker74111d32011-01-15 16:57:55 +0000293 * Container for ASN1 bit strings.
294 */
295typedef struct _x509_bitstring
296{
Paul Bakker23986e52011-04-24 08:57:21 +0000297 size_t len; /**< ASN1 length, e.g. in octets. */
Paul Bakker74111d32011-01-15 16:57:55 +0000298 unsigned char unused_bits; /**< Number of unused bits at the end of the string */
299 unsigned char *p; /**< Raw ASN1 data for the bit string */
300}
301x509_bitstring;
302
303/**
Paul Bakker37ca75d2011-01-06 12:28:03 +0000304 * Container for ASN1 named information objects.
305 * It allows for Relative Distinguished Names (e.g. cn=polarssl,ou=code,etc.).
306 */
Paul Bakker5121ce52009-01-03 21:22:43 +0000307typedef struct _x509_name
308{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000309 x509_buf oid; /**< The object identifier. */
310 x509_buf val; /**< The named value. */
311 struct _x509_name *next; /**< The next named information object. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000312}
313x509_name;
314
Paul Bakker74111d32011-01-15 16:57:55 +0000315/**
316 * Container for a sequence of ASN.1 items
317 */
318typedef struct _x509_sequence
319{
320 x509_buf buf; /**< Buffer containing the given ASN.1 item. */
321 struct _x509_sequence *next; /**< The next entry in the sequence. */
322}
323x509_sequence;
324
Paul Bakker37ca75d2011-01-06 12:28:03 +0000325/** Container for date and time (precision in seconds). */
Paul Bakker5121ce52009-01-03 21:22:43 +0000326typedef struct _x509_time
327{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000328 int year, mon, day; /**< Date. */
329 int hour, min, sec; /**< Time. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000330}
331x509_time;
332
Paul Bakker37ca75d2011-01-06 12:28:03 +0000333/**
334 * Container for an X.509 certificate. The certificate may be chained.
335 */
Paul Bakker5121ce52009-01-03 21:22:43 +0000336typedef struct _x509_cert
337{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000338 x509_buf raw; /**< The raw certificate data (DER). */
339 x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000340
Paul Bakker37ca75d2011-01-06 12:28:03 +0000341 int version; /**< The X.509 version. (0=v1, 1=v2, 2=v3) */
342 x509_buf serial; /**< Unique id for certificate issued by a specific CA. */
343 x509_buf sig_oid1; /**< Signature algorithm, e.g. sha1RSA */
Paul Bakker5121ce52009-01-03 21:22:43 +0000344
Paul Bakker37ca75d2011-01-06 12:28:03 +0000345 x509_buf issuer_raw; /**< The raw issuer data (DER). Used for quick comparison. */
346 x509_buf subject_raw; /**< The raw subject data (DER). Used for quick comparison. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000347
Paul Bakker37ca75d2011-01-06 12:28:03 +0000348 x509_name issuer; /**< The parsed issuer data (named information object). */
349 x509_name subject; /**< The parsed subject data (named information object). */
Paul Bakker5121ce52009-01-03 21:22:43 +0000350
Paul Bakker37ca75d2011-01-06 12:28:03 +0000351 x509_time valid_from; /**< Start time of certificate validity. */
352 x509_time valid_to; /**< End time of certificate validity. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000353
Paul Bakker37ca75d2011-01-06 12:28:03 +0000354 x509_buf pk_oid; /**< Subject public key info. Includes the public key algorithm and the key itself. */
355 rsa_context rsa; /**< Container for the RSA context. Only RSA is supported for public keys at this time. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000356
Paul Bakker37ca75d2011-01-06 12:28:03 +0000357 x509_buf issuer_id; /**< Optional X.509 v2/v3 issuer unique identifier. */
358 x509_buf subject_id; /**< Optional X.509 v2/v3 subject unique identifier. */
359 x509_buf v3_ext; /**< Optional X.509 v3 extensions. Only Basic Contraints are supported at this time. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000360
Paul Bakker74111d32011-01-15 16:57:55 +0000361 int ext_types; /**< Bit string containing detected and parsed extensions */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000362 int ca_istrue; /**< Optional Basic Constraint extension value: 1 if this certificate belongs to a CA, 0 otherwise. */
363 int max_pathlen; /**< Optional Basic Constraint extension value: The maximum path length to the root certificate. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000364
Paul Bakker74111d32011-01-15 16:57:55 +0000365 unsigned char key_usage; /**< Optional key usage extension value: See the values below */
366
367 x509_sequence ext_key_usage; /**< Optional list of extended key usage OIDs. */
368
369 unsigned char ns_cert_type; /**< Optional Netscape certificate type extension value: See the values below */
370
Paul Bakker37ca75d2011-01-06 12:28:03 +0000371 x509_buf sig_oid2; /**< Signature algorithm. Must match sig_oid1. */
372 x509_buf sig; /**< Signature: hash of the tbs part signed with the private key. */
373 int sig_alg; /**< Internal representation of the signature algorithm, e.g. SIG_RSA_MD2 */
Paul Bakker5121ce52009-01-03 21:22:43 +0000374
Paul Bakker37ca75d2011-01-06 12:28:03 +0000375 struct _x509_cert *next; /**< Next certificate in the CA-chain. */
Paul Bakker5121ce52009-01-03 21:22:43 +0000376}
377x509_cert;
378
Paul Bakker37ca75d2011-01-06 12:28:03 +0000379/**
380 * Certificate revocation list entry.
381 * Contains the CA-specific serial numbers and revocation dates.
382 */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000383typedef struct _x509_crl_entry
384{
385 x509_buf raw;
386
387 x509_buf serial;
388
389 x509_time revocation_date;
390
391 x509_buf entry_ext;
392
393 struct _x509_crl_entry *next;
394}
395x509_crl_entry;
396
Paul Bakker37ca75d2011-01-06 12:28:03 +0000397/**
398 * Certificate revocation list structure.
399 * Every CRL may have multiple entries.
400 */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000401typedef struct _x509_crl
402{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000403 x509_buf raw; /**< The raw certificate data (DER). */
404 x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000405
406 int version;
407 x509_buf sig_oid1;
408
Paul Bakker37ca75d2011-01-06 12:28:03 +0000409 x509_buf issuer_raw; /**< The raw issuer data (DER). */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000410
Paul Bakker37ca75d2011-01-06 12:28:03 +0000411 x509_name issuer; /**< The parsed issuer data (named information object). */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000412
Paul Bakker37ca75d2011-01-06 12:28:03 +0000413 x509_time this_update;
Paul Bakkerd98030e2009-05-02 15:13:40 +0000414 x509_time next_update;
415
Paul Bakker37ca75d2011-01-06 12:28:03 +0000416 x509_crl_entry entry; /**< The CRL entries containing the certificate revocation times for this CA. */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000417
418 x509_buf crl_ext;
419
420 x509_buf sig_oid2;
421 x509_buf sig;
Paul Bakker27d66162010-03-17 06:56:01 +0000422 int sig_alg;
Paul Bakkerd98030e2009-05-02 15:13:40 +0000423
424 struct _x509_crl *next;
425}
426x509_crl;
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000427/** \} name Structures for parsing X.509 certificates and CRLs */
428/** \} addtogroup x509_module */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000429
Paul Bakker37ca75d2011-01-06 12:28:03 +0000430/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000431 * \name Structures for writing X.509 certificates.
Paul Bakker37ca75d2011-01-06 12:28:03 +0000432 * XvP: commented out as they are not used.
433 * - <tt>typedef struct _x509_node x509_node;</tt>
434 * - <tt>typedef struct _x509_raw x509_raw;</tt>
Paul Bakker5121ce52009-01-03 21:22:43 +0000435 */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000436/*
Paul Bakker5121ce52009-01-03 21:22:43 +0000437typedef struct _x509_node
438{
439 unsigned char *data;
440 unsigned char *p;
441 unsigned char *end;
442
443 size_t len;
444}
445x509_node;
446
447typedef struct _x509_raw
448{
449 x509_node raw;
450 x509_node tbs;
451
452 x509_node version;
453 x509_node serial;
454 x509_node tbs_signalg;
455 x509_node issuer;
456 x509_node validity;
457 x509_node subject;
458 x509_node subpubkey;
459
460 x509_node signalg;
461 x509_node sign;
462}
463x509_raw;
Paul Bakker37ca75d2011-01-06 12:28:03 +0000464*/
Paul Bakker5121ce52009-01-03 21:22:43 +0000465
466#ifdef __cplusplus
467extern "C" {
468#endif
469
470/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000471 * \name Functions to read in DHM parameters, a certificate, CRL or private RSA key
472 * \{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000473 */
474
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000475/** \ingroup x509_module */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000476/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000477 * \brief Parse one or more certificates and add them
478 * to the chained list
479 *
480 * \param chain points to the start of the chain
481 * \param buf buffer holding the certificate data
482 * \param buflen size of the buffer
483 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000484 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000485 */
Paul Bakker23986e52011-04-24 08:57:21 +0000486int x509parse_crt( x509_cert *chain, const unsigned char *buf, size_t buflen );
Paul Bakker5121ce52009-01-03 21:22:43 +0000487
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000488/** \ingroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000489/**
490 * \brief Load one or more certificates and add them
491 * to the chained list
492 *
493 * \param chain points to the start of the chain
494 * \param path filename to read the certificates from
495 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000496 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000497 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000498int x509parse_crtfile( x509_cert *chain, const char *path );
Paul Bakker5121ce52009-01-03 21:22:43 +0000499
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000500/** \ingroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000501/**
Paul Bakkerd98030e2009-05-02 15:13:40 +0000502 * \brief Parse one or more CRLs and add them
503 * to the chained list
504 *
505 * \param chain points to the start of the chain
506 * \param buf buffer holding the CRL data
507 * \param buflen size of the buffer
508 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000509 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakkerd98030e2009-05-02 15:13:40 +0000510 */
Paul Bakker23986e52011-04-24 08:57:21 +0000511int x509parse_crl( x509_crl *chain, const unsigned char *buf, size_t buflen );
Paul Bakkerd98030e2009-05-02 15:13:40 +0000512
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000513/** \ingroup x509_module */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000514/**
515 * \brief Load one or more CRLs and add them
516 * to the chained list
517 *
518 * \param chain points to the start of the chain
519 * \param path filename to read the CRLs from
520 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000521 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakkerd98030e2009-05-02 15:13:40 +0000522 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000523int x509parse_crlfile( x509_crl *chain, const char *path );
Paul Bakkerd98030e2009-05-02 15:13:40 +0000524
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000525/** \ingroup x509_module */
Paul Bakkerd98030e2009-05-02 15:13:40 +0000526/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000527 * \brief Parse a private RSA key
528 *
529 * \param rsa RSA context to be initialized
Paul Bakkerff60ee62010-03-16 21:09:09 +0000530 * \param key input buffer
531 * \param keylen size of the buffer
Paul Bakker5121ce52009-01-03 21:22:43 +0000532 * \param pwd password for decryption (optional)
533 * \param pwdlen size of the password
534 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000535 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000536 */
537int x509parse_key( rsa_context *rsa,
Paul Bakker23986e52011-04-24 08:57:21 +0000538 const unsigned char *key, size_t keylen,
539 const unsigned char *pwd, size_t pwdlen );
Paul Bakker5121ce52009-01-03 21:22:43 +0000540
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000541/** \ingroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000542/**
543 * \brief Load and parse a private RSA key
544 *
545 * \param rsa RSA context to be initialized
546 * \param path filename to read the private key from
Paul Bakker37ca75d2011-01-06 12:28:03 +0000547 * \param password password to decrypt the file (can be NULL)
Paul Bakker5121ce52009-01-03 21:22:43 +0000548 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000549 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000550 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000551int x509parse_keyfile( rsa_context *rsa, const char *path,
552 const char *password );
Paul Bakker1b57b062011-01-06 15:48:19 +0000553
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000554/** \ingroup x509_module */
Paul Bakker1b57b062011-01-06 15:48:19 +0000555/**
Paul Bakker917e7542011-03-25 14:23:36 +0000556 * \brief Parse a public RSA key
557 *
558 * \param rsa RSA context to be initialized
559 * \param key input buffer
560 * \param keylen size of the buffer
561 *
562 * \return 0 if successful, or a specific X509 or PEM error code
563 */
564int x509parse_public_key( rsa_context *rsa,
Paul Bakker23986e52011-04-24 08:57:21 +0000565 const unsigned char *key, size_t keylen );
Paul Bakker917e7542011-03-25 14:23:36 +0000566
567/** \ingroup x509_module */
568/**
569 * \brief Load and parse a public RSA key
570 *
571 * \param rsa RSA context to be initialized
572 * \param path filename to read the private key from
573 *
574 * \return 0 if successful, or a specific X509 or PEM error code
575 */
576int x509parse_public_keyfile( rsa_context *rsa, const char *path );
577
578/** \ingroup x509_module */
579/**
Paul Bakker1b57b062011-01-06 15:48:19 +0000580 * \brief Parse DHM parameters
581 *
582 * \param dhm DHM context to be initialized
583 * \param dhmin input buffer
584 * \param dhminlen size of the buffer
585 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000586 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakker1b57b062011-01-06 15:48:19 +0000587 */
Paul Bakker23986e52011-04-24 08:57:21 +0000588int x509parse_dhm( dhm_context *dhm, const unsigned char *dhmin, size_t dhminlen );
Paul Bakker1b57b062011-01-06 15:48:19 +0000589
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000590/** \ingroup x509_module */
Paul Bakker1b57b062011-01-06 15:48:19 +0000591/**
592 * \brief Load and parse DHM parameters
593 *
594 * \param dhm DHM context to be initialized
595 * \param path filename to read the DHM Parameters from
596 *
Paul Bakker96743fc2011-02-12 14:30:57 +0000597 * \return 0 if successful, or a specific X509 or PEM error code
Paul Bakker1b57b062011-01-06 15:48:19 +0000598 */
Paul Bakkerf3b86c12011-01-27 15:24:17 +0000599int x509parse_dhmfile( dhm_context *dhm, const char *path );
Paul Bakker1b57b062011-01-06 15:48:19 +0000600
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000601/** \} name Functions to read in DHM parameters, a certificate, CRL or private RSA key */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000602
603
Paul Bakker5121ce52009-01-03 21:22:43 +0000604
605/**
606 * \brief Store the certificate DN in printable form into buf;
Paul Bakkerd98030e2009-05-02 15:13:40 +0000607 * no more than size characters will be written.
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000608 *
609 * \param buf Buffer to write to
610 * \param size Maximum size of buffer
611 * \param dn The X509 name to represent
612 *
613 * \return The amount of data written to the buffer, or -1 in
614 * case of an error.
Paul Bakker5121ce52009-01-03 21:22:43 +0000615 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000616int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn );
Paul Bakker5121ce52009-01-03 21:22:43 +0000617
618/**
Paul Bakkerdd476992011-01-16 21:34:59 +0000619 * \brief Store the certificate serial in printable form into buf;
620 * no more than size characters will be written.
621 *
622 * \param buf Buffer to write to
623 * \param size Maximum size of buffer
624 * \param serial The X509 serial to represent
625 *
626 * \return The amount of data written to the buffer, or -1 in
627 * case of an error.
628 */
629int x509parse_serial_gets( char *buf, size_t size, const x509_buf *serial );
630
631/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000632 * \brief Returns an informational string about the
633 * certificate.
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000634 *
635 * \param buf Buffer to write to
636 * \param size Maximum size of buffer
637 * \param prefix A line prefix
638 * \param crt The X509 certificate to represent
639 *
640 * \return The amount of data written to the buffer, or -1 in
641 * case of an error.
Paul Bakker5121ce52009-01-03 21:22:43 +0000642 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000643int x509parse_cert_info( char *buf, size_t size, const char *prefix,
644 const x509_cert *crt );
Paul Bakkerd98030e2009-05-02 15:13:40 +0000645
646/**
647 * \brief Returns an informational string about the
648 * CRL.
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000649 *
650 * \param buf Buffer to write to
651 * \param size Maximum size of buffer
652 * \param prefix A line prefix
Paul Bakker37ca75d2011-01-06 12:28:03 +0000653 * \param crl The X509 CRL to represent
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000654 *
655 * \return The amount of data written to the buffer, or -1 in
656 * case of an error.
Paul Bakkerd98030e2009-05-02 15:13:40 +0000657 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000658int x509parse_crl_info( char *buf, size_t size, const char *prefix,
659 const x509_crl *crl );
Paul Bakker5121ce52009-01-03 21:22:43 +0000660
661/**
Paul Bakker74111d32011-01-15 16:57:55 +0000662 * \brief Give an known OID, return its descriptive string.
663 *
664 * \param oid buffer containing the oid
665 *
666 * \return Return a string if the OID is known,
667 * or NULL otherwise.
668 */
669const char *x509_oid_get_description( x509_buf *oid );
670
671/*
672 * \brief Give an OID, return a string version of its OID number.
673 *
674 * \param buf Buffer to write to
675 * \param size Maximum size of buffer
676 * \param oid Buffer containing the OID
677 *
678 * \return The amount of data written to the buffer, or -1 in
679 * case of an error.
680 */
681int x509_oid_get_numeric_string( char *buf, size_t size, x509_buf *oid );
682
683/**
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000684 * \brief Check a given x509_time against the system time and check
685 * if it is valid.
686 *
687 * \param time x509_time to check
688 *
689 * \return Return 0 if the x509_time is still valid,
Paul Bakker40ea7de2009-05-03 10:18:48 +0000690 * or 1 otherwise.
Paul Bakker5121ce52009-01-03 21:22:43 +0000691 */
Paul Bakkerff60ee62010-03-16 21:09:09 +0000692int x509parse_time_expired( const x509_time *time );
Paul Bakker5121ce52009-01-03 21:22:43 +0000693
694/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000695 * \name Functions to verify a certificate
696 * \{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000697 */
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000698/** \ingroup x509_module */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000699/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000700 * \brief Verify the certificate signature
701 *
702 * \param crt a certificate to be verified
703 * \param trust_ca the trusted CA chain
Paul Bakker40ea7de2009-05-03 10:18:48 +0000704 * \param ca_crl the CRL chain for trusted CA's
Paul Bakker5121ce52009-01-03 21:22:43 +0000705 * \param cn expected Common Name (can be set to
706 * NULL if the CN must not be verified)
707 * \param flags result of the verification
Paul Bakkerb63b0af2011-01-13 17:54:59 +0000708 * \param f_vrfy verification function
709 * \param p_vrfy verification parameter
Paul Bakker5121ce52009-01-03 21:22:43 +0000710 *
Paul Bakker40e46942009-01-03 21:51:57 +0000711 * \return 0 if successful or POLARSSL_ERR_X509_SIG_VERIFY_FAILED,
Paul Bakker5121ce52009-01-03 21:22:43 +0000712 * in which case *flags will have one or more of
713 * the following values set:
714 * BADCERT_EXPIRED --
715 * BADCERT_REVOKED --
716 * BADCERT_CN_MISMATCH --
717 * BADCERT_NOT_TRUSTED
718 *
719 * \note TODO: add two arguments, depth and crl
720 */
721int x509parse_verify( x509_cert *crt,
722 x509_cert *trust_ca,
Paul Bakker40ea7de2009-05-03 10:18:48 +0000723 x509_crl *ca_crl,
Paul Bakkerb63b0af2011-01-13 17:54:59 +0000724 const char *cn, int *flags,
725 int (*f_vrfy)(void *, x509_cert *, int, int),
726 void *p_vrfy );
Paul Bakker5121ce52009-01-03 21:22:43 +0000727
Paul Bakker74111d32011-01-15 16:57:55 +0000728/**
729 * \brief Verify the certificate signature
730 *
731 * \param crt a certificate to be verified
732 * \param crl the CRL to verify against
733 *
734 * \return 1 if the certificate is revoked, 0 otherwise
735 *
736 */
737int x509parse_revoked( const x509_cert *crt, const x509_crl *crl );
738
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000739/** \} name Functions to verify a certificate */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000740
741
742
743/**
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000744 * \name Functions to clear a certificate, CRL or private RSA key
745 * \{
Paul Bakker37ca75d2011-01-06 12:28:03 +0000746 */
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000747/** \ingroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000748/**
749 * \brief Unallocate all certificate data
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000750 *
751 * \param crt Certificate chain to free
Paul Bakker5121ce52009-01-03 21:22:43 +0000752 */
753void x509_free( x509_cert *crt );
754
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000755/** \ingroup x509_module */
Paul Bakker5121ce52009-01-03 21:22:43 +0000756/**
Paul Bakkerd98030e2009-05-02 15:13:40 +0000757 * \brief Unallocate all CRL data
Paul Bakker13e2dfe2009-07-28 07:18:38 +0000758 *
Paul Bakker37ca75d2011-01-06 12:28:03 +0000759 * \param crl CRL chain to free
Paul Bakkerd98030e2009-05-02 15:13:40 +0000760 */
761void x509_crl_free( x509_crl *crl );
762
Paul Bakker0f5f72e2011-01-18 14:58:55 +0000763/** \} name Functions to clear a certificate, CRL or private RSA key */
Paul Bakker37ca75d2011-01-06 12:28:03 +0000764
765
Paul Bakkerd98030e2009-05-02 15:13:40 +0000766/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000767 * \brief Checkup routine
768 *
769 * \return 0 if successful, or 1 if the test failed
770 */
771int x509_self_test( int verbose );
772
773#ifdef __cplusplus
774}
775#endif
776
777#endif /* x509.h */