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,21 +354,12 @@ static bool build_emsa_pss_signature(private_gmp_rsa_private_key_t *this,
{
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,
params->mgf1_hash);
return FALSE;
DBG1(DBG_LIB, "%N is not supported for MGF1", hash_algorithm_names,
params->mgf1_hash);
return FALSE;
}
/* emBits = modBits - 1 */
embits = mpz_sizeinbase(this->n, 2) - 1;
@@ -304,21 +304,12 @@ static bool verify_emsa_pss_signature(private_gmp_rsa_public_key_t *this,
{
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,
params->mgf1_hash);
return FALSE;
DBG1(DBG_LIB, "%N is not supported for MGF1", hash_algorithm_names,
params->mgf1_hash);
return FALSE;
}
chunk_skip_zero(signature);
if (signature.len == 0 || signature.len > this->k)