asn1_build_known_oid() includes ASN1_OID tag and length

This commit is contained in:
Andreas Steffen 2009-04-16 08:18:22 +00:00
parent ccb76a9cc8
commit cfa42285a4
4 changed files with 10 additions and 7 deletions

View File

@ -224,7 +224,7 @@ int asn1_known_oid(chunk_t object)
/* /*
* Defined in header. * Defined in header.
*/ */
chunk_t asn1_get_known_oid(int n) chunk_t asn1_build_known_oid(int n)
{ {
chunk_t oid; chunk_t oid;
int i; int i;
@ -235,7 +235,10 @@ chunk_t asn1_get_known_oid(int n)
} }
i = oid_names[n].level + 1; 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 do
{ {
if (oid_names[n].level >= i) if (oid_names[n].level >= i)

View File

@ -107,12 +107,12 @@ chunk_t asn1_algorithmIdentifier(int oid);
int asn1_known_oid(chunk_t object); 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 * @param n index into the oid_names[] table
* @return allocated OID chunk, chunk_empty if index out of range * @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 * Returns the length of an ASN.1 object

View File

@ -581,13 +581,13 @@ static status_t atodn(char *src, chunk_t *dn)
{ {
chunk_t rdn_oid; 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) if (rdn_oid.len)
{ {
rdns[rdn_count] = rdns[rdn_count] =
asn1_wrap(ASN1_SET, "m", asn1_wrap(ASN1_SET, "m",
asn1_wrap(ASN1_SEQUENCE, "mm", asn1_wrap(ASN1_SEQUENCE, "mm",
asn1_wrap(ASN1_OID, "m", rdn_oid), rdn_oid,
asn1_wrap(rdn_type, "c", name) asn1_wrap(rdn_type, "c", name)
) )
); );

View File

@ -118,7 +118,7 @@ extern const chunk_t ASN1_sha1WithRSA_id;
extern chunk_t asn1_algorithmIdentifier(int oid); extern chunk_t asn1_algorithmIdentifier(int oid);
extern int asn1_known_oid(chunk_t object); 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 u_int asn1_length(chunk_t *blob);
extern void code_asn1_length(size_t length, chunk_t *code); 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); extern u_char* build_asn1_object(chunk_t *object, asn1_t type, size_t datalen);