Correct order of extended key usage attributes

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
Dave Rodgman 2022-08-15 14:12:25 +01:00
parent 18b02d35d6
commit 64937856e0

View file

@ -445,13 +445,14 @@ int main( int argc, char *argv[] )
} }
else if( strcmp( p, "ext_key_usage" ) == 0 ) else if( strcmp( p, "ext_key_usage" ) == 0 )
{ {
mbedtls_asn1_sequence **tail = &opt.ext_key_usage;
while( q != NULL ) while( q != NULL )
{ {
if( ( r = strchr( q, ',' ) ) != NULL ) if( ( r = strchr( q, ',' ) ) != NULL )
*r++ = '\0'; *r++ = '\0';
ext_key_usage = mbedtls_calloc( 1, sizeof(mbedtls_asn1_sequence) ); ext_key_usage = mbedtls_calloc( 1, sizeof(mbedtls_asn1_sequence) );
ext_key_usage->next = opt.ext_key_usage;
ext_key_usage->buf.tag = MBEDTLS_ASN1_OID; ext_key_usage->buf.tag = MBEDTLS_ASN1_OID;
if( strcmp( q, "serverAuth" ) == 0 ) if( strcmp( q, "serverAuth" ) == 0 )
SET_OID( ext_key_usage->buf, MBEDTLS_OID_SERVER_AUTH ); SET_OID( ext_key_usage->buf, MBEDTLS_OID_SERVER_AUTH );
@ -467,7 +468,9 @@ int main( int argc, char *argv[] )
SET_OID( ext_key_usage->buf, MBEDTLS_OID_OCSP_SIGNING ); SET_OID( ext_key_usage->buf, MBEDTLS_OID_OCSP_SIGNING );
else else
goto usage; goto usage;
opt.ext_key_usage = ext_key_usage;
*tail = ext_key_usage;
tail = &ext_key_usage->next;
q = r; q = r;
} }