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

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers x509_crl.h Source File

x509_crl.h

Go to the documentation of this file.
00001 /**
00002  * \file x509_crl.h
00003  *
00004  * \brief X.509 certificate revocation list parsing
00005  *
00006  *  Copyright (C) 2006-2013, Brainspark B.V.
00007  *
00008  *  This file is part of PolarSSL (http://www.polarssl.org)
00009  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
00010  *
00011  *  All rights reserved.
00012  *
00013  *  This program is free software; you can redistribute it and/or modify
00014  *  it under the terms of the GNU General Public License as published by
00015  *  the Free Software Foundation; either version 2 of the License, or
00016  *  (at your option) any later version.
00017  *
00018  *  This program is distributed in the hope that it will be useful,
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *  GNU General Public License for more details.
00022  *
00023  *  You should have received a copy of the GNU General Public License along
00024  *  with this program; if not, write to the Free Software Foundation, Inc.,
00025  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00026  */
00027 #ifndef POLARSSL_X509_CRL_H
00028 #define POLARSSL_X509_CRL_H
00029 
00030 #if !defined(POLARSSL_CONFIG_FILE)
00031 #include "config.h"
00032 #else
00033 #include POLARSSL_CONFIG_FILE
00034 #endif
00035 
00036 #include "x509.h"
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 /**
00043  * \addtogroup x509_module
00044  * \{ */
00045 
00046 /**
00047  * \name Structures and functions for parsing CRLs
00048  * \{
00049  */
00050 
00051 /**
00052  * Certificate revocation list entry.
00053  * Contains the CA-specific serial numbers and revocation dates.
00054  */
00055 typedef struct _x509_crl_entry
00056 {
00057     x509_buf raw;
00058 
00059     x509_buf serial;
00060 
00061     x509_time revocation_date;
00062 
00063     x509_buf entry_ext;
00064 
00065     struct _x509_crl_entry *next;
00066 }
00067 x509_crl_entry;
00068 
00069 /**
00070  * Certificate revocation list structure.
00071  * Every CRL may have multiple entries.
00072  */
00073 typedef struct _x509_crl
00074 {
00075     x509_buf raw;           /**< The raw certificate data (DER). */
00076     x509_buf tbs;           /**< The raw certificate body (DER). The part that is To Be Signed. */
00077 
00078     int version;
00079     x509_buf sig_oid1;
00080 
00081     x509_buf issuer_raw;    /**< The raw issuer data (DER). */
00082 
00083     x509_name issuer;       /**< The parsed issuer data (named information object). */
00084 
00085     x509_time this_update;
00086     x509_time next_update;
00087 
00088     x509_crl_entry entry;   /**< The CRL entries containing the certificate revocation times for this CA. */
00089 
00090     x509_buf crl_ext;
00091 
00092     x509_buf sig_oid2;
00093     x509_buf sig;
00094     md_type_t sig_md;           /**< Internal representation of the MD algorithm of the signature algorithm, e.g. POLARSSL_MD_SHA256 */
00095     pk_type_t sig_pk            /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. POLARSSL_PK_RSA */;
00096 
00097     struct _x509_crl *next;
00098 }
00099 x509_crl;
00100 
00101 /**
00102  * \brief          Parse one or more CRLs and add them
00103  *                 to the chained list
00104  *
00105  * \param chain    points to the start of the chain
00106  * \param buf      buffer holding the CRL data
00107  * \param buflen   size of the buffer
00108  *
00109  * \return         0 if successful, or a specific X509 or PEM error code
00110  */
00111 int x509_crl_parse( x509_crl *chain, const unsigned char *buf, size_t buflen );
00112 
00113 #if defined(POLARSSL_FS_IO)
00114 /**
00115  * \brief          Load one or more CRLs and add them
00116  *                 to the chained list
00117  *
00118  * \param chain    points to the start of the chain
00119  * \param path     filename to read the CRLs from
00120  *
00121  * \return         0 if successful, or a specific X509 or PEM error code
00122  */
00123 int x509_crl_parse_file( x509_crl *chain, const char *path );
00124 #endif /* POLARSSL_FS_IO */
00125 
00126 /**
00127  * \brief          Returns an informational string about the CRL.
00128  *
00129  * \param buf      Buffer to write to
00130  * \param size     Maximum size of buffer
00131  * \param prefix   A line prefix
00132  * \param crl      The X509 CRL to represent
00133  *
00134  * \return         The amount of data written to the buffer, or -1 in
00135  *                 case of an error.
00136  */
00137 int x509_crl_info( char *buf, size_t size, const char *prefix,
00138                    const x509_crl *crl );
00139 
00140 /**
00141  * \brief          Initialize a CRL (chain)
00142  *
00143  * \param crl      CRL chain to initialize
00144  */
00145 void x509_crl_init( x509_crl *crl );
00146 
00147 /**
00148  * \brief          Unallocate all CRL data
00149  *
00150  * \param crl      CRL chain to free
00151  */
00152 void x509_crl_free( x509_crl *crl );
00153 
00154 /* \} name */
00155 /* \} addtogroup x509_module */
00156 
00157 #ifdef __cplusplus
00158 }
00159 #endif
00160 
00161 #endif /* x509_crl.h */
00162 
00163