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

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ssl_ciphersuites.h Source File

ssl_ciphersuites.h

Go to the documentation of this file.
00001 /**
00002  * \file ssl_ciphersuites.h
00003  *
00004  * \brief SSL Ciphersuites for PolarSSL
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_SSL_CIPHERSUITES_H
00028 #define POLARSSL_SSL_CIPHERSUITES_H
00029 
00030 #include "pk.h"
00031 #include "cipher.h"
00032 #include "md.h"
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 /*
00039  * Supported ciphersuites (Official IANA names)
00040  */
00041 #define TLS_RSA_WITH_NULL_MD5                    0x01   /**< Weak! */
00042 #define TLS_RSA_WITH_NULL_SHA                    0x02   /**< Weak! */
00043 
00044 #define TLS_RSA_WITH_RC4_128_MD5                 0x04
00045 #define TLS_RSA_WITH_RC4_128_SHA                 0x05
00046 #define TLS_RSA_WITH_DES_CBC_SHA                 0x09   /**< Weak! Not in TLS 1.2 */
00047 
00048 #define TLS_RSA_WITH_3DES_EDE_CBC_SHA            0x0A
00049 
00050 #define TLS_DHE_RSA_WITH_DES_CBC_SHA             0x15   /**< Weak! Not in TLS 1.2 */
00051 #define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA        0x16
00052 
00053 #define TLS_PSK_WITH_NULL_SHA                    0x2C   /**< Weak! */
00054 #define TLS_DHE_PSK_WITH_NULL_SHA                0x2D   /**< Weak! */
00055 #define TLS_RSA_PSK_WITH_NULL_SHA                0x2E   /**< Weak! */
00056 #define TLS_RSA_WITH_AES_128_CBC_SHA             0x2F
00057 
00058 #define TLS_DHE_RSA_WITH_AES_128_CBC_SHA         0x33
00059 #define TLS_RSA_WITH_AES_256_CBC_SHA             0x35
00060 #define TLS_DHE_RSA_WITH_AES_256_CBC_SHA         0x39
00061 
00062 #define TLS_RSA_WITH_NULL_SHA256                 0x3B   /**< Weak! */
00063 #define TLS_RSA_WITH_AES_128_CBC_SHA256          0x3C   /**< TLS 1.2 */
00064 #define TLS_RSA_WITH_AES_256_CBC_SHA256          0x3D   /**< TLS 1.2 */
00065 
00066 #define TLS_RSA_WITH_CAMELLIA_128_CBC_SHA        0x41
00067 #define TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA    0x45
00068 
00069 #define TLS_DHE_RSA_WITH_AES_128_CBC_SHA256      0x67   /**< TLS 1.2 */
00070 #define TLS_DHE_RSA_WITH_AES_256_CBC_SHA256      0x6B   /**< TLS 1.2 */
00071 
00072 #define TLS_RSA_WITH_CAMELLIA_256_CBC_SHA        0x84
00073 #define TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA    0x88
00074 
00075 #define TLS_PSK_WITH_RC4_128_SHA                 0x8A
00076 #define TLS_PSK_WITH_3DES_EDE_CBC_SHA            0x8B
00077 #define TLS_PSK_WITH_AES_128_CBC_SHA             0x8C
00078 #define TLS_PSK_WITH_AES_256_CBC_SHA             0x8D
00079 
00080 #define TLS_DHE_PSK_WITH_RC4_128_SHA             0x8E
00081 #define TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA        0x8F
00082 #define TLS_DHE_PSK_WITH_AES_128_CBC_SHA         0x90
00083 #define TLS_DHE_PSK_WITH_AES_256_CBC_SHA         0x91
00084 
00085 #define TLS_RSA_PSK_WITH_RC4_128_SHA             0x92
00086 #define TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA        0x93
00087 #define TLS_RSA_PSK_WITH_AES_128_CBC_SHA         0x94
00088 #define TLS_RSA_PSK_WITH_AES_256_CBC_SHA         0x95
00089 
00090 #define TLS_RSA_WITH_AES_128_GCM_SHA256          0x9C   /**< TLS 1.2 */
00091 #define TLS_RSA_WITH_AES_256_GCM_SHA384          0x9D   /**< TLS 1.2 */
00092 #define TLS_DHE_RSA_WITH_AES_128_GCM_SHA256      0x9E   /**< TLS 1.2 */
00093 #define TLS_DHE_RSA_WITH_AES_256_GCM_SHA384      0x9F   /**< TLS 1.2 */
00094 
00095 #define TLS_PSK_WITH_AES_128_GCM_SHA256          0xA8   /**< TLS 1.2 */
00096 #define TLS_PSK_WITH_AES_256_GCM_SHA384          0xA9   /**< TLS 1.2 */
00097 #define TLS_DHE_PSK_WITH_AES_128_GCM_SHA256      0xAA   /**< TLS 1.2 */
00098 #define TLS_DHE_PSK_WITH_AES_256_GCM_SHA384      0xAB   /**< TLS 1.2 */
00099 #define TLS_RSA_PSK_WITH_AES_128_GCM_SHA256      0xAC   /**< TLS 1.2 */
00100 #define TLS_RSA_PSK_WITH_AES_256_GCM_SHA384      0xAD   /**< TLS 1.2 */
00101 
00102 #define TLS_PSK_WITH_AES_128_CBC_SHA256          0xAE
00103 #define TLS_PSK_WITH_AES_256_CBC_SHA384          0xAF
00104 #define TLS_PSK_WITH_NULL_SHA256                 0xB0   /**< Weak! */
00105 #define TLS_PSK_WITH_NULL_SHA384                 0xB1   /**< Weak! */
00106 
00107 #define TLS_DHE_PSK_WITH_AES_128_CBC_SHA256      0xB2
00108 #define TLS_DHE_PSK_WITH_AES_256_CBC_SHA384      0xB3
00109 #define TLS_DHE_PSK_WITH_NULL_SHA256             0xB4   /**< Weak! */
00110 #define TLS_DHE_PSK_WITH_NULL_SHA384             0xB5   /**< Weak! */
00111 
00112 #define TLS_RSA_PSK_WITH_AES_128_CBC_SHA256      0xB6
00113 #define TLS_RSA_PSK_WITH_AES_256_CBC_SHA384      0xB7
00114 #define TLS_RSA_PSK_WITH_NULL_SHA256             0xB8   /**< Weak! */
00115 #define TLS_RSA_PSK_WITH_NULL_SHA384             0xB9   /**< Weak! */
00116 
00117 #define TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256     0xBA   /**< TLS 1.2 */
00118 #define TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xBE   /**< TLS 1.2 */
00119 
00120 #define TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256     0xC0   /**< TLS 1.2 */
00121 #define TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 0xC4   /**< TLS 1.2 */
00122 
00123 #define TLS_ECDH_ECDSA_WITH_NULL_SHA             0xC001 /**< Weak! */
00124 #define TLS_ECDH_ECDSA_WITH_RC4_128_SHA          0xC002 /**< Not in SSL3! */
00125 #define TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA     0xC003 /**< Not in SSL3! */
00126 #define TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA      0xC004 /**< Not in SSL3! */
00127 #define TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA      0xC005 /**< Not in SSL3! */
00128 
00129 #define TLS_ECDHE_ECDSA_WITH_NULL_SHA            0xC006 /**< Weak! */
00130 #define TLS_ECDHE_ECDSA_WITH_RC4_128_SHA         0xC007 /**< Not in SSL3! */
00131 #define TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA    0xC008 /**< Not in SSL3! */
00132 #define TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA     0xC009 /**< Not in SSL3! */
00133 #define TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA     0xC00A /**< Not in SSL3! */
00134 
00135 #define TLS_ECDH_RSA_WITH_NULL_SHA               0xC00B /**< Weak! */
00136 #define TLS_ECDH_RSA_WITH_RC4_128_SHA            0xC00C /**< Not in SSL3! */
00137 #define TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA       0xC00D /**< Not in SSL3! */
00138 #define TLS_ECDH_RSA_WITH_AES_128_CBC_SHA        0xC00E /**< Not in SSL3! */
00139 #define TLS_ECDH_RSA_WITH_AES_256_CBC_SHA        0xC00F /**< Not in SSL3! */
00140 
00141 #define TLS_ECDHE_RSA_WITH_NULL_SHA              0xC010 /**< Weak! */
00142 #define TLS_ECDHE_RSA_WITH_RC4_128_SHA           0xC011 /**< Not in SSL3! */
00143 #define TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA      0xC012 /**< Not in SSL3! */
00144 #define TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA       0xC013 /**< Not in SSL3! */
00145 #define TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA       0xC014 /**< Not in SSL3! */
00146 
00147 #define TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256  0xC023 /**< TLS 1.2 */
00148 #define TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384  0xC024 /**< TLS 1.2 */
00149 #define TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256   0xC025 /**< TLS 1.2 */
00150 #define TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384   0xC026 /**< TLS 1.2 */
00151 #define TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256    0xC027 /**< TLS 1.2 */
00152 #define TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384    0xC028 /**< TLS 1.2 */
00153 #define TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256     0xC029 /**< TLS 1.2 */
00154 #define TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384     0xC02A /**< TLS 1.2 */
00155 
00156 #define TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256  0xC02B /**< TLS 1.2 */
00157 #define TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384  0xC02C /**< TLS 1.2 */
00158 #define TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256   0xC02D /**< TLS 1.2 */
00159 #define TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384   0xC02E /**< TLS 1.2 */
00160 #define TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256    0xC02F /**< TLS 1.2 */
00161 #define TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384    0xC030 /**< TLS 1.2 */
00162 #define TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256     0xC031 /**< TLS 1.2 */
00163 #define TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384     0xC032 /**< TLS 1.2 */
00164 
00165 #define TLS_ECDHE_PSK_WITH_RC4_128_SHA           0xC033 /**< Not in SSL3! */
00166 #define TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA      0xC034 /**< Not in SSL3! */
00167 #define TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA       0xC035 /**< Not in SSL3! */
00168 #define TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA       0xC036 /**< Not in SSL3! */
00169 #define TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256    0xC037 /**< Not in SSL3! */
00170 #define TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384    0xC038 /**< Not in SSL3! */
00171 #define TLS_ECDHE_PSK_WITH_NULL_SHA              0xC039 /**< Weak! No SSL3! */
00172 #define TLS_ECDHE_PSK_WITH_NULL_SHA256           0xC03A /**< Weak! No SSL3! */
00173 #define TLS_ECDHE_PSK_WITH_NULL_SHA384           0xC03B /**< Weak! No SSL3! */
00174 
00175 #define TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0xC072 /**< Not in SSL3! */
00176 #define TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0xC073 /**< Not in SSL3! */
00177 #define TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256  0xC074 /**< Not in SSL3! */
00178 #define TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384  0xC075 /**< Not in SSL3! */
00179 #define TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256   0xC076 /**< Not in SSL3! */
00180 #define TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384   0xC077 /**< Not in SSL3! */
00181 #define TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256    0xC078 /**< Not in SSL3! */
00182 #define TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384    0xC079 /**< Not in SSL3! */
00183 
00184 #define TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256         0xC07A /**< TLS 1.2 */
00185 #define TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384         0xC07B /**< TLS 1.2 */
00186 #define TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256     0xC07C /**< TLS 1.2 */
00187 #define TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384     0xC07D /**< TLS 1.2 */
00188 #define TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 0xC086 /**< TLS 1.2 */
00189 #define TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 0xC087 /**< TLS 1.2 */
00190 #define TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256  0xC088 /**< TLS 1.2 */
00191 #define TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384  0xC089 /**< TLS 1.2 */
00192 #define TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256   0xC08A /**< TLS 1.2 */
00193 #define TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384   0xC08B /**< TLS 1.2 */
00194 #define TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256    0xC08C /**< TLS 1.2 */
00195 #define TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384    0xC08D /**< TLS 1.2 */
00196 
00197 #define TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256       0xC08E /**< TLS 1.2 */
00198 #define TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384       0xC08F /**< TLS 1.2 */
00199 #define TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256   0xC090 /**< TLS 1.2 */
00200 #define TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384   0xC091 /**< TLS 1.2 */
00201 #define TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256   0xC092 /**< TLS 1.2 */
00202 #define TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384   0xC093 /**< TLS 1.2 */
00203 
00204 #define TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256       0xC094
00205 #define TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384       0xC095
00206 #define TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256   0xC096
00207 #define TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384   0xC097
00208 #define TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256   0xC098
00209 #define TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384   0xC099
00210 #define TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0xC09A /**< Not in SSL3! */
00211 #define TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0xC09B /**< Not in SSL3! */
00212 
00213 typedef enum {
00214     POLARSSL_KEY_EXCHANGE_NONE = 0,
00215     POLARSSL_KEY_EXCHANGE_RSA,
00216     POLARSSL_KEY_EXCHANGE_DHE_RSA,
00217     POLARSSL_KEY_EXCHANGE_ECDHE_RSA,
00218     POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA,
00219     POLARSSL_KEY_EXCHANGE_PSK,
00220     POLARSSL_KEY_EXCHANGE_DHE_PSK,
00221     POLARSSL_KEY_EXCHANGE_RSA_PSK,
00222     POLARSSL_KEY_EXCHANGE_ECDHE_PSK,
00223     POLARSSL_KEY_EXCHANGE_ECDH_RSA,
00224     POLARSSL_KEY_EXCHANGE_ECDH_ECDSA,
00225 } key_exchange_type_t;
00226 
00227 typedef struct _ssl_ciphersuite_t ssl_ciphersuite_t;
00228 
00229 #define POLARSSL_CIPHERSUITE_WEAK   0x01    /**< Weak ciphersuite flag      */
00230 
00231 /**
00232  * \brief   This structure is used for storing ciphersuite information
00233  */
00234 struct _ssl_ciphersuite_t
00235 {
00236     int id;
00237     const char * name;
00238 
00239     cipher_type_t cipher;
00240     md_type_t mac;
00241     key_exchange_type_t key_exchange;
00242 
00243     int min_major_ver;
00244     int min_minor_ver;
00245     int max_major_ver;
00246     int max_minor_ver;
00247 
00248     unsigned char flags;
00249 };
00250 
00251 const int *ssl_list_ciphersuites( void );
00252 
00253 const ssl_ciphersuite_t *ssl_ciphersuite_from_string( const char *ciphersuite_name );
00254 const ssl_ciphersuite_t *ssl_ciphersuite_from_id( int ciphersuite_id );
00255 
00256 #if defined(POLARSSL_PK_C)
00257 pk_type_t ssl_get_ciphersuite_sig_pk_alg( const ssl_ciphersuite_t *info );
00258 #endif
00259 
00260 int ssl_ciphersuite_uses_ec( const ssl_ciphersuite_t *info );
00261 int ssl_ciphersuite_uses_psk( const ssl_ciphersuite_t *info );
00262 
00263 #ifdef __cplusplus
00264 }
00265 #endif
00266 
00267 #endif /* ssl_ciphersuites.h */
00268 
00269