asn1write: test NULL, OID and AlgorithmIdentifier
This commit is contained in:
parent
91d8d023c2
commit
9311cf5093
@ -1,3 +1,6 @@
|
||||
ASN.1 Write NULL
|
||||
mbedtls_asn1_write_null:"0500"
|
||||
|
||||
ASN.1 Write BOOLEAN FALSE
|
||||
mbedtls_asn1_write_bool:0:"010100"
|
||||
|
||||
@ -139,6 +142,42 @@ mbedtls_asn1_write_string:MBEDTLS_ASN1_IA5_STRING | MBEDTLS_ASN1_CONTEXT_SPECIFI
|
||||
ASN.1 Write tagged string: length=128
|
||||
mbedtls_asn1_write_string:MBEDTLS_ASN1_IA5_STRING | MBEDTLS_ASN1_CONTEXT_SPECIFIC:"0199a66790856f7199641f55cadabb660aaed6aa0d9ef8cef4417118c6e8c6e15becbaa21c63faf48726e92357a38b3079a0b9d60be7457ec6552f900dd032577167c91e829927343c3a769b362db4de0ad2ffb8f13cc2eeca9e52dc557118baa88b857477595622bc301a1ae2150030d652c4a482cf88d0ded85d6731ff2d38":"9681800199a66790856f7199641f55cadabb660aaed6aa0d9ef8cef4417118c6e8c6e15becbaa21c63faf48726e92357a38b3079a0b9d60be7457ec6552f900dd032577167c91e829927343c3a769b362db4de0ad2ffb8f13cc2eeca9e52dc557118baa88b857477595622bc301a1ae2150030d652c4a482cf88d0ded85d6731ff2d38"
|
||||
|
||||
ASN.1 Write OID: length=0
|
||||
mbedtls_asn1_write_string:MBEDTLS_ASN1_OID:"":"0600"
|
||||
|
||||
ASN.1 Write OID: length=1
|
||||
mbedtls_asn1_write_string:MBEDTLS_ASN1_OID:"41":"060141"
|
||||
|
||||
ASN.1 Write AlgorithmIdentifier, null parameters
|
||||
mbedtls_asn1_write_algorithm_identifier:"4f4944":8:"300d06034f4944"
|
||||
|
||||
ASN.1 Write AlgorithmIdentifier, parameters (8 bytes)
|
||||
mbedtls_asn1_write_algorithm_identifier:"4f4944":8:"300d06034f4944"
|
||||
|
||||
ASN.1 Write AlgorithmIdentifier, total length=0x7f
|
||||
mbedtls_asn1_write_algorithm_identifier:"4f4944":0x7a:"307f06034f4944"
|
||||
|
||||
ASN.1 Write AlgorithmIdentifier, total length=0x80
|
||||
mbedtls_asn1_write_algorithm_identifier:"4f4944":0x7b:"30818006034f4944"
|
||||
|
||||
ASN.1 Write AlgorithmIdentifier, total length=0xff
|
||||
mbedtls_asn1_write_algorithm_identifier:"4f4944":0xfa:"3081ff06034f4944"
|
||||
|
||||
ASN.1 Write AlgorithmIdentifier, total length=0x100
|
||||
mbedtls_asn1_write_algorithm_identifier:"4f4944":0xfb:"3082010006034f4944"
|
||||
|
||||
ASN.1 Write AlgorithmIdentifier, total length=0xffff
|
||||
mbedtls_asn1_write_algorithm_identifier:"4f4944":0xfffa:"3082ffff06034f4944"
|
||||
|
||||
ASN.1 Write AlgorithmIdentifier, total length=0x10000
|
||||
mbedtls_asn1_write_algorithm_identifier:"4f4944":0xfffb:"308301000006034f4944"
|
||||
|
||||
ASN.1 Write AlgorithmIdentifier, total length=0xffffff
|
||||
mbedtls_asn1_write_algorithm_identifier:"4f4944":0xfffffa:"3083ffffff06034f4944"
|
||||
|
||||
ASN.1 Write AlgorithmIdentifier, total length=0x1000000
|
||||
mbedtls_asn1_write_algorithm_identifier:"4f4944":0xfffffb:"30840100000006034f4944"
|
||||
|
||||
ASN.1 Write / Read Length #0 (Len = 0, short form)
|
||||
mbedtls_asn1_write_len:0:"00":1:1
|
||||
|
||||
|
@ -57,6 +57,26 @@ exit:
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_asn1_write_null( data_t *expected )
|
||||
{
|
||||
generic_write_data_t data = { NULL, NULL, NULL, NULL, 0 };
|
||||
int ret;
|
||||
|
||||
for( data.size = 0; data.size < expected->len + 1; data.size++ )
|
||||
{
|
||||
if( ! generic_write_start_step( &data ) )
|
||||
goto exit;
|
||||
ret = mbedtls_asn1_write_null( &data.p, data.start );
|
||||
if( ! generic_write_finish_step( &data, expected, ret ) )
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:
|
||||
mbedtls_free( data.output );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_asn1_write_bool( int val, data_t *expected )
|
||||
{
|
||||
@ -140,6 +160,11 @@ void mbedtls_asn1_write_string( int tag, data_t *content, data_t *expected )
|
||||
ret = mbedtls_asn1_write_octet_string(
|
||||
&data.p, data.start, content->x, content->len );
|
||||
break;
|
||||
case MBEDTLS_ASN1_OID:
|
||||
ret = mbedtls_asn1_write_oid(
|
||||
&data.p, data.start,
|
||||
(const char *) content->x, content->len );
|
||||
break;
|
||||
case MBEDTLS_ASN1_UTF8_STRING:
|
||||
ret = mbedtls_asn1_write_utf8_string(
|
||||
&data.p, data.start,
|
||||
@ -171,6 +196,36 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_asn1_write_algorithm_identifier( data_t *oid,
|
||||
int par_len,
|
||||
data_t *expected )
|
||||
{
|
||||
generic_write_data_t data = { NULL, NULL, NULL, NULL, 0 };
|
||||
int ret;
|
||||
|
||||
for( data.size = 0; data.size < expected->len + 1; data.size++ )
|
||||
{
|
||||
if( ! generic_write_start_step( &data ) )
|
||||
goto exit;
|
||||
ret = mbedtls_asn1_write_algorithm_identifier(
|
||||
&data.p, data.start,
|
||||
(const char *) oid->x, oid->len, par_len );
|
||||
/* If params_len != 0, mbedtls_asn1_write_algorithm_identifier()
|
||||
* assumes that the parameters are already present in the buffer
|
||||
* and returns a length that accounts for this, but our test
|
||||
* data omits the parameters. */
|
||||
if( ret >= 0 )
|
||||
ret -= par_len;
|
||||
if( ! generic_write_finish_step( &data, expected, ret ) )
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:
|
||||
mbedtls_free( data.output );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_ASN1_PARSE_C */
|
||||
void mbedtls_asn1_write_len( int len, data_t * asn1, int buf_len,
|
||||
int result )
|
||||
|
Loading…
Reference in New Issue
Block a user