]> git.sur5r.net Git - freertos/blob - FreeRTOS-Labs/Source/mbedtls/include/mbedtls/x509_crl.h
Add the Labs projects provided in the V10.2.1_191129 zip file.
[freertos] / FreeRTOS-Labs / Source / mbedtls / include / mbedtls / x509_crl.h
1 /**\r
2  * \file x509_crl.h\r
3  *\r
4  * \brief X.509 certificate revocation list parsing\r
5  */\r
6 /*\r
7  *  Copyright (C) 2006-2015, ARM Limited, All Rights Reserved\r
8  *  SPDX-License-Identifier: Apache-2.0\r
9  *\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
13  *\r
14  *  http://www.apache.org/licenses/LICENSE-2.0\r
15  *\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
21  *\r
22  *  This file is part of mbed TLS (https://tls.mbed.org)\r
23  */\r
24 #ifndef MBEDTLS_X509_CRL_H\r
25 #define MBEDTLS_X509_CRL_H\r
26 \r
27 #if !defined(MBEDTLS_CONFIG_FILE)\r
28 #include "config.h"\r
29 #else\r
30 #include MBEDTLS_CONFIG_FILE\r
31 #endif\r
32 \r
33 #include "x509.h"\r
34 \r
35 #ifdef __cplusplus\r
36 extern "C" {\r
37 #endif\r
38 \r
39 /**\r
40  * \addtogroup x509_module\r
41  * \{ */\r
42 \r
43 /**\r
44  * \name Structures and functions for parsing CRLs\r
45  * \{\r
46  */\r
47 \r
48 /**\r
49  * Certificate revocation list entry.\r
50  * Contains the CA-specific serial numbers and revocation dates.\r
51  */\r
52 typedef struct mbedtls_x509_crl_entry\r
53 {\r
54     mbedtls_x509_buf raw;\r
55 \r
56     mbedtls_x509_buf serial;\r
57 \r
58     mbedtls_x509_time revocation_date;\r
59 \r
60     mbedtls_x509_buf entry_ext;\r
61 \r
62     struct mbedtls_x509_crl_entry *next;\r
63 }\r
64 mbedtls_x509_crl_entry;\r
65 \r
66 /**\r
67  * Certificate revocation list structure.\r
68  * Every CRL may have multiple entries.\r
69  */\r
70 typedef struct mbedtls_x509_crl\r
71 {\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
74 \r
75     int version;            /**< CRL version (1=v1, 2=v2) */\r
76     mbedtls_x509_buf sig_oid;       /**< CRL signature type identifier */\r
77 \r
78     mbedtls_x509_buf issuer_raw;    /**< The raw issuer data (DER). */\r
79 \r
80     mbedtls_x509_name issuer;       /**< The parsed issuer data (named information object). */\r
81 \r
82     mbedtls_x509_time this_update;\r
83     mbedtls_x509_time next_update;\r
84 \r
85     mbedtls_x509_crl_entry entry;   /**< The CRL entries containing the certificate revocation times for this CA. */\r
86 \r
87     mbedtls_x509_buf crl_ext;\r
88 \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
94 \r
95     struct mbedtls_x509_crl *next;\r
96 }\r
97 mbedtls_x509_crl;\r
98 \r
99 /**\r
100  * \brief          Parse a DER-encoded CRL and append it to the chained list\r
101  *\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
106  *\r
107  * \return         0 if successful, or a specific X509 or PEM error code\r
108  */\r
109 int mbedtls_x509_crl_parse_der( mbedtls_x509_crl *chain,\r
110                         const unsigned char *buf, size_t buflen );\r
111 /**\r
112  * \brief          Parse one or more CRLs and append them to the chained list\r
113  *\r
114  * \note           Multiple CRLs are accepted only if using PEM format\r
115  *\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
120  *\r
121  * \return         0 if successful, or a specific X509 or PEM error code\r
122  */\r
123 int mbedtls_x509_crl_parse( mbedtls_x509_crl *chain, const unsigned char *buf, size_t buflen );\r
124 \r
125 #if defined(MBEDTLS_FS_IO)\r
126 /**\r
127  * \brief          Load one or more CRLs and append them to the chained list\r
128  *\r
129  * \note           Multiple CRLs are accepted only if using PEM format\r
130  *\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
133  *\r
134  * \return         0 if successful, or a specific X509 or PEM error code\r
135  */\r
136 int mbedtls_x509_crl_parse_file( mbedtls_x509_crl *chain, const char *path );\r
137 #endif /* MBEDTLS_FS_IO */\r
138 \r
139 /**\r
140  * \brief          Returns an informational string about the CRL.\r
141  *\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
146  *\r
147  * \return         The length of the string written (not including the\r
148  *                 terminated nul byte), or a negative error code.\r
149  */\r
150 int mbedtls_x509_crl_info( char *buf, size_t size, const char *prefix,\r
151                    const mbedtls_x509_crl *crl );\r
152 \r
153 /**\r
154  * \brief          Initialize a CRL (chain)\r
155  *\r
156  * \param crl      CRL chain to initialize\r
157  */\r
158 void mbedtls_x509_crl_init( mbedtls_x509_crl *crl );\r
159 \r
160 /**\r
161  * \brief          Unallocate all CRL data\r
162  *\r
163  * \param crl      CRL chain to free\r
164  */\r
165 void mbedtls_x509_crl_free( mbedtls_x509_crl *crl );\r
166 \r
167 /* \} name */\r
168 /* \} addtogroup x509_module */\r
169 \r
170 #ifdef __cplusplus\r
171 }\r
172 #endif\r
173 \r
174 #endif /* mbedtls_x509_crl.h */\r