[Redbutton-devel] SF.net SVN: redbutton: [400] redbutton-author/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-09-19 11:47:19
|
Revision: 400
http://redbutton.svn.sourceforge.net/redbutton/?rev=400&view=rev
Author: skilvington
Date: 2007-09-19 04:47:16 -0700 (Wed, 19 Sep 2007)
Log Message:
-----------
OctetString nodes need to look at their parent's parent to decide whether to set the tag or not
Modified Paths:
--------------
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-18 19:52:00 UTC (rev 399)
+++ redbutton-author/trunk/parser.c.header 2007-09-19 11:47:16 UTC (rev 400)
@@ -38,6 +38,7 @@
child->asn1class = (asn1tagclass >> 24) & 0xff;
child->length = 0;
child->value = NULL;
+ child->parent = parent;
child->children = NULL;
child->siblings = NULL;
@@ -119,15 +120,16 @@
return;
}
-void parse_STRING(struct node *parent)
+void parse_OCTETSTRING(struct node *parent)
{
- if(next_token() != STRING)
- parse_error("Unexpected token '%s'; expecting \"STRING\"", token_text());
-
- verbose("<STRING value=%s/>\n", token_text());
-
- /* give our parent a UNIVERSAL type if it is synthetic */
- if(is_synthetic(parent->asn1tag))
+ /*
+ * give our parent's parent a UNIVERSAL type if it is synthetic
+ * need to look at our parent's parent because an OctetString in the grammar
+ * is a choice between a STRING, a QPRINTABLE or a BASE64
+ * so our parent will always be a choice node
+ * the OCTETSTRING ASN1 type does not have this extra choice parent node
+ */
+ if(is_synthetic(parent->parent->asn1tag))
{
parent->asn1tag = ASN1TAG_OCTETSTRING;
parent->asn1class = ASN1CLASS_UNIVERSAL;
@@ -138,7 +140,18 @@
return;
}
+void parse_STRING(struct node *parent)
+{
+ if(next_token() != STRING)
+ parse_error("Unexpected token '%s'; expecting \"STRING\"", token_text());
+ verbose("<STRING value=%s/>\n", token_text());
+
+ parse_OCTETSTRING(parent);
+
+ return;
+}
+
void parse_QPRINTABLE(struct node *parent)
{
if(next_token() != QPRINTABLE)
@@ -146,19 +159,11 @@
verbose("<QPRINTABLE value=%s/>\n", token_text());
- /* give our parent a UNIVERSAL type if it is synthetic */
- if(is_synthetic(parent->asn1tag))
- {
- parent->asn1tag = ASN1TAG_OCTETSTRING;
- parent->asn1class = ASN1CLASS_UNIVERSAL;
- }
+ parse_OCTETSTRING(parent);
- der_encode_OctetString(&parent->value, &parent->length, token_text());
-
return;
}
-
void parse_BASE64(struct node *parent)
{
if(next_token() != BASE64)
@@ -166,19 +171,11 @@
verbose("<BASE64 value=%s/>\n", token_text());
- /* give our parent a UNIVERSAL type if it is synthetic */
- if(is_synthetic(parent->asn1tag))
- {
- parent->asn1tag = ASN1TAG_OCTETSTRING;
- parent->asn1class = ASN1CLASS_UNIVERSAL;
- }
+ parse_OCTETSTRING(parent);
- der_encode_OctetString(&parent->value, &parent->length, token_text());
-
return;
}
-
void parse_Null(struct node *parent)
{
if(next_token() != Null)
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-18 19:52:00 UTC (rev 399)
+++ redbutton-author/trunk/parser.h.header 2007-09-19 11:47:16 UTC (rev 400)
@@ -17,6 +17,7 @@
unsigned int length; /* length of the value data */
unsigned char *value; /* DER encoded value */
/* a tree of nodes */
+ struct node *parent; /* NULL if we are the top */
struct node *children; /* NULL if not a constructed type */
struct node *siblings; /* linked list of children */
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|