4 * \brief X.509 certificate revocation list parsing
7 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8 * SPDX-License-Identifier: GPL-2.0
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * This file is part of mbed TLS (https://tls.mbed.org)
26 #ifndef MBEDTLS_X509_CRL_H
27 #define MBEDTLS_X509_CRL_H
29 #if !defined(MBEDTLS_CONFIG_FILE)
32 #include MBEDTLS_CONFIG_FILE
42 * \addtogroup x509_module
46 * \name Structures and functions for parsing CRLs
51 * Certificate revocation list entry.
52 * Contains the CA-specific serial numbers and revocation dates.
54 typedef struct mbedtls_x509_crl_entry
58 mbedtls_x509_buf serial
;
60 mbedtls_x509_time revocation_date
;
62 mbedtls_x509_buf entry_ext
;
64 struct mbedtls_x509_crl_entry
*next
;
66 mbedtls_x509_crl_entry
;
69 * Certificate revocation list structure.
70 * Every CRL may have multiple entries.
72 typedef struct mbedtls_x509_crl
74 mbedtls_x509_buf raw
; /**< The raw certificate data (DER). */
75 mbedtls_x509_buf tbs
; /**< The raw certificate body (DER). The part that is To Be Signed. */
77 int version
; /**< CRL version (1=v1, 2=v2) */
78 mbedtls_x509_buf sig_oid
; /**< CRL signature type identifier */
80 mbedtls_x509_buf issuer_raw
; /**< The raw issuer data (DER). */
82 mbedtls_x509_name issuer
; /**< The parsed issuer data (named information object). */
84 mbedtls_x509_time this_update
;
85 mbedtls_x509_time next_update
;
87 mbedtls_x509_crl_entry entry
; /**< The CRL entries containing the certificate revocation times for this CA. */
89 mbedtls_x509_buf crl_ext
;
91 mbedtls_x509_buf sig_oid2
;
93 mbedtls_md_type_t sig_md
; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */
94 mbedtls_pk_type_t sig_pk
; /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */
95 void *sig_opts
; /**< Signature options to be passed to mbedtls_pk_verify_ext(), e.g. for RSASSA-PSS */
97 struct mbedtls_x509_crl
*next
;
102 * \brief Parse a DER-encoded CRL and append it to the chained list
104 * \param chain points to the start of the chain
105 * \param buf buffer holding the CRL data in DER format
106 * \param buflen size of the buffer
107 * (including the terminating null byte for PEM data)
109 * \return 0 if successful, or a specific X509 or PEM error code
111 int mbedtls_x509_crl_parse_der( mbedtls_x509_crl
*chain
,
112 const unsigned char *buf
, size_t buflen
);
114 * \brief Parse one or more CRLs and append them to the chained list
116 * \note Mutliple CRLs are accepted only if using PEM format
118 * \param chain points to the start of the chain
119 * \param buf buffer holding the CRL data in PEM or DER format
120 * \param buflen size of the buffer
121 * (including the terminating null byte for PEM data)
123 * \return 0 if successful, or a specific X509 or PEM error code
125 int mbedtls_x509_crl_parse( mbedtls_x509_crl
*chain
, const unsigned char *buf
, size_t buflen
);
127 #if defined(MBEDTLS_FS_IO)
129 * \brief Load one or more CRLs and append them to the chained list
131 * \note Mutliple CRLs are accepted only if using PEM format
133 * \param chain points to the start of the chain
134 * \param path filename to read the CRLs from (in PEM or DER encoding)
136 * \return 0 if successful, or a specific X509 or PEM error code
138 int mbedtls_x509_crl_parse_file( mbedtls_x509_crl
*chain
, const char *path
);
139 #endif /* MBEDTLS_FS_IO */
142 * \brief Returns an informational string about the CRL.
144 * \param buf Buffer to write to
145 * \param size Maximum size of buffer
146 * \param prefix A line prefix
147 * \param crl The X509 CRL to represent
149 * \return The length of the string written (not including the
150 * terminated nul byte), or a negative error code.
152 int mbedtls_x509_crl_info( char *buf
, size_t size
, const char *prefix
,
153 const mbedtls_x509_crl
*crl
);
156 * \brief Initialize a CRL (chain)
158 * \param crl CRL chain to initialize
160 void mbedtls_x509_crl_init( mbedtls_x509_crl
*crl
);
163 * \brief Unallocate all CRL data
165 * \param crl CRL chain to free
167 void mbedtls_x509_crl_free( mbedtls_x509_crl
*crl
);
170 /* \} addtogroup x509_module */
176 #endif /* mbedtls_x509_crl.h */