signature-params: Reject RSASSA-PSS params that result in negative salt len

The `salt_len` member in the struct is of type `ssize_t` because we use
negative values for special automatic salt lengths when generating
signatures.  This change ensures that `salt_len` will not overflow the
`len` fields of chunks (`size_t`), which could lead to integer overflows
when validating signatures (see the next commit).

Fixes: a22316520b ("signature-params: Add functions to parse/build ASN.1 RSASSA-PSS params")
This commit is contained in:
Tobias Brunner
2021-10-14 18:59:07 +02:00
parent 2403154f95
commit 03fbceb3f5
2 changed files with 11 additions and 1 deletions
@@ -322,7 +322,11 @@ bool rsa_pss_params_parse(chunk_t asn1, int level0, rsa_pss_params_t *params)
case RSASSA_PSS_PARAMS_SALT_LEN:
if (object.len)
{
params->salt_len = (size_t)asn1_parse_integer_uint64(object);
params->salt_len = (ssize_t)asn1_parse_integer_uint64(object);
if (params->salt_len < 0)
{
goto end;
}
}
break;
case RSASSA_PSS_PARAMS_TRAILER: