removed obsolete init_rdn()/get_next_rdn() functions
This commit is contained in:
@@ -267,130 +267,6 @@ static enumerator_t* create_part_enumerator(private_identification_t *this)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Pointer is set to the first RDN in a DN
|
|
||||||
*/
|
|
||||||
static bool init_rdn(chunk_t dn, chunk_t *rdn, chunk_t *attribute, bool *next)
|
|
||||||
{
|
|
||||||
*rdn = chunk_empty;
|
|
||||||
*attribute = chunk_empty;
|
|
||||||
|
|
||||||
/* a DN is a SEQUENCE OF RDNs */
|
|
||||||
if (*dn.ptr != ASN1_SEQUENCE)
|
|
||||||
{
|
|
||||||
/* DN is not a SEQUENCE */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
rdn->len = asn1_length(&dn);
|
|
||||||
|
|
||||||
if (rdn->len == ASN1_INVALID_LENGTH)
|
|
||||||
{
|
|
||||||
/* Invalid RDN length */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
rdn->ptr = dn.ptr;
|
|
||||||
|
|
||||||
/* are there any RDNs ? */
|
|
||||||
*next = rdn->len > 0;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the next RDN in a DN
|
|
||||||
*/
|
|
||||||
static bool get_next_rdn(chunk_t *rdn, chunk_t * attribute, chunk_t *oid,
|
|
||||||
chunk_t *value, asn1_t *type, bool *next)
|
|
||||||
{
|
|
||||||
chunk_t body;
|
|
||||||
|
|
||||||
/* initialize return values */
|
|
||||||
*oid = chunk_empty;
|
|
||||||
*value = chunk_empty;
|
|
||||||
|
|
||||||
/* if all attributes have been parsed, get next rdn */
|
|
||||||
if (attribute->len <= 0)
|
|
||||||
{
|
|
||||||
/* an RDN is a SET OF attributeTypeAndValue */
|
|
||||||
if (*rdn->ptr != ASN1_SET)
|
|
||||||
{
|
|
||||||
/* RDN is not a SET */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
attribute->len = asn1_length(rdn);
|
|
||||||
if (attribute->len == ASN1_INVALID_LENGTH)
|
|
||||||
{
|
|
||||||
/* Invalid attribute length */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
attribute->ptr = rdn->ptr;
|
|
||||||
/* advance to start of next RDN */
|
|
||||||
rdn->ptr += attribute->len;
|
|
||||||
rdn->len -= attribute->len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* an attributeTypeAndValue is a SEQUENCE */
|
|
||||||
if (*attribute->ptr != ASN1_SEQUENCE)
|
|
||||||
{
|
|
||||||
/* attributeTypeAndValue is not a SEQUENCE */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* extract the attribute body */
|
|
||||||
body.len = asn1_length(attribute);
|
|
||||||
|
|
||||||
if (body.len == ASN1_INVALID_LENGTH)
|
|
||||||
{
|
|
||||||
/* Invalid attribute body length */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
body.ptr = attribute->ptr;
|
|
||||||
|
|
||||||
/* advance to start of next attribute */
|
|
||||||
attribute->ptr += body.len;
|
|
||||||
attribute->len -= body.len;
|
|
||||||
|
|
||||||
/* attribute type is an OID */
|
|
||||||
if (*body.ptr != ASN1_OID)
|
|
||||||
{
|
|
||||||
/* attributeType is not an OID */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
/* extract OID */
|
|
||||||
oid->len = asn1_length(&body);
|
|
||||||
|
|
||||||
if (oid->len == ASN1_INVALID_LENGTH)
|
|
||||||
{
|
|
||||||
/* Invalid attribute OID length */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
oid->ptr = body.ptr;
|
|
||||||
|
|
||||||
/* advance to the attribute value */
|
|
||||||
body.ptr += oid->len;
|
|
||||||
body.len -= oid->len;
|
|
||||||
|
|
||||||
/* extract string type */
|
|
||||||
*type = *body.ptr;
|
|
||||||
|
|
||||||
/* extract string value */
|
|
||||||
value->len = asn1_length(&body);
|
|
||||||
|
|
||||||
if (value->len == ASN1_INVALID_LENGTH)
|
|
||||||
{
|
|
||||||
/* Invalid attribute string length */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
value->ptr = body.ptr;
|
|
||||||
|
|
||||||
/* are there any RDNs left? */
|
|
||||||
*next = rdn->len > 0 || attribute->len > 0;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a DN with all its RDN in a buffer to present it to the user
|
* Print a DN with all its RDN in a buffer to present it to the user
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user