s3_lib.c 105.3 KB
Newer Older
R
Rich Salz 已提交
1
/*
P
Pauli 已提交
2
 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
B
Bodo Möller 已提交
3
 *
R
Rich Salz 已提交
4 5 6 7
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
B
Bodo Möller 已提交
8
 */
R
Rich Salz 已提交
9

B
Bodo Möller 已提交
10 11 12
/* ====================================================================
 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
 *
13
 * Portions of the attached software ("Contribution") are developed by
B
Bodo Möller 已提交
14 15 16 17 18 19 20 21 22
 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
 *
 * The Contribution is licensed pursuant to the OpenSSL open source
 * license provided above.
 *
 * ECC cipher suite support in OpenSSL originally written by
 * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.
 *
 */
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
/* ====================================================================
 * Copyright 2005 Nokia. All rights reserved.
 *
 * The portions of the attached software ("Contribution") is developed by
 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
 * license.
 *
 * The Contribution, originally written by Mika Kousa and Pasi Eronen of
 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
 * support (see RFC 4279) to OpenSSL.
 *
 * No patent licenses or other rights except those expressly stated in
 * the OpenSSL open source license shall be deemed granted or received
 * expressly, by implication, estoppel, or otherwise.
 *
 * No assurances are provided by Nokia that the Contribution does not
 * infringe the patent or other intellectual property rights of any third
 * party or that the license provides you with all the necessary rights
 * to make use of the Contribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
 * OTHERWISE.
 */
49 50

#include <stdio.h>
51
#include <openssl/objects.h>
52
#include "ssl_locl.h"
53
#include <openssl/md5.h>
R
Rich Salz 已提交
54
#include <openssl/dh.h>
55
#include <openssl/rand.h>
56

D
Dr. Stephen Henson 已提交
57
#define SSL3_NUM_CIPHERS        OSSL_NELEM(ssl3_ciphers)
58
#define SSL3_NUM_SCSVS          OSSL_NELEM(ssl3_scsvs)
59

60 61 62 63 64 65 66 67
/* TLSv1.3 downgrade protection sentinel values */
const unsigned char tls11downgrade[] = {
    0x44, 0x4f, 0x57, 0x4e, 0x47, 0x52, 0x44, 0x00
};
const unsigned char tls12downgrade[] = {
    0x44, 0x4f, 0x57, 0x4e, 0x47, 0x52, 0x44, 0x01
};

R
Rich Salz 已提交
68
/*
R
Rich Salz 已提交
69
 * The list of available ciphers, mostly organized into the following
R
Rich Salz 已提交
70 71 72 73 74
 * groups:
 *      Always there
 *      EC
 *      PSK
 *      SRP (within that: RSA EC PSK)
P
Pauli 已提交
75
 *      Cipher families: Chacha/poly, Camellia, Gost, IDEA, SEED
R
Rich Salz 已提交
76 77
 *      Weak ciphers
 */
