the parameters field in an ASN.1 algorithmIdentifier is optional
authorAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 13 Mar 2009 20:22:24 +0000 (20:22 -0000)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 13 Mar 2009 20:22:24 +0000 (20:22 -0000)
src/libstrongswan/asn1/asn1.c
src/pluto/asn1.c

index fdb61c4..dacf12c 100644 (file)
@@ -452,13 +452,6 @@ bool asn1_parse_simple_object(chunk_t *object, asn1_t type, u_int level, const c
  * ASN.1 definition of an algorithmIdentifier
  */
 static const asn1Object_t algorithmIdentifierObjects[] = {
-       { 0, "algorithmIdentifier",     ASN1_SEQUENCE,  ASN1_NONE }, /* 0 */
-       { 1,   "algorithm",                     ASN1_OID,               ASN1_BODY }, /* 1 */
-       { 1,   "parameters",            ASN1_EOC,               ASN1_RAW  }, /* 2 */
-       { 0, "exit",                            ASN1_EOC,               ASN1_EXIT }
-};
-/* parameters are optional in case of ecdsa-with-SHA1 as algorithm (RFC 3279) */
-static const asn1Object_t algorithmIdentifierObjectsOptional[] = {
        { 0, "algorithmIdentifier",     ASN1_SEQUENCE,  ASN1_NONE         }, /* 0 */
        { 1,   "algorithm",                     ASN1_OID,               ASN1_BODY         }, /* 1 */
        { 1,   "parameters",            ASN1_EOC,               ASN1_RAW|ASN1_OPT }, /* 2 */
@@ -477,14 +470,8 @@ int asn1_parse_algorithmIdentifier(chunk_t blob, int level0, chunk_t *parameters
        chunk_t object;
        int objectID;
        int alg = OID_UNKNOWN;
-       const asn1Object_t *objects = algorithmIdentifierObjectsOptional;
-       
-       if (parameters != NULL)
-       {
-               objects = algorithmIdentifierObjects;
-       }
        
-       parser = asn1_parser_create(objects, blob);
+       parser = asn1_parser_create(algorithmIdentifierObjects, blob);
        parser->set_top_level(parser, level0);
        
        while (parser->iterate(parser, &objectID, &object))
index d15a68e..5303b68 100644 (file)
@@ -75,17 +75,19 @@ const chunk_t ASN1_rsaEncryption_id = strchunk(ASN1_rsaEncryption_id_str);
 const chunk_t ASN1_md5WithRSA_id = strchunk(ASN1_md5WithRSA_id_str);
 const chunk_t ASN1_sha1WithRSA_id = strchunk(ASN1_sha1WithRSA_id_str);
 
-/* ASN.1 definiton of an algorithmIdentifier */
+/* ASN.1 definition of an algorithmIdentifier */
 
 static const asn1Object_t algorithmIdentifierObjects[] = {
-  { 0, "algorithmIdentifier",  ASN1_SEQUENCE,     ASN1_NONE }, /* 0 */
-  { 1,   "algorithm",          ASN1_OID,          ASN1_BODY }, /* 1 */
-  { 1,   "parameters",         ASN1_EOC,          ASN1_RAW  }  /* 2 */
+  { 0, "algorithmIdentifier",  ASN1_SEQUENCE,  ASN1_NONE }, /* 0 */
+  { 1,   "algorithm",          ASN1_OID,       ASN1_BODY }, /* 1 */
+  { 1,   "parameters",         ASN1_EOC,       ASN1_OPT |
+                                               ASN1_RAW  }, /* 2 */
+  { 1,   "end opt",            ASN1_EOC,       ASN1_END  }  /* 3 */
 };
 
 #define ALGORITHM_ID_ALG               1
 #define ALGORITHM_ID_PARAMETERS                2
-#define ALGORITHM_ID_ROOF              3
+#define ALGORITHM_ID_ROOF              4
 
 /*
  * return the ASN.1 encoded algorithm identifier