Go to the documentation of this file.
72 #include "../conf/internal.h"
73 #include "../internal.h"
87 static int ipv6_hex(
unsigned char *
out,
const char *
in,
int inlen);
91 static int x509V3_add_len_value(
const char *
name,
const char *
value,
92 size_t value_len,
int omit_value,
96 char *tname = NULL, *tvalue = NULL;
97 int extlist_was_null = *extlist == NULL;
107 if (tvalue == NULL) {
113 if (!*extlist && !(*extlist = sk_CONF_VALUE_new_null()))
117 vtmp->
value = tvalue;
118 if (!sk_CONF_VALUE_push(*extlist, vtmp))
124 if (extlist_was_null) {
125 sk_CONF_VALUE_free(*extlist);
138 value == NULL, extlist);
150 return x509V3_add_len_value(
name, (
const char *)
value->data,
value->length,
261 if (
value[0] ==
'-') {
315 if (!(btmp =
value->value))
317 if (!strcmp(btmp,
"TRUE") || !strcmp(btmp,
"true")
318 || !strcmp(btmp,
"Y") || !strcmp(btmp,
"y")
319 || !strcmp(btmp,
"YES") || !strcmp(btmp,
"yes")) {
322 }
else if (!strcmp(btmp,
"FALSE") || !strcmp(btmp,
"false")
323 || !strcmp(btmp,
"N") || !strcmp(btmp,
"n")
324 || !strcmp(btmp,
"NO") || !strcmp(btmp,
"no")) {
361 if (linebuf == NULL) {
368 for (
p = linebuf, q = linebuf; (
c = *
p) && (
c !=
'\r') && (
c !=
'\n');
382 }
else if (
c ==
',') {
420 printf(
"%s=%s\n", ntmp, vtmp);
454 while (*
p && isspace((
unsigned char)*
p))
458 q =
p + strlen(
p) - 1;
459 while ((q !=
p) && isspace((
unsigned char)*q))
479 const unsigned char *
p;
481 static const char hexdig[] =
"0123456789ABCDEF";
490 *q++ = hexdig[(*
p >> 4) & 0xf];
491 *q++ = hexdig[*
p & 0xf];
501 unsigned char *hexbuf, *q;
502 unsigned char ch, cl, *
p;
509 for (
p = (
unsigned char *)
str, q = hexbuf; *
p;) {
520 if ((
ch >=
'0') && (
ch <=
'9'))
522 else if ((
ch >=
'a') && (
ch <=
'f'))
524 else if ((
ch >=
'A') && (
ch <=
'F'))
529 if ((cl >=
'0') && (cl <=
'9'))
531 else if ((cl >=
'a') && (cl <=
'f'))
533 else if ((cl >=
'A') && (cl <=
'F'))
538 *q++ = (
ch << 4) | cl;
567 if (!
c || (
c ==
'.'))
574 return strcmp(*
a, *
b);
590 AUTHORITY_INFO_ACCESS *info;
597 for (
i = 0;
i < sk_ACCESS_DESCRIPTION_num(info);
i++) {
644 for (j = 0;
j < sk_GENERAL_NAME_num(gens);
j++) {
645 gen = sk_GENERAL_NAME_value(gens, j);
664 if (email->
data == NULL || email->
length == 0)
683 sk_OPENSSL_STRING_sort(*sk);
684 if (sk_OPENSSL_STRING_find(*sk, NULL, emtmp)) {
688 if (!sk_OPENSSL_STRING_push(*sk, emtmp)) {
704 sk_OPENSSL_STRING_pop_free(sk,
str_free);
708 const unsigned char *subject,
size_t subject_len,
713 const unsigned char *subject,
size_t subject_len,
717 size_t pattern_len = *plen;
728 while (pattern_len > subject_len && *
pattern) {
737 if (pattern_len == subject_len) {
745 const unsigned char *subject,
size_t subject_len,
749 if (pattern_len != subject_len)
751 while (pattern_len) {
753 unsigned char r = *subject;
758 if (
'A' <=
l &&
l <=
'Z')
760 if (
'A' <=
r &&
r <=
'Z')
774 const unsigned char *subject,
size_t subject_len,
778 if (pattern_len != subject_len)
788 const unsigned char *
b,
size_t b_len,
789 unsigned int unused_flags)
801 if (
a[
i] ==
'@' ||
b[
i] ==
'@') {
817 const unsigned char *
suffix,
size_t suffix_len,
818 const unsigned char *subject,
size_t subject_len,
821 const unsigned char *wildcard_start;
822 const unsigned char *wildcard_end;
823 const unsigned char *
p;
827 if (subject_len < prefix_len + suffix_len)
831 wildcard_start = subject + prefix_len;
832 wildcard_end = subject + (subject_len - suffix_len);
839 if (prefix_len == 0 && *
suffix ==
'.') {
840 if (wildcard_start == wildcard_end)
852 if (wildcard_end == wildcard_start + 1 && *wildcard_start ==
'*')
859 for (
p = wildcard_start;
p != wildcard_end; ++
p)
860 if (!((
'0' <= *
p && *
p <=
'9') ||
861 (
'A' <= *
p && *
p <=
'Z') ||
862 (
'a' <= *
p && *
p <=
'z') ||
863 *
p ==
'-' || (allow_multi && *
p ==
'.')))
868 #define LABEL_START (1 << 0)
869 #define LABEL_END (1 << 1)
870 #define LABEL_HYPHEN (1 << 2)
871 #define LABEL_IDNA (1 << 3)
876 const unsigned char *star = 0;
880 for (
i = 0;
i <
len; ++
i) {
887 int atend = (
i ==
len - 1 ||
p[
i + 1] ==
'.');
897 && (!atstart || !atend))
900 if (!atstart && !atend)
904 }
else if ((
'a' <=
p[
i] &&
p[
i] <=
'z')
905 || (
'A' <=
p[
i] &&
p[
i] <=
'Z')
906 || (
'0' <=
p[
i] &&
p[
i] <=
'9')) {
912 }
else if (
p[
i] ==
'.') {
917 }
else if (
p[
i] ==
'-') {
937 const unsigned char *subject,
size_t subject_len,
940 const unsigned char *star = NULL;
946 if (!(subject_len > 1 && subject[0] ==
'.'))
950 subject, subject_len,
flags);
952 star + 1, (
pattern + pattern_len) - star - 1,
953 subject, subject_len,
flags);
963 if (
len > 0 &&
in[
len - 1] ==
'.') {
968 if (
len >= 2 &&
in[0] ==
'*' &&
in[1] ==
'.') {
977 size_t label_start = 0;
978 for (
size_t i = 0;
i <
len;
i++) {
979 unsigned char c =
in[
i];
980 if ((
c >=
'a' &&
c <=
'z') ||
981 (
c >=
'0' &&
c <=
'9') ||
982 (
c >=
'A' &&
c <=
'Z') ||
983 (
c ==
'-' &&
i > label_start) ||
992 if (
c ==
'.' &&
i > label_start &&
i <
len - 1) {
1010 unsigned int flags,
int check_type,
const char *
b,
1011 size_t blen,
char **peername)
1015 if (!
a->data || !
a->length)
1018 if (cmp_type !=
a->type)
1021 rv =
equal(
a->data,
a->length, (
unsigned char *)
b, blen,
flags);
1024 if (rv > 0 && peername)
1028 unsigned char *astr;
1041 rv =
equal(astr, astrlen, (
unsigned char *)
b, blen,
flags);
1043 if (rv > 0 && peername)
1051 unsigned int flags,
int check_type,
char **peername)
1053 GENERAL_NAMES *gens = NULL;
1068 }
else if (check_type ==
GEN_DNS) {
1071 if (chklen > 1 && chk[0] ==
'.')
1085 for (
i = 0;
i < sk_GENERAL_NAME_num(gens);
i++) {
1088 gen = sk_GENERAL_NAME_value(gens,
i);
1093 else if (check_type ==
GEN_DNS)
1099 chk, chklen, peername)) != 0)
1119 chk, chklen, peername)) != 0)
1126 unsigned int flags,
char **peername)
1155 unsigned char ipout[16];
1173 unsigned char ipout[16];
1194 unsigned char ipout[32];
1195 char *iptmp = NULL, *
p;
1197 p = strchr(ipasc,
'/');
1203 p = iptmp + (
p - ipasc);
1216 if (!iplen2 || (iplen1 != iplen2))
1239 if (strchr(ipasc,
':')) {
1253 if (sscanf(
in,
"%d.%d.%d.%d", &a0, &
a1, &
a2, &a3) != 4)
1255 if ((a0 < 0) || (a0 > 255) || (
a1 < 0) || (
a1 > 255)
1256 || (
a2 < 0) || (
a2 > 255) || (a3 < 0) || (a3 > 255))
1294 if (v6stat.
total != 16)
1298 if (v6stat.
total == 16)
1305 if (v6stat.
total > 0)
1348 if (s->zero_pos == -1)
1349 s->zero_pos = s->total;
1351 else if (s->zero_pos != s->total)
1382 unsigned int num = 0;
1388 if ((
c >=
'0') && (
c <=
'9'))
1390 else if ((
c >=
'A') && (
c <=
'F'))
1391 num |=
c -
'A' + 10;
1392 else if ((
c >=
'a') && (
c <=
'f'))
1393 num |=
c -
'a' + 10;
1403 unsigned long chtype)
1412 for (
i = 0;
i < sk_CONF_VALUE_num(dn_sk);
i++) {
1413 v = sk_CONF_VALUE_value(dn_sk,
i);
1419 if ((*
p ==
':') || (*
p ==
',') || (*
p ==
'.')) {
1431 (
unsigned char *)
v->value, -1, -1,
unsigned char * x509v3_hex_to_bytes(const char *str, long *len)
ASN1_OCTET_STRING * a2i_IPADDRESS(const char *ipasc)
#define NID_pkcs9_emailAddress
static int ipv6_from_asc(unsigned char v6[16], const char *in)
#define X509_get_subject_name
int X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool)
static int OPENSSL_memcmp(const void *s1, const void *s2, size_t n)
#define X509_REQ_get_extensions
#define X509V3_R_ODD_NUMBER_OF_DIGITS
static int equal_wildcard(const unsigned char *pattern, size_t pattern_len, const unsigned char *subject, size_t subject_len, unsigned int flags)
static int equal_email(const unsigned char *a, size_t a_len, const unsigned char *b, size_t b_len, unsigned int unused_flags)
int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint, STACK_OF(CONF_VALUE) **extlist)
static void str_free(OPENSSL_STRING str)
ASN1_IA5STRING * uniformResourceIdentifier
static int equal_case(const unsigned char *pattern, size_t pattern_len, const unsigned char *subject, size_t subject_len, unsigned int flags)
int(* equal_fn)(const unsigned char *pattern, size_t pattern_len, const unsigned char *subject, size_t subject_len, unsigned int flags)
#define OPENSSL_PUT_ERROR(library, reason)
static uint8_t equal(signed char b, signed char c)
ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, const char *value)
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
static int do_x509_check(X509 *x, const char *chk, size_t chklen, unsigned int flags, int check_type, char **peername)
#define X509V3_R_INVALID_NULL_VALUE
static int equal_nocase(const unsigned char *pattern, size_t pattern_len, const unsigned char *subject, size_t subject_len, unsigned int flags)
static void * OPENSSL_memchr(const void *s, int c, size_t n)
#define V_ASN1_OCTET_STRING
#define X509V3_conf_err(val)
#define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT
#define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS
int X509V3_add_value_uchar(const char *name, const unsigned char *value, STACK_OF(CONF_VALUE) **extlist)
static int wildcard_match(const unsigned char *prefix, size_t prefix_len, const unsigned char *suffix, size_t suffix_len, const unsigned char *subject, size_t subject_len, unsigned int flags)
int x509V3_add_value_asn1_string(const char *name, const ASN1_STRING *value, STACK_OF(CONF_VALUE) **extlist)
#define X509_NAME_get_index_by_NID
#define ASN1_OCTET_STRING_set
int X509_check_host(X509 *x, const char *chk, size_t chklen, unsigned int flags, char **peername)
static void * OPENSSL_memset(void *dst, int c, size_t n)
#define X509_REQ_get_subject_name
OPENSSL_EXPORT ASN1_OCTET_STRING * ASN1_OCTET_STRING_new(void)
#define X509V3_R_BN_DEC2BN_ERROR
static int sk_strcmp(const OPENSSL_STRING *a, const OPENSSL_STRING *b)
char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, const ASN1_INTEGER *a)
ASN1_OCTET_STRING * iPAddress
#define X509V3_R_INVALID_NULL_ARGUMENT
int X509_check_email(X509 *x, const char *chk, size_t chklen, unsigned int flags)
int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk, unsigned long chtype)
int X509V3_add_value_bool(const char *name, int asn1_bool, STACK_OF(CONF_VALUE) **extlist)
#define X509V3_R_INVALID_BOOLEAN_STRING
int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, unsigned int flags)
#define X509_NAME_get_entry
int X509V3_add_value_bool_nf(const char *name, int asn1_bool, STACK_OF(CONF_VALUE) **extlist)
static int ipv6_cb(const char *elem, int len, void *usr)
#define X509V3_R_BN_TO_ASN1_INTEGER_ERROR
static int ipv4_from_asc(unsigned char v4[4], const char *in)
#define OPENSSL_strncasecmp
static void * OPENSSL_memcpy(void *dst, const void *src, size_t n)
ASN1_IA5STRING * rfc822Name
#define X509_NAME_ENTRY_get_data
void X509_email_free(STACK_OF(OPENSSL_STRING) *sk)
#define ASN1_INTEGER_to_BN
char * x509v3_bytes_to_hex(const unsigned char *buffer, long len)
#define X509V3_R_INVALID_NULL_NAME
static char * bignum_to_string(const BIGNUM *bn)
OPENSSL_EXPORT GENERAL_NAME * gen
#define X509_EXTENSION_free
#define GENERAL_NAMES_free
static STACK_OF(OPENSSL_STRING)
#define X509V3_R_ILLEGAL_HEX_DIGIT
#define AUTHORITY_INFO_ACCESS_free
#define GENERAL_NAME_free
#define X509V3_parse_list
static int do_check_string(ASN1_STRING *a, int cmp_type, equal_fn equal, unsigned int flags, int check_type, const char *b, size_t blen, char **peername)
#define ASN1_STRING_to_UTF8
int x509v3_looks_like_dns_name(const unsigned char *in, size_t len)
union GENERAL_NAME_st::@370 d
unsigned char suffix[65536]
#define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS
static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, ASN1_IA5STRING *email)
int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint)
static const unsigned char * valid_star(const unsigned char *p, size_t len, unsigned int flags)
UniquePtr< SSL_SESSION > ret
void X509V3_conf_free(CONF_VALUE *conf)
#define X509_NAME_add_entry_by_txt
std::array< int64_t, Size > values
static const char prefix[]
#define X509_REQ_get1_email
char * i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *method, const ASN1_ENUMERATED *a)
int x509v3_name_cmp(const char *name, const char *cmp)
#define NID_subject_alt_name
#define _X509_CHECK_FLAG_DOT_SUBDOMAINS
#define X509_CHECK_FLAG_NO_WILDCARDS
#define X509V3_R_INVALID_VALUE
int x509v3_a2i_ipadd(unsigned char ipout[16], const char *ipasc)
static void skip_prefix(const unsigned char **p, size_t *plen, const unsigned char *subject, size_t subject_len, unsigned int flags)
#define ASN1_ENUMERATED_to_BN
#define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS
#define BN_to_ASN1_INTEGER
ASN1_OCTET_STRING * a2i_IPADDRESS_NC(const char *ipasc)
int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags)
static int ipv6_hex(unsigned char *out, const char *in, int inlen)
OPENSSL_EXPORT void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *str)
static struct rpc_state state
#define ERR_R_MALLOC_FAILURE
static char * strip_spaces(char *name)
int X509V3_add_value(const char *name, const char *value, STACK_OF(CONF_VALUE) **extlist)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:49