E
Emilia Kasper 已提交
78
static SSL_CIPHER ssl3_ciphers[] = {
79 80 81 82 83 84 85 86
    {
     1,
     SSL3_TXT_RSA_NULL_MD5,
     SSL3_CK_RSA_NULL_MD5,
     SSL_kRSA,
     SSL_aRSA,
     SSL_eNULL,
     SSL_MD5,
87
     SSL3_VERSION, TLS1_2_VERSION,
88
     DTLS1_BAD_VER, DTLS1_2_VERSION,
89
     SSL_STRONG_NONE,
90 91 92 93 94 95 96 97 98 99 100 101
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
    {
     1,
     SSL3_TXT_RSA_NULL_SHA,
     SSL3_CK_RSA_NULL_SHA,
     SSL_kRSA,
     SSL_aRSA,
     SSL_eNULL,
     SSL_SHA1,
102
     SSL3_VERSION, TLS1_2_VERSION,
103
     DTLS1_BAD_VER, DTLS1_2_VERSION,
104
     SSL_STRONG_NONE | SSL_FIPS,
105 106 107 108
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
109
#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
110 111 112 113 114 115 116 117
    {
     1,
     SSL3_TXT_RSA_DES_192_CBC3_SHA,
     SSL3_CK_RSA_DES_192_CBC3_SHA,
     SSL_kRSA,
     SSL_aRSA,
     SSL_3DES,
     SSL_SHA1,
118
     SSL3_VERSION, TLS1_2_VERSION,
119
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
120
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
121 122 123 124 125 126 127 128 129 130 131 132
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
    {
     1,
     SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA,
     SSL3_CK_DHE_DSS_DES_192_CBC3_SHA,
     SSL_kDHE,
     SSL_aDSS,
     SSL_3DES,
     SSL_SHA1,
133
     SSL3_VERSION, TLS1_2_VERSION,
134
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
135
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
136 137 138 139 140 141 142 143 144 145 146 147
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
    {
     1,
     SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA,
     SSL3_CK_DHE_RSA_DES_192_CBC3_SHA,
     SSL_kDHE,
     SSL_aRSA,
     SSL_3DES,
     SSL_SHA1,
148
     SSL3_VERSION, TLS1_2_VERSION,
149
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
150
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
151 152 153 154 155 156 157 158 159 160 161 162
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
    {
     1,
     SSL3_TXT_ADH_DES_192_CBC_SHA,
     SSL3_CK_ADH_DES_192_CBC_SHA,
     SSL_kDHE,
     SSL_aNULL,
     SSL_3DES,
     SSL_SHA1,
163
     SSL3_VERSION, TLS1_2_VERSION,
164
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
165
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
166 167 168 169
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
170
#endif
171 172 173 174 175 176 177 178
    {
     1,
     TLS1_TXT_RSA_WITH_AES_128_SHA,
     TLS1_CK_RSA_WITH_AES_128_SHA,
     SSL_kRSA,
     SSL_aRSA,
     SSL_AES128,
     SSL_SHA1,
179
     SSL3_VERSION, TLS1_2_VERSION,
180
     DTLS1_BAD_VER, DTLS1_2_VERSION,
181
     SSL_HIGH | SSL_FIPS,
182 183 184 185 186 187 188 189 190 191 192 193
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_DHE_DSS_WITH_AES_128_SHA,
     TLS1_CK_DHE_DSS_WITH_AES_128_SHA,
     SSL_kDHE,
     SSL_aDSS,
     SSL_AES128,
     SSL_SHA1,
194
     SSL3_VERSION, TLS1_2_VERSION,
195
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
196
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
197 198 199 200 201 202 203 204 205 206 207 208
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_DHE_RSA_WITH_AES_128_SHA,
     TLS1_CK_DHE_RSA_WITH_AES_128_SHA,
     SSL_kDHE,
     SSL_aRSA,
     SSL_AES128,
     SSL_SHA1,
209
     SSL3_VERSION, TLS1_2_VERSION,
210
     DTLS1_BAD_VER, DTLS1_2_VERSION,
211
     SSL_HIGH | SSL_FIPS,
212 213 214 215 216 217 218 219 220 221 222 223
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_ADH_WITH_AES_128_SHA,
     TLS1_CK_ADH_WITH_AES_128_SHA,
     SSL_kDHE,
     SSL_aNULL,
     SSL_AES128,
     SSL_SHA1,
224
     SSL3_VERSION, TLS1_2_VERSION,
225
     DTLS1_BAD_VER, DTLS1_2_VERSION,
226
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
227 228 229 230 231 232 233 234 235 236 237 238
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_RSA_WITH_AES_256_SHA,
     TLS1_CK_RSA_WITH_AES_256_SHA,
     SSL_kRSA,
     SSL_aRSA,
     SSL_AES256,
     SSL_SHA1,
239
     SSL3_VERSION, TLS1_2_VERSION,
240
     DTLS1_BAD_VER, DTLS1_2_VERSION,
241
     SSL_HIGH | SSL_FIPS,
242 243 244 245 246 247 248 249 250 251 252 253
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_DHE_DSS_WITH_AES_256_SHA,
     TLS1_CK_DHE_DSS_WITH_AES_256_SHA,
     SSL_kDHE,
     SSL_aDSS,
     SSL_AES256,
     SSL_SHA1,
254
     SSL3_VERSION, TLS1_2_VERSION,
255
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
256
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
257 258 259 260 261 262 263 264 265 266 267 268
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_DHE_RSA_WITH_AES_256_SHA,
     TLS1_CK_DHE_RSA_WITH_AES_256_SHA,
     SSL_kDHE,
     SSL_aRSA,
     SSL_AES256,
     SSL_SHA1,
269
     SSL3_VERSION, TLS1_2_VERSION,
270
     DTLS1_BAD_VER, DTLS1_2_VERSION,
271
     SSL_HIGH | SSL_FIPS,
272 273 274 275 276 277 278 279 280 281 282 283
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_ADH_WITH_AES_256_SHA,
     TLS1_CK_ADH_WITH_AES_256_SHA,
     SSL_kDHE,
     SSL_aNULL,
     SSL_AES256,
     SSL_SHA1,
284
     SSL3_VERSION, TLS1_2_VERSION,
285
     DTLS1_BAD_VER, DTLS1_2_VERSION,
286
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
287 288 289 290 291 292 293 294 295 296 297 298
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_RSA_WITH_NULL_SHA256,
     TLS1_CK_RSA_WITH_NULL_SHA256,
     SSL_kRSA,
     SSL_aRSA,
     SSL_eNULL,
     SSL_SHA256,
299 300
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
301
     SSL_STRONG_NONE | SSL_FIPS,
302 303 304 305 306 307 308 309 310 311 312 313
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
    {
     1,
     TLS1_TXT_RSA_WITH_AES_128_SHA256,
     TLS1_CK_RSA_WITH_AES_128_SHA256,
     SSL_kRSA,
     SSL_aRSA,
     SSL_AES128,
     SSL_SHA256,
314 315
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
316
     SSL_HIGH | SSL_FIPS,
317 318 319 320 321 322 323 324 325 326 327 328
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_RSA_WITH_AES_256_SHA256,
     TLS1_CK_RSA_WITH_AES_256_SHA256,
     SSL_kRSA,
     SSL_aRSA,
     SSL_AES256,
     SSL_SHA256,
329 330
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
331
     SSL_HIGH | SSL_FIPS,
332 333 334 335 336 337 338 339 340 341 342 343
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256,
     TLS1_CK_DHE_DSS_WITH_AES_128_SHA256,
     SSL_kDHE,
     SSL_aDSS,
     SSL_AES128,
     SSL_SHA256,
344 345
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
346
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
347 348 349 350 351 352 353 354 355 356 357 358
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256,
     TLS1_CK_DHE_RSA_WITH_AES_128_SHA256,
     SSL_kDHE,
     SSL_aRSA,
     SSL_AES128,
     SSL_SHA256,
359 360
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
361
     SSL_HIGH | SSL_FIPS,
362 363 364 365 366 367 368 369 370 371 372 373
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256,
     TLS1_CK_DHE_DSS_WITH_AES_256_SHA256,
     SSL_kDHE,
     SSL_aDSS,
     SSL_AES256,
     SSL_SHA256,
374 375
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
376
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
377 378 379 380 381 382 383 384 385 386 387 388
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256,
     TLS1_CK_DHE_RSA_WITH_AES_256_SHA256,
     SSL_kDHE,
     SSL_aRSA,
     SSL_AES256,
     SSL_SHA256,
389 390
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
391
     SSL_HIGH | SSL_FIPS,
392 393 394 395 396 397 398 399 400 401 402 403
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_ADH_WITH_AES_128_SHA256,
     TLS1_CK_ADH_WITH_AES_128_SHA256,
     SSL_kDHE,
     SSL_aNULL,
     SSL_AES128,
     SSL_SHA256,
404 405
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
406
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
407 408 409 410 411 412 413 414 415 416 417 418
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_ADH_WITH_AES_256_SHA256,
     TLS1_CK_ADH_WITH_AES_256_SHA256,
     SSL_kDHE,
     SSL_aNULL,
     SSL_AES256,
     SSL_SHA256,
419 420
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
421
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
422 423 424 425 426 427
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
428 429 430 431 432 433 434 435 436 437 438 439 440
     TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256,
     TLS1_CK_RSA_WITH_AES_128_GCM_SHA256,
     SSL_kRSA,
     SSL_aRSA,
     SSL_AES128GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
441 442
    {
     1,
R
Rich Salz 已提交
443 444
     TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384,
     TLS1_CK_RSA_WITH_AES_256_GCM_SHA384,
445 446
     SSL_kRSA,
     SSL_aRSA,
R
Rich Salz 已提交
447 448 449 450 451 452
     SSL_AES256GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
453 454 455 456 457
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
458 459
     TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256,
     TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256,
460
     SSL_kDHE,
R
Rich Salz 已提交
461 462 463 464 465 466 467 468 469
     SSL_aRSA,
     SSL_AES128GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
470 471 472
     },
    {
     1,
R
Rich Salz 已提交
473 474
     TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384,
     TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384,
475 476
     SSL_kDHE,
     SSL_aRSA,
R
Rich Salz 已提交
477 478 479 480 481 482
     SSL_AES256GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
483 484 485 486 487
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
488 489
     TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256,
     TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256,
490
     SSL_kDHE,
R
Rich Salz 已提交
491 492 493 494 495 496 497
     SSL_aDSS,
     SSL_AES128GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
498 499 500 501 502
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
503 504 505 506 507 508 509 510 511 512 513 514
     TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384,
     TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384,
     SSL_kDHE,
     SSL_aDSS,
     SSL_AES256GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
     256,
515 516 517
     },
    {
     1,
R
Rich Salz 已提交
518 519 520 521 522 523 524 525 526 527
     TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256,
     TLS1_CK_ADH_WITH_AES_128_GCM_SHA256,
     SSL_kDHE,
     SSL_aNULL,
     SSL_AES128GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
528 529 530 531 532
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
533 534 535 536 537 538 539 540 541 542
     TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384,
     TLS1_CK_ADH_WITH_AES_256_GCM_SHA384,
     SSL_kDHE,
     SSL_aNULL,
     SSL_AES256GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
543 544 545
     256,
     256,
     },
546 547
    {
     1,
R
Rich Salz 已提交
548 549 550 551 552 553 554 555 556 557
     TLS1_TXT_RSA_WITH_AES_128_CCM,
     TLS1_CK_RSA_WITH_AES_128_CCM,
     SSL_kRSA,
     SSL_aRSA,
     SSL_AES128CCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
558 559 560 561 562
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
563 564 565 566 567 568 569 570 571 572 573 574
     TLS1_TXT_RSA_WITH_AES_256_CCM,
     TLS1_CK_RSA_WITH_AES_256_CCM,
     SSL_kRSA,
     SSL_aRSA,
     SSL_AES256CCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
575 576 577
     },
    {
     1,
R
Rich Salz 已提交
578 579 580 581 582 583 584 585 586 587
     TLS1_TXT_DHE_RSA_WITH_AES_128_CCM,
     TLS1_CK_DHE_RSA_WITH_AES_128_CCM,
     SSL_kDHE,
     SSL_aRSA,
     SSL_AES128CCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
588 589 590 591 592
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
593 594 595 596 597 598 599 600 601 602
     TLS1_TXT_DHE_RSA_WITH_AES_256_CCM,
     TLS1_CK_DHE_RSA_WITH_AES_256_CCM,
     SSL_kDHE,
     SSL_aRSA,
     SSL_AES256CCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
603 604 605 606 607
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
608 609 610
     TLS1_TXT_RSA_WITH_AES_128_CCM_8,
     TLS1_CK_RSA_WITH_AES_128_CCM_8,
     SSL_kRSA,
611
     SSL_aRSA,
R
Rich Salz 已提交
612
     SSL_AES128CCM8,
613
     SSL_AEAD,
614 615
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
616
     SSL_NOT_DEFAULT | SSL_HIGH,
617 618 619 620 621 622
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
623 624
     TLS1_TXT_RSA_WITH_AES_256_CCM_8,
     TLS1_CK_RSA_WITH_AES_256_CCM_8,
625 626
     SSL_kRSA,
     SSL_aRSA,
R
Rich Salz 已提交
627
     SSL_AES256CCM8,
628
     SSL_AEAD,
629 630
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
631 632
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
633 634 635 636 637
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
638 639
     TLS1_TXT_DHE_RSA_WITH_AES_128_CCM_8,
     TLS1_CK_DHE_RSA_WITH_AES_128_CCM_8,
640 641
     SSL_kDHE,
     SSL_aRSA,
R
Rich Salz 已提交
642
     SSL_AES128CCM8,
643
     SSL_AEAD,
644 645
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
646
     SSL_NOT_DEFAULT | SSL_HIGH,
647 648 649 650 651 652
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
653 654
     TLS1_TXT_DHE_RSA_WITH_AES_256_CCM_8,
     TLS1_CK_DHE_RSA_WITH_AES_256_CCM_8,
655 656
     SSL_kDHE,
     SSL_aRSA,
R
Rich Salz 已提交
657
     SSL_AES256CCM8,
658
     SSL_AEAD,
659 660
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
661 662
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
663 664 665 666 667
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
668 669 670 671 672
     TLS1_TXT_PSK_WITH_AES_128_CCM,
     TLS1_CK_PSK_WITH_AES_128_CCM,
     SSL_kPSK,
     SSL_aPSK,
     SSL_AES128CCM,
673
     SSL_AEAD,
674 675
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
676
     SSL_NOT_DEFAULT | SSL_HIGH,
677 678 679 680 681 682
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
683 684 685 686 687
     TLS1_TXT_PSK_WITH_AES_256_CCM,
     TLS1_CK_PSK_WITH_AES_256_CCM,
     SSL_kPSK,
     SSL_aPSK,
     SSL_AES256CCM,
688
     SSL_AEAD,
689 690
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
691 692
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
693 694 695 696 697
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
698 699 700 701 702
     TLS1_TXT_DHE_PSK_WITH_AES_128_CCM,
     TLS1_CK_DHE_PSK_WITH_AES_128_CCM,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_AES128CCM,
703
     SSL_AEAD,
704 705
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
706
     SSL_NOT_DEFAULT | SSL_HIGH,
707 708 709 710 711 712
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
713 714 715 716 717
     TLS1_TXT_DHE_PSK_WITH_AES_256_CCM,
     TLS1_CK_DHE_PSK_WITH_AES_256_CCM,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_AES256CCM,
718
     SSL_AEAD,
719 720
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
721 722
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
723 724 725
     256,
     256,
     },
726 727
    {
     1,
R
Rich Salz 已提交
728 729
     TLS1_TXT_PSK_WITH_AES_128_CCM_8,
     TLS1_CK_PSK_WITH_AES_128_CCM_8,
730 731
     SSL_kPSK,
     SSL_aPSK,
R
Rich Salz 已提交
732
     SSL_AES128CCM8,
733
     SSL_AEAD,
734 735
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
736
     SSL_NOT_DEFAULT | SSL_HIGH,
737 738 739 740 741 742
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
743 744
     TLS1_TXT_PSK_WITH_AES_256_CCM_8,
     TLS1_CK_PSK_WITH_AES_256_CCM_8,
745 746
     SSL_kPSK,
     SSL_aPSK,
R
Rich Salz 已提交
747
     SSL_AES256CCM8,
748
     SSL_AEAD,
749 750
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
751 752
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
753 754 755
     256,
     256,
     },
756 757
    {
     1,
R
Rich Salz 已提交
758 759
     TLS1_TXT_DHE_PSK_WITH_AES_128_CCM_8,
     TLS1_CK_DHE_PSK_WITH_AES_128_CCM_8,
760 761
     SSL_kDHEPSK,
     SSL_aPSK,
R
Rich Salz 已提交
762
     SSL_AES128CCM8,
763
     SSL_AEAD,
764 765
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
766
     SSL_NOT_DEFAULT | SSL_HIGH,
767 768 769 770 771 772
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
773 774 775
     TLS1_TXT_DHE_PSK_WITH_AES_256_CCM_8,
     TLS1_CK_DHE_PSK_WITH_AES_256_CCM_8,
     SSL_kDHEPSK,
776
     SSL_aPSK,
R
Rich Salz 已提交
777
     SSL_AES256CCM8,
778
     SSL_AEAD,
779 780
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
781 782
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
783 784 785 786 787
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
788 789 790 791 792
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_AES128CCM,
793
     SSL_AEAD,
794 795
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
796
     SSL_NOT_DEFAULT | SSL_HIGH,
797 798 799 800 801 802
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
803 804 805 806 807
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_AES256CCM,
808
     SSL_AEAD,
809 810
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
811 812
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
813 814 815 816 817
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
818 819 820 821 822 823 824 825 826 827
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM_8,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM_8,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_AES128CCM8,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
828 829 830 831 832
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
833 834 835 836 837 838 839 840 841 842
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM_8,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM_8,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_AES256CCM8,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
843 844 845
     256,
     256,
     },
846 847 848 849
    {
     1,
     TLS1_3_TXT_AES_128_GCM_SHA256,
     TLS1_3_CK_AES_128_GCM_SHA256,
D
Dr. Stephen Henson 已提交
850
     0, 0,
851 852 853
     SSL_AES128GCM,
     SSL_AEAD,
     TLS1_3_VERSION, TLS1_3_VERSION,
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869
     SSL_kANY,
     SSL_aANY,
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256,
     128,
     128,
     },
    {
     1,
     TLS1_3_TXT_AES_256_GCM_SHA384,
     TLS1_3_CK_AES_256_GCM_SHA384,
     SSL_kANY,
     SSL_aANY,
     SSL_AES256GCM,
     SSL_AEAD,
     TLS1_3_VERSION, TLS1_3_VERSION,
870 871
     0, 0,
     SSL_HIGH,
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919
     SSL_HANDSHAKE_MAC_SHA384,
     256,
     256,
     },
#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
    {
     1,
     TLS1_3_TXT_CHACHA20_POLY1305_SHA256,
     TLS1_3_CK_CHACHA20_POLY1305_SHA256,
     SSL_kANY,
     SSL_aANY,
     SSL_CHACHA20POLY1305,
     SSL_AEAD,
     TLS1_3_VERSION, TLS1_3_VERSION,
     0, 0,
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256,
     256,
     256,
     },
#endif
    {
     1,
     TLS1_3_TXT_AES_128_CCM_SHA256,
     TLS1_3_CK_AES_128_CCM_SHA256,
     SSL_kANY,
     SSL_aANY,
     SSL_AES128CCM,
     SSL_AEAD,
     TLS1_3_VERSION, TLS1_3_VERSION,
     0, 0,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256,
     128,
     128,
     },
    {
     1,
     TLS1_3_TXT_AES_128_CCM_8_SHA256,
     TLS1_3_CK_AES_128_CCM_8_SHA256,
     SSL_kANY,
     SSL_aANY,
     SSL_AES128CCM8,
     SSL_AEAD,
     TLS1_3_VERSION, TLS1_3_VERSION,
     0, 0,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256,
920 921 922
     128,
     128,
     },
923

R
Rich Salz 已提交
924
#ifndef OPENSSL_NO_EC
925 926
    {
     1,
R
Rich Salz 已提交
927 928 929 930
     TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA,
     TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA,
     SSL_kECDHE,
     SSL_aECDSA,
931
     SSL_eNULL,
R
Rich Salz 已提交
932
     SSL_SHA1,
T
Todd Short 已提交
933
     TLS1_VERSION, TLS1_2_VERSION,
934
     DTLS1_BAD_VER, DTLS1_2_VERSION,
935
     SSL_STRONG_NONE | SSL_FIPS,
936 937 938 939
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
940
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
941 942
    {
     1,
R
Rich Salz 已提交
943 944 945 946 947 948
     TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
     TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_3DES,
     SSL_SHA1,
T
Todd Short 已提交
949
     TLS1_VERSION, TLS1_2_VERSION,
950
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
951
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
R
Rich Salz 已提交
952 953 954
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
955
     },
956
# endif
957 958
    {
     1,
R
Rich Salz 已提交
959 960 961 962
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
     SSL_kECDHE,
     SSL_aECDSA,
963
     SSL_AES128,
R
Rich Salz 已提交
964
     SSL_SHA1,
T
Todd Short 已提交
965
     TLS1_VERSION, TLS1_2_VERSION,
966
     DTLS1_BAD_VER, DTLS1_2_VERSION,
967
     SSL_HIGH | SSL_FIPS,
968 969 970 971 972 973
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
974 975 976 977
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
     SSL_kECDHE,
     SSL_aECDSA,
978
     SSL_AES256,
R
Rich Salz 已提交
979
     SSL_SHA1,
T
Todd Short 已提交
980
     TLS1_VERSION, TLS1_2_VERSION,
981
     DTLS1_BAD_VER, DTLS1_2_VERSION,
982
     SSL_HIGH | SSL_FIPS,
R
Rich Salz 已提交
983
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
984 985 986 987 988
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
989 990 991 992
     TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA,
     TLS1_CK_ECDHE_RSA_WITH_NULL_SHA,
     SSL_kECDHE,
     SSL_aRSA,
993
     SSL_eNULL,
R
Rich Salz 已提交
994
     SSL_SHA1,
T
Todd Short 已提交
995
     TLS1_VERSION, TLS1_2_VERSION,
996
     DTLS1_BAD_VER, DTLS1_2_VERSION,
997
     SSL_STRONG_NONE | SSL_FIPS,
998 999 1000 1001
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
1002
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
1003 1004
    {
     1,
R
Rich Salz 已提交
1005 1006 1007 1008 1009 1010
     TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
     TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
     SSL_kECDHE,
     SSL_aRSA,
     SSL_3DES,
     SSL_SHA1,
T
Todd Short 已提交
1011
     TLS1_VERSION, TLS1_2_VERSION,
1012
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1013
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
R
Rich Salz 已提交
1014 1015 1016
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
1017
     },
1018
# endif
1019 1020
    {
     1,
R
Rich Salz 已提交
1021 1022 1023
     TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA,
     TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA,
     SSL_kECDHE,
1024 1025
     SSL_aRSA,
     SSL_AES128,
R
Rich Salz 已提交
1026
     SSL_SHA1,
T
Todd Short 已提交
1027
     TLS1_VERSION, TLS1_2_VERSION,
1028
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1029
     SSL_HIGH | SSL_FIPS,
1030 1031 1032 1033 1034 1035
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1036 1037 1038
     TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA,
     TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA,
     SSL_kECDHE,
1039 1040
     SSL_aRSA,
     SSL_AES256,
R
Rich Salz 已提交
1041
     SSL_SHA1,
T
Todd Short 已提交
1042
     TLS1_VERSION, TLS1_2_VERSION,
1043
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1044
     SSL_HIGH | SSL_FIPS,
R
Rich Salz 已提交
1045
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1046 1047 1048 1049 1050
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1051 1052 1053 1054
     TLS1_TXT_ECDH_anon_WITH_NULL_SHA,
     TLS1_CK_ECDH_anon_WITH_NULL_SHA,
     SSL_kECDHE,
     SSL_aNULL,
1055
     SSL_eNULL,
R
Rich Salz 已提交
1056
     SSL_SHA1,
T
Todd Short 已提交
1057
     TLS1_VERSION, TLS1_2_VERSION,
1058
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1059
     SSL_STRONG_NONE | SSL_FIPS,
1060 1061 1062 1063
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
1064
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
1065 1066
    {
     1,
R
Rich Salz 已提交
1067 1068 1069 1070 1071 1072
     TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA,
     TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA,
     SSL_kECDHE,
     SSL_aNULL,
     SSL_3DES,
     SSL_SHA1,
T
Todd Short 已提交
1073
     TLS1_VERSION, TLS1_2_VERSION,
1074
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1075
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
R
Rich Salz 已提交
1076 1077 1078
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
1079
     },
1080
# endif
1081 1082
    {
     1,
R
Rich Salz 已提交
1083 1084 1085 1086 1087 1088
     TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA,
     TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA,
     SSL_kECDHE,
     SSL_aNULL,
     SSL_AES128,
     SSL_SHA1,
T
Todd Short 已提交
1089
     TLS1_VERSION, TLS1_2_VERSION,
1090
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1091 1092 1093 1094 1095
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
1096 1097
    {
     1,
R
Rich Salz 已提交
1098 1099 1100 1101 1102 1103
     TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA,
     TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA,
     SSL_kECDHE,
     SSL_aNULL,
     SSL_AES256,
     SSL_SHA1,
T
Todd Short 已提交
1104
     TLS1_VERSION, TLS1_2_VERSION,
1105
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_AES128,
1118
     SSL_SHA256,
1119 1120
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1121
     SSL_HIGH | SSL_FIPS,
1122 1123 1124 1125 1126 1127
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1128 1129 1130 1131 1132 1133
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_AES256,
     SSL_SHA384,
1134 1135
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1136 1137 1138 1139
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
     256,
1140 1141 1142
     },
    {
     1,
R
Rich Salz 已提交
1143 1144 1145 1146 1147
     TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256,
     TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256,
     SSL_kECDHE,
     SSL_aRSA,
     SSL_AES128,
1148
     SSL_SHA256,
1149 1150
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1151
     SSL_HIGH | SSL_FIPS,
1152 1153 1154 1155 1156 1157
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1158 1159 1160
     TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384,
     TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384,
     SSL_kECDHE,
1161
     SSL_aRSA,
R
Rich Salz 已提交
1162 1163
     SSL_AES256,
     SSL_SHA384,
1164 1165
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1166 1167
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1168 1169 1170 1171 1172
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1173 1174 1175 1176 1177 1178
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_AES128GCM,
     SSL_AEAD,
1179 1180
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1181
     SSL_HIGH | SSL_FIPS,
1182
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
R
Rich Salz 已提交
1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197
     128,
     128,
     },
    {
     1,
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_AES256GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1198 1199 1200 1201 1202
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1203 1204 1205
     TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
     TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
     SSL_kECDHE,
1206
     SSL_aRSA,
R
Rich Salz 已提交
1207 1208
     SSL_AES128GCM,
     SSL_AEAD,
1209 1210
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1211
     SSL_HIGH | SSL_FIPS,
1212
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
R
Rich Salz 已提交
1213 1214
     128,
     128,
1215 1216 1217
     },
    {
     1,
R
Rich Salz 已提交
1218 1219 1220 1221 1222 1223
     TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
     TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
     SSL_kECDHE,
     SSL_aRSA,
     SSL_AES256GCM,
     SSL_AEAD,
1224 1225
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1226 1227
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1228 1229 1230
     256,
     256,
     },
E
Emilia Kasper 已提交
1231
#endif                          /* OPENSSL_NO_EC */
1232

R
Rich Salz 已提交
1233
#ifndef OPENSSL_NO_PSK
1234 1235
    {
     1,
R
Rich Salz 已提交
1236 1237 1238 1239
     TLS1_TXT_PSK_WITH_NULL_SHA,
     TLS1_CK_PSK_WITH_NULL_SHA,
     SSL_kPSK,
     SSL_aPSK,
1240 1241
     SSL_eNULL,
     SSL_SHA1,
1242
     SSL3_VERSION, TLS1_2_VERSION,
1243
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1244
     SSL_STRONG_NONE | SSL_FIPS,
1245 1246 1247 1248 1249 1250
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
    {
     1,
R
Rich Salz 已提交
1251 1252 1253 1254 1255
     TLS1_TXT_DHE_PSK_WITH_NULL_SHA,
     TLS1_CK_DHE_PSK_WITH_NULL_SHA,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_eNULL,
1256
     SSL_SHA1,
1257
     SSL3_VERSION, TLS1_2_VERSION,
1258
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1259
     SSL_STRONG_NONE | SSL_FIPS,
1260
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
R
Rich Salz 已提交
1261 1262
     0,
     0,
1263 1264 1265
     },
    {
     1,
R
Rich Salz 已提交
1266 1267 1268 1269 1270 1271 1272
     TLS1_TXT_RSA_PSK_WITH_NULL_SHA,
     TLS1_CK_RSA_PSK_WITH_NULL_SHA,
     SSL_kRSAPSK,
     SSL_aRSA,
     SSL_eNULL,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1273
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1274 1275 1276 1277 1278
     SSL_STRONG_NONE | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
1279
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
R
Rich Salz 已提交
1280 1281 1282 1283 1284 1285
    {
     1,
     TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA,
     TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA,
     SSL_kPSK,
     SSL_aPSK,
1286 1287
     SSL_3DES,
     SSL_SHA1,
1288
     SSL3_VERSION, TLS1_2_VERSION,
1289
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1290
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
1291 1292 1293 1294
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
1295
# endif
1296 1297
    {
     1,
R
Rich Salz 已提交
1298 1299 1300 1301
     TLS1_TXT_PSK_WITH_AES_128_CBC_SHA,
     TLS1_CK_PSK_WITH_AES_128_CBC_SHA,
     SSL_kPSK,
     SSL_aPSK,
1302 1303
     SSL_AES128,
     SSL_SHA1,
1304
     SSL3_VERSION, TLS1_2_VERSION,
1305
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1306
     SSL_HIGH | SSL_FIPS,
1307 1308 1309 1310 1311 1312
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1313 1314 1315 1316
     TLS1_TXT_PSK_WITH_AES_256_CBC_SHA,
     TLS1_CK_PSK_WITH_AES_256_CBC_SHA,
     SSL_kPSK,
     SSL_aPSK,
1317 1318
     SSL_AES256,
     SSL_SHA1,
1319
     SSL3_VERSION, TLS1_2_VERSION,
1320
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1321
     SSL_HIGH | SSL_FIPS,
1322 1323 1324 1325
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
1326
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
1327 1328
    {
     1,
R
Rich Salz 已提交
1329 1330 1331 1332 1333
     TLS1_TXT_DHE_PSK_WITH_3DES_EDE_CBC_SHA,
     TLS1_CK_DHE_PSK_WITH_3DES_EDE_CBC_SHA,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_3DES,
1334
     SSL_SHA1,
1335
     SSL3_VERSION, TLS1_2_VERSION,
1336
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1337
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
1338
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
R
Rich Salz 已提交
1339 1340
     112,
     168,
1341
     },
1342
# endif
1343 1344
    {
     1,
R
Rich Salz 已提交
1345 1346 1347 1348 1349 1350 1351
     TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA,
     TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_AES128,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1352
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1353
     SSL_HIGH | SSL_FIPS,
1354 1355 1356 1357 1358 1359
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1360 1361 1362 1363 1364 1365 1366
     TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA,
     TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_AES256,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1367
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1368 1369 1370 1371 1372
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
1373
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
R
Rich Salz 已提交
1374 1375 1376 1377 1378
    {
     1,
     TLS1_TXT_RSA_PSK_WITH_3DES_EDE_CBC_SHA,
     TLS1_CK_RSA_PSK_WITH_3DES_EDE_CBC_SHA,
     SSL_kRSAPSK,
1379 1380 1381
     SSL_aRSA,
     SSL_3DES,
     SSL_SHA1,
1382
     SSL3_VERSION, TLS1_2_VERSION,
1383
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1384
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
1385 1386 1387 1388
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
1389
# endif
1390 1391
    {
     1,
R
Rich Salz 已提交
1392 1393 1394
     TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA,
     TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA,
     SSL_kRSAPSK,
1395 1396 1397
     SSL_aRSA,
     SSL_AES128,
     SSL_SHA1,
1398
     SSL3_VERSION, TLS1_2_VERSION,
1399
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1400
     SSL_HIGH | SSL_FIPS,
1401 1402 1403 1404 1405 1406
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1407 1408 1409
     TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA,
     TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA,
     SSL_kRSAPSK,
1410 1411 1412
     SSL_aRSA,
     SSL_AES256,
     SSL_SHA1,
1413
     SSL3_VERSION, TLS1_2_VERSION,
1414
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1415
     SSL_HIGH | SSL_FIPS,
1416 1417 1418 1419 1420 1421
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1422 1423 1424 1425 1426 1427 1428 1429 1430 1431
     TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256,
     TLS1_CK_PSK_WITH_AES_128_GCM_SHA256,
     SSL_kPSK,
     SSL_aPSK,
     SSL_AES128GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1432 1433 1434 1435 1436
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448
     TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384,
     TLS1_CK_PSK_WITH_AES_256_GCM_SHA384,
     SSL_kPSK,
     SSL_aPSK,
     SSL_AES256GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
     256,
1449 1450 1451
     },
    {
     1,
R
Rich Salz 已提交
1452 1453 1454 1455 1456 1457 1458 1459 1460 1461
     TLS1_TXT_DHE_PSK_WITH_AES_128_GCM_SHA256,
     TLS1_CK_DHE_PSK_WITH_AES_128_GCM_SHA256,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_AES128GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1462 1463 1464 1465 1466
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1467 1468 1469 1470 1471 1472 1473 1474 1475 1476
     TLS1_TXT_DHE_PSK_WITH_AES_256_GCM_SHA384,
     TLS1_CK_DHE_PSK_WITH_AES_256_GCM_SHA384,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_AES256GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1477 1478 1479 1480 1481
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1482 1483 1484
     TLS1_TXT_RSA_PSK_WITH_AES_128_GCM_SHA256,
     TLS1_CK_RSA_PSK_WITH_AES_128_GCM_SHA256,
     SSL_kRSAPSK,
1485
     SSL_aRSA,
R
Rich Salz 已提交
1486 1487 1488 1489 1490 1491 1492 1493
     SSL_AES128GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
1494 1495 1496
     },
    {
     1,
R
Rich Salz 已提交
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508
     TLS1_TXT_RSA_PSK_WITH_AES_256_GCM_SHA384,
     TLS1_CK_RSA_PSK_WITH_AES_256_GCM_SHA384,
     SSL_kRSAPSK,
     SSL_aRSA,
     SSL_AES256GCM,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
     256,
1509 1510 1511
     },
    {
     1,
R
Rich Salz 已提交
1512 1513 1514 1515
     TLS1_TXT_PSK_WITH_AES_128_CBC_SHA256,
     TLS1_CK_PSK_WITH_AES_128_CBC_SHA256,
     SSL_kPSK,
     SSL_aPSK,
1516
     SSL_AES128,
R
Rich Salz 已提交
1517 1518
     SSL_SHA256,
     TLS1_VERSION, TLS1_2_VERSION,
1519
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1520
     SSL_HIGH | SSL_FIPS,
1521 1522 1523 1524 1525 1526
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1527 1528 1529 1530 1531 1532 1533
     TLS1_TXT_PSK_WITH_AES_256_CBC_SHA384,
     TLS1_CK_PSK_WITH_AES_256_CBC_SHA384,
     SSL_kPSK,
     SSL_aPSK,
     SSL_AES256,
     SSL_SHA384,
     TLS1_VERSION, TLS1_2_VERSION,
1534
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1535 1536 1537 1538
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
     256,
1539 1540 1541
     },
    {
     1,
R
Rich Salz 已提交
1542 1543 1544 1545 1546 1547 1548
     TLS1_TXT_PSK_WITH_NULL_SHA256,
     TLS1_CK_PSK_WITH_NULL_SHA256,
     SSL_kPSK,
     SSL_aPSK,
     SSL_eNULL,
     SSL_SHA256,
     TLS1_VERSION, TLS1_2_VERSION,
1549
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1550
     SSL_STRONG_NONE | SSL_FIPS,
1551
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
R
Rich Salz 已提交
1552 1553
     0,
     0,
1554 1555 1556
     },
    {
     1,
R
Rich Salz 已提交
1557 1558 1559 1560 1561 1562 1563
     TLS1_TXT_PSK_WITH_NULL_SHA384,
     TLS1_CK_PSK_WITH_NULL_SHA384,
     SSL_kPSK,
     SSL_aPSK,
     SSL_eNULL,
     SSL_SHA384,
     TLS1_VERSION, TLS1_2_VERSION,
1564
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1565 1566 1567 1568
     SSL_STRONG_NONE | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     0,
     0,
1569 1570 1571
     },
    {
     1,
R
Rich Salz 已提交
1572 1573 1574 1575 1576 1577 1578
     TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA256,
     TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA256,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_AES128,
     SSL_SHA256,
     TLS1_VERSION, TLS1_2_VERSION,
1579
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1580
     SSL_HIGH | SSL_FIPS,
1581
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
R
Rich Salz 已提交
1582 1583
     128,
     128,
1584 1585 1586
     },
    {
     1,
R
Rich Salz 已提交
1587 1588 1589 1590
     TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA384,
     TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA384,
     SSL_kDHEPSK,
     SSL_aPSK,
1591
     SSL_AES256,
R
Rich Salz 已提交
1592 1593
     SSL_SHA384,
     TLS1_VERSION, TLS1_2_VERSION,
1594
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1595 1596
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1597 1598 1599 1600 1601
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1602 1603 1604 1605 1606
     TLS1_TXT_DHE_PSK_WITH_NULL_SHA256,
     TLS1_CK_DHE_PSK_WITH_NULL_SHA256,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_eNULL,
1607
     SSL_SHA256,
R
Rich Salz 已提交
1608
     TLS1_VERSION, TLS1_2_VERSION,
1609
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1610 1611 1612 1613
     SSL_STRONG_NONE | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
1614 1615 1616
     },
    {
     1,
R
Rich Salz 已提交
1617 1618 1619 1620 1621
     TLS1_TXT_DHE_PSK_WITH_NULL_SHA384,
     TLS1_CK_DHE_PSK_WITH_NULL_SHA384,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_eNULL,
1622
     SSL_SHA384,
R
Rich Salz 已提交
1623
     TLS1_VERSION, TLS1_2_VERSION,
1624
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1625
     SSL_STRONG_NONE | SSL_FIPS,
1626
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
R
Rich Salz 已提交
1627 1628
     0,
     0,
1629 1630 1631
     },
    {
     1,
R
Rich Salz 已提交
1632 1633 1634
     TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA256,
     TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA256,
     SSL_kRSAPSK,
1635 1636 1637
     SSL_aRSA,
     SSL_AES128,
     SSL_SHA256,
R
Rich Salz 已提交
1638
     TLS1_VERSION, TLS1_2_VERSION,
1639
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1640
     SSL_HIGH | SSL_FIPS,
R
Rich Salz 已提交
1641
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1642 1643 1644 1645 1646
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1647 1648 1649
     TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA384,
     TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA384,
     SSL_kRSAPSK,
1650 1651 1652
     SSL_aRSA,
     SSL_AES256,
     SSL_SHA384,
R
Rich Salz 已提交
1653
     TLS1_VERSION, TLS1_2_VERSION,
1654
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1655
     SSL_HIGH | SSL_FIPS,
1656 1657 1658 1659 1660 1661
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1662 1663 1664
     TLS1_TXT_RSA_PSK_WITH_NULL_SHA256,
     TLS1_CK_RSA_PSK_WITH_NULL_SHA256,
     SSL_kRSAPSK,
1665
     SSL_aRSA,
R
Rich Salz 已提交
1666 1667 1668
     SSL_eNULL,
     SSL_SHA256,
     TLS1_VERSION, TLS1_2_VERSION,
1669
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1670 1671 1672 1673
     SSL_STRONG_NONE | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
1674 1675 1676
     },
    {
     1,
R
Rich Salz 已提交
1677 1678 1679
     TLS1_TXT_RSA_PSK_WITH_NULL_SHA384,
     TLS1_CK_RSA_PSK_WITH_NULL_SHA384,
     SSL_kRSAPSK,
1680
     SSL_aRSA,
R
Rich Salz 已提交
1681 1682 1683
     SSL_eNULL,
     SSL_SHA384,
     TLS1_VERSION, TLS1_2_VERSION,
1684
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1685
     SSL_STRONG_NONE | SSL_FIPS,
1686
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
R
Rich Salz 已提交
1687 1688
     0,
     0,
1689
     },
R
Rich Salz 已提交
1690
# ifndef OPENSSL_NO_EC
1691
#  ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
1692 1693 1694 1695 1696 1697 1698 1699
    {
     1,
     TLS1_TXT_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA,
     TLS1_CK_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_3DES,
     SSL_SHA1,
T
Todd Short 已提交
1700
     TLS1_VERSION, TLS1_2_VERSION,
1701
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1702
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
1703 1704 1705 1706
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
1707
#  endif
1708 1709 1710 1711 1712 1713 1714 1715
    {
     1,
     TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA,
     TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_AES128,
     SSL_SHA1,
T
Todd Short 已提交
1716
     TLS1_VERSION, TLS1_2_VERSION,
1717
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1718
     SSL_HIGH | SSL_FIPS,
1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA,
     TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_AES256,
     SSL_SHA1,
T
Todd Short 已提交
1731
     TLS1_VERSION, TLS1_2_VERSION,
1732
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1733
     SSL_HIGH | SSL_FIPS,
1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA256,
     TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA256,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_AES128,
     SSL_SHA256,
1746
     TLS1_VERSION, TLS1_2_VERSION,
1747
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1748
     SSL_HIGH | SSL_FIPS,
1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA384,
     TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA384,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_AES256,
     SSL_SHA384,
1761
     TLS1_VERSION, TLS1_2_VERSION,
1762
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1763
     SSL_HIGH | SSL_FIPS,
1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA,
     TLS1_CK_ECDHE_PSK_WITH_NULL_SHA,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_eNULL,
     SSL_SHA1,
T
Todd Short 已提交
1776
     TLS1_VERSION, TLS1_2_VERSION,
1777
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1778
     SSL_STRONG_NONE | SSL_FIPS,
1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
    {
     1,
     TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA256,
     TLS1_CK_ECDHE_PSK_WITH_NULL_SHA256,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_eNULL,
     SSL_SHA256,
1791
     TLS1_VERSION, TLS1_2_VERSION,
1792
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1793
     SSL_STRONG_NONE | SSL_FIPS,
1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
    {
     1,
     TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA384,
     TLS1_CK_ECDHE_PSK_WITH_NULL_SHA384,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_eNULL,
     SSL_SHA384,
1806
     TLS1_VERSION, TLS1_2_VERSION,
1807
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1808
     SSL_STRONG_NONE | SSL_FIPS,
1809 1810 1811 1812
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     0,
     0,
     },
E
Emilia Kasper 已提交
1813 1814
# endif                         /* OPENSSL_NO_EC */
#endif                          /* OPENSSL_NO_PSK */
1815

R
Rich Salz 已提交
1816
#ifndef OPENSSL_NO_SRP
1817
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
R
Rich Salz 已提交
1818 1819 1820 1821 1822 1823 1824 1825 1826
    {
     1,
     TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA,
     TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA,
     SSL_kSRP,
     SSL_aSRP,
     SSL_3DES,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1827
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1828
     SSL_NOT_DEFAULT | SSL_MEDIUM,
R
Rich Salz 已提交
1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
    {
     1,
     TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA,
     TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA,
     SSL_kSRP,
     SSL_aRSA,
     SSL_3DES,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1842
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1843
     SSL_NOT_DEFAULT | SSL_MEDIUM,
R
Rich Salz 已提交
1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
    {
     1,
     TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA,
     TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA,
     SSL_kSRP,
     SSL_aDSS,
     SSL_3DES,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1857
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1858
     SSL_NOT_DEFAULT | SSL_MEDIUM,
R
Rich Salz 已提交
1859 1860 1861 1862
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
1863
# endif
R
Rich Salz 已提交
1864 1865 1866 1867 1868 1869 1870 1871 1872
    {
     1,
     TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA,
     TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA,
     SSL_kSRP,
     SSL_aSRP,
     SSL_AES128,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1873
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA,
     TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA,
     SSL_kSRP,
     SSL_aRSA,
     SSL_AES128,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1888
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA,
     TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA,
     SSL_kSRP,
     SSL_aDSS,
     SSL_AES128,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1903
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA,
     TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA,
     SSL_kSRP,
     SSL_aSRP,
     SSL_AES256,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1918
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA,
     TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA,
     SSL_kSRP,
     SSL_aRSA,
     SSL_AES256,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1933
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA,
     TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA,
     SSL_kSRP,
     SSL_aDSS,
     SSL_AES256,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
1948
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1949 1950 1951 1952 1953
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
E
Emilia Kasper 已提交
1954
#endif                          /* OPENSSL_NO_SRP */
R
Rich Salz 已提交
1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972

#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
# ifndef OPENSSL_NO_RSA
    {
     1,
     TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305,
     TLS1_CK_DHE_RSA_WITH_CHACHA20_POLY1305,
     SSL_kDHE,
     SSL_aRSA,
     SSL_CHACHA20POLY1305,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
E
Emilia Kasper 已提交
1973
# endif                         /* OPENSSL_NO_RSA */
R
Rich Salz 已提交
1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005

# ifndef OPENSSL_NO_EC
    {
     1,
     TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305,
     TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305,
     SSL_kECDHE,
     SSL_aRSA,
     SSL_CHACHA20POLY1305,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
     TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_CHACHA20POLY1305,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
E
Emilia Kasper 已提交
2006
# endif                         /* OPENSSL_NO_EC */
R
Rich Salz 已提交
2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068

# ifndef OPENSSL_NO_PSK
    {
     1,
     TLS1_TXT_PSK_WITH_CHACHA20_POLY1305,
     TLS1_CK_PSK_WITH_CHACHA20_POLY1305,
     SSL_kPSK,
     SSL_aPSK,
     SSL_CHACHA20POLY1305,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_ECDHE_PSK_WITH_CHACHA20_POLY1305,
     TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_CHACHA20POLY1305,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_DHE_PSK_WITH_CHACHA20_POLY1305,
     TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_CHACHA20POLY1305,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_RSA_PSK_WITH_CHACHA20_POLY1305,
     TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305,
     SSL_kRSAPSK,
     SSL_aRSA,
     SSL_CHACHA20POLY1305,
     SSL_AEAD,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
E
Emilia Kasper 已提交
2069 2070 2071
# endif                         /* OPENSSL_NO_PSK */
#endif                          /* !defined(OPENSSL_NO_CHACHA) &&
                                 * !defined(OPENSSL_NO_POLY1305) */
R
Rich Salz 已提交
2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202

#ifndef OPENSSL_NO_CAMELLIA
    {
     1,
     TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kRSA,
     SSL_aRSA,
     SSL_CAMELLIA128,
     SSL_SHA256,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kEDH,
     SSL_aDSS,
     SSL_CAMELLIA128,
     SSL_SHA256,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kEDH,
     SSL_aRSA,
     SSL_CAMELLIA128,
     SSL_SHA256,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kEDH,
     SSL_aNULL,
     SSL_CAMELLIA128,
     SSL_SHA256,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA256,
     TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA256,
     SSL_kRSA,
     SSL_aRSA,
     SSL_CAMELLIA256,
     SSL_SHA256,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256,
     TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256,
     SSL_kEDH,
     SSL_aDSS,
     SSL_CAMELLIA256,
     SSL_SHA256,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256,
     TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256,
     SSL_kEDH,
     SSL_aRSA,
     SSL_CAMELLIA256,
     SSL_SHA256,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA256,
     TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA256,
     SSL_kEDH,
     SSL_aNULL,
     SSL_CAMELLIA256,
     SSL_SHA256,
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA,
     TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA,
     SSL_kRSA,
     SSL_aRSA,
     SSL_CAMELLIA256,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2203
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
     TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
     SSL_kDHE,
     SSL_aDSS,
     SSL_CAMELLIA256,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2218
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
     TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
     SSL_kDHE,
     SSL_aRSA,
     SSL_CAMELLIA256,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2233
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA,
     TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA,
     SSL_kDHE,
     SSL_aNULL,
     SSL_CAMELLIA256,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2248
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
     TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA,
     TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA,
     SSL_kRSA,
     SSL_aRSA,
     SSL_CAMELLIA128,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2263
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
     TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
     SSL_kDHE,
     SSL_aDSS,
     SSL_CAMELLIA128,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2278
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
     TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
     SSL_kDHE,
     SSL_aRSA,
     SSL_CAMELLIA128,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2293
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
     TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA,
     TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA,
     SSL_kDHE,
     SSL_aNULL,
     SSL_CAMELLIA128,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2308
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2309 2310 2311 2312 2313 2314 2315 2316
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },

# ifndef OPENSSL_NO_EC
    {
2317 2318 2319 2320 2321 2322 2323
     1,
     TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_CAMELLIA128,
     SSL_SHA256,
2324 2325
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2326
     SSL_NOT_DEFAULT | SSL_HIGH,
2327 2328
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
E
Emilia Kasper 已提交
2329 2330
     128,
     },
R
Rich Salz 已提交
2331
    {
2332 2333 2334 2335 2336 2337 2338
     1,
     TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
     TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_CAMELLIA256,
     SSL_SHA384,
2339 2340
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2341
     SSL_NOT_DEFAULT | SSL_HIGH,
2342 2343
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
E
Emilia Kasper 已提交
2344 2345
     256,
     },
R
Rich Salz 已提交
2346
    {
2347 2348 2349 2350 2351 2352 2353
     1,
     TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kECDHE,
     SSL_aRSA,
     SSL_CAMELLIA128,
     SSL_SHA256,
2354 2355
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2356
     SSL_NOT_DEFAULT | SSL_HIGH,
2357 2358
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
E
Emilia Kasper 已提交
2359 2360
     128,
     },
R
Rich Salz 已提交
2361
    {
2362 2363 2364 2365 2366 2367 2368
     1,
     TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384,
     TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384,
     SSL_kECDHE,
     SSL_aRSA,
     SSL_CAMELLIA256,
     SSL_SHA384,
2369 2370
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2371
     SSL_NOT_DEFAULT | SSL_HIGH,
2372 2373
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
E
Emilia Kasper 已提交
2374 2375 2376
     256,
     },
# endif                         /* OPENSSL_NO_EC */
B
Ben Laurie 已提交
2377

R
Rich Salz 已提交
2378 2379
# ifndef OPENSSL_NO_PSK
    {
2380 2381 2382 2383 2384 2385 2386
     1,
     TLS1_TXT_PSK_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_PSK_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kPSK,
     SSL_aPSK,
     SSL_CAMELLIA128,
     SSL_SHA256,
2387
     TLS1_VERSION, TLS1_2_VERSION,
2388
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2389
     SSL_NOT_DEFAULT | SSL_HIGH,
2390 2391
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
E
Emilia Kasper 已提交
2392 2393
     128,
     },
R
Rich Salz 已提交
2394
    {
2395 2396 2397 2398 2399 2400 2401
     1,
     TLS1_TXT_PSK_WITH_CAMELLIA_256_CBC_SHA384,
     TLS1_CK_PSK_WITH_CAMELLIA_256_CBC_SHA384,
     SSL_kPSK,
     SSL_aPSK,
     SSL_CAMELLIA256,
     SSL_SHA384,
2402
     TLS1_VERSION, TLS1_2_VERSION,
2403
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2404
     SSL_NOT_DEFAULT | SSL_HIGH,
2405 2406
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
E
Emilia Kasper 已提交
2407 2408
     256,
     },
R
Rich Salz 已提交
2409
    {
2410 2411 2412 2413 2414 2415 2416
     1,
     TLS1_TXT_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_CAMELLIA128,
     SSL_SHA256,
2417
     TLS1_VERSION, TLS1_2_VERSION,
2418
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2419
     SSL_NOT_DEFAULT | SSL_HIGH,
2420 2421
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
E
Emilia Kasper 已提交
2422 2423
     128,
     },
R
Rich Salz 已提交
2424
    {
2425 2426 2427 2428 2429 2430 2431
     1,
     TLS1_TXT_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384,
     TLS1_CK_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_CAMELLIA256,
     SSL_SHA384,
2432
     TLS1_VERSION, TLS1_2_VERSION,
2433
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2434
     SSL_NOT_DEFAULT | SSL_HIGH,
2435 2436
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
E
Emilia Kasper 已提交
2437 2438
     256,
     },
R
Rich Salz 已提交
2439
    {
2440 2441 2442 2443 2444 2445 2446
     1,
     TLS1_TXT_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kRSAPSK,
     SSL_aRSA,
     SSL_CAMELLIA128,
     SSL_SHA256,
2447
     TLS1_VERSION, TLS1_2_VERSION,
2448
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2449
     SSL_NOT_DEFAULT | SSL_HIGH,
2450 2451
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
E
Emilia Kasper 已提交
2452 2453
     128,
     },
R
Rich Salz 已提交
2454
    {
2455 2456 2457 2458 2459 2460 2461
     1,
     TLS1_TXT_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384,
     TLS1_CK_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384,
     SSL_kRSAPSK,
     SSL_aRSA,
     SSL_CAMELLIA256,
     SSL_SHA384,
2462
     TLS1_VERSION, TLS1_2_VERSION,
2463
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2464
     SSL_NOT_DEFAULT | SSL_HIGH,
2465 2466
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
E
Emilia Kasper 已提交
2467 2468
     256,
     },
2469 2470
    {
     1,
R
Rich Salz 已提交
2471 2472 2473
     TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kECDHEPSK,
2474
     SSL_aPSK,
R
Rich Salz 已提交
2475 2476 2477
     SSL_CAMELLIA128,
     SSL_SHA256,
     TLS1_VERSION, TLS1_2_VERSION,
2478
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2479
     SSL_NOT_DEFAULT | SSL_HIGH,
R
Rich Salz 已提交
2480
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2481
     128,
E
Emilia Kasper 已提交
2482 2483
     128,
     },
2484 2485
    {
     1,
R
Rich Salz 已提交
2486 2487 2488
     TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384,
     TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384,
     SSL_kECDHEPSK,
2489
     SSL_aPSK,
R
Rich Salz 已提交
2490 2491 2492
     SSL_CAMELLIA256,
     SSL_SHA384,
     TLS1_VERSION, TLS1_2_VERSION,
2493
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2494
     SSL_NOT_DEFAULT | SSL_HIGH,
R
Rich Salz 已提交
2495
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2496
     256,
E
Emilia Kasper 已提交
2497 2498 2499
     256,
     },
# endif                         /* OPENSSL_NO_PSK */
2500

E
Emilia Kasper 已提交
2501
#endif                          /* OPENSSL_NO_CAMELLIA */
2502

P
Pauli 已提交
2503
#ifndef OPENSSL_NO_GOST
2504 2505
    {
     1,
R
Rich Salz 已提交
2506 2507 2508 2509 2510 2511 2512
     "GOST2001-GOST89-GOST89",
     0x3000081,
     SSL_kGOST,
     SSL_aGOST01,
     SSL_eGOST2814789CNT,
     SSL_GOST89MAC,
     TLS1_VERSION, TLS1_2_VERSION,
2513
     0, 0,
R
Rich Salz 已提交
2514 2515
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94 | TLS1_STREAM_MAC,
2516
     256,
E
Emilia Kasper 已提交
2517 2518
     256,
     },
R
Rich Salz 已提交
2519 2520 2521 2522 2523 2524 2525 2526 2527
    {
     1,
     "GOST2001-NULL-GOST94",
     0x3000083,
     SSL_kGOST,
     SSL_aGOST01,
     SSL_eNULL,
     SSL_GOST94,
     TLS1_VERSION, TLS1_2_VERSION,
2528
     0, 0,
R
Rich Salz 已提交
2529 2530 2531
     SSL_STRONG_NONE,
     SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94,
     0,
E
Emilia Kasper 已提交
2532 2533
     0,
     },
R
Rich Salz 已提交
2534 2535 2536 2537 2538 2539 2540 2541 2542
    {
     1,
     "GOST2012-GOST8912-GOST8912",
     0x0300ff85,
     SSL_kGOST,
     SSL_aGOST12 | SSL_aGOST01,
     SSL_eGOST2814789CNT12,
     SSL_GOST89MAC12,
     TLS1_VERSION, TLS1_2_VERSION,
2543
     0, 0,
R
Rich Salz 已提交
2544 2545
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_GOST12_256 | TLS1_PRF_GOST12_256 | TLS1_STREAM_MAC,
2546
     256,
E
Emilia Kasper 已提交
2547 2548
     256,
     },
R
Rich Salz 已提交
2549 2550 2551 2552 2553 2554 2555 2556 2557
    {
     1,
     "GOST2012-NULL-GOST12",
     0x0300ff87,
     SSL_kGOST,
     SSL_aGOST12 | SSL_aGOST01,
     SSL_eNULL,
     SSL_GOST12_256,
     TLS1_VERSION, TLS1_2_VERSION,
2558
     0, 0,
R
Rich Salz 已提交
2559 2560 2561
     SSL_STRONG_NONE,
     SSL_HANDSHAKE_MAC_GOST12_256 | TLS1_PRF_GOST12_256 | TLS1_STREAM_MAC,
     0,
E
Emilia Kasper 已提交
2562 2563 2564
     0,
     },
#endif                          /* OPENSSL_NO_GOST */
2565

R
Rich Salz 已提交
2566
#ifndef OPENSSL_NO_IDEA
2567 2568
    {
     1,
R
Rich Salz 已提交
2569 2570 2571 2572 2573 2574 2575
     SSL3_TXT_RSA_IDEA_128_SHA,
     SSL3_CK_RSA_IDEA_128_SHA,
     SSL_kRSA,
     SSL_aRSA,
     SSL_IDEA,
     SSL_SHA1,
     SSL3_VERSION, TLS1_1_VERSION,
2576
     DTLS1_BAD_VER, DTLS1_VERSION,
R
Rich Salz 已提交
2577 2578
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2579 2580 2581
     128,
     128,
     },
R
Rich Salz 已提交
2582
#endif
2583

R
Rich Salz 已提交
2584
#ifndef OPENSSL_NO_SEED
2585 2586
    {
     1,
R
Rich Salz 已提交
2587 2588 2589 2590 2591 2592 2593
     TLS1_TXT_RSA_WITH_SEED_SHA,
     TLS1_CK_RSA_WITH_SEED_SHA,
     SSL_kRSA,
     SSL_aRSA,
     SSL_SEED,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2594
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2595 2596 2597 2598
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
2599 2600 2601
     },
    {
     1,
R
Rich Salz 已提交
2602 2603 2604 2605 2606 2607 2608
     TLS1_TXT_DHE_DSS_WITH_SEED_SHA,
     TLS1_CK_DHE_DSS_WITH_SEED_SHA,
     SSL_kDHE,
     SSL_aDSS,
     SSL_SEED,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2609
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2610 2611
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2612 2613 2614 2615 2616
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
2617 2618 2619 2620 2621 2622 2623
     TLS1_TXT_DHE_RSA_WITH_SEED_SHA,
     TLS1_CK_DHE_RSA_WITH_SEED_SHA,
     SSL_kDHE,
     SSL_aRSA,
     SSL_SEED,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2624
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2625 2626 2627 2628
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
2629 2630 2631
     },
    {
     1,
R
Rich Salz 已提交
2632 2633 2634 2635 2636 2637 2638
     TLS1_TXT_ADH_WITH_SEED_SHA,
     TLS1_CK_ADH_WITH_SEED_SHA,
     SSL_kDHE,
     SSL_aNULL,
     SSL_SEED,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
2639
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2640 2641
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2642 2643 2644
     128,
     128,
     },
E
Emilia Kasper 已提交
2645
#endif                          /* OPENSSL_NO_SEED */
2646

R
Rich Salz 已提交
2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662
#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
    {
     1,
     SSL3_TXT_RSA_RC4_128_MD5,
     SSL3_CK_RSA_RC4_128_MD5,
     SSL_kRSA,
     SSL_aRSA,
     SSL_RC4,
     SSL_MD5,
     SSL3_VERSION, TLS1_2_VERSION,
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
2663 2664
    {
     1,
R
Rich Salz 已提交
2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676
     SSL3_TXT_RSA_RC4_128_SHA,
     SSL3_CK_RSA_RC4_128_SHA,
     SSL_kRSA,
     SSL_aRSA,
     SSL_RC4,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
2677 2678 2679
     },
    {
     1,
R
Rich Salz 已提交
2680 2681 2682 2683 2684 2685 2686 2687 2688 2689
     SSL3_TXT_ADH_RC4_128_MD5,
     SSL3_CK_ADH_RC4_128_MD5,
     SSL_kDHE,
     SSL_aNULL,
     SSL_RC4,
     SSL_MD5,
     SSL3_VERSION, TLS1_2_VERSION,
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2690 2691 2692 2693
     128,
     128,
     },

R
Rich Salz 已提交
2694
# ifndef OPENSSL_NO_EC
2695 2696
    {
     1,
R
Rich Salz 已提交
2697 2698 2699 2700 2701 2702
     TLS1_TXT_ECDHE_PSK_WITH_RC4_128_SHA,
     TLS1_CK_ECDHE_PSK_WITH_RC4_128_SHA,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_RC4,
     SSL_SHA1,
T
Todd Short 已提交
2703
     TLS1_VERSION, TLS1_2_VERSION,
R
Rich Salz 已提交
2704 2705 2706 2707 2708
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
2709
     },
A
Andy Polyakov 已提交
2710 2711
    {
     1,
R
Rich Salz 已提交
2712 2713
     TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA,
     TLS1_CK_ECDH_anon_WITH_RC4_128_SHA,
A
Andy Polyakov 已提交
2714
     SSL_kECDHE,
R
Rich Salz 已提交
2715 2716 2717
     SSL_aNULL,
     SSL_RC4,
     SSL_SHA1,
T
Todd Short 已提交
2718
     TLS1_VERSION, TLS1_2_VERSION,
R
Rich Salz 已提交
2719 2720 2721 2722 2723
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
A
Andy Polyakov 已提交
2724 2725 2726
     },
    {
     1,
R
Rich Salz 已提交
2727 2728
     TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA,
     TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA,
A
Andy Polyakov 已提交
2729 2730
     SSL_kECDHE,
     SSL_aECDSA,
R
Rich Salz 已提交
2731 2732
     SSL_RC4,
     SSL_SHA1,
T
Todd Short 已提交
2733
     TLS1_VERSION, TLS1_2_VERSION,
R
Rich Salz 已提交
2734 2735 2736 2737 2738
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
A
Andy Polyakov 已提交
2739 2740 2741
     },
    {
     1,
R
Rich Salz 已提交
2742 2743 2744
     TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA,
     TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA,
     SSL_kECDHE,
A
Andy Polyakov 已提交
2745
     SSL_aRSA,
R
Rich Salz 已提交
2746 2747
     SSL_RC4,
     SSL_SHA1,
T
Todd Short 已提交
2748
     TLS1_VERSION, TLS1_2_VERSION,
R
Rich Salz 已提交
2749 2750 2751 2752 2753
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
A
Andy Polyakov 已提交
2754
     },
E
Emilia Kasper 已提交
2755
# endif                         /* OPENSSL_NO_EC */
R
Rich Salz 已提交
2756

A
Andy Polyakov 已提交
2757 2758 2759
# ifndef OPENSSL_NO_PSK
    {
     1,
R
Rich Salz 已提交
2760 2761
     TLS1_TXT_PSK_WITH_RC4_128_SHA,
     TLS1_CK_PSK_WITH_RC4_128_SHA,
A
Andy Polyakov 已提交
2762 2763
     SSL_kPSK,
     SSL_aPSK,
R
Rich Salz 已提交
2764 2765 2766 2767 2768 2769 2770 2771
     SSL_RC4,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
A
Andy Polyakov 已提交
2772 2773 2774
     },
    {
     1,
R
Rich Salz 已提交
2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786
     TLS1_TXT_RSA_PSK_WITH_RC4_128_SHA,
     TLS1_CK_RSA_PSK_WITH_RC4_128_SHA,
     SSL_kRSAPSK,
     SSL_aRSA,
     SSL_RC4,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
A
Andy Polyakov 已提交
2787 2788 2789
     },
    {
     1,
R
Rich Salz 已提交
2790 2791
     TLS1_TXT_DHE_PSK_WITH_RC4_128_SHA,
     TLS1_CK_DHE_PSK_WITH_RC4_128_SHA,
A
Andy Polyakov 已提交
2792 2793
     SSL_kDHEPSK,
     SSL_aPSK,
R
Rich Salz 已提交
2794 2795 2796 2797 2798 2799 2800 2801
     SSL_RC4,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
A
Andy Polyakov 已提交
2802
     },
E
Emilia Kasper 已提交
2803
# endif                         /* OPENSSL_NO_PSK */
R
Rich Salz 已提交
2804

E
Emilia Kasper 已提交
2805
#endif                          /* OPENSSL_NO_WEAK_SSL_CIPHERS */
2806

2807 2808
};

2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828
/*
 * The list of known Signalling Cipher-Suite Value "ciphers", non-valid
 * values stuffed into the ciphers field of the wire protocol for signalling
 * purposes.
 */
static SSL_CIPHER ssl3_scsvs[] = {
    {
     0,
     "TLS_EMPTY_RENEGOTIATION_INFO_SCSV",
     SSL3_CK_SCSV,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    },
    {
     0,
     "TLS_FALLBACK_SCSV",
     SSL3_CK_FALLBACK_SCSV,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    },
};

R
Rich Salz 已提交
2829 2830 2831 2832 2833 2834 2835 2836 2837 2838
static int cipher_compare(const void *a, const void *b)
{
    const SSL_CIPHER *ap = (const SSL_CIPHER *)a;
    const SSL_CIPHER *bp = (const SSL_CIPHER *)b;

    return ap->id - bp->id;
}

void ssl_sort_cipher_list(void)
{
2839
    qsort(ssl3_ciphers, SSL3_NUM_CIPHERS, sizeof ssl3_ciphers[0],
R
Rich Salz 已提交
2840
          cipher_compare);
2841
    qsort(ssl3_scsvs, SSL3_NUM_SCSVS, sizeof ssl3_scsvs[0], cipher_compare);
R
Rich Salz 已提交
2842 2843
}

2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857
const SSL3_ENC_METHOD SSLv3_enc_data = {
    ssl3_enc,
    n_ssl3_mac,
    ssl3_setup_key_block,
    ssl3_generate_master_secret,
    ssl3_change_cipher_state,
    ssl3_final_finish_mac,
    SSL3_MD_CLIENT_FINISHED_CONST, 4,
    SSL3_MD_SERVER_FINISHED_CONST, 4,
    ssl3_alert_code,
    (int (*)(SSL *, unsigned char *, size_t, const char *,
             size_t, const unsigned char *, size_t,
             int use_context))ssl_undefined_function,
    0,
M
Matt Caswell 已提交
2858
    ssl3_set_handshake_header,
2859
    tls_close_construct_packet,
2860 2861
    ssl3_handshake_write
};
2862

2863
long ssl3_default_timeout(void)
2864 2865 2866 2867 2868 2869 2870
{
    /*
     * 2 hours, the 24 hours mentioned in the SSLv3 spec is way too long for
     * http, the cache would over fill
     */
    return (60 * 60 * 2);
}
2871

U
Ulf Möller 已提交
2872
int ssl3_num_ciphers(void)
2873 2874 2875
{
    return (SSL3_NUM_CIPHERS);
}
2876

2877
const SSL_CIPHER *ssl3_get_cipher(unsigned int u)
2878 2879 2880 2881 2882 2883
{
    if (u < SSL3_NUM_CIPHERS)
        return (&(ssl3_ciphers[SSL3_NUM_CIPHERS - 1 - u]));
    else
        return (NULL);
}
2884

M
Matt Caswell 已提交
2885
int ssl3_set_handshake_header(SSL *s, WPACKET *pkt, int htype)
2886
{
2887 2888 2889 2890
    /* No header in the event of a CCS */
    if (htype == SSL3_MT_CHANGE_CIPHER_SPEC)
        return 1;

2891
    /* Set the content type and 3 bytes for the message len */
2892
    if (!WPACKET_put_bytes_u8(pkt, htype)
M
Matt Caswell 已提交
2893
            || !WPACKET_start_sub_packet_u24(pkt))
2894 2895 2896 2897 2898
        return 0;

    return 1;
}

D
Dr. Stephen Henson 已提交
2899
int ssl3_handshake_write(SSL *s)
2900 2901 2902
{
    return ssl3_do_write(s, SSL3_RT_HANDSHAKE);
}
D
Dr. Stephen Henson 已提交
2903

U
Ulf Möller 已提交
2904
int ssl3_new(SSL *s)
2905 2906
{
    SSL3_STATE *s3;
2907

R
Rich Salz 已提交
2908
    if ((s3 = OPENSSL_zalloc(sizeof(*s3))) == NULL)
2909 2910
        goto err;
    s->s3 = s3;
B
Ben Laurie 已提交
2911

B
Ben Laurie 已提交
2912
#ifndef OPENSSL_NO_SRP
V
Viktor Dukhovni 已提交
2913
    if (!SSL_SRP_CTX_init(s))
E
Emilia Kasper 已提交
2914
        goto err;
B
Ben Laurie 已提交
2915
#endif
2916 2917 2918 2919

    if (!s->method->ssl_clear(s))
        return 0;

M
Matt Caswell 已提交
2920
    return 1;
2921
 err:
M
Matt Caswell 已提交
2922
    return 0;
2923
}
2924

U
Ulf Möller 已提交
2925
void ssl3_free(SSL *s)
2926
{
2927
    if (s == NULL || s->s3 == NULL)
2928
        return;
B
Ben Laurie 已提交
2929

2930
    ssl3_cleanup_key_block(s);
2931

D
Dr. Stephen Henson 已提交
2932
#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
2933 2934
    EVP_PKEY_free(s->s3->peer_tmp);
    s->s3->peer_tmp = NULL;
D
Dr. Stephen Henson 已提交
2935 2936
    EVP_PKEY_free(s->s3->tmp.pkey);
    s->s3->tmp.pkey = NULL;
B
Bodo Möller 已提交
2937 2938
#endif

2939
    OPENSSL_free(s->s3->tmp.ctype);
2940
    sk_X509_NAME_pop_free(s->s3->tmp.peer_ca_names, X509_NAME_free);
D
Dr. Stephen Henson 已提交
2941 2942 2943
    OPENSSL_free(s->s3->tmp.ciphers_raw);
    OPENSSL_clear_free(s->s3->tmp.pms, s->s3->tmp.pmslen);
    OPENSSL_free(s->s3->tmp.peer_sigalgs);
2944
    ssl3_free_digest_list(s);
R
Rich Salz 已提交
2945
    OPENSSL_free(s->s3->alpn_selected);
T
Todd Short 已提交
2946
    OPENSSL_free(s->s3->alpn_proposed);
A
Adam Langley 已提交
2947

B
Ben Laurie 已提交
2948
#ifndef OPENSSL_NO_SRP
2949
    SSL_SRP_CTX_free(s);
B
Ben Laurie 已提交
2950
#endif
R
Rich Salz 已提交
2951
    OPENSSL_clear_free(s->s3, sizeof(*s->s3));
2952 2953
    s->s3 = NULL;
}
2954

2955
int ssl3_clear(SSL *s)
2956 2957
{
    ssl3_cleanup_key_block(s);
2958
    OPENSSL_free(s->s3->tmp.ctype);
2959
    sk_X509_NAME_pop_free(s->s3->tmp.peer_ca_names, X509_NAME_free);
D
Dr. Stephen Henson 已提交
2960 2961 2962
    OPENSSL_free(s->s3->tmp.ciphers_raw);
    OPENSSL_clear_free(s->s3->tmp.pms, s->s3->tmp.pmslen);
    OPENSSL_free(s->s3->tmp.peer_sigalgs);
2963

D
Dr. Stephen Henson 已提交
2964
#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
D
Dr. Stephen Henson 已提交
2965
    EVP_PKEY_free(s->s3->tmp.pkey);
2966
    EVP_PKEY_free(s->s3->peer_tmp);
E
Emilia Kasper 已提交
2967
#endif                          /* !OPENSSL_NO_EC */
2968

2969
    ssl3_free_digest_list(s);
2970

T
Todd Short 已提交
2971 2972
    OPENSSL_free(s->s3->alpn_selected);
    OPENSSL_free(s->s3->alpn_proposed);
2973

T
Todd Short 已提交
2974
    /* NULL/zero-out everything in the s3 struct */
R
Rich Salz 已提交
2975
    memset(s->s3, 0, sizeof(*s->s3));
2976

2977 2978
    if (!ssl_free_wbio_buffer(s))
        return 0;
2979 2980

    s->version = SSL3_VERSION;
B
Ben Laurie 已提交
2981

2982
#if !defined(OPENSSL_NO_NEXTPROTONEG)
R
Rich Salz 已提交
2983 2984 2985
    OPENSSL_free(s->ext.npn);
    s->ext.npn = NULL;
    s->ext.npn_len = 0;
B
Ben Laurie 已提交
2986
#endif
2987 2988

    return 1;
2989
}
2990

B
Ben Laurie 已提交
2991
#ifndef OPENSSL_NO_SRP
2992 2993
static char *srp_password_from_info_cb(SSL *s, void *arg)
{
R
Rich Salz 已提交
2994
    return OPENSSL_strdup(s->srp_ctx.info);
2995
}
B
Ben Laurie 已提交
2996 2997
#endif

E
Emilia Kasper 已提交
2998
static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p, size_t len);
2999

3000
long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
3001 3002
{
    int ret = 0;
3003

3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019
    switch (cmd) {
    case SSL_CTRL_GET_CLIENT_CERT_REQUEST:
        break;
    case SSL_CTRL_GET_NUM_RENEGOTIATIONS:
        ret = s->s3->num_renegotiations;
        break;
    case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS:
        ret = s->s3->num_renegotiations;
        s->s3->num_renegotiations = 0;
        break;
    case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS:
        ret = s->s3->total_renegotiations;
        break;
    case SSL_CTRL_GET_FLAGS:
        ret = (int)(s->s3->flags);
        break;
3020
#ifndef OPENSSL_NO_DH
3021 3022 3023
    case SSL_CTRL_SET_TMP_DH:
        {
            DH *dh = (DH *)parg;
3024
            EVP_PKEY *pkdh = NULL;
3025 3026 3027 3028
            if (dh == NULL) {
                SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
                return (ret);
            }
3029 3030 3031 3032 3033
            pkdh = ssl_dh_to_pkey(dh);
            if (pkdh == NULL) {
                SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
                return 0;
            }
3034
            if (!ssl_security(s, SSL_SECOP_TMP_DH,
3035
                              EVP_PKEY_security_bits(pkdh), 0, pkdh)) {
3036
                SSLerr(SSL_F_SSL3_CTRL, SSL_R_DH_KEY_TOO_SMALL);
3037 3038
                EVP_PKEY_free(pkdh);
                return ret;
3039
            }
3040 3041
            EVP_PKEY_free(s->cert->dh_tmp);
            s->cert->dh_tmp = pkdh;
3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052
            ret = 1;
        }
        break;
    case SSL_CTRL_SET_TMP_DH_CB:
        {
            SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
            return (ret);
        }
    case SSL_CTRL_SET_DH_AUTO:
        s->cert->dh_tmp_auto = larg;
        return 1;
3053
#endif
3054
#ifndef OPENSSL_NO_EC
3055 3056
    case SSL_CTRL_SET_TMP_ECDH:
        {
3057 3058
            const EC_GROUP *group = NULL;
            int nid;
3059 3060 3061

            if (parg == NULL) {
                SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3062
                return 0;
3063
            }
3064 3065 3066 3067
            group = EC_KEY_get0_group((const EC_KEY *)parg);
            if (group == NULL) {
                SSLerr(SSL_F_SSL3_CTRL, EC_R_MISSING_PARAMETERS);
                return 0;
3068
            }
3069 3070 3071
            nid = EC_GROUP_get_curve_name(group);
            if (nid == NID_undef)
                return 0;
R
Rich Salz 已提交
3072 3073
            return tls1_set_groups(&s->ext.supportedgroups,
                                   &s->ext.supportedgroups_len,
3074
                                   &nid, 1);
3075 3076
        }
        break;
3077
#endif                          /* !OPENSSL_NO_EC */
3078 3079
    case SSL_CTRL_SET_TLSEXT_HOSTNAME:
        if (larg == TLSEXT_NAMETYPE_host_name) {
V
Viktor Dukhovni 已提交
3080 3081
            size_t len;

R
Rich Salz 已提交
3082 3083
            OPENSSL_free(s->ext.hostname);
            s->ext.hostname = NULL;
3084 3085 3086 3087

            ret = 1;
            if (parg == NULL)
                break;
V
Viktor Dukhovni 已提交
3088 3089
            len = strlen((char *)parg);
            if (len == 0 || len > TLSEXT_MAXLEN_host_name) {
3090 3091 3092
                SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
                return 0;
            }
R
Rich Salz 已提交
3093
            if ((s->ext.hostname = OPENSSL_strdup((char *)parg)) == NULL) {
3094 3095 3096 3097 3098 3099 3100 3101 3102
                SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR);
                return 0;
            }
        } else {
            SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE);
            return 0;
        }
        break;
    case SSL_CTRL_SET_TLSEXT_DEBUG_ARG:
R
Rich Salz 已提交
3103
        s->ext.debug_arg = parg;
3104 3105 3106
        ret = 1;
        break;

3107
    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE:
R
Rich Salz 已提交
3108
        ret = s->ext.status_type;
3109 3110
        break;

3111
    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
R
Rich Salz 已提交
3112
        s->ext.status_type = larg;
3113 3114 3115 3116
        ret = 1;
        break;

    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS:
R
Rich Salz 已提交
3117
        *(STACK_OF(X509_EXTENSION) **)parg = s->ext.ocsp.exts;
3118 3119 3120 3121
        ret = 1;
        break;

    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS:
R
Rich Salz 已提交
3122
        s->ext.ocsp.exts = parg;
3123 3124 3125 3126
        ret = 1;
        break;

    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS:
R
Rich Salz 已提交
3127
        *(STACK_OF(OCSP_RESPID) **)parg = s->ext.ocsp.ids;
3128 3129 3130 3131
        ret = 1;
        break;

    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS:
R
Rich Salz 已提交
3132
        s->ext.ocsp.ids = parg;
3133 3134 3135 3136
        ret = 1;
        break;

    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP:
R
Rich Salz 已提交
3137 3138 3139
        *(unsigned char **)parg = s->ext.ocsp.resp;
        if (s->ext.ocsp.resp_len == 0
                || s->ext.ocsp.resp_len > LONG_MAX)
M
Matt Caswell 已提交
3140
            return -1;
R
Rich Salz 已提交
3141
        return (long)s->ext.ocsp.resp_len;
3142 3143

    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP:
R
Rich Salz 已提交
3144 3145 3146
        OPENSSL_free(s->ext.ocsp.resp);
        s->ext.ocsp.resp = parg;
        s->ext.ocsp.resp_len = larg;
3147 3148 3149
        ret = 1;
        break;

3150 3151 3152 3153 3154 3155 3156
#ifndef OPENSSL_NO_HEARTBEATS
    case SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT:
    case SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING:
    case SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS:
        break;
#endif

3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181
    case SSL_CTRL_CHAIN:
        if (larg)
            return ssl_cert_set1_chain(s, NULL, (STACK_OF(X509) *)parg);
        else
            return ssl_cert_set0_chain(s, NULL, (STACK_OF(X509) *)parg);

    case SSL_CTRL_CHAIN_CERT:
        if (larg)
            return ssl_cert_add1_chain_cert(s, NULL, (X509 *)parg);
        else
            return ssl_cert_add0_chain_cert(s, NULL, (X509 *)parg);

    case SSL_CTRL_GET_CHAIN_CERTS:
        *(STACK_OF(X509) **)parg = s->cert->key->chain;
        break;

    case SSL_CTRL_SELECT_CURRENT_CERT:
        return ssl_cert_select_current(s->cert, (X509 *)parg);

    case SSL_CTRL_SET_CURRENT_CERT:
        if (larg == SSL_CERT_SET_SERVER) {
            const SSL_CIPHER *cipher;
            if (!s->server)
                return 0;
            cipher = s->s3->tmp.new_cipher;
D
Dr. Stephen Henson 已提交
3182
            if (cipher == NULL)
3183 3184 3185 3186 3187 3188 3189
                return 0;
            /*
             * No certificate for unauthenticated ciphersuites or using SRP
             * authentication
             */
            if (cipher->algorithm_auth & (SSL_aNULL | SSL_aSRP))
                return 2;
3190
            if (s->s3->tmp.cert == NULL)
3191
                return 0;
3192
            s->cert->key = s->s3->tmp.cert;
3193 3194 3195
            return 1;
        }
        return ssl_cert_set_current(s->cert, larg);
3196

3197
#ifndef OPENSSL_NO_EC
3198
    case SSL_CTRL_GET_GROUPS:
3199 3200 3201
        {
            unsigned char *clist;
            size_t clistlen;
R
Rich Salz 已提交
3202

3203 3204
            if (!s->session)
                return 0;
R
Rich Salz 已提交
3205 3206
            clist = s->session->ext.supportedgroups;
            clistlen = s->session->ext.supportedgroups_len / 2;
3207 3208 3209 3210 3211 3212
            if (parg) {
                size_t i;
                int *cptr = parg;
                unsigned int cid, nid;
                for (i = 0; i < clistlen; i++) {
                    n2s(clist, cid);
3213
                    /* TODO(TLS1.3): Handle DH groups here */
3214
                    nid = tls1_ec_curve_id2nid(cid, NULL);
3215 3216 3217 3218 3219 3220 3221 3222 3223
                    if (nid != 0)
                        cptr[i] = nid;
                    else
                        cptr[i] = TLSEXT_nid_unknown | cid;
                }
            }
            return (int)clistlen;
        }

3224
    case SSL_CTRL_SET_GROUPS:
R
Rich Salz 已提交
3225 3226
        return tls1_set_groups(&s->ext.supportedgroups,
                               &s->ext.supportedgroups_len, parg, larg);
3227

3228
    case SSL_CTRL_SET_GROUPS_LIST:
R
Rich Salz 已提交
3229 3230
        return tls1_set_groups_list(&s->ext.supportedgroups,
                                    &s->ext.supportedgroups_len, parg);
3231

3232 3233
    case SSL_CTRL_GET_SHARED_GROUP:
        return tls1_shared_group(s, larg);
3234

3235
#endif
3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253
    case SSL_CTRL_SET_SIGALGS:
        return tls1_set_sigalgs(s->cert, parg, larg, 0);

    case SSL_CTRL_SET_SIGALGS_LIST:
        return tls1_set_sigalgs_list(s->cert, parg, 0);

    case SSL_CTRL_SET_CLIENT_SIGALGS:
        return tls1_set_sigalgs(s->cert, parg, larg, 1);

    case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
        return tls1_set_sigalgs_list(s->cert, parg, 1);

    case SSL_CTRL_GET_CLIENT_CERT_TYPES:
        {
            const unsigned char **pctype = parg;
            if (s->server || !s->s3->tmp.cert_req)
                return 0;
            if (pctype)
3254 3255
                *pctype = s->s3->tmp.ctype;
            return s->s3->tmp.ctype_len;
3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272
        }

    case SSL_CTRL_SET_CLIENT_CERT_TYPES:
        if (!s->server)
            return 0;
        return ssl3_set_req_cert_type(s->cert, parg, larg);

    case SSL_CTRL_BUILD_CERT_CHAIN:
        return ssl_build_cert_chain(s, NULL, larg);

    case SSL_CTRL_SET_VERIFY_CERT_STORE:
        return ssl_cert_set_cert_store(s->cert, parg, 0, larg);

    case SSL_CTRL_SET_CHAIN_CERT_STORE:
        return ssl_cert_set_cert_store(s->cert, parg, 1, larg);

    case SSL_CTRL_GET_PEER_SIGNATURE_NID:
3273
        if (s->s3->tmp.peer_sigalg == NULL)
3274
            return 0;
3275 3276
        *(int *)parg = s->s3->tmp.peer_sigalg->hash;
        return 1;
3277 3278

    case SSL_CTRL_GET_SERVER_TMP_KEY:
D
Dr. Stephen Henson 已提交
3279 3280
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC)
        if (s->server || s->session == NULL || s->s3->peer_tmp == NULL) {
3281
            return 0;
D
Dr. Stephen Henson 已提交
3282 3283 3284 3285
        } else {
            EVP_PKEY_up_ref(s->s3->peer_tmp);
            *(EVP_PKEY **)parg = s->s3->peer_tmp;
            return 1;
3286
        }
D
Dr. Stephen Henson 已提交
3287 3288 3289
#else
        return 0;
#endif
3290
#ifndef OPENSSL_NO_EC
3291 3292 3293 3294
    case SSL_CTRL_GET_EC_POINT_FORMATS:
        {
            SSL_SESSION *sess = s->session;
            const unsigned char **pformat = parg;
R
Rich Salz 已提交
3295 3296

            if (sess == NULL || sess->ext.ecpointformats == NULL)
3297
                return 0;
R
Rich Salz 已提交
3298 3299
            *pformat = sess->ext.ecpointformats;
            return (int)sess->ext.ecpointformats_len;
3300
        }
3301
#endif
B
Bodo Moeller 已提交
3302

3303 3304 3305 3306 3307 3308 3309 3310 3311
    default:
        break;
    }
    return (ret);
}

long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp) (void))
{
    int ret = 0;
3312

3313
    switch (cmd) {
3314
#ifndef OPENSSL_NO_DH
3315 3316 3317 3318 3319
    case SSL_CTRL_SET_TMP_DH_CB:
        {
            s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
        }
        break;
3320
#endif
3321
    case SSL_CTRL_SET_TLSEXT_DEBUG_CB:
R
Rich Salz 已提交
3322
        s->ext.debug_cb = (void (*)(SSL *, int, int,
R
Rich Salz 已提交
3323
                                    const unsigned char *, int, void *))fp;
3324
        break;
3325

3326 3327 3328 3329 3330 3331 3332 3333 3334 3335
    case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
        {
            s->not_resumable_session_cb = (int (*)(SSL *, int))fp;
        }
        break;
    default:
        break;
    }
    return (ret);
}
3336

3337
long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
3338 3339
{
    switch (cmd) {
3340
#ifndef OPENSSL_NO_DH
3341 3342
    case SSL_CTRL_SET_TMP_DH:
        {
3343 3344 3345 3346
            DH *dh = (DH *)parg;
            EVP_PKEY *pkdh = NULL;
            if (dh == NULL) {
                SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3347 3348
                return 0;
            }
3349 3350 3351
            pkdh = ssl_dh_to_pkey(dh);
            if (pkdh == NULL) {
                SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_MALLOC_FAILURE);
3352 3353
                return 0;
            }
3354 3355 3356 3357 3358
            if (!ssl_ctx_security(ctx, SSL_SECOP_TMP_DH,
                                  EVP_PKEY_security_bits(pkdh), 0, pkdh)) {
                SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_DH_KEY_TOO_SMALL);
                EVP_PKEY_free(pkdh);
                return 1;
3359
            }
3360 3361
            EVP_PKEY_free(ctx->cert->dh_tmp);
            ctx->cert->dh_tmp = pkdh;
3362 3363 3364 3365 3366 3367 3368 3369 3370 3371
            return 1;
        }
    case SSL_CTRL_SET_TMP_DH_CB:
        {
            SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
            return (0);
        }
    case SSL_CTRL_SET_DH_AUTO:
        ctx->cert->dh_tmp_auto = larg;
        return 1;
3372
#endif
3373
#ifndef OPENSSL_NO_EC
3374 3375
    case SSL_CTRL_SET_TMP_ECDH:
        {
3376 3377
            const EC_GROUP *group = NULL;
            int nid;
3378 3379

            if (parg == NULL) {
3380
                SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3381 3382
                return 0;
            }
3383 3384 3385
            group = EC_KEY_get0_group((const EC_KEY *)parg);
            if (group == NULL) {
                SSLerr(SSL_F_SSL3_CTX_CTRL, EC_R_MISSING_PARAMETERS);
3386 3387
                return 0;
            }
3388 3389 3390
            nid = EC_GROUP_get_curve_name(group);
            if (nid == NID_undef)
                return 0;
R
Rich Salz 已提交
3391 3392
            return tls1_set_groups(&ctx->ext.supportedgroups,
                                   &ctx->ext.supportedgroups_len,
3393
                                   &nid, 1);
3394
        }
3395
#endif                          /* !OPENSSL_NO_EC */
3396
    case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG:
R
Rich Salz 已提交
3397
        ctx->ext.servername_arg = parg;
3398 3399 3400 3401 3402
        break;
    case SSL_CTRL_SET_TLSEXT_TICKET_KEYS:
    case SSL_CTRL_GET_TLSEXT_TICKET_KEYS:
        {
            unsigned char *keys = parg;
R
Rich Salz 已提交
3403 3404 3405
            long tick_keylen = (sizeof(ctx->ext.tick_key_name) +
                                sizeof(ctx->ext.tick_hmac_key) +
                                sizeof(ctx->ext.tick_aes_key));
K
Kurt Roeckx 已提交
3406
            if (keys == NULL)
R
Rich Salz 已提交
3407 3408
                return tick_keylen;
            if (larg != tick_keylen) {
3409 3410 3411 3412
                SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_TICKET_KEYS_LENGTH);
                return 0;
            }
            if (cmd == SSL_CTRL_SET_TLSEXT_TICKET_KEYS) {
R
Rich Salz 已提交
3413 3414 3415 3416 3417 3418 3419 3420 3421
                memcpy(ctx->ext.tick_key_name, keys,
                       sizeof(ctx->ext.tick_key_name));
                memcpy(ctx->ext.tick_hmac_key,
                       keys + sizeof(ctx->ext.tick_key_name),
                       sizeof(ctx->ext.tick_hmac_key));
                memcpy(ctx->ext.tick_aes_key,
                       keys + sizeof(ctx->ext.tick_key_name) +
                       sizeof(ctx->ext.tick_hmac_key),
                       sizeof(ctx->ext.tick_aes_key));
3422
            } else {
R
Rich Salz 已提交
3423 3424 3425 3426 3427 3428 3429 3430 3431
                memcpy(keys, ctx->ext.tick_key_name,
                       sizeof(ctx->ext.tick_key_name));
                memcpy(keys + sizeof(ctx->ext.tick_key_name),
                       ctx->ext.tick_hmac_key,
                       sizeof(ctx->ext.tick_hmac_key));
                memcpy(keys + sizeof(ctx->ext.tick_key_name) +
                       sizeof(ctx->ext.tick_hmac_key),
                       ctx->ext.tick_aes_key,
                       sizeof(ctx->ext.tick_aes_key));
3432 3433 3434 3435
            }
            return 1;
        }

3436
    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE:
R
Rich Salz 已提交
3437
        return ctx->ext.status_type;
3438

3439
    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
R
Rich Salz 已提交
3440
        ctx->ext.status_type = larg;
3441 3442
        break;

3443
    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG:
R
Rich Salz 已提交
3444
        ctx->ext.status_arg = parg;
3445 3446
        return 1;

3447
    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG:
R
Rich Salz 已提交
3448
        *(void**)parg = ctx->ext.status_arg;
3449 3450 3451
        break;

    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB:
R
Rich Salz 已提交
3452
        *(int (**)(SSL*, void*))parg = ctx->ext.status_cb;
3453 3454
        break;

3455
#ifndef OPENSSL_NO_SRP
3456 3457
    case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME:
        ctx->srp_ctx.srp_Mask |= SSL_kSRP;
R
Rich Salz 已提交
3458
        OPENSSL_free(ctx->srp_ctx.login);
3459 3460 3461
        ctx->srp_ctx.login = NULL;
        if (parg == NULL)
            break;
E
Emilia Kasper 已提交
3462
        if (strlen((const char *)parg) > 255 || strlen((const char *)parg) < 1) {
3463 3464 3465
            SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_SRP_USERNAME);
            return 0;
        }
R
Rich Salz 已提交
3466
        if ((ctx->srp_ctx.login = OPENSSL_strdup((char *)parg)) == NULL) {
3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483
            SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_INTERNAL_ERROR);
            return 0;
        }
        break;
    case SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD:
        ctx->srp_ctx.SRP_give_srp_client_pwd_callback =
            srp_password_from_info_cb;
        ctx->srp_ctx.info = parg;
        break;
    case SSL_CTRL_SET_SRP_ARG:
        ctx->srp_ctx.srp_Mask |= SSL_kSRP;
        ctx->srp_ctx.SRP_cb_arg = parg;
        break;

    case SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH:
        ctx->srp_ctx.strength = larg;
        break;
3484
#endif
3485

3486
#ifndef OPENSSL_NO_EC
3487
    case SSL_CTRL_SET_GROUPS:
R
Rich Salz 已提交
3488 3489
        return tls1_set_groups(&ctx->ext.supportedgroups,
                               &ctx->ext.supportedgroups_len,
3490 3491
                               parg, larg);

3492
    case SSL_CTRL_SET_GROUPS_LIST:
R
Rich Salz 已提交
3493 3494
        return tls1_set_groups_list(&ctx->ext.supportedgroups,
                                    &ctx->ext.supportedgroups_len,
3495
                                    parg);
3496
#endif
3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523
    case SSL_CTRL_SET_SIGALGS:
        return tls1_set_sigalgs(ctx->cert, parg, larg, 0);

    case SSL_CTRL_SET_SIGALGS_LIST:
        return tls1_set_sigalgs_list(ctx->cert, parg, 0);

    case SSL_CTRL_SET_CLIENT_SIGALGS:
        return tls1_set_sigalgs(ctx->cert, parg, larg, 1);

    case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
        return tls1_set_sigalgs_list(ctx->cert, parg, 1);

    case SSL_CTRL_SET_CLIENT_CERT_TYPES:
        return ssl3_set_req_cert_type(ctx->cert, parg, larg);

    case SSL_CTRL_BUILD_CERT_CHAIN:
        return ssl_build_cert_chain(NULL, ctx, larg);

    case SSL_CTRL_SET_VERIFY_CERT_STORE:
        return ssl_cert_set_cert_store(ctx->cert, parg, 0, larg);

    case SSL_CTRL_SET_CHAIN_CERT_STORE:
        return ssl_cert_set_cert_store(ctx->cert, parg, 1, larg);

        /* A Thawte special :-) */
    case SSL_CTRL_EXTRA_CHAIN_CERT:
        if (ctx->extra_certs == NULL) {
3524 3525 3526 3527 3528 3529 3530 3531
            if ((ctx->extra_certs = sk_X509_new_null()) == NULL) {
                SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_MALLOC_FAILURE);
                return 0;
            }
        }
        if (!sk_X509_push(ctx->extra_certs, (X509 *)parg)) {
            SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_MALLOC_FAILURE);
            return 0;
3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542
        }
        break;

    case SSL_CTRL_GET_EXTRA_CHAIN_CERTS:
        if (ctx->extra_certs == NULL && larg == 0)
            *(STACK_OF(X509) **)parg = ctx->cert->key->chain;
        else
            *(STACK_OF(X509) **)parg = ctx->extra_certs;
        break;

    case SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS:
R
Rich Salz 已提交
3543 3544
        sk_X509_pop_free(ctx->extra_certs, X509_free);
        ctx->extra_certs = NULL;
3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577
        break;

    case SSL_CTRL_CHAIN:
        if (larg)
            return ssl_cert_set1_chain(NULL, ctx, (STACK_OF(X509) *)parg);
        else
            return ssl_cert_set0_chain(NULL, ctx, (STACK_OF(X509) *)parg);

    case SSL_CTRL_CHAIN_CERT:
        if (larg)
            return ssl_cert_add1_chain_cert(NULL, ctx, (X509 *)parg);
        else
            return ssl_cert_add0_chain_cert(NULL, ctx, (X509 *)parg);

    case SSL_CTRL_GET_CHAIN_CERTS:
        *(STACK_OF(X509) **)parg = ctx->cert->key->chain;
        break;

    case SSL_CTRL_SELECT_CURRENT_CERT:
        return ssl_cert_select_current(ctx->cert, (X509 *)parg);

    case SSL_CTRL_SET_CURRENT_CERT:
        return ssl_cert_set_current(ctx->cert, larg);

    default:
        return (0);
    }
    return (1);
}

long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void))
{
    switch (cmd) {
3578
#ifndef OPENSSL_NO_DH
3579 3580
    case SSL_CTRL_SET_TMP_DH_CB:
        {
M
Matt Caswell 已提交
3581
            ctx->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3582 3583
        }
        break;
3584
#endif
3585
    case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB:
R
Rich Salz 已提交
3586
        ctx->ext.servername_cb = (int (*)(SSL *, int *, void *))fp;
3587 3588 3589
        break;

    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB:
R
Rich Salz 已提交
3590
        ctx->ext.status_cb = (int (*)(SSL *, void *))fp;
3591 3592 3593
        break;

    case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB:
R
Rich Salz 已提交
3594
        ctx->ext.ticket_key_cb = (int (*)(SSL *, unsigned char *,
3595 3596 3597 3598 3599
                                             unsigned char *,
                                             EVP_CIPHER_CTX *,
                                             HMAC_CTX *, int))fp;
        break;

3600
#ifndef OPENSSL_NO_SRP
3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614
    case SSL_CTRL_SET_SRP_VERIFY_PARAM_CB:
        ctx->srp_ctx.srp_Mask |= SSL_kSRP;
        ctx->srp_ctx.SRP_verify_param_callback = (int (*)(SSL *, void *))fp;
        break;
    case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB:
        ctx->srp_ctx.srp_Mask |= SSL_kSRP;
        ctx->srp_ctx.TLS_ext_srp_username_callback =
            (int (*)(SSL *, int *, void *))fp;
        break;
    case SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB:
        ctx->srp_ctx.srp_Mask |= SSL_kSRP;
        ctx->srp_ctx.SRP_give_srp_client_pwd_callback =
            (char *(*)(SSL *, void *))fp;
        break;
3615
#endif
3616 3617 3618 3619 3620 3621 3622 3623 3624 3625
    case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
        {
            ctx->not_resumable_session_cb = (int (*)(SSL *, int))fp;
        }
        break;
    default:
        return (0);
    }
    return (1);
}
3626

3627 3628 3629
const SSL_CIPHER *ssl3_get_cipher_by_id(uint32_t id)
{
    SSL_CIPHER c;
3630
    const SSL_CIPHER *cp;
3631 3632

    c.id = id;
3633 3634 3635 3636
    cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
    if (cp != NULL)
        return cp;
    return OBJ_bsearch_ssl_cipher_id(&c, ssl3_scsvs, SSL3_NUM_SCSVS);
3637 3638
}

3639 3640 3641 3642
/*
 * This function needs to check if the ciphers required are actually
 * available
 */
3643
const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
3644
{
3645
    return ssl3_get_cipher_by_id(SSL3_CK_CIPHERSUITE_FLAG
3646 3647
                                 | ((uint32_t)p[0] << 8L)
                                 | (uint32_t)p[1]);
3648
}
3649

M
Matt Caswell 已提交
3650
int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt, size_t *len)
3651
{
3652
    if ((c->id & 0xff000000) != SSL3_CK_CIPHERSUITE_FLAG) {
3653 3654 3655 3656
        *len = 0;
        return 1;
    }

3657
    if (!WPACKET_put_bytes_u16(pkt, c->id & 0xffff))
3658 3659 3660 3661 3662 3663
        return 0;

    *len = 2;
    return 1;
}

3664 3665 3666 3667 3668 3669 3670 3671
/*
 * ssl3_choose_cipher - choose a cipher from those offered by the client
 * @s: SSL connection
 * @clnt: ciphers offered by the client
 * @srvr: ciphers enabled on the server?
 *
 * Returns the selected cipher or NULL when no common ciphers.
 */
3672
const SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
E
Emilia Kasper 已提交
3673
                                     STACK_OF(SSL_CIPHER) *srvr)
3674
{
3675
    const SSL_CIPHER *c, *ret = NULL;
3676 3677
    STACK_OF(SSL_CIPHER) *prio, *allow;
    int i, ii, ok;
R
Richard Levitte 已提交
3678
    unsigned long alg_k = 0, alg_a = 0, mask_k, mask_a;
3679

3680
    /* Let's see which ciphers we can support */
3681

3682 3683 3684 3685 3686 3687
    /*
     * Do not set the compare functions, because this may lead to a
     * reordering by "id". We want to keep the original ordering. We may pay
     * a price in performance during sk_SSL_CIPHER_find(), but would have to
     * pay with the price of sk_SSL_CIPHER_dup().
     */
3688

B
Ben Laurie 已提交
3689
#ifdef CIPHER_DEBUG
3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701
    fprintf(stderr, "Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr),
            (void *)srvr);
    for (i = 0; i < sk_SSL_CIPHER_num(srvr); ++i) {
        c = sk_SSL_CIPHER_value(srvr, i);
        fprintf(stderr, "%p:%s\n", (void *)c, c->name);
    }
    fprintf(stderr, "Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt),
            (void *)clnt);
    for (i = 0; i < sk_SSL_CIPHER_num(clnt); ++i) {
        c = sk_SSL_CIPHER_value(clnt, i);
        fprintf(stderr, "%p:%s\n", (void *)c, c->name);
    }
B
Ben Laurie 已提交
3702 3703
#endif

3704 3705 3706 3707 3708 3709 3710 3711 3712
    if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE || tls1_suiteb(s)) {
        prio = srvr;
        allow = clnt;
    } else {
        prio = clnt;
        allow = srvr;
    }

    tls1_set_cert_validity(s);
3713
    ssl_set_masks(s);
3714 3715 3716 3717

    for (i = 0; i < sk_SSL_CIPHER_num(prio); i++) {
        c = sk_SSL_CIPHER_value(prio, i);

3718 3719
        /* Skip ciphers not supported by the protocol version */
        if (!SSL_IS_DTLS(s) &&
E
Emilia Kasper 已提交
3720
            ((s->version < c->min_tls) || (s->version > c->max_tls)))
3721
            continue;
3722
        if (SSL_IS_DTLS(s) &&
E
Emilia Kasper 已提交
3723 3724
            (DTLS_VERSION_LT(s->version, c->min_dtls) ||
             DTLS_VERSION_GT(s->version, c->max_dtls)))
3725
            continue;
3726 3727 3728 3729 3730 3731 3732
        /*
         * Since TLS 1.3 ciphersuites can be used with any auth or
         * key exchange scheme skip tests.
         */
        if (!SSL_IS_TLS13(s)) {
            mask_k = s->s3->tmp.mask_k;
            mask_a = s->s3->tmp.mask_a;
B
Ben Laurie 已提交
3733
#ifndef OPENSSL_NO_SRP
3734 3735 3736 3737
            if (s->srp_ctx.srp_Mask & SSL_kSRP) {
                mask_k |= SSL_kSRP;
                mask_a |= SSL_aSRP;
            }
B
Ben Laurie 已提交
3738
#endif
3739

3740 3741
            alg_k = c->algorithm_mkey;
            alg_a = c->algorithm_auth;
3742

3743
#ifndef OPENSSL_NO_PSK
3744 3745 3746
            /* with PSK there must be server callback set */
            if ((alg_k & SSL_PSK) && s->psk_server_callback == NULL)
                continue;
3747 3748
#endif                          /* OPENSSL_NO_PSK */

3749
            ok = (alg_k & mask_k) && (alg_a & mask_a);
3750
#ifdef CIPHER_DEBUG
3751 3752
            fprintf(stderr, "%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\n", ok, alg_k,
                    alg_a, mask_k, mask_a, (void *)c, c->name);
3753 3754
#endif

E
Emilia Kasper 已提交
3755
#ifndef OPENSSL_NO_EC
3756 3757 3758 3759 3760 3761
            /*
             * if we are considering an ECC cipher suite that uses an ephemeral
             * EC key check it
             */
            if (alg_k & SSL_kECDHE)
                ok = ok && tls1_check_ec_tmp_key(s, c->id);
E
Emilia Kasper 已提交
3762
#endif                          /* OPENSSL_NO_EC */
3763

3764 3765 3766
            if (!ok)
                continue;
        }
3767 3768 3769 3770
        ii = sk_SSL_CIPHER_find(allow, c);
        if (ii >= 0) {
            /* Check security callback permits this cipher */
            if (!ssl_security(s, SSL_SECOP_CIPHER_SHARED,
3771
                              c->strength_bits, 0, (void *)c))
3772
                continue;
3773
#if !defined(OPENSSL_NO_EC)
3774 3775 3776 3777 3778 3779
            if ((alg_k & SSL_kECDHE) && (alg_a & SSL_aECDSA)
                && s->s3->is_probably_safari) {
                if (!ret)
                    ret = sk_SSL_CIPHER_value(allow, ii);
                continue;
            }
3780
#endif
3781 3782 3783 3784 3785 3786
            ret = sk_SSL_CIPHER_value(allow, ii);
            break;
        }
    }
    return (ret);
}
3787

3788
int ssl3_get_req_cert_type(SSL *s, WPACKET *pkt)
3789
{
3790
    uint32_t alg_k, alg_a = 0;
3791 3792

    /* If we have custom certificate types set, use them */
3793 3794
    if (s->cert->ctype)
        return WPACKET_memcpy(pkt, s->cert->ctype, s->cert->ctype_len);
3795 3796 3797 3798
    /* Get mask of algorithms disabled by signature list */
    ssl_set_sig_mask(&alg_a, s, SSL_SECOP_SIGALG_MASK);

    alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
3799

D
Dr. Stephen Henson 已提交
3800
#ifndef OPENSSL_NO_GOST
3801 3802 3803 3804
    if (s->version >= TLS1_VERSION && (alg_k & SSL_kGOST))
            return WPACKET_put_bytes_u8(pkt, TLS_CT_GOST01_SIGN)
                    && WPACKET_put_bytes_u8(pkt, TLS_CT_GOST12_SIGN)
                    && WPACKET_put_bytes_u8(pkt, TLS_CT_GOST12_512_SIGN);
D
Dr. Stephen Henson 已提交
3805 3806
#endif

D
Dr. Stephen Henson 已提交
3807
    if ((s->version == SSL3_VERSION) && (alg_k & SSL_kDHE)) {
3808
#ifndef OPENSSL_NO_DH
3809
# ifndef OPENSSL_NO_RSA
3810 3811
        if (!WPACKET_put_bytes_u8(pkt, SSL3_CT_RSA_EPHEMERAL_DH))
            return 0;
3812 3813
# endif
# ifndef OPENSSL_NO_DSA
3814 3815
        if (!WPACKET_put_bytes_u8(pkt, SSL3_CT_DSS_EPHEMERAL_DH))
            return 0;
3816 3817
# endif
#endif                          /* !OPENSSL_NO_DH */
B
Ben Laurie 已提交
3818
    }
3819
#ifndef OPENSSL_NO_RSA
3820 3821
    if (!(alg_a & SSL_aRSA) && !WPACKET_put_bytes_u8(pkt, SSL3_CT_RSA_SIGN))
        return 0;
3822
#endif
3823
#ifndef OPENSSL_NO_DSA
3824 3825
    if (!(alg_a & SSL_aDSS) && !WPACKET_put_bytes_u8(pkt, SSL3_CT_DSS_SIGN))
        return 0;
3826
#endif
3827
#ifndef OPENSSL_NO_EC
3828
    /*
D
Dr. Stephen Henson 已提交
3829
     * ECDSA certs can be used with RSA cipher suites too so we don't
3830 3831
     * need to check for SSL_kECDH or SSL_kECDHE
     */
3832 3833 3834 3835
    if (s->version >= TLS1_VERSION
            && !(alg_a & SSL_aECDSA)
            && !WPACKET_put_bytes_u8(pkt, TLS_CT_ECDSA_SIGN))
        return 0;
3836
#endif
3837
    return 1;
3838
}
3839

3840
static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p, size_t len)
3841
{
3842 3843 3844 3845
    OPENSSL_free(c->ctype);
    c->ctype = NULL;
    c->ctype_len = 0;
    if (p == NULL || len == 0)
3846 3847 3848
        return 1;
    if (len > 0xff)
        return 0;
3849 3850
    c->ctype = OPENSSL_memdup(p, len);
    if (c->ctype == NULL)
3851
        return 0;
3852
    c->ctype_len = len;
3853 3854
    return 1;
}
3855

U
Ulf Möller 已提交
3856
int ssl3_shutdown(SSL *s)
3857 3858 3859 3860 3861 3862 3863
{
    int ret;

    /*
     * Don't do anything much if we have not done the handshake or we don't
     * want to send messages :-)
     */
M
Matt Caswell 已提交
3864
    if (s->quiet_shutdown || SSL_in_before(s)) {
3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883
        s->shutdown = (SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);
        return (1);
    }

    if (!(s->shutdown & SSL_SENT_SHUTDOWN)) {
        s->shutdown |= SSL_SENT_SHUTDOWN;
        ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY);
        /*
         * our shutdown alert has been sent now, and if it still needs to be
         * written, s->s3->alert_dispatch will be true
         */
        if (s->s3->alert_dispatch)
            return (-1);        /* return WANT_WRITE */
    } else if (s->s3->alert_dispatch) {
        /* resend it if not sent */
        ret = s->method->ssl_dispatch_alert(s);
        if (ret == -1) {
            /*
             * we only get to return -1 here the 2nd/Nth invocation, we must
F
FdaSilvaYY 已提交
3884
             * have already signalled return 0 upon a previous invocation,
3885 3886 3887 3888 3889
             * return WANT_WRITE
             */
            return (ret);
        }
    } else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
3890
        size_t readbytes;
3891 3892 3893
        /*
         * If we are waiting for a close from our peer, we are closed
         */
3894
        s->method->ssl_read_bytes(s, 0, NULL, NULL, 0, 0, &readbytes);
3895
        if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
3896
            return -1;        /* return WANT_READ */
3897 3898 3899 3900 3901 3902 3903 3904 3905
        }
    }

    if ((s->shutdown == (SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN)) &&
        !s->s3->alert_dispatch)
        return (1);
    else
        return (0);
}
3906

M
Matt Caswell 已提交
3907
int ssl3_write(SSL *s, const void *buf, size_t len, size_t *written)
3908 3909 3910
{
    clear_sys_error();
    if (s->s3->renegotiate)
3911
        ssl3_renegotiate_check(s, 0);
3912

M
Matt Caswell 已提交
3913 3914
    return s->method->ssl_write_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len,
                                      written);
3915
}
3916

3917
static int ssl3_read_internal(SSL *s, void *buf, size_t len, int peek,
3918
                              size_t *readbytes)
3919 3920 3921 3922 3923
{
    int ret;

    clear_sys_error();
    if (s->s3->renegotiate)
3924
        ssl3_renegotiate_check(s, 0);
3925 3926
    s->s3->in_read_app_data = 1;
    ret =
3927
        s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, NULL, buf, len,
3928
                                  peek, readbytes);
3929 3930 3931 3932 3933 3934 3935 3936
    if ((ret == -1) && (s->s3->in_read_app_data == 2)) {
        /*
         * ssl3_read_bytes decided to call s->handshake_func, which called
         * ssl3_read_bytes to read handshake data. However, ssl3_read_bytes
         * actually found application data and thinks that application data
         * makes sense here; so disable handshake processing and try to read
         * application data again.
         */
M
Matt Caswell 已提交
3937
        ossl_statem_set_in_handshake(s, 1);
3938
        ret =
3939
            s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, NULL, buf,
3940
                                      len, peek, readbytes);
M
Matt Caswell 已提交
3941
        ossl_statem_set_in_handshake(s, 0);
3942 3943 3944
    } else
        s->s3->in_read_app_data = 0;

3945
    return ret;
3946
}
3947

3948
int ssl3_read(SSL *s, void *buf, size_t len, size_t *readbytes)
3949
{
3950
    return ssl3_read_internal(s, buf, len, 0, readbytes);
3951
}
3952

3953
int ssl3_peek(SSL *s, void *buf, size_t len, size_t *readbytes)
3954
{
3955
    return ssl3_read_internal(s, buf, len, 1, readbytes);
3956
}
3957

U
Ulf Möller 已提交
3958
int ssl3_renegotiate(SSL *s)
3959 3960 3961
{
    if (s->handshake_func == NULL)
        return (1);
3962

3963 3964 3965
    s->s3->renegotiate = 1;
    return (1);
}
3966

3967 3968 3969 3970 3971 3972 3973 3974 3975
/*
 * Check if we are waiting to do a renegotiation and if so whether now is a
 * good time to do it. If |initok| is true then we are being called from inside
 * the state machine so ignore the result of SSL_in_init(s). Otherwise we
 * should not do a renegotiation if SSL_in_init(s) is true. Returns 1 if we
 * should do a renegotiation now and sets up the state machine for it. Otherwise
 * returns 0.
 */
int ssl3_renegotiate_check(SSL *s, int initok)
3976 3977 3978 3979
{
    int ret = 0;

    if (s->s3->renegotiate) {
3980 3981
        if (!RECORD_LAYER_read_pending(&s->rlayer)
            && !RECORD_LAYER_write_pending(&s->rlayer)
3982
            && (initok || !SSL_in_init(s))) {
3983 3984
            /*
             * if we are the server, and we have sent a 'RENEGOTIATE'
M
Matt Caswell 已提交
3985 3986
             * message, we need to set the state machine into the renegotiate
             * state.
3987
             */
M
Matt Caswell 已提交
3988
            ossl_statem_set_renegotiate(s);
3989 3990 3991 3992 3993 3994
            s->s3->renegotiate = 0;
            s->s3->num_renegotiations++;
            s->s3->total_renegotiations++;
            ret = 1;
        }
    }
3995
    return ret;
3996 3997
}

3998
/*
3999 4000
 * If we are using default SHA1+MD5 algorithms switch to new SHA256 PRF and
 * handshake macs if required.
D
Dr. Stephen Henson 已提交
4001 4002
 *
 * If PSK and using SHA384 for TLS < 1.2 switch to default.
4003 4004
 */
long ssl_get_algorithm2(SSL *s)
4005
{
4006 4007 4008 4009
    long alg2;
    if (s->s3 == NULL || s->s3->tmp.new_cipher == NULL)
        return -1;
    alg2 = s->s3->tmp.new_cipher->algorithm2;
D
Dr. Stephen Henson 已提交
4010 4011 4012 4013 4014 4015 4016
    if (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SHA256_PRF) {
        if (alg2 == (SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF))
            return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256;
    } else if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_PSK) {
        if (alg2 == (SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384))
            return SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF;
    }
4017 4018
    return alg2;
}
4019 4020 4021 4022 4023

/*
 * Fill a ClientRandom or ServerRandom field of length len. Returns <= 0 on
 * failure, 1 on success.
 */
4024 4025
int ssl_fill_hello_random(SSL *s, int server, unsigned char *result, size_t len,
                          DOWNGRADE dgrd)
4026
{
4027
    int send_time = 0, ret;
4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038

    if (len < 4)
        return 0;
    if (server)
        send_time = (s->mode & SSL_MODE_SEND_SERVERHELLO_TIME) != 0;
    else
        send_time = (s->mode & SSL_MODE_SEND_CLIENTHELLO_TIME) != 0;
    if (send_time) {
        unsigned long Time = (unsigned long)time(NULL);
        unsigned char *p = result;
        l2n(Time, p);
4039
        /* TODO(size_t): Convert this */
4040 4041 4042 4043 4044 4045
        ret = RAND_bytes(p, (int)(len - 4));
    } else {
        ret = RAND_bytes(result, (int)len);
    }
#ifndef OPENSSL_NO_TLS13DOWNGRADE
    if (ret) {
4046 4047 4048
        if (!ossl_assert(sizeof(tls11downgrade) < len)
                || !ossl_assert(sizeof(tls12downgrade) < len))
             return 0;
4049 4050 4051 4052 4053 4054 4055 4056 4057
        if (dgrd == DOWNGRADE_TO_1_2)
            memcpy(result + len - sizeof(tls12downgrade), tls12downgrade,
                   sizeof(tls12downgrade));
        else if (dgrd == DOWNGRADE_TO_1_1)
            memcpy(result + len - sizeof(tls11downgrade), tls11downgrade,
                   sizeof(tls11downgrade));
    }
#endif
    return ret;
4058
}
4059 4060 4061 4062

int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen,
                               int free_pms)
{
4063
    unsigned long alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
4064 4065
    int ret = 0;

4066
    if (alg_k & SSL_PSK) {
4067
#ifndef OPENSSL_NO_PSK
4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079
        unsigned char *pskpms, *t;
        size_t psklen = s->s3->tmp.psklen;
        size_t pskpmslen;

        /* create PSK premaster_secret */

        /* For plain PSK "other_secret" is psklen zeroes */
        if (alg_k & SSL_kPSK)
            pmslen = psklen;

        pskpmslen = 4 + pmslen + psklen;
        pskpms = OPENSSL_malloc(pskpmslen);
4080
        if (pskpms == NULL)
4081
            goto err;
4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093
        t = pskpms;
        s2n(pmslen, t);
        if (alg_k & SSL_kPSK)
            memset(t, 0, pmslen);
        else
            memcpy(t, pms, pmslen);
        t += pmslen;
        s2n(psklen, t);
        memcpy(t, s->s3->tmp.psk, psklen);

        OPENSSL_clear_free(s->s3->tmp.psk, psklen);
        s->s3->tmp.psk = NULL;
4094 4095 4096 4097
        if (!s->method->ssl3_enc->generate_master_secret(s,
                    s->session->master_key,pskpms, pskpmslen,
                    &s->session->master_key_length))
            goto err;
4098
        OPENSSL_clear_free(pskpms, pskpmslen);
4099 4100 4101
#else
        /* Should never happen */
        goto err;
4102
#endif
4103
    } else {
4104 4105 4106 4107
        if (!s->method->ssl3_enc->generate_master_secret(s,
                s->session->master_key, pms, pmslen,
                &s->session->master_key_length))
            goto err;
4108 4109
    }

4110
    ret = 1;
4111
 err:
4112 4113 4114 4115 4116 4117
    if (pms) {
        if (free_pms)
            OPENSSL_clear_free(pms, pmslen);
        else
            OPENSSL_cleanse(pms, pmslen);
    }
4118 4119
    if (s->server == 0)
        s->s3->tmp.pms = NULL;
4120
    return ret;
4121
}
4122

D
Dr. Stephen Henson 已提交
4123 4124
/* Generate a private key from parameters */
EVP_PKEY *ssl_generate_pkey(EVP_PKEY *pm)
4125 4126 4127
{
    EVP_PKEY_CTX *pctx = NULL;
    EVP_PKEY *pkey = NULL;
D
Dr. Stephen Henson 已提交
4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157

    if (pm == NULL)
        return NULL;
    pctx = EVP_PKEY_CTX_new(pm, NULL);
    if (pctx == NULL)
        goto err;
    if (EVP_PKEY_keygen_init(pctx) <= 0)
        goto err;
    if (EVP_PKEY_keygen(pctx, &pkey) <= 0) {
        EVP_PKEY_free(pkey);
        pkey = NULL;
    }

    err:
    EVP_PKEY_CTX_free(pctx);
    return pkey;
}
#ifndef OPENSSL_NO_EC
/* Generate a private key a curve ID */
EVP_PKEY *ssl_generate_pkey_curve(int id)
{
    EVP_PKEY_CTX *pctx = NULL;
    EVP_PKEY *pkey = NULL;
    unsigned int curve_flags;
    int nid = tls1_ec_curve_id2nid(id, &curve_flags);

    if (nid == 0)
        goto err;
    if ((curve_flags & TLS_CURVE_TYPE) == TLS_CURVE_CUSTOM) {
        pctx = EVP_PKEY_CTX_new_id(nid, NULL);
4158
        nid = 0;
4159
    } else {
D
Dr. Stephen Henson 已提交
4160
        pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL);
4161 4162 4163 4164 4165
    }
    if (pctx == NULL)
        goto err;
    if (EVP_PKEY_keygen_init(pctx) <= 0)
        goto err;
4166
    if (nid != 0 && EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, nid) <= 0)
4167 4168 4169 4170 4171 4172
        goto err;
    if (EVP_PKEY_keygen(pctx, &pkey) <= 0) {
        EVP_PKEY_free(pkey);
        pkey = NULL;
    }

E
Emilia Kasper 已提交
4173
 err:
4174 4175 4176
    EVP_PKEY_CTX_free(pctx);
    return pkey;
}
D
Dr. Stephen Henson 已提交
4177
#endif
E
Emilia Kasper 已提交
4178

