diff options
| -rw-r--r-- | src/lib/libssl/ssl.h | 12 | ||||
| -rw-r--r-- | src/lib/libssl/ssl_both.c | 9 | ||||
| -rw-r--r-- | src/lib/libssl/ssl_local.h | 6 | ||||
| -rw-r--r-- | src/lib/libssl/ssl_pkt.c | 40 | ||||
| -rw-r--r-- | src/lib/libssl/t1_enc.c | 21 |
5 files changed, 8 insertions, 80 deletions
diff --git a/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h index 48cb6256df..4ad73af722 100644 --- a/src/lib/libssl/ssl.h +++ b/src/lib/libssl/ssl.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl.h,v 1.249 2025/10/24 11:36:08 tb Exp $ */ | 1 | /* $OpenBSD: ssl.h,v 1.250 2026/04/03 13:11:00 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -369,15 +369,6 @@ typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len, | |||
| 369 | /* Allow initial connection to servers that don't support RI */ | 369 | /* Allow initial connection to servers that don't support RI */ |
| 370 | #define SSL_OP_LEGACY_SERVER_CONNECT 0x00000004L | 370 | #define SSL_OP_LEGACY_SERVER_CONNECT 0x00000004L |
| 371 | 371 | ||
| 372 | /* Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added | ||
| 373 | * in OpenSSL 0.9.6d. Usually (depending on the application protocol) | ||
| 374 | * the workaround is not needed. | ||
| 375 | * Unfortunately some broken SSL/TLS implementations cannot handle it | ||
| 376 | * at all, which is why it was previously included in SSL_OP_ALL. | ||
| 377 | * Now it's not. | ||
| 378 | */ | ||
| 379 | #define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800L | ||
| 380 | |||
| 381 | /* DTLS options */ | 372 | /* DTLS options */ |
| 382 | #define SSL_OP_NO_QUERY_MTU 0x00001000L | 373 | #define SSL_OP_NO_QUERY_MTU 0x00001000L |
| 383 | /* Turn on Cookie Exchange (on relevant for servers) */ | 374 | /* Turn on Cookie Exchange (on relevant for servers) */ |
| @@ -439,6 +430,7 @@ typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len, | |||
| 439 | #define SSL_OP_TLS_BLOCK_PADDING_BUG 0x0 | 430 | #define SSL_OP_TLS_BLOCK_PADDING_BUG 0x0 |
| 440 | #define SSL_OP_TLS_D5_BUG 0x0 | 431 | #define SSL_OP_TLS_D5_BUG 0x0 |
| 441 | #define SSL_OP_TLS_ROLLBACK_BUG 0x0 | 432 | #define SSL_OP_TLS_ROLLBACK_BUG 0x0 |
| 433 | #define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x0 | ||
| 442 | 434 | ||
| 443 | /* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success | 435 | /* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success |
| 444 | * when just a single record has been written): */ | 436 | * when just a single record has been written): */ |
diff --git a/src/lib/libssl/ssl_both.c b/src/lib/libssl/ssl_both.c index 5a704233c9..90f497553b 100644 --- a/src/lib/libssl/ssl_both.c +++ b/src/lib/libssl/ssl_both.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_both.c,v 1.48 2026/04/03 07:17:36 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_both.c,v 1.49 2026/04/03 13:11:00 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -513,7 +513,6 @@ ssl3_setup_read_buffer(SSL *s) | |||
| 513 | int | 513 | int |
| 514 | ssl3_setup_write_buffer(SSL *s) | 514 | ssl3_setup_write_buffer(SSL *s) |
| 515 | { | 515 | { |
| 516 | unsigned char *p; | ||
| 517 | size_t len, align, headerlen; | 516 | size_t len, align, headerlen; |
| 518 | 517 | ||
| 519 | if (SSL_is_dtls(s)) | 518 | if (SSL_is_dtls(s)) |
| @@ -526,13 +525,9 @@ ssl3_setup_write_buffer(SSL *s) | |||
| 526 | if (s->s3->wbuf.buf == NULL) { | 525 | if (s->s3->wbuf.buf == NULL) { |
| 527 | len = s->max_send_fragment + | 526 | len = s->max_send_fragment + |
| 528 | SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD + headerlen + align; | 527 | SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD + headerlen + align; |
| 529 | if (!(s->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)) | ||
| 530 | len += headerlen + align + | ||
| 531 | SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD; | ||
| 532 | 528 | ||
| 533 | if ((p = calloc(1, len)) == NULL) | 529 | if ((s->s3->wbuf.buf = calloc(1, len)) == NULL) |
| 534 | goto err; | 530 | goto err; |
| 535 | s->s3->wbuf.buf = p; | ||
| 536 | s->s3->wbuf.len = len; | 531 | s->s3->wbuf.len = len; |
| 537 | } | 532 | } |
| 538 | 533 | ||
diff --git a/src/lib/libssl/ssl_local.h b/src/lib/libssl/ssl_local.h index 45e57ead9e..6484c8dea3 100644 --- a/src/lib/libssl/ssl_local.h +++ b/src/lib/libssl/ssl_local.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_local.h,v 1.36 2026/04/03 07:17:36 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_local.h,v 1.37 2026/04/03 13:11:00 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -1099,10 +1099,6 @@ typedef struct ssl3_state_st { | |||
| 1099 | int alert_dispatch; | 1099 | int alert_dispatch; |
| 1100 | unsigned char send_alert[2]; | 1100 | unsigned char send_alert[2]; |
| 1101 | 1101 | ||
| 1102 | /* flags for countermeasure against known-IV weakness */ | ||
| 1103 | int need_empty_fragments; | ||
| 1104 | int empty_fragment_done; | ||
| 1105 | |||
| 1106 | /* Unprocessed Alert/Handshake protocol data. */ | 1102 | /* Unprocessed Alert/Handshake protocol data. */ |
| 1107 | struct tls_buffer *alert_fragment; | 1103 | struct tls_buffer *alert_fragment; |
| 1108 | struct tls_buffer *handshake_fragment; | 1104 | struct tls_buffer *handshake_fragment; |
diff --git a/src/lib/libssl/ssl_pkt.c b/src/lib/libssl/ssl_pkt.c index 683dc94a37..6440ef210f 100644 --- a/src/lib/libssl/ssl_pkt.c +++ b/src/lib/libssl/ssl_pkt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_pkt.c,v 1.71 2026/04/03 07:26:20 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_pkt.c,v 1.72 2026/04/03 13:11:00 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -506,16 +506,8 @@ ssl3_write_bytes(SSL *s, int type, const void *buf_, int len) | |||
| 506 | } | 506 | } |
| 507 | 507 | ||
| 508 | if ((i == (int)n) || (type == SSL3_RT_APPLICATION_DATA && | 508 | if ((i == (int)n) || (type == SSL3_RT_APPLICATION_DATA && |
| 509 | (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) { | 509 | (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) |
| 510 | /* | ||
| 511 | * Next chunk of data should get another prepended | ||
| 512 | * empty fragment in ciphersuites with known-IV | ||
| 513 | * weakness. | ||
| 514 | */ | ||
| 515 | s->s3->empty_fragment_done = 0; | ||
| 516 | |||
| 517 | return tot + i; | 510 | return tot + i; |
| 518 | } | ||
| 519 | 511 | ||
| 520 | n -= i; | 512 | n -= i; |
| 521 | tot += i; | 513 | tot += i; |
| @@ -526,8 +518,6 @@ static int | |||
| 526 | do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | 518 | do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) |
| 527 | { | 519 | { |
| 528 | SSL3_BUFFER_INTERNAL *wb = &(s->s3->wbuf); | 520 | SSL3_BUFFER_INTERNAL *wb = &(s->s3->wbuf); |
| 529 | SSL_SESSION *sess = s->session; | ||
| 530 | int need_empty_fragment = 0; | ||
| 531 | size_t align, out_len; | 521 | size_t align, out_len; |
| 532 | CBB cbb; | 522 | CBB cbb; |
| 533 | int ret; | 523 | int ret; |
| @@ -560,26 +550,7 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | |||
| 560 | if (len == 0) | 550 | if (len == 0) |
| 561 | return 0; | 551 | return 0; |
| 562 | 552 | ||
| 563 | /* | ||
| 564 | * Countermeasure against known-IV weakness in CBC ciphersuites | ||
| 565 | * (see http://www.openssl.org/~bodo/tls-cbc.txt). Note that this | ||
| 566 | * is unnecessary for AEAD. | ||
| 567 | */ | ||
| 568 | if (sess != NULL && tls12_record_layer_write_protected(s->rl)) { | ||
| 569 | if (s->s3->need_empty_fragments && | ||
| 570 | !s->s3->empty_fragment_done && | ||
| 571 | type == SSL3_RT_APPLICATION_DATA) | ||
| 572 | need_empty_fragment = 1; | ||
| 573 | } | ||
| 574 | |||
| 575 | /* | ||
| 576 | * An extra fragment would be a couple of cipher blocks, which would | ||
| 577 | * be a multiple of SSL3_ALIGN_PAYLOAD, so if we want to align the real | ||
| 578 | * payload, then we can just simply pretend we have two headers. | ||
| 579 | */ | ||
| 580 | align = (size_t)wb->buf + SSL3_RT_HEADER_LENGTH; | 553 | align = (size_t)wb->buf + SSL3_RT_HEADER_LENGTH; |
| 581 | if (need_empty_fragment) | ||
| 582 | align += SSL3_RT_HEADER_LENGTH; | ||
| 583 | align = (-align) & (SSL3_ALIGN_PAYLOAD - 1); | 554 | align = (-align) & (SSL3_ALIGN_PAYLOAD - 1); |
| 584 | wb->offset = align; | 555 | wb->offset = align; |
| 585 | 556 | ||
| @@ -588,13 +559,6 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | |||
| 588 | 559 | ||
| 589 | tls12_record_layer_set_version(s->rl, s->version); | 560 | tls12_record_layer_set_version(s->rl, s->version); |
| 590 | 561 | ||
| 591 | if (need_empty_fragment) { | ||
| 592 | if (!tls12_record_layer_seal_record(s->rl, type, | ||
| 593 | buf, 0, &cbb)) | ||
| 594 | goto err; | ||
| 595 | s->s3->empty_fragment_done = 1; | ||
| 596 | } | ||
| 597 | |||
| 598 | if (!tls12_record_layer_seal_record(s->rl, type, buf, len, &cbb)) | 562 | if (!tls12_record_layer_seal_record(s->rl, type, buf, len, &cbb)) |
| 599 | goto err; | 563 | goto err; |
| 600 | 564 | ||
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c index 64e1dd5b63..1a93b0d37e 100644 --- a/src/lib/libssl/t1_enc.c +++ b/src/lib/libssl/t1_enc.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: t1_enc.c,v 1.158 2024/07/20 04:04:23 jsing Exp $ */ | 1 | /* $OpenBSD: t1_enc.c,v 1.159 2026/04/03 13:11:00 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -389,25 +389,6 @@ tls1_setup_key_block(SSL *s) | |||
| 389 | s->s3->hs.tls12.key_block = key_block; | 389 | s->s3->hs.tls12.key_block = key_block; |
| 390 | key_block = NULL; | 390 | key_block = NULL; |
| 391 | 391 | ||
| 392 | if (!(s->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) && | ||
| 393 | s->method->version <= TLS1_VERSION) { | ||
| 394 | /* | ||
| 395 | * Enable vulnerability countermeasure for CBC ciphers with | ||
| 396 | * known-IV problem (http://www.openssl.org/~bodo/tls-cbc.txt) | ||
| 397 | */ | ||
| 398 | s->s3->need_empty_fragments = 1; | ||
| 399 | |||
| 400 | if (s->s3->hs.cipher != NULL) { | ||
| 401 | if (s->s3->hs.cipher->algorithm_enc == SSL_eNULL) | ||
| 402 | s->s3->need_empty_fragments = 0; | ||
| 403 | |||
| 404 | #ifndef OPENSSL_NO_RC4 | ||
| 405 | if (s->s3->hs.cipher->algorithm_enc == SSL_RC4) | ||
| 406 | s->s3->need_empty_fragments = 0; | ||
| 407 | #endif | ||
| 408 | } | ||
| 409 | } | ||
| 410 | |||
| 411 | ret = 1; | 392 | ret = 1; |
| 412 | 393 | ||
| 413 | err: | 394 | err: |
