der tests: improve/implement handling of context-specific data

no more "EOL" in the output as the flexi decoder handles now
context-specific data
This commit is contained in:
Steffen Jaeckel 2014-10-06 18:55:23 +02:00
parent 6da3b856d6
commit f75b5ec8f4

View File

@ -326,8 +326,37 @@ static void _der_tests_print_flexi(ltc_asn1_list* l, unsigned int level)
text = l->data; text = l->data;
break; break;
case LTC_ASN1_CONSTRUCTED: case LTC_ASN1_CONSTRUCTED:
if (l->used & 0x80)
name = "CONTEXT SPECIFIC";
else
name = "CONSTRUCTED"; name = "CONSTRUCTED";
text = ""; snprintf(buf, sizeof(buf), "[%d]", l->used & 0x1f);
text = buf;
break;
case LTC_ASN1_CONTEXT_SPECIFIC:
name = "CONTEXT SPECIFIC";
{
int r;
char* s = buf;
int sz = sizeof(buf);
r = snprintf(s, sz, "[%d] ", l->used & 0x1f);
if (r < 0 || r >= sz) {
printf("Context Specific boom");
exit(EXIT_FAILURE);
}
s += r;
sz -= r;
for (n = 0; n < l->size; ++n) {
r = snprintf(s, sz, "%02X", ((unsigned char*)l->data)[n]);
if (r < 0 || r >= sz) {
printf("Context Specific boom");
exit(EXIT_FAILURE);
}
s += r;
sz -= r;
}
text = buf;
}
break; break;
} }