I added functionality to get the RSSI, BER, and Cell Neighbor for reporting connection issues to M2X
Dependencies: WncControllerK64F
mbedtls/mbedtls/x509.h@18:198e9b0acf11, 2016-11-17 (annotated)
- Committer:
- JMF
- Date:
- Thu Nov 17 16:13:29 2016 +0000
- Revision:
- 18:198e9b0acf11
- Parent:
- 12:0071cb144c7a
Updates to mbed os resulted in mutex.h going away and rtos.h needed to be used; This fixes the Mutex typedef failure. Also cast data buffers from 'char *' to (const std::uint8_t*) to conform with Fred's changes in WncController
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JMF | 12:0071cb144c7a | 1 | /** |
JMF | 12:0071cb144c7a | 2 | * \file x509.h |
JMF | 12:0071cb144c7a | 3 | * |
JMF | 12:0071cb144c7a | 4 | * \brief X.509 generic defines and structures |
JMF | 12:0071cb144c7a | 5 | * |
JMF | 12:0071cb144c7a | 6 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
JMF | 12:0071cb144c7a | 7 | * SPDX-License-Identifier: Apache-2.0 |
JMF | 12:0071cb144c7a | 8 | * |
JMF | 12:0071cb144c7a | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
JMF | 12:0071cb144c7a | 10 | * not use this file except in compliance with the License. |
JMF | 12:0071cb144c7a | 11 | * You may obtain a copy of the License at |
JMF | 12:0071cb144c7a | 12 | * |
JMF | 12:0071cb144c7a | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
JMF | 12:0071cb144c7a | 14 | * |
JMF | 12:0071cb144c7a | 15 | * Unless required by applicable law or agreed to in writing, software |
JMF | 12:0071cb144c7a | 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
JMF | 12:0071cb144c7a | 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
JMF | 12:0071cb144c7a | 18 | * See the License for the specific language governing permissions and |
JMF | 12:0071cb144c7a | 19 | * limitations under the License. |
JMF | 12:0071cb144c7a | 20 | * |
JMF | 12:0071cb144c7a | 21 | * This file is part of mbed TLS (https://tls.mbed.org) |
JMF | 12:0071cb144c7a | 22 | */ |
JMF | 12:0071cb144c7a | 23 | #ifndef MBEDTLS_X509_H |
JMF | 12:0071cb144c7a | 24 | #define MBEDTLS_X509_H |
JMF | 12:0071cb144c7a | 25 | |
JMF | 12:0071cb144c7a | 26 | #if !defined(MBEDTLS_CONFIG_FILE) |
JMF | 12:0071cb144c7a | 27 | #include "config.h" |
JMF | 12:0071cb144c7a | 28 | #else |
JMF | 12:0071cb144c7a | 29 | #include MBEDTLS_CONFIG_FILE |
JMF | 12:0071cb144c7a | 30 | #endif |
JMF | 12:0071cb144c7a | 31 | |
JMF | 12:0071cb144c7a | 32 | #include "asn1.h" |
JMF | 12:0071cb144c7a | 33 | #include "pk.h" |
JMF | 12:0071cb144c7a | 34 | |
JMF | 12:0071cb144c7a | 35 | #if defined(MBEDTLS_RSA_C) |
JMF | 12:0071cb144c7a | 36 | #include "rsa.h" |
JMF | 12:0071cb144c7a | 37 | #endif |
JMF | 12:0071cb144c7a | 38 | |
JMF | 12:0071cb144c7a | 39 | /** |
JMF | 12:0071cb144c7a | 40 | * \addtogroup x509_module |
JMF | 12:0071cb144c7a | 41 | * \{ |
JMF | 12:0071cb144c7a | 42 | */ |
JMF | 12:0071cb144c7a | 43 | |
JMF | 12:0071cb144c7a | 44 | #if !defined(MBEDTLS_X509_MAX_INTERMEDIATE_CA) |
JMF | 12:0071cb144c7a | 45 | /** |
JMF | 12:0071cb144c7a | 46 | * Maximum number of intermediate CAs in a verification chain. |
JMF | 12:0071cb144c7a | 47 | * That is, maximum length of the chain, excluding the end-entity certificate |
JMF | 12:0071cb144c7a | 48 | * and the trusted root certificate. |
JMF | 12:0071cb144c7a | 49 | * |
JMF | 12:0071cb144c7a | 50 | * Set this to a low value to prevent an adversary from making you waste |
JMF | 12:0071cb144c7a | 51 | * resources verifying an overlong certificate chain. |
JMF | 12:0071cb144c7a | 52 | */ |
JMF | 12:0071cb144c7a | 53 | #define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 |
JMF | 12:0071cb144c7a | 54 | #endif |
JMF | 12:0071cb144c7a | 55 | |
JMF | 12:0071cb144c7a | 56 | /** |
JMF | 12:0071cb144c7a | 57 | * \name X509 Error codes |
JMF | 12:0071cb144c7a | 58 | * \{ |
JMF | 12:0071cb144c7a | 59 | */ |
JMF | 12:0071cb144c7a | 60 | #define MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE -0x2080 /**< Unavailable feature, e.g. RSA hashing/encryption combination. */ |
JMF | 12:0071cb144c7a | 61 | #define MBEDTLS_ERR_X509_UNKNOWN_OID -0x2100 /**< Requested OID is unknown. */ |
JMF | 12:0071cb144c7a | 62 | #define MBEDTLS_ERR_X509_INVALID_FORMAT -0x2180 /**< The CRT/CRL/CSR format is invalid, e.g. different type expected. */ |
JMF | 12:0071cb144c7a | 63 | #define MBEDTLS_ERR_X509_INVALID_VERSION -0x2200 /**< The CRT/CRL/CSR version element is invalid. */ |
JMF | 12:0071cb144c7a | 64 | #define MBEDTLS_ERR_X509_INVALID_SERIAL -0x2280 /**< The serial tag or value is invalid. */ |
JMF | 12:0071cb144c7a | 65 | #define MBEDTLS_ERR_X509_INVALID_ALG -0x2300 /**< The algorithm tag or value is invalid. */ |
JMF | 12:0071cb144c7a | 66 | #define MBEDTLS_ERR_X509_INVALID_NAME -0x2380 /**< The name tag or value is invalid. */ |
JMF | 12:0071cb144c7a | 67 | #define MBEDTLS_ERR_X509_INVALID_DATE -0x2400 /**< The date tag or value is invalid. */ |
JMF | 12:0071cb144c7a | 68 | #define MBEDTLS_ERR_X509_INVALID_SIGNATURE -0x2480 /**< The signature tag or value invalid. */ |
JMF | 12:0071cb144c7a | 69 | #define MBEDTLS_ERR_X509_INVALID_EXTENSIONS -0x2500 /**< The extension tag or value is invalid. */ |
JMF | 12:0071cb144c7a | 70 | #define MBEDTLS_ERR_X509_UNKNOWN_VERSION -0x2580 /**< CRT/CRL/CSR has an unsupported version number. */ |
JMF | 12:0071cb144c7a | 71 | #define MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG -0x2600 /**< Signature algorithm (oid) is unsupported. */ |
JMF | 12:0071cb144c7a | 72 | #define MBEDTLS_ERR_X509_SIG_MISMATCH -0x2680 /**< Signature algorithms do not match. (see \c ::mbedtls_x509_crt sig_oid) */ |
JMF | 12:0071cb144c7a | 73 | #define MBEDTLS_ERR_X509_CERT_VERIFY_FAILED -0x2700 /**< Certificate verification failed, e.g. CRL, CA or signature check failed. */ |
JMF | 12:0071cb144c7a | 74 | #define MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT -0x2780 /**< Format not recognized as DER or PEM. */ |
JMF | 12:0071cb144c7a | 75 | #define MBEDTLS_ERR_X509_BAD_INPUT_DATA -0x2800 /**< Input invalid. */ |
JMF | 12:0071cb144c7a | 76 | #define MBEDTLS_ERR_X509_ALLOC_FAILED -0x2880 /**< Allocation of memory failed. */ |
JMF | 12:0071cb144c7a | 77 | #define MBEDTLS_ERR_X509_FILE_IO_ERROR -0x2900 /**< Read/write of file failed. */ |
JMF | 12:0071cb144c7a | 78 | #define MBEDTLS_ERR_X509_BUFFER_TOO_SMALL -0x2980 /**< Destination buffer is too small. */ |
JMF | 12:0071cb144c7a | 79 | /* \} name */ |
JMF | 12:0071cb144c7a | 80 | |
JMF | 12:0071cb144c7a | 81 | /** |
JMF | 12:0071cb144c7a | 82 | * \name X509 Verify codes |
JMF | 12:0071cb144c7a | 83 | * \{ |
JMF | 12:0071cb144c7a | 84 | */ |
JMF | 12:0071cb144c7a | 85 | /* Reminder: update x509_crt_verify_strings[] in library/x509_crt.c */ |
JMF | 12:0071cb144c7a | 86 | #define MBEDTLS_X509_BADCERT_EXPIRED 0x01 /**< The certificate validity has expired. */ |
JMF | 12:0071cb144c7a | 87 | #define MBEDTLS_X509_BADCERT_REVOKED 0x02 /**< The certificate has been revoked (is on a CRL). */ |
JMF | 12:0071cb144c7a | 88 | #define MBEDTLS_X509_BADCERT_CN_MISMATCH 0x04 /**< The certificate Common Name (CN) does not match with the expected CN. */ |
JMF | 12:0071cb144c7a | 89 | #define MBEDTLS_X509_BADCERT_NOT_TRUSTED 0x08 /**< The certificate is not correctly signed by the trusted CA. */ |
JMF | 12:0071cb144c7a | 90 | #define MBEDTLS_X509_BADCRL_NOT_TRUSTED 0x10 /**< The CRL is not correctly signed by the trusted CA. */ |
JMF | 12:0071cb144c7a | 91 | #define MBEDTLS_X509_BADCRL_EXPIRED 0x20 /**< The CRL is expired. */ |
JMF | 12:0071cb144c7a | 92 | #define MBEDTLS_X509_BADCERT_MISSING 0x40 /**< Certificate was missing. */ |
JMF | 12:0071cb144c7a | 93 | #define MBEDTLS_X509_BADCERT_SKIP_VERIFY 0x80 /**< Certificate verification was skipped. */ |
JMF | 12:0071cb144c7a | 94 | #define MBEDTLS_X509_BADCERT_OTHER 0x0100 /**< Other reason (can be used by verify callback) */ |
JMF | 12:0071cb144c7a | 95 | #define MBEDTLS_X509_BADCERT_FUTURE 0x0200 /**< The certificate validity starts in the future. */ |
JMF | 12:0071cb144c7a | 96 | #define MBEDTLS_X509_BADCRL_FUTURE 0x0400 /**< The CRL is from the future */ |
JMF | 12:0071cb144c7a | 97 | #define MBEDTLS_X509_BADCERT_KEY_USAGE 0x0800 /**< Usage does not match the keyUsage extension. */ |
JMF | 12:0071cb144c7a | 98 | #define MBEDTLS_X509_BADCERT_EXT_KEY_USAGE 0x1000 /**< Usage does not match the extendedKeyUsage extension. */ |
JMF | 12:0071cb144c7a | 99 | #define MBEDTLS_X509_BADCERT_NS_CERT_TYPE 0x2000 /**< Usage does not match the nsCertType extension. */ |
JMF | 12:0071cb144c7a | 100 | #define MBEDTLS_X509_BADCERT_BAD_MD 0x4000 /**< The certificate is signed with an unacceptable hash. */ |
JMF | 12:0071cb144c7a | 101 | #define MBEDTLS_X509_BADCERT_BAD_PK 0x8000 /**< The certificate is signed with an unacceptable PK alg (eg RSA vs ECDSA). */ |
JMF | 12:0071cb144c7a | 102 | #define MBEDTLS_X509_BADCERT_BAD_KEY 0x010000 /**< The certificate is signed with an unacceptable key (eg bad curve, RSA too short). */ |
JMF | 12:0071cb144c7a | 103 | #define MBEDTLS_X509_BADCRL_BAD_MD 0x020000 /**< The CRL is signed with an unacceptable hash. */ |
JMF | 12:0071cb144c7a | 104 | #define MBEDTLS_X509_BADCRL_BAD_PK 0x040000 /**< The CRL is signed with an unacceptable PK alg (eg RSA vs ECDSA). */ |
JMF | 12:0071cb144c7a | 105 | #define MBEDTLS_X509_BADCRL_BAD_KEY 0x080000 /**< The CRL is signed with an unacceptable key (eg bad curve, RSA too short). */ |
JMF | 12:0071cb144c7a | 106 | |
JMF | 12:0071cb144c7a | 107 | /* \} name */ |
JMF | 12:0071cb144c7a | 108 | /* \} addtogroup x509_module */ |
JMF | 12:0071cb144c7a | 109 | |
JMF | 12:0071cb144c7a | 110 | /* |
JMF | 12:0071cb144c7a | 111 | * X.509 v3 Key Usage Extension flags |
JMF | 12:0071cb144c7a | 112 | * Reminder: update x509_info_key_usage() when adding new flags. |
JMF | 12:0071cb144c7a | 113 | */ |
JMF | 12:0071cb144c7a | 114 | #define MBEDTLS_X509_KU_DIGITAL_SIGNATURE (0x80) /* bit 0 */ |
JMF | 12:0071cb144c7a | 115 | #define MBEDTLS_X509_KU_NON_REPUDIATION (0x40) /* bit 1 */ |
JMF | 12:0071cb144c7a | 116 | #define MBEDTLS_X509_KU_KEY_ENCIPHERMENT (0x20) /* bit 2 */ |
JMF | 12:0071cb144c7a | 117 | #define MBEDTLS_X509_KU_DATA_ENCIPHERMENT (0x10) /* bit 3 */ |
JMF | 12:0071cb144c7a | 118 | #define MBEDTLS_X509_KU_KEY_AGREEMENT (0x08) /* bit 4 */ |
JMF | 12:0071cb144c7a | 119 | #define MBEDTLS_X509_KU_KEY_CERT_SIGN (0x04) /* bit 5 */ |
JMF | 12:0071cb144c7a | 120 | #define MBEDTLS_X509_KU_CRL_SIGN (0x02) /* bit 6 */ |
JMF | 12:0071cb144c7a | 121 | #define MBEDTLS_X509_KU_ENCIPHER_ONLY (0x01) /* bit 7 */ |
JMF | 12:0071cb144c7a | 122 | #define MBEDTLS_X509_KU_DECIPHER_ONLY (0x8000) /* bit 8 */ |
JMF | 12:0071cb144c7a | 123 | |
JMF | 12:0071cb144c7a | 124 | /* |
JMF | 12:0071cb144c7a | 125 | * Netscape certificate types |
JMF | 12:0071cb144c7a | 126 | * (http://www.mozilla.org/projects/security/pki/nss/tech-notes/tn3.html) |
JMF | 12:0071cb144c7a | 127 | */ |
JMF | 12:0071cb144c7a | 128 | |
JMF | 12:0071cb144c7a | 129 | #define MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT (0x80) /* bit 0 */ |
JMF | 12:0071cb144c7a | 130 | #define MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER (0x40) /* bit 1 */ |
JMF | 12:0071cb144c7a | 131 | #define MBEDTLS_X509_NS_CERT_TYPE_EMAIL (0x20) /* bit 2 */ |
JMF | 12:0071cb144c7a | 132 | #define MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING (0x10) /* bit 3 */ |
JMF | 12:0071cb144c7a | 133 | #define MBEDTLS_X509_NS_CERT_TYPE_RESERVED (0x08) /* bit 4 */ |
JMF | 12:0071cb144c7a | 134 | #define MBEDTLS_X509_NS_CERT_TYPE_SSL_CA (0x04) /* bit 5 */ |
JMF | 12:0071cb144c7a | 135 | #define MBEDTLS_X509_NS_CERT_TYPE_EMAIL_CA (0x02) /* bit 6 */ |
JMF | 12:0071cb144c7a | 136 | #define MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING_CA (0x01) /* bit 7 */ |
JMF | 12:0071cb144c7a | 137 | |
JMF | 12:0071cb144c7a | 138 | /* |
JMF | 12:0071cb144c7a | 139 | * X.509 extension types |
JMF | 12:0071cb144c7a | 140 | * |
JMF | 12:0071cb144c7a | 141 | * Comments refer to the status for using certificates. Status can be |
JMF | 12:0071cb144c7a | 142 | * different for writing certificates or reading CRLs or CSRs. |
JMF | 12:0071cb144c7a | 143 | */ |
JMF | 12:0071cb144c7a | 144 | #define MBEDTLS_X509_EXT_AUTHORITY_KEY_IDENTIFIER (1 << 0) |
JMF | 12:0071cb144c7a | 145 | #define MBEDTLS_X509_EXT_SUBJECT_KEY_IDENTIFIER (1 << 1) |
JMF | 12:0071cb144c7a | 146 | #define MBEDTLS_X509_EXT_KEY_USAGE (1 << 2) |
JMF | 12:0071cb144c7a | 147 | #define MBEDTLS_X509_EXT_CERTIFICATE_POLICIES (1 << 3) |
JMF | 12:0071cb144c7a | 148 | #define MBEDTLS_X509_EXT_POLICY_MAPPINGS (1 << 4) |
JMF | 12:0071cb144c7a | 149 | #define MBEDTLS_X509_EXT_SUBJECT_ALT_NAME (1 << 5) /* Supported (DNS) */ |
JMF | 12:0071cb144c7a | 150 | #define MBEDTLS_X509_EXT_ISSUER_ALT_NAME (1 << 6) |
JMF | 12:0071cb144c7a | 151 | #define MBEDTLS_X509_EXT_SUBJECT_DIRECTORY_ATTRS (1 << 7) |
JMF | 12:0071cb144c7a | 152 | #define MBEDTLS_X509_EXT_BASIC_CONSTRAINTS (1 << 8) /* Supported */ |
JMF | 12:0071cb144c7a | 153 | #define MBEDTLS_X509_EXT_NAME_CONSTRAINTS (1 << 9) |
JMF | 12:0071cb144c7a | 154 | #define MBEDTLS_X509_EXT_POLICY_CONSTRAINTS (1 << 10) |
JMF | 12:0071cb144c7a | 155 | #define MBEDTLS_X509_EXT_EXTENDED_KEY_USAGE (1 << 11) |
JMF | 12:0071cb144c7a | 156 | #define MBEDTLS_X509_EXT_CRL_DISTRIBUTION_POINTS (1 << 12) |
JMF | 12:0071cb144c7a | 157 | #define MBEDTLS_X509_EXT_INIHIBIT_ANYPOLICY (1 << 13) |
JMF | 12:0071cb144c7a | 158 | #define MBEDTLS_X509_EXT_FRESHEST_CRL (1 << 14) |
JMF | 12:0071cb144c7a | 159 | |
JMF | 12:0071cb144c7a | 160 | #define MBEDTLS_X509_EXT_NS_CERT_TYPE (1 << 16) /* Parsed (and then ?) */ |
JMF | 12:0071cb144c7a | 161 | |
JMF | 12:0071cb144c7a | 162 | /* |
JMF | 12:0071cb144c7a | 163 | * Storage format identifiers |
JMF | 12:0071cb144c7a | 164 | * Recognized formats: PEM and DER |
JMF | 12:0071cb144c7a | 165 | */ |
JMF | 12:0071cb144c7a | 166 | #define MBEDTLS_X509_FORMAT_DER 1 |
JMF | 12:0071cb144c7a | 167 | #define MBEDTLS_X509_FORMAT_PEM 2 |
JMF | 12:0071cb144c7a | 168 | |
JMF | 12:0071cb144c7a | 169 | #define MBEDTLS_X509_MAX_DN_NAME_SIZE 256 /**< Maximum value size of a DN entry */ |
JMF | 12:0071cb144c7a | 170 | |
JMF | 12:0071cb144c7a | 171 | #ifdef __cplusplus |
JMF | 12:0071cb144c7a | 172 | extern "C" { |
JMF | 12:0071cb144c7a | 173 | #endif |
JMF | 12:0071cb144c7a | 174 | |
JMF | 12:0071cb144c7a | 175 | /** |
JMF | 12:0071cb144c7a | 176 | * \addtogroup x509_module |
JMF | 12:0071cb144c7a | 177 | * \{ */ |
JMF | 12:0071cb144c7a | 178 | |
JMF | 12:0071cb144c7a | 179 | /** |
JMF | 12:0071cb144c7a | 180 | * \name Structures for parsing X.509 certificates, CRLs and CSRs |
JMF | 12:0071cb144c7a | 181 | * \{ |
JMF | 12:0071cb144c7a | 182 | */ |
JMF | 12:0071cb144c7a | 183 | |
JMF | 12:0071cb144c7a | 184 | /** |
JMF | 12:0071cb144c7a | 185 | * Type-length-value structure that allows for ASN1 using DER. |
JMF | 12:0071cb144c7a | 186 | */ |
JMF | 12:0071cb144c7a | 187 | typedef mbedtls_asn1_buf mbedtls_x509_buf; |
JMF | 12:0071cb144c7a | 188 | |
JMF | 12:0071cb144c7a | 189 | /** |
JMF | 12:0071cb144c7a | 190 | * Container for ASN1 bit strings. |
JMF | 12:0071cb144c7a | 191 | */ |
JMF | 12:0071cb144c7a | 192 | typedef mbedtls_asn1_bitstring mbedtls_x509_bitstring; |
JMF | 12:0071cb144c7a | 193 | |
JMF | 12:0071cb144c7a | 194 | /** |
JMF | 12:0071cb144c7a | 195 | * Container for ASN1 named information objects. |
JMF | 12:0071cb144c7a | 196 | * It allows for Relative Distinguished Names (e.g. cn=localhost,ou=code,etc.). |
JMF | 12:0071cb144c7a | 197 | */ |
JMF | 12:0071cb144c7a | 198 | typedef mbedtls_asn1_named_data mbedtls_x509_name; |
JMF | 12:0071cb144c7a | 199 | |
JMF | 12:0071cb144c7a | 200 | /** |
JMF | 12:0071cb144c7a | 201 | * Container for a sequence of ASN.1 items |
JMF | 12:0071cb144c7a | 202 | */ |
JMF | 12:0071cb144c7a | 203 | typedef mbedtls_asn1_sequence mbedtls_x509_sequence; |
JMF | 12:0071cb144c7a | 204 | |
JMF | 12:0071cb144c7a | 205 | /** Container for date and time (precision in seconds). */ |
JMF | 12:0071cb144c7a | 206 | typedef struct mbedtls_x509_time |
JMF | 12:0071cb144c7a | 207 | { |
JMF | 12:0071cb144c7a | 208 | int year, mon, day; /**< Date. */ |
JMF | 12:0071cb144c7a | 209 | int hour, min, sec; /**< Time. */ |
JMF | 12:0071cb144c7a | 210 | } |
JMF | 12:0071cb144c7a | 211 | mbedtls_x509_time; |
JMF | 12:0071cb144c7a | 212 | |
JMF | 12:0071cb144c7a | 213 | /** \} name Structures for parsing X.509 certificates, CRLs and CSRs */ |
JMF | 12:0071cb144c7a | 214 | /** \} addtogroup x509_module */ |
JMF | 12:0071cb144c7a | 215 | |
JMF | 12:0071cb144c7a | 216 | /** |
JMF | 12:0071cb144c7a | 217 | * \brief Store the certificate DN in printable form into buf; |
JMF | 12:0071cb144c7a | 218 | * no more than size characters will be written. |
JMF | 12:0071cb144c7a | 219 | * |
JMF | 12:0071cb144c7a | 220 | * \param buf Buffer to write to |
JMF | 12:0071cb144c7a | 221 | * \param size Maximum size of buffer |
JMF | 12:0071cb144c7a | 222 | * \param dn The X509 name to represent |
JMF | 12:0071cb144c7a | 223 | * |
JMF | 12:0071cb144c7a | 224 | * \return The length of the string written (not including the |
JMF | 12:0071cb144c7a | 225 | * terminated nul byte), or a negative error code. |
JMF | 12:0071cb144c7a | 226 | */ |
JMF | 12:0071cb144c7a | 227 | int mbedtls_x509_dn_gets( char *buf, size_t size, const mbedtls_x509_name *dn ); |
JMF | 12:0071cb144c7a | 228 | |
JMF | 12:0071cb144c7a | 229 | /** |
JMF | 12:0071cb144c7a | 230 | * \brief Store the certificate serial in printable form into buf; |
JMF | 12:0071cb144c7a | 231 | * no more than size characters will be written. |
JMF | 12:0071cb144c7a | 232 | * |
JMF | 12:0071cb144c7a | 233 | * \param buf Buffer to write to |
JMF | 12:0071cb144c7a | 234 | * \param size Maximum size of buffer |
JMF | 12:0071cb144c7a | 235 | * \param serial The X509 serial to represent |
JMF | 12:0071cb144c7a | 236 | * |
JMF | 12:0071cb144c7a | 237 | * \return The length of the string written (not including the |
JMF | 12:0071cb144c7a | 238 | * terminated nul byte), or a negative error code. |
JMF | 12:0071cb144c7a | 239 | */ |
JMF | 12:0071cb144c7a | 240 | int mbedtls_x509_serial_gets( char *buf, size_t size, const mbedtls_x509_buf *serial ); |
JMF | 12:0071cb144c7a | 241 | |
JMF | 12:0071cb144c7a | 242 | /** |
JMF | 12:0071cb144c7a | 243 | * \brief Check a given mbedtls_x509_time against the system time |
JMF | 12:0071cb144c7a | 244 | * and tell if it's in the past. |
JMF | 12:0071cb144c7a | 245 | * |
JMF | 12:0071cb144c7a | 246 | * \note Intended usage is "if( is_past( valid_to ) ) ERROR". |
JMF | 12:0071cb144c7a | 247 | * Hence the return value of 1 if on internal errors. |
JMF | 12:0071cb144c7a | 248 | * |
JMF | 12:0071cb144c7a | 249 | * \param time mbedtls_x509_time to check |
JMF | 12:0071cb144c7a | 250 | * |
JMF | 12:0071cb144c7a | 251 | * \return 1 if the given time is in the past or an error occured, |
JMF | 12:0071cb144c7a | 252 | * 0 otherwise. |
JMF | 12:0071cb144c7a | 253 | */ |
JMF | 12:0071cb144c7a | 254 | int mbedtls_x509_time_is_past( const mbedtls_x509_time *time ); |
JMF | 12:0071cb144c7a | 255 | |
JMF | 12:0071cb144c7a | 256 | /** |
JMF | 12:0071cb144c7a | 257 | * \brief Check a given mbedtls_x509_time against the system time |
JMF | 12:0071cb144c7a | 258 | * and tell if it's in the future. |
JMF | 12:0071cb144c7a | 259 | * |
JMF | 12:0071cb144c7a | 260 | * \note Intended usage is "if( is_future( valid_from ) ) ERROR". |
JMF | 12:0071cb144c7a | 261 | * Hence the return value of 1 if on internal errors. |
JMF | 12:0071cb144c7a | 262 | * |
JMF | 12:0071cb144c7a | 263 | * \param time mbedtls_x509_time to check |
JMF | 12:0071cb144c7a | 264 | * |
JMF | 12:0071cb144c7a | 265 | * \return 1 if the given time is in the future or an error occured, |
JMF | 12:0071cb144c7a | 266 | * 0 otherwise. |
JMF | 12:0071cb144c7a | 267 | */ |
JMF | 12:0071cb144c7a | 268 | int mbedtls_x509_time_is_future( const mbedtls_x509_time *time ); |
JMF | 12:0071cb144c7a | 269 | |
JMF | 12:0071cb144c7a | 270 | /** |
JMF | 12:0071cb144c7a | 271 | * \brief Checkup routine |
JMF | 12:0071cb144c7a | 272 | * |
JMF | 12:0071cb144c7a | 273 | * \return 0 if successful, or 1 if the test failed |
JMF | 12:0071cb144c7a | 274 | */ |
JMF | 12:0071cb144c7a | 275 | int mbedtls_x509_self_test( int verbose ); |
JMF | 12:0071cb144c7a | 276 | |
JMF | 12:0071cb144c7a | 277 | /* |
JMF | 12:0071cb144c7a | 278 | * Internal module functions. You probably do not want to use these unless you |
JMF | 12:0071cb144c7a | 279 | * know you do. |
JMF | 12:0071cb144c7a | 280 | */ |
JMF | 12:0071cb144c7a | 281 | int mbedtls_x509_get_name( unsigned char **p, const unsigned char *end, |
JMF | 12:0071cb144c7a | 282 | mbedtls_x509_name *cur ); |
JMF | 12:0071cb144c7a | 283 | int mbedtls_x509_get_alg_null( unsigned char **p, const unsigned char *end, |
JMF | 12:0071cb144c7a | 284 | mbedtls_x509_buf *alg ); |
JMF | 12:0071cb144c7a | 285 | int mbedtls_x509_get_alg( unsigned char **p, const unsigned char *end, |
JMF | 12:0071cb144c7a | 286 | mbedtls_x509_buf *alg, mbedtls_x509_buf *params ); |
JMF | 12:0071cb144c7a | 287 | #if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) |
JMF | 12:0071cb144c7a | 288 | int mbedtls_x509_get_rsassa_pss_params( const mbedtls_x509_buf *params, |
JMF | 12:0071cb144c7a | 289 | mbedtls_md_type_t *md_alg, mbedtls_md_type_t *mgf_md, |
JMF | 12:0071cb144c7a | 290 | int *salt_len ); |
JMF | 12:0071cb144c7a | 291 | #endif |
JMF | 12:0071cb144c7a | 292 | int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig ); |
JMF | 12:0071cb144c7a | 293 | int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params, |
JMF | 12:0071cb144c7a | 294 | mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg, |
JMF | 12:0071cb144c7a | 295 | void **sig_opts ); |
JMF | 12:0071cb144c7a | 296 | int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end, |
JMF | 12:0071cb144c7a | 297 | mbedtls_x509_time *time ); |
JMF | 12:0071cb144c7a | 298 | int mbedtls_x509_get_serial( unsigned char **p, const unsigned char *end, |
JMF | 12:0071cb144c7a | 299 | mbedtls_x509_buf *serial ); |
JMF | 12:0071cb144c7a | 300 | int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end, |
JMF | 12:0071cb144c7a | 301 | mbedtls_x509_buf *ext, int tag ); |
JMF | 12:0071cb144c7a | 302 | int mbedtls_x509_sig_alg_gets( char *buf, size_t size, const mbedtls_x509_buf *sig_oid, |
JMF | 12:0071cb144c7a | 303 | mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg, |
JMF | 12:0071cb144c7a | 304 | const void *sig_opts ); |
JMF | 12:0071cb144c7a | 305 | int mbedtls_x509_key_size_helper( char *buf, size_t buf_size, const char *name ); |
JMF | 12:0071cb144c7a | 306 | int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *name ); |
JMF | 12:0071cb144c7a | 307 | int mbedtls_x509_set_extension( mbedtls_asn1_named_data **head, const char *oid, size_t oid_len, |
JMF | 12:0071cb144c7a | 308 | int critical, const unsigned char *val, |
JMF | 12:0071cb144c7a | 309 | size_t val_len ); |
JMF | 12:0071cb144c7a | 310 | int mbedtls_x509_write_extensions( unsigned char **p, unsigned char *start, |
JMF | 12:0071cb144c7a | 311 | mbedtls_asn1_named_data *first ); |
JMF | 12:0071cb144c7a | 312 | int mbedtls_x509_write_names( unsigned char **p, unsigned char *start, |
JMF | 12:0071cb144c7a | 313 | mbedtls_asn1_named_data *first ); |
JMF | 12:0071cb144c7a | 314 | int mbedtls_x509_write_sig( unsigned char **p, unsigned char *start, |
JMF | 12:0071cb144c7a | 315 | const char *oid, size_t oid_len, |
JMF | 12:0071cb144c7a | 316 | unsigned char *sig, size_t size ); |
JMF | 12:0071cb144c7a | 317 | |
JMF | 12:0071cb144c7a | 318 | #define MBEDTLS_X509_SAFE_SNPRINTF \ |
JMF | 12:0071cb144c7a | 319 | do { \ |
JMF | 12:0071cb144c7a | 320 | if( ret < 0 || (size_t) ret >= n ) \ |
JMF | 12:0071cb144c7a | 321 | return( MBEDTLS_ERR_X509_BUFFER_TOO_SMALL ); \ |
JMF | 12:0071cb144c7a | 322 | \ |
JMF | 12:0071cb144c7a | 323 | n -= (size_t) ret; \ |
JMF | 12:0071cb144c7a | 324 | p += (size_t) ret; \ |
JMF | 12:0071cb144c7a | 325 | } while( 0 ) |
JMF | 12:0071cb144c7a | 326 | |
JMF | 12:0071cb144c7a | 327 | #ifdef __cplusplus |
JMF | 12:0071cb144c7a | 328 | } |
JMF | 12:0071cb144c7a | 329 | #endif |
JMF | 12:0071cb144c7a | 330 | |
JMF | 12:0071cb144c7a | 331 | #endif /* x509.h */ |