gmp: Use helper to determine XOF type

This commit is contained in:
Tobias Brunner
2017-11-08 16:48:10 +01:00
parent 883e7fcd65
commit 126fd8af09
2 changed files with 10 additions and 28 deletions
@@ -354,18 +354,9 @@ static bool build_emsa_pss_signature(private_gmp_rsa_private_key_t *this,
{ {
return FALSE; return FALSE;
} }
switch (params->mgf1_hash) xof = xof_mgf1_from_hash_algorithm(params->mgf1_hash);
if (xof == XOF_UNDEFINED)
{ {
case HASH_SHA1:
xof = XOF_MGF1_SHA1;
break;
case HASH_SHA256:
xof = XOF_MGF1_SHA256;
break;
case HASH_SHA512:
xof = XOF_MGF1_SHA512;
break;
default:
DBG1(DBG_LIB, "%N is not supported for MGF1", hash_algorithm_names, DBG1(DBG_LIB, "%N is not supported for MGF1", hash_algorithm_names,
params->mgf1_hash); params->mgf1_hash);
return FALSE; return FALSE;
@@ -304,18 +304,9 @@ static bool verify_emsa_pss_signature(private_gmp_rsa_public_key_t *this,
{ {
return FALSE; return FALSE;
} }
switch (params->mgf1_hash) xof = xof_mgf1_from_hash_algorithm(params->mgf1_hash);
if (xof == XOF_UNDEFINED)
{ {
case HASH_SHA1:
xof = XOF_MGF1_SHA1;
break;
case HASH_SHA256:
xof = XOF_MGF1_SHA256;
break;
case HASH_SHA512:
xof = XOF_MGF1_SHA512;
break;
default:
DBG1(DBG_LIB, "%N is not supported for MGF1", hash_algorithm_names, DBG1(DBG_LIB, "%N is not supported for MGF1", hash_algorithm_names,
params->mgf1_hash); params->mgf1_hash);
return FALSE; return FALSE;