• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2018, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #ifndef OPENSSL_HEADER_X509V3_INTERNAL_H
16 #define OPENSSL_HEADER_X509V3_INTERNAL_H
17 
18 #include <openssl/base.h>
19 
20 #include <openssl/conf.h>
21 
22 #if defined(__cplusplus)
23 extern "C" {
24 #endif
25 
26 
27 // x509v3_bytes_to_hex encodes |len| bytes from |buffer| to hex and returns a
28 // newly-allocated NUL-terminated string containing the result, or NULL on
29 // allocation error.
30 //
31 // Note this function was historically named |hex_to_string| in OpenSSL, not
32 // |string_to_hex|.
33 char *x509v3_bytes_to_hex(const unsigned char *buffer, long len);
34 
35 // x509v3_hex_string_to_bytes decodes |str| in hex and returns a newly-allocated
36 // array containing the result, or NULL on error. On success, it sets |*len| to
37 // the length of the result. Colon separators between bytes in the input are
38 // allowed and ignored.
39 //
40 // Note this function was historically named |string_to_hex| in OpenSSL, not
41 // |hex_to_string|.
42 unsigned char *x509v3_hex_to_bytes(const char *str, long *len);
43 
44 // x509v3_name_cmp returns zero if |name| is equal to |cmp| or begins with |cmp|
45 // followed by '.'. Otherwise, it returns a non-zero number.
46 int x509v3_name_cmp(const char *name, const char *cmp);
47 
48 // x509v3_looks_like_dns_name returns one if |in| looks like a DNS name and zero
49 // otherwise.
50 OPENSSL_EXPORT int x509v3_looks_like_dns_name(const unsigned char *in,
51                                               size_t len);
52 
53 // x509v3_cache_extensions fills in a number of fields relating to X.509
54 // extensions in |x|. It returns one on success and zero if some extensions were
55 // invalid.
56 int x509v3_cache_extensions(X509 *x);
57 
58 // x509v3_a2i_ipadd decodes |ipasc| as an IPv4 or IPv6 address. IPv6 addresses
59 // use colon-separated syntax while IPv4 addresses use dotted decimal syntax. If
60 // it decodes an IPv4 address, it writes the result to the first four bytes of
61 // |ipout| and returns four. If it decodes an IPv6 address, it writes the result
62 // to all 16 bytes of |ipout| and returns 16. Otherwise, it returns zero.
63 int x509v3_a2i_ipadd(unsigned char ipout[16], const char *ipasc);
64 
65 // A |BIT_STRING_BITNAME| is used to contain a list of bit names.
66 typedef struct {
67   int bitnum;
68   const char *lname;
69   const char *sname;
70 } BIT_STRING_BITNAME;
71 
72 // x509V3_add_value_asn1_string appends a |CONF_VALUE| with the specified name
73 // and value to |*extlist|. if |*extlist| is NULL, it sets |*extlist| to a
74 // newly-allocated |STACK_OF(CONF_VALUE)| first. It returns one on success and
75 // zero on error.
76 int x509V3_add_value_asn1_string(const char *name, const ASN1_STRING *value,
77                                  STACK_OF(CONF_VALUE) **extlist);
78 
79 
80 #if defined(__cplusplus)
81 }  /* extern C */
82 #endif
83 
84 #endif  /* OPENSSL_HEADER_X509V3_INTERNAL_H */
85