From c03e0c45f8fa7e0b5860806eee8e31821156cc33 Mon Sep 17 00:00:00 2001 From: Hakase Date: Sat, 16 Mar 2019 01:19:24 +0900 Subject: [PATCH] Fix crash and latest update. --- CHANGES | 11 +- Configurations/descrip.mms.tmpl | 5 +- Configurations/unix-Makefile.tmpl | 4 +- Configurations/windows-makefile.tmpl | 26 +- Configure | 2 + INSTALL | 4 + apps/apps.c | 14 +- apps/build.info | 8 +- apps/mac.c | 200 ++ apps/openssl.c | 69 +- apps/pkeyutl.c | 133 +- apps/verify.c | 45 +- crypto/asn1/a_verify.c | 3 +- crypto/blake2/blake2b.c | 8 +- crypto/bn/bn_prime.c | 271 ++- crypto/bn/bn_rsa_fips186_4.c | 346 ++++ crypto/bn/build.info | 3 +- crypto/build.info | 8 +- crypto/chacha/asm/chacha-s390x.pl | 1004 ++++++--- crypto/cms/cms_cd.c | 2 +- crypto/core_fetch.c | 97 + crypto/cpt_err.c | 12 +- crypto/crmf/build.info | 2 + crypto/crmf/crmf_asn.c | 240 +++ crypto/crmf/crmf_err.c | 104 + crypto/crmf/crmf_int.h | 394 ++++ crypto/crmf/crmf_lib.c | 753 +++++++ crypto/crmf/crmf_pbm.c | 231 +++ crypto/ec/curve448/curve448.c | 4 +- crypto/ec/curve448/curve448_tables.c | 1838 +++++++++++++---- crypto/ec/curve448/f_generic.c | 6 +- crypto/ec/curve448/scalar.c | 18 +- crypto/ec/ecp_nistp521.c | 11 +- crypto/err/err.c | 1 + crypto/err/err_all.c | 4 + crypto/err/openssl.ec | 1 + crypto/err/openssl.txt | 60 + crypto/include/internal/bn_int.h | 27 + crypto/include/internal/x509_int.h | 5 +- crypto/objects/obj_dat.h | 19 +- crypto/objects/obj_mac.num | 3 +- crypto/objects/obj_xref.h | 2 + crypto/objects/obj_xref.txt | 2 + crypto/objects/objects.txt | 2 + crypto/params.c | 725 +++++++ crypto/provider.c | 70 + crypto/provider_core.c | 451 ++++ crypto/rand/rand_vms.c | 4 + crypto/rsa/build.info | 3 +- crypto/rsa/rsa_chk.c | 14 + crypto/rsa/rsa_err.c | 21 +- crypto/rsa/rsa_gen.c | 9 +- crypto/rsa/rsa_lib.c | 2 +- crypto/rsa/rsa_locl.h | 38 + crypto/rsa/rsa_oaep.c | 26 +- crypto/rsa/rsa_pk1.c | 24 +- crypto/rsa/rsa_pmeth.c | 11 +- crypto/rsa/rsa_sp800_56b_check.c | 386 ++++ crypto/rsa/rsa_sp800_56b_gen.c | 362 ++++ crypto/rsa/rsa_ssl.c | 35 +- crypto/sha/asm/keccak1600-ppc64.pl | 40 +- crypto/sha/keccak1600.c | 48 +- crypto/sm2/sm2_pmeth.c | 4 + crypto/trace.c | 102 +- crypto/x509/x509_err.c | 4 +- crypto/x509/x_all.c | 110 + crypto/x509/x_x509.c | 12 + demos/pkcs12/pkread.c | 46 +- doc/internal/man3/ossl_method_construct.pod | 133 ++ doc/internal/man3/ossl_provider_new.pod | 215 ++ doc/man1/list.pod | 5 + doc/man1/mac.pod | 163 ++ doc/man1/openssl.pod | 18 +- doc/man1/pkeyutl.pod | 33 +- doc/man1/s_client.pod | 2 +- doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod | 66 + .../OSSL_CRMF_MSG_set1_regCtrl_regToken.pod | 106 + .../OSSL_CRMF_MSG_set1_regInfo_certReq.pod | 49 + doc/man3/OSSL_CRMF_MSG_set_validity.pod | 105 + doc/man3/OSSL_CRMF_pbmp_new.pod | 78 + doc/man3/OSSL_PARAM.pod | 88 +- doc/man3/OSSL_PARAM_TYPE.pod | 312 +++ doc/man3/OSSL_PROVIDER.pod | 112 + doc/man3/OSSL_trace_enabled.pod | 64 +- doc/man3/OSSL_trace_set_channel.pod | 37 +- doc/man3/RSA_padding_add_PKCS1_type_1.pod | 60 +- doc/man3/RSA_public_encrypt.pod | 38 +- doc/man3/SSL_CTX_set_read_ahead.pod | 2 +- doc/man3/X509_dup.pod | 14 + e_os.h | 4 +- fuzz/oids.txt | 1 + include/internal/core.h | 52 + include/internal/dsoerr.h | 6 +- include/internal/propertyerr.h | 4 + include/internal/provider.h | 70 + include/internal/refcount.h | 51 +- include/internal/symhacks.h | 26 + include/openssl/asn1err.h | 6 +- include/openssl/asyncerr.h | 6 +- include/openssl/bioerr.h | 6 +- include/openssl/bnerr.h | 6 +- include/openssl/buffererr.h | 6 +- include/openssl/cmserr.h | 6 +- include/openssl/comperr.h | 6 +- include/openssl/conferr.h | 6 +- include/openssl/core.h | 57 +- include/openssl/core_numbers.h | 80 + include/openssl/crmf.h | 137 ++ include/openssl/crmferr.h | 69 + include/openssl/cryptoerr.h | 14 +- include/openssl/cterr.h | 6 +- include/openssl/dherr.h | 6 +- include/openssl/dsaerr.h | 6 +- include/openssl/ecerr.h | 4 + include/openssl/engineerr.h | 6 +- include/openssl/err.h | 2 + include/openssl/esserr.h | 6 +- include/openssl/evperr.h | 4 + include/openssl/kdferr.h | 4 + include/openssl/obj_mac.h | 7 +- include/openssl/objectserr.h | 6 +- include/openssl/ocsperr.h | 6 +- include/openssl/ossl_typ.h | 2 + include/openssl/params.h | 186 ++ include/openssl/pemerr.h | 6 +- include/openssl/pkcs12err.h | 6 +- include/openssl/pkcs7err.h | 6 +- include/openssl/provider.h | 34 + include/openssl/randerr.h | 6 +- include/openssl/rsaerr.h | 18 +- include/openssl/sslerr.h | 4 + include/openssl/storeerr.h | 6 +- include/openssl/trace.h | 2 +- include/openssl/tserr.h | 4 + include/openssl/uierr.h | 6 +- include/openssl/x509.h | 5 + include/openssl/x509err.h | 8 +- include/openssl/x509v3err.h | 6 +- ssl/ssl_ciph.c | 4 +- ssl/ssl_lib.c | 13 +- test/asn1_encode_test.c | 4 +- test/bioprinttest.c | 8 +- test/bn_internal_test.c | 103 + test/build.info | 48 +- test/ct_test.c | 4 +- test/ectest.c | 70 + test/p_test.c | 110 + test/params_api_test.c | 627 ++++++ test/params_test.c | 549 +++++ test/provider_internal_test.c | 84 + test/provider_test.c | 75 + test/recipes/02-test_internal_provider.t | 18 + test/recipes/03-test_internal_bn.t | 19 + test/recipes/03-test_internal_rsa_sp800_56b.t | 19 + test/recipes/03-test_params_api.t | 12 + test/recipes/04-test_params.t | 15 + test/recipes/04-test_provider.t | 18 + test/recipes/20-test_mac.t | 194 ++ test/recipes/20-test_pkeyutl.t | 68 +- test/rsa_sp800_56b_test.c | 634 ++++++ test/rsa_test.c | 35 +- test/testutil.h | 9 + test/testutil/tests.c | 1 + util/libcrypto.num | 137 +- util/mkerr.pl | 8 +- util/perl/OpenSSL/ParseC.pm | 9 + util/private.num | 22 + util/providers.num | 1 + 168 files changed, 12859 insertions(+), 1295 deletions(-) create mode 100644 apps/mac.c create mode 100644 crypto/bn/bn_rsa_fips186_4.c create mode 100644 crypto/core_fetch.c create mode 100644 crypto/crmf/build.info create mode 100644 crypto/crmf/crmf_asn.c create mode 100644 crypto/crmf/crmf_err.c create mode 100644 crypto/crmf/crmf_int.h create mode 100644 crypto/crmf/crmf_lib.c create mode 100644 crypto/crmf/crmf_pbm.c create mode 100644 crypto/params.c create mode 100644 crypto/provider.c create mode 100644 crypto/provider_core.c create mode 100644 crypto/rsa/rsa_sp800_56b_check.c create mode 100644 crypto/rsa/rsa_sp800_56b_gen.c create mode 100644 doc/internal/man3/ossl_method_construct.pod create mode 100644 doc/internal/man3/ossl_provider_new.pod create mode 100644 doc/man1/mac.pod create mode 100644 doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod create mode 100644 doc/man3/OSSL_CRMF_MSG_set1_regCtrl_regToken.pod create mode 100644 doc/man3/OSSL_CRMF_MSG_set1_regInfo_certReq.pod create mode 100644 doc/man3/OSSL_CRMF_MSG_set_validity.pod create mode 100644 doc/man3/OSSL_CRMF_pbmp_new.pod create mode 100644 doc/man3/OSSL_PARAM_TYPE.pod create mode 100644 doc/man3/OSSL_PROVIDER.pod create mode 100644 include/internal/core.h create mode 100644 include/internal/provider.h create mode 100644 include/internal/symhacks.h create mode 100644 include/openssl/core_numbers.h create mode 100644 include/openssl/crmf.h create mode 100644 include/openssl/crmferr.h create mode 100644 include/openssl/params.h create mode 100644 include/openssl/provider.h create mode 100644 test/bn_internal_test.c create mode 100644 test/p_test.c create mode 100644 test/params_api_test.c create mode 100644 test/params_test.c create mode 100644 test/provider_internal_test.c create mode 100644 test/provider_test.c create mode 100644 test/recipes/02-test_internal_provider.t create mode 100644 test/recipes/03-test_internal_bn.t create mode 100644 test/recipes/03-test_internal_rsa_sp800_56b.t create mode 100644 test/recipes/03-test_params_api.t create mode 100644 test/recipes/04-test_params.t create mode 100644 test/recipes/04-test_provider.t create mode 100644 test/recipes/20-test_mac.t create mode 100644 test/rsa_sp800_56b_test.c create mode 100644 util/providers.num diff --git a/CHANGES b/CHANGES index d977c766..0f7b77a4 100644 --- a/CHANGES +++ b/CHANGES @@ -9,9 +9,14 @@ Changes between 1.1.1 and 3.0.0 [xx XXX xxxx] - *) Added support for enabling instrumentation through trace output. - This is left to application control, by allowing it to register BIOs as - channels for a number of tracing and debugging categories. + *) Added a new generic trace API which provides support for enabling + instrumentation through trace output. This feature is mainly intended + as an aid for developers and is disabled by default. To utilize it, + OpenSSL needs to be configured with the `enable-trace` option. + + If the tracing API is enabled, the application can activate trace output + by registering BIOs as trace channels for a number of tracing and debugging + categories. The 'openssl' application has been expanded to enable any of the types available via environment variables defined by the user, and serves as diff --git a/Configurations/descrip.mms.tmpl b/Configurations/descrip.mms.tmpl index 8efdeb7b..2f74756d 100644 --- a/Configurations/descrip.mms.tmpl +++ b/Configurations/descrip.mms.tmpl @@ -167,6 +167,8 @@ OPENSSLDIR={- catdir($config{openssldir}) or OPENSSLDIR_C={- platform->osslprefix() -}DATAROOT:[000000] # Where installed ENGINE modules reside, for C ENGINESDIR_C={- platform->osslprefix() -}ENGINES{- $sover_dirname.$target{pointer_size} -}: +# Where modules reside, for C +MODULESDIR_C={- platform->osslprefix() -}MODULES{- $sover_dirname.$target{pointer_size} -}: ##### User defined commands and flags ################################ @@ -226,7 +228,8 @@ LIB_DEFINES={- our $lib_defines = @{$config{shared_defines}})); join('', $lib_defines, (map { ",$_" } 'OPENSSLDIR="""$(OPENSSLDIR_C)"""', - 'ENGINESDIR="""$(ENGINESDIR_C)"""'), + 'ENGINESDIR="""$(ENGINESDIR_C)"""', + 'MODULESDIR="""$(MODULESDIR_C)"""'), '$(CNF_DEFINES)', '$(DEFINES)') -} LIB_INCLUDES={- our $lib_includes = join(',', @{$target{lib_includes}}, diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index dfae9afd..2561c473 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -142,6 +142,7 @@ LIBDIR={- our $libdir = $config{libdir}; libdir={- file_name_is_absolute($libdir) ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -} ENGINESDIR=$(libdir)/engines-{- $sover_dirname -} +MODULESDIR=$(libdir)/ossl-modules # Convenience variable for those who want to set the rpath in shared # libraries and applications @@ -238,7 +239,8 @@ LIB_CPPFLAGS={- our $lib_cppflags = join(' ', $lib_cppflags, (map { '-D'.$_ } 'OPENSSLDIR="\"$(OPENSSLDIR)\""', - 'ENGINESDIR="\"$(ENGINESDIR)\""'), + 'ENGINESDIR="\"$(ENGINESDIR)\""', + 'MODULESDIR="\"$(MODULESDIR)\""'), '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} LIB_CFLAGS={- join(' ', $target{lib_cflags} || (), $target{shared_cflag} || (), diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl index 6d38cfe1..8999d6f1 100644 --- a/Configurations/windows-makefile.tmpl +++ b/Configurations/windows-makefile.tmpl @@ -148,20 +148,33 @@ OPENSSLDIR_dev={- # OPENSSLDIR_dir={- canonpath($openssldir_dir) -} LIBDIR={- our $libdir = $config{libdir} || "lib"; file_name_is_absolute($libdir) ? "" : $libdir -} -ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath); - our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname"); - our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) = - splitpath($enginesdir, 1); - $enginesdir_dev -} +MODULESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath catpath); + our $modulesprefix = catdir($prefix,$libdir); + our ($modulesprefix_dev, $modulesprefix_dir, + $modulesprefix_file) = + splitpath($modulesprefix, 1); + our $modulesdir_dev = $modulesprefix_dev; + our $modulesdir_dir = + catdir($modulesprefix_dir, "ossl-modules"); + our $modulesdir = catpath($modulesdir_dev, $modulesdir_dir); + our $enginesdir_dev = $modulesprefix_dev; + our $enginesdir_dir = + catdir($modulesprefix_dir, "engines-$sover_dirname"); + our $enginesdir = catpath($enginesdir_dev, $enginesdir_dir); + $modulesdir_dev -} +MODULESDIR_dir={- canonpath($modulesdir_dir) -} +ENGINESDIR_dev={- $enginesdir_dev -} ENGINESDIR_dir={- canonpath($enginesdir_dir) -} !IF "$(DESTDIR)" != "" INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir) OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir) ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir) +MODULESDIR=$(DESTDIR)$(MODULESDIR_dir) !ELSE INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir) OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir) ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir) +MODULESDIR=$(MODULESDIR_dev)$(MODULESDIR_dir) !ENDIF # $(libdir) is chosen to be compatible with the GNU coding standards @@ -255,7 +268,8 @@ LIB_CPPFLAGS={- our $lib_cppflags = join(' ', $lib_cppflags, (map { '-D'.quotify1($_) } "OPENSSLDIR=\"$openssldir\"", - "ENGINESDIR=\"$enginesdir\""), + "ENGINESDIR=\"$enginesdir\"", + "MODULESDIR=\"$modulesdir\""), '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} LIB_CFLAGS={- join(' ', $target{lib_cflags} || (), $target{shared_cflag} || (), diff --git a/Configure b/Configure index b2410a2b..6b533f46 100755 --- a/Configure +++ b/Configure @@ -349,6 +349,7 @@ my @disablables = ( "cmac", "cms", "comp", + "crmf", "crypto-mdebug", "crypto-mdebug-backtrace", "ct", @@ -463,6 +464,7 @@ our %disabled = ( # "what" => "comment" "ssl-trace" => "default", "ssl3" => "default", "ssl3-method" => "default", + "trace" => "default", "ubsan" => "default", "unit-test" => "default", "weak-ssl-ciphers" => "default", diff --git a/INSTALL b/INSTALL index d8c5dc59..cffa241a 100644 --- a/INSTALL +++ b/INSTALL @@ -523,6 +523,10 @@ require additional system-dependent options! See "Note on multi-threading" below. + enable-trace + Build with support for the integrated tracing api. See manual pages + OSSL_trace_set_channel(3) and OSSL_trace_enabled(3) for details. + no-ts Don't build Time Stamping Authority support. diff --git a/apps/apps.c b/apps/apps.c index d095dee2..06b54348 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -48,6 +48,8 @@ static int WIN32_rename(const char *from, const char *to); # define rename(from,to) WIN32_rename((from),(to)) #endif +#define PASS_SOURCE_SIZE_MAX 4 + typedef struct { const char *name; unsigned long flag; @@ -205,6 +207,7 @@ static char *app_get_pass(const char *arg, int keepbio) char *tmp, tpass[APP_PASS_LEN]; int i; + /* PASS_SOURCE_SIZE_MAX = max number of chars before ':' in below strings */ if (strncmp(arg, "pass:", 5) == 0) return OPENSSL_strdup(arg + 5); if (strncmp(arg, "env:", 4) == 0) { @@ -253,7 +256,16 @@ static char *app_get_pass(const char *arg, int keepbio) return NULL; } } else { - BIO_printf(bio_err, "Invalid password argument \"%s\"\n", arg); + /* argument syntax error; do not reveal too much about arg */ + tmp = strchr(arg, ':'); + if (tmp == NULL || tmp - arg > PASS_SOURCE_SIZE_MAX) + BIO_printf(bio_err, + "Invalid password argument, missing ':' within the first %d chars\n", + PASS_SOURCE_SIZE_MAX + 1); + else + BIO_printf(bio_err, + "Invalid password argument, starting with \"%.*s\"\n", + (int)(tmp - arg + 1), arg); return NULL; } } diff --git a/apps/build.info b/apps/build.info index 9b77c469..ad14038a 100644 --- a/apps/build.info +++ b/apps/build.info @@ -2,10 +2,10 @@ 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 - genpkey.c genrsa.c nseq.c ocsp.c passwd.c pkcs12.c pkcs7.c pkcs8.c - pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c rsa.c 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); + genpkey.c genrsa.c mac.c nseq.c ocsp.c passwd.c pkcs12.c pkcs7.c + pkcs8.c pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c rsa.c + 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); 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), diff --git a/apps/mac.c b/apps/mac.c new file mode 100644 index 00000000..a02779b2 --- /dev/null +++ b/apps/mac.c @@ -0,0 +1,200 @@ +/* + * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (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 "apps.h" +#include "progs.h" +#include +#include +#include + +#undef BUFSIZE +#define BUFSIZE 1024*8 + +typedef enum OPTION_choice { + OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, + OPT_MACOPT, OPT_BIN, OPT_IN, OPT_OUT +} OPTION_CHOICE; + +const OPTIONS mac_options[] = { + {OPT_HELP_STR, 1, '-', "Usage: %s [options] mac_name\n"}, + {OPT_HELP_STR, 1, '-', "mac_name\t\t MAC algorithm (See list " + "-mac-algorithms)"}, + {"help", OPT_HELP, '-', "Display this summary"}, + {"macopt", OPT_MACOPT, 's', "MAC algorithm control parameters in n:v form. " + "See 'Supported Controls' in the EVP_MAC_ docs"}, + {"in", OPT_IN, '<', "Input file to MAC (default is stdin)"}, + {"out", OPT_OUT, '>', "Output to filename rather than stdout"}, + {"binary", OPT_BIN, '-', "Output in binary format (Default is hexadecimal " + "output)"}, + {NULL} +}; + +static int mac_ctrl_string(EVP_MAC_CTX *ctx, const char *value) +{ + int rv; + char *stmp, *vtmp = NULL; + + stmp = OPENSSL_strdup(value); + if (stmp == NULL) + return -1; + vtmp = strchr(stmp, ':'); + if (vtmp != NULL) { + *vtmp = 0; + vtmp++; + } + rv = EVP_MAC_ctrl_str(ctx, stmp, vtmp); + OPENSSL_free(stmp); + return rv; +} + +int mac_main(int argc, char **argv) +{ + int ret = 1; + char *prog; + const EVP_MAC *mac = NULL; + OPTION_CHOICE o; + EVP_MAC_CTX *ctx = NULL; + STACK_OF(OPENSSL_STRING) *opts = NULL; + unsigned char *buf = NULL; + size_t len; + int i; + BIO *in = NULL, *out = NULL; + const char *outfile = NULL; + const char *infile = NULL; + int out_bin = 0; + int inform = FORMAT_BINARY; + + prog = opt_init(argc, argv, mac_options); + buf = app_malloc(BUFSIZE, "I/O buffer"); + while ((o = opt_next()) != OPT_EOF) { + switch (o) { + case OPT_EOF: + case OPT_ERR: +opthelp: + BIO_printf(bio_err, "%s: Use -help for summary.\n", prog); + goto err; + case OPT_HELP: + opt_help(mac_options); + ret = 0; + goto err; + case OPT_BIN: + out_bin = 1; + break; + case OPT_IN: + infile = opt_arg(); + break; + case OPT_OUT: + outfile = opt_arg(); + break; + case OPT_MACOPT: + if (opts == NULL) + opts = sk_OPENSSL_STRING_new_null(); + if (opts == NULL || !sk_OPENSSL_STRING_push(opts, opt_arg())) + goto opthelp; + break; + } + } + argc = opt_num_rest(); + argv = opt_rest(); + + if (argc != 1) { + BIO_printf(bio_err, "Invalid number of extra arguments\n"); + goto opthelp; + } + + mac = EVP_get_macbyname(argv[0]); + if (mac == NULL) { + BIO_printf(bio_err, "Invalid MAC name %s\n", argv[0]); + goto opthelp; + } + + ctx = EVP_MAC_CTX_new(mac); + if (ctx == NULL) + goto err; + + if (opts != NULL) { + for (i = 0; i < sk_OPENSSL_STRING_num(opts); i++) { + char *opt = sk_OPENSSL_STRING_value(opts, i); + if (mac_ctrl_string(ctx, opt) <= 0) { + BIO_printf(bio_err, "MAC parameter error '%s'\n", opt); + ERR_print_errors(bio_err); + goto err; + } + } + } + + /* Use text mode for stdin */ + if (infile == NULL || strcmp(infile, "-") == 0) + inform = FORMAT_TEXT; + in = bio_open_default(infile, 'r', inform); + if (in == NULL) + goto err; + + out = bio_open_default(outfile, 'w', out_bin ? FORMAT_BINARY : FORMAT_TEXT); + if (out == NULL) + goto err; + + if (!EVP_MAC_init(ctx)) { + BIO_printf(bio_err, "EVP_MAC_Init failed\n"); + goto err; + } + + + for (;;) { + i = BIO_read(in, (char *)buf, BUFSIZE); + if (i < 0) { + BIO_printf(bio_err, "Read Error in '%s'\n", infile); + goto err; + } + if (i == 0) + break; + if (!EVP_MAC_update(ctx, buf, i)) { + BIO_printf(bio_err, "EVP_MAC_update failed\n"); + goto err; + } + } + + if (!EVP_MAC_final(ctx, NULL, &len)) { + BIO_printf(bio_err, "EVP_MAC_final failed\n"); + goto err; + } + if (len > BUFSIZE) { + BIO_printf(bio_err, "output len is too large\n"); + goto err; + } + + if (!EVP_MAC_final(ctx, buf, &len)) { + BIO_printf(bio_err, "EVP_MAC_final failed\n"); + goto err; + } + + if (out_bin) { + BIO_write(out, buf, len); + } else { + if (outfile == NULL) + BIO_printf(out,"\n"); + for (i = 0; i < (int)len; ++i) + BIO_printf(out, "%02X", buf[i]); + if (outfile == NULL) + BIO_printf(out,"\n"); + } + + ret = 0; +err: + if (ret != 0) + ERR_print_errors(bio_err); + OPENSSL_clear_free(buf, BUFSIZE); + sk_OPENSSL_STRING_free(opts); + BIO_free(in); + BIO_free(out); + EVP_MAC_CTX_free(ctx); + return ret; +} diff --git a/apps/openssl.c b/apps/openssl.c index 854f943f..119d3e8f 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -54,6 +54,7 @@ static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]); static void list_pkey(void); static void list_pkey_meth(void); static void list_type(FUNC_TYPE ft, int one); +static void list_engines(void); static void list_disabled(void); char *default_config_file = NULL; @@ -125,30 +126,19 @@ typedef struct tracedata_st { static size_t internal_trace_cb(const char *buf, size_t cnt, int category, int cmd, void *vdata) { - int ret; + int ret = 0; tracedata *trace_data = vdata; - int set_prefix = 0; + union { + CRYPTO_THREAD_ID tid; + unsigned long ltid; + } tid; + char buffer[256]; switch (cmd) { case OSSL_TRACE_CTRL_BEGIN: + if (!ossl_assert(!trace_data->ingroup)) + return 0; trace_data->ingroup = 1; - set_prefix = 1; - break; - case OSSL_TRACE_CTRL_DURING: - if (!trace_data->ingroup) - set_prefix = 1; - break; - case OSSL_TRACE_CTRL_END: - trace_data->ingroup = 0; - break; - } - - if (set_prefix) { - union { - CRYPTO_THREAD_ID tid; - unsigned long ltid; - } tid; - char buffer[256]; tid.ltid = 0; tid.tid = CRYPTO_THREAD_get_current_id(); @@ -157,8 +147,22 @@ static size_t internal_trace_cb(const char *buf, size_t cnt, OSSL_trace_get_category_name(category)); BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX, strlen(buffer), buffer); + break; + case OSSL_TRACE_CTRL_WRITE: + if (!ossl_assert(trace_data->ingroup)) + return 0; + + ret = BIO_write(trace_data->bio, buf, cnt); + break; + case OSSL_TRACE_CTRL_END: + if (!ossl_assert(trace_data->ingroup)) + return 0; + trace_data->ingroup = 0; + + BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX, 0, NULL); + + break; } - ret = BIO_write(trace_data->bio, buf, cnt); return ret < 0 ? 0 : ret; } @@ -523,8 +527,8 @@ typedef enum HELPLIST_CHOICE { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE, OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS, OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS, - OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_DISABLED, OPT_MISSING_HELP, - OPT_OBJECTS + OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_ENGINES, OPT_DISABLED, + OPT_MISSING_HELP, OPT_OBJECTS } HELPLIST_CHOICE; const OPTIONS list_options[] = { @@ -544,6 +548,8 @@ const OPTIONS list_options[] = { "List of public key algorithms"}, {"public-key-methods", OPT_PK_METHOD, '-', "List of public key methods"}, + {"engines", OPT_ENGINES, '-', + "List of loaded engines"}, {"disabled", OPT_DISABLED, '-', "List of disabled features"}, {"missing-help", OPT_MISSING_HELP, '-', @@ -599,6 +605,9 @@ opthelp: case OPT_PK_METHOD: list_pkey_meth(); break; + case OPT_ENGINES: + list_engines(); + break; case OPT_DISABLED: list_disabled(); break; @@ -837,6 +846,22 @@ static int SortFnByName(const void *_f1, const void *_f2) return strcmp(f1->name, f2->name); } +static void list_engines(void) +{ +#ifndef OPENSSL_NO_ENGINE + ENGINE *e; + + BIO_puts(bio_out, "Engines:\n"); + e = ENGINE_get_first(); + while (e) { + BIO_printf(bio_out, "%s\n", ENGINE_get_id(e)); + e = ENGINE_get_next(e); + } +#else + BIO_puts(bio_out, "Engine support is disabled.\n"); +#endif +} + static void list_disabled(void) { BIO_puts(bio_out, "Disabled algorithms:\n"); diff --git a/apps/pkeyutl.c b/apps/pkeyutl.c index c084525c..0c27589b 100644 --- a/apps/pkeyutl.c +++ b/apps/pkeyutl.c @@ -13,6 +13,9 @@ #include #include #include +#ifndef OPENSSL_NO_POSIX_IO +# include +#endif #define KEY_NONE 0 #define KEY_PRIVKEY 1 @@ -22,7 +25,7 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize, const char *keyfile, int keyform, int key_type, char *passinarg, int pkey_op, ENGINE *e, - const int impl, EVP_PKEY **ppkey); + const int impl, int rawin, EVP_PKEY **ppkey); static int setup_peer(EVP_PKEY_CTX *ctx, int peerform, const char *file, ENGINE *e); @@ -33,7 +36,7 @@ static int do_keyop(EVP_PKEY_CTX *ctx, int pkey_op, static int do_raw_keyop(int pkey_op, EVP_PKEY_CTX *ctx, const EVP_MD *md, EVP_PKEY *pkey, BIO *in, - unsigned char *sig, int siglen, + int filesize, unsigned char *sig, int siglen, unsigned char **out, size_t *poutlen); typedef enum OPTION_choice { @@ -109,6 +112,7 @@ int pkeyutl_main(int argc, char **argv) STACK_OF(OPENSSL_STRING) *pkeyopts_passin = NULL; int rawin = 0; const EVP_MD *md = NULL; + int filesize = -1; prog = opt_init(argc, argv, pkeyutl_options); while ((o = opt_next()) != OPT_EOF) { @@ -264,7 +268,7 @@ int pkeyutl_main(int argc, char **argv) goto opthelp; } ctx = init_ctx(kdfalg, &keysize, inkey, keyform, key_type, - passinarg, pkey_op, e, engine_impl, &pkey); + passinarg, pkey_op, e, engine_impl, rawin, &pkey); if (ctx == NULL) { BIO_printf(bio_err, "%s: Error initializing context\n", prog); ERR_print_errors(bio_err); @@ -344,6 +348,15 @@ int pkeyutl_main(int argc, char **argv) if (pkey_op != EVP_PKEY_OP_DERIVE) { in = bio_open_default(infile, 'r', FORMAT_BINARY); +#ifndef OPENSSL_NO_POSIX_IO + if (infile != NULL) + { + struct stat st; + + if (stat(infile, &st) == 0 && st.st_size <= INT_MAX) + filesize = (int)st.st_size; + } +#endif if (in == NULL) goto end; } @@ -399,7 +412,7 @@ int pkeyutl_main(int argc, char **argv) if (pkey_op == EVP_PKEY_OP_VERIFY) { if (rawin) { - rv = do_raw_keyop(pkey_op, ctx, md, pkey, in, sig, siglen, + rv = do_raw_keyop(pkey_op, ctx, md, pkey, in, filesize, sig, siglen, NULL, 0); } else { rv = EVP_PKEY_verify(ctx, sig, (size_t)siglen, @@ -419,7 +432,7 @@ int pkeyutl_main(int argc, char **argv) } else { if (rawin) { /* rawin allocates the buffer in do_raw_keyop() */ - rv = do_raw_keyop(pkey_op, ctx, md, pkey, in, NULL, 0, + rv = do_raw_keyop(pkey_op, ctx, md, pkey, in, filesize, NULL, 0, &buf_out, (size_t *)&buf_outlen); } else { rv = do_keyop(ctx, pkey_op, NULL, (size_t *)&buf_outlen, @@ -468,7 +481,8 @@ int pkeyutl_main(int argc, char **argv) static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize, const char *keyfile, int keyform, int key_type, char *passinarg, int pkey_op, ENGINE *e, - const int engine_impl, EVP_PKEY **ppkey) + const int engine_impl, int rawin, + EVP_PKEY **ppkey) { EVP_PKEY *pkey = NULL; EVP_PKEY_CTX *ctx = NULL; @@ -554,30 +568,39 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize, if (ctx == NULL) goto end; - switch (pkey_op) { - case EVP_PKEY_OP_SIGN: - rv = EVP_PKEY_sign_init(ctx); - break; + /* + * If rawin then we don't need to actually initialise the EVP_PKEY_CTX + * itself. That will get initialised during EVP_DigestSignInit or + * EVP_DigestVerifyInit. + */ + if (rawin) { + rv = 1; + } else { + switch (pkey_op) { + case EVP_PKEY_OP_SIGN: + rv = EVP_PKEY_sign_init(ctx); + break; - case EVP_PKEY_OP_VERIFY: - rv = EVP_PKEY_verify_init(ctx); - break; + case EVP_PKEY_OP_VERIFY: + rv = EVP_PKEY_verify_init(ctx); + break; - case EVP_PKEY_OP_VERIFYRECOVER: - rv = EVP_PKEY_verify_recover_init(ctx); - break; + case EVP_PKEY_OP_VERIFYRECOVER: + rv = EVP_PKEY_verify_recover_init(ctx); + break; - case EVP_PKEY_OP_ENCRYPT: - rv = EVP_PKEY_encrypt_init(ctx); - break; + case EVP_PKEY_OP_ENCRYPT: + rv = EVP_PKEY_encrypt_init(ctx); + break; - case EVP_PKEY_OP_DECRYPT: - rv = EVP_PKEY_decrypt_init(ctx); - break; + case EVP_PKEY_OP_DECRYPT: + rv = EVP_PKEY_decrypt_init(ctx); + break; - case EVP_PKEY_OP_DERIVE: - rv = EVP_PKEY_derive_init(ctx); - break; + case EVP_PKEY_OP_DERIVE: + rv = EVP_PKEY_derive_init(ctx); + break; + } } if (rv <= 0) { @@ -649,13 +672,14 @@ static int do_keyop(EVP_PKEY_CTX *ctx, int pkey_op, static int do_raw_keyop(int pkey_op, EVP_PKEY_CTX *ctx, const EVP_MD *md, EVP_PKEY *pkey, BIO *in, - unsigned char *sig, int siglen, + int filesize, unsigned char *sig, int siglen, unsigned char **out, size_t *poutlen) { int rv = 0; EVP_MD_CTX *mctx = NULL; unsigned char tbuf[TBUF_MAXSIZE]; - int tbuf_len = 0; + unsigned char *mbuf = NULL; + int buf_len = 0; if ((mctx = EVP_MD_CTX_new()) == NULL) { BIO_printf(bio_err, "Error: out of memory\n"); @@ -663,19 +687,58 @@ static int do_raw_keyop(int pkey_op, EVP_PKEY_CTX *ctx, } EVP_MD_CTX_set_pkey_ctx(mctx, ctx); + /* Some algorithms only support oneshot digests */ + if (EVP_PKEY_id(pkey) == EVP_PKEY_ED25519 + || EVP_PKEY_id(pkey) == EVP_PKEY_ED448) { + if (filesize < 0) { + BIO_printf(bio_err, + "Error: unable to determine file size for oneshot operation\n"); + return rv; + } + mbuf = app_malloc(filesize, "oneshot sign/verify buffer"); + switch(pkey_op) { + case EVP_PKEY_OP_VERIFY: + if (EVP_DigestVerifyInit(mctx, NULL, md, NULL, pkey) != 1) + goto end; + buf_len = BIO_read(in, mbuf, filesize); + if (buf_len != filesize) { + BIO_printf(bio_err, "Error reading raw input data\n"); + goto end; + } + rv = EVP_DigestVerify(mctx, sig, (size_t)siglen, mbuf, buf_len); + break; + case EVP_PKEY_OP_SIGN: + if (EVP_DigestSignInit(mctx, NULL, md, NULL, pkey) != 1) + goto end; + buf_len = BIO_read(in, mbuf, filesize); + if (buf_len != filesize) { + BIO_printf(bio_err, "Error reading raw input data\n"); + goto end; + } + rv = EVP_DigestSign(mctx, NULL, poutlen, mbuf, buf_len); + if (rv == 1 && out != NULL) { + *out = app_malloc(*poutlen, "buffer output"); + rv = EVP_DigestSign(mctx, *out, poutlen, mbuf, buf_len); + } + break; + } + OPENSSL_free(mbuf); + goto end; + } + switch(pkey_op) { case EVP_PKEY_OP_VERIFY: if (EVP_DigestVerifyInit(mctx, NULL, md, NULL, pkey) != 1) goto end; for (;;) { - tbuf_len = BIO_read(in, tbuf, TBUF_MAXSIZE); - if (tbuf_len == 0) + buf_len = BIO_read(in, tbuf, TBUF_MAXSIZE); + if (buf_len == 0) break; - if (tbuf_len < 0) { + if (buf_len < 0) { BIO_printf(bio_err, "Error reading raw input data\n"); goto end; } - rv = EVP_DigestVerifyUpdate(mctx, tbuf, (size_t)tbuf_len); + rv = EVP_DigestVerifyUpdate(mctx, tbuf, (size_t)buf_len); if (rv != 1) { BIO_printf(bio_err, "Error verifying raw input data\n"); goto end; @@ -687,14 +750,14 @@ static int do_raw_keyop(int pkey_op, EVP_PKEY_CTX *ctx, if (EVP_DigestSignInit(mctx, NULL, md, NULL, pkey) != 1) goto end; for (;;) { - tbuf_len = BIO_read(in, tbuf, TBUF_MAXSIZE); - if (tbuf_len == 0) + buf_len = BIO_read(in, tbuf, TBUF_MAXSIZE); + if (buf_len == 0) break; - if (tbuf_len < 0) { + if (buf_len < 0) { BIO_printf(bio_err, "Error reading raw input data\n"); goto end; } - rv = EVP_DigestSignUpdate(mctx, tbuf, (size_t)tbuf_len); + rv = EVP_DigestSignUpdate(mctx, tbuf, (size_t)buf_len); if (rv != 1) { BIO_printf(bio_err, "Error signing raw input data\n"); goto end; diff --git a/apps/verify.c b/apps/verify.c index 2f66912c..fcd10dd9 100644 --- a/apps/verify.c +++ b/apps/verify.c @@ -21,7 +21,8 @@ static int cb(int ok, X509_STORE_CTX *ctx); static int check(X509_STORE *ctx, const char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, - STACK_OF(X509_CRL) *crls, int show_chain); + STACK_OF(X509_CRL) *crls, int show_chain, + unsigned char *sm2id, size_t sm2idlen); static int v_verbose = 0, vflags = 0; typedef enum OPTION_choice { @@ -29,7 +30,7 @@ typedef enum OPTION_choice { OPT_ENGINE, OPT_CAPATH, OPT_CAFILE, OPT_NOCAPATH, OPT_NOCAFILE, OPT_UNTRUSTED, OPT_TRUSTED, OPT_CRLFILE, OPT_CRL_DOWNLOAD, OPT_SHOW_CHAIN, OPT_V_ENUM, OPT_NAMEOPT, - OPT_VERBOSE + OPT_VERBOSE, OPT_SM2ID, OPT_SM2HEXID } OPTION_CHOICE; const OPTIONS verify_options[] = { @@ -56,6 +57,12 @@ const OPTIONS verify_options[] = { OPT_V_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"}, + {"sm2-hex-id", OPT_SM2HEXID, 's', + "Specify a hex ID string to verify an SM2 certificate"}, #endif {NULL} }; @@ -71,6 +78,8 @@ int verify_main(int argc, char **argv) int noCApath = 0, noCAfile = 0; int vpmtouched = 0, crl_download = 0, show_chain = 0, i = 0, ret = 1; OPTION_CHOICE o; + unsigned char *sm2_id = NULL; + size_t sm2_idlen = 0; if ((vpm = X509_VERIFY_PARAM_new()) == NULL) goto end; @@ -158,6 +167,19 @@ int verify_main(int argc, char **argv) case OPT_VERBOSE: v_verbose = 1; break; + case OPT_SM2ID: + /* we assume the input is not a hex string */ + 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 */ + 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(); @@ -183,12 +205,13 @@ int verify_main(int argc, char **argv) ret = 0; if (argc < 1) { - if (check(store, NULL, untrusted, trusted, crls, show_chain) != 1) + if (check(store, NULL, untrusted, trusted, crls, show_chain, + sm2_id, sm2_idlen) != 1) ret = -1; } else { for (i = 0; i < argc; i++) if (check(store, argv[i], untrusted, trusted, crls, - show_chain) != 1) + show_chain, sm2_id, sm2_idlen) != 1) ret = -1; } @@ -204,7 +227,8 @@ int verify_main(int argc, char **argv) static int check(X509_STORE *ctx, const char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, - STACK_OF(X509_CRL) *crls, int show_chain) + STACK_OF(X509_CRL) *crls, int show_chain, + unsigned char *sm2id, size_t sm2idlen) { X509 *x = NULL; int i = 0, ret = 0; @@ -216,6 +240,17 @@ static int check(X509_STORE *ctx, const char *file, if (x == NULL) goto end; + if (sm2id != NULL) { +#ifndef OPENSSL_NO_SM2 + ASN1_OCTET_STRING v; + + v.data = sm2id; + v.length = sm2idlen; + + X509_set_sm2_id(x, &v); +#endif + } + csc = X509_STORE_CTX_new(); if (csc == NULL) { printf("error %s: X.509 store context allocation failed\n", diff --git a/crypto/asn1/a_verify.c b/crypto/asn1/a_verify.c index 1f245831..d26c5236 100644 --- a/crypto/asn1/a_verify.c +++ b/crypto/asn1/a_verify.c @@ -94,7 +94,7 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, int mdnid, pknid; size_t inll = 0; - if (!pkey) { + if (pkey == NULL) { ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_PASSED_NULL_PARAMETER); return -1; } @@ -150,7 +150,6 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a, ret = 0; goto err; } - } inl = ASN1_item_i2d(asn, &buf_in, it); diff --git a/crypto/blake2/blake2b.c b/crypto/blake2/blake2b.c index 73ba0b6b..813f9dde 100644 --- a/crypto/blake2/blake2b.c +++ b/crypto/blake2/blake2b.c @@ -23,10 +23,10 @@ static const uint64_t blake2b_IV[8] = { - 0x6a09e667f3bcc908U, 0xbb67ae8584caa73bU, - 0x3c6ef372fe94f82bU, 0xa54ff53a5f1d36f1U, - 0x510e527fade682d1U, 0x9b05688c2b3e6c1fU, - 0x1f83d9abfb41bd6bU, 0x5be0cd19137e2179U + 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, + 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, + 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, + 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL }; static const uint8_t blake2b_sigma[12][16] = diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c index c4ab8693..7a87b97d 100644 --- a/crypto/bn/bn_prime.c +++ b/crypto/bn/bn_prime.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 @@ -19,14 +19,49 @@ */ #include "bn_prime.h" -static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1, - const BIGNUM *a1_odd, int k, BN_CTX *ctx, - BN_MONT_CTX *mont); static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods); static int probable_prime_dh_safe(BIGNUM *rnd, int bits, const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx); +#if BN_BITS2 == 64 +# define BN_DEF(lo, hi) (BN_ULONG)hi<<32|lo +#else +# define BN_DEF(lo, hi) lo, hi +#endif + +/* + * See SP800 89 5.3.3 (Step f) + * The product of the set of primes ranging from 3 to 751 + * Generated using process in test/bn_internal_test.c test_bn_small_factors(). + * This includes 751 (which is not currently included in SP 800-89). + */ +static const BN_ULONG small_prime_factors[] = { + BN_DEF(0x3ef4e3e1, 0xc4309333), BN_DEF(0xcd2d655f, 0x71161eb6), + BN_DEF(0x0bf94862, 0x95e2238c), BN_DEF(0x24f7912b, 0x3eb233d3), + BN_DEF(0xbf26c483, 0x6b55514b), BN_DEF(0x5a144871, 0x0a84d817), + BN_DEF(0x9b82210a, 0x77d12fee), BN_DEF(0x97f050b3, 0xdb5b93c2), + BN_DEF(0x4d6c026b, 0x4acad6b9), BN_DEF(0x54aec893, 0xeb7751f3), + BN_DEF(0x36bc85c4, 0xdba53368), BN_DEF(0x7f5ec78e, 0xd85a1b28), + BN_DEF(0x6b322244, 0x2eb072d8), BN_DEF(0x5e2b3aea, 0xbba51112), + BN_DEF(0x0e2486bf, 0x36ed1a6c), BN_DEF(0xec0c5727, 0x5f270460), + (BN_ULONG)0x000017b1 +}; + +#define BN_SMALL_PRIME_FACTORS_TOP OSSL_NELEM(small_prime_factors) +static const BIGNUM _bignum_small_prime_factors = { + (BN_ULONG *)small_prime_factors, + BN_SMALL_PRIME_FACTORS_TOP, + BN_SMALL_PRIME_FACTORS_TOP, + 0, + BN_FLG_STATIC_DATA +}; + +const BIGNUM *bn_get0_small_factors(void) +{ + return &_bignum_small_prime_factors; +} + int BN_GENCB_call(BN_GENCB *cb, int a, int b) { /* No callback means continue */ @@ -148,127 +183,199 @@ int BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 0, cb); } -int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, +/* See FIPS 186-4 C.3.1 Miller Rabin Probabilistic Primality Test. */ +int BN_is_prime_fasttest_ex(const BIGNUM *w, int checks, BN_CTX *ctx_passed, int do_trial_division, BN_GENCB *cb) { - int i, j, ret = -1; - int k; + int i, status, ret = -1; BN_CTX *ctx = NULL; - BIGNUM *A1, *A1_odd, *A3, *check; /* taken from ctx */ - BN_MONT_CTX *mont = NULL; - /* Take care of the really small primes 2 & 3 */ - if (BN_is_word(a, 2) || BN_is_word(a, 3)) - return 1; - - /* Check odd and bigger than 1 */ - if (!BN_is_odd(a) || BN_cmp(a, BN_value_one()) <= 0) + /* w must be bigger than 1 */ + if (BN_cmp(w, BN_value_one()) <= 0) return 0; - if (checks == BN_prime_checks) - checks = BN_prime_checks_for_size(BN_num_bits(a)); + /* w must be odd */ + if (BN_is_odd(w)) { + /* Take care of the really small prime 3 */ + if (BN_is_word(w, 3)) + return 1; + } else { + /* 2 is the only even prime */ + return BN_is_word(w, 2); + } /* first look for small factors */ if (do_trial_division) { for (i = 1; i < NUMPRIMES; i++) { - BN_ULONG mod = BN_mod_word(a, primes[i]); + BN_ULONG mod = BN_mod_word(w, primes[i]); if (mod == (BN_ULONG)-1) - goto err; + return -1; if (mod == 0) - return BN_is_word(a, primes[i]); + return BN_is_word(w, primes[i]); } if (!BN_GENCB_call(cb, 1, -1)) - goto err; + return -1; } - if (ctx_passed != NULL) ctx = ctx_passed; else if ((ctx = BN_CTX_new()) == NULL) goto err; + + ret = bn_miller_rabin_is_prime(w, checks, ctx, cb, 0, &status); + if (!ret) + goto err; + ret = (status == BN_PRIMETEST_PROBABLY_PRIME); +err: + if (ctx_passed == NULL) + BN_CTX_free(ctx); + return ret; +} + +/* + * Refer to FIPS 186-4 C.3.2 Enhanced Miller-Rabin Probabilistic Primality Test. + * OR C.3.1 Miller-Rabin Probabilistic Primality Test (if enhanced is zero). + * The Step numbers listed in the code refer to the enhanced case. + * + * if enhanced is set, then status returns one of the following: + * BN_PRIMETEST_PROBABLY_PRIME + * BN_PRIMETEST_COMPOSITE_WITH_FACTOR + * BN_PRIMETEST_COMPOSITE_NOT_POWER_OF_PRIME + * if enhanced is zero, then status returns either + * BN_PRIMETEST_PROBABLY_PRIME or + * BN_PRIMETEST_COMPOSITE + * + * returns 0 if there was an error, otherwise it returns 1. + */ +int bn_miller_rabin_is_prime(const BIGNUM *w, int iterations, BN_CTX *ctx, + BN_GENCB *cb, int enhanced, int *status) +{ + int i, j, a, ret = 0; + BIGNUM *g, *w1, *w3, *x, *m, *z, *b; + BN_MONT_CTX *mont = NULL; + + /* w must be odd */ + if (!BN_is_odd(w)) + return 0; + BN_CTX_start(ctx); + g = BN_CTX_get(ctx); + w1 = BN_CTX_get(ctx); + w3 = BN_CTX_get(ctx); + x = BN_CTX_get(ctx); + m = BN_CTX_get(ctx); + z = BN_CTX_get(ctx); + b = BN_CTX_get(ctx); - A1 = BN_CTX_get(ctx); - A3 = BN_CTX_get(ctx); - A1_odd = BN_CTX_get(ctx); - check = BN_CTX_get(ctx); - if (check == NULL) + if (!(b != NULL + /* w1 := w - 1 */ + && BN_copy(w1, w) + && BN_sub_word(w1, 1) + /* w3 := w - 3 */ + && BN_copy(w3, w) + && BN_sub_word(w3, 3))) goto err; - /* compute A1 := a - 1 */ - if (!BN_copy(A1, a) || !BN_sub_word(A1, 1)) - goto err; - /* compute A3 := a - 3 */ - if (!BN_copy(A3, a) || !BN_sub_word(A3, 3)) + /* check w is larger than 3, otherwise the random b will be too small */ + if (BN_is_zero(w3) || BN_is_negative(w3)) goto err; - /* write A1 as A1_odd * 2^k */ - k = 1; - while (!BN_is_bit_set(A1, k)) - k++; - if (!BN_rshift(A1_odd, A1, k)) + /* (Step 1) Calculate largest integer 'a' such that 2^a divides w-1 */ + a = 1; + while (!BN_is_bit_set(w1, a)) + a++; + /* (Step 2) m = (w-1) / 2^a */ + if (!BN_rshift(m, w1, a)) goto err; /* Montgomery setup for computations mod a */ mont = BN_MONT_CTX_new(); - if (mont == NULL) - goto err; - if (!BN_MONT_CTX_set(mont, a, ctx)) + if (mont == NULL || !BN_MONT_CTX_set(mont, w, ctx)) goto err; - for (i = 0; i < checks; i++) { - /* 1 < check < a-1 */ - if (!BN_priv_rand_range(check, A3) || !BN_add_word(check, 2)) + if (iterations == BN_prime_checks) + iterations = BN_prime_checks_for_size(BN_num_bits(w)); + + /* (Step 4) */ + for (i = 0; i < iterations; ++i) { + /* (Step 4.1) obtain a Random string of bits b where 1 < b < w-1 */ + if (!BN_priv_rand_range(b, w3) || !BN_add_word(b, 2)) /* 1 < b < w-1 */ goto err; - j = witness(check, a, A1, A1_odd, k, ctx, mont); - if (j == -1) - goto err; - if (j) { - ret = 0; + if (enhanced) { + /* (Step 4.3) */ + if (!BN_gcd(g, b, w, ctx)) + goto err; + /* (Step 4.4) */ + if (!BN_is_one(g)) { + *status = BN_PRIMETEST_COMPOSITE_WITH_FACTOR; + ret = 1; + goto err; + } + } + /* (Step 4.5) z = b^m mod w */ + if (!BN_mod_exp_mont(z, b, m, w, ctx, mont)) goto err; + /* (Step 4.6) if (z = 1 or z = w-1) */ + if (BN_is_one(z) || BN_cmp(z, w1) == 0) + goto outer_loop; + /* (Step 4.7) for j = 1 to a-1 */ + for (j = 1; j < a ; ++j) { + /* (Step 4.7.1 - 4.7.2) x = z. z = x^2 mod w */ + if (!BN_copy(x, z) || !BN_mod_mul(z, x, x, w, ctx)) + goto err; + /* (Step 4.7.3) */ + if (BN_cmp(z, w1) == 0) + goto outer_loop; + /* (Step 4.7.4) */ + if (BN_is_one(z)) + goto composite; } if (!BN_GENCB_call(cb, 1, i)) goto err; + /* At this point z = b^((w-1)/2) mod w */ + /* (Steps 4.8 - 4.9) x = z, z = x^2 mod w */ + if (!BN_copy(x, z) || !BN_mod_mul(z, x, x, w, ctx)) + goto err; + /* (Step 4.10) */ + if (BN_is_one(z)) + goto composite; + /* (Step 4.11) x = b^(w-1) mod w */ + if (!BN_copy(x, z)) + goto err; +composite: + if (enhanced) { + /* (Step 4.1.2) g = GCD(x-1, w) */ + if (!BN_sub_word(x, 1) || !BN_gcd(g, x, w, ctx)) + goto err; + /* (Steps 4.1.3 - 4.1.4) */ + if (BN_is_one(g)) + *status = BN_PRIMETEST_COMPOSITE_NOT_POWER_OF_PRIME; + else + *status = BN_PRIMETEST_COMPOSITE_WITH_FACTOR; + } else { + *status = BN_PRIMETEST_COMPOSITE; + } + ret = 1; + goto err; +outer_loop: ; + /* (Step 4.1.5) */ } + /* (Step 5) */ + *status = BN_PRIMETEST_PROBABLY_PRIME; ret = 1; - err: - if (ctx != NULL) { - BN_CTX_end(ctx); - if (ctx_passed == NULL) - BN_CTX_free(ctx); - } +err: + BN_clear(g); + BN_clear(w1); + BN_clear(w3); + BN_clear(x); + BN_clear(m); + BN_clear(z); + BN_clear(b); + BN_CTX_end(ctx); BN_MONT_CTX_free(mont); - return ret; } -static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1, - const BIGNUM *a1_odd, int k, BN_CTX *ctx, - BN_MONT_CTX *mont) -{ - if (!BN_mod_exp_mont(w, w, a1_odd, a, ctx, mont)) /* w := w^a1_odd mod a */ - return -1; - if (BN_is_one(w)) - return 0; /* probably prime */ - if (BN_cmp(w, a1) == 0) - return 0; /* w == -1 (mod a), 'a' is probably prime */ - while (--k) { - if (!BN_mod_mul(w, w, w, a, ctx)) /* w := w^2 mod a */ - return -1; - if (BN_is_one(w)) - return 1; /* 'a' is composite, otherwise a previous 'w' - * would have been == -1 (mod 'a') */ - if (BN_cmp(w, a1) == 0) - return 0; /* w == -1 (mod a), 'a' is probably prime */ - } - /* - * If we get here, 'w' is the (a-1)/2-th power of the original 'w', and - * it is neither -1 nor +1 -- so 'a' cannot be prime - */ - bn_check_top(w); - return 1; -} - static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods) { int i; diff --git a/crypto/bn/bn_rsa_fips186_4.c b/crypto/bn/bn_rsa_fips186_4.c new file mode 100644 index 00000000..261669d0 --- /dev/null +++ b/crypto/bn/bn_rsa_fips186_4.c @@ -0,0 +1,346 @@ +/* + * Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2018-2019, Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the OpenSSL license (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 + */ + +/* + * According to NIST SP800-131A "Transitioning the use of cryptographic + * algorithms and key lengths" Generation of 1024 bit RSA keys are no longer + * allowed for signatures (Table 2) or key transport (Table 5). In the code + * below any attempt to generate 1024 bit RSA keys will result in an error (Note + * that digital signature verification can still use deprecated 1024 bit keys). + * + * Also see FIPS1402IG A.14 + * FIPS 186-4 relies on the use of the auxiliary primes p1, p2, q1 and q2 that + * must be generated before the module generates the RSA primes p and q. + * Table B.1 in FIPS 186-4 specifies, for RSA modulus lengths of 2048 and + * 3072 bits only, the min/max total length of the auxiliary primes. + * When implementing the RSA signature generation algorithm + * with other approved RSA modulus sizes, the vendor shall use the limitations + * from Table B.1 that apply to the longest RSA modulus shown in Table B.1 of + * FIPS 186-4 whose length does not exceed that of the implementation's RSA + * modulus. In particular, when generating the primes for the 4096-bit RSA + * modulus the limitations stated for the 3072-bit modulus shall apply. + */ +#include +#include +#include "bn_lcl.h" +#include "internal/bn_int.h" + +/* + * FIPS 186-4 Table B.1. "Min length of auxiliary primes p1, p2, q1, q2". + * + * Params: + * nbits The key size in bits. + * Returns: + * The minimum size of the auxiliary primes or 0 if nbits is invalid. + */ +static int bn_rsa_fips186_4_aux_prime_min_size(int nbits) +{ + if (nbits >= 3072) + return 171; + if (nbits == 2048) + return 141; + return 0; +} + +/* + * FIPS 186-4 Table B.1 "Maximum length of len(p1) + len(p2) and + * len(q1) + len(q2) for p,q Probable Primes". + * + * Params: + * nbits The key size in bits. + * Returns: + * The maximum length or 0 if nbits is invalid. + */ +static int bn_rsa_fips186_4_aux_prime_max_sum_size_for_prob_primes(int nbits) +{ + if (nbits >= 3072) + return 1518; + if (nbits == 2048) + return 1007; + return 0; +} + +/* + * FIPS 186-4 Table C.3 for error probability of 2^-100 + * Minimum number of Miller Rabin Rounds for p1, p2, q1 & q2. + * + * Params: + * aux_prime_bits The auxiliary prime size in bits. + * Returns: + * The minimum number of Miller Rabin Rounds for an auxiliary prime, or + * 0 if aux_prime_bits is invalid. + */ +static int bn_rsa_fips186_4_aux_prime_MR_min_checks(int aux_prime_bits) +{ + if (aux_prime_bits > 170) + return 27; + if (aux_prime_bits > 140) + return 32; + return 0; /* Error case */ +} + +/* + * FIPS 186-4 Table C.3 for error probability of 2^-100 + * Minimum number of Miller Rabin Rounds for p, q. + * + * Params: + * nbits The key size in bits. + * Returns: + * The minimum number of Miller Rabin Rounds required, + * or 0 if nbits is invalid. + */ +int bn_rsa_fips186_4_prime_MR_min_checks(int nbits) +{ + if (nbits >= 3072) /* > 170 */ + return 3; + if (nbits == 2048) /* > 140 */ + return 4; + return 0; /* Error case */ +} + +/* + * Find the first odd integer that is a probable prime. + * + * See section FIPS 186-4 B.3.6 (Steps 4.2/5.2). + * + * Params: + * Xp1 The passed in starting point to find a probably prime. + * p1 The returned probable prime (first odd integer >= Xp1) + * ctx A BN_CTX object. + * cb An optional BIGNUM callback. + * Returns: 1 on success otherwise it returns 0. + */ +static int bn_rsa_fips186_4_find_aux_prob_prime(const BIGNUM *Xp1, + BIGNUM *p1, BN_CTX *ctx, + BN_GENCB *cb) +{ + int ret = 0; + int i = 0; + int checks = bn_rsa_fips186_4_aux_prime_MR_min_checks(BN_num_bits(Xp1)); + + if (checks == 0 || BN_copy(p1, Xp1) == NULL) + return 0; + + /* Find the first odd number >= Xp1 that is probably prime */ + for(;;) { + i++; + BN_GENCB_call(cb, 0, i); + /* MR test with trial division */ + if (BN_is_prime_fasttest_ex(p1, checks, ctx, 1, cb)) + break; + /* Get next odd number */ + if (!BN_add_word(p1, 2)) + goto err; + } + BN_GENCB_call(cb, 2, i); + ret = 1; +err: + return ret; +} + +/* + * Generate a probable prime (p or q). + * + * See FIPS 186-4 B.3.6 (Steps 4 & 5) + * + * Params: + * p The returned probable prime. + * Xpout An optionally returned random number used during generation of p. + * p1, p2 The returned auxiliary primes. If NULL they are not returned. + * Xp An optional passed in value (that is random number used during + * generation of p). + * Xp1, Xp2 Optional passed in values that are normally generated + * internally. Used to find p1, p2. + * nlen The bit length of the modulus (the key size). + * e The public exponent. + * ctx A BN_CTX object. + * cb An optional BIGNUM callback. + * Returns: 1 on success otherwise it returns 0. + */ +int bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout, + BIGNUM *p1, BIGNUM *p2, + const BIGNUM *Xp, const BIGNUM *Xp1, + const BIGNUM *Xp2, int nlen, + const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb) +{ + int ret = 0; + BIGNUM *p1i = NULL, *p2i = NULL, *Xp1i = NULL, *Xp2i = NULL; + int bitlen; + + if (p == NULL || Xpout == NULL) + return 0; + + BN_CTX_start(ctx); + + p1i = (p1 != NULL) ? p1 : BN_CTX_get(ctx); + p2i = (p2 != NULL) ? p2 : BN_CTX_get(ctx); + Xp1i = (Xp1 != NULL) ? (BIGNUM *)Xp1 : BN_CTX_get(ctx); + Xp2i = (Xp2 != NULL) ? (BIGNUM *)Xp2 : BN_CTX_get(ctx); + if (p1i == NULL || p2i == NULL || Xp1i == NULL || Xp2i == NULL) + goto err; + + bitlen = bn_rsa_fips186_4_aux_prime_min_size(nlen); + if (bitlen == 0) + goto err; + + /* (Steps 4.1/5.1): Randomly generate Xp1 if it is not passed in */ + if (Xp1 == NULL) { + /* Set the top and bottom bits to make it odd and the correct size */ + if (!BN_priv_rand(Xp1i, bitlen, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD)) + goto err; + } + /* (Steps 4.1/5.1): Randomly generate Xp2 if it is not passed in */ + if (Xp2 == NULL) { + /* Set the top and bottom bits to make it odd and the correct size */ + if (!BN_priv_rand(Xp2i, bitlen, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD)) + goto err; + } + + /* (Steps 4.2/5.2) - find first auxiliary probable primes */ + if (!bn_rsa_fips186_4_find_aux_prob_prime(Xp1i, p1i, ctx, cb) + || !bn_rsa_fips186_4_find_aux_prob_prime(Xp2i, p2i, ctx, cb)) + goto err; + /* (Table B.1) auxiliary prime Max length check */ + if ((BN_num_bits(p1i) + BN_num_bits(p2i)) >= + bn_rsa_fips186_4_aux_prime_max_sum_size_for_prob_primes(nlen)) + goto err; + /* (Steps 4.3/5.3) - generate prime */ + if (!bn_rsa_fips186_4_derive_prime(p, Xpout, Xp, p1i, p2i, nlen, e, ctx, cb)) + goto err; + ret = 1; +err: + /* Zeroize any internally generated values that are not returned */ + if (p1 == NULL) + BN_clear(p1i); + if (p2 == NULL) + BN_clear(p2i); + if (Xp1 == NULL) + BN_clear(Xp1i); + if (Xp2 == NULL) + BN_clear(Xp2i); + BN_CTX_end(ctx); + return ret; +} + +/* + * Constructs a probable prime (a candidate for p or q) using 2 auxiliary + * prime numbers and the Chinese Remainder Theorem. + * + * See FIPS 186-4 C.9 "Compute a Probable Prime Factor Based on Auxiliary + * Primes". Used by FIPS 186-4 B.3.6 Section (4.3) for p and Section (5.3) for q. + * + * Params: + * Y The returned prime factor (private_prime_factor) of the modulus n. + * X The returned random number used during generation of the prime factor. + * Xin An optional passed in value for X used for testing purposes. + * r1 An auxiliary prime. + * r2 An auxiliary prime. + * nlen The desired length of n (the RSA modulus). + * e The public exponent. + * ctx A BN_CTX object. + * cb An optional BIGNUM callback object. + * Returns: 1 on success otherwise it returns 0. + * Assumptions: + * Y, X, r1, r2, e are not NULL. + */ +int bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin, + const BIGNUM *r1, const BIGNUM *r2, int nlen, + const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb) +{ + int ret = 0; + int i, imax; + int bits = nlen >> 1; + int checks = bn_rsa_fips186_4_prime_MR_min_checks(nlen); + BIGNUM *tmp, *R, *r1r2x2, *y1, *r1x2; + + if (checks == 0) + return 0; + BN_CTX_start(ctx); + + R = BN_CTX_get(ctx); + tmp = BN_CTX_get(ctx); + r1r2x2 = BN_CTX_get(ctx); + y1 = BN_CTX_get(ctx); + r1x2 = BN_CTX_get(ctx); + if (r1x2 == NULL) + goto err; + + if (Xin != NULL && BN_copy(X, Xin) == NULL) + goto err; + + if (!(BN_lshift1(r1x2, r1) + /* (Step 1) GCD(2r1, r2) = 1 */ + && BN_gcd(tmp, r1x2, r2, ctx) + && BN_is_one(tmp) + /* (Step 2) R = ((r2^-1 mod 2r1) * r2) - ((2r1^-1 mod r2)*2r1) */ + && BN_mod_inverse(R, r2, r1x2, ctx) + && BN_mul(R, R, r2, ctx) /* R = (r2^-1 mod 2r1) * r2 */ + && BN_mod_inverse(tmp, r1x2, r2, ctx) + && BN_mul(tmp, tmp, r1x2, ctx) /* tmp = (2r1^-1 mod r2)*2r1 */ + && BN_sub(R, R, tmp) + /* Calculate 2r1r2 */ + && BN_mul(r1r2x2, r1x2, r2, ctx))) + goto err; + /* Make positive by adding the modulus */ + if (BN_is_negative(R) && !BN_add(R, R, r1r2x2)) + goto err; + + imax = 5 * bits; /* max = 5/2 * nbits */ + for (;;) { + if (Xin == NULL) { + /* + * (Step 3) Choose Random X such that + * sqrt(2) * 2^(nlen/2-1) < Random X < (2^(nlen/2)) - 1. + * + * For the lower bound: + * sqrt(2) * 2^(nlen/2 - 1) == sqrt(2)/2 * 2^(nlen/2) + * where sqrt(2)/2 = 0.70710678.. = 0.B504FC33F9DE... + * so largest number will have B5... as the top byte + * Setting the top 2 bits gives 0xC0. + */ + if (!BN_priv_rand(X, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY)) + goto end; + } + /* (Step 4) Y = X + ((R - X) mod 2r1r2) */ + if (!BN_mod_sub(Y, R, X, r1r2x2, ctx) || !BN_add(Y, Y, X)) + goto err; + /* (Step 5) */ + i = 0; + for (;;) { + /* (Step 6) */ + if (BN_num_bits(Y) > bits) { + if (Xin == NULL) + break; /* Randomly Generated X so Go back to Step 3 */ + else + goto err; /* X is not random so it will always fail */ + } + BN_GENCB_call(cb, 0, 2); + + /* (Step 7) If GCD(Y-1) == 1 & Y is probably prime then return Y */ + if (BN_copy(y1, Y) == NULL + || !BN_sub_word(y1, 1) + || !BN_gcd(tmp, y1, e, ctx)) + goto err; + if (BN_is_one(tmp) + && BN_is_prime_fasttest_ex(Y, checks, ctx, 1, cb)) + goto end; + /* (Step 8-10) */ + if (++i >= imax || !BN_add(Y, Y, r1r2x2)) + goto err; + } + } +end: + ret = 1; + BN_GENCB_call(cb, 3, 0); +err: + BN_clear(y1); + BN_CTX_end(ctx); + return ret; +} diff --git a/crypto/bn/build.info b/crypto/bn/build.info index a463edda..7e34ce41 100644 --- a/crypto/bn/build.info +++ b/crypto/bn/build.info @@ -5,7 +5,8 @@ SOURCE[../../libcrypto]=\ bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c \ {- $target{bn_asm_src} -} \ 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_depr.c bn_const.c bn_x931p.c bn_intern.c bn_dh.c bn_srp.c \ + bn_rsa_fips186_4.c INCLUDE[../../libcrypto]=../../crypto/include INCLUDE[bn_exp.o]=.. diff --git a/crypto/build.info b/crypto/build.info index e3e9ceee..39cd91ba 100644 --- a/crypto/build.info +++ b/crypto/build.info @@ -5,15 +5,19 @@ SUBDIRS=objects buffer bio stack lhash rand evp asn1 pem x509 x509v3 conf \ 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 + err comp ocsp cms ts srp cmac ct async kmac ess crmf LIBS=../libcrypto +# The Core +SOURCE[../libcrypto]=provider_core.c core_fetch.c + +# Central utilities SOURCE[../libcrypto]=\ cryptlib.c mem.c mem_dbg.c cversion.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 \ + trace.c provider.c params.c \ {- $target{cpuid_asm_src} -} {- $target{uplink_aux_src} -} DEPEND[cversion.o]=buildinf.h diff --git a/crypto/chacha/asm/chacha-s390x.pl b/crypto/chacha/asm/chacha-s390x.pl index abf7283d..51efe644 100755 --- a/crypto/chacha/asm/chacha-s390x.pl +++ b/crypto/chacha/asm/chacha-s390x.pl @@ -23,11 +23,20 @@ # # August 2018 # -# Add vx code path. +# Add vx code path: 4x"vertical". # # Copyright IBM Corp. 2018 # Author: Patrick Steuer +# +# February 2019 +# +# Add 6x"horizontal" VX implementation. It's ~25% faster than IBM's +# 4x"vertical" submission [on z13] and >3 faster than scalar code. +# But to harness overheads revert to transliteration of VSX code path +# from chacha-ppc module, which is also 4x"vertical", to handle inputs +# not longer than 256 bytes. + use strict; use FindBin qw($Bin); use lib "$Bin/../.."; @@ -50,11 +59,9 @@ while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} my $sp="%r15"; my $stdframe=16*$SIZE_T+4*8; +sub ROUND { my @x=map("%r$_",(0..7,"x","x","x","x",(10..13))); my @t=map("%r$_",(8,9)); -my @v=map("%v$_",(16..31)); - -sub ROUND { my ($a0,$b0,$c0,$d0)=@_; my ($a1,$b1,$c1,$d1)=map(($_&~3)+(($_+1)&3),($a0,$b0,$c0,$d0)); my ($a2,$b2,$c2,$d2)=map(($_&~3)+(($_+1)&3),($a1,$b1,$c1,$d1)); @@ -143,63 +150,92 @@ my ($xc,$xc_)=map("$_",@t); rll (@x[$b3],@x[$b3],7); } -sub VX_ROUND { +sub VX_lane_ROUND { my ($a0,$b0,$c0,$d0)=@_; my ($a1,$b1,$c1,$d1)=map(($_&~3)+(($_+1)&3),($a0,$b0,$c0,$d0)); my ($a2,$b2,$c2,$d2)=map(($_&~3)+(($_+1)&3),($a1,$b1,$c1,$d1)); my ($a3,$b3,$c3,$d3)=map(($_&~3)+(($_+1)&3),($a2,$b2,$c2,$d2)); +my @x=map("%v$_",(0..15)); - vaf (@v[$a0],@v[$a0],@v[$b0]); - vaf (@v[$a1],@v[$a1],@v[$b1]); - vaf (@v[$a2],@v[$a2],@v[$b2]); - vaf (@v[$a3],@v[$a3],@v[$b3]); - vx (@v[$d0],@v[$d0],@v[$a0]); - vx (@v[$d1],@v[$d1],@v[$a1]); - vx (@v[$d2],@v[$d2],@v[$a2]); - vx (@v[$d3],@v[$d3],@v[$a3]); - verllf (@v[$d0],@v[$d0],16); - verllf (@v[$d1],@v[$d1],16); - verllf (@v[$d2],@v[$d2],16); - verllf (@v[$d3],@v[$d3],16); + vaf (@x[$a0],@x[$a0],@x[$b0]); # Q1 + vx (@x[$d0],@x[$d0],@x[$a0]); + verllf (@x[$d0],@x[$d0],16); + vaf (@x[$a1],@x[$a1],@x[$b1]); # Q2 + vx (@x[$d1],@x[$d1],@x[$a1]); + verllf (@x[$d1],@x[$d1],16); + vaf (@x[$a2],@x[$a2],@x[$b2]); # Q3 + vx (@x[$d2],@x[$d2],@x[$a2]); + verllf (@x[$d2],@x[$d2],16); + vaf (@x[$a3],@x[$a3],@x[$b3]); # Q4 + vx (@x[$d3],@x[$d3],@x[$a3]); + verllf (@x[$d3],@x[$d3],16); - vaf (@v[$c0],@v[$c0],@v[$d0]); - vaf (@v[$c1],@v[$c1],@v[$d1]); - vaf (@v[$c2],@v[$c2],@v[$d2]); - vaf (@v[$c3],@v[$c3],@v[$d3]); - vx (@v[$b0],@v[$b0],@v[$c0]); - vx (@v[$b1],@v[$b1],@v[$c1]); - vx (@v[$b2],@v[$b2],@v[$c2]); - vx (@v[$b3],@v[$b3],@v[$c3]); - verllf (@v[$b0],@v[$b0],12); - verllf (@v[$b1],@v[$b1],12); - verllf (@v[$b2],@v[$b2],12); - verllf (@v[$b3],@v[$b3],12); + vaf (@x[$c0],@x[$c0],@x[$d0]); + vx (@x[$b0],@x[$b0],@x[$c0]); + verllf (@x[$b0],@x[$b0],12); + vaf (@x[$c1],@x[$c1],@x[$d1]); + vx (@x[$b1],@x[$b1],@x[$c1]); + verllf (@x[$b1],@x[$b1],12); + vaf (@x[$c2],@x[$c2],@x[$d2]); + vx (@x[$b2],@x[$b2],@x[$c2]); + verllf (@x[$b2],@x[$b2],12); + vaf (@x[$c3],@x[$c3],@x[$d3]); + vx (@x[$b3],@x[$b3],@x[$c3]); + verllf (@x[$b3],@x[$b3],12); - vaf (@v[$a0],@v[$a0],@v[$b0]); - vaf (@v[$a1],@v[$a1],@v[$b1]); - vaf (@v[$a2],@v[$a2],@v[$b2]); - vaf (@v[$a3],@v[$a3],@v[$b3]); - vx (@v[$d0],@v[$d0],@v[$a0]); - vx (@v[$d1],@v[$d1],@v[$a1]); - vx (@v[$d2],@v[$d2],@v[$a2]); - vx (@v[$d3],@v[$d3],@v[$a3]); - verllf (@v[$d0],@v[$d0],8); - verllf (@v[$d1],@v[$d1],8); - verllf (@v[$d2],@v[$d2],8); - verllf (@v[$d3],@v[$d3],8); + vaf (@x[$a0],@x[$a0],@x[$b0]); + vx (@x[$d0],@x[$d0],@x[$a0]); + verllf (@x[$d0],@x[$d0],8); + vaf (@x[$a1],@x[$a1],@x[$b1]); + vx (@x[$d1],@x[$d1],@x[$a1]); + verllf (@x[$d1],@x[$d1],8); + vaf (@x[$a2],@x[$a2],@x[$b2]); + vx (@x[$d2],@x[$d2],@x[$a2]); + verllf (@x[$d2],@x[$d2],8); + vaf (@x[$a3],@x[$a3],@x[$b3]); + vx (@x[$d3],@x[$d3],@x[$a3]); + verllf (@x[$d3],@x[$d3],8); - vaf (@v[$c0],@v[$c0],@v[$d0]); - vaf (@v[$c1],@v[$c1],@v[$d1]); - vaf (@v[$c2],@v[$c2],@v[$d2]); - vaf (@v[$c3],@v[$c3],@v[$d3]); - vx (@v[$b0],@v[$b0],@v[$c0]); - vx (@v[$b1],@v[$b1],@v[$c1]); - vx (@v[$b2],@v[$b2],@v[$c2]); - vx (@v[$b3],@v[$b3],@v[$c3]); - verllf (@v[$b0],@v[$b0],7); - verllf (@v[$b1],@v[$b1],7); - verllf (@v[$b2],@v[$b2],7); - verllf (@v[$b3],@v[$b3],7); + vaf (@x[$c0],@x[$c0],@x[$d0]); + vx (@x[$b0],@x[$b0],@x[$c0]); + verllf (@x[$b0],@x[$b0],7); + vaf (@x[$c1],@x[$c1],@x[$d1]); + vx (@x[$b1],@x[$b1],@x[$c1]); + verllf (@x[$b1],@x[$b1],7); + vaf (@x[$c2],@x[$c2],@x[$d2]); + vx (@x[$b2],@x[$b2],@x[$c2]); + verllf (@x[$b2],@x[$b2],7); + vaf (@x[$c3],@x[$c3],@x[$d3]); + vx (@x[$b3],@x[$b3],@x[$c3]); + verllf (@x[$b3],@x[$b3],7); +} + +sub VX_ROUND { +my @a=@_[0..5]; +my @b=@_[6..11]; +my @c=@_[12..17]; +my @d=@_[18..23]; +my $odd=@_[24]; + + vaf (@a[$_],@a[$_],@b[$_]) for (0..5); + vx (@d[$_],@d[$_],@a[$_]) for (0..5); + verllf (@d[$_],@d[$_],16) for (0..5); + + vaf (@c[$_],@c[$_],@d[$_]) for (0..5); + vx (@b[$_],@b[$_],@c[$_]) for (0..5); + verllf (@b[$_],@b[$_],12) for (0..5); + + vaf (@a[$_],@a[$_],@b[$_]) for (0..5); + vx (@d[$_],@d[$_],@a[$_]) for (0..5); + verllf (@d[$_],@d[$_],8) for (0..5); + + vaf (@c[$_],@c[$_],@d[$_]) for (0..5); + vx (@b[$_],@b[$_],@c[$_]) for (0..5); + verllf (@b[$_],@b[$_],7) for (0..5); + + vsldb (@c[$_],@c[$_],@c[$_],8) for (0..5); + vsldb (@b[$_],@b[$_],@b[$_],$odd?12:4) for (0..5); + vsldb (@d[$_],@d[$_],@d[$_],$odd?4:12) for (0..5); } PERLASM_BEGIN($output); @@ -210,13 +246,11 @@ TEXT (); ################ # void ChaCha20_ctr32(unsigned char *out, const unsigned char *inp, size_t len, # const unsigned int key[8], const unsigned int counter[4]) -{ my ($out,$inp,$len,$key,$counter)=map("%r$_",(2..6)); - -# VX CODE PATH { -my $off=$z*8*16+8; # offset(initial state) -my $frame=$stdframe+4*16+$off; +my $frame=$stdframe+4*20; +my @x=map("%r$_",(0..7,"x","x","x","x",(10..13))); +my @t=map("%r$_",(8,9)); GLOBL ("ChaCha20_ctr32"); TYPE ("ChaCha20_ctr32","\@function"); @@ -225,230 +259,16 @@ LABEL ("ChaCha20_ctr32"); larl ("%r1","OPENSSL_s390xcap_P"); lghi ("%r0",64); -&{$z? \&clgr:\&clr} ($len,"%r0"); - jle ("_s390x_chacha_novx"); - - lg ("%r0","S390X_STFLE+16(%r1)"); - tmhh ("%r0",0x4000); # check for vector facility - jz ("_s390x_chacha_novx"); - -if (!$z) { - llgfr ($len,$len); - std ("%f4","16*$SIZE_T+2*8($sp)"); - std ("%f6","16*$SIZE_T+3*8($sp)"); -} -&{$z? \&stmg:\&stm} ("%r6","%r7","6*$SIZE_T($sp)"); - - lghi ("%r1",-$frame); - lgr ("%r0",$sp); - la ($sp,"0(%r1,$sp)"); # allocate stack frame - - larl ("%r7",".Lsigma"); -&{$z? \&stg:\&st} ("%r0","0($sp)"); # backchain - - vstm ("%v8","%v15","8($sp)") if ($z); - - vlm ("%v1","%v2","0($key)"); # load key - vl ("%v0","0(%r7)"); # load sigma constant - vl ("%v3","0($counter)"); # load iv (counter||nonce) - l ("%r0","0($counter)"); # load counter - vstm ("%v0","%v3","$off($sp)"); # copy initial state to stack - - srlg ("%r1",$len,8); - ltgr ("%r1","%r1"); - jz (".Lvx_4x_done"); - -ALIGN (16); # process 4 64-byte blocks -LABEL (".Lvx_4x"); - vlrepf ("%v$_",($_*4)."+$off($sp)") for (0..15); # load initial - # state - vl ("%v31","16(%r7)"); - vaf ("%v12","%v12","%v31"); # increment counter - - vlr (@v[$_],"%v$_") for (0..15); # copy initial state - - lhi ("%r6",10); - j (".Loop_vx_4x"); - -ALIGN (16); -LABEL (".Loop_vx_4x"); - VX_ROUND( 0, 4, 8,12); # column round - VX_ROUND( 0, 5,10,15); # diagonal round - brct ("%r6",".Loop_vx_4x"); - - vaf (@v[$_],@v[$_],"%v$_") for (0..15); # state += initial - # state (mod 32) - vlm ("%v6","%v7","32(%r7)"); # load vperm operands - -for (0..3) { # blocks 1,2 - vmrhf ("%v0",@v[$_*4+0],@v[$_*4+1]); # ks = serialize(state) - vmrhf ("%v1",@v[$_*4+2],@v[$_*4+3]); - vperm ("%v".($_+ 8),"%v0","%v1","%v6"); - vperm ("%v".($_+12),"%v0","%v1","%v7"); -} - vlm ("%v0","%v7","0($inp)"); # load in - vx ("%v$_","%v$_","%v".($_+8)) for (0..7); # out = in ^ ks - vstm ("%v0","%v7","0($out)"); # store out - - vlm ("%v6","%v7","32(%r7)"); # restore vperm operands - -for (0..3) { # blocks 2,3 - vmrlf ("%v0",@v[$_*4+0],@v[$_*4+1]); # ks = serialize(state) - vmrlf ("%v1",@v[$_*4+2],@v[$_*4+3]); - vperm ("%v".($_+ 8),"%v0","%v1","%v6"); - vperm ("%v".($_+12),"%v0","%v1","%v7"); -} - vlm ("%v0","%v7","128($inp)"); # load in - vx ("%v$_","%v$_","%v".($_+8)) for (0..7); # out = in ^ ks - vstm ("%v0","%v7","128($out)"); # store out - - ahi ("%r0",4); - st ("%r0","48+$off($sp)"); # update initial state - - la ($inp,"256($inp)"); - la ($out,"256($out)"); - brctg ("%r1",".Lvx_4x"); - -ALIGN (16); -LABEL (".Lvx_4x_done"); - lghi ("%r1",0xff); - ngr ($len,"%r1"); - jnz (".Lvx_rem"); - -ALIGN (16); -LABEL (".Lvx_done"); - vzero ("%v$_") for (16..31); # wipe ks and key copy - vstm ("%v16","%v17","16+$off($sp)"); - vlm ("%v8","%v15","8($sp)") if ($z); - - la ($sp,"$frame($sp)"); -&{$z? \&lmg:\&lm} ("%r6","%r7","6*$SIZE_T($sp)"); - -if (!$z) { - ld ("%f4","16*$SIZE_T+2*8($sp)"); - ld ("%f6","16*$SIZE_T+3*8($sp)"); - vzero ("%v$_") for (8..15); -} - br ("%r14"); -ALIGN (16); -LABEL (".Lvx_rem"); - lhi ("%r0",64); - - sr ($len,"%r0"); - brc (2,".Lvx_rem_g64"); # cc==2? - - lghi ("%r1",-$stdframe); - - la ($counter,"48+$off($sp)"); # load updated iv - ar ($len,"%r0"); # restore len - - lgr ("%r7",$counter); -&{$z? \&stg:\&st} ("%r14","14*$SIZE_T+$frame($sp)"); - la ($sp,"0(%r1,$sp)"); - - bras ("%r14","_s390x_chacha_novx"); - - la ($sp,"$stdframe($sp)"); -&{$z? \&lg:\&l} ("%r14","14*$SIZE_T+$frame($sp)"); - lgr ($counter,"%r7"); - j (".Lvx_done"); - -ALIGN (16); -LABEL (".Lvx_rem_g64"); - vlrepf ("%v$_",($_*4)."+$off($sp)") for (0..15); # load initial - # state - vl ("%v31","16(%r7)"); - vaf ("%v12","%v12","%v31"); # increment counter - - vlr (@v[$_],"%v$_") for (0..15); # state = initial state - - lhi ("%r6",10); - j (".Loop_vx_rem"); - -ALIGN (16); -LABEL (".Loop_vx_rem"); - VX_ROUND( 0, 4, 8,12); # column round - VX_ROUND( 0, 5,10,15); # diagonal round - brct ("%r6",".Loop_vx_rem"); - - vaf (@v[$_],@v[$_],"%v$_") for (0..15); # state += initial - # state (mod 32) - vlm ("%v6","%v7","32(%r7)"); # load vperm operands - -for (0..3) { # blocks 1,2 - vmrhf ("%v0",@v[$_*4+0],@v[$_*4+1]); # ks = serialize(state) - vmrhf ("%v1",@v[$_*4+2],@v[$_*4+3]); - vperm ("%v".($_+8),"%v0","%v1","%v6"); - vperm ("%v".($_+12),"%v0","%v1","%v7"); -} - vlm ("%v0","%v3","0($inp)"); # load in - vx ("%v$_","%v$_","%v".($_+8)) for (0..3); # out = in ^ ks - vstm ("%v0","%v3","0($out)"); # store out - - la ($inp,"64($inp)"); - la ($out,"64($out)"); - - sr ($len,"%r0"); - brc (4,".Lvx_tail"); # cc==4? - - vlm ("%v0","%v3","0($inp)"); # load in - vx ("%v$_","%v$_","%v".($_+12)) for (0..3); # out = in ^ ks - vstm ("%v0","%v3","0($out)"); # store out - jz (".Lvx_done"); - -for (0..3) { # blocks 3,4 - vmrlf ("%v0",@v[$_*4+0],@v[$_*4+1]); # ks = serialize(state) - vmrlf ("%v1",@v[$_*4+2],@v[$_*4+3]); - vperm ("%v".($_+12),"%v0","%v1","%v6"); - vperm ("%v".($_+8),"%v0","%v1","%v7"); -} - la ($inp,"64($inp)"); - la ($out,"64($out)"); - - sr ($len,"%r0"); - brc (4,".Lvx_tail"); # cc==4? - - vlm ("%v0","%v3","0($inp)"); # load in - vx ("%v$_","%v$_","%v".($_+12)) for (0..3); # out = in ^ ks - vstm ("%v0","%v3","0($out)"); # store out - jz (".Lvx_done"); - - la ($inp,"64($inp)"); - la ($out,"64($out)"); - - sr ($len,"%r0"); - vlr ("%v".($_+4),"%v$_") for (8..11); - j (".Lvx_tail"); - -ALIGN (16); -LABEL (".Lvx_tail"); - ar ($len,"%r0"); # restore $len - ahi ($len,-1); - - lhi ("%r0",16); -for (0..2) { - vll ("%v0",$len,($_*16)."($inp)"); - vx ("%v0","%v0","%v".($_+12)); - vstl ("%v0",$len,($_*16)."($out)"); - sr ($len,"%r0"); - brc (4,".Lvx_done"); # cc==4? -} - vll ("%v0",$len,"3*16($inp)"); - vx ("%v0","%v0","%v15"); - vstl ("%v0",$len,"3*16($out)"); - j (".Lvx_done"); -SIZE ("ChaCha20_ctr32",".-ChaCha20_ctr32"); -} - -# NOVX CODE PATH -{ -my $frame=$stdframe+4*20; - -TYPE ("_s390x_chacha_novx","\@function"); -ALIGN (32); -LABEL ("_s390x_chacha_novx"); -&{$z? \<gr:\<r} ($len,$len); # $len==0? +&{$z? \<gr:\<r} ($len,$len); # len==0? bzr ("%r14"); + lg ("%r1","S390X_STFLE+16(%r1)"); +&{$z? \&clgr:\&clr} ($len,"%r0"); + jle (".Lshort"); + + tmhh ("%r1",0x4000); # check for vx bit + jnz (".LChaCha20_ctr32_vx"); + +LABEL (".Lshort"); &{$z? \&aghi:\&ahi} ($len,-64); &{$z? \&lghi:\&lhi} ("%r1",-$frame); &{$z? \&stmg:\&stm} ("%r6","%r15","6*$SIZE_T($sp)"); @@ -607,17 +427,629 @@ LABEL (".Loop_tail"); brct (@t[1],".Loop_tail"); j (".Ldone"); -SIZE ("_s390x_chacha_novx",".-_s390x_chacha_novx"); +SIZE ("ChaCha20_ctr32",".-ChaCha20_ctr32"); } + +######################################################################## +# 4x"vertical" layout minimizes amount of instructions, but pipeline +# runs underutilized [because of vector instructions' high latency]. +# On the other hand minimum amount of data it takes to fully utilize +# the pipeline is higher, so that effectively, short inputs would be +# processed slower. Hence this code path targeting <=256 bytes lengths. +# +{ +my ($xa0,$xa1,$xa2,$xa3, $xb0,$xb1,$xb2,$xb3, + $xc0,$xc1,$xc2,$xc3, $xd0,$xd1,$xd2,$xd3)=map("%v$_",(0..15)); +my @K=map("%v$_",(16..19)); +my $CTR="%v26"; +my ($xt0,$xt1,$xt2,$xt3)=map("%v$_",(27..30)); +my $beperm="%v31"; +my ($x00,$x10,$x20,$x30)=(0,map("r$_",(8..10))); +my $FRAME=$stdframe+4*16; + +ALIGN (32); +LABEL ("ChaCha20_ctr32_4x"); +LABEL (".LChaCha20_ctr32_4x"); +&{$z? \&stmg:\&stm} ("%r6","%r7","6*$SIZE_T($sp)"); +if (!$z) { + std ("%f4","16*$SIZE_T+2*8($sp)"); + std ("%f6","16*$SIZE_T+3*8($sp)"); +} +&{$z? \&lghi:\&lhi} ("%r1",-$FRAME); + lgr ("%r0",$sp); + la ($sp,"0(%r1,$sp)"); +&{$z? \&stg:\&st} ("%r0","0($sp)"); # back-chain +if ($z) { + std ("%f8","$stdframe+8*0($sp)"); + std ("%f9","$stdframe+8*1($sp)"); + std ("%f10","$stdframe+8*2($sp)"); + std ("%f11","$stdframe+8*3($sp)"); + std ("%f12","$stdframe+8*4($sp)"); + std ("%f13","$stdframe+8*5($sp)"); + std ("%f14","$stdframe+8*6($sp)"); + std ("%f15","$stdframe+8*7($sp)"); +} + larl ("%r7",".Lsigma"); + lhi ("%r0",10); + lhi ("%r1",0); + + vl (@K[0],"0(%r7)"); # load sigma + vl (@K[1],"0($key)"); # load key + vl (@K[2],"16($key)"); + vl (@K[3],"0($counter)"); # load counter + + vl ($beperm,"0x40(%r7)"); + vl ($xt1,"0x50(%r7)"); + vrepf ($CTR,@K[3],0); + vlvgf (@K[3],"%r1",0); # clear @K[3].word[0] + vaf ($CTR,$CTR,$xt1); + +#LABEL (".Loop_outer_4x"); + vlm ($xa0,$xa3,"0x60(%r7)"); # load [smashed] sigma + + vrepf ($xb0,@K[1],0); # smash the key + vrepf ($xb1,@K[1],1); + vrepf ($xb2,@K[1],2); + vrepf ($xb3,@K[1],3); + + vrepf ($xc0,@K[2],0); + vrepf ($xc1,@K[2],1); + vrepf ($xc2,@K[2],2); + vrepf ($xc3,@K[2],3); + + vlr ($xd0,$CTR); + vrepf ($xd1,@K[3],1); + vrepf ($xd2,@K[3],2); + vrepf ($xd3,@K[3],3); + +LABEL (".Loop_4x"); + VX_lane_ROUND(0, 4, 8,12); + VX_lane_ROUND(0, 5,10,15); + brct ("%r0",".Loop_4x"); + + vaf ($xd0,$xd0,$CTR); + + vmrhf ($xt0,$xa0,$xa1); # transpose data + vmrhf ($xt1,$xa2,$xa3); + vmrlf ($xt2,$xa0,$xa1); + vmrlf ($xt3,$xa2,$xa3); + vpdi ($xa0,$xt0,$xt1,0b0000); + vpdi ($xa1,$xt0,$xt1,0b0101); + vpdi ($xa2,$xt2,$xt3,0b0000); + vpdi ($xa3,$xt2,$xt3,0b0101); + + vmrhf ($xt0,$xb0,$xb1); + vmrhf ($xt1,$xb2,$xb3); + vmrlf ($xt2,$xb0,$xb1); + vmrlf ($xt3,$xb2,$xb3); + vpdi ($xb0,$xt0,$xt1,0b0000); + vpdi ($xb1,$xt0,$xt1,0b0101); + vpdi ($xb2,$xt2,$xt3,0b0000); + vpdi ($xb3,$xt2,$xt3,0b0101); + + vmrhf ($xt0,$xc0,$xc1); + vmrhf ($xt1,$xc2,$xc3); + vmrlf ($xt2,$xc0,$xc1); + vmrlf ($xt3,$xc2,$xc3); + vpdi ($xc0,$xt0,$xt1,0b0000); + vpdi ($xc1,$xt0,$xt1,0b0101); + vpdi ($xc2,$xt2,$xt3,0b0000); + vpdi ($xc3,$xt2,$xt3,0b0101); + + vmrhf ($xt0,$xd0,$xd1); + vmrhf ($xt1,$xd2,$xd3); + vmrlf ($xt2,$xd0,$xd1); + vmrlf ($xt3,$xd2,$xd3); + vpdi ($xd0,$xt0,$xt1,0b0000); + vpdi ($xd1,$xt0,$xt1,0b0101); + vpdi ($xd2,$xt2,$xt3,0b0000); + vpdi ($xd3,$xt2,$xt3,0b0101); + + #vrepif ($xt0,4); + #vaf ($CTR,$CTR,$xt0); # next counter value + + vaf ($xa0,$xa0,@K[0]); + vaf ($xb0,$xb0,@K[1]); + vaf ($xc0,$xc0,@K[2]); + vaf ($xd0,$xd0,@K[3]); + + vperm ($xa0,$xa0,$xa0,$beperm); + vperm ($xb0,$xb0,$xb0,$beperm); + vperm ($xc0,$xc0,$xc0,$beperm); + vperm ($xd0,$xd0,$xd0,$beperm); + + #&{$z? \&clgfi:\&clfi} ($len,0x40); + #jl (".Ltail_4x"); + + vlm ($xt0,$xt3,"0($inp)"); + + vx ($xt0,$xt0,$xa0); + vx ($xt1,$xt1,$xb0); + vx ($xt2,$xt2,$xc0); + vx ($xt3,$xt3,$xd0); + + vstm ($xt0,$xt3,"0($out)"); + + la ($inp,"0x40($inp)"); + la ($out,"0x40($out)"); +&{$z? \&aghi:\&ahi} ($len,-0x40); + #je (".Ldone_4x"); + + vaf ($xa0,$xa1,@K[0]); + vaf ($xb0,$xb1,@K[1]); + vaf ($xc0,$xc1,@K[2]); + vaf ($xd0,$xd1,@K[3]); + + vperm ($xa0,$xa0,$xa0,$beperm); + vperm ($xb0,$xb0,$xb0,$beperm); + vperm ($xc0,$xc0,$xc0,$beperm); + vperm ($xd0,$xd0,$xd0,$beperm); + +&{$z? \&clgfi:\&clfi} ($len,0x40); + jl (".Ltail_4x"); + + vlm ($xt0,$xt3,"0($inp)"); + + vx ($xt0,$xt0,$xa0); + vx ($xt1,$xt1,$xb0); + vx ($xt2,$xt2,$xc0); + vx ($xt3,$xt3,$xd0); + + vstm ($xt0,$xt3,"0($out)"); + + la ($inp,"0x40($inp)"); + la ($out,"0x40($out)"); +&{$z? \&aghi:\&ahi} ($len,-0x40); + je (".Ldone_4x"); + + vaf ($xa0,$xa2,@K[0]); + vaf ($xb0,$xb2,@K[1]); + vaf ($xc0,$xc2,@K[2]); + vaf ($xd0,$xd2,@K[3]); + + vperm ($xa0,$xa0,$xa0,$beperm); + vperm ($xb0,$xb0,$xb0,$beperm); + vperm ($xc0,$xc0,$xc0,$beperm); + vperm ($xd0,$xd0,$xd0,$beperm); + +&{$z? \&clgfi:\&clfi} ($len,0x40); + jl (".Ltail_4x"); + + vlm ($xt0,$xt3,"0($inp)"); + + vx ($xt0,$xt0,$xa0); + vx ($xt1,$xt1,$xb0); + vx ($xt2,$xt2,$xc0); + vx ($xt3,$xt3,$xd0); + + vstm ($xt0,$xt3,"0($out)"); + + la ($inp,"0x40($inp)"); + la ($out,"0x40($out)"); +&{$z? \&aghi:\&ahi} ($len,-0x40); + je (".Ldone_4x"); + + vaf ($xa0,$xa3,@K[0]); + vaf ($xb0,$xb3,@K[1]); + vaf ($xc0,$xc3,@K[2]); + vaf ($xd0,$xd3,@K[3]); + + vperm ($xa0,$xa0,$xa0,$beperm); + vperm ($xb0,$xb0,$xb0,$beperm); + vperm ($xc0,$xc0,$xc0,$beperm); + vperm ($xd0,$xd0,$xd0,$beperm); + +&{$z? \&clgfi:\&clfi} ($len,0x40); + jl (".Ltail_4x"); + + vlm ($xt0,$xt3,"0($inp)"); + + vx ($xt0,$xt0,$xa0); + vx ($xt1,$xt1,$xb0); + vx ($xt2,$xt2,$xc0); + vx ($xt3,$xt3,$xd0); + + vstm ($xt0,$xt3,"0($out)"); + + #la $inp,0x40($inp)); + #la $out,0x40($out)); + #lhi %r0,10); + #&{$z? \&aghi:\&ahi} $len,-0x40); + #jne .Loop_outer_4x); + +LABEL (".Ldone_4x"); +if (!$z) { + ld ("%f4","$FRAME+16*$SIZE_T+2*8($sp)"); + ld ("%f6","$FRAME+16*$SIZE_T+3*8($sp)"); +} else { + ld ("%f8","$stdframe+8*0($sp)"); + ld ("%f9","$stdframe+8*1($sp)"); + ld ("%f10","$stdframe+8*2($sp)"); + ld ("%f11","$stdframe+8*3($sp)"); + ld ("%f12","$stdframe+8*4($sp)"); + ld ("%f13","$stdframe+8*5($sp)"); + ld ("%f14","$stdframe+8*6($sp)"); + ld ("%f15","$stdframe+8*7($sp)"); +} +&{$z? \&lmg:\&lm} ("%r6","%r7","$FRAME+6*$SIZE_T($sp)"); + la ($sp,"$FRAME($sp)"); + br ("%r14"); + +ALIGN (16); +LABEL (".Ltail_4x"); +if (!$z) { + vlr ($xt0,$xb0); + ld ("%f4","$FRAME+16*$SIZE_T+2*8($sp)"); + ld ("%f6","$FRAME+16*$SIZE_T+3*8($sp)"); + + vst ($xa0,"$stdframe+0x00($sp)"); + vst ($xt0,"$stdframe+0x10($sp)"); + vst ($xc0,"$stdframe+0x20($sp)"); + vst ($xd0,"$stdframe+0x30($sp)"); +} else { + vlr ($xt0,$xc0); + ld ("%f8","$stdframe+8*0($sp)"); + ld ("%f9","$stdframe+8*1($sp)"); + ld ("%f10","$stdframe+8*2($sp)"); + ld ("%f11","$stdframe+8*3($sp)"); + vlr ($xt1,$xd0); + ld ("%f12","$stdframe+8*4($sp)"); + ld ("%f13","$stdframe+8*5($sp)"); + ld ("%f14","$stdframe+8*6($sp)"); + ld ("%f15","$stdframe+8*7($sp)"); + + vst ($xa0,"$stdframe+0x00($sp)"); + vst ($xb0,"$stdframe+0x10($sp)"); + vst ($xt0,"$stdframe+0x20($sp)"); + vst ($xt1,"$stdframe+0x30($sp)"); +} + lghi ("%r1",0); + +LABEL (".Loop_tail_4x"); + llgc ("%r5","0(%r1,$inp)"); + llgc ("%r6","$stdframe(%r1,$sp)"); + xr ("%r6","%r5"); + stc ("%r6","0(%r1,$out)"); + la ("%r1","1(%r1)"); + brct ($len,".Loop_tail_4x"); + +&{$z? \&lmg:\&lm} ("%r6","%r7","$FRAME+6*$SIZE_T($sp)"); + la ($sp,"$FRAME($sp)"); + br ("%r14"); +SIZE ("ChaCha20_ctr32_4x",".-ChaCha20_ctr32_4x"); +} + +######################################################################## +# 6x"horizontal" layout is optimal fit for the platform in its current +# shape, more specifically for given vector instructions' latency. Well, +# computational part of 8x"vertical" would be faster, but it consumes +# all registers and dealing with that will diminish the return... +# +{ +my ($a0,$b0,$c0,$d0, $a1,$b1,$c1,$d1, + $a2,$b2,$c2,$d2, $a3,$b3,$c3,$d3, + $a4,$b4,$c4,$d4, $a5,$b5,$c5,$d5)=map("%v$_",(0..23)); +my @K=map("%v$_",(27,24..26)); +my ($t0,$t1,$t2,$t3)=map("%v$_",27..30); +my $beperm="%v31"; +my $FRAME=$stdframe + 4*16; + +GLOBL ("ChaCha20_ctr32_vx"); +ALIGN (32); +LABEL ("ChaCha20_ctr32_vx"); +LABEL (".LChaCha20_ctr32_vx"); +&{$z? \&clgfi:\&clfi} ($len,256); + jle (".LChaCha20_ctr32_4x"); +&{$z? \&stmg:\&stm} ("%r6","%r7","6*$SIZE_T($sp)"); +if (!$z) { + std ("%f4","16*$SIZE_T+2*8($sp)"); + std ("%f6","16*$SIZE_T+3*8($sp)"); +} +&{$z? \&lghi:\&lhi} ("%r1",-$FRAME); + lgr ("%r0",$sp); + la ($sp,"0(%r1,$sp)"); +&{$z? \&stg:\&st} ("%r0","0($sp)"); # back-chain +if ($z) { + std ("%f8","$FRAME-8*8($sp)"); + std ("%f9","$FRAME-8*7($sp)"); + std ("%f10","$FRAME-8*6($sp)"); + std ("%f11","$FRAME-8*5($sp)"); + std ("%f12","$FRAME-8*4($sp)"); + std ("%f13","$FRAME-8*3($sp)"); + std ("%f14","$FRAME-8*2($sp)"); + std ("%f15","$FRAME-8*1($sp)"); +} + larl ("%r7",".Lsigma"); + lhi ("%r0",10); + + vlm (@K[1],@K[2],"0($key)"); # load key + vl (@K[3],"0($counter)"); # load counter + + vlm (@K[0],"$beperm","0(%r7)"); # load sigma, increments, ... + +LABEL (".Loop_outer_vx"); + vlr ($a0,@K[0]); + vlr ($b0,@K[1]); + vlr ($a1,@K[0]); + vlr ($b1,@K[1]); + vlr ($a2,@K[0]); + vlr ($b2,@K[1]); + vlr ($a3,@K[0]); + vlr ($b3,@K[1]); + vlr ($a4,@K[0]); + vlr ($b4,@K[1]); + vlr ($a5,@K[0]); + vlr ($b5,@K[1]); + + vlr ($d0,@K[3]); + vaf ($d1,@K[3],$t1); # K[3]+1 + vaf ($d2,@K[3],$t2); # K[3]+2 + vaf ($d3,@K[3],$t3); # K[3]+3 + vaf ($d4,$d2,$t2); # K[3]+4 + vaf ($d5,$d2,$t3); # K[3]+5 + + vlr ($c0,@K[2]); + vlr ($c1,@K[2]); + vlr ($c2,@K[2]); + vlr ($c3,@K[2]); + vlr ($c4,@K[2]); + vlr ($c5,@K[2]); + + vlr ($t1,$d1); + vlr ($t2,$d2); + vlr ($t3,$d3); + +ALIGN (4); +LABEL (".Loop_vx"); + + VX_ROUND($a0,$a1,$a2,$a3,$a4,$a5, + $b0,$b1,$b2,$b3,$b4,$b5, + $c0,$c1,$c2,$c3,$c4,$c5, + $d0,$d1,$d2,$d3,$d4,$d5, + 0); + + VX_ROUND($a0,$a1,$a2,$a3,$a4,$a5, + $b0,$b1,$b2,$b3,$b4,$b5, + $c0,$c1,$c2,$c3,$c4,$c5, + $d0,$d1,$d2,$d3,$d4,$d5, + 1); + + brct ("%r0",".Loop_vx"); + + vaf ($a0,$a0,@K[0]); + vaf ($b0,$b0,@K[1]); + vaf ($c0,$c0,@K[2]); + vaf ($d0,$d0,@K[3]); + vaf ($a1,$a1,@K[0]); + vaf ($d1,$d1,$t1); # +K[3]+1 + + vperm ($a0,$a0,$a0,$beperm); + vperm ($b0,$b0,$b0,$beperm); + vperm ($c0,$c0,$c0,$beperm); + vperm ($d0,$d0,$d0,$beperm); + +&{$z? \&clgfi:\&clfi} ($len,0x40); + jl (".Ltail_vx"); + + vaf ($d2,$d2,$t2); # +K[3]+2 + vaf ($d3,$d3,$t3); # +K[3]+3 + vlm ($t0,$t3,"0($inp)"); + + vx ($a0,$a0,$t0); + vx ($b0,$b0,$t1); + vx ($c0,$c0,$t2); + vx ($d0,$d0,$t3); + + vlm (@K[0],$t3,"0(%r7)"); # re-load sigma and increments + + vstm ($a0,$d0,"0($out)"); + + la ($inp,"0x40($inp)"); + la ($out,"0x40($out)"); +&{$z? \&aghi:\&ahi} ($len,-0x40); + je (".Ldone_vx"); + + vaf ($b1,$b1,@K[1]); + vaf ($c1,$c1,@K[2]); + + vperm ($a0,$a1,$a1,$beperm); + vperm ($b0,$b1,$b1,$beperm); + vperm ($c0,$c1,$c1,$beperm); + vperm ($d0,$d1,$d1,$beperm); + +&{$z? \&clgfi:\&clfi} ($len,0x40); + jl (".Ltail_vx"); + + vlm ($a1,$d1,"0($inp)"); + + vx ($a0,$a0,$a1); + vx ($b0,$b0,$b1); + vx ($c0,$c0,$c1); + vx ($d0,$d0,$d1); + + vstm ($a0,$d0,"0($out)"); + + la ($inp,"0x40($inp)"); + la ($out,"0x40($out)"); +&{$z? \&aghi:\&ahi} ($len,-0x40); + je (".Ldone_vx"); + + vaf ($a2,$a2,@K[0]); + vaf ($b2,$b2,@K[1]); + vaf ($c2,$c2,@K[2]); + + vperm ($a0,$a2,$a2,$beperm); + vperm ($b0,$b2,$b2,$beperm); + vperm ($c0,$c2,$c2,$beperm); + vperm ($d0,$d2,$d2,$beperm); + +&{$z? \&clgfi:\&clfi} ($len,0x40); + jl (".Ltail_vx"); + + vlm ($a1,$d1,"0($inp)"); + + vx ($a0,$a0,$a1); + vx ($b0,$b0,$b1); + vx ($c0,$c0,$c1); + vx ($d0,$d0,$d1); + + vstm ($a0,$d0,"0($out)"); + + la ($inp,"0x40($inp)"); + la ($out,"0x40($out)"); +&{$z? \&aghi:\&ahi} ($len,-0x40); + je (".Ldone_vx"); + + vaf ($a3,$a3,@K[0]); + vaf ($b3,$b3,@K[1]); + vaf ($c3,$c3,@K[2]); + vaf ($d2,@K[3],$t3); # K[3]+3 + + vperm ($a0,$a3,$a3,$beperm); + vperm ($b0,$b3,$b3,$beperm); + vperm ($c0,$c3,$c3,$beperm); + vperm ($d0,$d3,$d3,$beperm); + +&{$z? \&clgfi:\&clfi} ($len,0x40); + jl (".Ltail_vx"); + + vaf ($d3,$d2,$t1); # K[3]+4 + vlm ($a1,$d1,"0($inp)"); + + vx ($a0,$a0,$a1); + vx ($b0,$b0,$b1); + vx ($c0,$c0,$c1); + vx ($d0,$d0,$d1); + + vstm ($a0,$d0,"0($out)"); + + la ($inp,"0x40($inp)"); + la ($out,"0x40($out)"); +&{$z? \&aghi:\&ahi} ($len,-0x40); + je (".Ldone_vx"); + + vaf ($a4,$a4,@K[0]); + vaf ($b4,$b4,@K[1]); + vaf ($c4,$c4,@K[2]); + vaf ($d4,$d4,$d3); # +K[3]+4 + vaf ($d3,$d3,$t1); # K[3]+5 + vaf (@K[3],$d2,$t3); # K[3]+=6 + + vperm ($a0,$a4,$a4,$beperm); + vperm ($b0,$b4,$b4,$beperm); + vperm ($c0,$c4,$c4,$beperm); + vperm ($d0,$d4,$d4,$beperm); + +&{$z? \&clgfi:\&clfi} ($len,0x40); + jl (".Ltail_vx"); + + vlm ($a1,$d1,"0($inp)"); + + vx ($a0,$a0,$a1); + vx ($b0,$b0,$b1); + vx ($c0,$c0,$c1); + vx ($d0,$d0,$d1); + + vstm ($a0,$d0,"0($out)"); + + la ($inp,"0x40($inp)"); + la ($out,"0x40($out)"); +&{$z? \&aghi:\&ahi} ($len,-0x40); + je (".Ldone_vx"); + + vaf ($a5,$a5,@K[0]); + vaf ($b5,$b5,@K[1]); + vaf ($c5,$c5,@K[2]); + vaf ($d5,$d5,$d3); # +K[3]+5 + + vperm ($a0,$a5,$a5,$beperm); + vperm ($b0,$b5,$b5,$beperm); + vperm ($c0,$c5,$c5,$beperm); + vperm ($d0,$d5,$d5,$beperm); + +&{$z? \&clgfi:\&clfi} ($len,0x40); + jl (".Ltail_vx"); + + vlm ($a1,$d1,"0($inp)"); + + vx ($a0,$a0,$a1); + vx ($b0,$b0,$b1); + vx ($c0,$c0,$c1); + vx ($d0,$d0,$d1); + + vstm ($a0,$d0,"0($out)"); + + la ($inp,"0x40($inp)"); + la ($out,"0x40($out)"); + lhi ("%r0",10); +&{$z? \&aghi:\&ahi} ($len,-0x40); + jne (".Loop_outer_vx"); + +LABEL (".Ldone_vx"); +if (!$z) { + ld ("%f4","$FRAME+16*$SIZE_T+2*8($sp)"); + ld ("%f6","$FRAME+16*$SIZE_T+3*8($sp)"); +} else { + ld ("%f8","$FRAME-8*8($sp)"); + ld ("%f9","$FRAME-8*7($sp)"); + ld ("%f10","$FRAME-8*6($sp)"); + ld ("%f11","$FRAME-8*5($sp)"); + ld ("%f12","$FRAME-8*4($sp)"); + ld ("%f13","$FRAME-8*3($sp)"); + ld ("%f14","$FRAME-8*2($sp)"); + ld ("%f15","$FRAME-8*1($sp)"); +} +&{$z? \&lmg:\&lm} ("%r6","%r7","$FRAME+6*$SIZE_T($sp)"); + la ($sp,"$FRAME($sp)"); + br ("%r14"); + +ALIGN (16); +LABEL (".Ltail_vx"); +if (!$z) { + ld ("%f4","$FRAME+16*$SIZE_T+2*8($sp)"); + ld ("%f6","$FRAME+16*$SIZE_T+3*8($sp)"); +} else { + ld ("%f8","$FRAME-8*8($sp)"); + ld ("%f9","$FRAME-8*7($sp)"); + ld ("%f10","$FRAME-8*6($sp)"); + ld ("%f11","$FRAME-8*5($sp)"); + ld ("%f12","$FRAME-8*4($sp)"); + ld ("%f13","$FRAME-8*3($sp)"); + ld ("%f14","$FRAME-8*2($sp)"); + ld ("%f15","$FRAME-8*1($sp)"); +} + vstm ($a0,$d0,"$stdframe($sp)"); + lghi ("%r1",0); + +LABEL (".Loop_tail_vx"); + llgc ("%r5","0(%r1,$inp)"); + llgc ("%r6","$stdframe(%r1,$sp)"); + xr ("%r6","%r5"); + stc ("%r6","0(%r1,$out)"); + la ("%r1","1(%r1)"); + brct ($len,".Loop_tail_vx"); + +&{$z? \&lmg:\&lm} ("%r6","%r7","$FRAME+6*$SIZE_T($sp)"); + la ($sp,"$FRAME($sp)"); + br ("%r14"); +SIZE ("ChaCha20_ctr32_vx",".-ChaCha20_ctr32_vx"); } ################ -ALIGN (64); +ALIGN (32); LABEL (".Lsigma"); LONG (0x61707865,0x3320646e,0x79622d32,0x6b206574); # endian-neutral sigma -LONG (0x00000000,0x00000001,0x00000002,0x00000003); # vaf counter increment -LONG (0x03020100,0x07060504,0x13121110,0x17161514); # vperm serialization -LONG (0x0b0a0908,0x0f0e0d0c,0x1b1a1918,0x1f1e1d1c); # vperm serialization +LONG (1,0,0,0); +LONG (2,0,0,0); +LONG (3,0,0,0); +LONG (0x03020100,0x07060504,0x0b0a0908,0x0f0e0d0c); # byte swap + +LONG (0,1,2,3); +LONG (0x61707865,0x61707865,0x61707865,0x61707865); # smashed sigma +LONG (0x3320646e,0x3320646e,0x3320646e,0x3320646e); +LONG (0x79622d32,0x79622d32,0x79622d32,0x79622d32); +LONG (0x6b206574,0x6b206574,0x6b206574,0x6b206574); + ASCIZ ("\"ChaCha20 for s390x, CRYPTOGAMS by \""); ALIGN (4); diff --git a/crypto/cms/cms_cd.c b/crypto/cms/cms_cd.c index 93862730..5a11928e 100644 --- a/crypto/cms/cms_cd.c +++ b/crypto/cms/cms_cd.c @@ -60,7 +60,7 @@ CMS_ContentInfo *cms_CompressedData_create(int comp_nid) return NULL; } -BIO *cms_CompressedData_init_bio(CMS_ContentInfo *cms) +BIO *cms_CompressedData_init_bio(const CMS_ContentInfo *cms) { CMS_CompressedData *cd; const ASN1_OBJECT *compoid; diff --git a/crypto/core_fetch.c b/crypto/core_fetch.c new file mode 100644 index 00000000..d2d77665 --- /dev/null +++ b/crypto/core_fetch.c @@ -0,0 +1,97 @@ +/* + * 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.h" +#include "internal/core.h" +#include "internal/property.h" +#include "internal/provider.h" + +struct construct_data_st { + OPENSSL_CTX *libctx; + OSSL_METHOD_STORE *store; + int operation_id; + int force_store; + OSSL_METHOD_CONSTRUCT_METHOD *mcm; + void *mcm_data; +}; + +static int ossl_method_construct_this(OSSL_PROVIDER *provider, void *cbdata) +{ + struct construct_data_st *data = cbdata; + int no_store = 0; /* Assume caching is ok */ + const OSSL_ALGORITHM *map = + ossl_provider_query_operation(provider, data->operation_id, &no_store); + + while (map->algorithm_name != NULL) { + const OSSL_ALGORITHM *thismap = map++; + void *method = NULL; + + if ((method = data->mcm->construct(thismap->implementation, provider, + data->mcm_data)) == NULL) + continue; + + if (data->force_store || !no_store) { + /* + * If we haven't been told not to store, + * add to the global store + */ + if (!data->mcm->put(data->libctx, NULL, + thismap->property_definition, + method, data->mcm_data)) { + data->mcm->destruct(method); + continue; + } + } + + if (!data->mcm->put(data->libctx, data->store, + thismap->property_definition, + method, data->mcm_data)) { + data->mcm->destruct(method); + continue; + } + } + + return 1; +} + +void *ossl_method_construct(OPENSSL_CTX *libctx, int operation_id, + const char *name, const char *propquery, + int force_store, + OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data) +{ + void *method = NULL; + + if ((method = mcm->get(libctx, NULL, propquery, mcm_data)) == NULL) { + struct construct_data_st cbdata; + + /* + * We have a temporary store to be able to easily search among new + * items, or items that should find themselves in the global store. + */ + if ((cbdata.store = mcm->alloc_tmp_store()) == NULL) + goto fin; + + cbdata.libctx = libctx; + cbdata.operation_id = operation_id; + cbdata.force_store = force_store; + cbdata.mcm = mcm; + cbdata.mcm_data = mcm_data; + ossl_provider_forall_loaded(libctx, ossl_method_construct_this, + &cbdata); + + method = mcm->get(libctx, cbdata.store, propquery, mcm_data); + mcm->dealloc_tmp_store(cbdata.store); + } + + fin: + return method; +} diff --git a/crypto/cpt_err.c b/crypto/cpt_err.c index 8c11da88..bf7985ce 100644 --- a/crypto/cpt_err.c +++ b/crypto/cpt_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 @@ -32,6 +32,8 @@ static const ERR_STRING_DATA CRYPTO_str_functs[] = { "CRYPTO_set_ex_data"}, {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_FIPS_MODE_SET, 0), "FIPS_mode_set"}, {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_GET_AND_LOCK, 0), "get_and_lock"}, + {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_GET_PROVIDER_STORE, 0), + "get_provider_store"}, {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OPENSSL_ATEXIT, 0), "OPENSSL_atexit"}, {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OPENSSL_BUF2HEXSTR, 0), "OPENSSL_buf2hexstr"}, @@ -44,6 +46,12 @@ static const ERR_STRING_DATA CRYPTO_str_functs[] = { {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OPENSSL_SK_DEEP_COPY, 0), "OPENSSL_sk_deep_copy"}, {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OPENSSL_SK_DUP, 0), "OPENSSL_sk_dup"}, + {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OSSL_PROVIDER_ADD_BUILTIN, 0), + "OSSL_PROVIDER_add_builtin"}, + {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OSSL_PROVIDER_ACTIVATE, 0), + "ossl_provider_activate"}, + {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OSSL_PROVIDER_NEW, 0), + "ossl_provider_new"}, {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_PKEY_HMAC_INIT, 0), "pkey_hmac_init"}, {ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_PKEY_POLY1305_INIT, 0), "pkey_poly1305_init"}, @@ -60,6 +68,8 @@ static const ERR_STRING_DATA CRYPTO_str_reasons[] = { "illegal hex digit"}, {ERR_PACK(ERR_LIB_CRYPTO, 0, CRYPTO_R_ODD_NUMBER_OF_DIGITS), "odd number of digits"}, + {ERR_PACK(ERR_LIB_CRYPTO, 0, CRYPTO_R_PROVIDER_ALREADY_EXISTS), + "provider already exists"}, {0, NULL} }; diff --git a/crypto/crmf/build.info b/crypto/crmf/build.info new file mode 100644 index 00000000..7cfa8ec2 --- /dev/null +++ b/crypto/crmf/build.info @@ -0,0 +1,2 @@ +LIBS=../../libcrypto +SOURCE[../../libcrypto]=crmf_asn.c crmf_err.c crmf_lib.c crmf_pbm.c diff --git a/crypto/crmf/crmf_asn.c b/crypto/crmf/crmf_asn.c new file mode 100644 index 00000000..d0ab6e95 --- /dev/null +++ b/crypto/crmf/crmf_asn.c @@ -0,0 +1,240 @@ +/*- + * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2018 + * Copyright Siemens AG 2015-2018 + * + * Licensed under the OpenSSL license (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 + * + * CRMF implementation by Martin Peylo, Miikka Viljanen, and David von Oheimb. + */ + +#include + +#include "crmf_int.h" + +/* explicit #includes not strictly needed since implied by the above: */ +#include + +ASN1_SEQUENCE(OSSL_CRMF_PRIVATEKEYINFO) = { + ASN1_SIMPLE(OSSL_CRMF_PRIVATEKEYINFO, version, ASN1_INTEGER), + ASN1_SIMPLE(OSSL_CRMF_PRIVATEKEYINFO, privateKeyAlgorithm, X509_ALGOR), + ASN1_SIMPLE(OSSL_CRMF_PRIVATEKEYINFO, privateKey, ASN1_OCTET_STRING), + ASN1_IMP_SET_OF_OPT(OSSL_CRMF_PRIVATEKEYINFO, attributes, X509_ATTRIBUTE, 0) +} ASN1_SEQUENCE_END(OSSL_CRMF_PRIVATEKEYINFO) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_PRIVATEKEYINFO) + + +ASN1_CHOICE(OSSL_CRMF_ENCKEYWITHID_IDENTIFIER) = { + ASN1_SIMPLE(OSSL_CRMF_ENCKEYWITHID_IDENTIFIER, value.string, ASN1_UTF8STRING), + ASN1_SIMPLE(OSSL_CRMF_ENCKEYWITHID_IDENTIFIER, value.generalName, GENERAL_NAME) +} ASN1_CHOICE_END(OSSL_CRMF_ENCKEYWITHID_IDENTIFIER) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_ENCKEYWITHID_IDENTIFIER) + + +ASN1_SEQUENCE(OSSL_CRMF_ENCKEYWITHID) = { + ASN1_SIMPLE(OSSL_CRMF_ENCKEYWITHID, privateKey, OSSL_CRMF_PRIVATEKEYINFO), + ASN1_OPT(OSSL_CRMF_ENCKEYWITHID, identifier, + OSSL_CRMF_ENCKEYWITHID_IDENTIFIER) +} ASN1_SEQUENCE_END(OSSL_CRMF_ENCKEYWITHID) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_ENCKEYWITHID) + + +ASN1_SEQUENCE(OSSL_CRMF_CERTID) = { + ASN1_SIMPLE(OSSL_CRMF_CERTID, issuer, GENERAL_NAME), + ASN1_SIMPLE(OSSL_CRMF_CERTID, serialNumber, ASN1_INTEGER) +} ASN1_SEQUENCE_END(OSSL_CRMF_CERTID) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_CERTID) +IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTID) + + +ASN1_SEQUENCE(OSSL_CRMF_ENCRYPTEDVALUE) = { + ASN1_IMP_OPT(OSSL_CRMF_ENCRYPTEDVALUE, intendedAlg, X509_ALGOR, 0), + ASN1_IMP_OPT(OSSL_CRMF_ENCRYPTEDVALUE, symmAlg, X509_ALGOR, 1), + ASN1_IMP_OPT(OSSL_CRMF_ENCRYPTEDVALUE, encSymmKey, ASN1_BIT_STRING, 2), + ASN1_IMP_OPT(OSSL_CRMF_ENCRYPTEDVALUE, keyAlg, X509_ALGOR, 3), + ASN1_IMP_OPT(OSSL_CRMF_ENCRYPTEDVALUE, valueHint, ASN1_OCTET_STRING, 4), + ASN1_SIMPLE(OSSL_CRMF_ENCRYPTEDVALUE, encValue, ASN1_BIT_STRING) +} ASN1_SEQUENCE_END(OSSL_CRMF_ENCRYPTEDVALUE) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_ENCRYPTEDVALUE) + +ASN1_SEQUENCE(OSSL_CRMF_SINGLEPUBINFO) = { + ASN1_SIMPLE(OSSL_CRMF_SINGLEPUBINFO, pubMethod, ASN1_INTEGER), + ASN1_SIMPLE(OSSL_CRMF_SINGLEPUBINFO, pubLocation, GENERAL_NAME) +} ASN1_SEQUENCE_END(OSSL_CRMF_SINGLEPUBINFO) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_SINGLEPUBINFO) + + +ASN1_SEQUENCE(OSSL_CRMF_PKIPUBLICATIONINFO) = { + ASN1_SIMPLE(OSSL_CRMF_PKIPUBLICATIONINFO, action, ASN1_INTEGER), + ASN1_SEQUENCE_OF_OPT(OSSL_CRMF_PKIPUBLICATIONINFO, pubInfos, + OSSL_CRMF_SINGLEPUBINFO) +} ASN1_SEQUENCE_END(OSSL_CRMF_PKIPUBLICATIONINFO) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_PKIPUBLICATIONINFO) +IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CRMF_PKIPUBLICATIONINFO) + + +ASN1_SEQUENCE(OSSL_CRMF_PKMACVALUE) = { + ASN1_SIMPLE(OSSL_CRMF_PKMACVALUE, algId, X509_ALGOR), + ASN1_SIMPLE(OSSL_CRMF_PKMACVALUE, value, ASN1_BIT_STRING) +} ASN1_SEQUENCE_END(OSSL_CRMF_PKMACVALUE) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_PKMACVALUE) + + +ASN1_CHOICE(OSSL_CRMF_POPOPRIVKEY) = { + ASN1_IMP(OSSL_CRMF_POPOPRIVKEY, value.thisMessage, ASN1_BIT_STRING, 0), + ASN1_IMP(OSSL_CRMF_POPOPRIVKEY, value.subsequentMessage, ASN1_INTEGER, 1), + ASN1_IMP(OSSL_CRMF_POPOPRIVKEY, value.dhMAC, ASN1_BIT_STRING, 2), + ASN1_IMP(OSSL_CRMF_POPOPRIVKEY, value.agreeMAC, OSSL_CRMF_PKMACVALUE, 3), + /* + * TODO: This is not ASN1_NULL but CMS_ENVELOPEDDATA which should be somehow + * taken from crypto/cms which exists now - this is not used anywhere so far + */ + ASN1_IMP(OSSL_CRMF_POPOPRIVKEY, value.encryptedKey, ASN1_NULL, 4), +} ASN1_CHOICE_END(OSSL_CRMF_POPOPRIVKEY) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPOPRIVKEY) + + +ASN1_SEQUENCE(OSSL_CRMF_PBMPARAMETER) = { + ASN1_SIMPLE(OSSL_CRMF_PBMPARAMETER, salt, ASN1_OCTET_STRING), + ASN1_SIMPLE(OSSL_CRMF_PBMPARAMETER, owf, X509_ALGOR), + ASN1_SIMPLE(OSSL_CRMF_PBMPARAMETER, iterationCount, ASN1_INTEGER), + ASN1_SIMPLE(OSSL_CRMF_PBMPARAMETER, mac, X509_ALGOR) +} ASN1_SEQUENCE_END(OSSL_CRMF_PBMPARAMETER) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_PBMPARAMETER) + + +ASN1_CHOICE(OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO) = { + ASN1_EXP(OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO, value.sender, + GENERAL_NAME, 0), + ASN1_SIMPLE(OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO, value.publicKeyMAC, + OSSL_CRMF_PKMACVALUE) +} ASN1_CHOICE_END(OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO) + + +ASN1_SEQUENCE(OSSL_CRMF_POPOSIGNINGKEYINPUT) = { + ASN1_SIMPLE(OSSL_CRMF_POPOSIGNINGKEYINPUT, authInfo, + OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO), + ASN1_SIMPLE(OSSL_CRMF_POPOSIGNINGKEYINPUT, publicKey, X509_PUBKEY) +} ASN1_SEQUENCE_END(OSSL_CRMF_POPOSIGNINGKEYINPUT) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEYINPUT) + + +ASN1_SEQUENCE(OSSL_CRMF_POPOSIGNINGKEY) = { + ASN1_IMP_OPT(OSSL_CRMF_POPOSIGNINGKEY, poposkInput, + OSSL_CRMF_POPOSIGNINGKEYINPUT, 0), + ASN1_SIMPLE(OSSL_CRMF_POPOSIGNINGKEY, algorithmIdentifier, X509_ALGOR), + ASN1_SIMPLE(OSSL_CRMF_POPOSIGNINGKEY, signature, ASN1_BIT_STRING) +} ASN1_SEQUENCE_END(OSSL_CRMF_POPOSIGNINGKEY) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEY) + + +ASN1_CHOICE(OSSL_CRMF_POPO) = { + ASN1_IMP(OSSL_CRMF_POPO, value.raVerified, ASN1_NULL, 0), + ASN1_IMP(OSSL_CRMF_POPO, value.signature, OSSL_CRMF_POPOSIGNINGKEY, 1), + ASN1_EXP(OSSL_CRMF_POPO, value.keyEncipherment, OSSL_CRMF_POPOPRIVKEY, 2), + ASN1_EXP(OSSL_CRMF_POPO, value.keyAgreement, OSSL_CRMF_POPOPRIVKEY, 3) +} ASN1_CHOICE_END(OSSL_CRMF_POPO) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_POPO) + + +ASN1_ADB_TEMPLATE(attributetypeandvalue_default) = ASN1_OPT( + OSSL_CRMF_ATTRIBUTETYPEANDVALUE, value.other, ASN1_ANY); +ASN1_ADB(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) = { + ADB_ENTRY(NID_id_regCtrl_regToken, + ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, + value.regToken, ASN1_UTF8STRING)), + ADB_ENTRY(NID_id_regCtrl_authenticator, + ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, + value.authenticator, ASN1_UTF8STRING)), + ADB_ENTRY(NID_id_regCtrl_pkiPublicationInfo, + ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, + value.pkiPublicationInfo, + OSSL_CRMF_PKIPUBLICATIONINFO)), + ADB_ENTRY(NID_id_regCtrl_oldCertID, + ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, + value.oldCertID, OSSL_CRMF_CERTID)), + ADB_ENTRY(NID_id_regCtrl_protocolEncrKey, + ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, + value.protocolEncrKey, X509_PUBKEY)), + ADB_ENTRY(NID_id_regInfo_utf8Pairs, + ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, + value.utf8Pairs, ASN1_UTF8STRING)), + ADB_ENTRY(NID_id_regInfo_certReq, + ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, + value.certReq, OSSL_CRMF_CERTREQUEST)), +} ASN1_ADB_END(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, 0, type, 0, + &attributetypeandvalue_default_tt, NULL); + + +ASN1_SEQUENCE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) = { + ASN1_SIMPLE(OSSL_CRMF_ATTRIBUTETYPEANDVALUE, type, ASN1_OBJECT), + ASN1_ADB_OBJECT(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) +} ASN1_SEQUENCE_END(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) + +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) +IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) + + +ASN1_SEQUENCE(OSSL_CRMF_OPTIONALVALIDITY) = { + ASN1_EXP_OPT(OSSL_CRMF_OPTIONALVALIDITY, notBefore, ASN1_TIME, 0), + ASN1_EXP_OPT(OSSL_CRMF_OPTIONALVALIDITY, notAfter, ASN1_TIME, 1) +} ASN1_SEQUENCE_END(OSSL_CRMF_OPTIONALVALIDITY) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_OPTIONALVALIDITY) + + +ASN1_SEQUENCE(OSSL_CRMF_CERTTEMPLATE) = { + ASN1_IMP_OPT(OSSL_CRMF_CERTTEMPLATE, version, ASN1_INTEGER, 0), + /* + * serialNumber MUST be omitted. This field is assigned by the CA + * during certificate creation. + */ + ASN1_IMP_OPT(OSSL_CRMF_CERTTEMPLATE, serialNumber, ASN1_INTEGER, 1), + /* + * signingAlg MUST be omitted. This field is assigned by the CA + * during certificate creation. + */ + ASN1_IMP_OPT(OSSL_CRMF_CERTTEMPLATE, signingAlg, X509_ALGOR, 2), + ASN1_EXP_OPT(OSSL_CRMF_CERTTEMPLATE, issuer, X509_NAME, 3), + ASN1_IMP_OPT(OSSL_CRMF_CERTTEMPLATE, validity, + OSSL_CRMF_OPTIONALVALIDITY, 4), + ASN1_EXP_OPT(OSSL_CRMF_CERTTEMPLATE, subject, X509_NAME, 5), + ASN1_IMP_OPT(OSSL_CRMF_CERTTEMPLATE, publicKey, X509_PUBKEY, 6), + /* issuerUID is deprecated in version 2 */ + ASN1_IMP_OPT(OSSL_CRMF_CERTTEMPLATE, issuerUID, ASN1_BIT_STRING, 7), + /* subjectUID is deprecated in version 2 */ + ASN1_IMP_OPT(OSSL_CRMF_CERTTEMPLATE, subjectUID, ASN1_BIT_STRING, 8), + ASN1_IMP_SEQUENCE_OF_OPT(OSSL_CRMF_CERTTEMPLATE, extensions, + X509_EXTENSION, 9), +} ASN1_SEQUENCE_END(OSSL_CRMF_CERTTEMPLATE) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_CERTTEMPLATE) + + +ASN1_SEQUENCE(OSSL_CRMF_CERTREQUEST) = { + ASN1_SIMPLE(OSSL_CRMF_CERTREQUEST, certReqId, ASN1_INTEGER), + ASN1_SIMPLE(OSSL_CRMF_CERTREQUEST, certTemplate, OSSL_CRMF_CERTTEMPLATE), + ASN1_SEQUENCE_OF_OPT(OSSL_CRMF_CERTREQUEST, controls, + OSSL_CRMF_ATTRIBUTETYPEANDVALUE) +} ASN1_SEQUENCE_END(OSSL_CRMF_CERTREQUEST) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_CERTREQUEST) +IMPLEMENT_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTREQUEST) + + +ASN1_SEQUENCE(OSSL_CRMF_MSG) = { + ASN1_SIMPLE(OSSL_CRMF_MSG, certReq, OSSL_CRMF_CERTREQUEST), + ASN1_OPT(OSSL_CRMF_MSG, popo, OSSL_CRMF_POPO), + ASN1_SEQUENCE_OF_OPT(OSSL_CRMF_MSG, regInfo, + OSSL_CRMF_ATTRIBUTETYPEANDVALUE) +} ASN1_SEQUENCE_END(OSSL_CRMF_MSG) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_MSG) + + +ASN1_ITEM_TEMPLATE(OSSL_CRMF_MSGS) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, + OSSL_CRMF_MSGS, OSSL_CRMF_MSG) + ASN1_ITEM_TEMPLATE_END(OSSL_CRMF_MSGS) +IMPLEMENT_ASN1_FUNCTIONS(OSSL_CRMF_MSGS) + diff --git a/crypto/crmf/crmf_err.c b/crypto/crmf/crmf_err.c new file mode 100644 index 00000000..f3405b11 --- /dev/null +++ b/crypto/crmf/crmf_err.c @@ -0,0 +1,104 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (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 CRMF_str_functs[] = { + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_CRMF_POPOSIGNINGKEY_INIT, 0), + "CRMF_poposigningkey_init"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_CERTID_GEN, 0), + "OSSL_CRMF_CERTID_gen"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_CERTTEMPLATE_FILL, 0), + "OSSL_CRMF_CERTTEMPLATE_fill"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT, 0), + "OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSGS_VERIFY_POPO, 0), + "OSSL_CRMF_MSGS_verify_popo"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_CREATE_POPO, 0), + "OSSL_CRMF_MSG_create_popo"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_GET0_TMPL, 0), + "OSSL_CRMF_MSG_get0_tmpl"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_GET_CERTREQID, 0), + "OSSL_CRMF_MSG_get_certReqId"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_PKIPUBLICATIONINFO_PUSH0_SINGLEPUBINFO, 0), + "OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_PUSH0_EXTENSION, 0), + "OSSL_CRMF_MSG_push0_extension"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_PUSH0_REGCTRL, 0), + "OSSL_CRMF_MSG_push0_regCtrl"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_PUSH0_REGINFO, 0), + "OSSL_CRMF_MSG_push0_regInfo"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_SET0_EXTENSIONS, 0), + "OSSL_CRMF_MSG_set0_extensions"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_SET0_SINGLEPUBINFO, 0), + "OSSL_CRMF_MSG_set0_SinglePubInfo"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_SET_CERTREQID, 0), + "OSSL_CRMF_MSG_set_certReqId"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_SET_PKIPUBLICATIONINFO_ACTION, 0), + "OSSL_CRMF_MSG_set_PKIPublicationInfo_action"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_MSG_SET_VALIDITY, 0), + "OSSL_CRMF_MSG_set_validity"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_PBMP_NEW, 0), + "OSSL_CRMF_pbmp_new"}, + {ERR_PACK(ERR_LIB_CRMF, CRMF_F_OSSL_CRMF_PBM_NEW, 0), "OSSL_CRMF_pbm_new"}, + {0, NULL} +}; + +static const ERR_STRING_DATA CRMF_str_reasons[] = { + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_BAD_PBM_ITERATIONCOUNT), + "bad pbm iterationcount"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_CRMFERROR), "crmferror"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_ERROR), "error"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_ERROR_DECODING_CERTIFICATE), + "error decoding certificate"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_ERROR_DECRYPTING_CERTIFICATE), + "error decrypting certificate"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_ERROR_DECRYPTING_SYMMETRIC_KEY), + "error decrypting symmetric key"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_FAILURE_OBTAINING_RANDOM), + "failure obtaining random"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_ITERATIONCOUNT_BELOW_100), + "iterationcount below 100"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_MALFORMED_IV), "malformed iv"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_NULL_ARGUMENT), "null argument"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_SETTING_MAC_ALGOR_FAILURE), + "setting mac algor failure"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_SETTING_OWF_ALGOR_FAILURE), + "setting owf algor failure"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_UNSUPPORTED_ALGORITHM), + "unsupported algorithm"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_UNSUPPORTED_ALG_FOR_POPSIGNINGKEY), + "unsupported alg for popsigningkey"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_UNSUPPORTED_CIPHER), + "unsupported cipher"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_UNSUPPORTED_METHOD_FOR_CREATING_POPO), + "unsupported method for creating popo"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_UNSUPPORTED_POPO_METHOD), + "unsupported popo method"}, + {ERR_PACK(ERR_LIB_CRMF, 0, CRMF_R_UNSUPPORTED_POPO_NOT_ACCEPTED), + "unsupported popo not accepted"}, + {0, NULL} +}; + +#endif + +int ERR_load_CRMF_strings(void) +{ +#ifndef OPENSSL_NO_ERR + if (ERR_func_error_string(CRMF_str_functs[0].error) == NULL) { + ERR_load_strings_const(CRMF_str_functs); + ERR_load_strings_const(CRMF_str_reasons); + } +#endif + return 1; +} diff --git a/crypto/crmf/crmf_int.h b/crypto/crmf/crmf_int.h new file mode 100644 index 00000000..db1547b0 --- /dev/null +++ b/crypto/crmf/crmf_int.h @@ -0,0 +1,394 @@ +/*- + * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2018 + * Copyright Siemens AG 2015-2018 + * + * Licensed under the OpenSSL license (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 + * + * CRMF implementation by Martin Peylo, Miikka Viljanen, and David von Oheimb. + */ + +#ifndef OSSL_HEADER_CRMF_INT_H +# define OSSL_HEADER_CRMF_INT_H + +# include +# include + +/* explicit #includes not strictly needed since implied by the above: */ +# include +# include +# include +# include + +/*- + * EncryptedValue ::= SEQUENCE { + * intendedAlg [0] AlgorithmIdentifier OPTIONAL, + * -- the intended algorithm for which the value will be used + * symmAlg [1] AlgorithmIdentifier OPTIONAL, + * -- the symmetric algorithm used to encrypt the value + * encSymmKey [2] BIT STRING OPTIONAL, + * -- the (encrypted) symmetric key used to encrypt the value + * keyAlg [3] AlgorithmIdentifier OPTIONAL, + * -- algorithm used to encrypt the symmetric key + * valueHint [4] OCTET STRING OPTIONAL, + * -- a brief description or identifier of the encValue content + * -- (may be meaningful only to the sending entity, and + * -- used only if EncryptedValue might be re-examined + * -- by the sending entity in the future) + * encValue BIT STRING + * -- the encrypted value itself + * } + */ +struct OSSL_crmf_encryptedvalue_st { + X509_ALGOR *intendedAlg; /* 0 */ + X509_ALGOR *symmAlg; /* 1 */ + ASN1_BIT_STRING *encSymmKey; /* 2 */ + X509_ALGOR *keyAlg; /* 3 */ + ASN1_OCTET_STRING *valueHint; /* 4 */ + ASN1_BIT_STRING *encValue; +} /* OSSL_CRMF_ENCRYPTEDVALUE */; + +/*- + * Attributes ::= SET OF Attribute + * => X509_ATTRIBUTE + * + * PrivateKeyInfo ::= SEQUENCE { + * version INTEGER, + * privateKeyAlgorithm AlgorithmIdentifier, + * privateKey OCTET STRING, + * attributes [0] IMPLICIT Attributes OPTIONAL + * } + */ +typedef struct OSSL_crmf_privatekeyinfo_st { + ASN1_INTEGER *version; + X509_ALGOR *privateKeyAlgorithm; + ASN1_OCTET_STRING *privateKey; + STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ +} OSSL_CRMF_PRIVATEKEYINFO; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PRIVATEKEYINFO) + +/*- + * section 4.2.1 Private Key Info Content Type + * id-ct-encKeyWithID OBJECT IDENTIFIER ::= {id-ct 21} + * + * EncKeyWithID ::= SEQUENCE { + * privateKey PrivateKeyInfo, + * identifier CHOICE { + * string UTF8String, + * generalName GeneralName + * } OPTIONAL + * } + */ +typedef struct OSSL_crmf_enckeywithid_identifier_st { + int type; + union { + ASN1_UTF8STRING *string; + GENERAL_NAME *generalName; + } value; +} OSSL_CRMF_ENCKEYWITHID_IDENTIFIER; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCKEYWITHID_IDENTIFIER) + +typedef struct OSSL_crmf_enckeywithid_st { + OSSL_CRMF_PRIVATEKEYINFO *privateKey; + /* [0] */ + OSSL_CRMF_ENCKEYWITHID_IDENTIFIER *identifier; +} OSSL_CRMF_ENCKEYWITHID; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCKEYWITHID) + +/*- + * CertId ::= SEQUENCE { + * issuer GeneralName, + * serialNumber INTEGER + * } + */ +struct OSSL_crmf_certid_st { + GENERAL_NAME *issuer; + ASN1_INTEGER *serialNumber; +} /* OSSL_CRMF_CERTID */; +DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTID) + +/*- + * SinglePubInfo ::= SEQUENCE { + * pubMethod INTEGER { + * dontCare (0), + * x500 (1), + * web (2), + * ldap (3) }, + * pubLocation GeneralName OPTIONAL + * } + */ +struct OSSL_crmf_singlepubinfo_st { + ASN1_INTEGER *pubMethod; + GENERAL_NAME *pubLocation; +} /* OSSL_CRMF_SINGLEPUBINFO */; +DEFINE_STACK_OF(OSSL_CRMF_SINGLEPUBINFO) +typedef STACK_OF(OSSL_CRMF_SINGLEPUBINFO) OSSL_CRMF_PUBINFOS; + + +/*- + * PKIPublicationInfo ::= SEQUENCE { + * action INTEGER { + * dontPublish (0), + * pleasePublish (1) }, + * pubInfos SEQUENCE SIZE (1..MAX) OF SinglePubInfo OPTIONAL + * -- pubInfos MUST NOT be present if action is "dontPublish" + * -- (if action is "pleasePublish" and pubInfos is omitted, + * -- "dontCare" is assumed) + * } + */ +struct OSSL_crmf_pkipublicationinfo_st { + ASN1_INTEGER *action; + OSSL_CRMF_PUBINFOS *pubInfos; +} /* OSSL_CRMF_PKIPUBLICATIONINFO */; +DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_PKIPUBLICATIONINFO) + +/*- + * PKMACValue ::= SEQUENCE { + * algId AlgorithmIdentifier, + * -- algorithm value shall be PasswordBasedMac {1 2 840 113533 7 66 13} + * -- parameter value is PBMParameter + * value BIT STRING + * } + */ +typedef struct OSSL_crmf_pkmacvalue_st { + X509_ALGOR *algId; + ASN1_BIT_STRING *value; +} OSSL_CRMF_PKMACVALUE; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PKMACVALUE) + +/*- + * SubsequentMessage ::= INTEGER { + * encrCert (0), + * -- requests that resulting certificate be encrypted for the + * -- end entity (following which, POP will be proven in a + * -- confirmation message) + * challengeResp (1) + * -- requests that CA engage in challenge-response exchange with + * -- end entity in order to prove private key possession + * } + * + * POPOPrivKey ::= CHOICE { + * thisMessage [0] BIT STRING, -- Deprecated + * -- possession is proven in this message (which contains the private + * -- key itself (encrypted for the CA)) + * subsequentMessage [1] SubsequentMessage, + * -- possession will be proven in a subsequent message + * dhMAC [2] BIT STRING, -- Deprecated + * agreeMAC [3] PKMACValue, + * encryptedKey [4] EnvelopedData + * } + */ + +typedef struct OSSL_crmf_popoprivkey_st { + int type; + union { + ASN1_BIT_STRING *thisMessage; /* 0 */ /* Deprecated */ + ASN1_INTEGER *subsequentMessage; /* 1 */ + ASN1_BIT_STRING *dhMAC; /* 2 */ /* Deprecated */ + OSSL_CRMF_PKMACVALUE *agreeMAC; /* 3 */ + /* + * TODO: This is not ASN1_NULL but CMS_ENVELOPEDDATA which should be + * somehow taken from crypto/cms which exists now + * - this is not used anywhere so far + */ + ASN1_NULL *encryptedKey; /* 4 */ + } value; +} OSSL_CRMF_POPOPRIVKEY; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOPRIVKEY) + +/*- + * PBMParameter ::= SEQUENCE { + * salt OCTET STRING, + * owf AlgorithmIdentifier, + * -- AlgId for a One-Way Function (SHA-1 recommended) + * iterationCount INTEGER, + * -- number of times the OWF is applied + * mac AlgorithmIdentifier + * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11], + * -- or HMAC [HMAC, RFC2202]) + * } + */ +struct OSSL_crmf_pbmparameter_st { + ASN1_OCTET_STRING *salt; + X509_ALGOR *owf; + ASN1_INTEGER *iterationCount; + X509_ALGOR *mac; +} /* OSSL_CRMF_PBMPARAMETER */; +#define OSSL_CRMF_PBM_MAX_ITERATION_COUNT 100000 /* if too large allows DoS */ + +/*- + * POPOSigningKeyInput ::= SEQUENCE { + * authInfo CHOICE { + * sender [0] GeneralName, + * -- used only if an authenticated identity has been + * -- established for the sender (e.g., a DN from a + * -- previously-issued and currently-valid certificate) + * publicKeyMAC PKMACValue }, + * -- used if no authenticated GeneralName currently exists for + * -- the sender; publicKeyMAC contains a password-based MAC + * -- on the DER-encoded value of publicKey + * publicKey SubjectPublicKeyInfo -- from CertTemplate + * } +*/ +typedef struct OSSL_crmf_poposigningkeyinput_authinfo_st { + int type; + union { + /* 0 */ GENERAL_NAME *sender; + /* 1 */ OSSL_CRMF_PKMACVALUE *publicKeyMAC; + } value; +} OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO) + +typedef struct OSSL_crmf_poposigningkeyinput_st { + OSSL_CRMF_POPOSIGNINGKEYINPUT_AUTHINFO *authInfo; + X509_PUBKEY *publicKey; +} OSSL_CRMF_POPOSIGNINGKEYINPUT; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEYINPUT) + +/*- + * POPOSigningKey ::= SEQUENCE { + * poposkInput [0] POPOSigningKeyInput OPTIONAL, + * algorithmIdentifier AlgorithmIdentifier, + * signature BIT STRING + * } + */ +struct OSSL_crmf_poposigningkey_st { + OSSL_CRMF_POPOSIGNINGKEYINPUT *poposkInput; + X509_ALGOR *algorithmIdentifier; + ASN1_BIT_STRING *signature; +} /* OSSL_CRMF_POPOSIGNINGKEY */; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPOSIGNINGKEY) + +/*- + * ProofOfPossession ::= CHOICE { + * raVerified [0] NULL, + * -- used if the RA has already verified that the requester is in + * -- possession of the private key + * signature [1] POPOSigningKey, + * keyEncipherment [2] POPOPrivKey, + * keyAgreement [3] POPOPrivKey + * } + */ +typedef struct OSSL_crmf_popo_st { + int type; + union { + ASN1_NULL *raVerified; /* 0 */ + OSSL_CRMF_POPOSIGNINGKEY *signature; /* 1 */ + OSSL_CRMF_POPOPRIVKEY *keyEncipherment; /* 2 */ + OSSL_CRMF_POPOPRIVKEY *keyAgreement; /* 3 */ + } value; +} OSSL_CRMF_POPO; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_POPO) + +/*- + * OptionalValidity ::= SEQUENCE { + * notBefore [0] Time OPTIONAL, + * notAfter [1] Time OPTIONAL -- at least one MUST be present + * } + */ +struct OSSL_crmf_optionalvalidity_st { + /* 0 */ ASN1_TIME *notBefore; + /* 1 */ ASN1_TIME *notAfter; +} /* OSSL_CRMF_OPTIONALVALIDITY */; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_OPTIONALVALIDITY) + +/*- + * CertTemplate ::= SEQUENCE { + * version [0] Version OPTIONAL, + * serialNumber [1] INTEGER OPTIONAL, + * signingAlg [2] AlgorithmIdentifier OPTIONAL, + * issuer [3] Name OPTIONAL, + * validity [4] OptionalValidity OPTIONAL, + * subject [5] Name OPTIONAL, + * publicKey [6] SubjectPublicKeyInfo OPTIONAL, + * issuerUID [7] UniqueIdentifier OPTIONAL, + * subjectUID [8] UniqueIdentifier OPTIONAL, + * extensions [9] Extensions OPTIONAL + * } + */ +struct OSSL_crmf_certtemplate_st { + ASN1_INTEGER *version; /* 0 */ + ASN1_INTEGER *serialNumber; /* 1 */ /* serialNumber MUST be omitted */ + /* This field is assigned by the CA during certificate creation */ + X509_ALGOR *signingAlg; /* 2 */ /* signingAlg MUST be omitted */ + /* This field is assigned by the CA during certificate creation */ + X509_NAME *issuer; /* 3 */ + OSSL_CRMF_OPTIONALVALIDITY *validity; /* 4 */ + X509_NAME *subject; /* 5 */ + X509_PUBKEY *publicKey; /* 6 */ + ASN1_BIT_STRING *issuerUID; /* 7 */ /* deprecated in version 2 */ + /* According to rfc 3280: UniqueIdentifier ::= BIT STRING */ + ASN1_BIT_STRING *subjectUID; /* 8 */ /* deprecated in version 2 */ + /* Could be X509_EXTENSION*S*, but that's only cosmetic */ + STACK_OF(X509_EXTENSION) *extensions; /* 9 */ +} /* OSSL_CRMF_CERTTEMPLATE */; + +/*- + * CertRequest ::= SEQUENCE { + * certReqId INTEGER, -- ID for matching request and reply + * certTemplate CertTemplate, -- Selected fields of cert to be issued + * controls Controls OPTIONAL -- Attributes affecting issuance + * } + */ +struct OSSL_crmf_certrequest_st { + ASN1_INTEGER *certReqId; + OSSL_CRMF_CERTTEMPLATE *certTemplate; + /* TODO: make OSSL_CRMF_CONTROLS out of that - but only cosmetical */ + STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *controls; +} /* OSSL_CRMF_CERTREQUEST */; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTREQUEST) +DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_CERTREQUEST) + +/* TODO: isn't there a better way to have this for ANY type? */ +struct OSSL_crmf_attributetypeandvalue_st { + ASN1_OBJECT *type; + union { + /* NID_id_regCtrl_regToken */ + ASN1_UTF8STRING *regToken; + + /* NID_id_regCtrl_authenticator */ + ASN1_UTF8STRING *authenticator; + + /* NID_id_regCtrl_pkiPublicationInfo */ + OSSL_CRMF_PKIPUBLICATIONINFO *pkiPublicationInfo; + + /* NID_id_regCtrl_oldCertID */ + OSSL_CRMF_CERTID *oldCertID; + + /* NID_id_regCtrl_protocolEncrKey */ + X509_PUBKEY *protocolEncrKey; + + /* NID_id_regInfo_utf8Pairs */ + ASN1_UTF8STRING *utf8Pairs; + + /* NID_id_regInfo_certReq */ + OSSL_CRMF_CERTREQUEST *certReq; + + ASN1_TYPE *other; + } value; +} /* OSSL_CRMF_ATTRIBUTETYPEANDVALUE */; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) +DEFINE_STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) +DECLARE_ASN1_DUP_FUNCTION(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) + +/*- + * CertReqMessages ::= SEQUENCE SIZE (1..MAX) OF CertReqMsg + * CertReqMsg ::= SEQUENCE { + * certReq CertRequest, + * popo ProofOfPossession OPTIONAL, + * -- content depends upon key type + * regInfo SEQUENCE SIZE(1..MAX) OF AttributeTypeAndValue OPTIONAL + * } + */ +struct OSSL_crmf_msg_st { + OSSL_CRMF_CERTREQUEST *certReq; + /* 0 */ + OSSL_CRMF_POPO *popo; + /* 1 */ + STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *regInfo; +} /* OSSL_CRMF_MSG */; +/* DEFINE_STACK_OF(OSSL_CRMF_MSG) */ +#endif diff --git a/crypto/crmf/crmf_lib.c b/crypto/crmf/crmf_lib.c new file mode 100644 index 00000000..49deca75 --- /dev/null +++ b/crypto/crmf/crmf_lib.c @@ -0,0 +1,753 @@ +/*- + * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2018 + * Copyright Siemens AG 2015-2018 + * + * Licensed under the OpenSSL license (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 + * + * CRMF implementation by Martin Peylo, Miikka Viljanen, and David von Oheimb. + */ + +/* + * This file contains the functions that handle the individual items inside + * the CRMF structures + */ + +/* + * NAMING + * + * The 0 functions use the supplied structure pointer directly in the parent and + * it will be freed up when the parent is freed. + * + * The 1 functions use a copy of the supplied structure pointer (or in some + * cases increases its link count) in the parent and so both should be freed up. + */ + +#include + +#include "crmf_int.h" + +/* explicit #includes not strictly needed since implied by the above: */ +#include +#include +#include + +/*- + * atyp = Attribute Type + * valt = Value Type + * ctrlinf = "regCtrl" or "regInfo" + */ +#define IMPLEMENT_CRMF_CTRL_FUNC(atyp, valt, ctrlinf) \ +int OSSL_CRMF_MSG_set1_##ctrlinf##_##atyp(OSSL_CRMF_MSG *msg, \ + const valt *in) \ +{ \ + OSSL_CRMF_ATTRIBUTETYPEANDVALUE *atav = NULL; \ + \ + if (msg == NULL || in == NULL) \ + goto err; \ + if ((atav = OSSL_CRMF_ATTRIBUTETYPEANDVALUE_new()) == NULL) \ + goto err; \ + if ((atav->type = OBJ_nid2obj(NID_id_##ctrlinf##_##atyp)) == NULL) \ + goto err; \ + if ((atav->value.atyp = valt##_dup(in)) == NULL) \ + goto err; \ + if (!OSSL_CRMF_MSG_push0_##ctrlinf(msg, atav)) \ + goto err; \ + return 1; \ + err: \ + OSSL_CRMF_ATTRIBUTETYPEANDVALUE_free(atav); \ + return 0; \ +} + + +/*- + * Pushes the given control attribute into the controls stack of a CertRequest + * (section 6) + * returns 1 on success, 0 on error + */ +static int OSSL_CRMF_MSG_push0_regCtrl(OSSL_CRMF_MSG *crm, + OSSL_CRMF_ATTRIBUTETYPEANDVALUE *ctrl) +{ + int new = 0; + + if (crm == NULL || crm->certReq == NULL || ctrl == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_MSG_PUSH0_REGCTRL, CRMF_R_NULL_ARGUMENT); + return 0; + } + + if (crm->certReq->controls == NULL) { + crm->certReq->controls = sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_new_null(); + if (crm->certReq->controls == NULL) + goto oom; + new = 1; + } + if (!sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_push(crm->certReq->controls, ctrl)) + goto oom; + + return 1; + oom: + CRMFerr(CRMF_F_OSSL_CRMF_MSG_PUSH0_REGCTRL, ERR_R_MALLOC_FAILURE); + + if (new != 0) { + sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_free(crm->certReq->controls); + crm->certReq->controls = NULL; + } + return 0; +} + + /* id-regCtrl-regToken Control (section 6.1) */ +IMPLEMENT_CRMF_CTRL_FUNC(regToken, ASN1_STRING, regCtrl) + + /* id-regCtrl-authenticator Control (section 6.2) */ +#define ASN1_UTF8STRING_dup ASN1_STRING_dup +IMPLEMENT_CRMF_CTRL_FUNC(authenticator, ASN1_UTF8STRING, regCtrl) + +int OSSL_CRMF_MSG_set0_SinglePubInfo(OSSL_CRMF_SINGLEPUBINFO *spi, + int method, GENERAL_NAME *nm) +{ + if (spi == NULL + || method < OSSL_CRMF_PUB_METHOD_DONTCARE + || method > OSSL_CRMF_PUB_METHOD_LDAP) { + CRMFerr(CRMF_F_OSSL_CRMF_MSG_SET0_SINGLEPUBINFO, + ERR_R_PASSED_INVALID_ARGUMENT); + return 0; + } + + if (!ASN1_INTEGER_set(spi->pubMethod, method)) + return 0; + GENERAL_NAME_free(spi->pubLocation); + spi->pubLocation = nm; + return 1; +} + +int OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo( + OSSL_CRMF_PKIPUBLICATIONINFO *pi, + OSSL_CRMF_SINGLEPUBINFO *spi) +{ + if (pi == NULL || spi == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_MSG_PKIPUBLICATIONINFO_PUSH0_SINGLEPUBINFO, + CRMF_R_NULL_ARGUMENT); + return 0; + } + if (pi->pubInfos == NULL) + pi->pubInfos = sk_OSSL_CRMF_SINGLEPUBINFO_new_null(); + if (pi->pubInfos == NULL) + goto oom; + + if (!sk_OSSL_CRMF_SINGLEPUBINFO_push(pi->pubInfos, spi)) + goto oom; + return 1; + + oom: + CRMFerr(CRMF_F_OSSL_CRMF_MSG_PKIPUBLICATIONINFO_PUSH0_SINGLEPUBINFO, + ERR_R_MALLOC_FAILURE); + return 0; +} + +int OSSL_CRMF_MSG_set_PKIPublicationInfo_action( + OSSL_CRMF_PKIPUBLICATIONINFO *pi, int action) +{ + if (pi == NULL + || action < OSSL_CRMF_PUB_ACTION_DONTPUBLISH + || action > OSSL_CRMF_PUB_ACTION_PLEASEPUBLISH) { + CRMFerr(CRMF_F_OSSL_CRMF_MSG_SET_PKIPUBLICATIONINFO_ACTION, + ERR_R_PASSED_INVALID_ARGUMENT); + return 0; + } + + return ASN1_INTEGER_set(pi->action, action); +} + + /* id-regCtrl-pkiPublicationInfo Control (section 6.3) */ +IMPLEMENT_CRMF_CTRL_FUNC(pkiPublicationInfo, OSSL_CRMF_PKIPUBLICATIONINFO, + regCtrl) + + /* id-regCtrl-oldCertID Control (section 6.5) from the given */ +IMPLEMENT_CRMF_CTRL_FUNC(oldCertID, OSSL_CRMF_CERTID, regCtrl) + +OSSL_CRMF_CERTID *OSSL_CRMF_CERTID_gen(const X509_NAME *issuer, + const ASN1_INTEGER *serial) +{ + OSSL_CRMF_CERTID *cid = NULL; + + if (issuer == NULL || serial == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_CERTID_GEN, CRMF_R_NULL_ARGUMENT); + return NULL; + } + + if ((cid = OSSL_CRMF_CERTID_new()) == NULL) + goto oom; + + if (!X509_NAME_set(&cid->issuer->d.directoryName, issuer)) + goto oom; + cid->issuer->type = GEN_DIRNAME; + + ASN1_INTEGER_free(cid->serialNumber); + if ((cid->serialNumber = ASN1_INTEGER_dup(serial)) == NULL) + goto oom; + + return cid; + + oom: + CRMFerr(CRMF_F_OSSL_CRMF_CERTID_GEN, ERR_R_MALLOC_FAILURE); + OSSL_CRMF_CERTID_free(cid); + return NULL; +} + + /* + * id-regCtrl-protocolEncrKey Control (section 6.6) + * + * For some reason X509_PUBKEY_dup() is not implemented in OpenSSL X509 + * TODO: check whether that should go elsewhere + */ +static IMPLEMENT_ASN1_DUP_FUNCTION(X509_PUBKEY) +IMPLEMENT_CRMF_CTRL_FUNC(protocolEncrKey, X509_PUBKEY, regCtrl) + +/*- + * Pushes the attribute given in regInfo in to the CertReqMsg->regInfo stack. + * (section 7) + * returns 1 on success, 0 on error + */ +static int OSSL_CRMF_MSG_push0_regInfo(OSSL_CRMF_MSG *crm, + OSSL_CRMF_ATTRIBUTETYPEANDVALUE *ri) +{ + STACK_OF(OSSL_CRMF_ATTRIBUTETYPEANDVALUE) *info = NULL; + + if (crm == NULL || ri == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_MSG_PUSH0_REGINFO, CRMF_R_NULL_ARGUMENT); + return 0; + } + + if (crm->regInfo == NULL) + crm->regInfo = info = sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_new_null(); + if (crm->regInfo == NULL) + goto oom; + if (!sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_push(crm->regInfo, ri)) + goto oom; + return 1; + + oom: + CRMFerr(CRMF_F_OSSL_CRMF_MSG_PUSH0_REGINFO, ERR_R_MALLOC_FAILURE); + if (info != NULL) + crm->regInfo = NULL; + sk_OSSL_CRMF_ATTRIBUTETYPEANDVALUE_free(info); + return 0; +} + +/* id-regInfo-utf8Pairs to regInfo (section 7.1) */ +IMPLEMENT_CRMF_CTRL_FUNC(utf8Pairs, ASN1_UTF8STRING, regInfo) + +/* id-regInfo-certReq to regInfo (section 7.2) */ +IMPLEMENT_CRMF_CTRL_FUNC(certReq, OSSL_CRMF_CERTREQUEST, regInfo) + + +/* retrieves the certificate template of crm */ +OSSL_CRMF_CERTTEMPLATE *OSSL_CRMF_MSG_get0_tmpl(const OSSL_CRMF_MSG *crm) +{ + if (crm == NULL || crm->certReq == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_MSG_GET0_TMPL, CRMF_R_NULL_ARGUMENT); + return NULL; + } + return crm->certReq->certTemplate; +} + + +int OSSL_CRMF_MSG_set_validity(OSSL_CRMF_MSG *crm, time_t from, time_t to) +{ + OSSL_CRMF_OPTIONALVALIDITY *vld = NULL; + ASN1_TIME *from_asn = NULL; + ASN1_TIME *to_asn = NULL; + OSSL_CRMF_CERTTEMPLATE *tmpl = OSSL_CRMF_MSG_get0_tmpl(crm); + + if (tmpl == NULL) { /* also crm == NULL implies this */ + CRMFerr(CRMF_F_OSSL_CRMF_MSG_SET_VALIDITY, CRMF_R_NULL_ARGUMENT); + return 0; + } + + if (from != 0 && ((from_asn = ASN1_TIME_set(NULL, from)) == NULL)) + goto oom; + if (to != 0 && ((to_asn = ASN1_TIME_set(NULL, to)) == NULL)) + goto oom; + if ((vld = OSSL_CRMF_OPTIONALVALIDITY_new()) == NULL) + goto oom; + + vld->notBefore = from_asn; + vld->notAfter = to_asn; + + tmpl->validity = vld; + + return 1; + oom: + CRMFerr(CRMF_F_OSSL_CRMF_MSG_SET_VALIDITY, ERR_R_MALLOC_FAILURE); + ASN1_TIME_free(from_asn); + ASN1_TIME_free(to_asn); + return 0; +} + + +int OSSL_CRMF_MSG_set_certReqId(OSSL_CRMF_MSG *crm, int rid) +{ + if (crm == NULL || crm->certReq == NULL || crm->certReq->certReqId == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_MSG_SET_CERTREQID, CRMF_R_NULL_ARGUMENT); + return 0; + } + + return ASN1_INTEGER_set(crm->certReq->certReqId, rid); +} + +/* get ASN.1 encoded integer, return -1 on error */ +static int crmf_asn1_get_int(int func, const ASN1_INTEGER *a) +{ + int64_t res; + + if (!ASN1_INTEGER_get_int64(&res, a)) { + CRMFerr(func, ASN1_R_INVALID_NUMBER); + return -1; + } + if (res < INT_MIN) { + CRMFerr(func, ASN1_R_TOO_SMALL); + return -1; + } + if (res > INT_MAX) { + CRMFerr(func, ASN1_R_TOO_LARGE); + return -1; + } + return (int)res; +} + +int OSSL_CRMF_MSG_get_certReqId(OSSL_CRMF_MSG *crm) +{ + if (crm == NULL || /* not really needed: */ crm->certReq == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_MSG_GET_CERTREQID, CRMF_R_NULL_ARGUMENT); + return -1; + } + return crmf_asn1_get_int(CRMF_F_OSSL_CRMF_MSG_GET_CERTREQID, + crm->certReq->certReqId); +} + + +int OSSL_CRMF_MSG_set0_extensions(OSSL_CRMF_MSG *crm, + X509_EXTENSIONS *exts) +{ + OSSL_CRMF_CERTTEMPLATE *tmpl = OSSL_CRMF_MSG_get0_tmpl(crm); + + if (tmpl == NULL) { /* also crm == NULL implies this */ + CRMFerr(CRMF_F_OSSL_CRMF_MSG_SET0_EXTENSIONS, CRMF_R_NULL_ARGUMENT); + return 0; + } + + if (sk_X509_EXTENSION_num(exts) == 0) { + sk_X509_EXTENSION_free(exts); + exts = NULL; /* do not include empty extensions list */ + } + + sk_X509_EXTENSION_pop_free(tmpl->extensions, X509_EXTENSION_free); + tmpl->extensions = exts; + return 1; +} + + +int OSSL_CRMF_MSG_push0_extension(OSSL_CRMF_MSG *crm, + const X509_EXTENSION *ext) +{ + int new = 0; + OSSL_CRMF_CERTTEMPLATE *tmpl = OSSL_CRMF_MSG_get0_tmpl(crm); + + if (tmpl == NULL || ext == NULL) { /* also crm == NULL implies this */ + CRMFerr(CRMF_F_OSSL_CRMF_MSG_PUSH0_EXTENSION, CRMF_R_NULL_ARGUMENT); + return 0; + } + + if (tmpl->extensions == NULL) { + if ((tmpl->extensions = sk_X509_EXTENSION_new_null()) == NULL) + goto oom; + new = 1; + } + + if (!sk_X509_EXTENSION_push(tmpl->extensions, (X509_EXTENSION *)ext)) + goto oom; + return 1; + oom: + CRMFerr(CRMF_F_OSSL_CRMF_MSG_PUSH0_EXTENSION, ERR_R_MALLOC_FAILURE); + + if (new != 0) { + sk_X509_EXTENSION_free(tmpl->extensions); + tmpl->extensions = NULL; + } + return 0; +} + +/* TODO: support cases 1+2 (besides case 3) defined in RFC 4211, section 4.1. */ +static int CRMF_poposigningkey_init(OSSL_CRMF_POPOSIGNINGKEY *ps, + OSSL_CRMF_CERTREQUEST *cr, + EVP_PKEY *pkey, int dgst) +{ + int len; + size_t crlen; + size_t siglen; + unsigned char *crder = NULL, *sig = NULL; + int alg_nid = 0; + int md_nid = 0; + const EVP_MD *alg = NULL; + EVP_MD_CTX *ctx = NULL; + int ret = 0; + + if (ps == NULL || cr == NULL || pkey == NULL) { + CRMFerr(CRMF_F_CRMF_POPOSIGNINGKEY_INIT, CRMF_R_NULL_ARGUMENT); + return 0; + } + + /* OpenSSL defaults all bit strings to be encoded as ASN.1 NamedBitList */ + ps->signature->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); + ps->signature->flags |= ASN1_STRING_FLAG_BITS_LEFT; + + len = i2d_OSSL_CRMF_CERTREQUEST(cr, &crder); + if (len < 0 || crder == NULL) { + CRMFerr(CRMF_F_CRMF_POPOSIGNINGKEY_INIT, CRMF_R_ERROR); + goto err; + } + crlen = (size_t)len; + + if (!OBJ_find_sigid_by_algs(&alg_nid, dgst, EVP_PKEY_id(pkey))) { + CRMFerr(CRMF_F_CRMF_POPOSIGNINGKEY_INIT, + CRMF_R_UNSUPPORTED_ALG_FOR_POPSIGNINGKEY); + goto err; + } + if (!OBJ_find_sigid_algs(alg_nid, &md_nid, NULL) + || (alg = EVP_get_digestbynid(md_nid)) == NULL) { + CRMFerr(CRMF_F_CRMF_POPOSIGNINGKEY_INIT, + CRMF_R_UNSUPPORTED_ALG_FOR_POPSIGNINGKEY); + goto err; + } + if (!X509_ALGOR_set0(ps->algorithmIdentifier, OBJ_nid2obj(alg_nid), + V_ASN1_NULL, NULL) + || (ctx = EVP_MD_CTX_new()) == NULL + || EVP_DigestSignInit(ctx, NULL, alg, NULL, pkey) <= 0 + || EVP_DigestSignUpdate(ctx, crder, crlen) <= 0 + || EVP_DigestSignFinal(ctx, NULL, &siglen) <= 0) { + CRMFerr(CRMF_F_CRMF_POPOSIGNINGKEY_INIT, CRMF_R_ERROR); + goto err; + } + if ((sig = OPENSSL_malloc(siglen)) == NULL) { + CRMFerr(CRMF_F_CRMF_POPOSIGNINGKEY_INIT, ERR_R_MALLOC_FAILURE); + goto err; + } + if (EVP_DigestSignFinal(ctx, sig, &siglen) <= 0 + || !ASN1_BIT_STRING_set(ps->signature, sig, siglen)) { + CRMFerr(CRMF_F_CRMF_POPOSIGNINGKEY_INIT, CRMF_R_ERROR); + goto err; + } + ret = 1; + + err: + OPENSSL_free(crder); + EVP_MD_CTX_free(ctx); + OPENSSL_free(sig); + return ret; +} + + +int OSSL_CRMF_MSG_create_popo(OSSL_CRMF_MSG *crm, EVP_PKEY *pkey, + int dgst, int ppmtd) +{ + OSSL_CRMF_POPO *pp = NULL; + ASN1_INTEGER *tag = NULL; + + if (crm == NULL || (ppmtd == OSSL_CRMF_POPO_SIGNATURE && pkey == NULL)) { + CRMFerr(CRMF_F_OSSL_CRMF_MSG_CREATE_POPO, CRMF_R_NULL_ARGUMENT); + return 0; + } + + if (ppmtd == OSSL_CRMF_POPO_NONE) + goto end; + if ((pp = OSSL_CRMF_POPO_new()) == NULL) + goto oom; + pp->type = ppmtd; + + switch (ppmtd) { + case OSSL_CRMF_POPO_RAVERIFIED: + if ((pp->value.raVerified = ASN1_NULL_new()) == NULL) + goto oom; + break; + + case OSSL_CRMF_POPO_SIGNATURE: + { + OSSL_CRMF_POPOSIGNINGKEY *ps = OSSL_CRMF_POPOSIGNINGKEY_new(); + if (ps == NULL + || !CRMF_poposigningkey_init(ps, crm->certReq, pkey, dgst)){ + OSSL_CRMF_POPOSIGNINGKEY_free(ps); + goto err; + } + pp->value.signature = ps; + } + break; + + case OSSL_CRMF_POPO_KEYENC: + if ((pp->value.keyEncipherment = OSSL_CRMF_POPOPRIVKEY_new()) == NULL) + goto oom; + tag = ASN1_INTEGER_new(); + pp->value.keyEncipherment->type = + OSSL_CRMF_POPOPRIVKEY_SUBSEQUENTMESSAGE; + pp->value.keyEncipherment->value.subsequentMessage = tag; + if (tag == NULL + || !ASN1_INTEGER_set(tag, OSSL_CRMF_SUBSEQUENTMESSAGE_ENCRCERT)) + goto oom; + break; + + default: + CRMFerr(CRMF_F_OSSL_CRMF_MSG_CREATE_POPO, + CRMF_R_UNSUPPORTED_METHOD_FOR_CREATING_POPO); + goto err; + } + + end: + OSSL_CRMF_POPO_free(crm->popo); + crm->popo = pp; + + return 1; + oom: + CRMFerr(CRMF_F_OSSL_CRMF_MSG_CREATE_POPO, ERR_R_MALLOC_FAILURE); + err: + OSSL_CRMF_POPO_free(pp); + return 0; +} + +/* returns 0 for equal, -1 for a < b or error on a, 1 for a > b or error on b */ +static int X509_PUBKEY_cmp(X509_PUBKEY *a, X509_PUBKEY *b) +{ + X509_ALGOR *algA = NULL, *algB = NULL; + int res = 0; + + if (a == b) + return 0; + if (a == NULL || !X509_PUBKEY_get0_param(NULL, NULL, NULL, &algA, a) + || algA == NULL) + return -1; + if (b == NULL || !X509_PUBKEY_get0_param(NULL, NULL, NULL, &algB, b) + || algB == NULL) + return 1; + if ((res = X509_ALGOR_cmp(algA, algB)) != 0) + return res; + return EVP_PKEY_cmp(X509_PUBKEY_get0(a), X509_PUBKEY_get0(b)); +} + +/* verifies the Proof-of-Possession of the request with the given rid in reqs */ +int OSSL_CRMF_MSGS_verify_popo(const OSSL_CRMF_MSGS *reqs, + int rid, int acceptRAVerified) +{ + OSSL_CRMF_MSG *req = NULL; + X509_PUBKEY *pubkey = NULL; + OSSL_CRMF_POPOSIGNINGKEY *sig = NULL; + + if (reqs == NULL + || (req = sk_OSSL_CRMF_MSG_value(reqs, rid)) == NULL + || req->popo == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_MSGS_VERIFY_POPO, + CRMF_R_NULL_ARGUMENT); + return 0; + } + + switch (req->popo->type) { + case OSSL_CRMF_POPO_RAVERIFIED: + if (acceptRAVerified) + return 1; + break; + case OSSL_CRMF_POPO_SIGNATURE: + pubkey = req->certReq->certTemplate->publicKey; + sig = req->popo->value.signature; + if (sig->poposkInput != NULL) { + /* + * According to RFC 4211: publicKey contains a copy of + * the public key from the certificate template. This MUST be + * exactly the same value as contained in the certificate template. + */ + if (pubkey == NULL + || sig->poposkInput->publicKey == NULL + || X509_PUBKEY_cmp(pubkey, sig->poposkInput->publicKey) + || ASN1_item_verify( + ASN1_ITEM_rptr(OSSL_CRMF_POPOSIGNINGKEYINPUT), + sig->algorithmIdentifier, sig->signature, + sig->poposkInput, X509_PUBKEY_get0(pubkey)) < 1) + break; + } else { + if (pubkey == NULL + || req->certReq->certTemplate->subject == NULL + || ASN1_item_verify(ASN1_ITEM_rptr(OSSL_CRMF_CERTREQUEST), + sig->algorithmIdentifier, sig->signature, + req->certReq, + X509_PUBKEY_get0(pubkey)) < 1) + break; + } + return 1; + case OSSL_CRMF_POPO_KEYENC: + /* + * TODO: when OSSL_CMP_certrep_new() supports encrypted certs, + * return 1 if the type of req->popo->value.keyEncipherment + * is OSSL_CRMF_POPOPRIVKEY_SUBSEQUENTMESSAGE and + * its value.subsequentMessage == OSSL_CRMF_SUBSEQUENTMESSAGE_ENCRCERT + */ + case OSSL_CRMF_POPO_KEYAGREE: + default: + CRMFerr(CRMF_F_OSSL_CRMF_MSGS_VERIFY_POPO, + CRMF_R_UNSUPPORTED_POPO_METHOD); + return 0; + } + CRMFerr(CRMF_F_OSSL_CRMF_MSGS_VERIFY_POPO, + CRMF_R_UNSUPPORTED_POPO_NOT_ACCEPTED); + return 0; +} + +/* retrieves the serialNumber of the given cert template or NULL on error */ +ASN1_INTEGER *OSSL_CRMF_CERTTEMPLATE_get0_serialNumber(OSSL_CRMF_CERTTEMPLATE *tmpl) +{ + return tmpl != NULL ? tmpl->serialNumber : NULL; +} + +/* retrieves the issuer name of the given cert template or NULL on error */ +X509_NAME *OSSL_CRMF_CERTTEMPLATE_get0_issuer(OSSL_CRMF_CERTTEMPLATE *tmpl) +{ + return tmpl != NULL ? tmpl->issuer : NULL; +} + +/* + * fill in certificate template. + * Any value argument that is NULL will leave the respective field unchanged. + */ +int OSSL_CRMF_CERTTEMPLATE_fill(OSSL_CRMF_CERTTEMPLATE *tmpl, + EVP_PKEY *pubkey, + const X509_NAME *subject, + const X509_NAME *issuer, + const ASN1_INTEGER *serial) +{ + if (tmpl == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_CERTTEMPLATE_FILL, CRMF_R_NULL_ARGUMENT); + return 0; + } + if (subject != NULL && !X509_NAME_set(&tmpl->subject, subject)) + goto oom; + if (issuer != NULL && !X509_NAME_set(&tmpl->issuer, issuer)) + goto oom; + if (serial != NULL) { + ASN1_INTEGER_free(tmpl->serialNumber); + if ((tmpl->serialNumber = ASN1_INTEGER_dup(serial)) == NULL) + goto oom; + } + if (pubkey != NULL && !X509_PUBKEY_set(&tmpl->publicKey, pubkey)) + goto oom; + return 1; + + oom: + CRMFerr(CRMF_F_OSSL_CRMF_CERTTEMPLATE_FILL, ERR_R_MALLOC_FAILURE); + return 0; +} + + +/*- + * Decrypts the certificate in the given encryptedValue + * this is needed for the indirect PoP method as in RFC 4210 section 5.2.8.2 + * + * returns a pointer to the decrypted certificate + * returns NULL on error or if no certificate available + */ +X509 *OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert(OSSL_CRMF_ENCRYPTEDVALUE *ecert, + EVP_PKEY *pkey) +{ + X509 *cert = NULL; /* decrypted certificate */ + EVP_CIPHER_CTX *evp_ctx = NULL; /* context for symmetric encryption */ + unsigned char *ek = NULL; /* decrypted symmetric encryption key */ + const EVP_CIPHER *cipher = NULL; /* used cipher */ + unsigned char *iv = NULL; /* initial vector for symmetric encryption */ + unsigned char *outbuf = NULL; /* decryption output buffer */ + const unsigned char *p = NULL; /* needed for decoding ASN1 */ + int symmAlg = 0; /* NIDs for symmetric algorithm */ + int n, outlen = 0; + EVP_PKEY_CTX *pkctx = NULL; /* private key context */ + + if (ecert == NULL || ecert->symmAlg == NULL || ecert->encSymmKey == NULL + || ecert->encValue == NULL || pkey == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT, + CRMF_R_NULL_ARGUMENT); + return NULL; + } + if ((symmAlg = OBJ_obj2nid(ecert->symmAlg->algorithm)) == 0) { + CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT, + CRMF_R_UNSUPPORTED_CIPHER); + return NULL; + } + + /* first the symmetric key needs to be decrypted */ + pkctx = EVP_PKEY_CTX_new(pkey, NULL); + if (pkctx != NULL && EVP_PKEY_decrypt_init(pkctx)) { + ASN1_BIT_STRING *encKey = ecert->encSymmKey; + size_t eksize = 0; + + if (EVP_PKEY_decrypt(pkctx, NULL, &eksize, encKey->data, encKey->length) + <= 0 + || (ek = OPENSSL_malloc(eksize)) == NULL + || EVP_PKEY_decrypt(pkctx, ek, &eksize, encKey->data, + encKey->length) <= 0) { + CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT, + CRMF_R_ERROR_DECRYPTING_SYMMETRIC_KEY); + goto end; + } + } else { + goto oom; + } + + /* select symmetric cipher based on algorithm given in message */ + if ((cipher = EVP_get_cipherbynid(symmAlg)) == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT, + CRMF_R_UNSUPPORTED_CIPHER); + goto end; + } + if ((iv = OPENSSL_malloc(EVP_CIPHER_iv_length(cipher))) == NULL) + goto oom; + if (ASN1_TYPE_get_octetstring(ecert->symmAlg->parameter, iv, + EVP_CIPHER_iv_length(cipher)) + != EVP_CIPHER_iv_length(cipher)) { + CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT, + CRMF_R_MALFORMED_IV); + goto end; + } + + /* + * d2i_X509 changes the given pointer, so use p for decoding the message and + * keep the original pointer in outbuf so the memory can be freed later + */ + if ((p = outbuf = OPENSSL_malloc(ecert->encValue->length + + EVP_CIPHER_block_size(cipher))) == NULL + || (evp_ctx = EVP_CIPHER_CTX_new()) == NULL) + goto oom; + EVP_CIPHER_CTX_set_padding(evp_ctx, 0); + + if (!EVP_DecryptInit(evp_ctx, cipher, ek, iv) + || !EVP_DecryptUpdate(evp_ctx, outbuf, &outlen, + ecert->encValue->data, + ecert->encValue->length) + || !EVP_DecryptFinal(evp_ctx, outbuf + outlen, &n)) { + CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT, + CRMF_R_ERROR_DECRYPTING_CERTIFICATE); + goto end; + } + outlen += n; + + /* convert decrypted certificate from DER to internal ASN.1 structure */ + if ((cert = d2i_X509(NULL, &p, outlen)) == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT, + CRMF_R_ERROR_DECODING_CERTIFICATE); + } + goto end; + + oom: + CRMFerr(CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT, ERR_R_MALLOC_FAILURE); + end: + EVP_PKEY_CTX_free(pkctx); + OPENSSL_free(outbuf); + EVP_CIPHER_CTX_free(evp_ctx); + OPENSSL_free(ek); + OPENSSL_free(iv); + return cert; +} diff --git a/crypto/crmf/crmf_pbm.c b/crypto/crmf/crmf_pbm.c new file mode 100644 index 00000000..60d06d4a --- /dev/null +++ b/crypto/crmf/crmf_pbm.c @@ -0,0 +1,231 @@ +/*- + * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2018 + * Copyright Siemens AG 2015-2018 + * + * Licensed under the OpenSSL license (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 + * + * CRMF implementation by Martin Peylo, Miikka Viljanen, and David von Oheimb. + */ + + +#include +#include + +#include "crmf_int.h" + +/* explicit #includes not strictly needed since implied by the above: */ +#include +#include +#include +#include + +/*- + * creates and initializes OSSL_CRMF_PBMPARAMETER (section 4.4) + * |slen| SHOULD be > 8 (16 is common) + * |owfnid| e.g., NID_sha256 + * |itercnt| MUST be > 100 (500 is common) + * |macnid| e.g., NID_hmac_sha1 + * returns pointer to OSSL_CRMF_PBMPARAMETER on success, NULL on error + */ +OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(size_t slen, int owfnid, + int itercnt, int macnid) +{ + OSSL_CRMF_PBMPARAMETER *pbm = NULL; + unsigned char *salt = NULL; + + if ((pbm = OSSL_CRMF_PBMPARAMETER_new()) == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_PBMP_NEW, ERR_R_MALLOC_FAILURE); + goto err; + } + + /* + * salt contains a randomly generated value used in computing the key + * of the MAC process. The salt SHOULD be at least 8 octets (64 + * bits) long. + */ + if ((salt = OPENSSL_malloc(slen)) == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_PBMP_NEW, ERR_R_MALLOC_FAILURE); + goto err; + } + if (RAND_bytes(salt, (int)slen) <= 0) { + CRMFerr(CRMF_F_OSSL_CRMF_PBMP_NEW, CRMF_R_FAILURE_OBTAINING_RANDOM); + goto err; + } + if (!ASN1_OCTET_STRING_set(pbm->salt, salt, (int)slen)) + goto err; + + /* + * owf identifies the hash algorithm and associated parameters used to + * compute the key used in the MAC process. All implementations MUST + * support SHA-1. + */ + if (!X509_ALGOR_set0(pbm->owf, OBJ_nid2obj(owfnid), V_ASN1_UNDEF, NULL)) { + CRMFerr(CRMF_F_OSSL_CRMF_PBMP_NEW, CRMF_R_SETTING_OWF_ALGOR_FAILURE); + goto err; + } + + /* + * iterationCount identifies the number of times the hash is applied + * during the key computation process. The iterationCount MUST be a + * minimum of 100. Many people suggest using values as high as 1000 + * iterations as the minimum value. The trade off here is between + * protection of the password from attacks and the time spent by the + * server processing all of the different iterations in deriving + * passwords. Hashing is generally considered a cheap operation but + * this may not be true with all hash functions in the future. + */ + if (itercnt < 100) { + CRMFerr(CRMF_F_OSSL_CRMF_PBMP_NEW, CRMF_R_ITERATIONCOUNT_BELOW_100); + goto err; + } + + if (!ASN1_INTEGER_set(pbm->iterationCount, itercnt)) { + CRMFerr(CRMF_F_OSSL_CRMF_PBMP_NEW, CRMF_R_CRMFERROR); + goto err; + } + + /* + * mac identifies the algorithm and associated parameters of the MAC + * function to be used. All implementations MUST support HMAC-SHA1 [HMAC]. + * All implementations SHOULD support DES-MAC and Triple-DES-MAC [PKCS11]. + */ + if (!X509_ALGOR_set0(pbm->mac, OBJ_nid2obj(macnid), V_ASN1_UNDEF, NULL)) { + CRMFerr(CRMF_F_OSSL_CRMF_PBMP_NEW, CRMF_R_SETTING_MAC_ALGOR_FAILURE); + goto err; + } + + OPENSSL_free(salt); + return pbm; + err: + OPENSSL_free(salt); + OSSL_CRMF_PBMPARAMETER_free(pbm); + return NULL; +} + +/*- + * calculates the PBM based on the settings of the given OSSL_CRMF_PBMPARAMETER + * |pbmp| identifies the algorithms, salt to use + * |msg| message to apply the PBM for + * |msglen| length of the message + * |sec| key to use + * |seclen| length of the key + * |mac| pointer to the computed mac, will be set on success + * |maclen| if not NULL, will set variable to the length of the mac on success + * returns 1 on success, 0 on error + */ +int OSSL_CRMF_pbm_new(const OSSL_CRMF_PBMPARAMETER *pbmp, + const unsigned char *msg, size_t msglen, + const unsigned char *sec, size_t seclen, + unsigned char **mac, size_t *maclen) +{ + int mac_nid, hmac_md_nid = NID_undef; + const EVP_MD *m = NULL; + EVP_MD_CTX *ctx = NULL; + unsigned char basekey[EVP_MAX_MD_SIZE]; + unsigned int bklen = EVP_MAX_MD_SIZE; + int64_t iterations; + unsigned char *mac_res = 0; + int ok = 0; + EVP_MAC_CTX *mctx = NULL; + + if (mac == NULL || pbmp == NULL || pbmp->mac == NULL + || pbmp->mac->algorithm == NULL || msg == NULL || sec == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_PBM_NEW, CRMF_R_NULL_ARGUMENT); + goto err; + } + if ((mac_res = OPENSSL_malloc(EVP_MAX_MD_SIZE)) == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_PBM_NEW, ERR_R_MALLOC_FAILURE); + goto err; + } + + /* + * owf identifies the hash algorithm and associated parameters used to + * compute the key used in the MAC process. All implementations MUST + * support SHA-1. + */ + if ((m = EVP_get_digestbyobj(pbmp->owf->algorithm)) == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_PBM_NEW, CRMF_R_UNSUPPORTED_ALGORITHM); + goto err; + } + + if ((ctx = EVP_MD_CTX_new()) == NULL) { + CRMFerr(CRMF_F_OSSL_CRMF_PBM_NEW, ERR_R_MALLOC_FAILURE); + goto err; + } + + /* compute the basekey of the salted secret */ + if (!EVP_DigestInit_ex(ctx, m, NULL)) + goto err; + /* first the secret */ + if (!EVP_DigestUpdate(ctx, sec, seclen)) + goto err; + /* then the salt */ + if (!EVP_DigestUpdate(ctx, pbmp->salt->data, pbmp->salt->length)) + goto err; + if (!EVP_DigestFinal_ex(ctx, basekey, &bklen)) + goto err; + if (!ASN1_INTEGER_get_int64(&iterations, pbmp->iterationCount) + || iterations < 100 /* min from RFC */ + || iterations > OSSL_CRMF_PBM_MAX_ITERATION_COUNT) { + CRMFerr(CRMF_F_OSSL_CRMF_PBM_NEW, CRMF_R_BAD_PBM_ITERATIONCOUNT); + goto err; + } + + /* the first iteration was already done above */ + while (--iterations > 0) { + if (!EVP_DigestInit_ex(ctx, m, NULL)) + goto err; + if (!EVP_DigestUpdate(ctx, basekey, bklen)) + goto err; + if (!EVP_DigestFinal_ex(ctx, basekey, &bklen)) + goto err; + } + + /* + * mac identifies the algorithm and associated parameters of the MAC + * function to be used. All implementations MUST support HMAC-SHA1 [HMAC]. + * All implementations SHOULD support DES-MAC and Triple-DES-MAC [PKCS11]. + */ + mac_nid = OBJ_obj2nid(pbmp->mac->algorithm); + + if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, mac_nid, NULL, &hmac_md_nid, NULL) + || ((m = EVP_get_digestbynid(hmac_md_nid)) == NULL)) { + CRMFerr(CRMF_F_OSSL_CRMF_PBM_NEW, CRMF_R_UNSUPPORTED_ALGORITHM); + goto err; + } + + if ((mctx = EVP_MAC_CTX_new(EVP_get_macbyname("HMAC"))) == NULL + || EVP_MAC_ctrl(mctx, EVP_MAC_CTRL_SET_MD, m) <= 0 + || EVP_MAC_ctrl(mctx, EVP_MAC_CTRL_SET_KEY, basekey, bklen) <= 0 + || !EVP_MAC_init(mctx) + || !EVP_MAC_update(mctx, msg, msglen) + || !EVP_MAC_final(mctx, mac_res, maclen)) + goto err; + + ok = 1; + + err: + /* cleanup */ + OPENSSL_cleanse(basekey, bklen); + EVP_MAC_CTX_free(mctx); + EVP_MD_CTX_free(ctx); + + if (ok == 1) { + *mac = mac_res; + return 1; + } + + OPENSSL_free(mac_res); + + if (pbmp != NULL && pbmp->mac != NULL) { + char buf[128]; + + if (OBJ_obj2txt(buf, sizeof(buf), pbmp->mac->algorithm, 0)) + ERR_add_error_data(1, buf); + } + return 0; +} diff --git a/crypto/ec/curve448/curve448.c b/crypto/ec/curve448/curve448.c index b06aa583..6236ad66 100644 --- a/crypto/ec/curve448/curve448.c +++ b/crypto/ec/curve448/curve448.c @@ -27,8 +27,8 @@ static const curve448_scalar_t precomputed_scalarmul_adjustment = { { { - SC_LIMB(0xc873d6d54a7bb0cf), SC_LIMB(0xe933d8d723a70aad), - SC_LIMB(0xbb124b65129c96fd), SC_LIMB(0x00000008335dc163) + SC_LIMB(0xc873d6d54a7bb0cfULL), SC_LIMB(0xe933d8d723a70aadULL), + SC_LIMB(0xbb124b65129c96fdULL), SC_LIMB(0x00000008335dc163ULL) } } }; diff --git a/crypto/ec/curve448/curve448_tables.c b/crypto/ec/curve448/curve448_tables.c index 4e6bc857..ec8ffcc3 100644 --- a/crypto/ec/curve448/curve448_tables.c +++ b/crypto/ec/curve448/curve448_tables.c @@ -16,325 +16,1045 @@ static const curve448_precomputed_s curve448_precomputed_base_table = { { {{ - {FIELD_LITERAL(0x00cc3b062366f4cc,0x003d6e34e314aa3c,0x00d51c0a7521774d,0x0094e060eec6ab8b,0x00d21291b4d80082,0x00befed12b55ef1e,0x00c3dd2df5c94518,0x00e0a7b112b8d4e6)}, - {FIELD_LITERAL(0x0019eb5608d8723a,0x00d1bab52fb3aedb,0x00270a7311ebc90c,0x0037c12b91be7f13,0x005be16cd8b5c704,0x003e181acda888e1,0x00bc1f00fc3fc6d0,0x00d3839bfa319e20)}, - {FIELD_LITERAL(0x003caeb88611909f,0x00ea8b378c4df3d4,0x00b3295b95a5a19a,0x00a65f97514bdfb5,0x00b39efba743cab1,0x0016ba98b862fd2d,0x0001508812ee71d7,0x000a75740eea114a)}, - }}, {{ - {FIELD_LITERAL(0x00ebcf0eb649f823,0x00166d332e98ea03,0x0059ddf64f5cd5f6,0x0047763123d9471b,0x00a64065c53ef62f,0x00978e44c480153d,0x000b5b2a0265f194,0x0046a24b9f32965a)}, - {FIELD_LITERAL(0x00b9eef787034df0,0x0020bc24de3390cd,0x000022160bae99bb,0x00ae66e886e97946,0x0048d4bbe02cbb8b,0x0072ba97b34e38d4,0x00eae7ec8f03e85a,0x005ba92ecf808b2c)}, - {FIELD_LITERAL(0x00c9cfbbe74258fd,0x00843a979ea9eaa7,0x000cbb4371cfbe90,0x0059bac8f7f0a628,0x004b3dff882ff530,0x0011869df4d90733,0x00595aa71f4abfc2,0x0070e2d38990c2e6)}, - }}, {{ - {FIELD_LITERAL(0x00de2010c0a01733,0x00c739a612e24297,0x00a7212643141d7c,0x00f88444f6b67c11,0x00484b7b16ec28f2,0x009c1b8856af9c68,0x00ff4669591fe9d6,0x0054974be08a32c8)}, - {FIELD_LITERAL(0x0010de3fd682ceed,0x008c07642d83ca4e,0x0013bb064e00a1cc,0x009411ae27870e11,0x00ea8e5b4d531223,0x0032fe7d2aaece2e,0x00d989e243e7bb41,0x000fe79a508e9b8b)}, - {FIELD_LITERAL(0x005e0426b9bfc5b1,0x0041a5b1d29ee4fa,0x0015b0def7774391,0x00bc164f1f51af01,0x00d543b0942797b9,0x003c129b6398099c,0x002b114c6e5adf18,0x00b4e630e4018a7b)}, - }}, {{ - {FIELD_LITERAL(0x00d490afc95f8420,0x00b096bf50c1d9b9,0x00799fd707679866,0x007c74d9334afbea,0x00efaa8be80ff4ed,0x0075c4943bb81694,0x00c21c2fca161f36,0x00e77035d492bfee)}, - {FIELD_LITERAL(0x006658a190dd6661,0x00e0e9bab38609a6,0x0028895c802237ed,0x006a0229c494f587,0x002dcde96c9916b7,0x00d158822de16218,0x00173b917a06856f,0x00ca78a79ae07326)}, - {FIELD_LITERAL(0x00e35bfc79caced4,0x0087238a3e1fe3bb,0x00bcbf0ff4ceff5b,0x00a19c1c94099b91,0x0071e102b49db976,0x0059e3d004eada1e,0x008da78afa58a47e,0x00579c8ebf269187)}, - }}, {{ - {FIELD_LITERAL(0x00a16c2905eee75f,0x009d4bcaea2c7e1d,0x00d3bd79bfad19df,0x0050da745193342c,0x006abdb8f6b29ab1,0x00a24fe0a4fef7ef,0x0063730da1057dfb,0x00a08c312c8eb108)}, - {FIELD_LITERAL(0x00b583be005375be,0x00a40c8f8a4e3df4,0x003fac4a8f5bdbf7,0x00d4481d872cd718,0x004dc8749cdbaefe,0x00cce740d5e5c975,0x000b1c1f4241fd21,0x00a76de1b4e1cd07)}, - {FIELD_LITERAL(0x007a076500d30b62,0x000a6e117b7f090f,0x00c8712ae7eebd9a,0x000fbd6c1d5f6ff7,0x003a7977246ebf11,0x00166ed969c6600e,0x00aa42e469c98bec,0x00dc58f307cf0666)}, - }}, {{ - {FIELD_LITERAL(0x004b491f65a9a28b,0x006a10309e8a55b7,0x00b67210185187ef,0x00cf6497b12d9b8f,0x0085778c56e2b1ba,0x0015b4c07a814d85,0x00686479e62da561,0x008de5d88f114916)}, - {FIELD_LITERAL(0x00e37c88d6bba7b1,0x003e4577e1b8d433,0x0050d8ea5f510ec0,0x0042fc9f2da9ef59,0x003bd074c1141420,0x00561b8b7b68774e,0x00232e5e5d1013a3,0x006b7f2cb3d7e73f)}, - {FIELD_LITERAL(0x004bdd0f0b41e6a0,0x001773057c405d24,0x006029f99915bd97,0x006a5ba70a17fe2f,0x0046111977df7e08,0x004d8124c89fb6b7,0x00580983b2bb2724,0x00207bf330d6f3fe)}, - }}, {{ - {FIELD_LITERAL(0x007efdc93972a48b,0x002f5e50e78d5fee,0x0080dc11d61c7fe5,0x0065aa598707245b,0x009abba2300641be,0x000c68787656543a,0x00ffe0fef2dc0a17,0x00007ffbd6cb4f3a)}, - {FIELD_LITERAL(0x0036012f2b836efc,0x00458c126d6b5fbc,0x00a34436d719ad1e,0x0097be6167117dea,0x0009c219c879cff3,0x0065564493e60755,0x00993ac94a8cdec0,0x002d4885a4d0dbaf)}, - {FIELD_LITERAL(0x00598b60b4c068ba,0x00c547a0be7f1afd,0x009582164acf12af,0x00af4acac4fbbe40,0x005f6ca7c539121a,0x003b6e752ebf9d66,0x00f08a30d5cac5d4,0x00e399bb5f97c5a9)}, - }}, {{ - {FIELD_LITERAL(0x007445a0409c0a66,0x00a65c369f3829c0,0x0031d248a4f74826,0x006817f34defbe8e,0x00649741d95ebf2e,0x00d46466ab16b397,0x00fdc35703bee414,0x00343b43334525f8)}, - {FIELD_LITERAL(0x001796bea93f6401,0x00090c5a42e85269,0x00672412ba1252ed,0x001201d47b6de7de,0x006877bccfe66497,0x00b554fd97a4c161,0x009753f42dbac3cf,0x00e983e3e378270a)}, - {FIELD_LITERAL(0x00ac3eff18849872,0x00f0eea3bff05690,0x00a6d72c21dd505d,0x001b832642424169,0x00a6813017b540e5,0x00a744bd71b385cd,0x0022a7d089130a7b,0x004edeec9a133486)}, - }}, {{ - {FIELD_LITERAL(0x00b2d6729196e8a9,0x0088a9bb2031cef4,0x00579e7787dc1567,0x0030f49feb059190,0x00a0b1d69c7f7d8f,0x0040bdcc6d9d806f,0x00d76c4037edd095,0x00bbf24376415dd7)}, - {FIELD_LITERAL(0x00240465ff5a7197,0x00bb97e76caf27d0,0x004b4edbf8116d39,0x001d8586f708cbaa,0x000f8ee8ff8e4a50,0x00dde5a1945dd622,0x00e6fc1c0957e07c,0x0041c9cdabfd88a0)}, - {FIELD_LITERAL(0x005344b0bf5b548c,0x002957d0b705cc99,0x00f586a70390553d,0x0075b3229f583cc3,0x00a1aa78227490e4,0x001bf09cf7957717,0x00cf6bf344325f52,0x0065bd1c23ca3ecf)}, - }}, {{ - {FIELD_LITERAL(0x009bff3b3239363c,0x00e17368796ef7c0,0x00528b0fe0971f3a,0x0008014fc8d4a095,0x00d09f2e8a521ec4,0x006713ab5dde5987,0x0003015758e0dbb1,0x00215999f1ba212d)}, - {FIELD_LITERAL(0x002c88e93527da0e,0x0077c78f3456aad5,0x0071087a0a389d1c,0x00934dac1fb96dbd,0x008470e801162697,0x005bc2196cd4ad49,0x00e535601d5087c3,0x00769888700f497f)}, - {FIELD_LITERAL(0x00da7a4b557298ad,0x0019d2589ea5df76,0x00ef3e38be0c6497,0x00a9644e1312609a,0x004592f61b2558da,0x0082c1df510d7e46,0x0042809a535c0023,0x00215bcb5afd7757)}, - }}, {{ - {FIELD_LITERAL(0x002b9df55a1a4213,0x00dcfc3b464a26be,0x00c4f9e07a8144d5,0x00c8e0617a92b602,0x008e3c93accafae0,0x00bf1bcb95b2ca60,0x004ce2426a613bf3,0x00266cac58e40921)}, - {FIELD_LITERAL(0x008456d5db76e8f0,0x0032ca9cab2ce163,0x0059f2b8bf91abcf,0x0063c2a021712788,0x00f86155af22f72d,0x00db98b2a6c005a0,0x00ac6e416a693ac4,0x007a93572af53226)}, - {FIELD_LITERAL(0x0087767520f0de22,0x0091f64012279fb5,0x001050f1f0644999,0x004f097a2477ad3c,0x006b37913a9947bd,0x001a3d78645af241,0x0057832bbb3008a7,0x002c1d902b80dc20)}, - }}, {{ - {FIELD_LITERAL(0x001a6002bf178877,0x009bce168aa5af50,0x005fc318ff04a7f5,0x0052818f55c36461,0x008768f5d4b24afb,0x0037ffbae7b69c85,0x0018195a4b61edc0,0x001e12ea088434b2)}, - {FIELD_LITERAL(0x0047d3f804e7ab07,0x00a809ab5f905260,0x00b3ffc7cdaf306d,0x00746e8ec2d6e509,0x00d0dade8887a645,0x00acceeebde0dd37,0x009bc2579054686b,0x0023804f97f1c2bf)}, - {FIELD_LITERAL(0x0043e2e2e50b80d7,0x00143aafe4427e0f,0x005594aaecab855b,0x008b12ccaaecbc01,0x002deeb091082bc3,0x009cca4be2ae7514,0x00142b96e696d047,0x00ad2a2b1c05256a)}, - }}, {{ - {FIELD_LITERAL(0x003914f2f144b78b,0x007a95dd8bee6f68,0x00c7f4384d61c8e6,0x004e51eb60f1bdb2,0x00f64be7aa4621d8,0x006797bfec2f0ac0,0x007d17aab3c75900,0x001893e73cac8bc5)}, - {FIELD_LITERAL(0x00140360b768665b,0x00b68aca4967f977,0x0001089b66195ae4,0x00fe71122185e725,0x000bca2618d49637,0x00a54f0557d7e98a,0x00cdcd2f91d6f417,0x00ab8c13741fd793)}, - {FIELD_LITERAL(0x00725ee6b1e549e0,0x007124a0769777fa,0x000b68fdad07ae42,0x0085b909cd4952df,0x0092d2e3c81606f4,0x009f22f6cac099a0,0x00f59da57f2799a8,0x00f06c090122f777)}, - }}, {{ - {FIELD_LITERAL(0x00ce0bed0a3532bc,0x001a5048a22df16b,0x00e31db4cbad8bf1,0x00e89292120cf00e,0x007d1dd1a9b00034,0x00e2a9041ff8f680,0x006a4c837ae596e7,0x00713af1068070b3)}, - {FIELD_LITERAL(0x00c4fe64ce66d04b,0x00b095d52e09b3d7,0x00758bbecb1a3a8e,0x00f35cce8d0650c0,0x002b878aa5984473,0x0062e0a3b7544ddc,0x00b25b290ed116fe,0x007b0f6abe0bebf2)}, - {FIELD_LITERAL(0x0081d4e3addae0a8,0x003410c836c7ffcc,0x00c8129ad89e4314,0x000e3d5a23922dcd,0x00d91e46f29c31f3,0x006c728cde8c5947,0x002bc655ba2566c0,0x002ca94721533108)}, - }}, {{ - {FIELD_LITERAL(0x0051e4b3f764d8a9,0x0019792d46e904a0,0x00853bc13dbc8227,0x000840208179f12d,0x0068243474879235,0x0013856fbfe374d0,0x00bda12fe8676424,0x00bbb43635926eb2)}, - {FIELD_LITERAL(0x0012cdc880a93982,0x003c495b21cd1b58,0x00b7e5c93f22a26e,0x0044aa82dfb99458,0x009ba092cdffe9c0,0x00a14b3ab2083b73,0x000271c2f70e1c4b,0x00eea9cac0f66eb8)}, - {FIELD_LITERAL(0x001a1847c4ac5480,0x00b1b412935bb03a,0x00f74285983bf2b2,0x00624138b5b5d0f1,0x008820c0b03d38bf,0x00b94e50a18c1572,0x0060f6934841798f,0x00c52f5d66d6ebe2)}, - }}, {{ - {FIELD_LITERAL(0x00da23d59f9bcea6,0x00e0f27007a06a4b,0x00128b5b43a6758c,0x000cf50190fa8b56,0x00fc877aba2b2d72,0x00623bef52edf53f,0x00e6af6b819669e2,0x00e314dc34fcaa4f)}, - {FIELD_LITERAL(0x0066e5eddd164d1e,0x00418a7c6fe28238,0x0002e2f37e962c25,0x00f01f56b5975306,0x0048842fa503875c,0x0057b0e968078143,0x00ff683024f3d134,0x0082ae28fcad12e4)}, - {FIELD_LITERAL(0x0011ddfd21260e42,0x00d05b0319a76892,0x00183ea4368e9b8f,0x00b0815662affc96,0x00b466a5e7ce7c88,0x00db93b07506e6ee,0x0033885f82f62401,0x0086f9090ec9b419)}, - }}, {{ - {FIELD_LITERAL(0x00d95d1c5fcb435a,0x0016d1ed6b5086f9,0x00792aa0b7e54d71,0x0067b65715f1925d,0x00a219755ec6176b,0x00bc3f026b12c28f,0x00700c897ffeb93e,0x0089b83f6ec50b46)}, - {FIELD_LITERAL(0x003c97e6384da36e,0x00423d53eac81a09,0x00b70d68f3cdce35,0x00ee7959b354b92c,0x00f4e9718819c8ca,0x009349f12acbffe9,0x005aee7b62cb7da6,0x00d97764154ffc86)}, - {FIELD_LITERAL(0x00526324babb46dc,0x002ee99b38d7bf9e,0x007ea51794706ef4,0x00abeb04da6e3c39,0x006b457c1d281060,0x00fe243e9a66c793,0x00378de0fb6c6ee4,0x003e4194b9c3cb93)}, - }}, {{ - {FIELD_LITERAL(0x00fed3cd80ca2292,0x0015b043a73ca613,0x000a9fd7bf9be227,0x003b5e03de2db983,0x005af72d46904ef7,0x00c0f1b5c49faa99,0x00dc86fc3bd305e1,0x00c92f08c1cb1797)}, - {FIELD_LITERAL(0x0079680ce111ed3b,0x001a1ed82806122c,0x000c2e7466d15df3,0x002c407f6f7150fd,0x00c5e7c96b1b0ce3,0x009aa44626863ff9,0x00887b8b5b80be42,0x00b6023cec964825)}, - {FIELD_LITERAL(0x00e4a8e1048970c8,0x0062887b7830a302,0x00bcf1c8cd81402b,0x0056dbb81a68f5be,0x0014eced83f12452,0x00139e1a510150df,0x00bb81140a82d1a3,0x000febcc1aaf1aa7)}, - }}, {{ - {FIELD_LITERAL(0x00a7527958238159,0x0013ec9537a84cd6,0x001d7fee7d562525,0x00b9eefa6191d5e5,0x00dbc97db70bcb8a,0x00481affc7a4d395,0x006f73d3e70c31bb,0x00183f324ed96a61)}, - {FIELD_LITERAL(0x0039dd7ce7fc6860,0x00d64f6425653da1,0x003e037c7f57d0af,0x0063477a06e2bcf2,0x001727dbb7ac67e6,0x0049589f5efafe2e,0x00fc0fef2e813d54,0x008baa5d087fb50d)}, - {FIELD_LITERAL(0x0024fb59d9b457c7,0x00a7d4e060223e4c,0x00c118d1b555fd80,0x0082e216c732f22a,0x00cd2a2993089504,0x003638e836a3e13d,0x000d855ee89b4729,0x008ec5b7d4810c91)}, - }}, {{ - {FIELD_LITERAL(0x001bf51f7d65cdfd,0x00d14cdafa16a97d,0x002c38e60fcd10e7,0x00a27446e393efbd,0x000b5d8946a71fdd,0x0063df2cde128f2f,0x006c8679569b1888,0x0059ffc4925d732d)}, - {FIELD_LITERAL(0x00ece96f95f2b66f,0x00ece7952813a27b,0x0026fc36592e489e,0x007157d1a2de0f66,0x00759dc111d86ddf,0x0012881e5780bb0f,0x00c8ccc83ad29496,0x0012b9bd1929eb71)}, - {FIELD_LITERAL(0x000fa15a20da5df0,0x00349ddb1a46cd31,0x002c512ad1d8e726,0x00047611f669318d,0x009e68fba591e17e,0x004320dffa803906,0x00a640874951a3d3,0x00b6353478baa24f)}, - }}, {{ - {FIELD_LITERAL(0x009696510000d333,0x00ec2f788bc04826,0x000e4d02b1f67ba5,0x00659aa8dace08b6,0x00d7a38a3a3ae533,0x008856defa8c746b,0x004d7a4402d3da1a,0x00ea82e06229260f)}, - {FIELD_LITERAL(0x006a15bb20f75c0c,0x0079a144027a5d0c,0x00d19116ce0b4d70,0x0059b83bcb0b268e,0x005f58f63f16c127,0x0079958318ee2c37,0x00defbb063d07f82,0x00f1f0b931d2d446)}, - {FIELD_LITERAL(0x00cb5e4c3c35d422,0x008df885ca43577f,0x00fa50b16ca3e471,0x005a0e58e17488c8,0x00b2ceccd6d34d19,0x00f01d5d235e36e9,0x00db2e7e4be6ca44,0x00260ab77f35fccd)}, - }}, {{ - {FIELD_LITERAL(0x006f6fd9baac61d5,0x002a7710a020a895,0x009de0db7fc03d4d,0x00cdedcb1875f40b,0x00050caf9b6b1e22,0x005e3a6654456ab0,0x00775fdf8c4423d4,0x0028701ea5738b5d)}, - {FIELD_LITERAL(0x009ffd90abfeae96,0x00cba3c2b624a516,0x005ef08bcee46c91,0x00e6fde30afb6185,0x00f0b4db4f818ce4,0x006c54f45d2127f5,0x00040125035854c7,0x00372658a3287e13)}, - {FIELD_LITERAL(0x00d7070fb1beb2ab,0x0078fc845a93896b,0x006894a4b2f224a6,0x005bdd8192b9dbde,0x00b38839874b3a9e,0x00f93618b04b7a57,0x003e3ec75fd2c67e,0x00bf5e6bfc29494a)}, - }}, {{ - {FIELD_LITERAL(0x00f19224ebba2aa5,0x0074f89d358e694d,0x00eea486597135ad,0x0081579a4555c7e1,0x0010b9b872930a9d,0x00f002e87a30ecc0,0x009b9d66b6de56e2,0x00a3c4f45e8004eb)}, - {FIELD_LITERAL(0x0045e8dda9400888,0x002ff12e5fc05db7,0x00a7098d54afe69c,0x00cdbe846a500585,0x00879c1593ca1882,0x003f7a7fea76c8b0,0x002cd73dd0c8e0a1,0x00645d6ce96f51fe)}, - {FIELD_LITERAL(0x002b7e83e123d6d6,0x00398346f7419c80,0x0042922e55940163,0x005e7fc5601886a3,0x00e88f2cee1d3103,0x00e7fab135f2e377,0x00b059984dbf0ded,0x0009ce080faa5bb8)}, - }}, {{ - {FIELD_LITERAL(0x0085e78af7758979,0x00275a4ee1631a3a,0x00d26bc0ed78b683,0x004f8355ea21064f,0x00d618e1a32696e5,0x008d8d7b150e5680,0x00a74cd854b278d2,0x001dd62702203ea0)}, - {FIELD_LITERAL(0x00f89335c2a59286,0x00a0f5c905d55141,0x00b41fb836ee9382,0x00e235d51730ca43,0x00a5cb37b5c0a69a,0x009b966ffe136c45,0x00cb2ea10bf80ed1,0x00fb2b370b40dc35)}, - {FIELD_LITERAL(0x00d687d16d4ee8ba,0x0071520bdd069dff,0x00de85c60d32355d,0x0087d2e3565102f4,0x00cde391b8dfc9aa,0x00e18d69efdfefe5,0x004a9d0591954e91,0x00fa36dd8b50eee5)}, - }}, {{ - {FIELD_LITERAL(0x002e788749a865f7,0x006e4dc3116861ea,0x009f1428c37276e6,0x00e7d2e0fc1e1226,0x003aeebc6b6c45f6,0x0071a8073bf500c9,0x004b22ad986b530c,0x00f439e63c0d79d4)}, - {FIELD_LITERAL(0x006bc3d53011f470,0x00032d6e692b83e8,0x00059722f497cd0b,0x0009b4e6f0c497cc,0x0058a804b7cce6c0,0x002b71d3302bbd5d,0x00e2f82a36765fce,0x008dded99524c703)}, - {FIELD_LITERAL(0x004d058953747d64,0x00701940fe79aa6f,0x00a620ac71c760bf,0x009532b611158b75,0x00547ed7f466f300,0x003cb5ab53a8401a,0x00c7763168ce3120,0x007e48e33e4b9ab2)}, - }}, {{ - {FIELD_LITERAL(0x001b2fc57bf3c738,0x006a3f918993fb80,0x0026f7a14fdec288,0x0075a2cdccef08db,0x00d3ecbc9eecdbf1,0x0048c40f06e5bf7f,0x00d63e423009896b,0x000598bc99c056a8)}, - {FIELD_LITERAL(0x002f194eaafa46dc,0x008e38f57fe87613,0x00dc8e5ae25f4ab2,0x000a17809575e6bd,0x00d3ec7923ba366a,0x003a7e72e0ad75e3,0x0010024b88436e0a,0x00ed3c5444b64051)}, - {FIELD_LITERAL(0x00831fc1340af342,0x00c9645669466d35,0x007692b4cc5a080f,0x009fd4a47ac9259f,0x001eeddf7d45928b,0x003c0446fc45f28b,0x002c0713aa3e2507,0x0095706935f0f41e)}, - }}, {{ - {FIELD_LITERAL(0x00766ae4190ec6d8,0x0065768cabc71380,0x00b902598416cdc2,0x00380021ad38df52,0x008f0b89d6551134,0x004254d4cc62c5a5,0x000d79f4484b9b94,0x00b516732ae3c50e)}, - {FIELD_LITERAL(0x001fb73475c45509,0x00d2b2e5ea43345a,0x00cb3c3842077bd1,0x0029f90ad820946e,0x007c11b2380778aa,0x009e54ece62c1704,0x004bc60c41ca01c3,0x004525679a5a0b03)}, - {FIELD_LITERAL(0x00c64fbddbed87b3,0x0040601d11731faa,0x009c22475b6f9d67,0x0024b79dae875f15,0x00616fed3f02c3b0,0x0000cf39f6af2d3b,0x00c46bac0aa9a688,0x00ab23e2800da204)}, - }}, {{ - {FIELD_LITERAL(0x000b3a37617632b0,0x00597199fe1cfb6c,0x0042a7ccdfeafdd6,0x004cc9f15ebcea17,0x00f436e596a6b4a4,0x00168861142df0d8,0x000753edfec26af5,0x000c495d7e388116)}, - {FIELD_LITERAL(0x0017085f4a346148,0x00c7cf7a37f62272,0x001776e129bc5c30,0x009955134c9eef2a,0x001ba5bdf1df07be,0x00ec39497103a55c,0x006578354fda6cfb,0x005f02719d4f15ee)}, - {FIELD_LITERAL(0x0052b9d9b5d9655d,0x00d4ec7ba1b461c3,0x00f95df4974f280b,0x003d8e5ca11aeb51,0x00d4981eb5a70b26,0x000af9a4f6659f29,0x004598c846faeb43,0x0049d9a183a47670)}, - }}, {{ - {FIELD_LITERAL(0x000a72d23dcb3f1f,0x00a3737f84011727,0x00f870c0fbbf4a47,0x00a7aadd04b5c9ca,0x000c7715c67bd072,0x00015a136afcd74e,0x0080d5caea499634,0x0026b448ec7514b7)}, - {FIELD_LITERAL(0x00b60167d9e7d065,0x00e60ba0d07381e8,0x003a4f17b725c2d4,0x006c19fe176b64fa,0x003b57b31af86ccb,0x0021047c286180fd,0x00bdc8fb00c6dbb6,0x00fe4a9f4bab4f3f)}, - {FIELD_LITERAL(0x0088ffc3a16111f7,0x009155e4245d0bc8,0x00851d68220572d5,0x00557ace1e514d29,0x0031d7c339d91022,0x00101d0ae2eaceea,0x00246ab3f837b66a,0x00d5216d381ff530)}, - }}, {{ - {FIELD_LITERAL(0x0057e7ea35f36dae,0x00f47d7ad15de22e,0x00d757ea4b105115,0x008311457d579d7e,0x00b49b75b1edd4eb,0x0081c7ff742fd63a,0x00ddda3187433df6,0x00475727d55f9c66)}, - {FIELD_LITERAL(0x00a6295218dc136a,0x00563b3af0e9c012,0x00d3753b0145db1b,0x004550389c043dc1,0x00ea94ae27401bdf,0x002b0b949f2b7956,0x00c63f780ad8e23c,0x00e591c47d6bab15)}, - {FIELD_LITERAL(0x00416c582b058eb6,0x004107da5b2cc695,0x00b3cd2556aeec64,0x00c0b418267e57a1,0x001799293579bd2e,0x0046ed44590e4d07,0x001d7459b3630a1e,0x00c6afba8b6696aa)}, - }}, {{ - {FIELD_LITERAL(0x008d6009b26da3f8,0x00898e88ca06b1ca,0x00edb22b2ed7fe62,0x00fbc93516aabe80,0x008b4b470c42ce0d,0x00e0032ba7d0dcbb,0x00d76da3a956ecc8,0x007f20fe74e3852a)}, - {FIELD_LITERAL(0x002419222c607674,0x00a7f23af89188b3,0x00ad127284e73d1c,0x008bba582fae1c51,0x00fc6aa7ca9ecab1,0x003df5319eb6c2ba,0x002a05af8a8b199a,0x004bf8354558407c)}, - {FIELD_LITERAL(0x00ce7d4a30f0fcbf,0x00d02c272629f03d,0x0048c001f7400bc2,0x002c21368011958d,0x0098a550391e96b5,0x002d80b66390f379,0x001fa878760cc785,0x001adfce54b613d5)}, - }}, {{ - {FIELD_LITERAL(0x001ed4dc71fa2523,0x005d0bff19bf9b5c,0x00c3801cee065a64,0x001ed0b504323fbf,0x0003ab9fdcbbc593,0x00df82070178b8d2,0x00a2bcaa9c251f85,0x00c628a3674bd02e)}, - {FIELD_LITERAL(0x006b7a0674f9f8de,0x00a742414e5c7cff,0x0041cbf3c6e13221,0x00e3a64fd207af24,0x0087c05f15fbe8d1,0x004c50936d9e8a33,0x001306ec21042b6d,0x00a4f4137d1141c2)}, - {FIELD_LITERAL(0x0009e6fb921568b0,0x00b3c60120219118,0x002a6c3460dd503a,0x009db1ef11654b54,0x0063e4bf0be79601,0x00670d34bb2592b9,0x00dcee2f6c4130ce,0x00b2682e88e77f54)}, - }}, {{ - {FIELD_LITERAL(0x000d5b4b3da135ab,0x00838f3e5064d81d,0x00d44eb50f6d94ed,0x0008931ab502ac6d,0x00debe01ca3d3586,0x0025c206775f0641,0x005ad4b6ae912763,0x007e2c318ad8f247)}, - {FIELD_LITERAL(0x00ddbe0750dd1add,0x004b3c7b885844b8,0x00363e7ecf12f1ae,0x0062e953e6438f9d,0x0023cc73b076afe9,0x00b09fa083b4da32,0x00c7c3d2456c541d,0x005b591ec6b694d4)}, - {FIELD_LITERAL(0x0028656e19d62fcf,0x0052a4af03df148d,0x00122765ddd14e42,0x00f2252904f67157,0x004741965b636f3a,0x006441d296132cb9,0x005e2106f956a5b7,0x00247029592d335c)}, - }}, {{ - {FIELD_LITERAL(0x003fe038eb92f894,0x000e6da1b72e8e32,0x003a1411bfcbe0fa,0x00b55d473164a9e4,0x00b9a775ac2df48d,0x0002ddf350659e21,0x00a279a69eb19cb3,0x00f844eab25cba44)}, - {FIELD_LITERAL(0x00c41d1f9c1f1ac1,0x007b2df4e9f19146,0x00b469355fd5ba7a,0x00b5e1965afc852a,0x00388d5f1e2d8217,0x0022079e4c09ae93,0x0014268acd4ef518,0x00c1dd8d9640464c)}, - {FIELD_LITERAL(0x0038526adeed0c55,0x00dd68c607e3fe85,0x00f746ddd48a5d57,0x0042f2952b963b7c,0x001cbbd6876d5ec2,0x005e341470bca5c2,0x00871d41e085f413,0x00e53ab098f45732)}, - }}, {{ - {FIELD_LITERAL(0x004d51124797c831,0x008f5ae3750347ad,0x0070ced94c1a0c8e,0x00f6db2043898e64,0x000d00c9a5750cd0,0x000741ec59bad712,0x003c9d11aab37b7f,0x00a67ba169807714)}, - {FIELD_LITERAL(0x00adb2c1566e8b8f,0x0096c68a35771a9a,0x00869933356f334a,0x00ba9c93459f5962,0x009ec73fb6e8ca4b,0x003c3802c27202e1,0x0031f5b733e0c008,0x00f9058c19611fa9)}, - {FIELD_LITERAL(0x00238f01814a3421,0x00c325a44b6cce28,0x002136f97aeb0e73,0x000cac8268a4afe2,0x0022fd218da471b3,0x009dcd8dfff8def9,0x00cb9f8181d999bb,0x00143ae56edea349)}, - }}, {{ - {FIELD_LITERAL(0x0000623bf87622c5,0x00a1966fdd069496,0x00c315b7b812f9fc,0x00bdf5efcd128b97,0x001d464f532e3e16,0x003cd94f081bfd7e,0x00ed9dae12ce4009,0x002756f5736eee70)}, - {FIELD_LITERAL(0x00a5187e6ee7341b,0x00e6d52e82d83b6e,0x00df3c41323094a7,0x00b3324f444e9de9,0x00689eb21a35bfe5,0x00f16363becd548d,0x00e187cc98e7f60f,0x00127d9062f0ccab)}, - {FIELD_LITERAL(0x004ad71b31c29e40,0x00a5fcace12fae29,0x004425b5597280ed,0x00e7ef5d716c3346,0x0010b53ada410ac8,0x0092310226060c9b,0x0091c26128729c7e,0x0088b42900f8ec3b)}, - }}, {{ - {FIELD_LITERAL(0x00f1e26e9762d4a8,0x00d9d74082183414,0x00ffec9bd57a0282,0x000919e128fd497a,0x00ab7ae7d00fe5f8,0x0054dc442851ff68,0x00c9ebeb3b861687,0x00507f7cab8b698f)}, - {FIELD_LITERAL(0x00c13c5aae3ae341,0x009c6c9ed98373e7,0x00098f26864577a8,0x0015b886e9488b45,0x0037692c42aadba5,0x00b83170b8e7791c,0x001670952ece1b44,0x00fd932a39276da2)}, - {FIELD_LITERAL(0x0081a3259bef3398,0x005480fff416107b,0x00ce4f607d21be98,0x003ffc084b41df9b,0x0043d0bb100502d1,0x00ec35f575ba3261,0x00ca18f677300ef3,0x00e8bb0a827d8548)}, - }}, {{ - {FIELD_LITERAL(0x00df76b3328ada72,0x002e20621604a7c2,0x00f910638a105b09,0x00ef4724d96ef2cd,0x00377d83d6b8a2f7,0x00b4f48805ade324,0x001cd5da8b152018,0x0045af671a20ca7f)}, - {FIELD_LITERAL(0x009ae3b93a56c404,0x004a410b7a456699,0x00023a619355e6b2,0x009cdc7297387257,0x0055b94d4ae70d04,0x002cbd607f65b005,0x003208b489697166,0x00ea2aa058867370)}, - {FIELD_LITERAL(0x00f29d2598ee3f32,0x00b4ac5385d82adc,0x007633eaf04df19b,0x00aa2d3d77ceab01,0x004a2302fcbb778a,0x00927f225d5afa34,0x004a8e9d5047f237,0x008224ae9dbce530)}, - }}, {{ - {FIELD_LITERAL(0x001cf640859b02f8,0x00758d1d5d5ce427,0x00763c784ef4604c,0x005fa81aee205270,0x00ac537bfdfc44cb,0x004b919bd342d670,0x00238508d9bf4b7a,0x00154888795644f3)}, - {FIELD_LITERAL(0x00c845923c084294,0x00072419a201bc25,0x0045f408b5f8e669,0x00e9d6a186b74dfe,0x00e19108c68fa075,0x0017b91d874177b7,0x002f0ca2c7912c5a,0x009400aa385a90a2)}, - {FIELD_LITERAL(0x0071110b01482184,0x00cfed0044f2bef8,0x0034f2901cf4662e,0x003b4ae2a67f9834,0x00cca9b96fe94810,0x00522507ae77abd0,0x00bac7422721e73e,0x0066622b0f3a62b0)}, - }}, {{ - {FIELD_LITERAL(0x00f8ac5cf4705b6a,0x00867d82dcb457e3,0x007e13ab2ccc2ce9,0x009ee9a018d3930e,0x008370f8ecb42df8,0x002d9f019add263e,0x003302385b92d196,0x00a15654536e2c0c)}, - {FIELD_LITERAL(0x0026ef1614e160af,0x00c023f9edfc9c76,0x00cff090da5f57ba,0x0076db7a66643ae9,0x0019462f8c646999,0x008fec00b3854b22,0x00d55041692a0a1c,0x0065db894215ca00)}, - {FIELD_LITERAL(0x00a925036e0a451c,0x002a0390c36b6cc1,0x00f27020d90894f4,0x008d90d52cbd3d7f,0x00e1d0137392f3b8,0x00f017c158b51a8f,0x00cac313d3ed7dbc,0x00b99a81e3eb42d3)}, - }}, {{ - {FIELD_LITERAL(0x00b54850275fe626,0x0053a3fd1ec71140,0x00e3d2d7dbe096fa,0x00e4ac7b595cce4c,0x0077bad449c0a494,0x00b7c98814afd5b3,0x0057226f58486cf9,0x00b1557154f0cc57)}, - {FIELD_LITERAL(0x008cc9cd236315c0,0x0031d9c5b39fda54,0x00a5713ef37e1171,0x00293d5ae2886325,0x00c4aba3e05015e1,0x0003f35ef78e4fc6,0x0039d6bd3ac1527b,0x0019d7c3afb77106)}, - {FIELD_LITERAL(0x007b162931a985af,0x00ad40a2e0daa713,0x006df27c4009f118,0x00503e9f4e2e8bec,0x00751a77c82c182d,0x000298937769245b,0x00ffb1e8fabf9ee5,0x0008334706e09abe)}, - }}, {{ - {FIELD_LITERAL(0x00dbca4e98a7dcd9,0x00ee29cfc78bde99,0x00e4a3b6995f52e9,0x0045d70189ae8096,0x00fd2a8a3b9b0d1b,0x00af1793b107d8e1,0x00dbf92cbe4afa20,0x00da60f798e3681d)}, - {FIELD_LITERAL(0x004246bfcecc627a,0x004ba431246c03a4,0x00bd1d101872d497,0x003b73d3f185ee16,0x001feb2e2678c0e3,0x00ff13c5a89dec76,0x00ed06042e771d8f,0x00a4fd2a897a83dd)}, - {FIELD_LITERAL(0x009a4a3be50d6597,0x00de3165fc5a1096,0x004f3f56e345b0c7,0x00f7bf721d5ab8bc,0x004313e47b098c50,0x00e4c7d5c0e1adbb,0x002e3e3db365051e,0x00a480c2cd6a96fb)}, - }}, {{ - {FIELD_LITERAL(0x00417fa30a7119ed,0x00af257758419751,0x00d358a487b463d4,0x0089703cc720b00d,0x00ce56314ff7f271,0x0064db171ade62c1,0x00640b36d4a22fed,0x00424eb88696d23f)}, - {FIELD_LITERAL(0x004ede34af2813f3,0x00d4a8e11c9e8216,0x004796d5041de8a5,0x00c4c6b4d21cc987,0x00e8a433ee07fa1e,0x0055720b5abcc5a1,0x008873ea9c74b080,0x005b3fec1ab65d48)}, - {FIELD_LITERAL(0x0047e5277db70ec5,0x000a096c66db7d6b,0x00b4164cc1730159,0x004a9f783fe720fe,0x00a8177b94449dbc,0x0095a24ff49a599f,0x0069c1c578250cbc,0x00452019213debf4)}, - }}, {{ - {FIELD_LITERAL(0x0021ce99e09ebda3,0x00fcbd9f91875ad0,0x009bbf6b7b7a0b5f,0x00388886a69b1940,0x00926a56d0f81f12,0x00e12903c3358d46,0x005dfce4e8e1ce9d,0x0044cfa94e2f7e23)}, - {FIELD_LITERAL(0x001bd59c09e982ea,0x00f72daeb937b289,0x0018b76dca908e0e,0x00edb498512384ad,0x00ce0243b6cc9538,0x00f96ff690cb4e70,0x007c77bf9f673c8d,0x005bf704c088a528)}, - {FIELD_LITERAL(0x0093d4628dcb33be,0x0095263d51d42582,0x0049b3222458fe06,0x00e7fce73b653a7f,0x003ca2ebce60b369,0x00c5de239a32bea4,0x0063b8b3d71fb6bf,0x0039aeeb78a1a839)}, - }}, {{ - {FIELD_LITERAL(0x007dc52da400336c,0x001fded1e15b9457,0x00902e00f5568e3a,0x00219bef40456d2d,0x005684161fb3dbc9,0x004a4e9be49a76ea,0x006e685ae88b78ff,0x0021c42f13042d3c)}, - {FIELD_LITERAL(0x00fb22bb5fd3ce50,0x0017b48aada7ae54,0x00fd5c44ad19a536,0x000ccc4e4e55e45c,0x00fd637d45b4c3f5,0x0038914e023c37cf,0x00ac1881d6a8d898,0x00611ed8d3d943a8)}, - {FIELD_LITERAL(0x0056e2259d113d2b,0x00594819b284ec16,0x00c7bf794bb36696,0x00721ee75097cdc6,0x00f71be9047a2892,0x00df6ba142564edf,0x0069580b7a184e8d,0x00f056e38fca0fee)}, - }}, {{ - {FIELD_LITERAL(0x009df98566a18c6d,0x00cf3a200968f219,0x0044ba60da6d9086,0x00dbc9c0e344da03,0x000f9401c4466855,0x00d46a57c5b0a8d1,0x00875a635d7ac7c6,0x00ef4a933b7e0ae6)}, - {FIELD_LITERAL(0x005e8694077a1535,0x008bef75f71c8f1d,0x000a7c1316423511,0x00906e1d70604320,0x003fc46c1a2ffbd6,0x00d1d5022e68f360,0x002515fba37bbf46,0x00ca16234e023b44)}, - {FIELD_LITERAL(0x00787c99561f4690,0x00a857a8c1561f27,0x00a10df9223c09fe,0x00b98a9562e3b154,0x004330b8744c3ed2,0x00e06812807ec5c4,0x00e4cf6a7db9f1e3,0x00d95b089f132a34)}, - }}, {{ - {FIELD_LITERAL(0x002922b39ca33eec,0x0090d12a5f3ab194,0x00ab60c02fb5f8ed,0x00188d292abba1cf,0x00e10edec9698f6e,0x0069a4d9934133c8,0x0024aac40e6d3d06,0x001702c2177661b0)}, - {FIELD_LITERAL(0x00139078397030bd,0x000e3c447e859a00,0x0064a5b334c82393,0x00b8aabeb7358093,0x00020778bb9ae73b,0x0032ee94c7892a18,0x008215253cb41bda,0x005e2797593517ae)}, - {FIELD_LITERAL(0x0083765a5f855d4a,0x0051b6d1351b8ee2,0x00116de548b0f7bb,0x0087bd88703affa0,0x0095b2cc34d7fdd2,0x0084cd81b53f0bc8,0x008562fc995350ed,0x00a39abb193651e3)}, - }}, {{ - {FIELD_LITERAL(0x0019e23f0474b114,0x00eb94c2ad3b437e,0x006ddb34683b75ac,0x00391f9209b564c6,0x00083b3bb3bff7aa,0x00eedcd0f6dceefc,0x00b50817f794fe01,0x0036474deaaa75c9)}, - {FIELD_LITERAL(0x0091868594265aa2,0x00797accae98ca6d,0x0008d8c5f0f8a184,0x00d1f4f1c2b2fe6e,0x0036783dfb48a006,0x008c165120503527,0x0025fd780058ce9b,0x0068beb007be7d27)}, - {FIELD_LITERAL(0x00d0ff88aa7c90c2,0x00b2c60dacf53394,0x0094a7284d9666d6,0x00bed9022ce7a19d,0x00c51553f0cd7682,0x00c3fb870b124992,0x008d0bc539956c9b,0x00fc8cf258bb8885)}, - }}, {{ - {FIELD_LITERAL(0x003667bf998406f8,0x0000115c43a12975,0x001e662f3b20e8fd,0x0019ffa534cb24eb,0x00016be0dc8efb45,0x00ff76a8b26243f5,0x00ae20d241a541e3,0x0069bd6af13cd430)}, - {FIELD_LITERAL(0x0045fdc16487cda3,0x00b2d8e844cf2ed7,0x00612c50e88c1607,0x00a08aabc66c1672,0x006031fdcbb24d97,0x001b639525744b93,0x004409d62639ab17,0x00a1853d0347ab1d)}, - {FIELD_LITERAL(0x0075a1a56ebf5c21,0x00a3e72be9ac53ed,0x00efcde1629170c2,0x0004225fe91ef535,0x0088049fc73dfda7,0x004abc74857e1288,0x0024e2434657317c,0x00d98cb3d3e5543c)}, - }}, {{ - {FIELD_LITERAL(0x00b4b53eab6bdb19,0x009b22d8b43711d0,0x00d948b9d961785d,0x00cb167b6f279ead,0x00191de3a678e1c9,0x00d9dd9511095c2e,0x00f284324cd43067,0x00ed74fa535151dd)}, - {FIELD_LITERAL(0x007e32c049b5c477,0x009d2bfdbd9bcfd8,0x00636e93045938c6,0x007fde4af7687298,0x0046a5184fafa5d3,0x0079b1e7f13a359b,0x00875adf1fb927d6,0x00333e21c61bcad2)}, - {FIELD_LITERAL(0x00048014f73d8b8d,0x0075684aa0966388,0x0092be7df06dc47c,0x0097cebcd0f5568a,0x005a7004d9c4c6a9,0x00b0ecbb659924c7,0x00d90332dd492a7c,0x0057fc14df11493d)}, - }}, {{ - {FIELD_LITERAL(0x0008ed8ea0ad95be,0x0041d324b9709645,0x00e25412257a19b4,0x0058df9f3423d8d2,0x00a9ab20def71304,0x009ae0dbf8ac4a81,0x00c9565977e4392a,0x003c9269444baf55)}, - {FIELD_LITERAL(0x007df6cbb926830b,0x00d336058ae37865,0x007af47dac696423,0x0048d3011ec64ac8,0x006b87666e40049f,0x0036a2e0e51303d7,0x00ba319bd79dbc55,0x003e2737ecc94f53)}, - {FIELD_LITERAL(0x00d296ff726272d9,0x00f6d097928fcf57,0x00e0e616a55d7013,0x00deaf454ed9eac7,0x0073a56bedef4d92,0x006ccfdf6fc92e19,0x009d1ee1371a7218,0x00ee3c2ee4462d80)}, - }}, {{ - {FIELD_LITERAL(0x00437bce9bccdf9d,0x00e0c8e2f85dc0a3,0x00c91a7073995a19,0x00856ec9fe294559,0x009e4b33394b156e,0x00e245b0dc497e5c,0x006a54e687eeaeff,0x00f1cd1cd00fdb7c)}, - {FIELD_LITERAL(0x008132ae5c5d8cd1,0x00121d68324a1d9f,0x00d6be9dafcb8c76,0x00684d9070edf745,0x00519fbc96d7448e,0x00388182fdc1f27e,0x000235baed41f158,0x00bf6cf6f1a1796a)}, - {FIELD_LITERAL(0x002adc4b4d148219,0x003084ada0d3a90a,0x0046de8aab0f2e4e,0x00452d342a67b5fd,0x00d4b50f01d4de21,0x00db6d9fc0cefb79,0x008c184c86a462cd,0x00e17c83764d42da)}, - }}, {{ - {FIELD_LITERAL(0x007b2743b9a1e01a,0x007847ffd42688c4,0x006c7844d610a316,0x00f0cb8b250aa4b0,0x00a19060143b3ae6,0x0014eb10b77cfd80,0x000170905729dd06,0x00063b5b9cd72477)}, - {FIELD_LITERAL(0x00ce382dc7993d92,0x00021153e938b4c8,0x00096f7567f48f51,0x0058f81ddfe4b0d5,0x00cc379a56b355c7,0x002c760770d3e819,0x00ee22d1d26e5a40,0x00de6d93d5b082d7)}, - {FIELD_LITERAL(0x000a91a42c52e056,0x00185f6b77fce7ea,0x000803c51962f6b5,0x0022528582ba563d,0x0043f8040e9856d6,0x0085a29ec81fb860,0x005f9a611549f5ff,0x00c1f974ecbd4b06)}, - }}, {{ - {FIELD_LITERAL(0x005b64c6fd65ec97,0x00c1fdd7f877bc7f,0x000d9cc6c89f841c,0x005c97b7f1aff9ad,0x0075e3c61475d47e,0x001ecb1ba8153011,0x00fe7f1c8d71d40d,0x003fa9757a229832)}, - {FIELD_LITERAL(0x00ffc5c89d2b0cba,0x00d363d42e3e6fc3,0x0019a1a0118e2e8a,0x00f7baeff48882e1,0x001bd5af28c6b514,0x0055476ca2253cb2,0x00d8eb1977e2ddf3,0x00b173b1adb228a1)}, - {FIELD_LITERAL(0x00f2cb99dd0ad707,0x00e1e08b6859ddd8,0x000008f2d0650bcc,0x00d7ed392f8615c3,0x00976750a94da27f,0x003e83bb0ecb69ba,0x00df8e8d15c14ac6,0x00f9f7174295d9c2)}, - }}, {{ - {FIELD_LITERAL(0x00f11cc8e0e70bcb,0x00e5dc689974e7dd,0x0014e409f9ee5870,0x00826e6689acbd63,0x008a6f4e3d895d88,0x00b26a8da41fd4ad,0x000fb7723f83efd7,0x009c749db0a5f6c3)}, - {FIELD_LITERAL(0x002389319450f9ba,0x003677f31aa1250a,0x0092c3db642f38cb,0x00f8b64c0dfc9773,0x00cd49fe3505b795,0x0068105a4090a510,0x00df0ba2072a8bb6,0x00eb396143afd8be)}, - {FIELD_LITERAL(0x00a0d4ecfb24cdff,0x00ddaf8008ba6479,0x00f0b3e36d4b0f44,0x003734bd3af1f146,0x00b87e2efc75527e,0x00d230df55ddab50,0x002613257ae56c1d,0x00bc0946d135934d)}, - }}, {{ - {FIELD_LITERAL(0x00468711bd994651,0x0033108fa67561bf,0x0089d760192a54b4,0x00adc433de9f1871,0x000467d05f36e050,0x007847e0f0579f7f,0x00a2314ad320052d,0x00b3a93649f0b243)}, - {FIELD_LITERAL(0x0067f8f0c4fe26c9,0x0079c4a3cc8f67b9,0x0082b1e62f23550d,0x00f2d409caefd7f5,0x0080e67dcdb26e81,0x0087ae993ea1f98a,0x00aa108becf61d03,0x001acf11efb608a3)}, - {FIELD_LITERAL(0x008225febbab50d9,0x00f3b605e4dd2083,0x00a32b28189e23d2,0x00d507e5e5eb4c97,0x005a1a84e302821f,0x0006f54c1c5f08c7,0x00a347c8cb2843f0,0x0009f73e9544bfa5)}, - }}, {{ - {FIELD_LITERAL(0x006c59c9ae744185,0x009fc32f1b4282cd,0x004d6348ca59b1ac,0x00105376881be067,0x00af4096013147dc,0x004abfb5a5cb3124,0x000d2a7f8626c354,0x009c6ed568e07431)}, - {FIELD_LITERAL(0x00e828333c297f8b,0x009ef3cf8c3f7e1f,0x00ab45f8fff31cb9,0x00c8b4178cb0b013,0x00d0c50dd3260a3f,0x0097126ac257f5bc,0x0042376cc90c705a,0x001d96fdb4a1071e)}, - {FIELD_LITERAL(0x00542d44d89ee1a8,0x00306642e0442d98,0x0090853872b87338,0x002362cbf22dc044,0x002c222adff663b8,0x0067c924495fcb79,0x000e621d983c977c,0x00df77a9eccb66fb)}, - }}, {{ - {FIELD_LITERAL(0x002809e4bbf1814a,0x00b9e854f9fafb32,0x00d35e67c10f7a67,0x008f1bcb76e748cf,0x004224d9515687d2,0x005ba0b774e620c4,0x00b5e57db5d54119,0x00e15babe5683282)}, - {FIELD_LITERAL(0x00832d02369b482c,0x00cba52ff0d93450,0x003fa9c908d554db,0x008d1e357b54122f,0x00abd91c2dc950c6,0x007eff1df4c0ec69,0x003f6aeb13fb2d31,0x00002d6179fc5b2c)}, - {FIELD_LITERAL(0x0046c9eda81c9c89,0x00b60cb71c8f62fc,0x0022f5a683baa558,0x00f87319fccdf997,0x009ca09b51ce6a22,0x005b12baf4af7d77,0x008a46524a1e33e2,0x00035a77e988be0d)}, - }}, {{ - {FIELD_LITERAL(0x00a7efe46a7dbe2f,0x002f66fd55014fe7,0x006a428afa1ff026,0x0056caaa9604ab72,0x0033f3bcd7fac8ae,0x00ccb1aa01c86764,0x00158d1edf13bf40,0x009848ee76fcf3b4)}, - {FIELD_LITERAL(0x00a9e7730a819691,0x00d9cc73c4992b70,0x00e299bde067de5a,0x008c314eb705192a,0x00e7226f17e8a3cc,0x0029dfd956e65a47,0x0053a8e839073b12,0x006f942b2ab1597e)}, - {FIELD_LITERAL(0x001c3d780ecd5e39,0x0094f247fbdcc5fe,0x00d5c786fd527764,0x00b6f4da74f0db2a,0x0080f1f8badcd5fc,0x00f36a373ad2e23b,0x00f804f9f4343bf2,0x00d1af40ec623982)}, - }}, {{ - {FIELD_LITERAL(0x0082aeace5f1b144,0x00f68b3108cf4dd3,0x00634af01dde3020,0x000beab5df5c2355,0x00e8b790d1b49b0b,0x00e48d15854e36f4,0x0040ab2d95f3db9f,0x002711c4ed9e899a)}, - {FIELD_LITERAL(0x0039343746531ebe,0x00c8509d835d429d,0x00e79eceff6b0018,0x004abfd31e8efce5,0x007bbfaaa1e20210,0x00e3be89c193e179,0x001c420f4c31d585,0x00f414a315bef5ae)}, - {FIELD_LITERAL(0x007c296a24990df8,0x00d5d07525a75588,0x00dd8e113e94b7e7,0x007bbc58febe0cc8,0x0029f51af9bfcad3,0x007e9311ec7ab6f3,0x009a884de1676343,0x0050d5f2dce84be9)}, - }}, {{ - {FIELD_LITERAL(0x005fa020cca2450a,0x00491c29db6416d8,0x0037cefe3f9f9a85,0x003d405230647066,0x0049e835f0fdbe89,0x00feb78ac1a0815c,0x00828e4b32dc9724,0x00db84f2dc8d6fd4)}, - {FIELD_LITERAL(0x0098cddc8b39549a,0x006da37e3b05d22c,0x00ce633cfd4eb3cb,0x00fda288ef526acd,0x0025338878c5d30a,0x00f34438c4e5a1b4,0x00584efea7c310f1,0x0041a551f1b660ad)}, - {FIELD_LITERAL(0x00d7f7a8fbd6437a,0x0062872413bf3753,0x00ad4bbcb43c584b,0x007fe49be601d7e3,0x0077c659789babf4,0x00eb45fcb06a741b,0x005ce244913f9708,0x0088426401736326)}, - }}, {{ - {FIELD_LITERAL(0x007bf562ca768d7c,0x006c1f3a174e387c,0x00f024b447fee939,0x007e7af75f01143f,0x003adb70b4eed89d,0x00e43544021ad79a,0x0091f7f7042011f6,0x0093c1a1ee3a0ddc)}, - {FIELD_LITERAL(0x00a0b68ec1eb72d2,0x002c03235c0d45a0,0x00553627323fe8c5,0x006186e94b17af94,0x00a9906196e29f14,0x0025b3aee6567733,0x007e0dd840080517,0x0018eb5801a4ba93)}, - {FIELD_LITERAL(0x00d7fe7017bf6a40,0x006e3f0624be0c42,0x00ffbba205358245,0x00f9fc2cf8194239,0x008d93b37bf15b4e,0x006ddf2e38be8e95,0x002b6e79bf5fcff9,0x00ab355da425e2de)}, - }}, {{ - {FIELD_LITERAL(0x00938f97e20be973,0x0099141a36aaf306,0x0057b0ca29e545a1,0x0085db571f9fbc13,0x008b333c554b4693,0x0043ab6ef3e241cb,0x0054fb20aa1e5c70,0x00be0ff852760adf)}, - {FIELD_LITERAL(0x003973d8938971d6,0x002aca26fa80c1f5,0x00108af1faa6b513,0x00daae275d7924e6,0x0053634ced721308,0x00d2355fe0bbd443,0x00357612b2d22095,0x00f9bb9dd4136cf3)}, - {FIELD_LITERAL(0x002bff12cf5e03a5,0x001bdb1fa8a19cf8,0x00c91c6793f84d39,0x00f869f1b2eba9af,0x0059bc547dc3236b,0x00d91611d6d38689,0x00e062daaa2c0214,0x00ed3c047cc2bc82)}, - }}, {{ - {FIELD_LITERAL(0x000050d70c32b31a,0x001939d576d437b3,0x00d709e598bf9fe6,0x00a885b34bd2ee9e,0x00dd4b5c08ab1a50,0x0091bebd50b55639,0x00cf79ff64acdbc6,0x006067a39d826336)}, - {FIELD_LITERAL(0x0062dd0fb31be374,0x00fcc96b84c8e727,0x003f64f1375e6ae3,0x0057d9b6dd1af004,0x00d6a167b1103c7b,0x00dd28f3180fb537,0x004ff27ad7167128,0x008934c33461f2ac)}, - {FIELD_LITERAL(0x0065b472b7900043,0x00ba7efd2ff1064b,0x000b67d6c4c3020f,0x0012d28469f4e46d,0x0031c32939703ec7,0x00b49f0bce133066,0x00f7e10416181d47,0x005c90f51867eecc)}, - }}, {{ - {FIELD_LITERAL(0x0051207abd179101,0x00fc2a5c20d9c5da,0x00fb9d5f2701b6df,0x002dd040fdea82b8,0x00f163b0738442ff,0x00d9736bd68855b8,0x00e0d8e93005e61c,0x00df5a40b3988570)}, - {FIELD_LITERAL(0x0006918f5dfce6dc,0x00d4bf1c793c57fb,0x0069a3f649435364,0x00e89a50e5b0cd6e,0x00b9f6a237e973af,0x006d4ed8b104e41d,0x00498946a3924cd2,0x00c136ec5ac9d4f7)}, - {FIELD_LITERAL(0x0011a9c290ac5336,0x002b9a2d4a6a6533,0x009a8a68c445d937,0x00361b27b07e5e5c,0x003c043b1755b974,0x00b7eb66cf1155ee,0x0077af5909eefff2,0x0098f609877cc806)}, - }}, {{ - {FIELD_LITERAL(0x00ab13af436bf8f4,0x000bcf0a0dac8574,0x00d50c864f705045,0x00c40e611debc842,0x0085010489bd5caa,0x007c5050acec026f,0x00f67d943c8da6d1,0x00de1da0278074c6)}, - {FIELD_LITERAL(0x00b373076597455f,0x00e83f1af53ac0f5,0x0041f63c01dc6840,0x0097dea19b0c6f4b,0x007f9d63b4c1572c,0x00e692d492d0f5f0,0x00cbcb392e83b4ad,0x0069c0f39ed9b1a8)}, - {FIELD_LITERAL(0x00861030012707c9,0x009fbbdc7fd4aafb,0x008f591d6b554822,0x00df08a41ea18ade,0x009d7d83e642abea,0x0098c71bda3b78ff,0x0022c89e7021f005,0x0044d29a3fe1e3c4)}, - }}, {{ - {FIELD_LITERAL(0x00e748cd7b5c52f2,0x00ea9df883f89cc3,0x0018970df156b6c7,0x00c5a46c2a33a847,0x00cbde395e32aa09,0x0072474ebb423140,0x00fb00053086a23d,0x001dafcfe22d4e1f)}, - {FIELD_LITERAL(0x00c903ee6d825540,0x00add6c4cf98473e,0x007636efed4227f1,0x00905124ae55e772,0x00e6b38fab12ed53,0x0045e132b863fe55,0x003974662edb366a,0x00b1787052be8208)}, - {FIELD_LITERAL(0x00a614b00d775c7c,0x00d7c78941cc7754,0x00422dd68b5dabc4,0x00a6110f0167d28b,0x00685a309c252886,0x00b439ffd5143660,0x003656e29ee7396f,0x00c7c9b9ed5ad854)}, - }}, {{ - {FIELD_LITERAL(0x0040f7e7c5b37bf2,0x0064e4dc81181bba,0x00a8767ae2a366b6,0x001496b4f90546f2,0x002a28493f860441,0x0021f59513049a3a,0x00852d369a8b7ee3,0x00dd2e7d8b7d30a9)}, - {FIELD_LITERAL(0x00006e34a35d9fbc,0x00eee4e48b2f019a,0x006b344743003a5f,0x00541d514f04a7e3,0x00e81f9ee7647455,0x005e2b916c438f81,0x00116f8137b7eff0,0x009bd3decc7039d1)}, - {FIELD_LITERAL(0x0005d226f434110d,0x00af8288b8ef21d5,0x004a7a52ef181c8c,0x00be0b781b4b06de,0x00e6e3627ded07e1,0x00e43aa342272b8b,0x00e86ab424577d84,0x00fb292c566e35bb)}, - }}, {{ - {FIELD_LITERAL(0x00334f5303ea1222,0x00dfb3dbeb0a5d3e,0x002940d9592335c1,0x00706a7a63e8938a,0x005a533558bc4caf,0x00558e33192022a9,0x00970d9faf74c133,0x002979fcb63493ca)}, - {FIELD_LITERAL(0x00e38abece3c82ab,0x005a51f18a2c7a86,0x009dafa2e86d592e,0x00495a62eb688678,0x00b79df74c0eb212,0x0023e8cc78b75982,0x005998cb91075e13,0x00735aa9ba61bc76)}, - {FIELD_LITERAL(0x00d9f7a82ddbe628,0x00a1fc782889ae0f,0x0071ffda12d14b66,0x0037cf4eca7fb3d5,0x00c80bc242c58808,0x0075bf8c2d08c863,0x008d41f31afc52a7,0x00197962ecf38741)}, - }}, {{ - {FIELD_LITERAL(0x006e9f475cccf2ee,0x00454b9cd506430c,0x00224a4fb79ee479,0x0062e3347ef0b5e2,0x0034fd2a3512232a,0x00b8b3cb0f457046,0x00eb20165daa38ec,0x00128eebc2d9c0f7)}, - {FIELD_LITERAL(0x00bfc5fa1e4ea21f,0x00c21d7b6bb892e6,0x00cf043f3acf0291,0x00c13f2f849b3c90,0x00d1a97ebef10891,0x0061e130a445e7fe,0x0019513fdedbf22b,0x001d60c813bff841)}, - {FIELD_LITERAL(0x0019561c7fcf0213,0x00e3dca6843ebd77,0x0068ea95b9ca920e,0x009bdfb70f253595,0x00c68f59186aa02a,0x005aee1cca1c3039,0x00ab79a8a937a1ce,0x00b9a0e549959e6f)}, - }}, {{ - {FIELD_LITERAL(0x00c79e0b6d97dfbd,0x00917c71fd2bc6e8,0x00db7529ccfb63d8,0x00be5be957f17866,0x00a9e11fdc2cdac1,0x007b91a8e1f44443,0x00a3065e4057d80f,0x004825f5b8d5f6d4)}, - {FIELD_LITERAL(0x003e4964fa8a8fc8,0x00f6a1cdbcf41689,0x00943cb18fe7fda7,0x00606dafbf34440a,0x005d37a86399c789,0x00e79a2a69417403,0x00fe34f7e68b8866,0x0011f448ed2df10e)}, - {FIELD_LITERAL(0x00f1f57efcc1fcc4,0x00513679117de154,0x002e5b5b7c86d8c3,0x009f6486561f9cfb,0x00169e74b0170cf7,0x00900205af4af696,0x006acfddb77853f3,0x00df184c90f31068)}, - }}, {{ - {FIELD_LITERAL(0x00b37396c3320791,0x00fc7b67175c5783,0x00c36d2cd73ecc38,0x0080ebcc0b328fc5,0x0043a5b22b35d35d,0x00466c9f1713c9da,0x0026ad346dcaa8da,0x007c684e701183a6)}, - {FIELD_LITERAL(0x00fd579ffb691713,0x00b76af4f81c412d,0x00f239de96110f82,0x00e965fb437f0306,0x00ca7e9436900921,0x00e487f1325fa24a,0x00633907de476380,0x00721c62ac5b8ea0)}, - {FIELD_LITERAL(0x00c0d54e542eb4f9,0x004ed657171c8dcf,0x00b743a4f7c2a39b,0x00fd9f93ed6cc567,0x00307fae3113e58b,0x0058aa577c93c319,0x00d254556f35b346,0x00491aada2203f0d)}, - }}, {{ - {FIELD_LITERAL(0x00dff3103786ff34,0x000144553b1f20c3,0x0095613baeb930e4,0x00098058275ea5d4,0x007cd1402b046756,0x0074d74e4d58aee3,0x005f93fc343ff69b,0x00873df17296b3b0)}, - {FIELD_LITERAL(0x00c4a1fb48635413,0x00b5dd54423ad59f,0x009ff5d53fd24a88,0x003c98d267fc06a7,0x002db7cb20013641,0x00bd1d6716e191f2,0x006dbc8b29094241,0x0044bbf233dafa2c)}, - {FIELD_LITERAL(0x0055838d41f531e6,0x00bf6a2dd03c81b2,0x005827a061c4839e,0x0000de2cbb36aac3,0x002efa29d9717478,0x00f9e928cc8a77ba,0x00c134b458def9ef,0x00958a182223fc48)}, - }}, {{ - {FIELD_LITERAL(0x000a9ee23c06881f,0x002c727d3d871945,0x00f47d971512d24a,0x00671e816f9ef31a,0x00883af2cfaad673,0x00601f98583d6c9a,0x00b435f5adc79655,0x00ad87b71c04bff2)}, - {FIELD_LITERAL(0x007860d99db787cf,0x00fda8983018f4a8,0x008c8866bac4743c,0x00ef471f84c82a3f,0x00abea5976d3b8e7,0x00714882896cd015,0x00b49fae584ddac5,0x008e33a1a0b69c81)}, - {FIELD_LITERAL(0x007b6ee2c9e8a9ec,0x002455dbbd89d622,0x006490cf4eaab038,0x00d925f6c3081561,0x00153b3047de7382,0x003b421f8bdceb6f,0x00761a4a5049da78,0x00980348c5202433)}, - }}, {{ - {FIELD_LITERAL(0x007f8a43da97dd5c,0x00058539c800fc7b,0x0040f3cf5a28414a,0x00d68dd0d95283d6,0x004adce9da90146e,0x00befa41c7d4f908,0x007603bc2e3c3060,0x00bdf360ab3545db)}, - {FIELD_LITERAL(0x00eebfd4e2312cc3,0x00474b2564e4fc8c,0x003303ef14b1da9b,0x003c93e0e66beb1d,0x0013619b0566925a,0x008817c24d901bf3,0x00b62bd8898d218b,0x0075a7716f1e88a2)}, - {FIELD_LITERAL(0x0009218da1e6890f,0x0026907f5fd02575,0x004dabed5f19d605,0x003abf181870249d,0x00b52fd048cc92c4,0x00b6dd51e415a5c5,0x00d9eb82bd2b4014,0x002c865a43b46b43)}, - }}, {{ - {FIELD_LITERAL(0x0070047189452f4c,0x00f7ad12e1ce78d5,0x00af1ba51ec44a8b,0x005f39f63e667cd6,0x00058eac4648425e,0x00d7fdab42bea03b,0x0028576a5688de15,0x00af973209e77c10)}, - {FIELD_LITERAL(0x00c338b915d8fef0,0x00a893292045c39a,0x0028ab4f2eba6887,0x0060743cb519fd61,0x0006213964093ac0,0x007c0b7a43f6266d,0x008e3557c4fa5bda,0x002da976de7b8d9d)}, - {FIELD_LITERAL(0x0048729f8a8b6dcd,0x00fe23b85cc4d323,0x00e7384d16e4db0e,0x004a423970678942,0x00ec0b763345d4ba,0x00c477b9f99ed721,0x00c29dad3777b230,0x001c517b466f7df6)}, - }}, {{ - {FIELD_LITERAL(0x006366c380f7b574,0x001c7d1f09ff0438,0x003e20a7301f5b22,0x00d3efb1916d28f6,0x0049f4f81060ce83,0x00c69d91ea43ced1,0x002b6f3e5cd269ed,0x005b0fb22ce9ec65)}, - {FIELD_LITERAL(0x00aa2261022d883f,0x00ebcca4548010ac,0x002528512e28a437,0x0070ca7676b66082,0x0084bda170f7c6d3,0x00581b4747c9b8bb,0x005c96a01061c7e2,0x00fb7c4a362b5273)}, - {FIELD_LITERAL(0x00c30020eb512d02,0x0060f288283a4d26,0x00b7ed13becde260,0x0075ebb74220f6e9,0x00701079fcfe8a1f,0x001c28fcdff58938,0x002e4544b8f4df6b,0x0060c5bc4f1a7d73)}, - }}, {{ - {FIELD_LITERAL(0x00ae307cf069f701,0x005859f222dd618b,0x00212d6c46ec0b0d,0x00a0fe4642afb62d,0x00420d8e4a0a8903,0x00a80ff639bdf7b0,0x0019bee1490b5d8e,0x007439e4b9c27a86)}, - {FIELD_LITERAL(0x00a94700032a093f,0x0076e96c225216e7,0x00a63a4316e45f91,0x007d8bbb4645d3b2,0x00340a6ff22793eb,0x006f935d4572aeb7,0x00b1fb69f00afa28,0x009e8f3423161ed3)}, - {FIELD_LITERAL(0x009ef49c6b5ced17,0x00a555e6269e9f0a,0x007e6f1d79ec73b5,0x009ac78695a32ac4,0x0001d77fbbcd5682,0x008cea1fee0aaeed,0x00f42bea82a53462,0x002e46ab96cafcc9)}, - }}, {{ - {FIELD_LITERAL(0x0051cfcc5885377a,0x00dce566cb1803ca,0x00430c7643f2c7d4,0x00dce1a1337bdcc0,0x0010d5bd7283c128,0x003b1b547f9b46fe,0x000f245e37e770ab,0x007b72511f022b37)}, - {FIELD_LITERAL(0x0060db815bc4786c,0x006fab25beedc434,0x00c610d06084797c,0x000c48f08537bec0,0x0031aba51c5b93da,0x007968fa6e01f347,0x0030070da52840c6,0x00c043c225a4837f)}, - {FIELD_LITERAL(0x001bcfd00649ee93,0x006dceb47e2a0fd5,0x00f2cebda0cf8fd0,0x00b6b9d9d1fbdec3,0x00815262e6490611,0x00ef7f5ce3176760,0x00e49cd0c998d58b,0x005fc6cc269ba57c)}, - }}, {{ - {FIELD_LITERAL(0x008940211aa0d633,0x00addae28136571d,0x00d68fdbba20d673,0x003bc6129bc9e21a,0x000346cf184ebe9a,0x0068774d741ebc7f,0x0019d5e9e6966557,0x0003cbd7f981b651)}, - {FIELD_LITERAL(0x004a2902926f8d3f,0x00ad79b42637ab75,0x0088f60b90f2d4e8,0x0030f54ef0e398c4,0x00021dc9bf99681e,0x007ebf66fde74ee3,0x004ade654386e9a4,0x00e7485066be4c27)}, - {FIELD_LITERAL(0x00445f1263983be0,0x004cf371dda45e6a,0x00744a89d5a310e7,0x001f20ce4f904833,0x00e746edebe66e29,0x000912ab1f6c153d,0x00f61d77d9b2444c,0x0001499cd6647610)}, + {FIELD_LITERAL(0x00cc3b062366f4ccULL, 0x003d6e34e314aa3cULL, + 0x00d51c0a7521774dULL, 0x0094e060eec6ab8bULL, + 0x00d21291b4d80082ULL, 0x00befed12b55ef1eULL, + 0x00c3dd2df5c94518ULL, 0x00e0a7b112b8d4e6ULL)}, + {FIELD_LITERAL(0x0019eb5608d8723aULL, 0x00d1bab52fb3aedbULL, + 0x00270a7311ebc90cULL, 0x0037c12b91be7f13ULL, + 0x005be16cd8b5c704ULL, 0x003e181acda888e1ULL, + 0x00bc1f00fc3fc6d0ULL, 0x00d3839bfa319e20ULL)}, + {FIELD_LITERAL(0x003caeb88611909fULL, 0x00ea8b378c4df3d4ULL, + 0x00b3295b95a5a19aULL, 0x00a65f97514bdfb5ULL, + 0x00b39efba743cab1ULL, 0x0016ba98b862fd2dULL, + 0x0001508812ee71d7ULL, 0x000a75740eea114aULL)}, + }}, {{ + {FIELD_LITERAL(0x00ebcf0eb649f823ULL, 0x00166d332e98ea03ULL, + 0x0059ddf64f5cd5f6ULL, 0x0047763123d9471bULL, + 0x00a64065c53ef62fULL, 0x00978e44c480153dULL, + 0x000b5b2a0265f194ULL, 0x0046a24b9f32965aULL)}, + {FIELD_LITERAL(0x00b9eef787034df0ULL, 0x0020bc24de3390cdULL, + 0x000022160bae99bbULL, 0x00ae66e886e97946ULL, + 0x0048d4bbe02cbb8bULL, 0x0072ba97b34e38d4ULL, + 0x00eae7ec8f03e85aULL, 0x005ba92ecf808b2cULL)}, + {FIELD_LITERAL(0x00c9cfbbe74258fdULL, 0x00843a979ea9eaa7ULL, + 0x000cbb4371cfbe90ULL, 0x0059bac8f7f0a628ULL, + 0x004b3dff882ff530ULL, 0x0011869df4d90733ULL, + 0x00595aa71f4abfc2ULL, 0x0070e2d38990c2e6ULL)}, + }}, {{ + {FIELD_LITERAL(0x00de2010c0a01733ULL, 0x00c739a612e24297ULL, + 0x00a7212643141d7cULL, 0x00f88444f6b67c11ULL, + 0x00484b7b16ec28f2ULL, 0x009c1b8856af9c68ULL, + 0x00ff4669591fe9d6ULL, 0x0054974be08a32c8ULL)}, + {FIELD_LITERAL(0x0010de3fd682ceedULL, 0x008c07642d83ca4eULL, + 0x0013bb064e00a1ccULL, 0x009411ae27870e11ULL, + 0x00ea8e5b4d531223ULL, 0x0032fe7d2aaece2eULL, + 0x00d989e243e7bb41ULL, 0x000fe79a508e9b8bULL)}, + {FIELD_LITERAL(0x005e0426b9bfc5b1ULL, 0x0041a5b1d29ee4faULL, + 0x0015b0def7774391ULL, 0x00bc164f1f51af01ULL, + 0x00d543b0942797b9ULL, 0x003c129b6398099cULL, + 0x002b114c6e5adf18ULL, 0x00b4e630e4018a7bULL)}, + }}, {{ + {FIELD_LITERAL(0x00d490afc95f8420ULL, 0x00b096bf50c1d9b9ULL, + 0x00799fd707679866ULL, 0x007c74d9334afbeaULL, + 0x00efaa8be80ff4edULL, 0x0075c4943bb81694ULL, + 0x00c21c2fca161f36ULL, 0x00e77035d492bfeeULL)}, + {FIELD_LITERAL(0x006658a190dd6661ULL, 0x00e0e9bab38609a6ULL, + 0x0028895c802237edULL, 0x006a0229c494f587ULL, + 0x002dcde96c9916b7ULL, 0x00d158822de16218ULL, + 0x00173b917a06856fULL, 0x00ca78a79ae07326ULL)}, + {FIELD_LITERAL(0x00e35bfc79caced4ULL, 0x0087238a3e1fe3bbULL, + 0x00bcbf0ff4ceff5bULL, 0x00a19c1c94099b91ULL, + 0x0071e102b49db976ULL, 0x0059e3d004eada1eULL, + 0x008da78afa58a47eULL, 0x00579c8ebf269187ULL)}, + }}, {{ + {FIELD_LITERAL(0x00a16c2905eee75fULL, 0x009d4bcaea2c7e1dULL, + 0x00d3bd79bfad19dfULL, 0x0050da745193342cULL, + 0x006abdb8f6b29ab1ULL, 0x00a24fe0a4fef7efULL, + 0x0063730da1057dfbULL, 0x00a08c312c8eb108ULL)}, + {FIELD_LITERAL(0x00b583be005375beULL, 0x00a40c8f8a4e3df4ULL, + 0x003fac4a8f5bdbf7ULL, 0x00d4481d872cd718ULL, + 0x004dc8749cdbaefeULL, 0x00cce740d5e5c975ULL, + 0x000b1c1f4241fd21ULL, 0x00a76de1b4e1cd07ULL)}, + {FIELD_LITERAL(0x007a076500d30b62ULL, 0x000a6e117b7f090fULL, + 0x00c8712ae7eebd9aULL, 0x000fbd6c1d5f6ff7ULL, + 0x003a7977246ebf11ULL, 0x00166ed969c6600eULL, + 0x00aa42e469c98becULL, 0x00dc58f307cf0666ULL)}, + }}, {{ + {FIELD_LITERAL(0x004b491f65a9a28bULL, 0x006a10309e8a55b7ULL, + 0x00b67210185187efULL, 0x00cf6497b12d9b8fULL, + 0x0085778c56e2b1baULL, 0x0015b4c07a814d85ULL, + 0x00686479e62da561ULL, 0x008de5d88f114916ULL)}, + {FIELD_LITERAL(0x00e37c88d6bba7b1ULL, 0x003e4577e1b8d433ULL, + 0x0050d8ea5f510ec0ULL, 0x0042fc9f2da9ef59ULL, + 0x003bd074c1141420ULL, 0x00561b8b7b68774eULL, + 0x00232e5e5d1013a3ULL, 0x006b7f2cb3d7e73fULL)}, + {FIELD_LITERAL(0x004bdd0f0b41e6a0ULL, 0x001773057c405d24ULL, + 0x006029f99915bd97ULL, 0x006a5ba70a17fe2fULL, + 0x0046111977df7e08ULL, 0x004d8124c89fb6b7ULL, + 0x00580983b2bb2724ULL, 0x00207bf330d6f3feULL)}, + }}, {{ + {FIELD_LITERAL(0x007efdc93972a48bULL, 0x002f5e50e78d5feeULL, + 0x0080dc11d61c7fe5ULL, 0x0065aa598707245bULL, + 0x009abba2300641beULL, 0x000c68787656543aULL, + 0x00ffe0fef2dc0a17ULL, 0x00007ffbd6cb4f3aULL)}, + {FIELD_LITERAL(0x0036012f2b836efcULL, 0x00458c126d6b5fbcULL, + 0x00a34436d719ad1eULL, 0x0097be6167117deaULL, + 0x0009c219c879cff3ULL, 0x0065564493e60755ULL, + 0x00993ac94a8cdec0ULL, 0x002d4885a4d0dbafULL)}, + {FIELD_LITERAL(0x00598b60b4c068baULL, 0x00c547a0be7f1afdULL, + 0x009582164acf12afULL, 0x00af4acac4fbbe40ULL, + 0x005f6ca7c539121aULL, 0x003b6e752ebf9d66ULL, + 0x00f08a30d5cac5d4ULL, 0x00e399bb5f97c5a9ULL)}, + }}, {{ + {FIELD_LITERAL(0x007445a0409c0a66ULL, 0x00a65c369f3829c0ULL, + 0x0031d248a4f74826ULL, 0x006817f34defbe8eULL, + 0x00649741d95ebf2eULL, 0x00d46466ab16b397ULL, + 0x00fdc35703bee414ULL, 0x00343b43334525f8ULL)}, + {FIELD_LITERAL(0x001796bea93f6401ULL, 0x00090c5a42e85269ULL, + 0x00672412ba1252edULL, 0x001201d47b6de7deULL, + 0x006877bccfe66497ULL, 0x00b554fd97a4c161ULL, + 0x009753f42dbac3cfULL, 0x00e983e3e378270aULL)}, + {FIELD_LITERAL(0x00ac3eff18849872ULL, 0x00f0eea3bff05690ULL, + 0x00a6d72c21dd505dULL, 0x001b832642424169ULL, + 0x00a6813017b540e5ULL, 0x00a744bd71b385cdULL, + 0x0022a7d089130a7bULL, 0x004edeec9a133486ULL)}, + }}, {{ + {FIELD_LITERAL(0x00b2d6729196e8a9ULL, 0x0088a9bb2031cef4ULL, + 0x00579e7787dc1567ULL, 0x0030f49feb059190ULL, + 0x00a0b1d69c7f7d8fULL, 0x0040bdcc6d9d806fULL, + 0x00d76c4037edd095ULL, 0x00bbf24376415dd7ULL)}, + {FIELD_LITERAL(0x00240465ff5a7197ULL, 0x00bb97e76caf27d0ULL, + 0x004b4edbf8116d39ULL, 0x001d8586f708cbaaULL, + 0x000f8ee8ff8e4a50ULL, 0x00dde5a1945dd622ULL, + 0x00e6fc1c0957e07cULL, 0x0041c9cdabfd88a0ULL)}, + {FIELD_LITERAL(0x005344b0bf5b548cULL, 0x002957d0b705cc99ULL, + 0x00f586a70390553dULL, 0x0075b3229f583cc3ULL, + 0x00a1aa78227490e4ULL, 0x001bf09cf7957717ULL, + 0x00cf6bf344325f52ULL, 0x0065bd1c23ca3ecfULL)}, + }}, {{ + {FIELD_LITERAL(0x009bff3b3239363cULL, 0x00e17368796ef7c0ULL, + 0x00528b0fe0971f3aULL, 0x0008014fc8d4a095ULL, + 0x00d09f2e8a521ec4ULL, 0x006713ab5dde5987ULL, + 0x0003015758e0dbb1ULL, 0x00215999f1ba212dULL)}, + {FIELD_LITERAL(0x002c88e93527da0eULL, 0x0077c78f3456aad5ULL, + 0x0071087a0a389d1cULL, 0x00934dac1fb96dbdULL, + 0x008470e801162697ULL, 0x005bc2196cd4ad49ULL, + 0x00e535601d5087c3ULL, 0x00769888700f497fULL)}, + {FIELD_LITERAL(0x00da7a4b557298adULL, 0x0019d2589ea5df76ULL, + 0x00ef3e38be0c6497ULL, 0x00a9644e1312609aULL, + 0x004592f61b2558daULL, 0x0082c1df510d7e46ULL, + 0x0042809a535c0023ULL, 0x00215bcb5afd7757ULL)}, + }}, {{ + {FIELD_LITERAL(0x002b9df55a1a4213ULL, 0x00dcfc3b464a26beULL, + 0x00c4f9e07a8144d5ULL, 0x00c8e0617a92b602ULL, + 0x008e3c93accafae0ULL, 0x00bf1bcb95b2ca60ULL, + 0x004ce2426a613bf3ULL, 0x00266cac58e40921ULL)}, + {FIELD_LITERAL(0x008456d5db76e8f0ULL, 0x0032ca9cab2ce163ULL, + 0x0059f2b8bf91abcfULL, 0x0063c2a021712788ULL, + 0x00f86155af22f72dULL, 0x00db98b2a6c005a0ULL, + 0x00ac6e416a693ac4ULL, 0x007a93572af53226ULL)}, + {FIELD_LITERAL(0x0087767520f0de22ULL, 0x0091f64012279fb5ULL, + 0x001050f1f0644999ULL, 0x004f097a2477ad3cULL, + 0x006b37913a9947bdULL, 0x001a3d78645af241ULL, + 0x0057832bbb3008a7ULL, 0x002c1d902b80dc20ULL)}, + }}, {{ + {FIELD_LITERAL(0x001a6002bf178877ULL, 0x009bce168aa5af50ULL, + 0x005fc318ff04a7f5ULL, 0x0052818f55c36461ULL, + 0x008768f5d4b24afbULL, 0x0037ffbae7b69c85ULL, + 0x0018195a4b61edc0ULL, 0x001e12ea088434b2ULL)}, + {FIELD_LITERAL(0x0047d3f804e7ab07ULL, 0x00a809ab5f905260ULL, + 0x00b3ffc7cdaf306dULL, 0x00746e8ec2d6e509ULL, + 0x00d0dade8887a645ULL, 0x00acceeebde0dd37ULL, + 0x009bc2579054686bULL, 0x0023804f97f1c2bfULL)}, + {FIELD_LITERAL(0x0043e2e2e50b80d7ULL, 0x00143aafe4427e0fULL, + 0x005594aaecab855bULL, 0x008b12ccaaecbc01ULL, + 0x002deeb091082bc3ULL, 0x009cca4be2ae7514ULL, + 0x00142b96e696d047ULL, 0x00ad2a2b1c05256aULL)}, + }}, {{ + {FIELD_LITERAL(0x003914f2f144b78bULL, 0x007a95dd8bee6f68ULL, + 0x00c7f4384d61c8e6ULL, 0x004e51eb60f1bdb2ULL, + 0x00f64be7aa4621d8ULL, 0x006797bfec2f0ac0ULL, + 0x007d17aab3c75900ULL, 0x001893e73cac8bc5ULL)}, + {FIELD_LITERAL(0x00140360b768665bULL, 0x00b68aca4967f977ULL, + 0x0001089b66195ae4ULL, 0x00fe71122185e725ULL, + 0x000bca2618d49637ULL, 0x00a54f0557d7e98aULL, + 0x00cdcd2f91d6f417ULL, 0x00ab8c13741fd793ULL)}, + {FIELD_LITERAL(0x00725ee6b1e549e0ULL, 0x007124a0769777faULL, + 0x000b68fdad07ae42ULL, 0x0085b909cd4952dfULL, + 0x0092d2e3c81606f4ULL, 0x009f22f6cac099a0ULL, + 0x00f59da57f2799a8ULL, 0x00f06c090122f777ULL)}, + }}, {{ + {FIELD_LITERAL(0x00ce0bed0a3532bcULL, 0x001a5048a22df16bULL, + 0x00e31db4cbad8bf1ULL, 0x00e89292120cf00eULL, + 0x007d1dd1a9b00034ULL, 0x00e2a9041ff8f680ULL, + 0x006a4c837ae596e7ULL, 0x00713af1068070b3ULL)}, + {FIELD_LITERAL(0x00c4fe64ce66d04bULL, 0x00b095d52e09b3d7ULL, + 0x00758bbecb1a3a8eULL, 0x00f35cce8d0650c0ULL, + 0x002b878aa5984473ULL, 0x0062e0a3b7544ddcULL, + 0x00b25b290ed116feULL, 0x007b0f6abe0bebf2ULL)}, + {FIELD_LITERAL(0x0081d4e3addae0a8ULL, 0x003410c836c7ffccULL, + 0x00c8129ad89e4314ULL, 0x000e3d5a23922dcdULL, + 0x00d91e46f29c31f3ULL, 0x006c728cde8c5947ULL, + 0x002bc655ba2566c0ULL, 0x002ca94721533108ULL)}, + }}, {{ + {FIELD_LITERAL(0x0051e4b3f764d8a9ULL, 0x0019792d46e904a0ULL, + 0x00853bc13dbc8227ULL, 0x000840208179f12dULL, + 0x0068243474879235ULL, 0x0013856fbfe374d0ULL, + 0x00bda12fe8676424ULL, 0x00bbb43635926eb2ULL)}, + {FIELD_LITERAL(0x0012cdc880a93982ULL, 0x003c495b21cd1b58ULL, + 0x00b7e5c93f22a26eULL, 0x0044aa82dfb99458ULL, + 0x009ba092cdffe9c0ULL, 0x00a14b3ab2083b73ULL, + 0x000271c2f70e1c4bULL, 0x00eea9cac0f66eb8ULL)}, + {FIELD_LITERAL(0x001a1847c4ac5480ULL, 0x00b1b412935bb03aULL, + 0x00f74285983bf2b2ULL, 0x00624138b5b5d0f1ULL, + 0x008820c0b03d38bfULL, 0x00b94e50a18c1572ULL, + 0x0060f6934841798fULL, 0x00c52f5d66d6ebe2ULL)}, + }}, {{ + {FIELD_LITERAL(0x00da23d59f9bcea6ULL, 0x00e0f27007a06a4bULL, + 0x00128b5b43a6758cULL, 0x000cf50190fa8b56ULL, + 0x00fc877aba2b2d72ULL, 0x00623bef52edf53fULL, + 0x00e6af6b819669e2ULL, 0x00e314dc34fcaa4fULL)}, + {FIELD_LITERAL(0x0066e5eddd164d1eULL, 0x00418a7c6fe28238ULL, + 0x0002e2f37e962c25ULL, 0x00f01f56b5975306ULL, + 0x0048842fa503875cULL, 0x0057b0e968078143ULL, + 0x00ff683024f3d134ULL, 0x0082ae28fcad12e4ULL)}, + {FIELD_LITERAL(0x0011ddfd21260e42ULL, 0x00d05b0319a76892ULL, + 0x00183ea4368e9b8fULL, 0x00b0815662affc96ULL, + 0x00b466a5e7ce7c88ULL, 0x00db93b07506e6eeULL, + 0x0033885f82f62401ULL, 0x0086f9090ec9b419ULL)}, + }}, {{ + {FIELD_LITERAL(0x00d95d1c5fcb435aULL, 0x0016d1ed6b5086f9ULL, + 0x00792aa0b7e54d71ULL, 0x0067b65715f1925dULL, + 0x00a219755ec6176bULL, 0x00bc3f026b12c28fULL, + 0x00700c897ffeb93eULL, 0x0089b83f6ec50b46ULL)}, + {FIELD_LITERAL(0x003c97e6384da36eULL, 0x00423d53eac81a09ULL, + 0x00b70d68f3cdce35ULL, 0x00ee7959b354b92cULL, + 0x00f4e9718819c8caULL, 0x009349f12acbffe9ULL, + 0x005aee7b62cb7da6ULL, 0x00d97764154ffc86ULL)}, + {FIELD_LITERAL(0x00526324babb46dcULL, 0x002ee99b38d7bf9eULL, + 0x007ea51794706ef4ULL, 0x00abeb04da6e3c39ULL, + 0x006b457c1d281060ULL, 0x00fe243e9a66c793ULL, + 0x00378de0fb6c6ee4ULL, 0x003e4194b9c3cb93ULL)}, + }}, {{ + {FIELD_LITERAL(0x00fed3cd80ca2292ULL, 0x0015b043a73ca613ULL, + 0x000a9fd7bf9be227ULL, 0x003b5e03de2db983ULL, + 0x005af72d46904ef7ULL, 0x00c0f1b5c49faa99ULL, + 0x00dc86fc3bd305e1ULL, 0x00c92f08c1cb1797ULL)}, + {FIELD_LITERAL(0x0079680ce111ed3bULL, 0x001a1ed82806122cULL, + 0x000c2e7466d15df3ULL, 0x002c407f6f7150fdULL, + 0x00c5e7c96b1b0ce3ULL, 0x009aa44626863ff9ULL, + 0x00887b8b5b80be42ULL, 0x00b6023cec964825ULL)}, + {FIELD_LITERAL(0x00e4a8e1048970c8ULL, 0x0062887b7830a302ULL, + 0x00bcf1c8cd81402bULL, 0x0056dbb81a68f5beULL, + 0x0014eced83f12452ULL, 0x00139e1a510150dfULL, + 0x00bb81140a82d1a3ULL, 0x000febcc1aaf1aa7ULL)}, + }}, {{ + {FIELD_LITERAL(0x00a7527958238159ULL, 0x0013ec9537a84cd6ULL, + 0x001d7fee7d562525ULL, 0x00b9eefa6191d5e5ULL, + 0x00dbc97db70bcb8aULL, 0x00481affc7a4d395ULL, + 0x006f73d3e70c31bbULL, 0x00183f324ed96a61ULL)}, + {FIELD_LITERAL(0x0039dd7ce7fc6860ULL, 0x00d64f6425653da1ULL, + 0x003e037c7f57d0afULL, 0x0063477a06e2bcf2ULL, + 0x001727dbb7ac67e6ULL, 0x0049589f5efafe2eULL, + 0x00fc0fef2e813d54ULL, 0x008baa5d087fb50dULL)}, + {FIELD_LITERAL(0x0024fb59d9b457c7ULL, 0x00a7d4e060223e4cULL, + 0x00c118d1b555fd80ULL, 0x0082e216c732f22aULL, + 0x00cd2a2993089504ULL, 0x003638e836a3e13dULL, + 0x000d855ee89b4729ULL, 0x008ec5b7d4810c91ULL)}, + }}, {{ + {FIELD_LITERAL(0x001bf51f7d65cdfdULL, 0x00d14cdafa16a97dULL, + 0x002c38e60fcd10e7ULL, 0x00a27446e393efbdULL, + 0x000b5d8946a71fddULL, 0x0063df2cde128f2fULL, + 0x006c8679569b1888ULL, 0x0059ffc4925d732dULL)}, + {FIELD_LITERAL(0x00ece96f95f2b66fULL, 0x00ece7952813a27bULL, + 0x0026fc36592e489eULL, 0x007157d1a2de0f66ULL, + 0x00759dc111d86ddfULL, 0x0012881e5780bb0fULL, + 0x00c8ccc83ad29496ULL, 0x0012b9bd1929eb71ULL)}, + {FIELD_LITERAL(0x000fa15a20da5df0ULL, 0x00349ddb1a46cd31ULL, + 0x002c512ad1d8e726ULL, 0x00047611f669318dULL, + 0x009e68fba591e17eULL, 0x004320dffa803906ULL, + 0x00a640874951a3d3ULL, 0x00b6353478baa24fULL)}, + }}, {{ + {FIELD_LITERAL(0x009696510000d333ULL, 0x00ec2f788bc04826ULL, + 0x000e4d02b1f67ba5ULL, 0x00659aa8dace08b6ULL, + 0x00d7a38a3a3ae533ULL, 0x008856defa8c746bULL, + 0x004d7a4402d3da1aULL, 0x00ea82e06229260fULL)}, + {FIELD_LITERAL(0x006a15bb20f75c0cULL, 0x0079a144027a5d0cULL, + 0x00d19116ce0b4d70ULL, 0x0059b83bcb0b268eULL, + 0x005f58f63f16c127ULL, 0x0079958318ee2c37ULL, + 0x00defbb063d07f82ULL, 0x00f1f0b931d2d446ULL)}, + {FIELD_LITERAL(0x00cb5e4c3c35d422ULL, 0x008df885ca43577fULL, + 0x00fa50b16ca3e471ULL, 0x005a0e58e17488c8ULL, + 0x00b2ceccd6d34d19ULL, 0x00f01d5d235e36e9ULL, + 0x00db2e7e4be6ca44ULL, 0x00260ab77f35fccdULL)}, + }}, {{ + {FIELD_LITERAL(0x006f6fd9baac61d5ULL, 0x002a7710a020a895ULL, + 0x009de0db7fc03d4dULL, 0x00cdedcb1875f40bULL, + 0x00050caf9b6b1e22ULL, 0x005e3a6654456ab0ULL, + 0x00775fdf8c4423d4ULL, 0x0028701ea5738b5dULL)}, + {FIELD_LITERAL(0x009ffd90abfeae96ULL, 0x00cba3c2b624a516ULL, + 0x005ef08bcee46c91ULL, 0x00e6fde30afb6185ULL, + 0x00f0b4db4f818ce4ULL, 0x006c54f45d2127f5ULL, + 0x00040125035854c7ULL, 0x00372658a3287e13ULL)}, + {FIELD_LITERAL(0x00d7070fb1beb2abULL, 0x0078fc845a93896bULL, + 0x006894a4b2f224a6ULL, 0x005bdd8192b9dbdeULL, + 0x00b38839874b3a9eULL, 0x00f93618b04b7a57ULL, + 0x003e3ec75fd2c67eULL, 0x00bf5e6bfc29494aULL)}, + }}, {{ + {FIELD_LITERAL(0x00f19224ebba2aa5ULL, 0x0074f89d358e694dULL, + 0x00eea486597135adULL, 0x0081579a4555c7e1ULL, + 0x0010b9b872930a9dULL, 0x00f002e87a30ecc0ULL, + 0x009b9d66b6de56e2ULL, 0x00a3c4f45e8004ebULL)}, + {FIELD_LITERAL(0x0045e8dda9400888ULL, 0x002ff12e5fc05db7ULL, + 0x00a7098d54afe69cULL, 0x00cdbe846a500585ULL, + 0x00879c1593ca1882ULL, 0x003f7a7fea76c8b0ULL, + 0x002cd73dd0c8e0a1ULL, 0x00645d6ce96f51feULL)}, + {FIELD_LITERAL(0x002b7e83e123d6d6ULL, 0x00398346f7419c80ULL, + 0x0042922e55940163ULL, 0x005e7fc5601886a3ULL, + 0x00e88f2cee1d3103ULL, 0x00e7fab135f2e377ULL, + 0x00b059984dbf0dedULL, 0x0009ce080faa5bb8ULL)}, + }}, {{ + {FIELD_LITERAL(0x0085e78af7758979ULL, 0x00275a4ee1631a3aULL, + 0x00d26bc0ed78b683ULL, 0x004f8355ea21064fULL, + 0x00d618e1a32696e5ULL, 0x008d8d7b150e5680ULL, + 0x00a74cd854b278d2ULL, 0x001dd62702203ea0ULL)}, + {FIELD_LITERAL(0x00f89335c2a59286ULL, 0x00a0f5c905d55141ULL, + 0x00b41fb836ee9382ULL, 0x00e235d51730ca43ULL, + 0x00a5cb37b5c0a69aULL, 0x009b966ffe136c45ULL, + 0x00cb2ea10bf80ed1ULL, 0x00fb2b370b40dc35ULL)}, + {FIELD_LITERAL(0x00d687d16d4ee8baULL, 0x0071520bdd069dffULL, + 0x00de85c60d32355dULL, 0x0087d2e3565102f4ULL, + 0x00cde391b8dfc9aaULL, 0x00e18d69efdfefe5ULL, + 0x004a9d0591954e91ULL, 0x00fa36dd8b50eee5ULL)}, + }}, {{ + {FIELD_LITERAL(0x002e788749a865f7ULL, 0x006e4dc3116861eaULL, + 0x009f1428c37276e6ULL, 0x00e7d2e0fc1e1226ULL, + 0x003aeebc6b6c45f6ULL, 0x0071a8073bf500c9ULL, + 0x004b22ad986b530cULL, 0x00f439e63c0d79d4ULL)}, + {FIELD_LITERAL(0x006bc3d53011f470ULL, 0x00032d6e692b83e8ULL, + 0x00059722f497cd0bULL, 0x0009b4e6f0c497ccULL, + 0x0058a804b7cce6c0ULL, 0x002b71d3302bbd5dULL, + 0x00e2f82a36765fceULL, 0x008dded99524c703ULL)}, + {FIELD_LITERAL(0x004d058953747d64ULL, 0x00701940fe79aa6fULL, + 0x00a620ac71c760bfULL, 0x009532b611158b75ULL, + 0x00547ed7f466f300ULL, 0x003cb5ab53a8401aULL, + 0x00c7763168ce3120ULL, 0x007e48e33e4b9ab2ULL)}, + }}, {{ + {FIELD_LITERAL(0x001b2fc57bf3c738ULL, 0x006a3f918993fb80ULL, + 0x0026f7a14fdec288ULL, 0x0075a2cdccef08dbULL, + 0x00d3ecbc9eecdbf1ULL, 0x0048c40f06e5bf7fULL, + 0x00d63e423009896bULL, 0x000598bc99c056a8ULL)}, + {FIELD_LITERAL(0x002f194eaafa46dcULL, 0x008e38f57fe87613ULL, + 0x00dc8e5ae25f4ab2ULL, 0x000a17809575e6bdULL, + 0x00d3ec7923ba366aULL, 0x003a7e72e0ad75e3ULL, + 0x0010024b88436e0aULL, 0x00ed3c5444b64051ULL)}, + {FIELD_LITERAL(0x00831fc1340af342ULL, 0x00c9645669466d35ULL, + 0x007692b4cc5a080fULL, 0x009fd4a47ac9259fULL, + 0x001eeddf7d45928bULL, 0x003c0446fc45f28bULL, + 0x002c0713aa3e2507ULL, 0x0095706935f0f41eULL)}, + }}, {{ + {FIELD_LITERAL(0x00766ae4190ec6d8ULL, 0x0065768cabc71380ULL, + 0x00b902598416cdc2ULL, 0x00380021ad38df52ULL, + 0x008f0b89d6551134ULL, 0x004254d4cc62c5a5ULL, + 0x000d79f4484b9b94ULL, 0x00b516732ae3c50eULL)}, + {FIELD_LITERAL(0x001fb73475c45509ULL, 0x00d2b2e5ea43345aULL, + 0x00cb3c3842077bd1ULL, 0x0029f90ad820946eULL, + 0x007c11b2380778aaULL, 0x009e54ece62c1704ULL, + 0x004bc60c41ca01c3ULL, 0x004525679a5a0b03ULL)}, + {FIELD_LITERAL(0x00c64fbddbed87b3ULL, 0x0040601d11731faaULL, + 0x009c22475b6f9d67ULL, 0x0024b79dae875f15ULL, + 0x00616fed3f02c3b0ULL, 0x0000cf39f6af2d3bULL, + 0x00c46bac0aa9a688ULL, 0x00ab23e2800da204ULL)}, + }}, {{ + {FIELD_LITERAL(0x000b3a37617632b0ULL, 0x00597199fe1cfb6cULL, + 0x0042a7ccdfeafdd6ULL, 0x004cc9f15ebcea17ULL, + 0x00f436e596a6b4a4ULL, 0x00168861142df0d8ULL, + 0x000753edfec26af5ULL, 0x000c495d7e388116ULL)}, + {FIELD_LITERAL(0x0017085f4a346148ULL, 0x00c7cf7a37f62272ULL, + 0x001776e129bc5c30ULL, 0x009955134c9eef2aULL, + 0x001ba5bdf1df07beULL, 0x00ec39497103a55cULL, + 0x006578354fda6cfbULL, 0x005f02719d4f15eeULL)}, + {FIELD_LITERAL(0x0052b9d9b5d9655dULL, 0x00d4ec7ba1b461c3ULL, + 0x00f95df4974f280bULL, 0x003d8e5ca11aeb51ULL, + 0x00d4981eb5a70b26ULL, 0x000af9a4f6659f29ULL, + 0x004598c846faeb43ULL, 0x0049d9a183a47670ULL)}, + }}, {{ + {FIELD_LITERAL(0x000a72d23dcb3f1fULL, 0x00a3737f84011727ULL, + 0x00f870c0fbbf4a47ULL, 0x00a7aadd04b5c9caULL, + 0x000c7715c67bd072ULL, 0x00015a136afcd74eULL, + 0x0080d5caea499634ULL, 0x0026b448ec7514b7ULL)}, + {FIELD_LITERAL(0x00b60167d9e7d065ULL, 0x00e60ba0d07381e8ULL, + 0x003a4f17b725c2d4ULL, 0x006c19fe176b64faULL, + 0x003b57b31af86ccbULL, 0x0021047c286180fdULL, + 0x00bdc8fb00c6dbb6ULL, 0x00fe4a9f4bab4f3fULL)}, + {FIELD_LITERAL(0x0088ffc3a16111f7ULL, 0x009155e4245d0bc8ULL, + 0x00851d68220572d5ULL, 0x00557ace1e514d29ULL, + 0x0031d7c339d91022ULL, 0x00101d0ae2eaceeaULL, + 0x00246ab3f837b66aULL, 0x00d5216d381ff530ULL)}, + }}, {{ + {FIELD_LITERAL(0x0057e7ea35f36daeULL, 0x00f47d7ad15de22eULL, + 0x00d757ea4b105115ULL, 0x008311457d579d7eULL, + 0x00b49b75b1edd4ebULL, 0x0081c7ff742fd63aULL, + 0x00ddda3187433df6ULL, 0x00475727d55f9c66ULL)}, + {FIELD_LITERAL(0x00a6295218dc136aULL, 0x00563b3af0e9c012ULL, + 0x00d3753b0145db1bULL, 0x004550389c043dc1ULL, + 0x00ea94ae27401bdfULL, 0x002b0b949f2b7956ULL, + 0x00c63f780ad8e23cULL, 0x00e591c47d6bab15ULL)}, + {FIELD_LITERAL(0x00416c582b058eb6ULL, 0x004107da5b2cc695ULL, + 0x00b3cd2556aeec64ULL, 0x00c0b418267e57a1ULL, + 0x001799293579bd2eULL, 0x0046ed44590e4d07ULL, + 0x001d7459b3630a1eULL, 0x00c6afba8b6696aaULL)}, + }}, {{ + {FIELD_LITERAL(0x008d6009b26da3f8ULL, 0x00898e88ca06b1caULL, + 0x00edb22b2ed7fe62ULL, 0x00fbc93516aabe80ULL, + 0x008b4b470c42ce0dULL, 0x00e0032ba7d0dcbbULL, + 0x00d76da3a956ecc8ULL, 0x007f20fe74e3852aULL)}, + {FIELD_LITERAL(0x002419222c607674ULL, 0x00a7f23af89188b3ULL, + 0x00ad127284e73d1cULL, 0x008bba582fae1c51ULL, + 0x00fc6aa7ca9ecab1ULL, 0x003df5319eb6c2baULL, + 0x002a05af8a8b199aULL, 0x004bf8354558407cULL)}, + {FIELD_LITERAL(0x00ce7d4a30f0fcbfULL, 0x00d02c272629f03dULL, + 0x0048c001f7400bc2ULL, 0x002c21368011958dULL, + 0x0098a550391e96b5ULL, 0x002d80b66390f379ULL, + 0x001fa878760cc785ULL, 0x001adfce54b613d5ULL)}, + }}, {{ + {FIELD_LITERAL(0x001ed4dc71fa2523ULL, 0x005d0bff19bf9b5cULL, + 0x00c3801cee065a64ULL, 0x001ed0b504323fbfULL, + 0x0003ab9fdcbbc593ULL, 0x00df82070178b8d2ULL, + 0x00a2bcaa9c251f85ULL, 0x00c628a3674bd02eULL)}, + {FIELD_LITERAL(0x006b7a0674f9f8deULL, 0x00a742414e5c7cffULL, + 0x0041cbf3c6e13221ULL, 0x00e3a64fd207af24ULL, + 0x0087c05f15fbe8d1ULL, 0x004c50936d9e8a33ULL, + 0x001306ec21042b6dULL, 0x00a4f4137d1141c2ULL)}, + {FIELD_LITERAL(0x0009e6fb921568b0ULL, 0x00b3c60120219118ULL, + 0x002a6c3460dd503aULL, 0x009db1ef11654b54ULL, + 0x0063e4bf0be79601ULL, 0x00670d34bb2592b9ULL, + 0x00dcee2f6c4130ceULL, 0x00b2682e88e77f54ULL)}, + }}, {{ + {FIELD_LITERAL(0x000d5b4b3da135abULL, 0x00838f3e5064d81dULL, + 0x00d44eb50f6d94edULL, 0x0008931ab502ac6dULL, + 0x00debe01ca3d3586ULL, 0x0025c206775f0641ULL, + 0x005ad4b6ae912763ULL, 0x007e2c318ad8f247ULL)}, + {FIELD_LITERAL(0x00ddbe0750dd1addULL, 0x004b3c7b885844b8ULL, + 0x00363e7ecf12f1aeULL, 0x0062e953e6438f9dULL, + 0x0023cc73b076afe9ULL, 0x00b09fa083b4da32ULL, + 0x00c7c3d2456c541dULL, 0x005b591ec6b694d4ULL)}, + {FIELD_LITERAL(0x0028656e19d62fcfULL, 0x0052a4af03df148dULL, + 0x00122765ddd14e42ULL, 0x00f2252904f67157ULL, + 0x004741965b636f3aULL, 0x006441d296132cb9ULL, + 0x005e2106f956a5b7ULL, 0x00247029592d335cULL)}, + }}, {{ + {FIELD_LITERAL(0x003fe038eb92f894ULL, 0x000e6da1b72e8e32ULL, + 0x003a1411bfcbe0faULL, 0x00b55d473164a9e4ULL, + 0x00b9a775ac2df48dULL, 0x0002ddf350659e21ULL, + 0x00a279a69eb19cb3ULL, 0x00f844eab25cba44ULL)}, + {FIELD_LITERAL(0x00c41d1f9c1f1ac1ULL, 0x007b2df4e9f19146ULL, + 0x00b469355fd5ba7aULL, 0x00b5e1965afc852aULL, + 0x00388d5f1e2d8217ULL, 0x0022079e4c09ae93ULL, + 0x0014268acd4ef518ULL, 0x00c1dd8d9640464cULL)}, + {FIELD_LITERAL(0x0038526adeed0c55ULL, 0x00dd68c607e3fe85ULL, + 0x00f746ddd48a5d57ULL, 0x0042f2952b963b7cULL, + 0x001cbbd6876d5ec2ULL, 0x005e341470bca5c2ULL, + 0x00871d41e085f413ULL, 0x00e53ab098f45732ULL)}, + }}, {{ + {FIELD_LITERAL(0x004d51124797c831ULL, 0x008f5ae3750347adULL, + 0x0070ced94c1a0c8eULL, 0x00f6db2043898e64ULL, + 0x000d00c9a5750cd0ULL, 0x000741ec59bad712ULL, + 0x003c9d11aab37b7fULL, 0x00a67ba169807714ULL)}, + {FIELD_LITERAL(0x00adb2c1566e8b8fULL, 0x0096c68a35771a9aULL, + 0x00869933356f334aULL, 0x00ba9c93459f5962ULL, + 0x009ec73fb6e8ca4bULL, 0x003c3802c27202e1ULL, + 0x0031f5b733e0c008ULL, 0x00f9058c19611fa9ULL)}, + {FIELD_LITERAL(0x00238f01814a3421ULL, 0x00c325a44b6cce28ULL, + 0x002136f97aeb0e73ULL, 0x000cac8268a4afe2ULL, + 0x0022fd218da471b3ULL, 0x009dcd8dfff8def9ULL, + 0x00cb9f8181d999bbULL, 0x00143ae56edea349ULL)}, + }}, {{ + {FIELD_LITERAL(0x0000623bf87622c5ULL, 0x00a1966fdd069496ULL, + 0x00c315b7b812f9fcULL, 0x00bdf5efcd128b97ULL, + 0x001d464f532e3e16ULL, 0x003cd94f081bfd7eULL, + 0x00ed9dae12ce4009ULL, 0x002756f5736eee70ULL)}, + {FIELD_LITERAL(0x00a5187e6ee7341bULL, 0x00e6d52e82d83b6eULL, + 0x00df3c41323094a7ULL, 0x00b3324f444e9de9ULL, + 0x00689eb21a35bfe5ULL, 0x00f16363becd548dULL, + 0x00e187cc98e7f60fULL, 0x00127d9062f0ccabULL)}, + {FIELD_LITERAL(0x004ad71b31c29e40ULL, 0x00a5fcace12fae29ULL, + 0x004425b5597280edULL, 0x00e7ef5d716c3346ULL, + 0x0010b53ada410ac8ULL, 0x0092310226060c9bULL, + 0x0091c26128729c7eULL, 0x0088b42900f8ec3bULL)}, + }}, {{ + {FIELD_LITERAL(0x00f1e26e9762d4a8ULL, 0x00d9d74082183414ULL, + 0x00ffec9bd57a0282ULL, 0x000919e128fd497aULL, + 0x00ab7ae7d00fe5f8ULL, 0x0054dc442851ff68ULL, + 0x00c9ebeb3b861687ULL, 0x00507f7cab8b698fULL)}, + {FIELD_LITERAL(0x00c13c5aae3ae341ULL, 0x009c6c9ed98373e7ULL, + 0x00098f26864577a8ULL, 0x0015b886e9488b45ULL, + 0x0037692c42aadba5ULL, 0x00b83170b8e7791cULL, + 0x001670952ece1b44ULL, 0x00fd932a39276da2ULL)}, + {FIELD_LITERAL(0x0081a3259bef3398ULL, 0x005480fff416107bULL, + 0x00ce4f607d21be98ULL, 0x003ffc084b41df9bULL, + 0x0043d0bb100502d1ULL, 0x00ec35f575ba3261ULL, + 0x00ca18f677300ef3ULL, 0x00e8bb0a827d8548ULL)}, + }}, {{ + {FIELD_LITERAL(0x00df76b3328ada72ULL, 0x002e20621604a7c2ULL, + 0x00f910638a105b09ULL, 0x00ef4724d96ef2cdULL, + 0x00377d83d6b8a2f7ULL, 0x00b4f48805ade324ULL, + 0x001cd5da8b152018ULL, 0x0045af671a20ca7fULL)}, + {FIELD_LITERAL(0x009ae3b93a56c404ULL, 0x004a410b7a456699ULL, + 0x00023a619355e6b2ULL, 0x009cdc7297387257ULL, + 0x0055b94d4ae70d04ULL, 0x002cbd607f65b005ULL, + 0x003208b489697166ULL, 0x00ea2aa058867370ULL)}, + {FIELD_LITERAL(0x00f29d2598ee3f32ULL, 0x00b4ac5385d82adcULL, + 0x007633eaf04df19bULL, 0x00aa2d3d77ceab01ULL, + 0x004a2302fcbb778aULL, 0x00927f225d5afa34ULL, + 0x004a8e9d5047f237ULL, 0x008224ae9dbce530ULL)}, + }}, {{ + {FIELD_LITERAL(0x001cf640859b02f8ULL, 0x00758d1d5d5ce427ULL, + 0x00763c784ef4604cULL, 0x005fa81aee205270ULL, + 0x00ac537bfdfc44cbULL, 0x004b919bd342d670ULL, + 0x00238508d9bf4b7aULL, 0x00154888795644f3ULL)}, + {FIELD_LITERAL(0x00c845923c084294ULL, 0x00072419a201bc25ULL, + 0x0045f408b5f8e669ULL, 0x00e9d6a186b74dfeULL, + 0x00e19108c68fa075ULL, 0x0017b91d874177b7ULL, + 0x002f0ca2c7912c5aULL, 0x009400aa385a90a2ULL)}, + {FIELD_LITERAL(0x0071110b01482184ULL, 0x00cfed0044f2bef8ULL, + 0x0034f2901cf4662eULL, 0x003b4ae2a67f9834ULL, + 0x00cca9b96fe94810ULL, 0x00522507ae77abd0ULL, + 0x00bac7422721e73eULL, 0x0066622b0f3a62b0ULL)}, + }}, {{ + {FIELD_LITERAL(0x00f8ac5cf4705b6aULL, 0x00867d82dcb457e3ULL, + 0x007e13ab2ccc2ce9ULL, 0x009ee9a018d3930eULL, + 0x008370f8ecb42df8ULL, 0x002d9f019add263eULL, + 0x003302385b92d196ULL, 0x00a15654536e2c0cULL)}, + {FIELD_LITERAL(0x0026ef1614e160afULL, 0x00c023f9edfc9c76ULL, + 0x00cff090da5f57baULL, 0x0076db7a66643ae9ULL, + 0x0019462f8c646999ULL, 0x008fec00b3854b22ULL, + 0x00d55041692a0a1cULL, 0x0065db894215ca00ULL)}, + {FIELD_LITERAL(0x00a925036e0a451cULL, 0x002a0390c36b6cc1ULL, + 0x00f27020d90894f4ULL, 0x008d90d52cbd3d7fULL, + 0x00e1d0137392f3b8ULL, 0x00f017c158b51a8fULL, + 0x00cac313d3ed7dbcULL, 0x00b99a81e3eb42d3ULL)}, + }}, {{ + {FIELD_LITERAL(0x00b54850275fe626ULL, 0x0053a3fd1ec71140ULL, + 0x00e3d2d7dbe096faULL, 0x00e4ac7b595cce4cULL, + 0x0077bad449c0a494ULL, 0x00b7c98814afd5b3ULL, + 0x0057226f58486cf9ULL, 0x00b1557154f0cc57ULL)}, + {FIELD_LITERAL(0x008cc9cd236315c0ULL, 0x0031d9c5b39fda54ULL, + 0x00a5713ef37e1171ULL, 0x00293d5ae2886325ULL, + 0x00c4aba3e05015e1ULL, 0x0003f35ef78e4fc6ULL, + 0x0039d6bd3ac1527bULL, 0x0019d7c3afb77106ULL)}, + {FIELD_LITERAL(0x007b162931a985afULL, 0x00ad40a2e0daa713ULL, + 0x006df27c4009f118ULL, 0x00503e9f4e2e8becULL, + 0x00751a77c82c182dULL, 0x000298937769245bULL, + 0x00ffb1e8fabf9ee5ULL, 0x0008334706e09abeULL)}, + }}, {{ + {FIELD_LITERAL(0x00dbca4e98a7dcd9ULL, 0x00ee29cfc78bde99ULL, + 0x00e4a3b6995f52e9ULL, 0x0045d70189ae8096ULL, + 0x00fd2a8a3b9b0d1bULL, 0x00af1793b107d8e1ULL, + 0x00dbf92cbe4afa20ULL, 0x00da60f798e3681dULL)}, + {FIELD_LITERAL(0x004246bfcecc627aULL, 0x004ba431246c03a4ULL, + 0x00bd1d101872d497ULL, 0x003b73d3f185ee16ULL, + 0x001feb2e2678c0e3ULL, 0x00ff13c5a89dec76ULL, + 0x00ed06042e771d8fULL, 0x00a4fd2a897a83ddULL)}, + {FIELD_LITERAL(0x009a4a3be50d6597ULL, 0x00de3165fc5a1096ULL, + 0x004f3f56e345b0c7ULL, 0x00f7bf721d5ab8bcULL, + 0x004313e47b098c50ULL, 0x00e4c7d5c0e1adbbULL, + 0x002e3e3db365051eULL, 0x00a480c2cd6a96fbULL)}, + }}, {{ + {FIELD_LITERAL(0x00417fa30a7119edULL, 0x00af257758419751ULL, + 0x00d358a487b463d4ULL, 0x0089703cc720b00dULL, + 0x00ce56314ff7f271ULL, 0x0064db171ade62c1ULL, + 0x00640b36d4a22fedULL, 0x00424eb88696d23fULL)}, + {FIELD_LITERAL(0x004ede34af2813f3ULL, 0x00d4a8e11c9e8216ULL, + 0x004796d5041de8a5ULL, 0x00c4c6b4d21cc987ULL, + 0x00e8a433ee07fa1eULL, 0x0055720b5abcc5a1ULL, + 0x008873ea9c74b080ULL, 0x005b3fec1ab65d48ULL)}, + {FIELD_LITERAL(0x0047e5277db70ec5ULL, 0x000a096c66db7d6bULL, + 0x00b4164cc1730159ULL, 0x004a9f783fe720feULL, + 0x00a8177b94449dbcULL, 0x0095a24ff49a599fULL, + 0x0069c1c578250cbcULL, 0x00452019213debf4ULL)}, + }}, {{ + {FIELD_LITERAL(0x0021ce99e09ebda3ULL, 0x00fcbd9f91875ad0ULL, + 0x009bbf6b7b7a0b5fULL, 0x00388886a69b1940ULL, + 0x00926a56d0f81f12ULL, 0x00e12903c3358d46ULL, + 0x005dfce4e8e1ce9dULL, 0x0044cfa94e2f7e23ULL)}, + {FIELD_LITERAL(0x001bd59c09e982eaULL, 0x00f72daeb937b289ULL, + 0x0018b76dca908e0eULL, 0x00edb498512384adULL, + 0x00ce0243b6cc9538ULL, 0x00f96ff690cb4e70ULL, + 0x007c77bf9f673c8dULL, 0x005bf704c088a528ULL)}, + {FIELD_LITERAL(0x0093d4628dcb33beULL, 0x0095263d51d42582ULL, + 0x0049b3222458fe06ULL, 0x00e7fce73b653a7fULL, + 0x003ca2ebce60b369ULL, 0x00c5de239a32bea4ULL, + 0x0063b8b3d71fb6bfULL, 0x0039aeeb78a1a839ULL)}, + }}, {{ + {FIELD_LITERAL(0x007dc52da400336cULL, 0x001fded1e15b9457ULL, + 0x00902e00f5568e3aULL, 0x00219bef40456d2dULL, + 0x005684161fb3dbc9ULL, 0x004a4e9be49a76eaULL, + 0x006e685ae88b78ffULL, 0x0021c42f13042d3cULL)}, + {FIELD_LITERAL(0x00fb22bb5fd3ce50ULL, 0x0017b48aada7ae54ULL, + 0x00fd5c44ad19a536ULL, 0x000ccc4e4e55e45cULL, + 0x00fd637d45b4c3f5ULL, 0x0038914e023c37cfULL, + 0x00ac1881d6a8d898ULL, 0x00611ed8d3d943a8ULL)}, + {FIELD_LITERAL(0x0056e2259d113d2bULL, 0x00594819b284ec16ULL, + 0x00c7bf794bb36696ULL, 0x00721ee75097cdc6ULL, + 0x00f71be9047a2892ULL, 0x00df6ba142564edfULL, + 0x0069580b7a184e8dULL, 0x00f056e38fca0feeULL)}, + }}, {{ + {FIELD_LITERAL(0x009df98566a18c6dULL, 0x00cf3a200968f219ULL, + 0x0044ba60da6d9086ULL, 0x00dbc9c0e344da03ULL, + 0x000f9401c4466855ULL, 0x00d46a57c5b0a8d1ULL, + 0x00875a635d7ac7c6ULL, 0x00ef4a933b7e0ae6ULL)}, + {FIELD_LITERAL(0x005e8694077a1535ULL, 0x008bef75f71c8f1dULL, + 0x000a7c1316423511ULL, 0x00906e1d70604320ULL, + 0x003fc46c1a2ffbd6ULL, 0x00d1d5022e68f360ULL, + 0x002515fba37bbf46ULL, 0x00ca16234e023b44ULL)}, + {FIELD_LITERAL(0x00787c99561f4690ULL, 0x00a857a8c1561f27ULL, + 0x00a10df9223c09feULL, 0x00b98a9562e3b154ULL, + 0x004330b8744c3ed2ULL, 0x00e06812807ec5c4ULL, + 0x00e4cf6a7db9f1e3ULL, 0x00d95b089f132a34ULL)}, + }}, {{ + {FIELD_LITERAL(0x002922b39ca33eecULL, 0x0090d12a5f3ab194ULL, + 0x00ab60c02fb5f8edULL, 0x00188d292abba1cfULL, + 0x00e10edec9698f6eULL, 0x0069a4d9934133c8ULL, + 0x0024aac40e6d3d06ULL, 0x001702c2177661b0ULL)}, + {FIELD_LITERAL(0x00139078397030bdULL, 0x000e3c447e859a00ULL, + 0x0064a5b334c82393ULL, 0x00b8aabeb7358093ULL, + 0x00020778bb9ae73bULL, 0x0032ee94c7892a18ULL, + 0x008215253cb41bdaULL, 0x005e2797593517aeULL)}, + {FIELD_LITERAL(0x0083765a5f855d4aULL, 0x0051b6d1351b8ee2ULL, + 0x00116de548b0f7bbULL, 0x0087bd88703affa0ULL, + 0x0095b2cc34d7fdd2ULL, 0x0084cd81b53f0bc8ULL, + 0x008562fc995350edULL, 0x00a39abb193651e3ULL)}, + }}, {{ + {FIELD_LITERAL(0x0019e23f0474b114ULL, 0x00eb94c2ad3b437eULL, + 0x006ddb34683b75acULL, 0x00391f9209b564c6ULL, + 0x00083b3bb3bff7aaULL, 0x00eedcd0f6dceefcULL, + 0x00b50817f794fe01ULL, 0x0036474deaaa75c9ULL)}, + {FIELD_LITERAL(0x0091868594265aa2ULL, 0x00797accae98ca6dULL, + 0x0008d8c5f0f8a184ULL, 0x00d1f4f1c2b2fe6eULL, + 0x0036783dfb48a006ULL, 0x008c165120503527ULL, + 0x0025fd780058ce9bULL, 0x0068beb007be7d27ULL)}, + {FIELD_LITERAL(0x00d0ff88aa7c90c2ULL, 0x00b2c60dacf53394ULL, + 0x0094a7284d9666d6ULL, 0x00bed9022ce7a19dULL, + 0x00c51553f0cd7682ULL, 0x00c3fb870b124992ULL, + 0x008d0bc539956c9bULL, 0x00fc8cf258bb8885ULL)}, + }}, {{ + {FIELD_LITERAL(0x003667bf998406f8ULL, 0x0000115c43a12975ULL, + 0x001e662f3b20e8fdULL, 0x0019ffa534cb24ebULL, + 0x00016be0dc8efb45ULL, 0x00ff76a8b26243f5ULL, + 0x00ae20d241a541e3ULL, 0x0069bd6af13cd430ULL)}, + {FIELD_LITERAL(0x0045fdc16487cda3ULL, 0x00b2d8e844cf2ed7ULL, + 0x00612c50e88c1607ULL, 0x00a08aabc66c1672ULL, + 0x006031fdcbb24d97ULL, 0x001b639525744b93ULL, + 0x004409d62639ab17ULL, 0x00a1853d0347ab1dULL)}, + {FIELD_LITERAL(0x0075a1a56ebf5c21ULL, 0x00a3e72be9ac53edULL, + 0x00efcde1629170c2ULL, 0x0004225fe91ef535ULL, + 0x0088049fc73dfda7ULL, 0x004abc74857e1288ULL, + 0x0024e2434657317cULL, 0x00d98cb3d3e5543cULL)}, + }}, {{ + {FIELD_LITERAL(0x00b4b53eab6bdb19ULL, 0x009b22d8b43711d0ULL, + 0x00d948b9d961785dULL, 0x00cb167b6f279eadULL, + 0x00191de3a678e1c9ULL, 0x00d9dd9511095c2eULL, + 0x00f284324cd43067ULL, 0x00ed74fa535151ddULL)}, + {FIELD_LITERAL(0x007e32c049b5c477ULL, 0x009d2bfdbd9bcfd8ULL, + 0x00636e93045938c6ULL, 0x007fde4af7687298ULL, + 0x0046a5184fafa5d3ULL, 0x0079b1e7f13a359bULL, + 0x00875adf1fb927d6ULL, 0x00333e21c61bcad2ULL)}, + {FIELD_LITERAL(0x00048014f73d8b8dULL, 0x0075684aa0966388ULL, + 0x0092be7df06dc47cULL, 0x0097cebcd0f5568aULL, + 0x005a7004d9c4c6a9ULL, 0x00b0ecbb659924c7ULL, + 0x00d90332dd492a7cULL, 0x0057fc14df11493dULL)}, + }}, {{ + {FIELD_LITERAL(0x0008ed8ea0ad95beULL, 0x0041d324b9709645ULL, + 0x00e25412257a19b4ULL, 0x0058df9f3423d8d2ULL, + 0x00a9ab20def71304ULL, 0x009ae0dbf8ac4a81ULL, + 0x00c9565977e4392aULL, 0x003c9269444baf55ULL)}, + {FIELD_LITERAL(0x007df6cbb926830bULL, 0x00d336058ae37865ULL, + 0x007af47dac696423ULL, 0x0048d3011ec64ac8ULL, + 0x006b87666e40049fULL, 0x0036a2e0e51303d7ULL, + 0x00ba319bd79dbc55ULL, 0x003e2737ecc94f53ULL)}, + {FIELD_LITERAL(0x00d296ff726272d9ULL, 0x00f6d097928fcf57ULL, + 0x00e0e616a55d7013ULL, 0x00deaf454ed9eac7ULL, + 0x0073a56bedef4d92ULL, 0x006ccfdf6fc92e19ULL, + 0x009d1ee1371a7218ULL, 0x00ee3c2ee4462d80ULL)}, + }}, {{ + {FIELD_LITERAL(0x00437bce9bccdf9dULL, 0x00e0c8e2f85dc0a3ULL, + 0x00c91a7073995a19ULL, 0x00856ec9fe294559ULL, + 0x009e4b33394b156eULL, 0x00e245b0dc497e5cULL, + 0x006a54e687eeaeffULL, 0x00f1cd1cd00fdb7cULL)}, + {FIELD_LITERAL(0x008132ae5c5d8cd1ULL, 0x00121d68324a1d9fULL, + 0x00d6be9dafcb8c76ULL, 0x00684d9070edf745ULL, + 0x00519fbc96d7448eULL, 0x00388182fdc1f27eULL, + 0x000235baed41f158ULL, 0x00bf6cf6f1a1796aULL)}, + {FIELD_LITERAL(0x002adc4b4d148219ULL, 0x003084ada0d3a90aULL, + 0x0046de8aab0f2e4eULL, 0x00452d342a67b5fdULL, + 0x00d4b50f01d4de21ULL, 0x00db6d9fc0cefb79ULL, + 0x008c184c86a462cdULL, 0x00e17c83764d42daULL)}, + }}, {{ + {FIELD_LITERAL(0x007b2743b9a1e01aULL, 0x007847ffd42688c4ULL, + 0x006c7844d610a316ULL, 0x00f0cb8b250aa4b0ULL, + 0x00a19060143b3ae6ULL, 0x0014eb10b77cfd80ULL, + 0x000170905729dd06ULL, 0x00063b5b9cd72477ULL)}, + {FIELD_LITERAL(0x00ce382dc7993d92ULL, 0x00021153e938b4c8ULL, + 0x00096f7567f48f51ULL, 0x0058f81ddfe4b0d5ULL, + 0x00cc379a56b355c7ULL, 0x002c760770d3e819ULL, + 0x00ee22d1d26e5a40ULL, 0x00de6d93d5b082d7ULL)}, + {FIELD_LITERAL(0x000a91a42c52e056ULL, 0x00185f6b77fce7eaULL, + 0x000803c51962f6b5ULL, 0x0022528582ba563dULL, + 0x0043f8040e9856d6ULL, 0x0085a29ec81fb860ULL, + 0x005f9a611549f5ffULL, 0x00c1f974ecbd4b06ULL)}, + }}, {{ + {FIELD_LITERAL(0x005b64c6fd65ec97ULL, 0x00c1fdd7f877bc7fULL, + 0x000d9cc6c89f841cULL, 0x005c97b7f1aff9adULL, + 0x0075e3c61475d47eULL, 0x001ecb1ba8153011ULL, + 0x00fe7f1c8d71d40dULL, 0x003fa9757a229832ULL)}, + {FIELD_LITERAL(0x00ffc5c89d2b0cbaULL, 0x00d363d42e3e6fc3ULL, + 0x0019a1a0118e2e8aULL, 0x00f7baeff48882e1ULL, + 0x001bd5af28c6b514ULL, 0x0055476ca2253cb2ULL, + 0x00d8eb1977e2ddf3ULL, 0x00b173b1adb228a1ULL)}, + {FIELD_LITERAL(0x00f2cb99dd0ad707ULL, 0x00e1e08b6859ddd8ULL, + 0x000008f2d0650bccULL, 0x00d7ed392f8615c3ULL, + 0x00976750a94da27fULL, 0x003e83bb0ecb69baULL, + 0x00df8e8d15c14ac6ULL, 0x00f9f7174295d9c2ULL)}, + }}, {{ + {FIELD_LITERAL(0x00f11cc8e0e70bcbULL, 0x00e5dc689974e7ddULL, + 0x0014e409f9ee5870ULL, 0x00826e6689acbd63ULL, + 0x008a6f4e3d895d88ULL, 0x00b26a8da41fd4adULL, + 0x000fb7723f83efd7ULL, 0x009c749db0a5f6c3ULL)}, + {FIELD_LITERAL(0x002389319450f9baULL, 0x003677f31aa1250aULL, + 0x0092c3db642f38cbULL, 0x00f8b64c0dfc9773ULL, + 0x00cd49fe3505b795ULL, 0x0068105a4090a510ULL, + 0x00df0ba2072a8bb6ULL, 0x00eb396143afd8beULL)}, + {FIELD_LITERAL(0x00a0d4ecfb24cdffULL, 0x00ddaf8008ba6479ULL, + 0x00f0b3e36d4b0f44ULL, 0x003734bd3af1f146ULL, + 0x00b87e2efc75527eULL, 0x00d230df55ddab50ULL, + 0x002613257ae56c1dULL, 0x00bc0946d135934dULL)}, + }}, {{ + {FIELD_LITERAL(0x00468711bd994651ULL, 0x0033108fa67561bfULL, + 0x0089d760192a54b4ULL, 0x00adc433de9f1871ULL, + 0x000467d05f36e050ULL, 0x007847e0f0579f7fULL, + 0x00a2314ad320052dULL, 0x00b3a93649f0b243ULL)}, + {FIELD_LITERAL(0x0067f8f0c4fe26c9ULL, 0x0079c4a3cc8f67b9ULL, + 0x0082b1e62f23550dULL, 0x00f2d409caefd7f5ULL, + 0x0080e67dcdb26e81ULL, 0x0087ae993ea1f98aULL, + 0x00aa108becf61d03ULL, 0x001acf11efb608a3ULL)}, + {FIELD_LITERAL(0x008225febbab50d9ULL, 0x00f3b605e4dd2083ULL, + 0x00a32b28189e23d2ULL, 0x00d507e5e5eb4c97ULL, + 0x005a1a84e302821fULL, 0x0006f54c1c5f08c7ULL, + 0x00a347c8cb2843f0ULL, 0x0009f73e9544bfa5ULL)}, + }}, {{ + {FIELD_LITERAL(0x006c59c9ae744185ULL, 0x009fc32f1b4282cdULL, + 0x004d6348ca59b1acULL, 0x00105376881be067ULL, + 0x00af4096013147dcULL, 0x004abfb5a5cb3124ULL, + 0x000d2a7f8626c354ULL, 0x009c6ed568e07431ULL)}, + {FIELD_LITERAL(0x00e828333c297f8bULL, 0x009ef3cf8c3f7e1fULL, + 0x00ab45f8fff31cb9ULL, 0x00c8b4178cb0b013ULL, + 0x00d0c50dd3260a3fULL, 0x0097126ac257f5bcULL, + 0x0042376cc90c705aULL, 0x001d96fdb4a1071eULL)}, + {FIELD_LITERAL(0x00542d44d89ee1a8ULL, 0x00306642e0442d98ULL, + 0x0090853872b87338ULL, 0x002362cbf22dc044ULL, + 0x002c222adff663b8ULL, 0x0067c924495fcb79ULL, + 0x000e621d983c977cULL, 0x00df77a9eccb66fbULL)}, + }}, {{ + {FIELD_LITERAL(0x002809e4bbf1814aULL, 0x00b9e854f9fafb32ULL, + 0x00d35e67c10f7a67ULL, 0x008f1bcb76e748cfULL, + 0x004224d9515687d2ULL, 0x005ba0b774e620c4ULL, + 0x00b5e57db5d54119ULL, 0x00e15babe5683282ULL)}, + {FIELD_LITERAL(0x00832d02369b482cULL, 0x00cba52ff0d93450ULL, + 0x003fa9c908d554dbULL, 0x008d1e357b54122fULL, + 0x00abd91c2dc950c6ULL, 0x007eff1df4c0ec69ULL, + 0x003f6aeb13fb2d31ULL, 0x00002d6179fc5b2cULL)}, + {FIELD_LITERAL(0x0046c9eda81c9c89ULL, 0x00b60cb71c8f62fcULL, + 0x0022f5a683baa558ULL, 0x00f87319fccdf997ULL, + 0x009ca09b51ce6a22ULL, 0x005b12baf4af7d77ULL, + 0x008a46524a1e33e2ULL, 0x00035a77e988be0dULL)}, + }}, {{ + {FIELD_LITERAL(0x00a7efe46a7dbe2fULL, 0x002f66fd55014fe7ULL, + 0x006a428afa1ff026ULL, 0x0056caaa9604ab72ULL, + 0x0033f3bcd7fac8aeULL, 0x00ccb1aa01c86764ULL, + 0x00158d1edf13bf40ULL, 0x009848ee76fcf3b4ULL)}, + {FIELD_LITERAL(0x00a9e7730a819691ULL, 0x00d9cc73c4992b70ULL, + 0x00e299bde067de5aULL, 0x008c314eb705192aULL, + 0x00e7226f17e8a3ccULL, 0x0029dfd956e65a47ULL, + 0x0053a8e839073b12ULL, 0x006f942b2ab1597eULL)}, + {FIELD_LITERAL(0x001c3d780ecd5e39ULL, 0x0094f247fbdcc5feULL, + 0x00d5c786fd527764ULL, 0x00b6f4da74f0db2aULL, + 0x0080f1f8badcd5fcULL, 0x00f36a373ad2e23bULL, + 0x00f804f9f4343bf2ULL, 0x00d1af40ec623982ULL)}, + }}, {{ + {FIELD_LITERAL(0x0082aeace5f1b144ULL, 0x00f68b3108cf4dd3ULL, + 0x00634af01dde3020ULL, 0x000beab5df5c2355ULL, + 0x00e8b790d1b49b0bULL, 0x00e48d15854e36f4ULL, + 0x0040ab2d95f3db9fULL, 0x002711c4ed9e899aULL)}, + {FIELD_LITERAL(0x0039343746531ebeULL, 0x00c8509d835d429dULL, + 0x00e79eceff6b0018ULL, 0x004abfd31e8efce5ULL, + 0x007bbfaaa1e20210ULL, 0x00e3be89c193e179ULL, + 0x001c420f4c31d585ULL, 0x00f414a315bef5aeULL)}, + {FIELD_LITERAL(0x007c296a24990df8ULL, 0x00d5d07525a75588ULL, + 0x00dd8e113e94b7e7ULL, 0x007bbc58febe0cc8ULL, + 0x0029f51af9bfcad3ULL, 0x007e9311ec7ab6f3ULL, + 0x009a884de1676343ULL, 0x0050d5f2dce84be9ULL)}, + }}, {{ + {FIELD_LITERAL(0x005fa020cca2450aULL, 0x00491c29db6416d8ULL, + 0x0037cefe3f9f9a85ULL, 0x003d405230647066ULL, + 0x0049e835f0fdbe89ULL, 0x00feb78ac1a0815cULL, + 0x00828e4b32dc9724ULL, 0x00db84f2dc8d6fd4ULL)}, + {FIELD_LITERAL(0x0098cddc8b39549aULL, 0x006da37e3b05d22cULL, + 0x00ce633cfd4eb3cbULL, 0x00fda288ef526acdULL, + 0x0025338878c5d30aULL, 0x00f34438c4e5a1b4ULL, + 0x00584efea7c310f1ULL, 0x0041a551f1b660adULL)}, + {FIELD_LITERAL(0x00d7f7a8fbd6437aULL, 0x0062872413bf3753ULL, + 0x00ad4bbcb43c584bULL, 0x007fe49be601d7e3ULL, + 0x0077c659789babf4ULL, 0x00eb45fcb06a741bULL, + 0x005ce244913f9708ULL, 0x0088426401736326ULL)}, + }}, {{ + {FIELD_LITERAL(0x007bf562ca768d7cULL, 0x006c1f3a174e387cULL, + 0x00f024b447fee939ULL, 0x007e7af75f01143fULL, + 0x003adb70b4eed89dULL, 0x00e43544021ad79aULL, + 0x0091f7f7042011f6ULL, 0x0093c1a1ee3a0ddcULL)}, + {FIELD_LITERAL(0x00a0b68ec1eb72d2ULL, 0x002c03235c0d45a0ULL, + 0x00553627323fe8c5ULL, 0x006186e94b17af94ULL, + 0x00a9906196e29f14ULL, 0x0025b3aee6567733ULL, + 0x007e0dd840080517ULL, 0x0018eb5801a4ba93ULL)}, + {FIELD_LITERAL(0x00d7fe7017bf6a40ULL, 0x006e3f0624be0c42ULL, + 0x00ffbba205358245ULL, 0x00f9fc2cf8194239ULL, + 0x008d93b37bf15b4eULL, 0x006ddf2e38be8e95ULL, + 0x002b6e79bf5fcff9ULL, 0x00ab355da425e2deULL)}, + }}, {{ + {FIELD_LITERAL(0x00938f97e20be973ULL, 0x0099141a36aaf306ULL, + 0x0057b0ca29e545a1ULL, 0x0085db571f9fbc13ULL, + 0x008b333c554b4693ULL, 0x0043ab6ef3e241cbULL, + 0x0054fb20aa1e5c70ULL, 0x00be0ff852760adfULL)}, + {FIELD_LITERAL(0x003973d8938971d6ULL, 0x002aca26fa80c1f5ULL, + 0x00108af1faa6b513ULL, 0x00daae275d7924e6ULL, + 0x0053634ced721308ULL, 0x00d2355fe0bbd443ULL, + 0x00357612b2d22095ULL, 0x00f9bb9dd4136cf3ULL)}, + {FIELD_LITERAL(0x002bff12cf5e03a5ULL, 0x001bdb1fa8a19cf8ULL, + 0x00c91c6793f84d39ULL, 0x00f869f1b2eba9afULL, + 0x0059bc547dc3236bULL, 0x00d91611d6d38689ULL, + 0x00e062daaa2c0214ULL, 0x00ed3c047cc2bc82ULL)}, + }}, {{ + {FIELD_LITERAL(0x000050d70c32b31aULL, 0x001939d576d437b3ULL, + 0x00d709e598bf9fe6ULL, 0x00a885b34bd2ee9eULL, + 0x00dd4b5c08ab1a50ULL, 0x0091bebd50b55639ULL, + 0x00cf79ff64acdbc6ULL, 0x006067a39d826336ULL)}, + {FIELD_LITERAL(0x0062dd0fb31be374ULL, 0x00fcc96b84c8e727ULL, + 0x003f64f1375e6ae3ULL, 0x0057d9b6dd1af004ULL, + 0x00d6a167b1103c7bULL, 0x00dd28f3180fb537ULL, + 0x004ff27ad7167128ULL, 0x008934c33461f2acULL)}, + {FIELD_LITERAL(0x0065b472b7900043ULL, 0x00ba7efd2ff1064bULL, + 0x000b67d6c4c3020fULL, 0x0012d28469f4e46dULL, + 0x0031c32939703ec7ULL, 0x00b49f0bce133066ULL, + 0x00f7e10416181d47ULL, 0x005c90f51867eeccULL)}, + }}, {{ + {FIELD_LITERAL(0x0051207abd179101ULL, 0x00fc2a5c20d9c5daULL, + 0x00fb9d5f2701b6dfULL, 0x002dd040fdea82b8ULL, + 0x00f163b0738442ffULL, 0x00d9736bd68855b8ULL, + 0x00e0d8e93005e61cULL, 0x00df5a40b3988570ULL)}, + {FIELD_LITERAL(0x0006918f5dfce6dcULL, 0x00d4bf1c793c57fbULL, + 0x0069a3f649435364ULL, 0x00e89a50e5b0cd6eULL, + 0x00b9f6a237e973afULL, 0x006d4ed8b104e41dULL, + 0x00498946a3924cd2ULL, 0x00c136ec5ac9d4f7ULL)}, + {FIELD_LITERAL(0x0011a9c290ac5336ULL, 0x002b9a2d4a6a6533ULL, + 0x009a8a68c445d937ULL, 0x00361b27b07e5e5cULL, + 0x003c043b1755b974ULL, 0x00b7eb66cf1155eeULL, + 0x0077af5909eefff2ULL, 0x0098f609877cc806ULL)}, + }}, {{ + {FIELD_LITERAL(0x00ab13af436bf8f4ULL, 0x000bcf0a0dac8574ULL, + 0x00d50c864f705045ULL, 0x00c40e611debc842ULL, + 0x0085010489bd5caaULL, 0x007c5050acec026fULL, + 0x00f67d943c8da6d1ULL, 0x00de1da0278074c6ULL)}, + {FIELD_LITERAL(0x00b373076597455fULL, 0x00e83f1af53ac0f5ULL, + 0x0041f63c01dc6840ULL, 0x0097dea19b0c6f4bULL, + 0x007f9d63b4c1572cULL, 0x00e692d492d0f5f0ULL, + 0x00cbcb392e83b4adULL, 0x0069c0f39ed9b1a8ULL)}, + {FIELD_LITERAL(0x00861030012707c9ULL, 0x009fbbdc7fd4aafbULL, + 0x008f591d6b554822ULL, 0x00df08a41ea18adeULL, + 0x009d7d83e642abeaULL, 0x0098c71bda3b78ffULL, + 0x0022c89e7021f005ULL, 0x0044d29a3fe1e3c4ULL)}, + }}, {{ + {FIELD_LITERAL(0x00e748cd7b5c52f2ULL, 0x00ea9df883f89cc3ULL, + 0x0018970df156b6c7ULL, 0x00c5a46c2a33a847ULL, + 0x00cbde395e32aa09ULL, 0x0072474ebb423140ULL, + 0x00fb00053086a23dULL, 0x001dafcfe22d4e1fULL)}, + {FIELD_LITERAL(0x00c903ee6d825540ULL, 0x00add6c4cf98473eULL, + 0x007636efed4227f1ULL, 0x00905124ae55e772ULL, + 0x00e6b38fab12ed53ULL, 0x0045e132b863fe55ULL, + 0x003974662edb366aULL, 0x00b1787052be8208ULL)}, + {FIELD_LITERAL(0x00a614b00d775c7cULL, 0x00d7c78941cc7754ULL, + 0x00422dd68b5dabc4ULL, 0x00a6110f0167d28bULL, + 0x00685a309c252886ULL, 0x00b439ffd5143660ULL, + 0x003656e29ee7396fULL, 0x00c7c9b9ed5ad854ULL)}, + }}, {{ + {FIELD_LITERAL(0x0040f7e7c5b37bf2ULL, 0x0064e4dc81181bbaULL, + 0x00a8767ae2a366b6ULL, 0x001496b4f90546f2ULL, + 0x002a28493f860441ULL, 0x0021f59513049a3aULL, + 0x00852d369a8b7ee3ULL, 0x00dd2e7d8b7d30a9ULL)}, + {FIELD_LITERAL(0x00006e34a35d9fbcULL, 0x00eee4e48b2f019aULL, + 0x006b344743003a5fULL, 0x00541d514f04a7e3ULL, + 0x00e81f9ee7647455ULL, 0x005e2b916c438f81ULL, + 0x00116f8137b7eff0ULL, 0x009bd3decc7039d1ULL)}, + {FIELD_LITERAL(0x0005d226f434110dULL, 0x00af8288b8ef21d5ULL, + 0x004a7a52ef181c8cULL, 0x00be0b781b4b06deULL, + 0x00e6e3627ded07e1ULL, 0x00e43aa342272b8bULL, + 0x00e86ab424577d84ULL, 0x00fb292c566e35bbULL)}, + }}, {{ + {FIELD_LITERAL(0x00334f5303ea1222ULL, 0x00dfb3dbeb0a5d3eULL, + 0x002940d9592335c1ULL, 0x00706a7a63e8938aULL, + 0x005a533558bc4cafULL, 0x00558e33192022a9ULL, + 0x00970d9faf74c133ULL, 0x002979fcb63493caULL)}, + {FIELD_LITERAL(0x00e38abece3c82abULL, 0x005a51f18a2c7a86ULL, + 0x009dafa2e86d592eULL, 0x00495a62eb688678ULL, + 0x00b79df74c0eb212ULL, 0x0023e8cc78b75982ULL, + 0x005998cb91075e13ULL, 0x00735aa9ba61bc76ULL)}, + {FIELD_LITERAL(0x00d9f7a82ddbe628ULL, 0x00a1fc782889ae0fULL, + 0x0071ffda12d14b66ULL, 0x0037cf4eca7fb3d5ULL, + 0x00c80bc242c58808ULL, 0x0075bf8c2d08c863ULL, + 0x008d41f31afc52a7ULL, 0x00197962ecf38741ULL)}, + }}, {{ + {FIELD_LITERAL(0x006e9f475cccf2eeULL, 0x00454b9cd506430cULL, + 0x00224a4fb79ee479ULL, 0x0062e3347ef0b5e2ULL, + 0x0034fd2a3512232aULL, 0x00b8b3cb0f457046ULL, + 0x00eb20165daa38ecULL, 0x00128eebc2d9c0f7ULL)}, + {FIELD_LITERAL(0x00bfc5fa1e4ea21fULL, 0x00c21d7b6bb892e6ULL, + 0x00cf043f3acf0291ULL, 0x00c13f2f849b3c90ULL, + 0x00d1a97ebef10891ULL, 0x0061e130a445e7feULL, + 0x0019513fdedbf22bULL, 0x001d60c813bff841ULL)}, + {FIELD_LITERAL(0x0019561c7fcf0213ULL, 0x00e3dca6843ebd77ULL, + 0x0068ea95b9ca920eULL, 0x009bdfb70f253595ULL, + 0x00c68f59186aa02aULL, 0x005aee1cca1c3039ULL, + 0x00ab79a8a937a1ceULL, 0x00b9a0e549959e6fULL)}, + }}, {{ + {FIELD_LITERAL(0x00c79e0b6d97dfbdULL, 0x00917c71fd2bc6e8ULL, + 0x00db7529ccfb63d8ULL, 0x00be5be957f17866ULL, + 0x00a9e11fdc2cdac1ULL, 0x007b91a8e1f44443ULL, + 0x00a3065e4057d80fULL, 0x004825f5b8d5f6d4ULL)}, + {FIELD_LITERAL(0x003e4964fa8a8fc8ULL, 0x00f6a1cdbcf41689ULL, + 0x00943cb18fe7fda7ULL, 0x00606dafbf34440aULL, + 0x005d37a86399c789ULL, 0x00e79a2a69417403ULL, + 0x00fe34f7e68b8866ULL, 0x0011f448ed2df10eULL)}, + {FIELD_LITERAL(0x00f1f57efcc1fcc4ULL, 0x00513679117de154ULL, + 0x002e5b5b7c86d8c3ULL, 0x009f6486561f9cfbULL, + 0x00169e74b0170cf7ULL, 0x00900205af4af696ULL, + 0x006acfddb77853f3ULL, 0x00df184c90f31068ULL)}, + }}, {{ + {FIELD_LITERAL(0x00b37396c3320791ULL, 0x00fc7b67175c5783ULL, + 0x00c36d2cd73ecc38ULL, 0x0080ebcc0b328fc5ULL, + 0x0043a5b22b35d35dULL, 0x00466c9f1713c9daULL, + 0x0026ad346dcaa8daULL, 0x007c684e701183a6ULL)}, + {FIELD_LITERAL(0x00fd579ffb691713ULL, 0x00b76af4f81c412dULL, + 0x00f239de96110f82ULL, 0x00e965fb437f0306ULL, + 0x00ca7e9436900921ULL, 0x00e487f1325fa24aULL, + 0x00633907de476380ULL, 0x00721c62ac5b8ea0ULL)}, + {FIELD_LITERAL(0x00c0d54e542eb4f9ULL, 0x004ed657171c8dcfULL, + 0x00b743a4f7c2a39bULL, 0x00fd9f93ed6cc567ULL, + 0x00307fae3113e58bULL, 0x0058aa577c93c319ULL, + 0x00d254556f35b346ULL, 0x00491aada2203f0dULL)}, + }}, {{ + {FIELD_LITERAL(0x00dff3103786ff34ULL, 0x000144553b1f20c3ULL, + 0x0095613baeb930e4ULL, 0x00098058275ea5d4ULL, + 0x007cd1402b046756ULL, 0x0074d74e4d58aee3ULL, + 0x005f93fc343ff69bULL, 0x00873df17296b3b0ULL)}, + {FIELD_LITERAL(0x00c4a1fb48635413ULL, 0x00b5dd54423ad59fULL, + 0x009ff5d53fd24a88ULL, 0x003c98d267fc06a7ULL, + 0x002db7cb20013641ULL, 0x00bd1d6716e191f2ULL, + 0x006dbc8b29094241ULL, 0x0044bbf233dafa2cULL)}, + {FIELD_LITERAL(0x0055838d41f531e6ULL, 0x00bf6a2dd03c81b2ULL, + 0x005827a061c4839eULL, 0x0000de2cbb36aac3ULL, + 0x002efa29d9717478ULL, 0x00f9e928cc8a77baULL, + 0x00c134b458def9efULL, 0x00958a182223fc48ULL)}, + }}, {{ + {FIELD_LITERAL(0x000a9ee23c06881fULL, 0x002c727d3d871945ULL, + 0x00f47d971512d24aULL, 0x00671e816f9ef31aULL, + 0x00883af2cfaad673ULL, 0x00601f98583d6c9aULL, + 0x00b435f5adc79655ULL, 0x00ad87b71c04bff2ULL)}, + {FIELD_LITERAL(0x007860d99db787cfULL, 0x00fda8983018f4a8ULL, + 0x008c8866bac4743cULL, 0x00ef471f84c82a3fULL, + 0x00abea5976d3b8e7ULL, 0x00714882896cd015ULL, + 0x00b49fae584ddac5ULL, 0x008e33a1a0b69c81ULL)}, + {FIELD_LITERAL(0x007b6ee2c9e8a9ecULL, 0x002455dbbd89d622ULL, + 0x006490cf4eaab038ULL, 0x00d925f6c3081561ULL, + 0x00153b3047de7382ULL, 0x003b421f8bdceb6fULL, + 0x00761a4a5049da78ULL, 0x00980348c5202433ULL)}, + }}, {{ + {FIELD_LITERAL(0x007f8a43da97dd5cULL, 0x00058539c800fc7bULL, + 0x0040f3cf5a28414aULL, 0x00d68dd0d95283d6ULL, + 0x004adce9da90146eULL, 0x00befa41c7d4f908ULL, + 0x007603bc2e3c3060ULL, 0x00bdf360ab3545dbULL)}, + {FIELD_LITERAL(0x00eebfd4e2312cc3ULL, 0x00474b2564e4fc8cULL, + 0x003303ef14b1da9bULL, 0x003c93e0e66beb1dULL, + 0x0013619b0566925aULL, 0x008817c24d901bf3ULL, + 0x00b62bd8898d218bULL, 0x0075a7716f1e88a2ULL)}, + {FIELD_LITERAL(0x0009218da1e6890fULL, 0x0026907f5fd02575ULL, + 0x004dabed5f19d605ULL, 0x003abf181870249dULL, + 0x00b52fd048cc92c4ULL, 0x00b6dd51e415a5c5ULL, + 0x00d9eb82bd2b4014ULL, 0x002c865a43b46b43ULL)}, + }}, {{ + {FIELD_LITERAL(0x0070047189452f4cULL, 0x00f7ad12e1ce78d5ULL, + 0x00af1ba51ec44a8bULL, 0x005f39f63e667cd6ULL, + 0x00058eac4648425eULL, 0x00d7fdab42bea03bULL, + 0x0028576a5688de15ULL, 0x00af973209e77c10ULL)}, + {FIELD_LITERAL(0x00c338b915d8fef0ULL, 0x00a893292045c39aULL, + 0x0028ab4f2eba6887ULL, 0x0060743cb519fd61ULL, + 0x0006213964093ac0ULL, 0x007c0b7a43f6266dULL, + 0x008e3557c4fa5bdaULL, 0x002da976de7b8d9dULL)}, + {FIELD_LITERAL(0x0048729f8a8b6dcdULL, 0x00fe23b85cc4d323ULL, + 0x00e7384d16e4db0eULL, 0x004a423970678942ULL, + 0x00ec0b763345d4baULL, 0x00c477b9f99ed721ULL, + 0x00c29dad3777b230ULL, 0x001c517b466f7df6ULL)}, + }}, {{ + {FIELD_LITERAL(0x006366c380f7b574ULL, 0x001c7d1f09ff0438ULL, + 0x003e20a7301f5b22ULL, 0x00d3efb1916d28f6ULL, + 0x0049f4f81060ce83ULL, 0x00c69d91ea43ced1ULL, + 0x002b6f3e5cd269edULL, 0x005b0fb22ce9ec65ULL)}, + {FIELD_LITERAL(0x00aa2261022d883fULL, 0x00ebcca4548010acULL, + 0x002528512e28a437ULL, 0x0070ca7676b66082ULL, + 0x0084bda170f7c6d3ULL, 0x00581b4747c9b8bbULL, + 0x005c96a01061c7e2ULL, 0x00fb7c4a362b5273ULL)}, + {FIELD_LITERAL(0x00c30020eb512d02ULL, 0x0060f288283a4d26ULL, + 0x00b7ed13becde260ULL, 0x0075ebb74220f6e9ULL, + 0x00701079fcfe8a1fULL, 0x001c28fcdff58938ULL, + 0x002e4544b8f4df6bULL, 0x0060c5bc4f1a7d73ULL)}, + }}, {{ + {FIELD_LITERAL(0x00ae307cf069f701ULL, 0x005859f222dd618bULL, + 0x00212d6c46ec0b0dULL, 0x00a0fe4642afb62dULL, + 0x00420d8e4a0a8903ULL, 0x00a80ff639bdf7b0ULL, + 0x0019bee1490b5d8eULL, 0x007439e4b9c27a86ULL)}, + {FIELD_LITERAL(0x00a94700032a093fULL, 0x0076e96c225216e7ULL, + 0x00a63a4316e45f91ULL, 0x007d8bbb4645d3b2ULL, + 0x00340a6ff22793ebULL, 0x006f935d4572aeb7ULL, + 0x00b1fb69f00afa28ULL, 0x009e8f3423161ed3ULL)}, + {FIELD_LITERAL(0x009ef49c6b5ced17ULL, 0x00a555e6269e9f0aULL, + 0x007e6f1d79ec73b5ULL, 0x009ac78695a32ac4ULL, + 0x0001d77fbbcd5682ULL, 0x008cea1fee0aaeedULL, + 0x00f42bea82a53462ULL, 0x002e46ab96cafcc9ULL)}, + }}, {{ + {FIELD_LITERAL(0x0051cfcc5885377aULL, 0x00dce566cb1803caULL, + 0x00430c7643f2c7d4ULL, 0x00dce1a1337bdcc0ULL, + 0x0010d5bd7283c128ULL, 0x003b1b547f9b46feULL, + 0x000f245e37e770abULL, 0x007b72511f022b37ULL)}, + {FIELD_LITERAL(0x0060db815bc4786cULL, 0x006fab25beedc434ULL, + 0x00c610d06084797cULL, 0x000c48f08537bec0ULL, + 0x0031aba51c5b93daULL, 0x007968fa6e01f347ULL, + 0x0030070da52840c6ULL, 0x00c043c225a4837fULL)}, + {FIELD_LITERAL(0x001bcfd00649ee93ULL, 0x006dceb47e2a0fd5ULL, + 0x00f2cebda0cf8fd0ULL, 0x00b6b9d9d1fbdec3ULL, + 0x00815262e6490611ULL, 0x00ef7f5ce3176760ULL, + 0x00e49cd0c998d58bULL, 0x005fc6cc269ba57cULL)}, + }}, {{ + {FIELD_LITERAL(0x008940211aa0d633ULL, 0x00addae28136571dULL, + 0x00d68fdbba20d673ULL, 0x003bc6129bc9e21aULL, + 0x000346cf184ebe9aULL, 0x0068774d741ebc7fULL, + 0x0019d5e9e6966557ULL, 0x0003cbd7f981b651ULL)}, + {FIELD_LITERAL(0x004a2902926f8d3fULL, 0x00ad79b42637ab75ULL, + 0x0088f60b90f2d4e8ULL, 0x0030f54ef0e398c4ULL, + 0x00021dc9bf99681eULL, 0x007ebf66fde74ee3ULL, + 0x004ade654386e9a4ULL, 0x00e7485066be4c27ULL)}, + {FIELD_LITERAL(0x00445f1263983be0ULL, 0x004cf371dda45e6aULL, + 0x00744a89d5a310e7ULL, 0x001f20ce4f904833ULL, + 0x00e746edebe66e29ULL, 0x000912ab1f6c153dULL, + 0x00f61d77d9b2444cULL, 0x0001499cd6647610ULL)}, }} } }; @@ -343,133 +1063,421 @@ const struct curve448_precomputed_s *curve448_precomputed_base static const niels_t curve448_wnaf_base_table[32] = { {{ - {FIELD_LITERAL(0x00303cda6feea532,0x00860f1d5a3850e4,0x00226b9fa4728ccd,0x00e822938a0a0c0c,0x00263a61c9ea9216,0x001204029321b828,0x006a468360983c65,0x0002846f0a782143)}, - {FIELD_LITERAL(0x00303cda6feea532,0x00860f1d5a3850e4,0x00226b9fa4728ccd,0x006822938a0a0c0c,0x00263a61c9ea9215,0x001204029321b828,0x006a468360983c65,0x0082846f0a782143)}, - {FIELD_LITERAL(0x00ef8e22b275198d,0x00b0eb141a0b0e8b,0x001f6789da3cb38c,0x006d2ff8ed39073e,0x00610bdb69a167f3,0x00571f306c9689b4,0x00f557e6f84b2df8,0x002affd38b2c86db)}, + {FIELD_LITERAL(0x00303cda6feea532ULL, 0x00860f1d5a3850e4ULL, + 0x00226b9fa4728ccdULL, 0x00e822938a0a0c0cULL, + 0x00263a61c9ea9216ULL, 0x001204029321b828ULL, + 0x006a468360983c65ULL, 0x0002846f0a782143ULL)}, + {FIELD_LITERAL(0x00303cda6feea532ULL, 0x00860f1d5a3850e4ULL, + 0x00226b9fa4728ccdULL, 0x006822938a0a0c0cULL, + 0x00263a61c9ea9215ULL, 0x001204029321b828ULL, + 0x006a468360983c65ULL, 0x0082846f0a782143ULL)}, + {FIELD_LITERAL(0x00ef8e22b275198dULL, 0x00b0eb141a0b0e8bULL, + 0x001f6789da3cb38cULL, 0x006d2ff8ed39073eULL, + 0x00610bdb69a167f3ULL, 0x00571f306c9689b4ULL, + 0x00f557e6f84b2df8ULL, 0x002affd38b2c86dbULL)}, }}, {{ - {FIELD_LITERAL(0x00cea0fc8d2e88b5,0x00821612d69f1862,0x0074c283b3e67522,0x005a195ba05a876d,0x000cddfe557feea4,0x008046c795bcc5e5,0x00540969f4d6e119,0x00d27f96d6b143d5)}, - {FIELD_LITERAL(0x000c3b1019d474e8,0x00e19533e4952284,0x00cc9810ba7c920a,0x00f103d2785945ac,0x00bfa5696cc69b34,0x00a8d3d51e9ca839,0x005623cb459586b9,0x00eae7ce1cd52e9e)}, - {FIELD_LITERAL(0x0005a178751dd7d8,0x002cc3844c69c42f,0x00acbfe5efe10539,0x009c20f43431a65a,0x008435d96374a7b3,0x009ee57566877bd3,0x0044691725ed4757,0x001e87bb2fe2c6b2)}, + {FIELD_LITERAL(0x00cea0fc8d2e88b5ULL, 0x00821612d69f1862ULL, + 0x0074c283b3e67522ULL, 0x005a195ba05a876dULL, + 0x000cddfe557feea4ULL, 0x008046c795bcc5e5ULL, + 0x00540969f4d6e119ULL, 0x00d27f96d6b143d5ULL)}, + {FIELD_LITERAL(0x000c3b1019d474e8ULL, 0x00e19533e4952284ULL, + 0x00cc9810ba7c920aULL, 0x00f103d2785945acULL, + 0x00bfa5696cc69b34ULL, 0x00a8d3d51e9ca839ULL, + 0x005623cb459586b9ULL, 0x00eae7ce1cd52e9eULL)}, + {FIELD_LITERAL(0x0005a178751dd7d8ULL, 0x002cc3844c69c42fULL, + 0x00acbfe5efe10539ULL, 0x009c20f43431a65aULL, + 0x008435d96374a7b3ULL, 0x009ee57566877bd3ULL, + 0x0044691725ed4757ULL, 0x001e87bb2fe2c6b2ULL)}, }}, {{ - {FIELD_LITERAL(0x000cedc4debf7a04,0x002ffa45000470ac,0x002e9f9678201915,0x0017da1208c4fe72,0x007d558cc7d656cb,0x0037a827287cf289,0x00142472d3441819,0x009c21f166cf8dd1)}, - {FIELD_LITERAL(0x003ef83af164b2f2,0x000949a5a0525d0d,0x00f4498186cac051,0x00e77ac09ef126d2,0x0073ae0b2c9296e9,0x001c163f6922e3ed,0x0062946159321bea,0x00cfb79b22990b39)}, - {FIELD_LITERAL(0x00b001431ca9e654,0x002d7e5eabcc9a3a,0x0052e8114c2f6747,0x0079ac4f94487f92,0x00bffd919b5d749c,0x00261f92ad15e620,0x00718397b7a97895,0x00c1443e6ebbc0c4)}, + {FIELD_LITERAL(0x000cedc4debf7a04ULL, 0x002ffa45000470acULL, + 0x002e9f9678201915ULL, 0x0017da1208c4fe72ULL, + 0x007d558cc7d656cbULL, 0x0037a827287cf289ULL, + 0x00142472d3441819ULL, 0x009c21f166cf8dd1ULL)}, + {FIELD_LITERAL(0x003ef83af164b2f2ULL, 0x000949a5a0525d0dULL, + 0x00f4498186cac051ULL, 0x00e77ac09ef126d2ULL, + 0x0073ae0b2c9296e9ULL, 0x001c163f6922e3edULL, + 0x0062946159321beaULL, 0x00cfb79b22990b39ULL)}, + {FIELD_LITERAL(0x00b001431ca9e654ULL, 0x002d7e5eabcc9a3aULL, + 0x0052e8114c2f6747ULL, 0x0079ac4f94487f92ULL, + 0x00bffd919b5d749cULL, 0x00261f92ad15e620ULL, + 0x00718397b7a97895ULL, 0x00c1443e6ebbc0c4ULL)}, }}, {{ - {FIELD_LITERAL(0x00eacd90c1e0a049,0x008977935b149fbe,0x0004cb9ba11c93dc,0x009fbd5b3470844d,0x004bc18c9bfc22cf,0x0057679a991839f3,0x00ef15b76fb4092e,0x0074a5173a225041)}, - {FIELD_LITERAL(0x003f5f9d7ec4777b,0x00ab2e733c919c94,0x001bb6c035245ae5,0x00a325a49a883630,0x0033e9a9ea3cea2f,0x00e442a1eaa0e844,0x00b2116d5b0e71b8,0x00c16abed6d64047)}, - {FIELD_LITERAL(0x00c560b5ed051165,0x001945adc5d65094,0x00e221865710f910,0x00cc12bc9e9b8ceb,0x004faa9518914e35,0x0017476d89d42f6d,0x00b8f637c8fa1c8b,0x0088c7d2790864b8)}, + {FIELD_LITERAL(0x00eacd90c1e0a049ULL, 0x008977935b149fbeULL, + 0x0004cb9ba11c93dcULL, 0x009fbd5b3470844dULL, + 0x004bc18c9bfc22cfULL, 0x0057679a991839f3ULL, + 0x00ef15b76fb4092eULL, 0x0074a5173a225041ULL)}, + {FIELD_LITERAL(0x003f5f9d7ec4777bULL, 0x00ab2e733c919c94ULL, + 0x001bb6c035245ae5ULL, 0x00a325a49a883630ULL, + 0x0033e9a9ea3cea2fULL, 0x00e442a1eaa0e844ULL, + 0x00b2116d5b0e71b8ULL, 0x00c16abed6d64047ULL)}, + {FIELD_LITERAL(0x00c560b5ed051165ULL, 0x001945adc5d65094ULL, + 0x00e221865710f910ULL, 0x00cc12bc9e9b8cebULL, + 0x004faa9518914e35ULL, 0x0017476d89d42f6dULL, + 0x00b8f637c8fa1c8bULL, 0x0088c7d2790864b8ULL)}, }}, {{ - {FIELD_LITERAL(0x00ef7eafc1c69be6,0x0085d3855778fbea,0x002c8d5b450cb6f5,0x004e77de5e1e7fec,0x0047c057893abded,0x001b430b85d51e16,0x00965c7b45640c3c,0x00487b2bb1162b97)}, - {FIELD_LITERAL(0x0099c73a311beec2,0x00a3eff38d8912ad,0x002efa9d1d7e8972,0x00f717ae1e14d126,0x002833f795850c8b,0x0066c12ad71486bd,0x00ae9889da4820eb,0x00d6044309555c08)}, - {FIELD_LITERAL(0x004b1c5283d15e41,0x00669d8ea308ff75,0x0004390233f762a1,0x00e1d67b83cb6cec,0x003eebaa964c78b1,0x006b0aff965eb664,0x00b313d4470bdc37,0x008814ffcb3cb9d8)}, + {FIELD_LITERAL(0x00ef7eafc1c69be6ULL, 0x0085d3855778fbeaULL, + 0x002c8d5b450cb6f5ULL, 0x004e77de5e1e7fecULL, + 0x0047c057893abdedULL, 0x001b430b85d51e16ULL, + 0x00965c7b45640c3cULL, 0x00487b2bb1162b97ULL)}, + {FIELD_LITERAL(0x0099c73a311beec2ULL, 0x00a3eff38d8912adULL, + 0x002efa9d1d7e8972ULL, 0x00f717ae1e14d126ULL, + 0x002833f795850c8bULL, 0x0066c12ad71486bdULL, + 0x00ae9889da4820ebULL, 0x00d6044309555c08ULL)}, + {FIELD_LITERAL(0x004b1c5283d15e41ULL, 0x00669d8ea308ff75ULL, + 0x0004390233f762a1ULL, 0x00e1d67b83cb6cecULL, + 0x003eebaa964c78b1ULL, 0x006b0aff965eb664ULL, + 0x00b313d4470bdc37ULL, 0x008814ffcb3cb9d8ULL)}, }}, {{ - {FIELD_LITERAL(0x009724b8ce68db70,0x007678b5ed006f3d,0x00bdf4b89c0abd73,0x00299748e04c7c6d,0x00ddd86492c3c977,0x00c5a7febfa30a99,0x00ed84715b4b02bb,0x00319568adf70486)}, - {FIELD_LITERAL(0x0070ff2d864de5bb,0x005a37eeb637ee95,0x0033741c258de160,0x00e6ca5cb1988f46,0x001ceabd92a24661,0x0030957bd500fe40,0x001c3362afe912c5,0x005187889f678bd2)}, - {FIELD_LITERAL(0x0086835fc62bbdc7,0x009c3516ca4910a1,0x00956c71f8d00783,0x0095c78fcf63235f,0x00fc7ff6ba05c222,0x00cdd8b3f8d74a52,0x00ac5ae16de8256e,0x00e9d4be8ed48624)}, + {FIELD_LITERAL(0x009724b8ce68db70ULL, 0x007678b5ed006f3dULL, + 0x00bdf4b89c0abd73ULL, 0x00299748e04c7c6dULL, + 0x00ddd86492c3c977ULL, 0x00c5a7febfa30a99ULL, + 0x00ed84715b4b02bbULL, 0x00319568adf70486ULL)}, + {FIELD_LITERAL(0x0070ff2d864de5bbULL, 0x005a37eeb637ee95ULL, + 0x0033741c258de160ULL, 0x00e6ca5cb1988f46ULL, + 0x001ceabd92a24661ULL, 0x0030957bd500fe40ULL, + 0x001c3362afe912c5ULL, 0x005187889f678bd2ULL)}, + {FIELD_LITERAL(0x0086835fc62bbdc7ULL, 0x009c3516ca4910a1ULL, + 0x00956c71f8d00783ULL, 0x0095c78fcf63235fULL, + 0x00fc7ff6ba05c222ULL, 0x00cdd8b3f8d74a52ULL, + 0x00ac5ae16de8256eULL, 0x00e9d4be8ed48624ULL)}, }}, {{ - {FIELD_LITERAL(0x00c0ce11405df2d8,0x004e3f37b293d7b6,0x002410172e1ac6db,0x00b8dbff4bf8143d,0x003a7b409d56eb66,0x003e0f6a0dfef9af,0x0081c4e4d3645be1,0x00ce76076b127623)}, - {FIELD_LITERAL(0x00f6ee0f98974239,0x0042d89af07d3a4f,0x00846b7fe84346b5,0x006a21fc6a8d39a1,0x00ac8bc2541ff2d9,0x006d4e2a77732732,0x009a39b694cc3f2f,0x0085c0aa2a404c8f)}, - {FIELD_LITERAL(0x00b261101a218548,0x00c1cae96424277b,0x00869da0a77dd268,0x00bc0b09f8ec83ea,0x00d61027f8e82ba9,0x00aa4c85999dce67,0x00eac3132b9f3fe1,0x00fb9b0cf1c695d2)}, + {FIELD_LITERAL(0x00c0ce11405df2d8ULL, 0x004e3f37b293d7b6ULL, + 0x002410172e1ac6dbULL, 0x00b8dbff4bf8143dULL, + 0x003a7b409d56eb66ULL, 0x003e0f6a0dfef9afULL, + 0x0081c4e4d3645be1ULL, 0x00ce76076b127623ULL)}, + {FIELD_LITERAL(0x00f6ee0f98974239ULL, 0x0042d89af07d3a4fULL, + 0x00846b7fe84346b5ULL, 0x006a21fc6a8d39a1ULL, + 0x00ac8bc2541ff2d9ULL, 0x006d4e2a77732732ULL, + 0x009a39b694cc3f2fULL, 0x0085c0aa2a404c8fULL)}, + {FIELD_LITERAL(0x00b261101a218548ULL, 0x00c1cae96424277bULL, + 0x00869da0a77dd268ULL, 0x00bc0b09f8ec83eaULL, + 0x00d61027f8e82ba9ULL, 0x00aa4c85999dce67ULL, + 0x00eac3132b9f3fe1ULL, 0x00fb9b0cf1c695d2ULL)}, }}, {{ - {FIELD_LITERAL(0x0043079295512f0d,0x0046a009861758e0,0x003ee2842a807378,0x0034cc9d1298e4fa,0x009744eb4d31b3ee,0x00afacec96650cd0,0x00ac891b313761ae,0x00e864d6d26e708a)}, - {FIELD_LITERAL(0x00a84d7c8a23b491,0x0088e19aa868b27f,0x0005986d43e78ce9,0x00f28012f0606d28,0x0017ded7e10249b3,0x005ed4084b23af9b,0x00b9b0a940564472,0x00ad9056cceeb1f4)}, - {FIELD_LITERAL(0x00db91b357fe755e,0x00a1aa544b15359c,0x00af4931a0195574,0x007686124fe11aef,0x00d1ead3c7b9ef7e,0x00aaf5fc580f8c15,0x00e727be147ee1ec,0x003c61c1e1577b86)}, + {FIELD_LITERAL(0x0043079295512f0dULL, 0x0046a009861758e0ULL, + 0x003ee2842a807378ULL, 0x0034cc9d1298e4faULL, + 0x009744eb4d31b3eeULL, 0x00afacec96650cd0ULL, + 0x00ac891b313761aeULL, 0x00e864d6d26e708aULL)}, + {FIELD_LITERAL(0x00a84d7c8a23b491ULL, 0x0088e19aa868b27fULL, + 0x0005986d43e78ce9ULL, 0x00f28012f0606d28ULL, + 0x0017ded7e10249b3ULL, 0x005ed4084b23af9bULL, + 0x00b9b0a940564472ULL, 0x00ad9056cceeb1f4ULL)}, + {FIELD_LITERAL(0x00db91b357fe755eULL, 0x00a1aa544b15359cULL, + 0x00af4931a0195574ULL, 0x007686124fe11aefULL, + 0x00d1ead3c7b9ef7eULL, 0x00aaf5fc580f8c15ULL, + 0x00e727be147ee1ecULL, 0x003c61c1e1577b86ULL)}, }}, {{ - {FIELD_LITERAL(0x009d3fca983220cf,0x00cd11acbc853dc4,0x0017590409d27f1d,0x00d2176698082802,0x00fa01251b2838c8,0x00dd297a0d9b51c6,0x00d76c92c045820a,0x00534bc7c46c9033)}, - {FIELD_LITERAL(0x0080ed9bc9b07338,0x00fceac7745d2652,0x008a9d55f5f2cc69,0x0096ce72df301ac5,0x00f53232e7974d87,0x0071728c7ae73947,0x0090507602570778,0x00cb81cfd883b1b2)}, - {FIELD_LITERAL(0x005011aadea373da,0x003a8578ec896034,0x00f20a6535fa6d71,0x005152d31e5a87cf,0x002bac1c8e68ca31,0x00b0e323db4c1381,0x00f1d596b7d5ae25,0x00eae458097cb4e0)}, + {FIELD_LITERAL(0x009d3fca983220cfULL, 0x00cd11acbc853dc4ULL, + 0x0017590409d27f1dULL, 0x00d2176698082802ULL, + 0x00fa01251b2838c8ULL, 0x00dd297a0d9b51c6ULL, + 0x00d76c92c045820aULL, 0x00534bc7c46c9033ULL)}, + {FIELD_LITERAL(0x0080ed9bc9b07338ULL, 0x00fceac7745d2652ULL, + 0x008a9d55f5f2cc69ULL, 0x0096ce72df301ac5ULL, + 0x00f53232e7974d87ULL, 0x0071728c7ae73947ULL, + 0x0090507602570778ULL, 0x00cb81cfd883b1b2ULL)}, + {FIELD_LITERAL(0x005011aadea373daULL, 0x003a8578ec896034ULL, + 0x00f20a6535fa6d71ULL, 0x005152d31e5a87cfULL, + 0x002bac1c8e68ca31ULL, 0x00b0e323db4c1381ULL, + 0x00f1d596b7d5ae25ULL, 0x00eae458097cb4e0ULL)}, }}, {{ - {FIELD_LITERAL(0x00920ac80f9b0d21,0x00f80f7f73401246,0x0086d37849b557d6,0x0002bd4b317b752e,0x00b26463993a42bb,0x002070422a73b129,0x00341acaa0380cb3,0x00541914dd66a1b2)}, - {FIELD_LITERAL(0x00c1513cd66abe8c,0x000139e01118944d,0x0064abbcb8080bbb,0x00b3b08202473142,0x00c629ef25da2403,0x00f0aec3310d9b7f,0x0050b2227472d8cd,0x00f6c8a922d41fb4)}, - {FIELD_LITERAL(0x001075ccf26b7b1f,0x00bb6bb213170433,0x00e9491ad262da79,0x009ef4f48d2d384c,0x008992770766f09d,0x001584396b6b1101,0x00af3f8676c9feef,0x0024603c40269118)}, + {FIELD_LITERAL(0x00920ac80f9b0d21ULL, 0x00f80f7f73401246ULL, + 0x0086d37849b557d6ULL, 0x0002bd4b317b752eULL, + 0x00b26463993a42bbULL, 0x002070422a73b129ULL, + 0x00341acaa0380cb3ULL, 0x00541914dd66a1b2ULL)}, + {FIELD_LITERAL(0x00c1513cd66abe8cULL, 0x000139e01118944dULL, + 0x0064abbcb8080bbbULL, 0x00b3b08202473142ULL, + 0x00c629ef25da2403ULL, 0x00f0aec3310d9b7fULL, + 0x0050b2227472d8cdULL, 0x00f6c8a922d41fb4ULL)}, + {FIELD_LITERAL(0x001075ccf26b7b1fULL, 0x00bb6bb213170433ULL, + 0x00e9491ad262da79ULL, 0x009ef4f48d2d384cULL, + 0x008992770766f09dULL, 0x001584396b6b1101ULL, + 0x00af3f8676c9feefULL, 0x0024603c40269118ULL)}, }}, {{ - {FIELD_LITERAL(0x009dd7b31319527c,0x001e7ac948d873a9,0x00fa54b46ef9673a,0x0066efb8d5b02fe6,0x00754b1d3928aeae,0x0004262ac72a6f6b,0x0079b7d49a6eb026,0x003126a753540102)}, - {FIELD_LITERAL(0x009666e24f693947,0x00f714311269d45f,0x0010ffac1d0c851c,0x0066e80c37363497,0x00f1f4ad010c60b0,0x0015c87408470ff7,0x00651d5e9c7766a4,0x008138819d7116de)}, - {FIELD_LITERAL(0x003934b11c57253b,0x00ef308edf21f46e,0x00e54e99c7a16198,0x0080d57135764e63,0x00751c27b946bc24,0x00dd389ce4e9e129,0x00a1a2bfd1cd84dc,0x002fae73e5149b32)}, + {FIELD_LITERAL(0x009dd7b31319527cULL, 0x001e7ac948d873a9ULL, + 0x00fa54b46ef9673aULL, 0x0066efb8d5b02fe6ULL, + 0x00754b1d3928aeaeULL, 0x0004262ac72a6f6bULL, + 0x0079b7d49a6eb026ULL, 0x003126a753540102ULL)}, + {FIELD_LITERAL(0x009666e24f693947ULL, 0x00f714311269d45fULL, + 0x0010ffac1d0c851cULL, 0x0066e80c37363497ULL, + 0x00f1f4ad010c60b0ULL, 0x0015c87408470ff7ULL, + 0x00651d5e9c7766a4ULL, 0x008138819d7116deULL)}, + {FIELD_LITERAL(0x003934b11c57253bULL, 0x00ef308edf21f46eULL, + 0x00e54e99c7a16198ULL, 0x0080d57135764e63ULL, + 0x00751c27b946bc24ULL, 0x00dd389ce4e9e129ULL, + 0x00a1a2bfd1cd84dcULL, 0x002fae73e5149b32ULL)}, }}, {{ - {FIELD_LITERAL(0x00911657dffb4cdd,0x00c100b7cc553d06,0x00449d075ec467cc,0x007062100bc64e70,0x0043cf86f7bd21e7,0x00f401dc4b797dea,0x005224afb2f62e65,0x00d1ede3fb5a42be)}, - {FIELD_LITERAL(0x00f2ba36a41aa144,0x00a0c22d946ee18f,0x008aae8ef9a14f99,0x00eef4d79b19bb36,0x008e75ce3d27b1fc,0x00a65daa03b29a27,0x00d9cc83684eb145,0x009e1ed80cc2ed74)}, - {FIELD_LITERAL(0x00bed953d1997988,0x00b93ed175a24128,0x00871c5963fb6365,0x00ca2df20014a787,0x00f5d9c1d0b34322,0x00f6f5942818db0a,0x004cc091f49c9906,0x00e8a188a60bff9f)}, + {FIELD_LITERAL(0x00911657dffb4cddULL, 0x00c100b7cc553d06ULL, + 0x00449d075ec467ccULL, 0x007062100bc64e70ULL, + 0x0043cf86f7bd21e7ULL, 0x00f401dc4b797deaULL, + 0x005224afb2f62e65ULL, 0x00d1ede3fb5a42beULL)}, + {FIELD_LITERAL(0x00f2ba36a41aa144ULL, 0x00a0c22d946ee18fULL, + 0x008aae8ef9a14f99ULL, 0x00eef4d79b19bb36ULL, + 0x008e75ce3d27b1fcULL, 0x00a65daa03b29a27ULL, + 0x00d9cc83684eb145ULL, 0x009e1ed80cc2ed74ULL)}, + {FIELD_LITERAL(0x00bed953d1997988ULL, 0x00b93ed175a24128ULL, + 0x00871c5963fb6365ULL, 0x00ca2df20014a787ULL, + 0x00f5d9c1d0b34322ULL, 0x00f6f5942818db0aULL, + 0x004cc091f49c9906ULL, 0x00e8a188a60bff9fULL)}, }}, {{ - {FIELD_LITERAL(0x0032c7762032fae8,0x00e4087232e0bc21,0x00f767344b6e8d85,0x00bbf369b76c2aa2,0x008a1f46c6e1570c,0x001368cd9780369f,0x007359a39d079430,0x0003646512921434)}, - {FIELD_LITERAL(0x007c4b47ca7c73e7,0x005396221039734b,0x008b64ddf0e45d7e,0x00bfad5af285e6c2,0x008ec711c5b1a1a8,0x00cf663301237f98,0x00917ee3f1655126,0x004152f337efedd8)}, - {FIELD_LITERAL(0x0007c7edc9305daa,0x000a6664f273701c,0x00f6e78795e200b1,0x005d05b9ecd2473e,0x0014f5f17c865786,0x00c7fd2d166fa995,0x004939a2d8eb80e0,0x002244ba0942c199)}, + {FIELD_LITERAL(0x0032c7762032fae8ULL, 0x00e4087232e0bc21ULL, + 0x00f767344b6e8d85ULL, 0x00bbf369b76c2aa2ULL, + 0x008a1f46c6e1570cULL, 0x001368cd9780369fULL, + 0x007359a39d079430ULL, 0x0003646512921434ULL)}, + {FIELD_LITERAL(0x007c4b47ca7c73e7ULL, 0x005396221039734bULL, + 0x008b64ddf0e45d7eULL, 0x00bfad5af285e6c2ULL, + 0x008ec711c5b1a1a8ULL, 0x00cf663301237f98ULL, + 0x00917ee3f1655126ULL, 0x004152f337efedd8ULL)}, + {FIELD_LITERAL(0x0007c7edc9305daaULL, 0x000a6664f273701cULL, + 0x00f6e78795e200b1ULL, 0x005d05b9ecd2473eULL, + 0x0014f5f17c865786ULL, 0x00c7fd2d166fa995ULL, + 0x004939a2d8eb80e0ULL, 0x002244ba0942c199ULL)}, }}, {{ - {FIELD_LITERAL(0x00321e767f0262cf,0x002e57d776caf68e,0x00bf2c94814f0437,0x00c339196acd622f,0x001db4cce71e2770,0x001ded5ddba6eee2,0x0078608ab1554c8d,0x00067fe0ab76365b)}, - {FIELD_LITERAL(0x00f09758e11e3985,0x00169efdbd64fad3,0x00e8889b7d6dacd6,0x0035cdd58ea88209,0x00bcda47586d7f49,0x003cdddcb2879088,0x0016da70187e954b,0x009556ea2e92aacd)}, - {FIELD_LITERAL(0x008cab16bd1ff897,0x00b389972cdf753f,0x00ea8ed1e46dfdc0,0x004fe7ef94c589f4,0x002b8ae9b805ecf3,0x0025c08d892874a5,0x0023938e98d44c4c,0x00f759134cabf69c)}, + {FIELD_LITERAL(0x00321e767f0262cfULL, 0x002e57d776caf68eULL, + 0x00bf2c94814f0437ULL, 0x00c339196acd622fULL, + 0x001db4cce71e2770ULL, 0x001ded5ddba6eee2ULL, + 0x0078608ab1554c8dULL, 0x00067fe0ab76365bULL)}, + {FIELD_LITERAL(0x00f09758e11e3985ULL, 0x00169efdbd64fad3ULL, + 0x00e8889b7d6dacd6ULL, 0x0035cdd58ea88209ULL, + 0x00bcda47586d7f49ULL, 0x003cdddcb2879088ULL, + 0x0016da70187e954bULL, 0x009556ea2e92aacdULL)}, + {FIELD_LITERAL(0x008cab16bd1ff897ULL, 0x00b389972cdf753fULL, + 0x00ea8ed1e46dfdc0ULL, 0x004fe7ef94c589f4ULL, + 0x002b8ae9b805ecf3ULL, 0x0025c08d892874a5ULL, + 0x0023938e98d44c4cULL, 0x00f759134cabf69cULL)}, }}, {{ - {FIELD_LITERAL(0x006c2a84678e4b3b,0x007a194aacd1868f,0x00ed0225af424761,0x00da0a6f293c64b8,0x001062ac5c6a7a18,0x0030f5775a8aeef4,0x0002acaad76b7af0,0x00410b8fd63a579f)}, - {FIELD_LITERAL(0x001ec59db3d9590e,0x001e9e3f1c3f182d,0x0045a9c3ec2cab14,0x0008198572aeb673,0x00773b74068bd167,0x0012535eaa395434,0x0044dba9e3bbb74a,0x002fba4d3c74bd0e)}, - {FIELD_LITERAL(0x0042bf08fe66922c,0x003318b8fbb49e8c,0x00d75946004aa14c,0x00f601586b42bf1c,0x00c74cf1d912fe66,0x00abcb36974b30ad,0x007eb78720c9d2b8,0x009f54ab7bd4df85)}, + {FIELD_LITERAL(0x006c2a84678e4b3bULL, 0x007a194aacd1868fULL, + 0x00ed0225af424761ULL, 0x00da0a6f293c64b8ULL, + 0x001062ac5c6a7a18ULL, 0x0030f5775a8aeef4ULL, + 0x0002acaad76b7af0ULL, 0x00410b8fd63a579fULL)}, + {FIELD_LITERAL(0x001ec59db3d9590eULL, 0x001e9e3f1c3f182dULL, + 0x0045a9c3ec2cab14ULL, 0x0008198572aeb673ULL, + 0x00773b74068bd167ULL, 0x0012535eaa395434ULL, + 0x0044dba9e3bbb74aULL, 0x002fba4d3c74bd0eULL)}, + {FIELD_LITERAL(0x0042bf08fe66922cULL, 0x003318b8fbb49e8cULL, + 0x00d75946004aa14cULL, 0x00f601586b42bf1cULL, + 0x00c74cf1d912fe66ULL, 0x00abcb36974b30adULL, + 0x007eb78720c9d2b8ULL, 0x009f54ab7bd4df85ULL)}, }}, {{ - {FIELD_LITERAL(0x00db9fc948f73826,0x00fa8b3746ed8ee9,0x00132cb65aafbeb2,0x00c36ff3fe7925b8,0x00837daed353d2fe,0x00ec661be0667cf4,0x005beb8ed2e90204,0x00d77dd69e564967)}, - {FIELD_LITERAL(0x0042e6268b861751,0x0008dd0469500c16,0x00b51b57c338a3fd,0x00cc4497d85cff6b,0x002f13d6b57c34a4,0x0083652eaf301105,0x00cc344294cc93a8,0x0060f4d02810e270)}, - {FIELD_LITERAL(0x00a8954363cd518b,0x00ad171124bccb7b,0x0065f46a4adaae00,0x001b1a5b2a96e500,0x0043fe24f8233285,0x0066996d8ae1f2c3,0x00c530f3264169f9,0x00c0f92d07cf6a57)}, + {FIELD_LITERAL(0x00db9fc948f73826ULL, 0x00fa8b3746ed8ee9ULL, + 0x00132cb65aafbeb2ULL, 0x00c36ff3fe7925b8ULL, + 0x00837daed353d2feULL, 0x00ec661be0667cf4ULL, + 0x005beb8ed2e90204ULL, 0x00d77dd69e564967ULL)}, + {FIELD_LITERAL(0x0042e6268b861751ULL, 0x0008dd0469500c16ULL, + 0x00b51b57c338a3fdULL, 0x00cc4497d85cff6bULL, + 0x002f13d6b57c34a4ULL, 0x0083652eaf301105ULL, + 0x00cc344294cc93a8ULL, 0x0060f4d02810e270ULL)}, + {FIELD_LITERAL(0x00a8954363cd518bULL, 0x00ad171124bccb7bULL, + 0x0065f46a4adaae00ULL, 0x001b1a5b2a96e500ULL, + 0x0043fe24f8233285ULL, 0x0066996d8ae1f2c3ULL, + 0x00c530f3264169f9ULL, 0x00c0f92d07cf6a57ULL)}, }}, {{ - {FIELD_LITERAL(0x0036a55c6815d943,0x008c8d1def993db3,0x002e0e1e8ff7318f,0x00d883a4b92db00a,0x002f5e781ae33906,0x001a72adb235c06d,0x00f2e59e736e9caa,0x001a4b58e3031914)}, - {FIELD_LITERAL(0x00d73bfae5e00844,0x00bf459766fb5f52,0x0061b4f5a5313cde,0x004392d4c3b95514,0x000d3551b1077523,0x0000998840ee5d71,0x006de6e340448b7b,0x00251aa504875d6e)}, - {FIELD_LITERAL(0x003bf343427ac342,0x00adc0a78642b8c5,0x0003b893175a8314,0x0061a34ade5703bc,0x00ea3ea8bb71d632,0x00be0df9a1f198c2,0x0046dd8e7c1635fb,0x00f1523fdd25d5e5)}, + {FIELD_LITERAL(0x0036a55c6815d943ULL, 0x008c8d1def993db3ULL, + 0x002e0e1e8ff7318fULL, 0x00d883a4b92db00aULL, + 0x002f5e781ae33906ULL, 0x001a72adb235c06dULL, + 0x00f2e59e736e9caaULL, 0x001a4b58e3031914ULL)}, + {FIELD_LITERAL(0x00d73bfae5e00844ULL, 0x00bf459766fb5f52ULL, + 0x0061b4f5a5313cdeULL, 0x004392d4c3b95514ULL, + 0x000d3551b1077523ULL, 0x0000998840ee5d71ULL, + 0x006de6e340448b7bULL, 0x00251aa504875d6eULL)}, + {FIELD_LITERAL(0x003bf343427ac342ULL, 0x00adc0a78642b8c5ULL, + 0x0003b893175a8314ULL, 0x0061a34ade5703bcULL, + 0x00ea3ea8bb71d632ULL, 0x00be0df9a1f198c2ULL, + 0x0046dd8e7c1635fbULL, 0x00f1523fdd25d5e5ULL)}, }}, {{ - {FIELD_LITERAL(0x00633f63fc9dd406,0x00e713ff80e04a43,0x0060c6e970f2d621,0x00a57cd7f0df1891,0x00f2406a550650bb,0x00b064290efdc684,0x001eab0144d17916,0x00cd15f863c293ab)}, - {FIELD_LITERAL(0x0029cec55273f70d,0x007044ee275c6340,0x0040f637a93015e2,0x00338bb78db5aae9,0x001491b2a6132147,0x00a125d6cfe6bde3,0x005f7ac561ba8669,0x001d5eaea3fbaacf)}, - {FIELD_LITERAL(0x00054e9635e3be31,0x000e43f31e2872be,0x00d05b1c9e339841,0x006fac50bd81fd98,0x00cdc7852eaebb09,0x004ff519b061991b,0x009099e8107d4c85,0x00273e24c36a4a61)}, + {FIELD_LITERAL(0x00633f63fc9dd406ULL, 0x00e713ff80e04a43ULL, + 0x0060c6e970f2d621ULL, 0x00a57cd7f0df1891ULL, + 0x00f2406a550650bbULL, 0x00b064290efdc684ULL, + 0x001eab0144d17916ULL, 0x00cd15f863c293abULL)}, + {FIELD_LITERAL(0x0029cec55273f70dULL, 0x007044ee275c6340ULL, + 0x0040f637a93015e2ULL, 0x00338bb78db5aae9ULL, + 0x001491b2a6132147ULL, 0x00a125d6cfe6bde3ULL, + 0x005f7ac561ba8669ULL, 0x001d5eaea3fbaacfULL)}, + {FIELD_LITERAL(0x00054e9635e3be31ULL, 0x000e43f31e2872beULL, + 0x00d05b1c9e339841ULL, 0x006fac50bd81fd98ULL, + 0x00cdc7852eaebb09ULL, 0x004ff519b061991bULL, + 0x009099e8107d4c85ULL, 0x00273e24c36a4a61ULL)}, }}, {{ - {FIELD_LITERAL(0x00070b4441ef2c46,0x00efa5b02801a109,0x00bf0b8c3ee64adf,0x008a67e0b3452e98,0x001916b1f2fa7a74,0x00d781a78ff6cdc3,0x008682ce57e5c919,0x00cc1109dd210da3)}, - {FIELD_LITERAL(0x00cae8aaff388663,0x005e983a35dda1c7,0x007ab1030d8e37f4,0x00e48940f5d032fe,0x006a36f9ef30b331,0x009be6f03958c757,0x0086231ceba91400,0x008bd0f7b823e7aa)}, - {FIELD_LITERAL(0x00cf881ebef5a45a,0x004ebea78e7c6f2c,0x0090da9209cf26a0,0x00de2b2e4c775b84,0x0071d6031c3c15ae,0x00d9e927ef177d70,0x00894ee8c23896fd,0x00e3b3b401e41aad)}, + {FIELD_LITERAL(0x00070b4441ef2c46ULL, 0x00efa5b02801a109ULL, + 0x00bf0b8c3ee64adfULL, 0x008a67e0b3452e98ULL, + 0x001916b1f2fa7a74ULL, 0x00d781a78ff6cdc3ULL, + 0x008682ce57e5c919ULL, 0x00cc1109dd210da3ULL)}, + {FIELD_LITERAL(0x00cae8aaff388663ULL, 0x005e983a35dda1c7ULL, + 0x007ab1030d8e37f4ULL, 0x00e48940f5d032feULL, + 0x006a36f9ef30b331ULL, 0x009be6f03958c757ULL, + 0x0086231ceba91400ULL, 0x008bd0f7b823e7aaULL)}, + {FIELD_LITERAL(0x00cf881ebef5a45aULL, 0x004ebea78e7c6f2cULL, + 0x0090da9209cf26a0ULL, 0x00de2b2e4c775b84ULL, + 0x0071d6031c3c15aeULL, 0x00d9e927ef177d70ULL, + 0x00894ee8c23896fdULL, 0x00e3b3b401e41aadULL)}, }}, {{ - {FIELD_LITERAL(0x00204fef26864170,0x00819269c5dee0f8,0x00bfb4713ec97966,0x0026339a6f34df78,0x001f26e64c761dc2,0x00effe3af313cb60,0x00e17b70138f601b,0x00f16e1ccd9ede5e)}, - {FIELD_LITERAL(0x005d9a8353fdb2db,0x0055cc2048c698f0,0x00f6c4ac89657218,0x00525034d73faeb2,0x00435776fbda3c7d,0x0070ea5312323cbc,0x007a105d44d069fb,0x006dbc8d6dc786aa)}, - {FIELD_LITERAL(0x0017cff19cd394ec,0x00fef7b810922587,0x00e6483970dff548,0x00ddf36ad6874264,0x00e61778523fcce2,0x0093a66c0c93b24a,0x00fd367114db7f86,0x007652d7ddce26dd)}, + {FIELD_LITERAL(0x00204fef26864170ULL, 0x00819269c5dee0f8ULL, + 0x00bfb4713ec97966ULL, 0x0026339a6f34df78ULL, + 0x001f26e64c761dc2ULL, 0x00effe3af313cb60ULL, + 0x00e17b70138f601bULL, 0x00f16e1ccd9ede5eULL)}, + {FIELD_LITERAL(0x005d9a8353fdb2dbULL, 0x0055cc2048c698f0ULL, + 0x00f6c4ac89657218ULL, 0x00525034d73faeb2ULL, + 0x00435776fbda3c7dULL, 0x0070ea5312323cbcULL, + 0x007a105d44d069fbULL, 0x006dbc8d6dc786aaULL)}, + {FIELD_LITERAL(0x0017cff19cd394ecULL, 0x00fef7b810922587ULL, + 0x00e6483970dff548ULL, 0x00ddf36ad6874264ULL, + 0x00e61778523fcce2ULL, 0x0093a66c0c93b24aULL, + 0x00fd367114db7f86ULL, 0x007652d7ddce26ddULL)}, }}, {{ - {FIELD_LITERAL(0x00d92ced7ba12843,0x00aea9c7771e86e7,0x0046639693354f7b,0x00a628dbb6a80c47,0x003a0b0507372953,0x00421113ab45c0d9,0x00e545f08362ab7a,0x0028ce087b4d6d96)}, - {FIELD_LITERAL(0x00a67ee7cf9f99eb,0x005713b275f2ff68,0x00f1d536a841513d,0x00823b59b024712e,0x009c46b9d0d38cec,0x00cdb1595aa2d7d4,0x008375b3423d9af8,0x000ab0b516d978f7)}, - {FIELD_LITERAL(0x00428dcb3c510b0f,0x00585607ea24bb4e,0x003736bf1603687a,0x00c47e568c4fe3c7,0x003cd00282848605,0x0043a487c3b91939,0x004ffc04e1095a06,0x00a4c989a3d4b918)}, + {FIELD_LITERAL(0x00d92ced7ba12843ULL, 0x00aea9c7771e86e7ULL, + 0x0046639693354f7bULL, 0x00a628dbb6a80c47ULL, + 0x003a0b0507372953ULL, 0x00421113ab45c0d9ULL, + 0x00e545f08362ab7aULL, 0x0028ce087b4d6d96ULL)}, + {FIELD_LITERAL(0x00a67ee7cf9f99ebULL, 0x005713b275f2ff68ULL, + 0x00f1d536a841513dULL, 0x00823b59b024712eULL, + 0x009c46b9d0d38cecULL, 0x00cdb1595aa2d7d4ULL, + 0x008375b3423d9af8ULL, 0x000ab0b516d978f7ULL)}, + {FIELD_LITERAL(0x00428dcb3c510b0fULL, 0x00585607ea24bb4eULL, + 0x003736bf1603687aULL, 0x00c47e568c4fe3c7ULL, + 0x003cd00282848605ULL, 0x0043a487c3b91939ULL, + 0x004ffc04e1095a06ULL, 0x00a4c989a3d4b918ULL)}, }}, {{ - {FIELD_LITERAL(0x00a8778d0e429f7a,0x004c02b059105a68,0x0016653b609da3ff,0x00d5107bd1a12d27,0x00b4708f9a771cab,0x00bb63b662033f69,0x0072f322240e7215,0x0019445b59c69222)}, - {FIELD_LITERAL(0x00cf4f6069a658e6,0x0053ca52859436a6,0x0064b994d7e3e117,0x00cb469b9a07f534,0x00cfb68f399e9d47,0x00f0dcb8dac1c6e7,0x00f2ab67f538b3a5,0x0055544f178ab975)}, - {FIELD_LITERAL(0x0099b7a2685d538c,0x00e2f1897b7c0018,0x003adac8ce48dae3,0x00089276d5c50c0c,0x00172fca07ad6717,0x00cb1a72f54069e5,0x004ee42f133545b3,0x00785f8651362f16)}, + {FIELD_LITERAL(0x00a8778d0e429f7aULL, 0x004c02b059105a68ULL, + 0x0016653b609da3ffULL, 0x00d5107bd1a12d27ULL, + 0x00b4708f9a771cabULL, 0x00bb63b662033f69ULL, + 0x0072f322240e7215ULL, 0x0019445b59c69222ULL)}, + {FIELD_LITERAL(0x00cf4f6069a658e6ULL, 0x0053ca52859436a6ULL, + 0x0064b994d7e3e117ULL, 0x00cb469b9a07f534ULL, + 0x00cfb68f399e9d47ULL, 0x00f0dcb8dac1c6e7ULL, + 0x00f2ab67f538b3a5ULL, 0x0055544f178ab975ULL)}, + {FIELD_LITERAL(0x0099b7a2685d538cULL, 0x00e2f1897b7c0018ULL, + 0x003adac8ce48dae3ULL, 0x00089276d5c50c0cULL, + 0x00172fca07ad6717ULL, 0x00cb1a72f54069e5ULL, + 0x004ee42f133545b3ULL, 0x00785f8651362f16ULL)}, }}, {{ - {FIELD_LITERAL(0x0049cbac38509e11,0x0015234505d42cdf,0x00794fb0b5840f1c,0x00496437344045a5,0x0031b6d944e4f9b0,0x00b207318ac1f5d8,0x0000c840da7f5c5d,0x00526f373a5c8814)}, - {FIELD_LITERAL(0x002c7b7742d1dfd9,0x002cabeb18623c01,0x00055f5e3e044446,0x006c20f3b4ef54ba,0x00c600141ec6b35f,0x00354f437f1a32a3,0x00bac4624a3520f9,0x00c483f734a90691)}, - {FIELD_LITERAL(0x0053a737d422918d,0x00f7fca1d8758625,0x00c360336dadb04c,0x00f38e3d9158a1b8,0x0069ce3b418e84c6,0x005d1697eca16ead,0x00f8bd6a35ece13d,0x007885dfc2b5afea)}, + {FIELD_LITERAL(0x0049cbac38509e11ULL, 0x0015234505d42cdfULL, + 0x00794fb0b5840f1cULL, 0x00496437344045a5ULL, + 0x0031b6d944e4f9b0ULL, 0x00b207318ac1f5d8ULL, + 0x0000c840da7f5c5dULL, 0x00526f373a5c8814ULL)}, + {FIELD_LITERAL(0x002c7b7742d1dfd9ULL, 0x002cabeb18623c01ULL, + 0x00055f5e3e044446ULL, 0x006c20f3b4ef54baULL, + 0x00c600141ec6b35fULL, 0x00354f437f1a32a3ULL, + 0x00bac4624a3520f9ULL, 0x00c483f734a90691ULL)}, + {FIELD_LITERAL(0x0053a737d422918dULL, 0x00f7fca1d8758625ULL, + 0x00c360336dadb04cULL, 0x00f38e3d9158a1b8ULL, + 0x0069ce3b418e84c6ULL, 0x005d1697eca16eadULL, + 0x00f8bd6a35ece13dULL, 0x007885dfc2b5afeaULL)}, }}, {{ - {FIELD_LITERAL(0x00c3617ae260776c,0x00b20dc3e96922d7,0x00a1a7802246706a,0x00ca6505a5240244,0x002246b62d919782,0x001439102d7aa9b3,0x00e8af1139e6422c,0x00c888d1b52f2b05)}, - {FIELD_LITERAL(0x005b67690ffd41d9,0x005294f28df516f9,0x00a879272412fcb9,0x00098b629a6d1c8d,0x00fabd3c8050865a,0x00cd7e5b0a3879c5,0x00153238210f3423,0x00357cac101e9f42)}, - {FIELD_LITERAL(0x008917b454444fb7,0x00f59247c97e441b,0x00a6200a6815152d,0x0009a4228601d254,0x001c0360559bd374,0x007563362039cb36,0x00bd75b48d74e32b,0x0017f515ac3499e8)}, + {FIELD_LITERAL(0x00c3617ae260776cULL, 0x00b20dc3e96922d7ULL, + 0x00a1a7802246706aULL, 0x00ca6505a5240244ULL, + 0x002246b62d919782ULL, 0x001439102d7aa9b3ULL, + 0x00e8af1139e6422cULL, 0x00c888d1b52f2b05ULL)}, + {FIELD_LITERAL(0x005b67690ffd41d9ULL, 0x005294f28df516f9ULL, + 0x00a879272412fcb9ULL, 0x00098b629a6d1c8dULL, + 0x00fabd3c8050865aULL, 0x00cd7e5b0a3879c5ULL, + 0x00153238210f3423ULL, 0x00357cac101e9f42ULL)}, + {FIELD_LITERAL(0x008917b454444fb7ULL, 0x00f59247c97e441bULL, + 0x00a6200a6815152dULL, 0x0009a4228601d254ULL, + 0x001c0360559bd374ULL, 0x007563362039cb36ULL, + 0x00bd75b48d74e32bULL, 0x0017f515ac3499e8ULL)}, }}, {{ - {FIELD_LITERAL(0x001532a7ffe41c5a,0x00eb1edce358d6bf,0x00ddbacc7b678a7b,0x008a7b70f3c841a3,0x00f1923bf27d3f4c,0x000b2713ed8f7873,0x00aaf67e29047902,0x0044994a70b3976d)}, - {FIELD_LITERAL(0x00d54e802082d42c,0x00a55aa0dce7cc6c,0x006477b96073f146,0x0082efe4ceb43594,0x00a922bcba026845,0x0077f19d1ab75182,0x00c2bb2737846e59,0x0004d7eec791dd33)}, - {FIELD_LITERAL(0x0044588d1a81d680,0x00b0a9097208e4f8,0x00212605350dc57e,0x0028717cd2871123,0x00fb083c100fd979,0x0045a056ce063fdf,0x00a5d604b4dd6a41,0x001dabc08ba4e236)}, + {FIELD_LITERAL(0x001532a7ffe41c5aULL, 0x00eb1edce358d6bfULL, + 0x00ddbacc7b678a7bULL, 0x008a7b70f3c841a3ULL, + 0x00f1923bf27d3f4cULL, 0x000b2713ed8f7873ULL, + 0x00aaf67e29047902ULL, 0x0044994a70b3976dULL)}, + {FIELD_LITERAL(0x00d54e802082d42cULL, 0x00a55aa0dce7cc6cULL, + 0x006477b96073f146ULL, 0x0082efe4ceb43594ULL, + 0x00a922bcba026845ULL, 0x0077f19d1ab75182ULL, + 0x00c2bb2737846e59ULL, 0x0004d7eec791dd33ULL)}, + {FIELD_LITERAL(0x0044588d1a81d680ULL, 0x00b0a9097208e4f8ULL, + 0x00212605350dc57eULL, 0x0028717cd2871123ULL, + 0x00fb083c100fd979ULL, 0x0045a056ce063fdfULL, + 0x00a5d604b4dd6a41ULL, 0x001dabc08ba4e236ULL)}, }}, {{ - {FIELD_LITERAL(0x00c4887198d7a7fa,0x00244f98fb45784a,0x0045911e15a15d01,0x001d323d374c0966,0x00967c3915196562,0x0039373abd2f3c67,0x000d2c5614312423,0x0041cf2215442ce3)}, - {FIELD_LITERAL(0x008ede889ada7f06,0x001611e91de2e135,0x00fdb9a458a471b9,0x00563484e03710d1,0x0031cc81925e3070,0x0062c97b3af80005,0x00fa733eea28edeb,0x00e82457e1ebbc88)}, - {FIELD_LITERAL(0x006a0df5fe9b6f59,0x00a0d4ff46040d92,0x004a7cedb6f93250,0x00d1df8855b8c357,0x00e73a46086fd058,0x0048fb0add6dfe59,0x001e03a28f1b4e3d,0x00a871c993308d76)}, + {FIELD_LITERAL(0x00c4887198d7a7faULL, 0x00244f98fb45784aULL, + 0x0045911e15a15d01ULL, 0x001d323d374c0966ULL, + 0x00967c3915196562ULL, 0x0039373abd2f3c67ULL, + 0x000d2c5614312423ULL, 0x0041cf2215442ce3ULL)}, + {FIELD_LITERAL(0x008ede889ada7f06ULL, 0x001611e91de2e135ULL, + 0x00fdb9a458a471b9ULL, 0x00563484e03710d1ULL, + 0x0031cc81925e3070ULL, 0x0062c97b3af80005ULL, + 0x00fa733eea28edebULL, 0x00e82457e1ebbc88ULL)}, + {FIELD_LITERAL(0x006a0df5fe9b6f59ULL, 0x00a0d4ff46040d92ULL, + 0x004a7cedb6f93250ULL, 0x00d1df8855b8c357ULL, + 0x00e73a46086fd058ULL, 0x0048fb0add6dfe59ULL, + 0x001e03a28f1b4e3dULL, 0x00a871c993308d76ULL)}, }}, {{ - {FIELD_LITERAL(0x0030dbb2d1766ec8,0x00586c0ad138555e,0x00d1a34f9e91c77c,0x0063408ad0e89014,0x00d61231b05f6f5b,0x0009abf569f5fd8a,0x00aec67a110f1c43,0x0031d1a790938dd7)}, - {FIELD_LITERAL(0x006cded841e2a862,0x00198d60af0ab6fb,0x0018f09db809e750,0x004e6ac676016263,0x00eafcd1620969cb,0x002c9784ca34917d,0x0054f00079796de7,0x00d9fab5c5972204)}, - {FIELD_LITERAL(0x004bd0fee2438a83,0x00b571e62b0f83bd,0x0059287d7ce74800,0x00fb3631b645c3f0,0x00a018e977f78494,0x0091e27065c27b12,0x007696c1817165e0,0x008c40be7c45ba3a)}, + {FIELD_LITERAL(0x0030dbb2d1766ec8ULL, 0x00586c0ad138555eULL, + 0x00d1a34f9e91c77cULL, 0x0063408ad0e89014ULL, + 0x00d61231b05f6f5bULL, 0x0009abf569f5fd8aULL, + 0x00aec67a110f1c43ULL, 0x0031d1a790938dd7ULL)}, + {FIELD_LITERAL(0x006cded841e2a862ULL, 0x00198d60af0ab6fbULL, + 0x0018f09db809e750ULL, 0x004e6ac676016263ULL, + 0x00eafcd1620969cbULL, 0x002c9784ca34917dULL, + 0x0054f00079796de7ULL, 0x00d9fab5c5972204ULL)}, + {FIELD_LITERAL(0x004bd0fee2438a83ULL, 0x00b571e62b0f83bdULL, + 0x0059287d7ce74800ULL, 0x00fb3631b645c3f0ULL, + 0x00a018e977f78494ULL, 0x0091e27065c27b12ULL, + 0x007696c1817165e0ULL, 0x008c40be7c45ba3aULL)}, }}, {{ - {FIELD_LITERAL(0x00a0f326327cb684,0x001c7d0f672680ff,0x008c1c81ffb112d1,0x00f8f801674eddc8,0x00e926d5d48c2a9d,0x005bd6d954c6fe9a,0x004c6b24b4e33703,0x00d05eb5c09105cc)}, - {FIELD_LITERAL(0x00d61731caacf2cf,0x002df0c7609e01c5,0x00306172208b1e2b,0x00b413fe4fb2b686,0x00826d360902a221,0x003f8d056e67e7f7,0x0065025b0175e989,0x00369add117865eb)}, - {FIELD_LITERAL(0x00aaf895aec2fa11,0x000f892bc313eb52,0x005b1c794dad050b,0x003f8ec4864cec14,0x00af81058d0b90e5,0x00ebe43e183997bb,0x00a9d610f9f3e615,0x007acd8eec2e88d3)}, + {FIELD_LITERAL(0x00a0f326327cb684ULL, 0x001c7d0f672680ffULL, + 0x008c1c81ffb112d1ULL, 0x00f8f801674eddc8ULL, + 0x00e926d5d48c2a9dULL, 0x005bd6d954c6fe9aULL, + 0x004c6b24b4e33703ULL, 0x00d05eb5c09105ccULL)}, + {FIELD_LITERAL(0x00d61731caacf2cfULL, 0x002df0c7609e01c5ULL, + 0x00306172208b1e2bULL, 0x00b413fe4fb2b686ULL, + 0x00826d360902a221ULL, 0x003f8d056e67e7f7ULL, + 0x0065025b0175e989ULL, 0x00369add117865ebULL)}, + {FIELD_LITERAL(0x00aaf895aec2fa11ULL, 0x000f892bc313eb52ULL, + 0x005b1c794dad050bULL, 0x003f8ec4864cec14ULL, + 0x00af81058d0b90e5ULL, 0x00ebe43e183997bbULL, + 0x00a9d610f9f3e615ULL, 0x007acd8eec2e88d3ULL)}, }}, {{ - {FIELD_LITERAL(0x0049b2fab13812a3,0x00846db32cd60431,0x000177fa578c8d6c,0x00047d0e2ad4bc51,0x00b158ba38d1e588,0x006a45daad79e3f3,0x000997b93cab887b,0x00c47ea42fa23dc3)}, - {FIELD_LITERAL(0x0012b6fef7aeb1ca,0x009412768194b6a7,0x00ff0d351f23ab93,0x007e8a14c1aff71b,0x006c1c0170c512bc,0x0016243ea02ab2e5,0x007bb6865b303f3e,0x0015ce6b29b159f4)}, - {FIELD_LITERAL(0x009961cd02e68108,0x00e2035d3a1d0836,0x005d51f69b5e1a1d,0x004bccb4ea36edcd,0x0069be6a7aeef268,0x0063f4dd9de8d5a7,0x006283783092ca35,0x0075a31af2c35409)}, + {FIELD_LITERAL(0x0049b2fab13812a3ULL, 0x00846db32cd60431ULL, + 0x000177fa578c8d6cULL, 0x00047d0e2ad4bc51ULL, + 0x00b158ba38d1e588ULL, 0x006a45daad79e3f3ULL, + 0x000997b93cab887bULL, 0x00c47ea42fa23dc3ULL)}, + {FIELD_LITERAL(0x0012b6fef7aeb1caULL, 0x009412768194b6a7ULL, + 0x00ff0d351f23ab93ULL, 0x007e8a14c1aff71bULL, + 0x006c1c0170c512bcULL, 0x0016243ea02ab2e5ULL, + 0x007bb6865b303f3eULL, 0x0015ce6b29b159f4ULL)}, + {FIELD_LITERAL(0x009961cd02e68108ULL, 0x00e2035d3a1d0836ULL, + 0x005d51f69b5e1a1dULL, 0x004bccb4ea36edcdULL, + 0x0069be6a7aeef268ULL, 0x0063f4dd9de8d5a7ULL, + 0x006283783092ca35ULL, 0x0075a31af2c35409ULL)}, }}, {{ - {FIELD_LITERAL(0x00c412365162e8cf,0x00012283fb34388a,0x003e6543babf39e2,0x00eead6b3a804978,0x0099c0314e8b326f,0x00e98e0a8d477a4f,0x00d2eb96b127a687,0x00ed8d7df87571bb)}, - {FIELD_LITERAL(0x00777463e308cacf,0x00c8acb93950132d,0x00ebddbf4ca48b2c,0x0026ad7ca0795a0a,0x00f99a3d9a715064,0x000d60bcf9d4dfcc,0x005e65a73a437a06,0x0019d536a8db56c8)}, - {FIELD_LITERAL(0x00192d7dd558d135,0x0027cd6a8323ffa7,0x00239f1a412dc1e7,0x0046b4b3be74fc5c,0x0020c47a2bef5bce,0x00aa17e48f43862b,0x00f7e26c96342e5f,0x0008011c530f39a9)}, + {FIELD_LITERAL(0x00c412365162e8cfULL, 0x00012283fb34388aULL, + 0x003e6543babf39e2ULL, 0x00eead6b3a804978ULL, + 0x0099c0314e8b326fULL, 0x00e98e0a8d477a4fULL, + 0x00d2eb96b127a687ULL, 0x00ed8d7df87571bbULL)}, + {FIELD_LITERAL(0x00777463e308cacfULL, 0x00c8acb93950132dULL, + 0x00ebddbf4ca48b2cULL, 0x0026ad7ca0795a0aULL, + 0x00f99a3d9a715064ULL, 0x000d60bcf9d4dfccULL, + 0x005e65a73a437a06ULL, 0x0019d536a8db56c8ULL)}, + {FIELD_LITERAL(0x00192d7dd558d135ULL, 0x0027cd6a8323ffa7ULL, + 0x00239f1a412dc1e7ULL, 0x0046b4b3be74fc5cULL, + 0x0020c47a2bef5bceULL, 0x00aa17e48f43862bULL, + 0x00f7e26c96342e5fULL, 0x0008011c530f39a9ULL)}, }}, {{ - {FIELD_LITERAL(0x00aad4ac569bf0f1,0x00a67adc90b27740,0x0048551369a5751a,0x0031252584a3306a,0x0084e15df770e6fc,0x00d7bba1c74b5805,0x00a80ef223af1012,0x0089c85ceb843a34)}, - {FIELD_LITERAL(0x00c4545be4a54004,0x0099e11f60357e6c,0x001f3936d19515a6,0x007793df84341a6e,0x0051061886717ffa,0x00e9b0a660b28f85,0x0044ea685892de0d,0x000257d2a1fda9d9)}, - {FIELD_LITERAL(0x007e8b01b24ac8a8,0x006cf3b0b5ca1337,0x00f1607d3e36a570,0x0039b7fab82991a1,0x00231777065840c5,0x00998e5afdd346f9,0x00b7dc3e64acc85f,0x00baacc748013ad6)}, + {FIELD_LITERAL(0x00aad4ac569bf0f1ULL, 0x00a67adc90b27740ULL, + 0x0048551369a5751aULL, 0x0031252584a3306aULL, + 0x0084e15df770e6fcULL, 0x00d7bba1c74b5805ULL, + 0x00a80ef223af1012ULL, 0x0089c85ceb843a34ULL)}, + {FIELD_LITERAL(0x00c4545be4a54004ULL, 0x0099e11f60357e6cULL, + 0x001f3936d19515a6ULL, 0x007793df84341a6eULL, + 0x0051061886717ffaULL, 0x00e9b0a660b28f85ULL, + 0x0044ea685892de0dULL, 0x000257d2a1fda9d9ULL)}, + {FIELD_LITERAL(0x007e8b01b24ac8a8ULL, 0x006cf3b0b5ca1337ULL, + 0x00f1607d3e36a570ULL, 0x0039b7fab82991a1ULL, + 0x00231777065840c5ULL, 0x00998e5afdd346f9ULL, + 0x00b7dc3e64acc85fULL, 0x00baacc748013ad6ULL)}, }}, {{ - {FIELD_LITERAL(0x008ea6a4177580bf,0x005fa1953e3f0378,0x005fe409ac74d614,0x00452327f477e047,0x00a4018507fb6073,0x007b6e71951caac8,0x0012b42ab8a6ce91,0x0080eca677294ab7)}, - {FIELD_LITERAL(0x00a53edc023ba69b,0x00c6afa83ddde2e8,0x00c3f638b307b14e,0x004a357a64414062,0x00e4d94d8b582dc9,0x001739caf71695b7,0x0012431b2ae28de1,0x003b6bc98682907c)}, - {FIELD_LITERAL(0x008a9a93be1f99d6,0x0079fa627cc699c8,0x00b0cfb134ba84c8,0x001c4b778249419a,0x00df4ab3d9c44f40,0x009f596e6c1a9e3c,0x001979c0df237316,0x00501e953a919b87)}, + {FIELD_LITERAL(0x008ea6a4177580bfULL, 0x005fa1953e3f0378ULL, + 0x005fe409ac74d614ULL, 0x00452327f477e047ULL, + 0x00a4018507fb6073ULL, 0x007b6e71951caac8ULL, + 0x0012b42ab8a6ce91ULL, 0x0080eca677294ab7ULL)}, + {FIELD_LITERAL(0x00a53edc023ba69bULL, 0x00c6afa83ddde2e8ULL, + 0x00c3f638b307b14eULL, 0x004a357a64414062ULL, + 0x00e4d94d8b582dc9ULL, 0x001739caf71695b7ULL, + 0x0012431b2ae28de1ULL, 0x003b6bc98682907cULL)}, + {FIELD_LITERAL(0x008a9a93be1f99d6ULL, 0x0079fa627cc699c8ULL, + 0x00b0cfb134ba84c8ULL, 0x001c4b778249419aULL, + 0x00df4ab3d9c44f40ULL, 0x009f596e6c1a9e3cULL, + 0x001979c0df237316ULL, 0x00501e953a919b87ULL)}, }} }; const niels_t *curve448_wnaf_base = curve448_wnaf_base_table; diff --git a/crypto/ec/curve448/f_generic.c b/crypto/ec/curve448/f_generic.c index e459e54d..7e63998a 100644 --- a/crypto/ec/curve448/f_generic.c +++ b/crypto/ec/curve448/f_generic.c @@ -12,9 +12,9 @@ #include "field.h" static const gf MODULUS = { - FIELD_LITERAL(0xffffffffffffff, 0xffffffffffffff, 0xffffffffffffff, - 0xffffffffffffff, 0xfffffffffffffe, 0xffffffffffffff, - 0xffffffffffffff, 0xffffffffffffff) + FIELD_LITERAL(0xffffffffffffffULL, 0xffffffffffffffULL, 0xffffffffffffffULL, + 0xffffffffffffffULL, 0xfffffffffffffeULL, 0xffffffffffffffULL, + 0xffffffffffffffULL, 0xffffffffffffffULL) }; /* Serialize to wire format. */ diff --git a/crypto/ec/curve448/scalar.c b/crypto/ec/curve448/scalar.c index ce9a4884..2923859e 100644 --- a/crypto/ec/curve448/scalar.c +++ b/crypto/ec/curve448/scalar.c @@ -14,24 +14,24 @@ #include "word.h" #include "point_448.h" -static const c448_word_t MONTGOMERY_FACTOR = (c448_word_t) 0x3bd440fae918bc5; +static const c448_word_t MONTGOMERY_FACTOR = (c448_word_t) 0x3bd440fae918bc5ULL; static const curve448_scalar_t sc_p = { { { - SC_LIMB(0x2378c292ab5844f3), SC_LIMB(0x216cc2728dc58f55), - SC_LIMB(0xc44edb49aed63690), SC_LIMB(0xffffffff7cca23e9), - SC_LIMB(0xffffffffffffffff), SC_LIMB(0xffffffffffffffff), - SC_LIMB(0x3fffffffffffffff) + SC_LIMB(0x2378c292ab5844f3ULL), SC_LIMB(0x216cc2728dc58f55ULL), + SC_LIMB(0xc44edb49aed63690ULL), SC_LIMB(0xffffffff7cca23e9ULL), + SC_LIMB(0xffffffffffffffffULL), SC_LIMB(0xffffffffffffffffULL), + SC_LIMB(0x3fffffffffffffffULL) } } }, sc_r2 = { { { - SC_LIMB(0xe3539257049b9b60), SC_LIMB(0x7af32c4bc1b195d9), - SC_LIMB(0x0d66de2388ea1859), SC_LIMB(0xae17cf725ee4d838), - SC_LIMB(0x1a9cc14ba3c47c44), SC_LIMB(0x2052bcb7e4d070af), - SC_LIMB(0x3402a939f823b729) + SC_LIMB(0xe3539257049b9b60ULL), SC_LIMB(0x7af32c4bc1b195d9ULL), + SC_LIMB(0x0d66de2388ea1859ULL), SC_LIMB(0xae17cf725ee4d838ULL), + SC_LIMB(0x1a9cc14ba3c47c44ULL), SC_LIMB(0x2052bcb7e4d070afULL), + SC_LIMB(0x3402a939f823b729ULL) } } }; diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index a32f3023..fe6f3b3b 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -357,10 +357,15 @@ static void felem_diff64(felem out, const felem in) static void felem_diff_128_64(largefelem out, const felem in) { /* - * In order to prevent underflow, we add 0 mod p before subtracting. + * In order to prevent underflow, we add 64p mod p (which is equivalent + * to 0 mod p) before subtracting. p is 2^521 - 1, i.e. in binary a 521 + * digit number with all bits set to 1. See "The representation of field + * elements" comment above for a description of how limbs are used to + * represent a number. 64p is represented with 8 limbs containing a number + * with 58 bits set and one limb with a number with 57 bits set. */ - static const limb two63m6 = (((limb) 1) << 62) - (((limb) 1) << 5); - static const limb two63m5 = (((limb) 1) << 62) - (((limb) 1) << 4); + static const limb two63m6 = (((limb) 1) << 63) - (((limb) 1) << 6); + static const limb two63m5 = (((limb) 1) << 63) - (((limb) 1) << 5); out[0] += two63m6 - in[0]; out[1] += two63m5 - in[1]; diff --git a/crypto/err/err.c b/crypto/err/err.c index 3aa3daed..63dcfc35 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -58,6 +58,7 @@ static ERR_STRING_DATA ERR_str_libraries[] = { {ERR_PACK(ERR_LIB_UI, 0, 0), "UI routines"}, {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_HMAC, 0, 0), "HMAC routines"}, {ERR_PACK(ERR_LIB_CT, 0, 0), "CT routines"}, {ERR_PACK(ERR_LIB_ASYNC, 0, 0), "ASYNC routines"}, diff --git a/crypto/err/err_all.c b/crypto/err/err_all.c index 4bf020c2..1166b01c 100644 --- a/crypto/err/err_all.c +++ b/crypto/err/err_all.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -90,6 +91,9 @@ int err_load_crypto_strings_int(void) # ifndef OPENSSL_NO_CMS ERR_load_CMS_strings() == 0 || # endif +# ifndef OPENSSL_NO_CMP + ERR_load_CRMF_strings() == 0 || +# endif # ifndef OPENSSL_NO_CT ERR_load_CT_strings() == 0 || # endif diff --git a/crypto/err/openssl.ec b/crypto/err/openssl.ec index 901a847d..a204434f 100644 --- a/crypto/err/openssl.ec +++ b/crypto/err/openssl.ec @@ -29,6 +29,7 @@ L UI include/openssl/ui.h crypto/ui/ui_err.c 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 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 9dc9d183..d8c8d714 100644 --- a/crypto/err/openssl.txt +++ b/crypto/err/openssl.txt @@ -348,6 +348,28 @@ CONF_F_NCONF_NEW:111:NCONF_new CONF_F_PROCESS_INCLUDE:116:process_include CONF_F_SSL_MODULE_INIT:123:ssl_module_init CONF_F_STR_COPY:101:str_copy +CRMF_F_CRMF_POPOSIGNINGKEY_INIT:100:CRMF_poposigningkey_init +CRMF_F_OSSL_CRMF_CERTID_GEN:101:OSSL_CRMF_CERTID_gen +CRMF_F_OSSL_CRMF_CERTTEMPLATE_FILL:102:OSSL_CRMF_CERTTEMPLATE_fill +CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT:103:\ + OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert +CRMF_F_OSSL_CRMF_MSGS_VERIFY_POPO:104:OSSL_CRMF_MSGS_verify_popo +CRMF_F_OSSL_CRMF_MSG_CREATE_POPO:105:OSSL_CRMF_MSG_create_popo +CRMF_F_OSSL_CRMF_MSG_GET0_TMPL:106:OSSL_CRMF_MSG_get0_tmpl +CRMF_F_OSSL_CRMF_MSG_GET_CERTREQID:107:OSSL_CRMF_MSG_get_certReqId +CRMF_F_OSSL_CRMF_MSG_PKIPUBLICATIONINFO_PUSH0_SINGLEPUBINFO:108:\ + OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo +CRMF_F_OSSL_CRMF_MSG_PUSH0_EXTENSION:109:OSSL_CRMF_MSG_push0_extension +CRMF_F_OSSL_CRMF_MSG_PUSH0_REGCTRL:110:OSSL_CRMF_MSG_push0_regCtrl +CRMF_F_OSSL_CRMF_MSG_PUSH0_REGINFO:111:OSSL_CRMF_MSG_push0_regInfo +CRMF_F_OSSL_CRMF_MSG_SET0_EXTENSIONS:112:OSSL_CRMF_MSG_set0_extensions +CRMF_F_OSSL_CRMF_MSG_SET0_SINGLEPUBINFO:113:OSSL_CRMF_MSG_set0_SinglePubInfo +CRMF_F_OSSL_CRMF_MSG_SET_CERTREQID:114:OSSL_CRMF_MSG_set_certReqId +CRMF_F_OSSL_CRMF_MSG_SET_PKIPUBLICATIONINFO_ACTION:115:\ + OSSL_CRMF_MSG_set_PKIPublicationInfo_action +CRMF_F_OSSL_CRMF_MSG_SET_VALIDITY:116:OSSL_CRMF_MSG_set_validity +CRMF_F_OSSL_CRMF_PBMP_NEW:117:OSSL_CRMF_pbmp_new +CRMF_F_OSSL_CRMF_PBM_NEW:118:OSSL_CRMF_pbm_new CRYPTO_F_CMAC_CTX_NEW:120:CMAC_CTX_new CRYPTO_F_CRYPTO_DUP_EX_DATA:110:CRYPTO_dup_ex_data CRYPTO_F_CRYPTO_FREE_EX_DATA:111:CRYPTO_free_ex_data @@ -359,6 +381,7 @@ CRYPTO_F_CRYPTO_OCB128_INIT:122:CRYPTO_ocb128_init CRYPTO_F_CRYPTO_SET_EX_DATA:102:CRYPTO_set_ex_data CRYPTO_F_FIPS_MODE_SET:109:FIPS_mode_set CRYPTO_F_GET_AND_LOCK:113:get_and_lock +CRYPTO_F_GET_PROVIDER_STORE:133:get_provider_store CRYPTO_F_OPENSSL_ATEXIT:114:OPENSSL_atexit CRYPTO_F_OPENSSL_BUF2HEXSTR:117:OPENSSL_buf2hexstr CRYPTO_F_OPENSSL_FOPEN:119:openssl_fopen @@ -367,6 +390,9 @@ CRYPTO_F_OPENSSL_INIT_CRYPTO:116:OPENSSL_init_crypto CRYPTO_F_OPENSSL_LH_NEW:126:OPENSSL_LH_new CRYPTO_F_OPENSSL_SK_DEEP_COPY:127:OPENSSL_sk_deep_copy CRYPTO_F_OPENSSL_SK_DUP:128:OPENSSL_sk_dup +CRYPTO_F_OSSL_PROVIDER_ACTIVATE:130:ossl_provider_activate +CRYPTO_F_OSSL_PROVIDER_ADD_BUILTIN:132:OSSL_PROVIDER_add_builtin +CRYPTO_F_OSSL_PROVIDER_NEW:131:ossl_provider_new CRYPTO_F_PKEY_HMAC_INIT:123:pkey_hmac_init CRYPTO_F_PKEY_POLY1305_INIT:124:pkey_poly1305_init CRYPTO_F_PKEY_SIPHASH_INIT:125:pkey_siphash_init @@ -1097,6 +1123,7 @@ RSA_F_RSA_CHECK_KEY:123:RSA_check_key RSA_F_RSA_CHECK_KEY_EX:160:RSA_check_key_ex RSA_F_RSA_CMS_DECRYPT:159:rsa_cms_decrypt RSA_F_RSA_CMS_VERIFY:158:rsa_cms_verify +RSA_F_RSA_FIPS186_4_GEN_PROB_PRIMES:168:rsa_fips186_4_gen_prob_primes RSA_F_RSA_ITEM_VERIFY:148:rsa_item_verify RSA_F_RSA_METH_DUP:161:RSA_meth_dup RSA_F_RSA_METH_NEW:162:RSA_meth_new @@ -1140,6 +1167,10 @@ RSA_F_RSA_PUB_DECODE:139:rsa_pub_decode RSA_F_RSA_SETUP_BLINDING:136:RSA_setup_blinding RSA_F_RSA_SIGN:117:RSA_sign RSA_F_RSA_SIGN_ASN1_OCTET_STRING:118:RSA_sign_ASN1_OCTET_STRING +RSA_F_RSA_SP800_56B_CHECK_KEYPAIR:169:rsa_sp800_56b_check_keypair +RSA_F_RSA_SP800_56B_CHECK_PUBLIC:170:rsa_sp800_56b_check_public +RSA_F_RSA_SP800_56B_PAIRWISE_TEST:171:rsa_sp800_56b_pairwise_test +RSA_F_RSA_SP800_56B_VALIDATE_STRENGTH:172:rsa_sp800_56b_validate_strength RSA_F_RSA_VERIFY:119:RSA_verify RSA_F_RSA_VERIFY_ASN1_OCTET_STRING:120:RSA_verify_ASN1_OCTET_STRING RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1:126:RSA_verify_PKCS1_PSS_mgf1 @@ -1803,8 +1834,10 @@ X509_F_X509_STORE_NEW:158:X509_STORE_new X509_F_X509_TO_X509_REQ:126:X509_to_X509_REQ X509_F_X509_TRUST_ADD:133:X509_TRUST_add X509_F_X509_TRUST_SET:141:X509_TRUST_set +X509_F_X509_VERIFY:161:X509_verify X509_F_X509_VERIFY_CERT:127:X509_verify_cert X509_F_X509_VERIFY_PARAM_NEW:159:X509_VERIFY_PARAM_new +X509_F_X509_VERIFY_SM2:162:x509_verify_sm2 #Reason codes ASN1_R_ADDING_OBJECT:171:adding object @@ -2094,9 +2127,29 @@ CONF_R_UNABLE_TO_CREATE_NEW_SECTION:103:unable to create new section CONF_R_UNKNOWN_MODULE_NAME:113:unknown module name CONF_R_VARIABLE_EXPANSION_TOO_LONG:116:variable expansion too long CONF_R_VARIABLE_HAS_NO_VALUE:104:variable has no value +CRMF_R_BAD_PBM_ITERATIONCOUNT:100:bad pbm iterationcount +CRMF_R_CRMFERROR:102:crmferror +CRMF_R_ERROR:103:error +CRMF_R_ERROR_DECODING_CERTIFICATE:104:error decoding certificate +CRMF_R_ERROR_DECRYPTING_CERTIFICATE:105:error decrypting certificate +CRMF_R_ERROR_DECRYPTING_SYMMETRIC_KEY:106:error decrypting symmetric key +CRMF_R_FAILURE_OBTAINING_RANDOM:107:failure obtaining random +CRMF_R_ITERATIONCOUNT_BELOW_100:108:iterationcount below 100 +CRMF_R_MALFORMED_IV:101:malformed iv +CRMF_R_NULL_ARGUMENT:109:null argument +CRMF_R_SETTING_MAC_ALGOR_FAILURE:110:setting mac algor failure +CRMF_R_SETTING_OWF_ALGOR_FAILURE:111:setting owf algor failure +CRMF_R_UNSUPPORTED_ALGORITHM:112:unsupported algorithm +CRMF_R_UNSUPPORTED_ALG_FOR_POPSIGNINGKEY:113:unsupported alg for popsigningkey +CRMF_R_UNSUPPORTED_CIPHER:114:unsupported cipher +CRMF_R_UNSUPPORTED_METHOD_FOR_CREATING_POPO:115:\ + unsupported method for creating popo +CRMF_R_UNSUPPORTED_POPO_METHOD:116:unsupported popo method +CRMF_R_UNSUPPORTED_POPO_NOT_ACCEPTED:117:unsupported popo not accepted CRYPTO_R_FIPS_MODE_NOT_SUPPORTED:101:fips mode not supported CRYPTO_R_ILLEGAL_HEX_DIGIT:102:illegal hex digit CRYPTO_R_ODD_NUMBER_OF_DIGITS:103:odd number of digits +CRYPTO_R_PROVIDER_ALREADY_EXISTS:104:provider already exists CT_R_BASE64_DECODE_ERROR:108:base64 decode error CT_R_INVALID_LOG_ID_LENGTH:100:invalid log id length CT_R_LOG_CONF_INVALID:109:log conf invalid @@ -2586,16 +2639,21 @@ RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE:144:\ RSA_R_INVALID_DIGEST:157:invalid digest RSA_R_INVALID_DIGEST_LENGTH:143:invalid digest length RSA_R_INVALID_HEADER:137:invalid header +RSA_R_INVALID_KEYPAIR:171:invalid keypair +RSA_R_INVALID_KEY_LENGTH:173:invalid key length RSA_R_INVALID_LABEL:160:invalid label RSA_R_INVALID_MESSAGE_LENGTH:131:invalid message length RSA_R_INVALID_MGF1_MD:156:invalid mgf1 md +RSA_R_INVALID_MODULUS:174:invalid modulus RSA_R_INVALID_MULTI_PRIME_KEY:167:invalid multi prime key RSA_R_INVALID_OAEP_PARAMETERS:161:invalid oaep parameters RSA_R_INVALID_PADDING:138:invalid padding RSA_R_INVALID_PADDING_MODE:141:invalid padding mode RSA_R_INVALID_PSS_PARAMETERS:149:invalid pss parameters RSA_R_INVALID_PSS_SALTLEN:146:invalid pss saltlen +RSA_R_INVALID_REQUEST:175:invalid request RSA_R_INVALID_SALT_LENGTH:150:invalid salt length +RSA_R_INVALID_STRENGTH:176:invalid strength RSA_R_INVALID_TRAILER:139:invalid trailer RSA_R_INVALID_X931_DIGEST:142:invalid x931 digest RSA_R_IQMP_NOT_INVERSE_OF_Q:126:iqmp not inverse of q @@ -2615,8 +2673,10 @@ RSA_R_OAEP_DECODING_ERROR:121:oaep decoding error RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE:148:\ operation not supported for this keytype RSA_R_PADDING_CHECK_FAILED:114:padding check failed +RSA_R_PAIRWISE_TEST_FAILURE:177:pairwise test failure RSA_R_PKCS_DECODING_ERROR:159:pkcs decoding error RSA_R_PSS_SALTLEN_TOO_SMALL:164:pss saltlen too small +RSA_R_PUB_EXPONENT_OUT_OF_RANGE:178:pub exponent out of range RSA_R_P_NOT_PRIME:128:p not prime RSA_R_Q_NOT_PRIME:129:q not prime RSA_R_RSA_OPERATIONS_NOT_SUPPORTED:130:rsa operations not supported diff --git a/crypto/include/internal/bn_int.h b/crypto/include/internal/bn_int.h index 66e34ec5..514eaeeb 100644 --- a/crypto/include/internal/bn_int.h +++ b/crypto/include/internal/bn_int.h @@ -87,4 +87,31 @@ int bn_rshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n); int bn_div_fixed_top(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); +#define BN_PRIMETEST_COMPOSITE 0 +#define BN_PRIMETEST_COMPOSITE_WITH_FACTOR 1 +#define BN_PRIMETEST_COMPOSITE_NOT_POWER_OF_PRIME 2 +#define BN_PRIMETEST_PROBABLY_PRIME 3 + +int bn_miller_rabin_is_prime(const BIGNUM *w, int iterations, BN_CTX *ctx, + BN_GENCB *cb, int enhanced, int *status); + +const BIGNUM *bn_get0_small_factors(void); + +int bn_rsa_fips186_4_prime_MR_min_checks(int nbits); + +int bn_rsa_fips186_4_gen_prob_primes(BIGNUM *p, BIGNUM *Xpout, + BIGNUM *p1, BIGNUM *p2, + const BIGNUM *Xp, const BIGNUM *Xp1, + const BIGNUM *Xp2, int nlen, + const BIGNUM *e, BN_CTX *ctx, + BN_GENCB *cb); + +int bn_rsa_fips186_4_derive_prime(BIGNUM *Y, BIGNUM *X, const BIGNUM *Xin, + const BIGNUM *r1, const BIGNUM *r2, int nlen, + const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/crypto/include/internal/x509_int.h b/crypto/include/internal/x509_int.h index 82d7bbff..93f923e0 100644 --- a/crypto/include/internal/x509_int.h +++ b/crypto/include/internal/x509_int.h @@ -175,7 +175,7 @@ struct x509_st { STACK_OF(DIST_POINT) *crldp; STACK_OF(GENERAL_NAME) *altname; NAME_CONSTRAINTS *nc; -#ifndef OPENSSL_NO_RFC3779 +# ifndef OPENSSL_NO_RFC3779 STACK_OF(IPAddressFamily) *rfc3779_addr; struct ASIdentifiers_st *rfc3779_asid; # endif @@ -183,6 +183,9 @@ struct x509_st { X509_CERT_AUX *aux; CRYPTO_RWLOCK *lock; volatile int ex_cached; +# ifndef OPENSSL_NO_SM2 + ASN1_OCTET_STRING sm2_id; +# endif } /* X509 */ ; /* diff --git a/crypto/objects/obj_dat.h b/crypto/objects/obj_dat.h index 7ba1ecda..339aaa70 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[7767] = { +static const unsigned char so[7775] = { 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,9 +1077,10 @@ static const unsigned char so[7767] = { 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 */ }; -#define NUM_NID 1205 +#define NUM_NID 1206 static const ASN1_OBJECT nid_objs[NUM_NID] = { {"UNDEF", "undefined", NID_undef}, {"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]}, @@ -2285,10 +2286,11 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = { {"BLAKE2BMAC", "blake2bmac", NID_blake2bmac}, {"BLAKE2SMAC", "blake2smac", NID_blake2smac}, {"SSHKDF", "sshkdf", NID_sshkdf}, + {"SM2-SM3", "SM2-with-SM3", NID_SM2_with_SM3, 8, &so[7766]}, {"ChaCha20-Poly1305-D", "chacha20-poly1305-draft", NID_chacha20_poly1305_draft}, }; -#define NUM_SN 1196 +#define NUM_SN 1197 static const unsigned int sn_objs[NUM_SN] = { 364, /* "AD_DVCS" */ 419, /* "AES-128-CBC" */ @@ -2411,7 +2413,7 @@ static const unsigned int sn_objs[NUM_SN] = { 417, /* "CSPName" */ 1019, /* "ChaCha20" */ 1018, /* "ChaCha20-Poly1305" */ - 1204, /* "ChaCha20-Poly1305-D" */ + 1205, /* "ChaCha20-Poly1305-D" */ 367, /* "CrlID" */ 391, /* "DC" */ 31, /* "DES-CBC" */ @@ -2563,6 +2565,7 @@ static const unsigned int sn_objs[NUM_SN] = { 1100, /* "SHAKE128" */ 1101, /* "SHAKE256" */ 1172, /* "SM2" */ + 1204, /* "SM2-SM3" */ 1143, /* "SM3" */ 1134, /* "SM4-CBC" */ 1137, /* "SM4-CFB" */ @@ -3488,7 +3491,7 @@ static const unsigned int sn_objs[NUM_SN] = { 1093, /* "x509ExtAdmission" */ }; -#define NUM_LN 1196 +#define NUM_LN 1197 static const unsigned int ln_objs[NUM_LN] = { 363, /* "AD Time Stamping" */ 405, /* "ANSI X9.62" */ @@ -3644,6 +3647,7 @@ static const unsigned int ln_objs[NUM_LN] = { 1119, /* "RSA-SHA3-512" */ 188, /* "S/MIME" */ 167, /* "S/MIME Capabilities" */ + 1204, /* "SM2-with-SM3" */ 1006, /* "SNILS" */ 387, /* "SNMPv2" */ 1025, /* "SSH Client" */ @@ -3872,7 +3876,7 @@ static const unsigned int ln_objs[NUM_LN] = { 883, /* "certificateRevocationList" */ 1019, /* "chacha20" */ 1018, /* "chacha20-poly1305" */ - 1204, /* "chacha20-poly1305-draft" */ + 1205, /* "chacha20-poly1305-draft" */ 54, /* "challengePassword" */ 407, /* "characteristic-two-field" */ 395, /* "clearance" */ @@ -4688,7 +4692,7 @@ static const unsigned int ln_objs[NUM_LN] = { 125, /* "zlib compression" */ }; -#define NUM_OBJ 1072 +#define NUM_OBJ 1073 static const unsigned int obj_objs[NUM_OBJ] = { 0, /* OBJ_undef 0 */ 181, /* OBJ_iso 1 */ @@ -5158,6 +5162,7 @@ static const unsigned int obj_objs[NUM_OBJ] = { 1139, /* OBJ_sm4_ctr 1 2 156 10197 1 104 7 */ 1172, /* OBJ_sm2 1 2 156 10197 1 301 */ 1143, /* OBJ_sm3 1 2 156 10197 1 401 */ + 1204, /* OBJ_SM2_with_SM3 1 2 156 10197 1 501 */ 1144, /* OBJ_sm3WithRSAEncryption 1 2 156 10197 1 504 */ 776, /* OBJ_seed_ecb 1 2 410 200004 1 3 */ 777, /* OBJ_seed_cbc 1 2 410 200004 1 4 */ diff --git a/crypto/objects/obj_mac.num b/crypto/objects/obj_mac.num index 08185475..4d3e79d4 100644 --- a/crypto/objects/obj_mac.num +++ b/crypto/objects/obj_mac.num @@ -1201,4 +1201,5 @@ aes_256_siv 1200 blake2bmac 1201 blake2smac 1202 sshkdf 1203 -chacha20_poly1305_draft 1204 +SM2_with_SM3 1204 +chacha20_poly1305_draft 1205 diff --git a/crypto/objects/obj_xref.h b/crypto/objects/obj_xref.h index 1c2a0636..2a02a934 100644 --- a/crypto/objects/obj_xref.h +++ b/crypto/objects/obj_xref.h @@ -79,6 +79,7 @@ static const nid_triple sigoid_srt[] = { {NID_RSA_SHA3_256, NID_sha3_256, NID_rsaEncryption}, {NID_RSA_SHA3_384, NID_sha3_384, NID_rsaEncryption}, {NID_RSA_SHA3_512, NID_sha3_512, NID_rsaEncryption}, + {NID_SM2_with_SM3, NID_sm3, NID_sm2}, }; static const nid_triple *const sigoid_srt_xref[] = { @@ -125,4 +126,5 @@ static const nid_triple *const sigoid_srt_xref[] = { &sigoid_srt[45], &sigoid_srt[46], &sigoid_srt[47], + &sigoid_srt[48], }; diff --git a/crypto/objects/obj_xref.txt b/crypto/objects/obj_xref.txt index ca3e7446..f3dd8ed3 100644 --- a/crypto/objects/obj_xref.txt +++ b/crypto/objects/obj_xref.txt @@ -64,3 +64,5 @@ dhSinglePass_cofactorDH_sha224kdf_scheme sha224 dh_cofactor_kdf dhSinglePass_cofactorDH_sha256kdf_scheme sha256 dh_cofactor_kdf dhSinglePass_cofactorDH_sha384kdf_scheme sha384 dh_cofactor_kdf dhSinglePass_cofactorDH_sha512kdf_scheme sha512 dh_cofactor_kdf + +SM2_with_SM3 sm3 sm2 diff --git a/crypto/objects/objects.txt b/crypto/objects/objects.txt index d480bd38..2f236c30 100644 --- a/crypto/objects/objects.txt +++ b/crypto/objects/objects.txt @@ -394,6 +394,8 @@ sm-scheme 301 : SM2 : sm2 sm-scheme 401 : SM3 : sm3 sm-scheme 504 : RSA-SM3 : sm3WithRSAEncryption +sm-scheme 501 : SM2-SM3 : SM2-with-SM3 + # From RFC4231 rsadsi 2 8 : : hmacWithSHA224 rsadsi 2 9 : : hmacWithSHA256 diff --git a/crypto/params.c b/crypto/params.c new file mode 100644 index 00000000..a53d5134 --- /dev/null +++ b/crypto/params.c @@ -0,0 +1,725 @@ +/* + * 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 +#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) +{ + if (p != NULL && key != NULL) + for (; p->key != NULL; p++) + if (strcmp(key, p->key) == 0) + return p; + return NULL; +} + +static OSSL_PARAM ossl_param_construct(const char *key, unsigned int data_type, + void *data, size_t data_size, + size_t *return_size) +{ + OSSL_PARAM res; + + res.key = key; + res.data_type = data_type; + res.data = data; + res.data_size = data_size; + res.return_size = return_size; + return res; +} + +int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val) +{ + if (val == NULL || p == NULL || p->data_type != OSSL_PARAM_INTEGER) + return 0; + + switch (p->data_size) { + case sizeof(int32_t): + if (sizeof(int) >= sizeof(int32_t)) { + *val = (int)*(const int32_t *)p->data; + return 1; + } + break; + case sizeof(int64_t): + if (sizeof(int) >= sizeof(int64_t)) { + *val = (int)*(const int64_t *)p->data; + return 1; + } + break; + } + return 0; +} + +int OSSL_PARAM_set_int(const OSSL_PARAM *p, int val) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 0); + if (p->data_type != OSSL_PARAM_INTEGER) + return 0; + + SET_RETURN_SIZE(p, sizeof(int)); /* Minimum expected size */ + switch (p->data_size) { + case sizeof(int32_t): + if (sizeof(int32_t) >= sizeof(int)) { + SET_RETURN_SIZE(p, sizeof(int32_t)); + *(int32_t *)p->data = (int32_t)val; + return 1; + } + break; + case sizeof(int64_t): + if (sizeof(int64_t) >= sizeof(int)) { + SET_RETURN_SIZE(p, sizeof(int64_t)); + *(int64_t *)p->data = (int64_t)val; + return 1; + } + break; + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf, size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int), + rsize); +} + +int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val) +{ + if (val == NULL + || p == NULL + || (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)) + return 0; + + switch (p->data_size) { + case sizeof(uint32_t): + if (sizeof(unsigned int) >= sizeof(uint32_t)) { + *val = (unsigned int)*(const uint32_t *)p->data; + return 1; + } + break; + case sizeof(uint64_t): + if (sizeof(unsigned int) >= sizeof(uint64_t)) { + *val = (unsigned int)*(const uint64_t *)p->data; + return 1; + } + break; + } + return 0; +} + +int OSSL_PARAM_set_uint(const OSSL_PARAM *p, unsigned int val) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 0); + if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER) + return 0; + + SET_RETURN_SIZE(p, sizeof(unsigned int)); /* Minimum expected size */ + switch (p->data_size) { + case sizeof(uint32_t): + if (sizeof(uint32_t) >= sizeof(unsigned int)) { + SET_RETURN_SIZE(p, sizeof(uint32_t)); + *(uint32_t *)p->data = (uint32_t)val; + return 1; + } + break; + case sizeof(uint64_t): + if (sizeof(uint64_t) >= sizeof(unsigned int)) { + SET_RETURN_SIZE(p, sizeof(uint64_t)); + *(uint64_t *)p->data = (uint64_t)val; + return 1; + } + break; + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf, + size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf, + sizeof(unsigned int), rsize); +} + +int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val) +{ + if (val == NULL || p == NULL || (p->data_type != OSSL_PARAM_INTEGER)) + return 0; + + switch (p->data_size) { + case sizeof(int32_t): + if (sizeof(long int) >= sizeof(int32_t)) { + *val = (long int)*(const int32_t *)p->data; + return 1; + } break; + case sizeof(int64_t): + if (sizeof(long int) >= sizeof(int64_t)) { + *val = (long int)*(const int64_t *)p->data; + return 1; + } + break; + } + return 0; +} + +int OSSL_PARAM_set_long(const OSSL_PARAM *p, long int val) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 0); + if (p->data_type != OSSL_PARAM_INTEGER) + return 0; + + SET_RETURN_SIZE(p, sizeof(long int)); /* Minimum expected size */ + switch (p->data_size) { + case sizeof(int32_t): + if (sizeof(int32_t) >= sizeof(long int)) { + SET_RETURN_SIZE(p, sizeof(int32_t)); + *(int32_t *)p->data = (int32_t)val; + return 1; + } + break; + case sizeof(int64_t): + if (sizeof(int64_t) >= sizeof(long int)) { + SET_RETURN_SIZE(p, sizeof(int64_t)); + *(int64_t *)p->data = (int64_t)val; + return 1; + } + break; + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf, + size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(long int), + rsize); +} + +int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val) +{ + if (val == NULL + || p == NULL + || (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)) + return 0; + + switch (p->data_size) { + case sizeof(uint32_t): + if (sizeof(unsigned long int) >= sizeof(uint32_t)) { + *val = (unsigned long int)*(const uint32_t *)p->data; + return 1; + } + break; + case sizeof(uint64_t): + if (sizeof(unsigned long int) >= sizeof(uint64_t)) { + *val = (unsigned long int)*(const uint64_t *)p->data; + return 1; + } + break; + } + return 0; +} + +int OSSL_PARAM_set_ulong(const OSSL_PARAM *p, unsigned long int val) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 0); + if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER) + return 0; + + SET_RETURN_SIZE(p, sizeof(unsigned long int)); /* Minimum exp size */ + switch (p->data_size) { + case sizeof(uint32_t): + if (sizeof(uint32_t) >= sizeof(unsigned long int)) { + SET_RETURN_SIZE(p, sizeof(uint32_t)); + *(uint32_t *)p->data = (uint32_t)val; + return 1; + } + break; + case sizeof(uint64_t): + if (sizeof(uint64_t) >= sizeof(unsigned long int)) { + SET_RETURN_SIZE(p, sizeof(uint64_t)); + *(uint64_t *)p->data = (uint64_t)val; + return 1; + } + break; + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf, + size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf, + sizeof(unsigned long int), rsize); +} + +int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val) +{ + if (val == NULL || p == NULL || (p->data_type != OSSL_PARAM_INTEGER)) + return 0; + + if (p->data_size == sizeof(int32_t)) { + *val = *(const int32_t *)p->data; + return 1; + } + return 0; +} + +int OSSL_PARAM_set_int32(const OSSL_PARAM *p, int32_t val) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 0); + if (p->data_type != OSSL_PARAM_INTEGER) + return 0; + + SET_RETURN_SIZE(p, sizeof(int32_t)); /* Minimum expected size */ + switch (p->data_size) { + case sizeof(int32_t): + SET_RETURN_SIZE(p, sizeof(int32_t)); + *(int32_t *)p->data = val; + return 1; + case sizeof(int64_t): + SET_RETURN_SIZE(p, sizeof(int64_t)); + *(int64_t *)p->data = (int64_t)val; + return 1; + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf, + size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, + sizeof(int32_t), rsize); +} + +int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val) +{ + if (val == NULL + || p == NULL + || (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)) + return 0; + + if (p->data_size == sizeof(uint32_t)) { + *val = *(const uint32_t *)p->data; + return 1; + } + return 0; +} + +int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val) +{ + if (p == NULL) return 0; + SET_RETURN_SIZE(p, 0); + if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER) + return 0; + + SET_RETURN_SIZE(p, sizeof(uint32_t)); /* Minimum expected size */ + switch (p->data_size) { + case sizeof(uint32_t): + SET_RETURN_SIZE(p, sizeof(uint32_t)); + *(uint32_t *)p->data = val; + return 1; + case sizeof(uint64_t): + SET_RETURN_SIZE(p, sizeof(uint64_t)); + *(uint64_t *)p->data = (uint64_t)val; + return 1; + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf, + size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf, + sizeof(uint32_t), rsize); +} + +int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val) +{ + if (val == NULL || p == NULL || (p->data_type != OSSL_PARAM_INTEGER)) + return 0; + + switch (p->data_size) { + case sizeof(int32_t): + *val = (int64_t)*(const int32_t *)p->data; + return 1; + case sizeof(int64_t): + *val = *(const int64_t *)p->data; + return 1; + } + return 0; +} + +int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 0); + if (p->data_type != OSSL_PARAM_INTEGER) + return 0; + + SET_RETURN_SIZE(p, sizeof(int64_t)); /* Minimum expected size */ + switch (p->data_size) { + case sizeof(int64_t): + SET_RETURN_SIZE(p, sizeof(int64_t)); + *(int64_t *)p->data = val; + return 1; + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf, + size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int64_t), + rsize); +} + +int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val) +{ + if (val == NULL + || p == NULL + || (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)) + return 0; + + switch (p->data_size) { + case sizeof(uint32_t): + *val = (uint64_t)*(const uint32_t *)p->data; + return 1; + case sizeof(uint64_t): + *val = *(const uint64_t *)p->data; + return 1; + } + return 0; +} + +int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 0); + if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER) + return 0; + + SET_RETURN_SIZE(p, sizeof(uint64_t)); /* Minimum expected size */ + switch (p->data_size) { + case sizeof(uint64_t): + SET_RETURN_SIZE(p, sizeof(uint64_t)); + *(uint64_t *)p->data = val; + return 1; + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf, + size_t *rsize) { + return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf, + sizeof(uint64_t), rsize); +} + +int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val) +{ + if (val == NULL + || p == NULL + || p->data_type != OSSL_PARAM_UNSIGNED_INTEGER) + return 0; + + switch (p->data_size) { + case sizeof(uint32_t): + if (sizeof(size_t) >= sizeof(uint32_t)) { + *val = (size_t)*(const uint32_t *)p->data; + return 1; + } + break; + case sizeof(uint64_t): + if (sizeof(size_t) >= sizeof(uint64_t)) { + *val = (size_t)*(const uint64_t *)p->data; + return 1; + } + break; + } + return 0; +} + +int OSSL_PARAM_set_size_t(const OSSL_PARAM *p, size_t val) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 0); + if (p->data_type != OSSL_PARAM_UNSIGNED_INTEGER) + return 0; + + SET_RETURN_SIZE(p, sizeof(size_t)); /* Minimum expected size */ + switch (p->data_size) { + case sizeof(uint32_t): + if (sizeof(uint32_t) >= sizeof(size_t)) { + SET_RETURN_SIZE(p, sizeof(uint32_t)); + *(uint32_t *)p->data = (uint32_t)val; + return 1; + } + break; + case sizeof(uint64_t): + SET_RETURN_SIZE(p, sizeof(uint64_t)); + if (sizeof(uint64_t) >= sizeof(size_t)) { + *(uint64_t *)p->data = (uint64_t)val; + return 1; + } + break; + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf, + size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf, + sizeof(size_t), rsize); } + +int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val) +{ + BIGNUM *b; + + if (val == NULL + || p == NULL + || p->data_type != OSSL_PARAM_UNSIGNED_INTEGER) + return 0; + + b = BN_native2bn(p->data, (int)p->data_size, *val); + if (b != NULL) { + *val = b; + return 1; + } + return 0; +} + +int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const BIGNUM *val) +{ + size_t bytes; + + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 0); + if (val == NULL || p->data_type != OSSL_PARAM_UNSIGNED_INTEGER) + return 0; + + bytes = (size_t)BN_num_bytes(val); + SET_RETURN_SIZE(p, 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) +{ + return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, + buf, bsize, rsize); +} + +int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val) +{ + if (val == NULL || p == NULL || p->data_type != OSSL_PARAM_REAL) + return 0; + + switch (p->data_size) { + case sizeof(double): + *val = *(const double *)p->data; + return 1; + } + return 0; +} + +int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 0); + if (p->data_type != OSSL_PARAM_REAL) + return 0; + + switch (p->data_size) { + case sizeof(double): + SET_RETURN_SIZE(p, sizeof(double)); + *(double *)p->data = val; + return 1; + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf, + size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_REAL, buf, sizeof(double), + rsize); +} + +static int get_string_internal(const OSSL_PARAM *p, void **val, size_t max_len, + size_t *used_len, unsigned int type) +{ + size_t sz; + + if (val == NULL || p == NULL || p->data_type != type) + return 0; + + sz = p->data_size; + + if (used_len != NULL) + *used_len = sz; + + if (*val == NULL) { + char *const q = OPENSSL_malloc(sz); + + if (q == NULL) + return 0; + *val = q; + memcpy(q, p->data, sz); + return 1; + } + if (max_len < sz) + return 0; + memcpy(*val, p->data, sz); + return 1; +} + +int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len) +{ + return get_string_internal(p, (void **)val, max_len, NULL, + OSSL_PARAM_UTF8_STRING); +} + +int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len, + size_t *used_len) +{ + return get_string_internal(p, val, max_len, used_len, + OSSL_PARAM_OCTET_STRING); +} + +static int set_string_internal(const OSSL_PARAM *p, const void *val, size_t len, + unsigned int type) +{ + SET_RETURN_SIZE(p, len); + if (p->data_type != type || p->data_size < len) + return 0; + + memcpy(p->data, val, len); + return 1; +} + +int OSSL_PARAM_set_utf8_string(const OSSL_PARAM *p, const char *val) +{ + if (p == NULL) + return 0; + + SET_RETURN_SIZE(p, 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, + size_t len) +{ + if (p == NULL) + return 0; + + SET_RETURN_SIZE(p, 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) +{ + return ossl_param_construct(key, OSSL_PARAM_UTF8_STRING, buf, bsize, + rsize); +} + +OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, + size_t bsize, size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_OCTET_STRING, buf, bsize, + rsize); +} + +static int get_ptr_internal(const OSSL_PARAM *p, const void **val, + size_t *used_len, unsigned int type) +{ + if (val == NULL || p == NULL || p->data_type != type) + return 0; + if (used_len != NULL) + *used_len = p->data_size; + *val = *(const void **)p->data; + return 1; +} + +int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val) +{ + return get_ptr_internal(p, (const void **)val, NULL, OSSL_PARAM_UTF8_PTR); +} + +int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val, + size_t *used_len) +{ + return get_ptr_internal(p, val, used_len, OSSL_PARAM_OCTET_PTR); +} + +static int set_ptr_internal(const OSSL_PARAM *p, const void *val, + unsigned int type, size_t len) +{ + SET_RETURN_SIZE(p, 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) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 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, + size_t used_len) +{ + if (p == NULL) + return 0; + SET_RETURN_SIZE(p, 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 *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_UTF8_PTR, buf, 0, rsize); +} + +OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, + size_t *rsize) +{ + return ossl_param_construct(key, OSSL_PARAM_OCTET_PTR, buf, 0, rsize); +} diff --git a/crypto/provider.c b/crypto/provider.c new file mode 100644 index 00000000..823d5dd5 --- /dev/null +++ b/crypto/provider.c @@ -0,0 +1,70 @@ +/* + * 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.h" + +OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *libctx, const char *name) +{ + OSSL_PROVIDER *prov = NULL; + + /* Find it or create it */ + if ((prov = ossl_provider_find(libctx, name)) == NULL + && (prov = ossl_provider_new(libctx, name, NULL)) == NULL) + return NULL; + + if (!ossl_provider_activate(prov)) { + ossl_provider_free(prov); + return NULL; + } + + return prov; +} + +int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov) +{ + ossl_provider_free(prov); + return 1; +} + +const OSSL_ITEM *OSSL_PROVIDER_get_param_types(OSSL_PROVIDER *prov) +{ + return ossl_provider_get_param_types(prov); +} + +int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, const OSSL_PARAM params[]) +{ + return ossl_provider_get_params(prov, params); +} + +int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *libctx, const char *name, + OSSL_provider_init_fn *init_fn) +{ + OSSL_PROVIDER *prov = NULL; + + if (name == NULL || init_fn == NULL) { + CRYPTOerr(CRYPTO_F_OSSL_PROVIDER_ADD_BUILTIN, + ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + + /* Create it */ + if ((prov = ossl_provider_new(libctx, name, init_fn)) == NULL) + return 0; + + /* + * It's safely stored in the internal store at this point, + * free the returned extra reference + */ + ossl_provider_free(prov); + + return 1; +} diff --git a/crypto/provider_core.c b/crypto/provider_core.c new file mode 100644 index 00000000..8af5b1f1 --- /dev/null +++ b/crypto/provider_core.c @@ -0,0 +1,451 @@ +/* + * 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/cryptlib.h" +#include "internal/thread_once.h" +#include "internal/provider.h" +#include "internal/refcount.h" + +/*- + * Provider Object structure + * ========================= + */ + +struct provider_store_st; /* Forward declaration */ + +struct ossl_provider_st { + /* Flag bits */ + unsigned int flag_initialized:1; + + /* OpenSSL library side data */ + CRYPTO_REF_COUNT refcnt; + CRYPTO_RWLOCK *refcnt_lock; /* For the ref counter */ + char *name; + DSO *module; + OSSL_provider_init_fn *init_function; + + /* Provider side functions */ + OSSL_provider_teardown_fn *teardown; + OSSL_provider_get_param_types_fn *get_param_types; + OSSL_provider_get_params_fn *get_params; + OSSL_provider_query_operation_fn *query_operation; +}; +DEFINE_STACK_OF(OSSL_PROVIDER) + +static int ossl_provider_cmp(const OSSL_PROVIDER * const *a, + const OSSL_PROVIDER * const *b) +{ + return strcmp((*a)->name, (*b)->name); +} + +/*- + * Provider Object store + * ===================== + * + * The Provider Object store is a library context object, and therefore needs + * an index. + */ + +struct provider_store_st { + STACK_OF(OSSL_PROVIDER) *providers; + CRYPTO_RWLOCK *lock; +}; +static int provider_store_index = -1; + +static void provider_store_free(void *vstore) +{ + struct provider_store_st *store = vstore; + + if (store == NULL) + return; + sk_OSSL_PROVIDER_pop_free(store->providers, ossl_provider_free); + CRYPTO_THREAD_lock_free(store->lock); + OPENSSL_free(store); +} + +static void *provider_store_new(void) +{ + struct provider_store_st *store = OPENSSL_zalloc(sizeof(*store)); + + if (store == NULL + || (store->providers = sk_OSSL_PROVIDER_new(ossl_provider_cmp)) == NULL + || (store->lock = CRYPTO_THREAD_lock_new()) == NULL) { + provider_store_free(store); + store = NULL; + } + return store; +} + +static const OPENSSL_CTX_METHOD provider_store_method = { + provider_store_new, + provider_store_free, +}; + +static CRYPTO_ONCE provider_store_init_flag = CRYPTO_ONCE_STATIC_INIT; +DEFINE_RUN_ONCE_STATIC(do_provider_store_init) +{ + return OPENSSL_init_crypto(0, NULL) + && (provider_store_index = + openssl_ctx_new_index(&provider_store_method)) != -1; +} + + +static struct provider_store_st *get_provider_store(OPENSSL_CTX *libctx) +{ + struct provider_store_st *store = NULL; + + if (!RUN_ONCE(&provider_store_init_flag, do_provider_store_init)) + return NULL; + + store = openssl_ctx_get_data(libctx, provider_store_index); + if (store == NULL) + CRYPTOerr(CRYPTO_F_GET_PROVIDER_STORE, ERR_R_INTERNAL_ERROR); + return store; +} + +/*- + * Provider Object methods + * ======================= + */ + +int ossl_provider_upref(OSSL_PROVIDER *prov) +{ + int ref = 0; + + CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock); + return ref; +} + +/* Finder, constructor and destructor */ +OSSL_PROVIDER *ossl_provider_find(OPENSSL_CTX *libctx, const char *name) +{ + struct provider_store_st *store = NULL; + OSSL_PROVIDER *prov = NULL; + + if ((store = get_provider_store(libctx)) != NULL) { + OSSL_PROVIDER tmpl = { 0, }; + int i; + + tmpl.name = (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)) + prov = NULL; + CRYPTO_THREAD_unlock(store->lock); + } + + return prov; +} + +OSSL_PROVIDER *ossl_provider_new(OPENSSL_CTX *libctx, const char *name, + OSSL_provider_init_fn *init_function) +{ + struct provider_store_st *store = NULL; + OSSL_PROVIDER *prov = NULL; + + if ((store = get_provider_store(libctx)) == NULL) + return NULL; + + if ((prov = ossl_provider_find(libctx, name)) != NULL) { /* refcount +1 */ + ossl_provider_free(prov); /* refcount -1 */ + CRYPTOerr(CRYPTO_F_OSSL_PROVIDER_NEW, + CRYPTO_R_PROVIDER_ALREADY_EXISTS); + ERR_add_error_data(2, "name=", name); + return NULL; + } + + if ((prov = OPENSSL_zalloc(sizeof(*prov))) == NULL +#ifndef HAVE_ATOMICS + || (prov->refcnt_lock = CRYPTO_THREAD_lock_new()) == NULL +#endif + || !ossl_provider_upref(prov) /* +1 One reference to be returned */ + || (prov->name = OPENSSL_strdup(name)) == NULL) { + ossl_provider_free(prov); + CRYPTOerr(CRYPTO_F_OSSL_PROVIDER_NEW, ERR_R_MALLOC_FAILURE); + return NULL; + } + + prov->init_function = init_function; + + CRYPTO_THREAD_write_lock(store->lock); + if (!ossl_provider_upref(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) { + ossl_provider_free(prov); /* -1 Store reference */ + ossl_provider_free(prov); /* -1 Reference that was to be returned */ + prov = NULL; + } + CRYPTO_THREAD_unlock(store->lock); + + if (prov == NULL) + CRYPTOerr(CRYPTO_F_OSSL_PROVIDER_NEW, ERR_R_MALLOC_FAILURE); + + /* + * At this point, the provider is only partially "loaded". To be + * fully "loaded", ossl_provider_activate() must also be called. + */ + + return prov; +} + +void ossl_provider_free(OSSL_PROVIDER *prov) +{ + if (prov != NULL) { + int ref = 0; + + CRYPTO_DOWN_REF(&prov->refcnt, &ref, prov->refcnt_lock); + + /* + * When the refcount drops down to one, there is only one reference, + * the store. + * When that happens, the provider is inactivated. + */ + if (ref == 1 && prov->flag_initialized) { + if (prov->teardown != NULL) + prov->teardown(); + prov->flag_initialized = 0; + } + + /* + * When the refcount drops to zero, it has been taken out of + * the store. All we have to do here is clean it out. + */ + if (ref == 0) { + DSO_free(prov->module); + OPENSSL_free(prov->name); +#ifndef HAVE_ATOMICS + CRYPTO_THREAD_lock_free(prov->refcnt_lock); +#endif + OPENSSL_free(prov); + } + } +} + +/* + * Provider activation. + * + * What "activation" means depends on the provider form; for built in + * providers (in the library or the application alike), the provider + * can already be considered to be loaded, all that's needed is to + * initialize it. However, for dynamically loadable provider modules, + * we must first load that module. + * + * Built in modules are distinguished from dynamically loaded modules + * with an already assigned init function. + */ +static const OSSL_DISPATCH *core_dispatch; /* Define further down */ + +int ossl_provider_activate(OSSL_PROVIDER *prov) +{ + const OSSL_DISPATCH *provider_dispatch = NULL; + + if (prov->flag_initialized) + return 1; + + /* + * If the init function isn't set, it indicates that this provider is + * a loadable module. + */ + if (prov->init_function == NULL) { + if (prov->module == NULL) { + char *platform_module_name = NULL; + char *module_path = NULL; + const char *load_dir = ossl_safe_getenv("OPENSSL_MODULES"); + + if ((prov->module = DSO_new()) == NULL) { + /* DSO_new() generates an error already */ + return 0; + } + + if (load_dir == NULL) + load_dir = MODULESDIR; + + DSO_ctrl(prov->module, DSO_CTRL_SET_FLAGS, + DSO_FLAG_NAME_TRANSLATION_EXT_ONLY, NULL); + if ((platform_module_name = + DSO_convert_filename(prov->module, prov->name)) == NULL + || (module_path = + DSO_merge(prov->module, platform_module_name, + load_dir)) == NULL + || DSO_load(prov->module, module_path, NULL, + DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == NULL) { + DSO_free(prov->module); + prov->module = NULL; + } + + OPENSSL_free(platform_module_name); + OPENSSL_free(module_path); + } + + if (prov->module != NULL) + prov->init_function = (OSSL_provider_init_fn *) + DSO_bind_func(prov->module, "OSSL_provider_init"); + } + + if (prov->init_function == NULL + || !prov->init_function(prov, core_dispatch, &provider_dispatch)) { + CRYPTOerr(CRYPTO_F_OSSL_PROVIDER_ACTIVATE, ERR_R_INIT_FAIL); + ERR_add_error_data(2, "name=", prov->name); + DSO_free(prov->module); + prov->module = NULL; + return 0; + } + + for (; provider_dispatch->function_id != 0; provider_dispatch++) { + switch (provider_dispatch->function_id) { + case OSSL_FUNC_PROVIDER_TEARDOWN: + prov->teardown = + OSSL_get_provider_teardown(provider_dispatch); + break; + case OSSL_FUNC_PROVIDER_GET_PARAM_TYPES: + prov->get_param_types = + OSSL_get_provider_get_param_types(provider_dispatch); + break; + case OSSL_FUNC_PROVIDER_GET_PARAMS: + prov->get_params = + OSSL_get_provider_get_params(provider_dispatch); + break; + case OSSL_FUNC_PROVIDER_QUERY_OPERATION: + prov->query_operation = + OSSL_get_provider_query_operation(provider_dispatch); + break; + } + } + + /* With this flag set, this provider has become fully "loaded". */ + prov->flag_initialized = 1; + + return 1; +} + +int ossl_provider_forall_loaded(OPENSSL_CTX *ctx, + int (*cb)(OSSL_PROVIDER *provider, + void *cbdata), + void *cbdata) +{ + int ret = 1; + int i; + struct provider_store_st *store = get_provider_store(ctx); + + if (store != NULL) { + CRYPTO_THREAD_read_lock(store->lock); + for (i = 0; i < sk_OSSL_PROVIDER_num(store->providers); i++) { + OSSL_PROVIDER *prov = sk_OSSL_PROVIDER_value(store->providers, i); + + if (prov->flag_initialized + && !(ret = cb(prov, cbdata))) + break; + } + CRYPTO_THREAD_unlock(store->lock); + } + + return ret; +} + +/* Getters of Provider Object data */ +const char *ossl_provider_name(OSSL_PROVIDER *prov) +{ + return prov->name; +} + +const DSO *ossl_provider_dso(OSSL_PROVIDER *prov) +{ + return prov->module; +} + +const char *ossl_provider_module_name(OSSL_PROVIDER *prov) +{ + return DSO_get_filename(prov->module); +} + +const char *ossl_provider_module_path(OSSL_PROVIDER *prov) +{ + /* FIXME: Ensure it's a full path */ + return DSO_get_filename(prov->module); +} + +/* Wrappers around calls to the provider */ +void ossl_provider_teardown(const OSSL_PROVIDER *prov) +{ + if (prov->teardown != NULL) + prov->teardown(); +} + +const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov) +{ + return prov->get_param_types == NULL ? NULL : prov->get_param_types(prov); +} + +int ossl_provider_get_params(const OSSL_PROVIDER *prov, + const OSSL_PARAM params[]) +{ + return prov->get_params == NULL ? 0 : prov->get_params(prov, params); +} + + +const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov, + int operation_id, + int *no_cache) +{ + return prov->query_operation(prov, operation_id, no_cache); +} + +/*- + * Core functions for the provider + * =============================== + * + * This is the set of functions that the core makes available to the provider + */ + +/* + * This returns a list of Provider Object parameters with their types, for + * discovery. We do not expect that many providers will use this, but one + * never knows. + */ +static const OSSL_ITEM param_types[] = { + { OSSL_PARAM_UTF8_PTR, "openssl-version" }, + { OSSL_PARAM_UTF8_PTR, "provider-name" }, + { 0, NULL } +}; + +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[]) +{ + int i; + + for (i = 0; params[i].key != NULL; i++) { + if (strcmp(params[i].key, "openssl-version") == 0) { + *(void **)params[i].data = OPENSSL_VERSION_STR; + if (params[i].return_size) + *params[i].return_size = sizeof(OPENSSL_VERSION_STR); + } else if (strcmp(params[i].key, "provider-name") == 0) { + *(void **)params[i].data = prov->name; + if (params[i].return_size) + *params[i].return_size = strlen(prov->name) + 1; + } + } + + return 1; +} + +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 }, + { 0, NULL } +}; +static const OSSL_DISPATCH *core_dispatch = core_dispatch_; diff --git a/crypto/rand/rand_vms.c b/crypto/rand/rand_vms.c index c083977e..d35106a3 100644 --- a/crypto/rand/rand_vms.c +++ b/crypto/rand/rand_vms.c @@ -507,7 +507,11 @@ int rand_pool_add_additional_data(RAND_POOL *pool) * concurrently (which is the case for the drbg). */ data.tid = CRYPTO_THREAD_get_current_id(); +#if __CRTL_VER >= 80400000 sys$gettim_prec(&data.time); +#else + sys$gettim((void*)&data.time); +#endif return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0); } diff --git a/crypto/rsa/build.info b/crypto/rsa/build.info index 87f92492..70864170 100644 --- a/crypto/rsa/build.info +++ b/crypto/rsa/build.info @@ -3,4 +3,5 @@ SOURCE[../../libcrypto]=\ rsa_ossl.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c \ rsa_pk1.c rsa_ssl.c rsa_none.c rsa_oaep.c rsa_chk.c \ rsa_pss.c rsa_x931.c rsa_asn1.c rsa_depr.c rsa_ameth.c rsa_prn.c \ - rsa_pmeth.c rsa_crpt.c rsa_x931g.c rsa_meth.c rsa_mp.c + rsa_pmeth.c rsa_crpt.c rsa_x931g.c rsa_meth.c rsa_mp.c \ + rsa_sp800_56b_gen.c rsa_sp800_56b_check.c diff --git a/crypto/rsa/rsa_chk.c b/crypto/rsa/rsa_chk.c index 805f998f..4f65dfa6 100644 --- a/crypto/rsa/rsa_chk.c +++ b/crypto/rsa/rsa_chk.c @@ -16,8 +16,21 @@ int RSA_check_key(const RSA *key) return RSA_check_key_ex(key, NULL); } +/* + * NOTE: Key validation requires separate checks to be able to be accessed + * individually. These should be visible from the PKEY API.. + * See rsa_sp800_56b_check_public, rsa_sp800_56b_check_private and + * rsa_sp800_56b_check_keypair. + */ int RSA_check_key_ex(const RSA *key, BN_GENCB *cb) { +#ifdef FIPS_MODE + if (!(rsa_sp800_56b_check_public(key) + && rsa_sp800_56b_check_private(key) + && rsa_sp800_56b_check_keypair(key, NULL, -1, RSA_bits(key)) + return 0; + +#else BIGNUM *i, *j, *k, *l, *m; BN_CTX *ctx; int ret = 1, ex_primes = 0, idx; @@ -225,4 +238,5 @@ int RSA_check_key_ex(const RSA *key, BN_GENCB *cb) BN_free(m); BN_CTX_free(ctx); return ret; +#endif /* FIPS_MODE */ } diff --git a/crypto/rsa/rsa_err.c b/crypto/rsa/rsa_err.c index 24eaaf89..936413d4 100644 --- a/crypto/rsa/rsa_err.c +++ b/crypto/rsa/rsa_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 @@ -32,6 +32,8 @@ static const ERR_STRING_DATA RSA_str_functs[] = { {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_CHECK_KEY_EX, 0), "RSA_check_key_ex"}, {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_CMS_DECRYPT, 0), "rsa_cms_decrypt"}, {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_CMS_VERIFY, 0), "rsa_cms_verify"}, + {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_FIPS186_4_GEN_PROB_PRIMES, 0), + "rsa_fips186_4_gen_prob_primes"}, {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_ITEM_VERIFY, 0), "rsa_item_verify"}, {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_METH_DUP, 0), "RSA_meth_dup"}, {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_METH_NEW, 0), "RSA_meth_new"}, @@ -97,6 +99,14 @@ static const ERR_STRING_DATA RSA_str_functs[] = { {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_SIGN, 0), "RSA_sign"}, {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_SIGN_ASN1_OCTET_STRING, 0), "RSA_sign_ASN1_OCTET_STRING"}, + {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_SP800_56B_CHECK_KEYPAIR, 0), + "rsa_sp800_56b_check_keypair"}, + {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_SP800_56B_CHECK_PUBLIC, 0), + "rsa_sp800_56b_check_public"}, + {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_SP800_56B_PAIRWISE_TEST, 0), + "rsa_sp800_56b_pairwise_test"}, + {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_SP800_56B_VALIDATE_STRENGTH, 0), + "rsa_sp800_56b_validate_strength"}, {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_VERIFY, 0), "RSA_verify"}, {ERR_PACK(ERR_LIB_RSA, RSA_F_RSA_VERIFY_ASN1_OCTET_STRING, 0), "RSA_verify_ASN1_OCTET_STRING"}, @@ -146,10 +156,13 @@ static const ERR_STRING_DATA RSA_str_reasons[] = { {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_DIGEST_LENGTH), "invalid digest length"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_HEADER), "invalid header"}, + {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_KEYPAIR), "invalid keypair"}, + {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_KEY_LENGTH), "invalid key length"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_LABEL), "invalid label"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_MESSAGE_LENGTH), "invalid message length"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_MGF1_MD), "invalid mgf1 md"}, + {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_MODULUS), "invalid modulus"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_MULTI_PRIME_KEY), "invalid multi prime key"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_OAEP_PARAMETERS), @@ -161,8 +174,10 @@ static const ERR_STRING_DATA RSA_str_reasons[] = { "invalid pss parameters"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_PSS_SALTLEN), "invalid pss saltlen"}, + {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_REQUEST), "invalid request"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_SALT_LENGTH), "invalid salt length"}, + {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_STRENGTH), "invalid strength"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_TRAILER), "invalid trailer"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_INVALID_X931_DIGEST), "invalid x931 digest"}, @@ -193,10 +208,14 @@ static const ERR_STRING_DATA RSA_str_reasons[] = { "operation not supported for this keytype"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_PADDING_CHECK_FAILED), "padding check failed"}, + {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_PAIRWISE_TEST_FAILURE), + "pairwise test failure"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_PKCS_DECODING_ERROR), "pkcs decoding error"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_PSS_SALTLEN_TOO_SMALL), "pss saltlen too small"}, + {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_PUB_EXPONENT_OUT_OF_RANGE), + "pub exponent out of range"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_P_NOT_PRIME), "p not prime"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_Q_NOT_PRIME), "q not prime"}, {ERR_PACK(ERR_LIB_RSA, 0, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED), diff --git a/crypto/rsa/rsa_gen.c b/crypto/rsa/rsa_gen.c index 1d38ec99..4bfe3c3a 100644 --- a/crypto/rsa/rsa_gen.c +++ b/crypto/rsa/rsa_gen.c @@ -41,6 +41,7 @@ int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb) int RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes, BIGNUM *e_value, BN_GENCB *cb) { +#ifndef FIPS_MODE /* multi-prime is only supported with the builtin key generation */ if (rsa->meth->rsa_multi_prime_keygen != NULL) { return rsa->meth->rsa_multi_prime_keygen(rsa, bits, primes, @@ -57,13 +58,18 @@ int RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes, else return 0; } - +#endif /* FIPS_MODE */ return rsa_builtin_keygen(rsa, bits, primes, e_value, cb); } static int rsa_builtin_keygen(RSA *rsa, int bits, int primes, BIGNUM *e_value, BN_GENCB *cb) { +#ifdef FIPS_MODE + if (primes != 2) + return 0; + return rsa_sp800_56b_generate_key(rsa, bits, e_value, cb); +#else BIGNUM *r0 = NULL, *r1 = NULL, *r2 = NULL, *tmp, *prime; int ok = -1, n = 0, bitsr[RSA_MAX_PRIME_NUM], bitse = 0; int i = 0, quo = 0, rmd = 0, adj = 0, retries = 0; @@ -391,4 +397,5 @@ static int rsa_builtin_keygen(RSA *rsa, int bits, int primes, BIGNUM *e_value, BN_CTX_end(ctx); BN_CTX_free(ctx); return ok; +#endif /* FIPS_MODE */ } diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c index 0848936b..f337a0df 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -253,7 +253,7 @@ static uint32_t ilog_e(uint64_t v) * \cdot(log_e(nBits \cdot log_e(2))^{2/3} - 4.69}{log_e(2)} * The two cube roots are merged together here. */ -static uint16_t rsa_compute_security_bits(int n) +uint16_t rsa_compute_security_bits(int n) { uint64_t x; uint32_t lx; diff --git a/crypto/rsa/rsa_locl.h b/crypto/rsa/rsa_locl.h index 44a2a2df..5dcd6eab 100644 --- a/crypto/rsa/rsa_locl.h +++ b/crypto/rsa/rsa_locl.h @@ -7,6 +7,9 @@ * https://www.openssl.org/source/license.html */ +#ifndef RSA_LOCAL_HEADER_H +#define RSA_LOCAL_HEADER_H + #include #include "internal/refcount.h" @@ -130,3 +133,38 @@ void rsa_multip_info_free(RSA_PRIME_INFO *pinfo); RSA_PRIME_INFO *rsa_multip_info_new(void); int rsa_multip_calc_product(RSA *rsa); int rsa_multip_cap(int bits); + +uint16_t rsa_compute_security_bits(int n); + +int rsa_sp800_56b_validate_strength(int nbits, int strength); +int rsa_check_pminusq_diff(BIGNUM *diff, const BIGNUM *p, const BIGNUM *q, + int nbits); +int rsa_get_lcm(BN_CTX *ctx, const BIGNUM *p, const BIGNUM *q, + BIGNUM *lcm, BIGNUM *gcd, BIGNUM *p1, BIGNUM *q1, + BIGNUM *p1q1); + +int rsa_check_public_exponent(const BIGNUM *e); +int rsa_check_private_exponent(const RSA *rsa, int nbits, BN_CTX *ctx); +int rsa_check_prime_factor(BIGNUM *p, BIGNUM *e, int nbits, BN_CTX *ctx); +int rsa_check_prime_factor_range(const BIGNUM *p, int nbits, BN_CTX *ctx); +int rsa_check_crt_components(const RSA *rsa, BN_CTX *ctx); + +int rsa_sp800_56b_pairwise_test(RSA *rsa, BN_CTX *ctx); +int rsa_sp800_56b_check_public(const RSA *rsa); +int rsa_sp800_56b_check_private(const RSA *rsa); +int rsa_sp800_56b_check_keypair(const RSA *rsa, const BIGNUM *efixed, + int strength, int nbits); +int rsa_sp800_56b_generate_key(RSA *rsa, int nbits, const BIGNUM *efixed, + BN_GENCB *cb); + +int rsa_sp800_56b_derive_params_from_pq(RSA *rsa, int nbits, + const BIGNUM *e, BN_CTX *ctx); +int rsa_fips186_4_gen_prob_primes(RSA *rsa, BIGNUM *p1, BIGNUM *p2, + BIGNUM *Xpout, const BIGNUM *Xp, + const BIGNUM *Xp1, const BIGNUM *Xp2, + BIGNUM *q1, BIGNUM *q2, BIGNUM *Xqout, + const BIGNUM *Xq, const BIGNUM *Xq1, + const BIGNUM *Xq2, int nbits, + const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb); + +#endif /* RSA_LOCAL_HEADER_H */ diff --git a/crypto/rsa/rsa_oaep.c b/crypto/rsa/rsa_oaep.c index 552b89a1..8fca4fab 100644 --- a/crypto/rsa/rsa_oaep.c +++ b/crypto/rsa/rsa_oaep.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 @@ -143,7 +143,7 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, * |num| is the length of the modulus; |flen| is the length of the * encoded message. Therefore, for any |from| that was obtained by * decrypting a ciphertext, we must have |flen| <= |num|. Similarly, - * num < 2 * mdlen + 2 must hold for the modulus irrespective of + * |num| >= 2 * |mdlen| + 2 must hold for the modulus irrespective of * the ciphertext, see PKCS #1 v2.2, section 7.1.2. * This does not leak any side-channel information. */ @@ -179,17 +179,16 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, from -= 1 & mask; *--em = *from & mask; } - from = em; /* * The first byte must be zero, however we must not leak if this is * true. See James H. Manger, "A Chosen Ciphertext Attack on RSA * Optimal Asymmetric Encryption Padding (OAEP) [...]", CRYPTO 2001). */ - good = constant_time_is_zero(from[0]); + good = constant_time_is_zero(em[0]); - maskedseed = from + 1; - maskeddb = from + 1 + mdlen; + maskedseed = em + 1; + maskeddb = em + 1 + mdlen; if (PKCS1_MGF1(seed, mdlen, maskeddb, dblen, mgf1md)) goto cleanup; @@ -230,7 +229,7 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, mlen = dblen - msg_index; /* - * For good measure, do this check in constant tine as well. + * For good measure, do this check in constant time as well. */ good &= constant_time_ge(tlen, mlen); @@ -244,15 +243,16 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, * should be noted that failure is indistinguishable from normal * operation if |tlen| is fixed by protocol. */ - tlen = constant_time_select_int(constant_time_lt(dblen, tlen), dblen, tlen); + tlen = constant_time_select_int(constant_time_lt(dblen - mdlen - 1, tlen), + dblen - mdlen - 1, tlen); msg_index = constant_time_select_int(good, msg_index, dblen - tlen); mlen = dblen - msg_index; - for (from = db + msg_index, mask = good, i = 0; i < tlen; i++) { - unsigned int equals = constant_time_eq(i, mlen); + for (mask = good, i = 0; i < tlen; i++) { + unsigned int equals = constant_time_eq(msg_index, dblen); - from -= dblen & equals; /* if (i == dblen) rewind */ - mask &= mask ^ equals; /* if (i == dblen) mask = 0 */ - to[i] = constant_time_select_8(mask, from[i], to[i]); + msg_index -= tlen & equals; /* rewind at EOF */ + mask &= ~equals; /* mask = 0 at EOF */ + to[i] = constant_time_select_8(mask, db[msg_index++], to[i]); } /* diff --git a/crypto/rsa/rsa_pk1.c b/crypto/rsa/rsa_pk1.c index cb7518e1..58ac992c 100644 --- a/crypto/rsa/rsa_pk1.c +++ b/crypto/rsa/rsa_pk1.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 @@ -192,15 +192,14 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, from -= 1 & mask; *--em = *from & mask; } - from = em; - good = constant_time_is_zero(from[0]); - good &= constant_time_eq(from[1], 2); + good = constant_time_is_zero(em[0]); + good &= constant_time_eq(em[1], 2); /* scan over padding data */ found_zero_byte = 0; for (i = 2; i < num; i++) { - unsigned int equals0 = constant_time_is_zero(from[i]); + unsigned int equals0 = constant_time_is_zero(em[i]); zero_index = constant_time_select_int(~found_zero_byte & equals0, i, zero_index); @@ -208,7 +207,7 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, } /* - * PS must be at least 8 bytes long, and it starts two bytes into |from|. + * PS must be at least 8 bytes long, and it starts two bytes into |em|. * If we never found a 0-byte, then |zero_index| is 0 and the check * also fails. */ @@ -236,15 +235,16 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, * should be noted that failure is indistinguishable from normal * operation if |tlen| is fixed by protocol. */ - tlen = constant_time_select_int(constant_time_lt(num, tlen), num, tlen); + tlen = constant_time_select_int(constant_time_lt(num - 11, tlen), + num - 11, tlen); msg_index = constant_time_select_int(good, msg_index, num - tlen); mlen = num - msg_index; - for (from += msg_index, mask = good, i = 0; i < tlen; i++) { - unsigned int equals = constant_time_eq(i, mlen); + for (mask = good, i = 0; i < tlen; i++) { + unsigned int equals = constant_time_eq(msg_index, num); - from -= tlen & equals; /* if (i == mlen) rewind */ - mask &= mask ^ equals; /* if (i == mlen) mask = 0 */ - to[i] = constant_time_select_8(mask, from[i], to[i]); + msg_index -= tlen & equals; /* rewind at EOF */ + mask &= ~equals; /* mask = 0 at EOF */ + to[i] = constant_time_select_8(mask, em[msg_index++], to[i]); } OPENSSL_clear_free(em, num); diff --git a/crypto/rsa/rsa_pmeth.c b/crypto/rsa/rsa_pmeth.c index 2295fa57..8931d7e8 100644 --- a/crypto/rsa/rsa_pmeth.c +++ b/crypto/rsa/rsa_pmeth.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-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,6 +7,8 @@ * https://www.openssl.org/source/license.html */ +#include "internal/constant_time_locl.h" + #include #include "internal/cryptlib.h" #include @@ -340,10 +342,9 @@ static int pkey_rsa_decrypt(EVP_PKEY_CTX *ctx, ret = RSA_private_decrypt(inlen, in, out, ctx->pkey->pkey.rsa, rctx->pad_mode); } - if (ret < 0) - return ret; - *outlen = ret; - return 1; + *outlen = constant_time_select_s(constant_time_msb_s(ret), *outlen, ret); + ret = constant_time_select_int(constant_time_msb(ret), ret, 1); + return ret; } static int check_padding_md(const EVP_MD *md, int padding) diff --git a/crypto/rsa/rsa_sp800_56b_check.c b/crypto/rsa/rsa_sp800_56b_check.c new file mode 100644 index 00000000..10e264e5 --- /dev/null +++ b/crypto/rsa/rsa_sp800_56b_check.c @@ -0,0 +1,386 @@ +/* + * Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2018-2019, Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the OpenSSL license (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/bn_int.h" +#include "rsa_locl.h" + +/* + * Part of the RSA keypair test. + * Check the Chinese Remainder Theorem components are valid. + * + * See SP800-5bBr1 + * 6.4.1.2.3: rsakpv1-crt Step 7 + * 6.4.1.3.3: rsakpv2-crt Step 7 + */ +int rsa_check_crt_components(const RSA *rsa, BN_CTX *ctx) +{ + int ret = 0; + BIGNUM *r = NULL, *p1 = NULL, *q1 = NULL; + + /* check if only some of the crt components are set */ + if (rsa->dmp1 == NULL || rsa->dmq1 == NULL || rsa->iqmp == NULL) { + if (rsa->dmp1 != NULL || rsa->dmq1 != NULL || rsa->iqmp != NULL) + return 0; + return 1; /* return ok if all components are NULL */ + } + + BN_CTX_start(ctx); + r = BN_CTX_get(ctx); + p1 = BN_CTX_get(ctx); + q1 = BN_CTX_get(ctx); + ret = (q1 != NULL) + /* p1 = p -1 */ + && (BN_copy(p1, rsa->p) != NULL) + && BN_sub_word(p1, 1) + /* q1 = q - 1 */ + && (BN_copy(q1, rsa->q) != NULL) + && BN_sub_word(q1, 1) + /* (a) 1 < dP < (p – 1). */ + && (BN_cmp(rsa->dmp1, BN_value_one()) > 0) + && (BN_cmp(rsa->dmp1, p1) < 0) + /* (b) 1 < dQ < (q - 1). */ + && (BN_cmp(rsa->dmq1, BN_value_one()) > 0) + && (BN_cmp(rsa->dmq1, q1) < 0) + /* (c) 1 < qInv < p */ + && (BN_cmp(rsa->iqmp, BN_value_one()) > 0) + && (BN_cmp(rsa->iqmp, rsa->p) < 0) + /* (d) 1 = (dP . e) mod (p - 1)*/ + && BN_mod_mul(r, rsa->dmp1, rsa->e, p1, ctx) + && BN_is_one(r) + /* (e) 1 = (dQ . e) mod (q - 1) */ + && BN_mod_mul(r, rsa->dmq1, rsa->e, q1, ctx) + && BN_is_one(r) + /* (f) 1 = (qInv . q) mod p */ + && BN_mod_mul(r, rsa->iqmp, rsa->q, rsa->p, ctx) + && BN_is_one(r); + BN_clear(p1); + BN_clear(q1); + BN_CTX_end(ctx); + return ret; +} + +/* + * Part of the RSA keypair test. + * Check that (√2)(2^(nbits/2 - 1) <= p <= 2^(nbits/2) - 1 + * + * See SP800-5bBr1 6.4.1.2.1 Part 5 (c) & (g) - used for both p and q. + * + * (√2)(2^(nbits/2 - 1) = (√2/2)(2^(nbits/2)) + * √2/2 = 0.707106781186547524400 = 0.B504F333F9DE6484597D8 + * 0.B504F334 gives an approximation to 11 decimal places. + * The range is then from + * 0xB504F334_0000.......................000 to + * 0xFFFFFFFF_FFFF.......................FFF + */ +int rsa_check_prime_factor_range(const BIGNUM *p, int nbits, BN_CTX *ctx) +{ + int ret = 0; + BIGNUM *tmp, *low; + + nbits >>= 1; + + /* Upper bound check */ + if (BN_num_bits(p) != nbits) + return 0; + + BN_CTX_start(ctx); + tmp = BN_CTX_get(ctx); + low = BN_CTX_get(ctx); + + /* set low = (√2)(2^(nbits/2 - 1) */ + if (low == NULL || !BN_set_word(tmp, 0xB504F334)) + goto err; + + if (nbits >= 32) { + if (!BN_lshift(low, tmp, nbits - 32)) + goto err; + } else if (!BN_rshift(low, tmp, 32 - nbits)) { + goto err; + } + if (BN_cmp(p, low) < 0) + goto err; + ret = 1; +err: + BN_CTX_end(ctx); + return ret; +} + +/* + * Part of the RSA keypair test. + * Check the prime factor (for either p or q) + * i.e: p is prime AND GCD(p - 1, e) = 1 + * + * See SP800-5bBr1 6.4.1.2.3 Step 5 (a to d) & (e to h). + */ +int rsa_check_prime_factor(BIGNUM *p, BIGNUM *e, int nbits, BN_CTX *ctx) +{ + int checks = bn_rsa_fips186_4_prime_MR_min_checks(nbits); + int ret = 0; + BIGNUM *p1 = NULL, *gcd = NULL; + + /* (Steps 5 a-b) prime test */ + if (BN_is_prime_fasttest_ex(p, checks, ctx, 1, NULL) != 1 + /* (Step 5c) (√2)(2^(nbits/2 - 1) <= p <= 2^(nbits/2 - 1) */ + || rsa_check_prime_factor_range(p, nbits, ctx) != 1) + return 0; + + BN_CTX_start(ctx); + p1 = BN_CTX_get(ctx); + gcd = BN_CTX_get(ctx); + ret = (gcd != NULL) + /* (Step 5d) GCD(p-1, e) = 1 */ + && (BN_copy(p1, p) != NULL) + && BN_sub_word(p1, 1) + && BN_gcd(gcd, p1, e, ctx) + && BN_is_one(gcd); + + BN_clear(p1); + BN_CTX_end(ctx); + return ret; +} + +/* + * See SP800-56Br1 6.4.1.2.3 Part 6(a-b) Check the private exponent d + * satisfies: + * (Step 6a) 2^(nBit/2) < d < LCM(p–1, q–1). + * (Step 6b) 1 = (d*e) mod LCM(p–1, q–1) + */ +int rsa_check_private_exponent(const RSA *rsa, int nbits, BN_CTX *ctx) +{ + int ret; + BIGNUM *r, *p1, *q1, *lcm, *p1q1, *gcd; + + /* (Step 6a) 2^(nbits/2) < d */ + if (BN_num_bits(rsa->d) <= (nbits >> 1)) + return 0; + + BN_CTX_start(ctx); + r = BN_CTX_get(ctx); + p1 = BN_CTX_get(ctx); + q1 = BN_CTX_get(ctx); + lcm = BN_CTX_get(ctx); + p1q1 = BN_CTX_get(ctx); + gcd = BN_CTX_get(ctx); + ret = (gcd != NULL + /* LCM(p - 1, q - 1) */ + && (rsa_get_lcm(ctx, rsa->p, rsa->q, lcm, gcd, p1, q1, p1q1) == 1) + /* (Step 6a) d < LCM(p - 1, q - 1) */ + && (BN_cmp(rsa->d, lcm) < 0) + /* (Step 6b) 1 = (e . d) mod LCM(p - 1, q - 1) */ + && BN_mod_mul(r, rsa->e, rsa->d, lcm, ctx) + && BN_is_one(r)); + + BN_clear(p1); + BN_clear(q1); + BN_clear(lcm); + BN_clear(gcd); + BN_CTX_end(ctx); + return ret; +} + +/* Check exponent is odd, and has a bitlen ranging from [17..256] */ +int rsa_check_public_exponent(const BIGNUM *e) +{ + int bitlen = BN_num_bits(e); + + return (BN_is_odd(e) && bitlen > 16 && bitlen < 257); +} + +/* + * SP800-56Br1 6.4.1.2.1 (Step 5i): |p - q| > 2^(nbits/2 - 100) + * i.e- numbits(p-q-1) > (nbits/2 -100) + */ +int rsa_check_pminusq_diff(BIGNUM *diff, const BIGNUM *p, const BIGNUM *q, + int nbits) +{ + int bitlen = (nbits >> 1) - 100; + + if (!BN_sub(diff, p, q)) + return -1; + BN_set_negative(diff, 0); + + if (BN_is_zero(diff)) + return 0; + + if (!BN_sub_word(diff, 1)) + return -1; + return (BN_num_bits(diff) > bitlen); +} + +/* return LCM(p-1, q-1) */ +int rsa_get_lcm(BN_CTX *ctx, const BIGNUM *p, const BIGNUM *q, + BIGNUM *lcm, BIGNUM *gcd, BIGNUM *p1, BIGNUM *q1, + BIGNUM *p1q1) +{ + return BN_sub(p1, p, BN_value_one()) /* p-1 */ + && BN_sub(q1, q, BN_value_one()) /* q-1 */ + && BN_mul(p1q1, p1, q1, ctx) /* (p-1)(q-1) */ + && BN_gcd(gcd, p1, q1, ctx) + && BN_div(lcm, NULL, p1q1, gcd, ctx); /* LCM((p-1, q-1)) */ +} + +/* + * SP800-56Br1 6.4.2.2 Partial Public Key Validation for RSA refers to + * SP800-89 5.3.3 (Explicit) Partial Public Key Validation for RSA + * caveat is that the modulus must be as specified in SP800-56Br1 + */ +int rsa_sp800_56b_check_public(const RSA *rsa) +{ + int ret = 0, nbits, iterations, status; + BN_CTX *ctx = NULL; + BIGNUM *gcd = NULL; + + if (rsa->n == NULL || rsa->e == NULL) + return 0; + + /* + * (Step a): modulus must be 2048 or 3072 (caveat from SP800-56Br1) + * NOTE: changed to allow keys >= 2048 + */ + nbits = BN_num_bits(rsa->n); + if (!rsa_sp800_56b_validate_strength(nbits, -1)) { + RSAerr(RSA_F_RSA_SP800_56B_CHECK_PUBLIC, RSA_R_INVALID_KEY_LENGTH); + return 0; + } + if (!BN_is_odd(rsa->n)) { + RSAerr(RSA_F_RSA_SP800_56B_CHECK_PUBLIC, RSA_R_INVALID_MODULUS); + return 0; + } + + /* (Steps b-c): 2^16 < e < 2^256, n and e must be odd */ + if (!rsa_check_public_exponent(rsa->e)) { + RSAerr(RSA_F_RSA_SP800_56B_CHECK_PUBLIC, + RSA_R_PUB_EXPONENT_OUT_OF_RANGE); + return 0; + } + + ctx = BN_CTX_new(); + gcd = BN_new(); + if (ctx == NULL || gcd == NULL) + goto err; + + iterations = bn_rsa_fips186_4_prime_MR_min_checks(nbits); + /* (Steps d-f): + * The modulus is composite, but not a power of a prime. + * The modulus has no factors smaller than 752. + */ + if (!BN_gcd(gcd, rsa->n, bn_get0_small_factors(), ctx) || !BN_is_one(gcd)) { + RSAerr(RSA_F_RSA_SP800_56B_CHECK_PUBLIC, RSA_R_INVALID_MODULUS); + goto err; + } + + ret = bn_miller_rabin_is_prime(rsa->n, iterations, ctx, NULL, 1, &status); + if (ret != 1 || status != BN_PRIMETEST_COMPOSITE_NOT_POWER_OF_PRIME) { + RSAerr(RSA_F_RSA_SP800_56B_CHECK_PUBLIC, RSA_R_INVALID_MODULUS); + ret = 0; + goto err; + } + + ret = 1; +err: + BN_free(gcd); + BN_CTX_free(ctx); + return ret; +} + +/* + * Perform validation of the RSA private key to check that 0 < D < N. + */ +int rsa_sp800_56b_check_private(const RSA *rsa) +{ + if (rsa->d == NULL || rsa->n == NULL) + return 0; + return BN_cmp(rsa->d, BN_value_one()) >= 0 && BN_cmp(rsa->d, rsa->n) < 0; +} + +/* + * RSA key pair validation. + * + * SP800-56Br1. + * 6.4.1.2 "RSAKPV1 Family: RSA Key - Pair Validation with a Fixed Exponent" + * 6.4.1.3 "RSAKPV2 Family: RSA Key - Pair Validation with a Random Exponent" + * + * It uses: + * 6.4.1.2.3 "rsakpv1 - crt" + * 6.4.1.3.3 "rsakpv2 - crt" + */ +int rsa_sp800_56b_check_keypair(const RSA *rsa, const BIGNUM *efixed, + int strength, int nbits) +{ + int ret = 0; + BN_CTX *ctx = NULL; + BIGNUM *r = NULL; + + if (rsa->p == NULL + || rsa->q == NULL + || rsa->e == NULL + || rsa->d == NULL + || rsa->n == NULL) { + RSAerr(RSA_F_RSA_SP800_56B_CHECK_KEYPAIR, RSA_R_INVALID_REQUEST); + return 0; + } + /* (Step 1): Check Ranges */ + if (!rsa_sp800_56b_validate_strength(nbits, strength)) + return 0; + + /* If the exponent is known */ + if (efixed != NULL) { + /* (2): Check fixed exponent matches public exponent. */ + if (BN_cmp(efixed, rsa->e) != 0) { + RSAerr(RSA_F_RSA_SP800_56B_CHECK_KEYPAIR, RSA_R_INVALID_REQUEST); + return 0; + } + } + /* (Step 1.c): e is odd integer 65537 <= e < 2^256 */ + if (!rsa_check_public_exponent(rsa->e)) { + /* exponent out of range */ + RSAerr(RSA_F_RSA_SP800_56B_CHECK_KEYPAIR, + RSA_R_PUB_EXPONENT_OUT_OF_RANGE); + return 0; + } + /* (Step 3.b): check the modulus */ + if (nbits != BN_num_bits(rsa->n)) { + RSAerr(RSA_F_RSA_SP800_56B_CHECK_KEYPAIR, RSA_R_INVALID_KEYPAIR); + return 0; + } + + ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + + BN_CTX_start(ctx); + r = BN_CTX_get(ctx); + if (r == NULL || !BN_mul(r, rsa->p, rsa->q, ctx)) + goto err; + /* (Step 4.c): Check n = pq */ + if (BN_cmp(rsa->n, r) != 0) { + RSAerr(RSA_F_RSA_SP800_56B_CHECK_KEYPAIR, RSA_R_INVALID_REQUEST); + goto err; + } + + /* (Step 5): check prime factors p & q */ + ret = rsa_check_prime_factor(rsa->p, rsa->e, nbits, ctx) + && rsa_check_prime_factor(rsa->q, rsa->e, nbits, ctx) + && (rsa_check_pminusq_diff(r, rsa->p, rsa->q, nbits) > 0) + /* (Step 6): Check the private exponent d */ + && rsa_check_private_exponent(rsa, nbits, ctx) + /* 6.4.1.2.3 (Step 7): Check the CRT components */ + && rsa_check_crt_components(rsa, ctx); + if (ret != 1) + RSAerr(RSA_F_RSA_SP800_56B_CHECK_KEYPAIR, RSA_R_INVALID_KEYPAIR); + +err: + BN_clear(r); + BN_CTX_end(ctx); + BN_CTX_free(ctx); + return ret; +} diff --git a/crypto/rsa/rsa_sp800_56b_gen.c b/crypto/rsa/rsa_sp800_56b_gen.c new file mode 100644 index 00000000..221136bd --- /dev/null +++ b/crypto/rsa/rsa_sp800_56b_gen.c @@ -0,0 +1,362 @@ +/* + * Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2018-2019, Oracle and/or its affiliates. All rights reserved. + * + * Licensed under the OpenSSL license (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/bn_int.h" +#include "rsa_locl.h" + +#define RSA_FIPS1864_MIN_KEYGEN_KEYSIZE 2048 +#define RSA_FIPS1864_MIN_KEYGEN_STRENGTH 112 +#define RSA_FIPS1864_MAX_KEYGEN_STRENGTH 256 + +/* + * Generate probable primes 'p' & 'q'. See FIPS 186-4 Section B.3.6 + * "Generation of Probable Primes with Conditions Based on Auxiliary Probable + * Primes". + * + * Params: + * rsa Object used to store primes p & q. + * p1, p2 The returned auxiliary primes for p. If NULL they are not returned. + * Xpout An optionally returned random number used during generation of p. + * Xp An optional passed in value (that is random number used during + * generation of p). + * Xp1, Xp2 Optionally passed in randomly generated numbers from which + * auxiliary primes p1 & p2 are calculated. If NULL these values + * are generated internally. + * q1, q2 The returned auxiliary primes for q. If NULL they are not returned. + * Xqout An optionally returned random number used during generation of q. + * Xq An optional passed in value (that is random number used during + * generation of q). + * Xq1, Xq2 Optionally passed in randomly generated numbers from which + * auxiliary primes q1 & q2 are calculated. If NULL these values + * are generated internally. + * nbits The key size in bits (The size of the modulus n). + * e The public exponent. + * ctx A BN_CTX object. + * cb An optional BIGNUM callback. + * Returns: 1 if successful, or 0 otherwise. + * Notes: + * p1, p2, q1, q2, Xpout, Xqout are returned if they are not NULL. + * Xp, Xp1, Xp2, Xq, Xq1, Xq2 are optionally passed in. + * (Required for CAVS testing). + */ +int rsa_fips186_4_gen_prob_primes(RSA *rsa, BIGNUM *p1, BIGNUM *p2, + BIGNUM *Xpout, const BIGNUM *Xp, + const BIGNUM *Xp1, const BIGNUM *Xp2, + BIGNUM *q1, BIGNUM *q2, BIGNUM *Xqout, + const BIGNUM *Xq, const BIGNUM *Xq1, + const BIGNUM *Xq2, int nbits, + const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb) +{ + int ret = 0, ok; + BIGNUM *Xpo = NULL, *Xqo = NULL, *tmp = NULL; + + /* (Step 1) Check key length + * NOTE: SP800-131A Rev1 Disallows key lengths of < 2048 bits for RSA + * Signature Generation and Key Agree/Transport. + */ + if (nbits < RSA_FIPS1864_MIN_KEYGEN_KEYSIZE) { + RSAerr(RSA_F_RSA_FIPS186_4_GEN_PROB_PRIMES, RSA_R_INVALID_KEY_LENGTH); + return 0; + } + + if (!rsa_check_public_exponent(e)) { + RSAerr(RSA_F_RSA_FIPS186_4_GEN_PROB_PRIMES, + RSA_R_PUB_EXPONENT_OUT_OF_RANGE); + goto err; + } + + /* (Step 3) Determine strength and check rand generator strength is ok - + * this step is redundant because the generator always returns a higher + * strength than is required. + */ + + BN_CTX_start(ctx); + tmp = BN_CTX_get(ctx); + Xpo = (Xpout != NULL) ? Xpout : BN_CTX_get(ctx); + Xqo = (Xqout != NULL) ? Xqout : BN_CTX_get(ctx); + if (tmp == NULL || Xpo == NULL || Xqo == NULL) + goto err; + + if (rsa->p == NULL) + rsa->p = BN_secure_new(); + if (rsa->q == NULL) + rsa->q = BN_secure_new(); + if (rsa->p == NULL || rsa->q == NULL) + goto err; + + /* (Step 4) Generate p, Xp */ + if (!bn_rsa_fips186_4_gen_prob_primes(rsa->p, Xpo, p1, p2, Xp, Xp1, Xp2, + nbits, e, ctx, cb)) + goto err; + for(;;) { + /* (Step 5) Generate q, Xq*/ + if (!bn_rsa_fips186_4_gen_prob_primes(rsa->q, Xqo, q1, q2, Xq, Xq1, + Xq2, nbits, e, ctx, cb)) + goto err; + + /* (Step 6) |Xp - Xq| > 2^(nbitlen/2 - 100) */ + ok = rsa_check_pminusq_diff(tmp, Xpo, Xqo, nbits); + if (ok < 0) + goto err; + if (ok == 0) + continue; + + /* (Step 6) |p - q| > 2^(nbitlen/2 - 100) */ + ok = rsa_check_pminusq_diff(tmp, rsa->p, rsa->q, nbits); + if (ok < 0) + goto err; + if (ok == 0) + continue; + break; /* successfully finished */ + } + ret = 1; +err: + /* Zeroize any internally generated values that are not returned */ + if (Xpo != Xpout) + BN_clear(Xpo); + if (Xqo != Xqout) + BN_clear(Xqo); + BN_clear(tmp); + + BN_CTX_end(ctx); + return ret; +} + +/* + * Validates the RSA key size based on the target strength. + * See SP800-56Br1 6.3.1.1 (Steps 1a-1b) + * + * Params: + * nbits The key size in bits. + * strength The target strength in bits. -1 means the target + * strength is unknown. + * Returns: 1 if the key size matches the target strength, or 0 otherwise. + */ +int rsa_sp800_56b_validate_strength(int nbits, int strength) +{ + int s = (int)rsa_compute_security_bits(nbits); + + if (s < RSA_FIPS1864_MIN_KEYGEN_STRENGTH + || s > RSA_FIPS1864_MAX_KEYGEN_STRENGTH) { + RSAerr(RSA_F_RSA_SP800_56B_VALIDATE_STRENGTH, RSA_R_INVALID_MODULUS); + return 0; + } + if (strength != -1 && s != strength) { + RSAerr(RSA_F_RSA_SP800_56B_VALIDATE_STRENGTH, RSA_R_INVALID_STRENGTH); + return 0; + } + return 1; +} + +/* + * + * Using p & q, calculate other required parameters such as n, d. + * as well as the CRT parameters dP, dQ, qInv. + * + * See SP800-56Br1 + * 6.3.1.1 rsakpg1 - basic (Steps 3-4) + * 6.3.1.3 rsakpg1 - crt (Step 5) + * + * Params: + * rsa An rsa object. + * nbits The key size. + * e The public exponent. + * ctx A BN_CTX object. + * Notes: + * There is a small chance that the generated d will be too small. + * Returns: -1 = error, + * 0 = d is too small, + * 1 = success. + */ +int rsa_sp800_56b_derive_params_from_pq(RSA *rsa, int nbits, + const BIGNUM *e, BN_CTX *ctx) +{ + int ret = -1; + BIGNUM *p1, *q1, *lcm, *p1q1, *gcd; + + BN_CTX_start(ctx); + p1 = BN_CTX_get(ctx); + q1 = BN_CTX_get(ctx); + lcm = BN_CTX_get(ctx); + p1q1 = BN_CTX_get(ctx); + gcd = BN_CTX_get(ctx); + if (gcd == NULL) + goto err; + + /* LCM((p-1, q-1)) */ + if (rsa_get_lcm(ctx, rsa->p, rsa->q, lcm, gcd, p1, q1, p1q1) != 1) + goto err; + + /* copy e */ + BN_free(rsa->e); + rsa->e = BN_dup(e); + if (rsa->e == NULL) + goto err; + + BN_clear_free(rsa->d); + /* (Step 3) d = (e^-1) mod (LCM(p-1, q-1)) */ + rsa->d = BN_secure_new(); + if (rsa->d == NULL || BN_mod_inverse(rsa->d, e, lcm, ctx) == NULL) + goto err; + + /* (Step 3) return an error if d is too small */ + if (BN_num_bits(rsa->d) <= (nbits >> 1)) { + ret = 0; + goto err; + } + + /* (Step 4) n = pq */ + if (rsa->n == NULL) + rsa->n = BN_new(); + if (rsa->n == NULL || !BN_mul(rsa->n, rsa->p, rsa->q, ctx)) + goto err; + + /* (Step 5a) dP = d mod (p-1) */ + if (rsa->dmp1 == NULL) + rsa->dmp1 = BN_new(); + if (rsa->dmp1 == NULL || !BN_mod(rsa->dmp1, rsa->d, p1, ctx)) + goto err; + + /* (Step 5b) dQ = d mod (q-1) */ + if (rsa->dmq1 == NULL) + rsa->dmq1 = BN_secure_new(); + if (rsa->dmq1 == NULL || !BN_mod(rsa->dmq1, rsa->d, q1, ctx)) + goto err; + + /* (Step 5c) qInv = (inverse of q) mod p */ + BN_free(rsa->iqmp); + rsa->iqmp = BN_secure_new(); + if (rsa->iqmp == NULL + || BN_mod_inverse(rsa->iqmp, rsa->q, rsa->p, ctx) == NULL) + goto err; + + ret = 1; +err: + if (ret != 1) { + BN_free(rsa->e); + rsa->e = NULL; + BN_free(rsa->d); + rsa->d = NULL; + BN_free(rsa->n); + rsa->n = NULL; + BN_free(rsa->iqmp); + rsa->iqmp = NULL; + BN_free(rsa->dmq1); + rsa->dmq1 = NULL; + BN_free(rsa->dmp1); + rsa->dmp1 = NULL; + } + BN_clear(p1); + BN_clear(q1); + BN_clear(lcm); + BN_clear(p1q1); + BN_clear(gcd); + + BN_CTX_end(ctx); + return ret; +} + +/* + * Generate a SP800-56B RSA key. + * + * See SP800-56Br1 6.3.1 "RSA Key-Pair Generation with a Fixed Public Exponent" + * 6.3.1.1 rsakpg1 - basic + * 6.3.1.3 rsakpg1 - crt + * + * See also FIPS 186-4 Section B.3.6 + * "Generation of Probable Primes with Conditions Based on Auxiliary + * Probable Primes." + * + * Params: + * rsa The rsa object. + * nbits The intended key size in bits. + * efixed The public exponent. If NULL a default of 65537 is used. + * cb An optional BIGNUM callback. + * Returns: 1 if successfully generated otherwise it returns 0. + */ +int rsa_sp800_56b_generate_key(RSA *rsa, int nbits, const BIGNUM *efixed, + BN_GENCB *cb) +{ + int ret = 0; + int ok; + BN_CTX *ctx = NULL; + BIGNUM *e = NULL; + + /* (Steps 1a-1b) : Currently ignores the strength check */ + if (!rsa_sp800_56b_validate_strength(nbits, -1)) + return 0; + + ctx = BN_CTX_new(); + if (ctx == NULL) + return 0; + + /* Set default if e is not passed in */ + if (efixed == NULL) { + e = BN_new(); + if (e == NULL || !BN_set_word(e, 65537)) + goto err; + } else { + e = (BIGNUM *)efixed; + } + /* (Step 1c) fixed exponent is checked later . */ + + for (;;) { + /* (Step 2) Generate prime factors */ + if (!rsa_fips186_4_gen_prob_primes(rsa, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, nbits, e, ctx, cb)) + goto err; + /* (Steps 3-5) Compute params d, n, dP, dQ, qInv */ + ok = rsa_sp800_56b_derive_params_from_pq(rsa, nbits, e, ctx); + if (ok < 0) + goto err; + if (ok > 0) + break; + /* Gets here if computed d is too small - so try again */ + } + + /* (Step 6) Do pairwise test - optional validity test has been omitted */ + ret = rsa_sp800_56b_pairwise_test(rsa, ctx); +err: + if (efixed == NULL) + BN_free(e); + BN_CTX_free(ctx); + return ret; +} + +/* + * See SP800-56Br1 6.3.1.3 (Step 6) Perform a pair-wise consistency test by + * verifying that: k = (k^e)^d mod n for some integer k where 1 < k < n-1. + * + * Returns 1 if the RSA key passes the pairwise test or 0 it it fails. + */ +int rsa_sp800_56b_pairwise_test(RSA *rsa, BN_CTX *ctx) +{ + int ret = 0; + BIGNUM *k, *tmp; + + BN_CTX_start(ctx); + tmp = BN_CTX_get(ctx); + k = BN_CTX_get(ctx); + if (k == NULL) + goto err; + + ret = (BN_set_word(k, 2) + && BN_mod_exp(tmp, k, rsa->e, rsa->n, ctx) + && BN_mod_exp(tmp, tmp, rsa->d, rsa->n, ctx) + && BN_cmp(k, tmp) == 0); + if (ret == 0) + RSAerr(RSA_F_RSA_SP800_56B_PAIRWISE_TEST, RSA_R_PAIRWISE_TEST_FAILURE); +err: + BN_CTX_end(ctx); + return ret; +} diff --git a/crypto/rsa/rsa_ssl.c b/crypto/rsa/rsa_ssl.c index 563c8ba5..3659d838 100644 --- a/crypto/rsa/rsa_ssl.c +++ b/crypto/rsa/rsa_ssl.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 @@ -55,7 +55,7 @@ int RSA_padding_add_SSLv23(unsigned char *to, int tlen, /* * Copy of RSA_padding_check_PKCS1_type_2 with a twist that rejects padding - * if nul delimiter is preceded by 8 consecutive 0x03 bytes. It also + * if nul delimiter is not preceded by 8 consecutive 0x03 bytes. It also * preserves error code reporting for backward compatibility. */ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, @@ -67,7 +67,10 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, unsigned int good, found_zero_byte, mask, threes_in_row; int zero_index = 0, msg_index, mlen = -1, err; - if (flen < 10) { + if (tlen <= 0 || flen <= 0) + return -1; + + if (flen > num || num < 11) { RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_DATA_TOO_SMALL); return -1; } @@ -89,10 +92,9 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, from -= 1 & mask; *--em = *from & mask; } - from = em; - good = constant_time_is_zero(from[0]); - good &= constant_time_eq(from[1], 2); + good = constant_time_is_zero(em[0]); + good &= constant_time_eq(em[1], 2); err = constant_time_select_int(good, 0, RSA_R_BLOCK_TYPE_IS_NOT_02); mask = ~good; @@ -100,18 +102,18 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, found_zero_byte = 0; threes_in_row = 0; for (i = 2; i < num; i++) { - unsigned int equals0 = constant_time_is_zero(from[i]); + unsigned int equals0 = constant_time_is_zero(em[i]); zero_index = constant_time_select_int(~found_zero_byte & equals0, i, zero_index); found_zero_byte |= equals0; threes_in_row += 1 & ~found_zero_byte; - threes_in_row &= found_zero_byte | constant_time_eq(from[i], 3); + threes_in_row &= found_zero_byte | constant_time_eq(em[i], 3); } /* - * PS must be at least 8 bytes long, and it starts two bytes into |from|. + * PS must be at least 8 bytes long, and it starts two bytes into |em|. * If we never found a 0-byte, then |zero_index| is 0 and the check * also fails. */ @@ -120,7 +122,7 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, RSA_R_NULL_BEFORE_BLOCK_MISSING); mask = ~good; - good &= constant_time_lt(threes_in_row, 8); + good &= constant_time_ge(threes_in_row, 8); err = constant_time_select_int(mask | good, err, RSA_R_SSLV3_ROLLBACK_ATTACK); mask = ~good; @@ -148,15 +150,16 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, * should be noted that failure is indistinguishable from normal * operation if |tlen| is fixed by protocol. */ - tlen = constant_time_select_int(constant_time_lt(num, tlen), num, tlen); + tlen = constant_time_select_int(constant_time_lt(num - 11, tlen), + num - 11, tlen); msg_index = constant_time_select_int(good, msg_index, num - tlen); mlen = num - msg_index; - for (from += msg_index, mask = good, i = 0; i < tlen; i++) { - unsigned int equals = constant_time_eq(i, mlen); + for (mask = good, i = 0; i < tlen; i++) { + unsigned int equals = constant_time_eq(msg_index, num); - from -= tlen & equals; /* if (i == mlen) rewind */ - mask &= mask ^ equals; /* if (i == mlen) mask = 0 */ - to[i] = constant_time_select_8(mask, from[i], to[i]); + msg_index -= tlen & equals; /* rewind at EOF */ + mask &= ~equals; /* mask = 0 at EOF */ + to[i] = constant_time_select_8(mask, em[msg_index++], to[i]); } OPENSSL_clear_free(em, num); diff --git a/crypto/sha/asm/keccak1600-ppc64.pl b/crypto/sha/asm/keccak1600-ppc64.pl index 5c23841d..876632b1 100755 --- a/crypto/sha/asm/keccak1600-ppc64.pl +++ b/crypto/sha/asm/keccak1600-ppc64.pl @@ -27,10 +27,10 @@ # # r=1088(*) # -# PPC970/G5 14.6/+120% -# POWER7 10.3/+100% -# POWER8 11.5/+85% -# POWER9 9.4/+45% +# PPC970/G5 14.0/+130% +# POWER7 9.7/+110% +# POWER8 10.6/+100% +# POWER9 8.2/+66% # # (*) Corresponds to SHA3-256. Percentage after slash is improvement # over gcc-4.x-generated KECCAK_1X_ALT code. Newer compilers do @@ -384,19 +384,19 @@ KeccakF1600: .type dword_le_load,\@function .align 5 dword_le_load: - lbzu r0,1(r3) - lbzu r4,1(r3) - lbzu r5,1(r3) + lbz r0,1(r3) + lbz r4,2(r3) + lbz r5,3(r3) insrdi r0,r4,8,48 - lbzu r4,1(r3) + lbz r4,4(r3) insrdi r0,r5,8,40 - lbzu r5,1(r3) + lbz r5,5(r3) insrdi r0,r4,8,32 - lbzu r4,1(r3) + lbz r4,6(r3) insrdi r0,r5,8,24 - lbzu r5,1(r3) + lbz r5,7(r3) insrdi r0,r4,8,16 - lbzu r4,1(r3) + lbzu r4,8(r3) insrdi r0,r5,8,8 insrdi r0,r4,8,0 blr @@ -657,21 +657,21 @@ SHA3_squeeze: ${UCMP}i $len,8 blt .Lsqueeze_tail - stbu r0,1($out) + stb r0,1($out) srdi r0,r0,8 - stbu r0,1($out) + stb r0,2($out) srdi r0,r0,8 - stbu r0,1($out) + stb r0,3($out) srdi r0,r0,8 - stbu r0,1($out) + stb r0,4($out) srdi r0,r0,8 - stbu r0,1($out) + stb r0,5($out) srdi r0,r0,8 - stbu r0,1($out) + stb r0,6($out) srdi r0,r0,8 - stbu r0,1($out) + stb r0,7($out) srdi r0,r0,8 - stbu r0,1($out) + stbu r0,8($out) subic. $len,$len,8 beq .Lsqueeze_done diff --git a/crypto/sha/keccak1600.c b/crypto/sha/keccak1600.c index 7aa07552..ff53a260 100644 --- a/crypto/sha/keccak1600.c +++ b/crypto/sha/keccak1600.c @@ -85,30 +85,30 @@ static const unsigned char rhotates[5][5] = { }; static const uint64_t iotas[] = { - BIT_INTERLEAVE ? 0x0000000000000001U : 0x0000000000000001U, - BIT_INTERLEAVE ? 0x0000008900000000U : 0x0000000000008082U, - BIT_INTERLEAVE ? 0x8000008b00000000U : 0x800000000000808aU, - BIT_INTERLEAVE ? 0x8000808000000000U : 0x8000000080008000U, - BIT_INTERLEAVE ? 0x0000008b00000001U : 0x000000000000808bU, - BIT_INTERLEAVE ? 0x0000800000000001U : 0x0000000080000001U, - BIT_INTERLEAVE ? 0x8000808800000001U : 0x8000000080008081U, - BIT_INTERLEAVE ? 0x8000008200000001U : 0x8000000000008009U, - BIT_INTERLEAVE ? 0x0000000b00000000U : 0x000000000000008aU, - BIT_INTERLEAVE ? 0x0000000a00000000U : 0x0000000000000088U, - BIT_INTERLEAVE ? 0x0000808200000001U : 0x0000000080008009U, - BIT_INTERLEAVE ? 0x0000800300000000U : 0x000000008000000aU, - BIT_INTERLEAVE ? 0x0000808b00000001U : 0x000000008000808bU, - BIT_INTERLEAVE ? 0x8000000b00000001U : 0x800000000000008bU, - BIT_INTERLEAVE ? 0x8000008a00000001U : 0x8000000000008089U, - BIT_INTERLEAVE ? 0x8000008100000001U : 0x8000000000008003U, - BIT_INTERLEAVE ? 0x8000008100000000U : 0x8000000000008002U, - BIT_INTERLEAVE ? 0x8000000800000000U : 0x8000000000000080U, - BIT_INTERLEAVE ? 0x0000008300000000U : 0x000000000000800aU, - BIT_INTERLEAVE ? 0x8000800300000000U : 0x800000008000000aU, - BIT_INTERLEAVE ? 0x8000808800000001U : 0x8000000080008081U, - BIT_INTERLEAVE ? 0x8000008800000000U : 0x8000000000008080U, - BIT_INTERLEAVE ? 0x0000800000000001U : 0x0000000080000001U, - BIT_INTERLEAVE ? 0x8000808200000000U : 0x8000000080008008U + BIT_INTERLEAVE ? 0x0000000000000001ULL : 0x0000000000000001ULL, + BIT_INTERLEAVE ? 0x0000008900000000ULL : 0x0000000000008082ULL, + BIT_INTERLEAVE ? 0x8000008b00000000ULL : 0x800000000000808aULL, + BIT_INTERLEAVE ? 0x8000808000000000ULL : 0x8000000080008000ULL, + BIT_INTERLEAVE ? 0x0000008b00000001ULL : 0x000000000000808bULL, + BIT_INTERLEAVE ? 0x0000800000000001ULL : 0x0000000080000001ULL, + BIT_INTERLEAVE ? 0x8000808800000001ULL : 0x8000000080008081ULL, + BIT_INTERLEAVE ? 0x8000008200000001ULL : 0x8000000000008009ULL, + BIT_INTERLEAVE ? 0x0000000b00000000ULL : 0x000000000000008aULL, + BIT_INTERLEAVE ? 0x0000000a00000000ULL : 0x0000000000000088ULL, + BIT_INTERLEAVE ? 0x0000808200000001ULL : 0x0000000080008009ULL, + BIT_INTERLEAVE ? 0x0000800300000000ULL : 0x000000008000000aULL, + BIT_INTERLEAVE ? 0x0000808b00000001ULL : 0x000000008000808bULL, + BIT_INTERLEAVE ? 0x8000000b00000001ULL : 0x800000000000008bULL, + BIT_INTERLEAVE ? 0x8000008a00000001ULL : 0x8000000000008089ULL, + BIT_INTERLEAVE ? 0x8000008100000001ULL : 0x8000000000008003ULL, + BIT_INTERLEAVE ? 0x8000008100000000ULL : 0x8000000000008002ULL, + BIT_INTERLEAVE ? 0x8000000800000000ULL : 0x8000000000000080ULL, + BIT_INTERLEAVE ? 0x0000008300000000ULL : 0x000000000000800aULL, + BIT_INTERLEAVE ? 0x8000800300000000ULL : 0x800000008000000aULL, + BIT_INTERLEAVE ? 0x8000808800000001ULL : 0x8000000080008081ULL, + BIT_INTERLEAVE ? 0x8000008800000000ULL : 0x8000000000008080ULL, + BIT_INTERLEAVE ? 0x0000800000000001ULL : 0x0000000080000001ULL, + BIT_INTERLEAVE ? 0x8000808200000000ULL : 0x8000000080008008ULL }; #if defined(KECCAK_REF) diff --git a/crypto/sm2/sm2_pmeth.c b/crypto/sm2/sm2_pmeth.c index fecdc28f..8c81ca37 100644 --- a/crypto/sm2/sm2_pmeth.c +++ b/crypto/sm2/sm2_pmeth.c @@ -220,6 +220,10 @@ static int pkey_sm2_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) *(size_t *)p2 = smctx->id_len; return 1; + case EVP_PKEY_CTRL_DIGESTINIT: + /* nothing to be inited, this is to suppress the error... */ + return 1; + default: return -2; } diff --git a/crypto/trace.c b/crypto/trace.c index 8ead944b..613664c3 100644 --- a/crypto/trace.c +++ b/crypto/trace.c @@ -65,7 +65,7 @@ static int trace_write(BIO *channel, const char *buf, size_t num, size_t *written) { struct trace_data_st *ctx = BIO_get_data(channel); - size_t cnt = ctx->callback(buf, num, ctx->category, OSSL_TRACE_CTRL_DURING, + size_t cnt = ctx->callback(buf, num, ctx->category, OSSL_TRACE_CTRL_WRITE, ctx->data); *written = cnt; @@ -158,7 +158,7 @@ int OSSL_trace_get_category_num(const char *name) /* We use one trace channel for each trace category */ static struct { - enum { t_channel, t_callback } type; + enum { SIMPLE_CHANNEL, CALLBACK_CHANNEL } type; BIO *bio; char *prefix; char *suffix; @@ -169,18 +169,25 @@ static struct { #endif #ifndef OPENSSL_NO_TRACE + +enum { + CHANNEL, + PREFIX, + SUFFIX +}; + static int trace_attach_cb(int category, int type, const void *data) { switch (type) { - case 0: /* Channel */ + case CHANNEL: OSSL_TRACE2(TRACE, "Attach channel %p to category '%s'\n", data, trace_categories[category].name); break; - case 1: /* Prefix */ + case PREFIX: OSSL_TRACE2(TRACE, "Attach prefix \"%s\" to category '%s'\n", (const char *)data, trace_categories[category].name); break; - case 2: /* Suffix */ + case SUFFIX: OSSL_TRACE2(TRACE, "Attach suffix \"%s\" to category '%s'\n", (const char *)data, trace_categories[category].name); break; @@ -193,15 +200,15 @@ static int trace_attach_cb(int category, int type, const void *data) static int trace_detach_cb(int category, int type, const void *data) { switch (type) { - case 0: /* Channel */ + case CHANNEL: OSSL_TRACE2(TRACE, "Detach channel %p from category '%s'\n", data, trace_categories[category].name); break; - case 1: /* Prefix */ + case PREFIX: OSSL_TRACE2(TRACE, "Detach prefix \"%s\" from category '%s'\n", (const char *)data, trace_categories[category].name); break; - case 2: /* Suffix */ + case SUFFIX: OSSL_TRACE2(TRACE, "Detach suffix \"%s\" from category '%s'\n", (const char *)data, trace_categories[category].name); break; @@ -211,7 +218,7 @@ static int trace_detach_cb(int category, int type, const void *data) return 1; } -static int set_trace_data(int category, BIO **channel, +static int set_trace_data(int category, int type, BIO **channel, const char **prefix, const char **suffix, int (*attach_cb)(int, int, const void *), int (*detach_cb)(int, int, const void *)) @@ -222,15 +229,15 @@ static int set_trace_data(int category, BIO **channel, /* Make sure to run the detach callback first on all data */ if (prefix != NULL && curr_prefix != NULL) { - detach_cb(category, 1, curr_prefix); + detach_cb(category, PREFIX, curr_prefix); } if (suffix != NULL && curr_suffix != NULL) { - detach_cb(category, 2, curr_suffix); + detach_cb(category, SUFFIX, curr_suffix); } if (channel != NULL && curr_channel != NULL) { - detach_cb(category, 0, curr_channel); + detach_cb(category, CHANNEL, curr_channel); } /* After detach callbacks are done, clear data where appropriate */ @@ -246,11 +253,13 @@ static int set_trace_data(int category, BIO **channel, if (channel != NULL && curr_channel != NULL) { BIO_free(curr_channel); + trace_channels[category].type = 0; trace_channels[category].bio = NULL; } /* Before running callbacks are done, set new data where appropriate */ if (channel != NULL && *channel != NULL) { + trace_channels[category].type = type; trace_channels[category].bio = *channel; } @@ -268,15 +277,15 @@ static int set_trace_data(int category, BIO **channel, /* Finally, run the attach callback on the new data */ if (channel != NULL && *channel != NULL) { - attach_cb(category, 0, *channel); + attach_cb(category, CHANNEL, *channel); } if (prefix != NULL && *prefix != NULL) { - attach_cb(category, 1, *prefix); + attach_cb(category, PREFIX, *prefix); } if (suffix != NULL && *suffix != NULL) { - attach_cb(category, 2, *suffix); + attach_cb(category, SUFFIX, *suffix); } return 1; @@ -287,11 +296,11 @@ int ossl_trace_init(void) { #ifndef OPENSSL_NO_TRACE trace_lock = CRYPTO_THREAD_lock_new(); - if (trace_lock != NULL) - return 1; + if (trace_lock == NULL) + return 0; #endif - return 0; + return 1; } void ossl_trace_cleanup(void) @@ -306,10 +315,11 @@ void ossl_trace_cleanup(void) /* We force the TRACE category to be treated last */ if (category == OSSL_TRACE_CATEGORY_TRACE) continue; - set_trace_data(category, &channel, &prefix, &suffix, + set_trace_data(category, 0, &channel, &prefix, &suffix, trace_attach_cb, trace_detach_cb); } - set_trace_data(OSSL_TRACE_CATEGORY_TRACE, &channel, &prefix, &suffix, + set_trace_data(OSSL_TRACE_CATEGORY_TRACE, 0, &channel, + &prefix, &suffix, trace_attach_cb, trace_detach_cb); CRYPTO_THREAD_lock_free(trace_lock); #endif @@ -319,33 +329,27 @@ int OSSL_trace_set_channel(int category, BIO *channel) { #ifndef OPENSSL_NO_TRACE if (category < 0 || category >= OSSL_TRACE_CATEGORY_NUM - || !set_trace_data(category, &channel, NULL, NULL, + || !set_trace_data(category, SIMPLE_CHANNEL, &channel, NULL, NULL, trace_attach_cb, trace_detach_cb)) - goto err; - - trace_channels[category].type = t_channel; - return 1; - - err: + return 0; #endif - - return 0; + return 1; } #ifndef OPENSSL_NO_TRACE static int trace_attach_w_callback_cb(int category, int type, const void *data) { switch (type) { - case 0: /* Channel */ + case CHANNEL: OSSL_TRACE2(TRACE, "Attach channel %p to category '%s' (with callback)\n", data, trace_categories[category].name); break; - case 1: /* Prefix */ + case PREFIX: OSSL_TRACE2(TRACE, "Attach prefix \"%s\" to category '%s'\n", (const char *)data, trace_categories[category].name); break; - case 2: /* Suffix */ + case SUFFIX: OSSL_TRACE2(TRACE, "Attach suffix \"%s\" to category '%s'\n", (const char *)data, trace_categories[category].name); break; @@ -378,41 +382,45 @@ int OSSL_trace_set_callback(int category, OSSL_trace_cb callback, void *data) BIO_set_data(channel, trace_data); } - if (!set_trace_data(category, &channel, NULL, NULL, + if (!set_trace_data(category, CALLBACK_CHANNEL, &channel, NULL, NULL, trace_attach_w_callback_cb, trace_detach_cb)) goto err; - trace_channels[category].type = t_callback; - return 1; + goto done; err: BIO_free(channel); OPENSSL_free(trace_data); -#endif - return 0; + done: +#endif + return 1; } int OSSL_trace_set_prefix(int category, const char *prefix) { + int rv = 1; + #ifndef OPENSSL_NO_TRACE if (category >= 0 || category < OSSL_TRACE_CATEGORY_NUM) - return set_trace_data(category, NULL, &prefix, NULL, + return set_trace_data(category, 0, NULL, &prefix, NULL, trace_attach_cb, trace_detach_cb); + rv = 0; #endif - - return 0; + return rv; } int OSSL_trace_set_suffix(int category, const char *suffix) { + int rv = 1; + #ifndef OPENSSL_NO_TRACE if (category >= 0 || category < OSSL_TRACE_CATEGORY_NUM) - return set_trace_data(category, NULL, NULL, &suffix, + return set_trace_data(category, 0, NULL, NULL, &suffix, trace_attach_cb, trace_detach_cb); + rv = 0; #endif - - return 0; + return rv; } #ifndef OPENSSL_NO_TRACE @@ -450,13 +458,13 @@ BIO *OSSL_trace_begin(int category) CRYPTO_THREAD_write_lock(trace_lock); current_channel = channel; switch (trace_channels[category].type) { - case t_channel: + case SIMPLE_CHANNEL: if (prefix != NULL) { (void)BIO_puts(channel, prefix); (void)BIO_puts(channel, "\n"); } break; - case t_callback: + case CALLBACK_CHANNEL: (void)BIO_ctrl(channel, OSSL_TRACE_CTRL_BEGIN, prefix == NULL ? 0 : strlen(prefix), prefix); break; @@ -477,13 +485,13 @@ void OSSL_trace_end(int category, BIO * channel) && ossl_assert(channel == current_channel)) { (void)BIO_flush(channel); switch (trace_channels[category].type) { - case t_channel: + case SIMPLE_CHANNEL: if (suffix != NULL) { (void)BIO_puts(channel, suffix); (void)BIO_puts(channel, "\n"); } break; - case t_callback: + case CALLBACK_CHANNEL: (void)BIO_ctrl(channel, OSSL_TRACE_CTRL_END, suffix == NULL ? 0 : strlen(suffix), suffix); break; diff --git a/crypto/x509/x509_err.c b/crypto/x509/x509_err.c index 1c753f51..fbd2cf8e 100644 --- a/crypto/x509/x509_err.c +++ b/crypto/x509/x509_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 @@ -104,9 +104,11 @@ static const ERR_STRING_DATA X509_str_functs[] = { {ERR_PACK(ERR_LIB_X509, X509_F_X509_TO_X509_REQ, 0), "X509_to_X509_REQ"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_TRUST_ADD, 0), "X509_TRUST_add"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_TRUST_SET, 0), "X509_TRUST_set"}, + {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY, 0), "X509_verify"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_CERT, 0), "X509_verify_cert"}, {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_PARAM_NEW, 0), "X509_VERIFY_PARAM_new"}, + {ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_SM2, 0), "x509_verify_sm2"}, {0, NULL} }; diff --git a/crypto/x509/x_all.c b/crypto/x509/x_all.c index dca138c3..afcf0b7b 100644 --- a/crypto/x509/x_all.c +++ b/crypto/x509/x_all.c @@ -19,10 +19,120 @@ #include #include +#ifndef OPENSSL_NO_SM2 + +# include "internal/asn1_int.h" +# include "internal/evp_int.h" + +static int x509_verify_sm2(X509 *x, EVP_PKEY *pkey, int mdnid, int pknid) +{ + 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); + + if (type == NULL) { + X509err(X509_F_X509_VERIFY_SM2, + ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM); + goto err; + } + + if (pkey == NULL) { + X509err(X509_F_X509_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); + return -1; + } + + ctx = EVP_MD_CTX_new(); + if (ctx == NULL) { + X509err(X509_F_X509_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); + goto err; + } + + if (!EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2)) { + X509err(X509_F_X509_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); + ret = 0; + goto err; + } + if (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); + 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); + ret = 0; + goto err; + } + + inl = ASN1_item_i2d((ASN1_VALUE *)&x->cert_info, &buf_in, + ASN1_ITEM_rptr(X509_CINF)); + if (inl <= 0) { + X509err(X509_F_X509_VERIFY_SM2, ERR_R_INTERNAL_ERROR); + goto err; + } + if (buf_in == NULL) { + X509err(X509_F_X509_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); + if (ret <= 0) { + X509err(X509_F_X509_VERIFY_SM2, ERR_R_EVP_LIB); + goto err; + } + ret = 1; + err: + OPENSSL_clear_free(buf_in, inll); + EVP_MD_CTX_free(ctx); + EVP_PKEY_CTX_free(pctx); + return ret; +} +#endif + int X509_verify(X509 *a, EVP_PKEY *r) { +#ifndef OPENSSL_NO_SM2 + int mdnid, pknid; +#endif + if (X509_ALGOR_cmp(&a->sig_alg, &a->cert_info.signature)) return 0; + +#ifndef OPENSSL_NO_SM2 + /* 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_VERIFY, ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); + return 0; + } + + if (pknid == NID_sm2) + return x509_verify_sm2(a, r, mdnid, pknid); +#endif + return (ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF), &a->sig_alg, &a->signature, &a->cert_info, r)); } diff --git a/crypto/x509/x_x509.c b/crypto/x509/x_x509.c index 54d015b2..901a3e6a 100644 --- a/crypto/x509/x_x509.c +++ b/crypto/x509/x_x509.c @@ -244,3 +244,15 @@ int X509_get_signature_nid(const X509 *x) { return OBJ_obj2nid(x->sig_alg.algorithm); } + +#ifndef OPENSSL_NO_SM2 +void X509_set_sm2_id(X509 *x, ASN1_OCTET_STRING *sm2_id) +{ + x->sm2_id = *sm2_id; +} + +ASN1_OCTET_STRING *X509_get0_sm2_id(X509 *x) +{ + return &x->sm2_id; +} +#endif diff --git a/demos/pkcs12/pkread.c b/demos/pkcs12/pkread.c index 992b42c0..33fba5d2 100644 --- a/demos/pkcs12/pkread.c +++ b/demos/pkcs12/pkread.c @@ -17,7 +17,7 @@ static char *find_friendly_name(PKCS12 *p12) { - STACK_OF(PKCS7) *safes = PKCS12_unpack_authsafes(p12); + STACK_OF(PKCS7) *safes; int n, m; char *name = NULL; PKCS7 *safe; @@ -48,56 +48,64 @@ static char *find_friendly_name(PKCS12 *p12) int main(int argc, char **argv) { FILE *fp; - EVP_PKEY *pkey; - X509 *cert; + EVP_PKEY *pkey = NULL; + X509 *cert = NULL; STACK_OF(X509) *ca = NULL; - PKCS12 *p12; - const char *name; - int i; + PKCS12 *p12 = NULL; + char *name = NULL; + int i, ret = EXIT_FAILURE; if (argc != 4) { fprintf(stderr, "Usage: pkread p12file password opfile\n"); - exit(1); + exit(EXIT_FAILURE); } - OpenSSL_add_all_algorithms(); - ERR_load_crypto_strings(); + if ((fp = fopen(argv[1], "rb")) == NULL) { fprintf(stderr, "Error opening file %s\n", argv[1]); - exit(1); + exit(EXIT_FAILURE); } p12 = d2i_PKCS12_fp(fp, NULL); fclose(fp); - if (!p12) { + if (p12 == NULL) { fprintf(stderr, "Error reading PKCS#12 file\n"); ERR_print_errors_fp(stderr); - exit(1); + goto err; } if (!PKCS12_parse(p12, argv[2], &pkey, &cert, &ca)) { fprintf(stderr, "Error parsing PKCS#12 file\n"); ERR_print_errors_fp(stderr); - exit(1); + goto err; } name = find_friendly_name(p12); PKCS12_free(p12); if ((fp = fopen(argv[3], "w")) == NULL) { fprintf(stderr, "Error opening file %s\n", argv[1]); - exit(1); + goto err; } - if (name) + if (name != NULL) fprintf(fp, "***Friendly Name***\n%s\n", name); - if (pkey) { + if (pkey != NULL) { fprintf(fp, "***Private Key***\n"); PEM_write_PrivateKey(fp, pkey, NULL, NULL, 0, NULL, NULL); } - if (cert) { + if (cert != NULL) { fprintf(fp, "***User Certificate***\n"); PEM_write_X509_AUX(fp, cert); } - if (ca && sk_X509_num(ca)) { + if (ca != NULL && sk_X509_num(ca) > 0) { fprintf(fp, "***Other Certificates***\n"); for (i = 0; i < sk_X509_num(ca); i++) PEM_write_X509_AUX(fp, sk_X509_value(ca, i)); } fclose(fp); - return 0; + + ret = EXIT_SUCCESS; + + err: + OPENSSL_free(name); + X509_free(cert); + EVP_PKEY_free(pkey); + sk_X509_pop_free(ca, X509_free); + + return ret; } diff --git a/doc/internal/man3/ossl_method_construct.pod b/doc/internal/man3/ossl_method_construct.pod new file mode 100644 index 00000000..e91cfcd6 --- /dev/null +++ b/doc/internal/man3/ossl_method_construct.pod @@ -0,0 +1,133 @@ +=pod + +=head1 NAME + +OSSL_METHOD_CONSTRUCT_METHOD, ossl_method_construct +- generic method constructor + +=head1 SYNOPSIS + + #include "internal/core.h" + + struct ossl_method_construct_method_st { + /* Create store */ + void *(*alloc_tmp_store)(void); + /* 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 *propquery, + void *data); + /* Store a method in a store */ + int (*put)(OPENSSL_CTX *libctx, void *store, const char *propdef, + void *method, void *data); + /* Construct a new method */ + void *(*construct)(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov, + void *data); + /* Destruct a method */ + void (*destruct)(void *method); + }; + typedef struct ossl_method_construct_method OSSL_METHOD_CONSTRUCT_METHOD; + + void *ossl_method_construct(OPENSSL_CTX *ctx, int operation_id, + const char *name, const char *properties, + int force_cache, + OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data); + +=head1 DESCRIPTION + +All libcrypto sub-systems that want to create their own methods based +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. + +=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 +functions given by the sub-system specific method creator through +C and the data in C (which is passed by +ossl_method_construct()). + +=head2 Structures + +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 +function pointers: + +=over 4 + +=item alloc_tmp_store() + +Create a temporary method store. +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. + +=item dealloc_tmp_store() + +Remove a temporary store. + +=item get() + +Look up an already existing method from a store. + +The store may be given with C. +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. + +The method to be looked up should be identified with data from C +(which is the C that was passed to ossl_construct_method()) +and the provided property query C. + +=item put() + +Places the C created by the construct() function (see below) +in a store. + +The store may be given with C. +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. + +The method should be associated with the given property definition +C and any identification data given through C (which is +the C that was passed to ossl_construct_method()). + +=item construct() + +Constructs a sub-system method given a dispatch table C. + +The associated I C 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(). + +=item desctruct() + +Destruct the given C. + +=back + +=head1 RETURN VALUES + +ossl_method_construct() returns a constructed method on success, or +B on error. + +=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/internal/man3/ossl_provider_new.pod b/doc/internal/man3/ossl_provider_new.pod new file mode 100644 index 00000000..7633e0e2 --- /dev/null +++ b/doc/internal/man3/ossl_provider_new.pod @@ -0,0 +1,215 @@ +=pod + +=head1 NAME + +ossl_provider_find, ossl_provider_new, ossl_provider_upref, +ossl_provider_free, ossl_provider_add_module_location, +ossl_provider_activate, 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, +ossl_provider_get_params, ossl_provider_query_operation +- internal provider routines + +=head1 SYNOPSIS + + #include "internal/provider.h" + + 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); + void ossl_provider_free(OSSL_PROVIDER *prov); + + /* Setters */ + int ossl_provider_add_module_location(OSSL_PROVIDER *prov, const char *loc); + + /* Load and initialize the Provider */ + int ossl_provider_activate(OSSL_PROVIDER *prov); + + /* Iterate over all loaded providers */ + int ossl_provider_forall_loaded(OPENSSL_CTX *, + int (*cb)(OSSL_PROVIDER *provider, + void *cbdata), + 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); + + /* 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[]); + 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 +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. + +A I is always stored in a set of Is +in the library context. + +Is are reference counted. + +Is 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 it's 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_free() decrements a I's reference +counter; if it drops to one, the I will be +inactivated (it's teardown function is called) but kept in the store; +if it drops down to zero, the associated module will be unloaded if +one was loaded, and the I will be freed. + +ossl_provider_add_module_location() adds a location to look for a +provider module. + +ossl_provider_activate() "activates" the provider for the given +I. +What "activates" means depends on what type of I it +is: + +=over 4 + +=item * + +If an initialization function was given with ossl_provider_new(), that +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 +be located in that module, and called. + +=back + +ossl_provider_forall_loaded() iterates over all the currently +"activated" providers, and calls C for each of them. + +ossl_provider_name() returns the name that was given with +ossl_provider_new(). + +ossl_provider_dso() returns a reference to the module, for providers +that come in the form of loadable modules. + +ossl_provider_module_name() returns the file name of the module, for +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 +the provider has one. + +ossl_provider_get_param_types() calls the provider's C +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. + +ossl_provider_get_params() calls the provider's parameter request +responder. +It should treat the given C 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. + +=head1 NOTES + +Locating a provider module happens as follows: + +=over 4 + +=item 1. + +Look in each directory given by ossl_provider_add_module_location(). + +=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. + +=back + +=head1 RETURN VALUES + +ossl_provider_find() and ossl_provider_new() return a pointer to a +I (C) on success, or B on error. + +ossl_provider_upref() returns the value of the reference counter after +it has been incremented. + +ossl_provider_free() doesn't return any value. + +ossl_provider_add_module_location() 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 +is returned. + +ossl_provider_teardown() doesnt't return any value. + +ossl_provider_get_param_types() returns a pointer to an C +array if this function is available in the provider, otherwise +B. + +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 + +=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/man1/list.pod b/doc/man1/list.pod index b1a147ba..901a2668 100644 --- a/doc/man1/list.pod +++ b/doc/man1/list.pod @@ -18,6 +18,7 @@ B [B<-cipher-algorithms>] [B<-public-key-algorithms>] [B<-public-key-methods>] +[B<-engines>] [B<-disabled>] =head1 DESCRIPTION @@ -80,6 +81,10 @@ a block of multiple lines, all but the first are indented. Display a list of public key method OIDs: this also includes public key methods without an associated ASN.1 method, for example, KDF algorithms. +=item B<-engines> + +Display a list of loaded engines. + =item B<-disabled> Display a list of disabled features, those that were compiled out diff --git a/doc/man1/mac.pod b/doc/man1/mac.pod new file mode 100644 index 00000000..5d1e7966 --- /dev/null +++ b/doc/man1/mac.pod @@ -0,0 +1,163 @@ +=pod + +=head1 NAME + +openssl-mac, +mac - perform Message Authentication Code operations + +=head1 SYNOPSIS + +B +[B<-help>] +[B<-macopt>] +[B<-in filename>] +[B<-out filename>] +[B<-binary>] +B + +B I [B<...>] B + +=head1 DESCRIPTION + +The message authentication code functions output the MAC of a supplied input +file. + +=head1 OPTIONS + +=over 4 + +=item B<-help> + +Print a usage message. + +=item B<-in filename> + +Input filename to calculate a MAC for, or standard input by default. +Standard input is used if the filename is '-'. +Files are expected to be in binary format, standard input uses hexadecimal text +format. + +=item B<-out filename> + +Filename to output to, or standard output by default. + +=item B<-binary> + +Output the MAC in binary form. Uses hexadecimal text format if not specified. + +=item B<-macopt nm:v> + +Passes options to the MAC algorithm. +A comprehensive list of controls can be found in the EVP_MAC implementation +documentation. +Common control strings used by EVP_MAC_ctrl_str() are: + +=over 4 + +=item B + +Specifies the MAC key as an alphanumeric string (use if the key contains +printable characters only). +The string length must conform to any restrictions of the MAC algorithm. +A key must be specified for every MAC algorithm. + +=item B + +Specifies the MAC key in hexadecimal form (two hex digits per byte). +The key length must conform to any restrictions of the MAC algorithm. +A key must be specified for every MAC algorithm. + +=item B + +Used by HMAC as an alphanumeric string (use if the key contains printable +characters only). +The string length must conform to any restrictions of the MAC algorithm. +To see the list of supported digests, use the command I. + +=item B + +Used by CMAC and GMAC to specifiy 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. + +=item B + +Used by GMAC to specify an IV as an alphanumeric string (use if the IV contains +printable characters only). + +=item B + +Used by GMAC to specify an IV in hexadecimal form (two hex digits per byte). + +=item B + +Used by KMAC128 or KMAC256 to specify an output length. +The default sizes are 32 or 64 bytes respectively. + +=item B + +Used by KMAC128 or KMAC256 to specify a customization string. +The default is the empty string "". + +=back + +=item B + +Specifies the name of a supported MAC algorithm which will be used. +To see the list of supported MAC's use the command I. + +=back + + +=head1 EXAMPLES + +To create a hex-encoded HMAC-SHA1 MAC of a file and write to stdout: \ + openssl mac -macopt digest:SHA1 \ + -macopt hexkey:000102030405060708090A0B0C0D0E0F10111213 \ + -in msg.bin HMAC + +To create a SipHash MAC from a file with a binary file output: \ + openssl mac -macopt hexkey:000102030405060708090A0B0C0D0E0F \ + -in msg.bin -out out.bin -binary SipHash + +To create a hex-encoded CMAC-AES-128-CBC MAC from a file:\ + openssl mac -macopt cipher:AES-128-CBC \ + -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B \ + -in msg.bin CMAC + +To create a hex-encoded KMAC128 MAC from a file with a Customisation String +'Tag' and output length of 16: \ + openssl mac -macopt custom:Tag -macopt hexkey:40414243444546 \ + -macopt outlen:16 -in msg.bin KMAC128 + +To create a hex-encoded GMAC-AES-128-GCM with a IV from a file: \ + openssl mac -macopt cipher:AES-128-GCM -macopt hexiv:E0E00F19FED7BA0136A797F3 \ + -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B -in msg.bin GMAC + +=head1 NOTES + +The MAC mechanisms that are available will depend on the options +used when building OpenSSL. +The B command can be used to list them. + +=head1 SEE ALSO + +L, +L, +L, +L, +L, +L, +L + +=head1 COPYRIGHT + +Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the OpenSSL license (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/openssl.pod b/doc/man1/openssl.pod index ca4f78c2..5f6f8d3b 100644 --- a/doc/man1/openssl.pod +++ b/doc/man1/openssl.pod @@ -11,7 +11,7 @@ I [ I ] [ I ] -B B [ B | B | B | B | B | B] +B B [ B | B | B | B | B | B | B] B BI [ I ] @@ -28,7 +28,7 @@ It can be used for o Creation and management of private keys, public keys and parameters o Public key cryptographic operations o Creation of X.509 certificates, CSRs and CRLs - o Calculation of Message Digests + o Calculation of Message Digests and Message Authentication Codes o Encryption and Decryption with Ciphers o SSL/TLS Client and Server Tests o Handling of S/MIME signed or encrypted mail @@ -57,8 +57,9 @@ and B output a list (one entry per line) of the names of all standard commands, message digest commands, or cipher commands, respectively, that are available in the present B utility. -The list parameters B and -B list all cipher and message digest names, one entry per line. Aliases are listed as: +The list parameters B, B, +and B list all cipher, message digest, and message +authentication code names, one entry per line. Aliases are listed as: from => to @@ -106,7 +107,8 @@ CRL to PKCS#7 Conversion. =item B -Message Digest Calculation. +Message Digest calculation. MAC calculations are superseded by +L. =item B @@ -165,6 +167,10 @@ Generation of Private Key or Parameters. Generation of RSA Private Key. Superseded by L. +=item B + +Message Authentication Code Calculation. + =item B Create or examine a Netscape certificate sequence. @@ -606,7 +612,7 @@ L, L, L, L, L, L, L, L, L, L, L, L, L, -L, L, L, +L, L, L, L, L, L, L, L, L, L, L, L, diff --git a/doc/man1/pkeyutl.pod b/doc/man1/pkeyutl.pod index c566f6d8..13af3277 100644 --- a/doc/man1/pkeyutl.pod +++ b/doc/man1/pkeyutl.pod @@ -62,7 +62,7 @@ if this option is not specified. This indicates that the input data is raw data, which is not hashed by any message digest algorithm. The user can specify a digest algorithm by using the B<-digest> option. This option can only be used with B<-sign> and -B<-verify>. +B<-verify> and must be used with the Ed25519 and Ed448 algorithms. =item B<-digest algorithm> @@ -216,21 +216,18 @@ hash the input data. It is used (by some algorithms) for sanity-checking the lengths of data passed in to the B and for creating the structures that make up the signature (e.g. B in RSASSA PKCS#1 v1.5 signatures). -This utility does not hash the input data but rather it will use the data -directly as input to the signature algorithm. Depending on the key type, -signature type, and mode of padding, the maximum acceptable lengths of input -data differ. The signed data can't be longer than the key modulus with RSA. In -case of ECDSA and DSA the data shouldn't be longer than the field -size, otherwise it will be silently truncated to the field size. In any event -the input size must not be larger than the largest supported digest size. +This utility does not hash the input data (except where -rawin is used) but +rather it will use the data directly as input to the signature algorithm. +Depending on the key type, signature type, and mode of padding, the maximum +acceptable lengths of input data differ. The signed data can't be longer than +the key modulus with RSA. In case of ECDSA and DSA the data shouldn't be longer +than the field size, otherwise it will be silently truncated to the field size. +In any event the input size must not be larger than the largest supported digest +size. In other words, if the value of digest is B the input should be the 20 bytes long binary encoding of the SHA-1 hash function output. -The Ed25519 and Ed448 signature algorithms are not supported by this utility. -They accept non-hashed input, but this utility can only be used to sign hashed -input. - =head1 RSA ALGORITHM The RSA algorithm generally supports the encrypt, decrypt, sign, @@ -319,6 +316,18 @@ this digest is assumed by default. The X25519 and X448 algorithms support key derivation only. Currently there are no additional options. +=head1 Ed25519 and Ed448 ALGORITHMS + +These algorithms only support signing and verifying. OpenSSL only implements the +"pure" variants of these algorithms so raw data can be passed directly to them +without hashing them first. The option "-rawin" must be used with these +algorithms with no "-digest" specified. Additionally OpenSSL only supports +"oneshot" operation with these algorithms. This means that the entire file to +be signed/verified must be read into memory before processing it. Signing or +Verifying very large files should be avoided. Additionally the size of the file +must be known for this to work. If the size of the file cannot be determined +(for example if the input is stdin) then the sign or verify operation will fail. + =head1 SM2 The SM2 algorithm supports sign, verify, encrypt and decrypt operations. For diff --git a/doc/man1/s_client.pod b/doc/man1/s_client.pod index c4a98435..e1a71d17 100644 --- a/doc/man1/s_client.pod +++ b/doc/man1/s_client.pod @@ -218,7 +218,7 @@ Even though SNI should normally be a DNS name and not an IP address, if B<-servername> is provided then that name will be sent, regardless of whether it is a DNS name or not. -This option cannot be used in conjuction with B<-noservername>. +This option cannot be used in conjunction with B<-noservername>. =item B<-noservername> diff --git a/doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod b/doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod new file mode 100644 index 00000000..fbce7027 --- /dev/null +++ b/doc/man3/OSSL_CRMF_MSG_get0_tmpl.pod @@ -0,0 +1,66 @@ +=pod + +=head1 NAME + +OSSL_CRMF_MSG_get0_tmpl, +OSSL_CRMF_CERTTEMPLATE_get0_serialNumber, +OSSL_CRMF_CERTTEMPLATE_get0_issuer, +OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert, +OSSL_CRMF_MSG_get_certReqId +- functions reading from CRMF CertReqMsg structures + +=head1 SYNOPSIS + + #include + + OSSL_CRMF_CERTTEMPLATE *OSSL_CRMF_MSG_get0_tmpl(const OSSL_CRMF_MSG *crm); + ASN1_INTEGER + *OSSL_CRMF_CERTTEMPLATE_get0_serialNumber(OSSL_CRMF_CERTTEMPLATE *tmpl); + X509_NAME *OSSL_CRMF_CERTTEMPLATE_get0_issuer(OSSL_CRMF_CERTTEMPLATE *tmpl); + + X509 *OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert(OSSL_CRMF_ENCRYPTEDVALUE *ecert, + EVP_PKEY *pkey); + + int OSSL_CRMF_MSG_get_certReqId(OSSL_CRMF_MSG *crm); + + +=head1 DESCRIPTION + +OSSL_CRMF_MSG_get0_tmpl() retrieves the certificate template of B. + +OSSL_CRMF_CERTTEMPLATE_get0_serialNumber() retrieves the serialNumber of the +given certificate template B. + +OSSL_CRMF_CERTTEMPLATE_get0_issuer() retrieves the issuer name of the +given certificate template B. + +OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert() decrypts the certificate in the given +encryptedValue B, using the private key B. +This is needed for the indirect PoP method as in RFC 4210 section 5.2.8.2. +The function returns the decrypted certificate as a copy, leaving its ownership +with the caller, who is responsible for freeing it. + +OSSL_CRMF_MSG_get_certReqId() retrieves the certReqId of B. + + +=head1 RETURN VALUES + +OSSL_CRMF_MSG_get_certReqId() returns the certificate request ID as a +non-negative integer or -1 on error. + +All other functions return a pointer with the intended result or NULL on error. + +=head1 SEE ALSO + +B + +=head1 COPYRIGHT + +Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the OpenSSL license (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_set1_regCtrl_regToken.pod b/doc/man3/OSSL_CRMF_MSG_set1_regCtrl_regToken.pod new file mode 100644 index 00000000..851bd130 --- /dev/null +++ b/doc/man3/OSSL_CRMF_MSG_set1_regCtrl_regToken.pod @@ -0,0 +1,106 @@ +=pod + +=head1 NAME + +OSSL_CRMF_MSG_set1_regCtrl_regToken, +OSSL_CRMF_MSG_set1_regCtrl_authenticator, +OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo, +OSSL_CRMF_MSG_set0_SinglePubInfo, +OSSL_CRMF_MSG_set_PKIPublicationInfo_action, +OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo, +OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey, +OSSL_CRMF_MSG_set1_regCtrl_oldCertID, +OSSL_CRMF_CERTID_gen +- functions setting CRMF Registration Controls + +=head1 SYNOPSIS + + #include + + int OSSL_CRMF_MSG_set1_regCtrl_regToken(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *tok); + int OSSL_CRMF_MSG_set1_regCtrl_authenticator(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *auth); + int OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo( + OSSL_CRMF_PKIPUBLICATIONINFO *pi, + OSSL_CRMF_SINGLEPUBINFO *spi); + int OSSL_CRMF_MSG_set0_SinglePubInfo(OSSL_CRMF_SINGLEPUBINFO *spi, + int method, GENERAL_NAME *nm); + int OSSL_CRMF_MSG_set_PKIPublicationInfo_action( + OSSL_CRMF_PKIPUBLICATIONINFO *pi, int action); + int OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_PKIPUBLICATIONINFO *pi); + int OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey(OSSL_CRMF_MSG *msg, + const X509_PUBKEY *pubkey); + int OSSL_CRMF_MSG_set1_regCtrl_oldCertID(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_CERTID *cid); + OSSL_CRMF_CERTID *OSSL_CRMF_CERTID_gen(const X509_NAME *issuer, + const ASN1_INTEGER *serial); + +=head1 DESCRIPTION + +OSSL_CRMF_MSG_set1_regCtrl_regToken() sets the regToken control in the given +B copying the given B as value. See RFC 4211, section 6.1. + +OSSL_CRMF_MSG_set1_regCtrl_authenticator() sets the authenticator control in +the given B copying the given B as value. See RFC 4211, section 6.2. + +OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo() pushes the given B +to B. Consumes the B pointer. + +OSSL_CRMF_MSG_set0_SinglePubInfo() sets in the given SinglePubInfo B +the B and publication location, in the form of a GeneralName, B. +The publication location is optional, and therefore B may be NULL. +The function consumes the B pointer if present. +Available methods are: + # define OSSL_CRMF_PUB_METHOD_DONTCARE 0 + # define OSSL_CRMF_PUB_METHOD_X500 1 + # define OSSL_CRMF_PUB_METHOD_WEB 2 + # define OSSL_CRMF_PUB_METHOD_LDAP 3 + +OSSL_CRMF_MSG_set_PKIPublicationInfo_action() sets the action in the given B +using the given B as value. See RFC 4211, section 6.3. +Available actions are: + # define OSSL_CRMF_PUB_ACTION_DONTPUBLISH 0 + # define OSSL_CRMF_PUB_ACTION_PLEASEPUBLISH 1 + +OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo() sets the pkiPublicationInfo +control in the given B copying the given B as value. See RFC 4211, +section 6.3. + +OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey() sets the protocolEncrKey control in +the given B copying the given B as value. See RFC 4211, section 6.6. + +OSSL_CRMF_MSG_set1_regCtrl_oldCertID() sets the oldCertID control in the given +B copying the given B as value. See RFC 4211, section 6.5. + +OSSL_CRMF_CERTID_gen produces an OSSL_CRMF_CERTID_gen structure copying the +given B name and B number. + +=head1 RETURN VALUES + +OSSL_CRMF_CERTID_gen returns a pointer to the resulting structure +or NULL on error. + +All other functions return 1 on success, 0 on error. + +=head1 NOTES + +A function OSSL_CRMF_MSG_set1_regCtrl_pkiArchiveOptions() for setting an +Archive Options Control is not yet implemented due to missing features to +create the needed OSSL_CRMF_PKIARCHIVEOPTINS content. + +=head1 SEE ALSO + +RFC 4211 + +=head1 COPYRIGHT + +Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the OpenSSL license (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_set1_regInfo_certReq.pod b/doc/man3/OSSL_CRMF_MSG_set1_regInfo_certReq.pod new file mode 100644 index 00000000..9e33a4a2 --- /dev/null +++ b/doc/man3/OSSL_CRMF_MSG_set1_regInfo_certReq.pod @@ -0,0 +1,49 @@ +=pod + +=head1 NAME + +OSSL_CRMF_MSG_set1_regInfo_utf8Pairs, +OSSL_CRMF_MSG_set1_regInfo_certReq +- functions setting CRMF Registration Info + +=head1 SYNOPSIS + + #include + + int OSSL_CRMF_MSG_set1_regInfo_utf8Pairs(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *utf8pairs); + int OSSL_CRMF_MSG_set1_regInfo_certReq(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_CERTREQUEST *cr); + +=head1 DESCRIPTION + +OSSL_CRMF_MSG_set1_regInfo_utf8Pairs() adds a copy of the given B +value as utf8Pairs regInfo to the given B. See RFC 4211 section 7.1. + +OSSL_CRMF_MSG_set1_regInfo_certReq() adds a copy of the given B value +as certReq regInfo to the given B. See RFC 4211 section 7.2. + +=head1 RETURN VALUES + +All functions return 1 on success, 0 on error. + +=head1 NOTES + +Calling these functions multiple times adds multiple instances of the respective +control to the regInfo structure of the given B. While RFC 4211 expects +multiple utf8Pairs in one regInfo structure, it does not allow multiple certReq. + +=head1 SEE ALSO + +RFC 4211 + +=head1 COPYRIGHT + +Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the OpenSSL license (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_set_validity.pod b/doc/man3/OSSL_CRMF_MSG_set_validity.pod new file mode 100644 index 00000000..b6ea32ea --- /dev/null +++ b/doc/man3/OSSL_CRMF_MSG_set_validity.pod @@ -0,0 +1,105 @@ +=pod + +=head1 NAME + +OSSL_CRMF_MSG_set_validity, +OSSL_CRMF_MSG_set_certReqId, +OSSL_CRMF_CERTTEMPLATE_fill, +OSSL_CRMF_MSG_set0_extensions, +OSSL_CRMF_MSG_push0_extension, +OSSL_CRMF_MSG_create_popo, +OSSL_CRMF_MSGS_verify_popo +- functions populating and verifying CRMF CertReqMsg structures + +=head1 SYNOPSIS + + #include + + int OSSL_CRMF_MSG_set_validity(OSSL_CRMF_MSG *crm, time_t from, time_t to); + + int OSSL_CRMF_MSG_set_certReqId(OSSL_CRMF_MSG *crm, int rid); + + int OSSL_CRMF_CERTTEMPLATE_fill(OSSL_CRMF_CERTTEMPLATE *tmpl, + EVP_PKEY *pubkey, + const X509_NAME *subject, + const X509_NAME *issuer, + const ASN1_INTEGER *serial); + + int OSSL_CRMF_MSG_set0_extensions(OSSL_CRMF_MSG *crm, + X509_EXTENSIONS *exts); + + int OSSL_CRMF_MSG_push0_extension(OSSL_CRMF_MSG *crm, + const X509_EXTENSION *ext); + + int OSSL_CRMF_MSG_create_popo(OSSL_CRMF_MSG *crm, EVP_PKEY *pkey, + int dgst, int ppmtd); + + int OSSL_CRMF_MSGS_verify_popo(const OSSL_CRMF_MSGS *reqs, + int rid, int acceptRAVerified); + +=head1 DESCRIPTION + +OSSL_CRMF_MSG_set_validity() sets B as notBefore and B as notAfter +as the validity in the certTemplate of B. + +OSSL_CRMF_MSG_set_certReqId() sets B as the certReqId of B. + +OSSL_CRMF_CERTTEMPLATE_fill() sets those fields of the certTemplate B +for which non-NULL values are provided: B, B, B, +and/or B. +On success the reference counter of the B (if given) is incremented, +while the B, B, and B structures (if given) are copied. + +OSSL_CRMF_MSG_set0_extensions() sets B as the extensions in the +certTemplate of B. Frees any pre-existing ones and consumes B. + +OSSL_CRMF_MSG_push0_extension() pushes the X509 extension B to the +extensions in the certTemplate of B. Consumes B. + +OSSL_CRMF_MSG_create_popo() creates and sets the Proof-of-Possession (POP) +according to the method B for B to B. In case the method is +OSSL_CRMF_POPO_SIGNATURE, POP is calculated using the B. + +B can be one of the following: + +=over 8 + +=item * OSSL_CRMF_POPO_NONE - RFC 4211, section 4, POP field omitted. +CA/RA uses out-of-band method to verify POP. Note that servers may fail in this +case, resulting for instance in HTTP error code 500 (Internal error). + +=item * OSSL_CRMF_POPO_RAVERIFIED - RFC 4211, section 4, explicit indication +that the RA has already verified the POP. + +=item * OSSL_CRMF_POPO_SIGNATURE - RFC 4211, section 4.1, only case 3 supported +so far. + +=item * OSSL_CRMF_POPO_KEYENC - RFC 4211, section 4.2, only indirect method +(subsequentMessage/enccert) supported, +challenge-response exchange (challengeResp) not yet supported. + +=item * OSSL_CRMF_POPO_KEYAGREE - RFC 4211, section 4.3, not yet supported. + +=back + +OSSL_CRMF_MSGS_verify_popo verifies the Proof-of-Possession of the request with +the given B in the list of B. Optionally accepts RAVerified. + +=head1 RETURN VALUES + +All functions return 1 on success, 0 on error. + +=head1 SEE ALSO + +RFC 4211 + +=head1 COPYRIGHT + +Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the OpenSSL license (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_pbmp_new.pod b/doc/man3/OSSL_CRMF_pbmp_new.pod new file mode 100644 index 00000000..a83209b5 --- /dev/null +++ b/doc/man3/OSSL_CRMF_pbmp_new.pod @@ -0,0 +1,78 @@ +=pod + +=head1 NAME + +OSSL_CRMF_pbm_new, +OSSL_CRMF_pbmp_new +- functions for producing Password-Based MAC (PBM) + +=head1 SYNOPSIS + + #include + + int OSSL_CRMF_pbm_new(const OSSL_CRMF_PBMPARAMETER *pbmp, + const unsigned char *msg, size_t msglen, + const unsigned char *sec, size_t seclen, + unsigned char **mac, size_t *maclen); + + OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(size_t saltlen, int owfnid, + int itercnt, int macnid); + +=head1 DESCRIPTION + +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 +allocated MAC via the B reference parameter and writes the length via the +B reference parameter unless it its NULL. + +The iteration count must be at least 100, as stipulated by RFC 4211, and is +limited to at most 100000 to avoid DoS through manipulated or otherwise +malformed input. + +OSSL_CRMF_pbmp_new() initializes and returns a new PBMParameter +structure with a new random salt of given length B, OWF (one-way +function) NID B, iteration count B, and MAC NID B. + +=head1 NOTES + +The algorithms for the OWF (one-way function) and for the MAC (message +authentication code) may be any with a NID defined in B. +As specified by RFC 4210, these should include NID_hmac_sha1. + +RFC 4210 recommends that the salt SHOULD be at least 8 bytes (64 bits) long. + +=head1 RETURN VALUES + +OSSL_CRMF_pbm_new() returns 1 on success, 0 on error. + +OSSL_CRMF_pbmp_new() returns a new and initialized OSSL_CRMF_PBMPARAMETER +structure, or NULL on error. + +=head1 EXAMPLE + + OSSL_CRMF_PBMPARAMETER *pbm = NULL; + unsigned char *msg = "Hello"; + unsigned char *sec = "SeCrEt"; + unsigned char *mac = NULL; + size_t maclen; + + if ((pbm = OSSL_CRMF_pbmp_new(16, NID_sha256, 500, NID_hmac_sha1) == NULL)) + goto err; + if (!OSSL_CRMF_pbm_new(pbm, msg, 5, sec, 6, &mac, &maclen)) + goto err; + +=head1 SEE ALSO + +RFC 4211 section 4.4 + +=head1 COPYRIGHT + +Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the OpenSSL license (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_PARAM.pod b/doc/man3/OSSL_PARAM.pod index 9d474863..50089b4d 100644 --- a/doc/man3/OSSL_PARAM.pod +++ b/doc/man3/OSSL_PARAM.pod @@ -11,9 +11,9 @@ OSSL_PARAM - a structure to pass or request object parameters typedef struct ossl_param_st OSSL_PARAM; struct ossl_param_st { const char *key; /* the name of the parameter */ - unsigned char data_type; /* declare what kind of content is in buffer */ - void *buffer; /* value being passed in or out */ - size_t buffer_size; /* buffer size */ + 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 */ }; @@ -45,8 +45,8 @@ Request parameters of some object. The caller (the I) sets up the C array and calls some function (the I) that has intimate knowledge about the object, which can take the internal data of the object and -copy (possibly convert) that to the buffers prepared by the -I. +copy (possibly convert) that to the memory prepared by the +I and pointed at with the C C. =back @@ -69,13 +69,13 @@ The C is a value that describes the type and organization of the data. See L below for a description of the types. -=item C +=item C -=item C +=item C -C is a pointer to the memory where the parameter data is (when +C is a pointer to the memory where the parameter data is (when setting parameters) or shall (when requesting parameters) be stored, -and C is its size in bytes. +and C is its size in bytes. The organization of the data depends on the parameter type and flag. =item C @@ -83,9 +83,8 @@ The organization of the data depends on the parameter type and flag. When an array of C is used to request data, the I must set this field to indicate the actual size of the parameter data. -In case the C is too small for the data, the I -must still set this field to indicate the minimum buffer size -required. +In case the C is too small for the data, the I +must still set this field to indicate the minimum data size required. =back @@ -119,8 +118,6 @@ systems. =item C -=for comment It's still debated if we need this or not. - The parameter data is a floating point value in native form. =item C @@ -131,47 +128,50 @@ The parameter data is a printable string. The parameter data is an arbitrary string of bytes. -=back +=item C -Additionally, this flag can be added to any type: +The parameter data is a pointer to a printable string. -=over 4 +The difference between this and C is that C +doesn't point directly at the data, but to a pointer that points to the data. -=item C - -With this flag, C doesn't point directly at the data, but at a -pointer that points at the data. - -This can be used to indicate that constant data is or will be passed, +This is used to indicate that constant data is or will be passed, and there is therefore no need to copy the data that is passed, just the pointer to it. -If an C with this flag set is used to set a parameter, -C must be set to the size of the data, not the size of -the pointer to the data. +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. -If this C is used in a parameter request, C -is not relevant. -However, the I will set C<*return_size> to the size of the -data (again, not the size of the pointer to the data). - -Note that the use of this flag is B and can only be safely +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 long enough duration (such as the life-time of the entity that offers these parameters). -=back +=item C -For convenience, these types are provided: +The parameter data is a pointer to an arbitrary string of bytes. -=over 4 +The difference between this and C is that +C doesn't point directly at the data, but to a pointer that +points to the data. -=item C +This is used to indicate that constant data is or will be passed, and +there is therefore no need to copy the data that is passed, just the +pointer to it. -=item C +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. -These are combinations of C as well as -C with C. +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 +long enough duration (such as the life-time of the entity that +offers these parameters). =back @@ -197,7 +197,7 @@ 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 buffers that C and +may only change the contents of the memory that C and C point at. =item * @@ -213,7 +213,7 @@ C), but this is in no way mandatory. =item * -If a I finds that some buffers are too small for the +If a I finds that some data sizes are too small for the requested data, it must set C<*return_size> for each such C item to the required size, and eventually return an error. @@ -273,10 +273,10 @@ could fill in the parameters like this: for (i = 0; params[i].key != NULL; i++) { if (strcmp(params[i].key, "foo") == 0) { - *(char **)params[i].buffer = "foo value"; + *(char **)params[i].data = "foo value"; *params[i].return_size = 10; /* size of "foo value" */ } else if (strcmp(params[i].key, "bar") == 0) { - memcpy(params[1].buffer, "bar value", 10); + memcpy(params[1].data, "bar value", 10); *params[1].return_size = 10; /* size of "bar value" */ } /* Ignore stuff we don't know */ @@ -284,7 +284,7 @@ could fill in the parameters like this: =head1 SEE ALSO -L +L, L =head1 HISTORY diff --git a/doc/man3/OSSL_PARAM_TYPE.pod b/doc/man3/OSSL_PARAM_TYPE.pod new file mode 100644 index 00000000..c4ca37a3 --- /dev/null +++ b/doc/man3/OSSL_PARAM_TYPE.pod @@ -0,0 +1,312 @@ +=pod + +=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_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_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 +- OSSL_PARAM helpers + +=head1 SYNOPSIS + + #include + + #define OSSL_PARAM_TYPE(key, address) + #define OSSL_PARAM_utf8_string(key, address, size) + #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_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); + OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, + size_t bsize, size_t *rsize); + OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, + size_t bsize, size_t *rsize); + OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, + size_t *rsize); + OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, + size_t *rsize); + + OSSL_PARAM *OSSL_PARAM_locate(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_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_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_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_get_utf8_ptr(const OSSL_PARAM *p, char **val); + int OSSL_PARAM_set_utf8_ptr(const 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); + +=head1 DESCRIPTION + +A collection of utility functions that simplify and add type safety to the +OSSL_PARAM arrays. The following B names are supported: + +=over 1 + +=item * + +double + +=item * + +int + +=item * + +int32 (int32_t) + +=item * + +int64 (int64_t) + +=item * + +long int (long) + +=item * + +size_t + +=item * + +uint32 (uint32_t) + +=item * + +uint64 (uint64_t) + +=item * + +unsigned int (uint) + +=item * + +unsigned long int (ulong) + +=back + +OSSL_PARAM_TYPE() are a series of macros designed to assist initialising an +array of OSSL_PARAM structures. +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. +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. + +OSSL_PARAM_construct_TYPE() are a series of functions that create OSSL_PARAM +records dynamically. +A parameter with name B is created. +The parameter will use storage pointed to by B and return size of B. + +OSSL_PARAM_construct_BN() is a function that constructs a large integer +OSSL_PARAM structure. +A parameter with name B, storage B, size B and return +size B is created. + +OSSL_PARAM_construct_utf8_string() is a function that constructs a UTF8 +string OSSL_PARAM structure. +A parameter with name B, storage B, size B and return +size B is created. + +OSSL_PARAM_construct_octet_string() is a function that constructs an OCTET +string OSSL_PARAM structure. +A parameter with name B, storage B, size B and return +size B is created. + +OSSL_PARAM_construct_utf8_ptr() is a function that constructes a UTF string +pointer OSSL_PARAM structure. +A parameter with name B, storage pointer B<*buf> and return size B +is created. + +OSSL_PARAM_construct_octet_ptr() is a function that constructes an OCTET string +pointer OSSL_PARAM structure. +A parameter with name B, storage pointer B<*buf> and return size B +is created. + +OSSL_PARAM_locate() is a function that searches an B of parameters for +the one matching the B name. + +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 +B

. +Type coercion takes place as discussed in the NOTES section. + +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_get_utf8_string() retrieves a UTF8 string from the parameter +pointed to by B

. +The string is either stored into B<*val> with a length limit of B or, +in the case when B<*val> is B, memory is allocated for the string and +B is ignored. +If memory is allocated by this function, it must be freed by the caller. + +OSSL_PARAM_set_utf8_string() sets a UTF8 string from the parameter pointed to +by B

to the value referenced by B. + +OSSL_PARAM_get_octet_string() retrieves an OCTET string from the parameter +pointed to by B

. +The OCTETs are either stored into B<*val> with a length limit of B or, +in the case when B<*val> is B, memory is allocated and +B is ignored. +If memory is allocated by this function, it must be freed by the caller. + +OSSL_PARAM_set_octet_string() sets an OCTET string from the parameter +pointed to by B

to the value referenced by B. + +OSSL_PARAM_get_utf8_ptr() retrieves the UTF8 string pointer from the parameter +referenced by B

and stores it in B<*val>. + +OSSL_PARAM_set_utf8_ptr() sets the UTF8 string pointer in the parameter +referenced by B

to the values B. + +OSSL_PARAM_get_octet_ptr() retrieves the OCTET string pointer from the parameter +referenced by B

and stores it in B<*val>. +The length of the OCTET string is stored in B<*used_len>. + +OSSL_PARAM_set_octet_ptr() sets the OCTET string pointer in the parameter +referenced by B

to the values B. +The length of the OCTET string is provided by B. + +=head1 RETURN VALUES + +OSSL_PARAM_construct_TYPE(), OSSL_PARAM_construct_BN(), +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. + +All other functions return B<1> on success and B<0> on failure. + +=head1 NOTES + +Integral types will be widened and sign extended as required. +Apart from that, the functions must be used appropriately for the +expected type of the parameter. + +=head1 EXAMPLES + +Reusing the examples from L to just show how +C arrays can be handled using the macros and functions +defined herein. + +=head2 Example 1 + +This example is for setting parameters on some object: + + #include + + const char *foo = "some string"; + size_t foo_l = strlen(foo) + 1; + const char bar[] = "some other string"; + const OSSL_PARAM set[] = { + OSSL_PARAM_utf8_ptr("foo", foo, foo_l), + OSSL_PARAM_utf8_string("bar", bar, sizeof(bar)), + OSSL_PARAM_END + }; + +=head2 Example 2 + +This example is for requesting parameters on some object: + + 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_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_set_utf8_ptr(OSSL_PARAM_locate(params, "foo"), "foo value"); + OSSL_PARAM_set_utf8_string(OSSL_PARAM_locate(params, "bar"), "bar value"); + +=head1 SEE ALSO + +L, L + +=head1 HISTORY + +These APIs were introduced in 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/man3/OSSL_PROVIDER.pod b/doc/man3/OSSL_PROVIDER.pod new file mode 100644 index 00000000..e3653663 --- /dev/null +++ b/doc/man3/OSSL_PROVIDER.pod @@ -0,0 +1,112 @@ +=pod + +=head1 NAME + +OSSL_PROVIDER, OSSL_PROVIDER_load, OSSL_PROVIDER_unload, +OSSL_PROVIDER_get_param_types, OSSL_PROVIDER_get_params, +OSSL_PROVIDER_add_builtin - provider routines + +=head1 SYNOPSIS + + #include + + typedef struct ossl_provider_st OSSL_PROVIDER; + + 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[]); + + int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *, const char *name, + ossl_provider_init_fn *init_fn); + +=head1 DESCRIPTION + +B is a type that holds internal information about +implementation providers (see L for information on what a +provider is). +A provider can be built in to the application or the OpenSSL +libraries, or can be a loadable module. +The functions described here handle both forms. + +=head2 Functions + +OSSL_PROVIDER_add_builtin() is used to add a built in provider to +B store in the given library context, by associating a +provider name with a provider initialization function. +This name can then be used with OSSL_PROVIDER_load(). + +OSSL_PROVIDER_load() loads and initializes a provider. +This may simply initialize a provider that was previously added with +OSSL_PROVIDER_add_builtin() and run its given initialization function, +or load a provider module with the given name and run its provider +entry point, C. + +OSSL_PROVIDER_unload() unloads the given provider. +For a provider added with OSSL_PROVIDER_add_builtin(), this simply +runs its teardown function. + +OSSL_PROVIDER_get_param_types() is used to get a provider parameter +descriptor set as an B array. +Each element is a tuple of an B parameter type and a name +in form of a C string. +See L for more information on B and +parameter types. + +OSSL_PROVIDER_get_params() is used to get provider parameter values. +The caller must prepare the B array before calling this +function, and the variables acting as buffers for this parameter array +should be filled with data when it returns successfully. + +=head1 RETURN VALUES + +OSSL_PROVIDER_add() returns 1 on success, or 0 on error. + +OSSL_PROVIDER_load() returns a pointer to a provider object on +success, or B on error. + +OSSL_PROVIDER_unload() returns 1 on success, or 0 on error. + +OSSL_PROVIDER_get_param_types() returns a pointer to a constant array +of B, or NULL if none is provided. + +OSSL_PROVIDER_get_params() returns 1 on success, or 0 on error. + +=head1 EXAMPLES + +This demonstrates how to load the provider module "foo" and ask for +its build number. + + OSSL_PROVIDER *prov = NULL; + const char *build = NULL; + size_t built_l = 0; + const OSSL_PARAM request[] = { + { "build", OSSL_PARAM_UTF8_STRING_PTR, &build, 0, &build_l }, + { NULL, 0, NULL, 0, NULL } + }; + + if ((prov = OSSL_PROVIDER_load(NULL, "foo")) != NULL + && OSSL_PROVIDER_get_params(prov, request)) + printf("Provider 'foo' build %s\n", build); + else + ERR_print_errors_fp(stderr); + +=head1 SEE ALSO + +L, L + +=head1 HISTORY + +The type and functions described here 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/doc/man3/OSSL_trace_enabled.pod b/doc/man3/OSSL_trace_enabled.pod index ecb88ab0..98e3bd63 100644 --- a/doc/man3/OSSL_trace_enabled.pod +++ b/doc/man3/OSSL_trace_enabled.pod @@ -2,7 +2,8 @@ =head1 NAME -OSSL_trace_enabled, OSSL_trace_begin, OSSL_trace_end +OSSL_trace_enabled, OSSL_trace_begin, OSSL_trace_end, +OSSL_TRACE_BEGIN, OSSL_TRACE_END, OSSL_TRACE1, OSSL_TRACE2, OSSL_TRACE9 - OpenSSL Tracing API =head1 SYNOPSIS @@ -14,13 +15,25 @@ OSSL_trace_enabled, OSSL_trace_begin, OSSL_trace_end BIO *OSSL_trace_begin(int category); void OSSL_trace_end(int category, BIO *channel); + /* trace group macros */ + OSSL_TRACE_BEGIN(category) { + ... + } OSSL_TRACE_END(category); + + /* one-shot trace macros */ + OSSL_TRACE1(category, format, arg1) + OSSL_TRACE2(category, format, arg1, arg2) + ... + OSSL_TRACE9(category, format, arg1, ..., arg9) + + =head1 DESCRIPTION The functions described here are mainly interesting for those who provide OpenSSL functionality, either in OpenSSL itself or in engine modules or similar. -If operational (see L below), these functions are used to +If tracing is enabled (see L below), these functions are used to generate free text tracing output. The tracing output is divided into types which are enabled @@ -30,6 +43,30 @@ L. The fallback type C should I be used with the functions described here. +Tracing for a specific category is enabled if a so called +I is attached to it. A trace channel is simply a +BIO object to which the application can write its trace output. + +The application has two different ways of registering a trace channel, +either by directly providing a BIO object using OSSL_trace_set_channel(), +or by providing a callback routine using OSSL_trace_set_callback(). +The latter is wrapped internally by a dedicated BIO object, so for the +tracing code both channel types are effectively indistinguishable. +We call them a I and a I, +respectively. + +To produce trace output, it is necessary to obtain a pointer to the +trace channel (i.e., the BIO object) using OSSL_trace_begin(), write +to it using arbitrary BIO output routines, and finally releases the +channel using OSSL_trace_end(). The OSSL_trace_begin()/OSSL_trace_end() +calls surrounding the trace output create a group, which acts as a +critical section (guarded by a mutex) to ensure that the trace output +of different threads does not get mixed up. + +The tracing code normally does not call OSSL_trace_{begin,end}() directly, +but rather uses a set of convenience macros, see the L section below. + + =head2 Functions OSSL_trace_enabled() can be used to check if tracing for the given @@ -46,7 +83,7 @@ is I. The result of trying to produce tracing output outside of such sections is undefined. -=head2 Convenience Macros +=head2 Macros There are a number of convenience macros defined, to make tracing easy and consistent. @@ -60,7 +97,7 @@ the B C and are used as follows to wrap a trace section: } OSSL_TRACE_END(TLS); -This will normally expands to: +This will normally expand to: do { BIO *trc_out = OSSL_trace_begin(OSSL_TRACE_CATEGORY_TLS); @@ -98,6 +135,16 @@ This will normally expand to: OSSL_trace_end(OSSL_TRACE_CATEGORY_TLS, trc_out); } while (0); + +C, ... C are one-shot macros which essentially wrap +a single BIO_printf() into a tracing group. + +The call OSSL_TRACEn(category, format, arg1, ..., argN) expands to: + + OSSL_TRACE_BEGIN(category) { + BIO_printf(trc_out, format, arg1, ..., argN) + } OSSL_TRACE_END(category) + =head1 NOTES It is advisable to always check that a trace type is enabled with @@ -110,10 +157,11 @@ OSSL_trace_enabled() before generating any output, for example: OSSL_trace_end(OSSL_TRACE_CATEGORY_TLS, trace); } -=head2 Tracing disabled +=head2 Configure Tracing -The OpenSSL library may be built with tracing disabled, which makes -everything documented here inoperational. +By default, the OpenSSL library is built with tracing disabled. To +use the tracing functionality documented here, it is therefore +necessary to configure and build OpenSSL with the 'enable-trace' option. When the library is built with tracing disabled: @@ -132,7 +180,7 @@ nothing. =item * the convenience macros are defined to produce dead code. -For example, take this example from L above: +For example, take this example from L section above: OSSL_TRACE_BEGIN(TLS) { diff --git a/doc/man3/OSSL_trace_set_channel.pod b/doc/man3/OSSL_trace_set_channel.pod index 6981dbc2..773a6b10 100644 --- a/doc/man3/OSSL_trace_set_channel.pod +++ b/doc/man3/OSSL_trace_set_channel.pod @@ -25,14 +25,21 @@ This output comes in form of free text for humans to read. The trace output is divided into categories which can be enabled individually. -They are enabled by giving them a channel in form of a BIO, or a -tracer callback, which is responsible for performing the actual -output. +Every category can be enabled individually by attaching a so called +I to it, which in the simplest case is just a BIO object +to which the application can write the tracing output for this category. +Alternatively, the application can provide a tracer callback in order to +get more finegrained trace information. This callback will be wrapped +internally by a dedicated BIO object. + +For the tracing code, both trace channel types are indistinguishable. +These are called a I and a I, +respectively. =head2 Functions OSSL_trace_set_channel() is used to enable the given trace C -by giving it the B C. +by attaching the B C object as (simple) trace channel. OSSL_trace_set_prefix() and OSSL_trace_set_suffix() can be used to add an extra line for each channel, to be output before and after group of @@ -46,7 +53,8 @@ OSSL_trace_set_callback() instead. OSSL_trace_set_callback() is used to enable the given trace C by giving it the tracer callback C with the associated data C, which will simply be passed through to C whenever -it's called. +it's called. The callback function is internally wrapped by a +dedicated BIO object, the so called I. This should be used when it's desirable to do form the trace output to something suitable for application needs where a prefix and suffix line aren't enough. @@ -78,9 +86,13 @@ callback the possibility to output a dynamic starting line, or set a prefix that should be output at the beginning of each line, or something other. -=item C +=item C -The callback is called from any regular BIO output routine. +This callback is called whenever data is written to the BIO by some +regular BIO output routine. +An arbitrary number of C callbacks can occur +inside a group marked by a pair of C and +C calls, but never outside such a group. =item C @@ -177,8 +189,8 @@ success, or 0 on failure. =head1 EXAMPLES -In all examples below, we assume that the trace producing code is -this: +In all examples below, the trace producing code is assumed to be +the following: int foo = 42; const char bar[] = { 0, 1, 2, 3, 4, 5, 6, 7, @@ -261,10 +273,11 @@ The output is almost the same as for the simple example above. =head1 NOTES -=head2 Tracing disabled +=head2 Configure Tracing -The OpenSSL library may be built with tracing disabled, which makes -everything documented here inoperational. +By default, the OpenSSL library is built with tracing disabled. To +use the tracing functionality documented here, it is therefore +necessary to configure and build OpenSSL with the 'enable-trace' option. When the library is built with tracing disabled, the macro C is defined in C and all diff --git a/doc/man3/RSA_padding_add_PKCS1_type_1.pod b/doc/man3/RSA_padding_add_PKCS1_type_1.pod index 49340f13..685063b2 100644 --- a/doc/man3/RSA_padding_add_PKCS1_type_1.pod +++ b/doc/man3/RSA_padding_add_PKCS1_type_1.pod @@ -5,6 +5,7 @@ RSA_padding_add_PKCS1_type_1, RSA_padding_check_PKCS1_type_1, RSA_padding_add_PKCS1_type_2, RSA_padding_check_PKCS1_type_2, RSA_padding_add_PKCS1_OAEP, RSA_padding_check_PKCS1_OAEP, +RSA_padding_add_PKCS1_OAEP_mgf1, RSA_padding_check_PKCS1_OAEP_mgf1, RSA_padding_add_SSLv23, RSA_padding_check_SSLv23, RSA_padding_add_none, RSA_padding_check_none - asymmetric encryption padding @@ -14,35 +15,46 @@ padding #include int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, - unsigned char *f, int fl); + const unsigned char *f, int fl); int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, - unsigned char *f, int fl, int rsa_len); + const unsigned char *f, int fl, int rsa_len); int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, - unsigned char *f, int fl); + const unsigned char *f, int fl); int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, - unsigned char *f, int fl, int rsa_len); + const unsigned char *f, int fl, int rsa_len); int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, - unsigned char *f, int fl, unsigned char *p, int pl); + const unsigned char *f, int fl, + const unsigned char *p, int pl); int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, - unsigned char *f, int fl, int rsa_len, - unsigned char *p, int pl); + const unsigned char *f, int fl, int rsa_len, + const unsigned char *p, int pl); + + int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, + const unsigned char *f, int fl, + const unsigned char *p, int pl, + const EVP_MD *md, const EVP_MD *mgf1md); + + int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, + const unsigned char *f, int fl, int rsa_len, + const unsigned char *p, int pl, + const EVP_MD *md, const EVP_MD *mgf1md); int RSA_padding_add_SSLv23(unsigned char *to, int tlen, - unsigned char *f, int fl); + const unsigned char *f, int fl); int RSA_padding_check_SSLv23(unsigned char *to, int tlen, - unsigned char *f, int fl, int rsa_len); + const unsigned char *f, int fl, int rsa_len); int RSA_padding_add_none(unsigned char *to, int tlen, - unsigned char *f, int fl); + const unsigned char *f, int fl); int RSA_padding_check_none(unsigned char *to, int tlen, - unsigned char *f, int fl, int rsa_len); + const unsigned char *f, int fl, int rsa_len); =head1 DESCRIPTION @@ -98,6 +110,10 @@ at B. For RSA_padding_xxx_OAEP(), B

points to the encoding parameter of length B. B

may be B if B is 0. +For RSA_padding_xxx_OAEP_mgf1(), B points to the md hash, +if B is B that means md=sha1, and B points to +the mgf1 hash, if B is B that means mgf1md=md. + =head1 RETURN VALUES The RSA_padding_add_xxx() functions return 1 on success, 0 on error. @@ -107,15 +123,21 @@ L. =head1 WARNING -The RSA_padding_check_PKCS1_type_2() padding check leaks timing +The result of RSA_padding_check_PKCS1_type_2() is a very sensitive information which can potentially be used to mount a Bleichenbacher padding oracle attack. This is an inherent weakness in the PKCS #1 -v1.5 padding design. Prefer PKCS1_OAEP padding. Otherwise it can -be recommended to pass zero-padded B, so that B equals to -B, and if fixed by protocol, B being set to the -expected length. In such case leakage would be minimal, it would -take attacker's ability to observe memory access pattern with byte -granilarity as it occurs, post-factum timing analysis won't do. +v1.5 padding design. Prefer PKCS1_OAEP padding. If that is not +possible, the result of RSA_padding_check_PKCS1_type_2() should be +checked in constant time if it matches the expected length of the +plaintext and additionally some application specific consistency +checks on the plaintext need to be performed in constant time. +If the plaintext is rejected it must be kept secret which of the +checks caused the application to reject the message. +Do not remove the zero-padding from the decrypted raw RSA data +which was computed by RSA_private_decrypt() with B, +as this would create a small timing side channel which could be +used to mount a Bleichenbacher attack against any padding mode +including PKCS1_OAEP. =head1 SEE ALSO @@ -125,7 +147,7 @@ L, L =head1 COPYRIGHT -Copyright 2000-2016 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/RSA_public_encrypt.pod b/doc/man3/RSA_public_encrypt.pod index 4e3c119c..9c75944c 100644 --- a/doc/man3/RSA_public_encrypt.pod +++ b/doc/man3/RSA_public_encrypt.pod @@ -8,10 +8,10 @@ RSA_public_encrypt, RSA_private_decrypt - RSA public key cryptography #include - int RSA_public_encrypt(int flen, unsigned char *from, + int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding); - int RSA_private_decrypt(int flen, unsigned char *from, + int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding); =head1 DESCRIPTION @@ -27,6 +27,8 @@ B denotes one of the following modes: =item RSA_PKCS1_PADDING PKCS #1 v1.5 padding. This currently is the most widely used mode. +However, it is highly recommended to use RSA_PKCS1_OAEP_PADDING in +new applications. SEE WARNING BELOW. =item RSA_PKCS1_OAEP_PADDING @@ -46,23 +48,35 @@ Encrypting user data directly with RSA is insecure. =back -B must be less than RSA_size(B) - 11 for the PKCS #1 v1.5 -based padding modes, less than RSA_size(B) - 41 for +B must not be more than RSA_size(B) - 11 for the PKCS #1 v1.5 +based padding modes, not more than RSA_size(B) - 42 for RSA_PKCS1_OAEP_PADDING and exactly RSA_size(B) for RSA_NO_PADDING. -The random number generator must be seeded prior to calling -RSA_public_encrypt(). +When a padding mode other than RSA_NO_PADDING is in use, then +RSA_public_encrypt() will include some random bytes into the ciphertext +and therefore the ciphertext will be different each time, even if the +plaintext and the public key are exactly identical. +The returned ciphertext in B will always be zero padded to exactly +RSA_size(B) bytes. +B and B may overlap. RSA_private_decrypt() decrypts the B bytes at B using the -private key B and stores the plaintext in B. B must point -to a memory section large enough to hold the decrypted data (which is -smaller than RSA_size(B)). B is the padding mode that -was used to encrypt the data. +private key B and stores the plaintext in B. B should +be equal to RSA_size(B) but may be smaller, when leading zero +bytes are in the ciphertext. Those are not important and may be removed, +but RSA_public_encrypt() does not do that. B must point +to a memory section large enough to hold the maximal possible decrypted +data (which is equal to RSA_size(B) for RSA_NO_PADDING, +RSA_size(B) - 11 for the PKCS #1 v1.5 based padding modes and +RSA_size(B) - 42 for RSA_PKCS1_OAEP_PADDING). +B is the padding mode that was used to encrypt the data. +B and B may overlap. =head1 RETURN VALUES RSA_public_encrypt() returns the size of the encrypted data (i.e., RSA_size(B)). RSA_private_decrypt() returns the size of the -recovered plaintext. +recovered plaintext. A return value of 0 is not an error and +means only that the plaintext was empty. On error, -1 is returned; the error codes can be obtained by L. @@ -85,7 +99,7 @@ L =head1 COPYRIGHT -Copyright 2000-2016 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/SSL_CTX_set_read_ahead.pod b/doc/man3/SSL_CTX_set_read_ahead.pod index a71d72e3..97343b92 100644 --- a/doc/man3/SSL_CTX_set_read_ahead.pod +++ b/doc/man3/SSL_CTX_set_read_ahead.pod @@ -46,7 +46,7 @@ records, and SSL_has_pending() can't tell the difference between processed and unprocessed data, it's recommended that if read ahead is turned on that B is not turned off using SSL_CTX_clear_mode(). That will prevent getting B when there is still a complete -record availale that hasn't been processed. +record available that hasn't been processed. If the application wants to continue to use the underlying transport (e.g. TCP connection) after the SSL connection is finished using SSL_shutdown() reading diff --git a/doc/man3/X509_dup.pod b/doc/man3/X509_dup.pod index 8ad7648e..2f51e455 100644 --- a/doc/man3/X509_dup.pod +++ b/doc/man3/X509_dup.pod @@ -116,6 +116,20 @@ OCSP_SIGNATURE_free, OCSP_SIGNATURE_new, OCSP_SINGLERESP_free, OCSP_SINGLERESP_new, +OSSL_CRMF_CERTID_free, +OSSL_CRMF_CERTID_new, +OSSL_CRMF_CERTTEMPLATE_free, +OSSL_CRMF_CERTTEMPLATE_new, +OSSL_CRMF_ENCRYPTEDVALUE_free, +OSSL_CRMF_ENCRYPTEDVALUE_new, +OSSL_CRMF_MSG_free, +OSSL_CRMF_MSG_new, +OSSL_CRMF_PBMPARAMETER_free, +OSSL_CRMF_PBMPARAMETER_new, +OSSL_CRMF_PKIPUBLICATIONINFO_free, +OSSL_CRMF_PKIPUBLICATIONINFO_new, +OSSL_CRMF_MSGS_free, +OSSL_CRMF_MSGS_new, OTHERNAME_free, OTHERNAME_new, PBE2PARAM_free, diff --git a/e_os.h b/e_os.h index 472354e0..26de710c 100644 --- a/e_os.h +++ b/e_os.h @@ -28,7 +28,9 @@ * default, we will try to read at least one of these files */ # define DEVRANDOM "/dev/urandom", "/dev/random", "/dev/hwrng", "/dev/srandom" -# define DEVRANDOM_WAIT "/dev/random" +# ifdef __linux +# define DEVRANDOM_WAIT "/dev/random" +# endif # endif # if !defined(OPENSSL_NO_EGD) && !defined(DEVRANDOM_EGD) /* diff --git a/fuzz/oids.txt b/fuzz/oids.txt index 79a68fcd..3bb9cb58 100644 --- a/fuzz/oids.txt +++ b/fuzz/oids.txt @@ -1064,3 +1064,4 @@ 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_SM2_with_SM3="\x2A\x81\x1C\xCF\x55\x01\x83\x75" diff --git a/include/internal/core.h b/include/internal/core.h new file mode 100644 index 00000000..2f0df376 --- /dev/null +++ b/include/internal/core.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 + */ + +#ifndef OSSL_INTERNAL_CORE_H +# define OSSL_INTERNAL_CORE_H + +/* + * namespaces: + * + * ossl_method_ Core Method API + */ + +/* + * construct an arbitrary method from a dispatch table found by looking + * up a match for the < operation_id, name, property > combination. + * constructor and destructor are the constructor and destructor for that + * arbitrary object. + * + * These objects are normally cached, unless the provider says not to cache. + * However, force_cache can be used to force caching whatever the provider + * says (for example, because the application knows better). + */ +typedef struct ossl_method_construct_method_st { + /* Create store */ + void *(*alloc_tmp_store)(void); + /* 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 *propquery, + void *data); + /* Store a method in a store */ + int (*put)(OPENSSL_CTX *libctx, void *store, const char *propdef, + void *method, void *data); + /* Construct a new method */ + void *(*construct)(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov, + void *data); + /* Destruct a method */ + void (*destruct)(void *method); +} OSSL_METHOD_CONSTRUCT_METHOD; + +void *ossl_method_construct(OPENSSL_CTX *ctx, int operation_id, + const char *name, const char *properties, + int force_cache, + OSSL_METHOD_CONSTRUCT_METHOD *mcm, void *mcm_data); + +#endif diff --git a/include/internal/dsoerr.h b/include/internal/dsoerr.h index 5c839f85..3645aa5c 100644 --- a/include/internal/dsoerr.h +++ b/include/internal/dsoerr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_DSOERR_H # define HEADER_DSOERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # include # ifndef OPENSSL_NO_DSO diff --git a/include/internal/propertyerr.h b/include/internal/propertyerr.h index 908c9109..d4002977 100644 --- a/include/internal/propertyerr.h +++ b/include/internal/propertyerr.h @@ -11,6 +11,10 @@ #ifndef HEADER_PROPERR_H # define HEADER_PROPERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/internal/provider.h b/include/internal/provider.h new file mode 100644 index 00000000..ac70fcc5 --- /dev/null +++ b/include/internal/provider.h @@ -0,0 +1,70 @@ +/* + * 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_INTERNAL_PROVIDER_H +# define OSSL_INTERNAL_PROVIDER_H + +# include +# include "internal/dso.h" +# include "internal/symhacks.h" + +# ifdef __cplusplus +extern "C" { +# endif + +/* + * namespaces: + * + * ossl_provider_ Provider Object internal API + * OSSL_PROVIDER Provider Object + */ + +/* Provider Object finder, constructor and destructor */ +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); +void ossl_provider_free(OSSL_PROVIDER *prov); + +/* Setters */ +int ossl_provider_add_module_location(OSSL_PROVIDER *prov, const char *loc); + +/* + * Activate the Provider + * If the Provider is a module, the module will be loaded + * Inactivation is done by freeing the Provider + */ +int ossl_provider_activate(OSSL_PROVIDER *prov); + +/* Iterate over all loaded providers */ +int ossl_provider_forall_loaded(OPENSSL_CTX *, + int (*cb)(OSSL_PROVIDER *provider, + void *cbdata), + 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); + +/* 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[]); +const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov, + int operation_id, + int *no_cache); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/include/internal/refcount.h b/include/internal/refcount.h index b6c9f9c9..f8b07789 100644 --- a/include/internal/refcount.h +++ b/include/internal/refcount.h @@ -16,16 +16,17 @@ # endif # endif -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ - && !defined(__STDC_NO_ATOMICS__) -# include -# define HAVE_C11_ATOMICS -# endif +# ifndef OPENSSL_DEV_NO_ATOMICS +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ + && !defined(__STDC_NO_ATOMICS__) +# include +# define HAVE_C11_ATOMICS +# endif -# if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) \ - && ATOMIC_INT_LOCK_FREE > 0 +# if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) \ + && ATOMIC_INT_LOCK_FREE > 0 -# define HAVE_ATOMICS 1 +# define HAVE_ATOMICS 1 typedef _Atomic int CRYPTO_REF_COUNT; @@ -53,9 +54,9 @@ static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock) return 1; } -# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0 +# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0 -# define HAVE_ATOMICS 1 +# define HAVE_ATOMICS 1 typedef int CRYPTO_REF_COUNT; @@ -73,17 +74,17 @@ static __inline__ int CRYPTO_DOWN_REF(int *val, int *ret, void *lock) return 1; } -# elif defined(_MSC_VER) && _MSC_VER>=1200 +# elif defined(_MSC_VER) && _MSC_VER>=1200 -# define HAVE_ATOMICS 1 +# define HAVE_ATOMICS 1 typedef volatile int CRYPTO_REF_COUNT; -# if (defined(_M_ARM) && _M_ARM>=7) || defined(_M_ARM64) -# include -# if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH) -# define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH -# endif +# if (defined(_M_ARM) && _M_ARM>=7) || defined(_M_ARM64) +# include +# if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH) +# define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH +# endif static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock) { @@ -98,8 +99,8 @@ static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock) __dmb(_ARM_BARRIER_ISH); return 1; } -# else -# pragma intrinsic(_InterlockedExchangeAdd) +# else +# pragma intrinsic(_InterlockedExchangeAdd) static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock) { @@ -112,9 +113,17 @@ static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock) *ret = _InterlockedExchangeAdd(val, -1) - 1; return 1; } -# endif +# endif -# else +# endif +# endif /* !OPENSSL_DEV_NO_ATOMICS */ + +/* + * All the refcounting implementations above define HAVE_ATOMICS, so if it's + * still undefined here (such as when OPENSSL_DEV_NO_ATMOICS is defined), it + * means we need to implement a fallback. This fallback uses locks. + */ +# ifndef HAVE_ATOMICS typedef int CRYPTO_REF_COUNT; diff --git a/include/internal/symhacks.h b/include/internal/symhacks.h new file mode 100644 index 00000000..2b096046 --- /dev/null +++ b/include/internal/symhacks.h @@ -0,0 +1,26 @@ +/* + * 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_INTERNAL_SYMHACKS_H +# define OSSL_INTERNAL_SYMHACKS_H + +# include + +# if defined(OPENSSL_SYS_VMS) + +/* ossl_provider_get_param_types vs OSSL_PROVIDER_get_param_types */ +# undef ossl_provider_get_param_types +# define ossl_provider_get_param_types ossl_int_prov_get_param_types +/* ossl_provider_get_params vs OSSL_PROVIDER_get_params */ +# undef ossl_provider_get_params +# define ossl_provider_get_params ossl_int_prov_get_params + +# endif + +#endif /* ! defined HEADER_VMS_IDHACKS_H */ diff --git a/include/openssl/asn1err.h b/include/openssl/asn1err.h index e4387906..97e9d051 100644 --- a/include/openssl/asn1err.h +++ b/include/openssl/asn1err.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_ASN1ERR_H # define HEADER_ASN1ERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/asyncerr.h b/include/openssl/asyncerr.h index 25ceffa2..84f381de 100644 --- a/include/openssl/asyncerr.h +++ b/include/openssl/asyncerr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_ASYNCERR_H # define HEADER_ASYNCERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/bioerr.h b/include/openssl/bioerr.h index f15e35a6..e5c0deb7 100644 --- a/include/openssl/bioerr.h +++ b/include/openssl/bioerr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_BIOERR_H # define HEADER_BIOERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/bnerr.h b/include/openssl/bnerr.h index 187b0822..bcf4f8f2 100644 --- a/include/openssl/bnerr.h +++ b/include/openssl/bnerr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_BNERR_H # define HEADER_BNERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/buffererr.h b/include/openssl/buffererr.h index d4fe6dfc..7f2af2ac 100644 --- a/include/openssl/buffererr.h +++ b/include/openssl/buffererr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_BUFERR_H # define HEADER_BUFERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/cmserr.h b/include/openssl/cmserr.h index e7337f59..1919a888 100644 --- a/include/openssl/cmserr.h +++ b/include/openssl/cmserr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_CMSERR_H # define HEADER_CMSERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # include # ifndef OPENSSL_NO_CMS diff --git a/include/openssl/comperr.h b/include/openssl/comperr.h index 3353e418..ab87f7d4 100644 --- a/include/openssl/comperr.h +++ b/include/openssl/comperr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_COMPERR_H # define HEADER_COMPERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # include # ifndef OPENSSL_NO_COMP diff --git a/include/openssl/conferr.h b/include/openssl/conferr.h index bea0224e..0a24b7ee 100644 --- a/include/openssl/conferr.h +++ b/include/openssl/conferr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_CONFERR_H # define HEADER_CONFERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/core.h b/include/openssl/core.h index 98b58bea..6edcd99b 100644 --- a/include/openssl/core.h +++ b/include/openssl/core.h @@ -75,8 +75,8 @@ struct ossl_algorithm_st { struct ossl_param_st { const char *key; /* the name of the parameter */ unsigned int data_type; /* declare what kind of content is in buffer */ - void *buffer; /* value being passed in or out */ - size_t buffer_size; /* buffer size */ + void *data; /* value being passed in or out */ + size_t data_size; /* data size */ size_t *return_size; /* OPTIONAL: address to content size */ }; @@ -111,13 +111,12 @@ struct ossl_param_st { * printed as a hexdump. */ # define OSSL_PARAM_OCTET_STRING 5 - /*- - * Pointer flag + * OSSL_PARAM_UTF8_PTR + * is a pointer to a printable string. Is expteced to be printed as it is. * - * This flag can be added to any type to signify that the buffer - * pointer is set to point at a pointer to the data instead of - * pointing directly at the data. + * The difference between this and OSSL_PARAM_UTF8_STRING is that only pointers + * are manipulated for this type. * * This is more relevant for parameter requests, where the responding * function doesn't need to copy the data to the provided buffer, but @@ -126,15 +125,43 @@ struct ossl_param_st { * WARNING! Using these is FRAGILE, as it assumes that the actual * data and its location are constant. */ -# define OSSL_PARAM_POINTER_FLAG 0x80000000UL - -/* - * Convenience pointer types for strings. +# define OSSL_PARAM_UTF8_PTR 6 +/*- + * OSSL_PARAM_OCTET_PTR + * is a pointer to a string of bytes with no further specification. It is + * expected to be printed as a hexdump. + * + * The difference between this and OSSL_PARAM_OCTET_STRING is that only pointers + * are manipulated for this type. + * + * This is more relevant for parameter requests, where the responding + * function doesn't need to copy the data to the provided buffer, but + * sets the provided buffer to point at the actual data instead. + * + * WARNING! Using these is FRAGILE, as it assumes that the actual + * data and its location are constant. */ -# define OSSL_PARAM_UTF8_STRING_PTR \ - (OSSL_PARAM_UTF8_STRING|OSSL_PARAM_POINTER_FLAG) -# define OSSL_PARAM_OCTET_STRING_PTR \ - (OSSL_PARAM_OCTET_STRING|OSSL_PARAM_POINTER_FLAG) +# define OSSL_PARAM_OCTET_PTR 7 + +/*- + * Provider entry point + * -------------------- + * + * This function is expected to be present in any dynamically loadable + * provider module. By definition, if this function doesn't exist in a + * module, that module is not an OpenSSL provider module. + */ +/*- + * |provider| pointer to opaque type OSSL_PROVIDER. This can be used + * together with some functions passed via |in| to query data. + * |in| is the array of functions that the Core passes to the provider. + * |out| will be the array of base functions that the provider passes + * back to the Core. + */ +typedef int (OSSL_provider_init_fn)(const OSSL_PROVIDER *provider, + const OSSL_DISPATCH *in, + const OSSL_DISPATCH **out); +extern OSSL_provider_init_fn OSSL_provider_init; # ifdef __cplusplus } diff --git a/include/openssl/core_numbers.h b/include/openssl/core_numbers.h new file mode 100644 index 00000000..7be2a2bb --- /dev/null +++ b/include/openssl/core_numbers.h @@ -0,0 +1,80 @@ +/* + * 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_NUMBERS_H +# define OSSL_CORE_NUMBERS_H + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/*- + * Identities + * ---------- + * + * All series start with 1, to allow 0 to be an array terminator. + * For any FUNC identity, we also provide a function signature typedef + * and a static inline function to extract a function pointer from a + * OSSL_DISPATCH element in a type safe manner. + * + * Names: + * for any function base name 'foo' (uppercase form 'FOO'), we will have + * the following: + * - a macro for the identity with the name OSSL_FUNC_'FOO' or derivates + * thereof (to be specified further down) + * - a function signature typedef with the name OSSL_'foo'_fn + * - a function pointer extractor function with the name OSSL_'foo' + */ + +/* Helper macro to create the function signature typedef and the extractor */ +#define OSSL_CORE_MAKE_FUNC(type,name,args) \ + typedef type (OSSL_##name##_fn)args; \ + static ossl_inline \ + OSSL_##name##_fn *OSSL_get_##name(const OSSL_DISPATCH *opf) \ + { \ + return (OSSL_##name##_fn *)opf->function; \ + } + +/* + * Core function identities, for the two OSSL_DISPATCH tables being passed + * in the OSSL_provider_init call. + * + * 0 serves as a marker for the end of the OSSL_DISPATCH array, and must + * therefore NEVER be used as a function identity. + */ +/* Functions provided by the Core to the provider, reserved numbers 1-1023 */ +# define OSSL_FUNC_CORE_GET_PARAM_TYPES 1 +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[])) + +/* 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)) +# define OSSL_FUNC_PROVIDER_GET_PARAM_TYPES 1025 +OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *, + provider_get_param_types,(const OSSL_PROVIDER *prov)) +# define OSSL_FUNC_PROVIDER_GET_PARAMS 1026 +OSSL_CORE_MAKE_FUNC(int,provider_get_params,(const OSSL_PROVIDER *prov, + const OSSL_PARAM params[])) +# define OSSL_FUNC_PROVIDER_QUERY_OPERATION 1027 +OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation, + (const OSSL_PROVIDER *, int operation_id, + const int *no_store)) + + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/include/openssl/crmf.h b/include/openssl/crmf.h new file mode 100644 index 00000000..b4221a9e --- /dev/null +++ b/include/openssl/crmf.h @@ -0,0 +1,137 @@ +/*- + * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright Nokia 2007-2018 + * Copyright Siemens AG 2015-2018 + * + * Licensed under the OpenSSL license (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 + * + * CRMF (RFC 4211) implementation by M. Peylo, M. Viljanen, and D. von Oheimb. + */ + +#ifndef OSSL_HEADER_CRMF_H +# define OSSL_HEADER_CRMF_H + +# include + +# ifndef OPENSSL_NO_CMP +# include +# include +# include +# include /* for GENERAL_NAME etc. */ + +/* explicit #includes not strictly needed since implied by the above: */ +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# define OSSL_CRMF_POPOPRIVKEY_THISMESSAGE 0 +# define OSSL_CRMF_POPOPRIVKEY_SUBSEQUENTMESSAGE 1 +# define OSSL_CRMF_POPOPRIVKEY_DHMAC 2 +# define OSSL_CRMF_POPOPRIVKEY_AGREEMAC 3 +# define OSSL_CRMF_POPOPRIVKEY_ENCRYPTEDKEY 4 + +# define OSSL_CRMF_SUBSEQUENTMESSAGE_ENCRCERT 0 +# define OSSL_CRMF_SUBSEQUENTMESSAGE_CHALLENGERESP 1 + +typedef struct OSSL_crmf_encryptedvalue_st OSSL_CRMF_ENCRYPTEDVALUE; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_ENCRYPTEDVALUE) +typedef struct OSSL_crmf_msg_st OSSL_CRMF_MSG; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_MSG) +DEFINE_STACK_OF(OSSL_CRMF_MSG) +typedef struct OSSL_crmf_attributetypeandvalue_st OSSL_CRMF_ATTRIBUTETYPEANDVALUE; +typedef struct OSSL_crmf_pbmparameter_st OSSL_CRMF_PBMPARAMETER; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PBMPARAMETER) +typedef struct OSSL_crmf_poposigningkey_st OSSL_CRMF_POPOSIGNINGKEY; +typedef struct OSSL_crmf_certrequest_st OSSL_CRMF_CERTREQUEST; +typedef struct OSSL_crmf_certid_st OSSL_CRMF_CERTID; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTID) +DEFINE_STACK_OF(OSSL_CRMF_CERTID) + +typedef struct OSSL_crmf_pkipublicationinfo_st OSSL_CRMF_PKIPUBLICATIONINFO; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_PKIPUBLICATIONINFO) +typedef struct OSSL_crmf_singlepubinfo_st OSSL_CRMF_SINGLEPUBINFO; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_SINGLEPUBINFO) +typedef struct OSSL_crmf_certtemplate_st OSSL_CRMF_CERTTEMPLATE; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_CERTTEMPLATE) +typedef STACK_OF(OSSL_CRMF_MSG) OSSL_CRMF_MSGS; +DECLARE_ASN1_FUNCTIONS(OSSL_CRMF_MSGS) + +typedef struct OSSL_crmf_optionalvalidity_st OSSL_CRMF_OPTIONALVALIDITY; + +/* crmf_pbm.c */ +OSSL_CRMF_PBMPARAMETER *OSSL_CRMF_pbmp_new(size_t slen, int owfnid, + int itercnt, int macnid); +int OSSL_CRMF_pbm_new(const OSSL_CRMF_PBMPARAMETER *pbmp, + const unsigned char *msg, size_t msglen, + const unsigned char *sec, size_t seclen, + unsigned char **mac, size_t *maclen); + +/* crmf_lib.c */ +int OSSL_CRMF_MSG_set1_regCtrl_regToken(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *tok); +int OSSL_CRMF_MSG_set1_regCtrl_authenticator(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *auth); +int OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo( + OSSL_CRMF_PKIPUBLICATIONINFO *pi, + OSSL_CRMF_SINGLEPUBINFO *spi); +# define OSSL_CRMF_PUB_METHOD_DONTCARE 0 +# define OSSL_CRMF_PUB_METHOD_X500 1 +# define OSSL_CRMF_PUB_METHOD_WEB 2 +# define OSSL_CRMF_PUB_METHOD_LDAP 3 +int OSSL_CRMF_MSG_set0_SinglePubInfo(OSSL_CRMF_SINGLEPUBINFO *spi, + int method, GENERAL_NAME *nm); +# define OSSL_CRMF_PUB_ACTION_DONTPUBLISH 0 +# define OSSL_CRMF_PUB_ACTION_PLEASEPUBLISH 1 +int OSSL_CRMF_MSG_set_PKIPublicationInfo_action( + OSSL_CRMF_PKIPUBLICATIONINFO *pi, int action); +int OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_PKIPUBLICATIONINFO *pi); +int OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey(OSSL_CRMF_MSG *msg, + const X509_PUBKEY *pubkey); +int OSSL_CRMF_MSG_set1_regCtrl_oldCertID(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_CERTID *cid); +OSSL_CRMF_CERTID *OSSL_CRMF_CERTID_gen(const X509_NAME *issuer, + const ASN1_INTEGER *serial); + +int OSSL_CRMF_MSG_set1_regInfo_utf8Pairs(OSSL_CRMF_MSG *msg, + const ASN1_UTF8STRING *utf8pairs); +int OSSL_CRMF_MSG_set1_regInfo_certReq(OSSL_CRMF_MSG *msg, + const OSSL_CRMF_CERTREQUEST *cr); + +int OSSL_CRMF_MSG_set_validity(OSSL_CRMF_MSG *crm, time_t from, time_t to); +int OSSL_CRMF_MSG_set_certReqId(OSSL_CRMF_MSG *crm, int rid); +int OSSL_CRMF_MSG_get_certReqId(OSSL_CRMF_MSG *crm); +int OSSL_CRMF_MSG_set0_extensions(OSSL_CRMF_MSG *crm, X509_EXTENSIONS *exts); + +int OSSL_CRMF_MSG_push0_extension(OSSL_CRMF_MSG *crm, const X509_EXTENSION *ext); +# define OSSL_CRMF_POPO_NONE -1 +# define OSSL_CRMF_POPO_RAVERIFIED 0 +# define OSSL_CRMF_POPO_SIGNATURE 1 +# define OSSL_CRMF_POPO_KEYENC 2 +# define OSSL_CRMF_POPO_KEYAGREE 3 +int OSSL_CRMF_MSG_create_popo(OSSL_CRMF_MSG *crm, EVP_PKEY *pkey, + int dgst, int ppmtd); +int OSSL_CRMF_MSGS_verify_popo(const OSSL_CRMF_MSGS *reqs, + int rid, int acceptRAVerified); +OSSL_CRMF_CERTTEMPLATE *OSSL_CRMF_MSG_get0_tmpl(const OSSL_CRMF_MSG *crm); +ASN1_INTEGER *OSSL_CRMF_CERTTEMPLATE_get0_serialNumber(OSSL_CRMF_CERTTEMPLATE *t); +X509_NAME *OSSL_CRMF_CERTTEMPLATE_get0_issuer(OSSL_CRMF_CERTTEMPLATE *tmpl); +int OSSL_CRMF_CERTTEMPLATE_fill(OSSL_CRMF_CERTTEMPLATE *tmpl, + EVP_PKEY *pubkey, + const X509_NAME *subject, + const X509_NAME *issuer, + const ASN1_INTEGER *serial); +X509 *OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert(OSSL_CRMF_ENCRYPTEDVALUE *ecert, + EVP_PKEY *pkey); + +# ifdef __cplusplus +} +# endif +# endif /* !defined OPENSSL_NO_CMP */ +#endif /* !defined OSSL_HEADER_CRMF_H */ diff --git a/include/openssl/crmferr.h b/include/openssl/crmferr.h new file mode 100644 index 00000000..06f90fb3 --- /dev/null +++ b/include/openssl/crmferr.h @@ -0,0 +1,69 @@ +/* + * Generated by util/mkerr.pl DO NOT EDIT + * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (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_CRMFERR_H +# define HEADER_CRMFERR_H + +# include + +# ifndef OPENSSL_NO_CMP + +# ifdef __cplusplus +extern "C" +# endif +int ERR_load_CRMF_strings(void); + +/* + * CRMF function codes. + */ +# define CRMF_F_CRMF_POPOSIGNINGKEY_INIT 100 +# define CRMF_F_OSSL_CRMF_CERTID_GEN 101 +# define CRMF_F_OSSL_CRMF_CERTTEMPLATE_FILL 102 +# define CRMF_F_OSSL_CRMF_ENCRYPTEDVALUE_GET1_ENCCERT 103 +# define CRMF_F_OSSL_CRMF_MSGS_VERIFY_POPO 104 +# define CRMF_F_OSSL_CRMF_MSG_CREATE_POPO 105 +# define CRMF_F_OSSL_CRMF_MSG_GET0_TMPL 106 +# define CRMF_F_OSSL_CRMF_MSG_GET_CERTREQID 107 +# define CRMF_F_OSSL_CRMF_MSG_PKIPUBLICATIONINFO_PUSH0_SINGLEPUBINFO 108 +# define CRMF_F_OSSL_CRMF_MSG_PUSH0_EXTENSION 109 +# define CRMF_F_OSSL_CRMF_MSG_PUSH0_REGCTRL 110 +# define CRMF_F_OSSL_CRMF_MSG_PUSH0_REGINFO 111 +# define CRMF_F_OSSL_CRMF_MSG_SET0_EXTENSIONS 112 +# define CRMF_F_OSSL_CRMF_MSG_SET0_SINGLEPUBINFO 113 +# define CRMF_F_OSSL_CRMF_MSG_SET_CERTREQID 114 +# define CRMF_F_OSSL_CRMF_MSG_SET_PKIPUBLICATIONINFO_ACTION 115 +# define CRMF_F_OSSL_CRMF_MSG_SET_VALIDITY 116 +# define CRMF_F_OSSL_CRMF_PBMP_NEW 117 +# define CRMF_F_OSSL_CRMF_PBM_NEW 118 + +/* + * CRMF reason codes. + */ +# define CRMF_R_BAD_PBM_ITERATIONCOUNT 100 +# define CRMF_R_MALFORMED_IV 101 +# define CRMF_R_CRMFERROR 102 +# define CRMF_R_ERROR 103 +# define CRMF_R_ERROR_DECODING_CERTIFICATE 104 +# define CRMF_R_ERROR_DECRYPTING_CERTIFICATE 105 +# define CRMF_R_ERROR_DECRYPTING_SYMMETRIC_KEY 106 +# define CRMF_R_FAILURE_OBTAINING_RANDOM 107 +# define CRMF_R_ITERATIONCOUNT_BELOW_100 108 +# define CRMF_R_NULL_ARGUMENT 109 +# define CRMF_R_SETTING_MAC_ALGOR_FAILURE 110 +# define CRMF_R_SETTING_OWF_ALGOR_FAILURE 111 +# define CRMF_R_UNSUPPORTED_ALGORITHM 112 +# define CRMF_R_UNSUPPORTED_ALG_FOR_POPSIGNINGKEY 113 +# define CRMF_R_UNSUPPORTED_CIPHER 114 +# define CRMF_R_UNSUPPORTED_METHOD_FOR_CREATING_POPO 115 +# define CRMF_R_UNSUPPORTED_POPO_METHOD 116 +# define CRMF_R_UNSUPPORTED_POPO_NOT_ACCEPTED 117 + +# endif +#endif diff --git a/include/openssl/cryptoerr.h b/include/openssl/cryptoerr.h index 2f3df746..c27f05c9 100644 --- a/include/openssl/cryptoerr.h +++ b/include/openssl/cryptoerr.h @@ -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 @@ -11,12 +11,13 @@ #ifndef HEADER_CRYPTOERR_H # define HEADER_CRYPTOERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif - -# include - int ERR_load_CRYPTO_strings(void); /* @@ -33,6 +34,7 @@ int ERR_load_CRYPTO_strings(void); # define CRYPTO_F_CRYPTO_SET_EX_DATA 102 # define CRYPTO_F_FIPS_MODE_SET 109 # define CRYPTO_F_GET_AND_LOCK 113 +# define CRYPTO_F_GET_PROVIDER_STORE 133 # define CRYPTO_F_OPENSSL_ATEXIT 114 # define CRYPTO_F_OPENSSL_BUF2HEXSTR 117 # define CRYPTO_F_OPENSSL_FOPEN 119 @@ -41,6 +43,9 @@ int ERR_load_CRYPTO_strings(void); # define CRYPTO_F_OPENSSL_LH_NEW 126 # define CRYPTO_F_OPENSSL_SK_DEEP_COPY 127 # define CRYPTO_F_OPENSSL_SK_DUP 128 +# define CRYPTO_F_OSSL_PROVIDER_ADD_BUILTIN 132 +# define CRYPTO_F_OSSL_PROVIDER_ACTIVATE 130 +# define CRYPTO_F_OSSL_PROVIDER_NEW 131 # define CRYPTO_F_PKEY_HMAC_INIT 123 # define CRYPTO_F_PKEY_POLY1305_INIT 124 # define CRYPTO_F_PKEY_SIPHASH_INIT 125 @@ -52,5 +57,6 @@ int ERR_load_CRYPTO_strings(void); # define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101 # define CRYPTO_R_ILLEGAL_HEX_DIGIT 102 # define CRYPTO_R_ODD_NUMBER_OF_DIGITS 103 +# define CRYPTO_R_PROVIDER_ALREADY_EXISTS 104 #endif diff --git a/include/openssl/cterr.h b/include/openssl/cterr.h index 6f223e07..16ef932f 100644 --- a/include/openssl/cterr.h +++ b/include/openssl/cterr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_CTERR_H # define HEADER_CTERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # include # ifndef OPENSSL_NO_CT diff --git a/include/openssl/dherr.h b/include/openssl/dherr.h index 892a5997..22035542 100644 --- a/include/openssl/dherr.h +++ b/include/openssl/dherr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_DHERR_H # define HEADER_DHERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # include # ifndef OPENSSL_NO_DH diff --git a/include/openssl/dsaerr.h b/include/openssl/dsaerr.h index b8182c80..c58b9ebe 100644 --- a/include/openssl/dsaerr.h +++ b/include/openssl/dsaerr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_DSAERR_H # define HEADER_DSAERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # include # ifndef OPENSSL_NO_DSA diff --git a/include/openssl/ecerr.h b/include/openssl/ecerr.h index 80744815..0ba02cb9 100644 --- a/include/openssl/ecerr.h +++ b/include/openssl/ecerr.h @@ -11,6 +11,10 @@ #ifndef HEADER_ECERR_H # define HEADER_ECERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # include # ifndef OPENSSL_NO_EC diff --git a/include/openssl/engineerr.h b/include/openssl/engineerr.h index ed2404ea..ace3d3d8 100644 --- a/include/openssl/engineerr.h +++ b/include/openssl/engineerr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_ENGINEERR_H # define HEADER_ENGINEERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # include # ifndef OPENSSL_NO_ENGINE diff --git a/include/openssl/err.h b/include/openssl/err.h index 0d6956cf..fded82c4 100644 --- a/include/openssl/err.h +++ b/include/openssl/err.h @@ -96,6 +96,7 @@ typedef struct err_state_st { # define ERR_LIB_SM2 53 # define ERR_LIB_ESS 54 # define ERR_LIB_PROP 55 +# define ERR_LIB_CRMF 56 # define ERR_LIB_USER 128 @@ -129,6 +130,7 @@ typedef struct err_state_st { # define OSSL_STOREerr(f,r) ERR_PUT_error(ERR_LIB_OSSL_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE) # 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 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/esserr.h b/include/openssl/esserr.h index e8fdb1d2..eb1c9aeb 100644 --- a/include/openssl/esserr.h +++ b/include/openssl/esserr.h @@ -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 @@ -11,7 +11,9 @@ #ifndef HEADER_ESSERR_H # define HEADER_ESSERR_H -# include +# ifndef HEADER_SYMHACKS_H +# include +# endif # ifdef __cplusplus extern "C" diff --git a/include/openssl/evperr.h b/include/openssl/evperr.h index 7da602d9..445d173c 100644 --- a/include/openssl/evperr.h +++ b/include/openssl/evperr.h @@ -11,6 +11,10 @@ #ifndef HEADER_EVPERR_H # define HEADER_EVPERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/kdferr.h b/include/openssl/kdferr.h index 6ef4da22..9a1d980d 100644 --- a/include/openssl/kdferr.h +++ b/include/openssl/kdferr.h @@ -11,6 +11,10 @@ #ifndef HEADER_KDFERR_H # define HEADER_KDFERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/obj_mac.h b/include/openssl/obj_mac.h index e525a04b..2ad7e077 100644 --- a/include/openssl/obj_mac.h +++ b/include/openssl/obj_mac.h @@ -1200,6 +1200,11 @@ #define NID_sm3WithRSAEncryption 1144 #define OBJ_sm3WithRSAEncryption OBJ_sm_scheme,504L +#define SN_SM2_with_SM3 "SM2-SM3" +#define LN_SM2_with_SM3 "SM2-with-SM3" +#define NID_SM2_with_SM3 1204 +#define OBJ_SM2_with_SM3 OBJ_sm_scheme,501L + #define LN_hmacWithSHA224 "hmacWithSHA224" #define NID_hmacWithSHA224 798 #define OBJ_hmacWithSHA224 OBJ_rsadsi,2L,8L @@ -4830,7 +4835,7 @@ #define SN_chacha20_poly1305_draft "ChaCha20-Poly1305-D" #define LN_chacha20_poly1305_draft "chacha20-poly1305-draft" -#define NID_chacha20_poly1305_draft 1204 +#define NID_chacha20_poly1305_draft 1205 #define SN_chacha20 "ChaCha20" #define LN_chacha20 "chacha20" diff --git a/include/openssl/objectserr.h b/include/openssl/objectserr.h index 6e70e960..2fe8cc40 100644 --- a/include/openssl/objectserr.h +++ b/include/openssl/objectserr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_OBJERR_H # define HEADER_OBJERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/ocsperr.h b/include/openssl/ocsperr.h index 25df8c1c..18e92cea 100644 --- a/include/openssl/ocsperr.h +++ b/include/openssl/ocsperr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_OCSPERR_H # define HEADER_OCSPERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # include # ifndef OPENSSL_NO_OCSP diff --git a/include/openssl/ossl_typ.h b/include/openssl/ossl_typ.h index 9b97e3d3..07e5f029 100644 --- a/include/openssl/ossl_typ.h +++ b/include/openssl/ossl_typ.h @@ -18,6 +18,8 @@ extern "C" { # include +typedef struct ossl_provider_st OSSL_PROVIDER; /* Provider Object */ + # ifdef NO_ASN1_TYPEDEFS # define ASN1_INTEGER ASN1_STRING # define ASN1_ENUMERATED ASN1_STRING diff --git a/include/openssl/params.h b/include/openssl/params.h new file mode 100644 index 00000000..10ed28d3 --- /dev/null +++ b/include/openssl/params.h @@ -0,0 +1,186 @@ +/* + * 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 + */ + +#ifndef HEADER_PARAMS_H +# define HEADER_PARAMS_H + +# include +# include + +# ifdef __cplusplus +extern "C" { +# endif + +# define OSSL_PARAM_END \ + { NULL, 0, NULL, 0, NULL } + +# define OSSL_PARAM_DEFN(key, type, addr, sz, rsz) \ + { (key), (type), (addr), (sz), (rsz) } + +/* Basic parameter types without return sizes */ +# define OSSL_PARAM_int(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int), NULL) +# define OSSL_PARAM_uint(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ + sizeof(unsigned int), NULL) +# define OSSL_PARAM_long(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int), \ + NULL) +# define OSSL_PARAM_ulong(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ + sizeof(unsigned long int), NULL) +# define OSSL_PARAM_int32(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t), NULL) +# define OSSL_PARAM_uint32(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ + sizeof(uint32_t), NULL) +# define OSSL_PARAM_int64(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t), NULL) +# define OSSL_PARAM_uint64(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \ + sizeof(uint64_t), NULL) +# define OSSL_PARAM_size_t(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(size_t), \ + NULL) +# define OSSL_PARAM_double(key, addr) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double), NULL) + +# define OSSL_PARAM_utf8_string(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz, NULL) +# define OSSL_PARAM_octet_string(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz, NULL) + +# define OSSL_PARAM_utf8_ptr(key, addr, sz) \ + OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, &(addr), sz, NULL) +# 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)) + +/* Search an OSSL_PARAM array for a matching name */ +const OSSL_PARAM *OSSL_PARAM_locate(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_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); +OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf, + size_t bsize, size_t *rsize); +OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf, + size_t *rsize); +OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf, + size_t bsize, size_t *rsize); +OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf, + size_t *rsize); + +int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val); +int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val); +int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val); +int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val); +int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val); +int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val); +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_get_double(const OSSL_PARAM *p, double *val); +int OSSL_PARAM_set_double(const 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_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_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_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_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, + size_t used_len); + +# ifdef __cplusplus +} +# endif +#endif diff --git a/include/openssl/pemerr.h b/include/openssl/pemerr.h index 54548f3c..1213d75d 100644 --- a/include/openssl/pemerr.h +++ b/include/openssl/pemerr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_PEMERR_H # define HEADER_PEMERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/pkcs12err.h b/include/openssl/pkcs12err.h index d99ca649..d4a31f20 100644 --- a/include/openssl/pkcs12err.h +++ b/include/openssl/pkcs12err.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_PKCS12ERR_H # define HEADER_PKCS12ERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/pkcs7err.h b/include/openssl/pkcs7err.h index 909be11d..89fb4924 100644 --- a/include/openssl/pkcs7err.h +++ b/include/openssl/pkcs7err.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_PKCS7ERR_H # define HEADER_PKCS7ERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/provider.h b/include/openssl/provider.h new file mode 100644 index 00000000..7dc5b8ae --- /dev/null +++ b/include/openssl/provider.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 OSSL_PROVIDER_H +# define OSSL_PROVIDER_H + +# include + +# ifdef __cplusplus +extern "C" { +# endif + +/* Load and unload a provider */ +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[]); + +/* Add a built in providers */ +int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *, const char *name, + OSSL_provider_init_fn *init_fn); + +# ifdef __cplusplus +} +# endif + +#endif diff --git a/include/openssl/randerr.h b/include/openssl/randerr.h index bdfbd00c..26c20ae9 100644 --- a/include/openssl/randerr.h +++ b/include/openssl/randerr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_RANDERR_H # define HEADER_RANDERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/rsaerr.h b/include/openssl/rsaerr.h index 186cabb6..0c381002 100644 --- a/include/openssl/rsaerr.h +++ b/include/openssl/rsaerr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_RSAERR_H # define HEADER_RSAERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif @@ -35,6 +39,7 @@ int ERR_load_RSA_strings(void); # define RSA_F_RSA_CHECK_KEY_EX 160 # define RSA_F_RSA_CMS_DECRYPT 159 # define RSA_F_RSA_CMS_VERIFY 158 +# define RSA_F_RSA_FIPS186_4_GEN_PROB_PRIMES 168 # define RSA_F_RSA_ITEM_VERIFY 148 # define RSA_F_RSA_METH_DUP 161 # define RSA_F_RSA_METH_NEW 162 @@ -78,6 +83,10 @@ int ERR_load_RSA_strings(void); # define RSA_F_RSA_SETUP_BLINDING 136 # define RSA_F_RSA_SIGN 117 # define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 +# define RSA_F_RSA_SP800_56B_CHECK_KEYPAIR 169 +# define RSA_F_RSA_SP800_56B_CHECK_PUBLIC 170 +# define RSA_F_RSA_SP800_56B_PAIRWISE_TEST 171 +# define RSA_F_RSA_SP800_56B_VALIDATE_STRENGTH 172 # define RSA_F_RSA_VERIFY 119 # define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 120 # define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1 126 @@ -110,16 +119,21 @@ int ERR_load_RSA_strings(void); # define RSA_R_INVALID_DIGEST 157 # define RSA_R_INVALID_DIGEST_LENGTH 143 # define RSA_R_INVALID_HEADER 137 +# define RSA_R_INVALID_KEYPAIR 171 +# define RSA_R_INVALID_KEY_LENGTH 173 # define RSA_R_INVALID_LABEL 160 # define RSA_R_INVALID_MESSAGE_LENGTH 131 # define RSA_R_INVALID_MGF1_MD 156 +# define RSA_R_INVALID_MODULUS 174 # define RSA_R_INVALID_MULTI_PRIME_KEY 167 # define RSA_R_INVALID_OAEP_PARAMETERS 161 # define RSA_R_INVALID_PADDING 138 # define RSA_R_INVALID_PADDING_MODE 141 # define RSA_R_INVALID_PSS_PARAMETERS 149 # define RSA_R_INVALID_PSS_SALTLEN 146 +# define RSA_R_INVALID_REQUEST 175 # define RSA_R_INVALID_SALT_LENGTH 150 +# define RSA_R_INVALID_STRENGTH 176 # define RSA_R_INVALID_TRAILER 139 # define RSA_R_INVALID_X931_DIGEST 142 # define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 @@ -138,8 +152,10 @@ int ERR_load_RSA_strings(void); # define RSA_R_OAEP_DECODING_ERROR 121 # define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148 # define RSA_R_PADDING_CHECK_FAILED 114 +# define RSA_R_PAIRWISE_TEST_FAILURE 177 # define RSA_R_PKCS_DECODING_ERROR 159 # define RSA_R_PSS_SALTLEN_TOO_SMALL 164 +# define RSA_R_PUB_EXPONENT_OUT_OF_RANGE 178 # define RSA_R_P_NOT_PRIME 128 # define RSA_R_Q_NOT_PRIME 129 # define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 diff --git a/include/openssl/sslerr.h b/include/openssl/sslerr.h index 77910bad..fac8736d 100644 --- a/include/openssl/sslerr.h +++ b/include/openssl/sslerr.h @@ -11,6 +11,10 @@ #ifndef HEADER_SSLERR_H # define HEADER_SSLERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/storeerr.h b/include/openssl/storeerr.h index 3e042cc2..0571fa5a 100644 --- a/include/openssl/storeerr.h +++ b/include/openssl/storeerr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_OSSL_STOREERR_H # define HEADER_OSSL_STOREERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/trace.h b/include/openssl/trace.h index da0ba0b5..767b19fa 100644 --- a/include/openssl/trace.h +++ b/include/openssl/trace.h @@ -95,7 +95,7 @@ typedef size_t (*OSSL_trace_cb)(const char *buffer, size_t count, * Possible |cmd| numbers. */ # define OSSL_TRACE_CTRL_BEGIN 0 -# define OSSL_TRACE_CTRL_DURING 1 +# define OSSL_TRACE_CTRL_WRITE 1 # define OSSL_TRACE_CTRL_END 2 /* diff --git a/include/openssl/tserr.h b/include/openssl/tserr.h index 0a2dd159..e492981e 100644 --- a/include/openssl/tserr.h +++ b/include/openssl/tserr.h @@ -11,6 +11,10 @@ #ifndef HEADER_TSERR_H # define HEADER_TSERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # include # ifndef OPENSSL_NO_TS diff --git a/include/openssl/uierr.h b/include/openssl/uierr.h index 5746135d..98244b3c 100644 --- a/include/openssl/uierr.h +++ b/include/openssl/uierr.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_UIERR_H # define HEADER_UIERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/include/openssl/x509.h b/include/openssl/x509.h index bf127c07..4de88bd5 100644 --- a/include/openssl/x509.h +++ b/include/openssl/x509.h @@ -566,6 +566,11 @@ void X509_get0_signature(const ASN1_BIT_STRING **psig, const X509_ALGOR **palg, const X509 *x); int X509_get_signature_nid(const X509 *x); +# ifndef OPENSSL_NO_SM2 +void X509_set_sm2_id(X509 *x, ASN1_OCTET_STRING *sm2_id); +ASN1_OCTET_STRING *X509_get0_sm2_id(X509 *x); +# endif + int X509_trusted(const X509 *x); int X509_alias_set1(X509 *x, const unsigned char *name, int len); int X509_keyid_set1(X509 *x, const unsigned char *id, int len); diff --git a/include/openssl/x509err.h b/include/openssl/x509err.h index 33b78e4f..78d1c893 100644 --- a/include/openssl/x509err.h +++ b/include/openssl/x509err.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_X509ERR_H # define HEADER_X509ERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif @@ -78,8 +82,10 @@ int ERR_load_X509_strings(void); # define X509_F_X509_TO_X509_REQ 126 # define X509_F_X509_TRUST_ADD 133 # define X509_F_X509_TRUST_SET 141 +# define X509_F_X509_VERIFY 161 # define X509_F_X509_VERIFY_CERT 127 # define X509_F_X509_VERIFY_PARAM_NEW 159 +# define X509_F_X509_VERIFY_SM2 162 /* * X509 reason codes. diff --git a/include/openssl/x509v3err.h b/include/openssl/x509v3err.h index 64648427..1d91d097 100644 --- a/include/openssl/x509v3err.h +++ b/include/openssl/x509v3err.h @@ -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 @@ -11,6 +11,10 @@ #ifndef HEADER_X509V3ERR_H # define HEADER_X509V3ERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + # ifdef __cplusplus extern "C" # endif diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index e801d3b4..df92f518 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -1685,6 +1685,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, } } OPENSSL_free(co_list); /* Not needed any longer */ + co_list = NULL; OSSL_TRACE_END(TLS_CIPHER); if (!update_cipher_list_by_id(cipher_list_by_id, cipherstack)) @@ -1705,9 +1706,6 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, *cipher_list = pref_list; pref_list = NULL; - // sk_SSL_CIPHER_free(*cipher_list); - // *cipher_list = cipherstack; - return cipherstack; err: diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 8f462b71..9828b43b 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -2649,21 +2649,14 @@ STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx) /* * Distinguish between ciphers controlled by set_ciphersuite() and * set_cipher_list() when counting. + * Enabled "TLS13+AESGCM+AES128" or the others. */ static int cipher_list_tls12_num(STACK_OF(SSL_CIPHER) *sk) { - int i, num = 0; - const SSL_CIPHER *c; - if (sk == NULL) return 0; - for (i = 0; i < sk_SSL_CIPHER_num(sk); ++i) { - c = sk_SSL_CIPHER_value(sk, i); - if (c->min_tls >= TLS1_3_VERSION) - continue; - num++; - } - return num; + else + return sk_SSL_CIPHER_num(sk); } /** specify the ciphers to be used by default by the SSL_CTX */ diff --git a/test/asn1_encode_test.c b/test/asn1_encode_test.c index 18c46459..64f8f175 100644 --- a/test/asn1_encode_test.c +++ b/test/asn1_encode_test.c @@ -396,7 +396,7 @@ static ASN1_INT64_DATA int64_expected[] = { CUSTOM_EXPECTED_FAILURE, /* t_8bytes_3_pad (illegal padding) */ CUSTOM_EXPECTED_SUCCESS(INT64_MIN, INT64_MIN), /* t_8bytes_4_neg */ CUSTOM_EXPECTED_FAILURE, /* t_8bytes_5_negpad (illegal padding) */ - CUSTOM_EXPECTED_SUCCESS(0x1ffffffff, 0x1ffffffff), /* t_5bytes_1 */ + CUSTOM_EXPECTED_SUCCESS(0x1ffffffffULL, 0x1ffffffffULL), /* t_5bytes_1 */ CUSTOM_EXPECTED_SUCCESS(0x80000000, 0x80000000), /* t_4bytes_1 */ CUSTOM_EXPECTED_SUCCESS(INT32_MAX - 1, INT32_MAX -1), /* t_4bytes_2 */ CUSTOM_EXPECTED_FAILURE, /* t_4bytes_3_pad (illegal padding) */ @@ -446,7 +446,7 @@ static ASN1_UINT64_DATA uint64_expected[] = { CUSTOM_EXPECTED_FAILURE, /* t_8bytes_3_pad */ CUSTOM_EXPECTED_FAILURE, /* t_8bytes_4_neg */ CUSTOM_EXPECTED_FAILURE, /* t_8bytes_5_negpad */ - CUSTOM_EXPECTED_SUCCESS(0x1ffffffff, 0x1ffffffff), /* t_5bytes_1 */ + CUSTOM_EXPECTED_SUCCESS(0x1ffffffffULL, 0x1ffffffffULL), /* t_5bytes_1 */ CUSTOM_EXPECTED_SUCCESS(0x80000000, 0x80000000), /* t_4bytes_1 */ CUSTOM_EXPECTED_SUCCESS(INT32_MAX - 1, INT32_MAX -1), /* t_4bytes_2 */ CUSTOM_EXPECTED_FAILURE, /* t_4bytes_3_pad (illegal padding) */ diff --git a/test/bioprinttest.c b/test/bioprinttest.c index 97151cdf..14f0bfe5 100644 --- a/test/bioprinttest.c +++ b/test/bioprinttest.c @@ -146,14 +146,14 @@ typedef struct j_data_st { } j_data; static j_data jf_data[] = { - { 0xffffffffffffffffU, "%ju", "18446744073709551615" }, - { 0xffffffffffffffffU, "%jx", "ffffffffffffffff" }, - { 0x8000000000000000U, "%ju", "9223372036854775808" }, + { 0xffffffffffffffffULL, "%ju", "18446744073709551615" }, + { 0xffffffffffffffffULL, "%jx", "ffffffffffffffff" }, + { 0x8000000000000000ULL, "%ju", "9223372036854775808" }, /* * These tests imply two's-complement, but it's the only binary * representation we support, see test/sanitytest.c... */ - { 0x8000000000000000U, "%ji", "-9223372036854775808" }, + { 0x8000000000000000ULL, "%ji", "-9223372036854775808" }, }; static int test_j(int i) diff --git a/test/bn_internal_test.c b/test/bn_internal_test.c new file mode 100644 index 00000000..eabeaf8b --- /dev/null +++ b/test/bn_internal_test.c @@ -0,0 +1,103 @@ +/* + * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (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 +#include +#include +#include "internal/nelem.h" +#include "internal/numbers.h" +#include "testutil.h" +#include "bn_prime.h" +#include "internal/bn_int.h" + +static BN_CTX *ctx; + +static int test_is_prime_enhanced(void) +{ + int ret; + int status = 0; + BIGNUM *bn = NULL; + + ret = TEST_ptr(bn = BN_new()) + /* test passing a prime returns the correct status */ + && TEST_true(BN_set_word(bn, 11)) + /* return extra parameters related to composite */ + && TEST_true(bn_miller_rabin_is_prime(bn, 10, ctx, NULL, 1, &status)) + && TEST_int_eq(status, BN_PRIMETEST_PROBABLY_PRIME); + BN_free(bn); + return ret; +} + +static int composites[] = { + 9, 21, 77, 81, 265 +}; + +static int test_is_composite_enhanced(int id) +{ + int ret; + int status = 0; + BIGNUM *bn = NULL; + + ret = TEST_ptr(bn = BN_new()) + /* negative tests for different composite numbers */ + && TEST_true(BN_set_word(bn, composites[id])) + && TEST_true(bn_miller_rabin_is_prime(bn, 10, ctx, NULL, 1, &status)) + && TEST_int_ne(status, BN_PRIMETEST_PROBABLY_PRIME); + + BN_free(bn); + return ret; +} + +/* Test that multiplying all the small primes from 3 to 751 equals a constant. + * This test is mainly used to test that both 32 and 64 bit are correct. + */ +static int test_bn_small_factors(void) +{ + int ret = 0, i; + BIGNUM *b = NULL; + + if (!(TEST_ptr(b = BN_new()) && TEST_true(BN_set_word(b, 3)))) + goto err; + + for (i = 1; i < NUMPRIMES; i++) { + prime_t p = primes[i]; + if (p > 3 && p <= 751) + BN_mul_word(b, p); + if (p > 751) + break; + } + ret = TEST_BN_eq(bn_get0_small_factors(), b); +err: + BN_free(b); + return ret; +} + +int setup_tests(void) +{ + if (!TEST_ptr(ctx = BN_CTX_new())) + return 0; + + ADD_TEST(test_is_prime_enhanced); + ADD_ALL_TESTS(test_is_composite_enhanced, (int)OSSL_NELEM(composites)); + ADD_TEST(test_bn_small_factors); + + return 1; +} + +void cleanup_tests(void) +{ + BN_CTX_free(ctx); +} + diff --git a/test/build.info b/test/build.info index 4dd400f6..13d66308 100644 --- a/test/build.info +++ b/test/build.info @@ -34,7 +34,7 @@ IF[{- !$disabled{tests} -}] bftest ssltest_old dsatest dsa_no_digest_size_test exptest rsa_test \ evp_test evp_extra_test igetest v3nametest v3ext \ crltest danetest bad_dtls_test lhash_test sparse_array_test \ - conf_include_test \ + conf_include_test params_api_test \ constant_time_test verify_extra_test clienthellotest \ packettest asynctest secmemtest srptest memleaktest stack_test \ dtlsv1listentest ct_test threadstest afalgtest d2i_test \ @@ -50,7 +50,7 @@ IF[{- !$disabled{tests} -}] time_offset_test pemtest ssl_cert_table_internal_test ciphername_test \ servername_test ocspapitest rsa_mp_test fatalerrtest tls13ccstest \ sysdefaulttest errtest gosttest \ - context_internal_test aesgcmtest + context_internal_test aesgcmtest params_test SOURCE[versions]=versions.c INCLUDE[versions]=../include ../apps/include @@ -307,6 +307,10 @@ IF[{- !$disabled{tests} -}] INCLUDE[bioprinttest]=../include ../apps/include DEPEND[bioprinttest]=../libcrypto libtestutil.a + SOURCE[params_api_test]=params_api_test.c + INCLUDE[params_api_test]=../include ../apps/include + DEPEND[params_api_test]=../libcrypto libtestutil.a + SOURCE[sslapitest]=sslapitest.c ssltestlib.c INCLUDE[sslapitest]=../include ../apps/include .. DEPEND[sslapitest]=../libcrypto ../libssl libtestutil.a @@ -445,7 +449,9 @@ IF[{- !$disabled{tests} -}] IF[1] PROGRAMS{noinst}=asn1_internal_test modes_internal_test x509_internal_test \ tls13encryptiontest wpackettest ctype_internal_test \ - rdrand_sanitytest property_test + rdrand_sanitytest property_test \ + rsa_sp800_56b_test bn_internal_test + IF[{- !$disabled{poly1305} -}] PROGRAMS{noinst}=poly1305_internal_test ENDIF @@ -528,6 +534,14 @@ IF[{- !$disabled{tests} -}] SOURCE[rdrand_sanitytest]=rdrand_sanitytest.c INCLUDE[rdrand_sanitytest]=../include ../apps/include DEPEND[rdrand_sanitytest]=../libcrypto.a libtestutil.a + + SOURCE[rsa_sp800_56b_test]=rsa_sp800_56b_test.c + INCLUDE[rsa_sp800_56b_test]=.. ../include ../crypto/include ../crypto/rsa ../apps/include + DEPEND[rsa_sp800_56b_test]=../libcrypto.a libtestutil.a + + SOURCE[bn_internal_test]=bn_internal_test.c + INCLUDE[bn_internal_test]=.. ../include ../crypto/include ../crypto/bn ../apps/include + DEPEND[bn_internal_test]=../libcrypto.a libtestutil.a ENDIF IF[{- !$disabled{mdc2} -}] @@ -578,6 +592,34 @@ IF[{- !$disabled{tests} -}] SOURCE[context_internal_test]=context_internal_test.c INCLUDE[context_internal_test]=.. ../include ../apps/include DEPEND[context_internal_test]=../libcrypto.a libtestutil.a + + PROGRAMS{noinst}=provider_internal_test + DEFINE[provider_internal_test]=PROVIDER_INIT_FUNCTION_NAME=p_test_init + SOURCE[provider_internal_test]=provider_internal_test.c p_test.c + INCLUDE[provider_internal_test]=../include ../apps/include + DEPEND[provider_internal_test]=../libcrypto.a libtestutil.a + PROGRAMS{noinst}=provider_test + DEFINE[provider_test]=PROVIDER_INIT_FUNCTION_NAME=p_test_init + SOURCE[provider_test]=provider_test.c p_test.c + INCLUDE[provider_test]=../include ../apps/include + DEPEND[provider_test]=../libcrypto.a libtestutil.a + IF[{- !$disabled{shared} -}] + MODULES{noinst}=p_test + SOURCE[p_test]=p_test.c + INCLUDE[p_test]=../include + IF[{- defined $target{shared_defflag} -}] + SOURCE[p_test]=p_test.ld + GENERATE[p_test.ld]=../util/providers.num + ENDIF + ELSE + DEFINE[provider_test]=OPENSSL_NO_SHARED + DEFINE[provider_internal_test]=OPENSSL_NO_SHARED + ENDIF + + PROGRAMS{noinst}=params_test + SOURCE[params_test]=params_test.c + INCLUDE[params_test]=.. ../include ../apps/include + DEPEND[params_test]=../libcrypto.a libtestutil.a ENDIF {- diff --git a/test/ct_test.c b/test/ct_test.c index e1cc148e..8f1e1990 100644 --- a/test/ct_test.c +++ b/test/ct_test.c @@ -63,7 +63,7 @@ static CT_TEST_FIXTURE *set_up(const char *const test_case_name) if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture)))) goto end; fixture->test_case_name = test_case_name; - fixture->epoch_time_in_ms = 1473269626000; /* Sep 7 17:33:46 2016 GMT */ + fixture->epoch_time_in_ms = 1473269626000ULL; /* Sep 7 17:33:46 2016 GMT */ if (!TEST_ptr(fixture->ctlog_store = CTLOG_STORE_new()) || !TEST_int_eq( CTLOG_STORE_load_default_file(fixture->ctlog_store), 1)) @@ -423,7 +423,7 @@ static int test_verify_fails_for_future_sct(void) SETUP_CT_TEST_FIXTURE(); if (fixture == NULL) return 0; - fixture->epoch_time_in_ms = 1365094800000; /* Apr 4 17:00:00 2013 GMT */ + fixture->epoch_time_in_ms = 1365094800000ULL; /* Apr 4 17:00:00 2013 GMT */ fixture->certs_dir = certs_dir; fixture->certificate_file = "embeddedSCTs1.pem"; fixture->issuer_file = "embeddedSCTs1_issuer.pem"; diff --git a/test/ectest.c b/test/ectest.c index 0f425979..59c7e99d 100644 --- a/test/ectest.c +++ b/test/ectest.c @@ -1440,6 +1440,75 @@ err: BN_CTX_free(ctx); return r; } + +/* + * Tests a point known to cause an incorrect underflow in an old version of + * ecp_nist521.c + */ +static int underflow_test(void) +{ + BN_CTX *ctx = NULL; + EC_GROUP *grp = NULL; + EC_POINT *P = NULL, *Q = NULL, *R = NULL; + BIGNUM *x1 = NULL, *y1 = NULL, *z1 = NULL, *x2 = NULL, *y2 = NULL; + BIGNUM *k = NULL; + int testresult = 0; + const char *x1str = + "1534f0077fffffe87e9adcfe000000000000000000003e05a21d2400002e031b1f4" + "b80000c6fafa4f3c1288798d624a247b5e2ffffffffffffffefe099241900004"; + const char *p521m1 = + "1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"; + + ctx = BN_CTX_new(); + if (!TEST_ptr(ctx)) + return 0; + + BN_CTX_start(ctx); + x1 = BN_CTX_get(ctx); + y1 = BN_CTX_get(ctx); + z1 = BN_CTX_get(ctx); + x2 = BN_CTX_get(ctx); + y2 = BN_CTX_get(ctx); + k = BN_CTX_get(ctx); + if (!TEST_ptr(k)) + goto err; + + grp = EC_GROUP_new_by_curve_name(NID_secp521r1); + P = EC_POINT_new(grp); + Q = EC_POINT_new(grp); + R = EC_POINT_new(grp); + if (!TEST_ptr(grp) || !TEST_ptr(P) || !TEST_ptr(Q) || !TEST_ptr(R)) + goto err; + + if (!TEST_int_gt(BN_hex2bn(&x1, x1str), 0) + || !TEST_int_gt(BN_hex2bn(&y1, p521m1), 0) + || !TEST_int_gt(BN_hex2bn(&z1, p521m1), 0) + || !TEST_int_gt(BN_hex2bn(&k, "02"), 0) + || !TEST_true(EC_POINT_set_Jprojective_coordinates_GFp(grp, P, x1, + y1, z1, ctx)) + || !TEST_true(EC_POINT_mul(grp, Q, NULL, P, k, ctx)) + || !TEST_true(EC_POINT_get_affine_coordinates(grp, Q, x1, y1, ctx)) + || !TEST_true(EC_POINT_dbl(grp, R, P, ctx)) + || !TEST_true(EC_POINT_get_affine_coordinates(grp, R, x2, y2, ctx))) + goto err; + + if (!TEST_int_eq(BN_cmp(x1, x2), 0) + || !TEST_int_eq(BN_cmp(y1, y2), 0)) + goto err; + + testresult = 1; + + err: + BN_CTX_end(ctx); + EC_POINT_free(P); + EC_POINT_free(Q); + EC_POINT_free(R); + EC_GROUP_free(grp); + BN_CTX_free(ctx); + + return testresult; +} # endif static const unsigned char p521_named[] = { @@ -1547,6 +1616,7 @@ int setup_tests(void) # endif # ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 ADD_ALL_TESTS(nistp_single_test, OSSL_NELEM(nistp_tests_params)); + ADD_TEST(underflow_test); # endif ADD_ALL_TESTS(internal_curve_test, crv_len); ADD_ALL_TESTS(internal_curve_test_method, crv_len); diff --git a/test/p_test.c b/test/p_test.c new file mode 100644 index 00000000..9e1ba8ed --- /dev/null +++ b/test/p_test.c @@ -0,0 +1,110 @@ +/* + * 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 + */ + +/* + * This is a very simple provider that does absolutely nothing except respond + * to provider global parameter requests. It does this by simply echoing back + * a parameter request it makes to the loading library. + */ + +#include +#include + +/* + * When built as an object file to link the application with, we get the + * init function name through the macro PROVIDER_INIT_FUNCTION_NAME. If + * not defined, we use the standard init function name for the shared + * object form. + */ +#ifdef PROVIDER_INIT_FUNCTION_NAME +# define OSSL_provider_init PROVIDER_INIT_FUNCTION_NAME +#endif + +#include +#include + +static OSSL_core_get_param_types_fn *c_get_param_types = NULL; +static OSSL_core_get_params_fn *c_get_params = NULL; + +/* Tell the core what params we provide and what type they are */ +static const OSSL_ITEM p_param_types[] = { + { OSSL_PARAM_UTF8_STRING, "greeting" }, + { 0, NULL } +}; + +static const OSSL_ITEM *p_get_param_types(const OSSL_PROVIDER *_) +{ + return p_param_types; +} + +static int p_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]) +{ + const OSSL_PARAM *p = params; + int ok = 1; + + for (; ok && p->key != NULL; p++) { + if (strcmp(p->key, "greeting") == 0) { + static char *opensslv = NULL; + static char *provname = NULL; + static OSSL_PARAM counter_request[] = { + { "openssl-version", OSSL_PARAM_UTF8_PTR, + &opensslv, sizeof(&opensslv), NULL }, + { "provider-name", OSSL_PARAM_UTF8_PTR, + &provname, sizeof(&provname), NULL}, + { NULL, 0, NULL, 0, NULL } + }; + char buf[256]; + size_t buf_l; + + if (c_get_params(prov, counter_request)) { + const char *versionp = *(void **)counter_request[0].data; + const char *namep = *(void **)counter_request[1].data; + sprintf(buf, "Hello OpenSSL %.20s, greetings from %s!", + versionp, namep); + } else { + sprintf(buf, "Howdy stranger..."); + } + + *p->return_size = buf_l = strlen(buf) + 1; + if (p->data_size >= buf_l) + strncpy(p->data, buf, buf_l); + else + ok = 0; + } + } + return ok; +} + +static const OSSL_DISPATCH p_test_table[] = { + { OSSL_FUNC_PROVIDER_GET_PARAM_TYPES, (void (*)(void))p_get_param_types }, + { OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))p_get_params }, + { 0, NULL } +}; + +int OSSL_provider_init(const OSSL_PROVIDER *provider, + const OSSL_DISPATCH *in, + const OSSL_DISPATCH **out) +{ + for (; in->function_id != 0; in++) { + switch (in->function_id) { + case OSSL_FUNC_CORE_GET_PARAM_TYPES: + c_get_param_types = OSSL_get_core_get_param_types(in); + break; + case OSSL_FUNC_CORE_GET_PARAMS: + c_get_params = OSSL_get_core_get_params(in); + break; + default: + /* Just ignore anything we don't understand */ + break; + } + } + + *out = p_test_table; + return 1; +} diff --git a/test/params_api_test.c b/test/params_api_test.c new file mode 100644 index 00000000..77b8af4f --- /dev/null +++ b/test/params_api_test.c @@ -0,0 +1,627 @@ +/* + * 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 +#include "testutil.h" +#include "internal/nelem.h" +#include +#include + +/* The maximum size of the static buffers used to test most things */ +#define MAX_LEN 20 + +static void swap_copy(unsigned char *out, const void *in, size_t len) +{ + size_t j; + + for (j = 0; j < len; j++) + out[j] = ((unsigned char *)in)[len - j - 1]; +} + +static void copy_to_le(unsigned char *out, const void *in, size_t len) +{ +#ifdef B_ENDIAN + swap_copy(out, in, len); +#else + memcpy(out, in, len); +#endif +} + +static void copy_be_to_native(unsigned char *out, const void *in, size_t len) +{ +#ifdef B_ENDIAN + memcpy(out, in, len); +#else + swap_copy(out, in, len); +#endif +} + +static const struct { + size_t len; + unsigned char value[MAX_LEN]; +} raw_values[] = { + { 4, { 0x38, 0x27, 0xbf, 0x3b } }, + { 4, { 0x9f, 0x26, 0x48, 0x22 } }, + { 8, { 0x59, 0xb2, 0x1a, 0xe9, 0x2a, 0xd8, 0x46, 0x40 } }, + { 8, { 0xb4, 0xae, 0xbd, 0xb4, 0xdd, 0x04, 0xb1, 0x4c } }, + { 16, { 0x61, 0xe8, 0x7e, 0x31, 0xe9, 0x33, 0x83, 0x3d, + 0x87, 0x99, 0xc7, 0xd8, 0x5d, 0xa9, 0x8b, 0x42 } }, + { 16, { 0xee, 0x6e, 0x8b, 0xc3, 0xec, 0xcf, 0x37, 0xcc, + 0x89, 0x67, 0xf2, 0x68, 0x33, 0xa0, 0x14, 0xb0 } }, +}; + +static int test_param_type_extra(const OSSL_PARAM *param, unsigned char *cmp, + size_t width) +{ + int32_t i32; + int64_t i64; + size_t s, sz; + unsigned char buf[MAX_LEN]; + const int bit32 = param->data_size == sizeof(int32_t); + const int sizet = bit32 && sizeof(size_t) > sizeof(int32_t); + const int signd = param->data_type == OSSL_PARAM_INTEGER; + + if (signd) { + if ((bit32 && !TEST_true(OSSL_PARAM_get_int32(param, &i32))) + || !TEST_true(OSSL_PARAM_get_int64(param, &i64))) + return 0; + } else { + if ((bit32 + && !TEST_true(OSSL_PARAM_get_uint32(param, (uint32_t *)&i32))) + || !TEST_true(OSSL_PARAM_get_uint64(param, (uint64_t *)&i64)) + || (sizet && !TEST_true(OSSL_PARAM_get_size_t(param, &s)))) + return 0; + } + + /* Check signed types */ + if (bit32) { + copy_to_le(buf, &i32, sizeof(i32)); + sz = sizeof(i32) < width ? sizeof(i32) : width; + if (!TEST_mem_eq(buf, sz, cmp, sz)) + return 0; + } + copy_to_le(buf, &i64, sizeof(i64)); + sz = sizeof(i64) < width ? sizeof(i64) : width; + if (!TEST_mem_eq(buf, sz, cmp, sz)) + return 0; + if (sizet && !signd) { + copy_to_le(buf, &s, sizeof(s)); + sz = sizeof(s) < width ? sizeof(s) : width; + if (!TEST_mem_eq(buf, sz, cmp, sz)) + return 0; + } + + /* Check a widening write if possible */ + if (sizeof(size_t) > width) { + if (signd) { + if (!TEST_true(OSSL_PARAM_set_int32(param, 12345)) + || !TEST_true(OSSL_PARAM_get_int64(param, &i64)) + || !TEST_size_t_eq(i64, 12345)) + return 0; + } else { + if (!TEST_true(OSSL_PARAM_set_uint32(param, 12345)) + || !TEST_true(OSSL_PARAM_get_uint64(param, (uint64_t *)&i64)) + || !TEST_size_t_eq(i64, 12345)) + return 0; + } + } + return 1; +} + +/* + * The test cases for each of the bastic integral types are similar. + * For each type, a param of that type is set and an attempt to read it + * get is made. Finally, the above function is called to verify that + * the params can be read as other types. + * + * All the real work is done via byte buffers which are converted to machine + * byte order and to little endian for comparisons. Narrower values are best + * compared using little endian because their values and positions don't + * change. + */ + +static int test_param_int(int n) +{ + int in, out; + unsigned char buf[MAX_LEN], le[MAX_LEN], cmp[sizeof(int)]; + const size_t len = raw_values[n].len >= sizeof(int) ? + sizeof(int) : raw_values[n].len; + OSSL_PARAM param = OSSL_PARAM_int("a", NULL); + + memset(buf, 0, sizeof(buf)); + memset(le, 0, sizeof(le)); + copy_be_to_native(buf, raw_values[n].value, len); + swap_copy(le, raw_values[n].value, len); + memcpy(&in, buf, sizeof(in)); + param.data = &out; + if (!TEST_true(OSSL_PARAM_set_int(¶m, in))) + return 0; + copy_to_le(cmp, &out, sizeof(out)); + if (!TEST_mem_eq(cmp, len, le, len)) + return 0; + in = 0; + param.data = buf; + if (!TEST_true(OSSL_PARAM_get_int(¶m, &in))) + return 0; + copy_to_le(cmp, &in, sizeof(in)); + if (!TEST_mem_eq(cmp, sizeof(in), le, sizeof(in))) + return 0; + param.data = &out; + return test_param_type_extra(¶m, le, sizeof(int)); +} + +static int test_param_long(int n) +{ + long int in, out; + unsigned char buf[MAX_LEN], le[MAX_LEN], cmp[sizeof(long int)]; + const size_t len = raw_values[n].len >= sizeof(long int) + ? sizeof(long int) : raw_values[n].len; + OSSL_PARAM param = OSSL_PARAM_long("a", NULL); + + memset(buf, 0, sizeof(buf)); + memset(le, 0, sizeof(le)); + copy_be_to_native(buf, raw_values[n].value, len); + swap_copy(le, raw_values[n].value, len); + memcpy(&in, buf, sizeof(in)); + param.data = &out; + if (!TEST_true(OSSL_PARAM_set_long(¶m, in))) + return 0; + copy_to_le(cmp, &out, sizeof(out)); + if (!TEST_mem_eq(cmp, len, le, len)) + return 0; + in = 0; + param.data = buf; + if (!TEST_true(OSSL_PARAM_get_long(¶m, &in))) + return 0; + copy_to_le(cmp, &in, sizeof(in)); + if (!TEST_mem_eq(cmp, sizeof(in), le, sizeof(in))) + return 0; + param.data = &out; + return test_param_type_extra(¶m, le, sizeof(long int)); +} + +static int test_param_uint(int n) +{ + unsigned int in, out; + unsigned char buf[MAX_LEN], le[MAX_LEN], cmp[sizeof(unsigned int)]; + const size_t len = raw_values[n].len >= sizeof(unsigned int) ? sizeof(unsigned int) : raw_values[n].len; + OSSL_PARAM param = OSSL_PARAM_uint("a", NULL); + memset(buf, 0, sizeof(buf)); + memset(le, 0, sizeof(le)); + copy_be_to_native(buf, raw_values[n].value, len); + swap_copy(le, raw_values[n].value, len); + memcpy(&in, buf, sizeof(in)); + param.data = &out; + if (!TEST_true(OSSL_PARAM_set_uint(¶m, in))) + return 0; + copy_to_le(cmp, &out, sizeof(out)); + if (!TEST_mem_eq(cmp, len, le, len)) + return 0; + in = 0; + param.data = buf; + if (!TEST_true(OSSL_PARAM_get_uint(¶m, &in))) + return 0; + copy_to_le(cmp, &in, sizeof(in)); + if (!TEST_mem_eq(cmp, sizeof(in), le, sizeof(in))) + return 0; + param.data = &out; + return test_param_type_extra(¶m, le, sizeof(unsigned int)); +} + +static int test_param_ulong(int n) +{ + unsigned long int in, out; + unsigned char buf[MAX_LEN], le[MAX_LEN], cmp[sizeof(unsigned long int)]; + const size_t len = raw_values[n].len >= sizeof(unsigned long int) + ? sizeof(unsigned long int) : raw_values[n].len; + OSSL_PARAM param = OSSL_PARAM_ulong("a", NULL); + memset(buf, 0, sizeof(buf)); + memset(le, 0, sizeof(le)); + copy_be_to_native(buf, raw_values[n].value, len); + swap_copy(le, raw_values[n].value, len); + memcpy(&in, buf, sizeof(in)); + param.data = &out; + if (!TEST_true(OSSL_PARAM_set_ulong(¶m, in))) + return 0; + copy_to_le(cmp, &out, sizeof(out)); + if (!TEST_mem_eq(cmp, len, le, len)) + return 0; + in = 0; + param.data = buf; + if (!TEST_true(OSSL_PARAM_get_ulong(¶m, &in))) + return 0; + copy_to_le(cmp, &in, sizeof(in)); + if (!TEST_mem_eq(cmp, sizeof(in), le, sizeof(in))) + return 0; + param.data = &out; + return test_param_type_extra(¶m, le, sizeof(unsigned long int)); +} + +static int test_param_int32(int n) +{ + int32_t in, out; + unsigned char buf[MAX_LEN], le[MAX_LEN], cmp[sizeof(int32_t)]; + const size_t len = raw_values[n].len >= sizeof(int32_t) + ? sizeof(int32_t) : raw_values[n].len; + OSSL_PARAM param = OSSL_PARAM_int32("a", NULL); + memset(buf, 0, sizeof(buf)); + memset(le, 0, sizeof(le)); + copy_be_to_native(buf, raw_values[n].value, len); + swap_copy(le, raw_values[n].value, len); + memcpy(&in, buf, sizeof(in)); + param.data = &out; + if (!TEST_true(OSSL_PARAM_set_int32(¶m, in))) + return 0; + copy_to_le(cmp, &out, sizeof(out)); + if (!TEST_mem_eq(cmp, len, le, len)) + return 0; + in = 0; + param.data = buf; + if (!TEST_true(OSSL_PARAM_get_int32(¶m, &in))) + return 0; + copy_to_le(cmp, &in, sizeof(in)); + if (!TEST_mem_eq(cmp, sizeof(in), le, sizeof(in))) + return 0; + param.data = &out; + return test_param_type_extra(¶m, le, sizeof(int32_t)); +} + +static int test_param_uint32(int n) +{ + uint32_t in, out; + unsigned char buf[MAX_LEN], le[MAX_LEN], cmp[sizeof(uint32_t)]; + const size_t len = raw_values[n].len >= sizeof(uint32_t) + ? sizeof(uint32_t) : raw_values[n].len; + OSSL_PARAM param = OSSL_PARAM_uint32("a", NULL); + memset(buf, 0, sizeof(buf)); + memset(le, 0, sizeof(le)); + copy_be_to_native(buf, raw_values[n].value, len); + swap_copy(le, raw_values[n].value, len); + memcpy(&in, buf, sizeof(in)); + param.data = &out; + if (!TEST_true(OSSL_PARAM_set_uint32(¶m, in))) + return 0; + copy_to_le(cmp, &out, sizeof(out)); + if (!TEST_mem_eq(cmp, len, le, len)) + return 0; + in = 0; + param.data = buf; + if (!TEST_true(OSSL_PARAM_get_uint32(¶m, &in))) + return 0; + copy_to_le(cmp, &in, sizeof(in)); + if (!TEST_mem_eq(cmp, sizeof(in), le, sizeof(in))) + return 0; + param.data = &out; + return test_param_type_extra(¶m, le, sizeof(uint32_t)); +} + +static int test_param_int64(int n) +{ + int64_t in, out; + unsigned char buf[MAX_LEN], le[MAX_LEN], cmp[sizeof(int64_t)]; + const size_t len = raw_values[n].len >= sizeof(int64_t) + ? sizeof(int64_t) : raw_values[n].len; + OSSL_PARAM param = OSSL_PARAM_int64("a", NULL); + memset(buf, 0, sizeof(buf)); + memset(le, 0, sizeof(le)); + copy_be_to_native(buf, raw_values[n].value, len); + swap_copy(le, raw_values[n].value, len); + memcpy(&in, buf, sizeof(in)); + param.data = &out; + if (!TEST_true(OSSL_PARAM_set_int64(¶m, in))) + return 0; + copy_to_le(cmp, &out, sizeof(out)); + if (!TEST_mem_eq(cmp, len, le, len)) + return 0; + in = 0; + param.data = buf; + if (!TEST_true(OSSL_PARAM_get_int64(¶m, &in))) + return 0; + copy_to_le(cmp, &in, sizeof(in)); + if (!TEST_mem_eq(cmp, sizeof(in), le, sizeof(in))) + return 0; + param.data = &out; + return test_param_type_extra(¶m, le, sizeof(int64_t)); +} + +static int test_param_uint64(int n) +{ + uint64_t in, out; + unsigned char buf[MAX_LEN], le[MAX_LEN], cmp[sizeof(uint64_t)]; + const size_t len = raw_values[n].len >= sizeof(uint64_t) + ? sizeof(uint64_t) : raw_values[n].len; + OSSL_PARAM param = OSSL_PARAM_uint64("a", NULL); + memset(buf, 0, sizeof(buf)); + memset(le, 0, sizeof(le)); + copy_be_to_native(buf, raw_values[n].value, len); + swap_copy(le, raw_values[n].value, len); + memcpy(&in, buf, sizeof(in)); + param.data = &out; + if (!TEST_true(OSSL_PARAM_set_uint64(¶m, in))) + return 0; + copy_to_le(cmp, &out, sizeof(out)); + if (!TEST_mem_eq(cmp, len, le, len)) + return 0; + in = 0; + param.data = buf; + if (!TEST_true(OSSL_PARAM_get_uint64(¶m, &in))) + return 0; + copy_to_le(cmp, &in, sizeof(in)); + if (!TEST_mem_eq(cmp, sizeof(in), le, sizeof(in))) + return 0; + param.data = &out; + return test_param_type_extra(¶m, le, sizeof(uint64_t)); +} + +static int test_param_size_t(int n) +{ + size_t in, out; + unsigned char buf[MAX_LEN], le[MAX_LEN], cmp[sizeof(size_t)]; + const size_t len = raw_values[n].len >= sizeof(size_t) + ? sizeof(size_t) : raw_values[n].len; + OSSL_PARAM param = OSSL_PARAM_size_t("a", NULL); + memset(buf, 0, sizeof(buf)); + memset(le, 0, sizeof(le)); + copy_be_to_native(buf, raw_values[n].value, len); + swap_copy(le, raw_values[n].value, len); + memcpy(&in, buf, sizeof(in)); + param.data = &out; + if (!TEST_true(OSSL_PARAM_set_size_t(¶m, in))) + return 0; + copy_to_le(cmp, &out, sizeof(out)); + if (!TEST_mem_eq(cmp, len, le, len)) + return 0; + in = 0; + param.data = buf; + if (!TEST_true(OSSL_PARAM_get_size_t(¶m, &in))) + return 0; + copy_to_le(cmp, &in, sizeof(in)); + if (!TEST_mem_eq(cmp, sizeof(in), le, sizeof(in))) + return 0; + param.data = &out; + return test_param_type_extra(¶m, le, sizeof(size_t)); +} + +static int test_param_bignum(int n) +{ + unsigned char buf[MAX_LEN], bnbuf[MAX_LEN], le[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); + int ret = 0; + + param.data = bnbuf; + param.data_size = len; + param.return_size = &bnsize; + + copy_be_to_native(buf, raw_values[n].value, len); + swap_copy(le, raw_values[n].value, len); + if (!TEST_ptr(b = BN_bin2bn(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)) + goto err; + param.data_size = *param.return_size; + if (!TEST_true(OSSL_PARAM_get_BN(¶m, &c)) + || !TEST_BN_eq(b, c)) + goto err; + + ret = 1; +err: + BN_free(b); + BN_free(c); + return ret; +} + +static int test_param_real(void) +{ + double p; + OSSL_PARAM param = OSSL_PARAM_double("r", NULL); + + param.data = &p; + return TEST_true(OSSL_PARAM_set_double(¶m, 3.14159)) + && 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[] = { + "int", "long", "int32", "int64" + }; + static const char *uint_names[] = { + "uint", "ulong", "uint32", "uint64", "size_t" + }; + static const unsigned char bn_val[16] = { + 0xac, 0x75, 0x22, 0x7d, 0x81, 0x06, 0x7a, 0x23, + 0xa6, 0xed, 0x87, 0xc7, 0xab, 0xf4, 0x73, 0x22 + }; + OSSL_PARAM params[20]; + char buf[100], buf2[100], *bufp, *bufp2; + unsigned char ubuf[100]; + void *vp, *vp2; + OSSL_PARAM *p; + const OSSL_PARAM *cp; + static const OSSL_PARAM pend = OSSL_PARAM_END; + int i, n = 0, ret = 0; + unsigned int u; + long int l; + unsigned long int ul; + int32_t i32; + uint32_t u32; + int64_t i64; + uint64_t u64; + size_t j, k, s, sz; + 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, &sz); + params[n++] = OSSL_PARAM_construct_octet_ptr("octptr", &vp, &sz); + params[n] = pend; + + /* Search failure */ + if (!TEST_ptr_null(OSSL_PARAM_locate(params, "fnord"))) + goto err; + + /* All signed integral types */ + for (j = 0; j < OSSL_NELEM(int_names); j++) { + 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((size_t)i64, 3 + j)) { + TEST_note("iteration %zu var %s", j + 1, int_names[j]); + goto err; + } + } + /* All unsigned integral types */ + for (j = 0; j < OSSL_NELEM(uint_names); j++) { + 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((size_t)u64, 3 + j)) { + TEST_note("iteration %zu var %s", j + 1, uint_names[j]); + goto err; + } + } + /* Real */ + 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_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_true(OSSL_PARAM_get_utf8_string(cp, &bufp, 0)) + || !TEST_str_eq(bufp, "abcdef")) + goto err; + OPENSSL_free(bufp); + bufp = buf2; + if (!TEST_true(OSSL_PARAM_get_utf8_string(cp, &bufp, sizeof(buf2))) + || !TEST_str_eq(buf2, "abcdef")) + 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_str_eq(bufp, "tuvwxyz") + || !TEST_true(OSSL_PARAM_get_utf8_ptr(cp, (const char **)&bufp2)) + || !TEST_ptr_eq(bufp2, bufp)) + goto err; + /* OCTET string */ + vp = NULL; + if (!TEST_ptr(p = locate(params, "octstr")) + || !TEST_true(OSSL_PARAM_set_octet_string(p, "abcdefghi", + sizeof("abcdefghi"))) + || !TEST_size_t_eq(sz, 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, &vp, 0, &s)) + || !TEST_size_t_eq(s, sizeof("abcdefghi")) + || !TEST_mem_eq(vp, sizeof("abcdefghi"), + "abcdefghi", sizeof("abcdefghi"))) + goto err; + OPENSSL_free(vp); + vp = buf2; + if (!TEST_true(OSSL_PARAM_get_octet_string(p, &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)) + || !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)) + || !TEST_size_t_eq(k, sizeof(ul)) + || !TEST_ptr_eq(vp2, vp)) + goto err; + /* BIGNUM */ + if (!TEST_ptr(p = 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))) + 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)) + || !TEST_BN_eq(bn, bn2)) + goto err; + ret = 1; +err: + BN_free(bn); + BN_free(bn2); + return ret; +} + +int setup_tests(void) +{ + ADD_ALL_TESTS(test_param_int, OSSL_NELEM(raw_values)); + ADD_ALL_TESTS(test_param_long, OSSL_NELEM(raw_values)); + ADD_ALL_TESTS(test_param_uint, OSSL_NELEM(raw_values)); + ADD_ALL_TESTS(test_param_ulong, OSSL_NELEM(raw_values)); + ADD_ALL_TESTS(test_param_int32, OSSL_NELEM(raw_values)); + ADD_ALL_TESTS(test_param_uint32, OSSL_NELEM(raw_values)); + ADD_ALL_TESTS(test_param_size_t, OSSL_NELEM(raw_values)); + ADD_ALL_TESTS(test_param_int64, OSSL_NELEM(raw_values)); + ADD_ALL_TESTS(test_param_uint64, OSSL_NELEM(raw_values)); + ADD_ALL_TESTS(test_param_bignum, OSSL_NELEM(raw_values)); + ADD_TEST(test_param_real); + ADD_TEST(test_param_construct); + return 1; +} diff --git a/test/params_test.c b/test/params_test.c new file mode 100644 index 00000000..338e6b20 --- /dev/null +++ b/test/params_test.c @@ -0,0 +1,549 @@ +/* + * 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 may obtain a copy of the License at + * https://www.openssl.org/source/license.html + * or in the file LICENSE in the source distribution. + */ + +/* + * This program tests the use of OSSL_PARAM, currently in raw form. + */ + +#include +#include +#include +#include +#include "internal/nelem.h" +#include "testutil.h" + +/*- + * PROVIDER SECTION + * ================ + * + * Even though it's not necessarily ONLY providers doing this part, + * they are naturally going to be the most common users of + * set_params and get_params functions. + */ + +/* + * In real use cases, setters and getters would take an object with + * which the parameters are associated. This structure is a cheap + * simulation. + */ +struct object_st { + /* + * Documented as a native integer, of the size given by sizeof(int). + * Assumed data type OSSL_PARAM_INTEGER + */ + int p1; + /* + * Documented as a native double, of the size given by sizeof(double). + * Assumed data type OSSL_PARAM_REAL + */ + double p2; + /* + * Documented as an arbitrarly large unsigned integer. + * The data size must be large enough to accomodate. + * Assumed data type OSSL_PARAM_UNSIGNED_INTEGER + */ + BIGNUM *p3; + /* + * Documented as a C string. + * The data size must be large enough to accomodate. + * Assumed data type OSSL_PARAM_UTF8_STRING + */ + char *p4; + size_t p4_l; + /* + * Documented as a C string. + * Assumed data type OSSL_PARAM_UTF8_STRING + */ + char p5[256]; + size_t p5_l; + /* + * Documented as a pointer to a constant C string. + * Assumed data type OSSL_PARAM_UTF8_PTR + */ + const char *p6; + size_t p6_l; +}; + +#define p1_init 42 /* The ultimate answer */ +#define p2_init 6.283 /* Magic number */ +/* Stolen from evp_data, BLAKE2s256 test */ +#define p3_init \ + "4142434445464748494a4b4c4d4e4f50" \ + "5152535455565758595a616263646566" \ + "6768696a6b6c6d6e6f70717273747576" \ + "7778797a30313233343536373839" +#define p4_init "BLAKE2s256" /* Random string */ +#define p5_init "Hellow World" /* Random string */ +#define p6_init OPENSSL_FULL_VERSION_STR /* Static string */ + +static void cleanup_object(void *vobj) +{ + struct object_st *obj = vobj; + + BN_free(obj->p3); + obj->p3 = NULL; + OPENSSL_free(obj->p4); + obj->p4 = NULL; + OPENSSL_free(obj); +} + +static void *init_object(void) +{ + struct object_st *obj = OPENSSL_zalloc(sizeof(*obj)); + + obj->p1 = p1_init; + obj->p2 = p2_init; + if (!TEST_true(BN_hex2bn(&obj->p3, p3_init))) + goto fail; + if (!TEST_ptr(obj->p4 = OPENSSL_strdup(p4_init))) + goto fail; + strcpy(obj->p5, p5_init); + obj->p6 = p6_init; + + return obj; + fail: + cleanup_object(obj); + obj = NULL; + + return NULL; +} + +/* + * RAW provider, which handles the parameters in a very raw manner, + * with no fancy API and very minimal checking. The application that + * calls these to set or request parameters MUST get its OSSL_PARAM + * array right. + */ + +static int raw_set_params(void *vobj, const OSSL_PARAM *params) +{ + struct object_st *obj = vobj; + + for (; params->key != NULL; params++) + if (strcmp(params->key, "p1") == 0) { + obj->p1 = *(int *)params->data; + } else if (strcmp(params->key, "p2") == 0) { + obj->p2 = *(double *)params->data; + } else if (strcmp(params->key, "p3") == 0) { + BN_free(obj->p3); + if (!TEST_ptr(obj->p3 = BN_native2bn(params->data, + params->data_size, NULL))) + return 0; + } else if (strcmp(params->key, "p4") == 0) { + OPENSSL_free(obj->p4); + if (!TEST_ptr(obj->p4 = OPENSSL_strndup(params->data, + params->data_size))) + return 0; + } else if (strcmp(params->key, "p5") == 0) { + strncpy(obj->p5, params->data, params->data_size); + } else if (strcmp(params->key, "p6") == 0) { + obj->p6 = *(const char **)params->data; + } + + return 1; +} + +static int raw_get_params(void *vobj, const 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); + *(int *)params->data = obj->p1; + } else if (strcmp(params->key, "p2") == 0) { + if (params->return_size != NULL) + *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; + 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; + 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; + if (!TEST_size_t_ge(params->data_size, bytes)) + return 0; + strcpy(params->data, obj->p5); + } else if (strcmp(params->key, "p6") == 0) { + /* + * We COULD also use OPENSSL_FULL_VERSION_STR directly and + * use sizeof(OPENSSL_FULL_VERSION_STR) instead of calling + * strlen(). + * The caller wouldn't know the difference. + */ + size_t bytes = strlen(obj->p6) + 1; + + if (params->return_size != NULL) + *params->return_size = bytes; + *(const char **)params->data = obj->p6; + } + + return 1; +} + +/* + * API provider, which handles the parameters using the API from params.h + */ + +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 + && !TEST_true(OSSL_PARAM_get_int(p, &obj->p1))) + return 0; + if ((p = OSSL_PARAM_locate(params, "p2")) != NULL + && !TEST_true(OSSL_PARAM_get_double(p, &obj->p2))) + return 0; + if ((p = OSSL_PARAM_locate(params, "p3")) != NULL + && !TEST_true(OSSL_PARAM_get_BN(p, &obj->p3))) + return 0; + if ((p = OSSL_PARAM_locate(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) { + char *p5_ptr = obj->p5; + if (!TEST_true(OSSL_PARAM_get_utf8_string(p, &p5_ptr, sizeof(obj->p5)))) + return 0; + } + if ((p = OSSL_PARAM_locate(params, "p6")) != NULL + && !TEST_true(OSSL_PARAM_get_utf8_ptr(p, &obj->p6))) + return 0; + + return 1; +} + +static int api_get_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 + && !TEST_true(OSSL_PARAM_set_int(p, obj->p1))) + return 0; + if ((p = OSSL_PARAM_locate(params, "p2")) != NULL + && !TEST_true(OSSL_PARAM_set_double(p, obj->p2))) + return 0; + if ((p = OSSL_PARAM_locate(params, "p3")) != NULL + && !TEST_true(OSSL_PARAM_set_BN(p, obj->p3))) + return 0; + if ((p = OSSL_PARAM_locate(params, "p4")) != NULL + && !TEST_true(OSSL_PARAM_set_utf8_string(p, obj->p4))) + return 0; + if ((p = OSSL_PARAM_locate(params, "p5")) != NULL + && !TEST_true(OSSL_PARAM_set_utf8_string(p, obj->p5))) + return 0; + if ((p = OSSL_PARAM_locate(params, "p6")) != NULL + && !TEST_true(OSSL_PARAM_set_utf8_ptr(p, obj->p6))) + return 0; + + return 1; +} + +/* + * This structure only simulates a provider dispatch, the real deal is + * a bit more code that's not necessary in these tests. + */ +struct provider_dispatch_st { + int (*set_params)(void *obj, const OSSL_PARAM *params); + int (*get_params)(void *obj, const OSSL_PARAM *params); +}; + +/* "raw" provider */ +static const struct provider_dispatch_st provider_raw = { + raw_set_params, raw_get_params +}; + +/* "api" provider */ +static const struct provider_dispatch_st provider_api = { + api_set_params, api_get_params +}; + +/*- + * APPLICATION SECTION + * =================== + */ + +/* In all our tests, these are variables that get manipulated as parameters + * + * These arrays consistenly 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 + * they don't understand (the application may have one big bag of + * parameters). + */ +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 */ +#define app_p3_init "deadbeef" /* Classic */ +#define app_p4_init "Hello" +#define app_p5_init "World" +#define app_p6_init "Cookie" +#define app_foo_init 'z' + +static int cleanup_app_variables(void) +{ + BN_free(app_p3); + app_p3 = NULL; + return 1; +} + +static int init_app_variables(void) +{ + int l = 0; + + cleanup_app_variables(); + + app_p1 = app_p1_init; + app_p2 = app_p2_init; + 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; +} + +/* + * Here, we define test OSSL_PARAM arrays + */ + +/* 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 }, + { "p6", OSSL_PARAM_UTF8_PTR, &app_p6, sizeof(app_p6), &app_p6_l }, + { "foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), &foo_l }, + { NULL, 0, NULL, 0, NULL } +}; + +/* The same array of OSSL_PARAM, specified with the macros from params.h */ +static const 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_DEFN("p6", OSSL_PARAM_UTF8_PTR, + &app_p6, sizeof(app_p6), &app_p6_l), + OSSL_PARAM_DEFN("foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), &foo_l), + OSSL_PARAM_END +}; + +/* + * The same array again, but constructed at run-time + * This exercises the OSSL_PARAM constructor functions + */ +static OSSL_PARAM *construct_api_params(void) +{ + size_t n = 0; + static OSSL_PARAM params[10]; + OSSL_PARAM param_end = OSSL_PARAM_END; + + 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_utf8_string("p5", app_p5, + sizeof(app_p5), &app_p5_l); + params[n++] = OSSL_PARAM_construct_utf8_ptr("p6", (char **)&app_p6, + &app_p6_l); + params[n++] = OSSL_PARAM_construct_octet_string("foo", &foo, sizeof(foo), + &foo_l); + params[n++] = param_end; + + return params; +} + +struct param_owner_st { + const OSSL_PARAM *static_params; + OSSL_PARAM *(*constructed_params)(void); +}; + +static const struct param_owner_st raw_params = { + static_raw_params, NULL +}; + +static const struct param_owner_st api_params = { + static_api_params, construct_api_params +}; + +/*- + * TESTING + * ======= + */ + +/* + * Test cases to combine parameters with "provider side" functions + */ +static struct { + const struct provider_dispatch_st *prov; + const struct param_owner_st *app; + const char *desc; +} test_cases[] = { + /* Tests within specific methods */ + { &provider_raw, &raw_params, "raw provider vs raw params" }, + { &provider_api, &api_params, "api provider vs api params" }, + + /* Mixed methods */ + { &provider_raw, &api_params, "raw provider vs api params" }, + { &provider_api, &raw_params, "api provider vs raw params" }, +}; + +/* Generic tester of combinations of "providers" and params */ +static int test_case_variant(const OSSL_PARAM *params, + const struct provider_dispatch_st *prov) +{ + BIGNUM *verify_p3 = NULL; + void *obj = NULL; + int errcnt = 0; + + /* + * Initialize + */ + if (!TEST_ptr(obj = init_object()) + || !TEST_true(BN_hex2bn(&verify_p3, p3_init))) { + errcnt++; + goto fin; + } + + /* + * Get parameters a first time, just to see that getting works and + * gets us the values we expect. + */ + init_app_variables(); + + 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_BN_eq(app_p3, verify_p3) /* "provider" value */ + || !TEST_str_eq(app_p4, p4_init) /* "provider" value */ + || !TEST_str_eq(app_p5, p5_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))) + errcnt++; + + /* + * Set parameters, then sneak into the object itself and check + * that its attributes got set (or ignored) properly. + */ + init_app_variables(); + + if (!TEST_true(prov->set_params(obj, params))) { + errcnt++; + } else { + struct object_st *sneakpeek = obj; + + if (!TEST_int_eq(sneakpeek->p1, app_p1) /* app value set */ + || !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_str_eq(sneakpeek->p5, app_p5)) /* app value set */ + errcnt++; + } + + /* + * Get parameters again, checking that we get different values + * than earlier where relevant. + */ + BN_free(verify_p3); + verify_p3 = NULL; + + if (!TEST_true(BN_hex2bn(&verify_p3, app_p3_init))) { + errcnt++; + goto fin; + } + + 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_BN_eq(app_p3, verify_p3) /* app value */ + || !TEST_str_eq(app_p4, app_p4_init) /* app value */ + || !TEST_str_eq(app_p5, app_p5_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))) + errcnt++; + + fin: + BN_free(verify_p3); + verify_p3 = NULL; + cleanup_app_variables(); + cleanup_object(obj); + + return errcnt == 0; +} + +static int test_case(int i) +{ + TEST_info("Case: %s", test_cases[i].desc); + + return test_case_variant(test_cases[i].app->static_params, + test_cases[i].prov) + && (test_cases[i].app->constructed_params == NULL + || test_case_variant(test_cases[i].app->constructed_params(), + test_cases[i].prov)); +} + +int setup_tests(void) +{ + ADD_ALL_TESTS(test_case, OSSL_NELEM(test_cases)); + return 1; +} diff --git a/test/provider_internal_test.c b/test/provider_internal_test.c new file mode 100644 index 00000000..ca554b89 --- /dev/null +++ b/test/provider_internal_test.c @@ -0,0 +1,84 @@ +/* + * 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/provider.h" +#include "testutil.h" + +#if !defined(DSO_VMS) && !defined(DSO_DLCFN) && !defined(DSO_DL) \ + && !defined(DSO_WIN32) && !defined(DSO_DLFCN) +# define OPENSSL_NO_DSO +#endif + +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 } +}; + +static int test_provider(OSSL_PROVIDER *prov) +{ + const char *name = NULL; + const char *greeting = NULL; + char expected_greeting[256]; + int ret = 0; + + if (!TEST_ptr(name = ossl_provider_name(prov))) + return 0; + + snprintf(expected_greeting, sizeof(expected_greeting), + "Hello OpenSSL %.20s, greetings from %s!", + OPENSSL_VERSION_STR, name); + + ret = + TEST_true(ossl_provider_activate(prov)) + && TEST_true(ossl_provider_get_params(prov, greeting_request)) + && TEST_ptr(greeting = greeting_request[0].data) + && TEST_size_t_gt(greeting_request[0].data_size, 0) + && TEST_str_eq(greeting, expected_greeting); + + ossl_provider_free(prov); + return ret; +} + +static int test_builtin_provider(void) +{ + const char *name = "p_test_builtin"; + OSSL_PROVIDER *prov = NULL; + + return + TEST_ptr(prov = + ossl_provider_new(NULL, name, PROVIDER_INIT_FUNCTION_NAME)) + && test_provider(prov); +} + +#ifndef OPENSSL_NO_DSO +static int test_loaded_provider(void) +{ + const char *name = "p_test"; + OSSL_PROVIDER *prov = NULL; + + return + TEST_ptr(prov = ossl_provider_new(NULL, name, NULL)) + && test_provider(prov); +} +#endif + +int setup_tests(void) +{ + ADD_TEST(test_builtin_provider); +#ifndef OPENSSL_NO_DSO + ADD_TEST(test_loaded_provider); +#endif + return 1; +} + diff --git a/test/provider_test.c b/test/provider_test.c new file mode 100644 index 00000000..eefafcf5 --- /dev/null +++ b/test/provider_test.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 "testutil.h" + +#if !defined(DSO_VMS) && !defined(DSO_DLCFN) && !defined(DSO_DL) \ + && !defined(DSO_WIN32) && !defined(DSO_DLFCN) +# define OPENSSL_NO_DSO +#endif + + +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 } +}; + +static int test_provider(const char *name) +{ + OSSL_PROVIDER *prov = NULL; + const char *greeting = NULL; + char expected_greeting[256]; + + snprintf(expected_greeting, sizeof(expected_greeting), + "Hello OpenSSL %.20s, greetings from %s!", + OPENSSL_VERSION_STR, name); + + return + TEST_ptr(prov = OSSL_PROVIDER_load(NULL, name)) + && TEST_true(OSSL_PROVIDER_get_params(prov, greeting_request)) + && TEST_ptr(greeting = greeting_request[0].data) + && TEST_size_t_gt(greeting_request[0].data_size, 0) + && TEST_str_eq(greeting, expected_greeting) + && TEST_true(OSSL_PROVIDER_unload(prov)); +} + +static int test_builtin_provider(void) +{ + const char *name = "p_test_builtin"; + + return + TEST_true(OSSL_PROVIDER_add_builtin(NULL, name, + PROVIDER_INIT_FUNCTION_NAME)) + && test_provider(name); +} + +#ifndef OPENSSL_NO_DSO +static int test_loaded_provider(void) +{ + const char *name = "p_test"; + + return test_provider(name); +} +#endif + +int setup_tests(void) +{ + ADD_TEST(test_builtin_provider); +#ifndef OPENSSL_NO_DSO + ADD_TEST(test_loaded_provider); +#endif + return 1; +} + diff --git a/test/recipes/02-test_internal_provider.t b/test/recipes/02-test_internal_provider.t new file mode 100644 index 00000000..8275eb27 --- /dev/null +++ b/test/recipes/02-test_internal_provider.t @@ -0,0 +1,18 @@ +#! /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 qw(:DEFAULT bldtop_dir); +use OpenSSL::Test::Simple; +use OpenSSL::Test::Utils; + +setup("test_internal_provider"); + +$ENV{"OPENSSL_MODULES"} = bldtop_dir("test"); + +simple_test("test_internal_provider", "provider_internal_test"); diff --git a/test/recipes/03-test_internal_bn.t b/test/recipes/03-test_internal_bn.t new file mode 100644 index 00000000..8aed18ac --- /dev/null +++ b/test/recipes/03-test_internal_bn.t @@ -0,0 +1,19 @@ +#! /usr/bin/env perl +# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the OpenSSL license (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_bn"); + +plan skip_all => "This test is unsupported in a shared library build on Windows" + if $^O eq 'MSWin32' && !disabled("shared"); + +simple_test("test_internal_bn", "bn_internal_test"); diff --git a/test/recipes/03-test_internal_rsa_sp800_56b.t b/test/recipes/03-test_internal_rsa_sp800_56b.t new file mode 100644 index 00000000..2f5e0034 --- /dev/null +++ b/test/recipes/03-test_internal_rsa_sp800_56b.t @@ -0,0 +1,19 @@ +#! /usr/bin/env perl +# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the OpenSSL license (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_rsa_sp800_56b"); + +plan skip_all => "This test is unsupported in a shared library build on Windows" + if $^O eq 'MSWin32' && !disabled("shared"); + +simple_test("test_internal_rsa_sp800_56b", "rsa_sp800_56b_test"); diff --git a/test/recipes/03-test_params_api.t b/test/recipes/03-test_params_api.t new file mode 100644 index 00000000..9e821c99 --- /dev/null +++ b/test/recipes/03-test_params_api.t @@ -0,0 +1,12 @@ +#! /usr/bin/env perl +# 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 + +use OpenSSL::Test::Simple; + +simple_test("test_params_api", "params_api_test"); diff --git a/test/recipes/04-test_params.t b/test/recipes/04-test_params.t new file mode 100644 index 00000000..ae83d4fd --- /dev/null +++ b/test/recipes/04-test_params.t @@ -0,0 +1,15 @@ +#! /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; +use OpenSSL::Test::Simple; + +setup("test_params"); + +simple_test("test_params", "params_test"); diff --git a/test/recipes/04-test_provider.t b/test/recipes/04-test_provider.t new file mode 100644 index 00000000..9195a424 --- /dev/null +++ b/test/recipes/04-test_provider.t @@ -0,0 +1,18 @@ +#! /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 qw(:DEFAULT bldtop_dir); +use OpenSSL::Test::Simple; +use OpenSSL::Test::Utils; + +setup("test_provider"); + +$ENV{"OPENSSL_MODULES"} = bldtop_dir("test"); + +simple_test("test_provider", "provider_test"); diff --git a/test/recipes/20-test_mac.t b/test/recipes/20-test_mac.t new file mode 100644 index 00000000..6a2c094a --- /dev/null +++ b/test/recipes/20-test_mac.t @@ -0,0 +1,194 @@ +#! /usr/bin/env perl +# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the OpenSSL license (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 warnings; + +use OpenSSL::Test; +use OpenSSL::Test::Utils; +use Storable qw(dclone); + +setup("test_mac"); + +my @mac_tests = ( + { cmd => [qw{openssl mac -macopt digest:SHA1 -macopt hexkey:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F}], + type => 'HMAC', + input => unpack("H*", "Sample message for keylen=blocklen"), + expected => '5FD596EE78D5553C8FF4E72D266DFD192366DA29', + desc => 'HMAC SHA1' }, + { cmd => [qw{openssl mac -macopt cipher:AES-256-GCM -macopt hexkey:4C973DBC7364621674F8B5B89E5C15511FCED9216490FB1C1A2CAA0FFE0407E5 -macopt hexiv:7AE8E2CA4EC500012E58495C}], + type => 'GMAC', + input => '68F2E77696CE7AE8E2CA4EC588E541002E58495C08000F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D0007', + expected => '00BDA1B7E87608BCBF470F12157F4C07', + desc => 'GMAC' }, + { cmd => [qw{openssl mac -macopt hexkey:404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F -macopt xof:0}], + type => 'KMAC128', + input => '00010203', + expected => 'E5780B0D3EA6F7D3A429C5706AA43A00FADBD7D49628839E3187243F456EE14E', + desc => 'KMAC128' }, + { cmd => [qw{openssl mac -macopt hexkey:404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F -macopt }, 'custom:My Tagged Application'], + type => 'KMAC256', + input => '00010203', + expected => '20C570C31346F703C9AC36C61C03CB64C3970D0CFC787E9B79599D273A68D2F7F69D4CC3DE9D104A351689F27CF6F5951F0103F33F4F24871024D9C27773A8DD', + desc => 'KMAC256' }, + { cmd => [qw{openssl mac -macopt hexkey:404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F -macopt xof:1 -macopt}, 'custom:My Tagged Application'], + type => 'KMAC256', + input => '000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7', + expected => 'D5BE731C954ED7732846BB59DBE3A8E30F83E77A4BFF4459F2F1C2B4ECEBB8CE67BA01C62E8AB8578D2D499BD1BB276768781190020A306A97DE281DCC30305D', + desc => 'KMAC256 with xof len of 64' }, +); + +my @siphash_tests = ( + { cmd => [qw{openssl mac -macopt hexkey:000102030405060708090A0B0C0D0E0F}], + type => 'SipHash', + input => '00', + expected => 'da87c1d86b99af44347659119b22fc45', + desc => 'SipHash No input' } +); + +my @cmac_tests = ( + { cmd => [qw{openssl mac -macopt cipher:AES-256-CBC -macopt hexkey:0B122AC8F34ED1FE082A3625D157561454167AC145A10BBF77C6A70596D574F1}], + type => 'CMAC', + input => '498B53FDEC87EDCBF07097DCCDE93A084BAD7501A224E388DF349CE18959FE8485F8AD1537F0D896EA73BEDC7214713F', + expected => 'F62C46329B41085625669BAF51DEA66A', + desc => 'CMAC AES-256-CBC' } +); + +my @poly1305_tests = ( + { cmd => [qw{openssl mac -macopt hexkey:02000000000000000000000000000000ffffffffffffffffffffffffffffffff}], + type => 'Poly1305', + input => '02000000000000000000000000000000', + expected => '03000000000000000000000000000000', + desc => 'Poly1305 (wrap 2^128)' }, +); + +push @mac_tests, @siphash_tests unless disabled("siphash"); +push @mac_tests, @cmac_tests unless disabled("cmac"); +push @mac_tests, @poly1305_tests unless disabled("poly1305"); + +my @mac_fail_tests = ( + { cmd => [qw{openssl mac}], + type => 'KMAC128', + input => '00', + err => 'EVP_MAC_Init', + desc => 'KMAC128 Fail no key' }, +); + +my @siphash_fail_tests = ( + { cmd => [qw{openssl mac}], + type => 'SipHash', + input => '00', + err => '', + desc => 'SipHash Fail no key' }, +); + +push @mac_fail_tests, @siphash_fail_tests unless disabled("siphash"); + +plan tests => (scalar @mac_tests * 2) + scalar @mac_fail_tests; + +foreach (@mac_tests) { + ok(compareline($_->{cmd}, $_->{type}, $_->{input}, $_->{expected}, $_->{err}), $_->{desc}); +} +foreach (@mac_tests) { + ok(comparefile($_->{cmd}, $_->{type}, $_->{input}, $_->{expected}), $_->{desc}); +} + +foreach (@mac_fail_tests) { + ok(compareline($_->{cmd}, $_->{type}, $_->{input}, $_->{expected}, $_->{err}), $_->{desc}); +} + +# Create a temp input file and save the input data into it, and +# then compare the stdout output matches the expected value. +sub compareline { + my $tmpfile = 'tmp.bin'; + my ($cmdarray_orig, $type, $input, $expect, $err) = @_; + my $cmdarray = dclone $cmdarray_orig; + if (defined($expect)) { + $expect = uc $expect; + } + # Open a temporary input file and write $input to it + open(my $in, '>', $tmpfile) or die "Could not open file"; + binmode($in); + my $bin = pack("H*", $input); + print $in $bin; + close $in; + + # The last cmd parameter is the temporary input file we just created. + my @other = ('-in', $tmpfile, $type); + push @$cmdarray, @other; + + my @lines = run(app($cmdarray), capture => 1); + unlink $tmpfile; + + if (defined($expect)) { + if ($lines[1] =~ m|^\Q${expect}\E\R$|) { + return 1; + } else { + print "Got: $lines[1]"; + print "Exp: $expect\n"; + return 0; + } + } + if (defined($err)) { + if (defined($lines[0])) { + $lines[0] =~ s/\s+$//; + if ($lines[0] eq $err) { + return 1; + } else { + print "Got: $lines[0]"; + print "Exp: $err\n"; + return 0; + } + } else { + # expected an error + return 1; + } + } + return 0; +} + +# Create a temp input file and save the input data into it, and +# use the '-bin -out ' commandline options to save results out to a file. +# Read this file back in and check its output matches the expected value. +sub comparefile { + my $tmpfile = 'tmp.bin'; + my $outfile = 'out.bin'; + my ($cmdarray, $type, $input, $expect) = @_; + $expect = uc $expect; + + # Open a temporary input file and write $input to it + open(my $in, '>', $tmpfile) or die "Could not open file"; + binmode($in); + my $bin = pack("H*", $input); + print $in $bin; + close $in; + + my @other = ("-binary", "-in", $tmpfile, "-out", $outfile, $type); + push @$cmdarray, @other; + + run(app($cmdarray)); + unlink $tmpfile; + open(my $out, '<', $outfile) or die "Could not open file"; + binmode($out); + my $buffer; + my $BUFSIZE = 1024; + read($out, $buffer, $BUFSIZE) or die "unable to read"; + + my $line = uc unpack("H*", $buffer); + close($out); + unlink $outfile; + + if ($line eq $expect) { + return 1; + } else { + print "Got: $line\n"; + print "Exp: $expect\n"; + return 0; + } +} diff --git a/test/recipes/20-test_pkeyutl.t b/test/recipes/20-test_pkeyutl.t index 14575301..21f4e629 100644 --- a/test/recipes/20-test_pkeyutl.t +++ b/test/recipes/20-test_pkeyutl.t @@ -15,34 +15,56 @@ use OpenSSL::Test::Utils; setup("test_pkeyutl"); -plan tests => 2; +plan tests => 6; -sub sign -{ - # Utilize the sm2.crt as the TBS file - return run(app(([ 'openssl', 'pkeyutl', '-sign', - '-in', srctop_file('test', 'certs', 'sm2.crt'), - '-inkey', srctop_file('test', 'certs', 'sm2.key'), - '-out', 'signature.sm2', '-rawin', - '-digest', 'sm3', '-pkeyopt', 'sm2_id:someid']))); -} - -sub verify -{ - # Utilize the sm2.crt as the TBS file - return run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin', - '-in', srctop_file('test', 'certs', 'sm2.crt'), - '-inkey', srctop_file('test', 'certs', 'sm2.crt'), - '-sigfile', 'signature.sm2', '-rawin', - '-digest', 'sm3', '-pkeyopt', 'sm2_id:someid']))); -} +# For the tests below we use the cert itself as the TBS file SKIP: { skip "Skipping tests that require EC, SM2 or SM3", 2 if disabled("ec") || disabled("sm2") || disabled("sm3"); - ok(sign, "Sign a piece of data using SM2"); - ok(verify, "Verify an SM2 signature against a piece of data"); + # SM2 + ok(run(app(([ 'openssl', 'pkeyutl', '-sign', + '-in', srctop_file('test', 'certs', 'sm2.crt'), + '-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', + '-in', srctop_file('test', 'certs', 'sm2.crt'), + '-inkey', srctop_file('test', 'certs', 'sm2.crt'), + '-sigfile', 'signature.dat', '-rawin', + '-digest', 'sm3', '-pkeyopt', 'sm2_id:someid']))), + "Verify an SM2 signature against a piece of data"); } -unlink 'signature.sm2'; +SKIP: { + skip "Skipping tests that require EC", 4 + if disabled("ec"); + + # Ed25519 + ok(run(app(([ 'openssl', 'pkeyutl', '-sign', '-in', + srctop_file('test', 'certs', 'server-ed25519-cert.pem'), + '-inkey', srctop_file('test', 'certs', 'server-ed25519-key.pem'), + '-out', 'signature.dat', '-rawin']))), + "Sign a piece of data using Ed25519"); + ok(run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin', '-in', + srctop_file('test', 'certs', 'server-ed25519-cert.pem'), + '-inkey', srctop_file('test', 'certs', 'server-ed25519-cert.pem'), + '-sigfile', 'signature.dat', '-rawin']))), + "Verify an Ed25519 signature against a piece of data"); + + # Ed448 + ok(run(app(([ 'openssl', 'pkeyutl', '-sign', '-in', + srctop_file('test', 'certs', 'server-ed448-cert.pem'), + '-inkey', srctop_file('test', 'certs', 'server-ed448-key.pem'), + '-out', 'signature.dat', '-rawin']))), + "Sign a piece of data using Ed448"); + ok(run(app(([ 'openssl', 'pkeyutl', '-verify', '-certin', '-in', + srctop_file('test', 'certs', 'server-ed448-cert.pem'), + '-inkey', srctop_file('test', 'certs', 'server-ed448-cert.pem'), + '-sigfile', 'signature.dat', '-rawin']))), + "Verify an Ed448 signature against a piece of data"); +} + +unlink 'signature.dat'; diff --git a/test/rsa_sp800_56b_test.c b/test/rsa_sp800_56b_test.c new file mode 100644 index 00000000..a64f9f2c --- /dev/null +++ b/test/rsa_sp800_56b_test.c @@ -0,0 +1,634 @@ +/* + * Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (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/nelem.h" + +#include +#include +#include +#include + +#include "testutil.h" + +#ifdef OPENSSL_NO_RSA +int setup_tests(void) +{ + /* No tests */ + return 1; +} +#else +# include "rsa_locl.h" +# include + +/* taken from RSA2 cavs data */ +static const unsigned char cav_e[] = { + 0x01,0x00,0x01 +}; +static const unsigned char cav_Xp[] = { + 0xcf,0x72,0x1b,0x9a,0xfd,0x0d,0x22,0x1a,0x74,0x50,0x97,0x22,0x76,0xd8,0xc0, + 0xc2,0xfd,0x08,0x81,0x05,0xdd,0x18,0x21,0x99,0x96,0xd6,0x5c,0x79,0xe3,0x02, + 0x81,0xd7,0x0e,0x3f,0x3b,0x34,0xda,0x61,0xc9,0x2d,0x84,0x86,0x62,0x1e,0x3d, + 0x5d,0xbf,0x92,0x2e,0xcd,0x35,0x3d,0x6e,0xb9,0x59,0x16,0xc9,0x82,0x50,0x41, + 0x30,0x45,0x67,0xaa,0xb7,0xbe,0xec,0xea,0x4b,0x9e,0xa0,0xc3,0x05,0xb3,0x88, + 0xd4,0x4c,0xac,0xeb,0xe4,0x03,0xc6,0xca,0xcb,0xd9,0xd3,0x4e,0xf6,0x7f,0x2c, + 0x27,0x1e,0x08,0x6c,0xc2,0xd6,0x45,0x1f,0x84,0xe4,0x3c,0x97,0x19,0xde,0xb8, + 0x55,0xaf,0x0e,0xcf,0x9e,0xb0,0x9c,0x20,0xd3,0x1f,0xa8,0xd7,0x52,0xc2,0x95, + 0x1c,0x80,0x15,0x42,0x4d,0x4f,0x19,0x16 +}; +static const unsigned char cav_Xp1[] = { + 0xac,0x5f,0x7f,0x6e,0x33,0x3e,0x97,0x3a,0xb3,0x17,0x44,0xa9,0x0f,0x7a,0x54, + 0x70,0x27,0x06,0x93,0xd5,0x49,0xde,0x91,0x83,0xbc,0x8a,0x7b,0x95 +}; +static const unsigned char cav_Xp2[] = { + 0x0b,0xf6,0xe8,0x79,0x5a,0x81,0xae,0x90,0x1d,0xa4,0x38,0x74,0x9c,0x0e,0x6f, + 0xe0,0x03,0xcf,0xc4,0x53,0x16,0x32,0x17,0xf7,0x09,0x5f,0xd9 +}; +static const unsigned char cav_Xq[] = { + 0xfe,0xab,0xf2,0x7c,0x16,0x4a,0xf0,0x8d,0x31,0xc6,0x0a,0x82,0xe2,0xae,0xbb, + 0x03,0x7e,0x7b,0x20,0x4e,0x64,0xb0,0x16,0xad,0x3c,0x01,0x1a,0xd3,0x54,0xbf, + 0x2b,0xa4,0x02,0x9e,0xc3,0x0d,0x60,0x3d,0x1f,0xb9,0xc0,0x0d,0xe6,0x97,0x68, + 0xbb,0x8c,0x81,0xd5,0xc1,0x54,0x96,0x0f,0x99,0xf0,0xa8,0xa2,0xf3,0xc6,0x8e, + 0xec,0xbc,0x31,0x17,0x70,0x98,0x24,0xa3,0x36,0x51,0xa8,0x54,0xbd,0x9a,0x89, + 0x99,0x6e,0x57,0x5e,0xd0,0x39,0x86,0xc3,0xa3,0x1b,0xc7,0xcf,0xc4,0x4f,0x47, + 0x25,0x9e,0x2c,0x79,0xe1,0x2c,0xcc,0xe4,0x63,0xf4,0x02,0x84,0xf8,0xf6,0xa1, + 0x5c,0x93,0x14,0xf2,0x68,0x5f,0x3a,0x90,0x2f,0x4e,0x5e,0xf9,0x16,0x05,0xcf, + 0x21,0x63,0xca,0xfa,0xb0,0x08,0x02,0xc0 +}; +static const unsigned char cav_Xq1[] = { + 0x9b,0x02,0xd4,0xba,0xf0,0xaa,0x14,0x99,0x6d,0xc0,0xb7,0xa5,0xe1,0xd3,0x70, + 0xb6,0x5a,0xa2,0x9b,0x59,0xd5,0x8c,0x1e,0x9f,0x3f,0x9a,0xde,0xeb,0x9e,0x9c, + 0x61,0xd6,0x5a,0xe1 +}; +static const unsigned char cav_Xq2[] = { + 0x06,0x81,0x53,0xfd,0xa8,0x7b,0xa3,0x85,0x90,0x15,0x2c,0x97,0xb2,0xa0,0x17, + 0x48,0xb0,0x7f,0x0a,0x01,0x6d +}; +/* expected values */ +static const unsigned char cav_p1[] = { + 0xac,0x5f,0x7f,0x6e,0x33,0x3e,0x97,0x3a,0xb3,0x17,0x44,0xa9,0x0f,0x7a,0x54, + 0x70,0x27,0x06,0x93,0xd5,0x49,0xde,0x91,0x83,0xbc,0x8a,0x7b,0xc3 +}; +static const unsigned char cav_p2[] = { + 0x0b,0xf6,0xe8,0x79,0x5a,0x81,0xae,0x90,0x1d,0xa4,0x38,0x74,0x9c,0x0e,0x6f, + 0xe0,0x03,0xcf,0xc4,0x53,0x16,0x32,0x17,0xf7,0x09,0x5f,0xd9 +}; +static const unsigned char cav_q1[] = { + 0x9b,0x02,0xd4,0xba,0xf0,0xaa,0x14,0x99,0x6d,0xc0,0xb7,0xa5,0xe1,0xd3,0x70, + 0xb6,0x5a,0xa2,0x9b,0x59,0xd5,0x8c,0x1e,0x9f,0x3f,0x9a,0xde,0xeb,0x9e,0x9c, + 0x61,0xd6,0x5d,0x47 +}; +static const unsigned char cav_q2[] = { + 0x06,0x81,0x53,0xfd,0xa8,0x7b,0xa3,0x85,0x90,0x15,0x2c,0x97,0xb2,0xa0,0x17, + 0x48,0xb0,0x7f,0x0a,0x01,0x8f +}; +static const unsigned char cav_p[] = { + 0xcf,0x72,0x1b,0x9a,0xfd,0x0d,0x22,0x1a,0x74,0x50,0x97,0x22,0x76,0xd8,0xc0, + 0xc2,0xfd,0x08,0x81,0x05,0xdd,0x18,0x21,0x99,0x96,0xd6,0x5c,0x79,0xe3,0x02, + 0x81,0xd7,0x0e,0x3f,0x3b,0x34,0xda,0x61,0xc9,0x2d,0x84,0x86,0x62,0x1e,0x3d, + 0x5d,0xbf,0x92,0x2e,0xcd,0x35,0x3d,0x6e,0xb9,0x59,0x16,0xc9,0x82,0x50,0x41, + 0x30,0x45,0x67,0xaa,0xb7,0xbe,0xec,0xea,0x4b,0x9e,0xa0,0xc3,0x05,0xbc,0x4c, + 0x01,0xa5,0x4b,0xbd,0xa4,0x20,0xb5,0x20,0xd5,0x59,0x6f,0x82,0x5c,0x8f,0x4f, + 0xe0,0x3a,0x4e,0x7e,0xfe,0x44,0xf3,0x3c,0xc0,0x0e,0x14,0x2b,0x32,0xe6,0x28, + 0x8b,0x63,0x87,0x00,0xc3,0x53,0x4a,0x5b,0x71,0x7a,0x5b,0x28,0x40,0xc4,0x18, + 0xb6,0x77,0x0b,0xab,0x59,0xa4,0x96,0x7d +}; +static const unsigned char cav_q[] = { + 0xfe,0xab,0xf2,0x7c,0x16,0x4a,0xf0,0x8d,0x31,0xc6,0x0a,0x82,0xe2,0xae,0xbb, + 0x03,0x7e,0x7b,0x20,0x4e,0x64,0xb0,0x16,0xad,0x3c,0x01,0x1a,0xd3,0x54,0xbf, + 0x2b,0xa4,0x02,0x9e,0xc3,0x0d,0x60,0x3d,0x1f,0xb9,0xc0,0x0d,0xe6,0x97,0x68, + 0xbb,0x8c,0x81,0xd5,0xc1,0x54,0x96,0x0f,0x99,0xf0,0xa8,0xa2,0xf3,0xc6,0x8e, + 0xec,0xbc,0x31,0x17,0x70,0x98,0x24,0xa3,0x36,0x51,0xa8,0x54,0xc4,0x44,0xdd, + 0xf7,0x7e,0xda,0x47,0x4a,0x67,0x44,0x5d,0x4e,0x75,0xf0,0x4d,0x00,0x68,0xe1, + 0x4a,0xec,0x1f,0x45,0xf9,0xe6,0xca,0x38,0x95,0x48,0x6f,0xdc,0x9d,0x1b,0xa3, + 0x4b,0xfd,0x08,0x4b,0x54,0xcd,0xeb,0x3d,0xef,0x33,0x11,0x6e,0xce,0xe4,0x5d, + 0xef,0xa9,0x58,0x5c,0x87,0x4d,0xc8,0xcf +}; +static const unsigned char cav_n[] = { + 0xce,0x5e,0x8d,0x1a,0xa3,0x08,0x7a,0x2d,0xb4,0x49,0x48,0xf0,0x06,0xb6,0xfe, + 0xba,0x2f,0x39,0x7c,0x7b,0xe0,0x5d,0x09,0x2d,0x57,0x4e,0x54,0x60,0x9c,0xe5, + 0x08,0x4b,0xe1,0x1a,0x73,0xc1,0x5e,0x2f,0xb6,0x46,0xd7,0x81,0xca,0xbc,0x98, + 0xd2,0xf9,0xef,0x1c,0x92,0x8c,0x8d,0x99,0x85,0x28,0x52,0xd6,0xd5,0xab,0x70, + 0x7e,0x9e,0xa9,0x87,0x82,0xc8,0x95,0x64,0xeb,0xf0,0x6c,0x0f,0x3f,0xe9,0x02, + 0x29,0x2e,0x6d,0xa1,0xec,0xbf,0xdc,0x23,0xdf,0x82,0x4f,0xab,0x39,0x8d,0xcc, + 0xac,0x21,0x51,0x14,0xf8,0xef,0xec,0x73,0x80,0x86,0xa3,0xcf,0x8f,0xd5,0xcf, + 0x22,0x1f,0xcc,0x23,0x2f,0xba,0xcb,0xf6,0x17,0xcd,0x3a,0x1f,0xd9,0x84,0xb9, + 0x88,0xa7,0x78,0x0f,0xaa,0xc9,0x04,0x01,0x20,0x72,0x5d,0x2a,0xfe,0x5b,0xdd, + 0x16,0x5a,0xed,0x83,0x02,0x96,0x39,0x46,0x37,0x30,0xc1,0x0d,0x87,0xc2,0xc8, + 0x33,0x38,0xed,0x35,0x72,0xe5,0x29,0xf8,0x1f,0x23,0x60,0xe1,0x2a,0x5b,0x1d, + 0x6b,0x53,0x3f,0x07,0xc4,0xd9,0xbb,0x04,0x0c,0x5c,0x3f,0x0b,0xc4,0xd4,0x61, + 0x96,0x94,0xf1,0x0f,0x4a,0x49,0xac,0xde,0xd2,0xe8,0x42,0xb3,0x4a,0x0b,0x64, + 0x7a,0x32,0x5f,0x2b,0x5b,0x0f,0x8b,0x8b,0xe0,0x33,0x23,0x34,0x64,0xf8,0xb5, + 0x7f,0x69,0x60,0xb8,0x71,0xe9,0xff,0x92,0x42,0xb1,0xf7,0x23,0xa8,0xa7,0x92, + 0x04,0x3d,0x6b,0xff,0xf7,0xab,0xbb,0x14,0x1f,0x4c,0x10,0x97,0xd5,0x6b,0x71, + 0x12,0xfd,0x93,0xa0,0x4a,0x3b,0x75,0x72,0x40,0x96,0x1c,0x5f,0x40,0x40,0x57, + 0x13 +}; +static const unsigned char cav_d[] = { + 0x47,0x47,0x49,0x1d,0x66,0x2a,0x4b,0x68,0xf5,0xd8,0x4a,0x24,0xfd,0x6c,0xbf, + 0x56,0xb7,0x70,0xf7,0x9a,0x21,0xc8,0x80,0x9e,0xf4,0x84,0xcd,0x88,0x01,0x28, + 0xea,0x50,0xab,0x13,0x63,0xdf,0xea,0x14,0x38,0xb5,0x07,0x42,0x81,0x2f,0xda, + 0xe9,0x24,0x02,0x7e,0xaf,0xef,0x74,0x09,0x0e,0x80,0xfa,0xfb,0xd1,0x19,0x41, + 0xe5,0xba,0x0f,0x7c,0x0a,0xa4,0x15,0x55,0xa2,0x58,0x8c,0x3a,0x48,0x2c,0xc6, + 0xde,0x4a,0x76,0xfb,0x72,0xb6,0x61,0xe6,0xd2,0x10,0x44,0x4c,0x33,0xb8,0xd2, + 0x74,0xb1,0x9d,0x3b,0xcd,0x2f,0xb1,0x4f,0xc3,0x98,0xbd,0x83,0xb7,0x7e,0x75, + 0xe8,0xa7,0x6a,0xee,0xcc,0x51,0x8c,0x99,0x17,0x67,0x7f,0x27,0xf9,0x0d,0x6a, + 0xb7,0xd4,0x80,0x17,0x89,0x39,0x9c,0xf3,0xd7,0x0f,0xdf,0xb0,0x55,0x80,0x1d, + 0xaf,0x57,0x2e,0xd0,0xf0,0x4f,0x42,0x69,0x55,0xbc,0x83,0xd6,0x97,0x83,0x7a, + 0xe6,0xc6,0x30,0x6d,0x3d,0xb5,0x21,0xa7,0xc4,0x62,0x0a,0x20,0xce,0x5e,0x5a, + 0x17,0x98,0xb3,0x6f,0x6b,0x9a,0xeb,0x6b,0xa3,0xc4,0x75,0xd8,0x2b,0xdc,0x5c, + 0x6f,0xec,0x5d,0x49,0xac,0xa8,0xa4,0x2f,0xb8,0x8c,0x4f,0x2e,0x46,0x21,0xee, + 0x72,0x6a,0x0e,0x22,0x80,0x71,0xc8,0x76,0x40,0x44,0x61,0x16,0xbf,0xa5,0xf8, + 0x89,0xc7,0xe9,0x87,0xdf,0xbd,0x2e,0x4b,0x4e,0xc2,0x97,0x53,0xe9,0x49,0x1c, + 0x05,0xb0,0x0b,0x9b,0x9f,0x21,0x19,0x41,0xe9,0xf5,0x61,0xd7,0x33,0x2e,0x2c, + 0x94,0xb8,0xa8,0x9a,0x3a,0xcc,0x6a,0x24,0x8d,0x19,0x13,0xee,0xb9,0xb0,0x48, + 0x61 +}; + +/* helper function */ +static BIGNUM *bn_load_new(const unsigned char *data, int sz) +{ + BIGNUM *ret = BN_new(); + if (ret != NULL) + BN_bin2bn(data, sz, ret); + return ret; +} + +/* helper function */ +static BIGNUM *bn_load(BN_CTX *ctx, const unsigned char *data, int sz) +{ + BIGNUM *ret = BN_CTX_get(ctx); + if (ret != NULL) + BN_bin2bn(data, sz, ret); + return ret; +} + +static int test_check_public_exponent(void) +{ + int ret = 0; + BIGNUM *e = NULL; + + ret = TEST_ptr(e = BN_new()) + /* e is too small */ + && TEST_true(BN_set_word(e, 65535)) + && TEST_false(rsa_check_public_exponent(e)) + /* e is even will fail */ + && TEST_true(BN_set_word(e, 65536)) + && TEST_false(rsa_check_public_exponent(e)) + /* e is ok */ + && TEST_true(BN_set_word(e, 65537)) + && TEST_true(rsa_check_public_exponent(e)) + /* e = 2^256 is too big */ + && TEST_true(BN_lshift(e, BN_value_one(), 256)) + && TEST_false(rsa_check_public_exponent(e)) + /* e = 2^256-1 is odd and in range */ + && TEST_true(BN_sub(e, e, BN_value_one())) + && TEST_true(rsa_check_public_exponent(e)); + BN_free(e); + return ret; +} + +static int test_check_prime_factor_range(void) +{ + int ret = 0; + BN_CTX *ctx = NULL; + BIGNUM *p = NULL; + BIGNUM *bn_p1 = NULL, *bn_p2 = NULL, *bn_p3 = NULL, *bn_p4 = NULL; + /* Some range checks that are larger than 32 bits */ + static const unsigned char p1[] = { 0x0B, 0x50, 0x4F, 0x33, 0x3F }; + static const unsigned char p2[] = { 0x10, 0x00, 0x00, 0x00, 0x00 }; + static const unsigned char p3[] = { 0x0B, 0x50, 0x4F, 0x33, 0x40 }; + static const unsigned char p4[] = { 0x0F, 0xFF, 0xFF, 0xFF, 0xFF }; + + /* (√2)(2^(nbits/2 - 1) <= p <= 2^(nbits/2) - 1 + * For 8 bits: 0xB.504F <= p <= 0xF + * for 72 bits: 0xB504F333F. <= p <= 0xF_FFFF_FFFF + */ + ret = TEST_ptr(p = BN_new()) + && TEST_ptr(bn_p1 = bn_load_new(p1, sizeof(p1))) + && TEST_ptr(bn_p2 = bn_load_new(p2, sizeof(p2))) + && TEST_ptr(bn_p3 = bn_load_new(p3, sizeof(p3))) + && TEST_ptr(bn_p4 = bn_load_new(p4, sizeof(p4))) + && TEST_ptr(ctx = BN_CTX_new()) + && TEST_true(BN_set_word(p, 0xA)) + && TEST_false(rsa_check_prime_factor_range(p, 8, ctx)) + && TEST_true(BN_set_word(p, 0x10)) + && TEST_false(rsa_check_prime_factor_range(p, 8, ctx)) + && TEST_true(BN_set_word(p, 0xB)) + && TEST_true(rsa_check_prime_factor_range(p, 8, ctx)) + && TEST_true(BN_set_word(p, 0xF)) + && TEST_true(rsa_check_prime_factor_range(p, 8, ctx)) + && TEST_false(rsa_check_prime_factor_range(bn_p1, 72, ctx)) + && TEST_false(rsa_check_prime_factor_range(bn_p2, 72, ctx)) + && TEST_true(rsa_check_prime_factor_range(bn_p3, 72, ctx)) + && TEST_true(rsa_check_prime_factor_range(bn_p4, 72, ctx)); + + BN_free(bn_p4); + BN_free(bn_p3); + BN_free(bn_p2); + BN_free(bn_p1); + BN_free(p); + BN_CTX_free(ctx); + return ret; +} + +static int test_check_prime_factor(void) +{ + int ret = 0; + BN_CTX *ctx = NULL; + BIGNUM *p = NULL, *e = NULL; + BIGNUM *bn_p1 = NULL, *bn_p2 = NULL, *bn_p3 = NULL; + + /* Some range checks that are larger than 32 bits */ + static const unsigned char p1[] = { 0x0B, 0x50, 0x4f, 0x33, 0x73 }; + static const unsigned char p2[] = { 0x0B, 0x50, 0x4f, 0x33, 0x75 }; + static const unsigned char p3[] = { 0x0F, 0x50, 0x00, 0x03, 0x75 }; + + ret = TEST_ptr(p = BN_new()) + && TEST_ptr(bn_p1 = bn_load_new(p1, sizeof(p1))) + && TEST_ptr(bn_p2 = bn_load_new(p2, sizeof(p2))) + && TEST_ptr(bn_p3 = bn_load_new(p3, sizeof(p3))) + && TEST_ptr(e = BN_new()) + && TEST_ptr(ctx = BN_CTX_new()) + /* Fails the prime test */ + && TEST_true(BN_set_word(e, 0x1)) + && TEST_false(rsa_check_prime_factor(bn_p1, e, 72, ctx)) + /* p is prime and in range and gcd(p-1, e) = 1 */ + && TEST_true(rsa_check_prime_factor(bn_p2, e, 72, ctx)) + /* gcd(p-1,e) = 1 test fails */ + && TEST_true(BN_set_word(e, 0x2)) + && TEST_false(rsa_check_prime_factor(p, e, 72, ctx)) + /* p fails the range check */ + && TEST_true(BN_set_word(e, 0x1)) + && TEST_false(rsa_check_prime_factor(bn_p3, e, 72, ctx)); + + BN_free(bn_p3); + BN_free(bn_p2); + BN_free(bn_p1); + BN_free(e); + BN_free(p); + BN_CTX_free(ctx); + return ret; +} + +static int test_check_private_exponent(void) +{ + int ret = 0; + RSA *key = NULL; + BN_CTX *ctx = NULL; + BIGNUM *p = NULL, *q = NULL, *e = NULL, *d = NULL, *n = NULL; + + ret = TEST_ptr(key = RSA_new()) + && TEST_ptr(ctx = BN_CTX_new()) + && TEST_ptr(p = BN_new()) + && TEST_ptr(q = BN_new()) + && TEST_ptr(e = BN_new()) + && TEST_ptr(d = BN_new()) + && TEST_ptr(n = BN_new()) + /* lcm(15-1,17-1) = 14*16 / 2 = 112 */ + && TEST_true(BN_set_word(p, 15)) + && TEST_true(BN_set_word(q, 17)) + && TEST_true(BN_set_word(e, 5)) + && TEST_true(BN_set_word(d, 157)) + && TEST_true(BN_set_word(n, 15*17)) + && TEST_true(RSA_set0_factors(key, p, q)) + && TEST_true(RSA_set0_key(key, n, e, d)) + /* fails since d >= lcm(p-1, q-1) */ + && TEST_false(rsa_check_private_exponent(key, 8, ctx)) + && TEST_true(BN_set_word(d, 45)) + /* d is correct size and 1 = e.d mod lcm(p-1, q-1) */ + && TEST_true(rsa_check_private_exponent(key, 8, ctx)) + /* d is too small compared to nbits */ + && TEST_false(rsa_check_private_exponent(key, 16, ctx)) + /* d is too small compared to nbits */ + && TEST_true(BN_set_word(d, 16)) + && TEST_false(rsa_check_private_exponent(key, 8, ctx)) + /* fail if 1 != e.d mod lcm(p-1, q-1) */ + && TEST_true(BN_set_word(d, 46)) + && TEST_false(rsa_check_private_exponent(key, 8, ctx)); + + RSA_free(key); + BN_CTX_free(ctx); + return ret; +} + +static int test_check_crt_components(void) +{ + const int P = 15; + const int Q = 17; + const int E = 5; + const int N = P*Q; + const int DP = 3; + const int DQ = 13; + const int QINV = 8; + + int ret = 0; + RSA *key = NULL; + BN_CTX *ctx = NULL; + BIGNUM *p = NULL, *q = NULL, *e = NULL; + + ret = TEST_ptr(key = RSA_new()) + && TEST_ptr(ctx = BN_CTX_new()) + && TEST_ptr(p = BN_new()) + && TEST_ptr(q = BN_new()) + && TEST_ptr(e = BN_new()) + && TEST_true(BN_set_word(p, P)) + && TEST_true(BN_set_word(q, Q)) + && TEST_true(BN_set_word(e, E)) + && TEST_true(RSA_set0_factors(key, p, q)) + && TEST_true(rsa_sp800_56b_derive_params_from_pq(key, 8, e, ctx)) + && TEST_BN_eq_word(key->n, N) + && TEST_BN_eq_word(key->dmp1, DP) + && TEST_BN_eq_word(key->dmq1, DQ) + && TEST_BN_eq_word(key->iqmp, QINV) + && TEST_true(rsa_check_crt_components(key, ctx)) + /* (a) 1 < dP < (p – 1). */ + && TEST_true(BN_set_word(key->dmp1, 1)) + && TEST_false(rsa_check_crt_components(key, ctx)) + && TEST_true(BN_set_word(key->dmp1, P-1)) + && TEST_false(rsa_check_crt_components(key, ctx)) + && TEST_true(BN_set_word(key->dmp1, DP)) + /* (b) 1 < dQ < (q - 1). */ + && TEST_true(BN_set_word(key->dmq1, 1)) + && TEST_false(rsa_check_crt_components(key, ctx)) + && TEST_true(BN_set_word(key->dmq1, Q-1)) + && TEST_false(rsa_check_crt_components(key, ctx)) + && TEST_true(BN_set_word(key->dmq1, DQ)) + /* (c) 1 < qInv < p */ + && TEST_true(BN_set_word(key->iqmp, 1)) + && TEST_false(rsa_check_crt_components(key, ctx)) + && TEST_true(BN_set_word(key->iqmp, P)) + && TEST_false(rsa_check_crt_components(key, ctx)) + && TEST_true(BN_set_word(key->iqmp, QINV)) + /* (d) 1 = (dP . e) mod (p - 1)*/ + && TEST_true(BN_set_word(key->dmp1, DP+1)) + && TEST_false(rsa_check_crt_components(key, ctx)) + && TEST_true(BN_set_word(key->dmp1, DP)) + /* (e) 1 = (dQ . e) mod (q - 1) */ + && TEST_true(BN_set_word(key->dmq1, DQ-1)) + && TEST_false(rsa_check_crt_components(key, ctx)) + && TEST_true(BN_set_word(key->dmq1, DQ)) + /* (f) 1 = (qInv . q) mod p */ + && TEST_true(BN_set_word(key->iqmp, QINV+1)) + && TEST_false(rsa_check_crt_components(key, ctx)) + && TEST_true(BN_set_word(key->iqmp, QINV)) + /* check defaults are still valid */ + && TEST_true(rsa_check_crt_components(key, ctx)); + + BN_free(e); + RSA_free(key); + BN_CTX_free(ctx); + return ret; +} + +static int test_pq_diff(void) +{ + int ret = 0; + BIGNUM *tmp = NULL, *p = NULL, *q = NULL; + + ret = TEST_ptr(tmp = BN_new()) + && TEST_ptr(p = BN_new()) + && TEST_ptr(q = BN_new()) + /* |1-(2+1)| > 2^1 */ + && TEST_true(BN_set_word(p, 1)) + && TEST_true(BN_set_word(q, 1+2)) + && TEST_false(rsa_check_pminusq_diff(tmp, p, q, 202)) + /* Check |p - q| > 2^(nbits/2 - 100) */ + && TEST_true(BN_set_word(q, 1+3)) + && TEST_true(rsa_check_pminusq_diff(tmp, p, q, 202)) + && TEST_true(BN_set_word(p, 1+3)) + && TEST_true(BN_set_word(q, 1)) + && TEST_true(rsa_check_pminusq_diff(tmp, p, q, 202)); + BN_free(p); + BN_free(q); + BN_free(tmp); + return ret; +} + +static int test_invalid_keypair(void) +{ + int ret = 0; + RSA *key = NULL; + BN_CTX *ctx = NULL; + BIGNUM *p = NULL, *q = NULL, *n = NULL, *e = NULL, *d = NULL; + + ret = TEST_ptr(key = RSA_new()) + && TEST_ptr(ctx = BN_CTX_new()) + /* NULL parameters */ + && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, 2048)) + /* load key */ + && TEST_ptr(p = bn_load_new(cav_p, sizeof(cav_p))) + && TEST_ptr(q = bn_load_new(cav_q, sizeof(cav_q))) + && TEST_ptr(e = bn_load_new(cav_e, sizeof(cav_e))) + && TEST_ptr(n = bn_load_new(cav_n, sizeof(cav_n))) + && TEST_ptr(d = bn_load_new(cav_d, sizeof(cav_d))) + && TEST_true(RSA_set0_key(key, n, e, d)) + && TEST_true(RSA_set0_factors(key, p, q)) + + /* bad strength/key size */ + && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, 100, 2048)) + && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, 112, 1024)) + && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, 128, 2048)) + && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, 140, 3072)) + /* mismatching exponent */ + && TEST_false(rsa_sp800_56b_check_keypair(key, BN_value_one(), -1, + 2048)) + /* bad exponent */ + && TEST_true(BN_add_word(e, 1)) + && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, + 2048)) + && TEST_true(BN_sub_word(e, 1)) + + /* mismatch between bits and modulus */ + && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, 3072)) + && TEST_true(rsa_sp800_56b_check_keypair(key, e, 112, 2048)) + /* check n == pq failure */ + && TEST_true(BN_add_word(n, 1)) + && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, 2048)) + && TEST_true(BN_sub_word(n, 1)) + /* check p */ + && TEST_true(BN_sub_word(p, 2)) + && TEST_true(BN_mul(n, p, q, ctx)) + && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, 2048)) + && TEST_true(BN_add_word(p, 2)) + && TEST_true(BN_mul(n, p, q, ctx)) + /* check q */ + && TEST_true(BN_sub_word(q, 2)) + && TEST_true(BN_mul(n, p, q, ctx)) + && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, 2048)) + && TEST_true(BN_add_word(q, 2)) + && TEST_true(BN_mul(n, p, q, ctx)); + + RSA_free(key); + BN_CTX_free(ctx); + return ret; +} + +static int test_fips1864_keygen_kat(void) +{ + int ret = 0; + RSA *key = NULL; + BN_CTX *ctx = NULL; + BIGNUM *e, *Xp, *Xp1, *Xp2, *Xq, *Xq1, *Xq2; + BIGNUM *p1, *p2, *q1, *q2; + BIGNUM *p1_exp, *p2_exp, *q1_exp, *q2_exp; + BIGNUM *p_exp, *q_exp, *n_exp, *d_exp; + const BIGNUM *p, *q, *n, *d, *e2; + + if (!(TEST_ptr(key = RSA_new()) && TEST_ptr(ctx = BN_CTX_new()))) + goto err; + BN_CTX_start(ctx); + + e = bn_load(ctx, cav_e, sizeof(cav_e)); + Xp = bn_load(ctx, cav_Xp, sizeof(cav_Xp)); + Xp1 = bn_load(ctx, cav_Xp1, sizeof(cav_Xp1)); + Xp2 = bn_load(ctx, cav_Xp2, sizeof(cav_Xp2)); + Xq = bn_load(ctx, cav_Xq, sizeof(cav_Xq)); + Xq1 = bn_load(ctx, cav_Xq1, sizeof(cav_Xq1)); + Xq2 = bn_load(ctx, cav_Xq2, sizeof(cav_Xq2)); + p1_exp = bn_load(ctx, cav_p1, sizeof(cav_p1)); + p2_exp = bn_load(ctx, cav_p2, sizeof(cav_p2)); + q1_exp = bn_load(ctx, cav_q1, sizeof(cav_q1)); + q2_exp = bn_load(ctx, cav_q2, sizeof(cav_q2)); + p_exp = bn_load(ctx, cav_p, sizeof(cav_p)); + q_exp = bn_load(ctx, cav_q, sizeof(cav_q)); + n_exp = bn_load(ctx, cav_n, sizeof(cav_n)); + d_exp = bn_load(ctx, cav_d, sizeof(cav_d)); + p1 = BN_CTX_get(ctx); + p2 = BN_CTX_get(ctx); + q1 = BN_CTX_get(ctx); + q2 = BN_CTX_get(ctx); + ret = TEST_ptr(q2) + && TEST_true(rsa_fips186_4_gen_prob_primes(key, p1, p2, NULL, Xp, Xp1, + Xp2, q1, q2, NULL, Xq, Xq1, + Xq2, 2048, e, ctx, NULL)) + && TEST_true(rsa_sp800_56b_derive_params_from_pq(key, 2048, e, ctx)) + && TEST_BN_eq(p1_exp, p1) + && TEST_BN_eq(p2_exp, p2) + && TEST_BN_eq(q1_exp, q1) + && TEST_BN_eq(q2_exp, q2); + if (!ret) + goto err; + + RSA_get0_key(key, &n, &e2, &d); + RSA_get0_factors(key, &p, &q); + ret = TEST_BN_eq(e, e2) + && TEST_BN_eq(p_exp, p) + && TEST_BN_eq(q_exp, q) + && TEST_BN_eq(n_exp, n) + && TEST_BN_eq(d_exp, d); +err: + RSA_free(key); + BN_CTX_end(ctx); + BN_CTX_free(ctx); + return ret; +} + + +static int keygen_size[] = +{ + 2048, 3072 +}; + +static int test_sp80056b_keygen(int id) +{ + RSA *key = NULL; + int ret; + int sz = keygen_size[id]; + + ret = TEST_ptr(key = RSA_new()) + && TEST_true(rsa_sp800_56b_generate_key(key, sz, NULL, NULL)) + && TEST_true(rsa_sp800_56b_check_public(key)) + && TEST_true(rsa_sp800_56b_check_private(key)) + && TEST_true(rsa_sp800_56b_check_keypair(key, NULL, -1, sz)); + + RSA_free(key); + return ret; +} + +static int test_check_private_key(void) +{ + int ret = 0; + BIGNUM *n = NULL, *d = NULL, *e = NULL; + RSA *key = NULL; + + ret = TEST_ptr(key = RSA_new()) + /* check NULL pointers fail */ + && TEST_false(rsa_sp800_56b_check_private(key)) + /* load private key */ + && TEST_ptr(n = bn_load_new(cav_n, sizeof(cav_n))) + && TEST_ptr(d = bn_load_new(cav_d, sizeof(cav_d))) + && TEST_ptr(e = bn_load_new(cav_e, sizeof(cav_e))) + && TEST_true(RSA_set0_key(key, n, e, d)) + /* check d is in range */ + && TEST_true(rsa_sp800_56b_check_private(key)) + /* check d is too low */ + && TEST_true(BN_set_word(d, 0)) + && TEST_false(rsa_sp800_56b_check_private(key)) + /* check d is too high */ + && TEST_ptr(BN_copy(d, n)) + && TEST_false(rsa_sp800_56b_check_private(key)); + + RSA_free(key); + return ret; +} + +static int test_check_public_key(void) +{ + int ret = 0; + BIGNUM *n = NULL, *e = NULL; + RSA *key = NULL; + + ret = TEST_ptr(key = RSA_new()) + /* check NULL pointers fail */ + && TEST_false(rsa_sp800_56b_check_public(key)) + /* load public key */ + && TEST_ptr(e = bn_load_new(cav_e, sizeof(cav_e))) + && TEST_ptr(n = bn_load_new(cav_n, sizeof(cav_n))) + && TEST_true(RSA_set0_key(key, n, e, NULL)) + /* check public key is valid */ + && TEST_true(rsa_sp800_56b_check_public(key)) + /* check fail if n is even */ + && TEST_true(BN_add_word(n, 1)) + && TEST_false(rsa_sp800_56b_check_public(key)) + && TEST_true(BN_sub_word(n, 1)) + /* check fail if n is wrong number of bits */ + && TEST_true(BN_lshift1(n, n)) + && TEST_false(rsa_sp800_56b_check_public(key)) + && TEST_true(BN_rshift1(n, n)) + /* test odd exponent fails */ + && TEST_true(BN_add_word(e, 1)) + && TEST_false(rsa_sp800_56b_check_public(key)) + && TEST_true(BN_sub_word(e, 1)) + /* modulus fails composite check */ + && TEST_true(BN_add_word(n, 2)) + && TEST_false(rsa_sp800_56b_check_public(key)); + + RSA_free(key); + return ret; +} + +int setup_tests(void) +{ + ADD_TEST(test_check_public_exponent); + ADD_TEST(test_check_prime_factor_range); + ADD_TEST(test_check_prime_factor); + ADD_TEST(test_check_private_exponent); + ADD_TEST(test_check_crt_components); + ADD_TEST(test_check_private_key); + ADD_TEST(test_check_public_key); + ADD_TEST(test_invalid_keypair); + ADD_TEST(test_pq_diff); + ADD_TEST(test_fips1864_keygen_kat); + ADD_ALL_TESTS(test_sp80056b_keygen, (int)OSSL_NELEM(keygen_size)); + return 1; +} +#endif diff --git a/test/rsa_test.c b/test/rsa_test.c index cd9ca7f1..084f533a 100644 --- a/test/rsa_test.c +++ b/test/rsa_test.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 @@ -42,6 +42,8 @@ int setup_tests(void) BN_bin2bn(dmp1, sizeof(dmp1)-1, NULL), \ BN_bin2bn(dmq1, sizeof(dmq1)-1, NULL), \ BN_bin2bn(iqmp, sizeof(iqmp)-1, NULL)); \ + if (c == NULL) \ + return 0; \ memcpy(c, ctext_ex, sizeof(ctext_ex) - 1); \ return sizeof(ctext_ex) - 1; @@ -268,6 +270,36 @@ err: return ret; } +static int test_rsa_sslv23(int idx) +{ + int ret = 0; + RSA *key; + unsigned char ptext[256]; + unsigned char ctext[256]; + static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a"; + unsigned char ctext_ex[256]; + int plen; + int clen = 0; + int num; + + plen = sizeof(ptext_ex) - 1; + clen = rsa_setkey(&key, ctext_ex, idx); + + num = RSA_public_encrypt(plen, ptext_ex, ctext, key, + RSA_SSLV23_PADDING); + if (!TEST_int_eq(num, clen)) + goto err; + + num = RSA_private_decrypt(num, ctext, ptext, key, RSA_SSLV23_PADDING); + if (!TEST_mem_eq(ptext, num, ptext_ex, plen)) + goto err; + + ret = 1; +err: + RSA_free(key); + return ret; +} + static int test_rsa_oaep(int idx) { int ret = 0; @@ -391,6 +423,7 @@ err: int setup_tests(void) { ADD_ALL_TESTS(test_rsa_pkcs1, 3); + ADD_ALL_TESTS(test_rsa_sslv23, 3); ADD_ALL_TESTS(test_rsa_oaep, 3); ADD_ALL_TESTS(test_rsa_security_bit, OSSL_NELEM(rsa_security_bits_cases)); return 1; diff --git a/test/testutil.h b/test/testutil.h index ec2f532c..7f5db601 100644 --- a/test/testutil.h +++ b/test/testutil.h @@ -255,7 +255,9 @@ DECLARE_COMPARISONS(char, char) DECLARE_COMPARISONS(unsigned char, uchar) DECLARE_COMPARISONS(long, long) DECLARE_COMPARISONS(unsigned long, ulong) +DECLARE_COMPARISONS(double, double) DECLARE_COMPARISONS(time_t, time_t) + /* * Because this comparison uses a printf format specifier that's not * universally known (yet), we provide an option to not have it declared. @@ -406,6 +408,13 @@ void test_perror(const char *s); # define TEST_size_t_gt(a, b) test_size_t_gt(__FILE__, __LINE__, #a, #b, a, b) # define TEST_size_t_ge(a, b) test_size_t_ge(__FILE__, __LINE__, #a, #b, a, b) +# define TEST_double_eq(a, b) test_double_eq(__FILE__, __LINE__, #a, #b, a, b) +# define TEST_double_ne(a, b) test_double_ne(__FILE__, __LINE__, #a, #b, a, b) +# define TEST_double_lt(a, b) test_double_lt(__FILE__, __LINE__, #a, #b, a, b) +# define TEST_double_le(a, b) test_double_le(__FILE__, __LINE__, #a, #b, a, b) +# define TEST_double_gt(a, b) test_double_gt(__FILE__, __LINE__, #a, #b, a, b) +# define TEST_double_ge(a, b) test_double_ge(__FILE__, __LINE__, #a, #b, a, b) + # define TEST_time_t_eq(a, b) test_time_t_eq(__FILE__, __LINE__, #a, #b, a, b) # define TEST_time_t_ne(a, b) test_time_t_ne(__FILE__, __LINE__, #a, #b, a, b) # define TEST_time_t_lt(a, b) test_time_t_lt(__FILE__, __LINE__, #a, #b, a, b) diff --git a/test/testutil/tests.c b/test/testutil/tests.c index 2ba5b9a6..05b06888 100644 --- a/test/testutil/tests.c +++ b/test/testutil/tests.c @@ -213,6 +213,7 @@ DEFINE_COMPARISONS(unsigned char, uchar, "%u") DEFINE_COMPARISONS(long, long, "%ld") DEFINE_COMPARISONS(unsigned long, ulong, "%lu") DEFINE_COMPARISONS(size_t, size_t, "%zu") +DEFINE_COMPARISONS(double, double, "%g") DEFINE_COMPARISON(void *, ptr, eq, ==, "%p") DEFINE_COMPARISON(void *, ptr, ne, !=, "%p") diff --git a/util/libcrypto.num b/util/libcrypto.num index a5829966..12ebd5ab 100644 --- a/util/libcrypto.num +++ b/util/libcrypto.num @@ -4655,4 +4655,139 @@ OSSL_trace_set_callback 4610 3_0_0 EXIST::FUNCTION: OSSL_trace_enabled 4611 3_0_0 EXIST::FUNCTION: OSSL_trace_begin 4612 3_0_0 EXIST::FUNCTION: OSSL_trace_end 4613 3_0_0 EXIST::FUNCTION: -EVP_chacha20_poly1305_draft 4614 3_0_0 EXIST::FUNCTION:CHACHA,POLY1305 +OSSL_PROVIDER_load 4614 3_0_0 EXIST::FUNCTION: +OSSL_PROVIDER_unload 4615 3_0_0 EXIST::FUNCTION: +OSSL_PROVIDER_add_builtin 4616 3_0_0 EXIST::FUNCTION: +OSSL_PROVIDER_get_param_types 4617 3_0_0 EXIST::FUNCTION: +OSSL_PROVIDER_get_params 4618 3_0_0 EXIST::FUNCTION: +d2i_OSSL_CRMF_ENCRYPTEDVALUE 4619 3_0_0 EXIST::FUNCTION:CMP +i2d_OSSL_CRMF_ENCRYPTEDVALUE 4620 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_ENCRYPTEDVALUE_free 4621 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_ENCRYPTEDVALUE_new 4622 3_0_0 EXIST::FUNCTION:CMP +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:CMP +OSSL_CRMF_ENCRYPTEDVALUE_it 4624 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CMP +d2i_OSSL_CRMF_MSG 4625 3_0_0 EXIST::FUNCTION:CMP +i2d_OSSL_CRMF_MSG 4626 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_free 4627 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_new 4628 3_0_0 EXIST::FUNCTION:CMP +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:CMP +OSSL_CRMF_MSG_it 4630 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CMP +d2i_OSSL_CRMF_PBMPARAMETER 4631 3_0_0 EXIST::FUNCTION:CMP +i2d_OSSL_CRMF_PBMPARAMETER 4632 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_PBMPARAMETER_free 4633 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_PBMPARAMETER_new 4634 3_0_0 EXIST::FUNCTION:CMP +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:CMP +OSSL_CRMF_PBMPARAMETER_it 4636 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CMP +d2i_OSSL_CRMF_CERTID 4637 3_0_0 EXIST::FUNCTION:CMP +i2d_OSSL_CRMF_CERTID 4638 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_CERTID_free 4639 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_CERTID_new 4640 3_0_0 EXIST::FUNCTION:CMP +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:CMP +OSSL_CRMF_CERTID_it 4642 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CMP +d2i_OSSL_CRMF_PKIPUBLICATIONINFO 4643 3_0_0 EXIST::FUNCTION:CMP +i2d_OSSL_CRMF_PKIPUBLICATIONINFO 4644 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_PKIPUBLICATIONINFO_free 4645 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_PKIPUBLICATIONINFO_new 4646 3_0_0 EXIST::FUNCTION:CMP +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:CMP +OSSL_CRMF_PKIPUBLICATIONINFO_it 4648 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CMP +d2i_OSSL_CRMF_SINGLEPUBINFO 4649 3_0_0 EXIST::FUNCTION:CMP +i2d_OSSL_CRMF_SINGLEPUBINFO 4650 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_SINGLEPUBINFO_free 4651 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_SINGLEPUBINFO_new 4652 3_0_0 EXIST::FUNCTION:CMP +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:CMP +OSSL_CRMF_SINGLEPUBINFO_it 4654 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CMP +d2i_OSSL_CRMF_CERTTEMPLATE 4655 3_0_0 EXIST::FUNCTION:CMP +i2d_OSSL_CRMF_CERTTEMPLATE 4656 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_CERTTEMPLATE_free 4657 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_CERTTEMPLATE_new 4658 3_0_0 EXIST::FUNCTION:CMP +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:CMP +OSSL_CRMF_CERTTEMPLATE_it 4660 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CMP +d2i_OSSL_CRMF_MSGS 4661 3_0_0 EXIST::FUNCTION:CMP +i2d_OSSL_CRMF_MSGS 4662 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSGS_free 4663 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSGS_new 4664 3_0_0 EXIST::FUNCTION:CMP +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:CMP +OSSL_CRMF_MSGS_it 4666 3_0_0 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:CMP +OSSL_CRMF_pbmp_new 4667 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_pbm_new 4668 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set1_regCtrl_regToken 4669 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set1_regCtrl_authenticator 4670 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_PKIPublicationInfo_push0_SinglePubInfo 4671 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set0_SinglePubInfo 4672 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set_PKIPublicationInfo_action 4673 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set1_regCtrl_pkiPublicationInfo 4674 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set1_regCtrl_protocolEncrKey 4675 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set1_regCtrl_oldCertID 4676 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_CERTID_gen 4677 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set1_regInfo_utf8Pairs 4678 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set1_regInfo_certReq 4679 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set_validity 4680 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set_certReqId 4681 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_get_certReqId 4682 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_set0_extensions 4683 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_push0_extension 4684 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_create_popo 4685 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSGS_verify_popo 4686 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_MSG_get0_tmpl 4687 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_CERTTEMPLATE_get0_serialNumber 4688 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_CERTTEMPLATE_get0_issuer 4689 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_CERTTEMPLATE_fill 4690 3_0_0 EXIST::FUNCTION:CMP +OSSL_CRMF_ENCRYPTEDVALUE_get1_encCert 4691 3_0_0 EXIST::FUNCTION:CMP +ERR_load_CRMF_strings 4692 3_0_0 EXIST::FUNCTION:CMP +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_set_sm2_id 4739 3_0_0 EXIST::FUNCTION:SM2 +X509_get0_sm2_id 4740 3_0_0 EXIST::FUNCTION:SM2 +EVP_chacha20_poly1305_draft 4741 3_0_0 EXIST::FUNCTION:CHACHA,POLY1305 diff --git a/util/mkerr.pl b/util/mkerr.pl index cf100d12..7139ee3b 100755 --- a/util/mkerr.pl +++ b/util/mkerr.pl @@ -417,9 +417,7 @@ print STDERR "\n" if $debug; &phase("Writing files"); my $newstate = 0; foreach my $lib ( keys %errorfile ) { - if ( ! $fnew{$lib} && ! $rnew{$lib} ) { - next unless $rebuild; - } + next if ! $fnew{$lib} && ! $rnew{$lib} && ! $rebuild; next if scalar keys %modules > 0 && !$modules{$lib}; next if $nowrite; print STDERR "$lib: $fnew{$lib} new functions\n" if $fnew{$lib}; @@ -455,6 +453,10 @@ foreach my $lib ( keys %errorfile ) { #ifndef HEADER_${lib}ERR_H # define HEADER_${lib}ERR_H +# ifndef HEADER_SYMHACKS_H +# include +# endif + EOF if ( $internal ) { # Declare the load function because the generate C file diff --git a/util/perl/OpenSSL/ParseC.pm b/util/perl/OpenSSL/ParseC.pm index 7a13930d..59b08e8d 100644 --- a/util/perl/OpenSSL/ParseC.pm +++ b/util/perl/OpenSSL/ParseC.pm @@ -578,6 +578,15 @@ my @chandlers = ( { regexp => qr/extern "C" (.*;)/, massager => sub { return ($1); }, }, + # any other extern is just ignored + { regexp => qr/^\s* # Any spaces before + extern # The keyword we look for + \b # word to non-word boundary + .* # Anything after + ; + /x, + massager => sub { return (); }, + }, # union, struct and enum definitions # Because this one might appear a little everywhere within type # definitions, we take it out and replace it with just diff --git a/util/private.num b/util/private.num index ad1865f0..6c37fc05 100644 --- a/util/private.num +++ b/util/private.num @@ -33,6 +33,7 @@ OPENSSL_Applink external OPENSSL_CTX datatype NAMING_AUTHORITY datatype OSSL_PARAM datatype +OSSL_PROVIDER datatype OSSL_STORE_CTX datatype OSSL_STORE_INFO datatype OSSL_STORE_LOADER datatype @@ -322,6 +323,21 @@ 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_utf8_ptr define +OSSL_PARAM_SIZED_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 @@ -487,3 +503,9 @@ ASYNC_STATUS_EAGAIN define ASYNC_STATUS_OK define ASYNC_STATUS_ERR define ASYNC_STATUS_UNSUPPORTED define +OSSL_TRACE_BEGIN define +OSSL_TRACE_END define +OSSL_TRACE_CANCEL define +OSSL_TRACE1 define +OSSL_TRACE2 define +OSSL_TRACE9 define diff --git a/util/providers.num b/util/providers.num new file mode 100644 index 00000000..4e2fa81b --- /dev/null +++ b/util/providers.num @@ -0,0 +1 @@ +OSSL_provider_init 1 * EXIST::FUNCTION: