tlsv1_common.h
Go to the documentation of this file.
00001 /*
00002  * TLSv1 common definitions
00003  * Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 2 as
00007  * published by the Free Software Foundation.
00008  *
00009  * Alternatively, this software may be distributed under the terms of BSD
00010  * license.
00011  *
00012  * See README and COPYING for more details.
00013  */
00014 
00015 #ifndef TLSV1_COMMON_H
00016 #define TLSV1_COMMON_H
00017 
00018 #include "crypto/crypto.h"
00019 
00020 #define TLS_VERSION 0x0301 /* TLSv1 */
00021 #define TLS_RANDOM_LEN 32
00022 #define TLS_PRE_MASTER_SECRET_LEN 48
00023 #define TLS_MASTER_SECRET_LEN 48
00024 #define TLS_SESSION_ID_MAX_LEN 32
00025 #define TLS_VERIFY_DATA_LEN 12
00026 
00027 /* HandshakeType */
00028 enum {
00029         TLS_HANDSHAKE_TYPE_HELLO_REQUEST = 0,
00030         TLS_HANDSHAKE_TYPE_CLIENT_HELLO = 1,
00031         TLS_HANDSHAKE_TYPE_SERVER_HELLO = 2,
00032         TLS_HANDSHAKE_TYPE_NEW_SESSION_TICKET = 4 /* RFC 4507 */,
00033         TLS_HANDSHAKE_TYPE_CERTIFICATE = 11,
00034         TLS_HANDSHAKE_TYPE_SERVER_KEY_EXCHANGE = 12,
00035         TLS_HANDSHAKE_TYPE_CERTIFICATE_REQUEST = 13,
00036         TLS_HANDSHAKE_TYPE_SERVER_HELLO_DONE = 14,
00037         TLS_HANDSHAKE_TYPE_CERTIFICATE_VERIFY = 15,
00038         TLS_HANDSHAKE_TYPE_CLIENT_KEY_EXCHANGE = 16,
00039         TLS_HANDSHAKE_TYPE_FINISHED = 20,
00040         TLS_HANDSHAKE_TYPE_CERTIFICATE_URL = 21 /* RFC 4366 */,
00041         TLS_HANDSHAKE_TYPE_CERTIFICATE_STATUS = 22 /* RFC 4366 */
00042 };
00043 
00044 /* CipherSuite */
00045 #define TLS_NULL_WITH_NULL_NULL                 0x0000 /* RFC 2246 */
00046 #define TLS_RSA_WITH_NULL_MD5                   0x0001 /* RFC 2246 */
00047 #define TLS_RSA_WITH_NULL_SHA                   0x0002 /* RFC 2246 */
00048 #define TLS_RSA_EXPORT_WITH_RC4_40_MD5          0x0003 /* RFC 2246 */
00049 #define TLS_RSA_WITH_RC4_128_MD5                0x0004 /* RFC 2246 */
00050 #define TLS_RSA_WITH_RC4_128_SHA                0x0005 /* RFC 2246 */
00051 #define TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5      0x0006 /* RFC 2246 */
00052 #define TLS_RSA_WITH_IDEA_CBC_SHA               0x0007 /* RFC 2246 */
00053 #define TLS_RSA_EXPORT_WITH_DES40_CBC_SHA       0x0008 /* RFC 2246 */
00054 #define TLS_RSA_WITH_DES_CBC_SHA                0x0009 /* RFC 2246 */
00055 #define TLS_RSA_WITH_3DES_EDE_CBC_SHA           0x000A /* RFC 2246 */
00056 #define TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA    0x000B /* RFC 2246 */
00057 #define TLS_DH_DSS_WITH_DES_CBC_SHA             0x000C /* RFC 2246 */
00058 #define TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA        0x000D /* RFC 2246 */
00059 #define TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA    0x000E /* RFC 2246 */
00060 #define TLS_DH_RSA_WITH_DES_CBC_SHA             0x000F /* RFC 2246 */
00061 #define TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA        0x0010 /* RFC 2246 */
00062 #define TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA   0x0011 /* RFC 2246 */
00063 #define TLS_DHE_DSS_WITH_DES_CBC_SHA            0x0012 /* RFC 2246 */
00064 #define TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA       0x0013 /* RFC 2246 */
00065 #define TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA   0x0014 /* RFC 2246 */
00066 #define TLS_DHE_RSA_WITH_DES_CBC_SHA            0x0015 /* RFC 2246 */
00067 #define TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA       0x0016 /* RFC 2246 */
00068 #define TLS_DH_anon_EXPORT_WITH_RC4_40_MD5      0x0017 /* RFC 2246 */
00069 #define TLS_DH_anon_WITH_RC4_128_MD5            0x0018 /* RFC 2246 */
00070 #define TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA   0x0019 /* RFC 2246 */
00071 #define TLS_DH_anon_WITH_DES_CBC_SHA            0x001A /* RFC 2246 */
00072 #define TLS_DH_anon_WITH_3DES_EDE_CBC_SHA       0x001B /* RFC 2246 */
00073 #define TLS_RSA_WITH_AES_128_CBC_SHA            0x002F /* RFC 3268 */
00074 #define TLS_DH_DSS_WITH_AES_128_CBC_SHA         0x0030 /* RFC 3268 */
00075 #define TLS_DH_RSA_WITH_AES_128_CBC_SHA         0x0031 /* RFC 3268 */
00076 #define TLS_DHE_DSS_WITH_AES_128_CBC_SHA        0x0032 /* RFC 3268 */
00077 #define TLS_DHE_RSA_WITH_AES_128_CBC_SHA        0x0033 /* RFC 3268 */
00078 #define TLS_DH_anon_WITH_AES_128_CBC_SHA        0x0034 /* RFC 3268 */
00079 #define TLS_RSA_WITH_AES_256_CBC_SHA            0x0035 /* RFC 3268 */
00080 #define TLS_DH_DSS_WITH_AES_256_CBC_SHA         0x0036 /* RFC 3268 */
00081 #define TLS_DH_RSA_WITH_AES_256_CBC_SHA         0x0037 /* RFC 3268 */
00082 #define TLS_DHE_DSS_WITH_AES_256_CBC_SHA        0x0038 /* RFC 3268 */
00083 #define TLS_DHE_RSA_WITH_AES_256_CBC_SHA        0x0039 /* RFC 3268 */
00084 #define TLS_DH_anon_WITH_AES_256_CBC_SHA        0x003A /* RFC 3268 */
00085 
00086 /* CompressionMethod */
00087 #define TLS_COMPRESSION_NULL 0
00088 
00089 /* AlertLevel */
00090 #define TLS_ALERT_LEVEL_WARNING 1
00091 #define TLS_ALERT_LEVEL_FATAL 2
00092 
00093 /* AlertDescription */
00094 #define TLS_ALERT_CLOSE_NOTIFY                  0
00095 #define TLS_ALERT_UNEXPECTED_MESSAGE            10
00096 #define TLS_ALERT_BAD_RECORD_MAC                20
00097 #define TLS_ALERT_DECRYPTION_FAILED             21
00098 #define TLS_ALERT_RECORD_OVERFLOW               22
00099 #define TLS_ALERT_DECOMPRESSION_FAILURE         30
00100 #define TLS_ALERT_HANDSHAKE_FAILURE             40
00101 #define TLS_ALERT_BAD_CERTIFICATE               42
00102 #define TLS_ALERT_UNSUPPORTED_CERTIFICATE       43
00103 #define TLS_ALERT_CERTIFICATE_REVOKED           44
00104 #define TLS_ALERT_CERTIFICATE_EXPIRED           45
00105 #define TLS_ALERT_CERTIFICATE_UNKNOWN           46
00106 #define TLS_ALERT_ILLEGAL_PARAMETER             47
00107 #define TLS_ALERT_UNKNOWN_CA                    48
00108 #define TLS_ALERT_ACCESS_DENIED                 49
00109 #define TLS_ALERT_DECODE_ERROR                  50
00110 #define TLS_ALERT_DECRYPT_ERROR                 51
00111 #define TLS_ALERT_EXPORT_RESTRICTION            60
00112 #define TLS_ALERT_PROTOCOL_VERSION              70
00113 #define TLS_ALERT_INSUFFICIENT_SECURITY         71
00114 #define TLS_ALERT_INTERNAL_ERROR                80
00115 #define TLS_ALERT_USER_CANCELED                 90
00116 #define TLS_ALERT_NO_RENEGOTIATION              100
00117 #define TLS_ALERT_UNSUPPORTED_EXTENSION         110 /* RFC 4366 */
00118 #define TLS_ALERT_CERTIFICATE_UNOBTAINABLE      111 /* RFC 4366 */
00119 #define TLS_ALERT_UNRECOGNIZED_NAME             112 /* RFC 4366 */
00120 #define TLS_ALERT_BAD_CERTIFICATE_STATUS_RESPONSE       113 /* RFC 4366 */
00121 #define TLS_ALERT_BAD_CERTIFICATE_HASH_VALUE    114 /* RFC 4366 */
00122 
00123 /* ChangeCipherSpec */
00124 enum {
00125         TLS_CHANGE_CIPHER_SPEC = 1
00126 };
00127 
00128 /* TLS Extensions */
00129 #define TLS_EXT_SERVER_NAME                     0 /* RFC 4366 */
00130 #define TLS_EXT_MAX_FRAGMENT_LENGTH             1 /* RFC 4366 */
00131 #define TLS_EXT_CLIENT_CERTIFICATE_URL          2 /* RFC 4366 */
00132 #define TLS_EXT_TRUSTED_CA_KEYS                 3 /* RFC 4366 */
00133 #define TLS_EXT_TRUNCATED_HMAC                  4 /* RFC 4366 */
00134 #define TLS_EXT_STATUS_REQUEST                  5 /* RFC 4366 */
00135 #define TLS_EXT_SESSION_TICKET                  35 /* RFC 4507 */
00136 
00137 #define TLS_EXT_PAC_OPAQUE TLS_EXT_SESSION_TICKET /* EAP-FAST terminology */
00138 
00139 
00140 typedef enum {
00141         TLS_KEY_X_NULL,
00142         TLS_KEY_X_RSA,
00143         TLS_KEY_X_RSA_EXPORT,
00144         TLS_KEY_X_DH_DSS_EXPORT,
00145         TLS_KEY_X_DH_DSS,
00146         TLS_KEY_X_DH_RSA_EXPORT,
00147         TLS_KEY_X_DH_RSA,
00148         TLS_KEY_X_DHE_DSS_EXPORT,
00149         TLS_KEY_X_DHE_DSS,
00150         TLS_KEY_X_DHE_RSA_EXPORT,
00151         TLS_KEY_X_DHE_RSA,
00152         TLS_KEY_X_DH_anon_EXPORT,
00153         TLS_KEY_X_DH_anon
00154 } tls_key_exchange;
00155 
00156 typedef enum {
00157         TLS_CIPHER_NULL,
00158         TLS_CIPHER_RC4_40,
00159         TLS_CIPHER_RC4_128,
00160         TLS_CIPHER_RC2_CBC_40,
00161         TLS_CIPHER_IDEA_CBC,
00162         TLS_CIPHER_DES40_CBC,
00163         TLS_CIPHER_DES_CBC,
00164         TLS_CIPHER_3DES_EDE_CBC,
00165         TLS_CIPHER_AES_128_CBC,
00166         TLS_CIPHER_AES_256_CBC
00167 } tls_cipher;
00168 
00169 typedef enum {
00170         TLS_HASH_NULL,
00171         TLS_HASH_MD5,
00172         TLS_HASH_SHA
00173 } tls_hash;
00174 
00175 struct tls_cipher_suite {
00176         u16 suite;
00177         tls_key_exchange key_exchange;
00178         tls_cipher cipher;
00179         tls_hash hash;
00180 };
00181 
00182 typedef enum {
00183         TLS_CIPHER_STREAM,
00184         TLS_CIPHER_BLOCK
00185 } tls_cipher_type;
00186 
00187 struct tls_cipher_data {
00188         tls_cipher cipher;
00189         tls_cipher_type type;
00190         size_t key_material;
00191         size_t expanded_key_material;
00192         size_t block_size; /* also iv_size */
00193         enum crypto_cipher_alg alg;
00194 };
00195 
00196 
00197 struct tls_verify_hash {
00198         struct crypto_hash *md5_client;
00199         struct crypto_hash *sha1_client;
00200         struct crypto_hash *md5_server;
00201         struct crypto_hash *sha1_server;
00202         struct crypto_hash *md5_cert;
00203         struct crypto_hash *sha1_cert;
00204 };
00205 
00206 
00207 const struct tls_cipher_suite * tls_get_cipher_suite(u16 suite);
00208 const struct tls_cipher_data * tls_get_cipher_data(tls_cipher cipher);
00209 int tls_server_key_exchange_allowed(tls_cipher cipher);
00210 int tls_parse_cert(const u8 *buf, size_t len, struct crypto_public_key **pk);
00211 int tls_verify_hash_init(struct tls_verify_hash *verify);
00212 void tls_verify_hash_add(struct tls_verify_hash *verify, const u8 *buf,
00213                          size_t len);
00214 void tls_verify_hash_free(struct tls_verify_hash *verify);
00215 
00216 #endif /* TLSV1_COMMON_H */


wpa_supplicant
Author(s): Package maintained by Blaise Gassend
autogenerated on Thu Jan 2 2014 11:26:38