Compare commits
No commits in common. "2c8650dc704d944ead22790d1ddd282b3fb233e6" and "0ba6e4b9b30d5c5fec3b17786bfe5e8219a42f9e" have entirely different histories.
2c8650dc70
...
0ba6e4b9b3
@ -1,461 +0,0 @@
|
||||
From 3f499b24f3bcd66db022074f7e8b4f6ee266a3ae Mon Sep 17 00:00:00 2001
|
||||
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
|
||||
Date: Mon, 13 Feb 2023 17:46:41 +0100
|
||||
Subject: [PATCH] Alternative fix for CVE-2022-4304
|
||||
|
||||
This is about a timing leak in the topmost limb
|
||||
of the internal result of RSA_private_decrypt,
|
||||
before the padding check.
|
||||
|
||||
There are in fact at least three bugs together that
|
||||
caused the timing leak:
|
||||
|
||||
First and probably most important is the fact that
|
||||
the blinding did not use the constant time code path
|
||||
at all when the RSA object was used for a private
|
||||
decrypt, due to the fact that the Montgomery context
|
||||
rsa->_method_mod_n was not set up early enough in
|
||||
rsa_ossl_private_decrypt, when BN_BLINDING_create_param
|
||||
needed it, and that was persisted as blinding->m_ctx,
|
||||
although the RSA object creates the Montgomery context
|
||||
just a bit later.
|
||||
|
||||
Then the infamous bn_correct_top was used on the
|
||||
secret value right after the blinding was removed.
|
||||
|
||||
And finally the function BN_bn2binpad did not use
|
||||
the constant-time code path since the BN_FLG_CONSTTIME
|
||||
was not set on the secret value.
|
||||
|
||||
In order to address the first problem, this patch
|
||||
makes sure that the rsa->_method_mod_n is initialized
|
||||
right before the blinding context.
|
||||
|
||||
And to fix the second problem, we add a new utility
|
||||
function bn_correct_top_consttime, a const-time
|
||||
variant of bn_correct_top.
|
||||
|
||||
Together with the fact, that BN_bn2binpad is already
|
||||
constant time if the flag BN_FLG_CONSTTIME is set,
|
||||
this should eliminate the timing oracle completely.
|
||||
|
||||
In addition the no-asm variant may also have
|
||||
branches that depend on secret values, because the last
|
||||
invocation of bn_sub_words in bn_from_montgomery_word
|
||||
had branches when the function is compiled by certain
|
||||
gcc compiler versions, due to the clumsy coding style.
|
||||
|
||||
So additionally this patch stream-lined the no-asm
|
||||
C-code in order to avoid branches where possible and
|
||||
improve the resulting code quality.
|
||||
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/20284)
|
||||
|
||||
Reference:https://github.com/openssl/openssl/commit/3f499b24f3bcd66db022074f7e8b4f6ee266a3ae
|
||||
Confilts:CHANGES
|
||||
---
|
||||
crypto/bn/bn_asm.c | 106 +++++++++++++++++++++++-------------------
|
||||
crypto/bn/bn_blind.c | 3 +-
|
||||
crypto/bn/bn_lib.c | 22 +++++++++
|
||||
crypto/bn/bn_local.h | 26 +++++------
|
||||
crypto/rsa/rsa_ossl.c | 13 +++---
|
||||
5 files changed, 101 insertions(+), 69 deletions(-)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_asm.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_asm.c
|
||||
index 4d83a8cf11..177558c647 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_asm.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_asm.c
|
||||
@@ -381,25 +381,33 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
#ifndef OPENSSL_SMALL_FOOTPRINT
|
||||
while (n & ~3) {
|
||||
t1 = a[0];
|
||||
- t2 = b[0];
|
||||
- r[0] = (t1 - t2 - c) & BN_MASK2;
|
||||
- if (t1 != t2)
|
||||
- c = (t1 < t2);
|
||||
+ t2 = (t1 - c) & BN_MASK2;
|
||||
+ c = (t2 > t1);
|
||||
+ t1 = b[0];
|
||||
+ t1 = (t2 - t1) & BN_MASK2;
|
||||
+ r[0] = t1;
|
||||
+ c += (t1 > t2);
|
||||
t1 = a[1];
|
||||
- t2 = b[1];
|
||||
- r[1] = (t1 - t2 - c) & BN_MASK2;
|
||||
- if (t1 != t2)
|
||||
- c = (t1 < t2);
|
||||
+ t2 = (t1 - c) & BN_MASK2;
|
||||
+ c = (t2 > t1);
|
||||
+ t1 = b[1];
|
||||
+ t1 = (t2 - t1) & BN_MASK2;
|
||||
+ r[1] = t1;
|
||||
+ c += (t1 > t2);
|
||||
t1 = a[2];
|
||||
- t2 = b[2];
|
||||
- r[2] = (t1 - t2 - c) & BN_MASK2;
|
||||
- if (t1 != t2)
|
||||
- c = (t1 < t2);
|
||||
+ t2 = (t1 - c) & BN_MASK2;
|
||||
+ c = (t2 > t1);
|
||||
+ t1 = b[2];
|
||||
+ t1 = (t2 - t1) & BN_MASK2;
|
||||
+ r[2] = t1;
|
||||
+ c += (t1 > t2);
|
||||
t1 = a[3];
|
||||
- t2 = b[3];
|
||||
- r[3] = (t1 - t2 - c) & BN_MASK2;
|
||||
- if (t1 != t2)
|
||||
- c = (t1 < t2);
|
||||
+ t2 = (t1 - c) & BN_MASK2;
|
||||
+ c = (t2 > t1);
|
||||
+ t1 = b[3];
|
||||
+ t1 = (t2 - t1) & BN_MASK2;
|
||||
+ r[3] = t1;
|
||||
+ c += (t1 > t2);
|
||||
a += 4;
|
||||
b += 4;
|
||||
r += 4;
|
||||
@@ -408,10 +416,12 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
#endif
|
||||
while (n) {
|
||||
t1 = a[0];
|
||||
- t2 = b[0];
|
||||
- r[0] = (t1 - t2 - c) & BN_MASK2;
|
||||
- if (t1 != t2)
|
||||
- c = (t1 < t2);
|
||||
+ t2 = (t1 - c) & BN_MASK2;
|
||||
+ c = (t2 > t1);
|
||||
+ t1 = b[0];
|
||||
+ t1 = (t2 - t1) & BN_MASK2;
|
||||
+ r[0] = t1;
|
||||
+ c += (t1 > t2);
|
||||
a++;
|
||||
b++;
|
||||
r++;
|
||||
@@ -446,7 +456,7 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
t += c0; /* no carry */ \
|
||||
c0 = (BN_ULONG)Lw(t); \
|
||||
hi = (BN_ULONG)Hw(t); \
|
||||
- c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
+ c1 = (c1+hi)&BN_MASK2; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define mul_add_c2(a,b,c0,c1,c2) do { \
|
||||
@@ -455,11 +465,11 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
BN_ULLONG tt = t+c0; /* no carry */ \
|
||||
c0 = (BN_ULONG)Lw(tt); \
|
||||
hi = (BN_ULONG)Hw(tt); \
|
||||
- c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
+ c1 = (c1+hi)&BN_MASK2; c2 += (c1<hi); \
|
||||
t += c0; /* no carry */ \
|
||||
c0 = (BN_ULONG)Lw(t); \
|
||||
hi = (BN_ULONG)Hw(t); \
|
||||
- c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
+ c1 = (c1+hi)&BN_MASK2; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define sqr_add_c(a,i,c0,c1,c2) do { \
|
||||
@@ -468,7 +478,7 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
t += c0; /* no carry */ \
|
||||
c0 = (BN_ULONG)Lw(t); \
|
||||
hi = (BN_ULONG)Hw(t); \
|
||||
- c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
+ c1 = (c1+hi)&BN_MASK2; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
@@ -483,26 +493,26 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
BN_ULONG ta = (a), tb = (b); \
|
||||
BN_ULONG lo, hi; \
|
||||
BN_UMULT_LOHI(lo,hi,ta,tb); \
|
||||
- c0 += lo; hi += (c0<lo)?1:0; \
|
||||
- c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
+ c0 += lo; hi += (c0<lo); \
|
||||
+ c1 += hi; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define mul_add_c2(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a), tb = (b); \
|
||||
BN_ULONG lo, hi, tt; \
|
||||
BN_UMULT_LOHI(lo,hi,ta,tb); \
|
||||
- c0 += lo; tt = hi+((c0<lo)?1:0); \
|
||||
- c1 += tt; c2 += (c1<tt)?1:0; \
|
||||
- c0 += lo; hi += (c0<lo)?1:0; \
|
||||
- c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
+ c0 += lo; tt = hi + (c0<lo); \
|
||||
+ c1 += tt; c2 += (c1<tt); \
|
||||
+ c0 += lo; hi += (c0<lo); \
|
||||
+ c1 += hi; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define sqr_add_c(a,i,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a)[i]; \
|
||||
BN_ULONG lo, hi; \
|
||||
BN_UMULT_LOHI(lo,hi,ta,ta); \
|
||||
- c0 += lo; hi += (c0<lo)?1:0; \
|
||||
- c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
+ c0 += lo; hi += (c0<lo); \
|
||||
+ c1 += hi; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
@@ -517,26 +527,26 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
BN_ULONG ta = (a), tb = (b); \
|
||||
BN_ULONG lo = ta * tb; \
|
||||
BN_ULONG hi = BN_UMULT_HIGH(ta,tb); \
|
||||
- c0 += lo; hi += (c0<lo)?1:0; \
|
||||
- c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
+ c0 += lo; hi += (c0<lo); \
|
||||
+ c1 += hi; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define mul_add_c2(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a), tb = (b), tt; \
|
||||
BN_ULONG lo = ta * tb; \
|
||||
BN_ULONG hi = BN_UMULT_HIGH(ta,tb); \
|
||||
- c0 += lo; tt = hi + ((c0<lo)?1:0); \
|
||||
- c1 += tt; c2 += (c1<tt)?1:0; \
|
||||
- c0 += lo; hi += (c0<lo)?1:0; \
|
||||
- c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
+ c0 += lo; tt = hi + (c0<lo); \
|
||||
+ c1 += tt; c2 += (c1<tt); \
|
||||
+ c0 += lo; hi += (c0<lo); \
|
||||
+ c1 += hi; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define sqr_add_c(a,i,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a)[i]; \
|
||||
BN_ULONG lo = ta * ta; \
|
||||
BN_ULONG hi = BN_UMULT_HIGH(ta,ta); \
|
||||
- c0 += lo; hi += (c0<lo)?1:0; \
|
||||
- c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
+ c0 += lo; hi += (c0<lo); \
|
||||
+ c1 += hi; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
@@ -551,8 +561,8 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
BN_ULONG lo = LBITS(a), hi = HBITS(a); \
|
||||
BN_ULONG bl = LBITS(b), bh = HBITS(b); \
|
||||
mul64(lo,hi,bl,bh); \
|
||||
- c0 = (c0+lo)&BN_MASK2; if (c0<lo) hi++; \
|
||||
- c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
+ c0 = (c0+lo)&BN_MASK2; hi += (c0<lo); \
|
||||
+ c1 = (c1+hi)&BN_MASK2; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define mul_add_c2(a,b,c0,c1,c2) do { \
|
||||
@@ -561,17 +571,17 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
BN_ULONG bl = LBITS(b), bh = HBITS(b); \
|
||||
mul64(lo,hi,bl,bh); \
|
||||
tt = hi; \
|
||||
- c0 = (c0+lo)&BN_MASK2; if (c0<lo) tt++; \
|
||||
- c1 = (c1+tt)&BN_MASK2; if (c1<tt) c2++; \
|
||||
- c0 = (c0+lo)&BN_MASK2; if (c0<lo) hi++; \
|
||||
- c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
+ c0 = (c0+lo)&BN_MASK2; tt += (c0<lo); \
|
||||
+ c1 = (c1+tt)&BN_MASK2; c2 += (c1<tt); \
|
||||
+ c0 = (c0+lo)&BN_MASK2; hi += (c0<lo); \
|
||||
+ c1 = (c1+hi)&BN_MASK2; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define sqr_add_c(a,i,c0,c1,c2) do { \
|
||||
BN_ULONG lo, hi; \
|
||||
sqr64(lo,hi,(a)[i]); \
|
||||
- c0 = (c0+lo)&BN_MASK2; if (c0<lo) hi++; \
|
||||
- c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
+ c0 = (c0+lo)&BN_MASK2; hi += (c0<lo); \
|
||||
+ c1 = (c1+hi)&BN_MASK2; c2 += (c1<hi); \
|
||||
} while(0)
|
||||
|
||||
# define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_blind.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_blind.c
|
||||
index 15d9e0a544..e76f6107a7 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_blind.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_blind.c
|
||||
@@ -191,7 +191,8 @@ int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b,
|
||||
n->top = (int)(rtop & ~mask) | (ntop & mask);
|
||||
n->flags |= (BN_FLG_FIXED_TOP & ~mask);
|
||||
}
|
||||
- ret = BN_mod_mul_montgomery(n, n, r, b->m_ctx, ctx);
|
||||
+ ret = bn_mul_mont_fixed_top(n, n, r, b->m_ctx, ctx);
|
||||
+ bn_correct_top_consttime(n);
|
||||
} else {
|
||||
ret = BN_mod_mul(n, n, r, b->mod, ctx);
|
||||
}
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_lib.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_lib.c
|
||||
index eb4a31849b..fe6fb0e40f 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_lib.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_lib.c
|
||||
@@ -1001,6 +1001,28 @@ BIGNUM *bn_wexpand(BIGNUM *a, int words)
|
||||
return (words <= a->dmax) ? a : bn_expand2(a, words);
|
||||
}
|
||||
|
||||
+void bn_correct_top_consttime(BIGNUM *a)
|
||||
+{
|
||||
+ int j, atop;
|
||||
+ BN_ULONG limb;
|
||||
+ unsigned int mask;
|
||||
+
|
||||
+ for (j = 0, atop = 0; j < a->dmax; j++) {
|
||||
+ limb = a->d[j];
|
||||
+ limb |= 0 - limb;
|
||||
+ limb >>= BN_BITS2 - 1;
|
||||
+ limb = 0 - limb;
|
||||
+ mask = (unsigned int)limb;
|
||||
+ mask &= constant_time_msb(j - a->top);
|
||||
+ atop = constant_time_select_int(mask, j + 1, atop);
|
||||
+ }
|
||||
+
|
||||
+ mask = constant_time_eq_int(atop, 0);
|
||||
+ a->top = atop;
|
||||
+ a->neg = constant_time_select_int(mask, 0, a->neg);
|
||||
+ a->flags &= ~BN_FLG_FIXED_TOP;
|
||||
+}
|
||||
+
|
||||
void bn_correct_top(BIGNUM *a)
|
||||
{
|
||||
BN_ULONG *ftl;
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_local.h b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_local.h
|
||||
index ee6342b60c..818e34348e 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_local.h
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/bn/bn_local.h
|
||||
@@ -515,10 +515,10 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
|
||||
ret = (r); \
|
||||
BN_UMULT_LOHI(low,high,w,tmp); \
|
||||
ret += (c); \
|
||||
- (c) = (ret<(c))?1:0; \
|
||||
+ (c) = (ret<(c)); \
|
||||
(c) += high; \
|
||||
ret += low; \
|
||||
- (c) += (ret<low)?1:0; \
|
||||
+ (c) += (ret<low); \
|
||||
(r) = ret; \
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
|
||||
BN_UMULT_LOHI(low,high,w,ta); \
|
||||
ret = low + (c); \
|
||||
(c) = high; \
|
||||
- (c) += (ret<low)?1:0; \
|
||||
+ (c) += (ret<low); \
|
||||
(r) = ret; \
|
||||
}
|
||||
|
||||
@@ -543,10 +543,10 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
|
||||
high= BN_UMULT_HIGH(w,tmp); \
|
||||
ret += (c); \
|
||||
low = (w) * tmp; \
|
||||
- (c) = (ret<(c))?1:0; \
|
||||
+ (c) = (ret<(c)); \
|
||||
(c) += high; \
|
||||
ret += low; \
|
||||
- (c) += (ret<low)?1:0; \
|
||||
+ (c) += (ret<low); \
|
||||
(r) = ret; \
|
||||
}
|
||||
|
||||
@@ -556,7 +556,7 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
|
||||
high= BN_UMULT_HIGH(w,ta); \
|
||||
ret = low + (c); \
|
||||
(c) = high; \
|
||||
- (c) += (ret<low)?1:0; \
|
||||
+ (c) += (ret<low); \
|
||||
(r) = ret; \
|
||||
}
|
||||
|
||||
@@ -589,10 +589,10 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
|
||||
lt=(bl)*(lt); \
|
||||
m1=(bl)*(ht); \
|
||||
ht =(bh)*(ht); \
|
||||
- m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \
|
||||
+ m=(m+m1)&BN_MASK2; ht += L2HBITS((BN_ULONG)(m < m1)); \
|
||||
ht+=HBITS(m); \
|
||||
m1=L2HBITS(m); \
|
||||
- lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
|
||||
+ lt=(lt+m1)&BN_MASK2; ht += (lt < m1); \
|
||||
(l)=lt; \
|
||||
(h)=ht; \
|
||||
}
|
||||
@@ -609,7 +609,7 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
|
||||
h*=h; \
|
||||
h+=(m&BN_MASK2h1)>>(BN_BITS4-1); \
|
||||
m =(m&BN_MASK2l)<<(BN_BITS4+1); \
|
||||
- l=(l+m)&BN_MASK2; if (l < m) h++; \
|
||||
+ l=(l+m)&BN_MASK2; h += (l < m); \
|
||||
(lo)=l; \
|
||||
(ho)=h; \
|
||||
}
|
||||
@@ -623,9 +623,9 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
|
||||
mul64(l,h,(bl),(bh)); \
|
||||
\
|
||||
/* non-multiply part */ \
|
||||
- l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
|
||||
+ l=(l+(c))&BN_MASK2; h += (l < (c)); \
|
||||
(c)=(r); \
|
||||
- l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
|
||||
+ l=(l+(c))&BN_MASK2; h += (l < (c)); \
|
||||
(c)=h&BN_MASK2; \
|
||||
(r)=l; \
|
||||
}
|
||||
@@ -639,7 +639,7 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
|
||||
mul64(l,h,(bl),(bh)); \
|
||||
\
|
||||
/* non-multiply part */ \
|
||||
- l+=(c); if ((l&BN_MASK2) < (c)) h++; \
|
||||
+ l+=(c); h += ((l&BN_MASK2) < (c)); \
|
||||
(c)=h&BN_MASK2; \
|
||||
(r)=l&BN_MASK2; \
|
||||
}
|
||||
@@ -669,7 +669,7 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
int cl, int dl);
|
||||
int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
|
||||
const BN_ULONG *np, const BN_ULONG *n0, int num);
|
||||
-
|
||||
+void bn_correct_top_consttime(BIGNUM *a);
|
||||
BIGNUM *int_bn_mod_inverse(BIGNUM *in,
|
||||
const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx,
|
||||
int *noinv);
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/rsa/rsa_ossl.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/rsa/rsa_ossl.c
|
||||
index 53cf2d03c9..cf5a10ab43 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/rsa/rsa_ossl.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/rsa/rsa_ossl.c
|
||||
@@ -226,6 +226,7 @@ static int rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind,
|
||||
* will only read the modulus from BN_BLINDING. In both cases it's safe
|
||||
* to access the blinding without a lock.
|
||||
*/
|
||||
+ BN_set_flags(f, BN_FLG_CONSTTIME);
|
||||
return BN_BLINDING_invert_ex(f, unblind, b, ctx);
|
||||
}
|
||||
|
||||
@@ -412,6 +413,11 @@ static int rsa_ossl_private_decrypt(int flen, const unsigned char *from,
|
||||
goto err;
|
||||
}
|
||||
|
||||
+ if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
|
||||
+ if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, rsa->lock,
|
||||
+ rsa->n, ctx))
|
||||
+ goto err;
|
||||
+
|
||||
if (!(rsa->flags & RSA_FLAG_NO_BLINDING)) {
|
||||
blinding = rsa_get_blinding(rsa, &local_blinding, ctx);
|
||||
if (blinding == NULL) {
|
||||
@@ -449,13 +455,6 @@ static int rsa_ossl_private_decrypt(int flen, const unsigned char *from,
|
||||
goto err;
|
||||
}
|
||||
BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME);
|
||||
-
|
||||
- if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
|
||||
- if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, rsa->lock,
|
||||
- rsa->n, ctx)) {
|
||||
- BN_free(d);
|
||||
- goto err;
|
||||
- }
|
||||
if (!rsa->meth->bn_mod_exp(ret, f, d, rsa->n, ctx,
|
||||
rsa->_method_mod_n)) {
|
||||
BN_free(d);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,367 +0,0 @@
|
||||
From 55815e423bb82cc828836bbd60c79c1f9a195763 Mon Sep 17 00:00:00 2001
|
||||
From: Deanna Garcia <deannagarcia@google.com>
|
||||
Date: Tue, 13 Sep 2022 17:20:00 +0000
|
||||
Subject: [PATCH] Apply patch
|
||||
|
||||
Reference:https://github.com/protocolbuffers/protobuf/commit/55815e423bb82cc828836bbd60c79c1f9a195763
|
||||
Conflict: Changing the Source File Path
|
||||
---
|
||||
src/google/protobuf/extension_set_inl.h | 27 +++--
|
||||
src/google/protobuf/wire_format.cc | 26 +++--
|
||||
src/google/protobuf/wire_format_lite.h | 27 +++--
|
||||
src/google/protobuf/wire_format_unittest.cc | 109 ++++++++++++++++++--
|
||||
4 files changed, 152 insertions(+), 37 deletions(-)
|
||||
|
||||
diff --git a/external/protobuf/protobuf_code/src/google/protobuf/extension_set_inl.h b/external/protobuf/protobuf_code/src/google/protobuf/extension_set_inl.h
|
||||
index 074784b96d5..77f95f62fd5 100644
|
||||
--- a/external/protobuf/protobuf_code/src/google/protobuf/extension_set_inl.h
|
||||
+++ b/external/protobuf/protobuf_code/src/google/protobuf/extension_set_inl.h
|
||||
@@ -206,16 +206,21 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(
|
||||
const char* ptr, const Msg* containing_type,
|
||||
internal::InternalMetadata* metadata, internal::ParseContext* ctx) {
|
||||
std::string payload;
|
||||
- uint32 type_id = 0;
|
||||
- bool payload_read = false;
|
||||
+ uint32 type_id;
|
||||
+ enum class State { kNoTag, kHasType, kHasPayload, kDone };
|
||||
+ State state = State::kNoTag;
|
||||
+
|
||||
while (!ctx->Done(&ptr)) {
|
||||
uint32 tag = static_cast<uint8>(*ptr++);
|
||||
if (tag == WireFormatLite::kMessageSetTypeIdTag) {
|
||||
uint64 tmp;
|
||||
ptr = ParseBigVarint(ptr, &tmp);
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
- type_id = tmp;
|
||||
- if (payload_read) {
|
||||
+ if (state == State::kNoTag) {
|
||||
+ type_id = tmp;
|
||||
+ state = State::kHasType;
|
||||
+ } else if (state == State::kHasPayload) {
|
||||
+ type_id = tmp;
|
||||
ExtensionInfo extension;
|
||||
bool was_packed_on_wire;
|
||||
if (!FindExtension(2, type_id, containing_type, ctx, &extension,
|
||||
@@ -241,20 +246,24 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(value->_InternalParse(p, &tmp_ctx) &&
|
||||
tmp_ctx.EndedAtLimit());
|
||||
}
|
||||
- type_id = 0;
|
||||
+ state = State::kDone;
|
||||
}
|
||||
} else if (tag == WireFormatLite::kMessageSetMessageTag) {
|
||||
- if (type_id != 0) {
|
||||
+ if (state == State::kHasType) {
|
||||
ptr = ParseFieldMaybeLazily(static_cast<uint64>(type_id) * 8 + 2, ptr,
|
||||
containing_type, metadata, ctx);
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
|
||||
- type_id = 0;
|
||||
+ state = State::kDone;
|
||||
} else {
|
||||
+ std::string tmp;
|
||||
int32 size = ReadSize(&ptr);
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
- ptr = ctx->ReadString(ptr, size, &payload);
|
||||
+ ptr = ctx->ReadString(ptr, size, &tmp);
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
- payload_read = true;
|
||||
+ if (state == State::kNoTag) {
|
||||
+ payload = std::move(tmp);
|
||||
+ state = State::kHasPayload;
|
||||
+ }
|
||||
}
|
||||
} else {
|
||||
ptr = ReadTag(ptr - 1, &tag);
|
||||
diff --git a/external/protobuf/protobuf_code/src/google/protobuf/wire_format.cc b/external/protobuf/protobuf_code/src/google/protobuf/wire_format.cc
|
||||
index c30b7abff63..382d01ea0cf 100644
|
||||
--- a/external/protobuf/protobuf_code/src/google/protobuf/wire_format.cc
|
||||
+++ b/external/protobuf/protobuf_code/src/google/protobuf/wire_format.cc
|
||||
@@ -657,9 +657,11 @@ struct WireFormat::MessageSetParser {
|
||||
const char* _InternalParse(const char* ptr, internal::ParseContext* ctx) {
|
||||
// Parse a MessageSetItem
|
||||
auto metadata = reflection->MutableInternalMetadata(msg);
|
||||
+ enum class State { kNoTag, kHasType, kHasPayload, kDone };
|
||||
+ State state = State::kNoTag;
|
||||
+
|
||||
std::string payload;
|
||||
uint32 type_id = 0;
|
||||
- bool payload_read = false;
|
||||
while (!ctx->Done(&ptr)) {
|
||||
// We use 64 bit tags in order to allow typeid's that span the whole
|
||||
// range of 32 bit numbers.
|
||||
@@ -668,8 +670,11 @@ struct WireFormat::MessageSetParser {
|
||||
uint64 tmp;
|
||||
ptr = ParseBigVarint(ptr, &tmp);
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
- type_id = tmp;
|
||||
- if (payload_read) {
|
||||
+ if (state == State::kNoTag) {
|
||||
+ type_id = tmp;
|
||||
+ state = State::kHasType;
|
||||
+ } else if (state == State::kHasPayload) {
|
||||
+ type_id = tmp;
|
||||
const FieldDescriptor* field;
|
||||
if (ctx->data().pool == nullptr) {
|
||||
field = reflection->FindKnownExtensionByNumber(type_id);
|
||||
@@ -696,17 +701,17 @@ struct WireFormat::MessageSetParser {
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(value->_InternalParse(p, &tmp_ctx) &&
|
||||
tmp_ctx.EndedAtLimit());
|
||||
}
|
||||
- type_id = 0;
|
||||
+ state = State::kDone;
|
||||
}
|
||||
continue;
|
||||
} else if (tag == WireFormatLite::kMessageSetMessageTag) {
|
||||
- if (type_id == 0) {
|
||||
+ if (state == State::kNoTag) {
|
||||
int32 size = ReadSize(&ptr);
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
ptr = ctx->ReadString(ptr, size, &payload);
|
||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
- payload_read = true;
|
||||
- } else {
|
||||
+ state = State::kHasPayload;
|
||||
+ } else if (state == State::kHasType) {
|
||||
// We're now parsing the payload
|
||||
const FieldDescriptor* field = nullptr;
|
||||
if (descriptor->IsExtensionNumber(type_id)) {
|
||||
@@ -720,7 +725,12 @@ struct WireFormat::MessageSetParser {
|
||||
ptr = WireFormat::_InternalParseAndMergeField(
|
||||
msg, ptr, ctx, static_cast<uint64>(type_id) * 8 + 2, reflection,
|
||||
field);
|
||||
- type_id = 0;
|
||||
+ state = State::kDone;
|
||||
+ } else {
|
||||
+ int32 size = ReadSize(&ptr);
|
||||
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
+ ptr = ctx->Skip(ptr, size);
|
||||
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
||||
}
|
||||
} else {
|
||||
// An unknown field in MessageSetItem.
|
||||
diff --git a/external/protobuf/protobuf_code/src/google/protobuf/wire_format_lite.h b/external/protobuf/protobuf_code/src/google/protobuf/wire_format_lite.h
|
||||
index f2a3cad8281..0b13096ccbf 100644
|
||||
--- a/external/protobuf/protobuf_code/src/google/protobuf/wire_format_lite.h
|
||||
+++ b/external/protobuf/protobuf_code/src/google/protobuf/wire_format_lite.h
|
||||
@@ -1798,6 +1798,9 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
|
||||
// we can parse it later.
|
||||
std::string message_data;
|
||||
|
||||
+ enum class State { kNoTag, kHasType, kHasPayload, kDone };
|
||||
+ State state = State::kNoTag;
|
||||
+
|
||||
while (true) {
|
||||
const uint32 tag = input->ReadTagNoLastTag();
|
||||
if (tag == 0) return false;
|
||||
@@ -1806,26 +1809,34 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
|
||||
case WireFormatLite::kMessageSetTypeIdTag: {
|
||||
uint32 type_id;
|
||||
if (!input->ReadVarint32(&type_id)) return false;
|
||||
- last_type_id = type_id;
|
||||
-
|
||||
- if (!message_data.empty()) {
|
||||
+ if (state == State::kNoTag) {
|
||||
+ last_type_id = type_id;
|
||||
+ state = State::kHasType;
|
||||
+ } else if (state == State::kHasPayload) {
|
||||
// We saw some message data before the type_id. Have to parse it
|
||||
// now.
|
||||
io::CodedInputStream sub_input(
|
||||
reinterpret_cast<const uint8*>(message_data.data()),
|
||||
static_cast<int>(message_data.size()));
|
||||
sub_input.SetRecursionLimit(input->RecursionBudget());
|
||||
- if (!ms.ParseField(last_type_id, &sub_input)) {
|
||||
+ if (!ms.ParseField(type_id, &sub_input)) {
|
||||
return false;
|
||||
}
|
||||
message_data.clear();
|
||||
+ state = State::kDone;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WireFormatLite::kMessageSetMessageTag: {
|
||||
- if (last_type_id == 0) {
|
||||
+ if (state == State::kHasType) {
|
||||
+ // Already saw type_id, so we can parse this directly.
|
||||
+ if (!ms.ParseField(last_type_id, input)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ state = State::kDone;
|
||||
+ } else if (state == State::kNoTag) {
|
||||
// We haven't seen a type_id yet. Append this data to message_data.
|
||||
uint32 length;
|
||||
if (!input->ReadVarint32(&length)) return false;
|
||||
@@ -1836,11 +1847,9 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
|
||||
auto ptr = reinterpret_cast<uint8*>(&message_data[0]);
|
||||
ptr = io::CodedOutputStream::WriteVarint32ToArray(length, ptr);
|
||||
if (!input->ReadRaw(ptr, length)) return false;
|
||||
+ state = State::kHasPayload;
|
||||
} else {
|
||||
- // Already saw type_id, so we can parse this directly.
|
||||
- if (!ms.ParseField(last_type_id, input)) {
|
||||
- return false;
|
||||
- }
|
||||
+ if (!ms.SkipField(tag, input)) return false;
|
||||
}
|
||||
|
||||
break;
|
||||
diff --git a/external/protobuf/protobuf_code/src/google/protobuf/wire_format_unittest.cc b/external/protobuf/protobuf_code/src/google/protobuf/wire_format_unittest.cc
|
||||
index e75fc316f87..8d767b2833e 100644
|
||||
--- a/external/protobuf/protobuf_code/src/google/protobuf/wire_format_unittest.cc
|
||||
+++ b/external/protobuf/protobuf_code/src/google/protobuf/wire_format_unittest.cc
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
||||
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
+#include <google/protobuf/dynamic_message.h>
|
||||
#include <google/protobuf/wire_format_lite.h>
|
||||
#include <google/protobuf/testing/googletest.h>
|
||||
#include <google/protobuf/stubs/logging.h>
|
||||
@@ -585,30 +586,56 @@ TEST(WireFormatTest, ParseMessageSet) {
|
||||
EXPECT_EQ(message_set.DebugString(), dynamic_message_set.DebugString());
|
||||
}
|
||||
|
||||
-TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) {
|
||||
+namespace {
|
||||
+std::string BuildMessageSetItemStart() {
|
||||
std::string data;
|
||||
{
|
||||
- unittest::TestMessageSetExtension1 message;
|
||||
- message.set_i(123);
|
||||
- // Build a MessageSet manually with its message content put before its
|
||||
- // type_id.
|
||||
io::StringOutputStream output_stream(&data);
|
||||
io::CodedOutputStream coded_output(&output_stream);
|
||||
coded_output.WriteTag(WireFormatLite::kMessageSetItemStartTag);
|
||||
+ }
|
||||
+ return data;
|
||||
+}
|
||||
+std::string BuildMessageSetItemEnd() {
|
||||
+ std::string data;
|
||||
+ {
|
||||
+ io::StringOutputStream output_stream(&data);
|
||||
+ io::CodedOutputStream coded_output(&output_stream);
|
||||
+ coded_output.WriteTag(WireFormatLite::kMessageSetItemEndTag);
|
||||
+ }
|
||||
+ return data;
|
||||
+}
|
||||
+std::string BuildMessageSetTestExtension1(int value = 123) {
|
||||
+ std::string data;
|
||||
+ {
|
||||
+ unittest::TestMessageSetExtension1 message;
|
||||
+ message.set_i(value);
|
||||
+ io::StringOutputStream output_stream(&data);
|
||||
+ io::CodedOutputStream coded_output(&output_stream);
|
||||
// Write the message content first.
|
||||
WireFormatLite::WriteTag(WireFormatLite::kMessageSetMessageNumber,
|
||||
WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
|
||||
&coded_output);
|
||||
coded_output.WriteVarint32(message.ByteSizeLong());
|
||||
message.SerializeWithCachedSizes(&coded_output);
|
||||
- // Write the type id.
|
||||
- uint32 type_id = message.GetDescriptor()->extension(0)->number();
|
||||
+ }
|
||||
+ return data;
|
||||
+}
|
||||
+std::string BuildMessageSetItemTypeId(int extension_number) {
|
||||
+ std::string data;
|
||||
+ {
|
||||
+ io::StringOutputStream output_stream(&data);
|
||||
+ io::CodedOutputStream coded_output(&output_stream);
|
||||
WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber,
|
||||
- type_id, &coded_output);
|
||||
- coded_output.WriteTag(WireFormatLite::kMessageSetItemEndTag);
|
||||
+ extension_number, &coded_output);
|
||||
}
|
||||
+ return data;
|
||||
+}
|
||||
+void ValidateTestMessageSet(const std::string& test_case,
|
||||
+ const std::string& data) {
|
||||
+ SCOPED_TRACE(test_case);
|
||||
{
|
||||
- proto2_wireformat_unittest::TestMessageSet message_set;
|
||||
+ ::proto2_wireformat_unittest::TestMessageSet message_set;
|
||||
ASSERT_TRUE(message_set.ParseFromString(data));
|
||||
|
||||
EXPECT_EQ(123,
|
||||
@@ -616,10 +643,15 @@ TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) {
|
||||
.GetExtension(
|
||||
unittest::TestMessageSetExtension1::message_set_extension)
|
||||
.i());
|
||||
+
|
||||
+ // Make sure it does not contain anything else.
|
||||
+ message_set.ClearExtension(
|
||||
+ unittest::TestMessageSetExtension1::message_set_extension);
|
||||
+ EXPECT_EQ(message_set.SerializeAsString(), "");
|
||||
}
|
||||
{
|
||||
// Test parse the message via Reflection.
|
||||
- proto2_wireformat_unittest::TestMessageSet message_set;
|
||||
+ ::proto2_wireformat_unittest::TestMessageSet message_set;
|
||||
io::CodedInputStream input(reinterpret_cast<const uint8*>(data.data()),
|
||||
data.size());
|
||||
EXPECT_TRUE(WireFormat::ParseAndMergePartial(&input, &message_set));
|
||||
@@ -631,6 +663,61 @@ TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) {
|
||||
unittest::TestMessageSetExtension1::message_set_extension)
|
||||
.i());
|
||||
}
|
||||
+ {
|
||||
+ // Test parse the message via DynamicMessage.
|
||||
+ DynamicMessageFactory factory;
|
||||
+ std::unique_ptr<Message> msg(
|
||||
+ factory
|
||||
+ .GetPrototype(
|
||||
+ ::proto2_wireformat_unittest::TestMessageSet::descriptor())
|
||||
+ ->New());
|
||||
+ msg->ParseFromString(data);
|
||||
+ auto* reflection = msg->GetReflection();
|
||||
+ std::vector<const FieldDescriptor*> fields;
|
||||
+ reflection->ListFields(*msg, &fields);
|
||||
+ ASSERT_EQ(fields.size(), 1);
|
||||
+ const auto& sub = reflection->GetMessage(*msg, fields[0]);
|
||||
+ reflection = sub.GetReflection();
|
||||
+ EXPECT_EQ(123, reflection->GetInt32(
|
||||
+ sub, sub.GetDescriptor()->FindFieldByName("i")));
|
||||
+ }
|
||||
+}
|
||||
+} // namespace
|
||||
+
|
||||
+TEST(WireFormatTest, ParseMessageSetWithAnyTagOrder) {
|
||||
+ std::string start = BuildMessageSetItemStart();
|
||||
+ std::string end = BuildMessageSetItemEnd();
|
||||
+ std::string id = BuildMessageSetItemTypeId(
|
||||
+ unittest::TestMessageSetExtension1::descriptor()->extension(0)->number());
|
||||
+ std::string message = BuildMessageSetTestExtension1();
|
||||
+
|
||||
+ ValidateTestMessageSet("id + message", start + id + message + end);
|
||||
+ ValidateTestMessageSet("message + id", start + message + id + end);
|
||||
+}
|
||||
+
|
||||
+TEST(WireFormatTest, ParseMessageSetWithDuplicateTags) {
|
||||
+ std::string start = BuildMessageSetItemStart();
|
||||
+ std::string end = BuildMessageSetItemEnd();
|
||||
+ std::string id = BuildMessageSetItemTypeId(
|
||||
+ unittest::TestMessageSetExtension1::descriptor()->extension(0)->number());
|
||||
+ std::string other_id = BuildMessageSetItemTypeId(123456);
|
||||
+ std::string message = BuildMessageSetTestExtension1();
|
||||
+ std::string other_message = BuildMessageSetTestExtension1(321);
|
||||
+
|
||||
+ // Double id
|
||||
+ ValidateTestMessageSet("id + other_id + message",
|
||||
+ start + id + other_id + message + end);
|
||||
+ ValidateTestMessageSet("id + message + other_id",
|
||||
+ start + id + message + other_id + end);
|
||||
+ ValidateTestMessageSet("message + id + other_id",
|
||||
+ start + message + id + other_id + end);
|
||||
+ // Double message
|
||||
+ ValidateTestMessageSet("id + message + other_message",
|
||||
+ start + id + message + other_message + end);
|
||||
+ ValidateTestMessageSet("message + id + other_message",
|
||||
+ start + message + id + other_message + end);
|
||||
+ ValidateTestMessageSet("message + other_message + id",
|
||||
+ start + message + other_message + id + end);
|
||||
}
|
||||
|
||||
void SerializeReverseOrder(
|
||||
@ -1,45 +0,0 @@
|
||||
From bbcf509bd046b34cca19c766bbddc31683d0858b Mon Sep 17 00:00:00 2001
|
||||
From: Matt Caswell <matt@openssl.org>
|
||||
Date: Tue, 13 Dec 2022 14:54:55 +0000
|
||||
Subject: [PATCH] Avoid dangling ptrs in header and data params for
|
||||
PEM_read_bio_ex
|
||||
|
||||
In the event of a failure in PEM_read_bio_ex() we free the buffers we
|
||||
allocated for the header and data buffers. However we were not clearing
|
||||
the ptrs stored in *header and *data. Since, on success, the caller is
|
||||
responsible for freeing these ptrs this can potentially lead to a double
|
||||
free if the caller frees them even on failure.
|
||||
|
||||
Thanks to Dawei Wang for reporting this issue.
|
||||
|
||||
Based on a proposed patch by Kurt Roeckx.
|
||||
|
||||
CVE-2022-4450
|
||||
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
Reviewed-by: Hugo Landau <hlandau@openssl.org>
|
||||
|
||||
Reference:https://github.com/openssl/openssl/commit/bbcf509bd046b34cca19c766bbddc31683d0858b
|
||||
Confilts:CHANGES
|
||||
|
||||
---
|
||||
crypto/pem/pem_lib.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/pem/pem_lib.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/pem/pem_lib.c
|
||||
index d416d939ea..328c30cdbb 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/pem/pem_lib.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/pem/pem_lib.c
|
||||
@@ -957,7 +957,9 @@ int PEM_read_bio_ex(BIO *bp, char **name_out, char **header,
|
||||
*data = pem_malloc(len, flags);
|
||||
if (*header == NULL || *data == NULL) {
|
||||
pem_free(*header, flags, 0);
|
||||
+ *header = NULL;
|
||||
pem_free(*data, flags, 0);
|
||||
+ *data = NULL;
|
||||
goto end;
|
||||
}
|
||||
BIO_read(headerB, *header, headerlen);
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,110 +0,0 @@
|
||||
From c3829dd8825c654652201e16f8a0a0c46ee3f344 Mon Sep 17 00:00:00 2001
|
||||
From: Matt Caswell <matt@openssl.org>
|
||||
Date: Wed, 14 Dec 2022 16:18:14 +0000
|
||||
Subject: [PATCH] Fix a UAF resulting from a bug in BIO_new_NDEF
|
||||
|
||||
If the aux->asn1_cb() call fails in BIO_new_NDEF then the "out" BIO will
|
||||
be part of an invalid BIO chain. This causes a "use after free" when the
|
||||
BIO is eventually freed.
|
||||
|
||||
Based on an original patch by Viktor Dukhovni and an idea from Theo
|
||||
Buehler.
|
||||
|
||||
Thanks to Octavio Galland for reporting this issue.
|
||||
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
|
||||
Reference:https://github.com/openssl/openssl/commit/c3829dd8825c654652201e16f8a0a0c46ee3f344
|
||||
Conflict: NA
|
||||
|
||||
---
|
||||
crypto/asn1/bio_ndef.c | 39 ++++++++++++++++++++++++++++++++-------
|
||||
1 file changed, 32 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/asn1/bio_ndef.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/asn1/bio_ndef.c
|
||||
index 760e4846a4..f8d4b1b9aa 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/asn1/bio_ndef.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/asn1/bio_ndef.c
|
||||
@@ -49,12 +49,19 @@ static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg);
|
||||
static int ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen,
|
||||
void *parg);
|
||||
|
||||
+/*
|
||||
+ * On success, the returned BIO owns the input BIO as part of its BIO chain.
|
||||
+ * On failure, NULL is returned and the input BIO is owned by the caller.
|
||||
+ *
|
||||
+ * Unfortunately cannot constify this due to CMS_stream() and PKCS7_stream()
|
||||
+ */
|
||||
BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
|
||||
{
|
||||
NDEF_SUPPORT *ndef_aux = NULL;
|
||||
BIO *asn_bio = NULL;
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
ASN1_STREAM_ARG sarg;
|
||||
+ BIO *pop_bio = NULL;
|
||||
|
||||
if (!aux || !aux->asn1_cb) {
|
||||
ASN1err(ASN1_F_BIO_NEW_NDEF, ASN1_R_STREAMING_NOT_SUPPORTED);
|
||||
@@ -69,21 +76,39 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
|
||||
out = BIO_push(asn_bio, out);
|
||||
if (out == NULL)
|
||||
goto err;
|
||||
+ pop_bio = asn_bio;
|
||||
|
||||
- BIO_asn1_set_prefix(asn_bio, ndef_prefix, ndef_prefix_free);
|
||||
- BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free);
|
||||
+ if (BIO_asn1_set_prefix(asn_bio, ndef_prefix, ndef_prefix_free) <= 0
|
||||
+ || BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free) <= 0
|
||||
+ || BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux) <= 0)
|
||||
+ goto err;
|
||||
|
||||
/*
|
||||
- * Now let callback prepends any digest, cipher etc BIOs ASN1 structure
|
||||
- * needs.
|
||||
+ * Now let the callback prepend any digest, cipher, etc., that the BIO's
|
||||
+ * ASN1 structure needs.
|
||||
*/
|
||||
|
||||
sarg.out = out;
|
||||
sarg.ndef_bio = NULL;
|
||||
sarg.boundary = NULL;
|
||||
|
||||
- if (aux->asn1_cb(ASN1_OP_STREAM_PRE, &val, it, &sarg) <= 0)
|
||||
+ /*
|
||||
+ * The asn1_cb(), must not have mutated asn_bio on error, leaving it in the
|
||||
+ * middle of some partially built, but not returned BIO chain.
|
||||
+ */
|
||||
+ if (aux->asn1_cb(ASN1_OP_STREAM_PRE, &val, it, &sarg) <= 0) {
|
||||
+ /*
|
||||
+ * ndef_aux is now owned by asn_bio so we must not free it in the err
|
||||
+ * clean up block
|
||||
+ */
|
||||
+ ndef_aux = NULL;
|
||||
goto err;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * We must not fail now because the callback has prepended additional
|
||||
+ * BIOs to the chain
|
||||
+ */
|
||||
|
||||
ndef_aux->val = val;
|
||||
ndef_aux->it = it;
|
||||
@@ -91,11 +116,11 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
|
||||
ndef_aux->boundary = sarg.boundary;
|
||||
ndef_aux->out = out;
|
||||
|
||||
- BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux);
|
||||
-
|
||||
return sarg.ndef_bio;
|
||||
|
||||
err:
|
||||
+ /* BIO_pop() is NULL safe */
|
||||
+ (void)BIO_pop(pop_bio);
|
||||
BIO_free(asn_bio);
|
||||
OPENSSL_free(ndef_aux);
|
||||
return NULL;
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
From 2c6c9d439b484e1ba9830d8454a34fa4f80fdfe9 Mon Sep 17 00:00:00 2001
|
||||
From: Hugo Landau <hlandau@openssl.org>
|
||||
Date: Tue, 17 Jan 2023 17:45:42 +0000
|
||||
Subject: [PATCH] CVE-2023-0286: Fix GENERAL_NAME_cmp for x400Address (1.1.1)
|
||||
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
|
||||
Reference:https://github.com/openssl/openssl/commit/2c6c9d439b484e1ba9830d8454a34fa4f80fdfe9
|
||||
Confilts:CHANGES
|
||||
|
||||
---
|
||||
crypto/x509v3/v3_genn.c | 2 +-
|
||||
include/openssl/x509v3.h | 2 +-
|
||||
test/v3nametest.c | 8 ++++++++
|
||||
3 files changed, 12 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/v3_genn.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/v3_genn.c
|
||||
index 87a5eff47c..e54ddc55c9 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/v3_genn.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/v3_genn.c
|
||||
@@ -98,7 +98,7 @@ int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b)
|
||||
return -1;
|
||||
switch (a->type) {
|
||||
case GEN_X400:
|
||||
- result = ASN1_TYPE_cmp(a->d.x400Address, b->d.x400Address);
|
||||
+ result = ASN1_STRING_cmp(a->d.x400Address, b->d.x400Address);
|
||||
break;
|
||||
|
||||
case GEN_EDIPARTY:
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/x509v3.h b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/x509v3.h
|
||||
index 90fa3592ce..e61c0f29d4 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/x509v3.h
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/x509v3.h
|
||||
@@ -136,7 +136,7 @@ typedef struct GENERAL_NAME_st {
|
||||
OTHERNAME *otherName; /* otherName */
|
||||
ASN1_IA5STRING *rfc822Name;
|
||||
ASN1_IA5STRING *dNSName;
|
||||
- ASN1_TYPE *x400Address;
|
||||
+ ASN1_STRING *x400Address;
|
||||
X509_NAME *directoryName;
|
||||
EDIPARTYNAME *ediPartyName;
|
||||
ASN1_IA5STRING *uniformResourceIdentifier;
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/test/v3nametest.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/test/v3nametest.c
|
||||
index d1852190b8..37819da8fd 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/test/v3nametest.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/test/v3nametest.c
|
||||
@@ -646,6 +646,14 @@ static struct gennamedata {
|
||||
0xb7, 0x09, 0x02, 0x02
|
||||
},
|
||||
15
|
||||
+ }, {
|
||||
+ /*
|
||||
+ * Regression test for CVE-2023-0286.
|
||||
+ */
|
||||
+ {
|
||||
+ 0xa3, 0x00
|
||||
+ },
|
||||
+ 2
|
||||
}
|
||||
};
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,226 +0,0 @@
|
||||
From 879f7080d7e141f415c79eaa3a8ac4a3dad0348b Mon Sep 17 00:00:00 2001
|
||||
From: Pauli <pauli@openssl.org>
|
||||
Date: Wed, 8 Mar 2023 15:28:20 +1100
|
||||
Subject: [PATCH] x509: excessive resource use verifying policy constraints
|
||||
|
||||
A security vulnerability has been identified in all supported versions
|
||||
of OpenSSL related to the verification of X.509 certificate chains
|
||||
that include policy constraints. Attackers may be able to exploit this
|
||||
vulnerability by creating a malicious certificate chain that triggers
|
||||
exponential use of computational resources, leading to a denial-of-service
|
||||
(DoS) attack on affected systems.
|
||||
|
||||
Fixes CVE-2023-0464
|
||||
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
|
||||
(Merged from https://github.com/openssl/openssl/pull/20569)
|
||||
|
||||
Reference:https://github.com/openssl/openssl/commit/879f7080d7e141f415c79eaa3a8ac4a3dad0348b
|
||||
Confilts:NA
|
||||
|
||||
---
|
||||
crypto/x509v3/pcy_local.h | 8 +++++++-
|
||||
crypto/x509v3/pcy_node.c | 12 +++++++++---
|
||||
crypto/x509v3/pcy_tree.c | 37 +++++++++++++++++++++++++++----------
|
||||
3 files changed, 43 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_local.h b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_local.h
|
||||
index 5daf78de45..344aa06765 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_local.h
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_local.h
|
||||
@@ -111,6 +111,11 @@ struct X509_POLICY_LEVEL_st {
|
||||
};
|
||||
|
||||
struct X509_POLICY_TREE_st {
|
||||
+ /* The number of nodes in the tree */
|
||||
+ size_t node_count;
|
||||
+ /* The maximum number of nodes in the tree */
|
||||
+ size_t node_maximum;
|
||||
+
|
||||
/* This is the tree 'level' data */
|
||||
X509_POLICY_LEVEL *levels;
|
||||
int nlevel;
|
||||
@@ -159,7 +164,8 @@ X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk,
|
||||
X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
X509_POLICY_DATA *data,
|
||||
X509_POLICY_NODE *parent,
|
||||
- X509_POLICY_TREE *tree);
|
||||
+ X509_POLICY_TREE *tree,
|
||||
+ int extra_data);
|
||||
void policy_node_free(X509_POLICY_NODE *node);
|
||||
int policy_node_match(const X509_POLICY_LEVEL *lvl,
|
||||
const X509_POLICY_NODE *node, const ASN1_OBJECT *oid);
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_node.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_node.c
|
||||
index e2d7b15322..d574fb9d66 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_node.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_node.c
|
||||
@@ -59,10 +59,15 @@ X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level,
|
||||
X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
X509_POLICY_DATA *data,
|
||||
X509_POLICY_NODE *parent,
|
||||
- X509_POLICY_TREE *tree)
|
||||
+ X509_POLICY_TREE *tree,
|
||||
+ int extra_data)
|
||||
{
|
||||
X509_POLICY_NODE *node;
|
||||
|
||||
+ /* Verify that the tree isn't too large. This mitigates CVE-2023-0464 */
|
||||
+ if (tree->node_maximum > 0 && tree->node_count >= tree->node_maximum)
|
||||
+ return NULL;
|
||||
+
|
||||
node = OPENSSL_zalloc(sizeof(*node));
|
||||
if (node == NULL) {
|
||||
X509V3err(X509V3_F_LEVEL_ADD_NODE, ERR_R_MALLOC_FAILURE);
|
||||
@@ -70,7 +75,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
}
|
||||
node->data = data;
|
||||
node->parent = parent;
|
||||
- if (level) {
|
||||
+ if (level != NULL) {
|
||||
if (OBJ_obj2nid(data->valid_policy) == NID_any_policy) {
|
||||
if (level->anyPolicy)
|
||||
goto node_error;
|
||||
@@ -90,7 +95,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
}
|
||||
}
|
||||
|
||||
- if (tree) {
|
||||
+ if (extra_data) {
|
||||
if (tree->extra_data == NULL)
|
||||
tree->extra_data = sk_X509_POLICY_DATA_new_null();
|
||||
if (tree->extra_data == NULL){
|
||||
@@ -103,6 +108,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
}
|
||||
}
|
||||
|
||||
+ tree->node_count++;
|
||||
if (parent)
|
||||
parent->nchild++;
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_tree.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_tree.c
|
||||
index 6e8322cbc5..6c7fd35405 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_tree.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509v3/pcy_tree.c
|
||||
@@ -13,6 +13,18 @@
|
||||
|
||||
#include "pcy_local.h"
|
||||
|
||||
+/*
|
||||
+ * If the maximum number of nodes in the policy tree isn't defined, set it to
|
||||
+ * a generous default of 1000 nodes.
|
||||
+ *
|
||||
+ * Defining this to be zero means unlimited policy tree growth which opens the
|
||||
+ * door on CVE-2023-0464.
|
||||
+ */
|
||||
+
|
||||
+#ifndef OPENSSL_POLICY_TREE_NODES_MAX
|
||||
+# define OPENSSL_POLICY_TREE_NODES_MAX 1000
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* Enable this to print out the complete policy tree at various point during
|
||||
* evaluation.
|
||||
@@ -168,6 +180,9 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
|
||||
return X509_PCY_TREE_INTERNAL;
|
||||
}
|
||||
|
||||
+ /* Limit the growth of the tree to mitigate CVE-2023-0464 */
|
||||
+ tree->node_maximum = OPENSSL_POLICY_TREE_NODES_MAX;
|
||||
+
|
||||
/*
|
||||
* http://tools.ietf.org/html/rfc5280#section-6.1.2, figure 3.
|
||||
*
|
||||
@@ -184,7 +199,7 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
|
||||
level = tree->levels;
|
||||
if ((data = policy_data_new(NULL, OBJ_nid2obj(NID_any_policy), 0)) == NULL)
|
||||
goto bad_tree;
|
||||
- if (level_add_node(level, data, NULL, tree) == NULL) {
|
||||
+ if (level_add_node(level, data, NULL, tree, 1) == NULL) {
|
||||
policy_data_free(data);
|
||||
goto bad_tree;
|
||||
}
|
||||
@@ -243,7 +258,8 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
|
||||
* Return value: 1 on success, 0 otherwise
|
||||
*/
|
||||
static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
|
||||
- X509_POLICY_DATA *data)
|
||||
+ X509_POLICY_DATA *data,
|
||||
+ X509_POLICY_TREE *tree)
|
||||
{
|
||||
X509_POLICY_LEVEL *last = curr - 1;
|
||||
int i, matched = 0;
|
||||
@@ -253,13 +269,13 @@ static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
|
||||
X509_POLICY_NODE *node = sk_X509_POLICY_NODE_value(last->nodes, i);
|
||||
|
||||
if (policy_node_match(last, node, data->valid_policy)) {
|
||||
- if (level_add_node(curr, data, node, NULL) == NULL)
|
||||
+ if (level_add_node(curr, data, node, tree, 0) == NULL)
|
||||
return 0;
|
||||
matched = 1;
|
||||
}
|
||||
}
|
||||
if (!matched && last->anyPolicy) {
|
||||
- if (level_add_node(curr, data, last->anyPolicy, NULL) == NULL)
|
||||
+ if (level_add_node(curr, data, last->anyPolicy, tree, 0) == NULL)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -272,7 +288,8 @@ static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
|
||||
* Return value: 1 on success, 0 otherwise.
|
||||
*/
|
||||
static int tree_link_nodes(X509_POLICY_LEVEL *curr,
|
||||
- const X509_POLICY_CACHE *cache)
|
||||
+ const X509_POLICY_CACHE *cache,
|
||||
+ X509_POLICY_TREE *tree)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -280,7 +297,7 @@ static int tree_link_nodes(X509_POLICY_LEVEL *curr,
|
||||
X509_POLICY_DATA *data = sk_X509_POLICY_DATA_value(cache->data, i);
|
||||
|
||||
/* Look for matching nodes in previous level */
|
||||
- if (!tree_link_matching_nodes(curr, data))
|
||||
+ if (!tree_link_matching_nodes(curr, data, tree))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -311,7 +328,7 @@ static int tree_add_unmatched(X509_POLICY_LEVEL *curr,
|
||||
/* Curr may not have anyPolicy */
|
||||
data->qualifier_set = cache->anyPolicy->qualifier_set;
|
||||
data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
|
||||
- if (level_add_node(curr, data, node, tree) == NULL) {
|
||||
+ if (level_add_node(curr, data, node, tree, 1) == NULL) {
|
||||
policy_data_free(data);
|
||||
return 0;
|
||||
}
|
||||
@@ -373,7 +390,7 @@ static int tree_link_any(X509_POLICY_LEVEL *curr,
|
||||
}
|
||||
/* Finally add link to anyPolicy */
|
||||
if (last->anyPolicy &&
|
||||
- level_add_node(curr, cache->anyPolicy, last->anyPolicy, NULL) == NULL)
|
||||
+ level_add_node(curr, cache->anyPolicy, last->anyPolicy, tree, 0) == NULL)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -555,7 +572,7 @@ static int tree_calculate_user_set(X509_POLICY_TREE *tree,
|
||||
extra->qualifier_set = anyPolicy->data->qualifier_set;
|
||||
extra->flags = POLICY_DATA_FLAG_SHARED_QUALIFIERS
|
||||
| POLICY_DATA_FLAG_EXTRA_NODE;
|
||||
- node = level_add_node(NULL, extra, anyPolicy->parent, tree);
|
||||
+ node = level_add_node(NULL, extra, anyPolicy->parent, tree, 1);
|
||||
}
|
||||
if (!tree->user_policies) {
|
||||
tree->user_policies = sk_X509_POLICY_NODE_new_null();
|
||||
@@ -582,7 +599,7 @@ static int tree_evaluate(X509_POLICY_TREE *tree)
|
||||
|
||||
for (i = 1; i < tree->nlevel; i++, curr++) {
|
||||
cache = policy_cache_set(curr->cert);
|
||||
- if (!tree_link_nodes(curr, cache))
|
||||
+ if (!tree_link_nodes(curr, cache, tree))
|
||||
return X509_PCY_TREE_INTERNAL;
|
||||
|
||||
if (!(curr->flags & X509_V_FLAG_INHIBIT_ANY)
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
From b013765abfa80036dc779dd0e50602c57bb3bf95 Mon Sep 17 00:00:00 2001
|
||||
From: Matt Caswell <matt@openssl.org>
|
||||
Date: Tue, 7 Mar 2023 16:52:55 +0000
|
||||
Subject: [PATCH] Ensure that EXFLAG_INVALID_POLICY is checked even in leaf
|
||||
certs
|
||||
|
||||
Even though we check the leaf cert to confirm it is valid, we
|
||||
later ignored the invalid flag and did not notice that the leaf
|
||||
cert was bad.
|
||||
|
||||
Fixes: CVE-2023-0465
|
||||
|
||||
Reviewed-by: Hugo Landau <hlandau@openssl.org>
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/20588)
|
||||
|
||||
Reference:https://github.com/openssl/openssl/commit/b013765abfa80036dc779dd0e50602c57bb3bf95
|
||||
Confilts:NA
|
||||
|
||||
---
|
||||
crypto/x509/x509_vfy.c | 11 +++++++++--
|
||||
1 file changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509/x509_vfy.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509/x509_vfy.c
|
||||
index 925fbb5412..1dfe4f9f31 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509/x509_vfy.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/x509/x509_vfy.c
|
||||
@@ -1649,18 +1649,25 @@ static int check_policy(X509_STORE_CTX *ctx)
|
||||
}
|
||||
/* Invalid or inconsistent extensions */
|
||||
if (ret == X509_PCY_TREE_INVALID) {
|
||||
- int i;
|
||||
+ int i, cbcalled = 0;
|
||||
|
||||
/* Locate certificates with bad extensions and notify callback. */
|
||||
- for (i = 1; i < sk_X509_num(ctx->chain); i++) {
|
||||
+ for (i = 0; i < sk_X509_num(ctx->chain); i++) {
|
||||
X509 *x = sk_X509_value(ctx->chain, i);
|
||||
|
||||
if (!(x->ex_flags & EXFLAG_INVALID_POLICY))
|
||||
continue;
|
||||
+ cbcalled = 1;
|
||||
if (!verify_cb_cert(ctx, x, i,
|
||||
X509_V_ERR_INVALID_POLICY_EXTENSION))
|
||||
return 0;
|
||||
}
|
||||
+ if (!cbcalled) {
|
||||
+ /* Should not be able to get here */
|
||||
+ X509err(X509_F_CHECK_POLICY, ERR_R_INTERNAL_ERROR);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ /* The callback ignored the error so we return success */
|
||||
return 1;
|
||||
}
|
||||
if (ret == X509_PCY_TREE_FAILURE) {
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
From 0d16b7e99aafc0b4a6d729eec65a411a7e025f0a Mon Sep 17 00:00:00 2001
|
||||
From: Tomas Mraz <tomas@openssl.org>
|
||||
Date: Tue, 21 Mar 2023 16:15:47 +0100
|
||||
Subject: [PATCH] Fix documentation of X509_VERIFY_PARAM_add0_policy()
|
||||
|
||||
The function was incorrectly documented as enabling policy checking.
|
||||
|
||||
Fixes: CVE-2023-0466
|
||||
|
||||
Reviewed-by: Matt Caswell <matt@openssl.org>
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/20564)
|
||||
|
||||
Reference:https://github.com/openssl/openssl/commit/0d16b7e99aafc0b4a6d729eec65a411a7e025f0a
|
||||
Confilts:CHANGES,NEWS
|
||||
|
||||
---
|
||||
doc/man3/X509_VERIFY_PARAM_set_flags.pod | 9 +++++++--
|
||||
1 files changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/doc/man3/X509_VERIFY_PARAM_set_flags.pod b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/doc/man3/X509_VERIFY_PARAM_set_flags.pod
|
||||
index f6f304bf7b..aa292f9336 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/doc/man3/X509_VERIFY_PARAM_set_flags.pod
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/doc/man3/X509_VERIFY_PARAM_set_flags.pod
|
||||
@@ -92,8 +92,9 @@ B<trust>.
|
||||
X509_VERIFY_PARAM_set_time() sets the verification time in B<param> to
|
||||
B<t>. Normally the current time is used.
|
||||
|
||||
-X509_VERIFY_PARAM_add0_policy() enables policy checking (it is disabled
|
||||
-by default) and adds B<policy> to the acceptable policy set.
|
||||
+X509_VERIFY_PARAM_add0_policy() adds B<policy> to the acceptable policy set.
|
||||
+Contrary to preexisting documentation of this function it does not enable
|
||||
+policy checking.
|
||||
|
||||
X509_VERIFY_PARAM_set1_policies() enables policy checking (it is disabled
|
||||
by default) and sets the acceptable policy set to B<policies>. Any existing
|
||||
@@ -377,6 +378,10 @@ and has no effect.
|
||||
|
||||
The X509_VERIFY_PARAM_get_hostflags() function was added in OpenSSL 1.1.0i.
|
||||
|
||||
+The function X509_VERIFY_PARAM_add0_policy() was historically documented as
|
||||
+enabling policy checking however the implementation has never done this.
|
||||
+The documentation was changed to align with the implementation.
|
||||
+
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright 2009-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,68 +0,0 @@
|
||||
From 9e209944b35cf82368071f160a744b6178f9b098 Mon Sep 17 00:00:00 2001
|
||||
From: Richard Levitte <levitte@openssl.org>
|
||||
Date: Fri, 12 May 2023 10:00:13 +0200
|
||||
Subject: [PATCH] Restrict the size of OBJECT IDENTIFIERs that OBJ_obj2txt will
|
||||
translate
|
||||
|
||||
OBJ_obj2txt() would translate any size OBJECT IDENTIFIER to canonical
|
||||
numeric text form. For gigantic sub-identifiers, this would take a very
|
||||
long time, the time complexity being O(n^2) where n is the size of that
|
||||
sub-identifier.
|
||||
|
||||
To mitigate this, a restriction on the size that OBJ_obj2txt() will
|
||||
translate to canonical numeric text form is added, based on RFC 2578
|
||||
(STD 58), which says this:
|
||||
|
||||
> 3.5. OBJECT IDENTIFIER values
|
||||
>
|
||||
> An OBJECT IDENTIFIER value is an ordered list of non-negative numbers.
|
||||
> For the SMIv2, each number in the list is referred to as a sub-identifier,
|
||||
> there are at most 128 sub-identifiers in a value, and each sub-identifier
|
||||
> has a maximum value of 2^32-1 (4294967295 decimal).
|
||||
|
||||
Fixes otc/security#96
|
||||
Fixes CVE-2023-2650
|
||||
|
||||
Reviewed-by: Matt Caswell <matt@openssl.org>
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
|
||||
Reference:https://github.com/openssl/openssl/commit/9e209944b35cf82368071f160a744b6178f9b098
|
||||
Confilts:CHANGES,NEWS
|
||||
|
||||
---
|
||||
crypto/objects/obj_dat.c | 19 +++++++++++++++++++
|
||||
1 files changed, 19 insertions(+)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/objects/obj_dat.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/objects/obj_dat.c
|
||||
index 7e8de727f3..d699915b20 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/objects/obj_dat.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/objects/obj_dat.c
|
||||
@@ -428,6 +428,25 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
|
||||
first = 1;
|
||||
bl = NULL;
|
||||
|
||||
+ /*
|
||||
+ * RFC 2578 (STD 58) says this about OBJECT IDENTIFIERs:
|
||||
+ *
|
||||
+ * > 3.5. OBJECT IDENTIFIER values
|
||||
+ * >
|
||||
+ * > An OBJECT IDENTIFIER value is an ordered list of non-negative
|
||||
+ * > numbers. For the SMIv2, each number in the list is referred to as a
|
||||
+ * > sub-identifier, there are at most 128 sub-identifiers in a value,
|
||||
+ * > and each sub-identifier has a maximum value of 2^32-1 (4294967295
|
||||
+ * > decimal).
|
||||
+ *
|
||||
+ * So a legitimate OID according to this RFC is at most (32 * 128 / 7),
|
||||
+ * i.e. 586 bytes long.
|
||||
+ *
|
||||
+ * Ref: https://datatracker.ietf.org/doc/html/rfc2578#section-3.5
|
||||
+ */
|
||||
+ if (len > 586)
|
||||
+ goto err;
|
||||
+
|
||||
while (len > 0) {
|
||||
l = 0;
|
||||
use_bn = 0;
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,134 +0,0 @@
|
||||
From 8780a896543a654e757db1b9396383f9d8095528 Mon Sep 17 00:00:00 2001
|
||||
From: Matt Caswell <matt@openssl.org>
|
||||
Date: Thu, 6 Jul 2023 16:36:35 +0100
|
||||
Subject: [PATCH] Fix DH_check() excessive time with over sized modulus
|
||||
|
||||
The DH_check() function checks numerous aspects of the key or parameters
|
||||
that have been supplied. Some of those checks use the supplied modulus
|
||||
value even if it is excessively large.
|
||||
|
||||
There is already a maximum DH modulus size (10,000 bits) over which
|
||||
OpenSSL will not generate or derive keys. DH_check() will however still
|
||||
perform various tests for validity on such a large modulus. We introduce a
|
||||
new maximum (32,768) over which DH_check() will just fail.
|
||||
|
||||
An application that calls DH_check() and supplies a key or parameters
|
||||
obtained from an untrusted source could be vulnerable to a Denial of
|
||||
Service attack.
|
||||
|
||||
The function DH_check() is itself called by a number of other OpenSSL
|
||||
functions. An application calling any of those other functions may
|
||||
similarly be affected. The other functions affected by this are
|
||||
DH_check_ex() and EVP_PKEY_param_check().
|
||||
|
||||
CVE-2023-3446
|
||||
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
|
||||
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/21452)
|
||||
|
||||
Reference:https://github.com/openssl/openssl/commit/8780a896543a654e757db1b9396383f9d8095528
|
||||
Confilts:Change the Source File Patch
|
||||
|
||||
---
|
||||
crypto/dh/dh_check.c | 6 ++++++
|
||||
crypto/dh/dh_err.c | 3 ++-
|
||||
crypto/err/openssl.txt | 3 ++-
|
||||
include/openssl/dh.h | 3 +++
|
||||
include/openssl/dherr.h | 3 ++-
|
||||
5 files changed, 15 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c
|
||||
index 4ac169e75c..e5f9dd5030 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c
|
||||
@@ -101,6 +101,12 @@ int DH_check(const DH *dh, int *ret)
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *t1 = NULL, *t2 = NULL;
|
||||
|
||||
+ /* Don't do any checks at all with an excessively large modulus */
|
||||
+ if (BN_num_bits(dh->p) > OPENSSL_DH_CHECK_MAX_MODULUS_BITS) {
|
||||
+ DHerr(DH_F_DH_CHECK, DH_R_MODULUS_TOO_LARGE);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
if (!DH_check_params(dh, ret))
|
||||
return 0;
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_err.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_err.c
|
||||
index 7285587b4a..92800d3fcc 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_err.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_err.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
- * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
+ * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -18,6 +18,7 @@ static const ERR_STRING_DATA DH_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_DH, DH_F_DHPARAMS_PRINT_FP, 0), "DHparams_print_fp"},
|
||||
{ERR_PACK(ERR_LIB_DH, DH_F_DH_BUILTIN_GENPARAMS, 0),
|
||||
"dh_builtin_genparams"},
|
||||
+ {ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK, 0), "DH_check"},
|
||||
{ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_EX, 0), "DH_check_ex"},
|
||||
{ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_PARAMS_EX, 0), "DH_check_params_ex"},
|
||||
{ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_PUB_KEY_EX, 0), "DH_check_pub_key_ex"},
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/err/openssl.txt b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/err/openssl.txt
|
||||
index 9f91a4a811..c0a3cd720b 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/err/openssl.txt
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/err/openssl.txt
|
||||
@@ -1,4 +1,4 @@
|
||||
-# Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.
|
||||
+# Copyright 1999-2023 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
@@ -401,6 +401,7 @@ CT_F_SCT_SET_VERSION:104:SCT_set_version
|
||||
DH_F_COMPUTE_KEY:102:compute_key
|
||||
DH_F_DHPARAMS_PRINT_FP:101:DHparams_print_fp
|
||||
DH_F_DH_BUILTIN_GENPARAMS:106:dh_builtin_genparams
|
||||
+DH_F_DH_CHECK:126:DH_check
|
||||
DH_F_DH_CHECK_EX:121:DH_check_ex
|
||||
DH_F_DH_CHECK_PARAMS_EX:122:DH_check_params_ex
|
||||
DH_F_DH_CHECK_PUB_KEY_EX:123:DH_check_pub_key_ex
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dh.h b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dh.h
|
||||
index 3527540cdd..892e31559d 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dh.h
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dh.h
|
||||
@@ -29,6 +29,9 @@ extern "C" {
|
||||
# ifndef OPENSSL_DH_MAX_MODULUS_BITS
|
||||
# define OPENSSL_DH_MAX_MODULUS_BITS 10000
|
||||
# endif
|
||||
+# ifndef OPENSSL_DH_CHECK_MAX_MODULUS_BITS
|
||||
+# define OPENSSL_DH_CHECK_MAX_MODULUS_BITS 32768
|
||||
+# endif
|
||||
|
||||
# define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dherr.h b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dherr.h
|
||||
index 916b3bed0b..528c819856 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dherr.h
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dherr.h
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
- * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
+ * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -30,6 +30,7 @@ int ERR_load_DH_strings(void);
|
||||
# define DH_F_COMPUTE_KEY 102
|
||||
# define DH_F_DHPARAMS_PRINT_FP 101
|
||||
# define DH_F_DH_BUILTIN_GENPARAMS 106
|
||||
+# define DH_F_DH_CHECK 126
|
||||
# define DH_F_DH_CHECK_EX 121
|
||||
# define DH_F_DH_CHECK_PARAMS_EX 122
|
||||
# define DH_F_DH_CHECK_PUB_KEY_EX 123
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
From 91ddeba0f2269b017dc06c46c993a788974b1aa5 Mon Sep 17 00:00:00 2001
|
||||
From: Tomas Mraz <tomas@openssl.org>
|
||||
Date: Fri, 21 Jul 2023 11:39:41 +0200
|
||||
Subject: [PATCH] DH_check(): Do not try checking q properties if it is
|
||||
obviously invalid
|
||||
|
||||
If |q| >= |p| then the q value is obviously wrong as q
|
||||
is supposed to be a prime divisor of p-1.
|
||||
|
||||
We check if p is overly large so this added test implies that
|
||||
q is not large either when performing subsequent tests using that
|
||||
q value.
|
||||
|
||||
Otherwise if it is too large these additional checks of the q value
|
||||
such as the primality test can then trigger DoS by doing overly long
|
||||
computations.
|
||||
|
||||
Fixes CVE-2023-3817
|
||||
|
||||
Reviewed-by: Paul Dale <pauli@openssl.org>
|
||||
Reviewed-by: Matt Caswell <matt@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/21551)
|
||||
|
||||
Reference:https://github.com/openssl/openssl/commit/91ddeba0f2269b017dc06c46c993a788974b1aa5
|
||||
Confilts:Change the Source File Patch
|
||||
|
||||
---
|
||||
crypto/dh/dh_check.c | 11 +++++++++--
|
||||
1 file changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c
|
||||
index 2001d2e7cb..9ae96991eb 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c
|
||||
@@ -97,7 +97,7 @@ int DH_check_ex(const DH *dh)
|
||||
|
||||
int DH_check(const DH *dh, int *ret)
|
||||
{
|
||||
- int ok = 0, r;
|
||||
+ int ok = 0, r, q_good = 0;
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *t1 = NULL, *t2 = NULL;
|
||||
|
||||
@@ -120,7 +120,14 @@ int DH_check(const DH *dh, int *ret)
|
||||
if (t2 == NULL)
|
||||
goto err;
|
||||
|
||||
- if (dh->q) {
|
||||
+ if (dh->q != NULL) {
|
||||
+ if (BN_ucmp(dh->p, dh->q) > 0)
|
||||
+ q_good = 1;
|
||||
+ else
|
||||
+ *ret |= DH_CHECK_INVALID_Q_VALUE;
|
||||
+ }
|
||||
+
|
||||
+ if (q_good) {
|
||||
if (BN_cmp(dh->g, BN_value_one()) <= 0)
|
||||
*ret |= DH_NOT_SUITABLE_GENERATOR;
|
||||
else if (BN_cmp(dh->g, dh->p) >= 0)
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,134 +0,0 @@
|
||||
From 58589a46204c0dfca58906d6e66cf610caa11d88 Mon Sep 17 00:00:00 2001
|
||||
From: lanming1120 <lanming1120@126.com>
|
||||
Date: Tue, 7 Nov 2023 14:42:28 +0800
|
||||
Subject: [PATCH] Make DH_check_pub_key() and DH_generate_key() safer yet
|
||||
|
||||
Signed-off-by: lanming1120 <lanming1120@126.com>
|
||||
|
||||
Reference:https://gitee.com/openeuler/openssl/commit/58589a46204c0dfca58906d6e66cf610caa11d88
|
||||
Confilts:NA
|
||||
|
||||
---
|
||||
crypto/dh/dh_check.c | 13 +++++++++++++
|
||||
crypto/dh/dh_err.c | 1 +
|
||||
crypto/dh/dh_key.c | 12 ++++++++++++
|
||||
crypto/err/openssl.txt | 1 +
|
||||
include/openssl/dh.h | 5 +++--
|
||||
include/openssl/dherr.h | 1 +
|
||||
6 files changed, 31 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c
|
||||
index ae1b03bc92..779cfbcd91 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_check.c
|
||||
@@ -198,6 +198,19 @@ int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
|
||||
BN_CTX *ctx = NULL;
|
||||
|
||||
*ret = 0;
|
||||
+
|
||||
+ /* Don't do any checks at all with an excessively large modulus */
|
||||
+ if (BN_num_bits(dh->p) > OPENSSL_DH_CHECK_MAX_MODULUS_BITS) {
|
||||
+ DHerr(DH_F_DH_CHECK_EX, DH_R_MODULUS_TOO_LARGE);
|
||||
+ *ret = DH_MODULUS_TOO_LARGE | DH_CHECK_PUBKEY_INVALID;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (dh->q != NULL && BN_ucmp(dh->p, dh->q) < 0) {
|
||||
+ *ret |= DH_CHECK_INVALID_Q_VALUE | DH_CHECK_PUBKEY_INVALID;
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_err.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_err.c
|
||||
index 92800d3fcc..b3b1e7a706 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_err.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_err.c
|
||||
@@ -82,6 +82,7 @@ static const ERR_STRING_DATA DH_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_DH, 0, DH_R_PARAMETER_ENCODING_ERROR),
|
||||
"parameter encoding error"},
|
||||
{ERR_PACK(ERR_LIB_DH, 0, DH_R_PEER_KEY_ERROR), "peer key error"},
|
||||
+ {ERR_PACK(ERR_LIB_DH, 0, DH_R_Q_TOO_LARGE), "q too large"},
|
||||
{ERR_PACK(ERR_LIB_DH, 0, DH_R_SHARED_INFO_ERROR), "shared info error"},
|
||||
{ERR_PACK(ERR_LIB_DH, 0, DH_R_UNABLE_TO_CHECK_GENERATOR),
|
||||
"unable to check generator"},
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_key.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_key.c
|
||||
index 117f2fa883..4c4c4b9874 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_key.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/dh/dh_key.c
|
||||
@@ -109,6 +109,12 @@ static int generate_key(DH *dh)
|
||||
BN_MONT_CTX *mont = NULL;
|
||||
BIGNUM *pub_key = NULL, *priv_key = NULL;
|
||||
|
||||
+ if (dh->q != NULL
|
||||
+ && BN_num_bits(dh->q) > OPENSSL_DH_MAX_MODULUS_BITS) {
|
||||
+ DHerr(DH_F_GENERATE_KEY, DH_R_Q_TOO_LARGE);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) {
|
||||
DHerr(DH_F_GENERATE_KEY, DH_R_MODULUS_TOO_LARGE);
|
||||
return 0;
|
||||
@@ -202,6 +208,12 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
|
||||
int ret = -1;
|
||||
int check_result;
|
||||
|
||||
+ if (dh->q != NULL
|
||||
+ && BN_num_bits(dh->q) > OPENSSL_DH_MAX_MODULUS_BITS) {
|
||||
+ DHerr(DH_F_COMPUTE_KEY, DH_R_Q_TOO_LARGE);
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) {
|
||||
DHerr(DH_F_COMPUTE_KEY, DH_R_MODULUS_TOO_LARGE);
|
||||
goto err;
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/err/openssl.txt b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/err/openssl.txt
|
||||
index c111822eac..56d4093ada 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/err/openssl.txt
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/crypto/err/openssl.txt
|
||||
@@ -2139,6 +2139,7 @@ DH_R_NO_PARAMETERS_SET:107:no parameters set
|
||||
DH_R_NO_PRIVATE_VALUE:100:no private value
|
||||
DH_R_PARAMETER_ENCODING_ERROR:105:parameter encoding error
|
||||
DH_R_PEER_KEY_ERROR:111:peer key error
|
||||
+DH_R_Q_TOO_LARGE:130:q too large
|
||||
DH_R_SHARED_INFO_ERROR:113:shared info error
|
||||
DH_R_UNABLE_TO_CHECK_GENERATOR:121:unable to check generator
|
||||
DSA_R_BAD_Q_VALUE:102:bad q value
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dh.h b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dh.h
|
||||
index 6c6ff3636a..7509f4fc3e 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dh.h
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dh.h
|
||||
@@ -71,14 +71,15 @@ DECLARE_ASN1_ITEM(DHparams)
|
||||
/* #define DH_GENERATOR_3 3 */
|
||||
# define DH_GENERATOR_5 5
|
||||
|
||||
-/* DH_check error codes */
|
||||
+/* DH_check error codes, some of them shared with DH_check_pub_key */
|
||||
# define DH_CHECK_P_NOT_PRIME 0x01
|
||||
# define DH_CHECK_P_NOT_SAFE_PRIME 0x02
|
||||
# define DH_UNABLE_TO_CHECK_GENERATOR 0x04
|
||||
# define DH_NOT_SUITABLE_GENERATOR 0x08
|
||||
# define DH_CHECK_Q_NOT_PRIME 0x10
|
||||
-# define DH_CHECK_INVALID_Q_VALUE 0x20
|
||||
+# define DH_CHECK_INVALID_Q_VALUE 0x20 /* +DH_check_pub_key */
|
||||
# define DH_CHECK_INVALID_J_VALUE 0x40
|
||||
+# define DH_MODULUS_TOO_LARGE 0x100
|
||||
|
||||
/* DH_check_pub_key error codes */
|
||||
# define DH_CHECK_PUBKEY_TOO_SMALL 0x01
|
||||
diff --git a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dherr.h b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dherr.h
|
||||
index 528c819856..d66c35aa8e 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dherr.h
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/include/openssl/dherr.h
|
||||
@@ -82,6 +82,7 @@ int ERR_load_DH_strings(void);
|
||||
# define DH_R_NO_PRIVATE_VALUE 100
|
||||
# define DH_R_PARAMETER_ENCODING_ERROR 105
|
||||
# define DH_R_PEER_KEY_ERROR 111
|
||||
+# define DH_R_Q_TOO_LARGE 130
|
||||
# define DH_R_SHARED_INFO_ERROR 113
|
||||
# define DH_R_UNABLE_TO_CHECK_GENERATOR 121
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,169 +0,0 @@
|
||||
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/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/ssl/ssl_lib.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/ssl/ssl_lib.c
|
||||
index 00410a7385..cb2dca4247 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/ssl/ssl_lib.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/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/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/ssl/statem/extensions_clnt.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/ssl/statem/extensions_clnt.c
|
||||
index c641ae7351..4ad75c8e2d 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/ssl/statem/extensions_clnt.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/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/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/ssl/statem/extensions_srvr.c b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/ssl/statem/extensions_srvr.c
|
||||
index 775d9a7444..a08027fd6d 100644
|
||||
--- a/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/ssl/statem/extensions_srvr.c
|
||||
+++ b/external/dcap_source/SGXDataCenterAttestationPrimitives-DCAP_1.12.1/QuoteVerification/intel-sgx-ssl-lin_2.15.1_1.1.1l/openssl_source/openssl-1.1.1l/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
|
||||
|
||||
|
||||
@ -1,251 +0,0 @@
|
||||
From 2502597c269947edcd2bc38d9d4277f558a4a25e Mon Sep 17 00:00:00 2001
|
||||
From: gaoyusong <a869920004@163.com>
|
||||
Date: Tue, 28 Feb 2023 19:57:46 +0800
|
||||
Subject: [PATCH] Fix sgx_create_enclave retry mechanism
|
||||
|
||||
Reference: https://github.com/intel/linux-sgx/commit/111a916b5d19554d2c86f3d881bf00ac91de1b34
|
||||
Conflict: NA
|
||||
|
||||
---
|
||||
.../templates/sgx/SGXEnclave/untrusted/sample.cpp | 5 +++++
|
||||
SampleCode/Cxx11SGXDemo/App/App.cpp | 5 +++++
|
||||
SampleCode/Cxx14SGXDemo/App/App.cpp | 5 +++++
|
||||
SampleCode/PowerTransition/App/ErrorSupport.cpp | 1 +
|
||||
SampleCode/ProtobufSGXDemo/App/App.cpp | 5 +++++
|
||||
SampleCode/SampleDNNL/App/App.cpp | 5 +++++
|
||||
SampleCode/SampleEnclave/App/App.cpp | 5 +++++
|
||||
SampleCode/SampleEnclaveGMIPP/App/App.cpp | 5 +++++
|
||||
SampleCode/SampleEnclavePCL/App/App.cpp | 5 +++++
|
||||
SampleCode/SealUnseal/App/ErrorSupport.cpp | 1 +
|
||||
SampleCode/Switchless/App/App.cpp | 5 +++++
|
||||
common/inc/sgx_error.h | 2 +-
|
||||
psw/ae/aesm_service/source/oal/linux/internal_log.cpp | 1 +
|
||||
psw/urts/loader.cpp | 9 +++++----
|
||||
14 files changed, 54 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.cpp b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.cpp
|
||||
index 2885ebd..c8bcf48 100644
|
||||
--- a/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.cpp
|
||||
+++ b/Linux_SGXEclipsePlugin/build_directory/plugins/com.intel.sgx/templates/sgx/SGXEnclave/untrusted/sample.cpp
|
||||
@@ -102,6 +102,11 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
"Can't open enclave file.",
|
||||
NULL
|
||||
},
|
||||
+ {
|
||||
+ SGX_ERROR_MEMORY_MAP_FAILURE,
|
||||
+ "Failed to reserve memory for the enclave.",
|
||||
+ NULL
|
||||
+ },
|
||||
};
|
||||
|
||||
/* Check error conditions for loading enclave */
|
||||
diff --git a/SampleCode/Cxx11SGXDemo/App/App.cpp b/SampleCode/Cxx11SGXDemo/App/App.cpp
|
||||
index cc92865..f44b435 100644
|
||||
--- a/SampleCode/Cxx11SGXDemo/App/App.cpp
|
||||
+++ b/SampleCode/Cxx11SGXDemo/App/App.cpp
|
||||
@@ -132,6 +132,11 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
"The enclave is signed as product enclave, and can not be created as debuggable enclave.",
|
||||
NULL
|
||||
},
|
||||
+ {
|
||||
+ SGX_ERROR_MEMORY_MAP_FAILURE,
|
||||
+ "Failed to reserve memory for the enclave.",
|
||||
+ NULL
|
||||
+ },
|
||||
};
|
||||
|
||||
/* Check error conditions for loading enclave */
|
||||
diff --git a/SampleCode/Cxx14SGXDemo/App/App.cpp b/SampleCode/Cxx14SGXDemo/App/App.cpp
|
||||
index 62a8dde..59cdfbe 100644
|
||||
--- a/SampleCode/Cxx14SGXDemo/App/App.cpp
|
||||
+++ b/SampleCode/Cxx14SGXDemo/App/App.cpp
|
||||
@@ -132,6 +132,11 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
"The enclave is signed as product enclave, and can not be created as debuggable enclave.",
|
||||
NULL
|
||||
},
|
||||
+ {
|
||||
+ SGX_ERROR_MEMORY_MAP_FAILURE,
|
||||
+ "Failed to reserve memory for the enclave.",
|
||||
+ NULL
|
||||
+ },
|
||||
};
|
||||
|
||||
/* Check error conditions for loading enclave */
|
||||
diff --git a/SampleCode/PowerTransition/App/ErrorSupport.cpp b/SampleCode/PowerTransition/App/ErrorSupport.cpp
|
||||
index 4142ab0..9fdf0ce 100644
|
||||
--- a/SampleCode/PowerTransition/App/ErrorSupport.cpp
|
||||
+++ b/SampleCode/PowerTransition/App/ErrorSupport.cpp
|
||||
@@ -51,6 +51,7 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
{SGX_ERROR_OUT_OF_EPC, "Out of EPC memory."},
|
||||
{SGX_ERROR_NO_DEVICE, "Invalid SGX device."},
|
||||
{SGX_ERROR_MEMORY_MAP_CONFLICT, "Memory map conflicted."},
|
||||
+ {SGX_ERROR_MEMORY_MAP_FAILURE, "Failed to reserve memory for the enclave."},
|
||||
{SGX_ERROR_INVALID_METADATA, "Invalid encalve metadata."},
|
||||
{SGX_ERROR_DEVICE_BUSY, "SGX device is busy."},
|
||||
{SGX_ERROR_INVALID_VERSION, "Enclave metadata version is invalid."},
|
||||
diff --git a/SampleCode/ProtobufSGXDemo/App/App.cpp b/SampleCode/ProtobufSGXDemo/App/App.cpp
|
||||
index 58b74b4..ae7f2f3 100644
|
||||
--- a/SampleCode/ProtobufSGXDemo/App/App.cpp
|
||||
+++ b/SampleCode/ProtobufSGXDemo/App/App.cpp
|
||||
@@ -132,6 +132,11 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
"The enclave is signed as product enclave, and can not be created as debuggable enclave.",
|
||||
NULL
|
||||
},
|
||||
+ {
|
||||
+ SGX_ERROR_MEMORY_MAP_FAILURE,
|
||||
+ "Failed to reserve memory for the enclave.",
|
||||
+ NULL
|
||||
+ },
|
||||
};
|
||||
|
||||
/* Check error conditions for loading enclave */
|
||||
diff --git a/SampleCode/SampleDNNL/App/App.cpp b/SampleCode/SampleDNNL/App/App.cpp
|
||||
index 41c6752..cfb4f15 100644
|
||||
--- a/SampleCode/SampleDNNL/App/App.cpp
|
||||
+++ b/SampleCode/SampleDNNL/App/App.cpp
|
||||
@@ -134,6 +134,11 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
"Can't open enclave file.",
|
||||
NULL
|
||||
},
|
||||
+ {
|
||||
+ SGX_ERROR_MEMORY_MAP_FAILURE,
|
||||
+ "Failed to reserve memory for the enclave.",
|
||||
+ NULL
|
||||
+ },
|
||||
};
|
||||
|
||||
/* Check error conditions for loading enclave */
|
||||
diff --git a/SampleCode/SampleEnclave/App/App.cpp b/SampleCode/SampleEnclave/App/App.cpp
|
||||
index 6ac49c8..8aa10da 100644
|
||||
--- a/SampleCode/SampleEnclave/App/App.cpp
|
||||
+++ b/SampleCode/SampleEnclave/App/App.cpp
|
||||
@@ -128,6 +128,11 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
"Can't open enclave file.",
|
||||
NULL
|
||||
},
|
||||
+ {
|
||||
+ SGX_ERROR_MEMORY_MAP_FAILURE,
|
||||
+ "Failed to reserve memory for the enclave.",
|
||||
+ NULL
|
||||
+ },
|
||||
};
|
||||
|
||||
/* Check error conditions for loading enclave */
|
||||
diff --git a/SampleCode/SampleEnclaveGMIPP/App/App.cpp b/SampleCode/SampleEnclaveGMIPP/App/App.cpp
|
||||
index 9e951ae..8b2123c 100644
|
||||
--- a/SampleCode/SampleEnclaveGMIPP/App/App.cpp
|
||||
+++ b/SampleCode/SampleEnclaveGMIPP/App/App.cpp
|
||||
@@ -129,6 +129,11 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
"Can't open enclave file.",
|
||||
NULL
|
||||
},
|
||||
+ {
|
||||
+ SGX_ERROR_MEMORY_MAP_FAILURE,
|
||||
+ "Failed to reserve memory for the enclave.",
|
||||
+ NULL
|
||||
+ },
|
||||
};
|
||||
|
||||
/* Check error conditions for loading enclave */
|
||||
diff --git a/SampleCode/SampleEnclavePCL/App/App.cpp b/SampleCode/SampleEnclavePCL/App/App.cpp
|
||||
index 092c68f..42d3c64 100644
|
||||
--- a/SampleCode/SampleEnclavePCL/App/App.cpp
|
||||
+++ b/SampleCode/SampleEnclavePCL/App/App.cpp
|
||||
@@ -158,6 +158,11 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
"PCL sealed key GUID mismatch.",
|
||||
NULL
|
||||
},
|
||||
+ {
|
||||
+ SGX_ERROR_MEMORY_MAP_FAILURE,
|
||||
+ "Failed to reserve memory for the enclave.",
|
||||
+ NULL
|
||||
+ },
|
||||
};
|
||||
|
||||
/* Check error conditions for loading enclave */
|
||||
diff --git a/SampleCode/SealUnseal/App/ErrorSupport.cpp b/SampleCode/SealUnseal/App/ErrorSupport.cpp
|
||||
index d890442..8b456a8 100644
|
||||
--- a/SampleCode/SealUnseal/App/ErrorSupport.cpp
|
||||
+++ b/SampleCode/SealUnseal/App/ErrorSupport.cpp
|
||||
@@ -50,6 +50,7 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
{SGX_ERROR_OUT_OF_EPC, "Out of EPC memory."},
|
||||
{SGX_ERROR_NO_DEVICE, "Invalid SGX device."},
|
||||
{SGX_ERROR_MEMORY_MAP_CONFLICT, "Memory map conflicted."},
|
||||
+ {SGX_ERROR_MEMORY_MAP_FAILURE, "Failed to reserve memory for the enclave."},
|
||||
{SGX_ERROR_INVALID_METADATA, "Invalid encalve metadata."},
|
||||
{SGX_ERROR_DEVICE_BUSY, "SGX device is busy."},
|
||||
{SGX_ERROR_INVALID_VERSION, "Enclave metadata version is invalid."},
|
||||
diff --git a/SampleCode/Switchless/App/App.cpp b/SampleCode/Switchless/App/App.cpp
|
||||
index e86b49b..4f05c19 100644
|
||||
--- a/SampleCode/Switchless/App/App.cpp
|
||||
+++ b/SampleCode/Switchless/App/App.cpp
|
||||
@@ -132,6 +132,11 @@ static sgx_errlist_t sgx_errlist[] = {
|
||||
"Can't open enclave file.",
|
||||
NULL
|
||||
},
|
||||
+ {
|
||||
+ SGX_ERROR_MEMORY_MAP_FAILURE,
|
||||
+ "Failed to reserve memory for the enclave.",
|
||||
+ NULL
|
||||
+ },
|
||||
};
|
||||
|
||||
/* Check error conditions for loading enclave */
|
||||
diff --git a/common/inc/sgx_error.h b/common/inc/sgx_error.h
|
||||
index 1a410ca..d38ec05 100644
|
||||
--- a/common/inc/sgx_error.h
|
||||
+++ b/common/inc/sgx_error.h
|
||||
@@ -61,7 +61,7 @@ typedef enum _status_t
|
||||
SGX_ERROR_NDEBUG_ENCLAVE = SGX_MK_ERROR(0x2004), /* The enclave is signed as product enclave, and can not be created as debuggable enclave. */
|
||||
SGX_ERROR_OUT_OF_EPC = SGX_MK_ERROR(0x2005), /* Not enough EPC is available to load the enclave */
|
||||
SGX_ERROR_NO_DEVICE = SGX_MK_ERROR(0x2006), /* Can't open SGX device */
|
||||
- SGX_ERROR_MEMORY_MAP_CONFLICT= SGX_MK_ERROR(0x2007), /* Page mapping failed in driver */
|
||||
+ SGX_ERROR_MEMORY_MAP_CONFLICT= SGX_MK_ERROR(0x2007), /* Page mapping failed in driver. Deprecated*/
|
||||
SGX_ERROR_INVALID_METADATA = SGX_MK_ERROR(0x2009), /* The metadata is incorrect. */
|
||||
SGX_ERROR_DEVICE_BUSY = SGX_MK_ERROR(0x200c), /* Device is busy, mostly EINIT failed. */
|
||||
SGX_ERROR_INVALID_VERSION = SGX_MK_ERROR(0x200d), /* Metadata version is inconsistent between uRTS and sgx_sign or uRTS is incompatible with current platform. */
|
||||
diff --git a/psw/ae/aesm_service/source/oal/linux/internal_log.cpp b/psw/ae/aesm_service/source/oal/linux/internal_log.cpp
|
||||
index f10c3de..c2be8fb 100644
|
||||
--- a/psw/ae/aesm_service/source/oal/linux/internal_log.cpp
|
||||
+++ b/psw/ae/aesm_service/source/oal/linux/internal_log.cpp
|
||||
@@ -468,6 +468,7 @@ static const char *get_sgx_status_t_string(sgx_status_t status)
|
||||
CASE_ENUM_RET_STRING(SGX_ERROR_OUT_OF_EPC)
|
||||
CASE_ENUM_RET_STRING(SGX_ERROR_NO_DEVICE)
|
||||
CASE_ENUM_RET_STRING(SGX_ERROR_MEMORY_MAP_CONFLICT)
|
||||
+ CASE_ENUM_RET_STRING(SGX_ERROR_MEMORY_MAP_FAILURE)
|
||||
CASE_ENUM_RET_STRING(SGX_ERROR_INVALID_METADATA)
|
||||
CASE_ENUM_RET_STRING(SGX_ERROR_DEVICE_BUSY)
|
||||
CASE_ENUM_RET_STRING(SGX_ERROR_INVALID_VERSION)
|
||||
diff --git a/psw/urts/loader.cpp b/psw/urts/loader.cpp
|
||||
index bd98a3c..7ad8a69 100644
|
||||
--- a/psw/urts/loader.cpp
|
||||
+++ b/psw/urts/loader.cpp
|
||||
@@ -907,7 +907,7 @@ int CLoader::load_enclave(SGXLaunchToken *lc, int debug, const metadata_t *metad
|
||||
|
||||
int CLoader::load_enclave_ex(SGXLaunchToken *lc, bool debug, const metadata_t *metadata, sgx_config_id_t *config_id, sgx_config_svn_t config_svn, le_prd_css_file_t *prd_css_file, sgx_misc_attribute_t *misc_attr)
|
||||
{
|
||||
- unsigned int ret = SGX_SUCCESS, map_conflict_count = 3;
|
||||
+ unsigned int ret = SGX_SUCCESS, map_retry_count = 3;
|
||||
bool retry = true;
|
||||
|
||||
while (retry)
|
||||
@@ -919,12 +919,13 @@ int CLoader::load_enclave_ex(SGXLaunchToken *lc, bool debug, const metadata_t *m
|
||||
case SGX_ERROR_ENCLAVE_LOST: //caused by loading enclave while power transition occurs
|
||||
break;
|
||||
|
||||
- //If memroy map conflict occurs, we only retry 3 times.
|
||||
+ //If memroy map fail or conflict occurs, we only retry 3 times.
|
||||
+ case SGX_ERROR_MEMORY_MAP_FAILURE:
|
||||
case SGX_ERROR_MEMORY_MAP_CONFLICT:
|
||||
- if(0 == map_conflict_count)
|
||||
+ if(0 == map_retry_count)
|
||||
retry = false;
|
||||
else
|
||||
- map_conflict_count--;
|
||||
+ map_retry_count--;
|
||||
break;
|
||||
|
||||
//We don't re-load enclave due to other error code.
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: linux-sgx
|
||||
Version: 2.15.1
|
||||
Release: 12
|
||||
Release: 7
|
||||
Summary: Intel(R) Software Guard Extensions for Linux* OS
|
||||
ExclusiveArch: x86_64
|
||||
License: BSD-3-Clause
|
||||
@ -30,20 +30,6 @@ Patch8: backport-CVE-2022-2068-Fix-file-operations-in-c_rehash.patch
|
||||
Patch9: backport-CVE-2022-2097-Fix-AES-OCB-encrypt-decrypt-for-x86-AES-NI.patch
|
||||
Patch10: DCAP-disabling-the-rpatch-option.patch
|
||||
Patch11: add-strip-compilation-option-for-pck-id-retrieval-tool.patch
|
||||
Patch12: backport-Fix-sgx_create_enclave-retry-mechanism.patch
|
||||
Patch13: backport-CVE-2022-1941-Fix-parsing-vulnerability-for-MessageSet-type.patch
|
||||
Patch14: backport-Alternative-fix-for-CVE-2022-4304.patch
|
||||
Patch15: backport-CVE-2022-4450-Avoid-dangling-ptrs-in-header-and-data-params-for-PE.patch
|
||||
Patch16: backport-CVE-2023-0215-Fix-a-UAF-resulting-from-a-bug-in-BIO_new_NDEF.patch
|
||||
Patch17: backport-CVE-2023-0286-Fix-GENERAL_NAME_cmp-for-x400Address-1.patch
|
||||
Patch18: backport-CVE-2023-0464-x509-excessive-resource-use-verifying-policy-constra.patch
|
||||
Patch19: backport-CVE-2023-0465-Ensure-that-EXFLAG_INVALID_POLICY-is-checked-even-in.patch
|
||||
Patch20: backport-CVE-2023-0466-Fix-documentation-of-X509_VERIFY_PARAM_add0_policy.patch
|
||||
Patch21: backport-CVE-2023-2650-Restrict-the-size-of-OBJECT-IDENTIFIERs-that-OBJ_obj.patch
|
||||
Patch22: backport-CVE-2023-3446-Fix-DH_check-excessive-time-with-over-sized-modulus.patch
|
||||
Patch23: backport-CVE-2023-3817-DH_check-Do-not-try-checking-q-properties-if-it-is-o.patch
|
||||
Patch24: backport-CVE-2023-5678-Make-DH_check_pub_key-and-DH_generate_key-safer-yet.patch
|
||||
Patch25: backport-CVE-2024-5535-Fix-SSL_select_next_proto-and-add-ALPN.patch
|
||||
|
||||
BuildRequires: gcc-c++ protobuf-devel libtool ocaml-ocamlbuild openssl openssl-devel cmake python curl-devel createrepo_c git nasm
|
||||
|
||||
@ -764,9 +750,7 @@ rm -rf %{?buildroot}/libsgx-headers-dir/
|
||||
%pre
|
||||
|
||||
%post -n sgx-aesm-service
|
||||
if [ "$1" = "1" ];then
|
||||
if [ -x /opt/intel/sgx-aesm-service/startup.sh ]; then /opt/intel/sgx-aesm-service/startup.sh; fi
|
||||
fi
|
||||
if [ -x /opt/intel/sgx-aesm-service/startup.sh ]; then /opt/intel/sgx-aesm-service/startup.sh; fi
|
||||
|
||||
%post -n libsgx-enclave-common
|
||||
trigger_udev() {
|
||||
@ -903,28 +887,26 @@ echo -e "Installation succeed!"
|
||||
systemctl start mpa_registration_tool.service
|
||||
|
||||
%postun -n sgx-ra-service
|
||||
if [ "$1" = "0" ]; then
|
||||
# Generate the script to setup environment variables
|
||||
MPA_DST_PATH=/opt/intel/sgx-ra-service
|
||||
# Generate the script to setup environment variables
|
||||
MPA_DST_PATH=/opt/intel/sgx-ra-service
|
||||
|
||||
# Disable service
|
||||
if [ -d /run/systemd/users ]; then
|
||||
systemctl disable mpa_registration_tool.service
|
||||
fi
|
||||
|
||||
# Removing MPA configuration file
|
||||
rm -f /etc/init/mpa_registration_tool.conf
|
||||
rm -f /lib/systemd/system/mpa_registration_tool.service
|
||||
rm -f /usr/lib/systemd/system/mpa_registration_tool.service
|
||||
rm -f /etc/systemd/system/mpa_registration_tool.service
|
||||
|
||||
# Removing MPA folder
|
||||
rm -rf $MPA_DST_PATH
|
||||
|
||||
#Removing log file
|
||||
rm -f /var/log/mpa_registration.log
|
||||
# Disable service
|
||||
if [ -d /run/systemd/users ]; then
|
||||
systemctl disable mpa_registration_tool.service
|
||||
fi
|
||||
|
||||
# Removing MPA configuration file
|
||||
rm -f /etc/init/mpa_registration_tool.conf
|
||||
rm -f /lib/systemd/system/mpa_registration_tool.service
|
||||
rm -f /usr/lib/systemd/system/mpa_registration_tool.service
|
||||
rm -f /etc/systemd/system/mpa_registration_tool.service
|
||||
|
||||
# Removing MPA folder
|
||||
rm -rf $MPA_DST_PATH
|
||||
|
||||
#Removing log file
|
||||
rm -f /var/log/mpa_registration.log
|
||||
|
||||
echo -e "Uninstallation succeed!"
|
||||
|
||||
%postun -n sgx-pck-id-retrieval-tool
|
||||
@ -1048,21 +1030,6 @@ fi
|
||||
%files -n libsgx-headers -f %{LINUX_INSTALLER_RPM_DIR}/libsgx-headers/build/list-libsgx-headers
|
||||
|
||||
%changelog
|
||||
* Thu Jul 18 2024 wangqingsan<wangqingsan@huawei.com> - 2.15.1-12
|
||||
- fix CVE-2024-5535
|
||||
|
||||
* Tue Dec 26 2023 wangqingsan<wangqingsan@huawei.com> - 2.15.1-11
|
||||
- Disabling the Automatic Startup of Software Package Upgrade
|
||||
|
||||
* Tue Dec 19 2023 wangqingsan<wangqingsan@huawei.com> - 2.15.1-10
|
||||
- backport patch and cve
|
||||
|
||||
* Sat Oct 28 2023 houmingyong<houmingyong@huawei.com> - 2.15.1-9
|
||||
- backport patch and cve
|
||||
|
||||
* Sat Sep 24 2022 wangyu <wangyu283@huawei.com> - 2.15.1-8
|
||||
- The postun script should distinguish uninstall and upgrade scenarios
|
||||
|
||||
* Tue Sep 20 2022 wangyu <wangyu283@huawei.com> - 2.15.1-7
|
||||
- add strip compilation option for pck-id-retrieval-tool
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user