mbed TLS Build
include/mbedtls/x509_crl.h@0:cdf462088d13, 2017-01-05 (annotated)
- Committer:
- markrad
- Date:
- Thu Jan 05 00:18:44 2017 +0000
- Revision:
- 0:cdf462088d13
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
markrad | 0:cdf462088d13 | 1 | /** |
markrad | 0:cdf462088d13 | 2 | * \file x509_crl.h |
markrad | 0:cdf462088d13 | 3 | * |
markrad | 0:cdf462088d13 | 4 | * \brief X.509 certificate revocation list parsing |
markrad | 0:cdf462088d13 | 5 | * |
markrad | 0:cdf462088d13 | 6 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
markrad | 0:cdf462088d13 | 7 | * SPDX-License-Identifier: Apache-2.0 |
markrad | 0:cdf462088d13 | 8 | * |
markrad | 0:cdf462088d13 | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
markrad | 0:cdf462088d13 | 10 | * not use this file except in compliance with the License. |
markrad | 0:cdf462088d13 | 11 | * You may obtain a copy of the License at |
markrad | 0:cdf462088d13 | 12 | * |
markrad | 0:cdf462088d13 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
markrad | 0:cdf462088d13 | 14 | * |
markrad | 0:cdf462088d13 | 15 | * Unless required by applicable law or agreed to in writing, software |
markrad | 0:cdf462088d13 | 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
markrad | 0:cdf462088d13 | 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
markrad | 0:cdf462088d13 | 18 | * See the License for the specific language governing permissions and |
markrad | 0:cdf462088d13 | 19 | * limitations under the License. |
markrad | 0:cdf462088d13 | 20 | * |
markrad | 0:cdf462088d13 | 21 | * This file is part of mbed TLS (https://tls.mbed.org) |
markrad | 0:cdf462088d13 | 22 | */ |
markrad | 0:cdf462088d13 | 23 | #ifndef MBEDTLS_X509_CRL_H |
markrad | 0:cdf462088d13 | 24 | #define MBEDTLS_X509_CRL_H |
markrad | 0:cdf462088d13 | 25 | |
markrad | 0:cdf462088d13 | 26 | #if !defined(MBEDTLS_CONFIG_FILE) |
markrad | 0:cdf462088d13 | 27 | #include "config.h" |
markrad | 0:cdf462088d13 | 28 | #else |
markrad | 0:cdf462088d13 | 29 | #include MBEDTLS_CONFIG_FILE |
markrad | 0:cdf462088d13 | 30 | #endif |
markrad | 0:cdf462088d13 | 31 | |
markrad | 0:cdf462088d13 | 32 | #include "x509.h" |
markrad | 0:cdf462088d13 | 33 | |
markrad | 0:cdf462088d13 | 34 | #ifdef __cplusplus |
markrad | 0:cdf462088d13 | 35 | extern "C" { |
markrad | 0:cdf462088d13 | 36 | #endif |
markrad | 0:cdf462088d13 | 37 | |
markrad | 0:cdf462088d13 | 38 | /** |
markrad | 0:cdf462088d13 | 39 | * \addtogroup x509_module |
markrad | 0:cdf462088d13 | 40 | * \{ */ |
markrad | 0:cdf462088d13 | 41 | |
markrad | 0:cdf462088d13 | 42 | /** |
markrad | 0:cdf462088d13 | 43 | * \name Structures and functions for parsing CRLs |
markrad | 0:cdf462088d13 | 44 | * \{ |
markrad | 0:cdf462088d13 | 45 | */ |
markrad | 0:cdf462088d13 | 46 | |
markrad | 0:cdf462088d13 | 47 | /** |
markrad | 0:cdf462088d13 | 48 | * Certificate revocation list entry. |
markrad | 0:cdf462088d13 | 49 | * Contains the CA-specific serial numbers and revocation dates. |
markrad | 0:cdf462088d13 | 50 | */ |
markrad | 0:cdf462088d13 | 51 | typedef struct mbedtls_x509_crl_entry |
markrad | 0:cdf462088d13 | 52 | { |
markrad | 0:cdf462088d13 | 53 | mbedtls_x509_buf raw; |
markrad | 0:cdf462088d13 | 54 | |
markrad | 0:cdf462088d13 | 55 | mbedtls_x509_buf serial; |
markrad | 0:cdf462088d13 | 56 | |
markrad | 0:cdf462088d13 | 57 | mbedtls_x509_time revocation_date; |
markrad | 0:cdf462088d13 | 58 | |
markrad | 0:cdf462088d13 | 59 | mbedtls_x509_buf entry_ext; |
markrad | 0:cdf462088d13 | 60 | |
markrad | 0:cdf462088d13 | 61 | struct mbedtls_x509_crl_entry *next; |
markrad | 0:cdf462088d13 | 62 | } |
markrad | 0:cdf462088d13 | 63 | mbedtls_x509_crl_entry; |
markrad | 0:cdf462088d13 | 64 | |
markrad | 0:cdf462088d13 | 65 | /** |
markrad | 0:cdf462088d13 | 66 | * Certificate revocation list structure. |
markrad | 0:cdf462088d13 | 67 | * Every CRL may have multiple entries. |
markrad | 0:cdf462088d13 | 68 | */ |
markrad | 0:cdf462088d13 | 69 | typedef struct mbedtls_x509_crl |
markrad | 0:cdf462088d13 | 70 | { |
markrad | 0:cdf462088d13 | 71 | mbedtls_x509_buf raw; /**< The raw certificate data (DER). */ |
markrad | 0:cdf462088d13 | 72 | mbedtls_x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */ |
markrad | 0:cdf462088d13 | 73 | |
markrad | 0:cdf462088d13 | 74 | int version; /**< CRL version (1=v1, 2=v2) */ |
markrad | 0:cdf462088d13 | 75 | mbedtls_x509_buf sig_oid; /**< CRL signature type identifier */ |
markrad | 0:cdf462088d13 | 76 | |
markrad | 0:cdf462088d13 | 77 | mbedtls_x509_buf issuer_raw; /**< The raw issuer data (DER). */ |
markrad | 0:cdf462088d13 | 78 | |
markrad | 0:cdf462088d13 | 79 | mbedtls_x509_name issuer; /**< The parsed issuer data (named information object). */ |
markrad | 0:cdf462088d13 | 80 | |
markrad | 0:cdf462088d13 | 81 | mbedtls_x509_time this_update; |
markrad | 0:cdf462088d13 | 82 | mbedtls_x509_time next_update; |
markrad | 0:cdf462088d13 | 83 | |
markrad | 0:cdf462088d13 | 84 | mbedtls_x509_crl_entry entry; /**< The CRL entries containing the certificate revocation times for this CA. */ |
markrad | 0:cdf462088d13 | 85 | |
markrad | 0:cdf462088d13 | 86 | mbedtls_x509_buf crl_ext; |
markrad | 0:cdf462088d13 | 87 | |
markrad | 0:cdf462088d13 | 88 | mbedtls_x509_buf sig_oid2; |
markrad | 0:cdf462088d13 | 89 | mbedtls_x509_buf sig; |
markrad | 0:cdf462088d13 | 90 | mbedtls_md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */ |
markrad | 0:cdf462088d13 | 91 | mbedtls_pk_type_t sig_pk; /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */ |
markrad | 0:cdf462088d13 | 92 | void *sig_opts; /**< Signature options to be passed to mbedtls_pk_verify_ext(), e.g. for RSASSA-PSS */ |
markrad | 0:cdf462088d13 | 93 | |
markrad | 0:cdf462088d13 | 94 | struct mbedtls_x509_crl *next; |
markrad | 0:cdf462088d13 | 95 | } |
markrad | 0:cdf462088d13 | 96 | mbedtls_x509_crl; |
markrad | 0:cdf462088d13 | 97 | |
markrad | 0:cdf462088d13 | 98 | /** |
markrad | 0:cdf462088d13 | 99 | * \brief Parse a DER-encoded CRL and append it to the chained list |
markrad | 0:cdf462088d13 | 100 | * |
markrad | 0:cdf462088d13 | 101 | * \param chain points to the start of the chain |
markrad | 0:cdf462088d13 | 102 | * \param buf buffer holding the CRL data in DER format |
markrad | 0:cdf462088d13 | 103 | * \param buflen size of the buffer |
markrad | 0:cdf462088d13 | 104 | * (including the terminating null byte for PEM data) |
markrad | 0:cdf462088d13 | 105 | * |
markrad | 0:cdf462088d13 | 106 | * \return 0 if successful, or a specific X509 or PEM error code |
markrad | 0:cdf462088d13 | 107 | */ |
markrad | 0:cdf462088d13 | 108 | int mbedtls_x509_crl_parse_der( mbedtls_x509_crl *chain, |
markrad | 0:cdf462088d13 | 109 | const unsigned char *buf, size_t buflen ); |
markrad | 0:cdf462088d13 | 110 | /** |
markrad | 0:cdf462088d13 | 111 | * \brief Parse one or more CRLs and append them to the chained list |
markrad | 0:cdf462088d13 | 112 | * |
markrad | 0:cdf462088d13 | 113 | * \note Mutliple CRLs are accepted only if using PEM format |
markrad | 0:cdf462088d13 | 114 | * |
markrad | 0:cdf462088d13 | 115 | * \param chain points to the start of the chain |
markrad | 0:cdf462088d13 | 116 | * \param buf buffer holding the CRL data in PEM or DER format |
markrad | 0:cdf462088d13 | 117 | * \param buflen size of the buffer |
markrad | 0:cdf462088d13 | 118 | * (including the terminating null byte for PEM data) |
markrad | 0:cdf462088d13 | 119 | * |
markrad | 0:cdf462088d13 | 120 | * \return 0 if successful, or a specific X509 or PEM error code |
markrad | 0:cdf462088d13 | 121 | */ |
markrad | 0:cdf462088d13 | 122 | int mbedtls_x509_crl_parse( mbedtls_x509_crl *chain, const unsigned char *buf, size_t buflen ); |
markrad | 0:cdf462088d13 | 123 | |
markrad | 0:cdf462088d13 | 124 | #if defined(MBEDTLS_FS_IO) |
markrad | 0:cdf462088d13 | 125 | /** |
markrad | 0:cdf462088d13 | 126 | * \brief Load one or more CRLs and append them to the chained list |
markrad | 0:cdf462088d13 | 127 | * |
markrad | 0:cdf462088d13 | 128 | * \note Mutliple CRLs are accepted only if using PEM format |
markrad | 0:cdf462088d13 | 129 | * |
markrad | 0:cdf462088d13 | 130 | * \param chain points to the start of the chain |
markrad | 0:cdf462088d13 | 131 | * \param path filename to read the CRLs from (in PEM or DER encoding) |
markrad | 0:cdf462088d13 | 132 | * |
markrad | 0:cdf462088d13 | 133 | * \return 0 if successful, or a specific X509 or PEM error code |
markrad | 0:cdf462088d13 | 134 | */ |
markrad | 0:cdf462088d13 | 135 | int mbedtls_x509_crl_parse_file( mbedtls_x509_crl *chain, const char *path ); |
markrad | 0:cdf462088d13 | 136 | #endif /* MBEDTLS_FS_IO */ |
markrad | 0:cdf462088d13 | 137 | |
markrad | 0:cdf462088d13 | 138 | /** |
markrad | 0:cdf462088d13 | 139 | * \brief Returns an informational string about the CRL. |
markrad | 0:cdf462088d13 | 140 | * |
markrad | 0:cdf462088d13 | 141 | * \param buf Buffer to write to |
markrad | 0:cdf462088d13 | 142 | * \param size Maximum size of buffer |
markrad | 0:cdf462088d13 | 143 | * \param prefix A line prefix |
markrad | 0:cdf462088d13 | 144 | * \param crl The X509 CRL to represent |
markrad | 0:cdf462088d13 | 145 | * |
markrad | 0:cdf462088d13 | 146 | * \return The length of the string written (not including the |
markrad | 0:cdf462088d13 | 147 | * terminated nul byte), or a negative error code. |
markrad | 0:cdf462088d13 | 148 | */ |
markrad | 0:cdf462088d13 | 149 | int mbedtls_x509_crl_info( char *buf, size_t size, const char *prefix, |
markrad | 0:cdf462088d13 | 150 | const mbedtls_x509_crl *crl ); |
markrad | 0:cdf462088d13 | 151 | |
markrad | 0:cdf462088d13 | 152 | /** |
markrad | 0:cdf462088d13 | 153 | * \brief Initialize a CRL (chain) |
markrad | 0:cdf462088d13 | 154 | * |
markrad | 0:cdf462088d13 | 155 | * \param crl CRL chain to initialize |
markrad | 0:cdf462088d13 | 156 | */ |
markrad | 0:cdf462088d13 | 157 | void mbedtls_x509_crl_init( mbedtls_x509_crl *crl ); |
markrad | 0:cdf462088d13 | 158 | |
markrad | 0:cdf462088d13 | 159 | /** |
markrad | 0:cdf462088d13 | 160 | * \brief Unallocate all CRL data |
markrad | 0:cdf462088d13 | 161 | * |
markrad | 0:cdf462088d13 | 162 | * \param crl CRL chain to free |
markrad | 0:cdf462088d13 | 163 | */ |
markrad | 0:cdf462088d13 | 164 | void mbedtls_x509_crl_free( mbedtls_x509_crl *crl ); |
markrad | 0:cdf462088d13 | 165 | |
markrad | 0:cdf462088d13 | 166 | /* \} name */ |
markrad | 0:cdf462088d13 | 167 | /* \} addtogroup x509_module */ |
markrad | 0:cdf462088d13 | 168 | |
markrad | 0:cdf462088d13 | 169 | #ifdef __cplusplus |
markrad | 0:cdf462088d13 | 170 | } |
markrad | 0:cdf462088d13 | 171 | #endif |
markrad | 0:cdf462088d13 | 172 | |
markrad | 0:cdf462088d13 | 173 | #endif /* mbedtls_x509_crl.h */ |