s3_lib.c 102.7 KB
Newer Older
R
Rich Salz 已提交
1 2
/*
 * Copyright 1995-2016 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

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

R
Rich Salz 已提交
853
#ifndef OPENSSL_NO_EC
854 855
    {
     1,
R
Rich Salz 已提交
856 857 858 859
     TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA,
     TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA,
     SSL_kECDHE,
     SSL_aECDSA,
860
     SSL_eNULL,
R
Rich Salz 已提交
861 862
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
863
     DTLS1_BAD_VER, DTLS1_2_VERSION,
864
     SSL_STRONG_NONE | SSL_FIPS,
865 866 867 868
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
869
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
870 871
    {
     1,
R
Rich Salz 已提交
872 873 874 875 876 877 878
     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,
     SSL3_VERSION, TLS1_2_VERSION,
879
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
880
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
R
Rich Salz 已提交
881 882 883
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
884
     },
885
# endif
886 887
    {
     1,
R
Rich Salz 已提交
888 889 890 891
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
     SSL_kECDHE,
     SSL_aECDSA,
892
     SSL_AES128,
R
Rich Salz 已提交
893 894
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
895
     DTLS1_BAD_VER, DTLS1_2_VERSION,
896
     SSL_HIGH | SSL_FIPS,
897 898 899 900 901 902
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
903 904 905 906
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
     SSL_kECDHE,
     SSL_aECDSA,
907
     SSL_AES256,
R
Rich Salz 已提交
908 909
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
910
     DTLS1_BAD_VER, DTLS1_2_VERSION,
911
     SSL_HIGH | SSL_FIPS,
R
Rich Salz 已提交
912
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
913 914 915 916 917
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
918 919 920 921
     TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA,
     TLS1_CK_ECDHE_RSA_WITH_NULL_SHA,
     SSL_kECDHE,
     SSL_aRSA,
922
     SSL_eNULL,
R
Rich Salz 已提交
923 924
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
925
     DTLS1_BAD_VER, DTLS1_2_VERSION,
926
     SSL_STRONG_NONE | SSL_FIPS,
927 928 929 930
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
931
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
932 933
    {
     1,
R
Rich Salz 已提交
934 935 936 937 938 939 940
     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,
     SSL3_VERSION, TLS1_2_VERSION,
941
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
942
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
R
Rich Salz 已提交
943 944 945
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
946
     },
947
# endif
948 949
    {
     1,
R
Rich Salz 已提交
950 951 952
     TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA,
     TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA,
     SSL_kECDHE,
953 954
     SSL_aRSA,
     SSL_AES128,
R
Rich Salz 已提交
955 956
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
957
     DTLS1_BAD_VER, DTLS1_2_VERSION,
958
     SSL_HIGH | SSL_FIPS,
959 960 961 962 963 964
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
965 966 967
     TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA,
     TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA,
     SSL_kECDHE,
968 969
     SSL_aRSA,
     SSL_AES256,
R
Rich Salz 已提交
970 971
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
972
     DTLS1_BAD_VER, DTLS1_2_VERSION,
973
     SSL_HIGH | SSL_FIPS,
R
Rich Salz 已提交
974
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
975 976 977 978 979
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
980 981 982 983
     TLS1_TXT_ECDH_anon_WITH_NULL_SHA,
     TLS1_CK_ECDH_anon_WITH_NULL_SHA,
     SSL_kECDHE,
     SSL_aNULL,
984
     SSL_eNULL,
R
Rich Salz 已提交
985 986
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
987
     DTLS1_BAD_VER, DTLS1_2_VERSION,
988
     SSL_STRONG_NONE | SSL_FIPS,
989 990 991 992
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
993
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
994 995
    {
     1,
R
Rich Salz 已提交
996 997 998 999 1000 1001 1002
     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,
     SSL3_VERSION, TLS1_2_VERSION,
1003
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1004
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
R
Rich Salz 已提交
1005 1006 1007
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
1008
     },
1009
# endif
1010 1011
    {
     1,
R
Rich Salz 已提交
1012 1013 1014 1015 1016 1017 1018
     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,
     SSL3_VERSION, TLS1_2_VERSION,
1019
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1020 1021 1022 1023 1024
     SSL_NOT_DEFAULT | SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
1025 1026
    {
     1,
R
Rich Salz 已提交
1027 1028 1029 1030 1031 1032 1033
     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,
     SSL3_VERSION, TLS1_2_VERSION,
1034
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046
     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,
1047
     SSL_SHA256,
1048 1049
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1050
     SSL_HIGH | SSL_FIPS,
1051 1052 1053 1054 1055 1056
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1057 1058 1059 1060 1061 1062
     TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384,
     TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384,
     SSL_kECDHE,
     SSL_aECDSA,
     SSL_AES256,
     SSL_SHA384,
1063 1064
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1065 1066 1067 1068
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
     256,
1069 1070 1071
     },
    {
     1,
R
Rich Salz 已提交
1072 1073 1074 1075 1076
     TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256,
     TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256,
     SSL_kECDHE,
     SSL_aRSA,
     SSL_AES128,
1077
     SSL_SHA256,
1078 1079
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1080
     SSL_HIGH | SSL_FIPS,
1081 1082 1083 1084 1085 1086
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1087 1088 1089
     TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384,
     TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384,
     SSL_kECDHE,
1090
     SSL_aRSA,
R
Rich Salz 已提交
1091 1092
     SSL_AES256,
     SSL_SHA384,
1093 1094
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1095 1096
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1097 1098 1099 1100 1101
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1102 1103 1104 1105 1106 1107
     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,
1108 1109
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1110
     SSL_HIGH | SSL_FIPS,
1111
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
R
Rich Salz 已提交
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
     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,
1127 1128 1129 1130 1131
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1132 1133 1134
     TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
     TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
     SSL_kECDHE,
1135
     SSL_aRSA,
R
Rich Salz 已提交
1136 1137
     SSL_AES128GCM,
     SSL_AEAD,
1138 1139
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1140
     SSL_HIGH | SSL_FIPS,
1141
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
R
Rich Salz 已提交
1142 1143
     128,
     128,
1144 1145 1146
     },
    {
     1,
R
Rich Salz 已提交
1147 1148 1149 1150 1151 1152
     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,
1153 1154
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
R
Rich Salz 已提交
1155 1156
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1157 1158 1159
     256,
     256,
     },
E
Emilia Kasper 已提交
1160
#endif                          /* OPENSSL_NO_EC */
1161

