- } else {
- *dst += dst_len;
- }
- *src += len;
- return normalize_function;
-}
-
-
-/*
- * match_key - determine if the attribute type represented by the string
- * beginning at *src and of length len is a known attribute type. If so,
- * copy the string representation to *dst and return a pointer to the
- * normalization function for the attribute value. If the attribute type
- * places an upper bound on the length of the attribute value, make *ub that
- * upper bound, otherwise set *ub to -1.
- * If the attribute type is unknown, copy the string representation of the
- * attribute type to *dst and return NULL.
- */
-static av_normalize_type
-match_key(char **src, char **dst, int *ub, int len, int make_uppercase)
-{
- int i;
- int dst_len = 0;
- av_normalize_type normalize_function = NULL;
-
- *ub = -1;
-
- switch( len ) {
- case 1:
- if (strncasecmp(*src, "C", len) == 0) {
- /* country */
- **dst = 'c';
- dst_len = 1;
- *ub = 2;
- normalize_function = PrintableString_normalize;
- } else if (strncasecmp(*src, "O", len) == 0) {
- /* organization */
- **dst = 'o';
- dst_len = 1;
- *ub = 64;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "T", len) == 0) {
- /* title */
- strncpy(*dst, "title", 5);
- dst_len = 5;
- *ub = 64;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "S", len) == 0) {
- /* state or province */
- strncpy(*dst, "st", 2);
- dst_len = 2;
- *ub = 128;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "L", len) == 0) {
- /* locality */
- **dst = 'l';
- dst_len = 1;
- *ub = 128;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "E", len) == 0) {
- /* e-mail */
- **dst = 'e';
- dst_len = 1;
- *ub = 255;
- normalize_function = IA5String_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 2:
- if (strncasecmp(*src, "CN", len) == 0) {
- /* common name */
- strncpy(*dst, "cn", 2);
- dst_len = 2;
- *ub = 64;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "OU", len) == 0) {
- /* organizational unit */
- strncpy(*dst, "ou", 2);
- dst_len = 2;
- *ub = 64;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "DC", len) == 0) {
- /* domainComponent */
- strncpy(*dst, "dc", 2);
- dst_len = 2;
- *ub = -1;
- normalize_function = IA5String_normalize;
- } else if (strncasecmp(*src, "SN", len) == 0) {
- /* surname */
- strncpy(*dst, "sn", 2);
- dst_len = 2;
- *ub = 64;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "ST", len) == 0) {
- /* state or province */
- strncpy(*dst, "st", 2);
- dst_len = 2;
- *ub = 128;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 3:
- if (strncasecmp(*src, "SNU", len) == 0) {
- /* serial number */
- strncpy(*dst, "snu", 3);
- dst_len = 3;
- *ub = 64;
- normalize_function = PrintableString_normalize;
- } else if (strncasecmp(*src, "UID", len) == 0) {
- /* userID */
- strncpy(*dst, "uid", 3);
- dst_len = 3;
- *ub = 256;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 5:
- if (strncasecmp(*src, "TITLE", len) == 0) {
- /* title */
- strncpy(*dst, "title", 5);
- dst_len = 5;
- *ub = 64;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "STATE", len) == 0) {
- /* state or province */
- strncpy(*dst, "st", 2);
- dst_len = 2;
- *ub = 128;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 6:
- if (strncasecmp(*src, "USERID", len) == 0) {
- /* userID */
- strncpy(*dst, "uid", 3);
- dst_len = 3;
- *ub = 256;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "STREET", len) == 0) {
- /* street address */
- strncpy(*dst, "street", 6);
- dst_len = 6;
- *ub = 128;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 7:
- if (strncasecmp(*src, "SURNAME", len) == 0) {
- /* surname */
- strncpy(*dst, "sn", 2);
- dst_len = 2;
- *ub = 64;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 8:
- if (strncasecmp(*src, "INITIALS", len) == 0) {
- /* initials */
- strncpy(*dst, "initials", 8);
- dst_len = 8;
- *ub = -1;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "PROVINCE", len) == 0) {
- /* state or province */
- strncpy(*dst, "st", 2);
- dst_len = 2;
- *ub = 128;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 9:
- if (strncasecmp(*src, "GIVENNAME", len) == 0) {
- /* givenName */
- strncpy(*dst, "givenName", 9);
- dst_len = 9;
- *ub = -1;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "PSEUDONYM", len) == 0) {
- /* Pseudonym */
- strncpy(*dst, "Pseudonym", 9);
- dst_len = 9;
- *ub = 64;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 10:
- if (strncasecmp(*src, "COMMONNAME", len) == 0) {
- /* common name */
- strncpy(*dst, "cn", 2);
- dst_len = 2;
- *ub = 64;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 11:
- if (strncasecmp(*src, "DNQUALIFIER", len) == 0) {
- /* Distinguished Name Quailifier */
- strncpy(*dst, "dnQualifier", 11);
- dst_len = 11;
- *ub = -1;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "COUNTRYNAME", len) == 0) {
- /* country */
- **dst = 'c';
- dst_len = 1;
- *ub = 2;
- normalize_function = PrintableString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 12:
- if (strncasecmp(*src, "SERIALNUMBER", len) == 0) {
- /* serial number */
- strncpy(*dst, "snu", 3);
- dst_len = 3;
- *ub = 64;
- normalize_function = PrintableString_normalize;
- } else if (strncasecmp(*src, "LOCALITYNAME", len) == 0) {
- /* locality */
- **dst = 'l';
- dst_len = 1;
- *ub = 128;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "EMAILADDRESS", len) == 0) {
- /* e-mail */
- **dst = 'e';
- dst_len = 1;
- *ub = 255;
- normalize_function = IA5String_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 13:
- if (strncasecmp(*src, "STREETADDRESS", len) == 0) {
- /* street address */
- strncpy(*dst, "street", 6);
- dst_len = 6;
- *ub = 128;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 15:
- if (strncasecmp(*src, "DOMAINCOMPONENT", len) == 0) {
- /* domainComponent */
- strncpy(*dst, "dc", 2);
- dst_len = 2;
- *ub = -1;
- normalize_function = IA5String_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 16:
- if (strncasecmp(*src, "UNIQUEIDENTIFIER", len) == 0) {
- /* uniqueIdentifier */
- strncpy(*dst, "uniqueIdentifier", 16);
- dst_len = 16;
- *ub = -1;
- normalize_function = bitString_normalize;
- } else if (strncasecmp(*src, "ORGANIZATIONNAME", len) == 0) {
- /* organization */
- **dst = 'o';
- dst_len = 1;
- *ub = 64;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 17:
- if (strncasecmp(*src, "NAMEDISTINGUISHER", len) == 0) {
- /* name distinguisher */
- strncpy(*dst, "nameDistinguisher", 17);
- dst_len = 17;
- *ub = -1;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-
- case 19:
- if (strncasecmp(*src, "GENERATIONQUALIFIER", len) == 0) {
- /* Distinguished Name Quailifier */
- strncpy(*dst, "generationQualifier", 19);
- dst_len = 19;
- *ub = -1;
- normalize_function = DirectoryString_normalize;
- } else if (strncasecmp(*src, "STATEORPROVINCENAME", len) == 0) {
- /* state or province */
- strncpy(*dst, "st", 2);
- dst_len = 2;
- *ub = 128;
- normalize_function = DirectoryString_normalize;
- } else {
- /* Unknown attributeType */
- strncpy(*dst, *src, len);
- dst_len = len;
- *ub = -1;
- normalize_function = NULL;
- }
- break;
-