Log ASN.1 parsing in new ASN debug group.
authorTobias Brunner <tobias@strongswan.org>
Fri, 16 Dec 2011 15:29:48 +0000 (16:29 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 16 Dec 2011 15:44:38 +0000 (16:44 +0100)
src/libstrongswan/asn1/asn1.c
src/libstrongswan/asn1/asn1_parser.c

index 4466b37..96bf50a 100644 (file)
@@ -222,7 +222,7 @@ size_t asn1_length(chunk_t *blob)
 
        if (blob->len < 2)
        {
-               DBG2(DBG_LIB, "insufficient number of octets to parse ASN.1 length");
+               DBG2(DBG_ASN, "insufficient number of octets to parse ASN.1 length");
                return ASN1_INVALID_LENGTH;
        }
 
@@ -234,7 +234,7 @@ size_t asn1_length(chunk_t *blob)
        {       /* single length octet */
                if (n > blob->len)
                {
-                       DBG2(DBG_LIB, "length is larger than remaining blob size");
+                       DBG2(DBG_ASN, "length is larger than remaining blob size");
                        return ASN1_INVALID_LENGTH;
                }
                return n;
@@ -245,13 +245,13 @@ size_t asn1_length(chunk_t *blob)
 
        if (n == 0 || n > blob->len)
        {
-               DBG2(DBG_LIB, "number of length octets invalid");
+               DBG2(DBG_ASN, "number of length octets invalid");
                return ASN1_INVALID_LENGTH;
        }
 
        if (n > sizeof(len))
        {
-               DBG2(DBG_LIB, "number of length octets is larger than limit of"
+               DBG2(DBG_ASN, "number of length octets is larger than limit of"
                         " %d octets", (int)sizeof(len));
                return ASN1_INVALID_LENGTH;
        }
@@ -265,7 +265,7 @@ size_t asn1_length(chunk_t *blob)
        }
        if (len > blob->len)
        {
-               DBG2(DBG_LIB, "length is larger than remaining blob size");
+               DBG2(DBG_ASN, "length is larger than remaining blob size");
                return ASN1_INVALID_LENGTH;
        }
        return len;
@@ -471,12 +471,12 @@ void asn1_debug_simple_object(chunk_t object, asn1_t type, bool private)
                                {
                                        break;
                                }
-                               DBG2(DBG_LIB, "  %s", oid_str);
+                               DBG2(DBG_ASN, "  %s", oid_str);
                                free(oid_str);
                        }
                        else
                        {
-                               DBG2(DBG_LIB, "  '%s'", oid_names[oid].name);
+                               DBG2(DBG_ASN, "  '%s'", oid_names[oid].name);
                        }
                        return;
                case ASN1_UTF8STRING:
@@ -484,14 +484,14 @@ void asn1_debug_simple_object(chunk_t object, asn1_t type, bool private)
                case ASN1_PRINTABLESTRING:
                case ASN1_T61STRING:
                case ASN1_VISIBLESTRING:
-                       DBG2(DBG_LIB, "  '%.*s'", (int)object.len, object.ptr);
+                       DBG2(DBG_ASN, "  '%.*s'", (int)object.len, object.ptr);
                        return;
                case ASN1_UTCTIME:
                case ASN1_GENERALIZEDTIME:
                        {
                                time_t time = asn1_to_time(&object, type);
 
-                               DBG2(DBG_LIB, "  '%T'", &time, TRUE);
+                               DBG2(DBG_ASN, "  '%T'", &time, TRUE);
                        }
                        return;
                default:
@@ -499,11 +499,11 @@ void asn1_debug_simple_object(chunk_t object, asn1_t type, bool private)
        }
        if (private)
        {
-               DBG4(DBG_LIB, "%B", &object);
+               DBG4(DBG_ASN, "%B", &object);
        }
        else
        {
-               DBG3(DBG_LIB, "%B", &object);
+               DBG3(DBG_ASN, "%B", &object);
        }
 }
 
