VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.7/test/ciphername_test.c@ 106165

最後變更 在這個檔案從106165是 104078,由 vboxsync 提交於 8 月 前

openssl-3.1.5: Applied and adjusted our OpenSSL changes to 3.1.4. bugref:10638

檔案大小: 20.6 KB
 
1/*
2 * Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright 2017 BaishanCloud. All rights reserved.
4 *
5 * Licensed under the Apache License 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 * https://www.openssl.org/source/license.html
9 * or in the file LICENSE in the source distribution.
10 */
11
12#include <stdio.h>
13#include <string.h>
14
15#include <openssl/opensslconf.h>
16#include <openssl/err.h>
17#include <openssl/e_os2.h>
18#include <openssl/ssl.h>
19#include <openssl/ssl3.h>
20#include <openssl/tls1.h>
21
22#include "internal/nelem.h"
23#include "testutil.h"
24
25typedef struct cipher_id_name {
26 int id;
27 const char *name;
28} CIPHER_ID_NAME;
29
30/* Cipher suites, copied from t1_trce.c */
31static CIPHER_ID_NAME cipher_names[] = {
32 {0x0000, "TLS_NULL_WITH_NULL_NULL"},
33 {0x0001, "TLS_RSA_WITH_NULL_MD5"},
34 {0x0002, "TLS_RSA_WITH_NULL_SHA"},
35 {0x0003, "TLS_RSA_EXPORT_WITH_RC4_40_MD5"},
36 {0x0004, "TLS_RSA_WITH_RC4_128_MD5"},
37 {0x0005, "TLS_RSA_WITH_RC4_128_SHA"},
38 {0x0006, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5"},
39 {0x0007, "TLS_RSA_WITH_IDEA_CBC_SHA"},
40 {0x0008, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA"},
41 {0x0009, "TLS_RSA_WITH_DES_CBC_SHA"},
42 {0x000A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA"},
43 {0x000B, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA"},
44 {0x000C, "TLS_DH_DSS_WITH_DES_CBC_SHA"},
45 {0x000D, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA"},
46 {0x000E, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA"},
47 {0x000F, "TLS_DH_RSA_WITH_DES_CBC_SHA"},
48 {0x0010, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA"},
49 {0x0011, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"},
50 {0x0012, "TLS_DHE_DSS_WITH_DES_CBC_SHA"},
51 {0x0013, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA"},
52 {0x0014, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA"},
53 {0x0015, "TLS_DHE_RSA_WITH_DES_CBC_SHA"},
54 {0x0016, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA"},
55 {0x0017, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5"},
56 {0x0018, "TLS_DH_anon_WITH_RC4_128_MD5"},
57 {0x0019, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA"},
58 {0x001A, "TLS_DH_anon_WITH_DES_CBC_SHA"},
59 {0x001B, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA"},
60 {0x001D, "SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA"},
61 {0x001E, "SSL_FORTEZZA_KEA_WITH_RC4_128_SHA"},
62 {0x001F, "TLS_KRB5_WITH_3DES_EDE_CBC_SHA"},
63 {0x0020, "TLS_KRB5_WITH_RC4_128_SHA"},
64 {0x0021, "TLS_KRB5_WITH_IDEA_CBC_SHA"},
65 {0x0022, "TLS_KRB5_WITH_DES_CBC_MD5"},
66 {0x0023, "TLS_KRB5_WITH_3DES_EDE_CBC_MD5"},
67 {0x0024, "TLS_KRB5_WITH_RC4_128_MD5"},
68 {0x0025, "TLS_KRB5_WITH_IDEA_CBC_MD5"},
69 {0x0026, "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA"},
70 {0x0027, "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA"},
71 {0x0028, "TLS_KRB5_EXPORT_WITH_RC4_40_SHA"},
72 {0x0029, "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5"},
73 {0x002A, "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5"},
74 {0x002B, "TLS_KRB5_EXPORT_WITH_RC4_40_MD5"},
75 {0x002C, "TLS_PSK_WITH_NULL_SHA"},
76 {0x002D, "TLS_DHE_PSK_WITH_NULL_SHA"},
77 {0x002E, "TLS_RSA_PSK_WITH_NULL_SHA"},
78 {0x002F, "TLS_RSA_WITH_AES_128_CBC_SHA"},
79 {0x0030, "TLS_DH_DSS_WITH_AES_128_CBC_SHA"},
80 {0x0031, "TLS_DH_RSA_WITH_AES_128_CBC_SHA"},
81 {0x0032, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA"},
82 {0x0033, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA"},
83 {0x0034, "TLS_DH_anon_WITH_AES_128_CBC_SHA"},
84 {0x0035, "TLS_RSA_WITH_AES_256_CBC_SHA"},
85 {0x0036, "TLS_DH_DSS_WITH_AES_256_CBC_SHA"},
86 {0x0037, "TLS_DH_RSA_WITH_AES_256_CBC_SHA"},
87 {0x0038, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA"},
88 {0x0039, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA"},
89 {0x003A, "TLS_DH_anon_WITH_AES_256_CBC_SHA"},
90 {0x003B, "TLS_RSA_WITH_NULL_SHA256"},
91 {0x003C, "TLS_RSA_WITH_AES_128_CBC_SHA256"},
92 {0x003D, "TLS_RSA_WITH_AES_256_CBC_SHA256"},
93 {0x003E, "TLS_DH_DSS_WITH_AES_128_CBC_SHA256"},
94 {0x003F, "TLS_DH_RSA_WITH_AES_128_CBC_SHA256"},
95 {0x0040, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256"},
96 {0x0041, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA"},
97 {0x0042, "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA"},
98 {0x0043, "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA"},
99 {0x0044, "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA"},
100 {0x0045, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA"},
101 {0x0046, "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA"},
102 {0x0067, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256"},
103 {0x0068, "TLS_DH_DSS_WITH_AES_256_CBC_SHA256"},
104 {0x0069, "TLS_DH_RSA_WITH_AES_256_CBC_SHA256"},
105 {0x006A, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256"},
106 {0x006B, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256"},
107 {0x006C, "TLS_DH_anon_WITH_AES_128_CBC_SHA256"},
108 {0x006D, "TLS_DH_anon_WITH_AES_256_CBC_SHA256"},
109 {0x0084, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA"},
110 {0x0085, "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA"},
111 {0x0086, "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA"},
112 {0x0087, "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA"},
113 {0x0088, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA"},
114 {0x0089, "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA"},
115 {0x008A, "TLS_PSK_WITH_RC4_128_SHA"},
116 {0x008B, "TLS_PSK_WITH_3DES_EDE_CBC_SHA"},
117 {0x008C, "TLS_PSK_WITH_AES_128_CBC_SHA"},
118 {0x008D, "TLS_PSK_WITH_AES_256_CBC_SHA"},
119 {0x008E, "TLS_DHE_PSK_WITH_RC4_128_SHA"},
120 {0x008F, "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA"},
121 {0x0090, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA"},
122 {0x0091, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA"},
123 {0x0092, "TLS_RSA_PSK_WITH_RC4_128_SHA"},
124 {0x0093, "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA"},
125 {0x0094, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA"},
126 {0x0095, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA"},
127 {0x0096, "TLS_RSA_WITH_SEED_CBC_SHA"},
128 {0x0097, "TLS_DH_DSS_WITH_SEED_CBC_SHA"},
129 {0x0098, "TLS_DH_RSA_WITH_SEED_CBC_SHA"},
130 {0x0099, "TLS_DHE_DSS_WITH_SEED_CBC_SHA"},
131 {0x009A, "TLS_DHE_RSA_WITH_SEED_CBC_SHA"},
132 {0x009B, "TLS_DH_anon_WITH_SEED_CBC_SHA"},
133 {0x009C, "TLS_RSA_WITH_AES_128_GCM_SHA256"},
134 {0x009D, "TLS_RSA_WITH_AES_256_GCM_SHA384"},
135 {0x009E, "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"},
136 {0x009F, "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384"},
137 {0x00A0, "TLS_DH_RSA_WITH_AES_128_GCM_SHA256"},
138 {0x00A1, "TLS_DH_RSA_WITH_AES_256_GCM_SHA384"},
139 {0x00A2, "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256"},
140 {0x00A3, "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384"},
141 {0x00A4, "TLS_DH_DSS_WITH_AES_128_GCM_SHA256"},
142 {0x00A5, "TLS_DH_DSS_WITH_AES_256_GCM_SHA384"},
143 {0x00A6, "TLS_DH_anon_WITH_AES_128_GCM_SHA256"},
144 {0x00A7, "TLS_DH_anon_WITH_AES_256_GCM_SHA384"},
145 {0x00A8, "TLS_PSK_WITH_AES_128_GCM_SHA256"},
146 {0x00A9, "TLS_PSK_WITH_AES_256_GCM_SHA384"},
147 {0x00AA, "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256"},
148 {0x00AB, "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384"},
149 {0x00AC, "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256"},
150 {0x00AD, "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384"},
151 {0x00AE, "TLS_PSK_WITH_AES_128_CBC_SHA256"},
152 {0x00AF, "TLS_PSK_WITH_AES_256_CBC_SHA384"},
153 {0x00B0, "TLS_PSK_WITH_NULL_SHA256"},
154 {0x00B1, "TLS_PSK_WITH_NULL_SHA384"},
155 {0x00B2, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256"},
156 {0x00B3, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384"},
157 {0x00B4, "TLS_DHE_PSK_WITH_NULL_SHA256"},
158 {0x00B5, "TLS_DHE_PSK_WITH_NULL_SHA384"},
159 {0x00B6, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256"},
160 {0x00B7, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384"},
161 {0x00B8, "TLS_RSA_PSK_WITH_NULL_SHA256"},
162 {0x00B9, "TLS_RSA_PSK_WITH_NULL_SHA384"},
163 {0x00BA, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256"},
164 {0x00BB, "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256"},
165 {0x00BC, "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256"},
166 {0x00BD, "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256"},
167 {0x00BE, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256"},
168 {0x00BF, "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256"},
169 {0x00C0, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256"},
170 {0x00C1, "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256"},
171 {0x00C2, "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256"},
172 {0x00C3, "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256"},
173 {0x00C4, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256"},
174 {0x00C5, "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256"},
175 {0x00FF, "TLS_EMPTY_RENEGOTIATION_INFO_SCSV"},
176 {0x5600, "TLS_FALLBACK_SCSV"},
177 {0xC001, "TLS_ECDH_ECDSA_WITH_NULL_SHA"},
178 {0xC002, "TLS_ECDH_ECDSA_WITH_RC4_128_SHA"},
179 {0xC003, "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA"},
180 {0xC004, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA"},
181 {0xC005, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA"},
182 {0xC006, "TLS_ECDHE_ECDSA_WITH_NULL_SHA"},
183 {0xC007, "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA"},
184 {0xC008, "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA"},
185 {0xC009, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA"},
186 {0xC00A, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA"},
187 {0xC00B, "TLS_ECDH_RSA_WITH_NULL_SHA"},
188 {0xC00C, "TLS_ECDH_RSA_WITH_RC4_128_SHA"},
189 {0xC00D, "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA"},
190 {0xC00E, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA"},
191 {0xC00F, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA"},
192 {0xC010, "TLS_ECDHE_RSA_WITH_NULL_SHA"},
193 {0xC011, "TLS_ECDHE_RSA_WITH_RC4_128_SHA"},
194 {0xC012, "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA"},
195 {0xC013, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA"},
196 {0xC014, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA"},
197 {0xC015, "TLS_ECDH_anon_WITH_NULL_SHA"},
198 {0xC016, "TLS_ECDH_anon_WITH_RC4_128_SHA"},
199 {0xC017, "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA"},
200 {0xC018, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA"},
201 {0xC019, "TLS_ECDH_anon_WITH_AES_256_CBC_SHA"},
202 {0xC01A, "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA"},
203 {0xC01B, "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA"},
204 {0xC01C, "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA"},
205 {0xC01D, "TLS_SRP_SHA_WITH_AES_128_CBC_SHA"},
206 {0xC01E, "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA"},
207 {0xC01F, "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA"},
208 {0xC020, "TLS_SRP_SHA_WITH_AES_256_CBC_SHA"},
209 {0xC021, "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA"},
210 {0xC022, "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA"},
211 {0xC023, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"},
212 {0xC024, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384"},
213 {0xC025, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256"},
214 {0xC026, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384"},
215 {0xC027, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"},
216 {0xC028, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384"},
217 {0xC029, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256"},
218 {0xC02A, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384"},
219 {0xC02B, "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"},
220 {0xC02C, "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"},
221 {0xC02D, "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256"},
222 {0xC02E, "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384"},
223 {0xC02F, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"},
224 {0xC030, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"},
225 {0xC031, "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256"},
226 {0xC032, "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384"},
227 {0xC033, "TLS_ECDHE_PSK_WITH_RC4_128_SHA"},
228 {0xC034, "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA"},
229 {0xC035, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA"},
230 {0xC036, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA"},
231 {0xC037, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256"},
232 {0xC038, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384"},
233 {0xC039, "TLS_ECDHE_PSK_WITH_NULL_SHA"},
234 {0xC03A, "TLS_ECDHE_PSK_WITH_NULL_SHA256"},
235 {0xC03B, "TLS_ECDHE_PSK_WITH_NULL_SHA384"},
236 {0xC03C, "TLS_RSA_WITH_ARIA_128_CBC_SHA256"},
237 {0xC03D, "TLS_RSA_WITH_ARIA_256_CBC_SHA384"},
238 {0xC03E, "TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256"},
239 {0xC03F, "TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384"},
240 {0xC040, "TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256"},
241 {0xC041, "TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384"},
242 {0xC042, "TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256"},
243 {0xC043, "TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384"},
244 {0xC044, "TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256"},
245 {0xC045, "TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384"},
246 {0xC046, "TLS_DH_anon_WITH_ARIA_128_CBC_SHA256"},
247 {0xC047, "TLS_DH_anon_WITH_ARIA_256_CBC_SHA384"},
248 {0xC048, "TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256"},
249 {0xC049, "TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384"},
250 {0xC04A, "TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256"},
251 {0xC04B, "TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384"},
252 {0xC04C, "TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256"},
253 {0xC04D, "TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384"},
254 {0xC04E, "TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256"},
255 {0xC04F, "TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384"},
256 {0xC050, "TLS_RSA_WITH_ARIA_128_GCM_SHA256"},
257 {0xC051, "TLS_RSA_WITH_ARIA_256_GCM_SHA384"},
258 {0xC052, "TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256"},
259 {0xC053, "TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384"},
260 {0xC054, "TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256"},
261 {0xC055, "TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384"},
262 {0xC056, "TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256"},
263 {0xC057, "TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384"},
264 {0xC058, "TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256"},
265 {0xC059, "TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384"},
266 {0xC05A, "TLS_DH_anon_WITH_ARIA_128_GCM_SHA256"},
267 {0xC05B, "TLS_DH_anon_WITH_ARIA_256_GCM_SHA384"},
268 {0xC05C, "TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256"},
269 {0xC05D, "TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384"},
270 {0xC05E, "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256"},
271 {0xC05F, "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384"},
272 {0xC060, "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256"},
273 {0xC061, "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384"},
274 {0xC062, "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256"},
275 {0xC063, "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384"},
276 {0xC064, "TLS_PSK_WITH_ARIA_128_CBC_SHA256"},
277 {0xC065, "TLS_PSK_WITH_ARIA_256_CBC_SHA384"},
278 {0xC066, "TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256"},
279 {0xC067, "TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384"},
280 {0xC068, "TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256"},
281 {0xC069, "TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384"},
282 {0xC06A, "TLS_PSK_WITH_ARIA_128_GCM_SHA256"},
283 {0xC06B, "TLS_PSK_WITH_ARIA_256_GCM_SHA384"},
284 {0xC06C, "TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256"},
285 {0xC06D, "TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384"},
286 {0xC06E, "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256"},
287 {0xC06F, "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384"},
288 {0xC070, "TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256"},
289 {0xC071, "TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384"},
290 {0xC072, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256"},
291 {0xC073, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384"},
292 {0xC074, "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256"},
293 {0xC075, "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384"},
294 {0xC076, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256"},
295 {0xC077, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384"},
296 {0xC078, "TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256"},
297 {0xC079, "TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384"},
298 {0xC07A, "TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256"},
299 {0xC07B, "TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384"},
300 {0xC07C, "TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256"},
301 {0xC07D, "TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384"},
302 {0xC07E, "TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256"},
303 {0xC07F, "TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384"},
304 {0xC080, "TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256"},
305 {0xC081, "TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384"},
306 {0xC082, "TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256"},
307 {0xC083, "TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384"},
308 {0xC084, "TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256"},
309 {0xC085, "TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384"},
310 {0xC086, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256"},
311 {0xC087, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384"},
312 {0xC088, "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256"},
313 {0xC089, "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384"},
314 {0xC08A, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256"},
315 {0xC08B, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384"},
316 {0xC08C, "TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256"},
317 {0xC08D, "TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384"},
318 {0xC08E, "TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256"},
319 {0xC08F, "TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384"},
320 {0xC090, "TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256"},
321 {0xC091, "TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384"},
322 {0xC092, "TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256"},
323 {0xC093, "TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384"},
324 {0xC094, "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256"},
325 {0xC095, "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384"},
326 {0xC096, "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256"},
327 {0xC097, "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384"},
328 {0xC098, "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256"},
329 {0xC099, "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384"},
330 {0xC09A, "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256"},
331 {0xC09B, "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384"},
332 {0xC09C, "TLS_RSA_WITH_AES_128_CCM"},
333 {0xC09D, "TLS_RSA_WITH_AES_256_CCM"},
334 {0xC09E, "TLS_DHE_RSA_WITH_AES_128_CCM"},
335 {0xC09F, "TLS_DHE_RSA_WITH_AES_256_CCM"},
336 {0xC0A0, "TLS_RSA_WITH_AES_128_CCM_8"},
337 {0xC0A1, "TLS_RSA_WITH_AES_256_CCM_8"},
338 {0xC0A2, "TLS_DHE_RSA_WITH_AES_128_CCM_8"},
339 {0xC0A3, "TLS_DHE_RSA_WITH_AES_256_CCM_8"},
340 {0xC0A4, "TLS_PSK_WITH_AES_128_CCM"},
341 {0xC0A5, "TLS_PSK_WITH_AES_256_CCM"},
342 {0xC0A6, "TLS_DHE_PSK_WITH_AES_128_CCM"},
343 {0xC0A7, "TLS_DHE_PSK_WITH_AES_256_CCM"},
344 {0xC0A8, "TLS_PSK_WITH_AES_128_CCM_8"},
345 {0xC0A9, "TLS_PSK_WITH_AES_256_CCM_8"},
346 {0xC0AA, "TLS_PSK_DHE_WITH_AES_128_CCM_8"},
347 {0xC0AB, "TLS_PSK_DHE_WITH_AES_256_CCM_8"},
348 {0xC0AC, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM"},
349 {0xC0AD, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM"},
350 {0xC0AE, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8"},
351 {0xC0AF, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8"},
352 {0xCCA8, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"},
353 {0xCCA9, "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"},
354 {0xCCAA, "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256"},
355 {0xCCAB, "TLS_PSK_WITH_CHACHA20_POLY1305_SHA256"},
356 {0xCCAC, "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256"},
357 {0xCCAD, "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256"},
358 {0xCCAE, "TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256"},
359 {0x1301, "TLS_AES_128_GCM_SHA256"},
360 {0x1302, "TLS_AES_256_GCM_SHA384"},
361 {0x1303, "TLS_CHACHA20_POLY1305_SHA256"},
362 {0x1304, "TLS_AES_128_CCM_SHA256"},
363 {0x1305, "TLS_AES_128_CCM_8_SHA256"},
364 {0xFEFE, "SSL_RSA_FIPS_WITH_DES_CBC_SHA"},
365 {0xFEFF, "SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA"},
366};
367
368static const char *get_std_name_by_id(int id)
369{
370 size_t i;
371
372 for (i = 0; i < OSSL_NELEM(cipher_names); i++)
373 if (cipher_names[i].id == id)
374 return cipher_names[i].name;
375
376 return NULL;
377}
378
379static int test_cipher_name(void)
380{
381 SSL_CTX *ctx = NULL;
382 SSL *ssl = NULL;
383 const SSL_CIPHER *c;
384 STACK_OF(SSL_CIPHER) *sk = NULL;
385 const char *ciphers = "ALL:eNULL", *p, *q, *r;
386 int i, id = 0, ret = 0;
387
388 /* tests for invalid input */
389 p = SSL_CIPHER_standard_name(NULL);
390 if (!TEST_str_eq(p, "(NONE)")) {
391 TEST_info("test_cipher_name(std) failed: NULL input doesn't return \"(NONE)\"\n");
392 goto err;
393 }
394
395 p = OPENSSL_cipher_name(NULL);
396 if (!TEST_str_eq(p, "(NONE)")) {
397 TEST_info("test_cipher_name(ossl) failed: NULL input doesn't return \"(NONE)\"\n");
398 goto err;
399 }
400
401 p = OPENSSL_cipher_name("This is not a valid cipher");
402 if (!TEST_str_eq(p, "(NONE)")) {
403 TEST_info("test_cipher_name(ossl) failed: invalid input doesn't return \"(NONE)\"\n");
404 goto err;
405 }
406
407 /* tests for valid input */
408 ctx = SSL_CTX_new(TLS_server_method());
409 if (ctx == NULL) {
410 TEST_info("test_cipher_name failed: internal error\n");
411 goto err;
412 }
413
414 if (!SSL_CTX_set_cipher_list(ctx, ciphers)) {
415 TEST_info("test_cipher_name failed: internal error\n");
416 goto err;
417 }
418
419 ssl = SSL_new(ctx);
420 if (ssl == NULL) {
421 TEST_info("test_cipher_name failed: internal error\n");
422 goto err;
423 }
424
425 sk = SSL_get_ciphers(ssl);
426 if (sk == NULL) {
427 TEST_info("test_cipher_name failed: internal error\n");
428 goto err;
429 }
430
431 for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {
432 c = sk_SSL_CIPHER_value(sk, i);
433 id = SSL_CIPHER_get_id(c) & 0xFFFF;
434 if ((id == 0xC102) || (id == 0xFF85) ||(id == 0xFF87))
435 /* skip GOST2012-GOST8912-GOST891 and GOST2012-NULL-GOST12 */
436 continue;
437 p = SSL_CIPHER_standard_name(c);
438 q = get_std_name_by_id(id);
439 if (!TEST_ptr(p)) {
440 TEST_info("test_cipher_name failed: expected %s, got NULL, cipher %x\n",
441 q, id);
442 goto err;
443 }
444 /* check if p is a valid standard name */
445 if (!TEST_str_eq(p, q)) {
446 TEST_info("test_cipher_name(std) failed: expected %s, got %s, cipher %x\n",
447 q, p, id);
448 goto err;
449 }
450 /* test OPENSSL_cipher_name */
451 q = SSL_CIPHER_get_name(c);
452 r = OPENSSL_cipher_name(p);
453 if (!TEST_str_eq(r, q)) {
454 TEST_info("test_cipher_name(ossl) failed: expected %s, got %s, cipher %x\n",
455 q, r, id);
456 goto err;
457 }
458 }
459 ret = 1;
460err:
461 SSL_CTX_free(ctx);
462 SSL_free(ssl);
463 return ret;
464}
465
466int setup_tests(void)
467{
468 ADD_TEST(test_cipher_name);
469 return 1;
470}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette