aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_suites.cpp
blob: c24cdb9f7f2538826b612eca554523ec829458b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* TLS Cipher Suites
* (C) 2004-2010 Jack Lloyd
*
* Released under the terms of the Botan license
*/

#include <botan/tls_suites.h>
#include <botan/tls_exceptn.h>

namespace Botan {

/**
* Convert an SSL/TLS ciphersuite to algorithm fields
*/
TLS_Ciphersuite TLS_Ciphersuite::lookup_ciphersuite(u16bit suite)
   {
   switch(suite)
      {
      // RSA ciphersuites

      case TLS_RSA_WITH_AES_128_CBC_SHA:
         return TLS_Ciphersuite("RSA", "", "SHA-1", "AES-128", 16);

      case TLS_RSA_WITH_AES_256_CBC_SHA:
         return TLS_Ciphersuite("RSA", "", "SHA-1", "AES-256", 32);

      case TLS_RSA_WITH_AES_128_CBC_SHA256:
         return TLS_Ciphersuite("RSA", "", "SHA-256", "AES-128", 16);

      case TLS_RSA_WITH_AES_256_CBC_SHA256:
         return TLS_Ciphersuite("RSA", "", "SHA-256", "AES-256", 32);

      case TLS_RSA_WITH_3DES_EDE_CBC_SHA:
         return TLS_Ciphersuite("RSA", "", "SHA-1", "TripleDES", 24);

      case TLS_RSA_WITH_RC4_128_SHA:
         return TLS_Ciphersuite("RSA", "", "SHA-1", "ARC4", 16);

      case TLS_RSA_WITH_RC4_128_MD5:
         return TLS_Ciphersuite("RSA", "", "MD5", "ARC4", 16);

      case TLS_RSA_WITH_SEED_CBC_SHA:
         return TLS_Ciphersuite("RSA", "", "SHA-1", "SEED", 16);

      // DH/DSS ciphersuites

      case TLS_DHE_DSS_WITH_AES_128_CBC_SHA:
         return TLS_Ciphersuite("DSA", "DH", "SHA-1", "AES-128", 16);

      case TLS_DHE_DSS_WITH_AES_256_CBC_SHA:
         return TLS_Ciphersuite("DSA", "DH", "SHA-1", "AES-256", 32);

      case TLS_DHE_DSS_WITH_AES_128_CBC_SHA256:
         return TLS_Ciphersuite("DSA", "DH", "SHA-256", "AES-128", 16);

      case TLS_DHE_DSS_WITH_AES_256_CBC_SHA256:
         return TLS_Ciphersuite("DSA", "DH", "SHA-256", "AES-256", 32);

      case TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:
         return TLS_Ciphersuite("DSA", "DH", "SHA-1", "TripleDES", 24);

      case TLS_DHE_DSS_WITH_RC4_128_SHA:
         return TLS_Ciphersuite("DSA", "DH", "SHA-1", "ARC4", 16);

      case TLS_DHE_DSS_WITH_SEED_CBC_SHA:
         return TLS_Ciphersuite("DSA", "DH", "SHA-1", "SEED", 16);

      // DH/RSA ciphersuites

      case TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
         return TLS_Ciphersuite("RSA", "DH", "SHA-1", "AES-128", 16);

      case TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
         return TLS_Ciphersuite("RSA", "DH", "SHA-1", "AES-256", 32);

      case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
         return TLS_Ciphersuite("RSA", "DH", "SHA-256", "AES-128", 16);

      case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256:
         return TLS_Ciphersuite("RSA", "DH", "SHA-256", "AES-256", 32);

      case TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
         return TLS_Ciphersuite("RSA", "DH", "SHA-1", "TripleDES", 24);

      case TLS_DHE_RSA_WITH_SEED_CBC_SHA:
         return TLS_Ciphersuite("RSA", "DH", "SHA-1", "SEED", 16);

      // ECDH/RSA ciphersuites
      case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:
         return TLS_Ciphersuite("RSA", "ECDH", "SHA-1", "AES-128", 16);

      case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:
         return TLS_Ciphersuite("RSA", "ECDH", "SHA-1", "AES-256", 32);

      case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:
         return TLS_Ciphersuite("RSA", "ECDH", "SHA-1", "TripleDES", 24);

      case TLS_ECDHE_RSA_WITH_RC4_128_SHA:
         return TLS_Ciphersuite("RSA", "ECDH", "SHA-1", "ARC4", 16);

      // SRP/RSA ciphersuites

      case TLS_SRP_SHA_RSA_WITH_AES_128_SHA:
         return TLS_Ciphersuite("RSA", "SRP", "SHA-1", "AES-128", 16);

      case TLS_SRP_SHA_RSA_WITH_AES_256_SHA:
         return TLS_Ciphersuite("RSA", "SRP", "SHA-1", "AES-256", 32);

      case TLS_SRP_SHA_RSA_WITH_3DES_EDE_SHA:
         return TLS_Ciphersuite("RSA", "SRP", "SHA-1", "TripleDES", 24);

      // SRP/DSA ciphersuites

      case TLS_SRP_SHA_DSS_WITH_AES_128_SHA:
         return TLS_Ciphersuite("DSA", "SRP", "SHA-1", "AES-128", 16);

      case TLS_SRP_SHA_DSS_WITH_AES_256_SHA:
         return TLS_Ciphersuite("DSA", "SRP", "SHA-1", "AES-256", 32);

      case TLS_SRP_SHA_DSS_WITH_3DES_EDE_SHA:
         return TLS_Ciphersuite("DSA", "SRP", "SHA-1", "TripleDES", 24);

      // ECDH/ECDSA ciphersuites

      case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:
         return TLS_Ciphersuite("ECDSA", "ECDH", "SHA-1", "AES-128", 16);

      case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:
         return TLS_Ciphersuite("ECDSA", "ECDH", "SHA-1", "AES-256", 32);

      case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
         return TLS_Ciphersuite("ECDSA", "ECDH", "SHA-256", "AES-128", 16);

      case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
         return TLS_Ciphersuite("ECDSA", "ECDH", "SHA-384", "AES-256", 32);

      case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
         return TLS_Ciphersuite("ECDSA", "ECDH", "SHA-256", "AES-128", 16);

      case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
         return TLS_Ciphersuite("ECDSA", "ECDH", "SHA-384", "AES-256", 32);

      case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:
         return TLS_Ciphersuite("ECDSA", "ECDH", "SHA-1", "ARC4", 16);

      case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:
         return TLS_Ciphersuite("ECDSA", "ECDH", "SHA-1", "TripleDES", 24);

      default:
         return TLS_Ciphersuite(); // some unknown ciphersuite
      }
   }

TLS_Ciphersuite::TLS_Ciphersuite(const std::string& sig_algo,
                                 const std::string& kex_algo,
                                 const std::string& mac_algo,
                                 const std::string& cipher_algo,
                                 size_t cipher_algo_keylen) :
   m_sig_algo(sig_algo),
   m_kex_algo(kex_algo),
   m_mac_algo(mac_algo),
   m_cipher_algo(cipher_algo),
   m_cipher_keylen(cipher_algo_keylen)
   {
   }

}