R
Rich Salz 已提交
1162
#ifndef OPENSSL_NO_PSK
1163 1164
    {
     1,
R
Rich Salz 已提交
1165 1166 1167 1168
     TLS1_TXT_PSK_WITH_NULL_SHA,
     TLS1_CK_PSK_WITH_NULL_SHA,
     SSL_kPSK,
     SSL_aPSK,
1169 1170
     SSL_eNULL,
     SSL_SHA1,
1171
     SSL3_VERSION, TLS1_2_VERSION,
1172
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1173
     SSL_STRONG_NONE | SSL_FIPS,
1174 1175 1176 1177 1178 1179
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
    {
     1,
R
Rich Salz 已提交
1180 1181 1182 1183 1184
     TLS1_TXT_DHE_PSK_WITH_NULL_SHA,
     TLS1_CK_DHE_PSK_WITH_NULL_SHA,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_eNULL,
1185
     SSL_SHA1,
1186
     SSL3_VERSION, TLS1_2_VERSION,
1187
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1188
     SSL_STRONG_NONE | SSL_FIPS,
1189
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
R
Rich Salz 已提交
1190 1191
     0,
     0,
1192 1193 1194
     },
    {
     1,
R
Rich Salz 已提交
1195 1196 1197 1198 1199 1200 1201
     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,
1202
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1203 1204 1205 1206 1207
     SSL_STRONG_NONE | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
     },
1208
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
R
Rich Salz 已提交
1209 1210 1211 1212 1213 1214
    {
     1,
     TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA,
     TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA,
     SSL_kPSK,
     SSL_aPSK,
1215 1216
     SSL_3DES,
     SSL_SHA1,
1217
     SSL3_VERSION, TLS1_2_VERSION,
1218
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1219
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
1220 1221 1222 1223
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
1224
# endif
1225 1226
    {
     1,
R
Rich Salz 已提交
1227 1228 1229 1230
     TLS1_TXT_PSK_WITH_AES_128_CBC_SHA,
     TLS1_CK_PSK_WITH_AES_128_CBC_SHA,
     SSL_kPSK,
     SSL_aPSK,
1231 1232
     SSL_AES128,
     SSL_SHA1,
1233
     SSL3_VERSION, TLS1_2_VERSION,
1234
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1235
     SSL_HIGH | SSL_FIPS,
1236 1237 1238 1239 1240 1241
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1242 1243 1244 1245
     TLS1_TXT_PSK_WITH_AES_256_CBC_SHA,
     TLS1_CK_PSK_WITH_AES_256_CBC_SHA,
     SSL_kPSK,
     SSL_aPSK,
1246 1247
     SSL_AES256,
     SSL_SHA1,
1248
     SSL3_VERSION, TLS1_2_VERSION,
1249
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1250
     SSL_HIGH | SSL_FIPS,
1251 1252 1253 1254
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
1255
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
1256 1257
    {
     1,
R
Rich Salz 已提交
1258 1259 1260 1261 1262
     TLS1_TXT_DHE_PSK_WITH_3DES_EDE_CBC_SHA,
     TLS1_CK_DHE_PSK_WITH_3DES_EDE_CBC_SHA,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_3DES,
1263
     SSL_SHA1,
1264
     SSL3_VERSION, TLS1_2_VERSION,
1265
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1266
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
1267
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
R
Rich Salz 已提交
1268 1269
     112,
     168,
1270
     },
1271
# endif
1272 1273
    {
     1,
R
Rich Salz 已提交
1274 1275 1276 1277 1278 1279 1280
     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,
1281
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1282
     SSL_HIGH | SSL_FIPS,
1283 1284 1285 1286 1287 1288
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1289 1290 1291 1292 1293 1294 1295
     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,
1296
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1297 1298 1299 1300 1301
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
1302
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
R
Rich Salz 已提交
1303 1304 1305 1306 1307
    {
     1,
     TLS1_TXT_RSA_PSK_WITH_3DES_EDE_CBC_SHA,
     TLS1_CK_RSA_PSK_WITH_3DES_EDE_CBC_SHA,
     SSL_kRSAPSK,
1308 1309 1310
     SSL_aRSA,
     SSL_3DES,
     SSL_SHA1,
1311
     SSL3_VERSION, TLS1_2_VERSION,
1312
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1313
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
1314 1315 1316 1317
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
1318
# endif
1319 1320
    {
     1,
R
Rich Salz 已提交
1321 1322 1323
     TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA,
     TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA,
     SSL_kRSAPSK,
1324 1325 1326
     SSL_aRSA,
     SSL_AES128,
     SSL_SHA1,
1327
     SSL3_VERSION, TLS1_2_VERSION,
1328
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1329
     SSL_HIGH | SSL_FIPS,
1330 1331 1332 1333 1334 1335
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1336 1337 1338
     TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA,
     TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA,
     SSL_kRSAPSK,
1339 1340 1341
     SSL_aRSA,
     SSL_AES256,
     SSL_SHA1,
1342
     SSL3_VERSION, TLS1_2_VERSION,
1343
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1344
     SSL_HIGH | SSL_FIPS,
1345 1346 1347 1348 1349 1350
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360
     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,
1361 1362 1363 1364 1365
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
     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,
1378 1379 1380
     },
    {
     1,
R
Rich Salz 已提交
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390
     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,
1391 1392 1393 1394 1395
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405
     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,
1406 1407 1408 1409 1410
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1411 1412 1413
     TLS1_TXT_RSA_PSK_WITH_AES_128_GCM_SHA256,
     TLS1_CK_RSA_PSK_WITH_AES_128_GCM_SHA256,
     SSL_kRSAPSK,
1414
     SSL_aRSA,
R
Rich Salz 已提交
1415 1416 1417 1418 1419 1420 1421 1422
     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,
1423 1424 1425
     },
    {
     1,
R
Rich Salz 已提交
1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437
     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,
1438 1439 1440
     },
    {
     1,
R
Rich Salz 已提交
1441 1442 1443 1444
     TLS1_TXT_PSK_WITH_AES_128_CBC_SHA256,
     TLS1_CK_PSK_WITH_AES_128_CBC_SHA256,
     SSL_kPSK,
     SSL_aPSK,
1445
     SSL_AES128,
R
Rich Salz 已提交
1446 1447
     SSL_SHA256,
     TLS1_VERSION, TLS1_2_VERSION,
1448
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1449
     SSL_HIGH | SSL_FIPS,
1450 1451 1452 1453 1454 1455
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1456 1457 1458 1459 1460 1461 1462
     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,
1463
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1464 1465 1466 1467
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
     256,
1468 1469 1470
     },
    {
     1,
R
Rich Salz 已提交
1471 1472 1473 1474 1475 1476 1477
     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,
1478
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1479
     SSL_STRONG_NONE | SSL_FIPS,
1480
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
R
Rich Salz 已提交
1481 1482
     0,
     0,
1483 1484 1485
     },
    {
     1,
R
Rich Salz 已提交
1486 1487 1488 1489 1490 1491 1492
     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,
1493
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1494 1495 1496 1497
     SSL_STRONG_NONE | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     0,
     0,
1498 1499 1500
     },
    {
     1,
R
Rich Salz 已提交
1501 1502 1503 1504 1505 1506 1507
     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,
1508
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1509
     SSL_HIGH | SSL_FIPS,
1510
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
R
Rich Salz 已提交
1511 1512
     128,
     128,
1513 1514 1515
     },
    {
     1,
R
Rich Salz 已提交
1516 1517 1518 1519
     TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA384,
     TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA384,
     SSL_kDHEPSK,
     SSL_aPSK,
1520
     SSL_AES256,
R
Rich Salz 已提交
1521 1522
     SSL_SHA384,
     TLS1_VERSION, TLS1_2_VERSION,
1523
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1524 1525
     SSL_HIGH | SSL_FIPS,
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1526 1527 1528 1529 1530
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1531 1532 1533 1534 1535
     TLS1_TXT_DHE_PSK_WITH_NULL_SHA256,
     TLS1_CK_DHE_PSK_WITH_NULL_SHA256,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_eNULL,
1536
     SSL_SHA256,
R
Rich Salz 已提交
1537
     TLS1_VERSION, TLS1_2_VERSION,
1538
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1539 1540 1541 1542
     SSL_STRONG_NONE | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
1543 1544 1545
     },
    {
     1,
R
Rich Salz 已提交
1546 1547 1548 1549 1550
     TLS1_TXT_DHE_PSK_WITH_NULL_SHA384,
     TLS1_CK_DHE_PSK_WITH_NULL_SHA384,
     SSL_kDHEPSK,
     SSL_aPSK,
     SSL_eNULL,
1551
     SSL_SHA384,
R
Rich Salz 已提交
1552
     TLS1_VERSION, TLS1_2_VERSION,
1553
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1554
     SSL_STRONG_NONE | SSL_FIPS,
1555
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
R
Rich Salz 已提交
1556 1557
     0,
     0,
1558 1559 1560
     },
    {
     1,
R
Rich Salz 已提交
1561 1562 1563
     TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA256,
     TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA256,
     SSL_kRSAPSK,
1564 1565 1566
     SSL_aRSA,
     SSL_AES128,
     SSL_SHA256,
R
Rich Salz 已提交
1567
     TLS1_VERSION, TLS1_2_VERSION,
1568
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1569
     SSL_HIGH | SSL_FIPS,
R
Rich Salz 已提交
1570
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1571 1572 1573 1574 1575
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
1576 1577 1578
     TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA384,
     TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA384,
     SSL_kRSAPSK,
1579 1580 1581
     SSL_aRSA,
     SSL_AES256,
     SSL_SHA384,
R
Rich Salz 已提交
1582
     TLS1_VERSION, TLS1_2_VERSION,
1583
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1584
     SSL_HIGH | SSL_FIPS,
1585 1586 1587 1588 1589 1590
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
     256,
     },
    {
     1,
R
Rich Salz 已提交
1591 1592 1593
     TLS1_TXT_RSA_PSK_WITH_NULL_SHA256,
     TLS1_CK_RSA_PSK_WITH_NULL_SHA256,
     SSL_kRSAPSK,
1594
     SSL_aRSA,
R
Rich Salz 已提交
1595 1596 1597
     SSL_eNULL,
     SSL_SHA256,
     TLS1_VERSION, TLS1_2_VERSION,
1598
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1599 1600 1601 1602
     SSL_STRONG_NONE | SSL_FIPS,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     0,
     0,
1603 1604 1605
     },
    {
     1,
R
Rich Salz 已提交
1606 1607 1608
     TLS1_TXT_RSA_PSK_WITH_NULL_SHA384,
     TLS1_CK_RSA_PSK_WITH_NULL_SHA384,
     SSL_kRSAPSK,
1609
     SSL_aRSA,
R
Rich Salz 已提交
1610 1611 1612
     SSL_eNULL,
     SSL_SHA384,
     TLS1_VERSION, TLS1_2_VERSION,
1613
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1614
     SSL_STRONG_NONE | SSL_FIPS,
1615
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
R
Rich Salz 已提交
1616 1617
     0,
     0,
1618
     },
R
Rich Salz 已提交
1619
# ifndef OPENSSL_NO_EC
1620
#  ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
1621 1622 1623 1624 1625 1626 1627 1628
    {
     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,
1629
     SSL3_VERSION, TLS1_2_VERSION,
1630
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1631
     SSL_NOT_DEFAULT | SSL_MEDIUM | SSL_FIPS,
1632 1633 1634 1635
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
1636
#  endif
1637 1638 1639 1640 1641 1642 1643 1644
    {
     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,
1645
     SSL3_VERSION, TLS1_2_VERSION,
1646
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1647
     SSL_HIGH | SSL_FIPS,
1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659
     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,
1660
     SSL3_VERSION, TLS1_2_VERSION,
1661
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1662
     SSL_HIGH | SSL_FIPS,
1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674
     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,
1675
     TLS1_VERSION, TLS1_2_VERSION,
1676
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1677
     SSL_HIGH | SSL_FIPS,
1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689
     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,
1690
     TLS1_VERSION, TLS1_2_VERSION,
1691
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1692
     SSL_HIGH | SSL_FIPS,
1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704
     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,
1705
     SSL3_VERSION, TLS1_2_VERSION,
1706
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1707
     SSL_STRONG_NONE | SSL_FIPS,
1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719
     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,
1720
     TLS1_VERSION, TLS1_2_VERSION,
1721
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1722
     SSL_STRONG_NONE | SSL_FIPS,
1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734
     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,
1735
     TLS1_VERSION, TLS1_2_VERSION,
1736
     DTLS1_BAD_VER, DTLS1_2_VERSION,
1737
     SSL_STRONG_NONE | SSL_FIPS,
1738 1739 1740 1741
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     0,
     0,
     },
E
Emilia Kasper 已提交
1742 1743
# endif                         /* OPENSSL_NO_EC */
#endif                          /* OPENSSL_NO_PSK */
1744

R
Rich Salz 已提交
1745
#ifndef OPENSSL_NO_SRP
1746
# ifndef OPENSSL_NO_WEAK_SSL_CIPHERS
R
Rich Salz 已提交
1747 1748 1749 1750 1751 1752 1753 1754 1755
    {
     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,
1756
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1757
     SSL_NOT_DEFAULT | SSL_MEDIUM,
R
Rich Salz 已提交
1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770
     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,
1771
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1772
     SSL_NOT_DEFAULT | SSL_MEDIUM,
R
Rich Salz 已提交
1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785
     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,
1786
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1787
     SSL_NOT_DEFAULT | SSL_MEDIUM,
R
Rich Salz 已提交
1788 1789 1790 1791
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     112,
     168,
     },
1792
# endif
R
Rich Salz 已提交
1793 1794 1795 1796 1797 1798 1799 1800 1801
    {
     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,
1802
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816
     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,
1817
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831
     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,
1832
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846
     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,
1847
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861
     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,
1862
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876
     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,
1877
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
1878 1879 1880 1881 1882
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     256,
     256,
     },
E
Emilia Kasper 已提交
1883
#endif                          /* OPENSSL_NO_SRP */
R
Rich Salz 已提交
1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901

#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 已提交
1902
# endif                         /* OPENSSL_NO_RSA */
R
Rich Salz 已提交
1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934

# 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 已提交
1935
# endif                         /* OPENSSL_NO_EC */
R
Rich Salz 已提交
1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997

# 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 已提交
1998 1999 2000
# endif                         /* OPENSSL_NO_PSK */
#endif                          /* !defined(OPENSSL_NO_CHACHA) &&
                                 * !defined(OPENSSL_NO_POLY1305) */
R
Rich Salz 已提交
2001 2002 2003 2004 2005 2006 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 2069 2070 2071 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

#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,
2132
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146
     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,
2147
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161
     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,
2162
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176
     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,
2177
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191
     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,
2192
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206
     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,
2207
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221
     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,
2222
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236
     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,
2237
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2238 2239 2240 2241 2242 2243 2244 2245
     SSL_NOT_DEFAULT | SSL_HIGH,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
     },

# ifndef OPENSSL_NO_EC
    {
2246 2247 2248 2249 2250 2251 2252
     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,
2253 2254
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2255
     SSL_NOT_DEFAULT | SSL_HIGH,
2256 2257
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
E
Emilia Kasper 已提交
2258 2259
     128,
     },
R
Rich Salz 已提交
2260
    {
2261 2262 2263 2264 2265 2266 2267
     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,
2268 2269
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2270
     SSL_NOT_DEFAULT | SSL_HIGH,
2271 2272
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
E
Emilia Kasper 已提交
2273 2274
     256,
     },
R
Rich Salz 已提交
2275
    {
2276 2277 2278 2279 2280 2281 2282
     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,
2283 2284
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2285
     SSL_NOT_DEFAULT | SSL_HIGH,
2286 2287
     SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
     128,
E
Emilia Kasper 已提交
2288 2289
     128,
     },
R
Rich Salz 已提交
2290
    {
2291 2292 2293 2294 2295 2296 2297
     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,
2298 2299
     TLS1_2_VERSION, TLS1_2_VERSION,
     DTLS1_2_VERSION, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2300
     SSL_NOT_DEFAULT | SSL_HIGH,
2301 2302
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
E
Emilia Kasper 已提交
2303 2304 2305
     256,
     },
# endif                         /* OPENSSL_NO_EC */
B
Ben Laurie 已提交
2306

R
Rich Salz 已提交
2307 2308
# ifndef OPENSSL_NO_PSK
    {
2309 2310 2311 2312 2313 2314 2315
     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,
2316
     TLS1_VERSION, TLS1_2_VERSION,
2317
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2318
     SSL_NOT_DEFAULT | SSL_HIGH,
2319 2320
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
E
Emilia Kasper 已提交
2321 2322
     128,
     },
R
Rich Salz 已提交
2323
    {
2324 2325 2326 2327 2328 2329 2330
     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,
2331
     TLS1_VERSION, TLS1_2_VERSION,
2332
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2333
     SSL_NOT_DEFAULT | SSL_HIGH,
2334 2335
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
E
Emilia Kasper 已提交
2336 2337
     256,
     },
R
Rich Salz 已提交
2338
    {
2339 2340 2341 2342 2343 2344 2345
     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,
2346
     TLS1_VERSION, TLS1_2_VERSION,
2347
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2348
     SSL_NOT_DEFAULT | SSL_HIGH,
2349 2350
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
E
Emilia Kasper 已提交
2351 2352
     128,
     },
R
Rich Salz 已提交
2353
    {
2354 2355 2356 2357 2358 2359 2360
     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,
2361
     TLS1_VERSION, TLS1_2_VERSION,
2362
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2363
     SSL_NOT_DEFAULT | SSL_HIGH,
2364 2365
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
E
Emilia Kasper 已提交
2366 2367
     256,
     },
R
Rich Salz 已提交
2368
    {
2369 2370 2371 2372 2373 2374 2375
     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,
2376
     TLS1_VERSION, TLS1_2_VERSION,
2377
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2378
     SSL_NOT_DEFAULT | SSL_HIGH,
2379 2380
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
E
Emilia Kasper 已提交
2381 2382
     128,
     },
R
Rich Salz 已提交
2383
    {
2384 2385 2386 2387 2388 2389 2390
     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,
2391
     TLS1_VERSION, TLS1_2_VERSION,
2392
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2393
     SSL_NOT_DEFAULT | SSL_HIGH,
2394 2395
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
     256,
E
Emilia Kasper 已提交
2396 2397
     256,
     },
2398 2399
    {
     1,
R
Rich Salz 已提交
2400 2401 2402
     TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256,
     TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256,
     SSL_kECDHEPSK,
2403
     SSL_aPSK,
R
Rich Salz 已提交
2404 2405 2406
     SSL_CAMELLIA128,
     SSL_SHA256,
     TLS1_VERSION, TLS1_2_VERSION,
2407
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2408
     SSL_NOT_DEFAULT | SSL_HIGH,
R
Rich Salz 已提交
2409
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2410
     128,
E
Emilia Kasper 已提交
2411 2412
     128,
     },
2413 2414
    {
     1,
R
Rich Salz 已提交
2415 2416 2417
     TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384,
     TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384,
     SSL_kECDHEPSK,
2418
     SSL_aPSK,
R
Rich Salz 已提交
2419 2420 2421
     SSL_CAMELLIA256,
     SSL_SHA384,
     TLS1_VERSION, TLS1_2_VERSION,
2422
     DTLS1_BAD_VER, DTLS1_2_VERSION,
E
Emilia Kasper 已提交
2423
     SSL_NOT_DEFAULT | SSL_HIGH,
R
Rich Salz 已提交
2424
     SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2425
     256,
E
Emilia Kasper 已提交
2426 2427 2428
     256,
     },
# endif                         /* OPENSSL_NO_PSK */
2429

E
Emilia Kasper 已提交
2430
#endif                          /* OPENSSL_NO_CAMELLIA */
2431

P
Pauli 已提交
2432
#ifndef OPENSSL_NO_GOST
2433 2434
    {
     1,
R
Rich Salz 已提交
2435 2436 2437 2438 2439 2440 2441
     "GOST2001-GOST89-GOST89",
     0x3000081,
     SSL_kGOST,
     SSL_aGOST01,
     SSL_eGOST2814789CNT,
     SSL_GOST89MAC,
     TLS1_VERSION, TLS1_2_VERSION,
2442
     0, 0,
R
Rich Salz 已提交
2443 2444
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94 | TLS1_STREAM_MAC,
2445
     256,
E
Emilia Kasper 已提交
2446 2447
     256,
     },
R
Rich Salz 已提交
2448 2449 2450 2451 2452 2453 2454 2455 2456
    {
     1,
     "GOST2001-NULL-GOST94",
     0x3000083,
     SSL_kGOST,
     SSL_aGOST01,
     SSL_eNULL,
     SSL_GOST94,
     TLS1_VERSION, TLS1_2_VERSION,
2457
     0, 0,
R
Rich Salz 已提交
2458 2459 2460
     SSL_STRONG_NONE,
     SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94,
     0,
E
Emilia Kasper 已提交
2461 2462
     0,
     },
R
Rich Salz 已提交
2463 2464 2465 2466 2467 2468 2469 2470 2471
    {
     1,
     "GOST2012-GOST8912-GOST8912",
     0x0300ff85,
     SSL_kGOST,
     SSL_aGOST12 | SSL_aGOST01,
     SSL_eGOST2814789CNT12,
     SSL_GOST89MAC12,
     TLS1_VERSION, TLS1_2_VERSION,
2472
     0, 0,
R
Rich Salz 已提交
2473 2474
     SSL_HIGH,
     SSL_HANDSHAKE_MAC_GOST12_256 | TLS1_PRF_GOST12_256 | TLS1_STREAM_MAC,
2475
     256,
E
Emilia Kasper 已提交
2476 2477
     256,
     },
R
Rich Salz 已提交
2478 2479 2480 2481 2482 2483 2484 2485 2486
    {
     1,
     "GOST2012-NULL-GOST12",
     0x0300ff87,
     SSL_kGOST,
     SSL_aGOST12 | SSL_aGOST01,
     SSL_eNULL,
     SSL_GOST12_256,
     TLS1_VERSION, TLS1_2_VERSION,
2487
     0, 0,
R
Rich Salz 已提交
2488 2489 2490
     SSL_STRONG_NONE,
     SSL_HANDSHAKE_MAC_GOST12_256 | TLS1_PRF_GOST12_256 | TLS1_STREAM_MAC,
     0,
E
Emilia Kasper 已提交
2491 2492 2493
     0,
     },
#endif                          /* OPENSSL_NO_GOST */
2494

R
Rich Salz 已提交
2495
#ifndef OPENSSL_NO_IDEA
2496 2497
    {
     1,
R
Rich Salz 已提交
2498 2499 2500 2501 2502 2503 2504
     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,
2505
     DTLS1_BAD_VER, DTLS1_VERSION,
R
Rich Salz 已提交
2506 2507
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2508 2509 2510
     128,
     128,
     },
R
Rich Salz 已提交
2511
#endif
2512

R
Rich Salz 已提交
2513
#ifndef OPENSSL_NO_SEED
2514 2515
    {
     1,
R
Rich Salz 已提交
2516 2517 2518 2519 2520 2521 2522
     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,
2523
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2524 2525 2526 2527
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
2528 2529 2530
     },
    {
     1,
R
Rich Salz 已提交
2531 2532 2533 2534 2535 2536 2537
     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,
2538
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2539 2540
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2541 2542 2543 2544 2545
     128,
     128,
     },
    {
     1,
R
Rich Salz 已提交
2546 2547 2548 2549 2550 2551 2552
     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,
2553
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2554 2555 2556 2557
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
2558 2559 2560
     },
    {
     1,
R
Rich Salz 已提交
2561 2562 2563 2564 2565 2566 2567
     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,
2568
     DTLS1_BAD_VER, DTLS1_2_VERSION,
R
Rich Salz 已提交
2569 2570
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2571 2572 2573
     128,
     128,
     },
E
Emilia Kasper 已提交
2574
#endif                          /* OPENSSL_NO_SEED */
2575

R
Rich Salz 已提交
2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591
#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,
     },
2592 2593
    {
     1,
R
Rich Salz 已提交
2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605
     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,
2606 2607 2608
     },
    {
     1,
R
Rich Salz 已提交
2609 2610 2611 2612 2613 2614 2615 2616 2617 2618
     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,
2619 2620 2621 2622
     128,
     128,
     },

R
Rich Salz 已提交
2623
# ifndef OPENSSL_NO_EC
2624 2625
    {
     1,
R
Rich Salz 已提交
2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637
     TLS1_TXT_ECDHE_PSK_WITH_RC4_128_SHA,
     TLS1_CK_ECDHE_PSK_WITH_RC4_128_SHA,
     SSL_kECDHEPSK,
     SSL_aPSK,
     SSL_RC4,
     SSL_SHA1,
     SSL3_VERSION, TLS1_2_VERSION,
     0, 0,
     SSL_NOT_DEFAULT | SSL_MEDIUM,
     SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
     128,
     128,
2638
     },
A
Andy Polyakov 已提交
2639 2640
    {
     1,
R
Rich Salz 已提交
2641 2642
     TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA,
     TLS1_CK_ECDH_anon_WITH_RC4_128_SHA,
A
Andy Polyakov 已提交
2643
     SSL_kECDHE,
R
Rich Salz 已提交
2644 2645 2646 2647 2648 2649 2650 2651 2652
     SSL_aNULL,
     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 已提交
2653 2654 2655
     },
    {
     1,
R
Rich Salz 已提交
2656 2657
     TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA,
     TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA,
A
Andy Polyakov 已提交
2658 2659
     SSL_kECDHE,
     SSL_aECDSA,
R
Rich Salz 已提交
2660 2661 2662 2663 2664 2665 2666 2667
     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 已提交
2668 2669 2670
     },
    {
     1,
R
Rich Salz 已提交
2671 2672 2673
     TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA,
     TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA,
     SSL_kECDHE,
A
Andy Polyakov 已提交
2674
     SSL_aRSA,
R
Rich Salz 已提交
2675 2676 2677 2678 2679 2680 2681 2682
     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 已提交
2683
     },
E
Emilia Kasper 已提交
2684
# endif                         /* OPENSSL_NO_EC */
R
Rich Salz 已提交
2685

A
Andy Polyakov 已提交
2686 2687 2688
# ifndef OPENSSL_NO_PSK
    {
     1,
R
Rich Salz 已提交
2689 2690
     TLS1_TXT_PSK_WITH_RC4_128_SHA,
     TLS1_CK_PSK_WITH_RC4_128_SHA,
A
Andy Polyakov 已提交
2691 2692
     SSL_kPSK,
     SSL_aPSK,
R
Rich Salz 已提交
2693 2694 2695 2696 2697 2698 2699 2700
     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 已提交
2701 2702 2703
     },
    {
     1,
R
Rich Salz 已提交
2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715
     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 已提交
2716 2717 2718
     },
    {
     1,
R
Rich Salz 已提交
2719 2720
     TLS1_TXT_DHE_PSK_WITH_RC4_128_SHA,
     TLS1_CK_DHE_PSK_WITH_RC4_128_SHA,
A
Andy Polyakov 已提交
2721 2722
     SSL_kDHEPSK,
     SSL_aPSK,
R
Rich Salz 已提交
2723 2724 2725 2726 2727 2728 2729 2730
     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 已提交
2731
     },
E
Emilia Kasper 已提交
2732
# endif                         /* OPENSSL_NO_PSK */
R
Rich Salz 已提交
2733

E
Emilia Kasper 已提交
2734
#endif                          /* OPENSSL_NO_WEAK_SSL_CIPHERS */
2735

2736 2737
};

R
Rich Salz 已提交
2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751
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)
{
    qsort(ssl3_ciphers, OSSL_NELEM(ssl3_ciphers), sizeof ssl3_ciphers[0],
          cipher_compare);
}

2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765
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 已提交
2766
    ssl3_set_handshake_header,
2767
    tls_close_construct_packet,
2768 2769
    ssl3_handshake_write
};
2770

2771
long ssl3_default_timeout(void)
2772 2773 2774 2775 2776 2777 2778
{
    /*
     * 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);
}
2779

U
Ulf Möller 已提交
2780
int ssl3_num_ciphers(void)
2781 2782 2783
{
    return (SSL3_NUM_CIPHERS);
}
2784

2785
const SSL_CIPHER *ssl3_get_cipher(unsigned int u)
2786 2787 2788 2789 2790 2791
{
    if (u < SSL3_NUM_CIPHERS)
        return (&(ssl3_ciphers[SSL3_NUM_CIPHERS - 1 - u]));
    else
        return (NULL);
}
2792

M
Matt Caswell 已提交
2793
int ssl3_set_handshake_header(SSL *s, WPACKET *pkt, int htype)
2794
{
2795 2796 2797 2798
    /* No header in the event of a CCS */
    if (htype == SSL3_MT_CHANGE_CIPHER_SPEC)
        return 1;

2799
    /* Set the content type and 3 bytes for the message len */
2800
    if (!WPACKET_put_bytes_u8(pkt, htype)
M
Matt Caswell 已提交
2801
            || !WPACKET_start_sub_packet_u24(pkt))
2802 2803 2804 2805 2806
        return 0;

    return 1;
}

D
Dr. Stephen Henson 已提交
2807
int ssl3_handshake_write(SSL *s)
2808 2809 2810
{
    return ssl3_do_write(s, SSL3_RT_HANDSHAKE);
}
D
Dr. Stephen Henson 已提交
2811

U
Ulf Möller 已提交
2812
int ssl3_new(SSL *s)
2813 2814
{
    SSL3_STATE *s3;
2815

R
Rich Salz 已提交
2816
    if ((s3 = OPENSSL_zalloc(sizeof(*s3))) == NULL)
2817 2818
        goto err;
    s->s3 = s3;
B
Ben Laurie 已提交
2819

B
Ben Laurie 已提交
2820
#ifndef OPENSSL_NO_SRP
V
Viktor Dukhovni 已提交
2821
    if (!SSL_SRP_CTX_init(s))
E
Emilia Kasper 已提交
2822
        goto err;
B
Ben Laurie 已提交
2823
#endif
2824 2825 2826 2827 2828
    s->method->ssl_clear(s);
    return (1);
 err:
    return (0);
}
2829

U
Ulf Möller 已提交
2830
void ssl3_free(SSL *s)
2831
{
2832
    if (s == NULL || s->s3 == NULL)
2833
        return;
B
Ben Laurie 已提交
2834

2835
    ssl3_cleanup_key_block(s);
2836

D
Dr. Stephen Henson 已提交
2837
#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
2838 2839
    EVP_PKEY_free(s->s3->peer_tmp);
    s->s3->peer_tmp = NULL;
D
Dr. Stephen Henson 已提交
2840 2841
    EVP_PKEY_free(s->s3->tmp.pkey);
    s->s3->tmp.pkey = NULL;
B
Bodo Möller 已提交
2842 2843
#endif

R
Rich Salz 已提交
2844
    sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);
D
Dr. Stephen Henson 已提交
2845 2846 2847
    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);
