Example program to test AES-GCM functionality. Used for a workshop

Dependencies:   mbed

Committer:
HannesTschofenig
Date:
Thu Sep 27 06:34:22 2018 +0000
Revision:
0:796d0f61a05b
Example AES-GCM test program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HannesTschofenig 0:796d0f61a05b 1 /**
HannesTschofenig 0:796d0f61a05b 2 * \file x509_crl.h
HannesTschofenig 0:796d0f61a05b 3 *
HannesTschofenig 0:796d0f61a05b 4 * \brief X.509 certificate revocation list parsing
HannesTschofenig 0:796d0f61a05b 5 *
HannesTschofenig 0:796d0f61a05b 6 * Copyright (C) 2006-2013, Brainspark B.V.
HannesTschofenig 0:796d0f61a05b 7 *
HannesTschofenig 0:796d0f61a05b 8 * This file is part of PolarSSL (http://www.polarssl.org)
HannesTschofenig 0:796d0f61a05b 9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
HannesTschofenig 0:796d0f61a05b 10 *
HannesTschofenig 0:796d0f61a05b 11 * All rights reserved.
HannesTschofenig 0:796d0f61a05b 12 *
HannesTschofenig 0:796d0f61a05b 13 * This program is free software; you can redistribute it and/or modify
HannesTschofenig 0:796d0f61a05b 14 * it under the terms of the GNU General Public License as published by
HannesTschofenig 0:796d0f61a05b 15 * the Free Software Foundation; either version 2 of the License, or
HannesTschofenig 0:796d0f61a05b 16 * (at your option) any later version.
HannesTschofenig 0:796d0f61a05b 17 *
HannesTschofenig 0:796d0f61a05b 18 * This program is distributed in the hope that it will be useful,
HannesTschofenig 0:796d0f61a05b 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
HannesTschofenig 0:796d0f61a05b 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
HannesTschofenig 0:796d0f61a05b 21 * GNU General Public License for more details.
HannesTschofenig 0:796d0f61a05b 22 *
HannesTschofenig 0:796d0f61a05b 23 * You should have received a copy of the GNU General Public License along
HannesTschofenig 0:796d0f61a05b 24 * with this program; if not, write to the Free Software Foundation, Inc.,
HannesTschofenig 0:796d0f61a05b 25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
HannesTschofenig 0:796d0f61a05b 26 */
HannesTschofenig 0:796d0f61a05b 27 #ifndef POLARSSL_X509_CRL_H
HannesTschofenig 0:796d0f61a05b 28 #define POLARSSL_X509_CRL_H
HannesTschofenig 0:796d0f61a05b 29
HannesTschofenig 0:796d0f61a05b 30 #if !defined(POLARSSL_CONFIG_FILE)
HannesTschofenig 0:796d0f61a05b 31 #include "config.h"
HannesTschofenig 0:796d0f61a05b 32 #else
HannesTschofenig 0:796d0f61a05b 33 #include POLARSSL_CONFIG_FILE
HannesTschofenig 0:796d0f61a05b 34 #endif
HannesTschofenig 0:796d0f61a05b 35
HannesTschofenig 0:796d0f61a05b 36 #include "x509.h"
HannesTschofenig 0:796d0f61a05b 37
HannesTschofenig 0:796d0f61a05b 38 #ifdef __cplusplus
HannesTschofenig 0:796d0f61a05b 39 extern "C" {
HannesTschofenig 0:796d0f61a05b 40 #endif
HannesTschofenig 0:796d0f61a05b 41
HannesTschofenig 0:796d0f61a05b 42 /**
HannesTschofenig 0:796d0f61a05b 43 * \addtogroup x509_module
HannesTschofenig 0:796d0f61a05b 44 * \{ */
HannesTschofenig 0:796d0f61a05b 45
HannesTschofenig 0:796d0f61a05b 46 /**
HannesTschofenig 0:796d0f61a05b 47 * \name Structures and functions for parsing CRLs
HannesTschofenig 0:796d0f61a05b 48 * \{
HannesTschofenig 0:796d0f61a05b 49 */
HannesTschofenig 0:796d0f61a05b 50
HannesTschofenig 0:796d0f61a05b 51 /**
HannesTschofenig 0:796d0f61a05b 52 * Certificate revocation list entry.
HannesTschofenig 0:796d0f61a05b 53 * Contains the CA-specific serial numbers and revocation dates.
HannesTschofenig 0:796d0f61a05b 54 */
HannesTschofenig 0:796d0f61a05b 55 typedef struct _x509_crl_entry
HannesTschofenig 0:796d0f61a05b 56 {
HannesTschofenig 0:796d0f61a05b 57 x509_buf raw;
HannesTschofenig 0:796d0f61a05b 58
HannesTschofenig 0:796d0f61a05b 59 x509_buf serial;
HannesTschofenig 0:796d0f61a05b 60
HannesTschofenig 0:796d0f61a05b 61 x509_time revocation_date;
HannesTschofenig 0:796d0f61a05b 62
HannesTschofenig 0:796d0f61a05b 63 x509_buf entry_ext;
HannesTschofenig 0:796d0f61a05b 64
HannesTschofenig 0:796d0f61a05b 65 struct _x509_crl_entry *next;
HannesTschofenig 0:796d0f61a05b 66 }
HannesTschofenig 0:796d0f61a05b 67 x509_crl_entry;
HannesTschofenig 0:796d0f61a05b 68
HannesTschofenig 0:796d0f61a05b 69 /**
HannesTschofenig 0:796d0f61a05b 70 * Certificate revocation list structure.
HannesTschofenig 0:796d0f61a05b 71 * Every CRL may have multiple entries.
HannesTschofenig 0:796d0f61a05b 72 */
HannesTschofenig 0:796d0f61a05b 73 typedef struct _x509_crl
HannesTschofenig 0:796d0f61a05b 74 {
HannesTschofenig 0:796d0f61a05b 75 x509_buf raw; /**< The raw certificate data (DER). */
HannesTschofenig 0:796d0f61a05b 76 x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */
HannesTschofenig 0:796d0f61a05b 77
HannesTschofenig 0:796d0f61a05b 78 int version;
HannesTschofenig 0:796d0f61a05b 79 x509_buf sig_oid1;
HannesTschofenig 0:796d0f61a05b 80
HannesTschofenig 0:796d0f61a05b 81 x509_buf issuer_raw; /**< The raw issuer data (DER). */
HannesTschofenig 0:796d0f61a05b 82
HannesTschofenig 0:796d0f61a05b 83 x509_name issuer; /**< The parsed issuer data (named information object). */
HannesTschofenig 0:796d0f61a05b 84
HannesTschofenig 0:796d0f61a05b 85 x509_time this_update;
HannesTschofenig 0:796d0f61a05b 86 x509_time next_update;
HannesTschofenig 0:796d0f61a05b 87
HannesTschofenig 0:796d0f61a05b 88 x509_crl_entry entry; /**< The CRL entries containing the certificate revocation times for this CA. */
HannesTschofenig 0:796d0f61a05b 89
HannesTschofenig 0:796d0f61a05b 90 x509_buf crl_ext;
HannesTschofenig 0:796d0f61a05b 91
HannesTschofenig 0:796d0f61a05b 92 x509_buf sig_oid2;
HannesTschofenig 0:796d0f61a05b 93 x509_buf sig;
HannesTschofenig 0:796d0f61a05b 94 md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. POLARSSL_MD_SHA256 */
HannesTschofenig 0:796d0f61a05b 95 pk_type_t sig_pk /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. POLARSSL_PK_RSA */;
HannesTschofenig 0:796d0f61a05b 96
HannesTschofenig 0:796d0f61a05b 97 struct _x509_crl *next;
HannesTschofenig 0:796d0f61a05b 98 }
HannesTschofenig 0:796d0f61a05b 99 x509_crl;
HannesTschofenig 0:796d0f61a05b 100
HannesTschofenig 0:796d0f61a05b 101 /**
HannesTschofenig 0:796d0f61a05b 102 * \brief Parse one or more CRLs and add them
HannesTschofenig 0:796d0f61a05b 103 * to the chained list
HannesTschofenig 0:796d0f61a05b 104 *
HannesTschofenig 0:796d0f61a05b 105 * \param chain points to the start of the chain
HannesTschofenig 0:796d0f61a05b 106 * \param buf buffer holding the CRL data
HannesTschofenig 0:796d0f61a05b 107 * \param buflen size of the buffer
HannesTschofenig 0:796d0f61a05b 108 *
HannesTschofenig 0:796d0f61a05b 109 * \return 0 if successful, or a specific X509 or PEM error code
HannesTschofenig 0:796d0f61a05b 110 */
HannesTschofenig 0:796d0f61a05b 111 int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen );
HannesTschofenig 0:796d0f61a05b 112
HannesTschofenig 0:796d0f61a05b 113 #if defined(POLARSSL_FS_IO)
HannesTschofenig 0:796d0f61a05b 114 /**
HannesTschofenig 0:796d0f61a05b 115 * \brief Load one or more CRLs and add them
HannesTschofenig 0:796d0f61a05b 116 * to the chained list
HannesTschofenig 0:796d0f61a05b 117 *
HannesTschofenig 0:796d0f61a05b 118 * \param chain points to the start of the chain
HannesTschofenig 0:796d0f61a05b 119 * \param path filename to read the CRLs from
HannesTschofenig 0:796d0f61a05b 120 *
HannesTschofenig 0:796d0f61a05b 121 * \return 0 if successful, or a specific X509 or PEM error code
HannesTschofenig 0:796d0f61a05b 122 */
HannesTschofenig 0:796d0f61a05b 123 int x509_crl_parse_file( x509_crl *chain, const char *path );
HannesTschofenig 0:796d0f61a05b 124 #endif /* POLARSSL_FS_IO */
HannesTschofenig 0:796d0f61a05b 125
HannesTschofenig 0:796d0f61a05b 126 /**
HannesTschofenig 0:796d0f61a05b 127 * \brief Returns an informational string about the CRL.
HannesTschofenig 0:796d0f61a05b 128 *
HannesTschofenig 0:796d0f61a05b 129 * \param buf Buffer to write to
HannesTschofenig 0:796d0f61a05b 130 * \param size Maximum size of buffer
HannesTschofenig 0:796d0f61a05b 131 * \param prefix A line prefix
HannesTschofenig 0:796d0f61a05b 132 * \param crl The X509 CRL to represent
HannesTschofenig 0:796d0f61a05b 133 *
HannesTschofenig 0:796d0f61a05b 134 * \return The amount of data written to the buffer, or -1 in
HannesTschofenig 0:796d0f61a05b 135 * case of an error.
HannesTschofenig 0:796d0f61a05b 136 */
HannesTschofenig 0:796d0f61a05b 137 int x509_crl_info( char *buf, size_t size, const char *prefix,
HannesTschofenig 0:796d0f61a05b 138 const x509_crl *crl );
HannesTschofenig 0:796d0f61a05b 139
HannesTschofenig 0:796d0f61a05b 140 /**
HannesTschofenig 0:796d0f61a05b 141 * \brief Initialize a CRL (chain)
HannesTschofenig 0:796d0f61a05b 142 *
HannesTschofenig 0:796d0f61a05b 143 * \param crl CRL chain to initialize
HannesTschofenig 0:796d0f61a05b 144 */
HannesTschofenig 0:796d0f61a05b 145 void x509_crl_init( x509_crl *crl );
HannesTschofenig 0:796d0f61a05b 146
HannesTschofenig 0:796d0f61a05b 147 /**
HannesTschofenig 0:796d0f61a05b 148 * \brief Unallocate all CRL data
HannesTschofenig 0:796d0f61a05b 149 *
HannesTschofenig 0:796d0f61a05b 150 * \param crl CRL chain to free
HannesTschofenig 0:796d0f61a05b 151 */
HannesTschofenig 0:796d0f61a05b 152 void x509_crl_free( x509_crl *crl );
HannesTschofenig 0:796d0f61a05b 153
HannesTschofenig 0:796d0f61a05b 154 /* \} name */
HannesTschofenig 0:796d0f61a05b 155 /* \} addtogroup x509_module */
HannesTschofenig 0:796d0f61a05b 156
HannesTschofenig 0:796d0f61a05b 157 #ifdef __cplusplus
HannesTschofenig 0:796d0f61a05b 158 }
HannesTschofenig 0:796d0f61a05b 159 #endif
HannesTschofenig 0:796d0f61a05b 160
HannesTschofenig 0:796d0f61a05b 161 #endif /* x509_crl.h */
HannesTschofenig 0:796d0f61a05b 162
HannesTschofenig 0:796d0f61a05b 163