003 File Manager
Current Path:
/usr/src/contrib/subversion/subversion/libsvn_subr
usr
/
src
/
contrib
/
subversion
/
subversion
/
libsvn_subr
/
📁
..
📄
adler32.c
(3.16 KB)
📄
atomic.c
(7.23 KB)
📄
auth.c
(32.4 KB)
📄
auth.h
(6.1 KB)
📄
base64.c
(19.18 KB)
📄
bit_array.c
(6.26 KB)
📄
cache-inprocess.c
(21.2 KB)
📄
cache-membuffer.c
(116.43 KB)
📄
cache-memcache.c
(17.35 KB)
📄
cache-null.c
(4.35 KB)
📄
cache.c
(10.22 KB)
📄
cache.h
(4.03 KB)
📄
cache_config.c
(6.01 KB)
📄
checksum.c
(24.17 KB)
📄
checksum.h
(2.32 KB)
📄
cmdline.c
(58.99 KB)
📄
compat.c
(5.28 KB)
📄
compress_lz4.c
(4.51 KB)
📄
compress_zlib.c
(6.85 KB)
📄
config.c
(39.66 KB)
📄
config_auth.c
(8.65 KB)
📄
config_file.c
(70.25 KB)
📄
config_impl.h
(6.15 KB)
📄
config_keys.inc
(2.65 KB)
📄
config_win.c
(9.61 KB)
📄
crypto.c
(25.19 KB)
📄
crypto.h
(5.43 KB)
📄
ctype.c
(13.81 KB)
📄
date.c
(12.86 KB)
📄
debug.c
(3.77 KB)
📄
deprecated.c
(64.3 KB)
📄
dirent_uri.c
(80.17 KB)
📄
dirent_uri.h
(1.43 KB)
📄
dso.c
(3.74 KB)
📄
encode.c
(2.69 KB)
📄
eol.c
(2.79 KB)
📄
error.c
(24.52 KB)
📄
errorcode.inc
(4.27 KB)
📄
fnv1a.c
(6.92 KB)
📄
fnv1a.h
(3.04 KB)
📄
genctype.py
(3.84 KB)
📄
gpg_agent.c
(22.29 KB)
📄
hash.c
(19.59 KB)
📄
internal_statements.h
(1.87 KB)
📄
internal_statements.sql
(1.58 KB)
📄
io.c
(182.6 KB)
📄
iter.c
(3.84 KB)
📄
libsvn_subr.pc.in
(515 B)
📄
lock.c
(1.69 KB)
📄
log.c
(14 KB)
📁
lz4
📄
macos_keychain.c
(9.7 KB)
📄
magic.c
(5.25 KB)
📄
md5.c
(1.8 KB)
📄
mergeinfo.c
(89.24 KB)
📄
mutex.c
(3.06 KB)
📄
nls.c
(3.06 KB)
📄
object_pool.c
(9.76 KB)
📄
opt.c
(39.34 KB)
📄
opt.h
(1.89 KB)
📄
packed_data.c
(33.43 KB)
📄
path.c
(35.99 KB)
📄
pool.c
(4.35 KB)
📄
pools.h
(1.45 KB)
📄
prefix_string.c
(10.65 KB)
📄
prompt.c
(28.82 KB)
📄
properties.c
(13.59 KB)
📄
quoprint.c
(8.96 KB)
📄
root_pools.c
(3.15 KB)
📄
simple_providers.c
(25.54 KB)
📄
skel.c
(23.04 KB)
📄
sorts.c
(15.9 KB)
📄
spillbuf.c
(19.78 KB)
📄
sqlite.c
(49.68 KB)
📄
sqlite3wrapper.c
(3.16 KB)
📄
ssl_client_cert_providers.c
(6.66 KB)
📄
ssl_client_cert_pw_providers.c
(18.93 KB)
📄
ssl_server_trust_providers.c
(7.77 KB)
📄
stream.c
(65.69 KB)
📄
string.c
(40.2 KB)
📄
subst.c
(67.57 KB)
📄
sysinfo.c
(43.67 KB)
📄
sysinfo.h
(2.58 KB)
📄
target.c
(11.58 KB)
📄
temp_serializer.c
(14.02 KB)
📄
time.c
(9.08 KB)
📄
token.c
(2.58 KB)
📄
types.c
(9.43 KB)
📄
user.c
(2.66 KB)
📄
username_providers.c
(9.2 KB)
📄
utf.c
(40.38 KB)
📁
utf8proc
📄
utf8proc.c
(20.71 KB)
📄
utf_validate.c
(13.3 KB)
📄
utf_width.c
(10.85 KB)
📄
validate.c
(3.35 KB)
📄
version.c
(9.89 KB)
📄
win32_crashrpt.c
(25.06 KB)
📄
win32_crashrpt.h
(1.35 KB)
📄
win32_crashrpt_dll.h
(4 KB)
📄
win32_crypto.c
(18.12 KB)
📄
win32_xlate.c
(7.3 KB)
📄
win32_xlate.h
(2.11 KB)
📄
x509.h
(3.75 KB)
📄
x509info.c
(9.53 KB)
📄
x509parse.c
(35.77 KB)
📄
xml.c
(20.01 KB)
Editing: x509info.c
/* * x509info.c: Accessors for svn_x509_certinfo_t * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * ==================================================================== */ #include <string.h> #include <apr_pools.h> #include <apr_tables.h> #include "svn_string.h" #include "svn_hash.h" #include "x509.h" svn_x509_name_attr_t * svn_x509_name_attr_dup(const svn_x509_name_attr_t *attr, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { svn_x509_name_attr_t *result = apr_palloc(result_pool, sizeof(*result)); result->oid_len = attr->oid_len; result->oid = apr_pmemdup(result_pool, attr->oid, attr->oid_len); result->utf8_value = apr_pstrdup(result_pool, attr->utf8_value); return result; } const unsigned char * svn_x509_name_attr_get_oid(const svn_x509_name_attr_t *attr, apr_size_t *len) { *len = attr->oid_len; return attr->oid; } const char * svn_x509_name_attr_get_value(const svn_x509_name_attr_t *attr) { return attr->utf8_value; } /* Array elements are assumed to be nul-terminated C strings. */ static apr_array_header_t * deep_copy_array(apr_array_header_t *s, apr_pool_t *result_pool) { int i; apr_array_header_t *d; if (!s) return NULL; d = apr_array_copy(result_pool, s); /* Make a deep copy of the strings in the array. */ for (i = 0; i < s->nelts; ++i) { APR_ARRAY_IDX(d, i, const char *) = apr_pstrdup(result_pool, APR_ARRAY_IDX(s, i, const char *)); } return d; } /* Copy an array with elements that are svn_x509_name_attr_t's */ static apr_array_header_t * deep_copy_name_attrs(apr_array_header_t *s, apr_pool_t *result_pool) { int i; apr_array_header_t *d; if (!s) return NULL; d = apr_array_copy(result_pool, s); /* Make a deep copy of the svn_x509_name_attr_t's in the array. */ for (i = 0; i < s->nelts; ++i) { APR_ARRAY_IDX(d, i, const svn_x509_name_attr_t *) = svn_x509_name_attr_dup(APR_ARRAY_IDX(s, i, svn_x509_name_attr_t *), result_pool, result_pool); } return d; } svn_x509_certinfo_t * svn_x509_certinfo_dup(const svn_x509_certinfo_t *certinfo, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { svn_x509_certinfo_t *result = apr_palloc(result_pool, sizeof(*result)); result->subject = deep_copy_name_attrs(certinfo->subject, result_pool); result->issuer = deep_copy_name_attrs(certinfo->issuer, result_pool); result->valid_from = certinfo->valid_from; result->valid_to = certinfo->valid_to; result->digest = svn_checksum_dup(certinfo->digest, result_pool); result->hostnames = deep_copy_array(certinfo->hostnames, result_pool); return result; } typedef struct asn1_oid { const unsigned char *oid; const apr_size_t oid_len; const char *short_label; const char *long_label; } asn1_oid; #define CONSTANT_PAIR(c) (const unsigned char *)(c), sizeof((c)) - 1 static const asn1_oid asn1_oids[] = { { CONSTANT_PAIR(SVN_X509_OID_COMMON_NAME), "CN", "commonName" }, { CONSTANT_PAIR(SVN_X509_OID_COUNTRY), "C", "countryName" }, { CONSTANT_PAIR(SVN_X509_OID_LOCALITY), "L", "localityName" }, { CONSTANT_PAIR(SVN_X509_OID_STATE), "ST", "stateOrProvinceName" }, { CONSTANT_PAIR(SVN_X509_OID_ORGANIZATION), "O", "organizationName" }, { CONSTANT_PAIR(SVN_X509_OID_ORG_UNIT), "OU", "organizationalUnitName"}, { CONSTANT_PAIR(SVN_X509_OID_EMAIL), NULL, "emailAddress" }, { NULL }, }; /* Given an OID return a null-terminated C string representation. * For example an OID with the bytes "\x2A\x86\x48\x86\xF7\x0D\x01\x09\x01" * would be converted to the string "1.2.840.113549.1.9.1". */ const char * svn_x509_oid_to_string(const unsigned char *oid, apr_size_t oid_len, apr_pool_t *scratch_pool, apr_pool_t *result_pool) { svn_stringbuf_t *out = svn_stringbuf_create_empty(result_pool); const unsigned char *p = oid; const unsigned char *end = p + oid_len; const char *temp; while (p != end) { if (p == oid) { /* Handle decoding the first two values of the OID. These values * are encoded by taking the first value and adding 40 to it and * adding the result to the second value, then placing this single * value in the first byte of the output. This is unambiguous since * the first value is apparently limited to 0, 1 or 2 and the second * is limited to 0 to 39. */ temp = apr_psprintf(scratch_pool, "%d.%d", *p / 40, *p % 40); p++; } else if (*p < 128) { /* The remaining values if they're less than 128 are just * the number one to one encoded */ temp = apr_psprintf(scratch_pool, ".%d", *p); p++; } else { /* Values greater than 128 are encoded as a series of 7 bit values * with the left most bit set to indicate this encoding with the * last octet missing the left most bit to finish out the series.. */ unsigned int collector = 0; svn_boolean_t dot = FALSE; do { if (collector == 0 && *p == 0x80) { /* include leading zeros in the string representation technically not legal, but this seems nicer than just returning NULL */ if (!dot) { svn_stringbuf_appendbyte(out, '.'); dot = TRUE; } svn_stringbuf_appendbyte(out, '0'); } else if (collector > UINT_MAX >> 7) { /* overflow */ return NULL; } collector = collector << 7 | (*(p++) & 0x7f); } while (p != end && *p > 127); if (collector > UINT_MAX >> 7) return NULL; /* overflow */ collector = collector << 7 | *(p++); temp = apr_psprintf(scratch_pool, "%s%d", dot ? "" : ".", collector); } svn_stringbuf_appendcstr(out, temp); } if (svn_stringbuf_isempty(out)) return NULL; return out->data; } static const asn1_oid *oid_to_asn1_oid(unsigned char *oid, apr_size_t oid_len) { const asn1_oid *entry; for (entry = asn1_oids; entry->oid; entry++) { if (oid_len == entry->oid_len && memcmp(oid, entry->oid, oid_len) == 0) return entry; } return NULL; } static const char *oid_to_best_label(unsigned char *oid, apr_size_t oid_len, apr_pool_t *result_pool) { const asn1_oid *entry = oid_to_asn1_oid(oid, oid_len); if (entry) { if (entry->short_label) return entry->short_label; if (entry->long_label) return entry->long_label; } else { const char *oid_string = svn_x509_oid_to_string(oid, oid_len, result_pool, result_pool); if (oid_string) return oid_string; } return "??"; } /* * Store the name from dn in printable form into buf, * using scratch_pool for any temporary allocations. * If CN is not NULL, return any common name in CN */ static const char * get_dn(apr_array_header_t *name, apr_pool_t *result_pool) { svn_stringbuf_t *buf = svn_stringbuf_create_empty(result_pool); int n; for (n = 0; n < name->nelts; n++) { const svn_x509_name_attr_t *attr = APR_ARRAY_IDX(name, n, svn_x509_name_attr_t *); if (n > 0) svn_stringbuf_appendcstr(buf, ", "); svn_stringbuf_appendcstr(buf, oid_to_best_label(attr->oid, attr->oid_len, result_pool)); svn_stringbuf_appendbyte(buf, '='); svn_stringbuf_appendcstr(buf, attr->utf8_value); } return buf->data; } const char * svn_x509_certinfo_get_subject(const svn_x509_certinfo_t *certinfo, apr_pool_t *result_pool) { return get_dn(certinfo->subject, result_pool); } const apr_array_header_t * svn_x509_certinfo_get_subject_attrs(const svn_x509_certinfo_t *certinfo) { return certinfo->subject; } const char * svn_x509_certinfo_get_issuer(const svn_x509_certinfo_t *certinfo, apr_pool_t *result_pool) { return get_dn(certinfo->issuer, result_pool); } const apr_array_header_t * svn_x509_certinfo_get_issuer_attrs(const svn_x509_certinfo_t *certinfo) { return certinfo->issuer; } apr_time_t svn_x509_certinfo_get_valid_from(const svn_x509_certinfo_t *certinfo) { return certinfo->valid_from; } apr_time_t svn_x509_certinfo_get_valid_to(const svn_x509_certinfo_t *certinfo) { return certinfo->valid_to; } const svn_checksum_t * svn_x509_certinfo_get_digest(const svn_x509_certinfo_t *certinfo) { return certinfo->digest; } const apr_array_header_t * svn_x509_certinfo_get_hostnames(const svn_x509_certinfo_t *certinfo) { return certinfo->hostnames; }
Upload File
Create Folder