2848
    ssl3_free_digest_list(s);
R
Rich Salz 已提交
2849
    OPENSSL_free(s->s3->alpn_selected);
T
Todd Short 已提交
2850
    OPENSSL_free(s->s3->alpn_proposed);
A
Adam Langley 已提交
2851

B
Ben Laurie 已提交
2852
#ifndef OPENSSL_NO_SRP
2853
    SSL_SRP_CTX_free(s);
B
Ben Laurie 已提交
2854
#endif
R
Rich Salz 已提交
2855
    OPENSSL_clear_free(s->s3, sizeof(*s->s3));
2856 2857
    s->s3 = NULL;
}
2858

U
Ulf Möller 已提交
2859
void ssl3_clear(SSL *s)
2860 2861
{
    ssl3_cleanup_key_block(s);
R
Rich Salz 已提交
2862
    sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);
D
Dr. Stephen Henson 已提交
2863 2864 2865
    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);
2866

D
Dr. Stephen Henson 已提交
2867
#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
D
Dr. Stephen Henson 已提交
2868
    EVP_PKEY_free(s->s3->tmp.pkey);
2869
    EVP_PKEY_free(s->s3->peer_tmp);
E
Emilia Kasper 已提交
2870
#endif                          /* !OPENSSL_NO_EC */
2871

