git: 9b3d847e589e - 2026Q1 - security/openssl: Security update to 3.0.19
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 31 Jan 2026 10:37:14 UTC
The branch 2026Q1 has been updated by brnrd:
URL: https://cgit.FreeBSD.org/ports/commit/?id=9b3d847e589e0ed02551aba1bbb6cd3f6f5fd648
commit 9b3d847e589e0ed02551aba1bbb6cd3f6f5fd648
Author: Bernard Spil <brnrd@FreeBSD.org>
AuthorDate: 2026-01-27 19:18:42 +0000
Commit: Bernard Spil <brnrd@FreeBSD.org>
CommitDate: 2026-01-31 10:33:30 +0000
security/openssl: Security update to 3.0.19
Security: 4b824428-fb93-11f0-b194-8447094a420f
MFH: 2026Q1
(cherry picked from commit add1f8c51476ee5889147cff9d3fd48cb6b97c62)
---
security/openssl/Makefile | 2 +-
security/openssl/distinfo | 6 +-
security/openssl/files/extra-patch-ktls | 248 ++++++++++-----------
.../files/patch-crypto_async_arch_async__posix.h | 12 +-
security/openssl/files/patch-crypto_ppccap.c | 22 +-
5 files changed, 145 insertions(+), 145 deletions(-)
diff --git a/security/openssl/Makefile b/security/openssl/Makefile
index 4bbd371479e8..b08a0861e9e8 100644
--- a/security/openssl/Makefile
+++ b/security/openssl/Makefile
@@ -1,5 +1,5 @@
PORTNAME= openssl
-PORTVERSION= 3.0.18
+PORTVERSION= 3.0.19
PORTEPOCH= 1
CATEGORIES= security devel
MASTER_SITES= https://github.com/openssl/openssl/releases/download/${DISTNAME}/
diff --git a/security/openssl/distinfo b/security/openssl/distinfo
index b0235a50d86b..35f8ef070c36 100644
--- a/security/openssl/distinfo
+++ b/security/openssl/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1759300749
-SHA256 (openssl-3.0.18.tar.gz) = d80c34f5cf902dccf1f1b5df5ebb86d0392e37049e5d73df1b3abae72e4ffe8b
-SIZE (openssl-3.0.18.tar.gz) = 15348046
+TIMESTAMP = 1769528081
+SHA256 (openssl-3.0.19.tar.gz) = fa5a4143b8aae18be53ef2f3caf29a2e0747430b8bc74d32d88335b94ab63072
+SIZE (openssl-3.0.19.tar.gz) = 15280904
diff --git a/security/openssl/files/extra-patch-ktls b/security/openssl/files/extra-patch-ktls
index 8a46c272d95c..48a5dd43a972 100644
--- a/security/openssl/files/extra-patch-ktls
+++ b/security/openssl/files/extra-patch-ktls
@@ -3,14 +3,14 @@ index 95492fd065..3c82cae26b 100644
--- include/internal/ktls.h
+++ include/internal/ktls.h
@@ -40,6 +40,11 @@
- # define OPENSSL_KTLS_AES_GCM_128
- # define OPENSSL_KTLS_AES_GCM_256
- # define OPENSSL_KTLS_TLS13
-+# ifdef TLS_CHACHA20_IV_LEN
-+# ifndef OPENSSL_NO_CHACHA
-+# define OPENSSL_KTLS_CHACHA20_POLY1305
-+# endif
-+# endif
+ #define OPENSSL_KTLS_AES_GCM_128
+ #define OPENSSL_KTLS_AES_GCM_256
+ #define OPENSSL_KTLS_TLS13
++#ifdef TLS_CHACHA20_IV_LEN
++# ifndef OPENSSL_NO_CHACHA
++# define OPENSSL_KTLS_CHACHA20_POLY1305
++# endif
++#endif
typedef struct tls_enable ktls_crypto_info_t;
@@ -103,11 +103,11 @@ index 79d980959e..e343d382cc 100644
/* Function to configure kernel TLS structure */
-int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
+int ktls_configure_crypto(SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
- void *rl_sequence, ktls_crypto_info_t *crypto_info,
-- unsigned char **rec_seq, unsigned char *iv,
-+ int is_tx, unsigned char *iv,
- unsigned char *key, unsigned char *mac_key,
- size_t mac_secret_size)
+ void *rl_sequence, ktls_crypto_info_t *crypto_info,
+- unsigned char **rec_seq, unsigned char *iv,
++ int is_tx, unsigned char *iv,
+ unsigned char *key, unsigned char *mac_key,
+ size_t mac_secret_size)
{
@@ -71,6 +136,12 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
else
@@ -124,31 +124,31 @@ index 79d980959e..e343d382cc 100644
switch (s->s3.tmp.new_cipher->algorithm_mac) {
@@ -101,11 +172,11 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
crypto_info->tls_vminor = (s->version & 0x000000ff);
- # ifdef TCP_RXTLS_ENABLE
+ #ifdef TCP_RXTLS_ENABLE
memcpy(crypto_info->rec_seq, rl_sequence, sizeof(crypto_info->rec_seq));
- if (rec_seq != NULL)
- *rec_seq = crypto_info->rec_seq;
+ if (!is_tx && !check_rx_read_ahead(s, crypto_info->rec_seq))
+ return 0;
- # else
+ #else
- if (rec_seq != NULL)
- *rec_seq = NULL;
+ if (!is_tx)
+ return 0;
- # endif
+ #endif
return 1;
};
-@@ -154,15 +225,20 @@ int ktls_check_supported_cipher(const SSL *s, const EVP_CIPHER *c,
+@@ -154,15 +227,20 @@ int ktls_check_supported_cipher(const SSL *s, const EV
}
/* Function to configure kernel TLS structure */
-int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
+int ktls_configure_crypto(SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
- void *rl_sequence, ktls_crypto_info_t *crypto_info,
-- unsigned char **rec_seq, unsigned char *iv,
-+ int is_tx, unsigned char *iv,
- unsigned char *key, unsigned char *mac_key,
- size_t mac_secret_size)
+ void *rl_sequence, ktls_crypto_info_t *crypto_info,
+- unsigned char **rec_seq, unsigned char *iv,
++ int is_tx, unsigned char *iv,
+ unsigned char *key, unsigned char *mac_key,
+ size_t mac_secret_size)
{
unsigned char geniv[12];
unsigned char *iiv = iv;
@@ -158,60 +158,60 @@ index 79d980959e..e343d382cc 100644
+ return 0;
+# endif
+
- if (s->version == TLS1_2_VERSION &&
- EVP_CIPHER_get_mode(c) == EVP_CIPH_GCM_MODE) {
+ if (s->version == TLS1_2_VERSION && EVP_CIPHER_get_mode(c) == EVP_CIPH_GCM_MODE) {
if (!EVP_CIPHER_CTX_get_updated_iv(dd, geniv,
-@@ -186,8 +262,8 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
+ EVP_GCM_TLS_FIXED_IV_LEN
+@@ -186,8 +262,8 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPH
memcpy(crypto_info->gcm128.key, key, EVP_CIPHER_get_key_length(c));
memcpy(crypto_info->gcm128.rec_seq, rl_sequence,
- TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE);
+ TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE);
- if (rec_seq != NULL)
- *rec_seq = crypto_info->gcm128.rec_seq;
+ if (!is_tx && !check_rx_read_ahead(s, crypto_info->gcm128.rec_seq))
+ return 0;
return 1;
- # endif
- # ifdef OPENSSL_KTLS_AES_GCM_256
-@@ -201,8 +277,8 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
+ #endif
+ #ifdef OPENSSL_KTLS_AES_GCM_256
+@@ -201,8 +277,8 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPH
memcpy(crypto_info->gcm256.key, key, EVP_CIPHER_get_key_length(c));
memcpy(crypto_info->gcm256.rec_seq, rl_sequence,
- TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE);
+ TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE);
- if (rec_seq != NULL)
- *rec_seq = crypto_info->gcm256.rec_seq;
-+ if (!is_tx && !check_rx_read_ahead(s, crypto_info->gcm256.rec_seq))
++ if (!is_tx && !check_rx_read_ahead(s, crypto_info->ccm128.rec_seq))
+ return 0;
return 1;
- # endif
- # ifdef OPENSSL_KTLS_AES_CCM_128
-@@ -216,8 +292,8 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
+ #endif
+ #ifdef OPENSSL_KTLS_AES_CCM_128
+@@ -216,8 +292,8 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPH
memcpy(crypto_info->ccm128.key, key, EVP_CIPHER_get_key_length(c));
memcpy(crypto_info->ccm128.rec_seq, rl_sequence,
- TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE);
+ TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE);
- if (rec_seq != NULL)
- *rec_seq = crypto_info->ccm128.rec_seq;
+ if (!is_tx && !check_rx_read_ahead(s, crypto_info->ccm128.rec_seq))
+ return 0;
return 1;
- # endif
- # ifdef OPENSSL_KTLS_CHACHA20_POLY1305
-@@ -231,8 +307,10 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
- EVP_CIPHER_get_key_length(c));
- memcpy(crypto_info->chacha20poly1305.rec_seq, rl_sequence,
- TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE);
-- if (rec_seq != NULL)
-- *rec_seq = crypto_info->chacha20poly1305.rec_seq;
+ #endif
+ #ifdef OPENSSL_KTLS_CHACHA20_POLY1305
+@@ -231,7 +309,11 @@ int ktls_configure_crypto(const SSL *s, const EVP_CIPH
+ TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE);
+ if (rec_seq != NULL)
+ *rec_seq = crypto_info->chacha20poly1305.rec_seq;
+- return 1;
+ if (!is_tx
+ && !check_rx_read_ahead(s,
+ crypto_info->chacha20poly1305.rec_seq))
+ return 0;
- return 1;
- # endif
++ return 1;
+ #endif
default:
+ return 0;
diff --git ssl/record/ssl3_record.c ssl/record/ssl3_record.c
index d8ef018741..63caac080f 100644
--- ssl/record/ssl3_record.c
+++ ssl/record/ssl3_record.c
-@@ -185,18 +185,23 @@ int ssl3_get_record(SSL *s)
+@@ -186,18 +186,23 @@ int ssl3_get_record(SSL *s)
int imac_size;
size_t num_recs = 0, max_recs, j;
PACKET pkt, sslv2pkt;
@@ -237,7 +237,7 @@ index d8ef018741..63caac080f 100644
do {
thisrr = &rr[num_recs];
-@@ -361,7 +366,9 @@ int ssl3_get_record(SSL *s)
+@@ -357,7 +362,9 @@ int ssl3_get_record(SSL *s)
}
}
@@ -246,9 +246,9 @@ index d8ef018741..63caac080f 100644
+ && s->enc_read_ctx != NULL
+ && !using_ktls) {
if (thisrr->type != SSL3_RT_APPLICATION_DATA
- && (thisrr->type != SSL3_RT_CHANGE_CIPHER_SPEC
- || !SSL_IS_FIRST_HANDSHAKE(s))
-@@ -391,7 +398,13 @@ int ssl3_get_record(SSL *s)
+ && (thisrr->type != SSL3_RT_CHANGE_CIPHER_SPEC
+ || !SSL_IS_FIRST_HANDSHAKE(s))
+@@ -386,7 +393,13 @@ int ssl3_get_record(SSL *s)
}
if (SSL_IS_TLS13(s)) {
@@ -261,9 +261,9 @@ index d8ef018741..63caac080f 100644
+
+ if (thisrr->length > len) {
SSLfatal(s, SSL_AD_RECORD_OVERFLOW,
- SSL_R_ENCRYPTED_LENGTH_TOO_LONG);
+ SSL_R_ENCRYPTED_LENGTH_TOO_LONG);
return -1;
-@@ -409,7 +422,7 @@ int ssl3_get_record(SSL *s)
+@@ -404,7 +417,7 @@ int ssl3_get_record(SSL *s)
#endif
/* KTLS may use all of the buffer */
@@ -272,7 +272,7 @@ index d8ef018741..63caac080f 100644
len = SSL3_BUFFER_get_left(rbuf);
if (thisrr->length > len) {
-@@ -518,11 +531,7 @@ int ssl3_get_record(SSL *s)
+@@ -512,11 +525,7 @@ int ssl3_get_record(SSL *s)
return 1;
}
@@ -285,10 +285,10 @@ index d8ef018741..63caac080f 100644
goto skip_decryption;
if (s->read_hash != NULL) {
-@@ -677,21 +686,29 @@ int ssl3_get_record(SSL *s)
+@@ -684,21 +693,29 @@ skip_decryption:
if (SSL_IS_TLS13(s)
- && s->enc_read_ctx != NULL
- && thisrr->type != SSL3_RT_ALERT) {
+ && s->enc_read_ctx != NULL
+ && thisrr->type != SSL3_RT_ALERT) {
- size_t end;
+ /*
+ * The following logic are irrelevant in KTLS: the kernel provides
@@ -298,17 +298,16 @@ index d8ef018741..63caac080f 100644
+ */
+ if (!using_ktls) {
+ size_t end;
-
-- if (thisrr->length == 0
-- || thisrr->type != SSL3_RT_APPLICATION_DATA) {
-- SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_R_BAD_RECORD_TYPE);
-- goto end;
+ if (thisrr->length == 0
+ || thisrr->type != SSL3_RT_APPLICATION_DATA) {
+ SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_R_BAD_RECORD_TYPE);
+ goto end;
+ }
-+
+
+- if (thisrr->length == 0
+- || thisrr->type != SSL3_RT_APPLICATION_DATA) {
+- SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_R_BAD_RECORD_TYPE);
+- goto end;
+ /* Strip trailing padding */
+ for (end = thisrr->length - 1; end > 0 && thisrr->data[end] == 0;
+ end--)
@@ -317,69 +316,71 @@ index d8ef018741..63caac080f 100644
+ thisrr->length = end;
+ thisrr->type = thisrr->data[end];
}
--
+
- /* Strip trailing padding */
- for (end = thisrr->length - 1; end > 0 && thisrr->data[end] == 0;
-- end--)
+- end--)
- continue;
-
- thisrr->length = end;
- thisrr->type = thisrr->data[end];
if (thisrr->type != SSL3_RT_APPLICATION_DATA
- && thisrr->type != SSL3_RT_ALERT
- && thisrr->type != SSL3_RT_HANDSHAKE) {
-@@ -700,7 +717,7 @@ int ssl3_get_record(SSL *s)
+ && thisrr->type != SSL3_RT_ALERT
+ && thisrr->type != SSL3_RT_HANDSHAKE) {
+@@ -707,7 +724,7 @@ skip_decryption:
}
if (s->msg_callback)
s->msg_callback(0, s->version, SSL3_RT_INNER_CONTENT_TYPE,
-- &thisrr->data[end], 1, s, s->msg_callback_arg);
-+ &thisrr->type, 1, s, s->msg_callback_arg);
+- &thisrr->data[end], 1, s, s->msg_callback_arg);
++ &thisrr->type, 1, s, s->msg_callback_arg);
}
/*
-@@ -723,8 +740,7 @@ int ssl3_get_record(SSL *s)
+@@ -730,9 +747,8 @@ skip_decryption:
* Therefore we have to rely on KTLS to check the plaintext length
* limit in the kernel.
*/
- if (thisrr->length > SSL3_RT_MAX_PLAIN_LENGTH
-- && (!BIO_get_ktls_recv(s->rbio) || is_ktls_left)) {
+- && (!BIO_get_ktls_recv(s->rbio) || is_ktls_left)) {
+- SSLfatal(s, SSL_AD_RECORD_OVERFLOW, SSL_R_DATA_LENGTH_TOO_LONG);
+ if (thisrr->length > SSL3_RT_MAX_PLAIN_LENGTH && !using_ktls) {
- SSLfatal(s, SSL_AD_RECORD_OVERFLOW, SSL_R_DATA_LENGTH_TOO_LONG);
++ SSLfatal(s, SSL_AD_RECORD_OVERFLOW, SSL_R_DATA_LENGTH_TOO_LONG);
goto end;
}
+
diff --git ssl/ssl_local.h ssl/ssl_local.h
index 5471e900b8..79ced2f468 100644
--- ssl/ssl_local.h
+++ ssl/ssl_local.h
-@@ -2760,9 +2760,9 @@ __owur int ssl_log_secret(SSL *ssl, const char *label,
+@@ -2774,9 +2774,9 @@ int ktls_check_supported_cipher(const SSL *s, const EV
/* ktls.c */
int ktls_check_supported_cipher(const SSL *s, const EVP_CIPHER *c,
- const EVP_CIPHER_CTX *dd);
+ const EVP_CIPHER_CTX *dd);
-int ktls_configure_crypto(const SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
+int ktls_configure_crypto(SSL *s, const EVP_CIPHER *c, EVP_CIPHER_CTX *dd,
- void *rl_sequence, ktls_crypto_info_t *crypto_info,
-- unsigned char **rec_seq, unsigned char *iv,
-+ int is_tx, unsigned char *iv,
- unsigned char *key, unsigned char *mac_key,
- size_t mac_secret_size);
- # endif
+ void *rl_sequence, ktls_crypto_info_t *crypto_info,
+- unsigned char **rec_seq, unsigned char *iv,
++ int is_tx, unsigned char *iv,
+ unsigned char *key, unsigned char *mac_key,
+ size_t mac_secret_size);
+ #endif
diff --git ssl/t1_enc.c ssl/t1_enc.c
index 237a19cd93..900ba14fbd 100644
--- ssl/t1_enc.c
+++ ssl/t1_enc.c
-@@ -98,42 +98,6 @@ static int tls1_generate_key_block(SSL *s, unsigned char *km, size_t num)
+@@ -98,41 +98,6 @@ static int tls1_generate_key_block(SSL *s, unsigned ch
return ret;
}
-
+
-#ifndef OPENSSL_NO_KTLS
-- /*
-- * Count the number of records that were not processed yet from record boundary.
-- *
-- * This function assumes that there are only fully formed records read in the
-- * record layer. If read_ahead is enabled, then this might be false and this
-- * function will fail.
-- */
--# ifndef OPENSSL_NO_KTLS_RX
+-/*
+- * Count the number of records that were not processed yet from record boundary.
+- *
+- * This function assumes that there are only fully formed records read in the
+- * record layer. If read_ahead is enabled, then this might be false and this
+- * function will fail.
+- */
+-#ifndef OPENSSL_NO_KTLS_RX
-static int count_unprocessed_records(SSL *s)
-{
- SSL3_BUFFER *rbuf = RECORD_LAYER_get_rbuf(&s->rlayer);
@@ -403,39 +404,35 @@ index 237a19cd93..900ba14fbd 100644
-
- return count;
-}
--# endif
-#endif
--
+-#endif
-
int tls_provider_set_tls_params(SSL *s, EVP_CIPHER_CTX *ctx,
- const EVP_CIPHER *ciph,
- const EVP_MD *md)
-@@ -201,12 +165,7 @@ int tls1_change_cipher_state(SSL *s, int which)
+ const EVP_CIPHER *ciph,
+ const EVP_MD *md)
+@@ -199,12 +164,7 @@ int tls1_change_cipher_state(SSL *s, int which)
int reuse_dd = 0;
#ifndef OPENSSL_NO_KTLS
ktls_crypto_info_t crypto_info;
- unsigned char *rec_seq;
void *rl_sequence;
--# ifndef OPENSSL_NO_KTLS_RX
+-#ifndef OPENSSL_NO_KTLS_RX
- int count_unprocessed;
- int bit;
--# endif
+-#endif
BIO *bio;
#endif
-
-@@ -473,30 +432,11 @@ int tls1_change_cipher_state(SSL *s, int which)
+
+@@ -478,29 +438,10 @@ int tls1_change_cipher_state(SSL *s, int which)
else
rl_sequence = RECORD_LAYER_get_read_sequence(&s->rlayer);
-
+
- if (!ktls_configure_crypto(s, c, dd, rl_sequence, &crypto_info, &rec_seq,
-- iv, key, ms, *mac_secret_size))
-+ if (!ktls_configure_crypto(s, c, dd, rl_sequence, &crypto_info,
-+ which & SSL3_CC_WRITE, iv, key, ms,
-+ *mac_secret_size))
- goto skip_ktls;
-
+- iv, key, ms, *mac_secret_size))
+- goto skip_ktls;
+-
- if (which & SSL3_CC_READ) {
--# ifndef OPENSSL_NO_KTLS_RX
+-#ifndef OPENSSL_NO_KTLS_RX
- count_unprocessed = count_unprocessed_records(s);
- if (count_unprocessed < 0)
- goto skip_ktls;
@@ -449,14 +446,17 @@ index 237a19cd93..900ba14fbd 100644
- }
- count_unprocessed--;
- }
--# else
+-#else
- goto skip_ktls;
--# endif
+-#endif
- }
--
++ if (!ktls_configure_crypto(s, c, dd, rl_sequence, &crypto_info,
++ which & SSL3_CC_WRITE, iv, key, ms,
++ *mac_secret_size))
++ goto skip_ktls;
+
/* ktls works with user provided buffers directly */
if (BIO_set_ktls(bio, &crypto_info, which & SSL3_CC_WRITE)) {
- if (which & SSL3_CC_WRITE)
diff --git ssl/tls13_enc.c ssl/tls13_enc.c
index 12388922e3..eaab0e2a74 100644
--- ssl/tls13_enc.c
@@ -469,16 +469,16 @@ index 12388922e3..eaab0e2a74 100644
BIO *bio;
#endif
-@@ -688,8 +689,7 @@ int tls13_change_cipher_state(SSL *s, int which)
+@@ -690,8 +691,7 @@ int tls13_change_cipher_state(SSL *s, int which)
s->statem.enc_write_state = ENC_WRITE_STATE_VALID;
#ifndef OPENSSL_NO_KTLS
- # if defined(OPENSSL_KTLS_TLS13)
+ #if defined(OPENSSL_KTLS_TLS13)
- if (!(which & SSL3_CC_WRITE)
-- || !(which & SSL3_CC_APPLICATION)
+- || !(which & SSL3_CC_APPLICATION)
+ if (!(which & SSL3_CC_APPLICATION)
- || (s->options & SSL_OP_ENABLE_KTLS) == 0)
+ || (s->options & SSL_OP_ENABLE_KTLS) == 0)
goto skip_ktls;
-
+
@@ -705,7 +705,10 @@ int tls13_change_cipher_state(SSL *s, int which)
if (!ktls_check_supported_cipher(s, cipher, ciph_ctx))
goto skip_ktls;
@@ -491,21 +491,21 @@ index 12388922e3..eaab0e2a74 100644
if (!ossl_assert(bio != NULL)) {
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-@@ -713,18 +716,26 @@ int tls13_change_cipher_state(SSL *s, int which)
+@@ -715,18 +718,26 @@ int tls13_change_cipher_state(SSL *s, int which)
}
-
+
/* All future data will get encrypted by ktls. Flush the BIO or skip ktls */
- if (BIO_flush(bio) <= 0)
- goto skip_ktls;
+ if (which & SSL3_CC_WRITE) {
-+ if (BIO_flush(bio) <= 0)
++ if (BIO_flush(bio) <= 0)
+ goto skip_ktls;
+ }
-
+
/* configure kernel crypto structure */
- if (!ktls_configure_crypto(s, cipher, ciph_ctx,
-- RECORD_LAYER_get_write_sequence(&s->rlayer),
-- &crypto_info, NULL, iv, key, NULL, 0))
+- RECORD_LAYER_get_write_sequence(&s->rlayer),
+- &crypto_info, NULL, iv, key, NULL, 0))
+ if (which & SSL3_CC_WRITE)
+ rl_sequence = RECORD_LAYER_get_write_sequence(&s->rlayer);
+ else
@@ -514,7 +514,7 @@ index 12388922e3..eaab0e2a74 100644
+ if (!ktls_configure_crypto(s, cipher, ciph_ctx, rl_sequence, &crypto_info,
+ which & SSL3_CC_WRITE, iv, key, NULL, 0))
goto skip_ktls;
-
+
/* ktls works with user provided buffers directly */
- if (BIO_set_ktls(bio, &crypto_info, which & SSL3_CC_WRITE))
- ssl3_release_write_buffer(s);
@@ -523,7 +523,7 @@ index 12388922e3..eaab0e2a74 100644
+ ssl3_release_write_buffer(s);
+ }
skip_ktls:
- # endif
+ #endif
#endif
diff --git test/sslapitest.c test/sslapitest.c
index 2911d6e94b..faf2eec2bc 100644
diff --git a/security/openssl/files/patch-crypto_async_arch_async__posix.h b/security/openssl/files/patch-crypto_async_arch_async__posix.h
index b544aed6932a..8690f951fa42 100644
--- a/security/openssl/files/patch-crypto_async_arch_async__posix.h
+++ b/security/openssl/files/patch-crypto_async_arch_async__posix.h
@@ -21,12 +21,12 @@ diff --git a/crypto/async/arch/async_posix.h b/crypto/async/arch/async_posix.h
index a17c6b8e68af..2d97ec3acc9b 100644
--- crypto/async/arch/async_posix.h
+++ crypto/async/arch/async_posix.h
-@@ -18,7 +18,7 @@
- # include <unistd.h>
+@@ -19,7 +19,7 @@
+ #include <unistd.h>
- # if _POSIX_VERSION >= 200112L \
-- && (_POSIX_VERSION < 200809L || defined(__GLIBC__))
-+ && (_POSIX_VERSION < 200809L || defined(__GLIBC__) || defined(__FreeBSD__))
+ #if _POSIX_VERSION >= 200112L \
+- && (_POSIX_VERSION < 200809L || defined(__GLIBC__))
++ && (_POSIX_VERSION < 200809L || defined(__GLIBC__) || defined(__FreeBSD__))
- # include <pthread.h>
+ #include <pthread.h>
diff --git a/security/openssl/files/patch-crypto_ppccap.c b/security/openssl/files/patch-crypto_ppccap.c
index 14da11dedd4b..6783e0b13c2d 100644
--- a/security/openssl/files/patch-crypto_ppccap.c
+++ b/security/openssl/files/patch-crypto_ppccap.c
@@ -4,22 +4,22 @@
#endif
/* I wish <sys/auxv.h> was universally available */
--#define HWCAP 16 /* AT_HWCAP */
+-#define HWCAP 16 /* AT_HWCAP */
+#ifndef AT_HWCAP
-+# define AT_HWCAP 16 /* AT_HWCAP */
++# define AT_HWCAP 16 /* AT_HWCAP */
+#endif
- #define HWCAP_PPC64 (1U << 30)
- #define HWCAP_ALTIVEC (1U << 28)
- #define HWCAP_FPU (1U << 27)
- #define HWCAP_POWER6_EXT (1U << 9)
- #define HWCAP_VSX (1U << 7)
+ #define HWCAP_PPC64 (1U << 30)
+ #define HWCAP_ALTIVEC (1U << 28)
+ #define HWCAP_FPU (1U << 27)
+ #define HWCAP_POWER6_EXT (1U << 9)
+ #define HWCAP_VSX (1U << 7)
--#define HWCAP2 26 /* AT_HWCAP2 */
+-#define HWCAP2 26 /* AT_HWCAP2 */
+#ifndef AT_HWCAP2
-+# define AT_HWCAP2 26 /* AT_HWCAP2 */
++#define AT_HWCAP2 26 /* AT_HWCAP2 */
+#endif
- #define HWCAP_VEC_CRYPTO (1U << 25)
- #define HWCAP_ARCH_3_00 (1U << 23)
+ #define HWCAP_VEC_CRYPTO (1U << 25)
+ #define HWCAP_ARCH_3_00 (1U << 23)
@@ -215,8 +219,8 @@ void OPENSSL_cpuid_setup(void)