added private flag to asn1_ctx_t
This commit is contained in:
@@ -276,18 +276,20 @@ time_t asn1totime(const chunk_t *utctime, asn1_t type)
|
|||||||
/**
|
/**
|
||||||
* Initializes the internal context of the ASN.1 parser
|
* 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->blobs[0] = blob;
|
||||||
ctx->level0 = level0;
|
ctx->level0 = level0;
|
||||||
ctx->implicit = implicit;
|
ctx->implicit = implicit;
|
||||||
|
ctx->private = private;
|
||||||
memset(ctx->loopAddr, '\0', sizeof(ctx->loopAddr));
|
memset(ctx->loopAddr, '\0', sizeof(ctx->loopAddr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* print the value of an ASN.1 simple object
|
* 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;
|
int oid;
|
||||||
|
|
||||||
@@ -317,7 +319,10 @@ static void debug_asn1_simple_object(chunk_t object, asn1_t type)
|
|||||||
default:
|
default:
|
||||||
break;
|
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->ptr = start_ptr;
|
||||||
object->len = (size_t)(blob->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)
|
else if (obj.flags & ASN1_BODY)
|
||||||
{
|
{
|
||||||
*object = *blob1;
|
*object = *blob1;
|
||||||
debug_asn1_simple_object(*object, obj.type);
|
debug_asn1_simple_object(*object, obj.type, ctx->private);
|
||||||
}
|
}
|
||||||
return TRUE;
|
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);
|
DBG2("L%d - %s:", level, name);
|
||||||
debug_asn1_simple_object(*object, type);
|
debug_asn1_simple_object(*object, type, FALSE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +505,7 @@ int parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *parameters)
|
|||||||
int alg = OID_UNKNOWN;
|
int alg = OID_UNKNOWN;
|
||||||
int objectID = 0;
|
int objectID = 0;
|
||||||
|
|
||||||
asn1_init(&ctx, blob, level0, FALSE);
|
asn1_init(&ctx, blob, level0, FALSE, FALSE);
|
||||||
|
|
||||||
while (objectID < ALGORITHM_ID_ROOF)
|
while (objectID < ALGORITHM_ID_ROOF)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,19 +87,20 @@ typedef enum {
|
|||||||
/* definition of an ASN.1 object */
|
/* definition of an ASN.1 object */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u_int level;
|
u_int level;
|
||||||
const u_char *name;
|
const u_char *name;
|
||||||
asn1_t type;
|
asn1_t type;
|
||||||
u_char flags;
|
u_char flags;
|
||||||
} asn1Object_t;
|
} asn1Object_t;
|
||||||
|
|
||||||
#define ASN1_MAX_LEVEL 10
|
#define ASN1_MAX_LEVEL 10
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool implicit;
|
bool implicit;
|
||||||
u_int level0;
|
bool private;
|
||||||
u_int loopAddr[ASN1_MAX_LEVEL+1];
|
u_int level0;
|
||||||
chunk_t blobs[ASN1_MAX_LEVEL+2];
|
u_int loopAddr[ASN1_MAX_LEVEL+1];
|
||||||
|
chunk_t blobs[ASN1_MAX_LEVEL+2];
|
||||||
} asn1_ctx_t;
|
} asn1_ctx_t;
|
||||||
|
|
||||||
/* some common prefabricated ASN.1 constants */
|
/* 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 u_int asn1_length(chunk_t *blob);
|
||||||
extern bool is_printablestring(chunk_t str);
|
extern bool is_printablestring(chunk_t str);
|
||||||
extern time_t asn1totime(const chunk_t *utctime, asn1_t type);
|
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 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 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);
|
extern int parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *parameters);
|
||||||
|
|||||||
Reference in New Issue
Block a user