Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 1 | /** |
| 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é-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 30 | #if !defined(POLARSSL_CONFIG_FILE) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 31 | #include "config.h" |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 32 | #else |
| 33 | #include POLARSSL_CONFIG_FILE |
| 34 | #endif |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 35 | |
| 36 | #include "x509.h" |
| 37 | |
| 38 | #ifdef __cplusplus |
| 39 | extern "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 | */ |
| 55 | typedef 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 | } |
| 67 | x509_crl_entry; |
| 68 | |
| 69 | /** |
| 70 | * Certificate revocation list structure. |
| 71 | * Every CRL may have multiple entries. |
| 72 | */ |
| 73 | typedef 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é-Gonnard | f75f2f7 | 2014-06-05 15:14:28 +0200 | [diff] [blame] | 95 | pk_type_t sig_pk; /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. POLARSSL_PK_RSA */ |
Paul Bakker | 6dade7c | 2014-06-12 22:02:14 +0200 | [diff] [blame] | 96 | void *sig_opts; /**< Signature options to be passed to pk_verify_ext(), e.g. for RSASSA-PSS */ |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 97 | |
| 98 | struct _x509_crl *next; |
| 99 | } |
| 100 | x509_crl; |
| 101 | |
| 102 | /** |
| 103 | * \brief Parse one or more CRLs and add them |
| 104 | * to the chained list |
| 105 | * |
| 106 | * \param chain points to the start of the chain |
| 107 | * \param buf buffer holding the CRL data |
| 108 | * \param buflen size of the buffer |
| 109 | * |
| 110 | * \return 0 if successful, or a specific X509 or PEM error code |
| 111 | */ |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 112 | int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 113 | |
| 114 | #if defined(POLARSSL_FS_IO) |
| 115 | /** |
| 116 | * \brief Load one or more CRLs and add them |
| 117 | * to the chained list |
| 118 | * |
| 119 | * \param chain points to the start of the chain |
| 120 | * \param path filename to read the CRLs from |
| 121 | * |
| 122 | * \return 0 if successful, or a specific X509 or PEM error code |
| 123 | */ |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 124 | int x509_crl_parse_file( x509_crl *chain, const char *path ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 125 | #endif /* POLARSSL_FS_IO */ |
| 126 | |
| 127 | /** |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 128 | * \brief Returns an informational string about the CRL. |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 129 | * |
| 130 | * \param buf Buffer to write to |
| 131 | * \param size Maximum size of buffer |
| 132 | * \param prefix A line prefix |
| 133 | * \param crl The X509 CRL to represent |
| 134 | * |
| 135 | * \return The amount of data written to the buffer, or -1 in |
| 136 | * case of an error. |
| 137 | */ |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 138 | int x509_crl_info( char *buf, size_t size, const char *prefix, |
| 139 | const x509_crl *crl ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 140 | |
| 141 | /** |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 142 | * \brief Initialize a CRL (chain) |
| 143 | * |
| 144 | * \param crl CRL chain to initialize |
| 145 | */ |
| 146 | void x509_crl_init( x509_crl *crl ); |
| 147 | |
| 148 | /** |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 149 | * \brief Unallocate all CRL data |
| 150 | * |
| 151 | * \param crl CRL chain to free |
| 152 | */ |
| 153 | void x509_crl_free( x509_crl *crl ); |
| 154 | |
| 155 | /* \} name */ |
| 156 | /* \} addtogroup x509_module */ |
| 157 | |
| 158 | #ifdef __cplusplus |
| 159 | } |
| 160 | #endif |
| 161 | |
| 162 | #endif /* x509_crl.h */ |