idprime: Create algorithme reference based on the MGF1 flags as the HASH flags are no longer present for RSA-PSS mechanism

This commit is contained in:
Jakub Jelen 2021-01-18 11:37:59 +01:00 committed by Frank Morgner
parent 44d429c3ad
commit e1c8361ff3
1 changed files with 10 additions and 10 deletions

View File

@ -627,13 +627,13 @@ idprime_set_security_env(struct sc_card *card,
switch (env->operation) {
case SC_SEC_OPERATION_DECIPHER:
if (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_OAEP) {
if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA1) {
if (env->algorithm_flags & SC_ALGORITHM_MGF1_SHA1) {
new_env.algorithm_ref = 0x1D;
} else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA256) {
} else if (env->algorithm_flags & SC_ALGORITHM_MGF1_SHA256) {
new_env.algorithm_ref = 0x4D;
} else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA384) {
} else if (env->algorithm_flags & SC_ALGORITHM_MGF1_SHA384) {
new_env.algorithm_ref = 0x5D;
} else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA512) {
} else if (env->algorithm_flags & SC_ALGORITHM_MGF1_SHA512) {
new_env.algorithm_ref = 0x6D;
}
} else { /* RSA-PKCS without hashing */
@ -642,19 +642,19 @@ idprime_set_security_env(struct sc_card *card,
break;
case SC_SEC_OPERATION_SIGN:
if (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PSS) {
if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA256) {
if (env->algorithm_flags & SC_ALGORITHM_MGF1_SHA256) {
new_env.algorithm_ref = 0x45;
} else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA384) {
} else if (env->algorithm_flags & SC_ALGORITHM_MGF1_SHA384) {
new_env.algorithm_ref = 0x55;
} else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA512) {
} else if (env->algorithm_flags & SC_ALGORITHM_MGF1_SHA512) {
new_env.algorithm_ref = 0x65;
}
} else { /* RSA-PKCS */
if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA256) {
if (env->algorithm_flags & SC_ALGORITHM_MGF1_SHA256) {
new_env.algorithm_ref = 0x42;
} else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA384) {
} else if (env->algorithm_flags & SC_ALGORITHM_MGF1_SHA384) {
new_env.algorithm_ref = 0x52;
} else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA512) {
} else if (env->algorithm_flags & SC_ALGORITHM_MGF1_SHA512) {
new_env.algorithm_ref = 0x62;
} else { /* RSA-PKCS without hashing */
new_env.algorithm_ref = 0x02;