Skip to content

Commit 8e257b8

Browse files
beldmitt8m
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: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org>
1 parent fe6842f commit 8e257b8

File tree

6 files changed

+638
-21
lines changed

6 files changed

+638
-21
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_local.h

+14
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,20 @@ struct bn_gencb_st {
290290
} cb;
291291
};
292292

293+
struct bn_blinding_st {
294+
BIGNUM *A;
295+
BIGNUM *Ai;
296+
BIGNUM *e;
297+
BIGNUM *mod; /* just a reference */
298+
CRYPTO_THREAD_ID tid;
299+
int counter;
300+
unsigned long flags;
301+
BN_MONT_CTX *m_ctx;
302+
int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
303+
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
304+
CRYPTO_RWLOCK *lock;
305+
};
306+
293307
/*-
294308
* BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
295309
*

crypto/bn/build.info

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ $COMMON=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c \
105105
bn_mod.c bn_conv.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
106106
bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_sqr.c \
107107
bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \
108-
bn_intern.c bn_dh.c bn_rsa_fips186_4.c bn_const.c
108+
bn_intern.c bn_dh.c bn_rsa_fips186_4.c bn_const.c rsa_sup_mul.c
109109
SOURCE[../../libcrypto]=$COMMON $BNASM bn_print.c bn_err.c bn_srp.c
110110
DEFINE[../../libcrypto]=$BNDEF
111111
IF[{- !$disabled{'deprecated-0.9.8'} -}]

0 commit comments

Comments
 (0)