X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilcasn1%2Fsilcasn1.c;h=2e43b49c233631a017cabee0c7b9d07791e643c3;hp=dfb5cd3ded0c95ac9441ac9ad92a99e01c025745;hb=8a03227a106d087077ab9f9e21f644c8b653af3f;hpb=12cb6e09b64a9ecd8ee90f0243fc4af41a64238c diff --git a/lib/silcasn1/silcasn1.c b/lib/silcasn1/silcasn1.c index dfb5cd3d..2e43b49c 100644 --- a/lib/silcasn1/silcasn1.c +++ b/lib/silcasn1/silcasn1.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2003 - 2005 Pekka Riikonen + Copyright (C) 2003 - 2007 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ */ -#include "silcincludes.h" +#include "silc.h" #include "silcasn1.h" #include "silcber.h" @@ -53,7 +53,7 @@ SilcBool silc_asn1_init(SilcAsn1 asn1) asn1->stack2 = silc_stack_alloc(768); if (!asn1->stack2) { - silc_stack_free(asn1->stack2); + silc_stack_free(asn1->stack1); return FALSE; } @@ -66,15 +66,11 @@ SilcBool silc_asn1_init(SilcAsn1 asn1) void silc_asn1_uninit(SilcAsn1 asn1) { -#if 1 - silc_stack_stats(asn1->stack1); - silc_stack_stats(asn1->stack2); -#endif silc_stack_free(asn1->stack1); silc_stack_free(asn1->stack2); } -#ifdef SILC_DIST_INPLACE +#if defined(SILC_DEBUG) /* Returns string representation of a tag */ const char *silc_asn1_tag_name(SilcAsn1Tag tag) @@ -88,15 +84,18 @@ const char *silc_asn1_tag_name(SilcAsn1Tag tag) return "choice"; case SILC_ASN1_TAG_ANY: return "any"; + case SILC_ASN1_TAG_ANY_PRIMITIVE: + return "any primitive"; case SILC_ASN1_TAG_SEQUENCE_OF: return "sequence of"; - case SILC_ASN1_TAG_SEQUENCE: return "sequence"; case SILC_ASN1_TAG_SET: return "set"; case SILC_ASN1_TAG_INTEGER: return "integer"; + case SILC_ASN1_TAG_SHORT_INTEGER: + return "short integer"; case SILC_ASN1_TAG_OID: return "oid"; case SILC_ASN1_TAG_BOOLEAN: @@ -152,14 +151,17 @@ const char *silc_asn1_tag_name(SilcAsn1Tag tag) } return "unknown"; } +#endif /* SILC_DEBUG */ +#ifdef SILC_DIST_TOOLKIT +#ifdef SILC_DEBUG /* Dumps the ASN.1 data block into standard output (stdout). */ SilcBool silc_asn1_dump(SilcAsn1 asn1, SilcBuffer src) { SilcBool ret = FALSE; SilcBerEncoding renc; - SilcAsn1Tag rtag; + SilcUInt32 rtag; const unsigned char *rdata; SilcUInt32 rdata_len, len = 0; SilcBool rindef; @@ -168,7 +170,7 @@ SilcBool silc_asn1_dump(SilcAsn1 asn1, SilcBuffer src) while (silc_buffer_len(src)) { /* Decode the BER block */ - ret = silc_ber_decode(src, NULL, &renc, (SilcUInt32 *)&rtag, &rdata, + ret = silc_ber_decode(src, NULL, &renc, &rtag, &rdata, &rdata_len, &rindef, &len); if (!ret) { SILC_LOG_DEBUG(("Error parsing BER block, malformed ASN.1 data")); @@ -189,5 +191,5 @@ SilcBool silc_asn1_dump(SilcAsn1 asn1, SilcBuffer src) return TRUE; } - -#endif /* SILC_DIST_INPLACE */ +#endif /* SILC_DEBUG */ +#endif /* SILC_DIST_TOOLKIT */