2872
    ssl3_free_digest_list(s);
2873

T
Todd Short 已提交
2874 2875
    OPENSSL_free(s->s3->alpn_selected);
    OPENSSL_free(s->s3->alpn_proposed);
2876

T
Todd Short 已提交
2877
    /* NULL/zero-out everything in the s3 struct */
R
Rich Salz 已提交
2878
    memset(s->s3, 0, sizeof(*s->s3));
2879 2880 2881 2882

    ssl_free_wbio_buffer(s);

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

2884
#if !defined(OPENSSL_NO_NEXTPROTONEG)
R
Rich Salz 已提交
2885 2886 2887
    OPENSSL_free(s->ext.npn);
    s->ext.npn = NULL;
    s->ext.npn_len = 0;
B
Ben Laurie 已提交
2888
#endif
2889
}
2890

B
Ben Laurie 已提交
2891
#ifndef OPENSSL_NO_SRP
2892 2893
static char *srp_password_from_info_cb(SSL *s, void *arg)
{
R
Rich Salz 已提交
2894
    return OPENSSL_strdup(s->srp_ctx.info);
2895
}
B
Ben Laurie 已提交
2896 2897
#endif

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

2900
long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
2901 2902
{
    int ret = 0;
2903

2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919
    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;
2920
#ifndef OPENSSL_NO_DH
2921 2922 2923
    case SSL_CTRL_SET_TMP_DH:
        {
            DH *dh = (DH *)parg;
2924
            EVP_PKEY *pkdh = NULL;
2925 2926 2927 2928
            if (dh == NULL) {
                SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
                return (ret);
            }
2929 2930 2931 2932 2933
            pkdh = ssl_dh_to_pkey(dh);
            if (pkdh == NULL) {
                SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
                return 0;
            }
2934
            if (!ssl_security(s, SSL_SECOP_TMP_DH,
2935
                              EVP_PKEY_security_bits(pkdh), 0, pkdh)) {
2936
                SSLerr(SSL_F_SSL3_CTRL, SSL_R_DH_KEY_TOO_SMALL);
2937 2938
                EVP_PKEY_free(pkdh);
                return ret;
2939
            }
2940 2941
            EVP_PKEY_free(s->cert->dh_tmp);
            s->cert->dh_tmp = pkdh;
2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952
            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;
2953
#endif
2954
#ifndef OPENSSL_NO_EC
2955 2956
    case SSL_CTRL_SET_TMP_ECDH:
        {
2957 2958
            const EC_GROUP *group = NULL;
            int nid;
2959 2960 2961

            if (parg == NULL) {
                SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
2962
                return 0;
2963
            }
2964 2965 2966 2967
            group = EC_KEY_get0_group((const EC_KEY *)parg);
            if (group == NULL) {
                SSLerr(SSL_F_SSL3_CTRL, EC_R_MISSING_PARAMETERS);
                return 0;
2968
            }
2969 2970 2971
            nid = EC_GROUP_get_curve_name(group);
            if (nid == NID_undef)
                return 0;
R
Rich Salz 已提交
2972 2973
            return tls1_set_groups(&s->ext.supportedgroups,
                                   &s->ext.supportedgroups_len,
2974
                                   &nid, 1);
2975 2976
        }
        break;
2977
#endif                          /* !OPENSSL_NO_EC */
2978 2979
    case SSL_CTRL_SET_TLSEXT_HOSTNAME:
        if (larg == TLSEXT_NAMETYPE_host_name) {
V
Viktor Dukhovni 已提交
2980 2981
            size_t len;

R
Rich Salz 已提交
2982 2983
            OPENSSL_free(s->ext.hostname);
            s->ext.hostname = NULL;
2984 2985 2986 2987

            ret = 1;
            if (parg == NULL)
                break;
V
Viktor Dukhovni 已提交
2988 2989
            len = strlen((char *)parg);
            if (len == 0 || len > TLSEXT_MAXLEN_host_name) {
2990 2991 2992
                SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
                return 0;
            }
R
Rich Salz 已提交
2993
            if ((s->ext.hostname = OPENSSL_strdup((char *)parg)) == NULL) {
2994 2995 2996 2997 2998 2999 3000 3001 3002
                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 已提交
3003
        s->ext.debug_arg = parg;
3004 3005 3006
        ret = 1;
        break;

3007
    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE:
R
Rich Salz 已提交
3008
        ret = s->ext.status_type;
3009 3010
        break;

3011
    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
R
Rich Salz 已提交
3012
        s->ext.status_type = larg;
3013 3014 3015 3016
        ret = 1;
        break;

    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS:
R
Rich Salz 已提交
3017
        *(STACK_OF(X509_EXTENSION) **)parg = s->ext.ocsp.exts;
3018 3019 3020 3021
        ret = 1;
        break;

    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS:
R
Rich Salz 已提交
3022
        s->ext.ocsp.exts = parg;
3023 3024 3025 3026
        ret = 1;
        break;

    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS:
R
Rich Salz 已提交
3027
        *(STACK_OF(OCSP_RESPID) **)parg = s->ext.ocsp.ids;
3028 3029 3030 3031
        ret = 1;
        break;

    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS:
R
Rich Salz 已提交
3032
        s->ext.ocsp.ids = parg;
3033 3034 3035 3036
        ret = 1;
        break;

    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP:
R
Rich Salz 已提交
3037 3038 3039
        *(unsigned char **)parg = s->ext.ocsp.resp;
        if (s->ext.ocsp.resp_len == 0
                || s->ext.ocsp.resp_len > LONG_MAX)
M
Matt Caswell 已提交
3040
            return -1;
R
Rich Salz 已提交
3041
        return (long)s->ext.ocsp.resp_len;
3042 3043

    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP:
R
Rich Salz 已提交
3044 3045 3046
        OPENSSL_free(s->ext.ocsp.resp);
        s->ext.ocsp.resp = parg;
        s->ext.ocsp.resp_len = larg;
3047 3048 3049
        ret = 1;
        break;

3050 3051 3052 3053 3054 3055 3056
#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

3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097
    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) {
            CERT_PKEY *cpk;
            const SSL_CIPHER *cipher;
            if (!s->server)
                return 0;
            cipher = s->s3->tmp.new_cipher;
            if (!cipher)
                return 0;
            /*
             * No certificate for unauthenticated ciphersuites or using SRP
             * authentication
             */
            if (cipher->algorithm_auth & (SSL_aNULL | SSL_aSRP))
                return 2;
            cpk = ssl_get_server_send_pkey(s);
            if (!cpk)
                return 0;
            s->cert->key = cpk;
            return 1;
        }
        return ssl_cert_set_current(s->cert, larg);
3098

3099
#ifndef OPENSSL_NO_EC
3100
    case SSL_CTRL_GET_GROUPS:
3101 3102 3103
        {
            unsigned char *clist;
            size_t clistlen;
R
Rich Salz 已提交
3104

3105 3106
            if (!s->session)
                return 0;
R
Rich Salz 已提交
3107 3108
            clist = s->session->ext.supportedgroups;
            clistlen = s->session->ext.supportedgroups_len / 2;
3109 3110 3111 3112 3113 3114
            if (parg) {
                size_t i;
                int *cptr = parg;
                unsigned int cid, nid;
                for (i = 0; i < clistlen; i++) {
                    n2s(clist, cid);
3115
                    /* TODO(TLS1.3): Handle DH groups here */
3116
                    nid = tls1_ec_curve_id2nid(cid, NULL);
3117 3118 3119 3120 3121 3122 3123 3124 3125
                    if (nid != 0)
                        cptr[i] = nid;
                    else
                        cptr[i] = TLSEXT_nid_unknown | cid;
                }
            }
            return (int)clistlen;
        }

3126
    case SSL_CTRL_SET_GROUPS:
R
Rich Salz 已提交
3127 3128
        return tls1_set_groups(&s->ext.supportedgroups,
                               &s->ext.supportedgroups_len, parg, larg);
3129

3130
    case SSL_CTRL_SET_GROUPS_LIST:
R
Rich Salz 已提交
3131 3132
        return tls1_set_groups_list(&s->ext.supportedgroups,
                                    &s->ext.supportedgroups_len, parg);
3133

3134 3135
    case SSL_CTRL_GET_SHARED_GROUP:
        return tls1_shared_group(s, larg);
3136

3137
#endif
3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180
    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 (s->cert->ctypes) {
                if (pctype)
                    *pctype = s->cert->ctypes;
                return (int)s->cert->ctype_num;
            }
            if (pctype)
                *pctype = (unsigned char *)s->s3->tmp.ctype;
            return s->s3->tmp.ctype_num;
        }

    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:
        if (SSL_USE_SIGALGS(s)) {
D
Dr. Stephen Henson 已提交
3181
            if (s->session) {
3182
                const EVP_MD *sig;
3183
                sig = s->s3->tmp.peer_md;
3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195
                if (sig) {
                    *(int *)parg = EVP_MD_type(sig);
                    return 1;
                }
            }
            return 0;
        }
        /* Might want to do something here for other versions */
        else
            return 0;

    case SSL_CTRL_GET_SERVER_TMP_KEY:
D
Dr. Stephen Henson 已提交
3196 3197
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC)
        if (s->server || s->session == NULL || s->s3->peer_tmp == NULL) {
3198
            return 0;
D
Dr. Stephen Henson 已提交
3199 3200 3201 3202
        } else {
            EVP_PKEY_up_ref(s->s3->peer_tmp);
            *(EVP_PKEY **)parg = s->s3->peer_tmp;
            return 1;
3203
        }
D
Dr. Stephen Henson 已提交
3204 3205 3206
#else
        return 0;
#endif
3207
#ifndef OPENSSL_NO_EC
3208 3209 3210 3211
    case SSL_CTRL_GET_EC_POINT_FORMATS:
        {
            SSL_SESSION *sess = s->session;
            const unsigned char **pformat = parg;
R
Rich Salz 已提交
3212 3213

            if (sess == NULL || sess->ext.ecpointformats == NULL)
3214
                return 0;
R
Rich Salz 已提交
3215 3216
            *pformat = sess->ext.ecpointformats;
            return (int)sess->ext.ecpointformats_len;
3217
        }
3218
#endif
B
Bodo Moeller 已提交
3219

3220 3221 3222 3223 3224 3225 3226 3227 3228
    default:
        break;
    }
    return (ret);
}

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

