mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Merge pull request #5991 from gilles-peskine-arm/asn1write-0-fix-2.28
Backport 2.28: Improve ASN.1 write tests
This commit is contained in:
@ -133,6 +133,11 @@ int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start, const mbedt
|
||||
//
|
||||
len = mbedtls_mpi_size( X );
|
||||
|
||||
/* DER represents 0 with a sign bit (0=nonnegative) and 7 value bits, not
|
||||
* as 0 digits. We need to end up with 020100, not with 0200. */
|
||||
if( len == 0 )
|
||||
len = 1;
|
||||
|
||||
if( *p < start || (size_t)( *p - start ) < len )
|
||||
return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL );
|
||||
|
||||
|
Reference in New Issue
Block a user