Add DC, handle all Directory strings, fix signless problems.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16026 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -54,6 +54,8 @@ static unsigned email_num[] = { 1, 2, 840, 113549, 1, 9, 1 };
|
|||||||
static heim_oid email_oid = oid_enc(email_num);
|
static heim_oid email_oid = oid_enc(email_num);
|
||||||
static unsigned uid_num[] = { 0, 9, 2342, 19200300, 100, 1, 1 };
|
static unsigned uid_num[] = { 0, 9, 2342, 19200300, 100, 1, 1 };
|
||||||
static heim_oid uid_oid = oid_enc(uid_num);
|
static heim_oid uid_oid = oid_enc(uid_num);
|
||||||
|
static unsigned dc_num[] = { 0, 9, 2342, 19200300, 100, 1, 25 };
|
||||||
|
static heim_oid dc_oid = oid_enc(dc_num);
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
char *n;
|
char *n;
|
||||||
@@ -64,15 +66,16 @@ static const struct {
|
|||||||
{ "O", &organizationName_oid },
|
{ "O", &organizationName_oid },
|
||||||
{ "L", &localityName_oid },
|
{ "L", &localityName_oid },
|
||||||
{ "Email", &email_oid },
|
{ "Email", &email_oid },
|
||||||
{ "UID", &uid_oid }
|
{ "UID", &uid_oid },
|
||||||
|
{ "DC", &dc_oid }
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
quote_string(const char *f, size_t len, size_t *rlen)
|
quote_string(const char *f, size_t len, size_t *rlen)
|
||||||
{
|
{
|
||||||
size_t i, j, tolen;
|
size_t i, j, tolen;
|
||||||
const unsigned char *from = (const unsigned char *)f;
|
const char *from = f;
|
||||||
unsigned char *to;
|
char *to;
|
||||||
|
|
||||||
tolen = len * 3 + 1;
|
tolen = len * 3 + 1;
|
||||||
to = malloc(tolen);
|
to = malloc(tolen);
|
||||||
@@ -88,7 +91,7 @@ quote_string(const char *f, size_t len, size_t *rlen)
|
|||||||
{
|
{
|
||||||
to[j++] = '\\';
|
to[j++] = '\\';
|
||||||
to[j++] = from[i];
|
to[j++] = from[i];
|
||||||
} else if (from[i] >= 32 && from[i] <= 127) {
|
} else if (((unsigned char)from[i]) >= 32 && ((unsigned char)from[i]) <= 127) {
|
||||||
to[j++] = from[i];
|
to[j++] = from[i];
|
||||||
} else {
|
} else {
|
||||||
int l = snprintf(&to[j], tolen - j - 1,
|
int l = snprintf(&to[j], tolen - j - 1,
|
||||||
@@ -148,20 +151,20 @@ int
|
|||||||
hx509_name_to_string(const hx509_name name, char **str)
|
hx509_name_to_string(const hx509_name name, char **str)
|
||||||
{
|
{
|
||||||
const Name *n = &name->der_name;
|
const Name *n = &name->der_name;
|
||||||
ssize_t total_len = 0;
|
size_t total_len = 0;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
*str = strdup("");
|
*str = strdup("");
|
||||||
if (*str == NULL)
|
if (*str == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
for (i = 0 ; i < n->u.rdnSequence.len; i++) {
|
for (i = n->u.rdnSequence.len - 1 ; i >= 0 ; i--) {
|
||||||
char *ss;
|
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
for (j = 0; j < n->u.rdnSequence.val[i].len; j++) {
|
for (j = 0; j < n->u.rdnSequence.val[i].len; j++) {
|
||||||
DirectoryString *ds = &n->u.rdnSequence.val[i].val[j].value;
|
DirectoryString *ds = &n->u.rdnSequence.val[i].val[j].value;
|
||||||
char *oidname;
|
char *oidname;
|
||||||
|
char *ss;
|
||||||
|
|
||||||
oidname = oidtostring(&n->u.rdnSequence.val[i].val[j].type);
|
oidname = oidtostring(&n->u.rdnSequence.val[i].val[j].type);
|
||||||
|
|
||||||
@@ -175,11 +178,26 @@ hx509_name_to_string(const hx509_name name, char **str)
|
|||||||
case choice_DirectoryString_utf8String:
|
case choice_DirectoryString_utf8String:
|
||||||
ss = ds->u.ia5String;
|
ss = ds->u.ia5String;
|
||||||
break;
|
break;
|
||||||
#if 0
|
case choice_DirectoryString_bmpString: {
|
||||||
case choice_DirectoryString_bmpstring:
|
u_int16_t *bmp = ds->u.bmpString.data;
|
||||||
ss = ds->u.bmpstring;
|
size_t len = ds->u.bmpString.length / 2;
|
||||||
|
int k;
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
ss = malloc(len + 1);
|
||||||
|
if (ss == NULL)
|
||||||
|
abort();
|
||||||
|
for (k = 0; k < len + 1; k++)
|
||||||
|
ss[k] = bmp[k] & 0xff;
|
||||||
|
ss[k] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case choice_DirectoryString_teletexString:
|
||||||
|
ss = "teletex-string"; /* XXX */
|
||||||
|
break;
|
||||||
|
case choice_DirectoryString_universalString:
|
||||||
|
ss = "universalString"; /* XXX */
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@@ -188,11 +206,13 @@ hx509_name_to_string(const hx509_name name, char **str)
|
|||||||
append_string(str, &total_len, "=", 1, 0);
|
append_string(str, &total_len, "=", 1, 0);
|
||||||
len = strlen(ss);
|
len = strlen(ss);
|
||||||
append_string(str, &total_len, ss, len, 1);
|
append_string(str, &total_len, ss, len, 1);
|
||||||
|
if (ds->element == choice_DirectoryString_bmpString)
|
||||||
|
free(ss);
|
||||||
if (j + 1 < n->u.rdnSequence.val[i].len)
|
if (j + 1 < n->u.rdnSequence.val[i].len)
|
||||||
append_string(str, &total_len, "+", 1, 0);
|
append_string(str, &total_len, "+", 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i + 1 < n->u.rdnSequence.len)
|
if (i > 0)
|
||||||
append_string(str, &total_len, ", ", 2, 0);
|
append_string(str, &total_len, ", ", 2, 0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user