blob: 5c4564a450f5a11462bc77c1c847d6b87b019495 [file] [log] [blame]
Paul Bakker7c6b2c32013-09-16 13:49:26 +02001/**
2 * \file x509_crl.h
3 *
4 * \brief X.509 certificate revocation list parsing
5 *
6 * Copyright (C) 2006-2013, Brainspark B.V.
7 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
10 *
11 * All rights reserved.
12 *
13 * 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.
26 */
27#ifndef POLARSSL_X509_CRL_H
28#define POLARSSL_X509_CRL_H
29
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020030#if !defined(POLARSSL_CONFIG_FILE)
Paul Bakker7c6b2c32013-09-16 13:49:26 +020031#include "config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020032#else
33#include POLARSSL_CONFIG_FILE
34#endif
Paul Bakker7c6b2c32013-09-16 13:49:26 +020035
36#include "x509.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/**
43 * \addtogroup x509_module
44 * \{ */
45
46/**
47 * \name Structures and functions for parsing CRLs
48 * \{
49 */
50
51/**
52 * Certificate revocation list entry.
53 * Contains the CA-specific serial numbers and revocation dates.
54 */
55typedef struct _x509_crl_entry
56{
57 x509_buf raw;
58
59 x509_buf serial;
60
61 x509_time revocation_date;
62
63 x509_buf entry_ext;
64
65 struct _x509_crl_entry *next;
66}
67x509_crl_entry;
68
69/**
70 * Certificate revocation list structure.
71 * Every CRL may have multiple entries.
72 */
73typedef struct _x509_crl
74{
75 x509_buf raw; /**< The raw certificate data (DER). */
76 x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */
77
78 int version;
79 x509_buf sig_oid1;
80
81 x509_buf issuer_raw; /**< The raw issuer data (DER). */
82
83 x509_name issuer; /**< The parsed issuer data (named information object). */
84
85 x509_time this_update;
86 x509_time next_update;
87
88 x509_crl_entry entry; /**< The CRL entries containing the certificate revocation times for this CA. */
89
90 x509_buf crl_ext;
91
92 x509_buf sig_oid2;
93 x509_buf sig;
94 md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. POLARSSL_MD_SHA256 */
Manuel Pégourié-Gonnardf75f2f72014-06-05 15:14:28 +020095 pk_type_t sig_pk; /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. POLARSSL_PK_RSA */
Manuel Pégourié-Gonnard8e42ff62014-01-24 15:56:20 +010096#if defined(POLARSSL_RSASSA_PSS_CERTIFICATES)
Manuel Pégourié-Gonnardf75f2f72014-06-05 15:14:28 +020097 void *sig_opts; /**< Signature options to be passed to pk_verify_ext(), eg for RSASSA-PSS */
Manuel Pégourié-Gonnard8e42ff62014-01-24 15:56:20 +010098 x509_buf sig_params; /**< Parameters for the signature algorithm */
99#endif
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200100
101 struct _x509_crl *next;
102}
103x509_crl;
104
105/**
106 * \brief Parse one or more CRLs and add them
107 * to the chained list
108 *
109 * \param chain points to the start of the chain
110 * \param buf buffer holding the CRL data
111 * \param buflen size of the buffer
112 *
113 * \return 0 if successful, or a specific X509 or PEM error code
114 */
Paul Bakkerddf26b42013-09-18 13:46:23 +0200115int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen );
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200116
117#if defined(POLARSSL_FS_IO)
118/**
119 * \brief Load one or more CRLs and add them
120 * to the chained list
121 *
122 * \param chain points to the start of the chain
123 * \param path filename to read the CRLs from
124 *
125 * \return 0 if successful, or a specific X509 or PEM error code
126 */
Paul Bakkerddf26b42013-09-18 13:46:23 +0200127int x509_crl_parse_file( x509_crl *chain, const char *path );
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200128#endif /* POLARSSL_FS_IO */
129
130/**
Paul Bakkerddf26b42013-09-18 13:46:23 +0200131 * \brief Returns an informational string about the CRL.
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200132 *
133 * \param buf Buffer to write to
134 * \param size Maximum size of buffer
135 * \param prefix A line prefix
136 * \param crl The X509 CRL to represent
137 *
138 * \return The amount of data written to the buffer, or -1 in
139 * case of an error.
140 */
Paul Bakkerddf26b42013-09-18 13:46:23 +0200141int x509_crl_info( char *buf, size_t size, const char *prefix,
142 const x509_crl *crl );
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200143
144/**
Paul Bakker369d2eb2013-09-18 11:58:25 +0200145 * \brief Initialize a CRL (chain)
146 *
147 * \param crl CRL chain to initialize
148 */
149void x509_crl_init( x509_crl *crl );
150
151/**
Paul Bakker7c6b2c32013-09-16 13:49:26 +0200152 * \brief Unallocate all CRL data
153 *
154 * \param crl CRL chain to free
155 */
156void x509_crl_free( x509_crl *crl );
157
158/* \} name */
159/* \} addtogroup x509_module */
160
161#ifdef __cplusplus
162}
163#endif
164
165#endif /* x509_crl.h */