updated integrity algorithm identifiers
[strongswan.git] / src / libstrongswan / crypto / pkcs9.c
index 42101b0..525ea9d 100644 (file)
@@ -11,8 +11,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
- *
- * $Id$
  */
 
 #include <library.h>
@@ -77,21 +75,6 @@ struct attribute_t {
 
 };
 
-/* ASN.1 definition of the X.501 atttribute type */
-
-static const asn1Object_t attributesObjects[] = {
-       { 0, "attributes",              ASN1_SET,               ASN1_LOOP }, /* 0 */
-       { 1,   "attribute",             ASN1_SEQUENCE,  ASN1_NONE }, /* 1 */
-       { 2,     "type",                ASN1_OID,               ASN1_BODY }, /* 2 */
-       { 2,     "values",              ASN1_SET,               ASN1_LOOP }, /* 3 */
-       { 3,       "value",             ASN1_EOC,               ASN1_RAW  }, /* 4 */
-       { 2,     "end loop",    ASN1_EOC,               ASN1_END  }, /* 5 */
-       { 0, "end loop",                ASN1_EOC,               ASN1_END  }, /* 6 */
-};
-#define ATTRIBUTE_OBJ_TYPE     2
-#define ATTRIBUTE_OBJ_VALUE    4
-#define ATTRIBUTE_OBJ_ROOF     7
-
 /**
  * PKCS#9 attribute type OIDs
  */
@@ -391,6 +374,22 @@ pkcs9_t *pkcs9_create(void)
 }
 
 /**
+ * ASN.1 definition of the X.501 atttribute type
+ */
+static const asn1Object_t attributesObjects[] = {
+       { 0, "attributes",              ASN1_SET,               ASN1_LOOP }, /* 0 */
+       { 1,   "attribute",             ASN1_SEQUENCE,  ASN1_NONE }, /* 1 */
+       { 2,     "type",                ASN1_OID,               ASN1_BODY }, /* 2 */
+       { 2,     "values",              ASN1_SET,               ASN1_LOOP }, /* 3 */
+       { 3,       "value",             ASN1_EOC,               ASN1_RAW  }, /* 4 */
+       { 2,     "end loop",    ASN1_EOC,               ASN1_END  }, /* 5 */
+       { 0, "end loop",                ASN1_EOC,               ASN1_END  }, /* 6 */
+       { 0, "exit",                    ASN1_EOC,               ASN1_EXIT }
+};
+#define ATTRIBUTE_OBJ_TYPE     2
+#define ATTRIBUTE_OBJ_VALUE    4
+
+/**
  * Parse a PKCS#9 attribute list
  */
 static bool parse_attributes(chunk_t chunk, int level0, private_pkcs9_t* this)
@@ -399,9 +398,9 @@ static bool parse_attributes(chunk_t chunk, int level0, private_pkcs9_t* this)
        chunk_t object;
        int objectID;
        int oid = OID_UNKNOWN;
-       bool success = TRUE;
+       bool success = FALSE;
 
-       parser = asn1_parser_create(attributesObjects, ATTRIBUTE_OBJ_ROOF, chunk);
+       parser = asn1_parser_create(attributesObjects, chunk);
        parser->set_top_level(parser, level0);
 
        while (parser->iterate(parser, &objectID, &object))
@@ -433,16 +432,15 @@ static bool parse_attributes(chunk_t chunk, int level0, private_pkcs9_t* this)
                                                                                parser->get_level(parser)+1,
                                                                                oid_names[oid].name))
                                                {
-                                                       success = FALSE;
                                                        goto end;
                                                }
                                        }
                                }
                }
        }
+       success = parser->success(parser);
 
 end:
-       success &= parser->success(parser);
        parser->destroy(parser);
        return success;
 }