Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 1 | /* |
Manuel Pégourié-Gonnard | 1c082f3 | 2014-06-12 22:34:55 +0200 | [diff] [blame] | 2 | * X.509 Certidicate Revocation List (CRL) parsing |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 3 | * |
Manuel Pégourié-Gonnard | 6fb8187 | 2015-07-27 11:11:48 +0200 | [diff] [blame] | 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
Manuel Pégourié-Gonnard | 37ff140 | 2015-09-04 14:21:07 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: Apache-2.0 |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 8 | * not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 18 | * |
Manuel Pégourié-Gonnard | fe44643 | 2015-03-06 13:17:10 +0000 | [diff] [blame] | 19 | * This file is part of mbed TLS (https://tls.mbed.org) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 20 | */ |
| 21 | /* |
| 22 | * The ITU-T X.509 standard defines a certificate format for PKI. |
| 23 | * |
Manuel Pégourié-Gonnard | 1c082f3 | 2014-06-12 22:34:55 +0200 | [diff] [blame] | 24 | * http://www.ietf.org/rfc/rfc5280.txt (Certificates and CRLs) |
| 25 | * http://www.ietf.org/rfc/rfc3279.txt (Alg IDs for CRLs) |
| 26 | * http://www.ietf.org/rfc/rfc2986.txt (CSRs, aka PKCS#10) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 27 | * |
| 28 | * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf |
| 29 | * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf |
| 30 | */ |
| 31 | |
Gilles Peskine | db09ef6 | 2020-06-03 01:43:33 +0200 | [diff] [blame^] | 32 | #include "common.h" |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 33 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 34 | #if defined(MBEDTLS_X509_CRL_PARSE_C) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 35 | |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 36 | #include "mbedtls/x509_crl.h" |
Janos Follath | 73c616b | 2019-12-18 15:07:04 +0000 | [diff] [blame] | 37 | #include "mbedtls/error.h" |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 38 | #include "mbedtls/oid.h" |
Andres Amaya Garcia | 1f6301b | 2018-04-17 09:51:09 -0500 | [diff] [blame] | 39 | #include "mbedtls/platform_util.h" |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 40 | |
| 41 | #include <string.h> |
| 42 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 43 | #if defined(MBEDTLS_PEM_PARSE_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 44 | #include "mbedtls/pem.h" |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 45 | #endif |
| 46 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 47 | #if defined(MBEDTLS_PLATFORM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 48 | #include "mbedtls/platform.h" |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 49 | #else |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 50 | #include <stdlib.h> |
Manuel Pégourié-Gonnard | 981732b | 2015-02-17 15:46:45 +0000 | [diff] [blame] | 51 | #include <stdio.h> |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 52 | #define mbedtls_free free |
Manuel Pégourié-Gonnard | 7551cb9 | 2015-05-26 16:04:06 +0200 | [diff] [blame] | 53 | #define mbedtls_calloc calloc |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 54 | #define mbedtls_snprintf snprintf |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 55 | #endif |
| 56 | |
Paul Bakker | fa6a620 | 2013-10-28 18:48:30 +0100 | [diff] [blame] | 57 | #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 58 | #include <windows.h> |
| 59 | #else |
| 60 | #include <time.h> |
| 61 | #endif |
| 62 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 63 | #if defined(MBEDTLS_FS_IO) || defined(EFIX64) || defined(EFI32) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 64 | #include <stdio.h> |
| 65 | #endif |
| 66 | |
| 67 | /* |
| 68 | * Version ::= INTEGER { v1(0), v2(1) } |
| 69 | */ |
| 70 | static int x509_crl_get_version( unsigned char **p, |
| 71 | const unsigned char *end, |
| 72 | int *ver ) |
| 73 | { |
Janos Follath | 865b3eb | 2019-12-16 11:46:15 +0000 | [diff] [blame] | 74 | int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 75 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 76 | if( ( ret = mbedtls_asn1_get_int( p, end, ver ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 77 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 78 | if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 79 | { |
| 80 | *ver = 0; |
| 81 | return( 0 ); |
| 82 | } |
| 83 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 84 | return( MBEDTLS_ERR_X509_INVALID_VERSION + ret ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | return( 0 ); |
| 88 | } |
| 89 | |
| 90 | /* |
Manuel Pégourié-Gonnard | fd3e4fb | 2018-03-13 11:53:30 +0100 | [diff] [blame] | 91 | * X.509 CRL v2 extensions |
| 92 | * |
| 93 | * We currently don't parse any extension's content, but we do check that the |
| 94 | * list of extensions is well-formed and abort on critical extensions (that |
| 95 | * are unsupported as we don't support any extension so far) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 96 | */ |
| 97 | static int x509_get_crl_ext( unsigned char **p, |
| 98 | const unsigned char *end, |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 99 | mbedtls_x509_buf *ext ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 100 | { |
Janos Follath | 865b3eb | 2019-12-16 11:46:15 +0000 | [diff] [blame] | 101 | int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 102 | |
Hanno Becker | 12f62fb | 2019-02-12 17:22:36 +0000 | [diff] [blame] | 103 | if( *p == end ) |
| 104 | return( 0 ); |
| 105 | |
Manuel Pégourié-Gonnard | fd3e4fb | 2018-03-13 11:53:30 +0100 | [diff] [blame] | 106 | /* |
| 107 | * crlExtensions [0] EXPLICIT Extensions OPTIONAL |
| 108 | * -- if present, version MUST be v2 |
| 109 | */ |
| 110 | if( ( ret = mbedtls_x509_get_ext( p, end, ext, 0 ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 111 | return( ret ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 112 | |
Hanno Becker | 12f62fb | 2019-02-12 17:22:36 +0000 | [diff] [blame] | 113 | end = ext->p + ext->len; |
| 114 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 115 | while( *p < end ) |
| 116 | { |
Manuel Pégourié-Gonnard | fd3e4fb | 2018-03-13 11:53:30 +0100 | [diff] [blame] | 117 | /* |
| 118 | * Extension ::= SEQUENCE { |
| 119 | * extnID OBJECT IDENTIFIER, |
| 120 | * critical BOOLEAN DEFAULT FALSE, |
| 121 | * extnValue OCTET STRING } |
| 122 | */ |
| 123 | int is_critical = 0; |
| 124 | const unsigned char *end_ext_data; |
| 125 | size_t len; |
| 126 | |
| 127 | /* Get enclosing sequence tag */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 128 | if( ( ret = mbedtls_asn1_get_tag( p, end, &len, |
| 129 | MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) |
| 130 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 131 | |
Manuel Pégourié-Gonnard | fd3e4fb | 2018-03-13 11:53:30 +0100 | [diff] [blame] | 132 | end_ext_data = *p + len; |
| 133 | |
| 134 | /* Get OID (currently ignored) */ |
| 135 | if( ( ret = mbedtls_asn1_get_tag( p, end_ext_data, &len, |
| 136 | MBEDTLS_ASN1_OID ) ) != 0 ) |
| 137 | { |
| 138 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); |
| 139 | } |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 140 | *p += len; |
Manuel Pégourié-Gonnard | fd3e4fb | 2018-03-13 11:53:30 +0100 | [diff] [blame] | 141 | |
| 142 | /* Get optional critical */ |
| 143 | if( ( ret = mbedtls_asn1_get_bool( p, end_ext_data, |
| 144 | &is_critical ) ) != 0 && |
| 145 | ( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) ) |
| 146 | { |
| 147 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); |
| 148 | } |
| 149 | |
| 150 | /* Data should be octet string type */ |
| 151 | if( ( ret = mbedtls_asn1_get_tag( p, end_ext_data, &len, |
| 152 | MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) |
| 153 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); |
| 154 | |
| 155 | /* Ignore data so far and just check its length */ |
| 156 | *p += len; |
| 157 | if( *p != end_ext_data ) |
| 158 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + |
| 159 | MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); |
| 160 | |
| 161 | /* Abort on (unsupported) critical extensions */ |
| 162 | if( is_critical ) |
| 163 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + |
| 164 | MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | if( *p != end ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 168 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + |
| 169 | MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 170 | |
| 171 | return( 0 ); |
| 172 | } |
| 173 | |
| 174 | /* |
| 175 | * X.509 CRL v2 entry extensions (no extensions parsed yet.) |
| 176 | */ |
| 177 | static int x509_get_crl_entry_ext( unsigned char **p, |
| 178 | const unsigned char *end, |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 179 | mbedtls_x509_buf *ext ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 180 | { |
Janos Follath | 865b3eb | 2019-12-16 11:46:15 +0000 | [diff] [blame] | 181 | int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 182 | size_t len = 0; |
| 183 | |
| 184 | /* OPTIONAL */ |
Paul Bakker | 66d5d07 | 2014-06-17 16:39:18 +0200 | [diff] [blame] | 185 | if( end <= *p ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 186 | return( 0 ); |
| 187 | |
| 188 | ext->tag = **p; |
| 189 | ext->p = *p; |
| 190 | |
| 191 | /* |
| 192 | * Get CRL-entry extension sequence header |
| 193 | * crlEntryExtensions Extensions OPTIONAL -- if present, MUST be v2 |
| 194 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 195 | if( ( ret = mbedtls_asn1_get_tag( p, end, &ext->len, |
| 196 | MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 197 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 198 | if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 199 | { |
| 200 | ext->p = NULL; |
| 201 | return( 0 ); |
| 202 | } |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 203 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 204 | } |
| 205 | |
Paul Bakker | 9af723c | 2014-05-01 13:03:14 +0200 | [diff] [blame] | 206 | end = *p + ext->len; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 207 | |
| 208 | if( end != *p + ext->len ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 209 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + |
| 210 | MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 211 | |
| 212 | while( *p < end ) |
| 213 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 214 | if( ( ret = mbedtls_asn1_get_tag( p, end, &len, |
| 215 | MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) |
| 216 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 217 | |
| 218 | *p += len; |
| 219 | } |
| 220 | |
| 221 | if( *p != end ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 222 | return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + |
| 223 | MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 224 | |
| 225 | return( 0 ); |
| 226 | } |
| 227 | |
| 228 | /* |
| 229 | * X.509 CRL Entries |
| 230 | */ |
| 231 | static int x509_get_entries( unsigned char **p, |
| 232 | const unsigned char *end, |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 233 | mbedtls_x509_crl_entry *entry ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 234 | { |
Janos Follath | 865b3eb | 2019-12-16 11:46:15 +0000 | [diff] [blame] | 235 | int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 236 | size_t entry_len; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 237 | mbedtls_x509_crl_entry *cur_entry = entry; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 238 | |
| 239 | if( *p == end ) |
| 240 | return( 0 ); |
| 241 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 242 | if( ( ret = mbedtls_asn1_get_tag( p, end, &entry_len, |
| 243 | MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 244 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 245 | if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 246 | return( 0 ); |
| 247 | |
| 248 | return( ret ); |
| 249 | } |
| 250 | |
| 251 | end = *p + entry_len; |
| 252 | |
| 253 | while( *p < end ) |
| 254 | { |
| 255 | size_t len2; |
| 256 | const unsigned char *end2; |
| 257 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 258 | if( ( ret = mbedtls_asn1_get_tag( p, end, &len2, |
| 259 | MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 260 | { |
| 261 | return( ret ); |
| 262 | } |
| 263 | |
| 264 | cur_entry->raw.tag = **p; |
| 265 | cur_entry->raw.p = *p; |
| 266 | cur_entry->raw.len = len2; |
| 267 | end2 = *p + len2; |
| 268 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 269 | if( ( ret = mbedtls_x509_get_serial( p, end2, &cur_entry->serial ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 270 | return( ret ); |
| 271 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 272 | if( ( ret = mbedtls_x509_get_time( p, end2, |
Paul Bakker | b9e4e2c | 2014-05-01 14:18:25 +0200 | [diff] [blame] | 273 | &cur_entry->revocation_date ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 274 | return( ret ); |
| 275 | |
Paul Bakker | b9e4e2c | 2014-05-01 14:18:25 +0200 | [diff] [blame] | 276 | if( ( ret = x509_get_crl_entry_ext( p, end2, |
| 277 | &cur_entry->entry_ext ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 278 | return( ret ); |
| 279 | |
Paul Bakker | 66d5d07 | 2014-06-17 16:39:18 +0200 | [diff] [blame] | 280 | if( *p < end ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 281 | { |
Manuel Pégourié-Gonnard | 7551cb9 | 2015-05-26 16:04:06 +0200 | [diff] [blame] | 282 | cur_entry->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_crl_entry ) ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 283 | |
| 284 | if( cur_entry->next == NULL ) |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 285 | return( MBEDTLS_ERR_X509_ALLOC_FAILED ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 286 | |
| 287 | cur_entry = cur_entry->next; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 288 | } |
| 289 | } |
| 290 | |
| 291 | return( 0 ); |
| 292 | } |
| 293 | |
| 294 | /* |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 295 | * Parse one CRLs in DER format and append it to the chained list |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 296 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 297 | int mbedtls_x509_crl_parse_der( mbedtls_x509_crl *chain, |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 298 | const unsigned char *buf, size_t buflen ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 299 | { |
Janos Follath | 865b3eb | 2019-12-16 11:46:15 +0000 | [diff] [blame] | 300 | int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 301 | size_t len; |
Andres Amaya Garcia | f1ee635 | 2017-07-06 10:06:58 +0100 | [diff] [blame] | 302 | unsigned char *p = NULL, *end = NULL; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 303 | mbedtls_x509_buf sig_params1, sig_params2, sig_oid2; |
| 304 | mbedtls_x509_crl *crl = chain; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 305 | |
| 306 | /* |
| 307 | * Check for valid input |
| 308 | */ |
| 309 | if( crl == NULL || buf == NULL ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 310 | return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 311 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 312 | memset( &sig_params1, 0, sizeof( mbedtls_x509_buf ) ); |
| 313 | memset( &sig_params2, 0, sizeof( mbedtls_x509_buf ) ); |
| 314 | memset( &sig_oid2, 0, sizeof( mbedtls_x509_buf ) ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 315 | |
| 316 | /* |
| 317 | * Add new CRL on the end of the chain if needed. |
| 318 | */ |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 319 | while( crl->version != 0 && crl->next != NULL ) |
| 320 | crl = crl->next; |
| 321 | |
Paul Bakker | 66d5d07 | 2014-06-17 16:39:18 +0200 | [diff] [blame] | 322 | if( crl->version != 0 && crl->next == NULL ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 323 | { |
Manuel Pégourié-Gonnard | 7551cb9 | 2015-05-26 16:04:06 +0200 | [diff] [blame] | 324 | crl->next = mbedtls_calloc( 1, sizeof( mbedtls_x509_crl ) ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 325 | |
| 326 | if( crl->next == NULL ) |
| 327 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 328 | mbedtls_x509_crl_free( crl ); |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 329 | return( MBEDTLS_ERR_X509_ALLOC_FAILED ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 330 | } |
| 331 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 332 | mbedtls_x509_crl_init( crl->next ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 333 | crl = crl->next; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 334 | } |
| 335 | |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 336 | /* |
| 337 | * Copy raw DER-encoded CRL |
| 338 | */ |
Andres Amaya Garcia | cb5123f | 2017-12-06 09:39:23 +0000 | [diff] [blame] | 339 | if( buflen == 0 ) |
| 340 | return( MBEDTLS_ERR_X509_INVALID_FORMAT ); |
Andres Amaya Garcia | c9d6226 | 2017-12-12 20:15:03 +0000 | [diff] [blame] | 341 | |
| 342 | p = mbedtls_calloc( 1, buflen ); |
| 343 | if( p == NULL ) |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 344 | return( MBEDTLS_ERR_X509_ALLOC_FAILED ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 345 | |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 346 | memcpy( p, buf, buflen ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 347 | |
| 348 | crl->raw.p = p; |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 349 | crl->raw.len = buflen; |
| 350 | |
| 351 | end = p + buflen; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 352 | |
| 353 | /* |
| 354 | * CertificateList ::= SEQUENCE { |
| 355 | * tbsCertList TBSCertList, |
| 356 | * signatureAlgorithm AlgorithmIdentifier, |
| 357 | * signatureValue BIT STRING } |
| 358 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 359 | if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, |
| 360 | MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 361 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 362 | mbedtls_x509_crl_free( crl ); |
| 363 | return( MBEDTLS_ERR_X509_INVALID_FORMAT ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | if( len != (size_t) ( end - p ) ) |
| 367 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 368 | mbedtls_x509_crl_free( crl ); |
| 369 | return( MBEDTLS_ERR_X509_INVALID_FORMAT + |
| 370 | MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | /* |
| 374 | * TBSCertList ::= SEQUENCE { |
| 375 | */ |
| 376 | crl->tbs.p = p; |
| 377 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 378 | if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, |
| 379 | MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 380 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 381 | mbedtls_x509_crl_free( crl ); |
| 382 | return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | end = p + len; |
| 386 | crl->tbs.len = end - crl->tbs.p; |
| 387 | |
| 388 | /* |
| 389 | * Version ::= INTEGER OPTIONAL { v1(0), v2(1) } |
| 390 | * -- if present, MUST be v2 |
| 391 | * |
| 392 | * signature AlgorithmIdentifier |
| 393 | */ |
| 394 | if( ( ret = x509_crl_get_version( &p, end, &crl->version ) ) != 0 || |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 395 | ( ret = mbedtls_x509_get_alg( &p, end, &crl->sig_oid, &sig_params1 ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 396 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 397 | mbedtls_x509_crl_free( crl ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 398 | return( ret ); |
| 399 | } |
| 400 | |
Andres AG | 4f753c1 | 2017-02-10 14:39:58 +0000 | [diff] [blame] | 401 | if( crl->version < 0 || crl->version > 1 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 402 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 403 | mbedtls_x509_crl_free( crl ); |
| 404 | return( MBEDTLS_ERR_X509_UNKNOWN_VERSION ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 405 | } |
| 406 | |
Andres AG | 4f753c1 | 2017-02-10 14:39:58 +0000 | [diff] [blame] | 407 | crl->version++; |
| 408 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 409 | if( ( ret = mbedtls_x509_get_sig_alg( &crl->sig_oid, &sig_params1, |
Manuel Pégourié-Gonnard | f75f2f7 | 2014-06-05 15:14:28 +0200 | [diff] [blame] | 410 | &crl->sig_md, &crl->sig_pk, |
| 411 | &crl->sig_opts ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 412 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 413 | mbedtls_x509_crl_free( crl ); |
| 414 | return( MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | /* |
| 418 | * issuer Name |
| 419 | */ |
| 420 | crl->issuer_raw.p = p; |
| 421 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 422 | if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, |
| 423 | MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 424 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 425 | mbedtls_x509_crl_free( crl ); |
| 426 | return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 427 | } |
| 428 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 429 | if( ( ret = mbedtls_x509_get_name( &p, p + len, &crl->issuer ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 430 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 431 | mbedtls_x509_crl_free( crl ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 432 | return( ret ); |
| 433 | } |
| 434 | |
| 435 | crl->issuer_raw.len = p - crl->issuer_raw.p; |
| 436 | |
| 437 | /* |
| 438 | * thisUpdate Time |
| 439 | * nextUpdate Time OPTIONAL |
| 440 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 441 | if( ( ret = mbedtls_x509_get_time( &p, end, &crl->this_update ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 442 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 443 | mbedtls_x509_crl_free( crl ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 444 | return( ret ); |
| 445 | } |
| 446 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 447 | if( ( ret = mbedtls_x509_get_time( &p, end, &crl->next_update ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 448 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 449 | if( ret != ( MBEDTLS_ERR_X509_INVALID_DATE + |
| 450 | MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) && |
| 451 | ret != ( MBEDTLS_ERR_X509_INVALID_DATE + |
| 452 | MBEDTLS_ERR_ASN1_OUT_OF_DATA ) ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 453 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 454 | mbedtls_x509_crl_free( crl ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 455 | return( ret ); |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | /* |
| 460 | * revokedCertificates SEQUENCE OF SEQUENCE { |
| 461 | * userCertificate CertificateSerialNumber, |
| 462 | * revocationDate Time, |
| 463 | * crlEntryExtensions Extensions OPTIONAL |
| 464 | * -- if present, MUST be v2 |
| 465 | * } OPTIONAL |
| 466 | */ |
| 467 | if( ( ret = x509_get_entries( &p, end, &crl->entry ) ) != 0 ) |
| 468 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 469 | mbedtls_x509_crl_free( crl ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 470 | return( ret ); |
| 471 | } |
| 472 | |
| 473 | /* |
| 474 | * crlExtensions EXPLICIT Extensions OPTIONAL |
| 475 | * -- if present, MUST be v2 |
| 476 | */ |
| 477 | if( crl->version == 2 ) |
| 478 | { |
| 479 | ret = x509_get_crl_ext( &p, end, &crl->crl_ext ); |
| 480 | |
| 481 | if( ret != 0 ) |
| 482 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 483 | mbedtls_x509_crl_free( crl ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 484 | return( ret ); |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | if( p != end ) |
| 489 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 490 | mbedtls_x509_crl_free( crl ); |
| 491 | return( MBEDTLS_ERR_X509_INVALID_FORMAT + |
| 492 | MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | end = crl->raw.p + crl->raw.len; |
| 496 | |
| 497 | /* |
| 498 | * signatureAlgorithm AlgorithmIdentifier, |
| 499 | * signatureValue BIT STRING |
| 500 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 501 | if( ( ret = mbedtls_x509_get_alg( &p, end, &sig_oid2, &sig_params2 ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 502 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 503 | mbedtls_x509_crl_free( crl ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 504 | return( ret ); |
| 505 | } |
| 506 | |
Manuel Pégourié-Gonnard | 1022fed | 2015-03-27 16:30:47 +0100 | [diff] [blame] | 507 | if( crl->sig_oid.len != sig_oid2.len || |
| 508 | memcmp( crl->sig_oid.p, sig_oid2.p, crl->sig_oid.len ) != 0 || |
Manuel Pégourié-Gonnard | dddbb1d | 2014-06-05 17:02:24 +0200 | [diff] [blame] | 509 | sig_params1.len != sig_params2.len || |
Manuel Pégourié-Gonnard | 159c524 | 2015-04-30 11:15:22 +0200 | [diff] [blame] | 510 | ( sig_params1.len != 0 && |
| 511 | memcmp( sig_params1.p, sig_params2.p, sig_params1.len ) != 0 ) ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 512 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 513 | mbedtls_x509_crl_free( crl ); |
| 514 | return( MBEDTLS_ERR_X509_SIG_MISMATCH ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 515 | } |
| 516 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 517 | if( ( ret = mbedtls_x509_get_sig( &p, end, &crl->sig ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 518 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 519 | mbedtls_x509_crl_free( crl ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 520 | return( ret ); |
| 521 | } |
| 522 | |
| 523 | if( p != end ) |
| 524 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 525 | mbedtls_x509_crl_free( crl ); |
| 526 | return( MBEDTLS_ERR_X509_INVALID_FORMAT + |
| 527 | MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 528 | } |
| 529 | |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 530 | return( 0 ); |
| 531 | } |
| 532 | |
| 533 | /* |
| 534 | * Parse one or more CRLs and add them to the chained list |
| 535 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 536 | int mbedtls_x509_crl_parse( mbedtls_x509_crl *chain, const unsigned char *buf, size_t buflen ) |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 537 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 538 | #if defined(MBEDTLS_PEM_PARSE_C) |
Janos Follath | 865b3eb | 2019-12-16 11:46:15 +0000 | [diff] [blame] | 539 | int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; |
Benjamin Kier | 3605073 | 2019-05-30 14:49:17 -0400 | [diff] [blame] | 540 | size_t use_len = 0; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 541 | mbedtls_pem_context pem; |
Manuel Pégourié-Gonnard | 6ed2d92 | 2014-11-19 19:05:03 +0100 | [diff] [blame] | 542 | int is_pem = 0; |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 543 | |
| 544 | if( chain == NULL || buf == NULL ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 545 | return( MBEDTLS_ERR_X509_BAD_INPUT_DATA ); |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 546 | |
Manuel Pégourié-Gonnard | 6ed2d92 | 2014-11-19 19:05:03 +0100 | [diff] [blame] | 547 | do |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 548 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 549 | mbedtls_pem_init( &pem ); |
Manuel Pégourié-Gonnard | 43b37cb | 2015-05-12 11:20:10 +0200 | [diff] [blame] | 550 | |
Simon Butcher | 97e8290 | 2016-05-19 00:22:37 +0100 | [diff] [blame] | 551 | // Avoid calling mbedtls_pem_read_buffer() on non-null-terminated |
| 552 | // string |
| 553 | if( buflen == 0 || buf[buflen - 1] != '\0' ) |
| 554 | ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; |
| 555 | else |
| 556 | ret = mbedtls_pem_read_buffer( &pem, |
| 557 | "-----BEGIN X509 CRL-----", |
| 558 | "-----END X509 CRL-----", |
| 559 | buf, NULL, 0, &use_len ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 560 | |
Manuel Pégourié-Gonnard | 6ed2d92 | 2014-11-19 19:05:03 +0100 | [diff] [blame] | 561 | if( ret == 0 ) |
| 562 | { |
| 563 | /* |
| 564 | * Was PEM encoded |
| 565 | */ |
| 566 | is_pem = 1; |
| 567 | |
| 568 | buflen -= use_len; |
| 569 | buf += use_len; |
| 570 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 571 | if( ( ret = mbedtls_x509_crl_parse_der( chain, |
Manuel Pégourié-Gonnard | 6ed2d92 | 2014-11-19 19:05:03 +0100 | [diff] [blame] | 572 | pem.buf, pem.buflen ) ) != 0 ) |
| 573 | { |
Andres AG | 5708dcb | 2016-12-08 17:19:21 +0000 | [diff] [blame] | 574 | mbedtls_pem_free( &pem ); |
Manuel Pégourié-Gonnard | 6ed2d92 | 2014-11-19 19:05:03 +0100 | [diff] [blame] | 575 | return( ret ); |
| 576 | } |
Manuel Pégourié-Gonnard | 6ed2d92 | 2014-11-19 19:05:03 +0100 | [diff] [blame] | 577 | } |
Andres AG | 939954c | 2016-12-08 17:08:44 +0000 | [diff] [blame] | 578 | else if( is_pem ) |
Manuel Pégourié-Gonnard | 6ed2d92 | 2014-11-19 19:05:03 +0100 | [diff] [blame] | 579 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 580 | mbedtls_pem_free( &pem ); |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 581 | return( ret ); |
Manuel Pégourié-Gonnard | 6ed2d92 | 2014-11-19 19:05:03 +0100 | [diff] [blame] | 582 | } |
Andres AG | 5708dcb | 2016-12-08 17:19:21 +0000 | [diff] [blame] | 583 | |
| 584 | mbedtls_pem_free( &pem ); |
Manuel Pégourié-Gonnard | 6ed2d92 | 2014-11-19 19:05:03 +0100 | [diff] [blame] | 585 | } |
Manuel Pégourié-Gonnard | 43b37cb | 2015-05-12 11:20:10 +0200 | [diff] [blame] | 586 | /* In the PEM case, buflen is 1 at the end, for the terminated NULL byte. |
| 587 | * And a valid CRL cannot be less than 1 byte anyway. */ |
| 588 | while( is_pem && buflen > 1 ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 589 | |
Manuel Pégourié-Gonnard | 6ed2d92 | 2014-11-19 19:05:03 +0100 | [diff] [blame] | 590 | if( is_pem ) |
| 591 | return( 0 ); |
Manuel Pégourié-Gonnard | 426d4ae | 2014-11-19 16:58:28 +0100 | [diff] [blame] | 592 | else |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 593 | #endif /* MBEDTLS_PEM_PARSE_C */ |
| 594 | return( mbedtls_x509_crl_parse_der( chain, buf, buflen ) ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 595 | } |
| 596 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 597 | #if defined(MBEDTLS_FS_IO) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 598 | /* |
| 599 | * Load one or more CRLs and add them to the chained list |
| 600 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 601 | int mbedtls_x509_crl_parse_file( mbedtls_x509_crl *chain, const char *path ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 602 | { |
Janos Follath | 865b3eb | 2019-12-16 11:46:15 +0000 | [diff] [blame] | 603 | int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 604 | size_t n; |
| 605 | unsigned char *buf; |
| 606 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 607 | if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 608 | return( ret ); |
| 609 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 610 | ret = mbedtls_x509_crl_parse( chain, buf, n ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 611 | |
Andres Amaya Garcia | 1f6301b | 2018-04-17 09:51:09 -0500 | [diff] [blame] | 612 | mbedtls_platform_zeroize( buf, n ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 613 | mbedtls_free( buf ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 614 | |
| 615 | return( ret ); |
| 616 | } |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 617 | #endif /* MBEDTLS_FS_IO */ |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 618 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 619 | /* |
| 620 | * Return an informational string about the certificate. |
| 621 | */ |
| 622 | #define BEFORE_COLON 14 |
| 623 | #define BC "14" |
| 624 | /* |
| 625 | * Return an informational string about the CRL. |
| 626 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 627 | int mbedtls_x509_crl_info( char *buf, size_t size, const char *prefix, |
| 628 | const mbedtls_x509_crl *crl ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 629 | { |
Janos Follath | 865b3eb | 2019-12-16 11:46:15 +0000 | [diff] [blame] | 630 | int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 631 | size_t n; |
| 632 | char *p; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 633 | const mbedtls_x509_crl_entry *entry; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 634 | |
| 635 | p = buf; |
| 636 | n = size; |
| 637 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 638 | ret = mbedtls_snprintf( p, n, "%sCRL version : %d", |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 639 | prefix, crl->version ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 640 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 641 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 642 | ret = mbedtls_snprintf( p, n, "\n%sissuer name : ", prefix ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 643 | MBEDTLS_X509_SAFE_SNPRINTF; |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 644 | ret = mbedtls_x509_dn_gets( p, n, &crl->issuer ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 645 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 646 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 647 | ret = mbedtls_snprintf( p, n, "\n%sthis update : " \ |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 648 | "%04d-%02d-%02d %02d:%02d:%02d", prefix, |
| 649 | crl->this_update.year, crl->this_update.mon, |
| 650 | crl->this_update.day, crl->this_update.hour, |
| 651 | crl->this_update.min, crl->this_update.sec ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 652 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 653 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 654 | ret = mbedtls_snprintf( p, n, "\n%snext update : " \ |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 655 | "%04d-%02d-%02d %02d:%02d:%02d", prefix, |
| 656 | crl->next_update.year, crl->next_update.mon, |
| 657 | crl->next_update.day, crl->next_update.hour, |
| 658 | crl->next_update.min, crl->next_update.sec ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 659 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 660 | |
| 661 | entry = &crl->entry; |
| 662 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 663 | ret = mbedtls_snprintf( p, n, "\n%sRevoked certificates:", |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 664 | prefix ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 665 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 666 | |
| 667 | while( entry != NULL && entry->raw.len != 0 ) |
| 668 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 669 | ret = mbedtls_snprintf( p, n, "\n%sserial number: ", |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 670 | prefix ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 671 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 672 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 673 | ret = mbedtls_x509_serial_gets( p, n, &entry->serial ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 674 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 675 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 676 | ret = mbedtls_snprintf( p, n, " revocation date: " \ |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 677 | "%04d-%02d-%02d %02d:%02d:%02d", |
| 678 | entry->revocation_date.year, entry->revocation_date.mon, |
| 679 | entry->revocation_date.day, entry->revocation_date.hour, |
| 680 | entry->revocation_date.min, entry->revocation_date.sec ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 681 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 682 | |
| 683 | entry = entry->next; |
| 684 | } |
| 685 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 686 | ret = mbedtls_snprintf( p, n, "\n%ssigned using : ", prefix ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 687 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 688 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 689 | ret = mbedtls_x509_sig_alg_gets( p, n, &crl->sig_oid, crl->sig_pk, crl->sig_md, |
Manuel Pégourié-Gonnard | bf696d0 | 2014-06-05 17:07:30 +0200 | [diff] [blame] | 690 | crl->sig_opts ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 691 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 692 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 693 | ret = mbedtls_snprintf( p, n, "\n" ); |
Manuel Pégourié-Gonnard | 1685368 | 2015-06-22 11:12:02 +0200 | [diff] [blame] | 694 | MBEDTLS_X509_SAFE_SNPRINTF; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 695 | |
| 696 | return( (int) ( size - n ) ); |
| 697 | } |
| 698 | |
| 699 | /* |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 700 | * Initialize a CRL chain |
| 701 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 702 | void mbedtls_x509_crl_init( mbedtls_x509_crl *crl ) |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 703 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 704 | memset( crl, 0, sizeof(mbedtls_x509_crl) ); |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | /* |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 708 | * Unallocate all CRL data |
| 709 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 710 | void mbedtls_x509_crl_free( mbedtls_x509_crl *crl ) |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 711 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 712 | mbedtls_x509_crl *crl_cur = crl; |
| 713 | mbedtls_x509_crl *crl_prv; |
| 714 | mbedtls_x509_name *name_cur; |
| 715 | mbedtls_x509_name *name_prv; |
| 716 | mbedtls_x509_crl_entry *entry_cur; |
| 717 | mbedtls_x509_crl_entry *entry_prv; |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 718 | |
| 719 | if( crl == NULL ) |
| 720 | return; |
| 721 | |
| 722 | do |
| 723 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 724 | #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) |
| 725 | mbedtls_free( crl_cur->sig_opts ); |
Manuel Pégourié-Gonnard | f75f2f7 | 2014-06-05 15:14:28 +0200 | [diff] [blame] | 726 | #endif |
| 727 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 728 | name_cur = crl_cur->issuer.next; |
| 729 | while( name_cur != NULL ) |
| 730 | { |
| 731 | name_prv = name_cur; |
| 732 | name_cur = name_cur->next; |
Andres Amaya Garcia | 1f6301b | 2018-04-17 09:51:09 -0500 | [diff] [blame] | 733 | mbedtls_platform_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 734 | mbedtls_free( name_prv ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | entry_cur = crl_cur->entry.next; |
| 738 | while( entry_cur != NULL ) |
| 739 | { |
| 740 | entry_prv = entry_cur; |
| 741 | entry_cur = entry_cur->next; |
Andres Amaya Garcia | 1f6301b | 2018-04-17 09:51:09 -0500 | [diff] [blame] | 742 | mbedtls_platform_zeroize( entry_prv, |
| 743 | sizeof( mbedtls_x509_crl_entry ) ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 744 | mbedtls_free( entry_prv ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | if( crl_cur->raw.p != NULL ) |
| 748 | { |
Andres Amaya Garcia | 1f6301b | 2018-04-17 09:51:09 -0500 | [diff] [blame] | 749 | mbedtls_platform_zeroize( crl_cur->raw.p, crl_cur->raw.len ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 750 | mbedtls_free( crl_cur->raw.p ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | crl_cur = crl_cur->next; |
| 754 | } |
| 755 | while( crl_cur != NULL ); |
| 756 | |
| 757 | crl_cur = crl; |
| 758 | do |
| 759 | { |
| 760 | crl_prv = crl_cur; |
| 761 | crl_cur = crl_cur->next; |
| 762 | |
Andres Amaya Garcia | 1f6301b | 2018-04-17 09:51:09 -0500 | [diff] [blame] | 763 | mbedtls_platform_zeroize( crl_prv, sizeof( mbedtls_x509_crl ) ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 764 | if( crl_prv != crl ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 765 | mbedtls_free( crl_prv ); |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 766 | } |
| 767 | while( crl_cur != NULL ); |
| 768 | } |
| 769 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 770 | #endif /* MBEDTLS_X509_CRL_PARSE_C */ |