asn1_build_known_oid() includes ASN1_OID tag and length
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 16 Apr 2009 08:18:22 +0000 (08:18 -0000)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 16 Apr 2009 08:18:22 +0000 (08:18 -0000)
src/libstrongswan/asn1/asn1.c
src/libstrongswan/asn1/asn1.h
src/libstrongswan/utils/identification.c
src/pluto/asn1.h

index 3fe6ff7..d020be0 100644 (file)
@@ -224,7 +224,7 @@ int asn1_known_oid(chunk_t object)
 /*
  * Defined in header.
  */
-chunk_t asn1_get_known_oid(int n)
+chunk_t asn1_build_known_oid(int n)
 {
        chunk_t oid;
        int i;
@@ -235,7 +235,10 @@ chunk_t asn1_get_known_oid(int n)
        }
        
        i = oid_names[n].level + 1;
-       oid = chunk_alloc(i);
+       oid = chunk_alloc(2 + i);
+       oid.ptr[0] = ASN1_OID;
+       oid.ptr[1] = i;
+
        do
        {
                if (oid_names[n].level >= i)
index 1ff9fcb..cc0010a 100644 (file)
@@ -107,12 +107,12 @@ chunk_t asn1_algorithmIdentifier(int oid);
 int asn1_known_oid(chunk_t object);
 
 /**
- * Converts an known OID index to ASN.1 OID
+ * Converts a known OID index to an ASN.1 OID
  *
  * @param n                    index into the oid_names[] table
  * @return                     allocated OID chunk, chunk_empty if index out of range
  */
-chunk_t asn1_get_known_oid(int n);
+chunk_t asn1_build_known_oid(int n);
 
 /**
  * Returns the length of an ASN.1 object
index 7245b42..2423c66 100644 (file)
@@ -581,13 +581,13 @@ static status_t atodn(char *src, chunk_t *dn)
                                        {
                                                chunk_t rdn_oid;
                                                
-                                               rdn_oid = asn1_get_known_oid(x501rdns[i].oid);
+                                               rdn_oid = asn1_build_known_oid(x501rdns[i].oid);
                                                if (rdn_oid.len)
                                                {
                                                        rdns[rdn_count] = 
                                                                        asn1_wrap(ASN1_SET, "m",
                                                                                asn1_wrap(ASN1_SEQUENCE, "mm",
-                                                                                       asn1_wrap(ASN1_OID, "m", rdn_oid),
+                                                                                       rdn_oid,
                                                                                        asn1_wrap(rdn_type, "c", name)
                                                                                )
                                                                        );
index d5f50ad..abbdf0f 100644 (file)
@@ -118,7 +118,7 @@ extern const chunk_t ASN1_sha1WithRSA_id;
 
 extern chunk_t asn1_algorithmIdentifier(int oid);
 extern int asn1_known_oid(chunk_t object);
-extern chunk_t asn1_get_known_oid(int n);
+extern chunk_t asn1_build_known_oid(int n);
 extern u_int asn1_length(chunk_t *blob);
 extern void code_asn1_length(size_t length, chunk_t *code);
 extern u_char* build_asn1_object(chunk_t *object, asn1_t type, size_t datalen);