@@ -517,14 +517,14 @@ bool asn1_parse_simple_object(chunk_t *object, asn1_t type, u_int level, const c
        /* an ASN.1 object must possess at least a tag and length field */
        if (object->len < 2)
        {
-               DBG2(DBG_LIB, "L%d - %s:  ASN.1 object smaller than 2 octets", level,
+               DBG2(DBG_ASN, "L%d - %s:  ASN.1 object smaller than 2 octets", level,
                         name);
                return FALSE;
        }
 
        if (*object->ptr != type)
        {
-               DBG2(DBG_LIB, "L%d - %s: ASN1 tag 0x%02x expected, but is 0x%02x",
+               DBG2(DBG_ASN, "L%d - %s: ASN1 tag 0x%02x expected, but is 0x%02x",
                         level, name, type, *object->ptr);
                return FALSE;
        }
@@ -533,12 +533,12 @@ bool asn1_parse_simple_object(chunk_t *object, asn1_t type, u_int level, const c
 
        if (len == ASN1_INVALID_LENGTH || object->len < len)
        {
-               DBG2(DBG_LIB, "L%d - %s:  length of ASN.1 object invalid or too large",
+               DBG2(DBG_ASN, "L%d - %s:  length of ASN.1 object invalid or too large",
                         level, name);
                return FALSE;
        }
 
-       DBG2(DBG_LIB, "L%d - %s:", level, name);
+       DBG2(DBG_ASN, "L%d - %s:", level, name);
        asn1_debug_simple_object(*object, type, FALSE);
        return TRUE;
 }
@@ -606,7 +606,7 @@ bool is_asn1(chunk_t blob)
        tag = *blob.ptr;
        if (tag != ASN1_SEQUENCE && tag != ASN1_SET && tag != ASN1_OCTET_STRING)
        {
-               DBG2(DBG_LIB, "  file content is not binary ASN.1");
+               DBG2(DBG_ASN, "  file content is not binary ASN.1");
                return FALSE;
        }
 
@@ -624,7 +624,7 @@ bool is_asn1(chunk_t blob)
                return TRUE;
        }
 
-       DBG2(DBG_LIB, "  file size does not match ASN.1 coded length");
+       DBG2(DBG_ASN, "  file size does not match ASN.1 coded length");
        return FALSE;
 }
 
index 2a7a38a..f848bd3 100644 (file)
@@ -120,7 +120,7 @@ METHOD(asn1_parser_t, iterate, bool,
        if ((obj.flags & ASN1_DEF) && (blob->len == 0 || *start_ptr != obj.type) )
        {
                /* field is missing */
-               DBG2(DBG_LIB, "L%d - %s:", level, obj.name);
+               DBG2(DBG_ASN, "L%d - %s:", level, obj.name);
                if (obj.type & ASN1_CONSTRUCTED)
                {
                        this->line++ ;  /* skip context-specific tag */
@@ -147,7 +147,7 @@ METHOD(asn1_parser_t, iterate, bool,
 
        if (blob->len < 2)
        {
-               DBG1(DBG_LIB, "L%d - %s:  ASN.1 object smaller than 2 octets",
+               DBG1(DBG_ASN, "L%d - %s:  ASN.1 object smaller than 2 octets",
                                        level, obj.name);
                this->success = FALSE;
                goto end;
@@ -157,7 +157,7 @@ METHOD(asn1_parser_t, iterate, bool,
 
        if (blob1->len == ASN1_INVALID_LENGTH)
        {
-               DBG1(DBG_LIB, "L%d - %s:  length of ASN.1 object invalid or too large",
+               DBG1(DBG_ASN, "L%d - %s:  length of ASN.1 object invalid or too large",
                                        level, obj.name);
                this->success = FALSE;
        }
@@ -170,7 +170,7 @@ METHOD(asn1_parser_t, iterate, bool,
 
        if (obj.flags & ASN1_RAW)
        {
-               DBG2(DBG_LIB, "L%d - %s:", level, obj.name);
+               DBG2(DBG_ASN, "L%d - %s:", level, obj.name);
                object->ptr = start_ptr;
                object->len = (size_t)(blob->ptr - start_ptr);
                goto end;
@@ -178,14 +178,14 @@ METHOD(asn1_parser_t, iterate, bool,
 
        if (*start_ptr != obj.type && !(this->implicit && this->line == 0))
        {
-               DBG1(DBG_LIB, "L%d - %s: ASN1 tag 0x%02x expected, but is 0x%02x",
+               DBG1(DBG_ASN, "L%d - %s: ASN1 tag 0x%02x expected, but is 0x%02x",
                                        level, obj.name, obj.type, *start_ptr);
-               DBG3(DBG_LIB, "%b", start_ptr, (u_int)(blob->ptr - start_ptr));
+               DBG3(DBG_ASN, "%b", start_ptr, (u_int)(blob->ptr - start_ptr));
                this->success = FALSE;
                goto end;
        }
 
-       DBG2(DBG_LIB, "L%d - %s:", level, obj.name);
+       DBG2(DBG_ASN, "L%d - %s:", level, obj.name);
 
        /* In case of "SEQUENCE OF" or "SET OF" start a loop */
        if (obj.flags & ASN1_LOOP)
@@ -214,11 +214,11 @@ METHOD(asn1_parser_t, iterate, bool,
                object->len = (size_t)(blob->ptr - start_ptr);
                if (this->private)
                {
-                       DBG4(DBG_LIB, "%B", object);
+                       DBG4(DBG_ASN, "%B", object);
                }
                else
                {
-                       DBG3(DBG_LIB, "%B", object);
+                       DBG3(DBG_ASN, "%B", object);
                }
        }
        else if (obj.flags & ASN1_BODY)