Added asn1_write_raw_buffer()

This commit is contained in:
Paul Bakker 2013-08-26 12:05:02 +02:00
parent 8adf13bd92
commit 6db915b5a9
2 changed files with 18 additions and 1 deletions

View File

@ -52,6 +52,8 @@ int asn1_write_bitstring( unsigned char **p, unsigned char *start,
const unsigned char *buf, size_t bits );
int asn1_write_octet_string( unsigned char **p, unsigned char *start,
const unsigned char *buf, size_t size );
int asn1_write_raw_buffer( unsigned char **p, unsigned char *start,
const unsigned char *buf, size_t size );
#ifdef __cplusplus
}

View File

@ -272,7 +272,7 @@ int asn1_write_octet_string( unsigned char **p, unsigned char *start,
int ret;
size_t len = 0;
if( *p - start < (int) size + 1 )
if( *p - start < (int) size )
return( POLARSSL_ERR_ASN1_BUF_TOO_SMALL );
len = size;
@ -285,4 +285,19 @@ int asn1_write_octet_string( unsigned char **p, unsigned char *start,
return( len );
}
int asn1_write_raw_buffer( unsigned char **p, unsigned char *start,
const unsigned char *buf, size_t size )
{
size_t len = 0;
if( *p - start < (int) size )
return( POLARSSL_ERR_ASN1_BUF_TOO_SMALL );
len = size;
(*p) -= len;
memcpy( *p, buf, len );
return( len );
}
#endif