4 * \brief X.509 certificate revocation list parsing
\r
7 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
\r
8 * SPDX-License-Identifier: Apache-2.0
\r
10 * Licensed under the Apache License, Version 2.0 (the "License"); you may
\r
11 * not use this file except in compliance with the License.
\r
12 * You may obtain a copy of the License at
\r
14 * http://www.apache.org/licenses/LICENSE-2.0
\r
16 * Unless required by applicable law or agreed to in writing, software
\r
17 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
\r
18 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
19 * See the License for the specific language governing permissions and
\r
20 * limitations under the License.
\r
22 * This file is part of mbed TLS (https://tls.mbed.org)
\r
24 #ifndef MBEDTLS_X509_CRL_H
\r
25 #define MBEDTLS_X509_CRL_H
\r
27 #if !defined(MBEDTLS_CONFIG_FILE)
\r
30 #include MBEDTLS_CONFIG_FILE
\r
40 * \addtogroup x509_module
\r
44 * \name Structures and functions for parsing CRLs
\r
49 * Certificate revocation list entry.
\r
50 * Contains the CA-specific serial numbers and revocation dates.
\r
52 typedef struct mbedtls_x509_crl_entry
\r
54 mbedtls_x509_buf raw;
\r
56 mbedtls_x509_buf serial;
\r
58 mbedtls_x509_time revocation_date;
\r
60 mbedtls_x509_buf entry_ext;
\r
62 struct mbedtls_x509_crl_entry *next;
\r
64 mbedtls_x509_crl_entry;
\r
67 * Certificate revocation list structure.
\r
68 * Every CRL may have multiple entries.
\r
70 typedef struct mbedtls_x509_crl
\r
72 mbedtls_x509_buf raw; /**< The raw certificate data (DER). */
\r
73 mbedtls_x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */
\r
75 int version; /**< CRL version (1=v1, 2=v2) */
\r
76 mbedtls_x509_buf sig_oid; /**< CRL signature type identifier */
\r
78 mbedtls_x509_buf issuer_raw; /**< The raw issuer data (DER). */
\r
80 mbedtls_x509_name issuer; /**< The parsed issuer data (named information object). */
\r
82 mbedtls_x509_time this_update;
\r
83 mbedtls_x509_time next_update;
\r
85 mbedtls_x509_crl_entry entry; /**< The CRL entries containing the certificate revocation times for this CA. */
\r
87 mbedtls_x509_buf crl_ext;
\r
89 mbedtls_x509_buf sig_oid2;
\r
90 mbedtls_x509_buf sig;
\r
91 mbedtls_md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */
\r
92 mbedtls_pk_type_t sig_pk; /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */
\r
93 void *sig_opts; /**< Signature options to be passed to mbedtls_pk_verify_ext(), e.g. for RSASSA-PSS */
\r
95 struct mbedtls_x509_crl *next;
\r
100 * \brief Parse a DER-encoded CRL and append it to the chained list
\r
102 * \param chain points to the start of the chain
\r
103 * \param buf buffer holding the CRL data in DER format
\r
104 * \param buflen size of the buffer
\r
105 * (including the terminating null byte for PEM data)
\r
107 * \return 0 if successful, or a specific X509 or PEM error code
\r
109 int mbedtls_x509_crl_parse_der( mbedtls_x509_crl *chain,
\r
110 const unsigned char *buf, size_t buflen );
\r
112 * \brief Parse one or more CRLs and append them to the chained list
\r
114 * \note Multiple CRLs are accepted only if using PEM format
\r
116 * \param chain points to the start of the chain
\r
117 * \param buf buffer holding the CRL data in PEM or DER format
\r
118 * \param buflen size of the buffer
\r
119 * (including the terminating null byte for PEM data)
\r
121 * \return 0 if successful, or a specific X509 or PEM error code
\r
123 int mbedtls_x509_crl_parse( mbedtls_x509_crl *chain, const unsigned char *buf, size_t buflen );
\r
125 #if defined(MBEDTLS_FS_IO)
\r
127 * \brief Load one or more CRLs and append them to the chained list
\r
129 * \note Multiple CRLs are accepted only if using PEM format
\r
131 * \param chain points to the start of the chain
\r
132 * \param path filename to read the CRLs from (in PEM or DER encoding)
\r
134 * \return 0 if successful, or a specific X509 or PEM error code
\r
136 int mbedtls_x509_crl_parse_file( mbedtls_x509_crl *chain, const char *path );
\r
137 #endif /* MBEDTLS_FS_IO */
\r
140 * \brief Returns an informational string about the CRL.
\r
142 * \param buf Buffer to write to
\r
143 * \param size Maximum size of buffer
\r
144 * \param prefix A line prefix
\r
145 * \param crl The X509 CRL to represent
\r
147 * \return The length of the string written (not including the
\r
148 * terminated nul byte), or a negative error code.
\r
150 int mbedtls_x509_crl_info( char *buf, size_t size, const char *prefix,
\r
151 const mbedtls_x509_crl *crl );
\r
154 * \brief Initialize a CRL (chain)
\r
156 * \param crl CRL chain to initialize
\r
158 void mbedtls_x509_crl_init( mbedtls_x509_crl *crl );
\r
161 * \brief Unallocate all CRL data
\r
163 * \param crl CRL chain to free
\r
165 void mbedtls_x509_crl_free( mbedtls_x509_crl *crl );
\r
168 /* \} addtogroup x509_module */
\r
174 #endif /* mbedtls_x509_crl.h */
\r