Compare commits
10 Commits
3edec2f3c6
...
eb6b452ea9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb6b452ea9 | ||
|
|
0d7bcfe45d | ||
|
|
0da1b0fea6 | ||
|
|
31d33bcbb1 | ||
|
|
5d95b9efd4 | ||
|
|
5ca29fc85f | ||
|
|
c7e6789b95 | ||
|
|
f96426270d | ||
|
|
22694d5573 | ||
|
|
e13dee02fb |
142
backport-CVE-2024-13176-Fix-timing-side-channel.patch
Normal file
142
backport-CVE-2024-13176-Fix-timing-side-channel.patch
Normal file
@ -0,0 +1,142 @@
|
||||
From 751c6e6100726b7159eac4d7bd011cb1fb177263 Mon Sep 17 00:00:00 2001
|
||||
From: Tomas Mraz <tomas@openssl.org>
|
||||
Date: Wed, 15 Jan 2025 18:27:02 +0100
|
||||
Subject: [PATCH] Fix timing side-channel in ECDSA signature computation
|
||||
|
||||
There is a timing signal of around 300 nanoseconds when the top word of
|
||||
the inverted ECDSA nonce value is zero. This can happen with significant
|
||||
probability only for some of the supported elliptic curves. In particular
|
||||
the NIST P-521 curve is affected. To be able to measure this leak, the
|
||||
attacker process must either be located in the same physical computer or
|
||||
must have a very fast network connection with low latency.
|
||||
|
||||
Attacks on ECDSA nonce are also known as Minerva attack.
|
||||
|
||||
Fixes CVE-2024-13176
|
||||
|
||||
Reviewed-by: Tim Hudson <tjh@openssl.org>
|
||||
Reviewed-by: Neil Horman <nhorman@openssl.org>
|
||||
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
|
||||
(Merged from https://github.com/openssl/openssl/pull/26429)
|
||||
|
||||
(cherry picked from commit 63c40a66c5dc287485705d06122d3a6e74a6a203)
|
||||
---
|
||||
crypto/bn/bn_exp.c | 23 ++++++++++++++++-------
|
||||
crypto/ec/ec_lib.c | 8 ++++----
|
||||
include/crypto/bn.h | 3 +++
|
||||
include/openssl/bnerr.h | 1 +
|
||||
4 files changed, 24 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c
|
||||
index 517e3c29fc..1f64f35cba 100644
|
||||
--- a/crypto/bn/bn_exp.c
|
||||
+++ b/crypto/bn/bn_exp.c
|
||||
@@ -601,7 +601,7 @@ static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top,
|
||||
* out by Colin Percival,
|
||||
* http://www.daemonology.net/hyperthreading-considered-harmful/)
|
||||
*/
|
||||
-int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
+int bn_mod_exp_mont_fixed_top(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx,
|
||||
BN_MONT_CTX *in_mont)
|
||||
{
|
||||
@@ -618,12 +618,8 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
unsigned int t4 = 0;
|
||||
#endif
|
||||
|
||||
- bn_check_top(a);
|
||||
- bn_check_top(p);
|
||||
- bn_check_top(m);
|
||||
-
|
||||
if (!BN_is_odd(m)) {
|
||||
- BNerr(BN_F_BN_MOD_EXP_MONT_CONSTTIME, BN_R_CALLED_WITH_EVEN_MODULUS);
|
||||
+ BNerr(BN_F_BN_MOD_EXP_MONT_FIXED_TOP, BN_R_CALLED_WITH_EVEN_MODULUS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1141,7 +1137,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
goto err;
|
||||
} else
|
||||
#endif
|
||||
- if (!BN_from_montgomery(rr, &tmp, mont, ctx))
|
||||
+ if (!bn_from_mont_fixed_top(rr, &tmp, mont, ctx))
|
||||
goto err;
|
||||
ret = 1;
|
||||
err:
|
||||
@@ -1155,6 +1151,19 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
return ret;
|
||||
}
|
||||
|
||||
+int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
+ const BIGNUM *m, BN_CTX *ctx,
|
||||
+ BN_MONT_CTX *in_mont)
|
||||
+{
|
||||
+ bn_check_top(a);
|
||||
+ bn_check_top(p);
|
||||
+ bn_check_top(m);
|
||||
+ if (!bn_mod_exp_mont_fixed_top(rr, a, p, m, ctx, in_mont))
|
||||
+ return 0;
|
||||
+ bn_correct_top(rr);
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
|
||||
{
|
||||
diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c
|
||||
index 08db89fcee..9f0b480705 100644
|
||||
--- a/crypto/ec/ec_lib.c
|
||||
+++ b/crypto/ec/ec_lib.c
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/opensslv.h>
|
||||
-
|
||||
#include "ec_local.h"
|
||||
+#include "crypto/bn.h"
|
||||
|
||||
/* functions for EC_GROUP objects */
|
||||
|
||||
@@ -1155,10 +1155,10 @@ static int ec_field_inverse_mod_ord(const EC_GROUP *group, BIGNUM *r,
|
||||
if (!BN_sub(e, group->order, e))
|
||||
goto err;
|
||||
/*-
|
||||
- * Exponent e is public.
|
||||
- * No need for scatter-gather or BN_FLG_CONSTTIME.
|
||||
+ * Although the exponent is public we want the result to be
|
||||
+ * fixed top.
|
||||
*/
|
||||
- if (!BN_mod_exp_mont(r, x, e, group->order, ctx, group->mont_data))
|
||||
+ if (!bn_mod_exp_mont_fixed_top(r, x, e, group->order, ctx, group->mont_data))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
diff --git a/include/crypto/bn.h b/include/crypto/bn.h
|
||||
index 250914c46a..8484047fd0 100644
|
||||
--- a/include/crypto/bn.h
|
||||
+++ b/include/crypto/bn.h
|
||||
@@ -72,6 +72,9 @@ int bn_set_words(BIGNUM *a, const BN_ULONG *words, int num_words);
|
||||
*/
|
||||
int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
||||
BN_MONT_CTX *mont, BN_CTX *ctx);
|
||||
+int bn_mod_exp_mont_fixed_top(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
+ const BIGNUM *m, BN_CTX *ctx,
|
||||
+ BN_MONT_CTX *in_mont);
|
||||
int bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||
BN_CTX *ctx);
|
||||
int bn_from_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont,
|
||||
diff --git a/include/openssl/bnerr.h b/include/openssl/bnerr.h
|
||||
index 5c83777f9f..f6aef13441 100644
|
||||
--- a/include/openssl/bnerr.h
|
||||
+++ b/include/openssl/bnerr.h
|
||||
@@ -73,6 +73,7 @@ int ERR_load_BN_strings(void);
|
||||
# define BN_F_BN_STACK_PUSH 148
|
||||
# define BN_F_BN_USUB 115
|
||||
# define BN_F_OSSL_BN_RSA_DO_UNBLIND 151
|
||||
+# define BN_F_BN_MOD_EXP_MONT_FIXED_TOP 152
|
||||
|
||||
/*
|
||||
* BN reason codes.
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,168 @@
|
||||
From d7afe8e89ced1f4d5f1e5aab474dd9c069115b6e Mon Sep 17 00:00:00 2001
|
||||
From: xuhuiyue <xuhuiyue@huawei.com>
|
||||
Date: Fri, 28 Jun 2024 17:31:29 +0800
|
||||
Subject: [PATCH 2/2] Fix SSL_select_next_proto and add ALPN validation in the
|
||||
client
|
||||
|
||||
Fix CVE-2024-5535.
|
||||
|
||||
Signed-off-by: xuhuiyue <xuhuiyue@huawei.com>
|
||||
---
|
||||
ssl/ssl_lib.c | 63 +++++++++++++++++++++++-------------
|
||||
ssl/statem/extensions_clnt.c | 27 +++++++++++++++-
|
||||
ssl/statem/extensions_srvr.c | 3 +-
|
||||
3 files changed, 68 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
|
||||
index 00410a7385..cb2dca4247 100644
|
||||
--- a/ssl/ssl_lib.c
|
||||
+++ b/ssl/ssl_lib.c
|
||||
@@ -2767,37 +2767,54 @@ int SSL_select_next_proto(unsigned char **out, unsigned char *outlen,
|
||||
unsigned int server_len,
|
||||
const unsigned char *client, unsigned int client_len)
|
||||
{
|
||||
- unsigned int i, j;
|
||||
- const unsigned char *result;
|
||||
- int status = OPENSSL_NPN_UNSUPPORTED;
|
||||
+ PACKET cpkt, csubpkt, spkt, ssubpkt;
|
||||
+
|
||||
+ if (!PACKET_buf_init(&cpkt, client, client_len)
|
||||
+ || !PACKET_get_length_prefixed_1(&cpkt, &csubpkt)
|
||||
+ || PACKET_remaining(&csubpkt) == 0) {
|
||||
+ *out = NULL;
|
||||
+ *outlen = 0;
|
||||
+ return OPENSSL_NPN_NO_OVERLAP;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Set the default opportunistic protocol. Will be overwritten if we find
|
||||
+ * a match.
|
||||
+ */
|
||||
+ *out = (unsigned char *)PACKET_data(&csubpkt);
|
||||
+ *outlen = (unsigned char)PACKET_remaining(&csubpkt);
|
||||
|
||||
/*
|
||||
* For each protocol in server preference order, see if we support it.
|
||||
*/
|
||||
- for (i = 0; i < server_len;) {
|
||||
- for (j = 0; j < client_len;) {
|
||||
- if (server[i] == client[j] &&
|
||||
- memcmp(&server[i + 1], &client[j + 1], server[i]) == 0) {
|
||||
- /* We found a match */
|
||||
- result = &server[i];
|
||||
- status = OPENSSL_NPN_NEGOTIATED;
|
||||
- goto found;
|
||||
+ if (PACKET_buf_init(&spkt, server, server_len)) {
|
||||
+ while (PACKET_get_length_prefixed_1(&spkt, &ssubpkt)) {
|
||||
+ if (PACKET_remaining(&ssubpkt) == 0)
|
||||
+ continue; /* Invalid - ignore it */
|
||||
+ if (PACKET_buf_init(&cpkt, client, client_len)) {
|
||||
+ while (PACKET_get_length_prefixed_1(&cpkt, &csubpkt)) {
|
||||
+ if (PACKET_equal(&csubpkt, PACKET_data(&ssubpkt),
|
||||
+ PACKET_remaining(&ssubpkt))) {
|
||||
+ /* We found a match */
|
||||
+ *out = (unsigned char *)PACKET_data(&ssubpkt);
|
||||
+ *outlen = (unsigned char)PACKET_remaining(&ssubpkt);
|
||||
+ return OPENSSL_NPN_NEGOTIATED;
|
||||
+ }
|
||||
+ }
|
||||
+ /* Ignore spurious trailing bytes in the client list */
|
||||
+ } else {
|
||||
+ /* This should never happen */
|
||||
+ return OPENSSL_NPN_NO_OVERLAP;
|
||||
}
|
||||
- j += client[j];
|
||||
- j++;
|
||||
}
|
||||
- i += server[i];
|
||||
- i++;
|
||||
+ /* Ignore spurious trailing bytes in the server list */
|
||||
}
|
||||
|
||||
- /* There's no overlap between our protocols and the server's list. */
|
||||
- result = client;
|
||||
- status = OPENSSL_NPN_NO_OVERLAP;
|
||||
-
|
||||
- found:
|
||||
- *out = (unsigned char *)result + 1;
|
||||
- *outlen = result[0];
|
||||
- return status;
|
||||
+ /*
|
||||
+ * There's no overlap between our protocols and the server's list. We use
|
||||
+ * the default opportunistic protocol selected earlier
|
||||
+ */
|
||||
+ return OPENSSL_NPN_NO_OVERLAP;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
diff --git a/ssl/statem/extensions_clnt.c b/ssl/statem/extensions_clnt.c
|
||||
index c641ae7351..4ad75c8e2d 100644
|
||||
--- a/ssl/statem/extensions_clnt.c
|
||||
+++ b/ssl/statem/extensions_clnt.c
|
||||
@@ -1602,7 +1602,8 @@ int tls_parse_stoc_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
PACKET_data(pkt),
|
||||
PACKET_remaining(pkt),
|
||||
s->ctx->ext.npn_select_cb_arg) !=
|
||||
- SSL_TLSEXT_ERR_OK) {
|
||||
+ SSL_TLSEXT_ERR_OK
|
||||
+ || selected_len == 0) {
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS_PARSE_STOC_NPN,
|
||||
SSL_R_BAD_EXTENSION);
|
||||
return 0;
|
||||
@@ -1633,6 +1634,8 @@ int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
size_t chainidx)
|
||||
{
|
||||
size_t len;
|
||||
+ PACKET confpkt, protpkt;
|
||||
+ int valid = 0;
|
||||
|
||||
/* We must have requested it. */
|
||||
if (!s->s3->alpn_sent) {
|
||||
@@ -1653,6 +1656,28 @@ int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||
SSL_R_BAD_EXTENSION);
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+ /* It must be a protocol that we sent */
|
||||
+ if (!PACKET_buf_init(&confpkt, s->ext.alpn, s->ext.alpn_len)) {
|
||||
+ SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_STOC_ALPN, ERR_R_INTERNAL_ERROR);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ while (PACKET_get_length_prefixed_1(&confpkt, &protpkt)) {
|
||||
+ if (PACKET_remaining(&protpkt) != len)
|
||||
+ continue;
|
||||
+ if (memcmp(PACKET_data(pkt), PACKET_data(&protpkt), len) == 0) {
|
||||
+ /* Valid protocol found */
|
||||
+ valid = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!valid) {
|
||||
+ /* The protocol sent from the server does not match one we advertised */
|
||||
+ SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PARSE_STOC_ALPN, SSL_R_BAD_EXTENSION);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
OPENSSL_free(s->s3->alpn_selected);
|
||||
s->s3->alpn_selected = OPENSSL_malloc(len);
|
||||
if (s->s3->alpn_selected == NULL) {
|
||||
diff --git a/ssl/statem/extensions_srvr.c b/ssl/statem/extensions_srvr.c
|
||||
index 775d9a7444..a08027fd6d 100644
|
||||
--- a/ssl/statem/extensions_srvr.c
|
||||
+++ b/ssl/statem/extensions_srvr.c
|
||||
@@ -1562,9 +1562,10 @@ EXT_RETURN tls_construct_stoc_next_proto_neg(SSL *s, WPACKET *pkt,
|
||||
return EXT_RETURN_FAIL;
|
||||
}
|
||||
s->s3->npn_seen = 1;
|
||||
+ return EXT_RETURN_SENT;
|
||||
}
|
||||
|
||||
- return EXT_RETURN_SENT;
|
||||
+ return EXT_RETURN_NOT_SENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,201 @@
|
||||
From 72ae83ad214d2eef262461365a1975707f862712 Mon Sep 17 00:00:00 2001
|
||||
From: Viktor Dukhovni <viktor@openssl.org>
|
||||
Date: Thu, 19 Sep 2024 01:02:40 +1000
|
||||
Subject: [PATCH] Harden BN_GF2m_poly2arr against misuse.
|
||||
|
||||
The BN_GF2m_poly2arr() function converts characteristic-2 field
|
||||
(GF_{2^m}) Galois polynomials from a representation as a BIGNUM bitmask,
|
||||
to a compact array with just the exponents of the non-zero terms.
|
||||
|
||||
These polynomials are then used in BN_GF2m_mod_arr() to perform modular
|
||||
reduction. A precondition of calling BN_GF2m_mod_arr() is that the
|
||||
polynomial must have a non-zero constant term (i.e. the array has `0` as
|
||||
its final element).
|
||||
|
||||
Internally, callers of BN_GF2m_poly2arr() did not verify that
|
||||
precondition, and binary EC curve parameters with an invalid polynomial
|
||||
could lead to out of bounds memory reads and writes in BN_GF2m_mod_arr().
|
||||
|
||||
The precondition is always true for polynomials that arise from the
|
||||
standard form of EC parameters for characteristic-two fields (X9.62).
|
||||
See the "Finite Field Identification" section of:
|
||||
|
||||
https://www.itu.int/ITU-T/formal-language/itu-t/x/x894/2018-cor1/ANSI-X9-62.html
|
||||
|
||||
The OpenSSL GF(2^m) code supports only the trinomial and pentanomial
|
||||
basis X9.62 forms.
|
||||
|
||||
This commit updates BN_GF2m_poly2arr() to return `0` (failure) when
|
||||
the constant term is zero (i.e. the input bitmask BIGNUM is not odd).
|
||||
|
||||
Additionally, the return value is made unambiguous when there is not
|
||||
enough space to also pad the array with a final `-1` sentinel value.
|
||||
The return value is now always the number of elements (including the
|
||||
final `-1`) that would be filled when the output array is sufficiently
|
||||
large. Previously the same count was returned both when the array has
|
||||
just enough room for the final `-1` and when it had only enough space
|
||||
for non-sentinel values.
|
||||
|
||||
Finally, BN_GF2m_poly2arr() is updated to reject polynomials whose
|
||||
degree exceeds `OPENSSL_ECC_MAX_FIELD_BITS`, this guards against
|
||||
CPU exhausition attacks via excessively large inputs.
|
||||
|
||||
The above issues do not arise in processing X.509 certificates. These
|
||||
generally have EC keys from "named curves", and RFC5840 (Section 2.1.1)
|
||||
disallows explicit EC parameters. The TLS code in OpenSSL enforces this
|
||||
constraint only after the certificate is decoded, but, even if explicit
|
||||
parameters are specified, they are in X9.62 form, which cannot represent
|
||||
problem values as noted above.
|
||||
|
||||
Initially reported as oss-fuzz issue 71623.
|
||||
|
||||
A closely related issue was earlier reported in
|
||||
<https://github.com/openssl/openssl/issues/19826>.
|
||||
|
||||
Severity: Low, CVE-2024-9143
|
||||
|
||||
Reviewed-by: Matt Caswell <matt@openssl.org>
|
||||
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
|
||||
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/25639)
|
||||
|
||||
(cherry picked from commit 8e008cb8b23ec7dc75c45a66eeed09c815b11cd2)
|
||||
---
|
||||
crypto/bn/bn_gf2m.c | 28 +++++++++++++++-------
|
||||
test/ec_internal_test.c | 51 +++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 71 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c
|
||||
index c811ae82d6..bcc66613cc 100644
|
||||
--- a/crypto/bn/bn_gf2m.c
|
||||
+++ b/crypto/bn/bn_gf2m.c
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "bn_local.h"
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
+# include <openssl/ec.h>
|
||||
|
||||
/*
|
||||
* Maximum number of iterations before BN_GF2m_mod_solve_quad_arr should
|
||||
@@ -1140,16 +1141,26 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
/*
|
||||
* Convert the bit-string representation of a polynomial ( \sum_{i=0}^n a_i *
|
||||
* x^i) into an array of integers corresponding to the bits with non-zero
|
||||
- * coefficient. Array is terminated with -1. Up to max elements of the array
|
||||
- * will be filled. Return value is total number of array elements that would
|
||||
- * be filled if array was large enough.
|
||||
+ * coefficient. The array is intended to be suitable for use with
|
||||
+ * `BN_GF2m_mod_arr()`, and so the constant term of the polynomial must not be
|
||||
+ * zero. This translates to a requirement that the input BIGNUM `a` is odd.
|
||||
+ *
|
||||
+ * Given sufficient room, the array is terminated with -1. Up to max elements
|
||||
+ * of the array will be filled.
|
||||
+ *
|
||||
+ * The return value is total number of array elements that would be filled if
|
||||
+ * array was large enough, including the terminating `-1`. It is `0` when `a`
|
||||
+ * is not odd or the constant term is zero contrary to requirement.
|
||||
+ *
|
||||
+ * The return value is also `0` when the leading exponent exceeds
|
||||
+ * `OPENSSL_ECC_MAX_FIELD_BITS`, this guards against CPU exhaustion attacks,
|
||||
*/
|
||||
int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max)
|
||||
{
|
||||
int i, j, k = 0;
|
||||
BN_ULONG mask;
|
||||
|
||||
- if (BN_is_zero(a))
|
||||
+ if (!BN_is_odd(a))
|
||||
return 0;
|
||||
|
||||
for (i = a->top - 1; i >= 0; i--) {
|
||||
@@ -1167,12 +1178,13 @@ int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max)
|
||||
}
|
||||
}
|
||||
|
||||
- if (k < max) {
|
||||
+ if (k > 0 && p[0] > OPENSSL_ECC_MAX_FIELD_BITS)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (k < max)
|
||||
p[k] = -1;
|
||||
- k++;
|
||||
- }
|
||||
|
||||
- return k;
|
||||
+ return k + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
diff --git a/test/ec_internal_test.c b/test/ec_internal_test.c
|
||||
index 8c2cd05631..02cfd4e9d8 100644
|
||||
--- a/test/ec_internal_test.c
|
||||
+++ b/test/ec_internal_test.c
|
||||
@@ -155,6 +155,56 @@ static int field_tests_ecp_mont(void)
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
+/* Test that decoding of invalid GF2m field parameters fails. */
|
||||
+static int ec2m_field_sanity(void)
|
||||
+{
|
||||
+ int ret = 0;
|
||||
+ BN_CTX *ctx = BN_CTX_new();
|
||||
+ BIGNUM *p, *a, *b;
|
||||
+ EC_GROUP *group1 = NULL, *group2 = NULL, *group3 = NULL;
|
||||
+
|
||||
+ TEST_info("Testing GF2m hardening\n");
|
||||
+
|
||||
+ BN_CTX_start(ctx);
|
||||
+ p = BN_CTX_get(ctx);
|
||||
+ a = BN_CTX_get(ctx);
|
||||
+ if (!TEST_ptr(b = BN_CTX_get(ctx))
|
||||
+ || !TEST_true(BN_one(a))
|
||||
+ || !TEST_true(BN_one(b)))
|
||||
+ goto out;
|
||||
+
|
||||
+ /* Even pentanomial value should be rejected */
|
||||
+ if (!TEST_true(BN_set_word(p, 0xf2)))
|
||||
+ goto out;
|
||||
+ if (!TEST_ptr_null(group1 = EC_GROUP_new_curve_GF2m(p, a, b, ctx)))
|
||||
+ TEST_error("Zero constant term accepted in GF2m polynomial");
|
||||
+
|
||||
+ /* Odd hexanomial should also be rejected */
|
||||
+ if (!TEST_true(BN_set_word(p, 0xf3)))
|
||||
+ goto out;
|
||||
+ if (!TEST_ptr_null(group2 = EC_GROUP_new_curve_GF2m(p, a, b, ctx)))
|
||||
+ TEST_error("Hexanomial accepted as GF2m polynomial");
|
||||
+
|
||||
+ /* Excessive polynomial degree should also be rejected */
|
||||
+ if (!TEST_true(BN_set_word(p, 0x71))
|
||||
+ || !TEST_true(BN_set_bit(p, OPENSSL_ECC_MAX_FIELD_BITS + 1)))
|
||||
+ goto out;
|
||||
+ if (!TEST_ptr_null(group3 = EC_GROUP_new_curve_GF2m(p, a, b, ctx)))
|
||||
+ TEST_error("GF2m polynomial degree > %d accepted",
|
||||
+ OPENSSL_ECC_MAX_FIELD_BITS);
|
||||
+
|
||||
+ ret = group1 == NULL && group2 == NULL && group3 == NULL;
|
||||
+
|
||||
+ out:
|
||||
+ EC_GROUP_free(group1);
|
||||
+ EC_GROUP_free(group2);
|
||||
+ EC_GROUP_free(group3);
|
||||
+ BN_CTX_end(ctx);
|
||||
+ BN_CTX_free(ctx);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
/* test EC_GF2m_simple_method directly */
|
||||
static int field_tests_ec2_simple(void)
|
||||
{
|
||||
@@ -443,6 +493,7 @@ int setup_tests(void)
|
||||
ADD_TEST(field_tests_ecp_simple);
|
||||
ADD_TEST(field_tests_ecp_mont);
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
+ ADD_TEST(ec2m_field_sanity);
|
||||
ADD_TEST(field_tests_ec2_simple);
|
||||
#endif
|
||||
ADD_ALL_TESTS(field_tests_default, crv_len);
|
||||
--
|
||||
2.43.0.windows.1
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
From f4942134815f95845706993c15ca7e4fd6e44627 Mon Sep 17 00:00:00 2001
|
||||
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
|
||||
Date: Fri, 7 Jan 2022 10:18:58 +0100
|
||||
Subject: [PATCH] Fix password_callback to handle short passwords
|
||||
|
||||
Fixes #17426
|
||||
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/17439)
|
||||
---
|
||||
apps/apps.c | 8 ++++++--
|
||||
test/recipes/15-test_genrsa.t | 7 ++++++-
|
||||
2 files changed, 12 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/apps/apps.c b/apps/apps.c
|
||||
index c06241abb9..531fbec551 100644
|
||||
--- a/apps/apps.c
|
||||
+++ b/apps/apps.c
|
||||
@@ -300,9 +300,13 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp)
|
||||
int ui_flags = 0;
|
||||
const char *prompt_info = NULL;
|
||||
char *prompt;
|
||||
+ int pw_min_len = PW_MIN_LENGTH;
|
||||
|
||||
if (cb_data != NULL && cb_data->prompt_info != NULL)
|
||||
prompt_info = cb_data->prompt_info;
|
||||
+ if (cb_data != NULL && cb_data->password != NULL
|
||||
+ && *(const char*)cb_data->password != '\0')
|
||||
+ pw_min_len = 1;
|
||||
prompt = UI_construct_prompt(ui, "pass phrase", prompt_info);
|
||||
if (!prompt) {
|
||||
BIO_printf(bio_err, "Out of memory\n");
|
||||
@@ -317,12 +321,12 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp)
|
||||
(void)UI_add_user_data(ui, cb_data);
|
||||
|
||||
ok = UI_add_input_string(ui, prompt, ui_flags, buf,
|
||||
- PW_MIN_LENGTH, bufsiz - 1);
|
||||
+ pw_min_len, bufsiz - 1);
|
||||
|
||||
if (ok >= 0 && verify) {
|
||||
buff = app_malloc(bufsiz, "password buffer");
|
||||
ok = UI_add_verify_string(ui, prompt, ui_flags, buff,
|
||||
- PW_MIN_LENGTH, bufsiz - 1, buf);
|
||||
+ pw_min_len, bufsiz - 1, buf);
|
||||
}
|
||||
if (ok >= 0)
|
||||
do {
|
||||
diff --git a/test/recipes/15-test_genrsa.t b/test/recipes/15-test_genrsa.t
|
||||
index e16a9a4042..c9bc6bdc8a 100644
|
||||
--- a/test/recipes/15-test_genrsa.t
|
||||
+++ b/test/recipes/15-test_genrsa.t
|
||||
@@ -16,7 +16,7 @@ use OpenSSL::Test::Utils;
|
||||
|
||||
setup("test_genrsa");
|
||||
|
||||
-plan tests => 5;
|
||||
+plan tests => 7;
|
||||
|
||||
# We want to know that an absurdly small number of bits isn't support
|
||||
is(run(app([ 'openssl', 'genrsa', '-3', '-out', 'genrsatest.pem', '8'])), 0, "genrsa -3 8");
|
||||
@@ -52,3 +52,8 @@ ok(run(app([ 'openssl', 'genrsa', '-f4', '-out', 'genrsatest.pem', $good ])),
|
||||
"genrsa -f4 $good");
|
||||
ok(run(app([ 'openssl', 'rsa', '-check', '-in', 'genrsatest.pem', '-noout' ])),
|
||||
"rsa -check");
|
||||
+ok(run(app([ 'openssl', 'rsa', '-in', 'genrsatest.pem', '-out', 'genrsatest-enc.pem',
|
||||
+ '-aes256', '-passout', 'pass:x' ])),
|
||||
+ "rsa encrypt");
|
||||
+ok(run(app([ 'openssl', 'rsa', '-in', 'genrsatest-enc.pem', '-passin', 'pass:x' ])),
|
||||
+ "rsa decrypt");
|
||||
--
|
||||
Gitee
|
||||
@ -0,0 +1,45 @@
|
||||
From df9c7ceefef59cc870c80346906471fabec62494 Mon Sep 17 00:00:00 2001
|
||||
From: Matt Caswell <matt@openssl.org>
|
||||
Date: Fri, 21 Oct 2022 14:08:29 +0100
|
||||
Subject: [PATCH] Pipeline output/input buf arrays must live until the
|
||||
EVP_Cipher is called
|
||||
|
||||
Conflict:adapt context
|
||||
Reference:https://github.com/openssl/openssl/commit/df9c7ceefef59cc870c80346906471fabec62494
|
||||
|
||||
The pipeline input/output buf arrays must remain accessible to the
|
||||
EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an
|
||||
asan error discovered by the newly added pipeline test.
|
||||
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
Reviewed-by: Hugo Landau <hlandau@openssl.org>
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/20208)
|
||||
---
|
||||
ssl/record/ssl3_record.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/ssl/record/ssl3_record.c b/ssl/record/ssl3_record.c
|
||||
index 368aaea5e9..4256f29663 100644
|
||||
--- a/ssl/record/ssl3_record.c
|
||||
+++ b/ssl/record/ssl3_record.c
|
||||
@@ -964,6 +964,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int sending,
|
||||
EVP_CIPHER_CTX *ds;
|
||||
size_t reclen[SSL_MAX_PIPELINES];
|
||||
unsigned char buf[SSL_MAX_PIPELINES][EVP_AEAD_TLS1_AAD_LEN];
|
||||
+ unsigned char *data[SSL_MAX_PIPELINES];
|
||||
int i, pad = 0, ret, tmpr;
|
||||
size_t bs, mac_size = 0, ctr, padnum, loop;
|
||||
unsigned char padval;
|
||||
@@ -1123,8 +1124,6 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int sending,
|
||||
}
|
||||
}
|
||||
if (n_recs > 1) {
|
||||
- unsigned char *data[SSL_MAX_PIPELINES];
|
||||
-
|
||||
/* Set the output buffers */
|
||||
for (ctr = 0; ctr < n_recs; ctr++) {
|
||||
data[ctr] = recs[ctr].data;
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -75,13 +75,14 @@ index d701c46b43..79cfd1d835 100644
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
diff --git a/test/sslapitest.c b/test/sslapitest.c
|
||||
index 21322ceec5..09a732f577 100644
|
||||
index 650ff68..8b2ba80 100644
|
||||
--- a/test/sslapitest.c
|
||||
+++ b/test/sslapitest.c
|
||||
@@ -6734,6 +6734,64 @@ end:
|
||||
SSL_CTX_free(cctx);
|
||||
return testresult;
|
||||
@@ -6780,6 +6780,72 @@ static int test_ssl_dup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
+#ifndef OPENSSL_NO_TLS1_3
|
||||
+
|
||||
+/*
|
||||
+ * Test that the lifetime hint of a TLSv1.3 ticket is no more than 1 week
|
||||
@ -99,7 +100,12 @@ index 21322ceec5..09a732f577 100644
|
||||
+#define TWO_WEEK_SEC (2 * ONE_WEEK_SEC)
|
||||
+
|
||||
+ if (idx == 0) {
|
||||
+#ifdef OPENSSL_NO_TLS1_2
|
||||
+ TEST_info("Skipping: TLS 1.2 is disabled.");
|
||||
+ return 1;
|
||||
+#else
|
||||
+ version = TLS1_2_VERSION;
|
||||
+#endif
|
||||
+ }
|
||||
+
|
||||
+ if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(),
|
||||
@ -140,17 +146,21 @@ index 21322ceec5..09a732f577 100644
|
||||
+ SSL_CTX_free(cctx);
|
||||
+ return testresult;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
struct resume_servername_cb_data {
|
||||
int i;
|
||||
SSL_CTX *cctx;
|
||||
@@ -7077,6 +7143,9 @@ int setup_tests(void)
|
||||
#ifndef OPENSSL_NO_TLS1_2
|
||||
ADD_TEST(test_ssl_dup);
|
||||
#endif
|
||||
/*
|
||||
* Test that setting an ALPN does not violate RFC
|
||||
@@ -6973,6 +7031,7 @@ int setup_tests(void)
|
||||
+#ifndef OPENSSL_NO_TLS1_3
|
||||
+ ADD_TEST(test_ticket_lifetime);
|
||||
+#endif
|
||||
#if !defined(OPENSSL_NO_TLS1_2) || !defined(OPENSSL_NO_TLS1_3)
|
||||
ADD_ALL_TESTS(test_session_cache_overflow, 4);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1_3
|
||||
ADD_TEST(test_sni_tls13);
|
||||
+ ADD_ALL_TESTS(test_ticket_lifetime, 2);
|
||||
#endif
|
||||
ADD_TEST(test_set_alpn);
|
||||
ADD_TEST(test_inherit_verify_param);
|
||||
--
|
||||
2.17.1
|
||||
|
||||
|
||||
Binary file not shown.
24
openssl.spec
24
openssl.spec
@ -2,7 +2,7 @@
|
||||
Name: openssl
|
||||
Epoch: 1
|
||||
Version: 1.1.1f
|
||||
Release: 34
|
||||
Release: 39
|
||||
Summary: Cryptography and SSL/TLS Toolkit
|
||||
License: OpenSSL and SSLeay and GPLv2+
|
||||
URL: https://www.openssl.org/
|
||||
@ -142,6 +142,13 @@ Patch131: backport-Add-a-test-for-session-cache-overflow.patch
|
||||
Patch132: backport-CVE-2024-4741-Only-free-the-read-buffer.patch
|
||||
Patch133: backport-CVE-2024-4741-Set-rlayer.packet-to-NULL-after-we-ve-.patch
|
||||
Patch134: backport-CVE-2024-4741-test-Fix-possible-use-after-free.patch
|
||||
Patch135: backport-CVE-2024-5535-Fix-SSL_select_next_proto-and-add-ALPN.patch
|
||||
Patch136: backport-Pipeline-output-input-buf-arrays-must-live-until-the.patch
|
||||
Patch137: backport-Fix-password_callback-to-handle-short-passwords.patch
|
||||
Patch138: backport-Check-password-length-only-when-verify-is-enabled.patch
|
||||
Patch139: backport-ticket_lifetime_hint-may-exceed-1-week-in-TLSv1.3.patch
|
||||
Patch140: backport-CVE-2024-9143-Harden-BN_GF2m_poly2arr-against-misuse.patch
|
||||
Patch141: backport-CVE-2024-13176-Fix-timing-side-channel.patch
|
||||
|
||||
BuildRequires: gcc make lksctp-tools-devel coreutils util-linux zlib-devel
|
||||
|
||||
@ -325,6 +332,21 @@ make test || :
|
||||
%{_pkgdocdir}/html/
|
||||
|
||||
%changelog
|
||||
* Wed Feb 5 2025 jinlun <jinlun@huawei.com> - 1:1.1.1f-39
|
||||
- fix CVE-2024-13176
|
||||
|
||||
* Wed Nov 27 2024 liningjie <liningjie@xfusion.com> - 1:1.1.1f-38
|
||||
- fix CVE-2024-9143
|
||||
|
||||
* Sat Nov 16 2024 liningjie <liningjie@xfusion.com> - 1:1.1.1f-37
|
||||
- fix CI build error
|
||||
|
||||
* Fri Oct 11 2024 hugel <gengqihu2@h-partners.com> - 1:1.1.1f-36
|
||||
- fix openssl asan error
|
||||
|
||||
* Thu Jul 4 2024 steven <steven_ygui@163.com> - 1:1.1.1f-35
|
||||
- fix CVE-2024-5535
|
||||
|
||||
* Mon Jun 3 2024 wangcheng <wangcheng156@huawei.com> - 1:1.1.1f-34
|
||||
- fix CVE-2024-4741
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user