From f75b5ec8f49a8823a473cf88eb86247f8cca7cfd Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Mon, 6 Oct 2014 18:55:23 +0200 Subject: [PATCH] der tests: improve/implement handling of context-specific data no more "EOL" in the output as the flexi decoder handles now context-specific data --- testprof/der_tests.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/testprof/der_tests.c b/testprof/der_tests.c index 301f3f9..128ee09 100644 --- a/testprof/der_tests.c +++ b/testprof/der_tests.c @@ -326,8 +326,37 @@ static void _der_tests_print_flexi(ltc_asn1_list* l, unsigned int level) text = l->data; break; case LTC_ASN1_CONSTRUCTED: - name = "CONSTRUCTED"; - text = ""; + if (l->used & 0x80) + name = "CONTEXT SPECIFIC"; + else + name = "CONSTRUCTED"; + 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; }