mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-25 18:55:34 +00:00
pk_wrap: add a check for equal signature parts
This commit is contained in:
parent
f8c94a811a
commit
c097b0fded
|
@ -542,10 +542,9 @@ static psa_algorithm_t translate_md_to_psa( mbedtls_md_type_t md_alg )
|
||||||
static int extract_ecdsa_sig( unsigned char **p, const unsigned char *end,
|
static int extract_ecdsa_sig( unsigned char **p, const unsigned char *end,
|
||||||
mbedtls_asn1_buf *sig )
|
mbedtls_asn1_buf *sig )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret, tag_type;
|
||||||
size_t len_signature;
|
size_t len_signature, len_partial;
|
||||||
size_t len_partial;
|
|
||||||
int tag_type;
|
|
||||||
if( ( end - *p ) < 1 )
|
if( ( end - *p ) < 1 )
|
||||||
{
|
{
|
||||||
return( MBEDTLS_ERR_X509_INVALID_SIGNATURE +
|
return( MBEDTLS_ERR_X509_INVALID_SIGNATURE +
|
||||||
|
@ -590,6 +589,10 @@ static int extract_ecdsa_sig( unsigned char **p, const unsigned char *end,
|
||||||
len_partial--;
|
len_partial--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if both parts are of the same size
|
||||||
|
if( len_partial != len_signature )
|
||||||
|
return( MBEDTLS_ERR_X509_INVALID_SIGNATURE );
|
||||||
|
|
||||||
memcpy( sig->p + len_partial, *p, len_partial );
|
memcpy( sig->p + len_partial, *p, len_partial );
|
||||||
len_signature += len_partial;
|
len_signature += len_partial;
|
||||||
sig->tag = tag_type;
|
sig->tag = tag_type;
|
||||||
|
|
Loading…
Reference in a new issue