Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions lib/pkcs11h-openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ __pkcs11h_openssl_rsa_dec (
rv = CKR_MECHANISM_INVALID;
break;
case RSA_NO_PADDING:
mech = CKM_RSA_X_509;
break;
default:
rv = CKR_MECHANISM_INVALID;
break;
}
Expand Down Expand Up @@ -552,6 +555,7 @@ __pkcs11h_openssl_rsa_enc (
PKCS11H_BOOL session_locked = FALSE;
CK_RV rv = CKR_FUNCTION_FAILED;
size_t tlen;
CK_MECHANISM_TYPE mech = CKM_RSA_PKCS;

_PKCS11H_ASSERT (from!=NULL);
_PKCS11H_ASSERT (to!=NULL);
Expand All @@ -567,9 +571,16 @@ __pkcs11h_openssl_rsa_enc (
padding
);

if (padding != RSA_PKCS1_PADDING) {
rv = CKR_MECHANISM_INVALID;
goto cleanup;
switch (padding) {
case RSA_PKCS1_PADDING:
mech = CKM_RSA_PKCS;
break;
case RSA_NO_PADDING:
mech = CKM_RSA_X_509;
break;
default:
rv = CKR_MECHANISM_INVALID;
goto cleanup;
}

tlen = (size_t)RSA_size(rsa);
Expand All @@ -587,7 +598,7 @@ __pkcs11h_openssl_rsa_enc (
if (
(rv = pkcs11h_certificate_signAny (
certificate,
CKM_RSA_PKCS,
mech,
from,
flen,
to,
Expand Down