mirror of
git://git.openembedded.org/meta-openembedded
synced 2026-10-02 14:04:47 +00:00
CVE-2023-5992: A vulnerability was found in OpenSC where PKCS#1 encryption padding removal is not implemented as side-channel resistant. This issue may result in the potential leak of private data. Reference: [https://nvd.nist.gov/vuln/detail/CVE-2023-5992] [https://github.com/OpenSC/OpenSC/wiki/CVE-2023-5992] Upstream patches: [https://github.com/OpenSC/OpenSC/pull/2948] [https://github.com/OpenSC/OpenSC/pull/3016] Signed-off-by: Zhang Peng <peng.zhang1.cn@windriver.com> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
64 lines
2.0 KiB
Diff
64 lines
2.0 KiB
Diff
From f7fc30b02090d657b9ba64cbb5168cb5a94592ef Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Veronika=20Hanul=C3=ADkov=C3=A1?= <vhanulik@redhat.com>
|
|
Date: Mon, 8 Jan 2024 14:59:22 +0100
|
|
Subject: [PATCH 05/10] mechanism: Handle PKCS#1 v1.5 depadding constant-time
|
|
|
|
CVE: CVE-2023-5992
|
|
Upstream-Status: Backport [https://github.com/OpenSC/OpenSC/pull/2948]
|
|
|
|
Signed-off-by: Zhang Peng <peng.zhang1.cn@windriver.com>
|
|
---
|
|
src/pkcs11/mechanism.c | 15 +++++++++++++--
|
|
1 file changed, 13 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/pkcs11/mechanism.c b/src/pkcs11/mechanism.c
|
|
index c5959b36b..b3fce1714 100644
|
|
--- a/src/pkcs11/mechanism.c
|
|
+++ b/src/pkcs11/mechanism.c
|
|
@@ -23,6 +23,7 @@
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
+#include "common/constant-time.h"
|
|
#include "sc-pkcs11.h"
|
|
|
|
/* Also used for verification data */
|
|
@@ -844,7 +845,9 @@ sc_pkcs11_decr(struct sc_pkcs11_session *session,
|
|
rv = op->type->decrypt(op, pEncryptedData, ulEncryptedDataLen,
|
|
pData, pulDataLen);
|
|
|
|
- if (rv != CKR_BUFFER_TOO_SMALL && pData != NULL)
|
|
+ /* terminate session for any return value except CKR_BUFFER_TOO_SMALL,
|
|
+ * perform check in time side-channel free way to prevent Marvin attack */
|
|
+ if (!constant_time_eq_s(rv, CKR_BUFFER_TOO_SMALL) && pData != NULL)
|
|
session_stop_operation(session, SC_PKCS11_OPERATION_DECRYPT);
|
|
|
|
return rv;
|
|
@@ -1084,14 +1087,22 @@ sc_pkcs11_decrypt(sc_pkcs11_operation_t *operation,
|
|
{
|
|
struct signature_data *data;
|
|
struct sc_pkcs11_object *key;
|
|
+ CK_RV rv;
|
|
|
|
data = (struct signature_data*) operation->priv_data;
|
|
|
|
key = data->key;
|
|
- return key->ops->decrypt(operation->session,
|
|
+ rv = key->ops->decrypt(operation->session,
|
|
key, &operation->mechanism,
|
|
pEncryptedData, ulEncryptedDataLen,
|
|
pData, pulDataLen);
|
|
+
|
|
+ /* Skip DecryptFinalize for PKCS#1 v1.5 padding to prevent time side-channel leakage */
|
|
+ if (((CK_MECHANISM_PTR)&operation->mechanism)->mechanism == CKM_RSA_PKCS)
|
|
+ return rv;
|
|
+
|
|
+ if (rv != CKR_OK)
|
|
+ return rv;
|
|
}
|
|
|
|
static CK_RV
|
|
--
|
|
2.50.0
|
|
|