mbed client lightswitch demo

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by Austin Blackstone

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

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