signature-params: Properly handle MGF1 algorithm identifier without parameters
Credit to OSS-Fuzz. Fixes: CVE-2018-6459
This commit is contained in:
@@ -280,13 +280,17 @@ bool rsa_pss_params_parse(chunk_t asn1, int level0, rsa_pss_params_t *params)
|
|||||||
case RSASSA_PSS_PARAMS_MGF_ALG:
|
case RSASSA_PSS_PARAMS_MGF_ALG:
|
||||||
if (object.len)
|
if (object.len)
|
||||||
{
|
{
|
||||||
chunk_t hash;
|
chunk_t hash = chunk_empty;
|
||||||
|
|
||||||
alg = asn1_parse_algorithmIdentifier(object, level, &hash);
|
alg = asn1_parse_algorithmIdentifier(object, level, &hash);
|
||||||
if (alg != OID_MGF1)
|
if (alg != OID_MGF1)
|
||||||
{
|
{
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
if (!hash.len)
|
||||||
|
{
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
alg = asn1_parse_algorithmIdentifier(hash, level+1, NULL);
|
alg = asn1_parse_algorithmIdentifier(hash, level+1, NULL);
|
||||||
params->mgf1_hash = hasher_algorithm_from_oid(alg);
|
params->mgf1_hash = hasher_algorithm_from_oid(alg);
|
||||||
if (params->mgf1_hash == HASH_UNKNOWN)
|
if (params->mgf1_hash == HASH_UNKNOWN)
|
||||||
|
|||||||
Reference in New Issue
Block a user