3230
    switch (cmd) {
3231
#ifndef OPENSSL_NO_DH
3232 3233 3234 3235 3236
    case SSL_CTRL_SET_TMP_DH_CB:
        {
            s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
        }
        break;
3237
#endif
3238
    case SSL_CTRL_SET_TLSEXT_DEBUG_CB:
R
Rich Salz 已提交
3239
        s->ext.debug_cb = (void (*)(SSL *, int, int,
R
Rich Salz 已提交
3240
                                    const unsigned char *, int, void *))fp;
3241
        break;
3242

3243 3244 3245 3246 3247 3248 3249 3250 3251 3252
    case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
        {
            s->not_resumable_session_cb = (int (*)(SSL *, int))fp;
        }
        break;
    default:
        break;
    }
    return (ret);
}
3253

3254
long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
3255 3256
{
    switch (cmd) {
3257
#ifndef OPENSSL_NO_DH
3258 3259
    case SSL_CTRL_SET_TMP_DH:
        {
3260 3261 3262 3263
            DH *dh = (DH *)parg;
            EVP_PKEY *pkdh = NULL;
            if (dh == NULL) {
                SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3264 3265
                return 0;
            }
3266 3267 3268
            pkdh = ssl_dh_to_pkey(dh);
            if (pkdh == NULL) {
                SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_MALLOC_FAILURE);
3269 3270
                return 0;
            }
3271 3272 3273 3274 3275
            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;
3276
            }
3277 3278
            EVP_PKEY_free(ctx->cert->dh_tmp);
            ctx->cert->dh_tmp = pkdh;
3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291
            return 1;
        }
        /*
         * break;
         */
    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;