4179 4180
/* Derive secrets for ECDH/DH */
int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey, int gensecret)
4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204
{
    int rv = 0;
    unsigned char *pms = NULL;
    size_t pmslen = 0;
    EVP_PKEY_CTX *pctx;

    if (privkey == NULL || pubkey == NULL)
        return 0;

    pctx = EVP_PKEY_CTX_new(privkey, NULL);

    if (EVP_PKEY_derive_init(pctx) <= 0
        || EVP_PKEY_derive_set_peer(pctx, pubkey) <= 0
        || EVP_PKEY_derive(pctx, NULL, &pmslen) <= 0) {
        goto err;
    }

    pms = OPENSSL_malloc(pmslen);
    if (pms == NULL)
        goto err;

    if (EVP_PKEY_derive(pctx, pms, &pmslen) <= 0)
        goto err;

4205 4206 4207
    if (gensecret) {
        if (SSL_IS_TLS13(s)) {
            /*
4208 4209
             * If we are resuming then we already generated the early secret
             * when we created the ClientHello, so don't recreate it.
4210
             */
4211 4212 4213 4214
            if (!s->hit)
                rv = tls13_generate_secret(s, ssl_handshake_md(s), NULL, NULL,
                                           0,
                                           (unsigned char *)&s->early_secret);
4215 4216 4217
            else
                rv = 1;

4218
            rv = rv && tls13_generate_handshake_secret(s, pms, pmslen);
4219
        } else {
4220
            rv = ssl_generate_master_secret(s, pms, pmslen, 0);
4221
        }
4222
    } else {
4223
        /* Save premaster secret */
4224 4225 4226 4227 4228 4229
        s->s3->tmp.pms = pms;
        s->s3->tmp.pmslen = pmslen;
        pms = NULL;
        rv = 1;
    }

E
Emilia Kasper 已提交
4230
 err:
4231 4232 4233 4234
    OPENSSL_clear_free(pms, pmslen);
    EVP_PKEY_CTX_free(pctx);
    return rv;
}
D
Dr. Stephen Henson 已提交
4235

B
Ben Laurie 已提交
4236
#ifndef OPENSSL_NO_DH
D
Dr. Stephen Henson 已提交
4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248
EVP_PKEY *ssl_dh_to_pkey(DH *dh)
{
    EVP_PKEY *ret;
    if (dh == NULL)
        return NULL;
    ret = EVP_PKEY_new();
    if (EVP_PKEY_set1_DH(ret, dh) <= 0) {
        EVP_PKEY_free(ret);
        return NULL;
    }
    return ret;
}
B
Ben Laurie 已提交
4249
#endif