Arm Mbed OS support forum

MbedTLS ASN.1 functional sequence issue

I am using mbed tls to develop some ASN.1/DER related data:


I have payload similar above

unsigned char payload[145] = {
   0x30, 0x81, 0x8b, 0xa0, 0x81, 0x88, 0x02, 0x01, 0x02, 0x16, 0x05, 0x4b, 0x49, 0x43, 0x5f, 0x34, 0x80, 0x01, 0x20, 0x83, 0x79, 0x30, 0x77, 0x04, 0x41, 0x04, 0x47, 0x78, 0x80, 0x52, 0xbc, 0x8b, 0xb6, 0x8f, 0x6a, 0xed, 0x92, 0x8e, 0x78, 0x06, 0x0f, 0xb3, 0x7d, 0x78, 0x55, 0x16, 0xe7, 0x71, 0xa8, 0xc8, 0x0f, 0xcc, 0x2e, 0x09, 0x42, 0x3f, 0x4c, 0x04, 0xca, 0xc7, 0xf0, 0x76, 0xe2, 0x39, 0x85, 0x38, 0xed, 0x00, 0x5e, 0x11, 0xed, 0x01, 0xaa, 0x1f, 0xbc, 0xb1, 0xe9, 0xfc, 0xa7, 0xe6, 0x44, 0xf9, 0x38, 0x6b, 0x05, 0x43, 0x77, 0xd4, 0x59, 0xb6, 0x04, 0x10, 0x30, 0x3f, 0x08, 0x73, 0x54, 0xf2, 0x8a, 0x9f, 0x3b, 0xc9, 0x4c, 0x28, 0xd6, 0x21, 0xa5, 0xd1, 0x04, 0x20, 0x7d, 0x26, 0x26, 0x2a, 0x3a, 0x0d, 0xa1, 0x60, 0xf4, 0x43, 0xb8, 0xf8, 0x19, 0x55, 0xc0, 0xc5, 0x87, 0xf2, 0x41, 0x5e, 0x1b, 0xc9, 0xe1, 0x3a, 0x49, 0x7e, 0x5c, 0xdb, 0x16, 0x56, 0x47, 0x10

unsigned char* p = &(payload[0]);
unsigned char* end = &(payload[144]) + 1;
mbedtls_asn1_sequence base;

memset(&base, 0, sizeof(base));
ret = mbedtls_asn1_get_sequence_of(&p, end, &base, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE);
if (ret) {
	printf("cannot parse, err %d", ret);

the result I got is -98 (decimal) = MBEDTLS_ERR_ASN1_UNEXPECTED_TAG -0x0062

When I passed ASN.1 Playground: ASN.1 compiler, encoder, decoder, the sequence was correct, I wonder where I went wrong?