3292
#endif
3293
#ifndef OPENSSL_NO_EC
3294 3295
    case SSL_CTRL_SET_TMP_ECDH:
        {
3296 3297
            const EC_GROUP *group = NULL;
            int nid;
3298 3299

            if (parg == NULL) {
3300
                SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3301 3302
                return 0;
            }
3303 3304 3305
            group = EC_KEY_get0_group((const EC_KEY *)parg);
            if (group == NULL) {
                SSLerr(SSL_F_SSL3_CTX_CTRL, EC_R_MISSING_PARAMETERS);
3306 3307
                return 0;
            }
3308 3309 3310
            nid = EC_GROUP_get_curve_name(group);
            if (nid == NID_undef)
                return 0;
R
Rich Salz 已提交
3311 3312
            return tls1_set_groups(&ctx->ext.supportedgroups,
                                   &ctx->ext.supportedgroups_len,
3313
                                   &nid, 1);
3314 3315
        }
        /* break; */
3316
#endif                          /* !OPENSSL_NO_EC */
3317
    case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG:
R
Rich Salz 已提交
3318
        ctx->ext.servername_arg = parg;
3319 3320 3321 3322 3323
        break;
    case SSL_CTRL_SET_TLSEXT_TICKET_KEYS:
    case SSL_CTRL_GET_TLSEXT_TICKET_KEYS:
        {
            unsigned char *keys = parg;
R
Rich Salz 已提交
3324 3325 3326
            long tick_keylen = (sizeof(ctx->ext.tick_key_name) +
                                sizeof(ctx->ext.tick_hmac_key) +
                                sizeof(ctx->ext.tick_aes_key));
K
Kurt Roeckx 已提交
3327
            if (keys == NULL)
R
Rich Salz 已提交
3328 3329
                return tick_keylen;
            if (larg != tick_keylen) {
3330 3331 3332 3333
                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 已提交
3334 3335 3336 3337 3338 3339 3340 3341 3342
                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));
3343
            } else {
R
Rich Salz 已提交
3344 3345 3346 3347 3348 3349 3350 3351 3352
                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));
3353 3354 3355 3356
            }
            return 1;
        }

3357
    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE:
R
Rich Salz 已提交
3358
        return ctx->ext.status_type;
3359

3360
    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
R
Rich Salz 已提交
3361
        ctx->ext.status_type = larg;
3362 3363
        break;

3364
    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG:
R
Rich Salz 已提交
3365
        ctx->ext.status_arg = parg;
3366 3367
        return 1;

3368
    case SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG:
R
Rich Salz 已提交
3369
        *(void**)parg = ctx->ext.status_arg;
3370 3371 3372
        break;

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

3376
#ifndef OPENSSL_NO_SRP
3377 3378
    case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME:
        ctx->srp_ctx.srp_Mask |= SSL_kSRP;
R
Rich Salz 已提交
3379
        OPENSSL_free(ctx->srp_ctx.login);
3380 3381 3382
        ctx->srp_ctx.login = NULL;
        if (parg == NULL)
            break;
E
Emilia Kasper 已提交
3383
        if (strlen((const char *)parg) > 255 || strlen((const char *)parg) < 1) {
3384 3385 3386
            SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_SRP_USERNAME);
            return 0;
        }
