diff --git a/CHANGES b/CHANGES index 86da7f1b..c44dc0fd 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,48 @@ Changes between 1.1.1 and 3.0.0 [xx XXX xxxx] + *) Removed NextStep support and the macro OPENSSL_UNISTD + [Rich Salz] + + *) Removed DES_check_key. Also removed OPENSSL_IMPLEMENT_GLOBAL, + OPENSSL_GLOBAL_REF, OPENSSL_DECLARE_GLOBAL. + Also removed "export var as function" capability; we do not export + variables, only functions. + [Rich Salz] + + *) RC5_32_set_key has been changed to return an int type, with 0 indicating + an error and 1 indicating success. In previous versions of OpenSSL this + was a void type. If a key was set longer than the maximum possible this + would crash. + [Matt Caswell] + + *) Support SM2 signing and verification schemes with X509 certificate. + [Paul Yang] + + *) Use SHA256 as the default digest for TS query in the ts app. + [Tomas Mraz] + + *) Change PBKDF2 to conform to SP800-132 instead of the older PKCS5 RFC2898. + This checks that the salt length is at least 128 bits, the derived key + length is at least 112 bits, and that the iteration count is at least 1000. + For backwards compatibility these checks are disabled by default in the + default provider, but are enabled by default in the fips provider. + To enable or disable these checks use the control + EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE. + [Shane Lontis] + + *) Default cipher lists/suites are now available via a function, the + #defines are deprecated. + [Todd Short] + + *) Add target VC-WIN32-UWP, VC-WIN64A-UWP, VC-WIN32-ARM-UWP and + VC-WIN64-ARM-UWP in Windows OneCore target for making building libraries + for Windows Store apps easier. Also, the "no-uplink" option has been added. + [Kenji Mouri] + + *) Join the directories crypto/x509 and crypto/x509v3 + [Richard Levitte] + *) Change the default RSA, DSA and DH size to 2048 bit instead of 1024. This changes the size when using the genpkey app when no size is given. It fixes an omission in earlier changes that changed all RSA, DSA and DH @@ -18,7 +60,7 @@ *) Added command 'openssl kdf' that uses the EVP_KDF API. [Shane Lontis] - *) Added command 'openssl mac' that uses the EVP_MAC API. + *) Added command 'openssl mac' that uses the EVP_MAC API. [Shane Lontis] *) Added OPENSSL_info() to get diverse built-in OpenSSL data, such @@ -420,7 +462,7 @@ SSL_set_ciphersuites() [Matt Caswell] - *) Memory allocation failures consistenly add an error to the error + *) Memory allocation failures consistently add an error to the error stack. [Rich Salz] @@ -6958,7 +7000,7 @@ reason texts, thereby removing some of the footprint that may not be interesting if those errors aren't displayed anyway. - NOTE: it's still possible for any application or module to have it's + NOTE: it's still possible for any application or module to have its own set of error texts inserted. The routines are there, just not used by default when no-err is given. [Richard Levitte] @@ -8924,7 +8966,7 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k Changes between 0.9.6g and 0.9.6h [5 Dec 2002] *) New function OPENSSL_cleanse(), which is used to cleanse a section of - memory from it's contents. This is done with a counter that will + memory from its contents. This is done with a counter that will place alternating values in each byte. This can be used to solve two issues: 1) the removal of calls to memset() by highly optimizing compilers, and 2) cleansing with other values than 0, since those can diff --git a/CONTRIBUTING b/CONTRIBUTING index 250bbdbf..b65463c0 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -19,8 +19,16 @@ guidelines: 1. Anything other than a trivial contribution requires a Contributor License Agreement (CLA), giving us permission to use your code. See https://www.openssl.org/policies/cla.html for details. If your - contribution is too small to require a CLA, put "CLA: trivial" on a - line by itself in your commit message body. + contribution is too small to require a CLA (e.g. fixing a spelling + mistake), place the text "CLA: trivial" on a line by itself separated by + an empty line from the rest of the commit message. It is not sufficient to + only place the text in the GitHub pull request description. + + To amend a missing "CLA: trivial" line after submission, do the following: + + git commit --amend + [add the line, save and quit the editor] + git push -f 2. All source files should start with the following text (with appropriate comment characters at the start of each line and the diff --git a/Configurations/00-base-templates.conf b/Configurations/00-base-templates.conf index 20298c25..98200af7 100644 --- a/Configurations/00-base-templates.conf +++ b/Configurations/00-base-templates.conf @@ -14,28 +14,6 @@ my %targets=( thread_scheme => "(unknown)", # Assume we don't know thread_defines => [], - apps_aux_src => "", - apps_init_src => "", - cpuid_asm_src => "mem_clr.c", - uplink_aux_src => "", - bn_asm_src => "bn_asm.c", - ec_asm_src => "", - des_asm_src => "des_enc.c fcrypt_b.c", - aes_asm_src => "aes_core.c aes_cbc.c", - bf_asm_src => "bf_enc.c", - md5_asm_src => "", - cast_asm_src => "c_enc.c", - rc4_asm_src => "rc4_enc.c rc4_skey.c", - rmd160_asm_src => "", - rc5_asm_src => "rc5_enc.c", - wp_asm_src => "wp_block.c", - cmll_asm_src => "camellia.c cmll_misc.c cmll_cbc.c", - modes_asm_src => "", - padlock_asm_src => "", - chacha_asm_src => "chacha_enc.c", - poly1305_asm_src => "", - keccak1600_asm_src => "keccak1600.c", - unistd => "", shared_target => "", shared_cflag => "", @@ -168,190 +146,4 @@ my %targets=( perl_platform => 'VMS', }, - - uplink_common => { - template => 1, - apps_init_src => add("../ms/applink.c"), - uplink_aux_src => add("../ms/uplink.c"), - defines => add("OPENSSL_USE_APPLINK"), - }, - x86_uplink => { - inherit_from => [ "uplink_common" ], - template => 1, - uplink_aux_src => add("uplink-x86.s"), - }, - x86_64_uplink => { - inherit_from => [ "uplink_common" ], - template => 1, - uplink_aux_src => add("uplink-x86_64.s"), - }, - ia64_uplink => { - inherit_from => [ "uplink_common" ], - template => 1, - uplink_aux_src => add("uplink-ia64.s"), - }, - - x86_asm => { - template => 1, - cpuid_asm_src => "x86cpuid.s", - bn_asm_src => "bn-586.s co-586.s x86-mont.s x86-gf2m.s", - ec_asm_src => "ecp_nistz256.c ecp_nistz256-x86.s", - des_asm_src => "des-586.s crypt586.s", - aes_asm_src => "aes-586.s vpaes-x86.s aesni-x86.s", - bf_asm_src => "bf-586.s", - md5_asm_src => "md5-586.s", - cast_asm_src => "cast-586.s", - sha1_asm_src => "sha1-586.s sha256-586.s sha512-586.s", - rc4_asm_src => "rc4-586.s", - rmd160_asm_src => "rmd-586.s", - rc5_asm_src => "rc5-586.s", - wp_asm_src => "wp_block.c wp-mmx.s", - cmll_asm_src => "cmll-x86.s", - modes_asm_src => "ghash-x86.s", - padlock_asm_src => "e_padlock-x86.s", - chacha_asm_src => "chacha-x86.s", - poly1305_asm_src=> "poly1305-x86.s", - }, - x86_elf_asm => { - template => 1, - inherit_from => [ "x86_asm" ], - perlasm_scheme => "elf" - }, - x86_64_asm => { - template => 1, - cpuid_asm_src => "x86_64cpuid.s", - bn_asm_src => "asm/x86_64-gcc.c x86_64-mont.s x86_64-mont5.s x86_64-gf2m.s rsaz_exp.c rsaz-x86_64.s rsaz-avx2.s", - ec_asm_src => "ecp_nistz256.c ecp_nistz256-x86_64.s x25519-x86_64.s", - aes_asm_src => "aes-x86_64.s vpaes-x86_64.s bsaes-x86_64.s aesni-x86_64.s aesni-sha1-x86_64.s aesni-sha256-x86_64.s aesni-mb-x86_64.s", - md5_asm_src => "md5-x86_64.s", - sha1_asm_src => "sha1-x86_64.s sha256-x86_64.s sha512-x86_64.s sha1-mb-x86_64.s sha256-mb-x86_64.s", - rc4_asm_src => "rc4-x86_64.s rc4-md5-x86_64.s", - wp_asm_src => "wp-x86_64.s", - cmll_asm_src => "cmll-x86_64.s cmll_misc.c", - modes_asm_src => "ghash-x86_64.s aesni-gcm-x86_64.s", - padlock_asm_src => "e_padlock-x86_64.s", - chacha_asm_src => "chacha-x86_64.s", - poly1305_asm_src=> "poly1305-x86_64.s", - keccak1600_asm_src => "keccak1600-x86_64.s", - }, - ia64_asm => { - template => 1, - cpuid_asm_src => "ia64cpuid.s", - bn_asm_src => "bn-ia64.s ia64-mont.s", - aes_asm_src => "aes_core.c aes_cbc.c aes-ia64.s", - sha1_asm_src => "sha1-ia64.s sha256-ia64.s sha512-ia64.s", - modes_asm_src => "ghash-ia64.s", - chacha_asm_src => "chacha-ia64.S", - poly1305_asm_src=> "asm/poly1305-ia64.S", - perlasm_scheme => "void" - }, - sparcv9_asm => { - template => 1, - cpuid_asm_src => "sparcv9cap.c sparccpuid.S", - bn_asm_src => "asm/sparcv8plus.S sparcv9-mont.S sparcv9a-mont.S vis3-mont.S sparct4-mont.S sparcv9-gf2m.S", - ec_asm_src => "ecp_nistz256.c ecp_nistz256-sparcv9.S", - des_asm_src => "des_enc-sparc.S fcrypt_b.c dest4-sparcv9.S", - aes_asm_src => "aes_core.c aes_cbc.c aes-sparcv9.S aest4-sparcv9.S aesfx-sparcv9.S", - md5_asm_src => "md5-sparcv9.S", - sha1_asm_src => "sha1-sparcv9.S sha256-sparcv9.S sha512-sparcv9.S", - cmll_asm_src => "camellia.c cmll_misc.c cmll_cbc.c cmllt4-sparcv9.S", - modes_asm_src => "ghash-sparcv9.S", - poly1305_asm_src=> "poly1305-sparcv9.S", - perlasm_scheme => "void" - }, - sparcv8_asm => { - template => 1, - cpuid_asm_src => "", - bn_asm_src => "asm/sparcv8.S", - des_asm_src => "des_enc-sparc.S fcrypt_b.c", - perlasm_scheme => "void" - }, - alpha_asm => { - template => 1, - cpuid_asm_src => "alphacpuid.s", - bn_asm_src => "bn_asm.c alpha-mont.S", - sha1_asm_src => "sha1-alpha.S", - modes_asm_src => "ghash-alpha.S", - perlasm_scheme => "void" - }, - mips32_asm => { - template => 1, - bn_asm_src => "bn-mips.S mips-mont.S", - aes_asm_src => "aes_cbc.c aes-mips.S", - sha1_asm_src => "sha1-mips.S sha256-mips.S", - }, - mips64_asm => { - inherit_from => [ "mips32_asm" ], - template => 1, - sha1_asm_src => add("sha512-mips.S"), - poly1305_asm_src=> "poly1305-mips.S", - }, - s390x_asm => { - template => 1, - cpuid_asm_src => "s390xcap.c s390xcpuid.S", - bn_asm_src => "asm/s390x.S s390x-mont.S s390x-gf2m.s", - aes_asm_src => "aes-s390x.S aes-ctr.fake aes-xts.fake", - sha1_asm_src => "sha1-s390x.S sha256-s390x.S sha512-s390x.S", - rc4_asm_src => "rc4-s390x.s", - modes_asm_src => "ghash-s390x.S", - chacha_asm_src => "chacha-s390x.S", - poly1305_asm_src=> "poly1305-s390x.S", - keccak1600_asm_src => "keccak1600-s390x.S", - }, - armv4_asm => { - template => 1, - cpuid_asm_src => "armcap.c armv4cpuid.S", - bn_asm_src => "bn_asm.c armv4-mont.S armv4-gf2m.S", - ec_asm_src => "ecp_nistz256.c ecp_nistz256-armv4.S", - aes_asm_src => "aes_cbc.c aes-armv4.S bsaes-armv7.S aesv8-armx.S", - sha1_asm_src => "sha1-armv4-large.S sha256-armv4.S sha512-armv4.S", - modes_asm_src => "ghash-armv4.S ghashv8-armx.S", - chacha_asm_src => "chacha-armv4.S", - poly1305_asm_src=> "poly1305-armv4.S", - keccak1600_asm_src => "keccak1600-armv4.S", - perlasm_scheme => "void" - }, - aarch64_asm => { - template => 1, - cpuid_asm_src => "armcap.c arm64cpuid.S", - ec_asm_src => "ecp_nistz256.c ecp_nistz256-armv8.S", - bn_asm_src => "bn_asm.c armv8-mont.S", - aes_asm_src => "aes_core.c aes_cbc.c aesv8-armx.S vpaes-armv8.S", - sha1_asm_src => "sha1-armv8.S sha256-armv8.S sha512-armv8.S", - modes_asm_src => "ghashv8-armx.S", - chacha_asm_src => "chacha-armv8.S", - poly1305_asm_src=> "poly1305-armv8.S", - keccak1600_asm_src => "keccak1600-armv8.S", - }, - parisc11_asm => { - template => 1, - cpuid_asm_src => "pariscid.s", - bn_asm_src => "bn_asm.c parisc-mont.s", - aes_asm_src => "aes_core.c aes_cbc.c aes-parisc.s", - sha1_asm_src => "sha1-parisc.s sha256-parisc.s sha512-parisc.s", - rc4_asm_src => "rc4-parisc.s", - modes_asm_src => "ghash-parisc.s", - perlasm_scheme => "32" - }, - parisc20_64_asm => { - template => 1, - inherit_from => [ "parisc11_asm" ], - perlasm_scheme => "64", - }, - ppc32_asm => { - template => 1, - cpuid_asm_src => "ppccpuid.s ppccap.c", - bn_asm_src => "bn-ppc.s ppc-mont.s", - aes_asm_src => "aes_core.c aes_cbc.c aes-ppc.s vpaes-ppc.s aesp8-ppc.s", - sha1_asm_src => "sha1-ppc.s sha256-ppc.s sha512-ppc.s sha256p8-ppc.s sha512p8-ppc.s", - modes_asm_src => "ghashp8-ppc.s", - chacha_asm_src => "chacha-ppc.s", - poly1305_asm_src=> "poly1305-ppc.s poly1305-ppcfp.s", - }, - ppc64_asm => { - inherit_from => [ "ppc32_asm" ], - template => 1, - ec_asm_src => "ecp_nistz256.c ecp_nistz256-ppc64.s x25519-ppc64.s", - keccak1600_asm_src => "keccak1600-ppc64.s", - }, ); diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf index 27e587fb..9b08cf4f 100644 --- a/Configurations/10-main.conf +++ b/Configurations/10-main.conf @@ -221,7 +221,7 @@ my %targets = ( # NB. GNU C has to be configured to use GNU assembler, and not # /usr/ccs/bin/as. Failure to comply will result in compile # failures [at least] in 32-bit build. - inherit_from => [ "solaris-common", asm("x86_elf_asm") ], + inherit_from => [ "solaris-common" ], CC => "gcc", CFLAGS => add_before(picker(default => "-Wall", debug => "-O0 -g", @@ -232,6 +232,8 @@ my %targets = ( bn_ops => "BN_LLONG", shared_cflag => "-fPIC", shared_ldflag => add_before("-shared -static-libgcc"), + asm_arch => 'x86', + perlasm_scheme => 'elf', }, "solaris64-x86_64-gcc" => { # -shared -static-libgcc might appear controversial, but modules @@ -242,7 +244,7 @@ my %targets = ( # code [thanks to inline assembler], I would actually recommend # to consider using gcc shared build even with vendor compiler:-) # -- - inherit_from => [ "solaris-common", asm("x86_64_asm") ], + inherit_from => [ "solaris-common" ], CC => "gcc", CFLAGS => add_before(picker(default => "-Wall", debug => "-O0 -g", @@ -251,6 +253,7 @@ my %targets = ( lib_cppflags => add("-DL_ENDIAN"), ex_libs => add(threads("-pthread")), bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'x86_64', perlasm_scheme => "elf", shared_cflag => "-fPIC", shared_ldflag => add_before("-shared -static-libgcc"), @@ -271,7 +274,7 @@ my %targets = ( # Consider switching to solaris64-x86_64-gcc even here... # "solaris64-x86_64-cc" => { - inherit_from => [ "solaris-common", asm("x86_64_asm") ], + inherit_from => [ "solaris-common" ], CC => "cc", CFLAGS => add_before(picker(debug => "-g", release => "-xO5 -xdepend -xbuiltin")), @@ -282,6 +285,7 @@ my %targets = ( lflags => add(threads("-mt")), ex_libs => add(threads("-lpthread")), bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'x86_64', perlasm_scheme => "elf", shared_cflag => "-KPIC", shared_ldflag => add_before("-G -dy -z text"), @@ -303,14 +307,18 @@ my %targets = ( shared_ldflag => add_before("-shared"), }, "solaris-sparcv8-gcc" => { - inherit_from => [ "solaris-sparcv7-gcc", asm("sparcv8_asm") ], + inherit_from => [ "solaris-sparcv7-gcc" ], cflags => add_before("-mcpu=v8"), + asm_arch => 'sparcv8', + perlasm_scheme => 'void', }, "solaris-sparcv9-gcc" => { # -m32 should be safe to add as long as driver recognizes # -mcpu=ultrasparc - inherit_from => [ "solaris-sparcv7-gcc", asm("sparcv9_asm") ], + inherit_from => [ "solaris-sparcv7-gcc" ], cflags => add_before("-m32 -mcpu=ultrasparc"), + asm_arch => 'sparcv9', + perlasm_scheme => 'void', }, "solaris64-sparcv9-gcc" => { inherit_from => [ "solaris-sparcv9-gcc" ], @@ -339,17 +347,23 @@ my %targets = ( }, #### "solaris-sparcv8-cc" => { - inherit_from => [ "solaris-sparcv7-cc", asm("sparcv8_asm") ], + inherit_from => [ "solaris-sparcv7-cc" ], cflags => add_before("-xarch=v8"), + asm_arch => 'sparcv8', + perlasm_scheme => 'void', }, "solaris-sparcv9-cc" => { - inherit_from => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ], + inherit_from => [ "solaris-sparcv7-cc" ], cflags => add_before("-xarch=v8plus"), + asm_arch => 'sparcv9', + perlasm_scheme => 'void', }, "solaris64-sparcv9-cc" => { - inherit_from => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ], + inherit_from => [ "solaris-sparcv7-cc" ], cflags => add_before("-xarch=v9"), bn_ops => "BN_LLONG RC4_CHAR", + asm_arch => 'sparcv9', + perlasm_scheme => 'void', multilib => "/64", }, @@ -368,45 +382,49 @@ my %targets = ( shared_sonameflag=> "-Wl,-soname,", }, "irix-mips3-gcc" => { - inherit_from => [ "irix-common", asm("mips64_asm") ], + inherit_from => [ "irix-common" ], CC => "gcc", CFLAGS => picker(debug => "-g -O0", release => "-O3"), LDFLAGS => "-static-libgcc", cflags => "-mabi=n32", bn_ops => "RC4_CHAR SIXTY_FOUR_BIT", + asm_arch => 'mips64', perlasm_scheme => "n32", multilib => "32", }, "irix-mips3-cc" => { - inherit_from => [ "irix-common", asm("mips64_asm") ], + inherit_from => [ "irix-common" ], CC => "cc", CFLAGS => picker(debug => "-g -O0", release => "-O2"), cflags => "-n32 -mips3 -use_readonly_const -G0 -rdata_shared", bn_ops => "RC4_CHAR SIXTY_FOUR_BIT", + asm_arch => 'mips64', perlasm_scheme => "n32", multilib => "32", }, # N64 ABI builds. "irix64-mips4-gcc" => { - inherit_from => [ "irix-common", asm("mips64_asm") ], + inherit_from => [ "irix-common" ], CC => "gcc", CFLAGS => picker(debug => "-g -O0", release => "-O3"), LDFLAGS => "-static-libgcc", cflags => "-mabi=64 -mips4", bn_ops => "RC4_CHAR SIXTY_FOUR_BIT_LONG", + asm_arch => 'mips64', perlasm_scheme => "64", multilib => "64", }, "irix64-mips4-cc" => { - inherit_from => [ "irix-common", asm("mips64_asm") ], + inherit_from => [ "irix-common" ], CC => "cc", CFLAGS => picker(debug => "-g -O0", release => "-O2"), cflags => "-64 -mips4 -use_readonly_const -G0 -rdata_shared", bn_ops => "RC4_CHAR SIXTY_FOUR_BIT_LONG", + asm_arch => 'mips64', perlasm_scheme => "64", multilib => "64", }, @@ -466,17 +484,21 @@ my %targets = ( shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)", }, "hpux-parisc1_1-gcc" => { - inherit_from => [ "hpux-parisc-gcc", asm("parisc11_asm") ], + inherit_from => [ "hpux-parisc-gcc" ], + asm_arch => 'parisc11', + perlasm_scheme => "32", multilib => "/pa1.1", }, "hpux64-parisc2-gcc" => { - inherit_from => [ "hpux-common", asm("parisc20_64_asm") ], + inherit_from => [ "hpux-common" ], CC => "gcc", CFLAGS => combine(picker(debug => "-O0 -g", release => "-O3")), cflags => add(threads("-pthread")), ex_libs => add("-ldl", threads("-pthread")), bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", + asm_arch => 'parisc20_64', + perlasm_scheme => "64", shared_cflag => "-fpic", shared_ldflag => add_before("-shared"), shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)", @@ -500,12 +522,14 @@ my %targets = ( shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)", }, "hpux-parisc1_1-cc" => { - inherit_from => [ "hpux-parisc-cc", asm("parisc11_asm") ], + inherit_from => [ "hpux-parisc-cc" ], cflags => add_before("+DA1.1"), + asm_arch => 'parisc11', + perlasm_scheme => "32", multilib => "/pa1.1", }, "hpux64-parisc2-cc" => { - inherit_from => [ "hpux-common", asm("parisc20_64_asm") ], + inherit_from => [ "hpux-common" ], CC => "cc", CFLAGS => picker(debug => "+O0 +d -g", release => "+O3") , @@ -514,6 +538,8 @@ my %targets = ( lib_cppflags => add("-DMD32_XARRAY"), ex_libs => add("-ldl", threads("-lpthread")), bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", + asm_arch => 'parisc20_64', + perlasm_scheme => "64", shared_cflag => "+Z", shared_ldflag => add_before("-b"), shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)", @@ -522,7 +548,7 @@ my %targets = ( # HP/UX IA-64 targets "hpux-ia64-cc" => { - inherit_from => [ "hpux-common", asm("ia64_asm") ], + inherit_from => [ "hpux-common" ], CC => "cc", CFLAGS => picker(debug => "+O0 +d -g", release => "+O2"), @@ -530,12 +556,14 @@ my %targets = ( cppflags => add(threads("-D_REENTRANT")), ex_libs => add("-ldl", threads("-lpthread")), bn_ops => "SIXTY_FOUR_BIT", + asm_arch => 'ia64', + perlasm_scheme => 'void', shared_cflag => "+Z", shared_ldflag => add_before("-b"), multilib => "/hpux32", }, "hpux64-ia64-cc" => { - inherit_from => [ "hpux-common", asm("ia64_asm") ], + inherit_from => [ "hpux-common" ], CC => "cc", CFLAGS => picker(debug => "+O0 +d -g", release => "+O3"), @@ -543,31 +571,37 @@ my %targets = ( cppflags => threads("-D_REENTRANT"), ex_libs => add("-ldl", threads("-lpthread")), bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'ia64', + perlasm_scheme => 'void', shared_cflag => "+Z", shared_ldflag => add_before("-b"), multilib => "/hpux64", }, # GCC builds... "hpux-ia64-gcc" => { - inherit_from => [ "hpux-common", asm("ia64_asm") ], + inherit_from => [ "hpux-common" ], CC => "gcc", CFLAGS => picker(debug => "-O0 -g", release => "-O3"), cflags => add(threads("-pthread")), ex_libs => add("-ldl", threads("-pthread")), bn_ops => "SIXTY_FOUR_BIT", + asm_arch => 'ia64', + perlasm_scheme => 'void', shared_cflag => "-fpic", shared_ldflag => add_before("-shared"), multilib => "/hpux32", }, "hpux64-ia64-gcc" => { - inherit_from => [ "hpux-common", asm("ia64_asm") ], + inherit_from => [ "hpux-common" ], CC => "gcc", CFLAGS => picker(debug => "-O0 -g", release => "-O3"), cflags => combine("-mlp64", threads("-pthread")), ex_libs => add("-ldl", threads("-pthread")), bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'ia64', + perlasm_scheme => 'void', shared_cflag => "-fpic", shared_ldflag => add_before("-shared"), multilib => "/hpux64", @@ -593,20 +627,22 @@ my %targets = ( #### there were even osf1-* configs targeting prior versions provided, #### but not anymore... "tru64-alpha-gcc" => { - inherit_from => [ "BASE_unix", asm("alpha_asm") ], + inherit_from => [ "BASE_unix" ], CC => "gcc", CFLAGS => "-O3", cflags => add("-std=c9x", threads("-pthread")), cppflags => "-D_XOPEN_SOURCE=500 -D_OSF_SOURCE", ex_libs => add("-lrt", threads("-pthread")), # for mlock(2) bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'alpha', + perlasm_scheme => "void", thread_scheme => "pthreads", dso_scheme => "dlfcn", shared_target => "alpha-osf1-shared", shared_extension => ".so", }, "tru64-alpha-cc" => { - inherit_from => [ "BASE_unix", asm("alpha_asm") ], + inherit_from => [ "BASE_unix" ], CC => "cc", CFLAGS => "-tune host -fast", cflags => add("-std1 -readonly_strings", @@ -614,6 +650,8 @@ my %targets = ( cppflags => "-D_XOPEN_SOURCE=500 -D_OSF_SOURCE", ex_libs => add("-lrt", threads("-pthread")), # for mlock(2) bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'alpha', + perlasm_scheme => "void", thread_scheme => "pthreads", dso_scheme => "dlfcn", shared_target => "alpha-osf1-shared", @@ -654,22 +692,25 @@ my %targets = ( }, "linux-ppc" => { - inherit_from => [ "linux-generic32", asm("ppc32_asm") ], + inherit_from => [ "linux-generic32" ], + asm_arch => 'ppc32', perlasm_scheme => "linux32", }, "linux-ppc64" => { - inherit_from => [ "linux-generic64", asm("ppc64_asm") ], + inherit_from => [ "linux-generic64" ], cflags => add("-m64"), cxxflags => add("-m64"), lib_cppflags => add("-DB_ENDIAN"), + asm_arch => 'ppc64', perlasm_scheme => "linux64", multilib => "64", }, "linux-ppc64le" => { - inherit_from => [ "linux-generic64", asm("ppc64_asm") ], + inherit_from => [ "linux-generic64" ], cflags => add("-m64"), cxxflags => add("-m64"), lib_cppflags => add("-DL_ENDIAN"), + asm_arch => 'ppc64', perlasm_scheme => "linux64le", }, @@ -705,43 +746,49 @@ my %targets = ( # # ./Configure linux-armv4 -march=armv6 -D__ARM_MAX_ARCH__=8 # - inherit_from => [ "linux-generic32", asm("armv4_asm") ], + inherit_from => [ "linux-generic32" ], + asm_arch => 'armv4', perlasm_scheme => "linux32", }, "linux-aarch64" => { - inherit_from => [ "linux-generic64", asm("aarch64_asm") ], + inherit_from => [ "linux-generic64" ], + asm_arch => 'aarch64', perlasm_scheme => "linux64", }, "linux-arm64ilp32" => { # https://wiki.linaro.org/Platform/arm64-ilp32 - inherit_from => [ "linux-generic32", asm("aarch64_asm") ], + inherit_from => [ "linux-generic32" ], cflags => add("-mabi=ilp32"), cxxflags => add("-mabi=ilp32"), bn_ops => "SIXTY_FOUR_BIT RC4_CHAR", + asm_arch => 'aarch64', perlasm_scheme => "linux64", }, "linux-mips32" => { # Configure script adds minimally required -march for assembly # support, if no -march was specified at command line. - inherit_from => [ "linux-generic32", asm("mips32_asm") ], + inherit_from => [ "linux-generic32" ], cflags => add("-mabi=32"), cxxflags => add("-mabi=32"), + asm_arch => 'mips32', perlasm_scheme => "o32", }, # mips32 and mips64 below refer to contemporary MIPS Architecture # specifications, MIPS32 and MIPS64, rather than to kernel bitness. "linux-mips64" => { - inherit_from => [ "linux-generic32", asm("mips64_asm") ], + inherit_from => [ "linux-generic32" ], cflags => add("-mabi=n32"), cxxflags => add("-mabi=n32"), bn_ops => "SIXTY_FOUR_BIT RC4_CHAR", + asm_arch => 'mips64', perlasm_scheme => "n32", multilib => "32", }, "linux64-mips64" => { - inherit_from => [ "linux-generic64", asm("mips64_asm") ], + inherit_from => [ "linux-generic64" ], cflags => add("-mabi=64"), cxxflags => add("-mabi=64"), + asm_arch => 'mips64', perlasm_scheme => "64", multilib => "64", }, @@ -750,13 +797,15 @@ my %targets = ( #### These two targets are a bit aged and are to be used on older Linux #### machines where gcc doesn't understand -m32 and -m64 "linux-elf" => { - inherit_from => [ "linux-generic32", asm("x86_elf_asm") ], + inherit_from => [ "linux-generic32" ], CFLAGS => add(picker(release => "-fomit-frame-pointer")), lib_cppflags => add("-DL_ENDIAN"), bn_ops => "BN_LLONG", + asm_arch => 'x86', + perlasm_scheme => "elf", }, "linux-aout" => { - inherit_from => [ "BASE_unix", asm("x86_asm") ], + inherit_from => [ "BASE_unix" ], CC => "gcc", CFLAGS => add(picker(default => "-Wall", debug => "-O0 -g", @@ -764,17 +813,19 @@ my %targets = ( lib_cppflags => add("-DL_ENDIAN"), bn_ops => "BN_LLONG", thread_scheme => "(unknown)", + asm_arch => 'x86', perlasm_scheme => "a.out", }, #### X86 / X86_64 targets "linux-x86" => { - inherit_from => [ "linux-generic32", asm("x86_asm") ], + inherit_from => [ "linux-generic32" ], CFLAGS => add(picker(release => "-fomit-frame-pointer")), cflags => add("-m32"), cxxflags => add("-m32"), lib_cppflags => add("-DL_ENDIAN"), bn_ops => "BN_LLONG", + asm_arch => 'x86', perlasm_scheme => "elf", }, "linux-x86-clang" => { @@ -783,11 +834,12 @@ my %targets = ( CXX => "clang++", }, "linux-x86_64" => { - inherit_from => [ "linux-generic64", asm("x86_64_asm") ], + inherit_from => [ "linux-generic64" ], cflags => add("-m64"), cxxflags => add("-m64"), lib_cppflags => add("-DL_ENDIAN"), bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'x86_64', perlasm_scheme => "elf", multilib => "64", }, @@ -797,25 +849,29 @@ my %targets = ( CXX => "clang++", }, "linux-x32" => { - inherit_from => [ "linux-generic32", asm("x86_64_asm") ], + inherit_from => [ "linux-generic32" ], cflags => add("-mx32"), cxxflags => add("-mx32"), lib_cppflags => add("-DL_ENDIAN"), bn_ops => "SIXTY_FOUR_BIT", + asm_arch => 'x86_64', perlasm_scheme => "elf32", multilib => "x32", }, "linux-ia64" => { - inherit_from => [ "linux-generic64", asm("ia64_asm") ], + inherit_from => [ "linux-generic64" ], bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'ia64', + perlasm_scheme => 'void', }, "linux64-s390x" => { - inherit_from => [ "linux-generic64", asm("s390x_asm") ], + inherit_from => [ "linux-generic64" ], cflags => add("-m64"), cxxflags => add("-m64"), lib_cppflags => add("-DB_ENDIAN"), + asm_arch => 's390x', perlasm_scheme => "64", multilib => "64", }, @@ -836,44 +892,52 @@ my %targets = ( # yet, because of couple of bugs in glibc # sysdeps/s390/dl-procinfo.c affecting ldconfig and ld.so.1... # - inherit_from => [ "linux-generic32", asm("s390x_asm") ], + inherit_from => [ "linux-generic32" ], cflags => add("-m31 -Wa,-mzarch"), cxxflags => add("-m31 -Wa,-mzarch"), lib_cppflags => add("-DB_ENDIAN"), - bn_asm_src => sub { my $r=join(" ",@_); $r=~s|asm/s390x\.S|bn_asm.c|; $r; }, + asm_arch => 's390x', perlasm_scheme => "31", multilib => "/highgprs", }, #### SPARC Linux setups "linux-sparcv8" => { - inherit_from => [ "linux-generic32", asm("sparcv8_asm") ], + inherit_from => [ "linux-generic32" ], cflags => add("-mcpu=v8"), cxxflags => add("-mcpu=v8"), lib_cppflags => add("-DB_ENDIAN -DBN_DIV2W"), + asm_arch => 'sparcv8', + perlasm_scheme => 'void', }, "linux-sparcv9" => { # it's a real mess with -mcpu=ultrasparc option under Linux, # but -Wa,-Av8plus should do the trick no matter what. - inherit_from => [ "linux-generic32", asm("sparcv9_asm") ], + inherit_from => [ "linux-generic32" ], cflags => add("-m32 -mcpu=ultrasparc -Wa,-Av8plus"), cxxflags => add("-m32 -mcpu=ultrasparc -Wa,-Av8plus"), lib_cppflags => add("-DB_ENDIAN -DBN_DIV2W"), + asm_arch => 'sparcv9', + perlasm_scheme => 'void', }, "linux64-sparcv9" => { # GCC 3.1 is a requirement - inherit_from => [ "linux-generic64", asm("sparcv9_asm") ], + inherit_from => [ "linux-generic64" ], cflags => add("-m64 -mcpu=ultrasparc"), cxxflags => add("-m64 -mcpu=ultrasparc"), lib_cppflags => add("-DB_ENDIAN"), bn_ops => "BN_LLONG RC4_CHAR", + asm_arch => 'sparcv9', + perlasm_scheme => 'void', multilib => "64", }, "linux-alpha-gcc" => { - inherit_from => [ "linux-generic64", asm("alpha_asm") ], + inherit_from => [ "linux-generic64" ], lib_cppflags => add("-DL_ENDIAN"), bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'alpha', + perlasm_scheme => "void", }, "linux-c64xplus" => { inherit_from => [ "BASE_unix" ], @@ -885,15 +949,8 @@ my %targets = ( cppflags => combine("-DOPENSSL_SMALL_FOOTPRINT", threads("-D_REENTRANT")), bn_ops => "BN_LLONG", - cpuid_asm_src => "c64xpluscpuid.s", - bn_asm_src => "asm/bn-c64xplus.asm c64xplus-gf2m.s", - aes_asm_src => "aes-c64xplus.s aes_cbc.c aes-ctr.fake", - sha1_asm_src => "sha1-c64xplus.s sha256-c64xplus.s sha512-c64xplus.s", - rc4_asm_src => "rc4-c64xplus.s", - modes_asm_src => "ghash-c64xplus.s", - chacha_asm_src => "chacha-c64xplus.s", - poly1305_asm_src => "poly1305-c64xplus.s", thread_scheme => "pthreads", + asm_arch => 'c64xplus', perlasm_scheme => "void", dso_scheme => "dlfcn", shared_target => "linux-shared", @@ -932,11 +989,12 @@ my %targets = ( }, "BSD-x86" => { - inherit_from => [ "BSD-generic32", asm("x86_asm") ], + inherit_from => [ "BSD-generic32" ], CFLAGS => add(picker(release => "-fomit-frame-pointer")), lib_cppflags => add("-DL_ENDIAN"), bn_ops => "BN_LLONG", shared_target => "bsd-shared", + asm_arch => 'x86', perlasm_scheme => "a.out", }, "BSD-x86-elf" => { @@ -945,62 +1003,54 @@ my %targets = ( }, "BSD-sparcv8" => { - inherit_from => [ "BSD-generic32", asm("sparcv8_asm") ], + inherit_from => [ "BSD-generic32" ], cflags => add("-mcpu=v8"), lib_cppflags => add("-DB_ENDIAN"), + asm_arch => 'sparcv8', + perlasm_scheme => 'void', }, "BSD-sparc64" => { # -DMD32_REG_T=int doesn't actually belong in sparc64 target, it # simply *happens* to work around a compiler bug in gcc 3.3.3, # triggered by RIPEMD160 code. - inherit_from => [ "BSD-generic64", asm("sparcv9_asm") ], + inherit_from => [ "BSD-generic64" ], lib_cppflags => add("-DB_ENDIAN -DMD32_REG_T=int"), bn_ops => "BN_LLONG", + asm_arch => 'sparcv9', + perlasm_scheme => 'void', }, "BSD-ia64" => { - inherit_from => [ "BSD-generic64", asm("ia64_asm") ], + inherit_from => [ "BSD-generic64" ], lib_cppflags => add("-DL_ENDIAN"), bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'ia64', + perlasm_scheme => 'void', }, "BSD-x86_64" => { - inherit_from => [ "BSD-generic64", asm("x86_64_asm") ], + inherit_from => [ "BSD-generic64" ], lib_cppflags => add("-DL_ENDIAN"), bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'x86_64', perlasm_scheme => "elf", }, "bsdi-elf-gcc" => { - inherit_from => [ "BASE_unix", asm("x86_elf_asm") ], + inherit_from => [ "BASE_unix" ], CC => "gcc", CFLAGS => "-fomit-frame-pointer -O3 -Wall", lib_cppflags => "-DPERL5 -DL_ENDIAN", ex_libs => add("-ldl"), bn_ops => "BN_LLONG", + asm_arch => 'x86', + perlasm_scheme => "elf", thread_scheme => "(unknown)", dso_scheme => "dlfcn", shared_target => "bsd-gcc-shared", shared_cflag => "-fPIC", }, - "nextstep" => { - inherit_from => [ "BASE_unix" ], - CC => "cc", - CFLAGS => "-O -Wall", - unistd => "", - bn_ops => "BN_LLONG", - thread_scheme => "(unknown)", - }, - "nextstep3.3" => { - inherit_from => [ "BASE_unix" ], - CC => "cc", - CFLAGS => "-O3 -Wall", - unistd => "", - bn_ops => "BN_LLONG", - thread_scheme => "(unknown)", - }, - #### SCO/Caldera targets. # # Originally we had like unixware-*, unixware-*-pentium, unixware-*-p6, etc. @@ -1030,7 +1080,7 @@ my %targets = ( thread_scheme => "uithreads", }, "unixware-7" => { - inherit_from => [ "BASE_unix", asm("x86_elf_asm") ], + inherit_from => [ "BASE_unix" ], CC => "cc", CFLAGS => "-O", cflags => combine("-Kalloca", threads("-Kthread")), @@ -1038,13 +1088,14 @@ my %targets = ( ex_libs => add("-lsocket -lnsl"), thread_scheme => "uithreads", bn_ops => "BN_LLONG", + asm_arch => 'x86', perlasm_scheme => "elf-1", dso_scheme => "dlfcn", shared_target => "svr5-shared", shared_cflag => "-Kpic", }, "unixware-7-gcc" => { - inherit_from => [ "BASE_unix", asm("x86_elf_asm") ], + inherit_from => [ "BASE_unix" ], CC => "gcc", CFLAGS => "-O3 -fomit-frame-pointer -Wall", cppflags => add(threads("-D_REENTRANT")), @@ -1052,6 +1103,7 @@ my %targets = ( ex_libs => add("-lsocket -lnsl"), bn_ops => "BN_LLONG", thread_scheme => "pthreads", + asm_arch => 'x86', perlasm_scheme => "elf-1", dso_scheme => "dlfcn", shared_target => "gnu-shared", @@ -1059,23 +1111,25 @@ my %targets = ( }, # SCO 5 - Ben Laurie says the -O breaks the SCO cc. "sco5-cc" => { - inherit_from => [ "BASE_unix", asm("x86_elf_asm") ], + inherit_from => [ "BASE_unix" ], cc => "cc", cflags => "-belf", ex_libs => add("-lsocket -lnsl"), thread_scheme => "(unknown)", + asm_arch => 'x86', perlasm_scheme => "elf-1", dso_scheme => "dlfcn", shared_target => "svr3-shared", shared_cflag => "-Kpic", }, "sco5-gcc" => { - inherit_from => [ "BASE_unix", asm("x86_elf_asm") ], + inherit_from => [ "BASE_unix" ], cc => "gcc", cflags => "-O3 -fomit-frame-pointer", ex_libs => add("-lsocket -lnsl"), bn_ops => "BN_LLONG", thread_scheme => "(unknown)", + asm_arch => 'x86', perlasm_scheme => "elf-1", dso_scheme => "dlfcn", shared_target => "svr3-shared", @@ -1097,32 +1151,34 @@ my %targets = ( thread_scheme => "pthreads", dso_scheme => "dlfcn", shared_target => "aix", - module_ldflags => "-Wl,-G,-bsymbolic,-bexpall", + module_ldflags => "-Wl,-G,-bsymbolic,-bnoentry", shared_ldflag => "-Wl,-G,-bsymbolic,-bnoentry", shared_defflag => "-Wl,-bE:", perl_platform => 'AIX', }, "aix-gcc" => { - inherit_from => [ "aix-common", asm("ppc32_asm") ], + inherit_from => [ "aix-common" ], CC => "gcc", CFLAGS => picker(debug => "-O0 -g", release => "-O"), cflags => add(threads("-pthread")), ex_libs => threads("-pthread"), bn_ops => "BN_LLONG RC4_CHAR", + asm_arch => 'ppc32', perlasm_scheme => "aix32", shared_ldflag => add_before("-shared -static-libgcc"), AR => add("-X32"), RANLIB => add("-X32"), }, "aix64-gcc" => { - inherit_from => [ "aix-common", asm("ppc64_asm") ], + inherit_from => [ "aix-common" ], CC => "gcc", CFLAGS => picker(debug => "-O0 -g", release => "-O"), cflags => combine("-maix64", threads("-pthread")), ex_libs => threads("-pthread"), bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", + asm_arch => 'ppc64', perlasm_scheme => "aix64", shared_ldflag => add_before("-shared -static-libgcc"), shared_extension => "64.so.\$(SHLIB_VERSION_NUMBER)", @@ -1130,7 +1186,7 @@ my %targets = ( RANLIB => add("-X64"), }, "aix-cc" => { - inherit_from => [ "aix-common", asm("ppc32_asm") ], + inherit_from => [ "aix-common" ], CC => "cc", CFLAGS => picker(debug => "-O0 -g", release => "-O"), @@ -1139,13 +1195,14 @@ my %targets = ( cppflags => threads("-D_THREAD_SAFE"), ex_libs => threads("-lpthreads"), bn_ops => "BN_LLONG RC4_CHAR", + asm_arch => 'ppc32', perlasm_scheme => "aix32", shared_cflag => "-qpic", AR => add("-X32"), RANLIB => add("-X32"), }, "aix64-cc" => { - inherit_from => [ "aix-common", asm("ppc64_asm") ], + inherit_from => [ "aix-common" ], CC => "cc", CFLAGS => picker(debug => "-O0 -g", release => "-O"), @@ -1154,6 +1211,7 @@ my %targets = ( cppflags => threads("-D_THREAD_SAFE"), ex_libs => threads("-lpthreads"), bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", + asm_arch => 'ppc64', perlasm_scheme => "aix64", dso_scheme => "dlfcn", shared_cflag => "-qpic", @@ -1216,8 +1274,6 @@ my %targets = ( shared_target => "win-shared", # meaningless except it gives Configure a hint thread_scheme => "winthreads", dso_scheme => "win32", - apps_aux_src => add("win32_init.c"), - bn_ops => "EXPORT_VAR_AS_FN", perl_platform => 'Windows::MSVC', # additional parameter to build_scheme denotes install-path "flavour" build_scheme => add("VC-common", { separator => undef }), @@ -1272,33 +1328,30 @@ my %targets = ( bn_ops => add("SIXTY_FOUR_BIT"), }, "VC-WIN64I" => { - inherit_from => [ "VC-WIN64-common", asm("ia64_asm"), - sub { $disabled{shared} ? () : "ia64_uplink" } ], + inherit_from => [ "VC-WIN64-common" ], AS => "ias", ASFLAGS => "-d debug", asoutflag => "-o ", sys_id => "WIN64I", - bn_asm_src => sub { return undef unless @_; - my $r=join(" ",@_); $r=~s|bn-ia64.s|bn_asm.c|; $r; }, + uplink_arch => 'ia64', + asm_arch => 'ia64', perlasm_scheme => "ias", multilib => "-ia64", }, "VC-WIN64A" => { - inherit_from => [ "VC-WIN64-common", asm("x86_64_asm"), - sub { $disabled{shared} ? () : "x86_64_uplink" } ], + inherit_from => [ "VC-WIN64-common" ], AS => sub { vc_win64a_info()->{AS} }, ASFLAGS => sub { vc_win64a_info()->{ASFLAGS} }, asoutflag => sub { vc_win64a_info()->{asoutflag} }, asflags => sub { vc_win64a_info()->{asflags} }, sys_id => "WIN64A", - bn_asm_src => sub { return undef unless @_; - my $r=join(" ",@_); $r=~s|asm/x86_64-gcc|bn_asm|; $r; }, + uplink_arch => 'x86_64', + asm_arch => 'x86_64', perlasm_scheme => "auto", multilib => "-x64", }, "VC-WIN32" => { - inherit_from => [ "VC-noCE-common", asm("x86_asm"), - sub { $disabled{shared} ? () : "uplink_common" } ], + inherit_from => [ "VC-noCE-common" ], CFLAGS => add("/WX"), AS => sub { vc_win32_info()->{AS} }, ASFLAGS => sub { vc_win32_info()->{ASFLAGS} }, @@ -1306,6 +1359,8 @@ my %targets = ( asflags => sub { vc_win32_info()->{asflags} }, sys_id => "WIN32", bn_ops => add("BN_LLONG"), + uplink_arch => 'common', + asm_arch => 'x86', perlasm_scheme => sub { vc_win32_info()->{perlasm_scheme} }, # "WOW" stands for "Windows on Windows", and "VC-WOW" engages # some installation path heuristics in windows-makefile.tmpl... @@ -1370,40 +1425,41 @@ my %targets = ( threads("-D_MT")), lib_cppflags => "-DL_ENDIAN", ex_libs => add("-lws2_32 -lgdi32 -lcrypt32"), - bn_ops => "EXPORT_VAR_AS_FN", thread_scheme => "winthreads", dso_scheme => "win32", shared_target => "mingw-shared", shared_cppflags => add("_WINDLL"), shared_ldflag => "-static-libgcc", - apps_aux_src => add("win32_init.c"), perl_platform => 'mingw', }, "mingw" => { - inherit_from => [ "mingw-common", asm("x86_asm"), - sub { $disabled{shared} ? () : "x86_uplink" } ], + inherit_from => [ "mingw-common" ], CFLAGS => add(picker(release => "-fomit-frame-pointer")), cflags => "-m32", sys_id => "MINGW32", bn_ops => add("BN_LLONG"), + asm_arch => 'x86', + uplink_arch => 'x86', perlasm_scheme => "coff", shared_rcflag => "--target=pe-i386", multilib => "", }, "mingw64" => { - # As for OPENSSL_USE_APPLINK. Applink makes it possible to use + # As for uplink_arch. Applink makes it possible to use # .dll compiled with one compiler with application compiled with # another compiler. It's possible to engage Applink support in - # mingw64 build, but it's not done, because till mingw64 + # mingw64 build, but it's not done, because until mingw64 # supports structured exception handling, one can't seriously # consider its binaries for using with non-mingw64 run-time # environment. And as mingw64 is always consistent with itself, # Applink is never engaged and can as well be omitted. - inherit_from => [ "mingw-common", asm("x86_64_asm") ], + inherit_from => [ "mingw-common" ], cflags => "-m64", sys_id => "MINGW64", bn_ops => add("SIXTY_FOUR_BIT"), + asm_arch => 'x86_64', + uplink_arch => undef, perlasm_scheme => "mingw64", shared_rcflag => "--target=pe-x86-64", multilib => "64", @@ -1448,15 +1504,17 @@ my %targets = ( perl_platform => 'Cygwin', }, "Cygwin-x86" => { - inherit_from => [ "Cygwin-common", asm("x86_asm") ], + inherit_from => [ "Cygwin-common" ], CFLAGS => add(picker(release => "-O3 -fomit-frame-pointer")), bn_ops => "BN_LLONG", + asm_arch => 'x86', perlasm_scheme => "coff", }, "Cygwin-x86_64" => { - inherit_from => [ "Cygwin-common", asm("x86_64_asm") ], + inherit_from => [ "Cygwin-common" ], CC => "gcc", bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'x86_64', perlasm_scheme => "mingw64", }, # Backward compatibility for those using this target @@ -1500,46 +1558,51 @@ my %targets = ( # with future defaults for below two targets, because MacOS X # for PPC has no future, it was discontinued by vendor in 2009. "darwin-ppc-cc" => { - inherit_from => [ "darwin-common", asm("ppc32_asm") ], + inherit_from => [ "darwin-common" ], cflags => add("-arch ppc -std=gnu9x -Wa,-force_cpusubtype_ALL"), lib_cppflags => add("-DB_ENDIAN"), shared_cflag => add("-fno-common"), + asm_arch => 'ppc32', perlasm_scheme => "osx32", }, "darwin64-ppc-cc" => { - inherit_from => [ "darwin-common", asm("ppc64_asm") ], + inherit_from => [ "darwin-common" ], cflags => add("-arch ppc64 -std=gnu9x"), lib_cppflags => add("-DB_ENDIAN"), bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", + asm_arch => 'ppc64', perlasm_scheme => "osx64", }, "darwin-i386-cc" => { - inherit_from => [ "darwin-common", asm("x86_asm") ], + inherit_from => [ "darwin-common" ], CFLAGS => add(picker(release => "-fomit-frame-pointer")), cflags => add("-arch i386"), lib_cppflags => add("-DL_ENDIAN"), bn_ops => "BN_LLONG RC4_INT", + asm_arch => 'x86', perlasm_scheme => "macosx", }, "darwin64-x86_64-cc" => { - inherit_from => [ "darwin-common", asm("x86_64_asm") ], + inherit_from => [ "darwin-common" ], CFLAGS => add("-Wall"), cflags => add("-arch x86_64"), lib_cppflags => add("-DL_ENDIAN"), bn_ops => "SIXTY_FOUR_BIT_LONG", + asm_arch => 'x86_64', perlasm_scheme => "macosx", }, ##### GNU Hurd "hurd-x86" => { inherit_from => [ "BASE_unix" ], - inherit_from => [ asm("x86_elf_asm") ], CC => "gcc", CFLAGS => "-O3 -fomit-frame-pointer -Wall", cflags => threads("-pthread"), lib_cppflags => "-DL_ENDIAN", ex_libs => add("-ldl", threads("-pthread")), bn_ops => "BN_LLONG", + asm_arch => 'x86', + perlasm_scheme => 'elf', thread_scheme => "pthreads", dso_scheme => "dlfcn", shared_target => "linux-shared", @@ -1629,7 +1692,7 @@ my %targets = ( ranlib => "ranlibpentium", }, "vxworks-mips" => { - inherit_from => [ "BASE_unix", asm("mips32_asm") ], + inherit_from => [ "BASE_unix" ], CC => "ccmips", CFLAGS => "-O -G 0", cflags => "-mrtp -mips2 -B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -msoft-float -mno-branch-likely -fno-builtin -fno-defer-pop", @@ -1644,6 +1707,7 @@ my %targets = ( lflags => add("-L \$(WIND_BASE)/target/usr/lib/mips/MIPSI32/sfcommon"), ex_libs => add("-Wl,--defsym,__wrs_rtp_base=0xe0000000"), thread_scheme => "pthreads", + asm_arch => 'mips32', perlasm_scheme => "o32", ranlib => "ranlibmips", }, @@ -1725,8 +1789,6 @@ my %targets = ( disable => add('pinshared'), - apps_aux_src => "vms_term_sock.c vms_decc_argv.c", - apps_init_src => "vms_decc_init.c", }, # From HELP CC/POINTER_SIZE: @@ -1759,13 +1821,12 @@ my %targets = ( pointer_size => "64", }, "vms-ia64" => { - inherit_from => [ "vms-generic", - sub { vms_info()->{AS} - ? asm("ia64_asm")->() : () } ], + inherit_from => [ "vms-generic" ], bn_ops => "SIXTY_FOUR_BIT RC4_INT", + asm_arch => sub { vms_info()->{AS} ? 'ia64' : undef }, + perlasm_scheme => 'ias', pointer_size => "", - modes_asm_src => "", # Because ghash-ia64.s doesn't work on VMS }, "vms-ia64-p32" => { inherit_from => [ "vms-ia64" ], diff --git a/Configurations/15-android.conf b/Configurations/15-android.conf index 7b496a45..69c3693d 100644 --- a/Configurations/15-android.conf +++ b/Configurations/15-android.conf @@ -199,18 +199,22 @@ my %targets = ( # -march and/or -mfloat-abi flags. NDK defaults to armv5te. # Newer NDK versions reportedly require additional -latomic. # - inherit_from => [ "android", asm("armv4_asm") ], + inherit_from => [ "android" ], bn_ops => add("RC4_CHAR"), + asm_arch => 'armv4', + perlasm_scheme => "void", }, "android-arm64" => { - inherit_from => [ "android", asm("aarch64_asm") ], + inherit_from => [ "android" ], bn_ops => add("RC4_CHAR"), + asm_arch => 'aarch64', perlasm_scheme => "linux64", }, "android-mips" => { - inherit_from => [ "android", asm("mips32_asm") ], + inherit_from => [ "android" ], bn_ops => add("RC4_CHAR"), + asm_arch => 'mips32', perlasm_scheme => "o32", }, "android-mips64" => { @@ -223,20 +227,23 @@ my %targets = ( # with previous MIPS ISA versions, in sense that unlike # prior versions original MIPS binary code will fail. # - inherit_from => [ "android", asm("mips64_asm") ], + inherit_from => [ "android" ], bn_ops => add("RC4_CHAR"), + asm_arch => 'mips64', perlasm_scheme => "64", }, "android-x86" => { - inherit_from => [ "android", asm("x86_asm") ], + inherit_from => [ "android" ], CFLAGS => add(picker(release => "-fomit-frame-pointer")), bn_ops => add("RC4_INT"), + asm_arch => 'x86', perlasm_scheme => "android", }, "android-x86_64" => { - inherit_from => [ "android", asm("x86_64_asm") ], + inherit_from => [ "android" ], bn_ops => add("RC4_INT"), + asm_arch => 'x86_64', perlasm_scheme => "elf", }, diff --git a/Configurations/15-ios.conf b/Configurations/15-ios.conf index 1bb9f48d..4b5aeecc 100644 --- a/Configurations/15-ios.conf +++ b/Configurations/15-ios.conf @@ -1,6 +1,6 @@ #### iPhoneOS/iOS # -# It takes recent enough XCode to use following two targets. It shouldn't +# It takes recent enough Xcode to use following two targets. It shouldn't # be a problem by now, but if they don't work, original targets below # that depend on manual definition of environment variables should still # work... @@ -13,19 +13,21 @@ my %targets = ( disable => [ "engine", "async" ], }, "ios-xcrun" => { - inherit_from => [ "ios-common", asm("armv4_asm") ], + inherit_from => [ "ios-common" ], # It should be possible to go below iOS 6 and even add -arch armv6, # thus targeting iPhone pre-3GS, but it's assumed to be irrelevant # at this point. CC => "xcrun -sdk iphoneos cc", cflags => add("-arch armv7 -mios-version-min=6.0.0 -fno-common"), + asm_arch => 'armv4', perlasm_scheme => "ios32", }, "ios64-xcrun" => { - inherit_from => [ "ios-common", asm("aarch64_asm") ], + inherit_from => [ "ios-common" ], CC => "xcrun -sdk iphoneos cc", cflags => add("-arch arm64 -mios-version-min=7.0.0 -fno-common"), bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", + asm_arch => 'aarch64', perlasm_scheme => "ios64", }, "iossimulator-xcrun" => { diff --git a/Configurations/50-djgpp.conf b/Configurations/50-djgpp.conf index a8853a81..16888924 100644 --- a/Configurations/50-djgpp.conf +++ b/Configurations/50-djgpp.conf @@ -4,7 +4,6 @@ my %targets = ( "DJGPP" => { - inherit_from => [ asm("x86_asm") ], CC => "gcc", CFLAGS => "-fomit-frame-pointer -O2 -Wall", cflags => "-I/dev/env/WATT_ROOT/inc -DTERMIOS -DL_ENDIAN", @@ -12,6 +11,7 @@ my %targets = ( lflags => add("-L/dev/env/WATT_ROOT/lib"), ex_libs => add("-lwatt"), bn_ops => "BN_LLONG", + asm_arch => 'x86', perlasm_scheme => "a.out", }, ); diff --git a/Configurations/50-haiku.conf b/Configurations/50-haiku.conf index 5bc4db5f..d37ab83a 100644 --- a/Configurations/50-haiku.conf +++ b/Configurations/50-haiku.conf @@ -18,9 +18,11 @@ my %targets = ( perl_platform => 'Unix', }, "haiku-x86" => { - inherit_from => [ "haiku-common", asm("x86_elf_asm") ], + inherit_from => [ "haiku-common" ], CFLAGS => add(picker(release => "-fomit-frame-pointer")), bn_ops => "BN_LLONG", + asm_arch => 'x86', + perlasm_scheme => 'elf', }, "haiku-x86_64" => { inherit_from => [ "haiku-common" ], diff --git a/Configurations/50-masm.conf b/Configurations/50-masm.conf index 2c55dddc..587a1e70 100644 --- a/Configurations/50-masm.conf +++ b/Configurations/50-masm.conf @@ -9,15 +9,14 @@ my %targets = ( "VC-WIN64A-masm" => { - inherit_from => [ "VC-WIN64-common", asm("x86_64_asm"), - sub { $disabled{shared} ? () : "x86_64_uplink" } ], + inherit_from => [ "VC-WIN64-common" ], AS => "ml64", ASFLAGS => "/nologo /Zi", asoutflag => "/Fo", asflags => "/c /Cp /Cx", sys_id => "WIN64A", - bn_asm_src => sub { return undef unless @_; - my $r=join(" ",@_); $r=~s|asm/x86_64-gcc|bn_asm|; $r; }, + uplink_arch => 'x86_64', + asm_arch => 'x86_64', perlasm_scheme => "masm", }, ); diff --git a/Configurations/50-win-onecore.conf b/Configurations/50-win-onecore.conf index 51cb3819..d4e6e64f 100644 --- a/Configurations/50-win-onecore.conf +++ b/Configurations/50-win-onecore.conf @@ -1,6 +1,6 @@ # Windows OneCore targets. # -# OneCore is new API stability "contract" that transends Desktop, IoT and +# OneCore is new API stability "contract" that transcends Desktop, IoT and # Mobile[?] Windows editions. It's a set up "umbrella" libraries that # export subset of Win32 API that are common to all Windows 10 devices. # @@ -47,7 +47,7 @@ my %targets = ( inherit_from => [ "VC-noCE-common" ], defines => add("_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE", "OPENSSL_SYS_WIN_CORE"), - bn_ops => "BN_LLONG RC4_CHAR EXPORT_VAR_AS_FN", + bn_ops => "BN_LLONG RC4_CHAR", lflags => add("/NODEFAULTLIB:kernel32.lib"), ex_libs => "onecore.lib", multilib => "-arm", @@ -56,9 +56,58 @@ my %targets = ( inherit_from => [ "VC-noCE-common" ], defines => add("_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE", "OPENSSL_SYS_WIN_CORE"), - bn_ops => "SIXTY_FOUR_BIT RC4_CHAR EXPORT_VAR_AS_FN", + bn_ops => "SIXTY_FOUR_BIT RC4_CHAR", lflags => add("/NODEFAULTLIB:kernel32.lib"), ex_libs => "onecore.lib", multilib => "-arm64", }, + + # Universal Windows Platform (UWP) App Support + + # TODO + # + # The 'disable' attribute should have 'uplink'. + # however, these are checked in some 'inherit_from', which is processed + # very early, before the 'disable' attributes are seen. + # This is a problem that needs to be resolved in Configure first. + # + # But if you want to build library with Windows 10 Version 1809 SDK or + # earlier, the 'disable' attribute should also have 'asm'. + + "VC-WIN32-UWP" => { + inherit_from => [ "VC-WIN32-ONECORE" ], + lflags => add("/APPCONTAINER"), + defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP", + "_WIN32_WINNT=0x0A00"), + dso_scheme => "", + disable => [ 'ui-console', 'stdio', 'async', 'uplink' ], + ex_libs => "WindowsApp.lib", + }, + "VC-WIN64A-UWP" => { + inherit_from => [ "VC-WIN64A-ONECORE" ], + lflags => add("/APPCONTAINER"), + defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP", + "_WIN32_WINNT=0x0A00"), + dso_scheme => "", + disable => [ 'ui-console', 'stdio', 'async', 'uplink' ], + ex_libs => "WindowsApp.lib", + }, + "VC-WIN32-ARM-UWP" => { + inherit_from => [ "VC-WIN32-ARM" ], + lflags => add("/APPCONTAINER"), + defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP", + "_WIN32_WINNT=0x0A00"), + dso_scheme => "", + disable => [ 'ui-console', 'stdio', 'async', 'uplink' ], + ex_libs => "WindowsApp.lib", + }, + "VC-WIN64-ARM-UWP" => { + inherit_from => [ "VC-WIN64-ARM" ], + lflags => add("/APPCONTAINER"), + defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP", + "_WIN32_WINNT=0x0A00"), + dso_scheme => "", + disable => [ 'ui-console', 'stdio', 'async', 'uplink' ], + ex_libs => "WindowsApp.lib", + }, ); diff --git a/Configurations/90-team.norelease.conf b/Configurations/90-team.norelease.conf index 6ead6104..8ad05a6c 100644 --- a/Configurations/90-team.norelease.conf +++ b/Configurations/90-team.norelease.conf @@ -24,6 +24,7 @@ my %targets = ( ex_libs => add(" ","-ldl"), bn_ops => "SIXTY_FOUR_BIT_LONG", thread_scheme => "pthreads", + asm_arch => 'x86_64', perlasm_scheme => "elf", dso_scheme => "dlfcn", shared_target => "linux-shared", @@ -38,6 +39,8 @@ my %targets = ( threads("-D_REENTRANT")), ex_libs => add(" ","-ldl"), bn_ops => "BN_LLONG", + asm_arch => 'x86', + perlasm_scheme => 'elf', thread_scheme => "pthreads", dso_scheme => "dlfcn", }, @@ -48,44 +51,20 @@ my %targets = ( threads("-D_REENTRANT")), ex_libs => add(" ","-ldl"), bn_ops => "BN_LLONG", + asm_arch => 'x86', + perlasm_scheme => 'elf', thread_scheme => "pthreads", dso_scheme => "dlfcn", }, - "debug-linux-ia32-aes" => { - inherit_from => [ 'BASE_unix' ], - cc => "gcc", - cflags => combine("-DL_ENDIAN -O3 -fomit-frame-pointer -Wall", - threads("-D_REENTRANT")), - ex_libs => add(" ","-ldl"), - bn_ops => "BN_LLONG", - cpuid_asm_src => "x86cpuid.s", - bn_asm_src => "bn-586.s co-586.s x86-mont.s", - des_asm_src => "des-586.s crypt586.s", - aes_asm_src => "aes_x86core.s aes_cbc.s aesni-x86.s", - bf_asm_src => "bf-586.s", - md5_asm_src => "md5-586.s", - sha1_asm_src => "sha1-586.s sha256-586.s sha512-586.s", - cast_asm_src => "cast-586.s", - rc4_asm_src => "rc4-586.s", - rmd160_asm_src => "rmd-586.s", - rc5_asm_src => "rc5-586.s", - wp_asm_src => "wp_block.s wp-mmx.s", - modes_asm_src => "ghash-x86.s", - padlock_asm_src => "e_padlock-x86.s", - thread_scheme => "pthreads", - perlasm_scheme => "elf", - dso_scheme => "dlfcn", - shared_target => "linux-shared", - shared_cflag => "-fPIC", - }, "debug-test-64-clang" => { inherit_from => [ 'BASE_unix', "x86_64_asm" ], cc => "clang", cflags => combine(join(' ', @gcc_devteam_warn), - "-Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe", + "-Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_UNUSED -g3 -O3 -pipe", threads("${BSDthreads}")), bn_ops => "SIXTY_FOUR_BIT_LONG", thread_scheme => "pthreads", + asm_arch => 'x86_64', perlasm_scheme => "elf", dso_scheme => "dlfcn", shared_target => "bsd-gcc-shared", @@ -96,11 +75,12 @@ my %targets = ( cc => "clang", cflags => combine("-arch x86_64 -DL_ENDIAN", join(' ', @gcc_devteam_warn), - "-Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe", + "-Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_UNUSED -g3 -O3 -pipe", threads("${BSDthreads}")), sys_id => "MACOSX", bn_ops => "SIXTY_FOUR_BIT_LONG", thread_scheme => "pthreads", + asm_arch => 'x86_64', perlasm_scheme => "macosx", dso_scheme => "dlfcn", shared_target => "darwin-shared", diff --git a/Configurations/README b/Configurations/README index 8efabb37..a0618ca2 100644 --- a/Configurations/README +++ b/Configurations/README @@ -165,6 +165,13 @@ In each table entry, the following keys are significant: that use dlopen() et al but do not have fcntl.h), "DL" (shl_load() et al), "WIN32" and "VMS". + asm_arch => The architecture to be used for compiling assembly + source. This acts as a selector in build.info files. + uplink_arch => The architecture to be used for compiling uplink + source. This acts as a selector in build.info files. + This is separate from asm_arch because it's compiled + even when 'no-asm' is given, even though it contains + assembler source. perlasm_scheme => The perlasm method used to create the assembler files used when compiling with assembler implementations. @@ -229,63 +236,6 @@ In each table entry, the following keys are significant: up of 'unsigned char's; RC4_INT RC4 key schedule is made up of 'unsigned int's; - EXPORT_VAR_AS_FN for shared libraries, - export vars as - accessor functions. - - apps_aux_src => Extra source to build apps/openssl and other - apps, as needed by the target and that can be - collected in a library. - apps_init_src => Init source to build apps/openssl and other - apps, as needed by the target. This code - cannot be placed in a library, as the rest - of the code isn't expected to link to it - explicitly. - cpuid_asm_src => assembler implementation of cpuid code as - well as OPENSSL_cleanse(). - Default to mem_clr.c - bn_asm_src => Assembler implementation of core bignum - functions. - Defaults to bn_asm.c - ec_asm_src => Assembler implementation of core EC - functions. - des_asm_src => Assembler implementation of core DES - encryption functions. - Defaults to 'des_enc.c fcrypt_b.c' - aes_asm_src => Assembler implementation of core AES - functions. - Defaults to 'aes_core.c aes_cbc.c' - bf_asm_src => Assembler implementation of core BlowFish - functions. - Defaults to 'bf_enc.c' - md5_asm_src => Assembler implementation of core MD5 - functions. - sha1_asm_src => Assembler implementation of core SHA1, - functions, and also possibly SHA256 and - SHA512 ones. - cast_asm_src => Assembler implementation of core CAST - functions. - Defaults to 'c_enc.c' - rc4_asm_src => Assembler implementation of core RC4 - functions. - Defaults to 'rc4_enc.c rc4_skey.c' - rmd160_asm_src => Assembler implementation of core RMD160 - functions. - rc5_asm_src => Assembler implementation of core RC5 - functions. - Defaults to 'rc5_enc.c' - wp_asm_src => Assembler implementation of core WHIRLPOOL - functions. - cmll_asm_src => Assembler implementation of core CAMELLIA - functions. - Defaults to 'camellia.c cmll_misc.c cmll_cbc.c' - modes_asm_src => Assembler implementation of cipher modes, - currently the functions gcm_gmult_4bit and - gcm_ghash_4bit. - padlock_asm_src => Assembler implementation of core parts of - the padlock engine. This is mandatory on - any platform where the padlock engine might - actually be built. [1] as part of the target configuration, one can have a key called diff --git a/Configurations/common0.tmpl b/Configurations/common0.tmpl index 03acb3e0..852b1fb3 100644 --- a/Configurations/common0.tmpl +++ b/Configurations/common0.tmpl @@ -22,7 +22,7 @@ our @generated = sort ( ( grep { defined $unified_info{generate}->{$_} } sort keys %generatables ), - # Scripts are assumed to be generated, so add thhem too + # Scripts are assumed to be generated, so add them too ( grep { defined $unified_info{sources}->{$_} } @{$unified_info{scripts}} ) ); diff --git a/Configurations/platform/AIX.pm b/Configurations/platform/AIX.pm index f441c157..c6f0e8d2 100644 --- a/Configurations/platform/AIX.pm +++ b/Configurations/platform/AIX.pm @@ -12,6 +12,7 @@ require platform::Unix; # Assume someone set @INC right before loading this module use configdata; +sub dsoext { '.so' } sub shlibextsimple { '.a' } # In shared mode, the default static library names clashes with the final diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 2561c473..52eeaa9a 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -422,7 +422,7 @@ uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev install_docs: install_man_docs install_html_docs uninstall_docs: uninstall_man_docs uninstall_html_docs - $(RM) -r -v $(DESTDIR)$(DOCDIR) + $(RM) -r $(DESTDIR)$(DOCDIR) install_ssldirs: @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs @@ -728,7 +728,7 @@ generate: generate_apps generate_crypto_bn generate_crypto_objects \ .PHONY: doc-nits doc-nits: build_generated - (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits + (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p -s ) >doc-nits @if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \ else echo 'doc-nits: no errors.'; rm doc-nits ; fi @@ -804,7 +804,6 @@ errors: our @cryptoheaders = qw( include/internal/dso.h include/internal/o_dir.h - include/internal/o_str.h include/internal/err.h include/internal/sslconf.h ); our @cryptoskipheaders = ( @sslheaders, diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl index de597941..3c8d51b6 100644 --- a/Configurations/windows-makefile.tmpl +++ b/Configurations/windows-makefile.tmpl @@ -287,7 +287,17 @@ DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (), @{$config{module_asflags}}, '$(CNF_ASFLAGS)', '$(ASFLAGS)') -} DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (), - $target{module_cppflags} || (), + $target{module_cppflag} || (), + (map { '-D'.quotify1($_) } + @{$target{dso_defines}}, + @{$target{module_defines}}, + @{$config{dso_defines}}, + @{$config{module_defines}}), + (map { '-I'.quotify1($_) } + @{$target{dso_includes}}, + @{$target{module_includes}}, + @{$config{dso_includes}}, + @{$config{module_includes}}), @{$config{dso_cppflags}}, @{$config{module_cppflags}}, '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} @@ -539,7 +549,7 @@ reconfigure reconf: $args{generator}->[1] || platform->dsoname($args{product}); return <<"EOF"; $target: $args{generator}->[0] $deps $mkdef - \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target + "\$(PERL)" $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target EOF } elsif (!platform->isasm($args{src})) { my $target = $args{src}; diff --git a/Configure b/Configure index 2247a36a..30f9e61a 100755 --- a/Configure +++ b/Configure @@ -64,6 +64,7 @@ my $usage="Usage: Configure [no- ...] [enable- ...] [-Dxxx] [-lx # zlib-dynamic Like "zlib", but the zlib library is expected to be a shared # library and will be loaded in run-time by the OpenSSL library. # sctp include SCTP support +# no-uplink Don't build support for UPLINK interface. # enable-weak-ssl-ciphers # Enable weak ciphers that are disabled by default. # 386 generate 80386 code in assembly modules @@ -88,9 +89,6 @@ my $usage="Usage: Configure [no- ...] [enable- ...] [-Dxxx] [-lx # linked openssl executable has rather debugging value than # production quality. # -# DEBUG_SAFESTACK use type-safe stacks to enforce type-safety on stack items -# provided to stack calls. Generates unique stack functions for -# each possible stack type. # BN_LLONG use the type 'long long' in crypto/bn/bn.h # RC4_CHAR use 'char' instead of 'int' for RC4_INT in crypto/rc4/rc4.h # Following are set automatically by this script @@ -415,6 +413,7 @@ my @disablables = ( "ubsan", "ui-console", "unit-test", + "uplink", "whirlpool", "weak-ssl-ciphers", "zlib", @@ -483,8 +482,9 @@ my @disable_cascades = ( "ssl3-method" => [ "ssl3" ], "zlib" => [ "zlib-dynamic" ], "des" => [ "mdc2" ], - "ec" => [ "ecdsa", "ecdh" ], - + "ec" => [ "ecdsa", "ecdh", "sm2" ], + sub { $disabled{"ec"} && $disabled{"dh"} } + => [ "tls1_3" ], "dgram" => [ "dtls", "sctp" ], "sock" => [ "dgram" ], "dtls" => [ @dtls ], @@ -507,7 +507,7 @@ my @disable_cascades = ( # which cannot be guaranteed if shared libraries aren't present. # (note that even with shared libraries, both the app and dynamic engines # must be linked with the same library) - "shared" => [ "dynamic-engine" ], + "shared" => [ "dynamic-engine", "uplink" ], # Other modules don't necessarily have to link with libcrypto, so shared # libraries do not have to be a condition to produce those. @@ -527,7 +527,6 @@ my @disable_cascades = ( "apps" => [ "tests" ], "tests" => [ "external-tests" ], "comp" => [ "zlib" ], - "ec" => [ "tls1_3", "sm2" ], "sm3" => [ "sm2" ], sub { !$disabled{"unit-test"} } => [ "heartbeats" ], @@ -1136,6 +1135,12 @@ foreach my $feature (@{$target{enable}}) { delete $disabled{$feature}; } } + +# If uplink_arch isn't defined, disable uplink +$disabled{uplink} = 'no uplink_arch' unless (defined $target{uplink_arch}); +# If asm_arch isn't defined, disable asm +$disabled{asm} = 'no asm_arch' unless (defined $target{asm_arch}); + disable(); # Run a cascade now $target{CXXFLAGS}//=$target{CFLAGS} if $target{CXX}; @@ -1399,71 +1404,6 @@ if ($target{sys_id} ne "") } unless ($disabled{asm}) { - $target{cpuid_asm_src}=$table{DEFAULTS}->{cpuid_asm_src} if ($config{processor} eq "386"); - push @{$config{lib_defines}}, "OPENSSL_CPUID_OBJ" if ($target{cpuid_asm_src} ne "mem_clr.c"); - - $target{bn_asm_src} =~ s/\w+-gf2m.c// if (defined($disabled{ec2m})); - - # bn-586 is the only one implementing bn_*_part_words - push @{$config{lib_defines}}, "OPENSSL_BN_ASM_PART_WORDS" if ($target{bn_asm_src} =~ /bn-586/); - push @{$config{lib_defines}}, "OPENSSL_IA32_SSE2" if (!$disabled{sse2} && $target{bn_asm_src} =~ /86/); - - push @{$config{lib_defines}}, "OPENSSL_BN_ASM_MONT" if ($target{bn_asm_src} =~ /-mont/); - push @{$config{lib_defines}}, "OPENSSL_BN_ASM_MONT5" if ($target{bn_asm_src} =~ /-mont5/); - push @{$config{lib_defines}}, "OPENSSL_BN_ASM_GF2m" if ($target{bn_asm_src} =~ /-gf2m/); - push @{$config{lib_defines}}, "BN_DIV3W" if ($target{bn_asm_src} =~ /-div3w/); - - if ($target{sha1_asm_src}) { - push @{$config{lib_defines}}, "SHA1_ASM" if ($target{sha1_asm_src} =~ /sx86/ || $target{sha1_asm_src} =~ /sha1/); - push @{$config{lib_defines}}, "SHA256_ASM" if ($target{sha1_asm_src} =~ /sha256/); - push @{$config{lib_defines}}, "SHA512_ASM" if ($target{sha1_asm_src} =~ /sha512/); - } - if ($target{keccak1600_asm_src} ne $table{DEFAULTS}->{keccak1600_asm_src}) { - push @{$config{lib_defines}}, "KECCAK1600_ASM"; - } - if ($target{rc4_asm_src} ne $table{DEFAULTS}->{rc4_asm_src}) { - push @{$config{lib_defines}}, "RC4_ASM"; - } - if ($target{md5_asm_src}) { - push @{$config{lib_defines}}, "MD5_ASM"; - } - $target{cast_asm_src}=$table{DEFAULTS}->{cast_asm_src} unless $disabled{pic}; # CAST assembler is not PIC - if ($target{rmd160_asm_src}) { - push @{$config{lib_defines}}, "RMD160_ASM"; - } - if ($target{aes_asm_src}) { - push @{$config{lib_defines}}, "AES_ASM" if ($target{aes_asm_src} =~ m/\baes-/);; - # aes-ctr.fake is not a real file, only indication that assembler - # module implements AES_ctr32_encrypt... - push @{$config{lib_defines}}, "AES_CTR_ASM" if ($target{aes_asm_src} =~ s/\s*aes-ctr\.fake//); - # aes-xts.fake indicates presence of AES_xts_[en|de]crypt... - push @{$config{lib_defines}}, "AES_XTS_ASM" if ($target{aes_asm_src} =~ s/\s*aes-xts\.fake//); - $target{aes_asm_src} =~ s/\s*(vpaes|aesni)-x86\.s//g if ($disabled{sse2}); - push @{$config{lib_defines}}, "VPAES_ASM" if ($target{aes_asm_src} =~ m/vpaes/); - push @{$config{lib_defines}}, "BSAES_ASM" if ($target{aes_asm_src} =~ m/bsaes/); - } - if ($target{wp_asm_src} =~ /mmx/) { - if ($config{processor} eq "386") { - $target{wp_asm_src}=$table{DEFAULTS}->{wp_asm_src}; - } elsif (!$disabled{"whirlpool"}) { - push @{$config{lib_defines}}, "WHIRLPOOL_ASM"; - } - } - if ($target{modes_asm_src} =~ /ghash-/) { - push @{$config{lib_defines}}, "GHASH_ASM"; - } - if ($target{ec_asm_src} =~ /ecp_nistz256/) { - push @{$config{lib_defines}}, "ECP_NISTZ256_ASM"; - } - if ($target{ec_asm_src} =~ /x25519/) { - push @{$config{lib_defines}}, "X25519_ASM"; - } - if ($target{padlock_asm_src} ne $table{DEFAULTS}->{padlock_asm_src}) { - push @{$config{dso_defines}}, "PADLOCK_ASM"; - } - if ($target{poly1305_asm_src} ne "") { - push @{$config{lib_defines}}, "POLY1305_ASM"; - } } my %predefined_C = compiler_predefined($config{CROSS_COMPILE}.$config{CC}); @@ -1516,7 +1456,6 @@ if (!$disabled{asm} && !$predefined_C{__MACH__} && $^O ne 'VMS') { # Deal with bn_ops ################################################### $config{bn_ll} =0; -$config{export_var_as_fn} =0; my $def_int="unsigned int"; $config{rc4_int} =$def_int; ($config{b64l},$config{b64},$config{b32})=(0,0,1); @@ -1524,7 +1463,6 @@ $config{rc4_int} =$def_int; my $count = 0; foreach (sort split(/\s+/,$target{bn_ops})) { $count++ if /SIXTY_FOUR_BIT|SIXTY_FOUR_BIT_LONG|THIRTY_TWO_BIT/; - $config{export_var_as_fn}=1 if $_ eq 'EXPORT_VAR_AS_FN'; $config{bn_ll}=1 if $_ eq 'BN_LLONG'; $config{rc4_int}="unsigned char" if $_ eq 'RC4_CHAR'; ($config{b64l},$config{b64},$config{b32}) @@ -1791,6 +1729,24 @@ if ($builder eq "unified") { my %depends = (); my %generate = (); + # Support for $variablename in build.info files. + # Embedded perl code is the ultimate master, still. If its output + # contains a dollar sign, it had better be escaped, or it will be + # taken for a variable name prefix. + my %variables = (); + my $variable_re = qr/\$([[:alpha:]][[:alnum:]_]*)/; + my $expand_variables = sub { + my $value = ''; + my $value_rest = shift; + + while ($value_rest =~ /(? sub { if (! @skip || $skip[$#skip] > 0) { - push @skip, !! $1; + push @skip, !! $expand_variables->($1); } else { push @skip, -1; } @@ -1837,7 +1793,7 @@ if ($builder eq "unified") { => sub { die "ELSIF out of scope" if ! @skip; die "ELSIF following ELSE" if abs($skip[$#skip]) == 2; $skip[$#skip] = -1 if $skip[$#skip] != 0; - $skip[$#skip] = !! $1 + $skip[$#skip] = !! $expand_variables->($1) if $skip[$#skip] == 0; }, qr/^\s*ELSE\s*$/ => sub { die "ELSE out of scope" if ! @skip; @@ -1846,10 +1802,18 @@ if ($builder eq "unified") { qr/^\s*ENDIF\s*$/ => sub { die "ENDIF out of scope" if ! @skip; pop @skip; }, + qr/^\s*${variable_re}\s*=\s*(.*?)\s*$/ + => sub { + if (!@skip || $skip[$#skip] > 0) { + my $n = $1; + my $v = $2; + $variables{$n} = $expand_variables->($v); + } + }, qr/^\s*SUBDIRS\s*=\s*(.*)\s*$/ => sub { if (!@skip || $skip[$#skip] > 0) { - foreach (tokenize($1)) { + foreach (tokenize($expand_variables->($1))) { push @build_dirs, [ @curd, splitdir($_, 1) ]; } } @@ -1858,7 +1822,7 @@ if ($builder eq "unified") { => sub { if (!@skip || $skip[$#skip] > 0) { my @a = tokenize($1, qr|\s*,\s*|); - my @p = tokenize($2); + my @p = tokenize($expand_variables->($2)); push @programs, @p; foreach my $a (@a) { my $ak = $a; @@ -1877,7 +1841,7 @@ if ($builder eq "unified") { => sub { if (!@skip || $skip[$#skip] > 0) { my @a = tokenize($1, qr|\s*,\s*|); - my @l = tokenize($2); + my @l = tokenize($expand_variables->($2)); push @libraries, @l; foreach my $a (@a) { my $ak = $a; @@ -1896,7 +1860,7 @@ if ($builder eq "unified") { => sub { if (!@skip || $skip[$#skip] > 0) { my @a = tokenize($1, qr|\s*,\s*|); - my @m = tokenize($2); + my @m = tokenize($expand_variables->($2)); push @modules, @m; foreach my $a (@a) { my $ak = $a; @@ -1915,7 +1879,7 @@ if ($builder eq "unified") { => sub { if (!@skip || $skip[$#skip] > 0) { my @a = tokenize($1, qr|\s*,\s*|); - my @s = tokenize($2); + my @s = tokenize($expand_variables->($2)); push @scripts, @s; foreach my $a (@a) { my $ak = $a; @@ -1932,22 +1896,23 @@ if ($builder eq "unified") { }, qr/^\s*ORDINALS\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/, - => sub { push @{$ordinals{$1}}, tokenize($2) + => sub { push @{$ordinals{$1}}, tokenize($expand_variables->($2)) if !@skip || $skip[$#skip] > 0 }, qr/^\s*SOURCE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/ - => sub { push @{$sources{$1}}, tokenize($2) + => sub { push @{$sources{$1}}, tokenize($expand_variables->($2)) if !@skip || $skip[$#skip] > 0 }, qr/^\s*SHARED_SOURCE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/ - => sub { push @{$shared_sources{$1}}, tokenize($2) + => sub { push @{$shared_sources{$1}}, + tokenize($expand_variables->($2)) if !@skip || $skip[$#skip] > 0 }, qr/^\s*INCLUDE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/ - => sub { push @{$includes{$1}}, tokenize($2) + => sub { push @{$includes{$1}}, tokenize($expand_variables->($2)) if !@skip || $skip[$#skip] > 0 }, qr/^\s*DEFINE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/ - => sub { push @{$defines{$1}}, tokenize($2) + => sub { push @{$defines{$1}}, tokenize($expand_variables->($2)) if !@skip || $skip[$#skip] > 0 }, qr/^\s*DEPEND\[((?:\\.|[^\\\]])*)\]\s*=\s*(.*)\s*$/ - => sub { push @{$depends{$1}}, tokenize($2) + => sub { push @{$depends{$1}}, tokenize($expand_variables->($2)) if !@skip || $skip[$#skip] > 0 }, qr/^\s*GENERATE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/ => sub { push @{$generate{$1}}, $2 @@ -2174,6 +2139,34 @@ They are ignored and should be replaced with a combination of GENERATE, DEPEND and SHARED_SOURCE. EOF + + # Go through the sources of all libraries and check that the same basename + # doesn't appear more than once. Some static library archivers depend on + # them being unique. + { + my $err = 0; + foreach my $prod (keys %{$unified_info{libraries}}) { + my @prod_sources = + map { keys %{$unified_info{sources}->{$_}} } + keys %{$unified_info{sources}->{$prod}}; + my %srccnt = (); + + # Count how many times a given each source basename + # appears for each product. + foreach my $src (@prod_sources) { + $srccnt{basename $src}++; + } + + foreach my $src (keys %srccnt) { + if ((my $cnt = $srccnt{$src}) > 1) { + print STDERR "$src appears $cnt times for the product $prod\n"; + $err++ + } + } + } + die if $err > 0; + } + # Massage the result # If we depend on a header file or a perl module, add an inclusion of @@ -2284,6 +2277,7 @@ EOF } } } + # At this point, we have a number of sources with the value -1. They # aren't part of the local build and are probably meant for a different # platform, and can therefore be cleaned away. That happens when making @@ -2898,18 +2892,6 @@ _____ # Thus, whenever there's mention of a returned value, it's about that # intended value. -# Helper function to implement conditional inheritance depending on the -# value of $disabled{asm}. Used in inherit_from values as follows: -# -# inherit_from => [ "template", asm("asm_tmpl") ] -# -sub asm { - my @x = @_; - sub { - $disabled{asm} ? () : @x; - } -} - # Helper function to implement conditional value variants, with a default # plus additional values based on the value of $config{build_type}. # Arguments are given in hash table form: @@ -3330,31 +3312,11 @@ sub print_table_entry "includes", "cc", "cflags", - "unistd", "ld", "lflags", "loutflag", "ex_libs", "bn_ops", - "apps_aux_src", - "cpuid_asm_src", - "uplink_aux_src", - "bn_asm_src", - "ec_asm_src", - "des_asm_src", - "aes_asm_src", - "bf_asm_src", - "md5_asm_src", - "cast_asm_src", - "sha1_asm_src", - "rc4_asm_src", - "rmd160_asm_src", - "rc5_asm_src", - "wp_asm_src", - "cmll_asm_src", - "modes_asm_src", - "padlock_asm_src", - "chacha_asm_src", "poly1035_asm_src", "thread_scheme", "perlasm_scheme", diff --git a/HACKING b/HACKING new file mode 100644 index 00000000..a9e39d02 --- /dev/null +++ b/HACKING @@ -0,0 +1,26 @@ + MODIFYING OPENSSL SOURCE + ------------------------ + This document describes the way to add custom modifications to OpenSSL sources. + + If you are adding new public functions to the custom library build, you need to + either add a prototype in one of the existing OpenSSL header files; + or provide a new header file and edit Configurations/unix-Makefile.tmpl to pick up that file. + + After that perform the following steps: + + ./config -Werror --strict-warnings [your-options] + make update + make + make test + + "make update" ensures that your functions declarations are added to util/libcrypto.num or util/libssl.num + If you plan to submit the changes you made to OpenSSL (see CONTRIBUTING), it's worth running: + + make doc-nits + + after running "make update" to ensure that documentation has correct format. + + "make update" also generates files related to OIDs (in the crypto/objects/ folder) and errors. + If a merge error occurs in one of these generated files then the generated files need to be removed + and regenerated using "make update". + To aid in this process the generated files can be committed separately so they can be removed easily. diff --git a/INSTALL b/INSTALL index 88425a8c..16de9b88 100644 --- a/INSTALL +++ b/INSTALL @@ -314,6 +314,9 @@ Don't build the CAPI engine. This option will be forced if on a platform that does not support CAPI. + no-cmp + Don't build support for CMP features + no-cms Don't build support for CMS features @@ -555,6 +558,9 @@ Enable additional unit test APIs. This should not typically be used in production deployments. + no-uplink + Don't build support for UPLINK interface. + enable-weak-ssl-ciphers Build support for SSL/TLS ciphers that are considered "weak" (e.g. RC4 based ciphersuites). @@ -1200,6 +1206,11 @@ $ make TESTS='[89]? -90' +To stochastically verify that the algorithm that produces uniformly distributed +random numbers is operating correctly (with a false positive rate of 0.01%): + + $ ./util/shlib_wrap.sh test/bntest -stochastic + Note on multi-threading ----------------------- diff --git a/NEWS b/NEWS index 6c79bc24..aeb2eb74 100644 --- a/NEWS +++ b/NEWS @@ -605,7 +605,7 @@ Major changes between OpenSSL 0.9.7h and OpenSSL 0.9.7i [14 Oct 2005]: - o Give EVP_MAX_MD_SIZE it's old value, except for a FIPS build. + o Give EVP_MAX_MD_SIZE its old value, except for a FIPS build. Major changes between OpenSSL 0.9.7g and OpenSSL 0.9.7h [11 Oct 2005]: diff --git a/NOTES.WIN b/NOTES.WIN index 4d39d06f..ca033602 100644 --- a/NOTES.WIN +++ b/NOTES.WIN @@ -83,6 +83,16 @@ is, of course, to choose a different set of directories by using --prefix and --openssldir when configuring. + + Special notes for Universal Windows Platform builds, a.k.a. VC-*-UWP + -------------------------------------------------------------------- + + - UWP targets only support building the static and dynamic libraries. + + - You should define the platform type to "uwp" and the target arch via + "vcvarsall.bat" before you compile. For example, if you want to build + "arm64" builds, you should type "vcvarsall.bat x86_arm64 uwp". + mingw and mingw64 ================= diff --git a/apps/build.info b/apps/build.info index cbb70fc7..3b4ea25d 100644 --- a/apps/build.info +++ b/apps/build.info @@ -1,4 +1,25 @@ -{- our @apps_openssl_src = +# Program init source, that don't have direct linkage with the rest of the +# source, and can therefore not be part of a library. +IF[{- !$disabled{uplink} -}] + $INITSRC=../ms/applink.c +ENDIF +IF[{- $config{target} =~ /^vms-/ -}] + $INITSRC=vms_decc_init.c +ENDIF + +# Auxilliary program source +IF[{- $config{target} =~ /^(?:VC-|mingw)/ -}] + # It's called 'init', but doesn't have much 'init' in it... + $AUXLIBAPPSSRC=win32_init.c +ENDIF +IF[{- $config{target} =~ /^vms-/ -}] + $AUXLIBAPPSSRC=vms_term_sock.c vms_decc_argv.c +ENDIF + +# Source for the 'openssl' program +# We need the perl variable for the DEPEND generator further down. +$OPENSSLSRC={- + our @opensslsrc = qw(openssl.c asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c dgst.c dhparam.c dsa.c dsaparam.c ec.c ecparam.c enc.c engine.c errstr.c gendsa.c @@ -7,30 +28,28 @@ rsautl.c s_client.c s_server.c s_time.c sess_id.c smime.c speed.c spkac.c srp.c ts.c verify.c version.c x509.c rehash.c storeutl.c info.c); - our @apps_lib_src = - ( qw(apps.c apps_ui.c opt.c fmt.c s_cb.c s_socket.c app_rand.c - bf_prefix.c), - split(/\s+/, $target{apps_aux_src}) ); - our @apps_init_src = split(/\s+/, $target{apps_init_src}); - "" -} + join(' ', @opensslsrc); -} +# Source for libapps +$LIBAPPSSRC=apps.c apps_ui.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \ + bf_prefix.c + IF[{- !$disabled{apps} -}] LIBS{noinst}=libapps.a - SOURCE[libapps.a]={- join(" ", @apps_lib_src) -} + SOURCE[libapps.a]=$LIBAPPSSRC $AUXLIBAPPSSRC INCLUDE[libapps.a]=.. ../include include PROGRAMS=openssl - SOURCE[openssl]={- join(" ", @apps_init_src) -} - SOURCE[openssl]={- join(" ", @apps_openssl_src) -} + SOURCE[openssl]=$INITSRC $OPENSSLSRC INCLUDE[openssl]=.. ../include include DEPEND[openssl]=libapps.a ../libssl -IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-)/ -}] - GENERATE[openssl.rc]=../util/mkrc.pl openssl - SOURCE[openssl]=openssl.rc -ENDIF + IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-)/ -}] + GENERATE[openssl.rc]=../util/mkrc.pl openssl + SOURCE[openssl]=openssl.rc + ENDIF {- join("\n ", map { (my $x = $_) =~ s|\.c$|.o|; "DEPEND[$x]=progs.h" } - @apps_openssl_src) -} + @opensslsrc) -} GENERATE[progs.h]=progs.pl $(APPS_OPENSSL) DEPEND[progs.h]=../configdata.pm diff --git a/apps/ca.c b/apps/ca.c index 4464b2ba..b188b9b4 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -96,7 +96,8 @@ static int certify(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509, const char *enddate, long days, int batch, const char *ext_sect, CONF *conf, int verbose, unsigned long certopt, unsigned long nameopt, - int default_op, int ext_copy, int selfsign); + int default_op, int ext_copy, int selfsign, + unsigned char *sm2_id, size_t sm2idlen); static int certify_cert(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst, STACK_OF(OPENSSL_STRING) *sigopts, STACK_OF(CONF_VALUE) *policy, CA_DB *db, @@ -147,7 +148,7 @@ typedef enum OPTION_choice { OPT_INFILES, OPT_SS_CERT, OPT_SPKAC, OPT_REVOKE, OPT_VALID, OPT_EXTENSIONS, OPT_EXTFILE, OPT_STATUS, OPT_UPDATEDB, OPT_CRLEXTS, OPT_RAND_SERIAL, - OPT_R_ENUM, + OPT_R_ENUM, OPT_SM2ID, OPT_SM2HEXID, /* Do not change the order here; see related case statements below */ OPT_CRL_REASON, OPT_CRL_HOLD, OPT_CRL_COMPROMISE, OPT_CRL_CA_COMPROMISE } OPTION_CHOICE; @@ -217,6 +218,12 @@ const OPTIONS ca_options[] = { OPT_R_OPTIONS, #ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, +#endif +#ifndef OPENSSL_NO_SM2 + {"sm2-id", OPT_SM2ID, 's', + "Specify an ID string to verify an SM2 certificate request"}, + {"sm2-hex-id", OPT_SM2HEXID, 's', + "Specify a hex ID string to verify an SM2 certificate request"}, #endif {NULL} }; @@ -262,6 +269,9 @@ int ca_main(int argc, char **argv) REVINFO_TYPE rev_type = REV_NONE; X509_REVOKED *r = NULL; OPTION_CHOICE o; + unsigned char *sm2_id = NULL; + size_t sm2_idlen = 0; + int sm2_free = 0; prog = opt_init(argc, argv, ca_options); while ((o = opt_next()) != OPT_EOF) { @@ -425,6 +435,30 @@ opthelp: case OPT_ENGINE: e = setup_engine(opt_arg(), 0); break; + case OPT_SM2ID: + /* we assume the input is not a hex string */ + if (sm2_id != NULL) { + BIO_printf(bio_err, + "Use one of the options 'sm2-hex-id' or 'sm2-id'\n"); + goto end; + } + sm2_id = (unsigned char *)opt_arg(); + sm2_idlen = strlen((const char *)sm2_id); + break; + case OPT_SM2HEXID: + /* try to parse the input as hex string first */ + if (sm2_id != NULL) { + BIO_printf(bio_err, + "Use one of the options 'sm2-hex-id' or 'sm2-id'\n"); + goto end; + } + sm2_free = 1; + sm2_id = OPENSSL_hexstr2buf(opt_arg(), (long *)&sm2_idlen); + if (sm2_id == NULL) { + BIO_printf(bio_err, "Invalid hex string input\n"); + goto end; + } + break; } } end_of_options: @@ -913,7 +947,8 @@ end_of_options: j = certify(&x, infile, pkey, x509p, dgst, sigopts, attribs, db, serial, subj, chtype, multirdn, email_dn, startdate, enddate, days, batch, extensions, conf, verbose, - certopt, get_nameopt(), default_op, ext_copy, selfsign); + certopt, get_nameopt(), default_op, ext_copy, selfsign, + sm2_id, sm2_idlen); if (j < 0) goto end; if (j > 0) { @@ -932,7 +967,8 @@ end_of_options: j = certify(&x, argv[i], pkey, x509p, dgst, sigopts, attribs, db, serial, subj, chtype, multirdn, email_dn, startdate, enddate, days, batch, extensions, conf, verbose, - certopt, get_nameopt(), default_op, ext_copy, selfsign); + certopt, get_nameopt(), default_op, ext_copy, selfsign, + sm2_id, sm2_idlen); if (j < 0) goto end; if (j > 0) { @@ -1230,6 +1266,8 @@ end_of_options: ret = 0; end: + if (sm2_free) + OPENSSL_free(sm2_id); if (ret) ERR_print_errors(bio_err); BIO_free_all(Sout); @@ -1268,7 +1306,8 @@ static int certify(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509, const char *enddate, long days, int batch, const char *ext_sect, CONF *lconf, int verbose, unsigned long certopt, unsigned long nameopt, - int default_op, int ext_copy, int selfsign) + int default_op, int ext_copy, int selfsign, + unsigned char *sm2id, size_t sm2idlen) { X509_REQ *req = NULL; BIO *in = NULL; @@ -1300,6 +1339,25 @@ static int certify(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509, BIO_printf(bio_err, "error unpacking public key\n"); goto end; } + if (sm2id != NULL) { +#ifndef OPENSSL_NO_SM2 + ASN1_OCTET_STRING *v; + + v = ASN1_OCTET_STRING_new(); + if (v == NULL) { + BIO_printf(bio_err, "error: SM2 ID allocation failed\n"); + goto end; + } + + if (!ASN1_OCTET_STRING_set(v, sm2id, sm2idlen)) { + BIO_printf(bio_err, "error: setting SM2 ID failed\n"); + ASN1_OCTET_STRING_free(v); + goto end; + } + + X509_REQ_set0_sm2_id(req, v); +#endif + } i = X509_REQ_verify(req, pktmp); pktmp = NULL; if (i < 0) { diff --git a/apps/cms.c b/apps/cms.c index 2863a92e..9c9f01d3 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -603,6 +603,14 @@ int cms_main(int argc, char **argv) goto opthelp; } + if (flags & CMS_CADES) { + if (flags & CMS_NOATTR) { + BIO_puts(bio_err, "Incompatible options: " + "CAdES required signed attributes\n"); + goto opthelp; + } + } + if (operation & SMIME_SIGNERS) { if (keyfile != NULL && signerfile == NULL) { BIO_puts(bio_err, "Illegal -inkey without -signer\n"); diff --git a/apps/include/opt.h b/apps/include/opt.h index ecfa06e0..81faf705 100644 --- a/apps/include/opt.h +++ b/apps/include/opt.h @@ -317,7 +317,8 @@ int opt_int(const char *arg, int *result); int opt_ulong(const char *arg, unsigned long *result); int opt_long(const char *arg, long *result); #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ - defined(INTMAX_MAX) && defined(UINTMAX_MAX) + defined(INTMAX_MAX) && defined(UINTMAX_MAX) && \ + !defined(OPENSSL_NO_INTTYPES_H) int opt_imax(const char *arg, intmax_t *result); int opt_umax(const char *arg, uintmax_t *result); #else diff --git a/apps/openssl.c b/apps/openssl.c index 9c0d933d..d6820a19 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -130,11 +130,8 @@ static size_t internal_trace_cb(const char *buf, size_t cnt, { int ret = 0; tracedata *trace_data = vdata; - union { - CRYPTO_THREAD_ID tid; - unsigned long ltid; - } tid; - char buffer[256]; + char buffer[256], *hex; + CRYPTO_THREAD_ID tid; switch (cmd) { case OSSL_TRACE_CTRL_BEGIN: @@ -142,11 +139,11 @@ static size_t internal_trace_cb(const char *buf, size_t cnt, return 0; trace_data->ingroup = 1; - tid.ltid = 0; - tid.tid = CRYPTO_THREAD_get_current_id(); - - BIO_snprintf(buffer, sizeof(buffer), "TRACE[%lx]:%s: ", tid.ltid, - OSSL_trace_get_category_name(category)); + tid = CRYPTO_THREAD_get_current_id(); + hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid)); + BIO_snprintf(buffer, sizeof(buffer), "TRACE[%s]:%s: ", + hex, OSSL_trace_get_category_name(category)); + OPENSSL_free(hex); BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX, strlen(buffer), buffer); break; @@ -216,6 +213,13 @@ static void setup_trace(const char *str) { char *val; + /* + * We add this handler as early as possible to ensure it's executed + * as late as possible, i.e. after the TRACE code has done its cleanup + * (which happens last in OPENSSL_cleanup). + */ + atexit(cleanup_trace); + trace_data_stack = sk_tracedata_new_null(); val = OPENSSL_strdup(str); @@ -240,7 +244,6 @@ static void setup_trace(const char *str) } OPENSSL_free(val); - atexit(cleanup_trace); } #endif /* OPENSSL_NO_TRACE */ diff --git a/apps/opt.c b/apps/opt.c index 439f271f..c2a5878e 100644 --- a/apps/opt.c +++ b/apps/opt.c @@ -15,7 +15,7 @@ #include "internal/nelem.h" #include #if !defined(OPENSSL_SYS_MSDOS) -# include OPENSSL_UNISTD +# include #endif #include @@ -377,7 +377,8 @@ int opt_long(const char *value, long *result) } #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ - defined(INTMAX_MAX) && defined(UINTMAX_MAX) + defined(INTMAX_MAX) && defined(UINTMAX_MAX) && \ + !defined(OPENSSL_NO_INTTYPES_H) /* Parse an intmax_t, put it into *result; return 0 on failure, else 1. */ int opt_imax(const char *value, intmax_t *result) diff --git a/apps/pkcs12.c b/apps/pkcs12.c index bf22aeb4..407340b3 100644 --- a/apps/pkcs12.c +++ b/apps/pkcs12.c @@ -838,7 +838,7 @@ static int alg_print(const X509_ALGOR *alg) goto done; } BIO_printf(bio_err, ", Salt length: %d, Cost(N): %ld, " - "Block size(r): %ld, Paralelizm(p): %ld", + "Block size(r): %ld, Parallelism(p): %ld", ASN1_STRING_length(kdf->salt), ASN1_INTEGER_get(kdf->costParameter), ASN1_INTEGER_get(kdf->blockSize), diff --git a/apps/req.c b/apps/req.c index 67dc0c8c..f11d341c 100644 --- a/apps/req.c +++ b/apps/req.c @@ -90,7 +90,7 @@ typedef enum OPTION_choice { OPT_VERIFY, OPT_NODES, OPT_NOOUT, OPT_VERBOSE, OPT_UTF8, OPT_NAMEOPT, OPT_REQOPT, OPT_SUBJ, OPT_SUBJECT, OPT_TEXT, OPT_X509, OPT_MULTIVALUE_RDN, OPT_DAYS, OPT_SET_SERIAL, OPT_ADDEXT, OPT_EXTENSIONS, - OPT_REQEXTS, OPT_PRECERT, OPT_MD, + OPT_REQEXTS, OPT_PRECERT, OPT_MD, OPT_SM2ID, OPT_SM2HEXID, OPT_R_ENUM } OPTION_CHOICE; @@ -145,6 +145,12 @@ const OPTIONS req_options[] = { {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, {"keygen_engine", OPT_KEYGEN_ENGINE, 's', "Specify engine to be used for key generation operations"}, +#endif +#ifndef OPENSSL_NO_SM2 + {"sm2-id", OPT_SM2ID, 's', + "Specify an ID string to verify an SM2 certificate request"}, + {"sm2-hex-id", OPT_SM2HEXID, 's', + "Specify a hex ID string to verify an SM2 certificate request"}, #endif {NULL} }; @@ -239,6 +245,9 @@ int req_main(int argc, char **argv) int nodes = 0, newhdr = 0, subject = 0, pubkey = 0, precert = 0; long newkey = -1; unsigned long chtype = MBSTRING_ASC, reqflag = 0; + unsigned char *sm2_id = NULL; + size_t sm2_idlen = 0; + int sm2_free = 0; #ifndef OPENSSL_NO_DES cipher = EVP_des_ede3_cbc(); @@ -414,6 +423,29 @@ int req_main(int argc, char **argv) goto opthelp; digest = md_alg; break; + case OPT_SM2ID: + if (sm2_id != NULL) { + BIO_printf(bio_err, + "Use one of the options 'sm2-hex-id' or 'sm2-id'\n"); + goto end; + } + sm2_id = (unsigned char *)opt_arg(); + sm2_idlen = strlen((const char *)sm2_id); + break; + case OPT_SM2HEXID: + if (sm2_id != NULL) { + BIO_printf(bio_err, + "Use one of the options 'sm2-hex-id' or 'sm2-id'\n"); + goto end; + } + /* try to parse the input as hex string first */ + sm2_free = 1; + sm2_id = OPENSSL_hexstr2buf(opt_arg(), (long *)&sm2_idlen); + if (sm2_id == NULL) { + BIO_printf(bio_err, "Invalid hex string input\n"); + goto end; + } + break; } } argc = opt_num_rest(); @@ -844,6 +876,26 @@ int req_main(int argc, char **argv) goto end; } + if (sm2_id != NULL) { +#ifndef OPENSSL_NO_SM2 + ASN1_OCTET_STRING *v; + + v = ASN1_OCTET_STRING_new(); + if (v == NULL) { + BIO_printf(bio_err, "error: SM2 ID allocation failed\n"); + goto end; + } + + if (!ASN1_OCTET_STRING_set(v, sm2_id, sm2_idlen)) { + BIO_printf(bio_err, "error: setting SM2 ID failed\n"); + ASN1_OCTET_STRING_free(v); + goto end; + } + + X509_REQ_set0_sm2_id(req, v); +#endif + } + i = X509_REQ_verify(req, tpubkey); if (i < 0) { @@ -881,9 +933,19 @@ int req_main(int argc, char **argv) if (text) { if (x509) - X509_print_ex(out, x509ss, get_nameopt(), reqflag); + ret = X509_print_ex(out, x509ss, get_nameopt(), reqflag); else - X509_REQ_print_ex(out, req, get_nameopt(), reqflag); + ret = X509_REQ_print_ex(out, req, get_nameopt(), reqflag); + + if (ret == 0) { + if (x509) + BIO_printf(bio_err, "Error printing certificate\n"); + else + BIO_printf(bio_err, "Error printing certificate request\n"); + + ERR_print_errors(bio_err); + goto end; + } } if (subject) { @@ -942,6 +1004,8 @@ int req_main(int argc, char **argv) } ret = 0; end: + if (sm2_free) + OPENSSL_free(sm2_id); if (ret) { ERR_print_errors(bio_err); } @@ -1596,14 +1660,58 @@ static int genpkey_cb(EVP_PKEY_CTX *ctx) return 1; } +#ifndef OPENSSL_NO_SM2 +static int ec_pkey_is_sm2(EVP_PKEY *pkey) +{ + EC_KEY *eckey = NULL; + const EC_GROUP *group = NULL; + + if (EVP_PKEY_id(pkey) == EVP_PKEY_SM2) + return 1; + if (EVP_PKEY_id(pkey) == EVP_PKEY_EC + && (eckey = EVP_PKEY_get0_EC_KEY(pkey)) != NULL + && (group = EC_KEY_get0_group(eckey)) != NULL + && EC_GROUP_get_curve_name(group) == NID_sm2) + return 1; + return 0; +} +#endif + static int do_sign_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey, const EVP_MD *md, STACK_OF(OPENSSL_STRING) *sigopts) { EVP_PKEY_CTX *pkctx = NULL; - int i, def_nid; +#ifndef OPENSSL_NO_SM2 + EVP_PKEY_CTX *pctx = NULL; +#endif + int i, def_nid, ret = 0; if (ctx == NULL) - return 0; + goto err; +#ifndef OPENSSL_NO_SM2 + if (ec_pkey_is_sm2(pkey)) { + /* initialize some SM2-specific code */ + if (!EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2)) { + BIO_printf(bio_err, "Internal error.\n"); + goto err; + } + pctx = EVP_PKEY_CTX_new(pkey, NULL); + if (pctx == NULL) { + BIO_printf(bio_err, "memory allocation failure.\n"); + goto err; + } + /* set SM2 ID from sig options before calling the real init routine */ + for (i = 0; i < sk_OPENSSL_STRING_num(sigopts); i++) { + char *sigopt = sk_OPENSSL_STRING_value(sigopts, i); + if (pkey_ctrl_string(pctx, sigopt) <= 0) { + BIO_printf(bio_err, "parameter error \"%s\"\n", sigopt); + ERR_print_errors(bio_err); + goto err; + } + } + EVP_MD_CTX_set_pkey_ctx(ctx, pctx); + } +#endif /* * EVP_PKEY_get_default_digest_nid() returns 2 if the digest is mandatory * for this algorithm. @@ -1614,16 +1722,23 @@ static int do_sign_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey, md = NULL; } if (!EVP_DigestSignInit(ctx, &pkctx, md, NULL, pkey)) - return 0; + goto err; for (i = 0; i < sk_OPENSSL_STRING_num(sigopts); i++) { char *sigopt = sk_OPENSSL_STRING_value(sigopts, i); if (pkey_ctrl_string(pkctx, sigopt) <= 0) { BIO_printf(bio_err, "parameter error \"%s\"\n", sigopt); ERR_print_errors(bio_err); - return 0; + goto err; } } - return 1; + + ret = 1; + err: +#ifndef OPENSSL_NO_SM2 + if (!ret) + EVP_PKEY_CTX_free(pctx); +#endif + return ret; } int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md, @@ -1631,10 +1746,20 @@ int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md, { int rv; EVP_MD_CTX *mctx = EVP_MD_CTX_new(); +#ifndef OPENSSL_NO_SM2 + EVP_PKEY_CTX *pctx = NULL; +#endif rv = do_sign_init(mctx, pkey, md, sigopts); if (rv > 0) rv = X509_sign_ctx(x, mctx); +#ifndef OPENSSL_NO_SM2 + /* only in SM2 case we need to free the pctx explicitly */ + if (ec_pkey_is_sm2(pkey)) { + pctx = EVP_MD_CTX_pkey_ctx(mctx); + EVP_PKEY_CTX_free(pctx); + } +#endif EVP_MD_CTX_free(mctx); return rv > 0 ? 1 : 0; } @@ -1644,9 +1769,20 @@ int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md, { int rv; EVP_MD_CTX *mctx = EVP_MD_CTX_new(); +#ifndef OPENSSL_NO_SM2 + EVP_PKEY_CTX *pctx = NULL; +#endif + rv = do_sign_init(mctx, pkey, md, sigopts); if (rv > 0) rv = X509_REQ_sign_ctx(x, mctx); +#ifndef OPENSSL_NO_SM2 + /* only in SM2 case we need to free the pctx explicitly */ + if (ec_pkey_is_sm2(pkey)) { + pctx = EVP_MD_CTX_pkey_ctx(mctx); + EVP_PKEY_CTX_free(pctx); + } +#endif EVP_MD_CTX_free(mctx); return rv > 0 ? 1 : 0; } @@ -1656,9 +1792,20 @@ int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md, { int rv; EVP_MD_CTX *mctx = EVP_MD_CTX_new(); +#ifndef OPENSSL_NO_SM2 + EVP_PKEY_CTX *pctx = NULL; +#endif + rv = do_sign_init(mctx, pkey, md, sigopts); if (rv > 0) rv = X509_CRL_sign_ctx(x, mctx); +#ifndef OPENSSL_NO_SM2 + /* only in SM2 case we need to free the pctx explicitly */ + if (ec_pkey_is_sm2(pkey)) { + pctx = EVP_MD_CTX_pkey_ctx(mctx); + EVP_PKEY_CTX_free(pctx); + } +#endif EVP_MD_CTX_free(mctx); return rv > 0 ? 1 : 0; } diff --git a/apps/s_client.c b/apps/s_client.c index 282d137b..6f2d133d 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -2395,7 +2395,7 @@ int s_client_main(int argc, char **argv) (void)BIO_flush(fbio); /* * The first line is the HTTP response. According to RFC 7230, - * it's formated exactly like this: + * it's formatted exactly like this: * * HTTP/d.d ddd Reason text\r\n */ diff --git a/apps/s_time.c b/apps/s_time.c index e436b57a..39e3d4bb 100644 --- a/apps/s_time.c +++ b/apps/s_time.c @@ -24,7 +24,7 @@ #include #include #if !defined(OPENSSL_SYS_MSDOS) -# include OPENSSL_UNISTD +# include #endif #define SSL_CONNECT_NAME "localhost:4433" diff --git a/apps/speed.c b/apps/speed.c index 5f16b139..a5e9d443 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -29,7 +29,7 @@ #include #include #if !defined(OPENSSL_SYS_MSDOS) -# include OPENSSL_UNISTD +# include #endif #if defined(_WIN32) @@ -1876,7 +1876,7 @@ int speed_main(int argc, char **argv) } buflen = lengths[size_num - 1]; - if (buflen < 36) /* size of random vector in RSA bencmark */ + if (buflen < 36) /* size of random vector in RSA benchmark */ buflen = 36; buflen += MAX_MISALIGNMENT + 1; loopargs[i].buf_malloc = app_malloc(buflen, "input buffer"); @@ -1985,7 +1985,10 @@ int speed_main(int argc, char **argv) RC2_set_key(&rc2_ks, 16, key16, 128); #endif #ifndef OPENSSL_NO_RC5 - RC5_32_set_key(&rc5_ks, 16, key16, 12); + if (!RC5_32_set_key(&rc5_ks, 16, key16, 12)) { + BIO_printf(bio_err, "Failed setting RC5 key\n"); + goto end; + } #endif #ifndef OPENSSL_NO_BF BF_set_key(&bf_ks, 16, key16); diff --git a/apps/storeutl.c b/apps/storeutl.c index bc212c6b..f557f4d3 100644 --- a/apps/storeutl.c +++ b/apps/storeutl.c @@ -125,7 +125,7 @@ int storeutl_main(int argc, char *argv[]) } /* * If expected wasn't set at this point, it means the map - * isn't syncronised with the possible options leading here. + * isn't synchronised with the possible options leading here. */ OPENSSL_assert(expected != 0); } diff --git a/apps/ts.c b/apps/ts.c index 63c52101..4ef8a72e 100644 --- a/apps/ts.c +++ b/apps/ts.c @@ -425,7 +425,7 @@ static TS_REQ *create_query(BIO *data_bio, const char *digest, const EVP_MD *md, ASN1_OBJECT *policy_obj = NULL; ASN1_INTEGER *nonce_asn1 = NULL; - if (md == NULL && (md = EVP_get_digestbyname("sha1")) == NULL) + if (md == NULL && (md = EVP_get_digestbyname("sha256")) == NULL) goto err; if ((ts_req = TS_REQ_new()) == NULL) goto err; diff --git a/apps/verify.c b/apps/verify.c index 3767972a..fd407646 100644 --- a/apps/verify.c +++ b/apps/verify.c @@ -169,11 +169,20 @@ int verify_main(int argc, char **argv) v_verbose = 1; break; case OPT_SM2ID: - /* we assume the input is not a hex string */ + if (sm2_id != NULL) { + BIO_printf(bio_err, + "Use one of the options 'sm2-hex-id' or 'sm2-id' \n"); + goto end; + } sm2_id = (unsigned char *)opt_arg(); sm2_idlen = strlen((const char *)sm2_id); break; case OPT_SM2HEXID: + if (sm2_id != NULL) { + BIO_printf(bio_err, + "Use one of the options 'sm2-hex-id' or 'sm2-id' \n"); + goto end; + } /* try to parse the input as hex string first */ sm2_free = 1; sm2_id = OPENSSL_hexstr2buf(opt_arg(), (long *)&sm2_idlen); diff --git a/config b/config index 0755961e..058421c1 100755 --- a/config +++ b/config @@ -349,17 +349,6 @@ if [ -d /usr/apollo ]; then exit 0 fi -# Now NeXT -ISNEXT=`hostinfo 2>/dev/null` -case "$ISNEXT" in - *'NeXT Mach 3.3'*) - echo "whatever-next-nextstep3.3"; exit 0 - ;; - *NeXT*) - echo "whatever-next-nextstep"; exit 0 - ;; -esac - # At this point we gone through all the one's # we know of: Punt @@ -498,12 +487,12 @@ case "$GUESSOS" in OUT="darwin64-x86_64-cc" fi ;; armv6+7-*-iphoneos) - __CNF_CFLAGS="$__CNF_CFLAGS -arch%20armv6 -arch%20armv7" - __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch%20armv6 -arch%20armv7" + __CNF_CFLAGS="$__CNF_CFLAGS -arch armv6 -arch armv7" + __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch armv6 -arch armv7" OUT="iphoneos-cross" ;; *-*-iphoneos) - __CNF_CFLAGS="$__CNF_CFLAGS -arch%20${MACHINE}" - __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch%20${MACHINE}" + __CNF_CFLAGS="$__CNF_CFLAGS -arch ${MACHINE}" + __CNF_CXXFLAGS="$__CNF_CXXFLAGS -arch ${MACHINE}" OUT="iphoneos-cross" ;; arm64-*-iphoneos|*-*-ios64) OUT="ios64-cross" ;; diff --git a/crypto/README.sparse_array b/crypto/README.sparse_array index 947c34db..d86a48d9 100644 --- a/crypto/README.sparse_array +++ b/crypto/README.sparse_array @@ -43,7 +43,7 @@ The tree height is dynamically increased as needed based on additions. An empty tree is represented by a NULL root pointer. Inserting a value at index 0 results in the allocation of a top level node full of null pointers except for the single pointer to the user's data (N = SA_BLOCK_MAX for -breviety): +brevity): +----+ |Root| diff --git a/crypto/aes/asm/aes-s390x.pl b/crypto/aes/asm/aes-s390x.pl index 4f55a6be..9a150918 100644 --- a/crypto/aes/asm/aes-s390x.pl +++ b/crypto/aes/asm/aes-s390x.pl @@ -38,14 +38,14 @@ # Implement AES_set_[en|de]crypt_key. Key schedule setup is avoided # for 128-bit keys, if hardware support is detected. -# Januray 2009. +# January 2009. # # Add support for hardware AES192/256 and reschedule instructions to # minimize/avoid Address Generation Interlock hazard and to favour # dual-issue z10 pipeline. This gave ~25% improvement on z10 and # almost 50% on z9. The gain is smaller on z10, because being dual- # issue z10 makes it impossible to eliminate the interlock condition: -# critial path is not long enough. Yet it spends ~24 cycles per byte +# critical path is not long enough. Yet it spends ~24 cycles per byte # processed with 128-bit key. # # Unlike previous version hardware support detection takes place only diff --git a/crypto/aes/build.info b/crypto/aes/build.info index 1aa7a18d..0ba1758d 100644 --- a/crypto/aes/build.info +++ b/crypto/aes/build.info @@ -1,7 +1,69 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - aes_misc.c aes_ecb.c aes_cfb.c aes_ofb.c \ - aes_ige.c aes_wrap.c {- $target{aes_asm_src} -} + +$AESASM=aes_core.c aes_cbc.c +IF[{- !$disabled{asm} -}] + $AESASM_x86=aes-586.s + $AESDEF_x86=AES_ASM + $AESASM_x86_sse2=vpaes-x86.s aesni-x86.s + $AESDEF_x86_sse2=VPAES_ASM + + $AESASM_x86_64=\ + aes-x86_64.s vpaes-x86_64.s bsaes-x86_64.s aesni-x86_64.s \ + aesni-sha1-x86_64.s aesni-sha256-x86_64.s aesni-mb-x86_64.s + $AESDEF_x86_64=AES_ASM VPAES_ASM BSAES_ASM + + $AESASM_ia64=aes_core.c aes_cbc.c aes-ia64.s + $AESDEF_ia64=AES_ASM + + $AESASM_sparcv9=\ + aes_core.c aes_cbc.c aes-sparcv9.S aest4-sparcv9.S aesfx-sparcv9.S + $AESDEF_sparcv9=AES_ASM + + $AESASM_mips32=aes_cbc.c aes-mips.S + $AESDEF_mips32=AES_ASM + $AESASM_mips64=$AESASM_mips32 + $AESDEF_mips64=$AESDEF_mips32 + + $AESASM_s390x=aes-s390x.S + # aes-390x.S implements AES_ctr32_encrypt and AES_xts_[en|de]crypt + $AESDEF_s390x=AES_ASM AES_CTR_ASM AES_XTS_ASM + + $AESASM_armv4=aes_cbc.c aes-armv4.S bsaes-armv7.S aesv8-armx.S + $AESDEF_armv4=AES_ASM BSAES_ASM + $AESASM_aarch64=aes_core.c aes_cbc.c aesv8-armx.S vpaes-armv8.S + $AESDEF_aarch64=VPAES_ASM + + $AESASM_parisc11=aes_core.c aes_cbc.c aes-parisc.s + $AESDEF_parisc11=AES_ASM + $AESASM_parisc20_64=$AESASM_parisc11 + $AESDEF_parisc20_64=$AESDEF_parisc11 + + $AESASM_ppc32=aes_core.c aes_cbc.c aes-ppc.s vpaes-ppc.s aesp8-ppc.s + $AESDEF_ppc32=AES_ASM VPAES_ASM + $AESASM_ppc64=$AESASM_ppc32 + $AESDEF_ppc64=$AESDEF_ppc32 + + $AESASM_c64xplus=aes-c64xplus.s aes_cbc.c + # aes-c64xplus.s implements AES_ctr32_encrypt + $AESDEF_c64xplus=AES_ASM AES_CTR_ASM + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$AESASM_{- $target{asm_arch} -}] + $AESASM=$AESASM_{- $target{asm_arch} -} + $AESDEF=$AESDEF_{- $target{asm_arch} -} + IF[{- !$disabled{sse2} -}] + $AESASM=$AESASM $AESASM_{- $target{asm_arch} -}_sse2 + $AESDEF=$AESDEF $AESDEF_{- $target{asm_arch} -}_sse2 + ENDIF + ENDIF +ENDIF + +$COMMON=aes_misc.c aes_ecb.c $AESASM +SOURCE[../../libcrypto]=$COMMON aes_cfb.c aes_ofb.c aes_ige.c aes_wrap.c +DEFINE[../../libcrypto]=$AESDEF +SOURCE[../../providers/fips]=$COMMON +DEFINE[../../providers/fips]=$AESDEF GENERATE[aes-ia64.s]=asm/aes-ia64.S diff --git a/crypto/asn1/a_sign.c b/crypto/asn1/a_sign.c index 97e8efcb..e2ef60f7 100644 --- a/crypto/asn1/a_sign.c +++ b/crypto/asn1/a_sign.c @@ -145,7 +145,7 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it, unsigned char *buf_in = NULL, *buf_out = NULL; size_t inl = 0, outl = 0, outll = 0; int signid, paramtype, buf_len = 0; - int rv; + int rv, pkey_id; type = EVP_MD_CTX_md(ctx); pkey = EVP_PKEY_CTX_get0_pkey(EVP_MD_CTX_pkey_ctx(ctx)); @@ -184,9 +184,14 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it, ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ASN1_R_CONTEXT_NOT_INITIALISED); goto err; } - if (!OBJ_find_sigid_by_algs(&signid, - EVP_MD_nid(type), - pkey->ameth->pkey_id)) { + + pkey_id = +#ifndef OPENSSL_NO_SM2 + EVP_PKEY_id(pkey) == NID_sm2 ? NID_sm2 : +#endif + pkey->ameth->pkey_id; + + if (!OBJ_find_sigid_by_algs(&signid, EVP_MD_nid(type), pkey_id)) { ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); goto err; diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index 60df8991..491909b0 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c @@ -67,7 +67,7 @@ static void determine_days(struct tm *tm) } c = y / 100; y %= 100; - /* Zeller's congruance */ + /* Zeller's congruence */ tm->tm_wday = (d + (13 * m) / 5 + y + y / 4 + c / 4 + 5 * c + 6) % 7; } diff --git a/crypto/asn1/a_type.c b/crypto/asn1/a_type.c index 15844013..9b8810cd 100644 --- a/crypto/asn1/a_type.c +++ b/crypto/asn1/a_type.c @@ -15,7 +15,9 @@ int ASN1_TYPE_get(const ASN1_TYPE *a) { - if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL)) + if (a->type == V_ASN1_BOOLEAN + || a->type == V_ASN1_NULL + || a->value.ptr != NULL) return a->type; else return 0; @@ -23,7 +25,9 @@ int ASN1_TYPE_get(const ASN1_TYPE *a) void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value) { - if (a->value.ptr != NULL) { + if (a->type != V_ASN1_BOOLEAN + && a->type != V_ASN1_NULL + && a->value.ptr != NULL) { ASN1_TYPE **tmp_a = &a; asn1_primitive_free((ASN1_VALUE **)tmp_a, NULL, 0); } diff --git a/crypto/async/async.c b/crypto/async/async.c index 53d288ca..43b16a7b 100644 --- a/crypto/async/async.c +++ b/crypto/async/async.c @@ -30,11 +30,13 @@ static CRYPTO_THREAD_LOCAL ctxkey; static CRYPTO_THREAD_LOCAL poolkey; +static void async_delete_thread_state(void *arg); + static async_ctx *async_ctx_new(void) { async_ctx *nctx; - if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) + if (!ossl_init_thread_start(NULL, NULL, async_delete_thread_state)) return NULL; nctx = OPENSSL_malloc(sizeof(*nctx)); @@ -326,7 +328,7 @@ int ASYNC_init_thread(size_t max_size, size_t init_size) if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) return 0; - if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) + if (!ossl_init_thread_start(NULL, NULL, async_delete_thread_state)) return 0; pool = OPENSSL_zalloc(sizeof(*pool)); @@ -374,7 +376,8 @@ err: return 0; } -void async_delete_thread_state(void) +/* TODO(3.0): arg ignored for now */ +static void async_delete_thread_state(void *arg) { async_pool *pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey); @@ -393,7 +396,7 @@ void ASYNC_cleanup_thread(void) if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) return; - async_delete_thread_state(); + async_delete_thread_state(NULL); } ASYNC_JOB *ASYNC_get_current_job(void) diff --git a/crypto/bf/build.info b/crypto/bf/build.info index 29adc8ce..cc06212d 100644 --- a/crypto/bf/build.info +++ b/crypto/bf/build.info @@ -1,6 +1,17 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c \ - {- $target{bf_asm_src} -} + +$BFASM=bf_enc.c +IF[{- !$disabled{asm} -}] + $BFASM_x86=bf-586.s + + # Now that we have defined all the arch specific variables, use the + # appropriate one + IF[$BFASM_{- $target{asm_arch} -}] + $BFASM=$BFASM_{- $target{asm_arch} -} + ENDIF +ENDIF + +SOURCE[../../libcrypto]=bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c $BFASM GENERATE[bf-586.s]=asm/bf-586.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR) diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c index 0f398243..d7fcf2fc 100644 --- a/crypto/bio/b_addr.c +++ b/crypto/bio/b_addr.c @@ -696,6 +696,7 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type, /* Note that |res| SHOULD be a 'struct addrinfo **' thanks to * macro magic in bio_lcl.h */ + retry: switch ((gai_ret = getaddrinfo(host, service, &hints, res))) { # ifdef EAI_SYSTEM case EAI_SYSTEM: @@ -706,6 +707,19 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type, case 0: ret = 1; /* Success */ break; +# if (defined(EAI_FAMILY) || defined(EAI_ADDRFAMILY)) && defined(AI_ADDRCONFIG) +# ifdef EAI_FAMILY + case EAI_FAMILY: +# endif +# ifdef EAI_ADDRFAMILY + case EAI_ADDRFAMILY: +# endif + if (hints.ai_flags & AI_ADDRCONFIG) { + hints.ai_flags &= ~AI_ADDRCONFIG; + goto retry; + } +# endif + /* fall through */ default: BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_SYS_LIB); ERR_add_error_data(1, gai_strerror(gai_ret)); diff --git a/crypto/bio/bio_lcl.h b/crypto/bio/bio_lcl.h index 0fea5d00..95f3a937 100644 --- a/crypto/bio/bio_lcl.h +++ b/crypto/bio/bio_lcl.h @@ -152,7 +152,7 @@ extern CRYPTO_RWLOCK *bio_type_lock; void bio_sock_cleanup_int(void); -#if BIO_FLAGS_UPLINK==0 +#if BIO_FLAGS_UPLINK_INTERNAL==0 /* Shortcut UPLINK calls on most platforms... */ # define UP_stdin stdin # define UP_stdout stdout diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index cc8080c5..941429a3 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -784,7 +784,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr) * reasons. When BIO_CTRL_DGRAM_SET_PEEK_MODE was first defined its value * was incorrectly clashing with BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE. The * value has been updated to a non-clashing value. However to preserve - * binary compatiblity we now respond to both the old value and the new one + * binary compatibility we now respond to both the old value and the new one */ case BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE: case BIO_CTRL_DGRAM_SET_PEEK_MODE: diff --git a/crypto/bio/bss_fd.c b/crypto/bio/bss_fd.c index db470fbf..c599dada 100644 --- a/crypto/bio/bss_fd.c +++ b/crypto/bio/bss_fd.c @@ -94,7 +94,7 @@ static int fd_new(BIO *bi) bi->init = 0; bi->num = -1; bi->ptr = NULL; - bi->flags = BIO_FLAGS_UPLINK; /* essentially redundant */ + bi->flags = BIO_FLAGS_UPLINK_INTERNAL; /* essentially redundant */ return 1; } @@ -107,7 +107,7 @@ static int fd_free(BIO *a) UP_close(a->num); } a->init = 0; - a->flags = BIO_FLAGS_UPLINK; + a->flags = BIO_FLAGS_UPLINK_INTERNAL; } return 1; } diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c index 93ba0069..0e07632f 100644 --- a/crypto/bio/bss_file.c +++ b/crypto/bio/bss_file.c @@ -86,8 +86,8 @@ BIO *BIO_new_file(const char *filename, const char *mode) return NULL; } - BIO_clear_flags(ret, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage - * UPLINK */ + /* we did fopen -> we disengage UPLINK */ + BIO_clear_flags(ret, BIO_FLAGS_UPLINK_INTERNAL); BIO_set_fp(ret, file, fp_flags); return ret; } @@ -100,7 +100,7 @@ BIO *BIO_new_fp(FILE *stream, int close_flag) return NULL; /* redundant flag, left for documentation purposes */ - BIO_set_flags(ret, BIO_FLAGS_UPLINK); + BIO_set_flags(ret, BIO_FLAGS_UPLINK_INTERNAL); BIO_set_fp(ret, stream, close_flag); return ret; } @@ -115,7 +115,7 @@ static int file_new(BIO *bi) bi->init = 0; bi->num = 0; bi->ptr = NULL; - bi->flags = BIO_FLAGS_UPLINK; /* default to UPLINK */ + bi->flags = BIO_FLAGS_UPLINK_INTERNAL; /* default to UPLINK */ return 1; } @@ -125,12 +125,12 @@ static int file_free(BIO *a) return 0; if (a->shutdown) { if ((a->init) && (a->ptr != NULL)) { - if (a->flags & BIO_FLAGS_UPLINK) + if (a->flags & BIO_FLAGS_UPLINK_INTERNAL) UP_fclose(a->ptr); else fclose(a->ptr); a->ptr = NULL; - a->flags = BIO_FLAGS_UPLINK; + a->flags = BIO_FLAGS_UPLINK_INTERNAL; } a->init = 0; } @@ -142,13 +142,13 @@ static int file_read(BIO *b, char *out, int outl) int ret = 0; if (b->init && (out != NULL)) { - if (b->flags & BIO_FLAGS_UPLINK) + if (b->flags & BIO_FLAGS_UPLINK_INTERNAL) ret = UP_fread(out, 1, (int)outl, b->ptr); else ret = fread(out, 1, (int)outl, (FILE *)b->ptr); if (ret == 0 - && (b->flags & BIO_FLAGS_UPLINK) ? UP_ferror((FILE *)b->ptr) : - ferror((FILE *)b->ptr)) { + && (b->flags & BIO_FLAGS_UPLINK_INTERNAL + ? UP_ferror((FILE *)b->ptr) : ferror((FILE *)b->ptr))) { SYSerr(SYS_F_FREAD, get_last_sys_error()); BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB); ret = -1; @@ -162,7 +162,7 @@ static int file_write(BIO *b, const char *in, int inl) int ret = 0; if (b->init && (in != NULL)) { - if (b->flags & BIO_FLAGS_UPLINK) + if (b->flags & BIO_FLAGS_UPLINK_INTERNAL) ret = UP_fwrite(in, (int)inl, 1, b->ptr); else ret = fwrite(in, (int)inl, 1, (FILE *)b->ptr); @@ -189,20 +189,20 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) switch (cmd) { case BIO_C_FILE_SEEK: case BIO_CTRL_RESET: - if (b->flags & BIO_FLAGS_UPLINK) + if (b->flags & BIO_FLAGS_UPLINK_INTERNAL) ret = (long)UP_fseek(b->ptr, num, 0); else ret = (long)fseek(fp, num, 0); break; case BIO_CTRL_EOF: - if (b->flags & BIO_FLAGS_UPLINK) + if (b->flags & BIO_FLAGS_UPLINK_INTERNAL) ret = (long)UP_feof(fp); else ret = (long)feof(fp); break; case BIO_C_FILE_TELL: case BIO_CTRL_INFO: - if (b->flags & BIO_FLAGS_UPLINK) + if (b->flags & BIO_FLAGS_UPLINK_INTERNAL) ret = UP_ftell(b->ptr); else ret = ftell(fp); @@ -212,22 +212,22 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) b->shutdown = (int)num & BIO_CLOSE; b->ptr = ptr; b->init = 1; -# if BIO_FLAGS_UPLINK!=0 +# if BIO_FLAGS_UPLINK_INTERNAL!=0 # if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES) # define _IOB_ENTRIES 20 # endif /* Safety net to catch purely internal BIO_set_fp calls */ # if defined(_MSC_VER) && _MSC_VER>=1900 if (ptr == stdin || ptr == stdout || ptr == stderr) - BIO_clear_flags(b, BIO_FLAGS_UPLINK); + BIO_clear_flags(b, BIO_FLAGS_UPLINK_INTERNAL); # elif defined(_IOB_ENTRIES) if ((size_t)ptr >= (size_t)stdin && (size_t)ptr < (size_t)(stdin + _IOB_ENTRIES)) - BIO_clear_flags(b, BIO_FLAGS_UPLINK); + BIO_clear_flags(b, BIO_FLAGS_UPLINK_INTERNAL); # endif # endif # ifdef UP_fsetmod - if (b->flags & BIO_FLAGS_UPLINK) + if (b->flags & BIO_FLAGS_UPLINK_INTERNAL) UP_fsetmod(b->ptr, (char)((num & BIO_FP_TEXT) ? 't' : 'b')); else # endif @@ -296,8 +296,8 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) } b->ptr = fp; b->init = 1; - BIO_clear_flags(b, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage - * UPLINK */ + /* we did fopen -> we disengage UPLINK */ + BIO_clear_flags(b, BIO_FLAGS_UPLINK_INTERNAL); break; case BIO_C_GET_FILE_PTR: /* the ptr parameter is actually a FILE ** in this case. */ @@ -313,7 +313,7 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) b->shutdown = (int)num; break; case BIO_CTRL_FLUSH: - st = b->flags & BIO_FLAGS_UPLINK + st = b->flags & BIO_FLAGS_UPLINK_INTERNAL ? UP_fflush(b->ptr) : fflush((FILE *)b->ptr); if (st == EOF) { SYSerr(SYS_F_FFLUSH, get_last_sys_error()); @@ -342,7 +342,7 @@ static int file_gets(BIO *bp, char *buf, int size) int ret = 0; buf[0] = '\0'; - if (bp->flags & BIO_FLAGS_UPLINK) { + if (bp->flags & BIO_FLAGS_UPLINK_INTERNAL) { if (!UP_fgets(buf, size, bp->ptr)) goto err; } else { diff --git a/crypto/bio/bss_mem.c b/crypto/bio/bss_mem.c index a7f2bfba..19a3bd88 100644 --- a/crypto/bio/bss_mem.c +++ b/crypto/bio/bss_mem.c @@ -259,9 +259,7 @@ static long mem_ctrl(BIO *b, int cmd, long num, void *ptr) bm = bbm->buf; if (bm->data != NULL) { if (!(b->flags & BIO_FLAGS_MEM_RDONLY)) { - if (b->flags & BIO_FLAGS_NONCLEAR_RST) { - bm->length = bm->max; - } else { + if (!(b->flags & BIO_FLAGS_NONCLEAR_RST)) { memset(bm->data, 0, bm->max); bm->length = 0; } diff --git a/crypto/blake2/blake2b_mac.c b/crypto/blake2/blake2b_mac.c index 71b85178..f6025b1f 100644 --- a/crypto/blake2/blake2b_mac.c +++ b/crypto/blake2/blake2b_mac.c @@ -10,7 +10,7 @@ #ifndef OPENSSL_NO_BLAKE2 # include -# include "blake2_locl.h" +# include "internal/blake2.h" # include "internal/cryptlib.h" # include "internal/evp_int.h" @@ -26,7 +26,7 @@ static EVP_MAC_IMPL *blake2b_mac_new(void) EVP_MAC_IMPL *macctx = OPENSSL_zalloc(sizeof(*macctx)); if (macctx != NULL) { blake2b_param_init(&macctx->params); - /* ctx initialization is deferred to BLAKE2b_Init() */ + /* ctx initialization is deferred to blake2b_init() */ } return macctx; } @@ -39,10 +39,16 @@ static void blake2b_mac_free(EVP_MAC_IMPL *macctx) } } -static int blake2b_mac_copy(EVP_MAC_IMPL *dst, EVP_MAC_IMPL *src) +static EVP_MAC_IMPL *blake2b_mac_dup(const EVP_MAC_IMPL *src) { + EVP_MAC_IMPL *dst; + + dst = OPENSSL_zalloc(sizeof(*dst)); + if (dst == NULL) + return NULL; + *dst = *src; - return 1; + return dst; } static int blake2b_mac_init(EVP_MAC_IMPL *macctx) @@ -53,18 +59,18 @@ static int blake2b_mac_init(EVP_MAC_IMPL *macctx) return 0; } - return BLAKE2b_Init_key(&macctx->ctx, &macctx->params, macctx->key); + return blake2b_init_key(&macctx->ctx, &macctx->params, macctx->key); } static int blake2b_mac_update(EVP_MAC_IMPL *macctx, const unsigned char *data, size_t datalen) { - return BLAKE2b_Update(&macctx->ctx, data, datalen); + return blake2b_update(&macctx->ctx, data, datalen); } static int blake2b_mac_final(EVP_MAC_IMPL *macctx, unsigned char *out) { - return BLAKE2b_Final(out, &macctx->ctx); + return blake2b_final(out, &macctx->ctx); } /* @@ -177,7 +183,7 @@ static size_t blake2b_mac_size(EVP_MAC_IMPL *macctx) const EVP_MAC blake2b_mac_meth = { EVP_MAC_BLAKE2B, blake2b_mac_new, - blake2b_mac_copy, + blake2b_mac_dup, blake2b_mac_free, blake2b_mac_size, blake2b_mac_init, diff --git a/crypto/blake2/blake2s_mac.c b/crypto/blake2/blake2s_mac.c index d40778cb..9ce8db13 100644 --- a/crypto/blake2/blake2s_mac.c +++ b/crypto/blake2/blake2s_mac.c @@ -10,7 +10,7 @@ #ifndef OPENSSL_NO_BLAKE2 # include -# include "blake2_locl.h" +# include "internal/blake2.h" # include "internal/cryptlib.h" # include "internal/evp_int.h" @@ -39,10 +39,16 @@ static void blake2s_mac_free(EVP_MAC_IMPL *macctx) } } -static int blake2s_mac_copy(EVP_MAC_IMPL *dst, EVP_MAC_IMPL *src) +static EVP_MAC_IMPL *blake2s_mac_dup(const EVP_MAC_IMPL *src) { + EVP_MAC_IMPL *dst; + + dst = OPENSSL_malloc(sizeof(*dst)); + if (dst == NULL) + return NULL; + *dst = *src; - return 1; + return dst; } static int blake2s_mac_init(EVP_MAC_IMPL *macctx) @@ -53,18 +59,18 @@ static int blake2s_mac_init(EVP_MAC_IMPL *macctx) return 0; } - return BLAKE2s_Init_key(&macctx->ctx, &macctx->params, macctx->key); + return blake2s_init_key(&macctx->ctx, &macctx->params, macctx->key); } static int blake2s_mac_update(EVP_MAC_IMPL *macctx, const unsigned char *data, size_t datalen) { - return BLAKE2s_Update(&macctx->ctx, data, datalen); + return blake2s_update(&macctx->ctx, data, datalen); } static int blake2s_mac_final(EVP_MAC_IMPL *macctx, unsigned char *out) { - return BLAKE2s_Final(out, &macctx->ctx); + return blake2s_final(out, &macctx->ctx); } /* @@ -177,7 +183,7 @@ static size_t blake2s_mac_size(EVP_MAC_IMPL *macctx) const EVP_MAC blake2s_mac_meth = { EVP_MAC_BLAKE2S, blake2s_mac_new, - blake2s_mac_copy, + blake2s_mac_dup, blake2s_mac_free, blake2s_mac_size, blake2s_mac_init, diff --git a/crypto/blake2/build.info b/crypto/blake2/build.info index ab72ef2a..f02bf9a6 100644 --- a/crypto/blake2/build.info +++ b/crypto/blake2/build.info @@ -1,3 +1,3 @@ LIBS=../../libcrypto SOURCE[../../libcrypto]=\ - blake2b.c blake2s.c blake2b_mac.c blake2s_mac.c m_blake2b.c m_blake2s.c + blake2b_mac.c blake2s_mac.c m_blake2b.c m_blake2s.c diff --git a/crypto/blake2/m_blake2b.c b/crypto/blake2/m_blake2b.c index 2fb80f8b..b429d2d7 100644 --- a/crypto/blake2/m_blake2b.c +++ b/crypto/blake2/m_blake2b.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,37 +7,26 @@ * https://www.openssl.org/source/license.html */ -/* - * Derived from the BLAKE2 reference implementation written by Samuel Neves. - * Copyright 2012, Samuel Neves - * More information about the BLAKE2 hash function and its implementations - * can be found at https://blake2.net. - */ - -#include "internal/cryptlib.h" - #ifndef OPENSSL_NO_BLAKE2 -# include -# include -# include "blake2_locl.h" +# include +# include # include "internal/evp_int.h" +# include "internal/blake2.h" static int init(EVP_MD_CTX *ctx) { - BLAKE2B_PARAM P; - blake2b_param_init(&P); - return BLAKE2b_Init(EVP_MD_CTX_md_data(ctx), &P); + return blake2b512_init(EVP_MD_CTX_md_data(ctx)); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { - return BLAKE2b_Update(EVP_MD_CTX_md_data(ctx), data, count); + return blake2b_update(EVP_MD_CTX_md_data(ctx), data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { - return BLAKE2b_Final(md, EVP_MD_CTX_md_data(ctx)); + return blake2b_final(md, EVP_MD_CTX_md_data(ctx)); } static const EVP_MD blake2b_md = { @@ -58,4 +47,4 @@ const EVP_MD *EVP_blake2b512(void) { return &blake2b_md; } -#endif +#endif /* OPENSSL_NO_BLAKE2 */ diff --git a/crypto/blake2/m_blake2s.c b/crypto/blake2/m_blake2s.c index 8ff17275..dd4b68fa 100644 --- a/crypto/blake2/m_blake2s.c +++ b/crypto/blake2/m_blake2s.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,37 +7,26 @@ * https://www.openssl.org/source/license.html */ -/* - * Derived from the BLAKE2 reference implementation written by Samuel Neves. - * Copyright 2012, Samuel Neves - * More information about the BLAKE2 hash function and its implementations - * can be found at https://blake2.net. - */ - -#include "internal/cryptlib.h" - #ifndef OPENSSL_NO_BLAKE2 -# include -# include -# include "blake2_locl.h" +# include +# include # include "internal/evp_int.h" +# include "internal/blake2.h" static int init(EVP_MD_CTX *ctx) { - BLAKE2S_PARAM P; - blake2s_param_init(&P); - return BLAKE2s_Init(EVP_MD_CTX_md_data(ctx), &P); + return blake2s256_init(EVP_MD_CTX_md_data(ctx)); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { - return BLAKE2s_Update(EVP_MD_CTX_md_data(ctx), data, count); + return blake2s_update(EVP_MD_CTX_md_data(ctx), data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { - return BLAKE2s_Final(md, EVP_MD_CTX_md_data(ctx)); + return blake2s_final(md, EVP_MD_CTX_md_data(ctx)); } static const EVP_MD blake2s_md = { @@ -58,4 +47,4 @@ const EVP_MD *EVP_blake2s256(void) { return &blake2s_md; } -#endif +#endif /* OPENSSL_NO_BLAKE2 */ diff --git a/crypto/bn/asm/mips.pl b/crypto/bn/asm/mips.pl index bff624d1..35971769 100644 --- a/crypto/bn/asm/mips.pl +++ b/crypto/bn/asm/mips.pl @@ -800,7 +800,7 @@ $code.=<<___; #if 0 /* * The bn_div_3_words entry point is re-used for constant-time interface. - * Implementation is retained as hystorical reference. + * Implementation is retained as historical reference. */ .align 5 .globl bn_div_3_words diff --git a/crypto/bn/bn_conv.c b/crypto/bn/bn_conv.c new file mode 100644 index 00000000..9219fa4c --- /dev/null +++ b/crypto/bn/bn_conv.c @@ -0,0 +1,287 @@ +/* + * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include "internal/ctype.h" +#include "bn_lcl.h" + +static const char Hex[] = "0123456789ABCDEF"; + +/* Must 'OPENSSL_free' the returned data */ +char *BN_bn2hex(const BIGNUM *a) +{ + int i, j, v, z = 0; + char *buf; + char *p; + + if (BN_is_zero(a)) + return OPENSSL_strdup("0"); + buf = OPENSSL_malloc(a->top * BN_BYTES * 2 + 2); + if (buf == NULL) { + BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE); + goto err; + } + p = buf; + if (a->neg) + *p++ = '-'; + for (i = a->top - 1; i >= 0; i--) { + for (j = BN_BITS2 - 8; j >= 0; j -= 8) { + /* strip leading zeros */ + v = (int)((a->d[i] >> j) & 0xff); + if (z || v != 0) { + *p++ = Hex[v >> 4]; + *p++ = Hex[v & 0x0f]; + z = 1; + } + } + } + *p = '\0'; + err: + return buf; +} + +#ifndef FIPS_MODE +/* No BIO_snprintf in FIPS_MODE */ +/* Must 'OPENSSL_free' the returned data */ +char *BN_bn2dec(const BIGNUM *a) +{ + int i = 0, num, ok = 0, n, tbytes; + char *buf = NULL; + char *p; + BIGNUM *t = NULL; + BN_ULONG *bn_data = NULL, *lp; + int bn_data_num; + + /*- + * get an upper bound for the length of the decimal integer + * num <= (BN_num_bits(a) + 1) * log(2) + * <= 3 * BN_num_bits(a) * 0.101 + log(2) + 1 (rounding error) + * <= 3 * BN_num_bits(a) / 10 + 3 * BN_num_bits / 1000 + 1 + 1 + */ + i = BN_num_bits(a) * 3; + num = (i / 10 + i / 1000 + 1) + 1; + tbytes = num + 3; /* negative and terminator and one spare? */ + bn_data_num = num / BN_DEC_NUM + 1; + bn_data = OPENSSL_malloc(bn_data_num * sizeof(BN_ULONG)); + buf = OPENSSL_malloc(tbytes); + if (buf == NULL || bn_data == NULL) { + BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE); + goto err; + } + if ((t = BN_dup(a)) == NULL) + goto err; + + p = buf; + lp = bn_data; + if (BN_is_zero(t)) { + *p++ = '0'; + *p++ = '\0'; + } else { + if (BN_is_negative(t)) + *p++ = '-'; + + while (!BN_is_zero(t)) { + if (lp - bn_data >= bn_data_num) + goto err; + *lp = BN_div_word(t, BN_DEC_CONV); + if (*lp == (BN_ULONG)-1) + goto err; + lp++; + } + lp--; + /* + * We now have a series of blocks, BN_DEC_NUM chars in length, where + * the last one needs truncation. The blocks need to be reversed in + * order. + */ + n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT1, *lp); + if (n < 0) + goto err; + p += n; + while (lp != bn_data) { + lp--; + n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT2, *lp); + if (n < 0) + goto err; + p += n; + } + } + ok = 1; + err: + OPENSSL_free(bn_data); + BN_free(t); + if (ok) + return buf; + OPENSSL_free(buf); + return NULL; +} +#endif + +int BN_hex2bn(BIGNUM **bn, const char *a) +{ + BIGNUM *ret = NULL; + BN_ULONG l = 0; + int neg = 0, h, m, i, j, k, c; + int num; + + if (a == NULL || *a == '\0') + return 0; + + if (*a == '-') { + neg = 1; + a++; + } + + for (i = 0; i <= INT_MAX / 4 && ossl_isxdigit(a[i]); i++) + continue; + + if (i == 0 || i > INT_MAX / 4) + goto err; + + num = i + neg; + if (bn == NULL) + return num; + + /* a is the start of the hex digits, and it is 'i' long */ + if (*bn == NULL) { + if ((ret = BN_new()) == NULL) + return 0; + } else { + ret = *bn; + BN_zero(ret); + } + + /* i is the number of hex digits */ + if (bn_expand(ret, i * 4) == NULL) + goto err; + + j = i; /* least significant 'hex' */ + m = 0; + h = 0; + while (j > 0) { + m = (BN_BYTES * 2 <= j) ? BN_BYTES * 2 : j; + l = 0; + for (;;) { + c = a[j - m]; + k = OPENSSL_hexchar2int(c); + if (k < 0) + k = 0; /* paranoia */ + l = (l << 4) | k; + + if (--m <= 0) { + ret->d[h++] = l; + break; + } + } + j -= BN_BYTES * 2; + } + ret->top = h; + bn_correct_top(ret); + + *bn = ret; + bn_check_top(ret); + /* Don't set the negative flag if it's zero. */ + if (ret->top != 0) + ret->neg = neg; + return num; + err: + if (*bn == NULL) + BN_free(ret); + return 0; +} + +int BN_dec2bn(BIGNUM **bn, const char *a) +{ + BIGNUM *ret = NULL; + BN_ULONG l = 0; + int neg = 0, i, j; + int num; + + if (a == NULL || *a == '\0') + return 0; + if (*a == '-') { + neg = 1; + a++; + } + + for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++) + continue; + + if (i == 0 || i > INT_MAX / 4) + goto err; + + num = i + neg; + if (bn == NULL) + return num; + + /* + * a is the start of the digits, and it is 'i' long. We chop it into + * BN_DEC_NUM digits at a time + */ + if (*bn == NULL) { + if ((ret = BN_new()) == NULL) + return 0; + } else { + ret = *bn; + BN_zero(ret); + } + + /* i is the number of digits, a bit of an over expand */ + if (bn_expand(ret, i * 4) == NULL) + goto err; + + j = BN_DEC_NUM - i % BN_DEC_NUM; + if (j == BN_DEC_NUM) + j = 0; + l = 0; + while (--i >= 0) { + l *= 10; + l += *a - '0'; + a++; + if (++j == BN_DEC_NUM) { + if (!BN_mul_word(ret, BN_DEC_CONV) + || !BN_add_word(ret, l)) + goto err; + l = 0; + j = 0; + } + } + + bn_correct_top(ret); + *bn = ret; + bn_check_top(ret); + /* Don't set the negative flag if it's zero. */ + if (ret->top != 0) + ret->neg = neg; + return num; + err: + if (*bn == NULL) + BN_free(ret); + return 0; +} + +int BN_asc2bn(BIGNUM **bn, const char *a) +{ + const char *p = a; + + if (*p == '-') + p++; + + if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x')) { + if (!BN_hex2bn(bn, p + 2)) + return 0; + } else { + if (!BN_dec2bn(bn, p)) + return 0; + } + /* Don't set the negative flag if it's zero. */ + if (*a == '-' && (*bn)->top != 0) + (*bn)->neg = 1; + return 1; +} diff --git a/crypto/bn/bn_ctx.c b/crypto/bn/bn_ctx.c index 62e29b5d..cc3c3034 100644 --- a/crypto/bn/bn_ctx.c +++ b/crypto/bn/bn_ctx.c @@ -86,8 +86,11 @@ struct bignum_ctx { int too_many; /* Flags. */ int flags; + /* The library context */ + OPENSSL_CTX *libctx; }; +#ifndef FIPS_MODE /* Debugging functionality */ static void ctxdbg(BIO *channel, const char *text, BN_CTX *ctx) { @@ -116,39 +119,54 @@ static void ctxdbg(BIO *channel, const char *text, BN_CTX *ctx) BIO_printf(channel, "\n"); } -#define CTXDBG(str, ctx) \ +# define CTXDBG(str, ctx) \ OSSL_TRACE_BEGIN(BN_CTX) { \ ctxdbg(trc_out, str, ctx); \ } OSSL_TRACE_END(BN_CTX) +#else +/* TODO(3.0): Consider if we want to do this in FIPS mode */ +# define CTXDBG(str, ctx) do {} while(0) +#endif /* FIPS_MODE */ - -BN_CTX *BN_CTX_new(void) +BN_CTX *BN_CTX_new_ex(OPENSSL_CTX *ctx) { BN_CTX *ret; if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) { - BNerr(BN_F_BN_CTX_NEW, ERR_R_MALLOC_FAILURE); + BNerr(BN_F_BN_CTX_NEW_EX, ERR_R_MALLOC_FAILURE); return NULL; } /* Initialise the structure */ BN_POOL_init(&ret->pool); BN_STACK_init(&ret->stack); + ret->libctx = ctx; return ret; } -BN_CTX *BN_CTX_secure_new(void) +BN_CTX *BN_CTX_new(void) { - BN_CTX *ret = BN_CTX_new(); + return BN_CTX_new_ex(NULL); +} + +BN_CTX *BN_CTX_secure_new_ex(OPENSSL_CTX *ctx) +{ + BN_CTX *ret = BN_CTX_new_ex(ctx); if (ret != NULL) ret->flags = BN_FLG_SECURE; return ret; } +BN_CTX *BN_CTX_secure_new(void) +{ + return BN_CTX_secure_new_ex(NULL); +} + void BN_CTX_free(BN_CTX *ctx) { if (ctx == NULL) return; +#ifndef FIPS_MODE OSSL_TRACE_BEGIN(BN_CTX) { BN_POOL_ITEM *pool = ctx->pool.head; BIO_printf(trc_out, @@ -163,6 +181,7 @@ void BN_CTX_free(BN_CTX *ctx) } BIO_printf(trc_out, "\n"); } OSSL_TRACE_END(BN_CTX); +#endif BN_STACK_finish(&ctx->stack); BN_POOL_finish(&ctx->pool); OPENSSL_free(ctx); @@ -226,6 +245,13 @@ BIGNUM *BN_CTX_get(BN_CTX *ctx) return ret; } +OPENSSL_CTX *bn_get_lib_ctx(BN_CTX *ctx) +{ + if (ctx == NULL) + return NULL; + return ctx->libctx; +} + /************/ /* BN_STACK */ /************/ diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c index 750c30ed..88fcaf7f 100644 --- a/crypto/bn/bn_div.c +++ b/crypto/bn/bn_div.c @@ -258,7 +258,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, * * - availability of constant-time bn_div_3_words; * - dividend is at least as "wide" as divisor, limb-wise, zero-padded - * if so requied, which shouldn't be a privacy problem, because + * if so required, which shouldn't be a privacy problem, because * divisor's length is considered public; */ int bn_div_fixed_top(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, diff --git a/crypto/bn/bn_err.c b/crypto/bn/bn_err.c index b988646f..a28443c7 100644 --- a/crypto/bn/bn_err.c +++ b/crypto/bn/bn_err.c @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -29,6 +29,7 @@ static const ERR_STRING_DATA BN_str_functs[] = { {ERR_PACK(ERR_LIB_BN, BN_F_BN_COMPUTE_WNAF, 0), "bn_compute_wNAF"}, {ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_GET, 0), "BN_CTX_get"}, {ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_NEW, 0), "BN_CTX_new"}, + {ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_NEW_EX, 0), "BN_CTX_new_ex"}, {ERR_PACK(ERR_LIB_BN, BN_F_BN_CTX_START, 0), "BN_CTX_start"}, {ERR_PACK(ERR_LIB_BN, BN_F_BN_DIV, 0), "BN_div"}, {ERR_PACK(ERR_LIB_BN, BN_F_BN_DIV_RECP, 0), "BN_div_recp"}, @@ -95,6 +96,7 @@ static const ERR_STRING_DATA BN_str_reasons[] = { {ERR_PACK(ERR_LIB_BN, 0, BN_R_NOT_INITIALIZED), "not initialized"}, {ERR_PACK(ERR_LIB_BN, 0, BN_R_NO_INVERSE), "no inverse"}, {ERR_PACK(ERR_LIB_BN, 0, BN_R_NO_SOLUTION), "no solution"}, + {ERR_PACK(ERR_LIB_BN, 0, BN_R_NO_SUITABLE_DIGEST), "no suitable digest"}, {ERR_PACK(ERR_LIB_BN, 0, BN_R_PRIVATE_KEY_TOO_LARGE), "private key too large"}, {ERR_PACK(ERR_LIB_BN, 0, BN_R_P_IS_NOT_PRIME), "p is not prime"}, diff --git a/crypto/bn/bn_lcl.h b/crypto/bn/bn_lcl.h index 5c0413c2..160f2f5a 100644 --- a/crypto/bn/bn_lcl.h +++ b/crypto/bn/bn_lcl.h @@ -295,7 +295,7 @@ struct bn_gencb_st { (b) > 23 ? 3 : 1) /* - * BN_mod_exp_mont_conttime is based on the assumption that the L1 data cache + * BN_mod_exp_mont_consttime is based on the assumption that the L1 data cache * line width of the target processor is at least the following value. */ # define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH ( 64 ) @@ -668,4 +668,6 @@ static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits) return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2); } +OPENSSL_CTX *bn_get_lib_ctx(BN_CTX *ctx); + #endif diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c index 03402c2c..47e2f235 100644 --- a/crypto/bn/bn_prime.c +++ b/crypto/bn/bn_prime.c @@ -98,8 +98,12 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, /* There are no prime numbers this small. */ BNerr(BN_F_BN_GENERATE_PRIME_EX, BN_R_BITS_TOO_SMALL); return 0; - } else if (bits == 2 && safe) { - /* The smallest safe prime (7) is three bits. */ + } else if (add == NULL && safe && bits < 6 && bits != 3) { + /* + * The smallest safe prime (7) is three bits. + * But the following two safe primes with less than 6 bits (11, 23) + * are unreachable for BN_rand with BN_RAND_TOP_TWO. + */ BNerr(BN_F_BN_GENERATE_PRIME_EX, BN_R_BITS_TOO_SMALL); return 0; } diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c index 6c1e3f64..2274b85c 100644 --- a/crypto/bn/bn_print.c +++ b/crypto/bn/bn_print.c @@ -8,285 +8,12 @@ */ #include -#include "internal/ctype.h" -#include -#include "internal/cryptlib.h" -#include +#include #include "bn_lcl.h" static const char Hex[] = "0123456789ABCDEF"; -/* Must 'OPENSSL_free' the returned data */ -char *BN_bn2hex(const BIGNUM *a) -{ - int i, j, v, z = 0; - char *buf; - char *p; - - if (BN_is_zero(a)) - return OPENSSL_strdup("0"); - buf = OPENSSL_malloc(a->top * BN_BYTES * 2 + 2); - if (buf == NULL) { - BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE); - goto err; - } - p = buf; - if (a->neg) - *p++ = '-'; - for (i = a->top - 1; i >= 0; i--) { - for (j = BN_BITS2 - 8; j >= 0; j -= 8) { - /* strip leading zeros */ - v = (int)((a->d[i] >> j) & 0xff); - if (z || v != 0) { - *p++ = Hex[v >> 4]; - *p++ = Hex[v & 0x0f]; - z = 1; - } - } - } - *p = '\0'; - err: - return buf; -} - -/* Must 'OPENSSL_free' the returned data */ -char *BN_bn2dec(const BIGNUM *a) -{ - int i = 0, num, ok = 0, n, tbytes; - char *buf = NULL; - char *p; - BIGNUM *t = NULL; - BN_ULONG *bn_data = NULL, *lp; - int bn_data_num; - - /*- - * get an upper bound for the length of the decimal integer - * num <= (BN_num_bits(a) + 1) * log(2) - * <= 3 * BN_num_bits(a) * 0.101 + log(2) + 1 (rounding error) - * <= 3 * BN_num_bits(a) / 10 + 3 * BN_num_bits / 1000 + 1 + 1 - */ - i = BN_num_bits(a) * 3; - num = (i / 10 + i / 1000 + 1) + 1; - tbytes = num + 3; /* negative and terminator and one spare? */ - bn_data_num = num / BN_DEC_NUM + 1; - bn_data = OPENSSL_malloc(bn_data_num * sizeof(BN_ULONG)); - buf = OPENSSL_malloc(tbytes); - if (buf == NULL || bn_data == NULL) { - BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE); - goto err; - } - if ((t = BN_dup(a)) == NULL) - goto err; - - p = buf; - lp = bn_data; - if (BN_is_zero(t)) { - *p++ = '0'; - *p++ = '\0'; - } else { - if (BN_is_negative(t)) - *p++ = '-'; - - while (!BN_is_zero(t)) { - if (lp - bn_data >= bn_data_num) - goto err; - *lp = BN_div_word(t, BN_DEC_CONV); - if (*lp == (BN_ULONG)-1) - goto err; - lp++; - } - lp--; - /* - * We now have a series of blocks, BN_DEC_NUM chars in length, where - * the last one needs truncation. The blocks need to be reversed in - * order. - */ - n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT1, *lp); - if (n < 0) - goto err; - p += n; - while (lp != bn_data) { - lp--; - n = BIO_snprintf(p, tbytes - (size_t)(p - buf), BN_DEC_FMT2, *lp); - if (n < 0) - goto err; - p += n; - } - } - ok = 1; - err: - OPENSSL_free(bn_data); - BN_free(t); - if (ok) - return buf; - OPENSSL_free(buf); - return NULL; -} - -int BN_hex2bn(BIGNUM **bn, const char *a) -{ - BIGNUM *ret = NULL; - BN_ULONG l = 0; - int neg = 0, h, m, i, j, k, c; - int num; - - if (a == NULL || *a == '\0') - return 0; - - if (*a == '-') { - neg = 1; - a++; - } - - for (i = 0; i <= INT_MAX / 4 && ossl_isxdigit(a[i]); i++) - continue; - - if (i == 0 || i > INT_MAX / 4) - goto err; - - num = i + neg; - if (bn == NULL) - return num; - - /* a is the start of the hex digits, and it is 'i' long */ - if (*bn == NULL) { - if ((ret = BN_new()) == NULL) - return 0; - } else { - ret = *bn; - BN_zero(ret); - } - - /* i is the number of hex digits */ - if (bn_expand(ret, i * 4) == NULL) - goto err; - - j = i; /* least significant 'hex' */ - m = 0; - h = 0; - while (j > 0) { - m = (BN_BYTES * 2 <= j) ? BN_BYTES * 2 : j; - l = 0; - for (;;) { - c = a[j - m]; - k = OPENSSL_hexchar2int(c); - if (k < 0) - k = 0; /* paranoia */ - l = (l << 4) | k; - - if (--m <= 0) { - ret->d[h++] = l; - break; - } - } - j -= BN_BYTES * 2; - } - ret->top = h; - bn_correct_top(ret); - - *bn = ret; - bn_check_top(ret); - /* Don't set the negative flag if it's zero. */ - if (ret->top != 0) - ret->neg = neg; - return num; - err: - if (*bn == NULL) - BN_free(ret); - return 0; -} - -int BN_dec2bn(BIGNUM **bn, const char *a) -{ - BIGNUM *ret = NULL; - BN_ULONG l = 0; - int neg = 0, i, j; - int num; - - if (a == NULL || *a == '\0') - return 0; - if (*a == '-') { - neg = 1; - a++; - } - - for (i = 0; i <= INT_MAX / 4 && ossl_isdigit(a[i]); i++) - continue; - - if (i == 0 || i > INT_MAX / 4) - goto err; - - num = i + neg; - if (bn == NULL) - return num; - - /* - * a is the start of the digits, and it is 'i' long. We chop it into - * BN_DEC_NUM digits at a time - */ - if (*bn == NULL) { - if ((ret = BN_new()) == NULL) - return 0; - } else { - ret = *bn; - BN_zero(ret); - } - - /* i is the number of digits, a bit of an over expand */ - if (bn_expand(ret, i * 4) == NULL) - goto err; - - j = BN_DEC_NUM - i % BN_DEC_NUM; - if (j == BN_DEC_NUM) - j = 0; - l = 0; - while (--i >= 0) { - l *= 10; - l += *a - '0'; - a++; - if (++j == BN_DEC_NUM) { - if (!BN_mul_word(ret, BN_DEC_CONV) - || !BN_add_word(ret, l)) - goto err; - l = 0; - j = 0; - } - } - - bn_correct_top(ret); - *bn = ret; - bn_check_top(ret); - /* Don't set the negative flag if it's zero. */ - if (ret->top != 0) - ret->neg = neg; - return num; - err: - if (*bn == NULL) - BN_free(ret); - return 0; -} - -int BN_asc2bn(BIGNUM **bn, const char *a) -{ - const char *p = a; - - if (*p == '-') - p++; - - if (p[0] == '0' && (p[1] == 'X' || p[1] == 'x')) { - if (!BN_hex2bn(bn, p + 2)) - return 0; - } else { - if (!BN_dec2bn(bn, p)) - return 0; - } - /* Don't set the negative flag if it's zero. */ - if (*a == '-' && (*bn)->top != 0) - (*bn)->neg = 1; - return 1; -} - -# ifndef OPENSSL_NO_STDIO +#ifndef OPENSSL_NO_STDIO int BN_print_fp(FILE *fp, const BIGNUM *a) { BIO *b; @@ -299,7 +26,7 @@ int BN_print_fp(FILE *fp, const BIGNUM *a) BIO_free(b); return ret; } -# endif +#endif int BN_print(BIO *bp, const BIGNUM *a) { diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c index 727c6957..a71e7d49 100644 --- a/crypto/bn/bn_rand.c +++ b/crypto/bn/bn_rand.c @@ -10,18 +10,22 @@ #include #include #include "internal/cryptlib.h" +#include "internal/rand_int.h" #include "bn_lcl.h" #include #include +#include typedef enum bnrand_flag_e { NORMAL, TESTING, PRIVATE } BNRAND_FLAG; -static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom) +static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom, + BN_CTX *ctx) { unsigned char *buf = NULL; int b, ret = 0, bit, bytes, mask; + OPENSSL_CTX *libctx = bn_get_lib_ctx(ctx); if (bits == 0) { if (top != BN_RAND_TOP_ANY || bottom != BN_RAND_BOTTOM_ANY) @@ -43,7 +47,8 @@ static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom) } /* make a random number and set the top and bottom bits */ - b = flag == NORMAL ? RAND_bytes(buf, bytes) : RAND_priv_bytes(buf, bytes); + b = flag == NORMAL ? rand_bytes_ex(libctx, buf, bytes) + : rand_priv_bytes_ex(libctx, buf, bytes); if (b <= 0) goto err; @@ -55,7 +60,7 @@ static int bnrand(BNRAND_FLAG flag, BIGNUM *rnd, int bits, int top, int bottom) unsigned char c; for (i = 0; i < bytes; i++) { - if (RAND_bytes(&c, 1) <= 0) + if (rand_bytes_ex(libctx, &c, 1) <= 0) goto err; if (c >= 128 && i > 0) buf[i] = buf[i - 1]; @@ -94,23 +99,33 @@ toosmall: return 0; } +int BN_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, BN_CTX *ctx) +{ + return bnrand(NORMAL, rnd, bits, top, bottom, ctx); +} int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) { - return bnrand(NORMAL, rnd, bits, top, bottom); + return bnrand(NORMAL, rnd, bits, top, bottom, NULL); } int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom) { - return bnrand(TESTING, rnd, bits, top, bottom); + return bnrand(TESTING, rnd, bits, top, bottom, NULL); +} + +int BN_priv_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, BN_CTX *ctx) +{ + return bnrand(PRIVATE, rnd, bits, top, bottom, ctx); } int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom) { - return bnrand(PRIVATE, rnd, bits, top, bottom); + return bnrand(PRIVATE, rnd, bits, top, bottom, NULL); } /* random number r: 0 <= r < range */ -static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range) +static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range, + BN_CTX *ctx) { int n; int count = 100; @@ -132,7 +147,8 @@ static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range) * than range */ do { - if (!bnrand(flag, r, n + 1, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY)) + if (!bnrand(flag, r, n + 1, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY, + ctx)) return 0; /* @@ -159,7 +175,7 @@ static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range) } else { do { /* range = 11..._2 or range = 101..._2 */ - if (!bnrand(flag, r, n, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY)) + if (!bnrand(flag, r, n, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY, ctx)) return 0; if (!--count) { @@ -174,14 +190,24 @@ static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range) return 1; } +int BN_rand_range_ex(BIGNUM *r, const BIGNUM *range, BN_CTX *ctx) +{ + return bnrand_range(NORMAL, r, range, ctx); +} + int BN_rand_range(BIGNUM *r, const BIGNUM *range) { - return bnrand_range(NORMAL, r, range); + return bnrand_range(NORMAL, r, range, NULL); +} + +int BN_priv_rand_range_ex(BIGNUM *r, const BIGNUM *range, BN_CTX *ctx) +{ + return bnrand_range(PRIVATE, r, range, ctx); } int BN_priv_rand_range(BIGNUM *r, const BIGNUM *range) { - return bnrand_range(PRIVATE, r, range); + return bnrand_range(PRIVATE, r, range, NULL); } int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom) @@ -206,7 +232,7 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, const BIGNUM *priv, const unsigned char *message, size_t message_len, BN_CTX *ctx) { - SHA512_CTX sha; + EVP_MD_CTX *mdctx = EVP_MD_CTX_new(); /* * We use 512 bits of random data per iteration to ensure that we have at * least |range| bits of randomness. @@ -217,8 +243,13 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, /* We generate |range|+8 bytes of random output. */ const unsigned num_k_bytes = BN_num_bytes(range) + 8; unsigned char private_bytes[96]; - unsigned char *k_bytes; + unsigned char *k_bytes = NULL; int ret = 0; + EVP_MD *md = NULL; + OPENSSL_CTX *libctx = bn_get_lib_ctx(ctx); + + if (mdctx == NULL) + goto err; k_bytes = OPENSSL_malloc(num_k_bytes); if (k_bytes == NULL) @@ -238,15 +269,23 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, memcpy(private_bytes, priv->d, todo); memset(private_bytes + todo, 0, sizeof(private_bytes) - todo); + md = EVP_MD_fetch(libctx, "SHA512", NULL); + if (md == NULL) { + BNerr(BN_F_BN_GENERATE_DSA_NONCE, BN_R_NO_SUITABLE_DIGEST); + goto err; + } for (done = 0; done < num_k_bytes;) { - if (RAND_priv_bytes(random_bytes, sizeof(random_bytes)) != 1) + if (!rand_priv_bytes_ex(libctx, random_bytes, sizeof(random_bytes))) + goto err; + + if (!EVP_DigestInit_ex(mdctx, md, NULL) + || !EVP_DigestUpdate(mdctx, &done, sizeof(done)) + || !EVP_DigestUpdate(mdctx, private_bytes, + sizeof(private_bytes)) + || !EVP_DigestUpdate(mdctx, message, message_len) + || !EVP_DigestUpdate(mdctx, random_bytes, sizeof(random_bytes)) + || !EVP_DigestFinal_ex(mdctx, digest, NULL)) goto err; - SHA512_Init(&sha); - SHA512_Update(&sha, &done, sizeof(done)); - SHA512_Update(&sha, private_bytes, sizeof(private_bytes)); - SHA512_Update(&sha, message, message_len); - SHA512_Update(&sha, random_bytes, sizeof(random_bytes)); - SHA512_Final(digest, &sha); todo = num_k_bytes - done; if (todo > SHA512_DIGEST_LENGTH) @@ -262,6 +301,8 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, ret = 1; err: + EVP_MD_CTX_free(mdctx); + EVP_MD_meth_free(md); OPENSSL_free(k_bytes); OPENSSL_cleanse(private_bytes, sizeof(private_bytes)); return ret; diff --git a/crypto/bn/bn_sqrt.c b/crypto/bn/bn_sqrt.c index 7ed88287..5981cd07 100644 --- a/crypto/bn/bn_sqrt.c +++ b/crypto/bn/bn_sqrt.c @@ -125,7 +125,8 @@ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) * = a. * * (This is due to A.O.L. Atkin, - * , + * Subject: Square Roots and Cognate Matters modulo p=8n+5. + * URL: https://listserv.nodak.edu/cgi-bin/wa.exe?A2=ind9211&L=NMBRTHRY&P=4026 * November 1992.) */ diff --git a/crypto/bn/build.info b/crypto/bn/build.info index 7e34ce41..8353b322 100644 --- a/crypto/bn/build.info +++ b/crypto/bn/build.info @@ -1,12 +1,117 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \ - bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \ - bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c \ - {- $target{bn_asm_src} -} \ + +$BNASM=bn_asm.c +IF[{- !$disabled{asm} -}] + # Define source files and macros per asm architecture + # Known macros are: + # + # OPENSSL_BN_ASM_PART_WORDS For any collection with /-586/ file names + # OPENSSL_BN_ASM_MONT For any collection with /-mont/ file names + # OPENSSL_BN_ASM_MONT5 For any collection with /-mont5/ file names + # OPENSSL_BN_ASM_GF2m For any collection with /-gf2m/ file names + # OPENSSL_IA32_SSE2 For any collection with /86/ file names + # when sse2 is enabled + # BN_DIV3W For any collection with /-div3w/ file names + # + # All variables are named in such a way that they can be "indexed" with + # $target{asm_arch} + + $BNASM_x86=bn-586.s co-586.s x86-mont.s x86-gf2m.s + # bn-586 is the only one implementing bn_*_part_words + # => OPENSSL_BN_ASM_PART_WORDS + $BNDEF_x86=OPENSSL_BN_ASM_PART_WORDS OPENSSL_BN_ASM_MONT OPENSSL_BN_ASM_GF2m + $BNDEF_x86_sse2=OPENSSL_IA32_SSE2 + + $BNASM_x86_64=\ + x86_64-mont.s x86_64-mont5.s x86_64-gf2m.s rsaz_exp.c rsaz-x86_64.s \ + rsaz-avx2.s + IF[{- $config{target} !~ /^VC/ -}] + $BNASM_x86_64=asm/x86_64-gcc.c $BNASM_x86_64 + ELSE + $BNASM_x86_64=bn_asm.c $BNASM_x86_64 + ENDIF + $BNDEF_x86_64=OPENSSL_BN_ASM_MONT OPENSSL_BN_ASM_MONT5 OPENSSL_BN_ASM_GF2m + $BNDEF_x86_64_sse2=OPENSSL_IA32_SSE2 + + IF[{- $config{target} !~ /^VC/ -}] + $BNASM_ia64=bn-ia64.s ia64-mont.s + ELSE + $BNASM_ia64=bn_asm.c ia64-mont.s + ENDIF + + $BNASM_sparcv9=asm/sparcv8plus.S sparcv9-mont.S sparcv9a-mont.S vis3-mont.S \ + sparct4-mont.S + $BNDEF_sparcv9=OPENSSL_BN_ASM_MONT + $BNASM_sparcv9_ec2m=sparcv9-gf2m.S + $BNDEF_sparcv9_ec2m=OPENSSL_BN_ASM_GF2m + + $BNASM_sparcv8=asm/sparcv8.S + + $BNASM_alpha=bn_asm.c alpha-mont.S + $BNDEF_alpha=OPENSSL_BN_ASM_MONT + + $BNASM_mips32=bn-mips.S mips-mont.S + $BNDEF_mips32=OPENSSL_BN_ASM_MONT + $BNASM_mips64=$BNASM_mips32 + $BNDEF_mips64=$BNDEF_mips32 + + IF[{- ($target{perlasm_scheme} // '') eq '31' -}] + $BNASM_s390x=bn_asm.c s390x-mont.S + ELSE + $BNASM_s390x=asm/s390x.S s390x-mont.S + ENDIF + $BNDEF_s390x=OPENSSL_BN_ASM_MONT + $BNASM_s390x_ec2m=s390x-gf2m.s + $BNDEF_s390x_ec2m=OPENSSL_BN_ASM_GF2m + + $BNASM_armv4=bn_asm.c armv4-mont.S + $BNDEF_armv4=OPENSSL_BN_ASM_MONT + $BNASM_armv4_ec2m=armv4-gf2m.S + $BNDEF_armv4_ec2m=OPENSSL_BN_ASM_GF2m + + $BNASM_aarch64=bn_asm.c armv8-mont.S + $BNDEF_aarch64=OPENSSL_BN_ASM_MONT + + $BNASM_parisc11=bn_asm.c parisc-mont.s + $BNDEF_parisc11=OPENSSL_BN_ASM_MONT + $BNASM_parisc20_64=$BNASM_parisc11 + $BNDEF_parisc20_64=$BNDEF_parisc11 + + $BNASM_ppc32=bn-ppc.s ppc-mont.s + $BNDEF_ppc32=OPENSSL_BN_ASM_MONT + $BNASM_ppc64=$BNASM_ppc32 + $BNDEF_ppc64=$BNDEF_ppc32 + + $BNASM_c64xplus=asm/bn-c64xplus.asm + $BNASM_c64xplus_ec2m=c64xplus-gf2m.s + $BNDEF_c64xplus_ec2m=OPENSSL_BN_ASM_GF2m + + # Now that we have defined all the arch specific variables, use the + # appropriate ones, and define the appropriate macros + IF[$BNASM_{- $target{asm_arch} -}] + $BNASM=$BNASM_{- $target{asm_arch} -} + $BNDEF=$BNDEF_{- $target{asm_arch} -} + IF[{- !$disabled{ec2m} -}] + $BNASM=$BNASM $BNASM_{- $target{asm_arch} -}_ec2m + $BNDEF=$BNDEF $BNDEF_{- $target{asm_arch} -}_ec2m + ENDIF + IF[{- !$disabled{sse2} -}] + $BNDEF_sse2=$BNDEF $BNDEF_{- $target{asm_arch} -}_sse2 + ENDIF + ENDIF +ENDIF + +$COMMON=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c \ + bn_mod.c bn_conv.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \ + bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_sqr.c \ bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \ - bn_depr.c bn_const.c bn_x931p.c bn_intern.c bn_dh.c bn_srp.c \ - bn_rsa_fips186_4.c + bn_const.c bn_x931p.c bn_intern.c bn_dh.c \ + bn_rsa_fips186_4.c $BNASM +SOURCE[../../libcrypto]=$COMMON bn_print.c bn_err.c bn_depr.c bn_srp.c +DEFINE[../../libcrypto]=$BNDEF +SOURCE[../../providers/fips]=$COMMON +DEFINE[../../providers/fips]=$BNDEF + INCLUDE[../../libcrypto]=../../crypto/include INCLUDE[bn_exp.o]=.. diff --git a/crypto/build.info b/crypto/build.info index db6d6afb..fccca081 100644 --- a/crypto/build.info +++ b/crypto/build.info @@ -1,34 +1,85 @@ # Note that these directories are filtered in Configure. Look for %skipdir # there for further explanations. -SUBDIRS=objects buffer bio stack lhash rand evp asn1 pem x509 x509v3 conf \ +SUBDIRS=objects buffer bio stack lhash rand evp asn1 pem x509 conf \ txt_db pkcs7 pkcs12 ui kdf store property \ md2 md4 md5 sha mdc2 gmac hmac ripemd whrlpool poly1305 blake2 \ siphash sm3 des aes rc2 rc4 rc5 idea aria bf cast camellia \ seed sm4 chacha modes bn ec rsa dsa dh sm2 dso engine \ - err comp ocsp cms ts srp cmac ct async kmac ess crmf + err comp ocsp cms ts srp cmac ct async kmac ess crmf cmp LIBS=../libcrypto -# The Core -SOURCE[../libcrypto]=provider_core.c provider_predefined.c provider_conf.c \ - core_fetch.c core_namemap.c -SOURCE[../providers/fips]=provider_core.c provider_predefined.c \ - core_fetch.c core_namemap.c +$UPLINKSRC= +$UPLINKDEF= +IF[{- !$disabled{uplink} -}] + $UPLINKSRC_common=../ms/uplink.c + $UPLINKSRC_x86=$UPLINKSRC_common uplink-x86.s + $UPLINKSRC_x86_64=$UPLINKSRC_common uplink-x86_64.s + $UPLINKSRC_ia64=$UPLINKSRC_common uplink-ia64.s + + IF[$UPLINKSRC_{- $target{uplink_arch} -}] + $UPLINKSRC=$UPLINKSRC_{- $target{uplink_arch} -} + $UPLINKDEF=OPENSSL_USE_APPLINK + ENDIF +ENDIF + +$CPUIDASM=mem_clr.c +$CPUIDDEF= +IF[{- !$disabled{asm} && $config{processor} ne '386' -}] + $CPUIDASM_x86=x86cpuid.s + + $CPUIDASM_x86_64=x86_64cpuid.s + + $CPUIDASM_ia64=ia64cpuid.s + + $CPUIDASM_sparcv9=sparcv9cap.c sparccpuid.S + + $CPUIDASM_alpha=alphacpuid.s + + $CPUIDASM_s390x=s390xcap.c s390xcpuid.S + + $CPUIDASM_armv4=armcap.c armv4cpuid.S + + $CPUIDASM_aarch64=armcap.c arm64cpuid.S + + $CPUIDASM_parisc11=pariscid.s + $CPUIDASM_parisc20_64=$CPUIDASM_parisc11 + + $CPUIDASM_ppc32=ppccpuid.s ppccap.c + $CPUIDASM_ppc64=$CPUIDASM_ppc32 + + $CPUIDASM_c64xplus=c64xpluscpuid.s + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$CPUIDASM_{- $target{asm_arch} -}] + $CPUIDASM=$CPUIDASM_{- $target{asm_arch} -} + $CPUIDDEF=OPENSSL_CPUID_OBJ + ENDIF +ENDIF + +# The Core +$CORE_COMMON=provider_core.c provider_predefined.c core_fetch.c core_namemap.c + +SOURCE[../libcrypto]=$CORE_COMMON provider_conf.c +SOURCE[../providers/fips]=$CORE_COMMON # Central utilities -SOURCE[../libcrypto]=\ - cryptlib.c mem.c mem_dbg.c cversion.c info.c ex_data.c cpt_err.c \ - ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fopen.c ctype.c \ - threads_pthread.c threads_win.c threads_none.c getenv.c \ - o_init.c o_fips.c mem_sec.c init.c context.c sparse_array.c \ - trace.c provider.c params.c bsearch.c \ - {- $target{cpuid_asm_src} -} {- $target{uplink_aux_src} -} +$UTIL_COMMON=\ + cryptlib.c params.c bsearch.c ex_data.c o_str.c \ + ctype.c threads_pthread.c threads_win.c threads_none.c initthread.c \ + context.c sparse_array.c $CPUIDASM +$UTIL_DEFINE=$CPUIDDEF -# FIPS module -SOURCE[../providers/fips]=\ - cryptlib.c mem.c mem_clr.c params.c bsearch.c ex_data.c o_str.c \ - ctype.c threads_pthread.c threads_win.c threads_none.c context.c \ - sparse_array.c +SOURCE[../libcrypto]=$UTIL_COMMON \ + mem.c mem_sec.c mem_str.c mem_dbg.c \ + cversion.c info.c cpt_err.c ebcdic.c uid.c o_time.c o_dir.c \ + o_fopen.c getenv.c o_init.c o_fips.c init.c trace.c provider.c \ + $UPLINKSRC +DEFINE[../libcrypto]=$UTIL_DEFINE $UPLINKDEF +SOURCE[../providers/fips]=$UTIL_COMMON +DEFINE[../providers/fips]=$UTIL_DEFINE + DEPEND[cversion.o]=buildinf.h diff --git a/crypto/camellia/build.info b/crypto/camellia/build.info index e36a19bd..8d74b9f0 100644 --- a/crypto/camellia/build.info +++ b/crypto/camellia/build.info @@ -1,7 +1,19 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - cmll_ecb.c cmll_ofb.c cmll_cfb.c cmll_ctr.c \ - {- $target{cmll_asm_src} -} + +$CMLLASM=camellia.c cmll_misc.c cmll_cbc.c +IF[{- !$disabled{asm} -}] + $CMLLASM_x86=cmll-x86.s + $CMLLASM_x86_64=cmll-x86_64.s cmll_misc.c + $CMLLASM_sparcv9=camellia.c cmll_misc.c cmll_cbc.c cmllt4-sparcv9.S + + # Now that we have defined all the arch specific variables, use the + # appropriate one + IF[$CMLLASM_{- $target{asm_arch} -}] + $CMLLASM=$CMLLASM_{- $target{asm_arch} -} + ENDIF +ENDIF + +SOURCE[../../libcrypto]=cmll_ecb.c cmll_ofb.c cmll_cfb.c cmll_ctr.c $CMLLASM GENERATE[cmll-x86.s]=asm/cmll-x86.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) \ diff --git a/crypto/cast/build.info b/crypto/cast/build.info index b0f59f38..97779c22 100644 --- a/crypto/cast/build.info +++ b/crypto/cast/build.info @@ -1,6 +1,18 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - c_skey.c c_ecb.c {- $target{cast_asm_src} -} c_cfb64.c c_ofb64.c + +$CASTASM=c_enc.c +# CAST assembly source is not PIC +IF[{- !$disabled{asm} && !$disabled{pic} -}] + $CASTASM_x86=cast-586.s + + # Now that we have defined all the arch specific variables, use the + # appropriate one + IF[$CASTASM_{- $target{asm_arch} -}] + $CASTASM=$CASTASM_{- $target{asm_arch} -} + ENDIF +ENDIF + +SOURCE[../../libcrypto]=c_skey.c c_ecb.c $CASTASM c_cfb64.c c_ofb64.c GENERATE[cast-586.s]=asm/cast-586.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR) diff --git a/crypto/chacha/build.info b/crypto/chacha/build.info index a7418265..e8eeaf0c 100644 --- a/crypto/chacha/build.info +++ b/crypto/chacha/build.info @@ -1,5 +1,30 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]={- $target{chacha_asm_src} -} + +$CHACHAASM=chacha_enc.c +IF[{- !$disabled{asm} -}] + $CHACHAASM_x86=chacha-x86.s + $CHACHAASM_x86_64=chacha-x86_64.s + + $CHACHAASM_ia64=chacha-ia64.S + + $CHACHAASM_s390x=chacha-s390x.S + + $CHACHAASM_armv4=chacha-armv4.S + $CHACHAASM_aarch64=chacha-armv8.S + + $CHACHAASM_ppc32=chacha-ppc.s + $CHACHAASM_ppc64=$CHACHAASM_ppc32 + + $CHACHAASM_c64xplus=chacha-c64xplus.s + + # Now that we have defined all the arch specific variables, use the + # appropriate one + IF[$CHACHAASM_{- $target{asm_arch} -}] + $CHACHAASM=$CHACHAASM_{- $target{asm_arch} -} + ENDIF +ENDIF + +SOURCE[../../libcrypto]=$CHACHAASM GENERATE[chacha-x86.s]=asm/chacha-x86.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR) diff --git a/crypto/cmac/cm_meth.c b/crypto/cmac/cm_meth.c index 3f20e6ce..07acf050 100644 --- a/crypto/cmac/cm_meth.c +++ b/crypto/cmac/cm_meth.c @@ -46,14 +46,22 @@ static void cmac_free(EVP_MAC_IMPL *cctx) } } -static int cmac_copy(EVP_MAC_IMPL *cdst, EVP_MAC_IMPL *csrc) +static EVP_MAC_IMPL *cmac_dup(const EVP_MAC_IMPL *csrc) { - if (!CMAC_CTX_copy(cdst->ctx, csrc->ctx)) - return 0; + EVP_MAC_IMPL *cdst = cmac_new(); + + if (cdst == NULL) + return NULL; + + if (!CMAC_CTX_copy(cdst->ctx, csrc->ctx)) { + cmac_free(cdst); + return NULL; + } cdst->tmpengine = csrc->tmpengine; cdst->tmpcipher = csrc->tmpcipher; - return 1; + + return cdst; } static size_t cmac_size(EVP_MAC_IMPL *cctx) @@ -153,7 +161,7 @@ static int cmac_ctrl_str(EVP_MAC_IMPL *cctx, const char *type, const EVP_MAC cmac_meth = { EVP_MAC_CMAC, cmac_new, - cmac_copy, + cmac_dup, cmac_free, cmac_size, cmac_init, diff --git a/crypto/cmp/build.info b/crypto/cmp/build.info new file mode 100644 index 00000000..6b6ccaaf --- /dev/null +++ b/crypto/cmp/build.info @@ -0,0 +1,2 @@ +LIBS=../../libcrypto +SOURCE[../../libcrypto]= cmp_asn.c cmp_err.c diff --git a/crypto/cmp/cmp_asn.c b/crypto/cmp/cmp_asn.c new file mode 100644 index 00000000..8555586d --- /dev/null +++ b/crypto/cmp/cmp_asn.c @@ -0,0 +1,398 @@ +/* + * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2019 + * Copyright Siemens AG 2015-2019 + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + * + * CMP implementation by Martin Peylo, Miikka Viljanen, and David von Oheimb. + */ + +#include + +#include "cmp_int.h" + +/* explicit #includes not strictly needed since implied by the above: */ +#include +#include + +/* ASN.1 declarations from RFC4210 */ +ASN1_SEQUENCE(OSSL_CMP_REVANNCONTENT) = { + /* OSSL_CMP_PKISTATUS is effectively ASN1_INTEGER so it is used directly */ + ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, status, ASN1_INTEGER), + ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, certId, OSSL_CRMF_CERTID), + ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, willBeRevokedAt, ASN1_GENERALIZEDTIME), + ASN1_SIMPLE(OSSL_CMP_REVANNCONTENT, badSinceDate, ASN1_GENERALIZEDTIME), + ASN1_OPT(OSSL_CMP_REVANNCONTENT, crlDetails, X509_EXTENSIONS) +} ASN1_SEQUENCE_END(OSSL_CMP_REVANNCONTENT) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVANNCONTENT) + + +ASN1_SEQUENCE(OSSL_CMP_CHALLENGE) = { + ASN1_OPT(OSSL_CMP_CHALLENGE, owf, X509_ALGOR), + ASN1_SIMPLE(OSSL_CMP_CHALLENGE, witness, ASN1_OCTET_STRING), + ASN1_SIMPLE(OSSL_CMP_CHALLENGE, challenge, ASN1_OCTET_STRING) +} ASN1_SEQUENCE_END(OSSL_CMP_CHALLENGE) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CHALLENGE) + + +ASN1_ITEM_TEMPLATE(OSSL_CMP_POPODECKEYCHALLCONTENT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, + OSSL_CMP_POPODECKEYCHALLCONTENT, OSSL_CMP_CHALLENGE) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POPODECKEYCHALLCONTENT) + + +ASN1_ITEM_TEMPLATE(OSSL_CMP_POPODECKEYRESPCONTENT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, + OSSL_CMP_POPODECKEYRESPCONTENT, ASN1_INTEGER) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POPODECKEYRESPCONTENT) + + +ASN1_SEQUENCE(OSSL_CMP_CAKEYUPDANNCONTENT) = { + /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */ + ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, oldWithNew, X509), + /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */ + ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, newWithOld, X509), + /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */ + ASN1_SIMPLE(OSSL_CMP_CAKEYUPDANNCONTENT, newWithNew, X509) +} ASN1_SEQUENCE_END(OSSL_CMP_CAKEYUPDANNCONTENT) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CAKEYUPDANNCONTENT) + + +ASN1_SEQUENCE(OSSL_CMP_ERRORMSGCONTENT) = { + ASN1_SIMPLE(OSSL_CMP_ERRORMSGCONTENT, pKIStatusInfo, OSSL_CMP_PKISI), + ASN1_OPT(OSSL_CMP_ERRORMSGCONTENT, errorCode, ASN1_INTEGER), + /* + * OSSL_CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING + * so it is used directly + * + */ + ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ERRORMSGCONTENT, errorDetails, ASN1_UTF8STRING) +} ASN1_SEQUENCE_END(OSSL_CMP_ERRORMSGCONTENT) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_ERRORMSGCONTENT) + +ASN1_ADB_TEMPLATE(infotypeandvalue_default) = ASN1_OPT(OSSL_CMP_ITAV, + infoValue.other, ASN1_ANY); +/* ITAV means InfoTypeAndValue */ +ASN1_ADB(OSSL_CMP_ITAV) = { + /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */ + ADB_ENTRY(NID_id_it_caProtEncCert, ASN1_OPT(OSSL_CMP_ITAV, + infoValue.caProtEncCert, X509)), + ADB_ENTRY(NID_id_it_signKeyPairTypes, + ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV, + infoValue.signKeyPairTypes, X509_ALGOR)), + ADB_ENTRY(NID_id_it_encKeyPairTypes, + ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV, + infoValue.encKeyPairTypes, X509_ALGOR)), + ADB_ENTRY(NID_id_it_preferredSymmAlg, + ASN1_OPT(OSSL_CMP_ITAV, infoValue.preferredSymmAlg, + X509_ALGOR)), + ADB_ENTRY(NID_id_it_caKeyUpdateInfo, + ASN1_OPT(OSSL_CMP_ITAV, infoValue.caKeyUpdateInfo, + OSSL_CMP_CAKEYUPDANNCONTENT)), + ADB_ENTRY(NID_id_it_currentCRL, + ASN1_OPT(OSSL_CMP_ITAV, infoValue.currentCRL, X509_CRL)), + ADB_ENTRY(NID_id_it_unsupportedOIDs, + ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV, + infoValue.unsupportedOIDs, ASN1_OBJECT)), + ADB_ENTRY(NID_id_it_keyPairParamReq, + ASN1_OPT(OSSL_CMP_ITAV, infoValue.keyPairParamReq, + ASN1_OBJECT)), + ADB_ENTRY(NID_id_it_keyPairParamRep, + ASN1_OPT(OSSL_CMP_ITAV, infoValue.keyPairParamRep, + X509_ALGOR)), + ADB_ENTRY(NID_id_it_revPassphrase, + ASN1_OPT(OSSL_CMP_ITAV, infoValue.revPassphrase, + OSSL_CRMF_ENCRYPTEDVALUE)), + ADB_ENTRY(NID_id_it_implicitConfirm, + ASN1_OPT(OSSL_CMP_ITAV, infoValue.implicitConfirm, + ASN1_NULL)), + ADB_ENTRY(NID_id_it_confirmWaitTime, + ASN1_OPT(OSSL_CMP_ITAV, infoValue.confirmWaitTime, + ASN1_GENERALIZEDTIME)), + ADB_ENTRY(NID_id_it_origPKIMessage, + ASN1_OPT(OSSL_CMP_ITAV, infoValue.origPKIMessage, + OSSL_CMP_MSGS)), + ADB_ENTRY(NID_id_it_suppLangTags, + ASN1_SEQUENCE_OF_OPT(OSSL_CMP_ITAV, infoValue.suppLangTagsValue, + ASN1_UTF8STRING)), +} ASN1_ADB_END(OSSL_CMP_ITAV, 0, infoType, 0, + &infotypeandvalue_default_tt, NULL); + + +ASN1_SEQUENCE(OSSL_CMP_ITAV) = { + ASN1_SIMPLE(OSSL_CMP_ITAV, infoType, ASN1_OBJECT), + ASN1_ADB_OBJECT(OSSL_CMP_ITAV) +} ASN1_SEQUENCE_END(OSSL_CMP_ITAV) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_ITAV) +IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV) + +OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value) +{ + OSSL_CMP_ITAV *itav; + + if (type == NULL || (itav = OSSL_CMP_ITAV_new()) == NULL) + return NULL; + OSSL_CMP_ITAV_set0(itav, type, value); + return itav; +} + +void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type, + ASN1_TYPE *value) +{ + itav->infoType = type; + itav->infoValue.other = value; +} + +ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav) +{ + if (itav == NULL) + return NULL; + return itav->infoType; +} + +ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav) +{ + if (itav == NULL) + return NULL; + return itav->infoValue.other; +} + +int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p, + OSSL_CMP_ITAV *itav) +{ + int created = 0; + + if (itav_sk_p == NULL) + goto err; + + if (*itav_sk_p == NULL) { + if ((*itav_sk_p = sk_OSSL_CMP_ITAV_new_null()) == NULL) + goto err; + created = 1; + } + if (itav != NULL) { + if (!sk_OSSL_CMP_ITAV_push(*itav_sk_p, itav)) + goto err; + } + return 1; + err: + if (created != 0) { + sk_OSSL_CMP_ITAV_free(*itav_sk_p); + *itav_sk_p = NULL; + } + return 0; +} + +ASN1_CHOICE(OSSL_CMP_CERTORENCCERT) = { + /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */ + ASN1_EXP(OSSL_CMP_CERTORENCCERT, value.certificate, X509, 0), + ASN1_EXP(OSSL_CMP_CERTORENCCERT, value.encryptedCert, + OSSL_CRMF_ENCRYPTEDVALUE, 1), +} ASN1_CHOICE_END(OSSL_CMP_CERTORENCCERT) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTORENCCERT) + + +ASN1_SEQUENCE(OSSL_CMP_CERTIFIEDKEYPAIR) = { + ASN1_SIMPLE(OSSL_CMP_CERTIFIEDKEYPAIR, certOrEncCert, + OSSL_CMP_CERTORENCCERT), + ASN1_EXP_OPT(OSSL_CMP_CERTIFIEDKEYPAIR, privateKey, + OSSL_CRMF_ENCRYPTEDVALUE, 0), + ASN1_EXP_OPT(OSSL_CMP_CERTIFIEDKEYPAIR, publicationInfo, + OSSL_CRMF_PKIPUBLICATIONINFO, 1) +} ASN1_SEQUENCE_END(OSSL_CMP_CERTIFIEDKEYPAIR) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTIFIEDKEYPAIR) + + +ASN1_SEQUENCE(OSSL_CMP_REVDETAILS) = { + ASN1_SIMPLE(OSSL_CMP_REVDETAILS, certDetails, OSSL_CRMF_CERTTEMPLATE), + ASN1_OPT(OSSL_CMP_REVDETAILS, crlEntryDetails, X509_EXTENSIONS) +} ASN1_SEQUENCE_END(OSSL_CMP_REVDETAILS) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVDETAILS) + + +ASN1_ITEM_TEMPLATE(OSSL_CMP_REVREQCONTENT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_REVREQCONTENT, + OSSL_CMP_REVDETAILS) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_REVREQCONTENT) + + +ASN1_SEQUENCE(OSSL_CMP_REVREPCONTENT) = { + ASN1_SEQUENCE_OF(OSSL_CMP_REVREPCONTENT, status, OSSL_CMP_PKISI), + ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_REVREPCONTENT, revCerts, OSSL_CRMF_CERTID, + 0), + ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_REVREPCONTENT, crls, X509_CRL, 1) +} ASN1_SEQUENCE_END(OSSL_CMP_REVREPCONTENT) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_REVREPCONTENT) + + +ASN1_SEQUENCE(OSSL_CMP_KEYRECREPCONTENT) = { + ASN1_SIMPLE(OSSL_CMP_KEYRECREPCONTENT, status, OSSL_CMP_PKISI), + ASN1_EXP_OPT(OSSL_CMP_KEYRECREPCONTENT, newSigCert, X509, 0), + ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_KEYRECREPCONTENT, caCerts, X509, 1), + ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_KEYRECREPCONTENT, keyPairHist, + OSSL_CMP_CERTIFIEDKEYPAIR, 2) +} ASN1_SEQUENCE_END(OSSL_CMP_KEYRECREPCONTENT) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_KEYRECREPCONTENT) + + +ASN1_ITEM_TEMPLATE(OSSL_CMP_PKISTATUS) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_UNIVERSAL, 0, status, ASN1_INTEGER) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_PKISTATUS) + +ASN1_SEQUENCE(OSSL_CMP_PKISI) = { + ASN1_SIMPLE(OSSL_CMP_PKISI, status, OSSL_CMP_PKISTATUS), + /* + * CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING + * so it is used directly + */ + ASN1_SEQUENCE_OF_OPT(OSSL_CMP_PKISI, statusString, ASN1_UTF8STRING), + /* + * OSSL_CMP_PKIFAILUREINFO is effectively ASN1_BIT_STRING so used directly + */ + ASN1_OPT(OSSL_CMP_PKISI, failInfo, ASN1_BIT_STRING) +} ASN1_SEQUENCE_END(OSSL_CMP_PKISI) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKISI) +IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI) + +ASN1_SEQUENCE(OSSL_CMP_CERTSTATUS) = { + ASN1_SIMPLE(OSSL_CMP_CERTSTATUS, certHash, ASN1_OCTET_STRING), + ASN1_SIMPLE(OSSL_CMP_CERTSTATUS, certReqId, ASN1_INTEGER), + ASN1_OPT(OSSL_CMP_CERTSTATUS, statusInfo, OSSL_CMP_PKISI) +} ASN1_SEQUENCE_END(OSSL_CMP_CERTSTATUS) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTSTATUS) + +ASN1_ITEM_TEMPLATE(OSSL_CMP_CERTCONFIRMCONTENT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_CERTCONFIRMCONTENT, + OSSL_CMP_CERTSTATUS) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_CERTCONFIRMCONTENT) + +ASN1_SEQUENCE(OSSL_CMP_CERTRESPONSE) = { + ASN1_SIMPLE(OSSL_CMP_CERTRESPONSE, certReqId, ASN1_INTEGER), + ASN1_SIMPLE(OSSL_CMP_CERTRESPONSE, status, OSSL_CMP_PKISI), + ASN1_OPT(OSSL_CMP_CERTRESPONSE, certifiedKeyPair, + OSSL_CMP_CERTIFIEDKEYPAIR), + ASN1_OPT(OSSL_CMP_CERTRESPONSE, rspInfo, ASN1_OCTET_STRING) +} ASN1_SEQUENCE_END(OSSL_CMP_CERTRESPONSE) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTRESPONSE) + +ASN1_SEQUENCE(OSSL_CMP_POLLREQ) = { + ASN1_SIMPLE(OSSL_CMP_POLLREQ, certReqId, ASN1_INTEGER) +} ASN1_SEQUENCE_END(OSSL_CMP_POLLREQ) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_POLLREQ) + +ASN1_ITEM_TEMPLATE(OSSL_CMP_POLLREQCONTENT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_POLLREQCONTENT, + OSSL_CMP_POLLREQ) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POLLREQCONTENT) + +ASN1_SEQUENCE(OSSL_CMP_POLLREP) = { + ASN1_SIMPLE(OSSL_CMP_POLLREP, certReqId, ASN1_INTEGER), + ASN1_SIMPLE(OSSL_CMP_POLLREP, checkAfter, ASN1_INTEGER), + ASN1_SEQUENCE_OF_OPT(OSSL_CMP_POLLREP, reason, ASN1_UTF8STRING), +} ASN1_SEQUENCE_END(OSSL_CMP_POLLREP) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_POLLREP) + +ASN1_ITEM_TEMPLATE(OSSL_CMP_POLLREPCONTENT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, + OSSL_CMP_POLLREPCONTENT, + OSSL_CMP_POLLREP) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_POLLREPCONTENT) + +ASN1_SEQUENCE(OSSL_CMP_CERTREPMESSAGE) = { + /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */ + ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_CERTREPMESSAGE, caPubs, X509, 1), + ASN1_SEQUENCE_OF(OSSL_CMP_CERTREPMESSAGE, response, OSSL_CMP_CERTRESPONSE) +} ASN1_SEQUENCE_END(OSSL_CMP_CERTREPMESSAGE) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_CERTREPMESSAGE) + +ASN1_ITEM_TEMPLATE(OSSL_CMP_GENMSGCONTENT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_GENMSGCONTENT, + OSSL_CMP_ITAV) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_GENMSGCONTENT) + +ASN1_ITEM_TEMPLATE(OSSL_CMP_GENREPCONTENT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_GENREPCONTENT, + OSSL_CMP_ITAV) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_GENREPCONTENT) + +ASN1_ITEM_TEMPLATE(OSSL_CMP_CRLANNCONTENT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, + OSSL_CMP_CRLANNCONTENT, X509_CRL) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_CRLANNCONTENT) + +ASN1_CHOICE(OSSL_CMP_PKIBODY) = { + ASN1_EXP(OSSL_CMP_PKIBODY, value.ir, OSSL_CRMF_MSGS, 0), + ASN1_EXP(OSSL_CMP_PKIBODY, value.ip, OSSL_CMP_CERTREPMESSAGE, 1), + ASN1_EXP(OSSL_CMP_PKIBODY, value.cr, OSSL_CRMF_MSGS, 2), + ASN1_EXP(OSSL_CMP_PKIBODY, value.cp, OSSL_CMP_CERTREPMESSAGE, 3), + ASN1_EXP(OSSL_CMP_PKIBODY, value.p10cr, X509_REQ, 4), + ASN1_EXP(OSSL_CMP_PKIBODY, value.popdecc, OSSL_CMP_POPODECKEYCHALLCONTENT, 5), + ASN1_EXP(OSSL_CMP_PKIBODY, value.popdecr, OSSL_CMP_POPODECKEYRESPCONTENT, 6), + ASN1_EXP(OSSL_CMP_PKIBODY, value.kur, OSSL_CRMF_MSGS, 7), + ASN1_EXP(OSSL_CMP_PKIBODY, value.kup, OSSL_CMP_CERTREPMESSAGE, 8), + ASN1_EXP(OSSL_CMP_PKIBODY, value.krr, OSSL_CRMF_MSGS, 9), + ASN1_EXP(OSSL_CMP_PKIBODY, value.krp, OSSL_CMP_KEYRECREPCONTENT, 10), + ASN1_EXP(OSSL_CMP_PKIBODY, value.rr, OSSL_CMP_REVREQCONTENT, 11), + ASN1_EXP(OSSL_CMP_PKIBODY, value.rp, OSSL_CMP_REVREPCONTENT, 12), + ASN1_EXP(OSSL_CMP_PKIBODY, value.ccr, OSSL_CRMF_MSGS, 13), + ASN1_EXP(OSSL_CMP_PKIBODY, value.ccp, OSSL_CMP_CERTREPMESSAGE, 14), + ASN1_EXP(OSSL_CMP_PKIBODY, value.ckuann, OSSL_CMP_CAKEYUPDANNCONTENT, 15), + ASN1_EXP(OSSL_CMP_PKIBODY, value.cann, X509, 16), + ASN1_EXP(OSSL_CMP_PKIBODY, value.rann, OSSL_CMP_REVANNCONTENT, 17), + ASN1_EXP(OSSL_CMP_PKIBODY, value.crlann, OSSL_CMP_CRLANNCONTENT, 18), + ASN1_EXP(OSSL_CMP_PKIBODY, value.pkiconf, ASN1_ANY, 19), + ASN1_EXP(OSSL_CMP_PKIBODY, value.nested, OSSL_CMP_MSGS, 20), + ASN1_EXP(OSSL_CMP_PKIBODY, value.genm, OSSL_CMP_GENMSGCONTENT, 21), + ASN1_EXP(OSSL_CMP_PKIBODY, value.genp, OSSL_CMP_GENREPCONTENT, 22), + ASN1_EXP(OSSL_CMP_PKIBODY, value.error, OSSL_CMP_ERRORMSGCONTENT, 23), + ASN1_EXP(OSSL_CMP_PKIBODY, value.certConf, OSSL_CMP_CERTCONFIRMCONTENT, 24), + ASN1_EXP(OSSL_CMP_PKIBODY, value.pollReq, OSSL_CMP_POLLREQCONTENT, 25), + ASN1_EXP(OSSL_CMP_PKIBODY, value.pollRep, OSSL_CMP_POLLREPCONTENT, 26), +} ASN1_CHOICE_END(OSSL_CMP_PKIBODY) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKIBODY) + +ASN1_SEQUENCE(OSSL_CMP_PKIHEADER) = { + ASN1_SIMPLE(OSSL_CMP_PKIHEADER, pvno, ASN1_INTEGER), + ASN1_SIMPLE(OSSL_CMP_PKIHEADER, sender, GENERAL_NAME), + ASN1_SIMPLE(OSSL_CMP_PKIHEADER, recipient, GENERAL_NAME), + ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, messageTime, ASN1_GENERALIZEDTIME, 0), + ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, protectionAlg, X509_ALGOR, 1), + ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, senderKID, ASN1_OCTET_STRING, 2), + ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, recipKID, ASN1_OCTET_STRING, 3), + ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, transactionID, ASN1_OCTET_STRING, 4), + ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, senderNonce, ASN1_OCTET_STRING, 5), + ASN1_EXP_OPT(OSSL_CMP_PKIHEADER, recipNonce, ASN1_OCTET_STRING, 6), + /* + * OSSL_CMP_PKIFREETEXT is effectively a sequence of ASN1_UTF8STRING + * so it is used directly + */ + ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_PKIHEADER, freeText, ASN1_UTF8STRING, 7), + ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_PKIHEADER, generalInfo, + OSSL_CMP_ITAV, 8) +} ASN1_SEQUENCE_END(OSSL_CMP_PKIHEADER) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_PKIHEADER) + +ASN1_SEQUENCE(CMP_PROTECTEDPART) = { + ASN1_SIMPLE(OSSL_CMP_MSG, header, OSSL_CMP_PKIHEADER), + ASN1_SIMPLE(OSSL_CMP_MSG, body, OSSL_CMP_PKIBODY) +} ASN1_SEQUENCE_END(CMP_PROTECTEDPART) +IMPLEMENT_ASN1_FUNCTIONS(CMP_PROTECTEDPART) + +ASN1_SEQUENCE(OSSL_CMP_MSG) = { + ASN1_SIMPLE(OSSL_CMP_MSG, header, OSSL_CMP_PKIHEADER), + ASN1_SIMPLE(OSSL_CMP_MSG, body, OSSL_CMP_PKIBODY), + ASN1_EXP_OPT(OSSL_CMP_MSG, protection, ASN1_BIT_STRING, 0), + /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */ + ASN1_EXP_SEQUENCE_OF_OPT(OSSL_CMP_MSG, extraCerts, X509, 1) +} ASN1_SEQUENCE_END(OSSL_CMP_MSG) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CMP_MSG) +IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CMP_MSG) + +ASN1_ITEM_TEMPLATE(OSSL_CMP_MSGS) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, OSSL_CMP_MSGS, + OSSL_CMP_MSG) +ASN1_ITEM_TEMPLATE_END(OSSL_CMP_MSGS) diff --git a/crypto/cmp/cmp_err.c b/crypto/cmp/cmp_err.c new file mode 100644 index 00000000..b85b8bac --- /dev/null +++ b/crypto/cmp/cmp_err.c @@ -0,0 +1,35 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include + +#ifndef OPENSSL_NO_ERR + +static const ERR_STRING_DATA CMP_str_functs[] = { + {0, NULL} +}; + +static const ERR_STRING_DATA CMP_str_reasons[] = { + {0, NULL} +}; + +#endif + +int ERR_load_CMP_strings(void) +{ +#ifndef OPENSSL_NO_ERR + if (ERR_func_error_string(CMP_str_functs[0].error) == NULL) { + ERR_load_strings_const(CMP_str_functs); + ERR_load_strings_const(CMP_str_reasons); + } +#endif + return 1; +} diff --git a/crypto/cmp/cmp_int.h b/crypto/cmp/cmp_int.h new file mode 100644 index 00000000..e78968aa --- /dev/null +++ b/crypto/cmp/cmp_int.h @@ -0,0 +1,589 @@ +/* + * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2019 + * Copyright Siemens AG 2015-2019 + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + * + * CMP implementation by Martin Peylo, Miikka Viljanen, and David von Oheimb. + */ + +#ifndef OSSL_HEADER_CMP_INT_H +# define OSSL_HEADER_CMP_INT_H + +# include "internal/cryptlib.h" + +# include +# include + +/* explicit #includes not strictly needed since implied by the above: */ +# include +# include +# include +# include +# include + +/* + * ########################################################################## + * ASN.1 DECLARATIONS + * ########################################################################## + */ + +/*- + * RevAnnContent ::= SEQUENCE { + * status PKIStatus, + * certId CertId, + * willBeRevokedAt GeneralizedTime, + * badSinceDate GeneralizedTime, + * crlDetails Extensions OPTIONAL + * -- extra CRL details (e.g., crl number, reason, location, etc.) + * } + */ +typedef struct OSSL_cmp_revanncontent_st { + ASN1_INTEGER *status; + OSSL_CRMF_CERTID *certId; + ASN1_GENERALIZEDTIME *willBeRevokedAt; + ASN1_GENERALIZEDTIME *badSinceDate; + X509_EXTENSIONS *crlDetails; +} OSSL_CMP_REVANNCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVANNCONTENT) + +/*- + * Challenge ::= SEQUENCE { + * owf AlgorithmIdentifier OPTIONAL, + * + * -- MUST be present in the first Challenge; MAY be omitted in + * -- any subsequent Challenge in POPODecKeyChallContent (if + * -- omitted, then the owf used in the immediately preceding + * -- Challenge is to be used). + * + * witness OCTET STRING, + * -- the result of applying the one-way function (owf) to a + * -- randomly-generated INTEGER, A. [Note that a different + * -- INTEGER MUST be used for each Challenge.] + * challenge OCTET STRING + * -- the encryption (under the public key for which the cert. + * -- request is being made) of Rand, where Rand is specified as + * -- Rand ::= SEQUENCE { + * -- int INTEGER, + * -- - the randomly-generated INTEGER A (above) + * -- sender GeneralName + * -- - the sender's name (as included in PKIHeader) + * -- } + * } + */ +typedef struct OSSL_cmp_challenge_st { + X509_ALGOR *owf; + ASN1_OCTET_STRING *witness; + ASN1_OCTET_STRING *challenge; +} OSSL_CMP_CHALLENGE; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CHALLENGE) + +/*- + * CAKeyUpdAnnContent ::= SEQUENCE { + * oldWithNew Certificate, + * newWithOld Certificate, + * newWithNew Certificate + * } + */ +typedef struct OSSL_cmp_cakeyupdanncontent_st { + X509 *oldWithNew; + X509 *newWithOld; + X509 *newWithNew; +} OSSL_CMP_CAKEYUPDANNCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CAKEYUPDANNCONTENT) + +/*- + * declared already here as it will be used in OSSL_CMP_MSG (nested) and + * infoType and infoValue + */ +typedef STACK_OF(OSSL_CMP_MSG) OSSL_CMP_MSGS; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_MSGS) + +/*- + * InfoTypeAndValue ::= SEQUENCE { + * infoType OBJECT IDENTIFIER, + * infoValue ANY DEFINED BY infoType OPTIONAL + * } + */ +struct OSSL_cmp_itav_st { + ASN1_OBJECT *infoType; + union { + char *ptr; + /* NID_id_it_caProtEncCert - CA Protocol Encryption Certificate */ + X509 *caProtEncCert; + /* NID_id_it_signKeyPairTypes - Signing Key Pair Types */ + STACK_OF(X509_ALGOR) *signKeyPairTypes; + /* NID_id_it_encKeyPairTypes - Encryption/Key Agreement Key Pair Types */ + STACK_OF(X509_ALGOR) *encKeyPairTypes; + /* NID_id_it_preferredSymmAlg - Preferred Symmetric Algorithm */ + X509_ALGOR *preferredSymmAlg; + /* NID_id_it_caKeyUpdateInfo - Updated CA Key Pair */ + OSSL_CMP_CAKEYUPDANNCONTENT *caKeyUpdateInfo; + /* NID_id_it_currentCRL - CRL */ + X509_CRL *currentCRL; + /* NID_id_it_unsupportedOIDs - Unsupported Object Identifiers */ + STACK_OF(ASN1_OBJECT) *unsupportedOIDs; + /* NID_id_it_keyPairParamReq - Key Pair Parameters Request */ + ASN1_OBJECT *keyPairParamReq; + /* NID_id_it_keyPairParamRep - Key Pair Parameters Response */ + X509_ALGOR *keyPairParamRep; + /* NID_id_it_revPassphrase - Revocation Passphrase */ + OSSL_CRMF_ENCRYPTEDVALUE *revPassphrase; + /* NID_id_it_implicitConfirm - ImplicitConfirm */ + ASN1_NULL *implicitConfirm; + /* NID_id_it_confirmWaitTime - ConfirmWaitTime */ + ASN1_GENERALIZEDTIME *confirmWaitTime; + /* NID_id_it_origPKIMessage - origPKIMessage */ + OSSL_CMP_MSGS *origPKIMessage; + /* NID_id_it_suppLangTags - Supported Language Tags */ + STACK_OF(ASN1_UTF8STRING) *suppLangTagsValue; + /* this is to be used for so far undeclared objects */ + ASN1_TYPE *other; + } infoValue; +} /* OSSL_CMP_ITAV */; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ITAV) +DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_ITAV) + + +typedef struct OSSL_cmp_certorenccert_st { + int type; + union { + X509 *certificate; + OSSL_CRMF_ENCRYPTEDVALUE *encryptedCert; + } value; +} OSSL_CMP_CERTORENCCERT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTORENCCERT) + +/*- + * CertifiedKeyPair ::= SEQUENCE { + * certOrEncCert CertOrEncCert, + * privateKey [0] EncryptedValue OPTIONAL, + * -- see [CRMF] for comment on encoding + * publicationInfo [1] PKIPublicationInfo OPTIONAL + * } + */ +typedef struct OSSL_cmp_certifiedkeypair_st { + OSSL_CMP_CERTORENCCERT *certOrEncCert; + OSSL_CRMF_ENCRYPTEDVALUE *privateKey; + OSSL_CRMF_PKIPUBLICATIONINFO *publicationInfo; +} OSSL_CMP_CERTIFIEDKEYPAIR; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTIFIEDKEYPAIR) + +/*- + * PKIStatusInfo ::= SEQUENCE { + * status PKIStatus, + * statusString PKIFreeText OPTIONAL, + * failInfo PKIFailureInfo OPTIONAL + * } + */ +struct OSSL_cmp_pkisi_st { + OSSL_CMP_PKISTATUS *status; + OSSL_CMP_PKIFREETEXT *statusString; + OSSL_CMP_PKIFAILUREINFO *failInfo; +} /* OSSL_CMP_PKISI */; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKISI) +DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_PKISI) + +/*- + * RevReqContent ::= SEQUENCE OF RevDetails + * + * RevDetails ::= SEQUENCE { + * certDetails CertTemplate, + * crlEntryDetails Extensions OPTIONAL + * } + */ +typedef struct OSSL_cmp_revdetails_st { + OSSL_CRMF_CERTTEMPLATE *certDetails; + X509_EXTENSIONS *crlEntryDetails; +} OSSL_CMP_REVDETAILS; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVDETAILS) +DEFINE_STACK_OF(OSSL_CMP_REVDETAILS) + +/*- + * RevRepContent ::= SEQUENCE { + * status SEQUENCE SIZE (1..MAX) OF PKIStatusInfo, + * -- in same order as was sent in RevReqContent + * revCerts [0] SEQUENCE SIZE (1..MAX) OF CertId + * OPTIONAL, + * -- IDs for which revocation was requested + * -- (same order as status) + * crls [1] SEQUENCE SIZE (1..MAX) OF CertificateList + * OPTIONAL + * -- the resulting CRLs (there may be more than one) + * } + */ +struct OSSL_cmp_revrepcontent_st { + STACK_OF(OSSL_CMP_PKISI) *status; + STACK_OF(OSSL_CRMF_CERTID) *revCerts; + STACK_OF(X509_CRL) *crls; +} /* OSSL_CMP_REVREPCONTENT */; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVREPCONTENT) + +/*- + * KeyRecRepContent ::= SEQUENCE { + * status PKIStatusInfo, + * newSigCert [0] Certificate OPTIONAL, + * caCerts [1] SEQUENCE SIZE (1..MAX) OF + * Certificate OPTIONAL, + * keyPairHist [2] SEQUENCE SIZE (1..MAX) OF + * CertifiedKeyPair OPTIONAL + * } + */ +typedef struct OSSL_cmp_keyrecrepcontent_st { + OSSL_CMP_PKISI *status; + X509 *newSigCert; + STACK_OF(X509) *caCerts; + STACK_OF(OSSL_CMP_CERTIFIEDKEYPAIR) *keyPairHist; +} OSSL_CMP_KEYRECREPCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_KEYRECREPCONTENT) + +/*- + * ErrorMsgContent ::= SEQUENCE { + * pKIStatusInfo PKIStatusInfo, + * errorCode INTEGER OPTIONAL, + * -- implementation-specific error codes + * errorDetails PKIFreeText OPTIONAL + * -- implementation-specific error details + * } + */ +typedef struct OSSL_cmp_errormsgcontent_st { + OSSL_CMP_PKISI *pKIStatusInfo; + ASN1_INTEGER *errorCode; + OSSL_CMP_PKIFREETEXT *errorDetails; +} OSSL_CMP_ERRORMSGCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_ERRORMSGCONTENT) + +/*- + * CertConfirmContent ::= SEQUENCE OF CertStatus + * + * CertStatus ::= SEQUENCE { + * certHash OCTET STRING, + * -- the hash of the certificate, using the same hash algorithm + * -- as is used to create and verify the certificate signature + * certReqId INTEGER, + * -- to match this confirmation with the corresponding req/rep + * statusInfo PKIStatusInfo OPTIONAL + * } + */ +struct OSSL_cmp_certstatus_st { + ASN1_OCTET_STRING *certHash; + ASN1_INTEGER *certReqId; + OSSL_CMP_PKISI *statusInfo; +} /* OSSL_CMP_CERTSTATUS */; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTSTATUS) + +typedef STACK_OF(OSSL_CMP_CERTSTATUS) OSSL_CMP_CERTCONFIRMCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTCONFIRMCONTENT) + +/*- + * CertResponse ::= SEQUENCE { + * certReqId INTEGER, + * -- to match this response with corresponding request (a value + * -- of -1 is to be used if certReqId is not specified in the + * -- corresponding request) + * status PKIStatusInfo, + * certifiedKeyPair CertifiedKeyPair OPTIONAL, + * rspInfo OCTET STRING OPTIONAL + * -- analogous to the id-regInfo-utf8Pairs string defined + * -- for regInfo in CertReqMsg [CRMF] + * } + */ +struct OSSL_cmp_certresponse_st { + ASN1_INTEGER *certReqId; + OSSL_CMP_PKISI *status; + OSSL_CMP_CERTIFIEDKEYPAIR *certifiedKeyPair; + ASN1_OCTET_STRING *rspInfo; +} /* OSSL_CMP_CERTRESPONSE */; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTRESPONSE) + +/*- + * CertRepMessage ::= SEQUENCE { + * caPubs [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate + * OPTIONAL, + * response SEQUENCE OF CertResponse + * } + */ +struct OSSL_cmp_certrepmessage_st { + STACK_OF(X509) *caPubs; + STACK_OF(OSSL_CMP_CERTRESPONSE) *response; +} /* OSSL_CMP_CERTREPMESSAGE */; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CERTREPMESSAGE) + +/*- + * PollReqContent ::= SEQUENCE OF SEQUENCE { + * certReqId INTEGER + * } + */ +typedef struct OSSL_cmp_pollreq_st { + ASN1_INTEGER *certReqId; +} OSSL_CMP_POLLREQ; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREQ) +DEFINE_STACK_OF(OSSL_CMP_POLLREQ) +typedef STACK_OF(OSSL_CMP_POLLREQ) OSSL_CMP_POLLREQCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREQCONTENT) + +/*- + * PollRepContent ::= SEQUENCE OF SEQUENCE { + * certReqId INTEGER, + * checkAfter INTEGER, -- time in seconds + * reason PKIFreeText OPTIONAL + * } + */ +struct OSSL_cmp_pollrep_st { + ASN1_INTEGER *certReqId; + ASN1_INTEGER *checkAfter; + OSSL_CMP_PKIFREETEXT *reason; +} /* OSSL_CMP_POLLREP */; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREP) +DEFINE_STACK_OF(OSSL_CMP_POLLREP) +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POLLREPCONTENT) + +/*- + * PKIHeader ::= SEQUENCE { + * pvno INTEGER { cmp1999(1), cmp2000(2) }, + * sender GeneralName, + * -- identifies the sender + * recipient GeneralName, + * -- identifies the intended recipient + * messageTime [0] GeneralizedTime OPTIONAL, + * -- time of production of this message (used when sender + * -- believes that the transport will be "suitable"; i.e., + * -- that the time will still be meaningful upon receipt) + * protectionAlg [1] AlgorithmIdentifier OPTIONAL, + * -- algorithm used for calculation of protection bits + * senderKID [2] KeyIdentifier OPTIONAL, + * recipKID [3] KeyIdentifier OPTIONAL, + * -- to identify specific keys used for protection + * transactionID [4] OCTET STRING OPTIONAL, + * -- identifies the transaction; i.e., this will be the same in + * -- corresponding request, response, certConf, and PKIConf + * -- messages + * senderNonce [5] OCTET STRING OPTIONAL, + * recipNonce [6] OCTET STRING OPTIONAL, + * -- nonces used to provide replay protection, senderNonce + * -- is inserted by the creator of this message; recipNonce + * -- is a nonce previously inserted in a related message by + * -- the intended recipient of this message + * freeText [7] PKIFreeText OPTIONAL, + * -- this may be used to indicate context-specific instructions + * -- (this field is intended for human consumption) + * generalInfo [8] SEQUENCE SIZE (1..MAX) OF + * InfoTypeAndValue OPTIONAL + * -- this may be used to convey context-specific information + * -- (this field not primarily intended for human consumption) + * } + */ +struct OSSL_cmp_pkiheader_st { + ASN1_INTEGER *pvno; + GENERAL_NAME *sender; + GENERAL_NAME *recipient; + ASN1_GENERALIZEDTIME *messageTime; /* 0 */ + X509_ALGOR *protectionAlg; /* 1 */ + ASN1_OCTET_STRING *senderKID; /* 2 */ + ASN1_OCTET_STRING *recipKID; /* 3 */ + ASN1_OCTET_STRING *transactionID; /* 4 */ + ASN1_OCTET_STRING *senderNonce; /* 5 */ + ASN1_OCTET_STRING *recipNonce; /* 6 */ + OSSL_CMP_PKIFREETEXT *freeText; /* 7 */ + STACK_OF(OSSL_CMP_ITAV) *generalInfo; /* 8 */ +} /* OSSL_CMP_PKIHEADER */; + +typedef STACK_OF(OSSL_CMP_CHALLENGE) OSSL_CMP_POPODECKEYCHALLCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POPODECKEYCHALLCONTENT) +typedef STACK_OF(ASN1_INTEGER) OSSL_CMP_POPODECKEYRESPCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_POPODECKEYRESPCONTENT) +typedef STACK_OF(OSSL_CMP_REVDETAILS) OSSL_CMP_REVREQCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_REVREQCONTENT) +typedef STACK_OF(X509_CRL) OSSL_CMP_CRLANNCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_CRLANNCONTENT) +typedef STACK_OF(OSSL_CMP_ITAV) OSSL_CMP_GENMSGCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_GENMSGCONTENT) +typedef STACK_OF(OSSL_CMP_ITAV) OSSL_CMP_GENREPCONTENT; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_GENREPCONTENT) + +/*- + * PKIBody ::= CHOICE { -- message-specific body elements + * ir [0] CertReqMessages, --Initialization Request + * ip [1] CertRepMessage, --Initialization Response + * cr [2] CertReqMessages, --Certification Request + * cp [3] CertRepMessage, --Certification Response + * p10cr [4] CertificationRequest, --imported from [PKCS10] + * popdecc [5] POPODecKeyChallContent, --pop Challenge + * popdecr [6] POPODecKeyRespContent, --pop Response + * kur [7] CertReqMessages, --Key Update Request + * kup [8] CertRepMessage, --Key Update Response + * krr [9] CertReqMessages, --Key Recovery Request + * krp [10] KeyRecRepContent, --Key Recovery Response + * rr [11] RevReqContent, --Revocation Request + * rp [12] RevRepContent, --Revocation Response + * ccr [13] CertReqMessages, --Cross-Cert. Request + * ccp [14] CertRepMessage, --Cross-Cert. Response + * ckuann [15] CAKeyUpdAnnContent, --CA Key Update Ann. + * cann [16] CertAnnContent, --Certificate Ann. + * rann [17] RevAnnContent, --Revocation Ann. + * crlann [18] CRLAnnContent, --CRL Announcement + * pkiconf [19] PKIConfirmContent, --Confirmation + * nested [20] NestedMessageContent, --Nested Message + * genm [21] GenMsgContent, --General Message + * genp [22] GenRepContent, --General Response + * error [23] ErrorMsgContent, --Error Message + * certConf [24] CertConfirmContent, --Certificate confirm + * pollReq [25] PollReqContent, --Polling request + * pollRep [26] PollRepContent --Polling response + */ +typedef struct OSSL_cmp_pkibody_st { + int type; + union { + OSSL_CRMF_MSGS *ir; /* 0 */ + OSSL_CMP_CERTREPMESSAGE *ip; /* 1 */ + OSSL_CRMF_MSGS *cr; /* 2 */ + OSSL_CMP_CERTREPMESSAGE *cp; /* 3 */ + /* p10cr [4] CertificationRequest, --imported from [PKCS10] */ + /* + * PKCS10_CERTIFICATIONREQUEST is effectively X509_REQ + * so it is used directly + */ + X509_REQ *p10cr; /* 4 */ + /* popdecc [5] POPODecKeyChallContent, --pop Challenge */ + /* POPODecKeyChallContent ::= SEQUENCE OF Challenge */ + OSSL_CMP_POPODECKEYCHALLCONTENT *popdecc; /* 5 */ + /* popdecr [6] POPODecKeyRespContent, --pop Response */ + /* POPODecKeyRespContent ::= SEQUENCE OF INTEGER */ + OSSL_CMP_POPODECKEYRESPCONTENT *popdecr; /* 6 */ + OSSL_CRMF_MSGS *kur; /* 7 */ + OSSL_CMP_CERTREPMESSAGE *kup; /* 8 */ + OSSL_CRMF_MSGS *krr; /* 9 */ + + /* krp [10] KeyRecRepContent, --Key Recovery Response */ + OSSL_CMP_KEYRECREPCONTENT *krp; /* 10 */ + /* rr [11] RevReqContent, --Revocation Request */ + OSSL_CMP_REVREQCONTENT *rr; /* 11 */ + /* rp [12] RevRepContent, --Revocation Response */ + OSSL_CMP_REVREPCONTENT *rp; /* 12 */ + /* ccr [13] CertReqMessages, --Cross-Cert. Request */ + OSSL_CRMF_MSGS *ccr; /* 13 */ + /* ccp [14] CertRepMessage, --Cross-Cert. Response */ + OSSL_CMP_CERTREPMESSAGE *ccp; /* 14 */ + /* ckuann [15] CAKeyUpdAnnContent, --CA Key Update Ann. */ + OSSL_CMP_CAKEYUPDANNCONTENT *ckuann; /* 15 */ + /* cann [16] CertAnnContent, --Certificate Ann. */ + /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */ + X509 *cann; /* 16 */ + /* rann [17] RevAnnContent, --Revocation Ann. */ + OSSL_CMP_REVANNCONTENT *rann; /* 17 */ + /* crlann [18] CRLAnnContent, --CRL Announcement */ + /* CRLAnnContent ::= SEQUENCE OF CertificateList */ + OSSL_CMP_CRLANNCONTENT *crlann; + /* PKIConfirmContent ::= NULL */ + /* pkiconf [19] PKIConfirmContent, --Confirmation */ + /* OSSL_CMP_PKICONFIRMCONTENT would be only a typedef of ASN1_NULL */ + /* OSSL_CMP_CONFIRMCONTENT *pkiconf; */ + /* + * NOTE: this should ASN1_NULL according to the RFC + * but there might be a struct in it when sent from faulty servers... + */ + ASN1_TYPE *pkiconf; /* 19 */ + /* nested [20] NestedMessageContent, --Nested Message */ + /* NestedMessageContent ::= PKIMessages */ + OSSL_CMP_MSGS *nested; /* 20 */ + /* genm [21] GenMsgContent, --General Message */ + /* GenMsgContent ::= SEQUENCE OF InfoTypeAndValue */ + OSSL_CMP_GENMSGCONTENT *genm; /* 21 */ + /* genp [22] GenRepContent, --General Response */ + /* GenRepContent ::= SEQUENCE OF InfoTypeAndValue */ + OSSL_CMP_GENREPCONTENT *genp; /* 22 */ + /* error [23] ErrorMsgContent, --Error Message */ + OSSL_CMP_ERRORMSGCONTENT *error; /* 23 */ + /* certConf [24] CertConfirmContent, --Certificate confirm */ + OSSL_CMP_CERTCONFIRMCONTENT *certConf; /* 24 */ + /* pollReq [25] PollReqContent, --Polling request */ + OSSL_CMP_POLLREQCONTENT *pollReq; + /* pollRep [26] PollRepContent --Polling response */ + OSSL_CMP_POLLREPCONTENT *pollRep; + } value; +} OSSL_CMP_PKIBODY; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKIBODY) + +/*- + * PKIProtection ::= BIT STRING + * + * PKIMessages ::= SEQUENCE SIZE (1..MAX) OF PKIMessage + * + * PKIMessage ::= SEQUENCE { + * header PKIHeader, + * body PKIBody, + * protection [0] PKIProtection OPTIONAL, + * extraCerts [1] SEQUENCE SIZE (1..MAX) OF CMPCertificate + * OPTIONAL + * } + */ +struct OSSL_cmp_msg_st { + OSSL_CMP_PKIHEADER *header; + OSSL_CMP_PKIBODY *body; + ASN1_BIT_STRING *protection; /* 0 */ + /* OSSL_CMP_CMPCERTIFICATE is effectively X509 so it is used directly */ + STACK_OF(X509) *extraCerts; /* 1 */ +} /* OSSL_CMP_MSG */; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_MSG) + +/*- + * ProtectedPart ::= SEQUENCE { + * header PKIHeader, + * body PKIBody + * } + */ +typedef struct cmp_protectedpart_st { + OSSL_CMP_PKIHEADER *header; + OSSL_CMP_PKIBODY *body; +} CMP_PROTECTEDPART; +DECLARE_ASN1_FUNCTIONS(CMP_PROTECTEDPART) + +/*- + * this is not defined here as it is already in CRMF: + * id-PasswordBasedMac OBJECT IDENTIFIER ::= {1 2 840 113533 7 66 13} + * PBMParameter ::= SEQUENCE { + * salt OCTET STRING, + * -- note: implementations MAY wish to limit acceptable sizes + * -- of this string to values appropriate for their environment + * -- in order to reduce the risk of denial-of-service attacks + * owf AlgorithmIdentifier, + * -- AlgId for a One-Way Function (SHA-1 recommended) + * iterationCount INTEGER, + * -- number of times the OWF is applied + * -- note: implementations MAY wish to limit acceptable sizes + * -- of this integer to values appropriate for their environment + * -- in order to reduce the risk of denial-of-service attacks + * mac AlgorithmIdentifier + * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11], + * } -- or HMAC [RFC2104, RFC2202]) + */ +/*- + * TODO: this is not yet defined here - but DH is anyway not used yet + * + * id-DHBasedMac OBJECT IDENTIFIER ::= {1 2 840 113533 7 66 30} + * DHBMParameter ::= SEQUENCE { + * owf AlgorithmIdentifier, + * -- AlgId for a One-Way Function (SHA-1 recommended) + * mac AlgorithmIdentifier + * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11], + * } -- or HMAC [RFC2104, RFC2202]) + */ +/*- + * The following is not cared for, because it is described in section 5.2.5 + * that this is beyond the scope of CMP + * OOBCert ::= CMPCertificate + * + * OOBCertHash ::= SEQUENCE { + * hashAlg [0] AlgorithmIdentifier OPTIONAL, + * certId [1] CertId OPTIONAL, + * hashVal BIT STRING + * -- hashVal is calculated over the DER encoding of the + * -- self-signed certificate with the identifier certID. + * } + */ + +#endif /* !defined OSSL_HEADER_CMP_INT_H */ diff --git a/crypto/cms/cms_att.c b/crypto/cms/cms_att.c index a68b9bce..e5481805 100644 --- a/crypto/cms/cms_att.c +++ b/crypto/cms/cms_att.c @@ -13,6 +13,56 @@ #include #include #include "cms_lcl.h" +#include "internal/nelem.h" + +/*- + * Attribute flags. + * CMS attribute restrictions are discussed in + * - RFC 5652 Section 11. + * ESS attribute restrictions are discussed in + * - RFC 2634 Section 1.3.4 AND + * - RFC 5035 Section 5.4 + */ +/* This is a signed attribute */ +#define CMS_ATTR_F_SIGNED 0x01 +/* This is an unsigned attribute */ +#define CMS_ATTR_F_UNSIGNED 0x02 +/* Must be present if there are any other attributes of the same type */ +#define CMS_ATTR_F_REQUIRED_COND 0x10 +/* There can only be one instance of this attribute */ +#define CMS_ATTR_F_ONLY_ONE 0x20 +/* The Attribute's value must have exactly one entry */ +#define CMS_ATTR_F_ONE_ATTR_VALUE 0x40 + +/* Attributes rules for different attributes */ +static const struct { + int nid; /* The attribute id */ + int flags; +} cms_attribute_properties[] = { + /* See RFC Section 11 */ + { NID_pkcs9_contentType, CMS_ATTR_F_SIGNED + | CMS_ATTR_F_ONLY_ONE + | CMS_ATTR_F_ONE_ATTR_VALUE + | CMS_ATTR_F_REQUIRED_COND }, + { NID_pkcs9_messageDigest, CMS_ATTR_F_SIGNED + | CMS_ATTR_F_ONLY_ONE + | CMS_ATTR_F_ONE_ATTR_VALUE + | CMS_ATTR_F_REQUIRED_COND }, + { NID_pkcs9_signingTime, CMS_ATTR_F_SIGNED + | CMS_ATTR_F_ONLY_ONE + | CMS_ATTR_F_ONE_ATTR_VALUE }, + { NID_pkcs9_countersignature, CMS_ATTR_F_UNSIGNED }, + /* ESS */ + { NID_id_smime_aa_signingCertificate, CMS_ATTR_F_SIGNED + | CMS_ATTR_F_ONLY_ONE + | CMS_ATTR_F_ONE_ATTR_VALUE }, + { NID_id_smime_aa_signingCertificateV2, CMS_ATTR_F_SIGNED + | CMS_ATTR_F_ONLY_ONE + | CMS_ATTR_F_ONE_ATTR_VALUE }, + { NID_id_smime_aa_receiptRequest, CMS_ATTR_F_SIGNED + | CMS_ATTR_F_ONLY_ONE + | CMS_ATTR_F_ONE_ATTR_VALUE } +}; /* CMS SignedData Attribute utilities */ @@ -149,4 +199,86 @@ void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid, return X509at_get0_data_by_OBJ(si->unsignedAttrs, oid, lastpos, type); } -/* Specific attribute cases */ +/* + * Retrieve an attribute by nid from a stack of attributes starting at index + * *lastpos + 1. + * Returns the attribute or NULL if there is no attribute. + * If an attribute was found *lastpos returns the index of the found attribute. + */ +static X509_ATTRIBUTE *cms_attrib_get(int nid, + const STACK_OF(X509_ATTRIBUTE) *attrs, + int *lastpos) +{ + X509_ATTRIBUTE *at; + int loc; + + loc = X509at_get_attr_by_NID(attrs, nid, *lastpos); + if (loc < 0) + return NULL; + + at = X509at_get_attr(attrs, loc); + *lastpos = loc; + return at; +} + +static int cms_check_attribute(int nid, int flags, int type, + const STACK_OF(X509_ATTRIBUTE) *attrs, + int have_attrs) +{ + int lastpos = -1; + X509_ATTRIBUTE *at = cms_attrib_get(nid, attrs, &lastpos); + + if (at != NULL) { + int count = X509_ATTRIBUTE_count(at); + + /* Is this attribute allowed? */ + if (((flags & type) == 0) + /* check if multiple attributes of the same type are allowed */ + || (((flags & CMS_ATTR_F_ONLY_ONE) != 0) + && cms_attrib_get(nid, attrs, &lastpos) != NULL) + /* Check if attribute should have exactly one value in its set */ + || (((flags & CMS_ATTR_F_ONE_ATTR_VALUE) != 0) + && count != 1) + /* There should be at least one value */ + || count == 0) + return 0; + } else { + /* fail if a required attribute is missing */ + if (have_attrs + && ((flags & CMS_ATTR_F_REQUIRED_COND) != 0) + && (flags & type) != 0) + return 0; + } + return 1; +} + +/* + * Check that the signerinfo attributes obey the attribute rules which includes + * the following checks + * - If any signed attributes exist then there must be a Content Type + * and Message Digest attribute in the signed attributes. + * - The countersignature attribute is an optional unsigned attribute only. + * - Content Type, Message Digest, and Signing time attributes are signed + * attributes. Only one instance of each is allowed, with each of these + * attributes containing a single attribute value in its set. + */ +int CMS_si_check_attributes(const CMS_SignerInfo *si) +{ + int i; + int have_signed_attrs = (CMS_signed_get_attr_count(si) > 0); + int have_unsigned_attrs = (CMS_unsigned_get_attr_count(si) > 0); + + for (i = 0; i < (int)OSSL_NELEM(cms_attribute_properties); ++i) { + int nid = cms_attribute_properties[i].nid; + int flags = cms_attribute_properties[i].flags; + + if (!cms_check_attribute(nid, flags, CMS_ATTR_F_SIGNED, + si->signedAttrs, have_signed_attrs) + || !cms_check_attribute(nid, flags, CMS_ATTR_F_UNSIGNED, + si->unsignedAttrs, have_unsigned_attrs)) { + CMSerr(CMS_F_CMS_SI_CHECK_ATTRIBUTES, CMS_R_ATTRIBUTE_ERROR); + return 0; + } + } + return 1; +} diff --git a/crypto/cms/cms_err.c b/crypto/cms/cms_err.c index f7d4b7fd..c05de0e6 100644 --- a/crypto/cms/cms_err.c +++ b/crypto/cms/cms_err.c @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -150,6 +150,8 @@ static const ERR_STRING_DATA CMS_str_functs[] = { {ERR_PACK(ERR_LIB_CMS, CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT, 0), "CMS_SignerInfo_verify_content"}, {ERR_PACK(ERR_LIB_CMS, CMS_F_CMS_SIGN_RECEIPT, 0), "CMS_sign_receipt"}, + {ERR_PACK(ERR_LIB_CMS, CMS_F_CMS_SI_CHECK_ATTRIBUTES, 0), + "CMS_si_check_attributes"}, {ERR_PACK(ERR_LIB_CMS, CMS_F_CMS_STREAM, 0), "CMS_stream"}, {ERR_PACK(ERR_LIB_CMS, CMS_F_CMS_UNCOMPRESS, 0), "CMS_uncompress"}, {ERR_PACK(ERR_LIB_CMS, CMS_F_CMS_VERIFY, 0), "CMS_verify"}, @@ -159,6 +161,7 @@ static const ERR_STRING_DATA CMS_str_functs[] = { static const ERR_STRING_DATA CMS_str_reasons[] = { {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ADD_SIGNER_ERROR), "add signer error"}, + {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_ATTRIBUTE_ERROR), "attribute error"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CERTIFICATE_ALREADY_PRESENT), "certificate already present"}, {ERR_PACK(ERR_LIB_CMS, 0, CMS_R_CERTIFICATE_HAS_NO_KEYID), diff --git a/crypto/cms/cms_lcl.h b/crypto/cms/cms_lcl.h index 64b673ac..dbc329d1 100644 --- a/crypto/cms/cms_lcl.h +++ b/crypto/cms/cms_lcl.h @@ -416,6 +416,8 @@ int cms_RecipientInfo_kari_encrypt(const CMS_ContentInfo *cms, /* PWRI routines */ int cms_RecipientInfo_pwri_crypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri, int en_de); +/* SignerInfo routines */ +int CMS_si_check_attributes(const CMS_SignerInfo *si); DECLARE_ASN1_ITEM(CMS_CertificateChoices) DECLARE_ASN1_ITEM(CMS_DigestedData) diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c index 71b30411..40a33563 100644 --- a/crypto/cms/cms_sd.c +++ b/crypto/cms/cms_sd.c @@ -109,6 +109,27 @@ static void cms_sd_set_version(CMS_SignedData *sd) } +/* + * RFC 5652 Section 11.1 Content Type + * The content-type attribute within signed-data MUST + * 1) be present if there are signed attributes + * 2) match the content type in the signed-data, + * 3) be a signed attribute. + * 4) not have more than one copy of the attribute. + * + * Note that since the CMS_SignerInfo_sign() always adds the "signing time" + * attribute, the content type attribute MUST be added also. + * Assumptions: This assumes that the attribute does not already exist. + */ +static int cms_set_si_contentType_attr(CMS_ContentInfo *cms, CMS_SignerInfo *si) +{ + ASN1_OBJECT *ctype = cms->d.signedData->encapContentInfo->eContentType; + + /* Add the contentType attribute */ + return CMS_signed_add1_attr_by_NID(si, NID_pkcs9_contentType, + V_ASN1_OBJECT, ctype, -1) > 0; +} + /* Copy an existing messageDigest value */ static int cms_copy_messageDigest(CMS_ContentInfo *cms, CMS_SignerInfo *si) @@ -325,13 +346,6 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, if (!i) goto merr; } - if (flags & CMS_REUSE_DIGEST) { - if (!cms_copy_messageDigest(cms, si)) - goto err; - if (!(flags & (CMS_PARTIAL | CMS_KEY_PARAM)) && - !CMS_SignerInfo_sign(si)) - goto err; - } if (flags & CMS_CADES) { ESS_SIGNING_CERT *sc = NULL; ESS_SIGNING_CERT_V2 *sc2 = NULL; @@ -353,6 +367,15 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, if (!add_sc) goto err; } + if (flags & CMS_REUSE_DIGEST) { + if (!cms_copy_messageDigest(cms, si)) + goto err; + if (!cms_set_si_contentType_attr(cms, si)) + goto err; + if (!(flags & (CMS_PARTIAL | CMS_KEY_PARAM)) && + !CMS_SignerInfo_sign(si)) + goto err; + } } if (!(flags & CMS_NOCERTS)) { @@ -370,8 +393,7 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, goto err; if (EVP_PKEY_CTX_set_signature_md(si->pctx, md) <= 0) goto err; - } else if (EVP_DigestSignInit(si->mctx, &si->pctx, md, NULL, pk) <= - 0) + } else if (EVP_DigestSignInit(si->mctx, &si->pctx, md, NULL, pk) <= 0) goto err; } @@ -579,8 +601,6 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms, */ if (CMS_signed_get_attr_count(si) >= 0) { - ASN1_OBJECT *ctype = - cms->d.signedData->encapContentInfo->eContentType; unsigned char md[EVP_MAX_MD_SIZE]; unsigned int mdlen; if (!EVP_DigestFinal_ex(mctx, md, &mdlen)) @@ -589,9 +609,9 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms, V_ASN1_OCTET_STRING, md, mdlen)) goto err; /* Copy content type across */ - if (CMS_signed_add1_attr_by_NID(si, NID_pkcs9_contentType, - V_ASN1_OBJECT, ctype, -1) <= 0) + if (!cms_set_si_contentType_attr(cms, si)) goto err; + if (!CMS_SignerInfo_sign(si)) goto err; } else if (si->pctx) { @@ -671,6 +691,9 @@ int CMS_SignerInfo_sign(CMS_SignerInfo *si) goto err; } + if (!CMS_si_check_attributes(si)) + goto err; + if (si->pctx) pctx = si->pctx; else { @@ -717,7 +740,6 @@ int CMS_SignerInfo_sign(CMS_SignerInfo *si) OPENSSL_free(abuf); EVP_MD_CTX_reset(mctx); return 0; - } int CMS_SignerInfo_verify(CMS_SignerInfo *si) @@ -732,6 +754,9 @@ int CMS_SignerInfo_verify(CMS_SignerInfo *si) return -1; } + if (!CMS_si_check_attributes(si)) + return -1; + md = EVP_get_digestbyobj(si->digestAlgorithm->algorithm); if (md == NULL) return -1; diff --git a/crypto/conf/conf_sap.c b/crypto/conf/conf_sap.c index 3994a863..921ff770 100644 --- a/crypto/conf/conf_sap.c +++ b/crypto/conf/conf_sap.c @@ -42,7 +42,7 @@ void OPENSSL_config(const char *appname) int openssl_config_int(const OPENSSL_INIT_SETTINGS *settings) { - int ret; + int ret = 0; const char *filename; const char *appname; unsigned long flags; diff --git a/crypto/context.c b/crypto/context.c index 7a976c02..cc1ec0e6 100644 --- a/crypto/context.c +++ b/crypto/context.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "internal/cryptlib.h" +#include "internal/cryptlib_int.h" #include "internal/thread_once.h" struct openssl_ctx_onfree_list_st { @@ -80,6 +80,8 @@ static int context_deinit(OPENSSL_CTX *ctx) if (ctx == NULL) return 1; + ossl_ctx_thread_stop(ctx); + onfree = ctx->onfreelist; while (onfree != NULL) { onfree->fn(ctx); @@ -129,6 +131,18 @@ void OPENSSL_CTX_free(OPENSSL_CTX *ctx) OPENSSL_free(ctx); } +OPENSSL_CTX *openssl_ctx_get_concrete(OPENSSL_CTX *ctx) +{ +#ifndef FIPS_MODE + if (ctx == NULL) { + if (!RUN_ONCE(&default_context_init, do_default_context_init)) + return 0; + return default_context; + } +#endif + return ctx; +} + static void openssl_ctx_generic_new(void *parent_ign, void *ptr_ign, CRYPTO_EX_DATA *ad, int index, long argl_ign, void *argp) @@ -154,13 +168,7 @@ static int openssl_ctx_init_index(OPENSSL_CTX *ctx, int static_index, { int idx; -#ifndef FIPS_MODE - if (ctx == NULL) { - if (!RUN_ONCE(&default_context_init, do_default_context_init)) - return 0; - ctx = default_context; - } -#endif + ctx = openssl_ctx_get_concrete(ctx); if (ctx == NULL) return 0; @@ -180,13 +188,7 @@ void *openssl_ctx_get_data(OPENSSL_CTX *ctx, int index, { void *data = NULL; -#ifndef FIPS_MODE - if (ctx == NULL) { - if (!RUN_ONCE(&default_context_init, do_default_context_init)) - return NULL; - ctx = default_context; - } -#endif + ctx = openssl_ctx_get_concrete(ctx); if (ctx == NULL) return NULL; @@ -210,18 +212,7 @@ void *openssl_ctx_get_data(OPENSSL_CTX *ctx, int index, OSSL_EX_DATA_GLOBAL *openssl_ctx_get_ex_data_global(OPENSSL_CTX *ctx) { - /* - * The default context code is not needed in FIPS_MODE and ctx should never - * be NULL in the FIPS provider. However we compile this code out to ensure - * we fail immediately if ctx == NULL in FIPS_MODE - */ -#ifndef FIPS_MODE - if (ctx == NULL) { - if (!RUN_ONCE(&default_context_init, do_default_context_init)) - return NULL; - ctx = default_context; - } -#endif + ctx = openssl_ctx_get_concrete(ctx); if (ctx == NULL) return NULL; return &ctx->global; @@ -232,13 +223,7 @@ int openssl_ctx_run_once(OPENSSL_CTX *ctx, unsigned int idx, { int done = 0, ret = 0; -#ifndef FIPS_MODE - if (ctx == NULL) { - if (!RUN_ONCE(&default_context_init, do_default_context_init)) - return 0; - ctx = default_context; - } -#endif + ctx = openssl_ctx_get_concrete(ctx); if (ctx == NULL) return 0; diff --git a/crypto/core_fetch.c b/crypto/core_fetch.c index 227f9207..56a3c5ca 100644 --- a/crypto/core_fetch.c +++ b/crypto/core_fetch.c @@ -31,6 +31,9 @@ static int ossl_method_construct_this(OSSL_PROVIDER *provider, void *cbdata) const OSSL_ALGORITHM *map = ossl_provider_query_operation(provider, data->operation_id, &no_store); + if (map == NULL) + return 0; + while (map->algorithm_name != NULL) { const OSSL_ALGORITHM *thismap = map++; void *method = NULL; @@ -56,12 +59,12 @@ static int ossl_method_construct_this(OSSL_PROVIDER *provider, void *cbdata) * If we haven't been told not to store, * add to the global store */ - data->mcm->put(data->libctx, NULL, method, + data->mcm->put(data->libctx, NULL, method, data->operation_id, thismap->algorithm_name, thismap->property_definition, data->mcm_data); } - data->mcm->put(data->libctx, data->store, method, + data->mcm->put(data->libctx, data->store, method, data->operation_id, thismap->algorithm_name, thismap->property_definition, data->mcm_data); @@ -80,7 +83,8 @@ void *ossl_method_construct(OPENSSL_CTX *libctx, int operation_id, void *method = NULL; if ((method = - mcm->get(libctx, NULL, name, propquery, mcm_data)) == NULL) { + mcm->get(libctx, NULL, operation_id, name, propquery, mcm_data)) + == NULL) { struct construct_data_st cbdata; /* @@ -98,7 +102,8 @@ void *ossl_method_construct(OPENSSL_CTX *libctx, int operation_id, ossl_provider_forall_loaded(libctx, ossl_method_construct_this, &cbdata); - method = mcm->get(libctx, cbdata.store, name, propquery, mcm_data); + method = mcm->get(libctx, cbdata.store, operation_id, name, + propquery, mcm_data); mcm->dealloc_tmp_store(cbdata.store); } diff --git a/crypto/core_namemap.c b/crypto/core_namemap.c index 5155a221..d4c94190 100644 --- a/crypto/core_namemap.c +++ b/crypto/core_namemap.c @@ -7,45 +7,52 @@ * https://www.openssl.org/source/license.html */ +#include "e_os.h" /* strcasecmp */ #include "internal/namemap.h" #include -#include +#include "internal/lhash.h" /* openssl_lh_strcasehash */ -/* The namemap entry */ +/*- + * The namenum entry + * ================= + */ typedef struct { + char *name; int number; - const char *name; - char body[1]; /* Sized appropriately to contain the name */ -} NAMEMAP_ENTRY; +} NAMENUM_ENTRY; -DEFINE_LHASH_OF(NAMEMAP_ENTRY); -DEFINE_STACK_OF(NAMEMAP_ENTRY) +DEFINE_LHASH_OF(NAMENUM_ENTRY); -/* The namemap, which provides for bidirectional indexing */ +/*- + * The namemap itself + * ================== + */ struct ossl_namemap_st { /* Flags */ unsigned int stored:1; /* If 1, it's stored in a library context */ CRYPTO_RWLOCK *lock; - LHASH_OF(NAMEMAP_ENTRY) *namenum; /* Name->number mapping */ - STACK_OF(NAMEMAP_ENTRY) *numname; /* Number->name mapping */ + LHASH_OF(NAMENUM_ENTRY) *namenum; /* Name->number mapping */ + int max_number; /* Current max number */ }; /* LHASH callbacks */ -static unsigned long namemap_hash(const NAMEMAP_ENTRY *n) +static unsigned long namenum_hash(const NAMENUM_ENTRY *n) { - return OPENSSL_LH_strhash(n->name); + return openssl_lh_strcasehash(n->name); } -static int namemap_cmp(const NAMEMAP_ENTRY *a, const NAMEMAP_ENTRY *b) +static int namenum_cmp(const NAMENUM_ENTRY *a, const NAMENUM_ENTRY *b) { - return strcmp(a->name, b->name); + return strcasecmp(a->name, b->name); } -static void namemap_free(NAMEMAP_ENTRY *n) +static void namenum_free(NAMENUM_ENTRY *n) { + if (n != NULL) + OPENSSL_free(n->name); OPENSSL_free(n); } @@ -75,7 +82,10 @@ static const OPENSSL_CTX_METHOD stored_namemap_method = { stored_namemap_free, }; -/* API functions */ +/*- + * API functions + * ============= + */ OSSL_NAMEMAP *ossl_namemap_stored(OPENSSL_CTX *libctx) { @@ -89,11 +99,9 @@ OSSL_NAMEMAP *ossl_namemap_new(void) if ((namemap = OPENSSL_zalloc(sizeof(*namemap))) != NULL && (namemap->lock = CRYPTO_THREAD_lock_new()) != NULL - && (namemap->numname = sk_NAMEMAP_ENTRY_new_null()) != NULL && (namemap->namenum = - lh_NAMEMAP_ENTRY_new(namemap_hash, namemap_cmp)) != NULL) { + lh_NAMENUM_ENTRY_new(namenum_hash, namenum_cmp)) != NULL) return namemap; - } ossl_namemap_free(namemap); return NULL; @@ -104,69 +112,71 @@ void ossl_namemap_free(OSSL_NAMEMAP *namemap) if (namemap == NULL || namemap->stored) return; - /* The elements will be freed by sk_NAMEMAP_ENTRY_pop_free() */ - lh_NAMEMAP_ENTRY_free(namemap->namenum); - - sk_NAMEMAP_ENTRY_pop_free(namemap->numname, namemap_free); + lh_NAMENUM_ENTRY_doall(namemap->namenum, namenum_free); + lh_NAMENUM_ENTRY_free(namemap->namenum); CRYPTO_THREAD_lock_free(namemap->lock); OPENSSL_free(namemap); } -/* - * TODO(3.0) It isn't currently possible to have a default namemap in the - * FIPS module because if init and cleanup constraints, so we currently - * disable the code that would allow it when FIPS_MODE is defined. - */ - -const char *ossl_namemap_name(const OSSL_NAMEMAP *namemap, int number) -{ - NAMEMAP_ENTRY *entry; - -#ifndef FIPS_MODE - if (namemap == NULL) - namemap = ossl_namemap_stored(NULL); -#endif - - if (namemap == NULL || number == 0) - return NULL; - - CRYPTO_THREAD_read_lock(namemap->lock); - entry = sk_NAMEMAP_ENTRY_value(namemap->numname, number); - CRYPTO_THREAD_unlock(namemap->lock); - - if (entry != NULL) - return entry->name; - return NULL; -} - -int ossl_namemap_number(const OSSL_NAMEMAP *namemap, const char *name) -{ - NAMEMAP_ENTRY *entry, template; - -#ifndef FIPS_MODE - if (namemap == NULL) - namemap = ossl_namemap_stored(NULL); -#endif - - if (namemap == NULL) - return 0; - - template.name = name; - CRYPTO_THREAD_read_lock(namemap->lock); - entry = lh_NAMEMAP_ENTRY_retrieve(namemap->namenum, &template); - CRYPTO_THREAD_unlock(namemap->lock); - - if (entry == NULL) - return 0; - - return entry->number; -} - -int ossl_namemap_add(OSSL_NAMEMAP *namemap, const char *name) -{ - NAMEMAP_ENTRY *entry; +typedef struct doall_names_data_st { int number; + void (*fn)(const char *name, void *data); + void *data; +} DOALL_NAMES_DATA; + +static void do_name(const NAMENUM_ENTRY *namenum, DOALL_NAMES_DATA *data) +{ + if (namenum->number == data->number) + data->fn(namenum->name, data->data); +} + +IMPLEMENT_LHASH_DOALL_ARG_CONST(NAMENUM_ENTRY, DOALL_NAMES_DATA); + +void ossl_namemap_doall_names(const OSSL_NAMEMAP *namemap, int number, + void (*fn)(const char *name, void *data), + void *data) +{ + DOALL_NAMES_DATA cbdata; + + cbdata.number = number; + cbdata.fn = fn; + cbdata.data = data; + CRYPTO_THREAD_read_lock(namemap->lock); + lh_NAMENUM_ENTRY_doall_DOALL_NAMES_DATA(namemap->namenum, do_name, + &cbdata); + CRYPTO_THREAD_unlock(namemap->lock); +} + +int ossl_namemap_name2num(const OSSL_NAMEMAP *namemap, const char *name) +{ + NAMENUM_ENTRY *namenum_entry, namenum_tmpl; + int number = 0; + +#ifndef FIPS_MODE + if (namemap == NULL) + namemap = ossl_namemap_stored(NULL); +#endif + + if (namemap == NULL) + return 0; + + namenum_tmpl.name = (char *)name; + namenum_tmpl.number = 0; + CRYPTO_THREAD_read_lock(namemap->lock); + namenum_entry = + lh_NAMENUM_ENTRY_retrieve(namemap->namenum, &namenum_tmpl); + if (namenum_entry != NULL) + number = namenum_entry->number; + CRYPTO_THREAD_unlock(namemap->lock); + + return number; +} + +int ossl_namemap_add(OSSL_NAMEMAP *namemap, int number, const char *name) +{ + NAMENUM_ENTRY *namenum = NULL; + int tmp_number; #ifndef FIPS_MODE if (namemap == NULL) @@ -176,36 +186,29 @@ int ossl_namemap_add(OSSL_NAMEMAP *namemap, const char *name) if (name == NULL || namemap == NULL) return 0; - if ((number = ossl_namemap_number(namemap, name)) != 0) - return number; /* Pretend success */ - - if ((entry = OPENSSL_zalloc(sizeof(*entry) + strlen(name))) == NULL) - goto err; - - strcpy(entry->body, name); - entry->name = entry->body; + if ((tmp_number = ossl_namemap_name2num(namemap, name)) != 0) + return tmp_number; /* Pretend success */ CRYPTO_THREAD_write_lock(namemap->lock); - entry->number = sk_NAMEMAP_ENTRY_push(namemap->numname, entry); - - if (entry->number == 0) + if ((namenum = OPENSSL_zalloc(sizeof(*namenum))) == NULL + || (namenum->name = OPENSSL_strdup(name)) == NULL) goto err; - (void)lh_NAMEMAP_ENTRY_insert(namemap->namenum, entry); - if (lh_NAMEMAP_ENTRY_error(namemap->namenum)) + namenum->number = tmp_number = + number != 0 ? number : ++namemap->max_number; + (void)lh_NAMENUM_ENTRY_insert(namemap->namenum, namenum); + + if (lh_NAMENUM_ENTRY_error(namemap->namenum)) goto err; CRYPTO_THREAD_unlock(namemap->lock); - return entry->number; + return tmp_number; err: - if (entry != NULL) { - if (entry->number != 0) - (void)sk_NAMEMAP_ENTRY_pop(namemap->numname); - lh_NAMEMAP_ENTRY_delete(namemap->namenum, entry); - CRYPTO_THREAD_unlock(namemap->lock); - } + namenum_free(namenum); + + CRYPTO_THREAD_unlock(namemap->lock); return 0; } diff --git a/crypto/crmf/crmf_asn.c b/crypto/crmf/crmf_asn.c index 8810cb43..05442c2c 100644 --- a/crypto/crmf/crmf_asn.c +++ b/crypto/crmf/crmf_asn.c @@ -1,7 +1,7 @@ /*- - * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. - * Copyright Nokia 2007-2018 - * Copyright Siemens AG 2015-2018 + * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2019 + * Copyright Siemens AG 2015-2019 * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy diff --git a/crypto/crmf/crmf_int.h b/crypto/crmf/crmf_int.h index f908eac8..b7620578 100644 --- a/crypto/crmf/crmf_int.h +++ b/crypto/crmf/crmf_int.h @@ -1,7 +1,7 @@ /*- - * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. - * Copyright Nokia 2007-2018 - * Copyright Siemens AG 2015-2018 + * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2019 + * Copyright Siemens AG 2015-2019 * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy diff --git a/crypto/crmf/crmf_lib.c b/crypto/crmf/crmf_lib.c index 6a259f96..55f1f38a 100644 --- a/crypto/crmf/crmf_lib.c +++ b/crypto/crmf/crmf_lib.c @@ -1,7 +1,7 @@ /*- - * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. * Copyright Nokia 2007-2018 - * Copyright Siemens AG 2015-2018 + * Copyright Siemens AG 2015-2019 * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy diff --git a/crypto/crmf/crmf_pbm.c b/crypto/crmf/crmf_pbm.c index 09e4ffad..7b291666 100644 --- a/crypto/crmf/crmf_pbm.c +++ b/crypto/crmf/crmf_pbm.c @@ -1,7 +1,7 @@ /*- - * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. - * Copyright Nokia 2007-2018 - * Copyright Siemens AG 2015-2018 + * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2019 + * Copyright Siemens AG 2015-2019 * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy diff --git a/crypto/des/build.info b/crypto/des/build.info index 05cb154c..474d14e2 100644 --- a/crypto/des/build.info +++ b/crypto/des/build.info @@ -1,10 +1,24 @@ +$DESASM=des_enc.c fcrypt_b.c +IF[{- !$disabled{asm} -}] + $DESASM_x86=des-586.s crypt586.s + $DESASM_ia64=ghash-ia64.s + $DESASM_sparcv9=des_enc-sparc.S fcrypt_b.c dest4-sparcv9.S + $DESASM_sparcv8=des_enc-sparc.S fcrypt_b.c + + # Now that we have defined all the arch specific variables, use the + # appropriate one + IF[$DESASM_{- $target{asm_arch} -}] + $DESASM=$DESASM_{- $target{asm_arch} -} + ENDIF +ENDIF + LIBS=../../libcrypto SOURCE[../../libcrypto]=\ set_key.c ecb_enc.c cbc_enc.c \ ecb3_enc.c cfb64enc.c cfb64ede.c cfb_enc.c \ ofb64ede.c ofb64enc.c ofb_enc.c \ str2key.c pcbc_enc.c qud_cksm.c rand_key.c \ - {- $target{des_asm_src} -} \ + $DESASM \ fcrypt.c xcbc_enc.c cbc_cksm.c GENERATE[des_enc-sparc.S]=asm/des_enc.m4 diff --git a/crypto/des/set_key.c b/crypto/des/set_key.c index 4726bb22..d42cebda 100644 --- a/crypto/des/set_key.c +++ b/crypto/des/set_key.c @@ -18,9 +18,6 @@ #include #include "des_locl.h" -/* defaults to false */ -OPENSSL_IMPLEMENT_GLOBAL(int, DES_check_key, 0) - static const unsigned char odd_parity[256] = { 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31, @@ -277,12 +274,7 @@ static const DES_LONG des_skb[8][64] = { int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule) { - if (DES_check_key) { - return DES_set_key_checked(key, schedule); - } else { - DES_set_key_unchecked(key, schedule); - return 0; - } + return DES_set_key_checked(key, schedule); } /*- diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c index 1424c41a..524cac5b 100644 --- a/crypto/dh/dh_ameth.c +++ b/crypto/dh/dh_ameth.c @@ -488,6 +488,18 @@ static int dh_cms_encrypt(CMS_RecipientInfo *ri); #endif static int dh_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) +{ + switch (op) { + case ASN1_PKEY_CTRL_SET1_TLS_ENCPT: + return dh_buf2key(EVP_PKEY_get0_DH(pkey), arg2, arg1); + case ASN1_PKEY_CTRL_GET1_TLS_ENCPT: + return dh_key2buf(EVP_PKEY_get0_DH(pkey), arg2); + default: + return -2; + } +} + +static int dhx_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) { switch (op) { #ifndef OPENSSL_NO_CMS @@ -558,7 +570,7 @@ const EVP_PKEY_ASN1_METHOD dh_asn1_meth = { 0, int_dh_free, - 0, + dh_pkey_ctrl, 0, 0, 0, 0, 0, @@ -597,7 +609,7 @@ const EVP_PKEY_ASN1_METHOD dhx_asn1_meth = { 0, int_dh_free, - dh_pkey_ctrl, + dhx_pkey_ctrl, 0, 0, 0, 0, 0, diff --git a/crypto/dh/dh_err.c b/crypto/dh/dh_err.c index 66bf6b5a..a78a6a9c 100644 --- a/crypto/dh/dh_err.c +++ b/crypto/dh/dh_err.c @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -16,6 +16,7 @@ static const ERR_STRING_DATA DH_str_functs[] = { {ERR_PACK(ERR_LIB_DH, DH_F_COMPUTE_KEY, 0), "compute_key"}, {ERR_PACK(ERR_LIB_DH, DH_F_DHPARAMS_PRINT_FP, 0), "DHparams_print_fp"}, + {ERR_PACK(ERR_LIB_DH, DH_F_DH_BUF2KEY, 0), "dh_buf2key"}, {ERR_PACK(ERR_LIB_DH, DH_F_DH_BUILTIN_GENPARAMS, 0), "dh_builtin_genparams"}, {ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_EX, 0), "DH_check_ex"}, @@ -25,6 +26,7 @@ static const ERR_STRING_DATA DH_str_functs[] = { {ERR_PACK(ERR_LIB_DH, DH_F_DH_CMS_SET_PEERKEY, 0), "dh_cms_set_peerkey"}, {ERR_PACK(ERR_LIB_DH, DH_F_DH_CMS_SET_SHARED_INFO, 0), "dh_cms_set_shared_info"}, + {ERR_PACK(ERR_LIB_DH, DH_F_DH_KEY2BUF, 0), "dh_key2buf"}, {ERR_PACK(ERR_LIB_DH, DH_F_DH_METH_DUP, 0), "DH_meth_dup"}, {ERR_PACK(ERR_LIB_DH, DH_F_DH_METH_NEW, 0), "DH_meth_new"}, {ERR_PACK(ERR_LIB_DH, DH_F_DH_METH_SET1_NAME, 0), "DH_meth_set1_name"}, diff --git a/crypto/dh/dh_kdf.c b/crypto/dh/dh_kdf.c index 2a01bfce..03b1e4ed 100644 --- a/crypto/dh/dh_kdf.c +++ b/crypto/dh/dh_kdf.c @@ -1,5 +1,5 @@ /* - * Copyright 2013-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2013-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -10,141 +10,43 @@ #include "e_os.h" #ifndef OPENSSL_NO_CMS -#include -#include -#include -#include -#include - - -/* Key derivation from X9.42/RFC2631 */ -/* Uses CMS functions, hence the #ifdef wrapper. */ - -#define DH_KDF_MAX (1L << 30) - -/* Skip past an ASN1 structure: for OBJECT skip content octets too */ - -static int skip_asn1(unsigned char **pp, long *plen, int exptag) -{ - const unsigned char *q = *pp; - int i, tag, xclass; - long tmplen; - i = ASN1_get_object(&q, &tmplen, &tag, &xclass, *plen); - if (i & 0x80) - return 0; - if (tag != exptag || xclass != V_ASN1_UNIVERSAL) - return 0; - if (tag == V_ASN1_OBJECT) - q += tmplen; - *plen -= q - *pp; - *pp = (unsigned char *)q; - return 1; -} - -/* - * Encode the DH shared info structure, return an offset to the counter value - * so we can update the structure without reencoding it. - */ - -static int dh_sharedinfo_encode(unsigned char **pder, unsigned char **pctr, - ASN1_OBJECT *key_oid, size_t outlen, - const unsigned char *ukm, size_t ukmlen) -{ - unsigned char *p; - int derlen; - long tlen; - /* "magic" value to check offset is sane */ - static unsigned char ctr[4] = { 0xF3, 0x17, 0x22, 0x53 }; - X509_ALGOR atmp; - ASN1_OCTET_STRING ctr_oct, ukm_oct, *pukm_oct; - ASN1_TYPE ctr_atype; - if (ukmlen > DH_KDF_MAX || outlen > DH_KDF_MAX) - return 0; - ctr_oct.data = ctr; - ctr_oct.length = 4; - ctr_oct.flags = 0; - ctr_oct.type = V_ASN1_OCTET_STRING; - ctr_atype.type = V_ASN1_OCTET_STRING; - ctr_atype.value.octet_string = &ctr_oct; - atmp.algorithm = key_oid; - atmp.parameter = &ctr_atype; - if (ukm) { - ukm_oct.type = V_ASN1_OCTET_STRING; - ukm_oct.flags = 0; - ukm_oct.data = (unsigned char *)ukm; - ukm_oct.length = ukmlen; - pukm_oct = &ukm_oct; - } else - pukm_oct = NULL; - derlen = CMS_SharedInfo_encode(pder, &atmp, pukm_oct, outlen); - if (derlen <= 0) - return 0; - p = *pder; - tlen = derlen; - if (!skip_asn1(&p, &tlen, V_ASN1_SEQUENCE)) - return 0; - if (!skip_asn1(&p, &tlen, V_ASN1_SEQUENCE)) - return 0; - if (!skip_asn1(&p, &tlen, V_ASN1_OBJECT)) - return 0; - if (!skip_asn1(&p, &tlen, V_ASN1_OCTET_STRING)) - return 0; - if (CRYPTO_memcmp(p, ctr, 4)) - return 0; - *pctr = p; - return derlen; -} +# include +# include +# include +# include +# include int DH_KDF_X9_42(unsigned char *out, size_t outlen, const unsigned char *Z, size_t Zlen, ASN1_OBJECT *key_oid, const unsigned char *ukm, size_t ukmlen, const EVP_MD *md) { - EVP_MD_CTX *mctx = NULL; - int rv = 0; - unsigned int i; - size_t mdlen; - unsigned char *der = NULL, *ctr; - int derlen; - if (Zlen > DH_KDF_MAX) + int ret = 0, nid; + EVP_KDF_CTX *kctx = NULL; + const EVP_KDF *kdf = NULL; + const char *oid_sn; + + nid = OBJ_obj2nid(key_oid); + if (nid == NID_undef) return 0; - mctx = EVP_MD_CTX_new(); - if (mctx == NULL) + oid_sn = OBJ_nid2sn(nid); + if (oid_sn == NULL) return 0; - mdlen = EVP_MD_size(md); - derlen = dh_sharedinfo_encode(&der, &ctr, key_oid, outlen, ukm, ukmlen); - if (derlen == 0) + + kdf = EVP_get_kdfbyname(SN_x942kdf); + if (kdf == NULL) goto err; - for (i = 1;; i++) { - unsigned char mtmp[EVP_MAX_MD_SIZE]; - if (!EVP_DigestInit_ex(mctx, md, NULL) - || !EVP_DigestUpdate(mctx, Z, Zlen)) - goto err; - ctr[3] = i & 0xFF; - ctr[2] = (i >> 8) & 0xFF; - ctr[1] = (i >> 16) & 0xFF; - ctr[0] = (i >> 24) & 0xFF; - if (!EVP_DigestUpdate(mctx, der, derlen)) - goto err; - if (outlen >= mdlen) { - if (!EVP_DigestFinal(mctx, out, NULL)) - goto err; - outlen -= mdlen; - if (outlen == 0) - break; - out += mdlen; - } else { - if (!EVP_DigestFinal(mctx, mtmp, NULL)) - goto err; - memcpy(out, mtmp, outlen); - OPENSSL_cleanse(mtmp, mdlen); - break; - } - } - rv = 1; - err: - OPENSSL_free(der); - EVP_MD_CTX_free(mctx); - return rv; + kctx = EVP_KDF_CTX_new(kdf); + ret = + kctx != NULL + && EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, md) > 0 + && EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, Z, Zlen) > 0 + && (ukm == NULL + || EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_UKM, ukm, ukmlen) > 0) + && EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_CEK_ALG, oid_sn) > 0 + && EVP_KDF_derive(kctx, out, outlen) > 0; +err: + EVP_KDF_CTX_free(kctx); + return ret; } -#endif +#endif /* OPENSSL_NO_CMS */ diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c index 4b0b1f32..6b3a1247 100644 --- a/crypto/dh/dh_key.c +++ b/crypto/dh/dh_key.c @@ -228,3 +228,66 @@ static int dh_finish(DH *dh) BN_MONT_CTX_free(dh->method_mont_p); return 1; } + +int dh_buf2key(DH *dh, const unsigned char *buf, size_t len) +{ + int err_reason = DH_R_BN_ERROR; + BIGNUM *pubkey = NULL; + const BIGNUM *p; + size_t p_size; + + if ((pubkey = BN_bin2bn(buf, len, NULL)) == NULL) + goto err; + DH_get0_pqg(dh, &p, NULL, NULL); + if (p == NULL || (p_size = BN_num_bytes(p)) == 0) { + err_reason = DH_R_NO_PARAMETERS_SET; + goto err; + } + /* + * As per Section 4.2.8.1 of RFC 8446 fail if DHE's + * public key is of size not equal to size of p + */ + if (BN_is_zero(pubkey) || p_size != len) { + err_reason = DH_R_INVALID_PUBKEY; + goto err; + } + if (DH_set0_key(dh, pubkey, NULL) != 1) + goto err; + return 1; +err: + DHerr(DH_F_DH_BUF2KEY, err_reason); + BN_free(pubkey); + return 0; +} + +size_t dh_key2buf(const DH *dh, unsigned char **pbuf_out) +{ + const BIGNUM *pubkey; + unsigned char *pbuf; + const BIGNUM *p; + int p_size; + + DH_get0_pqg(dh, &p, NULL, NULL); + DH_get0_key(dh, &pubkey, NULL); + if (p == NULL || pubkey == NULL + || (p_size = BN_num_bytes(p)) == 0 + || BN_num_bytes(pubkey) == 0) { + DHerr(DH_F_DH_KEY2BUF, DH_R_INVALID_PUBKEY); + return 0; + } + if ((pbuf = OPENSSL_malloc(p_size)) == NULL) { + DHerr(DH_F_DH_KEY2BUF, ERR_R_MALLOC_FAILURE); + return 0; + } + /* + * As per Section 4.2.8.1 of RFC 8446 left pad public + * key with zeros to the size of p + */ + if (BN_bn2binpad(pubkey, pbuf, p_size) < 0) { + OPENSSL_free(pbuf); + DHerr(DH_F_DH_KEY2BUF, DH_R_BN_ERROR); + return 0; + } + *pbuf_out = pbuf; + return p_size; +} diff --git a/crypto/dh/dh_locl.h b/crypto/dh/dh_locl.h index 6186901e..bb64cde9 100644 --- a/crypto/dh/dh_locl.h +++ b/crypto/dh/dh_locl.h @@ -55,3 +55,6 @@ struct dh_method { int (*generate_params) (DH *dh, int prime_len, int generator, BN_GENCB *cb); }; + +int dh_buf2key(DH *key, const unsigned char *buf, size_t len); +size_t dh_key2buf(const DH *dh, unsigned char **pbuf); diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c index 756ee744..ef6fc763 100644 --- a/crypto/dsa/dsa_ameth.c +++ b/crypto/dsa/dsa_ameth.c @@ -505,7 +505,7 @@ static int dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) case ASN1_PKEY_CTRL_DEFAULT_MD_NID: *(int *)arg2 = NID_sha256; - return 2; + return 1; default: return -2; diff --git a/crypto/dsa/dsa_ossl.c b/crypto/dsa/dsa_ossl.c index b66d5ad0..a9384a0f 100644 --- a/crypto/dsa/dsa_ossl.c +++ b/crypto/dsa/dsa_ossl.c @@ -248,7 +248,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, * one bit longer than the modulus. * * There are some concerns about the efficacy of doing this. More - * specificly refer to the discussion starting with: + * specifically refer to the discussion starting with: * https://github.com/openssl/openssl/pull/7486#discussion_r228323705 * The fix is to rework BN so these gymnastics aren't required. */ diff --git a/crypto/ec/asm/ecp_nistz256-x86_64.pl b/crypto/ec/asm/ecp_nistz256-x86_64.pl index e1e23ca9..7fbc3eb4 100755 --- a/crypto/ec/asm/ecp_nistz256-x86_64.pl +++ b/crypto/ec/asm/ecp_nistz256-x86_64.pl @@ -1301,7 +1301,7 @@ ecp_nistz256_ord_mul_montx: ################################# reduction mulx 8*0+128(%r14), $t0, $t1 - adcx $t0, $acc3 # guranteed to be zero + adcx $t0, $acc3 # guaranteed to be zero adox $t1, $acc4 mulx 8*1+128(%r14), $t0, $t1 diff --git a/crypto/ec/asm/x25519-ppc64.pl b/crypto/ec/asm/x25519-ppc64.pl index 2f8d82c2..5f6bff18 100755 --- a/crypto/ec/asm/x25519-ppc64.pl +++ b/crypto/ec/asm/x25519-ppc64.pl @@ -451,7 +451,7 @@ x25519_fe64_tobytes: and $t0,$t0,$t1 sldi $a3,$a3,1 add $t0,$t0,$t1 # compare to modulus in the same go - srdi $a3,$a3,1 # most signifcant bit cleared + srdi $a3,$a3,1 # most significant bit cleared addc $a0,$a0,$t0 addze $a1,$a1 @@ -462,7 +462,7 @@ x25519_fe64_tobytes: sradi $t0,$a3,63 # most significant bit -> mask sldi $a3,$a3,1 andc $t0,$t1,$t0 - srdi $a3,$a3,1 # most signifcant bit cleared + srdi $a3,$a3,1 # most significant bit cleared subi $rp,$rp,1 subfc $a0,$t0,$a0 diff --git a/crypto/ec/build.info b/crypto/ec/build.info index dd1c891e..5e9778d3 100644 --- a/crypto/ec/build.info +++ b/crypto/ec/build.info @@ -1,3 +1,47 @@ +$ECASM= +IF[{- !$disabled{asm} -}] + $ECASM_x86=ecp_nistz256.c ecp_nistz256-x86.s + $ECDEF_x86=ECP_NISTZ256_ASM + + $ECASM_x86_64=ecp_nistz256.c ecp_nistz256-x86_64.s x25519-x86_64.s + $ECDEF_x86_64=ECP_NISTZ256_ASM X25519_ASM + + $ECASM_ia64= + + $ECASM_sparcv9=ecp_nistz256.c ecp_nistz256-sparcv9.S + $ECDEF_sparcv9=ECP_NISTZ256_ASM + + $ECASM_sparcv8= + + $ECASM_alpha= + + $ECASM_mips32= + $ECASM_mips64= + + $ECASM_s390x= + + $ECASM_armv4=ecp_nistz256.c ecp_nistz256-armv4.S + $ECDEF_armv4=ECP_NISTZ256_ASM + $ECASM_aarch64=ecp_nistz256.c ecp_nistz256-armv8.S + $ECDEF_aarch64=ECP_NISTZ256_ASM + + $ECASM_parisc11= + $ECASM_parisc20_64= + + $ECASM_ppc32= + $ECASM_ppc64=ecp_nistz256.c ecp_nistz256-ppc64.s x25519-ppc64.s + $ECDEF_ppc64=ECP_NISTZ256_ASM X25519_ASM + + $ECASM_c64xplus= + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$ECASM_{- $target{asm_arch} -}] + $ECASM=$ECASM_{- $target{asm_arch} -} + $ECDEF=$ECDEF_{- $target{asm_arch} -} + ENDIF +ENDIF + LIBS=../../libcrypto SOURCE[../../libcrypto]=\ ec_lib.c ecp_smpl.c ecp_mont.c ecp_nist.c ec_cvt.c ec_mult.c \ @@ -8,7 +52,8 @@ SOURCE[../../libcrypto]=\ ecdsa_ossl.c ecdsa_sign.c ecdsa_vrf.c curve25519.c ecx_meth.c \ curve448/arch_32/f_impl.c curve448/f_generic.c curve448/scalar.c \ curve448/curve448_tables.c curve448/eddsa.c curve448/curve448.c \ - {- $target{ec_asm_src} -} + $ECASM +DEFINE[../../libcrypto]=$ECDEF GENERATE[ecp_nistz256-x86.s]=asm/ecp_nistz256-x86.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR) diff --git a/crypto/ec/ec_check.c b/crypto/ec/ec_check.c index 097d7e1c..315b9fd4 100644 --- a/crypto/ec/ec_check.c +++ b/crypto/ec/ec_check.c @@ -22,6 +22,13 @@ int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only) int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx) { +#ifdef FIPS_MODE + /* + * ECC domain parameter validation. + * See SP800-56A R3 5.5.2 "Assurances of Domain-Parameter Validity" Part 1b. + */ + return EC_GROUP_check_named_curve(group, 1) >= 0 ? 1 : 0; +#else int ret = 0; const BIGNUM *order; BN_CTX *new_ctx = NULL; @@ -84,4 +91,5 @@ int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx) BN_CTX_free(new_ctx); EC_POINT_free(point); return ret; +#endif /* FIPS_MODE */ } diff --git a/crypto/ec/ec_curve.c b/crypto/ec/ec_curve.c index 6c7c9ddb..8b44c251 100644 --- a/crypto/ec/ec_curve.c +++ b/crypto/ec/ec_curve.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2019 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the Apache License 2.0 (the "License"). You may not use @@ -14,7 +14,6 @@ #include #include #include "internal/nelem.h" -#include "internal/o_str.h" typedef struct { int field_type, /* either NID_X9_62_prime_field or @@ -2801,6 +2800,70 @@ typedef struct _ec_list_element_st { const char *comment; } ec_list_element; +#ifdef FIPS_MODE +static const ec_list_element curve_list[] = { + /* prime field curves */ + /* secg curves */ +# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 + {NID_secp224r1, &_EC_NIST_PRIME_224.h, EC_GFp_nistp224_method, + "NIST/SECG curve over a 224 bit prime field"}, +# else + {NID_secp224r1, &_EC_NIST_PRIME_224.h, 0, + "NIST/SECG curve over a 224 bit prime field"}, +# endif + /* SECG secp256r1 is the same as X9.62 prime256v1 and hence omitted */ + {NID_secp384r1, &_EC_NIST_PRIME_384.h, 0, + "NIST/SECG curve over a 384 bit prime field"}, + +# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 + {NID_secp521r1, &_EC_NIST_PRIME_521.h, EC_GFp_nistp521_method, + "NIST/SECG curve over a 521 bit prime field"}, +# else + {NID_secp521r1, &_EC_NIST_PRIME_521.h, 0, + "NIST/SECG curve over a 521 bit prime field"}, +# endif + + /* X9.62 curves */ + {NID_X9_62_prime192v1, &_EC_NIST_PRIME_192.h, 0, + "NIST/X9.62/SECG curve over a 192 bit prime field"}, + {NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, +# if defined(ECP_NISTZ256_ASM) + EC_GFp_nistz256_method, +# elif !defined(OPENSSL_NO_EC_NISTP_64_GCC_128) + EC_GFp_nistp256_method, +# else + 0, +# endif + "X9.62/SECG curve over a 256 bit prime field"}, + +# ifndef OPENSSL_NO_EC2M + /* characteristic two field curves */ + /* NIST/SECG curves */ + {NID_sect163k1, &_EC_NIST_CHAR2_163K.h, 0, + "NIST/SECG/WTLS curve over a 163 bit binary field"}, + {NID_sect163r2, &_EC_NIST_CHAR2_163B.h, 0, + "NIST/SECG curve over a 163 bit binary field"}, + {NID_sect233k1, &_EC_NIST_CHAR2_233K.h, 0, + "NIST/SECG/WTLS curve over a 233 bit binary field"}, + {NID_sect233r1, &_EC_NIST_CHAR2_233B.h, 0, + "NIST/SECG/WTLS curve over a 233 bit binary field"}, + {NID_sect283k1, &_EC_NIST_CHAR2_283K.h, 0, + "NIST/SECG curve over a 283 bit binary field"}, + {NID_sect283r1, &_EC_NIST_CHAR2_283B.h, 0, + "NIST/SECG curve over a 283 bit binary field"}, + {NID_sect409k1, &_EC_NIST_CHAR2_409K.h, 0, + "NIST/SECG curve over a 409 bit binary field"}, + {NID_sect409r1, &_EC_NIST_CHAR2_409B.h, 0, + "NIST/SECG curve over a 409 bit binary field"}, + {NID_sect571k1, &_EC_NIST_CHAR2_571K.h, 0, + "NIST/SECG curve over a 571 bit binary field"}, + {NID_sect571r1, &_EC_NIST_CHAR2_571B.h, 0, + "NIST/SECG curve over a 571 bit binary field"}, +# endif +}; + +#else + static const ec_list_element curve_list[] = { /* prime field curves */ /* secg curves */ @@ -2823,25 +2886,25 @@ static const ec_list_element curve_list[] = { "SECG curve over a 192 bit prime field"}, {NID_secp224k1, &_EC_SECG_PRIME_224K1.h, 0, "SECG curve over a 224 bit prime field"}, -#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 +# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 {NID_secp224r1, &_EC_NIST_PRIME_224.h, EC_GFp_nistp224_method, "NIST/SECG curve over a 224 bit prime field"}, -#else +# else {NID_secp224r1, &_EC_NIST_PRIME_224.h, 0, "NIST/SECG curve over a 224 bit prime field"}, -#endif +# endif {NID_secp256k1, &_EC_SECG_PRIME_256K1.h, 0, "SECG curve over a 256 bit prime field"}, /* SECG secp256r1 is the same as X9.62 prime256v1 and hence omitted */ {NID_secp384r1, &_EC_NIST_PRIME_384.h, 0, "NIST/SECG curve over a 384 bit prime field"}, -#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 +# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 {NID_secp521r1, &_EC_NIST_PRIME_521.h, EC_GFp_nistp521_method, "NIST/SECG curve over a 521 bit prime field"}, -#else +# else {NID_secp521r1, &_EC_NIST_PRIME_521.h, 0, "NIST/SECG curve over a 521 bit prime field"}, -#endif +# endif /* X9.62 curves */ {NID_X9_62_prime192v1, &_EC_NIST_PRIME_192.h, 0, "NIST/X9.62/SECG curve over a 192 bit prime field"}, @@ -2856,15 +2919,15 @@ static const ec_list_element curve_list[] = { {NID_X9_62_prime239v3, &_EC_X9_62_PRIME_239V3.h, 0, "X9.62 curve over a 239 bit prime field"}, {NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, -#if defined(ECP_NISTZ256_ASM) +# if defined(ECP_NISTZ256_ASM) EC_GFp_nistz256_method, -#elif !defined(OPENSSL_NO_EC_NISTP_64_GCC_128) +# elif !defined(OPENSSL_NO_EC_NISTP_64_GCC_128) EC_GFp_nistp256_method, -#else +# else 0, -#endif +# endif "X9.62/SECG curve over a 256 bit prime field"}, -#ifndef OPENSSL_NO_EC2M +# ifndef OPENSSL_NO_EC2M /* characteristic two field curves */ /* NIST/SECG curves */ {NID_sect113r1, &_EC_SECG_CHAR2_113R1.h, 0, @@ -2948,7 +3011,7 @@ static const ec_list_element curve_list[] = { "SECG curve over a 113 bit binary field"}, {NID_wap_wsg_idm_ecid_wtls5, &_EC_X9_62_CHAR2_163V1.h, 0, "X9.62 curve over a 163 bit binary field"}, -#endif +# endif {NID_wap_wsg_idm_ecid_wtls6, &_EC_SECG_PRIME_112R1.h, 0, "SECG/WTLS curve over a 112 bit prime field"}, {NID_wap_wsg_idm_ecid_wtls7, &_EC_SECG_PRIME_160R2.h, 0, @@ -2957,15 +3020,15 @@ static const ec_list_element curve_list[] = { "WTLS curve over a 112 bit prime field"}, {NID_wap_wsg_idm_ecid_wtls9, &_EC_WTLS_9.h, 0, "WTLS curve over a 160 bit prime field"}, -#ifndef OPENSSL_NO_EC2M +# ifndef OPENSSL_NO_EC2M {NID_wap_wsg_idm_ecid_wtls10, &_EC_NIST_CHAR2_233K.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field"}, {NID_wap_wsg_idm_ecid_wtls11, &_EC_NIST_CHAR2_233B.h, 0, "NIST/SECG/WTLS curve over a 233 bit binary field"}, -#endif +# endif {NID_wap_wsg_idm_ecid_wtls12, &_EC_WTLS_12.h, 0, "WTLS curve over a 224 bit prime field"}, -#ifndef OPENSSL_NO_EC2M +# ifndef OPENSSL_NO_EC2M /* IPSec curves */ {NID_ipsec3, &_EC_IPSEC_155_ID3.h, 0, "\n\tIPSec/IKE/Oakley curve #3 over a 155 bit binary field.\n" @@ -2973,7 +3036,7 @@ static const ec_list_element curve_list[] = { {NID_ipsec4, &_EC_IPSEC_185_ID4.h, 0, "\n\tIPSec/IKE/Oakley curve #4 over a 185 bit binary field.\n" "\tNot suitable for ECDSA.\n\tQuestionable extension field!"}, -#endif +# endif /* brainpool curves */ {NID_brainpoolP160r1, &_EC_brainpoolP160r1.h, 0, "RFC 5639 curve over a 160 bit prime field"}, @@ -3003,11 +3066,12 @@ static const ec_list_element curve_list[] = { "RFC 5639 curve over a 512 bit prime field"}, {NID_brainpoolP512t1, &_EC_brainpoolP512t1.h, 0, "RFC 5639 curve over a 512 bit prime field"}, -#ifndef OPENSSL_NO_SM2 +# ifndef OPENSSL_NO_SM2 {NID_sm2, &_EC_sm2p256v1.h, 0, "SM2 curve over a 256 bit prime field"}, -#endif +# endif }; +#endif /* FIPS_MODE */ #define curve_list_length OSSL_NELEM(curve_list) @@ -3126,6 +3190,15 @@ EC_GROUP *EC_GROUP_new_by_curve_name(int nid) if (nid <= 0) return NULL; +#ifdef FIPS_MODE + /* + * Only use approved NIST curves in FIPS. + * NOTE: "B-163", "K-163" & "P-192" can only be used for legacy use + * (i.e- ECDSA signature verification). + */ + if (EC_curve_nid2nist(nid) == NULL) + return NULL; +#endif /* FIPS_MODE */ for (i = 0; i < curve_list_length; i++) if (curve_list[i].nid == nid) { ret = ec_group_new_from_data(curve_list[i]); @@ -3302,10 +3375,10 @@ int ec_curve_nid_from_params(const EC_GROUP *group) /* Check the optional seed (ignore if its not set) */ && (data->seed_len == 0 || seed_len == 0 || ((size_t)data->seed_len == seed_len - && OPENSSL_memcmp(params_seed, seed, seed_len) == 0)) + && memcmp(params_seed, seed, seed_len) == 0)) /* Check that the groups params match the built-in curve params */ - && OPENSSL_memcmp(param_bytes, params, param_len * NUM_BN_FIELDS) - == 0) { + && memcmp(param_bytes, params, param_len * NUM_BN_FIELDS) + == 0) { ret = curve.nid; goto end; } diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index 76aea4f4..47ccfd0a 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -303,7 +303,7 @@ int EC_KEY_check_key(const EC_KEY *eckey) * See SP800-56A R3 Section 5.6.2.3.3 (Part 2) * i.e. * - If q = odd prime p: Verify that xQ and yQ are integers in the - * interval[0, p − 1], OR + * interval[0, p - 1], OR * - If q = 2m: Verify that xQ and yQ are bit strings of length m bits. * Returns 1 if the public key has a valid range, otherwise it returns 0. */ diff --git a/crypto/ec/ec_lcl.h b/crypto/ec/ec_lcl.h index c54789ba..0b1697ec 100644 --- a/crypto/ec/ec_lcl.h +++ b/crypto/ec/ec_lcl.h @@ -154,7 +154,7 @@ struct ec_method_st { int (*field_div) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); /*- - * 'field_inv' computes the multipicative inverse of a in the field, + * 'field_inv' computes the multiplicative inverse of a in the field, * storing the result in r. * * If 'a' is zero (or equivalent), you'll get an EC_R_CANNOT_INVERT error. diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c index 45798b4f..e581741f 100644 --- a/crypto/ec/ec_pmeth.c +++ b/crypto/ec/ec_pmeth.c @@ -327,7 +327,8 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) EVP_MD_type((const EVP_MD *)p2) != NID_sha3_224 && EVP_MD_type((const EVP_MD *)p2) != NID_sha3_256 && EVP_MD_type((const EVP_MD *)p2) != NID_sha3_384 && - EVP_MD_type((const EVP_MD *)p2) != NID_sha3_512) { + EVP_MD_type((const EVP_MD *)p2) != NID_sha3_512 && + EVP_MD_type((const EVP_MD *)p2) != NID_sm3) { ECerr(EC_F_PKEY_EC_CTRL, EC_R_INVALID_DIGEST_TYPE); return 0; } diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index fe6f3b3b..06f1a638 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -1269,7 +1269,7 @@ static void point_add(felem x3, felem y3, felem z3, * ffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb * 71e913863f7, in that case the penultimate intermediate is -9G and * the final digit is also -9G. Since this only happens for a single - * scalar, the timing leak is irrelevent. (Any attacker who wanted to + * scalar, the timing leak is irrelevant. (Any attacker who wanted to * check whether a secret scalar was that exact value, can already do * so.) */ diff --git a/crypto/ec/ecp_nistputil.c b/crypto/ec/ecp_nistputil.c index 82cca66b..0715370b 100644 --- a/crypto/ec/ecp_nistputil.c +++ b/crypto/ec/ecp_nistputil.c @@ -158,13 +158,13 @@ void ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array, * of a nonnegative integer (b_k in {0, 1}), rewrite it in digits 0, 1, -1 * by using bit-wise subtraction as follows: * - * b_k b_(k-1) ... b_2 b_1 b_0 - * - b_k ... b_3 b_2 b_1 b_0 - * ------------------------------------- - * s_k b_(k-1) ... s_3 s_2 s_1 s_0 + * b_k b_(k-1) ... b_2 b_1 b_0 + * - b_k ... b_3 b_2 b_1 b_0 + * ----------------------------------------- + * s_(k+1) s_k ... s_3 s_2 s_1 s_0 * * A left-shift followed by subtraction of the original value yields a new - * representation of the same value, using signed bits s_i = b_(i+1) - b_i. + * representation of the same value, using signed bits s_i = b_(i-1) - b_i. * This representation from Booth's paper has since appeared in the * literature under a variety of different names including "reversed binary * form", "alternating greedy expansion", "mutual opposite form", and @@ -188,7 +188,7 @@ void ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array, * (1961), pp. 67-91), in a radix-2^5 setting. That is, we always combine five * signed bits into a signed digit: * - * s_(4j + 4) s_(4j + 3) s_(4j + 2) s_(4j + 1) s_(4j) + * s_(5j + 4) s_(5j + 3) s_(5j + 2) s_(5j + 1) s_(5j) * * The sign-alternating property implies that the resulting digit values are * integers from -16 to 16. @@ -196,14 +196,14 @@ void ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array, * Of course, we don't actually need to compute the signed digits s_i as an * intermediate step (that's just a nice way to see how this scheme relates * to the wNAF): a direct computation obtains the recoded digit from the - * six bits b_(4j + 4) ... b_(4j - 1). + * six bits b_(5j + 4) ... b_(5j - 1). * - * This function takes those five bits as an integer (0 .. 63), writing the + * This function takes those six bits as an integer (0 .. 63), writing the * recoded digit to *sign (0 for positive, 1 for negative) and *digit (absolute - * value, in the range 0 .. 8). Note that this integer essentially provides the - * input bits "shifted to the left" by one position: for example, the input to - * compute the least significant recoded digit, given that there's no bit b_-1, - * has to be b_4 b_3 b_2 b_1 b_0 0. + * value, in the range 0 .. 16). Note that this integer essentially provides + * the input bits "shifted to the left" by one position: for example, the input + * to compute the least significant recoded digit, given that there's no bit + * b_-1, has to be b_4 b_3 b_2 b_1 b_0 0. * */ void ec_GFp_nistp_recode_scalar_bits(unsigned char *sign, diff --git a/crypto/ec/ecx_meth.c b/crypto/ec/ecx_meth.c index 7d133a3c..1958aa26 100644 --- a/crypto/ec/ecx_meth.c +++ b/crypto/ec/ecx_meth.c @@ -532,7 +532,7 @@ static int ecd_item_sign25519(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, X509_ALGOR_set0(alg1, OBJ_nid2obj(NID_ED25519), V_ASN1_UNDEF, NULL); if (alg2) X509_ALGOR_set0(alg2, OBJ_nid2obj(NID_ED25519), V_ASN1_UNDEF, NULL); - /* Algorithm idetifiers set: carry on as normal */ + /* Algorithm identifiers set: carry on as normal */ return 3; } diff --git a/crypto/err/err.c b/crypto/err/err.c index 345d2302..8752c119 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -59,6 +59,7 @@ static ERR_STRING_DATA ERR_str_libraries[] = { {ERR_PACK(ERR_LIB_FIPS, 0, 0), "FIPS routines"}, {ERR_PACK(ERR_LIB_CMS, 0, 0), "CMS routines"}, {ERR_PACK(ERR_LIB_CRMF, 0, 0), "CRMF routines"}, + {ERR_PACK(ERR_LIB_CMP, 0, 0), "CMP routines"}, {ERR_PACK(ERR_LIB_HMAC, 0, 0), "HMAC routines"}, {ERR_PACK(ERR_LIB_CT, 0, 0), "CT routines"}, {ERR_PACK(ERR_LIB_ASYNC, 0, 0), "ASYNC routines"}, @@ -187,8 +188,8 @@ static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d) } #ifndef OPENSSL_NO_ERR -/* A measurement on Linux 2018-11-21 showed about 3.5kib */ -# define SPACE_SYS_STR_REASONS 4 * 1024 +/* 2019-05-21: Russian and Ukrainian locales on Linux require more than 6,5 kB */ +# define SPACE_SYS_STR_REASONS 8 * 1024 # define NUM_SYS_STR_REASONS 127 static ERR_STRING_DATA SYS_str_reasons[NUM_SYS_STR_REASONS + 1]; @@ -222,21 +223,23 @@ static void build_SYS_str_reasons(void) ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; str->error = ERR_PACK(ERR_LIB_SYS, 0, i); - if (str->string == NULL) { + /* + * If we have used up all the space in strerror_pool, + * there's no point in calling openssl_strerror_r() + */ + if (str->string == NULL && cnt < sizeof(strerror_pool)) { if (openssl_strerror_r(i, cur, sizeof(strerror_pool) - cnt)) { size_t l = strlen(cur); str->string = cur; cnt += l; - if (cnt > sizeof(strerror_pool)) - cnt = sizeof(strerror_pool); cur += l; /* * VMS has an unusual quirk of adding spaces at the end of - * some (most? all?) messages. Lets trim them off. + * some (most? all?) messages. Lets trim them off. */ - while (ossl_isspace(cur[-1])) { + while (cur > strerror_pool && ossl_isspace(cur[-1])) { cur--; cnt--; } @@ -685,7 +688,8 @@ const char *ERR_reason_error_string(unsigned long e) return ((p == NULL) ? NULL : p->string); } -void err_delete_thread_state(void) +/* TODO(3.0): arg ignored for now */ +static void err_delete_thread_state(void *arg) { ERR_STATE *state = CRYPTO_THREAD_get_local(&err_thread_local); if (state == NULL) @@ -737,7 +741,7 @@ ERR_STATE *ERR_get_state(void) return NULL; } - if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE) + if (!ossl_init_thread_start(NULL, NULL, err_delete_thread_state) || !CRYPTO_THREAD_set_local(&err_thread_local, state)) { ERR_STATE_free(state); CRYPTO_THREAD_set_local(&err_thread_local, NULL); @@ -846,32 +850,41 @@ void ERR_add_error_data(int num, ...) void ERR_add_error_vdata(int num, va_list args) { - int i, n, s; - char *str, *p, *a; + int i, len, size; + char *str, *p, *arg; + ERR_STATE *es; - s = 80; - if ((str = OPENSSL_malloc(s + 1)) == NULL) { + /* Get the current error data; if an allocated string get it. */ + es = ERR_get_state(); + if (es == NULL) + return; + i = es->top; + p = es->err_data_flags[i] == (ERR_TXT_MALLOCED | ERR_TXT_STRING) + ? es->err_data[i] : ""; + + /* Start with initial (or empty) string and allocate a new buffer */ + size = 80 + strlen(p); + if ((str = OPENSSL_malloc(size + 1)) == NULL) { /* ERRerr(ERR_F_ERR_ADD_ERROR_VDATA, ERR_R_MALLOC_FAILURE); */ return; } - str[0] = '\0'; + strcpy(str, p); - n = 0; - for (i = 0; i < num; i++) { - a = va_arg(args, char *); - if (a == NULL) - a = ""; - n += strlen(a); - if (n > s) { - s = n + 20; - p = OPENSSL_realloc(str, s + 1); + for (len = 0; --num >= 0; ) { + arg = va_arg(args, char *); + if (arg == NULL) + arg = ""; + len += strlen(arg); + if (len > size) { + size = len + 20; + p = OPENSSL_realloc(str, size + 1); if (p == NULL) { OPENSSL_free(str); return; } str = p; } - OPENSSL_strlcat(str, a, (size_t)s + 1); + OPENSSL_strlcat(str, arg, (size_t)size + 1); } if (!err_set_error_data_int(str, ERR_TXT_MALLOCED | ERR_TXT_STRING)) OPENSSL_free(str); diff --git a/crypto/err/err_all.c b/crypto/err/err_all.c index a56cf9c4..8962fe5c 100644 --- a/crypto/err/err_all.c +++ b/crypto/err/err_all.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -94,6 +95,7 @@ int err_load_crypto_strings_int(void) # endif # ifndef OPENSSL_NO_CRMF ERR_load_CRMF_strings() == 0 || + ERR_load_CMP_strings() == 0 || # endif # ifndef OPENSSL_NO_CT ERR_load_CT_strings() == 0 || diff --git a/crypto/err/err_prn.c b/crypto/err/err_prn.c index ba9a7c59..b43367f6 100644 --- a/crypto/err/err_prn.c +++ b/crypto/err/err_prn.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -16,27 +16,19 @@ void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u), void *u) { + CRYPTO_THREAD_ID tid = CRYPTO_THREAD_get_current_id(); unsigned long l; char buf[256]; - char buf2[4096]; + char buf2[4096], *hex; const char *file, *data; int line, flags; - /* - * We don't know what kind of thing CRYPTO_THREAD_ID is. Here is our best - * attempt to convert it into something we can print. - */ - union { - CRYPTO_THREAD_ID tid; - unsigned long ltid; - } tid; - - tid.ltid = 0; - tid.tid = CRYPTO_THREAD_get_current_id(); while ((l = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) { ERR_error_string_n(l, buf, sizeof(buf)); - BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", tid.ltid, buf, - file, line, (flags & ERR_TXT_STRING) ? data : ""); + hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid)); + BIO_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%d:%s\n", hex, buf, file, + line, (flags & ERR_TXT_STRING) ? data : ""); + OPENSSL_free(hex); if (cb(buf2, strlen(buf2), u) <= 0) break; /* abort outputting the error report */ } diff --git a/crypto/err/openssl.ec b/crypto/err/openssl.ec index b28aa491..04e76df6 100644 --- a/crypto/err/openssl.ec +++ b/crypto/err/openssl.ec @@ -19,7 +19,7 @@ L EC include/openssl/ec.h crypto/ec/ec_err.c L SSL include/openssl/ssl.h ssl/ssl_err.c L BIO include/openssl/bio.h crypto/bio/bio_err.c L PKCS7 include/openssl/pkcs7.h crypto/pkcs7/pkcs7err.c -L X509V3 include/openssl/x509v3.h crypto/x509v3/v3err.c +L X509V3 include/openssl/x509v3.h crypto/x509/v3err.c L PKCS12 include/openssl/pkcs12.h crypto/pkcs12/pk12err.c L RAND include/openssl/rand.h crypto/rand/rand_err.c L DSO include/internal/dso.h crypto/dso/dso_err.c @@ -30,6 +30,7 @@ L COMP include/openssl/comp.h crypto/comp/comp_err.c L TS include/openssl/ts.h crypto/ts/ts_err.c L CMS include/openssl/cms.h crypto/cms/cms_err.c L CRMF include/openssl/crmf.h crypto/crmf/crmf_err.c +L CMP include/openssl/cmp.h crypto/cmp/cmp_err.c L CT include/openssl/ct.h crypto/ct/ct_err.c L ASYNC include/openssl/async.h crypto/async/async_err.c L KDF include/openssl/kdf.h crypto/kdf/kdf_err.c diff --git a/crypto/err/openssl.txt b/crypto/err/openssl.txt index 82a35645..b5ae4e1a 100644 --- a/crypto/err/openssl.txt +++ b/crypto/err/openssl.txt @@ -196,6 +196,7 @@ BN_F_BN_BN2HEX:105:BN_bn2hex BN_F_BN_COMPUTE_WNAF:142:bn_compute_wNAF BN_F_BN_CTX_GET:116:BN_CTX_get BN_F_BN_CTX_NEW:106:BN_CTX_new +BN_F_BN_CTX_NEW_EX:151:BN_CTX_new_ex BN_F_BN_CTX_START:129:BN_CTX_start BN_F_BN_DIV:107:BN_div BN_F_BN_DIV_RECP:130:BN_div_recp @@ -318,6 +319,7 @@ CMS_F_CMS_SIGNERINFO_VERIFY:152:CMS_SignerInfo_verify CMS_F_CMS_SIGNERINFO_VERIFY_CERT:153:cms_signerinfo_verify_cert CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT:154:CMS_SignerInfo_verify_content CMS_F_CMS_SIGN_RECEIPT:163:CMS_sign_receipt +CMS_F_CMS_SI_CHECK_ATTRIBUTES:183:CMS_si_check_attributes CMS_F_CMS_STREAM:155:CMS_stream CMS_F_CMS_UNCOMPRESS:156:CMS_uncompress CMS_F_CMS_VERIFY:157:CMS_verify @@ -437,6 +439,7 @@ CT_F_SCT_SET_SIGNATURE_NID:103:SCT_set_signature_nid CT_F_SCT_SET_VERSION:104:SCT_set_version DH_F_COMPUTE_KEY:102:compute_key DH_F_DHPARAMS_PRINT_FP:101:DHparams_print_fp +DH_F_DH_BUF2KEY:126:dh_buf2key DH_F_DH_BUILTIN_GENPARAMS:106:dh_builtin_genparams DH_F_DH_CHECK_EX:121:DH_check_ex DH_F_DH_CHECK_PARAMS_EX:122:DH_check_params_ex @@ -444,6 +447,7 @@ DH_F_DH_CHECK_PUB_KEY_EX:123:DH_check_pub_key_ex DH_F_DH_CMS_DECRYPT:114:dh_cms_decrypt DH_F_DH_CMS_SET_PEERKEY:115:dh_cms_set_peerkey DH_F_DH_CMS_SET_SHARED_INFO:116:dh_cms_set_shared_info +DH_F_DH_KEY2BUF:127:dh_key2buf DH_F_DH_METH_DUP:117:DH_meth_dup DH_F_DH_METH_NEW:118:DH_meth_new DH_F_DH_METH_SET1_NAME:119:DH_meth_set1_name @@ -808,7 +812,7 @@ EVP_F_EVP_KDF_CTX_NEW:240:EVP_KDF_CTX_new EVP_F_EVP_KDF_CTX_NEW_ID:226:EVP_KDF_CTX_new_id EVP_F_EVP_MAC_CTRL:209:EVP_MAC_ctrl EVP_F_EVP_MAC_CTRL_STR:210:EVP_MAC_ctrl_str -EVP_F_EVP_MAC_CTX_COPY:211:EVP_MAC_CTX_copy +EVP_F_EVP_MAC_CTX_DUP:211:EVP_MAC_CTX_dup EVP_F_EVP_MAC_CTX_NEW:213:EVP_MAC_CTX_new EVP_F_EVP_MAC_INIT:212:EVP_MAC_init EVP_F_EVP_MD_BLOCK_SIZE:232:EVP_MD_block_size @@ -879,11 +883,13 @@ EVP_F_PKCS5_V2_PBE_KEYIVGEN:118:PKCS5_v2_PBE_keyivgen EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN:164:PKCS5_v2_PBKDF2_keyivgen EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN:180:PKCS5_v2_scrypt_keyivgen EVP_F_PKEY_KDF_CTRL:227:pkey_kdf_ctrl +EVP_F_PKEY_MAC_COPY:241:pkey_mac_copy EVP_F_PKEY_MAC_INIT:214:pkey_mac_init EVP_F_PKEY_SET_TYPE:158:pkey_set_type EVP_F_POLY1305_CTRL:216:poly1305_ctrl EVP_F_RC2_MAGIC_TO_METH:109:rc2_magic_to_meth EVP_F_RC5_CTRL:125:rc5_ctrl +EVP_F_R_32_12_16_INIT_KEY:242:r_32_12_16_init_key EVP_F_S390X_AES_GCM_CTRL:201:s390x_aes_gcm_ctrl EVP_F_S390X_AES_GCM_TLS_CIPHER:208:s390x_aes_gcm_tls_cipher EVP_F_SCRYPT_ALG:228:scrypt_alg @@ -893,6 +899,7 @@ KDF_F_KDF_HKDF_DERIVE:113:kdf_hkdf_derive KDF_F_KDF_HKDF_NEW:114:kdf_hkdf_new KDF_F_KDF_HKDF_SIZE:115:kdf_hkdf_size KDF_F_KDF_MD2CTRL:116:kdf_md2ctrl +KDF_F_KDF_PBKDF2_CTRL:140:kdf_pbkdf2_ctrl KDF_F_KDF_PBKDF2_CTRL_STR:117:kdf_pbkdf2_ctrl_str KDF_F_KDF_PBKDF2_DERIVE:118:kdf_pbkdf2_derive KDF_F_KDF_PBKDF2_NEW:119:kdf_pbkdf2_new @@ -908,6 +915,7 @@ KDF_F_KDF_SSHKDF_NEW:133:kdf_sshkdf_new KDF_F_KDF_TLS1_PRF_CTRL_STR:125:kdf_tls1_prf_ctrl_str KDF_F_KDF_TLS1_PRF_DERIVE:126:kdf_tls1_prf_derive KDF_F_KDF_TLS1_PRF_NEW:127:kdf_tls1_prf_new +KDF_F_PBKDF2_DERIVE:141:pbkdf2_derive KDF_F_PBKDF2_SET_MEMBUF:128:pbkdf2_set_membuf KDF_F_PKEY_HKDF_CTRL_STR:103:pkey_hkdf_ctrl_str KDF_F_PKEY_HKDF_DERIVE:102:pkey_hkdf_derive @@ -927,6 +935,11 @@ KDF_F_SSKDF_MAC2CTRL:136:sskdf_mac2ctrl KDF_F_SSKDF_NEW:137:sskdf_new KDF_F_SSKDF_SIZE:138:sskdf_size KDF_F_TLS1_PRF_ALG:111:tls1_prf_alg +KDF_F_X942KDF_CTRL:142:x942kdf_ctrl +KDF_F_X942KDF_DERIVE:143:x942kdf_derive +KDF_F_X942KDF_HASH_KDM:144:x942kdf_hash_kdm +KDF_F_X942KDF_NEW:145:x942kdf_new +KDF_F_X942KDF_SIZE:146:x942kdf_size KDF_F_X963KDF_DERIVE:139:x963kdf_derive OBJ_F_OBJ_ADD_OBJECT:105:OBJ_add_object OBJ_F_OBJ_ADD_SIGID:107:OBJ_add_sigid @@ -1132,6 +1145,7 @@ RAND_F_DRBG_GET_ENTROPY:105:drbg_get_entropy RAND_F_DRBG_SETUP:117:drbg_setup RAND_F_GET_ENTROPY:106:get_entropy RAND_F_RAND_BYTES:100:RAND_bytes +RAND_F_RAND_BYTES_EX:126:rand_bytes_ex RAND_F_RAND_DRBG_ENABLE_LOCKING:119:rand_drbg_enable_locking RAND_F_RAND_DRBG_GENERATE:107:RAND_DRBG_generate RAND_F_RAND_DRBG_GET_ENTROPY:120:rand_drbg_get_entropy @@ -1825,6 +1839,7 @@ X509_F_BUILD_CHAIN:106:build_chain X509_F_BY_FILE_CTRL:101:by_file_ctrl X509_F_CHECK_NAME_CONSTRAINTS:149:check_name_constraints X509_F_CHECK_POLICY:145:check_policy +X509_F_COMMON_VERIFY_SM2:165:common_verify_sm2 X509_F_DANE_I2D:107:dane_i2d X509_F_DIR_CTRL:102:dir_ctrl X509_F_GET_CERT_BY_SUBJECT:103:get_cert_by_subject @@ -1868,6 +1883,8 @@ X509_F_X509_REQ_CHECK_PRIVATE_KEY:144:X509_REQ_check_private_key X509_F_X509_REQ_PRINT_EX:121:X509_REQ_print_ex X509_F_X509_REQ_PRINT_FP:122:X509_REQ_print_fp X509_F_X509_REQ_TO_X509:123:X509_REQ_to_X509 +X509_F_X509_REQ_VERIFY:163:X509_REQ_verify +X509_F_X509_REQ_VERIFY_SM2:164:x509_req_verify_sm2 X509_F_X509_STORE_ADD_CERT:124:X509_STORE_add_cert X509_F_X509_STORE_ADD_CRL:125:X509_STORE_add_crl X509_F_X509_STORE_ADD_LOOKUP:157:X509_STORE_add_lookup @@ -2056,11 +2073,13 @@ BN_R_NOT_A_SQUARE:111:not a square BN_R_NOT_INITIALIZED:107:not initialized BN_R_NO_INVERSE:108:no inverse BN_R_NO_SOLUTION:116:no solution +BN_R_NO_SUITABLE_DIGEST:120:no suitable digest BN_R_PRIVATE_KEY_TOO_LARGE:117:private key too large BN_R_P_IS_NOT_PRIME:112:p is not prime BN_R_TOO_MANY_ITERATIONS:113:too many iterations BN_R_TOO_MANY_TEMPORARY_VARIABLES:109:too many temporary variables CMS_R_ADD_SIGNER_ERROR:99:add signer error +CMS_R_ATTRIBUTE_ERROR:161:attribute error CMS_R_CERTIFICATE_ALREADY_PRESENT:175:certificate already present CMS_R_CERTIFICATE_HAS_NO_KEYID:160:certificate has no keyid CMS_R_CERTIFICATE_VERIFY_ERROR:100:certificate verify error @@ -2373,6 +2392,7 @@ ESS_R_ESS_SIGNING_CERT_V2_ADD_ERROR:101:ess signing cert v2 add error EVP_R_AES_KEY_SETUP_FAILED:143:aes key setup failed EVP_R_ARIA_KEY_SETUP_FAILED:176:aria key setup failed EVP_R_BAD_DECRYPT:100:bad decrypt +EVP_R_BAD_KEY_LENGTH:195:bad key length EVP_R_BUFFER_TOO_SMALL:155:buffer too small EVP_R_CAMELLIA_KEY_SETUP_FAILED:157:camellia key setup failed EVP_R_CIPHER_NOT_GCM_MODE:184:cipher not gcm mode @@ -2425,7 +2445,7 @@ EVP_R_NO_OPERATION_SET:149:no operation set EVP_R_ONLY_ONESHOT_SUPPORTED:177:only oneshot supported EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE:150:\ operation not supported for this keytype -EVP_R_OPERATON_NOT_INITIALIZED:151:operaton not initialized +EVP_R_OPERATON_NOT_INITIALIZED:151:operation not initialized EVP_R_PARAMETER_TOO_LARGE:187:parameter too large EVP_R_PARTIALLY_OVERLAPPING:162:partially overlapping buffers EVP_R_PBKDF2_ERROR:181:pbkdf2 error @@ -2454,8 +2474,15 @@ EVP_R_WRAP_MODE_NOT_ALLOWED:170:wrap mode not allowed EVP_R_WRONG_FINAL_BLOCK_LENGTH:109:wrong final block length EVP_R_XTS_DATA_UNIT_IS_TOO_LARGE:191:xts data unit is too large EVP_R_XTS_DUPLICATED_KEYS:192:xts duplicated keys +KDF_R_BAD_ENCODING:122:bad encoding +KDF_R_BAD_LENGTH:123:bad length +KDF_R_INAVLID_UKM_LEN:124:inavlid ukm len KDF_R_INVALID_DIGEST:100:invalid digest +KDF_R_INVALID_ITERATION_COUNT:119:invalid iteration count +KDF_R_INVALID_KEY_LEN:120:invalid key len KDF_R_INVALID_MAC_TYPE:116:invalid mac type +KDF_R_INVALID_SALT_LEN:121:invalid salt len +KDF_R_MISSING_CEK_ALG:125:missing cek alg KDF_R_MISSING_ITERATION_COUNT:109:missing iteration count KDF_R_MISSING_KEY:104:missing key KDF_R_MISSING_MESSAGE_DIGEST:105:missing message digest @@ -2469,6 +2496,7 @@ KDF_R_MISSING_TYPE:114:missing type KDF_R_MISSING_XCGHASH:115:missing xcghash KDF_R_NOT_SUPPORTED:118:not supported KDF_R_UNKNOWN_PARAMETER_TYPE:103:unknown parameter type +KDF_R_UNSUPPORTED_CEK_ALG:126:unsupported cek alg KDF_R_UNSUPPORTED_MAC_TYPE:117:unsupported mac type KDF_R_VALUE_ERROR:108:value error KDF_R_VALUE_MISSING:102:value missing @@ -3207,6 +3235,7 @@ X509_R_CERT_ALREADY_IN_HASH_TABLE:101:cert already in hash table X509_R_CRL_ALREADY_DELTA:127:crl already delta X509_R_CRL_VERIFY_FAILURE:131:crl verify failure X509_R_IDP_MISMATCH:128:idp mismatch +X509_R_INVALID_ATTRIBUTES:138:invalid attributes X509_R_INVALID_DIRECTORY:113:invalid directory X509_R_INVALID_FIELD_NAME:119:invalid field name X509_R_INVALID_TRUST:123:invalid trust diff --git a/crypto/evp/bio_ok.c b/crypto/evp/bio_ok.c index 8fe2cbcc..7f99f325 100644 --- a/crypto/evp/bio_ok.c +++ b/crypto/evp/bio_ok.c @@ -38,9 +38,9 @@ of memory. BIO_f_reliable splits data stream into blocks. Each block is prefixed - with it's length and suffixed with it's digest. So you need only + with its length and suffixed with its digest. So you need only several Kbytes of memory to buffer single block before verifying - it's digest. + its digest. BIO_f_reliable goes further and adds several important capabilities: diff --git a/crypto/evp/build.info b/crypto/evp/build.info index 61e88806..fa49f2ef 100644 --- a/crypto/evp/build.info +++ b/crypto/evp/build.info @@ -1,6 +1,7 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - encode.c digest.c evp_enc.c evp_key.c evp_cnf.c \ +$COMMON=digest.c evp_enc.c evp_lib.c evp_fetch.c cmeth_lib.c evp_utils.c +SOURCE[../../libcrypto]=$COMMON\ + encode.c evp_key.c evp_cnf.c \ e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c\ e_rc4.c e_aes.c names.c e_seed.c e_aria.c e_sm4.c \ e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \ @@ -8,21 +9,14 @@ SOURCE[../../libcrypto]=\ m_md5_sha1.c m_mdc2.c m_ripemd.c m_sha3.c \ p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \ bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \ - c_allc.c c_alld.c evp_lib.c bio_ok.c \ + c_allc.c c_alld.c bio_ok.c \ evp_pkey.c kdf_lib.c evp_pbe.c p5_crpt.c p5_crpt2.c pbe_scrypt.c \ pkey_kdf.c c_allkdf.c \ e_old.c pmeth_lib.c pmeth_fn.c pmeth_gn.c m_sigver.c \ e_aes_cbc_hmac_sha1.c e_aes_cbc_hmac_sha256.c e_rc4_hmac_md5.c \ - e_chacha20_poly1305.c cmeth_lib.c \ + e_chacha20_poly1305.c \ mac_lib.c c_allm.c pkey_mac.c - -# New design -SOURCE[../../libcrypto]=\ - evp_fetch.c - -# FIPS Module -SOURCE[../../providers/fips]=\ - digest.c evp_enc.c evp_lib.c evp_fetch.c cmeth_lib.c +SOURCE[../../providers/fips]=$COMMON INCLUDE[e_aes.o]=.. ../modes INCLUDE[e_aes_cbc_hmac_sha1.o]=../modes diff --git a/crypto/evp/c_allkdf.c b/crypto/evp/c_allkdf.c index 2233fd9c..860c11c5 100644 --- a/crypto/evp/c_allkdf.c +++ b/crypto/evp/c_allkdf.c @@ -21,4 +21,7 @@ void openssl_add_all_kdfs_int(void) EVP_add_kdf(&sshkdf_kdf_meth); EVP_add_kdf(&ss_kdf_meth); EVP_add_kdf(&x963_kdf_meth); +#ifndef OPENSSL_NO_CMS + EVP_add_kdf(&x942_kdf_meth); +#endif } diff --git a/crypto/evp/cmeth_lib.c b/crypto/evp/cmeth_lib.c index 0520157c..40aca34e 100644 --- a/crypto/evp/cmeth_lib.c +++ b/crypto/evp/cmeth_lib.c @@ -60,7 +60,7 @@ void EVP_CIPHER_meth_free(EVP_CIPHER *cipher) } } -int EVP_CIPHER_upref(EVP_CIPHER *cipher) +int EVP_CIPHER_up_ref(EVP_CIPHER *cipher) { int ref = 0; diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index a1f0154a..65b12e31 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,10 +8,12 @@ */ #include -#include "internal/cryptlib.h" #include #include #include +#include +#include +#include "internal/cryptlib.h" #include "internal/evp_int.h" #include "internal/provider.h" #include "evp_locl.h" @@ -127,6 +129,16 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) (type == NULL || (type->type == ctx->digest->type))) goto skip_to_init; + if (type != NULL) { + /* + * Ensure an ENGINE left lying around from last time is cleared (the + * previous check attempted to avoid this if the same ENGINE and + * EVP_MD could be used). + */ + ENGINE_finish(ctx->engine); + ctx->engine = NULL; + } + if (type != NULL && impl == NULL) tmpimpl = ENGINE_get_digest_engine(type->type); #endif @@ -149,16 +161,6 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) goto legacy; } - if (type->prov == NULL) { - switch(type->type) { - case NID_sha256: - case NID_md2: - break; - default: - goto legacy; - } - } - if (ctx->digest != NULL && ctx->digest->ctx_size > 0) { OPENSSL_clear_free(ctx->md_data, ctx->digest->ctx_size); ctx->md_data = NULL; @@ -184,6 +186,11 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) #endif } + if (ctx->provctx != NULL && ctx->digest != NULL && ctx->digest != type) { + if (ctx->digest->freectx != NULL) + ctx->digest->freectx(ctx->provctx); + ctx->provctx = NULL; + } ctx->digest = type; if (ctx->provctx == NULL) { ctx->provctx = ctx->digest->newctx(ossl_provider_ctx(type->prov)); @@ -205,12 +212,6 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODE) if (type) { - /* - * Ensure an ENGINE left lying around from last time is cleared (the - * previous check attempted to avoid this if the same ENGINE and - * EVP_MD could be used). - */ - ENGINE_finish(ctx->engine); if (impl != NULL) { if (!ENGINE_init(impl)) { EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_INITIALIZATION_ERROR); @@ -334,7 +335,6 @@ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *isize) } EVP_MD_CTX_reset(ctx); - return ret; /* TODO(3.0): Remove legacy code below */ @@ -354,12 +354,30 @@ int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *isize) int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md, size_t size) { int ret = 0; + OSSL_PARAM params[2]; + size_t i = 0; + if (ctx->digest == NULL || ctx->digest->prov == NULL) + goto legacy; + + if (ctx->digest->dfinal == NULL) { + EVPerr(EVP_F_EVP_DIGESTFINALXOF, EVP_R_FINAL_ERROR); + return 0; + } + + params[i++] = OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN, &size); + params[i++] = OSSL_PARAM_construct_end(); + + if (EVP_MD_CTX_set_params(ctx, params) > 0) + ret = ctx->digest->dfinal(ctx->provctx, md, &size, size); + EVP_MD_CTX_reset(ctx); + return ret; + +legacy: if (ctx->digest->flags & EVP_MD_FLAG_XOF && size <= INT_MAX && ctx->digest->md_ctrl(ctx, EVP_MD_CTRL_XOF_LEN, (int)size, NULL)) { ret = ctx->digest->final(ctx, md); - if (ctx->digest->cleanup != NULL) { ctx->digest->cleanup(ctx); EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_CLEANED); @@ -404,7 +422,7 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) out->provctx = NULL; if (in->fetched_digest != NULL) - EVP_MD_upref(in->fetched_digest); + EVP_MD_up_ref(in->fetched_digest); out->provctx = in->digest->dupctx(in->provctx); if (out->provctx == NULL) { @@ -506,13 +524,55 @@ int EVP_Digest(const void *data, size_t count, return ret; } +int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]) +{ + if (ctx->digest != NULL && ctx->digest->set_params != NULL) + return ctx->digest->set_params(ctx->provctx, params); + return 0; +} + +int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[]) +{ + if (ctx->digest != NULL && ctx->digest->get_params != NULL) + return ctx->digest->get_params(ctx->provctx, params); + return 0; +} + +/* TODO(3.0): Remove legacy code below - only used by engines & DigestSign */ int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2) { - if (ctx->digest && ctx->digest->md_ctrl) { - int ret = ctx->digest->md_ctrl(ctx, cmd, p1, p2); - if (ret <= 0) + if (ctx->digest != NULL) { + if (ctx->digest->prov != NULL) { + OSSL_PARAM params[2]; + size_t i, n = 0; + + switch (cmd) { + case EVP_MD_CTRL_XOF_LEN: + if (ctx->digest->set_params == NULL) + break; + i = (size_t)p1; + params[n++] = + OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN, &i); + params[n++] = OSSL_PARAM_construct_end(); + return ctx->digest->set_params(ctx->provctx, params); + case EVP_MD_CTRL_MICALG: + if (ctx->digest->get_params == NULL) + break; + params[n++] = + OSSL_PARAM_construct_utf8_string(OSSL_DIGEST_PARAM_MICALG, + p2, p1 ? p1 : 9999); + params[n++] = OSSL_PARAM_construct_end(); + return ctx->digest->get_params(ctx->provctx, params); + } return 0; - return 1; + } + /* legacy code */ + if (ctx->digest->md_ctrl != NULL) { + int ret = ctx->digest->md_ctrl(ctx, cmd, p1, p2); + if (ret <= 0) + return 0; + return 1; + } } return 0; } @@ -530,55 +590,59 @@ static void *evp_md_from_dispatch(const OSSL_DISPATCH *fns, for (; fns->function_id != 0; fns++) { switch (fns->function_id) { case OSSL_FUNC_DIGEST_NEWCTX: - if (md->newctx != NULL) - break; - md->newctx = OSSL_get_OP_digest_newctx(fns); - fncnt++; + if (md->newctx == NULL) { + md->newctx = OSSL_get_OP_digest_newctx(fns); + fncnt++; + } break; case OSSL_FUNC_DIGEST_INIT: - if (md->dinit != NULL) - break; - md->dinit = OSSL_get_OP_digest_init(fns); - fncnt++; + if (md->dinit == NULL) { + md->dinit = OSSL_get_OP_digest_init(fns); + fncnt++; + } break; case OSSL_FUNC_DIGEST_UPDATE: - if (md->dupdate != NULL) - break; - md->dupdate = OSSL_get_OP_digest_update(fns); - fncnt++; + if (md->dupdate == NULL) { + md->dupdate = OSSL_get_OP_digest_update(fns); + fncnt++; + } break; case OSSL_FUNC_DIGEST_FINAL: - if (md->dfinal != NULL) - break; - md->dfinal = OSSL_get_OP_digest_final(fns); - fncnt++; + if (md->dfinal == NULL) { + md->dfinal = OSSL_get_OP_digest_final(fns); + fncnt++; + } break; case OSSL_FUNC_DIGEST_DIGEST: - if (md->digest != NULL) - break; - md->digest = OSSL_get_OP_digest_digest(fns); + if (md->digest == NULL) + md->digest = OSSL_get_OP_digest_digest(fns); /* We don't increment fnct for this as it is stand alone */ break; case OSSL_FUNC_DIGEST_FREECTX: - if (md->freectx != NULL) - break; - md->freectx = OSSL_get_OP_digest_freectx(fns); - fncnt++; + if (md->freectx == NULL) { + md->freectx = OSSL_get_OP_digest_freectx(fns); + fncnt++; + } break; case OSSL_FUNC_DIGEST_DUPCTX: - if (md->dupctx != NULL) - break; - md->dupctx = OSSL_get_OP_digest_dupctx(fns); + if (md->dupctx == NULL) + md->dupctx = OSSL_get_OP_digest_dupctx(fns); break; case OSSL_FUNC_DIGEST_SIZE: - if (md->size != NULL) - break; - md->size = OSSL_get_OP_digest_size(fns); + if (md->size == NULL) + md->size = OSSL_get_OP_digest_size(fns); break; case OSSL_FUNC_DIGEST_BLOCK_SIZE: - if (md->dblock_size != NULL) - break; - md->dblock_size = OSSL_get_OP_digest_block_size(fns); + if (md->dblock_size == NULL) + md->dblock_size = OSSL_get_OP_digest_block_size(fns); + break; + case OSSL_FUNC_DIGEST_SET_PARAMS: + if (md->set_params == NULL) + md->set_params = OSSL_get_OP_digest_set_params(fns); + break; + case OSSL_FUNC_DIGEST_GET_PARAMS: + if (md->get_params == NULL) + md->get_params = OSSL_get_OP_digest_get_params(fns); break; } } @@ -596,14 +660,14 @@ static void *evp_md_from_dispatch(const OSSL_DISPATCH *fns, } md->prov = prov; if (prov != NULL) - ossl_provider_upref(prov); + ossl_provider_up_ref(prov); return md; } -static int evp_md_upref(void *md) +static int evp_md_up_ref(void *md) { - return EVP_MD_upref(md); + return EVP_MD_up_ref(md); } static void evp_md_free(void *md) @@ -616,7 +680,7 @@ EVP_MD *EVP_MD_fetch(OPENSSL_CTX *ctx, const char *algorithm, { EVP_MD *md = evp_generic_fetch(ctx, OSSL_OP_DIGEST, algorithm, properties, - evp_md_from_dispatch, evp_md_upref, + evp_md_from_dispatch, evp_md_up_ref, evp_md_free); #ifndef FIPS_MODE diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c index c9dbca98..6f58e270 100644 --- a/crypto/evp/e_aes.c +++ b/crypto/evp/e_aes.c @@ -7,18 +7,19 @@ * https://www.openssl.org/source/license.html */ +#include +#include #include #include #include #include -#include -#include #include -#include "internal/evp_int.h" -#include "internal/cryptlib.h" -#include "modes_lcl.h" #include #include +#include "internal/evp_int.h" +#include "internal/cryptlib.h" +#include "internal/modes_int.h" +#include "modes_lcl.h" #include "evp_locl.h" typedef struct { @@ -63,6 +64,12 @@ typedef struct { const unsigned char iv[16]); } EVP_AES_XTS_CTX; +#ifdef FIPS_MODE +static const int allow_insecure_decrypt = 0; +#else +static const int allow_insecure_decrypt = 1; +#endif + typedef struct { union { OSSL_UNION_ALIGN; @@ -387,6 +394,7 @@ static int aesni_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { EVP_AES_XTS_CTX *xctx = EVP_C_DATA(EVP_AES_XTS_CTX,ctx); + if (!iv && !key) return 1; @@ -401,7 +409,8 @@ static int aesni_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, * This addresses Rogaway's vulnerability. * See comment in aes_xts_init_key() below. */ - if (memcmp(key, key + bytes, bytes) == 0) { + if ((!allow_insecure_decrypt || enc) + && CRYPTO_memcmp(key, key + bytes, bytes) == 0) { EVPerr(EVP_F_AESNI_XTS_INIT_KEY, EVP_R_XTS_DUPLICATED_KEYS); return 0; } @@ -804,6 +813,7 @@ static int aes_t4_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { EVP_AES_XTS_CTX *xctx = EVP_C_DATA(EVP_AES_XTS_CTX,ctx); + if (!iv && !key) return 1; @@ -818,7 +828,8 @@ static int aes_t4_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, * This addresses Rogaway's vulnerability. * See comment in aes_xts_init_key() below. */ - if (memcmp(key, key + bytes, bytes) == 0) { + if ((!allow_insecure_decrypt || enc) + && CRYPTO_memcmp(key, key + bytes, bytes) == 0) { EVPerr(EVP_F_AES_T4_XTS_INIT_KEY, EVP_R_XTS_DUPLICATED_KEYS); return 0; } @@ -3408,10 +3419,12 @@ BLOCK_CIPHER_custom(NID_aes, 128, 1, 12, gcm, GCM, static int aes_xts_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) { - EVP_AES_XTS_CTX *xctx = EVP_C_DATA(EVP_AES_XTS_CTX,c); + EVP_AES_XTS_CTX *xctx = EVP_C_DATA(EVP_AES_XTS_CTX, c); + if (type == EVP_CTRL_COPY) { EVP_CIPHER_CTX *out = ptr; EVP_AES_XTS_CTX *xctx_out = EVP_C_DATA(EVP_AES_XTS_CTX,out); + if (xctx->xts.key1) { if (xctx->xts.key1 != &xctx->ks1) return 0; @@ -3435,6 +3448,7 @@ static int aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { EVP_AES_XTS_CTX *xctx = EVP_C_DATA(EVP_AES_XTS_CTX,ctx); + if (!iv && !key) return 1; @@ -3460,7 +3474,8 @@ static int aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, * BEFORE using the keys in the XTS-AES algorithm to process * data with them." */ - if (memcmp(key, key + bytes, bytes) == 0) { + if ((!allow_insecure_decrypt || enc) + && CRYPTO_memcmp(key, key + bytes, bytes) == 0) { EVPerr(EVP_F_AES_XTS_INIT_KEY, EVP_R_XTS_DUPLICATED_KEYS); return 0; } diff --git a/crypto/evp/e_rc5.c b/crypto/evp/e_rc5.c index b0234c91..95a626bd 100644 --- a/crypto/evp/e_rc5.c +++ b/crypto/evp/e_rc5.c @@ -66,9 +66,12 @@ static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { - RC5_32_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), - key, data(ctx)->rounds); - return 1; + if (EVP_CIPHER_CTX_key_length(ctx) > 255) { + EVPerr(EVP_F_R_32_12_16_INIT_KEY, EVP_R_BAD_KEY_LENGTH); + return 0; + } + return RC5_32_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), + key, data(ctx)->rounds); } #endif diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 02f0e005..3b83d117 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -920,6 +920,14 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) { + int ok = evp_do_param(c->cipher, &keylen, sizeof(keylen), + OSSL_CIPHER_PARAM_KEYLEN, OSSL_PARAM_INTEGER, + evp_do_ciph_ctx_setparams, c->provctx); + + if (ok != -2) + return ok; + + /* TODO(3.0) legacy code follows */ if (c->cipher->flags & EVP_CIPH_CUSTOM_KEY_LENGTH) return EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_KEY_LENGTH, keylen, NULL); if (EVP_CIPHER_CTX_key_length(c) == keylen) @@ -934,40 +942,51 @@ int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad) { + int ok; + if (pad) ctx->flags &= ~EVP_CIPH_NO_PADDING; else ctx->flags |= EVP_CIPH_NO_PADDING; - if (ctx->cipher != NULL && ctx->cipher->prov != NULL) { - OSSL_PARAM params[] = { - OSSL_PARAM_int(OSSL_CIPHER_PARAM_PADDING, NULL), - OSSL_PARAM_END - }; - - params[0].data = &pad; - - if (ctx->cipher->ctx_set_params == NULL) { - EVPerr(EVP_F_EVP_CIPHER_CTX_SET_PADDING, EVP_R_CTRL_NOT_IMPLEMENTED); - return 0; - } - - if (!ctx->cipher->ctx_set_params(ctx->provctx, params)) - return 0; - } - - return 1; + ok = evp_do_param(ctx->cipher, &pad, sizeof(pad), + OSSL_CIPHER_PARAM_PADDING, OSSL_PARAM_INTEGER, + evp_do_ciph_ctx_setparams, ctx->provctx); + return ok != 0; } int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) { - int ret; + int ret = -2; /* Unsupported */ if (!ctx->cipher) { EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_NO_CIPHER_SET); return 0; } + if (ctx->cipher->prov == NULL) + goto legacy; + + switch (type) { + case EVP_CTRL_SET_KEY_LENGTH: + ret = evp_do_param(ctx->cipher, &arg, sizeof(arg), + OSSL_CIPHER_PARAM_KEYLEN, OSSL_PARAM_INTEGER, + evp_do_ciph_ctx_setparams, ctx->provctx); + break; + case EVP_CTRL_GET_IV: + ret = evp_do_param(ctx->cipher, ptr, arg, + OSSL_CIPHER_PARAM_IV, OSSL_PARAM_OCTET_STRING, + evp_do_ciph_ctx_getparams, ctx->provctx); + break; + case EVP_CTRL_RAND_KEY: /* Used by DES */ + case EVP_CTRL_SET_PIPELINE_OUTPUT_BUFS: /* Used by DASYNC */ + case EVP_CTRL_INIT: /* TODO(3.0) Purely legacy, no provider counterpart */ + ret = -2; /* Unsupported */ + break; + } + return ret; + + legacy: if (!ctx->cipher->ctrl) { EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_NOT_IMPLEMENTED); return 0; @@ -1016,7 +1035,7 @@ int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in) *out = *in; out->provctx = NULL; - if (in->fetched_cipher != NULL && !EVP_CIPHER_upref(in->fetched_cipher)) { + if (in->fetched_cipher != NULL && !EVP_CIPHER_up_ref(in->fetched_cipher)) { out->fetched_cipher = NULL; return 0; } @@ -1123,21 +1142,6 @@ static void *evp_cipher_from_dispatch(const OSSL_DISPATCH *fns, break; cipher->dupctx = OSSL_get_OP_cipher_dupctx(fns); break; - case OSSL_FUNC_CIPHER_KEY_LENGTH: - if (cipher->key_length != NULL) - break; - cipher->key_length = OSSL_get_OP_cipher_key_length(fns); - break; - case OSSL_FUNC_CIPHER_IV_LENGTH: - if (cipher->iv_length != NULL) - break; - cipher->iv_length = OSSL_get_OP_cipher_iv_length(fns); - break; - case OSSL_FUNC_CIPHER_BLOCK_SIZE: - if (cipher->blocksize != NULL) - break; - cipher->blocksize = OSSL_get_OP_cipher_block_size(fns); - break; case OSSL_FUNC_CIPHER_GET_PARAMS: if (cipher->get_params != NULL) break; @@ -1157,10 +1161,7 @@ static void *evp_cipher_from_dispatch(const OSSL_DISPATCH *fns, } if ((fnciphcnt != 0 && fnciphcnt != 3 && fnciphcnt != 4) || (fnciphcnt == 0 && cipher->ccipher == NULL) - || fnctxcnt != 2 - || cipher->blocksize == NULL - || cipher->iv_length == NULL - || cipher->key_length == NULL) { + || fnctxcnt != 2) { /* * In order to be a consistent set of functions we must have at least * a complete set of "encrypt" functions, or a complete set of "decrypt" @@ -1174,14 +1175,14 @@ static void *evp_cipher_from_dispatch(const OSSL_DISPATCH *fns, } cipher->prov = prov; if (prov != NULL) - ossl_provider_upref(prov); + ossl_provider_up_ref(prov); return cipher; } -static int evp_cipher_upref(void *cipher) +static int evp_cipher_up_ref(void *cipher) { - return EVP_CIPHER_upref(cipher); + return EVP_CIPHER_up_ref(cipher); } static void evp_cipher_free(void *cipher) @@ -1194,7 +1195,7 @@ EVP_CIPHER *EVP_CIPHER_fetch(OPENSSL_CTX *ctx, const char *algorithm, { EVP_CIPHER *cipher = evp_generic_fetch(ctx, OSSL_OP_CIPHER, algorithm, properties, - evp_cipher_from_dispatch, evp_cipher_upref, + evp_cipher_from_dispatch, evp_cipher_up_ref, evp_cipher_free); #ifndef FIPS_MODE diff --git a/crypto/evp/evp_err.c b/crypto/evp/evp_err.c index 836f5ee9..99535c00 100644 --- a/crypto/evp/evp_err.c +++ b/crypto/evp/evp_err.c @@ -78,7 +78,7 @@ static const ERR_STRING_DATA EVP_str_functs[] = { {ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_KDF_CTX_NEW_ID, 0), "EVP_KDF_CTX_new_id"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_CTRL, 0), "EVP_MAC_ctrl"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_CTRL_STR, 0), "EVP_MAC_ctrl_str"}, - {ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_CTX_COPY, 0), "EVP_MAC_CTX_copy"}, + {ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_CTX_DUP, 0), "EVP_MAC_CTX_dup"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_CTX_NEW, 0), "EVP_MAC_CTX_new"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_INIT, 0), "EVP_MAC_init"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MD_BLOCK_SIZE, 0), "EVP_MD_block_size"}, @@ -179,11 +179,14 @@ static const ERR_STRING_DATA EVP_str_functs[] = { {ERR_PACK(ERR_LIB_EVP, EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN, 0), "PKCS5_v2_scrypt_keyivgen"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_PKEY_KDF_CTRL, 0), "pkey_kdf_ctrl"}, + {ERR_PACK(ERR_LIB_EVP, EVP_F_PKEY_MAC_COPY, 0), "pkey_mac_copy"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_PKEY_MAC_INIT, 0), "pkey_mac_init"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_PKEY_SET_TYPE, 0), "pkey_set_type"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_POLY1305_CTRL, 0), "poly1305_ctrl"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_RC2_MAGIC_TO_METH, 0), "rc2_magic_to_meth"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_RC5_CTRL, 0), "rc5_ctrl"}, + {ERR_PACK(ERR_LIB_EVP, EVP_F_R_32_12_16_INIT_KEY, 0), + "r_32_12_16_init_key"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_S390X_AES_GCM_CTRL, 0), "s390x_aes_gcm_ctrl"}, {ERR_PACK(ERR_LIB_EVP, EVP_F_S390X_AES_GCM_TLS_CIPHER, 0), "s390x_aes_gcm_tls_cipher"}, @@ -198,6 +201,7 @@ static const ERR_STRING_DATA EVP_str_reasons[] = { {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_ARIA_KEY_SETUP_FAILED), "aria key setup failed"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_BAD_DECRYPT), "bad decrypt"}, + {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_BAD_KEY_LENGTH), "bad key length"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_BUFFER_TOO_SMALL), "buffer too small"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_CAMELLIA_KEY_SETUP_FAILED), "camellia key setup failed"}, @@ -280,7 +284,7 @@ static const ERR_STRING_DATA EVP_str_reasons[] = { {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE), "operation not supported for this keytype"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_OPERATON_NOT_INITIALIZED), - "operaton not initialized"}, + "operation not initialized"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PARAMETER_TOO_LARGE), "parameter too large"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_PARTIALLY_OVERLAPPING), diff --git a/crypto/evp/evp_fetch.c b/crypto/evp/evp_fetch.c index fdd6209b..0c25f0d5 100644 --- a/crypto/evp/evp_fetch.c +++ b/crypto/evp/evp_fetch.c @@ -39,7 +39,6 @@ static const OPENSSL_CTX_METHOD default_method_store_method = { struct method_data_st { OPENSSL_CTX *libctx; const char *name; - int id; OSSL_METHOD_CONSTRUCT_METHOD *mcm; void *(*method_from_dispatch)(const OSSL_DISPATCH *, OSSL_PROVIDER *); int (*refcnt_up_method)(void *method); @@ -66,24 +65,45 @@ static OSSL_METHOD_STORE *get_default_method_store(OPENSSL_CTX *libctx) &default_method_store_method); } +/* + * To identity the method in the method store, we mix the name identity + * with the operation identity, with the assumption that we don't have + * more than 2^24 names or more than 2^8 operation types. + * + * The resulting identity is a 32-bit integer, composed like this: + * + * +---------24 bits--------+-8 bits-+ + * | name identity | op id | + * +------------------------+--------+ + */ +static uint32_t method_id(unsigned int operation_id, unsigned int name_id) +{ + if (!ossl_assert(name_id < (1 << 24) || operation_id < (1 << 8)) + || !ossl_assert(name_id > 0 && operation_id > 0)) + return 0; + return ((name_id << 8) & 0xFFFFFF00) | (operation_id & 0x000000FF); +} + static void *get_method_from_store(OPENSSL_CTX *libctx, void *store, - const char *name, const char *propquery, - void *data) + int operation_id, const char *name, + const char *propquery, void *data) { struct method_data_st *methdata = data; void *method = NULL; OSSL_NAMEMAP *namemap; - int id; + int nameid; + uint32_t methid; if (store == NULL && (store = get_default_method_store(libctx)) == NULL) return NULL; if ((namemap = ossl_namemap_stored(libctx)) == NULL - || (id = ossl_namemap_add(namemap, name)) == 0) + || (nameid = ossl_namemap_name2num(namemap, name)) == 0 + || (methid = method_id(operation_id, nameid)) == 0) return NULL; - (void)ossl_method_store_fetch(store, id, propquery, &method); + (void)ossl_method_store_fetch(store, methid, propquery, &method); if (method != NULL && !methdata->refcnt_up_method(method)) { @@ -93,15 +113,18 @@ static void *get_method_from_store(OPENSSL_CTX *libctx, void *store, } static int put_method_in_store(OPENSSL_CTX *libctx, void *store, - void *method, const char *name, - const char *propdef, void *data) + void *method, int operation_id, + const char *name, const char *propdef, + void *data) { struct method_data_st *methdata = data; OSSL_NAMEMAP *namemap; - int id; + int nameid; + uint32_t methid; if ((namemap = ossl_namemap_stored(methdata->libctx)) == NULL - || (id = ossl_namemap_add(namemap, name)) == 0) + || (nameid = ossl_namemap_add(namemap, 0, name)) == 0 + || (methid = method_id(operation_id, nameid)) == 0) return 0; if (store == NULL @@ -109,7 +132,7 @@ static int put_method_in_store(OPENSSL_CTX *libctx, void *store, return 0; if (methdata->refcnt_up_method(method) - && ossl_method_store_add(store, id, propdef, method, + && ossl_method_store_add(store, methid, propdef, method, methdata->destruct_method)) return 1; return 0; @@ -134,19 +157,37 @@ void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id, const char *name, const char *properties, void *(*new_method)(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov), - int (*upref_method)(void *), + int (*up_ref_method)(void *), void (*free_method)(void *)) { OSSL_METHOD_STORE *store = get_default_method_store(libctx); OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx); - int id; + int nameid = 0; + uint32_t methid = 0; void *method = NULL; if (store == NULL || namemap == NULL) return NULL; - if ((id = ossl_namemap_number(namemap, name)) == 0 - || !ossl_method_store_cache_get(store, id, properties, &method)) { + /* + * If there's ever an operation_id == 0 passed, we have an internal + * programming error. + */ + if (!ossl_assert(operation_id > 0)) + return NULL; + + /* + * method_id returns 0 if we have too many operations (more than + * about 2^8) or too many names (more than about 2^24). In that + * case, we can't create any new method. + */ + if ((nameid = ossl_namemap_name2num(namemap, name)) != 0 + && (methid = method_id(operation_id, nameid)) == 0) + return NULL; + + if (nameid == 0 + || !ossl_method_store_cache_get(store, methid, properties, + &method)) { OSSL_METHOD_CONSTRUCT_METHOD mcm = { alloc_tmp_method_store, dealloc_tmp_method_store, @@ -159,16 +200,26 @@ void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id, mcmdata.mcm = &mcm; mcmdata.libctx = libctx; + mcmdata.name = name; mcmdata.method_from_dispatch = new_method; mcmdata.destruct_method = free_method; - mcmdata.refcnt_up_method = upref_method; + mcmdata.refcnt_up_method = up_ref_method; mcmdata.destruct_method = free_method; - method = ossl_method_construct(libctx, operation_id, name, - properties, 0 /* !force_cache */, - &mcm, &mcmdata); - ossl_method_store_cache_set(store, id, properties, method); + if ((method = ossl_method_construct(libctx, operation_id, name, + properties, 0 /* !force_cache */, + &mcm, &mcmdata)) != NULL) { + /* + * If construction did create a method for us, we know that + * there is a correct nameid and methodid, since those have + * already been calculated in get_method_from_store() and + * put_method_in_store() above. + */ + nameid = ossl_namemap_name2num(namemap, name); + methid = method_id(operation_id, nameid); + ossl_method_store_cache_set(store, methid, properties, method); + } } else { - upref_method(method); + up_ref_method(method); } return method; diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index faaa69d3..9d1d197c 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -217,13 +217,12 @@ int EVP_CIPHER_type(const EVP_CIPHER *ctx) int EVP_CIPHER_block_size(const EVP_CIPHER *cipher) { - if (cipher->prov != NULL) { - if (cipher->blocksize != NULL) - return cipher->blocksize(); - /* We default to a block size of 1 */ - return 1; - } - return cipher->block_size; + int v = cipher->block_size; + int ok = evp_do_param(cipher, &v, sizeof(v), + OSSL_CIPHER_PARAM_BLOCK_SIZE, OSSL_PARAM_INTEGER, + evp_do_ciph_getparams, NULL); + + return ok != 0 ? v : -1; } int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx) @@ -266,7 +265,12 @@ int EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx) unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher) { - return cipher->flags; + unsigned long v = cipher->flags; + int ok = evp_do_param(cipher, &v, sizeof(v), + OSSL_CIPHER_PARAM_FLAGS, OSSL_PARAM_UNSIGNED_INTEGER, + evp_do_ciph_getparams, NULL); + + return ok != 0 ? v : 0; } void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx) @@ -296,13 +300,12 @@ void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data) int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher) { - if (cipher->prov != NULL) { - if (cipher->iv_length != NULL) - return (int)cipher->iv_length(); - return 0; - } + int v = cipher->iv_len; + int ok = evp_do_param(cipher, &v, sizeof(v), + OSSL_CIPHER_PARAM_IVLEN, OSSL_PARAM_UNSIGNED_INTEGER, + evp_do_ciph_getparams, NULL); - return cipher->iv_len; + return ok != 0 ? v: -1; } int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx) @@ -315,14 +318,27 @@ const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx) return ctx->oiv; } +/* + * OSSL_PARAM_OCTET_PTR gets us the pointer to the running IV in the provider + */ const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx) { - return ctx->iv; + const unsigned char *v = ctx->iv; + int ok = evp_do_param(ctx->cipher, &v, sizeof(ctx->iv), + OSSL_CIPHER_PARAM_IV, OSSL_PARAM_OCTET_PTR, + evp_do_ciph_ctx_getparams, ctx->provctx); + + return ok != 0 ? v: NULL; } unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx) { - return ctx->iv; + unsigned char *v = ctx->iv; + int ok = evp_do_param(ctx->cipher, &v, sizeof(ctx->iv), + OSSL_CIPHER_PARAM_IV, OSSL_PARAM_OCTET_PTR, + evp_do_ciph_ctx_getparams, ctx->provctx); + + return ok != 0 ? v: NULL; } unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx) @@ -332,34 +348,42 @@ unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx) int EVP_CIPHER_CTX_num(const EVP_CIPHER_CTX *ctx) { - return ctx->num; + int v = ctx->num; + int ok = evp_do_param(ctx->cipher, &v, sizeof(v), + OSSL_CIPHER_PARAM_NUM, OSSL_PARAM_INTEGER, + evp_do_ciph_ctx_getparams, ctx->provctx); + + return ok != 0 ? v: -1; } -void EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num) +int EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num) { + int ok = evp_do_param(ctx->cipher, &num, sizeof(num), + OSSL_CIPHER_PARAM_NUM, OSSL_PARAM_INTEGER, + evp_do_ciph_ctx_setparams, ctx->provctx); + ctx->num = num; + return ok != 0; } int EVP_CIPHER_key_length(const EVP_CIPHER *cipher) { - if (cipher->prov != NULL) { - if (cipher->key_length != NULL) - return (int)cipher->key_length(); - return -1; - } + int v = cipher->key_len; + int ok = evp_do_param(cipher, &v, sizeof(v), + OSSL_CIPHER_PARAM_KEYLEN, OSSL_PARAM_INTEGER, + evp_do_ciph_getparams, NULL); - return cipher->key_len; + return ok != 0 ? v: -1; } int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx) { - /* - * TODO(3.0): This may need to change if/when we introduce variable length - * key ciphers into the providers. - */ - if (ctx->cipher != NULL && ctx->cipher->prov != NULL) - return EVP_CIPHER_key_length(ctx->cipher); - return ctx->key_len; + int v = ctx->key_len; + int ok = evp_do_param(ctx->cipher, &v, sizeof(v), + OSSL_CIPHER_PARAM_KEYLEN, OSSL_PARAM_INTEGER, + evp_do_ciph_ctx_getparams, ctx->provctx); + + return ok != 0 ? v: -1; } int EVP_CIPHER_nid(const EVP_CIPHER *cipher) @@ -374,28 +398,12 @@ int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) int EVP_CIPHER_mode(const EVP_CIPHER *cipher) { - if (cipher->prov != NULL) { - int mode; + int v = EVP_CIPHER_flags(cipher) & EVP_CIPH_MODE; + int ok = evp_do_param(cipher, &v, sizeof(v), + OSSL_CIPHER_PARAM_MODE, OSSL_PARAM_INTEGER, + evp_do_ciph_getparams, NULL); - /* Cipher comes from a provider - so ask the provider for the mode */ - OSSL_PARAM params[] = { - OSSL_PARAM_int(OSSL_CIPHER_PARAM_MODE, NULL), - OSSL_PARAM_END - }; - - params[0].data = &mode; - - if (cipher->get_params == NULL) { - EVPerr(EVP_F_EVP_CIPHER_MODE, EVP_R_CTRL_NOT_IMPLEMENTED); - return 0; - } - - if (!cipher->get_params(params)) - return 0; - - return mode; - } - return EVP_CIPHER_flags(cipher) & EVP_CIPH_MODE; + return ok != 0 ? v: 0; } @@ -469,7 +477,7 @@ EVP_MD *EVP_MD_meth_dup(const EVP_MD *md) return to; } -int EVP_MD_upref(EVP_MD *md) +int EVP_MD_up_ref(EVP_MD *md) { int ref = 0; diff --git a/crypto/evp/evp_locl.h b/crypto/evp/evp_locl.h index 8876b061..54f9e081 100644 --- a/crypto/evp/evp_locl.h +++ b/crypto/evp/evp_locl.h @@ -93,5 +93,42 @@ void *evp_generic_fetch(OPENSSL_CTX *ctx, int operation_id, const char *algorithm, const char *properties, void *(*new_method)(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov), - int (*upref_method)(void *), + int (*up_ref_method)(void *), void (*free_method)(void *)); + +/* Helper functions to avoid duplicating code */ + +/* + * The callbacks implement different ways to pass a params array to the + * provider. They will return one of these values: + * + * -2 if the method doesn't come from a provider + * (evp_do_param will return this to the called) + * -1 if the provider doesn't offer the desired function + * (evp_do_param will raise an error and return 0) + * or the return value from the desired function + * (evp_do_param will return it to the caller) + */ +int evp_do_ciph_getparams(const void *vciph, void *ignored, + OSSL_PARAM params[]); +int evp_do_ciph_ctx_getparams(const void *vciph, void *provctx, + OSSL_PARAM params[]); +int evp_do_ciph_ctx_setparams(const void *vciph, void *provctx, + OSSL_PARAM params[]); + +/*- + * prepares a singular parameter, then calls the callback to execute. + * + * |method| points to the method used by the callback. + * EVP_CIPHER, EVP_MD, ... + * |ptr| points at the data to transfer. + * |sz| is the size of the data to transfer. + * |key| is the name of the parameter to pass. + * |datatype| is the data type of the parameter to pass. + * |cb| is the callback that actually performs the parameter passing + * |cb_ctx| is the cipher context + */ +int evp_do_param(const void *method, void *ptr, size_t sz, const char *key, + int datatype, + int (*cb)(const void *method, void *ctx, OSSL_PARAM params[]), + void *cb_ctx); diff --git a/crypto/evp/evp_utils.c b/crypto/evp/evp_utils.c new file mode 100644 index 00000000..48f548c7 --- /dev/null +++ b/crypto/evp/evp_utils.c @@ -0,0 +1,78 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* Internal EVP utility functions */ + +#include +#include +#include +#include /* evp_locl.h needs it */ +#include /* evp_locl.h needs it */ +#include "internal/evp_int.h" /* evp_locl.h needs it */ +#include "evp_locl.h" + +int evp_do_ciph_getparams(const void *vciph, void *ignored, + OSSL_PARAM params[]) +{ + const EVP_CIPHER *ciph = vciph; + + if (ciph->prov == NULL) + return -2; + if (ciph->get_params == NULL) + return -1; + return ciph->get_params(params); +} + +int evp_do_ciph_ctx_getparams(const void *vciph, void *provctx, + OSSL_PARAM params[]) +{ + const EVP_CIPHER *ciph = vciph; + + if (ciph->prov == NULL) + return -2; + if (ciph->ctx_get_params == NULL) + return -1; + return ciph->ctx_get_params(provctx, params); +} + +int evp_do_ciph_ctx_setparams(const void *vciph, void *provctx, + OSSL_PARAM params[]) +{ + const EVP_CIPHER *ciph = vciph; + + if (ciph->prov == NULL) + return -2; + if (ciph->ctx_set_params == NULL) + return -1; + return ciph->ctx_set_params(provctx, params); +} + +int evp_do_param(const void *method, void *ptr, size_t sz, const char *key, + int datatype, + int (*cb)(const void *method, void *ctx, OSSL_PARAM params[]), + void *cb_ctx) +{ + OSSL_PARAM params[2] = { + OSSL_PARAM_END, + OSSL_PARAM_END + }; + int ret; + + params[0].key = key; + params[0].data_type = datatype; + params[0].data = ptr; + params[0].data_size = sz; + + ret = cb(method, cb_ctx, params); + if (ret == -1) { + EVPerr(0, EVP_R_CTRL_NOT_IMPLEMENTED); + ret = 0; + } + return ret; +} diff --git a/crypto/evp/m_md5_sha1.c b/crypto/evp/m_md5_sha1.c index 425ed477..af8ae31e 100644 --- a/crypto/evp/m_md5_sha1.c +++ b/crypto/evp/m_md5_sha1.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,131 +7,46 @@ * https://www.openssl.org/source/license.html */ -#if !defined(OPENSSL_NO_MD5) +#ifndef OPENSSL_NO_MD5 +# include # include -# include -# include -# include -# include -# include "internal/cryptlib.h" +# include # include "internal/evp_int.h" -# include - -struct md5_sha1_ctx { - MD5_CTX md5; - SHA_CTX sha1; -}; +# include "internal/md5_sha1.h" static int init(EVP_MD_CTX *ctx) { - struct md5_sha1_ctx *mctx = EVP_MD_CTX_md_data(ctx); - if (!MD5_Init(&mctx->md5)) - return 0; - return SHA1_Init(&mctx->sha1); + return md5_sha1_init(EVP_MD_CTX_md_data(ctx)); } static int update(EVP_MD_CTX *ctx, const void *data, size_t count) { - struct md5_sha1_ctx *mctx = EVP_MD_CTX_md_data(ctx); - if (!MD5_Update(&mctx->md5, data, count)) - return 0; - return SHA1_Update(&mctx->sha1, data, count); + return md5_sha1_update(EVP_MD_CTX_md_data(ctx), data, count); } static int final(EVP_MD_CTX *ctx, unsigned char *md) { - struct md5_sha1_ctx *mctx = EVP_MD_CTX_md_data(ctx); - if (!MD5_Final(md, &mctx->md5)) - return 0; - return SHA1_Final(md + MD5_DIGEST_LENGTH, &mctx->sha1); + return md5_sha1_final(md, EVP_MD_CTX_md_data(ctx)); } static int ctrl(EVP_MD_CTX *ctx, int cmd, int mslen, void *ms) { - unsigned char padtmp[48]; - unsigned char md5tmp[MD5_DIGEST_LENGTH]; - unsigned char sha1tmp[SHA_DIGEST_LENGTH]; - struct md5_sha1_ctx *mctx; - - if (cmd != EVP_CTRL_SSL3_MASTER_SECRET) - return -2; - - if (ctx == NULL) - return 0; - - mctx = EVP_MD_CTX_md_data(ctx); - - /* SSLv3 client auth handling: see RFC-6101 5.6.8 */ - if (mslen != 48) - return 0; - - /* At this point hash contains all handshake messages, update - * with master secret and pad_1. - */ - - if (update(ctx, ms, mslen) <= 0) - return 0; - - /* Set padtmp to pad_1 value */ - memset(padtmp, 0x36, sizeof(padtmp)); - - if (!MD5_Update(&mctx->md5, padtmp, sizeof(padtmp))) - return 0; - - if (!MD5_Final(md5tmp, &mctx->md5)) - return 0; - - if (!SHA1_Update(&mctx->sha1, padtmp, 40)) - return 0; - - if (!SHA1_Final(sha1tmp, &mctx->sha1)) - return 0; - - /* Reinitialise context */ - - if (!init(ctx)) - return 0; - - if (update(ctx, ms, mslen) <= 0) - return 0; - - /* Set padtmp to pad_2 value */ - memset(padtmp, 0x5c, sizeof(padtmp)); - - if (!MD5_Update(&mctx->md5, padtmp, sizeof(padtmp))) - return 0; - - if (!MD5_Update(&mctx->md5, md5tmp, sizeof(md5tmp))) - return 0; - - if (!SHA1_Update(&mctx->sha1, padtmp, 40)) - return 0; - - if (!SHA1_Update(&mctx->sha1, sha1tmp, sizeof(sha1tmp))) - return 0; - - /* Now when ctx is finalised it will return the SSL v3 hash value */ - - OPENSSL_cleanse(md5tmp, sizeof(md5tmp)); - OPENSSL_cleanse(sha1tmp, sizeof(sha1tmp)); - - return 1; - + return md5_sha1_ctrl(EVP_MD_CTX_md_data(ctx), cmd, mslen, ms); } static const EVP_MD md5_sha1_md = { NID_md5_sha1, NID_md5_sha1, - MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, + MD5_SHA1_DIGEST_LENGTH, 0, init, update, final, NULL, NULL, - MD5_CBLOCK, - sizeof(EVP_MD *) + sizeof(struct md5_sha1_ctx), + MD5_SHA1_CBLOCK, + sizeof(EVP_MD *) + sizeof(MD5_SHA1_CTX), ctrl }; @@ -139,4 +54,5 @@ const EVP_MD *EVP_md5_sha1(void) { return &md5_sha1_md; } -#endif + +#endif /* OPENSSL_NO_MD5 */ diff --git a/crypto/evp/m_sha1.c b/crypto/evp/m_sha1.c index 59333b24..1258ea03 100644 --- a/crypto/evp/m_sha1.c +++ b/crypto/evp/m_sha1.c @@ -32,63 +32,9 @@ static int final(EVP_MD_CTX *ctx, unsigned char *md) return SHA1_Final(md, EVP_MD_CTX_md_data(ctx)); } -static int ctrl(EVP_MD_CTX *ctx, int cmd, int mslen, void *ms) +static int ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2) { - unsigned char padtmp[40]; - unsigned char sha1tmp[SHA_DIGEST_LENGTH]; - - SHA_CTX *sha1; - - if (cmd != EVP_CTRL_SSL3_MASTER_SECRET) - return -2; - - if (ctx == NULL) - return 0; - - sha1 = EVP_MD_CTX_md_data(ctx); - - /* SSLv3 client auth handling: see RFC-6101 5.6.8 */ - if (mslen != 48) - return 0; - - /* At this point hash contains all handshake messages, update - * with master secret and pad_1. - */ - - if (SHA1_Update(sha1, ms, mslen) <= 0) - return 0; - - /* Set padtmp to pad_1 value */ - memset(padtmp, 0x36, sizeof(padtmp)); - - if (!SHA1_Update(sha1, padtmp, sizeof(padtmp))) - return 0; - - if (!SHA1_Final(sha1tmp, sha1)) - return 0; - - /* Reinitialise context */ - - if (!SHA1_Init(sha1)) - return 0; - - if (SHA1_Update(sha1, ms, mslen) <= 0) - return 0; - - /* Set padtmp to pad_2 value */ - memset(padtmp, 0x5c, sizeof(padtmp)); - - if (!SHA1_Update(sha1, padtmp, sizeof(padtmp))) - return 0; - - if (!SHA1_Update(sha1, sha1tmp, sizeof(sha1tmp))) - return 0; - - /* Now when ctx is finalised it will return the SSL v3 hash value */ - OPENSSL_cleanse(sha1tmp, sizeof(sha1tmp)); - - return 1; - + return sha1_ctrl(ctx != NULL ? EVP_MD_CTX_md_data(ctx) : NULL, cmd, p1, p2); } static const EVP_MD sha1_md = { diff --git a/crypto/evp/m_sha3.c b/crypto/evp/m_sha3.c index a9263b80..f3266ebe 100644 --- a/crypto/evp/m_sha3.c +++ b/crypto/evp/m_sha3.c @@ -13,120 +13,33 @@ #include #include #include "internal/evp_int.h" +#include "internal/sha3.h" #include "evp_locl.h" -size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len, - size_t r); -void SHA3_squeeze(uint64_t A[5][5], unsigned char *out, size_t len, size_t r); - -#define KECCAK1600_WIDTH 1600 - -typedef struct { - uint64_t A[5][5]; - size_t block_size; /* cached ctx->digest->block_size */ - size_t md_size; /* output length, variable in XOF */ - size_t num; /* used bytes in below buffer */ - unsigned char buf[KECCAK1600_WIDTH / 8 - 32]; - unsigned char pad; -} KECCAK1600_CTX; - -static int init(EVP_MD_CTX *evp_ctx, unsigned char pad) +static int init(EVP_MD_CTX *ctx) { - KECCAK1600_CTX *ctx = evp_ctx->md_data; - size_t bsz = evp_ctx->digest->block_size; - - if (bsz <= sizeof(ctx->buf)) { - memset(ctx->A, 0, sizeof(ctx->A)); - - ctx->num = 0; - ctx->block_size = bsz; - ctx->md_size = evp_ctx->digest->md_size; - ctx->pad = pad; - - return 1; - } - - return 0; + return sha3_init(EVP_MD_CTX_md_data(ctx), '\x06', ctx->digest->md_size * 8); } -static int sha3_init(EVP_MD_CTX *evp_ctx) +static int update(EVP_MD_CTX *ctx, const void *_inp, size_t len) { - return init(evp_ctx, '\x06'); + return sha3_update(EVP_MD_CTX_md_data(ctx), _inp, len); } -static int shake_init(EVP_MD_CTX *evp_ctx) +static int final(EVP_MD_CTX *ctx, unsigned char *md) { - return init(evp_ctx, '\x1f'); + return sha3_final(md, EVP_MD_CTX_md_data(ctx)); } -static int kmac_init(EVP_MD_CTX *evp_ctx) +static int shake_init(EVP_MD_CTX *ctx) { - return init(evp_ctx, '\x04'); + return sha3_init(EVP_MD_CTX_md_data(ctx), '\x1f', ctx->digest->md_size * 8); } -static int sha3_update(EVP_MD_CTX *evp_ctx, const void *_inp, size_t len) +static int kmac_init(EVP_MD_CTX *ctx) { - KECCAK1600_CTX *ctx = evp_ctx->md_data; - const unsigned char *inp = _inp; - size_t bsz = ctx->block_size; - size_t num, rem; - - if (len == 0) - return 1; - - if ((num = ctx->num) != 0) { /* process intermediate buffer? */ - rem = bsz - num; - - if (len < rem) { - memcpy(ctx->buf + num, inp, len); - ctx->num += len; - return 1; - } - /* - * We have enough data to fill or overflow the intermediate - * buffer. So we append |rem| bytes and process the block, - * leaving the rest for later processing... - */ - memcpy(ctx->buf + num, inp, rem); - inp += rem, len -= rem; - (void)SHA3_absorb(ctx->A, ctx->buf, bsz, bsz); - ctx->num = 0; - /* ctx->buf is processed, ctx->num is guaranteed to be zero */ - } - - if (len >= bsz) - rem = SHA3_absorb(ctx->A, inp, len, bsz); - else - rem = len; - - if (rem) { - memcpy(ctx->buf, inp + len - rem, rem); - ctx->num = rem; - } - - return 1; -} - -static int sha3_final(EVP_MD_CTX *evp_ctx, unsigned char *md) -{ - KECCAK1600_CTX *ctx = evp_ctx->md_data; - size_t bsz = ctx->block_size; - size_t num = ctx->num; - - /* - * Pad the data with 10*1. Note that |num| can be |bsz - 1| - * in which case both byte operations below are performed on - * same byte... - */ - memset(ctx->buf + num, 0, bsz - num); - ctx->buf[num] = ctx->pad; - ctx->buf[bsz - 1] |= 0x80; - - (void)SHA3_absorb(ctx->A, ctx->buf, bsz, bsz); - - SHA3_squeeze(ctx->A, md, ctx->md_size, bsz); - - return 1; + return keccak_kmac_init(EVP_MD_CTX_md_data(ctx), '\x04', + ctx->digest->md_size * 8 / 2); } static int shake_ctrl(EVP_MD_CTX *evp_ctx, int cmd, int p1, void *p2) @@ -205,7 +118,7 @@ static int s390x_sha3_init(EVP_MD_CTX *evp_ctx) } memset(ctx->A, 0, sizeof(ctx->A)); - ctx->num = 0; + ctx->bufsz = 0; ctx->block_size = bsz; ctx->md_size = evp_ctx->digest->md_size; return 1; @@ -232,7 +145,7 @@ static int s390x_shake_init(EVP_MD_CTX *evp_ctx) } memset(ctx->A, 0, sizeof(ctx->A)); - ctx->num = 0; + ctx->bufsz = 0; ctx->block_size = bsz; ctx->md_size = evp_ctx->digest->md_size; return 1; @@ -248,19 +161,19 @@ static int s390x_sha3_update(EVP_MD_CTX *evp_ctx, const void *_inp, size_t len) if (len == 0) return 1; - if ((num = ctx->num) != 0) { + if ((num = ctx->bufsz) != 0) { rem = bsz - num; if (len < rem) { memcpy(ctx->buf + num, inp, len); - ctx->num += len; + ctx->bufsz += len; return 1; } memcpy(ctx->buf + num, inp, rem); inp += rem; len -= rem; s390x_kimd(ctx->buf, bsz, ctx->pad, ctx->A); - ctx->num = 0; + ctx->bufsz = 0; } rem = len % bsz; @@ -268,7 +181,7 @@ static int s390x_sha3_update(EVP_MD_CTX *evp_ctx, const void *_inp, size_t len) if (rem) { memcpy(ctx->buf, inp + len - rem, rem); - ctx->num = rem; + ctx->bufsz = rem; } return 1; } @@ -277,7 +190,7 @@ static int s390x_sha3_final(EVP_MD_CTX *evp_ctx, unsigned char *md) { KECCAK1600_CTX *ctx = evp_ctx->md_data; - s390x_klmd(ctx->buf, ctx->num, NULL, 0, ctx->pad, ctx->A); + s390x_klmd(ctx->buf, ctx->bufsz, NULL, 0, ctx->pad, ctx->A); memcpy(md, ctx->A, ctx->md_size); return 1; } @@ -286,7 +199,7 @@ static int s390x_shake_final(EVP_MD_CTX *evp_ctx, unsigned char *md) { KECCAK1600_CTX *ctx = evp_ctx->md_data; - s390x_klmd(ctx->buf, ctx->num, md, ctx->md_size, ctx->pad, ctx->A); + s390x_klmd(ctx->buf, ctx->bufsz, md, ctx->md_size, ctx->pad, ctx->A); return 1; } @@ -311,9 +224,9 @@ const EVP_MD *EVP_sha3_##bitlen(void) \ NID_RSA_SHA3_##bitlen, \ bitlen / 8, \ EVP_MD_FLAG_DIGALGID_ABSENT, \ - sha3_init, \ - sha3_update, \ - sha3_final, \ + init, \ + update, \ + final, \ NULL, \ NULL, \ (KECCAK1600_WIDTH - bitlen * 2) / 8, \ @@ -347,8 +260,8 @@ const EVP_MD *EVP_shake##bitlen(void) \ bitlen / 8, \ EVP_MD_FLAG_XOF, \ shake_init, \ - sha3_update, \ - sha3_final, \ + update, \ + final, \ NULL, \ NULL, \ (KECCAK1600_WIDTH - bitlen * 2) / 8, \ @@ -370,9 +283,9 @@ const EVP_MD *EVP_sha3_##bitlen(void) \ NID_RSA_SHA3_##bitlen, \ bitlen / 8, \ EVP_MD_FLAG_DIGALGID_ABSENT, \ - sha3_init, \ - sha3_update, \ - sha3_final, \ + init, \ + update, \ + final, \ NULL, \ NULL, \ (KECCAK1600_WIDTH - bitlen * 2) / 8, \ @@ -390,8 +303,8 @@ const EVP_MD *EVP_shake##bitlen(void) \ bitlen / 8, \ EVP_MD_FLAG_XOF, \ shake_init, \ - sha3_update, \ - sha3_final, \ + update, \ + final, \ NULL, \ NULL, \ (KECCAK1600_WIDTH - bitlen * 2) / 8, \ @@ -416,13 +329,13 @@ EVP_MD_SHAKE(256) const EVP_MD *evp_keccak_kmac##bitlen(void) \ { \ static const EVP_MD kmac_##bitlen##_md = { \ - -1, \ + NID_kmac##bitlen, \ 0, \ 2 * bitlen / 8, \ EVP_MD_FLAG_XOF, \ kmac_init, \ - sha3_update, \ - sha3_final, \ + update, \ + final, \ NULL, \ NULL, \ (KECCAK1600_WIDTH - bitlen * 2) / 8, \ diff --git a/crypto/evp/mac_lib.c b/crypto/evp/mac_lib.c index 39efff08..ee4a68f4 100644 --- a/crypto/evp/mac_lib.c +++ b/crypto/evp/mac_lib.c @@ -48,18 +48,28 @@ void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx) OPENSSL_free(ctx); } -int EVP_MAC_CTX_copy(EVP_MAC_CTX *dst, const EVP_MAC_CTX *src) +EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src) { - EVP_MAC_IMPL *macdata; + EVP_MAC_CTX *dst; - if (src->data != NULL && !dst->meth->copy(dst->data, src->data)) - return 0; + if (src->data == NULL) + return NULL; + + dst = OPENSSL_malloc(sizeof(*dst)); + if (dst == NULL) { + EVPerr(EVP_F_EVP_MAC_CTX_DUP, ERR_R_MALLOC_FAILURE); + return NULL; + } - macdata = dst->data; *dst = *src; - dst->data = macdata; - return 1; + dst->data = src->meth->dup(src->data); + if (dst->data == NULL) { + EVP_MAC_CTX_free(dst); + return NULL; + } + + return dst; } const EVP_MAC *EVP_MAC_CTX_mac(EVP_MAC_CTX *ctx) diff --git a/crypto/evp/p5_crpt2.c b/crypto/evp/p5_crpt2.c index c231a32c..a7d4cafa 100644 --- a/crypto/evp/p5_crpt2.c +++ b/crypto/evp/p5_crpt2.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -40,6 +40,7 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, if (kctx == NULL) return 0; if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PASS, pass, (size_t)passlen) != 1 + || EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE, 1) != 1 || EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, salt, (size_t)saltlen) != 1 || EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_ITER, iter) != 1 diff --git a/crypto/evp/pkey_mac.c b/crypto/evp/pkey_mac.c index fc627f17..fafe3c96 100644 --- a/crypto/evp/pkey_mac.c +++ b/crypto/evp/pkey_mac.c @@ -10,6 +10,7 @@ #include #include #include "internal/evp_int.h" +#include "evp_locl.h" /* MAC PKEY context structure */ @@ -75,15 +76,25 @@ static int pkey_mac_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src) { MAC_PKEY_CTX *sctx, *dctx; - if (!pkey_mac_init(dst)) + sctx = EVP_PKEY_CTX_get_data(src); + if (sctx->ctx->data == NULL) return 0; - sctx = EVP_PKEY_CTX_get_data(src); - dctx = EVP_PKEY_CTX_get_data(dst); + dctx = OPENSSL_zalloc(sizeof(*dctx)); + if (dctx == NULL) { + EVPerr(EVP_F_PKEY_MAC_COPY, ERR_R_MALLOC_FAILURE); + return 0; + } - if (!EVP_MAC_CTX_copy(dctx->ctx, sctx->ctx)) + EVP_PKEY_CTX_set_data(dst, dctx); + dst->keygen_info_count = 0; + + dctx->ctx = EVP_MAC_CTX_dup(sctx->ctx); + if (dctx->ctx == NULL) goto err; + dctx->type = sctx->type; + switch (dctx->type) { case MAC_TYPE_RAW: dctx->raw_data.md = sctx->raw_data.md; @@ -100,7 +111,7 @@ static int pkey_mac_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src) } return 1; err: - pkey_mac_cleanup (dst); + pkey_mac_cleanup(dst); return 0; } @@ -141,14 +152,10 @@ static int pkey_mac_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) break; case MAC_TYPE_MAC: { - EVP_MAC_CTX *cmkey = EVP_MAC_CTX_new_id(nid); + EVP_MAC_CTX *cmkey = EVP_MAC_CTX_dup(hctx->ctx); if (cmkey == NULL) return 0; - if (!EVP_MAC_CTX_copy(cmkey, hctx->ctx)) { - EVP_MAC_CTX_free(cmkey); - return 0; - } EVP_PKEY_assign(pkey, nid, cmkey); } break; @@ -249,13 +256,18 @@ static int pkey_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) case MAC_TYPE_RAW: hctx->raw_data.md = p2; break; - case MAC_TYPE_MAC: - if (ctx->pkey != NULL - && !EVP_MAC_CTX_copy(hctx->ctx, - (EVP_MAC_CTX *)ctx->pkey->pkey.ptr)) - return 0; - if (!EVP_MAC_init(hctx->ctx)) - return 0; + case MAC_TYPE_MAC: { + EVP_MAC_CTX *new_mac_ctx; + + if (ctx->pkey == NULL) + return 0; + new_mac_ctx = EVP_MAC_CTX_dup((EVP_MAC_CTX *)ctx->pkey + ->pkey.ptr); + if (new_mac_ctx == NULL) + return 0; + EVP_MAC_CTX_free(hctx->ctx); + hctx->ctx = new_mac_ctx; + } break; default: /* This should be dead code */ diff --git a/crypto/ex_data.c b/crypto/ex_data.c index 055420a9..d7d0d5a7 100644 --- a/crypto/ex_data.c +++ b/crypto/ex_data.c @@ -36,7 +36,7 @@ static EX_CALLBACKS *get_and_lock(OPENSSL_CTX *ctx, int class_index) } global = openssl_ctx_get_ex_data_global(ctx); - if (global->ex_data_lock == NULL) { + if (global == NULL || global->ex_data_lock == NULL) { /* * This can happen in normal operation when using CRYPTO_mem_leaks(). * The CRYPTO_mem_leaks() function calls OPENSSL_cleanup() which cleans diff --git a/crypto/gmac/gmac.c b/crypto/gmac/gmac.c index 5e3891fb..0e2eda38 100644 --- a/crypto/gmac/gmac.c +++ b/crypto/gmac/gmac.c @@ -39,11 +39,23 @@ static EVP_MAC_IMPL *gmac_new(void) return gctx; } -static int gmac_copy(EVP_MAC_IMPL *gdst, EVP_MAC_IMPL *gsrc) +static EVP_MAC_IMPL *gmac_dup(const EVP_MAC_IMPL *gsrc) { + EVP_MAC_IMPL *gdst; + + gdst = gmac_new(); + if (gdst == NULL) + return NULL; + + if (!EVP_CIPHER_CTX_copy(gdst->ctx, gsrc->ctx)) { + gmac_free(gdst); + return NULL; + } + gdst->cipher = gsrc->cipher; gdst->engine = gsrc->engine; - return EVP_CIPHER_CTX_copy(gdst->ctx, gsrc->ctx); + + return gdst; } static size_t gmac_size(EVP_MAC_IMPL *gctx) @@ -172,7 +184,7 @@ static int gmac_ctrl_str(EVP_MAC_IMPL *gctx, const char *type, const EVP_MAC gmac_meth = { EVP_MAC_GMAC, gmac_new, - gmac_copy, + gmac_dup, gmac_free, gmac_size, gmac_init, diff --git a/crypto/hmac/build.info b/crypto/hmac/build.info index f63524d3..b1c14618 100644 --- a/crypto/hmac/build.info +++ b/crypto/hmac/build.info @@ -1,3 +1,6 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - hmac.c hm_ameth.c hm_meth.c + +$COMMON=hmac.c hm_meth.c + +SOURCE[../../libcrypto]=$COMMON hm_ameth.c +SOURCE[../../providers/fips]=$COMMON diff --git a/crypto/hmac/hm_meth.c b/crypto/hmac/hm_meth.c index 705bf7fd..19278ef6 100644 --- a/crypto/hmac/hm_meth.c +++ b/crypto/hmac/hm_meth.c @@ -45,14 +45,23 @@ static void hmac_free(EVP_MAC_IMPL *hctx) } } -static int hmac_copy(EVP_MAC_IMPL *hdst, EVP_MAC_IMPL *hsrc) +static EVP_MAC_IMPL *hmac_dup(const EVP_MAC_IMPL *hsrc) { - if (!HMAC_CTX_copy(hdst->ctx, hsrc->ctx)) - return 0; + EVP_MAC_IMPL *hdst; + + hdst = hmac_new(); + if (hdst == NULL) + return NULL; + + if (!HMAC_CTX_copy(hdst->ctx, hsrc->ctx)) { + hmac_free(hdst); + return NULL; + } hdst->tmpengine = hsrc->tmpengine; hdst->tmpmd = hsrc->tmpmd; - return 1; + + return hdst; } static size_t hmac_size(EVP_MAC_IMPL *hctx) @@ -143,6 +152,15 @@ static int hmac_ctrl_str(EVP_MAC_IMPL *hctx, const char *type, { if (!value) return 0; +#ifndef FIPS_MODE + /* + * We don't have EVP_get_digestbyname() in FIPS_MODE. That function returns + * an EVP_MD without an associated provider implementation (i.e. it is + * using "implicit fetch"). We could replace it with an "explicit" fetch + * using EVP_MD_fetch(), but we'd then be required to free the returned + * EVP_MD somewhere. Probably the complexity isn't worth it as we are + * unlikely to need this ctrl in FIPS_MODE anyway. + */ if (strcmp(type, "digest") == 0) { const EVP_MD *d = EVP_get_digestbyname(value); @@ -150,6 +168,7 @@ static int hmac_ctrl_str(EVP_MAC_IMPL *hctx, const char *type, return 0; return hmac_ctrl_int(hctx, EVP_MAC_CTRL_SET_MD, d); } +#endif if (strcmp(type, "key") == 0) return EVP_str2ctrl(hmac_ctrl_str_cb, hctx, EVP_MAC_CTRL_SET_KEY, value); @@ -162,7 +181,7 @@ static int hmac_ctrl_str(EVP_MAC_IMPL *hctx, const char *type, const EVP_MAC hmac_meth = { EVP_MAC_HMAC, hmac_new, - hmac_copy, + hmac_dup, hmac_free, hmac_size, hmac_init, diff --git a/crypto/include/internal/async.h b/crypto/include/internal/async.h index f5454f2e..e9a89da3 100644 --- a/crypto/include/internal/async.h +++ b/crypto/include/internal/async.h @@ -11,5 +11,4 @@ int async_init(void); void async_deinit(void); -void async_delete_thread_state(void); diff --git a/crypto/include/internal/cryptlib_int.h b/crypto/include/internal/cryptlib_int.h index 422ef01d..673a004f 100644 --- a/crypto/include/internal/cryptlib_int.h +++ b/crypto/include/internal/cryptlib_int.h @@ -7,17 +7,17 @@ * https://www.openssl.org/source/license.html */ +#include #include "internal/cryptlib.h" /* This file is not scanned by mkdef.pl, whereas cryptlib.h is */ -struct thread_local_inits_st { - int async; - int err_state; - int rand; -}; - -int ossl_init_thread_start(uint64_t opts); +int ossl_init_thread_start(const void *index, void *arg, + OSSL_thread_stop_handler_fn handfn); +int ossl_init_thread_deregister(void *index); +int ossl_init_thread(void); +void ossl_cleanup_thread(void); +void ossl_ctx_thread_stop(void *arg); /* * OPENSSL_INIT flags. The primary list of these is in crypto.h. Flags below @@ -27,11 +27,6 @@ int ossl_init_thread_start(uint64_t opts); # define OPENSSL_INIT_ZLIB 0x00010000L # define OPENSSL_INIT_BASE_ONLY 0x00040000L -/* OPENSSL_INIT_THREAD flags */ -# define OPENSSL_INIT_THREAD_ASYNC 0x01 -# define OPENSSL_INIT_THREAD_ERR_STATE 0x02 -# define OPENSSL_INIT_THREAD_RAND 0x04 - int ossl_trace_init(void); void ossl_trace_cleanup(void); void ossl_malloc_setup_failures(void); diff --git a/crypto/include/internal/err_int.h b/crypto/include/internal/err_int.h index a2006cad..68c6d62e 100644 --- a/crypto/include/internal/err_int.h +++ b/crypto/include/internal/err_int.h @@ -12,7 +12,6 @@ int err_load_crypto_strings_int(void); void err_cleanup(void); -void err_delete_thread_state(void); int err_shelve_state(void **); void err_unshelve_state(void *); diff --git a/crypto/include/internal/evp_int.h b/crypto/include/internal/evp_int.h index 43932a41..da4ae0f1 100644 --- a/crypto/include/internal/evp_int.h +++ b/crypto/include/internal/evp_int.h @@ -118,7 +118,7 @@ typedef struct evp_mac_impl_st EVP_MAC_IMPL; struct evp_mac_st { int type; EVP_MAC_IMPL *(*new) (void); - int (*copy) (EVP_MAC_IMPL *macdst, EVP_MAC_IMPL *macsrc); + EVP_MAC_IMPL *(*dup) (const EVP_MAC_IMPL *macsrc); void (*free) (EVP_MAC_IMPL *macctx); size_t (*size) (EVP_MAC_IMPL *macctx); int (*init) (EVP_MAC_IMPL *macctx); @@ -173,6 +173,7 @@ extern const EVP_KDF hkdf_kdf_meth; extern const EVP_KDF sshkdf_kdf_meth; extern const EVP_KDF ss_kdf_meth; extern const EVP_KDF x963_kdf_meth; +extern const EVP_KDF x942_kdf_meth; struct evp_md_st { /* nid */ @@ -207,6 +208,8 @@ struct evp_md_st { OSSL_OP_digest_dupctx_fn *dupctx; OSSL_OP_digest_size_fn *size; OSSL_OP_digest_block_size_fn *dblock_size; + OSSL_OP_digest_set_params_fn *set_params; + OSSL_OP_digest_get_params_fn *get_params; } /* EVP_MD */ ; @@ -254,9 +257,6 @@ struct evp_cipher_st { OSSL_OP_cipher_cipher_fn *ccipher; OSSL_OP_cipher_freectx_fn *freectx; OSSL_OP_cipher_dupctx_fn *dupctx; - OSSL_OP_cipher_key_length_fn *key_length; - OSSL_OP_cipher_iv_length_fn *iv_length; - OSSL_OP_cipher_block_size_fn *blocksize; OSSL_OP_cipher_get_params_fn *get_params; OSSL_OP_cipher_ctx_get_params_fn *ctx_get_params; OSSL_OP_cipher_ctx_set_params_fn *ctx_set_params; diff --git a/crypto/include/internal/modes_int.h b/crypto/include/internal/modes_int.h new file mode 100644 index 00000000..8a8ef6e1 --- /dev/null +++ b/crypto/include/internal/modes_int.h @@ -0,0 +1,34 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OPENSSL_NO_SIV + +typedef struct siv128_context SIV128_CONTEXT; + +SIV128_CONTEXT *CRYPTO_siv128_new(const unsigned char *key, int klen, + EVP_CIPHER* cbc, EVP_CIPHER* ctr); +int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen, + const EVP_CIPHER* cbc, const EVP_CIPHER* ctr); +int CRYPTO_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src); +int CRYPTO_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad, + size_t len); +int CRYPTO_siv128_encrypt(SIV128_CONTEXT *ctx, + const unsigned char *in, unsigned char *out, + size_t len); +int CRYPTO_siv128_decrypt(SIV128_CONTEXT *ctx, + const unsigned char *in, unsigned char *out, + size_t len); +int CRYPTO_siv128_finish(SIV128_CONTEXT *ctx); +int CRYPTO_siv128_set_tag(SIV128_CONTEXT *ctx, const unsigned char *tag, + size_t len); +int CRYPTO_siv128_get_tag(SIV128_CONTEXT *ctx, unsigned char *tag, size_t len); +int CRYPTO_siv128_cleanup(SIV128_CONTEXT *ctx); +int CRYPTO_siv128_speed(SIV128_CONTEXT *ctx, int arg); + +#endif /* OPENSSL_NO_SIV */ diff --git a/crypto/include/internal/rand_int.h b/crypto/include/internal/rand_int.h index b7453934..d964a1d4 100644 --- a/crypto/include/internal/rand_int.h +++ b/crypto/include/internal/rand_int.h @@ -24,8 +24,6 @@ typedef struct rand_pool_st RAND_POOL; void rand_cleanup_int(void); -void rand_drbg_cleanup_int(void); -void drbg_delete_thread_state(void); void rand_fork(void); /* Hardware-based seeding functions. */ @@ -139,4 +137,10 @@ void rand_pool_cleanup(void); */ void rand_pool_keep_random_devices_open(int keep); +/* Equivalent of RAND_priv_bytes() but additionally taking an OPENSSL_CTX */ +int rand_priv_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num); + +/* Equivalent of RAND_bytes() but additionally taking an OPENSSL_CTX */ +int rand_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num); + #endif diff --git a/crypto/include/internal/sha.h b/crypto/include/internal/sha.h index 3b5ac032..38632615 100644 --- a/crypto/include/internal/sha.h +++ b/crypto/include/internal/sha.h @@ -15,5 +15,6 @@ int sha512_224_init(SHA512_CTX *); int sha512_256_init(SHA512_CTX *); +int sha1_ctrl(SHA_CTX *ctx, int cmd, int mslen, void *ms); #endif diff --git a/crypto/include/internal/sparse_array.h b/crypto/include/internal/sparse_array.h index ec3fb2f9..037ccfee 100644 --- a/crypto/include/internal/sparse_array.h +++ b/crypto/include/internal/sparse_array.h @@ -19,7 +19,7 @@ extern "C" { # define SPARSE_ARRAY_OF(type) struct sparse_array_st_ ## type -# define DEFINE_SPARSE_ARRAY_OF(type) \ +# define DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, ctype) \ SPARSE_ARRAY_OF(type); \ static ossl_unused ossl_inline SPARSE_ARRAY_OF(type) * \ ossl_sa_##type##_new(void) \ @@ -53,18 +53,23 @@ extern "C" { void *))leaf, \ arg); \ } \ - static ossl_unused ossl_inline type *ossl_sa_##type##_get(const SPARSE_ARRAY_OF(type) *sa, \ + static ossl_unused ossl_inline ctype *ossl_sa_##type##_get(const SPARSE_ARRAY_OF(type) *sa, \ ossl_uintmax_t n) \ { \ return (type *)OPENSSL_SA_get((OPENSSL_SA *)sa, n); \ } \ static ossl_unused ossl_inline int ossl_sa_##type##_set(SPARSE_ARRAY_OF(type) *sa, \ - ossl_uintmax_t n, type *val) \ + ossl_uintmax_t n, ctype *val) \ { \ return OPENSSL_SA_set((OPENSSL_SA *)sa, n, (void *)val); \ } \ SPARSE_ARRAY_OF(type) +# define DEFINE_SPARSE_ARRAY_OF(type) \ + DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, type) +# define DEFINE_SPARSE_ARRAY_OF_CONST(type) \ + DEFINE_SPARSE_ARRAY_OF_INTERNAL(type, const type) + typedef struct sparse_array_st OPENSSL_SA; OPENSSL_SA *OPENSSL_SA_new(void); void OPENSSL_SA_free(OPENSSL_SA *sa); diff --git a/crypto/include/internal/x509_int.h b/crypto/include/internal/x509_int.h index 7c40b159..f6897e14 100644 --- a/crypto/include/internal/x509_int.h +++ b/crypto/include/internal/x509_int.h @@ -71,6 +71,9 @@ struct X509_req_st { ASN1_BIT_STRING *signature; /* signature */ CRYPTO_REF_COUNT references; CRYPTO_RWLOCK *lock; +# ifndef OPENSSL_NO_SM2 + ASN1_OCTET_STRING *sm2_id; +# endif }; struct X509_crl_info_st { diff --git a/crypto/init.c b/crypto/init.c index 58fff701..d5f0ebd7 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -31,51 +31,6 @@ static int stopped = 0; -/* - * Since per-thread-specific-data destructors are not universally - * available, i.e. not on Windows, only below CRYPTO_THREAD_LOCAL key - * is assumed to have destructor associated. And then an effort is made - * to call this single destructor on non-pthread platform[s]. - * - * Initial value is "impossible". It is used as guard value to shortcut - * destructor for threads terminating before libcrypto is initialized or - * after it's de-initialized. Access to the key doesn't have to be - * serialized for the said threads, because they didn't use libcrypto - * and it doesn't matter if they pick "impossible" or derefernce real - * key value and pull NULL past initialization in the first thread that - * intends to use libcrypto. - */ -static union { - long sane; - CRYPTO_THREAD_LOCAL value; -} destructor_key = { -1 }; - -static void ossl_init_thread_stop(struct thread_local_inits_st *locals); - -static void ossl_init_thread_destructor(void *local) -{ - ossl_init_thread_stop((struct thread_local_inits_st *)local); -} - -static struct thread_local_inits_st *ossl_init_get_thread_local(int alloc) -{ - struct thread_local_inits_st *local = - CRYPTO_THREAD_get_local(&destructor_key.value); - - if (alloc) { - if (local == NULL - && (local = OPENSSL_zalloc(sizeof(*local))) != NULL - && !CRYPTO_THREAD_set_local(&destructor_key.value, local)) { - OPENSSL_free(local); - return NULL; - } - } else { - CRYPTO_THREAD_set_local(&destructor_key.value, NULL); - } - - return local; -} - typedef struct ossl_init_stop_st OPENSSL_INIT_STOP; struct ossl_init_stop_st { void (*handler)(void); @@ -89,8 +44,6 @@ static CRYPTO_ONCE base = CRYPTO_ONCE_STATIC_INIT; static int base_inited = 0; DEFINE_RUN_ONCE_STATIC(ossl_init_base) { - CRYPTO_THREAD_LOCAL key; - if (ossl_trace_init() == 0) return 0; @@ -98,13 +51,14 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_base) #ifndef OPENSSL_NO_CRYPTO_MDEBUG ossl_malloc_setup_failures(); #endif - if (!CRYPTO_THREAD_init_local(&key, ossl_init_thread_destructor)) - return 0; + if ((init_lock = CRYPTO_THREAD_lock_new()) == NULL) goto err; OPENSSL_cpuid_setup(); - destructor_key.value = key; + if (!ossl_init_thread()) + return 0; + base_inited = 1; return 1; @@ -113,7 +67,6 @@ err: CRYPTO_THREAD_lock_free(init_lock); init_lock = NULL; - CRYPTO_THREAD_cleanup_local(&key); return 0; } @@ -417,76 +370,9 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_zlib) } #endif -static void ossl_init_thread_stop(struct thread_local_inits_st *locals) -{ - /* Can't do much about this */ - if (locals == NULL) - return; - - if (locals->async) { - OSSL_TRACE(INIT, "async_delete_thread_state()\n"); - async_delete_thread_state(); - } - - if (locals->err_state) { - OSSL_TRACE(INIT, "err_delete_thread_state()\n"); - err_delete_thread_state(); - } - - if (locals->rand) { - OSSL_TRACE(INIT, "drbg_delete_thread_state()\n"); - drbg_delete_thread_state(); - } - - OPENSSL_free(locals); -} - -void OPENSSL_thread_stop(void) -{ - if (destructor_key.sane != -1) - ossl_init_thread_stop(ossl_init_get_thread_local(0)); -} - -int ossl_init_thread_start(uint64_t opts) -{ - struct thread_local_inits_st *locals; - - if (!OPENSSL_init_crypto(0, NULL)) - return 0; - - locals = ossl_init_get_thread_local(1); - - if (locals == NULL) - return 0; - - if (opts & OPENSSL_INIT_THREAD_ASYNC) { - OSSL_TRACE(INIT, - "ossl_init_thread_start: " - "marking thread for async\n"); - locals->async = 1; - } - - if (opts & OPENSSL_INIT_THREAD_ERR_STATE) { - OSSL_TRACE(INIT, - "ossl_init_thread_start: " - "marking thread for err_state\n"); - locals->err_state = 1; - } - - if (opts & OPENSSL_INIT_THREAD_RAND) { - OSSL_TRACE(INIT, - "ossl_init_thread_start: " - "marking thread for rand\n"); - locals->rand = 1; - } - - return 1; -} - void OPENSSL_cleanup(void) { OPENSSL_INIT_STOP *currhandler, *lasthandler; - CRYPTO_THREAD_LOCAL key; /* * TODO(3.0): This function needs looking at with a view to moving most/all @@ -506,7 +392,7 @@ void OPENSSL_cleanup(void) * Thread stop may not get automatically called by the thread library for * the very last thread in some situations, so call it directly. */ - ossl_init_thread_stop(ossl_init_get_thread_local(0)); + OPENSSL_thread_stop(); currhandler = stop_handlers; while (currhandler != NULL) { @@ -542,10 +428,6 @@ void OPENSSL_cleanup(void) err_free_strings_int(); } - key = destructor_key.value; - destructor_key.sane = -1; - CRYPTO_THREAD_cleanup_local(&key); - /* * Note that cleanup order is important: * - rand_cleanup_int could call an ENGINE's RAND cleanup function so @@ -560,9 +442,6 @@ void OPENSSL_cleanup(void) OSSL_TRACE(INIT, "OPENSSL_cleanup: rand_cleanup_int()\n"); rand_cleanup_int(); - OSSL_TRACE(INIT, "OPENSSL_cleanup: rand_drbg_cleanup_int()\n"); - rand_drbg_cleanup_int(); - OSSL_TRACE(INIT, "OPENSSL_cleanup: conf_modules_free_int()\n"); conf_modules_free_int(); @@ -576,6 +455,8 @@ void OPENSSL_cleanup(void) OSSL_TRACE(INIT, "OPENSSL_cleanup: openssl_ctx_default_deinit()\n"); openssl_ctx_default_deinit(); + ossl_cleanup_thread(); + OSSL_TRACE(INIT, "OPENSSL_cleanup: bio_cleanup()\n"); bio_cleanup(); @@ -855,5 +736,6 @@ void OPENSSL_fork_parent(void) void OPENSSL_fork_child(void) { rand_fork(); + /* TODO(3.0): Inform all providers about a fork event */ } #endif diff --git a/crypto/initthread.c b/crypto/initthread.c new file mode 100644 index 00000000..99cd96ce --- /dev/null +++ b/crypto/initthread.c @@ -0,0 +1,414 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include +#include "internal/cryptlib_int.h" +#include "internal/providercommon.h" +#include "internal/thread_once.h" + +#ifdef FIPS_MODE +/* + * Thread aware code may want to be told about thread stop events. We register + * to hear about those thread stop events when we see a new thread has started. + * We call the ossl_init_thread_start function to do that. In the FIPS provider + * we have our own copy of ossl_init_thread_start, which cascades notifications + * about threads stopping from libcrypto to all the code in the FIPS provider + * that needs to know about it. + * + * The FIPS provider tells libcrypto about which threads it is interested in + * by calling "c_thread_start" which is a function pointer created during + * provider initialisation (i.e. OSSL_init_provider). + */ +extern OSSL_core_thread_start_fn *c_thread_start; +#endif + +typedef struct thread_event_handler_st THREAD_EVENT_HANDLER; +struct thread_event_handler_st { + const void *index; + void *arg; + OSSL_thread_stop_handler_fn handfn; + THREAD_EVENT_HANDLER *next; +}; + +#ifndef FIPS_MODE +DEFINE_SPECIAL_STACK_OF(THREAD_EVENT_HANDLER_PTR, THREAD_EVENT_HANDLER *) + +typedef struct global_tevent_register_st GLOBAL_TEVENT_REGISTER; +struct global_tevent_register_st { + STACK_OF(THREAD_EVENT_HANDLER_PTR) *skhands; + CRYPTO_RWLOCK *lock; +}; + +static GLOBAL_TEVENT_REGISTER *glob_tevent_reg = NULL; + +static CRYPTO_ONCE tevent_register_runonce = CRYPTO_ONCE_STATIC_INIT; + +DEFINE_RUN_ONCE_STATIC(create_global_tevent_register) +{ + glob_tevent_reg = OPENSSL_zalloc(sizeof(*glob_tevent_reg)); + if (glob_tevent_reg == NULL) + return 0; + + glob_tevent_reg->skhands = sk_THREAD_EVENT_HANDLER_PTR_new_null(); + glob_tevent_reg->lock = CRYPTO_THREAD_lock_new(); + if (glob_tevent_reg->skhands == NULL || glob_tevent_reg->lock == NULL) { + sk_THREAD_EVENT_HANDLER_PTR_free(glob_tevent_reg->skhands); + CRYPTO_THREAD_lock_free(glob_tevent_reg->lock); + OPENSSL_free(glob_tevent_reg); + glob_tevent_reg = NULL; + return 0; + } + + return 1; +} + +static GLOBAL_TEVENT_REGISTER *get_global_tevent_register(void) +{ + if (!RUN_ONCE(&tevent_register_runonce, create_global_tevent_register)) + return NULL; + return glob_tevent_reg; +} +#endif + +static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands); + +static THREAD_EVENT_HANDLER ** +init_get_thread_local(CRYPTO_THREAD_LOCAL *local, int alloc, int keep) +{ + THREAD_EVENT_HANDLER **hands = CRYPTO_THREAD_get_local(local); + + if (alloc) { + if (hands == NULL) { +#ifndef FIPS_MODE + GLOBAL_TEVENT_REGISTER *gtr; +#endif + + if ((hands = OPENSSL_zalloc(sizeof(*hands))) == NULL) { + OPENSSL_free(hands); + return NULL; + } + +#ifndef FIPS_MODE + /* + * The thread event handler is thread specific and is a linked + * list of all handler functions that should be called for the + * current thread. We also keep a global reference to that linked + * list, so that we can deregister handlers if necessary before all + * the threads are stopped. + */ + gtr = get_global_tevent_register(); + if (gtr == NULL) { + OPENSSL_free(hands); + return NULL; + } + CRYPTO_THREAD_write_lock(gtr->lock); + if (!sk_THREAD_EVENT_HANDLER_PTR_push(gtr->skhands, hands)) { + OPENSSL_free(hands); + CRYPTO_THREAD_unlock(gtr->lock); + return NULL; + } + CRYPTO_THREAD_unlock(gtr->lock); +#endif + if (!CRYPTO_THREAD_set_local(local, hands)) { + OPENSSL_free(hands); + return NULL; + } + } + } else if (!keep) { + CRYPTO_THREAD_set_local(local, NULL); + } + + return hands; +} + +#ifndef FIPS_MODE +/* + * Since per-thread-specific-data destructors are not universally + * available, i.e. not on Windows, only below CRYPTO_THREAD_LOCAL key + * is assumed to have destructor associated. And then an effort is made + * to call this single destructor on non-pthread platform[s]. + * + * Initial value is "impossible". It is used as guard value to shortcut + * destructor for threads terminating before libcrypto is initialized or + * after it's de-initialized. Access to the key doesn't have to be + * serialized for the said threads, because they didn't use libcrypto + * and it doesn't matter if they pick "impossible" or dereference real + * key value and pull NULL past initialization in the first thread that + * intends to use libcrypto. + */ +static union { + long sane; + CRYPTO_THREAD_LOCAL value; +} destructor_key = { -1 }; + +static void init_thread_remove_handlers(THREAD_EVENT_HANDLER **handsin) +{ + GLOBAL_TEVENT_REGISTER *gtr; + int i; + + gtr = get_global_tevent_register(); + if (gtr == NULL) + return; + CRYPTO_THREAD_write_lock(gtr->lock); + for (i = 0; i < sk_THREAD_EVENT_HANDLER_PTR_num(gtr->skhands); i++) { + THREAD_EVENT_HANDLER **hands + = sk_THREAD_EVENT_HANDLER_PTR_value(gtr->skhands, i); + + if (hands == handsin) { + hands = sk_THREAD_EVENT_HANDLER_PTR_delete(gtr->skhands, i); + CRYPTO_THREAD_unlock(gtr->lock); + return; + } + } + CRYPTO_THREAD_unlock(gtr->lock); + return; +} + +static void init_thread_destructor(void *hands) +{ + init_thread_stop(NULL, (THREAD_EVENT_HANDLER **)hands); + init_thread_remove_handlers(hands); + OPENSSL_free(hands); +} + +int ossl_init_thread(void) +{ + if (!CRYPTO_THREAD_init_local(&destructor_key.value, + init_thread_destructor)) + return 0; + + return 1; +} + +static int init_thread_deregister(void *arg, int all); + +void ossl_cleanup_thread(void) +{ + init_thread_deregister(NULL, 1); + CRYPTO_THREAD_cleanup_local(&destructor_key.value); + destructor_key.sane = -1; +} + +void OPENSSL_thread_stop_ex(OPENSSL_CTX *ctx) +{ + ctx = openssl_ctx_get_concrete(ctx); + /* + * TODO(3.0). It would be nice if we could figure out a way to do this on + * all threads that have used the OPENSSL_CTX when the OPENSSL_CTX is freed. + * This is currently not possible due to the use of thread local variables. + */ + ossl_ctx_thread_stop(ctx); +} + +void OPENSSL_thread_stop(void) +{ + if (destructor_key.sane != -1) { + THREAD_EVENT_HANDLER **hands + = init_get_thread_local(&destructor_key.value, 0, 0); + init_thread_stop(NULL, hands); + + init_thread_remove_handlers(hands); + OPENSSL_free(hands); + } +} + +void ossl_ctx_thread_stop(void *arg) +{ + if (destructor_key.sane != -1) { + THREAD_EVENT_HANDLER **hands + = init_get_thread_local(&destructor_key.value, 0, 1); + init_thread_stop(arg, hands); + } +} + +#else + +static void *thread_event_ossl_ctx_new(OPENSSL_CTX *libctx) +{ + THREAD_EVENT_HANDLER **hands = NULL; + CRYPTO_THREAD_LOCAL *tlocal = OPENSSL_zalloc(sizeof(*tlocal)); + + if (tlocal == NULL) + return NULL; + + if (!CRYPTO_THREAD_init_local(tlocal, NULL)) { + goto err; + } + + hands = OPENSSL_zalloc(sizeof(*hands)); + if (hands == NULL) + goto err; + + if (!CRYPTO_THREAD_set_local(tlocal, hands)) + goto err; + + return tlocal; + err: + OPENSSL_free(hands); + OPENSSL_free(tlocal); + return NULL; +} + +static void thread_event_ossl_ctx_free(void *tlocal) +{ + OPENSSL_free(tlocal); +} + +static const OPENSSL_CTX_METHOD thread_event_ossl_ctx_method = { + thread_event_ossl_ctx_new, + thread_event_ossl_ctx_free, +}; + +void ossl_ctx_thread_stop(void *arg) +{ + THREAD_EVENT_HANDLER **hands; + OPENSSL_CTX *ctx = arg; + CRYPTO_THREAD_LOCAL *local + = openssl_ctx_get_data(ctx, OPENSSL_CTX_THREAD_EVENT_HANDLER_INDEX, + &thread_event_ossl_ctx_method); + + if (local == NULL) + return; + hands = init_get_thread_local(local, 0, 0); + init_thread_stop(arg, hands); + OPENSSL_free(hands); +} +#endif /* FIPS_MODE */ + + +static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands) +{ + THREAD_EVENT_HANDLER *curr, *prev = NULL; + + /* Can't do much about this */ + if (hands == NULL) + return; + + curr = *hands; + while (curr != NULL) { + if (arg != NULL && curr->arg != arg) { + curr = curr->next; + continue; + } + curr->handfn(curr->arg); + prev = curr; + curr = curr->next; + if (prev == *hands) + *hands = curr; + OPENSSL_free(prev); + } +} + +int ossl_init_thread_start(const void *index, void *arg, + OSSL_thread_stop_handler_fn handfn) +{ + THREAD_EVENT_HANDLER **hands; + THREAD_EVENT_HANDLER *hand; +#ifdef FIPS_MODE + OPENSSL_CTX *ctx = arg; + + /* + * In FIPS mode the list of THREAD_EVENT_HANDLERs is unique per combination + * of OPENSSL_CTX and thread. This is because in FIPS mode each OPENSSL_CTX + * gets informed about thread stop events individually. + */ + CRYPTO_THREAD_LOCAL *local + = openssl_ctx_get_data(ctx, OPENSSL_CTX_THREAD_EVENT_HANDLER_INDEX, + &thread_event_ossl_ctx_method); +#else + /* + * Outside of FIPS mode the list of THREAD_EVENT_HANDLERs is unique per + * thread, but may hold multiple OPENSSL_CTXs. We only get told about + * thread stop events globally, so we have to ensure all affected + * OPENSSL_CTXs are informed. + */ + CRYPTO_THREAD_LOCAL *local = &destructor_key.value; +#endif + + hands = init_get_thread_local(local, 1, 0); + if (hands == NULL) + return 0; + +#ifdef FIPS_MODE + if (*hands == NULL) { + /* + * We've not yet registered any handlers for this thread. We need to get + * libcrypto to tell us about later thread stop events. c_thread_start + * is a callback to libcrypto defined in fipsprov.c + */ + if (!c_thread_start(FIPS_get_provider(ctx), ossl_ctx_thread_stop)) + return 0; + } +#endif + + hand = OPENSSL_malloc(sizeof(*hand)); + if (hand == NULL) + return 0; + + hand->handfn = handfn; + hand->arg = arg; + hand->index = index; + hand->next = *hands; + *hands = hand; + + return 1; +} + +#ifndef FIPS_MODE +static int init_thread_deregister(void *index, int all) +{ + GLOBAL_TEVENT_REGISTER *gtr; + int i; + + gtr = get_global_tevent_register(); + if (!all) + CRYPTO_THREAD_write_lock(gtr->lock); + for (i = 0; i < sk_THREAD_EVENT_HANDLER_PTR_num(gtr->skhands); i++) { + THREAD_EVENT_HANDLER **hands + = sk_THREAD_EVENT_HANDLER_PTR_value(gtr->skhands, i); + THREAD_EVENT_HANDLER *curr = *hands, *prev = NULL, *tmp; + + if (hands == NULL) { + if (!all) + CRYPTO_THREAD_unlock(gtr->lock); + return 0; + } + while (curr != NULL) { + if (all || curr->index == index) { + if (prev != NULL) + prev->next = curr->next; + else + *hands = curr->next; + tmp = curr; + curr = curr->next; + OPENSSL_free(tmp); + continue; + } + prev = curr; + curr = curr->next; + } + if (all) + OPENSSL_free(hands); + } + if (all) { + CRYPTO_THREAD_lock_free(gtr->lock); + sk_THREAD_EVENT_HANDLER_PTR_free(gtr->skhands); + OPENSSL_free(gtr); + } else { + CRYPTO_THREAD_unlock(gtr->lock); + } + return 1; +} + +int ossl_init_thread_deregister(void *index) +{ + return init_thread_deregister(index, 0); +} +#endif diff --git a/crypto/kdf/build.info b/crypto/kdf/build.info index 52e40a4f..4fdaccdd 100644 --- a/crypto/kdf/build.info +++ b/crypto/kdf/build.info @@ -1,4 +1,4 @@ LIBS=../../libcrypto SOURCE[../../libcrypto]=\ tls1_prf.c kdf_err.c kdf_util.c hkdf.c scrypt.c pbkdf2.c sshkdf.c \ - sskdf.c + sskdf.c x942kdf.c diff --git a/crypto/kdf/kdf_err.c b/crypto/kdf/kdf_err.c index 49028ab3..1b6e7845 100644 --- a/crypto/kdf/kdf_err.c +++ b/crypto/kdf/kdf_err.c @@ -19,6 +19,7 @@ static const ERR_STRING_DATA KDF_str_functs[] = { {ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_HKDF_NEW, 0), "kdf_hkdf_new"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_HKDF_SIZE, 0), "kdf_hkdf_size"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_MD2CTRL, 0), "kdf_md2ctrl"}, + {ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_PBKDF2_CTRL, 0), "kdf_pbkdf2_ctrl"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_PBKDF2_CTRL_STR, 0), "kdf_pbkdf2_ctrl_str"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_PBKDF2_DERIVE, 0), "kdf_pbkdf2_derive"}, @@ -41,6 +42,7 @@ static const ERR_STRING_DATA KDF_str_functs[] = { {ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_TLS1_PRF_DERIVE, 0), "kdf_tls1_prf_derive"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_TLS1_PRF_NEW, 0), "kdf_tls1_prf_new"}, + {ERR_PACK(ERR_LIB_KDF, KDF_F_PBKDF2_DERIVE, 0), "pbkdf2_derive"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_PBKDF2_SET_MEMBUF, 0), "pbkdf2_set_membuf"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_HKDF_CTRL_STR, 0), "pkey_hkdf_ctrl_str"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_HKDF_DERIVE, 0), "pkey_hkdf_derive"}, @@ -65,13 +67,26 @@ static const ERR_STRING_DATA KDF_str_functs[] = { {ERR_PACK(ERR_LIB_KDF, KDF_F_SSKDF_NEW, 0), "sskdf_new"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_SSKDF_SIZE, 0), "sskdf_size"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_TLS1_PRF_ALG, 0), "tls1_prf_alg"}, + {ERR_PACK(ERR_LIB_KDF, KDF_F_X942KDF_CTRL, 0), "x942kdf_ctrl"}, + {ERR_PACK(ERR_LIB_KDF, KDF_F_X942KDF_DERIVE, 0), "x942kdf_derive"}, + {ERR_PACK(ERR_LIB_KDF, KDF_F_X942KDF_HASH_KDM, 0), "x942kdf_hash_kdm"}, + {ERR_PACK(ERR_LIB_KDF, KDF_F_X942KDF_NEW, 0), "x942kdf_new"}, + {ERR_PACK(ERR_LIB_KDF, KDF_F_X942KDF_SIZE, 0), "x942kdf_size"}, {ERR_PACK(ERR_LIB_KDF, KDF_F_X963KDF_DERIVE, 0), "x963kdf_derive"}, {0, NULL} }; static const ERR_STRING_DATA KDF_str_reasons[] = { + {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_BAD_ENCODING), "bad encoding"}, + {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_BAD_LENGTH), "bad length"}, + {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_INAVLID_UKM_LEN), "inavlid ukm len"}, {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_INVALID_DIGEST), "invalid digest"}, + {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_INVALID_ITERATION_COUNT), + "invalid iteration count"}, + {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_INVALID_KEY_LEN), "invalid key len"}, {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_INVALID_MAC_TYPE), "invalid mac type"}, + {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_INVALID_SALT_LEN), "invalid salt len"}, + {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_CEK_ALG), "missing cek alg"}, {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_ITERATION_COUNT), "missing iteration count"}, {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_KEY), "missing key"}, @@ -88,6 +103,8 @@ static const ERR_STRING_DATA KDF_str_reasons[] = { {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_NOT_SUPPORTED), "not supported"}, {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_UNKNOWN_PARAMETER_TYPE), "unknown parameter type"}, + {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_UNSUPPORTED_CEK_ALG), + "unsupported cek alg"}, {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_UNSUPPORTED_MAC_TYPE), "unsupported mac type"}, {ERR_PACK(ERR_LIB_KDF, 0, KDF_R_VALUE_ERROR), "value error"}, diff --git a/crypto/kdf/pbkdf2.c b/crypto/kdf/pbkdf2.c index 7009dfde..d4168977 100644 --- a/crypto/kdf/pbkdf2.c +++ b/crypto/kdf/pbkdf2.c @@ -1,5 +1,5 @@ /* - * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -17,12 +17,27 @@ #include "internal/evp_int.h" #include "kdf_local.h" +/* Constants specified in SP800-132 */ +#define KDF_PBKDF2_MIN_KEY_LEN_BITS 112 +#define KDF_PBKDF2_MAX_KEY_LEN_DIGEST_RATIO 0xFFFFFFFF +#define KDF_PBKDF2_MIN_ITERATIONS 1000 +#define KDF_PBKDF2_MIN_SALT_LEN (128 / 8) +/* + * For backwards compatibility reasons, + * Extra checks are done by default in fips mode only. + */ +#ifdef FIPS_MODE +# define KDF_PBKDF2_DEFAULT_CHECKS 1 +#else +# define KDF_PBKDF2_DEFAULT_CHECKS 0 +#endif /* FIPS_MODE */ + static void kdf_pbkdf2_reset(EVP_KDF_IMPL *impl); static void kdf_pbkdf2_init(EVP_KDF_IMPL *impl); -static int pkcs5_pbkdf2_alg(const char *pass, size_t passlen, - const unsigned char *salt, int saltlen, int iter, - const EVP_MD *digest, unsigned char *key, - size_t keylen); +static int pbkdf2_derive(const char *pass, size_t passlen, + const unsigned char *salt, int saltlen, int iter, + const EVP_MD *digest, unsigned char *key, + size_t keylen, int extra_checks); struct evp_kdf_impl_st { unsigned char *pass; @@ -31,6 +46,7 @@ struct evp_kdf_impl_st { size_t salt_len; int iter; const EVP_MD *md; + int lower_bound_checks; }; static EVP_KDF_IMPL *kdf_pbkdf2_new(void) @@ -64,6 +80,7 @@ static void kdf_pbkdf2_init(EVP_KDF_IMPL *impl) { impl->iter = PKCS5_DEFAULT_ITER; impl->md = EVP_sha1(); + impl->lower_bound_checks = KDF_PBKDF2_DEFAULT_CHECKS; } static int pbkdf2_set_membuf(unsigned char **buffer, size_t *buflen, @@ -91,12 +108,16 @@ static int pbkdf2_set_membuf(unsigned char **buffer, size_t *buflen, static int kdf_pbkdf2_ctrl(EVP_KDF_IMPL *impl, int cmd, va_list args) { - int iter; + int iter, pkcs5, min_iter; const unsigned char *p; size_t len; const EVP_MD *md; switch (cmd) { + case EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE: + pkcs5 = va_arg(args, int); + impl->lower_bound_checks = (pkcs5 == 0) ? 1 : 0; + return 1; case EVP_KDF_CTRL_SET_PASS: p = va_arg(args, const unsigned char *); len = va_arg(args, size_t); @@ -105,20 +126,28 @@ static int kdf_pbkdf2_ctrl(EVP_KDF_IMPL *impl, int cmd, va_list args) case EVP_KDF_CTRL_SET_SALT: p = va_arg(args, const unsigned char *); len = va_arg(args, size_t); + if (impl->lower_bound_checks != 0 && len < KDF_PBKDF2_MIN_SALT_LEN) { + KDFerr(KDF_F_KDF_PBKDF2_CTRL, KDF_R_INVALID_SALT_LEN); + return 0; + } return pbkdf2_set_membuf(&impl->salt, &impl->salt_len, p, len); case EVP_KDF_CTRL_SET_ITER: iter = va_arg(args, int); - if (iter < 1) + min_iter = impl->lower_bound_checks != 0 ? KDF_PBKDF2_MIN_ITERATIONS : 1; + if (iter < min_iter) { + KDFerr(KDF_F_KDF_PBKDF2_CTRL, KDF_R_INVALID_ITERATION_COUNT); return 0; - + } impl->iter = iter; return 1; case EVP_KDF_CTRL_SET_MD: md = va_arg(args, const EVP_MD *); - if (md == NULL) + if (md == NULL) { + KDFerr(KDF_F_KDF_PBKDF2_CTRL, KDF_R_VALUE_MISSING); return 0; + } impl->md = md; return 1; @@ -159,6 +188,9 @@ static int kdf_pbkdf2_ctrl_str(EVP_KDF_IMPL *impl, const char *type, if (strcmp(type, "digest") == 0) return kdf_md2ctrl(impl, kdf_pbkdf2_ctrl, EVP_KDF_CTRL_SET_MD, value); + if (strcmp(type, "pkcs5") == 0) + return kdf_str2ctrl(impl, kdf_pbkdf2_ctrl, + EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE, value); return -2; } @@ -175,9 +207,9 @@ static int kdf_pbkdf2_derive(EVP_KDF_IMPL *impl, unsigned char *key, return 0; } - return pkcs5_pbkdf2_alg((char *)impl->pass, impl->pass_len, - impl->salt, impl->salt_len, impl->iter, - impl->md, key, keylen); + return pbkdf2_derive((char *)impl->pass, impl->pass_len, + impl->salt, impl->salt_len, impl->iter, + impl->md, key, keylen, impl->lower_bound_checks); } const EVP_KDF pbkdf2_kdf_meth = { @@ -195,12 +227,16 @@ const EVP_KDF pbkdf2_kdf_meth = { * This is an implementation of PKCS#5 v2.0 password based encryption key * derivation function PBKDF2. SHA1 version verified against test vectors * posted by Peter Gutmann to the PKCS-TNG mailing list. + * + * The constraints specified by SP800-132 have been added i.e. + * - Check the range of the key length. + * - Minimum iteration count of 1000. + * - Randomly-generated portion of the salt shall be at least 128 bits. */ - -static int pkcs5_pbkdf2_alg(const char *pass, size_t passlen, - const unsigned char *salt, int saltlen, int iter, - const EVP_MD *digest, unsigned char *key, - size_t keylen) +static int pbkdf2_derive(const char *pass, size_t passlen, + const unsigned char *salt, int saltlen, int iter, + const EVP_MD *digest, unsigned char *key, + size_t keylen, int lower_bound_checks) { int ret = 0; unsigned char digtmp[EVP_MAX_MD_SIZE], *p, itmp[4]; @@ -209,9 +245,33 @@ static int pkcs5_pbkdf2_alg(const char *pass, size_t passlen, HMAC_CTX *hctx_tpl = NULL, *hctx = NULL; mdlen = EVP_MD_size(digest); - if (mdlen < 0) + if (mdlen <= 0) return 0; + /* + * This check should always be done because keylen / mdlen >= (2^32 - 1) + * results in an overflow of the loop counter 'i'. + */ + if ((keylen / mdlen) >= KDF_PBKDF2_MAX_KEY_LEN_DIGEST_RATIO) { + KDFerr(KDF_F_PBKDF2_DERIVE, KDF_R_INVALID_KEY_LEN); + return 0; + } + + if (lower_bound_checks) { + if ((keylen * 8) < KDF_PBKDF2_MIN_KEY_LEN_BITS) { + KDFerr(KDF_F_PBKDF2_DERIVE, KDF_R_INVALID_KEY_LEN); + return 0; + } + if (saltlen < KDF_PBKDF2_MIN_SALT_LEN) { + KDFerr(KDF_F_PBKDF2_DERIVE, KDF_R_INVALID_SALT_LEN); + return 0; + } + if (iter < KDF_PBKDF2_MIN_ITERATIONS) { + KDFerr(KDF_F_PBKDF2_DERIVE, KDF_R_INVALID_ITERATION_COUNT); + return 0; + } + } + hctx_tpl = HMAC_CTX_new(); if (hctx_tpl == NULL) return 0; diff --git a/crypto/kdf/sskdf.c b/crypto/kdf/sskdf.c index 92bf9954..62372a50 100644 --- a/crypto/kdf/sskdf.c +++ b/crypto/kdf/sskdf.c @@ -17,7 +17,7 @@ * Result(0) = empty bit string (i.e., the null string). * For i = 1 to reps, do the following: * Increment counter by 1. - * Result(i) = Result(i – 1) || H(counter || Z || FixedInfo). + * Result(i) = Result(i - 1) || H(counter || Z || FixedInfo). * DKM = LeftmostBits(Result(reps), L)) * * NOTES: @@ -202,9 +202,8 @@ static int SSKDF_mac_kdm(const EVP_MAC *kdf_mac, const EVP_MD *hmac_md, || derived_key_len == 0) return 0; - ctx = EVP_MAC_CTX_new(kdf_mac); ctx_init = EVP_MAC_CTX_new(kdf_mac); - if (ctx == NULL || ctx_init == NULL) + if (ctx_init == NULL) goto end; if (hmac_md != NULL && EVP_MAC_ctrl(ctx_init, EVP_MAC_CTRL_SET_MD, hmac_md) <= 0) @@ -233,7 +232,8 @@ static int SSKDF_mac_kdm(const EVP_MAC *kdf_mac, const EVP_MD *hmac_md, c[2] = (unsigned char)((counter >> 8) & 0xff); c[3] = (unsigned char)(counter & 0xff); - if (!(EVP_MAC_CTX_copy(ctx, ctx_init) + ctx = EVP_MAC_CTX_dup(ctx_init); + if (!(ctx != NULL && EVP_MAC_update(ctx, c, sizeof(c)) && EVP_MAC_update(ctx, z, z_len) && EVP_MAC_update(ctx, info, info_len))) @@ -251,6 +251,8 @@ static int SSKDF_mac_kdm(const EVP_MAC *kdf_mac, const EVP_MD *hmac_md, memcpy(out, mac, len); break; } + EVP_MAC_CTX_free(ctx); + ctx = NULL; } ret = 1; end: diff --git a/crypto/kdf/tls1_prf.c b/crypto/kdf/tls1_prf.c index c39cf204..b14ae6fe 100644 --- a/crypto/kdf/tls1_prf.c +++ b/crypto/kdf/tls1_prf.c @@ -237,10 +237,8 @@ static int tls1_prf_P_hash(const EVP_MD *md, size_t Ai_len; int ret = 0; - ctx = EVP_MAC_CTX_new_id(EVP_MAC_HMAC); - ctx_Ai = EVP_MAC_CTX_new_id(EVP_MAC_HMAC); ctx_init = EVP_MAC_CTX_new_id(EVP_MAC_HMAC); - if (ctx == NULL || ctx_Ai == NULL || ctx_init == NULL) + if (ctx_init == NULL) goto err; if (EVP_MAC_ctrl(ctx_init, EVP_MAC_CTRL_SET_FLAGS, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW) != 1) goto err; @@ -254,7 +252,8 @@ static int tls1_prf_P_hash(const EVP_MD *md, if (chunk == 0) goto err; /* A(0) = seed */ - if (!EVP_MAC_CTX_copy(ctx_Ai, ctx_init)) + ctx_Ai = EVP_MAC_CTX_dup(ctx_init); + if (ctx_Ai == NULL) goto err; if (seed != NULL && !EVP_MAC_update(ctx_Ai, seed, seed_len)) goto err; @@ -263,15 +262,21 @@ static int tls1_prf_P_hash(const EVP_MD *md, /* calc: A(i) = HMAC_(secret, A(i-1)) */ if (!EVP_MAC_final(ctx_Ai, Ai, &Ai_len)) goto err; + EVP_MAC_CTX_free(ctx_Ai); + ctx_Ai = NULL; /* calc next chunk: HMAC_(secret, A(i) + seed) */ - if (!EVP_MAC_CTX_copy(ctx, ctx_init)) + ctx = EVP_MAC_CTX_dup(ctx_init); + if (ctx == NULL) goto err; if (!EVP_MAC_update(ctx, Ai, Ai_len)) goto err; /* save state for calculating next A(i) value */ - if (olen > chunk && !EVP_MAC_CTX_copy(ctx_Ai, ctx)) - goto err; + if (olen > chunk) { + ctx_Ai = EVP_MAC_CTX_dup(ctx); + if (ctx_Ai == NULL) + goto err; + } if (seed != NULL && !EVP_MAC_update(ctx, seed, seed_len)) goto err; if (olen <= chunk) { @@ -283,6 +288,8 @@ static int tls1_prf_P_hash(const EVP_MD *md, } if (!EVP_MAC_final(ctx, out, NULL)) goto err; + EVP_MAC_CTX_free(ctx); + ctx = NULL; out += chunk; olen -= chunk; } diff --git a/crypto/kdf/x942kdf.c b/crypto/kdf/x942kdf.c new file mode 100644 index 00000000..ce9ad610 --- /dev/null +++ b/crypto/kdf/x942kdf.c @@ -0,0 +1,407 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "e_os.h" + +#ifndef OPENSSL_NO_CMS + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include "internal/cryptlib.h" +# include "internal/evp_int.h" +# include "kdf_local.h" + +# define X942KDF_MAX_INLEN (1 << 30) + +struct evp_kdf_impl_st { + const EVP_MD *md; + unsigned char *secret; + size_t secret_len; + int cek_nid; + unsigned char *ukm; + size_t ukm_len; + size_t dkm_len; +}; + +/* A table of allowed wrapping algorithms and the associated output lengths */ +static const struct { + int nid; + size_t keklen; /* size in bytes */ +} kek_algs[] = { + { NID_id_smime_alg_CMS3DESwrap, 24 }, + { NID_id_smime_alg_CMSRC2wrap, 16 }, + { NID_id_aes128_wrap, 16 }, + { NID_id_aes192_wrap, 24 }, + { NID_id_aes256_wrap, 32 }, + { NID_id_camellia128_wrap, 16 }, + { NID_id_camellia192_wrap, 24 }, + { NID_id_camellia256_wrap, 32 } +}; + +/* Skip past an ASN1 structure: for OBJECT skip content octets too */ +static int skip_asn1(unsigned char **pp, long *plen, int exptag) +{ + int i, tag, xclass; + long tmplen; + const unsigned char *q = *pp; + + i = ASN1_get_object(&q, &tmplen, &tag, &xclass, *plen); + if ((i & 0x80) != 0 || tag != exptag || xclass != V_ASN1_UNIVERSAL) + return 0; + if (tag == V_ASN1_OBJECT) + q += tmplen; + *pp = (unsigned char *)q; + *plen -= q - *pp; + return 1; +} + +/* + * Encode the other info structure. + * + * RFC2631 Section 2.1.2 Contains the following definition for otherinfo + * + * OtherInfo ::= SEQUENCE { + * keyInfo KeySpecificInfo, + * partyAInfo [0] OCTET STRING OPTIONAL, + * suppPubInfo [2] OCTET STRING + * } + * + * KeySpecificInfo ::= SEQUENCE { + * algorithm OBJECT IDENTIFIER, + * counter OCTET STRING SIZE (4..4) + * } + * + * |nid| is the algorithm object identifier. + * |keylen| is the length (in bytes) of the generated KEK. It is stored into + * suppPubInfo (in bits). + * |ukm| is the optional user keying material that is stored into partyAInfo. It + * can be NULL. + * |ukmlen| is the user keying material length (in bytes). + * |der| is the returned encoded data. It must be freed by the caller. + * |der_len| is the returned size of the encoded data. + * |out_ctr| returns a pointer to the counter data which is embedded inside the + * encoded data. This allows the counter bytes to be updated without re-encoding. + * + * Returns: 1 if successfully encoded, or 0 otherwise. + * Assumptions: |der|, |der_len| & |out_ctr| are not NULL. + */ +static int x942_encode_otherinfo(int nid, size_t keylen, + const unsigned char *ukm, size_t ukmlen, + unsigned char **der, size_t *der_len, + unsigned char **out_ctr) +{ + unsigned char *p, *encoded = NULL; + int ret = 0, encoded_len; + long tlen; + /* "magic" value to check offset is sane */ + static unsigned char ctr[4] = { 0x00, 0x00, 0x00, 0x01 }; + X509_ALGOR *ksi = NULL; + ASN1_OBJECT *alg_oid = NULL; + ASN1_OCTET_STRING *ctr_oct = NULL, *ukm_oct = NULL; + + /* set the KeySpecificInfo - which contains an algorithm oid and counter */ + ksi = X509_ALGOR_new(); + alg_oid = OBJ_dup(OBJ_nid2obj(nid)); + ctr_oct = ASN1_OCTET_STRING_new(); + if (ksi == NULL + || alg_oid == NULL + || ctr_oct == NULL + || !ASN1_OCTET_STRING_set(ctr_oct, ctr, sizeof(ctr)) + || !X509_ALGOR_set0(ksi, alg_oid, V_ASN1_OCTET_STRING, ctr_oct)) + goto err; + /* NULL these as they now belong to ksi */ + alg_oid = NULL; + ctr_oct = NULL; + + /* Set the optional partyAInfo */ + if (ukm != NULL) { + ukm_oct = ASN1_OCTET_STRING_new(); + if (ukm_oct == NULL) + goto err; + ASN1_OCTET_STRING_set(ukm_oct, (unsigned char *)ukm, ukmlen); + } + /* Generate the OtherInfo DER data */ + encoded_len = CMS_SharedInfo_encode(&encoded, ksi, ukm_oct, keylen); + if (encoded_len <= 0) + goto err; + + /* Parse the encoded data to find the offset of the counter data */ + p = encoded; + tlen = (long)encoded_len; + if (skip_asn1(&p, &tlen, V_ASN1_SEQUENCE) + && skip_asn1(&p, &tlen, V_ASN1_SEQUENCE) + && skip_asn1(&p, &tlen, V_ASN1_OBJECT) + && skip_asn1(&p, &tlen, V_ASN1_OCTET_STRING) + && CRYPTO_memcmp(p, ctr, 4) == 0) { + *out_ctr = p; + *der = encoded; + *der_len = (size_t)encoded_len; + ret = 1; + } +err: + if (ret != 1) + OPENSSL_free(encoded); + ASN1_OCTET_STRING_free(ctr_oct); + ASN1_OCTET_STRING_free(ukm_oct); + ASN1_OBJECT_free(alg_oid); + X509_ALGOR_free(ksi); + return ret; +} + +static int x942kdf_hash_kdm(const EVP_MD *kdf_md, + const unsigned char *z, size_t z_len, + const unsigned char *other, size_t other_len, + unsigned char *ctr, + unsigned char *derived_key, size_t derived_key_len) +{ + int ret = 0, hlen; + size_t counter, out_len, len = derived_key_len; + unsigned char mac[EVP_MAX_MD_SIZE]; + unsigned char *out = derived_key; + EVP_MD_CTX *ctx = NULL, *ctx_init = NULL; + + if (z_len > X942KDF_MAX_INLEN || other_len > X942KDF_MAX_INLEN + || derived_key_len > X942KDF_MAX_INLEN + || derived_key_len == 0) { + KDFerr(KDF_F_X942KDF_HASH_KDM, KDF_R_BAD_LENGTH); + return 0; + } + + hlen = EVP_MD_size(kdf_md); + if (hlen <= 0) + return 0; + out_len = (size_t)hlen; + + ctx = EVP_MD_CTX_create(); + ctx_init = EVP_MD_CTX_create(); + if (ctx == NULL || ctx_init == NULL) + goto end; + + if (!EVP_DigestInit(ctx_init, kdf_md)) + goto end; + + for (counter = 1;; counter++) { + /* updating the ctr modifies 4 bytes in the 'other' buffer */ + ctr[0] = (unsigned char)((counter >> 24) & 0xff); + ctr[1] = (unsigned char)((counter >> 16) & 0xff); + ctr[2] = (unsigned char)((counter >> 8) & 0xff); + ctr[3] = (unsigned char)(counter & 0xff); + + if (!EVP_MD_CTX_copy_ex(ctx, ctx_init) + || !EVP_DigestUpdate(ctx, z, z_len) + || !EVP_DigestUpdate(ctx, other, other_len)) + goto end; + if (len >= out_len) { + if (!EVP_DigestFinal_ex(ctx, out, NULL)) + goto end; + out += out_len; + len -= out_len; + if (len == 0) + break; + } else { + if (!EVP_DigestFinal_ex(ctx, mac, NULL)) + goto end; + memcpy(out, mac, len); + break; + } + } + ret = 1; +end: + EVP_MD_CTX_free(ctx); + EVP_MD_CTX_free(ctx_init); + OPENSSL_cleanse(mac, sizeof(mac)); + return ret; +} + +static EVP_KDF_IMPL *x942kdf_new(void) +{ + EVP_KDF_IMPL *impl; + + if ((impl = OPENSSL_zalloc(sizeof(*impl))) == NULL) + KDFerr(KDF_F_X942KDF_NEW, ERR_R_MALLOC_FAILURE); + return impl; +} + +static void x942kdf_reset(EVP_KDF_IMPL *impl) +{ + OPENSSL_clear_free(impl->secret, impl->secret_len); + OPENSSL_clear_free(impl->ukm, impl->ukm_len); + memset(impl, 0, sizeof(*impl)); +} + +static void x942kdf_free(EVP_KDF_IMPL *impl) +{ + x942kdf_reset(impl); + OPENSSL_free(impl); +} + +static int x942kdf_set_buffer(va_list args, unsigned char **out, size_t *out_len) +{ + const unsigned char *p; + size_t len; + + p = va_arg(args, const unsigned char *); + len = va_arg(args, size_t); + if (len == 0 || p == NULL) + return 1; + + OPENSSL_free(*out); + *out = OPENSSL_memdup(p, len); + if (*out == NULL) + return 0; + + *out_len = len; + return 1; +} + +static int x942kdf_ctrl(EVP_KDF_IMPL *impl, int cmd, va_list args) +{ + const EVP_MD *md; + char *alg_str = NULL; + size_t i; + + switch (cmd) { + case EVP_KDF_CTRL_SET_MD: + md = va_arg(args, const EVP_MD *); + if (md == NULL) + return 0; + + impl->md = md; + return 1; + + case EVP_KDF_CTRL_SET_KEY: + return x942kdf_set_buffer(args, &impl->secret, &impl->secret_len); + + case EVP_KDF_CTRL_SET_UKM: + return x942kdf_set_buffer(args, &impl->ukm, &impl->ukm_len); + + case EVP_KDF_CTRL_SET_CEK_ALG: + alg_str = va_arg(args, char *); + if (alg_str == NULL) + return 0; + impl->cek_nid = OBJ_sn2nid(alg_str); + for (i = 0; i < (size_t)OSSL_NELEM(kek_algs); ++i) { + if (kek_algs[i].nid == impl->cek_nid) { + impl->dkm_len = kek_algs[i].keklen; + return 1; + } + } + KDFerr(KDF_F_X942KDF_CTRL, KDF_R_UNSUPPORTED_CEK_ALG); + return 0; + + default: + return -2; + } +} + +static int x942kdf_ctrl_str(EVP_KDF_IMPL *impl, const char *type, + const char *value) +{ + if (strcmp(type, "digest") == 0) + return kdf_md2ctrl(impl, x942kdf_ctrl, EVP_KDF_CTRL_SET_MD, value); + + if (strcmp(type, "secret") == 0 || strcmp(type, "key") == 0) + return kdf_str2ctrl(impl, x942kdf_ctrl, EVP_KDF_CTRL_SET_KEY, + value); + + if (strcmp(type, "hexsecret") == 0 || strcmp(type, "hexkey") == 0) + return kdf_hex2ctrl(impl, x942kdf_ctrl, EVP_KDF_CTRL_SET_KEY, + value); + + if (strcmp(type, "ukm") == 0) + return kdf_str2ctrl(impl, x942kdf_ctrl, EVP_KDF_CTRL_SET_UKM, + value); + + if (strcmp(type, "hexukm") == 0) + return kdf_hex2ctrl(impl, x942kdf_ctrl, EVP_KDF_CTRL_SET_UKM, + value); + + if (strcmp(type, "cekalg") == 0) + return kdf_str2ctrl(impl, x942kdf_ctrl, EVP_KDF_CTRL_SET_CEK_ALG, + value); + + return -2; +} + +static size_t x942kdf_size(EVP_KDF_IMPL *impl) +{ + int len; + + if (impl->md == NULL) { + KDFerr(KDF_F_X942KDF_SIZE, KDF_R_MISSING_MESSAGE_DIGEST); + return 0; + } + len = EVP_MD_size(impl->md); + return (len <= 0) ? 0 : (size_t)len; +} + +static int x942kdf_derive(EVP_KDF_IMPL *impl, unsigned char *key, size_t keylen) +{ + int ret = 0; + unsigned char *ctr; + unsigned char *der = NULL; + size_t der_len = 0; + + if (impl->secret == NULL) { + KDFerr(KDF_F_X942KDF_DERIVE, KDF_R_MISSING_SECRET); + return 0; + } + if (impl->md == NULL) { + KDFerr(KDF_F_X942KDF_DERIVE, KDF_R_MISSING_MESSAGE_DIGEST); + return 0; + } + if (impl->cek_nid == NID_undef) { + KDFerr(KDF_F_X942KDF_DERIVE, KDF_R_MISSING_CEK_ALG); + return 0; + } + if (impl->ukm != NULL && impl->ukm_len >= X942KDF_MAX_INLEN) { + /* + * Note the ukm length MUST be 512 bits. + * For backwards compatibility the old check is being done. + */ + KDFerr(KDF_F_X942KDF_DERIVE, KDF_R_INAVLID_UKM_LEN); + return 0; + } + if (keylen != impl->dkm_len) { + KDFerr(KDF_F_X942KDF_DERIVE, KDF_R_MISSING_CEK_ALG); + return 0; + } + /* generate the otherinfo der */ + if (!x942_encode_otherinfo(impl->cek_nid, impl->dkm_len, + impl->ukm, impl->ukm_len, + &der, &der_len, &ctr)) { + KDFerr(KDF_F_X942KDF_DERIVE, KDF_R_BAD_ENCODING); + return 0; + } + ret = x942kdf_hash_kdm(impl->md, impl->secret, impl->secret_len, + der, der_len, ctr, key, keylen); + OPENSSL_free(der); + return ret; +} + +const EVP_KDF x942_kdf_meth = { + EVP_KDF_X942, + x942kdf_new, + x942kdf_free, + x942kdf_reset, + x942kdf_ctrl, + x942kdf_ctrl_str, + x942kdf_size, + x942kdf_derive +}; + +#endif /* OPENSSL_NO_CMS */ diff --git a/crypto/kmac/kmac.c b/crypto/kmac/kmac.c index 76e75c1e..69c334c3 100644 --- a/crypto/kmac/kmac.c +++ b/crypto/kmac/kmac.c @@ -147,8 +147,19 @@ static EVP_MAC_IMPL *kmac256_new(void) return kmac_new(evp_keccak_kmac256()); } -static int kmac_copy(EVP_MAC_IMPL *gdst, EVP_MAC_IMPL *gsrc) +static EVP_MAC_IMPL *kmac_dup(const EVP_MAC_IMPL *gsrc) { + EVP_MAC_IMPL *gdst; + + gdst = kmac_new(gsrc->md); + if (gdst == NULL) + return NULL; + + if (!EVP_MD_CTX_copy(gdst->ctx, gsrc->ctx)) { + kmac_free(gdst); + return NULL; + } + gdst->md = gsrc->md; gdst->out_len = gsrc->out_len; gdst->key_len = gsrc->key_len; @@ -157,7 +168,7 @@ static int kmac_copy(EVP_MAC_IMPL *gdst, EVP_MAC_IMPL *gsrc) memcpy(gdst->key, gsrc->key, gsrc->key_len); memcpy(gdst->custom, gsrc->custom, gdst->custom_len); - return EVP_MD_CTX_copy(gdst->ctx, gsrc->ctx); + return gdst; } /* @@ -444,7 +455,7 @@ static int kmac_bytepad_encode_key(unsigned char *out, int *out_len, const EVP_MAC kmac128_meth = { EVP_MAC_KMAC128, kmac128_new, - kmac_copy, + kmac_dup, kmac_free, kmac_size, kmac_init, @@ -457,7 +468,7 @@ const EVP_MAC kmac128_meth = { const EVP_MAC kmac256_meth = { EVP_MAC_KMAC256, kmac256_new, - kmac_copy, + kmac_dup, kmac_free, kmac_size, kmac_init, diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c index e3c7ac45..f91a56a7 100644 --- a/crypto/lhash/lhash.c +++ b/crypto/lhash/lhash.c @@ -19,14 +19,14 @@ /* * A hashing implementation that appears to be based on the linear hashing - * alogrithm: + * algorithm: * https://en.wikipedia.org/wiki/Linear_hashing * * Litwin, Witold (1980), "Linear hashing: A new tool for file and table * addressing", Proc. 6th Conference on Very Large Databases: 212-223 - * http://hackthology.com/pdfs/Litwin-1980-Linear_Hashing.pdf + * https://hackthology.com/pdfs/Litwin-1980-Linear_Hashing.pdf * - * From the wikipedia article "Linear hashing is used in the BDB Berkeley + * From the Wikipedia article "Linear hashing is used in the BDB Berkeley * database system, which in turn is used by many software systems such as * OpenLDAP, using a C implementation derived from the CACM article and first * published on the Usenet in 1988 by Esmond Pitt." diff --git a/crypto/md5/build.info b/crypto/md5/build.info index e641fecd..3b91abf3 100644 --- a/crypto/md5/build.info +++ b/crypto/md5/build.info @@ -1,6 +1,21 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - md5_dgst.c md5_one.c {- $target{md5_asm_src} -} + +$MD5ASM= +IF[{- !$disabled{asm} -}] + $MD5ASM_x86=md5-586.s + $MD5ASM_x86_64=md5-x86_64.s + $MD5ASM_sparcv9=md5-sparcv9.S + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$MD5ASM_{- $target{asm_arch} -}] + $MD5ASM=$MD5ASM_{- $target{asm_arch} -} + $MD5DEF=MD5_ASM + ENDIF +ENDIF + +SOURCE[../../libcrypto]=md5_dgst.c md5_one.c md5_sha1.c $MD5ASM +DEFINE[../../libcrypto]=$MD5DEF GENERATE[md5-586.s]=asm/md5-586.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) diff --git a/crypto/md5/md5_sha1.c b/crypto/md5/md5_sha1.c new file mode 100644 index 00000000..5d5fac95 --- /dev/null +++ b/crypto/md5/md5_sha1.c @@ -0,0 +1,101 @@ +/* + * Copyright 2015-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ +#include +#include "internal/md5_sha1.h" +#include + +int md5_sha1_init(MD5_SHA1_CTX *mctx) +{ + if (!MD5_Init(&mctx->md5)) + return 0; + return SHA1_Init(&mctx->sha1); +} + +int md5_sha1_update(MD5_SHA1_CTX *mctx, const void *data, size_t count) +{ + if (!MD5_Update(&mctx->md5, data, count)) + return 0; + return SHA1_Update(&mctx->sha1, data, count); +} + +int md5_sha1_final(unsigned char *md, MD5_SHA1_CTX *mctx) +{ + if (!MD5_Final(md, &mctx->md5)) + return 0; + return SHA1_Final(md + MD5_DIGEST_LENGTH, &mctx->sha1); +} + +int md5_sha1_ctrl(MD5_SHA1_CTX *mctx, int cmd, int mslen, void *ms) +{ + unsigned char padtmp[48]; + unsigned char md5tmp[MD5_DIGEST_LENGTH]; + unsigned char sha1tmp[SHA_DIGEST_LENGTH]; + + if (cmd != EVP_CTRL_SSL3_MASTER_SECRET) + return -2; + + if (mctx == NULL) + return 0; + + /* SSLv3 client auth handling: see RFC-6101 5.6.8 */ + if (mslen != 48) + return 0; + + /* At this point hash contains all handshake messages, update + * with master secret and pad_1. + */ + + if (md5_sha1_update(mctx, ms, mslen) <= 0) + return 0; + + /* Set padtmp to pad_1 value */ + memset(padtmp, 0x36, sizeof(padtmp)); + + if (!MD5_Update(&mctx->md5, padtmp, sizeof(padtmp))) + return 0; + + if (!MD5_Final(md5tmp, &mctx->md5)) + return 0; + + if (!SHA1_Update(&mctx->sha1, padtmp, 40)) + return 0; + + if (!SHA1_Final(sha1tmp, &mctx->sha1)) + return 0; + + /* Reinitialise context */ + + if (!md5_sha1_init(mctx)) + return 0; + + if (md5_sha1_update(mctx, ms, mslen) <= 0) + return 0; + + /* Set padtmp to pad_2 value */ + memset(padtmp, 0x5c, sizeof(padtmp)); + + if (!MD5_Update(&mctx->md5, padtmp, sizeof(padtmp))) + return 0; + + if (!MD5_Update(&mctx->md5, md5tmp, sizeof(md5tmp))) + return 0; + + if (!SHA1_Update(&mctx->sha1, padtmp, 40)) + return 0; + + if (!SHA1_Update(&mctx->sha1, sha1tmp, sizeof(sha1tmp))) + return 0; + + /* Now when ctx is finalised it will return the SSL v3 hash value */ + + OPENSSL_cleanse(md5tmp, sizeof(md5tmp)); + OPENSSL_cleanse(sha1tmp, sizeof(sha1tmp)); + + return 1; +} diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c index 703cc30c..8fcdbeca 100644 --- a/crypto/mem_dbg.c +++ b/crypto/mem_dbg.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -455,20 +455,11 @@ typedef struct mem_leak_st { static void print_leak(const MEM *m, MEM_LEAK *l) { char buf[1024]; - char *bufp = buf; + char *bufp = buf, *hex; size_t len = sizeof(buf), ami_cnt; APP_INFO *amip; int n; struct tm *lcl = NULL; - /* - * Convert between CRYPTO_THREAD_ID (which could be anything at all) and - * a long. This may not be meaningful depending on what CRYPTO_THREAD_ID is - * but hopefully should give something sensible on most platforms - */ - union { - CRYPTO_THREAD_ID tid; - unsigned long ltid; - } tid; CRYPTO_THREAD_ID ti; lcl = localtime(&m->time); @@ -488,15 +479,11 @@ static void print_leak(const MEM *m, MEM_LEAK *l) bufp += n; len -= n; - tid.ltid = 0; - tid.tid = m->threadid; - n = BIO_snprintf(bufp, len, "thread=%lu, ", tid.ltid); - if (n <= 0) - return; - bufp += n; - len -= n; - - n = BIO_snprintf(bufp, len, "number=%d, address=%p\n", m->num, m->addr); + hex = OPENSSL_buf2hexstr((const unsigned char *)&m->threadid, + sizeof(m->threadid)); + n = BIO_snprintf(bufp, len, "thread=%s, number=%d, address=%p\n", hex, + m->num, m->addr); + OPENSSL_free(hex); if (n <= 0) return; bufp += n; @@ -522,11 +509,12 @@ static void print_leak(const MEM *m, MEM_LEAK *l) break; memset(buf, '>', ami_cnt); buf[ami_cnt] = '\0'; - tid.ltid = 0; - tid.tid = amip->threadid; + hex = OPENSSL_buf2hexstr((const unsigned char *)&amip->threadid, + sizeof(amip->threadid)); n = BIO_snprintf(buf + ami_cnt, sizeof(buf) - ami_cnt, - " thread=%lu, file=%s, line=%d, info=\"", - tid.ltid, amip->file, amip->line); + "thread=%s, file=%s, line=%d, info=\"", + hex, amip->file, amip->line); + OPENSSL_free(hex); if (n <= 0) break; buf_len = ami_cnt + n; diff --git a/crypto/mem_str.c b/crypto/mem_str.c new file mode 100644 index 00000000..da13ea4a --- /dev/null +++ b/crypto/mem_str.c @@ -0,0 +1,133 @@ +/* + * Copyright 2003-2017 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "e_os.h" +#include +#include +#include "internal/cryptlib.h" + +char *CRYPTO_strdup(const char *str, const char* file, int line) +{ + char *ret; + + if (str == NULL) + return NULL; + ret = CRYPTO_malloc(strlen(str) + 1, file, line); + if (ret != NULL) + strcpy(ret, str); + return ret; +} + +char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line) +{ + size_t maxlen; + char *ret; + + if (str == NULL) + return NULL; + + maxlen = OPENSSL_strnlen(str, s); + + ret = CRYPTO_malloc(maxlen + 1, file, line); + if (ret) { + memcpy(ret, str, maxlen); + ret[maxlen] = '\0'; + } + return ret; +} + +void *CRYPTO_memdup(const void *data, size_t siz, const char* file, int line) +{ + void *ret; + + if (data == NULL || siz >= INT_MAX) + return NULL; + + ret = CRYPTO_malloc(siz, file, line); + if (ret == NULL) { + CRYPTOerr(CRYPTO_F_CRYPTO_MEMDUP, ERR_R_MALLOC_FAILURE); + return NULL; + } + return memcpy(ret, data, siz); +} + +/* + * Give a string of hex digits convert to a buffer + */ +unsigned char *OPENSSL_hexstr2buf(const char *str, long *len) +{ + unsigned char *hexbuf, *q; + unsigned char ch, cl; + int chi, cli; + const unsigned char *p; + size_t s; + + s = strlen(str); + if ((hexbuf = OPENSSL_malloc(s >> 1)) == NULL) { + CRYPTOerr(CRYPTO_F_OPENSSL_HEXSTR2BUF, ERR_R_MALLOC_FAILURE); + return NULL; + } + for (p = (const unsigned char *)str, q = hexbuf; *p; ) { + ch = *p++; + if (ch == ':') + continue; + cl = *p++; + if (!cl) { + CRYPTOerr(CRYPTO_F_OPENSSL_HEXSTR2BUF, + CRYPTO_R_ODD_NUMBER_OF_DIGITS); + OPENSSL_free(hexbuf); + return NULL; + } + cli = OPENSSL_hexchar2int(cl); + chi = OPENSSL_hexchar2int(ch); + if (cli < 0 || chi < 0) { + OPENSSL_free(hexbuf); + CRYPTOerr(CRYPTO_F_OPENSSL_HEXSTR2BUF, CRYPTO_R_ILLEGAL_HEX_DIGIT); + return NULL; + } + *q++ = (unsigned char)((chi << 4) | cli); + } + + if (len) + *len = q - hexbuf; + return hexbuf; +} + +/* + * Given a buffer of length 'len' return a OPENSSL_malloc'ed string with its + * hex representation @@@ (Contents of buffer are always kept in ASCII, also + * on EBCDIC machines) + */ +char *OPENSSL_buf2hexstr(const unsigned char *buffer, long len) +{ + static const char hexdig[] = "0123456789ABCDEF"; + char *tmp, *q; + const unsigned char *p; + int i; + + if (len == 0) + return OPENSSL_zalloc(1); + + if ((tmp = OPENSSL_malloc(len * 3)) == NULL) { + CRYPTOerr(CRYPTO_F_OPENSSL_BUF2HEXSTR, ERR_R_MALLOC_FAILURE); + return NULL; + } + q = tmp; + for (i = 0, p = buffer; i < len; i++, p++) { + *q++ = hexdig[(*p >> 4) & 0xf]; + *q++ = hexdig[*p & 0xf]; + *q++ = ':'; + } + q[-1] = 0; +#ifdef CHARSET_EBCDIC + ebcdic2ascii(tmp, tmp, q - tmp - 1); +#endif + + return tmp; +} diff --git a/crypto/modes/build.info b/crypto/modes/build.info index f015a4c3..81525a99 100644 --- a/crypto/modes/build.info +++ b/crypto/modes/build.info @@ -1,8 +1,59 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - cbc128.c ctr128.c cts128.c cfb128.c ofb128.c gcm128.c \ - ccm128.c xts128.c wrap128.c ocb128.c siv128.c \ - {- $target{modes_asm_src} -} + +$MODESASM= +IF[{- !$disabled{asm} -}] + $MODESASM_x86=ghash-x86.s + $MODESDEF_x86=GHASH_ASM + $MODESASM_x86_64=ghash-x86_64.s aesni-gcm-x86_64.s + $MODESDEF_x86_64=GHASH_ASM + + # ghash-ia64.s doesn't work on VMS + IF[{- $config{target} !~ /^vms-/ -}] + $MODESASM_ia64=ghash-ia64.s + $MODESDEF_ia64=GHASH_ASM + ENDIF + + $MODESASM_sparcv9=ghash-sparcv9.S + $MODESDEF_sparcv9=GHASH_ASM + + $MODESASM_alpha=ghash-alpha.S + $MODESDEF_alpha=GHASH_ASM + + $MODESASM_s390x=ghash-s390x.S + $MODESDEF_s390x=GHASH_ASM + + $MODESASM_armv4=ghash-armv4.S ghashv8-armx.S + $MODESDEF_armv4=GHASH_ASM + $MODESASM_aarch64=ghashv8-armx.S + $MODESDEF_aarch64= + + $MODESASM_parisc11=ghash-parisc.s + $MODESDEF_parisc11=GHASH_ASM + $MODESASM_parisc20_64=$MODESASM_parisc11 + $MODESDEF_parisc20_64=$MODESDEF_parisc11 + + $MODESASM_ppc32=ghashp8-ppc.s + $MODESDEF_ppc32= + $MODESASM_ppc64=$MODESASM_ppc32 + $MODESDEF_ppc64=$MODESDEF_ppc32 + + $MODESASM_c64xplus=ghash-c64xplus.s + $MODESDEF_c64xplus=GHASH_ASM + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$MODESASM_{- $target{asm_arch} -}] + $MODESASM=$MODESASM_{- $target{asm_arch} -} + $MODESDEF=$MODESDEF_{- $target{asm_arch} -} + ENDIF +ENDIF + +$COMMON=cbc128.c ctr128.c cfb128.c ofb128.c $MODESASM +SOURCE[../../libcrypto]=$COMMON \ + cts128.c gcm128.c ccm128.c xts128.c wrap128.c ocb128.c siv128.c +DEFINE[../../libcrypto]=$MODESDEF +SOURCE[../../providers/fips]=$COMMON +DEFINE[../../providers/fips]=$MODESDEF INCLUDE[gcm128.o]=.. diff --git a/crypto/modes/modes_lcl.h b/crypto/modes/modes_lcl.h index aed79ffb..d4ce4623 100644 --- a/crypto/modes/modes_lcl.h +++ b/crypto/modes/modes_lcl.h @@ -213,7 +213,6 @@ struct siv128_context { SIV_BLOCK tag; EVP_CIPHER_CTX *cipher_ctx; EVP_MAC_CTX *mac_ctx_init; - EVP_MAC_CTX *mac_ctx; int final_ret; int crypto_ok; }; diff --git a/crypto/modes/siv128.c b/crypto/modes/siv128.c index f812d0a7..4445cf36 100644 --- a/crypto/modes/siv128.c +++ b/crypto/modes/siv128.c @@ -10,6 +10,7 @@ #include #include #include +#include "internal/modes_int.h" #include "modes_lcl.h" #ifndef OPENSSL_NO_SIV @@ -92,30 +93,38 @@ __owur static ossl_inline int siv128_do_s2v_p(SIV128_CONTEXT *ctx, SIV_BLOCK *ou { SIV_BLOCK t; size_t out_len = sizeof(out->byte); + EVP_MAC_CTX *mac_ctx; + int ret = 0; - if (!EVP_MAC_CTX_copy(ctx->mac_ctx, ctx->mac_ctx_init)) + mac_ctx = EVP_MAC_CTX_dup(ctx->mac_ctx_init); + if (mac_ctx == NULL) return 0; if (len >= SIV_LEN) { - if (!EVP_MAC_update(ctx->mac_ctx, in, len - SIV_LEN)) - return 0; + if (!EVP_MAC_update(mac_ctx, in, len - SIV_LEN)) + goto err; memcpy(&t, in + (len-SIV_LEN), SIV_LEN); siv128_xorblock(&t, &ctx->d); - if (!EVP_MAC_update(ctx->mac_ctx, t.byte, SIV_LEN)) - return 0; + if (!EVP_MAC_update(mac_ctx, t.byte, SIV_LEN)) + goto err; } else { memset(&t, 0, sizeof(t)); memcpy(&t, in, len); t.byte[len] = 0x80; siv128_dbl(&ctx->d); siv128_xorblock(&t, &ctx->d); - if (!EVP_MAC_update(ctx->mac_ctx, t.byte, SIV_LEN)) - return 0; + if (!EVP_MAC_update(mac_ctx, t.byte, SIV_LEN)) + goto err; } - if (!EVP_MAC_final(ctx->mac_ctx, out->byte, &out_len) + if (!EVP_MAC_final(mac_ctx, out->byte, &out_len) || out_len != SIV_LEN) - return 0; - return 1; + goto err; + + ret = 1; + +err: + EVP_MAC_CTX_free(mac_ctx); + return ret; } @@ -156,27 +165,27 @@ int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen, { static const unsigned char zero[SIV_LEN] = { 0 }; size_t out_len = SIV_LEN; + EVP_MAC_CTX *mac_ctx = NULL; memset(&ctx->d, 0, sizeof(ctx->d)); ctx->cipher_ctx = NULL; - ctx->mac_ctx = NULL; ctx->mac_ctx_init = NULL; if (key == NULL || cbc == NULL || ctr == NULL || (ctx->cipher_ctx = EVP_CIPHER_CTX_new()) == NULL || (ctx->mac_ctx_init = EVP_MAC_CTX_new_id(EVP_MAC_CMAC)) == NULL - || (ctx->mac_ctx = EVP_MAC_CTX_new_id(EVP_MAC_CMAC)) == NULL || EVP_MAC_ctrl(ctx->mac_ctx_init, EVP_MAC_CTRL_SET_CIPHER, cbc) <= 0 || EVP_MAC_ctrl(ctx->mac_ctx_init, EVP_MAC_CTRL_SET_KEY, key, klen) <= 0 || !EVP_EncryptInit_ex(ctx->cipher_ctx, ctr, NULL, key + klen, NULL) - || !EVP_MAC_CTX_copy(ctx->mac_ctx, ctx->mac_ctx_init) - || !EVP_MAC_update(ctx->mac_ctx, zero, sizeof(zero)) - || !EVP_MAC_final(ctx->mac_ctx, ctx->d.byte, &out_len)) { + || (mac_ctx = EVP_MAC_CTX_dup(ctx->mac_ctx_init)) == NULL + || !EVP_MAC_update(mac_ctx, zero, sizeof(zero)) + || !EVP_MAC_final(mac_ctx, ctx->d.byte, &out_len)) { EVP_CIPHER_CTX_free(ctx->cipher_ctx); EVP_MAC_CTX_free(ctx->mac_ctx_init); - EVP_MAC_CTX_free(ctx->mac_ctx); + EVP_MAC_CTX_free(mac_ctx); return 0; } + EVP_MAC_CTX_free(mac_ctx); ctx->final_ret = -1; ctx->crypto_ok = 1; @@ -192,9 +201,10 @@ int CRYPTO_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src) memcpy(&dest->d, &src->d, sizeof(src->d)); if (!EVP_CIPHER_CTX_copy(dest->cipher_ctx, src->cipher_ctx)) return 0; - if (!EVP_MAC_CTX_copy(dest->mac_ctx_init, src->mac_ctx_init)) + EVP_MAC_CTX_free(dest->mac_ctx_init); + dest->mac_ctx_init = EVP_MAC_CTX_dup(src->mac_ctx_init); + if (dest->mac_ctx_init == NULL) return 0; - /* no need to copy mac_ctx since it's temp storage */ return 1; } @@ -208,19 +218,23 @@ int CRYPTO_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad, { SIV_BLOCK mac_out; size_t out_len = SIV_LEN; + EVP_MAC_CTX *mac_ctx; siv128_dbl(&ctx->d); - if (!EVP_MAC_CTX_copy(ctx->mac_ctx, ctx->mac_ctx_init) - || !EVP_MAC_update(ctx->mac_ctx, aad, len) - || !EVP_MAC_final(ctx->mac_ctx, mac_out.byte, &out_len) - || out_len != SIV_LEN) + mac_ctx = EVP_MAC_CTX_dup(ctx->mac_ctx_init); + if (mac_ctx == NULL + || !EVP_MAC_update(mac_ctx, aad, len) + || !EVP_MAC_final(mac_ctx, mac_out.byte, &out_len) + || out_len != SIV_LEN) { + EVP_MAC_CTX_free(mac_ctx); return 0; + } + EVP_MAC_CTX_free(mac_ctx); siv128_xorblock(&ctx->d, &mac_out); return 1; - } /* @@ -330,8 +344,6 @@ int CRYPTO_siv128_cleanup(SIV128_CONTEXT *ctx) ctx->cipher_ctx = NULL; EVP_MAC_CTX_free(ctx->mac_ctx_init); ctx->mac_ctx_init = NULL; - EVP_MAC_CTX_free(ctx->mac_ctx); - ctx->mac_ctx = NULL; OPENSSL_cleanse(&ctx->d, sizeof(ctx->d)); OPENSSL_cleanse(&ctx->tag, sizeof(ctx->tag)); ctx->final_ret = -1; diff --git a/crypto/o_str.c b/crypto/o_str.c index 3b271e74..35bb6540 100644 --- a/crypto/o_str.c +++ b/crypto/o_str.c @@ -11,63 +11,6 @@ #include #include #include "internal/cryptlib.h" -#include "internal/o_str.h" - -int OPENSSL_memcmp(const void *v1, const void *v2, size_t n) -{ - const unsigned char *c1 = v1, *c2 = v2; - int ret = 0; - - while (n && (ret = *c1 - *c2) == 0) - n--, c1++, c2++; - - return ret; -} - -char *CRYPTO_strdup(const char *str, const char* file, int line) -{ - char *ret; - - if (str == NULL) - return NULL; - ret = CRYPTO_malloc(strlen(str) + 1, file, line); - if (ret != NULL) - strcpy(ret, str); - return ret; -} - -char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line) -{ - size_t maxlen; - char *ret; - - if (str == NULL) - return NULL; - - maxlen = OPENSSL_strnlen(str, s); - - ret = CRYPTO_malloc(maxlen + 1, file, line); - if (ret) { - memcpy(ret, str, maxlen); - ret[maxlen] = '\0'; - } - return ret; -} - -void *CRYPTO_memdup(const void *data, size_t siz, const char* file, int line) -{ - void *ret; - - if (data == NULL || siz >= INT_MAX) - return NULL; - - ret = CRYPTO_malloc(siz, file, line); - if (ret == NULL) { - CRYPTOerr(CRYPTO_F_CRYPTO_MEMDUP, ERR_R_MALLOC_FAILURE); - return NULL; - } - return memcpy(ret, data, siz); -} size_t OPENSSL_strnlen(const char *str, size_t maxlen) { @@ -141,83 +84,6 @@ int OPENSSL_hexchar2int(unsigned char c) return -1; } -/* - * Give a string of hex digits convert to a buffer - */ -unsigned char *OPENSSL_hexstr2buf(const char *str, long *len) -{ - unsigned char *hexbuf, *q; - unsigned char ch, cl; - int chi, cli; - const unsigned char *p; - size_t s; - - s = strlen(str); - if ((hexbuf = OPENSSL_malloc(s >> 1)) == NULL) { - CRYPTOerr(CRYPTO_F_OPENSSL_HEXSTR2BUF, ERR_R_MALLOC_FAILURE); - return NULL; - } - for (p = (const unsigned char *)str, q = hexbuf; *p; ) { - ch = *p++; - if (ch == ':') - continue; - cl = *p++; - if (!cl) { - CRYPTOerr(CRYPTO_F_OPENSSL_HEXSTR2BUF, - CRYPTO_R_ODD_NUMBER_OF_DIGITS); - OPENSSL_free(hexbuf); - return NULL; - } - cli = OPENSSL_hexchar2int(cl); - chi = OPENSSL_hexchar2int(ch); - if (cli < 0 || chi < 0) { - OPENSSL_free(hexbuf); - CRYPTOerr(CRYPTO_F_OPENSSL_HEXSTR2BUF, CRYPTO_R_ILLEGAL_HEX_DIGIT); - return NULL; - } - *q++ = (unsigned char)((chi << 4) | cli); - } - - if (len) - *len = q - hexbuf; - return hexbuf; -} - -/* - * Given a buffer of length 'len' return a OPENSSL_malloc'ed string with its - * hex representation @@@ (Contents of buffer are always kept in ASCII, also - * on EBCDIC machines) - */ -char *OPENSSL_buf2hexstr(const unsigned char *buffer, long len) -{ - static const char hexdig[] = "0123456789ABCDEF"; - char *tmp, *q; - const unsigned char *p; - int i; - - if (len == 0) - { - return OPENSSL_zalloc(1); - } - - if ((tmp = OPENSSL_malloc(len * 3)) == NULL) { - CRYPTOerr(CRYPTO_F_OPENSSL_BUF2HEXSTR, ERR_R_MALLOC_FAILURE); - return NULL; - } - q = tmp; - for (i = 0, p = buffer; i < len; i++, p++) { - *q++ = hexdig[(*p >> 4) & 0xf]; - *q++ = hexdig[*p & 0xf]; - *q++ = ':'; - } - q[-1] = 0; -#ifdef CHARSET_EBCDIC - ebcdic2ascii(tmp, tmp, q - tmp - 1); -#endif - - return tmp; -} - int openssl_strerror_r(int errnum, char *buf, size_t buflen) { #if defined(_MSC_VER) && _MSC_VER>=1400 @@ -231,7 +97,7 @@ int openssl_strerror_r(int errnum, char *buf, size_t buflen) * buf is left unused. */ err = strerror_r(errnum, buf, buflen); - if (err == NULL) + if (err == NULL || buflen == 0) return 0; /* * If err is statically allocated, err != buf and we need to copy the data. diff --git a/crypto/objects/obj_dat.h b/crypto/objects/obj_dat.h index 0e825e5b..8b3737f3 100644 --- a/crypto/objects/obj_dat.h +++ b/crypto/objects/obj_dat.h @@ -10,7 +10,7 @@ */ /* Serialized OID's */ -static const unsigned char so[7775] = { +static const unsigned char so[7813] = { 0x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 0] OBJ_rsadsi */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 6] OBJ_pkcs */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 13] OBJ_md2 */ @@ -1077,10 +1077,14 @@ static const unsigned char so[7775] = { 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0C, /* [ 7745] OBJ_hmacWithSHA512_224 */ 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0D, /* [ 7753] OBJ_hmacWithSHA512_256 */ 0x28,0xCC,0x45,0x03,0x04, /* [ 7761] OBJ_gmac */ - 0x2A,0x81,0x1C,0xCF,0x55,0x01,0x83,0x75, /* [ 7766] OBJ_SM2_with_SM3 */ + 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x13, /* [ 7766] OBJ_kmac128 */ + 0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x14, /* [ 7775] OBJ_kmac256 */ + 0x2B,0x06,0x01,0x04,0x01,0x8D,0x3A,0x0C,0x02,0x01, /* [ 7784] OBJ_blake2bmac */ + 0x2B,0x06,0x01,0x04,0x01,0x8D,0x3A,0x0C,0x02,0x02, /* [ 7794] OBJ_blake2smac */ + 0x2A,0x81,0x1C,0xCF,0x55,0x01,0x83,0x75, /* [ 7804] OBJ_SM2_with_SM3 */ }; -#define NUM_NID 1208 +#define NUM_NID 1209 static const ASN1_OBJECT nid_objs[NUM_NID] = { {"UNDEF", "undefined", NID_undef}, {"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]}, @@ -2278,21 +2282,22 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = { {"hmacWithSHA512-224", "hmacWithSHA512-224", NID_hmacWithSHA512_224, 8, &so[7745]}, {"hmacWithSHA512-256", "hmacWithSHA512-256", NID_hmacWithSHA512_256, 8, &so[7753]}, {"GMAC", "gmac", NID_gmac, 5, &so[7761]}, - {"KMAC128", "kmac128", NID_kmac128}, - {"KMAC256", "kmac256", NID_kmac256}, + {"KMAC128", "kmac128", NID_kmac128, 9, &so[7766]}, + {"KMAC256", "kmac256", NID_kmac256, 9, &so[7775]}, {"AES-128-SIV", "aes-128-siv", NID_aes_128_siv}, {"AES-192-SIV", "aes-192-siv", NID_aes_192_siv}, {"AES-256-SIV", "aes-256-siv", NID_aes_256_siv}, - {"BLAKE2BMAC", "blake2bmac", NID_blake2bmac}, - {"BLAKE2SMAC", "blake2smac", NID_blake2smac}, + {"BLAKE2BMAC", "blake2bmac", NID_blake2bmac, 10, &so[7784]}, + {"BLAKE2SMAC", "blake2smac", NID_blake2smac, 10, &so[7794]}, {"SSHKDF", "sshkdf", NID_sshkdf}, - {"SM2-SM3", "SM2-with-SM3", NID_SM2_with_SM3, 8, &so[7766]}, + {"SM2-SM3", "SM2-with-SM3", NID_SM2_with_SM3, 8, &so[7804]}, {"SSKDF", "sskdf", NID_sskdf}, {"X963KDF", "x963kdf", NID_x963kdf}, + {"X942KDF", "x942kdf", NID_x942kdf}, {"ChaCha20-Poly1305-D", "chacha20-poly1305-draft", NID_chacha20_poly1305_draft}, }; -#define NUM_SN 1199 +#define NUM_SN 1200 static const unsigned int sn_objs[NUM_SN] = { 364, /* "AD_DVCS" */ 419, /* "AES-128-CBC" */ @@ -2415,7 +2420,7 @@ static const unsigned int sn_objs[NUM_SN] = { 417, /* "CSPName" */ 1019, /* "ChaCha20" */ 1018, /* "ChaCha20-Poly1305" */ - 1207, /* "ChaCha20-Poly1305-D" */ + 1208, /* "ChaCha20-Poly1305-D" */ 367, /* "CrlID" */ 391, /* "DC" */ 31, /* "DES-CBC" */ @@ -2594,6 +2599,7 @@ static const unsigned int sn_objs[NUM_SN] = { 378, /* "X500algorithms" */ 12, /* "X509" */ 184, /* "X9-57" */ + 1207, /* "X942KDF" */ 1206, /* "X963KDF" */ 185, /* "X9cm" */ 125, /* "ZLIB" */ @@ -3495,7 +3501,7 @@ static const unsigned int sn_objs[NUM_SN] = { 1093, /* "x509ExtAdmission" */ }; -#define NUM_LN 1199 +#define NUM_LN 1200 static const unsigned int ln_objs[NUM_LN] = { 363, /* "AD Time Stamping" */ 405, /* "ANSI X9.62" */ @@ -3880,7 +3886,7 @@ static const unsigned int ln_objs[NUM_LN] = { 883, /* "certificateRevocationList" */ 1019, /* "chacha20" */ 1018, /* "chacha20-poly1305" */ - 1207, /* "chacha20-poly1305-draft" */ + 1208, /* "chacha20-poly1305-draft" */ 54, /* "challengePassword" */ 407, /* "characteristic-two-field" */ 395, /* "clearance" */ @@ -4694,11 +4700,12 @@ static const unsigned int ln_objs[NUM_LN] = { 503, /* "x500UniqueIdentifier" */ 158, /* "x509Certificate" */ 160, /* "x509Crl" */ + 1207, /* "x942kdf" */ 1206, /* "x963kdf" */ 125, /* "zlib compression" */ }; -#define NUM_OBJ 1073 +#define NUM_OBJ 1077 static const unsigned int obj_objs[NUM_OBJ] = { 0, /* OBJ_undef 0 */ 181, /* OBJ_iso 1 */ @@ -5550,6 +5557,8 @@ static const unsigned int obj_objs[NUM_OBJ] = { 1103, /* OBJ_hmac_sha3_256 2 16 840 1 101 3 4 2 14 */ 1104, /* OBJ_hmac_sha3_384 2 16 840 1 101 3 4 2 15 */ 1105, /* OBJ_hmac_sha3_512 2 16 840 1 101 3 4 2 16 */ + 1196, /* OBJ_kmac128 2 16 840 1 101 3 4 2 19 */ + 1197, /* OBJ_kmac256 2 16 840 1 101 3 4 2 20 */ 802, /* OBJ_dsa_with_SHA224 2 16 840 1 101 3 4 3 1 */ 803, /* OBJ_dsa_with_SHA256 2 16 840 1 101 3 4 3 2 */ 1106, /* OBJ_dsa_with_SHA384 2 16 840 1 101 3 4 3 3 */ @@ -5667,6 +5676,8 @@ static const unsigned int obj_objs[NUM_OBJ] = { 138, /* OBJ_ms_efs 1 3 6 1 4 1 311 10 3 4 */ 648, /* OBJ_ms_smartcard_login 1 3 6 1 4 1 311 20 2 2 */ 649, /* OBJ_ms_upn 1 3 6 1 4 1 311 20 2 3 */ + 1201, /* OBJ_blake2bmac 1 3 6 1 4 1 1722 12 2 1 */ + 1202, /* OBJ_blake2smac 1 3 6 1 4 1 1722 12 2 2 */ 951, /* OBJ_ct_precert_scts 1 3 6 1 4 1 11129 2 4 2 */ 952, /* OBJ_ct_precert_poison 1 3 6 1 4 1 11129 2 4 3 */ 953, /* OBJ_ct_precert_signer 1 3 6 1 4 1 11129 2 4 4 */ diff --git a/crypto/objects/obj_mac.num b/crypto/objects/obj_mac.num index 957a28d4..4751e561 100644 --- a/crypto/objects/obj_mac.num +++ b/crypto/objects/obj_mac.num @@ -1204,4 +1204,5 @@ sshkdf 1203 SM2_with_SM3 1204 sskdf 1205 x963kdf 1206 -chacha20_poly1305_draft 1207 +x942kdf 1207 +chacha20_poly1305_draft 1208 diff --git a/crypto/objects/objects.txt b/crypto/objects/objects.txt index 92f235d5..660bcd85 100644 --- a/crypto/objects/objects.txt +++ b/crypto/objects/objects.txt @@ -14,12 +14,6 @@ iso 3 : identified-organization # GMAC OID iso 0 9797 3 4 : GMAC : gmac -# There are no OIDs for these yet... - : KMAC128 : kmac128 - : KMAC256 : kmac256 - : BLAKE2BMAC : blake2bmac - : BLAKE2SMAC : blake2smac - # HMAC OIDs identified-organization 6 1 5 5 8 1 1 : HMAC-MD5 : hmac-md5 identified-organization 6 1 5 5 8 1 2 : HMAC-SHA1 : hmac-sha1 @@ -709,8 +703,10 @@ algorithm 29 : RSA-SHA1-2 : sha1WithRSA 1 3 36 3 2 1 : RIPEMD160 : ripemd160 1 3 36 3 3 1 2 : RSA-RIPEMD160 : ripemd160WithRSA -1 3 6 1 4 1 1722 12 2 1 16 : BLAKE2b512 : blake2b512 -1 3 6 1 4 1 1722 12 2 2 8 : BLAKE2s256 : blake2s256 +1 3 6 1 4 1 1722 12 2 1 : BLAKE2BMAC : blake2bmac +1 3 6 1 4 1 1722 12 2 2 : BLAKE2SMAC : blake2smac +blake2bmac 16 : BLAKE2b512 : blake2b512 +blake2smac 8 : BLAKE2s256 : blake2s256 !Cname sxnet 1 3 101 1 4 1 : SXNetID : Strong Extranet ID @@ -987,6 +983,10 @@ nist_hashalgs 16 : id-hmacWithSHA3-512 : hmac-sha3-512 # how to handle them... # nist_hashalgs 17 : id-shake128-len : shake128-len # nist_hashalgs 18 : id-shake256-len : shake256-len +nist_hashalgs 19 : KMAC128 : kmac128 +nist_hashalgs 20 : KMAC256 : kmac256 +# nist_hashalgs 21 : KMAC128-XOF : kmac128-xof +# nist_hashalgs 22 : KMAC256-XOF : kmac256-xof # OIDs for dsa-with-sha224 and dsa-with-sha256 !Alias dsa_with_sha2 nistAlgorithms 3 @@ -1617,6 +1617,8 @@ secg-scheme 14 3 : dhSinglePass-cofactorDH-sha512kdf-scheme # NID for SSKDF : SSKDF : sskdf +# NID for X942KDF + : X942KDF : x942kdf # NID for X963-2001 KDF : X963KDF : x963kdf diff --git a/crypto/ocsp/v3_ocsp.c b/crypto/ocsp/v3_ocsp.c index c58fa07b..2e4503ee 100644 --- a/crypto/ocsp/v3_ocsp.c +++ b/crypto/ocsp/v3_ocsp.c @@ -14,7 +14,7 @@ # include # include "ocsp_lcl.h" # include -# include "../x509v3/ext_dat.h" +# include "../x509/ext_dat.h" /* * OCSP extensions and a couple of CRL entry extensions diff --git a/crypto/params.c b/crypto/params.c index 183884fa..0c9e6f3e 100644 --- a/crypto/params.c +++ b/crypto/params.c @@ -12,11 +12,7 @@ #include #include "internal/thread_once.h" -#define SET_RETURN_SIZE(p, sz) \ - if ((p)->return_size != NULL) \ - *(p)->return_size = (sz) - -const OSSL_PARAM *OSSL_PARAM_locate(const OSSL_PARAM *p, const char *key) +OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *p, const char *key) { if (p != NULL && key != NULL) for (; p->key != NULL; p++) @@ -25,9 +21,13 @@ const OSSL_PARAM *OSSL_PARAM_locate(const OSSL_PARAM *p, const char *key) return NULL; } +const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *p, const char *key) +{ + return OSSL_PARAM_locate((OSSL_PARAM *)p, key); +} + static OSSL_PARAM ossl_param_construct(const char *key, unsigned int data_type, - void *data, size_t data_size, - size_t *return_size) + void *data, size_t data_size) { OSSL_PARAM res; @@ -35,7 +35,7 @@ static OSSL_PARAM ossl_param_construct(const char *key, unsigned int data_type, res.data_type = data_type; res.data = data; res.data_size = data_size; - res.return_size = return_size; + res.return_size = 0; return res; } @@ -50,7 +50,7 @@ int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val) return 0; } -int OSSL_PARAM_set_int(const OSSL_PARAM *p, int val) +int OSSL_PARAM_set_int(OSSL_PARAM *p, int val) { switch (sizeof(int)) { case sizeof(int32_t): @@ -61,10 +61,9 @@ int OSSL_PARAM_set_int(const OSSL_PARAM *p, int val) return 0; } -OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf, size_t *rsize) +OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf) { - return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int), - rsize); + return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int)); } int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val) @@ -78,7 +77,7 @@ int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val) return 0; } -int OSSL_PARAM_set_uint(const OSSL_PARAM *p, unsigned int val) +int OSSL_PARAM_set_uint(OSSL_PARAM *p, unsigned int val) { switch (sizeof(unsigned int)) { case sizeof(uint32_t): @@ -89,11 +88,10 @@ int OSSL_PARAM_set_uint(const OSSL_PARAM *p, unsigned int val) return 0; } -OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf, - size_t *rsize) +OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf) { return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf, - sizeof(unsigned int), rsize); + sizeof(unsigned int)); } int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val) @@ -107,7 +105,7 @@ int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val) return 0; } -int OSSL_PARAM_set_long(const OSSL_PARAM *p, long int val) +int OSSL_PARAM_set_long(OSSL_PARAM *p, long int val) { switch (sizeof(long int)) { case sizeof(int32_t): @@ -118,11 +116,9 @@ int OSSL_PARAM_set_long(const OSSL_PARAM *p, long int val) return 0; } -OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf, - size_t *rsize) +OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf) { - return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(long int), - rsize); + return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(long int)); } int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val) @@ -136,7 +132,7 @@ int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val) return 0; } -int OSSL_PARAM_set_ulong(const OSSL_PARAM *p, unsigned long int val) +int OSSL_PARAM_set_ulong(OSSL_PARAM *p, unsigned long int val) { switch (sizeof(unsigned long int)) { case sizeof(uint32_t): @@ -147,11 +143,10 @@ int OSSL_PARAM_set_ulong(const OSSL_PARAM *p, unsigned long int val) return 0; } -OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf, - size_t *rsize) +OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf) { return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf, - sizeof(unsigned long int), rsize); + sizeof(unsigned long int)); } int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val) @@ -208,35 +203,35 @@ int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val) return 0; } -int OSSL_PARAM_set_int32(const OSSL_PARAM *p, int32_t val) +int OSSL_PARAM_set_int32(OSSL_PARAM *p, int32_t val) { if (p == NULL) return 0; - SET_RETURN_SIZE(p, 0); + p->return_size = 0; if (p->data_type == OSSL_PARAM_INTEGER) { - SET_RETURN_SIZE(p, sizeof(int32_t)); /* Minimum expected size */ + p->return_size = sizeof(int32_t); /* Minimum expected size */ switch (p->data_size) { case sizeof(int32_t): *(int32_t *)p->data = val; return 1; case sizeof(int64_t): - SET_RETURN_SIZE(p, sizeof(int64_t)); + p->return_size = sizeof(int64_t); *(int64_t *)p->data = (int64_t)val; return 1; } } else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER && val >= 0) { - SET_RETURN_SIZE(p, sizeof(uint32_t)); /* Minimum expected size */ + p->return_size = sizeof(uint32_t); /* Minimum expected size */ switch (p->data_size) { case sizeof(uint32_t): *(uint32_t *)p->data = (uint32_t)val; return 1; case sizeof(uint64_t): - SET_RETURN_SIZE(p, sizeof(uint64_t)); + p->return_size = sizeof(uint64_t); *(uint64_t *)p->data = (uint64_t)val; return 1; } } else if (p->data_type == OSSL_PARAM_REAL) { - SET_RETURN_SIZE(p, sizeof(double)); + p->return_size = sizeof(double); switch (p->data_size) { case sizeof(double): *(double *)p->data = (double)val; @@ -246,11 +241,10 @@ int OSSL_PARAM_set_int32(const OSSL_PARAM *p, int32_t val) return 0; } -OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf, - size_t *rsize) +OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf) { return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, - sizeof(int32_t), rsize); + sizeof(int32_t)); } int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val) @@ -307,25 +301,25 @@ int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val) return 0; } -int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val) +int OSSL_PARAM_set_uint32(OSSL_PARAM *p, uint32_t val) { if (p == NULL) return 0; - SET_RETURN_SIZE(p, 0); + p->return_size = 0; if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) { - SET_RETURN_SIZE(p, sizeof(uint32_t)); /* Minimum expected size */ + p->return_size = sizeof(uint32_t); /* Minimum expected size */ switch (p->data_size) { case sizeof(uint32_t): *(uint32_t *)p->data = val; return 1; case sizeof(uint64_t): - SET_RETURN_SIZE(p, sizeof(uint64_t)); + p->return_size = sizeof(uint64_t); *(uint64_t *)p->data = val; return 1; } } else if (p->data_type == OSSL_PARAM_INTEGER) { - SET_RETURN_SIZE(p, sizeof(int32_t)); /* Minimum expected size */ + p->return_size = sizeof(int32_t); /* Minimum expected size */ switch (p->data_size) { case sizeof(int32_t): if (val <= INT32_MAX) { @@ -334,12 +328,12 @@ int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val) } break; case sizeof(int64_t): - SET_RETURN_SIZE(p, sizeof(int64_t)); + p->return_size = sizeof(int64_t); *(int64_t *)p->data = (int64_t)val; return 1; } } else if (p->data_type == OSSL_PARAM_REAL) { - SET_RETURN_SIZE(p, sizeof(double)); + p->return_size = sizeof(double); switch (p->data_size) { case sizeof(double): *(double *)p->data = (double)val; @@ -349,11 +343,10 @@ int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val) return 0; } -OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf, - size_t *rsize) +OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf) { return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf, - sizeof(uint32_t), rsize); + sizeof(uint32_t)); } int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val) @@ -400,19 +393,19 @@ int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val) return 0; } -int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val) +int OSSL_PARAM_set_int64(OSSL_PARAM *p, int64_t val) { uint64_t u64; if (p == NULL) return 0; - SET_RETURN_SIZE(p, 0); + p->return_size = 0; if (p->data_type == OSSL_PARAM_INTEGER) { - SET_RETURN_SIZE(p, sizeof(int64_t)); /* Expected size */ + p->return_size = sizeof(int64_t); /* Expected size */ switch (p->data_size) { case sizeof(int32_t): if (val >= INT32_MIN && val <= INT32_MAX) { - SET_RETURN_SIZE(p, sizeof(int32_t)); + p->return_size = sizeof(int32_t); *(int32_t *)p->data = (int32_t)val; return 1; } @@ -422,11 +415,11 @@ int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val) return 1; } } else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER && val >= 0) { - SET_RETURN_SIZE(p, sizeof(uint64_t)); /* Expected size */ + p->return_size = sizeof(uint64_t); /* Expected size */ switch (p->data_size) { case sizeof(uint32_t): if (val <= UINT32_MAX) { - SET_RETURN_SIZE(p, sizeof(uint32_t)); + p->return_size = sizeof(uint32_t); *(uint32_t *)p->data = (uint32_t)val; return 1; } @@ -436,7 +429,7 @@ int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val) return 1; } } else if (p->data_type == OSSL_PARAM_REAL) { - SET_RETURN_SIZE(p, sizeof(double)); + p->return_size = sizeof(double); switch (p->data_size) { case sizeof(double): u64 = val < 0 ? -val : val; @@ -450,11 +443,9 @@ int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val) return 0; } -OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf, - size_t *rsize) +OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf) { - return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int64_t), - rsize); + return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int64_t)); } int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val) @@ -506,18 +497,18 @@ int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val) return 0; } -int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val) +int OSSL_PARAM_set_uint64(OSSL_PARAM *p, uint64_t val) { if (p == NULL) return 0; - SET_RETURN_SIZE(p, 0); + p->return_size = 0; if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) { - SET_RETURN_SIZE(p, sizeof(uint64_t)); /* Expected size */ + p->return_size = sizeof(uint64_t); /* Expected size */ switch (p->data_size) { case sizeof(uint32_t): if (val <= UINT32_MAX) { - SET_RETURN_SIZE(p, sizeof(uint32_t)); + p->return_size = sizeof(uint32_t); *(uint32_t *)p->data = (uint32_t)val; return 1; } @@ -527,11 +518,11 @@ int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val) return 1; } } else if (p->data_type == OSSL_PARAM_INTEGER) { - SET_RETURN_SIZE(p, sizeof(int64_t)); /* Expected size */ + p->return_size = sizeof(int64_t); /* Expected size */ switch (p->data_size) { case sizeof(int32_t): if (val <= INT32_MAX) { - SET_RETURN_SIZE(p, sizeof(int32_t)); + p->return_size = sizeof(int32_t); *(int32_t *)p->data = (int32_t)val; return 1; } @@ -544,7 +535,7 @@ int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val) break; } } else if (p->data_type == OSSL_PARAM_REAL) { - SET_RETURN_SIZE(p, sizeof(double)); + p->return_size = sizeof(double); switch (p->data_size) { case sizeof(double): if ((val >> 53) == 0) { /* 53 significant bits in the mantissa */ @@ -557,10 +548,10 @@ int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val) return 0; } -OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf, - size_t *rsize) { +OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf) +{ return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf, - sizeof(uint64_t), rsize); + sizeof(uint64_t)); } int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val) @@ -574,7 +565,7 @@ int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val) return 0; } -int OSSL_PARAM_set_size_t(const OSSL_PARAM *p, size_t val) +int OSSL_PARAM_set_size_t(OSSL_PARAM *p, size_t val) { switch (sizeof(size_t)) { case sizeof(uint32_t): @@ -585,11 +576,11 @@ int OSSL_PARAM_set_size_t(const OSSL_PARAM *p, size_t val) return 0; } -OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf, - size_t *rsize) +OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf) { return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf, - sizeof(size_t), rsize); } + sizeof(size_t)); +} #ifndef FIPS_MODE /* @@ -615,13 +606,13 @@ int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val) return 0; } -int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const BIGNUM *val) +int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val) { size_t bytes; if (p == NULL) return 0; - SET_RETURN_SIZE(p, 0); + p->return_size = 0; if (val == NULL || p->data_type != OSSL_PARAM_UNSIGNED_INTEGER) return 0; @@ -630,16 +621,16 @@ int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const BIGNUM *val) return 0; bytes = (size_t)BN_num_bytes(val); - SET_RETURN_SIZE(p, bytes); + p->return_size = bytes; return p->data_size >= bytes && BN_bn2nativepad(val, p->data, bytes) >= 0; } OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf, - size_t bsize, size_t *rsize) + size_t bsize) { return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, - buf, bsize, rsize); + buf, bsize); } #endif @@ -688,14 +679,14 @@ int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val) return 0; } -int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val) +int OSSL_PARAM_set_double(OSSL_PARAM *p, double val) { if (p == NULL) return 0; - SET_RETURN_SIZE(p, 0); + p->return_size = 0; if (p->data_type == OSSL_PARAM_REAL) { - SET_RETURN_SIZE(p, sizeof(double)); + p->return_size = sizeof(double); switch (p->data_size) { case sizeof(double): *(double *)p->data = val; @@ -703,35 +694,35 @@ int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val) } } else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER && val == (uintmax_t)val) { - SET_RETURN_SIZE(p, sizeof(double)); + p->return_size = sizeof(double); switch (p->data_size) { case sizeof(uint32_t): if (val >= 0 && val <= UINT32_MAX) { - SET_RETURN_SIZE(p, sizeof(uint32_t)); + p->return_size = sizeof(uint32_t); *(uint32_t *)p->data = (uint32_t)val; return 1; } break; case sizeof(uint64_t): if (val >= 0 && val <= UINT64_MAX) { - SET_RETURN_SIZE(p, sizeof(uint64_t)); + p->return_size = sizeof(uint64_t); *(uint64_t *)p->data = (uint64_t)val; return 1; } break; } } else if (p->data_type == OSSL_PARAM_INTEGER && val == (intmax_t)val) { - SET_RETURN_SIZE(p, sizeof(double)); + p->return_size = sizeof(double); switch (p->data_size) { case sizeof(int32_t): if (val >= INT32_MIN && val <= INT32_MAX) { - SET_RETURN_SIZE(p, sizeof(int32_t)); + p->return_size = sizeof(int32_t); *(int32_t *)p->data = (int32_t)val; return 1; } break; case sizeof(int64_t): if (val >= INT64_MIN && val <= INT64_MAX) { - SET_RETURN_SIZE(p, sizeof(int64_t)); + p->return_size = sizeof(int64_t); *(int64_t *)p->data = (int64_t)val; return 1; } @@ -741,11 +732,9 @@ int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val) return 0; } -OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf, - size_t *rsize) +OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf) { - return ossl_param_construct(key, OSSL_PARAM_REAL, buf, sizeof(double), - rsize); + return ossl_param_construct(key, OSSL_PARAM_REAL, buf, sizeof(double)); } static int get_string_internal(const OSSL_PARAM *p, void **val, size_t max_len, @@ -789,10 +778,10 @@ int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len, OSSL_PARAM_OCTET_STRING); } -static int set_string_internal(const OSSL_PARAM *p, const void *val, size_t len, +static int set_string_internal(OSSL_PARAM *p, const void *val, size_t len, unsigned int type) { - SET_RETURN_SIZE(p, len); + p->return_size = len; if (p->data_type != type || p->data_size < len) return 0; @@ -800,41 +789,39 @@ static int set_string_internal(const OSSL_PARAM *p, const void *val, size_t len, return 1; } -int OSSL_PARAM_set_utf8_string(const OSSL_PARAM *p, const char *val) +int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val) { if (p == NULL) return 0; - SET_RETURN_SIZE(p, 0); + p->return_size = 0; if (val == NULL) return 0; return set_string_internal(p, val, strlen(val) + 1, OSSL_PARAM_UTF8_STRING); } -int OSSL_PARAM_set_octet_string(const OSSL_PARAM *p, const void *val, +int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len) { if (p == NULL) return 0; - SET_RETURN_SIZE(p, 0); + p->return_size = 0; if (val == NULL) return 0; return set_string_internal(p, val, len, OSSL_PARAM_OCTET_STRING); } OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, - size_t bsize, size_t *rsize) + size_t bsize) { - return ossl_param_construct(key, OSSL_PARAM_UTF8_STRING, buf, bsize, - rsize); + return ossl_param_construct(key, OSSL_PARAM_UTF8_STRING, buf, bsize); } OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, - size_t bsize, size_t *rsize) + size_t bsize) { - return ossl_param_construct(key, OSSL_PARAM_OCTET_STRING, buf, bsize, - rsize); + return ossl_param_construct(key, OSSL_PARAM_OCTET_STRING, buf, bsize); } static int get_ptr_internal(const OSSL_PARAM *p, const void **val, @@ -859,47 +846,47 @@ int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val, return get_ptr_internal(p, val, used_len, OSSL_PARAM_OCTET_PTR); } -static int set_ptr_internal(const OSSL_PARAM *p, const void *val, +static int set_ptr_internal(OSSL_PARAM *p, const void *val, unsigned int type, size_t len) { - SET_RETURN_SIZE(p, len); + p->return_size = len; if (p->data_type != type) return 0; *(const void **)p->data = val; return 1; } -int OSSL_PARAM_set_utf8_ptr(const OSSL_PARAM *p, const char *val) +int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val) { if (p == NULL) return 0; - SET_RETURN_SIZE(p, 0); + p->return_size = 0; if (val == NULL) return 0; return set_ptr_internal(p, val, OSSL_PARAM_UTF8_PTR, strlen(val) + 1); } -int OSSL_PARAM_set_octet_ptr(const OSSL_PARAM *p, const void *val, +int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val, size_t used_len) { if (p == NULL) return 0; - SET_RETURN_SIZE(p, 0); + p->return_size = 0; if (val == NULL) return 0; return set_ptr_internal(p, val, OSSL_PARAM_OCTET_PTR, used_len); } OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, - size_t bsize, size_t *rsize) + size_t bsize) { - return ossl_param_construct(key, OSSL_PARAM_UTF8_PTR, buf, bsize, rsize); + return ossl_param_construct(key, OSSL_PARAM_UTF8_PTR, buf, bsize); } OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, - size_t bsize, size_t *rsize) + size_t bsize) { - return ossl_param_construct(key, OSSL_PARAM_OCTET_PTR, buf, bsize, rsize); + return ossl_param_construct(key, OSSL_PARAM_OCTET_PTR, buf, bsize); } OSSL_PARAM OSSL_PARAM_construct_end(void) diff --git a/crypto/poly1305/asm/poly1305-ppc.pl b/crypto/poly1305/asm/poly1305-ppc.pl index 9f15c0d0..2770f5e7 100755 --- a/crypto/poly1305/asm/poly1305-ppc.pl +++ b/crypto/poly1305/asm/poly1305-ppc.pl @@ -969,15 +969,15 @@ __poly1305_blocks_vsx: addi $t1,$ctx,`48+(12^$BIG_ENDIAN)` bl __poly1305_splat - bl __poly1305_mul # caclulate r^2 + bl __poly1305_mul # calculate r^2 addi $t1,$ctx,`48+(4^$BIG_ENDIAN)` bl __poly1305_splat - bl __poly1305_mul # caclulate r^3 + bl __poly1305_mul # calculate r^3 addi $t1,$ctx,`48+(8^$BIG_ENDIAN)` bl __poly1305_splat - bl __poly1305_mul # caclulate r^4 + bl __poly1305_mul # calculate r^4 addi $t1,$ctx,`48+(0^$BIG_ENDIAN)` bl __poly1305_splat diff --git a/crypto/poly1305/build.info b/crypto/poly1305/build.info index 60eeeeec..064c2599 100644 --- a/crypto/poly1305/build.info +++ b/crypto/poly1305/build.info @@ -1,8 +1,36 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - poly1305_ameth.c \ - poly1305_meth.c \ - poly1305.c {- $target{poly1305_asm_src} -} + +$POLY1305ASM= +IF[{- !$disabled{asm} -}] + $POLY1305ASM_x86=poly1305-x86.s + $POLY1305ASM_x86_64=poly1305-x86_64.s + + $POLY1305ASM_ia64=asm/poly1305-ia64.S + + $POLY1305ASM_sparcv9=poly1305-sparcv9.S + + $POLY1305ASM_mips64=poly1305-mips.S + + $POLY1305ASM_s390x=poly1305-s390x.S + + $POLY1305ASM_armv4=poly1305-armv4.S + $POLY1305ASM_aarch64=poly1305-armv8.S + + $POLY1305ASM_ppc32=poly1305-ppc.s poly1305-ppcfp.s + $POLY1305ASM_ppc64=$POLY1305ASM_ppc32 + + $POLY1305ASM_c64xplus=poly1305-c64xplus.s + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$POLY1305ASM_{- $target{asm_arch} -}] + $POLY1305ASM=$POLY1305ASM_{- $target{asm_arch} -} + $POLY1305DEF=POLY1305_ASM + ENDIF +ENDIF + +SOURCE[../../libcrypto]=poly1305_ameth.c poly1305_meth.c poly1305.c $POLY1305ASM +DEFINE[../../libcrypto]=$POLY1305DEF GENERATE[poly1305-sparcv9.S]=asm/poly1305-sparcv9.pl $(PERLASM_SCHEME) INCLUDE[poly1305-sparcv9.o]=.. diff --git a/crypto/poly1305/poly1305_meth.c b/crypto/poly1305/poly1305_meth.c index 9248d460..f1ade58b 100644 --- a/crypto/poly1305/poly1305_meth.c +++ b/crypto/poly1305/poly1305_meth.c @@ -37,11 +37,17 @@ static void poly1305_free(EVP_MAC_IMPL *ctx) } } -static int poly1305_copy(EVP_MAC_IMPL *dst, EVP_MAC_IMPL *src) +static EVP_MAC_IMPL *poly1305_dup(const EVP_MAC_IMPL *src) { + EVP_MAC_IMPL *dst; + + dst = poly1305_new(); + if (dst == NULL) + return NULL; + *dst->ctx = *src->ctx; - return 1; + return dst; } static size_t poly1305_size(EVP_MAC_IMPL *ctx) @@ -130,7 +136,7 @@ static int poly1305_ctrl_str(EVP_MAC_IMPL *ctx, const EVP_MAC poly1305_meth = { EVP_MAC_POLY1305, poly1305_new, - poly1305_copy, + poly1305_dup, poly1305_free, poly1305_size, poly1305_init, diff --git a/crypto/ppccap.c b/crypto/ppccap.c index 0d5ab794..9109c4d3 100644 --- a/crypto/ppccap.c +++ b/crypto/ppccap.c @@ -38,6 +38,7 @@ unsigned int OPENSSL_ppccap_P = 0; static sigset_t all_masked; + #ifdef OPENSSL_BN_ASM_MONT int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num) @@ -64,7 +65,6 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, return bn_mul_mont_int(rp, ap, bp, np, n0, num); } #endif - void sha256_block_p8(void *ctx, const void *inp, size_t len); void sha256_block_ppc(void *ctx, const void *inp, size_t len); void sha256_block_data_order(void *ctx, const void *inp, size_t len); @@ -83,7 +83,12 @@ void sha512_block_data_order(void *ctx, const void *inp, size_t len) sha512_block_ppc(ctx, inp, len); } -#ifndef OPENSSL_NO_CHACHA +/* + * TODO(3.0): Temporarily disabled some assembler that hasn't been brought into + * the FIPS module yet. + */ +#ifndef FIPS_MODE +# ifndef OPENSSL_NO_CHACHA void ChaCha20_ctr32_int(unsigned char *out, const unsigned char *inp, size_t len, const unsigned int key[8], const unsigned int counter[4]); @@ -103,9 +108,9 @@ void ChaCha20_ctr32(unsigned char *out, const unsigned char *inp, ? ChaCha20_ctr32_vmx(out, inp, len, key, counter) : ChaCha20_ctr32_int(out, inp, len, key, counter); } -#endif +# endif -#ifndef OPENSSL_NO_POLY1305 +# ifndef OPENSSL_NO_POLY1305 void poly1305_init_int(void *ctx, const unsigned char key[16]); void poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, unsigned int padbit); @@ -139,9 +144,9 @@ int poly1305_init(void *ctx, const unsigned char key[16], void *func[2]) } return 1; } -#endif +# endif -#ifdef ECP_NISTZ256_ASM +# ifdef ECP_NISTZ256_ASM void ecp_nistz256_mul_mont(unsigned long res[4], const unsigned long a[4], const unsigned long b[4]); @@ -163,7 +168,8 @@ void ecp_nistz256_from_mont(unsigned long res[4], const unsigned long in[4]) ecp_nistz256_mul_mont(res, in, one); } -#endif +# endif +#endif /* FIPS_MODE */ static sigjmp_buf ill_jmp; static void ill_handler(int sig) diff --git a/crypto/property/build.info b/crypto/property/build.info index 3bdf307c..db3c9444 100644 --- a/crypto/property/build.info +++ b/crypto/property/build.info @@ -1,5 +1,4 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=property_string.c property_parse.c property.c \ - property_err.c defn_cache.c -SOURCE[../../providers/fips]=\ - property_string.c property_parse.c property.c defn_cache.c +$COMMON=property_string.c property_parse.c property.c defn_cache.c +SOURCE[../../libcrypto]=$COMMON property_err.c +SOURCE[../../providers/fips]=$COMMON diff --git a/crypto/property/properties.ebnf b/crypto/property/properties.ebnf index 0051c7e4..a55198bd 100644 --- a/crypto/property/properties.ebnf +++ b/crypto/property/properties.ebnf @@ -3,8 +3,8 @@ Definition ::= PropertyName ( '=' Value )? ( ',' PropertyName ( '=' Value )? )* Query ::= PropertyQuery ( ',' PropertyQuery )* -PropertyQuery ::= '-'? PropertyName - | '?' ( PropertyName (( '=' | '!=' ) Value)?) +PropertyQuery ::= '-' PropertyName + | '?'? ( PropertyName (( '=' | '!=' ) Value)?) Value ::= NumberLiteral | StringLiteral StringLiteral ::= QuotedString | UnquotedString diff --git a/crypto/property/properties.xhtml b/crypto/property/properties.xhtml deleted file mode 100755 index 766d885b..00000000 --- a/crypto/property/properties.xhtml +++ /dev/null @@ -1,733 +0,0 @@ - - - - - - - - - - - Definition: - - - - - - - - PropertyName - - = - - - Value - - , - - - - - -
         ::= PropertyName ( '=' Value )? ( ',' PropertyName ( '=' Value )? )*
-
- no referencesQuery: - - - - - - - - PropertyQuery - - , - - - - -
Query    ::= PropertyQuery ( ',' PropertyQuery )*
-
- no referencesPropertyQuery: - - - - - - - - - - - - PropertyName - - ? - - - PropertyName - - = - - - != - - - Value - - - - -
         ::= '-'? PropertyName
-
           | '?' PropertyName ( ( '=' | '!=' ) Value )?
-
- referenced by: - - Query - - Value: - - - - - - - - NumberLiteral - - - StringLiteral - - - -
Value    ::= NumberLiteral
-
           | StringLiteral
-
- referenced by: - - Definition - PropertyQuery - - StringLiteral: - - - - - - - - QuotedString - - - UnquotedString - - - - -
         ::= QuotedString
-
           | UnquotedString
-
- referenced by: - - Value - - QuotedString: - - - - - - - - " - - - [^"] - - - " - - - ' - - - [^'] - - - ' - - - - - -
         ::= '"' [^"]* '"'
-
           | "'" [^']* "'"
-
- referenced by: - - StringLiteral - - UnquotedString: - - - - - - - - [^{space},] - - - - - -
         ::= [^{space},]+
-
- referenced by: - - StringLiteral - - NumberLiteral: - - - - - - - - 0 - - - [0-7] - - - x - - - [0-9] - - - [A-F] - - - [a-f] - - - - - - - [1-9] - - - [0-9] - - - - - -
         ::= '0' ( [0-7]* | 'x' [0-9A-Fa-f]+ )
-
           | '-'? [1-9] [0-9]+
-
- referenced by: - - Value - - PropertyName: - - - - - - - - [A-Z] - - - [A-Z] - - - [0-9] - - - _ - - - . - - - - - -
         ::= [A-Z] [A-Z0-9_]* ( '.' [A-Z] [A-Z0-9_]* )*
-
- referenced by: - - Definition - PropertyQuery - - - - - -   - - ... generated by Railroad Diagram Generator - - - - - - - - R - R - - - - - - \ No newline at end of file diff --git a/crypto/property/property_parse.c b/crypto/property/property_parse.c index c63a433d..0b4dcfc8 100644 --- a/crypto/property/property_parse.c +++ b/crypto/property/property_parse.c @@ -92,6 +92,7 @@ static int parse_name(OPENSSL_CTX *ctx, const char *t[], int create, for (;;) { if (!ossl_isalpha(*s)) { PROPerr(PROP_F_PARSE_NAME, PROP_R_NOT_AN_IDENTIFIER); + ERR_add_error_data(2, "HERE-->", *t); return 0; } do { @@ -110,13 +111,14 @@ static int parse_name(OPENSSL_CTX *ctx, const char *t[], int create, s++; } name[i] = '\0'; - *t = skip_space(s); - if (!err) { - *idx = ossl_property_name(ctx, name, user_name && create); - return 1; + if (err) { + PROPerr(PROP_F_PARSE_NAME, PROP_R_NAME_TOO_LONG); + ERR_add_error_data(2, "HERE-->", *t); + return 0; } - PROPerr(PROP_F_PARSE_NAME, PROP_R_NAME_TOO_LONG); - return 0; + *t = skip_space(s); + *idx = ossl_property_name(ctx, name, user_name && create); + return 1; } static int parse_number(const char *t[], PROPERTY_DEFINITION *res) @@ -131,6 +133,7 @@ static int parse_number(const char *t[], PROPERTY_DEFINITION *res) } while (ossl_isdigit(*s)); if (!ossl_isspace(*s) && *s != '\0' && *s != ',') { PROPerr(PROP_F_PARSE_NUMBER, PROP_R_NOT_A_DECIMAL_DIGIT); + ERR_add_error_data(2, "HERE-->", *t); return 0; } *t = skip_space(s); @@ -155,6 +158,7 @@ static int parse_hex(const char *t[], PROPERTY_DEFINITION *res) } while (ossl_isxdigit(*++s)); if (!ossl_isspace(*s) && *s != '\0' && *s != ',') { PROPerr(PROP_F_PARSE_HEX, PROP_R_NOT_AN_HEXADECIMAL_DIGIT); + ERR_add_error_data(2, "HERE-->", *t); return 0; } *t = skip_space(s); @@ -175,6 +179,7 @@ static int parse_oct(const char *t[], PROPERTY_DEFINITION *res) } while (ossl_isdigit(*++s) && *s != '9' && *s != '8'); if (!ossl_isspace(*s) && *s != '\0' && *s != ',') { PROPerr(PROP_F_PARSE_OCT, PROP_R_NOT_AN_OCTAL_DIGIT); + ERR_add_error_data(2, "HERE-->", *t); return 0; } *t = skip_space(s); @@ -199,16 +204,22 @@ static int parse_string(OPENSSL_CTX *ctx, const char *t[], char delim, s++; } if (*s == '\0') { + char buf[2] = { 0, 0 }; + PROPerr(PROP_F_PARSE_STRING, PROP_R_NO_MATCHING_STRING_DELIMETER); + buf[0] = delim; + ERR_add_error_data(3, "HERE-->", buf, *t); return 0; } v[i] = '\0'; - *t = skip_space(s + 1); - if (err) + if (err) { PROPerr(PROP_F_PARSE_STRING, PROP_R_STRING_TOO_LONG); - else + ERR_add_error_data(2, "HERE-->", *t); + } else { res->v.str_val = ossl_property_value(ctx, v, create); + } + *t = skip_space(s + 1); res->type = PROPERTY_TYPE_STRING; return !err; } @@ -232,14 +243,17 @@ static int parse_unquoted(OPENSSL_CTX *ctx, const char *t[], } if (!ossl_isspace(*s) && *s != '\0' && *s != ',') { PROPerr(PROP_F_PARSE_UNQUOTED, PROP_R_NOT_AN_ASCII_CHARACTER); + ERR_add_error_data(2, "HERE-->", s); return 0; } v[i] = 0; - *t = skip_space(s); - if (err) + if (err) { PROPerr(PROP_F_PARSE_UNQUOTED, PROP_R_STRING_TOO_LONG); - else + ERR_add_error_data(2, "HERE-->", *t); + } else { res->v.str_val = ossl_property_value(ctx, v, create); + } + *t = skip_space(s); res->type = PROPERTY_TYPE_STRING; return !err; } @@ -333,6 +347,8 @@ OSSL_PROPERTY_LIST *ossl_parse_property(OPENSSL_CTX *ctx, const char *defn) s = skip_space(s); done = *s == '\0'; while (!done) { + const char *start = s; + prop = OPENSSL_malloc(sizeof(*prop)); if (prop == NULL) goto err; @@ -343,11 +359,13 @@ OSSL_PROPERTY_LIST *ossl_parse_property(OPENSSL_CTX *ctx, const char *defn) prop->oper = PROPERTY_OPER_EQ; if (prop->name_idx == 0) { PROPerr(PROP_F_OSSL_PARSE_PROPERTY, PROP_R_PARSE_FAILED); + ERR_add_error_data(2, "Unknown name HERE-->", start); goto err; } if (match_ch(&s, '=')) { if (!parse_value(ctx, &s, prop, 1)) { PROPerr(PROP_F_OSSL_PARSE_PROPERTY, PROP_R_NO_VALUE); + ERR_add_error_data(2, "HERE-->", start); goto err; } } else { @@ -363,6 +381,7 @@ OSSL_PROPERTY_LIST *ossl_parse_property(OPENSSL_CTX *ctx, const char *defn) } if (*s != '\0') { PROPerr(PROP_F_OSSL_PARSE_PROPERTY, PROP_R_TRAILING_CHARACTERS); + ERR_add_error_data(2, "HERE-->", s); goto err; } res = stack_to_property_list(sk); @@ -424,6 +443,7 @@ skip_value: } if (*s != '\0') { PROPerr(PROP_F_OSSL_PARSE_QUERY, PROP_R_TRAILING_CHARACTERS); + ERR_add_error_data(2, "HERE-->", s); goto err; } res = stack_to_property_list(sk); diff --git a/crypto/provider.c b/crypto/provider.c index 823d5dd5..4e21bfe6 100644 --- a/crypto/provider.c +++ b/crypto/provider.c @@ -35,12 +35,12 @@ int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov) return 1; } -const OSSL_ITEM *OSSL_PROVIDER_get_param_types(OSSL_PROVIDER *prov) +const OSSL_ITEM *OSSL_PROVIDER_get_param_types(const OSSL_PROVIDER *prov) { return ossl_provider_get_param_types(prov); } -int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, const OSSL_PARAM params[]) +int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]) { return ossl_provider_get_params(prov, params); } diff --git a/crypto/provider_core.c b/crypto/provider_core.c index d17ff93e..c16e91d1 100644 --- a/crypto/provider_core.c +++ b/crypto/provider_core.c @@ -11,7 +11,7 @@ #include #include #include -#include "internal/cryptlib.h" +#include "internal/cryptlib_int.h" #include "internal/nelem.h" #include "internal/thread_once.h" #include "internal/provider.h" @@ -47,7 +47,18 @@ struct ossl_provider_st { DSO *module; OSSL_provider_init_fn *init_function; STACK_OF(INFOPAIR) *parameters; + OPENSSL_CTX *libctx; /* The library context this instance is in */ struct provider_store_st *store; /* The store this instance belongs to */ +#ifndef FIPS_MODE + /* + * In the FIPS module inner provider, this isn't needed, since the + * error upcalls are always direct calls to the outer provider. + */ + int error_lib; /* ERR library number, one for each provider */ +# ifndef OPENSSL_NO_ERR + ERR_STRING_DATA *error_strings; /* Copy of what the provider gives us */ +# endif +#endif /* Provider side functions */ OSSL_provider_teardown_fn *teardown; @@ -120,7 +131,11 @@ static void *provider_store_new(OPENSSL_CTX *ctx) CRYPTOerr(CRYPTO_F_PROVIDER_STORE_NEW, ERR_R_INTERNAL_ERROR); return NULL; } + prov->libctx = ctx; prov->store = store; +#ifndef FIPS_MODE + prov->error_lib = ERR_get_next_error_library(); +#endif if(p->is_fallback) ossl_provider_set_fallback(prov); } @@ -157,7 +172,7 @@ OSSL_PROVIDER *ossl_provider_find(OPENSSL_CTX *libctx, const char *name) CRYPTO_THREAD_write_lock(store->lock); if ((i = sk_OSSL_PROVIDER_find(store->providers, &tmpl)) == -1 || (prov = sk_OSSL_PROVIDER_value(store->providers, i)) == NULL - || !ossl_provider_upref(prov)) + || !ossl_provider_up_ref(prov)) prov = NULL; CRYPTO_THREAD_unlock(store->lock); } @@ -179,7 +194,7 @@ static OSSL_PROVIDER *provider_new(const char *name, #ifndef HAVE_ATOMICS || (prov->refcnt_lock = CRYPTO_THREAD_lock_new()) == NULL #endif - || !ossl_provider_upref(prov) /* +1 One reference to be returned */ + || !ossl_provider_up_ref(prov) /* +1 One reference to be returned */ || (prov->name = OPENSSL_strdup(name)) == NULL) { ossl_provider_free(prov); CRYPTOerr(CRYPTO_F_PROVIDER_NEW, ERR_R_MALLOC_FAILURE); @@ -190,11 +205,12 @@ static OSSL_PROVIDER *provider_new(const char *name, return prov; } -int ossl_provider_upref(OSSL_PROVIDER *prov) +int ossl_provider_up_ref(OSSL_PROVIDER *prov) { int ref = 0; - CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock); + if (CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock) <= 0) + return 0; return ref; } @@ -220,7 +236,7 @@ OSSL_PROVIDER *ossl_provider_new(OPENSSL_CTX *libctx, const char *name, return NULL; CRYPTO_THREAD_write_lock(store->lock); - if (!ossl_provider_upref(prov)) { /* +1 One reference for the store */ + if (!ossl_provider_up_ref(prov)) { /* +1 One reference for the store */ ossl_provider_free(prov); /* -1 Reference that was to be returned */ prov = NULL; } else if (sk_OSSL_PROVIDER_push(store->providers, prov) == 0) { @@ -228,7 +244,11 @@ OSSL_PROVIDER *ossl_provider_new(OPENSSL_CTX *libctx, const char *name, ossl_provider_free(prov); /* -1 Reference that was to be returned */ prov = NULL; } else { + prov->libctx = libctx; prov->store = store; +#ifndef FIPS_MODE + prov->error_lib = ERR_get_next_error_library(); +#endif } CRYPTO_THREAD_unlock(store->lock); @@ -265,8 +285,20 @@ void ossl_provider_free(OSSL_PROVIDER *prov) * When that happens, the provider is inactivated. */ if (ref < 2 && prov->flag_initialized) { +#ifndef FIPS_MODE + ossl_init_thread_deregister(prov); +#endif if (prov->teardown != NULL) prov->teardown(prov->provctx); +#ifndef OPENSSL_NO_ERR +# ifndef FIPS_MODE + if (prov->error_strings != NULL) { + ERR_unload_strings(prov->error_lib, prov->error_strings); + OPENSSL_free(prov->error_strings); + prov->error_strings = NULL; + } +# endif +#endif prov->flag_initialized = 0; } @@ -340,13 +372,16 @@ static const OSSL_DISPATCH *core_dispatch; /* Define further down */ /* * Internal version that doesn't affect the store flags, and thereby avoid * locking. Direct callers must remember to set the store flags when - * appropriate. The libctx parameter is only necessary when FIPS_MODE is set - * (i.e. we are being called from inside the FIPS module) - it is ignored for - * other uses. + * appropriate. */ -static int provider_activate(OSSL_PROVIDER *prov, OPENSSL_CTX *libctx) +static int provider_activate(OSSL_PROVIDER *prov) { const OSSL_DISPATCH *provider_dispatch = NULL; +#ifndef OPENSSL_NO_ERR +# ifndef FIPS_MODE + OSSL_provider_get_reason_strings_fn *p_get_reason_strings = NULL; +# endif +#endif if (prov->flag_initialized) return 1; @@ -399,26 +434,7 @@ static int provider_activate(OSSL_PROVIDER *prov, OPENSSL_CTX *libctx) #endif } - /* - * We call the initialise function for the provider. - * - * If FIPS_MODE is defined then we are inside the FIPS module and are about - * to recursively initialise ourselves. We need to do this so that we can - * get all the provider callback functions set up in order for us to be able - * to make EVP calls from within the FIPS module itself. Only algorithms - * from the FIPS module itself are available via the FIPS module EVP - * interface, i.e. we only ever have one provider available inside the FIPS - * module - the FIPS provider itself. - * - * For modules in general we cannot know what value will be used for the - * provctx - it is a "black box". But for the FIPS module we know that the - * provctx is really a library context. We default the provctx value to the - * same library context as was used for the EVP call that caused this call - * to "provider_activate". - */ -#ifdef FIPS_MODE - prov->provctx = libctx; -#endif + /* Call the initialise function for the provider. */ if (prov->init_function == NULL || !prov->init_function(prov, core_dispatch, &provider_dispatch, &prov->provctx)) { @@ -449,9 +465,62 @@ static int provider_activate(OSSL_PROVIDER *prov, OPENSSL_CTX *libctx) prov->query_operation = OSSL_get_provider_query_operation(provider_dispatch); break; +#ifndef OPENSSL_NO_ERR +# ifndef FIPS_MODE + case OSSL_FUNC_PROVIDER_GET_REASON_STRINGS: + p_get_reason_strings = + OSSL_get_provider_get_reason_strings(provider_dispatch); + break; +# endif +#endif } } +#ifndef OPENSSL_NO_ERR +# ifndef FIPS_MODE + if (p_get_reason_strings != NULL) { + const OSSL_ITEM *reasonstrings = p_get_reason_strings(prov->provctx); + size_t cnt, cnt2; + + /* + * ERR_load_strings() handles ERR_STRING_DATA rather than OSSL_ITEM, + * although they are essentially the same type. + * Furthermore, ERR_load_strings() patches the array's error number + * with the error library number, so we need to make a copy of that + * array either way. + */ + cnt = 1; /* One for the terminating item */ + while (reasonstrings[cnt].id != 0) { + if (ERR_GET_LIB(reasonstrings[cnt].id) != 0) + return 0; + cnt++; + } + + /* Allocate one extra item for the "library" name */ + prov->error_strings = + OPENSSL_zalloc(sizeof(ERR_STRING_DATA) * (cnt + 1)); + if (prov->error_strings == NULL) + return 0; + + /* + * Set the "library" name. + */ + prov->error_strings[0].error = ERR_PACK(prov->error_lib, 0, 0); + prov->error_strings[0].string = prov->name; + /* + * Copy reasonstrings item 0..cnt-1 to prov->error_trings positions + * 1..cnt. + */ + for (cnt2 = 1; cnt2 <= cnt; cnt2++) { + prov->error_strings[cnt2].error = (int)reasonstrings[cnt2-1].id; + prov->error_strings[cnt2].string = reasonstrings[cnt2-1].ptr; + } + + ERR_load_strings(prov->error_lib, prov->error_strings); + } +# endif +#endif + /* With this flag set, this provider has become fully "loaded". */ prov->flag_initialized = 1; @@ -460,7 +529,7 @@ static int provider_activate(OSSL_PROVIDER *prov, OPENSSL_CTX *libctx) int ossl_provider_activate(OSSL_PROVIDER *prov) { - if (provider_activate(prov, NULL)) { + if (provider_activate(prov)) { CRYPTO_THREAD_write_lock(prov->store->lock); prov->store->use_fallbacks = 0; CRYPTO_THREAD_unlock(prov->store->lock); @@ -537,7 +606,7 @@ int ossl_provider_forall_loaded(OPENSSL_CTX *ctx, */ if (prov->flag_fallback) { activated_fallback_count++; - provider_activate(prov, ctx); + provider_activate(prov); } } @@ -575,17 +644,17 @@ int ossl_provider_set_fallback(OSSL_PROVIDER *prov) } /* Getters of Provider Object data */ -const char *ossl_provider_name(OSSL_PROVIDER *prov) +const char *ossl_provider_name(const OSSL_PROVIDER *prov) { return prov->name; } -const DSO *ossl_provider_dso(OSSL_PROVIDER *prov) +const DSO *ossl_provider_dso(const OSSL_PROVIDER *prov) { return prov->module; } -const char *ossl_provider_module_name(OSSL_PROVIDER *prov) +const char *ossl_provider_module_name(const OSSL_PROVIDER *prov) { #ifdef FIPS_MODE return NULL; @@ -594,7 +663,7 @@ const char *ossl_provider_module_name(OSSL_PROVIDER *prov) #endif } -const char *ossl_provider_module_path(OSSL_PROVIDER *prov) +const char *ossl_provider_module_path(const OSSL_PROVIDER *prov) { #ifdef FIPS_MODE return NULL; @@ -617,8 +686,7 @@ const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov) ? NULL : prov->get_param_types(prov->provctx); } -int ossl_provider_get_params(const OSSL_PROVIDER *prov, - const OSSL_PARAM params[]) +int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]) { return prov->get_params == NULL ? 0 : prov->get_params(prov->provctx, params); @@ -655,10 +723,10 @@ static const OSSL_ITEM *core_get_param_types(const OSSL_PROVIDER *prov) return param_types; } -static int core_get_params(const OSSL_PROVIDER *prov, const OSSL_PARAM params[]) +static int core_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]) { int i; - const OSSL_PARAM *p; + OSSL_PARAM *p; if ((p = OSSL_PARAM_locate(params, "openssl-version")) != NULL) OSSL_PARAM_set_utf8_ptr(p, OPENSSL_VERSION_STR); @@ -678,11 +746,89 @@ static int core_get_params(const OSSL_PROVIDER *prov, const OSSL_PARAM params[]) return 1; } +static OSSL_core_get_library_context_fn core_get_libctx; /* Check */ +static OPENSSL_CTX *core_get_libctx(const OSSL_PROVIDER *prov) +{ + return prov->libctx; +} + +static int core_thread_start(const OSSL_PROVIDER *prov, + OSSL_thread_stop_handler_fn handfn) +{ + return ossl_init_thread_start(prov, prov->provctx, handfn); +} + +/* + * The FIPS module inner provider doesn't implement these. They aren't + * needed there, since the FIPS module upcalls are always the outer provider + * ones. + */ +#ifndef FIPS_MODE +static void core_put_error(const OSSL_PROVIDER *prov, + uint32_t reason, const char *file, int line) +{ + /* + * If the uppermost 8 bits are non-zero, it's an OpenSSL library + * error and will be treated as such. Otherwise, it's a new style + * provider error and will be treated as such. + */ + if (ERR_GET_LIB(reason) != 0) { + ERR_PUT_error(ERR_GET_LIB(reason), + ERR_GET_FUNC(reason), + ERR_GET_REASON(reason), + file, line); + } else { + ERR_PUT_error(prov->error_lib, 0, (int)reason, file, line); + } +} + +/* + * TODO(3.0) This, as well as core_put_error above, should use |prov| + * to select the proper library context to report in the correct error + * stack, at least if error stacks become tied to the library context. + * We cannot currently do that since there's no support for it in the + * ERR subsystem. + */ +static void core_add_error_vdata(const OSSL_PROVIDER *prov, + int num, va_list args) +{ + ERR_add_error_vdata(num, args); +} +#endif + +/* + * Functions provided by the core. Blank line separates "families" of related + * functions. + */ static const OSSL_DISPATCH core_dispatch_[] = { { OSSL_FUNC_CORE_GET_PARAM_TYPES, (void (*)(void))core_get_param_types }, { OSSL_FUNC_CORE_GET_PARAMS, (void (*)(void))core_get_params }, - { OSSL_FUNC_CORE_PUT_ERROR, (void (*)(void))ERR_put_error }, - { OSSL_FUNC_CORE_ADD_ERROR_VDATA, (void (*)(void))ERR_add_error_vdata }, + { OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT, (void (*)(void))core_get_libctx }, + { OSSL_FUNC_CORE_THREAD_START, (void (*)(void))core_thread_start }, +#ifndef FIPS_MODE + { OSSL_FUNC_CORE_PUT_ERROR, (void (*)(void))core_put_error }, + { OSSL_FUNC_CORE_ADD_ERROR_VDATA, (void (*)(void))core_add_error_vdata }, +#endif + + { OSSL_FUNC_CRYPTO_MALLOC, (void (*)(void))CRYPTO_malloc }, + { OSSL_FUNC_CRYPTO_ZALLOC, (void (*)(void))CRYPTO_zalloc }, + { OSSL_FUNC_CRYPTO_MEMDUP, (void (*)(void))CRYPTO_memdup }, + { OSSL_FUNC_CRYPTO_STRDUP, (void (*)(void))CRYPTO_strdup }, + { OSSL_FUNC_CRYPTO_STRNDUP, (void (*)(void))CRYPTO_strndup }, + { OSSL_FUNC_CRYPTO_FREE, (void (*)(void))CRYPTO_free }, + { OSSL_FUNC_CRYPTO_CLEAR_FREE, (void (*)(void))CRYPTO_clear_free }, + { OSSL_FUNC_CRYPTO_REALLOC, (void (*)(void))CRYPTO_realloc }, + { OSSL_FUNC_CRYPTO_CLEAR_REALLOC, (void (*)(void))CRYPTO_clear_realloc }, + { OSSL_FUNC_CRYPTO_SECURE_MALLOC, (void (*)(void))CRYPTO_secure_malloc }, + { OSSL_FUNC_CRYPTO_SECURE_ZALLOC, (void (*)(void))CRYPTO_secure_zalloc }, + { OSSL_FUNC_CRYPTO_SECURE_FREE, (void (*)(void))CRYPTO_secure_free }, + { OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE, + (void (*)(void))CRYPTO_secure_clear_free }, + { OSSL_FUNC_CRYPTO_SECURE_ALLOCATED, + (void (*)(void))CRYPTO_secure_allocated }, + { OSSL_FUNC_OPENSSL_CLEANSE, (void (*)(void))OPENSSL_cleanse }, + { OSSL_FUNC_OPENSSL_HEXSTR2BUF, (void (*)(void))OPENSSL_hexstr2buf }, + { 0, NULL } }; static const OSSL_DISPATCH *core_dispatch = core_dispatch_; diff --git a/crypto/rand/build.info b/crypto/rand/build.info index 70d25803..3e0a9c74 100644 --- a/crypto/rand/build.info +++ b/crypto/rand/build.info @@ -1,5 +1,7 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - randfile.c rand_lib.c rand_err.c rand_crng_test.c rand_egd.c \ - rand_win.c rand_unix.c rand_vms.c drbg_lib.c drbg_ctr.c rand_vxworks.c \ - drbg_hash.c drbg_hmac.c + +$COMMON=rand_lib.c rand_crng_test.c rand_win.c rand_unix.c rand_vms.c \ + drbg_lib.c drbg_ctr.c rand_vxworks.c drbg_hash.c drbg_hmac.c + +SOURCE[../../libcrypto]=$COMMON randfile.c rand_err.c rand_egd.c +SOURCE[../../providers/fips]=$COMMON diff --git a/crypto/rand/drbg_ctr.c b/crypto/rand/drbg_ctr.c index 4c11e657..23e504bf 100644 --- a/crypto/rand/drbg_ctr.c +++ b/crypto/rand/drbg_ctr.c @@ -354,6 +354,7 @@ static int drbg_ctr_uninstantiate(RAND_DRBG *drbg) { EVP_CIPHER_CTX_free(drbg->data.ctr.ctx); EVP_CIPHER_CTX_free(drbg->data.ctr.ctx_df); + EVP_CIPHER_meth_free(drbg->data.ctr.cipher); OPENSSL_cleanse(&drbg->data.ctr, sizeof(drbg->data.ctr)); return 1; } @@ -369,6 +370,7 @@ int drbg_ctr_init(RAND_DRBG *drbg) { RAND_DRBG_CTR *ctr = &drbg->data.ctr; size_t keylen; + EVP_CIPHER *cipher = NULL; switch (drbg->type) { default: @@ -376,17 +378,22 @@ int drbg_ctr_init(RAND_DRBG *drbg) return 0; case NID_aes_128_ctr: keylen = 16; - ctr->cipher = EVP_aes_128_ecb(); + cipher = EVP_CIPHER_fetch(drbg->libctx, "AES-128-ECB", ""); break; case NID_aes_192_ctr: keylen = 24; - ctr->cipher = EVP_aes_192_ecb(); + cipher = EVP_CIPHER_fetch(drbg->libctx, "AES-192-ECB", ""); break; case NID_aes_256_ctr: keylen = 32; - ctr->cipher = EVP_aes_256_ecb(); + cipher = EVP_CIPHER_fetch(drbg->libctx, "AES-256-ECB", ""); break; } + if (cipher == NULL) + return 0; + + EVP_CIPHER_meth_free(ctr->cipher); + ctr->cipher = cipher; drbg->meth = &drbg_ctr_meth; diff --git a/crypto/rand/drbg_hash.c b/crypto/rand/drbg_hash.c index 09431802..bb6f36ce 100644 --- a/crypto/rand/drbg_hash.c +++ b/crypto/rand/drbg_hash.c @@ -14,6 +14,7 @@ #include #include #include "internal/thread_once.h" +#include "internal/providercommon.h" #include "rand_lcl.h" /* 440 bits from SP800-90Ar1 10.1 table 2 */ @@ -289,6 +290,7 @@ static int drbg_hash_generate(RAND_DRBG *drbg, static int drbg_hash_uninstantiate(RAND_DRBG *drbg) { + EVP_MD_meth_free(drbg->data.hash.md); EVP_MD_CTX_free(drbg->data.hash.ctx); OPENSSL_cleanse(&drbg->data.hash, sizeof(drbg->data.hash)); return 1; @@ -303,23 +305,55 @@ static RAND_DRBG_METHOD drbg_hash_meth = { int drbg_hash_init(RAND_DRBG *drbg) { - const EVP_MD *md; + EVP_MD *md; RAND_DRBG_HASH *hash = &drbg->data.hash; - /* Any approved digest is allowed */ - md = EVP_get_digestbynid(drbg->type); + /* + * Confirm digest is allowed. Outside FIPS_MODE we allow all non-legacy + * digests. Inside FIPS_MODE we only allow approved digests. Also no XOF + * digests (such as SHAKE). + */ + switch (drbg->type) { + default: + return 0; + + case NID_sha1: + case NID_sha224: + case NID_sha256: + case NID_sha384: + case NID_sha512: + case NID_sha512_224: + case NID_sha512_256: + case NID_sha3_224: + case NID_sha3_256: + case NID_sha3_384: + case NID_sha3_512: +#ifndef FIPS_MODE + case NID_blake2b512: + case NID_blake2s256: + case NID_sm3: +#endif + break; + } + + md = EVP_MD_fetch(drbg->libctx, ossl_prov_util_nid_to_name(drbg->type), ""); if (md == NULL) return 0; + drbg->meth = &drbg_hash_meth; - hash->md = md; if (hash->ctx == NULL) { hash->ctx = EVP_MD_CTX_new(); - if (hash->ctx == NULL) + if (hash->ctx == NULL) { + EVP_MD_meth_free(md); return 0; + } } + EVP_MD_meth_free(hash->md); + hash->md = md; + /* These are taken from SP 800-90 10.1 Table 2 */ hash->blocklen = EVP_MD_size(md); /* See SP800-57 Part1 Rev4 5.6.1 Table 3 */ diff --git a/crypto/rand/drbg_hmac.c b/crypto/rand/drbg_hmac.c index cb70bcb8..baafc590 100644 --- a/crypto/rand/drbg_hmac.c +++ b/crypto/rand/drbg_hmac.c @@ -13,6 +13,7 @@ #include #include #include "internal/thread_once.h" +#include "internal/providercommon.h" #include "rand_lcl.h" /* @@ -183,6 +184,7 @@ static int drbg_hmac_generate(RAND_DRBG *drbg, static int drbg_hmac_uninstantiate(RAND_DRBG *drbg) { + EVP_MD_meth_free(drbg->data.hmac.md); HMAC_CTX_free(drbg->data.hmac.ctx); OPENSSL_cleanse(&drbg->data.hmac, sizeof(drbg->data.hmac)); return 1; @@ -197,11 +199,38 @@ static RAND_DRBG_METHOD drbg_hmac_meth = { int drbg_hmac_init(RAND_DRBG *drbg) { - const EVP_MD *md = NULL; + EVP_MD *md = NULL; RAND_DRBG_HMAC *hmac = &drbg->data.hmac; - /* Any approved digest is allowed - assume we pass digest (not NID_hmac*) */ - md = EVP_get_digestbynid(drbg->type); + /* + * Confirm digest is allowed. Outside FIPS_MODE we allow all non-legacy + * digests. Inside FIPS_MODE we only allow approved digests. Also no XOF + * digests (such as SHAKE). + */ + switch (drbg->type) { + default: + return 0; + + case NID_sha1: + case NID_sha224: + case NID_sha256: + case NID_sha384: + case NID_sha512: + case NID_sha512_224: + case NID_sha512_256: + case NID_sha3_224: + case NID_sha3_256: + case NID_sha3_384: + case NID_sha3_512: +#ifndef FIPS_MODE + case NID_blake2b512: + case NID_blake2s256: + case NID_sm3: +#endif + break; + } + + md = EVP_MD_fetch(drbg->libctx, ossl_prov_util_nid_to_name(drbg->type), ""); if (md == NULL) return 0; @@ -209,11 +238,14 @@ int drbg_hmac_init(RAND_DRBG *drbg) if (hmac->ctx == NULL) { hmac->ctx = HMAC_CTX_new(); - if (hmac->ctx == NULL) + if (hmac->ctx == NULL) { + EVP_MD_meth_free(md); return 0; + } } /* These are taken from SP 800-90 10.1 Table 2 */ + EVP_MD_meth_free(hmac->md); hmac->md = md; hmac->blocklen = EVP_MD_size(md); /* See SP800-57 Part1 Rev4 5.6.1 Table 3 */ diff --git a/crypto/rand/drbg_lib.c b/crypto/rand/drbg_lib.c index fbe75e66..c1b9b3b2 100644 --- a/crypto/rand/drbg_lib.c +++ b/crypto/rand/drbg_lib.c @@ -29,49 +29,54 @@ * a much bigger deal than just re-setting an allocated resource.) */ -/* - * The three shared DRBG instances - * - * There are three shared DRBG instances: , , and . - */ -/* - * The DRBG - * - * Not used directly by the application, only for reseeding the two other - * DRBGs. It reseeds itself by pulling either randomness from os entropy - * sources or by consuming randomness which was added by RAND_add(). - * - * The DRBG is a global instance which is accessed concurrently by - * all threads. The necessary locking is managed automatically by its child - * DRBG instances during reseeding. - */ -static RAND_DRBG *master_drbg; -/* - * The DRBG - * - * Used by default for generating random bytes using RAND_bytes(). - * - * The DRBG is thread-local, i.e., there is one instance per thread. - */ -static CRYPTO_THREAD_LOCAL public_drbg; -/* - * The DRBG - * - * Used by default for generating private keys using RAND_priv_bytes() - * - * The DRBG is thread-local, i.e., there is one instance per thread. - */ -static CRYPTO_THREAD_LOCAL private_drbg; +typedef struct drbg_global_st { + /* + * The three shared DRBG instances + * + * There are three shared DRBG instances: , , and . + */ + /* + * The DRBG + * + * Not used directly by the application, only for reseeding the two other + * DRBGs. It reseeds itself by pulling either randomness from os entropy + * sources or by consuming randomness which was added by RAND_add(). + * + * The DRBG is a global instance which is accessed concurrently by + * all threads. The necessary locking is managed automatically by its child + * DRBG instances during reseeding. + */ + RAND_DRBG *master_drbg; + /* + * The DRBG + * + * Used by default for generating random bytes using RAND_bytes(). + * + * The DRBG is thread-local, i.e., there is one instance per + * thread. + */ + CRYPTO_THREAD_LOCAL public_drbg; + /* + * The DRBG + * + * Used by default for generating private keys using RAND_priv_bytes() + * + * The DRBG is thread-local, i.e., there is one instance per + * thread. + */ + CRYPTO_THREAD_LOCAL private_drbg; +} DRBG_GLOBAL; +typedef struct drbg_nonce_global_st { + CRYPTO_RWLOCK *rand_nonce_lock; + int rand_nonce_count; +} DRBG_NONCE_GLOBAL; /* NIST SP 800-90A DRBG recommends the use of a personalization string. */ static const char ossl_pers_string[] = DRBG_DEFAULT_PERS_STRING; -static CRYPTO_ONCE rand_drbg_init = CRYPTO_ONCE_STATIC_INIT; - - #define RAND_DRBG_TYPE_FLAGS ( \ RAND_DRBG_FLAG_MASTER | RAND_DRBG_FLAG_PUBLIC | RAND_DRBG_FLAG_PRIVATE ) @@ -102,9 +107,10 @@ static const unsigned int rand_drbg_used_flags = RAND_DRBG_FLAG_CTR_NO_DF | RAND_DRBG_FLAG_HMAC | RAND_DRBG_TYPE_FLAGS; -static RAND_DRBG *drbg_setup(RAND_DRBG *parent, int drbg_type); +static RAND_DRBG *drbg_setup(OPENSSL_CTX *ctx, RAND_DRBG *parent, int drbg_type); -static RAND_DRBG *rand_drbg_new(int secure, +static RAND_DRBG *rand_drbg_new(OPENSSL_CTX *ctx, + int secure, int type, unsigned int flags, RAND_DRBG *parent); @@ -141,6 +147,157 @@ static int is_digest(int type) } } +/* + * Initialize the OPENSSL_CTX global DRBGs on first use. + * Returns the allocated global data on success or NULL on failure. + */ +static void *drbg_ossl_ctx_new(OPENSSL_CTX *libctx) +{ + DRBG_GLOBAL *dgbl = OPENSSL_zalloc(sizeof(*dgbl)); + + if (dgbl == NULL) + return NULL; + +#ifndef FIPS_MODE + /* + * We need to ensure that base libcrypto thread handling has been + * initialised. + */ + OPENSSL_init_crypto(0, NULL); +#endif + + if (!CRYPTO_THREAD_init_local(&dgbl->private_drbg, NULL)) + goto err1; + + if (!CRYPTO_THREAD_init_local(&dgbl->public_drbg, NULL)) + goto err2; + + dgbl->master_drbg = drbg_setup(libctx, NULL, RAND_DRBG_TYPE_MASTER); + if (dgbl->master_drbg == NULL) + goto err3; + + return dgbl; + + err3: + CRYPTO_THREAD_cleanup_local(&dgbl->public_drbg); + err2: + CRYPTO_THREAD_cleanup_local(&dgbl->private_drbg); + err1: + OPENSSL_free(dgbl); + return NULL; +} + +static void drbg_ossl_ctx_free(void *vdgbl) +{ + DRBG_GLOBAL *dgbl = vdgbl; + + RAND_DRBG_free(dgbl->master_drbg); + CRYPTO_THREAD_cleanup_local(&dgbl->private_drbg); + CRYPTO_THREAD_cleanup_local(&dgbl->public_drbg); + + OPENSSL_free(dgbl); +} + +static const OPENSSL_CTX_METHOD drbg_ossl_ctx_method = { + drbg_ossl_ctx_new, + drbg_ossl_ctx_free, +}; + +/* + * drbg_ossl_ctx_new() calls drgb_setup() which calls rand_drbg_get_nonce() + * which needs to get the rand_nonce_lock out of the OPENSSL_CTX...but since + * drbg_ossl_ctx_new() hasn't finished running yet we need the rand_nonce_lock + * to be in a different global data object. Otherwise we will go into an + * infinite recursion loop. + */ +static void *drbg_nonce_ossl_ctx_new(OPENSSL_CTX *libctx) +{ + DRBG_NONCE_GLOBAL *dngbl = OPENSSL_zalloc(sizeof(*dngbl)); + + if (dngbl == NULL) + return NULL; + + dngbl->rand_nonce_lock = CRYPTO_THREAD_lock_new(); + if (dngbl->rand_nonce_lock == NULL) { + OPENSSL_free(dngbl); + return NULL; + } + + return dngbl; +} + +static void drbg_nonce_ossl_ctx_free(void *vdngbl) +{ + DRBG_NONCE_GLOBAL *dngbl = vdngbl; + + CRYPTO_THREAD_lock_free(dngbl->rand_nonce_lock); + + OPENSSL_free(dngbl); +} + +static const OPENSSL_CTX_METHOD drbg_nonce_ossl_ctx_method = { + drbg_nonce_ossl_ctx_new, + drbg_nonce_ossl_ctx_free, +}; + +static DRBG_GLOBAL *drbg_get_global(OPENSSL_CTX *libctx) +{ + return openssl_ctx_get_data(libctx, OPENSSL_CTX_DRBG_INDEX, + &drbg_ossl_ctx_method); +} + +/* Implements the get_nonce() callback (see RAND_DRBG_set_callbacks()) */ +size_t rand_drbg_get_nonce(RAND_DRBG *drbg, + unsigned char **pout, + int entropy, size_t min_len, size_t max_len) +{ + size_t ret = 0; + RAND_POOL *pool; + DRBG_NONCE_GLOBAL *dngbl + = openssl_ctx_get_data(drbg->libctx, OPENSSL_CTX_DRBG_NONCE_INDEX, + &drbg_nonce_ossl_ctx_method); + struct { + void *instance; + int count; + } data; + + if (dngbl == NULL) + return 0; + + memset(&data, 0, sizeof(data)); + pool = rand_pool_new(0, min_len, max_len); + if (pool == NULL) + return 0; + + if (rand_pool_add_nonce_data(pool) == 0) + goto err; + + data.instance = drbg; + CRYPTO_atomic_add(&dngbl->rand_nonce_count, 1, &data.count, + dngbl->rand_nonce_lock); + + if (rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0) == 0) + goto err; + + ret = rand_pool_length(pool); + *pout = rand_pool_detach(pool); + + err: + rand_pool_free(pool); + + return ret; +} + +/* + * Implements the cleanup_nonce() callback (see RAND_DRBG_set_callbacks()) + * + */ +void rand_drbg_cleanup_nonce(RAND_DRBG *drbg, + unsigned char *out, size_t outlen) +{ + OPENSSL_secure_clear_free(out, outlen); +} + /* * Set/initialize |drbg| to be of type |type|, with optional |flags|. * @@ -236,7 +393,8 @@ int RAND_DRBG_set_defaults(int type, unsigned int flags) * * Returns a pointer to the new DRBG instance on success, NULL on failure. */ -static RAND_DRBG *rand_drbg_new(int secure, +static RAND_DRBG *rand_drbg_new(OPENSSL_CTX *ctx, + int secure, int type, unsigned int flags, RAND_DRBG *parent) @@ -249,6 +407,7 @@ static RAND_DRBG *rand_drbg_new(int secure, return NULL; } + drbg->libctx = ctx; drbg->secure = secure && CRYPTO_secure_allocated(drbg); drbg->fork_count = rand_fork_count; drbg->parent = parent; @@ -305,16 +464,27 @@ static RAND_DRBG *rand_drbg_new(int secure, return NULL; } +RAND_DRBG *RAND_DRBG_new_ex(OPENSSL_CTX *ctx, int type, unsigned int flags, + RAND_DRBG *parent) +{ + return rand_drbg_new(ctx, 0, type, flags, parent); +} + RAND_DRBG *RAND_DRBG_new(int type, unsigned int flags, RAND_DRBG *parent) { - return rand_drbg_new(0, type, flags, parent); + return RAND_DRBG_new_ex(NULL, type, flags, parent); +} + +RAND_DRBG *RAND_DRBG_secure_new_ex(OPENSSL_CTX *ctx, int type, + unsigned int flags, RAND_DRBG *parent) +{ + return rand_drbg_new(ctx, 1, type, flags, parent); } RAND_DRBG *RAND_DRBG_secure_new(int type, unsigned int flags, RAND_DRBG *parent) { - return rand_drbg_new(1, type, flags, parent); + return RAND_DRBG_secure_new_ex(NULL, type, flags, parent); } - /* * Uninstantiate |drbg| and free all memory. */ @@ -376,7 +546,7 @@ int RAND_DRBG_instantiate(RAND_DRBG *drbg, /* * NIST SP800-90Ar1 section 9.1 says you can combine getting the entropy * and nonce in 1 call by increasing the entropy with 50% and increasing - * the minimum length to accomadate the length of the nonce. + * the minimum length to accommodate the length of the nonce. * We do this in case a nonce is require and get_nonce is NULL. */ if (drbg->min_noncelen > 0 && drbg->get_nonce == NULL) { @@ -943,12 +1113,12 @@ void *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx) * * Returns a pointer to the new DRBG instance on success, NULL on failure. */ -static RAND_DRBG *drbg_setup(RAND_DRBG *parent, int drbg_type) +static RAND_DRBG *drbg_setup(OPENSSL_CTX *ctx, RAND_DRBG *parent, int drbg_type) { RAND_DRBG *drbg; - drbg = RAND_DRBG_secure_new(rand_drbg_type[drbg_type], - rand_drbg_flags[drbg_type], parent); + drbg = RAND_DRBG_secure_new_ex(ctx, rand_drbg_type[drbg_type], + rand_drbg_flags[drbg_type], parent); if (drbg == NULL) return NULL; @@ -975,60 +1145,20 @@ err: return NULL; } -/* - * Initialize the global DRBGs on first use. - * Returns 1 on success, 0 on failure. - */ -DEFINE_RUN_ONCE_STATIC(do_rand_drbg_init) -{ - /* - * ensure that libcrypto is initialized, otherwise the - * DRBG locks are not cleaned up properly - */ - if (!OPENSSL_init_crypto(0, NULL)) - return 0; - - if (!CRYPTO_THREAD_init_local(&private_drbg, NULL)) - return 0; - - if (!CRYPTO_THREAD_init_local(&public_drbg, NULL)) - goto err1; - - master_drbg = drbg_setup(NULL, RAND_DRBG_TYPE_MASTER); - if (master_drbg == NULL) - goto err2; - - return 1; - -err2: - CRYPTO_THREAD_cleanup_local(&public_drbg); -err1: - CRYPTO_THREAD_cleanup_local(&private_drbg); - return 0; -} - -/* Clean up the global DRBGs before exit */ -void rand_drbg_cleanup_int(void) -{ - if (master_drbg != NULL) { - RAND_DRBG_free(master_drbg); - master_drbg = NULL; - - CRYPTO_THREAD_cleanup_local(&private_drbg); - CRYPTO_THREAD_cleanup_local(&public_drbg); - } -} - -void drbg_delete_thread_state(void) +static void drbg_delete_thread_state(void *arg) { + OPENSSL_CTX *ctx = arg; + DRBG_GLOBAL *dgbl = drbg_get_global(ctx); RAND_DRBG *drbg; - drbg = CRYPTO_THREAD_get_local(&public_drbg); - CRYPTO_THREAD_set_local(&public_drbg, NULL); + if (dgbl == NULL) + return; + drbg = CRYPTO_THREAD_get_local(&dgbl->public_drbg); + CRYPTO_THREAD_set_local(&dgbl->public_drbg, NULL); RAND_DRBG_free(drbg); - drbg = CRYPTO_THREAD_get_local(&private_drbg); - CRYPTO_THREAD_set_local(&private_drbg, NULL); + drbg = CRYPTO_THREAD_get_local(&dgbl->private_drbg); + CRYPTO_THREAD_set_local(&dgbl->private_drbg, NULL); RAND_DRBG_free(drbg); } @@ -1180,56 +1310,77 @@ static int drbg_status(void) * Returns pointer to the DRBG on success, NULL on failure. * */ -RAND_DRBG *RAND_DRBG_get0_master(void) +RAND_DRBG *OPENSSL_CTX_get0_master_drbg(OPENSSL_CTX *ctx) { - if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init)) + DRBG_GLOBAL *dgbl = drbg_get_global(ctx); + + if (dgbl == NULL) return NULL; - return master_drbg; + return dgbl->master_drbg; +} + +RAND_DRBG *RAND_DRBG_get0_master(void) +{ + return OPENSSL_CTX_get0_master_drbg(NULL); } /* * Get the public DRBG. * Returns pointer to the DRBG on success, NULL on failure. */ -RAND_DRBG *RAND_DRBG_get0_public(void) +RAND_DRBG *OPENSSL_CTX_get0_public_drbg(OPENSSL_CTX *ctx) { + DRBG_GLOBAL *dgbl = drbg_get_global(ctx); RAND_DRBG *drbg; - if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init)) + if (dgbl == NULL) return NULL; - drbg = CRYPTO_THREAD_get_local(&public_drbg); + drbg = CRYPTO_THREAD_get_local(&dgbl->public_drbg); if (drbg == NULL) { - if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_RAND)) + ctx = openssl_ctx_get_concrete(ctx); + if (!ossl_init_thread_start(NULL, ctx, drbg_delete_thread_state)) return NULL; - drbg = drbg_setup(master_drbg, RAND_DRBG_TYPE_PUBLIC); - CRYPTO_THREAD_set_local(&public_drbg, drbg); + drbg = drbg_setup(ctx, dgbl->master_drbg, RAND_DRBG_TYPE_PUBLIC); + CRYPTO_THREAD_set_local(&dgbl->public_drbg, drbg); } return drbg; } +RAND_DRBG *RAND_DRBG_get0_public(void) +{ + return OPENSSL_CTX_get0_public_drbg(NULL); +} + /* * Get the private DRBG. * Returns pointer to the DRBG on success, NULL on failure. */ -RAND_DRBG *RAND_DRBG_get0_private(void) +RAND_DRBG *OPENSSL_CTX_get0_private_drbg(OPENSSL_CTX *ctx) { + DRBG_GLOBAL *dgbl = drbg_get_global(ctx); RAND_DRBG *drbg; - if (!RUN_ONCE(&rand_drbg_init, do_rand_drbg_init)) + if (dgbl == NULL) return NULL; - drbg = CRYPTO_THREAD_get_local(&private_drbg); + drbg = CRYPTO_THREAD_get_local(&dgbl->private_drbg); if (drbg == NULL) { - if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_RAND)) + ctx = openssl_ctx_get_concrete(ctx); + if (!ossl_init_thread_start(NULL, ctx, drbg_delete_thread_state)) return NULL; - drbg = drbg_setup(master_drbg, RAND_DRBG_TYPE_PRIVATE); - CRYPTO_THREAD_set_local(&private_drbg, drbg); + drbg = drbg_setup(ctx, dgbl->master_drbg, RAND_DRBG_TYPE_PRIVATE); + CRYPTO_THREAD_set_local(&dgbl->private_drbg, drbg); } return drbg; } +RAND_DRBG *RAND_DRBG_get0_private(void) +{ + return OPENSSL_CTX_get0_private_drbg(NULL); +} + RAND_METHOD rand_meth = { drbg_seed, drbg_bytes, @@ -1241,5 +1392,9 @@ RAND_METHOD rand_meth = { RAND_METHOD *RAND_OpenSSL(void) { +#ifndef FIPS_MODE return &rand_meth; +#else + return NULL; +#endif } diff --git a/crypto/rand/rand_crng_test.c b/crypto/rand/rand_crng_test.c index 1b4f1674..44e077e0 100644 --- a/crypto/rand/rand_crng_test.c +++ b/crypto/rand/rand_crng_test.c @@ -16,66 +16,83 @@ #include #include "internal/rand_int.h" #include "internal/thread_once.h" +#include "internal/cryptlib.h" #include "rand_lcl.h" -static RAND_POOL *crngt_pool; -static unsigned char crngt_prev[EVP_MAX_MD_SIZE]; +typedef struct crng_test_global_st { + unsigned char crngt_prev[EVP_MAX_MD_SIZE]; + RAND_POOL *crngt_pool; +} CRNG_TEST_GLOBAL; -int (*crngt_get_entropy)(unsigned char *, unsigned char *, unsigned int *) +int (*crngt_get_entropy)(OPENSSL_CTX *, RAND_POOL *, unsigned char *, + unsigned char *, unsigned int *) = &rand_crngt_get_entropy_cb; -int rand_crngt_get_entropy_cb(unsigned char *buf, unsigned char *md, +static void rand_crng_ossl_ctx_free(void *vcrngt_glob) +{ + CRNG_TEST_GLOBAL *crngt_glob = vcrngt_glob; + + rand_pool_free(crngt_glob->crngt_pool); + OPENSSL_free(crngt_glob); +} + +static void *rand_crng_ossl_ctx_new(OPENSSL_CTX *ctx) +{ + unsigned char buf[CRNGT_BUFSIZ]; + CRNG_TEST_GLOBAL *crngt_glob = OPENSSL_zalloc(sizeof(*crngt_glob)); + + if (crngt_glob == NULL) + return NULL; + + if ((crngt_glob->crngt_pool + = rand_pool_new(0, CRNGT_BUFSIZ, CRNGT_BUFSIZ)) == NULL) { + OPENSSL_free(crngt_glob); + return NULL; + } + if (crngt_get_entropy(ctx, crngt_glob->crngt_pool, buf, + crngt_glob->crngt_prev, NULL)) { + OPENSSL_cleanse(buf, sizeof(buf)); + return crngt_glob; + } + rand_pool_free(crngt_glob->crngt_pool); + OPENSSL_free(crngt_glob); + return NULL; +} + +static const OPENSSL_CTX_METHOD rand_crng_ossl_ctx_method = { + rand_crng_ossl_ctx_new, + rand_crng_ossl_ctx_free, +}; + +int rand_crngt_get_entropy_cb(OPENSSL_CTX *ctx, + RAND_POOL *pool, + unsigned char *buf, + unsigned char *md, unsigned int *md_size) { int r; size_t n; unsigned char *p; - n = rand_pool_acquire_entropy(crngt_pool); + if (pool == NULL) + return 0; + + n = rand_pool_acquire_entropy(pool); if (n >= CRNGT_BUFSIZ) { - p = rand_pool_detach(crngt_pool); - r = EVP_Digest(p, CRNGT_BUFSIZ, md, md_size, EVP_sha256(), NULL); + EVP_MD *fmd = EVP_MD_fetch(ctx, "SHA256", ""); + if (fmd == NULL) + return 0; + p = rand_pool_detach(pool); + r = EVP_Digest(p, CRNGT_BUFSIZ, md, md_size, fmd, NULL); if (r != 0) memcpy(buf, p, CRNGT_BUFSIZ); - rand_pool_reattach(crngt_pool, p); + rand_pool_reattach(pool, p); + EVP_MD_meth_free(fmd); return r; } return 0; } -void rand_crngt_cleanup(void) -{ - rand_pool_free(crngt_pool); - crngt_pool = NULL; -} - -int rand_crngt_init(void) -{ - unsigned char buf[CRNGT_BUFSIZ]; - - if ((crngt_pool = rand_pool_new(0, CRNGT_BUFSIZ, CRNGT_BUFSIZ)) == NULL) - return 0; - if (crngt_get_entropy(buf, crngt_prev, NULL)) { - OPENSSL_cleanse(buf, sizeof(buf)); - return 1; - } - rand_crngt_cleanup(); - return 0; -} - -static CRYPTO_ONCE rand_crngt_init_flag = CRYPTO_ONCE_STATIC_INIT; -DEFINE_RUN_ONCE_STATIC(do_rand_crngt_init) -{ - return OPENSSL_init_crypto(0, NULL) - && rand_crngt_init() - && OPENSSL_atexit(&rand_crngt_cleanup); -} - -int rand_crngt_single_init(void) -{ - return RUN_ONCE(&rand_crngt_init_flag, do_rand_crngt_init); -} - size_t rand_crngt_get_entropy(RAND_DRBG *drbg, unsigned char **pout, int entropy, size_t min_len, size_t max_len, @@ -86,8 +103,11 @@ size_t rand_crngt_get_entropy(RAND_DRBG *drbg, RAND_POOL *pool; size_t q, r = 0, s, t = 0; int attempts = 3; + CRNG_TEST_GLOBAL *crngt_glob + = openssl_ctx_get_data(drbg->libctx, OPENSSL_CTX_RAND_CRNGT_INDEX, + &rand_crng_ossl_ctx_method); - if (!RUN_ONCE(&rand_crngt_init_flag, do_rand_crngt_init)) + if (crngt_glob == NULL) return 0; if ((pool = rand_pool_new(entropy, min_len, max_len)) == NULL) @@ -95,11 +115,12 @@ size_t rand_crngt_get_entropy(RAND_DRBG *drbg, while ((q = rand_pool_bytes_needed(pool, 1)) > 0 && attempts-- > 0) { s = q > sizeof(buf) ? sizeof(buf) : q; - if (!crngt_get_entropy(buf, md, &sz) - || memcmp(crngt_prev, md, sz) == 0 + if (!crngt_get_entropy(drbg->libctx, crngt_glob->crngt_pool, buf, md, + &sz) + || memcmp(crngt_glob->crngt_prev, md, sz) == 0 || !rand_pool_add(pool, buf, s, s * 8)) goto err; - memcpy(crngt_prev, md, sz); + memcpy(crngt_glob->crngt_prev, md, sz); t += s; attempts++; } diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c index ef552119..bac8d609 100644 --- a/crypto/rand/rand_egd.c +++ b/crypto/rand/rand_egd.c @@ -38,7 +38,7 @@ int RAND_egd_bytes(const char *path, int bytes) # else -# include OPENSSL_UNISTD +# include # include # include # include diff --git a/crypto/rand/rand_err.c b/crypto/rand/rand_err.c index 5c0dc3d8..d729441e 100644 --- a/crypto/rand/rand_err.c +++ b/crypto/rand/rand_err.c @@ -20,6 +20,7 @@ static const ERR_STRING_DATA RAND_str_functs[] = { {ERR_PACK(ERR_LIB_RAND, RAND_F_DRBG_SETUP, 0), "drbg_setup"}, {ERR_PACK(ERR_LIB_RAND, RAND_F_GET_ENTROPY, 0), "get_entropy"}, {ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_BYTES, 0), "RAND_bytes"}, + {ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_BYTES_EX, 0), "rand_bytes_ex"}, {ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_DRBG_ENABLE_LOCKING, 0), "rand_drbg_enable_locking"}, {ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_DRBG_GENERATE, 0), diff --git a/crypto/rand/rand_lcl.h b/crypto/rand/rand_lcl.h index 3ce5f7ad..416237ac 100644 --- a/crypto/rand/rand_lcl.h +++ b/crypto/rand/rand_lcl.h @@ -17,6 +17,7 @@ # include # include # include "internal/tsan_assist.h" +# include "internal/rand_int.h" # include "internal/numbers.h" @@ -129,7 +130,7 @@ typedef struct rand_drbg_method_st { #define HASH_PRNG_MAX_SEEDLEN (888/8) typedef struct rand_drbg_hash_st { - const EVP_MD *md; + EVP_MD *md; EVP_MD_CTX *ctx; size_t blocklen; unsigned char V[HASH_PRNG_MAX_SEEDLEN]; @@ -139,7 +140,7 @@ typedef struct rand_drbg_hash_st { } RAND_DRBG_HASH; typedef struct rand_drbg_hmac_st { - const EVP_MD *md; + EVP_MD *md; HMAC_CTX *ctx; size_t blocklen; unsigned char K[EVP_MAX_MD_SIZE]; @@ -152,7 +153,7 @@ typedef struct rand_drbg_hmac_st { typedef struct rand_drbg_ctr_st { EVP_CIPHER_CTX *ctx; EVP_CIPHER_CTX *ctx_df; - const EVP_CIPHER *cipher; + EVP_CIPHER *cipher; size_t keylen; unsigned char K[32]; unsigned char V[16]; @@ -192,6 +193,8 @@ struct rand_pool_st { */ struct rand_drbg_st { CRYPTO_RWLOCK *lock; + /* The library context this DRBG is associated with, if any */ + OPENSSL_CTX *libctx; RAND_DRBG *parent; int secure; /* 1: allocated on the secure heap, 0: otherwise */ int type; /* the nid of the underlying algorithm */ @@ -334,18 +337,11 @@ int drbg_hmac_init(RAND_DRBG *drbg); * Entropy call back for the FIPS 140-2 section 4.9.2 Conditional Tests. * These need to be exposed for the unit tests. */ -int rand_crngt_get_entropy_cb(unsigned char *buf, unsigned char *md, +int rand_crngt_get_entropy_cb(OPENSSL_CTX *ctx, RAND_POOL *pool, + unsigned char *buf, unsigned char *md, unsigned int *md_size); -extern int (*crngt_get_entropy)(unsigned char *buf, unsigned char *md, +extern int (*crngt_get_entropy)(OPENSSL_CTX *ctx, RAND_POOL *pool, + unsigned char *buf, unsigned char *md, unsigned int *md_size); -int rand_crngt_init(void); -void rand_crngt_cleanup(void); - -/* - * Expose the run once initialisation function for the unit tests because. - * they need to restart from scratch to validate the first block is skipped - * properly. - */ -int rand_crngt_single_init(void); #endif diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c index 2b779605..7768ade8 100644 --- a/crypto/rand/rand_lib.c +++ b/crypto/rand/rand_lib.c @@ -17,21 +17,20 @@ #include "rand_lcl.h" #include "e_os.h" -#ifndef OPENSSL_NO_ENGINE +#ifndef FIPS_MODE +# ifndef OPENSSL_NO_ENGINE /* non-NULL if default_RAND_meth is ENGINE-provided */ static ENGINE *funct_ref; static CRYPTO_RWLOCK *rand_engine_lock; -#endif +# endif static CRYPTO_RWLOCK *rand_meth_lock; static const RAND_METHOD *default_RAND_meth; static CRYPTO_ONCE rand_init = CRYPTO_ONCE_STATIC_INIT; -int rand_fork_count; - -static CRYPTO_RWLOCK *rand_nonce_lock; -static int rand_nonce_count; - static int rand_inited = 0; +#endif /* FIPS_MODE */ + +int rand_fork_count; #ifdef OPENSSL_RAND_SEED_RDTSC /* @@ -208,56 +207,6 @@ void rand_drbg_cleanup_entropy(RAND_DRBG *drbg, OPENSSL_secure_clear_free(out, outlen); } - -/* - * Implements the get_nonce() callback (see RAND_DRBG_set_callbacks()) - * - */ -size_t rand_drbg_get_nonce(RAND_DRBG *drbg, - unsigned char **pout, - int entropy, size_t min_len, size_t max_len) -{ - size_t ret = 0; - RAND_POOL *pool; - - struct { - void * instance; - int count; - } data; - - memset(&data, 0, sizeof(data)); - pool = rand_pool_new(0, min_len, max_len); - if (pool == NULL) - return 0; - - if (rand_pool_add_nonce_data(pool) == 0) - goto err; - - data.instance = drbg; - CRYPTO_atomic_add(&rand_nonce_count, 1, &data.count, rand_nonce_lock); - - if (rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0) == 0) - goto err; - - ret = rand_pool_length(pool); - *pout = rand_pool_detach(pool); - - err: - rand_pool_free(pool); - - return ret; -} - -/* - * Implements the cleanup_nonce() callback (see RAND_DRBG_set_callbacks()) - * - */ -void rand_drbg_cleanup_nonce(RAND_DRBG *drbg, - unsigned char *out, size_t outlen) -{ - OPENSSL_secure_clear_free(out, outlen); -} - /* * Generate additional data that can be used for the drbg. The data does * not need to contain entropy, but it's useful if it contains at least @@ -292,39 +241,32 @@ void rand_fork(void) rand_fork_count++; } +#ifndef FIPS_MODE DEFINE_RUN_ONCE_STATIC(do_rand_init) { -#ifndef OPENSSL_NO_ENGINE +# ifndef OPENSSL_NO_ENGINE rand_engine_lock = CRYPTO_THREAD_lock_new(); if (rand_engine_lock == NULL) return 0; -#endif +# endif rand_meth_lock = CRYPTO_THREAD_lock_new(); if (rand_meth_lock == NULL) - goto err1; - - rand_nonce_lock = CRYPTO_THREAD_lock_new(); - if (rand_nonce_lock == NULL) - goto err2; + goto err; if (!rand_pool_init()) - goto err3; + goto err; rand_inited = 1; return 1; -err3: - CRYPTO_THREAD_lock_free(rand_nonce_lock); - rand_nonce_lock = NULL; -err2: + err: CRYPTO_THREAD_lock_free(rand_meth_lock); rand_meth_lock = NULL; -err1: -#ifndef OPENSSL_NO_ENGINE +# ifndef OPENSSL_NO_ENGINE CRYPTO_THREAD_lock_free(rand_engine_lock); rand_engine_lock = NULL; -#endif +# endif return 0; } @@ -339,19 +281,18 @@ void rand_cleanup_int(void) meth->cleanup(); RAND_set_rand_method(NULL); rand_pool_cleanup(); -#ifndef OPENSSL_NO_ENGINE +# ifndef OPENSSL_NO_ENGINE CRYPTO_THREAD_lock_free(rand_engine_lock); rand_engine_lock = NULL; -#endif +# endif CRYPTO_THREAD_lock_free(rand_meth_lock); rand_meth_lock = NULL; - CRYPTO_THREAD_lock_free(rand_nonce_lock); - rand_nonce_lock = NULL; rand_inited = 0; } +/* TODO(3.0): Do we need to handle this somehow in the FIPS module? */ /* - * RAND_close_seed_files() ensures that any seed file decriptors are + * RAND_close_seed_files() ensures that any seed file descriptors are * closed after use. */ void RAND_keep_random_devices_open(int keep) @@ -371,8 +312,6 @@ int RAND_poll(void) { int ret = 0; - RAND_POOL *pool = NULL; - const RAND_METHOD *meth = RAND_get_rand_method(); if (meth == RAND_OpenSSL()) { @@ -389,6 +328,8 @@ int RAND_poll(void) return ret; } else { + RAND_POOL *pool = NULL; + /* fill random pool and seed the current legacy RNG */ pool = rand_pool_new(RAND_DRBG_STRENGTH, (RAND_DRBG_STRENGTH + 7) / 8, @@ -406,12 +347,14 @@ int RAND_poll(void) goto err; ret = 1; + + err: + rand_pool_free(pool); } -err: - rand_pool_free(pool); return ret; } +#endif /* FIPS_MODE */ /* * Allocate memory and initialize a new random pool @@ -708,23 +651,28 @@ int rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy) return 1; } +#ifndef FIPS_MODE int RAND_set_rand_method(const RAND_METHOD *meth) { if (!RUN_ONCE(&rand_init, do_rand_init)) return 0; CRYPTO_THREAD_write_lock(rand_meth_lock); -#ifndef OPENSSL_NO_ENGINE +# ifndef OPENSSL_NO_ENGINE ENGINE_finish(funct_ref); funct_ref = NULL; -#endif +# endif default_RAND_meth = meth; CRYPTO_THREAD_unlock(rand_meth_lock); return 1; } +#endif const RAND_METHOD *RAND_get_rand_method(void) { +#ifdef FIPS_MODE + return NULL; +#else const RAND_METHOD *tmp_meth = NULL; if (!RUN_ONCE(&rand_init, do_rand_init)) @@ -732,7 +680,7 @@ const RAND_METHOD *RAND_get_rand_method(void) CRYPTO_THREAD_write_lock(rand_meth_lock); if (default_RAND_meth == NULL) { -#ifndef OPENSSL_NO_ENGINE +# ifndef OPENSSL_NO_ENGINE ENGINE *e; /* If we have an engine that can do RAND, use it. */ @@ -744,16 +692,17 @@ const RAND_METHOD *RAND_get_rand_method(void) ENGINE_finish(e); default_RAND_meth = &rand_meth; } -#else +# else default_RAND_meth = &rand_meth; -#endif +# endif } tmp_meth = default_RAND_meth; CRYPTO_THREAD_unlock(rand_meth_lock); return tmp_meth; +#endif } -#ifndef OPENSSL_NO_ENGINE +#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODE) int RAND_set_rand_engine(ENGINE *engine) { const RAND_METHOD *tmp_meth = NULL; @@ -800,16 +749,42 @@ void RAND_add(const void *buf, int num, double randomness) * the default method, then just call RAND_bytes(). Otherwise make * sure we're instantiated and use the private DRBG. */ -int RAND_priv_bytes(unsigned char *buf, int num) +int rand_priv_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num) { - const RAND_METHOD *meth = RAND_get_rand_method(); RAND_DRBG *drbg; int ret; + const RAND_METHOD *meth = RAND_get_rand_method(); if (meth != RAND_OpenSSL()) - return RAND_bytes(buf, num); + return meth->bytes(buf, num); - drbg = RAND_DRBG_get0_private(); + drbg = OPENSSL_CTX_get0_private_drbg(ctx); + if (drbg == NULL) + return 0; + + ret = RAND_DRBG_bytes(drbg, buf, num); + return ret; +} + +int RAND_priv_bytes(unsigned char *buf, int num) +{ + return rand_priv_bytes_ex(NULL, buf, num); +} + +int rand_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num) +{ + RAND_DRBG *drbg; + int ret; + const RAND_METHOD *meth = RAND_get_rand_method(); + + if (meth != RAND_OpenSSL()) { + if (meth->bytes != NULL) + return meth->bytes(buf, num); + RANDerr(RAND_F_RAND_BYTES_EX, RAND_R_FUNC_NOT_IMPLEMENTED); + return -1; + } + + drbg = OPENSSL_CTX_get0_public_drbg(ctx); if (drbg == NULL) return 0; @@ -819,15 +794,10 @@ int RAND_priv_bytes(unsigned char *buf, int num) int RAND_bytes(unsigned char *buf, int num) { - const RAND_METHOD *meth = RAND_get_rand_method(); - - if (meth->bytes != NULL) - return meth->bytes(buf, num); - RANDerr(RAND_F_RAND_BYTES, RAND_R_FUNC_NOT_IMPLEMENTED); - return -1; + return rand_bytes_ex(NULL, buf, num); } -#if !OPENSSL_API_1_1_0 +#if !OPENSSL_API_1_1_0 && !defined(FIPS_MODE) int RAND_pseudo_bytes(unsigned char *buf, int num) { const RAND_METHOD *meth = RAND_get_rand_method(); diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c index 2b3e32dc..e45e018e 100644 --- a/crypto/rand/rand_unix.c +++ b/crypto/rand/rand_unix.c @@ -21,7 +21,7 @@ #if defined(__linux) # include #endif -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) && !defined(OPENSSL_SYS_UEFI) # include # include # include @@ -285,7 +285,7 @@ static ssize_t syscall_random(void *buf, size_t buflen) if (getentropy != NULL) return getentropy(buf, buflen) == 0 ? (ssize_t)buflen : -1; -# else +# elif !defined(FIPS_MODE) union { void *p; int (*f)(void *buffer, size_t length); @@ -489,29 +489,6 @@ size_t rand_pool_acquire_entropy(RAND_POOL *pool) bytes_needed = rand_pool_bytes_needed(pool, 1 /*entropy_factor*/); { size_t i; -#ifdef DEVRANDOM_WAIT - static int wait_done = 0; - - /* - * On some implementations reading from /dev/urandom is possible - * before it is initialized. Therefore we wait for /dev/random - * to be readable to make sure /dev/urandom is initialized. - */ - if (!wait_done && bytes_needed > 0) { - int f = open(DEVRANDOM_WAIT, O_RDONLY); - - if (f >= 0) { - fd_set fds; - - FD_ZERO(&fds); - FD_SET(f, &fds); - while (select(f+1, &fds, NULL, NULL, NULL) < 0 - && errno == EINTR); - close(f); - } - wait_done = 1; - } -#endif for (i = 0; bytes_needed > 0 && i < OSSL_NELEM(random_device_paths); i++) { ssize_t bytes = 0; diff --git a/crypto/rand/rand_win.c b/crypto/rand/rand_win.c index 17ab1371..8b874196 100644 --- a/crypto/rand/rand_win.c +++ b/crypto/rand/rand_win.c @@ -162,7 +162,7 @@ int rand_pool_add_additional_data(RAND_POOL *pool) return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0); } -# if !OPENSSL_API_1_1_0 +# if !OPENSSL_API_1_1_0 && !defined(FIPS_MODE) int RAND_event(UINT iMsg, WPARAM wParam, LPARAM lParam) { RAND_poll(); diff --git a/crypto/rc4/build.info b/crypto/rc4/build.info index 8d272e4f..30e36bac 100644 --- a/crypto/rc4/build.info +++ b/crypto/rc4/build.info @@ -1,6 +1,23 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - {- $target{rc4_asm_src} -} + +$RC4ASM=rc4_enc.c rc4_skey.c +IF[{- !$disabled{asm} -}] + $RC4ASM_x86=rc4-586.s + $RC4ASM_x86_64=rc4-x86_64.s rc4-md5-x86_64.s + $RC4ASM_s390x=rc4-s390x.s + $RC4ASM_parisc11=rc4-parisc.s + $RC4ASM_parisc20_64=$RC4ASM_parisc11 + $RC4ASM_c64xplus=rc4-c64xplus.s + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$RC4ASM_{- $target{asm_arch} -}] + $RC4ASM=$RC4ASM_{- $target{asm_arch} -} + $RC4DEF=RC4_ASM + ENDIF +ENDIF + +SOURCE[../../libcrypto]=$RC4ASM GENERATE[rc4-586.s]=asm/rc4-586.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR) diff --git a/crypto/rc5/build.info b/crypto/rc5/build.info index 928a62cd..5780f3c5 100644 --- a/crypto/rc5/build.info +++ b/crypto/rc5/build.info @@ -1,6 +1,19 @@ LIBS=../../libcrypto + +$RC5ASM=rc5_enc.c +IF[{- !$disabled{asm} -}] + $RC5ASM_x86=rc5-586.s + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$RC5ASM_{- $target{asm_arch} -}] + $RC5ASM=$RC5ASM_{- $target{asm_arch} -} + $RC5DEF=RC5_ASM + ENDIF +ENDIF + SOURCE[../../libcrypto]=\ - rc5_skey.c rc5_ecb.c {- $target{rc5_asm_src} -} rc5cfb64.c rc5ofb64.c + rc5_skey.c rc5_ecb.c $RC5ASM rc5cfb64.c rc5ofb64.c GENERATE[rc5-586.s]=asm/rc5-586.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) diff --git a/crypto/rc5/rc5_skey.c b/crypto/rc5/rc5_skey.c index 1746406c..43dc9320 100644 --- a/crypto/rc5/rc5_skey.c +++ b/crypto/rc5/rc5_skey.c @@ -10,12 +10,15 @@ #include #include "rc5_locl.h" -void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, - int rounds) +int RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, + int rounds) { RC5_32_INT L[64], l, ll, A, B, *S, k; int i, j, m, c, t, ii, jj; + if (len > 255) + return 0; + if ((rounds != RC5_16_ROUNDS) && (rounds != RC5_12_ROUNDS) && (rounds != RC5_8_ROUNDS)) rounds = RC5_16_ROUNDS; @@ -58,4 +61,6 @@ void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, if (++jj >= c) jj = 0; } + + return 1; } diff --git a/crypto/ripemd/build.info b/crypto/ripemd/build.info index a4a894e2..e2db2932 100644 --- a/crypto/ripemd/build.info +++ b/crypto/ripemd/build.info @@ -1,6 +1,19 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - rmd_dgst.c rmd_one.c {- $target{rmd160_asm_src} -} + +$RMD160ASM= +IF[{- !$disabled{asm} -}] + $RMD160ASM_x86=rmd-586.s + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$RMD160ASM_{- $target{asm_arch} -}] + $RMD160ASM=$RMD160ASM_{- $target{asm_arch} -} + $RMD160DEF=RMD160_ASM + ENDIF +ENDIF + +SOURCE[../../libcrypto]=rmd_dgst.c rmd_one.c $RMD160ASM +DEFINE[../../libcrypto]=$RMD160DEF GENERATE[rmd-586.s]=asm/rmd-586.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) diff --git a/crypto/rsa/rsa_gen.c b/crypto/rsa/rsa_gen.c index 1611fc86..dfbb79f9 100644 --- a/crypto/rsa/rsa_gen.c +++ b/crypto/rsa/rsa_gen.c @@ -256,7 +256,7 @@ static int rsa_builtin_keygen(RSA *rsa, int bits, int primes, BIGNUM *e_value, * * This strategy has the following goals: * - * 1. 1024-bit factors are effcient when using 3072 and 4096-bit key + * 1. 1024-bit factors are efficient when using 3072 and 4096-bit key * 2. stay the same logic with normal 2-prime key */ bitse -= bitsr[i]; diff --git a/crypto/s390x_arch.h b/crypto/s390x_arch.h index 501283e0..5e12542c 100644 --- a/crypto/s390x_arch.h +++ b/crypto/s390x_arch.h @@ -26,6 +26,9 @@ void s390x_kmf(const unsigned char *in, size_t len, unsigned char *out, unsigned int fc, void *param); void s390x_kma(const unsigned char *aad, size_t alen, const unsigned char *in, size_t len, unsigned char *out, unsigned int fc, void *param); +int s390x_pcc(unsigned int fc, void *param); +int s390x_kdsa(unsigned int fc, void *param, const unsigned char *in, + size_t len); /* * The field elements of OPENSSL_s390xcap_P are the 64-bit words returned by @@ -45,6 +48,8 @@ struct OPENSSL_s390xcap_st { unsigned long long kmf[2]; unsigned long long prno[2]; unsigned long long kma[2]; + unsigned long long pcc[2]; + unsigned long long kdsa[2]; }; extern struct OPENSSL_s390xcap_st OPENSSL_s390xcap_P; @@ -69,6 +74,8 @@ extern struct OPENSSL_s390xcap_st OPENSSL_s390xcap_P; # define S390X_KMF 0x90 # define S390X_PRNO 0xa0 # define S390X_KMA 0xb0 +# define S390X_PCC 0xc0 +# define S390X_KDSA 0xd0 /* Facility Bit Numbers */ # define S390X_MSA 17 /* message-security-assist */ @@ -80,6 +87,7 @@ extern struct OPENSSL_s390xcap_st OPENSSL_s390xcap_P; # define S390X_VXD 134 /* vector packed decimal */ # define S390X_VXE 135 /* vector enhancements 1 */ # define S390X_MSA8 146 /* message-security-assist-ext. 8 */ +# define S390X_MSA9 155 /* message-security-assist-ext. 9 */ /* Function Codes */ @@ -111,10 +119,24 @@ extern struct OPENSSL_s390xcap_st OPENSSL_s390xcap_P; # define S390X_SHA_512_DRNG 3 # define S390X_TRNG 114 +/* pcc */ +# define S390X_SCALAR_MULTIPLY_P256 64 +# define S390X_SCALAR_MULTIPLY_P384 65 +# define S390X_SCALAR_MULTIPLY_P521 66 + +/* kdsa */ +# define S390X_ECDSA_VERIFY_P256 1 +# define S390X_ECDSA_VERIFY_P384 2 +# define S390X_ECDSA_VERIFY_P521 3 +# define S390X_ECDSA_SIGN_P256 9 +# define S390X_ECDSA_SIGN_P384 10 +# define S390X_ECDSA_SIGN_P521 11 + /* Register 0 Flags */ # define S390X_DECRYPT 0x80 # define S390X_KMA_LPC 0x100 # define S390X_KMA_LAAD 0x200 # define S390X_KMA_HS 0x400 +# define S390X_KDSA_D 0x80 #endif diff --git a/crypto/s390xcap.c b/crypto/s390xcap.c index 717849e5..b75eacf2 100644 --- a/crypto/s390xcap.c +++ b/crypto/s390xcap.c @@ -137,6 +137,10 @@ void OPENSSL_cpuid_setup(void) OPENSSL_s390xcap_P.prno[1] &= cap.prno[1]; OPENSSL_s390xcap_P.kma[0] &= cap.kma[0]; OPENSSL_s390xcap_P.kma[1] &= cap.kma[1]; + OPENSSL_s390xcap_P.pcc[0] &= cap.pcc[0]; + OPENSSL_s390xcap_P.pcc[1] &= cap.pcc[1]; + OPENSSL_s390xcap_P.kdsa[0] &= cap.kdsa[0]; + OPENSSL_s390xcap_P.kdsa[1] &= cap.kdsa[1]; } } @@ -163,6 +167,8 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap) /*.kmf = */{0ULL, 0ULL}, /*.prno = */{0ULL, 0ULL}, /*.kma = */{0ULL, 0ULL}, + /*.pcc = */{0ULL, 0ULL}, + /*.kdsa = */{0ULL, 0ULL}, }; /*- @@ -189,6 +195,8 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap) /*.kmf = */{0ULL, 0ULL}, /*.prno = */{0ULL, 0ULL}, /*.kma = */{0ULL, 0ULL}, + /*.pcc = */{0ULL, 0ULL}, + /*.kdsa = */{0ULL, 0ULL}, }; /*- @@ -220,6 +228,8 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap) /*.kmf = */{0ULL, 0ULL}, /*.prno = */{0ULL, 0ULL}, /*.kma = */{0ULL, 0ULL}, + /*.pcc = */{0ULL, 0ULL}, + /*.kdsa = */{0ULL, 0ULL}, }; /*- @@ -257,6 +267,8 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap) /*.kmf = */{0ULL, 0ULL}, /*.prno = */{0ULL, 0ULL}, /*.kma = */{0ULL, 0ULL}, + /*.pcc = */{0ULL, 0ULL}, + /*.kdsa = */{0ULL, 0ULL}, }; /*- @@ -313,6 +325,9 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap) 0ULL}, /*.prno = */{0ULL, 0ULL}, /*.kma = */{0ULL, 0ULL}, + /*.pcc = */{S390X_CAPBIT(S390X_QUERY), + 0ULL}, + /*.kdsa = */{0ULL, 0ULL}, }; /*- @@ -369,6 +384,9 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap) 0ULL}, /*.prno = */{0ULL, 0ULL}, /*.kma = */{0ULL, 0ULL}, + /*.pcc = */{S390X_CAPBIT(S390X_QUERY), + 0ULL}, + /*.kdsa = */{0ULL, 0ULL}, }; /*- @@ -429,6 +447,9 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap) | S390X_CAPBIT(S390X_SHA_512_DRNG), 0ULL}, /*.kma = */{0ULL, 0ULL}, + /*.pcc = */{S390X_CAPBIT(S390X_QUERY), + 0ULL}, + /*.kdsa = */{0ULL, 0ULL}, }; /*- @@ -508,6 +529,101 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap) | S390X_CAPBIT(S390X_AES_192) | S390X_CAPBIT(S390X_AES_256), 0ULL}, + /*.pcc = */{S390X_CAPBIT(S390X_QUERY), + 0ULL}, + /*.kdsa = */{0ULL, 0ULL}, + }; + + /*- + * z15 (2019) - z/Architecture POP SA22-7832-12 + * Implements MSA and MSA1-9. + */ + static const struct OPENSSL_s390xcap_st z15 = { + /*.stfle = */{S390X_CAPBIT(S390X_MSA) + | S390X_CAPBIT(S390X_STCKF) + | S390X_CAPBIT(S390X_MSA5), + S390X_CAPBIT(S390X_MSA3) + | S390X_CAPBIT(S390X_MSA4), + S390X_CAPBIT(S390X_VX) + | S390X_CAPBIT(S390X_VXD) + | S390X_CAPBIT(S390X_VXE) + | S390X_CAPBIT(S390X_MSA8), + 0ULL}, + /*.kimd = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_SHA_1) + | S390X_CAPBIT(S390X_SHA_256) + | S390X_CAPBIT(S390X_SHA_512) + | S390X_CAPBIT(S390X_SHA3_224) + | S390X_CAPBIT(S390X_SHA3_256) + | S390X_CAPBIT(S390X_SHA3_384) + | S390X_CAPBIT(S390X_SHA3_512) + | S390X_CAPBIT(S390X_SHAKE_128) + | S390X_CAPBIT(S390X_SHAKE_256), + S390X_CAPBIT(S390X_GHASH)}, + /*.klmd = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_SHA_1) + | S390X_CAPBIT(S390X_SHA_256) + | S390X_CAPBIT(S390X_SHA_512) + | S390X_CAPBIT(S390X_SHA3_224) + | S390X_CAPBIT(S390X_SHA3_256) + | S390X_CAPBIT(S390X_SHA3_384) + | S390X_CAPBIT(S390X_SHA3_512) + | S390X_CAPBIT(S390X_SHAKE_128) + | S390X_CAPBIT(S390X_SHAKE_256), + 0ULL}, + /*.km = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_AES_128) + | S390X_CAPBIT(S390X_AES_192) + | S390X_CAPBIT(S390X_AES_256) + | S390X_CAPBIT(S390X_XTS_AES_128) + | S390X_CAPBIT(S390X_XTS_AES_256), + 0ULL}, + /*.kmc = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_AES_128) + | S390X_CAPBIT(S390X_AES_192) + | S390X_CAPBIT(S390X_AES_256), + 0ULL}, + /*.kmac = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_AES_128) + | S390X_CAPBIT(S390X_AES_192) + | S390X_CAPBIT(S390X_AES_256), + 0ULL}, + /*.kmctr = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_AES_128) + | S390X_CAPBIT(S390X_AES_192) + | S390X_CAPBIT(S390X_AES_256), + 0ULL}, + /*.kmo = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_AES_128) + | S390X_CAPBIT(S390X_AES_192) + | S390X_CAPBIT(S390X_AES_256), + 0ULL}, + /*.kmf = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_AES_128) + | S390X_CAPBIT(S390X_AES_192) + | S390X_CAPBIT(S390X_AES_256), + 0ULL}, + /*.prno = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_SHA_512_DRNG), + S390X_CAPBIT(S390X_TRNG)}, + /*.kma = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_AES_128) + | S390X_CAPBIT(S390X_AES_192) + | S390X_CAPBIT(S390X_AES_256), + 0ULL}, + /*.pcc = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_SCALAR_MULTIPLY_P256) + | S390X_CAPBIT(S390X_SCALAR_MULTIPLY_P384) + | S390X_CAPBIT(S390X_SCALAR_MULTIPLY_P521), + 0ULL}, + /*.kdsa = */{S390X_CAPBIT(S390X_QUERY) + | S390X_CAPBIT(S390X_ECDSA_VERIFY_P256) + | S390X_CAPBIT(S390X_ECDSA_VERIFY_P384) + | S390X_CAPBIT(S390X_ECDSA_VERIFY_P521) + | S390X_CAPBIT(S390X_ECDSA_SIGN_P256) + | S390X_CAPBIT(S390X_ECDSA_SIGN_P384) + | S390X_CAPBIT(S390X_ECDSA_SIGN_P521), + 0ULL}, }; char *tok_begin, *tok_end, *buff, tok[S390X_STFLE_MAX][LEN + 1]; @@ -551,6 +667,8 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap) else if TOK_FUNC(kmf) else if TOK_FUNC(prno) else if TOK_FUNC(kma) + else if TOK_FUNC(pcc) + else if TOK_FUNC(kdsa) /* CPU model tokens */ else if TOK_CPU(z900) @@ -561,6 +679,7 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap) else if TOK_CPU(zEC12) else if TOK_CPU(z13) else if TOK_CPU(z14) + else if TOK_CPU(z15) /* whitespace(ignored) or invalid tokens */ else { diff --git a/crypto/s390xcpuid.pl b/crypto/s390xcpuid.pl index 790fbc2c..2678b21e 100755 --- a/crypto/s390xcpuid.pl +++ b/crypto/s390xcpuid.pl @@ -77,8 +77,13 @@ OPENSSL_s390x_functions: stg %r0,S390X_PRNO+8(%r4) stg %r0,S390X_KMA(%r4) stg %r0,S390X_KMA+8(%r4) + stg %r0,S390X_PCC(%r4) + stg %r0,S390X_PCC+8(%r4) + stg %r0,S390X_KDSA(%r4) + stg %r0,S390X_KDSA+8(%r4) lmg %r2,%r3,S390X_STFLE(%r4) + tmhl %r2,0x4000 # check for message-security-assist jz .Lret @@ -102,6 +107,13 @@ OPENSSL_s390x_functions: la %r1,S390X_KMAC(%r4) .long 0xb91e0042 # kmac %r4,%r2 + tmhh %r3,0x0003 # check for message-security-assist-3 + jz .Lret + + lghi %r0,S390X_QUERY # query pcc capability vector + la %r1,S390X_PCC(%r4) + .long 0xb92c0000 # pcc + tmhh %r3,0x0004 # check for message-security-assist-4 jz .Lret @@ -125,6 +137,7 @@ OPENSSL_s390x_functions: .long 0xb93c0042 # prno %r4,%r2 lg %r2,S390X_STFLE+16(%r4) + tmhl %r2,0x2000 # check for message-security-assist-8 jz .Lret @@ -132,6 +145,13 @@ OPENSSL_s390x_functions: la %r1,S390X_KMA(%r4) .long 0xb9294022 # kma %r2,%r4,%r2 + tmhl %r2,0x0010 # check for message-security-assist-9 + jz .Lret + + lghi %r0,S390X_QUERY # query kdsa capability vector + la %r1,S390X_KDSA(%r4) + .long 0xb93a0002 # kdsa %r0,%r2 + .Lret: br $ra .size OPENSSL_s390x_functions,.-OPENSSL_s390x_functions @@ -422,6 +442,57 @@ s390x_kma: ___ } +################ +# void s390x_pcc(unsigned int fc, void *param) +{ +my ($fc,$param) = map("%r$_",(2..3)); +$code.=<<___; +.globl s390x_pcc +.type s390x_pcc,\@function +.align 16 +s390x_pcc: + lr %r0,$fc + l${g}r %r1,$param + lhi %r2,0 + + .long 0xb92c0000 # pcc + brc 1,.-4 # pay attention to "partial completion" + brc 7,.Lpcc_err # if CC==0 return 0, else return 1 +.Lpcc_out: + br $ra +.Lpcc_err: + lhi %r2,1 + j .Lpcc_out +.size s390x_pcc,.-s390x_pcc +___ +} + +################ +# void s390x_kdsa(unsigned int fc, void *param, +# const unsigned char *in, size_t len) +{ +my ($fc,$param,$in,$len) = map("%r$_",(2..5)); +$code.=<<___; +.globl s390x_kdsa +.type s390x_kdsa,\@function +.align 16 +s390x_kdsa: + lr %r0,$fc + l${g}r %r1,$param + lhi %r2,0 + + .long 0xb93a0004 # kdsa %r0,$in + brc 1,.-4 # pay attention to "partial completion" + brc 7,.Lkdsa_err # if CC==0 return 0, else return 1 +.Lkdsa_out: + br $ra +.Lkdsa_err: + lhi %r2,1 + j .Lkdsa_out +.size s390x_kdsa,.-s390x_kdsa +___ +} + $code.=<<___; .section .init brasl $ra,OPENSSL_cpuid_setup diff --git a/crypto/sha/asm/keccak1600-armv8.pl b/crypto/sha/asm/keccak1600-armv8.pl index dc72f18b..66206908 100755 --- a/crypto/sha/asm/keccak1600-armv8.pl +++ b/crypto/sha/asm/keccak1600-armv8.pl @@ -731,7 +731,7 @@ $code.=<<___; blo .Lprocess_block_ce ldr d31,[$inp],#8 // *inp++ #ifdef __AARCH64EB__ - rev v31.16b,v31.16b + rev64 v31.16b,v31.16b #endif eor $A[$j/5][$j%5],$A[$j/5][$j%5],v31.16b beq .Lprocess_block_ce @@ -740,7 +740,7 @@ ___ $code.=<<___; ldr d31,[$inp],#8 // *inp++ #ifdef __AARCH64EB__ - rev v31.16b,v31.16b + rev64 v31.16b,v31.16b #endif eor $A[4][4],$A[4][4],v31.16b diff --git a/crypto/sha/asm/sha512-sparcv9.pl b/crypto/sha/asm/sha512-sparcv9.pl index 7f57010f..daf6d226 100644 --- a/crypto/sha/asm/sha512-sparcv9.pl +++ b/crypto/sha/asm/sha512-sparcv9.pl @@ -27,7 +27,7 @@ # over 2x than 32-bit code. X[16] resides on stack, but access to it # is scheduled for L2 latency and staged through 32 least significant # bits of %l0-%l7. The latter is done to achieve 32-/64-bit ABI -# duality. Nevetheless it's ~40% faster than SHA256, which is pretty +# duality. Nevertheless it's ~40% faster than SHA256, which is pretty # good [optimal coefficient is 50%]. # # SHA512 on UltraSPARC T1. diff --git a/crypto/sha/build.info b/crypto/sha/build.info index 242a08e3..187d0c49 100644 --- a/crypto/sha/build.info +++ b/crypto/sha/build.info @@ -1,9 +1,83 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - sha1dgst.c sha1_one.c sha256.c sha512.c {- $target{sha1_asm_src} -} \ - {- $target{keccak1600_asm_src} -} -SOURCE[../../providers/fips]= sha256.c +$SHA1ASM= +IF[{- !$disabled{asm} -}] + $SHA1ASM_x86=sha1-586.s sha256-586.s sha512-586.s + $SHA1DEF_x86=SHA1_ASM SHA256_ASM SHA512_ASM + $SHA1ASM_x86_64=\ + sha1-x86_64.s sha256-x86_64.s sha512-x86_64.s sha1-mb-x86_64.s \ + sha256-mb-x86_64.s + $SHA1DEF_x86_64=SHA1_ASM SHA256_ASM SHA512_ASM + + $SHA1ASM_ia64=sha1-ia64.s sha256-ia64.s sha512-ia64.s + $SHA1DEF_ia64=SHA1_ASM SHA256_ASM SHA512_ASM + + $SHA1ASM_sparcv9=sha1-sparcv9.S sha256-sparcv9.S sha512-sparcv9.S + $SHA1DEF_sparcv9=SHA1_ASM SHA256_ASM SHA512_ASM + + $SHA1ASM_alpha=sha1-alpha.S + $SHA1DEF_alpha=SHA1_ASM + + $SHA1ASM_mips32=sha1-mips.S sha256-mips.S + $SHA1DEF_mips32=SHA1_ASM SHA256_ASM + $SHA1ASM_mips64=$SHA1ASM_mips32 sha512-mips.S + $SHA1DEF_mips64=$SHA1DEF_mips32 SHA512_ASM + + $SHA1ASM_s390x=sha1-s390x.S sha256-s390x.S sha512-s390x.S + $SHA1DEF_s390x=SHA1_ASM SHA256_ASM SHA512_ASM + + $SHA1ASM_armv4=sha1-armv4-large.S sha256-armv4.S sha512-armv4.S + $SHA1DEF_armv4=SHA1_ASM SHA256_ASM SHA512_ASM + $SHA1ASM_aarch64=sha1-armv8.S sha256-armv8.S sha512-armv8.S + $SHA1DEF_aarch64=SHA1_ASM SHA256_ASM SHA512_ASM + + $SHA1ASM_parisc11=sha1-parisc.s sha256-parisc.s sha512-parisc.s + $SHA1DEF_parisc11=SHA1_ASM SHA256_ASM SHA512_ASM + $SHA1ASM_parisc20_64=$SHA1ASM_parisc11 + $SHA1DEF_parisc20_64=$SHA1DEF_parisc11 + + $SHA1ASM_ppc32=\ + sha1-ppc.s sha256-ppc.s sha512-ppc.s sha256p8-ppc.s sha512p8-ppc.s + $SHA1DEF_ppc32=SHA1_ASM SHA256_ASM SHA512_ASM + $SHA1ASM_ppc64=$SHA1ASM_ppc32 + $SHA1DEF_ppc64=$SHA1DEF_ppc32 + + $SHA1ASM_c64xplus=sha1-c64xplus.s sha256-c64xplus.s sha512-c64xplus.s + $SHA1DEF_c64xplus=SHA1_ASM SHA256_ASM SHA512_ASM + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$SHA1ASM_{- $target{asm_arch} -}] + $SHA1ASM=$SHA1ASM_{- $target{asm_arch} -} + $SHA1DEF=$SHA1DEF_{- $target{asm_arch} -} + ENDIF +ENDIF + +$KECCAK1600ASM=keccak1600.c +IF[{- !$disabled{asm} -}] + $KECCAK1600ASM_x86= + $KECCAK1600ASM_x86_64=keccak1600-x86_64.s + + $KECCAK1600ASM_s390x=keccak1600-s390x.S + + $KECCAK1600ASM_armv4=keccak1600-armv4.S + $KECCAK1600ASM_aarch64=keccak1600-armv8.S + + $KECCAK1600ASM_ppc64=keccak1600-ppc64.s + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$KECCAK1600ASM_{- $target{asm_arch} -}] + $KECCAK1600ASM=$KECCAK1600ASM_{- $target{asm_arch} -} + $KECCAK1600DEF=KECCAK1600_ASM + ENDIF +ENDIF + +$COMMON=sha1dgst.c sha256.c sha512.c sha3.c $SHA1ASM $KECCAK1600ASM +SOURCE[../../libcrypto]=$COMMON sha1_one.c +DEFINE[../../libcrypto]=$SHA1DEF $KECCAK1600DEF +SOURCE[../../providers/fips]= $COMMON +DEFINE[../../providers/fips]= $SHA1DEF $KECCAK1600DEF GENERATE[sha1-586.s]=asm/sha1-586.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR) diff --git a/crypto/sha/keccak1600.c b/crypto/sha/keccak1600.c index ff53a260..ccbf12b1 100644 --- a/crypto/sha/keccak1600.c +++ b/crypto/sha/keccak1600.c @@ -1090,7 +1090,7 @@ size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len, } /* - * SHA3_squeeze is called once at the end to generate |out| hash value + * sha3_squeeze is called once at the end to generate |out| hash value * of |len| bytes. */ void SHA3_squeeze(uint64_t A[5][5], unsigned char *out, size_t len, size_t r) diff --git a/crypto/sha/sha1dgst.c b/crypto/sha/sha1dgst.c index d31a5d4b..4881bcb1 100644 --- a/crypto/sha/sha1dgst.c +++ b/crypto/sha/sha1dgst.c @@ -10,8 +10,65 @@ #include #include -# include +#include +#include +#include /* The implementation is in ../md32_common.h */ -# include "sha_locl.h" +#include "sha_locl.h" +#include "internal/sha.h" + +int sha1_ctrl(SHA_CTX *sha1, int cmd, int mslen, void *ms) +{ + unsigned char padtmp[40]; + unsigned char sha1tmp[SHA_DIGEST_LENGTH]; + + if (cmd != EVP_CTRL_SSL3_MASTER_SECRET) + return -2; + + if (sha1 == NULL) + return 0; + + /* SSLv3 client auth handling: see RFC-6101 5.6.8 */ + if (mslen != 48) + return 0; + + /* At this point hash contains all handshake messages, update + * with master secret and pad_1. + */ + + if (SHA1_Update(sha1, ms, mslen) <= 0) + return 0; + + /* Set padtmp to pad_1 value */ + memset(padtmp, 0x36, sizeof(padtmp)); + + if (!SHA1_Update(sha1, padtmp, sizeof(padtmp))) + return 0; + + if (!SHA1_Final(sha1tmp, sha1)) + return 0; + + /* Reinitialise context */ + + if (!SHA1_Init(sha1)) + return 0; + + if (SHA1_Update(sha1, ms, mslen) <= 0) + return 0; + + /* Set padtmp to pad_2 value */ + memset(padtmp, 0x5c, sizeof(padtmp)); + + if (!SHA1_Update(sha1, padtmp, sizeof(padtmp))) + return 0; + + if (!SHA1_Update(sha1, sha1tmp, sizeof(sha1tmp))) + return 0; + + /* Now when ctx is finalised it will return the SSL v3 hash value */ + OPENSSL_cleanse(sha1tmp, sizeof(sha1tmp)); + + return 1; +} diff --git a/crypto/sha/sha3.c b/crypto/sha/sha3.c new file mode 100644 index 00000000..19ef4266 --- /dev/null +++ b/crypto/sha/sha3.c @@ -0,0 +1,106 @@ +/* + * Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include "internal/sha3.h" + +void SHA3_squeeze(uint64_t A[5][5], unsigned char *out, size_t len, size_t r); + +void sha3_reset(KECCAK1600_CTX *ctx) +{ + memset(ctx->A, 0, sizeof(ctx->A)); + ctx->bufsz = 0; +} + +int sha3_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen) +{ + size_t bsz = SHA3_BLOCKSIZE(bitlen); + + if (bsz <= sizeof(ctx->buf)) { + sha3_reset(ctx); + ctx->block_size = bsz; + ctx->md_size = bitlen / 8; + ctx->pad = pad; + return 1; + } + + return 0; +} + +int keccak_kmac_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen) +{ + int ret = sha3_init(ctx, pad, bitlen); + + if (ret) + ctx->md_size *= 2; + return ret; +} + +int sha3_update(KECCAK1600_CTX *ctx, const void *_inp, size_t len) +{ + const unsigned char *inp = _inp; + size_t bsz = ctx->block_size; + size_t num, rem; + + if (len == 0) + return 1; + + if ((num = ctx->bufsz) != 0) { /* process intermediate buffer? */ + rem = bsz - num; + + if (len < rem) { + memcpy(ctx->buf + num, inp, len); + ctx->bufsz += len; + return 1; + } + /* + * We have enough data to fill or overflow the intermediate + * buffer. So we append |rem| bytes and process the block, + * leaving the rest for later processing... + */ + memcpy(ctx->buf + num, inp, rem); + inp += rem, len -= rem; + (void)SHA3_absorb(ctx->A, ctx->buf, bsz, bsz); + ctx->bufsz = 0; + /* ctx->buf is processed, ctx->num is guaranteed to be zero */ + } + + if (len >= bsz) + rem = SHA3_absorb(ctx->A, inp, len, bsz); + else + rem = len; + + if (rem) { + memcpy(ctx->buf, inp + len - rem, rem); + ctx->bufsz = rem; + } + + return 1; +} + +int sha3_final(unsigned char *md, KECCAK1600_CTX *ctx) +{ + size_t bsz = ctx->block_size; + size_t num = ctx->bufsz; + + /* + * Pad the data with 10*1. Note that |num| can be |bsz - 1| + * in which case both byte operations below are performed on + * same byte... + */ + memset(ctx->buf + num, 0, bsz - num); + ctx->buf[num] = ctx->pad; + ctx->buf[bsz - 1] |= 0x80; + + (void)SHA3_absorb(ctx->A, ctx->buf, bsz, bsz); + + SHA3_squeeze(ctx->A, md, ctx->md_size, bsz); + + return 1; +} diff --git a/crypto/siphash/siphash_meth.c b/crypto/siphash/siphash_meth.c index 37cb286e..5fcff2d1 100644 --- a/crypto/siphash/siphash_meth.c +++ b/crypto/siphash/siphash_meth.c @@ -31,10 +31,17 @@ static void siphash_free(EVP_MAC_IMPL *sctx) OPENSSL_free(sctx); } -static int siphash_copy(EVP_MAC_IMPL *sdst, EVP_MAC_IMPL *ssrc) +static EVP_MAC_IMPL *siphash_dup(const EVP_MAC_IMPL *ssrc) { + EVP_MAC_IMPL *sdst; + + sdst = siphash_new(); + if (sdst == NULL) + return NULL; + *sdst = *ssrc; - return 1; + + return sdst; } static size_t siphash_size(EVP_MAC_IMPL *sctx) @@ -128,7 +135,7 @@ static int siphash_ctrl_str(EVP_MAC_IMPL *ctx, const EVP_MAC siphash_meth = { EVP_MAC_SIPHASH, siphash_new, - siphash_copy, + siphash_dup, siphash_free, siphash_size, siphash_init, diff --git a/crypto/sm2/sm2_sign.c b/crypto/sm2/sm2_sign.c index 6c2e1ca5..38e55624 100644 --- a/crypto/sm2/sm2_sign.c +++ b/crypto/sm2/sm2_sign.c @@ -313,12 +313,12 @@ static int sm2_sig_verify(const EC_KEY *key, const ECDSA_SIG *sig, /* * B1: verify whether r' in [1,n-1], verification failed if not - * B2: vefify whether s' in [1,n-1], verification failed if not + * B2: verify whether s' in [1,n-1], verification failed if not * B3: set M'~=ZA || M' * B4: calculate e'=Hv(M'~) * B5: calculate t = (r' + s') modn, verification failed if t=0 * B6: calculate the point (x1', y1')=[s']G + [t]PA - * B7: calculate R=(e'+x1') modn, verfication pass if yes, otherwise failed + * B7: calculate R=(e'+x1') modn, verification pass if yes, otherwise failed */ ECDSA_SIG_get0(sig, &r, &s); diff --git a/crypto/sm3/m_sm3.c b/crypto/sm3/m_sm3.c index 877dedbe..38ddbfe3 100644 --- a/crypto/sm3/m_sm3.c +++ b/crypto/sm3/m_sm3.c @@ -12,8 +12,8 @@ #ifndef OPENSSL_NO_SM3 # include -# include "internal/evp_int.h" # include "internal/sm3.h" +# include "internal/evp_int.h" static int init(EVP_MD_CTX *ctx) { diff --git a/crypto/sm3/sm3_locl.h b/crypto/sm3/sm3_locl.h index e1fcede7..a5b79623 100644 --- a/crypto/sm3/sm3_locl.h +++ b/crypto/sm3/sm3_locl.h @@ -34,6 +34,7 @@ } while (0) #define HASH_BLOCK_DATA_ORDER sm3_block_data_order +void sm3_block_data_order(SM3_CTX *c, const void *p, size_t num); void sm3_transform(SM3_CTX *c, const unsigned char *data); #include "internal/md32_common.h" diff --git a/crypto/sparcv9cap.c b/crypto/sparcv9cap.c index ec825662..e48ebf7e 100644 --- a/crypto/sparcv9cap.c +++ b/crypto/sparcv9cap.c @@ -24,6 +24,11 @@ __attribute__ ((visibility("hidden"))) #endif unsigned int OPENSSL_sparcv9cap_P[2] = { SPARCV9_TICK_PRIVILEGED, 0 }; +/* + * TODO(3.0): Temporarily disabled some assembler that hasn't been brought into + * the FIPS module yet. + */ +#ifndef FIPS_MODE int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num) { @@ -86,6 +91,7 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, } return bn_mul_mont_int(rp, ap, bp, np, n0, num); } +#endif /* FIPS_MODE */ unsigned long _sparcv9_rdtick(void); void _sparcv9_vis1_probe(void); diff --git a/crypto/sparse_array.c b/crypto/sparse_array.c index f534c047..a74db5d2 100644 --- a/crypto/sparse_array.c +++ b/crypto/sparse_array.c @@ -13,7 +13,7 @@ #include "internal/sparse_array.h" /* - * How many bits are used to index each level in the tree structre? + * How many bits are used to index each level in the tree structure? * This setting determines the number of pointers stored in each node of the * tree used to represent the sparse array. Having more pointers reduces the * depth of the tree but potentially wastes more memory. That is, this is a diff --git a/crypto/store/loader_file.c b/crypto/store/loader_file.c index cac86987..5a704995 100644 --- a/crypto/store/loader_file.c +++ b/crypto/store/loader_file.c @@ -172,7 +172,7 @@ typedef OSSL_STORE_INFO *(*file_try_decode_fn)(const char *pem_name, typedef int (*file_eof_fn)(void *handler_ctx); /* * The destroy_ctx function is used to destroy the handler_ctx that was - * intiated by a repeatable try_decode fuction. This is only used when + * initiated by a repeatable try_decode function. This is only used when * the handler is marked repeatable. */ typedef void (*file_destroy_ctx_fn)(void **handler_ctx); @@ -470,7 +470,7 @@ static FILE_HANDLER PrivateKey_handler = { }; /* - * Public key decoder. Only supports SubjectPublicKeyInfo formated keys. + * Public key decoder. Only supports SubjectPublicKeyInfo formatted keys. */ static OSSL_STORE_INFO *try_decode_PUBKEY(const char *pem_name, const char *pem_header, @@ -860,10 +860,10 @@ static OSSL_STORE_LOADER_CTX *file_open(const OSSL_STORE_LOADER *loader, if (ctx->_.dir.last_entry == NULL) { if (ctx->_.dir.last_errno != 0) { char errbuf[256]; - errno = ctx->_.dir.last_errno; - openssl_strerror_r(errno, errbuf, sizeof(errbuf)); OSSL_STOREerr(OSSL_STORE_F_FILE_OPEN, ERR_R_SYS_LIB); - ERR_add_error_data(1, errbuf); + errno = ctx->_.dir.last_errno; + if (openssl_strerror_r(errno, errbuf, sizeof(errbuf))) + ERR_add_error_data(1, errbuf); goto err; } ctx->_.dir.end_reached = 1; @@ -1260,11 +1260,11 @@ static OSSL_STORE_INFO *file_load(OSSL_STORE_LOADER_CTX *ctx, if (!ctx->_.dir.end_reached) { char errbuf[256]; assert(ctx->_.dir.last_errno != 0); + OSSL_STOREerr(OSSL_STORE_F_FILE_LOAD, ERR_R_SYS_LIB); errno = ctx->_.dir.last_errno; ctx->errcnt++; - openssl_strerror_r(errno, errbuf, sizeof(errbuf)); - OSSL_STOREerr(OSSL_STORE_F_FILE_LOAD, ERR_R_SYS_LIB); - ERR_add_error_data(1, errbuf); + if (openssl_strerror_r(errno, errbuf, sizeof(errbuf))) + ERR_add_error_data(1, errbuf); } return NULL; } diff --git a/crypto/store/store_lib.c b/crypto/store/store_lib.c index ebe91823..8c55c431 100644 --- a/crypto/store/store_lib.c +++ b/crypto/store/store_lib.c @@ -228,7 +228,7 @@ int OSSL_STORE_close(OSSL_STORE_CTX *ctx) * Functions to generate OSSL_STORE_INFOs, one function for each type we * support having in them as well as a generic constructor. * - * In all cases, ownership of the object is transfered to the OSSL_STORE_INFO + * In all cases, ownership of the object is transferred to the OSSL_STORE_INFO * and will therefore be freed when the OSSL_STORE_INFO is freed. */ static OSSL_STORE_INFO *store_info_new(int type, void *data) diff --git a/crypto/trace.c b/crypto/trace.c index ecfc6d4e..d9524da1 100644 --- a/crypto/trace.c +++ b/crypto/trace.c @@ -223,9 +223,16 @@ static int set_trace_data(int category, int type, BIO **channel, int (*attach_cb)(int, int, const void *), int (*detach_cb)(int, int, const void *)) { - BIO *curr_channel = trace_channels[category].bio; - char *curr_prefix = trace_channels[category].prefix; - char *curr_suffix = trace_channels[category].suffix; + BIO *curr_channel = NULL; + char *curr_prefix = NULL; + char *curr_suffix = NULL; + + /* Ensure ossl_trace_init() is called */ + OPENSSL_init_crypto(0, NULL); + + curr_channel = trace_channels[category].bio; + curr_prefix = trace_channels[category].prefix; + curr_suffix = trace_channels[category].suffix; /* Make sure to run the detach callback first on all data */ if (prefix != NULL && curr_prefix != NULL) { diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c index a3a00652..8c3502e8 100644 --- a/crypto/ui/ui_lib.c +++ b/crypto/ui/ui_lib.c @@ -500,6 +500,7 @@ int UI_process(UI *ui) if (ui->meth->ui_flush != NULL) switch (ui->meth->ui_flush(ui)) { case -1: /* Interrupt/Cancel/something... */ + ui->flags &= ~UI_FLAG_REDOABLE; ok = -2; goto err; case 0: /* Errors */ @@ -517,6 +518,7 @@ int UI_process(UI *ui) sk_UI_STRING_value(ui->strings, i))) { case -1: /* Interrupt/Cancel/something... */ + ui->flags &= ~UI_FLAG_REDOABLE; ok = -2; goto err; case 0: /* Errors */ diff --git a/crypto/ui/ui_openssl.c b/crypto/ui/ui_openssl.c index 04d4f6e4..4c1ec554 100644 --- a/crypto/ui/ui_openssl.c +++ b/crypto/ui/ui_openssl.c @@ -34,11 +34,7 @@ # include # if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) -# ifdef OPENSSL_UNISTD -# include OPENSSL_UNISTD -# else -# include -# endif +# include /* * If unistd.h defines _POSIX_VERSION, we conclude that we are on a POSIX * system and have sigaction and termios. @@ -79,7 +75,7 @@ * systems that require something different. * * Note: we do not use SGTTY unless it's defined by the configuration. We - * may eventually opt to remove it's use entirely. + * may eventually opt to remove its use entirely. */ # if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY) diff --git a/crypto/uid.c b/crypto/uid.c index 494dbdef..55e276df 100644 --- a/crypto/uid.c +++ b/crypto/uid.c @@ -10,25 +10,25 @@ #include #include -#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) || defined(__DragonFly__) - -# include OPENSSL_UNISTD - -int OPENSSL_issetugid(void) -{ - return issetugid(); -} - -#elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) int OPENSSL_issetugid(void) { return 0; } +#elif defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) || defined(__DragonFly__) + +# include + +int OPENSSL_issetugid(void) +{ + return issetugid(); +} + #else -# include OPENSSL_UNISTD +# include # include # if defined(__GLIBC__) && defined(__GLIBC_PREREQ) diff --git a/crypto/whrlpool/build.info b/crypto/whrlpool/build.info index 4b167b50..f67bf41b 100644 --- a/crypto/whrlpool/build.info +++ b/crypto/whrlpool/build.info @@ -1,5 +1,24 @@ LIBS=../../libcrypto -SOURCE[../../libcrypto]=wp_dgst.c {- $target{wp_asm_src} -} + +$WPASM=wp_block.c +IF[{- !$disabled{asm} -}] + IF[{- $config{processor} ne "386" -}] + $WPASM_x86=wp_block.c wp-mmx.s + $WPDEF_x86=WHIRLPOOL_ASM + ENDIF + $WPASM_x86_64=wp-x86_64.s + $WPDEF_x86_64=WHIRLPOOL_ASM + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$WPASM_{- $target{asm_arch} -}] + $WPASM=$WPASM_{- $target{asm_arch} -} + $WPDEF=$WPDEF_{- $target{asm_arch} -} + ENDIF +ENDIF + +SOURCE[../../libcrypto]=wp_dgst.c $WPASM +DEFINE[../../libcrypto]=$WPDEF GENERATE[wp-mmx.s]=asm/wp-mmx.pl \ $(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR) diff --git a/crypto/x509/build.info b/crypto/x509/build.info index afd0b613..bee9f809 100644 --- a/crypto/x509/build.info +++ b/crypto/x509/build.info @@ -7,4 +7,11 @@ SOURCE[../../libcrypto]=\ x509type.c x509_meth.c x509_lu.c x_all.c x509_txt.c \ x509_trs.c by_file.c by_dir.c x509_vpm.c \ x_crl.c t_crl.c x_req.c t_req.c x_x509.c t_x509.c \ - x_pubkey.c x_x509a.c x_attrib.c x_exten.c x_name.c + x_pubkey.c x_x509a.c x_attrib.c x_exten.c x_name.c \ + v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c \ + v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c \ + v3_pku.c v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c \ + v3_info.c v3_akeya.c v3_pmaps.c v3_pcons.c v3_ncons.c \ + v3_pcia.c v3_pci.c \ + pcy_cache.c pcy_node.c pcy_data.c pcy_map.c pcy_tree.c pcy_lib.c \ + v3_asid.c v3_addr.c v3_tlsf.c v3_admis.c diff --git a/crypto/x509v3/ext_dat.h b/crypto/x509/ext_dat.h similarity index 100% rename from crypto/x509v3/ext_dat.h rename to crypto/x509/ext_dat.h diff --git a/crypto/x509v3/pcy_cache.c b/crypto/x509/pcy_cache.c similarity index 100% rename from crypto/x509v3/pcy_cache.c rename to crypto/x509/pcy_cache.c diff --git a/crypto/x509v3/pcy_data.c b/crypto/x509/pcy_data.c similarity index 100% rename from crypto/x509v3/pcy_data.c rename to crypto/x509/pcy_data.c diff --git a/crypto/x509v3/pcy_int.h b/crypto/x509/pcy_int.h similarity index 100% rename from crypto/x509v3/pcy_int.h rename to crypto/x509/pcy_int.h diff --git a/crypto/x509v3/pcy_lib.c b/crypto/x509/pcy_lib.c similarity index 100% rename from crypto/x509v3/pcy_lib.c rename to crypto/x509/pcy_lib.c diff --git a/crypto/x509v3/pcy_map.c b/crypto/x509/pcy_map.c similarity index 100% rename from crypto/x509v3/pcy_map.c rename to crypto/x509/pcy_map.c diff --git a/crypto/x509v3/pcy_node.c b/crypto/x509/pcy_node.c similarity index 100% rename from crypto/x509v3/pcy_node.c rename to crypto/x509/pcy_node.c diff --git a/crypto/x509v3/pcy_tree.c b/crypto/x509/pcy_tree.c similarity index 100% rename from crypto/x509v3/pcy_tree.c rename to crypto/x509/pcy_tree.c diff --git a/crypto/x509v3/standard_exts.h b/crypto/x509/standard_exts.h similarity index 100% rename from crypto/x509v3/standard_exts.h rename to crypto/x509/standard_exts.h diff --git a/crypto/x509/t_req.c b/crypto/x509/t_req.c index 28157de7..8af6510b 100644 --- a/crypto/x509/t_req.c +++ b/crypto/x509/t_req.c @@ -127,6 +127,10 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, if ((j = i2a_ASN1_OBJECT(bp, aobj)) > 0) { ii = 0; count = X509_ATTRIBUTE_count(a); + if (count == 0) { + X509err(X509_F_X509_REQ_PRINT_EX, X509_R_INVALID_ATTRIBUTES); + return 0; + } get_next: at = X509_ATTRIBUTE_get0_type(a, ii); type = at->type; diff --git a/crypto/x509v3/v3_addr.c b/crypto/x509/v3_addr.c similarity index 100% rename from crypto/x509v3/v3_addr.c rename to crypto/x509/v3_addr.c diff --git a/crypto/x509v3/v3_admis.c b/crypto/x509/v3_admis.c similarity index 100% rename from crypto/x509v3/v3_admis.c rename to crypto/x509/v3_admis.c diff --git a/crypto/x509v3/v3_admis.h b/crypto/x509/v3_admis.h similarity index 100% rename from crypto/x509v3/v3_admis.h rename to crypto/x509/v3_admis.h diff --git a/crypto/x509v3/v3_akey.c b/crypto/x509/v3_akey.c similarity index 100% rename from crypto/x509v3/v3_akey.c rename to crypto/x509/v3_akey.c diff --git a/crypto/x509v3/v3_akeya.c b/crypto/x509/v3_akeya.c similarity index 100% rename from crypto/x509v3/v3_akeya.c rename to crypto/x509/v3_akeya.c diff --git a/crypto/x509v3/v3_alt.c b/crypto/x509/v3_alt.c similarity index 98% rename from crypto/x509v3/v3_alt.c rename to crypto/x509/v3_alt.c index 9b627e07..30799404 100644 --- a/crypto/x509v3/v3_alt.c +++ b/crypto/x509/v3_alt.c @@ -157,15 +157,18 @@ int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen) break; case GEN_EMAIL: - BIO_printf(out, "email:%s", gen->d.ia5->data); + BIO_printf(out, "email:"); + ASN1_STRING_print(out, gen->d.ia5); break; case GEN_DNS: - BIO_printf(out, "DNS:%s", gen->d.ia5->data); + BIO_printf(out, "DNS:"); + ASN1_STRING_print(out, gen->d.ia5); break; case GEN_URI: - BIO_printf(out, "URI:%s", gen->d.ia5->data); + BIO_printf(out, "URI:"); + ASN1_STRING_print(out, gen->d.ia5); break; case GEN_DIRNAME: diff --git a/crypto/x509v3/v3_asid.c b/crypto/x509/v3_asid.c similarity index 100% rename from crypto/x509v3/v3_asid.c rename to crypto/x509/v3_asid.c diff --git a/crypto/x509v3/v3_bcons.c b/crypto/x509/v3_bcons.c similarity index 100% rename from crypto/x509v3/v3_bcons.c rename to crypto/x509/v3_bcons.c diff --git a/crypto/x509v3/v3_bitst.c b/crypto/x509/v3_bitst.c similarity index 100% rename from crypto/x509v3/v3_bitst.c rename to crypto/x509/v3_bitst.c diff --git a/crypto/x509v3/v3_conf.c b/crypto/x509/v3_conf.c similarity index 100% rename from crypto/x509v3/v3_conf.c rename to crypto/x509/v3_conf.c diff --git a/crypto/x509v3/v3_cpols.c b/crypto/x509/v3_cpols.c similarity index 100% rename from crypto/x509v3/v3_cpols.c rename to crypto/x509/v3_cpols.c diff --git a/crypto/x509v3/v3_crld.c b/crypto/x509/v3_crld.c similarity index 100% rename from crypto/x509v3/v3_crld.c rename to crypto/x509/v3_crld.c diff --git a/crypto/x509v3/v3_enum.c b/crypto/x509/v3_enum.c similarity index 100% rename from crypto/x509v3/v3_enum.c rename to crypto/x509/v3_enum.c diff --git a/crypto/x509v3/v3_extku.c b/crypto/x509/v3_extku.c similarity index 100% rename from crypto/x509v3/v3_extku.c rename to crypto/x509/v3_extku.c diff --git a/crypto/x509v3/v3_genn.c b/crypto/x509/v3_genn.c similarity index 100% rename from crypto/x509v3/v3_genn.c rename to crypto/x509/v3_genn.c diff --git a/crypto/x509v3/v3_ia5.c b/crypto/x509/v3_ia5.c similarity index 100% rename from crypto/x509v3/v3_ia5.c rename to crypto/x509/v3_ia5.c diff --git a/crypto/x509v3/v3_info.c b/crypto/x509/v3_info.c similarity index 100% rename from crypto/x509v3/v3_info.c rename to crypto/x509/v3_info.c diff --git a/crypto/x509v3/v3_int.c b/crypto/x509/v3_int.c similarity index 100% rename from crypto/x509v3/v3_int.c rename to crypto/x509/v3_int.c diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509/v3_lib.c similarity index 100% rename from crypto/x509v3/v3_lib.c rename to crypto/x509/v3_lib.c diff --git a/crypto/x509v3/v3_ncons.c b/crypto/x509/v3_ncons.c similarity index 100% rename from crypto/x509v3/v3_ncons.c rename to crypto/x509/v3_ncons.c diff --git a/crypto/x509v3/v3_pci.c b/crypto/x509/v3_pci.c similarity index 100% rename from crypto/x509v3/v3_pci.c rename to crypto/x509/v3_pci.c diff --git a/crypto/x509v3/v3_pcia.c b/crypto/x509/v3_pcia.c similarity index 100% rename from crypto/x509v3/v3_pcia.c rename to crypto/x509/v3_pcia.c diff --git a/crypto/x509v3/v3_pcons.c b/crypto/x509/v3_pcons.c similarity index 100% rename from crypto/x509v3/v3_pcons.c rename to crypto/x509/v3_pcons.c diff --git a/crypto/x509v3/v3_pku.c b/crypto/x509/v3_pku.c similarity index 100% rename from crypto/x509v3/v3_pku.c rename to crypto/x509/v3_pku.c diff --git a/crypto/x509v3/v3_pmaps.c b/crypto/x509/v3_pmaps.c similarity index 100% rename from crypto/x509v3/v3_pmaps.c rename to crypto/x509/v3_pmaps.c diff --git a/crypto/x509v3/v3_prn.c b/crypto/x509/v3_prn.c similarity index 100% rename from crypto/x509v3/v3_prn.c rename to crypto/x509/v3_prn.c diff --git a/crypto/x509v3/v3_purp.c b/crypto/x509/v3_purp.c similarity index 100% rename from crypto/x509v3/v3_purp.c rename to crypto/x509/v3_purp.c diff --git a/crypto/x509v3/v3_skey.c b/crypto/x509/v3_skey.c similarity index 100% rename from crypto/x509v3/v3_skey.c rename to crypto/x509/v3_skey.c diff --git a/crypto/x509v3/v3_sxnet.c b/crypto/x509/v3_sxnet.c similarity index 100% rename from crypto/x509v3/v3_sxnet.c rename to crypto/x509/v3_sxnet.c diff --git a/crypto/x509v3/v3_tlsf.c b/crypto/x509/v3_tlsf.c similarity index 99% rename from crypto/x509v3/v3_tlsf.c rename to crypto/x509/v3_tlsf.c index d3ab3f81..28e83bb2 100644 --- a/crypto/x509v3/v3_tlsf.c +++ b/crypto/x509/v3_tlsf.c @@ -10,7 +10,6 @@ #include "e_os.h" #include "internal/cryptlib.h" #include -#include "internal/o_str.h" #include #include #include diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509/v3_utl.c similarity index 100% rename from crypto/x509v3/v3_utl.c rename to crypto/x509/v3_utl.c diff --git a/crypto/x509v3/v3err.c b/crypto/x509/v3err.c similarity index 100% rename from crypto/x509v3/v3err.c rename to crypto/x509/v3err.c diff --git a/crypto/x509/x509_att.c b/crypto/x509/x509_att.c index f1cd9df2..317a45a4 100644 --- a/crypto/x509/x509_att.c +++ b/crypto/x509/x509_att.c @@ -314,7 +314,9 @@ void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, ttmp = X509_ATTRIBUTE_get0_type(attr, idx); if (!ttmp) return NULL; - if (atrtype != ASN1_TYPE_get(ttmp)) { + if (atrtype == V_ASN1_BOOLEAN + || atrtype == V_ASN1_NULL + || atrtype != ASN1_TYPE_get(ttmp)) { X509err(X509_F_X509_ATTRIBUTE_GET0_DATA, X509_R_WRONG_TYPE); return NULL; } diff --git a/crypto/x509/x509_err.c b/crypto/x509/x509_err.c index fbd2cf8e..1d0c518b 100644 --- a/crypto/x509/x509_err.c +++ b/crypto/x509/x509_err.c @@ -20,6 +20,7 @@ static const ERR_STRING_DATA X509_str_functs[] = { {ERR_PACK(ERR_LIB_X509, X509_F_CHECK_NAME_CONSTRAINTS, 0), "check_name_constraints"}, {ERR_PACK(ERR_LIB_X509, X509_F_CHECK_POLICY, 0), "check_policy"}, + {ERR_PACK(ERR_LIB_X509, X509_F_COMMON_VERIFY_SM2, 0), "common_verify_sm2"}, {ERR_PACK(ERR_LIB_X509, X509_F_DANE_I2D, 0), "dane_i2d"}, {ERR_PACK(ERR_LIB_X509, X509_F_DIR_CTRL, 0), "dir_ctrl"}, {ERR_PACK(ERR_LIB_X509, X509_F_GET_CERT_BY_SUBJECT, 0), @@ -86,6 +87,9 @@ static const ERR_STRING_DATA X509_str_functs[] = { {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_PRINT_EX, 0), "X509_REQ_print_ex"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_PRINT_FP, 0), "X509_REQ_print_fp"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_TO_X509, 0), "X509_REQ_to_X509"}, + {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_VERIFY, 0), "X509_REQ_verify"}, + {ERR_PACK(ERR_LIB_X509, X509_F_X509_REQ_VERIFY_SM2, 0), + "x509_req_verify_sm2"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_ADD_CERT, 0), "X509_STORE_add_cert"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_ADD_CRL, 0), @@ -125,6 +129,8 @@ static const ERR_STRING_DATA X509_str_reasons[] = { {ERR_PACK(ERR_LIB_X509, 0, X509_R_CRL_VERIFY_FAILURE), "crl verify failure"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_IDP_MISMATCH), "idp mismatch"}, + {ERR_PACK(ERR_LIB_X509, 0, X509_R_INVALID_ATTRIBUTES), + "invalid attributes"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_INVALID_DIRECTORY), "invalid directory"}, {ERR_PACK(ERR_LIB_X509, 0, X509_R_INVALID_FIELD_NAME), "invalid field name"}, diff --git a/crypto/x509/x_all.c b/crypto/x509/x_all.c index 9c9e8ffa..392f47e8 100644 --- a/crypto/x509/x_all.c +++ b/crypto/x509/x_all.c @@ -24,86 +24,105 @@ # include "internal/asn1_int.h" # include "internal/evp_int.h" -static int x509_verify_sm2(X509 *x, EVP_PKEY *pkey, int mdnid, int pknid) +static int common_verify_sm2(void *data, EVP_PKEY *pkey, + int mdnid, int pknid, int req) { + X509 *x = NULL; + X509_REQ *r = NULL; EVP_MD_CTX *ctx = NULL; unsigned char *buf_in = NULL; int ret = -1, inl = 0; size_t inll = 0; EVP_PKEY_CTX *pctx = NULL; const EVP_MD *type = EVP_get_digestbynid(mdnid); + ASN1_BIT_STRING *signature = NULL; + ASN1_OCTET_STRING *sm2_id = NULL; + ASN1_VALUE *tbv = NULL; if (type == NULL) { - X509err(X509_F_X509_VERIFY_SM2, + X509err(X509_F_COMMON_VERIFY_SM2, ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM); goto err; } if (pkey == NULL) { - X509err(X509_F_X509_VERIFY_SM2, ERR_R_PASSED_NULL_PARAMETER); + X509err(X509_F_COMMON_VERIFY_SM2, ERR_R_PASSED_NULL_PARAMETER); return -1; } - if (x->signature.type == V_ASN1_BIT_STRING && x->signature.flags & 0x7) { - X509err(X509_F_X509_VERIFY_SM2, ASN1_R_INVALID_BIT_STRING_BITS_LEFT); + if (req == 1) { + r = (X509_REQ *)data; + signature = r->signature; + sm2_id = r->sm2_id; + tbv = (ASN1_VALUE *)&r->req_info; + } else { + x = (X509 *)data; + signature = &x->signature; + sm2_id = x->sm2_id; + tbv = (ASN1_VALUE *)&x->cert_info; + } + + if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7) { + X509err(X509_F_COMMON_VERIFY_SM2, ASN1_R_INVALID_BIT_STRING_BITS_LEFT); return -1; } ctx = EVP_MD_CTX_new(); if (ctx == NULL) { - X509err(X509_F_X509_VERIFY_SM2, ERR_R_MALLOC_FAILURE); + X509err(X509_F_COMMON_VERIFY_SM2, ERR_R_MALLOC_FAILURE); goto err; } /* Check public key OID matches public key type */ if (EVP_PKEY_type(pknid) != pkey->ameth->pkey_id) { - X509err(X509_F_X509_VERIFY_SM2, ASN1_R_WRONG_PUBLIC_KEY_TYPE); + X509err(X509_F_COMMON_VERIFY_SM2, ASN1_R_WRONG_PUBLIC_KEY_TYPE); goto err; } if (!EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2)) { - X509err(X509_F_X509_VERIFY_SM2, ERR_R_EVP_LIB); + X509err(X509_F_COMMON_VERIFY_SM2, ERR_R_EVP_LIB); ret = 0; goto err; } pctx = EVP_PKEY_CTX_new(pkey, NULL); if (pctx == NULL) { - X509err(X509_F_X509_VERIFY_SM2, ERR_R_EVP_LIB); + X509err(X509_F_COMMON_VERIFY_SM2, ERR_R_EVP_LIB); ret = 0; goto err; } /* NOTE: we tolerate no actual ID, to provide maximum flexibility */ - if (x->sm2_id != NULL - && EVP_PKEY_CTX_set1_id(pctx, x->sm2_id->data, - x->sm2_id->length) != 1) { - X509err(X509_F_X509_VERIFY_SM2, ERR_R_EVP_LIB); + if (sm2_id != NULL + && EVP_PKEY_CTX_set1_id(pctx, sm2_id->data, sm2_id->length) != 1) { + X509err(X509_F_COMMON_VERIFY_SM2, ERR_R_EVP_LIB); ret = 0; goto err; } EVP_MD_CTX_set_pkey_ctx(ctx, pctx); if (!EVP_DigestVerifyInit(ctx, NULL, type, NULL, pkey)) { - X509err(X509_F_X509_VERIFY_SM2, ERR_R_EVP_LIB); + X509err(X509_F_COMMON_VERIFY_SM2, ERR_R_EVP_LIB); ret = 0; goto err; } - inl = ASN1_item_i2d((ASN1_VALUE *)&x->cert_info, &buf_in, + inl = ASN1_item_i2d(tbv, &buf_in, + req == 1 ? + ASN1_ITEM_rptr(X509_REQ_INFO) : ASN1_ITEM_rptr(X509_CINF)); if (inl <= 0) { - X509err(X509_F_X509_VERIFY_SM2, ERR_R_INTERNAL_ERROR); + X509err(X509_F_COMMON_VERIFY_SM2, ERR_R_INTERNAL_ERROR); goto err; } if (buf_in == NULL) { - X509err(X509_F_X509_VERIFY_SM2, ERR_R_MALLOC_FAILURE); + X509err(X509_F_COMMON_VERIFY_SM2, ERR_R_MALLOC_FAILURE); goto err; } inll = inl; - ret = EVP_DigestVerify(ctx, x->signature.data, - (size_t)x->signature.length, buf_in, inl); + ret = EVP_DigestVerify(ctx, signature->data, + (size_t)signature->length, buf_in, inl); if (ret <= 0) { - X509err(X509_F_X509_VERIFY_SM2, ERR_R_EVP_LIB); + X509err(X509_F_COMMON_VERIFY_SM2, ERR_R_EVP_LIB); goto err; } ret = 1; @@ -113,6 +132,18 @@ static int x509_verify_sm2(X509 *x, EVP_PKEY *pkey, int mdnid, int pknid) EVP_PKEY_CTX_free(pctx); return ret; } + +static int x509_verify_sm2(X509 *x, EVP_PKEY *pkey, int mdnid, int pknid) +{ + return common_verify_sm2(x, pkey, mdnid, pknid, 0); +} + +static int x509_req_verify_sm2(X509_REQ *x, EVP_PKEY *pkey, + int mdnid, int pknid) +{ + return common_verify_sm2(x, pkey, mdnid, pknid, 1); +} + #endif int X509_verify(X509 *a, EVP_PKEY *r) @@ -142,6 +173,20 @@ int X509_verify(X509 *a, EVP_PKEY *r) int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r) { +#ifndef OPENSSL_NO_SM2 + int mdnid, pknid; + + /* Convert signature OID into digest and public key OIDs */ + if (!OBJ_find_sigid_algs(OBJ_obj2nid(a->sig_alg.algorithm), + &mdnid, &pknid)) { + X509err(X509_F_X509_REQ_VERIFY, ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); + return 0; + } + + if (pknid == NID_sm2) + return x509_req_verify_sm2(a, r, mdnid, pknid); +#endif + return (ASN1_item_verify(ASN1_ITEM_rptr(X509_REQ_INFO), &a->sig_alg, a->signature, &a->req_info, r)); } diff --git a/crypto/x509/x_req.c b/crypto/x509/x_req.c index 7fb84482..5bda794a 100644 --- a/crypto/x509/x_req.c +++ b/crypto/x509/x_req.c @@ -45,6 +45,29 @@ static int rinf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, return 1; } +static int req_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, + void *exarg) +{ +#ifndef OPENSSL_NO_SM2 + X509_REQ *ret = (X509_REQ *)*pval; + + switch (operation) { + case ASN1_OP_D2I_PRE: + ASN1_OCTET_STRING_free(ret->sm2_id); + /* fall thru */ + case ASN1_OP_NEW_POST: + ret->sm2_id = NULL; + break; + + case ASN1_OP_FREE_POST: + ASN1_OCTET_STRING_free(ret->sm2_id); + break; + } +#endif + + return 1; +} + ASN1_SEQUENCE_enc(X509_REQ_INFO, enc, rinf_cb) = { ASN1_SIMPLE(X509_REQ_INFO, version, ASN1_INTEGER), ASN1_SIMPLE(X509_REQ_INFO, subject, X509_NAME), @@ -57,7 +80,7 @@ ASN1_SEQUENCE_enc(X509_REQ_INFO, enc, rinf_cb) = { IMPLEMENT_ASN1_FUNCTIONS(X509_REQ_INFO) -ASN1_SEQUENCE_ref(X509_REQ, 0) = { +ASN1_SEQUENCE_ref(X509_REQ, req_cb) = { ASN1_EMBED(X509_REQ, req_info, X509_REQ_INFO), ASN1_EMBED(X509_REQ, sig_alg, X509_ALGOR), ASN1_SIMPLE(X509_REQ, signature, ASN1_BIT_STRING) @@ -66,3 +89,16 @@ ASN1_SEQUENCE_ref(X509_REQ, 0) = { IMPLEMENT_ASN1_FUNCTIONS(X509_REQ) IMPLEMENT_ASN1_DUP_FUNCTION(X509_REQ) + +#ifndef OPENSSL_NO_SM2 +void X509_REQ_set0_sm2_id(X509_REQ *x, ASN1_OCTET_STRING *sm2_id) +{ + ASN1_OCTET_STRING_free(x->sm2_id); + x->sm2_id = sm2_id; +} + +ASN1_OCTET_STRING *X509_REQ_get0_sm2_id(X509_REQ *x) +{ + return x->sm2_id; +} +#endif diff --git a/crypto/x509/x_x509.c b/crypto/x509/x_x509.c index 78e1a756..d91c2d24 100644 --- a/crypto/x509/x_x509.c +++ b/crypto/x509/x_x509.c @@ -53,6 +53,9 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free); ASIdentifiers_free(ret->rfc3779_asid); #endif +#ifndef OPENSSL_NO_SM2 + ASN1_OCTET_STRING_free(ret->sm2_id); +#endif /* fall thru */ diff --git a/crypto/x509v3/build.info b/crypto/x509v3/build.info deleted file mode 100644 index 4ab64884..00000000 --- a/crypto/x509v3/build.info +++ /dev/null @@ -1,8 +0,0 @@ -LIBS=../../libcrypto -SOURCE[../../libcrypto]=\ - v3_bcons.c v3_bitst.c v3_conf.c v3_extku.c v3_ia5.c v3_lib.c \ - v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c v3_pku.c \ - v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c v3_info.c \ - v3_akeya.c v3_pmaps.c v3_pcons.c v3_ncons.c v3_pcia.c v3_pci.c \ - pcy_cache.c pcy_node.c pcy_data.c pcy_map.c pcy_tree.c pcy_lib.c \ - v3_asid.c v3_addr.c v3_tlsf.c v3_admis.c diff --git a/demos/bio/descrip.mms b/demos/bio/descrip.mms index d49725ff..44ca2feb 100644 --- a/demos/bio/descrip.mms +++ b/demos/bio/descrip.mms @@ -37,7 +37,7 @@ server-arg.exe : server-arg.obj server-cmod.exe : server-cmod.obj server-conf.exe : server-conf.obj -# Stoopid MMS doesn't infer this automatically... +# MMS doesn't infer this automatically... client-arg.obj : client-arg.c client-conf.obj : client-conf.c saccept.obj : saccept.c diff --git a/demos/evp/aesgcm.c b/demos/evp/aesgcm.c index 4decdaa1..c902e15b 100644 --- a/demos/evp/aesgcm.c +++ b/demos/evp/aesgcm.c @@ -84,7 +84,7 @@ void aes_gcm_decrypt(void) EVP_CIPHER_CTX *ctx; int outlen, tmplen, rv; unsigned char outbuf[1024]; - printf("AES GCM Derypt:\n"); + printf("AES GCM Decrypt:\n"); printf("Ciphertext:\n"); BIO_dump_fp(stdout, gcm_ct, sizeof(gcm_ct)); ctx = EVP_CIPHER_CTX_new(); diff --git a/doc/HOWTO/proxy_certificates.txt b/doc/HOWTO/proxy_certificates.txt index 2936cd6e..3c423492 100644 --- a/doc/HOWTO/proxy_certificates.txt +++ b/doc/HOWTO/proxy_certificates.txt @@ -255,7 +255,7 @@ Here is some skeleton code you can fill in: /* * process_rights() is supposed to be a procedure - * that takes a string and it's length, interprets + * that takes a string and its length, interprets * it and sets the bits in the YOUR_RIGHTS pointed * at by the third argument. */ diff --git a/doc/internal/man3/evp_generic_fetch.pod b/doc/internal/man3/evp_generic_fetch.pod index 2679a7eb..0688ac01 100644 --- a/doc/internal/man3/evp_generic_fetch.pod +++ b/doc/internal/man3/evp_generic_fetch.pod @@ -13,7 +13,7 @@ evp_generic_fetch - generic algorithm fetcher and method creator for EVP const char *name, const char *properties, void *(*new_method)(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov), - int (*upref_method)(void *), + int (*up_ref_method)(void *), void (*free_method)(void *)); =head1 DESCRIPTION @@ -21,7 +21,7 @@ evp_generic_fetch - generic algorithm fetcher and method creator for EVP evp_generic_fetch() calls ossl_method_construct() with the given C, C, C, and C and uses it to create an EVP method with the help of the functions -C, C, and C. +C, C, and C. The three functions are supposed to: @@ -32,7 +32,7 @@ The three functions are supposed to: creates an internal method from function pointers found in the dispatch table C. -=item upref_method() +=item up_ref_method() increments the reference counter for the given method, if there is one. @@ -116,7 +116,7 @@ And here's the implementation of the FOO method fetcher: } foo->prov = prov; if (prov) - ossl_provider_upref(prov); + ossl_provider_up_ref(prov); return foo; } @@ -137,7 +137,7 @@ And here's the implementation of the FOO method fetcher: return EVP_FOO_meth_from_dispatch(fns, prov); } - static int foo_upref(void *vfoo) + static int foo_up_ref(void *vfoo) { EVP_FOO *foo = vfoo; int ref = 0; @@ -157,7 +157,7 @@ And here's the implementation of the FOO method fetcher: { EVP_FOO *foo = evp_generic_fetch(ctx, OSSL_OP_FOO, name, properties, - foo_from_dispatch, foo_upref, foo_free); + foo_from_dispatch, foo_up_ref, foo_free); /* * If this method exists in legacy form, with a constant NID for the diff --git a/doc/internal/man3/openssl_ctx_get_data.pod b/doc/internal/man3/openssl_ctx_get_data.pod index d9b3f5dd..3d821b5f 100644 --- a/doc/internal/man3/openssl_ctx_get_data.pod +++ b/doc/internal/man3/openssl_ctx_get_data.pod @@ -29,7 +29,7 @@ as a C, which allows data from diverse parts of the library to be added and removed dynamically. Each such data item must have a corresponding CRYPTO_EX_DATA index associated with it. Unlike normal CRYPTO_EX_DATA objects we use static indexes -to identify data items. These are mapped transparetnly to CRYPTO_EX_DATA dynamic +to identify data items. These are mapped transparently to CRYPTO_EX_DATA dynamic indexes internally to the implementation. See the example further down to see how that's done. diff --git a/doc/internal/man3/ossl_init_thread_deregister.pod b/doc/internal/man3/ossl_init_thread_deregister.pod new file mode 100644 index 00000000..4d4c7166 --- /dev/null +++ b/doc/internal/man3/ossl_init_thread_deregister.pod @@ -0,0 +1,66 @@ +=pod + +=head1 NAME + +OSSL_thread_stop_handler_fn, +ossl_init_thread_start, +ossl_init_thread_deregister +- internal thread routines + +=head1 SYNOPSIS + + #include "internal/cryptlib_int.h" + #include + + typedef void (*OSSL_thread_stop_handler_fn)(void *arg); + + int ossl_init_thread_start(const void *index, void *arg, + OSSL_thread_stop_handler_fn handfn); + int ossl_init_thread_deregister(void *index); + +=head1 DESCRIPTION + +Thread aware code may be informed about when a thread is stopping, typically to +perform some cleanup operation. +Thread stop events may be detected by OpenSSL either automatically (using the +capabilities of the underlying threading library) where possible or explicitly +by the application calling OPENSSL_thread_stop() or OPENSSL_thread_stop_ex(). + +Thread aware code registers a "stop handler" for each new thread that it uses. +Typically, when a new thread is being used, code will add a new value to some +thread local variable and then register a stop handler. When the thread is +stopping the stop handler is called (while on that thread) and the code can +clean up the value stored in the thread local variable. + +A new stop handler is registerd using the function ossl_init_thread_start(). +The B parameter should be a unique value that can be used to identify a +set of common stop handlers and is passed in a later call to +ossl_init_thread_deregister. If no later call to ossl_init_thread_deregister is +made then NULL can be passed for this parameter. The B parameter is passed +back as an argument to the stop handler when it is later invoked. Finally the +B is a function pointer to the stop handler itself. + +In the event that previously registered stop handlers need to be deregistered +then this can be done using the function ossl_init_thread_deregister(). +This will deregister all stop handlers (no matter which thread they were +registered for) which the same B value. + +=head1 RETURN VALUES + +ossl_init_thread_start() and ossl_init_thread_deregister() return 1 for success +or 0 on error. + +=head1 HISTORY + +The functions described here were all added in OpenSSL 3.0. + +=head1 COPYRIGHT + +Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut diff --git a/doc/internal/man3/ossl_method_construct.pod b/doc/internal/man3/ossl_method_construct.pod index 60de260e..9beb7942 100644 --- a/doc/internal/man3/ossl_method_construct.pod +++ b/doc/internal/man3/ossl_method_construct.pod @@ -15,11 +15,13 @@ OSSL_METHOD_CONSTRUCT_METHOD, ossl_method_construct /* Remove a store */ void (*dealloc_tmp_store)(void *store); /* Get an already existing method from a store */ - void *(*get)(OPENSSL_CTX *libctx, void *store, const char *name, - const char *propquery, void *data); + void *(*get)(OPENSSL_CTX *libctx, void *store, + int operation_id, const char *name, const char *propquery, + void *data); /* Store a method in a store */ int (*put)(OPENSSL_CTX *libctx, void *store, void *method, - const char *name, const char *propdef, void *data); + int operation_id, const char *name, const char *propdef, + void *data); /* Construct a new method */ void *(*construct)(const char *name, const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov, void *data); @@ -41,13 +43,25 @@ on provider dispatch tables need to do so in exactly the same way. ossl_method_construct() does this while leaving it to the sub-systems to define more precisely how the methods are created, stored, etc. +It's important to keep in mind that a method is identified by three things: + +=over 4 + +=item The operation identity + +=item The name of the algorithm + +=item The properties associated with the algorithm implementation + +=back + =head2 Functions ossl_method_construct() creates a method by asking all available -providers for a dispatch table given an C, an algorithm -C and a set of C, and then calling appropriate +providers for a dispatch table given an I, an algorithm +I and a set of I, and then calling the appropriate functions given by the sub-system specific method creator through -C and the data in C (which is passed by +I and the data in I (which is passed by ossl_method_construct()). This function assumes that the sub-system method creator implements @@ -59,14 +73,14 @@ appropriate). A central part of constructing a sub-system specific method is to give ossl_method_construct a set of functions, all in the -C structure, which holds the following +B structure, which holds the following function pointers: =over 4 =item alloc_tmp_store() -Create a temporary method store in the scope of the library context C. +Create a temporary method store in the scope of the library context I. This store is used to temporarily store methods for easier lookup, for when the provider doesn't want its dispatch table stored in a longer term cache. @@ -79,50 +93,51 @@ Remove a temporary store. Look up an already existing method from a store by name. -The store may be given with C. +The store may be given with I. B is a valid value and means that a sub-system default store must be used. -This default store should be stored in the library context C. +This default store should be stored in the library context I. -The method to be looked up should be identified with the given C and -data from C -(which is the C that was passed to ossl_construct_method()) -and the provided property query C. +The method to be looked up should be identified with the given +I, I, the provided property query I +and data from I (which is the I that was passed to +ossl_construct_method()). This function is expected to increment the method's reference count. =item put() -Places the C created by the construct() function (see below) +Places the I created by the construct() function (see below) in a store. -The store may be given with C. +The store may be given with I. B is a valid value and means that a sub-system default store must be used. -This default store should be stored in the library context C. +This default store should be stored in the library context I. -The method should be associated with the given C and property definition -C as well as any identification data given through C (which is -the C that was passed to ossl_construct_method()). +The method should be associated with the given I, +I and property definition I as well as any +identification data given through I (which is the I +that was passed to ossl_construct_method()). -This function is expected to increment the C's reference count. +This function is expected to increment the I's reference count. =item construct() -Constructs a sub-system method for the given C and the given -dispatch table C. +Constructs a sub-system method for the given I and the given +dispatch table I. -The associated I C is passed as well, to make +The associated provider object I is passed as well, to make it possible for the sub-system constructor to keep a reference, which is recommended. If such a reference is kept, the I reference counter -must be incremented, using ossl_provider_upref(). +must be incremented, using ossl_provider_up_ref(). This function is expected to set the method's reference count to 1. -=item desctruct() +=item destruct() -Decrement the C's reference count, and destruct it when +Decrement the I's reference count, and destruct it when the reference count reaches zero. =back diff --git a/doc/internal/man3/ossl_namemap_new.pod b/doc/internal/man3/ossl_namemap_new.pod index 07dc914f..8699b861 100644 --- a/doc/internal/man3/ossl_namemap_new.pod +++ b/doc/internal/man3/ossl_namemap_new.pod @@ -3,7 +3,7 @@ =head1 NAME ossl_namemap_new, ossl_namemap_free, ossl_namemap_stored, -ossl_namemap_add, ossl_namemap_name, ossl_namemap_number +ossl_namemap_add, ossl_namemap_name2num, ossl_namemap_doall_names - internal number E-E name map =head1 SYNOPSIS @@ -15,15 +15,18 @@ ossl_namemap_add, ossl_namemap_name, ossl_namemap_number OSSL_NAMEMAP *ossl_namemap_new(void); void ossl_namemap_free(OSSL_NAMEMAP *namemap); - int ossl_namemap_add(OSSL_NAMEMAP *namemap, const char *name); - const char *ossl_namemap_name(const OSSL_NAMEMAP *namemap, int number); - int ossl_namemap_number(const OSSL_NAMEMAP *namemap, const char *name); + int ossl_namemap_add(OSSL_NAMEMAP *namemap, int number, const char *name); + + int ossl_namemap_name2num(const OSSL_NAMEMAP *namemap, const char *name); + void ossl_namemap_doall_names(const OSSL_NAMEMAP *namemap, int number, + void (*fn)(const char *name, void *data), + void *data); =head1 DESCRIPTION -A B is a simple number E-E name map, which can -be used to give any arbitrary name (any string) a unique dynamic -identity that is valid throughout the lifetime of the associated +A B is a one-to-many number E-E names map, which +can be used to give any arbitrary set of names (any string) a unique +dynamic identity that is valid throughout the lifetime of the associated library context. ossl_namemap_new() and ossl_namemap_free() construct and destruct a @@ -38,11 +41,19 @@ ossl_namemap_free(). ossl_namemap_add() adds a new name to the namemap if it's not already present. +If the given I is zero, a new number will be allocated to +identify this I. +If the given I is non-zero, the I is added to the set of +names already associated with that number. -ossl_namemap_name() finds the name corresponding to the given number. +ossl_namemap_name2num() finds the number corresponding to the given +I. -ossl_namemap_number() finds the number corresponding to the given -name. +ossl_namemap_doall_names() walks through all names associated with +I in the given I and calls the function I for +each of them. +I is also passed the I argument, which allows any caller to +pass extra data for that function to use. =head1 RETURN VALUES @@ -52,12 +63,21 @@ B, or NULL on error. ossl_namemap_add() returns the number associated with the added string, or zero on error. -ossl_namemap_name() returns a pointer to the name corresponding to the -given number, or NULL if it's undefined in the given B. +ossl_namemap_num2names() returns a pointer to a NULL-terminated list of +pointers to the names corresponding to the given number, or NULL if +it's undefined in the given B. -ossl_namemap_number() returns the number corresponding to the given +ossl_namemap_name2num() returns the number corresponding to the given name, or 0 if it's undefined in the given B. +=head1 NOTES + +The result from ossl_namemap_num2names() isn't thread safe, other threads +dealing with the same namemap may cause the list of names to change +location. +It is therefore strongly recommended to only use the result in code +guarded by a thread lock. + =head1 HISTORY The functions described here were all added in OpenSSL 3.0. diff --git a/doc/internal/man3/ossl_prov_util_nid_to_name.pod b/doc/internal/man3/ossl_prov_util_nid_to_name.pod new file mode 100644 index 00000000..56a16d34 --- /dev/null +++ b/doc/internal/man3/ossl_prov_util_nid_to_name.pod @@ -0,0 +1,35 @@ +=pod + +=head1 NAME + +ossl_prov_util_nid_to_name +- provider utility functions + +=head1 SYNOPSIS + + #include "internal/providercommon.h" + + const char *ossl_prov_util_nid_to_name(int nid); + +=head1 DESCRIPTION + +The ossl_prov_util_nid_to_name() returns the name of an algorithm given a NID +in the B parameter. For the default and legacy providers it is equivalent +to calling OBJ_nid2sn(). The FIPS provider does not have the object database +code available to it (because that code relies on the ASN.1 code), so this +function is a static lookup of all known FIPS algorithm NIDs. + +=head1 RETURN VALUES + +Returns a pointer to the algorithm name, or NULL on error. + +=head1 COPYRIGHT + +Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut diff --git a/doc/internal/man3/ossl_provider_add_conf_module.pod b/doc/internal/man3/ossl_provider_add_conf_module.pod new file mode 100644 index 00000000..7e4d5097 --- /dev/null +++ b/doc/internal/man3/ossl_provider_add_conf_module.pod @@ -0,0 +1,41 @@ +=pod + +=head1 NAME + +ossl_provider_add_conf_module - internal standard configuration module + +=head1 SYNOPSIS + + #include "internal/provider.h" + + /* Configuration */ + void ossl_provider_add_conf_module(void); + +=head1 DESCRIPTION + +ossl_provider_add_conf_module() adds the standard configuration module +for providers. +This allows providers to be configured with an OpenSSL L file. + +=head1 RETURN VALUES + +ossl_provider_add_conf_module() doesn't return any value. + +=head1 SEE ALSO + +L, L + +=head1 HISTORY + +The functions described here were all added in OpenSSL 3.0. + +=head1 COPYRIGHT + +Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut diff --git a/doc/internal/man3/ossl_provider_new.pod b/doc/internal/man3/ossl_provider_new.pod index 04535086..cb40cb2c 100644 --- a/doc/internal/man3/ossl_provider_new.pod +++ b/doc/internal/man3/ossl_provider_new.pod @@ -2,10 +2,13 @@ =head1 NAME -ossl_provider_find, ossl_provider_new, ossl_provider_upref, -ossl_provider_free, ossl_provider_add_module_location, -ossl_provider_set_fallback, ossl_provider_activate, -ossl_provider_ctx, ossl_provider_forall_loaded, +ossl_provider_find, ossl_provider_new, ossl_provider_up_ref, +ossl_provider_free, +ossl_provider_set_fallback, ossl_provider_set_module_path, +ossl_provider_add_parameter, +ossl_provider_activate, +ossl_provider_ctx, +ossl_provider_forall_loaded, ossl_provider_name, ossl_provider_dso, ossl_provider_module_name, ossl_provider_module_path, ossl_provider_teardown, ossl_provider_get_param_types, @@ -19,12 +22,14 @@ ossl_provider_get_params, ossl_provider_query_operation OSSL_PROVIDER *ossl_provider_find(OPENSSL_CTX *libctx, const char *name); OSSL_PROVIDER *ossl_provider_new(OPENSSL_CTX *libctx, const char *name, ossl_provider_init_fn *init_function); - int ossl_provider_upref(OSSL_PROVIDER *prov); + int ossl_provider_up_ref(OSSL_PROVIDER *prov); void ossl_provider_free(OSSL_PROVIDER *prov); /* Setters */ - int ossl_provider_add_module_location(OSSL_PROVIDER *prov, const char *loc); int ossl_provider_set_fallback(OSSL_PROVIDER *prov); + int ossl_provider_set_module_path(OSSL_PROVIDER *prov, const char *path); + int ossl_provider_add_parameter(OSSL_PROVIDER *prov, const char *name, + const char *value); /* Load and initialize the Provider */ int ossl_provider_activate(OSSL_PROVIDER *prov); @@ -47,65 +52,84 @@ ossl_provider_get_params, ossl_provider_query_operation /* Thin wrappers around calls to the provider */ void ossl_provider_teardown(const OSSL_PROVIDER *prov); const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov); - int ossl_provider_get_params(const OSSL_PROVIDER *prov, - const OSSL_PARAM params[]); + int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]); const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov, int operation_id, int *no_cache); =head1 DESCRIPTION -C is a type that holds all the necessary information +I is a type that holds all the necessary information to handle a provider, regardless of if it's built in to the application or the OpenSSL libraries, or if it's a loadable provider module. -Instances of this type are commonly refered to as Is. +Instances of this type are commonly referred to as "provider objects". -A I is always stored in a set of Is +A provider object is always stored in a set of provider objects in the library context. -Is are reference counted. +Provider objects are reference counted. -Is are initially inactive, i.e. they are only -recorded in the store, but are not used. +Provider objects are initially inactive, i.e. they are only recorded +in the store, but are not used. They are activated with the first call to ossl_provider_activate(), and are inactivated when ossl_provider_free() has been called as many times as ossl_provider_activate() has. =head2 Functions -ossl_provider_find() finds an existing I in the -I store by C. -The I it finds gets its reference count -incremented. +ossl_provider_find() finds an existing provider object in the provider +object store by I. +The provider object it finds has its reference count incremented. -ossl_provider_new() creates a new I and stores it in -the I store, unless there already is one there with -the same name. -The reference counter of a newly created I will -always be 2; one for being added to the store, and one for the -returned reference. -To indicate a built-in provider, the C argument must -point at the provider initialization function for that provider. +ossl_provider_new() creates a new provider object named I and +stores it in the provider object store, unless there already is one +there with the same name. +If there already is one with the same name, it's returned with its +reference count incremented. +The reference count of a newly created provider object will always +be 2; one for being added to the store, and one for the returned +reference. +If I is NULL, the provider is assumed to be a +dynamically loadable module, with the symbol B as +its initialisation function. +If I isn't NULL, the provider is assumed to be built +in, with I being the pointer to its initialisation +function. +For further description of the initialisation function, see the +description of ossl_provider_activate() below. -ossl_provider_free() decrements a I's reference -counter; if it drops below 2, the I is assumed to -have fallen out of use and will be inactivated (its teardown function -is called); if it drops down to zero, the I is -assumed to have been taken out of the store, and the associated module -will be unloaded if one was loaded, and the I will be -freed. +ossl_provider_up_ref() increments the provider object I's +reference count. -ossl_provider_add_module_location() adds a location to look for a -provider module. +ossl_provider_free() decrements the provider object I's +reference count; if it drops below 2, the provider object is assumed +to have fallen out of use and will be deactivated (its I +function is called); if it drops down to zero, I is assumed to +have been taken out of the store, and the associated module will be +unloaded if one was loaded, and I itself will be freed. -ossl_provider_set_fallback() marks an available provider as fallback. -Note that after this call, the I pointer that was +ossl_provider_set_fallback() marks an available provider I as +fallback. +Note that after this call, the provider object pointer that was used can simply be dropped, but not freed. +ossl_provider_set_module_path() sets the module path to load the +provider module given the provider object I. +This will be used in preference to automatically trying to figure out +the path from the provider name and the default module directory (more +on this in L). + +ossl_provider_add_parameter() adds a global parameter for the provider +to retrieve as it sees fit. +The parameters are a combination of I and I, and the +provider will use the name to find the value it wants. +Only text parameters can be given, and it's up to the provider to +interpret them. + ossl_provider_activate() "activates" the provider for the given -I. -What "activates" means depends on what type of I it +provider object I. +What "activates" means depends on what type of provider object it is: =over 4 @@ -117,9 +141,9 @@ function will get called. =item * -If no intialization function was given with ossl_provider_new(), a -loadable module with the C that was given to ossl_provider_new() -will be located and loaded, then the symbol C will +If no initialization function was given with ossl_provider_new(), a +loadable module with the I that was given to ossl_provider_new() +will be located and loaded, then the symbol B will be located in that module, and called. =back @@ -129,7 +153,7 @@ Outside of the provider, it's completely opaque, but it needs to be passed back to some of the provider functions. ossl_provider_forall_loaded() iterates over all the currently -"activated" providers, and calls C for each of them. +"activated" providers, and calls I for each of them. If no providers have been "activated" yet, it tries to activate all available fallback providers and tries another iteration. @@ -145,23 +169,23 @@ providers that come in the form of loadable modules. ossl_provider_module_path() returns the full path of the module file, for providers that come in the form of loadable modules. -ossl_provider_teardown() calls the provider's C function, if +ossl_provider_teardown() calls the provider's I function, if the provider has one. -ossl_provider_get_param_types() calls the provider's C +ossl_provider_get_param_types() calls the provider's I function, if the provider has one. -It should return an array of C to describe all the -parameters that the provider has for the I. +It should return an array of I to describe all the +parameters that the provider has for the provider object. ossl_provider_get_params() calls the provider's parameter request responder. -It should treat the given C array as described in +It should treat the given I array as described in L. ossl_provider_query_operation() calls the provider's -C function, if the provider has one. -It should return an array of C for the given -C. +I function, if the provider has one. +It should return an array of I for the given +I. =head1 NOTES @@ -171,50 +195,56 @@ Locating a provider module happens as follows: =item 1. -Look in each directory given by ossl_provider_add_module_location(). +If a path was given with ossl_provider_set_module_path(), use that as +module path. +Otherwise, use the provider object's name as module path, with +platform specific standard extensions added. =item 2. -Look in the directory given by the environment variable -B. - -=item 3. - -Look in the directory given by the OpenSSL built in macro -B. +If the environment variable B is defined, assume its +value is a directory specification and merge it with the module path. +Otherwise, merge the value of the OpenSSL built in macro B +with the module path. =back +When this process is done, the result is used when trying to load the +provider module. + +The command C can be used to find out the value +of the built in macro B. + =head1 RETURN VALUES ossl_provider_find() and ossl_provider_new() return a pointer to a -I (C) on success, or B on error. +provider object (I) on success, or NULL on error. -ossl_provider_upref() returns the value of the reference counter after +ossl_provider_up_ref() returns the value of the reference count after it has been incremented. ossl_provider_free() doesn't return any value. -ossl_provider_add_module_location(), ossl_provider_set_fallback() and +ossl_provider_set_module_path(), ossl_provider_set_fallback() and ossl_provider_activate() return 1 on success, or 0 on error. ossl_provider_name(), ossl_provider_dso(), ossl_provider_module_name(), and ossl_provider_module_path() return a -pointer to their respective data if it's available, otherwise B +pointer to their respective data if it's available, otherwise NULL is returned. ossl_provider_teardown() doesnt't return any value. -ossl_provider_get_param_types() returns a pointer to an C +ossl_provider_get_param_types() returns a pointer to an I array if this function is available in the provider, otherwise -B. +NULL. ossl_provider_get_params() returns 1 on success, or 0 on error. If this function isn't available in the provider, 0 is returned. =head1 SEE ALSO -L, L +L, L, L =head1 HISTORY diff --git a/doc/internal/man3/rand_bytes_ex.pod b/doc/internal/man3/rand_bytes_ex.pod new file mode 100644 index 00000000..74060731 --- /dev/null +++ b/doc/internal/man3/rand_bytes_ex.pod @@ -0,0 +1,41 @@ +=pod + +=head1 NAME + +rand_bytes_ex, rand_priv_bytes_ex +- internal random number routines + +=head1 SYNOPSIS + + #include "internal/rand_int.h" + + int rand_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num); + int rand_priv_bytes_ex(OPENSSL_CTX *ctx, unsigned char *buf, int num); + +=head1 DESCRIPTION + +rand_bytes_ex() and rand_priv_bytes_ex() are the equivalent of RAND_bytes() and +RAND_priv_bytes() in the public API except that they both take an additional +B parameter. +The DRBG used for the operation is the public or private DRBG associated with +the specified B. The parameter can be NULL, in which case +the default library ctx is used. +If the default RAND_METHOD has been changed then for compatibility reasons the +RAND_METHOD will be used in preference and the DRBG of the library context +ignored. + +=head1 RETURN VALUES + +rand_bytes_ex() and rand_bytes_priv_ex() return 0 or less on error or 1 on +success. + +=head1 COPYRIGHT + +Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut diff --git a/doc/man1/ca.pod b/doc/man1/ca.pod index 6e90c334..8438d1dc 100644 --- a/doc/man1/ca.pod +++ b/doc/man1/ca.pod @@ -57,6 +57,8 @@ B B [B<-multivalue-rdn>] [B<-rand file...>] [B<-writerand file>] +[B<-sm2-id string>] +[B<-sm2-hex-id hex-string>] =head1 DESCRIPTION @@ -303,6 +305,16 @@ all others. Writes random data to the specified I upon exit. This can be used with a subsequent B<-rand> flag. +=item B<-sm2-id> + +Specify the ID string to use when verifying an SM2 certificate. The ID string is +required by the SM2 signature algorithm for signing and verification. + +=item B<-sm2-hex-id> + +Specify a binary ID string to use when signing or verifying using an SM2 +certificate. The argument for this option is string of hexadecimal digits. + =back =head1 CRL OPTIONS @@ -600,6 +612,10 @@ Sign a certificate request: openssl ca -in req.pem -out newcert.pem +Sign an SM2 certificate request: + + openssl ca -in sm2.csr -out sm2.crt -md sm3 -sigopt "sm2_id:1234567812345678" -sm2-id "1234567812345678" + Sign a certificate request, using CA extensions: openssl ca -in req.pem -extensions v3_ca -out newcert.pem diff --git a/doc/man1/kdf.pod b/doc/man1/kdf.pod index 0ff7762b..7282d73c 100644 --- a/doc/man1/kdf.pod +++ b/doc/man1/kdf.pod @@ -150,6 +150,7 @@ L L L L +L =head1 HISTORY diff --git a/doc/man1/mac.pod b/doc/man1/mac.pod index 5d1e7966..3143df8d 100644 --- a/doc/man1/mac.pod +++ b/doc/man1/mac.pod @@ -76,7 +76,7 @@ To see the list of supported digests, use the command I. =item B -Used by CMAC and GMAC to specifiy the cipher algorithm. +Used by CMAC and GMAC to specify the cipher algorithm. For CMAC it must be one of AES-128-CBC, AES-192-CBC, AES-256-CBC or DES-EDE3-CBC. For GMAC it should be a GCM mode cipher e.g. AES-128-GCM. diff --git a/doc/man1/pkeyutl.pod b/doc/man1/pkeyutl.pod index 033360f4..3a7f31b8 100644 --- a/doc/man1/pkeyutl.pod +++ b/doc/man1/pkeyutl.pod @@ -395,7 +395,8 @@ Verify some data using an L certificate and a specific ID: L, L, L L, L, L, -L, L +L, L, +L =head1 COPYRIGHT diff --git a/doc/man1/req.pod b/doc/man1/req.pod index 8f30bd79..1e73ee5d 100644 --- a/doc/man1/req.pod +++ b/doc/man1/req.pod @@ -50,6 +50,8 @@ B B [B<-batch>] [B<-verbose>] [B<-engine id>] +[B<-sm2-id string>] +[B<-sm2-hex-id hex-string>] =head1 DESCRIPTION @@ -339,6 +341,16 @@ for all available algorithms. Specifies an engine (by its unique B string) which would be used for key generation operations. +=item B<-sm2-id> + +Specify the ID string to use when verifying an SM2 certificate. The ID string is +required by the SM2 signature algorithm for signing and verification. + +=item B<-sm2-hex-id> + +Specify a binary ID string to use when signing or verifying using an SM2 +certificate. The argument for this option is string of hexadecimal digits. + =back =head1 CONFIGURATION FILE FORMAT @@ -534,6 +546,15 @@ Generate a self signed root certificate: openssl req -x509 -newkey rsa:2048 -keyout key.pem -out req.pem +Create an SM2 private key and then generate a certificate request from it: + + openssl ecparam -genkey -name SM2 -out sm2.key + openssl req -new -key sm2.key -out sm2.csr -sm3 -sigopt "sm2_id:1234567812345678" + +Examine and verify an SM2 certificate request: + + openssl req -verify -in sm2.csr -sm3 -sm2-id 1234567812345678 + Example of a file pointed to by the B option: 1.2.3.4 shortName A longer Name diff --git a/doc/man1/ts.pod b/doc/man1/ts.pod index 38ecffcb..ade077a3 100644 --- a/doc/man1/ts.pod +++ b/doc/man1/ts.pod @@ -170,7 +170,7 @@ in use. (Optional) The message digest to apply to the data file. Any digest supported by the OpenSSL B command can be used. -The default is SHA-1. (Optional) +The default is SHA-256. (Optional) =item B<-tspolicy> object_id @@ -518,7 +518,7 @@ included. Default is no. (Optional) =item B This option specifies the hash function to be used to calculate the TSA's -public key certificate identifier. Default is sha1. (Optional) +public key certificate identifier. Default is sha256. (Optional) =back @@ -530,8 +530,9 @@ openssl/apps/openssl.cnf will do. =head2 Time Stamp Request -To create a time stamp request for design1.txt with SHA-1 -without nonce and policy and no certificate is required in the response: +To create a time stamp request for design1.txt with SHA-256 digest, +without nonce and policy, and without requirement for a certificate +in the response: openssl ts -query -data design1.txt -no_nonce \ -out design1.tsq @@ -546,12 +547,12 @@ To print the content of the previous request in human readable format: openssl ts -query -in design1.tsq -text -To create a time stamp request which includes the MD-5 digest -of design2.txt, requests the signer certificate and nonce, +To create a time stamp request which includes the SHA-512 digest +of design2.txt, requests the signer certificate and nonce, and specifies a policy id (assuming the tsa_policy1 name is defined in the OID section of the config file): - openssl ts -query -data design2.txt -md5 \ + openssl ts -query -data design2.txt -sha512 \ -tspolicy tsa_policy1 -cert -out design2.tsq =head2 Time Stamp Response diff --git a/doc/man3/ADMISSIONS.pod b/doc/man3/ADMISSIONS.pod index 75901233..f86aac92 100644 --- a/doc/man3/ADMISSIONS.pod +++ b/doc/man3/ADMISSIONS.pod @@ -130,7 +130,7 @@ ADMISSION_SYNTAX_set0_contentsOfAdmissions() functions free any existing value and set the pointer to the specified value. The B type has an authority name, authority object, and a -stack of B items. +stack of B items. The ADMISSIONS_get0_admissionAuthority(), ADMISSIONS_get0_namingAuthority(), and ADMISSIONS_get0_professionInfos() functions return pointers to those values within the object. diff --git a/doc/man3/BIO_connect.pod b/doc/man3/BIO_connect.pod index c0edae71..9e0d972b 100644 --- a/doc/man3/BIO_connect.pod +++ b/doc/man3/BIO_connect.pod @@ -24,7 +24,7 @@ but is present for future use. BIO_bind() binds the source address and service to a socket and may be useful before calling BIO_connect(). The options may include -B, which is described in L below. +B, which is described in L below. BIO_connect() connects B to the address and service given by B. Connection B may be zero or any combination of diff --git a/doc/man3/BIO_s_mem.pod b/doc/man3/BIO_s_mem.pod index 6d9e747b..7cb9efa9 100644 --- a/doc/man3/BIO_s_mem.pod +++ b/doc/man3/BIO_s_mem.pod @@ -41,9 +41,10 @@ If the BIO_CLOSE flag is set when a memory BIO is freed then the underlying BUF_MEM structure is also freed. Calling BIO_reset() on a read write memory BIO clears any data in it if the -flag BIO_FLAGS_NONCLEAR_RST is not set. On a read only BIO or if the flag -BIO_FLAGS_NONCLEAR_RST is set it restores the BIO to its original state and -the data can be read again. +flag BIO_FLAGS_NONCLEAR_RST is not set, otherwise it just restores the read +pointer to the state it was just after the last write was performed and the +data can be read again. On a read only BIO it similarly restores the BIO to +its original state and the read only data can be read again. BIO_eof() is true if no data is in the BIO. @@ -79,11 +80,11 @@ first, so the supplied area of memory must be unchanged until the BIO is freed. Writes to memory BIOs will always succeed if memory is available: that is their size can grow indefinitely. -Every read from a read write memory BIO will remove the data just read with -an internal copy operation, if a BIO contains a lot of data and it is -read in small chunks the operation can be very slow. The use of a read only -memory BIO avoids this problem. If the BIO must be read write then adding -a buffering BIO to the chain will speed up the process. +Every write after partial read (not all data in the memory buffer was read) +to a read write memory BIO will have to move the unread data with an internal +copy operation, if a BIO contains a lot of data and it is read in small +chunks intertwined with writes the operation can be very slow. Adding +a buffering BIO to the chain can speed up the process. Calling BIO_set_mem_buf() on a BIO created with BIO_new_secmem() will give undefined results, including perhaps a program crash. @@ -104,6 +105,15 @@ BIO is set to BIO_NOCLOSE, before freeing the BUF_MEM the data pointer in it must be set to NULL as the data pointer does not point to an allocated memory. +Calling BIO_reset() on a read write memory BIO with BIO_FLAGS_NONCLEAR_RST +flag set can have unexpected outcome when the reads and writes to the +BIO are intertwined. As documented above the BIO will be reset to the +state after the last completed write operation. The effects of reads +preceding that write operation cannot be undone. + +Calling BIO_get_mem_ptr() prior to a BIO_reset() call with +BIO_FLAGS_NONCLEAR_RST set has the same effect as a write operation. + =head1 BUGS There should be an option to set the maximum size of a memory BIO. diff --git a/doc/man3/BN_CTX_new.pod b/doc/man3/BN_CTX_new.pod index eb8899b7..17c53ec7 100644 --- a/doc/man3/BN_CTX_new.pod +++ b/doc/man3/BN_CTX_new.pod @@ -2,14 +2,17 @@ =head1 NAME -BN_CTX_new, BN_CTX_secure_new, BN_CTX_free - allocate and free BN_CTX structures +BN_CTX_new_ex, BN_CTX_new, BN_CTX_secure_new_ex, BN_CTX_secure_new, BN_CTX_free +- allocate and free BN_CTX structures =head1 SYNOPSIS #include + BN_CTX *BN_CTX_new_ex(OPENSSL_CTX *ctx); BN_CTX *BN_CTX_new(void); + BN_CTX *BN_CTX_secure_new_ex(OPENSSL_CTX *ctx); BN_CTX *BN_CTX_secure_new(void); void BN_CTX_free(BN_CTX *c); @@ -21,10 +24,17 @@ library functions. Since dynamic memory allocation to create Bs is rather expensive when used in conjunction with repeated subroutine calls, the B structure is used. -BN_CTX_new() allocates and initializes a B structure. -BN_CTX_secure_new() allocates and initializes a B structure +BN_CTX_new_ex() allocates and initializes a B structure for the given +library context B. The value may be NULL in which case the default +library context will be used. BN_CTX_new() is the same as BN_CTX_new_ex() except +that the default library context is always used. + +BN_CTX_secure_new_ex() allocates and initializes a B structure but uses the secure heap (see L) to hold the -Bs. +Bs for the given library context B. The value may be NULL in +which case the default library context will be used. BN_CTX_secure_new() is the +same as BN_CTX_secure_new_ex() except that the default library context is always +used. BN_CTX_free() frees the components of the B and the structure itself. Since BN_CTX_start() is required in order to obtain Bs from the diff --git a/doc/man3/BN_generate_prime.pod b/doc/man3/BN_generate_prime.pod index 253fde3c..eb5d89a3 100644 --- a/doc/man3/BN_generate_prime.pod +++ b/doc/man3/BN_generate_prime.pod @@ -51,7 +51,9 @@ L: =head1 DESCRIPTION BN_generate_prime_ex() generates a pseudo-random prime number of -at least bit length B. +at least bit length B. The returned number is probably prime +with a negligible error. + If B is not B, it will be used to store the number. If B is not B, it is used as follows: @@ -89,8 +91,9 @@ generator. If B is true, it will be a safe prime (i.e. a prime p so that (p-1)/2 is also prime). -The PRNG must be seeded prior to calling BN_generate_prime_ex(). -The prime number generation has a negligible error probability. +The random generator must be seeded prior to calling BN_generate_prime_ex(). +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. BN_is_prime_ex() and BN_is_prime_fasttest_ex() test if the number B

is prime. The following tests are performed until one of them shows that @@ -193,7 +196,8 @@ Instead applications should create a BN_GENCB structure using BN_GENCB_new: =head1 SEE ALSO L, L, -L, L, L +L, L, L, +L =head1 HISTORY diff --git a/doc/man3/BN_rand.pod b/doc/man3/BN_rand.pod index 93e8c3f9..fc41322f 100644 --- a/doc/man3/BN_rand.pod +++ b/doc/man3/BN_rand.pod @@ -2,30 +2,37 @@ =head1 NAME -BN_rand, BN_priv_rand, BN_pseudo_rand, -BN_rand_range, BN_priv_rand_range, BN_pseudo_rand_range +BN_rand_ex, BN_rand, BN_priv_rand_ex, BN_priv_rand, BN_pseudo_rand, +BN_rand_range_ex, BN_rand_range, BN_priv_rand_range_ex, BN_priv_rand_range, +BN_pseudo_rand_range - generate pseudo-random number =head1 SYNOPSIS #include + int BN_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, BN_CTX *ctx); int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); + int BN_priv_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, BN_CTX *ctx); int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom); int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); + int BN_rand_range_ex(BIGNUM *rnd, BIGNUM *range, BN_CTX *ctx); int BN_rand_range(BIGNUM *rnd, BIGNUM *range); + int BN_priv_rand_range_ex(BIGNUM *rnd, BIGNUM *range, BN_CTX *ctx); int BN_priv_rand_range(BIGNUM *rnd, BIGNUM *range); int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); =head1 DESCRIPTION -BN_rand() generates a cryptographically strong pseudo-random number of -B in length and stores it in B. +BN_rand_ex() generate a cryptographically strong pseudo-random +number of B in length and stores it in B using the random number +generator for the library context associated with B. The parameter B +may be NULL in which case the default library context is used. If B is less than zero, or too small to accommodate the requirements specified by the B and B parameters, an error is returned. @@ -40,11 +47,20 @@ If B is B, the number will be odd; if it is B it can be odd or even. If B is 1 then B cannot also be B. -BN_rand_range() generates a cryptographically strong pseudo-random -number B in the range 0 E= B E B. +BN_rand() is the same as BN_rand_ex() except that the default library context +is always used. -BN_priv_rand() and BN_priv_rand_range() have the same semantics as -BN_rand() and BN_rand_range() respectively. They are intended to be +BN_rand_range_ex() generates a cryptographically strong pseudo-random +number B in the range 0 E= B E B using the random number +generator for the library context associated with B. The parameter B +may be NULL in which case the default library context is used. + +BN_rand_range() is the same as BN_rand_range_ex() except that the default +library context is always used. + +BN_priv_rand_ex(), BN_priv_rand(), BN_priv_rand_rand_ex() and +BN_priv_rand_range() have the same semantics as BN_rand_ex(), BN_rand(), +BN_rand_range_ex() and BN_rand_range() respectively. They are intended to be used for generating values that should remain private, and mirror the same difference between L and L. @@ -85,6 +101,11 @@ a future release. The BN_priv_rand() and BN_priv_rand_range() functions were added in OpenSSL 1.1.1. +=item * + +The BN_rand_ex(), BN_priv_rand_ex(), BN_rand_range_ex() and +BN_priv_rand_range_ex() functions were added in OpenSSL 3.0. + =back =head1 COPYRIGHT diff --git a/doc/man3/CMS_final.pod b/doc/man3/CMS_final.pod index eab335e6..8270d53b 100644 --- a/doc/man3/CMS_final.pod +++ b/doc/man3/CMS_final.pod @@ -12,7 +12,7 @@ CMS_final - finalise a CMS_ContentInfo structure =head1 DESCRIPTION -CMS_final() finalises the structure B. It's purpose is to perform any +CMS_final() finalises the structure B. Its purpose is to perform any operations necessary on B (digest computation for example) and set the appropriate fields. The parameter B contains the content to be processed. The B parameter contains a BIO to write content to after diff --git a/doc/man3/CRYPTO_memcmp.pod b/doc/man3/CRYPTO_memcmp.pod new file mode 100644 index 00000000..9182d007 --- /dev/null +++ b/doc/man3/CRYPTO_memcmp.pod @@ -0,0 +1,39 @@ +=pod + +=head1 NAME + +CRYPTO_memcmp - Constant time memory comparison + +=head1 SYNOPSIS + + #include + + int CRYPTO_memcmp(const void *a, const void *b, size_t len); + +=head1 DESCRIPTION + +The CRYPTO_memcmp function compares the B bytes pointed to by B and B +for equality. +It takes an amount of time dependent on B, but independent of the +contents of the memory regions pointed to by B and B. + +=head1 RETURN VALUES + +CRYPTO_memcmp() returns 0 if the memory regions are equal and non-zero +otherwise. + +=head1 NOTES + +Unlike memcmp(2), this function cannot be used to order the two memory regions +as the return value when they differ is undefined, other than being non-zero. + +=head1 COPYRIGHT + +Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut diff --git a/doc/man3/DES_random_key.pod b/doc/man3/DES_random_key.pod index 4f0f25a5..1506923d 100644 --- a/doc/man3/DES_random_key.pod +++ b/doc/man3/DES_random_key.pod @@ -104,9 +104,11 @@ consists of 8 bytes with odd parity. The least significant bit in each byte is the parity bit. The key schedule is an expanded form of the key; it is used to speed the encryption process. -DES_random_key() generates a random key. The PRNG must be seeded -prior to using this function (see L). If the PRNG -could not generate a secure key, 0 is returned. +DES_random_key() generates a random key. The random generator must be +seeded when calling this function. +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. +If the function fails, 0 is returned. Before a DES key can be used, it must be converted into the architecture dependent I via the @@ -117,11 +119,8 @@ and is not a weak or semi-weak key. If the parity is wrong, then -1 is returned. If the key is a weak key, then -2 is returned. If an error is returned, the key schedule is not generated. -DES_set_key() works like -DES_set_key_checked() if the I flag is non-zero, -otherwise like DES_set_key_unchecked(). These functions are available -for compatibility; it is recommended to use a function that does not -depend on a global variable. +DES_set_key() works like DES_set_key_checked() and remains for +backward compatibility. DES_set_odd_parity() sets the parity of the passed I to odd. diff --git a/doc/man3/DSA_generate_key.pod b/doc/man3/DSA_generate_key.pod index 6dc2f79a..079c2fef 100644 --- a/doc/man3/DSA_generate_key.pod +++ b/doc/man3/DSA_generate_key.pod @@ -15,7 +15,9 @@ DSA_generate_key - generate DSA key pair DSA_generate_key() expects B to contain DSA parameters. It generates a new key pair and stores it in Bpub_key> and Bpriv_key>. -The PRNG must be seeded prior to calling DSA_generate_key(). +The random generator must be seeded prior to calling DSA_generate_key(). +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. =head1 RETURN VALUES diff --git a/doc/man3/DSA_sign.pod b/doc/man3/DSA_sign.pod index 07fa3ca9..bf99eccd 100644 --- a/doc/man3/DSA_sign.pod +++ b/doc/man3/DSA_sign.pod @@ -36,8 +36,10 @@ B is the signer's public key. The B parameter is ignored. -The PRNG must be seeded before DSA_sign() (or DSA_sign_setup()) +The random generator must be seeded when DSA_sign() (or DSA_sign_setup()) is called. +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. =head1 RETURN VALUES @@ -54,7 +56,8 @@ Standard, DSS), ANSI X9.30 =head1 SEE ALSO L, L, L, -L +L, +L =head1 COPYRIGHT diff --git a/doc/man3/ERR_put_error.pod b/doc/man3/ERR_put_error.pod index abc9805e..31a0e76f 100644 --- a/doc/man3/ERR_put_error.pod +++ b/doc/man3/ERR_put_error.pod @@ -23,6 +23,7 @@ This function is usually called by a macro. ERR_add_error_data() associates the concatenation of its B string arguments with the error code added last. ERR_add_error_vdata() is similar except the argument is a B. +Multiple calls to these functions append to the current top of the error queue. L can be used to register error strings so that the application can a generate human-readable diff --git a/doc/man3/EVP_CIPHER_meth_new.pod b/doc/man3/EVP_CIPHER_meth_new.pod index c8138382..3d4da9c0 100644 --- a/doc/man3/EVP_CIPHER_meth_new.pod +++ b/doc/man3/EVP_CIPHER_meth_new.pod @@ -10,7 +10,8 @@ EVP_CIPHER_meth_set_set_asn1_params, EVP_CIPHER_meth_set_get_asn1_params, EVP_CIPHER_meth_set_ctrl, EVP_CIPHER_meth_get_init, EVP_CIPHER_meth_get_do_cipher, EVP_CIPHER_meth_get_cleanup, EVP_CIPHER_meth_get_set_asn1_params, EVP_CIPHER_meth_get_get_asn1_params, -EVP_CIPHER_meth_get_ctrl - Routines to build up EVP_CIPHER methods +EVP_CIPHER_meth_get_ctrl, EVP_CIPHER_up_ref +- Routines to build up EVP_CIPHER methods =head1 SYNOPSIS @@ -62,6 +63,8 @@ EVP_CIPHER_meth_get_ctrl - Routines to build up EVP_CIPHER methods int type, int arg, void *ptr); + int EVP_CIPHER_up_ref(EVP_CIPHER *cipher); + =head1 DESCRIPTION The B type is a structure for symmetric cipher method @@ -223,6 +226,8 @@ EVP_CIPHER_meth_get_get_asn1_params() and EVP_CIPHER_meth_get_ctrl() are all used to retrieve the method data given with the EVP_CIPHER_meth_set_*() functions above. +EVP_CIPHER_up_ref() increments the reference count for an EVP_CIPHER structure. + =head1 RETURN VALUES EVP_CIPHER_meth_new() and EVP_CIPHER_meth_dup() return a pointer to a @@ -231,6 +236,8 @@ All EVP_CIPHER_meth_set_*() functions return 1. All EVP_CIPHER_meth_get_*() functions return pointers to their respective B function. +EVP_CIPHER_up_ref() returns 1 for success or 0 otherwise. + =head1 SEE ALSO L diff --git a/doc/man3/EVP_DigestInit.pod b/doc/man3/EVP_DigestInit.pod index 4f5e38c3..bc10fa36 100644 --- a/doc/man3/EVP_DigestInit.pod +++ b/doc/man3/EVP_DigestInit.pod @@ -3,8 +3,8 @@ =head1 NAME EVP_MD_CTX_new, EVP_MD_CTX_reset, EVP_MD_CTX_free, EVP_MD_CTX_copy, -EVP_MD_CTX_copy_ex, EVP_MD_CTX_ctrl, EVP_MD_CTX_set_flags, -EVP_MD_CTX_clear_flags, EVP_MD_CTX_test_flags, +EVP_MD_CTX_copy_ex, EVP_MD_CTX_ctrl, EVP_MD_CTX_set_params, EVP_MD_CTX_get_params, +EVP_MD_CTX_set_flags, EVP_MD_CTX_clear_flags, EVP_MD_CTX_test_flags, EVP_Digest, EVP_DigestInit_ex, EVP_DigestInit, EVP_DigestUpdate, EVP_DigestFinal_ex, EVP_DigestFinalXOF, EVP_DigestFinal, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size, EVP_MD_block_size, EVP_MD_flags, @@ -22,6 +22,8 @@ EVP_MD_CTX_pkey_ctx, EVP_MD_CTX_set_pkey_ctx - EVP digest routines int EVP_MD_CTX_reset(EVP_MD_CTX *ctx); void EVP_MD_CTX_free(EVP_MD_CTX *ctx); void EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void* p2); + int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[]); + int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]); void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags); int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags); @@ -88,12 +90,25 @@ Cleans up digest context B and frees up the space allocated to it. =item EVP_MD_CTX_ctrl() +This is a legacy method. EVP_MD_CTX_set_params() and EVP_MD_CTX_get_params() +is the mechanism that should be used to set and get parameters that are used by +providers. Performs digest-specific control actions on context B. The control command is indicated in B and any additional arguments in B and B. EVP_MD_CTX_ctrl() must be called after EVP_DigestInit_ex(). Other restrictions may apply depending on the control type and digest implementation. See L below for more information. +=item EVP_MD_CTX_get_params + +Retrieves the requested list of B from a MD context B. +See L below for more information. + +=item EVP_MD_CTX_set_params + +Sets the list of into a MD context B. +See L below for more information. + =item EVP_MD_CTX_set_flags(), EVP_MD_CTX_clear_flags(), EVP_MD_CTX_test_flags() Sets, clears and tests B flags. See L below for more information. @@ -239,6 +254,38 @@ depends on how the B is created. =back +=head1 PARAMS + +See L for information about passing parameters. + +EVP_MD_CTX_set_params() can be used with the following OSSL_PARAM keys: + +=over 4 + +=item OSSL_PARAM_DIGEST_KEY_XOFLEN + +Sets the digest length for extendable output functions. +It is used by the SHAKE algorithm. + +=item OSSL_PARAM_DIGEST_KEY_PAD_TYPE + +Sets the pad type. +It is used by the MDC2 algorithm. + +=back + +EVP_MD_CTX_get_params() can be used with the following OSSL_PARAM keys: + +=over 4 + +=item OSSL_PARAM_DIGEST_KEY_MICALG . + +Gets the digest Message Integrity Check algorithm string. This is used when +creating S/MIME multipart/signed messages, as specified in RFC 3851. +It may be used by external engines or providers. + +=back + =head1 CONTROLS EVP_MD_CTX_ctrl() can be used to send the following standard controls: @@ -307,6 +354,11 @@ success and 0 for failure. Returns 1 if successful or 0 for failure. +=item EVP_MD_CTX_set_params(), +EVP_MD_CTX_get_params() + +Returns 1 if successful or 0 for failure. + =item EVP_MD_CTX_copy_ex() Returns 1 if successful or 0 for failure. @@ -418,7 +470,9 @@ digest name passed on the command line. L, L, -L +L, +L, +L The full list of digest algorithms are provided below. @@ -446,9 +500,12 @@ The EVP_dss1() function was removed in OpenSSL 1.1.0. The EVP_MD_CTX_set_pkey_ctx() function was added in 1.1.1. +The EVP_MD_CTX_set_params() and EVP_MD_CTX_get_params() functions were +added in 3.0. + =head1 COPYRIGHT -Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/doc/man3/EVP_DigestSignInit.pod b/doc/man3/EVP_DigestSignInit.pod index b584d706..0f9c9523 100644 --- a/doc/man3/EVP_DigestSignInit.pod +++ b/doc/man3/EVP_DigestSignInit.pod @@ -35,7 +35,7 @@ EVP_MD_CTX is freed). The digest B may be NULL if the signing algorithm supports it. -No B will be created by EVP_DigsetSignInit() if the passed B +No B will be created by EVP_DigestSignInit() if the passed B has already been assigned one via L. See also L. Only EVP_PKEY types that support signing can be used with these functions. This @@ -125,8 +125,9 @@ and public key algorithms. This meant that "clone" digests such as EVP_dss1() needed to be used to sign using SHA1 and DSA. This is no longer necessary and the use of clone digest is now discouraged. -For some key types and parameters the random number generator must be seeded -or the operation will fail. +For some key types and parameters the random number generator must be seeded. +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. The call to EVP_DigestSignFinal() internally finalizes a copy of the digest context. This means that calls to EVP_DigestSignUpdate() and @@ -147,7 +148,8 @@ L, L, L, L, L, L, L, L, -L, L +L, L, +L =head1 HISTORY diff --git a/doc/man3/EVP_DigestVerifyInit.pod b/doc/man3/EVP_DigestVerifyInit.pod index abb29308..97bb7737 100644 --- a/doc/man3/EVP_DigestVerifyInit.pod +++ b/doc/man3/EVP_DigestVerifyInit.pod @@ -32,7 +32,7 @@ being passed to EVP_DigestVerifyInit() (which means the EVP_PKEY_CTX is created inside EVP_DigestVerifyInit() and it will be freed automatically when the EVP_MD_CTX is freed). -No B will be created by EVP_DigsetSignInit() if the passed B +No B will be created by EVP_DigestSignInit() if the passed B has already been assigned one via L. See also L. EVP_DigestVerifyUpdate() hashes B bytes of data at B into the @@ -76,8 +76,9 @@ and public key algorithms. This meant that "clone" digests such as EVP_dss1() needed to be used to sign using SHA1 and DSA. This is no longer necessary and the use of clone digest is now discouraged. -For some key types and parameters the random number generator must be seeded -or the operation will fail. +For some key types and parameters the random number generator must be seeded. +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. The call to EVP_DigestVerifyFinal() internally finalizes a copy of the digest context. This means that EVP_VerifyUpdate() and EVP_VerifyFinal() can @@ -93,7 +94,8 @@ L, L, L, L, L, L, L, L, -L, L +L, L, +L =head1 HISTORY diff --git a/doc/man3/EVP_KDF_CTX.pod b/doc/man3/EVP_KDF_CTX.pod index 342807fa..38993610 100644 --- a/doc/man3/EVP_KDF_CTX.pod +++ b/doc/man3/EVP_KDF_CTX.pod @@ -278,6 +278,7 @@ L L L L +L =head1 HISTORY diff --git a/doc/man3/EVP_MAC.pod b/doc/man3/EVP_MAC.pod index a55d8db2..01ad6ed5 100644 --- a/doc/man3/EVP_MAC.pod +++ b/doc/man3/EVP_MAC.pod @@ -3,7 +3,7 @@ =head1 NAME EVP_MAC, EVP_MAC_CTX, EVP_MAC_CTX_new, EVP_MAC_CTX_new_id, EVP_MAC_CTX_free, -EVP_MAC_CTX_copy, EVP_MAC_CTX_mac, EVP_MAC_size, EVP_MAC_init, EVP_MAC_update, +EVP_MAC_CTX_dup, EVP_MAC_CTX_mac, EVP_MAC_size, EVP_MAC_init, EVP_MAC_update, EVP_MAC_final, EVP_MAC_ctrl, EVP_MAC_vctrl, EVP_MAC_ctrl_str, EVP_MAC_str2ctrl, EVP_MAC_hex2ctrl, EVP_MAC_nid, EVP_MAC_name, EVP_get_macbyname, EVP_get_macbynid, EVP_get_macbyobj - EVP MAC routines @@ -18,7 +18,7 @@ EVP_get_macbyname, EVP_get_macbynid, EVP_get_macbyobj - EVP MAC routines EVP_MAC_CTX *EVP_MAC_CTX_new(const EVP_MAC *mac); EVP_MAC_CTX *EVP_MAC_CTX_new_id(int nid); void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx); - int EVP_MAC_CTX_copy(EVP_MAC_CTX *dest, EVP_MAC_CTX *src); + EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src); const EVP_MAC *EVP_MAC_CTX_mac(EVP_MAC_CTX *ctx); size_t EVP_MAC_size(EVP_MAC_CTX *ctx); int EVP_MAC_init(EVP_MAC_CTX *ctx); @@ -72,10 +72,8 @@ EVP_MAC_CTX_free() frees the contents of the context, including an underlying context if there is one, as well as the context itself. B is a valid parameter, for which this function is a no-op. -EVP_MAC_CTX_copy() makes a deep copy of the C context to the -C context. -The C context I have been created before calling this -function. +EVP_MAC_CTX_dup() duplicates the C context and returns a newly allocated +context. EVP_MAC_CTX_mac() returns the B associated with the context C. @@ -231,13 +229,12 @@ implemented as a macro. =head1 RETURN VALUES -EVP_MAC_CTX_new() and EVP_MAC_CTX_new_id() return a pointer to a newly -created EVP_MAC_CTX, or NULL if allocation failed. +EVP_MAC_CTX_new(), EVP_MAC_CTX_new_id() and EVP_MAC_CTX_dup() return a pointer +to a newly created EVP_MAC_CTX, or NULL if allocation failed. EVP_MAC_CTX_free() returns nothing at all. -EVP_MAC_CTX_copy(), EVP_MAC_init(), EVP_MAC_update(), -and EVP_MAC_final() return 1 on success, 0 on error. +EVP_MAC_init(), EVP_MAC_update(), and EVP_MAC_final() return 1 on success, 0 on error. EVP_MAC_ctrl(), EVP_MAC_ctrl_str(), EVP_MAC_str2ctrl() and EVP_MAC_hex2ctrl() return 1 on success and 0 or a negative value on @@ -359,6 +356,10 @@ L, L, L +=head1 HISTORY + +These functions were added in OpenSSL 3.0.0. + =head1 COPYRIGHT Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. diff --git a/doc/man3/EVP_MD_fetch.pod b/doc/man3/EVP_MD_fetch.pod index cba3bc4f..1e43b4fb 100644 --- a/doc/man3/EVP_MD_fetch.pod +++ b/doc/man3/EVP_MD_fetch.pod @@ -2,7 +2,7 @@ =head1 NAME -EVP_MD_fetch +EVP_MD_fetch, EVP_CIPHER_fetch - Functions to explicitly fetch algorithm implementations =head1 SYNOPSIS @@ -11,60 +11,106 @@ EVP_MD_fetch EVP_MD *EVP_MD_fetch(OPENSSL_CTX *ctx, const char *algorithm, const char *properties); + EVP_CIPHER *EVP_CIPHER_fetch(OPENSSL_CTX *ctx, const char *algorithm, + const char *properties); =head1 DESCRIPTION -The B object is used for representing a digest method implementation. +Cryptographic algorithms are represented by different OpenSSL objects depending +on what type of algorithm it is. The following cryptographic algorithm types are +supported. -Having obtained a digest implementation as an B type it can be used to -calculate the digest of input data using functions such as -L, L and L. +=over 4 -Digest implementations may be obtained in one of three ways, i.e. implicit -fetch, explicit fetch or user defined. +=item B + +Represents a digest algorithm. + +=item B + +Represents a symmetric cipher algorithm. + +=item B + +Represents a Message Authentication Code algorithm. + +=item B + +Represents a Key Derivation Function algorithm. + +=back + +The algorithm objects may or may not have an associated algorithm +implementation. +Cryptographic algorithms are implemented by providers. +Any algorithm may be supported by zero or more providers. +In order to use an algorithm an implementation must first be obtained. +This can happen in one of three ways, i.e. implicit fetch, explicit fetch or +user defined. =over 4 =item Implicit Fetch With implicit fetch an application can use functions such as L, -L or L to obtain an B object. When -used in a function like L the actual implementation to -be used will be fetched implicitly using default search criteria. Typically, -(unless the default search criteria have been changed and/or different providers -have been loaded), this will return an implementation of the appropriate -algorithm from the default provider. +L or L to obtain an algorithm object with +no associated implementation. +When used in a function like L or L +the actual implementation to be used will be fetched implicitly using default +search criteria. +Typically, this will return an implementation of the appropriate algorithm from +the default provider unless the default search criteria have been changed and/or +different providers have been loaded. =item Explicit Fetch -With explicit fetch an application uses the EVP_MD_fetch() function to obtain -an algorithm implementation. An implementation with the given name and -satisfying the search criteria specified in the B parameter -combined with the default search criteria will be looked for within the -available providers and returned. +With explicit fetch an application uses one of the "fetch" functions to obtain +an algorithm object with an associated implementation. +An implementation with the given name that satisfies the search criteria +specified in the B parameter combined with the default search +criteria will be looked for within the available providers and returned. See L for information on default search criteria and L for information about providers. =item User defined -Using the user defined approach an application constructs its own EVP_MD object. -See L for details. +Using the user defined approach an application constructs its own algorithm +object. +See L and L for details. =back -The EVP_MD_fetch() function will look for an algorithm within the providers that -have been loaded into the B given in the B parameter. This -parameter may be NULL in which case the default B will be used. See -L and L for further details. +Having obtained an algorithm implementation as an algorithm object it can then +be used to perform cryptographic operations. +For example to calculate the digest of input data with an B algorithm +object you can use functions such as L, +L and L. + +The fetch functions will look for an algorithm within the providers that +have been loaded into the B given in the B parameter. +This parameter may be NULL in which case the default B will be +used. +See L and L for further details. The B parameter gives the name of the algorithm to be looked up. -Different algorithms can be made available by loading different providers. The -built-in default provider algorithm implementation names are: SHA1, SHA224, -SHA256, SHA384, SHA512, SHA512-224, SHA512-256,SHA3-224, SHA3-256, SHA3-384, -SHA3-512, SHAKE128, SHAKE256, SM3, BLAKE2b512, BLAKE2s256 and MD5-SHA1. +Different algorithms can be made available by loading different providers. + +The built-in default provider digest algorithm implementation names are: SHA1, +SHA224, SHA256, SHA384, SHA512, SHA512-224, SHA512-256, SHA3-224, SHA3-256, +SHA3-384, SHA3-512, SHAKE128, SHAKE256, SM3, BLAKE2b512, BLAKE2s256 and +MD5-SHA1. + +The built-in default provider cipher algorithm implementation names are: +AES-256-ECB, AES-192-ECB, AES-128-ECB, AES-256-CBC, AES-192-CBC, AES-128-CBC, +AES-256-OFB, AES-192-OFB, AES-128-OFB, AES-256-CFB, AES-192-CFB, AES-128-CFB, +AES-256-CFB1, AES-192-CFB1, AES-128-CFB1, AES-256-CFB8, AES-192-CFB8, +AES-128-CFB8, AES-256-CTR, AES-192-CTR, AES-128-CTR, id-aes256-GCM, +id-aes192-GCM and id-aes128-GCM. Additional algorithm implementations may be obtained by loading the "legacy" -provider. The names of these algorithms are: RIPEMD160, MD2, MD4, MD5, MDC2 and +provider. + +The legacy provider digest algorithms are: RIPEMD160, MD2, MD4, MD5, MDC2 and whirlpool. The B parameter specifies the search criteria that will be used to @@ -82,14 +128,19 @@ NULL in which case any implementation from the available providers with the given algorithm name will be returned. The return value from a call to EVP_MD_fetch() must be freed by the caller using -L. Note that EVP_MD objects are reference counted. See -L. +L. +Note that EVP_MD objects are reference counted. See L. + +The return value from a call to EVP_CIPHER_fetch() must be freed by the caller +using L. +Note that EVP_CIPHER objects are reference counted. +See L. =head1 NOTES Where an application that previously used implicit fetch is converted to use explicit fetch care should be taken with the L function. -Specifically, this function returns the EVP_MD object orginally passed to +Specifically, this function returns the EVP_MD object originally passed to EVP_DigestInit_ex() (or other similar function). With implicit fetch the returned EVP_MD object is guaranteed to be available throughout the application lifetime. However, with explicit fetch EVP_MD objects are reference counted. @@ -107,6 +158,14 @@ an EVP_MD object, or NULL on error. Fetch any available implementation of SHA256 in the default context: EVP_MD *md = EVP_MD_fetch(NULL, "SHA256", NULL); + ... + EVP_MD_meth_free(md); + +Fetch any available implementation of AES-128-CBC in the default context: + + EVP_CIPHER *cipher = EVP_CIPHER_fetch(NULL, "AES-128-CBC", NULL); + ... + EVP_CIPHER_meth_free(cipher); Fetch an implementation of SHA256 from the default provider in the default context: @@ -140,7 +199,7 @@ implementation of whirlpool from it: EVP_MD_meth_free(md); Note that in the above example the property string "legacy=yes" is optional -since, assuming no other providers have been loaded, the only implmentation of +since, assuming no other providers have been loaded, the only implementation of the "whirlpool" algorithm is in the "legacy" provider. Also note that the default provider should be explicitly loaded if it is required in addition to other providers: @@ -157,9 +216,10 @@ other providers: =head1 SEE ALSO -L, L, L, -L, L, L, -L +L, L, L, +L, L, L, +L, L, L, +L, L =head1 HISTORY diff --git a/doc/man3/EVP_MD_meth_new.pod b/doc/man3/EVP_MD_meth_new.pod index 6269a05c..5e35539e 100644 --- a/doc/man3/EVP_MD_meth_new.pod +++ b/doc/man3/EVP_MD_meth_new.pod @@ -11,7 +11,7 @@ EVP_MD_meth_set_ctrl, EVP_MD_meth_get_input_blocksize, EVP_MD_meth_get_result_size, EVP_MD_meth_get_app_datasize, EVP_MD_meth_get_flags, EVP_MD_meth_get_init, EVP_MD_meth_get_update, EVP_MD_meth_get_final, EVP_MD_meth_get_copy, EVP_MD_meth_get_cleanup, -EVP_MD_meth_get_ctrl, EVP_MD_upref +EVP_MD_meth_get_ctrl, EVP_MD_up_ref - Routines to build up EVP_MD methods =head1 SYNOPSIS @@ -54,7 +54,7 @@ EVP_MD_meth_get_ctrl, EVP_MD_upref int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd, int p1, void *p2); - int EVP_MD_upref(EVP_MD *md); + int EVP_MD_up_ref(EVP_MD *md); =head1 DESCRIPTION @@ -162,7 +162,7 @@ EVP_MD_meth_get_cleanup() and EVP_MD_meth_get_ctrl() are all used to retrieve the method data given with the EVP_MD_meth_set_*() functions above. -EVP_MD_upref() increments the reference count for an EVP_MD structure. +EVP_MD_up_ref() increments the reference count for an EVP_MD structure. =head1 RETURN VALUES @@ -175,7 +175,7 @@ indicated sizes or flags. All other EVP_CIPHER_meth_get_*() functions return pointers to their respective B function. -EVP_MD_upref() returns 1 for success or 0 otherwise. +EVP_MD_up_ref() returns 1 for success or 0 otherwise. =head1 SEE ALSO @@ -184,7 +184,7 @@ L, L, L =head1 HISTORY The B structure was openly available in OpenSSL before version -1.1. EVP_MD_upref() was added in OpenSSL 3.0. All other functions described +1.1. EVP_MD_up_ref() was added in OpenSSL 3.0. All other functions described here were added in OpenSSL 1.1. =head1 COPYRIGHT diff --git a/doc/man3/EVP_SealInit.pod b/doc/man3/EVP_SealInit.pod index f630e1b1..73d9bb75 100644 --- a/doc/man3/EVP_SealInit.pod +++ b/doc/man3/EVP_SealInit.pod @@ -55,7 +55,9 @@ failure. =head1 NOTES Because a random secret key is generated the random number generator -must be seeded before calling EVP_SealInit(). +must be seeded when EVP_SealInit() is called. +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. The public key must be RSA because it is the only OpenSSL public key algorithm that supports key transport. @@ -75,7 +77,8 @@ with B set to NULL. L, L, L, -L +L, +L =head1 COPYRIGHT diff --git a/doc/man3/EVP_SignInit.pod b/doc/man3/EVP_SignInit.pod index 02786d07..8dbc644a 100644 --- a/doc/man3/EVP_SignInit.pod +++ b/doc/man3/EVP_SignInit.pod @@ -66,9 +66,10 @@ The B interface to digital signatures should almost always be used in preference to the low level interfaces. This is because the code then becomes transparent to the algorithm used and much more flexible. -When signing with DSA private keys the random number generator must be seeded -or the operation will fail. The random number generator does not need to be -seeded for RSA signatures. +When signing with DSA private keys the random number generator must be seeded. +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. +This requirement does not hold for RSA signatures. The call to EVP_SignFinal() internally finalizes a copy of the digest context. This means that calls to EVP_SignUpdate() and EVP_SignFinal() can be called diff --git a/doc/man3/EVP_VerifyInit.pod b/doc/man3/EVP_VerifyInit.pod index b60c31ca..654c6bc5 100644 --- a/doc/man3/EVP_VerifyInit.pod +++ b/doc/man3/EVP_VerifyInit.pod @@ -72,7 +72,7 @@ data have been passed through EVP_SignUpdate(). It is not possible to change the signing parameters using these function. -The previous two bugs are fixed in the newer EVP_VerifyDigest*() function. +The previous two bugs are fixed in the newer EVP_DigestVerify*() function. =head1 SEE ALSO diff --git a/doc/man3/EVP_aria.pod b/doc/man3/EVP_aria.pod index 340e91ad..b686edf5 100644 --- a/doc/man3/EVP_aria.pod +++ b/doc/man3/EVP_aria.pod @@ -32,7 +32,7 @@ EVP_aria_256_ccm, EVP_aria_128_gcm, EVP_aria_192_gcm, EVP_aria_256_gcm, -- EVP AES cipher +- EVP ARIA cipher =head1 SYNOPSIS @@ -106,7 +106,7 @@ L =head1 COPYRIGHT -Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/doc/man3/EVP_md5.pod b/doc/man3/EVP_md5.pod index 01d7157b..a0b127fe 100644 --- a/doc/man3/EVP_md5.pod +++ b/doc/man3/EVP_md5.pod @@ -29,7 +29,7 @@ The MD5 algorithm which produces a 128-bit output from a given input. =item EVP_md5_sha1() -A hash algorithm of SSL v3 that combines MD5 with SHA-1 as decirbed in RFC +A hash algorithm of SSL v3 that combines MD5 with SHA-1 as described in RFC 6101. WARNING: this algorithm is not intended for non-SSL usage. diff --git a/doc/man3/EVP_rc5_32_12_16_cbc.pod b/doc/man3/EVP_rc5_32_12_16_cbc.pod index ee3ef854..0876fab6 100644 --- a/doc/man3/EVP_rc5_32_12_16_cbc.pod +++ b/doc/man3/EVP_rc5_32_12_16_cbc.pod @@ -33,7 +33,26 @@ EVP_rc5_32_12_16_ofb() RC5 encryption algorithm in CBC, CFB, ECB and OFB modes respectively. This is a variable key length cipher with an additional "number of rounds" parameter. By -default the key length is set to 128 bits and 12 rounds. +default the key length is set to 128 bits and 12 rounds. Alternative key lengths +can be set using L. The maximum key length is +2040 bits. + +The following rc5 specific Is are supported (see +L). + +=over 4 + +=item EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_RC5_ROUNDS, rounds, NULL) + +Sets the number of rounds to B. This must be one of RC5_8_ROUNDS, +RC5_12_ROUNDS or RC5_16_ROUNDS. + +=item EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GET_RC5_ROUNDS, 0, &rounds) + +Stores the number of rounds currently configured in B<*rounds> where B<*rounds> +is an int. + +=back =back @@ -43,10 +62,6 @@ These functions return an B structure that contains the implementation of the symmetric cipher. See L for details of the B structure. -=head1 BUGS - -Currently the number of rounds in RC5 can only be set to 8, 12 or 16. -This is a limitation of the current RC5 code rather than the EVP interface. =head1 SEE ALSO diff --git a/doc/man3/OPENSSL_CTX.pod b/doc/man3/OPENSSL_CTX.pod index 53483671..1893c923 100644 --- a/doc/man3/OPENSSL_CTX.pod +++ b/doc/man3/OPENSSL_CTX.pod @@ -21,6 +21,10 @@ the internal default context with functions that take a C argument. OPENSSL_CTX_new() creates a new OpenSSL library context. +When a non default library context is in use care should be taken with +multi-threaded applications to properly clean up thread local resources before +the OPENSSL_CTX is freed. +See L for more information. OPENSSL_CTX_free() frees the given C. diff --git a/doc/man3/OPENSSL_fork_prepare.pod b/doc/man3/OPENSSL_fork_prepare.pod index 4f5380aa..d028a55b 100644 --- a/doc/man3/OPENSSL_fork_prepare.pod +++ b/doc/man3/OPENSSL_fork_prepare.pod @@ -24,7 +24,7 @@ The OPENSSL_fork_prepare(), OPENSSL_fork_parent(), and OPENSSL_fork_child() functions are used to reset this internal state. Platforms without fork(2) will probably not need to use these functions. -Platforms with fork(2) but without pthreads_atfork(3) will probably need +Platforms with fork(2) but without pthread_atfork(3) will probably need to call them manually, as described in the following paragraph. Platforms such as Linux that have both functions will normally not need to call these functions as the OpenSSL library will do so automatically. @@ -32,7 +32,7 @@ functions as the OpenSSL library will do so automatically. L will register these functions with the appropriate handler, when the B flag is used. For other applications, these functions can be called directly. They should be used -according to the calling sequence described by the pthreads_atfork(3) +according to the calling sequence described by the pthread_atfork(3) documentation, which is summarized here. OPENSSL_fork_prepare() should be called before a fork() is done. After the fork() returns, the parent process should call OPENSSL_fork_parent() and the child process should diff --git a/doc/man3/OPENSSL_init_crypto.pod b/doc/man3/OPENSSL_init_crypto.pod index a8325614..e20fc8c9 100644 --- a/doc/man3/OPENSSL_init_crypto.pod +++ b/doc/man3/OPENSSL_init_crypto.pod @@ -5,7 +5,7 @@ OPENSSL_INIT_new, OPENSSL_INIT_set_config_filename, OPENSSL_INIT_set_config_appname, OPENSSL_INIT_set_config_file_flags, OPENSSL_INIT_free, OPENSSL_init_crypto, OPENSSL_cleanup, OPENSSL_atexit, -OPENSSL_thread_stop - OpenSSL initialisation +OPENSSL_thread_stop_ex, OPENSSL_thread_stop - OpenSSL initialisation and deinitialisation functions =head1 SYNOPSIS @@ -15,6 +15,7 @@ and deinitialisation functions void OPENSSL_cleanup(void); int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); int OPENSSL_atexit(void (*handler)(void)); + void OPENSSL_thread_stop_ex(OPENSSL_CTX *ctx); void OPENSSL_thread_stop(void); OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void); @@ -202,11 +203,25 @@ called after deinitialisation of resources local to a thread, but before other process wide resources are freed. In the event that multiple stop handlers are registered, no guarantees are made about the order of execution. -The OPENSSL_thread_stop() function deallocates resources associated -with the current thread. Typically this function will be called automatically by -the library when the thread exits. This should only be called directly if -resources should be freed at an earlier time, or under the circumstances -described in the NOTES section below. +The OPENSSL_thread_stop_ex() function deallocates resources associated +with the current thread for the given OPENSSL_CTX B. The B parameter +can be NULL in which case the default OPENSSL_CTX is used. + +Typically, this function will be called automatically by the library when +the thread exits as long as the OPENSSL_CTX has not been freed before the thread +exits. If OPENSSL_CTX_free() is called OPENSSL_thread_stop_ex will be called +automatically for the current thread (but not any other threads that may have +used this OPENSSL_CTX). + +OPENSSL_thread_stop_ex should be called on all threads that will exit after the +OPENSSL_CTX is freed. +Typically this is not necessary for the default OPENSSL_CTX (because all +resources are cleaned up on library exit) except if thread local resources +should be freed before library exit, or under the circumstances described in +the NOTES section below. + +OPENSSL_thread_stop() is the same as OPENSSL_thread_stop_ex() except that the +default OPENSSL_CTX is always used. The B flag will load a configuration file, as with L with NULL filename and application name and the diff --git a/doc/man3/OPENSSL_s390xcap.pod b/doc/man3/OPENSSL_s390xcap.pod index 34c029a4..e45da446 100644 --- a/doc/man3/OPENSSL_s390xcap.pod +++ b/doc/man3/OPENSSL_s390xcap.pod @@ -34,14 +34,14 @@ There are three types of tokens: The name of a processor generation. A bit in the environment variable's mask is set to one if and only if the specified processor generation implements the corresponding instruction set extension. Possible values -are z900, z990, z9, z10, z196, zEC12, z13 and z14. +are z900, z990, z9, z10, z196, zEC12, z13, z14 and z15. =item :: The name of an instruction followed by two 64-bit masks. The part of the environment variable's mask corresponding to the specified instruction is set to the specified 128-bit mask. Possible values are kimd, klmd, km, kmc, -kmac, kmctr, kmo, kmf, prno and kma. +kmac, kmctr, kmo, kmf, prno, kma, pcc and kdsa. =item stfle::: @@ -139,6 +139,21 @@ the numbering is continuous across 64-bit mask boundaries. # 20 1<<43 KMA-GCM-AES-256 : + pcc : + : + # 64 1<<63 PCC-Scalar-Multiply-P256 + # 65 1<<62 PCC-Scalar-Multiply-P384 + # 66 1<<61 PCC-Scalar-Multiply-P521 + + kdsa : + # 1 1<<62 KDSA-ECDSA-Verify-P256 + # 2 1<<61 KDSA-ECDSA-Verify-P384 + # 3 1<<60 KDSA-ECDSA-Verify-P521 + # 9 1<<54 KDSA-ECDSA-Sign-P256 + # 10 1<<53 KDSA-ECDSA-Sign-P384 + # 11 1<<52 KDSA-ECDSA-Sign-P521 + : + =head1 RETURN VALUES Not available. @@ -159,7 +174,7 @@ Disables the KM-XTS-AES and and the KIMD-SHAKE function codes: =head1 SEE ALSO -[1] z/Architecture Principles of Operation, SA22-7832-11 +[1] z/Architecture Principles of Operation, SA22-7832-12 =head1 COPYRIGHT diff --git a/doc/man3/OSSL_CMP_ITAV_set0.pod b/doc/man3/OSSL_CMP_ITAV_set0.pod new file mode 100644 index 00000000..082b0bfe --- /dev/null +++ b/doc/man3/OSSL_CMP_ITAV_set0.pod @@ -0,0 +1,105 @@ +=pod + +=head1 NAME + +OSSL_CMP_ITAV_create, +OSSL_CMP_ITAV_set0, +OSSL_CMP_ITAV_get0_type, +OSSL_CMP_ITAV_get0_value, +OSSL_CMP_ITAV_push0_stack_item +- OSSL_CMP_ITAV utility functions + +=head1 SYNOPSIS + + #include + OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value); + void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type, + ASN1_TYPE *value); + ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav); + ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav); + + int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p, + OSSL_CMP_ITAV *itav); + +=head1 DESCRIPTION + +ITAV is short for InfoTypeAndValue. This type is defined in RFC 4210 +section 5.3.19 and Appendix F. It is used at various places in CMP messages, +e.g., in the generalInfo PKIHeader field, to hold a key-value pair. + +OSSL_CMP_ITAV_create() creates a new OSSL_CMP_ITAV structure and fills it in. +It combines B and B. + +OSSL_CMP_ITAV_set0() sets the B with an infoType of B and an +infoValue of B. This function uses the pointers B and B +internally, so they must B be freed up after the call. + +OSSL_CMP_ITAV_get0_type() returns a direct pointer to the infoType in the +B. + +OSSL_CMP_ITAV_get0_value() returns a direct pointer to the infoValue in +the B as generic ASN1_TYPE*. + +OSSL_CMP_ITAV_push0_stack_item() pushes B to the stack pointed to +by B<*itav_sk_p>. It creates a new stack if B<*itav_sk_p> points to NULL. + +=head1 NOTES + +CMP is defined in RFC 4210 (and CRMF in RFC 4211). + +=head1 RETURN VALUES + +OSSL_CMP_ITAV_create() returns a pointer to the ITAV structure on success, +or NULL on error. + +OSSL_CMP_ITAV_set0() does not return a value. + +OSSL_CMP_ITAV_get0_type() and OSSL_CMP_ITAV_get0_value() +return the respective pointer or NULL if their input is NULL. + +OSSL_CMP_ITAV_push0_stack_item() returns 1 on success, 0 on error. + +=head1 EXAMPLE + +The following code creates and sets a structure representing a generic +InfoTypeAndValue sequence, using an OID created from text as type, and an +integer as value. Afterwards, it is pushed to the OSSL_CMP_CTX to be later +included in the requests' PKIHeader's genInfo field. + + ASN1_OBJECT *type = OBJ_txt2obj("1.2.3.4.5", 1); + if (type == NULL) ... + + ASN1_INTEGER *asn1int = ASN1_INTEGER_new(); + if (asn1int == NULL || !ASN1_INTEGER_set(asn1int, 12345)) ... + + ASN1_TYPE *val = ASN1_TYPE_new(); + if (val == NULL) ... + ASN1_TYPE_set(val, V_ASN1_INTEGER, asn1int); + + OSSL_CMP_ITAV *itav = OSSL_CMP_ITAV_create(type, val); + if (itav == NULL) ... + + OSSL_CMP_CTX *ctx = OSSL_CMP_CTX_new(); + if (ctx == NULL || !OSSL_CMP_CTX_geninfo_push0_ITAV(ctx, itav)) { + OSSL_CMP_ITAV_free(itav); /* also frees type and val */ + goto err; + } + + ... + + OSSL_CMP_CTX_free(ctx); /* also frees itav */ + +=head1 SEE ALSO + +L, L, L + +=head1 COPYRIGHT + +Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut diff --git a/doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod b/doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod index 0ddfc719..1ca79bc9 100644 --- a/doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod +++ b/doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod @@ -56,7 +56,7 @@ B =head1 COPYRIGHT -Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/doc/man3/OSSL_CRMF_MSG_set1_regCtrl_regToken.pod b/doc/man3/OSSL_CRMF_MSG_set1_regCtrl_regToken.pod index 5709b178..e73a4905 100644 --- a/doc/man3/OSSL_CRMF_MSG_set1_regCtrl_regToken.pod +++ b/doc/man3/OSSL_CRMF_MSG_set1_regCtrl_regToken.pod @@ -96,7 +96,7 @@ RFC 4211 =head1 COPYRIGHT -Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/doc/man3/OSSL_CRMF_MSG_set1_regInfo_certReq.pod b/doc/man3/OSSL_CRMF_MSG_set1_regInfo_certReq.pod index cad175c0..3d895a41 100644 --- a/doc/man3/OSSL_CRMF_MSG_set1_regInfo_certReq.pod +++ b/doc/man3/OSSL_CRMF_MSG_set1_regInfo_certReq.pod @@ -39,7 +39,7 @@ RFC 4211 =head1 COPYRIGHT -Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/doc/man3/OSSL_CRMF_MSG_set_validity.pod b/doc/man3/OSSL_CRMF_MSG_set_validity.pod index 588c8b7b..80f23661 100644 --- a/doc/man3/OSSL_CRMF_MSG_set_validity.pod +++ b/doc/man3/OSSL_CRMF_MSG_set_validity.pod @@ -95,7 +95,7 @@ RFC 4211 =head1 COPYRIGHT -Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/doc/man3/OSSL_CRMF_pbmp_new.pod b/doc/man3/OSSL_CRMF_pbmp_new.pod index 651c4307..cdd30ffc 100644 --- a/doc/man3/OSSL_CRMF_pbmp_new.pod +++ b/doc/man3/OSSL_CRMF_pbmp_new.pod @@ -22,7 +22,7 @@ OSSL_CRMF_pbmp_new OSSL_CRMF_pbm_new() generates a PBM (Password-Based MAC) based on given PBM parameters B, message B, and secret B, along with the respective -lengths B and B. On success writes the adddress of the newly +lengths B and B. On success writes the address of the newly allocated MAC via the B reference parameter and writes the length via the B reference parameter unless it its NULL. @@ -68,7 +68,7 @@ RFC 4211 section 4.4 =head1 COPYRIGHT -Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/doc/man3/OSSL_PARAM.pod b/doc/man3/OSSL_PARAM.pod index 50089b4d..fbe37b4b 100644 --- a/doc/man3/OSSL_PARAM.pod +++ b/doc/man3/OSSL_PARAM.pod @@ -14,7 +14,7 @@ OSSL_PARAM - a structure to pass or request object parameters unsigned char data_type; /* declare what kind of content is in data */ void *data; /* value being passed in or out */ size_t data_size; /* data size */ - size_t *return_size; /* OPTIONAL: address to content size */ + size_t return_size; /* returned size */ }; =head1 DESCRIPTION @@ -143,7 +143,7 @@ C must be set to the size of the data, not the size of the pointer to the data. If this is used in a parameter request, C is not relevant. However, the I will set -C<*return_size> to the size of the data. +C to the size of the data. Note that the use of this type is B and can only be safely used for data that remains constant and in a constant location for a @@ -166,7 +166,7 @@ C must be set to the size of the data, not the size of the pointer to the data. If this is used in a parameter request, C is not relevant. However, the I will set -C<*return_size> to the size of the data. +C to the size of the data. Note that the use of this type is B and can only be safely used for data that remains constant and in a constant location for a @@ -196,9 +196,10 @@ enough set of data, that call should succeed. =item * -A I must never change the fields of an C, it -may only change the contents of the memory that C and -C point at. +Apart from the C, a I must never change the fields +of an C. +To return a value, it should change the contents of the memory that +C points at. =item * @@ -214,7 +215,7 @@ C), but this is in no way mandatory. =item * If a I finds that some data sizes are too small for the -requested data, it must set C<*return_size> for each such +requested data, it must set C for each such C item to the required size, and eventually return an error. @@ -244,9 +245,9 @@ This example is for setting parameters on some object: const char *foo = "some string"; size_t foo_l = strlen(foo) + 1; const char bar[] = "some other string"; - const OSSL_PARAM set[] = { - { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, foo_l, NULL }, - { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), NULL }, + OSSL_PARAM set[] = { + { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, foo_l, 0 }, + { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), 0 }, { NULL, 0, NULL, 0, NULL } }; @@ -258,26 +259,26 @@ This example is for requesting parameters on some object: size_t foo_l; char bar[1024]; size_t bar_l; - const OSSL_PARAM request[] = { - { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, 0 /*irrelevant*/, &foo_l }, - { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), &bar_l }, + OSSL_PARAM request[] = { + { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, 0 /*irrelevant*/, 0 }, + { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), 0 }, { NULL, 0, NULL, 0, NULL } }; A I that receives this array (as C in this example) could fill in the parameters like this: - /* const OSSL_PARAM *params */ + /* OSSL_PARAM *params */ int i; for (i = 0; params[i].key != NULL; i++) { if (strcmp(params[i].key, "foo") == 0) { *(char **)params[i].data = "foo value"; - *params[i].return_size = 10; /* size of "foo value" */ + params[i].return_size = 10; /* size of "foo value" */ } else if (strcmp(params[i].key, "bar") == 0) { - memcpy(params[1].data, "bar value", 10); - *params[1].return_size = 10; /* size of "bar value" */ + memcpy(params[i].data, "bar value", 10); + params[i].return_size = 10; /* size of "bar value" */ } /* Ignore stuff we don't know */ } diff --git a/doc/man3/OSSL_PARAM_TYPE.pod b/doc/man3/OSSL_PARAM_int.pod similarity index 72% rename from doc/man3/OSSL_PARAM_TYPE.pod rename to doc/man3/OSSL_PARAM_int.pod index 1b750b2c..3aa6141f 100644 --- a/doc/man3/OSSL_PARAM_TYPE.pod +++ b/doc/man3/OSSL_PARAM_int.pod @@ -2,18 +2,27 @@ =head1 NAME -OSSL_PARAM_TYPE, OSSL_PARAM_utf8_string, OSSL_PARAM_octet_string, -OSSL_PARAM_utf8_ptr, OSSL_PARAM_octet_ptr, OSSL_PARAM_SIZED_TYPE, -OSSL_PARAM_SIZED_BN, OSSL_PARAM_SIZED_utf8_string, -OSSL_PARAM_SIZED_octet_string, OSSL_PARAM_SIZED_utf8_ptr, -OSSL_PARAM_SIZED_octet_ptr, OSSL_PARAM_END, OSSL_PARAM_construct_TYPE, -OSSL_PARAM_END, -OSSL_PARAM_construct_BN, OSSL_PARAM_construct_utf8_string, -OSSL_PARAM_construct_utf8_ptr, OSSL_PARAM_construct_octet_string, -OSSL_PARAM_construct_octet_ptr, OSSL_PARAM_construct_end, -OSSL_PARAM_locate, OSSL_PARAM_get_TYPE, -OSSL_PARAM_set_TYPE, OSSL_PARAM_get_BN, OSSL_PARAM_set_BN, -OSSL_PARAM_get_utf8_string, OSSL_PARAM_set_utf8_string, +OSSL_PARAM_double, OSSL_PARAM_int, OSSL_PARAM_int32, OSSL_PARAM_int64, +OSSL_PARAM_long, OSSL_PARAM_size_t, OSSL_PARAM_uint, OSSL_PARAM_uint32, +OSSL_PARAM_uint64, OSSL_PARAM_ulong, OSSL_PARAM_BN, OSSL_PARAM_utf8_string, +OSSL_PARAM_octet_string, OSSL_PARAM_utf8_ptr, OSSL_PARAM_octet_ptr, +OSSL_PARAM_END, OSSL_PARAM_construct_BN, OSSL_PARAM_construct_double, +OSSL_PARAM_construct_int, OSSL_PARAM_construct_int32, +OSSL_PARAM_construct_int64, OSSL_PARAM_construct_long, +OSSL_PARAM_construct_size_t, OSSL_PARAM_construct_uint, +OSSL_PARAM_construct_uint32, OSSL_PARAM_construct_uint64, +OSSL_PARAM_construct_ulong, OSSL_PARAM_END, OSSL_PARAM_construct_BN, +OSSL_PARAM_construct_utf8_string, OSSL_PARAM_construct_utf8_ptr, +OSSL_PARAM_construct_octet_string, OSSL_PARAM_construct_octet_ptr, +OSSL_PARAM_construct_end, OSSL_PARAM_locate, OSSL_PARAM_locate_const, +OSSL_PARAM_get_double, OSSL_PARAM_get_int, OSSL_PARAM_get_int32, +OSSL_PARAM_get_int64, OSSL_PARAM_get_long, OSSL_PARAM_get_size_t, +OSSL_PARAM_get_uint, OSSL_PARAM_get_uint32, OSSL_PARAM_get_uint64, +OSSL_PARAM_get_ulong, OSSL_PARAM_set_double, OSSL_PARAM_set_int, +OSSL_PARAM_set_int32, OSSL_PARAM_set_int64, OSSL_PARAM_set_long, +OSSL_PARAM_set_size_t, OSSL_PARAM_set_uint, OSSL_PARAM_set_uint32, +OSSL_PARAM_set_uint64, OSSL_PARAM_set_ulong, OSSL_PARAM_get_BN, +OSSL_PARAM_set_BN, OSSL_PARAM_get_utf8_string, OSSL_PARAM_set_utf8_string, OSSL_PARAM_get_octet_string, OSSL_PARAM_set_octet_string, OSSL_PARAM_get_utf8_ptr, OSSL_PARAM_set_utf8_ptr, OSSL_PARAM_get_octet_ptr, OSSL_PARAM_set_octet_ptr @@ -21,6 +30,8 @@ OSSL_PARAM_set_octet_ptr =head1 SYNOPSIS +=for comment generic + #include #define OSSL_PARAM_TYPE(key, address) @@ -28,50 +39,46 @@ OSSL_PARAM_set_octet_ptr #define OSSL_PARAM_octet_string(key, address, size) #define OSSL_PARAM_utf8_ptr(key, address, size) #define OSSL_PARAM_octet_ptr(key, address, size) - #define OSSL_PARAM_SIZED_TYPE(key, address, return_size) - #define OSSL_PARAM_SIZED_BN(key, address, size, return_size) - #define OSSL_PARAM_SIZED_utf8_string(key, address, size, return_size) - #define OSSL_PARAM_SIZED_octet_string(key, address, size, return_size) - #define OSSL_PARAM_SIZED_utf8_ptr(key, address, size, return_size) - #define OSSL_PARAM_SIZED_octet_ptr(key, address, size, return_size) + #define OSSL_PARAM_BN(key, address, size) #define OSSL_PARAM_END OSSL_PARAM OSSL_PARAM_construct_TYPE(const char *key, TYPE *buf, size_t *ret); OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf, - size_t bsize, size_t *rsize); + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, - size_t bsize, size_t *rsize); + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, - size_t bsize, size_t *rsize); + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, - size_t bsize, size_t *rsize); + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, - size_t bsize, size_t *rsize); + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_end(void); OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *array, const char *key); + const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *array, + const char *key); int OSSL_PARAM_get_TYPE(const OSSL_PARAM *p, const char *key, TYPE *val); - int OSSL_PARAM_set_TYPE(const OSSL_PARAM *p, const char *key, TYPE val); + int OSSL_PARAM_set_TYPE(OSSL_PARAM *p, const char *key, TYPE val); int OSSL_PARAM_get_BN(const OSSL_PARAM *p, const char *key, BIGNUM **val); - int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const char *key, const BIGNUM *val); + int OSSL_PARAM_set_BN(OSSL_PARAM *p, const char *key, const BIGNUM *val); int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len); - int OSSL_PARAM_set_utf8_string(const OSSL_PARAM *p, const char *val); + int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val); int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len, size_t *used_len); - int OSSL_PARAM_set_octet_string(const OSSL_PARAM *p, const void *val, - size_t len); + int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len); int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, char **val); - int OSSL_PARAM_set_utf8_ptr(const OSSL_PARAM *p, char *val); + int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, char *val); int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, void **val, size_t *used_len); - int OSSL_PARAM_set_octet_ptr(const OSSL_PARAM *p, void *val, size_t used_len); + int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, void *val, size_t used_len); =head1 DESCRIPTION @@ -128,26 +135,11 @@ Each of these macros defines a parameter of the specified B with the provided B and parameter variable B

. OSSL_PARAM_utf8_string(), OSSL_PARAM_octet_string(), OSSL_PARAM_utf8_ptr(), -OSSL_PARAM_octet_ptr() are macros that provide support for defining UTF8 -strings and OCTET strings. +OSSL_PARAM_octet_ptr(), OSSL_PARAM_BN() are macros that provide support +for defining UTF8 strings, OCTET strings and big numbers. A parameter with name B is defined. The storage for this parameter is at B
and is of B bytes. -OSSL_PARAM_SIZED_TYPE() are a second series of macros designed to assist with -the initialisation of OSSL_PARAM structures. -They are similar to the OSSL_PARAM_TYPE() macros but also include a -B argument which contains the address of a size_t variable which -will be populated with the actual size of the parameter upon return from a -OSSL_PARAM_set_TYPE() call. - -OSSL_PARAM_SIZED_BN(), OSSL_PARAM_SIZED_utf8_string(), -OSSL_PARAM_SIZED_octet_string(), OSSL_PARAM_SIZED_utf8_ptr(), -OSSL_PARAM_SIZED_octet_ptr() are macros that provide support for defining large -integers, UTF8 string and OCTET strings in an OSSL_PARAM array. -A parameter with name B is defined. -The storage for this parameter is at B
and is of B bytes. -The size used by the parameter value, in bytes, is written to B. - OSSL_PARAM_END provides an end of parameter list marker. This should terminate all OSSL_PARAM arrays. @@ -187,11 +179,14 @@ OSSL_PARAM structure. OSSL_PARAM_locate() is a function that searches an B of parameters for the one matching the B name. +OSSL_PARAM_locate_const() behaves exactly like OSSL_PARAM_locate() except for +the presence of I for the B argument and its return value. + OSSL_PARAM_get_TYPE() retrieves a value of type B from the parameter B

. The value is copied to the address B. Type coercion takes place as discussed in the NOTES section. -OSSL_PARAM_set_TYPE() stores a value B of type B into the paramter +OSSL_PARAM_set_TYPE() stores a value B of type B into the parameter B

. Type coercion takes place as discussed in the NOTES section. @@ -199,7 +194,7 @@ OSSL_PARAM_get_BN() retrieves a BIGNUM from the parameter pointed to by B

. The BIGNUM referenced by B is updated and is allocated if B<*val> is B. -OSSL_PARAM_set_BN() stores the BIGNUM B into the paramater B

. +OSSL_PARAM_set_BN() stores the BIGNUM B into the parameter B

. OSSL_PARAM_get_utf8_string() retrieves a UTF8 string from the parameter pointed to by B

. @@ -242,9 +237,9 @@ OSSL_PARAM_construct_utf8_string(), OSSL_PARAM_construct_octet_string(), OSSL_PARAM_construct_utf8_ptr() and OSSL_PARAM_construct_octet_ptr() return a populated OSSL_PARAM structure. -OSSL_PARAM_locate() returns a pointer to the matching OSSL_PARAM object. -It returns B on error or when no object matching B exists in -the B. +OSSL_PARAM_locate() and OSSL_PARAM_locate_const() return a pointer to +the matching OSSL_PARAM object. They return B on error or when +no object matching B exists in the B. All other functions return B<1> on success and B<0> on failure. @@ -290,21 +285,19 @@ demonstrates that the requestor isn't obligated to request all available parameters: const char *foo = NULL; - size_t foo_l; char bar[1024]; - size_t bar_l; - const OSSL_PARAM request[] = { - OSSL_PARAM_UTF8_PTR("foo", foo, 0, foo_l), - OSSL_PARAM_UTF8_STRING("bar", bar, sizeof(bar), bar_l), + OSSL_PARAM request[] = { + OSSL_PARAM_utf8_ptr("foo", foo, 0), + OSSL_PARAM_utf8_string("bar", bar, sizeof(bar)), OSSL_PARAM_END }; A I that receives this array (as C in this example) could fill in the parameters like this: - /* const OSSL_PARAM *params */ + /* OSSL_PARAM *params */ - const OSSL_PARAM *p; + OSSL_PARAM *p; if ((p = OSSL_PARAM_locate(params, "foo")) == NULL) OSSL_PARAM_set_utf8_ptr(p, "foo value"); diff --git a/doc/man3/OSSL_PROVIDER.pod b/doc/man3/OSSL_PROVIDER.pod index e3653663..9fe2e18a 100644 --- a/doc/man3/OSSL_PROVIDER.pod +++ b/doc/man3/OSSL_PROVIDER.pod @@ -16,7 +16,7 @@ OSSL_PROVIDER_add_builtin - provider routines int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov); const OSSL_ITEM *OSSL_PROVIDER_get_param_types(OSSL_PROVIDER *prov); - int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, const OSSL_PARAM params[]); + int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, OSSL_PARAM params[]); int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *, const char *name, ossl_provider_init_fn *init_fn); @@ -81,7 +81,7 @@ its build number. OSSL_PROVIDER *prov = NULL; const char *build = NULL; size_t built_l = 0; - const OSSL_PARAM request[] = { + OSSL_PARAM request[] = { { "build", OSSL_PARAM_UTF8_STRING_PTR, &build, 0, &build_l }, { NULL, 0, NULL, 0, NULL } }; diff --git a/doc/man3/OSSL_STORE_LOADER.pod b/doc/man3/OSSL_STORE_LOADER.pod index 0a4d2f7a..101857d5 100644 --- a/doc/man3/OSSL_STORE_LOADER.pod +++ b/doc/man3/OSSL_STORE_LOADER.pod @@ -95,7 +95,7 @@ manner possible according to the scheme the loader implements, it also takes a B and associated data, to be used any time something needs to be prompted for. Furthermore, this function is expected to initialize what needs to be -initialized, to create a privata data store (B, see +initialized, to create a private data store (B, see above), and to return it. If something goes wrong, this function is expected to return NULL. diff --git a/doc/man3/OSSL_STORE_expect.pod b/doc/man3/OSSL_STORE_expect.pod index 05d6ea35..1a270c84 100644 --- a/doc/man3/OSSL_STORE_expect.pod +++ b/doc/man3/OSSL_STORE_expect.pod @@ -32,7 +32,7 @@ grained search of objects. OSSL_STORE_supports_search() checks if the loader of the given OSSL_STORE context supports the given search type. -See L for information on the +See L for information on the supported search criterion types. OSSL_STORE_expect() and OSSL_STORE_find I be called before the first diff --git a/doc/man3/OSSL_trace_enabled.pod b/doc/man3/OSSL_trace_enabled.pod index e26dee53..958e8b06 100644 --- a/doc/man3/OSSL_trace_enabled.pod +++ b/doc/man3/OSSL_trace_enabled.pod @@ -3,11 +3,17 @@ =head1 NAME OSSL_trace_enabled, OSSL_trace_begin, OSSL_trace_end, -OSSL_TRACE_BEGIN, OSSL_TRACE_END, OSSL_TRACE1, OSSL_TRACE2, OSSL_TRACE9 +OSSL_TRACE_BEGIN, OSSL_TRACE_END, OSSL_TRACE_CANCEL, +OSSL_TRACE, OSSL_TRACE1, OSSL_TRACE2, OSSL_TRACE3, OSSL_TRACE4, +OSSL_TRACE5, OSSL_TRACE6, OSSL_TRACE7, OSSL_TRACE8, OSSL_TRACE9, +OSSL_TRACEV, +OSSL_TRACE_ENABLED - OpenSSL Tracing API =head1 SYNOPSIS +=for comment generic + #include int OSSL_trace_enabled(int category); @@ -17,7 +23,13 @@ OSSL_TRACE_BEGIN, OSSL_TRACE_END, OSSL_TRACE1, OSSL_TRACE2, OSSL_TRACE9 /* trace group macros */ OSSL_TRACE_BEGIN(category) { - ... + ... + if (some_error) { + /* Leave trace group prematurely in case of an error */ + OSSL_TRACE_CANCEL(category); + goto err; + } + ... } OSSL_TRACE_END(category); /* one-shot trace macros */ @@ -26,6 +38,10 @@ OSSL_TRACE_BEGIN, OSSL_TRACE_END, OSSL_TRACE1, OSSL_TRACE2, OSSL_TRACE9 ... OSSL_TRACE9(category, format, arg1, ..., arg9) + /* check whether a trace category is enabled */ + if (OSSL_TRACE_ENABLED(category)) { + ... + } =head1 DESCRIPTION @@ -113,7 +129,7 @@ jumping out of a trace section: OSSL_TRACE_BEGIN(TLS) { - if (condition) { + if (some_error) { OSSL_TRACE_CANCEL(TLS); goto err; } @@ -126,7 +142,7 @@ This will normally expand to: do { BIO *trc_out = OSSL_trace_begin(OSSL_TRACE_CATEGORY_TLS); if (trc_out != NULL) { - if (condition) { + if (some_error) { OSSL_trace_end(OSSL_TRACE_CATEGORY_TLS, trc_out); goto err; } @@ -136,26 +152,71 @@ This will normally expand to: } while (0); -C, ... C are one-shot macros which essentially wrap -a single BIO_printf() into a tracing group. +C and C, C, ... C are +so-called one-shot macros: -The call OSSL_TRACEn(category, format, arg1, ..., argN) expands to: +The macro call C, produces literal text trace output. - OSSL_TRACE_BEGIN(category) { - BIO_printf(trc_out, format, arg1, ..., argN) - } OSSL_TRACE_END(category) +The macro call C produces +printf-style trace output with n format field arguments (n=1,...,9). +It expands to: + + OSSL_TRACE_BEGIN(category) { + BIO_printf(trc_out, format, arg1, ..., argN) + } OSSL_TRACE_END(category) + +Internally, all one-shot macros are implemented using a generic C +macro, since C90 does not support variadic macros. This helper macro has a rather +weird synopsis and should not be used directly. + +The C macro can be used to conditionally execute +some code only if a specific trace category is enabled. +In some situations this is simpler than entering a trace section using +C and C. +For example, the code + + if (OSSL_TRACE_ENABLED(TLS)) { + ... + } + +expands to + + if (OSSL_trace_enabled(OSSL_TRACE_CATEGORY_TLS) { + ... + } =head1 NOTES -It is advisable to always check that a trace type is enabled with -OSSL_trace_enabled() before generating any output, for example: +If producing the trace output requires carrying out auxiliary calculations, +this auxiliary code should be placed inside a conditional block which is +executed only if the trace category is enabled. - if (OSSL_trace_enabled(OSSL_TRACE_CATEGORY_TLS)) { - BIO *trace = OSSL_trace_begin(OSSL_TRACE_CATEGORY_TLS); - BIO_printf(trace, "FOO %d\n", somevalue); - BIO_dump(trace, somememory, somememory_l); - OSSL_trace_end(OSSL_TRACE_CATEGORY_TLS, trace); - } +The most natural way to do this is to place the code inside the trace section +itself because it already introduces such a conditional block. + + OSSL_TRACE_BEGIN(TLS) { + int var = do_some_auxiliary_calculation(); + + BIO_printf(trc_out, "var = %d\n", var); + + } OSSL_TRACE_END(TLS); + +In some cases it is more advantageous to use a simple conditional group instead +of a trace section. This is the case if calculations and tracing happen in +different locations of the code, or if the calculations are so time consuming +that placing them inside a (critical) trace section would create too much +contention. + + if (OSSL_TRACE_ENABLED(TLS)) { + int var = do_some_auxiliary_calculation(); + + OSSL_TRACE1("var = %d\n", var); + } + +Note however that premature optimization of tracing code is in general futile +and it's better to keep the tracing code as simple as possible. +Because most often the limiting factor for the application's speed is the time +it takes to print the trace output, not to calculate it. =head2 Configure Tracing diff --git a/doc/man3/RAND_DRBG_get0_master.pod b/doc/man3/RAND_DRBG_get0_master.pod index 62f6fdbd..77d0ab70 100644 --- a/doc/man3/RAND_DRBG_get0_master.pod +++ b/doc/man3/RAND_DRBG_get0_master.pod @@ -2,6 +2,9 @@ =head1 NAME +OPENSSL_CTX_get0_master_drbg, +OPENSSL_CTX_get0_public_drbg, +OPENSSL_CTX_get0_private_drbg, RAND_DRBG_get0_master, RAND_DRBG_get0_public, RAND_DRBG_get0_private @@ -11,6 +14,9 @@ RAND_DRBG_get0_private #include + RAND_DRBG *OPENSSL_CTX_get0_master_drbg(OPENSSL_CTX *ctx); + RAND_DRBG *OPENSSL_CTX_get0_public_drbg(OPENSSL_CTX *ctx); + RAND_DRBG *OPENSSL_CTX_get0_private_drbg(OPENSSL_CTX *ctx); RAND_DRBG *RAND_DRBG_get0_master(void); RAND_DRBG *RAND_DRBG_get0_public(void); RAND_DRBG *RAND_DRBG_get0_private(void); @@ -21,26 +27,35 @@ RAND_DRBG_get0_private The default RAND API implementation (RAND_OpenSSL()) utilizes three shared DRBG instances which are accessed via the RAND API: -The and DRBG are thread-local instances, which are used +The I and I DRBG are thread-local instances, which are used by RAND_bytes() and RAND_priv_bytes(), respectively. -The DRBG is a global instance, which is not intended to be used +The I DRBG is a global instance, which is not intended to be used directly, but is used internally to reseed the other two instances. These functions here provide access to the shared DRBG instances. =head1 RETURN VALUES -RAND_DRBG_get0_master() returns a pointer to the DRBG instance. +OPENSSL_CTX_get0_master_drbg() returns a pointer to the I DRBG instance +for the given OPENSSL_CTX B. -RAND_DRBG_get0_public() returns a pointer to the DRBG instance. +OPENSSL_CTX_get0_public_drbg() returns a pointer to the I DRBG instance +for the given OPENSSL_CTX B. -RAND_DRBG_get0_private() returns a pointer to the DRBG instance. +OPENSSL_CTX_get0_private_drbg() returns a pointer to the I DRBG instance +for the given OPENSSL_CTX B. +In all the above cases the B parameter can +be NULL in which case the default OPENSSL_CTX is used. RAND_DRBG_get0_master(), +RAND_DRBG_get0_public() and RAND_DRBG_get0_private() are the same as +OPENSSL_CTX_get0_master_drbg(), OPENSSL_CTX_get0_public_drbg() and +OPENSSL_CTX_get0_private_drbg() respectively except that the default OPENSSL_CTX +is always used. =head1 NOTES -It is not thread-safe to access the DRBG instance. -The and DRBG instance can be accessed safely, because +It is not thread-safe to access the I DRBG instance. +The I and I DRBG instance can be accessed safely, because they are thread-local. Note however, that changes to these two instances apply only to the current thread. @@ -65,7 +80,10 @@ L =head1 HISTORY -The RAND_DRBG functions were added in OpenSSL 1.1.1. +The OPENSSL_CTX_get0_master_drbg(), OPENSSL_CTX_get0_public_drbg() and +OPENSSL_CTX_get0_private_drbg() functions were added in OpenSSL 3.0. + +All other RAND_DRBG functions were added in OpenSSL 1.1.1. =head1 COPYRIGHT diff --git a/doc/man3/RAND_DRBG_new.pod b/doc/man3/RAND_DRBG_new.pod index 8b738406..3ff98ae0 100644 --- a/doc/man3/RAND_DRBG_new.pod +++ b/doc/man3/RAND_DRBG_new.pod @@ -2,7 +2,9 @@ =head1 NAME +RAND_DRBG_new_ex, RAND_DRBG_new, +RAND_DRBG_secure_new_ex, RAND_DRBG_secure_new, RAND_DRBG_set, RAND_DRBG_set_defaults, @@ -15,11 +17,20 @@ RAND_DRBG_free #include + RAND_DRBG *RAND_DRBG_new_ex(OPENSSL_CTX *ctx, + int type, + unsigned int flags, + RAND_DRBG *parent); RAND_DRBG *RAND_DRBG_new(int type, unsigned int flags, RAND_DRBG *parent); + RAND_DRBG *RAND_DRBG_secure_new_ex(OPENSSL_CTX *ctx, + int type, + unsigned int flags, + RAND_DRBG *parent); + RAND_DRBG *RAND_DRBG_secure_new(int type, unsigned int flags, RAND_DRBG *parent); @@ -39,10 +50,13 @@ RAND_DRBG_free =head1 DESCRIPTION -RAND_DRBG_new() and RAND_DRBG_secure_new() +RAND_DRBG_new_ex() and RAND_DRBG_secure_new_ex() create a new DRBG instance of the given B, allocated from the heap resp. -the secure heap -(using OPENSSL_zalloc() resp. OPENSSL_secure_zalloc()). +the secure heap, for the given OPENSSL_CTX +(using OPENSSL_zalloc() resp. OPENSSL_secure_zalloc()). The parameter can +be NULL in which case the default OPENSSL_CTX is used. RAND_DRBG_new() and +RAND_DRBG_secure_new() are the same as RAND_DRBG_new_ex() and +RAND_DRBG_secure_new_ex() except that the default OPENSSL_CTX is always used. RAND_DRBG_set() initializes the B with the given B and B. @@ -108,8 +122,9 @@ uninstantiated state. =head1 RETURN VALUES -RAND_DRBG_new() and RAND_DRBG_secure_new() return a pointer to a DRBG -instance allocated on the heap, resp. secure heap. +RAND_DRBG_new_ex(), RAND_DRBG_new(), RAND_DRBG_secure_new_ex() and +RAND_DRBG_secure_new() return a pointer to a DRBG instance allocated on the +heap, resp. secure heap. RAND_DRBG_set(), RAND_DRBG_instantiate(), and diff --git a/doc/man3/RAND_DRBG_set_callbacks.pod b/doc/man3/RAND_DRBG_set_callbacks.pod index 09a6ef1f..695c1903 100644 --- a/doc/man3/RAND_DRBG_set_callbacks.pod +++ b/doc/man3/RAND_DRBG_set_callbacks.pod @@ -111,7 +111,7 @@ and is being used. The derivation function is disabled during initialization by calling the RAND_DRBG_set() function with the RAND_DRBG_FLAG_CTR_NO_DF flag. For more information on the derivation function and when it can be omitted, -see [NIST SP 800-90A Rev. 1]. Roughly speeking it can be omitted if the random +see [NIST SP 800-90A Rev. 1]. Roughly speaking it can be omitted if the random source has "full entropy", i.e., contains 8 bits of entropy per byte. Even if a nonce is required, the B() and B() diff --git a/doc/man3/RSA_blinding_on.pod b/doc/man3/RSA_blinding_on.pod index 3bdf7346..db06b2f6 100644 --- a/doc/man3/RSA_blinding_on.pod +++ b/doc/man3/RSA_blinding_on.pod @@ -20,8 +20,7 @@ must be used to protect the RSA operation from that attack. RSA_blinding_on() turns blinding on for key B and generates a random blinding factor. B is B or a pre-allocated and -initialized B. The random number generator must be seeded -prior to calling RSA_blinding_on(). +initialized B. RSA_blinding_off() turns blinding off and frees the memory used for the blinding factor. diff --git a/doc/man3/RSA_generate_key.pod b/doc/man3/RSA_generate_key.pod index b4ff54f8..9d8b4228 100644 --- a/doc/man3/RSA_generate_key.pod +++ b/doc/man3/RSA_generate_key.pod @@ -16,7 +16,7 @@ Deprecated since OpenSSL 0.9.8, can be hidden entirely by defining B with a suitable version value, see L: - RSA *RSA_generate_key(int num, unsigned long e, + RSA *RSA_generate_key(int bits, unsigned long e, void (*callback)(int, int, void *), void *cb_arg); =head1 DESCRIPTION @@ -27,8 +27,10 @@ be seeded prior to calling RSA_generate_key_ex(). RSA_generate_multi_prime_key() generates a multi-prime RSA key pair and stores it in the B structure provided in B. The number of primes is given by -the B parameter. The pseudo-random number generator must be seeded prior -to calling RSA_generate_multi_prime_key(). +the B parameter. The random number generator must be seeded when +calling RSA_generate_multi_prime_key(). +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. The modulus size will be of length B, the number of primes to form the modulus will be B, and the public exponent will be B. Key sizes @@ -47,7 +49,7 @@ progress of the key generation. If B is not B, it will be called as follows using the BN_GENCB_call() function described on the L page. -RSA_generate_prime() is similar to RSA_generate_prime_ex() but +RSA_generate_key() is similar to RSA_generate_key_ex() but expects an old-style callback function; see L for information on the old-style callback. @@ -88,7 +90,8 @@ B is used with two different meanings. =head1 SEE ALSO -L, L, L +L, L, L, +L =head1 HISTORY diff --git a/doc/man3/RSA_padding_add_PKCS1_type_1.pod b/doc/man3/RSA_padding_add_PKCS1_type_1.pod index 685063b2..40eb8f94 100644 --- a/doc/man3/RSA_padding_add_PKCS1_type_1.pod +++ b/doc/man3/RSA_padding_add_PKCS1_type_1.pod @@ -100,6 +100,8 @@ simply copy the data The random number generator must be seeded prior to calling RSA_padding_add_xxx(). +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. RSA_padding_check_xxx() verifies that the B bytes at B contain a valid encoding for a B byte RSA key in the respective @@ -143,7 +145,8 @@ including PKCS1_OAEP. L, L, -L, L +L, L, +L =head1 COPYRIGHT diff --git a/doc/man3/RSA_sign_ASN1_OCTET_STRING.pod b/doc/man3/RSA_sign_ASN1_OCTET_STRING.pod index fad65e0c..27e7cdf6 100644 --- a/doc/man3/RSA_sign_ASN1_OCTET_STRING.pod +++ b/doc/man3/RSA_sign_ASN1_OCTET_STRING.pod @@ -26,7 +26,10 @@ memory. B is ignored. -The random number generator must be seeded prior to calling RSA_sign_ASN1_OCTET_STRING(). +The random number generator must be seeded when calling +RSA_sign_ASN1_OCTET_STRING(). +If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to +external circumstances (see L), the operation will fail. RSA_verify_ASN1_OCTET_STRING() verifies that the signature B of size B is the DER representation of a given octet string @@ -49,7 +52,8 @@ These functions serve no recognizable purpose. L, L, L, -L +L, +L =head1 COPYRIGHT diff --git a/doc/man3/SSL_CONF_cmd.pod b/doc/man3/SSL_CONF_cmd.pod index 5c58268f..227d9de3 100644 --- a/doc/man3/SSL_CONF_cmd.pod +++ b/doc/man3/SSL_CONF_cmd.pod @@ -79,9 +79,13 @@ B. The B argument is a colon separated list of groups. The group can be either the B name (e.g. B), some other commonly used name where -applicable (e.g. B) or an OpenSSL OID name (e.g B). Group -names are case sensitive. The list should be in order of preference with the -most preferred group first. +applicable (e.g. B, B) or an OpenSSL OID name +(e.g B). Group names are case sensitive. The list should be in +order of preference with the most preferred group first. + +Currently supported groups for B are B, B, B, +B, B, B, B, B, B, +B. =item B<-curves> @@ -356,9 +360,13 @@ B. The B argument is a colon separated list of groups. The group can be either the B name (e.g. B), some other commonly used name where -applicable (e.g. B) or an OpenSSL OID name (e.g B). Group -names are case sensitive. The list should be in order of preference with the -most preferred group first. +applicable (e.g. B, B) or an OpenSSL OID name +(e.g B). Group names are case sensitive. The list should be in +order of preference with the most preferred group first. + +Currently supported groups for B are B, B, B, +B, B, B, B, B, B, +B. =item B diff --git a/doc/man3/SSL_CTX_new.pod b/doc/man3/SSL_CTX_new.pod index 4b3e8ddb..6680496c 100644 --- a/doc/man3/SSL_CTX_new.pod +++ b/doc/man3/SSL_CTX_new.pod @@ -94,28 +94,31 @@ The actual protocol version used will be negotiated to the highest version mutually supported by the client and the server. The supported protocols are SSLv3, TLSv1, TLSv1.1, TLSv1.2 and TLSv1.3. Applications should use these methods, and avoid the version-specific -methods described below. +methods described below, which are deprecated. =item SSLv23_method(), SSLv23_server_method(), SSLv23_client_method() -Use of these functions is deprecated. They have been replaced with the above -TLS_method(), TLS_server_method() and TLS_client_method() respectively. New -code should use those functions instead. +These functions do not exist anymore, they have been renamed to +TLS_method(), TLS_server_method() and TLS_client_method() respectively. +Currently, the old function calls are renamed to the corresponding new +ones by preprocessor macros, to ensure that existing code which uses the +old function names still compiles. However, using the old function names +is deprecated and new code should call the new functions instead. =item TLSv1_2_method(), TLSv1_2_server_method(), TLSv1_2_client_method() A TLS/SSL connection established with these methods will only understand the -TLSv1.2 protocol. +TLSv1.2 protocol. These methods are deprecated. =item TLSv1_1_method(), TLSv1_1_server_method(), TLSv1_1_client_method() A TLS/SSL connection established with these methods will only understand the -TLSv1.1 protocol. +TLSv1.1 protocol. These methods are deprecated. =item TLSv1_method(), TLSv1_server_method(), TLSv1_client_method() A TLS/SSL connection established with these methods will only understand the -TLSv1 protocol. +TLSv1 protocol. These methods are deprecated. =item SSLv3_method(), SSLv3_server_method(), SSLv3_client_method() @@ -131,10 +134,12 @@ Currently supported protocols are DTLS 1.0 and DTLS 1.2. =item DTLSv1_2_method(), DTLSv1_2_server_method(), DTLSv1_2_client_method() These are the version-specific methods for DTLSv1.2. +These methods are deprecated. =item DTLSv1_method(), DTLSv1_server_method(), DTLSv1_client_method() These are the version-specific methods for DTLSv1. +These methods are deprecated. =back diff --git a/doc/man3/SSL_CTX_set1_curves.pod b/doc/man3/SSL_CTX_set1_curves.pod index b6f647e9..bb58a4db 100644 --- a/doc/man3/SSL_CTX_set1_curves.pod +++ b/doc/man3/SSL_CTX_set1_curves.pod @@ -39,11 +39,16 @@ SSL_CTX_set1_groups() sets the supported groups for B to B groups in the array B. The array consist of all NIDs of groups in preference order. For a TLS client the groups are used directly in the supported groups extension. For a TLS server the groups are used to -determine the set of shared groups. +determine the set of shared groups. Currently supported groups for +B are B, B, B, +B, B, B, B, +B, B and B. SSL_CTX_set1_groups_list() sets the supported groups for B to string B. The string is a colon separated list of group NIDs or -names, for example "P-521:P-384:P-256". +names, for example "P-521:P-384:P-256:X25519:ffdhe2048". Currently supported +groups for B are B, B, B, B, B, +B, B, B, B, B. SSL_set1_groups() and SSL_set1_groups_list() are similar except they set supported groups for the SSL structure B. diff --git a/doc/man3/SSL_CTX_set_cipher_list.pod b/doc/man3/SSL_CTX_set_cipher_list.pod index eccc8117..18524054 100644 --- a/doc/man3/SSL_CTX_set_cipher_list.pod +++ b/doc/man3/SSL_CTX_set_cipher_list.pod @@ -5,7 +5,9 @@ SSL_CTX_set_cipher_list, SSL_set_cipher_list, SSL_CTX_set_ciphersuites, -SSL_set_ciphersuites +SSL_set_ciphersuites, +OSSL_default_cipher_list, +OSSL_default_ciphersuites - choose list of available SSL_CIPHERs =head1 SYNOPSIS @@ -18,6 +20,9 @@ SSL_set_ciphersuites int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str); int SSL_set_ciphersuites(SSL *s, const char *str); + const char *OSSL_default_cipher_list(void); + const char *OSSL_default_ciphersuites(void); + =head1 DESCRIPTION SSL_CTX_set_cipher_list() sets the list of available ciphers (TLSv1.2 and below) @@ -31,7 +36,7 @@ B. SSL_CTX_set_ciphersuites() is used to configure the available TLSv1.3 ciphersuites for B. This is a simple colon (":") separated list of TLSv1.3 -ciphersuite names in order of perference. Valid TLSv1.3 ciphersuite names are: +ciphersuite names in order of preference. Valid TLSv1.3 ciphersuite names are: =over 4 @@ -54,6 +59,10 @@ An empty list is permissible. The default value for the this setting is: SSL_set_ciphersuites() is the same as SSL_CTX_set_ciphersuites() except it configures the ciphersuites for B. +OSSL_default_cipher_list() returns the default cipher string for TLSv1.2 +(and earlier) ciphers. OSSL_default_ciphersuites() returns the default +cipher string for TLSv1.3 ciphersuites. + =head1 NOTES The control string B for SSL_CTX_set_cipher_list() and @@ -85,6 +94,10 @@ of 512 bits and the server is not configured to use temporary RSA keys), the "no shared cipher" (SSL_R_NO_SHARED_CIPHER) error is generated and the handshake will fail. +OSSL_default_cipher_list() and OSSL_default_ciphersuites() replace +SSL_DEFAULT_CIPHER_LIST and TLS_DEFAULT_CIPHERSUITES, respectively. The +cipher list defines are deprecated as of 3.0.0. + =head1 RETURN VALUES SSL_CTX_set_cipher_list() and SSL_set_cipher_list() return 1 if any cipher @@ -100,6 +113,10 @@ L, L, L +=head1 HISTORY + +OSSL_default_cipher_list() and OSSL_default_ciphersites() are new in 3.0.0. + =head1 COPYRIGHT Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. diff --git a/doc/man3/SSL_CTX_set_generate_session_id.pod b/doc/man3/SSL_CTX_set_generate_session_id.pod index 8bf8e152..d90b138f 100644 --- a/doc/man3/SSL_CTX_set_generate_session_id.pod +++ b/doc/man3/SSL_CTX_set_generate_session_id.pod @@ -10,7 +10,7 @@ SSL_has_matching_session_id, GEN_SESSION_CB #include - typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id, + typedef int (*GEN_SESSION_CB)(SSL *ssl, unsigned char *id, unsigned int *id_len); int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb); @@ -98,7 +98,7 @@ server id given, and will fill the rest with pseudo random bytes: const char session_id_prefix = "www-18"; #define MAX_SESSION_ID_ATTEMPTS 10 - static int generate_session_id(const SSL *ssl, unsigned char *id, + static int generate_session_id(SSL *ssl, unsigned char *id, unsigned int *id_len) { unsigned int count = 0; diff --git a/doc/man3/SSL_CTX_set_srp_password.pod b/doc/man3/SSL_CTX_set_srp_password.pod index 0936885f..b8a5873c 100644 --- a/doc/man3/SSL_CTX_set_srp_password.pod +++ b/doc/man3/SSL_CTX_set_srp_password.pod @@ -111,7 +111,7 @@ user salt, B the password verifier and B is the optional user info. The SSL_set_srp_server_param_pw() function sets all SRP parameters for the connection B by generating a random salt and a password verifier. -B is the username, B the password and B the SRP group paramters +B is the username, B the password and B the SRP group parameters identifier for L. The SSL_get_srp_g() function returns the SRP group generator for B, or from diff --git a/doc/man3/SSL_CTX_set_verify.pod b/doc/man3/SSL_CTX_set_verify.pod index 7c151a5f..b72227c9 100644 --- a/doc/man3/SSL_CTX_set_verify.pod +++ b/doc/man3/SSL_CTX_set_verify.pod @@ -102,7 +102,7 @@ B if the client did not return a certificate, the TLS/SSL handshake is immediately terminated with a "handshake failure" alert. This flag must be used together with SSL_VERIFY_PEER. -B ignored +B ignored (see BUGS) =item SSL_VERIFY_CLIENT_ONCE @@ -112,7 +112,7 @@ renegotiation or post-authentication if a certificate was requested during the initial handshake. This flag must be used together with SSL_VERIFY_PEER. -B ignored +B ignored (see BUGS) =item SSL_VERIFY_POST_HANDSHAKE @@ -123,7 +123,7 @@ to be configured for post-handshake peer verification before the handshake occurs. This flag must be used together with SSL_VERIFY_PEER. TLSv1.3 only; no effect on pre-TLSv1.3 connections. -B ignored +B ignored (see BUGS) =back @@ -203,8 +203,8 @@ message is sent to the client. =head1 BUGS In client mode, it is not checked whether the SSL_VERIFY_PEER flag -is set, but whether any flags are set. This can lead to -unexpected behaviour if SSL_VERIFY_PEER and other flags are not used as +is set, but whether any flags other than SSL_VERIFY_NONE are set. This can +lead to unexpected behaviour if SSL_VERIFY_PEER and other flags are not used as required. =head1 RETURN VALUES diff --git a/doc/man3/SSL_SESSION_get0_hostname.pod b/doc/man3/SSL_SESSION_get0_hostname.pod index f54a21d8..5a0e7694 100644 --- a/doc/man3/SSL_SESSION_get0_hostname.pod +++ b/doc/man3/SSL_SESSION_get0_hostname.pod @@ -6,7 +6,7 @@ SSL_SESSION_get0_hostname, SSL_SESSION_set1_hostname, SSL_SESSION_get0_alpn_selected, SSL_SESSION_set1_alpn_selected -- get and set SNI and ALPN data ssociated with a session +- get and set SNI and ALPN data associated with a session =head1 SYNOPSIS diff --git a/doc/man3/SSL_get_error.pod b/doc/man3/SSL_get_error.pod index 150dd50f..8d081a5e 100644 --- a/doc/man3/SSL_get_error.pod +++ b/doc/man3/SSL_get_error.pod @@ -14,9 +14,9 @@ SSL_get_error - obtain result code for TLS/SSL I/O operation SSL_get_error() returns a result code (suitable for the C "switch" statement) for a preceding call to SSL_connect(), SSL_accept(), SSL_do_handshake(), -SSL_read_ex(), SSL_read(), SSL_peek_ex(), SSL_peek(), SSL_write_ex() or -SSL_write() on B. The value returned by that TLS/SSL I/O function must be -passed to SSL_get_error() in parameter B. +SSL_read_ex(), SSL_read(), SSL_peek_ex(), SSL_peek(), SSL_shutdown(), +SSL_write_ex() or SSL_write() on B. The value returned by that TLS/SSL I/O +function must be passed to SSL_get_error() in parameter B. In addition to B and B, SSL_get_error() inspects the current thread's OpenSSL error queue. Thus, SSL_get_error() must be diff --git a/doc/man3/SSL_write.pod b/doc/man3/SSL_write.pod index b18c215c..a1ceb202 100644 --- a/doc/man3/SSL_write.pod +++ b/doc/man3/SSL_write.pod @@ -125,7 +125,7 @@ of bytes of the file written to the TLS/SSL connection. =item E 0 The write operation was not successful, because either the connection was -closed, an error occured or action must be taken by the calling process. +closed, an error occurred or action must be taken by the calling process. Call SSL_get_error() with the return value to find out the reason. =back diff --git a/doc/man3/X509_STORE_new.pod b/doc/man3/X509_STORE_new.pod index 1ef3a71b..ccc3b060 100644 --- a/doc/man3/X509_STORE_new.pod +++ b/doc/man3/X509_STORE_new.pod @@ -23,7 +23,7 @@ X509_STORE_up_ref() increments the reference count associated with the X509_STORE object. X509_STORE_lock() locks the store from modification by other threads, -X509_STORE_unlock() locks it. +X509_STORE_unlock() unlocks it. X509_STORE_free() frees up a single X509_STORE object. diff --git a/doc/man3/X509_cmp.pod b/doc/man3/X509_cmp.pod new file mode 100644 index 00000000..3cb16b2a --- /dev/null +++ b/doc/man3/X509_cmp.pod @@ -0,0 +1,80 @@ +=pod + +=head1 NAME + +X509_cmp, X509_NAME_cmp, +X509_issuer_and_serial_cmp, X509_issuer_name_cmp, X509_subject_name_cmp, +X509_CRL_cmp, X509_CRL_match +- compare X509 certificates and related values + +=head1 SYNOPSIS + + #include + + int X509_cmp(const X509 *a, const X509 *b); + int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); + int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); + int X509_issuer_name_cmp(const X509 *a, const X509 *b); + int X509_subject_name_cmp(const X509 *a, const X509 *b); + int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); + int X509_CRL_match(const X509_CRL *a, const X509_CRL *b); + +=head1 DESCRIPTION + +This set of functions are used to compare X509 objects, including X509 +certificates, X509 CRL objects and various values in an X509 certificate. + +The X509_cmp() function compares two B objects indicated by parameters +B and B. The comparison is based on the B result of the hash +values of two B objects and the canonical (DER) encoding values. + +The X509_NAME_cmp() function compares two B objects indicated by +parameters B and B. The comparison is based on the B result of +the canonical (DER) encoding values of the two objects. L +has a more detailed description of the DER encoding of the B structure. + +The X509_issuer_and_serial_cmp() function compares the serial number and issuer +values in the given B objects B and B. + +The X509_issuer_name_cmp(), X509_subject_name_cmp() and X509_CRL_cmp() functions +are effectively wrappers of the X509_NAME_cmp() function. These functions compare +issuer names and subject names of the X<509> objects, or issuers of B +objects, respectively. + +The X509_CRL_match() function compares two B objects. Unlike the +X509_CRL_cmp() function, this function compares the whole CRL content instead +of just the issuer name. + +=head1 RETURN VALUES + +Like common memory comparison functions, the B comparison functions return +an integer less than, equal to, or greater than zero if object B is found to +be less than, to match, or be greater than object B, respectively. + +X509_NAME_cmp(), X509_issuer_and_serial_cmp(), X509_issuer_name_cmp(), +X509_subject_name_cmp() and X509_CRL_cmp() may return B<-2> to indicate an error. + +=head1 NOTES + +These functions in fact utilize the underlying B of the C library to do +the comparison job. Data to be compared varies from DER encoding data, hash +value or B. The sign of the comparison can be used to order the +objects but it does not have a special meaning in some cases. + +X509_NAME_cmp() and wrappers utilize the value B<-2> to indicate errors in some +circumstances, which could cause confusion for the applications. + +=head1 SEE ALSO + +L, L + +=head1 COPYRIGHT + +Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut diff --git a/doc/man3/X509_dup.pod b/doc/man3/X509_dup.pod index 2f51e455..526a6d68 100644 --- a/doc/man3/X509_dup.pod +++ b/doc/man3/X509_dup.pod @@ -116,20 +116,39 @@ OCSP_SIGNATURE_free, OCSP_SIGNATURE_new, OCSP_SINGLERESP_free, OCSP_SINGLERESP_new, +OSSL_CMP_ITAV_free, +OSSL_CMP_MSG_dup, +OSSL_CMP_MSG_it, +OSSL_CMP_MSG_free, +OSSL_CMP_PKIHEADER_free, +OSSL_CMP_PKIHEADER_it, +OSSL_CMP_PKIHEADER_new, +OSSL_CMP_PKISI_free, +OSSL_CMP_PKISTATUS_it, OSSL_CRMF_CERTID_free, +OSSL_CRMF_CERTID_it, OSSL_CRMF_CERTID_new, OSSL_CRMF_CERTTEMPLATE_free, +OSSL_CRMF_CERTTEMPLATE_it, OSSL_CRMF_CERTTEMPLATE_new, OSSL_CRMF_ENCRYPTEDVALUE_free, +OSSL_CRMF_ENCRYPTEDVALUE_it, OSSL_CRMF_ENCRYPTEDVALUE_new, +OSSL_CRMF_MSGS_free, +OSSL_CRMF_MSGS_it, +OSSL_CRMF_MSGS_new, OSSL_CRMF_MSG_free, +OSSL_CRMF_MSG_it, OSSL_CRMF_MSG_new, OSSL_CRMF_PBMPARAMETER_free, +OSSL_CRMF_PBMPARAMETER_it, OSSL_CRMF_PBMPARAMETER_new, OSSL_CRMF_PKIPUBLICATIONINFO_free, +OSSL_CRMF_PKIPUBLICATIONINFO_it, OSSL_CRMF_PKIPUBLICATIONINFO_new, -OSSL_CRMF_MSGS_free, -OSSL_CRMF_MSGS_new, +OSSL_CRMF_SINGLEPUBINFO_free, +OSSL_CRMF_SINGLEPUBINFO_it, +OSSL_CRMF_SINGLEPUBINFO_new, OTHERNAME_free, OTHERNAME_new, PBE2PARAM_free, diff --git a/doc/man3/X509_get0_sm2_id.pod b/doc/man3/X509_get0_sm2_id.pod index 9698c869..d8a85d7f 100644 --- a/doc/man3/X509_get0_sm2_id.pod +++ b/doc/man3/X509_get0_sm2_id.pod @@ -2,7 +2,9 @@ =head1 NAME -X509_get0_sm2_id, X509_set0_sm2_id - get or set SM2 ID for certificate operations +X509_get0_sm2_id, X509_set0_sm2_id, +X509_REQ_get0_sm2_id, X509_REQ_set0_sm2_id +- get or set SM2 ID for certificate operations =head1 SYNOPSIS @@ -10,6 +12,8 @@ X509_get0_sm2_id, X509_set0_sm2_id - get or set SM2 ID for certificate operation ASN1_OCTET_STRING *X509_get0_sm2_id(X509 *x); void X509_set0_sm2_id(X509 *x, ASN1_OCTET_STRING *sm2_id); + ASN1_OCTET_STRING *X509_REQ_get0_sm2_id(X509_REQ *x); + void X509_REQ_set0_sm2_id(X509_REQ *x, ASN1_OCTET_STRING *sm2_id); =head1 DESCRIPTION @@ -21,6 +25,10 @@ this function transfers the memory management of the value to the X509 object, and therefore the value that has been passed in should not be freed by the caller after this function has been called. +X509_REQ_get0_sm2_id() and X509_REQ_set0_sm2_id() have the same functionality +as X509_get0_sm2_id() and X509_set0_sm2_id() except that they deal with +B objects instead of B. + =head1 NOTES SM2 signature algorithm requires an ID value when generating and verifying a @@ -29,7 +37,7 @@ ability to set and retrieve the SM2 ID value. =head1 RETURN VALUES -X509_set0_sm2_id() does not return a value. +X509_set0_sm2_id() and X509_REQ_set0_sm2_id() do not return a value. =head1 SEE ALSO diff --git a/doc/man3/d2i_X509.pod b/doc/man3/d2i_X509.pod index cad78773..36a5e8f6 100644 --- a/doc/man3/d2i_X509.pod +++ b/doc/man3/d2i_X509.pod @@ -93,6 +93,16 @@ d2i_OCSP_REVOKEDINFO, d2i_OCSP_SERVICELOC, d2i_OCSP_SIGNATURE, d2i_OCSP_SINGLERESP, +d2i_OSSL_CMP_MSG, +d2i_OSSL_CMP_PKIHEADER, +d2i_OSSL_CRMF_CERTID, +d2i_OSSL_CRMF_CERTTEMPLATE, +d2i_OSSL_CRMF_ENCRYPTEDVALUE, +d2i_OSSL_CRMF_MSG, +d2i_OSSL_CRMF_MSGS, +d2i_OSSL_CRMF_PBMPARAMETER, +d2i_OSSL_CRMF_PKIPUBLICATIONINFO, +d2i_OSSL_CRMF_SINGLEPUBINFO, d2i_OTHERNAME, d2i_PBE2PARAM, d2i_PBEPARAM, @@ -269,6 +279,16 @@ i2d_OCSP_REVOKEDINFO, i2d_OCSP_SERVICELOC, i2d_OCSP_SIGNATURE, i2d_OCSP_SINGLERESP, +i2d_OSSL_CMP_MSG, +i2d_OSSL_CMP_PKIHEADER, +i2d_OSSL_CRMF_CERTID, +i2d_OSSL_CRMF_CERTTEMPLATE, +i2d_OSSL_CRMF_ENCRYPTEDVALUE, +i2d_OSSL_CRMF_MSG, +i2d_OSSL_CRMF_MSGS, +i2d_OSSL_CRMF_PBMPARAMETER, +i2d_OSSL_CRMF_PKIPUBLICATIONINFO, +i2d_OSSL_CRMF_SINGLEPUBINFO, i2d_OTHERNAME, i2d_PBE2PARAM, i2d_PBEPARAM, @@ -305,7 +325,6 @@ i2d_POLICYQUALINFO, i2d_PROFESSION_INFO, i2d_PROXY_CERT_INFO_EXTENSION, i2d_PROXY_POLICY, -i2d_PublicKey, i2d_RSAPrivateKey, i2d_RSAPrivateKey_bio, i2d_RSAPrivateKey_fp, @@ -503,8 +522,8 @@ Represents the B structure defined in PKCS#1 and PKCS#7. d2i_TYPE(), d2i_TYPE_bio() and d2i_TYPE_fp() return a valid B structure or B if an error occurs. If the "reuse" capability has been used with -a valid structure being passed in via B, then the object is not freed in -the event of error but may be in a potentially invalid or inconsistent state. +a valid structure being passed in via B, then the object is freed in +the event of error and B<*a> is set to NULL. i2d_TYPE() returns the number of bytes successfully encoded or a negative value if an error occurs. @@ -585,9 +604,13 @@ happen. =head1 BUGS In some versions of OpenSSL the "reuse" behaviour of d2i_TYPE() when -B<*px> is valid is broken and some parts of the reused structure may -persist if they are not present in the new one. As a result the use -of this "reuse" behaviour is strongly discouraged. +B<*a> is valid is broken and some parts of the reused structure may +persist if they are not present in the new one. Additionally, in versions of +OpenSSL prior to 1.1.0, when the "reuse" behaviour is used and an error occurs +the behaviour is inconsistent. Some functions behaved as described here, while +some did not free B<*a> on error and did not set B<*a> to NULL. + +As a result of the above issues the "reuse" behaviour is strongly discouraged. i2d_TYPE() will not return an error in many versions of OpenSSL, if mandatory fields are not initialized due to a programming error diff --git a/doc/man7/EVP_KDF_PBKDF2.pod b/doc/man7/EVP_KDF_PBKDF2.pod index ba322d40..c3d3f275 100644 --- a/doc/man7/EVP_KDF_PBKDF2.pod +++ b/doc/man7/EVP_KDF_PBKDF2.pod @@ -10,7 +10,7 @@ Support for computing the B password-based KDF through the B API. The EVP_KDF_PBKDF2 algorithm implements the PBKDF2 password-based key -derivation function, as described in RFC 2898; it derives a key from a password +derivation function, as described in SP800-132; it derives a key from a password using a salt and iteration count. =head2 Numeric identity @@ -30,13 +30,38 @@ The supported controls are: =item B +This control has a default value of 2048. + =item B These controls work as described in L. -B is the iteration count and its value should be greater than or equal to -1. RFC 2898 suggests an iteration count of at least 1000. The default value is -2048. Any B less than 1 is treated as a single iteration. +=item B + +This control expects one argument: C + +This control can be used to enable or disable SP800-132 compliance checks. + +Setting the mode to 0 enables the compliance checks. + +The checks performed are: + +=over 4 + +=item - the iteration count is at least 1000. + +=item - the salt length is at least 128 bits. + +=item - the derived key length is at least 112 bits. + +=back + +The default provider uses a default mode of 1 for backwards compatibility, +and the fips provider uses a default mode of 0. + +EVP_KDF_ctrl_str() type string: "pkcs5" + +The value string is expected to be a decimal number 0 or 1. =back @@ -55,7 +80,7 @@ byte sequence. =head1 CONFORMING TO -RFC 2898 +SP800-132 =head1 SEE ALSO @@ -66,9 +91,13 @@ L, L, L +=head1 HISTORY + +This functionality was added to OpenSSL 3.0.0. + =head1 COPYRIGHT -Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. +Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy diff --git a/doc/man7/EVP_KDF_SS.pod b/doc/man7/EVP_KDF_SS.pod index 3702ffe6..b3de26a4 100644 --- a/doc/man7/EVP_KDF_SS.pod +++ b/doc/man7/EVP_KDF_SS.pod @@ -11,7 +11,7 @@ SSKDF derives a key using input such as a shared secret key (that was generated during the execution of a key establishment scheme) and fixedinfo. SSKDF is also informally referred to as 'Concat KDF'. -=head2 Auxilary function +=head2 Auxiliary function The implementation uses a selectable auxiliary function H, which can be one of: diff --git a/doc/man7/EVP_KDF_SSHKDF.pod b/doc/man7/EVP_KDF_SSHKDF.pod index 9c9734e7..e233e86f 100644 --- a/doc/man7/EVP_KDF_SSHKDF.pod +++ b/doc/man7/EVP_KDF_SSHKDF.pod @@ -68,12 +68,12 @@ Sets the type for the SSHHKDF operation. There are six supported types: =over 4 -=item EVP_KDF_SSHKDF_TYPE_ININITAL_IV_CLI_TO_SRV +=item EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV The Initial IV from client to server. A single char of value 65 (ASCII char 'A'). -=item EVP_KDF_SSHKDF_TYPE_ININITAL_IV_SRV_TO_CLI +=item EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI The Initial IV from server to client A single char of value 66 (ASCII char 'B'). @@ -103,7 +103,7 @@ A single char of value 70 (ASCII char 'F'). EVP_KDF_ctrl_str() type string: "type" The value is a string of length one character. The only valid values -are the numerical values of the ASCII caracters: "A" (65) to "F" (70). +are the numerical values of the ASCII characters: "A" (65) to "F" (70). =back @@ -142,7 +142,7 @@ This example derives an 8 byte IV using SHA-256 with a 1K "key" and appropriate if (EVP_KDF_CTX_set1_sshkdf_session_id(kctx, session_id, 32) <= 0) /* Error */ if (EVP_KDF_CTX_set_sshkdf_type(kctx, - EVP_KDF_SSHKDF_TYPE_ININITAL_IV_CLI_TO_SRV) <= 0) + EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV) <= 0) /* Error */ if (EVP_KDF_derive(kctx, out, &outlen) <= 0) /* Error */ diff --git a/doc/man7/EVP_KDF_X942.pod b/doc/man7/EVP_KDF_X942.pod new file mode 100644 index 00000000..306ab2e4 --- /dev/null +++ b/doc/man7/EVP_KDF_X942.pod @@ -0,0 +1,150 @@ +=pod + +=head1 NAME + +EVP_KDF_X942 - The X9.42-2001 asn1 EVP_KDF implementation + +=head1 DESCRIPTION + +The EVP_KDF_X942 algorithm implements the key derivation function (X942KDF). +X942KDF is used by Cryptographic Message Syntax (CMS) for DH KeyAgreement, to +derive a key using input such as a shared secret key and other info. The other +info is DER encoded data that contains a 32 bit counter. + +=head2 Numeric identity + +B is the numeric identity for this implementation; it +can be used with the EVP_KDF_CTX_new_id() function. + +=head2 Supported controls + +The supported controls are: + +=over 4 + +=item B + +This control works as described in L. + +=item B + +This control expects two arguments: C, C + +The shared secret used for key derivation. This control sets the secret. + +EVP_KDF_ctrl_str() takes two type strings for this control: + +=over 4 + +=item "secret" + +The value string is used as is. + +=item "hexsecret" + +The value string is expected to be a hexadecimal number, which will be +decoded before being passed on as the control value. + +=back + +=item B + +This control expects two arguments: C, C + +An optional random string that is provided by the sender called "partyAInfo". +In CMS this is the user keying material. + +EVP_KDF_ctrl_str() takes two type strings for this control: + +=over 4 + +=item "ukm" + +The value string is used as is. + +=item "hexukm" + +The value string is expected to be a hexadecimal number, which will be +decoded before being passed on as the control value. + +=back + +=item B + +This control expects one argument: C + +The CEK wrapping algorithm name. + +EVP_KDF_ctrl_str() type string: "cekalg" + +The value string is used as is. + +=back + +=head1 NOTES + +A context for X942KDF can be obtained by calling: + +EVP_KDF_CTX *kctx = EVP_KDF_CTX_new_id(EVP_KDF_X942); + +The output length of an X942KDF is specified via the C +parameter to the L function. + +=head1 EXAMPLE + +This example derives 24 bytes, with the secret key "secret" and a random user +keying material: + + EVP_KDF_CTX *kctx; + unsigned char out[192/8]; + unsignred char ukm[64]; + + if (RAND_bytes(ukm, sizeof(ukm)) <= 0) + error("RAND_bytes"); + + kctx = EVP_KDF_CTX_new_id(EVP_KDF_X942); + if (kctx == NULL) + error("EVP_KDF_CTX_new_id"); + + if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()) <= 0) + error("EVP_KDF_CTRL_SET_MD"); + if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, "secret", (size_t)6) <= 0) + error("EVP_KDF_CTRL_SET_KEY"); + if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_UKM, ukm, sizeof(ukm)) <= 0) + error("EVP_KDF_CTRL_SET_UKM"); + if (EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_CEK_ALG, + SN_id_smime_alg_CMS3DESwrap) <= 0) + error("EVP_KDF_CTRL_SET_CEK_ALG"); + if (EVP_KDF_derive(kctx, out, sizeof(out)) <= 0) + error("EVP_KDF_derive"); + + EVP_KDF_CTX_free(kctx); + +=head1 CONFORMING TO + +RFC 2631 + +=head1 SEE ALSO + +L, +L, +L, +L, +L, +L, +L + +=head1 HISTORY + +This functionality was added to OpenSSL 3.0.0. + +=head1 COPYRIGHT + +Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut diff --git a/doc/man7/EVP_KDF_X963.pod b/doc/man7/EVP_KDF_X963.pod index 11789ae5..eaea6da2 100644 --- a/doc/man7/EVP_KDF_X963.pod +++ b/doc/man7/EVP_KDF_X963.pod @@ -71,7 +71,7 @@ decoded before being passed on as the control value. =head1 NOTES -X963KDF is very similar to the SSKDF that uses a digest as the auxilary function, +X963KDF is very similar to the SSKDF that uses a digest as the auxiliary function, X963KDF appends the counter to the secret, whereas SSKDF prepends the counter. A context for X963KDF can be obtained by calling: diff --git a/doc/man7/RAND.pod b/doc/man7/RAND.pod index 3d476669..e253e902 100644 --- a/doc/man7/RAND.pod +++ b/doc/man7/RAND.pod @@ -28,6 +28,12 @@ As a normal application developer, you do not have to worry about any details, just use L to obtain random data. Having said that, there is one important rule to obey: Always check the error return value of L and do not take randomness for granted. +Although (re-)seeding is automatic, it can fail because no trusted random source +is available or the trusted source(s) temporarily fail to provide sufficient +random seed material. +In this case the CSPRNG enters an error state and ceases to provide output, +until it is able to recover from the error by reseeding itself. +For more details on reseeding and error recovery, see L. For values that should remain secret, you can use L instead. diff --git a/doc/man7/property.pod b/doc/man7/property.pod new file mode 100644 index 00000000..5b329ee6 --- /dev/null +++ b/doc/man7/property.pod @@ -0,0 +1,172 @@ +=pod + +=head1 NAME + +property - Properties, a selection mechanism for algorithm implementations + +=head1 DESCRIPTION + +As of OpenSSL 3.0, a new method has been introduced to decide which of +multiple implementations of an algorithm will be used. +The method is centered around the concept of properties. +Each implementation defines a number of properties and when an algorithm +is being selected, filters based on these properties can be used to +choose the most appropriate implementation of the algorithm. + +Properties are like variables, they are referenced by name and have a value +assigned. + +=head2 Property Names + +Property names fall into two categories: those reserved by the OpenSSL +project and user defined names. +A I property name consists of a single C-style identifier +(except for leading underscores not being permitted), which begins +with a letter and can be followed by any number of letters, numbers +and underscores. +Property names are case-insensitive, but OpenSSL will only use lowercase +letters. + +A I property name is similar, but it B consist of +two or more C-style identifiers, separated by periods. +The last identifier in the name can be considered the 'true' property +name, which is prefixed by some sort of 'namespace'. +Providers for example could include their name in the prefix and use +property names like + + . + .. + +=head2 Properties + +A I is a I pair. +A I is a sequence of comma separated properties. +There can be any number of properties in a definition. +For example: "" defines a null property definition; "my.foo=bar" +defines a property named I which has a string value I and +"iteration.count=3" defines a property named I which +has a numeric value of I<3>. +The full syntax for property definitions appears below. + +=head2 Implementations + +Each implementation of an algorithm can define any number of +properties. +For example, the default provider defines the property I +for all of its algorithms. +Likewise, the FIPS provider defines I and the legacy provider +defines I for all of their algorithms. + +=head2 Queries + +A I is a single conditional test. +For example, "fips=yes", "default!=yes" or "?iteration.count!=3". +The first two represent mandatory clauses, such clauses B match +for any algorithm to even be under consideration. +The third clause represents an optional clause. +Matching such clauses is not a requirement, but any additional optional +match counts in favor of the algorithm. +More details about that in the B section. +A I is a sequence of comma separated property query clauses. +The full syntax for property queries appears below, but the available syntactic +features are: + +=over 4 + +=item * + +B<=> is an infix operator providing an equality test. + +=item * + +B is an infix operator providing an inequality test. + +=item * + +B is a prefix operator that means that the following clause is optional +but preferred. + +=item * + +B<-> is a prefix operator that means any global query clause involving the +following property name should be ignored. + +=item * + +B<"..."> is a quoted string. +The quotes are not included in the body of the string. + +=item * + +B<'...'> is a quoted string. +The quotes are not included in the body of the string. + +=back + +=head2 Lookups + +When an algorithm is looked up, a property query is used to determine +the best matching algorithm. +All mandatory query clauses B be present and the implementation +that additionally has the largest number of matching optional query +clauses will be used. +If there is more than one such optimal candidate, the result will be +chosen from amongst those in an indeterminate way. +Ordering of optional clauses is not significant. + +=head2 Shortcut + +In order to permit a more concise expression of boolean properties, there +is one short cut: a property name alone (e.g. "default") is +exactly equivalent to "default=yes" in both definitions and queries. + +=head2 Global and Local + +Two levels of property query are supported. +A context based property query that applies to all fetch operations and a local +property query. +Where both the context and local queries include a clause with the same name, +the local clause overrides the context clause. + +It is possible for a local property query to remove a clause in the context +property query by preceding the property name with a '-'. +For example, a context property query that contains "fips=yes" would normally +result in implementations that have "fips=yes". + +However, if the setting of the "fips" property is irrelevant to the +operations being performed, the local property query can include the +clause "-fips". +Note that the local property query could not use "fips=no" because that would +disallow any implementations with "fips=yes" rather than not caring about the +setting. + +=head1 SYNTAX + +The lexical syntax in EBNF is given by: + + Definition ::= PropertyName ( '=' Value )? + ( ',' PropertyName ( '=' Value )? )* + Query ::= PropertyQuery ( ',' PropertyQuery )* + PropertyQuery ::= '-' PropertyName + | '?'? ( PropertyName (( '=' | '!=' ) Value)?) + Value ::= NumberLiteral | StringLiteral + StringLiteral ::= QuotedString | UnquotedString + QuotedString ::= '"' [^"]* '"' | "'" [^']* "'" + UnquotedString ::= [^{space},]+ + NumberLiteral ::= '0' ( [0-7]* | 'x' [0-9A-Fa-f]+ ) | '-'? [1-9] [0-9]+ + PropertyName ::= [A-Z] [A-Z0-9_]* ( '.' [A-Z] [A-Z0-9_]* )* + +=head1 HISTORY + +Properties were added in OpenSSL 3.0 + +=head1 COPYRIGHT + +Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut diff --git a/e_os.h b/e_os.h index 1c552724..5c887d42 100644 --- a/e_os.h +++ b/e_os.h @@ -28,9 +28,6 @@ * default, we will try to read at least one of these files */ # define DEVRANDOM "/dev/urandom", "/dev/random", "/dev/hwrng", "/dev/srandom" -# ifdef __linux -# define DEVRANDOM_WAIT "/dev/random" -# endif # endif # if !defined(OPENSSL_NO_EGD) && !defined(DEVRANDOM_EGD) /* @@ -260,11 +257,7 @@ extern FILE *_imp___iob; # else /* !defined VMS */ -# ifdef OPENSSL_UNISTD -# include OPENSSL_UNISTD -# else -# include -# endif +# include # include # ifdef OPENSSL_SYS_WIN32_CYGWIN # include diff --git a/engines/build.info b/engines/build.info index 3189f9f3..77aab6d5 100644 --- a/engines/build.info +++ b/engines/build.info @@ -1,9 +1,22 @@ IF[{- !$disabled{"engine"} -}] + $PADLOCKASM= + IF[{- !$disabled{asm} -}] + $PADLOCKASM_x86=e_padlock-x86.s + $PADLOCKASM_x86_64=e_padlock-x86_64.s + + # Now that we have defined all the arch specific variables, use the + # appropriate one, and define the appropriate macros + IF[$PADLOCKASM_{- $target{asm_arch} -}] + $PADLOCKASM=$PADLOCKASM_{- $target{asm_arch} -} + $PADLOCKDEF=PADLOCK_ASM + ENDIF + ENDIF + IF[{- $disabled{"dynamic-engine"} -}] LIBS=../libcrypto IF[{- !$disabled{padlockeng} -}] - SOURCE[../libcrypto]=\ - e_padlock.c {- $target{padlock_asm_src} -} + SOURCE[../libcrypto]=e_padlock.c $PADLOCKASM + DEFINE[../libcrypto]=$PADLOCKDEF ENDIF IF[{- !$disabled{capieng} -}] SOURCE[../libcrypto]=e_capi.c @@ -17,7 +30,8 @@ IF[{- !$disabled{"engine"} -}] ELSE IF[{- !$disabled{padlockeng} -}] MODULES{engine}=padlock - SOURCE[padlock]=e_padlock.c {- $target{padlock_asm_src} -} + SOURCE[padlock]=e_padlock.c $PADLOCKASM + DEFINE[padlock]=$PADLOCKDEF DEPEND[padlock]=../libcrypto INCLUDE[padlock]=../include IF[{- defined $target{shared_defflag} -}] diff --git a/engines/e_devcrypto.c b/engines/e_devcrypto.c index b1e87096..f51b5019 100644 --- a/engines/e_devcrypto.c +++ b/engines/e_devcrypto.c @@ -25,7 +25,7 @@ /* #define ENGINE_DEVCRYPTO_DEBUG */ -#ifdef CRYPTO_ALGORITHM_MIN +#if CRYPTO_ALGORITHM_MIN < CRYPTO_ALGORITHM_MAX # define CHECK_BSD_STYLE_MACROS #endif @@ -59,7 +59,7 @@ struct driver_info_st { enum devcrypto_accelerated_t { DEVCRYPTO_NOT_ACCELERATED = -1, /* software implemented */ - DEVCRYPTO_ACCELERATION_UNKNOWN = 0, /* acceleration support unkown */ + DEVCRYPTO_ACCELERATION_UNKNOWN = 0, /* acceleration support unknown */ DEVCRYPTO_ACCELERATED = 1 /* hardware accelerated */ } accelerated; diff --git a/fuzz/asn1.c b/fuzz/asn1.c index 83a1e7ae..54cd0fcf 100644 --- a/fuzz/asn1.c +++ b/fuzz/asn1.c @@ -1,5 +1,5 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,11 +27,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include "fuzzer.h" #include "rand.inc" @@ -317,10 +319,12 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) DO_TEST(TS_STATUS_INFO, d2i_TS_STATUS_INFO, i2d_TS_STATUS_INFO, TS_STATUS_INFO_print_bio); DO_TEST(TS_TST_INFO, d2i_TS_TST_INFO, i2d_TS_TST_INFO, TS_TST_INFO_print_bio); DO_TEST_NO_PRINT(TS_ACCURACY, d2i_TS_ACCURACY, i2d_TS_ACCURACY); +#endif DO_TEST_NO_PRINT(ESS_ISSUER_SERIAL, d2i_ESS_ISSUER_SERIAL, i2d_ESS_ISSUER_SERIAL); DO_TEST_NO_PRINT(ESS_CERT_ID, d2i_ESS_CERT_ID, i2d_ESS_CERT_ID); DO_TEST_NO_PRINT(ESS_SIGNING_CERT, d2i_ESS_SIGNING_CERT, i2d_ESS_SIGNING_CERT); -#endif + DO_TEST_NO_PRINT(ESS_CERT_ID_V2, d2i_ESS_CERT_ID_V2, i2d_ESS_CERT_ID_V2); + DO_TEST_NO_PRINT(ESS_SIGNING_CERT_V2, d2i_ESS_SIGNING_CERT_V2, i2d_ESS_SIGNING_CERT_V2); #ifndef OPENSSL_NO_DH DO_TEST(DH, d2i_DHparams, i2d_DHparams, DHparams_print); DO_TEST(DH, d2i_DHxparams, i2d_DHxparams, DHparams_print); diff --git a/fuzz/oids.txt b/fuzz/oids.txt index bd38a04d..f0ff6776 100644 --- a/fuzz/oids.txt +++ b/fuzz/oids.txt @@ -1064,4 +1064,8 @@ OBJ_id_tc26_gost_3410_2012_256_paramSetD="\x2A\x85\x03\x07\x01\x02\x01\x01\x04" OBJ_hmacWithSHA512_224="\x2A\x86\x48\x86\xF7\x0D\x02\x0C" OBJ_hmacWithSHA512_256="\x2A\x86\x48\x86\xF7\x0D\x02\x0D" OBJ_gmac="\x28\xCC\x45\x03\x04" +OBJ_kmac128="\x60\x86\x48\x01\x65\x03\x04\x02\x13" +OBJ_kmac256="\x60\x86\x48\x01\x65\x03\x04\x02\x14" +OBJ_blake2bmac="\x2B\x06\x01\x04\x01\x8D\x3A\x0C\x02\x01" +OBJ_blake2smac="\x2B\x06\x01\x04\x01\x8D\x3A\x0C\x02\x02" OBJ_SM2_with_SM3="\x2A\x81\x1C\xCF\x55\x01\x83\x75" diff --git a/crypto/blake2/blake2_locl.h b/include/internal/blake2.h similarity index 68% rename from crypto/blake2/blake2_locl.h rename to include/internal/blake2.h index e8c86dbd..1c2808ba 100644 --- a/crypto/blake2/blake2_locl.h +++ b/include/internal/blake2.h @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,26 +7,26 @@ * https://www.openssl.org/source/license.html */ -/* - * Derived from the BLAKE2 reference implementation written by Samuel Neves. - * Copyright 2012, Samuel Neves - * More information about the BLAKE2 hash function and its implementations - * can be found at https://blake2.net. - */ +/* TODO(3.0) Move this header into provider when dependencies are removed */ +#ifndef HEADER_BLAKE2_H +# define HEADER_BLAKE2_H -#include +# include -#define BLAKE2S_BLOCKBYTES 64 -#define BLAKE2S_OUTBYTES 32 -#define BLAKE2S_KEYBYTES 32 -#define BLAKE2S_SALTBYTES 8 -#define BLAKE2S_PERSONALBYTES 8 +# include +# include -#define BLAKE2B_BLOCKBYTES 128 -#define BLAKE2B_OUTBYTES 64 -#define BLAKE2B_KEYBYTES 64 -#define BLAKE2B_SALTBYTES 16 -#define BLAKE2B_PERSONALBYTES 16 +# define BLAKE2S_BLOCKBYTES 64 +# define BLAKE2S_OUTBYTES 32 +# define BLAKE2S_KEYBYTES 32 +# define BLAKE2S_SALTBYTES 8 +# define BLAKE2S_PERSONALBYTES 8 + +# define BLAKE2B_BLOCKBYTES 128 +# define BLAKE2B_OUTBYTES 64 +# define BLAKE2B_KEYBYTES 64 +# define BLAKE2B_SALTBYTES 16 +# define BLAKE2B_PERSONALBYTES 16 struct blake2s_param_st { uint8_t digest_length; /* 1 */ @@ -83,10 +83,13 @@ struct blake2b_ctx_st { typedef struct blake2s_ctx_st BLAKE2S_CTX; typedef struct blake2b_ctx_st BLAKE2B_CTX; -int BLAKE2b_Init(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P); -int BLAKE2b_Init_key(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P, const void *key); -int BLAKE2b_Update(BLAKE2B_CTX *c, const void *data, size_t datalen); -int BLAKE2b_Final(unsigned char *md, BLAKE2B_CTX *c); +int blake2s256_init(void *ctx); +int blake2b512_init(void *ctx); + +int blake2b_init(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P); +int blake2b_init_key(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P, const void *key); +int blake2b_update(BLAKE2B_CTX *c, const void *data, size_t datalen); +int blake2b_final(unsigned char *md, BLAKE2B_CTX *c); /* * These setters are internal and do not check the validity of their parameters. @@ -99,13 +102,15 @@ void blake2b_param_set_key_length(BLAKE2B_PARAM *P, uint8_t keylen); void blake2b_param_set_personal(BLAKE2B_PARAM *P, const uint8_t *personal, size_t length); void blake2b_param_set_salt(BLAKE2B_PARAM *P, const uint8_t *salt, size_t length); -int BLAKE2s_Init(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P); -int BLAKE2s_Init_key(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P, const void *key); -int BLAKE2s_Update(BLAKE2S_CTX *c, const void *data, size_t datalen); -int BLAKE2s_Final(unsigned char *md, BLAKE2S_CTX *c); +int blake2s_init(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P); +int blake2s_init_key(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P, const void *key); +int blake2s_update(BLAKE2S_CTX *c, const void *data, size_t datalen); +int blake2s_final(unsigned char *md, BLAKE2S_CTX *c); void blake2s_param_init(BLAKE2S_PARAM *P); void blake2s_param_set_digest_length(BLAKE2S_PARAM *P, uint8_t outlen); void blake2s_param_set_key_length(BLAKE2S_PARAM *P, uint8_t keylen); void blake2s_param_set_personal(BLAKE2S_PARAM *P, const uint8_t *personal, size_t length); void blake2s_param_set_salt(BLAKE2S_PARAM *P, const uint8_t *salt, size_t length); + +#endif /* HEADER_BLAKE2_H */ diff --git a/include/internal/core.h b/include/internal/core.h index 64547dca..3f0cdfae 100644 --- a/include/internal/core.h +++ b/include/internal/core.h @@ -32,11 +32,13 @@ typedef struct ossl_method_construct_method_st { /* Remove a store */ void (*dealloc_tmp_store)(void *store); /* Get an already existing method from a store */ - void *(*get)(OPENSSL_CTX *libctx, void *store, const char *name, - const char *propquery, void *data); + void *(*get)(OPENSSL_CTX *libctx, void *store, + int operation_id, const char *name, const char *propquery, + void *data); /* Store a method in a store */ int (*put)(OPENSSL_CTX *libctx, void *store, void *method, - const char *name, const char *propdef, void *data); + int operation_id, const char *name, const char *propdef, + void *data); /* Construct a new method */ void *(*construct)(const char *name, const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov, void *data); diff --git a/include/internal/cryptlib.h b/include/internal/cryptlib.h index 1ce822dd..1aa1dc60 100644 --- a/include/internal/cryptlib.h +++ b/include/internal/cryptlib.h @@ -14,9 +14,10 @@ # include # ifdef OPENSSL_USE_APPLINK -# undef BIO_FLAGS_UPLINK -# define BIO_FLAGS_UPLINK 0x8000 +# define BIO_FLAGS_UPLINK_INTERNAL 0x8000 # include "ms/uplink.h" +# else +# define BIO_FLAGS_UPLINK_INTERNAL 0 # endif # include @@ -146,13 +147,20 @@ typedef struct ossl_ex_data_global_st { # define OPENSSL_CTX_PROPERTY_DEFN_INDEX 2 # define OPENSSL_CTX_PROPERTY_STRING_INDEX 3 # define OPENSSL_CTX_NAMEMAP_INDEX 4 -# define OPENSSL_CTX_MAX_INDEXES 5 +# define OPENSSL_CTX_DRBG_INDEX 5 +# define OPENSSL_CTX_DRBG_NONCE_INDEX 6 +# define OPENSSL_CTX_RAND_CRNGT_INDEX 7 +# define OPENSSL_CTX_THREAD_EVENT_HANDLER_INDEX 8 +# define OPENSSL_CTX_FIPS_PROV_INDEX 9 +# define OPENSSL_CTX_MAX_INDEXES 10 typedef struct openssl_ctx_method { void *(*new_func)(OPENSSL_CTX *ctx); void (*free_func)(void *); } OPENSSL_CTX_METHOD; +OPENSSL_CTX *openssl_ctx_get_concrete(OPENSSL_CTX *ctx); + /* Functions to retrieve pointers to data by index */ void *openssl_ctx_get_data(OPENSSL_CTX *, int /* index */, const OPENSSL_CTX_METHOD * ctx); diff --git a/include/internal/md5_sha1.h b/include/internal/md5_sha1.h new file mode 100644 index 00000000..0f1f7350 --- /dev/null +++ b/include/internal/md5_sha1.h @@ -0,0 +1,37 @@ +/* + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* TODO(3.0) Move this header into provider when dependencies are removed */ +#ifndef HEADER_MD5_SHA1_H +# define HEADER_MD5_SHA1_H + +# include + +# ifndef OPENSSL_NO_MD5 +# include +# include +# include +# include + +# define MD5_SHA1_DIGEST_LENGTH (MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH) +# define MD5_SHA1_CBLOCK MD5_CBLOCK + +typedef struct md5_sha1_st { + MD5_CTX md5; + SHA_CTX sha1; +} MD5_SHA1_CTX; + +int md5_sha1_init(MD5_SHA1_CTX *mctx); +int md5_sha1_update(MD5_SHA1_CTX *mctx, const void *data, size_t count); +int md5_sha1_final(unsigned char *md, MD5_SHA1_CTX *mctx); +int md5_sha1_ctrl(MD5_SHA1_CTX *mctx, int cmd, int mslen, void *ms); + +# endif /* OPENSSL_NO_MD5 */ + +#endif /* HEADER_MD5_SHA1_H */ diff --git a/include/internal/namemap.h b/include/internal/namemap.h index 30028182..57423801 100644 --- a/include/internal/namemap.h +++ b/include/internal/namemap.h @@ -16,6 +16,14 @@ OSSL_NAMEMAP *ossl_namemap_stored(OPENSSL_CTX *libctx); OSSL_NAMEMAP *ossl_namemap_new(void); void ossl_namemap_free(OSSL_NAMEMAP *namemap); -int ossl_namemap_add(OSSL_NAMEMAP *namemap, const char *name); -const char *ossl_namemap_name(const OSSL_NAMEMAP *namemap, int number); -int ossl_namemap_number(const OSSL_NAMEMAP *namemap, const char *name); +int ossl_namemap_add(OSSL_NAMEMAP *namemap, int number, const char *name); + +/* + * The number<->name relationship is 1<->many + * Therefore, the name->number mapping is a simple function, while the + * number->name mapping is an iterator. + */ +int ossl_namemap_name2num(const OSSL_NAMEMAP *namemap, const char *name); +void ossl_namemap_doall_names(const OSSL_NAMEMAP *namemap, int number, + void (*fn)(const char *name, void *data), + void *data); diff --git a/include/internal/property.h b/include/internal/property.h index d1432631..a916be3c 100644 --- a/include/internal/property.h +++ b/include/internal/property.h @@ -28,7 +28,7 @@ int ossl_method_store_fetch(OSSL_METHOD_STORE *store, int nid, int ossl_method_store_set_global_properties(OSSL_METHOD_STORE *store, const char *prop_query); -/* proeprty query cache functions */ +/* property query cache functions */ int ossl_method_store_cache_get(OSSL_METHOD_STORE *store, int nid, const char *prop_query, void **result); int ossl_method_store_cache_set(OSSL_METHOD_STORE *store, int nid, diff --git a/include/internal/provider.h b/include/internal/provider.h index 7b053134..493fbde0 100644 --- a/include/internal/provider.h +++ b/include/internal/provider.h @@ -29,7 +29,7 @@ extern "C" { OSSL_PROVIDER *ossl_provider_find(OPENSSL_CTX *libctx, const char *name); OSSL_PROVIDER *ossl_provider_new(OPENSSL_CTX *libctx, const char *name, OSSL_provider_init_fn *init_function); -int ossl_provider_upref(OSSL_PROVIDER *prov); +int ossl_provider_up_ref(OSSL_PROVIDER *prov); void ossl_provider_free(OSSL_PROVIDER *prov); /* Setters */ @@ -55,16 +55,15 @@ int ossl_provider_forall_loaded(OPENSSL_CTX *, void *cbdata); /* Getters for other library functions */ -const char *ossl_provider_name(OSSL_PROVIDER *prov); -const DSO *ossl_provider_dso(OSSL_PROVIDER *prov); -const char *ossl_provider_module_name(OSSL_PROVIDER *prov); -const char *ossl_provider_module_path(OSSL_PROVIDER *prov); +const char *ossl_provider_name(const OSSL_PROVIDER *prov); +const DSO *ossl_provider_dso(const OSSL_PROVIDER *prov); +const char *ossl_provider_module_name(const OSSL_PROVIDER *prov); +const char *ossl_provider_module_path(const OSSL_PROVIDER *prov); /* Thin wrappers around calls to the provider */ void ossl_provider_teardown(const OSSL_PROVIDER *prov); const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov); -int ossl_provider_get_params(const OSSL_PROVIDER *prov, - const OSSL_PARAM params[]); +int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]); const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov, int operation_id, int *no_cache); diff --git a/include/internal/sha3.h b/include/internal/sha3.h new file mode 100644 index 00000000..b07d50c6 --- /dev/null +++ b/include/internal/sha3.h @@ -0,0 +1,52 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* TODO(3.0) Move this header into provider when dependencies are removed */ +#ifndef HEADER_INTERNAL_SHA3_H +# define HEADER_INTERNAL_SHA3_H + +# include +# include + +# define KECCAK1600_WIDTH 1600 +# define SHA3_MDSIZE(bitlen) (bitlen / 8) +# define KMAC_MDSIZE(bitlen) 2 * (bitlen / 8) +# define SHA3_BLOCKSIZE(bitlen) (KECCAK1600_WIDTH - bitlen * 2) / 8 + +typedef struct keccak_st KECCAK1600_CTX; + +typedef size_t (sha3_absorb_fn)(void *vctx, const void *inp, size_t len); +typedef int (sha3_final_fn)(unsigned char *md, void *vctx); + +typedef struct prov_sha3_meth_st +{ + sha3_absorb_fn *absorb; + sha3_final_fn *final; +} PROV_SHA3_METHOD; + +struct keccak_st { + uint64_t A[5][5]; + size_t block_size; /* cached ctx->digest->block_size */ + size_t md_size; /* output length, variable in XOF */ + size_t bufsz; /* used bytes in below buffer */ + unsigned char buf[KECCAK1600_WIDTH / 8 - 32]; + unsigned char pad; + PROV_SHA3_METHOD meth; +}; + +void sha3_reset(KECCAK1600_CTX *ctx); +int sha3_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen); +int keccak_kmac_init(KECCAK1600_CTX *ctx, unsigned char pad, size_t bitlen); +int sha3_update(KECCAK1600_CTX *ctx, const void *_inp, size_t len); +int sha3_final(unsigned char *md, KECCAK1600_CTX *ctx); + +size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len, + size_t r); + +#endif /* HEADER_INTERNAL_SHA3_H */ diff --git a/crypto/include/internal/sm3.h b/include/internal/sm3.h similarity index 83% rename from crypto/include/internal/sm3.h rename to include/internal/sm3.h index cb0f28d7..2aef712e 100644 --- a/crypto/include/internal/sm3.h +++ b/include/internal/sm3.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved. * Copyright 2017 Ribose Inc. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use @@ -8,6 +8,7 @@ * https://www.openssl.org/source/license.html */ +/* TODO(3.0) Move this header into provider when dependencies are removed */ #ifndef HEADER_SM3_H # define HEADER_SM3_H @@ -34,6 +35,4 @@ int sm3_init(SM3_CTX *c); int sm3_update(SM3_CTX *c, const void *data, size_t len); int sm3_final(unsigned char *md, SM3_CTX *c); -void sm3_block_data_order(SM3_CTX *c, const void *p, size_t num); - -#endif +#endif /* HEADER_SM3_H */ diff --git a/include/internal/thread_once.h b/include/internal/thread_once.h index 033e9705..0b38ade6 100644 --- a/include/internal/thread_once.h +++ b/include/internal/thread_once.h @@ -9,6 +9,13 @@ #include +/* + * Initialisation of global data should never happen via "RUN_ONCE" inside the + * FIPS module. Global data should instead always be associated with a specific + * OPENSSL_CTX object. In this way data will get cleaned up correctly when the + * module gets unloaded. + */ +#ifndef FIPS_MODE /* * DEFINE_RUN_ONCE: Define an initialiser function that should be run exactly * once. It takes no arguments and returns and int result (1 for success or @@ -23,7 +30,7 @@ * return 0; * } */ -#define DEFINE_RUN_ONCE(init) \ +# define DEFINE_RUN_ONCE(init) \ static int init(void); \ int init##_ossl_ret_ = 0; \ void init##_ossl_(void) \ @@ -36,7 +43,7 @@ * DECLARE_RUN_ONCE: Declare an initialiser function that should be run exactly * once that has been defined in another file via DEFINE_RUN_ONCE(). */ -#define DECLARE_RUN_ONCE(init) \ +# define DECLARE_RUN_ONCE(init) \ extern int init##_ossl_ret_; \ void init##_ossl_(void); @@ -55,7 +62,7 @@ * return 0; * } */ -#define DEFINE_RUN_ONCE_STATIC(init) \ +# define DEFINE_RUN_ONCE_STATIC(init) \ static int init(void); \ static int init##_ossl_ret_ = 0; \ static void init##_ossl_(void) \ @@ -72,9 +79,9 @@ * function defined via DEFINE_ONCE_STATIC where both functions use the same * CRYPTO_ONCE object to synchronise. Where an alternative initialiser function * is used only one of the primary or the alternative initialiser function will - * ever be called - and that function will be called exactly once. Definitition + * ever be called - and that function will be called exactly once. Definition * of an alternative initialiser function MUST occur AFTER the definition of the - * primiary initialiser function. + * primary initialiser function. * * Typical usage might be: * @@ -96,7 +103,7 @@ * return 0; * } */ -#define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init) \ +# define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init) \ static int initalt(void); \ static void initalt##_ossl_(void) \ { \ @@ -115,7 +122,7 @@ * * (*) by convention, since the init function must return 1 on success. */ -#define RUN_ONCE(once, init) \ +# define RUN_ONCE(once, init) \ (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0) /* @@ -133,5 +140,7 @@ * * (*) by convention, since the init function must return 1 on success. */ -#define RUN_ONCE_ALT(once, initalt, init) \ +# define RUN_ONCE_ALT(once, initalt, init) \ (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0) + +#endif /* FIPS_MODE */ diff --git a/include/internal/tsan_assist.h b/include/internal/tsan_assist.h index 0fd2f3e8..f8285b1d 100644 --- a/include/internal/tsan_assist.h +++ b/include/internal/tsan_assist.h @@ -18,7 +18,7 @@ * if (var == NOT_YET_INITIALIZED) * var = function_returning_same_value(); * - * This does work provided that loads and stores are single-instuction + * This does work provided that loads and stores are single-instruction * operations (and integer ones are on *all* supported platforms), but * it upsets Thread Sanitizer. Suggested solution is * diff --git a/include/openssl/asn1.h b/include/openssl/asn1.h index 3790c6b9..3268db17 100644 --- a/include/openssl/asn1.h +++ b/include/openssl/asn1.h @@ -310,23 +310,6 @@ TYPEDEF_D2I2D_OF(void); * */ -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* ASN1_ITEM pointer exported type */ -typedef const ASN1_ITEM ASN1_ITEM_EXP; - -/* Macro to obtain ASN1_ITEM pointer from exported type */ -# define ASN1_ITEM_ptr(iptr) (iptr) - -/* Macro to include ASN1_ITEM pointer from base type */ -# define ASN1_ITEM_ref(iptr) (&(iptr##_it)) - -# define ASN1_ITEM_rptr(ref) (&(ref##_it)) - -# define DECLARE_ASN1_ITEM(name) \ - OPENSSL_EXTERN const ASN1_ITEM name##_it; - -# else /* * Platforms that can't easily handle shared global variables are declared as @@ -337,18 +320,16 @@ typedef const ASN1_ITEM ASN1_ITEM_EXP; typedef const ASN1_ITEM *ASN1_ITEM_EXP (void); /* Macro to obtain ASN1_ITEM pointer from exported type */ -# define ASN1_ITEM_ptr(iptr) (iptr()) +# define ASN1_ITEM_ptr(iptr) (iptr()) /* Macro to include ASN1_ITEM pointer from base type */ -# define ASN1_ITEM_ref(iptr) (iptr##_it) +# define ASN1_ITEM_ref(iptr) (iptr##_it) -# define ASN1_ITEM_rptr(ref) (ref##_it()) +# define ASN1_ITEM_rptr(ref) (ref##_it()) -# define DECLARE_ASN1_ITEM(name) \ +# define DECLARE_ASN1_ITEM(name) \ const ASN1_ITEM * name##_it(void); -# endif - /* Parameters used by ASN1_STRING_print_ex() */ /* diff --git a/include/openssl/asn1t.h b/include/openssl/asn1t.h index 8158c41f..568b347c 100644 --- a/include/openssl/asn1t.h +++ b/include/openssl/asn1t.h @@ -25,44 +25,24 @@ extern "C" { #endif -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - /* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ -# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr)) +# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)())) /* Macros for start and end of ASN1_ITEM definition */ -# define ASN1_ITEM_start(itname) \ - const ASN1_ITEM itname##_it = { - -# define static_ASN1_ITEM_start(itname) \ - static const ASN1_ITEM itname##_it = { - -# define ASN1_ITEM_end(itname) \ - }; - -# else - -/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ -# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)())) - -/* Macros for start and end of ASN1_ITEM definition */ - -# define ASN1_ITEM_start(itname) \ +# define ASN1_ITEM_start(itname) \ const ASN1_ITEM * itname##_it(void) \ { \ static const ASN1_ITEM local_it = { -# define static_ASN1_ITEM_start(itname) \ +# define static_ASN1_ITEM_start(itname) \ static ASN1_ITEM_start(itname) -# define ASN1_ITEM_end(itname) \ +# define ASN1_ITEM_end(itname) \ }; \ return &local_it; \ } -# endif - /* Macros to aid ASN1 template writing */ # define ASN1_ITEM_TEMPLATE(tname) \ @@ -335,13 +315,9 @@ extern "C" { /* Any defined by macros: the field used is in the table itself */ -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION -# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } -# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } -# else -# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } -# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } -# endif +# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } +# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } + /* Plain simple type */ # define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) /* Embedded simple type */ @@ -421,23 +397,7 @@ extern "C" { # define ASN1_ADB(name) \ static const ASN1_ADB_TABLE name##_adbtbl[] -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ - ;\ - static const ASN1_ADB name##_adb = {\ - flags,\ - offsetof(name, field),\ - adb_cb,\ - name##_adbtbl,\ - sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ - def,\ - none\ - } - -# else - -# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ +# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ ;\ static const ASN1_ITEM *name##_adb(void) \ { \ @@ -455,8 +415,6 @@ extern "C" { } \ void dummy_function(void) -# endif - # define ADB_ENTRY(val, template) {val, template} # define ASN1_ADB_TEMPLATE(name) \ diff --git a/include/openssl/bio.h b/include/openssl/bio.h index 66e0b96b..17b2c0e2 100644 --- a/include/openssl/bio.h +++ b/include/openssl/bio.h @@ -20,10 +20,6 @@ # include # include -# ifndef OPENSSL_NO_SCTP -# include -# endif - #ifdef __cplusplus extern "C" { #endif @@ -178,12 +174,9 @@ extern "C" { # define BIO_FLAGS_IO_SPECIAL 0x04 # define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) # define BIO_FLAGS_SHOULD_RETRY 0x08 -# ifndef BIO_FLAGS_UPLINK -/* - * "UPLINK" flag denotes file descriptors provided by application. It - * defaults to 0, as most platforms don't require UPLINK interface. - */ -# define BIO_FLAGS_UPLINK 0 +# if !OPENSSL_API_3 +/* This #define was replaced by an internal constant and should not be used. */ +# define BIO_FLAGS_UPLINK 0 # endif # define BIO_FLAGS_BASE64_NO_NL 0x100 diff --git a/include/openssl/bn.h b/include/openssl/bn.h index 57d2ddd1..5c645d58 100644 --- a/include/openssl/bn.h +++ b/include/openssl/bn.h @@ -198,15 +198,21 @@ void BN_zero_ex(BIGNUM *a); const BIGNUM *BN_value_one(void); char *BN_options(void); +BN_CTX *BN_CTX_new_ex(OPENSSL_CTX *ctx); BN_CTX *BN_CTX_new(void); +BN_CTX *BN_CTX_secure_new_ex(OPENSSL_CTX *ctx); BN_CTX *BN_CTX_secure_new(void); void BN_CTX_free(BN_CTX *c); void BN_CTX_start(BN_CTX *ctx); BIGNUM *BN_CTX_get(BN_CTX *ctx); void BN_CTX_end(BN_CTX *ctx); +int BN_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, BN_CTX *ctx); int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); +int BN_priv_rand_ex(BIGNUM *rnd, int bits, int top, int bottom, BN_CTX *ctx); int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom); +int BN_rand_range_ex(BIGNUM *r, const BIGNUM *range, BN_CTX *ctx); int BN_rand_range(BIGNUM *rnd, const BIGNUM *range); +int BN_priv_rand_range_ex(BIGNUM *r, const BIGNUM *range, BN_CTX *ctx); int BN_priv_rand_range(BIGNUM *rnd, const BIGNUM *range); int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range); diff --git a/include/openssl/bnerr.h b/include/openssl/bnerr.h index bcf4f8f2..ebbcd9a2 100644 --- a/include/openssl/bnerr.h +++ b/include/openssl/bnerr.h @@ -35,6 +35,7 @@ int ERR_load_BN_strings(void); # define BN_F_BN_COMPUTE_WNAF 142 # define BN_F_BN_CTX_GET 116 # define BN_F_BN_CTX_NEW 106 +# define BN_F_BN_CTX_NEW_EX 151 # define BN_F_BN_CTX_START 129 # define BN_F_BN_DIV 107 # define BN_F_BN_DIV_RECP 130 @@ -92,6 +93,7 @@ int ERR_load_BN_strings(void); # define BN_R_NOT_INITIALIZED 107 # define BN_R_NO_INVERSE 108 # define BN_R_NO_SOLUTION 116 +# define BN_R_NO_SUITABLE_DIGEST 120 # define BN_R_PRIVATE_KEY_TOO_LARGE 117 # define BN_R_P_IS_NOT_PRIME 112 # define BN_R_TOO_MANY_ITERATIONS 113 diff --git a/include/openssl/cmp.h b/include/openssl/cmp.h new file mode 100644 index 00000000..3d9c3d4d --- /dev/null +++ b/include/openssl/cmp.h @@ -0,0 +1,243 @@ +/*- + * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2019 + * Copyright Siemens AG 2015-2019 + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + * + * CMP (RFC 4210) implementation by M. Peylo, M. Viljanen, and D. von Oheimb. + */ + +#ifndef OSSL_HEADER_CMP_H +# define OSSL_HEADER_CMP_H + +# include +# ifndef OPENSSL_NO_CMP + +# include +# include + +/* explicit #includes not strictly needed since implied by the above: */ +# include +# include +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# define OSSL_CMP_PVNO 2 + +/*- + * PKIFailureInfo ::= BIT STRING { + * -- since we can fail in more than one way! + * -- More codes may be added in the future if/when required. + * badAlg (0), + * -- unrecognized or unsupported Algorithm Identifier + * badMessageCheck (1), + * -- integrity check failed (e.g., signature did not verify) + * badRequest (2), + * -- transaction not permitted or supported + * badTime (3), + * -- messageTime was not sufficiently close to the system time, + * -- as defined by local policy + * badCertId (4), + * -- no certificate could be found matching the provided criteria + * badDataFormat (5), + * -- the data submitted has the wrong format + * wrongAuthority (6), + * -- the authority indicated in the request is different from the + * -- one creating the response token + * incorrectData (7), + * -- the requester's data is incorrect (for notary services) + * missingTimeStamp (8), + * -- when the timestamp is missing but should be there + * -- (by policy) + * badPOP (9), + * -- the proof-of-possession failed + * certRevoked (10), + * -- the certificate has already been revoked + * certConfirmed (11), + * -- the certificate has already been confirmed + * wrongIntegrity (12), + * -- invalid integrity, password based instead of signature or + * -- vice versa + * badRecipientNonce (13), + * -- invalid recipient nonce, either missing or wrong value + * timeNotAvailable (14), + * -- the TSA's time source is not available + * unacceptedPolicy (15), + * -- the requested TSA policy is not supported by the TSA. + * unacceptedExtension (16), + * -- the requested extension is not supported by the TSA. + * addInfoNotAvailable (17), + * -- the additional information requested could not be + * -- understood or is not available + * badSenderNonce (18), + * -- invalid sender nonce, either missing or wrong size + * badCertTemplate (19), + * -- invalid cert. template or missing mandatory information + * signerNotTrusted (20), + * -- signer of the message unknown or not trusted + * transactionIdInUse (21), + * -- the transaction identifier is already in use + * unsupportedVersion (22), + * -- the version of the message is not supported + * notAuthorized (23), + * -- the sender was not authorized to make the preceding + * -- request or perform the preceding action + * systemUnavail (24), + * -- the request cannot be handled due to system unavailability + * systemFailure (25), + * -- the request cannot be handled due to system failure + * duplicateCertReq (26) + * -- certificate cannot be issued because a duplicate + * -- certificate already exists + * } + */ +# define OSSL_CMP_PKIFAILUREINFO_badAlg 0 +# define OSSL_CMP_PKIFAILUREINFO_badMessageCheck 1 +# define OSSL_CMP_PKIFAILUREINFO_badRequest 2 +# define OSSL_CMP_PKIFAILUREINFO_badTime 3 +# define OSSL_CMP_PKIFAILUREINFO_badCertId 4 +# define OSSL_CMP_PKIFAILUREINFO_badDataFormat 5 +# define OSSL_CMP_PKIFAILUREINFO_wrongAuthority 6 +# define OSSL_CMP_PKIFAILUREINFO_incorrectData 7 +# define OSSL_CMP_PKIFAILUREINFO_missingTimeStamp 8 +# define OSSL_CMP_PKIFAILUREINFO_badPOP 9 +# define OSSL_CMP_PKIFAILUREINFO_certRevoked 10 +# define OSSL_CMP_PKIFAILUREINFO_certConfirmed 11 +# define OSSL_CMP_PKIFAILUREINFO_wrongIntegrity 12 +# define OSSL_CMP_PKIFAILUREINFO_badRecipientNonce 13 +# define OSSL_CMP_PKIFAILUREINFO_timeNotAvailable 14 +# define OSSL_CMP_PKIFAILUREINFO_unacceptedPolicy 15 +# define OSSL_CMP_PKIFAILUREINFO_unacceptedExtension 16 +# define OSSL_CMP_PKIFAILUREINFO_addInfoNotAvailable 17 +# define OSSL_CMP_PKIFAILUREINFO_badSenderNonce 18 +# define OSSL_CMP_PKIFAILUREINFO_badCertTemplate 19 +# define OSSL_CMP_PKIFAILUREINFO_signerNotTrusted 20 +# define OSSL_CMP_PKIFAILUREINFO_transactionIdInUse 21 +# define OSSL_CMP_PKIFAILUREINFO_unsupportedVersion 22 +# define OSSL_CMP_PKIFAILUREINFO_notAuthorized 23 +# define OSSL_CMP_PKIFAILUREINFO_systemUnavail 24 +# define OSSL_CMP_PKIFAILUREINFO_systemFailure 25 +# define OSSL_CMP_PKIFAILUREINFO_duplicateCertReq 26 +# define OSSL_CMP_PKIFAILUREINFO_MAX 26 +# define OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN \ + ( (1<<(OSSL_CMP_PKIFAILUREINFO_MAX+1)) - 1) +# if OSSL_CMP_PKIFAILUREINFO_MAX_BIT_PATTERN > INT_MAX +# error CMP_PKIFAILUREINFO_MAX bit pattern does not fit in type int +# endif + +typedef ASN1_BIT_STRING OSSL_CMP_PKIFAILUREINFO; + +# define OSSL_CMP_CTX_FAILINFO_badAlg (1 << 0) +# define OSSL_CMP_CTX_FAILINFO_badMessageCheck (1 << 1) +# define OSSL_CMP_CTX_FAILINFO_badRequest (1 << 2) +# define OSSL_CMP_CTX_FAILINFO_badTime (1 << 3) +# define OSSL_CMP_CTX_FAILINFO_badCertId (1 << 4) +# define OSSL_CMP_CTX_FAILINFO_badDataFormat (1 << 5) +# define OSSL_CMP_CTX_FAILINFO_wrongAuthority (1 << 6) +# define OSSL_CMP_CTX_FAILINFO_incorrectData (1 << 7) +# define OSSL_CMP_CTX_FAILINFO_missingTimeStamp (1 << 8) +# define OSSL_CMP_CTX_FAILINFO_badPOP (1 << 9) +# define OSSL_CMP_CTX_FAILINFO_certRevoked (1 << 10) +# define OSSL_CMP_CTX_FAILINFO_certConfirmed (1 << 11) +# define OSSL_CMP_CTX_FAILINFO_wrongIntegrity (1 << 12) +# define OSSL_CMP_CTX_FAILINFO_badRecipientNonce (1 << 13) +# define OSSL_CMP_CTX_FAILINFO_timeNotAvailable (1 << 14) +# define OSSL_CMP_CTX_FAILINFO_unacceptedPolicy (1 << 15) +# define OSSL_CMP_CTX_FAILINFO_unacceptedExtension (1 << 16) +# define OSSL_CMP_CTX_FAILINFO_addInfoNotAvailable (1 << 17) +# define OSSL_CMP_CTX_FAILINFO_badSenderNonce (1 << 18) +# define OSSL_CMP_CTX_FAILINFO_badCertTemplate (1 << 19) +# define OSSL_CMP_CTX_FAILINFO_signerNotTrusted (1 << 20) +# define OSSL_CMP_CTX_FAILINFO_transactionIdInUse (1 << 21) +# define OSSL_CMP_CTX_FAILINFO_unsupportedVersion (1 << 22) +# define OSSL_CMP_CTX_FAILINFO_notAuthorized (1 << 23) +# define OSSL_CMP_CTX_FAILINFO_systemUnavail (1 << 24) +# define OSSL_CMP_CTX_FAILINFO_systemFailure (1 << 25) +# define OSSL_CMP_CTX_FAILINFO_duplicateCertReq (1 << 26) + +/*- + * PKIStatus ::= INTEGER { + * accepted (0), + * -- you got exactly what you asked for + * grantedWithMods (1), + * -- you got something like what you asked for; the + * -- requester is responsible for ascertaining the differences + * rejection (2), + * -- you don't get it, more information elsewhere in the message + * waiting (3), + * -- the request body part has not yet been processed; expect to + * -- hear more later (note: proper handling of this status + * -- response MAY use the polling req/rep PKIMessages specified + * -- in Section 5.3.22; alternatively, polling in the underlying + * -- transport layer MAY have some utility in this regard) + * revocationWarning (4), + * -- this message contains a warning that a revocation is + * -- imminent + * revocationNotification (5), + * -- notification that a revocation has occurred + * keyUpdateWarning (6) + * -- update already done for the oldCertId specified in + * -- CertReqMsg + * } + */ +# define OSSL_CMP_PKISTATUS_accepted 0 +# define OSSL_CMP_PKISTATUS_grantedWithMods 1 +# define OSSL_CMP_PKISTATUS_rejection 2 +# define OSSL_CMP_PKISTATUS_waiting 3 +# define OSSL_CMP_PKISTATUS_revocationWarning 4 +# define OSSL_CMP_PKISTATUS_revocationNotification 5 +# define OSSL_CMP_PKISTATUS_keyUpdateWarning 6 + +typedef ASN1_INTEGER OSSL_CMP_PKISTATUS; +DECLARE_ASN1_ITEM(OSSL_CMP_PKISTATUS) + +# define OSSL_CMP_CERTORENCCERT_CERTIFICATE 0 +# define OSSL_CMP_CERTORENCCERT_ENCRYPTEDCERT 1 + +/* data type declarations */ +typedef struct OSSL_cmp_ctx_st OSSL_CMP_CTX; +typedef struct OSSL_cmp_pkiheader_st OSSL_CMP_PKIHEADER; +DECLARE_ASN1_FUNCTIONS(OSSL_CMP_PKIHEADER) +typedef struct OSSL_cmp_msg_st OSSL_CMP_MSG; +DECLARE_ASN1_ENCODE_FUNCTIONS(OSSL_CMP_MSG, OSSL_CMP_MSG, OSSL_CMP_MSG) +typedef struct OSSL_cmp_certstatus_st OSSL_CMP_CERTSTATUS; +DEFINE_STACK_OF(OSSL_CMP_CERTSTATUS) +typedef struct OSSL_cmp_itav_st OSSL_CMP_ITAV; +DEFINE_STACK_OF(OSSL_CMP_ITAV) +typedef struct OSSL_cmp_revrepcontent_st OSSL_CMP_REVREPCONTENT; +typedef struct OSSL_cmp_pkisi_st OSSL_CMP_PKISI; +DEFINE_STACK_OF(OSSL_CMP_PKISI) +typedef struct OSSL_cmp_certrepmessage_st OSSL_CMP_CERTREPMESSAGE; +DEFINE_STACK_OF(OSSL_CMP_CERTREPMESSAGE) +typedef struct OSSL_cmp_pollrep_st OSSL_CMP_POLLREP; +typedef STACK_OF(OSSL_CMP_POLLREP) OSSL_CMP_POLLREPCONTENT; +typedef struct OSSL_cmp_certresponse_st OSSL_CMP_CERTRESPONSE; +DEFINE_STACK_OF(OSSL_CMP_CERTRESPONSE) +typedef STACK_OF(ASN1_UTF8STRING) OSSL_CMP_PKIFREETEXT; + +/* from cmp_asn.c */ +OSSL_CMP_ITAV *OSSL_CMP_ITAV_create(ASN1_OBJECT *type, ASN1_TYPE *value); +void OSSL_CMP_ITAV_set0(OSSL_CMP_ITAV *itav, ASN1_OBJECT *type, + ASN1_TYPE *value); +ASN1_OBJECT *OSSL_CMP_ITAV_get0_type(const OSSL_CMP_ITAV *itav); +ASN1_TYPE *OSSL_CMP_ITAV_get0_value(const OSSL_CMP_ITAV *itav); +int OSSL_CMP_ITAV_push0_stack_item(STACK_OF(OSSL_CMP_ITAV) **itav_sk_p, + OSSL_CMP_ITAV *itav); +void OSSL_CMP_ITAV_free(OSSL_CMP_ITAV *itav); +void OSSL_CMP_MSG_free(OSSL_CMP_MSG *msg); +void OSSL_CMP_PKISI_free(OSSL_CMP_PKISI *si); +DECLARE_ASN1_DUP_FUNCTION(OSSL_CMP_MSG) + +# ifdef __cplusplus +} +# endif +# endif /* !defined OPENSSL_NO_CMP */ +#endif /* !defined OSSL_HEADER_CMP_H */ diff --git a/include/openssl/cmperr.h b/include/openssl/cmperr.h new file mode 100644 index 00000000..7c1402cb --- /dev/null +++ b/include/openssl/cmperr.h @@ -0,0 +1,32 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef HEADER_CMPERR_H +# define HEADER_CMPERR_H + +# include + +# ifndef OPENSSL_NO_CMP + +# ifdef __cplusplus +extern "C" +# endif +int ERR_load_CMP_strings(void); + +/* + * CMP function codes. + */ + +/* + * CMP reason codes. + */ + +# endif +#endif diff --git a/include/openssl/cmserr.h b/include/openssl/cmserr.h index 1919a888..eba163ac 100644 --- a/include/openssl/cmserr.h +++ b/include/openssl/cmserr.h @@ -107,6 +107,7 @@ int ERR_load_CMS_strings(void); # define CMS_F_CMS_SIGNERINFO_VERIFY_CERT 153 # define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT 154 # define CMS_F_CMS_SIGN_RECEIPT 163 +# define CMS_F_CMS_SI_CHECK_ATTRIBUTES 183 # define CMS_F_CMS_STREAM 155 # define CMS_F_CMS_UNCOMPRESS 156 # define CMS_F_CMS_VERIFY 157 @@ -116,6 +117,7 @@ int ERR_load_CMS_strings(void); * CMS reason codes. */ # define CMS_R_ADD_SIGNER_ERROR 99 +# define CMS_R_ATTRIBUTE_ERROR 161 # define CMS_R_CERTIFICATE_ALREADY_PRESENT 175 # define CMS_R_CERTIFICATE_HAS_NO_KEYID 160 # define CMS_R_CERTIFICATE_VERIFY_ERROR 100 diff --git a/include/openssl/core.h b/include/openssl/core.h index cf4d3f41..848b7143 100644 --- a/include/openssl/core.h +++ b/include/openssl/core.h @@ -77,7 +77,7 @@ struct ossl_param_st { unsigned int data_type; /* declare what kind of content is in buffer */ void *data; /* value being passed in or out */ size_t data_size; /* data size */ - size_t *return_size; /* OPTIONAL: address to content size */ + size_t return_size; /* returned content size */ }; /* Currently supported OSSL_PARAM data types */ @@ -143,6 +143,19 @@ struct ossl_param_st { */ # define OSSL_PARAM_OCTET_PTR 7 +/* + * Typedef for the thread stop handling callback. Used both internally and by + * providers. + * + * Providers may register for notifications about threads stopping by + * registering a callback to hear about such events. Providers register the + * callback using the OSSL_FUNC_CORE_THREAD_START function in the |in| dispatch + * table passed to OSSL_provider_init(). The arg passed back to a provider will + * be the provider side context object. + */ +typedef void (*OSSL_thread_stop_handler_fn)(void *arg); + + /*- * Provider entry point * -------------------- diff --git a/include/openssl/core_names.h b/include/openssl/core_names.h index 35a23d74..e4dd7330 100644 --- a/include/openssl/core_names.h +++ b/include/openssl/core_names.h @@ -39,6 +39,18 @@ extern "C" { #define OSSL_CIPHER_PARAM_PADDING "padding" #define OSSL_CIPHER_PARAM_MODE "mode" +#define OSSL_CIPHER_PARAM_BLOCK_SIZE "blocksize" /* OSSL_PARAM_INTEGER */ +#define OSSL_CIPHER_PARAM_FLAGS "flags" /* OSSL_PARAM_UNSIGNED_INTEGER */ +#define OSSL_CIPHER_PARAM_KEYLEN "keylen" /* OSSL_PARAM_INTEGER */ +#define OSSL_CIPHER_PARAM_IVLEN "ivlen" /* OSSL_PARAM_INTEGER */ +#define OSSL_CIPHER_PARAM_IV "iv" /* OSSL_PARAM_OCTET_PTR */ +#define OSSL_CIPHER_PARAM_NUM "num" /* OSSL_PARAM_INTEGER */ + +/* digest parameters */ +#define OSSL_DIGEST_PARAM_XOFLEN "xoflen" +#define OSSL_DIGEST_PARAM_SSL3_MS "ssl3-ms" +#define OSSL_DIGEST_PARAM_PAD_TYPE "pad_type" +#define OSSL_DIGEST_PARAM_MICALG "micalg" # ifdef __cplusplus } diff --git a/include/openssl/core_numbers.h b/include/openssl/core_numbers.h index 8d026f4a..05427327 100644 --- a/include/openssl/core_numbers.h +++ b/include/openssl/core_numbers.h @@ -35,7 +35,12 @@ extern "C" { * - a function pointer extractor function with the name OSSL_'foo' */ -/* Helper macro to create the function signature typedef and the extractor */ +/* + * Helper macro to create the function signature typedef and the extractor + * |type| is the return-type of the function, |name| is the name of the + * function to fetch, and |args| is a parenthesized list of parameters + * for the function (that is, it is |name|'s function signature). + */ #define OSSL_CORE_MAKE_FUNC(type,name,args) \ typedef type (OSSL_##name##_fn)args; \ static ossl_inline \ @@ -57,14 +62,72 @@ OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *, core_get_param_types,(const OSSL_PROVIDER *prov)) # define OSSL_FUNC_CORE_GET_PARAMS 2 OSSL_CORE_MAKE_FUNC(int,core_get_params,(const OSSL_PROVIDER *prov, - const OSSL_PARAM params[])) -# define OSSL_FUNC_CORE_PUT_ERROR 3 -OSSL_CORE_MAKE_FUNC(void,core_put_error,(int lib, int func, int reason, - const char *file, int line)) -# define OSSL_FUNC_CORE_ADD_ERROR_VDATA 4 -OSSL_CORE_MAKE_FUNC(void,core_add_error_vdata,(int num, va_list args)) + OSSL_PARAM params[])) +# define OSSL_FUNC_CORE_THREAD_START 3 +OSSL_CORE_MAKE_FUNC(int,core_thread_start,(const OSSL_PROVIDER *prov, + OSSL_thread_stop_handler_fn handfn)) +# define OSSL_FUNC_CORE_PUT_ERROR 4 +OSSL_CORE_MAKE_FUNC(void,core_put_error, + (const OSSL_PROVIDER *prov, + uint32_t reason, const char *file, int line)) +# define OSSL_FUNC_CORE_ADD_ERROR_VDATA 5 +OSSL_CORE_MAKE_FUNC(void,core_add_error_vdata,(const OSSL_PROVIDER *prov, + int num, va_list args)) +# define OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT 6 +OSSL_CORE_MAKE_FUNC(OPENSSL_CTX *,core_get_library_context, + (const OSSL_PROVIDER *prov)) +/* Memory allocation, freeing, clearing. */ +#define OSSL_FUNC_CRYPTO_MALLOC 10 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_malloc, (size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_ZALLOC 11 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_zalloc, (size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_MEMDUP 12 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_memdup, (const void *str, size_t siz, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_STRDUP 13 +OSSL_CORE_MAKE_FUNC(char *, + CRYPTO_strdup, (const char *str, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_STRNDUP 14 +OSSL_CORE_MAKE_FUNC(char *, + CRYPTO_strndup, (const char *str, size_t s, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_FREE 15 +OSSL_CORE_MAKE_FUNC(void, + CRYPTO_free, (void *ptr, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_CLEAR_FREE 16 +OSSL_CORE_MAKE_FUNC(void, + CRYPTO_clear_free, (void *ptr, size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_REALLOC 17 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_realloc, (void *addr, size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_CLEAR_REALLOC 18 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_clear_realloc, (void *addr, size_t old_num, size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_SECURE_MALLOC 19 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_secure_malloc, (size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_SECURE_ZALLOC 20 +OSSL_CORE_MAKE_FUNC(void *, + CRYPTO_secure_zalloc, (size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_SECURE_FREE 21 +OSSL_CORE_MAKE_FUNC(void, + CRYPTO_secure_free, (void *ptr, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE 22 +OSSL_CORE_MAKE_FUNC(void, + CRYPTO_secure_clear_free, (void *ptr, size_t num, const char *file, int line)) +#define OSSL_FUNC_CRYPTO_SECURE_ALLOCATED 23 +OSSL_CORE_MAKE_FUNC(int, + CRYPTO_secure_allocated, (const void *ptr)) +#define OSSL_FUNC_OPENSSL_CLEANSE 24 +OSSL_CORE_MAKE_FUNC(void, + OPENSSL_cleanse, (void *ptr, size_t len)) +# define OSSL_FUNC_OPENSSL_HEXSTR2BUF 25 +OSSL_CORE_MAKE_FUNC(unsigned char *, + OPENSSL_hexstr2buf, (const char *str, long *len)) + /* Functions provided by the provider to the Core, reserved numbers 1024-1535 */ # define OSSL_FUNC_PROVIDER_TEARDOWN 1024 OSSL_CORE_MAKE_FUNC(void,provider_teardown,(void *provctx)) @@ -73,10 +136,13 @@ OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *, provider_get_param_types,(void *provctx)) # define OSSL_FUNC_PROVIDER_GET_PARAMS 1026 OSSL_CORE_MAKE_FUNC(int,provider_get_params,(void *provctx, - const OSSL_PARAM params[])) + OSSL_PARAM params[])) # define OSSL_FUNC_PROVIDER_QUERY_OPERATION 1027 OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation, (void *provctx, int operation_id, const int *no_store)) +# define OSSL_FUNC_PROVIDER_GET_REASON_STRINGS 1028 +OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *,provider_get_reason_strings, + (void *provctx)) /* Digests */ @@ -91,7 +157,8 @@ OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation, # define OSSL_FUNC_DIGEST_DUPCTX 7 # define OSSL_FUNC_DIGEST_SIZE 8 # define OSSL_FUNC_DIGEST_BLOCK_SIZE 9 - +# define OSSL_FUNC_DIGEST_SET_PARAMS 10 +# define OSSL_FUNC_DIGEST_GET_PARAMS 11 OSSL_CORE_MAKE_FUNC(void *, OP_digest_newctx, (void *provctx)) OSSL_CORE_MAKE_FUNC(int, OP_digest_init, (void *dctx)) @@ -107,9 +174,13 @@ OSSL_CORE_MAKE_FUNC(int, OP_digest_digest, OSSL_CORE_MAKE_FUNC(void, OP_digest_cleanctx, (void *dctx)) OSSL_CORE_MAKE_FUNC(void, OP_digest_freectx, (void *dctx)) OSSL_CORE_MAKE_FUNC(void *, OP_digest_dupctx, (void *dctx)) + OSSL_CORE_MAKE_FUNC(size_t, OP_digest_size, (void)) OSSL_CORE_MAKE_FUNC(size_t, OP_digest_block_size, (void)) - +OSSL_CORE_MAKE_FUNC(int, OP_digest_set_params, + (void *vctx, const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, OP_digest_get_params, + (void *vctx, OSSL_PARAM params[])) /* Symmetric Ciphers */ @@ -123,12 +194,9 @@ OSSL_CORE_MAKE_FUNC(size_t, OP_digest_block_size, (void)) # define OSSL_FUNC_CIPHER_CIPHER 6 # define OSSL_FUNC_CIPHER_FREECTX 7 # define OSSL_FUNC_CIPHER_DUPCTX 8 -# define OSSL_FUNC_CIPHER_KEY_LENGTH 9 -# define OSSL_FUNC_CIPHER_IV_LENGTH 10 -# define OSSL_FUNC_CIPHER_BLOCK_SIZE 11 -# define OSSL_FUNC_CIPHER_GET_PARAMS 12 -# define OSSL_FUNC_CIPHER_CTX_GET_PARAMS 13 -# define OSSL_FUNC_CIPHER_CTX_SET_PARAMS 14 +# define OSSL_FUNC_CIPHER_GET_PARAMS 9 +# define OSSL_FUNC_CIPHER_CTX_GET_PARAMS 10 +# define OSSL_FUNC_CIPHER_CTX_SET_PARAMS 11 OSSL_CORE_MAKE_FUNC(void *, OP_cipher_newctx, (void *provctx)) OSSL_CORE_MAKE_FUNC(int, OP_cipher_encrypt_init, (void *cctx, @@ -154,16 +222,12 @@ OSSL_CORE_MAKE_FUNC(int, OP_cipher_cipher, const unsigned char *in, size_t inl)) OSSL_CORE_MAKE_FUNC(void, OP_cipher_freectx, (void *cctx)) OSSL_CORE_MAKE_FUNC(void *, OP_cipher_dupctx, (void *cctx)) -OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_key_length, (void)) -OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_iv_length, (void)) -OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_block_size, (void)) -OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_params, (const OSSL_PARAM params[])) +OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_params, (OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, OP_cipher_ctx_get_params, (void *cctx, - const OSSL_PARAM params[])) + OSSL_PARAM params[])) OSSL_CORE_MAKE_FUNC(int, OP_cipher_ctx_set_params, (void *cctx, const OSSL_PARAM params[])) - # ifdef __cplusplus } # endif diff --git a/include/openssl/crmf.h b/include/openssl/crmf.h index 737a49d2..bc0c891c 100644 --- a/include/openssl/crmf.h +++ b/include/openssl/crmf.h @@ -1,7 +1,7 @@ /*- - * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. - * Copyright Nokia 2007-2018 - * Copyright Siemens AG 2015-2018 + * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2019 + * Copyright Siemens AG 2015-2019 * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h index 5322cc8f..79531196 100644 --- a/include/openssl/crypto.h +++ b/include/openssl/crypto.h @@ -415,6 +415,7 @@ void OPENSSL_cleanup(void); int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); int OPENSSL_atexit(void (*handler)(void)); void OPENSSL_thread_stop(void); +void OPENSSL_thread_stop_ex(OPENSSL_CTX *ctx); /* Low-level control of initialization */ OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void); diff --git a/include/openssl/des.h b/include/openssl/des.h index a0f5f3ce..84b65e00 100644 --- a/include/openssl/des.h +++ b/include/openssl/des.h @@ -63,9 +63,6 @@ typedef struct DES_ks { # define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) -OPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */ -# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) - const char *DES_options(void); void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, DES_key_schedule *ks1, DES_key_schedule *ks2, @@ -148,8 +145,7 @@ int DES_check_key_parity(const_DES_cblock *key); int DES_is_weak_key(const_DES_cblock *key); /* * DES_set_key (= set_key = DES_key_sched = key_sched) calls - * DES_set_key_checked if global variable DES_check_key is set, - * DES_set_key_unchecked otherwise. + * DES_set_key_checked */ int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule); int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule); diff --git a/include/openssl/dherr.h b/include/openssl/dherr.h index 22035542..83f0e591 100644 --- a/include/openssl/dherr.h +++ b/include/openssl/dherr.h @@ -29,6 +29,7 @@ int ERR_load_DH_strings(void); */ # define DH_F_COMPUTE_KEY 102 # define DH_F_DHPARAMS_PRINT_FP 101 +# define DH_F_DH_BUF2KEY 126 # define DH_F_DH_BUILTIN_GENPARAMS 106 # define DH_F_DH_CHECK_EX 121 # define DH_F_DH_CHECK_PARAMS_EX 122 @@ -36,6 +37,7 @@ int ERR_load_DH_strings(void); # define DH_F_DH_CMS_DECRYPT 114 # define DH_F_DH_CMS_SET_PEERKEY 115 # define DH_F_DH_CMS_SET_SHARED_INFO 116 +# define DH_F_DH_KEY2BUF 127 # define DH_F_DH_METH_DUP 117 # define DH_F_DH_METH_NEW 118 # define DH_F_DH_METH_SET1_NAME 119 diff --git a/include/openssl/e_os2.h b/include/openssl/e_os2.h index b88abc17..b1a99f3c 100644 --- a/include/openssl/e_os2.h +++ b/include/openssl/e_os2.h @@ -136,15 +136,6 @@ extern "C" { * That's it for OS-specific stuff *****************************************************************************/ -/* Specials for I/O an exit */ -# ifdef OPENSSL_SYS_MSDOS -# define OPENSSL_UNISTD_IO -# define OPENSSL_DECLARE_EXIT extern void exit(int); -# else -# define OPENSSL_UNISTD_IO OPENSSL_UNISTD -# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ -# endif - /*- * OPENSSL_EXTERN is normally used to declare a symbol with possible extra * attributes to handle its presence in a shared library. @@ -172,29 +163,6 @@ extern "C" { # define OPENSSL_EXTERN extern # endif -/*- - * Macros to allow global variables to be reached through function calls when - * required (if a shared library version requires it, for example. - * The way it's done allows definitions like this: - * - * // in foobar.c - * OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0) - * // in foobar.h - * OPENSSL_DECLARE_GLOBAL(int,foobar); - * #define foobar OPENSSL_GLOBAL_REF(foobar) - */ -# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION -# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) \ - type *_shadow_##name(void) \ - { static type _hide_##name=value; return &_hide_##name; } -# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) -# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) -# else -# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) type _shadow_##name=value; -# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name -# define OPENSSL_GLOBAL_REF(name) _shadow_##name -# endif - # ifdef _WIN32 # ifdef _WIN64 # define ossl_ssize_t __int64 @@ -228,6 +196,8 @@ extern "C" { # endif /* Standard integer types */ +# define OPENSSL_NO_INTTYPES_H +# define OPENSSL_NO_STDINT_H # if defined(OPENSSL_SYS_UEFI) typedef INT8 int8_t; typedef UINT8 uint8_t; @@ -241,6 +211,9 @@ typedef UINT64 uint64_t; defined(__osf__) || defined(__sgi) || defined(__hpux) || \ defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__) # include +# undef OPENSSL_NO_INTTYPES_H +/* Because the specs say that inttypes.h includes stdint.h if present */ +# undef OPENSSL_NO_STDINT_H # elif defined(_MSC_VER) && _MSC_VER<=1500 /* * minimally required typdefs for systems not supporting inttypes.h or @@ -256,6 +229,7 @@ typedef __int64 int64_t; typedef unsigned __int64 uint64_t; # else # include +# undef OPENSSL_NO_STDINT_H # endif /* ossl_inline: portable inline definition usable in public headers */ diff --git a/include/openssl/ec.h b/include/openssl/ec.h index af559cb2..e523d0d7 100644 --- a/include/openssl/ec.h +++ b/include/openssl/ec.h @@ -142,7 +142,7 @@ const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); */ int EC_METHOD_get_field_type(const EC_METHOD *meth); -/** Sets the generator and it's order/cofactor of a EC_GROUP object. +/** Sets the generator and its order/cofactor of a EC_GROUP object. * \param group EC_GROUP object * \param generator EC_POINT object with the generator. * \param order the order of the group generated by the generator. diff --git a/include/openssl/err.h b/include/openssl/err.h index 7398029b..f601eaf2 100644 --- a/include/openssl/err.h +++ b/include/openssl/err.h @@ -99,6 +99,7 @@ typedef struct err_state_st { # define ERR_LIB_PROP 55 # define ERR_LIB_CRMF 56 # define ERR_LIB_PROV 57 +# define ERR_LIB_CMP 58 # define ERR_LIB_USER 128 @@ -133,6 +134,7 @@ typedef struct err_state_st { # define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) # define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) # define CRMFerr(f,r) ERR_PUT_error(ERR_LIB_CRMF,(f),(r),OPENSSL_FILE,OPENSSL_LINE) +# define CMPerr(f,r) ERR_PUT_error(ERR_LIB_CMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE) # define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) # define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE) # define CTerr(f,r) ERR_PUT_error(ERR_LIB_CT,(f),(r),OPENSSL_FILE,OPENSSL_LINE) diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 1c0415a9..cf1a5272 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -17,6 +17,7 @@ # include # include # include +# include # define EVP_MAX_MD_SIZE 64/* longest known is SHA512 */ # define EVP_MAX_KEY_LENGTH 64 @@ -79,7 +80,7 @@ int EVP_set_default_properties(OPENSSL_CTX *libctx, const char *propq); # ifndef EVP_MD EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type); EVP_MD *EVP_MD_meth_dup(const EVP_MD *md); -int EVP_MD_upref(EVP_MD *md); +int EVP_MD_up_ref(EVP_MD *md); void EVP_MD_meth_free(EVP_MD *md); int EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize); @@ -190,7 +191,7 @@ int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd, EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len); EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher); void EVP_CIPHER_meth_free(EVP_CIPHER *cipher); -int EVP_CIPHER_upref(EVP_CIPHER *cipher); +int EVP_CIPHER_up_ref(EVP_CIPHER *cipher); int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len); int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags); @@ -489,7 +490,7 @@ const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx); unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx); unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx); int EVP_CIPHER_CTX_num(const EVP_CIPHER_CTX *ctx); -void EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num); +int EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num); int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in); void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data); @@ -539,6 +540,8 @@ void BIO_set_md(BIO *, const EVP_MD *md); # define EVP_delete_digest_alias(alias) \ OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); +int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]); +int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[]); int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2); EVP_MD_CTX *EVP_MD_CTX_new(void); int EVP_MD_CTX_reset(EVP_MD_CTX *ctx); @@ -1012,7 +1015,7 @@ void EVP_MD_do_all_sorted(void (*fn) EVP_MAC_CTX *EVP_MAC_CTX_new(const EVP_MAC *mac); EVP_MAC_CTX *EVP_MAC_CTX_new_id(int nid); void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx); -int EVP_MAC_CTX_copy(EVP_MAC_CTX *dest, const EVP_MAC_CTX *src); +EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src); const EVP_MAC *EVP_MAC_CTX_mac(EVP_MAC_CTX *ctx); size_t EVP_MAC_size(EVP_MAC_CTX *ctx); int EVP_MAC_init(EVP_MAC_CTX *ctx); diff --git a/include/openssl/evperr.h b/include/openssl/evperr.h index 3aa97920..0e0d5f40 100644 --- a/include/openssl/evperr.h +++ b/include/openssl/evperr.h @@ -74,7 +74,7 @@ int ERR_load_EVP_strings(void); # define EVP_F_EVP_KDF_CTX_NEW_ID 226 # define EVP_F_EVP_MAC_CTRL 209 # define EVP_F_EVP_MAC_CTRL_STR 210 -# define EVP_F_EVP_MAC_CTX_COPY 211 +# define EVP_F_EVP_MAC_CTX_DUP 211 # define EVP_F_EVP_MAC_CTX_NEW 213 # define EVP_F_EVP_MAC_INIT 212 # define EVP_F_EVP_MD_BLOCK_SIZE 232 @@ -145,11 +145,13 @@ int ERR_load_EVP_strings(void); # define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN 164 # define EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN 180 # define EVP_F_PKEY_KDF_CTRL 227 +# define EVP_F_PKEY_MAC_COPY 241 # define EVP_F_PKEY_MAC_INIT 214 # define EVP_F_PKEY_SET_TYPE 158 # define EVP_F_POLY1305_CTRL 216 # define EVP_F_RC2_MAGIC_TO_METH 109 # define EVP_F_RC5_CTRL 125 +# define EVP_F_R_32_12_16_INIT_KEY 242 # define EVP_F_S390X_AES_GCM_CTRL 201 # define EVP_F_S390X_AES_GCM_TLS_CIPHER 208 # define EVP_F_SCRYPT_ALG 228 @@ -161,6 +163,7 @@ int ERR_load_EVP_strings(void); # define EVP_R_AES_KEY_SETUP_FAILED 143 # define EVP_R_ARIA_KEY_SETUP_FAILED 176 # define EVP_R_BAD_DECRYPT 100 +# define EVP_R_BAD_KEY_LENGTH 195 # define EVP_R_BUFFER_TOO_SMALL 155 # define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157 # define EVP_R_CIPHER_NOT_GCM_MODE 184 diff --git a/include/openssl/kdf.h b/include/openssl/kdf.h index b13b54cf..300cf760 100644 --- a/include/openssl/kdf.h +++ b/include/openssl/kdf.h @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -25,6 +25,7 @@ extern "C" { # define EVP_KDF_SSHKDF NID_sshkdf # define EVP_KDF_SS NID_sskdf # define EVP_KDF_X963 NID_x963kdf +# define EVP_KDF_X942 NID_x942kdf EVP_KDF_CTX *EVP_KDF_CTX_new_id(int id); EVP_KDF_CTX *EVP_KDF_CTX_new(const EVP_KDF *kdf); @@ -44,39 +45,42 @@ int EVP_KDF_nid(const EVP_KDF *kdf); # define EVP_KDF_name(o) OBJ_nid2sn(EVP_KDF_nid(o)) const EVP_KDF *EVP_get_kdfbyname(const char *name); -# define EVP_KDF_CTRL_SET_PASS 0x01 /* unsigned char *, size_t */ -# define EVP_KDF_CTRL_SET_SALT 0x02 /* unsigned char *, size_t */ -# define EVP_KDF_CTRL_SET_ITER 0x03 /* int */ -# define EVP_KDF_CTRL_SET_MD 0x04 /* EVP_MD * */ -# define EVP_KDF_CTRL_SET_KEY 0x05 /* unsigned char *, size_t */ -# define EVP_KDF_CTRL_SET_MAXMEM_BYTES 0x06 /* uint64_t */ -# define EVP_KDF_CTRL_SET_TLS_SECRET 0x07 /* unsigned char *, size_t */ -# define EVP_KDF_CTRL_RESET_TLS_SEED 0x08 -# define EVP_KDF_CTRL_ADD_TLS_SEED 0x09 /* unsigned char *, size_t */ -# define EVP_KDF_CTRL_RESET_HKDF_INFO 0x0a -# define EVP_KDF_CTRL_ADD_HKDF_INFO 0x0b /* unsigned char *, size_t */ -# define EVP_KDF_CTRL_SET_HKDF_MODE 0x0c /* int */ -# define EVP_KDF_CTRL_SET_SCRYPT_N 0x0d /* uint64_t */ -# define EVP_KDF_CTRL_SET_SCRYPT_R 0x0e /* uint32_t */ -# define EVP_KDF_CTRL_SET_SCRYPT_P 0x0f /* uint32_t */ -# define EVP_KDF_CTRL_SET_SSHKDF_XCGHASH 0x10 /* unsigned char *, size_t */ -# define EVP_KDF_CTRL_SET_SSHKDF_SESSION_ID 0x11 /* unsigned char *, size_t */ -# define EVP_KDF_CTRL_SET_SSHKDF_TYPE 0x12 /* int */ -# define EVP_KDF_CTRL_SET_MAC 0x13 /* EVP_MAC * */ -# define EVP_KDF_CTRL_SET_MAC_SIZE 0x14 /* size_t */ -# define EVP_KDF_CTRL_SET_SSKDF_INFO 0x15 /* unsigned char *, size_t */ -# define EVP_KDF_CTRL_SET_SHARED_INFO EVP_KDF_CTRL_SET_SSKDF_INFO +# define EVP_KDF_CTRL_SET_PASS 0x01 /* unsigned char *, size_t */ +# define EVP_KDF_CTRL_SET_SALT 0x02 /* unsigned char *, size_t */ +# define EVP_KDF_CTRL_SET_ITER 0x03 /* int */ +# define EVP_KDF_CTRL_SET_MD 0x04 /* EVP_MD * */ +# define EVP_KDF_CTRL_SET_KEY 0x05 /* unsigned char *, size_t */ +# define EVP_KDF_CTRL_SET_MAXMEM_BYTES 0x06 /* uint64_t */ +# define EVP_KDF_CTRL_SET_TLS_SECRET 0x07 /* unsigned char *, size_t */ +# define EVP_KDF_CTRL_RESET_TLS_SEED 0x08 +# define EVP_KDF_CTRL_ADD_TLS_SEED 0x09 /* unsigned char *, size_t */ +# define EVP_KDF_CTRL_RESET_HKDF_INFO 0x0a +# define EVP_KDF_CTRL_ADD_HKDF_INFO 0x0b /* unsigned char *, size_t */ +# define EVP_KDF_CTRL_SET_HKDF_MODE 0x0c /* int */ +# define EVP_KDF_CTRL_SET_SCRYPT_N 0x0d /* uint64_t */ +# define EVP_KDF_CTRL_SET_SCRYPT_R 0x0e /* uint32_t */ +# define EVP_KDF_CTRL_SET_SCRYPT_P 0x0f /* uint32_t */ +# define EVP_KDF_CTRL_SET_SSHKDF_XCGHASH 0x10 /* unsigned char *, size_t */ +# define EVP_KDF_CTRL_SET_SSHKDF_SESSION_ID 0x11 /* unsigned char *, size_t */ +# define EVP_KDF_CTRL_SET_SSHKDF_TYPE 0x12 /* int */ +# define EVP_KDF_CTRL_SET_MAC 0x13 /* EVP_MAC * */ +# define EVP_KDF_CTRL_SET_MAC_SIZE 0x14 /* size_t */ +# define EVP_KDF_CTRL_SET_SSKDF_INFO 0x15 /* unsigned char *, size_t */ +# define EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE 0x16 /* int */ +# define EVP_KDF_CTRL_SET_UKM 0x17 /* unsigned char *, size_t */ +# define EVP_KDF_CTRL_SET_CEK_ALG 0x18 /* char * */ +# define EVP_KDF_CTRL_SET_SHARED_INFO EVP_KDF_CTRL_SET_SSKDF_INFO # define EVP_KDF_HKDF_MODE_EXTRACT_AND_EXPAND 0 # define EVP_KDF_HKDF_MODE_EXTRACT_ONLY 1 # define EVP_KDF_HKDF_MODE_EXPAND_ONLY 2 -#define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV 65 -#define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI 66 +#define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_CLI_TO_SRV 65 +#define EVP_KDF_SSHKDF_TYPE_INITIAL_IV_SRV_TO_CLI 66 #define EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_CLI_TO_SRV 67 #define EVP_KDF_SSHKDF_TYPE_ENCRYPTION_KEY_SRV_TO_CLI 68 -#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV 69 -#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI 70 +#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_CLI_TO_SRV 69 +#define EVP_KDF_SSHKDF_TYPE_INTEGRITY_KEY_SRV_TO_CLI 70 /**** The legacy PKEY-based KDF API follows. ****/ diff --git a/include/openssl/kdferr.h b/include/openssl/kdferr.h index db87f69e..335bdf38 100644 --- a/include/openssl/kdferr.h +++ b/include/openssl/kdferr.h @@ -28,6 +28,7 @@ int ERR_load_KDF_strings(void); # define KDF_F_KDF_HKDF_NEW 114 # define KDF_F_KDF_HKDF_SIZE 115 # define KDF_F_KDF_MD2CTRL 116 +# define KDF_F_KDF_PBKDF2_CTRL 140 # define KDF_F_KDF_PBKDF2_CTRL_STR 117 # define KDF_F_KDF_PBKDF2_DERIVE 118 # define KDF_F_KDF_PBKDF2_NEW 119 @@ -43,6 +44,7 @@ int ERR_load_KDF_strings(void); # define KDF_F_KDF_TLS1_PRF_CTRL_STR 125 # define KDF_F_KDF_TLS1_PRF_DERIVE 126 # define KDF_F_KDF_TLS1_PRF_NEW 127 +# define KDF_F_PBKDF2_DERIVE 141 # define KDF_F_PBKDF2_SET_MEMBUF 128 # define KDF_F_PKEY_HKDF_CTRL_STR 103 # define KDF_F_PKEY_HKDF_DERIVE 102 @@ -62,13 +64,25 @@ int ERR_load_KDF_strings(void); # define KDF_F_SSKDF_NEW 137 # define KDF_F_SSKDF_SIZE 138 # define KDF_F_TLS1_PRF_ALG 111 +# define KDF_F_X942KDF_CTRL 142 +# define KDF_F_X942KDF_DERIVE 143 +# define KDF_F_X942KDF_HASH_KDM 144 +# define KDF_F_X942KDF_NEW 145 +# define KDF_F_X942KDF_SIZE 146 # define KDF_F_X963KDF_DERIVE 139 /* * KDF reason codes. */ +# define KDF_R_BAD_ENCODING 122 +# define KDF_R_BAD_LENGTH 123 +# define KDF_R_INAVLID_UKM_LEN 124 # define KDF_R_INVALID_DIGEST 100 +# define KDF_R_INVALID_ITERATION_COUNT 119 +# define KDF_R_INVALID_KEY_LEN 120 # define KDF_R_INVALID_MAC_TYPE 116 +# define KDF_R_INVALID_SALT_LEN 121 +# define KDF_R_MISSING_CEK_ALG 125 # define KDF_R_MISSING_ITERATION_COUNT 109 # define KDF_R_MISSING_KEY 104 # define KDF_R_MISSING_MESSAGE_DIGEST 105 @@ -82,6 +96,7 @@ int ERR_load_KDF_strings(void); # define KDF_R_MISSING_XCGHASH 115 # define KDF_R_NOT_SUPPORTED 118 # define KDF_R_UNKNOWN_PARAMETER_TYPE 103 +# define KDF_R_UNSUPPORTED_CEK_ALG 126 # define KDF_R_UNSUPPORTED_MAC_TYPE 117 # define KDF_R_VALUE_ERROR 108 # define KDF_R_VALUE_MISSING 102 diff --git a/include/openssl/modes.h b/include/openssl/modes.h index 0934482c..212c846f 100644 --- a/include/openssl/modes.h +++ b/include/openssl/modes.h @@ -202,32 +202,6 @@ int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len); void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx); # endif /* OPENSSL_NO_OCB */ -# ifndef OPENSSL_NO_SIV - -typedef struct siv128_context SIV128_CONTEXT; - -# define SIV_LEN 16 - -SIV128_CONTEXT *CRYPTO_siv128_new(const unsigned char *key, int klen, EVP_CIPHER* cbc, EVP_CIPHER* ctr); -int CRYPTO_siv128_init(SIV128_CONTEXT *ctx, const unsigned char *key, int klen, - const EVP_CIPHER* cbc, const EVP_CIPHER* ctr); -int CRYPTO_siv128_copy_ctx(SIV128_CONTEXT *dest, SIV128_CONTEXT *src); -int CRYPTO_siv128_aad(SIV128_CONTEXT *ctx, const unsigned char *aad, - size_t len); -int CRYPTO_siv128_encrypt(SIV128_CONTEXT *ctx, - const unsigned char *in, unsigned char *out, - size_t len); -int CRYPTO_siv128_decrypt(SIV128_CONTEXT *ctx, - const unsigned char *in, unsigned char *out, - size_t len); -int CRYPTO_siv128_finish(SIV128_CONTEXT *ctx); -int CRYPTO_siv128_set_tag(SIV128_CONTEXT *ctx, const unsigned char *tag, size_t len); -int CRYPTO_siv128_get_tag(SIV128_CONTEXT *ctx, unsigned char *tag, size_t len); -int CRYPTO_siv128_cleanup(SIV128_CONTEXT *ctx); -int CRYPTO_siv128_speed(SIV128_CONTEXT *ctx, int arg); - -# endif /* OPENSSL_NO_SIV */ - # ifdef __cplusplus } # endif diff --git a/include/openssl/obj_mac.h b/include/openssl/obj_mac.h index 6e9f141b..d08a9e3b 100644 --- a/include/openssl/obj_mac.h +++ b/include/openssl/obj_mac.h @@ -49,22 +49,6 @@ #define NID_gmac 1195 #define OBJ_gmac OBJ_iso,0L,9797L,3L,4L -#define SN_kmac128 "KMAC128" -#define LN_kmac128 "kmac128" -#define NID_kmac128 1196 - -#define SN_kmac256 "KMAC256" -#define LN_kmac256 "kmac256" -#define NID_kmac256 1197 - -#define SN_blake2bmac "BLAKE2BMAC" -#define LN_blake2bmac "blake2bmac" -#define NID_blake2bmac 1201 - -#define SN_blake2smac "BLAKE2SMAC" -#define LN_blake2smac "blake2smac" -#define NID_blake2smac 1202 - #define SN_hmac_md5 "HMAC-MD5" #define LN_hmac_md5 "hmac-md5" #define NID_hmac_md5 780 @@ -2139,15 +2123,25 @@ #define NID_ripemd160WithRSA 119 #define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L +#define SN_blake2bmac "BLAKE2BMAC" +#define LN_blake2bmac "blake2bmac" +#define NID_blake2bmac 1201 +#define OBJ_blake2bmac 1L,3L,6L,1L,4L,1L,1722L,12L,2L,1L + +#define SN_blake2smac "BLAKE2SMAC" +#define LN_blake2smac "blake2smac" +#define NID_blake2smac 1202 +#define OBJ_blake2smac 1L,3L,6L,1L,4L,1L,1722L,12L,2L,2L + #define SN_blake2b512 "BLAKE2b512" #define LN_blake2b512 "blake2b512" #define NID_blake2b512 1056 -#define OBJ_blake2b512 1L,3L,6L,1L,4L,1L,1722L,12L,2L,1L,16L +#define OBJ_blake2b512 OBJ_blake2bmac,16L #define SN_blake2s256 "BLAKE2s256" #define LN_blake2s256 "blake2s256" #define NID_blake2s256 1057 -#define OBJ_blake2s256 1L,3L,6L,1L,4L,1L,1722L,12L,2L,2L,8L +#define OBJ_blake2s256 OBJ_blake2smac,8L #define SN_sxnet "SXNetID" #define LN_sxnet "Strong Extranet ID" @@ -2997,6 +2991,16 @@ #define NID_hmac_sha3_512 1105 #define OBJ_hmac_sha3_512 OBJ_nist_hashalgs,16L +#define SN_kmac128 "KMAC128" +#define LN_kmac128 "kmac128" +#define NID_kmac128 1196 +#define OBJ_kmac128 OBJ_nist_hashalgs,19L + +#define SN_kmac256 "KMAC256" +#define LN_kmac256 "kmac256" +#define NID_kmac256 1197 +#define OBJ_kmac256 OBJ_nist_hashalgs,20L + #define OBJ_dsa_with_sha2 OBJ_nistAlgorithms,3L #define SN_dsa_with_SHA224 "dsa_with_SHA224" @@ -4835,7 +4839,7 @@ #define SN_chacha20_poly1305_draft "ChaCha20-Poly1305-D" #define LN_chacha20_poly1305_draft "chacha20-poly1305-draft" -#define NID_chacha20_poly1305_draft 1207 +#define NID_chacha20_poly1305_draft 1208 #define SN_chacha20 "ChaCha20" #define LN_chacha20 "chacha20" @@ -5008,6 +5012,10 @@ #define LN_sskdf "sskdf" #define NID_sskdf 1205 +#define SN_x942kdf "X942KDF" +#define LN_x942kdf "x942kdf" +#define NID_x942kdf 1207 + #define SN_x963kdf "X963KDF" #define LN_x963kdf "x963kdf" #define NID_x963kdf 1206 diff --git a/include/openssl/ocsp.h b/include/openssl/ocsp.h index bce367d9..5fdff088 100644 --- a/include/openssl/ocsp.h +++ b/include/openssl/ocsp.h @@ -123,7 +123,7 @@ typedef struct ocsp_service_locator_st OCSP_SERVICELOC; (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST, \ bp,(char **)(x),cb,NULL) -# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\ +# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb) (OCSP_RESPONSE *)PEM_ASN1_read_bio(\ (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE, \ bp,(char **)(x),cb,NULL) diff --git a/include/openssl/opensslconf.h.in b/include/openssl/opensslconf.h.in index ca680bc3..b0d339ac 100644 --- a/include/openssl/opensslconf.h.in +++ b/include/openssl/opensslconf.h.in @@ -85,7 +85,7 @@ extern "C" { /* In case someone defined both */ # if defined(OPENSSL_API_COMPAT) && defined(OPENSSL_API_LEVEL) -# error "Disallowed to defined both OPENSSL_API_COMPAT and OPENSSL_API_LEVEL" +# error "Disallowed to define both OPENSSL_API_COMPAT and OPENSSL_API_LEVEL" # endif # ifndef OPENSSL_API_COMPAT @@ -100,7 +100,7 @@ extern "C" { # elif (OPENSSL_API_COMPAT & 0xFFF00000L) == 0x10100000L # define OPENSSL_API_LEVEL 2 # else -/ * Major number 3 to 15 */ + /* Major number 3 to 15 */ # define OPENSSL_API_LEVEL ((OPENSSL_API_COMPAT >> 28) & 0xF) # endif # endif @@ -165,11 +165,6 @@ extern "C" { /* Generate 80386 code? */ {- $config{processor} eq "386" ? "# define" : "# undef" -} I386_ONLY -# undef OPENSSL_UNISTD -# define OPENSSL_UNISTD {- $target{unistd} -} - -{- $config{export_var_as_fn} ? "# define" : "# undef" -} OPENSSL_EXPORT_VAR_AS_FUNCTION - /* * The following are cipher-specific, but are part of the public API. */ diff --git a/include/openssl/opensslv.h b/include/openssl/opensslv.h index 73e64a72..0219d5fd 100644 --- a/include/openssl/opensslv.h +++ b/include/openssl/opensslv.h @@ -78,7 +78,7 @@ extern "C" { /* For checking general API compatibility when preprocessing */ # define OPENSSL_VERSION_PREREQ(maj,min) \ - ((OPENSSL_VERSION_MAJOR << 16) + OPENSSL_VERSION_MINOR >= (maj << 16) + min) + ((OPENSSL_VERSION_MAJOR << 16) + OPENSSL_VERSION_MINOR >= ((maj) << 16) + (min)) /* Helper macros for CPP string composition */ # define OPENSSL_MSTR_HELPER(x) #x diff --git a/include/openssl/params.h b/include/openssl/params.h index aea24bb2..0e830dee 100644 --- a/include/openssl/params.h +++ b/include/openssl/params.h @@ -19,124 +19,74 @@ extern "C" { # endif # define OSSL_PARAM_END \ - { NULL, 0, NULL, 0, NULL } + { NULL, 0, NULL, 0, 0 } -# define OSSL_PARAM_DEFN(key, type, addr, sz, rsz) \ - { (key), (type), (addr), (sz), (rsz) } +# define OSSL_PARAM_DEFN(key, type, addr, sz) \ + { (key), (type), (addr), (sz), 0 } /* Basic parameter types without return sizes */ # define OSSL_PARAM_int(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int), NULL) + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int)) # define OSSL_PARAM_uint(key, addr) \ OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ - sizeof(unsigned int), NULL) + sizeof(unsigned int)) # define OSSL_PARAM_long(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int), \ - NULL) + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int)) # define OSSL_PARAM_ulong(key, addr) \ OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ - sizeof(unsigned long int), NULL) + sizeof(unsigned long int)) # define OSSL_PARAM_int32(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t), NULL) + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t)) # define OSSL_PARAM_uint32(key, addr) \ OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ - sizeof(uint32_t), NULL) + sizeof(uint32_t)) # define OSSL_PARAM_int64(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t), NULL) + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t)) # define OSSL_PARAM_uint64(key, addr) \ OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ - sizeof(uint64_t), NULL) + sizeof(uint64_t)) # define OSSL_PARAM_size_t(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(size_t), \ - NULL) + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(size_t)) # define OSSL_PARAM_double(key, addr) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double), NULL) + OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double)) +# define OSSL_PARAM_BN(key, bn, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (bn), (sz)) # define OSSL_PARAM_utf8_string(key, addr, sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz, NULL) + OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz) # define OSSL_PARAM_octet_string(key, addr, sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz, NULL) + OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz) # define OSSL_PARAM_utf8_ptr(key, addr, sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, &(addr), sz, NULL) + OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, &(addr), sz) # define OSSL_PARAM_octet_ptr(key, addr, sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, &(addr), sz, NULL) - -/* Basic parameter types including return sizes */ -# define OSSL_PARAM_SIZED_int(key, addr, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int), &(r_sz)) -# define OSSL_PARAM_SIZED_uint(key, addr, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ - sizeof(unsigned int), &(r_sz)) -# define OSSL_PARAM_SIZED_long(key, addr, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int), \ - &(r_sz)) -# define OSSL_PARAM_SIZED_ulong(key, addr, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ - sizeof(unsigned long int), &(r_sz)) -# define OSSL_PARAM_SIZED_int32(key, addr, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t), &(r_sz)) -# define OSSL_PARAM_SIZED_uint32(key, addr, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ - sizeof(uint32_t), &(r_sz)) -# define OSSL_PARAM_SIZED_int64(key, addr, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t), &(r_sz)) -# define OSSL_PARAM_SIZED_uint64(key, addr, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ - sizeof(uint64_t), &(r_sz)) -# define OSSL_PARAM_SIZED_size_t(key, addr, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ - sizeof(size_t), &(r_sz)) -# define OSSL_PARAM_SIZED_double(key, addr, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double), &(r_sz)) - -# define OSSL_PARAM_SIZED_BN(key, addr, sz, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sz, \ - &(r_sz)) - -# define OSSL_PARAM_SIZED_utf8_string(key, addr, sz, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz, &(r_sz)) -# define OSSL_PARAM_SIZED_octet_string(key, addr, sz, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz, &(r_sz)) - -# define OSSL_PARAM_SIZED_utf8_ptr(key, addr, sz, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, &(addr), sz, &(r_sz)) -# define OSSL_PARAM_SIZED_octet_ptr(key, addr, sz, r_sz) \ - OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, &(addr), sz, &(r_sz)) + OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, &(addr), sz) /* Search an OSSL_PARAM array for a matching name */ -const OSSL_PARAM *OSSL_PARAM_locate(const OSSL_PARAM *p, const char *key); +OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *p, const char *key); +const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *p, const char *key); /* Basic parameter type run-time construction */ -OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf, size_t *ret); -OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf, - size_t *ret); -OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf, - size_t *ret); -OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf, - size_t *ret); -OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf, - size_t *ret); -OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf, - size_t *ret); -OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf, - size_t *ret); -OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf, - size_t *ret); -OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf, - size_t *ret); +OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf); +OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf); +OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf); +OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf); +OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf); +OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf); +OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf); +OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf); +OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf); OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf, - size_t bsize, size_t *rsize); -OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf, - size_t *rsize); + size_t bsize); +OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf); OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, - size_t bsize, size_t *rsize); + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, - size_t bsize, size_t *rsize); + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, - size_t bsize, size_t *rsize); + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, - size_t bsize, size_t *rsize); + size_t bsize); OSSL_PARAM OSSL_PARAM_construct_end(void); int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val); @@ -149,36 +99,35 @@ int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val); int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val); int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val); -int OSSL_PARAM_set_int(const OSSL_PARAM *p, int val); -int OSSL_PARAM_set_uint(const OSSL_PARAM *p, unsigned int val); -int OSSL_PARAM_set_long(const OSSL_PARAM *p, long int val); -int OSSL_PARAM_set_ulong(const OSSL_PARAM *p, unsigned long int val); -int OSSL_PARAM_set_int32(const OSSL_PARAM *p, int32_t val); -int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val); -int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val); -int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val); -int OSSL_PARAM_set_size_t(const OSSL_PARAM *p, size_t val); +int OSSL_PARAM_set_int(OSSL_PARAM *p, int val); +int OSSL_PARAM_set_uint(OSSL_PARAM *p, unsigned int val); +int OSSL_PARAM_set_long(OSSL_PARAM *p, long int val); +int OSSL_PARAM_set_ulong(OSSL_PARAM *p, unsigned long int val); +int OSSL_PARAM_set_int32(OSSL_PARAM *p, int32_t val); +int OSSL_PARAM_set_uint32(OSSL_PARAM *p, uint32_t val); +int OSSL_PARAM_set_int64(OSSL_PARAM *p, int64_t val); +int OSSL_PARAM_set_uint64(OSSL_PARAM *p, uint64_t val); +int OSSL_PARAM_set_size_t(OSSL_PARAM *p, size_t val); int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val); -int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val); +int OSSL_PARAM_set_double(OSSL_PARAM *p, double val); int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val); -int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const BIGNUM *val); +int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val); int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len); -int OSSL_PARAM_set_utf8_string(const OSSL_PARAM *p, const char *val); +int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val); int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len, size_t *used_len); -int OSSL_PARAM_set_octet_string(const OSSL_PARAM *p, const void *val, - size_t len); +int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len); int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val); -int OSSL_PARAM_set_utf8_ptr(const OSSL_PARAM *p, const char *val); +int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val); int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val, size_t *used_len); -int OSSL_PARAM_set_octet_ptr(const OSSL_PARAM *p, const void *val, +int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val, size_t used_len); # ifdef __cplusplus diff --git a/include/openssl/provider.h b/include/openssl/provider.h index 7dc5b8ae..c7f66645 100644 --- a/include/openssl/provider.h +++ b/include/openssl/provider.h @@ -20,8 +20,8 @@ extern "C" { OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *, const char *name); int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov); -const OSSL_ITEM *OSSL_PROVIDER_get_param_types(OSSL_PROVIDER *prov); -int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, const OSSL_PARAM params[]); +const OSSL_ITEM *OSSL_PROVIDER_get_param_types(const OSSL_PROVIDER *prov); +int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]); /* Add a built in providers */ int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *, const char *name, diff --git a/include/openssl/rand_drbg.h b/include/openssl/rand_drbg.h index 32c6dcfe..4e99d71a 100644 --- a/include/openssl/rand_drbg.h +++ b/include/openssl/rand_drbg.h @@ -72,6 +72,10 @@ extern "C" { /* * Object lifetime functions. */ +RAND_DRBG *RAND_DRBG_new_ex(OPENSSL_CTX *ctx, int type, unsigned int flags, + RAND_DRBG *parent); +RAND_DRBG *RAND_DRBG_secure_new_ex(OPENSSL_CTX *ctx, int type, + unsigned int flags, RAND_DRBG *parent); RAND_DRBG *RAND_DRBG_new(int type, unsigned int flags, RAND_DRBG *parent); RAND_DRBG *RAND_DRBG_secure_new(int type, unsigned int flags, RAND_DRBG *parent); int RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags); @@ -102,6 +106,9 @@ int RAND_DRBG_set_reseed_defaults( time_t slave_reseed_time_interval ); +RAND_DRBG *OPENSSL_CTX_get0_master_drbg(OPENSSL_CTX *ctx); +RAND_DRBG *OPENSSL_CTX_get0_public_drbg(OPENSSL_CTX *ctx); +RAND_DRBG *OPENSSL_CTX_get0_private_drbg(OPENSSL_CTX *ctx); RAND_DRBG *RAND_DRBG_get0_master(void); RAND_DRBG *RAND_DRBG_get0_public(void); RAND_DRBG *RAND_DRBG_get0_private(void); diff --git a/include/openssl/randerr.h b/include/openssl/randerr.h index bc1c0639..28dd59a2 100644 --- a/include/openssl/randerr.h +++ b/include/openssl/randerr.h @@ -29,6 +29,7 @@ int ERR_load_RAND_strings(void); # define RAND_F_DRBG_SETUP 117 # define RAND_F_GET_ENTROPY 106 # define RAND_F_RAND_BYTES 100 +# define RAND_F_RAND_BYTES_EX 126 # define RAND_F_RAND_DRBG_ENABLE_LOCKING 119 # define RAND_F_RAND_DRBG_GENERATE 107 # define RAND_F_RAND_DRBG_GET_ENTROPY 120 diff --git a/include/openssl/rc5.h b/include/openssl/rc5.h index 80a7d680..97e22f7a 100644 --- a/include/openssl/rc5.h +++ b/include/openssl/rc5.h @@ -39,8 +39,8 @@ typedef struct rc5_key_st { RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)]; } RC5_32_KEY; -void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, - int rounds); +int RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, + int rounds); void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out, RC5_32_KEY *key, int enc); void RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key); diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 23301772..814b203b 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -170,17 +170,25 @@ extern "C" { * The following cipher list is used by default. It also is substituted when * an application-defined cipher list string starts with 'DEFAULT'. * This applies to ciphersuites for TLSv1.2 and below. + * DEPRECATED IN 3.0.0, in favor of OSSL_default_cipher_list() + * Update both macro and function simultaneously */ -# define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL" -/* This is the default set of TLSv1.3 ciphersuites */ -# if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) -# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ - "TLS_CHACHA20_POLY1305_SHA256:" \ +# if !OPENSSL_API_3 +# define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL" +/* + * This is the default set of TLSv1.3 ciphersuites + * DEPRECATED IN 3.0.0, in favor of OSSL_default_ciphersuites() + * Update both macro and function simultaneously + */ +# if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) +# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ + "TLS_CHACHA20_POLY1305_SHA256:" \ + "TLS_AES_128_GCM_SHA256" +# else +# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ "TLS_AES_128_GCM_SHA256" -# else -# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ - "TLS_AES_128_GCM_SHA256" -#endif +# endif +# endif /* * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always * starts with a reasonable order, and all we have to do for DEFAULT is @@ -1370,24 +1378,24 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st)) # define SSL_CTX_set1_chain_cert_store(ctx,st) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st)) -# define SSL_set0_chain(ctx,sk) \ - SSL_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)(sk)) -# define SSL_set1_chain(ctx,sk) \ - SSL_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)(sk)) -# define SSL_add0_chain_cert(ctx,x509) \ - SSL_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)(x509)) -# define SSL_add1_chain_cert(ctx,x509) \ - SSL_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)(x509)) -# define SSL_get0_chain_certs(ctx,px509) \ - SSL_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509) -# define SSL_clear_chain_certs(ctx) \ - SSL_set0_chain(ctx,NULL) +# define SSL_set0_chain(s,sk) \ + SSL_ctrl(s,SSL_CTRL_CHAIN,0,(char *)(sk)) +# define SSL_set1_chain(s,sk) \ + SSL_ctrl(s,SSL_CTRL_CHAIN,1,(char *)(sk)) +# define SSL_add0_chain_cert(s,x509) \ + SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,0,(char *)(x509)) +# define SSL_add1_chain_cert(s,x509) \ + SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,1,(char *)(x509)) +# define SSL_get0_chain_certs(s,px509) \ + SSL_ctrl(s,SSL_CTRL_GET_CHAIN_CERTS,0,px509) +# define SSL_clear_chain_certs(s) \ + SSL_set0_chain(s,NULL) # define SSL_build_cert_chain(s, flags) \ SSL_ctrl(s,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) -# define SSL_select_current_cert(ctx,x509) \ - SSL_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509)) -# define SSL_set_current_cert(ctx,op) \ - SSL_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL) +# define SSL_select_current_cert(s,x509) \ + SSL_ctrl(s,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509)) +# define SSL_set_current_cert(s,op) \ + SSL_ctrl(s,SSL_CTRL_SET_CURRENT_CERT, op, NULL) # define SSL_set0_verify_cert_store(s,st) \ SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st)) # define SSL_set1_verify_cert_store(s,st) \ @@ -1396,34 +1404,34 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st)) # define SSL_set1_chain_cert_store(s,st) \ SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st)) -# define SSL_get1_groups(ctx, s) \ - SSL_ctrl(ctx,SSL_CTRL_GET_GROUPS,0,(char *)(s)) +# define SSL_get1_groups(s, glist) \ + SSL_ctrl(s,SSL_CTRL_GET_GROUPS,0,(int*)(glist)) # define SSL_CTX_set1_groups(ctx, glist, glistlen) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS,glistlen,(char *)(glist)) # define SSL_CTX_set1_groups_list(ctx, s) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(s)) -# define SSL_set1_groups(ctx, glist, glistlen) \ - SSL_ctrl(ctx,SSL_CTRL_SET_GROUPS,glistlen,(char *)(glist)) -# define SSL_set1_groups_list(ctx, s) \ - SSL_ctrl(ctx,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(s)) +# define SSL_set1_groups(s, glist, glistlen) \ + SSL_ctrl(s,SSL_CTRL_SET_GROUPS,glistlen,(char *)(glist)) +# define SSL_set1_groups_list(s, str) \ + SSL_ctrl(s,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(str)) # define SSL_get_shared_group(s, n) \ SSL_ctrl(s,SSL_CTRL_GET_SHARED_GROUP,n,NULL) # define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist)) # define SSL_CTX_set1_sigalgs_list(ctx, s) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(s)) -# define SSL_set1_sigalgs(ctx, slist, slistlen) \ - SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist)) -# define SSL_set1_sigalgs_list(ctx, s) \ - SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(s)) +# define SSL_set1_sigalgs(s, slist, slistlen) \ + SSL_ctrl(s,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist)) +# define SSL_set1_sigalgs_list(s, str) \ + SSL_ctrl(s,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(str)) # define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist)) # define SSL_CTX_set1_client_sigalgs_list(ctx, s) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(s)) -# define SSL_set1_client_sigalgs(ctx, slist, slistlen) \ - SSL_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,clistlen,(int *)(slist)) -# define SSL_set1_client_sigalgs_list(ctx, s) \ - SSL_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(s)) +# define SSL_set1_client_sigalgs(s, slist, slistlen) \ + SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist)) +# define SSL_set1_client_sigalgs_list(s, str) \ + SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(str)) # define SSL_get0_certificate_types(s, clist) \ SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)(clist)) # define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \ @@ -2445,6 +2453,10 @@ void SSL_set_allow_early_data_cb(SSL *s, SSL_allow_early_data_cb_fn cb, void *arg); +/* store the default cipher strings inside the library */ +const char *OSSL_default_cipher_list(void); +const char *OSSL_default_ciphersuites(void); + # ifdef __cplusplus } # endif diff --git a/include/openssl/store.h b/include/openssl/store.h index fa5ed1b1..9200fd0c 100644 --- a/include/openssl/store.h +++ b/include/openssl/store.h @@ -85,7 +85,7 @@ OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx); int OSSL_STORE_eof(OSSL_STORE_CTX *ctx); /* - * Check if an error occured + * Check if an error occurred * Returns 1 if it did, 0 otherwise. */ int OSSL_STORE_error(OSSL_STORE_CTX *ctx); @@ -117,7 +117,7 @@ int OSSL_STORE_close(OSSL_STORE_CTX *ctx); * Functions to generate OSSL_STORE_INFOs, one function for each type we * support having in them, as well as a generic constructor. * - * In all cases, ownership of the object is transfered to the OSSL_STORE_INFO + * In all cases, ownership of the object is transferred to the OSSL_STORE_INFO * and will therefore be freed when the OSSL_STORE_INFO is freed. */ OSSL_STORE_INFO *OSSL_STORE_INFO_new_NAME(char *name); diff --git a/include/openssl/x509.h b/include/openssl/x509.h index 7f80da3c..6e4d1e76 100644 --- a/include/openssl/x509.h +++ b/include/openssl/x509.h @@ -569,6 +569,8 @@ int X509_get_signature_nid(const X509 *x); # ifndef OPENSSL_NO_SM2 void X509_set0_sm2_id(X509 *x, ASN1_OCTET_STRING *sm2_id); ASN1_OCTET_STRING *X509_get0_sm2_id(X509 *x); +void X509_REQ_set0_sm2_id(X509_REQ *x, ASN1_OCTET_STRING *sm2_id); +ASN1_OCTET_STRING *X509_REQ_get0_sm2_id(X509_REQ *x); # endif int X509_trusted(const X509 *x); diff --git a/include/openssl/x509err.h b/include/openssl/x509err.h index 78d1c893..f04db92d 100644 --- a/include/openssl/x509err.h +++ b/include/openssl/x509err.h @@ -28,6 +28,7 @@ int ERR_load_X509_strings(void); # define X509_F_BY_FILE_CTRL 101 # define X509_F_CHECK_NAME_CONSTRAINTS 149 # define X509_F_CHECK_POLICY 145 +# define X509_F_COMMON_VERIFY_SM2 165 # define X509_F_DANE_I2D 107 # define X509_F_DIR_CTRL 102 # define X509_F_GET_CERT_BY_SUBJECT 103 @@ -71,6 +72,8 @@ int ERR_load_X509_strings(void); # define X509_F_X509_REQ_PRINT_EX 121 # define X509_F_X509_REQ_PRINT_FP 122 # define X509_F_X509_REQ_TO_X509 123 +# define X509_F_X509_REQ_VERIFY 163 +# define X509_F_X509_REQ_VERIFY_SM2 164 # define X509_F_X509_STORE_ADD_CERT 124 # define X509_F_X509_STORE_ADD_CRL 125 # define X509_F_X509_STORE_ADD_LOOKUP 157 @@ -99,6 +102,7 @@ int ERR_load_X509_strings(void); # define X509_R_CRL_ALREADY_DELTA 127 # define X509_R_CRL_VERIFY_FAILURE 131 # define X509_R_IDP_MISMATCH 128 +# define X509_R_INVALID_ATTRIBUTES 138 # define X509_R_INVALID_DIRECTORY 113 # define X509_R_INVALID_FIELD_NAME 119 # define X509_R_INVALID_TRUST 123 diff --git a/providers/build.info b/providers/build.info index f379f740..192a5def 100644 --- a/providers/build.info +++ b/providers/build.info @@ -20,6 +20,6 @@ IF[{- !$disabled{legacy} -}] SOURCE[legacy]=legacy.ld GENERATE[legacy.ld]=../util/providers.num ENDIF - INCLUDE[legacy]=.. ../include ../crypto/include + INCLUDE[legacy]=.. ../include ../crypto/include common/include DEPEND[legacy]=../libcrypto ENDIF diff --git a/providers/common/build.info b/providers/common/build.info index 1617467d..500ef64b 100644 --- a/providers/common/build.info +++ b/providers/common/build.info @@ -1,4 +1,4 @@ SUBDIRS=digests ciphers SOURCE[../../libcrypto]=\ - provider_err.c + provider_err.c provlib.c diff --git a/providers/common/ciphers/aes.c b/providers/common/ciphers/aes.c index 8d91ff48..a151a8b3 100644 --- a/providers/common/ciphers/aes.c +++ b/providers/common/ciphers/aes.c @@ -27,13 +27,6 @@ static OSSL_OP_cipher_final_fn aes_stream_final; static OSSL_OP_cipher_cipher_fn aes_cipher; static OSSL_OP_cipher_freectx_fn aes_freectx; static OSSL_OP_cipher_dupctx_fn aes_dupctx; -static OSSL_OP_cipher_key_length_fn key_length_256; -static OSSL_OP_cipher_key_length_fn key_length_192; -static OSSL_OP_cipher_key_length_fn key_length_128; -static OSSL_OP_cipher_iv_length_fn iv_length_16; -static OSSL_OP_cipher_iv_length_fn iv_length_0; -static OSSL_OP_cipher_block_size_fn block_size_16; -static OSSL_OP_cipher_block_size_fn block_size_1; static OSSL_OP_cipher_ctx_get_params_fn aes_ctx_get_params; static OSSL_OP_cipher_ctx_set_params_fn aes_ctx_set_params; @@ -255,69 +248,82 @@ static int aes_cipher(void *vctx, return 1; } -#define IMPLEMENT_new_params(lcmode, UCMODE) \ - static OSSL_OP_cipher_get_params_fn aes_##lcmode##_get_params; \ - static int aes_##lcmode##_get_params(const OSSL_PARAM params[]) \ +#define IMPLEMENT_cipher(lcmode, UCMODE, flags, kbits, blkbits, ivbits) \ + static OSSL_OP_cipher_get_params_fn aes_##kbits##_##lcmode##_get_params; \ + static int aes_##kbits##_##lcmode##_get_params(OSSL_PARAM params[]) \ { \ - const OSSL_PARAM *p; \ - \ - p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_MODE); \ - if (p != NULL && !OSSL_PARAM_set_int(p, EVP_CIPH_##UCMODE##_MODE)) \ - return 0; \ + OSSL_PARAM *p; \ + \ + p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_MODE); \ + if (p != NULL) { \ + if (!OSSL_PARAM_set_int(p, EVP_CIPH_##UCMODE##_MODE)) \ + return 0; \ + } \ + p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_FLAGS); \ + if (p != NULL) { \ + if (!OSSL_PARAM_set_ulong(p, (flags))) \ + return 0; \ + } \ + p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_KEYLEN); \ + if (p != NULL) { \ + if (!OSSL_PARAM_set_int(p, (kbits) / 8)) \ + return 0; \ + } \ + p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_BLOCK_SIZE); \ + if (p != NULL) { \ + if (!OSSL_PARAM_set_int(p, (blkbits) / 8)) \ + return 0; \ + } \ + p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_IVLEN); \ + if (p != NULL) { \ + if (!OSSL_PARAM_set_int(p, (ivbits) / 8)) \ + return 0; \ + } \ \ return 1; \ - } - -#define IMPLEMENT_new_ctx(lcmode, UCMODE, len) \ - static OSSL_OP_cipher_newctx_fn aes_##len##_##lcmode##_newctx; \ - static void *aes_##len##_##lcmode##_newctx(void *provctx) \ + } \ + static OSSL_OP_cipher_newctx_fn aes_##kbits##_##lcmode##_newctx; \ + static void *aes_##kbits##_##lcmode##_newctx(void *provctx) \ { \ PROV_AES_KEY *ctx = OPENSSL_zalloc(sizeof(*ctx)); \ \ ctx->pad = 1; \ - ctx->keylen = (len / 8); \ + ctx->keylen = ((kbits) / 8); \ ctx->ciph = PROV_AES_CIPHER_##lcmode(ctx->keylen); \ ctx->mode = EVP_CIPH_##UCMODE##_MODE; \ return ctx; \ } /* ECB */ -IMPLEMENT_new_params(ecb, ECB) -IMPLEMENT_new_ctx(ecb, ECB, 256) -IMPLEMENT_new_ctx(ecb, ECB, 192) -IMPLEMENT_new_ctx(ecb, ECB, 128) +IMPLEMENT_cipher(ecb, ECB, 0, 256, 128, 0) +IMPLEMENT_cipher(ecb, ECB, 0, 192, 128, 0) +IMPLEMENT_cipher(ecb, ECB, 0, 128, 128, 0) /* CBC */ -IMPLEMENT_new_params(cbc, CBC) -IMPLEMENT_new_ctx(cbc, CBC, 256) -IMPLEMENT_new_ctx(cbc, CBC, 192) -IMPLEMENT_new_ctx(cbc, CBC, 128) +IMPLEMENT_cipher(cbc, CBC, 0, 256, 128, 128) +IMPLEMENT_cipher(cbc, CBC, 0, 192, 128, 128) +IMPLEMENT_cipher(cbc, CBC, 0, 128, 128, 128) /* OFB */ -IMPLEMENT_new_params(ofb, OFB) -IMPLEMENT_new_ctx(ofb, OFB, 256) -IMPLEMENT_new_ctx(ofb, OFB, 192) -IMPLEMENT_new_ctx(ofb, OFB, 128) +IMPLEMENT_cipher(ofb, OFB, 0, 256, 8, 128) +IMPLEMENT_cipher(ofb, OFB, 0, 192, 8, 128) +IMPLEMENT_cipher(ofb, OFB, 0, 128, 8, 128) /* CFB */ -IMPLEMENT_new_params(cfb, CFB) -IMPLEMENT_new_params(cfb1, CFB) -IMPLEMENT_new_params(cfb8, CFB) -IMPLEMENT_new_ctx(cfb, CFB, 256) -IMPLEMENT_new_ctx(cfb, CFB, 192) -IMPLEMENT_new_ctx(cfb, CFB, 128) -IMPLEMENT_new_ctx(cfb1, CFB, 256) -IMPLEMENT_new_ctx(cfb1, CFB, 192) -IMPLEMENT_new_ctx(cfb1, CFB, 128) -IMPLEMENT_new_ctx(cfb8, CFB, 256) -IMPLEMENT_new_ctx(cfb8, CFB, 192) -IMPLEMENT_new_ctx(cfb8, CFB, 128) +IMPLEMENT_cipher(cfb, CFB, 0, 256, 8, 128) +IMPLEMENT_cipher(cfb, CFB, 0, 192, 8, 128) +IMPLEMENT_cipher(cfb, CFB, 0, 128, 8, 128) +IMPLEMENT_cipher(cfb1, CFB, 0, 256, 8, 128) +IMPLEMENT_cipher(cfb1, CFB, 0, 192, 8, 128) +IMPLEMENT_cipher(cfb1, CFB, 0, 128, 8, 128) +IMPLEMENT_cipher(cfb8, CFB, 0, 256, 8, 128) +IMPLEMENT_cipher(cfb8, CFB, 0, 192, 8, 128) +IMPLEMENT_cipher(cfb8, CFB, 0, 128, 8, 128) /* CTR */ -IMPLEMENT_new_params(ctr, CTR) -IMPLEMENT_new_ctx(ctr, CTR, 256) -IMPLEMENT_new_ctx(ctr, CTR, 192) -IMPLEMENT_new_ctx(ctr, CTR, 128) +IMPLEMENT_cipher(ctr, CTR, 0, 256, 8, 128) +IMPLEMENT_cipher(ctr, CTR, 0, 192, 8, 128) +IMPLEMENT_cipher(ctr, CTR, 0, 128, 8, 128) static void aes_freectx(void *vctx) { @@ -340,51 +346,36 @@ static void *aes_dupctx(void *ctx) return ret; } -static size_t key_length_256(void) -{ - return 256 / 8; -} - -static size_t key_length_192(void) -{ - return 192 / 8; -} - -static size_t key_length_128(void) -{ - return 128 / 8; -} - -static size_t iv_length_16(void) -{ - return 16; -} - -static size_t iv_length_0(void) -{ - return 0; -} - -static size_t block_size_16(void) -{ - return 16; -} - -static size_t block_size_1(void) -{ - return 1; -} - -static int aes_ctx_get_params(void *vctx, const OSSL_PARAM params[]) +static int aes_ctx_get_params(void *vctx, OSSL_PARAM params[]) { PROV_AES_KEY *ctx = (PROV_AES_KEY *)vctx; - const OSSL_PARAM *p; + OSSL_PARAM *p; p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_PADDING); if (p != NULL && !OSSL_PARAM_set_int(p, ctx->pad)) { PROVerr(PROV_F_AES_CTX_GET_PARAMS, PROV_R_FAILED_TO_SET_PARAMETER); return 0; } + p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_IV); + if (p != NULL + && !OSSL_PARAM_set_octet_ptr(p, &ctx->iv, AES_BLOCK_SIZE) + && !OSSL_PARAM_set_octet_string(p, &ctx->iv, AES_BLOCK_SIZE)) { + PROVerr(PROV_F_AES_CTX_GET_PARAMS, + PROV_R_FAILED_TO_SET_PARAMETER); + return 0; + } + p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_NUM); + if (p != NULL && !OSSL_PARAM_set_size_t(p, ctx->num)) { + PROVerr(PROV_F_AES_CTX_GET_PARAMS, + PROV_R_FAILED_TO_SET_PARAMETER); + return 0; + } + p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_KEYLEN); + if (p != NULL && !OSSL_PARAM_set_int(p, ctx->keylen)) { + PROVerr(PROV_F_AES_CTX_GET_PARAMS, + PROV_R_FAILED_TO_SET_PARAMETER); + return 0; + } return 1; } @@ -394,22 +385,45 @@ static int aes_ctx_set_params(void *vctx, const OSSL_PARAM params[]) PROV_AES_KEY *ctx = (PROV_AES_KEY *)vctx; const OSSL_PARAM *p; - p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_PADDING); + p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_PADDING); if (p != NULL) { int pad; if (!OSSL_PARAM_get_int(p, &pad)) { - PROVerr(PROV_F_AES_CTX_SET_PARAMS, PROV_R_FAILED_TO_GET_PARAMETER); + PROVerr(PROV_F_AES_CTX_SET_PARAMS, + PROV_R_FAILED_TO_GET_PARAMETER); return 0; } ctx->pad = pad ? 1 : 0; } + p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_NUM); + if (p != NULL) { + int num; + + if (!OSSL_PARAM_get_int(p, &num)) { + PROVerr(PROV_F_AES_CTX_SET_PARAMS, + PROV_R_FAILED_TO_GET_PARAMETER); + return 0; + } + ctx->num = num; + } + p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_KEYLEN); + if (p != NULL) { + int keylen; + + if (!OSSL_PARAM_get_int(p, &keylen)) { + PROVerr(PROV_F_AES_CTX_SET_PARAMS, + PROV_R_FAILED_TO_GET_PARAMETER); + return 0; + } + ctx->keylen = keylen; + } return 1; } -#define IMPLEMENT_block_funcs(mode, keylen, ivlen) \ - const OSSL_DISPATCH aes##keylen##mode##_functions[] = { \ - { OSSL_FUNC_CIPHER_NEWCTX, (void (*)(void))aes_##keylen##_##mode##_newctx }, \ +#define IMPLEMENT_block_funcs(mode, kbits) \ + const OSSL_DISPATCH aes##kbits##mode##_functions[] = { \ + { OSSL_FUNC_CIPHER_NEWCTX, (void (*)(void))aes_##kbits##_##mode##_newctx }, \ { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))aes_einit }, \ { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))aes_dinit }, \ { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))aes_block_update }, \ @@ -417,18 +431,15 @@ static int aes_ctx_set_params(void *vctx, const OSSL_PARAM params[]) { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))aes_cipher }, \ { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))aes_freectx }, \ { OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void))aes_dupctx }, \ - { OSSL_FUNC_CIPHER_KEY_LENGTH, (void (*)(void))key_length_##keylen }, \ - { OSSL_FUNC_CIPHER_IV_LENGTH, (void (*)(void))iv_length_##ivlen }, \ - { OSSL_FUNC_CIPHER_BLOCK_SIZE, (void (*)(void))block_size_16 }, \ - { OSSL_FUNC_CIPHER_GET_PARAMS, (void (*)(void))aes_##mode##_get_params }, \ + { OSSL_FUNC_CIPHER_GET_PARAMS, (void (*)(void))aes_##kbits##_##mode##_get_params }, \ { OSSL_FUNC_CIPHER_CTX_GET_PARAMS, (void (*)(void))aes_ctx_get_params }, \ { OSSL_FUNC_CIPHER_CTX_SET_PARAMS, (void (*)(void))aes_ctx_set_params }, \ { 0, NULL } \ }; -#define IMPLEMENT_stream_funcs(mode, keylen, ivlen) \ - const OSSL_DISPATCH aes##keylen##mode##_functions[] = { \ - { OSSL_FUNC_CIPHER_NEWCTX, (void (*)(void))aes_##keylen##_##mode##_newctx }, \ +#define IMPLEMENT_stream_funcs(mode, kbits) \ + const OSSL_DISPATCH aes##kbits##mode##_functions[] = { \ + { OSSL_FUNC_CIPHER_NEWCTX, (void (*)(void))aes_##kbits##_##mode##_newctx }, \ { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))aes_einit }, \ { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))aes_dinit }, \ { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))aes_stream_update }, \ @@ -436,42 +447,39 @@ static int aes_ctx_set_params(void *vctx, const OSSL_PARAM params[]) { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))aes_cipher }, \ { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))aes_freectx }, \ { OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void))aes_dupctx }, \ - { OSSL_FUNC_CIPHER_KEY_LENGTH, (void (*)(void))key_length_##keylen }, \ - { OSSL_FUNC_CIPHER_IV_LENGTH, (void (*)(void))iv_length_##ivlen }, \ - { OSSL_FUNC_CIPHER_BLOCK_SIZE, (void (*)(void))block_size_1 }, \ - { OSSL_FUNC_CIPHER_GET_PARAMS, (void (*)(void))aes_##mode##_get_params }, \ + { OSSL_FUNC_CIPHER_GET_PARAMS, (void (*)(void))aes_##kbits##_##mode##_get_params }, \ { OSSL_FUNC_CIPHER_CTX_GET_PARAMS, (void (*)(void))aes_ctx_get_params }, \ { OSSL_FUNC_CIPHER_CTX_SET_PARAMS, (void (*)(void))aes_ctx_set_params }, \ { 0, NULL } \ }; /* ECB */ -IMPLEMENT_block_funcs(ecb, 256, 0) -IMPLEMENT_block_funcs(ecb, 192, 0) -IMPLEMENT_block_funcs(ecb, 128, 0) +IMPLEMENT_block_funcs(ecb, 256) +IMPLEMENT_block_funcs(ecb, 192) +IMPLEMENT_block_funcs(ecb, 128) /* CBC */ -IMPLEMENT_block_funcs(cbc, 256, 16) -IMPLEMENT_block_funcs(cbc, 192, 16) -IMPLEMENT_block_funcs(cbc, 128, 16) +IMPLEMENT_block_funcs(cbc, 256) +IMPLEMENT_block_funcs(cbc, 192) +IMPLEMENT_block_funcs(cbc, 128) /* OFB */ -IMPLEMENT_stream_funcs(ofb, 256, 16) -IMPLEMENT_stream_funcs(ofb, 192, 16) -IMPLEMENT_stream_funcs(ofb, 128, 16) +IMPLEMENT_stream_funcs(ofb, 256) +IMPLEMENT_stream_funcs(ofb, 192) +IMPLEMENT_stream_funcs(ofb, 128) /* CFB */ -IMPLEMENT_stream_funcs(cfb, 256, 16) -IMPLEMENT_stream_funcs(cfb, 192, 16) -IMPLEMENT_stream_funcs(cfb, 128, 16) -IMPLEMENT_stream_funcs(cfb1, 256, 16) -IMPLEMENT_stream_funcs(cfb1, 192, 16) -IMPLEMENT_stream_funcs(cfb1, 128, 16) -IMPLEMENT_stream_funcs(cfb8, 256, 16) -IMPLEMENT_stream_funcs(cfb8, 192, 16) -IMPLEMENT_stream_funcs(cfb8, 128, 16) +IMPLEMENT_stream_funcs(cfb, 256) +IMPLEMENT_stream_funcs(cfb, 192) +IMPLEMENT_stream_funcs(cfb, 128) +IMPLEMENT_stream_funcs(cfb1, 256) +IMPLEMENT_stream_funcs(cfb1, 192) +IMPLEMENT_stream_funcs(cfb1, 128) +IMPLEMENT_stream_funcs(cfb8, 256) +IMPLEMENT_stream_funcs(cfb8, 192) +IMPLEMENT_stream_funcs(cfb8, 128) /* CTR */ -IMPLEMENT_stream_funcs(ctr, 256, 16) -IMPLEMENT_stream_funcs(ctr, 192, 16) -IMPLEMENT_stream_funcs(ctr, 128, 16) +IMPLEMENT_stream_funcs(ctr, 256) +IMPLEMENT_stream_funcs(ctr, 192) +IMPLEMENT_stream_funcs(ctr, 128) diff --git a/providers/common/ciphers/aes_basic.c b/providers/common/ciphers/aes_basic.c index 0f642966..619386ca 100644 --- a/providers/common/ciphers/aes_basic.c +++ b/providers/common/ciphers/aes_basic.c @@ -606,9 +606,9 @@ static const PROV_AES_CIPHER aes_##mode = { \ }; \ const PROV_AES_CIPHER *PROV_AES_CIPHER_##mode(size_t keylen) \ { \ - if ((keylen == 128 && S390X_aes_128_##mode##_CAPABLE) \ - || (keylen == 192 && S390X_aes_192_##mode##_CAPABLE) \ - || (keylen == 256 && S390X_aes_256_##mode##_CAPABLE)) \ + if ((keylen == 16 && S390X_aes_128_##mode##_CAPABLE) \ + || (keylen == 24 && S390X_aes_192_##mode##_CAPABLE) \ + || (keylen == 32 && S390X_aes_256_##mode##_CAPABLE)) \ return &s390x_aes_##mode; \ \ return &aes_##mode; \ diff --git a/providers/common/ciphers/build.info b/providers/common/ciphers/build.info index f4ff2ce8..fd49ccb9 100644 --- a/providers/common/ciphers/build.info +++ b/providers/common/ciphers/build.info @@ -2,3 +2,7 @@ LIBS=../../../libcrypto SOURCE[../../../libcrypto]=\ block.c aes.c aes_basic.c INCLUDE[../../../libcrypto]=. ../../../crypto + +SOURCE[../../fips]=\ + block.c aes.c aes_basic.c +INCLUDE[../../fips]=. ../../../crypto diff --git a/providers/common/digests/build.info b/providers/common/digests/build.info index b98df29f..513da687 100644 --- a/providers/common/digests/build.info +++ b/providers/common/digests/build.info @@ -1,5 +1,5 @@ SOURCE[../../../libcrypto]=\ - sha2.c + sha2_prov.c sha3_prov.c SOURCE[../../fips]=\ - sha2.c + sha2_prov.c sha3_prov.c diff --git a/providers/common/digests/sha2.c b/providers/common/digests/sha2.c deleted file mode 100644 index 5b219ab7..00000000 --- a/providers/common/digests/sha2.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the Apache License 2.0 (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include -#include -#include -#include "internal/provider_algs.h" - -/* - * Forward declaration of everything implemented here. This is not strictly - * necessary for the compiler, but provides an assurance that the signatures - * of the functions in the dispatch table are correct. - */ -static OSSL_OP_digest_newctx_fn sha256_newctx; -#if 0 /* Not defined here */ -static OSSL_OP_digest_init_fn sha256_init; -static OSSL_OP_digest_update_fn sha256_update; -#endif -static OSSL_OP_digest_final_fn sha256_final; -static OSSL_OP_digest_freectx_fn sha256_freectx; -static OSSL_OP_digest_dupctx_fn sha256_dupctx; -static OSSL_OP_digest_size_fn sha256_size; -static OSSL_OP_digest_block_size_fn sha256_size; - -static int sha256_final(void *ctx, - unsigned char *md, size_t *mdl, size_t mdsz) -{ - if (mdsz >= SHA256_DIGEST_LENGTH - && SHA256_Final(md, ctx)) { - *mdl = SHA256_DIGEST_LENGTH; - return 1; - } - - return 0; -} - -static void *sha256_newctx(void *provctx) -{ - SHA256_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx)); - - return ctx; -} - -static void sha256_freectx(void *vctx) -{ - SHA256_CTX *ctx = (SHA256_CTX *)vctx; - - OPENSSL_clear_free(ctx, sizeof(*ctx)); -} - -static void *sha256_dupctx(void *ctx) -{ - SHA256_CTX *in = (SHA256_CTX *)ctx; - SHA256_CTX *ret = OPENSSL_malloc(sizeof(*ret)); - - *ret = *in; - - return ret; -} - -static size_t sha256_size(void) -{ - return SHA256_DIGEST_LENGTH; -} - -static size_t sha256_block_size(void) -{ - return SHA256_CBLOCK; -} - -const OSSL_DISPATCH sha256_functions[] = { - { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))sha256_newctx }, - { OSSL_FUNC_DIGEST_INIT, (void (*)(void))SHA256_Init }, - { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))SHA256_Update }, - { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))sha256_final }, - { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))sha256_freectx }, - { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))sha256_dupctx }, - { OSSL_FUNC_DIGEST_SIZE, (void (*)(void))sha256_size }, - { OSSL_FUNC_DIGEST_BLOCK_SIZE, (void (*)(void))sha256_block_size }, - { 0, NULL } -}; diff --git a/providers/common/digests/sha2_prov.c b/providers/common/digests/sha2_prov.c new file mode 100644 index 00000000..0e49ae67 --- /dev/null +++ b/providers/common/digests/sha2_prov.c @@ -0,0 +1,65 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include +#include +#include +#include +#include +#include "internal/core_mkdigest.h" +#include "internal/provider_algs.h" +#include "internal/sha.h" + +static OSSL_OP_digest_set_params_fn sha1_set_params; + +/* Special set_params method for SSL3 */ +static int sha1_set_params(void *vctx, const OSSL_PARAM params[]) +{ + const OSSL_PARAM *p; + SHA_CTX *ctx = (SHA_CTX *)vctx; + + if (ctx != NULL && params != NULL) { + p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS); + if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING) + return sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, p->data_size, + p->data); + } + return 0; +} + +OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(sha1, SHA_CTX, + SHA_CBLOCK, SHA_DIGEST_LENGTH, + SHA1_Init, SHA1_Update, SHA1_Final, + sha1_set_params) + +OSSL_FUNC_DIGEST_CONSTRUCT(sha224, SHA256_CTX, + SHA256_CBLOCK, SHA224_DIGEST_LENGTH, + SHA224_Init, SHA224_Update, SHA224_Final) + +OSSL_FUNC_DIGEST_CONSTRUCT(sha256, SHA256_CTX, + SHA256_CBLOCK, SHA256_DIGEST_LENGTH, + SHA256_Init, SHA256_Update, SHA256_Final) + +OSSL_FUNC_DIGEST_CONSTRUCT(sha384, SHA512_CTX, + SHA512_CBLOCK, SHA384_DIGEST_LENGTH, + SHA384_Init, SHA384_Update, SHA384_Final) + +OSSL_FUNC_DIGEST_CONSTRUCT(sha512, SHA512_CTX, + SHA512_CBLOCK, SHA512_DIGEST_LENGTH, + SHA512_Init, SHA512_Update, SHA512_Final) + +OSSL_FUNC_DIGEST_CONSTRUCT(sha512_224, SHA512_CTX, + SHA512_CBLOCK, SHA224_DIGEST_LENGTH, + sha512_224_init, SHA512_Update, SHA512_Final) + +OSSL_FUNC_DIGEST_CONSTRUCT(sha512_256, SHA512_CTX, + SHA512_CBLOCK, SHA256_DIGEST_LENGTH, + sha512_256_init, SHA512_Update, SHA512_Final) + diff --git a/providers/common/digests/sha3_prov.c b/providers/common/digests/sha3_prov.c new file mode 100644 index 00000000..15cd670a --- /dev/null +++ b/providers/common/digests/sha3_prov.c @@ -0,0 +1,278 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include +#include +#include +#include +#include "internal/sha3.h" +#include "internal/core_mkdigest.h" +#include "internal/provider_algs.h" + +/* + * Forward declaration of any unique methods implemented here. This is not strictly + * necessary for the compiler, but provides an assurance that the signatures + * of the functions in the dispatch table are correct. + */ +static OSSL_OP_digest_init_fn keccak_init; +static OSSL_OP_digest_update_fn keccak_update; +static OSSL_OP_digest_final_fn keccak_final; +static OSSL_OP_digest_freectx_fn keccak_freectx; +static OSSL_OP_digest_dupctx_fn keccak_dupctx; +static OSSL_OP_digest_set_params_fn shake_set_params; +static sha3_absorb_fn generic_sha3_absorb; +static sha3_final_fn generic_sha3_final; + +#if defined(OPENSSL_CPUID_OBJ) && defined(__s390__) && defined(KECCAK1600_ASM) +/* + * IBM S390X support + */ +# include "s390x_arch.h" +# define S390_SHA3 1 +# define S390_SHA3_CAPABLE(name) \ + ((OPENSSL_s390xcap_P.kimd[0] & S390X_CAPBIT(S390X_##name)) && \ + (OPENSSL_s390xcap_P.klmd[0] & S390X_CAPBIT(S390X_##name))) + +#endif + +static int keccak_init(void *vctx) +{ + /* The newctx() handles most of the ctx fixed setup. */ + sha3_reset((KECCAK1600_CTX *)vctx); + return 1; +} + +static int keccak_update(void *vctx, const unsigned char *inp, size_t len) +{ + KECCAK1600_CTX *ctx = vctx; + const size_t bsz = ctx->block_size; + size_t num, rem; + + if (len == 0) + return 1; + + /* Is there anything in the buffer already ? */ + if ((num = ctx->bufsz) != 0) { + /* Calculate how much space is left in the buffer */ + rem = bsz - num; + /* If the new input does not fill the buffer then just add it */ + if (len < rem) { + memcpy(ctx->buf + num, inp, len); + ctx->bufsz += len; + return 1; + } + /* otherwise fill up the buffer and absorb the buffer */ + memcpy(ctx->buf + num, inp, rem); + /* Update the input pointer */ + inp += rem; + len -= rem; + ctx->meth.absorb(ctx, ctx->buf, bsz); + ctx->bufsz = 0; + } + /* Absorb the input - rem = leftover part of the input < blocksize) */ + rem = ctx->meth.absorb(ctx, inp, len); + /* Copy the leftover bit of the input into the buffer */ + if (rem) { + memcpy(ctx->buf, inp + len - rem, rem); + ctx->bufsz = rem; + } + return 1; +} + +static int keccak_final(void *vctx, unsigned char *out, size_t *outl, + size_t outsz) +{ + int ret; + KECCAK1600_CTX *ctx = vctx; + + ret = ctx->meth.final(out, ctx); + *outl = ctx->md_size; + return ret; +} + +/*- + * Generic software version of the absorb() and final(). + */ +static size_t generic_sha3_absorb(void *vctx, const void *inp, size_t len) +{ + KECCAK1600_CTX *ctx = vctx; + + return SHA3_absorb(ctx->A, inp, len, ctx->block_size); +} + +static int generic_sha3_final(unsigned char *md, void *vctx) +{ + return sha3_final(md, (KECCAK1600_CTX *)vctx); +} + +static PROV_SHA3_METHOD sha3_generic_md = +{ + generic_sha3_absorb, + generic_sha3_final +}; + +#if defined(S390_SHA3) + +static sha3_absorb_fn s390x_sha3_absorb; +static sha3_final_fn s390x_sha3_final; +static sha3_final_fn s390x_shake_final; + +/*- + * The platform specific parts of the absorb() and final() for S390X. + */ +static size_t s390x_sha3_absorb(void *vctx, const void *inp, size_t len) +{ + KECCAK1600_CTX *ctx = vctx; + size_t rem = len % ctx->block_size; + + s390x_kimd(inp, len - rem, ctx->pad, ctx->A); + return rem; +} + +static int s390x_sha3_final(unsigned char *md, void *vctx) +{ + KECCAK1600_CTX *ctx = vctx; + + s390x_klmd(ctx->buf, ctx->bufsz, NULL, 0, ctx->pad, ctx->A); + memcpy(md, ctx->A, ctx->md_size); + return 1; +} + +static int s390x_shake_final(unsigned char *md, void *vctx) +{ + KECCAK1600_CTX *ctx = vctx; + + s390x_klmd(ctx->buf, ctx->bufsz, md, ctx->md_size, ctx->pad, ctx->A); + return 1; +} + +static PROV_SHA3_METHOD sha3_s390x_md = +{ + s390x_sha3_absorb, + s390x_sha3_final +}; + +static PROV_SHA3_METHOD shake_s390x_md = +{ + s390x_sha3_absorb, + s390x_shake_final +}; + +# define SHA3_SET_MD(uname, typ) \ + if (S390_SHA3_CAPABLE(uname)) { \ + ctx->pad = S390X_##uname; \ + ctx->meth = typ##_s390x_md; \ + } else { \ + ctx->meth = sha3_generic_md; \ + } +#else +# define SHA3_SET_MD(uname, typ) ctx->meth = sha3_generic_md; +#endif /* S390_SHA3 */ + +#define SHA3_newctx(typ, uname, name, bitlen, pad) \ +static OSSL_OP_digest_newctx_fn name##_newctx; \ +static void *name##_newctx(void *provctx) \ +{ \ + KECCAK1600_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx)); \ + \ + if (ctx == NULL) \ + return NULL; \ + sha3_init(ctx, pad, bitlen); \ + SHA3_SET_MD(uname, typ) \ + return ctx; \ +} + +#define KMAC_newctx(uname, bitlen, pad) \ +static OSSL_OP_digest_newctx_fn uname##_newctx; \ +static void *uname##_newctx(void *provctx) \ +{ \ + KECCAK1600_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx)); \ + \ + if (ctx == NULL) \ + return NULL; \ + keccak_kmac_init(ctx, pad, bitlen); \ + ctx->meth = sha3_generic_md; \ + return ctx; \ +} + +#define OSSL_FUNC_SHA3_DIGEST(name, bitlen, dgstsize, stparams) \ +static OSSL_OP_digest_size_fn name##_size; \ +static OSSL_OP_digest_block_size_fn name##_block_size; \ +static size_t name##_block_size(void) \ +{ \ + return SHA3_BLOCKSIZE(bitlen); \ +} \ +static size_t name##_size(void) \ +{ \ + return dgstsize; \ +} \ +const OSSL_DISPATCH name##_functions[] = { \ + { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))name##_newctx }, \ + { OSSL_FUNC_DIGEST_INIT, (void (*)(void))keccak_init }, \ + { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))keccak_update }, \ + { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))keccak_final }, \ + { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))keccak_freectx }, \ + { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))keccak_dupctx }, \ + { OSSL_FUNC_DIGEST_SIZE, (void (*)(void))name##_size }, \ + { OSSL_FUNC_DIGEST_BLOCK_SIZE, (void (*)(void))name##_block_size }, \ + { OSSL_FUNC_DIGEST_SET_PARAMS, (void (*)(void))stparams },\ +OSSL_FUNC_DIGEST_CONSTRUCT_END + +static void keccak_freectx(void *vctx) +{ + KECCAK1600_CTX *ctx = (KECCAK1600_CTX *)vctx; + + OPENSSL_clear_free(ctx, sizeof(*ctx)); +} + +static void *keccak_dupctx(void *ctx) +{ + KECCAK1600_CTX *in = (KECCAK1600_CTX *)ctx; + KECCAK1600_CTX *ret = OPENSSL_malloc(sizeof(*ret)); + + *ret = *in; + return ret; +} + +static int shake_set_params(void *vctx, const OSSL_PARAM params[]) +{ + const OSSL_PARAM *p; + KECCAK1600_CTX *ctx = (KECCAK1600_CTX *)vctx; + + if (ctx != NULL && params != NULL) { + p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_XOFLEN); + if (p != NULL && !OSSL_PARAM_get_size_t(p, &ctx->md_size)) + return 0; + return 1; + } + return 0; /* Null Parameter */ +} + +#define SHA3(bitlen) \ + SHA3_newctx(sha3, SHA3_##bitlen, sha3_##bitlen, bitlen, '\x06') \ + OSSL_FUNC_SHA3_DIGEST(sha3_##bitlen, bitlen, SHA3_MDSIZE(bitlen), NULL) + +#define SHAKE(bitlen) \ + SHA3_newctx(shake, SHAKE_##bitlen, shake_##bitlen, bitlen, '\x1f') \ + OSSL_FUNC_SHA3_DIGEST(shake_##bitlen, bitlen, SHA3_MDSIZE(bitlen), \ + shake_set_params) +#define KMAC(bitlen) \ + KMAC_newctx(keccak_kmac_##bitlen, bitlen, '\x04') \ + OSSL_FUNC_SHA3_DIGEST(keccak_kmac_##bitlen, bitlen, KMAC_MDSIZE(bitlen), \ + shake_set_params) + +SHA3(224) +SHA3(256) +SHA3(384) +SHA3(512) +SHAKE(128) +SHAKE(256) +KMAC(128) +KMAC(256) diff --git a/providers/common/include/internal/core_mkdigest.h b/providers/common/include/internal/core_mkdigest.h new file mode 100644 index 00000000..7225196d --- /dev/null +++ b/providers/common/include/internal/core_mkdigest.h @@ -0,0 +1,95 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CORE_MKDIGEST_H +# define OSSL_CORE_MKDIGEST_H + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# define OSSL_FUNC_DIGEST_ALLOC_METHODS(name, CTX_NAME) \ +static OSSL_OP_digest_newctx_fn name##_newctx; \ +static OSSL_OP_digest_freectx_fn name##_freectx; \ +static OSSL_OP_digest_dupctx_fn name##_dupctx; \ +static void *name##_newctx(void *prov_ctx) \ +{ \ + CTX_NAME *ctx = OPENSSL_zalloc(sizeof(*ctx)); \ + return ctx; \ +} \ +static void name##_freectx(void *vctx) \ +{ \ + CTX_NAME *ctx = (CTX_NAME *)vctx; \ + OPENSSL_clear_free(ctx, sizeof(*ctx)); \ +} \ +static void *name##_dupctx(void *ctx) \ +{ \ + CTX_NAME *in = (CTX_NAME *)ctx; \ + CTX_NAME *ret = OPENSSL_malloc(sizeof(*ret)); \ + *ret = *in; \ + return ret; \ +} + +# define OSSL_FUNC_DIGEST_SET_FINAL(name, dgstsize, fin) \ +static OSSL_OP_digest_final_fn name##_wrapfinal; \ +static int name##_wrapfinal(void *ctx, unsigned char *out, size_t *outl, size_t outsz) \ +{ \ + if (outsz >= dgstsize && fin(out, ctx)) { \ + *outl = dgstsize; \ + return 1; \ + } \ + return 0; \ +} + +# define OSSL_FUNC_DIGEST_COMMON(name, blksize, dgstsize, init, upd) \ +static OSSL_OP_digest_block_size_fn name##_block_size; \ +static OSSL_OP_digest_size_fn name##_size; \ +static size_t name##_block_size(void) \ +{ \ + return blksize; \ +} \ +static size_t name##_size(void) \ +{ \ + return dgstsize; \ +} \ +const OSSL_DISPATCH name##_functions[] = { \ + { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))name##_newctx }, \ + { OSSL_FUNC_DIGEST_INIT, (void (*)(void))init }, \ + { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))upd }, \ + { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))name##_wrapfinal }, \ + { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))name##_freectx }, \ + { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))name##_dupctx }, \ + { OSSL_FUNC_DIGEST_SIZE, (void (*)(void))name##_size }, \ + { OSSL_FUNC_DIGEST_BLOCK_SIZE, (void (*)(void))name##_block_size }, + +# define OSSL_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, init, upd, fin) \ +OSSL_FUNC_DIGEST_ALLOC_METHODS(name, CTX) \ +OSSL_FUNC_DIGEST_SET_FINAL(name, dgstsize, fin) \ +OSSL_FUNC_DIGEST_COMMON(name, blksize, dgstsize, init, upd) + +# define OSSL_FUNC_DIGEST_CONSTRUCT_END \ + { 0, NULL } \ +}; + +# define OSSL_FUNC_DIGEST_CONSTRUCT(name, CTX, blksize, dgstsize, init, upd, fin) \ +OSSL_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, init, upd, fin) \ +OSSL_FUNC_DIGEST_CONSTRUCT_END + +# define OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(name, CTX, blksize, dgstsize, init, upd, fin, setparams) \ +OSSL_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, init, upd, fin) \ + { OSSL_FUNC_DIGEST_SET_PARAMS, (void (*)(void))setparams }, \ +OSSL_FUNC_DIGEST_CONSTRUCT_END + +# ifdef __cplusplus +} +# endif + +#endif /* OSSL_CORE_MKDIGEST_H */ diff --git a/providers/common/include/internal/provider_algs.h b/providers/common/include/internal/provider_algs.h index dd9211bb..0e26da05 100644 --- a/providers/common/include/internal/provider_algs.h +++ b/providers/common/include/internal/provider_algs.h @@ -8,7 +8,32 @@ */ /* Digests */ +extern const OSSL_DISPATCH sha1_functions[]; +extern const OSSL_DISPATCH sha224_functions[]; extern const OSSL_DISPATCH sha256_functions[]; +extern const OSSL_DISPATCH sha384_functions[]; +extern const OSSL_DISPATCH sha512_functions[]; +extern const OSSL_DISPATCH sha512_224_functions[]; +extern const OSSL_DISPATCH sha512_256_functions[]; +extern const OSSL_DISPATCH sha3_224_functions[]; +extern const OSSL_DISPATCH sha3_256_functions[]; +extern const OSSL_DISPATCH sha3_384_functions[]; +extern const OSSL_DISPATCH sha3_512_functions[]; +extern const OSSL_DISPATCH keccak_kmac_128_functions[]; +extern const OSSL_DISPATCH keccak_kmac_256_functions[]; +extern const OSSL_DISPATCH shake_128_functions[]; +extern const OSSL_DISPATCH shake_256_functions[]; +extern const OSSL_DISPATCH blake2s256_functions[]; +extern const OSSL_DISPATCH blake2b512_functions[]; +extern const OSSL_DISPATCH md5_functions[]; +extern const OSSL_DISPATCH md5_sha1_functions[]; +extern const OSSL_DISPATCH sm3_functions[]; +extern const OSSL_DISPATCH nullmd_functions[]; +extern const OSSL_DISPATCH md2_functions[]; +extern const OSSL_DISPATCH md4_functions[]; +extern const OSSL_DISPATCH mdc2_functions[]; +extern const OSSL_DISPATCH wp_functions[]; +extern const OSSL_DISPATCH ripemd160_functions[]; /* Ciphers */ extern const OSSL_DISPATCH aes256ecb_functions[]; diff --git a/include/internal/o_str.h b/providers/common/include/internal/provider_ctx.h similarity index 51% rename from include/internal/o_str.h rename to providers/common/include/internal/provider_ctx.h index dc236caa..365667d1 100644 --- a/include/internal/o_str.h +++ b/providers/common/include/internal/provider_ctx.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,11 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef HEADER_O_STR_H -# define HEADER_O_STR_H - -# include /* to get size_t */ - -int OPENSSL_memcmp(const void *p1, const void *p2, size_t n); - -#endif +/* + * To be used anywhere the library context needs to be passed, such as to + * fetching functions. + */ +#define PROV_LIBRARY_CONTEXT_OF(provctx) (provctx) diff --git a/providers/common/include/internal/providercommon.h b/providers/common/include/internal/providercommon.h index e69de29b..d54fafa9 100644 --- a/providers/common/include/internal/providercommon.h +++ b/providers/common/include/internal/providercommon.h @@ -0,0 +1,14 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include + +const OSSL_PROVIDER *FIPS_get_provider(OPENSSL_CTX *ctx); + +const char *ossl_prov_util_nid_to_name(int nid); diff --git a/providers/common/provlib.c b/providers/common/provlib.c new file mode 100644 index 00000000..43da7cda --- /dev/null +++ b/providers/common/provlib.c @@ -0,0 +1,21 @@ +/* + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include "internal/providercommon.h" + +/* + * The FIPS provider has its own version of this in fipsprov.c because it does + * not have OBJ_nid2sn(); + */ +const char *ossl_prov_util_nid_to_name(int nid) +{ + return OBJ_nid2sn(nid); +} + diff --git a/providers/default/build.info b/providers/default/build.info index eab90a3e..985d681b 100644 --- a/providers/default/build.info +++ b/providers/default/build.info @@ -1,3 +1,4 @@ +SUBDIRS=digests LIBS=../../libcrypto SOURCE[../../libcrypto]=\ defltprov.c diff --git a/providers/default/defltprov.c b/providers/default/defltprov.c index 95b2abfd..76ef2bcf 100644 --- a/providers/default/defltprov.c +++ b/providers/default/defltprov.c @@ -32,10 +32,9 @@ static const OSSL_ITEM *deflt_get_param_types(const OSSL_PROVIDER *prov) return deflt_param_types; } -static int deflt_get_params(const OSSL_PROVIDER *prov, - const OSSL_PARAM params[]) +static int deflt_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]) { - const OSSL_PARAM *p; + OSSL_PARAM *p; p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME); if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL Default Provider")) @@ -51,7 +50,42 @@ static int deflt_get_params(const OSSL_PROVIDER *prov, } static const OSSL_ALGORITHM deflt_digests[] = { + { "SHA1", "default=yes", sha1_functions }, + + { "SHA224", "default=yes", sha224_functions }, { "SHA256", "default=yes", sha256_functions }, + { "SHA384", "default=yes", sha384_functions }, + { "SHA512", "default=yes", sha512_functions }, + { "SHA512-224", "default=yes", sha512_224_functions }, + { "SHA512-256", "default=yes", sha512_256_functions }, + + { "SHA3-224", "default=yes", sha3_224_functions }, + { "SHA3-256", "default=yes", sha3_256_functions }, + { "SHA3-384", "default=yes", sha3_384_functions }, + { "SHA3-512", "default=yes", sha3_512_functions }, + + { "KMAC128", "default=yes", keccak_kmac_128_functions }, + { "KMAC256", "default=yes", keccak_kmac_256_functions }, + + { "SHAKE128", "default=yes", shake_128_functions }, + { "SHAKE256", "default=yes", shake_256_functions }, + +#ifndef OPENSSL_NO_BLAKE2 + { "BLAKE2s256", "default=yes", blake2s256_functions }, + { "BLAKE2b512", "default=yes", blake2b512_functions }, +#endif /* OPENSSL_NO_BLAKE2 */ + +#ifndef OPENSSL_NO_SM3 + { "SM3", "default=yes", sm3_functions }, +#endif /* OPENSSL_NO_SM3 */ + +#ifndef OPENSSL_NO_MD5 + { "MD5", "default=yes", md5_functions }, + { "MD5-SHA1", "default=yes", md5_sha1_functions }, +#endif /* OPENSSL_NO_MD5 */ + + /*{ "UNDEF", "default=yes", nullmd_functions }, */ + { NULL, NULL, NULL } }; @@ -109,6 +143,8 @@ int ossl_default_provider_init(const OSSL_PROVIDER *provider, const OSSL_DISPATCH **out, void **provctx) { + OSSL_core_get_library_context_fn *c_get_libctx = NULL; + for (; in->function_id != 0; in++) { switch (in->function_id) { case OSSL_FUNC_CORE_GET_PARAM_TYPES: @@ -117,12 +153,25 @@ int ossl_default_provider_init(const OSSL_PROVIDER *provider, case OSSL_FUNC_CORE_GET_PARAMS: c_get_params = OSSL_get_core_get_params(in); break; + case OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT: + c_get_libctx = OSSL_get_core_get_library_context(in); + break; default: /* Just ignore anything we don't understand */ break; } } + if (c_get_libctx == NULL) + return 0; + *out = deflt_dispatch_table; + + /* + * We want to make sure that all calls from this provider that requires + * a library context use the same context as the one used to call our + * functions. We do that by passing it along as the provider context. + */ + *provctx = c_get_libctx(provider); return 1; } diff --git a/crypto/blake2/blake2_impl.h b/providers/default/digests/blake2_impl.h similarity index 100% rename from crypto/blake2/blake2_impl.h rename to providers/default/digests/blake2_impl.h diff --git a/providers/default/digests/blake2_prov.c b/providers/default/digests/blake2_prov.c new file mode 100644 index 00000000..18a8d60b --- /dev/null +++ b/providers/default/digests/blake2_prov.c @@ -0,0 +1,40 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include "internal/blake2.h" +#include "internal/core_mkdigest.h" +#include "internal/provider_algs.h" + +OSSL_OP_digest_init_fn blake2s256_init; +OSSL_OP_digest_init_fn blake2b512_init; + +int blake2s256_init(void *ctx) +{ + BLAKE2S_PARAM P; + + blake2s_param_init(&P); + return blake2s_init((BLAKE2S_CTX *)ctx, &P); +} + +int blake2b512_init(void *ctx) +{ + BLAKE2B_PARAM P; + + blake2b_param_init(&P); + return blake2b_init((BLAKE2B_CTX *)ctx, &P); +} + +OSSL_FUNC_DIGEST_CONSTRUCT(blake2s256, BLAKE2S_CTX, + BLAKE2S_BLOCKBYTES, BLAKE2S_DIGEST_LENGTH, + blake2s256_init, blake2s_update, blake2s_final) + +OSSL_FUNC_DIGEST_CONSTRUCT(blake2b512, BLAKE2B_CTX, + BLAKE2B_BLOCKBYTES, BLAKE2B_DIGEST_LENGTH, + blake2b512_init, blake2b_update, blake2b_final) diff --git a/crypto/blake2/blake2b.c b/providers/default/digests/blake2b_prov.c similarity index 96% rename from crypto/blake2/blake2b.c rename to providers/default/digests/blake2b_prov.c index 813f9dde..88012704 100644 --- a/crypto/blake2/blake2b.c +++ b/providers/default/digests/blake2b_prov.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -17,10 +17,10 @@ #include #include #include - -#include "blake2_locl.h" #include "blake2_impl.h" +#include "internal/blake2.h" + static const uint64_t blake2b_IV[8] = { 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, @@ -122,7 +122,7 @@ void blake2b_param_set_salt(BLAKE2B_PARAM *P, const uint8_t *salt, size_t len) * Initialize the hashing context with the given parameter block. * Always returns 1. */ -int BLAKE2b_Init(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P) +int blake2b_init(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P) { blake2b_init_param(c, P); return 1; @@ -132,7 +132,7 @@ int BLAKE2b_Init(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P) * Initialize the hashing context with the given parameter block and key. * Always returns 1. */ -int BLAKE2b_Init_key(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P, const void *key) +int blake2b_init_key(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P, const void *key) { blake2b_init_param(c, P); @@ -141,7 +141,7 @@ int BLAKE2b_Init_key(BLAKE2B_CTX *c, const BLAKE2B_PARAM *P, const void *key) uint8_t block[BLAKE2B_BLOCKBYTES] = {0}; memcpy(block, key, P->key_length); - BLAKE2b_Update(c, block, BLAKE2B_BLOCKBYTES); + blake2b_update(c, block, BLAKE2B_BLOCKBYTES); OPENSSL_cleanse(block, BLAKE2B_BLOCKBYTES); } @@ -253,7 +253,7 @@ static void blake2b_compress(BLAKE2B_CTX *S, } /* Absorb the input data into the hash state. Always returns 1. */ -int BLAKE2b_Update(BLAKE2B_CTX *c, const void *data, size_t datalen) +int blake2b_update(BLAKE2B_CTX *c, const void *data, size_t datalen) { const uint8_t *in = data; size_t fill; @@ -301,7 +301,7 @@ int BLAKE2b_Update(BLAKE2B_CTX *c, const void *data, size_t datalen) * Calculate the final hash and save it in md. * Always returns 1. */ -int BLAKE2b_Final(unsigned char *md, BLAKE2B_CTX *c) +int blake2b_final(unsigned char *md, BLAKE2B_CTX *c) { uint8_t outbuffer[BLAKE2B_OUTBYTES] = {0}; uint8_t *target = outbuffer; diff --git a/crypto/blake2/blake2s.c b/providers/default/digests/blake2s_prov.c similarity index 95% rename from crypto/blake2/blake2s.c rename to providers/default/digests/blake2s_prov.c index 121f0d1a..a9c757ea 100644 --- a/crypto/blake2/blake2s.c +++ b/providers/default/digests/blake2s_prov.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -17,9 +17,8 @@ #include #include #include - -#include "blake2_locl.h" #include "blake2_impl.h" +#include "internal/blake2.h" static const uint32_t blake2s_IV[8] = { @@ -115,7 +114,7 @@ void blake2s_param_set_salt(BLAKE2S_PARAM *P, const uint8_t *salt, size_t len) * Initialize the hashing context with the given parameter block. * Always returns 1. */ -int BLAKE2s_Init(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P) +int blake2s_init(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P) { blake2s_init_param(c, P); return 1; @@ -125,7 +124,7 @@ int BLAKE2s_Init(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P) * Initialize the hashing context with the given parameter block and key. * Always returns 1. */ -int BLAKE2s_Init_key(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P, const void *key) +int blake2s_init_key(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P, const void *key) { blake2s_init_param(c, P); @@ -134,7 +133,7 @@ int BLAKE2s_Init_key(BLAKE2S_CTX *c, const BLAKE2S_PARAM *P, const void *key) uint8_t block[BLAKE2S_BLOCKBYTES] = {0}; memcpy(block, key, P->key_length); - BLAKE2s_Update(c, block, BLAKE2S_BLOCKBYTES); + blake2s_update(c, block, BLAKE2S_BLOCKBYTES); OPENSSL_cleanse(block, BLAKE2S_BLOCKBYTES); } @@ -244,7 +243,7 @@ static void blake2s_compress(BLAKE2S_CTX *S, } /* Absorb the input data into the hash state. Always returns 1. */ -int BLAKE2s_Update(BLAKE2S_CTX *c, const void *data, size_t datalen) +int blake2s_update(BLAKE2S_CTX *c, const void *data, size_t datalen) { const uint8_t *in = data; size_t fill; @@ -292,7 +291,7 @@ int BLAKE2s_Update(BLAKE2S_CTX *c, const void *data, size_t datalen) * Calculate the final hash and save it in md. * Always returns 1. */ -int BLAKE2s_Final(unsigned char *md, BLAKE2S_CTX *c) +int blake2s_final(unsigned char *md, BLAKE2S_CTX *c) { uint8_t outbuffer[BLAKE2S_OUTBYTES] = {0}; uint8_t *target = outbuffer; diff --git a/providers/default/digests/build.info b/providers/default/digests/build.info new file mode 100644 index 00000000..637436d3 --- /dev/null +++ b/providers/default/digests/build.info @@ -0,0 +1,17 @@ +SOURCE[../../../libcrypto]=\ + null_prov.c + +IF[{- !$disabled{blake2} -}] + SOURCE[../../../libcrypto]=\ + blake2_prov.c blake2b_prov.c blake2s_prov.c +ENDIF + +IF[{- !$disabled{sm3} -}] + SOURCE[../../../libcrypto]=\ + sm3_prov.c +ENDIF + +IF[{- !$disabled{md5} -}] + SOURCE[../../../libcrypto]=\ + md5_prov.c md5_sha1_prov.c +ENDIF diff --git a/providers/default/digests/md5_prov.c b/providers/default/digests/md5_prov.c new file mode 100644 index 00000000..81636f67 --- /dev/null +++ b/providers/default/digests/md5_prov.c @@ -0,0 +1,17 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include +#include "internal/core_mkdigest.h" +#include "internal/provider_algs.h" + +OSSL_FUNC_DIGEST_CONSTRUCT(md5, MD5_CTX, + MD5_CBLOCK, MD5_DIGEST_LENGTH, + MD5_Init, MD5_Update, MD5_Final) diff --git a/providers/default/digests/md5_sha1_prov.c b/providers/default/digests/md5_sha1_prov.c new file mode 100644 index 00000000..490134e7 --- /dev/null +++ b/providers/default/digests/md5_sha1_prov.c @@ -0,0 +1,40 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + + +#include +#include +#include +#include +#include +#include "internal/core_mkdigest.h" +#include "internal/md5_sha1.h" +#include "internal/provider_algs.h" + +static OSSL_OP_digest_set_params_fn md5_sha1_set_params; + +/* Special set_params method for SSL3 */ +static int md5_sha1_set_params(void *vctx, const OSSL_PARAM params[]) +{ + const OSSL_PARAM *p; + MD5_SHA1_CTX *ctx = (MD5_SHA1_CTX *)vctx; + + if (ctx != NULL && params != NULL) { + p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS); + if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING) + return md5_sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, p->data_size, + p->data); + } + return 0; +} + +OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(md5_sha1, MD5_SHA1_CTX, + MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH, + md5_sha1_init, md5_sha1_update, md5_sha1_final, + md5_sha1_set_params) diff --git a/providers/default/digests/null_prov.c b/providers/default/digests/null_prov.c new file mode 100644 index 00000000..d7644f4c --- /dev/null +++ b/providers/default/digests/null_prov.c @@ -0,0 +1,75 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include +#include "internal/provider_algs.h" + +static int nullmd_dummy = 1; + +static OSSL_OP_digest_init_fn nullmd_init; +static OSSL_OP_digest_update_fn nullmd_update; +static OSSL_OP_digest_final_fn nullmd_final; +static OSSL_OP_digest_newctx_fn nullmd_newctx; +static OSSL_OP_digest_freectx_fn nullmd_freectx; +static OSSL_OP_digest_dupctx_fn nullmd_dupctx; +static OSSL_OP_digest_size_fn nullmd_size; +static OSSL_OP_digest_block_size_fn nullmd_block_size; + +static size_t nullmd_block_size(void) +{ + return 0; +} + +static size_t nullmd_size(void) +{ + return 0; +} + +static int nullmd_init(void *vctx) +{ + return 1; +} + +static int nullmd_update(void *vctx, const unsigned char *inp, size_t bytes) +{ + return 1; +} + +static int nullmd_final(void *ctx, unsigned char *out, size_t *outl, size_t outsz) +{ + *outl = 0; + return 1; +} + +static void *nullmd_newctx(void *prov_ctx) +{ + return &nullmd_dummy; +} + +static void nullmd_freectx(void *vctx) +{ +} + +static void *nullmd_dupctx(void *ctx) +{ + return &nullmd_dummy; +} + +const OSSL_DISPATCH nullmd_functions[] = { + { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))nullmd_newctx }, + { OSSL_FUNC_DIGEST_INIT, (void (*)(void))nullmd_init }, + { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))nullmd_update }, + { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))nullmd_final }, + { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))nullmd_freectx }, + { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))nullmd_dupctx }, + { OSSL_FUNC_DIGEST_SIZE, (void (*)(void))nullmd_size }, + { OSSL_FUNC_DIGEST_BLOCK_SIZE, (void (*)(void))nullmd_block_size }, + { 0, NULL } +}; diff --git a/providers/default/digests/sm3_prov.c b/providers/default/digests/sm3_prov.c new file mode 100644 index 00000000..bd039a88 --- /dev/null +++ b/providers/default/digests/sm3_prov.c @@ -0,0 +1,17 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include "internal/sm3.h" +#include "internal/core_mkdigest.h" +#include "internal/provider_algs.h" + +OSSL_FUNC_DIGEST_CONSTRUCT(sm3, SM3_CTX, + SM3_CBLOCK, SM3_DIGEST_LENGTH, + sm3_init, sm3_update, sm3_final) diff --git a/providers/fips/fipsprov.c b/providers/fips/fipsprov.c index 7842f90f..8978d1bc 100644 --- a/providers/fips/fipsprov.c +++ b/providers/fips/fipsprov.c @@ -15,17 +15,69 @@ #include #include #include + /* TODO(3.0): Needed for dummy_evp_call(). To be removed */ #include +#include + #include "internal/cryptlib.h" #include "internal/property.h" #include "internal/evp_int.h" +#include "internal/provider_algs.h" +#include "internal/provider_ctx.h" +#include "internal/providercommon.h" +extern OSSL_core_thread_start_fn *c_thread_start; + +/* + * TODO(3.0): Should these be stored in the provider side provctx? Could they + * ever be different from one init to the next? Unfortunately we can't do this + * at the moment because c_put_error/c_add_error_vdata do not provide + * us with the OPENSSL_CTX as a parameter. + */ /* Functions provided by the core */ -static OSSL_core_get_param_types_fn *c_get_param_types = NULL; -static OSSL_core_get_params_fn *c_get_params = NULL; -static OSSL_core_put_error_fn *c_put_error = NULL; -static OSSL_core_add_error_vdata_fn *c_add_error_vdata = NULL; +static OSSL_core_get_param_types_fn *c_get_param_types; +static OSSL_core_get_params_fn *c_get_params; +OSSL_core_thread_start_fn *c_thread_start; +static OSSL_core_put_error_fn *c_put_error; +static OSSL_core_add_error_vdata_fn *c_add_error_vdata; +static OSSL_CRYPTO_malloc_fn *c_CRYPTO_malloc; +static OSSL_CRYPTO_zalloc_fn *c_CRYPTO_zalloc; +static OSSL_CRYPTO_memdup_fn *c_CRYPTO_memdup; +static OSSL_CRYPTO_strdup_fn *c_CRYPTO_strdup; +static OSSL_CRYPTO_strndup_fn *c_CRYPTO_strndup; +static OSSL_CRYPTO_free_fn *c_CRYPTO_free; +static OSSL_CRYPTO_clear_free_fn *c_CRYPTO_clear_free; +static OSSL_CRYPTO_realloc_fn *c_CRYPTO_realloc; +static OSSL_CRYPTO_clear_realloc_fn *c_CRYPTO_clear_realloc; +static OSSL_CRYPTO_secure_malloc_fn *c_CRYPTO_secure_malloc; +static OSSL_CRYPTO_secure_zalloc_fn *c_CRYPTO_secure_zalloc; +static OSSL_CRYPTO_secure_free_fn *c_CRYPTO_secure_free; +static OSSL_CRYPTO_secure_clear_free_fn *c_CRYPTO_secure_clear_free; +static OSSL_CRYPTO_secure_allocated_fn *c_CRYPTO_secure_allocated; +static OSSL_OPENSSL_hexstr2buf_fn *c_OPENSSL_hexstr2buf; + +typedef struct fips_global_st { + const OSSL_PROVIDER *prov; +} FIPS_GLOBAL; + +static void *fips_prov_ossl_ctx_new(OPENSSL_CTX *libctx) +{ + FIPS_GLOBAL *fgbl = OPENSSL_zalloc(sizeof(*fgbl)); + + return fgbl; +} + +static void fips_prov_ossl_ctx_free(void *fgbl) +{ + OPENSSL_free(fgbl); +} + +static const OPENSSL_CTX_METHOD fips_prov_ossl_ctx_method = { + fips_prov_ossl_ctx_new, + fips_prov_ossl_ctx_free, +}; + /* Parameters we provide to the core */ static const OSSL_ITEM fips_param_types[] = { @@ -36,8 +88,9 @@ static const OSSL_ITEM fips_param_types[] = { }; /* TODO(3.0): To be removed */ -static int dummy_evp_call(OPENSSL_CTX *libctx) +static int dummy_evp_call(void *provctx) { + OPENSSL_CTX *libctx = PROV_LIBRARY_CONTEXT_OF(provctx); EVP_MD_CTX *ctx = EVP_MD_CTX_new(); EVP_MD *sha256 = EVP_MD_fetch(libctx, "SHA256", NULL); char msg[] = "Hello World!"; @@ -49,8 +102,12 @@ static int dummy_evp_call(OPENSSL_CTX *libctx) unsigned int dgstlen = 0; unsigned char dgst[SHA256_DIGEST_LENGTH]; int ret = 0; + BN_CTX *bnctx = NULL; + BIGNUM *a = NULL, *b = NULL; + unsigned char randbuf[128]; + RAND_DRBG *drbg = OPENSSL_CTX_get0_public_drbg(libctx); - if (ctx == NULL || sha256 == NULL) + if (ctx == NULL || sha256 == NULL || drbg == NULL) goto err; if (!EVP_DigestInit_ex(ctx, sha256, NULL)) @@ -62,8 +119,31 @@ static int dummy_evp_call(OPENSSL_CTX *libctx) if (dgstlen != sizeof(exptd) || memcmp(dgst, exptd, sizeof(exptd)) != 0) goto err; + bnctx = BN_CTX_new_ex(libctx); + if (bnctx == NULL) + goto err; + BN_CTX_start(bnctx); + a = BN_CTX_get(bnctx); + b = BN_CTX_get(bnctx); + if (b == NULL) + goto err; + BN_zero(a); + if (!BN_one(b) + || !BN_add(a, a, b) + || BN_cmp(a, b) != 0) + goto err; + + if (RAND_DRBG_bytes(drbg, randbuf, sizeof(randbuf)) <= 0) + goto err; + + if (!BN_rand_ex(a, 256, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY, bnctx)) + goto err; + ret = 1; err: + BN_CTX_end(bnctx); + BN_CTX_free(bnctx); + EVP_MD_CTX_free(ctx); EVP_MD_meth_free(sha256); return ret; @@ -74,10 +154,9 @@ static const OSSL_ITEM *fips_get_param_types(const OSSL_PROVIDER *prov) return fips_param_types; } -static int fips_get_params(const OSSL_PROVIDER *prov, - const OSSL_PARAM params[]) +static int fips_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]) { - const OSSL_PARAM *p; + OSSL_PARAM *p; p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME); if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL FIPS Provider")) @@ -92,10 +171,88 @@ static int fips_get_params(const OSSL_PROVIDER *prov, return 1; } -extern const OSSL_DISPATCH sha256_functions[]; +/* FIPS specific version of the function of the same name in provlib.c */ +const char *ossl_prov_util_nid_to_name(int nid) +{ + /* We don't have OBJ_nid2n() in FIPS_MODE so we have an explicit list */ + + switch (nid) { + /* Digests */ + case NID_sha1: + return "SHA224"; + case NID_sha224: + return "SHA224"; + case NID_sha256: + return "SHA256"; + case NID_sha384: + return "SHA384"; + case NID_sha512: + return "SHA512"; + case NID_sha512_224: + return "SHA512-224"; + case NID_sha512_256: + return "SHA512-256"; + case NID_sha3_224: + return "SHA3-224"; + case NID_sha3_256: + return "SHA3-256"; + case NID_sha3_384: + return "SHA3-384"; + case NID_sha3_512: + return "SHA3-512"; + + /* Ciphers */ + case NID_aes_256_ecb: + return "AES-256-ECB"; + case NID_aes_192_ecb: + return "AES-192-ECB"; + case NID_aes_128_ecb: + return "AES-128-ECB"; + case NID_aes_256_cbc: + return "AES-256-CBC"; + case NID_aes_192_cbc: + return "AES-192-CBC"; + case NID_aes_128_cbc: + return "AES-128-CBC"; + case NID_aes_256_ctr: + return "AES-256-CTR"; + case NID_aes_192_ctr: + return "AES-192-CTR"; + case NID_aes_128_ctr: + return "AES-128-CTR"; + } + + return NULL; +} static const OSSL_ALGORITHM fips_digests[] = { + { "SHA1", "fips=yes", sha1_functions }, + { "SHA224", "fips=yes", sha224_functions }, { "SHA256", "fips=yes", sha256_functions }, + { "SHA384", "fips=yes", sha384_functions }, + { "SHA512", "fips=yes", sha512_functions }, + { "SHA512-224", "fips=yes", sha512_224_functions }, + { "SHA512-256", "fips=yes", sha512_256_functions }, + { "SHA3-224", "fips=yes", sha3_224_functions }, + { "SHA3-256", "fips=yes", sha3_256_functions }, + { "SHA3-384", "fips=yes", sha3_384_functions }, + { "SHA3-512", "fips=yes", sha3_512_functions }, + { "KMAC128", "fips=yes", keccak_kmac_128_functions }, + { "KMAC256", "fips=yes", keccak_kmac_256_functions }, + + { NULL, NULL, NULL } +}; + +static const OSSL_ALGORITHM fips_ciphers[] = { + { "AES-256-ECB", "fips=yes", aes256ecb_functions }, + { "AES-192-ECB", "fips=yes", aes192ecb_functions }, + { "AES-128-ECB", "fips=yes", aes128ecb_functions }, + { "AES-256-CBC", "fips=yes", aes256cbc_functions }, + { "AES-192-CBC", "fips=yes", aes192cbc_functions }, + { "AES-128-CBC", "fips=yes", aes128cbc_functions }, + { "AES-256-CTR", "fips=yes", aes256ctr_functions }, + { "AES-192-CTR", "fips=yes", aes192ctr_functions }, + { "AES-128-CTR", "fips=yes", aes128ctr_functions }, { NULL, NULL, NULL } }; @@ -107,6 +264,8 @@ static const OSSL_ALGORITHM *fips_query(OSSL_PROVIDER *prov, switch (operation_id) { case OSSL_OP_DIGEST: return fips_digests; + case OSSL_OP_CIPHER: + return fips_ciphers; } return NULL; } @@ -136,6 +295,7 @@ int OSSL_provider_init(const OSSL_PROVIDER *provider, const OSSL_DISPATCH **out, void **provctx) { + FIPS_GLOBAL *fgbl; OPENSSL_CTX *ctx; for (; in->function_id != 0; in++) { @@ -146,46 +306,97 @@ int OSSL_provider_init(const OSSL_PROVIDER *provider, case OSSL_FUNC_CORE_GET_PARAMS: c_get_params = OSSL_get_core_get_params(in); break; + case OSSL_FUNC_CORE_THREAD_START: + c_thread_start = OSSL_get_core_thread_start(in); + break; case OSSL_FUNC_CORE_PUT_ERROR: c_put_error = OSSL_get_core_put_error(in); break; case OSSL_FUNC_CORE_ADD_ERROR_VDATA: c_add_error_vdata = OSSL_get_core_add_error_vdata(in); break; - /* Just ignore anything we don't understand */ + case OSSL_FUNC_CRYPTO_MALLOC: + c_CRYPTO_malloc = OSSL_get_CRYPTO_malloc(in); + break; + case OSSL_FUNC_CRYPTO_ZALLOC: + c_CRYPTO_zalloc = OSSL_get_CRYPTO_zalloc(in); + break; + case OSSL_FUNC_CRYPTO_MEMDUP: + c_CRYPTO_memdup = OSSL_get_CRYPTO_memdup(in); + break; + case OSSL_FUNC_CRYPTO_STRDUP: + c_CRYPTO_strdup = OSSL_get_CRYPTO_strdup(in); + break; + case OSSL_FUNC_CRYPTO_STRNDUP: + c_CRYPTO_strndup = OSSL_get_CRYPTO_strndup(in); + break; + case OSSL_FUNC_CRYPTO_FREE: + c_CRYPTO_free = OSSL_get_CRYPTO_free(in); + break; + case OSSL_FUNC_CRYPTO_CLEAR_FREE: + c_CRYPTO_clear_free = OSSL_get_CRYPTO_clear_free(in); + break; + case OSSL_FUNC_CRYPTO_REALLOC: + c_CRYPTO_realloc = OSSL_get_CRYPTO_realloc(in); + break; + case OSSL_FUNC_CRYPTO_CLEAR_REALLOC: + c_CRYPTO_clear_realloc = OSSL_get_CRYPTO_clear_realloc(in); + break; + case OSSL_FUNC_CRYPTO_SECURE_MALLOC: + c_CRYPTO_secure_malloc = OSSL_get_CRYPTO_secure_malloc(in); + break; + case OSSL_FUNC_CRYPTO_SECURE_ZALLOC: + c_CRYPTO_secure_zalloc = OSSL_get_CRYPTO_secure_zalloc(in); + break; + case OSSL_FUNC_CRYPTO_SECURE_FREE: + c_CRYPTO_secure_free = OSSL_get_CRYPTO_secure_free(in); + break; + case OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE: + c_CRYPTO_secure_clear_free = OSSL_get_CRYPTO_secure_clear_free(in); + break; + case OSSL_FUNC_CRYPTO_SECURE_ALLOCATED: + c_CRYPTO_secure_allocated = OSSL_get_CRYPTO_secure_allocated(in); + break; + case OSSL_FUNC_OPENSSL_HEXSTR2BUF: + c_OPENSSL_hexstr2buf = OSSL_get_OPENSSL_hexstr2buf(in); + break; default: + /* Just ignore anything we don't understand */ break; } } - ctx = OPENSSL_CTX_new(); - if (ctx == NULL) + /* Create a context. */ + if ((ctx = OPENSSL_CTX_new()) == NULL) return 0; + if ((fgbl = openssl_ctx_get_data(ctx, OPENSSL_CTX_FIPS_PROV_INDEX, + &fips_prov_ossl_ctx_method)) == NULL) { + OPENSSL_CTX_free(ctx); + return 0; + } + fgbl->prov = provider; + *out = fips_dispatch_table; + *provctx = ctx; /* * TODO(3.0): Remove me. This is just a dummy call to demonstrate making * EVP calls from within the FIPS module. */ - if (!dummy_evp_call(ctx)) { - OPENSSL_CTX_free(ctx); + if (!dummy_evp_call(*provctx)) { + OPENSSL_CTX_free(*provctx); + *provctx = NULL; return 0; } - *out = fips_dispatch_table; - *provctx = ctx; return 1; } /* * The internal init function used when the FIPS module uses EVP to call * another algorithm also in the FIPS module. This is a recursive call that has - * been made from within the FIPS module itself. Normally we are responsible for - * providing our own provctx value, but in this recursive case it has been - * pre-populated for us with the same library context that was used in the EVP - * call that initiated this recursive call - so we don't need to do anything - * further with that parameter. This only works because we *know* in the core - * code that the FIPS module uses a library context for its provctx. This is - * not generally true for all providers. + * been made from within the FIPS module itself. To make this work, we populate + * the provider context of this inner instance with the same library context + * that was used in the EVP call that initiated this recursive call. */ OSSL_provider_init_fn fips_intern_provider_init; int fips_intern_provider_init(const OSSL_PROVIDER *provider, @@ -193,6 +404,30 @@ int fips_intern_provider_init(const OSSL_PROVIDER *provider, const OSSL_DISPATCH **out, void **provctx) { + OSSL_core_get_library_context_fn *c_get_libctx = NULL; + + for (; in->function_id != 0; in++) { + switch (in->function_id) { + case OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT: + c_get_libctx = OSSL_get_core_get_library_context(in); + break; + default: + break; + } + } + + if (c_get_libctx == NULL) + return 0; + + *provctx = c_get_libctx(provider); + + /* + * Safety measure... we should get the library context that was + * created up in OSSL_provider_init(). + */ + if (*provctx == NULL) + return 0; + *out = intern_dispatch_table; return 1; } @@ -200,17 +435,18 @@ int fips_intern_provider_init(const OSSL_PROVIDER *provider, void ERR_put_error(int lib, int func, int reason, const char *file, int line) { /* - * TODO(3.0): This works for the FIPS module because we're going to be - * using lib/func/reason codes that libcrypto already knows about. This - * won't work for third party providers that have their own error mechanisms, - * so we'll need to come up with something else for them. + * TODO(3.0) the first argument is currently NULL but is expected to + * be passed something else in the future, either an OSSL_PROVIDER or + * a OPENSSL_CTX pointer. */ - c_put_error(lib, func, reason, file, line); + c_put_error(NULL, ERR_PACK(lib, func, reason), file, line); + ERR_add_error_data(1, "(in the FIPS module)"); } void ERR_add_error_data(int num, ...) { va_list args; + va_start(args, num); ERR_add_error_vdata(num, args); va_end(args); @@ -218,5 +454,92 @@ void ERR_add_error_data(int num, ...) void ERR_add_error_vdata(int num, va_list args) { - c_add_error_vdata(num, args); + c_add_error_vdata(NULL, num, args); +} + +const OSSL_PROVIDER *FIPS_get_provider(OPENSSL_CTX *ctx) +{ + FIPS_GLOBAL *fgbl = openssl_ctx_get_data(ctx, OPENSSL_CTX_FIPS_PROV_INDEX, + &fips_prov_ossl_ctx_method); + + if (fgbl == NULL) + return NULL; + + return fgbl->prov; +} + +void *CRYPTO_malloc(size_t num, const char *file, int line) +{ + return c_CRYPTO_malloc(num, file, line); +} + +void *CRYPTO_zalloc(size_t num, const char *file, int line) +{ + return c_CRYPTO_zalloc(num, file, line); +} + +void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line) +{ + return c_CRYPTO_memdup(str, siz, file, line); +} + +char *CRYPTO_strdup(const char *str, const char *file, int line) +{ + return c_CRYPTO_strdup(str, file, line); +} + +char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line) +{ + return c_CRYPTO_strndup(str, s, file, line); +} + +void CRYPTO_free(void *ptr, const char *file, int line) +{ + c_CRYPTO_free(ptr, file, line); +} + +void CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line) +{ + c_CRYPTO_clear_free(ptr, num, file, line); +} + +void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line) +{ + return c_CRYPTO_realloc(addr, num, file, line); +} + +void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num, + const char *file, int line) +{ + return c_CRYPTO_clear_realloc(addr, old_num, num, file, line); +} + +void *CRYPTO_secure_malloc(size_t num, const char *file, int line) +{ + return c_CRYPTO_secure_malloc(num, file, line); +} + +void *CRYPTO_secure_zalloc(size_t num, const char *file, int line) +{ + return c_CRYPTO_secure_zalloc(num, file, line); +} + +void CRYPTO_secure_free(void *ptr, const char *file, int line) +{ + c_CRYPTO_secure_free(ptr, file, line); +} + +void CRYPTO_secure_clear_free(void *ptr, size_t num, const char *file, int line) +{ + c_CRYPTO_secure_clear_free(ptr, num, file, line); +} + +unsigned char *OPENSSL_hexstr2buf(const char *str, long *len) +{ + return c_OPENSSL_hexstr2buf(str, len); +} + +int CRYPTO_secure_allocated(const void *ptr) +{ + return c_CRYPTO_secure_allocated(ptr); } diff --git a/providers/legacy/digests/build.info b/providers/legacy/digests/build.info index c4e1278a..538afd4c 100644 --- a/providers/legacy/digests/build.info +++ b/providers/legacy/digests/build.info @@ -1,4 +1,24 @@ IF[{- !$disabled{md2} -}] SOURCE[../../legacy]=\ - md2.c + md2_prov.c ENDIF + +IF[{- !$disabled{md4} -}] + SOURCE[../../legacy]=\ + md4_prov.c +ENDIF + +IF[{- !$disabled{mdc2} -}] + SOURCE[../../legacy]=\ + mdc2_prov.c +ENDIF + +IF[{- !$disabled{whirlpool} -}] + SOURCE[../../legacy]=\ + wp_prov.c +ENDIF + +IF[{- !$disabled{rmd160} -}] + SOURCE[../../legacy]=\ + ripemd_prov.c +ENDIF \ No newline at end of file diff --git a/providers/legacy/digests/md2.c b/providers/legacy/digests/md2.c deleted file mode 100644 index 017a5111..00000000 --- a/providers/legacy/digests/md2.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the Apache License 2.0 (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include -#include -#include - -static int md2_final(void *ctx, unsigned char *md, size_t *size) -{ - if (MD2_Final(md, ctx)) { - *size = MD2_DIGEST_LENGTH; - return 1; - } - - return 0; -} - -static void *md2_newctx(void) -{ - MD2_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx)); - - return ctx; -} - -static void md2_freectx(void *vctx) -{ - MD2_CTX *ctx = (MD2_CTX *)vctx; - - OPENSSL_clear_free(ctx, sizeof(*ctx)); -} - -static void *md2_dupctx(void *ctx) -{ - MD2_CTX *in = (MD2_CTX *)ctx; - MD2_CTX *ret = OPENSSL_malloc(sizeof(*ret)); - - *ret = *in; - - return ret; -} - -static size_t md2_size(void) -{ - return MD2_DIGEST_LENGTH; -} - -extern const OSSL_DISPATCH md2_functions[]; -const OSSL_DISPATCH md2_functions[] = { - { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))md2_newctx }, - { OSSL_FUNC_DIGEST_INIT, (void (*)(void))MD2_Init }, - { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))MD2_Update }, - { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))md2_final }, - { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))md2_freectx }, - { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))md2_dupctx }, - { OSSL_FUNC_DIGEST_SIZE, (void (*)(void))md2_size }, - { 0, NULL } -}; diff --git a/providers/legacy/digests/md2_prov.c b/providers/legacy/digests/md2_prov.c new file mode 100644 index 00000000..edd4b78b --- /dev/null +++ b/providers/legacy/digests/md2_prov.c @@ -0,0 +1,18 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include + +#include "internal/core_mkdigest.h" +#include "internal/provider_algs.h" + +OSSL_FUNC_DIGEST_CONSTRUCT(md2, MD2_CTX, + MD2_BLOCK, MD2_DIGEST_LENGTH, + MD2_Init, MD2_Update, MD2_Final) diff --git a/providers/legacy/digests/md4_prov.c b/providers/legacy/digests/md4_prov.c new file mode 100644 index 00000000..86937f7b --- /dev/null +++ b/providers/legacy/digests/md4_prov.c @@ -0,0 +1,18 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include + +#include "internal/core_mkdigest.h" +#include "internal/provider_algs.h" + +OSSL_FUNC_DIGEST_CONSTRUCT(md4, MD4_CTX, + MD4_CBLOCK, MD4_DIGEST_LENGTH, + MD4_Init, MD4_Update, MD4_Final) diff --git a/providers/legacy/digests/mdc2_prov.c b/providers/legacy/digests/mdc2_prov.c new file mode 100644 index 00000000..31e95cb3 --- /dev/null +++ b/providers/legacy/digests/mdc2_prov.c @@ -0,0 +1,37 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include +#include +#include + +#include "internal/core_mkdigest.h" +#include "internal/provider_algs.h" + +static OSSL_OP_digest_set_params_fn mdc2_set_params; + +static int mdc2_set_params(void *vctx, const OSSL_PARAM params[]) +{ + const OSSL_PARAM *p; + MDC2_CTX *ctx = (MDC2_CTX *)vctx; + + if (ctx != NULL && params != NULL) { + p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_PAD_TYPE); + if (p != NULL && !OSSL_PARAM_get_int(p, &ctx->pad_type)) + return 0; + return 1; + } + return 0; /* Null Parameter */ +} + +OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(mdc2, MDC2_CTX, + MDC2_BLOCK, MDC2_DIGEST_LENGTH, + MDC2_Init, MDC2_Update, MDC2_Final, + mdc2_set_params) diff --git a/providers/legacy/digests/ripemd_prov.c b/providers/legacy/digests/ripemd_prov.c new file mode 100644 index 00000000..12435125 --- /dev/null +++ b/providers/legacy/digests/ripemd_prov.c @@ -0,0 +1,18 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include + +#include "internal/core_mkdigest.h" +#include "internal/provider_algs.h" + +OSSL_FUNC_DIGEST_CONSTRUCT(ripemd160, RIPEMD160_CTX, + RIPEMD160_CBLOCK, RIPEMD160_DIGEST_LENGTH, + RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final) diff --git a/providers/legacy/digests/wp_prov.c b/providers/legacy/digests/wp_prov.c new file mode 100644 index 00000000..ece67e09 --- /dev/null +++ b/providers/legacy/digests/wp_prov.c @@ -0,0 +1,18 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include +#include + +#include "internal/core_mkdigest.h" +#include "internal/provider_algs.h" + +OSSL_FUNC_DIGEST_CONSTRUCT(wp, WHIRLPOOL_CTX, + WHIRLPOOL_BBLOCK / 8, WHIRLPOOL_DIGEST_LENGTH, + WHIRLPOOL_Init, WHIRLPOOL_Update, WHIRLPOOL_Final) diff --git a/providers/legacy/legacyprov.c b/providers/legacy/legacyprov.c index 2d42229f..0be58d8e 100644 --- a/providers/legacy/legacyprov.c +++ b/providers/legacy/legacyprov.c @@ -13,6 +13,7 @@ #include #include #include +#include "internal/provider_algs.h" /* Functions provided by the core */ static OSSL_core_get_param_types_fn *c_get_param_types = NULL; @@ -31,10 +32,9 @@ static const OSSL_ITEM *legacy_get_param_types(const OSSL_PROVIDER *prov) return legacy_param_types; } -static int legacy_get_params(const OSSL_PROVIDER *prov, - const OSSL_PARAM params[]) +static int legacy_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]) { - const OSSL_PARAM *p; + OSSL_PARAM *p; p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME); if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL Legacy Provider")) @@ -49,12 +49,27 @@ static int legacy_get_params(const OSSL_PROVIDER *prov, return 1; } -extern const OSSL_DISPATCH md2_functions[]; - static const OSSL_ALGORITHM legacy_digests[] = { #ifndef OPENSSL_NO_MD2 { "MD2", "legacy=yes", md2_functions }, #endif + +#ifndef OPENSSL_NO_MD4 + { "MD4", "legacy=yes", md4_functions }, +#endif + +#ifndef OPENSSL_NO_MDC2 + { "MDC2", "legacy=yes", mdc2_functions }, +#endif /* OPENSSL_NO_MDC2 */ + +#ifndef OPENSSL_NO_WHIRLPOOL + { "whirlpool", "legacy=yes", wp_functions }, +#endif /* OPENSSL_NO_WHIRLPOOL */ + +#ifndef OPENSSL_NO_RMD160 + { "RIPEMD160", "legacy=yes", ripemd160_functions }, +#endif /* OPENSSL_NO_RMD160 */ + { NULL, NULL, NULL } }; @@ -83,6 +98,8 @@ int OSSL_provider_init(const OSSL_PROVIDER *provider, const OSSL_DISPATCH **out, void **provctx) { + OSSL_core_get_library_context_fn *c_get_libctx = NULL; + for (; in->function_id != 0; in++) { switch (in->function_id) { case OSSL_FUNC_CORE_GET_PARAM_TYPES: @@ -91,12 +108,25 @@ int OSSL_provider_init(const OSSL_PROVIDER *provider, case OSSL_FUNC_CORE_GET_PARAMS: c_get_params = OSSL_get_core_get_params(in); break; + case OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT: + c_get_libctx = OSSL_get_core_get_library_context(in); + break; /* Just ignore anything we don't understand */ default: break; } } + if (c_get_libctx == NULL) + return 0; + *out = legacy_dispatch_table; + + /* + * We want to make sure that all calls from this provider that requires + * a library context use the same context as the one used to call our + * functions. We do that by passing it along as the provider context. + */ + *provctx = c_get_libctx(provider); return 1; } diff --git a/ssl/d1_msg.c b/ssl/d1_msg.c index 0891d948..0dc83614 100644 --- a/ssl/d1_msg.c +++ b/ssl/d1_msg.c @@ -52,8 +52,7 @@ int dtls1_dispatch_alert(SSL *s) s->s3.alert_dispatch = 1; /* fprintf( stderr, "not done with alert\n" ); */ } else { - if (s->s3.send_alert[0] == SSL3_AL_FATAL) - (void)BIO_flush(s->wbio); + (void)BIO_flush(s->wbio); if (s->msg_callback) s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3.send_alert, diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c index 64e132aa..a9911328 100644 --- a/ssl/record/rec_layer_s3.c +++ b/ssl/record/rec_layer_s3.c @@ -377,6 +377,13 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, size_t len, s->rlayer.wnum = 0; + /* + * If we are supposed to be sending a KeyUpdate then go into init unless we + * have writes pending - in which case we should finish doing that first. + */ + if (wb->left == 0 && s->key_update != SSL_KEY_UPDATE_NONE) + ossl_statem_set_in_init(s, 1); + /* * When writing early data on the server side we could be "in_init" in * between receiving the EoED and the CF - but we don't want to handle those diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c index de4e678c..3edbae28 100644 --- a/ssl/s3_enc.c +++ b/ssl/s3_enc.c @@ -12,6 +12,7 @@ #include "ssl_locl.h" #include #include +#include #include "internal/cryptlib.h" static int ssl3_generate_key_block(SSL *s, unsigned char *km, int num) @@ -410,6 +411,16 @@ int ssl3_digest_cached_records(SSL *s, int keep) return 1; } +void ssl3_digest_master_key_set_params(const SSL_SESSION *session, + OSSL_PARAM params[]) +{ + int n = 0; + params[n++] = OSSL_PARAM_construct_octet_string(OSSL_DIGEST_PARAM_SSL3_MS, + (void *)session->master_key, + session->master_key_length); + params[n++] = OSSL_PARAM_construct_end(); +} + size_t ssl3_final_finish_mac(SSL *s, const char *sender, size_t len, unsigned char *p) { @@ -448,14 +459,18 @@ size_t ssl3_final_finish_mac(SSL *s, const char *sender, size_t len, goto err; } - if ((sender != NULL && EVP_DigestUpdate(ctx, sender, len) <= 0) - || EVP_MD_CTX_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, - (int)s->session->master_key_length, - s->session->master_key) <= 0 - || EVP_DigestFinal_ex(ctx, p, NULL) <= 0) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_FINAL_FINISH_MAC, - ERR_R_INTERNAL_ERROR); - ret = 0; + if (sender != NULL) { + OSSL_PARAM digest_cmd_params[3]; + + ssl3_digest_master_key_set_params(s->session, digest_cmd_params); + + if (EVP_DigestUpdate(ctx, sender, len) <= 0 + || EVP_MD_CTX_set_params(ctx, digest_cmd_params) <= 0 + || EVP_DigestFinal_ex(ctx, p, NULL) <= 0) { + SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL3_FINAL_FINISH_MAC, + ERR_R_INTERNAL_ERROR); + ret = 0; + } } err: diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 87326bad..7618b11e 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -3632,7 +3632,7 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg) } return ssl_cert_set_current(s->cert, larg); -#ifndef OPENSSL_NO_EC +#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) case SSL_CTRL_GET_GROUPS: { uint16_t *clist; @@ -3640,8 +3640,8 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg) if (!s->session) return 0; - clist = s->session->ext.supportedgroups; - clistlen = s->session->ext.supportedgroups_len; + clist = s->ext.peer_supportedgroups; + clistlen = s->ext.peer_supportedgroups_len; if (parg) { size_t i; int *cptr = parg; @@ -3677,7 +3677,8 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg) } return id; } -#endif +#endif /* !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) */ + case SSL_CTRL_SET_SIGALGS: return tls1_set_sigalgs(s->cert, parg, larg, 0); @@ -3755,13 +3756,12 @@ long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg) #ifndef OPENSSL_NO_EC case SSL_CTRL_GET_EC_POINT_FORMATS: { - SSL_SESSION *sess = s->session; const unsigned char **pformat = parg; - if (sess == NULL || sess->ext.ecpointformats == NULL) + if (s->ext.peer_ecpointformats == NULL) return 0; - *pformat = sess->ext.ecpointformats; - return (int)sess->ext.ecpointformats_len; + *pformat = s->ext.peer_ecpointformats; + return (int)s->ext.peer_ecpointformats_len; } #endif @@ -3953,7 +3953,7 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) break; #endif -#ifndef OPENSSL_NO_EC +#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) case SSL_CTRL_SET_GROUPS: return tls1_set_groups(&ctx->ext.supportedgroups, &ctx->ext.supportedgroups_len, @@ -3963,7 +3963,8 @@ long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) return tls1_set_groups_list(&ctx->ext.supportedgroups, &ctx->ext.supportedgroups_len, parg); -#endif +#endif /* !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) */ + case SSL_CTRL_SET_SIGALGS: return tls1_set_sigalgs(ctx->cert, parg, larg, 0); @@ -4738,25 +4739,40 @@ EVP_PKEY *ssl_generate_pkey(EVP_PKEY *pm) EVP_PKEY_CTX_free(pctx); return pkey; } -#ifndef OPENSSL_NO_EC + /* Generate a private key from a group ID */ +#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC) EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id) { + const TLS_GROUP_INFO *ginf = tls1_group_id_lookup(id); EVP_PKEY_CTX *pctx = NULL; EVP_PKEY *pkey = NULL; - const TLS_GROUP_INFO *ginf = tls1_group_id_lookup(id); uint16_t gtype; +# ifndef OPENSSL_NO_DH + DH *dh = NULL; +# endif if (ginf == NULL) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP, ERR_R_INTERNAL_ERROR); goto err; } - gtype = ginf->flags & TLS_CURVE_TYPE; - if (gtype == TLS_CURVE_CUSTOM) - pctx = EVP_PKEY_CTX_new_id(ginf->nid, NULL); + gtype = ginf->flags & TLS_GROUP_TYPE; +# ifndef OPENSSL_NO_DH + if (gtype == TLS_GROUP_FFDHE) + pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_DH, NULL); +# ifndef OPENSSL_NO_EC else - pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL); +# endif +# endif +# ifndef OPENSSL_NO_EC + { + if (gtype == TLS_GROUP_CURVE_CUSTOM) + pctx = EVP_PKEY_CTX_new_id(ginf->nid, NULL); + else + pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL); + } +# endif if (pctx == NULL) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP, ERR_R_MALLOC_FAILURE); @@ -4767,12 +4783,40 @@ EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id) ERR_R_EVP_LIB); goto err; } - if (gtype != TLS_CURVE_CUSTOM - && EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, ginf->nid) <= 0) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP, - ERR_R_EVP_LIB); - goto err; +# ifndef OPENSSL_NO_DH + if (gtype == TLS_GROUP_FFDHE) { + if ((pkey = EVP_PKEY_new()) == NULL + || (dh = DH_new_by_nid(ginf->nid)) == NULL + || !EVP_PKEY_assign(pkey, EVP_PKEY_DH, dh)) { + SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP, + ERR_R_EVP_LIB); + DH_free(dh); + EVP_PKEY_free(pkey); + pkey = NULL; + goto err; + } + if (EVP_PKEY_CTX_set_dh_nid(pctx, ginf->nid) <= 0) { + SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP, + ERR_R_EVP_LIB); + EVP_PKEY_free(pkey); + pkey = NULL; + goto err; + } } +# ifndef OPENSSL_NO_EC + else +# endif +# endif +# ifndef OPENSSL_NO_EC + { + if (gtype != TLS_GROUP_CURVE_CUSTOM + && EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, ginf->nid) <= 0) { + SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP, + ERR_R_EVP_LIB); + goto err; + } + } +# endif if (EVP_PKEY_keygen(pctx, &pkey) <= 0) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_GENERATE_PKEY_GROUP, ERR_R_EVP_LIB); @@ -4784,6 +4828,7 @@ EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id) EVP_PKEY_CTX_free(pctx); return pkey; } +#endif /* * Generate parameters from a group ID @@ -4793,11 +4838,12 @@ EVP_PKEY *ssl_generate_param_group(uint16_t id) EVP_PKEY_CTX *pctx = NULL; EVP_PKEY *pkey = NULL; const TLS_GROUP_INFO *ginf = tls1_group_id_lookup(id); + int pkey_ctx_id; if (ginf == NULL) goto err; - if ((ginf->flags & TLS_CURVE_TYPE) == TLS_CURVE_CUSTOM) { + if ((ginf->flags & TLS_GROUP_TYPE) == TLS_GROUP_CURVE_CUSTOM) { pkey = EVP_PKEY_new(); if (pkey != NULL && EVP_PKEY_set_type(pkey, ginf->nid)) return pkey; @@ -4805,13 +4851,28 @@ EVP_PKEY *ssl_generate_param_group(uint16_t id) return NULL; } - pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL); + pkey_ctx_id = (ginf->flags & TLS_GROUP_FFDHE) + ? EVP_PKEY_DH : EVP_PKEY_EC; + pctx = EVP_PKEY_CTX_new_id(pkey_ctx_id, NULL); if (pctx == NULL) goto err; if (EVP_PKEY_paramgen_init(pctx) <= 0) goto err; - if (EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, ginf->nid) <= 0) - goto err; +# ifndef OPENSSL_NO_DH + if (ginf->flags & TLS_GROUP_FFDHE) { + if (EVP_PKEY_CTX_set_dh_nid(pctx, ginf->nid) <= 0) + goto err; + } +# ifndef OPENSSL_NO_EC + else +# endif +# endif +# ifndef OPENSSL_NO_EC + { + if (EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx, ginf->nid) <= 0) + goto err; + } +# endif if (EVP_PKEY_paramgen(pctx, &pkey) <= 0) { EVP_PKEY_free(pkey); pkey = NULL; @@ -4821,7 +4882,6 @@ EVP_PKEY *ssl_generate_param_group(uint16_t id) EVP_PKEY_CTX_free(pctx); return pkey; } -#endif /* Derive secrets for ECDH/DH */ int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey, int gensecret) @@ -4847,6 +4907,11 @@ int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey, int gensecret) goto err; } +#ifndef OPENSSL_NO_DH + if (SSL_IS_TLS13(s) && EVP_PKEY_id(privkey) == EVP_PKEY_DH) + EVP_PKEY_CTX_set_dh_pad(pctx, 1); +#endif + pms = OPENSSL_malloc(pmslen); if (pms == NULL) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_SSL_DERIVE, diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index 04963f1b..5538e4da 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -154,8 +154,6 @@ CERT *ssl_cert_dup(CERT *cert) ret->client_sigalgslen = cert->client_sigalgslen; } else ret->client_sigalgs = NULL; - /* Shared sigalgs also NULL */ - ret->shared_sigalgs = NULL; /* Copy any custom client certificate types */ if (cert->ctype) { ret->ctype = OPENSSL_memdup(cert->ctype, cert->ctype_len); @@ -240,7 +238,6 @@ void ssl_cert_free(CERT *c) ssl_cert_clear_certs(c); OPENSSL_free(c->conf_sigalgs); OPENSSL_free(c->client_sigalgs); - OPENSSL_free(c->shared_sigalgs); OPENSSL_free(c->ctype); X509_STORE_free(c->verify_store); X509_STORE_free(c->chain_store); diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index e738a71a..7bd8f801 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -1640,7 +1640,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, ok = 1; rule_p = rule_str; if (strncmp(rule_str, "DEFAULT", 7) == 0) { - ok = ssl_cipher_process_rulestr(SSL_DEFAULT_CIPHER_LIST, + ok = ssl_cipher_process_rulestr(OSSL_default_cipher_list(), &head, &tail, ca_list, c); rule_p += 7; if (*rule_p == ':') @@ -2253,3 +2253,27 @@ int ssl_cert_is_disabled(size_t idx) return 1; return 0; } + +/* + * Default list of TLSv1.2 (and earlier) ciphers + * SSL_DEFAULT_CIPHER_LIST deprecated in 3.0.0 + * Update both macro and function simultaneously + */ +const char *OSSL_default_cipher_list(void) +{ + return "ALL:!COMPLEMENTOFDEFAULT:!eNULL"; +} + +/* + * Default list of TLSv1.3 (and later) ciphers + * TLS_DEFAULT_CIPHERSUITES deprecated in 3.0.0 + * Update both macro and function simultaneously + */ +const char *OSSL_default_ciphersuites(void) +{ + return "TLS_AES_256_GCM_SHA384:" +#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) + "TLS_CHACHA20_POLY1305_SHA256:" +#endif + "TLS_AES_128_GCM_SHA256"; +} diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 80f5db8c..6bd6d58f 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -629,6 +629,11 @@ int SSL_clear(SSL *s) /* Clear the verification result peername */ X509_VERIFY_PARAM_move_peername(s->param, NULL); + /* Clear any shared connection state */ + OPENSSL_free(s->shared_sigalgs); + s->shared_sigalgs = NULL; + s->shared_sigalgslen = 0; + /* * Check to see if we were changed into a different method, if so, revert * back. @@ -655,7 +660,7 @@ int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth) ctx->method = meth; - if (!SSL_CTX_set_ciphersuites(ctx, TLS_DEFAULT_CIPHERSUITES)) { + if (!SSL_CTX_set_ciphersuites(ctx, OSSL_default_ciphersuites())) { SSLerr(SSL_F_SSL_CTX_SET_SSL_VERSION, SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS); return 0; } @@ -663,7 +668,7 @@ int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth) ctx->tls13_ciphersuites, &(ctx->cipher_list), &(ctx->cipher_list_by_id), - SSL_DEFAULT_CIPHER_LIST, ctx->cert); + OSSL_default_cipher_list(), ctx->cert); if ((sk == NULL) || (sk_SSL_CIPHER_num(sk) <= 0)) { SSLerr(SSL_F_SSL_CTX_SET_SSL_VERSION, SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS); return 0; @@ -780,6 +785,7 @@ SSL *SSL_new(SSL_CTX *ctx) s->ext.ecpointformats_len = ctx->ext.ecpointformats_len; } +#endif if (ctx->ext.supportedgroups) { s->ext.supportedgroups = OPENSSL_memdup(ctx->ext.supportedgroups, @@ -789,7 +795,7 @@ SSL *SSL_new(SSL_CTX *ctx) goto err; s->ext.supportedgroups_len = ctx->ext.supportedgroups_len; } -#endif + #ifndef OPENSSL_NO_NEXTPROTONEG s->ext.npn = NULL; #endif @@ -1234,6 +1240,7 @@ void SSL_free(SSL *s) ssl_cipher_preference_list_free(s->cipher_list); sk_SSL_CIPHER_free(s->cipher_list_by_id); sk_SSL_CIPHER_free(s->tls13_ciphersuites); + sk_SSL_CIPHER_free(s->peer_ciphers); /* Make the next call work :-) */ if (s->session != NULL) { @@ -1246,13 +1253,16 @@ void SSL_free(SSL *s) clear_ciphers(s); ssl_cert_free(s->cert); + OPENSSL_free(s->shared_sigalgs); /* Free up if allocated */ OPENSSL_free(s->ext.hostname); SSL_CTX_free(s->session_ctx); #ifndef OPENSSL_NO_EC OPENSSL_free(s->ext.ecpointformats); + OPENSSL_free(s->ext.peer_ecpointformats); OPENSSL_free(s->ext.supportedgroups); + OPENSSL_free(s->ext.peer_supportedgroups); #endif /* OPENSSL_NO_EC */ sk_X509_EXTENSION_pop_free(s->ext.ocsp.exts, X509_EXTENSION_free); #ifndef OPENSSL_NO_OCSP @@ -2635,9 +2645,9 @@ STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s) STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *s) { - if ((s == NULL) || (s->session == NULL) || !s->server) + if ((s == NULL) || !s->server) return NULL; - return s->session->ciphers; + return s->peer_ciphers; } STACK_OF(SSL_CIPHER) *SSL_get1_supported_ciphers(SSL *s) @@ -2769,13 +2779,12 @@ char *SSL_get_shared_ciphers(const SSL *s, char *buf, int size) int i; if (!s->server - || s->session == NULL - || s->session->ciphers == NULL + || s->peer_ciphers == NULL || size < 2) return NULL; p = buf; - clntsk = s->session->ciphers; + clntsk = s->peer_ciphers; srvrsk = SSL_get_ciphers(s); if (clntsk == NULL || srvrsk == NULL) return NULL; @@ -3137,13 +3146,13 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth) goto err; #endif - if (!SSL_CTX_set_ciphersuites(ret, TLS_DEFAULT_CIPHERSUITES)) + if (!SSL_CTX_set_ciphersuites(ret, OSSL_default_ciphersuites())) goto err; if (!ssl_create_cipher_list(ret->method, ret->tls13_ciphersuites, &ret->cipher_list, &ret->cipher_list_by_id, - SSL_DEFAULT_CIPHER_LIST, ret->cert) + OSSL_default_cipher_list(), ret->cert) || sk_SSL_CIPHER_num(ret->cipher_list->ciphers) <= 0) { SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_LIBRARY_HAS_NO_CIPHERS); goto err2; diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index 935e7f4b..37f3ce6f 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -557,7 +557,6 @@ struct ssl_session_st { const SSL_CIPHER *cipher; unsigned long cipher_id; /* when ASN.1 loaded, this needs to be used to * load the 'cipher' structure */ - STACK_OF(SSL_CIPHER) *ciphers; /* ciphers offered by the client */ CRYPTO_EX_DATA ex_data; /* application specific data */ /* * These are used to make removal of session-ids more efficient and to @@ -567,13 +566,7 @@ struct ssl_session_st { struct { char *hostname; -# ifndef OPENSSL_NO_EC - size_t ecpointformats_len; - unsigned char *ecpointformats; /* peer's list */ -# endif /* OPENSSL_NO_EC */ - size_t supportedgroups_len; - uint16_t *supportedgroups; /* peer's list */ - /* RFC4507 info */ + /* RFC4507 info */ unsigned char *tick; /* Session ticket */ size_t ticklen; /* Session ticket length */ /* Session lifetime hint in seconds */ @@ -998,9 +991,10 @@ struct ssl_ctx_st { /* EC extension values inherited by SSL structure */ size_t ecpointformats_len; unsigned char *ecpointformats; +# endif /* OPENSSL_NO_EC */ + size_t supportedgroups_len; uint16_t *supportedgroups; -# endif /* OPENSSL_NO_EC */ /* * ALPN information (we are in the process of transitioning from NPN to @@ -1358,6 +1352,7 @@ struct ssl_st { /* Per connection DANE state */ SSL_DANE dane; /* crypto */ + STACK_OF(SSL_CIPHER) *peer_ciphers; struct ssl_cipher_preference_list_st *cipher_list; STACK_OF(SSL_CIPHER) *cipher_list_by_id; /* TLSv1.3 specific ciphersuites */ @@ -1521,10 +1516,19 @@ struct ssl_st { size_t ecpointformats_len; /* our list */ unsigned char *ecpointformats; + + size_t peer_ecpointformats_len; + /* peer's list */ + unsigned char *peer_ecpointformats; # endif /* OPENSSL_NO_EC */ size_t supportedgroups_len; /* our list */ uint16_t *supportedgroups; + + size_t peer_supportedgroups_len; + /* peer's list */ + uint16_t *peer_supportedgroups; + /* TLS Session Ticket extension override */ TLS_SESSION_TICKET_EXT *session_ticket; /* TLS Session Ticket extension callback */ @@ -1696,6 +1700,13 @@ struct ssl_st { /* Callback for SSL async handling */ SSL_async_callback_fn async_cb; void *async_cb_arg; + + /* + * Signature algorithms shared by client and server: cached because these + * are used most often. + */ + const struct sigalg_lookup_st **shared_sigalgs; + size_t shared_sigalgslen; }; /* @@ -1724,14 +1735,19 @@ typedef struct sigalg_lookup_st { typedef struct tls_group_info_st { int nid; /* Curve NID */ int secbits; /* Bits of security (from SP800-57) */ - uint16_t flags; /* Flags: currently just group type */ + uint32_t flags; /* For group type and applicable TLS versions */ + uint16_t group_id; /* Group ID */ } TLS_GROUP_INFO; /* flags values */ -# define TLS_CURVE_TYPE 0x3 /* Mask for group type */ -# define TLS_CURVE_PRIME 0x0 -# define TLS_CURVE_CHAR2 0x1 -# define TLS_CURVE_CUSTOM 0x2 +# define TLS_GROUP_TYPE 0x0000000FU /* Mask for group type */ +# define TLS_GROUP_CURVE_PRIME 0x00000001U +# define TLS_GROUP_CURVE_CHAR2 0x00000002U +# define TLS_GROUP_CURVE_CUSTOM 0x00000004U +# define TLS_GROUP_FFDHE 0x00000008U +# define TLS_GROUP_ONLY_FOR_TLS1_3 0x00000010U + +# define TLS_GROUP_FFDHE_FOR_TLS1_3 (TLS_GROUP_FFDHE|TLS_GROUP_ONLY_FOR_TLS1_3) /* * Structure containing table entry of certificate info corresponding to @@ -1955,12 +1971,6 @@ typedef struct cert_st { uint16_t *client_sigalgs; /* Size of above array */ size_t client_sigalgslen; - /* - * Signature algorithms shared by client and server: cached because these - * are used most often. - */ - const SIGALG_LOOKUP **shared_sigalgs; - size_t shared_sigalgslen; /* * Certificate setup callback: if set is called whenever a certificate * may be required (client or server). the callback can then examine any @@ -2291,8 +2301,8 @@ static ossl_inline int ssl_has_cert(const SSL *s, int idx) static ossl_inline void tls1_get_peer_groups(SSL *s, const uint16_t **pgroups, size_t *pgroupslen) { - *pgroups = s->session->ext.supportedgroups; - *pgroupslen = s->session->ext.supportedgroups_len; + *pgroups = s->ext.peer_supportedgroups; + *pgroupslen = s->ext.peer_supportedgroups_len; } # ifndef OPENSSL_UNIT_TEST @@ -2408,6 +2418,8 @@ __owur int ssl3_num_ciphers(void); __owur const SSL_CIPHER *ssl3_get_cipher(unsigned int u); int ssl3_renegotiate(SSL *ssl); int ssl3_renegotiate_check(SSL *ssl, int initok); +void ssl3_digest_master_key_set_params(const SSL_SESSION *session, + OSSL_PARAM params[]); __owur int ssl3_dispatch_alert(SSL *s); __owur size_t ssl3_final_finish_mac(SSL *s, const char *sender, size_t slen, unsigned char *p); @@ -2564,8 +2576,6 @@ __owur int ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL *s); SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n); -# ifndef OPENSSL_NO_EC - __owur const TLS_GROUP_INFO *tls1_group_id_lookup(uint16_t curve_id); __owur int tls1_check_group_id(SSL *s, uint16_t group_id, int check_own_curves); __owur uint16_t tls1_shared_group(SSL *s, int nmatch); @@ -2573,14 +2583,16 @@ __owur int tls1_set_groups(uint16_t **pext, size_t *pextlen, int *curves, size_t ncurves); __owur int tls1_set_groups_list(uint16_t **pext, size_t *pextlen, const char *str); +__owur EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id); +__owur int tls_valid_group(SSL *s, uint16_t group_id, int version); +__owur EVP_PKEY *ssl_generate_param_group(uint16_t id); +# ifndef OPENSSL_NO_EC void tls1_get_formatlist(SSL *s, const unsigned char **pformats, size_t *num_formats); __owur int tls1_check_ec_tmp_key(SSL *s, unsigned long id); -__owur EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id); -__owur EVP_PKEY *ssl_generate_param_group(uint16_t id); # endif /* OPENSSL_NO_EC */ -__owur int tls_curve_allowed(SSL *s, uint16_t curve, int op); +__owur int tls_group_allowed(SSL *s, uint16_t curve, int op); void tls1_get_supported_groups(SSL *s, const uint16_t **pgroups, size_t *pgroupslen); diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 0d04ffe4..d882f01c 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -121,12 +121,7 @@ SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket) dest->psk_identity_hint = NULL; dest->psk_identity = NULL; #endif - dest->ciphers = NULL; dest->ext.hostname = NULL; -#ifndef OPENSSL_NO_EC - dest->ext.ecpointformats = NULL; - dest->ext.supportedgroups = NULL; -#endif dest->ext.tick = NULL; dest->ext.alpn_selected = NULL; #ifndef OPENSSL_NO_SRP @@ -176,12 +171,6 @@ SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket) } #endif - if (src->ciphers != NULL) { - dest->ciphers = sk_SSL_CIPHER_dup(src->ciphers); - if (dest->ciphers == NULL) - goto err; - } - if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, &dest->ex_data, &src->ex_data)) { goto err; @@ -193,23 +182,6 @@ SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket) goto err; } } -#ifndef OPENSSL_NO_EC - if (src->ext.ecpointformats) { - dest->ext.ecpointformats = - OPENSSL_memdup(src->ext.ecpointformats, - src->ext.ecpointformats_len); - if (dest->ext.ecpointformats == NULL) - goto err; - } - if (src->ext.supportedgroups) { - dest->ext.supportedgroups = - OPENSSL_memdup(src->ext.supportedgroups, - src->ext.supportedgroups_len - * sizeof(*src->ext.supportedgroups)); - if (dest->ext.supportedgroups == NULL) - goto err; - } -#endif if (ticket != 0 && src->ext.tick != NULL) { dest->ext.tick = @@ -793,17 +765,8 @@ void SSL_SESSION_free(SSL_SESSION *ss) OPENSSL_cleanse(ss->session_id, sizeof(ss->session_id)); X509_free(ss->peer); sk_X509_pop_free(ss->peer_chain, X509_free); - sk_SSL_CIPHER_free(ss->ciphers); OPENSSL_free(ss->ext.hostname); OPENSSL_free(ss->ext.tick); -#ifndef OPENSSL_NO_EC - OPENSSL_free(ss->ext.ecpointformats); - ss->ext.ecpointformats = NULL; - ss->ext.ecpointformats_len = 0; - OPENSSL_free(ss->ext.supportedgroups); - ss->ext.supportedgroups = NULL; - ss->ext.supportedgroups_len = 0; -#endif /* OPENSSL_NO_EC */ #ifndef OPENSSL_NO_PSK OPENSSL_free(ss->psk_identity_hint); OPENSSL_free(ss->psk_identity); diff --git a/ssl/statem/extensions.c b/ssl/statem/extensions.c index 2e51aab4..2a9b796c 100644 --- a/ssl/statem/extensions.c +++ b/ssl/statem/extensions.c @@ -46,9 +46,7 @@ static int init_etm(SSL *s, unsigned int context); static int init_ems(SSL *s, unsigned int context); static int final_ems(SSL *s, unsigned int context, int sent); static int init_psk_kex_modes(SSL *s, unsigned int context); -#ifndef OPENSSL_NO_EC static int final_key_share(SSL *s, unsigned int context, int sent); -#endif #ifndef OPENSSL_NO_SRTP static int init_srtp(SSL *s, unsigned int context); #endif @@ -162,6 +160,10 @@ static const EXTENSION_DEFINITION ext_defs[] = { tls_construct_stoc_ec_pt_formats, tls_construct_ctos_ec_pt_formats, final_ec_pt_formats }, +#else + INVALID_EXTENSION, +#endif +#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) { /* * "supported_groups" is spread across several specifications. @@ -197,7 +199,6 @@ static const EXTENSION_DEFINITION ext_defs[] = { }, #else INVALID_EXTENSION, - INVALID_EXTENSION, #endif { TLSEXT_TYPE_session_ticket, @@ -322,7 +323,6 @@ static const EXTENSION_DEFINITION ext_defs[] = { init_psk_kex_modes, tls_parse_ctos_psk_kex_modes, NULL, NULL, tls_construct_ctos_psk_kex_modes, NULL }, -#ifndef OPENSSL_NO_EC { /* * Must be in this list after supported_groups. We need that to have @@ -336,7 +336,6 @@ static const EXTENSION_DEFINITION ext_defs[] = { tls_construct_stoc_key_share, tls_construct_ctos_key_share, final_key_share }, -#endif { /* Must be after key_share */ TLSEXT_TYPE_cookie, @@ -1040,18 +1039,18 @@ static int final_ec_pt_formats(SSL *s, unsigned int context, int sent) */ if (s->ext.ecpointformats != NULL && s->ext.ecpointformats_len > 0 - && s->session->ext.ecpointformats != NULL - && s->session->ext.ecpointformats_len > 0 + && s->ext.peer_ecpointformats != NULL + && s->ext.peer_ecpointformats_len > 0 && ((alg_k & SSL_kECDHE) || (alg_a & SSL_aECDSA))) { /* we are using an ECC cipher */ size_t i; - unsigned char *list = s->session->ext.ecpointformats; + unsigned char *list = s->ext.peer_ecpointformats; - for (i = 0; i < s->session->ext.ecpointformats_len; i++) { + for (i = 0; i < s->ext.peer_ecpointformats_len; i++) { if (*list++ == TLSEXT_ECPOINTFORMAT_uncompressed) break; } - if (i == s->session->ext.ecpointformats_len) { + if (i == s->ext.peer_ecpointformats_len) { SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_FINAL_EC_PT_FORMATS, SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST); return 0; @@ -1266,9 +1265,9 @@ static int final_sig_algs(SSL *s, unsigned int context, int sent) return 1; } -#ifndef OPENSSL_NO_EC static int final_key_share(SSL *s, unsigned int context, int sent) { +#if !defined(OPENSSL_NO_TLS1_3) if (!SSL_IS_TLS13(s)) return 1; @@ -1426,10 +1425,9 @@ static int final_key_share(SSL *s, unsigned int context, int sent) return 0; } } - +#endif /* !defined(OPENSSL_NO_TLS1_3) */ return 1; } -#endif static int init_psk_kex_modes(SSL *s, unsigned int context) { diff --git a/ssl/statem/extensions_clnt.c b/ssl/statem/extensions_clnt.c index 979954ff..b6e96ae5 100644 --- a/ssl/statem/extensions_clnt.c +++ b/ssl/statem/extensions_clnt.c @@ -113,11 +113,13 @@ EXT_RETURN tls_construct_ctos_srp(SSL *s, WPACKET *pkt, unsigned int context, #endif #ifndef OPENSSL_NO_EC -static int use_ecc(SSL *s) +static int use_ecc(SSL *s, int max_version) { int i, end, ret = 0; unsigned long alg_k, alg_a; STACK_OF(SSL_CIPHER) *cipher_stack = NULL; + const uint16_t *pgroups = NULL; + size_t num_groups, j; /* See if we support any ECC ciphersuites */ if (s->version == SSL3_VERSION) @@ -137,9 +139,21 @@ static int use_ecc(SSL *s) break; } } - sk_SSL_CIPHER_free(cipher_stack); - return ret; + if (!ret) + return 0; + + /* Check we have at least one EC supported group */ + tls1_get_supported_groups(s, &pgroups, &num_groups); + for (j = 0; j < num_groups; j++) { + uint16_t ctmp = pgroups[j]; + + if (tls_valid_group(s, ctmp, max_version) + && tls_group_allowed(s, ctmp, SSL_SECOP_CURVE_SUPPORTED)) + return 1; + } + + return 0; } EXT_RETURN tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt, @@ -148,8 +162,15 @@ EXT_RETURN tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt, { const unsigned char *pformats; size_t num_formats; + int reason, min_version, max_version; - if (!use_ecc(s)) + reason = ssl_get_min_max_version(s, &min_version, &max_version, NULL); + if (reason != 0) { + SSLfatal(s, SSL_AD_INTERNAL_ERROR, + SSL_F_TLS_CONSTRUCT_CTOS_EC_PT_FORMATS, reason); + return EXT_RETURN_FAIL; + } + if (!use_ecc(s, max_version)) return EXT_RETURN_NOT_SENT; /* Add TLS extension ECPointFormats to the ClientHello message */ @@ -167,43 +188,59 @@ EXT_RETURN tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt, return EXT_RETURN_SENT; } +#endif +#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC) EXT_RETURN tls_construct_ctos_supported_groups(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, size_t chainidx) { const uint16_t *pgroups = NULL; size_t num_groups = 0, i; + int min_version, max_version, reason; - if (!use_ecc(s)) + reason = ssl_get_min_max_version(s, &min_version, &max_version, NULL); + if (reason != 0) { + SSLfatal(s, SSL_AD_INTERNAL_ERROR, + SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_GROUPS, reason); + return EXT_RETURN_FAIL; + } + +#if defined(OPENSSL_NO_EC) + if (max_version < TLS1_3_VERSION) return EXT_RETURN_NOT_SENT; +#else + if (!use_ecc(s, max_version) && max_version < TLS1_3_VERSION) + return EXT_RETURN_NOT_SENT; +#endif /* * Add TLS extension supported_groups to the ClientHello message */ - /* TODO(TLS1.3): Add support for DHE groups */ tls1_get_supported_groups(s, &pgroups, &num_groups); if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_supported_groups) /* Sub-packet for supported_groups extension */ || !WPACKET_start_sub_packet_u16(pkt) - || !WPACKET_start_sub_packet_u16(pkt)) { + || !WPACKET_start_sub_packet_u16(pkt) + || !WPACKET_set_flags(pkt, WPACKET_FLAGS_NON_ZERO_LENGTH)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_GROUPS, ERR_R_INTERNAL_ERROR); return EXT_RETURN_FAIL; } - /* Copy curve ID if supported */ + /* Copy group ID if supported */ for (i = 0; i < num_groups; i++) { uint16_t ctmp = pgroups[i]; - if (tls_curve_allowed(s, ctmp, SSL_SECOP_CURVE_SUPPORTED)) { + if (tls_valid_group(s, ctmp, max_version) + && tls_group_allowed(s, ctmp, SSL_SECOP_CURVE_SUPPORTED)) { if (!WPACKET_put_bytes_u16(pkt, ctmp)) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, - SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_GROUPS, - ERR_R_INTERNAL_ERROR); - return EXT_RETURN_FAIL; - } + SSLfatal(s, SSL_AD_INTERNAL_ERROR, + SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_GROUPS, + ERR_R_INTERNAL_ERROR); + return EXT_RETURN_FAIL; + } } } if (!WPACKET_close(pkt) || !WPACKET_close(pkt)) { @@ -674,7 +711,7 @@ EXT_RETURN tls_construct_ctos_key_share(SSL *s, WPACKET *pkt, } else { for (i = 0; i < num_groups; i++) { - if (!tls_curve_allowed(s, pgroups[i], SSL_SECOP_CURVE_SUPPORTED)) + if (!tls_group_allowed(s, pgroups[i], SSL_SECOP_CURVE_SUPPORTED)) continue; curve_id = pgroups[i]; @@ -1374,19 +1411,19 @@ int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context, return 0; } - s->session->ext.ecpointformats_len = 0; - OPENSSL_free(s->session->ext.ecpointformats); - s->session->ext.ecpointformats = OPENSSL_malloc(ecpointformats_len); - if (s->session->ext.ecpointformats == NULL) { + s->ext.peer_ecpointformats_len = 0; + OPENSSL_free(s->ext.peer_ecpointformats); + s->ext.peer_ecpointformats = OPENSSL_malloc(ecpointformats_len); + if (s->ext.peer_ecpointformats == NULL) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS, ERR_R_INTERNAL_ERROR); return 0; } - s->session->ext.ecpointformats_len = ecpointformats_len; + s->ext.peer_ecpointformats_len = ecpointformats_len; if (!PACKET_copy_bytes(&ecptformatlist, - s->session->ext.ecpointformats, + s->ext.peer_ecpointformats, ecpointformats_len)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS, ERR_R_INTERNAL_ERROR); @@ -1834,7 +1871,7 @@ int tls_parse_stoc_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x, break; } if (i >= num_groups - || !tls_curve_allowed(s, group_id, SSL_SECOP_CURVE_SUPPORTED)) { + || !tls_group_allowed(s, group_id, SSL_SECOP_CURVE_SUPPORTED)) { SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS_PARSE_STOC_KEY_SHARE, SSL_R_BAD_KEY_SHARE); return 0; diff --git a/ssl/statem/extensions_srvr.c b/ssl/statem/extensions_srvr.c index d107af3f..e16722cb 100644 --- a/ssl/statem/extensions_srvr.c +++ b/ssl/statem/extensions_srvr.c @@ -254,8 +254,8 @@ int tls_parse_ctos_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context, if (!s->hit) { if (!PACKET_memdup(&ec_point_format_list, - &s->session->ext.ecpointformats, - &s->session->ext.ecpointformats_len)) { + &s->ext.peer_ecpointformats, + &s->ext.peer_ecpointformats_len)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_CTOS_EC_PT_FORMATS, ERR_R_INTERNAL_ERROR); return 0; @@ -946,7 +946,7 @@ int tls_parse_ctos_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x, return 1; } -#ifndef OPENSSL_NO_EC +#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, unsigned int context, X509 *x, size_t chainidx) { @@ -962,12 +962,12 @@ int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, unsigned int context, } if (!s->hit || SSL_IS_TLS13(s)) { - OPENSSL_free(s->session->ext.supportedgroups); - s->session->ext.supportedgroups = NULL; - s->session->ext.supportedgroups_len = 0; + OPENSSL_free(s->ext.peer_supportedgroups); + s->ext.peer_supportedgroups = NULL; + s->ext.peer_supportedgroups_len = 0; if (!tls1_save_u16(&supported_groups_list, - &s->session->ext.supportedgroups, - &s->session->ext.supportedgroups_len)) { + &s->ext.peer_supportedgroups, + &s->ext.peer_supportedgroups_len)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_CTOS_SUPPORTED_GROUPS, ERR_R_INTERNAL_ERROR); @@ -1379,7 +1379,7 @@ EXT_RETURN tls_construct_stoc_ec_pt_formats(SSL *s, WPACKET *pkt, unsigned long alg_k = s->s3.tmp.new_cipher->algorithm_mkey; unsigned long alg_a = s->s3.tmp.new_cipher->algorithm_auth; int using_ecc = ((alg_k & SSL_kECDHE) || (alg_a & SSL_aECDSA)) - && (s->session->ext.ecpointformats != NULL); + && (s->ext.peer_ecpointformats != NULL); const unsigned char *plist; size_t plistlen; @@ -1400,7 +1400,7 @@ EXT_RETURN tls_construct_stoc_ec_pt_formats(SSL *s, WPACKET *pkt, } #endif -#ifndef OPENSSL_NO_EC +#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) EXT_RETURN tls_construct_stoc_supported_groups(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, size_t chainidx) @@ -1424,7 +1424,8 @@ EXT_RETURN tls_construct_stoc_supported_groups(SSL *s, WPACKET *pkt, for (i = 0; i < numgroups; i++) { uint16_t group = groups[i]; - if (tls_curve_allowed(s, group, SSL_SECOP_CURVE_SUPPORTED)) { + if (tls_valid_group(s, group, SSL_version(s)) + && tls_group_allowed(s, group, SSL_SECOP_CURVE_SUPPORTED)) { if (first) { /* * Check if the client is already using our preferred group. If diff --git a/ssl/statem/statem_clnt.c b/ssl/statem/statem_clnt.c index 1be7c574..d0961435 100644 --- a/ssl/statem/statem_clnt.c +++ b/ssl/statem/statem_clnt.c @@ -474,12 +474,6 @@ static WRITE_TRAN ossl_statem_client13_write_transition(SSL *s) return WRITE_TRAN_CONTINUE; case TLS_ST_CR_KEY_UPDATE: - if (s->key_update != SSL_KEY_UPDATE_NONE) { - st->hand_state = TLS_ST_CW_KEY_UPDATE; - return WRITE_TRAN_CONTINUE; - } - /* Fall through */ - case TLS_ST_CW_KEY_UPDATE: case TLS_ST_CR_SESSION_TICKET: case TLS_ST_CW_FINISHED: diff --git a/ssl/statem/statem_lib.c b/ssl/statem/statem_lib.c index 033ea613..292f99c8 100644 --- a/ssl/statem/statem_lib.c +++ b/ssl/statem/statem_lib.c @@ -286,9 +286,13 @@ int tls_construct_cert_verify(SSL *s, WPACKET *pkt) } if (s->version == SSL3_VERSION) { if (EVP_DigestSignUpdate(mctx, hdata, hdatalen) <= 0 - || !EVP_MD_CTX_ctrl(mctx, EVP_CTRL_SSL3_MASTER_SECRET, - (int)s->session->master_key_length, - s->session->master_key) + /* + * TODO(3.0) Replace this when EVP_MD_CTX_ctrl() is deprecated + * with a call to ssl3_digest_master_key_set_params() + */ + || EVP_MD_CTX_ctrl(mctx, EVP_CTRL_SSL3_MASTER_SECRET, + (int)s->session->master_key_length, + s->session->master_key) <= 0 || EVP_DigestSignFinal(mctx, sig, &siglen) <= 0) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CERT_VERIFY, @@ -473,10 +477,14 @@ MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt) } } if (s->version == SSL3_VERSION) { + /* + * TODO(3.0) Replace this when EVP_MD_CTX_ctrl() is deprecated + * with a call to ssl3_digest_master_key_set_params() + */ if (EVP_DigestVerifyUpdate(mctx, hdata, hdatalen) <= 0 - || !EVP_MD_CTX_ctrl(mctx, EVP_CTRL_SSL3_MASTER_SECRET, - (int)s->session->master_key_length, - s->session->master_key)) { + || EVP_MD_CTX_ctrl(mctx, EVP_CTRL_SSL3_MASTER_SECRET, + (int)s->session->master_key_length, + s->session->master_key) <= 0) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_EVP_LIB); goto err; @@ -643,12 +651,9 @@ MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt) /* * If we get a request for us to update our sending keys too then, we need * to additionally send a KeyUpdate message. However that message should - * not also request an update (otherwise we get into an infinite loop). We - * ignore a request for us to update our sending keys too if we already - * sent close_notify. + * not also request an update (otherwise we get into an infinite loop). */ - if (updatetype == SSL_KEY_UPDATE_REQUESTED - && (s->shutdown & SSL_SENT_SHUTDOWN) == 0) + if (updatetype == SSL_KEY_UPDATE_REQUESTED) s->key_update = SSL_KEY_UPDATE_NOT_REQUESTED; if (!tls13_update_key(s, 0)) { @@ -2132,7 +2137,6 @@ int ssl_set_client_hello_version(SSL *s) * used. Returns 1 if the group is in the list (and allowed if |checkallow| is * 1) or 0 otherwise. */ -#ifndef OPENSSL_NO_EC int check_in_list(SSL *s, uint16_t group_id, const uint16_t *groups, size_t num_groups, int checkallow) { @@ -2146,14 +2150,13 @@ int check_in_list(SSL *s, uint16_t group_id, const uint16_t *groups, if (group_id == group && (!checkallow - || tls_curve_allowed(s, group, SSL_SECOP_CURVE_CHECK))) { + || tls_group_allowed(s, group, SSL_SECOP_CURVE_CHECK))) { return 1; } } return 0; } -#endif /* Replace ClientHello1 in the transcript hash with a synthetic message */ int create_synthetic_message_hash(SSL *s, const unsigned char *hashval, diff --git a/ssl/statem/statem_locl.h b/ssl/statem/statem_locl.h index 8f27deb9..f4242fa2 100644 --- a/ssl/statem/statem_locl.h +++ b/ssl/statem/statem_locl.h @@ -199,9 +199,9 @@ int tls_parse_ctos_early_data(SSL *s, PACKET *pkt, unsigned int context, #ifndef OPENSSL_NO_EC int tls_parse_ctos_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context, X509 *x, size_t chainidx); +#endif int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, unsigned int context, X509 *x, size_t chainidxl); -#endif int tls_parse_ctos_session_ticket(SSL *s, PACKET *pkt, unsigned int context, X509 *x, size_t chainidx); int tls_parse_ctos_sig_algs_cert(SSL *s, PACKET *pkt, unsigned int context, @@ -314,10 +314,11 @@ EXT_RETURN tls_construct_ctos_srp(SSL *s, WPACKET *pkt, unsigned int context, X5 EXT_RETURN tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, size_t chainidx); +#endif EXT_RETURN tls_construct_ctos_supported_groups(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, size_t chainidx); -#endif + EXT_RETURN tls_construct_ctos_early_data(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, size_t chainidx); diff --git a/ssl/statem/statem_srvr.c b/ssl/statem/statem_srvr.c index cdfbfbd5..840006dd 100644 --- a/ssl/statem/statem_srvr.c +++ b/ssl/statem/statem_srvr.c @@ -503,12 +503,6 @@ static WRITE_TRAN ossl_statem_server13_write_transition(SSL *s) return WRITE_TRAN_CONTINUE; case TLS_ST_SR_KEY_UPDATE: - if (s->key_update != SSL_KEY_UPDATE_NONE) { - st->hand_state = TLS_ST_SW_KEY_UPDATE; - return WRITE_TRAN_CONTINUE; - } - /* Fall through */ - case TLS_ST_SW_KEY_UPDATE: st->hand_state = TLS_ST_OK; return WRITE_TRAN_CONTINUE; @@ -1930,14 +1924,14 @@ static int tls_early_post_process_client_hello(SSL *s) && master_key_length > 0) { s->session->master_key_length = master_key_length; s->hit = 1; - s->session->ciphers = ciphers; + s->peer_ciphers = ciphers; s->session->verify_result = X509_V_OK; ciphers = NULL; /* check if some cipher was preferred by call back */ if (pref_cipher == NULL) - pref_cipher = ssl3_choose_cipher(s, s->session->ciphers, + pref_cipher = ssl3_choose_cipher(s, s->peer_ciphers, ssl_get_cipher_preferences(s)); if (pref_cipher == NULL) { SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, @@ -1949,9 +1943,9 @@ static int tls_early_post_process_client_hello(SSL *s) s->session->cipher = pref_cipher; ssl_cipher_preference_list_free(s->cipher_list); s->cipher_list = ssl_cipher_preference_list_from_ciphers( - s->session->ciphers); + s->peer_ciphers); sk_SSL_CIPHER_free(s->cipher_list_by_id); - s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers); + s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->peer_ciphers); } } @@ -2051,12 +2045,12 @@ static int tls_early_post_process_client_hello(SSL *s) #endif /* - * Given s->session->ciphers and SSL_get_ciphers, we must pick a cipher + * Given s->peer_ciphers and SSL_get_ciphers, we must pick a cipher */ if (!s->hit || SSL_IS_TLS13(s)) { - sk_SSL_CIPHER_free(s->session->ciphers); - s->session->ciphers = ciphers; + sk_SSL_CIPHER_free(s->peer_ciphers); + s->peer_ciphers = ciphers; if (ciphers == NULL) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_EARLY_POST_PROCESS_CLIENT_HELLO, @@ -2072,6 +2066,10 @@ static int tls_early_post_process_client_hello(SSL *s) #else s->session->compress_meth = (comp == NULL) ? 0 : comp->id; #endif + if (!tls1_set_server_sigalgs(s)) { + /* SSLfatal() already called */ + goto err; + } } sk_SSL_CIPHER_free(ciphers); @@ -2239,31 +2237,25 @@ WORK_STATE tls_post_process_client_hello(SSL *s, WORK_STATE wst) if (wst == WORK_MORE_B) { if (!s->hit || SSL_IS_TLS13(s)) { /* Let cert callback update server certificates if required */ - if (!s->hit) { - if (s->cert->cert_cb != NULL) { - int rv = s->cert->cert_cb(s, s->cert->cert_cb_arg); - if (rv == 0) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, - SSL_F_TLS_POST_PROCESS_CLIENT_HELLO, - SSL_R_CERT_CB_ERROR); - goto err; - } - if (rv < 0) { - s->rwstate = SSL_X509_LOOKUP; - return WORK_MORE_B; - } - s->rwstate = SSL_NOTHING; - } - if (!tls1_set_server_sigalgs(s)) { - /* SSLfatal already called */ + if (!s->hit && s->cert->cert_cb != NULL) { + int rv = s->cert->cert_cb(s, s->cert->cert_cb_arg); + if (rv == 0) { + SSLfatal(s, SSL_AD_INTERNAL_ERROR, + SSL_F_TLS_POST_PROCESS_CLIENT_HELLO, + SSL_R_CERT_CB_ERROR); goto err; } + if (rv < 0) { + s->rwstate = SSL_X509_LOOKUP; + return WORK_MORE_B; + } + s->rwstate = SSL_NOTHING; } /* In TLSv1.3 we selected the ciphersuite before resumption */ if (!SSL_IS_TLS13(s)) { cipher = - ssl3_choose_cipher(s, s->session->ciphers, ssl_get_cipher_preferences(s)); + ssl3_choose_cipher(s, s->peer_ciphers, ssl_get_cipher_preferences(s)); if (cipher == NULL) { SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index 8fad1f20..05c4ba54 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -128,83 +128,115 @@ int tls1_clear(SSL *s) return 1; } -#ifndef OPENSSL_NO_EC - /* - * Table of curve information. - * Do not delete entries or reorder this array! It is used as a lookup - * table: the index of each entry is one less than the TLS curve id. + * Table of group information. */ +#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC) static const TLS_GROUP_INFO nid_list[] = { - {NID_sect163k1, 80, TLS_CURVE_CHAR2}, /* sect163k1 (1) */ - {NID_sect163r1, 80, TLS_CURVE_CHAR2}, /* sect163r1 (2) */ - {NID_sect163r2, 80, TLS_CURVE_CHAR2}, /* sect163r2 (3) */ - {NID_sect193r1, 80, TLS_CURVE_CHAR2}, /* sect193r1 (4) */ - {NID_sect193r2, 80, TLS_CURVE_CHAR2}, /* sect193r2 (5) */ - {NID_sect233k1, 112, TLS_CURVE_CHAR2}, /* sect233k1 (6) */ - {NID_sect233r1, 112, TLS_CURVE_CHAR2}, /* sect233r1 (7) */ - {NID_sect239k1, 112, TLS_CURVE_CHAR2}, /* sect239k1 (8) */ - {NID_sect283k1, 128, TLS_CURVE_CHAR2}, /* sect283k1 (9) */ - {NID_sect283r1, 128, TLS_CURVE_CHAR2}, /* sect283r1 (10) */ - {NID_sect409k1, 192, TLS_CURVE_CHAR2}, /* sect409k1 (11) */ - {NID_sect409r1, 192, TLS_CURVE_CHAR2}, /* sect409r1 (12) */ - {NID_sect571k1, 256, TLS_CURVE_CHAR2}, /* sect571k1 (13) */ - {NID_sect571r1, 256, TLS_CURVE_CHAR2}, /* sect571r1 (14) */ - {NID_secp160k1, 80, TLS_CURVE_PRIME}, /* secp160k1 (15) */ - {NID_secp160r1, 80, TLS_CURVE_PRIME}, /* secp160r1 (16) */ - {NID_secp160r2, 80, TLS_CURVE_PRIME}, /* secp160r2 (17) */ - {NID_secp192k1, 80, TLS_CURVE_PRIME}, /* secp192k1 (18) */ - {NID_X9_62_prime192v1, 80, TLS_CURVE_PRIME}, /* secp192r1 (19) */ - {NID_secp224k1, 112, TLS_CURVE_PRIME}, /* secp224k1 (20) */ - {NID_secp224r1, 112, TLS_CURVE_PRIME}, /* secp224r1 (21) */ - {NID_secp256k1, 128, TLS_CURVE_PRIME}, /* secp256k1 (22) */ - {NID_X9_62_prime256v1, 128, TLS_CURVE_PRIME}, /* secp256r1 (23) */ - {NID_secp384r1, 192, TLS_CURVE_PRIME}, /* secp384r1 (24) */ - {NID_secp521r1, 256, TLS_CURVE_PRIME}, /* secp521r1 (25) */ - {NID_brainpoolP256r1, 128, TLS_CURVE_PRIME}, /* brainpoolP256r1 (26) */ - {NID_brainpoolP384r1, 192, TLS_CURVE_PRIME}, /* brainpoolP384r1 (27) */ - {NID_brainpoolP512r1, 256, TLS_CURVE_PRIME}, /* brainpool512r1 (28) */ - {EVP_PKEY_X25519, 128, TLS_CURVE_CUSTOM}, /* X25519 (29) */ - {EVP_PKEY_X448, 224, TLS_CURVE_CUSTOM}, /* X448 (30) */ +# ifndef OPENSSL_NO_EC + {NID_sect163k1, 80, TLS_GROUP_CURVE_CHAR2, 0x0001}, /* sect163k1 (1) */ + {NID_sect163r1, 80, TLS_GROUP_CURVE_CHAR2, 0x0002}, /* sect163r1 (2) */ + {NID_sect163r2, 80, TLS_GROUP_CURVE_CHAR2, 0x0003}, /* sect163r2 (3) */ + {NID_sect193r1, 80, TLS_GROUP_CURVE_CHAR2, 0x0004}, /* sect193r1 (4) */ + {NID_sect193r2, 80, TLS_GROUP_CURVE_CHAR2, 0x0005}, /* sect193r2 (5) */ + {NID_sect233k1, 112, TLS_GROUP_CURVE_CHAR2, 0x0006}, /* sect233k1 (6) */ + {NID_sect233r1, 112, TLS_GROUP_CURVE_CHAR2, 0x0007}, /* sect233r1 (7) */ + {NID_sect239k1, 112, TLS_GROUP_CURVE_CHAR2, 0x0008}, /* sect239k1 (8) */ + {NID_sect283k1, 128, TLS_GROUP_CURVE_CHAR2, 0x0009}, /* sect283k1 (9) */ + {NID_sect283r1, 128, TLS_GROUP_CURVE_CHAR2, 0x000A}, /* sect283r1 (10) */ + {NID_sect409k1, 192, TLS_GROUP_CURVE_CHAR2, 0x000B}, /* sect409k1 (11) */ + {NID_sect409r1, 192, TLS_GROUP_CURVE_CHAR2, 0x000C}, /* sect409r1 (12) */ + {NID_sect571k1, 256, TLS_GROUP_CURVE_CHAR2, 0x000D}, /* sect571k1 (13) */ + {NID_sect571r1, 256, TLS_GROUP_CURVE_CHAR2, 0x000E}, /* sect571r1 (14) */ + {NID_secp160k1, 80, TLS_GROUP_CURVE_PRIME, 0x000F}, /* secp160k1 (15) */ + {NID_secp160r1, 80, TLS_GROUP_CURVE_PRIME, 0x0010}, /* secp160r1 (16) */ + {NID_secp160r2, 80, TLS_GROUP_CURVE_PRIME, 0x0011}, /* secp160r2 (17) */ + {NID_secp192k1, 80, TLS_GROUP_CURVE_PRIME, 0x0012}, /* secp192k1 (18) */ + {NID_X9_62_prime192v1, 80, TLS_GROUP_CURVE_PRIME, 0x0013}, /* secp192r1 (19) */ + {NID_secp224k1, 112, TLS_GROUP_CURVE_PRIME, 0x0014}, /* secp224k1 (20) */ + {NID_secp224r1, 112, TLS_GROUP_CURVE_PRIME, 0x0015}, /* secp224r1 (21) */ + {NID_secp256k1, 128, TLS_GROUP_CURVE_PRIME, 0x0016}, /* secp256k1 (22) */ + {NID_X9_62_prime256v1, 128, TLS_GROUP_CURVE_PRIME, 0x0017}, /* secp256r1 (23) */ + {NID_secp384r1, 192, TLS_GROUP_CURVE_PRIME, 0x0018}, /* secp384r1 (24) */ + {NID_secp521r1, 256, TLS_GROUP_CURVE_PRIME, 0x0019}, /* secp521r1 (25) */ + {NID_brainpoolP256r1, 128, TLS_GROUP_CURVE_PRIME, 0x001A}, /* brainpoolP256r1 (26) */ + {NID_brainpoolP384r1, 192, TLS_GROUP_CURVE_PRIME, 0x001B}, /* brainpoolP384r1 (27) */ + {NID_brainpoolP512r1, 256, TLS_GROUP_CURVE_PRIME, 0x001C}, /* brainpool512r1 (28) */ + {EVP_PKEY_X25519, 128, TLS_GROUP_CURVE_CUSTOM, 0x001D}, /* X25519 (29) */ + {EVP_PKEY_X448, 224, TLS_GROUP_CURVE_CUSTOM, 0x001E}, /* X448 (30) */ +# endif /* OPENSSL_NO_EC */ +# ifndef OPENSSL_NO_DH + /* Security bit values for FFDHE groups are updated as per RFC 7919 */ + {NID_ffdhe2048, 103, TLS_GROUP_FFDHE_FOR_TLS1_3, 0x0100}, /* ffdhe2048 (0x0100) */ + {NID_ffdhe3072, 125, TLS_GROUP_FFDHE_FOR_TLS1_3, 0x0101}, /* ffdhe3072 (0x0101) */ + {NID_ffdhe4096, 150, TLS_GROUP_FFDHE_FOR_TLS1_3, 0x0102}, /* ffdhe4096 (0x0102) */ + {NID_ffdhe6144, 175, TLS_GROUP_FFDHE_FOR_TLS1_3, 0x0103}, /* ffdhe6144 (0x0103) */ + {NID_ffdhe8192, 192, TLS_GROUP_FFDHE_FOR_TLS1_3, 0x0104}, /* ffdhe8192 (0x0104) */ +# endif /* OPENSSL_NO_DH */ }; +#endif +#ifndef OPENSSL_NO_EC static const unsigned char ecformats_default[] = { TLSEXT_ECPOINTFORMAT_uncompressed, TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime, TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 }; +#endif /* !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) */ /* The default curves */ -static const uint16_t eccurves_default[] = { +#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC) +static const uint16_t supported_groups_default[] = { +# ifndef OPENSSL_NO_EC 29, /* X25519 (29) */ 23, /* secp256r1 (23) */ 30, /* X448 (30) */ 25, /* secp521r1 (25) */ 24, /* secp384r1 (24) */ +# endif +# ifndef OPENSSL_NO_DH + 0x100, /* ffdhe2048 (0x100) */ + 0x101, /* ffdhe3072 (0x101) */ + 0x102, /* ffdhe4096 (0x102) */ + 0x103, /* ffdhe6144 (0x103) */ + 0x104, /* ffdhe8192 (0x104) */ +# endif }; +#endif /* !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) */ +#ifndef OPENSSL_NO_EC static const uint16_t suiteb_curves[] = { TLSEXT_curve_P_256, TLSEXT_curve_P_384 }; +#endif const TLS_GROUP_INFO *tls1_group_id_lookup(uint16_t group_id) { - /* ECC curves from RFC 4492 and RFC 7027 */ - if (group_id < 1 || group_id > OSSL_NELEM(nid_list)) - return NULL; - return &nid_list[group_id - 1]; +#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC) + size_t i; + + /* ECC curves from RFC 4492 and RFC 7027 FFDHE group from RFC 8446 */ + for (i = 0; i < OSSL_NELEM(nid_list); i++) { + if (nid_list[i].group_id == group_id) + return &nid_list[i]; + } +#endif /* !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC) */ + return NULL; } +#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC) static uint16_t tls1_nid2group_id(int nid) { size_t i; + for (i = 0; i < OSSL_NELEM(nid_list); i++) { if (nid_list[i].nid == nid) - return (uint16_t)(i + 1); + return nid_list[i].group_id; } return 0; } +#endif /* !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) */ /* * Set *pgroups to the supported groups list and *pgroupslen to @@ -213,9 +245,10 @@ static uint16_t tls1_nid2group_id(int nid) void tls1_get_supported_groups(SSL *s, const uint16_t **pgroups, size_t *pgroupslen) { - +#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) /* For Suite B mode only include P-256, P-384 */ switch (tls1_suiteb(s)) { +# ifndef OPENSSL_NO_EC case SSL_CERT_FLAG_SUITEB_128_LOS: *pgroups = suiteb_curves; *pgroupslen = OSSL_NELEM(suiteb_curves); @@ -230,34 +263,54 @@ void tls1_get_supported_groups(SSL *s, const uint16_t **pgroups, *pgroups = suiteb_curves + 1; *pgroupslen = 1; break; +# endif default: if (s->ext.supportedgroups == NULL) { - *pgroups = eccurves_default; - *pgroupslen = OSSL_NELEM(eccurves_default); + *pgroups = supported_groups_default; + *pgroupslen = OSSL_NELEM(supported_groups_default); } else { *pgroups = s->ext.supportedgroups; *pgroupslen = s->ext.supportedgroups_len; } break; } +#else + *pgroups = NULL; + *pgroupslen = 0; +#endif /* !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) */ } -/* See if curve is allowed by security callback */ -int tls_curve_allowed(SSL *s, uint16_t curve, int op) +int tls_valid_group(SSL *s, uint16_t group_id, int version) { - const TLS_GROUP_INFO *cinfo = tls1_group_id_lookup(curve); - unsigned char ctmp[2]; + const TLS_GROUP_INFO *ginfo = tls1_group_id_lookup(group_id); - if (cinfo == NULL) + if (version < TLS1_3_VERSION) { + if ((ginfo->flags & TLS_GROUP_ONLY_FOR_TLS1_3) != 0) + return 0; + } + return 1; +} + +/* See if group is allowed by security callback */ +int tls_group_allowed(SSL *s, uint16_t group, int op) +{ + const TLS_GROUP_INFO *ginfo = tls1_group_id_lookup(group); + unsigned char gtmp[2]; + + if (ginfo == NULL) return 0; -# ifdef OPENSSL_NO_EC2M - if (cinfo->flags & TLS_CURVE_CHAR2) +#ifdef OPENSSL_NO_EC2M + if (ginfo->flags & TLS_GROUP_CURVE_CHAR2) return 0; -# endif - ctmp[0] = curve >> 8; - ctmp[1] = curve & 0xff; - return ssl_security(s, op, cinfo->secbits, cinfo->nid, (void *)ctmp); +#endif +#ifdef OPENSSL_NO_DH + if (ginfo->flags & TLS_GROUP_FFDHE) + return 0; +#endif + gtmp[0] = group >> 8; + gtmp[1] = group & 0xff; + return ssl_security(s, op, ginfo->secbits, ginfo->nid, (void *)gtmp); } /* Return 1 if "id" is in "list" */ @@ -320,7 +373,7 @@ uint16_t tls1_shared_group(SSL *s, int nmatch) uint16_t id = pref[i]; if (!tls1_in_list(id, supp, num_supp) - || !tls_curve_allowed(s, id, SSL_SECOP_CURVE_SHARED)) + || !tls_group_allowed(s, id, SSL_SECOP_CURVE_SHARED)) continue; if (nmatch == k) return id; @@ -335,13 +388,16 @@ uint16_t tls1_shared_group(SSL *s, int nmatch) int tls1_set_groups(uint16_t **pext, size_t *pextlen, int *groups, size_t ngroups) { +#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) uint16_t *glist; size_t i; /* - * Bitmap of groups included to detect duplicates: only works while group - * ids < 32 + * Bitmap of groups included to detect duplicates: two variables are added + * to detect duplicates as some values are more than 32. */ - unsigned long dup_list = 0; + unsigned long *dup_list = NULL; + unsigned long dup_list_egrp = 0; + unsigned long dup_list_dhgrp = 0; if (ngroups == 0) { SSLerr(SSL_F_TLS1_SET_GROUPS, SSL_R_BAD_LENGTH); @@ -354,44 +410,53 @@ int tls1_set_groups(uint16_t **pext, size_t *pextlen, for (i = 0; i < ngroups; i++) { unsigned long idmask; uint16_t id; - /* TODO(TLS1.3): Convert for DH groups */ id = tls1_nid2group_id(groups[i]); - idmask = 1L << id; - if (!id || (dup_list & idmask)) { - OPENSSL_free(glist); - return 0; - } - dup_list |= idmask; + if ((id & 0x00FF) >= (sizeof(unsigned long) * 8)) + goto err; + idmask = 1L << (id & 0x00FF); + dup_list = (id < 0x100) ? &dup_list_egrp : &dup_list_dhgrp; + if (!id || ((*dup_list) & idmask)) + goto err; + *dup_list |= idmask; glist[i] = id; } OPENSSL_free(*pext); *pext = glist; *pextlen = ngroups; return 1; +err: + OPENSSL_free(glist); + return 0; +#else + return 0; +#endif /* !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) */ } -# define MAX_CURVELIST OSSL_NELEM(nid_list) +#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) +# define MAX_GROUPLIST OSSL_NELEM(nid_list) typedef struct { size_t nidcnt; - int nid_arr[MAX_CURVELIST]; + int nid_arr[MAX_GROUPLIST]; } nid_cb_st; static int nid_cb(const char *elem, int len, void *arg) { nid_cb_st *narg = arg; size_t i; - int nid; + int nid = NID_undef; char etmp[20]; if (elem == NULL) return 0; - if (narg->nidcnt == MAX_CURVELIST) + if (narg->nidcnt == MAX_GROUPLIST) return 0; if (len > (int)(sizeof(etmp) - 1)) return 0; memcpy(etmp, elem, len); etmp[len] = 0; +# ifndef OPENSSL_NO_EC nid = EC_curve_nist2nid(etmp); +# endif if (nid == NID_undef) nid = OBJ_sn2nid(etmp); if (nid == NID_undef) @@ -404,10 +469,12 @@ static int nid_cb(const char *elem, int len, void *arg) narg->nid_arr[narg->nidcnt++] = nid; return 1; } +#endif /* !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) */ /* Set groups based on a colon separate list */ int tls1_set_groups_list(uint16_t **pext, size_t *pextlen, const char *str) { +#if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) nid_cb_st ncb; ncb.nidcnt = 0; if (!CONF_parse_list(str, ':', 1, nid_cb, &ncb)) @@ -415,17 +482,82 @@ int tls1_set_groups_list(uint16_t **pext, size_t *pextlen, const char *str) if (pext == NULL) return 1; return tls1_set_groups(pext, pextlen, ncb.nid_arr, ncb.nidcnt); +#else + return 0; +#endif } -/* Return group id of a key */ -static uint16_t tls1_get_group_id(EVP_PKEY *pkey) -{ - EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey); - const EC_GROUP *grp; - if (ec == NULL) +/* Check a group id matches preferences */ +int tls1_check_group_id(SSL *s, uint16_t group_id, int check_own_groups) + { + const uint16_t *groups; + size_t groups_len; + + if (group_id == 0) return 0; - grp = EC_KEY_get0_group(ec); - return tls1_nid2group_id(EC_GROUP_get_curve_name(grp)); + + /* Check for Suite B compliance */ + if (tls1_suiteb(s) && s->s3.tmp.new_cipher != NULL) { + unsigned long cid = s->s3.tmp.new_cipher->id; + + if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256) { + if (group_id != TLSEXT_curve_P_256) + return 0; + } else if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384) { + if (group_id != TLSEXT_curve_P_384) + return 0; + } else { + /* Should never happen */ + return 0; + } + } + + if (check_own_groups) { + /* Check group is one of our preferences */ + tls1_get_supported_groups(s, &groups, &groups_len); + if (!tls1_in_list(group_id, groups, groups_len)) + return 0; + } + + if (!tls_group_allowed(s, group_id, SSL_SECOP_CURVE_CHECK)) + return 0; + + /* For clients, nothing more to check */ + if (!s->server) + return 1; + + /* Check group is one of peers preferences */ + tls1_get_peer_groups(s, &groups, &groups_len); + + /* + * RFC 4492 does not require the supported elliptic curves extension + * so if it is not sent we can just choose any curve. + * It is invalid to send an empty list in the supported groups + * extension, so groups_len == 0 always means no extension. + */ + if (groups_len == 0) + return 1; + return tls1_in_list(group_id, groups, groups_len); +} + +#ifndef OPENSSL_NO_EC +void tls1_get_formatlist(SSL *s, const unsigned char **pformats, + size_t *num_formats) +{ + /* + * If we have a custom point format list use it otherwise use default + */ + if (s->ext.ecpointformats) { + *pformats = s->ext.ecpointformats; + *num_formats = s->ext.ecpointformats_len; + } else { + *pformats = ecformats_default; + /* For Suite B we don't support char2 fields */ + if (tls1_suiteb(s)) + *num_formats = sizeof(ecformats_default) - 1; + else + *num_formats = sizeof(ecformats_default); + } } /* Check a key is compatible with compression extension */ @@ -465,86 +597,26 @@ static int tls1_check_pkey_comp(SSL *s, EVP_PKEY *pkey) * If point formats extension present check it, otherwise everything is * supported (see RFC4492). */ - if (s->session->ext.ecpointformats == NULL) + if (s->ext.peer_ecpointformats == NULL) return 1; - for (i = 0; i < s->session->ext.ecpointformats_len; i++) { - if (s->session->ext.ecpointformats[i] == comp_id) + for (i = 0; i < s->ext.peer_ecpointformats_len; i++) { + if (s->ext.peer_ecpointformats[i] == comp_id) return 1; } return 0; } -/* Check a group id matches preferences */ -int tls1_check_group_id(SSL *s, uint16_t group_id, int check_own_groups) - { - const uint16_t *groups; - size_t groups_len; - - if (group_id == 0) - return 0; - - /* Check for Suite B compliance */ - if (tls1_suiteb(s) && s->s3.tmp.new_cipher != NULL) { - unsigned long cid = s->s3.tmp.new_cipher->id; - - if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256) { - if (group_id != TLSEXT_curve_P_256) - return 0; - } else if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384) { - if (group_id != TLSEXT_curve_P_384) - return 0; - } else { - /* Should never happen */ - return 0; - } - } - - if (check_own_groups) { - /* Check group is one of our preferences */ - tls1_get_supported_groups(s, &groups, &groups_len); - if (!tls1_in_list(group_id, groups, groups_len)) - return 0; - } - - if (!tls_curve_allowed(s, group_id, SSL_SECOP_CURVE_CHECK)) - return 0; - - /* For clients, nothing more to check */ - if (!s->server) - return 1; - - /* Check group is one of peers preferences */ - tls1_get_peer_groups(s, &groups, &groups_len); - - /* - * RFC 4492 does not require the supported elliptic curves extension - * so if it is not sent we can just choose any curve. - * It is invalid to send an empty list in the supported groups - * extension, so groups_len == 0 always means no extension. - */ - if (groups_len == 0) - return 1; - return tls1_in_list(group_id, groups, groups_len); -} - -void tls1_get_formatlist(SSL *s, const unsigned char **pformats, - size_t *num_formats) +/* Return group id of a key */ +static uint16_t tls1_get_group_id(EVP_PKEY *pkey) { - /* - * If we have a custom point format list use it otherwise use default - */ - if (s->ext.ecpointformats) { - *pformats = s->ext.ecpointformats; - *num_formats = s->ext.ecpointformats_len; - } else { - *pformats = ecformats_default; - /* For Suite B we don't support char2 fields */ - if (tls1_suiteb(s)) - *num_formats = sizeof(ecformats_default) - 1; - else - *num_formats = sizeof(ecformats_default); - } + EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey); + const EC_GROUP *grp; + + if (ec == NULL) + return 0; + grp = EC_KEY_get0_group(ec); + return tls1_nid2group_id(EC_GROUP_get_curve_name(grp)); } /* @@ -578,7 +650,6 @@ static int tls1_check_cert_param(SSL *s, X509 *x, int check_ee_md) if (check_ee_md && tls1_suiteb(s)) { int check_md; size_t i; - CERT *c = s->cert; /* Check to see we have necessary signing algorithm */ if (group_id == TLSEXT_curve_P_256) @@ -587,8 +658,8 @@ static int tls1_check_cert_param(SSL *s, X509 *x, int check_ee_md) check_md = NID_ecdsa_with_SHA384; else return 0; /* Should never happen */ - for (i = 0; i < c->shared_sigalgslen; i++) { - if (check_md == c->shared_sigalgs[i]->sigandhash) + for (i = 0; i < s->shared_sigalgslen; i++) { + if (check_md == s->shared_sigalgs[i]->sigandhash) return 1;; } return 0; @@ -1215,9 +1286,9 @@ int tls1_set_server_sigalgs(SSL *s) size_t i; /* Clear any shared signature algorithms */ - OPENSSL_free(s->cert->shared_sigalgs); - s->cert->shared_sigalgs = NULL; - s->cert->shared_sigalgslen = 0; + OPENSSL_free(s->shared_sigalgs); + s->shared_sigalgs = NULL; + s->shared_sigalgslen = 0; /* Clear certificate validity flags */ for (i = 0; i < SSL_PKEY_NUM; i++) s->s3.tmp.valid_flags[i] = 0; @@ -1252,7 +1323,7 @@ int tls1_set_server_sigalgs(SSL *s) SSL_F_TLS1_SET_SERVER_SIGALGS, ERR_R_INTERNAL_ERROR); return 0; } - if (s->cert->shared_sigalgs != NULL) + if (s->shared_sigalgs != NULL) return 1; /* Fatal error if no shared signature algorithms */ @@ -1724,9 +1795,9 @@ static int tls1_set_shared_sigalgs(SSL *s) CERT *c = s->cert; unsigned int is_suiteb = tls1_suiteb(s); - OPENSSL_free(c->shared_sigalgs); - c->shared_sigalgs = NULL; - c->shared_sigalgslen = 0; + OPENSSL_free(s->shared_sigalgs); + s->shared_sigalgs = NULL; + s->shared_sigalgslen = 0; /* If client use client signature algorithms if not NULL */ if (!s->server && c->client_sigalgs && !is_suiteb) { conf = c->client_sigalgs; @@ -1757,8 +1828,8 @@ static int tls1_set_shared_sigalgs(SSL *s) } else { salgs = NULL; } - c->shared_sigalgs = salgs; - c->shared_sigalgslen = nmatch; + s->shared_sigalgs = salgs; + s->shared_sigalgslen = nmatch; return 1; } @@ -1819,7 +1890,6 @@ int tls1_process_sigalgs(SSL *s) { size_t i; uint32_t *pvalid = s->s3.tmp.valid_flags; - CERT *c = s->cert; if (!tls1_set_shared_sigalgs(s)) return 0; @@ -1827,8 +1897,8 @@ int tls1_process_sigalgs(SSL *s) for (i = 0; i < SSL_PKEY_NUM; i++) pvalid[i] = 0; - for (i = 0; i < c->shared_sigalgslen; i++) { - const SIGALG_LOOKUP *sigptr = c->shared_sigalgs[i]; + for (i = 0; i < s->shared_sigalgslen; i++) { + const SIGALG_LOOKUP *sigptr = s->shared_sigalgs[i]; int idx = sigptr->sig_idx; /* Ignore PKCS1 based sig algs in TLSv1.3 */ @@ -1875,12 +1945,12 @@ int SSL_get_shared_sigalgs(SSL *s, int idx, unsigned char *rsig, unsigned char *rhash) { const SIGALG_LOOKUP *shsigalgs; - if (s->cert->shared_sigalgs == NULL + if (s->shared_sigalgs == NULL || idx < 0 - || idx >= (int)s->cert->shared_sigalgslen - || s->cert->shared_sigalgslen > INT_MAX) + || idx >= (int)s->shared_sigalgslen + || s->shared_sigalgslen > INT_MAX) return 0; - shsigalgs = s->cert->shared_sigalgs[idx]; + shsigalgs = s->shared_sigalgs[idx]; if (phash != NULL) *phash = shsigalgs->hash; if (psign != NULL) @@ -1891,7 +1961,7 @@ int SSL_get_shared_sigalgs(SSL *s, int idx, *rsig = (unsigned char)(shsigalgs->sigalg & 0xff); if (rhash != NULL) *rhash = (unsigned char)((shsigalgs->sigalg >> 8) & 0xff); - return (int)s->cert->shared_sigalgslen; + return (int)s->shared_sigalgslen; } /* Maximum possible number of unique entries in sigalgs array */ @@ -2072,7 +2142,7 @@ int tls1_set_sigalgs(CERT *c, const int *psig_nids, size_t salglen, int client) return 0; } -static int tls1_check_sig_alg(CERT *c, X509 *x, int default_nid) +static int tls1_check_sig_alg(SSL *s, X509 *x, int default_nid) { int sig_nid; size_t i; @@ -2081,8 +2151,8 @@ static int tls1_check_sig_alg(CERT *c, X509 *x, int default_nid) sig_nid = X509_get_signature_nid(x); if (default_nid) return sig_nid == default_nid ? 1 : 0; - for (i = 0; i < c->shared_sigalgslen; i++) - if (sig_nid == c->shared_sigalgs[i]->sigandhash) + for (i = 0; i < s->shared_sigalgslen; i++) + if (sig_nid == s->shared_sigalgs[i]->sigandhash) return 1; return 0; } @@ -2240,14 +2310,14 @@ int tls1_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain, } } /* Check signature algorithm of each cert in chain */ - if (!tls1_check_sig_alg(c, x, default_nid)) { + if (!tls1_check_sig_alg(s, x, default_nid)) { if (!check_flags) goto end; } else rv |= CERT_PKEY_EE_SIGNATURE; rv |= CERT_PKEY_CA_SIGNATURE; for (i = 0; i < sk_X509_num(chain); i++) { - if (!tls1_check_sig_alg(c, sk_X509_value(chain, i), default_nid)) { + if (!tls1_check_sig_alg(s, sk_X509_value(chain, i), default_nid)) { if (check_flags) { rv &= ~CERT_PKEY_CA_SIGNATURE; break; @@ -2612,8 +2682,8 @@ int tls_choose_sigalg(SSL *s, int fatalerrs) #endif /* Look for a certificate matching shared sigalgs */ - for (i = 0; i < s->cert->shared_sigalgslen; i++) { - lu = s->cert->shared_sigalgs[i]; + for (i = 0; i < s->shared_sigalgslen; i++) { + lu = s->shared_sigalgs[i]; sig_idx = -1; /* Skip SHA1, SHA224, DSA and RSA if not PSS */ @@ -2647,7 +2717,7 @@ int tls_choose_sigalg(SSL *s, int fatalerrs) } break; } - if (i == s->cert->shared_sigalgslen) { + if (i == s->shared_sigalgslen) { if (!fatalerrs) return 1; SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS_CHOOSE_SIGALG, @@ -2680,8 +2750,8 @@ int tls_choose_sigalg(SSL *s, int fatalerrs) * Find highest preference signature algorithm matching * cert type */ - for (i = 0; i < s->cert->shared_sigalgslen; i++) { - lu = s->cert->shared_sigalgs[i]; + for (i = 0; i < s->shared_sigalgslen; i++) { + lu = s->shared_sigalgs[i]; if (s->server) { if ((sig_idx = tls12_get_cert_sigalg_idx(s, lu)) == -1) @@ -2708,7 +2778,7 @@ int tls_choose_sigalg(SSL *s, int fatalerrs) #endif break; } - if (i == s->cert->shared_sigalgslen) { + if (i == s->shared_sigalgslen) { if (!fatalerrs) return 1; SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, diff --git a/ssl/tls13_enc.c b/ssl/tls13_enc.c index b0fc4b29..9bc34c1b 100644 --- a/ssl/tls13_enc.c +++ b/ssl/tls13_enc.c @@ -170,6 +170,7 @@ int tls13_generate_secret(SSL *s, const EVP_MD *md, if (!ossl_assert(mdleni >= 0)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_GENERATE_SECRET, ERR_R_INTERNAL_ERROR); + EVP_KDF_CTX_free(kctx); return 0; } mdlen = (size_t)mdleni; diff --git a/test/README b/test/README index ebe77846..9a093814 100644 --- a/test/README +++ b/test/README @@ -6,7 +6,8 @@ test/recipes/, named {nn}-test_{name}.t, where {nn} is a two digit number and {name} is a unique name of your choice. Please note that if a test involves a new testing executable, you will need to -do some additions in test/Makefile. More on this later. +do some additions in test/build.info. Please refer to the section "Changes to +test/build.info" below. Naming conventions @@ -100,7 +101,7 @@ to modify the include paths and source files if you don't want to use the basic test framework: SOURCE[{name}]={name}.c - INCLUDE[{name}]=.. ../include + INCLUDE[{name}]=.. ../include ../apps/include DEPEND[{name}]=../libcrypto libtestutil.a Generic form of C test executables diff --git a/test/asn1_time_test.c b/test/asn1_time_test.c index 3edc78d0..a619b373 100644 --- a/test/asn1_time_test.c +++ b/test/asn1_time_test.c @@ -24,8 +24,8 @@ struct testdata { int expected_type; /* expected type after set/set_string_gmt */ int check_result; /* check result */ time_t t; /* expected time_t*/ - int cmp_result; /* compariston to baseline result */ - int convert_result; /* convertion result */ + int cmp_result; /* comparison to baseline result */ + int convert_result; /* conversion result */ }; static struct testdata tbl_testdata_pos[] = { diff --git a/test/bio_memleak_test.c b/test/bio_memleak_test.c index fab5ce73..dab61f6f 100644 --- a/test/bio_memleak_test.c +++ b/test/bio_memleak_test.c @@ -181,6 +181,45 @@ finish: return ok; } +static int test_bio_nonclear_rst(void) +{ + int ok = 0; + BIO *bio = NULL; + char data[16]; + + bio = BIO_new(BIO_s_mem()); + if (!TEST_ptr(bio)) + goto finish; + if (!TEST_int_eq(BIO_puts(bio, "Hello World\n"), 12)) + goto finish; + + BIO_set_flags(bio, BIO_FLAGS_NONCLEAR_RST); + + if (!TEST_int_eq(BIO_read(bio, data, 16), 12)) + goto finish; + if (!TEST_mem_eq(data, 12, "Hello World\n", 12)) + goto finish; + if (!TEST_int_gt(BIO_reset(bio), 0)) + goto finish; + + if (!TEST_int_eq(BIO_read(bio, data, 16), 12)) + goto finish; + if (!TEST_mem_eq(data, 12, "Hello World\n", 12)) + goto finish; + + BIO_clear_flags(bio, BIO_FLAGS_NONCLEAR_RST); + if (!TEST_int_gt(BIO_reset(bio), 0)) + goto finish; + + if (!TEST_int_lt(BIO_read(bio, data, 16), 1)) + goto finish; + + ok = 1; + +finish: + BIO_free(bio); + return ok; +} int global_init(void) { @@ -196,5 +235,6 @@ int setup_tests(void) ADD_TEST(test_bio_new_mem_buf); ADD_TEST(test_bio_rdonly_mem_buf); ADD_TEST(test_bio_rdwr_rdonly); + ADD_TEST(test_bio_nonclear_rst); return 1; } diff --git a/test/bn_rand_range.h b/test/bn_rand_range.h new file mode 100644 index 00000000..2a63ef72 --- /dev/null +++ b/test/bn_rand_range.h @@ -0,0 +1,58 @@ +/* + * WARNING: do not edit! + * Generated by statistics/bn_rand_range.py in the OpenSSL tool repository. + * + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +static const struct { + unsigned int range; + unsigned int iterations; + double critical; +} rand_range_cases[] = { + { 2, 200, 3.841459 }, + { 3, 300, 5.991465 }, + { 4, 400, 7.814728 }, + { 5, 500, 9.487729 }, + { 6, 600, 11.070498 }, + { 7, 700, 12.591587 }, + { 8, 800, 14.067140 }, + { 9, 900, 15.507313 }, + { 10, 1000, 16.918978 }, + { 11, 1100, 18.307038 }, + { 12, 1200, 19.675138 }, + { 13, 1300, 21.026070 }, + { 14, 1400, 22.362032 }, + { 15, 1500, 23.684791 }, + { 16, 1600, 24.995790 }, + { 17, 1700, 26.296228 }, + { 18, 1800, 27.587112 }, + { 19, 1900, 28.869299 }, + { 20, 2000, 30.143527 }, + { 30, 3000, 42.556968 }, + { 40, 4000, 54.572228 }, + { 50, 5000, 66.338649 }, + { 60, 6000, 77.930524 }, + { 70, 7000, 89.391208 }, + { 80, 8000, 100.748619 }, + { 90, 9000, 112.021986 }, + { 100, 10000, 123.225221 }, + { 1000, 10000, 1073.642651 }, + { 2000, 20000, 2104.128222 }, + { 3000, 30000, 3127.515432 }, + { 4000, 40000, 4147.230012 }, + { 5000, 50000, 5164.598069 }, + { 6000, 60000, 6180.299514 }, + { 7000, 70000, 7194.738181 }, + { 8000, 80000, 8208.177159 }, + { 9000, 90000, 9220.799176 }, + { 10000, 100000, 10232.737266 }, +}; + +static const int binomial_critical = 29; + diff --git a/test/bntest.c b/test/bntest.c index 2043e43e..1e502103 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -1956,25 +1956,27 @@ static int test_rand(void) /* * Run some statistical tests to provide a degree confidence that the - * BN_rand_range() function works as expected. The critical value - * is computed using the R statistical suite: + * BN_rand_range() function works as expected. The test cases and + * critical values are generated by the bn_rand_range script. * - * qchisq(alpha, df=iterations - 1) + * Each individual test is a Chi^2 goodness of fit for a specified number + * of samples and range. The samples are assumed to be independent and + * that they are from a discrete uniform distribution. * - * where alpha is the significance level (0.95 is used here) and iterations - * is the number of samples being drawn. + * Some of these individual tests are expected to fail, the success/failure + * of each is an independent Bernoulli trial. The number of such successes + * will form a binomial distribution. The count of the successes is compared + * against a precomputed critical value to determine the overall outcome. */ -static const struct { +struct rand_range_case { unsigned int range; unsigned int iterations; double critical; -} rand_range_cases[] = { - { 2, 100, 123.2252 /* = qchisq(.95, df=99) */ }, - { 12, 1000, 1073.643 /* = qchisq(.95, df=999) */ }, - { 1023, 100000, 100735.7 /* = qchisq(.95, df=99999) */ }, }; -static int test_rand_range(int n) +#include "bn_rand_range.h" + +static int test_rand_range_single(size_t n) { const unsigned int range = rand_range_cases[n].range; const unsigned int iterations = rand_range_cases[n].iterations; @@ -1998,22 +2000,20 @@ static int test_rand_range(int n) counts[v]++; } - TEST_note("range %u iterations %u critical %.4f", range, iterations, - critical); - if (range < 20) { - TEST_note("frequencies (expected %.2f)", expected); - for (i = 0; i < range; i++) - TEST_note(" %2u %6zu", i, counts[i]); - } for (i = 0; i < range; i++) { const double delta = counts[i] - expected; sum += delta * delta; } sum /= expected; - TEST_note("test statistic %.4f", sum); - if (TEST_double_lt(sum, critical)) - res = 1; + if (sum > critical) { + TEST_info("Chi^2 test negative %.4f > %4.f", sum, critical); + TEST_note("test case %zu range %u iterations %u", n + 1, range, + iterations); + goto err; + } + + res = 1; err: BN_free(rng); BN_free(val); @@ -2021,6 +2021,19 @@ err: return res; } +static int test_rand_range(void) +{ + int n_success = 0; + size_t i; + + for (i = 0; i < OSSL_NELEM(rand_range_cases); i++) + n_success += test_rand_range_single(i); + if (TEST_int_ge(n_success, binomial_critical)) + return 1; + TEST_note("This test is expeced to fail by chance 0.01%% of the time."); + return 0; +} + static int test_negzero(void) { BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL; @@ -2236,18 +2249,50 @@ static int test_expmodone(void) return ret; } -static int test_smallprime(void) +static int test_smallprime(int kBits) { - static const int kBits = 10; BIGNUM *r; int st = 0; - if (!TEST_ptr(r = BN_new()) - || !TEST_true(BN_generate_prime_ex(r, (int)kBits, 0, - NULL, NULL, NULL)) - || !TEST_int_eq(BN_num_bits(r), kBits)) + if (!TEST_ptr(r = BN_new())) goto err; + if (kBits <= 1) { + if (!TEST_false(BN_generate_prime_ex(r, kBits, 0, + NULL, NULL, NULL))) + goto err; + } else { + if (!TEST_true(BN_generate_prime_ex(r, kBits, 0, + NULL, NULL, NULL)) + || !TEST_int_eq(BN_num_bits(r), kBits)) + goto err; + } + + st = 1; + err: + BN_free(r); + return st; +} + +static int test_smallsafeprime(int kBits) +{ + BIGNUM *r; + int st = 0; + + if (!TEST_ptr(r = BN_new())) + goto err; + + if (kBits <= 5 && kBits != 3) { + if (!TEST_false(BN_generate_prime_ex(r, kBits, 1, + NULL, NULL, NULL))) + goto err; + } else { + if (!TEST_true(BN_generate_prime_ex(r, kBits, 1, + NULL, NULL, NULL)) + || !TEST_int_eq(BN_num_bits(r), kBits)) + goto err; + } + st = 1; err: BN_free(r); @@ -2448,11 +2493,18 @@ static int run_file_tests(int i) return c == 0; } +typedef enum OPTION_choice { + OPT_ERR = -1, + OPT_EOF = 0, + OPT_STOCHASTIC_TESTS, + OPT_TEST_ENUM +} OPTION_CHOICE; + const OPTIONS *test_get_options(void) { - enum { OPT_TEST_ENUM }; static const OPTIONS test_options[] = { OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("[file...]\n"), + { "stochastic", OPT_STOCHASTIC_TESTS, '-', "Run stochastic tests" }, { OPT_HELP_STR, 1, '-', "file\tFile to run tests on. Normal tests are not run\n" }, { NULL } @@ -2462,7 +2514,22 @@ const OPTIONS *test_get_options(void) int setup_tests(void) { - int n = test_get_argument_count(); + OPTION_CHOICE o; + int n, stochastic = 0; + + while ((o = opt_next()) != OPT_EOF) { + switch (o) { + case OPT_STOCHASTIC_TESTS: + stochastic = 1; + break; + case OPT_TEST_CASES: + break; + default: + case OPT_ERR: + return 0; + } + } + n = test_get_argument_count(); if (!TEST_ptr(ctx = BN_CTX_new())) return 0; @@ -2483,7 +2550,8 @@ int setup_tests(void) ADD_TEST(test_badmod); ADD_TEST(test_expmodzero); ADD_TEST(test_expmodone); - ADD_TEST(test_smallprime); + ADD_ALL_TESTS(test_smallprime, 16); + ADD_ALL_TESTS(test_smallsafeprime, 16); ADD_TEST(test_swap); ADD_TEST(test_ctx_consttime_flag); #ifndef OPENSSL_NO_EC2M @@ -2499,7 +2567,8 @@ int setup_tests(void) #endif ADD_ALL_TESTS(test_is_prime, (int)OSSL_NELEM(primes)); ADD_ALL_TESTS(test_not_prime, (int)OSSL_NELEM(not_primes)); - ADD_ALL_TESTS(test_rand_range, OSSL_NELEM(rand_range_cases)); + if (stochastic) + ADD_TEST(test_rand_range); } else { ADD_ALL_TESTS(run_file_tests, n); } diff --git a/test/build.info b/test/build.info index fa3c1f1e..f5b802da 100644 --- a/test/build.info +++ b/test/build.info @@ -1,15 +1,20 @@ SUBDIRS=ossl_shim -{- - use File::Spec::Functions; - sub rebase_files - { - my ($base, $files) = @_; - return join(" ", map { "$base/$_" } split(/\s+/, $files)); - } - our $apps_aux_src = - join(' ', map { "../apps/$_" } split(/\s+/, $target{apps_aux_src})); - "" --} + +# TODO: use ../apps/libapps.a instead of direct ../apps source. +# This can't currently be done, because some of its units drag in too many +# unresolved references that don't apply here. Most of all, ../apps/apps.c +# needs to be divided in smaller pieces to be useful here. +# +# Auxilliary program source (copied from ../apps/build.info) +IF[{- $config{target} =~ /^(?:VC-|mingw)/ -}] + # It's called 'init', but doesn't have much 'init' in it... + $AUXLIBAPPSSRC=../apps/win32_init.c +ENDIF +IF[{- $config{target} =~ /^vms-/ -}] + $AUXLIBAPPSSRC=../apps/vms_term_sock.c ../apps/vms_decc_argv.c +ENDIF +$LIBAPPSSRC=../apps/opt.c ../apps/bf_prefix.c $AUXLIBAPPSSRC + IF[{- !$disabled{tests} -}] LIBS{noinst,has_main}=libtestutil.a SOURCE[libtestutil.a]=testutil/basic_output.c testutil/output_helpers.c \ @@ -17,7 +22,7 @@ IF[{- !$disabled{tests} -}] testutil/format_output.c testutil/tap_bio.c \ testutil/test_cleanup.c testutil/main.c testutil/init.c \ testutil/options.c testutil/test_options.c \ - testutil/apps_mem.c ../apps/opt.c {- $apps_aux_src; -} + testutil/apps_mem.c $LIBAPPSSRC INCLUDE[libtestutil.a]=../include ../apps/include .. DEPEND[libtestutil.a]=../libcrypto @@ -182,6 +187,9 @@ IF[{- !$disabled{tests} -}] SOURCE[evp_test]=evp_test.c INCLUDE[evp_test]=../include ../apps/include DEPEND[evp_test]=../libcrypto libtestutil.a + IF[{- $disabled{legacy} || !$target{dso_scheme} -}] + DEFINE[evp_test]=NO_LEGACY_MODULE + ENDIF SOURCE[evp_extra_test]=evp_extra_test.c INCLUDE[evp_extra_test]=../include ../apps/include ../crypto/include @@ -363,13 +371,13 @@ IF[{- !$disabled{tests} -}] DEPEND[recordlentest]=../libcrypto ../libssl libtestutil.a SOURCE[drbgtest]=drbgtest.c - INCLUDE[drbgtest]=../include ../apps/include + INCLUDE[drbgtest]=../include ../apps/include ../crypto/include DEPEND[drbgtest]=../libcrypto.a libtestutil.a SOURCE[drbg_cavs_test]=drbg_cavs_test.c drbg_cavs_data_ctr.c \ drbg_cavs_data_hash.c drbg_cavs_data_hmac.c - INCLUDE[drbg_cavs_test]=../include ../apps/include . .. + INCLUDE[drbg_cavs_test]=../include ../apps/include . .. ../crypto/include DEPEND[drbg_cavs_test]=../libcrypto libtestutil.a SOURCE[x509_dup_cert_test]=x509_dup_cert_test.c @@ -634,6 +642,11 @@ IF[{- !$disabled{tests} -}] SOURCE[params_test]=params_test.c INCLUDE[params_test]=.. ../include ../apps/include DEPEND[params_test]=../libcrypto.a libtestutil.a + + PROGRAMS{noinst}=namemap_internal_test + SOURCE[namemap_internal_test]=namemap_internal_test.c + INCLUDE[namemap_internal_test]=.. ../include ../apps/include + DEPEND[namemap_internal_test]=../libcrypto.a libtestutil.a ENDIF {- diff --git a/test/certs/sm2-csr.pem b/test/certs/sm2-csr.pem new file mode 100644 index 00000000..a6dcca87 --- /dev/null +++ b/test/certs/sm2-csr.pem @@ -0,0 +1,9 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIBMTCB1wIBADB1MQswCQYDVQQGEwJDTjERMA8GA1UECAwITGlhb25pbmcxETAP +BgNVBAcMCFNoZW55YW5nMQwwCgYDVQQKDANUZXQxDDAKBgNVBAsMA1RldDELMAkG +A1UEAwwCb28xFzAVBgkqhkiG9w0BCQEWCG9vQG9vLm9vMFkwEwYHKoZIzj0CAQYI +KoEcz1UBgi0DQgAE1NjdOpldcjTkuZpdGDNyHAnhK9cB2RZ7jAmFzt7jgEs9OHSg +rb3crjz+qGZfqyJ5AyZulQ7gdARzb1H55jvw5qAAMAoGCCqBHM9VAYN1A0kAMEYC +IQCacUXA8kyTTDwEm89Yz9qjsbfd8/N32lnzKxuKCcXJwQIhAIpugCbfeWuPxUQO +7AvQS3yxBp1yn0FbTT2XVSyYy6To +-----END CERTIFICATE REQUEST----- diff --git a/test/certs/sm2-root.crt b/test/certs/sm2-root.crt new file mode 100644 index 00000000..5677ac6c --- /dev/null +++ b/test/certs/sm2-root.crt @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICJDCCAcqgAwIBAgIJAOlkpDpSrmVbMAoGCCqBHM9VAYN1MGgxCzAJBgNVBAYT +AkNOMQswCQYDVQQIDAJMTjERMA8GA1UEBwwIU2hlbnlhbmcxETAPBgNVBAoMCFRl +c3QgT3JnMRAwDgYDVQQLDAdUZXN0IE9VMRQwEgYDVQQDDAtUZXN0IFNNMiBDQTAe +Fw0xOTAyMTkwNzA1NDhaFw0yMzAzMzAwNzA1NDhaMGgxCzAJBgNVBAYTAkNOMQsw +CQYDVQQIDAJMTjERMA8GA1UEBwwIU2hlbnlhbmcxETAPBgNVBAoMCFRlc3QgT3Jn +MRAwDgYDVQQLDAdUZXN0IE9VMRQwEgYDVQQDDAtUZXN0IFNNMiBDQTBZMBMGByqG +SM49AgEGCCqBHM9VAYItA0IABHRYnqErofBdXPptvvO7+BSVJxcpHuTGnZ+UPrbU +5kVEUMaUnNOeMJZl/vRGimZCm/AkReJmRfnb15ESHR+ssp6jXTBbMB0GA1UdDgQW +BBTFjcWu/zJgSZ5SKUlU5Vx4/0W5dDAfBgNVHSMEGDAWgBTFjcWu/zJgSZ5SKUlU +5Vx4/0W5dDAMBgNVHRMEBTADAQH/MAsGA1UdDwQEAwIBBjAKBggqgRzPVQGDdQNI +ADBFAiEAs6byi1nSQtFELOw/2tQIv5AEsZFR5MJ/oB2ztXzs2LYCIEfIw4xlUH6X +YFhs4RnIa0K9Ng1ebsGPrifYkudwBIk3 +-----END CERTIFICATE----- diff --git a/test/certs/sm2-root.key b/test/certs/sm2-root.key new file mode 100644 index 00000000..4bda65b5 --- /dev/null +++ b/test/certs/sm2-root.key @@ -0,0 +1,5 @@ +-----BEGIN PRIVATE KEY----- +MIGHAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBG0wawIBAQQglktdVbLA5tyXMc+9 +KV4ikyDaFZNnXqfNAzUVqTlqn8GhRANCAAR0WJ6hK6HwXVz6bb7zu/gUlScXKR7k +xp2flD621OZFRFDGlJzTnjCWZf70RopmQpvwJEXiZkX529eREh0frLKe +-----END PRIVATE KEY----- diff --git a/test/conf_include_test.c b/test/conf_include_test.c index ba40aa1b..16459c46 100644 --- a/test/conf_include_test.c +++ b/test/conf_include_test.c @@ -141,7 +141,7 @@ static int test_check_null_numbers(void) } /* - * Verify that a NULL config with a missing envrionment variable returns + * Verify that a NULL config with a missing environment variable returns * a failure code. */ if (!TEST_int_eq(unsetenv("FNORD"), 0) diff --git a/test/dhtest.c b/test/dhtest.c index 1bbf5654..7b2edec3 100644 --- a/test/dhtest.c +++ b/test/dhtest.c @@ -193,7 +193,7 @@ static int dh_test(void) BN_free(q); BN_free(g); err2: - /* an error occured before priv_key was assigned to dh */ + /* an error occurred before priv_key was assigned to dh */ BN_free(priv_key); err3: success: diff --git a/test/drbgtest.c b/test/drbgtest.c index 9e0aba83..9efdd87a 100644 --- a/test/drbgtest.c +++ b/test/drbgtest.c @@ -332,7 +332,7 @@ static int error_check(DRBG_SELFTEST_DATA *td) * Personalisation string tests */ - /* Test detection of too large personlisation string */ + /* Test detection of too large personalisation string */ if (!init(drbg, td, &t) || RAND_DRBG_instantiate(drbg, td->pers, drbg->max_perslen + 1) > 0) goto err; @@ -1264,7 +1264,8 @@ static const size_t crngt_num_cases = 6; static size_t crngt_case, crngt_idx; -static int crngt_entropy_cb(unsigned char *buf, unsigned char *md, +static int crngt_entropy_cb(OPENSSL_CTX *ctx, RAND_POOL *pool, + unsigned char *buf, unsigned char *md, unsigned int *md_size) { size_t i, z; @@ -1288,19 +1289,16 @@ static int test_crngt(int n) size_t ent; int res = 0; int expect; + OPENSSL_CTX *ctx = OPENSSL_CTX_new(); - if (!TEST_true(rand_crngt_single_init())) - return 0; - rand_crngt_cleanup(); - - if (!TEST_ptr(drbg = RAND_DRBG_new(dt->nid, dt->flags, NULL))) + if (!TEST_ptr(ctx)) return 0; + if (!TEST_ptr(drbg = RAND_DRBG_new_ex(ctx, dt->nid, dt->flags, NULL))) + goto err; ent = (drbg->min_entropylen + CRNGT_BUFSIZ - 1) / CRNGT_BUFSIZ; crngt_case = n % crngt_num_cases; crngt_idx = 0; crngt_get_entropy = &crngt_entropy_cb; - if (!TEST_true(rand_crngt_init())) - goto err; #ifndef FIPS_MODE if (!TEST_true(RAND_DRBG_set_callbacks(drbg, &rand_crngt_get_entropy, &rand_crngt_cleanup_entropy, @@ -1333,6 +1331,7 @@ err: uninstantiate(drbg); RAND_DRBG_free(drbg); crngt_get_entropy = &rand_crngt_get_entropy_cb; + OPENSSL_CTX_free(ctx); return res; } diff --git a/test/dtlstest.c b/test/dtlstest.c index 98a23f85..24848628 100644 --- a/test/dtlstest.c +++ b/test/dtlstest.c @@ -96,7 +96,7 @@ static int test_dtls_unprocessed(int testidx) /* * Create the connection. We use "create_bare_ssl_connection" here so that - * we can force the connection to not do "SSL_read" once partly conencted. + * we can force the connection to not do "SSL_read" once partly connected. * We don't want to accidentally read the dummy records we injected because * they will fail to decrypt. */ diff --git a/test/ecdsatest.c b/test/ecdsatest.c index 761832ff..a62efad1 100644 --- a/test/ecdsatest.c +++ b/test/ecdsatest.c @@ -118,6 +118,11 @@ static int x9_62_tests(int n) TEST_info("ECDSA KATs for curve %s", OBJ_nid2sn(nid)); +#ifdef FIPS_MODE + if (EC_curve_nid2nist(nid) == NULL) + return TEST_skip("skip non approved curves"); +#endif /* FIPS_MODE */ + if (!TEST_ptr(mctx = EVP_MD_CTX_new()) /* get the message digest */ || !TEST_ptr(message = OPENSSL_hexstr2buf(tbs, &msg_len)) diff --git a/test/ectest.c b/test/ectest.c index 3f7747e5..50f8c63f 100644 --- a/test/ectest.c +++ b/test/ectest.c @@ -1820,7 +1820,7 @@ static int parameter_test(void) unsigned char *buf = NULL; int r = 0, len; - if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(NID_secp112r1)) + if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(NID_secp224r1)) || !TEST_ptr(ecparameters = EC_GROUP_get_ecparameters(group, NULL)) || !TEST_ptr(group2 = EC_GROUP_new_from_ecparameters(ecparameters)) || !TEST_int_eq(EC_GROUP_cmp(group, group2, NULL), 0)) diff --git a/test/enginetest.c b/test/enginetest.c index 4836cbe9..b4d117ef 100644 --- a/test/enginetest.c +++ b/test/enginetest.c @@ -279,7 +279,7 @@ static int test_redirect(void) * Try setting test key engine. Both should fail because the * engine has no public key methods. */ - if (!TEST_ptr_null(EVP_PKEY_CTX_new(pkey, e)) + if (!TEST_ptr_null(ctx = EVP_PKEY_CTX_new(pkey, e)) || !TEST_int_le(EVP_PKEY_set1_engine(pkey, e), 0)) goto err; diff --git a/test/errtest.c b/test/errtest.c index 39017da8..df222da6 100644 --- a/test/errtest.c +++ b/test/errtest.c @@ -32,8 +32,21 @@ static int preserves_system_error(void) #endif } +/* Test that calls to ERR_add_error_[v]data append */ +static int vdata_appends(void) +{ + const char *data; + + CRYPTOerr(0, ERR_R_MALLOC_FAILURE); + ERR_add_error_data(1, "hello "); + ERR_add_error_data(1, "world"); + ERR_get_error_line_data(NULL, NULL, &data, NULL); + return TEST_str_eq(data, "hello world"); +} + int setup_tests(void) { ADD_TEST(preserves_system_error); + ADD_TEST(vdata_appends); return 1; } diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 724a1441..fc3d6283 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -301,7 +301,7 @@ static const unsigned char kExampleECPubKeyDER[] = { }; /* - * kExampleBadECKeyDER is a sample EC public key with a wrong OID + * kExampleBadECPubKeyDER is a sample EC public key with a wrong OID * 1.2.840.10045.2.2 instead of 1.2.840.10045.2.1 - EC Public Key */ static const unsigned char kExampleBadECPubKeyDER[] = { @@ -599,7 +599,7 @@ static int test_EVP_PKCS82PKEY(void) } #endif -#ifndef OPENSSL_NO_SM2 +#if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODE) static int test_EVP_SM2_verify(void) { @@ -1150,8 +1150,8 @@ static int test_EVP_MD_fetch(int tst) || !TEST_int_eq(EVP_MD_block_size(md), SHA256_CBLOCK)) goto err; - /* Also test EVP_MD_upref() while we're doing this */ - if (!TEST_true(EVP_MD_upref(md))) + /* Also test EVP_MD_up_ref() while we're doing this */ + if (!TEST_true(EVP_MD_up_ref(md))) goto err; /* Ref count should now be 2. Release both */ EVP_MD_meth_free(md); @@ -1178,7 +1178,7 @@ static int test_EVP_MD_fetch(int tst) md = NULL; /* - * Explicitly asking for the default implementation should succeeed except + * Explicitly asking for the default implementation should succeed except * in test 4 where the default provider is not loaded. */ md = EVP_MD_fetch(ctx, "SHA256", "default=yes"); @@ -1220,6 +1220,11 @@ static int test_EVP_MD_fetch(int tst) EVP_MD_meth_free(md); OSSL_PROVIDER_unload(defltprov); OSSL_PROVIDER_unload(fipsprov); + /* Not normally needed, but we would like to test that + * OPENSSL_thread_stop_ex() behaves as expected. + */ + if (ctx != NULL) + OPENSSL_thread_stop_ex(ctx); OPENSSL_CTX_free(ctx); return ret; } @@ -1233,7 +1238,7 @@ int setup_tests(void) #ifndef OPENSSL_NO_EC ADD_TEST(test_EVP_PKCS82PKEY); #endif -#ifndef OPENSSL_NO_SM2 +#if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODE) ADD_TEST(test_EVP_SM2); ADD_TEST(test_EVP_SM2_verify); #endif diff --git a/test/evp_kdf_test.c b/test/evp_kdf_test.c index 79177f98..e7c1381a 100644 --- a/test/evp_kdf_test.c +++ b/test/evp_kdf_test.c @@ -74,24 +74,57 @@ static int test_kdf_pbkdf2(void) { int ret; EVP_KDF_CTX *kctx; - unsigned char out[32]; - static const unsigned char expected[sizeof(out)] = { - 0xae, 0x4d, 0x0c, 0x95, 0xaf, 0x6b, 0x46, 0xd3, - 0x2d, 0x0a, 0xdf, 0xf9, 0x28, 0xf0, 0x6d, 0xd0, - 0x2a, 0x30, 0x3f, 0x8e, 0xf3, 0xc2, 0x51, 0xdf, - 0xd6, 0xe2, 0xd8, 0x5a, 0x95, 0x47, 0x4c, 0x43 + unsigned char out[25]; + size_t len = 0; + const unsigned char expected[sizeof(out)] = { + 0x34, 0x8c, 0x89, 0xdb, 0xcb, 0xd3, 0x2b, 0x2f, + 0x32, 0xd8, 0x14, 0xb8, 0x11, 0x6e, 0x84, 0xcf, + 0x2b, 0x17, 0x34, 0x7e, 0xbc, 0x18, 0x00, 0x18, + 0x1c }; - ret = - TEST_ptr(kctx = EVP_KDF_CTX_new_id(EVP_KDF_PBKDF2)) - && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PASS, "password", - (size_t)8), 0) - && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, "salt", - (size_t)4), 0) - && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_ITER, 2), 0) - && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()), 0) - && TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out)), 0) - && TEST_mem_eq(out, sizeof(out), expected, sizeof(expected)); + if (sizeof(len) > 32) + len = SIZE_MAX; + + ret = TEST_ptr(kctx = EVP_KDF_CTX_new_id(EVP_KDF_PBKDF2)) + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PASS, + "passwordPASSWORDpassword", + (size_t)24), 0) + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, + "saltSALTsaltSALTsaltSALTsaltSALTsalt", + (size_t)36), 0) + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_ITER, 4096), 0) + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha256()), + 0) + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE, + 0), 0) + && TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out)), 0) + && TEST_mem_eq(out, sizeof(out), expected, sizeof(expected)) + /* A key length that is too small should fail */ + && TEST_int_eq(EVP_KDF_derive(kctx, out, 112 / 8 - 1), 0) + /* A key length that is too large should fail */ + && (len == 0 || TEST_int_eq(EVP_KDF_derive(kctx, out, len), 0)) + /* Salt length less than 128 bits should fail */ + && TEST_int_eq(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, + "123456781234567", + (size_t)15), 0) + /* A small iteration count should fail */ + && TEST_int_eq(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_ITER, 1), 0) + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE, + 1), 0) + /* Small salts will pass if the "pkcs5" mode is enabled */ + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_SALT, + "123456781234567", + (size_t)15), 0) + /* A small iteration count will pass if "pkcs5" mode is enabled */ + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_ITER, 1), 0) + /* + * If the "pkcs5" mode is disabled then the small salt and iter will + * fail when the derive gets called. + */ + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_PBKDF2_PKCS5_MODE, + 0), 0) + && TEST_int_eq(EVP_KDF_derive(kctx, out, sizeof(out)), 0); EVP_KDF_CTX_free(kctx); return ret; @@ -374,6 +407,37 @@ static int test_kdf_get_kdf(void) && TEST_ptr_eq(kdf1, kdf2); } +#ifndef OPENSSL_NO_CMS +static int test_kdf_x942_asn1(void) +{ + int ret; + EVP_KDF_CTX *kctx = NULL; + unsigned char out[24]; + /* RFC2631 Section 2.1.6 Test data */ + static const unsigned char z[] = { + 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d, + 0x0e,0x0f,0x10,0x11,0x12,0x13 + }; + static const unsigned char expected[sizeof(out)] = { + 0xa0,0x96,0x61,0x39,0x23,0x76,0xf7,0x04, + 0x4d,0x90,0x52,0xa3,0x97,0x88,0x32,0x46, + 0xb6,0x7f,0x5f,0x1e,0xf6,0x3e,0xb5,0xfb + }; + + ret = + TEST_ptr(kctx = EVP_KDF_CTX_new_id(EVP_KDF_X942)) + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_MD, EVP_sha1()), 0) + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_KEY, z, sizeof(z)), 0) + && TEST_int_gt(EVP_KDF_ctrl(kctx, EVP_KDF_CTRL_SET_CEK_ALG, + SN_id_smime_alg_CMS3DESwrap), 0) + && TEST_int_gt(EVP_KDF_derive(kctx, out, sizeof(out)), 0) + && TEST_mem_eq(out, sizeof(out), expected, sizeof(expected)); + + EVP_KDF_CTX_free(kctx); + return ret; +} +#endif /* OPENSSL_NO_CMS */ + int setup_tests(void) { ADD_TEST(test_kdf_get_kdf); @@ -388,5 +452,8 @@ int setup_tests(void) ADD_TEST(test_kdf_ss_kmac); ADD_TEST(test_kdf_sshkdf); ADD_TEST(test_kdf_x963); +#ifndef OPENSSL_NO_CMS + ADD_TEST(test_kdf_x942_asn1); +#endif return 1; } diff --git a/test/evp_pkey_dparams_test.c b/test/evp_pkey_dparams_test.c index 30da6ed8..f1d528eb 100644 --- a/test/evp_pkey_dparams_test.c +++ b/test/evp_pkey_dparams_test.c @@ -21,43 +21,119 @@ #include #include "testutil.h" -static int pkey_param_types[] = { #ifndef OPENSSL_NO_DH - EVP_PKEY_DH, +static const unsigned char dhparam_bin[] = { +0x30,0x82,0x01,0x08,0x02,0x82,0x01,0x01,0x00,0xc0,0xd1,0x2e,0x14,0x18,0xbd,0x03, +0xfd,0x39,0xe1,0x99,0xf4,0x93,0x06,0x2d,0x49,0xc6,0xb5,0xb9,0xf0,0x91,0xcb,0x2f, +0x48,0x54,0x79,0x7d,0xc4,0x65,0x11,0x55,0xf7,0x99,0xde,0x42,0x83,0x84,0xc0,0xf8, +0x88,0x89,0xa0,0xff,0xff,0x7d,0xe8,0xef,0x9e,0xbc,0xf7,0x1d,0x70,0x6d,0x3a,0x33, +0x49,0x28,0xa1,0xa3,0xe1,0x41,0xc4,0x8b,0x91,0xf9,0xf2,0xb6,0xe2,0x77,0x79,0x38, +0x7d,0x21,0xb3,0xdf,0x79,0x9c,0x5e,0x65,0x16,0x00,0x16,0x82,0xb2,0x36,0x46,0x21, +0xac,0xaf,0x86,0xc7,0xe3,0x10,0x44,0x48,0xfb,0xbd,0xad,0x4e,0x11,0x73,0x4c,0x25, +0xb0,0x8c,0x1c,0x1e,0x8e,0x58,0x50,0x5e,0x43,0x89,0xe4,0xd9,0x34,0xf8,0x3b,0xcc, +0x36,0x2c,0x1b,0xb3,0xb2,0x77,0x0c,0xa5,0x96,0xc1,0x8a,0x38,0xd4,0xe3,0x9c,0x2a, +0xde,0x49,0x46,0xc7,0xd4,0xa2,0x47,0xc9,0x0a,0xbd,0x84,0xd4,0x1c,0xbc,0xb6,0x19, +0x04,0x94,0x64,0xfa,0x8a,0x11,0x9c,0x5f,0x4a,0x4c,0x0f,0x58,0x81,0x02,0xbf,0xcf, +0x87,0x27,0x2b,0xae,0x8e,0xe2,0x61,0x7a,0xdb,0xba,0x23,0x39,0x25,0x44,0xdc,0x22, +0x75,0xc3,0x28,0xd9,0x12,0x33,0x84,0x32,0xd4,0x5d,0xd9,0x77,0xf8,0x04,0x90,0x38, +0x0a,0xec,0x84,0x93,0x43,0xce,0xe7,0x07,0x42,0x7d,0x2d,0xe0,0x21,0x3b,0x19,0x22, +0xa7,0x8f,0x50,0x31,0xda,0xd0,0x0d,0xd3,0x0b,0xdb,0xad,0xed,0x94,0x92,0xff,0x83, +0x06,0x7f,0x7f,0xd7,0x7b,0x42,0x5b,0xba,0x93,0x7a,0xeb,0x43,0x5f,0xce,0x59,0x26, +0xe8,0x76,0xdc,0xee,0xe2,0xbe,0x36,0x7a,0x83,0x02,0x01,0x02 +}; +#endif + +#ifndef OPENSSL_NO_DSA +static const unsigned char dsaparam_bin[] = { +0x30,0x82,0x02,0x28,0x02,0x82,0x01,0x01,0x00,0xf2,0x85,0x01,0xa5,0xb9,0x56,0x65, +0x19,0xff,0x9a,0x7d,0xf9,0x90,0xd6,0xaa,0x73,0xac,0xf7,0x94,0xfa,0x8a,0x64,0x6d, +0xa0,0x01,0x42,0xe5,0x45,0xfc,0x53,0x72,0xb0,0x7c,0xe6,0x3b,0xfb,0x09,0x33,0x41, +0x27,0xbd,0x00,0xb5,0x18,0x87,0x62,0xa8,0x2b,0xfc,0xd0,0x52,0x4a,0x14,0x2d,0xaa, +0x36,0xc6,0xf3,0xa9,0xe3,0x90,0x1b,0x74,0xdf,0x0a,0x6d,0x33,0xba,0xf4,0x32,0x6d, +0xba,0x36,0x68,0x1d,0x83,0x36,0x50,0xc6,0x62,0xc0,0x40,0x67,0x0e,0xf6,0x22,0x00, +0x62,0x1b,0x76,0x72,0x62,0x5f,0xa0,0xdf,0x38,0xb1,0x1d,0x26,0x70,0x9b,0x84,0x64, +0xbb,0x16,0x15,0xc2,0x66,0xb9,0x97,0xd0,0x07,0xf1,0x4b,0x70,0x02,0x03,0xf1,0xd2, +0x03,0xdb,0x78,0x8b,0xb4,0xda,0x6f,0x3c,0xe2,0x31,0xa8,0x1c,0x99,0xea,0x9c,0x75, +0x28,0x96,0x82,0x16,0x77,0xac,0x79,0x32,0x61,0x87,0xec,0xb7,0xb4,0xc3,0xea,0x12, +0x62,0x1f,0x08,0xb8,0x16,0xab,0xcc,0xef,0x28,0xdf,0x06,0x07,0xbe,0xb0,0xdc,0x78, +0x83,0x8a,0x70,0x80,0x34,0xe6,0x91,0xe3,0xd3,0x92,0xd9,0xf4,0x56,0x53,0x52,0xb7, +0x35,0xf6,0x2a,0xec,0x4b,0xcb,0xa2,0x3c,0xc3,0x0c,0x94,0xa7,0x4e,0x1c,0x42,0x9c, +0x72,0x99,0x60,0x8c,0xfe,0xfb,0x60,0x57,0x75,0xf5,0x23,0x11,0x12,0xba,0x97,0xcd, +0xad,0x5a,0x0b,0xa6,0x1f,0x6a,0x48,0x2e,0x8d,0xda,0x95,0xc6,0x0e,0x14,0xde,0xf7, +0x22,0x55,0xa8,0x6b,0x25,0xdf,0xa2,0xab,0x33,0x65,0x56,0xfc,0x78,0x4f,0x62,0xdf, +0x48,0xdd,0xce,0x8b,0xe1,0x76,0xf4,0xf6,0x7f,0x02,0x1d,0x00,0xac,0xb0,0xb8,0x92, +0x3b,0x6b,0x61,0xcf,0x36,0x6d,0xf2,0x1e,0x5d,0xe0,0x7b,0xf5,0x73,0x48,0xa3,0x8b, +0x86,0x9e,0x88,0xce,0x40,0xf8,0x27,0x6d,0x02,0x82,0x01,0x00,0x77,0x6b,0x89,0xd6, +0x8f,0x3d,0xce,0x52,0x30,0x74,0xb2,0xa1,0x13,0x96,0xd5,0x92,0xf2,0xf1,0x6b,0x10, +0x31,0x0b,0xf3,0x69,0xaa,0xbf,0x4b,0x6c,0xcb,0x3f,0x6d,0x58,0x76,0x44,0x09,0xf9, +0x28,0xef,0xa0,0xe4,0x55,0x77,0x57,0xe0,0xfb,0xcc,0x9a,0x6a,0x2c,0x90,0xec,0x72, +0x24,0x0b,0x43,0xc5,0xbc,0x31,0xed,0x1a,0x46,0x2c,0x76,0x42,0x9e,0xc0,0x82,0xfc, +0xff,0xf9,0x7e,0xe2,0x1f,0x39,0xf3,0x3b,0xdb,0x27,0x36,0xe7,0xf5,0x3b,0xc2,0x23, +0xb6,0xd0,0xcf,0x5b,0x85,0x2e,0x1b,0x00,0x5b,0x31,0xaa,0x72,0x8f,0x37,0xee,0x56, +0x71,0xc4,0xfd,0x3c,0x8d,0xfa,0x5b,0xab,0xb1,0xa9,0x52,0x76,0xa0,0xe4,0xe3,0x78, +0x83,0x64,0x5d,0xd7,0x6c,0xec,0x9b,0x40,0x65,0xe2,0x0a,0x11,0x19,0x60,0xdd,0xce, +0x29,0x9f,0xc6,0x1d,0x0a,0xab,0x8e,0x59,0x25,0xc5,0x0b,0x9c,0x02,0x45,0xba,0x99, +0x74,0x22,0x1d,0xc1,0x57,0xca,0x50,0x8c,0x5e,0xdf,0xd8,0x5d,0x43,0xae,0x06,0x28, +0x29,0x82,0xf6,0x5a,0xa9,0x51,0xa2,0x04,0x1d,0xbf,0x88,0x15,0x98,0xce,0x8a,0xb4, +0x3b,0xe5,0x30,0x29,0xce,0x0c,0x9b,0xf8,0xdb,0xbf,0x06,0x9f,0xd0,0x59,0x18,0xd4, +0x0b,0x94,0xbf,0xe9,0x67,0x6b,0x9e,0xf0,0x72,0xc6,0xbf,0x79,0x8f,0x1e,0xa3,0x95, +0x24,0xe3,0xcb,0x58,0xb5,0x67,0xd3,0xae,0x79,0xb0,0x28,0x9c,0x9a,0xd0,0xa4,0xe7, +0x22,0x15,0xc1,0x8b,0x04,0xb9,0x8a,0xa8,0xb7,0x1b,0x62,0x44,0xc6,0xef,0x4b,0x74, +0xd0,0xfd,0xa9,0xb4,0x4e,0xdd,0x7d,0x38,0x60,0xd1,0x40,0xcd +}; +#endif + +#ifndef OPENSSL_NO_EC +static const unsigned char ecparam_bin[] = { +0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07 +}; +#endif + +static const struct { + int type; + const unsigned char *param_bin; + size_t param_bin_len; +} pkey_params [] = { +#ifndef OPENSSL_NO_DH + { EVP_PKEY_DH, dhparam_bin, sizeof(dhparam_bin) }, #endif #ifndef OPENSSL_NO_DSA - EVP_PKEY_DSA, + { EVP_PKEY_DSA, dsaparam_bin, sizeof(dsaparam_bin) }, #endif #ifndef OPENSSL_NO_EC - EVP_PKEY_EC + { EVP_PKEY_EC, ecparam_bin, sizeof(ecparam_bin) } #endif }; #if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_EC) - static int params_bio_test(int id) { - int ret; - BIO *mem_bio = NULL; + int ret, out_len; + BIO *in = NULL, *out = NULL; EVP_PKEY_CTX *ctx = NULL; - EVP_PKEY *params_key = NULL, *out_key = NULL; - int type = pkey_param_types[id]; + EVP_PKEY *in_key = NULL, *out_key = NULL; + unsigned char *out_bin; + int type = pkey_params[id].type; - ret = - TEST_ptr(mem_bio = BIO_new(BIO_s_mem())) - && TEST_ptr(ctx = EVP_PKEY_CTX_new_id(type, NULL)) - && TEST_int_gt(EVP_PKEY_paramgen_init(ctx), 0) - && (type != EVP_PKEY_EC - || EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, NID_secp256k1) > 0) - && TEST_int_gt(EVP_PKEY_paramgen(ctx, ¶ms_key), 0) - && TEST_int_gt(i2d_KeyParams_bio(mem_bio, params_key), 0) - && TEST_ptr(d2i_KeyParams_bio(type, &out_key, mem_bio)) - && TEST_int_gt(EVP_PKEY_cmp_parameters(out_key, params_key), 0); + ret = TEST_ptr(ctx = EVP_PKEY_CTX_new_id(type, NULL)) + && TEST_ptr(in = BIO_new_mem_buf(pkey_params[id].param_bin, + (int)pkey_params[id].param_bin_len)) + /* Load in pkey params from binary */ + && TEST_ptr(d2i_KeyParams_bio(type, &in_key, in)) + && TEST_ptr(out = BIO_new(BIO_s_mem())) + /* Save pkey params to binary */ + && TEST_int_gt(i2d_KeyParams_bio(out, in_key), 0) + /* test the output binary is the expected value */ + && TEST_int_gt(out_len = BIO_get_mem_data(out, &out_bin), 0) + && TEST_mem_eq(pkey_params[id].param_bin, + (int)pkey_params[id].param_bin_len, + out_bin, out_len); - BIO_free(mem_bio); - EVP_PKEY_CTX_free(ctx); - EVP_PKEY_free(params_key); + BIO_free(in); + BIO_free(out); + EVP_PKEY_free(in_key); EVP_PKEY_free(out_key); + EVP_PKEY_CTX_free(ctx); return ret; } #endif @@ -67,7 +143,7 @@ int setup_tests(void) #if defined(OPENSSL_NO_DH) && defined(OPENSSL_NO_DSA) && defined(OPENSSL_NO_EC) TEST_note("No DH/DSA/EC support"); #else - ADD_ALL_TESTS(params_bio_test, OSSL_NELEM(pkey_param_types)); + ADD_ALL_TESTS(params_bio_test, OSSL_NELEM(pkey_params)); #endif return 1; } diff --git a/test/evp_test.c b/test/evp_test.c index fa9cde82..f76929d5 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -75,6 +76,9 @@ static int find_key(EVP_PKEY **ppk, const char *name, KEY_LIST *lst); static int parse_bin(const char *value, unsigned char **buf, size_t *buflen); +static OSSL_PROVIDER *defltprov = NULL; +static OSSL_PROVIDER *legacyprov = NULL; + /* * Compare two memory regions for equality, returning zero if they differ. * However, if there is expected to be an error and the actual error @@ -370,6 +374,11 @@ static int digest_test_parse(EVP_TEST *t, return evp_test_buffer_set_count(value, mdata->input); if (strcmp(keyword, "Ncopy") == 0) return evp_test_buffer_ncopy(value, mdata->input); + if (strcmp(keyword, "Legacy") == 0) { + if (legacyprov == NULL) + t->skip = 1; + return 1; + } return 0; } @@ -652,6 +661,14 @@ static int cipher_test_enc(EVP_TEST *t, int enc, t->err = "KEY_SET_ERROR"; goto err; } + /* Check that we get the same IV back */ + if (expected->iv != NULL + && (EVP_CIPHER_flags(expected->cipher) & EVP_CIPH_CUSTOM_IV) == 0 + && !TEST_mem_eq(expected->iv, expected->iv_len, + EVP_CIPHER_CTX_iv(ctx), expected->iv_len)) { + t->err = "INVALID_IV"; + goto err; + } if (expected->aead == EVP_CIPH_CCM_MODE) { if (!EVP_CipherUpdate(ctx, NULL, &tmplen, NULL, out_len)) { @@ -1956,7 +1973,14 @@ static int kdf_test_init(EVP_TEST *t, const char *name) t->skip = 1; return 1; } -#endif +#endif /* OPENSSL_NO_SCRYPT */ + +#ifdef OPENSSL_NO_CMS + if (strcmp(name, "X942KDF") == 0) { + t->skip = 1; + return 1; + } +#endif /* OPENSSL_NO_CMS */ kdf = EVP_get_kdfbyname(name); if (kdf == NULL) @@ -2088,7 +2112,14 @@ static int pkey_kdf_test_init(EVP_TEST *t, const char *name) t->skip = 1; return 1; } -#endif +#endif /* OPENSSL_NO_SCRYPT */ + +#ifdef OPENSSL_NO_CMS + if (strcmp(name, "X942KDF") == 0) { + t->skip = 1; + return 1; + } +#endif /* OPENSSL_NO_CMS */ if (kdf_nid == NID_undef) kdf_nid = OBJ_ln2nid(name); @@ -3053,8 +3084,10 @@ static int run_file_tests(int i) while (!BIO_eof(t->s.fp)) { c = parse(t); - if (t->skip) + if (t->skip) { + t->s.numskip++; continue; + } if (c == 0 || !run_test(t)) { t->s.errors++; break; @@ -3080,6 +3113,23 @@ int setup_tests(void) if (n == 0) return 0; + defltprov = OSSL_PROVIDER_load(NULL, "default"); + if (!TEST_ptr(defltprov)) + return 0; +#ifndef NO_LEGACY_MODULE + legacyprov = OSSL_PROVIDER_load(NULL, "legacy"); + if (!TEST_ptr(legacyprov)) { + OSSL_PROVIDER_unload(defltprov); + return 0; + } +#endif /* NO_LEGACY_MODULE */ + ADD_ALL_TESTS(run_file_tests, n); return 1; } + +void cleanup_tests(void) +{ + OSSL_PROVIDER_unload(legacyprov); + OSSL_PROVIDER_unload(defltprov); +} diff --git a/test/mdc2test.c b/test/mdc2test.c index 79512fc7..5b54f103 100644 --- a/test/mdc2test.c +++ b/test/mdc2test.c @@ -8,7 +8,10 @@ */ #include - +#include +#include +#include +#include #include "internal/nelem.h" #include "testutil.h" @@ -36,12 +39,19 @@ static unsigned char pad2[16] = { static int test_mdc2(void) { - int testresult = 0; + int testresult = 0, pad_type = 2; unsigned char md[MDC2_DIGEST_LENGTH]; EVP_MD_CTX *c; static char text[] = "Now is the time for all "; - size_t tlen = strlen(text); + size_t tlen = strlen(text), i = 0; + OSSL_PROVIDER *prov = NULL; + OSSL_PARAM params[2]; + params[i++] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_PAD_TYPE, + &pad_type), + params[i++] = OSSL_PARAM_construct_end(); + + prov = OSSL_PROVIDER_load(NULL, "legacy"); # ifdef CHARSET_EBCDIC ebcdic2ascii(text, text, tlen); # endif @@ -55,9 +65,8 @@ static int test_mdc2(void) || !TEST_true(EVP_DigestInit_ex(c, EVP_mdc2(), NULL))) goto end; - /* FIXME: use a ctl function? */ - ((MDC2_CTX *)EVP_MD_CTX_md_data(c))->pad_type = 2; - if (!TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen)) + if (!TEST_int_gt(EVP_MD_CTX_set_params(c, params), 0) + || !TEST_true(EVP_DigestUpdate(c, (unsigned char *)text, tlen)) || !TEST_true(EVP_DigestFinal_ex(c, &(md[0]), NULL)) || !TEST_mem_eq(md, MDC2_DIGEST_LENGTH, pad2, MDC2_DIGEST_LENGTH)) goto end; @@ -65,6 +74,7 @@ static int test_mdc2(void) testresult = 1; end: EVP_MD_CTX_free(c); + OSSL_PROVIDER_unload(prov); return testresult; } #endif diff --git a/test/namemap_internal_test.c b/test/namemap_internal_test.c new file mode 100644 index 00000000..1aee01ed --- /dev/null +++ b/test/namemap_internal_test.c @@ -0,0 +1,63 @@ +/* + * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the Apache License 2.0 (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "internal/namemap.h" +#include "testutil.h" + +#define NAME1 "name1" +#define NAME2 "name2" +#define ALIAS1 "alias1" +#define ALIAS1_UC "ALIAS1" + +static int test_namemap(OSSL_NAMEMAP *nm) +{ + int num1 = ossl_namemap_add(nm, 0, NAME1); + int num2 = ossl_namemap_add(nm, 0, NAME2); + int num3 = ossl_namemap_add(nm, num1, ALIAS1); + int num4 = ossl_namemap_add(nm, 0, ALIAS1_UC); + int check1 = ossl_namemap_name2num(nm, NAME1); + int check2 = ossl_namemap_name2num(nm, NAME2); + int check3 = ossl_namemap_name2num(nm, ALIAS1); + int check4 = ossl_namemap_name2num(nm, ALIAS1_UC); + int false1 = ossl_namemap_name2num(nm, "foo"); + + return TEST_int_ne(num1, 0) + && TEST_int_ne(num2, 0) + && TEST_int_eq(num1, num3) + && TEST_int_eq(num3, num4) + && TEST_int_eq(num1, check1) + && TEST_int_eq(num2, check2) + && TEST_int_eq(num3, check3) + && TEST_int_eq(num4, check4) + && TEST_int_eq(false1, 0); +} + +static int test_namemap_independent(void) +{ + OSSL_NAMEMAP *nm = ossl_namemap_new(); + int ok = nm != NULL && test_namemap(nm); + + ossl_namemap_free(nm); + return ok; +} + +static int test_namemap_stored(void) +{ + OSSL_NAMEMAP *nm = ossl_namemap_stored(NULL); + + return nm != NULL + && test_namemap(nm); +} + +int setup_tests(void) +{ + ADD_TEST(test_namemap_independent); + ADD_TEST(test_namemap_stored); + return 1; +} diff --git a/test/p_test.c b/test/p_test.c index 15213b6c..904b75b2 100644 --- a/test/p_test.c +++ b/test/p_test.c @@ -47,10 +47,10 @@ static const OSSL_ITEM *p_get_param_types(void *_) return p_param_types; } -static int p_get_params(void *vprov, const OSSL_PARAM params[]) +static int p_get_params(void *vprov, OSSL_PARAM params[]) { const OSSL_PROVIDER *prov = vprov; - const OSSL_PARAM *p = params; + OSSL_PARAM *p = params; int ok = 1; for (; ok && p->key != NULL; p++) { @@ -58,18 +58,18 @@ static int p_get_params(void *vprov, const OSSL_PARAM params[]) static char *opensslv; static char *provname; static char *greeting; - static const OSSL_PARAM counter_request[] = { + static OSSL_PARAM counter_request[] = { /* Known libcrypto provided parameters */ { "openssl-version", OSSL_PARAM_UTF8_PTR, - &opensslv, sizeof(&opensslv), NULL }, + &opensslv, sizeof(&opensslv), 0 }, { "provider-name", OSSL_PARAM_UTF8_PTR, - &provname, sizeof(&provname), NULL}, + &provname, sizeof(&provname), 0}, /* This might be present, if there's such a configuration */ { "greeting", OSSL_PARAM_UTF8_PTR, - &greeting, sizeof(&greeting), NULL }, + &greeting, sizeof(&greeting), 0 }, - { NULL, 0, NULL, 0, NULL } + { NULL, 0, NULL, 0, 0 } }; char buf[256]; size_t buf_l; @@ -90,9 +90,9 @@ static int p_get_params(void *vprov, const OSSL_PARAM params[]) sprintf(buf, "Howdy stranger..."); } - *p->return_size = buf_l = strlen(buf) + 1; + p->return_size = buf_l = strlen(buf) + 1; if (p->data_size >= buf_l) - strncpy(p->data, buf, buf_l); + strcpy(p->data, buf); else ok = 0; } diff --git a/test/params_api_test.c b/test/params_api_test.c index df708da7..616035ec 100644 --- a/test/params_api_test.c +++ b/test/params_api_test.c @@ -58,8 +58,8 @@ static const struct { 0x89, 0x67, 0xf2, 0x68, 0x33, 0xa0, 0x14, 0xb0 } }, }; -static int test_param_type_extra(const OSSL_PARAM *param, - const unsigned char *cmp, size_t width) +static int test_param_type_extra(OSSL_PARAM *param, const unsigned char *cmp, + size_t width) { int32_t i32; int64_t i64; @@ -374,24 +374,22 @@ static int test_param_bignum(int n) { unsigned char buf[MAX_LEN], bnbuf[MAX_LEN]; const size_t len = raw_values[n].len; - size_t bnsize; BIGNUM *b = NULL, *c = NULL; OSSL_PARAM param = OSSL_PARAM_DEFN("bn", OSSL_PARAM_UNSIGNED_INTEGER, - NULL, 0, NULL); + NULL, 0); int ret = 0; param.data = bnbuf; param.data_size = len; - param.return_size = &bnsize; le_copy(buf, raw_values[n].value, len); if (!TEST_ptr(b = BN_lebin2bn(raw_values[n].value, (int)len, NULL))) goto err; if (!TEST_true(OSSL_PARAM_set_BN(¶m, b)) - || !TEST_mem_eq(bnbuf, bnsize, buf, bnsize)) + || !TEST_mem_eq(bnbuf, param.return_size, buf, param.return_size)) goto err; - param.data_size = *param.return_size; + param.data_size = param.return_size; if (!TEST_true(OSSL_PARAM_get_BN(¶m, &c)) || !TEST_BN_eq(b, c)) goto err; @@ -413,23 +411,6 @@ static int test_param_real(void) && TEST_double_eq(p, 3.14159); } -/* - * The tests are a bit special in that they are trying to do both sides - * of the param passing. This means that the OSSL_PARAM structure needs to - * be updated so that a get call matches size with the corresponding set call. - * This is not a problem in normal usage because the owner of the OSSL_PARAM - * "knows" the size of what it wants to put in and gets the size back via the - * return_size pointer when it needs to get data out. That is, the owner - * does not need to call these APIs since it has direct access. - * - * The result is that the tests need the locate call to return a non-const - * pointer at times. Hence the cast here. - */ -static OSSL_PARAM *locate(OSSL_PARAM *p, const char *name) -{ - return (OSSL_PARAM *)OSSL_PARAM_locate(p, name); -} - static int test_param_construct(void) { static const char *int_names[] = { @@ -446,8 +427,7 @@ static int test_param_construct(void) char buf[100], buf2[100], *bufp, *bufp2; unsigned char ubuf[100]; void *vp, *vpn = NULL, *vp2; - OSSL_PARAM *p; - const OSSL_PARAM *cp; + OSSL_PARAM *cp; int i, n = 0, ret = 0; unsigned int u; long int l; @@ -456,27 +436,25 @@ static int test_param_construct(void) uint32_t u32; int64_t i64; uint64_t u64; - size_t j, k, s, sz; + size_t j, k, s; double d, d2; BIGNUM *bn = NULL, *bn2 = NULL; - params[n++] = OSSL_PARAM_construct_int("int", &i, &sz); - params[n++] = OSSL_PARAM_construct_uint("uint", &u, &sz); - params[n++] = OSSL_PARAM_construct_long("long", &l, &sz); - params[n++] = OSSL_PARAM_construct_ulong("ulong", &ul, &sz); - params[n++] = OSSL_PARAM_construct_int32("int32", &i32, &sz); - params[n++] = OSSL_PARAM_construct_int64("int64", &i64, &sz); - params[n++] = OSSL_PARAM_construct_uint32("uint32", &u32, &sz); - params[n++] = OSSL_PARAM_construct_uint64("uint64", &u64, &sz); - params[n++] = OSSL_PARAM_construct_size_t("size_t", &s, &sz); - params[n++] = OSSL_PARAM_construct_double("double", &d, &sz); - params[n++] = OSSL_PARAM_construct_BN("bignum", ubuf, sizeof(ubuf), &sz); - params[n++] = OSSL_PARAM_construct_utf8_string("utf8str", buf, sizeof(buf), - &sz); - params[n++] = OSSL_PARAM_construct_octet_string("octstr", buf, sizeof(buf), - &sz); - params[n++] = OSSL_PARAM_construct_utf8_ptr("utf8ptr", &bufp, 0, &sz); - params[n++] = OSSL_PARAM_construct_octet_ptr("octptr", &vp, 0, &sz); + params[n++] = OSSL_PARAM_construct_int("int", &i); + params[n++] = OSSL_PARAM_construct_uint("uint", &u); + params[n++] = OSSL_PARAM_construct_long("long", &l); + params[n++] = OSSL_PARAM_construct_ulong("ulong", &ul); + params[n++] = OSSL_PARAM_construct_int32("int32", &i32); + params[n++] = OSSL_PARAM_construct_int64("int64", &i64); + params[n++] = OSSL_PARAM_construct_uint32("uint32", &u32); + params[n++] = OSSL_PARAM_construct_uint64("uint64", &u64); + params[n++] = OSSL_PARAM_construct_size_t("size_t", &s); + params[n++] = OSSL_PARAM_construct_double("double", &d); + params[n++] = OSSL_PARAM_construct_BN("bignum", ubuf, sizeof(ubuf)); + params[n++] = OSSL_PARAM_construct_utf8_string("utf8str", buf, sizeof(buf)); + params[n++] = OSSL_PARAM_construct_octet_string("octstr", buf, sizeof(buf)); + params[n++] = OSSL_PARAM_construct_utf8_ptr("utf8ptr", &bufp, 0); + params[n++] = OSSL_PARAM_construct_octet_ptr("octptr", &vp, 0); params[n] = OSSL_PARAM_construct_end(); /* Search failure */ @@ -488,7 +466,7 @@ static int test_param_construct(void) if (!TEST_ptr(cp = OSSL_PARAM_locate(params, int_names[j])) || !TEST_true(OSSL_PARAM_set_int32(cp, (int32_t)(3 + j))) || !TEST_true(OSSL_PARAM_get_int64(cp, &i64)) - || !TEST_size_t_eq(cp->data_size, sz) + || !TEST_size_t_eq(cp->data_size, cp->return_size) || !TEST_size_t_eq((size_t)i64, 3 + j)) { TEST_note("iteration %zu var %s", j + 1, int_names[j]); goto err; @@ -499,7 +477,7 @@ static int test_param_construct(void) if (!TEST_ptr(cp = OSSL_PARAM_locate(params, uint_names[j])) || !TEST_true(OSSL_PARAM_set_uint32(cp, (uint32_t)(3 + j))) || !TEST_true(OSSL_PARAM_get_uint64(cp, &u64)) - || !TEST_size_t_eq(cp->data_size, sz) + || !TEST_size_t_eq(cp->data_size, cp->return_size) || !TEST_size_t_eq((size_t)u64, 3 + j)) { TEST_note("iteration %zu var %s", j + 1, uint_names[j]); goto err; @@ -509,14 +487,14 @@ static int test_param_construct(void) if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "double")) || !TEST_true(OSSL_PARAM_set_double(cp, 3.14)) || !TEST_true(OSSL_PARAM_get_double(cp, &d2)) - || !TEST_size_t_eq(sz, sizeof(double)) + || !TEST_size_t_eq(cp->return_size, sizeof(double)) || !TEST_double_eq(d, d2)) goto err; /* UTF8 string */ bufp = NULL; if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "utf8str")) || !TEST_true(OSSL_PARAM_set_utf8_string(cp, "abcdef")) - || !TEST_size_t_eq(sz, sizeof("abcdef")) + || !TEST_size_t_eq(cp->return_size, sizeof("abcdef")) || !TEST_true(OSSL_PARAM_get_utf8_string(cp, &bufp, 0)) || !TEST_str_eq(bufp, "abcdef")) goto err; @@ -527,56 +505,54 @@ static int test_param_construct(void) goto err; /* UTF8 pointer */ bufp = buf; - sz = 0; if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "utf8ptr")) || !TEST_true(OSSL_PARAM_set_utf8_ptr(cp, "tuvwxyz")) - || !TEST_size_t_eq(sz, sizeof("tuvwxyz")) + || !TEST_size_t_eq(cp->return_size, sizeof("tuvwxyz")) || !TEST_str_eq(bufp, "tuvwxyz") || !TEST_true(OSSL_PARAM_get_utf8_ptr(cp, (const char **)&bufp2)) || !TEST_ptr_eq(bufp2, bufp)) goto err; /* OCTET string */ - if (!TEST_ptr(p = locate(params, "octstr")) - || !TEST_true(OSSL_PARAM_set_octet_string(p, "abcdefghi", + if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "octstr")) + || !TEST_true(OSSL_PARAM_set_octet_string(cp, "abcdefghi", sizeof("abcdefghi"))) - || !TEST_size_t_eq(sz, sizeof("abcdefghi"))) + || !TEST_size_t_eq(cp->return_size, sizeof("abcdefghi"))) goto err; /* Match the return size to avoid trailing garbage bytes */ - p->data_size = *p->return_size; - if (!TEST_true(OSSL_PARAM_get_octet_string(p, &vpn, 0, &s)) + cp->data_size = cp->return_size; + if (!TEST_true(OSSL_PARAM_get_octet_string(cp, &vpn, 0, &s)) || !TEST_size_t_eq(s, sizeof("abcdefghi")) || !TEST_mem_eq(vpn, sizeof("abcdefghi"), "abcdefghi", sizeof("abcdefghi"))) goto err; vp = buf2; - if (!TEST_true(OSSL_PARAM_get_octet_string(p, &vp, sizeof(buf2), &s)) + if (!TEST_true(OSSL_PARAM_get_octet_string(cp, &vp, sizeof(buf2), &s)) || !TEST_size_t_eq(s, sizeof("abcdefghi")) || !TEST_mem_eq(vp, sizeof("abcdefghi"), "abcdefghi", sizeof("abcdefghi"))) goto err; /* OCTET pointer */ vp = &l; - sz = 0; - if (!TEST_ptr(p = locate(params, "octptr")) - || !TEST_true(OSSL_PARAM_set_octet_ptr(p, &ul, sizeof(ul))) - || !TEST_size_t_eq(sz, sizeof(ul)) + if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "octptr")) + || !TEST_true(OSSL_PARAM_set_octet_ptr(cp, &ul, sizeof(ul))) + || !TEST_size_t_eq(cp->return_size, sizeof(ul)) || !TEST_ptr_eq(vp, &ul)) goto err; /* Match the return size to avoid trailing garbage bytes */ - p->data_size = *p->return_size; - if (!TEST_true(OSSL_PARAM_get_octet_ptr(p, (const void **)&vp2, &k)) + cp->data_size = cp->return_size; + if (!TEST_true(OSSL_PARAM_get_octet_ptr(cp, (const void **)&vp2, &k)) || !TEST_size_t_eq(k, sizeof(ul)) || !TEST_ptr_eq(vp2, vp)) goto err; /* BIGNUM */ - if (!TEST_ptr(p = locate(params, "bignum")) + if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "bignum")) || !TEST_ptr(bn = BN_lebin2bn(bn_val, (int)sizeof(bn_val), NULL)) - || !TEST_true(OSSL_PARAM_set_BN(p, bn)) - || !TEST_size_t_eq(sz, sizeof(bn_val))) + || !TEST_true(OSSL_PARAM_set_BN(cp, bn)) + || !TEST_size_t_eq(cp->return_size, sizeof(bn_val))) goto err; /* Match the return size to avoid trailing garbage bytes */ - p->data_size = *p->return_size; - if(!TEST_true(OSSL_PARAM_get_BN(p, &bn2)) + cp->data_size = cp->return_size; + if(!TEST_true(OSSL_PARAM_get_BN(cp, &bn2)) || !TEST_BN_eq(bn, bn2)) goto err; ret = 1; diff --git a/test/params_conversion_test.c b/test/params_conversion_test.c index 96d0aaaf..d6490833 100644 --- a/test/params_conversion_test.c +++ b/test/params_conversion_test.c @@ -9,16 +9,18 @@ */ #include -#include #include #include "testutil.h" -#ifdef OPENSSL_SYS_WINDOWS -# define strcasecmp _stricmp -#endif +/* On machines that dont support just disable the tests */ +#if !defined(OPENSSL_NO_INTTYPES_H) + +# ifdef OPENSSL_SYS_WINDOWS +# define strcasecmp _stricmp +# endif typedef struct { - const OSSL_PARAM *param; + OSSL_PARAM *param; int32_t i32; int64_t i64; uint32_t u32; @@ -37,7 +39,7 @@ static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s) static uint32_t datum_u32, ref_u32; static uint64_t datum_u64, ref_u64; static double datum_d, ref_d; - static const OSSL_PARAM params[] = { + static OSSL_PARAM params[] = { OSSL_PARAM_int32("int32", &datum_i32), OSSL_PARAM_int64("int64", &datum_i64), OSSL_PARAM_uint32("uint32", &datum_u32), @@ -320,6 +322,8 @@ end: return res; } +#endif /* OPENSSL_NO_INTTYPES_H */ + OPT_TEST_DECLARE_USAGE("file...\n") int setup_tests(void) @@ -329,6 +333,9 @@ int setup_tests(void) if (n == 0) return 0; +#if !defined(OPENSSL_NO_INTTYPES_H) ADD_ALL_TESTS(run_param_file_tests, n); +#endif /* OPENSSL_NO_INTTYPES_H */ + return 1; } diff --git a/test/params_test.c b/test/params_test.c index aae91f1f..339a5169 100644 --- a/test/params_test.c +++ b/test/params_test.c @@ -46,13 +46,13 @@ struct object_st { double p2; /* * Documented as an arbitrarly large unsigned integer. - * The data size must be large enough to accomodate. + * The data size must be large enough to accommodate. * Assumed data type OSSL_PARAM_UNSIGNED_INTEGER */ BIGNUM *p3; /* * Documented as a C string. - * The data size must be large enough to accomodate. + * The data size must be large enough to accommodate. * Assumed data type OSSL_PARAM_UTF8_STRING */ char *p4; @@ -152,40 +152,35 @@ static int raw_set_params(void *vobj, const OSSL_PARAM *params) return 1; } -static int raw_get_params(void *vobj, const OSSL_PARAM *params) +static int raw_get_params(void *vobj, OSSL_PARAM *params) { struct object_st *obj = vobj; for (; params->key != NULL; params++) if (strcmp(params->key, "p1") == 0) { - if (params->return_size != NULL) - *params->return_size = sizeof(obj->p1); + params->return_size = sizeof(obj->p1); *(int *)params->data = obj->p1; } else if (strcmp(params->key, "p2") == 0) { - if (params->return_size != NULL) - *params->return_size = sizeof(obj->p2); + params->return_size = sizeof(obj->p2); *(double *)params->data = obj->p2; } else if (strcmp(params->key, "p3") == 0) { size_t bytes = BN_num_bytes(obj->p3); - if (params->return_size != NULL) - *params->return_size = bytes; + params->return_size = bytes; if (!TEST_size_t_ge(params->data_size, bytes)) return 0; BN_bn2nativepad(obj->p3, params->data, bytes); } else if (strcmp(params->key, "p4") == 0) { size_t bytes = strlen(obj->p4) + 1; - if (params->return_size != NULL) - *params->return_size = bytes; + params->return_size = bytes; if (!TEST_size_t_ge(params->data_size, bytes)) return 0; strcpy(params->data, obj->p4); } else if (strcmp(params->key, "p5") == 0) { size_t bytes = strlen(obj->p5) + 1; - if (params->return_size != NULL) - *params->return_size = bytes; + params->return_size = bytes; if (!TEST_size_t_ge(params->data_size, bytes)) return 0; strcpy(params->data, obj->p5); @@ -198,8 +193,7 @@ static int raw_get_params(void *vobj, const OSSL_PARAM *params) */ size_t bytes = strlen(obj->p6) + 1; - if (params->return_size != NULL) - *params->return_size = bytes; + params->return_size = bytes; *(const char **)params->data = obj->p6; } @@ -215,29 +209,29 @@ static int api_set_params(void *vobj, const OSSL_PARAM *params) struct object_st *obj = vobj; const OSSL_PARAM *p = NULL; - if ((p = OSSL_PARAM_locate(params, "p1")) != NULL + if ((p = OSSL_PARAM_locate_const(params, "p1")) != NULL && !TEST_true(OSSL_PARAM_get_int(p, &obj->p1))) return 0; - if ((p = OSSL_PARAM_locate(params, "p2")) != NULL + if ((p = OSSL_PARAM_locate_const(params, "p2")) != NULL && !TEST_true(OSSL_PARAM_get_double(p, &obj->p2))) return 0; - if ((p = OSSL_PARAM_locate(params, "p3")) != NULL + if ((p = OSSL_PARAM_locate_const(params, "p3")) != NULL && !TEST_true(OSSL_PARAM_get_BN(p, &obj->p3))) return 0; - if ((p = OSSL_PARAM_locate(params, "p4")) != NULL) { + if ((p = OSSL_PARAM_locate_const(params, "p4")) != NULL) { OPENSSL_free(obj->p4); obj->p4 = NULL; /* If the value pointer is NULL, we get it automatically allocated */ if (!TEST_true(OSSL_PARAM_get_utf8_string(p, &obj->p4, 0))) return 0; } - if ((p = OSSL_PARAM_locate(params, "p5")) != NULL) { + if ((p = OSSL_PARAM_locate_const(params, "p5")) != NULL) { char *p5_ptr = obj->p5; if (!TEST_true(OSSL_PARAM_get_utf8_string(p, &p5_ptr, sizeof(obj->p5)))) return 0; obj->p5_l = strlen(obj->p5) + 1; } - if ((p = OSSL_PARAM_locate(params, "p6")) != NULL) { + if ((p = OSSL_PARAM_locate_const(params, "p6")) != NULL) { if (!TEST_true(OSSL_PARAM_get_utf8_ptr(p, &obj->p6))) return 0; obj->p6_l = strlen(obj->p6) + 1; @@ -246,10 +240,10 @@ static int api_set_params(void *vobj, const OSSL_PARAM *params) return 1; } -static int api_get_params(void *vobj, const OSSL_PARAM *params) +static int api_get_params(void *vobj, OSSL_PARAM *params) { struct object_st *obj = vobj; - const OSSL_PARAM *p = NULL; + OSSL_PARAM *p = NULL; if ((p = OSSL_PARAM_locate(params, "p1")) != NULL && !TEST_true(OSSL_PARAM_set_int(p, obj->p1))) @@ -279,7 +273,7 @@ static int api_get_params(void *vobj, const OSSL_PARAM *params) */ struct provider_dispatch_st { int (*set_params)(void *obj, const OSSL_PARAM *params); - int (*get_params)(void *obj, const OSSL_PARAM *params); + int (*get_params)(void *obj, OSSL_PARAM *params); }; /* "raw" provider */ @@ -299,7 +293,7 @@ static const struct provider_dispatch_st provider_api = { /* In all our tests, these are variables that get manipulated as parameters * - * These arrays consistenly do nothing with the "p2" parameter, and + * These arrays consistently do nothing with the "p2" parameter, and * always include a "foo" parameter. This is to check that the * set_params and get_params calls ignore the lack of parameters that * the application isn't interested in, as well as ignore parameters @@ -310,15 +304,10 @@ static int app_p1; /* "p1" */ static double app_p2; /* "p2" is ignored */ static BIGNUM *app_p3 = NULL; /* "p3" */ static unsigned char bignumbin[4096]; /* "p3" */ -static size_t bignumbin_l; /* "p3" */ static char app_p4[256]; /* "p4" */ -static size_t app_p4_l; /* "p4" */ static char app_p5[256]; /* "p5" */ -static size_t app_p5_l; /* "p5" */ static const char *app_p6 = NULL; /* "p6" */ -static size_t app_p6_l; /* "p6" */ static unsigned char foo[1]; /* "foo" */ -static size_t foo_l; /* "foo" */ #define app_p1_init 17 /* A random number */ #define app_p2_init 47.11 /* Another random number */ @@ -346,14 +335,10 @@ static int init_app_variables(void) if (!BN_hex2bn(&app_p3, app_p3_init) || (l = BN_bn2nativepad(app_p3, bignumbin, sizeof(bignumbin))) < 0) return 0; - bignumbin_l = (size_t)l; strcpy(app_p4, app_p4_init); - app_p4_l = sizeof(app_p4_init); strcpy(app_p5, app_p5_init); - app_p5_l = sizeof(app_p5_init); app_p6 = app_p6_init; foo[0] = app_foo_init; - foo_l = sizeof(app_foo_init); return 1; } @@ -363,30 +348,26 @@ static int init_app_variables(void) */ /* An array of OSSL_PARAM, specific in the most raw manner possible */ -static const OSSL_PARAM static_raw_params[] = { - { "p1", OSSL_PARAM_INTEGER, &app_p1, sizeof(app_p1), NULL }, - { "p3", OSSL_PARAM_UNSIGNED_INTEGER, &bignumbin, sizeof(bignumbin), - &bignumbin_l }, - { "p4", OSSL_PARAM_UTF8_STRING, &app_p4, sizeof(app_p4), &app_p4_l }, - { "p5", OSSL_PARAM_UTF8_STRING, &app_p5, sizeof(app_p5), &app_p5_l }, +static OSSL_PARAM static_raw_params[] = { + { "p1", OSSL_PARAM_INTEGER, &app_p1, sizeof(app_p1), 0 }, + { "p3", OSSL_PARAM_UNSIGNED_INTEGER, &bignumbin, sizeof(bignumbin), 0 }, + { "p4", OSSL_PARAM_UTF8_STRING, &app_p4, sizeof(app_p4), 0 }, + { "p5", OSSL_PARAM_UTF8_STRING, &app_p5, sizeof(app_p5), 0 }, /* sizeof(app_p6_init), because we know that's what we're using */ - { "p6", OSSL_PARAM_UTF8_PTR, &app_p6, sizeof(app_p6_init), &app_p6_l }, - { "foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), &foo_l }, - { NULL, 0, NULL, 0, NULL } + { "p6", OSSL_PARAM_UTF8_PTR, &app_p6, sizeof(app_p6_init), 0 }, + { "foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), 0 }, + { NULL, 0, NULL, 0, 0 } }; /* The same array of OSSL_PARAM, specified with the macros from params.h */ -static const OSSL_PARAM static_api_params[] = { +static OSSL_PARAM static_api_params[] = { OSSL_PARAM_int("p1", &app_p1), - OSSL_PARAM_SIZED_BN("p3", &bignumbin, sizeof(bignumbin), bignumbin_l), - OSSL_PARAM_DEFN("p4", OSSL_PARAM_UTF8_STRING, - &app_p4, sizeof(app_p4), &app_p4_l), - OSSL_PARAM_DEFN("p5", OSSL_PARAM_UTF8_STRING, - &app_p5, sizeof(app_p5), &app_p5_l), + OSSL_PARAM_BN("p3", &bignumbin, sizeof(bignumbin)), + OSSL_PARAM_DEFN("p4", OSSL_PARAM_UTF8_STRING, &app_p4, sizeof(app_p4)), + OSSL_PARAM_DEFN("p5", OSSL_PARAM_UTF8_STRING, &app_p5, sizeof(app_p5)), /* sizeof(app_p6_init), because we know that's what we're using */ - OSSL_PARAM_DEFN("p6", OSSL_PARAM_UTF8_PTR, - &app_p6, sizeof(app_p6_init), &app_p6_l), - OSSL_PARAM_DEFN("foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), &foo_l), + OSSL_PARAM_DEFN("p6", OSSL_PARAM_UTF8_PTR, &app_p6, sizeof(app_p6_init)), + OSSL_PARAM_DEFN("foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo)), OSSL_PARAM_END }; @@ -399,25 +380,23 @@ static OSSL_PARAM *construct_api_params(void) size_t n = 0; static OSSL_PARAM params[10]; - params[n++] = OSSL_PARAM_construct_int("p1", &app_p1, NULL); - params[n++] = OSSL_PARAM_construct_BN("p3", bignumbin, sizeof(bignumbin), - &bignumbin_l); - params[n++] = OSSL_PARAM_construct_utf8_string("p4", app_p4, sizeof(app_p4), - &app_p4_l); + params[n++] = OSSL_PARAM_construct_int("p1", &app_p1); + params[n++] = OSSL_PARAM_construct_BN("p3", bignumbin, sizeof(bignumbin)); + params[n++] = OSSL_PARAM_construct_utf8_string("p4", app_p4, + sizeof(app_p4)); params[n++] = OSSL_PARAM_construct_utf8_string("p5", app_p5, - sizeof(app_p5), &app_p5_l); + sizeof(app_p5)); /* sizeof(app_p6_init), because we know that's what we're using */ params[n++] = OSSL_PARAM_construct_utf8_ptr("p6", (char **)&app_p6, - sizeof(app_p6_init), &app_p6_l); - params[n++] = OSSL_PARAM_construct_octet_string("foo", &foo, sizeof(foo), - &foo_l); + sizeof(app_p6_init)); + params[n++] = OSSL_PARAM_construct_octet_string("foo", &foo, sizeof(foo)); params[n++] = OSSL_PARAM_construct_end(); return params; } struct param_owner_st { - const OSSL_PARAM *static_params; + OSSL_PARAM *static_params; OSSL_PARAM *(*constructed_params)(void); }; @@ -452,12 +431,12 @@ static struct { }; /* Generic tester of combinations of "providers" and params */ -static int test_case_variant(const OSSL_PARAM *params, - const struct provider_dispatch_st *prov) +static int test_case_variant(OSSL_PARAM *params, const struct provider_dispatch_st *prov) { BIGNUM *verify_p3 = NULL; void *obj = NULL; int errcnt = 0; + OSSL_PARAM *p; /* * Initialize @@ -477,15 +456,19 @@ static int test_case_variant(const OSSL_PARAM *params, if (!TEST_true(prov->get_params(obj, params)) || !TEST_int_eq(app_p1, p1_init) /* "provider" value */ || !TEST_double_eq(app_p2, app_p2_init) /* Should remain untouched */ - || !TEST_ptr(BN_native2bn(bignumbin, bignumbin_l, app_p3)) + || !TEST_ptr(p = OSSL_PARAM_locate(params, "p3")) + || !TEST_ptr(BN_native2bn(bignumbin, p->return_size, app_p3)) || !TEST_BN_eq(app_p3, verify_p3) /* "provider" value */ || !TEST_str_eq(app_p4, p4_init) /* "provider" value */ - || !TEST_size_t_eq(app_p5_l, sizeof(p5_init)) /* "provider" value */ + || !TEST_ptr(p = OSSL_PARAM_locate(params, "p5")) + || !TEST_size_t_eq(p->return_size, sizeof(p5_init)) /* "provider" value */ || !TEST_str_eq(app_p5, p5_init) /* "provider" value */ - || !TEST_size_t_eq(app_p6_l, sizeof(p6_init)) /* "provider" value */ + || !TEST_ptr(p = OSSL_PARAM_locate(params, "p6")) + || !TEST_size_t_eq(p->return_size, sizeof(p6_init)) /* "provider" value */ || !TEST_str_eq(app_p6, p6_init) /* "provider" value */ || !TEST_char_eq(foo[0], app_foo_init) /* Should remain untouched */ - || !TEST_int_eq(foo_l, sizeof(app_foo_init))) + || !TEST_ptr(p = OSSL_PARAM_locate(params, "foo")) + || !TEST_int_eq(p->return_size, 0)) errcnt++; /* @@ -503,10 +486,7 @@ static int test_case_variant(const OSSL_PARAM *params, || !TEST_double_eq(sneakpeek->p2, p2_init) /* Should remain untouched */ || !TEST_BN_eq(sneakpeek->p3, app_p3) /* app value set */ || !TEST_str_eq(sneakpeek->p4, app_p4) /* app value set */ - || !TEST_size_t_eq(sneakpeek->p5_l, app_p5_l) /* app value set */ || !TEST_str_eq(sneakpeek->p5, app_p5) /* app value set */ - || !TEST_size_t_eq(sneakpeek->p6_l, - sizeof(app_p6_init)) /* app value set */ || !TEST_str_eq(sneakpeek->p6, app_p6)) /* app value set */ errcnt++; } @@ -526,17 +506,21 @@ static int test_case_variant(const OSSL_PARAM *params, if (!TEST_true(prov->get_params(obj, params)) || !TEST_int_eq(app_p1, app_p1_init) /* app value */ || !TEST_double_eq(app_p2, app_p2_init) /* Should remain untouched */ - || !TEST_ptr(BN_native2bn(bignumbin, bignumbin_l, app_p3)) + || !TEST_ptr(p = OSSL_PARAM_locate(params, "p3")) + || !TEST_ptr(BN_native2bn(bignumbin, p->return_size, app_p3)) || !TEST_BN_eq(app_p3, verify_p3) /* app value */ || !TEST_str_eq(app_p4, app_p4_init) /* app value */ - || !TEST_size_t_eq(app_p5_l, + || !TEST_ptr(p = OSSL_PARAM_locate(params, "p5")) + || !TEST_size_t_eq(p->return_size, sizeof(app_p5_init)) /* app value */ || !TEST_str_eq(app_p5, app_p5_init) /* app value */ - || !TEST_size_t_eq(app_p6_l, + || !TEST_ptr(p = OSSL_PARAM_locate(params, "p6")) + || !TEST_size_t_eq(p->return_size, sizeof(app_p6_init)) /* app value */ || !TEST_str_eq(app_p6, app_p6_init) /* app value */ || !TEST_char_eq(foo[0], app_foo_init) /* Should remain untouched */ - || !TEST_int_eq(foo_l, sizeof(app_foo_init))) + || !TEST_ptr(p = OSSL_PARAM_locate(params, "foo")) + || !TEST_int_eq(p->return_size, 0)) errcnt++; fin: diff --git a/test/provider_internal_test.c b/test/provider_internal_test.c index 6123d6b4..aff858f3 100644 --- a/test/provider_internal_test.c +++ b/test/provider_internal_test.c @@ -15,10 +15,9 @@ extern OSSL_provider_init_fn PROVIDER_INIT_FUNCTION_NAME; static char buf[256]; -static size_t buf_l = 0; static OSSL_PARAM greeting_request[] = { - { "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf), &buf_l }, - { NULL, 0, NULL, 0, NULL } + { "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf), 0 }, + { NULL, 0, NULL, 0, 0 } }; static int test_provider(OSSL_PROVIDER *prov, const char *expected_greeting) diff --git a/test/provider_test.c b/test/provider_test.c index c00f5ab4..acb9f200 100644 --- a/test/provider_test.c +++ b/test/provider_test.c @@ -14,10 +14,9 @@ extern OSSL_provider_init_fn PROVIDER_INIT_FUNCTION_NAME; static char buf[256]; -static size_t buf_l = 0; static OSSL_PARAM greeting_request[] = { - { "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf), &buf_l }, - { NULL, 0, NULL, 0, NULL } + { "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf) }, + { NULL, 0, NULL, 0, 0 } }; static int test_provider(const char *name) diff --git a/test/rc5test.c b/test/rc5test.c index 16f40717..39a113e8 100644 --- a/test/rc5test.c +++ b/test/rc5test.c @@ -181,7 +181,8 @@ static int test_rc5_ecb(int n) RC5_32_KEY key; unsigned char buf[8], buf2[8]; - RC5_32_set_key(&key, 16, &RC5key[n][0], 12); + if (!TEST_true(RC5_32_set_key(&key, 16, &RC5key[n][0], 12))) + return 0; RC5_32_ecb_encrypt(&RC5plain[n][0], buf, &key, RC5_ENCRYPT); if (!TEST_mem_eq(&RC5cipher[n][0], sizeof(RC5cipher[0]), buf, sizeof(buf))) @@ -203,7 +204,9 @@ static int test_rc5_cbc(int n) i = rc5_cbc_rounds[n]; if (i >= 8) { - RC5_32_set_key(&key, rc5_cbc_key[n][0], &rc5_cbc_key[n][1], i); + if (!TEST_true(RC5_32_set_key(&key, rc5_cbc_key[n][0], + &rc5_cbc_key[n][1], i))) + return 0; memcpy(ivb, &rc5_cbc_iv[n][0], 8); RC5_32_cbc_encrypt(&rc5_cbc_plain[n][0], buf, 8, diff --git a/test/recipes/02-test_errstr.t b/test/recipes/02-test_errstr.t index 3498b819..76e0bba4 100644 --- a/test/recipes/02-test_errstr.t +++ b/test/recipes/02-test_errstr.t @@ -104,18 +104,31 @@ foreach my $errname (@posix_errors) { my @oerr = run(app([ qw(openssl errstr), sprintf("2%06x", $errnum) ]), capture => 1); $oerr[0] =~ s|\R$||; - $oerr[0] =~ s|.*system library:||g; # The actual message is last - - ok($oerr[0] eq $perr, "($errnum) '$oerr[0]' == '$perr'"); + @oerr = split_error($oerr[0]); + ok($oerr[3] eq $perr, "($errnum) '$oerr[3]' == '$perr'"); } } my @after = run(app([ qw(openssl errstr 2000080) ]), capture => 1); $after[0] =~ s|\R$||; -$after[0] =~ s|.*system library:||g; -ok($after[0] eq "reason(128)", "(128) '$after[0]' == 'reason(128)'"); +@after = split_error($after[0]); +ok($after[3] eq "reason(128)", "(128) '$after[3]' == 'reason(128)'"); my @zero = run(app([ qw(openssl errstr 2000000) ]), capture => 1); $zero[0] =~ s|\R$||; -$zero[0] =~ s|.*system library:||g; -ok($zero[0] eq "system library", "(0) '$zero[0]' == 'system library'"); +@zero = split_error($zero[0]); +ok($zero[3] eq "system library", "(0) '$zero[3]' == 'system library'"); + +# For an error string "error:xxxxxxxx:lib:func:reason", this returns +# the following array: +# +# ( "xxxxxxxx", "lib", "func", "reason" ) +sub split_error { + # Limit to 5 items, in case the reason contains a colon + my @erritems = split /:/, $_[0], 5; + + # Remove the first item, which is always "error" + shift @erritems; + + return @erritems; +} diff --git a/test/recipes/03-test_internal_namemap.t b/test/recipes/03-test_internal_namemap.t new file mode 100644 index 00000000..9214242c --- /dev/null +++ b/test/recipes/03-test_internal_namemap.t @@ -0,0 +1,16 @@ +#! /usr/bin/env perl +# Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License 2.0 (the "License"). You may not use +# this file except in compliance with the License. You can obtain a copy +# in the file LICENSE in the source distribution or at +# https://www.openssl.org/source/license.html + +use strict; +use OpenSSL::Test; # get 'plan' +use OpenSSL::Test::Simple; +use OpenSSL::Test::Utils; + +setup("test_internal_namemap"); + +simple_test("test_internal_namemap", "namemap_internal_test"); diff --git a/test/recipes/05-test_mdc2.t b/test/recipes/05-test_mdc2.t index eb5cd8f1..495a146e 100644 --- a/test/recipes/05-test_mdc2.t +++ b/test/recipes/05-test_mdc2.t @@ -7,6 +7,20 @@ # https://www.openssl.org/source/license.html -use OpenSSL::Test::Simple; +use strict; +use warnings; -simple_test("test_mdc2", "mdc2test", "mdc2"); +use OpenSSL::Test qw/:DEFAULT bldtop_dir/; +use OpenSSL::Test::Utils; + +setup("test_mdc2"); + +if (disabled("mdc2") || disabled("legacy")) { + plan skip_all => "mdc2 is not supported by this OpenSSL build"; +} + +plan tests => 1; + +$ENV{OPENSSL_MODULES} = bldtop_dir("providers"); + +ok(run(test(["mdc2test"])), "running mdc2test"); diff --git a/test/recipes/20-test_kdf.t b/test/recipes/20-test_kdf.t index 0ea484e0..39fb4852 100755 --- a/test/recipes/20-test_kdf.t +++ b/test/recipes/20-test_kdf.t @@ -25,8 +25,8 @@ my @kdf_tests = ( { cmd => [qw{openssl kdf -keylen 10 -kdfopt digest:SHA256 -kdfopt key:secret -kdfopt salt:salt -kdfopt info:label HKDF}], expected => '2a:c4:36:9f:52:59:96:f8:de:13', desc => 'HKDF SHA256' }, - { cmd => [qw{openssl kdf -keylen 32 -kdfopt digest:SHA256 -kdfopt pass:password -kdfopt salt:salt -kdfopt iter:2 PBKDF2}], - expected => 'ae:4d:0c:95:af:6b:46:d3:2d:0a:df:f9:28:f0:6d:d0:2a:30:3f:8e:f3:c2:51:df:d6:e2:d8:5a:95:47:4c:43', + { cmd => [qw{openssl kdf -keylen 25 -kdfopt digest:SHA256 -kdfopt pass:passwordPASSWORDpassword -kdfopt salt:saltSALTsaltSALTsaltSALTsaltSALTsalt -kdfopt iter:4096 PBKDF2}], + expected => '34:8C:89:DB:CB:D3:2B:2F:32:D8:14:B8:11:6E:84:CF:2B:17:34:7E:BC:18:00:18:1C', desc => 'PBKDF2 SHA256'}, { cmd => [qw{openssl kdf -keylen 64 -kdfopt mac:KMAC128 -kdfopt maclen:20 -kdfopt hexkey:b74a149a161546f8c20b06ac4ed4 -kdfopt hexinfo:348a37a27ef1282f5f020dcc -kdfopt hexsalt:3638271ccd68a25dc24ecddd39ef3f89 SSKDF}], expected => 'e9:c1:84:53:a0:62:b5:3b:db:fc:bb:5a:34:bd:b8:e5:e7:07:ee:bb:5d:d1:34:42:43:d8:cf:c2:c2:e6:33:2f:91:bd:a5:86:f3:7d:e4:8a:65:d4:c5:14:fd:ef:aa:1e:67:54:f3:73:d2:38:e1:95:ae:15:7e:1d:e8:14:98:03', diff --git a/test/recipes/20-test_pkeyutl.t b/test/recipes/20-test_pkeyutl.t index 5dbed983..83804d69 100644 --- a/test/recipes/20-test_pkeyutl.t +++ b/test/recipes/20-test_pkeyutl.t @@ -10,7 +10,7 @@ use strict; use warnings; use File::Spec; -use OpenSSL::Test qw/:DEFAULT srctop_file/; +use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips/; use OpenSSL::Test::Utils; setup("test_pkeyutl"); @@ -24,13 +24,13 @@ SKIP: { if disabled("ec") || disabled("sm2") || disabled("sm3"); # SM2 - ok(run(app(([ 'openssl', 'pkeyutl', '-sign', + ok_nofips(run(app(([ 'openssl', 'pkeyutl', '-sign', '-in', srctop_file('test', 'certs', 'sm2.pem'), '-inkey', srctop_file('test', 'certs', 'sm2.key'), '-out', 'signature.dat', '-rawin', '-digest', 'sm3', '-pkeyopt', 'sm2_id:someid']))), "Sign a piece of data using SM2"); - ok(run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin', + ok_nofips(run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin', '-in', srctop_file('test', 'certs', 'sm2.pem'), '-inkey', srctop_file('test', 'certs', 'sm2.pem'), '-sigfile', 'signature.dat', '-rawin', diff --git a/test/recipes/25-test_req.t b/test/recipes/25-test_req.t index eb25fd43..127b3386 100644 --- a/test/recipes/25-test_req.t +++ b/test/recipes/25-test_req.t @@ -15,7 +15,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/; setup("test_req"); -plan tests => 9; +plan tests => 10; require_ok(srctop_file('test','recipes','tconversion.pl')); @@ -58,6 +58,25 @@ subtest "generating certificate requests" => sub { "Verifying signature on request"); }; +subtest "generating SM2 certificate requests" => sub { + plan tests => 2; + + SKIP: { + skip "SM2 is not supported by this OpenSSL build", 2 + if disabled("sm2"); + ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"), + "-new", "-key", srctop_file("test", "certs", "sm2.key"), + "-sigopt", "sm2_id:1234567812345678", + "-out", "testreq.pem", "-sm3"])), + "Generating SM2 certificate request"); + + ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"), + "-verify", "-in", "testreq.pem", "-noout", + "-sm2-id", "1234567812345678", "-sm3"])), + "Verifying signature on SM2 certificate request"); + } +}; + my @openssl_args = ("req", "-config", srctop_file("apps", "openssl.cnf")); run_conversion('req conversions', diff --git a/test/recipes/25-test_verify.t b/test/recipes/25-test_verify.t index 96bfd03e..915c902b 100644 --- a/test/recipes/25-test_verify.t +++ b/test/recipes/25-test_verify.t @@ -11,7 +11,7 @@ use strict; use warnings; use File::Spec::Functions qw/canonpath/; -use OpenSSL::Test qw/:DEFAULT srctop_file/; +use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips/; use OpenSSL::Test::Utils; setup("test_verify"); @@ -379,9 +379,9 @@ SKIP: { if disabled("sm2"); # Test '-sm2-id' and '-sm2-hex-id' option - ok(verify("sm2", "any", ["sm2-ca-cert"], [], "-sm2-id", "1234567812345678"), + ok_nofips(verify("sm2", "any", ["sm2-ca-cert"], [], "-sm2-id", "1234567812345678"), "SM2 ID test"); - ok(verify("sm2", "any", ["sm2-ca-cert"], [], "-sm2-hex-id", + ok_nofips(verify("sm2", "any", ["sm2-ca-cert"], [], "-sm2-hex-id", "31323334353637383132333435363738"), "SM2 hex ID test"); } diff --git a/test/recipes/30-test_evp.t b/test/recipes/30-test_evp.t index 6cc4df04..c140f1a8 100644 --- a/test/recipes/30-test_evp.t +++ b/test/recipes/30-test_evp.t @@ -10,7 +10,7 @@ use strict; use warnings; -use OpenSSL::Test qw/:DEFAULT data_file/; +use OpenSSL::Test qw(:DEFAULT data_file bldtop_dir); setup("test_evp"); @@ -20,6 +20,8 @@ my @files = ( "evpciph.txt", "evpdigest.txt", "evpencod.txt", "evpkdf.txt", plan tests => scalar(@files); +$ENV{OPENSSL_MODULES} = bldtop_dir("providers"); + foreach my $f ( @files ) { ok(run(test(["evp_test", data_file("$f")])), "running evp_test $f"); diff --git a/test/recipes/30-test_evp_data/evpciph.txt b/test/recipes/30-test_evp_data/evpciph.txt index 916ba159..3dd5a87b 100644 --- a/test/recipes/30-test_evp_data/evpciph.txt +++ b/test/recipes/30-test_evp_data/evpciph.txt @@ -1190,13 +1190,34 @@ Result = CIPHERFINAL_ERROR Title = AES XTS test vectors from IEEE Std 1619-2007 +# Using the same key twice for encryption is always banned. Cipher = aes-128-xts +Operation = ENCRYPT Key = 0000000000000000000000000000000000000000000000000000000000000000 IV = 00000000000000000000000000000000 Plaintext = 0000000000000000000000000000000000000000000000000000000000000000 Ciphertext = 917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e Result = KEY_SET_ERROR +# Using the same key twice for decryption is banned in FIPS mode. +#Cipher = aes-128-xts +#FIPS = YES +#Operation = DECRYPT +#Key = 0000000000000000000000000000000000000000000000000000000000000000 +#IV = 00000000000000000000000000000000 +#Plaintext = 0000000000000000000000000000000000000000000000000000000000000000 +#Ciphertext = 917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e +#Result = KEY_SET_ERROR + +# Using the same key twice for decryption is allowed outside of FIPS mode. +Cipher = aes-128-xts +#FIPS = NO +Operation = DECRYPT +Key = 0000000000000000000000000000000000000000000000000000000000000000 +IV = 00000000000000000000000000000000 +Plaintext = 0000000000000000000000000000000000000000000000000000000000000000 +Ciphertext = 917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e + Cipher = aes-128-xts Key = 1111111111111111111111111111111122222222222222222222222222222222 IV = 33333333330000000000000000000000 diff --git a/test/recipes/30-test_evp_data/evpdigest.txt b/test/recipes/30-test_evp_data/evpdigest.txt index fe3de3cb..e32c5dd6 100644 --- a/test/recipes/30-test_evp_data/evpdigest.txt +++ b/test/recipes/30-test_evp_data/evpdigest.txt @@ -276,104 +276,127 @@ Title = MD4 tests Digest = MD4 Input = "" Output = 31d6cfe0d16ae931b73c59d7e0c089c0 +Legacy = 1 Digest = MD4 Input = "a" Output = bde52cb31de33e46245e05fbdbd6fb24 +Legacy = 1 Digest = MD4 Input = "abc" Output = a448017aaf21d8525fc10ae87aa6729d +Legacy = 1 Digest = MD4 Input = "message digest" Output = d9130a8164549fe818874806e1c7014b +Legacy = 1 Digest = MD4 Input = "abcdefghijklmnopqrstuvwxyz" Output = d79e1c308aa5bbcdeea8ed63df412da9 +Legacy = 1 Digest = MD4 Input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" Output = 043f8582f241db351ce627e153e7f0e4 +Legacy = 1 Digest = MD4 Input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890" Output = e33b4ddc9c38f2199c3e7b164fcc0536 +Legacy = 1 Title = RIPEMD160 tests Digest = RIPEMD160 Input = "" Output = 9c1185a5c5e9fc54612808977ee8f548b2258d31 +Legacy = 1 Digest = RIPEMD160 Input = "a" Output = 0bdc9d2d256b3ee9daae347be6f4dc835a467ffe +Legacy = 1 Digest = RIPEMD160 Input = "abc" Output = 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc +Legacy = 1 Digest = RIPEMD160 Input = "message digest" Output = 5d0689ef49d2fae572b881b123a85ffa21595f36 +Legacy = 1 Digest = RIPEMD160 Input = "abcdefghijklmnopqrstuvwxyz" Output = f71c27109c692c1b56bbdceb5b9d2865b3708dbc +Legacy = 1 Digest = RIPEMD160 Input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" Output = 12a053384a9c0c88e405a06c27dcf49ada62eb2b +Legacy = 1 Digest = RIPEMD160 Input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" Output = b0e20b6e3116640286ed3a87a5713079b21f5189 +Legacy = 1 Digest = RIPEMD160 Input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890" Output = 9b752e45573d4b39f4dbd3323cab82bf63326bfb +Legacy = 1 Title = Whirlpool (from ISO/IEC 10118-3 test vector set) Digest = whirlpool Input = "" Output = 19FA61D75522A4669B44E39C1D2E1726C530232130D407F89AFEE0964997F7A73E83BE698B288FEBCF88E3E03C4F0757EA8964E59B63D93708B138CC42A66EB3 +Legacy = 1 Digest = whirlpool Input = "a" Output = 8ACA2602792AEC6F11A67206531FB7D7F0DFF59413145E6973C45001D0087B42D11BC645413AEFF63A42391A39145A591A92200D560195E53B478584FDAE231A +Legacy = 1 Digest = whirlpool Input = "abc" Output = 4E2448A4C6F486BB16B6562C73B4020BF3043E3A731BCE721AE1B303D97E6D4C7181EEBDB6C57E277D0E34957114CBD6C797FC9D95D8B582D225292076D4EEF5 +Legacy = 1 Digest = whirlpool Input = "message digest" Output = 378C84A4126E2DC6E56DCC7458377AAC838D00032230F53CE1F5700C0FFB4D3B8421557659EF55C106B4B52AC5A4AAA692ED920052838F3362E86DBD37A8903E +Legacy = 1 Digest = whirlpool Input = "abcdefghijklmnopqrstuvwxyz" Output = F1D754662636FFE92C82EBB9212A484A8D38631EAD4238F5442EE13B8054E41B08BF2A9251C30B6A0B8AAE86177AB4A6F68F673E7207865D5D9819A3DBA4EB3B +Legacy = 1 Digest = whirlpool Input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" Output = DC37E008CF9EE69BF11F00ED9ABA26901DD7C28CDEC066CC6AF42E40F82F3A1E08EBA26629129D8FB7CB57211B9281A65517CC879D7B962142C65F5A7AF01467 +Legacy = 1 Digest = whirlpool Input = "12345678901234567890123456789012345678901234567890123456789012345678901234567890" Output = 466EF18BABB0154D25B9D38A6414F5C08784372BCCB204D6549C4AFADB6014294D5BD8DF2A6C44E538CD047B2681A51A2C60481E88C5A20B2C2A80CF3A9A083B +Legacy = 1 Digest = whirlpool Input = "abcdbcdecdefdefgefghfghighijhijk" Output = 2A987EA40F917061F5D6F0A0E4644F488A7A5A52DEEE656207C562F988E95C6916BDC8031BC5BE1B7B947639FE050B56939BAAA0ADFF9AE6745B7B181C3BE3FD +Legacy = 1 Digest = whirlpool Input = "aaaaaaaaaa" Count = 100000 Output = 0C99005BEB57EFF50A7CF005560DDF5D29057FD86B20BFD62DECA0F1CCEA4AF51FC15490EDDC47AF32BB2B66C34FF9AD8C6008AD677F77126953B226E4ED8B01 - +Legacy = 1 Title = SHA3 diff --git a/test/recipes/30-test_evp_data/evpkdf.txt b/test/recipes/30-test_evp_data/evpkdf.txt index 7100c21f..6f7270bb 100644 --- a/test/recipes/30-test_evp_data/evpkdf.txt +++ b/test/recipes/30-test_evp_data/evpkdf.txt @@ -306,6 +306,7 @@ Result = INTERNAL_ERROR Title = PBKDF2 tests KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass:password Ctrl.salt = salt:salt Ctrl.iter = iter:1 @@ -313,6 +314,7 @@ Ctrl.digest = digest:sha1 Output = 0c60c80f961f0e71f3a9b524af6012062fe037a6 KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass:password Ctrl.salt = salt:salt Ctrl.iter = iter:1 @@ -320,6 +322,7 @@ Ctrl.digest = digest:sha256 Output = 120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass:password Ctrl.salt = salt:salt Ctrl.iter = iter:1 @@ -327,6 +330,7 @@ Ctrl.digest = digest:sha512 Output = 867f70cf1ade02cff3752599a3a53dc4af34c7a669815ae5d513554e1c8cf252c02d470a285a0501bad999bfe943c08f050235d7d68b1da55e63f73b60a57fce KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass:password Ctrl.salt = salt:salt Ctrl.iter = iter:2 @@ -334,6 +338,7 @@ Ctrl.digest = digest:sha1 Output = ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957 KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass:password Ctrl.salt = salt:salt Ctrl.iter = iter:2 @@ -341,6 +346,7 @@ Ctrl.digest = digest:sha256 Output = ae4d0c95af6b46d32d0adff928f06dd02a303f8ef3c251dfd6e2d85a95474c43 KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass:password Ctrl.salt = salt:salt Ctrl.iter = iter:2 @@ -348,6 +354,7 @@ Ctrl.digest = digest:sha512 Output = e1d9c16aa681708a45f5c7c4e215ceb66e011a2e9f0040713f18aefdb866d53cf76cab2868a39b9f7840edce4fef5a82be67335c77a6068e04112754f27ccf4e KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass:password Ctrl.salt = salt:salt Ctrl.iter = iter:4096 @@ -355,6 +362,7 @@ Ctrl.digest = digest:sha1 Output = 4b007901b765489abead49d926f721d065a429c1 KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass:password Ctrl.salt = salt:salt Ctrl.iter = iter:4096 @@ -362,6 +370,7 @@ Ctrl.digest = digest:sha256 Output = c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass:password Ctrl.salt = salt:salt Ctrl.iter = iter:4096 @@ -390,6 +399,7 @@ Ctrl.digest = digest:sha512 Output = 8c0511f4c6e597c6ac6315d8f0362e225f3c501495ba23b868c005174dc4ee71115b59f9e60cd9532fa33e0f75aefe30225c583a186cd82bd4daea9724a3d3b8 KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.hexpass = hexpass:7061737300776f7264 Ctrl.hexsalt = hexsalt:7361006c74 Ctrl.iter = iter:4096 @@ -397,6 +407,7 @@ Ctrl.digest = digest:sha1 Output = 56fa6aa75548099dcc37d7f03425e0c3 KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.hexpass = hexpass:7061737300776f7264 Ctrl.hexsalt = hexsalt:7361006c74 Ctrl.iter = iter:4096 @@ -404,6 +415,7 @@ Ctrl.digest = digest:sha256 Output = 89b69d0516f829893c696226650a8687 KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.hexpass = hexpass:7061737300776f7264 Ctrl.hexsalt = hexsalt:7361006c74 Ctrl.iter = iter:4096 @@ -413,6 +425,7 @@ Output = 9d9e9c4cd21fe4be24d5b8244c759665 Title = PBKDF2 tests for empty inputs KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass: Ctrl.salt = salt:salt Ctrl.iter = iter:1 @@ -420,6 +433,7 @@ Ctrl.digest = digest:sha1 Output = a33dddc30478185515311f8752895d36ea4363a2 KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass: Ctrl.salt = salt:salt Ctrl.iter = iter:1 @@ -427,6 +441,7 @@ Ctrl.digest = digest:sha256 Output = f135c27993baf98773c5cdb40a5706ce6a345cde KDF = PBKDF2 +Ctrl.pkcs5 = pkcs5:1 Ctrl.pass = pass: Ctrl.salt = salt:salt Ctrl.iter = iter:1 @@ -6473,3 +6488,18 @@ Ctrl.digest = digest:SHA512 Ctrl.hexsecret = hexsecret:0037cd001a0ad87f35ddf58ab355d6144ba2ed0749a7435dab548ba0bfbe723c047e2396b4eef99653412a92c8db74bb5c03063f2eb0525ae87356750ae3676faa86 Ctrl.hexinfo = hexinfo:eb17da8851c41c7ac6710b1c49f324f8 Output = 829a28b81f9e95b5f306604067499c07d5944ca034ed130d513951f7143e4e162bad8adb2833e53b8235c293cd2a809659ac7f7e392cba6a543660e5d95070c0c9e6a9cdc38123e22da61bb4cbb6ad6d1a58a069e934fc231bd9fe39a24afcbf322ccea385f0418f3b01c1edd6e7124593a1cefe3e48fcd95daaf72cfd973c59 + +Title = X9.42 KDF tests (from RFC2631 test vectors) + +KDF = X942KDF +Ctrl.digest = digest:SHA1 +Ctrl.hexsecret = hexsecret:000102030405060708090a0b0c0d0e0f10111213 +Ctrl.cekalg = cekalg:id-smime-alg-CMS3DESwrap +Output = a09661392376f7044d9052a397883246b67f5f1ef63eb5fb + +KDF = X942KDF +Ctrl.digest = digest:SHA1 +Ctrl.hexsecret = hexsecret:000102030405060708090a0b0c0d0e0f10111213 +Ctrl.cekalg = cekalg:id-smime-alg-CMSRC2wrap +Ctrl.hexukm = hexukm:0123456789abcdeffedcba98765432010123456789abcdeffedcba98765432010123456789abcdeffedcba98765432010123456789abcdeffedcba9876543201 +Output = 48950c46e0530075403cce72889604e0 diff --git a/test/recipes/70-test_clienthello.t b/test/recipes/70-test_clienthello.t index a6b812aa..0ccbc8ef 100644 --- a/test/recipes/70-test_clienthello.t +++ b/test/recipes/70-test_clienthello.t @@ -15,6 +15,10 @@ setup("test_clienthello"); plan skip_all => "No TLS/SSL protocols are supported by this OpenSSL build" if alldisabled(grep { $_ ne "ssl3" } available_protocols("tls")); +#No EC with TLSv1.3 confuses the padding calculations in this test +plan skip_all => "No EC with TLSv1.3 is not supported by this test" + if disabled("ec") && !disabled("tls1_3"); + plan tests => 1; ok(run(test(["clienthellotest", srctop_file("test", "session.pem")])), diff --git a/test/recipes/70-test_key_share.t b/test/recipes/70-test_key_share.t index eeec0554..b5b01907 100644 --- a/test/recipes/70-test_key_share.t +++ b/test/recipes/70-test_key_share.t @@ -36,7 +36,9 @@ use constant { use constant { X25519 => 0x1d, - P_256 => 0x17 + P_256 => 0x17, + FFDHE2048 => 0x0100, + FFDHE3072 => 0x0101 }; my $testtype; @@ -74,7 +76,11 @@ my $proxy = TLSProxy::Proxy->new( $testtype = EMPTY_EXTENSION; $direction = CLIENT_TO_SERVER; $proxy->filter(\&modify_key_shares_filter); -$proxy->serverflags("-curves P-256"); +if (disabled("ec")) { + $proxy->serverflags("-groups ffdhe3072"); +} else { + $proxy->serverflags("-groups P-256"); +} $proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; plan tests => 22; ok(TLSProxy::Message->success(), "Success after HRR"); @@ -95,31 +101,52 @@ ok(TLSProxy::Message->fail(), "Missing key_shares extension"); # HelloRetryRequest $proxy->clear(); $proxy->filter(undef); -$proxy->serverflags("-curves P-256"); +if (disabled("ec")) { + $proxy->serverflags("-groups ffdhe3072"); +} else { + $proxy->serverflags("-groups P-256"); +} $proxy->start(); ok(TLSProxy::Message->success(), "No initial acceptable key_shares"); #Test 5: No acceptable key_shares and no shared groups should fail $proxy->clear(); $proxy->filter(undef); -$proxy->serverflags("-curves P-256"); -$proxy->clientflags("-curves P-384"); +if (disabled("ec")) { + $proxy->serverflags("-groups ffdhe2048"); +} else { + $proxy->serverflags("-groups P-256"); +} +if (disabled("ec")) { + $proxy->clientflags("-groups ffdhe3072"); +} else { + $proxy->clientflags("-groups P-384"); +} $proxy->start(); ok(TLSProxy::Message->fail(), "No acceptable key_shares"); #Test 6: A non preferred but acceptable key_share should succeed $proxy->clear(); $proxy->clientflags("-curves P-256"); +if (disabled("ec")) { + $proxy->clientflags("-groups ffdhe3072"); +} else { + $proxy->clientflags("-groups P-256"); +} $proxy->start(); ok(TLSProxy::Message->success(), "Non preferred key_share"); $proxy->filter(\&modify_key_shares_filter); -#Test 7: An acceptable key_share after a list of non-acceptable ones should -#succeed -$proxy->clear(); -$testtype = ACCEPTABLE_AT_END; -$proxy->start(); -ok(TLSProxy::Message->success(), "Acceptable key_share at end of list"); +SKIP: { + skip "No ec support in this OpenSSL build", 1 if disabled("ec"); + + #Test 7: An acceptable key_share after a list of non-acceptable ones should + #succeed + $proxy->clear(); + $testtype = ACCEPTABLE_AT_END; + $proxy->start(); + ok(TLSProxy::Message->success(), "Acceptable key_share at end of list"); +} #Test 8: An acceptable key_share but for a group not in supported_groups should #fail @@ -156,22 +183,45 @@ ok(TLSProxy::Message->fail(), "key_share list trailing data"); $proxy->clear(); $direction = SERVER_TO_CLIENT; $testtype = LOOK_ONLY; -$proxy->clientflags("-curves P-256:X25519"); +$selectedgroupid = 0; +if (disabled("ec")) { + $proxy->clientflags("-groups ffdhe3072:ffdhe2048"); +} else { + $proxy->clientflags("-groups P-256:X25519"); +} $proxy->start(); -ok(TLSProxy::Message->success() && ($selectedgroupid == P_256), - "Multiple acceptable key_shares"); +if (disabled("ec")) { + ok(TLSProxy::Message->success() && ($selectedgroupid == FFDHE3072), + "Multiple acceptable key_shares"); +} else { + ok(TLSProxy::Message->success() && ($selectedgroupid == P_256), + "Multiple acceptable key_shares"); +} #Test 14: Multiple acceptable key_shares - we choose the first one (part 2) $proxy->clear(); -$proxy->clientflags("-curves X25519:P-256"); +if (disabled("ec")) { + $proxy->clientflags("-curves ffdhe2048:ffdhe3072"); +} else { + $proxy->clientflags("-curves X25519:P-256"); +} $proxy->start(); -ok(TLSProxy::Message->success() && ($selectedgroupid == X25519), - "Multiple acceptable key_shares (part 2)"); +if (disabled("ec")) { + ok(TLSProxy::Message->success() && ($selectedgroupid == FFDHE2048), + "Multiple acceptable key_shares (part 2)"); +} else { + ok(TLSProxy::Message->success() && ($selectedgroupid == X25519), + "Multiple acceptable key_shares (part 2)"); +} #Test 15: Server sends key_share that wasn't offered should fail $proxy->clear(); $testtype = SELECT_X25519; -$proxy->clientflags("-curves P-256"); +if (disabled("ec")) { + $proxy->clientflags("-groups ffdhe3072"); +} else { + $proxy->clientflags("-groups P-256"); +} $proxy->start(); ok(TLSProxy::Message->fail(), "Non offered key_share"); @@ -229,7 +279,11 @@ SKIP: { $proxy->clear(); $direction = SERVER_TO_CLIENT; $testtype = NO_KEY_SHARES_IN_HRR; -$proxy->serverflags("-curves X25519"); +if (disabled("ec")) { + $proxy->serverflags("-groups ffdhe2048"); +} else { + $proxy->serverflags("-groups X25519"); +} $proxy->start(); ok(TLSProxy::Message->fail(), "Server sends HRR with no key_shares"); diff --git a/test/recipes/70-test_sslextension.t b/test/recipes/70-test_sslextension.t index e725b44f..93d7f47b 100644 --- a/test/recipes/70-test_sslextension.t +++ b/test/recipes/70-test_sslextension.t @@ -217,7 +217,10 @@ SKIP: { $proxy->clientflags("-no_tls1_3 -noservername"); $proxy->start(); ok($fatal_alert, "Unsolicited server name extension"); - +} +SKIP: { + skip "TLS <= 1.2 disabled or EC disabled", 1 + if $no_below_tls13 || disabled("ec"); #Test 5: Inject a noncompliant supported_groups extension (<= TLSv1.2) $proxy->clear(); $proxy->filter(\&inject_unsolicited_extension); diff --git a/test/recipes/70-test_tls13cookie.t b/test/recipes/70-test_tls13cookie.t index 3f324e3a..aef2cf88 100644 --- a/test/recipes/70-test_tls13cookie.t +++ b/test/recipes/70-test_tls13cookie.t @@ -46,17 +46,27 @@ my $testtype; #Test 1: Inserting a cookie into an HRR should see it echoed in the ClientHello $testtype = COOKIE_ONLY; $proxy->filter(\&cookie_filter); -$proxy->serverflags("-curves X25519"); +$proxy->serverflags("-curves X25519") if !disabled("ec"); $proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; plan tests => 2; -ok(TLSProxy::Message->success() && $cookieseen == 1, "Cookie seen"); +SKIP: { + skip "EC disabled", 1, if disabled("ec"); + ok(TLSProxy::Message->success() && $cookieseen == 1, "Cookie seen"); +} + + #Test 2: Same as test 1 but should also work where a new key_share is also # required $testtype = COOKIE_AND_KEY_SHARE; $proxy->clear(); -$proxy->clientflags("-curves P-256:X25519"); -$proxy->serverflags("-curves X25519"); +if (disabled("ec")) { + $proxy->clientflags("-curves ffdhe3072:ffdhe2048"); + $proxy->serverflags("-curves ffdhe2048"); +} else { + $proxy->clientflags("-curves P-256:X25519"); + $proxy->serverflags("-curves X25519"); +} $proxy->start(); ok(TLSProxy::Message->success() && $cookieseen == 1, "Cookie seen"); diff --git a/test/recipes/70-test_tls13hrr.t b/test/recipes/70-test_tls13hrr.t index 44ca0413..8f6e54e2 100644 --- a/test/recipes/70-test_tls13hrr.t +++ b/test/recipes/70-test_tls13hrr.t @@ -43,7 +43,11 @@ use constant { #Test 1: A client should fail if the server changes the ciphersuite between the # HRR and the SH $proxy->filter(\&hrr_filter); -$proxy->serverflags("-curves P-256"); +if (disabled("ec")) { + $proxy->serverflags("-curves ffdhe3072"); +} else { + $proxy->serverflags("-curves P-256"); +} my $testtype = CHANGE_HRR_CIPHERSUITE; $proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; plan tests => 2; @@ -52,7 +56,11 @@ ok(TLSProxy::Message->fail(), "Server ciphersuite changes"); #Test 2: It is an error if the client changes the offered ciphersuites so that # we end up selecting a different ciphersuite between HRR and the SH $proxy->clear(); -$proxy->serverflags("-curves P-256"); +if (disabled("ec")) { + $proxy->serverflags("-curves ffdhe3072"); +} else { + $proxy->serverflags("-curves P-256"); +} $proxy->ciphersuitess("TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384"); $testtype = CHANGE_CH1_CIPHERSUITE; $proxy->start(); diff --git a/test/recipes/70-test_tls13kexmodes.t b/test/recipes/70-test_tls13kexmodes.t index 36506011..069d6149 100644 --- a/test/recipes/70-test_tls13kexmodes.t +++ b/test/recipes/70-test_tls13kexmodes.t @@ -28,6 +28,9 @@ plan skip_all => "$test_name needs the sock feature enabled" plan skip_all => "$test_name needs TLSv1.3 enabled" if disabled("tls1_3"); +plan skip_all => "$test_name needs EC enabled" + if disabled("ec"); + $ENV{OPENSSL_ia32cap} = '~0x200000200000000'; $ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.conf"); diff --git a/test/recipes/70-test_tls13messages.t b/test/recipes/70-test_tls13messages.t index e961528c..a3fc35e4 100644 --- a/test/recipes/70-test_tls13messages.t +++ b/test/recipes/70-test_tls13messages.t @@ -28,6 +28,9 @@ plan skip_all => "$test_name needs the sock feature enabled" plan skip_all => "$test_name needs TLSv1.3 enabled" if disabled("tls1_3"); +plan skip_all => "$test_name needs EC enabled" + if disabled("ec"); + $ENV{OPENSSL_ia32cap} = '~0x200000200000000'; $ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.conf"); diff --git a/test/recipes/70-test_tls13psk.t b/test/recipes/70-test_tls13psk.t index 40e6ed10..11031f3f 100644 --- a/test/recipes/70-test_tls13psk.t +++ b/test/recipes/70-test_tls13psk.t @@ -66,7 +66,11 @@ ok(TLSProxy::Message->fail(), "PSK not last"); # ciphersuite. Should see PSK on second ClientHello $proxy->clear(); $proxy->clientflags("-sess_in ".$session); -$proxy->serverflags("-curves P-256"); +if (disabled("ec")) { + $proxy->serverflags("-curves ffdhe3072"); +} else { + $proxy->serverflags("-curves P-256"); +} $proxy->filter(undef); $proxy->start(); #Check if the PSK is present in the second ClientHello @@ -81,7 +85,11 @@ ok($pskseen, "PSK hash matches"); $proxy->clear(); $proxy->clientflags("-sess_in ".$session); $proxy->filter(\&modify_psk_filter); -$proxy->serverflags("-curves P-256"); +if (disabled("ec")) { + $proxy->serverflags("-curves ffdhe3072"); +} else { + $proxy->serverflags("-curves P-256"); +} $proxy->ciphersuitesc("TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384"); $proxy->ciphersuitess("TLS_AES_256_GCM_SHA384"); #We force an early failure because TLS Proxy doesn't actually support diff --git a/test/recipes/70-test_verify_extra.t b/test/recipes/70-test_verify_extra.t index 31e967b2..b8f4ab43 100644 --- a/test/recipes/70-test_verify_extra.t +++ b/test/recipes/70-test_verify_extra.t @@ -16,4 +16,5 @@ plan tests => 1; ok(run(test(["verify_extra_test", srctop_file("test", "certs", "roots.pem"), srctop_file("test", "certs", "untrusted.pem"), - srctop_file("test", "certs", "bad.pem")]))); + srctop_file("test", "certs", "bad.pem"), + srctop_file("test", "certs", "sm2-csr.pem")]))); diff --git a/test/recipes/80-test_ca.t b/test/recipes/80-test_ca.t index e3979650..483b1f5e 100644 --- a/test/recipes/80-test_ca.t +++ b/test/recipes/80-test_ca.t @@ -23,7 +23,7 @@ my $std_openssl_cnf = rmtree("demoCA", { safe => 0 }); -plan tests => 5; +plan tests => 6; SKIP: { $ENV{OPENSSL_CONFIG} = '-config "'.srctop_file("test", "CAss.cnf").'"'; skip "failed creating CA structure", 4 @@ -51,9 +51,25 @@ plan tests => 5; 'creating new pre-certificate'); } +SKIP: { + skip "SM2 is not supported by this OpenSSL build", 1 + if disabled("sm2"); + + is(yes(cmdstr(app(["openssl", "ca", "-config", + srctop_file("test", "CAss.cnf"), + "-in", srctop_file("test", "certs", "sm2-csr.pem"), + "-out", "sm2-test.crt", + "-sigopt", "sm2_id:1234567812345678", + "-sm2-id", "1234567812345678", + "-md", "sm3", + "-cert", srctop_file("test", "certs", "sm2-root.crt"), + "-keyfile", srctop_file("test", "certs", "sm2-root.key")]))), + 0, + "Signing SM2 certificate request"); +} rmtree("demoCA", { safe => 0 }); -unlink "newcert.pem", "newreq.pem", "newkey.pem"; +unlink "newcert.pem", "newreq.pem", "newkey.pem", "sm2-test.crt"; sub yes { diff --git a/test/recipes/80-test_cms.t b/test/recipes/80-test_cms.t index 1e28058c..868affc5 100644 --- a/test/recipes/80-test_cms.t +++ b/test/recipes/80-test_cms.t @@ -21,12 +21,13 @@ setup("test_cms"); plan skip_all => "CMS is not supported by this OpenSSL build" if disabled("cms"); +my $datadir = srctop_dir("test", "recipes", "80-test_cms_data"); my $smdir = srctop_dir("test", "smime-certs"); my $smcont = srctop_file("test", "smcont.txt"); my ($no_des, $no_dh, $no_dsa, $no_ec, $no_ec2m, $no_rc2, $no_zlib) = disabled qw/des dh dsa ec ec2m rc2 zlib/; -plan tests => 4; +plan tests => 6; my @smime_pkcs7_tests = ( @@ -416,6 +417,26 @@ my @smime_cms_param_tests = ( ] ); +my @contenttype_cms_test = ( + [ "signed content test - check that content type is added to additional signerinfo, RSA keys", + [ "-sign", "-binary", "-nodetach", "-stream", "-in", $smcont, "-outform", "DER", + "-signer", catfile($smdir, "smrsa1.pem"), "-md", "SHA256", + "-out", "test.cms" ], + [ "-resign", "-binary", "-nodetach", "-in", "test.cms", "-inform", "DER", "-outform", "DER", + "-signer", catfile($smdir, "smrsa2.pem"), "-md", "SHA256", + "-out", "test2.cms" ], + [ "-verify", "-in", "test2.cms", "-inform", "DER", + "-CAfile", catfile($smdir, "smroot.pem"), "-out", "smtst.txt" ] + ], +); + +my @incorrect_attribute_cms_test = ( + "bad_signtime_attr.cms", + "no_ct_attr.cms", + "no_md_attr.cms", + "ct_multiple_attr.cms" +); + subtest "CMS => PKCS#7 compatibility tests\n" => sub { plan tests => scalar @smime_pkcs7_tests; @@ -509,6 +530,52 @@ subtest "CMS <=> CMS consistency tests, modified key parameters\n" => sub { } }; +# Returns the number of matches of a Content Type Attribute in a binary file. +sub contentType_matches { + # Read in a binary file + my ($in) = @_; + open (HEX_IN, "$in") or die("open failed for $in : $!"); + binmode(HEX_IN); + local $/; + my $str = ; + + # Find ASN1 data for a Content Type Attribute (with a OID of PKCS7 data) + my @c = $str =~ /\x30\x18\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x09\x03\x31\x0B\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x07\x01/gs; + + close(HEX_IN); + return scalar(@c); +} + +subtest "CMS Check the content type attribute is added for additional signers\n" => sub { + plan tests => + (scalar @contenttype_cms_test); + + foreach (@contenttype_cms_test) { + SKIP: { + my $skip_reason = check_availability($$_[0]); + skip $skip_reason, 1 if $skip_reason; + + ok(run(app(["openssl", "cms", @{$$_[1]}])) + && run(app(["openssl", "cms", @{$$_[2]}])) + && contentType_matches("test2.cms") == 2 + && run(app(["openssl", "cms", @{$$_[3]}])), + $$_[0]); + } + } +}; + +subtest "CMS Check that bad attributes fail when verifying signers\n" => sub { + plan tests => + (scalar @incorrect_attribute_cms_test); + + foreach my $name (@incorrect_attribute_cms_test) { + ok(!run(app(["openssl", "cms", "-verify", "-in", + catfile($datadir, $name), "-inform", "DER", "-CAfile", + catfile($smdir, "smroot.pem"), "-out", "smtst.txt" ])), + $name); + } +}; + unlink "test.cms"; unlink "test2.cms"; unlink "smtst.txt"; diff --git a/test/recipes/80-test_cms_data/bad_signtime_attr.cms b/test/recipes/80-test_cms_data/bad_signtime_attr.cms new file mode 100644 index 00000000..048a4935 Binary files /dev/null and b/test/recipes/80-test_cms_data/bad_signtime_attr.cms differ diff --git a/test/recipes/80-test_cms_data/ct_multiple_attr.cms b/test/recipes/80-test_cms_data/ct_multiple_attr.cms new file mode 100644 index 00000000..974db6ef Binary files /dev/null and b/test/recipes/80-test_cms_data/ct_multiple_attr.cms differ diff --git a/test/recipes/80-test_cms_data/no_ct_attr.cms b/test/recipes/80-test_cms_data/no_ct_attr.cms new file mode 100644 index 00000000..64b688b9 Binary files /dev/null and b/test/recipes/80-test_cms_data/no_ct_attr.cms differ diff --git a/test/recipes/80-test_cms_data/no_md_attr.cms b/test/recipes/80-test_cms_data/no_md_attr.cms new file mode 100644 index 00000000..d0a3afa5 Binary files /dev/null and b/test/recipes/80-test_cms_data/no_md_attr.cms differ diff --git a/test/recipes/80-test_ssl_new.t b/test/recipes/80-test_ssl_new.t index 31c4399d..04a0c133 100644 --- a/test/recipes/80-test_ssl_new.t +++ b/test/recipes/80-test_ssl_new.t @@ -59,7 +59,7 @@ my %conf_dependent_tests = ( || !disabled("sctp"), "05-sni.conf" => disabled("tls1_1"), "07-dtls-protocol-version.conf" => !$is_default_dtls || !disabled("sctp"), - "10-resumption.conf" => !$is_default_tls, + "10-resumption.conf" => !$is_default_tls || $no_ec, "11-dtls_resumption.conf" => !$is_default_dtls || !disabled("sctp"), "16-dtls-certstatus.conf" => !$is_default_dtls || !disabled("sctp"), "17-renegotiate.conf" => disabled("tls1_2"), diff --git a/test/recipes/90-test_gost.t b/test/recipes/90-test_gost.t index d4f27b89..b01243fa 100644 --- a/test/recipes/90-test_gost.t +++ b/test/recipes/90-test_gost.t @@ -21,6 +21,10 @@ plan skip_all => "GOST support is disabled in this OpenSSL build" plan skip_all => "TLSv1.3 or TLSv1.2 are disabled in this OpenSSL build" if disabled("tls1_3") || disabled("tls1_2"); +plan skip_all => "EC is disabled in this OpenSSL build" + if disabled("ec"); + + plan skip_all => "No test GOST engine found" if !$ENV{OPENSSL_GOST_ENGINE_SO}; diff --git a/test/ssl-tests/protocol_version.pm b/test/ssl-tests/protocol_version.pm index 6c2e7789..6923e212 100644 --- a/test/ssl-tests/protocol_version.pm +++ b/test/ssl-tests/protocol_version.pm @@ -252,7 +252,7 @@ sub generate_resumption_tests { "client" => { }, "server" => { - "Curves" => "P-256" + "Curves" => disabled("ec") ? "ffdhe3072" : "P-256" }, "resume_client" => { }, diff --git a/test/sslapitest.c b/test/sslapitest.c index 3504eea6..bc1f006a 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -2960,8 +2960,13 @@ static int early_data_skip_helper(int testtype, int idx) if (testtype == 1 || testtype == 2) { /* Force an HRR to occur */ +#if defined(OPENSSL_NO_EC) + if (!TEST_true(SSL_set1_groups_list(serverssl, "ffdhe3072"))) + goto end; +#else if (!TEST_true(SSL_set1_groups_list(serverssl, "P-256"))) goto end; +#endif } else if (idx == 2) { /* * We force early_data rejection by ensuring the PSK identity is @@ -3735,6 +3740,122 @@ static int test_ciphersuite_change(void) return testresult; } +/* + * Test TLSv1.3 Key exchange + * Test 0 = Test ECDHE Key exchange + * Test 1 = Test ECDHE with TLSv1.2 client and TLSv1.2 server + * Test 2 = Test FFDHE Key exchange + * Test 3 = Test FFDHE with TLSv1.2 client and TLSv1.2 server + */ +static int test_tls13_key_exchange(int idx) +{ + SSL_CTX *sctx = NULL, *cctx = NULL; + SSL *serverssl = NULL, *clientssl = NULL; + int testresult = 0; +#ifndef OPENSSL_NO_EC + int ecdhe_kexch_groups[] = {NID_X9_62_prime256v1, NID_secp384r1, NID_secp521r1, + NID_X25519, NID_X448}; +#endif +#ifndef OPENSSL_NO_DH + int ffdhe_kexch_groups[] = {NID_ffdhe2048, NID_ffdhe3072, NID_ffdhe4096, + NID_ffdhe6144, NID_ffdhe8192}; +#endif + int *kexch_groups = NULL; + int kexch_groups_size = 0; + int max_version = TLS1_3_VERSION; + int want_err = SSL_ERROR_NONE; + int expected_err_func = 0; + int expected_err_reason = 0; + + switch (idx) { +#ifndef OPENSSL_NO_DH + case 3: + max_version = TLS1_2_VERSION; + /* Fall through */ + case 2: + kexch_groups = ffdhe_kexch_groups; + kexch_groups_size = OSSL_NELEM(ffdhe_kexch_groups); + break; +#endif +#ifndef OPENSSL_NO_EC + case 1: + max_version = TLS1_2_VERSION; + /* Fall through */ + case 0: + kexch_groups = ecdhe_kexch_groups; + kexch_groups_size = OSSL_NELEM(ecdhe_kexch_groups); + break; +#endif + default: + /* We're skipping this test */ + return 1; + } + + if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(), + TLS1_VERSION, max_version, + &sctx, &cctx, cert, privkey))) + goto end; + + if (!TEST_true(SSL_CTX_set_ciphersuites(sctx, TLS1_3_RFC_AES_128_GCM_SHA256))) + goto end; + + if (!TEST_true(SSL_CTX_set_ciphersuites(cctx, TLS1_3_RFC_AES_128_GCM_SHA256))) + goto end; + + if (!TEST_true(SSL_CTX_set_cipher_list(sctx, TLS1_TXT_RSA_WITH_AES_128_SHA))) + goto end; + + /* + * Must include an EC ciphersuite so that we send supported groups in + * TLSv1.2 + */ + if (!TEST_true(SSL_CTX_set_cipher_list(cctx, + TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM ":" + TLS1_TXT_RSA_WITH_AES_128_SHA))) + goto end; + + if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, + NULL, NULL))) + goto end; + + if (!TEST_true(SSL_set1_groups(serverssl, kexch_groups, kexch_groups_size)) + || !TEST_true(SSL_set1_groups(clientssl, kexch_groups, kexch_groups_size))) + goto end; + + if (!TEST_true(create_ssl_connection(serverssl, clientssl, want_err))) { + /* Fail only if no error is expected in handshake */ + if (expected_err_func == 0) + goto end; + } + + /* Fail if expected error is not happening for failure testcases */ + if (expected_err_func) { + unsigned long err_code = ERR_get_error(); + ERR_print_errors_fp(stdout); + if (TEST_int_eq(ERR_GET_FUNC(err_code), expected_err_func) + && TEST_int_eq(ERR_GET_REASON(err_code), expected_err_reason)) + testresult = 1; + goto end; + } + + /* + * If Handshake succeeds the negotiated kexch alg should the first one in + * configured, except in the case of FFDHE groups which are TLSv1.3 only + * so we expect no shared group to exist. + */ + if (!TEST_int_eq(SSL_get_shared_group(serverssl, 0), + idx == 3 ? 0 : kexch_groups[0])) + goto end; + + testresult = 1; + end: + SSL_free(serverssl); + SSL_free(clientssl); + SSL_CTX_free(sctx); + SSL_CTX_free(cctx); + return testresult; +} + /* * Test TLSv1.3 PSKs * Test 0 = Test new style callbacks @@ -3878,8 +3999,13 @@ static int test_tls13_psk(int idx) goto end; /* Force an HRR */ +#if defined(OPENSSL_NO_EC) + if (!TEST_true(SSL_set1_groups_list(serverssl, "ffdhe3072"))) + goto end; +#else if (!TEST_true(SSL_set1_groups_list(serverssl, "P-256"))) goto end; +#endif /* * Check we can create a connection, the PSK is used and the callbacks are @@ -4737,6 +4863,11 @@ static int test_key_update(void) || !TEST_int_eq(SSL_read(serverssl, buf, sizeof(buf)), strlen(mess))) goto end; + + if (!TEST_int_eq(SSL_write(serverssl, mess, strlen(mess)), strlen(mess)) + || !TEST_int_eq(SSL_read(clientssl, buf, sizeof(buf)), + strlen(mess))) + goto end; } testresult = 1; @@ -4749,6 +4880,91 @@ static int test_key_update(void) return testresult; } + +/* + * Test we can handle a KeyUpdate (update requested) message while write data + * is pending. + * Test 0: Client sends KeyUpdate while Server is writing + * Test 1: Server sends KeyUpdate while Client is writing + */ +static int test_key_update_in_write(int tst) +{ + SSL_CTX *cctx = NULL, *sctx = NULL; + SSL *clientssl = NULL, *serverssl = NULL; + int testresult = 0; + char buf[20]; + static char *mess = "A test message"; + BIO *bretry = BIO_new(bio_s_always_retry()); + BIO *tmp = NULL; + SSL *peerupdate = NULL, *peerwrite = NULL; + + if (!TEST_ptr(bretry) + || !TEST_true(create_ssl_ctx_pair(TLS_server_method(), + TLS_client_method(), + TLS1_3_VERSION, + 0, + &sctx, &cctx, cert, privkey)) + || !TEST_true(create_ssl_objects(sctx, cctx, &serverssl, &clientssl, + NULL, NULL)) + || !TEST_true(create_ssl_connection(serverssl, clientssl, + SSL_ERROR_NONE))) + goto end; + + peerupdate = tst == 0 ? clientssl : serverssl; + peerwrite = tst == 0 ? serverssl : clientssl; + + if (!TEST_true(SSL_key_update(peerupdate, SSL_KEY_UPDATE_REQUESTED)) + || !TEST_true(SSL_do_handshake(peerupdate))) + goto end; + + /* Swap the writing endpoint's write BIO to force a retry */ + tmp = SSL_get_wbio(peerwrite); + if (!TEST_ptr(tmp) || !TEST_true(BIO_up_ref(tmp))) { + tmp = NULL; + goto end; + } + SSL_set0_wbio(peerwrite, bretry); + bretry = NULL; + + /* Write data that we know will fail with SSL_ERROR_WANT_WRITE */ + if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), -1) + || !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_WRITE)) + goto end; + + /* Reinstate the original writing endpoint's write BIO */ + SSL_set0_wbio(peerwrite, tmp); + tmp = NULL; + + /* Now read some data - we will read the key update */ + if (!TEST_int_eq(SSL_read(peerwrite, buf, sizeof(buf)), -1) + || !TEST_int_eq(SSL_get_error(peerwrite, 0), SSL_ERROR_WANT_READ)) + goto end; + + /* + * Complete the write we started previously and read it from the other + * endpoint + */ + if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), strlen(mess)) + || !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), strlen(mess))) + goto end; + + /* Write more data to ensure we send the KeyUpdate message back */ + if (!TEST_int_eq(SSL_write(peerwrite, mess, strlen(mess)), strlen(mess)) + || !TEST_int_eq(SSL_read(peerupdate, buf, sizeof(buf)), strlen(mess))) + goto end; + + testresult = 1; + + end: + SSL_free(serverssl); + SSL_free(clientssl); + SSL_CTX_free(sctx); + SSL_CTX_free(cctx); + BIO_free(bretry); + BIO_free(tmp); + + return testresult; +} #endif /* OPENSSL_NO_TLS1_3 */ static int test_ssl_clear(int idx) @@ -6023,6 +6239,9 @@ static int cert_cb_cnt; static int cert_cb(SSL *s, void *arg) { SSL_CTX *ctx = (SSL_CTX *)arg; + BIO *in = NULL; + EVP_PKEY *pkey = NULL; + X509 *x509 = NULL; if (cert_cb_cnt == 0) { /* Suspend the handshake */ @@ -6043,9 +6262,39 @@ static int cert_cb(SSL *s, void *arg) return 0; cert_cb_cnt++; return 1; + } else if (cert_cb_cnt == 3) { + int rv; + if (!TEST_ptr(in = BIO_new(BIO_s_file())) + || !TEST_int_ge(BIO_read_filename(in, cert), 0) + || !TEST_ptr(x509 = PEM_read_bio_X509(in, NULL, NULL, NULL))) + goto out; + BIO_free(in); + if (!TEST_ptr(in = BIO_new(BIO_s_file())) + || !TEST_int_ge(BIO_read_filename(in, privkey), 0) + || !TEST_ptr(pkey = PEM_read_bio_PrivateKey(in, NULL, NULL, NULL))) + goto out; + rv = SSL_check_chain(s, x509, pkey, NULL); + /* + * If the cert doesn't show as valid here (e.g., because we don't + * have any shared sigalgs), then we will not set it, and there will + * be no certificate at all on the SSL or SSL_CTX. This, in turn, + * will cause tls_choose_sigalgs() to fail the connection. + */ + if ((rv & CERT_PKEY_VALID)) { + if (!SSL_use_cert_and_key(s, x509, pkey, NULL, 1)) + goto out; + } + BIO_free(in); + EVP_PKEY_free(pkey); + X509_free(x509); + return 1; } /* Abort the handshake */ + out: + BIO_free(in); + EVP_PKEY_free(pkey); + X509_free(x509); return 0; } @@ -6070,6 +6319,8 @@ static int test_cert_cb_int(int prot, int tst) if (tst == 0) cert_cb_cnt = -1; + else if (tst == 3) + cert_cb_cnt = 3; else cert_cb_cnt = 0; if (tst == 2) @@ -6082,7 +6333,8 @@ static int test_cert_cb_int(int prot, int tst) ret = create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE); if (!TEST_true(tst == 0 ? !ret : ret) - || (tst > 0 && !TEST_int_eq(cert_cb_cnt, 2))) { + || (tst > 0 + && !TEST_int_eq((cert_cb_cnt - 2) * (cert_cb_cnt - 3), 0))) { goto end; } @@ -6446,6 +6698,7 @@ int setup_tests(void) #else ADD_ALL_TESTS(test_tls13_psk, 4); #endif /* OPENSSL_NO_PSK */ + ADD_ALL_TESTS(test_tls13_key_exchange, 4); ADD_ALL_TESTS(test_custom_exts, 5); ADD_TEST(test_stateless); ADD_TEST(test_pha_key_update); @@ -6457,6 +6710,7 @@ int setup_tests(void) #ifndef OPENSSL_NO_TLS1_3 ADD_ALL_TESTS(test_export_key_mat_early, 3); ADD_TEST(test_key_update); + ADD_ALL_TESTS(test_key_update_in_write, 2); #endif ADD_ALL_TESTS(test_ssl_clear, 2); ADD_ALL_TESTS(test_max_fragment_len_ext, OSSL_NELEM(max_fragment_len_test)); @@ -6468,7 +6722,7 @@ int setup_tests(void) ADD_ALL_TESTS(test_ssl_get_shared_ciphers, OSSL_NELEM(shared_ciphers_data)); ADD_ALL_TESTS(test_ticket_callbacks, 12); ADD_ALL_TESTS(test_shutdown, 7); - ADD_ALL_TESTS(test_cert_cb, 3); + ADD_ALL_TESTS(test_cert_cb, 4); ADD_ALL_TESTS(test_client_cert_cb, 2); ADD_ALL_TESTS(test_ca_names, 3); return 1; @@ -6477,4 +6731,5 @@ int setup_tests(void) void cleanup_tests(void) { bio_s_mempacket_test_free(); + bio_s_always_retry_free(); } diff --git a/test/ssltest_old.c b/test/ssltest_old.c index 390ca88b..971015c6 100644 --- a/test/ssltest_old.c +++ b/test/ssltest_old.c @@ -71,7 +71,7 @@ #ifdef OPENSSL_SYS_WINDOWS # include #else -# include OPENSSL_UNISTD +# include #endif static SSL_CTX *s_ctx = NULL; diff --git a/test/ssltestlib.c b/test/ssltestlib.c index 8d7ab610..67d8cd02 100644 --- a/test/ssltestlib.c +++ b/test/ssltestlib.c @@ -70,9 +70,11 @@ static int tls_dump_puts(BIO *bp, const char *str); /* Choose a sufficiently large type likely to be unused for this custom BIO */ #define BIO_TYPE_TLS_DUMP_FILTER (0x80 | BIO_TYPE_FILTER) #define BIO_TYPE_MEMPACKET_TEST 0x81 +#define BIO_TYPE_ALWAYS_RETRY 0x82 static BIO_METHOD *method_tls_dump = NULL; static BIO_METHOD *meth_mem = NULL; +static BIO_METHOD *meth_always_retry = NULL; /* Note: Not thread safe! */ const BIO_METHOD *bio_f_tls_dump_filter(void) @@ -620,6 +622,100 @@ static int mempacket_test_puts(BIO *bio, const char *str) return mempacket_test_write(bio, str, strlen(str)); } +static int always_retry_new(BIO *bi); +static int always_retry_free(BIO *a); +static int always_retry_read(BIO *b, char *out, int outl); +static int always_retry_write(BIO *b, const char *in, int inl); +static long always_retry_ctrl(BIO *b, int cmd, long num, void *ptr); +static int always_retry_gets(BIO *bp, char *buf, int size); +static int always_retry_puts(BIO *bp, const char *str); + +const BIO_METHOD *bio_s_always_retry(void) +{ + if (meth_always_retry == NULL) { + if (!TEST_ptr(meth_always_retry = BIO_meth_new(BIO_TYPE_ALWAYS_RETRY, + "Always Retry")) + || !TEST_true(BIO_meth_set_write(meth_always_retry, + always_retry_write)) + || !TEST_true(BIO_meth_set_read(meth_always_retry, + always_retry_read)) + || !TEST_true(BIO_meth_set_puts(meth_always_retry, + always_retry_puts)) + || !TEST_true(BIO_meth_set_gets(meth_always_retry, + always_retry_gets)) + || !TEST_true(BIO_meth_set_ctrl(meth_always_retry, + always_retry_ctrl)) + || !TEST_true(BIO_meth_set_create(meth_always_retry, + always_retry_new)) + || !TEST_true(BIO_meth_set_destroy(meth_always_retry, + always_retry_free))) + return NULL; + } + return meth_always_retry; +} + +void bio_s_always_retry_free(void) +{ + BIO_meth_free(meth_always_retry); +} + +static int always_retry_new(BIO *bio) +{ + BIO_set_init(bio, 1); + return 1; +} + +static int always_retry_free(BIO *bio) +{ + BIO_set_data(bio, NULL); + BIO_set_init(bio, 0); + return 1; +} + +static int always_retry_read(BIO *bio, char *out, int outl) +{ + BIO_set_retry_read(bio); + return -1; +} + +static int always_retry_write(BIO *bio, const char *in, int inl) +{ + BIO_set_retry_write(bio); + return -1; +} + +static long always_retry_ctrl(BIO *bio, int cmd, long num, void *ptr) +{ + long ret = 1; + + switch (cmd) { + case BIO_CTRL_FLUSH: + BIO_set_retry_write(bio); + /* fall through */ + case BIO_CTRL_EOF: + case BIO_CTRL_RESET: + case BIO_CTRL_DUP: + case BIO_CTRL_PUSH: + case BIO_CTRL_POP: + default: + ret = 0; + break; + } + return ret; +} + +static int always_retry_gets(BIO *bio, char *buf, int size) +{ + BIO_set_retry_read(bio); + return -1; +} + +static int always_retry_puts(BIO *bio, const char *str) +{ + BIO_set_retry_write(bio); + return -1; +} + int create_ssl_ctx_pair(const SSL_METHOD *sm, const SSL_METHOD *cm, int min_proto_version, int max_proto_version, SSL_CTX **sctx, SSL_CTX **cctx, char *certfile, @@ -940,7 +1036,7 @@ int create_ssl_connection(SSL *serverssl, SSL *clientssl, int want) /* * We attempt to read some data on the client side which we expect to fail. * This will ensure we have received the NewSessionTicket in TLSv1.3 where - * appropriate. We do this twice because there are 2 NewSesionTickets. + * appropriate. We do this twice because there are 2 NewSessionTickets. */ for (i = 0; i < 2; i++) { if (SSL_read_ex(clientssl, &buf, sizeof(buf), &readbytes) > 0) { diff --git a/test/ssltestlib.h b/test/ssltestlib.h index 6573e385..32d3bfb3 100644 --- a/test/ssltestlib.h +++ b/test/ssltestlib.h @@ -33,6 +33,9 @@ void bio_f_tls_dump_filter_free(void); const BIO_METHOD *bio_s_mempacket_test(void); void bio_s_mempacket_test_free(void); +const BIO_METHOD *bio_s_always_retry(void); +void bio_s_always_retry_free(void); + /* Packet types - value 0 is reserved */ #define INJECT_PACKET 1 #define INJECT_PACKET_IGNORE_REC_SEQ 2 diff --git a/test/testutil/driver.c b/test/testutil/driver.c index 2da83ed7..7a1a5893 100644 --- a/test/testutil/driver.c +++ b/test/testutil/driver.c @@ -353,6 +353,8 @@ int run_tests(const char *test_prog_name) verdict = all_tests[i].test_fn(); test_verdict(verdict, "%d - %s", ii + 1, test_title); finalize(verdict != 0); + if (verdict == 0) + num_failed++; } else { int num_failed_inner = 0; diff --git a/test/testutil/init.c b/test/testutil/init.c index 44159024..7c6041ae 100644 --- a/test/testutil/init.c +++ b/test/testutil/init.c @@ -1,5 +1,5 @@ /* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,9 +7,137 @@ * https://www.openssl.org/source/license.html */ +#include +#include +#include +#include "apps.h" #include "../testutil.h" +#ifndef OPENSSL_NO_TRACE +typedef struct tracedata_st { + BIO *bio; + unsigned int ingroup:1; +} tracedata; + +static size_t internal_trace_cb(const char *buf, size_t cnt, + int category, int cmd, void *vdata) +{ + int ret = 0; + tracedata *trace_data = vdata; + char buffer[256], *hex; + CRYPTO_THREAD_ID tid; + + switch (cmd) { + case OSSL_TRACE_CTRL_BEGIN: + trace_data->ingroup = 1; + + tid = CRYPTO_THREAD_get_current_id(); + hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid)); + BIO_snprintf(buffer, sizeof(buffer), "TRACE[%s]:%s: ", + hex, OSSL_trace_get_category_name(category)); + OPENSSL_free(hex); + BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX, + strlen(buffer), buffer); + break; + case OSSL_TRACE_CTRL_WRITE: + ret = BIO_write(trace_data->bio, buf, cnt); + break; + case OSSL_TRACE_CTRL_END: + trace_data->ingroup = 0; + + BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX, 0, NULL); + break; + } + + return ret < 0 ? 0 : ret; +} + +DEFINE_STACK_OF(tracedata) +static STACK_OF(tracedata) *trace_data_stack; + +static void tracedata_free(tracedata *data) +{ + BIO_free_all(data->bio); + OPENSSL_free(data); +} + +static STACK_OF(tracedata) *trace_data_stack; + +static void cleanup_trace(void) +{ + sk_tracedata_pop_free(trace_data_stack, tracedata_free); +} + +static void setup_trace_category(int category) +{ + BIO *channel; + tracedata *trace_data; + + if (OSSL_trace_enabled(category)) + return; + + channel = BIO_push(BIO_new(apps_bf_prefix()), + BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT)); + trace_data = OPENSSL_zalloc(sizeof(*trace_data)); + + if (trace_data == NULL + || (trace_data->bio = channel) == NULL + || OSSL_trace_set_callback(category, internal_trace_cb, + trace_data) == 0 + || sk_tracedata_push(trace_data_stack, trace_data) == 0) { + + fprintf(stderr, + "warning: unable to setup trace callback for category '%s'.\n", + OSSL_trace_get_category_name(category)); + + OSSL_trace_set_callback(category, NULL, NULL); + BIO_free_all(channel); + } +} + +static void setup_trace(const char *str) +{ + char *val; + + /* + * We add this handler as early as possible to ensure it's executed + * as late as possible, i.e. after the TRACE code has done its cleanup + * (which happens last in OPENSSL_cleanup). + */ + atexit(cleanup_trace); + + trace_data_stack = sk_tracedata_new_null(); + val = OPENSSL_strdup(str); + + if (val != NULL) { + char *valp = val; + char *item; + + for (valp = val; (item = strtok(valp, ",")) != NULL; valp = NULL) { + int category = OSSL_trace_get_category_num(item); + + if (category == OSSL_TRACE_CATEGORY_ALL) { + while (++category < OSSL_TRACE_CATEGORY_NUM) + setup_trace_category(category); + break; + } else if (category > 0) { + setup_trace_category(category); + } else { + fprintf(stderr, + "warning: unknown trace category: '%s'.\n", item); + } + } + } + + OPENSSL_free(val); +} +#endif /* OPENSSL_NO_TRACE */ + int global_init(void) { +#ifndef OPENSSL_NO_TRACE + setup_trace(getenv("OPENSSL_TRACE")); +#endif + return 1; } diff --git a/test/tls13ccstest.c b/test/tls13ccstest.c index d89354c1..1d0a2686 100644 --- a/test/tls13ccstest.c +++ b/test/tls13ccstest.c @@ -315,8 +315,15 @@ static int test_tls13ccs(int tst) if ((tst >= 3 && tst <= 5) || tst >= 9) { /* HRR handshake */ +#if defined(OPENSSL_NO_EC) +# if !defined(OPENSSL_NO_DH) + if (!TEST_true(SSL_CTX_set1_groups_list(sctx, "ffdhe3072"))) + goto err; +# endif +#else if (!TEST_true(SSL_CTX_set1_groups_list(sctx, "P-256"))) goto err; +#endif } s_to_c_fbio = BIO_new(bio_f_watchccs_filter()); diff --git a/test/tls13secretstest.c b/test/tls13secretstest.c index 490e7c9d..4756faac 100644 --- a/test/tls13secretstest.c +++ b/test/tls13secretstest.c @@ -17,7 +17,7 @@ #define KEYLEN 16 /* - * Based on the test vectors availble in: + * Based on the test vectors available in: * https://tools.ietf.org/html/draft-ietf-tls-tls13-vectors-06 */ diff --git a/test/verify_extra_test.c b/test/verify_extra_test.c index f16b3f0b..d1da7303 100644 --- a/test/verify_extra_test.c +++ b/test/verify_extra_test.c @@ -19,6 +19,7 @@ static const char *roots_f; static const char *untrusted_f; static const char *bad_f; +static const char *req_f; static STACK_OF(X509) *load_certs_from_file(const char *filename) { @@ -218,19 +219,61 @@ static int test_sm2_id(void) BIO_free(bio); return ret; } + +static int test_req_sm2_id(void) +{ + /* we only need an X509_REQ structure, no matter if it's a real SM2 cert */ + X509_REQ *x = NULL; + BIO *bio = NULL; + int ret = 0; + ASN1_OCTET_STRING *v = NULL, *v2 = NULL; + char *sm2id = "this is an ID"; + + bio = BIO_new_file(req_f, "r"); + if (bio == NULL) + goto err; + + x = PEM_read_bio_X509_REQ(bio, NULL, 0, NULL); + if (x == NULL) + goto err; + + v = ASN1_OCTET_STRING_new(); + if (v == NULL) + goto err; + + if (!ASN1_OCTET_STRING_set(v, (unsigned char *)sm2id, (int)strlen(sm2id))) { + ASN1_OCTET_STRING_free(v); + goto err; + } + + X509_REQ_set0_sm2_id(x, v); + + v2 = X509_REQ_get0_sm2_id(x); + if (!TEST_ptr(v2) + || !TEST_int_eq(ASN1_OCTET_STRING_cmp(v, v2), 0)) + goto err; + + ret = 1; + err: + X509_REQ_free(x); + BIO_free(bio); + return ret; +} #endif int setup_tests(void) { if (!TEST_ptr(roots_f = test_get_argument(0)) || !TEST_ptr(untrusted_f = test_get_argument(1)) - || !TEST_ptr(bad_f = test_get_argument(2))) + || !TEST_ptr(bad_f = test_get_argument(2)) + || !TEST_ptr(req_f = test_get_argument(3))) return 0; ADD_TEST(test_alt_chains_cert_forgery); ADD_TEST(test_store_ctx); #ifndef OPENSSL_NO_SM2 ADD_TEST(test_sm2_id); + ADD_TEST(test_req_sm2_id); #endif return 1; } diff --git a/test/x509_check_cert_pkey_test.c b/test/x509_check_cert_pkey_test.c index 434054f8..6c1587b8 100644 --- a/test/x509_check_cert_pkey_test.c +++ b/test/x509_check_cert_pkey_test.c @@ -110,10 +110,11 @@ const OPTIONS *test_get_options(void) { enum { OPT_TEST_ENUM }; static const OPTIONS test_options[] = { - OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("certname key.pem type expected\n"), - { OPT_HELP_STR, 1, '-', "certname\tCertificate filename .pem/.req\n" }, - { OPT_HELP_STR, 1, '-', "type\t\tvalue must be 'pem' or 'req'\n" }, - { OPT_HELP_STR, 1, '-', "expected\tthe expected return value\n" }, + OPT_TEST_OPTIONS_WITH_EXTRA_USAGE("cert key type expected\n"), + { OPT_HELP_STR, 1, '-', "cert\tcertificate or CSR filename in PEM\n" }, + { OPT_HELP_STR, 1, '-', "key\tprivate key filename in PEM\n" }, + { OPT_HELP_STR, 1, '-', "type\t\tvalue must be 'cert' or 'req'\n" }, + { OPT_HELP_STR, 1, '-', "expected\tthe expected return value, either 'ok' or 'failed'\n" }, { NULL } }; return test_options; diff --git a/test/x509_internal_test.c b/test/x509_internal_test.c index d6b4f4f4..a17dfd93 100644 --- a/test/x509_internal_test.c +++ b/test/x509_internal_test.c @@ -23,8 +23,8 @@ * ***/ -#include "../crypto/x509v3/ext_dat.h" -#include "../crypto/x509v3/standard_exts.h" +#include "../crypto/x509/ext_dat.h" +#include "../crypto/x509/standard_exts.h" static int test_standard_exts(void) { diff --git a/util/find-doc-nits b/util/find-doc-nits index 25f3d5e2..ecd9f9af 100755 --- a/util/find-doc-nits +++ b/util/find-doc-nits @@ -20,11 +20,15 @@ use OpenSSL::Util::Pod; # Options. our($opt_d); +our($opt_e); +our($opt_s); +our($opt_o); our($opt_h); our($opt_l); our($opt_n); our($opt_p); our($opt_u); +our($opt_v); our($opt_c); sub help() @@ -32,10 +36,14 @@ sub help() print < ) { next if /^#/; next if /\bNOEXIST\b/; - next if /\bEXPORT_VAR_AS_FUNC\b/; my @fields = split(); die "Malformed line $_" if scalar @fields != 2 && scalar @fields != 4; @@ -291,12 +298,36 @@ sub getdocced my %docced; +sub loadmissing($) +{ + my $missingfile = shift; + my @missing; + + open FH, $missingfile + || die "Can't open $missingfile"; + while ( ) { + chomp; + next if /^#/; + push @missing, $_; + } + close FH; + + return @missing; +} + sub checkmacros() { my $count = 0; my %seen; + my @missing; - print "# Checking macros (approximate)\n"; + if ($opt_o) { + @missing = loadmissing('util/missingmacro111.txt'); + } elsif ($opt_v) { + @missing = loadmissing('util/missingmacro.txt'); + } + + print "# Checking macros (approximate)\n" if !$opt_s; foreach my $f ( glob('include/openssl/*.h') ) { # Skip some internals we don't want to document yet. next if $f eq 'include/openssl/asn1.h'; @@ -312,33 +343,43 @@ sub checkmacros() || $macro =~ /DEPRECATEDIN/ || $macro =~ /IMPLEMENT_/ || $macro =~ /DECLARE_/; - print "$f:$macro\n" if $opt_d; + + # Skip macros known to be missing + next if $opt_v && grep( /^$macro$/, @missing); + + print "$f:$macro\n" if $opt_d || $opt_e; $count++; $seen{$macro} = 1; } close(IN); } - print "# Found $count macros missing (not all should be documented)\n" + print "# Found $count macros missing\n" if !$opt_s || $count > 0; } sub printem() { my $libname = shift; my $numfile = shift; + my $missingfile = shift; my $count = 0; my %seen; + my @missing = loadmissing($missingfile) if ($opt_v); + foreach my $func ( &parsenum($numfile) ) { next if $docced{$func} || defined $seen{$func}; # Skip ASN1 utilities next if $func =~ /^ASN1_/; - print "$libname:$func\n" if $opt_d; + # Skip functions known to be missing + next if $opt_v && grep( /^$func$/, @missing); + + print "$libname:$func\n" if $opt_d || $opt_e; $count++; $seen{$func} = 1; } - print "# Found $count missing from $numfile\n\n"; + print "# Found $count missing from $numfile\n\n" if !$opt_s || $count > 0; } @@ -503,14 +544,22 @@ sub checkflags() { return $ok; } -getopts('cdlnphu'); +getopts('cdesolnphuv'); &help() if $opt_h; + $opt_n = 1 if $opt_p; $opt_u = 1 if $opt_d; +$opt_e = 1 if $opt_s; +$opt_v = 1 if $opt_o || $opt_e; -die "Need one of -[cdlnpu] flags.\n" - unless $opt_c or $opt_l or $opt_n or $opt_u; +die "Cannot use both -u and -v" if $opt_u && $opt_v; +die "Cannot use both -d and -e" if $opt_d && $opt_e; + +# We only need to check c, l, n, u and v. +# Options d, e, s, o and p imply one of the above. +die "Need one of -[cdesolnpuv] flags.\n" + unless $opt_c or $opt_l or $opt_n or $opt_u or $opt_v; if ( $opt_c ) { my $ok = 1; @@ -571,13 +620,18 @@ if ( $opt_n ) { } } -if ( $opt_u ) { +if ( $opt_u || $opt_v) { my %temp = getdocced('doc/man3'); foreach ( keys %temp ) { $docced{$_} = $temp{$_}; } - &printem('crypto', 'util/libcrypto.num'); - &printem('ssl', 'util/libssl.num'); + if ($opt_o) { + &printem('crypto', 'util/libcrypto.num', 'util/missingcrypto111.txt'); + &printem('ssl', 'util/libssl.num', 'util/missingssl111.txt'); + } else { + &printem('crypto', 'util/libcrypto.num', 'util/missingcrypto.txt'); + &printem('ssl', 'util/libssl.num', 'util/missingssl.txt'); + } &checkmacros(); } diff --git a/util/libcrypto.num b/util/libcrypto.num index 9643ffc1..32a3520a 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -13,8 +13,7 @@ X509_NAME_get0_der 12 3_0_0 EXIST::FUNCTION: i2d_ESS_ISSUER_SERIAL 13 3_0_0 EXIST::FUNCTION: X509at_get_attr_by_NID 14 3_0_0 EXIST::FUNCTION: X509_PUBKEY_set0_param 15 3_0_0 EXIST::FUNCTION: -PKCS12_it 16 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS12_it 16 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS12_it 16 3_0_0 EXIST::FUNCTION: i2d_ASN1_OCTET_STRING 17 3_0_0 EXIST::FUNCTION: EC_KEY_set_private_key 18 3_0_0 EXIST::FUNCTION:EC SRP_VBASE_get_by_user 19 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_1_1_0,SRP @@ -40,8 +39,7 @@ PEM_read_bio_PUBKEY 39 3_0_0 EXIST::FUNCTION: X509_NAME_delete_entry 40 3_0_0 EXIST::FUNCTION: EVP_PKEY_meth_set_verify_recover 41 3_0_0 EXIST::FUNCTION: UI_set_method 42 3_0_0 EXIST::FUNCTION: -PKCS7_ISSUER_AND_SERIAL_it 43 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_ISSUER_AND_SERIAL_it 43 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_ISSUER_AND_SERIAL_it 43 3_0_0 EXIST::FUNCTION: EC_GROUP_method_of 44 3_0_0 EXIST::FUNCTION:EC RSA_blinding_on 45 3_0_0 EXIST::FUNCTION:RSA X509_get0_signature 47 3_0_0 EXIST::FUNCTION: @@ -181,8 +179,7 @@ OCSP_response_status 182 3_0_0 EXIST::FUNCTION:OCSP i2d_ASN1_PRINTABLESTRING 183 3_0_0 EXIST::FUNCTION: X509_VERIFY_PARAM_set_hostflags 184 3_0_0 EXIST::FUNCTION: SCT_get0_log_id 185 3_0_0 EXIST::FUNCTION:CT -ASN1_IA5STRING_it 186 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_IA5STRING_it 186 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_IA5STRING_it 186 3_0_0 EXIST::FUNCTION: PEM_write_bio_ECPrivateKey 187 3_0_0 EXIST::FUNCTION:EC BN_consttime_swap 188 3_0_0 EXIST::FUNCTION: BIO_f_buffer 189 3_0_0 EXIST::FUNCTION: @@ -214,8 +211,7 @@ PEM_write_PKCS8_PRIV_KEY_INFO 214 3_0_0 EXIST::FUNCTION:STDIO X509at_get0_data_by_OBJ 215 3_0_0 EXIST::FUNCTION: b2i_PublicKey_bio 216 3_0_0 EXIST::FUNCTION:DSA s2i_ASN1_OCTET_STRING 217 3_0_0 EXIST::FUNCTION: -POLICYINFO_it 218 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -POLICYINFO_it 218 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +POLICYINFO_it 218 3_0_0 EXIST::FUNCTION: OBJ_create 219 3_0_0 EXIST::FUNCTION: d2i_NOTICEREF 220 3_0_0 EXIST::FUNCTION: BN_get_rfc2409_prime_768 221 3_0_0 EXIST::FUNCTION: @@ -264,8 +260,7 @@ PKCS7_add1_attrib_digest 265 3_0_0 EXIST::FUNCTION: EC_POINT_get_affine_coordinates_GFp 266 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3,EC EVP_seed_ecb 267 3_0_0 EXIST::FUNCTION:SEED BIO_dgram_sctp_wait_for_dry 268 3_0_0 EXIST::FUNCTION:DGRAM,SCTP -ASN1_OCTET_STRING_NDEF_it 269 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_OCTET_STRING_NDEF_it 269 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_OCTET_STRING_NDEF_it 269 3_0_0 EXIST::FUNCTION: EVP_PKEY_asn1_get_count 270 3_0_0 EXIST::FUNCTION: WHIRLPOOL_Init 271 3_0_0 EXIST::FUNCTION:WHIRLPOOL EVP_OpenInit 272 3_0_0 EXIST::FUNCTION:RSA @@ -340,13 +335,11 @@ BIO_get_host_ip 340 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_1 PKCS7_add_certificate 341 3_0_0 EXIST::FUNCTION: TS_REQ_get_ext 342 3_0_0 EXIST::FUNCTION:TS X509_NAME_cmp 343 3_0_0 EXIST::FUNCTION: -DIST_POINT_it 344 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -DIST_POINT_it 344 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +DIST_POINT_it 344 3_0_0 EXIST::FUNCTION: PEM_read_X509_CRL 345 3_0_0 EXIST::FUNCTION:STDIO OPENSSL_sk_sort 346 3_0_0 EXIST::FUNCTION: CTLOG_STORE_load_file 347 3_0_0 EXIST::FUNCTION:CT -ASN1_SEQUENCE_it 348 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_SEQUENCE_it 348 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_SEQUENCE_it 348 3_0_0 EXIST::FUNCTION: TS_RESP_CTX_get_tst_info 349 3_0_0 EXIST::FUNCTION:TS RC4 350 3_0_0 EXIST::FUNCTION:RC4 PKCS7_stream 352 3_0_0 EXIST::FUNCTION: @@ -360,8 +353,7 @@ PKCS12_mac_present 359 3_0_0 EXIST::FUNCTION: d2i_PUBKEY_bio 360 3_0_0 EXIST::FUNCTION: BN_asc2bn 361 3_0_0 EXIST::FUNCTION: EVP_desx_cbc 362 3_0_0 EXIST::FUNCTION:DES -SXNETID_it 363 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -SXNETID_it 363 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +SXNETID_it 363 3_0_0 EXIST::FUNCTION: CRYPTO_gcm128_encrypt 364 3_0_0 EXIST::FUNCTION: EVP_PKEY_CTX_ctrl_str 365 3_0_0 EXIST::FUNCTION: CMS_signed_add1_attr_by_txt 366 3_0_0 EXIST::FUNCTION:CMS @@ -462,7 +454,7 @@ X509v3_asid_add_id_or_range 462 3_0_0 EXIST::FUNCTION:RFC3779 X509_NAME_ENTRY_create_by_NID 463 3_0_0 EXIST::FUNCTION: EC_KEY_METHOD_get_init 464 3_0_0 EXIST::FUNCTION:EC ASN1_INTEGER_to_BN 465 3_0_0 EXIST::FUNCTION: -OPENSSL_memcmp 466 3_0_0 EXIST::FUNCTION: +OPENSSL_memcmp 466 3_0_0 NOEXIST::FUNCTION: BUF_MEM_new 467 3_0_0 EXIST::FUNCTION: DSO_set_filename 468 3_0_0 EXIST::FUNCTION: DH_new 469 3_0_0 EXIST::FUNCTION:DH @@ -470,8 +462,7 @@ OCSP_RESPID_free 470 3_0_0 EXIST::FUNCTION:OCSP PKCS5_pbe2_set 471 3_0_0 EXIST::FUNCTION: SCT_set_signature_nid 473 3_0_0 EXIST::FUNCTION:CT i2d_RSA_PUBKEY_fp 474 3_0_0 EXIST::FUNCTION:RSA,STDIO -PKCS12_BAGS_it 475 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS12_BAGS_it 475 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS12_BAGS_it 475 3_0_0 EXIST::FUNCTION: X509_pubkey_digest 476 3_0_0 EXIST::FUNCTION: ENGINE_register_all_RSA 477 3_0_0 EXIST::FUNCTION:ENGINE CRYPTO_THREAD_set_local 478 3_0_0 EXIST::FUNCTION: @@ -489,14 +480,12 @@ X509_STORE_set_trust 489 3_0_0 EXIST::FUNCTION: d2i_POLICYINFO 490 3_0_0 EXIST::FUNCTION: DES_cbc_encrypt 491 3_0_0 EXIST::FUNCTION:DES BN_GF2m_mod_sqr_arr 492 3_0_0 EXIST::FUNCTION:EC2M -ASN1_PRINTABLESTRING_it 493 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_PRINTABLESTRING_it 493 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_PRINTABLESTRING_it 493 3_0_0 EXIST::FUNCTION: BIO_f_cipher 494 3_0_0 EXIST::FUNCTION: UI_destroy_method 495 3_0_0 EXIST::FUNCTION: BN_get_rfc3526_prime_3072 496 3_0_0 EXIST::FUNCTION: X509_INFO_new 497 3_0_0 EXIST::FUNCTION: -OCSP_RESPDATA_it 498 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_RESPDATA_it 498 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_RESPDATA_it 498 3_0_0 EXIST::FUNCTION:OCSP X509_CRL_print 499 3_0_0 EXIST::FUNCTION: WHIRLPOOL_Update 500 3_0_0 EXIST::FUNCTION:WHIRLPOOL DSA_get_ex_data 501 3_0_0 EXIST::FUNCTION:DSA @@ -542,8 +531,7 @@ ENGINE_unregister_RAND 542 3_0_0 EXIST::FUNCTION:ENGINE PEM_write_bio_RSAPrivateKey 543 3_0_0 EXIST::FUNCTION:RSA CONF_get_number 544 3_0_0 EXIST::FUNCTION: X509_EXTENSION_get_object 545 3_0_0 EXIST::FUNCTION: -X509_EXTENSIONS_it 546 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_EXTENSIONS_it 546 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_EXTENSIONS_it 546 3_0_0 EXIST::FUNCTION: EC_POINT_set_compressed_coordinates_GF2m 547 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3,EC,EC2M RSA_sign_ASN1_OCTET_STRING 548 3_0_0 EXIST::FUNCTION:RSA d2i_X509_CRL_fp 549 3_0_0 EXIST::FUNCTION:STDIO @@ -595,11 +583,9 @@ RAND_query_egd_bytes 596 3_0_0 EXIST::FUNCTION:EGD i2d_ASN1_PRINTABLE 597 3_0_0 EXIST::FUNCTION: ENGINE_cmd_is_executable 598 3_0_0 EXIST::FUNCTION:ENGINE BIO_puts 599 3_0_0 EXIST::FUNCTION: -RSAPublicKey_it 601 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA -RSAPublicKey_it 601 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RSA +RSAPublicKey_it 601 3_0_0 EXIST::FUNCTION:RSA ISSUING_DIST_POINT_new 602 3_0_0 EXIST::FUNCTION: -X509_VAL_it 603 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_VAL_it 603 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_VAL_it 603 3_0_0 EXIST::FUNCTION: EVP_DigestVerifyInit 604 3_0_0 EXIST::FUNCTION: i2d_IPAddressChoice 605 3_0_0 EXIST::FUNCTION:RFC3779 EVP_md5 606 3_0_0 EXIST::FUNCTION:MD5 @@ -615,8 +601,7 @@ BN_is_negative 615 3_0_0 EXIST::FUNCTION: EVP_PKEY_get_attr_count 616 3_0_0 EXIST::FUNCTION: X509_REVOKED_get_ext_by_critical 617 3_0_0 EXIST::FUNCTION: X509at_get_attr 618 3_0_0 EXIST::FUNCTION: -X509_PUBKEY_it 619 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_PUBKEY_it 619 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_PUBKEY_it 619 3_0_0 EXIST::FUNCTION: DES_ede3_ofb64_encrypt 620 3_0_0 EXIST::FUNCTION:DES EC_KEY_METHOD_get_compute_key 621 3_0_0 EXIST::FUNCTION:EC RC2_cfb64_encrypt 622 3_0_0 EXIST::FUNCTION:RC2 @@ -634,8 +619,7 @@ OCSP_REQ_CTX_nbio_d2i 634 3_0_0 EXIST::FUNCTION:OCSP d2i_X509_REQ_fp 635 3_0_0 EXIST::FUNCTION:STDIO DH_OpenSSL 636 3_0_0 EXIST::FUNCTION:DH BN_get_rfc3526_prime_8192 637 3_0_0 EXIST::FUNCTION: -X509_REVOKED_it 638 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_REVOKED_it 638 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_REVOKED_it 638 3_0_0 EXIST::FUNCTION: CRYPTO_THREAD_write_lock 639 3_0_0 EXIST::FUNCTION: X509V3_NAME_from_section 640 3_0_0 EXIST::FUNCTION: EC_POINT_set_compressed_coordinates_GFp 641 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3,EC @@ -670,8 +654,7 @@ PKCS5_pbe_set0_algor 670 3_0_0 EXIST::FUNCTION: ENGINE_get_table_flags 671 3_0_0 EXIST::FUNCTION:ENGINE PKCS12_MAC_DATA_new 672 3_0_0 EXIST::FUNCTION: X509_chain_up_ref 673 3_0_0 EXIST::FUNCTION: -OCSP_REQINFO_it 674 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_REQINFO_it 674 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_REQINFO_it 674 3_0_0 EXIST::FUNCTION:OCSP PKCS12_add_localkeyid 675 3_0_0 EXIST::FUNCTION: PKCS12_SAFEBAG_get0_type 676 3_0_0 EXIST::FUNCTION: X509_TRUST_set_default 677 3_0_0 EXIST::FUNCTION: @@ -680,8 +663,7 @@ BN_sub 679 3_0_0 EXIST::FUNCTION: ASRange_free 680 3_0_0 EXIST::FUNCTION:RFC3779 EVP_aes_192_cfb8 681 3_0_0 EXIST::FUNCTION: DSO_global_lookup 682 3_0_0 EXIST::FUNCTION: -PKCS7_SIGNER_INFO_it 683 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_SIGNER_INFO_it 683 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_SIGNER_INFO_it 683 3_0_0 EXIST::FUNCTION: CRYPTO_ocb128_copy_ctx 684 3_0_0 EXIST::FUNCTION:OCB TS_REQ_get_ext_d2i 685 3_0_0 EXIST::FUNCTION:TS AES_ige_encrypt 686 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3 @@ -701,8 +683,7 @@ TS_RESP_CTX_set_signer_key 699 3_0_0 EXIST::FUNCTION:TS i2d_DSAPrivateKey_bio 700 3_0_0 EXIST::FUNCTION:DSA ASN1_item_d2i 702 3_0_0 EXIST::FUNCTION: BIO_int_ctrl 703 3_0_0 EXIST::FUNCTION: -CMS_ReceiptRequest_it 704 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CMS -CMS_ReceiptRequest_it 704 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CMS +CMS_ReceiptRequest_it 704 3_0_0 EXIST::FUNCTION:CMS X509_ATTRIBUTE_get0_type 705 3_0_0 EXIST::FUNCTION: EVP_MD_meth_set_copy 706 3_0_0 EXIST::FUNCTION: d2i_ASN1_ENUMERATED 707 3_0_0 EXIST::FUNCTION: @@ -720,8 +701,7 @@ BIO_new_PKCS7 719 3_0_0 EXIST::FUNCTION: UI_get0_user_data 720 3_0_0 EXIST::FUNCTION: TS_RESP_get_token 721 3_0_0 EXIST::FUNCTION:TS OCSP_RESPID_new 722 3_0_0 EXIST::FUNCTION:OCSP -ASN1_SET_ANY_it 723 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_SET_ANY_it 723 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_SET_ANY_it 723 3_0_0 EXIST::FUNCTION: d2i_TS_RESP_bio 724 3_0_0 EXIST::FUNCTION:TS PEM_write_X509_REQ 725 3_0_0 EXIST::FUNCTION:STDIO BIO_snprintf 726 3_0_0 EXIST::FUNCTION: @@ -825,8 +805,7 @@ PKCS7_DIGEST_free 824 3_0_0 EXIST::FUNCTION: OBJ_nid2ln 825 3_0_0 EXIST::FUNCTION: COMP_CTX_new 826 3_0_0 EXIST::FUNCTION:COMP BIO_ADDR_family 827 3_0_0 EXIST::FUNCTION:SOCK -OCSP_RESPONSE_it 828 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_RESPONSE_it 828 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_RESPONSE_it 828 3_0_0 EXIST::FUNCTION:OCSP BIO_ADDRINFO_socktype 829 3_0_0 EXIST::FUNCTION:SOCK d2i_X509_REQ_bio 830 3_0_0 EXIST::FUNCTION: EVP_PBE_cleanup 831 3_0_0 EXIST::FUNCTION: @@ -834,8 +813,7 @@ X509_STORE_CTX_get0_current_crl 832 3_0_0 EXIST::FUNCTION: CMS_get0_SignerInfos 833 3_0_0 EXIST::FUNCTION:CMS EVP_PKEY_paramgen 834 3_0_0 EXIST::FUNCTION: PEM_write_PKCS8PrivateKey_nid 835 3_0_0 EXIST::FUNCTION:STDIO -PKCS7_ATTR_VERIFY_it 836 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_ATTR_VERIFY_it 836 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_ATTR_VERIFY_it 836 3_0_0 EXIST::FUNCTION: OCSP_response_status_str 837 3_0_0 EXIST::FUNCTION:OCSP CRYPTO_gcm128_new 838 3_0_0 EXIST::FUNCTION: SMIME_read_PKCS7 839 3_0_0 EXIST::FUNCTION: @@ -862,8 +840,7 @@ TXT_DB_insert 860 3_0_0 EXIST::FUNCTION: EC_POINTs_make_affine 861 3_0_0 EXIST::FUNCTION:EC RSA_padding_add_PKCS1_PSS 862 3_0_0 EXIST::FUNCTION:RSA BF_options 863 3_0_0 EXIST::FUNCTION:BF -OCSP_BASICRESP_it 864 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_BASICRESP_it 864 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_BASICRESP_it 864 3_0_0 EXIST::FUNCTION:OCSP X509_VERIFY_PARAM_get0_name 865 3_0_0 EXIST::FUNCTION: TS_RESP_CTX_set_signer_digest 866 3_0_0 EXIST::FUNCTION:TS X509_VERIFY_PARAM_set1_email 867 3_0_0 EXIST::FUNCTION: @@ -873,8 +850,7 @@ BN_GF2m_mod_sqrt_arr 870 3_0_0 EXIST::FUNCTION:EC2M X509_get0_extensions 871 3_0_0 EXIST::FUNCTION: TS_STATUS_INFO_set_status 872 3_0_0 EXIST::FUNCTION:TS RSA_verify 873 3_0_0 EXIST::FUNCTION:RSA -ASN1_FBOOLEAN_it 874 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_FBOOLEAN_it 874 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_FBOOLEAN_it 874 3_0_0 EXIST::FUNCTION: d2i_ASN1_TIME 875 3_0_0 EXIST::FUNCTION: EVP_PKEY_meth_get_signctx 876 3_0_0 EXIST::FUNCTION: EC_KEY_METHOD_set_compute_key 877 3_0_0 EXIST::FUNCTION:EC @@ -892,8 +868,7 @@ X509_VERIFY_PARAM_set_purpose 889 3_0_0 EXIST::FUNCTION: i2d_TS_MSG_IMPRINT_bio 890 3_0_0 EXIST::FUNCTION:TS X509_EXTENSION_set_object 891 3_0_0 EXIST::FUNCTION: EVP_CIPHER_CTX_get_app_data 892 3_0_0 EXIST::FUNCTION: -CRL_DIST_POINTS_it 893 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -CRL_DIST_POINTS_it 893 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +CRL_DIST_POINTS_it 893 3_0_0 EXIST::FUNCTION: DIRECTORYSTRING_new 894 3_0_0 EXIST::FUNCTION: ERR_load_ASYNC_strings 895 3_0_0 EXIST::FUNCTION: EVP_bf_cfb64 896 3_0_0 EXIST::FUNCTION:BF @@ -934,8 +909,7 @@ X509at_add1_attr_by_NID 931 3_0_0 EXIST::FUNCTION: DHparams_dup 932 3_0_0 EXIST::FUNCTION:DH X509_get_ext 933 3_0_0 EXIST::FUNCTION: X509_issuer_and_serial_hash 934 3_0_0 EXIST::FUNCTION: -ASN1_BMPSTRING_it 935 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_BMPSTRING_it 935 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_BMPSTRING_it 935 3_0_0 EXIST::FUNCTION: PEM_read_EC_PUBKEY 936 3_0_0 EXIST::FUNCTION:EC,STDIO d2i_ASN1_IA5STRING 937 3_0_0 EXIST::FUNCTION: TS_TST_INFO_ext_free 938 3_0_0 EXIST::FUNCTION:TS @@ -950,8 +924,7 @@ i2d_ECPrivateKey 947 3_0_0 EXIST::FUNCTION:EC X509_NAME_ENTRY_create_by_OBJ 948 3_0_0 EXIST::FUNCTION: TS_VERIFY_CTX_cleanup 949 3_0_0 EXIST::FUNCTION:TS ASN1_INTEGER_get 950 3_0_0 EXIST::FUNCTION: -ASN1_PRINTABLE_it 951 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_PRINTABLE_it 951 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_PRINTABLE_it 951 3_0_0 EXIST::FUNCTION: EVP_VerifyFinal 952 3_0_0 EXIST::FUNCTION: TS_ASN1_INTEGER_print_bio 953 3_0_0 EXIST::FUNCTION:TS X509_NAME_ENTRY_set_object 954 3_0_0 EXIST::FUNCTION: @@ -970,10 +943,8 @@ TS_RESP_dup 966 3_0_0 EXIST::FUNCTION:TS ERR_set_error_data 967 3_0_0 EXIST::FUNCTION: BN_RECP_CTX_new 968 3_0_0 EXIST::FUNCTION: DES_options 969 3_0_0 EXIST::FUNCTION:DES -IPAddressChoice_it 970 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RFC3779 -IPAddressChoice_it 970 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RFC3779 -ASN1_UNIVERSALSTRING_it 971 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_UNIVERSALSTRING_it 971 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +IPAddressChoice_it 970 3_0_0 EXIST::FUNCTION:RFC3779 +ASN1_UNIVERSALSTRING_it 971 3_0_0 EXIST::FUNCTION: d2i_DSAPublicKey 972 3_0_0 EXIST::FUNCTION:DSA ENGINE_get_name 973 3_0_0 EXIST::FUNCTION:ENGINE CRYPTO_THREAD_read_lock 974 3_0_0 EXIST::FUNCTION: @@ -1001,8 +972,7 @@ a2i_IPADDRESS 996 3_0_0 EXIST::FUNCTION: ERR_peek_error_line_data 997 3_0_0 EXIST::FUNCTION: ERR_unload_strings 998 3_0_0 EXIST::FUNCTION: SEED_cfb128_encrypt 999 3_0_0 EXIST::FUNCTION:SEED -ASN1_BIT_STRING_it 1000 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_BIT_STRING_it 1000 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_BIT_STRING_it 1000 3_0_0 EXIST::FUNCTION: PKCS12_decrypt_skey 1001 3_0_0 EXIST::FUNCTION: ENGINE_register_EC 1002 3_0_0 EXIST::FUNCTION:ENGINE OCSP_RESPONSE_new 1003 3_0_0 EXIST::FUNCTION:OCSP @@ -1015,8 +985,7 @@ ASN1_item_digest 1009 3_0_0 EXIST::FUNCTION: X509_VERIFY_PARAM_set_trust 1010 3_0_0 EXIST::FUNCTION: X509_STORE_CTX_get_error 1011 3_0_0 EXIST::FUNCTION: EVP_PKEY_meth_set_encrypt 1012 3_0_0 EXIST::FUNCTION: -ASN1_UTCTIME_it 1013 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_UTCTIME_it 1013 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_UTCTIME_it 1013 3_0_0 EXIST::FUNCTION: i2d_DSA_PUBKEY_fp 1014 3_0_0 EXIST::FUNCTION:DSA,STDIO X509at_get_attr_by_OBJ 1015 3_0_0 EXIST::FUNCTION: EVP_MD_CTX_copy_ex 1016 3_0_0 EXIST::FUNCTION: @@ -1031,13 +1000,11 @@ X509_set_subject_name 1025 3_0_0 EXIST::FUNCTION: i2d_PKCS8PrivateKey_nid_bio 1026 3_0_0 EXIST::FUNCTION: ERR_put_error 1027 3_0_0 EXIST::FUNCTION: ERR_add_error_data 1028 3_0_0 EXIST::FUNCTION: -X509_ALGORS_it 1029 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_ALGORS_it 1029 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_ALGORS_it 1029 3_0_0 EXIST::FUNCTION: MD5_Update 1030 3_0_0 EXIST::FUNCTION:MD5 X509_policy_check 1031 3_0_0 EXIST::FUNCTION: X509_CRL_METHOD_new 1032 3_0_0 EXIST::FUNCTION: -ASN1_ANY_it 1033 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_ANY_it 1033 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_ANY_it 1033 3_0_0 EXIST::FUNCTION: d2i_DSA_SIG 1034 3_0_0 EXIST::FUNCTION:DSA DH_free 1035 3_0_0 EXIST::FUNCTION:DH ENGINE_register_all_DSA 1036 3_0_0 EXIST::FUNCTION:ENGINE @@ -1101,8 +1068,7 @@ ERR_load_PEM_strings 1094 3_0_0 EXIST::FUNCTION: ENGINE_unregister_pkey_asn1_meths 1095 3_0_0 EXIST::FUNCTION:ENGINE IPAddressFamily_free 1096 3_0_0 EXIST::FUNCTION:RFC3779 UI_method_get_prompt_constructor 1097 3_0_0 EXIST::FUNCTION: -ASN1_NULL_it 1098 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_NULL_it 1098 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_NULL_it 1098 3_0_0 EXIST::FUNCTION: X509_REQ_get_pubkey 1099 3_0_0 EXIST::FUNCTION: X509_CRL_set1_nextUpdate 1100 3_0_0 EXIST::FUNCTION: EVP_des_ede3_cfb64 1101 3_0_0 EXIST::FUNCTION:DES @@ -1127,8 +1093,7 @@ RSA_print_fp 1119 3_0_0 EXIST::FUNCTION:RSA,STDIO OPENSSL_INIT_set_config_appname 1120 3_0_0 EXIST::FUNCTION:STDIO EC_KEY_print_fp 1121 3_0_0 EXIST::FUNCTION:EC,STDIO BIO_dup_chain 1122 3_0_0 EXIST::FUNCTION: -PKCS8_PRIV_KEY_INFO_it 1123 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS8_PRIV_KEY_INFO_it 1123 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS8_PRIV_KEY_INFO_it 1123 3_0_0 EXIST::FUNCTION: RSA_OAEP_PARAMS_free 1124 3_0_0 EXIST::FUNCTION:RSA ASN1_item_new 1125 3_0_0 EXIST::FUNCTION: CRYPTO_cts128_encrypt 1126 3_0_0 EXIST::FUNCTION: @@ -1137,8 +1102,7 @@ PEM_write 1128 3_0_0 EXIST::FUNCTION:STDIO EVP_CIPHER_meth_get_get_asn1_params 1129 3_0_0 EXIST::FUNCTION: i2d_OCSP_RESPBYTES 1130 3_0_0 EXIST::FUNCTION:OCSP d2i_ASN1_UTF8STRING 1131 3_0_0 EXIST::FUNCTION: -EXTENDED_KEY_USAGE_it 1132 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -EXTENDED_KEY_USAGE_it 1132 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +EXTENDED_KEY_USAGE_it 1132 3_0_0 EXIST::FUNCTION: EVP_CipherInit 1133 3_0_0 EXIST::FUNCTION: PKCS12_add_safe 1134 3_0_0 EXIST::FUNCTION: ENGINE_get_digest 1135 3_0_0 EXIST::FUNCTION:ENGINE @@ -1171,8 +1135,7 @@ ASN1_tag2str 1161 3_0_0 EXIST::FUNCTION: BN_zero_ex 1162 3_0_0 EXIST::FUNCTION: X509_NAME_dup 1163 3_0_0 EXIST::FUNCTION: SCT_LIST_print 1164 3_0_0 EXIST::FUNCTION:CT -NOTICEREF_it 1165 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -NOTICEREF_it 1165 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +NOTICEREF_it 1165 3_0_0 EXIST::FUNCTION: CMS_add0_crl 1166 3_0_0 EXIST::FUNCTION:CMS d2i_DSAparams 1167 3_0_0 EXIST::FUNCTION:DSA EVP_CIPHER_CTX_set_app_data 1168 3_0_0 EXIST::FUNCTION: @@ -1219,15 +1182,13 @@ ENGINE_register_DSA 1208 3_0_0 EXIST::FUNCTION:ENGINE OPENSSL_LH_node_stats 1209 3_0_0 EXIST::FUNCTION:STDIO X509_policy_tree_free 1210 3_0_0 EXIST::FUNCTION: EC_GFp_simple_method 1211 3_0_0 EXIST::FUNCTION:EC -X509_it 1212 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_it 1212 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_it 1212 3_0_0 EXIST::FUNCTION: d2i_PROXY_POLICY 1213 3_0_0 EXIST::FUNCTION: MDC2_Update 1214 3_0_0 EXIST::FUNCTION:MDC2 EC_KEY_new_by_curve_name 1215 3_0_0 EXIST::FUNCTION:EC X509_CRL_free 1216 3_0_0 EXIST::FUNCTION: i2d_PKCS7_SIGN_ENVELOPE 1217 3_0_0 EXIST::FUNCTION: -OCSP_CERTSTATUS_it 1218 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_CERTSTATUS_it 1218 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_CERTSTATUS_it 1218 3_0_0 EXIST::FUNCTION:OCSP BIO_f_reliable 1219 3_0_0 EXIST::FUNCTION: OCSP_resp_count 1220 3_0_0 EXIST::FUNCTION:OCSP i2d_X509_AUX 1221 3_0_0 EXIST::FUNCTION: @@ -1299,8 +1260,7 @@ EC_KEY_new_method 1288 3_0_0 EXIST::FUNCTION:EC i2d_RSAPublicKey_fp 1289 3_0_0 EXIST::FUNCTION:RSA,STDIO CRYPTO_ctr128_encrypt_ctr32 1290 3_0_0 EXIST::FUNCTION: X509_VERIFY_PARAM_move_peername 1291 3_0_0 EXIST::FUNCTION: -OCSP_SINGLERESP_it 1292 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_SINGLERESP_it 1292 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_SINGLERESP_it 1292 3_0_0 EXIST::FUNCTION:OCSP BN_num_bits 1293 3_0_0 EXIST::FUNCTION: X509_CRL_METHOD_free 1294 3_0_0 EXIST::FUNCTION: PEM_read_NETSCAPE_CERT_SEQUENCE 1295 3_0_0 EXIST::FUNCTION:STDIO @@ -1313,11 +1273,9 @@ TS_ACCURACY_free 1301 3_0_0 EXIST::FUNCTION:TS PEM_write_DSA_PUBKEY 1302 3_0_0 EXIST::FUNCTION:DSA,STDIO BN_rshift1 1303 3_0_0 EXIST::FUNCTION: i2d_PKCS7_ENVELOPE 1304 3_0_0 EXIST::FUNCTION: -PBKDF2PARAM_it 1305 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PBKDF2PARAM_it 1305 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PBKDF2PARAM_it 1305 3_0_0 EXIST::FUNCTION: UI_get_result_maxsize 1306 3_0_0 EXIST::FUNCTION: -PBEPARAM_it 1307 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PBEPARAM_it 1307 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PBEPARAM_it 1307 3_0_0 EXIST::FUNCTION: TS_ACCURACY_set_seconds 1308 3_0_0 EXIST::FUNCTION:TS UI_get0_action_string 1309 3_0_0 EXIST::FUNCTION: RC2_decrypt 1310 3_0_0 EXIST::FUNCTION:RC2 @@ -1338,8 +1296,7 @@ SMIME_read_CMS 1324 3_0_0 EXIST::FUNCTION:CMS X509_subject_name_cmp 1325 3_0_0 EXIST::FUNCTION: CRYPTO_ocb128_finish 1326 3_0_0 EXIST::FUNCTION:OCB EVP_CIPHER_do_all 1327 3_0_0 EXIST::FUNCTION: -POLICY_MAPPINGS_it 1328 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -POLICY_MAPPINGS_it 1328 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +POLICY_MAPPINGS_it 1328 3_0_0 EXIST::FUNCTION: SCT_set0_log_id 1329 3_0_0 EXIST::FUNCTION:CT CRYPTO_cfb128_encrypt 1330 3_0_0 EXIST::FUNCTION: RSA_padding_add_PKCS1_type_2 1331 3_0_0 EXIST::FUNCTION:RSA @@ -1386,8 +1343,7 @@ BN_GENCB_set_old 1373 3_0_0 EXIST::FUNCTION: PEM_write_bio_X509 1374 3_0_0 EXIST::FUNCTION: EVP_PKEY_asn1_free 1375 3_0_0 EXIST::FUNCTION: ENGINE_unregister_DH 1376 3_0_0 EXIST::FUNCTION:ENGINE -PROXY_CERT_INFO_EXTENSION_it 1377 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PROXY_CERT_INFO_EXTENSION_it 1377 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PROXY_CERT_INFO_EXTENSION_it 1377 3_0_0 EXIST::FUNCTION: CT_POLICY_EVAL_CTX_set1_cert 1378 3_0_0 EXIST::FUNCTION:CT X509_NAME_hash 1379 3_0_0 EXIST::FUNCTION: SCT_set_timestamp 1380 3_0_0 EXIST::FUNCTION:CT @@ -1437,11 +1393,9 @@ CRYPTO_nistcts128_encrypt 1425 3_0_0 EXIST::FUNCTION: CONF_modules_finish 1426 3_0_0 EXIST::FUNCTION: BN_value_one 1427 3_0_0 EXIST::FUNCTION: RSA_padding_add_SSLv23 1428 3_0_0 EXIST::FUNCTION:RSA -OCSP_RESPBYTES_it 1429 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_RESPBYTES_it 1429 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_RESPBYTES_it 1429 3_0_0 EXIST::FUNCTION:OCSP EVP_aes_192_wrap 1430 3_0_0 EXIST::FUNCTION: -OCSP_CERTID_it 1431 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_CERTID_it 1431 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_CERTID_it 1431 3_0_0 EXIST::FUNCTION:OCSP ENGINE_get_RSA 1432 3_0_0 EXIST::FUNCTION:ENGINE RAND_get_rand_method 1433 3_0_0 EXIST::FUNCTION: ERR_load_DSA_strings 1434 3_0_0 EXIST::FUNCTION:DSA @@ -1497,8 +1451,7 @@ BIO_accept_ex 1484 3_0_0 EXIST::FUNCTION:SOCK CRYPTO_get_mem_functions 1485 3_0_0 EXIST::FUNCTION: PEM_read_bio 1486 3_0_0 EXIST::FUNCTION: OCSP_BASICRESP_get_ext_by_critical 1487 3_0_0 EXIST::FUNCTION:OCSP -SXNET_it 1488 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -SXNET_it 1488 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +SXNET_it 1488 3_0_0 EXIST::FUNCTION: BIO_indent 1489 3_0_0 EXIST::FUNCTION: i2d_X509_fp 1490 3_0_0 EXIST::FUNCTION:STDIO d2i_ASN1_TYPE 1491 3_0_0 EXIST::FUNCTION: @@ -1603,8 +1556,7 @@ X509_STORE_set_flags 1590 3_0_0 EXIST::FUNCTION: UI_get0_output_string 1591 3_0_0 EXIST::FUNCTION: ERR_get_error_line_data 1592 3_0_0 EXIST::FUNCTION: CTLOG_get0_name 1593 3_0_0 EXIST::FUNCTION:CT -ASN1_TBOOLEAN_it 1594 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_TBOOLEAN_it 1594 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_TBOOLEAN_it 1594 3_0_0 EXIST::FUNCTION: RC2_set_key 1595 3_0_0 EXIST::FUNCTION:RC2 X509_REVOKED_get_ext_by_NID 1596 3_0_0 EXIST::FUNCTION: RSA_padding_add_none 1597 3_0_0 EXIST::FUNCTION:RSA @@ -1650,8 +1602,7 @@ PKCS7_ENCRYPT_free 1638 3_0_0 EXIST::FUNCTION: i2d_DIST_POINT 1639 3_0_0 EXIST::FUNCTION: EVP_PKEY_paramgen_init 1640 3_0_0 EXIST::FUNCTION: TS_MSG_IMPRINT_dup 1641 3_0_0 EXIST::FUNCTION:TS -CMS_ContentInfo_it 1642 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CMS -CMS_ContentInfo_it 1642 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CMS +CMS_ContentInfo_it 1642 3_0_0 EXIST::FUNCTION:CMS OCSP_resp_get0_signature 1643 3_0_0 EXIST::FUNCTION:OCSP X509_STORE_CTX_get1_issuer 1644 3_0_0 EXIST::FUNCTION: EVP_Digest 1645 3_0_0 EXIST::FUNCTION: @@ -1684,8 +1635,7 @@ OCSP_crlID_new 1673 3_0_0 EXIST:!VMS:FUNCTION:OCSP OCSP_crlID2_new 1673 3_0_0 EXIST:VMS:FUNCTION:OCSP PEM_write_PKCS7 1674 3_0_0 EXIST::FUNCTION:STDIO PKCS7_add_signer 1675 3_0_0 EXIST::FUNCTION: -X509_SIG_it 1676 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_SIG_it 1676 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_SIG_it 1676 3_0_0 EXIST::FUNCTION: ASYNC_start_job 1677 3_0_0 EXIST::FUNCTION: TS_TST_INFO_dup 1678 3_0_0 EXIST::FUNCTION:TS EVP_aes_192_ctr 1679 3_0_0 EXIST::FUNCTION: @@ -1707,8 +1657,7 @@ d2i_PKCS12_MAC_DATA 1694 3_0_0 EXIST::FUNCTION: ENGINE_ctrl_cmd 1695 3_0_0 EXIST::FUNCTION:ENGINE PKCS12_SAFEBAG_get_bag_nid 1696 3_0_0 EXIST::FUNCTION: TS_CONF_set_digests 1697 3_0_0 EXIST::FUNCTION:TS -PKCS7_SIGNED_it 1698 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_SIGNED_it 1698 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_SIGNED_it 1698 3_0_0 EXIST::FUNCTION: b2i_PublicKey 1699 3_0_0 EXIST::FUNCTION:DSA X509_PURPOSE_cleanup 1700 3_0_0 EXIST::FUNCTION: ESS_SIGNING_CERT_dup 1701 3_0_0 EXIST::FUNCTION: @@ -1768,8 +1717,7 @@ ASYNC_init_thread 1755 3_0_0 EXIST::FUNCTION: OCSP_BASICRESP_get_ext_by_OBJ 1756 3_0_0 EXIST::FUNCTION:OCSP X509_reject_clear 1757 3_0_0 EXIST::FUNCTION: DH_security_bits 1758 3_0_0 EXIST::FUNCTION:DH -LONG_it 1759 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DEPRECATEDIN_3 -LONG_it 1759 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DEPRECATEDIN_3 +LONG_it 1759 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3 ASN1_dup 1760 3_0_0 EXIST::FUNCTION: TS_RESP_new 1761 3_0_0 EXIST::FUNCTION:TS i2d_PKCS8PrivateKeyInfo_fp 1762 3_0_0 EXIST::FUNCTION:STDIO @@ -1786,8 +1734,7 @@ ASN1_tag2bit 1772 3_0_0 EXIST::FUNCTION: TS_REQ_add_ext 1773 3_0_0 EXIST::FUNCTION:TS X509_digest 1776 3_0_0 EXIST::FUNCTION: CRYPTO_THREAD_cleanup_local 1777 3_0_0 EXIST::FUNCTION: -NETSCAPE_CERT_SEQUENCE_it 1778 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -NETSCAPE_CERT_SEQUENCE_it 1778 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +NETSCAPE_CERT_SEQUENCE_it 1778 3_0_0 EXIST::FUNCTION: EVP_aes_128_wrap 1779 3_0_0 EXIST::FUNCTION: X509V3_conf_free 1780 3_0_0 EXIST::FUNCTION: TS_TST_INFO_get_ext_by_NID 1781 3_0_0 EXIST::FUNCTION:TS @@ -1796,8 +1743,7 @@ X509_issuer_name_cmp 1783 3_0_0 EXIST::FUNCTION: CMS_RecipientEncryptedKey_get0_id 1784 3_0_0 EXIST::FUNCTION:CMS EVP_PKEY_meth_get_verify_recover 1785 3_0_0 EXIST::FUNCTION: NAME_CONSTRAINTS_check 1786 3_0_0 EXIST::FUNCTION: -X509_CERT_AUX_it 1787 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_CERT_AUX_it 1787 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_CERT_AUX_it 1787 3_0_0 EXIST::FUNCTION: X509_get_X509_PUBKEY 1789 3_0_0 EXIST::FUNCTION: TXT_DB_create_index 1790 3_0_0 EXIST::FUNCTION: RAND_set_rand_engine 1791 3_0_0 EXIST::FUNCTION:ENGINE @@ -1834,15 +1780,13 @@ X509V3_EXT_add_list 1821 3_0_0 EXIST::FUNCTION: CMS_compress 1822 3_0_0 EXIST::FUNCTION:CMS X509_get_ext_by_critical 1823 3_0_0 EXIST::FUNCTION: ASYNC_WAIT_CTX_clear_fd 1824 3_0_0 EXIST::FUNCTION: -ZLONG_it 1825 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DEPRECATEDIN_3 -ZLONG_it 1825 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DEPRECATEDIN_3 +ZLONG_it 1825 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3 OPENSSL_sk_find_ex 1826 3_0_0 EXIST::FUNCTION: ASN1_ENUMERATED_to_BN 1827 3_0_0 EXIST::FUNCTION: X509_CRL_get_ext_d2i 1828 3_0_0 EXIST::FUNCTION: i2d_AUTHORITY_KEYID 1829 3_0_0 EXIST::FUNCTION: TS_TST_INFO_get_time 1830 3_0_0 EXIST::FUNCTION:TS -ASN1_VISIBLESTRING_it 1831 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_VISIBLESTRING_it 1831 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_VISIBLESTRING_it 1831 3_0_0 EXIST::FUNCTION: X509V3_EXT_REQ_add_conf 1832 3_0_0 EXIST::FUNCTION: ASN1_STRING_to_UTF8 1833 3_0_0 EXIST::FUNCTION: EVP_MD_meth_set_update 1835 3_0_0 EXIST::FUNCTION: @@ -1856,15 +1800,13 @@ X509_CRL_get_ext_count 1842 3_0_0 EXIST::FUNCTION: PKCS12_add_key 1843 3_0_0 EXIST::FUNCTION: EVP_camellia_128_cfb1 1844 3_0_0 EXIST::FUNCTION:CAMELLIA BIO_find_type 1845 3_0_0 EXIST::FUNCTION: -ISSUING_DIST_POINT_it 1846 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ISSUING_DIST_POINT_it 1846 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ISSUING_DIST_POINT_it 1846 3_0_0 EXIST::FUNCTION: BIO_ctrl_wpending 1847 3_0_0 EXIST::FUNCTION: X509_ALGOR_cmp 1848 3_0_0 EXIST::FUNCTION: i2d_ASN1_bio_stream 1849 3_0_0 EXIST::FUNCTION: CRYPTO_THREAD_init_local 1850 3_0_0 EXIST::FUNCTION: TS_RESP_CTX_set_serial_cb 1851 3_0_0 EXIST::FUNCTION:TS -POLICY_MAPPING_it 1852 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -POLICY_MAPPING_it 1852 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +POLICY_MAPPING_it 1852 3_0_0 EXIST::FUNCTION: ERR_load_KDF_strings 1853 3_0_0 EXIST::FUNCTION: UI_method_set_reader 1854 3_0_0 EXIST::FUNCTION: BIO_next 1855 3_0_0 EXIST::FUNCTION: @@ -1877,8 +1819,7 @@ PKCS7_digest_from_attributes 1861 3_0_0 EXIST::FUNCTION: EC_GROUP_set_curve_GFp 1862 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3,EC X509_PURPOSE_get0 1863 3_0_0 EXIST::FUNCTION: EVP_PKEY_set1_DSA 1864 3_0_0 EXIST::FUNCTION:DSA -X509_NAME_it 1865 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_NAME_it 1865 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_NAME_it 1865 3_0_0 EXIST::FUNCTION: OBJ_add_object 1866 3_0_0 EXIST::FUNCTION: DSA_generate_key 1867 3_0_0 EXIST::FUNCTION:DSA EVP_DigestUpdate 1868 3_0_0 EXIST::FUNCTION: @@ -1901,8 +1842,7 @@ CMS_add1_crl 1884 3_0_0 EXIST::FUNCTION:CMS d2i_EDIPARTYNAME 1885 3_0_0 EXIST::FUNCTION: X509_STORE_CTX_set0_trusted_stack 1886 3_0_0 EXIST::FUNCTION: BIO_ADDR_service_string 1887 3_0_0 EXIST::FUNCTION:SOCK -ASN1_BOOLEAN_it 1888 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_BOOLEAN_it 1888 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_BOOLEAN_it 1888 3_0_0 EXIST::FUNCTION: TS_RESP_CTX_set_time_cb 1889 3_0_0 EXIST::FUNCTION:TS IDEA_cbc_encrypt 1890 3_0_0 EXIST::FUNCTION:IDEA BN_CTX_secure_new 1891 3_0_0 EXIST::FUNCTION: @@ -1977,8 +1917,7 @@ ENGINE_get_pkey_asn1_meth 1962 3_0_0 EXIST::FUNCTION:ENGINE SHA256_Update 1963 3_0_0 EXIST::FUNCTION: d2i_PKCS7_ISSUER_AND_SERIAL 1964 3_0_0 EXIST::FUNCTION: PKCS12_unpack_authsafes 1965 3_0_0 EXIST::FUNCTION: -X509_CRL_it 1966 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_CRL_it 1966 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_CRL_it 1966 3_0_0 EXIST::FUNCTION: d2i_X509_ALGOR 1967 3_0_0 EXIST::FUNCTION: PKCS12_PBE_keyivgen 1968 3_0_0 EXIST::FUNCTION: BIO_test_flags 1969 3_0_0 EXIST::FUNCTION: @@ -1990,8 +1929,7 @@ i2d_OCSP_REQINFO 1974 3_0_0 EXIST::FUNCTION:OCSP EVP_PKEY_sign 1975 3_0_0 EXIST::FUNCTION: TS_REQ_get_ext_by_critical 1976 3_0_0 EXIST::FUNCTION:TS EC_KEY_key2buf 1977 3_0_0 EXIST::FUNCTION:EC -X509_EXTENSION_it 1978 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_EXTENSION_it 1978 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_EXTENSION_it 1978 3_0_0 EXIST::FUNCTION: i2d_PKCS8_fp 1979 3_0_0 EXIST::FUNCTION:STDIO UTF8_getc 1980 3_0_0 EXIST::FUNCTION: ASN1_IA5STRING_free 1981 3_0_0 EXIST::FUNCTION: @@ -2004,16 +1942,14 @@ EVP_PKEY_get0_DSA 1987 3_0_0 EXIST::FUNCTION:DSA d2i_CMS_ContentInfo 1988 3_0_0 EXIST::FUNCTION:CMS EVP_CIPHER_meth_get_do_cipher 1989 3_0_0 EXIST::FUNCTION: i2d_DSA_PUBKEY 1990 3_0_0 EXIST::FUNCTION:DSA -GENERAL_NAME_it 1991 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -GENERAL_NAME_it 1991 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +GENERAL_NAME_it 1991 3_0_0 EXIST::FUNCTION: EVP_des_ede_ecb 1992 3_0_0 EXIST::FUNCTION:DES i2d_CRL_DIST_POINTS 1993 3_0_0 EXIST::FUNCTION: PEM_write_bio_X509_REQ_NEW 1994 3_0_0 EXIST::FUNCTION: RC5_32_ofb64_encrypt 1995 3_0_0 EXIST::FUNCTION:RC5 i2d_PKCS7 1996 3_0_0 EXIST::FUNCTION: BN_mod_lshift_quick 1997 3_0_0 EXIST::FUNCTION: -DIST_POINT_NAME_it 1998 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -DIST_POINT_NAME_it 1998 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +DIST_POINT_NAME_it 1998 3_0_0 EXIST::FUNCTION: PEM_read_PrivateKey 1999 3_0_0 EXIST::FUNCTION:STDIO X509V3_get_d2i 2000 3_0_0 EXIST::FUNCTION: PKCS7_SIGNER_INFO_sign 2001 3_0_0 EXIST::FUNCTION: @@ -2052,20 +1988,16 @@ ENGINE_unregister_RSA 2033 3_0_0 EXIST::FUNCTION:ENGINE EC_GROUP_order_bits 2034 3_0_0 EXIST::FUNCTION:EC d2i_CMS_bio 2035 3_0_0 EXIST::FUNCTION:CMS OPENSSL_sk_num 2036 3_0_0 EXIST::FUNCTION: -_shadow_DES_check_key 2037 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DES -_shadow_DES_check_key 2037 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DES CMS_RecipientInfo_set0_pkey 2038 3_0_0 EXIST::FUNCTION:CMS X509_STORE_CTX_set_default 2039 3_0_0 EXIST::FUNCTION: AES_wrap_key 2040 3_0_0 EXIST::FUNCTION: EVP_md_null 2041 3_0_0 EXIST::FUNCTION: i2d_SCT_LIST 2042 3_0_0 EXIST::FUNCTION:CT PKCS7_get_issuer_and_serial 2043 3_0_0 EXIST::FUNCTION: -PKCS7_SIGN_ENVELOPE_it 2044 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_SIGN_ENVELOPE_it 2044 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_SIGN_ENVELOPE_it 2044 3_0_0 EXIST::FUNCTION: ASN1_d2i_fp 2045 3_0_0 EXIST::FUNCTION:STDIO EVP_DecryptFinal 2046 3_0_0 EXIST::FUNCTION: -ASN1_ENUMERATED_it 2047 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_ENUMERATED_it 2047 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_ENUMERATED_it 2047 3_0_0 EXIST::FUNCTION: o2i_ECPublicKey 2048 3_0_0 EXIST::FUNCTION:EC ERR_load_BUF_strings 2049 3_0_0 EXIST::FUNCTION: PEM_read_bio_RSA_PUBKEY 2050 3_0_0 EXIST::FUNCTION:RSA @@ -2128,8 +2060,7 @@ i2d_TS_REQ 2106 3_0_0 EXIST::FUNCTION:TS OCSP_ONEREQ_add1_ext_i2d 2107 3_0_0 EXIST::FUNCTION:OCSP ENGINE_register_pkey_meths 2108 3_0_0 EXIST::FUNCTION:ENGINE ENGINE_load_public_key 2109 3_0_0 EXIST::FUNCTION:ENGINE -ASIdOrRange_it 2110 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RFC3779 -ASIdOrRange_it 2110 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RFC3779 +ASIdOrRange_it 2110 3_0_0 EXIST::FUNCTION:RFC3779 DHparams_print_fp 2111 3_0_0 EXIST::FUNCTION:DH,STDIO ERR_load_CRYPTO_strings 2112 3_0_0 EXIST:!VMS:FUNCTION: ERR_load_CRYPTOlib_strings 2112 3_0_0 EXIST:VMS:FUNCTION: @@ -2151,8 +2082,7 @@ EVP_mdc2 2127 3_0_0 EXIST::FUNCTION:MDC2 EVP_des_cfb64 2128 3_0_0 EXIST::FUNCTION:DES PKCS7_sign 2129 3_0_0 EXIST::FUNCTION: OCSP_SINGLERESP_get_ext_by_critical 2130 3_0_0 EXIST::FUNCTION:OCSP -EDIPARTYNAME_it 2131 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -EDIPARTYNAME_it 2131 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +EDIPARTYNAME_it 2131 3_0_0 EXIST::FUNCTION: ERR_print_errors_fp 2132 3_0_0 EXIST::FUNCTION:STDIO BN_GF2m_mod_div_arr 2133 3_0_0 EXIST::FUNCTION:EC2M PKCS12_SAFEBAG_get0_attr 2134 3_0_0 EXIST::FUNCTION: @@ -2168,12 +2098,10 @@ SEED_cbc_encrypt 2143 3_0_0 EXIST::FUNCTION:SEED EVP_rc2_40_cbc 2144 3_0_0 EXIST::FUNCTION:RC2 ECDSA_SIG_new 2145 3_0_0 EXIST::FUNCTION:EC i2d_PKCS8PrivateKey_nid_fp 2146 3_0_0 EXIST::FUNCTION:STDIO -X509_NAME_ENTRY_it 2147 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_NAME_ENTRY_it 2147 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_NAME_ENTRY_it 2147 3_0_0 EXIST::FUNCTION: CRYPTO_THREAD_compare_id 2148 3_0_0 EXIST::FUNCTION: d2i_IPAddressChoice 2149 3_0_0 EXIST::FUNCTION:RFC3779 -IPAddressFamily_it 2150 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RFC3779 -IPAddressFamily_it 2150 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RFC3779 +IPAddressFamily_it 2150 3_0_0 EXIST::FUNCTION:RFC3779 ERR_load_OCSP_strings 2151 3_0_0 EXIST::FUNCTION:OCSP BIO_push 2152 3_0_0 EXIST::FUNCTION: ASN1_BMPSTRING_new 2153 3_0_0 EXIST::FUNCTION: @@ -2189,10 +2117,8 @@ OPENSSL_sk_set 2162 3_0_0 EXIST::FUNCTION: OCSP_request_sign 2163 3_0_0 EXIST::FUNCTION:OCSP BN_GF2m_mod_solve_quad 2164 3_0_0 EXIST::FUNCTION:EC2M EC_POINT_method_of 2165 3_0_0 EXIST::FUNCTION:EC -PKCS7_ENCRYPT_it 2166 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_ENCRYPT_it 2166 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -AUTHORITY_INFO_ACCESS_it 2167 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -AUTHORITY_INFO_ACCESS_it 2167 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_ENCRYPT_it 2166 3_0_0 EXIST::FUNCTION: +AUTHORITY_INFO_ACCESS_it 2167 3_0_0 EXIST::FUNCTION: X509_EXTENSION_create_by_NID 2168 3_0_0 EXIST::FUNCTION: i2d_RSAPrivateKey 2169 3_0_0 EXIST::FUNCTION:RSA d2i_CERTIFICATEPOLICIES 2170 3_0_0 EXIST::FUNCTION: @@ -2206,8 +2132,7 @@ OCSP_ONEREQ_get_ext 2177 3_0_0 EXIST::FUNCTION:OCSP BN_get_rfc3526_prime_4096 2179 3_0_0 EXIST::FUNCTION: d2i_PKCS7_fp 2180 3_0_0 EXIST::FUNCTION:STDIO PEM_write_bio_NETSCAPE_CERT_SEQUENCE 2181 3_0_0 EXIST::FUNCTION: -PKCS12_AUTHSAFES_it 2182 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS12_AUTHSAFES_it 2182 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS12_AUTHSAFES_it 2182 3_0_0 EXIST::FUNCTION: EVP_MD_CTX_free 2183 3_0_0 EXIST::FUNCTION: CMS_RecipientInfo_kari_orig_id_cmp 2184 3_0_0 EXIST::FUNCTION:CMS NETSCAPE_SPKI_b64_encode 2185 3_0_0 EXIST::FUNCTION: @@ -2269,8 +2194,7 @@ SRP_VBASE_init 2241 3_0_0 EXIST::FUNCTION:SRP SHA224_Final 2242 3_0_0 EXIST::FUNCTION: OCSP_CERTSTATUS_free 2243 3_0_0 EXIST::FUNCTION:OCSP d2i_TS_TST_INFO 2244 3_0_0 EXIST::FUNCTION:TS -IPAddressOrRange_it 2245 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RFC3779 -IPAddressOrRange_it 2245 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RFC3779 +IPAddressOrRange_it 2245 3_0_0 EXIST::FUNCTION:RFC3779 ENGINE_get_cipher 2246 3_0_0 EXIST::FUNCTION:ENGINE TS_TST_INFO_delete_ext 2247 3_0_0 EXIST::FUNCTION:TS TS_OBJ_print_bio 2248 3_0_0 EXIST::FUNCTION:TS @@ -2280,8 +2204,7 @@ ERR_load_X509_strings 2251 3_0_0 EXIST::FUNCTION: SHA1_Transform 2252 3_0_0 EXIST::FUNCTION: CMS_signed_get_attr_by_NID 2253 3_0_0 EXIST::FUNCTION:CMS X509_STORE_CTX_get_by_subject 2254 3_0_0 EXIST::FUNCTION: -ASN1_OCTET_STRING_it 2255 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_OCTET_STRING_it 2255 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_OCTET_STRING_it 2255 3_0_0 EXIST::FUNCTION: OPENSSL_sk_set_cmp_func 2256 3_0_0 EXIST::FUNCTION: X509_VERIFY_PARAM_table_cleanup 2257 3_0_0 EXIST::FUNCTION: i2d_re_X509_REQ_tbs 2258 3_0_0 EXIST::FUNCTION: @@ -2295,8 +2218,7 @@ ERR_get_state 2265 3_0_0 EXIST::FUNCTION: d2i_DSAPrivateKey_bio 2266 3_0_0 EXIST::FUNCTION:DSA X509_PURPOSE_get_trust 2267 3_0_0 EXIST::FUNCTION: EC_GROUP_get_point_conversion_form 2268 3_0_0 EXIST::FUNCTION:EC -ASN1_OBJECT_it 2269 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_OBJECT_it 2269 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_OBJECT_it 2269 3_0_0 EXIST::FUNCTION: BN_mod_add_quick 2270 3_0_0 EXIST::FUNCTION: NCONF_free 2271 3_0_0 EXIST::FUNCTION: NETSCAPE_SPKI_b64_decode 2272 3_0_0 EXIST::FUNCTION: @@ -2389,8 +2311,7 @@ EVP_PKEY_up_ref 2359 3_0_0 EXIST::FUNCTION: X509_getm_notBefore 2360 3_0_0 EXIST::FUNCTION: BN_nist_mod_224 2361 3_0_0 EXIST::FUNCTION: DES_decrypt3 2362 3_0_0 EXIST::FUNCTION:DES -OTHERNAME_it 2363 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -OTHERNAME_it 2363 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +OTHERNAME_it 2363 3_0_0 EXIST::FUNCTION: X509at_add1_attr_by_txt 2364 3_0_0 EXIST::FUNCTION: PKCS7_SIGN_ENVELOPE_free 2365 3_0_0 EXIST::FUNCTION: BIO_dgram_is_sctp 2366 3_0_0 EXIST::FUNCTION:DGRAM,SCTP @@ -2404,8 +2325,7 @@ DES_encrypt3 2373 3_0_0 EXIST::FUNCTION:DES PKCS7_get_signer_info 2374 3_0_0 EXIST::FUNCTION: ASN1_OCTET_STRING_set 2375 3_0_0 EXIST::FUNCTION: BN_mask_bits 2376 3_0_0 EXIST::FUNCTION: -ASN1_UTF8STRING_it 2377 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_UTF8STRING_it 2377 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_UTF8STRING_it 2377 3_0_0 EXIST::FUNCTION: ASN1_SCTX_set_app_data 2378 3_0_0 EXIST::FUNCTION: CMS_add0_cert 2379 3_0_0 EXIST::FUNCTION:CMS i2d_GENERAL_NAME 2380 3_0_0 EXIST::FUNCTION: @@ -2451,8 +2371,7 @@ i2d_OCSP_CERTSTATUS 2421 3_0_0 EXIST::FUNCTION:OCSP X509_REVOKED_get0_revocationDate 2422 3_0_0 EXIST::FUNCTION: PKCS7_add_crl 2423 3_0_0 EXIST::FUNCTION: ECDSA_do_sign 2424 3_0_0 EXIST::FUNCTION:EC -ASN1_GENERALIZEDTIME_it 2425 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_GENERALIZEDTIME_it 2425 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_GENERALIZEDTIME_it 2425 3_0_0 EXIST::FUNCTION: PKCS8_pkey_get0 2426 3_0_0 EXIST::FUNCTION: OCSP_sendreq_new 2427 3_0_0 EXIST::FUNCTION:OCSP EVP_aes_256_cfb128 2428 3_0_0 EXIST::FUNCTION: @@ -2472,8 +2391,7 @@ BN_hex2bn 2441 3_0_0 EXIST::FUNCTION: EVP_CIPHER_meth_set_impl_ctx_size 2442 3_0_0 EXIST::FUNCTION: ASIdentifiers_new 2443 3_0_0 EXIST::FUNCTION:RFC3779 CONF_imodule_get_flags 2444 3_0_0 EXIST::FUNCTION: -PKCS12_SAFEBAG_it 2445 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS12_SAFEBAG_it 2445 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS12_SAFEBAG_it 2445 3_0_0 EXIST::FUNCTION: EVP_CIPHER_meth_set_set_asn1_params 2446 3_0_0 EXIST::FUNCTION: EC_KEY_get_enc_flags 2447 3_0_0 EXIST::FUNCTION:EC X509_OBJECT_idx_by_subject 2448 3_0_0 EXIST::FUNCTION: @@ -2483,8 +2401,7 @@ CRYPTO_ocb128_decrypt 2451 3_0_0 EXIST::FUNCTION:OCB ASYNC_WAIT_CTX_free 2452 3_0_0 EXIST::FUNCTION: d2i_PKCS7_DIGEST 2453 3_0_0 EXIST::FUNCTION: d2i_TS_TST_INFO_bio 2454 3_0_0 EXIST::FUNCTION:TS -BIGNUM_it 2455 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -BIGNUM_it 2455 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +BIGNUM_it 2455 3_0_0 EXIST::FUNCTION: BN_BLINDING_get_flags 2456 3_0_0 EXIST::FUNCTION: X509_EXTENSION_get_critical 2457 3_0_0 EXIST::FUNCTION: DSA_set_default_method 2458 3_0_0 EXIST::FUNCTION:DSA @@ -2500,8 +2417,7 @@ X509_signature_print 2467 3_0_0 EXIST::FUNCTION: EVP_camellia_128_ecb 2468 3_0_0 EXIST::FUNCTION:CAMELLIA MD2_Final 2469 3_0_0 EXIST::FUNCTION:MD2 OCSP_REQ_CTX_add1_header 2470 3_0_0 EXIST::FUNCTION:OCSP -NETSCAPE_SPKAC_it 2471 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -NETSCAPE_SPKAC_it 2471 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +NETSCAPE_SPKAC_it 2471 3_0_0 EXIST::FUNCTION: ASIdOrRange_free 2472 3_0_0 EXIST::FUNCTION:RFC3779 EC_POINT_get_Jprojective_coordinates_GFp 2473 3_0_0 EXIST::FUNCTION:EC EVP_aes_128_cbc_hmac_sha256 2474 3_0_0 EXIST::FUNCTION: @@ -2510,8 +2426,7 @@ TS_VERIFY_CTX_set_data 2476 3_0_0 EXIST::FUNCTION:TS BN_pseudo_rand_range 2477 3_0_0 EXIST::FUNCTION: X509V3_EXT_add_nconf 2478 3_0_0 EXIST::FUNCTION: EVP_CIPHER_CTX_ctrl 2479 3_0_0 EXIST::FUNCTION: -ASN1_T61STRING_it 2480 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_T61STRING_it 2480 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_T61STRING_it 2480 3_0_0 EXIST::FUNCTION: ENGINE_get_prev 2481 3_0_0 EXIST::FUNCTION:ENGINE OCSP_accept_responses_new 2482 3_0_0 EXIST::FUNCTION:OCSP ERR_load_EC_strings 2483 3_0_0 EXIST::FUNCTION:EC @@ -2607,8 +2522,7 @@ ASN1_item_ex_d2i 2575 3_0_0 EXIST::FUNCTION: EVP_MD_meth_free 2576 3_0_0 EXIST::FUNCTION: EVP_PKEY_meth_new 2577 3_0_0 EXIST::FUNCTION: RSA_padding_check_PKCS1_OAEP 2578 3_0_0 EXIST::FUNCTION:RSA -OCSP_SERVICELOC_it 2579 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_SERVICELOC_it 2579 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_SERVICELOC_it 2579 3_0_0 EXIST::FUNCTION:OCSP PKCS12_SAFEBAG_get_nid 2580 3_0_0 EXIST::FUNCTION: EVP_MD_CTX_set_update_fn 2581 3_0_0 EXIST::FUNCTION: BIO_f_asn1 2582 3_0_0 EXIST::FUNCTION: @@ -2635,21 +2549,18 @@ DH_set_method 2602 3_0_0 EXIST::FUNCTION:DH EVP_rc2_64_cbc 2603 3_0_0 EXIST::FUNCTION:RC2 CRYPTO_THREAD_get_current_id 2604 3_0_0 EXIST::FUNCTION: EVP_PKEY_CTX_set_cb 2605 3_0_0 EXIST::FUNCTION: -PROXY_POLICY_it 2606 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PROXY_POLICY_it 2606 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PROXY_POLICY_it 2606 3_0_0 EXIST::FUNCTION: ENGINE_register_complete 2607 3_0_0 EXIST::FUNCTION:ENGINE EVP_DecodeUpdate 2609 3_0_0 EXIST::FUNCTION: ENGINE_get_default_RAND 2610 3_0_0 EXIST::FUNCTION:ENGINE ERR_peek_last_error_line 2611 3_0_0 EXIST::FUNCTION: ENGINE_get_ssl_client_cert_function 2612 3_0_0 EXIST::FUNCTION:ENGINE OPENSSL_LH_node_usage_stats 2613 3_0_0 EXIST::FUNCTION:STDIO -DIRECTORYSTRING_it 2614 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -DIRECTORYSTRING_it 2614 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +DIRECTORYSTRING_it 2614 3_0_0 EXIST::FUNCTION: BIO_write 2615 3_0_0 EXIST::FUNCTION: OCSP_ONEREQ_get_ext_by_OBJ 2616 3_0_0 EXIST::FUNCTION:OCSP SEED_encrypt 2617 3_0_0 EXIST::FUNCTION:SEED -IPAddressRange_it 2618 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RFC3779 -IPAddressRange_it 2618 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RFC3779 +IPAddressRange_it 2618 3_0_0 EXIST::FUNCTION:RFC3779 PEM_read_bio_DSAPrivateKey 2619 3_0_0 EXIST::FUNCTION:DSA CMS_get0_type 2620 3_0_0 EXIST::FUNCTION:CMS ASN1_PCTX_free 2621 3_0_0 EXIST::FUNCTION: @@ -2663,10 +2574,8 @@ OBJ_add_sigid 2628 3_0_0 EXIST::FUNCTION: d2i_SXNETID 2629 3_0_0 EXIST::FUNCTION: CMS_get1_certs 2630 3_0_0 EXIST::FUNCTION:CMS X509_CRL_check_suiteb 2631 3_0_0 EXIST::FUNCTION: -PKCS7_ENVELOPE_it 2632 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_ENVELOPE_it 2632 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -ASIdentifierChoice_it 2633 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RFC3779 -ASIdentifierChoice_it 2633 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RFC3779 +PKCS7_ENVELOPE_it 2632 3_0_0 EXIST::FUNCTION: +ASIdentifierChoice_it 2633 3_0_0 EXIST::FUNCTION:RFC3779 CMS_RecipientEncryptedKey_cert_cmp 2634 3_0_0 EXIST::FUNCTION:CMS EVP_PKEY_CTX_get_app_data 2635 3_0_0 EXIST::FUNCTION: EC_GROUP_clear_free 2636 3_0_0 EXIST::FUNCTION:EC @@ -2679,8 +2588,7 @@ EVP_PKEY_meth_add0 2642 3_0_0 EXIST::FUNCTION: EVP_rc4_40 2643 3_0_0 EXIST::FUNCTION:RC4 RSA_bits 2645 3_0_0 EXIST::FUNCTION:RSA ASN1_item_dup 2646 3_0_0 EXIST::FUNCTION: -GENERAL_NAMES_it 2647 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -GENERAL_NAMES_it 2647 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +GENERAL_NAMES_it 2647 3_0_0 EXIST::FUNCTION: X509_issuer_name_hash 2648 3_0_0 EXIST::FUNCTION: TS_TST_INFO_get_nonce 2649 3_0_0 EXIST::FUNCTION:TS MD4_Init 2650 3_0_0 EXIST::FUNCTION:MD4 @@ -2713,15 +2621,13 @@ i2d_EXTENDED_KEY_USAGE 2677 3_0_0 EXIST::FUNCTION: PEM_write_bio_DSAparams 2678 3_0_0 EXIST::FUNCTION:DSA X509_cmp_time 2679 3_0_0 EXIST::FUNCTION: d2i_CMS_ReceiptRequest 2680 3_0_0 EXIST::FUNCTION:CMS -X509_CRL_INFO_it 2681 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_CRL_INFO_it 2681 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_CRL_INFO_it 2681 3_0_0 EXIST::FUNCTION: BUF_reverse 2682 3_0_0 EXIST::FUNCTION: d2i_OCSP_SIGNATURE 2683 3_0_0 EXIST::FUNCTION:OCSP X509_REQ_delete_attr 2684 3_0_0 EXIST::FUNCTION: TS_RESP_CTX_set_signer_cert 2685 3_0_0 EXIST::FUNCTION:TS X509V3_EXT_d2i 2686 3_0_0 EXIST::FUNCTION: -ASN1_GENERALSTRING_it 2687 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_GENERALSTRING_it 2687 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_GENERALSTRING_it 2687 3_0_0 EXIST::FUNCTION: POLICYQUALINFO_free 2688 3_0_0 EXIST::FUNCTION: EC_KEY_set_group 2689 3_0_0 EXIST::FUNCTION:EC OCSP_check_validity 2690 3_0_0 EXIST::FUNCTION:OCSP @@ -2768,8 +2674,7 @@ CMS_ContentInfo_print_ctx 2730 3_0_0 EXIST::FUNCTION:CMS d2i_PKCS7_SIGNED 2731 3_0_0 EXIST::FUNCTION: GENERAL_NAMES_free 2732 3_0_0 EXIST::FUNCTION: SCT_get_timestamp 2733 3_0_0 EXIST::FUNCTION:CT -OCSP_SIGNATURE_it 2734 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_SIGNATURE_it 2734 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_SIGNATURE_it 2734 3_0_0 EXIST::FUNCTION:OCSP CMS_verify_receipt 2735 3_0_0 EXIST::FUNCTION:CMS CRYPTO_THREAD_lock_new 2736 3_0_0 EXIST::FUNCTION: BIO_get_ex_data 2737 3_0_0 EXIST::FUNCTION: @@ -2792,8 +2697,7 @@ TS_REQ_get_policy_id 2753 3_0_0 EXIST::FUNCTION:TS RC5_32_cbc_encrypt 2754 3_0_0 EXIST::FUNCTION:RC5 BN_is_zero 2755 3_0_0 EXIST::FUNCTION: CT_POLICY_EVAL_CTX_new 2756 3_0_0 EXIST::FUNCTION:CT -NETSCAPE_SPKI_it 2757 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -NETSCAPE_SPKI_it 2757 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +NETSCAPE_SPKI_it 2757 3_0_0 EXIST::FUNCTION: CRYPTO_THREAD_unlock 2758 3_0_0 EXIST::FUNCTION: UI_method_set_writer 2759 3_0_0 EXIST::FUNCTION: UI_dup_info_string 2760 3_0_0 EXIST::FUNCTION: @@ -2804,24 +2708,20 @@ EVP_SealFinal 2764 3_0_0 EXIST::FUNCTION:RSA CONF_imodule_set_flags 2766 3_0_0 EXIST::FUNCTION: i2d_ASN1_SET_ANY 2767 3_0_0 EXIST::FUNCTION: EVP_PKEY_decrypt 2768 3_0_0 EXIST::FUNCTION: -OCSP_RESPID_it 2769 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_RESPID_it 2769 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_RESPID_it 2769 3_0_0 EXIST::FUNCTION:OCSP EVP_des_ede3_cbc 2770 3_0_0 EXIST::FUNCTION:DES X509_up_ref 2771 3_0_0 EXIST::FUNCTION: OBJ_NAME_do_all_sorted 2772 3_0_0 EXIST::FUNCTION: ENGINE_unregister_DSA 2773 3_0_0 EXIST::FUNCTION:ENGINE ASN1_bn_print 2774 3_0_0 EXIST::FUNCTION: CMS_is_detached 2775 3_0_0 EXIST::FUNCTION:CMS -X509_REQ_INFO_it 2776 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_REQ_INFO_it 2776 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -RSAPrivateKey_it 2777 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA -RSAPrivateKey_it 2777 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RSA +X509_REQ_INFO_it 2776 3_0_0 EXIST::FUNCTION: +RSAPrivateKey_it 2777 3_0_0 EXIST::FUNCTION:RSA X509_NAME_ENTRY_free 2778 3_0_0 EXIST::FUNCTION: BIO_new_fd 2779 3_0_0 EXIST::FUNCTION: OPENSSL_sk_value 2781 3_0_0 EXIST::FUNCTION: NCONF_get_section 2782 3_0_0 EXIST::FUNCTION: -PKCS12_MAC_DATA_it 2783 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS12_MAC_DATA_it 2783 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS12_MAC_DATA_it 2783 3_0_0 EXIST::FUNCTION: X509_REQ_add1_attr_by_NID 2784 3_0_0 EXIST::FUNCTION: ASN1_sign 2785 3_0_0 EXIST::FUNCTION: CMS_RecipientInfo_encrypt 2786 3_0_0 EXIST::FUNCTION:CMS @@ -2840,8 +2740,7 @@ X509_REQ_get0_signature 2799 3_0_0 EXIST::FUNCTION: PKEY_USAGE_PERIOD_free 2800 3_0_0 EXIST::FUNCTION: EC_GROUP_set_point_conversion_form 2801 3_0_0 EXIST::FUNCTION:EC CMS_dataFinal 2802 3_0_0 EXIST::FUNCTION:CMS -ASN1_TIME_it 2803 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_TIME_it 2803 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_TIME_it 2803 3_0_0 EXIST::FUNCTION: ENGINE_get_static_state 2804 3_0_0 EXIST::FUNCTION:ENGINE EC_KEY_set_asn1_flag 2805 3_0_0 EXIST::FUNCTION:EC EC_GFp_mont_method 2806 3_0_0 EXIST::FUNCTION:EC @@ -2890,13 +2789,11 @@ ASN1_UNIVERSALSTRING_free 2849 3_0_0 EXIST::FUNCTION: EC_KEY_precompute_mult 2850 3_0_0 EXIST::FUNCTION:EC CRYPTO_mem_debug_realloc 2851 3_0_0 EXIST::FUNCTION:CRYPTO_MDEBUG PKCS7_new 2852 3_0_0 EXIST::FUNCTION: -BASIC_CONSTRAINTS_it 2853 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -BASIC_CONSTRAINTS_it 2853 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +BASIC_CONSTRAINTS_it 2853 3_0_0 EXIST::FUNCTION: ASN1_generate_v3 2854 3_0_0 EXIST::FUNCTION: PEM_write_bio_PrivateKey 2855 3_0_0 EXIST::FUNCTION: ASN1_UTCTIME_check 2856 3_0_0 EXIST::FUNCTION: -ACCESS_DESCRIPTION_it 2857 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ACCESS_DESCRIPTION_it 2857 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ACCESS_DESCRIPTION_it 2857 3_0_0 EXIST::FUNCTION: TS_MSG_IMPRINT_get_msg 2859 3_0_0 EXIST::FUNCTION:TS PKCS8_add_keyusage 2860 3_0_0 EXIST::FUNCTION: X509_EXTENSION_dup 2861 3_0_0 EXIST::FUNCTION: @@ -2918,8 +2815,7 @@ NCONF_get_number_e 2876 3_0_0 EXIST::FUNCTION: OPENSSL_cleanse 2877 3_0_0 EXIST::FUNCTION: SCT_set0_signature 2878 3_0_0 EXIST::FUNCTION:CT X509_CRL_sign 2879 3_0_0 EXIST::FUNCTION: -X509_CINF_it 2880 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_CINF_it 2880 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_CINF_it 2880 3_0_0 EXIST::FUNCTION: TS_CONF_set_accuracy 2881 3_0_0 EXIST::FUNCTION:TS DES_crypt 2882 3_0_0 EXIST::FUNCTION:DES BN_BLINDING_create_param 2883 3_0_0 EXIST::FUNCTION: @@ -2927,8 +2823,7 @@ OCSP_SERVICELOC_free 2884 3_0_0 EXIST::FUNCTION:OCSP DIST_POINT_NAME_free 2885 3_0_0 EXIST::FUNCTION: BIO_listen 2886 3_0_0 EXIST::FUNCTION:SOCK BIO_ADDR_path_string 2887 3_0_0 EXIST::FUNCTION:SOCK -POLICY_CONSTRAINTS_it 2888 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -POLICY_CONSTRAINTS_it 2888 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +POLICY_CONSTRAINTS_it 2888 3_0_0 EXIST::FUNCTION: NCONF_free_data 2889 3_0_0 EXIST::FUNCTION: BIO_asn1_set_prefix 2890 3_0_0 EXIST::FUNCTION: PEM_SignUpdate 2891 3_0_0 EXIST::FUNCTION: @@ -2938,8 +2833,7 @@ IPAddressChoice_free 2894 3_0_0 EXIST::FUNCTION:RFC3779 d2i_X509_AUX 2895 3_0_0 EXIST::FUNCTION: X509_get_default_cert_area 2896 3_0_0 EXIST::FUNCTION: ERR_load_DSO_strings 2897 3_0_0 EXIST::FUNCTION: -ASIdentifiers_it 2898 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RFC3779 -ASIdentifiers_it 2898 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RFC3779 +ASIdentifiers_it 2898 3_0_0 EXIST::FUNCTION:RFC3779 BN_mod_lshift 2899 3_0_0 EXIST::FUNCTION: ENGINE_get_last 2900 3_0_0 EXIST::FUNCTION:ENGINE EVP_PKEY_encrypt_init 2901 3_0_0 EXIST::FUNCTION: @@ -2959,8 +2853,7 @@ X509_PUBKEY_get0 2914 3_0_0 EXIST::FUNCTION: X509_STORE_CTX_get0_parent_ctx 2915 3_0_0 EXIST::FUNCTION: EC_GROUP_set_seed 2916 3_0_0 EXIST::FUNCTION:EC X509_STORE_CTX_free 2917 3_0_0 EXIST::FUNCTION: -AUTHORITY_KEYID_it 2918 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -AUTHORITY_KEYID_it 2918 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +AUTHORITY_KEYID_it 2918 3_0_0 EXIST::FUNCTION: X509V3_get_value_int 2919 3_0_0 EXIST::FUNCTION: ASN1_UTCTIME_set_string 2920 3_0_0 EXIST::FUNCTION: RC5_32_decrypt 2921 3_0_0 EXIST::FUNCTION:RC5 @@ -3013,8 +2906,7 @@ SHA384_Init 2968 3_0_0 EXIST::FUNCTION: ASN1_UNIVERSALSTRING_new 2969 3_0_0 EXIST::FUNCTION: EVP_PKEY_print_private 2970 3_0_0 EXIST::FUNCTION: ASN1_INTEGER_new 2971 3_0_0 EXIST::FUNCTION: -NAME_CONSTRAINTS_it 2972 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -NAME_CONSTRAINTS_it 2972 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +NAME_CONSTRAINTS_it 2972 3_0_0 EXIST::FUNCTION: TS_REQ_get_cert_req 2973 3_0_0 EXIST::FUNCTION:TS BIO_pop 2974 3_0_0 EXIST::FUNCTION: SHA256_Final 2975 3_0_0 EXIST::FUNCTION: @@ -3062,8 +2954,7 @@ OCSP_request_is_signed 3017 3_0_0 EXIST::FUNCTION:OCSP i2d_BASIC_CONSTRAINTS 3018 3_0_0 EXIST::FUNCTION: EC_KEY_get_method 3019 3_0_0 EXIST::FUNCTION:EC EC_POINT_bn2point 3021 3_0_0 EXIST::FUNCTION:EC -PBE2PARAM_it 3022 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PBE2PARAM_it 3022 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PBE2PARAM_it 3022 3_0_0 EXIST::FUNCTION: BN_rand 3023 3_0_0 EXIST::FUNCTION: ASN1_TYPE_unpack_sequence 3024 3_0_0 EXIST::FUNCTION: X509_CRL_sign_ctx 3025 3_0_0 EXIST::FUNCTION: @@ -3075,8 +2966,7 @@ PEM_write_bio_PKCS8PrivateKey_nid 3030 3_0_0 EXIST::FUNCTION: BN_MONT_CTX_new 3031 3_0_0 EXIST::FUNCTION: CRYPTO_free_ex_index 3032 3_0_0 EXIST::FUNCTION: ASYNC_WAIT_CTX_new 3033 3_0_0 EXIST::FUNCTION: -PKCS7_it 3034 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_it 3034 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_it 3034 3_0_0 EXIST::FUNCTION: CMS_unsigned_get_attr_by_OBJ 3035 3_0_0 EXIST::FUNCTION:CMS BN_clear 3036 3_0_0 EXIST::FUNCTION: BIO_socket_ioctl 3037 3_0_0 EXIST::FUNCTION:SOCK @@ -3084,8 +2974,7 @@ GENERAL_NAME_cmp 3038 3_0_0 EXIST::FUNCTION: X509_STORE_CTX_set_purpose 3039 3_0_0 EXIST::FUNCTION: X509_REVOKED_get_ext_d2i 3040 3_0_0 EXIST::FUNCTION: X509V3_set_conf_lhash 3041 3_0_0 EXIST::FUNCTION: -PKCS7_ENC_CONTENT_it 3042 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_ENC_CONTENT_it 3042 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_ENC_CONTENT_it 3042 3_0_0 EXIST::FUNCTION: PKCS12_item_pack_safebag 3043 3_0_0 EXIST::FUNCTION: i2d_OCSP_RESPDATA 3044 3_0_0 EXIST::FUNCTION:OCSP i2d_X509_PUBKEY 3045 3_0_0 EXIST::FUNCTION: @@ -3166,8 +3055,7 @@ ASN1_BIT_STRING_set 3119 3_0_0 EXIST::FUNCTION: PKCS5_PBKDF2_HMAC_SHA1 3120 3_0_0 EXIST::FUNCTION: RSA_padding_check_PKCS1_type_2 3121 3_0_0 EXIST::FUNCTION:RSA EVP_des_ede3_ecb 3122 3_0_0 EXIST::FUNCTION:DES -CBIGNUM_it 3123 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -CBIGNUM_it 3123 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +CBIGNUM_it 3123 3_0_0 EXIST::FUNCTION: BIO_new_NDEF 3124 3_0_0 EXIST::FUNCTION: EVP_aes_256_wrap 3125 3_0_0 EXIST::FUNCTION: ASN1_STRING_print 3126 3_0_0 EXIST::FUNCTION: @@ -3296,8 +3184,7 @@ EVP_aes_192_ecb 3249 3_0_0 EXIST::FUNCTION: ASN1_OCTET_STRING_new 3250 3_0_0 EXIST::FUNCTION: CMS_set1_eContentType 3251 3_0_0 EXIST::FUNCTION:CMS EVP_des_ede3_wrap 3252 3_0_0 EXIST::FUNCTION:DES -GENERAL_SUBTREE_it 3253 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -GENERAL_SUBTREE_it 3253 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +GENERAL_SUBTREE_it 3253 3_0_0 EXIST::FUNCTION: EVP_read_pw_string_min 3254 3_0_0 EXIST::FUNCTION: X509_set1_notBefore 3255 3_0_0 EXIST::FUNCTION: MD4 3256 3_0_0 EXIST::FUNCTION:MD4 @@ -3342,8 +3229,7 @@ i2s_ASN1_IA5STRING 3295 3_0_0 EXIST::FUNCTION: EC_KEY_get_default_method 3296 3_0_0 EXIST::FUNCTION:EC PKCS8_decrypt 3297 3_0_0 EXIST::FUNCTION: EVP_PKEY_CTX_get_data 3298 3_0_0 EXIST::FUNCTION: -POLICYQUALINFO_it 3299 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -POLICYQUALINFO_it 3299 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +POLICYQUALINFO_it 3299 3_0_0 EXIST::FUNCTION: PKCS7_ISSUER_AND_SERIAL_free 3300 3_0_0 EXIST::FUNCTION: DSA_SIG_free 3301 3_0_0 EXIST::FUNCTION:DSA BIO_asn1_set_suffix 3302 3_0_0 EXIST::FUNCTION: @@ -3393,8 +3279,7 @@ OCSP_SERVICELOC_new 3346 3_0_0 EXIST::FUNCTION:OCSP ASN1_VISIBLESTRING_new 3347 3_0_0 EXIST::FUNCTION: BN_set_flags 3348 3_0_0 EXIST::FUNCTION: d2i_PrivateKey_bio 3349 3_0_0 EXIST::FUNCTION: -ASN1_SEQUENCE_ANY_it 3350 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_SEQUENCE_ANY_it 3350 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_SEQUENCE_ANY_it 3350 3_0_0 EXIST::FUNCTION: ASN1_UTCTIME_adj 3351 3_0_0 EXIST::FUNCTION: BN_mod_sqrt 3352 3_0_0 EXIST::FUNCTION: OPENSSL_sk_is_sorted 3353 3_0_0 EXIST::FUNCTION: @@ -3419,15 +3304,13 @@ CMS_add1_cert 3371 3_0_0 EXIST::FUNCTION:CMS DSO_convert_filename 3372 3_0_0 EXIST::FUNCTION: RSA_padding_check_SSLv23 3373 3_0_0 EXIST::FUNCTION:RSA CRYPTO_gcm128_finish 3374 3_0_0 EXIST::FUNCTION: -PKCS12_SAFEBAGS_it 3375 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS12_SAFEBAGS_it 3375 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS12_SAFEBAGS_it 3375 3_0_0 EXIST::FUNCTION: PKCS12_PBE_add 3376 3_0_0 EXIST::FUNCTION: EC_KEY_set_public_key_affine_coordinates 3377 3_0_0 EXIST::FUNCTION:EC EVP_EncryptInit_ex 3378 3_0_0 EXIST::FUNCTION: ENGINE_add 3379 3_0_0 EXIST::FUNCTION:ENGINE OPENSSL_LH_error 3380 3_0_0 EXIST::FUNCTION: -PKCS7_DIGEST_it 3381 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_DIGEST_it 3381 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_DIGEST_it 3381 3_0_0 EXIST::FUNCTION: X509_CINF_new 3382 3_0_0 EXIST::FUNCTION: EVP_PKEY_keygen_init 3383 3_0_0 EXIST::FUNCTION: EVP_aes_192_ocb 3384 3_0_0 EXIST::FUNCTION:OCB @@ -3560,8 +3443,7 @@ EVP_PKEY_add1_attr_by_NID 3513 3_0_0 EXIST::FUNCTION: i2d_PKCS8_PRIV_KEY_INFO_bio 3514 3_0_0 EXIST::FUNCTION: X509_NAME_get_index_by_NID 3515 3_0_0 EXIST::FUNCTION: ENGINE_get_first 3516 3_0_0 EXIST::FUNCTION:ENGINE -CERTIFICATEPOLICIES_it 3517 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -CERTIFICATEPOLICIES_it 3517 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +CERTIFICATEPOLICIES_it 3517 3_0_0 EXIST::FUNCTION: EVP_MD_CTX_ctrl 3518 3_0_0 EXIST::FUNCTION: PKCS7_final 3519 3_0_0 EXIST::FUNCTION: EVP_PKEY_size 3520 3_0_0 EXIST::FUNCTION: @@ -3608,10 +3490,8 @@ RAND_file_name 3564 3_0_0 EXIST::FUNCTION: EVP_CipherInit_ex 3566 3_0_0 EXIST::FUNCTION: BIO_dgram_sctp_notification_cb 3567 3_0_0 EXIST::FUNCTION:DGRAM,SCTP ERR_load_RAND_strings 3568 3_0_0 EXIST::FUNCTION: -X509_ATTRIBUTE_it 3569 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_ATTRIBUTE_it 3569 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -X509_ALGOR_it 3570 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_ALGOR_it 3570 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_ATTRIBUTE_it 3569 3_0_0 EXIST::FUNCTION: +X509_ALGOR_it 3570 3_0_0 EXIST::FUNCTION: OCSP_CRLID_free 3571 3_0_0 EXIST::FUNCTION:OCSP CRYPTO_ccm128_aad 3572 3_0_0 EXIST::FUNCTION: IPAddressFamily_new 3573 3_0_0 EXIST::FUNCTION:RFC3779 @@ -3635,8 +3515,7 @@ X509_issuer_and_serial_cmp 3590 3_0_0 EXIST::FUNCTION: OCSP_response_create 3591 3_0_0 EXIST::FUNCTION:OCSP SHA224 3592 3_0_0 EXIST::FUNCTION: MD2_options 3593 3_0_0 EXIST::FUNCTION:MD2 -X509_REQ_it 3595 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -X509_REQ_it 3595 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +X509_REQ_it 3595 3_0_0 EXIST::FUNCTION: RAND_bytes 3596 3_0_0 EXIST::FUNCTION: PKCS7_free 3597 3_0_0 EXIST::FUNCTION: X509_NAME_ENTRY_create_by_txt 3598 3_0_0 EXIST::FUNCTION: @@ -3682,8 +3561,7 @@ PEM_read_PUBKEY 3638 3_0_0 EXIST::FUNCTION:STDIO RSA_PKCS1_OpenSSL 3639 3_0_0 EXIST::FUNCTION:RSA AUTHORITY_INFO_ACCESS_free 3640 3_0_0 EXIST::FUNCTION: SCT_get0_signature 3641 3_0_0 EXIST::FUNCTION:CT -DISPLAYTEXT_it 3643 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -DISPLAYTEXT_it 3643 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +DISPLAYTEXT_it 3643 3_0_0 EXIST::FUNCTION: OPENSSL_gmtime_adj 3644 3_0_0 EXIST::FUNCTION: ASN1_INTEGER_dup 3645 3_0_0 EXIST::FUNCTION: DSA_print 3646 3_0_0 EXIST::FUNCTION:DSA @@ -3741,8 +3619,7 @@ OCSP_sendreq_nbio 3698 3_0_0 EXIST::FUNCTION:OCSP PKCS8_encrypt 3699 3_0_0 EXIST::FUNCTION: i2d_PKCS7_fp 3700 3_0_0 EXIST::FUNCTION:STDIO i2d_X509_REQ 3701 3_0_0 EXIST::FUNCTION: -OCSP_CRLID_it 3702 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_CRLID_it 3702 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_CRLID_it 3702 3_0_0 EXIST::FUNCTION:OCSP PEM_ASN1_write_bio 3703 3_0_0 EXIST::FUNCTION: X509_get0_reject_objects 3704 3_0_0 EXIST::FUNCTION: BIO_set_tcp_ndelay 3705 3_0_0 EXIST::FUNCTION:SOCK @@ -3752,8 +3629,7 @@ X509_CRL_get0_by_serial 3708 3_0_0 EXIST::FUNCTION: PKCS12_add_friendlyname_asc 3709 3_0_0 EXIST::FUNCTION: X509_STORE_CTX_get1_chain 3710 3_0_0 EXIST::FUNCTION: ASN1_mbstring_ncopy 3711 3_0_0 EXIST::FUNCTION: -PKCS7_RECIP_INFO_it 3712 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_RECIP_INFO_it 3712 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_RECIP_INFO_it 3712 3_0_0 EXIST::FUNCTION: ENGINE_register_all_digests 3713 3_0_0 EXIST::FUNCTION:ENGINE X509_REQ_get_version 3714 3_0_0 EXIST::FUNCTION: i2d_ASN1_UTCTIME 3715 3_0_0 EXIST::FUNCTION: @@ -3811,8 +3687,7 @@ BIO_ADDRINFO_family 3766 3_0_0 EXIST::FUNCTION:SOCK PEM_write_DHxparams 3767 3_0_0 EXIST::FUNCTION:DH,STDIO BN_mod_exp2_mont 3768 3_0_0 EXIST::FUNCTION: ASN1_PRINTABLE_free 3769 3_0_0 EXIST::FUNCTION: -PKCS7_ATTR_SIGN_it 3771 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKCS7_ATTR_SIGN_it 3771 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PKCS7_ATTR_SIGN_it 3771 3_0_0 EXIST::FUNCTION: EVP_MD_CTX_copy 3772 3_0_0 EXIST::FUNCTION: ENGINE_set_ctrl_function 3773 3_0_0 EXIST::FUNCTION:ENGINE OCSP_id_get0_info 3774 3_0_0 EXIST::FUNCTION:OCSP @@ -3820,8 +3695,7 @@ BIO_ADDRINFO_next 3775 3_0_0 EXIST::FUNCTION:SOCK OCSP_RESPBYTES_free 3776 3_0_0 EXIST::FUNCTION:OCSP EC_KEY_METHOD_set_init 3777 3_0_0 EXIST::FUNCTION:EC EVP_PKEY_asn1_copy 3778 3_0_0 EXIST::FUNCTION: -RSA_PSS_PARAMS_it 3779 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA -RSA_PSS_PARAMS_it 3779 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RSA +RSA_PSS_PARAMS_it 3779 3_0_0 EXIST::FUNCTION:RSA X509_STORE_CTX_get_error_depth 3780 3_0_0 EXIST::FUNCTION: ASN1_GENERALIZEDTIME_set_string 3781 3_0_0 EXIST::FUNCTION: EC_GROUP_new_curve_GFp 3782 3_0_0 EXIST::FUNCTION:EC @@ -3851,10 +3725,8 @@ EVP_bf_ecb 3805 3_0_0 EXIST::FUNCTION:BF v2i_GENERAL_NAME_ex 3806 3_0_0 EXIST::FUNCTION: CMS_signed_delete_attr 3807 3_0_0 EXIST::FUNCTION:CMS ASN1_TYPE_pack_sequence 3808 3_0_0 EXIST::FUNCTION: -USERNOTICE_it 3809 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -USERNOTICE_it 3809 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -PKEY_USAGE_PERIOD_it 3810 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PKEY_USAGE_PERIOD_it 3810 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +USERNOTICE_it 3809 3_0_0 EXIST::FUNCTION: +PKEY_USAGE_PERIOD_it 3810 3_0_0 EXIST::FUNCTION: BN_mul_word 3811 3_0_0 EXIST::FUNCTION: i2d_IPAddressRange 3813 3_0_0 EXIST::FUNCTION:RFC3779 CMS_unsigned_add1_attr_by_txt 3814 3_0_0 EXIST::FUNCTION:CMS @@ -3862,8 +3734,7 @@ d2i_RSA_PUBKEY 3815 3_0_0 EXIST::FUNCTION:RSA PKCS12_gen_mac 3816 3_0_0 EXIST::FUNCTION: ERR_load_ENGINE_strings 3817 3_0_0 EXIST::FUNCTION:ENGINE ERR_load_CT_strings 3818 3_0_0 EXIST::FUNCTION:CT -OCSP_ONEREQ_it 3819 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_ONEREQ_it 3819 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_ONEREQ_it 3819 3_0_0 EXIST::FUNCTION:OCSP X509_PURPOSE_get_by_sname 3820 3_0_0 EXIST::FUNCTION: X509_PURPOSE_set 3821 3_0_0 EXIST::FUNCTION: BN_mod_inverse 3822 3_0_0 EXIST::FUNCTION: @@ -3906,10 +3777,8 @@ i2o_ECPublicKey 3858 3_0_0 EXIST::FUNCTION:EC PKCS12_SAFEBAG_create0_pkcs8 3859 3_0_0 EXIST::FUNCTION: OBJ_get0_data 3860 3_0_0 EXIST::FUNCTION: EC_GROUP_get0_seed 3861 3_0_0 EXIST::FUNCTION:EC -OCSP_REQUEST_it 3862 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_REQUEST_it 3862 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP -ASRange_it 3863 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RFC3779 -ASRange_it 3863 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RFC3779 +OCSP_REQUEST_it 3862 3_0_0 EXIST::FUNCTION:OCSP +ASRange_it 3863 3_0_0 EXIST::FUNCTION:RFC3779 i2d_TS_RESP 3864 3_0_0 EXIST::FUNCTION:TS TS_TST_INFO_get_ext_by_OBJ 3865 3_0_0 EXIST::FUNCTION:TS d2i_PKCS7_RECIP_INFO 3866 3_0_0 EXIST::FUNCTION: @@ -3917,8 +3786,7 @@ d2i_X509_CRL 3867 3_0_0 EXIST::FUNCTION: ASN1_OCTET_STRING_dup 3868 3_0_0 EXIST::FUNCTION: CRYPTO_nistcts128_decrypt_block 3869 3_0_0 EXIST::FUNCTION: CMS_stream 3870 3_0_0 EXIST::FUNCTION:CMS -RSA_OAEP_PARAMS_it 3871 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA -RSA_OAEP_PARAMS_it 3871 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RSA +RSA_OAEP_PARAMS_it 3871 3_0_0 EXIST::FUNCTION:RSA BN_bn2mpi 3872 3_0_0 EXIST::FUNCTION: X509_STORE_CTX_cleanup 3873 3_0_0 EXIST::FUNCTION: OCSP_onereq_get0_id 3874 3_0_0 EXIST::FUNCTION:OCSP @@ -3930,8 +3798,7 @@ CMS_add0_RevocationInfoChoice 3880 3_0_0 EXIST::FUNCTION:CMS ASN1_PCTX_get_flags 3881 3_0_0 EXIST::FUNCTION: EVP_MD_meth_set_result_size 3882 3_0_0 EXIST::FUNCTION: i2d_X509_CRL 3883 3_0_0 EXIST::FUNCTION: -ASN1_INTEGER_it 3885 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ASN1_INTEGER_it 3885 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ASN1_INTEGER_it 3885 3_0_0 EXIST::FUNCTION: TS_ACCURACY_new 3886 3_0_0 EXIST::FUNCTION:TS i2d_SXNETID 3887 3_0_0 EXIST::FUNCTION: BN_mod_mul_montgomery 3888 3_0_0 EXIST::FUNCTION: @@ -3941,8 +3808,7 @@ PBKDF2PARAM_new 3891 3_0_0 EXIST::FUNCTION: ENGINE_set_RSA 3892 3_0_0 EXIST::FUNCTION:ENGINE i2d_X509_ATTRIBUTE 3893 3_0_0 EXIST::FUNCTION: PKCS7_ctrl 3894 3_0_0 EXIST::FUNCTION: -OCSP_REVOKEDINFO_it 3895 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:OCSP -OCSP_REVOKEDINFO_it 3895 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:OCSP +OCSP_REVOKEDINFO_it 3895 3_0_0 EXIST::FUNCTION:OCSP X509V3_set_ctx 3896 3_0_0 EXIST::FUNCTION: ASN1_ENUMERATED_set_int64 3897 3_0_0 EXIST::FUNCTION: o2i_SCT 3898 3_0_0 EXIST::FUNCTION:CT @@ -3969,13 +3835,10 @@ BN_BLINDING_unlock 3918 3_0_0 EXIST::FUNCTION: EC_GROUP_new_from_ecpkparameters 3919 3_0_0 EXIST::FUNCTION:EC EC_GROUP_get_ecpkparameters 3920 3_0_0 EXIST::FUNCTION:EC EC_GROUP_new_from_ecparameters 3921 3_0_0 EXIST::FUNCTION:EC -ECPARAMETERS_it 3922 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:EC -ECPARAMETERS_it 3922 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:EC -ECPKPARAMETERS_it 3923 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:EC -ECPKPARAMETERS_it 3923 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:EC +ECPARAMETERS_it 3922 3_0_0 EXIST::FUNCTION:EC +ECPKPARAMETERS_it 3923 3_0_0 EXIST::FUNCTION:EC EC_GROUP_get_ecparameters 3924 3_0_0 EXIST::FUNCTION:EC -DHparams_it 3925 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DH -DHparams_it 3925 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DH +DHparams_it 3925 3_0_0 EXIST::FUNCTION:DH EVP_blake2s256 3926 3_0_0 EXIST::FUNCTION:BLAKE2 EVP_blake2b512 3927 3_0_0 EXIST::FUNCTION:BLAKE2 X509_SIG_get0 3928 3_0_0 EXIST::FUNCTION: @@ -4253,22 +4116,14 @@ EVP_aria_128_ctr 4204 3_0_0 EXIST::FUNCTION:ARIA EVP_aria_192_ctr 4205 3_0_0 EXIST::FUNCTION:ARIA UI_null 4206 3_0_0 EXIST::FUNCTION: EC_KEY_get0_engine 4207 3_0_0 EXIST::FUNCTION:EC -INT32_it 4208 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -INT32_it 4208 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -UINT64_it 4209 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -UINT64_it 4209 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -ZINT32_it 4210 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ZINT32_it 4210 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -ZUINT64_it 4211 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ZUINT64_it 4211 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -INT64_it 4212 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -INT64_it 4212 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -ZUINT32_it 4213 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ZUINT32_it 4213 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -UINT32_it 4214 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -UINT32_it 4214 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: -ZINT64_it 4215 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ZINT64_it 4215 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +INT32_it 4208 3_0_0 EXIST::FUNCTION: +UINT64_it 4209 3_0_0 EXIST::FUNCTION: +ZINT32_it 4210 3_0_0 EXIST::FUNCTION: +ZUINT64_it 4211 3_0_0 EXIST::FUNCTION: +INT64_it 4212 3_0_0 EXIST::FUNCTION: +ZUINT32_it 4213 3_0_0 EXIST::FUNCTION: +UINT32_it 4214 3_0_0 EXIST::FUNCTION: +ZINT64_it 4215 3_0_0 EXIST::FUNCTION: CRYPTO_mem_leaks_cb 4216 3_0_0 EXIST::FUNCTION:CRYPTO_MDEBUG BIO_lookup_ex 4217 3_0_0 EXIST::FUNCTION:SOCK X509_CRL_print_ex 4218 3_0_0 EXIST::FUNCTION: @@ -4364,8 +4219,7 @@ SCRYPT_PARAMS_new 4310 3_0_0 EXIST::FUNCTION:SCRYPT SCRYPT_PARAMS_free 4311 3_0_0 EXIST::FUNCTION:SCRYPT i2d_SCRYPT_PARAMS 4312 3_0_0 EXIST::FUNCTION:SCRYPT d2i_SCRYPT_PARAMS 4313 3_0_0 EXIST::FUNCTION:SCRYPT -SCRYPT_PARAMS_it 4314 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:SCRYPT -SCRYPT_PARAMS_it 4314 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:SCRYPT +SCRYPT_PARAMS_it 4314 3_0_0 EXIST::FUNCTION:SCRYPT CRYPTO_secure_clear_free 4315 3_0_0 EXIST::FUNCTION: EVP_PKEY_meth_get0 4316 3_0_0 EXIST::FUNCTION: EVP_PKEY_meth_get_count 4317 3_0_0 EXIST::FUNCTION: @@ -4435,8 +4289,7 @@ d2i_ADMISSION_SYNTAX 4384 3_0_0 EXIST::FUNCTION: NAMING_AUTHORITY_set0_authorityId 4385 3_0_0 EXIST::FUNCTION: NAMING_AUTHORITY_set0_authorityURL 4386 3_0_0 EXIST::FUNCTION: d2i_PROFESSION_INFO 4387 3_0_0 EXIST::FUNCTION: -NAMING_AUTHORITY_it 4388 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -NAMING_AUTHORITY_it 4388 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +NAMING_AUTHORITY_it 4388 3_0_0 EXIST::FUNCTION: ADMISSION_SYNTAX_get0_contentsOfAdmissions 4389 3_0_0 EXIST::FUNCTION: PROFESSION_INFO_set0_professionItems 4390 3_0_0 EXIST::FUNCTION: NAMING_AUTHORITY_new 4391 3_0_0 EXIST::FUNCTION: @@ -4446,8 +4299,7 @@ PROFESSION_INFO_new 4394 3_0_0 EXIST::FUNCTION: ADMISSIONS_new 4395 3_0_0 EXIST::FUNCTION: ADMISSION_SYNTAX_set0_admissionAuthority 4396 3_0_0 EXIST::FUNCTION: PROFESSION_INFO_get0_professionOIDs 4397 3_0_0 EXIST::FUNCTION: -PROFESSION_INFO_it 4398 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -PROFESSION_INFO_it 4398 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +PROFESSION_INFO_it 4398 3_0_0 EXIST::FUNCTION: i2d_PROFESSION_INFO 4399 3_0_0 EXIST::FUNCTION: ADMISSIONS_set0_professionInfos 4400 3_0_0 EXIST::FUNCTION: PROFESSION_INFO_get0_namingAuthority 4401 3_0_0 EXIST::FUNCTION: @@ -4456,8 +4308,7 @@ PROFESSION_INFO_set0_addProfessionInfo 4403 3_0_0 EXIST::FUNCTION: PROFESSION_INFO_set0_registrationNumber 4404 3_0_0 EXIST::FUNCTION: ADMISSION_SYNTAX_set0_contentsOfAdmissions 4405 3_0_0 EXIST::FUNCTION: NAMING_AUTHORITY_get0_authorityId 4406 3_0_0 EXIST::FUNCTION: -ADMISSION_SYNTAX_it 4407 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ADMISSION_SYNTAX_it 4407 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ADMISSION_SYNTAX_it 4407 3_0_0 EXIST::FUNCTION: i2d_ADMISSION_SYNTAX 4408 3_0_0 EXIST::FUNCTION: NAMING_AUTHORITY_get0_authorityText 4409 3_0_0 EXIST::FUNCTION: PROFESSION_INFO_set0_namingAuthority 4410 3_0_0 EXIST::FUNCTION: @@ -4472,8 +4323,7 @@ PROFESSION_INFO_get0_professionItems 4418 3_0_0 EXIST::FUNCTION: ADMISSIONS_get0_admissionAuthority 4419 3_0_0 EXIST::FUNCTION: PROFESSION_INFO_set0_professionOIDs 4420 3_0_0 EXIST::FUNCTION: d2i_NAMING_AUTHORITY 4421 3_0_0 EXIST::FUNCTION: -ADMISSIONS_it 4422 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: -ADMISSIONS_it 4422 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: +ADMISSIONS_it 4422 3_0_0 EXIST::FUNCTION: ADMISSIONS_get0_namingAuthority 4423 3_0_0 EXIST::FUNCTION: NAMING_AUTHORITY_set0_authorityText 4424 3_0_0 EXIST::FUNCTION: ADMISSIONS_set0_namingAuthority 4425 3_0_0 EXIST::FUNCTION: @@ -4578,7 +4428,7 @@ EVP_PKEY_meth_get_digest_custom 4533 3_0_0 EXIST::FUNCTION: EVP_MAC_CTX_new 4534 3_0_0 EXIST::FUNCTION: EVP_MAC_CTX_new_id 4535 3_0_0 EXIST::FUNCTION: EVP_MAC_CTX_free 4536 3_0_0 EXIST::FUNCTION: -EVP_MAC_CTX_copy 4537 3_0_0 EXIST::FUNCTION: +EVP_MAC_CTX_dup 4537 3_0_0 EXIST::FUNCTION: EVP_MAC_CTX_mac 4538 3_0_0 EXIST::FUNCTION: EVP_MAC_size 4539 3_0_0 EXIST::FUNCTION: EVP_MAC_init 4540 3_0_0 EXIST::FUNCTION: @@ -4609,17 +4459,17 @@ OPENSSL_version_build_metadata 4564 3_0_0 EXIST::FUNCTION: EVP_aes_128_siv 4565 3_0_0 EXIST::FUNCTION:SIV EVP_aes_192_siv 4566 3_0_0 EXIST::FUNCTION:SIV EVP_aes_256_siv 4567 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_new 4568 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_init 4569 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_copy_ctx 4570 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_aad 4571 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_encrypt 4572 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_decrypt 4573 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_finish 4574 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_set_tag 4575 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_get_tag 4576 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_cleanup 4577 3_0_0 EXIST::FUNCTION:SIV -CRYPTO_siv128_speed 4578 3_0_0 EXIST::FUNCTION:SIV +CRYPTO_siv128_new 4568 3_0_0 NOEXIST::FUNCTION:SIV +CRYPTO_siv128_init 4569 3_0_0 NOEXIST::FUNCTION:SIV +CRYPTO_siv128_copy_ctx 4570 3_0_0 NOEXIST::FUNCTION:SIV +CRYPTO_siv128_aad 4571 3_0_0 NOEXIST::FUNCTION:SIV +CRYPTO_siv128_encrypt 4572 3_0_0 NOEXIST::FUNCTION:SIV +CRYPTO_siv128_decrypt 4573 3_0_0 NOEXIST::FUNCTION:SIV +CRYPTO_siv128_finish 4574 3_0_0 NOEXIST::FUNCTION:SIV +CRYPTO_siv128_set_tag 4575 3_0_0 NOEXIST::FUNCTION:SIV +CRYPTO_siv128_get_tag 4576 3_0_0 NOEXIST::FUNCTION:SIV +CRYPTO_siv128_cleanup 4577 3_0_0 NOEXIST::FUNCTION:SIV +CRYPTO_siv128_speed 4578 3_0_0 NOEXIST::FUNCTION:SIV OPENSSL_INIT_set_config_filename 4579 3_0_0 EXIST::FUNCTION:STDIO OPENSSL_INIT_set_config_file_flags 4580 3_0_0 EXIST::FUNCTION:STDIO ASYNC_WAIT_CTX_get_callback 4581 3_0_0 EXIST::FUNCTION: @@ -4664,148 +4514,168 @@ d2i_OSSL_CRMF_ENCRYPTEDVALUE 4619 3_0_0 EXIST::FUNCTION:CRMF i2d_OSSL_CRMF_ENCRYPTEDVALUE 4620 3_0_0 EXIST::FUNCTION:CRMF OSSL_CRMF_ENCRYPTEDVALUE_free 4621 3_0_0 EXIST::FUNCTION:CRMF OSSL_CRMF_ENCRYPTEDVALUE_new 4622 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_ENCRYPTEDVALUE_it 4623 3_0_0 NOEXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CMP -OSSL_CRMF_ENCRYPTEDVALUE_it 4624 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CRMF -OSSL_CRMF_ENCRYPTEDVALUE_it 4624 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CRMF -d2i_OSSL_CRMF_MSG 4625 3_0_0 EXIST::FUNCTION:CRMF -i2d_OSSL_CRMF_MSG 4626 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_free 4627 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_new 4628 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_it 4629 3_0_0 NOEXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CMP -OSSL_CRMF_MSG_it 4630 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CRMF -OSSL_CRMF_MSG_it 4630 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CRMF -d2i_OSSL_CRMF_PBMPARAMETER 4631 3_0_0 EXIST::FUNCTION:CRMF -i2d_OSSL_CRMF_PBMPARAMETER 4632 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_PBMPARAMETER_free 4633 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_PBMPARAMETER_new 4634 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_PBMPARAMETER_it 4635 3_0_0 NOEXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CMP -OSSL_CRMF_PBMPARAMETER_it 4636 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CRMF -OSSL_CRMF_PBMPARAMETER_it 4636 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CRMF -d2i_OSSL_CRMF_CERTID 4637 3_0_0 EXIST::FUNCTION:CRMF -i2d_OSSL_CRMF_CERTID 4638 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_CERTID_free 4639 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_CERTID_new 4640 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_CERTID_it 4641 3_0_0 NOEXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CMP -OSSL_CRMF_CERTID_it 4642 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CRMF -OSSL_CRMF_CERTID_it 4642 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CRMF -d2i_OSSL_CRMF_PKIPUBLICATIONINFO 4643 3_0_0 EXIST::FUNCTION:CRMF -i2d_OSSL_CRMF_PKIPUBLICATIONINFO 4644 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_PKIPUBLICATIONINFO_free 4645 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_PKIPUBLICATIONINFO_new 4646 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_PKIPUBLICATIONINFO_it 4647 3_0_0 NOEXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CMP -OSSL_CRMF_PKIPUBLICATIONINFO_it 4648 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CRMF -OSSL_CRMF_PKIPUBLICATIONINFO_it 4648 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CRMF -d2i_OSSL_CRMF_SINGLEPUBINFO 4649 3_0_0 EXIST::FUNCTION:CRMF -i2d_OSSL_CRMF_SINGLEPUBINFO 4650 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_SINGLEPUBINFO_free 4651 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_SINGLEPUBINFO_new 4652 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_SINGLEPUBINFO_it 4653 3_0_0 NOEXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CMP -OSSL_CRMF_SINGLEPUBINFO_it 4654 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CRMF -OSSL_CRMF_SINGLEPUBINFO_it 4654 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CRMF -d2i_OSSL_CRMF_CERTTEMPLATE 4655 3_0_0 EXIST::FUNCTION:CRMF -i2d_OSSL_CRMF_CERTTEMPLATE 4656 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_CERTTEMPLATE_free 4657 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_CERTTEMPLATE_new 4658 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_CERTTEMPLATE_it 4659 3_0_0 NOEXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CMP -OSSL_CRMF_CERTTEMPLATE_it 4660 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CRMF -OSSL_CRMF_CERTTEMPLATE_it 4660 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CRMF -d2i_OSSL_CRMF_MSGS 4661 3_0_0 EXIST::FUNCTION:CRMF -i2d_OSSL_CRMF_MSGS 4662 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSGS_free 4663 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSGS_new 4664 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSGS_it 4665 3_0_0 NOEXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CMP -OSSL_CRMF_MSGS_it 4666 3_0_0 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:CRMF -OSSL_CRMF_MSGS_it 4666 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CRMF -OSSL_CRMF_pbmp_new 4667 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_pbm_new 4668 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set1_regCtrl_regToken 4669 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set1_regCtrl_authenticator 4670 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo 4671 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set0_SinglePubInfo 4672 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set_PKIPublicationInfo_action 4673 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo 4674 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey 4675 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set1_regCtrl_oldCertID 4676 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_CERTID_gen 4677 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set1_regInfo_utf8Pairs 4678 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set1_regInfo_certReq 4679 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set_validity 4680 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set_certReqId 4681 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_get_certReqId 4682 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_set0_extensions 4683 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_push0_extension 4684 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_create_popo 4685 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSGS_verify_popo 4686 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_MSG_get0_tmpl 4687 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_CERTTEMPLATE_get0_serialNumber 4688 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_CERTTEMPLATE_get0_issuer 4689 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_CERTTEMPLATE_fill 4690 3_0_0 EXIST::FUNCTION:CRMF -OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert 4691 3_0_0 EXIST::FUNCTION:CRMF -ERR_load_CRMF_strings 4692 3_0_0 EXIST::FUNCTION:CRMF -OSSL_PARAM_locate 4693 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_int 4694 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_uint 4695 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_long 4696 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_ulong 4697 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_int32 4698 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_uint32 4699 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_int64 4700 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_uint64 4701 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_size_t 4702 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_BN 4703 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_double 4704 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_utf8_string 4705 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_utf8_ptr 4706 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_octet_string 4707 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_octet_ptr 4708 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_int 4709 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_uint 4710 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_long 4711 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_ulong 4712 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_int32 4713 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_uint32 4714 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_int64 4715 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_uint64 4716 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_size_t 4717 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_int 4718 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_uint 4719 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_long 4720 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_ulong 4721 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_int32 4722 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_uint32 4723 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_int64 4724 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_uint64 4725 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_size_t 4726 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_double 4727 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_double 4728 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_BN 4729 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_BN 4730 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_utf8_string 4731 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_utf8_string 4732 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_octet_string 4733 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_octet_string 4734 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_utf8_ptr 4735 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_utf8_ptr 4736 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_get_octet_ptr 4737 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_set_octet_ptr 4738 3_0_0 EXIST::FUNCTION: -X509_set0_sm2_id 4739 3_0_0 EXIST::FUNCTION:SM2 -X509_get0_sm2_id 4740 3_0_0 EXIST::FUNCTION:SM2 -EVP_PKEY_get0_engine 4741 3_0_0 EXIST::FUNCTION:ENGINE -EVP_MD_upref 4742 3_0_0 EXIST::FUNCTION: -EVP_MD_fetch 4743 3_0_0 EXIST::FUNCTION: -EVP_set_default_properties 4744 3_0_0 EXIST::FUNCTION: -OSSL_PARAM_construct_end 4745 3_0_0 EXIST::FUNCTION: -EC_GROUP_check_named_curve 4746 3_0_0 EXIST::FUNCTION:EC -EVP_CIPHER_upref 4747 3_0_0 EXIST::FUNCTION: -EVP_CIPHER_fetch 4748 3_0_0 EXIST::FUNCTION: -EVP_CIPHER_mode 4749 3_0_0 EXIST::FUNCTION: -OPENSSL_info 4750 3_0_0 EXIST::FUNCTION: -EVP_KDF_CTX_new 4751 3_0_0 EXIST::FUNCTION: -EVP_KDF_CTX_kdf 4752 3_0_0 EXIST::FUNCTION: -EVP_KDF_nid 4753 3_0_0 EXIST::FUNCTION: -EVP_get_kdfbyname 4754 3_0_0 EXIST::FUNCTION: -i2d_KeyParams 4755 3_0_0 EXIST::FUNCTION: -d2i_KeyParams 4756 3_0_0 EXIST::FUNCTION: -i2d_KeyParams_bio 4757 3_0_0 EXIST::FUNCTION: -d2i_KeyParams_bio 4758 3_0_0 EXIST::FUNCTION: -EVP_chacha20_poly1305_draft 4759 3_0_0 EXIST::FUNCTION:CHACHA,POLY1305 +OSSL_CRMF_ENCRYPTEDVALUE_it 4623 3_0_0 EXIST::FUNCTION:CRMF +d2i_OSSL_CRMF_MSG 4624 3_0_0 EXIST::FUNCTION:CRMF +i2d_OSSL_CRMF_MSG 4625 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_free 4626 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_new 4627 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_it 4628 3_0_0 EXIST::FUNCTION:CRMF +d2i_OSSL_CRMF_PBMPARAMETER 4629 3_0_0 EXIST::FUNCTION:CRMF +i2d_OSSL_CRMF_PBMPARAMETER 4630 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_PBMPARAMETER_free 4631 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_PBMPARAMETER_new 4632 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_PBMPARAMETER_it 4633 3_0_0 EXIST::FUNCTION:CRMF +d2i_OSSL_CRMF_CERTID 4634 3_0_0 EXIST::FUNCTION:CRMF +i2d_OSSL_CRMF_CERTID 4635 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_CERTID_free 4636 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_CERTID_new 4637 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_CERTID_it 4638 3_0_0 EXIST::FUNCTION:CRMF +d2i_OSSL_CRMF_PKIPUBLICATIONINFO 4639 3_0_0 EXIST::FUNCTION:CRMF +i2d_OSSL_CRMF_PKIPUBLICATIONINFO 4640 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_PKIPUBLICATIONINFO_free 4641 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_PKIPUBLICATIONINFO_new 4642 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_PKIPUBLICATIONINFO_it 4643 3_0_0 EXIST::FUNCTION:CRMF +d2i_OSSL_CRMF_SINGLEPUBINFO 4644 3_0_0 EXIST::FUNCTION:CRMF +i2d_OSSL_CRMF_SINGLEPUBINFO 4645 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_SINGLEPUBINFO_free 4646 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_SINGLEPUBINFO_new 4647 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_SINGLEPUBINFO_it 4648 3_0_0 EXIST::FUNCTION:CRMF +d2i_OSSL_CRMF_CERTTEMPLATE 4649 3_0_0 EXIST::FUNCTION:CRMF +i2d_OSSL_CRMF_CERTTEMPLATE 4650 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_CERTTEMPLATE_free 4651 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_CERTTEMPLATE_new 4652 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_CERTTEMPLATE_it 4653 3_0_0 EXIST::FUNCTION:CRMF +d2i_OSSL_CRMF_MSGS 4654 3_0_0 EXIST::FUNCTION:CRMF +i2d_OSSL_CRMF_MSGS 4655 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSGS_free 4656 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSGS_new 4657 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSGS_it 4658 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_pbmp_new 4659 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_pbm_new 4660 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set1_regCtrl_regToken 4661 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set1_regCtrl_authenticator 4662 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo 4663 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set0_SinglePubInfo 4664 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set_PKIPublicationInfo_action 4665 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo 4666 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey 4667 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set1_regCtrl_oldCertID 4668 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_CERTID_gen 4669 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set1_regInfo_utf8Pairs 4670 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set1_regInfo_certReq 4671 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set_validity 4672 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set_certReqId 4673 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_get_certReqId 4674 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_set0_extensions 4675 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_push0_extension 4676 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_create_popo 4677 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSGS_verify_popo 4678 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_MSG_get0_tmpl 4679 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_CERTTEMPLATE_get0_serialNumber 4680 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_CERTTEMPLATE_get0_issuer 4681 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_CERTTEMPLATE_fill 4682 3_0_0 EXIST::FUNCTION:CRMF +OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert 4683 3_0_0 EXIST::FUNCTION:CRMF +ERR_load_CRMF_strings 4684 3_0_0 EXIST::FUNCTION:CRMF +OSSL_PARAM_locate 4685 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_int 4686 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_uint 4687 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_long 4688 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_ulong 4689 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_int32 4690 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_uint32 4691 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_int64 4692 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_uint64 4693 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_size_t 4694 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_BN 4695 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_double 4696 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_utf8_string 4697 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_utf8_ptr 4698 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_octet_string 4699 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_octet_ptr 4700 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_int 4701 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_uint 4702 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_long 4703 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_ulong 4704 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_int32 4705 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_uint32 4706 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_int64 4707 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_uint64 4708 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_size_t 4709 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_int 4710 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_uint 4711 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_long 4712 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_ulong 4713 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_int32 4714 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_uint32 4715 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_int64 4716 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_uint64 4717 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_size_t 4718 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_double 4719 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_double 4720 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_BN 4721 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_BN 4722 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_utf8_string 4723 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_utf8_string 4724 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_octet_string 4725 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_octet_string 4726 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_utf8_ptr 4727 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_utf8_ptr 4728 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_get_octet_ptr 4729 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_set_octet_ptr 4730 3_0_0 EXIST::FUNCTION: +X509_set0_sm2_id 4731 3_0_0 EXIST::FUNCTION:SM2 +X509_get0_sm2_id 4732 3_0_0 EXIST::FUNCTION:SM2 +EVP_PKEY_get0_engine 4733 3_0_0 EXIST::FUNCTION:ENGINE +EVP_MD_up_ref 4734 3_0_0 EXIST::FUNCTION: +EVP_MD_fetch 4735 3_0_0 EXIST::FUNCTION: +EVP_set_default_properties 4736 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_construct_end 4737 3_0_0 EXIST::FUNCTION: +EC_GROUP_check_named_curve 4738 3_0_0 EXIST::FUNCTION:EC +EVP_CIPHER_up_ref 4739 3_0_0 EXIST::FUNCTION: +EVP_CIPHER_fetch 4740 3_0_0 EXIST::FUNCTION: +EVP_CIPHER_mode 4741 3_0_0 EXIST::FUNCTION: +OPENSSL_info 4742 3_0_0 EXIST::FUNCTION: +EVP_KDF_CTX_new 4743 3_0_0 EXIST::FUNCTION: +EVP_KDF_CTX_kdf 4744 3_0_0 EXIST::FUNCTION: +EVP_KDF_nid 4745 3_0_0 EXIST::FUNCTION: +EVP_get_kdfbyname 4746 3_0_0 EXIST::FUNCTION: +i2d_KeyParams 4747 3_0_0 EXIST::FUNCTION: +d2i_KeyParams 4748 3_0_0 EXIST::FUNCTION: +i2d_KeyParams_bio 4749 3_0_0 EXIST::FUNCTION: +d2i_KeyParams_bio 4750 3_0_0 EXIST::FUNCTION: +OSSL_CMP_PKISTATUS_it 4751 3_0_0 EXIST::FUNCTION:CMP +d2i_OSSL_CMP_PKIHEADER 4752 3_0_0 EXIST::FUNCTION:CMP +i2d_OSSL_CMP_PKIHEADER 4753 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_PKIHEADER_free 4754 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_PKIHEADER_new 4755 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_PKIHEADER_it 4756 3_0_0 EXIST::FUNCTION:CMP +d2i_OSSL_CMP_MSG 4757 3_0_0 EXIST::FUNCTION:CMP +i2d_OSSL_CMP_MSG 4758 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_MSG_it 4759 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_ITAV_create 4760 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_ITAV_set0 4761 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_ITAV_get0_type 4762 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_ITAV_get0_value 4763 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_ITAV_push0_stack_item 4764 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_ITAV_free 4765 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_MSG_free 4766 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_PKISI_free 4767 3_0_0 EXIST::FUNCTION:CMP +OSSL_CMP_MSG_dup 4768 3_0_0 EXIST::FUNCTION:CMP +ERR_load_CMP_strings 4769 3_0_0 EXIST::FUNCTION:CMP +EVP_MD_CTX_set_params 4770 3_0_0 EXIST::FUNCTION: +EVP_MD_CTX_get_params 4771 3_0_0 EXIST::FUNCTION: +RAND_DRBG_new_ex 4772 3_0_0 EXIST::FUNCTION: +RAND_DRBG_secure_new_ex 4773 3_0_0 EXIST::FUNCTION: +OPENSSL_CTX_get0_master_drbg 4774 3_0_0 EXIST::FUNCTION: +OPENSSL_CTX_get0_public_drbg 4775 3_0_0 EXIST::FUNCTION: +OPENSSL_CTX_get0_private_drbg 4776 3_0_0 EXIST::FUNCTION: +BN_CTX_new_ex 4777 3_0_0 EXIST::FUNCTION: +BN_CTX_secure_new_ex 4778 3_0_0 EXIST::FUNCTION: +OPENSSL_thread_stop_ex 4779 3_0_0 EXIST::FUNCTION: +OSSL_PARAM_locate_const 4780 3_0_0 EXIST::FUNCTION: +X509_REQ_set0_sm2_id 4781 3_0_0 EXIST::FUNCTION:SM2 +X509_REQ_get0_sm2_id 4782 3_0_0 EXIST::FUNCTION:SM2 +BN_rand_ex 4783 3_0_0 EXIST::FUNCTION: +BN_priv_rand_ex 4784 3_0_0 EXIST::FUNCTION: +BN_rand_range_ex 4785 3_0_0 EXIST::FUNCTION: +BN_priv_rand_range_ex 4786 3_0_0 EXIST::FUNCTION: +EVP_chacha20_poly1305_draft 4787 3_0_0 EXIST::FUNCTION:CHACHA,POLY1305 diff --git a/util/libssl.num b/util/libssl.num index 57014116..1a80dd9a 100644 --- a/util/libssl.num +++ b/util/libssl.num @@ -504,4 +504,6 @@ SSL_set_async_callback 504 3_0_0 EXIST::FUNCTION: SSL_set_async_callback_arg 505 3_0_0 EXIST::FUNCTION: SSL_get_async_status 506 3_0_0 EXIST::FUNCTION: SSL_sendfile 507 3_0_0 EXIST::FUNCTION: -SSL_CTX_set_timeout_tls13 508 3_0_0 EXIST::FUNCTION: +OSSL_default_cipher_list 508 3_0_0 EXIST::FUNCTION: +OSSL_default_ciphersuites 509 3_0_0 EXIST::FUNCTION: +SSL_CTX_set_timeout_tls13 510 3_0_0 EXIST::FUNCTION: diff --git a/util/missingcrypto.txt b/util/missingcrypto.txt new file mode 100644 index 00000000..a227b108 --- /dev/null +++ b/util/missingcrypto.txt @@ -0,0 +1,1494 @@ +# A list of libcrypto functions that are known to be missing documentation as +# used by the find-doc-nits -v option. The list is as of commit 355b419698. +ACCESS_DESCRIPTION_it +ADMISSIONS_it +ADMISSION_SYNTAX_it +AES_bi_ige_encrypt +AES_cbc_encrypt +AES_cfb128_encrypt +AES_cfb1_encrypt +AES_cfb8_encrypt +AES_decrypt +AES_ecb_encrypt +AES_encrypt +AES_ige_encrypt +AES_ofb128_encrypt +AES_options +AES_set_decrypt_key +AES_set_encrypt_key +AES_unwrap_key +AES_wrap_key +ASIdOrRange_it +ASIdentifierChoice_it +ASIdentifiers_it +ASRange_it +AUTHORITY_INFO_ACCESS_it +AUTHORITY_KEYID_it +BASIC_CONSTRAINTS_it +BIGNUM_it +BIO_accept +BIO_asn1_get_prefix +BIO_asn1_get_suffix +BIO_asn1_set_prefix +BIO_asn1_set_suffix +BIO_clear_flags +BIO_copy_next_retry +BIO_dgram_is_sctp +BIO_dgram_non_fatal_error +BIO_dgram_sctp_msg_waiting +BIO_dgram_sctp_notification_cb +BIO_dgram_sctp_wait_for_dry +BIO_dump +BIO_dump_cb +BIO_dump_fp +BIO_dump_indent +BIO_dump_indent_cb +BIO_dump_indent_fp +BIO_dup_chain +BIO_f_asn1 +BIO_f_linebuffer +BIO_f_nbio_test +BIO_f_reliable +BIO_f_zlib +BIO_fd_non_fatal_error +BIO_fd_should_retry +BIO_get_accept_socket +BIO_get_host_ip +BIO_get_port +BIO_gethostbyname +BIO_hex_string +BIO_indent +BIO_method_name +BIO_new_NDEF +BIO_new_PKCS7 +BIO_new_dgram +BIO_new_dgram_sctp +BIO_nread +BIO_nread0 +BIO_number_read +BIO_number_written +BIO_nwrite +BIO_nwrite0 +BIO_s_datagram +BIO_s_datagram_sctp +BIO_s_log +BIO_set_flags +BIO_set_tcp_ndelay +BIO_sock_error +BIO_sock_info +BIO_sock_init +BIO_sock_non_fatal_error +BIO_sock_should_retry +BIO_socket_ioctl +BIO_socket_nbio +BIO_test_flags +BN_GF2m_add +BN_GF2m_arr2poly +BN_GF2m_mod +BN_GF2m_mod_arr +BN_GF2m_mod_div +BN_GF2m_mod_div_arr +BN_GF2m_mod_exp +BN_GF2m_mod_exp_arr +BN_GF2m_mod_inv +BN_GF2m_mod_inv_arr +BN_GF2m_mod_mul +BN_GF2m_mod_mul_arr +BN_GF2m_mod_solve_quad +BN_GF2m_mod_solve_quad_arr +BN_GF2m_mod_sqr +BN_GF2m_mod_sqr_arr +BN_GF2m_mod_sqrt +BN_GF2m_mod_sqrt_arr +BN_GF2m_poly2arr +BN_MONT_CTX_set_locked +BN_X931_derive_prime_ex +BN_X931_generate_Xpq +BN_X931_generate_prime_ex +BN_abs_is_word +BN_asc2bn +BN_bntest_rand +BN_consttime_swap +BN_generate_dsa_nonce +BN_get_flags +BN_get_params +BN_is_negative +BN_kronecker +BN_mod_add_quick +BN_mod_exp2_mont +BN_mod_exp_mont +BN_mod_exp_mont_consttime +BN_mod_exp_mont_word +BN_mod_exp_recp +BN_mod_exp_simple +BN_mod_lshift +BN_mod_lshift1 +BN_mod_lshift1_quick +BN_mod_lshift_quick +BN_mod_sqrt +BN_mod_sub_quick +BN_nist_mod_192 +BN_nist_mod_224 +BN_nist_mod_256 +BN_nist_mod_384 +BN_nist_mod_521 +BN_nist_mod_func +BN_options +BN_reciprocal +BN_set_flags +BN_set_negative +BN_set_params +BN_uadd +BN_usub +BN_zero_ex +CAST_cbc_encrypt +CAST_cfb64_encrypt +CAST_decrypt +CAST_ecb_encrypt +CAST_encrypt +CAST_ofb64_encrypt +CAST_set_key +CBIGNUM_it +CERTIFICATEPOLICIES_it +CMAC_CTX_cleanup +CMAC_CTX_copy +CMAC_CTX_free +CMAC_CTX_get0_cipher_ctx +CMAC_CTX_new +CMAC_Final +CMAC_Init +CMAC_Update +CMAC_resume +CMS_ContentInfo_it +CMS_EncryptedData_decrypt +CMS_EncryptedData_encrypt +CMS_EncryptedData_set1_key +CMS_EnvelopedData_create +CMS_ReceiptRequest_it +CMS_RecipientEncryptedKey_cert_cmp +CMS_RecipientEncryptedKey_get0_id +CMS_RecipientInfo_get0_pkey_ctx +CMS_RecipientInfo_kari_decrypt +CMS_RecipientInfo_kari_get0_alg +CMS_RecipientInfo_kari_get0_ctx +CMS_RecipientInfo_kari_get0_orig_id +CMS_RecipientInfo_kari_get0_reks +CMS_RecipientInfo_kari_orig_id_cmp +CMS_RecipientInfo_kari_set0_pkey +CMS_RecipientInfo_ktri_get0_algs +CMS_RecipientInfo_set0_password +CMS_SharedInfo_encode +CMS_SignedData_init +CMS_SignerInfo_get0_algs +CMS_SignerInfo_get0_md_ctx +CMS_SignerInfo_get0_pkey_ctx +CMS_SignerInfo_verify +CMS_SignerInfo_verify_content +CMS_add0_CertificateChoices +CMS_add0_RevocationInfoChoice +CMS_add0_recipient_password +CMS_add_simple_smimecap +CMS_add_smimecap +CMS_add_standard_smimecap +CMS_data +CMS_dataFinal +CMS_dataInit +CMS_data_create +CMS_decrypt_set1_key +CMS_decrypt_set1_password +CMS_decrypt_set1_pkey +CMS_digest_create +CMS_digest_verify +CMS_is_detached +CMS_set1_signers_certs +CMS_set_detached +CMS_signed_add1_attr +CMS_signed_add1_attr_by_NID +CMS_signed_add1_attr_by_OBJ +CMS_signed_add1_attr_by_txt +CMS_signed_delete_attr +CMS_signed_get0_data_by_OBJ +CMS_signed_get_attr +CMS_signed_get_attr_by_NID +CMS_signed_get_attr_by_OBJ +CMS_signed_get_attr_count +CMS_stream +CMS_unsigned_add1_attr +CMS_unsigned_add1_attr_by_NID +CMS_unsigned_add1_attr_by_OBJ +CMS_unsigned_add1_attr_by_txt +CMS_unsigned_delete_attr +CMS_unsigned_get0_data_by_OBJ +CMS_unsigned_get_attr +CMS_unsigned_get_attr_by_NID +CMS_unsigned_get_attr_by_OBJ +CMS_unsigned_get_attr_count +COMP_CTX_free +COMP_CTX_get_method +COMP_CTX_get_type +COMP_CTX_new +COMP_compress_block +COMP_expand_block +COMP_get_name +COMP_get_type +COMP_zlib +CONF_dump_bio +CONF_dump_fp +CONF_free +CONF_get1_default_config_file +CONF_get_number +CONF_get_section +CONF_get_string +CONF_imodule_get_flags +CONF_imodule_get_module +CONF_imodule_get_name +CONF_imodule_get_usr_data +CONF_imodule_get_value +CONF_imodule_set_flags +CONF_imodule_set_usr_data +CONF_load +CONF_load_bio +CONF_load_fp +CONF_module_add +CONF_module_get_usr_data +CONF_module_set_usr_data +CONF_parse_list +CONF_set_default_method +CONF_set_nconf +CRL_DIST_POINTS_it +CRYPTO_128_unwrap +CRYPTO_128_unwrap_pad +CRYPTO_128_wrap +CRYPTO_128_wrap_pad +CRYPTO_THREAD_cleanup_local +CRYPTO_THREAD_compare_id +CRYPTO_THREAD_get_current_id +CRYPTO_THREAD_get_local +CRYPTO_THREAD_init_local +CRYPTO_THREAD_set_local +CRYPTO_cbc128_decrypt +CRYPTO_cbc128_encrypt +CRYPTO_ccm128_aad +CRYPTO_ccm128_decrypt +CRYPTO_ccm128_decrypt_ccm64 +CRYPTO_ccm128_encrypt +CRYPTO_ccm128_encrypt_ccm64 +CRYPTO_ccm128_init +CRYPTO_ccm128_setiv +CRYPTO_ccm128_tag +CRYPTO_cfb128_1_encrypt +CRYPTO_cfb128_8_encrypt +CRYPTO_cfb128_encrypt +CRYPTO_ctr128_encrypt +CRYPTO_ctr128_encrypt_ctr32 +CRYPTO_cts128_decrypt +CRYPTO_cts128_decrypt_block +CRYPTO_cts128_encrypt +CRYPTO_cts128_encrypt_block +CRYPTO_dup_ex_data +CRYPTO_gcm128_aad +CRYPTO_gcm128_decrypt +CRYPTO_gcm128_decrypt_ctr32 +CRYPTO_gcm128_encrypt +CRYPTO_gcm128_encrypt_ctr32 +CRYPTO_gcm128_finish +CRYPTO_gcm128_init +CRYPTO_gcm128_new +CRYPTO_gcm128_release +CRYPTO_gcm128_setiv +CRYPTO_gcm128_tag +CRYPTO_mem_debug_free +CRYPTO_mem_debug_malloc +CRYPTO_mem_debug_realloc +CRYPTO_memdup +CRYPTO_nistcts128_decrypt +CRYPTO_nistcts128_decrypt_block +CRYPTO_nistcts128_encrypt +CRYPTO_nistcts128_encrypt_block +CRYPTO_ocb128_aad +CRYPTO_ocb128_cleanup +CRYPTO_ocb128_copy_ctx +CRYPTO_ocb128_decrypt +CRYPTO_ocb128_encrypt +CRYPTO_ocb128_finish +CRYPTO_ocb128_init +CRYPTO_ocb128_new +CRYPTO_ocb128_setiv +CRYPTO_ocb128_tag +CRYPTO_ofb128_encrypt +CRYPTO_secure_actual_size +CRYPTO_secure_allocated +CRYPTO_siv128_aad +CRYPTO_siv128_cleanup +CRYPTO_siv128_copy_ctx +CRYPTO_siv128_decrypt +CRYPTO_siv128_encrypt +CRYPTO_siv128_finish +CRYPTO_siv128_get_tag +CRYPTO_siv128_init +CRYPTO_siv128_new +CRYPTO_siv128_set_tag +CRYPTO_siv128_speed +CRYPTO_xts128_encrypt +Camellia_cbc_encrypt +Camellia_cfb128_encrypt +Camellia_cfb1_encrypt +Camellia_cfb8_encrypt +Camellia_ctr128_encrypt +Camellia_decrypt +Camellia_ecb_encrypt +Camellia_encrypt +Camellia_ofb128_encrypt +Camellia_set_key +DES_cbc_encrypt +DES_check_key_parity +DES_decrypt3 +DES_ede3_cfb_encrypt +DES_encrypt1 +DES_encrypt2 +DES_encrypt3 +DES_options +DH_KDF_X9_42 +DH_check_pub_key +DH_compute_key_padded +DH_up_ref +DHparams_dup +DHparams_it +DIRECTORYSTRING_it +DISPLAYTEXT_it +DIST_POINT_NAME_it +DIST_POINT_it +DIST_POINT_set_dpname +DSA_get_method +DSA_up_ref +DSO_METHOD_openssl +DSO_bind_func +DSO_convert_filename +DSO_ctrl +DSO_dsobyaddr +DSO_flags +DSO_free +DSO_get_filename +DSO_global_lookup +DSO_load +DSO_merge +DSO_new +DSO_pathbyaddr +DSO_set_filename +DSO_up_ref +ECDH_KDF_X9_62 +ECDH_compute_key +ECPARAMETERS_it +ECPKPARAMETERS_it +ECParameters_print +ECParameters_print_fp +EC_GROUP_get_mont_data +EC_KEY_METHOD_free +EC_KEY_METHOD_get_compute_key +EC_KEY_METHOD_get_init +EC_KEY_METHOD_get_keygen +EC_KEY_METHOD_get_sign +EC_KEY_METHOD_get_verify +EC_KEY_METHOD_new +EC_KEY_METHOD_set_compute_key +EC_KEY_METHOD_set_init +EC_KEY_METHOD_set_keygen +EC_KEY_METHOD_set_sign +EC_KEY_METHOD_set_verify +EC_KEY_OpenSSL +EC_KEY_can_sign +EC_KEY_get_default_method +EC_KEY_new_method +EC_KEY_print +EC_KEY_print_fp +EC_KEY_set_default_method +EC_curve_nid2nist +EC_curve_nist2nid +EDIPARTYNAME_it +ENGINE_get_EC +ENGINE_get_default_EC +ENGINE_get_pkey_asn1_meth +ENGINE_get_pkey_asn1_meth_engine +ENGINE_get_pkey_asn1_meth_str +ENGINE_get_pkey_asn1_meths +ENGINE_get_pkey_meth +ENGINE_get_pkey_meth_engine +ENGINE_get_pkey_meths +ENGINE_get_ssl_client_cert_function +ENGINE_get_static_state +ENGINE_load_ssl_client_cert +ENGINE_pkey_asn1_find_str +ENGINE_register_EC +ENGINE_register_all_EC +ENGINE_register_all_pkey_asn1_meths +ENGINE_register_all_pkey_meths +ENGINE_register_pkey_asn1_meths +ENGINE_register_pkey_meths +ENGINE_set_EC +ENGINE_set_default_EC +ENGINE_set_default_pkey_asn1_meths +ENGINE_set_default_pkey_meths +ENGINE_set_load_ssl_client_cert_function +ENGINE_set_pkey_asn1_meths +ENGINE_set_pkey_meths +ENGINE_setup_bsd_cryptodev +ENGINE_unregister_EC +ENGINE_unregister_pkey_asn1_meths +ENGINE_unregister_pkey_meths +ERR_clear_last_mark +ERR_get_state +ERR_load_ASN1_strings +ERR_load_ASYNC_strings +ERR_load_BIO_strings +ERR_load_BN_strings +ERR_load_BUF_strings +ERR_load_CMP_strings +ERR_load_CMS_strings +ERR_load_COMP_strings +ERR_load_CONF_strings +ERR_load_CRMF_strings +ERR_load_CRYPTO_strings +ERR_load_CRYPTOlib_strings +ERR_load_CT_strings +ERR_load_DH_strings +ERR_load_DSA_strings +ERR_load_DSO_strings +ERR_load_EC_strings +ERR_load_ENGINE_strings +ERR_load_ERR_strings +ERR_load_ESS_strings +ERR_load_EVP_strings +ERR_load_KDF_strings +ERR_load_OBJ_strings +ERR_load_OCSP_strings +ERR_load_OSSL_STORE_strings +ERR_load_PEM_strings +ERR_load_PKCS12_strings +ERR_load_PKCS7_strings +ERR_load_RAND_strings +ERR_load_RSA_strings +ERR_load_TS_strings +ERR_load_UI_strings +ERR_load_X509V3_strings +ERR_load_X509_strings +ERR_load_strings_const +ERR_set_error_data +ERR_unload_strings +ESS_CERT_ID_V2_dup +ESS_CERT_ID_V2_free +ESS_CERT_ID_V2_new +ESS_SIGNING_CERT_V2_dup +ESS_SIGNING_CERT_V2_free +ESS_SIGNING_CERT_V2_new +ESS_SIGNING_CERT_V2_new_init +ESS_SIGNING_CERT_new_init +EVP_CIPHER_CTX_buf_noconst +EVP_CIPHER_CTX_clear_flags +EVP_CIPHER_CTX_copy +EVP_CIPHER_CTX_encrypting +EVP_CIPHER_CTX_iv +EVP_CIPHER_CTX_iv_noconst +EVP_CIPHER_CTX_num +EVP_CIPHER_CTX_original_iv +EVP_CIPHER_CTX_rand_key +EVP_CIPHER_CTX_set_flags +EVP_CIPHER_CTX_set_num +EVP_CIPHER_CTX_test_flags +EVP_CIPHER_do_all +EVP_CIPHER_do_all_sorted +EVP_CIPHER_get_asn1_iv +EVP_CIPHER_impl_ctx_size +EVP_CIPHER_set_asn1_iv +EVP_Cipher +EVP_MAC_do_all +EVP_MAC_do_all_sorted +EVP_MD_do_all +EVP_MD_do_all_sorted +EVP_PBE_CipherInit +EVP_PBE_alg_add +EVP_PBE_alg_add_type +EVP_PBE_cleanup +EVP_PBE_find +EVP_PBE_get +EVP_PBE_scrypt +EVP_PKCS82PKEY +EVP_PKEY2PKCS8 +EVP_PKEY_CTX_get0_peerkey +EVP_PKEY_CTX_get0_pkey +EVP_PKEY_CTX_get_data +EVP_PKEY_CTX_get_operation +EVP_PKEY_CTX_hex2ctrl +EVP_PKEY_CTX_set0_keygen_info +EVP_PKEY_CTX_set_data +EVP_PKEY_CTX_str2ctrl +EVP_PKEY_add1_attr +EVP_PKEY_add1_attr_by_NID +EVP_PKEY_add1_attr_by_OBJ +EVP_PKEY_add1_attr_by_txt +EVP_PKEY_assign +EVP_PKEY_bits +EVP_PKEY_decrypt_old +EVP_PKEY_delete_attr +EVP_PKEY_encrypt_old +EVP_PKEY_get0 +EVP_PKEY_get1_tls_encodedpoint +EVP_PKEY_get_attr +EVP_PKEY_get_attr_by_NID +EVP_PKEY_get_attr_by_OBJ +EVP_PKEY_get_attr_count +EVP_PKEY_save_parameters +EVP_PKEY_set1_tls_encodedpoint +EVP_PKEY_set_type +EVP_PKEY_set_type_str +EVP_add_alg_module +EVP_add_cipher +EVP_add_digest +EVP_aes_128_siv +EVP_aes_192_siv +EVP_aes_256_siv +EVP_get_pw_prompt +EVP_hex2ctrl +EVP_read_pw_string +EVP_read_pw_string_min +EVP_set_pw_prompt +EVP_str2ctrl +EXTENDED_KEY_USAGE_it +FIPS_mode +FIPS_mode_set +GENERAL_NAMES_it +GENERAL_NAME_cmp +GENERAL_NAME_get0_otherName +GENERAL_NAME_get0_value +GENERAL_NAME_it +GENERAL_NAME_print +GENERAL_NAME_set0_othername +GENERAL_NAME_set0_value +GENERAL_SUBTREE_it +IDEA_cbc_encrypt +IDEA_cfb64_encrypt +IDEA_ecb_encrypt +IDEA_encrypt +IDEA_ofb64_encrypt +IDEA_options +IDEA_set_decrypt_key +IDEA_set_encrypt_key +INT32_it +INT64_it +IPAddressChoice_it +IPAddressFamily_it +IPAddressOrRange_it +IPAddressRange_it +ISSUING_DIST_POINT_it +LONG_it +MD2_options +MD4_Transform +MD5_Transform +NAME_CONSTRAINTS_check +NAME_CONSTRAINTS_check_CN +NAME_CONSTRAINTS_it +NAMING_AUTHORITY_it +NCONF_WIN32 +NCONF_default +NCONF_dump_bio +NCONF_dump_fp +NCONF_free +NCONF_free_data +NCONF_get_number_e +NCONF_get_section +NCONF_get_string +NCONF_load +NCONF_load_bio +NCONF_load_fp +NCONF_new +NETSCAPE_CERT_SEQUENCE_it +NETSCAPE_SPKAC_it +NETSCAPE_SPKI_b64_decode +NETSCAPE_SPKI_b64_encode +NETSCAPE_SPKI_get_pubkey +NETSCAPE_SPKI_it +NETSCAPE_SPKI_print +NETSCAPE_SPKI_set_pubkey +NETSCAPE_SPKI_sign +NETSCAPE_SPKI_verify +NOTICEREF_it +OBJ_NAME_add +OBJ_NAME_cleanup +OBJ_NAME_do_all +OBJ_NAME_do_all_sorted +OBJ_NAME_get +OBJ_NAME_init +OBJ_NAME_new_index +OBJ_NAME_remove +OBJ_add_object +OBJ_add_sigid +OBJ_bsearch_ +OBJ_bsearch_ex_ +OBJ_create_objects +OBJ_find_sigid_algs +OBJ_find_sigid_by_algs +OBJ_new_nid +OBJ_sigid_free +OCSP_BASICRESP_add1_ext_i2d +OCSP_BASICRESP_add_ext +OCSP_BASICRESP_delete_ext +OCSP_BASICRESP_get1_ext_d2i +OCSP_BASICRESP_get_ext +OCSP_BASICRESP_get_ext_by_NID +OCSP_BASICRESP_get_ext_by_OBJ +OCSP_BASICRESP_get_ext_by_critical +OCSP_BASICRESP_get_ext_count +OCSP_BASICRESP_it +OCSP_CERTID_it +OCSP_CERTSTATUS_it +OCSP_CRLID_it +OCSP_ONEREQ_add1_ext_i2d +OCSP_ONEREQ_add_ext +OCSP_ONEREQ_delete_ext +OCSP_ONEREQ_get1_ext_d2i +OCSP_ONEREQ_get_ext +OCSP_ONEREQ_get_ext_by_NID +OCSP_ONEREQ_get_ext_by_OBJ +OCSP_ONEREQ_get_ext_by_critical +OCSP_ONEREQ_get_ext_count +OCSP_ONEREQ_it +OCSP_REQINFO_it +OCSP_REQUEST_add1_ext_i2d +OCSP_REQUEST_add_ext +OCSP_REQUEST_delete_ext +OCSP_REQUEST_get1_ext_d2i +OCSP_REQUEST_get_ext +OCSP_REQUEST_get_ext_by_NID +OCSP_REQUEST_get_ext_by_OBJ +OCSP_REQUEST_get_ext_by_critical +OCSP_REQUEST_get_ext_count +OCSP_REQUEST_it +OCSP_REQUEST_print +OCSP_REQ_CTX_get0_mem_bio +OCSP_REQ_CTX_http +OCSP_REQ_CTX_i2d +OCSP_REQ_CTX_nbio +OCSP_REQ_CTX_nbio_d2i +OCSP_REQ_CTX_new +OCSP_RESPBYTES_it +OCSP_RESPDATA_it +OCSP_RESPID_it +OCSP_RESPONSE_it +OCSP_RESPONSE_print +OCSP_REVOKEDINFO_it +OCSP_SERVICELOC_it +OCSP_SIGNATURE_it +OCSP_SINGLERESP_add1_ext_i2d +OCSP_SINGLERESP_add_ext +OCSP_SINGLERESP_delete_ext +OCSP_SINGLERESP_get0_id +OCSP_SINGLERESP_get1_ext_d2i +OCSP_SINGLERESP_get_ext +OCSP_SINGLERESP_get_ext_by_NID +OCSP_SINGLERESP_get_ext_by_OBJ +OCSP_SINGLERESP_get_ext_by_critical +OCSP_SINGLERESP_get_ext_count +OCSP_SINGLERESP_it +OCSP_accept_responses_new +OCSP_archive_cutoff_new +OCSP_basic_add1_cert +OCSP_basic_add1_status +OCSP_cert_status_str +OCSP_crlID2_new +OCSP_crlID_new +OCSP_crl_reason_str +OCSP_onereq_get0_id +OCSP_parse_url +OCSP_request_is_signed +OCSP_request_set1_name +OCSP_request_verify +OCSP_response_status_str +OCSP_url_svcloc_new +OPENSSL_DIR_end +OPENSSL_DIR_read +OPENSSL_LH_delete +OPENSSL_LH_doall +OPENSSL_LH_doall_arg +OPENSSL_LH_error +OPENSSL_LH_flush +OPENSSL_LH_free +OPENSSL_LH_get_down_load +OPENSSL_LH_insert +OPENSSL_LH_new +OPENSSL_LH_num_items +OPENSSL_LH_retrieve +OPENSSL_LH_set_down_load +OPENSSL_LH_strhash +OPENSSL_asc2uni +OPENSSL_die +OPENSSL_gmtime +OPENSSL_gmtime_adj +OPENSSL_gmtime_diff +OPENSSL_init +OPENSSL_isservice +OPENSSL_issetugid +OPENSSL_sk_deep_copy +OPENSSL_sk_delete +OPENSSL_sk_delete_ptr +OPENSSL_sk_dup +OPENSSL_sk_find +OPENSSL_sk_find_ex +OPENSSL_sk_free +OPENSSL_sk_insert +OPENSSL_sk_is_sorted +OPENSSL_sk_new +OPENSSL_sk_new_null +OPENSSL_sk_new_reserve +OPENSSL_sk_num +OPENSSL_sk_pop +OPENSSL_sk_pop_free +OPENSSL_sk_push +OPENSSL_sk_reserve +OPENSSL_sk_set +OPENSSL_sk_set_cmp_func +OPENSSL_sk_shift +OPENSSL_sk_sort +OPENSSL_sk_unshift +OPENSSL_sk_value +OPENSSL_sk_zero +OPENSSL_strnlen +OPENSSL_uni2asc +OPENSSL_uni2utf8 +OPENSSL_utf82uni +OSSL_PARAM_construct_double +OSSL_PARAM_construct_int +OSSL_PARAM_construct_int32 +OSSL_PARAM_construct_int64 +OSSL_PARAM_construct_long +OSSL_PARAM_construct_size_t +OSSL_PARAM_construct_uint +OSSL_PARAM_construct_uint32 +OSSL_PARAM_construct_uint64 +OSSL_PARAM_construct_ulong +OSSL_PARAM_get_double +OSSL_PARAM_get_int +OSSL_PARAM_get_int32 +OSSL_PARAM_get_int64 +OSSL_PARAM_get_long +OSSL_PARAM_get_size_t +OSSL_PARAM_get_uint +OSSL_PARAM_get_uint32 +OSSL_PARAM_get_uint64 +OSSL_PARAM_get_ulong +OSSL_PARAM_set_double +OSSL_PARAM_set_int +OSSL_PARAM_set_int32 +OSSL_PARAM_set_int64 +OSSL_PARAM_set_long +OSSL_PARAM_set_size_t +OSSL_PARAM_set_uint +OSSL_PARAM_set_uint32 +OSSL_PARAM_set_uint64 +OSSL_PARAM_set_ulong +OSSL_STORE_do_all_loaders +OSSL_STORE_vctrl +OTHERNAME_cmp +OTHERNAME_it +PBE2PARAM_it +PBEPARAM_it +PBKDF2PARAM_it +PEM_ASN1_read +PEM_ASN1_read_bio +PEM_ASN1_write +PEM_ASN1_write_bio +PEM_SignFinal +PEM_SignInit +PEM_SignUpdate +PEM_X509_INFO_read +PEM_X509_INFO_read_bio +PEM_X509_INFO_write_bio +PEM_def_callback +PEM_dek_info +PEM_proc_type +PEM_read_bio_ECPrivateKey +PEM_read_bio_Parameters +PEM_write_bio_ASN1_stream +PEM_write_bio_Parameters +PKCS12_AUTHSAFES_it +PKCS12_BAGS_it +PKCS12_MAC_DATA_it +PKCS12_PBE_add +PKCS12_PBE_keyivgen +PKCS12_SAFEBAGS_it +PKCS12_SAFEBAG_create0_p8inf +PKCS12_SAFEBAG_create0_pkcs8 +PKCS12_SAFEBAG_create_cert +PKCS12_SAFEBAG_create_crl +PKCS12_SAFEBAG_create_pkcs8_encrypt +PKCS12_SAFEBAG_get0_attr +PKCS12_SAFEBAG_get0_attrs +PKCS12_SAFEBAG_get0_p8inf +PKCS12_SAFEBAG_get0_pkcs8 +PKCS12_SAFEBAG_get0_safes +PKCS12_SAFEBAG_get0_type +PKCS12_SAFEBAG_get1_cert +PKCS12_SAFEBAG_get1_crl +PKCS12_SAFEBAG_get_bag_nid +PKCS12_SAFEBAG_get_nid +PKCS12_SAFEBAG_it +PKCS12_add_CSPName_asc +PKCS12_add_cert +PKCS12_add_friendlyname_asc +PKCS12_add_friendlyname_uni +PKCS12_add_friendlyname_utf8 +PKCS12_add_key +PKCS12_add_localkeyid +PKCS12_add_safe +PKCS12_add_safes +PKCS12_decrypt_skey +PKCS12_gen_mac +PKCS12_get0_mac +PKCS12_get_attr +PKCS12_get_attr_gen +PKCS12_get_friendlyname +PKCS12_init +PKCS12_it +PKCS12_item_decrypt_d2i +PKCS12_item_i2d_encrypt +PKCS12_item_pack_safebag +PKCS12_key_gen_asc +PKCS12_key_gen_uni +PKCS12_key_gen_utf8 +PKCS12_mac_present +PKCS12_pack_authsafes +PKCS12_pack_p7data +PKCS12_pack_p7encdata +PKCS12_pbe_crypt +PKCS12_set_mac +PKCS12_setup_mac +PKCS12_unpack_authsafes +PKCS12_unpack_p7data +PKCS12_unpack_p7encdata +PKCS12_verify_mac +PKCS1_MGF1 +PKCS5_PBE_add +PKCS5_PBE_keyivgen +PKCS5_pbe2_set +PKCS5_pbe2_set_iv +PKCS5_pbe2_set_scrypt +PKCS5_pbe_set +PKCS5_pbe_set0_algor +PKCS5_pbkdf2_set +PKCS5_v2_PBE_keyivgen +PKCS5_v2_scrypt_keyivgen +PKCS7_ATTR_SIGN_it +PKCS7_ATTR_VERIFY_it +PKCS7_DIGEST_it +PKCS7_ENCRYPT_it +PKCS7_ENC_CONTENT_it +PKCS7_ENVELOPE_it +PKCS7_ISSUER_AND_SERIAL_it +PKCS7_RECIP_INFO_get0_alg +PKCS7_RECIP_INFO_it +PKCS7_RECIP_INFO_set +PKCS7_SIGNED_it +PKCS7_SIGNER_INFO_get0_algs +PKCS7_SIGNER_INFO_it +PKCS7_SIGNER_INFO_set +PKCS7_SIGNER_INFO_sign +PKCS7_SIGN_ENVELOPE_it +PKCS7_add0_attrib_signing_time +PKCS7_add1_attrib_digest +PKCS7_add_attrib_content_type +PKCS7_add_attrib_smimecap +PKCS7_add_attribute +PKCS7_add_certificate +PKCS7_add_crl +PKCS7_add_recipient +PKCS7_add_recipient_info +PKCS7_add_signature +PKCS7_add_signed_attribute +PKCS7_add_signer +PKCS7_cert_from_signer_info +PKCS7_content_new +PKCS7_ctrl +PKCS7_dataDecode +PKCS7_dataFinal +PKCS7_dataInit +PKCS7_dataVerify +PKCS7_digest_from_attributes +PKCS7_final +PKCS7_get_attribute +PKCS7_get_issuer_and_serial +PKCS7_get_signed_attribute +PKCS7_get_signer_info +PKCS7_get_smimecap +PKCS7_it +PKCS7_set0_type_other +PKCS7_set_attributes +PKCS7_set_cipher +PKCS7_set_content +PKCS7_set_digest +PKCS7_set_signed_attributes +PKCS7_set_type +PKCS7_signatureVerify +PKCS7_simple_smimecap +PKCS7_stream +PKCS7_to_TS_TST_INFO +PKCS8_PRIV_KEY_INFO_it +PKCS8_add_keyusage +PKCS8_decrypt +PKCS8_encrypt +PKCS8_get_attr +PKCS8_pkey_add1_attr_by_NID +PKCS8_pkey_get0 +PKCS8_pkey_get0_attrs +PKCS8_pkey_set0 +PKCS8_set0_pbe +PKEY_USAGE_PERIOD_it +POLICYINFO_it +POLICYQUALINFO_it +POLICY_CONSTRAINTS_it +POLICY_MAPPINGS_it +POLICY_MAPPING_it +PROFESSION_INFO_it +PROXY_CERT_INFO_EXTENSION_it +PROXY_POLICY_it +RAND_set_rand_engine +RC2_cbc_encrypt +RC2_cfb64_encrypt +RC2_decrypt +RC2_ecb_encrypt +RC2_encrypt +RC2_ofb64_encrypt +RC2_set_key +RC4_options +RC5_32_cbc_encrypt +RC5_32_cfb64_encrypt +RC5_32_decrypt +RC5_32_ecb_encrypt +RC5_32_encrypt +RC5_32_ofb64_encrypt +RC5_32_set_key +RIPEMD160_Transform +RSAPrivateKey_it +RSAPublicKey_it +RSA_OAEP_PARAMS_it +RSA_PSS_PARAMS_it +RSA_X931_derive_ex +RSA_X931_generate_key_ex +RSA_X931_hash_id +RSA_null_method +RSA_padding_add_PKCS1_PSS +RSA_padding_add_PKCS1_PSS_mgf1 +RSA_padding_add_X931 +RSA_padding_check_X931 +RSA_pkey_ctx_ctrl +RSA_setup_blinding +RSA_up_ref +RSA_verify_PKCS1_PSS +RSA_verify_PKCS1_PSS_mgf1 +SCRYPT_PARAMS_it +SEED_cbc_encrypt +SEED_cfb128_encrypt +SEED_decrypt +SEED_ecb_encrypt +SEED_encrypt +SEED_ofb128_encrypt +SEED_set_key +SHA1_Transform +SHA256_Transform +SHA512_Transform +SMIME_crlf_copy +SMIME_read_ASN1 +SMIME_text +SMIME_write_ASN1 +SRP_Calc_A +SRP_Calc_B +SRP_Calc_client_key +SRP_Calc_server_key +SRP_Calc_u +SRP_Calc_x +SRP_Verify_A_mod_N +SRP_Verify_B_mod_N +SXNETID_it +SXNET_add_id_INTEGER +SXNET_add_id_asc +SXNET_add_id_ulong +SXNET_get_id_INTEGER +SXNET_get_id_asc +SXNET_get_id_ulong +SXNET_it +TS_ACCURACY_get_micros +TS_ACCURACY_get_millis +TS_ACCURACY_get_seconds +TS_ACCURACY_set_micros +TS_ACCURACY_set_millis +TS_ACCURACY_set_seconds +TS_ASN1_INTEGER_print_bio +TS_CONF_get_tsa_section +TS_CONF_load_cert +TS_CONF_load_certs +TS_CONF_load_key +TS_CONF_set_accuracy +TS_CONF_set_certs +TS_CONF_set_clock_precision_digits +TS_CONF_set_crypto_device +TS_CONF_set_def_policy +TS_CONF_set_default_engine +TS_CONF_set_digests +TS_CONF_set_ess_cert_id_chain +TS_CONF_set_ess_cert_id_digest +TS_CONF_set_ordering +TS_CONF_set_policies +TS_CONF_set_serial +TS_CONF_set_signer_cert +TS_CONF_set_signer_digest +TS_CONF_set_signer_key +TS_CONF_set_tsa_name +TS_MSG_IMPRINT_get_algo +TS_MSG_IMPRINT_get_msg +TS_MSG_IMPRINT_print_bio +TS_MSG_IMPRINT_set_algo +TS_MSG_IMPRINT_set_msg +TS_OBJ_print_bio +TS_REQ_add_ext +TS_REQ_delete_ext +TS_REQ_ext_free +TS_REQ_get_cert_req +TS_REQ_get_ext +TS_REQ_get_ext_by_NID +TS_REQ_get_ext_by_OBJ +TS_REQ_get_ext_by_critical +TS_REQ_get_ext_count +TS_REQ_get_ext_d2i +TS_REQ_get_exts +TS_REQ_get_msg_imprint +TS_REQ_get_nonce +TS_REQ_get_policy_id +TS_REQ_get_version +TS_REQ_print_bio +TS_REQ_set_cert_req +TS_REQ_set_msg_imprint +TS_REQ_set_nonce +TS_REQ_set_policy_id +TS_REQ_set_version +TS_REQ_to_TS_VERIFY_CTX +TS_RESP_CTX_add_failure_info +TS_RESP_CTX_add_flags +TS_RESP_CTX_add_md +TS_RESP_CTX_add_policy +TS_RESP_CTX_free +TS_RESP_CTX_get_request +TS_RESP_CTX_get_tst_info +TS_RESP_CTX_new +TS_RESP_CTX_set_accuracy +TS_RESP_CTX_set_certs +TS_RESP_CTX_set_clock_precision_digits +TS_RESP_CTX_set_def_policy +TS_RESP_CTX_set_ess_cert_id_digest +TS_RESP_CTX_set_extension_cb +TS_RESP_CTX_set_serial_cb +TS_RESP_CTX_set_signer_cert +TS_RESP_CTX_set_signer_digest +TS_RESP_CTX_set_signer_key +TS_RESP_CTX_set_status_info +TS_RESP_CTX_set_status_info_cond +TS_RESP_CTX_set_time_cb +TS_RESP_create_response +TS_RESP_get_status_info +TS_RESP_get_token +TS_RESP_get_tst_info +TS_RESP_print_bio +TS_RESP_set_status_info +TS_RESP_set_tst_info +TS_RESP_verify_response +TS_RESP_verify_signature +TS_RESP_verify_token +TS_STATUS_INFO_get0_failure_info +TS_STATUS_INFO_get0_status +TS_STATUS_INFO_get0_text +TS_STATUS_INFO_print_bio +TS_STATUS_INFO_set_status +TS_TST_INFO_add_ext +TS_TST_INFO_delete_ext +TS_TST_INFO_ext_free +TS_TST_INFO_get_accuracy +TS_TST_INFO_get_ext +TS_TST_INFO_get_ext_by_NID +TS_TST_INFO_get_ext_by_OBJ +TS_TST_INFO_get_ext_by_critical +TS_TST_INFO_get_ext_count +TS_TST_INFO_get_ext_d2i +TS_TST_INFO_get_exts +TS_TST_INFO_get_msg_imprint +TS_TST_INFO_get_nonce +TS_TST_INFO_get_ordering +TS_TST_INFO_get_policy_id +TS_TST_INFO_get_serial +TS_TST_INFO_get_time +TS_TST_INFO_get_tsa +TS_TST_INFO_get_version +TS_TST_INFO_print_bio +TS_TST_INFO_set_accuracy +TS_TST_INFO_set_msg_imprint +TS_TST_INFO_set_nonce +TS_TST_INFO_set_ordering +TS_TST_INFO_set_policy_id +TS_TST_INFO_set_serial +TS_TST_INFO_set_time +TS_TST_INFO_set_tsa +TS_TST_INFO_set_version +TS_VERIFY_CTS_set_certs +TS_VERIFY_CTX_add_flags +TS_VERIFY_CTX_cleanup +TS_VERIFY_CTX_free +TS_VERIFY_CTX_init +TS_VERIFY_CTX_new +TS_VERIFY_CTX_set_data +TS_VERIFY_CTX_set_flags +TS_VERIFY_CTX_set_imprint +TS_VERIFY_CTX_set_store +TS_X509_ALGOR_print_bio +TS_ext_print_bio +TXT_DB_create_index +TXT_DB_free +TXT_DB_get_by_index +TXT_DB_insert +TXT_DB_read +TXT_DB_write +UINT32_it +UINT64_it +USERNOTICE_it +UTF8_getc +UTF8_putc +WHIRLPOOL +WHIRLPOOL_BitUpdate +WHIRLPOOL_Final +WHIRLPOOL_Init +WHIRLPOOL_Update +X509V3_EXT_CRL_add_conf +X509V3_EXT_CRL_add_nconf +X509V3_EXT_REQ_add_conf +X509V3_EXT_REQ_add_nconf +X509V3_EXT_add +X509V3_EXT_add_alias +X509V3_EXT_add_conf +X509V3_EXT_add_list +X509V3_EXT_add_nconf +X509V3_EXT_add_nconf_sk +X509V3_EXT_cleanup +X509V3_EXT_conf +X509V3_EXT_conf_nid +X509V3_EXT_get +X509V3_EXT_get_nid +X509V3_EXT_nconf +X509V3_EXT_nconf_nid +X509V3_EXT_print +X509V3_EXT_print_fp +X509V3_EXT_val_prn +X509V3_NAME_from_section +X509V3_add_standard_extensions +X509V3_add_value +X509V3_add_value_bool +X509V3_add_value_bool_nf +X509V3_add_value_int +X509V3_add_value_uchar +X509V3_conf_free +X509V3_extensions_print +X509V3_get_section +X509V3_get_string +X509V3_get_value_bool +X509V3_get_value_int +X509V3_parse_list +X509V3_section_free +X509V3_set_conf_lhash +X509V3_set_ctx +X509V3_set_nconf +X509V3_string_free +X509_ALGORS_it +X509_ALGOR_it +X509_ATTRIBUTE_count +X509_ATTRIBUTE_create +X509_ATTRIBUTE_create_by_NID +X509_ATTRIBUTE_create_by_OBJ +X509_ATTRIBUTE_create_by_txt +X509_ATTRIBUTE_get0_data +X509_ATTRIBUTE_get0_object +X509_ATTRIBUTE_get0_type +X509_ATTRIBUTE_it +X509_ATTRIBUTE_set1_data +X509_ATTRIBUTE_set1_object +X509_CERT_AUX_it +X509_CINF_it +X509_CRL_INFO_it +X509_CRL_METHOD_free +X509_CRL_METHOD_new +X509_CRL_check_suiteb +X509_CRL_cmp +X509_CRL_diff +X509_CRL_get_lastUpdate +X509_CRL_get_meth_data +X509_CRL_get_nextUpdate +X509_CRL_http_nbio +X509_CRL_it +X509_CRL_match +X509_CRL_print +X509_CRL_print_ex +X509_CRL_print_fp +X509_CRL_set_default_method +X509_CRL_set_meth_data +X509_CRL_up_ref +X509_EXTENSIONS_it +X509_EXTENSION_it +X509_INFO_free +X509_INFO_new +X509_LOOKUP_by_alias +X509_LOOKUP_by_fingerprint +X509_LOOKUP_by_issuer_serial +X509_LOOKUP_by_subject +X509_LOOKUP_ctrl +X509_LOOKUP_free +X509_LOOKUP_init +X509_LOOKUP_new +X509_LOOKUP_shutdown +X509_NAME_ENTRY_it +X509_NAME_ENTRY_set +X509_NAME_cmp +X509_NAME_hash +X509_NAME_hash_old +X509_NAME_it +X509_NAME_set +X509_OBJECT_free +X509_OBJECT_get0_X509 +X509_OBJECT_get0_X509_CRL +X509_OBJECT_get_type +X509_OBJECT_idx_by_subject +X509_OBJECT_new +X509_OBJECT_retrieve_by_subject +X509_OBJECT_retrieve_match +X509_OBJECT_up_ref_count +X509_PKEY_free +X509_PKEY_new +X509_POLICY_NODE_print +X509_PUBKEY_it +X509_PURPOSE_add +X509_PURPOSE_cleanup +X509_PURPOSE_get0 +X509_PURPOSE_get0_name +X509_PURPOSE_get0_sname +X509_PURPOSE_get_by_id +X509_PURPOSE_get_by_sname +X509_PURPOSE_get_count +X509_PURPOSE_get_id +X509_PURPOSE_get_trust +X509_PURPOSE_set +X509_REQ_INFO_it +X509_REQ_add1_attr +X509_REQ_add1_attr_by_NID +X509_REQ_add1_attr_by_OBJ +X509_REQ_add1_attr_by_txt +X509_REQ_add_extensions +X509_REQ_add_extensions_nid +X509_REQ_delete_attr +X509_REQ_extension_nid +X509_REQ_get1_email +X509_REQ_get_attr +X509_REQ_get_attr_by_NID +X509_REQ_get_attr_by_OBJ +X509_REQ_get_attr_count +X509_REQ_get_extension_nids +X509_REQ_get_extensions +X509_REQ_it +X509_REQ_print +X509_REQ_print_ex +X509_REQ_print_fp +X509_REQ_set_extension_nids +X509_REQ_to_X509 +X509_REVOKED_it +X509_SIG_it +X509_STORE_CTX_get0_current_crl +X509_STORE_CTX_get0_current_issuer +X509_STORE_CTX_get0_parent_ctx +X509_STORE_CTX_get0_policy_tree +X509_STORE_CTX_get0_store +X509_STORE_CTX_get1_certs +X509_STORE_CTX_get1_crls +X509_STORE_CTX_get1_issuer +X509_STORE_CTX_get_by_subject +X509_STORE_CTX_get_explicit_policy +X509_STORE_CTX_get_obj_by_subject +X509_STORE_CTX_purpose_inherit +X509_STORE_CTX_set0_dane +X509_STORE_CTX_set_depth +X509_STORE_CTX_set_flags +X509_STORE_CTX_set_purpose +X509_STORE_CTX_set_time +X509_STORE_CTX_set_trust +X509_STORE_add_lookup +X509_STORE_get_verify +X509_TRUST_add +X509_TRUST_cleanup +X509_TRUST_get0 +X509_TRUST_get0_name +X509_TRUST_get_by_id +X509_TRUST_get_count +X509_TRUST_get_flags +X509_TRUST_get_trust +X509_TRUST_set +X509_TRUST_set_default +X509_VAL_it +X509_VERIFY_PARAM_add0_table +X509_VERIFY_PARAM_free +X509_VERIFY_PARAM_get0 +X509_VERIFY_PARAM_get0_name +X509_VERIFY_PARAM_get_count +X509_VERIFY_PARAM_inherit +X509_VERIFY_PARAM_lookup +X509_VERIFY_PARAM_move_peername +X509_VERIFY_PARAM_new +X509_VERIFY_PARAM_set1 +X509_VERIFY_PARAM_set1_name +X509_VERIFY_PARAM_table_cleanup +X509_add1_reject_object +X509_add1_trust_object +X509_alias_get0 +X509_alias_set1 +X509_aux_print +X509_certificate_type +X509_chain_check_suiteb +X509_check_akid +X509_check_purpose +X509_check_trust +X509_cmp +X509_email_free +X509_find_by_issuer_and_serial +X509_find_by_subject +X509_get0_pubkey_bitstr +X509_get0_reject_objects +X509_get0_trust_objects +X509_get1_email +X509_get1_ocsp +X509_get_default_cert_area +X509_get_default_cert_dir +X509_get_default_cert_dir_env +X509_get_default_cert_file +X509_get_default_cert_file_env +X509_get_default_private_dir +X509_get_pubkey_parameters +X509_get_signature_type +X509_gmtime_adj +X509_http_nbio +X509_issuer_and_serial_cmp +X509_issuer_and_serial_hash +X509_issuer_name_cmp +X509_issuer_name_hash +X509_issuer_name_hash_old +X509_it +X509_keyid_get0 +X509_keyid_set1 +X509_ocspid_print +X509_policy_check +X509_policy_level_get0_node +X509_policy_level_node_count +X509_policy_node_get0_parent +X509_policy_node_get0_policy +X509_policy_node_get0_qualifiers +X509_policy_tree_free +X509_policy_tree_get0_level +X509_policy_tree_get0_policies +X509_policy_tree_get0_user_policies +X509_policy_tree_level_count +X509_print +X509_print_ex +X509_print_ex_fp +X509_print_fp +X509_reject_clear +X509_signature_dump +X509_signature_print +X509_subject_name_cmp +X509_subject_name_hash +X509_subject_name_hash_old +X509_supported_extension +X509_to_X509_REQ +X509_trust_clear +X509_trusted +X509at_add1_attr +X509at_add1_attr_by_NID +X509at_add1_attr_by_OBJ +X509at_add1_attr_by_txt +X509at_delete_attr +X509at_get0_data_by_OBJ +X509at_get_attr +X509at_get_attr_by_NID +X509at_get_attr_by_OBJ +X509at_get_attr_count +X509v3_addr_add_inherit +X509v3_addr_add_prefix +X509v3_addr_add_range +X509v3_addr_canonize +X509v3_addr_get_afi +X509v3_addr_get_range +X509v3_addr_inherits +X509v3_addr_is_canonical +X509v3_addr_subset +X509v3_addr_validate_path +X509v3_addr_validate_resource_set +X509v3_asid_add_id_or_range +X509v3_asid_add_inherit +X509v3_asid_canonize +X509v3_asid_inherits +X509v3_asid_is_canonical +X509v3_asid_subset +X509v3_asid_validate_path +X509v3_asid_validate_resource_set +ZINT32_it +ZINT64_it +ZLONG_it +ZUINT32_it +ZUINT64_it +a2d_ASN1_OBJECT +a2i_ASN1_ENUMERATED +a2i_ASN1_INTEGER +a2i_ASN1_STRING +a2i_GENERAL_NAME +a2i_IPADDRESS +a2i_IPADDRESS_NC +b2i_PVK_bio +b2i_PrivateKey +b2i_PrivateKey_bio +b2i_PublicKey +b2i_PublicKey_bio +conf_ssl_get +conf_ssl_get_cmd +conf_ssl_name_find +d2i_ESS_CERT_ID_V2 +d2i_ESS_SIGNING_CERT_V2 +d2i_X509_bio +d2i_X509_fp +err_free_strings_int +i2a_ACCESS_DESCRIPTION +i2a_ASN1_ENUMERATED +i2a_ASN1_INTEGER +i2a_ASN1_OBJECT +i2a_ASN1_STRING +i2b_PVK_bio +i2b_PrivateKey_bio +i2b_PublicKey_bio +i2d_ESS_CERT_ID_V2 +i2d_ESS_SIGNING_CERT_V2 +i2d_PrivateKey_bio +i2d_PrivateKey_fp +i2d_X509_bio +i2d_X509_fp +i2o_ECPublicKey +i2s_ASN1_ENUMERATED +i2s_ASN1_ENUMERATED_TABLE +i2s_ASN1_IA5STRING +i2s_ASN1_INTEGER +i2s_ASN1_OCTET_STRING +i2v_ASN1_BIT_STRING +i2v_GENERAL_NAME +i2v_GENERAL_NAMES +o2i_ECPublicKey +s2i_ASN1_IA5STRING +s2i_ASN1_INTEGER +s2i_ASN1_OCTET_STRING +v2i_ASN1_BIT_STRING +v2i_GENERAL_NAME +v2i_GENERAL_NAMES +v2i_GENERAL_NAME_ex diff --git a/util/missingcrypto111.txt b/util/missingcrypto111.txt new file mode 100644 index 00000000..1fb924bc --- /dev/null +++ b/util/missingcrypto111.txt @@ -0,0 +1,1609 @@ +# A list of libcrypto functions that are known to be missing documentation as +# used by the find-doc-nits -v -o option. The list is as of commit 1708e3e85b +# (the release of 1.1.1). +ACCESS_DESCRIPTION_it +ACCESS_DESCRIPTION_it +ADMISSIONS_it +ADMISSIONS_it +ADMISSION_SYNTAX_it +ADMISSION_SYNTAX_it +AES_bi_ige_encrypt +AES_cbc_encrypt +AES_cfb128_encrypt +AES_cfb1_encrypt +AES_cfb8_encrypt +AES_decrypt +AES_ecb_encrypt +AES_encrypt +AES_ige_encrypt +AES_ofb128_encrypt +AES_options +AES_set_decrypt_key +AES_set_encrypt_key +AES_unwrap_key +AES_wrap_key +ASIdOrRange_it +ASIdOrRange_it +ASIdentifierChoice_it +ASIdentifierChoice_it +ASIdentifiers_it +ASIdentifiers_it +ASRange_it +ASRange_it +AUTHORITY_INFO_ACCESS_it +AUTHORITY_INFO_ACCESS_it +AUTHORITY_KEYID_it +AUTHORITY_KEYID_it +BASIC_CONSTRAINTS_it +BASIC_CONSTRAINTS_it +BIGNUM_it +BIGNUM_it +BIO_accept +BIO_asn1_get_prefix +BIO_asn1_get_suffix +BIO_asn1_set_prefix +BIO_asn1_set_suffix +BIO_clear_flags +BIO_copy_next_retry +BIO_dgram_is_sctp +BIO_dgram_non_fatal_error +BIO_dgram_sctp_msg_waiting +BIO_dgram_sctp_notification_cb +BIO_dgram_sctp_wait_for_dry +BIO_dump +BIO_dump_cb +BIO_dump_fp +BIO_dump_indent +BIO_dump_indent_cb +BIO_dump_indent_fp +BIO_dup_chain +BIO_f_asn1 +BIO_f_linebuffer +BIO_f_nbio_test +BIO_f_reliable +BIO_f_zlib +BIO_fd_non_fatal_error +BIO_fd_should_retry +BIO_get_accept_socket +BIO_get_host_ip +BIO_get_port +BIO_gethostbyname +BIO_hex_string +BIO_indent +BIO_method_name +BIO_new_NDEF +BIO_new_PKCS7 +BIO_new_dgram +BIO_new_dgram_sctp +BIO_nread +BIO_nread0 +BIO_number_read +BIO_number_written +BIO_nwrite +BIO_nwrite0 +BIO_s_datagram +BIO_s_datagram_sctp +BIO_s_log +BIO_set_flags +BIO_set_tcp_ndelay +BIO_sock_error +BIO_sock_info +BIO_sock_init +BIO_sock_non_fatal_error +BIO_sock_should_retry +BIO_socket_ioctl +BIO_socket_nbio +BIO_test_flags +BN_GF2m_add +BN_GF2m_arr2poly +BN_GF2m_mod +BN_GF2m_mod_arr +BN_GF2m_mod_div +BN_GF2m_mod_div_arr +BN_GF2m_mod_exp +BN_GF2m_mod_exp_arr +BN_GF2m_mod_inv +BN_GF2m_mod_inv_arr +BN_GF2m_mod_mul +BN_GF2m_mod_mul_arr +BN_GF2m_mod_solve_quad +BN_GF2m_mod_solve_quad_arr +BN_GF2m_mod_sqr +BN_GF2m_mod_sqr_arr +BN_GF2m_mod_sqrt +BN_GF2m_mod_sqrt_arr +BN_GF2m_poly2arr +BN_MONT_CTX_set_locked +BN_X931_derive_prime_ex +BN_X931_generate_Xpq +BN_X931_generate_prime_ex +BN_abs_is_word +BN_asc2bn +BN_bntest_rand +BN_consttime_swap +BN_generate_dsa_nonce +BN_get_flags +BN_get_params +BN_is_negative +BN_kronecker +BN_mod_add_quick +BN_mod_exp2_mont +BN_mod_exp_mont +BN_mod_exp_mont_consttime +BN_mod_exp_mont_word +BN_mod_exp_recp +BN_mod_exp_simple +BN_mod_lshift +BN_mod_lshift1 +BN_mod_lshift1_quick +BN_mod_lshift_quick +BN_mod_sqrt +BN_mod_sub_quick +BN_nist_mod_192 +BN_nist_mod_224 +BN_nist_mod_256 +BN_nist_mod_384 +BN_nist_mod_521 +BN_nist_mod_func +BN_options +BN_reciprocal +BN_set_flags +BN_set_negative +BN_set_params +BN_uadd +BN_usub +BN_zero_ex +CAST_cbc_encrypt +CAST_cfb64_encrypt +CAST_decrypt +CAST_ecb_encrypt +CAST_encrypt +CAST_ofb64_encrypt +CAST_set_key +CBIGNUM_it +CBIGNUM_it +CERTIFICATEPOLICIES_it +CERTIFICATEPOLICIES_it +CMAC_CTX_cleanup +CMAC_CTX_copy +CMAC_CTX_free +CMAC_CTX_get0_cipher_ctx +CMAC_CTX_new +CMAC_Final +CMAC_Init +CMAC_Update +CMAC_resume +CMS_ContentInfo_it +CMS_ContentInfo_it +CMS_EncryptedData_decrypt +CMS_EncryptedData_encrypt +CMS_EncryptedData_set1_key +CMS_EnvelopedData_create +CMS_ReceiptRequest_it +CMS_ReceiptRequest_it +CMS_RecipientEncryptedKey_cert_cmp +CMS_RecipientEncryptedKey_get0_id +CMS_RecipientInfo_get0_pkey_ctx +CMS_RecipientInfo_kari_decrypt +CMS_RecipientInfo_kari_get0_alg +CMS_RecipientInfo_kari_get0_ctx +CMS_RecipientInfo_kari_get0_orig_id +CMS_RecipientInfo_kari_get0_reks +CMS_RecipientInfo_kari_orig_id_cmp +CMS_RecipientInfo_kari_set0_pkey +CMS_RecipientInfo_ktri_get0_algs +CMS_RecipientInfo_set0_password +CMS_SharedInfo_encode +CMS_SignedData_init +CMS_SignerInfo_get0_algs +CMS_SignerInfo_get0_md_ctx +CMS_SignerInfo_get0_pkey_ctx +CMS_SignerInfo_verify +CMS_SignerInfo_verify_content +CMS_add0_CertificateChoices +CMS_add0_RevocationInfoChoice +CMS_add0_recipient_password +CMS_add_simple_smimecap +CMS_add_smimecap +CMS_add_standard_smimecap +CMS_data +CMS_dataFinal +CMS_dataInit +CMS_data_create +CMS_decrypt_set1_key +CMS_decrypt_set1_password +CMS_decrypt_set1_pkey +CMS_digest_create +CMS_digest_verify +CMS_is_detached +CMS_set1_signers_certs +CMS_set_detached +CMS_signed_add1_attr +CMS_signed_add1_attr_by_NID +CMS_signed_add1_attr_by_OBJ +CMS_signed_add1_attr_by_txt +CMS_signed_delete_attr +CMS_signed_get0_data_by_OBJ +CMS_signed_get_attr +CMS_signed_get_attr_by_NID +CMS_signed_get_attr_by_OBJ +CMS_signed_get_attr_count +CMS_stream +CMS_unsigned_add1_attr +CMS_unsigned_add1_attr_by_NID +CMS_unsigned_add1_attr_by_OBJ +CMS_unsigned_add1_attr_by_txt +CMS_unsigned_delete_attr +CMS_unsigned_get0_data_by_OBJ +CMS_unsigned_get_attr +CMS_unsigned_get_attr_by_NID +CMS_unsigned_get_attr_by_OBJ +CMS_unsigned_get_attr_count +COMP_CTX_free +COMP_CTX_get_method +COMP_CTX_get_type +COMP_CTX_new +COMP_compress_block +COMP_expand_block +COMP_get_name +COMP_get_type +COMP_zlib +CONF_dump_bio +CONF_dump_fp +CONF_free +CONF_get1_default_config_file +CONF_get_number +CONF_get_section +CONF_get_string +CONF_imodule_get_flags +CONF_imodule_get_module +CONF_imodule_get_name +CONF_imodule_get_usr_data +CONF_imodule_get_value +CONF_imodule_set_flags +CONF_imodule_set_usr_data +CONF_load +CONF_load_bio +CONF_load_fp +CONF_module_add +CONF_module_get_usr_data +CONF_module_set_usr_data +CONF_parse_list +CONF_set_default_method +CONF_set_nconf +CRL_DIST_POINTS_it +CRL_DIST_POINTS_it +CRYPTO_128_unwrap +CRYPTO_128_unwrap_pad +CRYPTO_128_wrap +CRYPTO_128_wrap_pad +CRYPTO_THREAD_cleanup_local +CRYPTO_THREAD_compare_id +CRYPTO_THREAD_get_current_id +CRYPTO_THREAD_get_local +CRYPTO_THREAD_init_local +CRYPTO_THREAD_set_local +CRYPTO_cbc128_decrypt +CRYPTO_cbc128_encrypt +CRYPTO_ccm128_aad +CRYPTO_ccm128_decrypt +CRYPTO_ccm128_decrypt_ccm64 +CRYPTO_ccm128_encrypt +CRYPTO_ccm128_encrypt_ccm64 +CRYPTO_ccm128_init +CRYPTO_ccm128_setiv +CRYPTO_ccm128_tag +CRYPTO_cfb128_1_encrypt +CRYPTO_cfb128_8_encrypt +CRYPTO_cfb128_encrypt +CRYPTO_ctr128_encrypt +CRYPTO_ctr128_encrypt_ctr32 +CRYPTO_cts128_decrypt +CRYPTO_cts128_decrypt_block +CRYPTO_cts128_encrypt +CRYPTO_cts128_encrypt_block +CRYPTO_dup_ex_data +CRYPTO_gcm128_aad +CRYPTO_gcm128_decrypt +CRYPTO_gcm128_decrypt_ctr32 +CRYPTO_gcm128_encrypt +CRYPTO_gcm128_encrypt_ctr32 +CRYPTO_gcm128_finish +CRYPTO_gcm128_init +CRYPTO_gcm128_new +CRYPTO_gcm128_release +CRYPTO_gcm128_setiv +CRYPTO_gcm128_tag +CRYPTO_mem_debug_free +CRYPTO_mem_debug_malloc +CRYPTO_mem_debug_realloc +CRYPTO_memdup +CRYPTO_nistcts128_decrypt +CRYPTO_nistcts128_decrypt_block +CRYPTO_nistcts128_encrypt +CRYPTO_nistcts128_encrypt_block +CRYPTO_ocb128_aad +CRYPTO_ocb128_cleanup +CRYPTO_ocb128_copy_ctx +CRYPTO_ocb128_decrypt +CRYPTO_ocb128_encrypt +CRYPTO_ocb128_finish +CRYPTO_ocb128_init +CRYPTO_ocb128_new +CRYPTO_ocb128_setiv +CRYPTO_ocb128_tag +CRYPTO_ofb128_encrypt +CRYPTO_secure_actual_size +CRYPTO_secure_allocated +CRYPTO_xts128_encrypt +Camellia_cbc_encrypt +Camellia_cfb128_encrypt +Camellia_cfb1_encrypt +Camellia_cfb8_encrypt +Camellia_ctr128_encrypt +Camellia_decrypt +Camellia_ecb_encrypt +Camellia_encrypt +Camellia_ofb128_encrypt +Camellia_set_key +DES_cbc_encrypt +DES_check_key_parity +DES_decrypt3 +DES_ede3_cfb_encrypt +DES_encrypt1 +DES_encrypt2 +DES_encrypt3 +DES_options +DH_KDF_X9_42 +DH_check_pub_key +DH_compute_key_padded +DH_up_ref +DHparams_dup +DHparams_it +DHparams_it +DIRECTORYSTRING_it +DIRECTORYSTRING_it +DISPLAYTEXT_it +DISPLAYTEXT_it +DIST_POINT_NAME_it +DIST_POINT_NAME_it +DIST_POINT_it +DIST_POINT_it +DIST_POINT_set_dpname +DSA_get_method +DSA_up_ref +DSO_METHOD_openssl +DSO_bind_func +DSO_convert_filename +DSO_ctrl +DSO_dsobyaddr +DSO_flags +DSO_free +DSO_get_filename +DSO_global_lookup +DSO_load +DSO_merge +DSO_new +DSO_pathbyaddr +DSO_set_filename +DSO_up_ref +ECDH_KDF_X9_62 +ECDH_compute_key +ECPARAMETERS_it +ECPARAMETERS_it +ECPKPARAMETERS_it +ECPKPARAMETERS_it +ECParameters_print +ECParameters_print_fp +EC_GROUP_get_mont_data +EC_KEY_METHOD_free +EC_KEY_METHOD_get_compute_key +EC_KEY_METHOD_get_init +EC_KEY_METHOD_get_keygen +EC_KEY_METHOD_get_sign +EC_KEY_METHOD_get_verify +EC_KEY_METHOD_new +EC_KEY_METHOD_set_compute_key +EC_KEY_METHOD_set_init +EC_KEY_METHOD_set_keygen +EC_KEY_METHOD_set_sign +EC_KEY_METHOD_set_verify +EC_KEY_OpenSSL +EC_KEY_can_sign +EC_KEY_get_default_method +EC_KEY_new_method +EC_KEY_print +EC_KEY_print_fp +EC_KEY_set_default_method +EC_curve_nid2nist +EC_curve_nist2nid +EDIPARTYNAME_it +EDIPARTYNAME_it +ENGINE_get_EC +ENGINE_get_default_EC +ENGINE_get_pkey_asn1_meth +ENGINE_get_pkey_asn1_meth_engine +ENGINE_get_pkey_asn1_meth_str +ENGINE_get_pkey_asn1_meths +ENGINE_get_pkey_meth +ENGINE_get_pkey_meth_engine +ENGINE_get_pkey_meths +ENGINE_get_ssl_client_cert_function +ENGINE_get_static_state +ENGINE_load_ssl_client_cert +ENGINE_pkey_asn1_find_str +ENGINE_register_EC +ENGINE_register_all_EC +ENGINE_register_all_pkey_asn1_meths +ENGINE_register_all_pkey_meths +ENGINE_register_pkey_asn1_meths +ENGINE_register_pkey_meths +ENGINE_set_EC +ENGINE_set_default_EC +ENGINE_set_default_pkey_asn1_meths +ENGINE_set_default_pkey_meths +ENGINE_set_load_ssl_client_cert_function +ENGINE_set_pkey_asn1_meths +ENGINE_set_pkey_meths +ENGINE_setup_bsd_cryptodev +ENGINE_unregister_EC +ENGINE_unregister_pkey_asn1_meths +ENGINE_unregister_pkey_meths +ERR_clear_last_mark +ERR_get_state +ERR_load_ASN1_strings +ERR_load_ASYNC_strings +ERR_load_BIO_strings +ERR_load_BN_strings +ERR_load_BUF_strings +ERR_load_CMS_strings +ERR_load_COMP_strings +ERR_load_CONF_strings +ERR_load_CRYPTO_strings +ERR_load_CRYPTOlib_strings +ERR_load_CT_strings +ERR_load_DH_strings +ERR_load_DSA_strings +ERR_load_DSO_strings +ERR_load_EC_strings +ERR_load_ENGINE_strings +ERR_load_ERR_strings +ERR_load_EVP_strings +ERR_load_KDF_strings +ERR_load_OBJ_strings +ERR_load_OCSP_strings +ERR_load_OSSL_STORE_strings +ERR_load_PEM_strings +ERR_load_PKCS12_strings +ERR_load_PKCS7_strings +ERR_load_RAND_strings +ERR_load_RSA_strings +ERR_load_TS_strings +ERR_load_UI_strings +ERR_load_X509V3_strings +ERR_load_X509_strings +ERR_load_strings_const +ERR_set_error_data +ERR_unload_strings +ESS_CERT_ID_V2_dup +ESS_CERT_ID_V2_free +ESS_CERT_ID_V2_new +ESS_SIGNING_CERT_V2_dup +ESS_SIGNING_CERT_V2_free +ESS_SIGNING_CERT_V2_new +EVP_CIPHER_CTX_buf_noconst +EVP_CIPHER_CTX_clear_flags +EVP_CIPHER_CTX_copy +EVP_CIPHER_CTX_encrypting +EVP_CIPHER_CTX_iv +EVP_CIPHER_CTX_iv_noconst +EVP_CIPHER_CTX_num +EVP_CIPHER_CTX_original_iv +EVP_CIPHER_CTX_rand_key +EVP_CIPHER_CTX_set_flags +EVP_CIPHER_CTX_set_num +EVP_CIPHER_CTX_test_flags +EVP_CIPHER_do_all +EVP_CIPHER_do_all_sorted +EVP_CIPHER_get_asn1_iv +EVP_CIPHER_impl_ctx_size +EVP_CIPHER_set_asn1_iv +EVP_Cipher +EVP_Digest +EVP_MD_CTX_pkey_ctx +EVP_MD_CTX_set_update_fn +EVP_MD_CTX_update_fn +EVP_MD_do_all +EVP_MD_do_all_sorted +EVP_MD_flags +EVP_PBE_CipherInit +EVP_PBE_alg_add +EVP_PBE_alg_add_type +EVP_PBE_cleanup +EVP_PBE_find +EVP_PBE_get +EVP_PBE_scrypt +EVP_PKCS82PKEY +EVP_PKEY2PKCS8 +EVP_PKEY_CTX_ctrl_uint64 +EVP_PKEY_CTX_get0_peerkey +EVP_PKEY_CTX_get0_pkey +EVP_PKEY_CTX_get_data +EVP_PKEY_CTX_get_operation +EVP_PKEY_CTX_hex2ctrl +EVP_PKEY_CTX_md +EVP_PKEY_CTX_set0_keygen_info +EVP_PKEY_CTX_set_data +EVP_PKEY_CTX_str2ctrl +EVP_PKEY_add1_attr +EVP_PKEY_add1_attr_by_NID +EVP_PKEY_add1_attr_by_OBJ +EVP_PKEY_add1_attr_by_txt +EVP_PKEY_assign +EVP_PKEY_bits +EVP_PKEY_decrypt_old +EVP_PKEY_delete_attr +EVP_PKEY_encrypt_old +EVP_PKEY_get0 +EVP_PKEY_get0_poly1305 +EVP_PKEY_get0_siphash +EVP_PKEY_get1_tls_encodedpoint +EVP_PKEY_get_attr +EVP_PKEY_get_attr_by_NID +EVP_PKEY_get_attr_by_OBJ +EVP_PKEY_get_attr_count +EVP_PKEY_save_parameters +EVP_PKEY_set1_tls_encodedpoint +EVP_PKEY_set_type +EVP_PKEY_set_type_str +EVP_add_alg_module +EVP_add_cipher +EVP_add_digest +EVP_aes_128_cfb128 +EVP_aes_192_cfb128 +EVP_aes_256_cfb128 +EVP_aria_128_cfb128 +EVP_aria_192_cfb128 +EVP_aria_256_cfb128 +EVP_bf_cfb64 +EVP_camellia_128_cfb128 +EVP_camellia_192_cfb128 +EVP_camellia_256_cfb128 +EVP_cast5_cfb64 +EVP_des_cfb64 +EVP_des_ede3_cfb64 +EVP_des_ede3_ecb +EVP_des_ede_cfb64 +EVP_des_ede_ecb +EVP_get_pw_prompt +EVP_idea_cfb64 +EVP_md5_sha1 +EVP_rc2_cfb64 +EVP_rc5_32_12_16_cfb64 +EVP_read_pw_string +EVP_read_pw_string_min +EVP_seed_cfb128 +EVP_set_pw_prompt +EVP_sm4_cfb128 +EXTENDED_KEY_USAGE_it +EXTENDED_KEY_USAGE_it +FIPS_mode +FIPS_mode_set +GENERAL_NAMES_it +GENERAL_NAMES_it +GENERAL_NAME_cmp +GENERAL_NAME_get0_otherName +GENERAL_NAME_get0_value +GENERAL_NAME_it +GENERAL_NAME_it +GENERAL_NAME_print +GENERAL_NAME_set0_othername +GENERAL_NAME_set0_value +GENERAL_SUBTREE_it +GENERAL_SUBTREE_it +IDEA_cbc_encrypt +IDEA_cfb64_encrypt +IDEA_ecb_encrypt +IDEA_encrypt +IDEA_ofb64_encrypt +IDEA_options +IDEA_set_decrypt_key +IDEA_set_encrypt_key +INT32_it +INT32_it +INT64_it +INT64_it +IPAddressChoice_it +IPAddressChoice_it +IPAddressFamily_it +IPAddressFamily_it +IPAddressOrRange_it +IPAddressOrRange_it +IPAddressRange_it +IPAddressRange_it +ISSUING_DIST_POINT_it +ISSUING_DIST_POINT_it +LONG_it +LONG_it +MD2_options +MD4_Transform +MD5_Transform +NAME_CONSTRAINTS_check +NAME_CONSTRAINTS_check_CN +NAME_CONSTRAINTS_it +NAME_CONSTRAINTS_it +NAMING_AUTHORITY_it +NAMING_AUTHORITY_it +NCONF_WIN32 +NCONF_default +NCONF_dump_bio +NCONF_dump_fp +NCONF_free +NCONF_free_data +NCONF_get_number_e +NCONF_get_section +NCONF_get_string +NCONF_load +NCONF_load_bio +NCONF_load_fp +NCONF_new +NETSCAPE_CERT_SEQUENCE_it +NETSCAPE_CERT_SEQUENCE_it +NETSCAPE_SPKAC_it +NETSCAPE_SPKAC_it +NETSCAPE_SPKI_b64_decode +NETSCAPE_SPKI_b64_encode +NETSCAPE_SPKI_get_pubkey +NETSCAPE_SPKI_it +NETSCAPE_SPKI_it +NETSCAPE_SPKI_print +NETSCAPE_SPKI_set_pubkey +NETSCAPE_SPKI_sign +NETSCAPE_SPKI_verify +NOTICEREF_it +NOTICEREF_it +OBJ_NAME_add +OBJ_NAME_cleanup +OBJ_NAME_do_all +OBJ_NAME_do_all_sorted +OBJ_NAME_get +OBJ_NAME_init +OBJ_NAME_new_index +OBJ_NAME_remove +OBJ_add_object +OBJ_add_sigid +OBJ_bsearch_ +OBJ_bsearch_ex_ +OBJ_create_objects +OBJ_find_sigid_algs +OBJ_find_sigid_by_algs +OBJ_new_nid +OBJ_sigid_free +OCSP_BASICRESP_add1_ext_i2d +OCSP_BASICRESP_add_ext +OCSP_BASICRESP_delete_ext +OCSP_BASICRESP_get1_ext_d2i +OCSP_BASICRESP_get_ext +OCSP_BASICRESP_get_ext_by_NID +OCSP_BASICRESP_get_ext_by_OBJ +OCSP_BASICRESP_get_ext_by_critical +OCSP_BASICRESP_get_ext_count +OCSP_BASICRESP_it +OCSP_BASICRESP_it +OCSP_CERTID_it +OCSP_CERTID_it +OCSP_CERTSTATUS_it +OCSP_CERTSTATUS_it +OCSP_CRLID_it +OCSP_CRLID_it +OCSP_ONEREQ_add1_ext_i2d +OCSP_ONEREQ_add_ext +OCSP_ONEREQ_delete_ext +OCSP_ONEREQ_get1_ext_d2i +OCSP_ONEREQ_get_ext +OCSP_ONEREQ_get_ext_by_NID +OCSP_ONEREQ_get_ext_by_OBJ +OCSP_ONEREQ_get_ext_by_critical +OCSP_ONEREQ_get_ext_count +OCSP_ONEREQ_it +OCSP_ONEREQ_it +OCSP_REQINFO_it +OCSP_REQINFO_it +OCSP_REQUEST_add1_ext_i2d +OCSP_REQUEST_add_ext +OCSP_REQUEST_delete_ext +OCSP_REQUEST_get1_ext_d2i +OCSP_REQUEST_get_ext +OCSP_REQUEST_get_ext_by_NID +OCSP_REQUEST_get_ext_by_OBJ +OCSP_REQUEST_get_ext_by_critical +OCSP_REQUEST_get_ext_count +OCSP_REQUEST_it +OCSP_REQUEST_it +OCSP_REQUEST_print +OCSP_REQ_CTX_get0_mem_bio +OCSP_REQ_CTX_http +OCSP_REQ_CTX_i2d +OCSP_REQ_CTX_nbio +OCSP_REQ_CTX_nbio_d2i +OCSP_REQ_CTX_new +OCSP_RESPBYTES_it +OCSP_RESPBYTES_it +OCSP_RESPDATA_it +OCSP_RESPDATA_it +OCSP_RESPID_it +OCSP_RESPID_it +OCSP_RESPONSE_it +OCSP_RESPONSE_it +OCSP_RESPONSE_print +OCSP_REVOKEDINFO_it +OCSP_REVOKEDINFO_it +OCSP_SERVICELOC_it +OCSP_SERVICELOC_it +OCSP_SIGNATURE_it +OCSP_SIGNATURE_it +OCSP_SINGLERESP_add1_ext_i2d +OCSP_SINGLERESP_add_ext +OCSP_SINGLERESP_delete_ext +OCSP_SINGLERESP_get0_id +OCSP_SINGLERESP_get1_ext_d2i +OCSP_SINGLERESP_get_ext +OCSP_SINGLERESP_get_ext_by_NID +OCSP_SINGLERESP_get_ext_by_OBJ +OCSP_SINGLERESP_get_ext_by_critical +OCSP_SINGLERESP_get_ext_count +OCSP_SINGLERESP_it +OCSP_SINGLERESP_it +OCSP_accept_responses_new +OCSP_archive_cutoff_new +OCSP_basic_add1_cert +OCSP_basic_add1_status +OCSP_cert_status_str +OCSP_crlID2_new +OCSP_crlID_new +OCSP_crl_reason_str +OCSP_onereq_get0_id +OCSP_parse_url +OCSP_request_is_signed +OCSP_request_set1_name +OCSP_request_verify +OCSP_response_status_str +OCSP_url_svcloc_new +OPENSSL_DIR_end +OPENSSL_DIR_read +OPENSSL_LH_delete +OPENSSL_LH_doall +OPENSSL_LH_doall_arg +OPENSSL_LH_error +OPENSSL_LH_free +OPENSSL_LH_get_down_load +OPENSSL_LH_insert +OPENSSL_LH_new +OPENSSL_LH_num_items +OPENSSL_LH_retrieve +OPENSSL_LH_set_down_load +OPENSSL_LH_strhash +OPENSSL_asc2uni +OPENSSL_die +OPENSSL_gmtime +OPENSSL_gmtime_adj +OPENSSL_gmtime_diff +OPENSSL_init +OPENSSL_isservice +OPENSSL_issetugid +OPENSSL_memcmp +OPENSSL_sk_deep_copy +OPENSSL_sk_delete +OPENSSL_sk_delete_ptr +OPENSSL_sk_dup +OPENSSL_sk_find +OPENSSL_sk_find_ex +OPENSSL_sk_free +OPENSSL_sk_insert +OPENSSL_sk_is_sorted +OPENSSL_sk_new +OPENSSL_sk_new_null +OPENSSL_sk_new_reserve +OPENSSL_sk_num +OPENSSL_sk_pop +OPENSSL_sk_pop_free +OPENSSL_sk_push +OPENSSL_sk_reserve +OPENSSL_sk_set +OPENSSL_sk_set_cmp_func +OPENSSL_sk_shift +OPENSSL_sk_sort +OPENSSL_sk_unshift +OPENSSL_sk_value +OPENSSL_sk_zero +OPENSSL_strnlen +OPENSSL_uni2asc +OPENSSL_uni2utf8 +OPENSSL_utf82uni +OSSL_STORE_do_all_loaders +OSSL_STORE_vctrl +OTHERNAME_cmp +OTHERNAME_it +OTHERNAME_it +PBE2PARAM_it +PBE2PARAM_it +PBEPARAM_it +PBEPARAM_it +PBKDF2PARAM_it +PBKDF2PARAM_it +PEM_ASN1_read +PEM_ASN1_read_bio +PEM_ASN1_write +PEM_ASN1_write_bio +PEM_SignFinal +PEM_SignInit +PEM_SignUpdate +PEM_X509_INFO_read +PEM_X509_INFO_read_bio +PEM_X509_INFO_write_bio +PEM_def_callback +PEM_dek_info +PEM_proc_type +PEM_read_bio_ECPrivateKey +PEM_read_bio_Parameters +PEM_write_bio_ASN1_stream +PEM_write_bio_Parameters +PKCS12_AUTHSAFES_it +PKCS12_AUTHSAFES_it +PKCS12_BAGS_it +PKCS12_BAGS_it +PKCS12_MAC_DATA_it +PKCS12_MAC_DATA_it +PKCS12_PBE_add +PKCS12_PBE_keyivgen +PKCS12_SAFEBAGS_it +PKCS12_SAFEBAGS_it +PKCS12_SAFEBAG_create0_p8inf +PKCS12_SAFEBAG_create0_pkcs8 +PKCS12_SAFEBAG_create_cert +PKCS12_SAFEBAG_create_crl +PKCS12_SAFEBAG_create_pkcs8_encrypt +PKCS12_SAFEBAG_get0_attr +PKCS12_SAFEBAG_get0_attrs +PKCS12_SAFEBAG_get0_p8inf +PKCS12_SAFEBAG_get0_pkcs8 +PKCS12_SAFEBAG_get0_safes +PKCS12_SAFEBAG_get0_type +PKCS12_SAFEBAG_get1_cert +PKCS12_SAFEBAG_get1_crl +PKCS12_SAFEBAG_get_bag_nid +PKCS12_SAFEBAG_get_nid +PKCS12_SAFEBAG_it +PKCS12_SAFEBAG_it +PKCS12_add_CSPName_asc +PKCS12_add_cert +PKCS12_add_friendlyname_asc +PKCS12_add_friendlyname_uni +PKCS12_add_friendlyname_utf8 +PKCS12_add_key +PKCS12_add_localkeyid +PKCS12_add_safe +PKCS12_add_safes +PKCS12_decrypt_skey +PKCS12_gen_mac +PKCS12_get0_mac +PKCS12_get_attr +PKCS12_get_attr_gen +PKCS12_get_friendlyname +PKCS12_init +PKCS12_it +PKCS12_it +PKCS12_item_decrypt_d2i +PKCS12_item_i2d_encrypt +PKCS12_item_pack_safebag +PKCS12_key_gen_asc +PKCS12_key_gen_uni +PKCS12_key_gen_utf8 +PKCS12_mac_present +PKCS12_pack_authsafes +PKCS12_pack_p7data +PKCS12_pack_p7encdata +PKCS12_pbe_crypt +PKCS12_set_mac +PKCS12_setup_mac +PKCS12_unpack_authsafes +PKCS12_unpack_p7data +PKCS12_unpack_p7encdata +PKCS12_verify_mac +PKCS1_MGF1 +PKCS5_PBE_add +PKCS5_PBE_keyivgen +PKCS5_pbe2_set +PKCS5_pbe2_set_iv +PKCS5_pbe2_set_scrypt +PKCS5_pbe_set +PKCS5_pbe_set0_algor +PKCS5_pbkdf2_set +PKCS5_v2_PBE_keyivgen +PKCS5_v2_scrypt_keyivgen +PKCS7_ATTR_SIGN_it +PKCS7_ATTR_SIGN_it +PKCS7_ATTR_VERIFY_it +PKCS7_ATTR_VERIFY_it +PKCS7_DIGEST_it +PKCS7_DIGEST_it +PKCS7_ENCRYPT_it +PKCS7_ENCRYPT_it +PKCS7_ENC_CONTENT_it +PKCS7_ENC_CONTENT_it +PKCS7_ENVELOPE_it +PKCS7_ENVELOPE_it +PKCS7_ISSUER_AND_SERIAL_it +PKCS7_ISSUER_AND_SERIAL_it +PKCS7_RECIP_INFO_get0_alg +PKCS7_RECIP_INFO_it +PKCS7_RECIP_INFO_it +PKCS7_RECIP_INFO_set +PKCS7_SIGNED_it +PKCS7_SIGNED_it +PKCS7_SIGNER_INFO_get0_algs +PKCS7_SIGNER_INFO_it +PKCS7_SIGNER_INFO_it +PKCS7_SIGNER_INFO_set +PKCS7_SIGNER_INFO_sign +PKCS7_SIGN_ENVELOPE_it +PKCS7_SIGN_ENVELOPE_it +PKCS7_add0_attrib_signing_time +PKCS7_add1_attrib_digest +PKCS7_add_attrib_content_type +PKCS7_add_attrib_smimecap +PKCS7_add_attribute +PKCS7_add_certificate +PKCS7_add_crl +PKCS7_add_recipient +PKCS7_add_recipient_info +PKCS7_add_signature +PKCS7_add_signed_attribute +PKCS7_add_signer +PKCS7_cert_from_signer_info +PKCS7_content_new +PKCS7_ctrl +PKCS7_dataDecode +PKCS7_dataFinal +PKCS7_dataInit +PKCS7_dataVerify +PKCS7_digest_from_attributes +PKCS7_final +PKCS7_get_attribute +PKCS7_get_issuer_and_serial +PKCS7_get_signed_attribute +PKCS7_get_signer_info +PKCS7_get_smimecap +PKCS7_it +PKCS7_it +PKCS7_set0_type_other +PKCS7_set_attributes +PKCS7_set_cipher +PKCS7_set_content +PKCS7_set_digest +PKCS7_set_signed_attributes +PKCS7_set_type +PKCS7_signatureVerify +PKCS7_simple_smimecap +PKCS7_stream +PKCS7_to_TS_TST_INFO +PKCS8_PRIV_KEY_INFO_it +PKCS8_PRIV_KEY_INFO_it +PKCS8_add_keyusage +PKCS8_decrypt +PKCS8_encrypt +PKCS8_get_attr +PKCS8_pkey_add1_attr_by_NID +PKCS8_pkey_get0 +PKCS8_pkey_get0_attrs +PKCS8_pkey_set0 +PKCS8_set0_pbe +PKEY_USAGE_PERIOD_it +PKEY_USAGE_PERIOD_it +POLICYINFO_it +POLICYINFO_it +POLICYQUALINFO_it +POLICYQUALINFO_it +POLICY_CONSTRAINTS_it +POLICY_CONSTRAINTS_it +POLICY_MAPPINGS_it +POLICY_MAPPINGS_it +POLICY_MAPPING_it +POLICY_MAPPING_it +PROFESSION_INFO_it +PROFESSION_INFO_it +PROXY_CERT_INFO_EXTENSION_it +PROXY_CERT_INFO_EXTENSION_it +PROXY_POLICY_it +PROXY_POLICY_it +RAND_set_rand_engine +RC2_cbc_encrypt +RC2_cfb64_encrypt +RC2_decrypt +RC2_ecb_encrypt +RC2_encrypt +RC2_ofb64_encrypt +RC2_set_key +RC4_options +RC5_32_cbc_encrypt +RC5_32_cfb64_encrypt +RC5_32_decrypt +RC5_32_ecb_encrypt +RC5_32_encrypt +RC5_32_ofb64_encrypt +RC5_32_set_key +RIPEMD160_Transform +RSAPrivateKey_it +RSAPrivateKey_it +RSAPublicKey_it +RSAPublicKey_it +RSA_OAEP_PARAMS_it +RSA_OAEP_PARAMS_it +RSA_PSS_PARAMS_it +RSA_PSS_PARAMS_it +RSA_X931_derive_ex +RSA_X931_generate_key_ex +RSA_X931_hash_id +RSA_null_method +RSA_padding_add_PKCS1_OAEP_mgf1 +RSA_padding_add_PKCS1_PSS +RSA_padding_add_PKCS1_PSS_mgf1 +RSA_padding_add_X931 +RSA_padding_check_PKCS1_OAEP_mgf1 +RSA_padding_check_X931 +RSA_pkey_ctx_ctrl +RSA_setup_blinding +RSA_up_ref +RSA_verify_PKCS1_PSS +RSA_verify_PKCS1_PSS_mgf1 +SCRYPT_PARAMS_it +SCRYPT_PARAMS_it +SEED_cbc_encrypt +SEED_cfb128_encrypt +SEED_decrypt +SEED_ecb_encrypt +SEED_encrypt +SEED_ofb128_encrypt +SEED_set_key +SHA1_Transform +SHA256_Transform +SHA512_Transform +SMIME_crlf_copy +SMIME_read_ASN1 +SMIME_text +SMIME_write_ASN1 +SRP_Calc_A +SRP_Calc_B +SRP_Calc_client_key +SRP_Calc_server_key +SRP_Calc_u +SRP_Calc_x +SRP_VBASE_free +SRP_VBASE_get1_by_user +SRP_VBASE_get_by_user +SRP_VBASE_init +SRP_VBASE_new +SRP_Verify_A_mod_N +SRP_Verify_B_mod_N +SRP_check_known_gN_param +SRP_create_verifier +SRP_create_verifier_BN +SRP_get_default_gN +SRP_user_pwd_free +SXNETID_it +SXNETID_it +SXNET_add_id_INTEGER +SXNET_add_id_asc +SXNET_add_id_ulong +SXNET_get_id_INTEGER +SXNET_get_id_asc +SXNET_get_id_ulong +SXNET_it +SXNET_it +TS_ACCURACY_get_micros +TS_ACCURACY_get_millis +TS_ACCURACY_get_seconds +TS_ACCURACY_set_micros +TS_ACCURACY_set_millis +TS_ACCURACY_set_seconds +TS_ASN1_INTEGER_print_bio +TS_CONF_get_tsa_section +TS_CONF_load_cert +TS_CONF_load_certs +TS_CONF_load_key +TS_CONF_set_accuracy +TS_CONF_set_certs +TS_CONF_set_clock_precision_digits +TS_CONF_set_crypto_device +TS_CONF_set_def_policy +TS_CONF_set_default_engine +TS_CONF_set_digests +TS_CONF_set_ess_cert_id_chain +TS_CONF_set_ess_cert_id_digest +TS_CONF_set_ordering +TS_CONF_set_policies +TS_CONF_set_serial +TS_CONF_set_signer_cert +TS_CONF_set_signer_digest +TS_CONF_set_signer_key +TS_CONF_set_tsa_name +TS_MSG_IMPRINT_get_algo +TS_MSG_IMPRINT_get_msg +TS_MSG_IMPRINT_print_bio +TS_MSG_IMPRINT_set_algo +TS_MSG_IMPRINT_set_msg +TS_OBJ_print_bio +TS_REQ_add_ext +TS_REQ_delete_ext +TS_REQ_ext_free +TS_REQ_get_cert_req +TS_REQ_get_ext +TS_REQ_get_ext_by_NID +TS_REQ_get_ext_by_OBJ +TS_REQ_get_ext_by_critical +TS_REQ_get_ext_count +TS_REQ_get_ext_d2i +TS_REQ_get_exts +TS_REQ_get_msg_imprint +TS_REQ_get_nonce +TS_REQ_get_policy_id +TS_REQ_get_version +TS_REQ_print_bio +TS_REQ_set_cert_req +TS_REQ_set_msg_imprint +TS_REQ_set_nonce +TS_REQ_set_policy_id +TS_REQ_set_version +TS_REQ_to_TS_VERIFY_CTX +TS_RESP_CTX_add_failure_info +TS_RESP_CTX_add_flags +TS_RESP_CTX_add_md +TS_RESP_CTX_add_policy +TS_RESP_CTX_free +TS_RESP_CTX_get_request +TS_RESP_CTX_get_tst_info +TS_RESP_CTX_new +TS_RESP_CTX_set_accuracy +TS_RESP_CTX_set_certs +TS_RESP_CTX_set_clock_precision_digits +TS_RESP_CTX_set_def_policy +TS_RESP_CTX_set_ess_cert_id_digest +TS_RESP_CTX_set_extension_cb +TS_RESP_CTX_set_serial_cb +TS_RESP_CTX_set_signer_cert +TS_RESP_CTX_set_signer_digest +TS_RESP_CTX_set_signer_key +TS_RESP_CTX_set_status_info +TS_RESP_CTX_set_status_info_cond +TS_RESP_CTX_set_time_cb +TS_RESP_create_response +TS_RESP_get_status_info +TS_RESP_get_token +TS_RESP_get_tst_info +TS_RESP_print_bio +TS_RESP_set_status_info +TS_RESP_set_tst_info +TS_RESP_verify_response +TS_RESP_verify_signature +TS_RESP_verify_token +TS_STATUS_INFO_get0_failure_info +TS_STATUS_INFO_get0_status +TS_STATUS_INFO_get0_text +TS_STATUS_INFO_print_bio +TS_STATUS_INFO_set_status +TS_TST_INFO_add_ext +TS_TST_INFO_delete_ext +TS_TST_INFO_ext_free +TS_TST_INFO_get_accuracy +TS_TST_INFO_get_ext +TS_TST_INFO_get_ext_by_NID +TS_TST_INFO_get_ext_by_OBJ +TS_TST_INFO_get_ext_by_critical +TS_TST_INFO_get_ext_count +TS_TST_INFO_get_ext_d2i +TS_TST_INFO_get_exts +TS_TST_INFO_get_msg_imprint +TS_TST_INFO_get_nonce +TS_TST_INFO_get_ordering +TS_TST_INFO_get_policy_id +TS_TST_INFO_get_serial +TS_TST_INFO_get_time +TS_TST_INFO_get_tsa +TS_TST_INFO_get_version +TS_TST_INFO_print_bio +TS_TST_INFO_set_accuracy +TS_TST_INFO_set_msg_imprint +TS_TST_INFO_set_nonce +TS_TST_INFO_set_ordering +TS_TST_INFO_set_policy_id +TS_TST_INFO_set_serial +TS_TST_INFO_set_time +TS_TST_INFO_set_tsa +TS_TST_INFO_set_version +TS_VERIFY_CTS_set_certs +TS_VERIFY_CTX_add_flags +TS_VERIFY_CTX_cleanup +TS_VERIFY_CTX_free +TS_VERIFY_CTX_init +TS_VERIFY_CTX_new +TS_VERIFY_CTX_set_data +TS_VERIFY_CTX_set_flags +TS_VERIFY_CTX_set_imprint +TS_VERIFY_CTX_set_store +TS_X509_ALGOR_print_bio +TS_ext_print_bio +TXT_DB_create_index +TXT_DB_free +TXT_DB_get_by_index +TXT_DB_insert +TXT_DB_read +TXT_DB_write +UINT32_it +UINT32_it +UINT64_it +UINT64_it +USERNOTICE_it +USERNOTICE_it +UTF8_getc +UTF8_putc +WHIRLPOOL +WHIRLPOOL_BitUpdate +WHIRLPOOL_Final +WHIRLPOOL_Init +WHIRLPOOL_Update +X509V3_EXT_CRL_add_conf +X509V3_EXT_CRL_add_nconf +X509V3_EXT_REQ_add_conf +X509V3_EXT_REQ_add_nconf +X509V3_EXT_add +X509V3_EXT_add_alias +X509V3_EXT_add_conf +X509V3_EXT_add_list +X509V3_EXT_add_nconf +X509V3_EXT_add_nconf_sk +X509V3_EXT_cleanup +X509V3_EXT_conf +X509V3_EXT_conf_nid +X509V3_EXT_get +X509V3_EXT_get_nid +X509V3_EXT_nconf +X509V3_EXT_nconf_nid +X509V3_EXT_print +X509V3_EXT_print_fp +X509V3_EXT_val_prn +X509V3_NAME_from_section +X509V3_add_standard_extensions +X509V3_add_value +X509V3_add_value_bool +X509V3_add_value_bool_nf +X509V3_add_value_int +X509V3_add_value_uchar +X509V3_conf_free +X509V3_extensions_print +X509V3_get_section +X509V3_get_string +X509V3_get_value_bool +X509V3_get_value_int +X509V3_parse_list +X509V3_section_free +X509V3_set_conf_lhash +X509V3_set_ctx +X509V3_set_nconf +X509V3_string_free +X509_ALGORS_it +X509_ALGORS_it +X509_ALGOR_it +X509_ALGOR_it +X509_ATTRIBUTE_count +X509_ATTRIBUTE_create +X509_ATTRIBUTE_create_by_NID +X509_ATTRIBUTE_create_by_OBJ +X509_ATTRIBUTE_create_by_txt +X509_ATTRIBUTE_get0_data +X509_ATTRIBUTE_get0_object +X509_ATTRIBUTE_get0_type +X509_ATTRIBUTE_it +X509_ATTRIBUTE_it +X509_ATTRIBUTE_set1_data +X509_ATTRIBUTE_set1_object +X509_CERT_AUX_it +X509_CERT_AUX_it +X509_CINF_it +X509_CINF_it +X509_CRL_INFO_it +X509_CRL_INFO_it +X509_CRL_METHOD_free +X509_CRL_METHOD_new +X509_CRL_check_suiteb +X509_CRL_cmp +X509_CRL_diff +X509_CRL_get_lastUpdate +X509_CRL_get_meth_data +X509_CRL_get_nextUpdate +X509_CRL_http_nbio +X509_CRL_it +X509_CRL_it +X509_CRL_match +X509_CRL_print +X509_CRL_print_ex +X509_CRL_print_fp +X509_CRL_set_default_method +X509_CRL_set_meth_data +X509_CRL_up_ref +X509_EXTENSIONS_it +X509_EXTENSIONS_it +X509_EXTENSION_it +X509_EXTENSION_it +X509_INFO_free +X509_INFO_new +X509_LOOKUP_by_alias +X509_LOOKUP_by_fingerprint +X509_LOOKUP_by_issuer_serial +X509_LOOKUP_by_subject +X509_LOOKUP_ctrl +X509_LOOKUP_free +X509_LOOKUP_init +X509_LOOKUP_new +X509_LOOKUP_shutdown +X509_NAME_ENTRY_it +X509_NAME_ENTRY_it +X509_NAME_ENTRY_set +X509_NAME_cmp +X509_NAME_hash +X509_NAME_hash_old +X509_NAME_it +X509_NAME_it +X509_NAME_set +X509_OBJECT_free +X509_OBJECT_get0_X509 +X509_OBJECT_get0_X509_CRL +X509_OBJECT_get_type +X509_OBJECT_idx_by_subject +X509_OBJECT_new +X509_OBJECT_retrieve_by_subject +X509_OBJECT_retrieve_match +X509_OBJECT_up_ref_count +X509_PKEY_free +X509_PKEY_new +X509_POLICY_NODE_print +X509_PUBKEY_it +X509_PUBKEY_it +X509_PURPOSE_add +X509_PURPOSE_cleanup +X509_PURPOSE_get0 +X509_PURPOSE_get0_name +X509_PURPOSE_get0_sname +X509_PURPOSE_get_by_id +X509_PURPOSE_get_by_sname +X509_PURPOSE_get_count +X509_PURPOSE_get_id +X509_PURPOSE_get_trust +X509_PURPOSE_set +X509_REQ_INFO_it +X509_REQ_INFO_it +X509_REQ_add1_attr +X509_REQ_add1_attr_by_NID +X509_REQ_add1_attr_by_OBJ +X509_REQ_add1_attr_by_txt +X509_REQ_add_extensions +X509_REQ_add_extensions_nid +X509_REQ_delete_attr +X509_REQ_extension_nid +X509_REQ_get1_email +X509_REQ_get_attr +X509_REQ_get_attr_by_NID +X509_REQ_get_attr_by_OBJ +X509_REQ_get_attr_count +X509_REQ_get_extension_nids +X509_REQ_get_extensions +X509_REQ_it +X509_REQ_it +X509_REQ_print +X509_REQ_print_ex +X509_REQ_print_fp +X509_REQ_set_extension_nids +X509_REQ_to_X509 +X509_REVOKED_it +X509_REVOKED_it +X509_SIG_it +X509_SIG_it +X509_STORE_CTX_get0_current_crl +X509_STORE_CTX_get0_current_issuer +X509_STORE_CTX_get0_parent_ctx +X509_STORE_CTX_get0_policy_tree +X509_STORE_CTX_get0_store +X509_STORE_CTX_get1_certs +X509_STORE_CTX_get1_crls +X509_STORE_CTX_get1_issuer +X509_STORE_CTX_get_by_subject +X509_STORE_CTX_get_explicit_policy +X509_STORE_CTX_get_obj_by_subject +X509_STORE_CTX_purpose_inherit +X509_STORE_CTX_set0_dane +X509_STORE_CTX_set_depth +X509_STORE_CTX_set_flags +X509_STORE_CTX_set_purpose +X509_STORE_CTX_set_time +X509_STORE_CTX_set_trust +X509_STORE_add_lookup +X509_STORE_get_verify +X509_TRUST_add +X509_TRUST_cleanup +X509_TRUST_get0 +X509_TRUST_get0_name +X509_TRUST_get_by_id +X509_TRUST_get_count +X509_TRUST_get_flags +X509_TRUST_get_trust +X509_TRUST_set +X509_TRUST_set_default +X509_VAL_it +X509_VAL_it +X509_VERIFY_PARAM_add0_table +X509_VERIFY_PARAM_free +X509_VERIFY_PARAM_get0 +X509_VERIFY_PARAM_get0_name +X509_VERIFY_PARAM_get_count +X509_VERIFY_PARAM_inherit +X509_VERIFY_PARAM_lookup +X509_VERIFY_PARAM_move_peername +X509_VERIFY_PARAM_new +X509_VERIFY_PARAM_set1 +X509_VERIFY_PARAM_set1_name +X509_VERIFY_PARAM_table_cleanup +X509_add1_reject_object +X509_add1_trust_object +X509_alias_get0 +X509_alias_set1 +X509_aux_print +X509_certificate_type +X509_chain_check_suiteb +X509_check_akid +X509_check_purpose +X509_check_trust +X509_cmp +X509_email_free +X509_find_by_issuer_and_serial +X509_find_by_subject +X509_get0_pubkey_bitstr +X509_get0_reject_objects +X509_get0_trust_objects +X509_get1_email +X509_get1_ocsp +X509_get_default_cert_area +X509_get_default_cert_dir +X509_get_default_cert_dir_env +X509_get_default_cert_file +X509_get_default_cert_file_env +X509_get_default_private_dir +X509_get_pubkey_parameters +X509_get_signature_type +X509_gmtime_adj +X509_http_nbio +X509_issuer_and_serial_cmp +X509_issuer_and_serial_hash +X509_issuer_name_cmp +X509_issuer_name_hash +X509_issuer_name_hash_old +X509_it +X509_it +X509_keyid_get0 +X509_keyid_set1 +X509_ocspid_print +X509_policy_check +X509_policy_level_get0_node +X509_policy_level_node_count +X509_policy_node_get0_parent +X509_policy_node_get0_policy +X509_policy_node_get0_qualifiers +X509_policy_tree_free +X509_policy_tree_get0_level +X509_policy_tree_get0_policies +X509_policy_tree_get0_user_policies +X509_policy_tree_level_count +X509_print +X509_print_ex +X509_print_ex_fp +X509_print_fp +X509_reject_clear +X509_signature_dump +X509_signature_print +X509_subject_name_cmp +X509_subject_name_hash +X509_subject_name_hash_old +X509_supported_extension +X509_to_X509_REQ +X509_trust_clear +X509_trusted +X509at_add1_attr +X509at_add1_attr_by_NID +X509at_add1_attr_by_OBJ +X509at_add1_attr_by_txt +X509at_delete_attr +X509at_get0_data_by_OBJ +X509at_get_attr +X509at_get_attr_by_NID +X509at_get_attr_by_OBJ +X509at_get_attr_count +X509v3_addr_add_inherit +X509v3_addr_add_prefix +X509v3_addr_add_range +X509v3_addr_canonize +X509v3_addr_get_afi +X509v3_addr_get_range +X509v3_addr_inherits +X509v3_addr_is_canonical +X509v3_addr_subset +X509v3_addr_validate_path +X509v3_addr_validate_resource_set +X509v3_asid_add_id_or_range +X509v3_asid_add_inherit +X509v3_asid_canonize +X509v3_asid_inherits +X509v3_asid_is_canonical +X509v3_asid_subset +X509v3_asid_validate_path +X509v3_asid_validate_resource_set +ZINT32_it +ZINT32_it +ZINT64_it +ZINT64_it +ZLONG_it +ZLONG_it +ZUINT32_it +ZUINT32_it +ZUINT64_it +ZUINT64_it +_shadow_DES_check_key +_shadow_DES_check_key +a2d_ASN1_OBJECT +a2i_ASN1_ENUMERATED +a2i_ASN1_INTEGER +a2i_ASN1_STRING +a2i_GENERAL_NAME +a2i_IPADDRESS +a2i_IPADDRESS_NC +b2i_PVK_bio +b2i_PrivateKey +b2i_PrivateKey_bio +b2i_PublicKey +b2i_PublicKey_bio +conf_ssl_get +conf_ssl_get_cmd +conf_ssl_name_find +d2i_ESS_CERT_ID_V2 +d2i_ESS_SIGNING_CERT_V2 +d2i_X509_bio +d2i_X509_fp +err_free_strings_int +i2a_ACCESS_DESCRIPTION +i2a_ASN1_ENUMERATED +i2a_ASN1_INTEGER +i2a_ASN1_OBJECT +i2a_ASN1_STRING +i2b_PVK_bio +i2b_PrivateKey_bio +i2b_PublicKey_bio +i2d_ESS_CERT_ID_V2 +i2d_ESS_SIGNING_CERT_V2 +i2d_PrivateKey_bio +i2d_PrivateKey_fp +i2d_X509_bio +i2d_X509_fp +i2o_ECPublicKey +i2s_ASN1_ENUMERATED +i2s_ASN1_ENUMERATED_TABLE +i2s_ASN1_IA5STRING +i2s_ASN1_INTEGER +i2s_ASN1_OCTET_STRING +i2v_ASN1_BIT_STRING +i2v_GENERAL_NAME +i2v_GENERAL_NAMES +o2i_ECPublicKey +s2i_ASN1_IA5STRING +s2i_ASN1_INTEGER +s2i_ASN1_OCTET_STRING +v2i_ASN1_BIT_STRING +v2i_GENERAL_NAME +v2i_GENERAL_NAMES +v2i_GENERAL_NAME_ex diff --git a/util/missingmacro.txt b/util/missingmacro.txt new file mode 100644 index 00000000..db4ce86e --- /dev/null +++ b/util/missingmacro.txt @@ -0,0 +1,216 @@ +# A list of macros that are known to be missing documentation as used by the +# find-doc-nits -v option. The list is as of commit 355b419698. +BIO_get_flags +BIO_set_retry_special +BIO_set_retry_read +BIO_set_retry_write +BIO_clear_retry_flags +BIO_get_retry_flags +BIO_CB_return +BIO_cb_pre +BIO_cb_post +BIO_set_app_data +BIO_get_app_data +BIO_set_conn_mode +BIO_dup_state +BIO_buffer_get_num_lines +BIO_buffer_peek +BIO_ctrl_dgram_connect +BIO_ctrl_set_connected +BIO_dgram_recv_timedout +BIO_dgram_send_timedout +BIO_dgram_get_peer +BIO_dgram_set_peer +BIO_dgram_get_mtu_overhead +BIO_sock_cleanup +ossl_bio__attr__ +BN_prime_checks_for_size +BN_GF2m_sub +BN_GF2m_cmp +BUF_strdup +BUF_strndup +BUF_memdup +BUF_strlcpy +BUF_strlcat +BUF_strnlen +COMP_zlib_cleanup +NCONF_get_number +OSSL_CORE_MAKE_FUNC +OPENSSL_MALLOC_MAX_NELEMS +CRYPTO_cleanup_all_ex_data +CRYPTO_num_locks +CRYPTO_set_locking_callback +CRYPTO_get_locking_callback +CRYPTO_set_add_lock_callback +CRYPTO_get_add_lock_callback +CRYPTO_THREADID_set_numeric +CRYPTO_THREADID_set_pointer +CRYPTO_THREADID_set_callback +CRYPTO_THREADID_get_callback +CRYPTO_THREADID_current +CRYPTO_THREADID_cmp +CRYPTO_THREADID_cpy +CRYPTO_THREADID_hash +CRYPTO_set_id_callback +CRYPTO_get_id_callback +CRYPTO_thread_id +CRYPTO_set_dynlock_create_callback +CRYPTO_set_dynlock_lock_callback +CRYPTO_set_dynlock_destroy_callback +CRYPTO_get_dynlock_create_callback +CRYPTO_get_dynlock_lock_callback +CRYPTO_get_dynlock_destroy_callback +OpenSSLDie +OPENSSL_assert +DSA_is_prime +ECParameters_dup +ENGINE_load_openssl +ENGINE_load_dynamic +ENGINE_load_padlock +ENGINE_load_capi +ENGINE_load_afalg +ENGINE_load_cryptodev +ENGINE_load_rdrand +EVP_MD_nid +EVP_MD_name +EVP_CIPHER_name +EVP_ENCODE_LENGTH +EVP_DECODE_LENGTH +BIO_set_md_ctx +EVP_add_cipher_alias +EVP_add_digest_alias +EVP_delete_cipher_alias +EVP_delete_digest_alias +EVP_MD_CTX_create +EVP_MD_CTX_init +EVP_MD_CTX_destroy +EVP_CIPHER_CTX_init +EVP_CIPHER_CTX_cleanup +OPENSSL_add_all_algorithms_conf +OPENSSL_add_all_algorithms_noconf +LHASH_HASH_FN +LHASH_COMP_FN +LHASH_DOALL_ARG_FN +LHASH_OF +DEFINE_LHASH_OF +int_implement_lhash_doall +OBJ_create_and_add_object +OBJ_bsearch +OBJ_bsearch_ex +PEM_read_bio_OCSP_REQUEST +PEM_read_bio_OCSP_RESPONSE +PEM_write_bio_OCSP_REQUEST +PEM_write_bio_OCSP_RESPONSE +ASN1_BIT_STRING_digest +OCSP_CERTSTATUS_dup +OPENSSL_VERSION_PREREQ +OPENSSL_MSTR_HELPER +OPENSSL_MSTR +OSSL_PARAM_DEFN +OSSL_PARAM_int +OSSL_PARAM_uint +OSSL_PARAM_long +OSSL_PARAM_ulong +OSSL_PARAM_int32 +OSSL_PARAM_uint32 +OSSL_PARAM_int64 +OSSL_PARAM_uint64 +OSSL_PARAM_size_t +OSSL_PARAM_double +OSSL_PARAM_SIZED_int +OSSL_PARAM_SIZED_uint +OSSL_PARAM_SIZED_long +OSSL_PARAM_SIZED_ulong +OSSL_PARAM_SIZED_int32 +OSSL_PARAM_SIZED_uint32 +OSSL_PARAM_SIZED_int64 +OSSL_PARAM_SIZED_uint64 +OSSL_PARAM_SIZED_size_t +OSSL_PARAM_SIZED_double +PKCS7_get_signed_attributes +PKCS7_get_attributes +PKCS7_type_is_signed +PKCS7_type_is_encrypted +PKCS7_type_is_enveloped +PKCS7_type_is_signedAndEnveloped +PKCS7_type_is_data +PKCS7_type_is_digest +PKCS7_set_detached +PKCS7_get_detached +PKCS7_is_detached +RSA_set_app_data +RSA_get_app_data +STACK_OF +SKM_DEFINE_STACK_OF +U64 +SSL_set_mtu +DTLS_set_link_mtu +DTLS_get_link_min_mtu +SSL_CTX_set_cert_flags +SSL_set_cert_flags +SSL_CTX_clear_cert_flags +SSL_clear_cert_flags +SSL_set_app_data +SSL_get_app_data +SSL_SESSION_set_app_data +SSL_SESSION_get_app_data +SSL_CTX_get_app_data +SSL_CTX_set_app_data +SSLeay_add_ssl_algorithms +DTLSv1_get_timeout +DTLSv1_handle_timeout +SSL_num_renegotiations +SSL_clear_num_renegotiations +SSL_total_renegotiations +SSL_CTX_set_dh_auto +SSL_set_dh_auto +SSL_get0_certificate_types +SSL_CTX_set1_client_certificate_types +SSL_set1_client_certificate_types +SSL_get0_raw_cipherlist +SSL_get0_ec_point_formats +SSL_CTX_need_tmp_RSA +SSL_CTX_set_tmp_rsa +SSL_need_tmp_RSA +SSL_set_tmp_rsa +SSL_CTX_set_tmp_rsa_callback +SSL_set_tmp_rsa_callback +SSL_get_ex_new_index +SSL_SESSION_get_ex_new_index +SSL_CTX_get_ex_new_index +SSL_CTX_set_default_read_ahead +SSL_cache_hit +TLS1_get_version +TLS1_get_client_version +SSL_set_tlsext_debug_callback +SSL_set_tlsext_debug_arg +SSL_get_tlsext_status_exts +SSL_set_tlsext_status_exts +SSL_get_tlsext_status_ids +SSL_set_tlsext_status_ids +SSL_CTX_get_tlsext_ticket_keys +SSL_CTX_set_tlsext_ticket_keys +OSSL_TRACE_CANCEL +OSSL_TRACE_ENABLED +OSSL_TRACEV +OSSL_TRACE +OSSL_TRACE3 +OSSL_TRACE4 +OSSL_TRACE5 +OSSL_TRACE6 +OSSL_TRACE7 +OSSL_TRACE8 +UI_set_app_data +UI_get_app_data +X509_extract_key +X509_REQ_extract_key +X509_name_cmp +X509_STORE_CTX_set_app_data +X509_STORE_CTX_get_app_data +X509_LOOKUP_load_file +X509_LOOKUP_add_dir +X509V3_conf_err +X509V3_set_ctx_test +X509V3_set_ctx_nodb +EXT_BITSTRING +EXT_IA5STRING diff --git a/util/missingmacro111.txt b/util/missingmacro111.txt new file mode 100644 index 00000000..f4294596 --- /dev/null +++ b/util/missingmacro111.txt @@ -0,0 +1,232 @@ +# A list of macros that are known to be missing documentation as used by the +# find-doc-nits -v -o option. The list is as of commit 1708e3e85b (the release +# of 1.1.1). +BIO_get_flags +BIO_set_retry_special +BIO_set_retry_read +BIO_set_retry_write +BIO_clear_retry_flags +BIO_get_retry_flags +BIO_CB_return +BIO_cb_pre +BIO_cb_post +BIO_set_app_data +BIO_get_app_data +BIO_set_conn_mode +BIO_dup_state +BIO_buffer_get_num_lines +BIO_buffer_peek +BIO_ctrl_dgram_connect +BIO_ctrl_set_connected +BIO_dgram_recv_timedout +BIO_dgram_send_timedout +BIO_dgram_get_peer +BIO_dgram_set_peer +BIO_dgram_get_mtu_overhead +BIO_sock_cleanup +ossl_bio__attr__ +BN_prime_checks_for_size +BN_GF2m_sub +BN_GF2m_cmp +BUF_strdup +BUF_strndup +BUF_memdup +BUF_strlcpy +BUF_strlcat +BUF_strnlen +COMP_zlib_cleanup +NCONF_get_number +OPENSSL_MALLOC_MAX_NELEMS +CRYPTO_cleanup_all_ex_data +CRYPTO_num_locks +CRYPTO_set_locking_callback +CRYPTO_get_locking_callback +CRYPTO_set_add_lock_callback +CRYPTO_get_add_lock_callback +CRYPTO_THREADID_set_numeric +CRYPTO_THREADID_set_pointer +CRYPTO_THREADID_set_callback +CRYPTO_THREADID_get_callback +CRYPTO_THREADID_current +CRYPTO_THREADID_cmp +CRYPTO_THREADID_cpy +CRYPTO_THREADID_hash +CRYPTO_set_id_callback +CRYPTO_get_id_callback +CRYPTO_thread_id +CRYPTO_set_dynlock_create_callback +CRYPTO_set_dynlock_lock_callback +CRYPTO_set_dynlock_destroy_callback +CRYPTO_get_dynlock_create_callback +CRYPTO_get_dynlock_lock_callback +CRYPTO_get_dynlock_destroy_callback +OpenSSLDie +OPENSSL_assert +EVP_PKEY_CTX_set_dh_paramgen_subprime_len +EVP_PKEY_CTX_set_dh_paramgen_type +EVP_PKEY_CTX_set_dh_rfc5114 +EVP_PKEY_CTX_set_dhx_rfc5114 +EVP_PKEY_CTX_set_dh_kdf_type +EVP_PKEY_CTX_get_dh_kdf_type +EVP_PKEY_CTX_set0_dh_kdf_oid +EVP_PKEY_CTX_get0_dh_kdf_oid +EVP_PKEY_CTX_set_dh_kdf_md +EVP_PKEY_CTX_get_dh_kdf_md +EVP_PKEY_CTX_set_dh_kdf_outlen +EVP_PKEY_CTX_get_dh_kdf_outlen +EVP_PKEY_CTX_set0_dh_kdf_ukm +EVP_PKEY_CTX_get0_dh_kdf_ukm +DSA_is_prime +OPENSSL_GLOBAL_REF +OPENSSL_GLOBAL_REF +ECParameters_dup +EVP_PKEY_CTX_set_ecdh_cofactor_mode +EVP_PKEY_CTX_get_ecdh_cofactor_mode +EVP_PKEY_CTX_set_ecdh_kdf_type +EVP_PKEY_CTX_get_ecdh_kdf_type +EVP_PKEY_CTX_set_ecdh_kdf_md +EVP_PKEY_CTX_get_ecdh_kdf_md +EVP_PKEY_CTX_set_ecdh_kdf_outlen +EVP_PKEY_CTX_get_ecdh_kdf_outlen +EVP_PKEY_CTX_set0_ecdh_kdf_ukm +EVP_PKEY_CTX_get0_ecdh_kdf_ukm +ENGINE_load_openssl +ENGINE_load_dynamic +ENGINE_load_padlock +ENGINE_load_capi +ENGINE_load_afalg +ENGINE_load_cryptodev +ENGINE_load_rdrand +EVP_PKEY_assign_SIPHASH +EVP_PKEY_assign_POLY1305 +EVP_MD_nid +EVP_MD_name +EVP_CIPHER_name +EVP_ENCODE_LENGTH +EVP_DECODE_LENGTH +BIO_set_md_ctx +EVP_add_cipher_alias +EVP_add_digest_alias +EVP_delete_cipher_alias +EVP_delete_digest_alias +EVP_MD_CTX_create +EVP_MD_CTX_init +EVP_MD_CTX_destroy +EVP_CIPHER_CTX_init +EVP_CIPHER_CTX_cleanup +OPENSSL_add_all_algorithms_conf +OPENSSL_add_all_algorithms_noconf +LHASH_HASH_FN +LHASH_COMP_FN +LHASH_DOALL_ARG_FN +LHASH_OF +DEFINE_LHASH_OF +int_implement_lhash_doall +OBJ_create_and_add_object +OBJ_bsearch +OBJ_bsearch_ex +PEM_read_bio_OCSP_REQUEST +PEM_read_bio_OCSP_RESPONSE +PEM_write_bio_OCSP_REQUEST +PEM_write_bio_OCSP_RESPONSE +ASN1_BIT_STRING_digest +OCSP_CERTSTATUS_dup +PKCS7_get_signed_attributes +PKCS7_get_attributes +PKCS7_type_is_signed +PKCS7_type_is_encrypted +PKCS7_type_is_enveloped +PKCS7_type_is_signedAndEnveloped +PKCS7_type_is_data +PKCS7_type_is_digest +PKCS7_set_detached +PKCS7_get_detached +PKCS7_is_detached +EVP_PKEY_CTX_get_rsa_padding +EVP_PKEY_CTX_get_rsa_pss_saltlen +EVP_PKEY_CTX_set_rsa_keygen_primes +EVP_PKEY_CTX_set_rsa_mgf1_md +EVP_PKEY_CTX_set_rsa_oaep_md +EVP_PKEY_CTX_get_rsa_mgf1_md +EVP_PKEY_CTX_get_rsa_oaep_md +EVP_PKEY_CTX_set0_rsa_oaep_label +EVP_PKEY_CTX_get0_rsa_oaep_label +RSA_set_app_data +RSA_get_app_data +STACK_OF +SKM_DEFINE_STACK_OF +U64 +U64 +U64 +SSL_set_mtu +DTLS_set_link_mtu +DTLS_get_link_min_mtu +SSL_heartbeat +SSL_CTX_set_cert_flags +SSL_set_cert_flags +SSL_CTX_clear_cert_flags +SSL_clear_cert_flags +SSL_set_app_data +SSL_get_app_data +SSL_SESSION_set_app_data +SSL_SESSION_get_app_data +SSL_CTX_get_app_data +SSL_CTX_set_app_data +SSLeay_add_ssl_algorithms +DTLSv1_get_timeout +DTLSv1_handle_timeout +SSL_num_renegotiations +SSL_clear_num_renegotiations +SSL_total_renegotiations +SSL_CTX_set_tmp_ecdh +SSL_CTX_set_dh_auto +SSL_set_dh_auto +SSL_set_tmp_ecdh +SSL_CTX_get_extra_chain_certs +SSL_CTX_get_extra_chain_certs_only +SSL_get0_certificate_types +SSL_CTX_set1_client_certificate_types +SSL_set1_client_certificate_types +SSL_get0_raw_cipherlist +SSL_get0_ec_point_formats +SSL_CTX_need_tmp_RSA +SSL_CTX_set_tmp_rsa +SSL_need_tmp_RSA +SSL_set_tmp_rsa +SSL_CTX_set_ecdh_auto +SSL_set_ecdh_auto +SSL_CTX_set_tmp_rsa_callback +SSL_set_tmp_rsa_callback +SSL_get_ex_new_index +SSL_SESSION_get_ex_new_index +SSL_CTX_get_ex_new_index +SSL_CTX_set_default_read_ahead +SSL_cache_hit +TLS1_get_version +TLS1_get_client_version +SSL_set_tlsext_debug_callback +SSL_set_tlsext_debug_arg +SSL_get_tlsext_status_exts +SSL_set_tlsext_status_exts +SSL_get_tlsext_status_ids +SSL_set_tlsext_status_ids +SSL_CTX_get_tlsext_ticket_keys +SSL_CTX_set_tlsext_ticket_keys +SSL_get_dtlsext_heartbeat_pending +SSL_set_dtlsext_heartbeat_no_requests +SSL_get_tlsext_heartbeat_pending +SSL_set_tlsext_heartbeat_no_requests +UI_set_app_data +UI_get_app_data +X509_extract_key +X509_REQ_extract_key +X509_name_cmp +X509_STORE_CTX_set_app_data +X509_STORE_CTX_get_app_data +X509_LOOKUP_load_file +X509_LOOKUP_add_dir +X509V3_conf_err +X509V3_set_ctx_test +X509V3_set_ctx_nodb +EXT_BITSTRING +EXT_IA5STRING diff --git a/util/missingssl.txt b/util/missingssl.txt new file mode 100644 index 00000000..07ba2b37 --- /dev/null +++ b/util/missingssl.txt @@ -0,0 +1,46 @@ +# A list of libssl functions that are known to be missing documentation as +# used by the find-doc-nits -v option. The list is as of commit 355b419698. +ERR_load_SSL_strings +SRP_Calc_A_param +SSL_COMP_get_name +SSL_COMP_set0_compression_methods +SSL_CONF_CTX_finish +SSL_CTX_SRP_CTX_free +SSL_CTX_SRP_CTX_init +SSL_CTX_get0_certificate +SSL_CTX_get0_ctlog_store +SSL_CTX_get0_privatekey +SSL_CTX_get_ssl_method +SSL_CTX_set0_ctlog_store +SSL_CTX_set_client_cert_engine +SSL_CTX_set_cookie_generate_cb +SSL_CTX_set_cookie_verify_cb +SSL_CTX_set_not_resumable_session_callback +SSL_CTX_set_purpose +SSL_CTX_set_trust +SSL_SRP_CTX_free +SSL_SRP_CTX_init +SSL_add_dir_cert_subjects_to_stack +SSL_add_file_cert_subjects_to_stack +SSL_add_ssl_module +SSL_certs_clear +SSL_copy_session_id +SSL_dup_CA_list +SSL_get0_dane +SSL_get_certificate +SSL_get_current_compression +SSL_get_current_expansion +SSL_get_finished +SSL_get_peer_finished +SSL_get_privatekey +SSL_set_SSL_CTX +SSL_set_debug +SSL_set_not_resumable_session_callback +SSL_set_purpose +SSL_set_session_secret_cb +SSL_set_session_ticket_ext +SSL_set_session_ticket_ext_cb +SSL_set_trust +SSL_srp_server_param_with_username +SSL_test_functions +SSL_trace diff --git a/util/missingssl111.txt b/util/missingssl111.txt new file mode 100644 index 00000000..c3459c61 --- /dev/null +++ b/util/missingssl111.txt @@ -0,0 +1,60 @@ +# A list of libssl functions that are known to be missing documentation as +# used by the find-doc-nits -v -o option. The list is as of commit 1708e3e85b +# (the release of 1.1.1). +ERR_load_SSL_strings +SRP_Calc_A_param +SSL_COMP_get_name +SSL_COMP_set0_compression_methods +SSL_CONF_CTX_finish +SSL_CTX_SRP_CTX_free +SSL_CTX_SRP_CTX_init +SSL_CTX_get0_certificate +SSL_CTX_get0_ctlog_store +SSL_CTX_get0_privatekey +SSL_CTX_get_ssl_method +SSL_CTX_set0_ctlog_store +SSL_CTX_set_client_cert_engine +SSL_CTX_set_cookie_generate_cb +SSL_CTX_set_cookie_verify_cb +SSL_CTX_set_not_resumable_session_callback +SSL_CTX_set_purpose +SSL_CTX_set_srp_cb_arg +SSL_CTX_set_srp_client_pwd_callback +SSL_CTX_set_srp_password +SSL_CTX_set_srp_strength +SSL_CTX_set_srp_username +SSL_CTX_set_srp_username_callback +SSL_CTX_set_srp_verify_param_callback +SSL_CTX_set_trust +SSL_SRP_CTX_free +SSL_SRP_CTX_init +SSL_add_dir_cert_subjects_to_stack +SSL_add_file_cert_subjects_to_stack +SSL_add_ssl_module +SSL_certs_clear +SSL_copy_session_id +SSL_dup_CA_list +SSL_get0_dane +SSL_get_certificate +SSL_get_current_compression +SSL_get_current_expansion +SSL_get_finished +SSL_get_peer_finished +SSL_get_privatekey +SSL_get_srp_N +SSL_get_srp_g +SSL_get_srp_userinfo +SSL_get_srp_username +SSL_set_SSL_CTX +SSL_set_debug +SSL_set_not_resumable_session_callback +SSL_set_purpose +SSL_set_session_secret_cb +SSL_set_session_ticket_ext +SSL_set_session_ticket_ext_cb +SSL_set_srp_server_param +SSL_set_srp_server_param_pw +SSL_set_trust +SSL_srp_server_param_with_username +SSL_test_functions +SSL_trace diff --git a/util/mkdef.pl b/util/mkdef.pl index 83c9d799..a860db60 100755 --- a/util/mkdef.pl +++ b/util/mkdef.pl @@ -109,24 +109,20 @@ my $libname = platform->sharedname($name); my %OS_data = ( solaris => { writer => \&writer_linux, sort => sorter_linux(), - platforms => { UNIX => 1, - EXPORT_VAR_AS_FUNCTION => 0 } }, + platforms => { UNIX => 1 } }, linux => 'solaris', # alias "bsd-gcc" => 'solaris', # alias aix => { writer => \&writer_aix, sort => sorter_unix(), - platforms => { UNIX => 1, - EXPORT_VAR_AS_FUNCTION => 0 } }, + platforms => { UNIX => 1 } }, VMS => { writer => \&writer_VMS, sort => OpenSSL::Ordinals::by_number(), - platforms => { VMS => 1, - EXPORT_VAR_AS_FUNCTION => 0 } }, + platforms => { VMS => 1 } }, vms => 'VMS', # alias WINDOWS => { writer => \&writer_windows, sort => OpenSSL::Ordinals::by_name(), platforms => { WIN32 => 1, - _WIN32 => 1, - EXPORT_VAR_AS_FUNCTION => 1 } }, + _WIN32 => 1 } }, windows => 'WINDOWS', # alias WIN32 => 'WINDOWS', # alias win32 => 'WIN32', # alias diff --git a/util/perl/OpenSSL/Ordinals.pm b/util/perl/OpenSSL/Ordinals.pm index c26a8664..302d58f8 100644 --- a/util/perl/OpenSSL/Ordinals.pm +++ b/util/perl/OpenSSL/Ordinals.pm @@ -342,8 +342,6 @@ sub _parse_platforms { # if ($def =~ m{^__DragonFly__$}) { $platforms{$&} = $op; } # if ($def =~ m{^__OpenBSD__$}) { $platforms{$&} = $op; } # if ($def =~ m{^__NetBSD__$}) { $platforms{$&} = $op; } - if ($def =~ - m{^OPENSSL_(EXPORT_VAR_AS_FUNCTION)$}) { $platforms{$1} = $op; } if ($def =~ m{^OPENSSL_SYS_}) { $platforms{$'} = $op; } } diff --git a/util/perl/OpenSSL/ParseC.pm b/util/perl/OpenSSL/ParseC.pm index 59b08e8d..286fa7e0 100644 --- a/util/perl/OpenSSL/ParseC.pm +++ b/util/perl/OpenSSL/ParseC.pm @@ -255,19 +255,6 @@ my @opensslchandlers = ( # to this parser. All of these do replacements, anything else is # an error. - ##### - # Global variable stuff - { regexp => qr/OPENSSL_DECLARE_GLOBAL<<<\((.*),\s*(.*)\)>>>;/, - massager => sub { return (<<"EOF"); -#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION -OPENSSL_EXPORT $1 _shadow_$2; -#else -$1 *_shadow_$2(void); -#endif -EOF - }, - }, - ##### # Deprecated stuff, by OpenSSL release. @@ -413,11 +400,7 @@ EOF { regexp => qr/DECLARE_ASN1_ITEM<<<\((.*)\)>>>/, massager => sub { return (<<"EOF"); -#ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION -OPENSSL_EXTERN const ASN1_ITEM *$1_it; -#else const ASN1_ITEM *$1_it(void); -#endif EOF }, }, diff --git a/util/perl/OpenSSL/Test.pm b/util/perl/OpenSSL/Test.pm index 5d6e9d9b..cf7502b0 100644 --- a/util/perl/OpenSSL/Test.pm +++ b/util/perl/OpenSSL/Test.pm @@ -66,6 +66,7 @@ use File::Spec::Functions qw/file_name_is_absolute curdir canonpath splitdir rel2abs/; use File::Path 2.00 qw/rmtree mkpath/; use File::Basename; +use Cwd qw/abs_path/; my $level = 0; @@ -165,13 +166,13 @@ C takes some additional options OPTS that affect the subdirectory: =item B 0|1> -When set to 1 (or any value that perl preceives as true), the subdirectory +When set to 1 (or any value that perl perceives as true), the subdirectory will be created if it doesn't already exist. This happens before BLOCK is executed. =item B 0|1> -When set to 1 (or any value that perl preceives as true), the subdirectory +When set to 1 (or any value that perl perceives as true), the subdirectory will be cleaned out and removed. This happens both before and after BLOCK is executed. @@ -932,8 +933,8 @@ i.e. Some tests may only work in non FIPS mode. sub __env { (my $recipe_datadir = basename($0)) =~ s/\.t$/_data/i; - $directories{SRCTOP} = $ENV{SRCTOP} || $ENV{TOP}; - $directories{BLDTOP} = $ENV{BLDTOP} || $ENV{TOP}; + $directories{SRCTOP} = abs_path($ENV{SRCTOP} || $ENV{TOP}); + $directories{BLDTOP} = abs_path($ENV{BLDTOP} || $ENV{TOP}); $directories{BLDAPPS} = $ENV{BIN_D} || __bldtop_dir("apps"); $directories{SRCAPPS} = __srctop_dir("apps"); $directories{BLDFUZZ} = __bldtop_dir("fuzz"); diff --git a/util/private.num b/util/private.num index cf08a83e..fb5d0b26 100644 --- a/util/private.num +++ b/util/private.num @@ -328,21 +328,19 @@ OpenSSL_add_all_algorithms define deprecated 1.1.0 OpenSSL_add_all_ciphers define deprecated 1.1.0 OpenSSL_add_all_digests define deprecated 1.1.0 OpenSSL_add_ssl_algorithms define +OSSL_PARAM_TYPE define +OSSL_PARAM_octet_ptr define +OSSL_PARAM_octet_string define OSSL_PARAM_utf8_ptr define -OSSL_PARAM_SIZED_BN define +OSSL_PARAM_BN define OSSL_PARAM_TYPE generic OSSL_PARAM_construct_TYPE generic OSSL_PARAM_octet_string define -OSSL_PARAM_SIZED_octet_ptr define OSSL_PARAM_utf8_string define OSSL_PARAM_octet_ptr define -OSSL_PARAM_SIZED_utf8_ptr define -OSSL_PARAM_SIZED_utf8_string define -OSSL_PARAM_SIZED_TYPE generic OSSL_PARAM_get_TYPE generic OSSL_PARAM_END define OSSL_PARAM_set_TYPE generic -OSSL_PARAM_SIZED_octet_string define PEM_FLAG_EAY_COMPATIBLE define PEM_FLAG_ONLY_B64 define PEM_FLAG_SECURE define @@ -421,6 +419,7 @@ SSL_CTX_set_tlsext_status_type define SSL_CTX_set_tlsext_ticket_key_cb define SSL_CTX_set_tmp_dh define SSL_CTX_set_tmp_ecdh define +SSL_DEFAULT_CIPHER_LIST define deprecated 3.0.0 SSL_add0_chain_cert define SSL_add1_chain_cert define SSL_build_cert_chain define @@ -499,6 +498,7 @@ SSL_want_x509_lookup define SSLv23_client_method define SSLv23_method define SSLv23_server_method define +TLS_DEFAULT_CIPHERSUITES define deprecated 3.0.0 X509_STORE_set_lookup_crls_cb define X509_STORE_set_verify_func define EVP_PKEY_CTX_set1_id define