mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 23:14:23 +01:00
Reduce code-size of mbedtls_asn1_get_alg()
The previous code - checked that at least 1 byte of ASN.1 tag data is available, - read and stored that ASN.1 tag, - called the ASN.1 parsing function, part of which is checking that enough space is available and that the ASN.1 tag matches the expected value MBEDTLS_ASN1_OID. Since the ASN.1 parsing function includes bounds checks, this can be streamlined to: - call the ASN.1 parsing function directly, - on success, store MBEDTLS_ASN1_OID in the tag field. This commit applies this simplification to mbedtls_asn1_get_alg().
This commit is contained in:
parent
30cb1ac23e
commit
b5419867cd
@ -295,15 +295,12 @@ int mbedtls_asn1_get_alg( unsigned char **p,
|
||||
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
if( ( end - *p ) < 1 )
|
||||
return( MBEDTLS_ERR_ASN1_OUT_OF_DATA );
|
||||
|
||||
alg->tag = **p;
|
||||
end = *p + len;
|
||||
|
||||
if( ( ret = mbedtls_asn1_get_tag( p, end, &alg->len, MBEDTLS_ASN1_OID ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
alg->tag = MBEDTLS_ASN1_OID;
|
||||
alg->p = *p;
|
||||
*p += alg->len;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user