Skip to content

Commit ae49b31

Browse files
davidbensamuel40791765
authored andcommitted
Merge crypto/x509v3 into crypto/x509
The public headers are not yet merged. That will be doen in the subsequent CL. This required teaching make_errors.go that x509v3 are found elsewhere, also to skip irrelevant OPENSSL_DECLARE_ERROR_REASON calls. Change-Id: Ic40de51f9a5325acd60262c614924dc3407b800c Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/64137 Commit-Queue: David Benjamin <[email protected]> Reviewed-by: Bob Beck <[email protected]> (cherry picked from commit 861cb31975b68abd0b6ed7d0dd37213b17385bab)
1 parent 32f0de9 commit ae49b31

38 files changed

+166
-254
lines changed

crypto/CMakeLists.txt

+38-38
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,42 @@ add_library(
460460
x509/t_req.c
461461
x509/t_x509.c
462462
x509/t_x509a.c
463-
x509/x509.c
463+
x509/v3_akey.c
464+
x509/v3_akeya.c
465+
x509/v3_alt.c
466+
x509/v3_bcons.c
467+
x509/v3_bitst.c
468+
x509/v3_conf.c
469+
x509/v3_cpols.c
470+
x509/v3_crld.c
471+
x509/v3_enum.c
472+
x509/v3_extku.c
473+
x509/v3_genn.c
474+
x509/v3_ia5.c
475+
x509/v3_info.c
476+
x509/v3_int.c
477+
x509/v3_lib.c
478+
x509/v3_ncons.c
479+
x509/v3_ocsp.c
480+
x509/v3_pcons.c
481+
x509/v3_pmaps.c
482+
x509/v3_prn.c
483+
x509/v3_purp.c
484+
x509/v3_skey.c
485+
x509/v3_utl.c
486+
x509/x_algor.c
487+
x509/x_all.c
488+
x509/x_attrib.c
489+
x509/x_crl.c
490+
x509/x_exten.c
491+
x509/x_name.c
492+
x509/x_pubkey.c
493+
x509/x_req.c
494+
x509/x_sig.c
495+
x509/x_spki.c
496+
x509/x_val.c
497+
x509/x_x509.c
498+
x509/x_x509a.c
464499
x509/x509_att.c
465500
x509/x509_cmp.c
466501
x509/x509_d2.c
@@ -475,46 +510,11 @@ add_library(
475510
x509/x509_v3.c
476511
x509/x509_vfy.c
477512
x509/x509_vpm.c
513+
x509/x509.c
478514
x509/x509cset.c
479515
x509/x509name.c
480516
x509/x509rset.c
481517
x509/x509spki.c
482-
x509/x_algor.c
483-
x509/x_all.c
484-
x509/x_attrib.c
485-
x509/x_crl.c
486-
x509/x_exten.c
487-
x509/x_name.c
488-
x509/x_pubkey.c
489-
x509/x_req.c
490-
x509/x_sig.c
491-
x509/x_spki.c
492-
x509/x_val.c
493-
x509/x_x509.c
494-
x509/x_x509a.c
495-
x509v3/v3_akey.c
496-
x509v3/v3_akeya.c
497-
x509v3/v3_alt.c
498-
x509v3/v3_bcons.c
499-
x509v3/v3_bitst.c
500-
x509v3/v3_conf.c
501-
x509v3/v3_cpols.c
502-
x509v3/v3_crld.c
503-
x509v3/v3_enum.c
504-
x509v3/v3_extku.c
505-
x509v3/v3_genn.c
506-
x509v3/v3_ia5.c
507-
x509v3/v3_info.c
508-
x509v3/v3_int.c
509-
x509v3/v3_lib.c
510-
x509v3/v3_ncons.c
511-
x509v3/v3_ocsp.c
512-
x509v3/v3_pcons.c
513-
x509v3/v3_pmaps.c
514-
x509v3/v3_prn.c
515-
x509v3/v3_purp.c
516-
x509v3/v3_skey.c
517-
x509v3/v3_utl.c
518518
decrepit/bio/base64_bio.c
519519
decrepit/blowfish/blowfish.c
520520
decrepit/cast/cast.c
@@ -765,9 +765,9 @@ if(BUILD_TESTING)
765765
test/file_test_gtest.cc
766766
thread_test.cc
767767
trust_token/trust_token_test.cc
768+
x509/tab_test.cc
768769
x509/x509_test.cc
769770
x509/x509_time_test.cc
770-
x509v3/tab_test.cc
771771
decrepit/blowfish/blowfish_test.cc
772772
decrepit/cast/cast_test.cc
773773
decrepit/cfb/cfb_test.cc

crypto/x509/asn1_gen.c

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969

7070
#include "../conf/internal.h"
7171
#include "../internal.h"
72-
#include "../x509v3/internal.h"
7372
#include "internal.h"
7473

7574

File renamed without changes.

crypto/x509/internal.h

+113
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include <openssl/base.h>
6363
#include <openssl/evp.h>
6464
#include <openssl/x509.h>
65+
#include <openssl/x509v3.h>
6566

6667
#include "../asn1/internal.h"
6768

@@ -428,6 +429,118 @@ int X509_policy_check(const STACK_OF(X509) *certs,
428429
// one internal project and rust-openssl, who use it by mistake.
429430
int x509_check_issued_with_callback(X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
430431

432+
// x509v3_bytes_to_hex encodes |len| bytes from |in| to hex and returns a
433+
// newly-allocated NUL-terminated string containing the result, or NULL on
434+
// allocation error.
435+
//
436+
// This function was historically named |hex_to_string| in OpenSSL. Despite the
437+
// name, |hex_to_string| converted to hex.
438+
OPENSSL_EXPORT char *x509v3_bytes_to_hex(const uint8_t *in, size_t len);
439+
440+
// x509v3_hex_string_to_bytes decodes |str| in hex and returns a newly-allocated
441+
// array containing the result, or NULL on error. On success, it sets |*len| to
442+
// the length of the result. Colon separators between bytes in the input are
443+
// allowed and ignored.
444+
//
445+
// This function was historically named |string_to_hex| in OpenSSL. Despite the
446+
// name, |string_to_hex| converted from hex.
447+
unsigned char *x509v3_hex_to_bytes(const char *str, size_t *len);
448+
449+
// x509v3_conf_name_matches returns one if |name| is equal to |cmp| or begins
450+
// with |cmp| followed by '.', and zero otherwise.
451+
int x509v3_conf_name_matches(const char *name, const char *cmp);
452+
453+
// x509v3_looks_like_dns_name returns one if |in| looks like a DNS name and zero
454+
// otherwise.
455+
OPENSSL_EXPORT int x509v3_looks_like_dns_name(const unsigned char *in,
456+
size_t len);
457+
458+
// x509v3_cache_extensions fills in a number of fields relating to X.509
459+
// extensions in |x|. It returns one on success and zero if some extensions were
460+
// invalid.
461+
OPENSSL_EXPORT int x509v3_cache_extensions(X509 *x);
462+
463+
// x509v3_a2i_ipadd decodes |ipasc| as an IPv4 or IPv6 address. IPv6 addresses
464+
// use colon-separated syntax while IPv4 addresses use dotted decimal syntax. If
465+
// it decodes an IPv4 address, it writes the result to the first four bytes of
466+
// |ipout| and returns four. If it decodes an IPv6 address, it writes the result
467+
// to all 16 bytes of |ipout| and returns 16. Otherwise, it returns zero.
468+
int x509v3_a2i_ipadd(unsigned char ipout[16], const char *ipasc);
469+
470+
// A |BIT_STRING_BITNAME| is used to contain a list of bit names.
471+
typedef struct {
472+
int bitnum;
473+
const char *lname;
474+
const char *sname;
475+
} BIT_STRING_BITNAME;
476+
477+
// x509V3_add_value_asn1_string appends a |CONF_VALUE| with the specified name
478+
// and value to |*extlist|. if |*extlist| is NULL, it sets |*extlist| to a
479+
// newly-allocated |STACK_OF(CONF_VALUE)| first. It returns one on success and
480+
// zero on error.
481+
int x509V3_add_value_asn1_string(const char *name, const ASN1_STRING *value,
482+
STACK_OF(CONF_VALUE) **extlist);
483+
484+
// X509V3_NAME_from_section adds attributes to |nm| by interpreting the
485+
// key/value pairs in |dn_sk|. It returns one on success and zero on error.
486+
// |chtype|, which should be one of |MBSTRING_*| constants, determines the
487+
// character encoding used to interpret values.
488+
int X509V3_NAME_from_section(X509_NAME *nm, const STACK_OF(CONF_VALUE) *dn_sk,
489+
int chtype);
490+
491+
// X509V3_bool_from_string decodes |str| as a boolean. On success, it returns
492+
// one and sets |*out_bool| to resulting value. Otherwise, it returns zero.
493+
int X509V3_bool_from_string(const char *str, ASN1_BOOLEAN *out_bool);
494+
495+
// X509V3_get_value_bool decodes |value| as a boolean. On success, it returns
496+
// one and sets |*out_bool| to the resulting value. Otherwise, it returns zero.
497+
int X509V3_get_value_bool(const CONF_VALUE *value, ASN1_BOOLEAN *out_bool);
498+
499+
// X509V3_get_value_int decodes |value| as an integer. On success, it returns
500+
// one and sets |*aint| to the resulting value. Otherwise, it returns zero. If
501+
// |*aint| was non-NULL at the start of the function, it frees the previous
502+
// value before writing a new one.
503+
int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint);
504+
505+
// X509V3_get_section behaves like |NCONF_get_section| but queries |ctx|'s
506+
// config database.
507+
const STACK_OF(CONF_VALUE) *X509V3_get_section(const X509V3_CTX *ctx,
508+
const char *section);
509+
510+
// X509V3_add_value appends a |CONF_VALUE| containing |name| and |value| to
511+
// |*extlist|. It returns one on success and zero on error. If |*extlist| is
512+
// NULL, it sets |*extlist| to a newly-allocated |STACK_OF(CONF_VALUE)|
513+
// containing the result. Either |name| or |value| may be NULL to omit the
514+
// field.
515+
//
516+
// On failure, if |*extlist| was NULL, |*extlist| will remain NULL when the
517+
// function returns.
518+
int X509V3_add_value(const char *name, const char *value,
519+
STACK_OF(CONF_VALUE) **extlist);
520+
521+
// X509V3_add_value_bool behaves like |X509V3_add_value| but stores the value
522+
// "TRUE" if |asn1_bool| is non-zero and "FALSE" otherwise.
523+
int X509V3_add_value_bool(const char *name, int asn1_bool,
524+
STACK_OF(CONF_VALUE) **extlist);
525+
526+
// X509V3_add_value_bool behaves like |X509V3_add_value| but stores a string
527+
// representation of |aint|. Note this string representation may be decimal or
528+
// hexadecimal, depending on the size of |aint|.
529+
int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint,
530+
STACK_OF(CONF_VALUE) **extlist);
531+
532+
#define X509V3_conf_err(val) \
533+
ERR_add_error_data(6, "section:", (val)->section, ",name:", (val)->name, \
534+
",value:", (val)->value);
535+
536+
// GENERAL_NAME_cmp returns zero if |a| and |b| are equal and a non-zero
537+
// value otherwise. Note this function does not provide a comparison suitable
538+
// for sorting.
539+
//
540+
// This function is exported for testing.
541+
OPENSSL_EXPORT int GENERAL_NAME_cmp(const GENERAL_NAME *a,
542+
const GENERAL_NAME *b);
543+
431544

432545
#if defined(__cplusplus)
433546
} // extern C

crypto/x509/policy.c

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <openssl/x509v3.h>
2323

2424
#include "../internal.h"
25-
#include "../x509v3/internal.h"
2625
#include "internal.h"
2726

2827

File renamed without changes.
File renamed without changes.
File renamed without changes.

crypto/x509v3/v3_alt.c crypto/x509/v3_alt.c

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
#include <openssl/obj.h>
6464
#include <openssl/x509v3.h>
6565

66-
#include "../x509/internal.h"
6766
#include "internal.h"
6867

6968

File renamed without changes.
File renamed without changes.

crypto/x509v3/v3_conf.c crypto/x509/v3_conf.c

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
#include <openssl/x509v3.h>
7070

7171
#include "../internal.h"
72-
#include "../x509/internal.h"
7372
#include "internal.h"
7473

7574
static int v3_check_critical(const char **value);
File renamed without changes.

crypto/x509v3/v3_crld.c crypto/x509/v3_crld.c

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
#include <openssl/obj.h>
6666
#include <openssl/x509v3.h>
6767

68-
#include "../x509/internal.h"
6968
#include "internal.h"
7069

7170

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

crypto/x509v3/v3_lib.c crypto/x509/v3_lib.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@
6666
#include <openssl/obj.h>
6767
#include <openssl/x509v3.h>
6868

69-
#include "../x509/internal.h"
69+
#include "internal.h"
7070

7171
#include "ext_dat.h"
72+
7273
static STACK_OF(X509V3_EXT_METHOD) *ext_list = NULL;
7374

7475
static int ext_stack_cmp(const X509V3_EXT_METHOD *const *a,

crypto/x509v3/v3_ncons.c crypto/x509/v3_ncons.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
#include <openssl/x509v3.h>
6666

6767
#include "../internal.h"
68-
#include "../x509/internal.h"
68+
#include "internal.h"
6969

7070

7171
static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

crypto/x509v3/v3_purp.c crypto/x509/v3_purp.c

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
#include <openssl/x509v3.h>
6767

6868
#include "../internal.h"
69-
#include "../x509/internal.h"
7069
#include "internal.h"
7170

7271
#define V1_ROOT (EXFLAG_V1 | EXFLAG_SS)

crypto/x509v3/v3_skey.c crypto/x509/v3_skey.c

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
#include <openssl/mem.h>
6565
#include <openssl/x509v3.h>
6666

67-
#include "../x509/internal.h"
6867
#include "internal.h"
6968

7069

File renamed without changes.

crypto/x509/x509_cmp.c

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
#include <openssl/x509v3.h>
6767

6868
#include "../internal.h"
69-
#include "../x509v3/internal.h"
7069
#include "internal.h"
7170

7271

crypto/x509/x509_set.c

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
#include <openssl/obj.h>
6161
#include <openssl/x509.h>
6262

63-
#include "../x509v3/internal.h"
6463
#include "internal.h"
6564
#include "openssl/x509v3.h"
6665

crypto/x509/x509_test.cc

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "../evp_extra/internal.h"
3939
#include "../internal.h"
4040
#include "../test/test_util.h"
41-
#include "../x509v3/internal.h"
4241

4342
#if defined(OPENSSL_THREADS)
4443
#include <thread>

crypto/x509/x509_trs.c

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
#include <openssl/obj.h>
6060
#include <openssl/x509v3.h>
6161

62-
#include "../x509v3/internal.h"
6362
#include "internal.h"
6463

6564

crypto/x509/x509_vfy.c

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
#include <openssl/x509v3.h>
6969

7070
#include "../internal.h"
71-
#include "../x509v3/internal.h"
7271
#include "internal.h"
7372

7473
static CRYPTO_EX_DATA_CLASS g_ex_data_class =

crypto/x509/x509_vpm.c

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
#include <openssl/x509v3.h>
6464

6565
#include "../internal.h"
66-
#include "../x509v3/internal.h"
6766
#include "internal.h"
6867

6968

0 commit comments

Comments
 (0)