R
Rich Salz 已提交
3387
        if ((ctx->srp_ctx.login = OPENSSL_strdup((char *)parg)) == NULL) {
3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404
            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;
3405
#endif
3406

3407
#ifndef OPENSSL_NO_EC
3408
    case SSL_CTRL_SET_GROUPS:
R
Rich Salz 已提交
3409 3410
        return tls1_set_groups(&ctx->ext.supportedgroups,
                               &ctx->ext.supportedgroups_len,
3411 3412
                               parg, larg);

3413
    case SSL_CTRL_SET_GROUPS_LIST:
R
Rich Salz 已提交
3414 3415
        return tls1_set_groups_list(&ctx->ext.supportedgroups,
                                    &ctx->ext.supportedgroups_len,
3416
                                    parg);
3417
#endif
3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444
    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) {
3445 3446 3447 3448 3449 3450 3451 3452
            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;
3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463
        }
        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 已提交
3464 3465
        sk_X509_pop_free(ctx->extra_certs, X509_free);
        ctx->extra_certs = NULL;
3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498
        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) {
3499
#ifndef OPENSSL_NO_DH
3500 3501
    case SSL_CTRL_SET_TMP_DH_CB:
        {
M
Matt Caswell 已提交
3502
            ctx->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3503 3504
        }
        break;
3505
#endif
3506
    case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB:
R
Rich Salz 已提交
3507
        ctx->ext.servername_cb = (int (*)(SSL *, int *, void *))fp;
3508 3509 3510
        break;

    case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB:
R
Rich Salz 已提交
3511
        ctx->ext.status_cb = (int (*)(SSL *, void *))fp;
3512 3513 3514
        break;

    case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB:
R
Rich Salz 已提交
3515
        ctx->ext.ticket_key_cb = (int (*)(SSL *, unsigned char *,
3516 3517 3518 3519 3520
                                             unsigned char *,
                                             EVP_CIPHER_CTX *,
                                             HMAC_CTX *, int))fp;
        break;

3521
#ifndef OPENSSL_NO_SRP
3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535
    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;
3536
#endif
3537 3538 3539 3540 3541 3542 3543 3544 3545 3546
    case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
        {
            ctx->not_resumable_session_cb = (int (*)(SSL *, int))fp;
        }
        break;
    default:
        return (0);
    }
    return (1);
}
3547

3548 3549 3550 3551
/*
 * This function needs to check if the ciphers required are actually
 * available
 */
3552
const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
3553 3554 3555
{
    SSL_CIPHER c;
    const SSL_CIPHER *cp;
3556
    uint32_t id;
3557

3558
    id = 0x03000000 | ((uint32_t)p[0] << 8L) | (uint32_t)p[1];
3559 3560 3561 3562
    c.id = id;
    cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
    return cp;
}
3563

M
Matt Caswell 已提交
3564
int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt, size_t *len)
3565 3566 3567 3568 3569 3570
{
    if ((c->id & 0xff000000) != 0x03000000) {
        *len = 0;
        return 1;
    }

3571
    if (!WPACKET_put_bytes_u16(pkt, c->id & 0xffff))
3572 3573 3574 3575 3576 3577
        return 0;

    *len = 2;
    return 1;
}

3578 3579 3580 3581 3582 3583 3584 3585
/*
 * 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.
 */
3586
const SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
E
Emilia Kasper 已提交
3587
                                     STACK_OF(SSL_CIPHER) *srvr)
3588
{
3589
    const SSL_CIPHER *c, *ret = NULL;
3590 3591
    STACK_OF(SSL_CIPHER) *prio, *allow;
    int i, ii, ok;
3592
    unsigned long alg_k, alg_a, mask_k, mask_a;
3593

3594
    /* Let's see which ciphers we can support */
3595

3596
#if 0
3597 3598 3599 3600 3601 3602 3603 3604
    /*
     * 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().
     */
    sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
    sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
3605
#endif
3606

B
Ben Laurie 已提交
3607
#ifdef CIPHER_DEBUG
3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619
    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 已提交
3620 3621
#endif

3622 3623 3624 3625 3626 3627 3628 3629 3630
    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);
3631
    ssl_set_masks(s);
3632 3633 3634 3635

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

3636 3637
        /* Skip ciphers not supported by the protocol version */
        if (!SSL_IS_DTLS(s) &&
E
Emilia Kasper 已提交
3638
            ((s->version < c->min_tls) || (s->version > c->max_tls)))
3639
            continue;
3640
        if (SSL_IS_DTLS(s) &&
E
Emilia Kasper 已提交
3641 3642
            (DTLS_VERSION_LT(s->version, c->min_dtls) ||
             DTLS_VERSION_GT(s->version, c->max_dtls)))
3643
            continue;
3644

3645 3646
        mask_k = s->s3->tmp.mask_k;
        mask_a = s->s3->tmp.mask_a;
B
Ben Laurie 已提交
3647
#ifndef OPENSSL_NO_SRP
3648 3649 3650 3651
        if (s->srp_ctx.srp_Mask & SSL_kSRP) {
            mask_k |= SSL_kSRP;
            mask_a |= SSL_aSRP;
        }
B
Ben Laurie 已提交
3652
#endif
3653 3654 3655

        alg_k = c->algorithm_mkey;
        alg_a = c->algorithm_auth;
3656

3657
#ifndef OPENSSL_NO_PSK
3658
        /* with PSK there must be server callback set */
3659
        if ((alg_k & SSL_PSK) && s->psk_server_callback == NULL)
3660 3661 3662
            continue;
#endif                          /* OPENSSL_NO_PSK */

3663
        ok = (alg_k & mask_k) && (alg_a & mask_a);
3664
#ifdef CIPHER_DEBUG
3665 3666
        fprintf(stderr, "%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\n", ok, alg_k,
                alg_a, mask_k, mask_a, (void *)c, c->name);
3667 3668
#endif

E
Emilia Kasper 已提交
3669
#ifndef OPENSSL_NO_EC
3670 3671 3672 3673 3674 3675
        /*
         * 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 已提交
3676
#endif                          /* OPENSSL_NO_EC */
3677 3678 3679 3680 3681 3682 3683

        if (!ok)
            continue;
        ii = sk_SSL_CIPHER_find(allow, c);
        if (ii >= 0) {
            /* Check security callback permits this cipher */
            if (!ssl_security(s, SSL_SECOP_CIPHER_SHARED,
3684
                              c->strength_bits, 0, (void *)c))
3685
                continue;
3686
#if !defined(OPENSSL_NO_EC)
3687 3688 3689 3690 3691 3692
            if ((alg_k & SSL_kECDHE) && (alg_a & SSL_aECDSA)
                && s->s3->is_probably_safari) {
                if (!ret)
                    ret = sk_SSL_CIPHER_value(allow, ii);
                continue;
            }
3693
#endif
3694 3695 3696 3697 3698 3699
            ret = sk_SSL_CIPHER_value(allow, ii);
            break;
        }
    }
    return (ret);
}
3700

3701
int ssl3_get_req_cert_type(SSL *s, WPACKET *pkt)
3702
{
3703
    uint32_t alg_k, alg_a = 0;
3704 3705 3706

    /* If we have custom certificate types set, use them */
    if (s->cert->ctypes) {
3707
        return WPACKET_memcpy(pkt, s->cert->ctypes, s->cert->ctype_num);
3708 3709 3710 3711 3712
    }
    /* 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;
3713

D
Dr. Stephen Henson 已提交
3714
#ifndef OPENSSL_NO_GOST
3715 3716 3717 3718
    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 已提交
3719 3720
#endif

D
Dr. Stephen Henson 已提交
3721
    if ((s->version == SSL3_VERSION) && (alg_k & SSL_kDHE)) {
3722
#ifndef OPENSSL_NO_DH
3723
# ifndef OPENSSL_NO_RSA
3724 3725
        if (!WPACKET_put_bytes_u8(pkt, SSL3_CT_RSA_EPHEMERAL_DH))
            return 0;
3726 3727
# endif
# ifndef OPENSSL_NO_DSA
3728 3729
        if (!WPACKET_put_bytes_u8(pkt, SSL3_CT_DSS_EPHEMERAL_DH))
            return 0;
3730 3731
# endif
#endif                          /* !OPENSSL_NO_DH */
B
Ben Laurie 已提交
3732
    }
3733
#ifndef OPENSSL_NO_RSA
3734 3735
    if (!(alg_a & SSL_aRSA) && !WPACKET_put_bytes_u8(pkt, SSL3_CT_RSA_SIGN))
        return 0;
3736
#endif
3737
#ifndef OPENSSL_NO_DSA
3738 3739
    if (!(alg_a & SSL_aDSS) && !WPACKET_put_bytes_u8(pkt, SSL3_CT_DSS_SIGN))
        return 0;
3740
#endif
3741
#ifndef OPENSSL_NO_EC
3742
    /*
D
Dr. Stephen Henson 已提交
3743
     * ECDSA certs can be used with RSA cipher suites too so we don't
3744 3745
     * need to check for SSL_kECDH or SSL_kECDHE
     */
3746 3747 3748 3749
    if (s->version >= TLS1_VERSION
            && !(alg_a & SSL_aECDSA)
            && !WPACKET_put_bytes_u8(pkt, TLS_CT_ECDSA_SIGN))
        return 0;
