Skip to content

Commit 43d8f88

Browse files
mattcaswelllevitte
authored andcommitted
Fix Timing Oracle in RSA decryption
A timing based side channel exists in the OpenSSL RSA Decryption implementation which could be sufficient to recover a plaintext across a network in a Bleichenbacher style attack. To achieve a successful decryption an attacker would have to be able to send a very large number of trial messages for decryption. The vulnerability affects all RSA padding modes: PKCS#1 v1.5, RSA-OEAP and RSASVE. Patch written by Dmitry Belyavsky and Hubert Kario CVE-2022-4304 Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org>
1 parent 1dc2ae4 commit 43d8f88

File tree

9 files changed

+653
-20
lines changed

9 files changed

+653
-20
lines changed

crypto/bn/bn_blind.c

-14
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,6 @@
1313

1414
#define BN_BLINDING_COUNTER 32
1515

16-
struct bn_blinding_st {
17-
BIGNUM *A;
18-
BIGNUM *Ai;
19-
BIGNUM *e;
20-
BIGNUM *mod; /* just a reference */
21-
CRYPTO_THREAD_ID tid;
22-
int counter;
23-
unsigned long flags;
24-
BN_MONT_CTX *m_ctx;
25-
int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
26-
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
27-
CRYPTO_RWLOCK *lock;
28-
};
29-
3016
BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod)
3117
{
3218
BN_BLINDING *ret = NULL;

crypto/bn/bn_err.c

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ static const ERR_STRING_DATA BN_str_functs[] = {
7373
{ERR_PACK(ERR_LIB_BN, BN_F_BN_SET_WORDS, 0), "bn_set_words"},
7474
{ERR_PACK(ERR_LIB_BN, BN_F_BN_STACK_PUSH, 0), "BN_STACK_push"},
7575
{ERR_PACK(ERR_LIB_BN, BN_F_BN_USUB, 0), "BN_usub"},
76+
{ERR_PACK(ERR_LIB_BN, BN_F_OSSL_BN_RSA_DO_UNBLIND, 0),
77+
"ossl_bn_rsa_do_unblind"},
7678
{0, NULL}
7779
};
7880

crypto/bn/bn_local.h

+14
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,20 @@ struct bn_gencb_st {
283283
} cb;
284284
};
285285

286+
struct bn_blinding_st {
287+
BIGNUM *A;
288+
BIGNUM *Ai;
289+
BIGNUM *e;
290+
BIGNUM *mod; /* just a reference */
291+
CRYPTO_THREAD_ID tid;
292+
int counter;
293+
unsigned long flags;
294+
BN_MONT_CTX *m_ctx;
295+
int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
296+
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
297+
CRYPTO_RWLOCK *lock;
298+
};
299+
286300
/*-
287301
* BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
288302
*

crypto/bn/build.info

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ SOURCE[../../libcrypto]=\
55
bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c \
66
{- $target{bn_asm_src} -} \
77
bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \
8-
bn_depr.c bn_const.c bn_x931p.c bn_intern.c bn_dh.c bn_srp.c
8+
bn_depr.c bn_const.c bn_x931p.c bn_intern.c bn_dh.c bn_srp.c \
9+
rsa_sup_mul.c
910

1011
INCLUDE[bn_exp.o]=..
1112

0 commit comments

Comments
 (0)