added private flag to asn1_ctx_t

This commit is contained in:
Andreas Steffen
2006-10-25 08:30:33 +00:00
parent a1fd9e6b7e
commit e4738363c1
2 changed files with 25 additions and 16 deletions
+15 -7
View File
@@ -276,18 +276,20 @@ time_t asn1totime(const chunk_t *utctime, asn1_t type)
/**
* Initializes the internal context of the ASN.1 parser
*/
void asn1_init(asn1_ctx_t *ctx, chunk_t blob, u_int level0, bool implicit)
void asn1_init(asn1_ctx_t *ctx, chunk_t blob, u_int level0,
bool implicit, bool private)
{
ctx->blobs[0] = blob;
ctx->level0 = level0;
ctx->implicit = implicit;
ctx->private = private;
memset(ctx->loopAddr, '\0', sizeof(ctx->loopAddr));
}
/**
* print the value of an ASN.1 simple object
*/
static void debug_asn1_simple_object(chunk_t object, asn1_t type)
static void debug_asn1_simple_object(chunk_t object, asn1_t type, bool private)
{
int oid;
@@ -317,7 +319,10 @@ static void debug_asn1_simple_object(chunk_t object, asn1_t type)
default:
break;
}
DBG3("%B", &object);
if (private)
DBG4("%B", &object);
else
DBG3("%B", &object);
}
/**
@@ -441,12 +446,15 @@ bool extract_object(asn1Object_t const *objects, u_int *objectID, chunk_t *objec
{
object->ptr = start_ptr;
object->len = (size_t)(blob->ptr - start_ptr);
DBG3("%B", object);
if (ctx->private)
DBG4("%B", object);
else
DBG3("%B", object);
}
else if (obj.flags & ASN1_BODY)
{
*object = *blob1;
debug_asn1_simple_object(*object, obj.type);
debug_asn1_simple_object(*object, obj.type, ctx->private);
}
return TRUE;
}
@@ -482,7 +490,7 @@ bool parse_asn1_simple_object(chunk_t *object, asn1_t type, u_int level, const c
}
DBG2("L%d - %s:", level, name);
debug_asn1_simple_object(*object, type);
debug_asn1_simple_object(*object, type, FALSE);
return TRUE;
}
@@ -497,7 +505,7 @@ int parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *parameters)
int alg = OID_UNKNOWN;
int objectID = 0;
asn1_init(&ctx, blob, level0, FALSE);
asn1_init(&ctx, blob, level0, FALSE, FALSE);
while (objectID < ALGORITHM_ID_ROOF)
{
+10 -9
View File
@@ -87,19 +87,20 @@ typedef enum {
/* definition of an ASN.1 object */
typedef struct {
u_int level;
const u_char *name;
asn1_t type;
u_char flags;
u_int level;
const u_char *name;
asn1_t type;
u_char flags;
} asn1Object_t;
#define ASN1_MAX_LEVEL 10
typedef struct {
bool implicit;
u_int level0;
u_int loopAddr[ASN1_MAX_LEVEL+1];
chunk_t blobs[ASN1_MAX_LEVEL+2];
bool implicit;
bool private;
u_int level0;
u_int loopAddr[ASN1_MAX_LEVEL+1];
chunk_t blobs[ASN1_MAX_LEVEL+2];
} asn1_ctx_t;
/* some common prefabricated ASN.1 constants */
@@ -119,7 +120,7 @@ extern int known_oid(chunk_t object);
extern u_int asn1_length(chunk_t *blob);
extern bool is_printablestring(chunk_t str);
extern time_t asn1totime(const chunk_t *utctime, asn1_t type);
extern void asn1_init(asn1_ctx_t *ctx, chunk_t blob, u_int level0, bool implicit);
extern void asn1_init(asn1_ctx_t *ctx, chunk_t blob, u_int level0, bool implicit, bool private);
extern bool extract_object(asn1Object_t const *objects, u_int *objectID, chunk_t *object, u_int *level, asn1_ctx_t *ctx);
extern bool parse_asn1_simple_object(chunk_t *object, asn1_t type, u_int level, const char* name);
extern int parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *parameters);