mirror of
https://github.com/strongswan/strongswan.git
synced 2025-11-22 00:01:45 -05:00
use save chunk advancing, check signature length
This commit is contained in:
parent
ebde1a7ddd
commit
e7227f0ba0
@ -140,11 +140,10 @@ static bool verify_emsa_pkcs1_signature(private_gmp_rsa_public_key_t *this,
|
|||||||
/* remove any preceding 0-bytes from signature */
|
/* remove any preceding 0-bytes from signature */
|
||||||
while (signature.len && *(signature.ptr) == 0x00)
|
while (signature.len && *(signature.ptr) == 0x00)
|
||||||
{
|
{
|
||||||
signature.len -= 1;
|
signature = chunk_skip(signature, 1);
|
||||||
signature.ptr++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signature.len > this->k)
|
if (signature.len == 0 || signature.len > this->k)
|
||||||
{
|
{
|
||||||
return INVALID_ARG;
|
return INVALID_ARG;
|
||||||
}
|
}
|
||||||
@ -163,8 +162,7 @@ static bool verify_emsa_pkcs1_signature(private_gmp_rsa_public_key_t *this,
|
|||||||
{
|
{
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
em.ptr += 2;
|
em = chunk_skip(em, 2);
|
||||||
em.len -= 2;
|
|
||||||
|
|
||||||
/* find magic 0x00 */
|
/* find magic 0x00 */
|
||||||
while (em.len > 0)
|
while (em.len > 0)
|
||||||
@ -172,8 +170,7 @@ static bool verify_emsa_pkcs1_signature(private_gmp_rsa_public_key_t *this,
|
|||||||
if (*em.ptr == 0x00)
|
if (*em.ptr == 0x00)
|
||||||
{
|
{
|
||||||
/* found magic byte, stop */
|
/* found magic byte, stop */
|
||||||
em.ptr++;
|
em = chunk_skip(em, 1);
|
||||||
em.len--;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (*em.ptr != 0xFF)
|
else if (*em.ptr != 0xFF)
|
||||||
@ -181,8 +178,7 @@ static bool verify_emsa_pkcs1_signature(private_gmp_rsa_public_key_t *this,
|
|||||||
/* bad padding, decryption failed ?!*/
|
/* bad padding, decryption failed ?!*/
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
em.ptr++;
|
em = chunk_skip(em, 1);
|
||||||
em.len--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (em.len == 0)
|
if (em.len == 0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user