68 static char *strip_spaces(
char *name);
69 static int sk_strcmp(
const char *
const *
a,
const char *
const *
b);
74 static int ipv4_from_asc(
unsigned char *v4,
const char *in);
75 static int ipv6_from_asc(
unsigned char *v6,
const char *in);
76 static int ipv6_cb(
const char *elem,
int len,
void *usr);
77 static int ipv6_hex(
unsigned char *out,
const char *in,
int inlen);
85 char *tname = NULL, *tvalue = NULL;
86 if(name && !(tname =
BUF_strdup(name)))
goto err;
87 if(value && !(tvalue =
BUF_strdup(value)))
goto err;
170 if (value[0] ==
'-') {
175 if (value[0] ==
'0' && ((value[1] ==
'x') || (value[1] ==
'X'))) {
183 if (!ret || value[ret]) {
216 if(!(btmp = value->
value))
goto err;
217 if(!strcmp(btmp,
"TRUE") || !strcmp(btmp,
"true")
218 || !strcmp(btmp,
"Y") || !strcmp(btmp,
"y")
219 || !strcmp(btmp,
"YES") || !strcmp(btmp,
"yes")) {
222 }
else if(!strcmp(btmp,
"FALSE") || !strcmp(btmp,
"false")
223 || !strcmp(btmp,
"N") || !strcmp(btmp,
"n")
224 || !strcmp(btmp,
"NO") || !strcmp(btmp,
"no")) {
262 for(p = linebuf, q = linebuf; (c = *
p) && (c!=
'\r') && (c!=
'\n'); p++) {
269 ntmp = strip_spaces(q);
275 }
else if(c ==
',') {
277 ntmp = strip_spaces(q);
280 printf(
"%s\n", ntmp);
294 vtmp = strip_spaces(q);
296 printf(
"%s\n", ntmp);
311 vtmp = strip_spaces(q);
313 printf(
"%s=%s\n", ntmp, vtmp);
321 ntmp = strip_spaces(q);
323 printf(
"%s\n", ntmp);
342 static char *strip_spaces(
char *name)
347 while(*p && isspace((
unsigned char)*p)) p++;
349 q = p + strlen(p) - 1;
350 while((q != p) && isspace((
unsigned char)*q)) q--;
366 const unsigned char *
p;
368 const static char hexdig[] =
"0123456789ABCDEF";
369 if(!buffer || !len)
return NULL;
375 for(i = 0, p = buffer; i <
len; i++,p++) {
376 *q++ = hexdig[(*p >> 4) & 0xf];
377 *q++ = hexdig[*p & 0xf];
381 #ifdef CHARSET_EBCDIC
394 unsigned char *hexbuf, *
q;
395 unsigned char ch, cl, *
p;
401 for(p = (
unsigned char *)str, q = hexbuf; *
p;) {
403 #ifdef CHARSET_EBCDIC
406 if(ch ==
':')
continue;
408 #ifdef CHARSET_EBCDIC
416 if(isupper(ch)) ch = tolower(ch);
417 if(isupper(cl)) cl = tolower(cl);
419 if((ch >=
'0') && (ch <=
'9')) ch -=
'0';
420 else if ((ch >=
'a') && (ch <=
'f')) ch -=
'a' - 10;
423 if((cl >=
'0') && (cl <=
'9')) cl -=
'0';
424 else if ((cl >=
'a') && (cl <=
'f')) cl -=
'a' - 10;
427 *q++ = (ch << 4) | cl;
430 if(len) *len = q - hexbuf;
455 if((ret = strncmp(name, cmp, len)))
return ret;
457 if(!c || (c==
'.'))
return 0;
461 static int sk_strcmp(
const char *
const *
a,
const char *
const *
b)
463 return strcmp(*a, *b);
479 AUTHORITY_INFO_ACCESS *info;
498 AUTHORITY_INFO_ACCESS_free(info);
508 exts = X509_REQ_get_extensions(x);
531 if(!append_ia5(&ret, email))
return NULL;
537 if(!append_ia5(&ret, gen->
d.
ia5))
return NULL;
577 unsigned char ipout[16];
588 ret = ASN1_OCTET_STRING_new();
593 ASN1_OCTET_STRING_free(ret);
602 unsigned char ipout[32];
603 char *iptmp = NULL, *
p;
605 p = strchr(ipasc,
'/');
611 p = iptmp + (p - ipasc);
624 if (!iplen2 || (iplen1 != iplen2))
627 ret = ASN1_OCTET_STRING_new();
639 ASN1_OCTET_STRING_free(ret);
648 if (strchr(ipasc,
':'))
650 if (!ipv6_from_asc(ipout, ipasc))
656 if (!ipv4_from_asc(ipout, ipasc))
662 static int ipv4_from_asc(
unsigned char *v4,
const char *in)
665 if (sscanf(in,
"%d.%d.%d.%d", &a0, &a1, &a2, &a3) != 4)
667 if ((a0 < 0) || (a0 > 255) || (a1 < 0) || (a1 > 255)
668 || (a2 < 0) || (a2 > 255) || (a3 < 0) || (a3 > 255))
679 unsigned char tmp[16];
689 static int ipv6_from_asc(
unsigned char *v6,
const char *in)
707 if (v6stat.
total != 16)
713 if (v6stat.
total == 16)
721 if (v6stat.
total > 0)
755 memcpy(v6, v6stat.
tmp, 16);
760 static int ipv6_cb(
const char *elem,
int len,
void *usr)
787 if (!ipv4_from_asc(s->
tmp + s->
total, elem))
793 if (!ipv6_hex(s->
tmp + s->
total, elem, len))
805 static int ipv6_hex(
unsigned char *out,
const char *in,
int inlen)
808 unsigned int num = 0;
815 if ((c >=
'0') && (c <=
'9'))
817 else if ((c >=
'A') && (c <=
'F'))
819 else if ((c >=
'a') && (c <=
'f'))
831 unsigned long chtype)
846 for(p = type; *
p ; p++)
847 #ifndef CHARSET_EBCDIC
848 if ((*p ==
':') || (*p ==
',') || (*p ==
'.'))
857 #ifndef CHARSET_EBCDIC
869 (
unsigned char *) v->
value,-1,-1,mval))