3750
#endif
3751
    return 1;
3752
}
3753

3754
static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p, size_t len)
3755
{
R
Rich Salz 已提交
3756 3757
    OPENSSL_free(c->ctypes);
    c->ctypes = NULL;
3758 3759 3760 3761 3762
    if (!p || !len)
        return 1;
    if (len > 0xff)
        return 0;
    c->ctypes = OPENSSL_malloc(len);
3763
    if (c->ctypes == NULL)
3764 3765 3766 3767 3768
        return 0;
    memcpy(c->ctypes, p, len);
    c->ctype_num = len;
    return 1;
}
3769

U
Ulf Möller 已提交
3770
int ssl3_shutdown(SSL *s)
3771 3772 3773 3774 3775 3776 3777
{
    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 已提交
3778
    if (s->quiet_shutdown || SSL_in_before(s)) {
3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797
        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 已提交
3798
             * have already signalled return 0 upon a previous invocation,
3799 3800 3801 3802 3803
             * return WANT_WRITE
             */
            return (ret);
        }
    } else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
3804
        size_t readbytes;
3805 3806 3807
        /*
         * If we are waiting for a close from our peer, we are closed
         */
3808
        s->method->ssl_read_bytes(s, 0, NULL, NULL, 0, 0, &readbytes);
3809
        if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
3810
            return -1;        /* return WANT_READ */
3811 3812 3813 3814 3815 3816 3817 3818 3819
        }
    }

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

M
Matt Caswell 已提交
3821
int ssl3_write(SSL *s, const void *buf, size_t len, size_t *written)
3822 3823 3824
{
    clear_sys_error();
    if (s->s3->renegotiate)
3825
        ssl3_renegotiate_check(s, 0);
3826

M
Matt Caswell 已提交
3827 3828
    return s->method->ssl_write_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len,
                                      written);
3829
}
3830

3831
static int ssl3_read_internal(SSL *s, void *buf, size_t len, int peek,
3832
                              size_t *readbytes)
3833 3834 3835 3836 3837
{
    int ret;

    clear_sys_error();
    if (s->s3->renegotiate)
3838
        ssl3_renegotiate_check(s, 0);
3839 3840
    s->s3->in_read_app_data = 1;
    ret =
3841
        s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, NULL, buf, len,
3842
                                  peek, readbytes);
3843 3844 3845 3846 3847 3848 3849 3850
    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 已提交
3851
        ossl_statem_set_in_handshake(s, 1);
3852
        ret =
3853
            s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, NULL, buf,
3854
                                      len, peek, readbytes);
M
Matt Caswell 已提交
3855
        ossl_statem_set_in_handshake(s, 0);
3856 3857 3858
    } else
        s->s3->in_read_app_data = 0;

3859
    return ret;
3860
}
3861

3862
int ssl3_read(SSL *s, void *buf, size_t len, size_t *readbytes)
3863
{
3864
    return ssl3_read_internal(s, buf, len, 0, readbytes);
3865
}
3866

3867
int ssl3_peek(SSL *s, void *buf, size_t len, size_t *readbytes)
3868
{
3869
    return ssl3_read_internal(s, buf, len, 1, readbytes);
3870
}
3871

U
Ulf Möller 已提交
3872
int ssl3_renegotiate(SSL *s)
3873 3874 3875
{
    if (s->handshake_func == NULL)
        return (1);
3876

3877 3878 3879
    s->s3->renegotiate = 1;
    return (1);
}
3880

3881 3882 3883 3884 3885 3886 3887 3888 3889
/*
 * 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)
3890 3891 3892 3893
{
    int ret = 0;

    if (s->s3->renegotiate) {
3894 3895
        if (!RECORD_LAYER_read_pending(&s->rlayer)
            && !RECORD_LAYER_write_pending(&s->rlayer)
3896
            && (initok || !SSL_in_init(s))) {
3897 3898
            /*
             * if we are the server, and we have sent a 'RENEGOTIATE'
M
Matt Caswell 已提交
3899 3900
             * message, we need to set the state machine into the renegotiate
             * state.
3901
             */
M
Matt Caswell 已提交
3902
            ossl_statem_set_renegotiate(s);
3903 3904 3905 3906 3907 3908
            s->s3->renegotiate = 0;
            s->s3->num_renegotiations++;
            s->s3->total_renegotiations++;
            ret = 1;
        }
    }
3909
    return ret;
3910 3911
}

3912
/*
3913 3914
 * If we are using default SHA1+MD5 algorithms switch to new SHA256 PRF and
 * handshake macs if required.
D
Dr. Stephen Henson 已提交
3915 3916
 *
 * If PSK and using SHA384 for TLS < 1.2 switch to default.
3917 3918
 */
long ssl_get_algorithm2(SSL *s)
3919
{
3920 3921 3922 3923
    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 已提交
3924 3925 3926 3927 3928 3929 3930
    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;
    }
3931 3932
    return alg2;
}
3933 3934 3935 3936 3937

/*
 * Fill a ClientRandom or ServerRandom field of length len. Returns <= 0 on
 * failure, 1 on success.
 */
3938
int ssl_fill_hello_random(SSL *s, int server, unsigned char *result, size_t len)
3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951
{
    int send_time = 0;

    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);
3952 3953
        /* TODO(size_t): Convert this */
        return RAND_bytes(p, (int)(len - 4));
3954
    } else
3955
        return RAND_bytes(result, (int)len);
3956
}
3957 3958 3959 3960

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

3964
    if (alg_k & SSL_PSK) {
3965
#ifndef OPENSSL_NO_PSK
3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977
        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);
3978
        if (pskpms == NULL)
3979
            goto err;
3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991
        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;
3992 3993 3994 3995
        if (!s->method->ssl3_enc->generate_master_secret(s,
                    s->session->master_key,pskpms, pskpmslen,
                    &s->session->master_key_length))
            goto err;
3996
        OPENSSL_clear_free(pskpms, pskpmslen);
3997 3998 3999
#else
        /* Should never happen */
        goto err;
4000
#endif
4001
    } else {
4002 4003 4004 4005
        if (!s->method->ssl3_enc->generate_master_secret(s,
                s->session->master_key, pms, pmslen,
                &s->session->master_key_length))
            goto err;
4006 4007
    }

4008
    ret = 1;
4009
 err:
4010 4011 4012 4013 4014 4015
    if (pms) {
        if (free_pms)
            OPENSSL_clear_free(pms, pmslen);
        else
            OPENSSL_cleanse(pms, pmslen);
    }
4016 4017
    if (s->server == 0)
        s->s3->tmp.pms = NULL;
4018
    return ret;
4019
}
4020

D
Dr. Stephen Henson 已提交
4021 4022
/* Generate a private key from parameters */
EVP_PKEY *ssl_generate_pkey(EVP_PKEY *pm)
4023 4024 4025
{
    EVP_PKEY_CTX *pctx = NULL;
    EVP_PKEY *pkey = NULL;
D
Dr. Stephen Henson 已提交
4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055

    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);
4056
        nid = 0;
4057
    } else {
D
Dr. Stephen Henson 已提交
4058
        pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL);
4059 4060 4061 4062 4063
    }
    if (pctx == NULL)
        goto err;
    if (EVP_PKEY_keygen_init(pctx) <= 0)
        goto err;
4064
    if (nid != 0 && EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, nid) <= 0)
4065 4066 4067 4068 4069 4070
        goto err;
    if (EVP_PKEY_keygen(pctx, &pkey) <= 0) {
        EVP_PKEY_free(pkey);
        pkey = NULL;
    }

E
Emilia Kasper 已提交
4071
 err:
4072 4073 4074
    EVP_PKEY_CTX_free(pctx);
    return pkey;
}
D
Dr. Stephen Henson 已提交
4075
#endif
E
Emilia Kasper 已提交
4076

4077 4078
/* Derive secrets for ECDH/DH */
int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey, int gensecret)
4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102
{
    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;

4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116
    if (gensecret) {
        if (SSL_IS_TLS13(s)) {
            /*
             * TODO(TLS1.3): For now we just use the default early_secret, this
             * will need to change later when other early_secrets will be
             * possible.
             */
            rv = tls13_generate_early_secret(s, NULL, 0)
                 && tls13_generate_handshake_secret(s, pms, pmslen);
            OPENSSL_free(pms);
        } else {
            /* Generate master secret and discard premaster */
            rv = ssl_generate_master_secret(s, pms, pmslen, 1);
        }
4117 4118
        pms = NULL;
    } else {
4119
        /* Save premaster secret */
4120 4121 4122 4123 4124 4125
        s->s3->tmp.pms = pms;
        s->s3->tmp.pmslen = pmslen;
        pms = NULL;
        rv = 1;
    }

E
Emilia Kasper 已提交
4126
 err:
4127 4128 4129 4130
    OPENSSL_clear_free(pms, pmslen);
    EVP_PKEY_CTX_free(pctx);
    return rv;
}
D
Dr. Stephen Henson 已提交
4131

B
Ben Laurie 已提交
4132
#ifndef OPENSSL_NO_DH
D
Dr. Stephen Henson 已提交
4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144
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 已提交
4145
#endif