/* needs stdio.h and asn1.h included */ #include void printasn1(const char* buf,const char* max) { const char* maxstack[100]; size_t sptr=0; size_t indent=0; unsigned long tag; enum asn1_tagclass tc; enum asn1_tagtype tt; size_t cl,len; maxstack[sptr]=max; while (buf %ld\n",(int)indent,"",l); } else if (tag==OCTET_STRING || tag==PrintableString || tag==IA5String || tag==UTCTIME || tag==BIT_STRING) { printf("%*s-> \"",(int)indent,""); for (i=0; i ",(int)indent,""); for (i=0; i=99) { printf("too many nested constructed elements!\n"); return; } maxstack[++sptr]=buf+len; } else buf+=len; while (sptr && maxstack[sptr]<=buf) { --sptr; indent-=2; printf("%*s}\n",(int)indent,""); } } }