|
|
a74aed |
From c149dd0767f32789e391280cb1eb06b7eb7c6bce Mon Sep 17 00:00:00 2001
|
|
|
a74aed |
From: Alexander Sosedkin <asosedkin@redhat.com>
|
|
|
a74aed |
Date: Tue, 9 Aug 2022 16:05:53 +0200
|
|
|
a74aed |
Subject: [PATCH 1/2] auth/rsa: side-step potential side-channel
|
|
|
a74aed |
|
|
|
a74aed |
Remove branching that depends on secret data.
|
|
|
a74aed |
|
|
|
a74aed |
Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
|
|
|
a74aed |
Signed-off-by: Hubert Kario <hkario@redhat.com>
|
|
|
a74aed |
Tested-by: Hubert Kario <hkario@redhat.com>
|
|
|
a74aed |
---
|
|
|
a74aed |
lib/auth/rsa.c | 10 ----------
|
|
|
a74aed |
1 file changed, 10 deletions(-)
|
|
|
a74aed |
|
|
|
a74aed |
diff --git a/lib/auth/rsa.c b/lib/auth/rsa.c
|
|
|
a74aed |
index 8108ee841d..6b158bacb2 100644
|
|
|
a74aed |
--- a/lib/auth/rsa.c
|
|
|
a74aed |
+++ b/lib/auth/rsa.c
|
|
|
a74aed |
@@ -155,7 +155,6 @@ static int
|
|
|
a74aed |
proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
|
|
a74aed |
size_t _data_size)
|
|
|
a74aed |
{
|
|
|
a74aed |
- const char attack_error[] = "auth_rsa: Possible PKCS #1 attack\n";
|
|
|
a74aed |
gnutls_datum_t ciphertext;
|
|
|
a74aed |
int ret, dsize;
|
|
|
a74aed |
ssize_t data_size = _data_size;
|
|
|
a74aed |
@@ -235,15 +234,6 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
|
|
a74aed |
ok &= CONSTCHECK_NOT_EQUAL(check_ver_min, 0) &
|
|
|
a74aed |
CONSTCHECK_EQUAL(session->key.key.data[1], ver_min);
|
|
|
a74aed |
|
|
|
a74aed |
- if (ok) {
|
|
|
a74aed |
- /* call logging function unconditionally so all branches are
|
|
|
a74aed |
- * indistinguishable for timing and cache access when debug
|
|
|
a74aed |
- * logging is disabled */
|
|
|
a74aed |
- _gnutls_no_log("%s", attack_error);
|
|
|
a74aed |
- } else {
|
|
|
a74aed |
- _gnutls_debug_log("%s", attack_error);
|
|
|
a74aed |
- }
|
|
|
a74aed |
-
|
|
|
a74aed |
/* This is here to avoid the version check attack
|
|
|
a74aed |
* discussed above.
|
|
|
a74aed |
*/
|
|
|
a74aed |
--
|
|
|
a74aed |
2.39.1
|
|
|
a74aed |
|
|
|
a74aed |
|
|
|
a74aed |
From 7c963102ec2119eecc1789b993aabe5edfd75f3b Mon Sep 17 00:00:00 2001
|
|
|
a74aed |
From: Hubert Kario <hkario@redhat.com>
|
|
|
a74aed |
Date: Wed, 8 Feb 2023 14:32:09 +0100
|
|
|
a74aed |
Subject: [PATCH 2/2] rsa: remove dead code
|
|
|
a74aed |
|
|
|
a74aed |
since the `ok` variable isn't used any more, we can remove all code
|
|
|
a74aed |
used to calculate it
|
|
|
a74aed |
|
|
|
a74aed |
Signed-off-by: Hubert Kario <hkario@redhat.com>
|
|
|
a74aed |
---
|
|
|
a74aed |
lib/auth/rsa.c | 20 +++-----------------
|
|
|
a74aed |
1 file changed, 3 insertions(+), 17 deletions(-)
|
|
|
a74aed |
|
|
|
a74aed |
diff --git a/lib/auth/rsa.c b/lib/auth/rsa.c
|
|
|
a74aed |
index 6b158bacb2..858701fe6e 100644
|
|
|
a74aed |
--- a/lib/auth/rsa.c
|
|
|
a74aed |
+++ b/lib/auth/rsa.c
|
|
|
a74aed |
@@ -159,8 +159,6 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
|
|
a74aed |
int ret, dsize;
|
|
|
a74aed |
ssize_t data_size = _data_size;
|
|
|
a74aed |
volatile uint8_t ver_maj, ver_min;
|
|
|
a74aed |
- volatile uint8_t check_ver_min;
|
|
|
a74aed |
- volatile uint32_t ok;
|
|
|
a74aed |
|
|
|
a74aed |
#ifdef ENABLE_SSL3
|
|
|
a74aed |
if (get_num_version(session) == GNUTLS_SSL3) {
|
|
|
a74aed |
@@ -186,7 +184,6 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
|
|
a74aed |
|
|
|
a74aed |
ver_maj = _gnutls_get_adv_version_major(session);
|
|
|
a74aed |
ver_min = _gnutls_get_adv_version_minor(session);
|
|
|
a74aed |
- check_ver_min = (session->internals.allow_wrong_pms == 0);
|
|
|
a74aed |
|
|
|
a74aed |
session->key.key.data = gnutls_malloc(GNUTLS_MASTER_SIZE);
|
|
|
a74aed |
if (session->key.key.data == NULL) {
|
|
|
a74aed |
@@ -205,10 +202,9 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
|
|
a74aed |
return ret;
|
|
|
a74aed |
}
|
|
|
a74aed |
|
|
|
a74aed |
- ret =
|
|
|
a74aed |
- gnutls_privkey_decrypt_data2(session->internals.selected_key,
|
|
|
a74aed |
- 0, &ciphertext, session->key.key.data,
|
|
|
a74aed |
- session->key.key.size);
|
|
|
a74aed |
+ gnutls_privkey_decrypt_data2(session->internals.selected_key,
|
|
|
a74aed |
+ 0, &ciphertext, session->key.key.data,
|
|
|
a74aed |
+ session->key.key.size);
|
|
|
a74aed |
/* After this point, any conditional on failure that cause differences
|
|
|
a74aed |
* in execution may create a timing or cache access pattern side
|
|
|
a74aed |
* channel that can be used as an oracle, so treat very carefully */
|
|
|
a74aed |
@@ -224,16 +220,6 @@ proc_rsa_client_kx(gnutls_session_t session, uint8_t * data,
|
|
|
a74aed |
* Vlastimil Klima, Ondej Pokorny and Tomas Rosa.
|
|
|
a74aed |
*/
|
|
|
a74aed |
|
|
|
a74aed |
- /* ok is 0 in case of error and 1 in case of success. */
|
|
|
a74aed |
-
|
|
|
a74aed |
- /* if ret < 0 */
|
|
|
a74aed |
- ok = CONSTCHECK_EQUAL(ret, 0);
|
|
|
a74aed |
- /* session->key.key.data[0] must equal ver_maj */
|
|
|
a74aed |
- ok &= CONSTCHECK_EQUAL(session->key.key.data[0], ver_maj);
|
|
|
a74aed |
- /* if check_ver_min then session->key.key.data[1] must equal ver_min */
|
|
|
a74aed |
- ok &= CONSTCHECK_NOT_EQUAL(check_ver_min, 0) &
|
|
|
a74aed |
- CONSTCHECK_EQUAL(session->key.key.data[1], ver_min);
|
|
|
a74aed |
-
|
|
|
a74aed |
/* This is here to avoid the version check attack
|
|
|
a74aed |
* discussed above.
|
|
|
a74aed |
*/
|
|
|
a74aed |
--
|
|
|
a74aed |
2.39.1
|
|
|
a74aed |
|