X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilcasn1%2Fsilcasn1.c;h=2e43b49c233631a017cabee0c7b9d07791e643c3;hp=eec926c49ec4fd1b2d789dc9f9b0b141f19fc945;hb=8a03227a106d087077ab9f9e21f644c8b653af3f;hpb=0f0340b9fbce9704cc7171f8f0104ce9103d2de6 diff --git a/lib/silcasn1/silcasn1.c b/lib/silcasn1/silcasn1.c index eec926c4..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" @@ -45,7 +45,7 @@ void silc_asn1_free(SilcAsn1 asn1) /* Init pre-allocated ASN.1 context */ -bool silc_asn1_init(SilcAsn1 asn1) +SilcBool silc_asn1_init(SilcAsn1 asn1) { asn1->stack1 = silc_stack_alloc(768); if (!asn1->stack1) @@ -53,7 +53,7 @@ bool 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 @@ bool 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,23 +151,26 @@ 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). */ -bool silc_asn1_dump(SilcAsn1 asn1, SilcBuffer src) +SilcBool silc_asn1_dump(SilcAsn1 asn1, SilcBuffer src) { - bool ret = FALSE; + SilcBool ret = FALSE; SilcBerEncoding renc; - SilcAsn1Tag rtag; + SilcUInt32 rtag; const unsigned char *rdata; SilcUInt32 rdata_len, len = 0; - bool rindef; + SilcBool rindef; SILC_LOG_DEBUG(("Dumping ASN.1")); 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 @@ bool silc_asn1_dump(SilcAsn1 asn1, SilcBuffer src) return TRUE; } - -#endif /* SILC_DIST_INPLACE */ +#endif /* SILC_DEBUG */ +#endif /* SILC_DIST_TOOLKIT */