Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant time RSA PKCS#1 v1.5 depadding #2948

Merged
merged 8 commits into from
Feb 5, 2024
Prev Previous commit
Next Next commit
pkcs11-object: Remove return value logging
To prevent Marvin attack on RSA PKCS#1 v1.5 padding
when logging the return value, signaling the padding error.
  • Loading branch information
xhanulik committed Jan 31, 2024
commit 306dc92bd4d2d74203f53cf3d9ea68c223115375
9 changes: 6 additions & 3 deletions src/pkcs11/pkcs11-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,8 @@ C_Decrypt(CK_SESSION_HANDLE hSession, /* the session's handle */
rv = reset_login_state(session->slot, rv);
}

SC_LOG_RV("C_Decrypt() = %s", rv);
/* do not log error code to prevent side channel attack */
SC_LOG("C_Decrypt()");
sc_pkcs11_unlock();
return rv;
}
Expand All @@ -1058,7 +1059,8 @@ C_DecryptUpdate(CK_SESSION_HANDLE hSession, /* the session's handle */
rv = sc_pkcs11_decr_update(session, pEncryptedPart, ulEncryptedPartLen,
pPart, pulPartLen);

SC_LOG_RV("C_DecryptUpdate() = %s", rv);
/* do not log error code to prevent side channel attack */
SC_LOG("C_DecryptUpdate()");
sc_pkcs11_unlock();
return rv;
}
Expand Down Expand Up @@ -1086,7 +1088,8 @@ C_DecryptFinal(CK_SESSION_HANDLE hSession, /* the session's handle */
rv = reset_login_state(session->slot, rv);
}

SC_LOG_RV("C_DecryptFinal() = %s", rv);
/* do not log error code to prevent side channel attack */
SC_LOG("C_DecryptFinal()");
sc_pkcs11_unlock();
return rv;
}
Expand Down
5 changes: 5 additions & 0 deletions src/pkcs11/sc-pkcs11.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ do {\
}\
} while(0)

#define SC_LOG(fmt) \
do { \
sc_log(context, (fmt)); \
} while (0)

/* Debug virtual slots. S is slot to be highlighted or NULL
* C is a comment format string and args It will be preceded by "VSS " */
#define DEBUG_VSS(S, ...) do { sc_log(context,"VSS " __VA_ARGS__); _debug_virtual_slots(S); } while (0)
Expand Down