diff --git a/CMakeLists.txt b/CMakeLists.txt index 68a7c2df..7847830a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,6 +306,33 @@ if(HAVE_NETINET_IP_H) add_definitions(-DHAVE_NETINET_IP_H) endif() +if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(aarch64|arm64)") + set(HOST_AARCH64 true) +elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm") + set(HOST_ARM true) +elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS" AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386") + set(HOST_X86_64 true) +elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86_64|amd64)") + set(HOST_X86_64 true) +elseif("${CMAKE_SYSTEM_NAME}" MATCHES "[i?86|x86]") + set(ENABLE_ASM false) + set(HOST_I386 true) +elseif("${CMAKE_SYSTEM_NAME}" MATCHES "mips64") + set(HOST_MIPS64 true) +elseif("${CMAKE_SYSTEM_NAME}" MATCHES "mips") + set(HOST_MIPS true) +elseif("${CMAKE_SYSTEM_NAME}" MATCHES "powerpc") + set(HOST_POWERPC true) +elseif("${CMAKE_SYSTEM_NAME}" MATCHES "ppc64") + set(HOST_PPC64 true) +elseif("${CMAKE_SYSTEM_NAME}" MATCHES "riscv64") + set(HOST_RISCV64 true) +elseif("${CMAKE_SYSTEM_NAME}" MATCHES "sparc64") + set(HOST_SPARC64 true) +else() + set(ENABLE_ASM false) +endif() + if(ENABLE_ASM) if("${CMAKE_C_COMPILER_ABI}" STREQUAL "ELF") if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86_64|amd64)") @@ -361,13 +388,13 @@ else() set(LIBTLS_TEST_LIBS tls ${PLATFORM_LIBS}) endif() +add_subdirectory(include) add_subdirectory(crypto) add_subdirectory(ssl) if(LIBRESSL_APPS) add_subdirectory(apps) endif() add_subdirectory(tls) -add_subdirectory(include) if(NOT MSVC) add_subdirectory(man) endif() diff --git a/ChangeLog b/ChangeLog index 98cc5a0e..5babe4ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,21 +19,129 @@ with relevant portions of the C library, to a Git repository. This makes it easier to follow all of the relevant changes to the upstream project in a single place: - https://github.com/libressl-portable/openbsd + https://github.com/libressl/openbsd The portable bits of the project are largely maintained out-of-tree, and their history is also available from Git. - https://github.com/libressl-portable/portable + https://github.com/libressl/portable LibreSSL Portable Release Notes: -3.6.2 - Stable release +3.7.2 - Stable release - * Security fix + * Portable changes + - Moved official Github project to https://github.com/libressl/. + - Build support for Apple Silicon. + - Installed opensslconf.h is now architecture-specific. + - Removed internal defines from opensslconf.h. + - Support reproducible builds on tagged commits in main branch. + +3.7.1 - Development release + + * Internal improvements + - Initial overhaul of the BIGNUM code: + - Added a new framework that allows architecture-dependent + replacement implementations for bignum primitives. + - Imported various s2n-bignum's constant time assembly primitives + and switched amd64 to them. + - Lots of cleanup, simplification and bug fixes. + - Changed Perl assembly generators to move constants into .rodata, + allowing code to run with execute-only permissions. + - Capped the number of iterations in DSA and ECDSA signing (avoiding + infinite loops), added additional sanity checks to DSA. + - ASN.1 parsing improvements. + - Made UI_destroy_method() NULL safe. + - Various improvements to nc(1). + - Always clear EC groups and points on free. + - Cleanup and improvements in EC code. + - Various openssl(1) improvements. + * Bug fixes + - Fixed a memory leak, a double free and various other issues in + BIO_new_NDEF(). + - Fixed various crashes in the openssl(1) testing utility. + - Do not check policies by default in the new X.509 verifier. + - Added missing error checking in PKCS7. + - Call CRYPTO_cleanup_all_ex_data() from OPENSSL_cleanup(). + * New features + - Added UI_null() + - Added X509_STORE_*check_issued() + - Added X509_CRL_get0_tbs_sigalg() and X509_get0_uids() accessors. + - Added EVP_CIPHER_meth_*() setter API. + * Documentation improvements + - Marked BIO_s_log(3) BIO_nread0(3), BIO_nread(3), BIO_nwrite0(3), BIO_nwrite(3), + BIO_dump_cb(3) and BIO_dump_indent_cb(3) as intentionally undocumented. + - Document BIO_number_read(3), BIO_number_written(3), + BIO_set_retry_read(3), BIO_set_retry_write(3), + BIO_set_retry_special(3), BIO_clear_retry_flags(3), + BIO_get_retry_flags(3), BIO_dup_chain(3), BIO_set_flags(3), + BIO_clear_flags(3), BIO_test_flags(3), BIO_get_flags(3). + BIO_callback_fn_ex(3), BIO_set_callback_ex(3), BIO_get_callback_ex(3), + BIO_callback_fn(3), and the BIO_FLAGS_* constants + - Correct the prototypes of BIO_get_conn_ip(3) and BIO_get_conn_int_port(3). + - Document ED25519_keypair(3), ED25519_sign(3), and ED25519_verify(3). + - Document EVP_PKEY_new_raw_private_key(3), + EVP_PKEY_new_raw_public_key(3), EVP_PKEY_get_raw_private_key(3), and + EVP_PKEY_get_raw_public_key(3). + - Document ASN1_buf_print(3). + - Document DH_get0_*, DSA_get0_*, ECDSA_SIG_get0_{r,s}() and RSA_get0_*. + - Merged documentation of UI_null() from OpenSSL 1.1 + - Various spelling and other documentation improvements. + * Testing and Proactive Security + - As always, new test coverage is added as bugs are fixed and subsystems + are cleaned up. + - New Wycheproof tests added. + - OpenSSL 3.0 Interop tests added. + - Many old tests rewritten, cleaned up and extended. + * Security fixes - A malicious certificate revocation list or timestamp response token would allow an attacker to read arbitrary memory. +3.7.0 - Development release + + * Internal improvements + - Remove dependency on system timegm() and gmtime() by replacing + traditional Julian date conversion with POSIX epoch-seconds date + conversion from BoringSSL. + - Clean old and unused BN code dealing with primes. + - Start rewriting name constraints code using CBS. + - Remove support for the HMAC PRIVATE KEY. + - Rework DSA signing and verifying internals. + - First few passes on cleaning up the BN code. + - Internal headers coming from OpenSSL are all called *_local.h now. + - Rewrite TLSv1.2 key exporter. + - Cleaned up and refactored various aspects of the legacy TLS stack. + * Compatibility changes + - BIO_read() and BIO_write() now behave more closely to OpenSSL 3 in + various corner cases. More work is needed here. + * Bug fixes + - Add EVP_chacha20_poly1305() to the list of all ciphers. + - Fix potential leaks of EVP_PKEY in various printing functions + - Fix potential leak in OBJ_NAME_add(). + - Avoid signed overflow in i2c_ASN1_BIT_STRING(). + - Clean up EVP_PKEY_ASN1_METHOD related tables and code. + - Fix long standing bugs BN_GF2m_poly2arr() and BN_GF2m_mod(). + - Fix segfaults in BN_{dec,hex}2bn(). + - Fix NULL dereference in x509_constraints_uri_host() reachable only + in the process of generating certificates. + - Fixed a variety of memory corruption issues in BIO chains coming + from poor old and new API: BIO_push(), BIO_pop(), BIO_set_next(). + - Avoid potential divide by zero in BIO_dump_indent_cb() + * Documentation improvements + - Numerous improvements and additions for ASN.1, BIO, BN, and X.509. + - The BN documentation is now considered to be complete. + * Testing and Proactive Security + - As always, new test coverage is added as bugs are fixed and + subsystems are cleaned up. + - Many old tests rewritten, cleaned up and extended. + * New features + - Added Ed25519 support both as a primitive and via OpenSSL's EVP + interfaces. + - X25519 is now also supported via EVP. + - The OpenSSL 1.1 raw public and private key API is available with + support for EVP_PKEY_ED25519, EVP_PKEY_HMAC and EVP_PKEY_X25519. + Poly1305 is not currently supported via this interface. + 3.6.1 - Stable release * Bug fixes @@ -2563,7 +2671,7 @@ LibreSSL Portable Release Notes: * Address POODLE attack by disabling SSLv3 by default * Fix Eliptical Curve cipher selection bug - (https://github.com/libressl-portable/portable/issues/35) + (https://github.com/libressl/portable/issues/35) 2.1.0 - First release from the OpenBSD 5.7 tree * Added support for automatic ephemeral EC keys diff --git a/Makefile.am b/Makefile.am index ed59df0b..d28692a2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = crypto ssl tls include apps man +SUBDIRS = include crypto ssl tls apps man if ENABLE_TESTS SUBDIRS += tests endif diff --git a/Makefile.am.common b/Makefile.am.common index 87aa8070..5405704b 100644 --- a/Makefile.am.common +++ b/Makefile.am.common @@ -1,3 +1,5 @@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL +AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CPPFLAGS += -I$(abs_top_builddir)/include +AM_CPPFLAGS += -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL AM_CPPFLAGS += -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= diff --git a/Makefile.in b/Makefile.in index b24540eb..d12a8897 100644 --- a/Makefile.in +++ b/Makefile.in @@ -191,7 +191,7 @@ am__define_uniq_tagged_files = \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` -DIST_SUBDIRS = crypto ssl tls include apps man tests +DIST_SUBDIRS = include crypto ssl tls apps man tests am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libcrypto.pc.in \ $(srcdir)/libssl.pc.in $(srcdir)/libtls.pc.in \ $(srcdir)/openssl.pc.in COPYING ChangeLog INSTALL README.md \ @@ -368,7 +368,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUBDIRS = crypto ssl tls include apps man $(am__append_1) +SUBDIRS = include crypto ssl tls apps man $(am__append_1) ACLOCAL_AMFLAGS = -I m4 pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libtls.pc $(am__append_2) diff --git a/README.md b/README.md index 464da181..f4015a1d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ ![LibreSSL image](https://www.libressl.org/images/libressl.jpg) ## Official portable version of [LibreSSL](https://www.libressl.org) ## -[![Linux Build Status](https://github.com/libressl-portable/portable/actions/workflows/linux_test.yml/badge.svg)](https://github.com/libressl-portable/portable/actions/workflows/linux_test.yml) -[![macOS Build Status](https://github.com/libressl-portable/portable/actions/workflows/macos_test.yml/badge.svg)](https://github.com/libressl-portable/portable/actions/workflows/macos_test.yml) -[![Android_Build Status](https://github.com/libressl-portable/portable/actions/workflows/android_test.yml/badge.svg)](https://github.com/libressl-portable/portable/actions/workflows/android_test.yml) -[![Cross_Build Status](https://github.com/libressl-portable/portable/actions/workflows/cross_test.yml/badge.svg)](https://github.com/libressl-portable/portable/actions/workflows/cross_test.yml) +[![Linux Build Status](https://github.com/libressl/portable/actions/workflows/linux_test.yml/badge.svg)](https://github.com/libressl/portable/actions/workflows/linux_test.yml) +[![macOS Build Status](https://github.com/libressl/portable/actions/workflows/macos_test.yml/badge.svg)](https://github.com/libressl/portable/actions/workflows/macos_test.yml) +[![Android_Build Status](https://github.com/libressl/portable/actions/workflows/android_test.yml/badge.svg)](https://github.com/libressl/portable/actions/workflows/android_test.yml) +[![Cross_Build Status](https://github.com/libressl/portable/actions/workflows/cross_test.yml/badge.svg)](https://github.com/libressl/portable/actions/workflows/cross_test.yml) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/libressl.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:libressl) -[![ASan Status](https://github.com/libressl-portable/portable/actions/workflows/linux_test_asan.yml/badge.svg)](https://github.com/libressl-portable/portable/actions/workflows/linux_test_asan.yml) +[![ASan Status](https://github.com/libressl/portable/actions/workflows/linux_test_asan.yml/badge.svg)](https://github.com/libressl/portable/actions/workflows/linux_test_asan.yml) LibreSSL is a fork of [OpenSSL](https://www.openssl.org) 1.0.1g developed by the [OpenBSD](https://www.openbsd.org) project. Our goal is to modernize the codebase, @@ -52,11 +52,11 @@ OpenBSD mirror in directory although we suggest that you use a [mirror](https://www.openbsd.org/ftp.html). The LibreSSL portable build framework is also -[mirrored](https://github.com/libressl-portable/portable) in Github. +[mirrored](https://github.com/libressl/portable) on GitHub. Please report bugs either to the public libressl@openbsd.org mailing list, -or to the github -[issue tracker](https://github.com/libressl-portable/portable/issues) +or to the GitHub +[issue tracker](https://github.com/libressl/portable/issues) Severe vulnerabilities or bugs requiring coordination with OpenSSL can be sent to the core team at libressl-security@openbsd.org. diff --git a/README.windows b/README.windows index a88ddc9c..1a9b7b55 100644 --- a/README.windows +++ b/README.windows @@ -46,7 +46,7 @@ problem. A script for generating ready-to-use .DLL and static .LIB files is included in the source repository at -https://github.com/libressl-portable/portable/blob/master/dist-win.sh +https://github.com/libressl/portable/blob/master/dist-win.sh This script uses mingw-w64 to build LibreSSL and then uses Visual Studio tools to generate compatible library import files ready-to-use with Visual diff --git a/VERSION b/VERSION index 3ccf55a1..e7921720 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -3.6.2.0 +3.7.2.0 diff --git a/apps/Makefile.in b/apps/Makefile.in index dc85fd40..fb9b53cb 100644 --- a/apps/Makefile.in +++ b/apps/Makefile.in @@ -313,9 +313,9 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ - -DLIBRESSL_INTERNAL -D__BEGIN_HIDDEN_DECLS= \ - -D__END_HIDDEN_DECLS= +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(abs_top_builddir)/include \ + -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL \ + -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= SUBDIRS = ocspcheck openssl nc EXTRA_DIST = CMakeLists.txt all: all-recursive diff --git a/apps/nc/Makefile.in b/apps/nc/Makefile.in index fc986495..4e33b9ff 100644 --- a/apps/nc/Makefile.in +++ b/apps/nc/Makefile.in @@ -360,9 +360,9 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ - -DLIBRESSL_INTERNAL -D__BEGIN_HIDDEN_DECLS= \ - -D__END_HIDDEN_DECLS= $(am__append_1) +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(abs_top_builddir)/include \ + -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL \ + -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= $(am__append_1) @BUILD_NC_TRUE@@ENABLE_NC_TRUE@dist_man_MANS = nc.1 @BUILD_NC_TRUE@EXTRA_DIST = nc.1 CMakeLists.txt @BUILD_NC_TRUE@nc_LDADD = $(abs_top_builddir)/tls/libtls.la \ diff --git a/apps/nc/netcat.c b/apps/nc/netcat.c index ec6ad0c8..ad3b4f1b 100644 --- a/apps/nc/netcat.c +++ b/apps/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.219 2022/06/08 20:07:31 tb Exp $ */ +/* $OpenBSD: netcat.c,v 1.225 2023/01/04 12:53:38 deraadt Exp $ */ /* * Copyright (c) 2001 Eric Jackson * Copyright (c) 2015 Bob Beck. All rights reserved. @@ -107,7 +107,7 @@ const char *Kflag; /* Private key file */ const char *oflag; /* OCSP stapling file */ const char *Rflag; /* Root CA file */ int tls_cachanged; /* Using non-default CA file */ -int TLSopt; /* TLS options */ +int TLSopt; /* TLS options */ char *tls_expectname; /* required name in peer cert */ char *tls_expecthash; /* required hash of peer cert */ char *tls_ciphers; /* TLS ciphers */ @@ -135,6 +135,7 @@ int timeout_connect(int, const struct sockaddr *, socklen_t); int socks_connect(const char *, const char *, struct addrinfo, const char *, const char *, struct addrinfo, int, const char *); int udptest(int); +void connection_info(const char *, const char *, const char *, const char *); int unix_bind(char *, int); int unix_connect(char *); int unix_listen(char *); @@ -157,7 +158,6 @@ main(int argc, char *argv[]) char *host, *uport; char ipaddr[NI_MAXHOST]; struct addrinfo hints; - struct servent *sv; socklen_t len; struct sockaddr_storage cliaddr; char *proxy = NULL, *proxyport = NULL; @@ -172,7 +172,6 @@ main(int argc, char *argv[]) socksv = 5; host = NULL; uport = NULL; - sv = NULL; Rflag = tls_default_ca_cert_file(); signal(SIGPIPE, SIG_IGN); @@ -711,36 +710,19 @@ main(int argc, char *argv[]) ret = 0; if (vflag || zflag) { + int print_info = 1; + /* For UDP, make sure we are connected. */ if (uflag) { - if (udptest(s) == -1) { + /* No info on failed or skipped test. */ + if ((print_info = udptest(s)) == -1) { ret = 1; continue; } } - - /* Don't look up port if -n. */ - if (nflag) - sv = NULL; - else { - sv = getservbyport( - ntohs(atoi(portlist[i])), - uflag ? "udp" : "tcp"); - } - - fprintf(stderr, "Connection to %s", host); - - /* - * if we aren't connecting thru a proxy and - * there is something to report, print IP - */ - if (!nflag && !xflag && - strcmp(host, ipaddr) != 0) - fprintf(stderr, " (%s)", ipaddr); - - fprintf(stderr, " %s port [%s/%s] succeeded!\n", - portlist[i], uflag ? "udp" : "tcp", - sv ? sv->s_name : "*"); + if (print_info == 1) + connection_info(host, portlist[i], + uflag ? "udp" : "tcp", ipaddr); } if (Fflag) fdpass(s); @@ -1551,6 +1533,10 @@ udptest(int s) { int i, ret; + /* Only write to the socket in scan mode or interactive mode. */ + if (!zflag && !isatty(STDIN_FILENO)) + return 0; + for (i = 0; i <= 3; i++) { if (write(s, "X", 1) == 1) ret = 1; @@ -1560,6 +1546,32 @@ udptest(int s) return ret; } +void +connection_info(const char *host, const char *port, const char *proto, + const char *ipaddr) +{ + struct servent *sv; + char *service = "*"; + + /* Look up service name unless -n. */ + if (!nflag) { + sv = getservbyport(ntohs(atoi(port)), proto); + if (sv != NULL) + service = sv->s_name; + } + + fprintf(stderr, "Connection to %s", host); + + /* + * if we aren't connecting thru a proxy and + * there is something to report, print IP + */ + if (!nflag && !xflag && strcmp(host, ipaddr) != 0) + fprintf(stderr, " (%s)", ipaddr); + + fprintf(stderr, " %s port [%s/%s] succeeded!\n", port, proto, service); +} + void set_common_sockopts(int s, int af) { diff --git a/apps/ocspcheck/Makefile.in b/apps/ocspcheck/Makefile.in index 49474b87..108eafe1 100644 --- a/apps/ocspcheck/Makefile.in +++ b/apps/ocspcheck/Makefile.in @@ -349,9 +349,9 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ - -DLIBRESSL_INTERNAL -D__BEGIN_HIDDEN_DECLS= \ - -D__END_HIDDEN_DECLS= +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(abs_top_builddir)/include \ + -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL \ + -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= @ENABLE_LIBTLS_ONLY_FALSE@dist_man_MANS = ocspcheck.8 EXTRA_DIST = ocspcheck.8 CMakeLists.txt ocspcheck_LDADD = $(abs_top_builddir)/crypto/libcrypto.la \ diff --git a/apps/ocspcheck/http.c b/apps/ocspcheck/http.c index 16691054..82a504ad 100644 --- a/apps/ocspcheck/http.c +++ b/apps/ocspcheck/http.c @@ -1,4 +1,4 @@ -/* $Id: http.c,v 1.15 2021/09/14 16:37:20 tb Exp $ */ +/* $Id: http.c,v 1.16 2022/12/15 08:07:03 florian Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons * @@ -556,7 +556,7 @@ http_head_parse(const struct http *http, struct httpxfer *trans, size_t *sz) } *ccp++ = '\0'; - while (isspace((int)*ccp)) + while (isspace((unsigned char)*ccp)) ccp++; h[hsz].key = cp; h[hsz++].val = ccp; diff --git a/apps/ocspcheck/ocspcheck.c b/apps/ocspcheck/ocspcheck.c index 46e7e666..516642b5 100644 --- a/apps/ocspcheck/ocspcheck.c +++ b/apps/ocspcheck/ocspcheck.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocspcheck.c,v 1.30 2021/07/12 15:09:21 beck Exp $ */ +/* $OpenBSD: ocspcheck.c,v 1.31 2022/12/28 21:30:17 jmc Exp $ */ /* * Copyright (c) 2017,2020 Bob Beck @@ -379,7 +379,7 @@ ocsp_request_new_from_cert(const char *cadir, char *file, int nonce) goto err; } if (request->data == NULL) { - warnx("Unable to allocte memory"); + warnx("Unable to allocate memory"); goto err; } return request; diff --git a/apps/openssl/Makefile.in b/apps/openssl/Makefile.in index caafd0b3..1319f6f9 100644 --- a/apps/openssl/Makefile.in +++ b/apps/openssl/Makefile.in @@ -404,9 +404,9 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ - -DLIBRESSL_INTERNAL -D__BEGIN_HIDDEN_DECLS= \ - -D__END_HIDDEN_DECLS= +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(abs_top_builddir)/include \ + -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL \ + -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= @ENABLE_LIBTLS_ONLY_FALSE@dist_man_MANS = openssl.1 openssl_LDADD = $(abs_top_builddir)/ssl/libssl.la \ $(abs_top_builddir)/crypto/libcrypto.la $(PLATFORM_LDADD) \ diff --git a/apps/openssl/asn1pars.c b/apps/openssl/asn1pars.c index 38d12f61..3eac72cb 100644 --- a/apps/openssl/asn1pars.c +++ b/apps/openssl/asn1pars.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1pars.c,v 1.11 2022/01/12 22:55:51 tb Exp $ */ +/* $OpenBSD: asn1pars.c,v 1.15 2023/03/10 09:44:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -86,14 +86,14 @@ static struct { int offset; char *oidfile; STACK_OF(OPENSSL_STRING) *osk; -} asn1pars_config; +} cfg; static int asn1pars_opt_dlimit(char *arg) { const char *errstr; - asn1pars_config.dump = strtonum(arg, 1, INT_MAX, &errstr); + cfg.dump = strtonum(arg, 1, INT_MAX, &errstr); if (errstr) { fprintf(stderr, "-dlimit must be from 1 to INT_MAX: %s\n", errstr); @@ -107,7 +107,7 @@ asn1pars_opt_length(char *arg) { const char *errstr; - asn1pars_config.length = strtonum(arg, 1, UINT_MAX, &errstr); + cfg.length = strtonum(arg, 1, UINT_MAX, &errstr); if (errstr) { fprintf(stderr, "-length must be from 1 to UINT_MAX: %s\n", errstr); @@ -119,7 +119,7 @@ asn1pars_opt_length(char *arg) static int asn1pars_opt_strparse(char *arg) { - if (sk_OPENSSL_STRING_push(asn1pars_config.osk, arg) == 0) { + if (sk_OPENSSL_STRING_push(cfg.osk, arg) == 0) { fprintf(stderr, "-strparse cannot add argument\n"); return (-1); } @@ -132,7 +132,7 @@ static const struct option asn1pars_options[] = { .desc = "Dump unknown data in hex form", .type = OPTION_VALUE, .value = -1, - .opt.value = &asn1pars_config.dump, + .opt.value = &cfg.dump, }, { .name = "dlimit", @@ -146,34 +146,34 @@ static const struct option asn1pars_options[] = { .argname = "file", .desc = "File to generate ASN.1 structure from", .type = OPTION_ARG, - .opt.arg = &asn1pars_config.genconf, + .opt.arg = &cfg.genconf, }, { .name = "genstr", .argname = "string", .desc = "String to generate ASN.1 structure from", .type = OPTION_ARG, - .opt.arg = &asn1pars_config.genstr, + .opt.arg = &cfg.genstr, }, { .name = "i", .desc = "Indent output according to depth of structures", .type = OPTION_FLAG, - .opt.flag = &asn1pars_config.indent, + .opt.flag = &cfg.indent, }, { .name = "in", .argname = "file", .desc = "The input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &asn1pars_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "fmt", .desc = "Input format (DER, TXT or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &asn1pars_config.informat, + .opt.value = &cfg.informat, }, { .name = "length", @@ -186,28 +186,28 @@ static const struct option asn1pars_options[] = { .name = "noout", .desc = "Do not produce any output", .type = OPTION_FLAG, - .opt.flag = &asn1pars_config.noout, + .opt.flag = &cfg.noout, }, { .name = "offset", .argname = "num", .desc = "Offset to begin parsing", .type = OPTION_ARG_INT, - .opt.value = &asn1pars_config.offset, + .opt.value = &cfg.offset, }, { .name = "oid", .argname = "file", .desc = "File containing additional object identifiers (OIDs)", .type = OPTION_ARG, - .opt.arg = &asn1pars_config.oidfile, + .opt.arg = &cfg.oidfile, }, { .name = "out", .argname = "file", .desc = "Output file in DER format", .type = OPTION_ARG, - .opt.arg = &asn1pars_config.derfile, + .opt.arg = &cfg.derfile, }, { .name = "strparse", @@ -247,17 +247,15 @@ asn1parse_main(int argc, char **argv) BUF_MEM *buf = NULL; ASN1_TYPE *at = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&asn1pars_config, 0, sizeof(asn1pars_config)); + memset(&cfg, 0, sizeof(cfg)); - asn1pars_config.informat = FORMAT_PEM; - if ((asn1pars_config.osk = sk_OPENSSL_STRING_new_null()) == NULL) { + cfg.informat = FORMAT_PEM; + if ((cfg.osk = sk_OPENSSL_STRING_new_null()) == NULL) { BIO_printf(bio_err, "Memory allocation failure\n"); goto end; } @@ -269,34 +267,34 @@ asn1parse_main(int argc, char **argv) in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); - if ((in == NULL) || (out == NULL)) { + if (in == NULL || out == NULL) { ERR_print_errors(bio_err); goto end; } BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); - if (asn1pars_config.oidfile != NULL) { - if (BIO_read_filename(in, asn1pars_config.oidfile) <= 0) { + if (cfg.oidfile != NULL) { + if (BIO_read_filename(in, cfg.oidfile) <= 0) { BIO_printf(bio_err, "problems opening %s\n", - asn1pars_config.oidfile); + cfg.oidfile); ERR_print_errors(bio_err); goto end; } OBJ_create_objects(in); } - if (asn1pars_config.infile == NULL) + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, asn1pars_config.infile) <= 0) { - perror(asn1pars_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } - if (asn1pars_config.derfile) { - if (!(derout = BIO_new_file(asn1pars_config.derfile, "wb"))) { + if (cfg.derfile != NULL) { + if ((derout = BIO_new_file(cfg.derfile, "wb")) == NULL) { BIO_printf(bio_err, "problems opening %s\n", - asn1pars_config.derfile); + cfg.derfile); ERR_print_errors(bio_err); goto end; } @@ -304,18 +302,16 @@ asn1parse_main(int argc, char **argv) if ((buf = BUF_MEM_new()) == NULL) goto end; if (!BUF_MEM_grow(buf, BUFSIZ * 8)) - goto end; /* Pre-allocate :-) */ + goto end; - if (asn1pars_config.genstr || asn1pars_config.genconf) { - num = do_generate(bio_err, asn1pars_config.genstr, - asn1pars_config.genconf, buf); + if (cfg.genstr != NULL || cfg.genconf) { + num = do_generate(bio_err, cfg.genstr, cfg.genconf, buf); if (num < 0) { ERR_print_errors(bio_err); goto end; } } else { - - if (asn1pars_config.informat == FORMAT_PEM) { + if (cfg.informat == FORMAT_PEM) { BIO *tmp; if ((b64 = BIO_new(BIO_f_base64())) == NULL) @@ -339,21 +335,18 @@ asn1parse_main(int argc, char **argv) /* If any structs to parse go through in sequence */ - if (sk_OPENSSL_STRING_num(asn1pars_config.osk)) { + if (sk_OPENSSL_STRING_num(cfg.osk) > 0) { tmpbuf = (unsigned char *) str; tmplen = num; - for (i = 0; i < sk_OPENSSL_STRING_num(asn1pars_config.osk); - i++) { + for (i = 0; i < sk_OPENSSL_STRING_num(cfg.osk); i++) { ASN1_TYPE *atmp; int typ; - j = strtonum( - sk_OPENSSL_STRING_value(asn1pars_config.osk, i), + j = strtonum(sk_OPENSSL_STRING_value(cfg.osk, i), 1, INT_MAX, &errstr); if (errstr) { BIO_printf(bio_err, "'%s' is an invalid number: %s\n", - sk_OPENSSL_STRING_value(asn1pars_config.osk, - i), errstr); + sk_OPENSSL_STRING_value(cfg.osk, i), errstr); continue; } tmpbuf += j; @@ -368,10 +361,10 @@ asn1parse_main(int argc, char **argv) goto end; } typ = ASN1_TYPE_get(at); - if ((typ == V_ASN1_OBJECT) || - (typ == V_ASN1_NULL)) { + if (typ == V_ASN1_BOOLEAN || typ == V_ASN1_NULL || + typ == V_ASN1_OBJECT) { BIO_printf(bio_err, "Can't parse %s type\n", - typ == V_ASN1_NULL ? "NULL" : "OBJECT"); + ASN1_tag2str(typ)); ERR_print_errors(bio_err); goto end; } @@ -382,28 +375,24 @@ asn1parse_main(int argc, char **argv) str = (char *) tmpbuf; num = tmplen; } - if (asn1pars_config.offset >= num) { + if (cfg.offset >= num) { BIO_printf(bio_err, "Error: offset too large\n"); goto end; } - num -= asn1pars_config.offset; - - if ((asn1pars_config.length == 0) || - ((long)asn1pars_config.length > num)) - asn1pars_config.length = (unsigned int) num; - if (derout) { - if (BIO_write(derout, str + asn1pars_config.offset, - asn1pars_config.length) != (int)asn1pars_config.length) { + num -= cfg.offset; + + if (cfg.length == 0 || (long)cfg.length > num) + cfg.length = (unsigned int) num; + if (derout != NULL) { + if (BIO_write(derout, str + cfg.offset, + cfg.length) != (int)cfg.length) { BIO_printf(bio_err, "Error writing output\n"); ERR_print_errors(bio_err); goto end; } } - if (!asn1pars_config.noout && - !ASN1_parse_dump(out, - (unsigned char *)&(str[asn1pars_config.offset]), - asn1pars_config.length, asn1pars_config.indent, - asn1pars_config.dump)) { + if (!cfg.noout && !ASN1_parse_dump(out, + (unsigned char *)&str[cfg.offset], cfg.length, cfg.indent, cfg.dump)) { ERR_print_errors(bio_err); goto end; } @@ -417,7 +406,7 @@ asn1parse_main(int argc, char **argv) ERR_print_errors(bio_err); BUF_MEM_free(buf); ASN1_TYPE_free(at); - sk_OPENSSL_STRING_free(asn1pars_config.osk); + sk_OPENSSL_STRING_free(cfg.osk); OBJ_cleanup(); return (ret); diff --git a/apps/openssl/ca.c b/apps/openssl/ca.c index bbc5403e..369d11ea 100644 --- a/apps/openssl/ca.c +++ b/apps/openssl/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.53 2022/02/03 17:44:04 tb Exp $ */ +/* $OpenBSD: ca.c,v 1.55 2023/03/06 14:32:05 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -207,63 +207,63 @@ static struct { char *startdate; char *subj; int verbose; -} ca_config; +} cfg; static int ca_opt_chtype_utf8(void) { - ca_config.chtype = MBSTRING_UTF8; + cfg.chtype = MBSTRING_UTF8; return (0); } static int ca_opt_crl_ca_compromise(char *arg) { - ca_config.rev_arg = arg; - ca_config.rev_type = REV_CA_COMPROMISE; + cfg.rev_arg = arg; + cfg.rev_type = REV_CA_COMPROMISE; return (0); } static int ca_opt_crl_compromise(char *arg) { - ca_config.rev_arg = arg; - ca_config.rev_type = REV_KEY_COMPROMISE; + cfg.rev_arg = arg; + cfg.rev_type = REV_KEY_COMPROMISE; return (0); } static int ca_opt_crl_hold(char *arg) { - ca_config.rev_arg = arg; - ca_config.rev_type = REV_HOLD; + cfg.rev_arg = arg; + cfg.rev_type = REV_HOLD; return (0); } static int ca_opt_crl_reason(char *arg) { - ca_config.rev_arg = arg; - ca_config.rev_type = REV_CRL_REASON; + cfg.rev_arg = arg; + cfg.rev_type = REV_CRL_REASON; return (0); } static int ca_opt_in(char *arg) { - ca_config.infile = arg; - ca_config.req = 1; + cfg.infile = arg; + cfg.req = 1; return (0); } static int ca_opt_infiles(int argc, char **argv, int *argsused) { - ca_config.infiles_num = argc - 1; - if (ca_config.infiles_num < 1) + cfg.infiles_num = argc - 1; + if (cfg.infiles_num < 1) return (1); - ca_config.infiles = argv + 1; - ca_config.req = 1; + cfg.infiles = argv + 1; + cfg.req = 1; *argsused = argc; return (0); } @@ -271,19 +271,19 @@ ca_opt_infiles(int argc, char **argv, int *argsused) static int ca_opt_revoke(char *arg) { - ca_config.infile = arg; - ca_config.dorevoke = 1; + cfg.infile = arg; + cfg.dorevoke = 1; return (0); } static int ca_opt_sigopt(char *arg) { - if (ca_config.sigopts == NULL) - ca_config.sigopts = sk_OPENSSL_STRING_new_null(); - if (ca_config.sigopts == NULL) + if (cfg.sigopts == NULL) + cfg.sigopts = sk_OPENSSL_STRING_new_null(); + if (cfg.sigopts == NULL) return (1); - if (!sk_OPENSSL_STRING_push(ca_config.sigopts, arg)) + if (!sk_OPENSSL_STRING_push(cfg.sigopts, arg)) return (1); return (0); } @@ -291,16 +291,16 @@ ca_opt_sigopt(char *arg) static int ca_opt_spkac(char *arg) { - ca_config.spkac_file = arg; - ca_config.req = 1; + cfg.spkac_file = arg; + cfg.req = 1; return (0); } static int ca_opt_ss_cert(char *arg) { - ca_config.ss_cert_file = arg; - ca_config.req = 1; + cfg.ss_cert_file = arg; + cfg.req = 1; return (0); } @@ -309,27 +309,27 @@ static const struct option ca_options[] = { .name = "batch", .desc = "Operate in batch mode", .type = OPTION_FLAG, - .opt.flag = &ca_config.batch, + .opt.flag = &cfg.batch, }, { .name = "cert", .argname = "file", .desc = "File containing the CA certificate", .type = OPTION_ARG, - .opt.arg = &ca_config.certfile, + .opt.arg = &cfg.certfile, }, { .name = "config", .argname = "file", .desc = "Specify an alternative configuration file", .type = OPTION_ARG, - .opt.arg = &ca_config.configfile, + .opt.arg = &cfg.configfile, }, { .name = "create_serial", .desc = "If reading serial fails, create a new random serial", .type = OPTION_FLAG, - .opt.flag = &ca_config.create_serial, + .opt.flag = &cfg.create_serial, }, { .name = "crl_CA_compromise", @@ -367,62 +367,62 @@ static const struct option ca_options[] = { .argname = "days", .desc = "Number of days before the next CRL is due", .type = OPTION_ARG_LONG, - .opt.lvalue = &ca_config.crldays, + .opt.lvalue = &cfg.crldays, }, { .name = "crlexts", .argname = "section", .desc = "CRL extension section (override value in config file)", .type = OPTION_ARG, - .opt.arg = &ca_config.crl_ext, + .opt.arg = &cfg.crl_ext, }, { .name = "crlhours", .argname = "hours", .desc = "Number of hours before the next CRL is due", .type = OPTION_ARG_LONG, - .opt.lvalue = &ca_config.crlhours, + .opt.lvalue = &cfg.crlhours, }, { .name = "crlsec", .argname = "seconds", .desc = "Number of seconds before the next CRL is due", .type = OPTION_ARG_LONG, - .opt.lvalue = &ca_config.crlsec, + .opt.lvalue = &cfg.crlsec, }, { .name = "days", .argname = "arg", .desc = "Number of days to certify the certificate for", .type = OPTION_ARG_LONG, - .opt.lvalue = &ca_config.days, + .opt.lvalue = &cfg.days, }, { .name = "enddate", .argname = "YYMMDDHHMMSSZ", .desc = "Certificate validity notAfter (overrides -days)", .type = OPTION_ARG, - .opt.arg = &ca_config.enddate, + .opt.arg = &cfg.enddate, }, { .name = "extensions", .argname = "section", .desc = "Extension section (override value in config file)", .type = OPTION_ARG, - .opt.arg = &ca_config.extensions, + .opt.arg = &cfg.extensions, }, { .name = "extfile", .argname = "file", .desc = "Configuration file with X509v3 extentions to add", .type = OPTION_ARG, - .opt.arg = &ca_config.extfile, + .opt.arg = &cfg.extfile, }, { .name = "gencrl", .desc = "Generate a new CRL", .type = OPTION_FLAG, - .opt.flag = &ca_config.gencrl, + .opt.flag = &cfg.gencrl, }, { .name = "in", @@ -443,93 +443,93 @@ static const struct option ca_options[] = { .argname = "password", .desc = "Key to decode the private key if it is encrypted", .type = OPTION_ARG, - .opt.arg = &ca_config.key, + .opt.arg = &cfg.key, }, { .name = "keyfile", .argname = "file", .desc = "Private key file", .type = OPTION_ARG, - .opt.arg = &ca_config.keyfile, + .opt.arg = &cfg.keyfile, }, { .name = "keyform", .argname = "fmt", .desc = "Private key file format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &ca_config.keyform, + .opt.value = &cfg.keyform, }, { .name = "md", .argname = "alg", .desc = "Message digest to use", .type = OPTION_ARG, - .opt.arg = &ca_config.md, + .opt.arg = &cfg.md, }, { .name = "msie_hack", .type = OPTION_FLAG, - .opt.flag = &ca_config.msie_hack, + .opt.flag = &cfg.msie_hack, }, { .name = "multivalue-rdn", .desc = "Enable support for multivalued RDNs", .type = OPTION_FLAG, - .opt.flag = &ca_config.multirdn, + .opt.flag = &cfg.multirdn, }, { .name = "name", .argname = "section", .desc = "Specifies the configuration file section to use", .type = OPTION_ARG, - .opt.arg = &ca_config.section, + .opt.arg = &cfg.section, }, { .name = "noemailDN", .desc = "Do not add the EMAIL field to the DN", .type = OPTION_VALUE, - .opt.value = &ca_config.email_dn, + .opt.value = &cfg.email_dn, .value = 0, }, { .name = "notext", .desc = "Do not print the generated certificate", .type = OPTION_FLAG, - .opt.flag = &ca_config.notext, + .opt.flag = &cfg.notext, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &ca_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outdir", .argname = "directory", .desc = " Directory to output certificates to", .type = OPTION_ARG, - .opt.arg = &ca_config.outdir, + .opt.arg = &cfg.outdir, }, { .name = "passin", .argname = "src", .desc = "Private key input password source", .type = OPTION_ARG, - .opt.arg = &ca_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "policy", .argname = "name", .desc = "The CA 'policy' to support", .type = OPTION_ARG, - .opt.arg = &ca_config.policy, + .opt.arg = &cfg.policy, }, { .name = "preserveDN", .desc = "Do not re-order the DN", .type = OPTION_FLAG, - .opt.flag = &ca_config.preserve, + .opt.flag = &cfg.preserve, }, { .name = "revoke", @@ -542,7 +542,7 @@ static const struct option ca_options[] = { .name = "selfsign", .desc = "Sign a certificate using the key associated with it", .type = OPTION_FLAG, - .opt.flag = &ca_config.selfsign, + .opt.flag = &cfg.selfsign, }, { .name = "sigopt", @@ -570,27 +570,27 @@ static const struct option ca_options[] = { .argname = "YYMMDDHHMMSSZ", .desc = "Certificate validity notBefore", .type = OPTION_ARG, - .opt.arg = &ca_config.startdate, + .opt.arg = &cfg.startdate, }, { .name = "status", .argname = "serial", .desc = "Shows certificate status given the serial number", .type = OPTION_ARG, - .opt.arg = &ca_config.serial_status, + .opt.arg = &cfg.serial_status, }, { .name = "subj", .argname = "arg", .desc = "Use arg instead of request's subject", .type = OPTION_ARG, - .opt.arg = &ca_config.subj, + .opt.arg = &cfg.subj, }, { .name = "updatedb", .desc = "Updates db for expired certificates", .type = OPTION_FLAG, - .opt.flag = &ca_config.doupdatedb, + .opt.flag = &cfg.doupdatedb, }, { .name = "utf8", @@ -602,7 +602,7 @@ static const struct option ca_options[] = { .name = "verbose", .desc = "Verbose output during processing", .type = OPTION_FLAG, - .opt.flag = &ca_config.verbose, + .opt.flag = &cfg.verbose, }, { NULL }, }; @@ -685,18 +685,16 @@ ca_main(int argc, char **argv) char *tofree = NULL; DB_ATTR db_attr; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&ca_config, 0, sizeof(ca_config)); - ca_config.email_dn = 1; - ca_config.keyform = FORMAT_PEM; - ca_config.chtype = MBSTRING_ASC; - ca_config.rev_type = REV_NONE; + memset(&cfg, 0, sizeof(cfg)); + cfg.email_dn = 1; + cfg.keyform = FORMAT_PEM; + cfg.chtype = MBSTRING_ASC; + cfg.rev_type = REV_NONE; conf = NULL; @@ -707,37 +705,37 @@ ca_main(int argc, char **argv) /*****************************************************************/ tofree = NULL; - if (ca_config.configfile == NULL) - ca_config.configfile = getenv("OPENSSL_CONF"); - if (ca_config.configfile == NULL) { + if (cfg.configfile == NULL) + cfg.configfile = getenv("OPENSSL_CONF"); + if (cfg.configfile == NULL) { if ((tofree = make_config_name()) == NULL) { BIO_printf(bio_err, "error making config file name\n"); goto err; } - ca_config.configfile = tofree; + cfg.configfile = tofree; } BIO_printf(bio_err, "Using configuration from %s\n", - ca_config.configfile); + cfg.configfile); conf = NCONF_new(NULL); - if (NCONF_load(conf, ca_config.configfile, &errorline) <= 0) { + if (NCONF_load(conf, cfg.configfile, &errorline) <= 0) { if (errorline <= 0) BIO_printf(bio_err, "error loading the config file '%s'\n", - ca_config.configfile); + cfg.configfile); else BIO_printf(bio_err, "error on line %ld of config file '%s'\n", - errorline, ca_config.configfile); + errorline, cfg.configfile); goto err; } free(tofree); tofree = NULL; /* Lets get the config section we are using */ - if (ca_config.section == NULL) { - ca_config.section = NCONF_get_string(conf, BASE_SECTION, + if (cfg.section == NULL) { + cfg.section = NCONF_get_string(conf, BASE_SECTION, ENV_DEFAULT_CA); - if (ca_config.section == NULL) { + if (cfg.section == NULL) { lookup_fail(BASE_SECTION, ENV_DEFAULT_CA); goto err; } @@ -767,7 +765,7 @@ ca_main(int argc, char **argv) goto err; } } - f = NCONF_get_string(conf, ca_config.section, STRING_MASK); + f = NCONF_get_string(conf, cfg.section, STRING_MASK); if (f == NULL) ERR_clear_error(); @@ -776,15 +774,15 @@ ca_main(int argc, char **argv) "Invalid global string mask setting %s\n", f); goto err; } - if (ca_config.chtype != MBSTRING_UTF8) { - f = NCONF_get_string(conf, ca_config.section, UTF8_IN); + if (cfg.chtype != MBSTRING_UTF8) { + f = NCONF_get_string(conf, cfg.section, UTF8_IN); if (f == NULL) ERR_clear_error(); else if (strcmp(f, "yes") == 0) - ca_config.chtype = MBSTRING_UTF8; + cfg.chtype = MBSTRING_UTF8; } db_attr.unique_subject = 1; - p = NCONF_get_string(conf, ca_config.section, ENV_UNIQUE_SUBJECT); + p = NCONF_get_string(conf, cfg.section, ENV_UNIQUE_SUBJECT); if (p != NULL) { db_attr.unique_subject = parse_yesno(p, 1); } else @@ -800,10 +798,10 @@ ca_main(int argc, char **argv) } /*****************************************************************/ /* report status of cert with serial number given on command line */ - if (ca_config.serial_status) { - if ((dbfile = NCONF_get_string(conf, ca_config.section, + if (cfg.serial_status) { + if ((dbfile = NCONF_get_string(conf, cfg.section, ENV_DATABASE)) == NULL) { - lookup_fail(ca_config.section, ENV_DATABASE); + lookup_fail(cfg.section, ENV_DATABASE); goto err; } db = load_index(dbfile, &db_attr); @@ -813,47 +811,47 @@ ca_main(int argc, char **argv) if (!index_index(db)) goto err; - if (get_certificate_status(ca_config.serial_status, db) != 1) + if (get_certificate_status(cfg.serial_status, db) != 1) BIO_printf(bio_err, "Error verifying serial %s!\n", - ca_config.serial_status); + cfg.serial_status); goto err; } /*****************************************************************/ /* we definitely need a private key, so let's get it */ - if ((ca_config.keyfile == NULL) && - ((ca_config.keyfile = NCONF_get_string(conf, ca_config.section, + if ((cfg.keyfile == NULL) && + ((cfg.keyfile = NCONF_get_string(conf, cfg.section, ENV_PRIVATE_KEY)) == NULL)) { - lookup_fail(ca_config.section, ENV_PRIVATE_KEY); + lookup_fail(cfg.section, ENV_PRIVATE_KEY); goto err; } - if (ca_config.key == NULL) { + if (cfg.key == NULL) { free_key = 1; - if (!app_passwd(bio_err, ca_config.passargin, NULL, - &ca_config.key, NULL)) { + if (!app_passwd(bio_err, cfg.passargin, NULL, + &cfg.key, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto err; } } - pkey = load_key(bio_err, ca_config.keyfile, ca_config.keyform, 0, - ca_config.key, "CA private key"); - if (ca_config.key != NULL) - explicit_bzero(ca_config.key, strlen(ca_config.key)); + pkey = load_key(bio_err, cfg.keyfile, cfg.keyform, 0, + cfg.key, "CA private key"); + if (cfg.key != NULL) + explicit_bzero(cfg.key, strlen(cfg.key)); if (pkey == NULL) { /* load_key() has already printed an appropriate message */ goto err; } /*****************************************************************/ /* we need a certificate */ - if (!ca_config.selfsign || ca_config.spkac_file != NULL || - ca_config.ss_cert_file != NULL || ca_config.gencrl) { - if ((ca_config.certfile == NULL) && - ((ca_config.certfile = NCONF_get_string(conf, - ca_config.section, ENV_CERTIFICATE)) == NULL)) { - lookup_fail(ca_config.section, ENV_CERTIFICATE); + if (!cfg.selfsign || cfg.spkac_file != NULL || + cfg.ss_cert_file != NULL || cfg.gencrl) { + if ((cfg.certfile == NULL) && + ((cfg.certfile = NCONF_get_string(conf, + cfg.section, ENV_CERTIFICATE)) == NULL)) { + lookup_fail(cfg.section, ENV_CERTIFICATE); goto err; } - x509 = load_cert(bio_err, ca_config.certfile, FORMAT_PEM, NULL, + x509 = load_cert(bio_err, cfg.certfile, FORMAT_PEM, NULL, "CA certificate"); if (x509 == NULL) goto err; @@ -864,21 +862,21 @@ ca_main(int argc, char **argv) goto err; } } - if (!ca_config.selfsign) + if (!cfg.selfsign) x509p = x509; f = NCONF_get_string(conf, BASE_SECTION, ENV_PRESERVE); if (f == NULL) ERR_clear_error(); if ((f != NULL) && ((*f == 'y') || (*f == 'Y'))) - ca_config.preserve = 1; + cfg.preserve = 1; f = NCONF_get_string(conf, BASE_SECTION, ENV_MSIE_HACK); if (f == NULL) ERR_clear_error(); if ((f != NULL) && ((*f == 'y') || (*f == 'Y'))) - ca_config.msie_hack = 1; + cfg.msie_hack = 1; - f = NCONF_get_string(conf, ca_config.section, ENV_NAMEOPT); + f = NCONF_get_string(conf, cfg.section, ENV_NAMEOPT); if (f != NULL) { if (!set_name_ex(&nameopt, f)) { @@ -890,7 +888,7 @@ ca_main(int argc, char **argv) } else ERR_clear_error(); - f = NCONF_get_string(conf, ca_config.section, ENV_CERTOPT); + f = NCONF_get_string(conf, cfg.section, ENV_CERTOPT); if (f != NULL) { if (!set_cert_ex(&certopt, f)) { @@ -902,7 +900,7 @@ ca_main(int argc, char **argv) } else ERR_clear_error(); - f = NCONF_get_string(conf, ca_config.section, ENV_EXTCOPY); + f = NCONF_get_string(conf, cfg.section, ENV_EXTCOPY); if (f != NULL) { if (!set_ext_copy(&ext_copy, f)) { @@ -915,9 +913,9 @@ ca_main(int argc, char **argv) /*****************************************************************/ /* lookup where to write new certificates */ - if (ca_config.outdir == NULL && ca_config.req) { - if ((ca_config.outdir = NCONF_get_string(conf, - ca_config.section, ENV_NEW_CERTS_DIR)) == NULL) { + if (cfg.outdir == NULL && cfg.req) { + if ((cfg.outdir = NCONF_get_string(conf, + cfg.section, ENV_NEW_CERTS_DIR)) == NULL) { BIO_printf(bio_err, "output directory %s not defined\n", ENV_NEW_CERTS_DIR); goto err; @@ -925,9 +923,9 @@ ca_main(int argc, char **argv) } /*****************************************************************/ /* we need to load the database file */ - if ((dbfile = NCONF_get_string(conf, ca_config.section, + if ((dbfile = NCONF_get_string(conf, cfg.section, ENV_DATABASE)) == NULL) { - lookup_fail(ca_config.section, ENV_DATABASE); + lookup_fail(cfg.section, ENV_DATABASE); goto err; } db = load_index(dbfile, &db_attr); @@ -978,7 +976,7 @@ ca_main(int argc, char **argv) p++; } } - if (ca_config.verbose) { + if (cfg.verbose) { BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); TXT_DB_write(out, db->db); BIO_printf(bio_err, "%d entries loaded from the database\n", @@ -990,8 +988,8 @@ ca_main(int argc, char **argv) /*****************************************************************/ /* Update the db file for expired certificates */ - if (ca_config.doupdatedb) { - if (ca_config.verbose) + if (cfg.doupdatedb) { + if (cfg.verbose) BIO_printf(bio_err, "Updating %s ...\n", dbfile); i = do_updatedb(db); @@ -999,7 +997,7 @@ ca_main(int argc, char **argv) BIO_printf(bio_err, "Malloc failure\n"); goto err; } else if (i == 0) { - if (ca_config.verbose) + if (cfg.verbose) BIO_printf(bio_err, "No entries found to mark expired\n"); } else { @@ -1009,92 +1007,92 @@ ca_main(int argc, char **argv) if (!rotate_index(dbfile, "new", "old")) goto err; - if (ca_config.verbose) + if (cfg.verbose) BIO_printf(bio_err, "Done. %d entries marked as expired\n", i); } } /*****************************************************************/ /* Read extentions config file */ - if (ca_config.extfile != NULL) { + if (cfg.extfile != NULL) { extconf = NCONF_new(NULL); - if (NCONF_load(extconf, ca_config.extfile, &errorline) <= 0) { + if (NCONF_load(extconf, cfg.extfile, &errorline) <= 0) { if (errorline <= 0) BIO_printf(bio_err, "ERROR: loading the config file '%s'\n", - ca_config.extfile); + cfg.extfile); else BIO_printf(bio_err, "ERROR: on line %ld of config file '%s'\n", - errorline, ca_config.extfile); + errorline, cfg.extfile); ret = 1; goto err; } - if (ca_config.verbose) + if (cfg.verbose) BIO_printf(bio_err, "Successfully loaded extensions file %s\n", - ca_config.extfile); + cfg.extfile); /* We can have sections in the ext file */ - if (ca_config.extensions == NULL && - (ca_config.extensions = NCONF_get_string(extconf, "default", + if (cfg.extensions == NULL && + (cfg.extensions = NCONF_get_string(extconf, "default", "extensions")) == NULL) - ca_config.extensions = "default"; + cfg.extensions = "default"; } /*****************************************************************/ - if (ca_config.req || ca_config.gencrl) { - if (ca_config.outfile != NULL) { - if (BIO_write_filename(Sout, ca_config.outfile) <= 0) { - perror(ca_config.outfile); + if (cfg.req || cfg.gencrl) { + if (cfg.outfile != NULL) { + if (BIO_write_filename(Sout, cfg.outfile) <= 0) { + perror(cfg.outfile); goto err; } } else { BIO_set_fp(Sout, stdout, BIO_NOCLOSE | BIO_FP_TEXT); } } - if ((ca_config.md == NULL) && - ((ca_config.md = NCONF_get_string(conf, ca_config.section, + if ((cfg.md == NULL) && + ((cfg.md = NCONF_get_string(conf, cfg.section, ENV_DEFAULT_MD)) == NULL)) { - lookup_fail(ca_config.section, ENV_DEFAULT_MD); + lookup_fail(cfg.section, ENV_DEFAULT_MD); goto err; } - if (strcmp(ca_config.md, "default") == 0) { + if (strcmp(cfg.md, "default") == 0) { int def_nid; if (EVP_PKEY_get_default_digest_nid(pkey, &def_nid) <= 0) { BIO_puts(bio_err, "no default digest\n"); goto err; } - ca_config.md = (char *) OBJ_nid2sn(def_nid); - if (ca_config.md == NULL) + cfg.md = (char *) OBJ_nid2sn(def_nid); + if (cfg.md == NULL) goto err; } - if ((dgst = EVP_get_digestbyname(ca_config.md)) == NULL) { + if ((dgst = EVP_get_digestbyname(cfg.md)) == NULL) { BIO_printf(bio_err, - "%s is an unsupported message digest type\n", ca_config.md); + "%s is an unsupported message digest type\n", cfg.md); goto err; } - if (ca_config.req) { - if ((ca_config.email_dn == 1) && - ((tmp_email_dn = NCONF_get_string(conf, ca_config.section, + if (cfg.req) { + if ((cfg.email_dn == 1) && + ((tmp_email_dn = NCONF_get_string(conf, cfg.section, ENV_DEFAULT_EMAIL_DN)) != NULL)) { if (strcmp(tmp_email_dn, "no") == 0) - ca_config.email_dn = 0; + cfg.email_dn = 0; } - if (ca_config.verbose) + if (cfg.verbose) BIO_printf(bio_err, "message digest is %s\n", OBJ_nid2ln(EVP_MD_type(dgst))); - if ((ca_config.policy == NULL) && - ((ca_config.policy = NCONF_get_string(conf, - ca_config.section, ENV_POLICY)) == NULL)) { - lookup_fail(ca_config.section, ENV_POLICY); + if ((cfg.policy == NULL) && + ((cfg.policy = NCONF_get_string(conf, + cfg.section, ENV_POLICY)) == NULL)) { + lookup_fail(cfg.section, ENV_POLICY); goto err; } - if (ca_config.verbose) - BIO_printf(bio_err, "policy is %s\n", ca_config.policy); + if (cfg.verbose) + BIO_printf(bio_err, "policy is %s\n", cfg.policy); - if ((serialfile = NCONF_get_string(conf, ca_config.section, + if ((serialfile = NCONF_get_string(conf, cfg.section, ENV_SERIAL)) == NULL) { - lookup_fail(ca_config.section, ENV_SERIAL); + lookup_fail(cfg.section, ENV_SERIAL); goto err; } if (extconf == NULL) { @@ -1102,59 +1100,59 @@ ca_main(int argc, char **argv) * no '-extfile' option, so we look for extensions in * the main configuration file */ - if (ca_config.extensions == NULL) { - ca_config.extensions = NCONF_get_string(conf, - ca_config.section, ENV_EXTENSIONS); - if (ca_config.extensions == NULL) + if (cfg.extensions == NULL) { + cfg.extensions = NCONF_get_string(conf, + cfg.section, ENV_EXTENSIONS); + if (cfg.extensions == NULL) ERR_clear_error(); } - if (ca_config.extensions != NULL) { + if (cfg.extensions != NULL) { /* Check syntax of file */ X509V3_CTX ctx; X509V3_set_ctx_test(&ctx); X509V3_set_nconf(&ctx, conf); if (!X509V3_EXT_add_nconf(conf, &ctx, - ca_config.extensions, NULL)) { + cfg.extensions, NULL)) { BIO_printf(bio_err, "Error Loading extension section %s\n", - ca_config.extensions); + cfg.extensions); ret = 1; goto err; } } } - if (ca_config.startdate == NULL) { - ca_config.startdate = NCONF_get_string(conf, - ca_config.section, ENV_DEFAULT_STARTDATE); - if (ca_config.startdate == NULL) + if (cfg.startdate == NULL) { + cfg.startdate = NCONF_get_string(conf, + cfg.section, ENV_DEFAULT_STARTDATE); + if (cfg.startdate == NULL) ERR_clear_error(); } - if (ca_config.startdate == NULL) - ca_config.startdate = "today"; + if (cfg.startdate == NULL) + cfg.startdate = "today"; - if (ca_config.enddate == NULL) { - ca_config.enddate = NCONF_get_string(conf, - ca_config.section, ENV_DEFAULT_ENDDATE); - if (ca_config.enddate == NULL) + if (cfg.enddate == NULL) { + cfg.enddate = NCONF_get_string(conf, + cfg.section, ENV_DEFAULT_ENDDATE); + if (cfg.enddate == NULL) ERR_clear_error(); } - if (ca_config.days == 0 && ca_config.enddate == NULL) { - if (!NCONF_get_number(conf, ca_config.section, - ENV_DEFAULT_DAYS, &ca_config.days)) - ca_config.days = 0; + if (cfg.days == 0 && cfg.enddate == NULL) { + if (!NCONF_get_number(conf, cfg.section, + ENV_DEFAULT_DAYS, &cfg.days)) + cfg.days = 0; } - if (ca_config.enddate == NULL && ca_config.days == 0) { + if (cfg.enddate == NULL && cfg.days == 0) { BIO_printf(bio_err, "cannot lookup how many days to certify for\n"); goto err; } - if ((serial = load_serial(serialfile, ca_config.create_serial, + if ((serial = load_serial(serialfile, cfg.create_serial, NULL)) == NULL) { BIO_printf(bio_err, "error while loading serial number\n"); goto err; } - if (ca_config.verbose) { + if (cfg.verbose) { if (BN_is_zero(serial)) BIO_printf(bio_err, "next serial number is 00\n"); @@ -1166,25 +1164,25 @@ ca_main(int argc, char **argv) free(f); } } - if ((attribs = NCONF_get_section(conf, ca_config.policy)) == + if ((attribs = NCONF_get_section(conf, cfg.policy)) == NULL) { BIO_printf(bio_err, "unable to find 'section' for %s\n", - ca_config.policy); + cfg.policy); goto err; } if ((cert_sk = sk_X509_new_null()) == NULL) { BIO_printf(bio_err, "Memory allocation failure\n"); goto err; } - if (ca_config.spkac_file != NULL) { + if (cfg.spkac_file != NULL) { total++; - j = certify_spkac(&x, ca_config.spkac_file, pkey, x509, - dgst, ca_config.sigopts, attribs, db, serial, - ca_config.subj, ca_config.chtype, - ca_config.multirdn, ca_config.email_dn, - ca_config.startdate, ca_config.enddate, - ca_config.days, ca_config.extensions, conf, - ca_config.verbose, certopt, nameopt, default_op, + j = certify_spkac(&x, cfg.spkac_file, pkey, x509, + dgst, cfg.sigopts, attribs, db, serial, + cfg.subj, cfg.chtype, + cfg.multirdn, cfg.email_dn, + cfg.startdate, cfg.enddate, + cfg.days, cfg.extensions, conf, + cfg.verbose, certopt, nameopt, default_op, ext_copy); if (j < 0) goto err; @@ -1198,21 +1196,21 @@ ca_main(int argc, char **argv) "Memory allocation failure\n"); goto err; } - if (ca_config.outfile != NULL) { + if (cfg.outfile != NULL) { output_der = 1; - ca_config.batch = 1; + cfg.batch = 1; } } } - if (ca_config.ss_cert_file != NULL) { + if (cfg.ss_cert_file != NULL) { total++; - j = certify_cert(&x, ca_config.ss_cert_file, pkey, x509, - dgst, ca_config.sigopts, attribs, db, serial, - ca_config.subj, ca_config.chtype, - ca_config.multirdn, ca_config.email_dn, - ca_config.startdate, ca_config.enddate, - ca_config.days, ca_config.batch, - ca_config.extensions, conf, ca_config.verbose, + j = certify_cert(&x, cfg.ss_cert_file, pkey, x509, + dgst, cfg.sigopts, attribs, db, serial, + cfg.subj, cfg.chtype, + cfg.multirdn, cfg.email_dn, + cfg.startdate, cfg.enddate, + cfg.days, cfg.batch, + cfg.extensions, conf, cfg.verbose, certopt, nameopt, default_op, ext_copy); if (j < 0) goto err; @@ -1228,17 +1226,17 @@ ca_main(int argc, char **argv) } } } - if (ca_config.infile != NULL) { + if (cfg.infile != NULL) { total++; - j = certify(&x, ca_config.infile, pkey, x509p, dgst, - ca_config.sigopts, attribs, db, serial, - ca_config.subj, ca_config.chtype, - ca_config.multirdn, ca_config.email_dn, - ca_config.startdate, ca_config.enddate, - ca_config.days, ca_config.batch, - ca_config.extensions, conf, ca_config.verbose, + j = certify(&x, cfg.infile, pkey, x509p, dgst, + cfg.sigopts, attribs, db, serial, + cfg.subj, cfg.chtype, + cfg.multirdn, cfg.email_dn, + cfg.startdate, cfg.enddate, + cfg.days, cfg.batch, + cfg.extensions, conf, cfg.verbose, certopt, nameopt, default_op, ext_copy, - ca_config.selfsign); + cfg.selfsign); if (j < 0) goto err; if (j > 0) { @@ -1253,17 +1251,17 @@ ca_main(int argc, char **argv) } } } - for (i = 0; i < ca_config.infiles_num; i++) { + for (i = 0; i < cfg.infiles_num; i++) { total++; - j = certify(&x, ca_config.infiles[i], pkey, x509p, dgst, - ca_config.sigopts, attribs, db, serial, - ca_config.subj, ca_config.chtype, - ca_config.multirdn, ca_config.email_dn, - ca_config.startdate, ca_config.enddate, - ca_config.days, ca_config.batch, - ca_config.extensions, conf, ca_config.verbose, + j = certify(&x, cfg.infiles[i], pkey, x509p, dgst, + cfg.sigopts, attribs, db, serial, + cfg.subj, cfg.chtype, + cfg.multirdn, cfg.email_dn, + cfg.startdate, cfg.enddate, + cfg.days, cfg.batch, + cfg.extensions, conf, cfg.verbose, certopt, nameopt, default_op, ext_copy, - ca_config.selfsign); + cfg.selfsign); if (j < 0) goto err; if (j > 0) { @@ -1284,7 +1282,7 @@ ca_main(int argc, char **argv) */ if (sk_X509_num(cert_sk) > 0) { - if (!ca_config.batch) { + if (!cfg.batch) { char answer[10]; BIO_printf(bio_err, @@ -1315,7 +1313,7 @@ ca_main(int argc, char **argv) if (!save_index(dbfile, "new", db)) goto err; } - if (ca_config.verbose) + if (cfg.verbose) BIO_printf(bio_err, "writing new certificates\n"); for (i = 0; i < sk_X509_num(cert_sk); i++) { ASN1_INTEGER *serialNumber; @@ -1336,7 +1334,7 @@ ca_main(int argc, char **argv) serialstr = strdup("00"); if (serialstr != NULL) { k = snprintf(pempath, sizeof(pempath), - "%s/%s.pem", ca_config.outdir, serialstr); + "%s/%s.pem", cfg.outdir, serialstr); free(serialstr); if (k < 0 || k >= sizeof(pempath)) { BIO_printf(bio_err, @@ -1348,7 +1346,7 @@ ca_main(int argc, char **argv) "memory allocation failed\n"); goto err; } - if (ca_config.verbose) + if (cfg.verbose) BIO_printf(bio_err, "writing %s\n", pempath); if (BIO_write_filename(Cout, pempath) <= 0) { @@ -1356,10 +1354,10 @@ ca_main(int argc, char **argv) goto err; } if (!write_new_certificate(Cout, x, 0, - ca_config.notext)) + cfg.notext)) goto err; if (!write_new_certificate(Sout, x, output_der, - ca_config.notext)) + cfg.notext)) goto err; } @@ -1375,29 +1373,29 @@ ca_main(int argc, char **argv) } } /*****************************************************************/ - if (ca_config.gencrl) { + if (cfg.gencrl) { int crl_v2 = 0; - if (ca_config.crl_ext == NULL) { - ca_config.crl_ext = NCONF_get_string(conf, - ca_config.section, ENV_CRLEXT); - if (ca_config.crl_ext == NULL) + if (cfg.crl_ext == NULL) { + cfg.crl_ext = NCONF_get_string(conf, + cfg.section, ENV_CRLEXT); + if (cfg.crl_ext == NULL) ERR_clear_error(); } - if (ca_config.crl_ext != NULL) { + if (cfg.crl_ext != NULL) { /* Check syntax of file */ X509V3_CTX ctx; X509V3_set_ctx_test(&ctx); X509V3_set_nconf(&ctx, conf); - if (!X509V3_EXT_add_nconf(conf, &ctx, ca_config.crl_ext, + if (!X509V3_EXT_add_nconf(conf, &ctx, cfg.crl_ext, NULL)) { BIO_printf(bio_err, "Error Loading CRL extension section %s\n", - ca_config.crl_ext); + cfg.crl_ext); ret = 1; goto err; } } - if ((crlnumberfile = NCONF_get_string(conf, ca_config.section, + if ((crlnumberfile = NCONF_get_string(conf, cfg.section, ENV_CRLNUMBER)) != NULL) if ((crlnumber = load_serial(crlnumberfile, 0, NULL)) == NULL) { @@ -1405,23 +1403,23 @@ ca_main(int argc, char **argv) "error while loading CRL number\n"); goto err; } - if (!ca_config.crldays && !ca_config.crlhours && - !ca_config.crlsec) { - if (!NCONF_get_number(conf, ca_config.section, - ENV_DEFAULT_CRL_DAYS, &ca_config.crldays)) - ca_config.crldays = 0; - if (!NCONF_get_number(conf, ca_config.section, - ENV_DEFAULT_CRL_HOURS, &ca_config.crlhours)) - ca_config.crlhours = 0; + if (!cfg.crldays && !cfg.crlhours && + !cfg.crlsec) { + if (!NCONF_get_number(conf, cfg.section, + ENV_DEFAULT_CRL_DAYS, &cfg.crldays)) + cfg.crldays = 0; + if (!NCONF_get_number(conf, cfg.section, + ENV_DEFAULT_CRL_HOURS, &cfg.crlhours)) + cfg.crlhours = 0; ERR_clear_error(); } - if ((ca_config.crldays == 0) && (ca_config.crlhours == 0) && - (ca_config.crlsec == 0)) { + if ((cfg.crldays == 0) && (cfg.crlhours == 0) && + (cfg.crlsec == 0)) { BIO_printf(bio_err, "cannot lookup how long until the next CRL is issued\n"); goto err; } - if (ca_config.verbose) + if (cfg.verbose) BIO_printf(bio_err, "making CRL\n"); if ((crl = X509_CRL_new()) == NULL) goto err; @@ -1432,8 +1430,8 @@ ca_main(int argc, char **argv) goto err; if (!X509_CRL_set_lastUpdate(crl, tmptm)) goto err; - if (X509_time_adj_ex(tmptm, ca_config.crldays, - ca_config.crlhours * 60 * 60 + ca_config.crlsec, NULL) == + if (X509_time_adj_ex(tmptm, cfg.crldays, + cfg.crlhours * 60 * 60 + cfg.crlsec, NULL) == NULL) { BIO_puts(bio_err, "error setting CRL nextUpdate\n"); goto err; @@ -1477,19 +1475,19 @@ ca_main(int argc, char **argv) X509_CRL_sort(crl); /* we now have a CRL */ - if (ca_config.verbose) + if (cfg.verbose) BIO_printf(bio_err, "signing CRL\n"); /* Add any extensions asked for */ - if (ca_config.crl_ext != NULL || crlnumberfile != NULL) { + if (cfg.crl_ext != NULL || crlnumberfile != NULL) { X509V3_CTX crlctx; X509V3_set_ctx(&crlctx, x509, NULL, NULL, crl, 0); X509V3_set_nconf(&crlctx, conf); - if (ca_config.crl_ext != NULL) + if (cfg.crl_ext != NULL) if (!X509V3_EXT_CRL_add_nconf(conf, &crlctx, - ca_config.crl_ext, crl)) + cfg.crl_ext, crl)) goto err; if (crlnumberfile != NULL) { tmpserial = BN_to_ASN1_INTEGER(crlnumber, NULL); @@ -1506,7 +1504,7 @@ ca_main(int argc, char **argv) goto err; } } - if (ca_config.crl_ext != NULL || crl_v2) { + if (cfg.crl_ext != NULL || crl_v2) { if (!X509_CRL_set_version(crl, 1)) goto err; /* version 2 CRL */ } @@ -1519,7 +1517,7 @@ ca_main(int argc, char **argv) crlnumber = NULL; if (!do_X509_CRL_sign(bio_err, crl, pkey, dgst, - ca_config.sigopts)) + cfg.sigopts)) goto err; if (!PEM_write_bio_X509_CRL(Sout, crl)) @@ -1531,18 +1529,18 @@ ca_main(int argc, char **argv) } /*****************************************************************/ - if (ca_config.dorevoke) { - if (ca_config.infile == NULL) { + if (cfg.dorevoke) { + if (cfg.infile == NULL) { BIO_printf(bio_err, "no input files\n"); goto err; } else { X509 *revcert; - revcert = load_cert(bio_err, ca_config.infile, - FORMAT_PEM, NULL, ca_config.infile); + revcert = load_cert(bio_err, cfg.infile, + FORMAT_PEM, NULL, cfg.infile); if (revcert == NULL) goto err; - j = do_revoke(revcert, db, ca_config.rev_type, - ca_config.rev_arg); + j = do_revoke(revcert, db, cfg.rev_type, + cfg.rev_arg); if (j <= 0) goto err; X509_free(revcert); @@ -1572,11 +1570,11 @@ ca_main(int argc, char **argv) if (ret) ERR_print_errors(bio_err); if (free_key) - free(ca_config.key); + free(cfg.key); BN_free(serial); BN_free(crlnumber); free_index(db); - sk_OPENSSL_STRING_free(ca_config.sigopts); + sk_OPENSSL_STRING_free(cfg.sigopts); EVP_PKEY_free(pkey); X509_free(x509); X509_CRL_free(crl); @@ -1780,7 +1778,7 @@ do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst, if (obj == NULL) goto err; - if (ca_config.msie_hack) { + if (cfg.msie_hack) { /* assume all type should be strings */ nid = OBJ_obj2nid(X509_NAME_ENTRY_get_object(ne)); if (nid == NID_undef) @@ -1942,7 +1940,7 @@ do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst, } } - if (ca_config.preserve) { + if (cfg.preserve) { X509_NAME_free(subject); /* subject=X509_NAME_dup(X509_REQ_get_subject_name(req)); */ subject = X509_NAME_dup(name); diff --git a/apps/openssl/certhash.c b/apps/openssl/certhash.c index a4417a2b..5ee29b8d 100644 --- a/apps/openssl/certhash.c +++ b/apps/openssl/certhash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: certhash.c,v 1.19 2021/10/23 08:13:48 tb Exp $ */ +/* $OpenBSD: certhash.c,v 1.21 2023/03/06 14:32:05 tb Exp $ */ /* * Copyright (c) 2014, 2015 Joel Sing * @@ -36,20 +36,20 @@ static struct { int dryrun; int verbose; -} certhash_config; +} cfg; static const struct option certhash_options[] = { { .name = "n", .desc = "Perform a dry-run - do not make any changes", .type = OPTION_FLAG, - .opt.flag = &certhash_config.dryrun, + .opt.flag = &cfg.dryrun, }, { .name = "v", .desc = "Verbose", .type = OPTION_FLAG, - .opt.flag = &certhash_config.verbose, + .opt.flag = &cfg.verbose, }, { NULL }, }; @@ -569,7 +569,7 @@ certhash_directory(const char *path) goto err; } - if (certhash_config.verbose) + if (cfg.verbose) fprintf(stdout, "scanning directory %s\n", path); /* Create lists of existing hash links, certs and CRLs. */ @@ -594,11 +594,11 @@ certhash_directory(const char *path) if (link->exists == 0 || (link->reference != NULL && link->changed == 0)) continue; - if (certhash_config.verbose) + if (cfg.verbose) fprintf(stdout, "%s link %s -> %s\n", - (certhash_config.dryrun ? "would remove" : + (cfg.dryrun ? "would remove" : "removing"), link->filename, link->target); - if (certhash_config.dryrun) + if (cfg.dryrun) continue; if (unlink(link->filename) == -1) { fprintf(stderr, "failed to remove link %s\n", @@ -611,12 +611,12 @@ certhash_directory(const char *path) for (link = links; link != NULL; link = link->next) { if (link->exists == 1 && link->changed == 0) continue; - if (certhash_config.verbose) + if (cfg.verbose) fprintf(stdout, "%s link %s -> %s\n", - (certhash_config.dryrun ? "would create" : + (cfg.dryrun ? "would create" : "creating"), link->filename, link->reference->filename); - if (certhash_config.dryrun) + if (cfg.dryrun) continue; if (symlink(link->reference->filename, link->filename) == -1) { fprintf(stderr, "failed to create link %s -> %s\n", @@ -653,14 +653,12 @@ certhash_main(int argc, char **argv) int argsused; int i, cwdfd, ret = 0; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&certhash_config, 0, sizeof(certhash_config)); + memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, certhash_options, NULL, &argsused) != 0) { certhash_usage(); diff --git a/apps/openssl/ciphers.c b/apps/openssl/ciphers.c index 583db116..247929bb 100644 --- a/apps/openssl/ciphers.c +++ b/apps/openssl/ciphers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ciphers.c,v 1.15 2022/07/19 20:15:19 tb Exp $ */ +/* $OpenBSD: ciphers.c,v 1.18 2023/03/06 14:32:05 tb Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -24,70 +24,70 @@ #include "apps.h" #include "progs.h" -struct { +static struct { int usage; int use_supported; int verbose; int version; -} ciphers_config; +} cfg; static const struct option ciphers_options[] = { { .name = "h", .type = OPTION_FLAG, - .opt.flag = &ciphers_config.usage, + .opt.flag = &cfg.usage, }, { .name = "?", .type = OPTION_FLAG, - .opt.flag = &ciphers_config.usage, + .opt.flag = &cfg.usage, }, { .name = "s", .desc = "Only list ciphers that are supported by the TLS method", .type = OPTION_FLAG, - .opt.flag = &ciphers_config.use_supported, + .opt.flag = &cfg.use_supported, }, { .name = "tls1", .desc = "Use TLS protocol version 1", .type = OPTION_VALUE, - .opt.value = &ciphers_config.version, + .opt.value = &cfg.version, .value = TLS1_VERSION, }, { .name = "tls1_1", .desc = "Use TLS protocol version 1.1", .type = OPTION_VALUE, - .opt.value = &ciphers_config.version, + .opt.value = &cfg.version, .value = TLS1_1_VERSION, }, { .name = "tls1_2", .desc = "Use TLS protocol version 1.2", .type = OPTION_VALUE, - .opt.value = &ciphers_config.version, + .opt.value = &cfg.version, .value = TLS1_2_VERSION, }, { .name = "tls1_3", .desc = "Use TLS protocol version 1.3", .type = OPTION_VALUE, - .opt.value = &ciphers_config.version, + .opt.value = &cfg.version, .value = TLS1_3_VERSION, }, { .name = "v", .desc = "Provide cipher listing", .type = OPTION_VALUE, - .opt.value = &ciphers_config.verbose, + .opt.value = &cfg.verbose, .value = 1, }, { .name = "V", .desc = "Provide cipher listing with cipher suite values", .type = OPTION_VALUE, - .opt.value = &ciphers_config.verbose, + .opt.value = &cfg.verbose, .value = 2, }, { NULL }, @@ -114,14 +114,12 @@ ciphers_main(int argc, char **argv) int i, rv = 0; char *desc; - if (single_execution) { - if (pledge("stdio rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&ciphers_config, 0, sizeof(ciphers_config)); + memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, ciphers_options, &cipherlist, NULL) != 0) { @@ -129,7 +127,7 @@ ciphers_main(int argc, char **argv) return (1); } - if (ciphers_config.usage) { + if (cfg.usage) { ciphers_usage(); return (1); } @@ -137,12 +135,12 @@ ciphers_main(int argc, char **argv) if ((ssl_ctx = SSL_CTX_new(TLS_method())) == NULL) goto err; - if (ciphers_config.version != 0) { + if (cfg.version != 0) { if (!SSL_CTX_set_min_proto_version(ssl_ctx, - ciphers_config.version)) + cfg.version)) goto err; if (!SSL_CTX_set_max_proto_version(ssl_ctx, - ciphers_config.version)) + cfg.version)) goto err; } @@ -154,7 +152,7 @@ ciphers_main(int argc, char **argv) if ((ssl = SSL_new(ssl_ctx)) == NULL) goto err; - if (ciphers_config.use_supported) { + if (cfg.use_supported) { if ((supported_ciphers = SSL_get1_supported_ciphers(ssl)) == NULL) goto err; @@ -166,12 +164,12 @@ ciphers_main(int argc, char **argv) for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { cipher = sk_SSL_CIPHER_value(ciphers, i); - if (ciphers_config.verbose == 0) { + if (cfg.verbose == 0) { fprintf(stdout, "%s%s", (i ? ":" : ""), SSL_CIPHER_get_name(cipher)); continue; } - if (ciphers_config.verbose > 1) { + if (cfg.verbose > 1) { value = SSL_CIPHER_get_value(cipher); fprintf(stdout, "%-*s0x%02X,0x%02X - ", 10, "", ((value >> 8) & 0xff), (value & 0xff)); @@ -184,7 +182,7 @@ ciphers_main(int argc, char **argv) fprintf(stdout, "%s", desc); free(desc); } - if (ciphers_config.verbose == 0) + if (cfg.verbose == 0) fprintf(stdout, "\n"); goto done; diff --git a/apps/openssl/cms.c b/apps/openssl/cms.c index a3004e8a..0ddf26e5 100644 --- a/apps/openssl/cms.c +++ b/apps/openssl/cms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms.c,v 1.30 2022/03/23 15:16:59 tb Exp $ */ +/* $OpenBSD: cms.c,v 1.33 2023/03/06 14:32:05 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -149,7 +149,7 @@ static struct { char *to; int verify_retcode; X509_VERIFY_PARAM *vpm; -} cms_config; +} cfg; static const EVP_CIPHER * get_cipher_by_name(char *name) @@ -198,8 +198,8 @@ cms_opt_cipher(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((cms_config.cipher = get_cipher_by_name(name)) == NULL) - if ((cms_config.cipher = EVP_get_cipherbyname(name)) == NULL) + if ((cfg.cipher = get_cipher_by_name(name)) == NULL) + if ((cfg.cipher = EVP_get_cipherbyname(name)) == NULL) return (1); *argsused = 1; @@ -209,9 +209,9 @@ cms_opt_cipher(int argc, char **argv, int *argsused) static int cms_opt_econtent_type(char *arg) { - ASN1_OBJECT_free(cms_config.econtent_type); + ASN1_OBJECT_free(cfg.econtent_type); - if ((cms_config.econtent_type = OBJ_txt2obj(arg, 0)) == NULL) { + if ((cfg.econtent_type = OBJ_txt2obj(arg, 0)) == NULL) { BIO_printf(bio_err, "Invalid OID %s\n", arg); return (1); } @@ -221,33 +221,33 @@ cms_opt_econtent_type(char *arg) static int cms_opt_inkey(char *arg) { - if (cms_config.keyfile == NULL) { - cms_config.keyfile = arg; + if (cfg.keyfile == NULL) { + cfg.keyfile = arg; return (0); } - - if (cms_config.signerfile == NULL) { + + if (cfg.signerfile == NULL) { BIO_puts(bio_err, "Illegal -inkey without -signer\n"); return (1); } - if (cms_config.sksigners == NULL) - cms_config.sksigners = sk_OPENSSL_STRING_new_null(); - if (cms_config.sksigners == NULL) + if (cfg.sksigners == NULL) + cfg.sksigners = sk_OPENSSL_STRING_new_null(); + if (cfg.sksigners == NULL) return (1); - if (!sk_OPENSSL_STRING_push(cms_config.sksigners, cms_config.signerfile)) + if (!sk_OPENSSL_STRING_push(cfg.sksigners, cfg.signerfile)) return (1); - cms_config.signerfile = NULL; + cfg.signerfile = NULL; - if (cms_config.skkeys == NULL) - cms_config.skkeys = sk_OPENSSL_STRING_new_null(); - if (cms_config.skkeys == NULL) + if (cfg.skkeys == NULL) + cfg.skkeys = sk_OPENSSL_STRING_new_null(); + if (cfg.skkeys == NULL) return (1); - if (!sk_OPENSSL_STRING_push(cms_config.skkeys, cms_config.keyfile)) + if (!sk_OPENSSL_STRING_push(cfg.skkeys, cfg.keyfile)) return (1); - cms_config.keyfile = arg; + cfg.keyfile = arg; return (0); } @@ -256,14 +256,14 @@ cms_opt_keyopt(char *arg) { int keyidx = -1; - if (cms_config.operation == SMIME_ENCRYPT) { - if (cms_config.encerts != NULL) - keyidx += sk_X509_num(cms_config.encerts); + if (cfg.operation == SMIME_ENCRYPT) { + if (cfg.encerts != NULL) + keyidx += sk_X509_num(cfg.encerts); } else { - if (cms_config.keyfile != NULL || cms_config.signerfile != NULL) + if (cfg.keyfile != NULL || cfg.signerfile != NULL) keyidx++; - if (cms_config.skkeys != NULL) - keyidx += sk_OPENSSL_STRING_num(cms_config.skkeys); + if (cfg.skkeys != NULL) + keyidx += sk_OPENSSL_STRING_num(cfg.skkeys); } if (keyidx < 0) { @@ -271,8 +271,8 @@ cms_opt_keyopt(char *arg) return (1); } - if (cms_config.key_param == NULL || - cms_config.key_param->idx != keyidx) { + if (cfg.key_param == NULL || + cfg.key_param->idx != keyidx) { struct cms_key_param *nparam; if ((nparam = calloc(1, sizeof(struct cms_key_param))) == NULL) @@ -285,15 +285,15 @@ cms_opt_keyopt(char *arg) } nparam->next = NULL; - if (cms_config.key_first == NULL) - cms_config.key_first = nparam; + if (cfg.key_first == NULL) + cfg.key_first = nparam; else - cms_config.key_param->next = nparam; + cfg.key_param->next = nparam; - cms_config.key_param = nparam; + cfg.key_param = nparam; } - if (!sk_OPENSSL_STRING_push(cms_config.key_param->param, arg)) + if (!sk_OPENSSL_STRING_push(cfg.key_param->param, arg)) return (1); return (0); @@ -302,7 +302,7 @@ cms_opt_keyopt(char *arg) static int cms_opt_md(char *arg) { - if ((cms_config.sign_md = EVP_get_digestbyname(arg)) == NULL) { + if ((cfg.sign_md = EVP_get_digestbyname(arg)) == NULL) { BIO_printf(bio_err, "Unknown digest %s\n", arg); return (1); } @@ -312,38 +312,38 @@ cms_opt_md(char *arg) static int cms_opt_print(void) { - cms_config.noout = 1; - cms_config.print = 1; + cfg.noout = 1; + cfg.print = 1; return (0); } static int cms_opt_pwri_pass(char *arg) { - cms_config.pwri_pass = (unsigned char *)arg; + cfg.pwri_pass = (unsigned char *)arg; return (0); } static int cms_opt_recip(char *arg) { - if (cms_config.operation == SMIME_ENCRYPT) { - if (cms_config.encerts == NULL) { - if ((cms_config.encerts = sk_X509_new_null()) == NULL) + if (cfg.operation == SMIME_ENCRYPT) { + if (cfg.encerts == NULL) { + if ((cfg.encerts = sk_X509_new_null()) == NULL) return (1); } - cms_config.cert = load_cert(bio_err, arg, FORMAT_PEM, + cfg.cert = load_cert(bio_err, arg, FORMAT_PEM, NULL, "recipient certificate file"); - if (cms_config.cert == NULL) + if (cfg.cert == NULL) return (1); - if (!sk_X509_push(cms_config.encerts, cms_config.cert)) + if (!sk_X509_push(cfg.encerts, cfg.cert)) return (1); - cms_config.cert = NULL; + cfg.cert = NULL; } else { - cms_config.recipfile = arg; + cfg.recipfile = arg; } return (0); } @@ -351,11 +351,11 @@ cms_opt_recip(char *arg) static int cms_opt_receipt_request_from(char *arg) { - if (cms_config.rr_from == NULL) - cms_config.rr_from = sk_OPENSSL_STRING_new_null(); - if (cms_config.rr_from == NULL) + if (cfg.rr_from == NULL) + cfg.rr_from = sk_OPENSSL_STRING_new_null(); + if (cfg.rr_from == NULL) return (1); - if (!sk_OPENSSL_STRING_push(cms_config.rr_from, arg)) + if (!sk_OPENSSL_STRING_push(cfg.rr_from, arg)) return (1); return (0); @@ -364,11 +364,11 @@ cms_opt_receipt_request_from(char *arg) static int cms_opt_receipt_request_to(char *arg) { - if (cms_config.rr_to == NULL) - cms_config.rr_to = sk_OPENSSL_STRING_new_null(); - if (cms_config.rr_to == NULL) + if (cfg.rr_to == NULL) + cfg.rr_to = sk_OPENSSL_STRING_new_null(); + if (cfg.rr_to == NULL) return (1); - if (!sk_OPENSSL_STRING_push(cms_config.rr_to, arg)) + if (!sk_OPENSSL_STRING_push(cfg.rr_to, arg)) return (1); return (0); @@ -379,13 +379,13 @@ cms_opt_secretkey(char *arg) { long ltmp; - free(cms_config.secret_key); + free(cfg.secret_key); - if ((cms_config.secret_key = string_to_hex(arg, <mp)) == NULL) { + if ((cfg.secret_key = string_to_hex(arg, <mp)) == NULL) { BIO_printf(bio_err, "Invalid key %s\n", arg); return (1); } - cms_config.secret_keylen = (size_t)ltmp; + cfg.secret_keylen = (size_t)ltmp; return (0); } @@ -394,44 +394,44 @@ cms_opt_secretkeyid(char *arg) { long ltmp; - free(cms_config.secret_keyid); + free(cfg.secret_keyid); - if ((cms_config.secret_keyid = string_to_hex(arg, <mp)) == NULL) { + if ((cfg.secret_keyid = string_to_hex(arg, <mp)) == NULL) { BIO_printf(bio_err, "Invalid id %s\n", arg); return (1); } - cms_config.secret_keyidlen = (size_t)ltmp; + cfg.secret_keyidlen = (size_t)ltmp; return (0); } static int cms_opt_signer(char *arg) { - if (cms_config.signerfile == NULL) { - cms_config.signerfile = arg; + if (cfg.signerfile == NULL) { + cfg.signerfile = arg; return (0); } - if (cms_config.sksigners == NULL) - cms_config.sksigners = sk_OPENSSL_STRING_new_null(); - if (cms_config.sksigners == NULL) + if (cfg.sksigners == NULL) + cfg.sksigners = sk_OPENSSL_STRING_new_null(); + if (cfg.sksigners == NULL) return (1); - if (!sk_OPENSSL_STRING_push(cms_config.sksigners, cms_config.signerfile)) + if (!sk_OPENSSL_STRING_push(cfg.sksigners, cfg.signerfile)) return (1); - if (cms_config.keyfile == NULL) - cms_config.keyfile = cms_config.signerfile; + if (cfg.keyfile == NULL) + cfg.keyfile = cfg.signerfile; - if (cms_config.skkeys == NULL) - cms_config.skkeys = sk_OPENSSL_STRING_new_null(); - if (cms_config.skkeys == NULL) + if (cfg.skkeys == NULL) + cfg.skkeys = sk_OPENSSL_STRING_new_null(); + if (cfg.skkeys == NULL) return (1); - if (!sk_OPENSSL_STRING_push(cms_config.skkeys, cms_config.keyfile)) + if (!sk_OPENSSL_STRING_push(cfg.skkeys, cfg.keyfile)) return (1); - cms_config.keyfile = NULL; + cfg.keyfile = NULL; - cms_config.signerfile = arg; + cfg.signerfile = arg; return (0); } @@ -441,7 +441,7 @@ cms_opt_verify_param(int argc, char **argv, int *argsused) int oargc = argc; int badarg = 0; - if (!args_verify(&argv, &argc, &badarg, bio_err, &cms_config.vpm)) + if (!args_verify(&argv, &argc, &badarg, bio_err, &cfg.vpm)) return (1); if (badarg) return (1); @@ -454,8 +454,8 @@ cms_opt_verify_param(int argc, char **argv, int *argsused) static int cms_opt_verify_receipt(char *arg) { - cms_config.operation = SMIME_VERIFY_RECEIPT; - cms_config.rctfile = arg; + cfg.operation = SMIME_VERIFY_RECEIPT; + cfg.rctfile = arg; return (0); } @@ -539,20 +539,20 @@ static const struct option cms_options[] = { .argname = "file", .desc = "Certificate Authority file", .type = OPTION_ARG, - .opt.arg = &cms_config.CAfile, + .opt.arg = &cfg.CAfile, }, { .name = "CApath", .argname = "path", .desc = "Certificate Authority path", .type = OPTION_ARG, - .opt.arg = &cms_config.CApath, + .opt.arg = &cfg.CApath, }, { .name = "binary", .desc = "Do not translate message to text", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_BINARY, }, { @@ -560,27 +560,27 @@ static const struct option cms_options[] = { .argname = "file", .desc = "Other certificates file", .type = OPTION_ARG, - .opt.arg = &cms_config.certfile, + .opt.arg = &cfg.certfile, }, { .name = "certsout", .argname = "file", .desc = "Certificate output file", .type = OPTION_ARG, - .opt.arg = &cms_config.certsoutfile, + .opt.arg = &cfg.certsoutfile, }, { .name = "cmsout", .desc = "Output CMS structure", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_CMSOUT, }, { .name = "compress", .desc = "Create CMS CompressedData type", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_COMPRESS, }, { @@ -588,55 +588,55 @@ static const struct option cms_options[] = { .argname = "file", .desc = "Supply or override content for detached signature", .type = OPTION_ARG, - .opt.arg = &cms_config.contfile, + .opt.arg = &cfg.contfile, }, { .name = "crlfeol", .desc = "Use CRLF as EOL termination instead of CR only", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_CRLFEOL, }, { .name = "data_create", .desc = "Create CMS Data type", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_DATA_CREATE, }, { .name = "data_out", .desc = "Output content from the input CMS Data type", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_DATAOUT, }, { .name = "debug_decrypt", .desc = "Set the CMS_DEBUG_DECRYPT flag when decrypting", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_DEBUG_DECRYPT, }, { .name = "decrypt", .desc = "Decrypt encrypted message", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_DECRYPT, }, { .name = "digest_create", .desc = "Create CMS DigestedData type", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_DIGEST_CREATE, }, { .name = "digest_verify", .desc = "Verify CMS DigestedData type and output the content", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_DIGEST_VERIFY, }, { @@ -650,21 +650,21 @@ static const struct option cms_options[] = { .name = "encrypt", .desc = "Encrypt message", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_ENCRYPT, }, { .name = "EncryptedData_decrypt", .desc = "Decrypt CMS EncryptedData", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_ENCRYPTED_DECRYPT, }, { .name = "EncryptedData_encrypt", .desc = "Encrypt content using supplied symmetric key and algorithm", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_ENCRYPTED_ENCRYPT, }, { @@ -672,20 +672,20 @@ static const struct option cms_options[] = { .argname = "addr", .desc = "From address", .type = OPTION_ARG, - .opt.arg = &cms_config.from, + .opt.arg = &cfg.from, }, { .name = "in", .argname = "file", .desc = "Input file", .type = OPTION_ARG, - .opt.arg = &cms_config.infile, + .opt.arg = &cfg.infile, }, { .name = "indef", .desc = "Same as -stream", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_STREAM, }, { @@ -693,7 +693,7 @@ static const struct option cms_options[] = { .argname = "fmt", .desc = "Input format (DER, PEM or SMIME (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &cms_config.informat, + .opt.value = &cfg.informat, }, { .name = "inkey", @@ -707,13 +707,13 @@ static const struct option cms_options[] = { .argname = "fmt", .desc = "Input key format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &cms_config.keyform, + .opt.value = &cfg.keyform, }, { .name = "keyid", .desc = "Use subject key identifier", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_USE_KEYID, }, { @@ -734,90 +734,90 @@ static const struct option cms_options[] = { .name = "no_attr_verify", .desc = "Do not verify the signer's attribute of a signature", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_NO_ATTR_VERIFY, }, { .name = "no_content_verify", .desc = "Do not verify the content of a signed message", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_NO_CONTENT_VERIFY, }, { .name = "no_signer_cert_verify", .desc = "Do not verify the signer's certificate", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_NO_SIGNER_CERT_VERIFY, }, { .name = "noattr", .desc = "Do not include any signed attributes", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_NOATTR, }, { .name = "nocerts", .desc = "Do not include signer's certificate when signing", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_NOCERTS, }, { .name = "nodetach", .desc = "Use opaque signing", .type = OPTION_VALUE_AND, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = ~CMS_DETACHED, }, { .name = "noindef", .desc = "Disable CMS streaming", .type = OPTION_VALUE_AND, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = ~CMS_STREAM, }, { .name = "nointern", .desc = "Do not search certificates in message for signer", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_NOINTERN, }, { .name = "nooldmime", .desc = "Output old S/MIME content type", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_NOOLDMIMETYPE, }, { .name = "noout", .desc = "Do not output the parsed CMS structure", .type = OPTION_FLAG, - .opt.flag = &cms_config.noout, + .opt.flag = &cfg.noout, }, { .name = "nosigs", .desc = "Do not verify message signature", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_NOSIGS, }, { .name = "nosmimecap", .desc = "Omit the SMIMECapabilities attribute", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_NOSMIMECAP, }, { .name = "noverify", .desc = "Do not verify signer's certificate", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_NO_SIGNER_CERT_VERIFY, }, { @@ -825,21 +825,21 @@ static const struct option cms_options[] = { .argname = "file", .desc = "Output file", .type = OPTION_ARG, - .opt.arg = &cms_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "fmt", .desc = "Output format (DER, PEM or SMIME (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &cms_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "passin", .argname = "src", .desc = "Private key password source", .type = OPTION_ARG, - .opt.arg = &cms_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "print", @@ -859,20 +859,20 @@ static const struct option cms_options[] = { .argname = "fmt", .desc = "Receipt file format (DER, PEM or SMIME (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &cms_config.rctformat, + .opt.value = &cfg.rctformat, }, { .name = "receipt_request_all", .desc = "Indicate requests should be provided by all recipients", .type = OPTION_VALUE, - .opt.value = &cms_config.rr_allorfirst, + .opt.value = &cfg.rr_allorfirst, .value = 0, }, { .name = "receipt_request_first", .desc = "Indicate requests should be provided by first tier recipient", .type = OPTION_VALUE, - .opt.value = &cms_config.rr_allorfirst, + .opt.value = &cfg.rr_allorfirst, .value = 1, }, { @@ -886,7 +886,7 @@ static const struct option cms_options[] = { .name = "receipt_request_print", .desc = "Print out the contents of any signed receipt requests", .type = OPTION_FLAG, - .opt.flag = &cms_config.rr_print, + .opt.flag = &cfg.rr_print, }, { .name = "receipt_request_to", @@ -906,7 +906,7 @@ static const struct option cms_options[] = { .name = "resign", .desc = "Resign a signed message", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_RESIGN, }, { @@ -927,14 +927,14 @@ static const struct option cms_options[] = { .name = "sign", .desc = "Sign message", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_SIGN, }, { .name = "sign_receipt", .desc = "Generate a signed receipt for the message", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_SIGN_RECEIPT, }, { @@ -948,7 +948,7 @@ static const struct option cms_options[] = { .name = "stream", .desc = "Enable CMS streaming", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_STREAM, }, { @@ -956,13 +956,13 @@ static const struct option cms_options[] = { .argname = "s", .desc = "Subject", .type = OPTION_ARG, - .opt.arg = &cms_config.subject, + .opt.arg = &cfg.subject, }, { .name = "text", .desc = "Include or delete text MIME headers", .type = OPTION_VALUE_OR, - .opt.value = &cms_config.flags, + .opt.value = &cfg.flags, .value = CMS_TEXT, }, { @@ -970,20 +970,20 @@ static const struct option cms_options[] = { .argname = "addr", .desc = "To address", .type = OPTION_ARG, - .opt.arg = &cms_config.to, + .opt.arg = &cfg.to, }, { .name = "uncompress", .desc = "Uncompress CMS CompressedData type", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_UNCOMPRESS, }, { .name = "verify", .desc = "Verify signed message", .type = OPTION_VALUE, - .opt.value = &cms_config.operation, + .opt.value = &cfg.operation, .value = SMIME_VERIFY, }, { @@ -997,7 +997,7 @@ static const struct option cms_options[] = { .name = "verify_retcode", .desc = "Set verification error code to exit code", .type = OPTION_FLAG, - .opt.flag = &cms_config.verify_retcode, + .opt.flag = &cfg.verify_retcode, }, { .name = "check_ss_sig", @@ -1165,91 +1165,89 @@ cms_main(int argc, char **argv) char *passin = NULL; unsigned char *pwri_tmp = NULL; - if (single_execution) { - if (pledge("stdio rpath wpath cpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio rpath wpath cpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&cms_config, 0, sizeof(cms_config)); - cms_config.flags = CMS_DETACHED; - cms_config.rr_allorfirst = -1; - cms_config.informat = FORMAT_SMIME; - cms_config.outformat = FORMAT_SMIME; - cms_config.rctformat = FORMAT_SMIME; - cms_config.keyform = FORMAT_PEM; + memset(&cfg, 0, sizeof(cfg)); + cfg.flags = CMS_DETACHED; + cfg.rr_allorfirst = -1; + cfg.informat = FORMAT_SMIME; + cfg.outformat = FORMAT_SMIME; + cfg.rctformat = FORMAT_SMIME; + cfg.keyform = FORMAT_PEM; if (options_parse(argc, argv, cms_options, NULL, &argsused) != 0) { goto argerr; } args = argv + argsused; ret = 1; - if (((cms_config.rr_allorfirst != -1) || cms_config.rr_from != NULL) && - cms_config.rr_to == NULL) { + if (((cfg.rr_allorfirst != -1) || cfg.rr_from != NULL) && + cfg.rr_to == NULL) { BIO_puts(bio_err, "No Signed Receipts Recipients\n"); goto argerr; } - if (!(cms_config.operation & SMIME_SIGNERS) && - (cms_config.rr_to != NULL || cms_config.rr_from != NULL)) { + if (!(cfg.operation & SMIME_SIGNERS) && + (cfg.rr_to != NULL || cfg.rr_from != NULL)) { BIO_puts(bio_err, "Signed receipts only allowed with -sign\n"); goto argerr; } - if (!(cms_config.operation & SMIME_SIGNERS) && - (cms_config.skkeys != NULL || cms_config.sksigners != NULL)) { + if (!(cfg.operation & SMIME_SIGNERS) && + (cfg.skkeys != NULL || cfg.sksigners != NULL)) { BIO_puts(bio_err, "Multiple signers or keys not allowed\n"); goto argerr; } - if (cms_config.operation & SMIME_SIGNERS) { - if (cms_config.keyfile != NULL && - cms_config.signerfile == NULL) { + if (cfg.operation & SMIME_SIGNERS) { + if (cfg.keyfile != NULL && + cfg.signerfile == NULL) { BIO_puts(bio_err, "Illegal -inkey without -signer\n"); goto argerr; } /* Check to see if any final signer needs to be appended */ - if (cms_config.signerfile != NULL) { - if (cms_config.sksigners == NULL && - (cms_config.sksigners = + if (cfg.signerfile != NULL) { + if (cfg.sksigners == NULL && + (cfg.sksigners = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - if (!sk_OPENSSL_STRING_push(cms_config.sksigners, - cms_config.signerfile)) + if (!sk_OPENSSL_STRING_push(cfg.sksigners, + cfg.signerfile)) goto end; - if (cms_config.skkeys == NULL && - (cms_config.skkeys = + if (cfg.skkeys == NULL && + (cfg.skkeys = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - if (cms_config.keyfile == NULL) - cms_config.keyfile = cms_config.signerfile; - if (!sk_OPENSSL_STRING_push(cms_config.skkeys, - cms_config.keyfile)) + if (cfg.keyfile == NULL) + cfg.keyfile = cfg.signerfile; + if (!sk_OPENSSL_STRING_push(cfg.skkeys, + cfg.keyfile)) goto end; } - if (cms_config.sksigners == NULL) { + if (cfg.sksigners == NULL) { BIO_printf(bio_err, "No signer certificate specified\n"); badarg = 1; } - cms_config.signerfile = NULL; - cms_config.keyfile = NULL; - } else if (cms_config.operation == SMIME_DECRYPT) { - if (cms_config.recipfile == NULL && - cms_config.keyfile == NULL && - cms_config.secret_key == NULL && - cms_config.pwri_pass == NULL) { + cfg.signerfile = NULL; + cfg.keyfile = NULL; + } else if (cfg.operation == SMIME_DECRYPT) { + if (cfg.recipfile == NULL && + cfg.keyfile == NULL && + cfg.secret_key == NULL && + cfg.pwri_pass == NULL) { BIO_printf(bio_err, "No recipient certificate or key specified\n"); badarg = 1; } - } else if (cms_config.operation == SMIME_ENCRYPT) { - if (*args == NULL && cms_config.secret_key == NULL && - cms_config.pwri_pass == NULL && - cms_config.encerts == NULL) { + } else if (cfg.operation == SMIME_ENCRYPT) { + if (*args == NULL && cfg.secret_key == NULL && + cfg.pwri_pass == NULL && + cfg.encerts == NULL) { BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n"); badarg = 1; } - } else if (!cms_config.operation) { + } else if (!cfg.operation) { badarg = 1; } @@ -1259,103 +1257,103 @@ cms_main(int argc, char **argv) goto end; } - if (!app_passwd(bio_err, cms_config.passargin, NULL, &passin, NULL)) { + if (!app_passwd(bio_err, cfg.passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } ret = 2; - if (!(cms_config.operation & SMIME_SIGNERS)) - cms_config.flags &= ~CMS_DETACHED; + if (!(cfg.operation & SMIME_SIGNERS)) + cfg.flags &= ~CMS_DETACHED; - if (cms_config.operation & SMIME_OP) { - if (cms_config.outformat == FORMAT_ASN1) + if (cfg.operation & SMIME_OP) { + if (cfg.outformat == FORMAT_ASN1) outmode = "wb"; } else { - if (cms_config.flags & CMS_BINARY) + if (cfg.flags & CMS_BINARY) outmode = "wb"; } - if (cms_config.operation & SMIME_IP) { - if (cms_config.informat == FORMAT_ASN1) + if (cfg.operation & SMIME_IP) { + if (cfg.informat == FORMAT_ASN1) inmode = "rb"; } else { - if (cms_config.flags & CMS_BINARY) + if (cfg.flags & CMS_BINARY) inmode = "rb"; } - if (cms_config.operation == SMIME_ENCRYPT) { - if (cms_config.cipher == NULL) { + if (cfg.operation == SMIME_ENCRYPT) { + if (cfg.cipher == NULL) { #ifndef OPENSSL_NO_DES - cms_config.cipher = EVP_des_ede3_cbc(); + cfg.cipher = EVP_des_ede3_cbc(); #else BIO_printf(bio_err, "No cipher selected\n"); goto end; #endif } - if (cms_config.secret_key != NULL && - cms_config.secret_keyid == NULL) { + if (cfg.secret_key != NULL && + cfg.secret_keyid == NULL) { BIO_printf(bio_err, "No secret key id\n"); goto end; } - if (*args != NULL && cms_config.encerts == NULL) - if ((cms_config.encerts = sk_X509_new_null()) == NULL) + if (*args != NULL && cfg.encerts == NULL) + if ((cfg.encerts = sk_X509_new_null()) == NULL) goto end; while (*args) { - if ((cms_config.cert = load_cert(bio_err, *args, + if ((cfg.cert = load_cert(bio_err, *args, FORMAT_PEM, NULL, "recipient certificate file")) == NULL) goto end; - if (!sk_X509_push(cms_config.encerts, cms_config.cert)) + if (!sk_X509_push(cfg.encerts, cfg.cert)) goto end; - cms_config.cert = NULL; + cfg.cert = NULL; args++; } } - if (cms_config.certfile != NULL) { - if ((other = load_certs(bio_err, cms_config.certfile, + if (cfg.certfile != NULL) { + if ((other = load_certs(bio_err, cfg.certfile, FORMAT_PEM, NULL, "certificate file")) == NULL) { ERR_print_errors(bio_err); goto end; } } - if (cms_config.recipfile != NULL && - (cms_config.operation == SMIME_DECRYPT)) { - if ((recip = load_cert(bio_err, cms_config.recipfile, + if (cfg.recipfile != NULL && + (cfg.operation == SMIME_DECRYPT)) { + if ((recip = load_cert(bio_err, cfg.recipfile, FORMAT_PEM, NULL, "recipient certificate file")) == NULL) { ERR_print_errors(bio_err); goto end; } } - if (cms_config.operation == SMIME_SIGN_RECEIPT) { - if ((signer = load_cert(bio_err, cms_config.signerfile, + if (cfg.operation == SMIME_SIGN_RECEIPT) { + if ((signer = load_cert(bio_err, cfg.signerfile, FORMAT_PEM, NULL, "receipt signer certificate file")) == NULL) { ERR_print_errors(bio_err); goto end; } } - if (cms_config.operation == SMIME_DECRYPT) { - if (cms_config.keyfile == NULL) - cms_config.keyfile = cms_config.recipfile; - } else if ((cms_config.operation == SMIME_SIGN) || - (cms_config.operation == SMIME_SIGN_RECEIPT)) { - if (cms_config.keyfile == NULL) - cms_config.keyfile = cms_config.signerfile; + if (cfg.operation == SMIME_DECRYPT) { + if (cfg.keyfile == NULL) + cfg.keyfile = cfg.recipfile; + } else if ((cfg.operation == SMIME_SIGN) || + (cfg.operation == SMIME_SIGN_RECEIPT)) { + if (cfg.keyfile == NULL) + cfg.keyfile = cfg.signerfile; } else { - cms_config.keyfile = NULL; + cfg.keyfile = NULL; } - if (cms_config.keyfile != NULL) { - key = load_key(bio_err, cms_config.keyfile, cms_config.keyform, + if (cfg.keyfile != NULL) { + key = load_key(bio_err, cfg.keyfile, cfg.keyform, 0, passin, "signing key file"); if (key == NULL) goto end; } - if (cms_config.infile != NULL) { - if ((in = BIO_new_file(cms_config.infile, inmode)) == NULL) { + if (cfg.infile != NULL) { + if ((in = BIO_new_file(cfg.infile, inmode)) == NULL) { BIO_printf(bio_err, - "Can't open input file %s\n", cms_config.infile); + "Can't open input file %s\n", cfg.infile); goto end; } } else { @@ -1363,12 +1361,12 @@ cms_main(int argc, char **argv) goto end; } - if (cms_config.operation & SMIME_IP) { - if (cms_config.informat == FORMAT_SMIME) + if (cfg.operation & SMIME_IP) { + if (cfg.informat == FORMAT_SMIME) cms = SMIME_read_CMS(in, &indata); - else if (cms_config.informat == FORMAT_PEM) + else if (cfg.informat == FORMAT_PEM) cms = PEM_read_bio_CMS(in, NULL, NULL, NULL); - else if (cms_config.informat == FORMAT_ASN1) + else if (cfg.informat == FORMAT_ASN1) cms = d2i_CMS_bio(in, NULL); else { BIO_printf(bio_err, "Bad input format for CMS file\n"); @@ -1379,24 +1377,24 @@ cms_main(int argc, char **argv) BIO_printf(bio_err, "Error reading S/MIME message\n"); goto end; } - if (cms_config.contfile != NULL) { + if (cfg.contfile != NULL) { BIO_free(indata); - if ((indata = BIO_new_file(cms_config.contfile, + if ((indata = BIO_new_file(cfg.contfile, "rb")) == NULL) { BIO_printf(bio_err, "Can't read content file %s\n", - cms_config.contfile); + cfg.contfile); goto end; } } - if (cms_config.certsoutfile != NULL) { + if (cfg.certsoutfile != NULL) { STACK_OF(X509) *allcerts; if ((allcerts = CMS_get1_certs(cms)) == NULL) goto end; - if (!save_certs(cms_config.certsoutfile, allcerts)) { + if (!save_certs(cfg.certsoutfile, allcerts)) { BIO_printf(bio_err, "Error writing certs to %s\n", - cms_config.certsoutfile); + cfg.certsoutfile); sk_X509_pop_free(allcerts, X509_free); ret = 5; goto end; @@ -1404,19 +1402,19 @@ cms_main(int argc, char **argv) sk_X509_pop_free(allcerts, X509_free); } } - if (cms_config.rctfile != NULL) { - char *rctmode = (cms_config.rctformat == FORMAT_ASN1) ? + if (cfg.rctfile != NULL) { + char *rctmode = (cfg.rctformat == FORMAT_ASN1) ? "rb" : "r"; - if ((rctin = BIO_new_file(cms_config.rctfile, rctmode)) == NULL) { + if ((rctin = BIO_new_file(cfg.rctfile, rctmode)) == NULL) { BIO_printf(bio_err, - "Can't open receipt file %s\n", cms_config.rctfile); + "Can't open receipt file %s\n", cfg.rctfile); goto end; } - if (cms_config.rctformat == FORMAT_SMIME) + if (cfg.rctformat == FORMAT_SMIME) rcms = SMIME_read_CMS(rctin, NULL); - else if (cms_config.rctformat == FORMAT_PEM) + else if (cfg.rctformat == FORMAT_PEM) rcms = PEM_read_bio_CMS(rctin, NULL, NULL, NULL); - else if (cms_config.rctformat == FORMAT_ASN1) + else if (cfg.rctformat == FORMAT_ASN1) rcms = d2i_CMS_bio(rctin, NULL); else { BIO_printf(bio_err, "Bad input format for receipt\n"); @@ -1428,10 +1426,10 @@ cms_main(int argc, char **argv) goto end; } } - if (cms_config.outfile != NULL) { - if ((out = BIO_new_file(cms_config.outfile, outmode)) == NULL) { + if (cfg.outfile != NULL) { + if ((out = BIO_new_file(cfg.outfile, outmode)) == NULL) { BIO_printf(bio_err, - "Can't open output file %s\n", cms_config.outfile); + "Can't open output file %s\n", cfg.outfile); goto end; } } else { @@ -1439,42 +1437,42 @@ cms_main(int argc, char **argv) goto end; } - if ((cms_config.operation == SMIME_VERIFY) || - (cms_config.operation == SMIME_VERIFY_RECEIPT)) { - if ((store = setup_verify(bio_err, cms_config.CAfile, - cms_config.CApath)) == NULL) + if ((cfg.operation == SMIME_VERIFY) || + (cfg.operation == SMIME_VERIFY_RECEIPT)) { + if ((store = setup_verify(bio_err, cfg.CAfile, + cfg.CApath)) == NULL) goto end; X509_STORE_set_verify_cb(store, cms_cb); - if (cms_config.vpm != NULL) { - if (!X509_STORE_set1_param(store, cms_config.vpm)) + if (cfg.vpm != NULL) { + if (!X509_STORE_set1_param(store, cfg.vpm)) goto end; } } ret = 3; - if (cms_config.operation == SMIME_DATA_CREATE) { - cms = CMS_data_create(in, cms_config.flags); - } else if (cms_config.operation == SMIME_DIGEST_CREATE) { - cms = CMS_digest_create(in, cms_config.sign_md, - cms_config.flags); - } else if (cms_config.operation == SMIME_COMPRESS) { - cms = CMS_compress(in, -1, cms_config.flags); - } else if (cms_config.operation == SMIME_ENCRYPT) { + if (cfg.operation == SMIME_DATA_CREATE) { + cms = CMS_data_create(in, cfg.flags); + } else if (cfg.operation == SMIME_DIGEST_CREATE) { + cms = CMS_digest_create(in, cfg.sign_md, + cfg.flags); + } else if (cfg.operation == SMIME_COMPRESS) { + cms = CMS_compress(in, -1, cfg.flags); + } else if (cfg.operation == SMIME_ENCRYPT) { int i; - cms_config.flags |= CMS_PARTIAL; - cms = CMS_encrypt(NULL, in, cms_config.cipher, - cms_config.flags); + cfg.flags |= CMS_PARTIAL; + cms = CMS_encrypt(NULL, in, cfg.cipher, + cfg.flags); if (cms == NULL) goto end; - for (i = 0; i < sk_X509_num(cms_config.encerts); i++) { + for (i = 0; i < sk_X509_num(cfg.encerts); i++) { CMS_RecipientInfo *ri; struct cms_key_param *kparam; - int tflags = cms_config.flags; + int tflags = cfg.flags; X509 *x; - - if ((x = sk_X509_value(cms_config.encerts, i)) == NULL) + + if ((x = sk_X509_value(cfg.encerts, i)) == NULL) goto end; - for (kparam = cms_config.key_first; kparam != NULL; + for (kparam = cfg.key_first; kparam != NULL; kparam = kparam->next) { if (kparam->idx == i) { tflags |= CMS_KEY_PARAM; @@ -1494,18 +1492,18 @@ cms_main(int argc, char **argv) } } - if (cms_config.secret_key != NULL) { + if (cfg.secret_key != NULL) { if (CMS_add0_recipient_key(cms, NID_undef, - cms_config.secret_key, cms_config.secret_keylen, - cms_config.secret_keyid, cms_config.secret_keyidlen, + cfg.secret_key, cfg.secret_keylen, + cfg.secret_keyid, cfg.secret_keyidlen, NULL, NULL, NULL) == NULL) goto end; /* NULL these because call absorbs them */ - cms_config.secret_key = NULL; - cms_config.secret_keyid = NULL; + cfg.secret_key = NULL; + cfg.secret_keyid = NULL; } - if (cms_config.pwri_pass != NULL) { - pwri_tmp = strdup(cms_config.pwri_pass); + if (cfg.pwri_pass != NULL) { + pwri_tmp = strdup(cfg.pwri_pass); if (pwri_tmp == NULL) goto end; if (CMS_add0_recipient_password(cms, -1, NID_undef, @@ -1513,16 +1511,16 @@ cms_main(int argc, char **argv) goto end; pwri_tmp = NULL; } - if (!(cms_config.flags & CMS_STREAM)) { - if (!CMS_final(cms, in, NULL, cms_config.flags)) + if (!(cfg.flags & CMS_STREAM)) { + if (!CMS_final(cms, in, NULL, cfg.flags)) goto end; } - } else if (cms_config.operation == SMIME_ENCRYPTED_ENCRYPT) { - cms = CMS_EncryptedData_encrypt(in, cms_config.cipher, - cms_config.secret_key, cms_config.secret_keylen, - cms_config.flags); + } else if (cfg.operation == SMIME_ENCRYPTED_ENCRYPT) { + cms = CMS_EncryptedData_encrypt(in, cfg.cipher, + cfg.secret_key, cfg.secret_keylen, + cfg.flags); - } else if (cms_config.operation == SMIME_SIGN_RECEIPT) { + } else if (cfg.operation == SMIME_SIGN_RECEIPT) { CMS_ContentInfo *srcms = NULL; STACK_OF(CMS_SignerInfo) *sis; CMS_SignerInfo *si; @@ -1533,36 +1531,36 @@ cms_main(int argc, char **argv) if (si == NULL) goto end; srcms = CMS_sign_receipt(si, signer, key, other, - cms_config.flags); + cfg.flags); if (srcms == NULL) goto end; CMS_ContentInfo_free(cms); cms = srcms; - } else if (cms_config.operation & SMIME_SIGNERS) { + } else if (cfg.operation & SMIME_SIGNERS) { int i; /* * If detached data content we enable streaming if S/MIME * output format. */ - if (cms_config.operation == SMIME_SIGN) { + if (cfg.operation == SMIME_SIGN) { - if (cms_config.flags & CMS_DETACHED) { - if (cms_config.outformat == FORMAT_SMIME) - cms_config.flags |= CMS_STREAM; + if (cfg.flags & CMS_DETACHED) { + if (cfg.outformat == FORMAT_SMIME) + cfg.flags |= CMS_STREAM; } - cms_config.flags |= CMS_PARTIAL; - cms = CMS_sign(NULL, NULL, other, in, cms_config.flags); + cfg.flags |= CMS_PARTIAL; + cms = CMS_sign(NULL, NULL, other, in, cfg.flags); if (cms == NULL) goto end; - if (cms_config.econtent_type != NULL) + if (cfg.econtent_type != NULL) if (!CMS_set1_eContentType(cms, - cms_config.econtent_type)) + cfg.econtent_type)) goto end; - if (cms_config.rr_to != NULL) { - rr = make_receipt_request(cms_config.rr_to, - cms_config.rr_allorfirst, - cms_config.rr_from); + if (cfg.rr_to != NULL) { + rr = make_receipt_request(cfg.rr_to, + cfg.rr_allorfirst, + cfg.rr_from); if (rr == NULL) { BIO_puts(bio_err, "Signed Receipt Request Creation Error\n"); @@ -1570,28 +1568,28 @@ cms_main(int argc, char **argv) } } } else { - cms_config.flags |= CMS_REUSE_DIGEST; + cfg.flags |= CMS_REUSE_DIGEST; } - for (i = 0; i < sk_OPENSSL_STRING_num(cms_config.sksigners); i++) { + for (i = 0; i < sk_OPENSSL_STRING_num(cfg.sksigners); i++) { CMS_SignerInfo *si; struct cms_key_param *kparam; - int tflags = cms_config.flags; + int tflags = cfg.flags; - cms_config.signerfile = sk_OPENSSL_STRING_value( - cms_config.sksigners, i); - cms_config.keyfile = sk_OPENSSL_STRING_value( - cms_config.skkeys, i); + cfg.signerfile = sk_OPENSSL_STRING_value( + cfg.sksigners, i); + cfg.keyfile = sk_OPENSSL_STRING_value( + cfg.skkeys, i); - signer = load_cert(bio_err, cms_config.signerfile, + signer = load_cert(bio_err, cfg.signerfile, FORMAT_PEM, NULL, "signer certificate"); if (signer == NULL) goto end; - key = load_key(bio_err, cms_config.keyfile, - cms_config.keyform, 0, passin, "signing key file"); + key = load_key(bio_err, cfg.keyfile, + cfg.keyform, 0, passin, "signing key file"); if (key == NULL) goto end; - for (kparam = cms_config.key_first; kparam != NULL; + for (kparam = cfg.key_first; kparam != NULL; kparam = kparam->next) { if (kparam->idx == i) { tflags |= CMS_KEY_PARAM; @@ -1599,7 +1597,7 @@ cms_main(int argc, char **argv) } } si = CMS_add1_signer(cms, signer, key, - cms_config.sign_md, tflags); + cfg.sign_md, tflags); if (si == NULL) goto end; if (kparam != NULL) { @@ -1618,9 +1616,9 @@ cms_main(int argc, char **argv) key = NULL; } /* If not streaming or resigning finalize structure */ - if ((cms_config.operation == SMIME_SIGN) && - !(cms_config.flags & CMS_STREAM)) { - if (!CMS_final(cms, in, NULL, cms_config.flags)) + if ((cfg.operation == SMIME_SIGN) && + !(cfg.flags & CMS_STREAM)) { + if (!CMS_final(cms, in, NULL, cfg.flags)) goto end; } } @@ -1629,15 +1627,15 @@ cms_main(int argc, char **argv) goto end; } ret = 4; - if (cms_config.operation == SMIME_DECRYPT) { - if (cms_config.flags & CMS_DEBUG_DECRYPT) + if (cfg.operation == SMIME_DECRYPT) { + if (cfg.flags & CMS_DEBUG_DECRYPT) CMS_decrypt(cms, NULL, NULL, NULL, NULL, - cms_config.flags); + cfg.flags); - if (cms_config.secret_key != NULL) { - if (!CMS_decrypt_set1_key(cms, cms_config.secret_key, - cms_config.secret_keylen, cms_config.secret_keyid, - cms_config.secret_keyidlen)) { + if (cfg.secret_key != NULL) { + if (!CMS_decrypt_set1_key(cms, cfg.secret_key, + cfg.secret_keylen, cfg.secret_keyid, + cfg.secret_keyidlen)) { BIO_puts(bio_err, "Error decrypting CMS using secret key\n"); goto end; @@ -1650,95 +1648,95 @@ cms_main(int argc, char **argv) goto end; } } - if (cms_config.pwri_pass != NULL) { + if (cfg.pwri_pass != NULL) { if (!CMS_decrypt_set1_password(cms, - cms_config.pwri_pass, -1)) { + cfg.pwri_pass, -1)) { BIO_puts(bio_err, "Error decrypting CMS using password\n"); goto end; } } if (!CMS_decrypt(cms, NULL, NULL, indata, out, - cms_config.flags)) { + cfg.flags)) { BIO_printf(bio_err, "Error decrypting CMS structure\n"); goto end; } - } else if (cms_config.operation == SMIME_DATAOUT) { - if (!CMS_data(cms, out, cms_config.flags)) + } else if (cfg.operation == SMIME_DATAOUT) { + if (!CMS_data(cms, out, cfg.flags)) goto end; - } else if (cms_config.operation == SMIME_UNCOMPRESS) { - if (!CMS_uncompress(cms, indata, out, cms_config.flags)) + } else if (cfg.operation == SMIME_UNCOMPRESS) { + if (!CMS_uncompress(cms, indata, out, cfg.flags)) goto end; - } else if (cms_config.operation == SMIME_DIGEST_VERIFY) { - if (CMS_digest_verify(cms, indata, out, cms_config.flags) > 0) + } else if (cfg.operation == SMIME_DIGEST_VERIFY) { + if (CMS_digest_verify(cms, indata, out, cfg.flags) > 0) BIO_printf(bio_err, "Verification successful\n"); else { BIO_printf(bio_err, "Verification failure\n"); goto end; } - } else if (cms_config.operation == SMIME_ENCRYPTED_DECRYPT) { - if (!CMS_EncryptedData_decrypt(cms, cms_config.secret_key, - cms_config.secret_keylen, indata, out, cms_config.flags)) + } else if (cfg.operation == SMIME_ENCRYPTED_DECRYPT) { + if (!CMS_EncryptedData_decrypt(cms, cfg.secret_key, + cfg.secret_keylen, indata, out, cfg.flags)) goto end; - } else if (cms_config.operation == SMIME_VERIFY) { + } else if (cfg.operation == SMIME_VERIFY) { if (CMS_verify(cms, other, store, indata, out, - cms_config.flags) > 0) { + cfg.flags) > 0) { BIO_printf(bio_err, "Verification successful\n"); } else { BIO_printf(bio_err, "Verification failure\n"); - if (cms_config.verify_retcode) + if (cfg.verify_retcode) ret = verify_err + 32; goto end; } - if (cms_config.signerfile != NULL) { + if (cfg.signerfile != NULL) { STACK_OF(X509) *signers; if ((signers = CMS_get0_signers(cms)) == NULL) goto end; - if (!save_certs(cms_config.signerfile, signers)) { + if (!save_certs(cfg.signerfile, signers)) { BIO_printf(bio_err, "Error writing signers to %s\n", - cms_config.signerfile); + cfg.signerfile); sk_X509_free(signers); ret = 5; goto end; } sk_X509_free(signers); } - if (cms_config.rr_print) + if (cfg.rr_print) receipt_request_print(bio_err, cms); - } else if (cms_config.operation == SMIME_VERIFY_RECEIPT) { + } else if (cfg.operation == SMIME_VERIFY_RECEIPT) { if (CMS_verify_receipt(rcms, cms, other, store, - cms_config.flags) > 0) { + cfg.flags) > 0) { BIO_printf(bio_err, "Verification successful\n"); } else { BIO_printf(bio_err, "Verification failure\n"); goto end; } } else { - if (cms_config.noout) { - if (cms_config.print && + if (cfg.noout) { + if (cfg.print && !CMS_ContentInfo_print_ctx(out, cms, 0, NULL)) goto end; - } else if (cms_config.outformat == FORMAT_SMIME) { - if (cms_config.to != NULL) - BIO_printf(out, "To: %s\n", cms_config.to); - if (cms_config.from != NULL) - BIO_printf(out, "From: %s\n", cms_config.from); - if (cms_config.subject != NULL) + } else if (cfg.outformat == FORMAT_SMIME) { + if (cfg.to != NULL) + BIO_printf(out, "To: %s\n", cfg.to); + if (cfg.from != NULL) + BIO_printf(out, "From: %s\n", cfg.from); + if (cfg.subject != NULL) BIO_printf(out, "Subject: %s\n", - cms_config.subject); - if (cms_config.operation == SMIME_RESIGN) + cfg.subject); + if (cfg.operation == SMIME_RESIGN) ret = SMIME_write_CMS(out, cms, indata, - cms_config.flags); + cfg.flags); else ret = SMIME_write_CMS(out, cms, in, - cms_config.flags); - } else if (cms_config.outformat == FORMAT_PEM) { + cfg.flags); + } else if (cfg.outformat == FORMAT_PEM) { ret = PEM_write_bio_CMS_stream(out, cms, in, - cms_config.flags); - } else if (cms_config.outformat == FORMAT_ASN1) { - ret = i2d_CMS_bio_stream(out, cms, in, cms_config.flags); + cfg.flags); + } else if (cfg.outformat == FORMAT_ASN1) { + ret = i2d_CMS_bio_stream(out, cms, in, cfg.flags); } else { BIO_printf(bio_err, "Bad output format for CMS file\n"); goto end; @@ -1754,27 +1752,27 @@ cms_main(int argc, char **argv) if (ret) ERR_print_errors(bio_err); - sk_X509_pop_free(cms_config.encerts, X509_free); + sk_X509_pop_free(cfg.encerts, X509_free); sk_X509_pop_free(other, X509_free); - X509_VERIFY_PARAM_free(cms_config.vpm); - sk_OPENSSL_STRING_free(cms_config.sksigners); - sk_OPENSSL_STRING_free(cms_config.skkeys); - free(cms_config.secret_key); - free(cms_config.secret_keyid); + X509_VERIFY_PARAM_free(cfg.vpm); + sk_OPENSSL_STRING_free(cfg.sksigners); + sk_OPENSSL_STRING_free(cfg.skkeys); + free(cfg.secret_key); + free(cfg.secret_keyid); free(pwri_tmp); - ASN1_OBJECT_free(cms_config.econtent_type); + ASN1_OBJECT_free(cfg.econtent_type); CMS_ReceiptRequest_free(rr); - sk_OPENSSL_STRING_free(cms_config.rr_to); - sk_OPENSSL_STRING_free(cms_config.rr_from); - for (cms_config.key_param = cms_config.key_first; cms_config.key_param;) { + sk_OPENSSL_STRING_free(cfg.rr_to); + sk_OPENSSL_STRING_free(cfg.rr_from); + for (cfg.key_param = cfg.key_first; cfg.key_param;) { struct cms_key_param *tparam; - sk_OPENSSL_STRING_free(cms_config.key_param->param); - tparam = cms_config.key_param->next; - free(cms_config.key_param); - cms_config.key_param = tparam; + sk_OPENSSL_STRING_free(cfg.key_param->param); + tparam = cfg.key_param->next; + free(cfg.key_param); + cfg.key_param = tparam; } X509_STORE_free(store); - X509_free(cms_config.cert); + X509_free(cfg.cert); X509_free(recip); X509_free(signer); EVP_PKEY_free(key); diff --git a/apps/openssl/crl.c b/apps/openssl/crl.c index 03136085..e64038df 100644 --- a/apps/openssl/crl.c +++ b/apps/openssl/crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crl.c,v 1.15 2021/10/31 16:47:27 tb Exp $ */ +/* $OpenBSD: crl.c,v 1.17 2023/03/06 14:32:05 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -86,7 +86,7 @@ static struct { int outformat; int text; int verify; -} crl_config; +} cfg; static const struct option crl_options[] = { { @@ -94,109 +94,109 @@ static const struct option crl_options[] = { .argname = "file", .desc = "Verify the CRL using certificates in the given file", .type = OPTION_ARG, - .opt.arg = &crl_config.cafile, + .opt.arg = &cfg.cafile, }, { .name = "CApath", .argname = "path", .desc = "Verify the CRL using certificates in the given path", .type = OPTION_ARG, - .opt.arg = &crl_config.capath, + .opt.arg = &cfg.capath, }, { .name = "crlnumber", .desc = "Print the CRL number", .type = OPTION_FLAG_ORD, - .opt.flag = &crl_config.crlnumber, + .opt.flag = &cfg.crlnumber, }, { .name = "fingerprint", .desc = "Print the CRL fingerprint", .type = OPTION_FLAG_ORD, - .opt.flag = &crl_config.fingerprint, + .opt.flag = &cfg.fingerprint, }, { .name = "hash", .desc = "Print the hash of the issuer name", .type = OPTION_FLAG_ORD, - .opt.flag = &crl_config.hash, + .opt.flag = &cfg.hash, }, { .name = "hash_old", .desc = "Print an old-style (MD5) hash of the issuer name", .type = OPTION_FLAG_ORD, - .opt.flag = &crl_config.hash_old, + .opt.flag = &cfg.hash_old, }, { .name = "in", .argname = "file", .desc = "Input file to read from (stdin if unspecified)", .type = OPTION_ARG, - .opt.arg = &crl_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM)", .type = OPTION_ARG_FORMAT, - .opt.value = &crl_config.informat, + .opt.value = &cfg.informat, }, { .name = "issuer", .desc = "Print the issuer name", .type = OPTION_FLAG_ORD, - .opt.flag = &crl_config.issuer, + .opt.flag = &cfg.issuer, }, { .name = "lastupdate", .desc = "Print the lastUpdate field", .type = OPTION_FLAG_ORD, - .opt.flag = &crl_config.lastupdate, + .opt.flag = &cfg.lastupdate, }, { .name = "nameopt", .argname = "options", .desc = "Specify certificate name options", .type = OPTION_ARG, - .opt.arg = &crl_config.nameopt, + .opt.arg = &cfg.nameopt, }, { .name = "nextupdate", .desc = "Print the nextUpdate field", .type = OPTION_FLAG_ORD, - .opt.flag = &crl_config.nextupdate, + .opt.flag = &cfg.nextupdate, }, { .name = "noout", .desc = "Do not output the encoded version of the CRL", .type = OPTION_FLAG, - .opt.flag = &crl_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file to write to (stdout if unspecified)", .type = OPTION_ARG, - .opt.arg = &crl_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM)", .type = OPTION_ARG_FORMAT, - .opt.value = &crl_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "text", .desc = "Print out the CRL in text form", .type = OPTION_FLAG, - .opt.flag = &crl_config.text, + .opt.flag = &cfg.text, }, { .name = "verify", .desc = "Verify the signature on the CRL", .type = OPTION_FLAG, - .opt.flag = &crl_config.verify, + .opt.flag = &cfg.verify, }, {NULL}, }; @@ -230,11 +230,9 @@ crl_main(int argc, char **argv) const EVP_MD *digest; char *digest_name = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } if (bio_out == NULL) { @@ -245,23 +243,23 @@ crl_main(int argc, char **argv) digest = EVP_sha256(); - memset(&crl_config, 0, sizeof(crl_config)); - crl_config.informat = FORMAT_PEM; - crl_config.outformat = FORMAT_PEM; + memset(&cfg, 0, sizeof(cfg)); + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, crl_options, &digest_name, NULL) != 0) { crl_usage(); goto end; } - if (crl_config.cafile != NULL || crl_config.capath != NULL) - crl_config.verify = 1; + if (cfg.cafile != NULL || cfg.capath != NULL) + cfg.verify = 1; - if (crl_config.nameopt != NULL) { - if (set_name_ex(&nmflag, crl_config.nameopt) != 1) { + if (cfg.nameopt != NULL) { + if (set_name_ex(&nmflag, cfg.nameopt) != 1) { fprintf(stderr, "Invalid -nameopt argument '%s'\n", - crl_config.nameopt); + cfg.nameopt); goto end; } } @@ -275,18 +273,18 @@ crl_main(int argc, char **argv) } } - x = load_crl(crl_config.infile, crl_config.informat); + x = load_crl(cfg.infile, cfg.informat); if (x == NULL) goto end; - if (crl_config.verify) { + if (cfg.verify) { store = X509_STORE_new(); if (store == NULL) goto end; lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file()); if (lookup == NULL) goto end; - if (!X509_LOOKUP_load_file(lookup, crl_config.cafile, + if (!X509_LOOKUP_load_file(lookup, cfg.cafile, X509_FILETYPE_PEM)) X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT); @@ -294,7 +292,7 @@ crl_main(int argc, char **argv) lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir()); if (lookup == NULL) goto end; - if (!X509_LOOKUP_add_dir(lookup, crl_config.capath, + if (!X509_LOOKUP_add_dir(lookup, cfg.capath, X509_FILETYPE_PEM)) X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT); @@ -337,11 +335,11 @@ crl_main(int argc, char **argv) /* Print requested information the order that the flags were given. */ for (i = 1; i <= argc; i++) { - if (crl_config.issuer == i) { + if (cfg.issuer == i) { print_name(bio_out, "issuer=", X509_CRL_get_issuer(x), nmflag); } - if (crl_config.crlnumber == i) { + if (cfg.crlnumber == i) { ASN1_INTEGER *crlnum; crlnum = X509_CRL_get_ext_d2i(x, NID_crl_number, NULL, NULL); @@ -353,23 +351,23 @@ crl_main(int argc, char **argv) BIO_puts(bio_out, ""); BIO_printf(bio_out, "\n"); } - if (crl_config.hash == i) { + if (cfg.hash == i) { BIO_printf(bio_out, "%08lx\n", X509_NAME_hash(X509_CRL_get_issuer(x))); } #ifndef OPENSSL_NO_MD5 - if (crl_config.hash_old == i) { + if (cfg.hash_old == i) { BIO_printf(bio_out, "%08lx\n", X509_NAME_hash_old(X509_CRL_get_issuer(x))); } #endif - if (crl_config.lastupdate == i) { + if (cfg.lastupdate == i) { BIO_printf(bio_out, "lastUpdate="); ASN1_TIME_print(bio_out, X509_CRL_get_lastUpdate(x)); BIO_printf(bio_out, "\n"); } - if (crl_config.nextupdate == i) { + if (cfg.nextupdate == i) { BIO_printf(bio_out, "nextUpdate="); if (X509_CRL_get_nextUpdate(x)) ASN1_TIME_print(bio_out, @@ -378,7 +376,7 @@ crl_main(int argc, char **argv) BIO_printf(bio_out, "NONE"); BIO_printf(bio_out, "\n"); } - if (crl_config.fingerprint == i) { + if (cfg.fingerprint == i) { int j; unsigned int n; unsigned char md[EVP_MAX_MD_SIZE]; @@ -401,25 +399,25 @@ crl_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (crl_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, crl_config.outfile) <= 0) { - perror(crl_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } - if (crl_config.text) + if (cfg.text) X509_CRL_print(out, x); - if (crl_config.noout) { + if (cfg.noout) { ret = 0; goto end; } - if (crl_config.outformat == FORMAT_ASN1) + if (cfg.outformat == FORMAT_ASN1) i = (int) i2d_X509_CRL_bio(out, x); - else if (crl_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_X509_CRL(out, x); else { BIO_printf(bio_err, diff --git a/apps/openssl/crl2p7.c b/apps/openssl/crl2p7.c index 8e5bf6a4..dfbc896a 100644 --- a/apps/openssl/crl2p7.c +++ b/apps/openssl/crl2p7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crl2p7.c,v 1.9 2019/07/14 03:30:45 guenther Exp $ */ +/* $OpenBSD: crl2p7.c,v 1.11 2023/03/06 14:32:05 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -83,18 +83,18 @@ static struct { int nocrl; char *outfile; int outformat; -} crl2p7_config; +} cfg; static int crl2p7_opt_certfile(char *arg) { - if (crl2p7_config.certflst == NULL) - crl2p7_config.certflst = sk_OPENSSL_STRING_new_null(); - if (crl2p7_config.certflst == NULL) { + if (cfg.certflst == NULL) + cfg.certflst = sk_OPENSSL_STRING_new_null(); + if (cfg.certflst == NULL) { fprintf(stderr, "out of memory\n"); return (1); } - if (!sk_OPENSSL_STRING_push(crl2p7_config.certflst, arg)) { + if (!sk_OPENSSL_STRING_push(cfg.certflst, arg)) { fprintf(stderr, "out of memory\n"); return (1); } @@ -115,34 +115,34 @@ static const struct option crl2p7_options[] = { .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &crl2p7_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &crl2p7_config.informat, + .opt.value = &cfg.informat, }, { .name = "nocrl", .desc = "Do not read CRL from input or include CRL in output", .type = OPTION_FLAG, - .opt.flag = &crl2p7_config.nocrl, + .opt.flag = &cfg.nocrl, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &crl2p7_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &crl2p7_config.outformat, + .opt.value = &cfg.outformat, }, { NULL }, }; @@ -169,17 +169,15 @@ crl2pkcs7_main(int argc, char **argv) STACK_OF(X509) *cert_stack = NULL; int ret = 1; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&crl2p7_config, 0, sizeof(crl2p7_config)); + memset(&cfg, 0, sizeof(cfg)); - crl2p7_config.informat = FORMAT_PEM; - crl2p7_config.outformat = FORMAT_PEM; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, crl2p7_options, NULL, NULL) != 0) { crl2p7_usage(); @@ -192,19 +190,19 @@ crl2pkcs7_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (!crl2p7_config.nocrl) { - if (crl2p7_config.infile == NULL) + if (!cfg.nocrl) { + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, crl2p7_config.infile) <= 0) { - perror(crl2p7_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } - if (crl2p7_config.informat == FORMAT_ASN1) + if (cfg.informat == FORMAT_ASN1) crl = d2i_X509_CRL_bio(in, NULL); - else if (crl2p7_config.informat == FORMAT_PEM) + else if (cfg.informat == FORMAT_PEM) crl = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL); else { BIO_printf(bio_err, @@ -238,9 +236,9 @@ crl2pkcs7_main(int argc, char **argv) goto end; p7s->cert = cert_stack; - if (crl2p7_config.certflst) { - for (i = 0; i < sk_OPENSSL_STRING_num(crl2p7_config.certflst); i++) { - certfile = sk_OPENSSL_STRING_value(crl2p7_config.certflst, i); + if (cfg.certflst) { + for (i = 0; i < sk_OPENSSL_STRING_num(cfg.certflst); i++) { + certfile = sk_OPENSSL_STRING_value(cfg.certflst, i); if (add_certs_from_file(cert_stack, certfile) < 0) { BIO_printf(bio_err, "error loading certificates\n"); @@ -250,20 +248,20 @@ crl2pkcs7_main(int argc, char **argv) } } - sk_OPENSSL_STRING_free(crl2p7_config.certflst); + sk_OPENSSL_STRING_free(cfg.certflst); - if (crl2p7_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, crl2p7_config.outfile) <= 0) { - perror(crl2p7_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } - if (crl2p7_config.outformat == FORMAT_ASN1) + if (cfg.outformat == FORMAT_ASN1) i = i2d_PKCS7_bio(out, p7); - else if (crl2p7_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_PKCS7(out, p7); else { BIO_printf(bio_err, diff --git a/apps/openssl/dgst.c b/apps/openssl/dgst.c index 689591cd..39799664 100644 --- a/apps/openssl/dgst.c +++ b/apps/openssl/dgst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dgst.c,v 1.19 2022/01/14 09:28:07 tb Exp $ */ +/* $OpenBSD: dgst.c,v 1.21 2023/03/06 14:32:05 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -96,7 +96,7 @@ static struct { char *sigfile; STACK_OF(OPENSSL_STRING) *sigopts; int want_pub; -} dgst_config; +} cfg; static int dgst_opt_macopt(char *arg) @@ -104,11 +104,11 @@ dgst_opt_macopt(char *arg) if (arg == NULL) return (1); - if (dgst_config.macopts == NULL && - (dgst_config.macopts = sk_OPENSSL_STRING_new_null()) == NULL) + if (cfg.macopts == NULL && + (cfg.macopts = sk_OPENSSL_STRING_new_null()) == NULL) return (1); - if (!sk_OPENSSL_STRING_push(dgst_config.macopts, arg)) + if (!sk_OPENSSL_STRING_push(cfg.macopts, arg)) return (1); return (0); @@ -122,10 +122,10 @@ dgst_opt_md(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((dgst_config.m = EVP_get_digestbyname(name)) == NULL) + if ((cfg.m = EVP_get_digestbyname(name)) == NULL) return (1); - dgst_config.md = dgst_config.m; + cfg.md = cfg.m; *argsused = 1; return (0); @@ -137,8 +137,8 @@ dgst_opt_prverify(char *arg) if (arg == NULL) return (1); - dgst_config.keyfile = arg; - dgst_config.do_verify = 1; + cfg.keyfile = arg; + cfg.do_verify = 1; return (0); } @@ -148,11 +148,11 @@ dgst_opt_sigopt(char *arg) if (arg == NULL) return (1); - if (dgst_config.sigopts == NULL && - (dgst_config.sigopts = sk_OPENSSL_STRING_new_null()) == NULL) + if (cfg.sigopts == NULL && + (cfg.sigopts = sk_OPENSSL_STRING_new_null()) == NULL) return (1); - if (!sk_OPENSSL_STRING_push(dgst_config.sigopts, arg)) + if (!sk_OPENSSL_STRING_push(cfg.sigopts, arg)) return (1); return (0); @@ -164,9 +164,9 @@ dgst_opt_verify(char *arg) if (arg == NULL) return (1); - dgst_config.keyfile = arg; - dgst_config.want_pub = 1; - dgst_config.do_verify = 1; + cfg.keyfile = arg; + cfg.want_pub = 1; + cfg.do_verify = 1; return (0); } @@ -175,27 +175,27 @@ static const struct option dgst_options[] = { .name = "binary", .desc = "Output the digest or signature in binary form", .type = OPTION_VALUE, - .opt.value = &dgst_config.out_bin, + .opt.value = &cfg.out_bin, .value = 1, }, { .name = "c", .desc = "Print the digest in two-digit groups separated by colons", .type = OPTION_VALUE, - .opt.value = &dgst_config.separator, + .opt.value = &cfg.separator, .value = 1, }, { .name = "d", .desc = "Print BIO debugging information", .type = OPTION_FLAG, - .opt.flag = &dgst_config.debug, + .opt.flag = &cfg.debug, }, { .name = "hex", .desc = "Output as hex dump", .type = OPTION_VALUE, - .opt.value = &dgst_config.out_bin, + .opt.value = &cfg.out_bin, .value = 0, }, { @@ -203,21 +203,21 @@ static const struct option dgst_options[] = { .argname = "key", .desc = "Create hashed MAC with key", .type = OPTION_ARG, - .opt.arg = &dgst_config.hmac_key, + .opt.arg = &cfg.hmac_key, }, { .name = "keyform", .argname = "format", .desc = "Key file format (PEM)", .type = OPTION_ARG_FORMAT, - .opt.value = &dgst_config.keyform, + .opt.value = &cfg.keyform, }, { .name = "mac", .argname = "algorithm", .desc = "Create MAC (not necessarily HMAC)", .type = OPTION_ARG, - .opt.arg = &dgst_config.mac_name, + .opt.arg = &cfg.mac_name, }, { .name = "macopt", @@ -231,14 +231,14 @@ static const struct option dgst_options[] = { .argname = "file", .desc = "Output to file rather than stdout", .type = OPTION_ARG, - .opt.arg = &dgst_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "passin", .argname = "arg", .desc = "Input file passphrase source", .type = OPTION_ARG, - .opt.arg = &dgst_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "prverify", @@ -251,7 +251,7 @@ static const struct option dgst_options[] = { .name = "r", .desc = "Output the digest in coreutils format", .type = OPTION_VALUE, - .opt.value = &dgst_config.separator, + .opt.value = &cfg.separator, .value = 2, }, { @@ -259,14 +259,14 @@ static const struct option dgst_options[] = { .argname = "file", .desc = "Sign digest using private key in file", .type = OPTION_ARG, - .opt.arg = &dgst_config.keyfile, + .opt.arg = &cfg.keyfile, }, { .name = "signature", .argname = "file", .desc = "Signature to verify", .type = OPTION_ARG, - .opt.arg = &dgst_config.sigfile, + .opt.arg = &cfg.sigfile, }, { .name = "sigopt", @@ -338,11 +338,9 @@ dgst_main(int argc, char **argv) int siglen = 0; char *passin = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } if ((buf = malloc(BUFSIZE)) == NULL) { @@ -350,24 +348,24 @@ dgst_main(int argc, char **argv) goto end; } - memset(&dgst_config, 0, sizeof(dgst_config)); - dgst_config.keyform = FORMAT_PEM; - dgst_config.out_bin = -1; + memset(&cfg, 0, sizeof(cfg)); + cfg.keyform = FORMAT_PEM; + cfg.out_bin = -1; /* first check the program name */ program_name(argv[0], pname, sizeof pname); - dgst_config.md = EVP_get_digestbyname(pname); + cfg.md = EVP_get_digestbyname(pname); if (options_parse(argc, argv, dgst_options, NULL, - &dgst_config.argsused) != 0) { + &cfg.argsused) != 0) { dgst_usage(); goto end; } - argc -= dgst_config.argsused; - argv += dgst_config.argsused; + argc -= cfg.argsused; + argv += cfg.argsused; - if (dgst_config.do_verify && !dgst_config.sigfile) { + if (cfg.do_verify && !cfg.sigfile) { BIO_printf(bio_err, "No signature to verify: use the -signature option\n"); goto end; @@ -380,50 +378,50 @@ dgst_main(int argc, char **argv) goto end; } - if (dgst_config.debug) { + if (cfg.debug) { BIO_set_callback(in, BIO_debug_callback); /* needed for windows 3.1 */ BIO_set_callback_arg(in, (char *) bio_err); } - if (!app_passwd(bio_err, dgst_config.passargin, NULL, &passin, NULL)) { + if (!app_passwd(bio_err, cfg.passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } - if (dgst_config.out_bin == -1) { - if (dgst_config.keyfile) - dgst_config.out_bin = 1; + if (cfg.out_bin == -1) { + if (cfg.keyfile) + cfg.out_bin = 1; else - dgst_config.out_bin = 0; + cfg.out_bin = 0; } - if (dgst_config.outfile) { - if (dgst_config.out_bin) - out = BIO_new_file(dgst_config.outfile, "wb"); + if (cfg.outfile) { + if (cfg.out_bin) + out = BIO_new_file(cfg.outfile, "wb"); else - out = BIO_new_file(dgst_config.outfile, "w"); + out = BIO_new_file(cfg.outfile, "w"); } else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } if (!out) { BIO_printf(bio_err, "Error opening output file %s\n", - dgst_config.outfile ? dgst_config.outfile : "(stdout)"); + cfg.outfile ? cfg.outfile : "(stdout)"); ERR_print_errors(bio_err); goto end; } - if ((!!dgst_config.mac_name + !!dgst_config.keyfile + - !!dgst_config.hmac_key) > 1) { + if ((!!cfg.mac_name + !!cfg.keyfile + + !!cfg.hmac_key) > 1) { BIO_printf(bio_err, "MAC and Signing key cannot both be specified\n"); goto end; } - if (dgst_config.keyfile) { - if (dgst_config.want_pub) - sigkey = load_pubkey(bio_err, dgst_config.keyfile, - dgst_config.keyform, 0, NULL, "key file"); + if (cfg.keyfile) { + if (cfg.want_pub) + sigkey = load_pubkey(bio_err, cfg.keyfile, + cfg.keyform, 0, NULL, "key file"); else - sigkey = load_key(bio_err, dgst_config.keyfile, - dgst_config.keyform, 0, passin, "key file"); + sigkey = load_key(bio_err, cfg.keyfile, + cfg.keyform, 0, passin, "key file"); if (!sigkey) { /* * load_[pub]key() has already printed an appropriate @@ -432,17 +430,17 @@ dgst_main(int argc, char **argv) goto end; } } - if (dgst_config.mac_name) { + if (cfg.mac_name) { EVP_PKEY_CTX *mac_ctx = NULL; int r = 0; - if (!init_gen_str(bio_err, &mac_ctx, dgst_config.mac_name, 0)) + if (!init_gen_str(bio_err, &mac_ctx, cfg.mac_name, 0)) goto mac_end; - if (dgst_config.macopts) { + if (cfg.macopts) { char *macopt; for (i = 0; i < sk_OPENSSL_STRING_num( - dgst_config.macopts); i++) { + cfg.macopts); i++) { macopt = sk_OPENSSL_STRING_value( - dgst_config.macopts, i); + cfg.macopts, i); if (pkey_ctrl_string(mac_ctx, macopt) <= 0) { BIO_printf(bio_err, "MAC parameter error \"%s\"\n", @@ -463,9 +461,9 @@ dgst_main(int argc, char **argv) if (r == 0) goto end; } - if (dgst_config.hmac_key) { + if (cfg.hmac_key) { sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, - (unsigned char *) dgst_config.hmac_key, -1); + (unsigned char *) cfg.hmac_key, -1); if (!sigkey) goto end; } @@ -478,23 +476,23 @@ dgst_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (dgst_config.do_verify) - r = EVP_DigestVerifyInit(mctx, &pctx, dgst_config.md, + if (cfg.do_verify) + r = EVP_DigestVerifyInit(mctx, &pctx, cfg.md, NULL, sigkey); else - r = EVP_DigestSignInit(mctx, &pctx, dgst_config.md, + r = EVP_DigestSignInit(mctx, &pctx, cfg.md, NULL, sigkey); if (!r) { BIO_printf(bio_err, "Error setting context\n"); ERR_print_errors(bio_err); goto end; } - if (dgst_config.sigopts) { + if (cfg.sigopts) { char *sigopt; for (i = 0; i < sk_OPENSSL_STRING_num( - dgst_config.sigopts); i++) { + cfg.sigopts); i++) { sigopt = sk_OPENSSL_STRING_value( - dgst_config.sigopts, i); + cfg.sigopts, i); if (pkey_ctrl_string(pctx, sigopt) <= 0) { BIO_printf(bio_err, "parameter error \"%s\"\n", @@ -507,16 +505,16 @@ dgst_main(int argc, char **argv) } /* we use md as a filter, reading from 'in' */ else { - if (dgst_config.md == NULL) - dgst_config.md = EVP_sha256(); - if (!BIO_set_md(bmd, dgst_config.md)) { + if (cfg.md == NULL) + cfg.md = EVP_sha256(); + if (!BIO_set_md(bmd, cfg.md)) { BIO_printf(bio_err, "Error setting digest %s\n", pname); ERR_print_errors(bio_err); goto end; } } - if (dgst_config.sigfile && sigkey) { + if (cfg.sigfile && sigkey) { BIO *sigbio; siglen = EVP_PKEY_size(sigkey); sigbuf = malloc(siglen); @@ -525,10 +523,10 @@ dgst_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - sigbio = BIO_new_file(dgst_config.sigfile, "rb"); + sigbio = BIO_new_file(cfg.sigfile, "rb"); if (!sigbio) { BIO_printf(bio_err, "Error opening signature file %s\n", - dgst_config.sigfile); + cfg.sigfile); ERR_print_errors(bio_err); goto end; } @@ -536,26 +534,26 @@ dgst_main(int argc, char **argv) BIO_free(sigbio); if (siglen <= 0) { BIO_printf(bio_err, "Error reading signature file %s\n", - dgst_config.sigfile); + cfg.sigfile); ERR_print_errors(bio_err); goto end; } } inp = BIO_push(bmd, in); - if (dgst_config.md == NULL) { + if (cfg.md == NULL) { EVP_MD_CTX *tctx; BIO_get_md_ctx(bmd, &tctx); - dgst_config.md = EVP_MD_CTX_md(tctx); + cfg.md = EVP_MD_CTX_md(tctx); } if (argc == 0) { BIO_set_fp(in, stdin, BIO_NOCLOSE); - err = do_fp(out, buf, inp, dgst_config.separator, - dgst_config.out_bin, sigkey, sigbuf, siglen, NULL, NULL, + err = do_fp(out, buf, inp, cfg.separator, + cfg.out_bin, sigkey, sigbuf, siglen, NULL, NULL, "stdin", bmd); } else { const char *md_name = NULL, *sig_name = NULL; - if (!dgst_config.out_bin) { + if (!cfg.out_bin) { if (sigkey) { const EVP_PKEY_ASN1_METHOD *ameth; ameth = EVP_PKEY_get0_asn1(sigkey); @@ -563,7 +561,7 @@ dgst_main(int argc, char **argv) EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL, &sig_name, ameth); } - md_name = EVP_MD_name(dgst_config.md); + md_name = EVP_MD_name(cfg.md); } err = 0; for (i = 0; i < argc; i++) { @@ -573,8 +571,8 @@ dgst_main(int argc, char **argv) err++; continue; } else { - r = do_fp(out, buf, inp, dgst_config.separator, - dgst_config.out_bin, sigkey, sigbuf, siglen, + r = do_fp(out, buf, inp, cfg.separator, + cfg.out_bin, sigkey, sigbuf, siglen, sig_name, md_name, argv[i], bmd); } if (r) @@ -589,8 +587,8 @@ dgst_main(int argc, char **argv) free(passin); BIO_free_all(out); EVP_PKEY_free(sigkey); - sk_OPENSSL_STRING_free(dgst_config.sigopts); - sk_OPENSSL_STRING_free(dgst_config.macopts); + sk_OPENSSL_STRING_free(cfg.sigopts); + sk_OPENSSL_STRING_free(cfg.macopts); free(sigbuf); BIO_free(bmd); diff --git a/apps/openssl/dh.c b/apps/openssl/dh.c index c2c5d689..a4c02235 100644 --- a/apps/openssl/dh.c +++ b/apps/openssl/dh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh.c,v 1.13 2022/01/14 09:21:54 tb Exp $ */ +/* $OpenBSD: dh.c,v 1.15 2023/03/06 14:32:05 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -83,60 +83,60 @@ static struct { char *outfile; int outformat; int text; -} dh_config; +} cfg; static const struct option dh_options[] = { { .name = "C", .desc = "Convert DH parameters into C code", .type = OPTION_FLAG, - .opt.flag = &dh_config.C, + .opt.flag = &cfg.C, }, { .name = "check", .desc = "Check the DH parameters", .type = OPTION_FLAG, - .opt.flag = &dh_config.check, + .opt.flag = &cfg.check, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &dh_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &dh_config.informat, + .opt.value = &cfg.informat, }, { .name = "noout", .desc = "No output", .type = OPTION_FLAG, - .opt.flag = &dh_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &dh_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &dh_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "text", .desc = "Print a text form of the DH parameters", .type = OPTION_FLAG, - .opt.flag = &dh_config.text, + .opt.flag = &cfg.text, }, { NULL }, }; @@ -158,17 +158,15 @@ dh_main(int argc, char **argv) BIO *in = NULL, *out = NULL; int ret = 1; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&dh_config, 0, sizeof(dh_config)); + memset(&cfg, 0, sizeof(cfg)); - dh_config.informat = FORMAT_PEM; - dh_config.outformat = FORMAT_PEM; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, dh_options, NULL, NULL) != 0) { dh_usage(); @@ -181,26 +179,26 @@ dh_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (dh_config.infile == NULL) + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, dh_config.infile) <= 0) { - perror(dh_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } - if (dh_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, dh_config.outfile) <= 0) { - perror(dh_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } - if (dh_config.informat == FORMAT_ASN1) + if (cfg.informat == FORMAT_ASN1) dh = d2i_DHparams_bio(in, NULL); - else if (dh_config.informat == FORMAT_PEM) + else if (cfg.informat == FORMAT_PEM) dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL); else { BIO_printf(bio_err, "bad input format specified\n"); @@ -211,10 +209,10 @@ dh_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (dh_config.text) { + if (cfg.text) { DHparams_print(out, dh); } - if (dh_config.check) { + if (cfg.check) { if (!DH_check(dh, &i)) { ERR_print_errors(bio_err); goto end; @@ -230,7 +228,7 @@ dh_main(int argc, char **argv) if (i == 0) printf("DH parameters appear to be ok.\n"); } - if (dh_config.C) { + if (cfg.C) { unsigned char *data; int len, l, bits; @@ -273,10 +271,10 @@ dh_main(int argc, char **argv) printf("\treturn(dh);\n\t}\n"); free(data); } - if (!dh_config.noout) { - if (dh_config.outformat == FORMAT_ASN1) + if (!cfg.noout) { + if (cfg.outformat == FORMAT_ASN1) i = i2d_DHparams_bio(out, dh); - else if (dh_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_DHparams(out, dh); else { BIO_printf(bio_err, "bad output format specified for outfile\n"); diff --git a/apps/openssl/dhparam.c b/apps/openssl/dhparam.c index da9075f5..0542464d 100644 --- a/apps/openssl/dhparam.c +++ b/apps/openssl/dhparam.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhparam.c,v 1.14 2022/01/14 09:22:50 tb Exp $ */ +/* $OpenBSD: dhparam.c,v 1.17 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -131,7 +131,7 @@ #define DEFBITS 2048 -struct { +static struct { int C; int check; int dsaparam; @@ -142,7 +142,7 @@ struct { char *outfile; int outformat; int text; -} dhparam_config; +} cfg; static const struct option dhparam_options[] = { { @@ -150,73 +150,73 @@ static const struct option dhparam_options[] = { .desc = "Generate DH parameters with a generator value of 2 " "(default)", .type = OPTION_VALUE, - .opt.value = &dhparam_config.g, + .opt.value = &cfg.g, .value = 2, }, { .name = "5", .desc = "Generate DH parameters with a generator value of 5", .type = OPTION_VALUE, - .opt.value = &dhparam_config.g, + .opt.value = &cfg.g, .value = 5, }, { .name = "C", .desc = "Convert DH parameters into C code", .type = OPTION_FLAG, - .opt.flag = &dhparam_config.C, + .opt.flag = &cfg.C, }, { .name = "check", .desc = "Check the DH parameters", .type = OPTION_FLAG, - .opt.flag = &dhparam_config.check, + .opt.flag = &cfg.check, }, { .name = "dsaparam", .desc = "Read or generate DSA parameters and convert to DH", .type = OPTION_FLAG, - .opt.flag = &dhparam_config.dsaparam, + .opt.flag = &cfg.dsaparam, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &dhparam_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &dhparam_config.informat, + .opt.value = &cfg.informat, }, { .name = "noout", .desc = "Do not output encoded version of DH parameters", .type = OPTION_FLAG, - .opt.flag = &dhparam_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &dhparam_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &dhparam_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "text", .desc = "Print DH parameters in plain text", .type = OPTION_FLAG, - .opt.flag = &dhparam_config.text, + .opt.flag = &cfg.text, }, { NULL }, }; @@ -244,17 +244,15 @@ dhparam_main(int argc, char **argv) int ret = 1; int i; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&dhparam_config, 0, sizeof(dhparam_config)); + memset(&cfg, 0, sizeof(cfg)); - dhparam_config.informat = FORMAT_PEM; - dhparam_config.outformat = FORMAT_PEM; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, dhparam_options, &num_bits, NULL) != 0) { dhparam_usage(); @@ -269,18 +267,18 @@ dhparam_main(int argc, char **argv) } } - if (dhparam_config.g && !num) + if (cfg.g && !num) num = DEFBITS; - if (dhparam_config.dsaparam) { - if (dhparam_config.g) { + if (cfg.dsaparam) { + if (cfg.g) { BIO_printf(bio_err, "generator may not be chosen for DSA parameters\n"); goto end; } } else { /* DH parameters */ - if (num && !dhparam_config.g) - dhparam_config.g = 2; + if (num && !cfg.g) + cfg.g = 2; } if (num) { @@ -291,7 +289,7 @@ dhparam_main(int argc, char **argv) } BN_GENCB_set(cb, dh_cb, bio_err); - if (dhparam_config.dsaparam) { + if (cfg.dsaparam) { DSA *dsa = DSA_new(); BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n", num); @@ -309,9 +307,9 @@ dhparam_main(int argc, char **argv) } } else { dh = DH_new(); - BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime, generator %d\n", num, dhparam_config.g); + BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime, generator %d\n", num, cfg.g); BIO_printf(bio_err, "This is going to take a long time\n"); - if (!dh || !DH_generate_parameters_ex(dh, num, dhparam_config.g, cb)) { + if (!dh || !DH_generate_parameters_ex(dh, num, cfg.g, cb)) { ERR_print_errors(bio_err); goto end; } @@ -323,24 +321,24 @@ dhparam_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (dhparam_config.infile == NULL) + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, dhparam_config.infile) <= 0) { - perror(dhparam_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } - if (dhparam_config.informat != FORMAT_ASN1 && - dhparam_config.informat != FORMAT_PEM) { + if (cfg.informat != FORMAT_ASN1 && + cfg.informat != FORMAT_PEM) { BIO_printf(bio_err, "bad input format specified\n"); goto end; } - if (dhparam_config.dsaparam) { + if (cfg.dsaparam) { DSA *dsa; - if (dhparam_config.informat == FORMAT_ASN1) + if (cfg.informat == FORMAT_ASN1) dsa = d2i_DSAparams_bio(in, NULL); else /* informat == FORMAT_PEM */ dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL); @@ -358,7 +356,7 @@ dhparam_main(int argc, char **argv) } } else { - if (dhparam_config.informat == FORMAT_ASN1) + if (cfg.informat == FORMAT_ASN1) dh = d2i_DHparams_bio(in, NULL); else /* informat == FORMAT_PEM */ dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL); @@ -378,20 +376,20 @@ dhparam_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (dhparam_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, dhparam_config.outfile) <= 0) { - perror(dhparam_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } - if (dhparam_config.text) { + if (cfg.text) { DHparams_print(out, dh); } - if (dhparam_config.check) { + if (cfg.check) { if (!DH_check(dh, &i)) { ERR_print_errors(bio_err); goto end; @@ -407,7 +405,7 @@ dhparam_main(int argc, char **argv) if (i == 0) printf("DH parameters appear to be ok.\n"); } - if (dhparam_config.C) { + if (cfg.C) { unsigned char *data; int len, l, bits; @@ -456,10 +454,10 @@ dhparam_main(int argc, char **argv) printf("\treturn(dh);\n\t}\n"); free(data); } - if (!dhparam_config.noout) { - if (dhparam_config.outformat == FORMAT_ASN1) + if (!cfg.noout) { + if (cfg.outformat == FORMAT_ASN1) i = i2d_DHparams_bio(out, dh); - else if (dhparam_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_DHparams(out, dh); else { BIO_printf(bio_err, "bad output format specified for outfile\n"); diff --git a/apps/openssl/dsa.c b/apps/openssl/dsa.c index df45cd6e..f1de78cf 100644 --- a/apps/openssl/dsa.c +++ b/apps/openssl/dsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa.c,v 1.16 2022/01/14 09:23:42 tb Exp $ */ +/* $OpenBSD: dsa.c,v 1.18 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -87,7 +87,7 @@ static struct { int pubout; int pvk_encr; int text; -} dsa_config; +} cfg; static int dsa_opt_enc(int argc, char **argv, int *argsused) @@ -97,7 +97,7 @@ dsa_opt_enc(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((dsa_config.enc = EVP_get_cipherbyname(name)) != NULL) { + if ((cfg.enc = EVP_get_cipherbyname(name)) != NULL) { *argsused = 1; return (0); } @@ -111,7 +111,7 @@ static const struct option dsa_options[] = { .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &dsa_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", @@ -119,87 +119,87 @@ static const struct option dsa_options[] = { .desc = "Input format (PEM (default) or any other supported" " format)", .type = OPTION_ARG_FORMAT, - .opt.value = &dsa_config.informat, + .opt.value = &cfg.informat, }, { .name = "modulus", .desc = "Print the DSA public value", .type = OPTION_FLAG, - .opt.flag = &dsa_config.modulus, + .opt.flag = &cfg.modulus, }, { .name = "noout", .desc = "No output", .type = OPTION_FLAG, - .opt.flag = &dsa_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &dsa_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER, MSBLOB, PEM (default) or PVK)", .type = OPTION_ARG_FORMAT, - .opt.value = &dsa_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "passin", .argname = "source", .desc = "Input file passphrase source", .type = OPTION_ARG, - .opt.arg = &dsa_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "passout", .argname = "source", .desc = "Output file passphrase source", .type = OPTION_ARG, - .opt.arg = &dsa_config.passargout, + .opt.arg = &cfg.passargout, }, { .name = "pubin", .desc = "Read a public key from the input file instead of" " private key", .type = OPTION_FLAG, - .opt.flag = &dsa_config.pubin, + .opt.flag = &cfg.pubin, }, { .name = "pubout", .desc = "Output a public key instead of private key", .type = OPTION_FLAG, - .opt.flag = &dsa_config.pubout, + .opt.flag = &cfg.pubout, }, { .name = "pvk-none", .desc = "PVK encryption level", .type = OPTION_VALUE, .value = 0, - .opt.value = &dsa_config.pvk_encr, + .opt.value = &cfg.pvk_encr, }, { .name = "pvk-strong", .desc = "PVK encryption level (default)", .type = OPTION_VALUE, .value = 2, - .opt.value = &dsa_config.pvk_encr, + .opt.value = &cfg.pvk_encr, }, { .name = "pvk-weak", .desc = "PVK encryption level", .type = OPTION_VALUE, .value = 1, - .opt.value = &dsa_config.pvk_encr, + .opt.value = &cfg.pvk_encr, }, { .name = "text", .desc = "Print the key in text form", .type = OPTION_FLAG, - .opt.flag = &dsa_config.text, + .opt.flag = &cfg.text, }, { .name = NULL, @@ -236,25 +236,23 @@ dsa_main(int argc, char **argv) BIO *in = NULL, *out = NULL; char *passin = NULL, *passout = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&dsa_config, 0, sizeof(dsa_config)); + memset(&cfg, 0, sizeof(cfg)); - dsa_config.pvk_encr = 2; - dsa_config.informat = FORMAT_PEM; - dsa_config.outformat = FORMAT_PEM; + cfg.pvk_encr = 2; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, dsa_options, NULL, NULL) != 0) { dsa_usage(); goto end; } - if (!app_passwd(bio_err, dsa_config.passargin, dsa_config.passargout, + if (!app_passwd(bio_err, cfg.passargin, cfg.passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); goto end; @@ -266,11 +264,11 @@ dsa_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (dsa_config.infile == NULL) + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, dsa_config.infile) <= 0) { - perror(dsa_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } @@ -280,12 +278,12 @@ dsa_main(int argc, char **argv) { EVP_PKEY *pkey; - if (dsa_config.pubin) - pkey = load_pubkey(bio_err, dsa_config.infile, - dsa_config.informat, 1, passin, "Public Key"); + if (cfg.pubin) + pkey = load_pubkey(bio_err, cfg.infile, + cfg.informat, 1, passin, "Public Key"); else - pkey = load_key(bio_err, dsa_config.infile, - dsa_config.informat, 1, passin, "Private Key"); + pkey = load_key(bio_err, cfg.infile, + cfg.informat, 1, passin, "Private Key"); if (pkey) { dsa = EVP_PKEY_get1_DSA(pkey); @@ -297,51 +295,51 @@ dsa_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (dsa_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, dsa_config.outfile) <= 0) { - perror(dsa_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } - if (dsa_config.text) { + if (cfg.text) { if (!DSA_print(out, dsa, 0)) { - perror(dsa_config.outfile); + perror(cfg.outfile); ERR_print_errors(bio_err); goto end; } } - if (dsa_config.modulus) { + if (cfg.modulus) { fprintf(stdout, "Public Key="); BN_print(out, DSA_get0_pub_key(dsa)); fprintf(stdout, "\n"); } - if (dsa_config.noout) + if (cfg.noout) goto end; BIO_printf(bio_err, "writing DSA key\n"); - if (dsa_config.outformat == FORMAT_ASN1) { - if (dsa_config.pubin || dsa_config.pubout) + if (cfg.outformat == FORMAT_ASN1) { + if (cfg.pubin || cfg.pubout) i = i2d_DSA_PUBKEY_bio(out, dsa); else i = i2d_DSAPrivateKey_bio(out, dsa); - } else if (dsa_config.outformat == FORMAT_PEM) { - if (dsa_config.pubin || dsa_config.pubout) + } else if (cfg.outformat == FORMAT_PEM) { + if (cfg.pubin || cfg.pubout) i = PEM_write_bio_DSA_PUBKEY(out, dsa); else - i = PEM_write_bio_DSAPrivateKey(out, dsa, dsa_config.enc, + i = PEM_write_bio_DSAPrivateKey(out, dsa, cfg.enc, NULL, 0, NULL, passout); #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_RC4) - } else if (dsa_config.outformat == FORMAT_MSBLOB || - dsa_config.outformat == FORMAT_PVK) { + } else if (cfg.outformat == FORMAT_MSBLOB || + cfg.outformat == FORMAT_PVK) { EVP_PKEY *pk; pk = EVP_PKEY_new(); EVP_PKEY_set1_DSA(pk, dsa); - if (dsa_config.outformat == FORMAT_PVK) - i = i2b_PVK_bio(out, pk, dsa_config.pvk_encr, 0, + if (cfg.outformat == FORMAT_PVK) + i = i2b_PVK_bio(out, pk, cfg.pvk_encr, 0, passout); - else if (dsa_config.pubin || dsa_config.pubout) + else if (cfg.pubin || cfg.pubout) i = i2b_PublicKey_bio(out, pk); else i = i2b_PrivateKey_bio(out, pk); diff --git a/apps/openssl/dsaparam.c b/apps/openssl/dsaparam.c index 33bde035..bc9ccd14 100644 --- a/apps/openssl/dsaparam.c +++ b/apps/openssl/dsaparam.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsaparam.c,v 1.13 2022/01/14 09:24:20 tb Exp $ */ +/* $OpenBSD: dsaparam.c,v 1.15 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -88,60 +88,60 @@ static struct { char *outfile; int outformat; int text; -} dsaparam_config; +} cfg; static const struct option dsaparam_options[] = { { .name = "C", .desc = "Convert DSA parameters into C code", .type = OPTION_FLAG, - .opt.flag = &dsaparam_config.C, + .opt.flag = &cfg.C, }, { .name = "genkey", .desc = "Generate a DSA key", .type = OPTION_FLAG, - .opt.flag = &dsaparam_config.genkey, + .opt.flag = &cfg.genkey, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &dsaparam_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &dsaparam_config.informat, + .opt.value = &cfg.informat, }, { .name = "noout", .desc = "No output", .type = OPTION_FLAG, - .opt.flag = &dsaparam_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &dsaparam_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &dsaparam_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "text", .desc = "Print as text", .type = OPTION_FLAG, - .opt.flag = &dsaparam_config.text, + .opt.flag = &cfg.text, }, { NULL }, }; @@ -169,17 +169,15 @@ dsaparam_main(int argc, char **argv) int numbits = -1; char *strbits = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&dsaparam_config, 0, sizeof(dsaparam_config)); + memset(&cfg, 0, sizeof(cfg)); - dsaparam_config.informat = FORMAT_PEM; - dsaparam_config.outformat = FORMAT_PEM; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, dsaparam_options, &strbits, NULL) != 0) { dsaparam_usage(); @@ -201,19 +199,19 @@ dsaparam_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (dsaparam_config.infile == NULL) + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, dsaparam_config.infile) <= 0) { - perror(dsaparam_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } - if (dsaparam_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, dsaparam_config.outfile) <= 0) { - perror(dsaparam_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } @@ -239,9 +237,9 @@ dsaparam_main(int argc, char **argv) BIO_printf(bio_err, "Error, DSA key generation failed\n"); goto end; } - } else if (dsaparam_config.informat == FORMAT_ASN1) + } else if (cfg.informat == FORMAT_ASN1) dsa = d2i_DSAparams_bio(in, NULL); - else if (dsaparam_config.informat == FORMAT_PEM) + else if (cfg.informat == FORMAT_PEM) dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL); else { BIO_printf(bio_err, "bad input format specified\n"); @@ -252,10 +250,10 @@ dsaparam_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (dsaparam_config.text) { + if (cfg.text) { DSAparams_print(out, dsa); } - if (dsaparam_config.C) { + if (cfg.C) { unsigned char *data; int l, len, bits_p; @@ -309,10 +307,10 @@ dsaparam_main(int argc, char **argv) printf("\tDSA_set0_pqg(dsa, p, q, g);\n"); printf("\treturn(dsa);\n\t}\n"); } - if (!dsaparam_config.noout) { - if (dsaparam_config.outformat == FORMAT_ASN1) + if (!cfg.noout) { + if (cfg.outformat == FORMAT_ASN1) i = i2d_DSAparams_bio(out, dsa); - else if (dsaparam_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_DSAparams(out, dsa); else { BIO_printf(bio_err, "bad output format specified for outfile\n"); @@ -324,7 +322,7 @@ dsaparam_main(int argc, char **argv) goto end; } } - if (dsaparam_config.genkey) { + if (cfg.genkey) { DSA *dsakey; if ((dsakey = DSAparams_dup(dsa)) == NULL) @@ -334,9 +332,9 @@ dsaparam_main(int argc, char **argv) DSA_free(dsakey); goto end; } - if (dsaparam_config.outformat == FORMAT_ASN1) + if (cfg.outformat == FORMAT_ASN1) i = i2d_DSAPrivateKey_bio(out, dsakey); - else if (dsaparam_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_DSAPrivateKey(out, dsakey, NULL, NULL, 0, NULL, NULL); else { BIO_printf(bio_err, "bad output format specified for outfile\n"); diff --git a/apps/openssl/ec.c b/apps/openssl/ec.c index 3aa9b0c2..c6af1263 100644 --- a/apps/openssl/ec.c +++ b/apps/openssl/ec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec.c,v 1.14 2019/07/14 03:30:45 guenther Exp $ */ +/* $OpenBSD: ec.c,v 1.16 2023/03/06 14:32:06 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -88,7 +88,7 @@ static struct { int pubin; int pubout; int text; -} ec_config; +} cfg; static int ec_opt_enc(int argc, char **argv, int *argsused) @@ -98,7 +98,7 @@ ec_opt_enc(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((ec_config.enc = EVP_get_cipherbyname(name)) != NULL) { + if ((cfg.enc = EVP_get_cipherbyname(name)) != NULL) { *argsused = 1; return (0); } @@ -110,17 +110,17 @@ static int ec_opt_form(char *arg) { if (strcmp(arg, "compressed") == 0) - ec_config.form = POINT_CONVERSION_COMPRESSED; + cfg.form = POINT_CONVERSION_COMPRESSED; else if (strcmp(arg, "uncompressed") == 0) - ec_config.form = POINT_CONVERSION_UNCOMPRESSED; + cfg.form = POINT_CONVERSION_UNCOMPRESSED; else if (strcmp(arg, "hybrid") == 0) - ec_config.form = POINT_CONVERSION_HYBRID; + cfg.form = POINT_CONVERSION_HYBRID; else { fprintf(stderr, "Invalid point conversion: %s\n", arg); return (1); } - ec_config.new_form = 1; + cfg.new_form = 1; return (0); } @@ -128,15 +128,15 @@ static int ec_opt_named(char *arg) { if (strcmp(arg, "named_curve") == 0) - ec_config.asn1_flag = OPENSSL_EC_NAMED_CURVE; + cfg.asn1_flag = OPENSSL_EC_NAMED_CURVE; else if (strcmp(arg, "explicit") == 0) - ec_config.asn1_flag = 0; + cfg.asn1_flag = 0; else { fprintf(stderr, "Invalid curve type: %s\n", arg); return (1); } - ec_config.new_asn1_flag = 1; + cfg.new_asn1_flag = 1; return (0); } @@ -154,34 +154,34 @@ static const struct option ec_options[] = { .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &ec_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &ec_config.informat, + .opt.value = &cfg.informat, }, { .name = "noout", .desc = "No output", .type = OPTION_FLAG, - .opt.flag = &ec_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &ec_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &ec_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "param_enc", @@ -195,39 +195,39 @@ static const struct option ec_options[] = { .name = "param_out", .desc = "Print the elliptic curve parameters", .type = OPTION_FLAG, - .opt.flag = &ec_config.param_out, + .opt.flag = &cfg.param_out, }, { .name = "passin", .argname = "source", .desc = "Input file passphrase source", .type = OPTION_ARG, - .opt.arg = &ec_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "passout", .argname = "source", .desc = "Output file passphrase source", .type = OPTION_ARG, - .opt.arg = &ec_config.passargout, + .opt.arg = &cfg.passargout, }, { .name = "pubin", .desc = "Read public key instead of private key from input", .type = OPTION_FLAG, - .opt.flag = &ec_config.pubin, + .opt.flag = &cfg.pubin, }, { .name = "pubout", .desc = "Output public key instead of private key in output", .type = OPTION_FLAG, - .opt.flag = &ec_config.pubout, + .opt.flag = &cfg.pubout, }, { .name = "text", .desc = "Print the public/private key components and parameters", .type = OPTION_FLAG, - .opt.flag = &ec_config.text, + .opt.flag = &cfg.text, }, { .name = NULL, @@ -267,26 +267,24 @@ ec_main(int argc, char **argv) BIO *in = NULL, *out = NULL; char *passin = NULL, *passout = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&ec_config, 0, sizeof(ec_config)); + memset(&cfg, 0, sizeof(cfg)); - ec_config.asn1_flag = OPENSSL_EC_NAMED_CURVE; - ec_config.form = POINT_CONVERSION_UNCOMPRESSED; - ec_config.informat = FORMAT_PEM; - ec_config.outformat = FORMAT_PEM; + cfg.asn1_flag = OPENSSL_EC_NAMED_CURVE; + cfg.form = POINT_CONVERSION_UNCOMPRESSED; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, ec_options, NULL, NULL) != 0) { ec_usage(); goto end; } - if (!app_passwd(bio_err, ec_config.passargin, ec_config.passargout, + if (!app_passwd(bio_err, cfg.passargin, cfg.passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); goto end; @@ -297,23 +295,23 @@ ec_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (ec_config.infile == NULL) + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, ec_config.infile) <= 0) { - perror(ec_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } BIO_printf(bio_err, "read EC key\n"); - if (ec_config.informat == FORMAT_ASN1) { - if (ec_config.pubin) + if (cfg.informat == FORMAT_ASN1) { + if (cfg.pubin) eckey = d2i_EC_PUBKEY_bio(in, NULL); else eckey = d2i_ECPrivateKey_bio(in, NULL); - } else if (ec_config.informat == FORMAT_PEM) { - if (ec_config.pubin) + } else if (cfg.informat == FORMAT_PEM) { + if (cfg.pubin) eckey = PEM_read_bio_EC_PUBKEY(in, NULL, NULL, NULL); else @@ -328,49 +326,49 @@ ec_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (ec_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, ec_config.outfile) <= 0) { - perror(ec_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } group = EC_KEY_get0_group(eckey); - if (ec_config.new_form) - EC_KEY_set_conv_form(eckey, ec_config.form); + if (cfg.new_form) + EC_KEY_set_conv_form(eckey, cfg.form); - if (ec_config.new_asn1_flag) - EC_KEY_set_asn1_flag(eckey, ec_config.asn1_flag); + if (cfg.new_asn1_flag) + EC_KEY_set_asn1_flag(eckey, cfg.asn1_flag); - if (ec_config.text) + if (cfg.text) if (!EC_KEY_print(out, eckey, 0)) { - perror(ec_config.outfile); + perror(cfg.outfile); ERR_print_errors(bio_err); goto end; } - if (ec_config.noout) { + if (cfg.noout) { ret = 0; goto end; } BIO_printf(bio_err, "writing EC key\n"); - if (ec_config.outformat == FORMAT_ASN1) { - if (ec_config.param_out) + if (cfg.outformat == FORMAT_ASN1) { + if (cfg.param_out) i = i2d_ECPKParameters_bio(out, group); - else if (ec_config.pubin || ec_config.pubout) + else if (cfg.pubin || cfg.pubout) i = i2d_EC_PUBKEY_bio(out, eckey); else i = i2d_ECPrivateKey_bio(out, eckey); - } else if (ec_config.outformat == FORMAT_PEM) { - if (ec_config.param_out) + } else if (cfg.outformat == FORMAT_PEM) { + if (cfg.param_out) i = PEM_write_bio_ECPKParameters(out, group); - else if (ec_config.pubin || ec_config.pubout) + else if (cfg.pubin || cfg.pubout) i = PEM_write_bio_EC_PUBKEY(out, eckey); else i = PEM_write_bio_ECPrivateKey(out, eckey, - ec_config.enc, NULL, 0, NULL, passout); + cfg.enc, NULL, 0, NULL, passout); } else { BIO_printf(bio_err, "bad output format specified for " "outfile\n"); diff --git a/apps/openssl/ecparam.c b/apps/openssl/ecparam.c index 01974a7f..933cd3eb 100644 --- a/apps/openssl/ecparam.c +++ b/apps/openssl/ecparam.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecparam.c,v 1.21 2021/05/10 20:58:32 tb Exp $ */ +/* $OpenBSD: ecparam.c,v 1.23 2023/03/06 14:32:06 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -107,21 +107,21 @@ static struct { char *outfile; int outformat; int text; -} ecparam_config; +} cfg; static int ecparam_opt_form(char *arg) { if (strcmp(arg, "compressed") == 0) - ecparam_config.form = POINT_CONVERSION_COMPRESSED; + cfg.form = POINT_CONVERSION_COMPRESSED; else if (strcmp(arg, "uncompressed") == 0) - ecparam_config.form = POINT_CONVERSION_UNCOMPRESSED; + cfg.form = POINT_CONVERSION_UNCOMPRESSED; else if (strcmp(arg, "hybrid") == 0) - ecparam_config.form = POINT_CONVERSION_HYBRID; + cfg.form = POINT_CONVERSION_HYBRID; else return (1); - ecparam_config.new_form = 1; + cfg.new_form = 1; return (0); } @@ -129,13 +129,13 @@ static int ecparam_opt_enctype(char *arg) { if (strcmp(arg, "explicit") == 0) - ecparam_config.asn1_flag = 0; + cfg.asn1_flag = 0; else if (strcmp(arg, "named_curve") == 0) - ecparam_config.asn1_flag = OPENSSL_EC_NAMED_CURVE; + cfg.asn1_flag = OPENSSL_EC_NAMED_CURVE; else return (1); - ecparam_config.new_asn1_flag = 1; + cfg.new_asn1_flag = 1; return (0); } @@ -144,13 +144,13 @@ static const struct option ecparam_options[] = { .name = "C", .desc = "Convert the EC parameters into C code", .type = OPTION_FLAG, - .opt.flag = &ecparam_config.C, + .opt.flag = &cfg.C, }, { .name = "check", .desc = "Validate the elliptic curve parameters", .type = OPTION_FLAG, - .opt.flag = &ecparam_config.check, + .opt.flag = &cfg.check, }, { .name = "conv_form", @@ -165,61 +165,61 @@ static const struct option ecparam_options[] = { .desc = "Generate an EC private key using the specified " "parameters", .type = OPTION_FLAG, - .opt.flag = &ecparam_config.genkey, + .opt.flag = &cfg.genkey, }, { .name = "in", .argname = "file", .desc = "Input file to read parameters from (default stdin)", .type = OPTION_ARG, - .opt.arg = &ecparam_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM)", .type = OPTION_ARG_FORMAT, - .opt.value = &ecparam_config.informat, + .opt.value = &cfg.informat, }, { .name = "list_curves", .desc = "Print list of all currently implemented EC " "parameter names", .type = OPTION_FLAG, - .opt.flag = &ecparam_config.list_curves, + .opt.flag = &cfg.list_curves, }, { .name = "name", .argname = "curve", .desc = "Use the EC parameters with the specified name", .type = OPTION_ARG, - .opt.arg = &ecparam_config.curve_name, + .opt.arg = &cfg.curve_name, }, { .name = "no_seed", .desc = "Do not output seed with explicit parameter encoding", .type = OPTION_FLAG, - .opt.flag = &ecparam_config.no_seed, + .opt.flag = &cfg.no_seed, }, { .name = "noout", .desc = "Do not output encoded version of EC parameters", .type = OPTION_FLAG, - .opt.flag = &ecparam_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file to write parameters to (default stdout)", .type = OPTION_ARG, - .opt.arg = &ecparam_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM)", .type = OPTION_ARG_FORMAT, - .opt.value = &ecparam_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "param_enc", @@ -233,7 +233,7 @@ static const struct option ecparam_options[] = { .name = "text", .desc = "Print out the EC parameters in human readable form", .type = OPTION_FLAG, - .opt.flag = &ecparam_config.text, + .opt.flag = &cfg.text, }, {NULL}, }; @@ -259,18 +259,16 @@ ecparam_main(int argc, char **argv) BIO *in = NULL, *out = NULL; int i, ret = 1; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&ecparam_config, 0, sizeof(ecparam_config)); - ecparam_config.asn1_flag = OPENSSL_EC_NAMED_CURVE; - ecparam_config.form = POINT_CONVERSION_UNCOMPRESSED; - ecparam_config.informat = FORMAT_PEM; - ecparam_config.outformat = FORMAT_PEM; + memset(&cfg, 0, sizeof(cfg)); + cfg.asn1_flag = OPENSSL_EC_NAMED_CURVE; + cfg.form = POINT_CONVERSION_UNCOMPRESSED; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, ecparam_options, NULL, NULL) != 0) { ecparam_usage(); @@ -283,24 +281,24 @@ ecparam_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (ecparam_config.infile == NULL) + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, ecparam_config.infile) <= 0) { - perror(ecparam_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } - if (ecparam_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, ecparam_config.outfile) <= 0) { - perror(ecparam_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } - if (ecparam_config.list_curves) { + if (cfg.list_curves) { EC_builtin_curve *curves = NULL; size_t crv_len = 0; size_t n = 0; @@ -333,7 +331,7 @@ ecparam_main(int argc, char **argv) ret = 0; goto end; } - if (ecparam_config.curve_name != NULL) { + if (cfg.curve_name != NULL) { int nid; /* @@ -341,36 +339,36 @@ ecparam_main(int argc, char **argv) * secp256r1 (which are the same as the curves prime192v1 and * prime256v1 defined in X9.62) */ - if (!strcmp(ecparam_config.curve_name, "secp192r1")) { + if (!strcmp(cfg.curve_name, "secp192r1")) { BIO_printf(bio_err, "using curve name prime192v1 " "instead of secp192r1\n"); nid = NID_X9_62_prime192v1; - } else if (!strcmp(ecparam_config.curve_name, "secp256r1")) { + } else if (!strcmp(cfg.curve_name, "secp256r1")) { BIO_printf(bio_err, "using curve name prime256v1 " "instead of secp256r1\n"); nid = NID_X9_62_prime256v1; } else - nid = OBJ_sn2nid(ecparam_config.curve_name); + nid = OBJ_sn2nid(cfg.curve_name); if (nid == 0) - nid = EC_curve_nist2nid(ecparam_config.curve_name); + nid = EC_curve_nist2nid(cfg.curve_name); if (nid == 0) { BIO_printf(bio_err, "unknown curve name (%s)\n", - ecparam_config.curve_name); + cfg.curve_name); goto end; } group = EC_GROUP_new_by_curve_name(nid); if (group == NULL) { BIO_printf(bio_err, "unable to create curve (%s)\n", - ecparam_config.curve_name); + cfg.curve_name); goto end; } - EC_GROUP_set_asn1_flag(group, ecparam_config.asn1_flag); - EC_GROUP_set_point_conversion_form(group, ecparam_config.form); - } else if (ecparam_config.informat == FORMAT_ASN1) { + EC_GROUP_set_asn1_flag(group, cfg.asn1_flag); + EC_GROUP_set_point_conversion_form(group, cfg.form); + } else if (cfg.informat == FORMAT_ASN1) { group = d2i_ECPKParameters_bio(in, NULL); - } else if (ecparam_config.informat == FORMAT_PEM) { + } else if (cfg.informat == FORMAT_PEM) { group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL); } else { BIO_printf(bio_err, "bad input format specified\n"); @@ -383,20 +381,20 @@ ecparam_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (ecparam_config.new_form) - EC_GROUP_set_point_conversion_form(group, ecparam_config.form); + if (cfg.new_form) + EC_GROUP_set_point_conversion_form(group, cfg.form); - if (ecparam_config.new_asn1_flag) - EC_GROUP_set_asn1_flag(group, ecparam_config.asn1_flag); + if (cfg.new_asn1_flag) + EC_GROUP_set_asn1_flag(group, cfg.asn1_flag); - if (ecparam_config.no_seed) + if (cfg.no_seed) EC_GROUP_set_seed(group, NULL, 0); - if (ecparam_config.text) { + if (cfg.text) { if (!ECPKParameters_print(out, group, 0)) goto end; } - if (ecparam_config.check) { + if (cfg.check) { BIO_printf(bio_err, "checking elliptic curve parameters: "); if (!EC_GROUP_check(group, NULL)) { BIO_printf(bio_err, "failed\n"); @@ -405,7 +403,7 @@ ecparam_main(int argc, char **argv) BIO_printf(bio_err, "ok\n"); } - if (ecparam_config.C) { + if (cfg.C) { size_t buf_len = 0, tmp_len = 0; const EC_POINT *point; int is_prime, len = 0; @@ -518,10 +516,10 @@ ecparam_main(int argc, char **argv) BIO_printf(out, "\t\t}\n"); BIO_printf(out, "\treturn(group);\n\t}\n"); } - if (!ecparam_config.noout) { - if (ecparam_config.outformat == FORMAT_ASN1) + if (!cfg.noout) { + if (cfg.outformat == FORMAT_ASN1) i = i2d_ECPKParameters_bio(out, group); - else if (ecparam_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_ECPKParameters(out, group); else { BIO_printf(bio_err, "bad output format specified for" @@ -535,7 +533,7 @@ ecparam_main(int argc, char **argv) goto end; } } - if (ecparam_config.genkey) { + if (cfg.genkey) { EC_KEY *eckey = EC_KEY_new(); if (eckey == NULL) @@ -550,9 +548,9 @@ ecparam_main(int argc, char **argv) EC_KEY_free(eckey); goto end; } - if (ecparam_config.outformat == FORMAT_ASN1) + if (cfg.outformat == FORMAT_ASN1) i = i2d_ECPrivateKey_bio(out, eckey); - else if (ecparam_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_ECPrivateKey(out, eckey, NULL, NULL, 0, NULL, NULL); else { diff --git a/apps/openssl/enc.c b/apps/openssl/enc.c index 7955d9b9..b80a177c 100644 --- a/apps/openssl/enc.c +++ b/apps/openssl/enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enc.c,v 1.24 2021/12/07 20:13:15 tb Exp $ */ +/* $OpenBSD: enc.c,v 1.27 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -100,7 +100,7 @@ static struct { int pbkdf2; int printkey; int verbose; -} enc_config; +} cfg; static int enc_opt_cipher(int argc, char **argv, int *argsused) @@ -111,12 +111,12 @@ enc_opt_cipher(int argc, char **argv, int *argsused) return (1); if (strcmp(name, "none") == 0) { - enc_config.cipher = NULL; + cfg.cipher = NULL; *argsused = 1; return (0); } - if ((enc_config.cipher = EVP_get_cipherbyname(name)) != NULL) { + if ((cfg.cipher = EVP_get_cipherbyname(name)) != NULL) { *argsused = 1; return (0); } @@ -129,44 +129,44 @@ static const struct option enc_options[] = { .name = "A", .desc = "Process base64 data on one line (requires -a)", .type = OPTION_FLAG, - .opt.flag = &enc_config.olb64, + .opt.flag = &cfg.olb64, }, { .name = "a", .desc = "Perform base64 encoding/decoding (alias -base64)", .type = OPTION_FLAG, - .opt.flag = &enc_config.base64, + .opt.flag = &cfg.base64, }, { .name = "base64", .type = OPTION_FLAG, - .opt.flag = &enc_config.base64, + .opt.flag = &cfg.base64, }, { .name = "bufsize", .argname = "size", .desc = "Specify the buffer size to use for I/O", .type = OPTION_ARG, - .opt.arg = &enc_config.bufsize, + .opt.arg = &cfg.bufsize, }, { .name = "d", .desc = "Decrypt the input data", .type = OPTION_VALUE, - .opt.value = &enc_config.enc, + .opt.value = &cfg.enc, .value = 0, }, { .name = "debug", .desc = "Print debugging information", .type = OPTION_FLAG, - .opt.flag = &enc_config.debug, + .opt.flag = &cfg.debug, }, { .name = "e", .desc = "Encrypt the input data (default)", .type = OPTION_VALUE, - .opt.value = &enc_config.enc, + .opt.value = &cfg.enc, .value = 1, }, { @@ -174,45 +174,45 @@ static const struct option enc_options[] = { .argname = "file", .desc = "Input file to read from (default stdin)", .type = OPTION_ARG, - .opt.arg = &enc_config.inf, + .opt.arg = &cfg.inf, }, { .name = "iter", .argname = "iterations", .desc = "Specify iteration count and force use of PBKDF2", .type = OPTION_ARG_INT, - .opt.value = &enc_config.iter, + .opt.value = &cfg.iter, }, { .name = "iv", .argname = "IV", .desc = "IV to use, specified as a hexadecimal string", .type = OPTION_ARG, - .opt.arg = &enc_config.hiv, + .opt.arg = &cfg.hiv, }, { .name = "K", .argname = "key", .desc = "Key to use, specified as a hexadecimal string", .type = OPTION_ARG, - .opt.arg = &enc_config.hkey, + .opt.arg = &cfg.hkey, }, { .name = "k", /* Superseded by -pass. */ .type = OPTION_ARG, - .opt.arg = &enc_config.keystr, + .opt.arg = &cfg.keystr, }, { .name = "kfile", /* Superseded by -pass. */ .type = OPTION_ARG, - .opt.arg = &enc_config.keyfile, + .opt.arg = &cfg.keyfile, }, { .name = "md", .argname = "digest", .desc = "Digest to use to create a key from the passphrase", .type = OPTION_ARG, - .opt.arg = &enc_config.md, + .opt.arg = &cfg.md, }, { .name = "none", @@ -224,12 +224,12 @@ static const struct option enc_options[] = { .name = "nopad", .desc = "Disable standard block padding", .type = OPTION_FLAG, - .opt.flag = &enc_config.nopad, + .opt.flag = &cfg.nopad, }, { .name = "nosalt", .type = OPTION_VALUE, - .opt.value = &enc_config.nosalt, + .opt.value = &cfg.nosalt, .value = 1, }, { @@ -237,21 +237,21 @@ static const struct option enc_options[] = { .argname = "file", .desc = "Output file to write to (default stdout)", .type = OPTION_ARG, - .opt.arg = &enc_config.outf, + .opt.arg = &cfg.outf, }, { .name = "P", .desc = "Print out the salt, key and IV used, then exit\n" " (no encryption or decryption is performed)", .type = OPTION_VALUE, - .opt.value = &enc_config.printkey, + .opt.value = &cfg.printkey, .value = 2, }, { .name = "p", .desc = "Print out the salt, key and IV used", .type = OPTION_VALUE, - .opt.value = &enc_config.printkey, + .opt.value = &cfg.printkey, .value = 1, }, { @@ -259,40 +259,40 @@ static const struct option enc_options[] = { .argname = "source", .desc = "Password source", .type = OPTION_ARG, - .opt.arg = &enc_config.passarg, + .opt.arg = &cfg.passarg, }, { .name = "pbkdf2", .desc = "Use the pbkdf2 key derivation function", .type = OPTION_FLAG, - .opt.flag = &enc_config.pbkdf2, + .opt.flag = &cfg.pbkdf2, }, { .name = "S", .argname = "salt", .desc = "Salt to use, specified as a hexadecimal string", .type = OPTION_ARG, - .opt.arg = &enc_config.hsalt, + .opt.arg = &cfg.hsalt, }, { .name = "salt", .desc = "Use a salt in the key derivation routines (default)", .type = OPTION_VALUE, - .opt.value = &enc_config.nosalt, + .opt.value = &cfg.nosalt, .value = 0, }, { .name = "v", .desc = "Verbose", .type = OPTION_FLAG, - .opt.flag = &enc_config.verbose, + .opt.flag = &cfg.verbose, }, #ifdef ZLIB { .name = "z", .desc = "Perform zlib compression/decompression", .type = OPTION_FLAG, - .opt.flag = &enc_config.do_zlib, + .opt.flag = &cfg.do_zlib, }, #endif { @@ -303,6 +303,22 @@ static const struct option enc_options[] = { { NULL }, }; +static void +skip_aead_and_xts(const OBJ_NAME *name, void *arg) +{ + const EVP_CIPHER *cipher; + + if ((cipher = EVP_get_cipherbyname(name->name)) == NULL) + return; + + if ((EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) != 0) + return; + if (EVP_CIPHER_mode(cipher) == EVP_CIPH_XTS_MODE) + return; + + show_cipher(name, arg); +} + static void enc_usage(void) { @@ -318,7 +334,7 @@ enc_usage(void) fprintf(stderr, "\n"); fprintf(stderr, "Valid ciphername values:\n\n"); - OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, show_cipher, &n); + OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, skip_aead_and_xts, &n); fprintf(stderr, "\n"); } @@ -344,34 +360,32 @@ enc_main(int argc, char **argv) char pname[PROG_NAME_SIZE + 1]; int i; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&enc_config, 0, sizeof(enc_config)); - enc_config.enc = 1; + memset(&cfg, 0, sizeof(cfg)); + cfg.enc = 1; /* first check the program name */ program_name(argv[0], pname, sizeof(pname)); if (strcmp(pname, "base64") == 0) - enc_config.base64 = 1; + cfg.base64 = 1; #ifdef ZLIB if (strcmp(pname, "zlib") == 0) - enc_config.do_zlib = 1; + cfg.do_zlib = 1; #endif - enc_config.cipher = EVP_get_cipherbyname(pname); + cfg.cipher = EVP_get_cipherbyname(pname); #ifdef ZLIB - if (!enc_config.do_zlib && !enc_config.base64 && - enc_config.cipher == NULL && strcmp(pname, "enc") != 0) + if (!cfg.do_zlib && !cfg.base64 && + cfg.cipher == NULL && strcmp(pname, "enc") != 0) #else - if (!enc_config.base64 && enc_config.cipher == NULL && + if (!cfg.base64 && cfg.cipher == NULL && strcmp(pname, "enc") != 0) #endif { @@ -384,20 +398,20 @@ enc_main(int argc, char **argv) goto end; } - if (enc_config.keyfile != NULL) { + if (cfg.keyfile != NULL) { static char buf[128]; FILE *infile; - infile = fopen(enc_config.keyfile, "r"); + infile = fopen(cfg.keyfile, "r"); if (infile == NULL) { BIO_printf(bio_err, "unable to read key from '%s'\n", - enc_config.keyfile); + cfg.keyfile); goto end; } buf[0] = '\0'; if (!fgets(buf, sizeof buf, infile)) { BIO_printf(bio_err, "unable to read key from '%s'\n", - enc_config.keyfile); + cfg.keyfile); fclose(infile); goto end; } @@ -411,22 +425,34 @@ enc_main(int argc, char **argv) BIO_printf(bio_err, "zero length password\n"); goto end; } - enc_config.keystr = buf; + cfg.keystr = buf; + } + + if (cfg.cipher != NULL && + (EVP_CIPHER_flags(cfg.cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) != 0) { + BIO_printf(bio_err, "enc does not support AEAD ciphers\n"); + goto end; + } + + if (cfg.cipher != NULL && + EVP_CIPHER_mode(cfg.cipher) == EVP_CIPH_XTS_MODE) { + BIO_printf(bio_err, "enc does not support XTS mode\n"); + goto end; } - if (enc_config.md != NULL && - (dgst = EVP_get_digestbyname(enc_config.md)) == NULL) { + if (cfg.md != NULL && + (dgst = EVP_get_digestbyname(cfg.md)) == NULL) { BIO_printf(bio_err, "%s is an unsupported message digest type\n", - enc_config.md); + cfg.md); goto end; } if (dgst == NULL) { dgst = EVP_sha256(); } - if (enc_config.bufsize != NULL) { - char *p = enc_config.bufsize; + if (cfg.bufsize != NULL) { + char *p = cfg.bufsize; unsigned long n; /* XXX - provide an OPTION_ARG_DISKUNIT. */ @@ -445,11 +471,11 @@ enc_main(int argc, char **argv) goto end; } /* It must be large enough for a base64 encoded line. */ - if (enc_config.base64 && n < 80) + if (cfg.base64 && n < 80) n = 80; bsize = (int)n; - if (enc_config.verbose) + if (cfg.verbose) BIO_printf(bio_err, "bufsize=%d\n", bsize); } strbuf = malloc(SIZE); @@ -464,41 +490,41 @@ enc_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (enc_config.debug) { + if (cfg.debug) { BIO_set_callback(in, BIO_debug_callback); BIO_set_callback(out, BIO_debug_callback); BIO_set_callback_arg(in, (char *) bio_err); BIO_set_callback_arg(out, (char *) bio_err); } - if (enc_config.inf == NULL) { - if (enc_config.bufsize != NULL) + if (cfg.inf == NULL) { + if (cfg.bufsize != NULL) setvbuf(stdin, (char *) NULL, _IONBF, 0); BIO_set_fp(in, stdin, BIO_NOCLOSE); } else { - if (BIO_read_filename(in, enc_config.inf) <= 0) { - perror(enc_config.inf); + if (BIO_read_filename(in, cfg.inf) <= 0) { + perror(cfg.inf); goto end; } } - if (!enc_config.keystr && enc_config.passarg) { - if (!app_passwd(bio_err, enc_config.passarg, NULL, + if (!cfg.keystr && cfg.passarg) { + if (!app_passwd(bio_err, cfg.passarg, NULL, &pass, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } - enc_config.keystr = pass; + cfg.keystr = pass; } - if (enc_config.keystr == NULL && enc_config.cipher != NULL && - enc_config.hkey == NULL) { + if (cfg.keystr == NULL && cfg.cipher != NULL && + cfg.hkey == NULL) { for (;;) { char buf[200]; int retval; retval = snprintf(buf, sizeof buf, "enter %s %s password:", - OBJ_nid2ln(EVP_CIPHER_nid(enc_config.cipher)), - enc_config.enc ? "encryption" : "decryption"); + OBJ_nid2ln(EVP_CIPHER_nid(cfg.cipher)), + cfg.enc ? "encryption" : "decryption"); if ((size_t)retval >= sizeof buf) { BIO_printf(bio_err, "Password prompt too long\n"); @@ -506,13 +532,13 @@ enc_main(int argc, char **argv) } strbuf[0] = '\0'; i = EVP_read_pw_string((char *)strbuf, SIZE, buf, - enc_config.enc); + cfg.enc); if (i == 0) { if (strbuf[0] == '\0') { ret = 1; goto end; } - enc_config.keystr = strbuf; + cfg.keystr = strbuf; break; } if (i < 0) { @@ -521,13 +547,13 @@ enc_main(int argc, char **argv) } } } - if (enc_config.outf == NULL) { + if (cfg.outf == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); - if (enc_config.bufsize != NULL) + if (cfg.bufsize != NULL) setvbuf(stdout, (char *)NULL, _IONBF, 0); } else { - if (BIO_write_filename(out, enc_config.outf) <= 0) { - perror(enc_config.outf); + if (BIO_write_filename(out, cfg.outf) <= 0) { + perror(cfg.outf); goto end; } } @@ -546,38 +572,38 @@ enc_main(int argc, char **argv) } #endif - if (enc_config.base64) { + if (cfg.base64) { if ((b64 = BIO_new(BIO_f_base64())) == NULL) goto end; - if (enc_config.debug) { + if (cfg.debug) { BIO_set_callback(b64, BIO_debug_callback); BIO_set_callback_arg(b64, (char *) bio_err); } - if (enc_config.olb64) + if (cfg.olb64) BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); - if (enc_config.enc) + if (cfg.enc) wbio = BIO_push(b64, wbio); else rbio = BIO_push(b64, rbio); } - if (enc_config.cipher != NULL) { + if (cfg.cipher != NULL) { /* * Note that keystr is NULL if a key was passed on the command * line, so we get no salt in that case. Is this a bug? */ - if (enc_config.keystr != NULL) { + if (cfg.keystr != NULL) { /* * Salt handling: if encrypting generate a salt and * write to output BIO. If decrypting read salt from * input BIO. */ unsigned char *sptr; - if (enc_config.nosalt) + if (cfg.nosalt) sptr = NULL; else { - if (enc_config.enc) { - if (enc_config.hsalt) { - if (!set_hex(enc_config.hsalt, salt, sizeof salt)) { + if (cfg.enc) { + if (cfg.hsalt) { + if (!set_hex(cfg.hsalt, salt, sizeof salt)) { BIO_printf(bio_err, "invalid hex salt value\n"); goto end; @@ -589,7 +615,7 @@ enc_main(int argc, char **argv) * If -P option then don't bother * writing */ - if ((enc_config.printkey != 2) + if ((cfg.printkey != 2) && (BIO_write(wbio, magic, sizeof magic - 1) != sizeof magic - 1 || BIO_write(wbio, @@ -610,23 +636,23 @@ enc_main(int argc, char **argv) } sptr = salt; } - if (enc_config.pbkdf2 == 1 || enc_config.iter > 0) { + if (cfg.pbkdf2 == 1 || cfg.iter > 0) { /* * derive key and default iv * concatenated into a temporary buffer */ unsigned char tmpkeyiv[EVP_MAX_KEY_LENGTH + EVP_MAX_IV_LENGTH]; - int iklen = EVP_CIPHER_key_length(enc_config.cipher); - int ivlen = EVP_CIPHER_iv_length(enc_config.cipher); + int iklen = EVP_CIPHER_key_length(cfg.cipher); + int ivlen = EVP_CIPHER_iv_length(cfg.cipher); /* not needed if HASH_UPDATE() is fixed : */ int islen = (sptr != NULL ? sizeof(salt) : 0); - if (enc_config.iter == 0) - enc_config.iter = 10000; + if (cfg.iter == 0) + cfg.iter = 10000; - if (!PKCS5_PBKDF2_HMAC(enc_config.keystr, - strlen(enc_config.keystr), sptr, islen, - enc_config.iter, dgst, iklen+ivlen, tmpkeyiv)) { + if (!PKCS5_PBKDF2_HMAC(cfg.keystr, + strlen(cfg.keystr), sptr, islen, + cfg.iter, dgst, iklen+ivlen, tmpkeyiv)) { BIO_printf(bio_err, "PKCS5_PBKDF2_HMAC failed\n"); goto end; } @@ -635,9 +661,9 @@ enc_main(int argc, char **argv) memcpy(iv, tmpkeyiv + iklen, ivlen); explicit_bzero(tmpkeyiv, sizeof tmpkeyiv); } else { - EVP_BytesToKey(enc_config.cipher, dgst, sptr, - (unsigned char *)enc_config.keystr, - strlen(enc_config.keystr), 1, key, iv); + EVP_BytesToKey(cfg.cipher, dgst, sptr, + (unsigned char *)cfg.keystr, + strlen(cfg.keystr), 1, key, iv); } /* @@ -645,19 +671,19 @@ enc_main(int argc, char **argv) * the command line bug picked up by Larry J. Hughes * Jr. */ - if (enc_config.keystr == strbuf) - explicit_bzero(enc_config.keystr, SIZE); + if (cfg.keystr == strbuf) + explicit_bzero(cfg.keystr, SIZE); else - explicit_bzero(enc_config.keystr, - strlen(enc_config.keystr)); + explicit_bzero(cfg.keystr, + strlen(cfg.keystr)); } - if (enc_config.hiv != NULL && - !set_hex(enc_config.hiv, iv, sizeof iv)) { + if (cfg.hiv != NULL && + !set_hex(cfg.hiv, iv, sizeof iv)) { BIO_printf(bio_err, "invalid hex iv value\n"); goto end; } - if (enc_config.hiv == NULL && enc_config.keystr == NULL && - EVP_CIPHER_iv_length(enc_config.cipher) != 0) { + if (cfg.hiv == NULL && cfg.keystr == NULL && + EVP_CIPHER_iv_length(cfg.cipher) != 0) { /* * No IV was explicitly set and no IV was generated * during EVP_BytesToKey. Hence the IV is undefined, @@ -666,8 +692,8 @@ enc_main(int argc, char **argv) BIO_printf(bio_err, "iv undefined\n"); goto end; } - if (enc_config.hkey != NULL && - !set_hex(enc_config.hkey, key, sizeof key)) { + if (cfg.hkey != NULL && + !set_hex(cfg.hkey, key, sizeof key)) { BIO_printf(bio_err, "invalid hex key value\n"); goto end; } @@ -681,51 +707,51 @@ enc_main(int argc, char **argv) BIO_get_cipher_ctx(benc, &ctx); - if (!EVP_CipherInit_ex(ctx, enc_config.cipher, NULL, NULL, - NULL, enc_config.enc)) { + if (!EVP_CipherInit_ex(ctx, cfg.cipher, NULL, NULL, + NULL, cfg.enc)) { BIO_printf(bio_err, "Error setting cipher %s\n", - EVP_CIPHER_name(enc_config.cipher)); + EVP_CIPHER_name(cfg.cipher)); ERR_print_errors(bio_err); goto end; } - if (enc_config.nopad) + if (cfg.nopad) EVP_CIPHER_CTX_set_padding(ctx, 0); if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, - enc_config.enc)) { + cfg.enc)) { BIO_printf(bio_err, "Error setting cipher %s\n", - EVP_CIPHER_name(enc_config.cipher)); + EVP_CIPHER_name(cfg.cipher)); ERR_print_errors(bio_err); goto end; } - if (enc_config.debug) { + if (cfg.debug) { BIO_set_callback(benc, BIO_debug_callback); BIO_set_callback_arg(benc, (char *) bio_err); } - if (enc_config.printkey) { + if (cfg.printkey) { int key_len, iv_len; - if (!enc_config.nosalt) { + if (!cfg.nosalt) { printf("salt="); for (i = 0; i < (int) sizeof(salt); i++) printf("%02X", salt[i]); printf("\n"); } - key_len = EVP_CIPHER_key_length(enc_config.cipher); + key_len = EVP_CIPHER_key_length(cfg.cipher); if (key_len > 0) { printf("key="); for (i = 0; i < key_len; i++) printf("%02X", key[i]); printf("\n"); } - iv_len = EVP_CIPHER_iv_length(enc_config.cipher); + iv_len = EVP_CIPHER_iv_length(cfg.cipher); if (iv_len > 0) { printf("iv ="); for (i = 0; i < iv_len; i++) printf("%02X", iv[i]); printf("\n"); } - if (enc_config.printkey == 2) { + if (cfg.printkey == 2) { ret = 0; goto end; } @@ -749,7 +775,7 @@ enc_main(int argc, char **argv) goto end; } ret = 0; - if (enc_config.verbose) { + if (cfg.verbose) { BIO_printf(bio_err, "bytes read :%8ld\n", BIO_number_read(in)); BIO_printf(bio_err, "bytes written:%8ld\n", BIO_number_written(out)); } diff --git a/apps/openssl/errstr.c b/apps/openssl/errstr.c index bb6bfc78..cb7cf1d5 100644 --- a/apps/openssl/errstr.c +++ b/apps/openssl/errstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: errstr.c,v 1.7 2019/07/14 03:30:45 guenther Exp $ */ +/* $OpenBSD: errstr.c,v 1.10 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -68,16 +68,16 @@ #include #include -struct { +static struct { int stats; -} errstr_config; +} cfg; static const struct option errstr_options[] = { { .name = "stats", .desc = "Print debugging statistics for the hash table", .type = OPTION_FLAG, - .opt.flag = &errstr_config.stats, + .opt.flag = &cfg.stats, }, { NULL }, }; @@ -98,21 +98,19 @@ errstr_main(int argc, char **argv) char buf[256]; int ret = 0; - if (single_execution) { - if (pledge("stdio rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&errstr_config, 0, sizeof(errstr_config)); + memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, errstr_options, NULL, &argsused) != 0) { errstr_usage(); return (1); } - if (errstr_config.stats) { + if (cfg.stats) { BIO *out; if ((out = BIO_new_fp(stdout, BIO_NOCLOSE)) == NULL) { diff --git a/apps/openssl/gendh.c b/apps/openssl/gendh.c index c6564e04..b9dde3c7 100644 --- a/apps/openssl/gendh.c +++ b/apps/openssl/gendh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gendh.c,v 1.12 2021/11/20 18:10:48 tb Exp $ */ +/* $OpenBSD: gendh.c,v 1.14 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -89,7 +89,7 @@ static int dh_cb(int p, int n, BN_GENCB *cb); static struct { int g; char *outfile; -} gendh_config; +} cfg; static const struct option gendh_options[] = { { @@ -98,21 +98,21 @@ static const struct option gendh_options[] = { "(default)", .type = OPTION_VALUE, .value = 2, - .opt.value = &gendh_config.g, + .opt.value = &cfg.g, }, { .name = "5", .desc = "Generate DH parameters with a generator value of 5", .type = OPTION_VALUE, .value = 5, - .opt.value = &gendh_config.g, + .opt.value = &cfg.g, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &gendh_config.outfile, + .opt.arg = &cfg.outfile, }, { NULL }, }; @@ -134,11 +134,9 @@ gendh_main(int argc, char **argv) BIO *out = NULL; char *strbits = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } if ((cb = BN_GENCB_new()) == NULL) { @@ -148,9 +146,9 @@ gendh_main(int argc, char **argv) BN_GENCB_set(cb, dh_cb, bio_err); - memset(&gendh_config, 0, sizeof(gendh_config)); + memset(&cfg, 0, sizeof(cfg)); - gendh_config.g = 2; + cfg.g = 2; if (options_parse(argc, argv, gendh_options, &strbits, NULL) != 0) { gendh_usage(); @@ -171,21 +169,21 @@ gendh_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (gendh_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, gendh_config.outfile) <= 0) { - perror(gendh_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime," - " generator %d\n", numbits, gendh_config.g); + " generator %d\n", numbits, cfg.g); BIO_printf(bio_err, "This is going to take a long time\n"); if (((dh = DH_new()) == NULL) || - !DH_generate_parameters_ex(dh, numbits, gendh_config.g, cb)) + !DH_generate_parameters_ex(dh, numbits, cfg.g, cb)) goto end; if (!PEM_write_bio_DHparams(out, dh)) diff --git a/apps/openssl/gendsa.c b/apps/openssl/gendsa.c index 6d69957e..00635c45 100644 --- a/apps/openssl/gendsa.c +++ b/apps/openssl/gendsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gendsa.c,v 1.15 2022/01/14 09:25:00 tb Exp $ */ +/* $OpenBSD: gendsa.c,v 1.17 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -78,7 +78,7 @@ static struct { const EVP_CIPHER *enc; char *outfile; char *passargout; -} gendsa_config; +} cfg; static const EVP_CIPHER *get_cipher_by_name(char *name) { @@ -122,7 +122,7 @@ set_enc(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((gendsa_config.enc = get_cipher_by_name(name)) == NULL) + if ((cfg.enc = get_cipher_by_name(name)) == NULL) return (1); *argsused = 1; @@ -197,14 +197,14 @@ static const struct option gendsa_options[] = { .argname = "file", .desc = "Output the key to 'file'", .type = OPTION_ARG, - .opt.arg = &gendsa_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "passout", .argname = "src", .desc = "Output file passphrase source", .type = OPTION_ARG, - .opt.arg = &gendsa_config.passargout, + .opt.arg = &cfg.passargout, }, { NULL }, }; @@ -229,14 +229,12 @@ gendsa_main(int argc, char **argv) char *passout = NULL; BIO *out = NULL, *in = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&gendsa_config, 0, sizeof(gendsa_config)); + memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, gendsa_options, &dsaparams, NULL) != 0) { gendsa_usage(); @@ -247,7 +245,7 @@ gendsa_main(int argc, char **argv) gendsa_usage(); goto end; } - if (!app_passwd(bio_err, NULL, gendsa_config.passargout, NULL, + if (!app_passwd(bio_err, NULL, cfg.passargout, NULL, &passout)) { BIO_printf(bio_err, "Error getting password\n"); goto end; @@ -268,11 +266,11 @@ gendsa_main(int argc, char **argv) if (out == NULL) goto end; - if (gendsa_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, gendsa_config.outfile) <= 0) { - perror(gendsa_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } @@ -282,7 +280,7 @@ gendsa_main(int argc, char **argv) if (!DSA_generate_key(dsa)) goto end; - if (!PEM_write_bio_DSAPrivateKey(out, dsa, gendsa_config.enc, NULL, 0, + if (!PEM_write_bio_DSAPrivateKey(out, dsa, cfg.enc, NULL, 0, NULL, passout)) goto end; ret = 0; diff --git a/apps/openssl/genpkey.c b/apps/openssl/genpkey.c index e2b46b77..e2445c14 100644 --- a/apps/openssl/genpkey.c +++ b/apps/openssl/genpkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: genpkey.c,v 1.13 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: genpkey.c,v 1.16 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006 */ @@ -68,7 +68,7 @@ static int init_keygen_file(BIO * err, EVP_PKEY_CTX **pctx, const char *file); static int genpkey_cb(EVP_PKEY_CTX * ctx); -struct { +static struct { const EVP_CIPHER *cipher; EVP_PKEY_CTX **ctx; int do_param; @@ -76,13 +76,13 @@ struct { int outformat; char *passarg; int text; -} genpkey_config; +} cfg; static int genpkey_opt_algorithm(char *arg) { - if (!init_gen_str(bio_err, genpkey_config.ctx, arg, - genpkey_config.do_param)) + if (!init_gen_str(bio_err, cfg.ctx, arg, + cfg.do_param)) return (1); return (0); @@ -96,16 +96,16 @@ genpkey_opt_cipher(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if (genpkey_config.do_param == 1) + if (cfg.do_param == 1) return (1); if (strcmp(name, "none") == 0) { - genpkey_config.cipher = NULL; + cfg.cipher = NULL; *argsused = 1; return (0); } - if ((genpkey_config.cipher = EVP_get_cipherbyname(name)) != NULL) { + if ((cfg.cipher = EVP_get_cipherbyname(name)) != NULL) { *argsused = 1; return (0); } @@ -116,9 +116,9 @@ genpkey_opt_cipher(int argc, char **argv, int *argsused) static int genpkey_opt_paramfile(char *arg) { - if (genpkey_config.do_param == 1) + if (cfg.do_param == 1) return (1); - if (!init_keygen_file(bio_err, genpkey_config.ctx, arg)) + if (!init_keygen_file(bio_err, cfg.ctx, arg)) return (1); return (0); @@ -127,12 +127,12 @@ genpkey_opt_paramfile(char *arg) static int genpkey_opt_pkeyopt(char *arg) { - if (*genpkey_config.ctx == NULL) { + if (*cfg.ctx == NULL) { BIO_puts(bio_err, "No keytype specified\n"); return (1); } - if (pkey_ctrl_string(*genpkey_config.ctx, arg) <= 0) { + if (pkey_ctrl_string(*cfg.ctx, arg) <= 0) { BIO_puts(bio_err, "parameter setting error\n"); ERR_print_errors(bio_err); return (1); @@ -153,21 +153,21 @@ static const struct option genpkey_options[] = { .name = "genparam", .desc = "Generate a set of parameters instead of a private key", .type = OPTION_FLAG, - .opt.flag = &genpkey_config.do_param, + .opt.flag = &cfg.do_param, }, { .name = "out", .argname = "file", .desc = "Output file to write to (default stdout)", .type = OPTION_ARG, - .opt.arg = &genpkey_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM)", .type = OPTION_ARG_FORMAT, - .opt.value = &genpkey_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "paramfile", @@ -182,7 +182,7 @@ static const struct option genpkey_options[] = { .argname = "arg", .desc = "Output file password source", .type = OPTION_ARG, - .opt.arg = &genpkey_config.passarg, + .opt.arg = &cfg.passarg, }, { .name = "pkeyopt", @@ -195,7 +195,7 @@ static const struct option genpkey_options[] = { .name = "text", .desc = "Print the private/public key in human readable form", .type = OPTION_FLAG, - .opt.flag = &genpkey_config.text, + .opt.flag = &cfg.text, }, { .name = NULL, @@ -224,16 +224,14 @@ genpkey_main(int argc, char **argv) char *pass = NULL; int ret = 1, rv; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&genpkey_config, 0, sizeof(genpkey_config)); - genpkey_config.ctx = &ctx; - genpkey_config.outformat = FORMAT_PEM; + memset(&cfg, 0, sizeof(cfg)); + cfg.ctx = &ctx; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, genpkey_options, NULL, NULL) != 0) { genpkey_usage(); @@ -245,15 +243,15 @@ genpkey_main(int argc, char **argv) goto end; } - if (!app_passwd(bio_err, genpkey_config.passarg, NULL, &pass, NULL)) { + if (!app_passwd(bio_err, cfg.passarg, NULL, &pass, NULL)) { BIO_puts(bio_err, "Error getting password\n"); goto end; } - if (genpkey_config.outfile != NULL) { - if ((out = BIO_new_file(genpkey_config.outfile, "wb")) == + if (cfg.outfile != NULL) { + if ((out = BIO_new_file(cfg.outfile, "wb")) == NULL) { BIO_printf(bio_err, "Can't open output file %s\n", - genpkey_config.outfile); + cfg.outfile); goto end; } } else { @@ -263,7 +261,7 @@ genpkey_main(int argc, char **argv) EVP_PKEY_CTX_set_cb(ctx, genpkey_cb); EVP_PKEY_CTX_set_app_data(ctx, bio_err); - if (genpkey_config.do_param) { + if (cfg.do_param) { if (EVP_PKEY_paramgen(ctx, &pkey) <= 0) { BIO_puts(bio_err, "Error generating parameters\n"); ERR_print_errors(bio_err); @@ -277,12 +275,12 @@ genpkey_main(int argc, char **argv) } } - if (genpkey_config.do_param) + if (cfg.do_param) rv = PEM_write_bio_Parameters(out, pkey); - else if (genpkey_config.outformat == FORMAT_PEM) - rv = PEM_write_bio_PrivateKey(out, pkey, genpkey_config.cipher, + else if (cfg.outformat == FORMAT_PEM) + rv = PEM_write_bio_PrivateKey(out, pkey, cfg.cipher, NULL, 0, NULL, pass); - else if (genpkey_config.outformat == FORMAT_ASN1) + else if (cfg.outformat == FORMAT_ASN1) rv = i2d_PrivateKey_bio(out, pkey); else { BIO_printf(bio_err, "Bad format specified for key\n"); @@ -293,8 +291,8 @@ genpkey_main(int argc, char **argv) BIO_puts(bio_err, "Error writing key\n"); ERR_print_errors(bio_err); } - if (genpkey_config.text) { - if (genpkey_config.do_param) + if (cfg.text) { + if (cfg.do_param) rv = EVP_PKEY_print_params(out, pkey, 0, NULL); else rv = EVP_PKEY_print_private(out, pkey, 0, NULL); diff --git a/apps/openssl/genrsa.c b/apps/openssl/genrsa.c index a199ba2e..0b5323fa 100644 --- a/apps/openssl/genrsa.c +++ b/apps/openssl/genrsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: genrsa.c,v 1.19 2022/01/14 09:25:42 tb Exp $ */ +/* $OpenBSD: genrsa.c,v 1.22 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -90,7 +90,7 @@ static struct { unsigned long f4; char *outfile; char *passargout; -} genrsa_config; +} cfg; static int set_public_exponent(int argc, char **argv, int *argsused) @@ -98,9 +98,9 @@ set_public_exponent(int argc, char **argv, int *argsused) char *option = argv[0]; if (strcmp(option, "-3") == 0) - genrsa_config.f4 = 3; + cfg.f4 = 3; else if (strcmp(option, "-f4") == 0 || strcmp(option, "-F4") == 0) - genrsa_config.f4 = RSA_F4; + cfg.f4 = RSA_F4; else return (1); @@ -150,7 +150,7 @@ set_enc(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((genrsa_config.enc = get_cipher_by_name(name)) == NULL) + if ((cfg.enc = get_cipher_by_name(name)) == NULL) return (1); *argsused = 1; @@ -243,14 +243,14 @@ static const struct option genrsa_options[] = { .argname = "file", .desc = "Output the key to 'file'", .type = OPTION_ARG, - .opt.arg = &genrsa_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "passout", .argname = "arg", .desc = "Output file passphrase source", .type = OPTION_ARG, - .opt.arg = &genrsa_config.passargout, + .opt.arg = &cfg.passargout, }, { NULL }, }; @@ -280,11 +280,9 @@ genrsa_main(int argc, char **argv) RSA *rsa = NULL; char *rsa_e_hex = NULL, *rsa_e_dec = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } if ((bn = BN_new()) == NULL) @@ -302,8 +300,8 @@ genrsa_main(int argc, char **argv) goto err; } - memset(&genrsa_config, 0, sizeof(genrsa_config)); - genrsa_config.f4 = RSA_F4; + memset(&cfg, 0, sizeof(cfg)); + cfg.f4 = RSA_F4; if (options_parse(argc, argv, genrsa_options, &numbits, NULL) != 0) { genrsa_usage(); @@ -316,17 +314,17 @@ genrsa_main(int argc, char **argv) goto err; } - if (!app_passwd(bio_err, NULL, genrsa_config.passargout, NULL, + if (!app_passwd(bio_err, NULL, cfg.passargout, NULL, &passout)) { BIO_printf(bio_err, "Error getting password\n"); goto err; } - if (genrsa_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, genrsa_config.outfile) <= 0) { - perror(genrsa_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto err; } } @@ -337,7 +335,7 @@ genrsa_main(int argc, char **argv) if (!rsa) goto err; - if (!BN_set_word(bn, genrsa_config.f4) || + if (!BN_set_word(bn, cfg.f4) || !RSA_generate_key_ex(rsa, num, bn, cb)) goto err; @@ -346,12 +344,12 @@ genrsa_main(int argc, char **argv) if ((rsa_e_dec = BN_bn2dec(RSA_get0_e(rsa))) == NULL) goto err; - BIO_printf(bio_err, "e is %s (0x%s)\n", rsa_e_hex, rsa_e_dec); + BIO_printf(bio_err, "e is %s (0x%s)\n", rsa_e_dec, rsa_e_hex); { PW_CB_DATA cb_data; cb_data.password = passout; - cb_data.prompt_info = genrsa_config.outfile; - if (!PEM_write_bio_RSAPrivateKey(out, rsa, genrsa_config.enc, + cb_data.prompt_info = cfg.outfile; + if (!PEM_write_bio_RSAPrivateKey(out, rsa, cfg.enc, NULL, 0, password_callback, &cb_data)) goto err; } diff --git a/apps/openssl/nseq.c b/apps/openssl/nseq.c index 516bde34..fb0dda5d 100644 --- a/apps/openssl/nseq.c +++ b/apps/openssl/nseq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nseq.c,v 1.9 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: nseq.c,v 1.11 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -68,7 +68,7 @@ static struct { char *infile; char *outfile; int toseq; -} nseq_config; +} cfg; static const struct option nseq_options[] = { { @@ -76,20 +76,20 @@ static const struct option nseq_options[] = { .argname = "file", .desc = "Input file to read from (default stdin)", .type = OPTION_ARG, - .opt.arg = &nseq_config.infile, + .opt.arg = &cfg.infile, }, { .name = "out", .argname = "file", .desc = "Output file to write to (default stdout)", .type = OPTION_ARG, - .opt.arg = &nseq_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "toseq", .desc = "Convert certificates to Netscape certificate sequence", .type = OPTION_FLAG, - .opt.flag = &nseq_config.toseq, + .opt.flag = &cfg.toseq, }, { NULL }, }; @@ -109,46 +109,44 @@ nseq_main(int argc, char **argv) NETSCAPE_CERT_SEQUENCE *seq = NULL; int i, ret = 1; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&nseq_config, 0, sizeof(nseq_config)); + memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, nseq_options, NULL, NULL) != 0) { nseq_usage(); return (1); } - if (nseq_config.infile) { - if (!(in = BIO_new_file(nseq_config.infile, "r"))) { + if (cfg.infile) { + if (!(in = BIO_new_file(cfg.infile, "r"))) { BIO_printf(bio_err, - "Can't open input file %s\n", nseq_config.infile); + "Can't open input file %s\n", cfg.infile); goto end; } } else in = BIO_new_fp(stdin, BIO_NOCLOSE); - if (nseq_config.outfile) { - if (!(out = BIO_new_file(nseq_config.outfile, "w"))) { + if (cfg.outfile) { + if (!(out = BIO_new_file(cfg.outfile, "w"))) { BIO_printf(bio_err, - "Can't open output file %s\n", nseq_config.outfile); + "Can't open output file %s\n", cfg.outfile); goto end; } } else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } - if (nseq_config.toseq) { + if (cfg.toseq) { seq = NETSCAPE_CERT_SEQUENCE_new(); seq->certs = sk_X509_new_null(); while ((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL))) sk_X509_push(seq->certs, x509); if (!sk_X509_num(seq->certs)) { - BIO_printf(bio_err, "Error reading certs file %s\n", nseq_config.infile); + BIO_printf(bio_err, "Error reading certs file %s\n", cfg.infile); ERR_print_errors(bio_err); goto end; } @@ -157,7 +155,7 @@ nseq_main(int argc, char **argv) goto end; } if (!(seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL))) { - BIO_printf(bio_err, "Error reading sequence file %s\n", nseq_config.infile); + BIO_printf(bio_err, "Error reading sequence file %s\n", cfg.infile); ERR_print_errors(bio_err); goto end; } diff --git a/apps/openssl/ocsp.c b/apps/openssl/ocsp.c index f954d969..cc942a45 100644 --- a/apps/openssl/ocsp.c +++ b/apps/openssl/ocsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp.c,v 1.21 2020/10/13 18:25:35 tb Exp $ */ +/* $OpenBSD: ocsp.c,v 1.23 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -143,27 +143,27 @@ static struct { int use_ssl; char *verify_certfile; unsigned long verify_flags; -} ocsp_config; +} cfg; static int ocsp_opt_cert(char *arg) { - X509_free(ocsp_config.cert); - ocsp_config.cert = load_cert(bio_err, arg, FORMAT_PEM, NULL, + X509_free(cfg.cert); + cfg.cert = load_cert(bio_err, arg, FORMAT_PEM, NULL, "certificate"); - if (ocsp_config.cert == NULL) { - ocsp_config.no_usage = 1; + if (cfg.cert == NULL) { + cfg.no_usage = 1; return (1); } - if (ocsp_config.cert_id_md == NULL) - ocsp_config.cert_id_md = EVP_sha1(); - if (!add_ocsp_cert(&ocsp_config.req, ocsp_config.cert, - ocsp_config.cert_id_md, ocsp_config.issuer, ocsp_config.ids)) { - ocsp_config.no_usage = 1; + if (cfg.cert_id_md == NULL) + cfg.cert_id_md = EVP_sha1(); + if (!add_ocsp_cert(&cfg.req, cfg.cert, + cfg.cert_id_md, cfg.issuer, cfg.ids)) { + cfg.no_usage = 1; return (1); } - if (!sk_OPENSSL_STRING_push(ocsp_config.reqnames, arg)) { - ocsp_config.no_usage = 1; + if (!sk_OPENSSL_STRING_push(cfg.reqnames, arg)) { + cfg.no_usage = 1; return (1); } return (0); @@ -177,7 +177,7 @@ ocsp_opt_cert_id_md(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((ocsp_config.cert_id_md = EVP_get_digestbyname(name)) == NULL) + if ((cfg.cert_id_md = EVP_get_digestbyname(name)) == NULL) return (1); *argsused = 1; @@ -190,8 +190,8 @@ ocsp_opt_header(int argc, char **argv, int *argsused) if (argc < 3 || argv[1] == NULL || argv[2] == NULL) return (1); - if (!X509V3_add_value(argv[1], argv[2], &ocsp_config.headers)) { - ocsp_config.no_usage = 1; + if (!X509V3_add_value(argv[1], argv[2], &cfg.headers)) { + cfg.no_usage = 1; return (1); } @@ -202,21 +202,21 @@ ocsp_opt_header(int argc, char **argv, int *argsused) static int ocsp_opt_host(char *arg) { - if (ocsp_config.use_ssl != -1) + if (cfg.use_ssl != -1) return (1); - ocsp_config.host = arg; + cfg.host = arg; return (0); } static int ocsp_opt_issuer(char *arg) { - X509_free(ocsp_config.issuer); - ocsp_config.issuer = load_cert(bio_err, arg, FORMAT_PEM, NULL, + X509_free(cfg.issuer); + cfg.issuer = load_cert(bio_err, arg, FORMAT_PEM, NULL, "issuer certificate"); - if (ocsp_config.issuer == NULL) { - ocsp_config.no_usage = 1; + if (cfg.issuer == NULL) { + cfg.no_usage = 1; return (1); } return (0); @@ -227,7 +227,7 @@ ocsp_opt_ndays(char *arg) { const char *errstr = NULL; - ocsp_config.ndays = strtonum(arg, 0, INT_MAX, &errstr); + cfg.ndays = strtonum(arg, 0, INT_MAX, &errstr); if (errstr != NULL) { BIO_printf(bio_err, "Illegal update period %s: %s\n", arg, errstr); @@ -241,17 +241,17 @@ ocsp_opt_nmin(char *arg) { const char *errstr = NULL; - ocsp_config.nmin = strtonum(arg, 0, INT_MAX, &errstr); + cfg.nmin = strtonum(arg, 0, INT_MAX, &errstr); if (errstr != NULL) { BIO_printf(bio_err, "Illegal update period %s: %s\n", arg, errstr); return (1); } - if (ocsp_config.ndays != -1) + if (cfg.ndays != -1) return (1); - ocsp_config.ndays = 0; + cfg.ndays = 0; return (0); } @@ -260,7 +260,7 @@ ocsp_opt_nrequest(char *arg) { const char *errstr = NULL; - ocsp_config.accept_count = strtonum(arg, 0, INT_MAX, &errstr); + cfg.accept_count = strtonum(arg, 0, INT_MAX, &errstr); if (errstr != NULL) { BIO_printf(bio_err, "Illegal accept count %s: %s\n", arg, errstr); @@ -272,25 +272,25 @@ ocsp_opt_nrequest(char *arg) static int ocsp_opt_port(char *arg) { - if (ocsp_config.use_ssl != -1) + if (cfg.use_ssl != -1) return (1); - ocsp_config.port = arg; + cfg.port = arg; return (0); } static int ocsp_opt_serial(char *arg) { - if (ocsp_config.cert_id_md == NULL) - ocsp_config.cert_id_md = EVP_sha1(); - if (!add_ocsp_serial(&ocsp_config.req, arg, ocsp_config.cert_id_md, - ocsp_config.issuer, ocsp_config.ids)) { - ocsp_config.no_usage = 1; + if (cfg.cert_id_md == NULL) + cfg.cert_id_md = EVP_sha1(); + if (!add_ocsp_serial(&cfg.req, arg, cfg.cert_id_md, + cfg.issuer, cfg.ids)) { + cfg.no_usage = 1; return (1); } - if (!sk_OPENSSL_STRING_push(ocsp_config.reqnames, arg)) { - ocsp_config.no_usage = 1; + if (!sk_OPENSSL_STRING_push(cfg.reqnames, arg)) { + cfg.no_usage = 1; return (1); } return (0); @@ -301,7 +301,7 @@ ocsp_opt_status_age(char *arg) { const char *errstr = NULL; - ocsp_config.maxage = strtonum(arg, 0, LONG_MAX, &errstr); + cfg.maxage = strtonum(arg, 0, LONG_MAX, &errstr); if (errstr != NULL) { BIO_printf(bio_err, "Illegal validity age %s: %s\n", arg, errstr); @@ -313,8 +313,8 @@ ocsp_opt_status_age(char *arg) static int ocsp_opt_text(void) { - ocsp_config.req_text = 1; - ocsp_config.resp_text = 1; + cfg.req_text = 1; + cfg.resp_text = 1; return (0); } @@ -323,7 +323,7 @@ ocsp_opt_timeout(char *arg) { const char *errstr = NULL; - ocsp_config.req_timeout = strtonum(arg, 0, INT_MAX, &errstr); + cfg.req_timeout = strtonum(arg, 0, INT_MAX, &errstr); if (errstr != NULL) { BIO_printf(bio_err, "Illegal timeout value %s: %s\n", arg, errstr); @@ -335,10 +335,10 @@ ocsp_opt_timeout(char *arg) static int ocsp_opt_url(char *arg) { - if (ocsp_config.host == NULL && ocsp_config.port == NULL && - ocsp_config.path == NULL) { - if (!OCSP_parse_url(arg, &ocsp_config.host, &ocsp_config.port, - &ocsp_config.path, &ocsp_config.use_ssl)) { + if (cfg.host == NULL && cfg.port == NULL && + cfg.path == NULL) { + if (!OCSP_parse_url(arg, &cfg.host, &cfg.port, + &cfg.path, &cfg.use_ssl)) { BIO_printf(bio_err, "Error parsing URL\n"); return (1); } @@ -349,8 +349,8 @@ ocsp_opt_url(char *arg) static int ocsp_opt_vafile(char *arg) { - ocsp_config.verify_certfile = arg; - ocsp_config.verify_flags |= OCSP_TRUSTOTHER; + cfg.verify_certfile = arg; + cfg.verify_flags |= OCSP_TRUSTOTHER; return (0); } @@ -359,7 +359,7 @@ ocsp_opt_validity_period(char *arg) { const char *errstr = NULL; - ocsp_config.nsec = strtonum(arg, 0, LONG_MAX, &errstr); + cfg.nsec = strtonum(arg, 0, LONG_MAX, &errstr); if (errstr != NULL) { BIO_printf(bio_err, "Illegal validity period %s: %s\n", arg, errstr); @@ -374,21 +374,21 @@ static const struct option ocsp_options[] = { .argname = "file", .desc = "CA certificate corresponding to the revocation information", .type = OPTION_ARG, - .opt.arg = &ocsp_config.rca_filename, + .opt.arg = &cfg.rca_filename, }, { .name = "CAfile", .argname = "file", .desc = "Trusted certificates file", .type = OPTION_ARG, - .opt.arg = &ocsp_config.CAfile, + .opt.arg = &cfg.CAfile, }, { .name = "CApath", .argname = "directory", .desc = "Trusted certificates directory", .type = OPTION_ARG, - .opt.arg = &ocsp_config.CApath, + .opt.arg = &cfg.CApath, }, { .name = "cert", @@ -415,14 +415,14 @@ static const struct option ocsp_options[] = { .name = "ignore_err", .desc = "Ignore the invalid response", .type = OPTION_FLAG, - .opt.flag = &ocsp_config.ignore_err, + .opt.flag = &cfg.ignore_err, }, { .name = "index", .argname = "indexfile", .desc = "Certificate status index file", .type = OPTION_ARG, - .opt.arg = &ocsp_config.ridx_filename, + .opt.arg = &cfg.ridx_filename, }, { .name = "issuer", @@ -449,70 +449,70 @@ static const struct option ocsp_options[] = { .name = "no_cert_checks", .desc = "Don't do additional checks on signing certificate", .type = OPTION_UL_VALUE_OR, - .opt.ulvalue = &ocsp_config.verify_flags, + .opt.ulvalue = &cfg.verify_flags, .ulvalue = OCSP_NOCHECKS, }, { .name = "no_cert_verify", .desc = "Don't check signing certificate", .type = OPTION_UL_VALUE_OR, - .opt.ulvalue = &ocsp_config.verify_flags, + .opt.ulvalue = &cfg.verify_flags, .ulvalue = OCSP_NOVERIFY, }, { .name = "no_certs", .desc = "Don't include any certificates in signed request", .type = OPTION_UL_VALUE_OR, - .opt.ulvalue = &ocsp_config.sign_flags, + .opt.ulvalue = &cfg.sign_flags, .ulvalue = OCSP_NOCERTS, }, { .name = "no_chain", .desc = "Don't use certificates in the response", .type = OPTION_UL_VALUE_OR, - .opt.ulvalue = &ocsp_config.verify_flags, + .opt.ulvalue = &cfg.verify_flags, .ulvalue = OCSP_NOCHAIN, }, { .name = "no_explicit", .desc = "Don't check the explicit trust for OCSP signing", .type = OPTION_UL_VALUE_OR, - .opt.ulvalue = &ocsp_config.verify_flags, + .opt.ulvalue = &cfg.verify_flags, .ulvalue = OCSP_NOEXPLICIT, }, { .name = "no_intern", .desc = "Don't search certificates contained in response for signer", .type = OPTION_UL_VALUE_OR, - .opt.ulvalue = &ocsp_config.verify_flags, + .opt.ulvalue = &cfg.verify_flags, .ulvalue = OCSP_NOINTERN, }, { .name = "no_nonce", .desc = "Don't add OCSP nonce to request", .type = OPTION_VALUE, - .opt.value = &ocsp_config.add_nonce, + .opt.value = &cfg.add_nonce, .value = 0, }, { .name = "no_signature_verify", .desc = "Don't check signature on response", .type = OPTION_UL_VALUE_OR, - .opt.ulvalue = &ocsp_config.verify_flags, + .opt.ulvalue = &cfg.verify_flags, .ulvalue = OCSP_NOSIGS, }, { .name = "nonce", .desc = "Add OCSP nonce to request", .type = OPTION_VALUE, - .opt.value = &ocsp_config.add_nonce, + .opt.value = &cfg.add_nonce, .value = 2, }, { .name = "noverify", .desc = "Don't verify response at all", .type = OPTION_FLAG, - .opt.flag = &ocsp_config.noverify, + .opt.flag = &cfg.noverify, }, { .name = "nrequest", @@ -526,14 +526,14 @@ static const struct option ocsp_options[] = { .argname = "file", .desc = "Output filename", .type = OPTION_ARG, - .opt.arg = &ocsp_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "path", .argname = "path", .desc = "Path to use in OCSP request", .type = OPTION_ARG, - .opt.arg = &ocsp_config.path, + .opt.arg = &cfg.path, }, { .name = "port", @@ -546,76 +546,76 @@ static const struct option ocsp_options[] = { .name = "req_text", .desc = "Print text form of request", .type = OPTION_FLAG, - .opt.flag = &ocsp_config.req_text, + .opt.flag = &cfg.req_text, }, { .name = "reqin", .argname = "file", .desc = "Read DER encoded OCSP request from \"file\"", .type = OPTION_ARG, - .opt.arg = &ocsp_config.reqin, + .opt.arg = &cfg.reqin, }, { .name = "reqout", .argname = "file", .desc = "Write DER encoded OCSP request to \"file\"", .type = OPTION_ARG, - .opt.arg = &ocsp_config.reqout, + .opt.arg = &cfg.reqout, }, { .name = "resp_key_id", .desc = "Identify response by signing certificate key ID", .type = OPTION_UL_VALUE_OR, - .opt.ulvalue = &ocsp_config.rflags, + .opt.ulvalue = &cfg.rflags, .ulvalue = OCSP_RESPID_KEY, }, { .name = "resp_no_certs", .desc = "Don't include any certificates in response", .type = OPTION_UL_VALUE_OR, - .opt.ulvalue = &ocsp_config.rflags, + .opt.ulvalue = &cfg.rflags, .ulvalue = OCSP_NOCERTS, }, { .name = "resp_text", .desc = "Print text form of response", .type = OPTION_FLAG, - .opt.flag = &ocsp_config.resp_text, + .opt.flag = &cfg.resp_text, }, { .name = "respin", .argname = "file", .desc = "Read DER encoded OCSP response from \"file\"", .type = OPTION_ARG, - .opt.arg = &ocsp_config.respin, + .opt.arg = &cfg.respin, }, { .name = "respout", .argname = "file", .desc = "Write DER encoded OCSP response to \"file\"", .type = OPTION_ARG, - .opt.arg = &ocsp_config.respout, + .opt.arg = &cfg.respout, }, { .name = "rkey", .argname = "file", .desc = "Responder key to sign responses with", .type = OPTION_ARG, - .opt.arg = &ocsp_config.rkeyfile, + .opt.arg = &cfg.rkeyfile, }, { .name = "rother", .argname = "file", .desc = "Other certificates to include in response", .type = OPTION_ARG, - .opt.arg = &ocsp_config.rcertfile, + .opt.arg = &cfg.rcertfile, }, { .name = "rsigner", .argname = "file", .desc = "Responder certificate to sign responses with", .type = OPTION_ARG, - .opt.arg = &ocsp_config.rsignfile, + .opt.arg = &cfg.rsignfile, }, { .name = "serial", @@ -629,21 +629,21 @@ static const struct option ocsp_options[] = { .argname = "file", .desc = "Additional certificates to include in signed request", .type = OPTION_ARG, - .opt.arg = &ocsp_config.sign_certfile, + .opt.arg = &cfg.sign_certfile, }, { .name = "signer", .argname = "file", .desc = "Certificate to sign OCSP request with", .type = OPTION_ARG, - .opt.arg = &ocsp_config.signfile, + .opt.arg = &cfg.signfile, }, { .name = "signkey", .argname = "file", .desc = "Private key to sign OCSP request with", .type = OPTION_ARG, - .opt.arg = &ocsp_config.keyfile, + .opt.arg = &cfg.keyfile, }, { .name = "status_age", @@ -669,7 +669,7 @@ static const struct option ocsp_options[] = { .name = "trust_other", .desc = "Don't verify additional certificates", .type = OPTION_UL_VALUE_OR, - .opt.ulvalue = &ocsp_config.verify_flags, + .opt.ulvalue = &cfg.verify_flags, .ulvalue = OCSP_TRUSTOTHER, }, { @@ -698,7 +698,7 @@ static const struct option ocsp_options[] = { .argname = "file", .desc = "Additional certificates to search for signer", .type = OPTION_ARG, - .opt.arg = &ocsp_config.verify_certfile, + .opt.arg = &cfg.verify_certfile, }, { .name = NULL, @@ -750,44 +750,42 @@ ocsp_main(int argc, char **argv) X509 *rca_cert = NULL; CA_DB *rdb = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath inet dns tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath inet dns tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&ocsp_config, 0, sizeof(ocsp_config)); - ocsp_config.accept_count = -1; - ocsp_config.add_nonce = 1; - if ((ocsp_config.ids = sk_OCSP_CERTID_new_null()) == NULL) + memset(&cfg, 0, sizeof(cfg)); + cfg.accept_count = -1; + cfg.add_nonce = 1; + if ((cfg.ids = sk_OCSP_CERTID_new_null()) == NULL) goto end; - ocsp_config.maxage = -1; - ocsp_config.ndays = -1; - ocsp_config.nsec = MAX_VALIDITY_PERIOD; - ocsp_config.req_timeout = -1; - if ((ocsp_config.reqnames = sk_OPENSSL_STRING_new_null()) == NULL) + cfg.maxage = -1; + cfg.ndays = -1; + cfg.nsec = MAX_VALIDITY_PERIOD; + cfg.req_timeout = -1; + if ((cfg.reqnames = sk_OPENSSL_STRING_new_null()) == NULL) goto end; - ocsp_config.use_ssl = -1; + cfg.use_ssl = -1; if (options_parse(argc, argv, ocsp_options, NULL, NULL) != 0) { - if (ocsp_config.no_usage) + if (cfg.no_usage) goto end; else badarg = 1; } /* Have we anything to do? */ - if (!ocsp_config.req && !ocsp_config.reqin && !ocsp_config.respin && - !(ocsp_config.port && ocsp_config.ridx_filename)) + if (!cfg.req && !cfg.reqin && !cfg.respin && + !(cfg.port && cfg.ridx_filename)) badarg = 1; if (badarg) { ocsp_usage(); goto end; } - if (ocsp_config.outfile) - out = BIO_new_file(ocsp_config.outfile, "w"); + if (cfg.outfile) + out = BIO_new_file(cfg.outfile, "w"); else out = BIO_new_fp(stdout, BIO_NOCLOSE); @@ -795,47 +793,47 @@ ocsp_main(int argc, char **argv) BIO_printf(bio_err, "Error opening output file\n"); goto end; } - if (!ocsp_config.req && (ocsp_config.add_nonce != 2)) - ocsp_config.add_nonce = 0; + if (!cfg.req && (cfg.add_nonce != 2)) + cfg.add_nonce = 0; - if (!ocsp_config.req && ocsp_config.reqin) { - derbio = BIO_new_file(ocsp_config.reqin, "rb"); + if (!cfg.req && cfg.reqin) { + derbio = BIO_new_file(cfg.reqin, "rb"); if (!derbio) { BIO_printf(bio_err, "Error Opening OCSP request file\n"); goto end; } - ocsp_config.req = d2i_OCSP_REQUEST_bio(derbio, NULL); + cfg.req = d2i_OCSP_REQUEST_bio(derbio, NULL); BIO_free(derbio); - if (!ocsp_config.req) { + if (!cfg.req) { BIO_printf(bio_err, "Error reading OCSP request\n"); goto end; } } - if (!ocsp_config.req && ocsp_config.port) { - acbio = init_responder(ocsp_config.port); + if (!cfg.req && cfg.port) { + acbio = init_responder(cfg.port); if (!acbio) goto end; } - if (ocsp_config.rsignfile && !rdb) { - if (!ocsp_config.rkeyfile) - ocsp_config.rkeyfile = ocsp_config.rsignfile; - rsigner = load_cert(bio_err, ocsp_config.rsignfile, FORMAT_PEM, + if (cfg.rsignfile && !rdb) { + if (!cfg.rkeyfile) + cfg.rkeyfile = cfg.rsignfile; + rsigner = load_cert(bio_err, cfg.rsignfile, FORMAT_PEM, NULL, "responder certificate"); if (!rsigner) { BIO_printf(bio_err, "Error loading responder certificate\n"); goto end; } - rca_cert = load_cert(bio_err, ocsp_config.rca_filename, + rca_cert = load_cert(bio_err, cfg.rca_filename, FORMAT_PEM, NULL, "CA certificate"); - if (ocsp_config.rcertfile) { - rother = load_certs(bio_err, ocsp_config.rcertfile, + if (cfg.rcertfile) { + rother = load_certs(bio_err, cfg.rcertfile, FORMAT_PEM, NULL, "responder other certificates"); if (!rother) goto end; } - rkey = load_key(bio_err, ocsp_config.rkeyfile, FORMAT_PEM, 0, + rkey = load_key(bio_err, cfg.rkeyfile, FORMAT_PEM, 0, NULL, "responder private key"); if (!rkey) goto end; @@ -846,95 +844,95 @@ ocsp_main(int argc, char **argv) redo_accept: if (acbio) { - if (!do_responder(&ocsp_config.req, &cbio, acbio, - ocsp_config.port)) + if (!do_responder(&cfg.req, &cbio, acbio, + cfg.port)) goto end; - if (!ocsp_config.req) { + if (!cfg.req) { resp = OCSP_response_create( OCSP_RESPONSE_STATUS_MALFORMEDREQUEST, NULL); send_ocsp_response(cbio, resp); goto done_resp; } } - if (!ocsp_config.req && - (ocsp_config.signfile || ocsp_config.reqout || ocsp_config.host || - ocsp_config.add_nonce || ocsp_config.ridx_filename)) { + if (!cfg.req && + (cfg.signfile || cfg.reqout || cfg.host || + cfg.add_nonce || cfg.ridx_filename)) { BIO_printf(bio_err, "Need an OCSP request for this operation!\n"); goto end; } - if (ocsp_config.req && ocsp_config.add_nonce) - OCSP_request_add1_nonce(ocsp_config.req, NULL, -1); + if (cfg.req && cfg.add_nonce) + OCSP_request_add1_nonce(cfg.req, NULL, -1); - if (ocsp_config.signfile) { - if (!ocsp_config.keyfile) - ocsp_config.keyfile = ocsp_config.signfile; - signer = load_cert(bio_err, ocsp_config.signfile, FORMAT_PEM, + if (cfg.signfile) { + if (!cfg.keyfile) + cfg.keyfile = cfg.signfile; + signer = load_cert(bio_err, cfg.signfile, FORMAT_PEM, NULL, "signer certificate"); if (!signer) { BIO_printf(bio_err, "Error loading signer certificate\n"); goto end; } - if (ocsp_config.sign_certfile) { + if (cfg.sign_certfile) { sign_other = load_certs(bio_err, - ocsp_config.sign_certfile, FORMAT_PEM, NULL, + cfg.sign_certfile, FORMAT_PEM, NULL, "signer certificates"); if (!sign_other) goto end; } - key = load_key(bio_err, ocsp_config.keyfile, FORMAT_PEM, 0, + key = load_key(bio_err, cfg.keyfile, FORMAT_PEM, 0, NULL, "signer private key"); if (!key) goto end; - if (!OCSP_request_sign(ocsp_config.req, signer, key, NULL, - sign_other, ocsp_config.sign_flags)) { + if (!OCSP_request_sign(cfg.req, signer, key, NULL, + sign_other, cfg.sign_flags)) { BIO_printf(bio_err, "Error signing OCSP request\n"); goto end; } } - if (ocsp_config.req_text && ocsp_config.req) - OCSP_REQUEST_print(out, ocsp_config.req, 0); + if (cfg.req_text && cfg.req) + OCSP_REQUEST_print(out, cfg.req, 0); - if (ocsp_config.reqout) { - derbio = BIO_new_file(ocsp_config.reqout, "wb"); + if (cfg.reqout) { + derbio = BIO_new_file(cfg.reqout, "wb"); if (!derbio) { BIO_printf(bio_err, "Error opening file %s\n", - ocsp_config.reqout); + cfg.reqout); goto end; } - i2d_OCSP_REQUEST_bio(derbio, ocsp_config.req); + i2d_OCSP_REQUEST_bio(derbio, cfg.req); BIO_free(derbio); } - if (ocsp_config.ridx_filename && (!rkey || !rsigner || !rca_cert)) { + if (cfg.ridx_filename && (!rkey || !rsigner || !rca_cert)) { BIO_printf(bio_err, "Need a responder certificate, key and CA for this operation!\n"); goto end; } - if (ocsp_config.ridx_filename && !rdb) { - rdb = load_index(ocsp_config.ridx_filename, NULL); + if (cfg.ridx_filename && !rdb) { + rdb = load_index(cfg.ridx_filename, NULL); if (!rdb) goto end; if (!index_index(rdb)) goto end; } if (rdb) { - i = make_ocsp_response(&resp, ocsp_config.req, rdb, rca_cert, - rsigner, rkey, rother, ocsp_config.rflags, - ocsp_config.nmin, ocsp_config.ndays); + i = make_ocsp_response(&resp, cfg.req, rdb, rca_cert, + rsigner, rkey, rother, cfg.rflags, + cfg.nmin, cfg.ndays); if (cbio) send_ocsp_response(cbio, resp); - } else if (ocsp_config.host) { - resp = process_responder(bio_err, ocsp_config.req, - ocsp_config.host, - ocsp_config.path ? ocsp_config.path : "/", - ocsp_config.port, ocsp_config.use_ssl, ocsp_config.headers, - ocsp_config.req_timeout); + } else if (cfg.host) { + resp = process_responder(bio_err, cfg.req, + cfg.host, + cfg.path ? cfg.path : "/", + cfg.port, cfg.use_ssl, cfg.headers, + cfg.req_timeout); if (!resp) goto end; - } else if (ocsp_config.respin) { - derbio = BIO_new_file(ocsp_config.respin, "rb"); + } else if (cfg.respin) { + derbio = BIO_new_file(cfg.respin, "rb"); if (!derbio) { BIO_printf(bio_err, "Error Opening OCSP response file\n"); @@ -953,11 +951,11 @@ ocsp_main(int argc, char **argv) done_resp: - if (ocsp_config.respout) { - derbio = BIO_new_file(ocsp_config.respout, "wb"); + if (cfg.respout) { + derbio = BIO_new_file(cfg.respout, "wb"); if (!derbio) { BIO_printf(bio_err, "Error opening file %s\n", - ocsp_config.respout); + cfg.respout); goto end; } i2d_OCSP_RESPONSE_bio(derbio, resp); @@ -968,24 +966,24 @@ ocsp_main(int argc, char **argv) if (i != OCSP_RESPONSE_STATUS_SUCCESSFUL) { BIO_printf(bio_err, "Responder Error: %s (%d)\n", OCSP_response_status_str(i), i); - if (ocsp_config.ignore_err) + if (cfg.ignore_err) goto redo_accept; ret = 1; goto end; } - if (ocsp_config.resp_text) + if (cfg.resp_text) OCSP_RESPONSE_print(out, resp, 0); /* If running as responder don't verify our own response */ if (cbio) { - if (ocsp_config.accept_count > 0) - ocsp_config.accept_count--; + if (cfg.accept_count > 0) + cfg.accept_count--; /* Redo if more connections needed */ - if (ocsp_config.accept_count) { + if (cfg.accept_count) { BIO_free_all(cbio); cbio = NULL; - OCSP_REQUEST_free(ocsp_config.req); - ocsp_config.req = NULL; + OCSP_REQUEST_free(cfg.req); + cfg.req = NULL; OCSP_RESPONSE_free(resp); resp = NULL; goto redo_accept; @@ -993,12 +991,12 @@ ocsp_main(int argc, char **argv) goto end; } if (!store) - store = setup_verify(bio_err, ocsp_config.CAfile, - ocsp_config.CApath); + store = setup_verify(bio_err, cfg.CAfile, + cfg.CApath); if (!store) goto end; - if (ocsp_config.verify_certfile) { - verify_other = load_certs(bio_err, ocsp_config.verify_certfile, + if (cfg.verify_certfile) { + verify_other = load_certs(bio_err, cfg.verify_certfile, FORMAT_PEM, NULL, "validator certificate"); if (!verify_other) goto end; @@ -1009,9 +1007,9 @@ ocsp_main(int argc, char **argv) BIO_printf(bio_err, "Error parsing response\n"); goto end; } - if (!ocsp_config.noverify) { - if (ocsp_config.req && - ((i = OCSP_check_nonce(ocsp_config.req, bs)) <= 0)) { + if (!cfg.noverify) { + if (cfg.req && + ((i = OCSP_check_nonce(cfg.req, bs)) <= 0)) { if (i == -1) { BIO_printf(bio_err, "WARNING: no nonce in response\n"); @@ -1021,7 +1019,7 @@ ocsp_main(int argc, char **argv) } } i = OCSP_basic_verify(bs, verify_other, store, - ocsp_config.verify_flags); + cfg.verify_flags); if (i < 0) i = OCSP_basic_verify(bs, NULL, store, 0); @@ -1032,8 +1030,8 @@ ocsp_main(int argc, char **argv) BIO_printf(bio_err, "Response verify OK\n"); } } - if (!print_ocsp_summary(out, bs, ocsp_config.req, ocsp_config.reqnames, - ocsp_config.ids, ocsp_config.nsec, ocsp_config.maxage)) + if (!print_ocsp_summary(out, bs, cfg.req, cfg.reqnames, + cfg.ids, cfg.nsec, cfg.maxage)) goto end; ret = 0; @@ -1044,27 +1042,27 @@ ocsp_main(int argc, char **argv) X509_STORE_free(store); EVP_PKEY_free(key); EVP_PKEY_free(rkey); - X509_free(ocsp_config.issuer); - X509_free(ocsp_config.cert); + X509_free(cfg.issuer); + X509_free(cfg.cert); X509_free(rsigner); X509_free(rca_cert); free_index(rdb); BIO_free_all(cbio); BIO_free_all(acbio); BIO_free(out); - OCSP_REQUEST_free(ocsp_config.req); + OCSP_REQUEST_free(cfg.req); OCSP_RESPONSE_free(resp); OCSP_BASICRESP_free(bs); - sk_OPENSSL_STRING_free(ocsp_config.reqnames); - sk_OCSP_CERTID_free(ocsp_config.ids); + sk_OPENSSL_STRING_free(cfg.reqnames); + sk_OCSP_CERTID_free(cfg.ids); sk_X509_pop_free(sign_other, X509_free); sk_X509_pop_free(verify_other, X509_free); - sk_CONF_VALUE_pop_free(ocsp_config.headers, X509V3_conf_free); + sk_CONF_VALUE_pop_free(cfg.headers, X509V3_conf_free); - if (ocsp_config.use_ssl != -1) { - free(ocsp_config.host); - free(ocsp_config.port); - free(ocsp_config.path); + if (cfg.use_ssl != -1) { + free(cfg.host); + free(cfg.port); + free(cfg.path); } return (ret); } diff --git a/apps/openssl/openssl.1 b/apps/openssl/openssl.1 index 419fbe4d..b28fc090 100644 --- a/apps/openssl/openssl.1 +++ b/apps/openssl/openssl.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: openssl.1,v 1.139 2022/07/19 16:08:09 tb Exp $ +.\" $OpenBSD: openssl.1,v 1.140 2022/12/22 19:53:23 kn Exp $ .\" ==================================================================== .\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. .\" @@ -110,7 +110,7 @@ .\" copied and put under another distribution licence .\" [including the GNU Public Licence.] .\" -.Dd $Mdocdate: July 19 2022 $ +.Dd $Mdocdate: December 22 2022 $ .Dt OPENSSL 1 .Os .Sh NAME @@ -119,8 +119,8 @@ .Sh SYNOPSIS .Nm .Ar command -.Op Ar command_opts -.Op Ar command_args +.Op Ar command_opt ... +.Op Ar command_arg ... .Pp .Nm .Cm list-standard-commands | diff --git a/apps/openssl/openssl.c b/apps/openssl/openssl.c index fe92a126..4c07cc90 100644 --- a/apps/openssl/openssl.c +++ b/apps/openssl/openssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openssl.c,v 1.30 2019/11/04 15:25:54 jsing Exp $ */ +/* $OpenBSD: openssl.c,v 1.32 2022/11/11 18:24:32 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -137,8 +137,6 @@ #define FUNC_TYPE_MD_ALG 5 #define FUNC_TYPE_CIPHER_ALG 6 -int single_execution = 0; - typedef struct { int type; const char *name; @@ -349,6 +347,7 @@ static void openssl_shutdown(void); static LHASH_OF(FUNCTION) *prog_init(void); static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]); +static void print_help(void); static void list_pkey(BIO * out); static void list_cipher(BIO * out); static void list_md(BIO * out); @@ -387,13 +386,8 @@ int main(int argc, char **argv) { ARGS arg; -#define PROG_NAME_SIZE 39 - char pname[PROG_NAME_SIZE + 1]; - FUNCTION f, *fp; - const char *prompt; - char buf[1024]; char *to_free = NULL; - int n, i, ret = 0; + int i, ret = 0; char *p; LHASH_OF(FUNCTION) * prog = NULL; long errline; @@ -455,74 +449,21 @@ main(int argc, char **argv) prog = prog_init(); - /* first check the program name */ - program_name(argv[0], pname, sizeof pname); - - f.name = pname; - fp = lh_FUNCTION_retrieve(prog, &f); - if (fp != NULL) { - argv[0] = pname; - - single_execution = 1; - ret = fp->func(argc, argv); - goto end; - } /* * ok, now check that there are not arguments, if there are, run with - * them, shifting the ssleay off the front + * them, shifting the executable name off the front */ - if (argc != 1) { - argc--; - argv++; - - single_execution = 1; - ret = do_cmd(prog, argc, argv); - if (ret < 0) - ret = 0; + argc--; + argv++; + + if (argc < 1) { + print_help(); goto end; } - /* ok, lets enter the old 'OpenSSL>' mode */ - for (;;) { + ret = do_cmd(prog, argc, argv); + if (ret < 0) ret = 0; - p = buf; - n = sizeof buf; - i = 0; - for (;;) { - p[0] = '\0'; - if (i++) - prompt = ">"; - else - prompt = "OpenSSL> "; - fputs(prompt, stdout); - fflush(stdout); - if (!fgets(p, n, stdin)) - goto end; - if (p[0] == '\0') - goto end; - i = strlen(p); - if (i <= 1) - break; - if (p[i - 2] != '\\') - break; - i -= 2; - p += i; - n -= i; - } - if (!chopup_args(&arg, buf, &argc, &argv)) - break; - - ret = do_cmd(prog, argc, argv); - if (ret < 0) { - ret = 0; - goto end; - } - if (ret != 0) - BIO_printf(bio_err, "error in %s\n", argv[0]); - (void) BIO_flush(bio_err); - } - BIO_printf(bio_err, "bad exit\n"); - ret = 1; end: free(to_free); @@ -556,12 +497,11 @@ static int do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]) { FUNCTION f, *fp; - int i, ret = 1, tp, nl; + int ret = 1; + + if (argc <= 0 || argv[0] == NULL) + return 0; - if ((argc <= 0) || (argv[0] == NULL)) { - ret = 0; - goto end; - } f.name = argv[0]; fp = lh_FUNCTION_retrieve(prog, &f); if (fp == NULL) { @@ -575,9 +515,16 @@ do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]) fp = &f; } } - if (fp != NULL) { - ret = fp->func(argc, argv); - } else if ((strncmp(argv[0], "no-", 3)) == 0) { + + if (fp != NULL) + return fp->func(argc, argv); + + if (strcmp(argv[0], "help") == 0) { + print_help(); + return 0; + } + + if ((strncmp(argv[0], "no-", 3)) == 0) { BIO *bio_stdout = BIO_new_fp(stdout, BIO_NOCLOSE); f.name = argv[0] + 3; ret = (lh_FUNCTION_retrieve(prog, &f) != NULL); @@ -586,14 +533,10 @@ do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]) else BIO_printf(bio_stdout, "%s\n", argv[0] + 3); BIO_free_all(bio_stdout); - goto end; - } else if ((strcmp(argv[0], "quit") == 0) || - (strcmp(argv[0], "q") == 0) || - (strcmp(argv[0], "exit") == 0) || - (strcmp(argv[0], "bye") == 0)) { - ret = -1; - goto end; - } else if ((strcmp(argv[0], LIST_STANDARD_COMMANDS) == 0) || + return ret; + } + + if ((strcmp(argv[0], LIST_STANDARD_COMMANDS) == 0) || (strcmp(argv[0], LIST_MESSAGE_DIGEST_COMMANDS) == 0) || (strcmp(argv[0], LIST_MESSAGE_DIGEST_ALGORITHMS) == 0) || (strcmp(argv[0], LIST_CIPHER_COMMANDS) == 0) || @@ -629,50 +572,58 @@ do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]) fp->name); } BIO_free_all(bio_stdout); - ret = 0; - goto end; - } else { - BIO_printf(bio_err, - "openssl:Error: '%s' is an invalid command.\n", - argv[0]); - BIO_printf(bio_err, "\nStandard commands"); - i = 0; - tp = 0; - for (fp = functions; fp->name != NULL; fp++) { - nl = 0; + return 0; + } + + BIO_printf(bio_err, + "openssl:Error: '%s' is an invalid command.\n", + argv[0]); + print_help(); + + return 1; +} + +static void +print_help(void) +{ + FUNCTION *fp; + int i = 0; + int tp = 0; + int nl; + + BIO_printf(bio_err, "\nStandard commands"); + for (fp = functions; fp->name != NULL; fp++) { + nl = 0; #ifdef OPENSSL_NO_CAMELLIA - if (((i++) % 5) == 0) + if (((i++) % 5) == 0) #else - if (((i++) % 4) == 0) + if (((i++) % 4) == 0) #endif - { + { + BIO_printf(bio_err, "\n"); + nl = 1; + } + if (fp->type != tp) { + tp = fp->type; + if (!nl) BIO_printf(bio_err, "\n"); - nl = 1; - } - if (fp->type != tp) { - tp = fp->type; - if (!nl) - BIO_printf(bio_err, "\n"); - if (tp == FUNC_TYPE_MD) { - i = 1; - BIO_printf(bio_err, - "\nMessage Digest commands (see the `dgst' command for more details)\n"); - } else if (tp == FUNC_TYPE_CIPHER) { - i = 1; - BIO_printf(bio_err, "\nCipher commands (see the `enc' command for more details)\n"); - } + if (tp == FUNC_TYPE_MD) { + i = 1; + BIO_printf(bio_err, + "\nMessage Digest commands (see the `dgst' command for more details)\n"); + } else if (tp == FUNC_TYPE_CIPHER) { + i = 1; + BIO_printf(bio_err, "\nCipher commands (see the `enc' command for more details)\n"); } + } #ifdef OPENSSL_NO_CAMELLIA - BIO_printf(bio_err, "%-15s", fp->name); + BIO_printf(bio_err, "%-15s", fp->name); #else - BIO_printf(bio_err, "%-18s", fp->name); + BIO_printf(bio_err, "%-18s", fp->name); #endif - } - BIO_printf(bio_err, "\n\n"); - ret = 0; } - end: - return (ret); + + BIO_printf(bio_err, "\n\n"); } static int diff --git a/apps/openssl/passwd.c b/apps/openssl/passwd.c index 11b43d65..a8dfa27d 100644 --- a/apps/openssl/passwd.c +++ b/apps/openssl/passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: passwd.c,v 1.12 2021/12/12 20:40:25 tb Exp $ */ +/* $OpenBSD: passwd.c,v 1.14 2023/03/06 14:32:06 tb Exp $ */ #if defined OPENSSL_NO_MD5 #define NO_MD5CRYPT_1 @@ -51,7 +51,7 @@ static struct { int use1; int useapr1; int usecrypt; -} passwd_config; +} cfg; static const struct option passwd_options[] = { #ifndef NO_MD5CRYPT_1 @@ -59,13 +59,13 @@ static const struct option passwd_options[] = { .name = "1", .desc = "Use MD5 based BSD password algorithm 1", .type = OPTION_FLAG, - .opt.flag = &passwd_config.use1, + .opt.flag = &cfg.use1, }, { .name = "apr1", .desc = "Use apr1 algorithm (Apache variant of BSD algorithm)", .type = OPTION_FLAG, - .opt.flag = &passwd_config.useapr1, + .opt.flag = &cfg.useapr1, }, #endif #ifndef OPENSSL_NO_DES @@ -73,7 +73,7 @@ static const struct option passwd_options[] = { .name = "crypt", .desc = "Use crypt algorithm (default)", .type = OPTION_FLAG, - .opt.flag = &passwd_config.usecrypt, + .opt.flag = &cfg.usecrypt, }, #endif { @@ -81,44 +81,44 @@ static const struct option passwd_options[] = { .argname = "file", .desc = "Read passwords from specified file", .type = OPTION_ARG, - .opt.arg = &passwd_config.infile, + .opt.arg = &cfg.infile, }, { .name = "noverify", .desc = "Do not verify password", .type = OPTION_FLAG, - .opt.flag = &passwd_config.noverify, + .opt.flag = &cfg.noverify, }, { .name = "quiet", .desc = "Do not output warnings", .type = OPTION_FLAG, - .opt.flag = &passwd_config.quiet, + .opt.flag = &cfg.quiet, }, { .name = "reverse", .desc = "Reverse table columns (requires -table)", .type = OPTION_FLAG, - .opt.flag = &passwd_config.reverse, + .opt.flag = &cfg.reverse, }, { .name = "salt", .argname = "string", .desc = "Use specified salt", .type = OPTION_ARG, - .opt.arg = &passwd_config.salt, + .opt.arg = &cfg.salt, }, { .name = "stdin", .desc = "Read passwords from stdin", .type = OPTION_FLAG, - .opt.flag = &passwd_config.in_stdin, + .opt.flag = &cfg.in_stdin, }, { .name = "table", .desc = "Output cleartext and hashed passwords (tab separated)", .type = OPTION_FLAG, - .opt.flag = &passwd_config.table, + .opt.flag = &cfg.table, }, { NULL }, }; @@ -145,14 +145,12 @@ passwd_main(int argc, char **argv) int argsused; int ret = 1; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&passwd_config, 0, sizeof(passwd_config)); + memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, passwd_options, NULL, &argsused) != 0) { passwd_usage(); @@ -161,23 +159,23 @@ passwd_main(int argc, char **argv) if (argsused < argc) passwds = &argv[argsused]; - if (passwd_config.salt != NULL) + if (cfg.salt != NULL) passed_salt = 1; - if (!passwd_config.usecrypt && !passwd_config.use1 && - !passwd_config.useapr1) - passwd_config.usecrypt = 1; /* use default */ - if (passwd_config.usecrypt + passwd_config.use1 + - passwd_config.useapr1 > 1) + if (!cfg.usecrypt && !cfg.use1 && + !cfg.useapr1) + cfg.usecrypt = 1; /* use default */ + if (cfg.usecrypt + cfg.use1 + + cfg.useapr1 > 1) badopt = 1; /* conflicting options */ /* Reject unsupported algorithms */ #ifdef OPENSSL_NO_DES - if (passwd_config.usecrypt) + if (cfg.usecrypt) badopt = 1; #endif #ifdef NO_MD5CRYPT_1 - if (passwd_config.use1 || passwd_config.useapr1) + if (cfg.use1 || cfg.useapr1) badopt = 1; #endif @@ -190,21 +188,21 @@ passwd_main(int argc, char **argv) goto err; BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); - if (passwd_config.infile != NULL || passwd_config.in_stdin) { + if (cfg.infile != NULL || cfg.in_stdin) { if ((in = BIO_new(BIO_s_file())) == NULL) goto err; - if (passwd_config.infile != NULL) { - assert(passwd_config.in_stdin == 0); - if (BIO_read_filename(in, passwd_config.infile) <= 0) + if (cfg.infile != NULL) { + assert(cfg.in_stdin == 0); + if (BIO_read_filename(in, cfg.infile) <= 0) goto err; } else { - assert(passwd_config.in_stdin); + assert(cfg.in_stdin); BIO_set_fp(in, stdin, BIO_NOCLOSE); } } - if (passwd_config.usecrypt) + if (cfg.usecrypt) pw_maxlen = 8; - else if (passwd_config.use1 || passwd_config.useapr1) + else if (cfg.use1 || cfg.useapr1) pw_maxlen = 256;/* arbitrary limit, should be enough for most * passwords */ @@ -225,7 +223,7 @@ passwd_main(int argc, char **argv) if (in == NULL) if (EVP_read_pw_string(passwd_malloc, passwd_malloc_size, "Password: ", - !(passed_salt || passwd_config.noverify)) != 0) + !(passed_salt || cfg.noverify)) != 0) goto err; passwds[0] = passwd_malloc; } @@ -235,11 +233,11 @@ passwd_main(int argc, char **argv) do { /* loop over list of passwords */ passwd = *passwds++; - if (!do_passwd(passed_salt, &passwd_config.salt, - &salt_malloc, passwd, out, passwd_config.quiet, - passwd_config.table, passwd_config.reverse, - pw_maxlen, passwd_config.usecrypt, - passwd_config.use1, passwd_config.useapr1)) + if (!do_passwd(passed_salt, &cfg.salt, + &salt_malloc, passwd, out, cfg.quiet, + cfg.table, cfg.reverse, + pw_maxlen, cfg.usecrypt, + cfg.use1, cfg.useapr1)) goto err; } while (*passwds != NULL); } else { @@ -260,12 +258,12 @@ passwd_main(int argc, char **argv) while ((r > 0) && (!strchr(trash, '\n'))); } - if (!do_passwd(passed_salt, &passwd_config.salt, + if (!do_passwd(passed_salt, &cfg.salt, &salt_malloc, passwd, out, - passwd_config.quiet, passwd_config.table, - passwd_config.reverse, pw_maxlen, - passwd_config.usecrypt, passwd_config.use1, - passwd_config.useapr1)) + cfg.quiet, cfg.table, + cfg.reverse, pw_maxlen, + cfg.usecrypt, cfg.use1, + cfg.useapr1)) goto err; } done = (r <= 0); diff --git a/apps/openssl/pkcs12.c b/apps/openssl/pkcs12.c index fb8a1f0e..aedae640 100644 --- a/apps/openssl/pkcs12.c +++ b/apps/openssl/pkcs12.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkcs12.c,v 1.23 2022/09/14 16:31:36 tb Exp $ */ +/* $OpenBSD: pkcs12.c,v 1.25 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -118,16 +118,16 @@ static struct { char *passargin; char *passargout; int twopass; -} pkcs12_config; +} cfg; static int pkcs12_opt_canames(char *arg) { - if (pkcs12_config.canames == NULL && - (pkcs12_config.canames = sk_OPENSSL_STRING_new_null()) == NULL) + if (cfg.canames == NULL && + (cfg.canames = sk_OPENSSL_STRING_new_null()) == NULL) return (1); - if (!sk_OPENSSL_STRING_push(pkcs12_config.canames, arg)) + if (!sk_OPENSSL_STRING_push(cfg.canames, arg)) return (1); return (0); @@ -136,20 +136,20 @@ pkcs12_opt_canames(char *arg) static int pkcs12_opt_cert_pbe(char *arg) { - return (!set_pbe(bio_err, &pkcs12_config.cert_pbe, arg)); + return (!set_pbe(bio_err, &cfg.cert_pbe, arg)); } static int pkcs12_opt_key_pbe(char *arg) { - return (!set_pbe(bio_err, &pkcs12_config.key_pbe, arg)); + return (!set_pbe(bio_err, &cfg.key_pbe, arg)); } static int pkcs12_opt_passarg(char *arg) { - pkcs12_config.passarg = arg; - pkcs12_config.noprompt = 1; + cfg.passarg = arg; + cfg.noprompt = 1; return (0); } @@ -196,8 +196,8 @@ pkcs12_opt_enc(int argc, char **argv, int *argsused) return (1); if (strcmp(name, "nodes") == 0) - pkcs12_config.enc = NULL; - else if ((pkcs12_config.enc = get_cipher_by_name(name)) == NULL) + cfg.enc = NULL; + else if ((cfg.enc = get_cipher_by_name(name)) == NULL) return (1); *argsused = 1; @@ -269,7 +269,7 @@ static const struct option pkcs12_options[] = { .name = "cacerts", .desc = "Only output CA certificates", .type = OPTION_VALUE_OR, - .opt.value = &pkcs12_config.options, + .opt.value = &cfg.options, .value = CACERTS, }, { @@ -277,7 +277,7 @@ static const struct option pkcs12_options[] = { .argname = "file", .desc = "PEM format file of CA certificates", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.CAfile, + .opt.arg = &cfg.CAfile, }, { .name = "caname", @@ -291,14 +291,14 @@ static const struct option pkcs12_options[] = { .argname = "directory", .desc = "PEM format directory of CA certificates", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.CApath, + .opt.arg = &cfg.CApath, }, { .name = "certfile", .argname = "file", .desc = "Add all certs in file", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.certfile, + .opt.arg = &cfg.certfile, }, { .name = "certpbe", @@ -311,13 +311,13 @@ static const struct option pkcs12_options[] = { .name = "chain", .desc = "Add certificate chain", .type = OPTION_FLAG, - .opt.flag = &pkcs12_config.chain, + .opt.flag = &cfg.chain, }, { .name = "clcerts", .desc = "Only output client certificates", .type = OPTION_VALUE_OR, - .opt.value = &pkcs12_config.options, + .opt.value = &cfg.options, .value = CLCERTS, }, { @@ -325,33 +325,33 @@ static const struct option pkcs12_options[] = { .argname = "name", .desc = "Microsoft CSP name", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.csp_name, + .opt.arg = &cfg.csp_name, }, { .name = "descert", .desc = "Encrypt PKCS#12 certificates with triple DES (default RC2-40)", .type = OPTION_VALUE, - .opt.value = &pkcs12_config.cert_pbe, + .opt.value = &cfg.cert_pbe, .value = NID_pbe_WithSHA1And3_Key_TripleDES_CBC, }, { .name = "export", .desc = "Output PKCS#12 file", .type = OPTION_FLAG, - .opt.flag = &pkcs12_config.export_cert, + .opt.flag = &cfg.export_cert, }, { .name = "in", .argname = "file", .desc = "Input filename", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.infile, + .opt.arg = &cfg.infile, }, { .name = "info", .desc = "Give info about PKCS#12 structure", .type = OPTION_VALUE_OR, - .opt.value = &pkcs12_config.options, + .opt.value = &cfg.options, .value = INFO, }, { @@ -359,13 +359,13 @@ static const struct option pkcs12_options[] = { .argname = "file", .desc = "Private key if not infile", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.keyname, + .opt.arg = &cfg.keyname, }, { .name = "keyex", .desc = "Set MS key exchange type", .type = OPTION_VALUE, - .opt.value = &pkcs12_config.keytype, + .opt.value = &cfg.keytype, .value = KEY_EX, }, { @@ -379,27 +379,27 @@ static const struct option pkcs12_options[] = { .name = "keysig", .desc = "Set MS key signature type", .type = OPTION_VALUE, - .opt.value = &pkcs12_config.keytype, + .opt.value = &cfg.keytype, .value = KEY_SIG, }, { .name = "LMK", .desc = "Add local machine keyset attribute to private key", .type = OPTION_FLAG, - .opt.flag = &pkcs12_config.add_lmk, + .opt.flag = &cfg.add_lmk, }, { .name = "macalg", .argname = "alg", .desc = "Digest algorithm used in MAC (default SHA1)", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.macalg, + .opt.arg = &cfg.macalg, }, { .name = "maciter", .desc = "Use MAC iteration", .type = OPTION_VALUE, - .opt.value = &pkcs12_config.maciter, + .opt.value = &cfg.maciter, .value = PKCS12_DEFAULT_ITER, }, { @@ -407,13 +407,13 @@ static const struct option pkcs12_options[] = { .argname = "name", .desc = "Use name as friendly name", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.name, + .opt.arg = &cfg.name, }, { .name = "nocerts", .desc = "Don't output certificates", .type = OPTION_VALUE_OR, - .opt.value = &pkcs12_config.options, + .opt.value = &cfg.options, .value = NOCERTS, }, { @@ -426,42 +426,42 @@ static const struct option pkcs12_options[] = { .name = "noiter", .desc = "Don't use encryption iteration", .type = OPTION_VALUE, - .opt.value = &pkcs12_config.iter, + .opt.value = &cfg.iter, .value = 1, }, { .name = "nokeys", .desc = "Don't output private keys", .type = OPTION_VALUE_OR, - .opt.value = &pkcs12_config.options, + .opt.value = &cfg.options, .value = NOKEYS, }, { .name = "nomac", .desc = "Don't generate MAC", .type = OPTION_VALUE, - .opt.value = &pkcs12_config.maciter, + .opt.value = &cfg.maciter, .value = -1, }, { .name = "nomaciter", .desc = "Don't use MAC iteration", .type = OPTION_VALUE, - .opt.value = &pkcs12_config.maciter, + .opt.value = &cfg.maciter, .value = 1, }, { .name = "nomacver", .desc = "Don't verify MAC", .type = OPTION_VALUE, - .opt.value = &pkcs12_config.macver, + .opt.value = &cfg.macver, .value = 0, }, { .name = "noout", .desc = "Don't output anything, just verify", .type = OPTION_VALUE_OR, - .opt.value = &pkcs12_config.options, + .opt.value = &cfg.options, .value = (NOKEYS | NOCERTS), }, { @@ -469,21 +469,21 @@ static const struct option pkcs12_options[] = { .argname = "file", .desc = "Output filename", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "passin", .argname = "arg", .desc = "Input file passphrase source", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "passout", .argname = "arg", .desc = "Output file passphrase source", .type = OPTION_ARG, - .opt.arg = &pkcs12_config.passargout, + .opt.arg = &cfg.passargout, }, { .name = "password", @@ -496,7 +496,7 @@ static const struct option pkcs12_options[] = { .name = "twopass", .desc = "Separate MAC, encryption passwords", .type = OPTION_FLAG, - .opt.flag = &pkcs12_config.twopass, + .opt.flag = &cfg.twopass, }, { NULL }, }; @@ -536,80 +536,78 @@ pkcs12_main(int argc, char **argv) char *cpass = NULL, *mpass = NULL; char *passin = NULL, *passout = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&pkcs12_config, 0, sizeof(pkcs12_config)); - pkcs12_config.cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC; - pkcs12_config.enc = EVP_des_ede3_cbc(); - pkcs12_config.iter = PKCS12_DEFAULT_ITER; - pkcs12_config.key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; - pkcs12_config.maciter = PKCS12_DEFAULT_ITER; - pkcs12_config.macver = 1; + memset(&cfg, 0, sizeof(cfg)); + cfg.cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC; + cfg.enc = EVP_des_ede3_cbc(); + cfg.iter = PKCS12_DEFAULT_ITER; + cfg.key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; + cfg.maciter = PKCS12_DEFAULT_ITER; + cfg.macver = 1; if (options_parse(argc, argv, pkcs12_options, NULL, NULL) != 0) { pkcs12_usage(); goto end; } - if (pkcs12_config.passarg != NULL) { - if (pkcs12_config.export_cert) - pkcs12_config.passargout = pkcs12_config.passarg; + if (cfg.passarg != NULL) { + if (cfg.export_cert) + cfg.passargout = cfg.passarg; else - pkcs12_config.passargin = pkcs12_config.passarg; + cfg.passargin = cfg.passarg; } - if (!app_passwd(bio_err, pkcs12_config.passargin, - pkcs12_config.passargout, &passin, &passout)) { + if (!app_passwd(bio_err, cfg.passargin, + cfg.passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); goto end; } if (cpass == NULL) { - if (pkcs12_config.export_cert) + if (cfg.export_cert) cpass = passout; else cpass = passin; } if (cpass != NULL) { mpass = cpass; - pkcs12_config.noprompt = 1; + cfg.noprompt = 1; } else { cpass = pass; mpass = macpass; } - if (pkcs12_config.infile == NULL) + if (cfg.infile == NULL) in = BIO_new_fp(stdin, BIO_NOCLOSE); else - in = BIO_new_file(pkcs12_config.infile, "rb"); + in = BIO_new_file(cfg.infile, "rb"); if (in == NULL) { BIO_printf(bio_err, "Error opening input file %s\n", - pkcs12_config.infile ? pkcs12_config.infile : ""); - perror(pkcs12_config.infile); + cfg.infile ? cfg.infile : ""); + perror(cfg.infile); goto end; } - if (pkcs12_config.outfile == NULL) { + if (cfg.outfile == NULL) { out = BIO_new_fp(stdout, BIO_NOCLOSE); } else - out = BIO_new_file(pkcs12_config.outfile, "wb"); + out = BIO_new_file(cfg.outfile, "wb"); if (out == NULL) { BIO_printf(bio_err, "Error opening output file %s\n", - pkcs12_config.outfile ? pkcs12_config.outfile : ""); - perror(pkcs12_config.outfile); + cfg.outfile ? cfg.outfile : ""); + perror(cfg.outfile); goto end; } - if (pkcs12_config.twopass) { + if (cfg.twopass) { if (EVP_read_pw_string(macpass, sizeof macpass, - "Enter MAC Password:", pkcs12_config.export_cert)) { + "Enter MAC Password:", cfg.export_cert)) { BIO_printf(bio_err, "Can't read Password\n"); goto end; } } - if (pkcs12_config.export_cert) { + if (cfg.export_cert) { EVP_PKEY *key = NULL; X509 *ucert = NULL, *x = NULL; STACK_OF(X509) *certs = NULL; @@ -617,25 +615,25 @@ pkcs12_main(int argc, char **argv) unsigned char *catmp = NULL; int i; - if ((pkcs12_config.options & (NOCERTS | NOKEYS)) == + if ((cfg.options & (NOCERTS | NOKEYS)) == (NOCERTS | NOKEYS)) { BIO_printf(bio_err, "Nothing to do!\n"); goto export_end; } - if (pkcs12_config.options & NOCERTS) - pkcs12_config.chain = 0; + if (cfg.options & NOCERTS) + cfg.chain = 0; - if (!(pkcs12_config.options & NOKEYS)) { - key = load_key(bio_err, pkcs12_config.keyname ? - pkcs12_config.keyname : pkcs12_config.infile, + if (!(cfg.options & NOKEYS)) { + key = load_key(bio_err, cfg.keyname ? + cfg.keyname : cfg.infile, FORMAT_PEM, 1, passin, "private key"); if (!key) goto export_end; } /* Load in all certs in input file */ - if (!(pkcs12_config.options & NOCERTS)) { - certs = load_certs(bio_err, pkcs12_config.infile, + if (!(cfg.options & NOCERTS)) { + certs = load_certs(bio_err, cfg.infile, FORMAT_PEM, NULL, "certificates"); if (certs == NULL) goto export_end; @@ -663,10 +661,10 @@ pkcs12_main(int argc, char **argv) } /* Add any more certificates asked for */ - if (pkcs12_config.certfile != NULL) { + if (cfg.certfile != NULL) { STACK_OF(X509) *morecerts = NULL; if ((morecerts = load_certs(bio_err, - pkcs12_config.certfile, FORMAT_PEM, NULL, + cfg.certfile, FORMAT_PEM, NULL, "certificates from certfile")) == NULL) goto export_end; while (sk_X509_num(morecerts) > 0) @@ -676,7 +674,7 @@ pkcs12_main(int argc, char **argv) /* If chaining get chain from user cert */ - if (pkcs12_config.chain) { + if (cfg.chain) { int vret; STACK_OF(X509) *chain2; X509_STORE *store = X509_STORE_new(); @@ -686,7 +684,7 @@ pkcs12_main(int argc, char **argv) goto export_end; } if (!X509_STORE_load_locations(store, - pkcs12_config.CAfile, pkcs12_config.CApath)) + cfg.CAfile, cfg.CApath)) X509_STORE_set_default_paths(store); vret = get_cert_chain(ucert, store, &chain2); @@ -713,51 +711,51 @@ pkcs12_main(int argc, char **argv) } /* Add any CA names */ - for (i = 0; i < sk_OPENSSL_STRING_num(pkcs12_config.canames); + for (i = 0; i < sk_OPENSSL_STRING_num(cfg.canames); i++) { catmp = (unsigned char *) sk_OPENSSL_STRING_value( - pkcs12_config.canames, i); + cfg.canames, i); X509_alias_set1(sk_X509_value(certs, i), catmp, -1); } - if (pkcs12_config.csp_name != NULL && key != NULL) + if (cfg.csp_name != NULL && key != NULL) EVP_PKEY_add1_attr_by_NID(key, NID_ms_csp_name, MBSTRING_ASC, - (unsigned char *) pkcs12_config.csp_name, -1); + (unsigned char *) cfg.csp_name, -1); - if (pkcs12_config.add_lmk && key != NULL) + if (cfg.add_lmk && key != NULL) EVP_PKEY_add1_attr_by_NID(key, NID_LocalKeySet, 0, NULL, -1); - if (!pkcs12_config.noprompt && + if (!cfg.noprompt && EVP_read_pw_string(pass, sizeof pass, "Enter Export Password:", 1)) { BIO_printf(bio_err, "Can't read Password\n"); goto export_end; } - if (!pkcs12_config.twopass) + if (!cfg.twopass) strlcpy(macpass, pass, sizeof macpass); - p12 = PKCS12_create(cpass, pkcs12_config.name, key, ucert, - certs, pkcs12_config.key_pbe, pkcs12_config.cert_pbe, - pkcs12_config.iter, -1, pkcs12_config.keytype); + p12 = PKCS12_create(cpass, cfg.name, key, ucert, + certs, cfg.key_pbe, cfg.cert_pbe, + cfg.iter, -1, cfg.keytype); if (p12 == NULL) { ERR_print_errors(bio_err); goto export_end; } - if (pkcs12_config.macalg != NULL) { - macmd = EVP_get_digestbyname(pkcs12_config.macalg); + if (cfg.macalg != NULL) { + macmd = EVP_get_digestbyname(cfg.macalg); if (macmd == NULL) { BIO_printf(bio_err, "Unknown digest algorithm %s\n", - pkcs12_config.macalg); + cfg.macalg); } } - if (pkcs12_config.maciter != -1) + if (cfg.maciter != -1) PKCS12_set_mac(p12, mpass, -1, NULL, 0, - pkcs12_config.maciter, macmd); + cfg.maciter, macmd); i2d_PKCS12_bio(out, p12); @@ -775,27 +773,27 @@ pkcs12_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (!pkcs12_config.noprompt && EVP_read_pw_string(pass, sizeof pass, + if (!cfg.noprompt && EVP_read_pw_string(pass, sizeof pass, "Enter Import Password:", 0)) { BIO_printf(bio_err, "Can't read Password\n"); goto end; } - if (!pkcs12_config.twopass) + if (!cfg.twopass) strlcpy(macpass, pass, sizeof macpass); - if ((pkcs12_config.options & INFO) != 0 && PKCS12_mac_present(p12)) { + if ((cfg.options & INFO) != 0 && PKCS12_mac_present(p12)) { const ASN1_INTEGER *iter; PKCS12_get0_mac(NULL, NULL, NULL, &iter, p12); BIO_printf(bio_err, "MAC Iteration %ld\n", iter != NULL ? ASN1_INTEGER_get(iter) : 1); } - if (pkcs12_config.macver) { + if (cfg.macver) { /* If we enter empty password try no password first */ if (!mpass[0] && PKCS12_verify_mac(p12, NULL, 0)) { /* If mac and crypto pass the same set it to NULL too */ - if (!pkcs12_config.twopass) + if (!cfg.twopass) cpass = NULL; } else if (!PKCS12_verify_mac(p12, mpass, -1)) { BIO_printf(bio_err, @@ -805,7 +803,7 @@ pkcs12_main(int argc, char **argv) } BIO_printf(bio_err, "MAC verified OK\n"); } - if (!dump_certs_keys_p12(out, p12, cpass, -1, pkcs12_config.options, + if (!dump_certs_keys_p12(out, p12, cpass, -1, cfg.options, passout)) { BIO_printf(bio_err, "Error outputting keys and certificates\n"); ERR_print_errors(bio_err); @@ -816,7 +814,7 @@ pkcs12_main(int argc, char **argv) PKCS12_free(p12); BIO_free(in); BIO_free_all(out); - sk_OPENSSL_STRING_free(pkcs12_config.canames); + sk_OPENSSL_STRING_free(cfg.canames); free(passin); free(passout); @@ -909,7 +907,7 @@ dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass, int passlen, if ((pkey = EVP_PKCS82PKEY(p8)) == NULL) return 0; print_attribs(out, PKCS8_pkey_get0_attrs(p8), "Key Attributes"); - PEM_write_bio_PrivateKey(out, pkey, pkcs12_config.enc, NULL, 0, + PEM_write_bio_PrivateKey(out, pkey, cfg.enc, NULL, 0, NULL, pempass); EVP_PKEY_free(pkey); break; @@ -940,7 +938,7 @@ dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass, int passlen, } print_attribs(out, PKCS8_pkey_get0_attrs(p8), "Key Attributes"); PKCS8_PRIV_KEY_INFO_free(p8); - PEM_write_bio_PrivateKey(out, pkey, pkcs12_config.enc, NULL, 0, + PEM_write_bio_PrivateKey(out, pkey, cfg.enc, NULL, 0, NULL, pempass); EVP_PKEY_free(pkey); break; diff --git a/apps/openssl/pkcs7.c b/apps/openssl/pkcs7.c index 4c184911..4e66855a 100644 --- a/apps/openssl/pkcs7.c +++ b/apps/openssl/pkcs7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkcs7.c,v 1.11 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: pkcs7.c,v 1.14 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -79,7 +79,7 @@ static struct { int p7_print; int print_certs; int text; -} pkcs7_config; +} cfg; static const struct option pkcs7_options[] = { { @@ -87,52 +87,52 @@ static const struct option pkcs7_options[] = { .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &pkcs7_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &pkcs7_config.informat, + .opt.value = &cfg.informat, }, { .name = "noout", .desc = "Do not output encoded version of PKCS#7 structure", .type = OPTION_FLAG, - .opt.flag = &pkcs7_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &pkcs7_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &pkcs7_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "print", .desc = "Output ASN.1 representation of PKCS#7 structure", .type = OPTION_FLAG, - .opt.flag = &pkcs7_config.p7_print, + .opt.flag = &cfg.p7_print, }, { .name = "print_certs", .desc = "Print out any certificates or CRLs contained in file", .type = OPTION_FLAG, - .opt.flag = &pkcs7_config.print_certs, + .opt.flag = &cfg.print_certs, }, { .name = "text", .desc = "Print out full certificate details", .type = OPTION_FLAG, - .opt.flag = &pkcs7_config.text, + .opt.flag = &cfg.text, }, { NULL }, }; @@ -154,17 +154,15 @@ pkcs7_main(int argc, char **argv) int ret = 1; int i; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&pkcs7_config, 0, sizeof(pkcs7_config)); + memset(&cfg, 0, sizeof(cfg)); - pkcs7_config.informat = FORMAT_PEM; - pkcs7_config.outformat = FORMAT_PEM; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, pkcs7_options, NULL, NULL) != 0) { pkcs7_usage(); @@ -177,18 +175,18 @@ pkcs7_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (pkcs7_config.infile == NULL) + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, pkcs7_config.infile) <= 0) { - perror(pkcs7_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } - if (pkcs7_config.informat == FORMAT_ASN1) + if (cfg.informat == FORMAT_ASN1) p7 = d2i_PKCS7_bio(in, NULL); - else if (pkcs7_config.informat == FORMAT_PEM) + else if (cfg.informat == FORMAT_PEM) p7 = PEM_read_bio_PKCS7(in, NULL, NULL, NULL); else { BIO_printf(bio_err, "bad input format specified for pkcs7 object\n"); @@ -199,31 +197,35 @@ pkcs7_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (pkcs7_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, pkcs7_config.outfile) <= 0) { - perror(pkcs7_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } - if (pkcs7_config.p7_print) + if (cfg.p7_print) PKCS7_print_ctx(out, p7, 0, NULL); - if (pkcs7_config.print_certs) { + if (cfg.print_certs) { STACK_OF(X509) * certs = NULL; STACK_OF(X509_CRL) * crls = NULL; i = OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signed: - certs = p7->d.sign->cert; - crls = p7->d.sign->crl; + if (p7->d.sign != NULL) { + certs = p7->d.sign->cert; + crls = p7->d.sign->crl; + } break; case NID_pkcs7_signedAndEnveloped: - certs = p7->d.signed_and_enveloped->cert; - crls = p7->d.signed_and_enveloped->crl; + if (p7->d.signed_and_enveloped != NULL) { + certs = p7->d.signed_and_enveloped->cert; + crls = p7->d.signed_and_enveloped->crl; + } break; default: break; @@ -234,12 +236,12 @@ pkcs7_main(int argc, char **argv) for (i = 0; i < sk_X509_num(certs); i++) { x = sk_X509_value(certs, i); - if (pkcs7_config.text) + if (cfg.text) X509_print(out, x); else dump_cert_text(out, x); - if (!pkcs7_config.noout) + if (!cfg.noout) PEM_write_bio_X509(out, x); BIO_puts(out, "\n"); } @@ -252,7 +254,7 @@ pkcs7_main(int argc, char **argv) X509_CRL_print(out, crl); - if (!pkcs7_config.noout) + if (!cfg.noout) PEM_write_bio_X509_CRL(out, crl); BIO_puts(out, "\n"); } @@ -260,10 +262,10 @@ pkcs7_main(int argc, char **argv) ret = 0; goto end; } - if (!pkcs7_config.noout) { - if (pkcs7_config.outformat == FORMAT_ASN1) + if (!cfg.noout) { + if (cfg.outformat == FORMAT_ASN1) i = i2d_PKCS7_bio(out, p7); - else if (pkcs7_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_PKCS7(out, p7); else { BIO_printf(bio_err, "bad output format specified for outfile\n"); diff --git a/apps/openssl/pkcs8.c b/apps/openssl/pkcs8.c index 0629b20c..d78202e0 100644 --- a/apps/openssl/pkcs8.c +++ b/apps/openssl/pkcs8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkcs8.c,v 1.14 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: pkcs8.c,v 1.16 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999-2004. */ @@ -79,12 +79,12 @@ static struct { char *passargout; int pbe_nid; int topk8; -} pkcs8_config; +} cfg; static int pkcs8_opt_v1(char *arg) { - if ((pkcs8_config.pbe_nid = OBJ_txt2nid(arg)) == NID_undef) { + if ((cfg.pbe_nid = OBJ_txt2nid(arg)) == NID_undef) { fprintf(stderr, "Unknown PBE algorithm '%s'\n", arg); return (1); } @@ -95,7 +95,7 @@ pkcs8_opt_v1(char *arg) static int pkcs8_opt_v2(char *arg) { - if ((pkcs8_config.cipher = EVP_get_cipherbyname(arg)) == NULL) { + if ((cfg.cipher = EVP_get_cipherbyname(arg)) == NULL) { fprintf(stderr, "Unknown cipher '%s'\n", arg); return (1); } @@ -109,62 +109,62 @@ static const struct option pkcs8_options[] = { .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &pkcs8_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "der | pem", .desc = "Input format (default PEM)", .type = OPTION_ARG_FORMAT, - .opt.value = &pkcs8_config.informat, + .opt.value = &cfg.informat, }, { .name = "nocrypt", .desc = "Use or expect unencrypted private key", .type = OPTION_FLAG, - .opt.flag = &pkcs8_config.nocrypt, + .opt.flag = &cfg.nocrypt, }, { .name = "noiter", .desc = "Use 1 as iteration count", .type = OPTION_VALUE, .value = 1, - .opt.value = &pkcs8_config.iter, + .opt.value = &cfg.iter, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &pkcs8_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "der | pem", .desc = "Output format (default PEM)", .type = OPTION_ARG_FORMAT, - .opt.value = &pkcs8_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "passin", .argname = "source", .desc = "Input file passphrase source", .type = OPTION_ARG, - .opt.arg = &pkcs8_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "passout", .argname = "source", .desc = "Output file passphrase source", .type = OPTION_ARG, - .opt.arg = &pkcs8_config.passargout, + .opt.arg = &cfg.passargout, }, { .name = "topk8", .desc = "Read traditional format key and write PKCS#8 format" " key", .type = OPTION_FLAG, - .opt.flag = &pkcs8_config.topk8, + .opt.flag = &cfg.topk8, }, { .name = "v1", @@ -203,55 +203,53 @@ pkcs8_main(int argc, char **argv) char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL; int ret = 1; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&pkcs8_config, 0, sizeof(pkcs8_config)); + memset(&cfg, 0, sizeof(cfg)); - pkcs8_config.iter = PKCS12_DEFAULT_ITER; - pkcs8_config.informat = FORMAT_PEM; - pkcs8_config.outformat = FORMAT_PEM; - pkcs8_config.pbe_nid = -1; + cfg.iter = PKCS12_DEFAULT_ITER; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; + cfg.pbe_nid = -1; if (options_parse(argc, argv, pkcs8_options, NULL, NULL) != 0) { pkcs8_usage(); return (1); } - if (!app_passwd(bio_err, pkcs8_config.passargin, - pkcs8_config.passargout, &passin, &passout)) { + if (!app_passwd(bio_err, cfg.passargin, + cfg.passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); goto end; } - if ((pkcs8_config.pbe_nid == -1) && !pkcs8_config.cipher) - pkcs8_config.pbe_nid = NID_pbeWithMD5AndDES_CBC; + if ((cfg.pbe_nid == -1) && !cfg.cipher) + cfg.pbe_nid = NID_pbeWithMD5AndDES_CBC; - if (pkcs8_config.infile) { - if (!(in = BIO_new_file(pkcs8_config.infile, "rb"))) { + if (cfg.infile) { + if (!(in = BIO_new_file(cfg.infile, "rb"))) { BIO_printf(bio_err, "Can't open input file '%s'\n", - pkcs8_config.infile); + cfg.infile); goto end; } } else in = BIO_new_fp(stdin, BIO_NOCLOSE); - if (pkcs8_config.outfile) { - if (!(out = BIO_new_file(pkcs8_config.outfile, "wb"))) { + if (cfg.outfile) { + if (!(out = BIO_new_file(cfg.outfile, "wb"))) { BIO_printf(bio_err, "Can't open output file '%s'\n", - pkcs8_config.outfile); + cfg.outfile); goto end; } } else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } - if (pkcs8_config.topk8) { - pkey = load_key(bio_err, pkcs8_config.infile, - pkcs8_config.informat, 1, passin, "key"); + if (cfg.topk8) { + pkey = load_key(bio_err, cfg.infile, + cfg.informat, 1, passin, "key"); if (!pkey) goto end; if (!(p8inf = EVP_PKEY2PKCS8(pkey))) { @@ -259,10 +257,10 @@ pkcs8_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (pkcs8_config.nocrypt) { - if (pkcs8_config.outformat == FORMAT_PEM) + if (cfg.nocrypt) { + if (cfg.outformat == FORMAT_PEM) PEM_write_bio_PKCS8_PRIV_KEY_INFO(out, p8inf); - else if (pkcs8_config.outformat == FORMAT_ASN1) + else if (cfg.outformat == FORMAT_ASN1) i2d_PKCS8_PRIV_KEY_INFO_bio(out, p8inf); else { BIO_printf(bio_err, @@ -278,16 +276,16 @@ pkcs8_main(int argc, char **argv) "Enter Encryption Password:", 1)) goto end; } - if (!(p8 = PKCS8_encrypt(pkcs8_config.pbe_nid, - pkcs8_config.cipher, p8pass, strlen(p8pass), - NULL, 0, pkcs8_config.iter, p8inf))) { + if (!(p8 = PKCS8_encrypt(cfg.pbe_nid, + cfg.cipher, p8pass, strlen(p8pass), + NULL, 0, cfg.iter, p8inf))) { BIO_printf(bio_err, "Error encrypting key\n"); ERR_print_errors(bio_err); goto end; } - if (pkcs8_config.outformat == FORMAT_PEM) + if (cfg.outformat == FORMAT_PEM) PEM_write_bio_PKCS8(out, p8); - else if (pkcs8_config.outformat == FORMAT_ASN1) + else if (cfg.outformat == FORMAT_ASN1) i2d_PKCS8_bio(out, p8); else { BIO_printf(bio_err, @@ -299,20 +297,20 @@ pkcs8_main(int argc, char **argv) ret = 0; goto end; } - if (pkcs8_config.nocrypt) { - if (pkcs8_config.informat == FORMAT_PEM) + if (cfg.nocrypt) { + if (cfg.informat == FORMAT_PEM) p8inf = PEM_read_bio_PKCS8_PRIV_KEY_INFO(in, NULL, NULL, NULL); - else if (pkcs8_config.informat == FORMAT_ASN1) + else if (cfg.informat == FORMAT_ASN1) p8inf = d2i_PKCS8_PRIV_KEY_INFO_bio(in, NULL); else { BIO_printf(bio_err, "Bad format specified for key\n"); goto end; } } else { - if (pkcs8_config.informat == FORMAT_PEM) + if (cfg.informat == FORMAT_PEM) p8 = PEM_read_bio_PKCS8(in, NULL, NULL, NULL); - else if (pkcs8_config.informat == FORMAT_ASN1) + else if (cfg.informat == FORMAT_ASN1) p8 = d2i_PKCS8_bio(in, NULL); else { BIO_printf(bio_err, "Bad format specified for key\n"); @@ -344,10 +342,10 @@ pkcs8_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (pkcs8_config.outformat == FORMAT_PEM) + if (cfg.outformat == FORMAT_PEM) PEM_write_bio_PrivateKey(out, pkey, NULL, NULL, 0, NULL, passout); - else if (pkcs8_config.outformat == FORMAT_ASN1) + else if (cfg.outformat == FORMAT_ASN1) i2d_PrivateKey_bio(out, pkey); else { BIO_printf(bio_err, "Bad format specified for key\n"); diff --git a/apps/openssl/pkey.c b/apps/openssl/pkey.c index dcddd976..cb558f5a 100644 --- a/apps/openssl/pkey.c +++ b/apps/openssl/pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkey.c,v 1.17 2022/01/14 10:17:30 tb Exp $ */ +/* $OpenBSD: pkey.c,v 1.19 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006 */ @@ -80,7 +80,7 @@ static struct { int pubout; int pubtext; int text; -} pkey_config; +} cfg; static int pkey_opt_cipher(int argc, char **argv, int *argsused) @@ -90,7 +90,7 @@ pkey_opt_cipher(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((pkey_config.cipher = EVP_get_cipherbyname(name)) == NULL) { + if ((cfg.cipher = EVP_get_cipherbyname(name)) == NULL) { BIO_printf(bio_err, "Unknown cipher %s\n", name); return (1); } @@ -104,87 +104,87 @@ static const struct option pkey_options[] = { .name = "check", .desc = "Check validity of key", .type = OPTION_FLAG, - .opt.flag = &pkey_config.check, + .opt.flag = &cfg.check, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &pkey_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &pkey_config.informat, + .opt.value = &cfg.informat, }, { .name = "noout", .desc = "Do not print encoded version of the key", .type = OPTION_FLAG, - .opt.flag = &pkey_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &pkey_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &pkey_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "passin", .argname = "src", .desc = "Input file passphrase source", .type = OPTION_ARG, - .opt.arg = &pkey_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "passout", .argname = "src", .desc = "Output file passphrase source", .type = OPTION_ARG, - .opt.arg = &pkey_config.passargout, + .opt.arg = &cfg.passargout, }, { .name = "pubcheck", .desc = "Check validity of public key", .type = OPTION_FLAG, - .opt.flag = &pkey_config.pubcheck, + .opt.flag = &cfg.pubcheck, }, { .name = "pubin", .desc = "Expect a public key (default private key)", .type = OPTION_VALUE, .value = 1, - .opt.value = &pkey_config.pubin, + .opt.value = &cfg.pubin, }, { .name = "pubout", .desc = "Output a public key (default private key)", .type = OPTION_VALUE, .value = 1, - .opt.value = &pkey_config.pubout, + .opt.value = &cfg.pubout, }, { .name = "text", .desc = "Print the public/private key in plain text", .type = OPTION_FLAG, - .opt.flag = &pkey_config.text, + .opt.flag = &cfg.text, }, { .name = "text_pub", .desc = "Print out only public key in plain text", .type = OPTION_FLAG, - .opt.flag = &pkey_config.pubtext, + .opt.flag = &cfg.pubtext, }, { .name = NULL, @@ -221,68 +221,66 @@ pkey_main(int argc, char **argv) char *passin = NULL, *passout = NULL; int ret = 1; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&pkey_config, 0, sizeof(pkey_config)); - pkey_config.informat = FORMAT_PEM; - pkey_config.outformat = FORMAT_PEM; + memset(&cfg, 0, sizeof(cfg)); + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, pkey_options, NULL, NULL) != 0) { pkey_usage(); goto end; } - if (pkey_config.pubtext) - pkey_config.text = 1; - if (pkey_config.pubin) - pkey_config.pubout = pkey_config.pubtext = 1; + if (cfg.pubtext) + cfg.text = 1; + if (cfg.pubin) + cfg.pubout = cfg.pubtext = 1; - if (!app_passwd(bio_err, pkey_config.passargin, pkey_config.passargout, + if (!app_passwd(bio_err, cfg.passargin, cfg.passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); goto end; } - if (pkey_config.outfile) { - if (!(out = BIO_new_file(pkey_config.outfile, "wb"))) { + if (cfg.outfile) { + if (!(out = BIO_new_file(cfg.outfile, "wb"))) { BIO_printf(bio_err, - "Can't open output file %s\n", pkey_config.outfile); + "Can't open output file %s\n", cfg.outfile); goto end; } } else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } - if (pkey_config.pubin) - pkey = load_pubkey(bio_err, pkey_config.infile, - pkey_config.informat, 1, passin, "Public Key"); + if (cfg.pubin) + pkey = load_pubkey(bio_err, cfg.infile, + cfg.informat, 1, passin, "Public Key"); else - pkey = load_key(bio_err, pkey_config.infile, - pkey_config.informat, 1, passin, "key"); + pkey = load_key(bio_err, cfg.infile, + cfg.informat, 1, passin, "key"); if (!pkey) goto end; - if (pkey_config.check) { + if (cfg.check) { if (!pkey_check(out, pkey, EVP_PKEY_check, "Key pair")) goto end; - } else if (pkey_config.pubcheck) { + } else if (cfg.pubcheck) { if (!pkey_check(out, pkey, EVP_PKEY_public_check, "Public key")) goto end; } - if (!pkey_config.noout) { - if (pkey_config.outformat == FORMAT_PEM) { - if (pkey_config.pubout) + if (!cfg.noout) { + if (cfg.outformat == FORMAT_PEM) { + if (cfg.pubout) PEM_write_bio_PUBKEY(out, pkey); else PEM_write_bio_PrivateKey(out, pkey, - pkey_config.cipher, NULL, 0, NULL, passout); - } else if (pkey_config.outformat == FORMAT_ASN1) { - if (pkey_config.pubout) + cfg.cipher, NULL, 0, NULL, passout); + } else if (cfg.outformat == FORMAT_ASN1) { + if (cfg.pubout) i2d_PUBKEY_bio(out, pkey); else i2d_PrivateKey_bio(out, pkey); @@ -292,8 +290,8 @@ pkey_main(int argc, char **argv) } } - if (pkey_config.text) { - if (pkey_config.pubtext) + if (cfg.text) { + if (cfg.pubtext) EVP_PKEY_print_public(out, pkey, 0, NULL); else EVP_PKEY_print_private(out, pkey, 0, NULL); diff --git a/apps/openssl/pkeyparam.c b/apps/openssl/pkeyparam.c index 924c39ed..94619564 100644 --- a/apps/openssl/pkeyparam.c +++ b/apps/openssl/pkeyparam.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkeyparam.c,v 1.14 2022/01/14 10:17:30 tb Exp $ */ +/* $OpenBSD: pkeyparam.c,v 1.17 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006 */ @@ -65,46 +65,46 @@ #include #include -struct { +static struct { int check; char *infile; int noout; char *outfile; int text; -} pkeyparam_config; +} cfg; static const struct option pkeyparam_options[] = { { .name = "check", .desc = "Check validity of key parameters", .type = OPTION_FLAG, - .opt.flag = &pkeyparam_config.check, + .opt.flag = &cfg.check, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &pkeyparam_config.infile, + .opt.arg = &cfg.infile, }, { .name = "noout", .desc = "Do not print encoded version of the parameters", .type = OPTION_FLAG, - .opt.flag = &pkeyparam_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &pkeyparam_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "text", .desc = "Print out the parameters in plain text", .type = OPTION_FLAG, - .opt.flag = &pkeyparam_config.text, + .opt.flag = &cfg.text, }, { NULL }, }; @@ -125,33 +125,31 @@ pkeyparam_main(int argc, char **argv) EVP_PKEY *pkey = NULL; int ret = 1; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&pkeyparam_config, 0, sizeof(pkeyparam_config)); + memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, pkeyparam_options, NULL, NULL) != 0) { pkeyparam_usage(); return (1); } - if (pkeyparam_config.infile) { - if (!(in = BIO_new_file(pkeyparam_config.infile, "r"))) { + if (cfg.infile) { + if (!(in = BIO_new_file(cfg.infile, "r"))) { BIO_printf(bio_err, "Can't open input file %s\n", - pkeyparam_config.infile); + cfg.infile); goto end; } } else in = BIO_new_fp(stdin, BIO_NOCLOSE); - if (pkeyparam_config.outfile) { - if (!(out = BIO_new_file(pkeyparam_config.outfile, "w"))) { + if (cfg.outfile) { + if (!(out = BIO_new_file(cfg.outfile, "w"))) { BIO_printf(bio_err, "Can't open output file %s\n", - pkeyparam_config.outfile); + cfg.outfile); goto end; } } else { @@ -165,15 +163,15 @@ pkeyparam_main(int argc, char **argv) goto end; } - if (pkeyparam_config.check) { + if (cfg.check) { if (!pkey_check(out, pkey, EVP_PKEY_param_check, "Parameters")) goto end; } - if (!pkeyparam_config.noout) + if (!cfg.noout) PEM_write_bio_Parameters(out, pkey); - if (pkeyparam_config.text) + if (cfg.text) EVP_PKEY_print_params(out, pkey, 0, NULL); ret = 0; diff --git a/apps/openssl/pkeyutl.c b/apps/openssl/pkeyutl.c index 09a1a975..efd0896c 100644 --- a/apps/openssl/pkeyutl.c +++ b/apps/openssl/pkeyutl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkeyutl.c,v 1.16 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: pkeyutl.c,v 1.19 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -68,7 +68,7 @@ #define KEY_PUBKEY 2 #define KEY_CERT 3 -struct { +static struct { int asn1parse; EVP_PKEY_CTX *ctx; int hexdump; @@ -82,7 +82,7 @@ struct { int pkey_op; int rev; char *sigfile; -} pkeyutl_config; +} cfg; static void pkeyutl_usage(void); @@ -101,48 +101,48 @@ static const struct option pkeyutl_options[] = { .name = "asn1parse", .desc = "ASN.1 parse the output data", .type = OPTION_FLAG, - .opt.flag = &pkeyutl_config.asn1parse, + .opt.flag = &cfg.asn1parse, }, { .name = "certin", .desc = "Input is a certificate containing a public key", .type = OPTION_VALUE, .value = KEY_CERT, - .opt.value = &pkeyutl_config.key_type, + .opt.value = &cfg.key_type, }, { .name = "decrypt", .desc = "Decrypt the input data using a private key", .type = OPTION_VALUE, .value = EVP_PKEY_OP_DECRYPT, - .opt.value = &pkeyutl_config.pkey_op, + .opt.value = &cfg.pkey_op, }, { .name = "derive", .desc = "Derive a shared secret using the peer key", .type = OPTION_VALUE, .value = EVP_PKEY_OP_DERIVE, - .opt.value = &pkeyutl_config.pkey_op, + .opt.value = &cfg.pkey_op, }, { .name = "encrypt", .desc = "Encrypt the input data using a public key", .type = OPTION_VALUE, .value = EVP_PKEY_OP_ENCRYPT, - .opt.value = &pkeyutl_config.pkey_op, + .opt.value = &cfg.pkey_op, }, { .name = "hexdump", .desc = "Hex dump the output data", .type = OPTION_FLAG, - .opt.flag = &pkeyutl_config.hexdump, + .opt.flag = &cfg.hexdump, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &pkeyutl_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inkey", @@ -156,28 +156,28 @@ static const struct option pkeyutl_options[] = { .argname = "fmt", .desc = "Input key format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &pkeyutl_config.keyform, + .opt.value = &cfg.keyform, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &pkeyutl_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "passin", .argname = "arg", .desc = "Key password source", .type = OPTION_ARG, - .opt.arg = &pkeyutl_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "peerform", .argname = "fmt", .desc = "Input key format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &pkeyutl_config.peerform, + .opt.value = &cfg.peerform, }, { .name = "peerkey", @@ -198,41 +198,41 @@ static const struct option pkeyutl_options[] = { .desc = "Input is a public key", .type = OPTION_VALUE, .value = KEY_PUBKEY, - .opt.value = &pkeyutl_config.key_type, + .opt.value = &cfg.key_type, }, { .name = "rev", .desc = "Reverse the input data", .type = OPTION_FLAG, - .opt.flag = &pkeyutl_config.rev, + .opt.flag = &cfg.rev, }, { .name = "sigfile", .argname = "file", .desc = "Signature file (verify operation only)", .type = OPTION_ARG, - .opt.arg = &pkeyutl_config.sigfile, + .opt.arg = &cfg.sigfile, }, { .name = "sign", .desc = "Sign the input data using private key", .type = OPTION_VALUE, .value = EVP_PKEY_OP_SIGN, - .opt.value = &pkeyutl_config.pkey_op, + .opt.value = &cfg.pkey_op, }, { .name = "verify", .desc = "Verify the input data using public key", .type = OPTION_VALUE, .value = EVP_PKEY_OP_VERIFY, - .opt.value = &pkeyutl_config.pkey_op, + .opt.value = &cfg.pkey_op, }, { .name = "verifyrecover", .desc = "Verify with public key, recover original data", .type = OPTION_VALUE, .value = EVP_PKEY_OP_VERIFYRECOVER, - .opt.value = &pkeyutl_config.pkey_op, + .opt.value = &cfg.pkey_op, }, {NULL}, @@ -263,43 +263,41 @@ pkeyutl_main(int argc, char **argv) int ret = 1, rv = -1; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&pkeyutl_config, 0, sizeof(pkeyutl_config)); - pkeyutl_config.pkey_op = EVP_PKEY_OP_SIGN; - pkeyutl_config.key_type = KEY_PRIVKEY; - pkeyutl_config.keyform = FORMAT_PEM; - pkeyutl_config.peerform = FORMAT_PEM; - pkeyutl_config.keysize = -1; + memset(&cfg, 0, sizeof(cfg)); + cfg.pkey_op = EVP_PKEY_OP_SIGN; + cfg.key_type = KEY_PRIVKEY; + cfg.keyform = FORMAT_PEM; + cfg.peerform = FORMAT_PEM; + cfg.keysize = -1; if (options_parse(argc, argv, pkeyutl_options, NULL, NULL) != 0) { pkeyutl_usage(); goto end; } - if (!pkeyutl_config.ctx) { + if (!cfg.ctx) { pkeyutl_usage(); goto end; } - if (pkeyutl_config.sigfile && - (pkeyutl_config.pkey_op != EVP_PKEY_OP_VERIFY)) { + if (cfg.sigfile && + (cfg.pkey_op != EVP_PKEY_OP_VERIFY)) { BIO_puts(bio_err, "Signature file specified for non verify\n"); goto end; } - if (!pkeyutl_config.sigfile && - (pkeyutl_config.pkey_op == EVP_PKEY_OP_VERIFY)) { + if (!cfg.sigfile && + (cfg.pkey_op == EVP_PKEY_OP_VERIFY)) { BIO_puts(bio_err, "No signature file specified for verify\n"); goto end; } - if (pkeyutl_config.pkey_op != EVP_PKEY_OP_DERIVE) { - if (pkeyutl_config.infile) { - if (!(in = BIO_new_file(pkeyutl_config.infile, "rb"))) { + if (cfg.pkey_op != EVP_PKEY_OP_DERIVE) { + if (cfg.infile) { + if (!(in = BIO_new_file(cfg.infile, "rb"))) { BIO_puts(bio_err, "Error Opening Input File\n"); ERR_print_errors(bio_err); @@ -308,8 +306,8 @@ pkeyutl_main(int argc, char **argv) } else in = BIO_new_fp(stdin, BIO_NOCLOSE); } - if (pkeyutl_config.outfile) { - if (!(out = BIO_new_file(pkeyutl_config.outfile, "wb"))) { + if (cfg.outfile) { + if (!(out = BIO_new_file(cfg.outfile, "wb"))) { BIO_printf(bio_err, "Error Creating Output File\n"); ERR_print_errors(bio_err); goto end; @@ -318,14 +316,14 @@ pkeyutl_main(int argc, char **argv) out = BIO_new_fp(stdout, BIO_NOCLOSE); } - if (pkeyutl_config.sigfile) { - BIO *sigbio = BIO_new_file(pkeyutl_config.sigfile, "rb"); + if (cfg.sigfile) { + BIO *sigbio = BIO_new_file(cfg.sigfile, "rb"); if (!sigbio) { BIO_printf(bio_err, "Can't open signature file %s\n", - pkeyutl_config.sigfile); + cfg.sigfile); goto end; } - siglen = bio_to_mem(&sig, pkeyutl_config.keysize * 10, sigbio); + siglen = bio_to_mem(&sig, cfg.keysize * 10, sigbio); BIO_free(sigbio); if (siglen <= 0) { BIO_printf(bio_err, "Error reading signature data\n"); @@ -334,12 +332,12 @@ pkeyutl_main(int argc, char **argv) } if (in) { /* Read the input data */ - buf_inlen = bio_to_mem(&buf_in, pkeyutl_config.keysize * 10, in); + buf_inlen = bio_to_mem(&buf_in, cfg.keysize * 10, in); if (buf_inlen <= 0) { BIO_printf(bio_err, "Error reading input Data\n"); exit(1); } - if (pkeyutl_config.rev) { + if (cfg.rev) { size_t i; unsigned char ctmp; size_t l = (size_t) buf_inlen; @@ -350,8 +348,8 @@ pkeyutl_main(int argc, char **argv) } } } - if (pkeyutl_config.pkey_op == EVP_PKEY_OP_VERIFY) { - rv = EVP_PKEY_verify(pkeyutl_config.ctx, sig, (size_t) siglen, + if (cfg.pkey_op == EVP_PKEY_OP_VERIFY) { + rv = EVP_PKEY_verify(cfg.ctx, sig, (size_t) siglen, buf_in, (size_t) buf_inlen); if (rv == 1) { BIO_puts(out, "Signature Verified Successfully\n"); @@ -361,15 +359,15 @@ pkeyutl_main(int argc, char **argv) if (rv >= 0) goto end; } else { - rv = do_keyop(pkeyutl_config.ctx, pkeyutl_config.pkey_op, NULL, + rv = do_keyop(cfg.ctx, cfg.pkey_op, NULL, (size_t *)&buf_outlen, buf_in, (size_t) buf_inlen); if (rv > 0) { buf_out = malloc(buf_outlen); if (!buf_out) rv = -1; else - rv = do_keyop(pkeyutl_config.ctx, - pkeyutl_config.pkey_op, + rv = do_keyop(cfg.ctx, + cfg.pkey_op, buf_out, (size_t *) & buf_outlen, buf_in, (size_t) buf_inlen); } @@ -381,16 +379,16 @@ pkeyutl_main(int argc, char **argv) goto end; } ret = 0; - if (pkeyutl_config.asn1parse) { + if (cfg.asn1parse) { if (!ASN1_parse_dump(out, buf_out, buf_outlen, 1, -1)) ERR_print_errors(bio_err); - } else if (pkeyutl_config.hexdump) + } else if (cfg.hexdump) BIO_dump(out, (char *) buf_out, buf_outlen); else BIO_write(out, buf_out, buf_outlen); end: - EVP_PKEY_CTX_free(pkeyutl_config.ctx); + EVP_PKEY_CTX_free(cfg.ctx); BIO_free(in); BIO_free_all(out); free(buf_in); @@ -408,32 +406,32 @@ init_ctx(char *keyfile) int rv = -1; X509 *x; - if (((pkeyutl_config.pkey_op == EVP_PKEY_OP_SIGN) - || (pkeyutl_config.pkey_op == EVP_PKEY_OP_DECRYPT) - || (pkeyutl_config.pkey_op == EVP_PKEY_OP_DERIVE)) - && (pkeyutl_config.key_type != KEY_PRIVKEY)) { + if (((cfg.pkey_op == EVP_PKEY_OP_SIGN) + || (cfg.pkey_op == EVP_PKEY_OP_DECRYPT) + || (cfg.pkey_op == EVP_PKEY_OP_DERIVE)) + && (cfg.key_type != KEY_PRIVKEY)) { BIO_printf(bio_err, "A private key is needed for this operation\n"); goto end; } - if (!app_passwd(bio_err, pkeyutl_config.passargin, NULL, &passin, + if (!app_passwd(bio_err, cfg.passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } - switch (pkeyutl_config.key_type) { + switch (cfg.key_type) { case KEY_PRIVKEY: - pkey = load_key(bio_err, keyfile, pkeyutl_config.keyform, 0, + pkey = load_key(bio_err, keyfile, cfg.keyform, 0, passin, "Private Key"); break; case KEY_PUBKEY: - pkey = load_pubkey(bio_err, keyfile, pkeyutl_config.keyform, 0, + pkey = load_pubkey(bio_err, keyfile, cfg.keyform, 0, NULL, "Public Key"); break; case KEY_CERT: - x = load_cert(bio_err, keyfile, pkeyutl_config.keyform, + x = load_cert(bio_err, keyfile, cfg.keyform, NULL, "Certificate"); if (x) { pkey = X509_get_pubkey(x); @@ -442,53 +440,53 @@ init_ctx(char *keyfile) break; } - pkeyutl_config.keysize = EVP_PKEY_size(pkey); + cfg.keysize = EVP_PKEY_size(pkey); if (!pkey) goto end; - pkeyutl_config.ctx = EVP_PKEY_CTX_new(pkey, NULL); + cfg.ctx = EVP_PKEY_CTX_new(pkey, NULL); EVP_PKEY_free(pkey); - if (!pkeyutl_config.ctx) + if (!cfg.ctx) goto end; - switch (pkeyutl_config.pkey_op) { + switch (cfg.pkey_op) { case EVP_PKEY_OP_SIGN: - rv = EVP_PKEY_sign_init(pkeyutl_config.ctx); + rv = EVP_PKEY_sign_init(cfg.ctx); break; case EVP_PKEY_OP_VERIFY: - rv = EVP_PKEY_verify_init(pkeyutl_config.ctx); + rv = EVP_PKEY_verify_init(cfg.ctx); break; case EVP_PKEY_OP_VERIFYRECOVER: - rv = EVP_PKEY_verify_recover_init(pkeyutl_config.ctx); + rv = EVP_PKEY_verify_recover_init(cfg.ctx); break; case EVP_PKEY_OP_ENCRYPT: - rv = EVP_PKEY_encrypt_init(pkeyutl_config.ctx); + rv = EVP_PKEY_encrypt_init(cfg.ctx); break; case EVP_PKEY_OP_DECRYPT: - rv = EVP_PKEY_decrypt_init(pkeyutl_config.ctx); + rv = EVP_PKEY_decrypt_init(cfg.ctx); break; case EVP_PKEY_OP_DERIVE: - rv = EVP_PKEY_derive_init(pkeyutl_config.ctx); + rv = EVP_PKEY_derive_init(cfg.ctx); break; } if (rv <= 0) { - EVP_PKEY_CTX_free(pkeyutl_config.ctx); - pkeyutl_config.ctx = NULL; + EVP_PKEY_CTX_free(cfg.ctx); + cfg.ctx = NULL; } end: free(passin); - if (!pkeyutl_config.ctx) { + if (!cfg.ctx) { BIO_puts(bio_err, "Error initializing context\n"); ERR_print_errors(bio_err); return (1); @@ -503,11 +501,11 @@ setup_peer(char *file) EVP_PKEY *peer = NULL; int ret; - if (!pkeyutl_config.ctx) { + if (!cfg.ctx) { BIO_puts(bio_err, "-peerkey command before -inkey\n"); return (1); } - peer = load_pubkey(bio_err, file, pkeyutl_config.peerform, 0, NULL, + peer = load_pubkey(bio_err, file, cfg.peerform, 0, NULL, "Peer Key"); if (!peer) { @@ -515,7 +513,7 @@ setup_peer(char *file) ERR_print_errors(bio_err); return (1); } - ret = EVP_PKEY_derive_set_peer(pkeyutl_config.ctx, peer); + ret = EVP_PKEY_derive_set_peer(cfg.ctx, peer); EVP_PKEY_free(peer); if (ret <= 0) { @@ -529,10 +527,10 @@ setup_peer(char *file) static int pkeyutl_pkeyopt(char *pkeyopt) { - if (!pkeyutl_config.ctx) { + if (!cfg.ctx) { BIO_puts(bio_err, "-pkeyopt command before -inkey\n"); return (1); - } else if (pkey_ctrl_string(pkeyutl_config.ctx, pkeyopt) <= 0) { + } else if (pkey_ctrl_string(cfg.ctx, pkeyopt) <= 0) { BIO_puts(bio_err, "parameter setting error\n"); ERR_print_errors(bio_err); return (1); diff --git a/apps/openssl/prime.c b/apps/openssl/prime.c index ee0c3429..d704d882 100644 --- a/apps/openssl/prime.c +++ b/apps/openssl/prime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prime.c,v 1.13 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: prime.c,v 1.17 2023/03/06 14:32:06 tb Exp $ */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved. * @@ -56,13 +56,13 @@ #include #include -struct { +static struct { int bits; int checks; int generate; int hex; int safe; -} prime_config; +} cfg; static const struct option prime_options[] = { { @@ -70,32 +70,32 @@ static const struct option prime_options[] = { .argname = "n", .desc = "Number of bits in the generated prime number", .type = OPTION_ARG_INT, - .opt.value = &prime_config.bits, + .opt.value = &cfg.bits, }, { .name = "checks", .argname = "n", - .desc = "Miller-Rabin probablistic primality test iterations", + .desc = "Miller-Rabin probabilistic primality test iterations", .type = OPTION_ARG_INT, - .opt.value = &prime_config.checks, + .opt.value = &cfg.checks, }, { .name = "generate", .desc = "Generate a pseudo-random prime number", .type = OPTION_FLAG, - .opt.flag = &prime_config.generate, + .opt.flag = &cfg.generate, }, { .name = "hex", .desc = "Hexadecimal prime numbers", .type = OPTION_FLAG, - .opt.flag = &prime_config.hex, + .opt.flag = &cfg.hex, }, { .name = "safe", .desc = "Generate only \"safe\" prime numbers", .type = OPTION_FLAG, - .opt.flag = &prime_config.safe, + .opt.flag = &cfg.safe, }, {NULL}, }; @@ -118,24 +118,22 @@ prime_main(int argc, char **argv) char *s; int is_prime, ret = 1; - if (single_execution) { - if (pledge("stdio rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&prime_config, 0, sizeof(prime_config)); + memset(&cfg, 0, sizeof(cfg)); /* Default iterations for Miller-Rabin probabilistic primality test. */ - prime_config.checks = 20; + cfg.checks = 20; if (options_parse(argc, argv, prime_options, &prime, NULL) != 0) { prime_usage(); return (1); } - if (prime == NULL && prime_config.generate == 0) { + if (prime == NULL && cfg.generate == 0) { BIO_printf(bio_err, "No prime specified.\n"); prime_usage(); return (1); @@ -147,8 +145,8 @@ prime_main(int argc, char **argv) } BIO_set_fp(bio_out, stdout, BIO_NOCLOSE); - if (prime_config.generate != 0) { - if (prime_config.bits == 0) { + if (cfg.generate != 0) { + if (cfg.bits == 0) { BIO_printf(bio_err, "Specify the number of bits.\n"); goto end; } @@ -157,12 +155,12 @@ prime_main(int argc, char **argv) BIO_printf(bio_err, "Out of memory.\n"); goto end; } - if (!BN_generate_prime_ex(bn, prime_config.bits, - prime_config.safe, NULL, NULL, NULL)) { + if (!BN_generate_prime_ex(bn, cfg.bits, + cfg.safe, NULL, NULL, NULL)) { BIO_printf(bio_err, "Prime generation error.\n"); goto end; } - s = prime_config.hex ? BN_bn2hex(bn) : BN_bn2dec(bn); + s = cfg.hex ? BN_bn2hex(bn) : BN_bn2dec(bn); if (s == NULL) { BIO_printf(bio_err, "Out of memory.\n"); goto end; @@ -170,7 +168,7 @@ prime_main(int argc, char **argv) BIO_printf(bio_out, "%s\n", s); free(s); } else { - if (prime_config.hex) { + if (cfg.hex) { if (!BN_hex2bn(&bn, prime)) { BIO_printf(bio_err, "%s is an invalid hex " "value.\n", prime); @@ -184,7 +182,7 @@ prime_main(int argc, char **argv) } } - is_prime = BN_is_prime_ex(bn, prime_config.checks, NULL, NULL); + is_prime = BN_is_prime_ex(bn, cfg.checks, NULL, NULL); if (is_prime < 0) { BIO_printf(bio_err, "BN_is_prime_ex failed.\n"); goto end; diff --git a/apps/openssl/rand.c b/apps/openssl/rand.c index fb639e3b..a0f3b446 100644 --- a/apps/openssl/rand.c +++ b/apps/openssl/rand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rand.c,v 1.14 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: rand.c,v 1.17 2023/03/06 14:32:06 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * @@ -62,31 +62,31 @@ #include #include -struct { +static struct { int base64; int hex; char *outfile; -} rand_config; +} cfg; static const struct option rand_options[] = { { .name = "base64", .desc = "Perform base64 encoding on output", .type = OPTION_FLAG, - .opt.flag = &rand_config.base64, + .opt.flag = &cfg.base64, }, { .name = "hex", .desc = "Hexadecimal output", .type = OPTION_FLAG, - .opt.flag = &rand_config.hex, + .opt.flag = &cfg.hex, }, { .name = "out", .argname = "file", .desc = "Write to the given file instead of standard output", .type = OPTION_ARG, - .opt.arg = &rand_config.outfile, + .opt.arg = &cfg.outfile, }, {NULL}, }; @@ -109,14 +109,12 @@ rand_main(int argc, char **argv) int i, r; BIO *out = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&rand_config, 0, sizeof(rand_config)); + memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, rand_options, &num_bytes, NULL) != 0) { rand_usage(); @@ -130,7 +128,7 @@ rand_main(int argc, char **argv) } else badopt = 1; - if (rand_config.hex && rand_config.base64) + if (cfg.hex && cfg.base64) badopt = 1; if (badopt) { @@ -141,13 +139,13 @@ rand_main(int argc, char **argv) out = BIO_new(BIO_s_file()); if (out == NULL) goto err; - if (rand_config.outfile != NULL) - r = BIO_write_filename(out, rand_config.outfile); + if (cfg.outfile != NULL) + r = BIO_write_filename(out, cfg.outfile); else r = BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); if (r <= 0) goto err; - if (rand_config.base64) { + if (cfg.base64) { BIO *b64 = BIO_new(BIO_f_base64()); if (b64 == NULL) goto err; @@ -162,7 +160,7 @@ rand_main(int argc, char **argv) if (chunk > (int) sizeof(buf)) chunk = sizeof(buf); arc4random_buf(buf, chunk); - if (rand_config.hex) { + if (cfg.hex) { for (i = 0; i < chunk; i++) BIO_printf(out, "%02x", buf[i]); } else @@ -170,7 +168,7 @@ rand_main(int argc, char **argv) num -= chunk; } - if (rand_config.hex) + if (cfg.hex) BIO_puts(out, "\n"); (void) BIO_flush(out); diff --git a/apps/openssl/req.c b/apps/openssl/req.c index 6d74ca0e..0994d0b2 100644 --- a/apps/openssl/req.c +++ b/apps/openssl/req.c @@ -1,4 +1,4 @@ -/* $OpenBSD: req.c,v 1.23 2022/02/03 17:44:04 tb Exp $ */ +/* $OpenBSD: req.c,v 1.27 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -129,7 +129,7 @@ static int duplicated(LHASH_OF(OPENSSL_STRING) *addexts, char *kv); static CONF *req_conf = NULL; static CONF *addext_conf = NULL; -struct { +static struct { LHASH_OF(OPENSSL_STRING) *addexts; BIO *addext_bio; int batch; @@ -168,26 +168,26 @@ struct { int verbose; int verify; int x509; -} req_config; +} cfg; static int req_opt_addext(char *arg) { int i; - if (req_config.addexts == NULL) { - req_config.addexts = (LHASH_OF(OPENSSL_STRING) *)lh_new( + if (cfg.addexts == NULL) { + cfg.addexts = (LHASH_OF(OPENSSL_STRING) *)lh_new( (LHASH_HASH_FN_TYPE)ext_name_hash, (LHASH_COMP_FN_TYPE)ext_name_cmp); - req_config.addext_bio = BIO_new(BIO_s_mem()); - if (req_config.addexts == NULL || - req_config.addext_bio == NULL) + cfg.addext_bio = BIO_new(BIO_s_mem()); + if (cfg.addexts == NULL || + cfg.addext_bio == NULL) return (1); } - i = duplicated(req_config.addexts, arg); + i = duplicated(cfg.addexts, arg); if (i == 1) return (1); - if (i < 0 || BIO_printf(req_config.addext_bio, "%s\n", arg) < 0) + if (i < 0 || BIO_printf(cfg.addext_bio, "%s\n", arg) < 0) return (1); return (0); @@ -198,11 +198,11 @@ req_opt_days(char *arg) { const char *errstr; - req_config.days = strtonum(arg, 1, INT_MAX, &errstr); + cfg.days = strtonum(arg, 1, INT_MAX, &errstr); if (errstr != NULL) { BIO_printf(bio_err, "bad -days %s, using 0: %s\n", arg, errstr); - req_config.days = 30; + cfg.days = 30; } return (0); } @@ -215,7 +215,7 @@ req_opt_digest(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((req_config.digest = EVP_get_digestbyname(name)) == NULL) + if ((cfg.digest = EVP_get_digestbyname(name)) == NULL) return (1); *argsused = 1; @@ -225,15 +225,15 @@ req_opt_digest(int argc, char **argv, int *argsused) static int req_opt_newkey(char *arg) { - req_config.keyalg = arg; - req_config.newreq = 1; + cfg.keyalg = arg; + cfg.newreq = 1; return (0); } static int req_opt_nameopt(char *arg) { - if (!set_name_ex(&req_config.nmflag, arg)) + if (!set_name_ex(&cfg.nmflag, arg)) return (1); return (0); } @@ -241,11 +241,11 @@ req_opt_nameopt(char *arg) static int req_opt_pkeyopt(char *arg) { - if (req_config.pkeyopts == NULL) - req_config.pkeyopts = sk_OPENSSL_STRING_new_null(); - if (req_config.pkeyopts == NULL) + if (cfg.pkeyopts == NULL) + cfg.pkeyopts = sk_OPENSSL_STRING_new_null(); + if (cfg.pkeyopts == NULL) return (1); - if (!sk_OPENSSL_STRING_push(req_config.pkeyopts, arg)) + if (!sk_OPENSSL_STRING_push(cfg.pkeyopts, arg)) return (1); return (0); } @@ -253,7 +253,7 @@ req_opt_pkeyopt(char *arg) static int req_opt_reqopt(char *arg) { - if (!set_cert_ex(&req_config.reqflag, arg)) + if (!set_cert_ex(&cfg.reqflag, arg)) return (1); return (0); } @@ -261,8 +261,8 @@ req_opt_reqopt(char *arg) static int req_opt_set_serial(char *arg) { - req_config.serial = s2i_ASN1_INTEGER(NULL, arg); - if (req_config.serial == NULL) + cfg.serial = s2i_ASN1_INTEGER(NULL, arg); + if (cfg.serial == NULL) return (1); return (0); } @@ -270,11 +270,11 @@ req_opt_set_serial(char *arg) static int req_opt_sigopt(char *arg) { - if (req_config.sigopts == NULL) - req_config.sigopts = sk_OPENSSL_STRING_new_null(); - if (req_config.sigopts == NULL) + if (cfg.sigopts == NULL) + cfg.sigopts = sk_OPENSSL_STRING_new_null(); + if (cfg.sigopts == NULL) return (1); - if (!sk_OPENSSL_STRING_push(req_config.sigopts, arg)) + if (!sk_OPENSSL_STRING_push(cfg.sigopts, arg)) return (1); return (0); } @@ -282,7 +282,7 @@ req_opt_sigopt(char *arg) static int req_opt_utf8(void) { - req_config.chtype = MBSTRING_UTF8; + cfg.chtype = MBSTRING_UTF8; return (0); } @@ -298,14 +298,14 @@ static const struct option req_options[] = { .name = "batch", .desc = "Operate in batch mode", .type = OPTION_FLAG, - .opt.flag = &req_config.batch, + .opt.flag = &cfg.batch, }, { .name = "config", .argname = "file", .desc = "Configuration file to use as request template", .type = OPTION_ARG, - .opt.arg = &req_config.template, + .opt.arg = &cfg.template, }, { .name = "days", @@ -319,54 +319,54 @@ static const struct option req_options[] = { .argname = "section", .desc = "Config section to use for certificate extensions", .type = OPTION_ARG, - .opt.arg = &req_config.extensions, + .opt.arg = &cfg.extensions, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &req_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &req_config.informat, + .opt.value = &cfg.informat, }, { .name = "key", .argname = "file", .desc = "Private key file", .type = OPTION_ARG, - .opt.arg = &req_config.keyfile, + .opt.arg = &cfg.keyfile, }, { .name = "keyform", .argname = "format", .desc = "Private key format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &req_config.keyform, + .opt.value = &cfg.keyform, }, { .name = "keyout", .argname = "file", .desc = "Private key output file", .type = OPTION_ARG, - .opt.arg = &req_config.keyout, + .opt.arg = &cfg.keyout, }, { .name = "modulus", .desc = "Print RSA modulus", .type = OPTION_FLAG, - .opt.flag = &req_config.modulus, + .opt.flag = &cfg.modulus, }, { .name = "multivalue-rdn", .desc = "Enable support for multivalued RDNs", .type = OPTION_FLAG, - .opt.flag = &req_config.multirdn, + .opt.flag = &cfg.multirdn, }, { .name = "nameopt", @@ -379,13 +379,13 @@ static const struct option req_options[] = { .name = "new", .desc = "New request", .type = OPTION_FLAG, - .opt.flag = &req_config.newreq, + .opt.flag = &cfg.newreq, }, { .name = "newhdr", .desc = "Include 'NEW' in header lines", .type = OPTION_FLAG, - .opt.flag = &req_config.newhdr, + .opt.flag = &cfg.newhdr, }, { .name = "newkey", @@ -398,41 +398,41 @@ static const struct option req_options[] = { .name = "nodes", .desc = "Do not encrypt output private key", .type = OPTION_FLAG, - .opt.flag = &req_config.nodes, + .opt.flag = &cfg.nodes, }, { .name = "noout", .desc = "Do not output request", .type = OPTION_FLAG, - .opt.flag = &req_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &req_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &req_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "passin", .argname = "source", .desc = "Private key input password source", .type = OPTION_ARG, - .opt.arg = &req_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "passout", .argname = "source", .desc = "Private key output password source", .type = OPTION_ARG, - .opt.arg = &req_config.passargout, + .opt.arg = &cfg.passargout, }, { .name = "pkeyopt", @@ -445,14 +445,14 @@ static const struct option req_options[] = { .name = "pubkey", .desc = "Output the public key", .type = OPTION_FLAG, - .opt.flag = &req_config.pubkey, + .opt.flag = &cfg.pubkey, }, { .name = "reqexts", .argname = "section", .desc = "Config section to use for request extensions", .type = OPTION_ARG, - .opt.arg = &req_config.req_exts, + .opt.arg = &cfg.req_exts, }, { .name = "reqopt", @@ -480,19 +480,19 @@ static const struct option req_options[] = { .argname = "name", .desc = "Set or modify the request subject", .type = OPTION_ARG, - .opt.arg = &req_config.subj, + .opt.arg = &cfg.subj, }, { .name = "subject", .desc = "Output the subject of the request", .type = OPTION_FLAG, - .opt.flag = &req_config.subject, + .opt.flag = &cfg.subject, }, { .name = "text", .desc = "Print request in text form", .type = OPTION_FLAG, - .opt.flag = &req_config.text, + .opt.flag = &cfg.text, }, { .name = "utf8", @@ -504,19 +504,19 @@ static const struct option req_options[] = { .name = "verbose", .desc = "Verbose", .type = OPTION_FLAG, - .opt.flag = &req_config.verbose, + .opt.flag = &cfg.verbose, }, { .name = "verify", .desc = "Verify signature on request", .type = OPTION_FLAG, - .opt.flag = &req_config.verify, + .opt.flag = &cfg.verify, }, { .name = "x509", .desc = "Output an X.509 structure instead of a certificate request", .type = OPTION_FLAG, - .opt.flag = &req_config.x509, + .opt.flag = &cfg.x509, }, { .name = NULL, @@ -563,22 +563,20 @@ req_main(int argc, char **argv) const EVP_MD *md_alg = NULL; char *p; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&req_config, 0, sizeof(req_config)); + memset(&cfg, 0, sizeof(cfg)); - req_config.chtype = MBSTRING_ASC; - req_config.days = 30; - req_config.digest = EVP_sha256(); - req_config.newkey = -1; - req_config.informat = FORMAT_PEM; - req_config.keyform = FORMAT_PEM; - req_config.outformat = FORMAT_PEM; + cfg.chtype = MBSTRING_ASC; + cfg.days = 30; + cfg.digest = EVP_sha256(); + cfg.newkey = -1; + cfg.informat = FORMAT_PEM; + cfg.keyform = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, req_options, NULL, NULL) != 0) { req_usage(); @@ -588,19 +586,19 @@ req_main(int argc, char **argv) req_conf = NULL; cipher = EVP_aes_256_cbc(); - if (!app_passwd(bio_err, req_config.passargin, req_config.passargout, &passin, &passout)) { + if (!app_passwd(bio_err, cfg.passargin, cfg.passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); goto end; } - if (req_config.template != NULL) { + if (cfg.template != NULL) { long errline = -1; - if (req_config.verbose) - BIO_printf(bio_err, "Using configuration from %s\n", req_config.template); + if (cfg.verbose) + BIO_printf(bio_err, "Using configuration from %s\n", cfg.template); if ((req_conf = NCONF_new(NULL)) == NULL) goto end; - if(!NCONF_load(req_conf, req_config.template, &errline)) { - BIO_printf(bio_err, "error on line %ld of %s\n", errline, req_config.template); + if(!NCONF_load(req_conf, cfg.template, &errline)) { + BIO_printf(bio_err, "error on line %ld of %s\n", errline, cfg.template); goto end; } } else { @@ -608,21 +606,21 @@ req_main(int argc, char **argv) if (req_conf == NULL) { BIO_printf(bio_err, "Unable to load config info from %s\n", default_config_file); - if (req_config.newreq) + if (cfg.newreq) goto end; - } else if (req_config.verbose) + } else if (cfg.verbose) BIO_printf(bio_err, "Using configuration from %s\n", default_config_file); } - if (req_config.addext_bio != NULL) { + if (cfg.addext_bio != NULL) { long errline = -1; - if (req_config.verbose) + if (cfg.verbose) BIO_printf(bio_err, "Using additional configuration from command line\n"); if ((addext_conf = NCONF_new(NULL)) == NULL) goto end; - if (!NCONF_load_bio(addext_conf, req_config.addext_bio, &errline)) { + if (!NCONF_load_bio(addext_conf, cfg.addext_bio, &errline)) { BIO_printf(bio_err, "req: Error on line %ld of config input\n", errline); @@ -660,22 +658,22 @@ req_main(int argc, char **argv) ERR_clear_error(); if (p != NULL) { if ((md_alg = EVP_get_digestbyname(p)) != NULL) - req_config.digest = md_alg; + cfg.digest = md_alg; } } - if (!req_config.extensions) { - req_config.extensions = NCONF_get_string(req_conf, SECTION, V3_EXTENSIONS); - if (!req_config.extensions) + if (!cfg.extensions) { + cfg.extensions = NCONF_get_string(req_conf, SECTION, V3_EXTENSIONS); + if (!cfg.extensions) ERR_clear_error(); } - if (req_config.extensions) { + if (cfg.extensions) { /* Check syntax of file */ X509V3_CTX ctx; X509V3_set_ctx_test(&ctx); X509V3_set_nconf(&ctx, req_conf); - if (!X509V3_EXT_add_nconf(req_conf, &ctx, req_config.extensions, NULL)) { + if (!X509V3_EXT_add_nconf(req_conf, &ctx, cfg.extensions, NULL)) { BIO_printf(bio_err, - "Error Loading extension section %s\n", req_config.extensions); + "Error Loading extension section %s\n", cfg.extensions); goto end; } } @@ -708,27 +706,27 @@ req_main(int argc, char **argv) BIO_printf(bio_err, "Invalid global string mask setting %s\n", p); goto end; } - if (req_config.chtype != MBSTRING_UTF8) { + if (cfg.chtype != MBSTRING_UTF8) { p = NCONF_get_string(req_conf, SECTION, UTF8_IN); if (!p) ERR_clear_error(); else if (!strcmp(p, "yes")) - req_config.chtype = MBSTRING_UTF8; + cfg.chtype = MBSTRING_UTF8; } - if (!req_config.req_exts) { - req_config.req_exts = NCONF_get_string(req_conf, SECTION, REQ_EXTENSIONS); - if (!req_config.req_exts) + if (!cfg.req_exts) { + cfg.req_exts = NCONF_get_string(req_conf, SECTION, REQ_EXTENSIONS); + if (!cfg.req_exts) ERR_clear_error(); } - if (req_config.req_exts) { + if (cfg.req_exts) { /* Check syntax of file */ X509V3_CTX ctx; X509V3_set_ctx_test(&ctx); X509V3_set_nconf(&ctx, req_conf); - if (!X509V3_EXT_add_nconf(req_conf, &ctx, req_config.req_exts, NULL)) { + if (!X509V3_EXT_add_nconf(req_conf, &ctx, cfg.req_exts, NULL)) { BIO_printf(bio_err, "Error Loading request extension section %s\n", - req_config.req_exts); + cfg.req_exts); goto end; } } @@ -737,8 +735,8 @@ req_main(int argc, char **argv) if ((in == NULL) || (out == NULL)) goto end; - if (req_config.keyfile != NULL) { - pkey = load_key(bio_err, req_config.keyfile, req_config.keyform, 0, passin, + if (cfg.keyfile != NULL) { + pkey = load_key(bio_err, cfg.keyfile, cfg.keyform, 0, passin, "Private Key"); if (!pkey) { /* @@ -748,31 +746,31 @@ req_main(int argc, char **argv) goto end; } } - if (req_config.newreq && (pkey == NULL)) { - if (!NCONF_get_number(req_conf, SECTION, BITS, &req_config.newkey)) { - req_config.newkey = DEFAULT_KEY_LENGTH; + if (cfg.newreq && (pkey == NULL)) { + if (!NCONF_get_number(req_conf, SECTION, BITS, &cfg.newkey)) { + cfg.newkey = DEFAULT_KEY_LENGTH; } - if (req_config.keyalg) { - genctx = set_keygen_ctx(bio_err, req_config.keyalg, &pkey_type, &req_config.newkey, + if (cfg.keyalg) { + genctx = set_keygen_ctx(bio_err, cfg.keyalg, &pkey_type, &cfg.newkey, &keyalgstr); if (!genctx) goto end; } - if (req_config.newkey < MIN_KEY_LENGTH && (pkey_type == EVP_PKEY_RSA || pkey_type == EVP_PKEY_DSA)) { + if (cfg.newkey < MIN_KEY_LENGTH && (pkey_type == EVP_PKEY_RSA || pkey_type == EVP_PKEY_DSA)) { BIO_printf(bio_err, "private key length is too short,\n"); - BIO_printf(bio_err, "it needs to be at least %d bits, not %ld\n", MIN_KEY_LENGTH, req_config.newkey); + BIO_printf(bio_err, "it needs to be at least %d bits, not %ld\n", MIN_KEY_LENGTH, cfg.newkey); goto end; } if (!genctx) { - genctx = set_keygen_ctx(bio_err, NULL, &pkey_type, &req_config.newkey, + genctx = set_keygen_ctx(bio_err, NULL, &pkey_type, &cfg.newkey, &keyalgstr); if (!genctx) goto end; } - if (req_config.pkeyopts) { + if (cfg.pkeyopts) { char *genopt; - for (i = 0; i < sk_OPENSSL_STRING_num(req_config.pkeyopts); i++) { - genopt = sk_OPENSSL_STRING_value(req_config.pkeyopts, i); + for (i = 0; i < sk_OPENSSL_STRING_num(cfg.pkeyopts); i++) { + genopt = sk_OPENSSL_STRING_value(cfg.pkeyopts, i); if (pkey_ctrl_string(genctx, genopt) <= 0) { BIO_printf(bio_err, "parameter error \"%s\"\n", @@ -783,7 +781,7 @@ req_main(int argc, char **argv) } } BIO_printf(bio_err, "Generating a %ld bit %s private key\n", - req_config.newkey, keyalgstr); + cfg.newkey, keyalgstr); EVP_PKEY_CTX_set_cb(genctx, genpkey_cb); EVP_PKEY_CTX_set_app_data(genctx, bio_err); @@ -795,18 +793,18 @@ req_main(int argc, char **argv) EVP_PKEY_CTX_free(genctx); genctx = NULL; - if (req_config.keyout == NULL) { - req_config.keyout = NCONF_get_string(req_conf, SECTION, KEYFILE); - if (req_config.keyout == NULL) + if (cfg.keyout == NULL) { + cfg.keyout = NCONF_get_string(req_conf, SECTION, KEYFILE); + if (cfg.keyout == NULL) ERR_clear_error(); } - if (req_config.keyout == NULL) { + if (cfg.keyout == NULL) { BIO_printf(bio_err, "writing new private key to stdout\n"); BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - BIO_printf(bio_err, "writing new private key to '%s'\n", req_config.keyout); - if (BIO_write_filename(out, req_config.keyout) <= 0) { - perror(req_config.keyout); + BIO_printf(bio_err, "writing new private key to '%s'\n", cfg.keyout); + if (BIO_write_filename(out, cfg.keyout) <= 0) { + perror(cfg.keyout); goto end; } } @@ -820,7 +818,7 @@ req_main(int argc, char **argv) } if ((p != NULL) && (strcmp(p, "no") == 0)) cipher = NULL; - if (req_config.nodes) + if (cfg.nodes) cipher = NULL; i = 0; @@ -837,19 +835,19 @@ req_main(int argc, char **argv) } BIO_printf(bio_err, "-----\n"); } - if (!req_config.newreq) { - if (req_config.infile == NULL) + if (!cfg.newreq) { + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { - if (BIO_read_filename(in, req_config.infile) <= 0) { - perror(req_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); goto end; } } - if (req_config.informat == FORMAT_ASN1) + if (cfg.informat == FORMAT_ASN1) req = d2i_X509_REQ_bio(in, NULL); - else if (req_config.informat == FORMAT_PEM) + else if (cfg.informat == FORMAT_PEM) req = PEM_read_bio_X509_REQ(in, NULL, NULL, NULL); else { BIO_printf(bio_err, "bad input format specified for X509 request\n"); @@ -860,7 +858,7 @@ req_main(int argc, char **argv) goto end; } } - if (req_config.newreq || req_config.x509) { + if (cfg.newreq || cfg.x509) { if (pkey == NULL) { BIO_printf(bio_err, "you need to specify a private key\n"); goto end; @@ -870,14 +868,14 @@ req_main(int argc, char **argv) if (req == NULL) { goto end; } - i = make_REQ(req, pkey, req_config.subj, req_config.multirdn, !req_config.x509, req_config.chtype); - req_config.subj = NULL; /* done processing '-subj' option */ + i = make_REQ(req, pkey, cfg.subj, cfg.multirdn, !cfg.x509, cfg.chtype); + cfg.subj = NULL; /* done processing '-subj' option */ if (!i) { BIO_printf(bio_err, "problems making Certificate Request\n"); goto end; } } - if (req_config.x509) { + if (cfg.x509) { EVP_PKEY *tmppkey; X509V3_CTX ext_ctx; @@ -885,11 +883,11 @@ req_main(int argc, char **argv) goto end; /* Set version to V3 */ - if ((req_config.extensions != NULL || addext_conf != NULL) && + if ((cfg.extensions != NULL || addext_conf != NULL) && !X509_set_version(x509ss, 2)) goto end; - if (req_config.serial) { - if (!X509_set_serialNumber(x509ss, req_config.serial)) + if (cfg.serial) { + if (!X509_set_serialNumber(x509ss, cfg.serial)) goto end; } else { if (!rand_serial(NULL, @@ -901,7 +899,7 @@ req_main(int argc, char **argv) goto end; if (!X509_gmtime_adj(X509_get_notBefore(x509ss), 0)) goto end; - if (!X509_time_adj_ex(X509_get_notAfter(x509ss), req_config.days, 0, NULL)) + if (!X509_time_adj_ex(X509_get_notAfter(x509ss), cfg.days, 0, NULL)) goto end; if (!X509_set_subject_name(x509ss, X509_REQ_get_subject_name(req))) goto end; @@ -916,11 +914,11 @@ req_main(int argc, char **argv) X509V3_set_nconf(&ext_ctx, req_conf); /* Add extensions */ - if (req_config.extensions && !X509V3_EXT_add_nconf(req_conf, - &ext_ctx, req_config.extensions, x509ss)) { + if (cfg.extensions && !X509V3_EXT_add_nconf(req_conf, + &ext_ctx, cfg.extensions, x509ss)) { BIO_printf(bio_err, "Error Loading extension section %s\n", - req_config.extensions); + cfg.extensions); goto end; } if (addext_conf != NULL && @@ -930,7 +928,7 @@ req_main(int argc, char **argv) "Error Loading command line extensions\n"); goto end; } - i = do_X509_sign(bio_err, x509ss, pkey, req_config.digest, req_config.sigopts); + i = do_X509_sign(bio_err, x509ss, pkey, cfg.digest, cfg.sigopts); if (!i) { ERR_print_errors(bio_err); goto end; @@ -944,11 +942,11 @@ req_main(int argc, char **argv) X509V3_set_nconf(&ext_ctx, req_conf); /* Add extensions */ - if (req_config.req_exts && !X509V3_EXT_REQ_add_nconf(req_conf, - &ext_ctx, req_config.req_exts, req)) { + if (cfg.req_exts && !X509V3_EXT_REQ_add_nconf(req_conf, + &ext_ctx, cfg.req_exts, req)) { BIO_printf(bio_err, "Error Loading extension section %s\n", - req_config.req_exts); + cfg.req_exts); goto end; } if (addext_conf != NULL && @@ -958,33 +956,33 @@ req_main(int argc, char **argv) "Error Loading command line extensions\n"); goto end; } - i = do_X509_REQ_sign(bio_err, req, pkey, req_config.digest, req_config.sigopts); + i = do_X509_REQ_sign(bio_err, req, pkey, cfg.digest, cfg.sigopts); if (!i) { ERR_print_errors(bio_err); goto end; } } } - if (req_config.subj && req_config.x509) { + if (cfg.subj && cfg.x509) { BIO_printf(bio_err, "Cannot modify certificate subject\n"); goto end; } - if (req_config.subj && !req_config.x509) { - if (req_config.verbose) { + if (cfg.subj && !cfg.x509) { + if (cfg.verbose) { BIO_printf(bio_err, "Modifying Request's Subject\n"); - print_name(bio_err, "old subject=", X509_REQ_get_subject_name(req), req_config.nmflag); + print_name(bio_err, "old subject=", X509_REQ_get_subject_name(req), cfg.nmflag); } - if (build_subject(req, req_config.subj, req_config.chtype, req_config.multirdn) == 0) { + if (build_subject(req, cfg.subj, cfg.chtype, cfg.multirdn) == 0) { BIO_printf(bio_err, "ERROR: cannot modify subject\n"); ex = 1; goto end; } - if (req_config.verbose) { - print_name(bio_err, "new subject=", X509_REQ_get_subject_name(req), req_config.nmflag); + if (cfg.verbose) { + print_name(bio_err, "new subject=", X509_REQ_get_subject_name(req), cfg.nmflag); } } - if (req_config.verify && !req_config.x509) { + if (cfg.verify && !cfg.x509) { EVP_PKEY *pubkey = pkey; if (pubkey == NULL) @@ -1000,24 +998,24 @@ req_main(int argc, char **argv) } else /* if (i > 0) */ BIO_printf(bio_err, "verify OK\n"); } - if (req_config.noout && !req_config.text && !req_config.modulus && !req_config.subject && !req_config.pubkey) { + if (cfg.noout && !cfg.text && !cfg.modulus && !cfg.subject && !cfg.pubkey) { ex = 0; goto end; } - if (req_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if ((req_config.keyout != NULL) && (strcmp(req_config.outfile, req_config.keyout) == 0)) - i = (int) BIO_append_filename(out, req_config.outfile); + if ((cfg.keyout != NULL) && (strcmp(cfg.outfile, cfg.keyout) == 0)) + i = (int) BIO_append_filename(out, cfg.outfile); else - i = (int) BIO_write_filename(out, req_config.outfile); + i = (int) BIO_write_filename(out, cfg.outfile); if (!i) { - perror(req_config.outfile); + perror(cfg.outfile); goto end; } } - if (req_config.pubkey) { + if (cfg.pubkey) { EVP_PKEY *tpubkey; if ((tpubkey = X509_REQ_get0_pubkey(req)) == NULL) { @@ -1027,22 +1025,22 @@ req_main(int argc, char **argv) } PEM_write_bio_PUBKEY(out, tpubkey); } - if (req_config.text) { - if (req_config.x509) - X509_print_ex(out, x509ss, req_config.nmflag, req_config.reqflag); + if (cfg.text) { + if (cfg.x509) + X509_print_ex(out, x509ss, cfg.nmflag, cfg.reqflag); else - X509_REQ_print_ex(out, req, req_config.nmflag, req_config.reqflag); + X509_REQ_print_ex(out, req, cfg.nmflag, cfg.reqflag); } - if (req_config.subject) { - if (req_config.x509) - print_name(out, "subject=", X509_get_subject_name(x509ss), req_config.nmflag); + if (cfg.subject) { + if (cfg.x509) + print_name(out, "subject=", X509_get_subject_name(x509ss), cfg.nmflag); else - print_name(out, "subject=", X509_REQ_get_subject_name(req), req_config.nmflag); + print_name(out, "subject=", X509_REQ_get_subject_name(req), cfg.nmflag); } - if (req_config.modulus) { + if (cfg.modulus) { EVP_PKEY *tpubkey; - if (req_config.x509) + if (cfg.x509) tpubkey = X509_get0_pubkey(x509ss); else tpubkey = X509_REQ_get0_pubkey(req); @@ -1061,11 +1059,11 @@ req_main(int argc, char **argv) fprintf(stdout, "Wrong Algorithm type"); fprintf(stdout, "\n"); } - if (!req_config.noout && !req_config.x509) { - if (req_config.outformat == FORMAT_ASN1) + if (!cfg.noout && !cfg.x509) { + if (cfg.outformat == FORMAT_ASN1) i = i2d_X509_REQ_bio(out, req); - else if (req_config.outformat == FORMAT_PEM) { - if (req_config.newhdr) + else if (cfg.outformat == FORMAT_PEM) { + if (cfg.newhdr) i = PEM_write_bio_X509_REQ_NEW(out, req); else i = PEM_write_bio_X509_REQ(out, req); @@ -1078,10 +1076,10 @@ req_main(int argc, char **argv) goto end; } } - if (!req_config.noout && req_config.x509 && (x509ss != NULL)) { - if (req_config.outformat == FORMAT_ASN1) + if (!cfg.noout && cfg.x509 && (x509ss != NULL)) { + if (cfg.outformat == FORMAT_ASN1) i = i2d_X509_bio(out, x509ss); - else if (req_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_X509(out, x509ss); else { BIO_printf(bio_err, "bad output format specified for outfile\n"); @@ -1100,25 +1098,25 @@ req_main(int argc, char **argv) if ((req_conf != NULL) && (req_conf != config)) NCONF_free(req_conf); NCONF_free(addext_conf); - BIO_free(req_config.addext_bio); + BIO_free(cfg.addext_bio); BIO_free(in); BIO_free_all(out); EVP_PKEY_free(pkey); if (genctx) EVP_PKEY_CTX_free(genctx); - if (req_config.pkeyopts) - sk_OPENSSL_STRING_free(req_config.pkeyopts); - if (req_config.sigopts) - sk_OPENSSL_STRING_free(req_config.sigopts); - lh_OPENSSL_STRING_doall(req_config.addexts, (LHASH_DOALL_FN_TYPE)exts_cleanup); - lh_OPENSSL_STRING_free(req_config.addexts); + if (cfg.pkeyopts) + sk_OPENSSL_STRING_free(cfg.pkeyopts); + if (cfg.sigopts) + sk_OPENSSL_STRING_free(cfg.sigopts); + lh_OPENSSL_STRING_doall(cfg.addexts, (LHASH_DOALL_FN_TYPE)exts_cleanup); + lh_OPENSSL_STRING_free(cfg.addexts); free(keyalgstr); X509_REQ_free(req); X509_free(x509ss); - ASN1_INTEGER_free(req_config.serial); - if (req_config.passargin && passin) + ASN1_INTEGER_free(cfg.serial); + if (cfg.passargin && passin) free(passin); - if (req_config.passargout && passout) + if (cfg.passargout && passout) free(passout); OBJ_cleanup(); @@ -1224,7 +1222,7 @@ prompt_info(X509_REQ * req, X509_NAME *subj; subj = X509_REQ_get_subject_name(req); - if (!req_config.batch) { + if (!cfg.batch) { BIO_printf(bio_err, "You are about to be asked to enter information that will be incorporated\n"); BIO_printf(bio_err, "into your certificate request.\n"); BIO_printf(bio_err, "What you are about to enter is what is called a Distinguished Name or a DN.\n"); @@ -1318,7 +1316,7 @@ prompt_info(X509_REQ * req, } if (attribs) { if ((attr_sk != NULL) && (sk_CONF_VALUE_num(attr_sk) > 0) && - (!req_config.batch)) { + (!cfg.batch)) { BIO_printf(bio_err, "\nPlease enter the following 'extra' attributes\n"); BIO_printf(bio_err, @@ -1454,7 +1452,7 @@ add_DN_object(X509_NAME * n, char *text, const char *def, char *value, int i, ret = 0; char buf[1024]; start: - if (!req_config.batch) + if (!cfg.batch) BIO_printf(bio_err, "%s [%s]:", text, def); (void) BIO_flush(bio_err); if (value != NULL) { @@ -1463,7 +1461,7 @@ add_DN_object(X509_NAME * n, char *text, const char *def, char *value, BIO_printf(bio_err, "%s\n", value); } else { buf[0] = '\0'; - if (!req_config.batch) { + if (!cfg.batch) { if (!fgets(buf, sizeof buf, stdin)) return 0; } else { @@ -1507,7 +1505,7 @@ add_attribute_object(X509_REQ * req, char *text, const char *def, static char buf[1024]; start: - if (!req_config.batch) + if (!cfg.batch) BIO_printf(bio_err, "%s [%s]:", text, def); (void) BIO_flush(bio_err); if (value != NULL) { @@ -1516,7 +1514,7 @@ add_attribute_object(X509_REQ * req, char *text, const char *def, BIO_printf(bio_err, "%s\n", value); } else { buf[0] = '\0'; - if (!req_config.batch) { + if (!cfg.batch) { if (!fgets(buf, sizeof buf, stdin)) return 0; } else { @@ -1739,7 +1737,7 @@ do_sign_init(BIO * err, EVP_MD_CTX * ctx, EVP_PKEY * pkey, { EVP_PKEY_CTX *pkctx = NULL; int i; - EVP_MD_CTX_init(ctx); + if (!EVP_DigestSignInit(ctx, &pkctx, md, NULL, pkey)) return 0; for (i = 0; i < sk_OPENSSL_STRING_num(sigopts); i++) { diff --git a/apps/openssl/rsa.c b/apps/openssl/rsa.c index acc05ee0..953daaac 100644 --- a/apps/openssl/rsa.c +++ b/apps/openssl/rsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa.c,v 1.16 2022/01/14 09:26:41 tb Exp $ */ +/* $OpenBSD: rsa.c,v 1.18 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -89,7 +89,7 @@ static struct { int pubout; int pvk_encr; int text; -} rsa_config; +} cfg; static int rsa_opt_cipher(int argc, char **argv, int *argsused) @@ -99,7 +99,7 @@ rsa_opt_cipher(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((rsa_config.enc = EVP_get_cipherbyname(name)) == NULL) { + if ((cfg.enc = EVP_get_cipherbyname(name)) == NULL) { fprintf(stderr, "Invalid cipher '%s'\n", name); return (1); } @@ -113,111 +113,111 @@ static const struct option rsa_options[] = { .name = "check", .desc = "Check consistency of RSA private key", .type = OPTION_FLAG, - .opt.flag = &rsa_config.check, + .opt.flag = &cfg.check, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &rsa_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER, NET or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &rsa_config.informat, + .opt.value = &cfg.informat, }, { .name = "modulus", .desc = "Print the RSA key modulus", .type = OPTION_FLAG, - .opt.flag = &rsa_config.modulus, + .opt.flag = &cfg.modulus, }, { .name = "noout", .desc = "Do not print encoded version of the key", .type = OPTION_FLAG, - .opt.flag = &rsa_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &rsa_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER, NET or PEM (default PEM))", .type = OPTION_ARG_FORMAT, - .opt.value = &rsa_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "passin", .argname = "src", .desc = "Input file passphrase source", .type = OPTION_ARG, - .opt.arg = &rsa_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "passout", .argname = "src", .desc = "Output file passphrase source", .type = OPTION_ARG, - .opt.arg = &rsa_config.passargout, + .opt.arg = &cfg.passargout, }, { .name = "pubin", .desc = "Expect a public key (default private key)", .type = OPTION_VALUE, .value = 1, - .opt.value = &rsa_config.pubin, + .opt.value = &cfg.pubin, }, { .name = "pubout", .desc = "Output a public key (default private key)", .type = OPTION_VALUE, .value = 1, - .opt.value = &rsa_config.pubout, + .opt.value = &cfg.pubout, }, { .name = "pvk-none", .type = OPTION_VALUE, .value = 0, - .opt.value = &rsa_config.pvk_encr, + .opt.value = &cfg.pvk_encr, }, { .name = "pvk-strong", .type = OPTION_VALUE, .value = 2, - .opt.value = &rsa_config.pvk_encr, + .opt.value = &cfg.pvk_encr, }, { .name = "pvk-weak", .type = OPTION_VALUE, .value = 1, - .opt.value = &rsa_config.pvk_encr, + .opt.value = &cfg.pvk_encr, }, { .name = "RSAPublicKey_in", .type = OPTION_VALUE, .value = 2, - .opt.value = &rsa_config.pubin, + .opt.value = &cfg.pubin, }, { .name = "RSAPublicKey_out", .type = OPTION_VALUE, .value = 2, - .opt.value = &rsa_config.pubout, + .opt.value = &cfg.pubout, }, { .name = "text", .desc = "Print in plain text in addition to encoded", .type = OPTION_FLAG, - .opt.flag = &rsa_config.text, + .opt.flag = &cfg.text, }, { .name = NULL, @@ -255,29 +255,27 @@ rsa_main(int argc, char **argv) BIO *out = NULL; char *passin = NULL, *passout = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&rsa_config, 0, sizeof(rsa_config)); - rsa_config.pvk_encr = 2; - rsa_config.informat = FORMAT_PEM; - rsa_config.outformat = FORMAT_PEM; + memset(&cfg, 0, sizeof(cfg)); + cfg.pvk_encr = 2; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, rsa_options, NULL, NULL) != 0) { rsa_usage(); goto end; } - if (!app_passwd(bio_err, rsa_config.passargin, rsa_config.passargout, + if (!app_passwd(bio_err, cfg.passargin, cfg.passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); goto end; } - if (rsa_config.check && rsa_config.pubin) { + if (cfg.check && cfg.pubin) { BIO_printf(bio_err, "Only private keys can be checked\n"); goto end; } @@ -286,21 +284,21 @@ rsa_main(int argc, char **argv) { EVP_PKEY *pkey; - if (rsa_config.pubin) { + if (cfg.pubin) { int tmpformat = -1; - if (rsa_config.pubin == 2) { - if (rsa_config.informat == FORMAT_PEM) + if (cfg.pubin == 2) { + if (cfg.informat == FORMAT_PEM) tmpformat = FORMAT_PEMRSA; - else if (rsa_config.informat == FORMAT_ASN1) + else if (cfg.informat == FORMAT_ASN1) tmpformat = FORMAT_ASN1RSA; } else - tmpformat = rsa_config.informat; + tmpformat = cfg.informat; - pkey = load_pubkey(bio_err, rsa_config.infile, + pkey = load_pubkey(bio_err, cfg.infile, tmpformat, 1, passin, "Public Key"); } else - pkey = load_key(bio_err, rsa_config.infile, - rsa_config.informat, 1, passin, "Private Key"); + pkey = load_key(bio_err, cfg.infile, + cfg.informat, 1, passin, "Private Key"); if (pkey != NULL) rsa = EVP_PKEY_get1_RSA(pkey); @@ -311,27 +309,27 @@ rsa_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (rsa_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, rsa_config.outfile) <= 0) { - perror(rsa_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } - if (rsa_config.text) + if (cfg.text) if (!RSA_print(out, rsa, 0)) { - perror(rsa_config.outfile); + perror(cfg.outfile); ERR_print_errors(bio_err); goto end; } - if (rsa_config.modulus) { + if (cfg.modulus) { BIO_printf(out, "Modulus="); BN_print(out, RSA_get0_n(rsa)); BIO_printf(out, "\n"); } - if (rsa_config.check) { + if (cfg.check) { int r = RSA_check_key(rsa); if (r == 1) @@ -355,38 +353,38 @@ rsa_main(int argc, char **argv) goto end; } } - if (rsa_config.noout) { + if (cfg.noout) { ret = 0; goto end; } BIO_printf(bio_err, "writing RSA key\n"); - if (rsa_config.outformat == FORMAT_ASN1) { - if (rsa_config.pubout || rsa_config.pubin) { - if (rsa_config.pubout == 2) + if (cfg.outformat == FORMAT_ASN1) { + if (cfg.pubout || cfg.pubin) { + if (cfg.pubout == 2) i = i2d_RSAPublicKey_bio(out, rsa); else i = i2d_RSA_PUBKEY_bio(out, rsa); } else i = i2d_RSAPrivateKey_bio(out, rsa); - } else if (rsa_config.outformat == FORMAT_PEM) { - if (rsa_config.pubout || rsa_config.pubin) { - if (rsa_config.pubout == 2) + } else if (cfg.outformat == FORMAT_PEM) { + if (cfg.pubout || cfg.pubin) { + if (cfg.pubout == 2) i = PEM_write_bio_RSAPublicKey(out, rsa); else i = PEM_write_bio_RSA_PUBKEY(out, rsa); } else i = PEM_write_bio_RSAPrivateKey(out, rsa, - rsa_config.enc, NULL, 0, NULL, passout); + cfg.enc, NULL, 0, NULL, passout); #if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) - } else if (rsa_config.outformat == FORMAT_MSBLOB || - rsa_config.outformat == FORMAT_PVK) { + } else if (cfg.outformat == FORMAT_MSBLOB || + cfg.outformat == FORMAT_PVK) { EVP_PKEY *pk; pk = EVP_PKEY_new(); EVP_PKEY_set1_RSA(pk, rsa); - if (rsa_config.outformat == FORMAT_PVK) - i = i2b_PVK_bio(out, pk, rsa_config.pvk_encr, 0, + if (cfg.outformat == FORMAT_PVK) + i = i2b_PVK_bio(out, pk, cfg.pvk_encr, 0, passout); - else if (rsa_config.pubin || rsa_config.pubout) + else if (cfg.pubin || cfg.pubout) i = i2b_PublicKey_bio(out, pk); else i = i2b_PrivateKey_bio(out, pk); diff --git a/apps/openssl/rsautl.c b/apps/openssl/rsautl.c index 06d7a81a..93272231 100644 --- a/apps/openssl/rsautl.c +++ b/apps/openssl/rsautl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsautl.c,v 1.18 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: rsautl.c,v 1.21 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -75,7 +75,7 @@ #define KEY_PUBKEY 2 #define KEY_CERT 3 -struct { +static struct { int asn1parse; int hexdump; char *infile; @@ -87,131 +87,131 @@ struct { char *passargin; int rev; int rsa_mode; -} rsautl_config; +} cfg; static const struct option rsautl_options[] = { { .name = "asn1parse", .desc = "ASN.1 parse the output data", .type = OPTION_FLAG, - .opt.flag = &rsautl_config.asn1parse, + .opt.flag = &cfg.asn1parse, }, { .name = "certin", .desc = "Input is a certificate containing an RSA public key", .type = OPTION_VALUE, .value = KEY_CERT, - .opt.value = &rsautl_config.key_type, + .opt.value = &cfg.key_type, }, { .name = "decrypt", .desc = "Decrypt the input data using RSA private key", .type = OPTION_VALUE, .value = RSA_DECRYPT, - .opt.value = &rsautl_config.rsa_mode, + .opt.value = &cfg.rsa_mode, }, { .name = "encrypt", .desc = "Encrypt the input data using RSA public key", .type = OPTION_VALUE, .value = RSA_ENCRYPT, - .opt.value = &rsautl_config.rsa_mode, + .opt.value = &cfg.rsa_mode, }, { .name = "hexdump", .desc = "Hex dump the output data", .type = OPTION_FLAG, - .opt.flag = &rsautl_config.hexdump, + .opt.flag = &cfg.hexdump, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &rsautl_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inkey", .argname = "file", .desc = "Input key file", .type = OPTION_ARG, - .opt.arg = &rsautl_config.keyfile, + .opt.arg = &cfg.keyfile, }, { .name = "keyform", .argname = "fmt", .desc = "Input key format (DER, TXT or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &rsautl_config.keyform, + .opt.value = &cfg.keyform, }, { .name = "oaep", .desc = "Use PKCS#1 OAEP padding", .type = OPTION_VALUE, .value = RSA_PKCS1_OAEP_PADDING, - .opt.value = &rsautl_config.pad, + .opt.value = &cfg.pad, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &rsautl_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "passin", .argname = "arg", .desc = "Key password source", .type = OPTION_ARG, - .opt.arg = &rsautl_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "pkcs", .desc = "Use PKCS#1 v1.5 padding (default)", .type = OPTION_VALUE, .value = RSA_PKCS1_PADDING, - .opt.value = &rsautl_config.pad, + .opt.value = &cfg.pad, }, { .name = "pubin", .desc = "Input is an RSA public key", .type = OPTION_VALUE, .value = KEY_PUBKEY, - .opt.value = &rsautl_config.key_type, + .opt.value = &cfg.key_type, }, { .name = "raw", .desc = "Use no padding", .type = OPTION_VALUE, .value = RSA_NO_PADDING, - .opt.value = &rsautl_config.pad, + .opt.value = &cfg.pad, }, { .name = "rev", .desc = "Reverse the input data", .type = OPTION_FLAG, - .opt.flag = &rsautl_config.rev, + .opt.flag = &cfg.rev, }, { .name = "sign", .desc = "Sign the input data using RSA private key", .type = OPTION_VALUE, .value = RSA_SIGN, - .opt.value = &rsautl_config.rsa_mode, + .opt.value = &cfg.rsa_mode, }, { .name = "verify", .desc = "Verify the input data using RSA public key", .type = OPTION_VALUE, .value = RSA_VERIFY, - .opt.value = &rsautl_config.rsa_mode, + .opt.value = &cfg.rsa_mode, }, { .name = "x931", .desc = "Use ANSI X9.31 padding", .type = OPTION_VALUE, .value = RSA_X931_PADDING, - .opt.value = &rsautl_config.pad, + .opt.value = &cfg.pad, }, {NULL}, @@ -244,51 +244,49 @@ rsautl_main(int argc, char **argv) int keysize; int ret = 1; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&rsautl_config, 0, sizeof(rsautl_config)); - rsautl_config.keyform = FORMAT_PEM; - rsautl_config.key_type = KEY_PRIVKEY; - rsautl_config.pad = RSA_PKCS1_PADDING; - rsautl_config.rsa_mode = RSA_VERIFY; + memset(&cfg, 0, sizeof(cfg)); + cfg.keyform = FORMAT_PEM; + cfg.key_type = KEY_PRIVKEY; + cfg.pad = RSA_PKCS1_PADDING; + cfg.rsa_mode = RSA_VERIFY; if (options_parse(argc, argv, rsautl_options, NULL, NULL) != 0) { rsautl_usage(); return (1); } - if (rsautl_config.rsa_mode == RSA_SIGN || - rsautl_config.rsa_mode == RSA_DECRYPT) + if (cfg.rsa_mode == RSA_SIGN || + cfg.rsa_mode == RSA_DECRYPT) need_priv = 1; - if (need_priv && rsautl_config.key_type != KEY_PRIVKEY) { + if (need_priv && cfg.key_type != KEY_PRIVKEY) { BIO_printf(bio_err, "A private key is needed for this operation\n"); goto end; } - if (!app_passwd(bio_err, rsautl_config.passargin, NULL, &passin, NULL)) { + if (!app_passwd(bio_err, cfg.passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } - switch (rsautl_config.key_type) { + switch (cfg.key_type) { case KEY_PRIVKEY: - pkey = load_key(bio_err, rsautl_config.keyfile, - rsautl_config.keyform, 0, passin, "Private Key"); + pkey = load_key(bio_err, cfg.keyfile, + cfg.keyform, 0, passin, "Private Key"); break; case KEY_PUBKEY: - pkey = load_pubkey(bio_err, rsautl_config.keyfile, - rsautl_config.keyform, 0, NULL, "Public Key"); + pkey = load_pubkey(bio_err, cfg.keyfile, + cfg.keyform, 0, NULL, "Public Key"); break; case KEY_CERT: - x = load_cert(bio_err, rsautl_config.keyfile, - rsautl_config.keyform, NULL, "Certificate"); + x = load_cert(bio_err, cfg.keyfile, + cfg.keyform, NULL, "Certificate"); if (x) { pkey = X509_get_pubkey(x); X509_free(x); @@ -307,8 +305,8 @@ rsautl_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (rsautl_config.infile) { - if (!(in = BIO_new_file(rsautl_config.infile, "rb"))) { + if (cfg.infile) { + if (!(in = BIO_new_file(cfg.infile, "rb"))) { BIO_printf(bio_err, "Error Reading Input File\n"); ERR_print_errors(bio_err); goto end; @@ -316,8 +314,8 @@ rsautl_main(int argc, char **argv) } else in = BIO_new_fp(stdin, BIO_NOCLOSE); - if (rsautl_config.outfile) { - if (!(out = BIO_new_file(rsautl_config.outfile, "wb"))) { + if (cfg.outfile) { + if (!(out = BIO_new_file(cfg.outfile, "wb"))) { BIO_printf(bio_err, "Error Reading Output File\n"); ERR_print_errors(bio_err); goto end; @@ -345,7 +343,7 @@ rsautl_main(int argc, char **argv) BIO_printf(bio_err, "Error reading input Data\n"); exit(1); } - if (rsautl_config.rev) { + if (cfg.rev) { int i; unsigned char ctmp; for (i = 0; i < rsa_inlen / 2; i++) { @@ -355,25 +353,25 @@ rsautl_main(int argc, char **argv) } } - switch (rsautl_config.rsa_mode) { + switch (cfg.rsa_mode) { case RSA_VERIFY: rsa_outlen = RSA_public_decrypt(rsa_inlen, rsa_in, rsa_out, - rsa, rsautl_config.pad); + rsa, cfg.pad); break; case RSA_SIGN: rsa_outlen = RSA_private_encrypt(rsa_inlen, rsa_in, rsa_out, - rsa, rsautl_config.pad); + rsa, cfg.pad); break; case RSA_ENCRYPT: rsa_outlen = RSA_public_encrypt(rsa_inlen, rsa_in, rsa_out, - rsa, rsautl_config.pad); + rsa, cfg.pad); break; case RSA_DECRYPT: rsa_outlen = RSA_private_decrypt(rsa_inlen, rsa_in, rsa_out, - rsa, rsautl_config.pad); + rsa, cfg.pad); break; } @@ -383,11 +381,11 @@ rsautl_main(int argc, char **argv) goto end; } ret = 0; - if (rsautl_config.asn1parse) { + if (cfg.asn1parse) { if (!ASN1_parse_dump(out, rsa_out, rsa_outlen, 1, -1)) { ERR_print_errors(bio_err); } - } else if (rsautl_config.hexdump) + } else if (cfg.hexdump) BIO_dump(out, (char *) rsa_out, rsa_outlen); else BIO_write(out, rsa_out, rsa_outlen); diff --git a/apps/openssl/s_client.c b/apps/openssl/s_client.c index 15ebb0c0..82a81282 100644 --- a/apps/openssl/s_client.c +++ b/apps/openssl/s_client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_client.c,v 1.58 2022/02/03 17:44:04 tb Exp $ */ +/* $OpenBSD: s_client.c,v 1.60 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -246,16 +246,16 @@ static struct { int verify; X509_VERIFY_PARAM *vpm; char *xmpphost; -} s_client_config; +} cfg; static int s_client_opt_keymatexportlen(char *arg) { - s_client_config.keymatexportlen = strtonum(arg, 1, INT_MAX, - &s_client_config.errstr); - if (s_client_config.errstr != NULL) { + cfg.keymatexportlen = strtonum(arg, 1, INT_MAX, + &cfg.errstr); + if (cfg.errstr != NULL) { BIO_printf(bio_err, "invalid argument %s: %s\n", - arg, s_client_config.errstr); + arg, cfg.errstr); return (1); } return (0); @@ -265,11 +265,11 @@ s_client_opt_keymatexportlen(char *arg) static int s_client_opt_mtu(char *arg) { - s_client_config.socket_mtu = strtonum(arg, 0, LONG_MAX, - &s_client_config.errstr); - if (s_client_config.errstr != NULL) { + cfg.socket_mtu = strtonum(arg, 0, LONG_MAX, + &cfg.errstr); + if (cfg.errstr != NULL) { BIO_printf(bio_err, "invalid argument %s: %s\n", - arg, s_client_config.errstr); + arg, cfg.errstr); return (1); } return (0); @@ -282,7 +282,7 @@ s_client_opt_port(char *arg) if (*arg == '\0') return (1); - s_client_config.port = arg; + cfg.port = arg; return (0); } @@ -290,8 +290,8 @@ s_client_opt_port(char *arg) static int s_client_opt_protocol_version_dtls(void) { - s_client_config.meth = DTLS_client_method(); - s_client_config.socket_type = SOCK_DGRAM; + cfg.meth = DTLS_client_method(); + cfg.socket_type = SOCK_DGRAM; return (0); } #endif @@ -300,10 +300,10 @@ s_client_opt_protocol_version_dtls(void) static int s_client_opt_protocol_version_dtls1(void) { - s_client_config.meth = DTLS_client_method(); - s_client_config.min_version = DTLS1_VERSION; - s_client_config.max_version = DTLS1_VERSION; - s_client_config.socket_type = SOCK_DGRAM; + cfg.meth = DTLS_client_method(); + cfg.min_version = DTLS1_VERSION; + cfg.max_version = DTLS1_VERSION; + cfg.socket_type = SOCK_DGRAM; return (0); } #endif @@ -312,10 +312,10 @@ s_client_opt_protocol_version_dtls1(void) static int s_client_opt_protocol_version_dtls1_2(void) { - s_client_config.meth = DTLS_client_method(); - s_client_config.min_version = DTLS1_2_VERSION; - s_client_config.max_version = DTLS1_2_VERSION; - s_client_config.socket_type = SOCK_DGRAM; + cfg.meth = DTLS_client_method(); + cfg.min_version = DTLS1_2_VERSION; + cfg.max_version = DTLS1_2_VERSION; + cfg.socket_type = SOCK_DGRAM; return (0); } #endif @@ -323,40 +323,40 @@ s_client_opt_protocol_version_dtls1_2(void) static int s_client_opt_protocol_version_tls1(void) { - s_client_config.min_version = TLS1_VERSION; - s_client_config.max_version = TLS1_VERSION; + cfg.min_version = TLS1_VERSION; + cfg.max_version = TLS1_VERSION; return (0); } static int s_client_opt_protocol_version_tls1_1(void) { - s_client_config.min_version = TLS1_1_VERSION; - s_client_config.max_version = TLS1_1_VERSION; + cfg.min_version = TLS1_1_VERSION; + cfg.max_version = TLS1_1_VERSION; return (0); } static int s_client_opt_protocol_version_tls1_2(void) { - s_client_config.min_version = TLS1_2_VERSION; - s_client_config.max_version = TLS1_2_VERSION; + cfg.min_version = TLS1_2_VERSION; + cfg.max_version = TLS1_2_VERSION; return (0); } static int s_client_opt_protocol_version_tls1_3(void) { - s_client_config.min_version = TLS1_3_VERSION; - s_client_config.max_version = TLS1_3_VERSION; + cfg.min_version = TLS1_3_VERSION; + cfg.max_version = TLS1_3_VERSION; return (0); } static int s_client_opt_quiet(void) { - s_client_config.quiet = 1; - s_client_config.ign_eof = 1; + cfg.quiet = 1; + cfg.ign_eof = 1; return (0); } @@ -364,17 +364,17 @@ static int s_client_opt_starttls(char *arg) { if (strcmp(arg, "smtp") == 0) - s_client_config.starttls_proto = PROTO_SMTP; + cfg.starttls_proto = PROTO_SMTP; else if (strcmp(arg, "lmtp") == 0) - s_client_config.starttls_proto = PROTO_LMTP; + cfg.starttls_proto = PROTO_LMTP; else if (strcmp(arg, "pop3") == 0) - s_client_config.starttls_proto = PROTO_POP3; + cfg.starttls_proto = PROTO_POP3; else if (strcmp(arg, "imap") == 0) - s_client_config.starttls_proto = PROTO_IMAP; + cfg.starttls_proto = PROTO_IMAP; else if (strcmp(arg, "ftp") == 0) - s_client_config.starttls_proto = PROTO_FTP; + cfg.starttls_proto = PROTO_FTP; else if (strcmp(arg, "xmpp") == 0) - s_client_config.starttls_proto = PROTO_XMPP; + cfg.starttls_proto = PROTO_XMPP; else return (1); return (0); @@ -383,12 +383,12 @@ s_client_opt_starttls(char *arg) static int s_client_opt_verify(char *arg) { - s_client_config.verify = SSL_VERIFY_PEER; + cfg.verify = SSL_VERIFY_PEER; - verify_depth = strtonum(arg, 0, INT_MAX, &s_client_config.errstr); - if (s_client_config.errstr != NULL) { + verify_depth = strtonum(arg, 0, INT_MAX, &cfg.errstr); + if (cfg.errstr != NULL) { BIO_printf(bio_err, "invalid argument %s: %s\n", - arg, s_client_config.errstr); + arg, cfg.errstr); return (1); } BIO_printf(bio_err, "verify depth is %d\n", verify_depth); @@ -403,7 +403,7 @@ s_client_opt_verify_param(int argc, char **argv, int *argsused) int badarg = 0; if (!args_verify(&pargs, &pargc, &badarg, bio_err, - &s_client_config.vpm)) { + &cfg.vpm)) { BIO_printf(bio_err, "unknown option %s\n", *argv); return (1); } @@ -419,14 +419,14 @@ static const struct option s_client_options[] = { .name = "4", .desc = "Use IPv4 only", .type = OPTION_VALUE, - .opt.value = &s_client_config.af, + .opt.value = &cfg.af, .value = AF_INET, }, { .name = "6", .desc = "Use IPv6 only", .type = OPTION_VALUE, - .opt.value = &s_client_config.af, + .opt.value = &cfg.af, .value = AF_INET6, }, { @@ -435,67 +435,67 @@ static const struct option s_client_options[] = { .desc = "Set the advertised protocols for ALPN" " (comma-separated list)", .type = OPTION_ARG, - .opt.arg = &s_client_config.alpn_in, + .opt.arg = &cfg.alpn_in, }, { .name = "bugs", .desc = "Enable various workarounds for buggy implementations", .type = OPTION_FLAG, - .opt.flag = &s_client_config.bugs, + .opt.flag = &cfg.bugs, }, { .name = "CAfile", .argname = "file", .desc = "PEM format file of CA certificates", .type = OPTION_ARG, - .opt.arg = &s_client_config.CAfile, + .opt.arg = &cfg.CAfile, }, { .name = "CApath", .argname = "directory", .desc = "PEM format directory of CA certificates", .type = OPTION_ARG, - .opt.arg = &s_client_config.CApath, + .opt.arg = &cfg.CApath, }, { .name = "cert", .argname = "file", .desc = "Certificate file to use, PEM format assumed", .type = OPTION_ARG, - .opt.arg = &s_client_config.cert_file, + .opt.arg = &cfg.cert_file, }, { .name = "certform", .argname = "fmt", .desc = "Certificate format (PEM or DER) PEM default", .type = OPTION_ARG_FORMAT, - .opt.value = &s_client_config.cert_format, + .opt.value = &cfg.cert_format, }, { .name = "cipher", .argname = "cipherlist", .desc = "Preferred cipher to use (see 'openssl ciphers')", .type = OPTION_ARG, - .opt.arg = &s_client_config.cipher, + .opt.arg = &cfg.cipher, }, { .name = "connect", .argname = "host:port", .desc = "Who to connect to (default is localhost:4433)", .type = OPTION_ARG, - .opt.arg = &s_client_config.connect, + .opt.arg = &cfg.connect, }, { .name = "crlf", .desc = "Convert LF from terminal into CRLF", .type = OPTION_FLAG, - .opt.flag = &s_client_config.crlf, + .opt.flag = &cfg.crlf, }, { .name = "debug", .desc = "Print extensive debugging information", .type = OPTION_FLAG, - .opt.flag = &s_client_config.debug, + .opt.flag = &cfg.debug, }, #ifndef OPENSSL_NO_DTLS { @@ -526,20 +526,20 @@ static const struct option s_client_options[] = { .argname = "list", .desc = "Specify EC groups (colon-separated list)", .type = OPTION_ARG, - .opt.arg = &s_client_config.groups_in, + .opt.arg = &cfg.groups_in, }, { .name = "host", .argname = "host", .desc = "Use -connect instead", .type = OPTION_ARG, - .opt.arg = &s_client_config.host, + .opt.arg = &cfg.host, }, { .name = "ign_eof", .desc = "Ignore input EOF (default when -quiet)", .type = OPTION_VALUE, - .opt.value = &s_client_config.ign_eof, + .opt.value = &cfg.ign_eof, .value = 1, }, { @@ -547,21 +547,21 @@ static const struct option s_client_options[] = { .argname = "file", .desc = "Private key file to use, if not, -cert file is used", .type = OPTION_ARG, - .opt.arg = &s_client_config.key_file, + .opt.arg = &cfg.key_file, }, { .name = "keyform", .argname = "fmt", .desc = "Key format (PEM or DER) PEM default", .type = OPTION_ARG_FORMAT, - .opt.value = &s_client_config.key_format, + .opt.value = &cfg.key_format, }, { .name = "keymatexport", .argname = "label", .desc = "Export keying material using label", .type = OPTION_ARG, - .opt.arg = &s_client_config.keymatexportlabel, + .opt.arg = &cfg.keymatexportlabel, }, { .name = "keymatexportlen", @@ -578,14 +578,14 @@ static const struct option s_client_options[] = { .name = "legacy_server_connect", .desc = "Allow initial connection to servers that don't support RI", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.off, + .opt.value = &cfg.off, .value = SSL_OP_LEGACY_SERVER_CONNECT, }, { .name = "msg", .desc = "Show all protocol messages with hex dump", .type = OPTION_FLAG, - .opt.flag = &s_client_config.msg, + .opt.flag = &cfg.msg, }, #ifndef OPENSSL_NO_DTLS { @@ -600,115 +600,115 @@ static const struct option s_client_options[] = { .name = "nbio", .desc = "Turn on non-blocking I/O", .type = OPTION_FLAG, - .opt.flag = &s_client_config.nbio, + .opt.flag = &cfg.nbio, }, { .name = "nbio_test", .desc = "Test non-blocking I/O", .type = OPTION_FLAG, - .opt.flag = &s_client_config.nbio_test, + .opt.flag = &cfg.nbio_test, }, { .name = "nextprotoneg", .argname = "protocols", .type = OPTION_ARG, - .opt.arg = &s_client_config.npn_in, /* Ignored. */ + .opt.arg = &cfg.npn_in, /* Ignored. */ }, { .name = "no_comp", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_COMPRESSION, }, { .name = "no_ign_eof", .desc = "Don't ignore input EOF", .type = OPTION_VALUE, - .opt.value = &s_client_config.ign_eof, + .opt.value = &cfg.ign_eof, .value = 0, }, { .name = "no_legacy_server_connect", .desc = "Disallow initial connection to servers that don't support RI", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.clr, + .opt.value = &cfg.clr, .value = SSL_OP_LEGACY_SERVER_CONNECT, }, { .name = "no_servername", .desc = "Do not send a Server Name Indication (SNI) extension", .type = OPTION_FLAG, - .opt.value = &s_client_config.no_servername, + .opt.value = &cfg.no_servername, }, { .name = "no_ssl2", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_SSLv2, }, { .name = "no_ssl3", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_SSLv3, }, { .name = "no_ticket", .desc = "Disable use of RFC4507 session ticket support", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_TICKET, }, { .name = "no_tls1", .desc = "Disable the use of TLSv1", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_TLSv1, }, { .name = "no_tls1_1", .desc = "Disable the use of TLSv1.1", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_TLSv1_1, }, { .name = "no_tls1_2", .desc = "Disable the use of TLSv1.2", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_TLSv1_2, }, { .name = "no_tls1_3", .desc = "Disable the use of TLSv1.3", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_TLSv1_3, }, { .name = "noservername", .type = OPTION_FLAG, - .opt.value = &s_client_config.no_servername, + .opt.value = &cfg.no_servername, }, { .name = "pass", .argname = "arg", .desc = "Private key file pass phrase source", .type = OPTION_ARG, - .opt.arg = &s_client_config.passarg, + .opt.arg = &cfg.passarg, }, { .name = "pause", .desc = "Pause 1 second between each read and write call", .type = OPTION_FLAG, - .opt.flag = &s_client_config.pause, + .opt.flag = &cfg.pause, }, { .name = "peekaboo", .type = OPTION_FLAG, - .opt.flag = &s_client_config.peekaboo, + .opt.flag = &cfg.peekaboo, }, { .name = "port", @@ -721,14 +721,14 @@ static const struct option s_client_options[] = { .name = "prexit", .desc = "Print session information when the program exits", .type = OPTION_FLAG, - .opt.flag = &s_client_config.prexit, + .opt.flag = &cfg.prexit, }, { .name = "proxy", .argname = "host:port", .desc = "Connect to http proxy", .type = OPTION_ARG, - .opt.arg = &s_client_config.proxy, + .opt.arg = &cfg.proxy, }, { .name = "quiet", @@ -740,7 +740,7 @@ static const struct option s_client_options[] = { .name = "reconnect", .desc = "Drop and re-make the connection with the same Session-ID", .type = OPTION_VALUE, - .opt.value = &s_client_config.reconnect, + .opt.value = &cfg.reconnect, .value = 5, }, { @@ -748,13 +748,13 @@ static const struct option s_client_options[] = { .argname = "name", .desc = "Set TLS extension servername in ClientHello (SNI)", .type = OPTION_ARG, - .opt.arg = &s_client_config.servername, + .opt.arg = &cfg.servername, }, { .name = "serverpref", .desc = "Use server's cipher preferences", .type = OPTION_VALUE_OR, - .opt.value = &s_client_config.off, + .opt.value = &cfg.off, .value = SSL_OP_CIPHER_SERVER_PREFERENCE, }, { @@ -762,20 +762,20 @@ static const struct option s_client_options[] = { .argname = "file", .desc = "File to read TLS session from", .type = OPTION_ARG, - .opt.arg = &s_client_config.sess_in, + .opt.arg = &cfg.sess_in, }, { .name = "sess_out", .argname = "file", .desc = "File to write TLS session to", .type = OPTION_ARG, - .opt.arg = &s_client_config.sess_out, + .opt.arg = &cfg.sess_out, }, { .name = "showcerts", .desc = "Show all server certificates in the chain", .type = OPTION_FLAG, - .opt.flag = &s_client_config.showcerts, + .opt.flag = &cfg.showcerts, }, { .name = "starttls", @@ -789,20 +789,20 @@ static const struct option s_client_options[] = { .name = "state", .desc = "Print the TLS session states", .type = OPTION_FLAG, - .opt.flag = &s_client_config.state, + .opt.flag = &cfg.state, }, { .name = "status", .desc = "Send a certificate status request to the server (OCSP)", .type = OPTION_FLAG, - .opt.flag = &s_client_config.status_req, + .opt.flag = &cfg.status_req, }, #ifndef OPENSSL_NO_DTLS { .name = "timeout", .desc = "Enable send/receive timeout on DTLS connections", .type = OPTION_FLAG, - .opt.flag = &s_client_config.enable_timeouts, + .opt.flag = &cfg.enable_timeouts, }, #endif { @@ -833,7 +833,7 @@ static const struct option s_client_options[] = { .name = "tlsextdebug", .desc = "Hex dump of all TLS extensions received", .type = OPTION_FLAG, - .opt.flag = &s_client_config.tlsextdebug, + .opt.flag = &cfg.tlsextdebug, }, #ifndef OPENSSL_NO_SRTP { @@ -841,7 +841,7 @@ static const struct option s_client_options[] = { .argname = "profiles", .desc = "Offer SRTP key management with a colon-separated profiles", .type = OPTION_ARG, - .opt.arg = &s_client_config.srtp_profiles, + .opt.arg = &cfg.srtp_profiles, }, #endif { @@ -862,7 +862,7 @@ static const struct option s_client_options[] = { .argname = "host", .desc = "Connect to this virtual host on the xmpp server", .type = OPTION_ARG, - .opt.arg = &s_client_config.xmpphost, + .opt.arg = &cfg.xmpphost, }, { .name = NULL, @@ -923,24 +923,22 @@ s_client_main(int argc, char **argv) struct sockaddr_storage peer; int peerlen = sizeof(peer); - if (single_execution) { - if (pledge("stdio cpath wpath rpath inet dns tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath inet dns tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&s_client_config, 0, sizeof(s_client_config)); - s_client_config.af = AF_UNSPEC; - s_client_config.cert_format = FORMAT_PEM; - s_client_config.host = SSL_HOST_NAME; - s_client_config.key_format = FORMAT_PEM; - s_client_config.keymatexportlen = 20; - s_client_config.meth = TLS_client_method(); - s_client_config.port = PORT_STR; - s_client_config.socket_type = SOCK_STREAM; - s_client_config.starttls_proto = PROTO_OFF; - s_client_config.verify = SSL_VERIFY_NONE; + memset(&cfg, 0, sizeof(cfg)); + cfg.af = AF_UNSPEC; + cfg.cert_format = FORMAT_PEM; + cfg.host = SSL_HOST_NAME; + cfg.key_format = FORMAT_PEM; + cfg.keymatexportlen = 20; + cfg.meth = TLS_client_method(); + cfg.port = PORT_STR; + cfg.socket_type = SOCK_STREAM; + cfg.starttls_proto = PROTO_OFF; + cfg.verify = SSL_VERIFY_NONE; if (((cbuf = malloc(BUFSIZZ)) == NULL) || ((sbuf = malloc(BUFSIZZ)) == NULL) || @@ -955,45 +953,45 @@ s_client_main(int argc, char **argv) badop = 1; goto bad; } - if (s_client_config.proxy != NULL) { - if (!extract_host_port(s_client_config.proxy, - &s_client_config.host, NULL, &s_client_config.port)) + if (cfg.proxy != NULL) { + if (!extract_host_port(cfg.proxy, + &cfg.host, NULL, &cfg.port)) goto bad; - if (s_client_config.connect == NULL) - s_client_config.connect = SSL_HOST_NAME; - } else if (s_client_config.connect != NULL) { - if (!extract_host_port(s_client_config.connect, - &s_client_config.host, NULL, &s_client_config.port)) + if (cfg.connect == NULL) + cfg.connect = SSL_HOST_NAME; + } else if (cfg.connect != NULL) { + if (!extract_host_port(cfg.connect, + &cfg.host, NULL, &cfg.port)) goto bad; } if (badop) { bad: - if (s_client_config.errstr == NULL) + if (cfg.errstr == NULL) sc_usage(); goto end; } - if (!app_passwd(bio_err, s_client_config.passarg, NULL, &pass, NULL)) { + if (!app_passwd(bio_err, cfg.passarg, NULL, &pass, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } - if (s_client_config.key_file == NULL) - s_client_config.key_file = s_client_config.cert_file; + if (cfg.key_file == NULL) + cfg.key_file = cfg.cert_file; - if (s_client_config.key_file) { + if (cfg.key_file) { - key = load_key(bio_err, s_client_config.key_file, - s_client_config.key_format, 0, pass, + key = load_key(bio_err, cfg.key_file, + cfg.key_format, 0, pass, "client certificate private key file"); if (!key) { ERR_print_errors(bio_err); goto end; } } - if (s_client_config.cert_file) { - cert = load_cert(bio_err, s_client_config.cert_file, - s_client_config.cert_format, + if (cfg.cert_file) { + cert = load_cert(bio_err, cfg.cert_file, + cfg.cert_format, NULL, "client certificate file"); if (!cert) { @@ -1001,8 +999,8 @@ s_client_main(int argc, char **argv) goto end; } } - if (s_client_config.quiet && !s_client_config.debug && - !s_client_config.msg) { + if (cfg.quiet && !cfg.debug && + !cfg.msg) { if ((bio_c_out = BIO_new(BIO_s_null())) == NULL) goto end; } else { @@ -1010,7 +1008,7 @@ s_client_main(int argc, char **argv) goto end; } - ctx = SSL_CTX_new(s_client_config.meth); + ctx = SSL_CTX_new(cfg.meth); if (ctx == NULL) { ERR_print_errors(bio_err); goto end; @@ -1018,31 +1016,31 @@ s_client_main(int argc, char **argv) SSL_CTX_clear_mode(ctx, SSL_MODE_AUTO_RETRY); - if (s_client_config.vpm) - SSL_CTX_set1_param(ctx, s_client_config.vpm); + if (cfg.vpm) + SSL_CTX_set1_param(ctx, cfg.vpm); - if (!SSL_CTX_set_min_proto_version(ctx, s_client_config.min_version)) + if (!SSL_CTX_set_min_proto_version(ctx, cfg.min_version)) goto end; - if (!SSL_CTX_set_max_proto_version(ctx, s_client_config.max_version)) + if (!SSL_CTX_set_max_proto_version(ctx, cfg.max_version)) goto end; #ifndef OPENSSL_NO_SRTP - if (s_client_config.srtp_profiles != NULL) - SSL_CTX_set_tlsext_use_srtp(ctx, s_client_config.srtp_profiles); + if (cfg.srtp_profiles != NULL) + SSL_CTX_set_tlsext_use_srtp(ctx, cfg.srtp_profiles); #endif - if (s_client_config.bugs) - SSL_CTX_set_options(ctx, SSL_OP_ALL | s_client_config.off); + if (cfg.bugs) + SSL_CTX_set_options(ctx, SSL_OP_ALL | cfg.off); else - SSL_CTX_set_options(ctx, s_client_config.off); + SSL_CTX_set_options(ctx, cfg.off); - if (s_client_config.clr) - SSL_CTX_clear_options(ctx, s_client_config.clr); + if (cfg.clr) + SSL_CTX_clear_options(ctx, cfg.clr); - if (s_client_config.alpn_in) { + if (cfg.alpn_in) { unsigned short alpn_len; unsigned char *alpn; - alpn = next_protos_parse(&alpn_len, s_client_config.alpn_in); + alpn = next_protos_parse(&alpn_len, cfg.alpn_in); if (alpn == NULL) { BIO_printf(bio_err, "Error parsing -alpn argument\n"); goto end; @@ -1050,42 +1048,42 @@ s_client_main(int argc, char **argv) SSL_CTX_set_alpn_protos(ctx, alpn, alpn_len); free(alpn); } - if (s_client_config.groups_in != NULL) { - if (SSL_CTX_set1_groups_list(ctx, s_client_config.groups_in) != 1) { + if (cfg.groups_in != NULL) { + if (SSL_CTX_set1_groups_list(ctx, cfg.groups_in) != 1) { BIO_printf(bio_err, "Failed to set groups '%s'\n", - s_client_config.groups_in); + cfg.groups_in); goto end; } } - if (s_client_config.state) + if (cfg.state) SSL_CTX_set_info_callback(ctx, apps_ssl_info_callback); - if (s_client_config.cipher != NULL) - if (!SSL_CTX_set_cipher_list(ctx, s_client_config.cipher)) { + if (cfg.cipher != NULL) + if (!SSL_CTX_set_cipher_list(ctx, cfg.cipher)) { BIO_printf(bio_err, "error setting cipher list\n"); ERR_print_errors(bio_err); goto end; } - SSL_CTX_set_verify(ctx, s_client_config.verify, verify_callback); + SSL_CTX_set_verify(ctx, cfg.verify, verify_callback); if (!set_cert_key_stuff(ctx, cert, key)) goto end; - if ((s_client_config.CAfile || s_client_config.CApath) - && !SSL_CTX_load_verify_locations(ctx, s_client_config.CAfile, - s_client_config.CApath)) + if ((cfg.CAfile || cfg.CApath) + && !SSL_CTX_load_verify_locations(ctx, cfg.CAfile, + cfg.CApath)) ERR_print_errors(bio_err); if (!SSL_CTX_set_default_verify_paths(ctx)) ERR_print_errors(bio_err); con = SSL_new(ctx); - if (s_client_config.sess_in) { + if (cfg.sess_in) { SSL_SESSION *sess; - BIO *stmp = BIO_new_file(s_client_config.sess_in, "r"); + BIO *stmp = BIO_new_file(cfg.sess_in, "r"); if (!stmp) { BIO_printf(bio_err, "Can't open session file %s\n", - s_client_config.sess_in); + cfg.sess_in); ERR_print_errors(bio_err); goto end; } @@ -1093,7 +1091,7 @@ s_client_main(int argc, char **argv) BIO_free(stmp); if (!sess) { BIO_printf(bio_err, "Can't open session file %s\n", - s_client_config.sess_in); + cfg.sess_in); ERR_print_errors(bio_err); goto end; } @@ -1102,15 +1100,15 @@ s_client_main(int argc, char **argv) } /* Attempt to opportunistically use the host name for SNI. */ - servername = s_client_config.servername; + servername = cfg.servername; if (servername == NULL) - servername = s_client_config.host; + servername = cfg.host; - if (!s_client_config.no_servername && servername != NULL && + if (!cfg.no_servername && servername != NULL && !SSL_set_tlsext_host_name(con, servername)) { long ssl_err = ERR_peek_error(); - if (s_client_config.servername != NULL || + if (cfg.servername != NULL || ERR_GET_LIB(ssl_err) != ERR_LIB_SSL || ERR_GET_REASON(ssl_err) != SSL_R_SSL3_EXT_INVALID_SERVERNAME) { BIO_printf(bio_err, @@ -1121,7 +1119,7 @@ s_client_main(int argc, char **argv) servername = NULL; ERR_clear_error(); } - if (!s_client_config.no_servername && servername != NULL) { + if (!cfg.no_servername && servername != NULL) { tlsextcbp.biodebug = bio_err; SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb); SSL_CTX_set_tlsext_servername_arg(ctx, &tlsextcbp); @@ -1129,22 +1127,22 @@ s_client_main(int argc, char **argv) re_start: - if (init_client(&s, s_client_config.host, s_client_config.port, - s_client_config.socket_type, s_client_config.af) == 0) { + if (init_client(&s, cfg.host, cfg.port, + cfg.socket_type, cfg.af) == 0) { BIO_printf(bio_err, "connect:errno=%d\n", errno); goto end; } BIO_printf(bio_c_out, "CONNECTED(%08X)\n", s); - if (s_client_config.nbio) { - if (!s_client_config.quiet) + if (cfg.nbio) { + if (!cfg.quiet) BIO_printf(bio_c_out, "turning on non blocking io\n"); if (!BIO_socket_nbio(s, 1)) { ERR_print_errors(bio_err); goto end; } } - if (s_client_config.pause & 0x01) + if (cfg.pause & 0x01) SSL_set_debug(con, 1); if (SSL_is_dtls(con)) { @@ -1159,7 +1157,7 @@ s_client_main(int argc, char **argv) } (void) BIO_ctrl_set_connected(sbio, 1, &peer); - if (s_client_config.enable_timeouts) { + if (cfg.enable_timeouts) { timeout.tv_sec = 0; timeout.tv_usec = DGRAM_RCV_TIMEOUT; BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_RECV_TIMEOUT, 0, @@ -1170,35 +1168,35 @@ s_client_main(int argc, char **argv) BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout); } - if (s_client_config.socket_mtu > 28) { + if (cfg.socket_mtu > 28) { SSL_set_options(con, SSL_OP_NO_QUERY_MTU); - SSL_set_mtu(con, s_client_config.socket_mtu - 28); + SSL_set_mtu(con, cfg.socket_mtu - 28); } else /* want to do MTU discovery */ BIO_ctrl(sbio, BIO_CTRL_DGRAM_MTU_DISCOVER, 0, NULL); } else sbio = BIO_new_socket(s, BIO_NOCLOSE); - if (s_client_config.nbio_test) { + if (cfg.nbio_test) { BIO *test; test = BIO_new(BIO_f_nbio_test()); sbio = BIO_push(test, sbio); } - if (s_client_config.debug) { + if (cfg.debug) { SSL_set_debug(con, 1); BIO_set_callback(sbio, bio_dump_callback); BIO_set_callback_arg(sbio, (char *) bio_c_out); } - if (s_client_config.msg) { + if (cfg.msg) { SSL_set_msg_callback(con, msg_cb); SSL_set_msg_callback_arg(con, bio_c_out); } - if (s_client_config.tlsextdebug) { + if (cfg.tlsextdebug) { SSL_set_tlsext_debug_callback(con, tlsext_cb); SSL_set_tlsext_debug_arg(con, bio_c_out); } - if (s_client_config.status_req) { + if (cfg.status_req) { SSL_set_tlsext_status_type(con, TLSEXT_STATUSTYPE_ocsp); SSL_CTX_set_tlsext_status_cb(ctx, ocsp_resp_cb); SSL_CTX_set_tlsext_status_arg(ctx, bio_c_out); @@ -1227,8 +1225,8 @@ s_client_main(int argc, char **argv) * push a buffering BIO into the chain that is removed again later on * to not disturb the rest of the s_client operation. */ - if (s_client_config.starttls_proto == PROTO_SMTP || - s_client_config.starttls_proto == PROTO_LMTP) { + if (cfg.starttls_proto == PROTO_SMTP || + cfg.starttls_proto == PROTO_LMTP) { int foundit = 0; BIO *fbio = BIO_new(BIO_f_buffer()); BIO_push(fbio, sbio); @@ -1239,7 +1237,7 @@ s_client_main(int argc, char **argv) while (mbuf_len > 3 && mbuf[3] == '-'); /* STARTTLS command requires EHLO... */ BIO_printf(fbio, "%cHLO openssl.client.net\r\n", - s_client_config.starttls_proto == PROTO_SMTP ? 'E' : 'L'); + cfg.starttls_proto == PROTO_SMTP ? 'E' : 'L'); (void) BIO_flush(fbio); /* wait for multi-line response to end EHLO SMTP response */ do { @@ -1257,7 +1255,7 @@ s_client_main(int argc, char **argv) " try anyway...\n"); BIO_printf(sbio, "STARTTLS\r\n"); BIO_read(sbio, sbuf, BUFSIZZ); - } else if (s_client_config.starttls_proto == PROTO_POP3) { + } else if (cfg.starttls_proto == PROTO_POP3) { mbuf_len = BIO_read(sbio, mbuf, BUFSIZZ); if (mbuf_len == -1) { BIO_printf(bio_err, "BIO_read failed\n"); @@ -1265,7 +1263,7 @@ s_client_main(int argc, char **argv) } BIO_printf(sbio, "STLS\r\n"); BIO_read(sbio, sbuf, BUFSIZZ); - } else if (s_client_config.starttls_proto == PROTO_IMAP) { + } else if (cfg.starttls_proto == PROTO_IMAP) { int foundit = 0; BIO *fbio = BIO_new(BIO_f_buffer()); BIO_push(fbio, sbio); @@ -1289,7 +1287,7 @@ s_client_main(int argc, char **argv) " try anyway...\n"); BIO_printf(sbio, ". STARTTLS\r\n"); BIO_read(sbio, sbuf, BUFSIZZ); - } else if (s_client_config.starttls_proto == PROTO_FTP) { + } else if (cfg.starttls_proto == PROTO_FTP) { BIO *fbio = BIO_new(BIO_f_buffer()); BIO_push(fbio, sbio); /* wait for multi-line response to end from FTP */ @@ -1302,13 +1300,13 @@ s_client_main(int argc, char **argv) BIO_free(fbio); BIO_printf(sbio, "AUTH TLS\r\n"); BIO_read(sbio, sbuf, BUFSIZZ); - } else if (s_client_config.starttls_proto == PROTO_XMPP) { + } else if (cfg.starttls_proto == PROTO_XMPP) { int seen = 0; BIO_printf(sbio, "", - s_client_config.xmpphost ? - s_client_config.xmpphost : s_client_config.host); + cfg.xmpphost ? + cfg.xmpphost : cfg.host); seen = BIO_read(sbio, mbuf, BUFSIZZ); if (seen <= 0) @@ -1331,9 +1329,9 @@ s_client_main(int argc, char **argv) if (!strstr(sbuf, " 0) full_log--; - if (s_client_config.starttls_proto) { + if (cfg.starttls_proto) { BIO_write(bio_err, mbuf, mbuf_len); /* We don't need to know any more */ - s_client_config.starttls_proto = PROTO_OFF; + cfg.starttls_proto = PROTO_OFF; } - if (s_client_config.reconnect) { - s_client_config.reconnect--; + if (cfg.reconnect) { + cfg.reconnect--; BIO_printf(bio_c_out, "drop connection and then reconnect\n"); SSL_shutdown(con); @@ -1518,7 +1516,7 @@ s_client_main(int argc, char **argv) } } #endif - if (s_client_config.peekaboo) { + if (cfg.peekaboo) { k = p = SSL_peek(con, pbuf, 1024 /* BUFSIZZ */ ); pending = SSL_pending(con); if (SSL_get_error(con, p) == SSL_ERROR_NONE) { @@ -1537,7 +1535,7 @@ s_client_main(int argc, char **argv) goto end; sbuf_off = 0; sbuf_len = k; - if (s_client_config.peekaboo) { + if (cfg.peekaboo) { if (p != pending) { ret = -1; BIO_printf(bio_err, @@ -1596,7 +1594,7 @@ s_client_main(int argc, char **argv) BIO_printf(bio_err, "poll error"); goto shut; } - if (s_client_config.crlf) { + if (cfg.crlf) { int j, lf_num; i = read(fileno(stdin), cbuf, BUFSIZZ / 2); @@ -1617,13 +1615,13 @@ s_client_main(int argc, char **argv) } else i = read(fileno(stdin), cbuf, BUFSIZZ); - if ((!s_client_config.ign_eof) && + if ((!cfg.ign_eof) && ((i <= 0) || (cbuf[0] == 'Q'))) { BIO_printf(bio_err, "DONE\n"); ret = 0; goto shut; } - if ((!s_client_config.ign_eof) && (cbuf[0] == 'R')) { + if ((!cfg.ign_eof) && (cbuf[0] == 'R')) { BIO_printf(bio_err, "RENEGOTIATING\n"); SSL_renegotiate(con); cbuf_len = 0; @@ -1646,7 +1644,7 @@ s_client_main(int argc, char **argv) close(SSL_get_fd(con)); end: if (con != NULL) { - if (s_client_config.prexit != 0) + if (cfg.prexit != 0) print_stuff(bio_c_out, con, 1); SSL_free(con); } @@ -1654,7 +1652,7 @@ s_client_main(int argc, char **argv) X509_free(cert); EVP_PKEY_free(key); free(pass); - X509_VERIFY_PARAM_free(s_client_config.vpm); + X509_VERIFY_PARAM_free(cfg.vpm); freezero(cbuf, BUFSIZZ); freezero(sbuf, BUFSIZZ); freezero(pbuf, BUFSIZZ); @@ -1694,7 +1692,7 @@ print_stuff(BIO *bio, SSL *s, int full) X509_NAME_oneline(X509_get_issuer_name( sk_X509_value(sk, i)), buf, sizeof buf); BIO_printf(bio, " i:%s\n", buf); - if (s_client_config.showcerts) + if (cfg.showcerts) PEM_write_bio_X509(bio, sk_X509_value(sk, i)); } @@ -1703,7 +1701,7 @@ print_stuff(BIO *bio, SSL *s, int full) peer = SSL_get_peer_certificate(s); if (peer != NULL) { BIO_printf(bio, "Server certificate\n"); - if (!(s_client_config.showcerts && got_a_chain)) { + if (!(cfg.showcerts && got_a_chain)) { /* Redundant if we showed the whole chain */ PEM_write_bio_X509(bio, peer); } @@ -1822,23 +1820,23 @@ print_stuff(BIO *bio, SSL *s, int full) #endif SSL_SESSION_print(bio, SSL_get_session(s)); - if (s_client_config.keymatexportlabel != NULL) { + if (cfg.keymatexportlabel != NULL) { BIO_printf(bio, "Keying material exporter:\n"); BIO_printf(bio, " Label: '%s'\n", - s_client_config.keymatexportlabel); + cfg.keymatexportlabel); BIO_printf(bio, " Length: %i bytes\n", - s_client_config.keymatexportlen); - exportedkeymat = malloc(s_client_config.keymatexportlen); + cfg.keymatexportlen); + exportedkeymat = malloc(cfg.keymatexportlen); if (exportedkeymat != NULL) { if (!SSL_export_keying_material(s, exportedkeymat, - s_client_config.keymatexportlen, - s_client_config.keymatexportlabel, - strlen(s_client_config.keymatexportlabel), + cfg.keymatexportlen, + cfg.keymatexportlabel, + strlen(cfg.keymatexportlabel), NULL, 0, 0)) { BIO_printf(bio, " Error\n"); } else { BIO_printf(bio, " Keying material: "); - for (i = 0; i < s_client_config.keymatexportlen; i++) + for (i = 0; i < cfg.keymatexportlen; i++) BIO_printf(bio, "%02X", exportedkeymat[i]); BIO_printf(bio, "\n"); diff --git a/apps/openssl/s_server.c b/apps/openssl/s_server.c index 9b06856a..a7f6146c 100644 --- a/apps/openssl/s_server.c +++ b/apps/openssl/s_server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_server.c,v 1.54 2021/12/06 11:06:58 tb Exp $ */ +/* $OpenBSD: s_server.c,v 1.56 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -294,23 +294,23 @@ static struct { int tlsextstatus; X509_VERIFY_PARAM *vpm; int www; -} s_server_config; +} cfg; static int s_server_opt_context(char *arg) { - s_server_config.context = (unsigned char *) arg; + cfg.context = (unsigned char *) arg; return (0); } static int s_server_opt_keymatexportlen(char *arg) { - s_server_config.keymatexportlen = strtonum(arg, 1, INT_MAX, - &s_server_config.errstr); - if (s_server_config.errstr != NULL) { + cfg.keymatexportlen = strtonum(arg, 1, INT_MAX, + &cfg.errstr); + if (cfg.errstr != NULL) { BIO_printf(bio_err, "invalid argument %s: %s\n", - arg, s_server_config.errstr); + arg, cfg.errstr); return (1); } return (0); @@ -320,11 +320,11 @@ s_server_opt_keymatexportlen(char *arg) static int s_server_opt_mtu(char *arg) { - s_server_config.socket_mtu = strtonum(arg, 0, LONG_MAX, - &s_server_config.errstr); - if (s_server_config.errstr != NULL) { + cfg.socket_mtu = strtonum(arg, 0, LONG_MAX, + &cfg.errstr); + if (cfg.errstr != NULL) { BIO_printf(bio_err, "invalid argument %s: %s\n", - arg, s_server_config.errstr); + arg, cfg.errstr); return (1); } return (0); @@ -335,8 +335,8 @@ s_server_opt_mtu(char *arg) static int s_server_opt_protocol_version_dtls(void) { - s_server_config.meth = DTLS_server_method(); - s_server_config.socket_type = SOCK_DGRAM; + cfg.meth = DTLS_server_method(); + cfg.socket_type = SOCK_DGRAM; return (0); } #endif @@ -345,10 +345,10 @@ s_server_opt_protocol_version_dtls(void) static int s_server_opt_protocol_version_dtls1(void) { - s_server_config.meth = DTLS_server_method(); - s_server_config.min_version = DTLS1_VERSION; - s_server_config.max_version = DTLS1_VERSION; - s_server_config.socket_type = SOCK_DGRAM; + cfg.meth = DTLS_server_method(); + cfg.min_version = DTLS1_VERSION; + cfg.max_version = DTLS1_VERSION; + cfg.socket_type = SOCK_DGRAM; return (0); } #endif @@ -357,10 +357,10 @@ s_server_opt_protocol_version_dtls1(void) static int s_server_opt_protocol_version_dtls1_2(void) { - s_server_config.meth = DTLS_server_method(); - s_server_config.min_version = DTLS1_2_VERSION; - s_server_config.max_version = DTLS1_2_VERSION; - s_server_config.socket_type = SOCK_DGRAM; + cfg.meth = DTLS_server_method(); + cfg.min_version = DTLS1_2_VERSION; + cfg.max_version = DTLS1_2_VERSION; + cfg.socket_type = SOCK_DGRAM; return (0); } #endif @@ -368,47 +368,47 @@ s_server_opt_protocol_version_dtls1_2(void) static int s_server_opt_protocol_version_tls1(void) { - s_server_config.min_version = TLS1_VERSION; - s_server_config.max_version = TLS1_VERSION; + cfg.min_version = TLS1_VERSION; + cfg.max_version = TLS1_VERSION; return (0); } static int s_server_opt_protocol_version_tls1_1(void) { - s_server_config.min_version = TLS1_1_VERSION; - s_server_config.max_version = TLS1_1_VERSION; + cfg.min_version = TLS1_1_VERSION; + cfg.max_version = TLS1_1_VERSION; return (0); } static int s_server_opt_protocol_version_tls1_2(void) { - s_server_config.min_version = TLS1_2_VERSION; - s_server_config.max_version = TLS1_2_VERSION; + cfg.min_version = TLS1_2_VERSION; + cfg.max_version = TLS1_2_VERSION; return (0); } static int s_server_opt_protocol_version_tls1_3(void) { - s_server_config.min_version = TLS1_3_VERSION; - s_server_config.max_version = TLS1_3_VERSION; + cfg.min_version = TLS1_3_VERSION; + cfg.max_version = TLS1_3_VERSION; return (0); } static int s_server_opt_nbio_test(void) { - s_server_config.nbio = 1; - s_server_config.nbio_test = 1; + cfg.nbio = 1; + cfg.nbio_test = 1; return (0); } static int s_server_opt_port(char *arg) { - if (!extract_port(arg, &s_server_config.port)) + if (!extract_port(arg, &cfg.port)) return (1); return (0); } @@ -416,12 +416,12 @@ s_server_opt_port(char *arg) static int s_server_opt_status_timeout(char *arg) { - s_server_config.tlsextstatus = 1; - s_server_config.tlscstatp.timeout = strtonum(arg, 0, INT_MAX, - &s_server_config.errstr); - if (s_server_config.errstr != NULL) { + cfg.tlsextstatus = 1; + cfg.tlscstatp.timeout = strtonum(arg, 0, INT_MAX, + &cfg.errstr); + if (cfg.errstr != NULL) { BIO_printf(bio_err, "invalid argument %s: %s\n", - arg, s_server_config.errstr); + arg, cfg.errstr); return (1); } return (0); @@ -430,10 +430,10 @@ s_server_opt_status_timeout(char *arg) static int s_server_opt_status_url(char *arg) { - s_server_config.tlsextstatus = 1; - if (!OCSP_parse_url(arg, &s_server_config.tlscstatp.host, - &s_server_config.tlscstatp.port, &s_server_config.tlscstatp.path, - &s_server_config.tlscstatp.use_ssl)) { + cfg.tlsextstatus = 1; + if (!OCSP_parse_url(arg, &cfg.tlscstatp.host, + &cfg.tlscstatp.port, &cfg.tlscstatp.path, + &cfg.tlscstatp.use_ssl)) { BIO_printf(bio_err, "Error parsing URL\n"); return (1); } @@ -443,20 +443,20 @@ s_server_opt_status_url(char *arg) static int s_server_opt_status_verbose(void) { - s_server_config.tlsextstatus = 1; - s_server_config.tlscstatp.verbose = 1; + cfg.tlsextstatus = 1; + cfg.tlscstatp.verbose = 1; return (0); } static int s_server_opt_verify(char *arg) { - s_server_config.server_verify = SSL_VERIFY_PEER | + cfg.server_verify = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE; - verify_depth = strtonum(arg, 0, INT_MAX, &s_server_config.errstr); - if (s_server_config.errstr != NULL) { + verify_depth = strtonum(arg, 0, INT_MAX, &cfg.errstr); + if (cfg.errstr != NULL) { BIO_printf(bio_err, "invalid argument %s: %s\n", - arg, s_server_config.errstr); + arg, cfg.errstr); return (1); } BIO_printf(bio_err, "verify depth is %d\n", verify_depth); @@ -466,12 +466,12 @@ s_server_opt_verify(char *arg) static int s_server_opt_verify_fail(char *arg) { - s_server_config.server_verify = SSL_VERIFY_PEER | + cfg.server_verify = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT | SSL_VERIFY_CLIENT_ONCE; - verify_depth = strtonum(arg, 0, INT_MAX, &s_server_config.errstr); - if (s_server_config.errstr != NULL) { + verify_depth = strtonum(arg, 0, INT_MAX, &cfg.errstr); + if (cfg.errstr != NULL) { BIO_printf(bio_err, "invalid argument %s: %s\n", - arg, s_server_config.errstr); + arg, cfg.errstr); return (1); } BIO_printf(bio_err, "verify depth is %d, must return a certificate\n", @@ -487,7 +487,7 @@ s_server_opt_verify_param(int argc, char **argv, int *argsused) int badarg = 0; if (!args_verify(&pargs, &pargc, &badarg, bio_err, - &s_server_config.vpm)) { + &cfg.vpm)) { BIO_printf(bio_err, "unknown option %s\n", *argv); return (1); } @@ -520,27 +520,27 @@ static const struct option s_server_options[] = { .desc = "Set the advertised protocols for the ALPN extension" " (comma-separated list)", .type = OPTION_ARG, - .opt.arg = &s_server_config.alpn_in, + .opt.arg = &cfg.alpn_in, }, { .name = "bugs", .desc = "Turn on SSL bug compatibility", .type = OPTION_FLAG, - .opt.flag = &s_server_config.bugs, + .opt.flag = &cfg.bugs, }, { .name = "CAfile", .argname = "file", .desc = "PEM format file of CA certificates", .type = OPTION_ARG, - .opt.arg = &s_server_config.CAfile, + .opt.arg = &cfg.CAfile, }, { .name = "CApath", .argname = "directory", .desc = "PEM format directory of CA certificates", .type = OPTION_ARG, - .opt.arg = &s_server_config.CApath, + .opt.arg = &cfg.CApath, }, { .name = "cert", @@ -548,7 +548,7 @@ static const struct option s_server_options[] = { .desc = "Certificate file to use\n" "(default is " TEST_CERT ")", .type = OPTION_ARG, - .opt.arg = &s_server_config.cert_file, + .opt.arg = &cfg.cert_file, }, { .name = "cert2", @@ -556,20 +556,20 @@ static const struct option s_server_options[] = { .desc = "Certificate file to use for servername\n" "(default is " TEST_CERT2 ")", .type = OPTION_ARG, - .opt.arg = &s_server_config.cert_file2, + .opt.arg = &cfg.cert_file2, }, { .name = "certform", .argname = "fmt", .desc = "Certificate format (PEM or DER) PEM default", .type = OPTION_ARG_FORMAT, - .opt.value = &s_server_config.cert_format, + .opt.value = &cfg.cert_format, }, #ifndef OPENSSL_NO_DTLS { .name = "chain", .type = OPTION_FLAG, - .opt.flag = &s_server_config.cert_chain, + .opt.flag = &cfg.cert_chain, }, #endif { @@ -577,7 +577,7 @@ static const struct option s_server_options[] = { .argname = "list", .desc = "List of ciphers to enable (see `openssl ciphers`)", .type = OPTION_ARG, - .opt.arg = &s_server_config.cipher, + .opt.arg = &cfg.cipher, }, { .name = "context", @@ -590,55 +590,55 @@ static const struct option s_server_options[] = { .name = "crlf", .desc = "Convert LF from terminal into CRLF", .type = OPTION_FLAG, - .opt.flag = &s_server_config.crlf, + .opt.flag = &cfg.crlf, }, { .name = "dcert", .argname = "file", .desc = "Second certificate file to use (usually for DSA)", .type = OPTION_ARG, - .opt.arg = &s_server_config.dcert_file, + .opt.arg = &cfg.dcert_file, }, { .name = "dcertform", .argname = "fmt", .desc = "Second certificate format (PEM or DER) PEM default", .type = OPTION_ARG_FORMAT, - .opt.value = &s_server_config.dcert_format, + .opt.value = &cfg.dcert_format, }, { .name = "debug", .desc = "Print more output", .type = OPTION_FLAG, - .opt.flag = &s_server_config.debug, + .opt.flag = &cfg.debug, }, { .name = "dhparam", .argname = "file", .desc = "DH parameter file to use, in cert file if not specified", .type = OPTION_ARG, - .opt.arg = &s_server_config.dhfile, + .opt.arg = &cfg.dhfile, }, { .name = "dkey", .argname = "file", .desc = "Second private key file to use (usually for DSA)", .type = OPTION_ARG, - .opt.arg = &s_server_config.dkey_file, + .opt.arg = &cfg.dkey_file, }, { .name = "dkeyform", .argname = "fmt", .desc = "Second key format (PEM or DER) PEM default", .type = OPTION_ARG_FORMAT, - .opt.value = &s_server_config.dkey_format, + .opt.value = &cfg.dkey_format, }, { .name = "dpass", .argname = "arg", .desc = "Second private key file pass phrase source", .type = OPTION_ARG, - .opt.arg = &s_server_config.dpassarg, + .opt.arg = &cfg.dpassarg, }, #ifndef OPENSSL_NO_DTLS { @@ -669,13 +669,13 @@ static const struct option s_server_options[] = { .argname = "list", .desc = "Specify EC groups (colon-separated list)", .type = OPTION_ARG, - .opt.arg = &s_server_config.groups_in, + .opt.arg = &cfg.groups_in, }, { .name = "HTTP", .desc = "Respond to a 'GET / HTTP/1.0' with file ./", .type = OPTION_VALUE, - .opt.value = &s_server_config.www, + .opt.value = &cfg.www, .value = 3, }, { @@ -683,7 +683,7 @@ static const struct option s_server_options[] = { .argname = "arg", .desc = "Generate SSL/TLS session IDs prefixed by 'arg'", .type = OPTION_ARG, - .opt.arg = &s_server_config.session_id_prefix, + .opt.arg = &cfg.session_id_prefix, }, { .name = "key", @@ -691,7 +691,7 @@ static const struct option s_server_options[] = { .desc = "Private Key file to use, in cert file if\n" "not specified (default is " TEST_CERT ")", .type = OPTION_ARG, - .opt.arg = &s_server_config.key_file, + .opt.arg = &cfg.key_file, }, { .name = "key2", @@ -699,21 +699,21 @@ static const struct option s_server_options[] = { .desc = "Private Key file to use for servername, in cert file if\n" "not specified (default is " TEST_CERT2 ")", .type = OPTION_ARG, - .opt.arg = &s_server_config.key_file2, + .opt.arg = &cfg.key_file2, }, { .name = "keyform", .argname = "fmt", .desc = "Key format (PEM or DER) PEM default", .type = OPTION_ARG_FORMAT, - .opt.value = &s_server_config.key_format, + .opt.value = &cfg.key_format, }, { .name = "keymatexport", .argname = "label", .desc = "Export keying material using label", .type = OPTION_ARG, - .opt.arg = &s_server_config.keymatexportlabel, + .opt.arg = &cfg.keymatexportlabel, }, { .name = "keymatexportlen", @@ -730,7 +730,7 @@ static const struct option s_server_options[] = { .name = "msg", .desc = "Show protocol messages", .type = OPTION_FLAG, - .opt.flag = &s_server_config.msg, + .opt.flag = &cfg.msg, }, #ifndef OPENSSL_NO_DTLS { @@ -746,19 +746,19 @@ static const struct option s_server_options[] = { .argname = "num", .desc = "Terminate after num connections", .type = OPTION_ARG_INT, - .opt.value = &s_server_config.naccept + .opt.value = &cfg.naccept }, { .name = "named_curve", .argname = "arg", .type = OPTION_ARG, - .opt.arg = &s_server_config.named_curve, + .opt.arg = &cfg.named_curve, }, { .name = "nbio", .desc = "Run with non-blocking I/O", .type = OPTION_FLAG, - .opt.flag = &s_server_config.nbio, + .opt.flag = &cfg.nbio, }, { .name = "nbio_test", @@ -770,78 +770,78 @@ static const struct option s_server_options[] = { .name = "nextprotoneg", .argname = "arg", .type = OPTION_ARG, - .opt.arg = &s_server_config.npn_in, /* Ignored. */ + .opt.arg = &cfg.npn_in, /* Ignored. */ }, { .name = "no_cache", .desc = "Disable session cache", .type = OPTION_FLAG, - .opt.flag = &s_server_config.no_cache, + .opt.flag = &cfg.no_cache, }, { .name = "no_comp", .desc = "Disable SSL/TLS compression", .type = OPTION_VALUE_OR, - .opt.value = &s_server_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_COMPRESSION, }, { .name = "no_dhe", .desc = "Disable ephemeral DH", .type = OPTION_FLAG, - .opt.flag = &s_server_config.no_dhe, + .opt.flag = &cfg.no_dhe, }, { .name = "no_ecdhe", .desc = "Disable ephemeral ECDH", .type = OPTION_FLAG, - .opt.flag = &s_server_config.no_ecdhe, + .opt.flag = &cfg.no_ecdhe, }, { .name = "no_ticket", .desc = "Disable use of RFC4507bis session tickets", .type = OPTION_VALUE_OR, - .opt.value = &s_server_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_TICKET, }, { .name = "no_ssl2", .type = OPTION_VALUE_OR, - .opt.value = &s_server_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_SSLv2, }, { .name = "no_ssl3", .type = OPTION_VALUE_OR, - .opt.value = &s_server_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_SSLv3, }, { .name = "no_tls1", .desc = "Just disable TLSv1", .type = OPTION_VALUE_OR, - .opt.value = &s_server_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_TLSv1, }, { .name = "no_tls1_1", .desc = "Just disable TLSv1.1", .type = OPTION_VALUE_OR, - .opt.value = &s_server_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_TLSv1_1, }, { .name = "no_tls1_2", .desc = "Just disable TLSv1.2", .type = OPTION_VALUE_OR, - .opt.value = &s_server_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_TLSv1_2, }, { .name = "no_tls1_3", .desc = "Just disable TLSv1.3", .type = OPTION_VALUE_OR, - .opt.value = &s_server_config.off, + .opt.value = &cfg.off, .value = SSL_OP_NO_TLSv1_3, }, { @@ -852,14 +852,14 @@ static const struct option s_server_options[] = { .name = "nocert", .desc = "Don't use any certificates (Anon-DH)", .type = OPTION_FLAG, - .opt.flag = &s_server_config.nocert, + .opt.flag = &cfg.nocert, }, { .name = "pass", .argname = "arg", .desc = "Private key file pass phrase source", .type = OPTION_ARG, - .opt.arg = &s_server_config.passarg, + .opt.arg = &cfg.passarg, }, { .name = "port", @@ -871,40 +871,40 @@ static const struct option s_server_options[] = { .name = "quiet", .desc = "Inhibit printing of session and certificate information", .type = OPTION_FLAG, - .opt.flag = &s_server_config.quiet, + .opt.flag = &cfg.quiet, }, { .name = "servername", .argname = "name", .desc = "Servername for HostName TLS extension", .type = OPTION_ARG, - .opt.arg = &s_server_config.tlsextcbp.servername, + .opt.arg = &cfg.tlsextcbp.servername, }, { .name = "servername_fatal", .desc = "On mismatch send fatal alert (default warning alert)", .type = OPTION_VALUE, - .opt.value = &s_server_config.tlsextcbp.extension_error, + .opt.value = &cfg.tlsextcbp.extension_error, .value = SSL_TLSEXT_ERR_ALERT_FATAL, }, { .name = "serverpref", .desc = "Use server's cipher preferences", .type = OPTION_VALUE_OR, - .opt.value = &s_server_config.off, + .opt.value = &cfg.off, .value = SSL_OP_CIPHER_SERVER_PREFERENCE, }, { .name = "state", .desc = "Print the SSL states", .type = OPTION_FLAG, - .opt.flag = &s_server_config.state, + .opt.flag = &cfg.state, }, { .name = "status", .desc = "Respond to certificate status requests", .type = OPTION_FLAG, - .opt.flag = &s_server_config.tlsextstatus, + .opt.flag = &cfg.tlsextstatus, }, { .name = "status_timeout", @@ -931,7 +931,7 @@ static const struct option s_server_options[] = { .name = "timeout", .desc = "Enable timeouts", .type = OPTION_FLAG, - .opt.flag = &s_server_config.enable_timeouts, + .opt.flag = &cfg.enable_timeouts, }, #endif { @@ -962,7 +962,7 @@ static const struct option s_server_options[] = { .name = "tlsextdebug", .desc = "Hex dump of all TLS extensions received", .type = OPTION_FLAG, - .opt.flag = &s_server_config.tlsextdebug, + .opt.flag = &cfg.tlsextdebug, }, #ifndef OPENSSL_NO_SRTP { @@ -970,7 +970,7 @@ static const struct option s_server_options[] = { .argname = "profiles", .desc = "Offer SRTP key management with a colon-separated profile list", .type = OPTION_ARG, - .opt.arg = &s_server_config.srtp_profiles, + .opt.arg = &cfg.srtp_profiles, }, #endif { @@ -997,14 +997,14 @@ static const struct option s_server_options[] = { .name = "WWW", .desc = "Respond to a 'GET / HTTP/1.0' with file ./", .type = OPTION_VALUE, - .opt.value = &s_server_config.www, + .opt.value = &cfg.www, .value = 2, }, { .name = "www", .desc = "Respond to a 'GET /' with a status page", .type = OPTION_VALUE, - .opt.value = &s_server_config.www, + .opt.value = &cfg.www, .value = 1, }, { @@ -1020,24 +1020,24 @@ static void s_server_init(void) { accept_socket = -1; - s_server_config.cipher = NULL; - s_server_config.server_verify = SSL_VERIFY_NONE; - s_server_config.dcert_file = NULL; - s_server_config.dkey_file = NULL; - s_server_config.cert_file = TEST_CERT; - s_server_config.key_file = NULL; - s_server_config.cert_file2 = TEST_CERT2; - s_server_config.key_file2 = NULL; + cfg.cipher = NULL; + cfg.server_verify = SSL_VERIFY_NONE; + cfg.dcert_file = NULL; + cfg.dkey_file = NULL; + cfg.cert_file = TEST_CERT; + cfg.key_file = NULL; + cfg.cert_file2 = TEST_CERT2; + cfg.key_file2 = NULL; ctx2 = NULL; - s_server_config.nbio = 0; - s_server_config.nbio_test = 0; + cfg.nbio = 0; + cfg.nbio_test = 0; ctx = NULL; - s_server_config.www = 0; + cfg.www = 0; bio_s_out = NULL; - s_server_config.debug = 0; - s_server_config.msg = 0; - s_server_config.quiet = 0; + cfg.debug = 0; + cfg.msg = 0; + cfg.quiet = 0; } static void @@ -1081,28 +1081,26 @@ s_server_main(int argc, char *argv[]) X509 *s_cert2 = NULL; tlsextalpnctx alpn_ctx = { NULL, 0 }; - if (single_execution) { - if (pledge("stdio rpath inet dns tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio rpath inet dns tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&s_server_config, 0, sizeof(s_server_config)); - s_server_config.keymatexportlen = 20; - s_server_config.meth = TLS_server_method(); - s_server_config.naccept = -1; - s_server_config.port = PORT; - s_server_config.cert_file = TEST_CERT; - s_server_config.cert_file2 = TEST_CERT2; - s_server_config.cert_format = FORMAT_PEM; - s_server_config.dcert_format = FORMAT_PEM; - s_server_config.dkey_format = FORMAT_PEM; - s_server_config.key_format = FORMAT_PEM; - s_server_config.server_verify = SSL_VERIFY_NONE; - s_server_config.socket_type = SOCK_STREAM; - s_server_config.tlscstatp.timeout = -1; - s_server_config.tlsextcbp.extension_error = + memset(&cfg, 0, sizeof(cfg)); + cfg.keymatexportlen = 20; + cfg.meth = TLS_server_method(); + cfg.naccept = -1; + cfg.port = PORT; + cfg.cert_file = TEST_CERT; + cfg.cert_file2 = TEST_CERT2; + cfg.cert_format = FORMAT_PEM; + cfg.dcert_format = FORMAT_PEM; + cfg.dkey_format = FORMAT_PEM; + cfg.key_format = FORMAT_PEM; + cfg.server_verify = SSL_VERIFY_NONE; + cfg.socket_type = SOCK_STREAM; + cfg.tlscstatp.timeout = -1; + cfg.tlsextcbp.extension_error = SSL_TLSEXT_ERR_ALERT_WARNING; local_argc = argc; @@ -1113,47 +1111,47 @@ s_server_main(int argc, char *argv[]) verify_depth = 0; if (options_parse(argc, argv, s_server_options, NULL, NULL) != 0) { - if (s_server_config.errstr == NULL) + if (cfg.errstr == NULL) sv_usage(); goto end; } - if (!app_passwd(bio_err, s_server_config.passarg, - s_server_config.dpassarg, &pass, &dpass)) { + if (!app_passwd(bio_err, cfg.passarg, + cfg.dpassarg, &pass, &dpass)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } - if (s_server_config.key_file == NULL) - s_server_config.key_file = s_server_config.cert_file; - if (s_server_config.key_file2 == NULL) - s_server_config.key_file2 = s_server_config.cert_file2; - - if (s_server_config.nocert == 0) { - s_key = load_key(bio_err, s_server_config.key_file, - s_server_config.key_format, 0, pass, + if (cfg.key_file == NULL) + cfg.key_file = cfg.cert_file; + if (cfg.key_file2 == NULL) + cfg.key_file2 = cfg.cert_file2; + + if (cfg.nocert == 0) { + s_key = load_key(bio_err, cfg.key_file, + cfg.key_format, 0, pass, "server certificate private key file"); if (!s_key) { ERR_print_errors(bio_err); goto end; } - s_cert = load_cert(bio_err, s_server_config.cert_file, - s_server_config.cert_format, + s_cert = load_cert(bio_err, cfg.cert_file, + cfg.cert_format, NULL, "server certificate file"); if (!s_cert) { ERR_print_errors(bio_err); goto end; } - if (s_server_config.tlsextcbp.servername) { - s_key2 = load_key(bio_err, s_server_config.key_file2, - s_server_config.key_format, 0, pass, + if (cfg.tlsextcbp.servername) { + s_key2 = load_key(bio_err, cfg.key_file2, + cfg.key_format, 0, pass, "second server certificate private key file"); if (!s_key2) { ERR_print_errors(bio_err); goto end; } - s_cert2 = load_cert(bio_err, s_server_config.cert_file2, - s_server_config.cert_format, + s_cert2 = load_cert(bio_err, cfg.cert_file2, + cfg.cert_format, NULL, "second server certificate file"); if (!s_cert2) { @@ -1163,29 +1161,29 @@ s_server_main(int argc, char *argv[]) } } alpn_ctx.data = NULL; - if (s_server_config.alpn_in) { + if (cfg.alpn_in) { unsigned short len; alpn_ctx.data = next_protos_parse(&len, - s_server_config.alpn_in); + cfg.alpn_in); if (alpn_ctx.data == NULL) goto end; alpn_ctx.len = len; } - if (s_server_config.dcert_file) { + if (cfg.dcert_file) { - if (s_server_config.dkey_file == NULL) - s_server_config.dkey_file = s_server_config.dcert_file; + if (cfg.dkey_file == NULL) + cfg.dkey_file = cfg.dcert_file; - s_dkey = load_key(bio_err, s_server_config.dkey_file, - s_server_config.dkey_format, + s_dkey = load_key(bio_err, cfg.dkey_file, + cfg.dkey_format, 0, dpass, "second certificate private key file"); if (!s_dkey) { ERR_print_errors(bio_err); goto end; } - s_dcert = load_cert(bio_err, s_server_config.dcert_file, - s_server_config.dcert_format, + s_dcert = load_cert(bio_err, cfg.dcert_file, + cfg.dcert_format, NULL, "second server certificate file"); if (!s_dcert) { @@ -1194,23 +1192,23 @@ s_server_main(int argc, char *argv[]) } } if (bio_s_out == NULL) { - if (s_server_config.quiet && !s_server_config.debug && - !s_server_config.msg) { + if (cfg.quiet && !cfg.debug && + !cfg.msg) { bio_s_out = BIO_new(BIO_s_null()); } else { if (bio_s_out == NULL) bio_s_out = BIO_new_fp(stdout, BIO_NOCLOSE); } } - if (s_server_config.nocert) { - s_server_config.cert_file = NULL; - s_server_config.key_file = NULL; - s_server_config.dcert_file = NULL; - s_server_config.dkey_file = NULL; - s_server_config.cert_file2 = NULL; - s_server_config.key_file2 = NULL; + if (cfg.nocert) { + cfg.cert_file = NULL; + cfg.key_file = NULL; + cfg.dcert_file = NULL; + cfg.dkey_file = NULL; + cfg.cert_file2 = NULL; + cfg.key_file2 = NULL; } - ctx = SSL_CTX_new(s_server_config.meth); + ctx = SSL_CTX_new(cfg.meth); if (ctx == NULL) { ERR_print_errors(bio_err); goto end; @@ -1218,16 +1216,16 @@ s_server_main(int argc, char *argv[]) SSL_CTX_clear_mode(ctx, SSL_MODE_AUTO_RETRY); - if (!SSL_CTX_set_min_proto_version(ctx, s_server_config.min_version)) + if (!SSL_CTX_set_min_proto_version(ctx, cfg.min_version)) goto end; - if (!SSL_CTX_set_max_proto_version(ctx, s_server_config.max_version)) + if (!SSL_CTX_set_max_proto_version(ctx, cfg.max_version)) goto end; - if (s_server_config.session_id_prefix) { - if (strlen(s_server_config.session_id_prefix) >= 32) + if (cfg.session_id_prefix) { + if (strlen(cfg.session_id_prefix) >= 32) BIO_printf(bio_err, "warning: id_prefix is too long, only one new session will be possible\n"); - else if (strlen(s_server_config.session_id_prefix) >= 16) + else if (strlen(cfg.session_id_prefix) >= 16) BIO_printf(bio_err, "warning: id_prefix is too long if you use SSLv2\n"); if (!SSL_CTX_set_generate_session_id(ctx, generate_session_id)) { @@ -1236,58 +1234,58 @@ s_server_main(int argc, char *argv[]) goto end; } BIO_printf(bio_err, "id_prefix '%s' set.\n", - s_server_config.session_id_prefix); + cfg.session_id_prefix); } SSL_CTX_set_quiet_shutdown(ctx, 1); - if (s_server_config.bugs) + if (cfg.bugs) SSL_CTX_set_options(ctx, SSL_OP_ALL); - SSL_CTX_set_options(ctx, s_server_config.off); + SSL_CTX_set_options(ctx, cfg.off); - if (s_server_config.state) + if (cfg.state) SSL_CTX_set_info_callback(ctx, apps_ssl_info_callback); - if (s_server_config.no_cache) + if (cfg.no_cache) SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF); else SSL_CTX_sess_set_cache_size(ctx, 128); #ifndef OPENSSL_NO_SRTP - if (s_server_config.srtp_profiles != NULL) - SSL_CTX_set_tlsext_use_srtp(ctx, s_server_config.srtp_profiles); + if (cfg.srtp_profiles != NULL) + SSL_CTX_set_tlsext_use_srtp(ctx, cfg.srtp_profiles); #endif - if ((!SSL_CTX_load_verify_locations(ctx, s_server_config.CAfile, - s_server_config.CApath)) || + if ((!SSL_CTX_load_verify_locations(ctx, cfg.CAfile, + cfg.CApath)) || (!SSL_CTX_set_default_verify_paths(ctx))) { /* BIO_printf(bio_err,"X509_load_verify_locations\n"); */ ERR_print_errors(bio_err); /* goto end; */ } - if (s_server_config.vpm) - SSL_CTX_set1_param(ctx, s_server_config.vpm); + if (cfg.vpm) + SSL_CTX_set1_param(ctx, cfg.vpm); if (s_cert2) { - ctx2 = SSL_CTX_new(s_server_config.meth); + ctx2 = SSL_CTX_new(cfg.meth); if (ctx2 == NULL) { ERR_print_errors(bio_err); goto end; } if (!SSL_CTX_set_min_proto_version(ctx2, - s_server_config.min_version)) + cfg.min_version)) goto end; if (!SSL_CTX_set_max_proto_version(ctx2, - s_server_config.max_version)) + cfg.max_version)) goto end; SSL_CTX_clear_mode(ctx2, SSL_MODE_AUTO_RETRY); } if (ctx2) { BIO_printf(bio_s_out, "Setting secondary ctx parameters\n"); - if (s_server_config.session_id_prefix) { - if (strlen(s_server_config.session_id_prefix) >= 32) + if (cfg.session_id_prefix) { + if (strlen(cfg.session_id_prefix) >= 32) BIO_printf(bio_err, "warning: id_prefix is too long, only one new session will be possible\n"); - else if (strlen(s_server_config.session_id_prefix) >= 16) + else if (strlen(cfg.session_id_prefix) >= 16) BIO_printf(bio_err, "warning: id_prefix is too long if you use SSLv2\n"); if (!SSL_CTX_set_generate_session_id(ctx2, @@ -1298,48 +1296,48 @@ s_server_main(int argc, char *argv[]) goto end; } BIO_printf(bio_err, "id_prefix '%s' set.\n", - s_server_config.session_id_prefix); + cfg.session_id_prefix); } SSL_CTX_set_quiet_shutdown(ctx2, 1); - if (s_server_config.bugs) + if (cfg.bugs) SSL_CTX_set_options(ctx2, SSL_OP_ALL); - SSL_CTX_set_options(ctx2, s_server_config.off); + SSL_CTX_set_options(ctx2, cfg.off); - if (s_server_config.state) + if (cfg.state) SSL_CTX_set_info_callback(ctx2, apps_ssl_info_callback); - if (s_server_config.no_cache) + if (cfg.no_cache) SSL_CTX_set_session_cache_mode(ctx2, SSL_SESS_CACHE_OFF); else SSL_CTX_sess_set_cache_size(ctx2, 128); if ((!SSL_CTX_load_verify_locations(ctx2, - s_server_config.CAfile, s_server_config.CApath)) || + cfg.CAfile, cfg.CApath)) || (!SSL_CTX_set_default_verify_paths(ctx2))) { ERR_print_errors(bio_err); } - if (s_server_config.vpm) - SSL_CTX_set1_param(ctx2, s_server_config.vpm); + if (cfg.vpm) + SSL_CTX_set1_param(ctx2, cfg.vpm); } if (alpn_ctx.data) SSL_CTX_set_alpn_select_cb(ctx, alpn_cb, &alpn_ctx); - if (s_server_config.groups_in != NULL) { - if (SSL_CTX_set1_groups_list(ctx, s_server_config.groups_in) != 1) { + if (cfg.groups_in != NULL) { + if (SSL_CTX_set1_groups_list(ctx, cfg.groups_in) != 1) { BIO_printf(bio_err, "Failed to set groups '%s'\n", - s_server_config.groups_in); + cfg.groups_in); goto end; } } #ifndef OPENSSL_NO_DH - if (!s_server_config.no_dhe) { + if (!cfg.no_dhe) { DH *dh = NULL; - if (s_server_config.dhfile) - dh = load_dh_param(s_server_config.dhfile); - else if (s_server_config.cert_file) - dh = load_dh_param(s_server_config.cert_file); + if (cfg.dhfile) + dh = load_dh_param(cfg.dhfile); + else if (cfg.cert_file) + dh = load_dh_param(cfg.cert_file); if (dh != NULL) BIO_printf(bio_s_out, "Setting temp DH parameters\n"); @@ -1358,12 +1356,12 @@ s_server_main(int argc, char *argv[]) } if (ctx2) { - if (!s_server_config.dhfile) { + if (!cfg.dhfile) { DH *dh2 = NULL; - if (s_server_config.cert_file2 != NULL) + if (cfg.cert_file2 != NULL) dh2 = load_dh_param( - s_server_config.cert_file2); + cfg.cert_file2); if (dh2 != NULL) { BIO_printf(bio_s_out, "Setting temp DH parameters\n"); @@ -1387,18 +1385,18 @@ s_server_main(int argc, char *argv[]) } #endif - if (!s_server_config.no_ecdhe && s_server_config.named_curve != NULL) { + if (!cfg.no_ecdhe && cfg.named_curve != NULL) { EC_KEY *ecdh = NULL; int nid; - if ((nid = OBJ_sn2nid(s_server_config.named_curve)) == 0) { + if ((nid = OBJ_sn2nid(cfg.named_curve)) == 0) { BIO_printf(bio_err, "unknown curve name (%s)\n", - s_server_config.named_curve); + cfg.named_curve); goto end; } if ((ecdh = EC_KEY_new_by_curve_name(nid)) == NULL) { BIO_printf(bio_err, "unable to create curve (%s)\n", - s_server_config.named_curve); + cfg.named_curve); goto end; } BIO_printf(bio_s_out, "Setting temp ECDH parameters\n"); @@ -1419,20 +1417,20 @@ s_server_main(int argc, char *argv[]) goto end; } - if (s_server_config.cipher != NULL) { - if (!SSL_CTX_set_cipher_list(ctx, s_server_config.cipher)) { + if (cfg.cipher != NULL) { + if (!SSL_CTX_set_cipher_list(ctx, cfg.cipher)) { BIO_printf(bio_err, "error setting cipher list\n"); ERR_print_errors(bio_err); goto end; } if (ctx2 && !SSL_CTX_set_cipher_list(ctx2, - s_server_config.cipher)) { + cfg.cipher)) { BIO_printf(bio_err, "error setting cipher list\n"); ERR_print_errors(bio_err); goto end; } } - SSL_CTX_set_verify(ctx, s_server_config.server_verify, verify_callback); + SSL_CTX_set_verify(ctx, cfg.server_verify, verify_callback); SSL_CTX_set_session_id_context(ctx, (void *) &s_server_session_id_context, sizeof s_server_session_id_context); @@ -1442,38 +1440,38 @@ s_server_main(int argc, char *argv[]) SSL_CTX_set_cookie_verify_cb(ctx, verify_cookie_callback); if (ctx2) { - SSL_CTX_set_verify(ctx2, s_server_config.server_verify, + SSL_CTX_set_verify(ctx2, cfg.server_verify, verify_callback); SSL_CTX_set_session_id_context(ctx2, (void *) &s_server_session_id_context, sizeof s_server_session_id_context); - s_server_config.tlsextcbp.biodebug = bio_s_out; + cfg.tlsextcbp.biodebug = bio_s_out; SSL_CTX_set_tlsext_servername_callback(ctx2, ssl_servername_cb); SSL_CTX_set_tlsext_servername_arg(ctx2, - &s_server_config.tlsextcbp); + &cfg.tlsextcbp); SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb); SSL_CTX_set_tlsext_servername_arg(ctx, - &s_server_config.tlsextcbp); + &cfg.tlsextcbp); } - if (s_server_config.CAfile != NULL) { + if (cfg.CAfile != NULL) { SSL_CTX_set_client_CA_list(ctx, - SSL_load_client_CA_file(s_server_config.CAfile)); + SSL_load_client_CA_file(cfg.CAfile)); if (ctx2) SSL_CTX_set_client_CA_list(ctx2, - SSL_load_client_CA_file(s_server_config.CAfile)); + SSL_load_client_CA_file(cfg.CAfile)); } BIO_printf(bio_s_out, "ACCEPT\n"); (void) BIO_flush(bio_s_out); - if (s_server_config.www) - do_server(s_server_config.port, s_server_config.socket_type, - &accept_socket, www_body, s_server_config.context, - s_server_config.naccept); + if (cfg.www) + do_server(cfg.port, cfg.socket_type, + &accept_socket, www_body, cfg.context, + cfg.naccept); else - do_server(s_server_config.port, s_server_config.socket_type, - &accept_socket, sv_body, s_server_config.context, - s_server_config.naccept); + do_server(cfg.port, cfg.socket_type, + &accept_socket, sv_body, cfg.context, + cfg.naccept); print_stats(bio_s_out, ctx); ret = 0; end: @@ -1484,10 +1482,10 @@ s_server_main(int argc, char *argv[]) EVP_PKEY_free(s_dkey); free(pass); free(dpass); - X509_VERIFY_PARAM_free(s_server_config.vpm); - free(s_server_config.tlscstatp.host); - free(s_server_config.tlscstatp.port); - free(s_server_config.tlscstatp.path); + X509_VERIFY_PARAM_free(cfg.vpm); + free(cfg.tlscstatp.host); + free(cfg.tlscstatp.port); + free(cfg.tlscstatp.path); SSL_CTX_free(ctx2); X509_free(s_cert2); EVP_PKEY_free(s_key2); @@ -1545,8 +1543,8 @@ sv_body(int s, unsigned char *context) BIO_printf(bio_err, "out of memory\n"); goto err; } - if (s_server_config.nbio) { - if (!s_server_config.quiet) + if (cfg.nbio) { + if (!cfg.quiet) BIO_printf(bio_err, "turning on non blocking io\n"); if (!BIO_socket_nbio(s, 1)) ERR_print_errors(bio_err); @@ -1554,15 +1552,15 @@ sv_body(int s, unsigned char *context) if (con == NULL) { con = SSL_new(ctx); - if (s_server_config.tlsextdebug) { + if (cfg.tlsextdebug) { SSL_set_tlsext_debug_callback(con, tlsext_cb); SSL_set_tlsext_debug_arg(con, bio_s_out); } - if (s_server_config.tlsextstatus) { + if (cfg.tlsextstatus) { SSL_CTX_set_tlsext_status_cb(ctx, cert_status_cb); - s_server_config.tlscstatp.err = bio_err; + cfg.tlscstatp.err = bio_err; SSL_CTX_set_tlsext_status_arg(ctx, - &s_server_config.tlscstatp); + &cfg.tlscstatp); } if (context) SSL_set_session_id_context(con, context, @@ -1573,7 +1571,7 @@ sv_body(int s, unsigned char *context) if (SSL_is_dtls(con)) { sbio = BIO_new_dgram(s, BIO_NOCLOSE); - if (s_server_config.enable_timeouts) { + if (cfg.enable_timeouts) { timeout.tv_sec = 0; timeout.tv_usec = DGRAM_RCV_TIMEOUT; BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_RECV_TIMEOUT, 0, @@ -1584,9 +1582,9 @@ sv_body(int s, unsigned char *context) BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout); } - if (s_server_config.socket_mtu > 28) { + if (cfg.socket_mtu > 28) { SSL_set_options(con, SSL_OP_NO_QUERY_MTU); - SSL_set_mtu(con, s_server_config.socket_mtu - 28); + SSL_set_mtu(con, cfg.socket_mtu - 28); } else /* want to do MTU discovery */ BIO_ctrl(sbio, BIO_CTRL_DGRAM_MTU_DISCOVER, 0, NULL); @@ -1596,7 +1594,7 @@ sv_body(int s, unsigned char *context) } else sbio = BIO_new_socket(s, BIO_NOCLOSE); - if (s_server_config.nbio_test) { + if (cfg.nbio_test) { BIO *test; test = BIO_new(BIO_f_nbio_test()); @@ -1607,16 +1605,16 @@ sv_body(int s, unsigned char *context) SSL_set_accept_state(con); /* SSL_set_fd(con,s); */ - if (s_server_config.debug) { + if (cfg.debug) { SSL_set_debug(con, 1); BIO_set_callback(SSL_get_rbio(con), bio_dump_callback); BIO_set_callback_arg(SSL_get_rbio(con), (char *) bio_s_out); } - if (s_server_config.msg) { + if (cfg.msg) { SSL_set_msg_callback(con, msg_cb); SSL_set_msg_callback_arg(con, bio_s_out); } - if (s_server_config.tlsextdebug) { + if (cfg.tlsextdebug) { SSL_set_tlsext_debug_callback(con, tlsext_cb); SSL_set_tlsext_debug_arg(con, bio_s_out); } @@ -1662,7 +1660,7 @@ sv_body(int s, unsigned char *context) } } if (read_from_terminal) { - if (s_server_config.crlf) { + if (cfg.crlf) { int j, lf_num; i = read(fileno(stdin), buf, bufsize / 2); @@ -1682,7 +1680,7 @@ sv_body(int s, unsigned char *context) assert(lf_num == 0); } else i = read(fileno(stdin), buf, bufsize); - if (!s_server_config.quiet) { + if (!cfg.quiet) { if ((i <= 0) || (buf[0] == 'Q')) { BIO_printf(bio_s_out, "DONE\n"); shutdown(s, SHUT_RD); @@ -1912,23 +1910,23 @@ init_ssl_connection(SSL *con) BIO_printf(bio_s_out, "Reused session-id\n"); BIO_printf(bio_s_out, "Secure Renegotiation IS%s supported\n", SSL_get_secure_renegotiation_support(con) ? "" : " NOT"); - if (s_server_config.keymatexportlabel != NULL) { + if (cfg.keymatexportlabel != NULL) { BIO_printf(bio_s_out, "Keying material exporter:\n"); BIO_printf(bio_s_out, " Label: '%s'\n", - s_server_config.keymatexportlabel); + cfg.keymatexportlabel); BIO_printf(bio_s_out, " Length: %i bytes\n", - s_server_config.keymatexportlen); - exportedkeymat = malloc(s_server_config.keymatexportlen); + cfg.keymatexportlen); + exportedkeymat = malloc(cfg.keymatexportlen); if (exportedkeymat != NULL) { if (!SSL_export_keying_material(con, exportedkeymat, - s_server_config.keymatexportlen, - s_server_config.keymatexportlabel, - strlen(s_server_config.keymatexportlabel), + cfg.keymatexportlen, + cfg.keymatexportlabel, + strlen(cfg.keymatexportlabel), NULL, 0, 0)) { BIO_printf(bio_s_out, " Error\n"); } else { BIO_printf(bio_s_out, " Keying material: "); - for (i = 0; i < s_server_config.keymatexportlen; i++) + for (i = 0; i < cfg.keymatexportlen; i++) BIO_printf(bio_s_out, "%02X", exportedkeymat[i]); BIO_printf(bio_s_out, "\n"); @@ -1973,8 +1971,8 @@ www_body(int s, unsigned char *context) if ((io == NULL) || (ssl_bio == NULL)) goto err; - if (s_server_config.nbio) { - if (!s_server_config.quiet) + if (cfg.nbio) { + if (!cfg.quiet) BIO_printf(bio_err, "turning on non blocking io\n"); if (!BIO_socket_nbio(s, 1)) ERR_print_errors(bio_err); @@ -1986,7 +1984,7 @@ www_body(int s, unsigned char *context) if ((con = SSL_new(ctx)) == NULL) goto err; - if (s_server_config.tlsextdebug) { + if (cfg.tlsextdebug) { SSL_set_tlsext_debug_callback(con, tlsext_cb); SSL_set_tlsext_debug_arg(con, bio_s_out); } @@ -1995,7 +1993,7 @@ www_body(int s, unsigned char *context) strlen((char *) context)); sbio = BIO_new_socket(s, BIO_NOCLOSE); - if (s_server_config.nbio_test) { + if (cfg.nbio_test) { BIO *test; test = BIO_new(BIO_f_nbio_test()); @@ -2008,12 +2006,12 @@ www_body(int s, unsigned char *context) BIO_set_ssl(ssl_bio, con, BIO_CLOSE); BIO_push(io, ssl_bio); - if (s_server_config.debug) { + if (cfg.debug) { SSL_set_debug(con, 1); BIO_set_callback(SSL_get_rbio(con), bio_dump_callback); BIO_set_callback_arg(SSL_get_rbio(con), (char *) bio_s_out); } - if (s_server_config.msg) { + if (cfg.msg) { SSL_set_msg_callback(con, msg_cb); SSL_set_msg_callback_arg(con, bio_s_out); } @@ -2021,11 +2019,11 @@ www_body(int s, unsigned char *context) i = BIO_gets(io, buf, bufsize - 1); if (i < 0) { /* error */ if (!BIO_should_retry(io)) { - if (!s_server_config.quiet) + if (!cfg.quiet) ERR_print_errors(bio_err); goto err; } else { - if (s_server_config.debug) { + if (cfg.debug) { BIO_printf(bio_s_out, "read R BLOCK\n"); sleep(1); } @@ -2036,9 +2034,9 @@ www_body(int s, unsigned char *context) goto end; } /* else we have data */ - if (((s_server_config.www == 1) && + if (((cfg.www == 1) && (strncmp("GET ", buf, 4) == 0)) || - ((s_server_config.www == 2) && + ((cfg.www == 2) && (strncmp("GET /stats ", buf, 11) == 0))) { char *p; X509 *peer; @@ -2119,8 +2117,8 @@ www_body(int s, unsigned char *context) "no client certificate available\n"); BIO_puts(io, "\r\n\r\n"); break; - } else if ((s_server_config.www == 2 || - s_server_config.www == 3) && + } else if ((cfg.www == 2 || + cfg.www == 3) && (strncmp("GET /", buf, 5) == 0)) { BIO *file; char *p, *e; @@ -2185,10 +2183,10 @@ www_body(int s, unsigned char *context) ERR_print_errors(io); break; } - if (!s_server_config.quiet) + if (!cfg.quiet) BIO_printf(bio_err, "FILE:%s\n", p); - if (s_server_config.www == 2) { + if (cfg.www == 2) { i = strlen(p); if (((i > 5) && (strcmp(&(p[i - 5]), ".html") == 0)) || ((i > 4) && (strcmp(&(p[i - 4]), ".php") == 0)) || @@ -2278,9 +2276,9 @@ generate_session_id(const SSL *ssl, unsigned char *id, unsigned int *id_len) * 1 session ID (ie. the prefix!) so all future session * negotiations will fail due to conflicts. */ - memcpy(id, s_server_config.session_id_prefix, - (strlen(s_server_config.session_id_prefix) < *id_len) ? - strlen(s_server_config.session_id_prefix) : *id_len); + memcpy(id, cfg.session_id_prefix, + (strlen(cfg.session_id_prefix) < *id_len) ? + strlen(cfg.session_id_prefix) : *id_len); } while (SSL_has_matching_session_id(ssl, id, *id_len) && (++count < MAX_SESSION_ID_ATTEMPTS)); @@ -2451,7 +2449,7 @@ alpn_cb(SSL *s, const unsigned char **out, unsigned char *outlen, { tlsextalpnctx *alpn_ctx = arg; - if (!s_server_config.quiet) { + if (!cfg.quiet) { /* We can assume that in is syntactically valid. */ unsigned i; @@ -2470,7 +2468,7 @@ alpn_cb(SSL *s, const unsigned char **out, unsigned char *outlen, alpn_ctx->len, in, inlen) != OPENSSL_NPN_NEGOTIATED) return (SSL_TLSEXT_ERR_NOACK); - if (!s_server_config.quiet) { + if (!cfg.quiet) { BIO_printf(bio_s_out, "ALPN protocols selected: "); BIO_write(bio_s_out, *out, *outlen); BIO_write(bio_s_out, "\n", 1); diff --git a/apps/openssl/s_time.c b/apps/openssl/s_time.c index 92fdb59a..7eed6d48 100644 --- a/apps/openssl/s_time.c +++ b/apps/openssl/s_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_time.c,v 1.35 2022/08/31 12:29:08 tb Exp $ */ +/* $OpenBSD: s_time.c,v 1.38 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -98,7 +98,7 @@ static SSL_CTX *tm_ctx = NULL; static const SSL_METHOD *s_time_meth = NULL; static long bytes_read = 0; -struct { +static struct { int bugs; char *CAfile; char *CApath; @@ -113,42 +113,42 @@ struct { int verify; int verify_depth; char *www_path; -} s_time_config; +} cfg; static const struct option s_time_options[] = { { .name = "bugs", .desc = "Enable workarounds for known SSL/TLS bugs", .type = OPTION_FLAG, - .opt.flag = &s_time_config.bugs, + .opt.flag = &cfg.bugs, }, { .name = "CAfile", .argname = "file", .desc = "File containing trusted certificates in PEM format", .type = OPTION_ARG, - .opt.arg = &s_time_config.CAfile, + .opt.arg = &cfg.CAfile, }, { .name = "CApath", .argname = "path", .desc = "Directory containing trusted certificates", .type = OPTION_ARG, - .opt.arg = &s_time_config.CApath, + .opt.arg = &cfg.CApath, }, { .name = "cert", .argname = "file", .desc = "Client certificate to use, if one is requested", .type = OPTION_ARG, - .opt.arg = &s_time_config.certfile, + .opt.arg = &cfg.certfile, }, { .name = "cipher", .argname = "list", .desc = "List of cipher suites to send to the server", .type = OPTION_ARG, - .opt.arg = &s_time_config.cipher, + .opt.arg = &cfg.cipher, }, { .name = "connect", @@ -156,39 +156,39 @@ static const struct option s_time_options[] = { .desc = "Host and port to connect to (default " SSL_CONNECT_NAME ")", .type = OPTION_ARG, - .opt.arg = &s_time_config.host, + .opt.arg = &cfg.host, }, { .name = "key", .argname = "file", .desc = "Client private key to use, if one is required", .type = OPTION_ARG, - .opt.arg = &s_time_config.keyfile, + .opt.arg = &cfg.keyfile, }, { .name = "nbio", .desc = "Use non-blocking I/O", .type = OPTION_FLAG, - .opt.flag = &s_time_config.nbio, + .opt.flag = &cfg.nbio, }, { .name = "new", .desc = "Use a new session ID for each connection", .type = OPTION_VALUE, - .opt.value = &s_time_config.perform, + .opt.value = &cfg.perform, .value = 1, }, { .name = "no_shutdown", .desc = "Shut down the connection without notifying the server", .type = OPTION_FLAG, - .opt.flag = &s_time_config.no_shutdown, + .opt.flag = &cfg.no_shutdown, }, { .name = "reuse", .desc = "Reuse the same session ID for each connection", .type = OPTION_VALUE, - .opt.value = &s_time_config.perform, + .opt.value = &cfg.perform, .value = 2, }, { @@ -196,21 +196,21 @@ static const struct option s_time_options[] = { .argname = "seconds", .desc = "Duration to perform timing tests for (default 30)", .type = OPTION_ARG_TIME, - .opt.tvalue = &s_time_config.maxtime, + .opt.tvalue = &cfg.maxtime, }, { .name = "verify", .argname = "depth", .desc = "Enable peer certificate verification with given depth", .type = OPTION_ARG_INT, - .opt.value = &s_time_config.verify_depth, + .opt.value = &cfg.verify_depth, }, { .name = "www", .argname = "page", .desc = "Page to GET from the server (default none)", .type = OPTION_ARG, - .opt.arg = &s_time_config.www_path, + .opt.arg = &cfg.www_path, }, { NULL }, }; @@ -236,38 +236,36 @@ s_time_main(int argc, char **argv) { int ret = 1; - if (single_execution) { - if (pledge("stdio rpath inet dns", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio rpath inet dns", NULL) == -1) { + perror("pledge"); + exit(1); } s_time_meth = TLS_client_method(); verify_depth = 0; - memset(&s_time_config, 0, sizeof(s_time_config)); + memset(&cfg, 0, sizeof(cfg)); - s_time_config.host = SSL_CONNECT_NAME; - s_time_config.maxtime = SECONDS; - s_time_config.perform = 3; - s_time_config.verify = SSL_VERIFY_NONE; - s_time_config.verify_depth = -1; + cfg.host = SSL_CONNECT_NAME; + cfg.maxtime = SECONDS; + cfg.perform = 3; + cfg.verify = SSL_VERIFY_NONE; + cfg.verify_depth = -1; if (options_parse(argc, argv, s_time_options, NULL, NULL) != 0) { s_time_usage(); goto end; } - if (s_time_config.verify_depth >= 0) { - s_time_config.verify = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE; - verify_depth = s_time_config.verify_depth; + if (cfg.verify_depth >= 0) { + cfg.verify = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE; + verify_depth = cfg.verify_depth; BIO_printf(bio_err, "verify depth is %d\n", verify_depth); } - if (s_time_config.www_path != NULL && - strlen(s_time_config.www_path) > MYBUFSIZ - 100) { + if (cfg.www_path != NULL && + strlen(cfg.www_path) > MYBUFSIZ - 100) { BIO_printf(bio_err, "-www option too long\n"); goto end; } @@ -277,25 +275,25 @@ s_time_main(int argc, char **argv) SSL_CTX_set_quiet_shutdown(tm_ctx, 1); - if (s_time_config.bugs) + if (cfg.bugs) SSL_CTX_set_options(tm_ctx, SSL_OP_ALL); - if (s_time_config.cipher != NULL) { - if (!SSL_CTX_set_cipher_list(tm_ctx, s_time_config.cipher)) { + if (cfg.cipher != NULL) { + if (!SSL_CTX_set_cipher_list(tm_ctx, cfg.cipher)) { BIO_printf(bio_err, "error setting cipher list\n"); ERR_print_errors(bio_err); goto end; } } - SSL_CTX_set_verify(tm_ctx, s_time_config.verify, NULL); + SSL_CTX_set_verify(tm_ctx, cfg.verify, NULL); - if (!set_cert_stuff(tm_ctx, s_time_config.certfile, - s_time_config.keyfile)) + if (!set_cert_stuff(tm_ctx, cfg.certfile, + cfg.keyfile)) goto end; - if ((!SSL_CTX_load_verify_locations(tm_ctx, s_time_config.CAfile, - s_time_config.CApath)) || + if ((!SSL_CTX_load_verify_locations(tm_ctx, cfg.CAfile, + cfg.CApath)) || (!SSL_CTX_set_default_verify_paths(tm_ctx))) { /* * BIO_printf(bio_err,"error setting default verify @@ -306,9 +304,9 @@ s_time_main(int argc, char **argv) } /* Loop and time how long it takes to make connections */ - if (s_time_config.perform & 1) { + if (cfg.perform & 1) { printf("Collecting connection statistics for %lld seconds\n", - (long long)s_time_config.maxtime); + (long long)cfg.maxtime); if (benchmark(0)) goto end; } @@ -316,7 +314,7 @@ s_time_main(int argc, char **argv) * Now loop and time connections using the same session id over and * over */ - if (s_time_config.perform & 2) { + if (cfg.perform & 2) { printf("\n\nNow timing with session id reuse.\n"); if (benchmark(1)) goto end; @@ -350,7 +348,7 @@ run_test(SSL *scon) if ((conn = BIO_new(BIO_s_connect())) == NULL) return 0; - BIO_set_conn_hostname(conn, s_time_config.host); + BIO_set_conn_hostname(conn, cfg.host); SSL_set_connect_state(scon); SSL_set_bio(scon, conn, conn); for (;;) { @@ -374,9 +372,9 @@ run_test(SSL *scon) ERR_print_errors(bio_err); return 0; } - if (s_time_config.www_path != NULL) { + if (cfg.www_path != NULL) { retval = snprintf(buf, sizeof buf, - "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); + "GET %s HTTP/1.0\r\n\r\n", cfg.www_path); if (retval < 0 || retval >= sizeof buf) { fprintf(stderr, "URL too long\n"); return 0; @@ -386,7 +384,7 @@ run_test(SSL *scon) while ((i = SSL_read(scon, buf, sizeof(buf))) > 0) bytes_read += i; } - if (s_time_config.no_shutdown) + if (cfg.no_shutdown) SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN); else @@ -438,7 +436,7 @@ benchmark(int reuse_session) app_timer_user(TM_RESET); for (;;) { elapsed = app_timer_real(TM_GET); - if (elapsed > s_time_config.maxtime) + if (elapsed > cfg.maxtime) break; if (scon == NULL) { if ((scon = SSL_new(tm_ctx)) == NULL) diff --git a/apps/openssl/sess_id.c b/apps/openssl/sess_id.c index d8a2bf27..c46da542 100644 --- a/apps/openssl/sess_id.c +++ b/apps/openssl/sess_id.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sess_id.c,v 1.10 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: sess_id.c,v 1.12 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -78,62 +78,62 @@ static struct { char *outfile; int outformat; int text; -} sess_id_config; +} cfg; static const struct option sess_id_options[] = { { .name = "cert", .desc = "Output certificate if present in session", .type = OPTION_FLAG, - .opt.flag = &sess_id_config.cert, + .opt.flag = &cfg.cert, }, { .name = "context", .argname = "id", .desc = "Set the session ID context for output", .type = OPTION_ARG, - .opt.arg = &sess_id_config.context, + .opt.arg = &cfg.context, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &sess_id_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "format", .desc = "Input format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &sess_id_config.informat, + .opt.value = &cfg.informat, }, { .name = "noout", .desc = "Do not output the encoded session info", .type = OPTION_FLAG, - .opt.flag = &sess_id_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &sess_id_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "format", .desc = "Output format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &sess_id_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "text", .desc = "Print various public or private key components in" " plain text", .type = OPTION_FLAG, - .opt.flag = &sess_id_config.text, + .opt.flag = &cfg.text, }, { NULL } }; @@ -158,69 +158,67 @@ sess_id_main(int argc, char **argv) int ret = 1, i; BIO *out = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&sess_id_config, 0, sizeof(sess_id_config)); + memset(&cfg, 0, sizeof(cfg)); - sess_id_config.informat = FORMAT_PEM; - sess_id_config.outformat = FORMAT_PEM; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; if (options_parse(argc, argv, sess_id_options, NULL, NULL) != 0) { sess_id_usage(); return (1); } - x = load_sess_id(sess_id_config.infile, sess_id_config.informat); + x = load_sess_id(cfg.infile, cfg.informat); if (x == NULL) { goto end; } peer = SSL_SESSION_get0_peer(x); - if (sess_id_config.context) { - size_t ctx_len = strlen(sess_id_config.context); + if (cfg.context) { + size_t ctx_len = strlen(cfg.context); if (ctx_len > SSL_MAX_SID_CTX_LENGTH) { BIO_printf(bio_err, "Context too long\n"); goto end; } SSL_SESSION_set1_id_context(x, - (unsigned char *)sess_id_config.context, ctx_len); + (unsigned char *)cfg.context, ctx_len); } - if (!sess_id_config.noout || sess_id_config.text) { + if (!cfg.noout || cfg.text) { out = BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto end; } - if (sess_id_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, sess_id_config.outfile) + if (BIO_write_filename(out, cfg.outfile) <= 0) { - perror(sess_id_config.outfile); + perror(cfg.outfile); goto end; } } } - if (sess_id_config.text) { + if (cfg.text) { SSL_SESSION_print(out, x); - if (sess_id_config.cert) { + if (cfg.cert) { if (peer == NULL) BIO_puts(out, "No certificate present\n"); else X509_print(out, peer); } } - if (!sess_id_config.noout && !sess_id_config.cert) { - if (sess_id_config.outformat == FORMAT_ASN1) + if (!cfg.noout && !cfg.cert) { + if (cfg.outformat == FORMAT_ASN1) i = i2d_SSL_SESSION_bio(out, x); - else if (sess_id_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_SSL_SESSION(out, x); else { BIO_printf(bio_err, @@ -231,11 +229,11 @@ sess_id_main(int argc, char **argv) BIO_printf(bio_err, "unable to write SSL_SESSION\n"); goto end; } - } else if (!sess_id_config.noout && (peer != NULL)) { + } else if (!cfg.noout && (peer != NULL)) { /* just print the certificate */ - if (sess_id_config.outformat == FORMAT_ASN1) + if (cfg.outformat == FORMAT_ASN1) i = (int) i2d_X509_bio(out, peer); - else if (sess_id_config.outformat == FORMAT_PEM) + else if (cfg.outformat == FORMAT_PEM) i = PEM_write_bio_X509(out, peer); else { BIO_printf(bio_err, diff --git a/apps/openssl/smime.c b/apps/openssl/smime.c index 2503177f..e54c8d0b 100644 --- a/apps/openssl/smime.c +++ b/apps/openssl/smime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smime.c,v 1.17 2022/01/16 07:12:28 inoguchi Exp $ */ +/* $OpenBSD: smime.c,v 1.19 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -107,7 +107,7 @@ static struct { char *subject; char *to; X509_VERIFY_PARAM *vpm; -} smime_config; +} cfg; static const EVP_CIPHER * get_cipher_by_name(char *name) @@ -156,8 +156,8 @@ smime_opt_cipher(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((smime_config.cipher = get_cipher_by_name(name)) == NULL) - if ((smime_config.cipher = EVP_get_cipherbyname(name)) == NULL) + if ((cfg.cipher = get_cipher_by_name(name)) == NULL) + if ((cfg.cipher = EVP_get_cipherbyname(name)) == NULL) return (1); *argsused = 1; @@ -167,41 +167,41 @@ smime_opt_cipher(int argc, char **argv, int *argsused) static int smime_opt_inkey(char *arg) { - if (smime_config.keyfile == NULL) { - smime_config.keyfile = arg; + if (cfg.keyfile == NULL) { + cfg.keyfile = arg; return (0); } - if (smime_config.signerfile == NULL) { + if (cfg.signerfile == NULL) { BIO_puts(bio_err, "Illegal -inkey without -signer\n"); return (1); } - if (smime_config.sksigners == NULL) { - if ((smime_config.sksigners = sk_OPENSSL_STRING_new_null()) == NULL) + if (cfg.sksigners == NULL) { + if ((cfg.sksigners = sk_OPENSSL_STRING_new_null()) == NULL) return (1); } - if (!sk_OPENSSL_STRING_push(smime_config.sksigners, - smime_config.signerfile)) + if (!sk_OPENSSL_STRING_push(cfg.sksigners, + cfg.signerfile)) return (1); - smime_config.signerfile = NULL; + cfg.signerfile = NULL; - if (smime_config.skkeys == NULL) { - if ((smime_config.skkeys = sk_OPENSSL_STRING_new_null()) == NULL) + if (cfg.skkeys == NULL) { + if ((cfg.skkeys = sk_OPENSSL_STRING_new_null()) == NULL) return (1); } - if (!sk_OPENSSL_STRING_push(smime_config.skkeys, smime_config.keyfile)) + if (!sk_OPENSSL_STRING_push(cfg.skkeys, cfg.keyfile)) return (1); - smime_config.keyfile = arg; + cfg.keyfile = arg; return (0); } static int smime_opt_md(char *arg) { - if ((smime_config.sign_md = EVP_get_digestbyname(arg)) == NULL) { + if ((cfg.sign_md = EVP_get_digestbyname(arg)) == NULL) { BIO_printf(bio_err, "Unknown digest %s\n", arg); return (1); } @@ -211,32 +211,32 @@ smime_opt_md(char *arg) static int smime_opt_signer(char *arg) { - if (smime_config.signerfile == NULL) { - smime_config.signerfile = arg; + if (cfg.signerfile == NULL) { + cfg.signerfile = arg; return (0); } - if (smime_config.sksigners == NULL) { - if ((smime_config.sksigners = sk_OPENSSL_STRING_new_null()) == NULL) + if (cfg.sksigners == NULL) { + if ((cfg.sksigners = sk_OPENSSL_STRING_new_null()) == NULL) return (1); } - if (!sk_OPENSSL_STRING_push(smime_config.sksigners, - smime_config.signerfile)) + if (!sk_OPENSSL_STRING_push(cfg.sksigners, + cfg.signerfile)) return (1); - if (smime_config.keyfile == NULL) - smime_config.keyfile = smime_config.signerfile; + if (cfg.keyfile == NULL) + cfg.keyfile = cfg.signerfile; - if (smime_config.skkeys == NULL) { - if ((smime_config.skkeys = sk_OPENSSL_STRING_new_null()) == NULL) + if (cfg.skkeys == NULL) { + if ((cfg.skkeys = sk_OPENSSL_STRING_new_null()) == NULL) return (1); } - if (!sk_OPENSSL_STRING_push(smime_config.skkeys, smime_config.keyfile)) + if (!sk_OPENSSL_STRING_push(cfg.skkeys, cfg.keyfile)) return (1); - smime_config.keyfile = NULL; + cfg.keyfile = NULL; - smime_config.signerfile = arg; + cfg.signerfile = arg; return (0); } @@ -246,7 +246,7 @@ smime_opt_verify_param(int argc, char **argv, int *argsused) int oargc = argc; int badarg = 0; - if (!args_verify(&argv, &argc, &badarg, bio_err, &smime_config.vpm)) + if (!args_verify(&argv, &argc, &badarg, bio_err, &cfg.vpm)) return (1); if (badarg) return (1); @@ -336,20 +336,20 @@ static const struct option smime_options[] = { .argname = "file", .desc = "Certificate Authority file", .type = OPTION_ARG, - .opt.arg = &smime_config.CAfile, + .opt.arg = &cfg.CAfile, }, { .name = "CApath", .argname = "path", .desc = "Certificate Authority path", .type = OPTION_ARG, - .opt.arg = &smime_config.CApath, + .opt.arg = &cfg.CApath, }, { .name = "binary", .desc = "Do not translate message to text", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_BINARY, }, { @@ -357,34 +357,34 @@ static const struct option smime_options[] = { .argname = "file", .desc = "Other certificates file", .type = OPTION_ARG, - .opt.arg = &smime_config.certfile, + .opt.arg = &cfg.certfile, }, { .name = "content", .argname = "file", .desc = "Supply or override content for detached signature", .type = OPTION_ARG, - .opt.arg = &smime_config.contfile, + .opt.arg = &cfg.contfile, }, { .name = "crlfeol", .desc = "Use CRLF as EOL termination instead of CR only", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_CRLFEOL, }, { .name = "decrypt", .desc = "Decrypt encrypted message", .type = OPTION_VALUE, - .opt.value = &smime_config.operation, + .opt.value = &cfg.operation, .value = SMIME_DECRYPT, }, { .name = "encrypt", .desc = "Encrypt message", .type = OPTION_VALUE, - .opt.value = &smime_config.operation, + .opt.value = &cfg.operation, .value = SMIME_ENCRYPT, }, { @@ -392,20 +392,20 @@ static const struct option smime_options[] = { .argname = "addr", .desc = "From address", .type = OPTION_ARG, - .opt.arg = &smime_config.from, + .opt.arg = &cfg.from, }, { .name = "in", .argname = "file", .desc = "Input file", .type = OPTION_ARG, - .opt.arg = &smime_config.infile, + .opt.arg = &cfg.infile, }, { .name = "indef", .desc = "Same as -stream", .type = OPTION_VALUE, - .opt.value = &smime_config.indef, + .opt.value = &cfg.indef, .value = 1, }, { @@ -413,7 +413,7 @@ static const struct option smime_options[] = { .argname = "fmt", .desc = "Input format (DER, PEM or SMIME (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &smime_config.informat, + .opt.value = &cfg.informat, }, { .name = "inkey", @@ -427,7 +427,7 @@ static const struct option smime_options[] = { .argname = "fmt", .desc = "Input key format (DER or PEM (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &smime_config.keyform, + .opt.value = &cfg.keyform, }, { .name = "md", @@ -440,70 +440,70 @@ static const struct option smime_options[] = { .name = "noattr", .desc = "Do not include any signed attributes", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_NOATTR, }, { .name = "nocerts", .desc = "Do not include signer's certificate when signing", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_NOCERTS, }, { .name = "nochain", .desc = "Do not chain verification of signer's certificates", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_NOCHAIN, }, { .name = "nodetach", .desc = "Use opaque signing", .type = OPTION_VALUE_AND, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = ~PKCS7_DETACHED, }, { .name = "noindef", .desc = "Disable streaming I/O", .type = OPTION_VALUE, - .opt.value = &smime_config.indef, + .opt.value = &cfg.indef, .value = 0, }, { .name = "nointern", .desc = "Do not search certificates in message for signer", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_NOINTERN, }, { .name = "nooldmime", .desc = "Output old S/MIME content type", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_NOOLDMIMETYPE, }, { .name = "nosigs", .desc = "Do not verify message signature", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_NOSIGS, }, { .name = "nosmimecap", .desc = "Omit the SMIMECapabilities attribute", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_NOSMIMECAP, }, { .name = "noverify", .desc = "Do not verify signer's certificate", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_NOVERIFY, }, { @@ -511,27 +511,27 @@ static const struct option smime_options[] = { .argname = "file", .desc = "Output file", .type = OPTION_ARG, - .opt.arg = &smime_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "fmt", .desc = "Output format (DER, PEM or SMIME (default))", .type = OPTION_ARG_FORMAT, - .opt.value = &smime_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "passin", .argname = "src", .desc = "Private key password source", .type = OPTION_ARG, - .opt.arg = &smime_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "pk7out", .desc = "Output PKCS#7 structure", .type = OPTION_VALUE, - .opt.value = &smime_config.operation, + .opt.value = &cfg.operation, .value = SMIME_PK7OUT, }, { @@ -539,20 +539,20 @@ static const struct option smime_options[] = { .argname = "file", .desc = "Recipient certificate file for decryption", .type = OPTION_ARG, - .opt.arg = &smime_config.recipfile, + .opt.arg = &cfg.recipfile, }, { .name = "resign", .desc = "Resign a signed message", .type = OPTION_VALUE, - .opt.value = &smime_config.operation, + .opt.value = &cfg.operation, .value = SMIME_RESIGN, }, { .name = "sign", .desc = "Sign message", .type = OPTION_VALUE, - .opt.value = &smime_config.operation, + .opt.value = &cfg.operation, .value = SMIME_SIGN, }, { @@ -566,7 +566,7 @@ static const struct option smime_options[] = { .name = "stream", .desc = "Enable streaming I/O", .type = OPTION_VALUE, - .opt.value = &smime_config.indef, + .opt.value = &cfg.indef, .value = 1, }, { @@ -574,13 +574,13 @@ static const struct option smime_options[] = { .argname = "s", .desc = "Subject", .type = OPTION_ARG, - .opt.arg = &smime_config.subject, + .opt.arg = &cfg.subject, }, { .name = "text", .desc = "Include or delete text MIME headers", .type = OPTION_VALUE_OR, - .opt.value = &smime_config.flags, + .opt.value = &cfg.flags, .value = PKCS7_TEXT, }, { @@ -588,13 +588,13 @@ static const struct option smime_options[] = { .argname = "addr", .desc = "To address", .type = OPTION_ARG, - .opt.arg = &smime_config.to, + .opt.arg = &cfg.to, }, { .name = "verify", .desc = "Verify signed message", .type = OPTION_VALUE, - .opt.value = &smime_config.operation, + .opt.value = &cfg.operation, .value = SMIME_VERIFY, }, { @@ -722,77 +722,75 @@ smime_main(int argc, char **argv) int badarg = 0; char *passin = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&smime_config, 0, sizeof(smime_config)); - smime_config.flags = PKCS7_DETACHED; - smime_config.informat = FORMAT_SMIME; - smime_config.outformat = FORMAT_SMIME; - smime_config.keyform = FORMAT_PEM; + memset(&cfg, 0, sizeof(cfg)); + cfg.flags = PKCS7_DETACHED; + cfg.informat = FORMAT_SMIME; + cfg.outformat = FORMAT_SMIME; + cfg.keyform = FORMAT_PEM; if (options_parse(argc, argv, smime_options, NULL, &argsused) != 0) { goto argerr; } args = argv + argsused; ret = 1; - if (!(smime_config.operation & SMIME_SIGNERS) && - (smime_config.skkeys != NULL || smime_config.sksigners != NULL)) { + if (!(cfg.operation & SMIME_SIGNERS) && + (cfg.skkeys != NULL || cfg.sksigners != NULL)) { BIO_puts(bio_err, "Multiple signers or keys not allowed\n"); goto argerr; } - if (smime_config.operation & SMIME_SIGNERS) { + if (cfg.operation & SMIME_SIGNERS) { /* Check to see if any final signer needs to be appended */ - if (smime_config.keyfile != NULL && - smime_config.signerfile == NULL) { + if (cfg.keyfile != NULL && + cfg.signerfile == NULL) { BIO_puts(bio_err, "Illegal -inkey without -signer\n"); goto argerr; } - if (smime_config.signerfile != NULL) { - if (smime_config.sksigners == NULL) { - if ((smime_config.sksigners = + if (cfg.signerfile != NULL) { + if (cfg.sksigners == NULL) { + if ((cfg.sksigners = sk_OPENSSL_STRING_new_null()) == NULL) goto end; } - if (!sk_OPENSSL_STRING_push(smime_config.sksigners, - smime_config.signerfile)) + if (!sk_OPENSSL_STRING_push(cfg.sksigners, + cfg.signerfile)) goto end; - if (smime_config.skkeys == NULL) { - if ((smime_config.skkeys = + if (cfg.skkeys == NULL) { + if ((cfg.skkeys = sk_OPENSSL_STRING_new_null()) == NULL) goto end; } - if (smime_config.keyfile == NULL) - smime_config.keyfile = smime_config.signerfile; - if (!sk_OPENSSL_STRING_push(smime_config.skkeys, - smime_config.keyfile)) + if (cfg.keyfile == NULL) + cfg.keyfile = cfg.signerfile; + if (!sk_OPENSSL_STRING_push(cfg.skkeys, + cfg.keyfile)) goto end; } - if (smime_config.sksigners == NULL) { + if (cfg.sksigners == NULL) { BIO_printf(bio_err, "No signer certificate specified\n"); badarg = 1; } - smime_config.signerfile = NULL; - smime_config.keyfile = NULL; - } else if (smime_config.operation == SMIME_DECRYPT) { - if (smime_config.recipfile == NULL && - smime_config.keyfile == NULL) { + cfg.signerfile = NULL; + cfg.keyfile = NULL; + } else if (cfg.operation == SMIME_DECRYPT) { + if (cfg.recipfile == NULL && + cfg.keyfile == NULL) { BIO_printf(bio_err, "No recipient certificate or key specified\n"); badarg = 1; } - } else if (smime_config.operation == SMIME_ENCRYPT) { + } else if (cfg.operation == SMIME_ENCRYPT) { if (*args == NULL) { BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n"); badarg = 1; } - } else if (!smime_config.operation) { + } else if (!cfg.operation) { badarg = 1; } @@ -802,35 +800,35 @@ smime_main(int argc, char **argv) goto end; } - if (!app_passwd(bio_err, smime_config.passargin, NULL, &passin, NULL)) { + if (!app_passwd(bio_err, cfg.passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } ret = 2; - if (!(smime_config.operation & SMIME_SIGNERS)) - smime_config.flags &= ~PKCS7_DETACHED; + if (!(cfg.operation & SMIME_SIGNERS)) + cfg.flags &= ~PKCS7_DETACHED; - if (smime_config.operation & SMIME_OP) { - if (smime_config.outformat == FORMAT_ASN1) + if (cfg.operation & SMIME_OP) { + if (cfg.outformat == FORMAT_ASN1) outmode = "wb"; } else { - if (smime_config.flags & PKCS7_BINARY) + if (cfg.flags & PKCS7_BINARY) outmode = "wb"; } - if (smime_config.operation & SMIME_IP) { - if (smime_config.informat == FORMAT_ASN1) + if (cfg.operation & SMIME_IP) { + if (cfg.informat == FORMAT_ASN1) inmode = "rb"; } else { - if (smime_config.flags & PKCS7_BINARY) + if (cfg.flags & PKCS7_BINARY) inmode = "rb"; } - if (smime_config.operation == SMIME_ENCRYPT) { - if (smime_config.cipher == NULL) { + if (cfg.operation == SMIME_ENCRYPT) { + if (cfg.cipher == NULL) { #ifndef OPENSSL_NO_RC2 - smime_config.cipher = EVP_rc2_40_cbc(); + cfg.cipher = EVP_rc2_40_cbc(); #else BIO_printf(bio_err, "No cipher selected\n"); goto end; @@ -849,41 +847,41 @@ smime_main(int argc, char **argv) args++; } } - if (smime_config.certfile != NULL) { - if ((other = load_certs(bio_err, smime_config.certfile, + if (cfg.certfile != NULL) { + if ((other = load_certs(bio_err, cfg.certfile, FORMAT_PEM, NULL, "certificate file")) == NULL) { ERR_print_errors(bio_err); goto end; } } - if (smime_config.recipfile != NULL && - (smime_config.operation == SMIME_DECRYPT)) { - if ((recip = load_cert(bio_err, smime_config.recipfile, + if (cfg.recipfile != NULL && + (cfg.operation == SMIME_DECRYPT)) { + if ((recip = load_cert(bio_err, cfg.recipfile, FORMAT_PEM, NULL, "recipient certificate file")) == NULL) { ERR_print_errors(bio_err); goto end; } } - if (smime_config.operation == SMIME_DECRYPT) { - if (smime_config.keyfile == NULL) - smime_config.keyfile = smime_config.recipfile; - } else if (smime_config.operation == SMIME_SIGN) { - if (smime_config.keyfile == NULL) - smime_config.keyfile = smime_config.signerfile; + if (cfg.operation == SMIME_DECRYPT) { + if (cfg.keyfile == NULL) + cfg.keyfile = cfg.recipfile; + } else if (cfg.operation == SMIME_SIGN) { + if (cfg.keyfile == NULL) + cfg.keyfile = cfg.signerfile; } else { - smime_config.keyfile = NULL; + cfg.keyfile = NULL; } - if (smime_config.keyfile != NULL) { - key = load_key(bio_err, smime_config.keyfile, - smime_config.keyform, 0, passin, "signing key file"); + if (cfg.keyfile != NULL) { + key = load_key(bio_err, cfg.keyfile, + cfg.keyform, 0, passin, "signing key file"); if (key == NULL) goto end; } - if (smime_config.infile != NULL) { - if ((in = BIO_new_file(smime_config.infile, inmode)) == NULL) { + if (cfg.infile != NULL) { + if ((in = BIO_new_file(cfg.infile, inmode)) == NULL) { BIO_printf(bio_err, - "Can't open input file %s\n", smime_config.infile); + "Can't open input file %s\n", cfg.infile); goto end; } } else { @@ -891,12 +889,12 @@ smime_main(int argc, char **argv) goto end; } - if (smime_config.operation & SMIME_IP) { - if (smime_config.informat == FORMAT_SMIME) + if (cfg.operation & SMIME_IP) { + if (cfg.informat == FORMAT_SMIME) p7 = SMIME_read_PKCS7(in, &indata); - else if (smime_config.informat == FORMAT_PEM) + else if (cfg.informat == FORMAT_PEM) p7 = PEM_read_bio_PKCS7(in, NULL, NULL, NULL); - else if (smime_config.informat == FORMAT_ASN1) + else if (cfg.informat == FORMAT_ASN1) p7 = d2i_PKCS7_bio(in, NULL); else { BIO_printf(bio_err, @@ -908,22 +906,22 @@ smime_main(int argc, char **argv) BIO_printf(bio_err, "Error reading S/MIME message\n"); goto end; } - if (smime_config.contfile != NULL) { + if (cfg.contfile != NULL) { BIO_free(indata); - if ((indata = BIO_new_file(smime_config.contfile, + if ((indata = BIO_new_file(cfg.contfile, "rb")) == NULL) { BIO_printf(bio_err, "Can't read content file %s\n", - smime_config.contfile); + cfg.contfile); goto end; } } } - if (smime_config.outfile != NULL) { - if ((out = BIO_new_file(smime_config.outfile, outmode)) == NULL) { + if (cfg.outfile != NULL) { + if ((out = BIO_new_file(cfg.outfile, outmode)) == NULL) { BIO_printf(bio_err, "Can't open output file %s\n", - smime_config.outfile); + cfg.outfile); goto end; } } else { @@ -931,60 +929,60 @@ smime_main(int argc, char **argv) goto end; } - if (smime_config.operation == SMIME_VERIFY) { - if ((store = setup_verify(bio_err, smime_config.CAfile, - smime_config.CApath)) == NULL) + if (cfg.operation == SMIME_VERIFY) { + if ((store = setup_verify(bio_err, cfg.CAfile, + cfg.CApath)) == NULL) goto end; X509_STORE_set_verify_cb(store, smime_cb); - if (smime_config.vpm != NULL) { - if (!X509_STORE_set1_param(store, smime_config.vpm)) + if (cfg.vpm != NULL) { + if (!X509_STORE_set1_param(store, cfg.vpm)) goto end; } } ret = 3; - if (smime_config.operation == SMIME_ENCRYPT) { - if (smime_config.indef) - smime_config.flags |= PKCS7_STREAM; - p7 = PKCS7_encrypt(encerts, in, smime_config.cipher, - smime_config.flags); - } else if (smime_config.operation & SMIME_SIGNERS) { + if (cfg.operation == SMIME_ENCRYPT) { + if (cfg.indef) + cfg.flags |= PKCS7_STREAM; + p7 = PKCS7_encrypt(encerts, in, cfg.cipher, + cfg.flags); + } else if (cfg.operation & SMIME_SIGNERS) { int i; /* * If detached data content we only enable streaming if * S/MIME output format. */ - if (smime_config.operation == SMIME_SIGN) { - if (smime_config.flags & PKCS7_DETACHED) { - if (smime_config.outformat == FORMAT_SMIME) - smime_config.flags |= PKCS7_STREAM; - } else if (smime_config.indef) { - smime_config.flags |= PKCS7_STREAM; + if (cfg.operation == SMIME_SIGN) { + if (cfg.flags & PKCS7_DETACHED) { + if (cfg.outformat == FORMAT_SMIME) + cfg.flags |= PKCS7_STREAM; + } else if (cfg.indef) { + cfg.flags |= PKCS7_STREAM; } - smime_config.flags |= PKCS7_PARTIAL; + cfg.flags |= PKCS7_PARTIAL; p7 = PKCS7_sign(NULL, NULL, other, in, - smime_config.flags); + cfg.flags); if (p7 == NULL) goto end; } else { - smime_config.flags |= PKCS7_REUSE_DIGEST; + cfg.flags |= PKCS7_REUSE_DIGEST; } - for (i = 0; i < sk_OPENSSL_STRING_num(smime_config.sksigners); i++) { - smime_config.signerfile = - sk_OPENSSL_STRING_value(smime_config.sksigners, i); - smime_config.keyfile = - sk_OPENSSL_STRING_value(smime_config.skkeys, i); - signer = load_cert(bio_err, smime_config.signerfile, + for (i = 0; i < sk_OPENSSL_STRING_num(cfg.sksigners); i++) { + cfg.signerfile = + sk_OPENSSL_STRING_value(cfg.sksigners, i); + cfg.keyfile = + sk_OPENSSL_STRING_value(cfg.skkeys, i); + signer = load_cert(bio_err, cfg.signerfile, FORMAT_PEM, NULL, "signer certificate"); if (signer == NULL) goto end; - key = load_key(bio_err, smime_config.keyfile, - smime_config.keyform, 0, passin, + key = load_key(bio_err, cfg.keyfile, + cfg.keyform, 0, passin, "signing key file"); if (key == NULL) goto end; if (PKCS7_sign_add_signer(p7, signer, key, - smime_config.sign_md, smime_config.flags) == NULL) + cfg.sign_md, cfg.flags) == NULL) goto end; X509_free(signer); signer = NULL; @@ -992,9 +990,9 @@ smime_main(int argc, char **argv) key = NULL; } /* If not streaming or resigning finalize structure */ - if ((smime_config.operation == SMIME_SIGN) && - !(smime_config.flags & PKCS7_STREAM)) { - if (!PKCS7_final(p7, in, smime_config.flags)) + if ((cfg.operation == SMIME_SIGN) && + !(cfg.flags & PKCS7_STREAM)) { + if (!PKCS7_final(p7, in, cfg.flags)) goto end; } } @@ -1004,58 +1002,58 @@ smime_main(int argc, char **argv) } ret = 4; - if (smime_config.operation == SMIME_DECRYPT) { - if (!PKCS7_decrypt(p7, key, recip, out, smime_config.flags)) { + if (cfg.operation == SMIME_DECRYPT) { + if (!PKCS7_decrypt(p7, key, recip, out, cfg.flags)) { BIO_printf(bio_err, "Error decrypting PKCS#7 structure\n"); goto end; } - } else if (smime_config.operation == SMIME_VERIFY) { + } else if (cfg.operation == SMIME_VERIFY) { STACK_OF(X509) *signers; if (PKCS7_verify(p7, other, store, indata, out, - smime_config.flags)) { + cfg.flags)) { BIO_printf(bio_err, "Verification successful\n"); } else { BIO_printf(bio_err, "Verification failure\n"); goto end; } if ((signers = PKCS7_get0_signers(p7, other, - smime_config.flags)) == NULL) + cfg.flags)) == NULL) goto end; - if (!save_certs(smime_config.signerfile, signers)) { + if (!save_certs(cfg.signerfile, signers)) { BIO_printf(bio_err, "Error writing signers to %s\n", - smime_config.signerfile); + cfg.signerfile); sk_X509_free(signers); ret = 5; goto end; } sk_X509_free(signers); - } else if (smime_config.operation == SMIME_PK7OUT) { + } else if (cfg.operation == SMIME_PK7OUT) { PEM_write_bio_PKCS7(out, p7); } else { - if (smime_config.to != NULL) - BIO_printf(out, "To: %s\n", smime_config.to); - if (smime_config.from != NULL) - BIO_printf(out, "From: %s\n", smime_config.from); - if (smime_config.subject != NULL) - BIO_printf(out, "Subject: %s\n", smime_config.subject); - if (smime_config.outformat == FORMAT_SMIME) { - if (smime_config.operation == SMIME_RESIGN) { + if (cfg.to != NULL) + BIO_printf(out, "To: %s\n", cfg.to); + if (cfg.from != NULL) + BIO_printf(out, "From: %s\n", cfg.from); + if (cfg.subject != NULL) + BIO_printf(out, "Subject: %s\n", cfg.subject); + if (cfg.outformat == FORMAT_SMIME) { + if (cfg.operation == SMIME_RESIGN) { if (!SMIME_write_PKCS7(out, p7, indata, - smime_config.flags)) + cfg.flags)) goto end; } else { if (!SMIME_write_PKCS7(out, p7, in, - smime_config.flags)) + cfg.flags)) goto end; } - } else if (smime_config.outformat == FORMAT_PEM) { + } else if (cfg.outformat == FORMAT_PEM) { if (!PEM_write_bio_PKCS7_stream(out, p7, in, - smime_config.flags)) + cfg.flags)) goto end; - } else if (smime_config.outformat == FORMAT_ASN1) { + } else if (cfg.outformat == FORMAT_ASN1) { if (!i2d_PKCS7_bio_stream(out, p7, in, - smime_config.flags)) + cfg.flags)) goto end; } else { BIO_printf(bio_err, @@ -1071,9 +1069,9 @@ smime_main(int argc, char **argv) ERR_print_errors(bio_err); sk_X509_pop_free(encerts, X509_free); sk_X509_pop_free(other, X509_free); - X509_VERIFY_PARAM_free(smime_config.vpm); - sk_OPENSSL_STRING_free(smime_config.sksigners); - sk_OPENSSL_STRING_free(smime_config.skkeys); + X509_VERIFY_PARAM_free(cfg.vpm); + sk_OPENSSL_STRING_free(cfg.sksigners); + sk_OPENSSL_STRING_free(cfg.skkeys); X509_STORE_free(store); X509_free(cert); X509_free(recip); diff --git a/apps/openssl/speed.c b/apps/openssl/speed.c index c0f86c08..5beaf607 100644 --- a/apps/openssl/speed.c +++ b/apps/openssl/speed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: speed.c,v 1.28 2022/01/14 09:27:30 tb Exp $ */ +/* $OpenBSD: speed.c,v 1.30 2023/02/23 14:55:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -480,11 +480,9 @@ speed_main(int argc, char **argv) const char *errstr = NULL; #endif - if (single_execution) { - if (pledge("stdio proc", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio proc", NULL) == -1) { + perror("pledge"); + exit(1); } usertime = -1; @@ -1534,7 +1532,7 @@ speed_main(int argc, char **argv) } d = Time_F(STOP); BIO_printf(bio_err, mr ? "+R1:%ld:%d:%.2f\n" - : "%ld %d bit private RSA's in %.2fs\n", + : "%ld %d bit private RSA in %.2fs\n", count, rsa_bits[j], d); rsa_results[j][0] = d / (double) count; rsa_count = count; @@ -1563,7 +1561,7 @@ speed_main(int argc, char **argv) } d = Time_F(STOP); BIO_printf(bio_err, mr ? "+R2:%ld:%d:%.2f\n" - : "%ld %d bit public RSA's in %.2fs\n", + : "%ld %d bit public RSA in %.2fs\n", count, rsa_bits[j], d); rsa_results[j][1] = d / (double) count; } @@ -1991,7 +1989,7 @@ pkey_print_message(const char *str, const char *str2, long num, int bits, int tm) { BIO_printf(bio_err, mr ? "+DTP:%d:%s:%s:%d\n" - : "Doing %d bit %s %s's for %ds: ", bits, str, str2, tm); + : "Doing %d bit %s %s for %ds: ", bits, str, str2, tm); (void) BIO_flush(bio_err); alarm(tm); } @@ -2003,7 +2001,7 @@ print_result(int alg, int run_no, int count, double time_used) speed_alarm_free(run); #endif BIO_printf(bio_err, mr ? "+R:%d:%s:%f\n" - : "%d %s's in %.2fs\n", count, names[alg], time_used); + : "%d %s in %.2fs\n", count, names[alg], time_used); results[alg][run_no] = ((double) count) / time_used * lengths[run_no]; } diff --git a/apps/openssl/spkac.c b/apps/openssl/spkac.c index 7fd8523c..12d530e3 100644 --- a/apps/openssl/spkac.c +++ b/apps/openssl/spkac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spkac.c,v 1.11 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: spkac.c,v 1.13 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. Based on an original idea by Massimiliano Pala * (madwolf@openca.org). @@ -84,7 +84,7 @@ static struct { char *spkac; char *spksect; int verify; -} spkac_config; +} cfg; static const struct option spkac_options[] = { { @@ -92,54 +92,54 @@ static const struct option spkac_options[] = { .argname = "string", .desc = "Specify challenge string if SPKAC is generated", .type = OPTION_ARG, - .opt.arg = &spkac_config.challenge, + .opt.arg = &cfg.challenge, }, { .name = "in", .argname = "file", .desc = "Input file (default stdin)", .type = OPTION_ARG, - .opt.arg = &spkac_config.infile, + .opt.arg = &cfg.infile, }, { .name = "key", .argname = "file", .desc = "Create SPKAC using private key file", .type = OPTION_ARG, - .opt.arg = &spkac_config.keyfile, + .opt.arg = &cfg.keyfile, }, { .name = "noout", .desc = "Do not print text version of SPKAC", .type = OPTION_FLAG, - .opt.flag = &spkac_config.noout, + .opt.flag = &cfg.noout, }, { .name = "out", .argname = "file", .desc = "Output file (default stdout)", .type = OPTION_ARG, - .opt.arg = &spkac_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "passin", .argname = "src", .desc = "Input file passphrase source", .type = OPTION_ARG, - .opt.arg = &spkac_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "pubkey", .desc = "Output public key of an SPKAC (not used if creating)", .type = OPTION_FLAG, - .opt.flag = &spkac_config.pubkey, + .opt.flag = &cfg.pubkey, }, { .name = "spkac", .argname = "name", .desc = "SPKAC name (default \"SPKAC\")", .type = OPTION_ARG, - .opt.arg = &spkac_config.spkac, + .opt.arg = &cfg.spkac, }, { .name = "spksect", @@ -147,13 +147,13 @@ static const struct option spkac_options[] = { .desc = "Name of the section containing SPKAC (default" " \"default\")", .type = OPTION_ARG, - .opt.arg = &spkac_config.spksect, + .opt.arg = &cfg.spksect, }, { .name = "verify", .desc = "Verify digital signature on supplied SPKAC", .type = OPTION_FLAG, - .opt.flag = &spkac_config.verify, + .opt.flag = &cfg.verify, }, { NULL } }; @@ -181,39 +181,37 @@ spkac_main(int argc, char **argv) NETSCAPE_SPKI *spki = NULL; EVP_PKEY *pkey = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&spkac_config, 0, sizeof(spkac_config)); - spkac_config.spkac = "SPKAC"; - spkac_config.spksect = "default"; + memset(&cfg, 0, sizeof(cfg)); + cfg.spkac = "SPKAC"; + cfg.spksect = "default"; if (options_parse(argc, argv, spkac_options, NULL, NULL) != 0) { spkac_usage(); return (1); } - if (!app_passwd(bio_err, spkac_config.passargin, NULL, &passin, NULL)) { + if (!app_passwd(bio_err, cfg.passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } - if (spkac_config.keyfile) { + if (cfg.keyfile) { pkey = load_key(bio_err, - strcmp(spkac_config.keyfile, "-") ? spkac_config.keyfile + strcmp(cfg.keyfile, "-") ? cfg.keyfile : NULL, FORMAT_PEM, 1, passin, "private key"); if (!pkey) { goto end; } spki = NETSCAPE_SPKI_new(); - if (spkac_config.challenge) + if (cfg.challenge) ASN1_STRING_set(spki->spkac->challenge, - spkac_config.challenge, - (int) strlen(spkac_config.challenge)); + cfg.challenge, + (int) strlen(cfg.challenge)); NETSCAPE_SPKI_set_pubkey(spki, pkey); NETSCAPE_SPKI_sign(spki, pkey, EVP_md5()); spkstr = NETSCAPE_SPKI_b64_encode(spki); @@ -223,8 +221,8 @@ spkac_main(int argc, char **argv) goto end; } - if (spkac_config.outfile) - out = BIO_new_file(spkac_config.outfile, "w"); + if (cfg.outfile) + out = BIO_new_file(cfg.outfile, "w"); else out = BIO_new_fp(stdout, BIO_NOCLOSE); @@ -238,8 +236,8 @@ spkac_main(int argc, char **argv) free(spkstr); goto end; } - if (spkac_config.infile) - in = BIO_new_file(spkac_config.infile, "r"); + if (cfg.infile) + in = BIO_new_file(cfg.infile, "r"); else in = BIO_new_fp(stdin, BIO_NOCLOSE); @@ -256,12 +254,12 @@ spkac_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - spkstr = NCONF_get_string(conf, spkac_config.spksect, - spkac_config.spkac); + spkstr = NCONF_get_string(conf, cfg.spksect, + cfg.spkac); if (!spkstr) { BIO_printf(bio_err, "Can't find SPKAC called \"%s\"\n", - spkac_config.spkac); + cfg.spkac); ERR_print_errors(bio_err); goto end; } @@ -272,8 +270,8 @@ spkac_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (spkac_config.outfile) - out = BIO_new_file(spkac_config.outfile, "w"); + if (cfg.outfile) + out = BIO_new_file(cfg.outfile, "w"); else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } @@ -283,10 +281,10 @@ spkac_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (!spkac_config.noout) + if (!cfg.noout) NETSCAPE_SPKI_print(out, spki); pkey = NETSCAPE_SPKI_get_pubkey(spki); - if (spkac_config.verify) { + if (cfg.verify) { i = NETSCAPE_SPKI_verify(spki, pkey); if (i > 0) BIO_printf(bio_err, "Signature OK\n"); @@ -296,7 +294,7 @@ spkac_main(int argc, char **argv) goto end; } } - if (spkac_config.pubkey) + if (cfg.pubkey) PEM_write_bio_PUBKEY(out, pkey); ret = 0; diff --git a/apps/openssl/ts.c b/apps/openssl/ts.c index 24301b69..84008183 100644 --- a/apps/openssl/ts.c +++ b/apps/openssl/ts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts.c,v 1.24 2022/09/11 18:08:17 tb Exp $ */ +/* $OpenBSD: ts.c,v 1.26 2023/03/06 14:32:06 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -138,7 +138,7 @@ static struct { int token_in; int token_out; char *untrusted; -} ts_config; +} cfg; static int ts_opt_md(int argc, char **argv, int *argsused) @@ -148,7 +148,7 @@ ts_opt_md(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((ts_config.md = EVP_get_digestbyname(name)) == NULL) + if ((cfg.md = EVP_get_digestbyname(name)) == NULL) return (1); *argsused = 1; @@ -158,27 +158,27 @@ ts_opt_md(int argc, char **argv, int *argsused) static int ts_opt_query(void) { - if (ts_config.mode != CMD_NONE) + if (cfg.mode != CMD_NONE) return (1); - ts_config.mode = CMD_QUERY; + cfg.mode = CMD_QUERY; return (0); } static int ts_opt_reply(void) { - if (ts_config.mode != CMD_NONE) + if (cfg.mode != CMD_NONE) return (1); - ts_config.mode = CMD_REPLY; + cfg.mode = CMD_REPLY; return (0); } static int ts_opt_verify(void) { - if (ts_config.mode != CMD_NONE) + if (cfg.mode != CMD_NONE) return (1); - ts_config.mode = CMD_VERIFY; + cfg.mode = CMD_VERIFY; return (0); } @@ -188,89 +188,89 @@ static const struct option ts_options[] = { .argname = "file", .desc = "Certificate Authority file", .type = OPTION_ARG, - .opt.arg = &ts_config.ca_file, + .opt.arg = &cfg.ca_file, }, { .name = "CApath", .argname = "path", .desc = "Certificate Authority path", .type = OPTION_ARG, - .opt.arg = &ts_config.ca_path, + .opt.arg = &cfg.ca_path, }, { .name = "cert", .desc = "Include signing certificate in the response", .type = OPTION_FLAG, - .opt.flag = &ts_config.cert, + .opt.flag = &cfg.cert, }, { .name = "chain", .argname = "file", .desc = "PEM certificates that will be included in the response", .type = OPTION_ARG, - .opt.arg = &ts_config.chain, + .opt.arg = &cfg.chain, }, { .name = "config", .argname = "file", .desc = "Specify an alternative configuration file", .type = OPTION_ARG, - .opt.arg = &ts_config.configfile, + .opt.arg = &cfg.configfile, }, { .name = "data", .argname = "file", .desc = "Data file for which the time stamp request needs to be created", .type = OPTION_ARG, - .opt.arg = &ts_config.data, + .opt.arg = &cfg.data, }, { .name = "digest", .argname = "arg", .desc = "Specify the message imprint explicitly without the data file", .type = OPTION_ARG, - .opt.arg = &ts_config.digest, + .opt.arg = &cfg.digest, }, { .name = "in", .argname = "file", .desc = "Input file", .type = OPTION_ARG, - .opt.arg = &ts_config.in, + .opt.arg = &cfg.in, }, { .name = "inkey", .argname = "file", .desc = "Input key file", .type = OPTION_ARG, - .opt.arg = &ts_config.inkey, + .opt.arg = &cfg.inkey, }, { .name = "no_nonce", .desc = "Specify no nonce in the request", .type = OPTION_FLAG, - .opt.flag = &ts_config.no_nonce, + .opt.flag = &cfg.no_nonce, }, { .name = "out", .argname = "file", .desc = "Output file", .type = OPTION_ARG, - .opt.arg = &ts_config.out, + .opt.arg = &cfg.out, }, { .name = "passin", .argname = "src", .desc = "Private key password source", .type = OPTION_ARG, - .opt.arg = &ts_config.passin, + .opt.arg = &cfg.passin, }, { .name = "policy", .argname = "object_id", .desc = "Policy for the TSA to use when creating the time stamp token", .type = OPTION_ARG, - .opt.arg = &ts_config.policy, + .opt.arg = &cfg.policy, }, { .name = "query", @@ -283,7 +283,7 @@ static const struct option ts_options[] = { .argname = "file", .desc = "File containing a DER-encoded time stamp request", .type = OPTION_ARG, - .opt.arg = &ts_config.queryfile, + .opt.arg = &cfg.queryfile, }, { .name = "reply", @@ -296,39 +296,39 @@ static const struct option ts_options[] = { .argname = "arg", .desc = "TSA section containing the settings for response generation", .type = OPTION_ARG, - .opt.arg = &ts_config.section, + .opt.arg = &cfg.section, }, { .name = "signer", .argname = "file", .desc = "Signer certificate file", .type = OPTION_ARG, - .opt.arg = &ts_config.signer, + .opt.arg = &cfg.signer, }, { .name = "text", .desc = "Output in human-readable text format", .type = OPTION_FLAG, - .opt.flag = &ts_config.text, + .opt.flag = &cfg.text, }, { .name = "token_in", .desc = "Input is a DER-encoded time stamp token", .type = OPTION_FLAG, - .opt.flag = &ts_config.token_in, + .opt.flag = &cfg.token_in, }, { .name = "token_out", .desc = "Output is a DER-encoded time stamp token", .type = OPTION_FLAG, - .opt.flag = &ts_config.token_out, + .opt.flag = &cfg.token_out, }, { .name = "untrusted", .argname = "file", .desc = "File containing untrusted certificates", .type = OPTION_ARG, - .opt.arg = &ts_config.untrusted, + .opt.arg = &cfg.untrusted, }, { .name = "verify", @@ -377,22 +377,20 @@ ts_main(int argc, char **argv) CONF *conf = NULL; char *password = NULL; /* Password itself. */ - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&ts_config, 0, sizeof(ts_config)); - ts_config.mode = CMD_NONE; + memset(&cfg, 0, sizeof(cfg)); + cfg.mode = CMD_NONE; if (options_parse(argc, argv, ts_options, NULL, NULL) != 0) goto usage; /* Get the password if required. */ - if (ts_config.mode == CMD_REPLY && ts_config.passin != NULL && - !app_passwd(bio_err, ts_config.passin, NULL, &password, NULL)) { + if (cfg.mode == CMD_REPLY && cfg.passin != NULL && + !app_passwd(bio_err, cfg.passin, NULL, &password, NULL)) { BIO_printf(bio_err, "Error getting password.\n"); goto cleanup; } @@ -400,7 +398,7 @@ ts_main(int argc, char **argv) * Check consistency of parameters and execute the appropriate * function. */ - switch (ts_config.mode) { + switch (cfg.mode) { case CMD_NONE: goto usage; case CMD_QUERY: @@ -408,50 +406,50 @@ ts_main(int argc, char **argv) * Data file and message imprint cannot be specified at the * same time. */ - ret = ts_config.data != NULL && ts_config.digest != NULL; + ret = cfg.data != NULL && cfg.digest != NULL; if (ret) goto usage; /* Load the config file for possible policy OIDs. */ - conf = load_config_file(ts_config.configfile); - ret = !query_command(ts_config.data, ts_config.digest, - ts_config.md, ts_config.policy, ts_config.no_nonce, - ts_config.cert, ts_config.in, ts_config.out, - ts_config.text); + conf = load_config_file(cfg.configfile); + ret = !query_command(cfg.data, cfg.digest, + cfg.md, cfg.policy, cfg.no_nonce, + cfg.cert, cfg.in, cfg.out, + cfg.text); break; case CMD_REPLY: - conf = load_config_file(ts_config.configfile); - if (ts_config.in == NULL) { - ret = !(ts_config.queryfile != NULL && conf != NULL && - !ts_config.token_in); + conf = load_config_file(cfg.configfile); + if (cfg.in == NULL) { + ret = !(cfg.queryfile != NULL && conf != NULL && + !cfg.token_in); if (ret) goto usage; } else { /* 'in' and 'queryfile' are exclusive. */ - ret = !(ts_config.queryfile == NULL); + ret = !(cfg.queryfile == NULL); if (ret) goto usage; } - ret = !reply_command(conf, ts_config.section, - ts_config.queryfile, password, ts_config.inkey, - ts_config.signer, ts_config.chain, ts_config.policy, - ts_config.in, ts_config.token_in, ts_config.out, - ts_config.token_out, ts_config.text); + ret = !reply_command(conf, cfg.section, + cfg.queryfile, password, cfg.inkey, + cfg.signer, cfg.chain, cfg.policy, + cfg.in, cfg.token_in, cfg.out, + cfg.token_out, cfg.text); break; case CMD_VERIFY: - ret = !(((ts_config.queryfile != NULL && ts_config.data == NULL && - ts_config.digest == NULL) || - (ts_config.queryfile == NULL && ts_config.data != NULL && - ts_config.digest == NULL) || - (ts_config.queryfile == NULL && ts_config.data == NULL && - ts_config.digest != NULL)) && - ts_config.in != NULL); + ret = !(((cfg.queryfile != NULL && cfg.data == NULL && + cfg.digest == NULL) || + (cfg.queryfile == NULL && cfg.data != NULL && + cfg.digest == NULL) || + (cfg.queryfile == NULL && cfg.data == NULL && + cfg.digest != NULL)) && + cfg.in != NULL); if (ret) goto usage; - ret = !verify_command(ts_config.data, ts_config.digest, - ts_config.queryfile, ts_config.in, ts_config.token_in, - ts_config.ca_path, ts_config.ca_file, ts_config.untrusted); + ret = !verify_command(cfg.data, cfg.digest, + cfg.queryfile, cfg.in, cfg.token_in, + cfg.ca_path, cfg.ca_file, cfg.untrusted); } goto cleanup; diff --git a/apps/openssl/verify.c b/apps/openssl/verify.c index dd321761..b4126239 100644 --- a/apps/openssl/verify.c +++ b/apps/openssl/verify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: verify.c,v 1.14 2021/02/15 17:57:58 jsing Exp $ */ +/* $OpenBSD: verify.c,v 1.16 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -81,7 +81,7 @@ static struct { char *untfile; int verbose; X509_VERIFY_PARAM *vpm; -} verify_config; +} cfg; static int verify_opt_args(int argc, char **argv, int *argsused) @@ -89,7 +89,7 @@ verify_opt_args(int argc, char **argv, int *argsused) int oargc = argc; int badarg = 0; - if (!args_verify(&argv, &argc, &badarg, bio_err, &verify_config.vpm)) + if (!args_verify(&argv, &argc, &badarg, bio_err, &cfg.vpm)) return (1); if (badarg) return (1); @@ -105,41 +105,41 @@ static const struct option verify_options[] = { .argname = "file", .desc = "Certificate Authority file", .type = OPTION_ARG, - .opt.arg = &verify_config.CAfile, + .opt.arg = &cfg.CAfile, }, { .name = "CApath", .argname = "path", .desc = "Certificate Authority path", .type = OPTION_ARG, - .opt.arg = &verify_config.CApath, + .opt.arg = &cfg.CApath, }, { .name = "CRLfile", .argname = "file", .desc = "Certificate Revocation List file", .type = OPTION_ARG, - .opt.arg = &verify_config.crlfile, + .opt.arg = &cfg.crlfile, }, { .name = "trusted", .argname = "file", .desc = "Trusted certificates file", .type = OPTION_ARG, - .opt.arg = &verify_config.trustfile, + .opt.arg = &cfg.trustfile, }, { .name = "untrusted", .argname = "file", .desc = "Untrusted certificates file", .type = OPTION_ARG, - .opt.arg = &verify_config.untfile, + .opt.arg = &cfg.untfile, }, { .name = "verbose", .desc = "Verbose", .type = OPTION_FLAG, - .opt.flag = &verify_config.verbose, + .opt.flag = &cfg.verbose, }, { .name = NULL, @@ -268,14 +268,12 @@ verify_main(int argc, char **argv) int argsused; int ret = 1; - if (single_execution) { - if (pledge("stdio rpath", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio rpath", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&verify_config, 0, sizeof(verify_config)); + memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, verify_options, NULL, &argsused) != 0) { verify_usage(); @@ -290,17 +288,17 @@ verify_main(int argc, char **argv) goto end; X509_STORE_set_verify_cb(cert_ctx, cb); - if (verify_config.vpm) - X509_STORE_set1_param(cert_ctx, verify_config.vpm); + if (cfg.vpm) + X509_STORE_set1_param(cert_ctx, cfg.vpm); lookup = X509_STORE_add_lookup(cert_ctx, X509_LOOKUP_file()); if (lookup == NULL) abort(); /* XXX */ - if (verify_config.CAfile) { - if (!X509_LOOKUP_load_file(lookup, verify_config.CAfile, + if (cfg.CAfile) { + if (!X509_LOOKUP_load_file(lookup, cfg.CAfile, X509_FILETYPE_PEM)) { BIO_printf(bio_err, "Error loading file %s\n", - verify_config.CAfile); + cfg.CAfile); ERR_print_errors(bio_err); goto end; } @@ -310,11 +308,11 @@ verify_main(int argc, char **argv) lookup = X509_STORE_add_lookup(cert_ctx, X509_LOOKUP_hash_dir()); if (lookup == NULL) abort(); /* XXX */ - if (verify_config.CApath) { - if (!X509_LOOKUP_add_dir(lookup, verify_config.CApath, + if (cfg.CApath) { + if (!X509_LOOKUP_add_dir(lookup, cfg.CApath, X509_FILETYPE_PEM)) { BIO_printf(bio_err, "Error loading directory %s\n", - verify_config.CApath); + cfg.CApath); ERR_print_errors(bio_err); goto end; } @@ -323,20 +321,20 @@ verify_main(int argc, char **argv) ERR_clear_error(); - if (verify_config.untfile) { - untrusted = load_certs(bio_err, verify_config.untfile, + if (cfg.untfile) { + untrusted = load_certs(bio_err, cfg.untfile, FORMAT_PEM, NULL, "untrusted certificates"); if (!untrusted) goto end; } - if (verify_config.trustfile) { - trusted = load_certs(bio_err, verify_config.trustfile, + if (cfg.trustfile) { + trusted = load_certs(bio_err, cfg.trustfile, FORMAT_PEM, NULL, "trusted certificates"); if (!trusted) goto end; } - if (verify_config.crlfile) { - crls = load_crls(bio_err, verify_config.crlfile, FORMAT_PEM, + if (cfg.crlfile) { + crls = load_crls(bio_err, cfg.crlfile, FORMAT_PEM, NULL, "other CRLs"); if (!crls) goto end; @@ -354,8 +352,8 @@ verify_main(int argc, char **argv) } end: - if (verify_config.vpm) - X509_VERIFY_PARAM_free(verify_config.vpm); + if (cfg.vpm) + X509_VERIFY_PARAM_free(cfg.vpm); if (cert_ctx != NULL) X509_STORE_free(cert_ctx); sk_X509_pop_free(untrusted, X509_free); @@ -456,7 +454,7 @@ cb(int ok, X509_STORE_CTX *ctx) } if (cert_error == X509_V_OK && ok == 2) policies_print(NULL, ctx); - if (!verify_config.verbose) + if (!cfg.verbose) ERR_clear_error(); return (ok); } diff --git a/apps/openssl/version.c b/apps/openssl/version.c index 374e0d0c..6ff1860e 100644 --- a/apps/openssl/version.c +++ b/apps/openssl/version.c @@ -1,4 +1,4 @@ -/* $OpenBSD: version.c,v 1.9 2019/07/14 03:30:46 guenther Exp $ */ +/* $OpenBSD: version.c,v 1.11 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -142,17 +142,17 @@ static struct { int options; int platform; int version; -} version_config; +} cfg; static int version_all_opts(void) { - version_config.cflags = 1; - version_config.date = 1; - version_config.dir= 1; - version_config.options = 1; - version_config.platform = 1; - version_config.version = 1; + cfg.cflags = 1; + cfg.date = 1; + cfg.dir= 1; + cfg.options = 1; + cfg.platform = 1; + cfg.version = 1; return (0); } @@ -168,37 +168,37 @@ static const struct option version_options[] = { .name = "b", .desc = "Date the current version of OpenSSL was built", .type = OPTION_FLAG, - .opt.flag = &version_config.date, + .opt.flag = &cfg.date, }, { .name = "d", .desc = "OPENSSLDIR value", .type = OPTION_FLAG, - .opt.flag = &version_config.dir, + .opt.flag = &cfg.dir, }, { .name = "f", .desc = "Compilation flags", .type = OPTION_FLAG, - .opt.flag = &version_config.cflags, + .opt.flag = &cfg.cflags, }, { .name = "o", .desc = "Option information", .type = OPTION_FLAG, - .opt.flag = &version_config.options, + .opt.flag = &cfg.options, }, { .name = "p", .desc = "Platform settings", .type = OPTION_FLAG, - .opt.flag = &version_config.platform, + .opt.flag = &cfg.platform, }, { .name = "v", .desc = "Current OpenSSL version", .type = OPTION_FLAG, - .opt.flag = &version_config.version, + .opt.flag = &cfg.version, }, {NULL}, }; @@ -213,14 +213,12 @@ version_usage(void) int version_main(int argc, char **argv) { - if (single_execution) { - if (pledge("stdio", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&version_config, 0, sizeof(version_config)); + memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, version_options, NULL, NULL) != 0) { version_usage(); @@ -228,9 +226,9 @@ version_main(int argc, char **argv) } if (argc == 1) - version_config.version = 1; + cfg.version = 1; - if (version_config.version) { + if (cfg.version) { if (SSLeay() == SSLEAY_VERSION_NUMBER) { printf("%s\n", SSLeay_version(SSLEAY_VERSION)); } else { @@ -239,11 +237,11 @@ version_main(int argc, char **argv) SSLeay_version(SSLEAY_VERSION)); } } - if (version_config.date) + if (cfg.date) printf("%s\n", SSLeay_version(SSLEAY_BUILT_ON)); - if (version_config.platform) + if (cfg.platform) printf("%s\n", SSLeay_version(SSLEAY_PLATFORM)); - if (version_config.options) { + if (cfg.options) { printf("options: "); printf("%s ", BN_options()); #ifndef OPENSSL_NO_RC4 @@ -260,9 +258,9 @@ version_main(int argc, char **argv) #endif printf("\n"); } - if (version_config.cflags) + if (cfg.cflags) printf("%s\n", SSLeay_version(SSLEAY_CFLAGS)); - if (version_config.dir) + if (cfg.dir) printf("%s\n", SSLeay_version(SSLEAY_DIR)); return (0); diff --git a/apps/openssl/x509.c b/apps/openssl/x509.c index c777ee9b..66cad3ab 100644 --- a/apps/openssl/x509.c +++ b/apps/openssl/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.29 2021/12/12 20:34:04 tb Exp $ */ +/* $OpenBSD: x509.c,v 1.31 2023/03/06 14:32:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -152,58 +152,58 @@ static struct { STACK_OF(ASN1_OBJECT) *trust; int trustout; int x509req; -} x509_config; +} cfg; static int x509_opt_addreject(char *arg) { - if ((x509_config.objtmp = OBJ_txt2obj(arg, 0)) == NULL) { + if ((cfg.objtmp = OBJ_txt2obj(arg, 0)) == NULL) { BIO_printf(bio_err, "Invalid reject object value %s\n", arg); return (1); } - if (x509_config.reject == NULL && - (x509_config.reject = sk_ASN1_OBJECT_new_null()) == NULL) + if (cfg.reject == NULL && + (cfg.reject = sk_ASN1_OBJECT_new_null()) == NULL) return (1); - if (!sk_ASN1_OBJECT_push(x509_config.reject, x509_config.objtmp)) + if (!sk_ASN1_OBJECT_push(cfg.reject, cfg.objtmp)) return (1); - x509_config.trustout = 1; + cfg.trustout = 1; return (0); } static int x509_opt_addtrust(char *arg) { - if ((x509_config.objtmp = OBJ_txt2obj(arg, 0)) == NULL) { + if ((cfg.objtmp = OBJ_txt2obj(arg, 0)) == NULL) { BIO_printf(bio_err, "Invalid trust object value %s\n", arg); return (1); } - if (x509_config.trust == NULL && - (x509_config.trust = sk_ASN1_OBJECT_new_null()) == NULL) + if (cfg.trust == NULL && + (cfg.trust = sk_ASN1_OBJECT_new_null()) == NULL) return (1); - if (!sk_ASN1_OBJECT_push(x509_config.trust, x509_config.objtmp)) + if (!sk_ASN1_OBJECT_push(cfg.trust, cfg.objtmp)) return (1); - x509_config.trustout = 1; + cfg.trustout = 1; return (0); } static int x509_opt_ca(char *arg) { - x509_config.CAfile = arg; - x509_config.CA_flag = ++x509_config.num; + cfg.CAfile = arg; + cfg.CA_flag = ++cfg.num; return (0); } static int x509_opt_certopt(char *arg) { - if (!set_cert_ex(&x509_config.certflag, arg)) + if (!set_cert_ex(&cfg.certflag, arg)) return (1); return (0); @@ -214,20 +214,20 @@ x509_opt_checkend(char *arg) { const char *errstr; - x509_config.checkoffset = strtonum(arg, 0, INT_MAX, &errstr); + cfg.checkoffset = strtonum(arg, 0, INT_MAX, &errstr); if (errstr != NULL) { BIO_printf(bio_err, "checkend unusable: %s\n", errstr); return (1); } - x509_config.checkend = 1; + cfg.checkend = 1; return (0); } static int x509_opt_dates(void) { - x509_config.startdate = ++x509_config.num; - x509_config.enddate = ++x509_config.num; + cfg.startdate = ++cfg.num; + cfg.enddate = ++cfg.num; return (0); } @@ -236,7 +236,7 @@ x509_opt_days(char *arg) { const char *errstr; - x509_config.days = strtonum(arg, 1, INT_MAX, &errstr); + cfg.days = strtonum(arg, 1, INT_MAX, &errstr); if (errstr != NULL) { BIO_printf(bio_err, "bad number of days: %s\n", errstr); return (1); @@ -252,11 +252,11 @@ x509_opt_digest(int argc, char **argv, int *argsused) if (*name++ != '-') return (1); - if ((x509_config.md_alg = EVP_get_digestbyname(name)) != NULL) { - x509_config.digest = x509_config.md_alg; + if ((cfg.md_alg = EVP_get_digestbyname(name)) != NULL) { + cfg.digest = cfg.md_alg; } else { BIO_printf(bio_err, "unknown option %s\n", *argv); - x509_config.badops = 1; + cfg.badops = 1; return (1); } @@ -267,7 +267,7 @@ x509_opt_digest(int argc, char **argv, int *argsused) static int x509_opt_nameopt(char *arg) { - if (!set_name_ex(&x509_config.nmflag, arg)) + if (!set_name_ex(&cfg.nmflag, arg)) return (1); return (0); @@ -276,8 +276,8 @@ x509_opt_nameopt(char *arg) static int x509_opt_set_serial(char *arg) { - ASN1_INTEGER_free(x509_config.sno); - if ((x509_config.sno = s2i_ASN1_INTEGER(NULL, arg)) == NULL) + ASN1_INTEGER_free(cfg.sno); + if ((cfg.sno = s2i_ASN1_INTEGER(NULL, arg)) == NULL) return (1); return (0); @@ -286,27 +286,27 @@ x509_opt_set_serial(char *arg) static int x509_opt_setalias(char *arg) { - x509_config.alias = arg; - x509_config.trustout = 1; + cfg.alias = arg; + cfg.trustout = 1; return (0); } static int x509_opt_signkey(char *arg) { - x509_config.keyfile = arg; - x509_config.sign_flag = ++x509_config.num; + cfg.keyfile = arg; + cfg.sign_flag = ++cfg.num; return (0); } static int x509_opt_sigopt(char *arg) { - if (x509_config.sigopts == NULL && - (x509_config.sigopts = sk_OPENSSL_STRING_new_null()) == NULL) + if (cfg.sigopts == NULL && + (cfg.sigopts = sk_OPENSSL_STRING_new_null()) == NULL) return (1); - if (!sk_OPENSSL_STRING_push(x509_config.sigopts, arg)) + if (!sk_OPENSSL_STRING_push(cfg.sigopts, arg)) return (1); return (0); @@ -317,8 +317,8 @@ static const struct option x509_options[] = { .name = "C", .desc = "Convert the certificate into C code", .type = OPTION_ORDER, - .opt.order = &x509_config.C, - .order = &x509_config.num, + .opt.order = &cfg.C, + .order = &cfg.num, }, { .name = "addreject", @@ -338,8 +338,8 @@ static const struct option x509_options[] = { .name = "alias", .desc = "Output certificate alias", .type = OPTION_ORDER, - .opt.order = &x509_config.aliasout, - .order = &x509_config.num, + .opt.order = &cfg.aliasout, + .order = &cfg.num, }, { .name = "CA", @@ -352,15 +352,15 @@ static const struct option x509_options[] = { .name = "CAcreateserial", .desc = "Create serial number file if it does not exist", .type = OPTION_ORDER, - .opt.order = &x509_config.CA_createserial, - .order = &x509_config.num, + .opt.order = &cfg.CA_createserial, + .order = &cfg.num, }, { .name = "CAform", .argname = "fmt", .desc = "CA format - default PEM", .type = OPTION_ARG_FORMAT, - .opt.value = &x509_config.CAformat, + .opt.value = &cfg.CAformat, }, { .name = "CAkey", @@ -368,21 +368,21 @@ static const struct option x509_options[] = { .desc = "CA key in PEM format unless -CAkeyform is specified\n" "if omitted, the key is assumed to be in the CA file", .type = OPTION_ARG, - .opt.arg = &x509_config.CAkeyfile, + .opt.arg = &cfg.CAkeyfile, }, { .name = "CAkeyform", .argname = "fmt", .desc = "CA key format - default PEM", .type = OPTION_ARG_FORMAT, - .opt.value = &x509_config.CAkeyformat, + .opt.value = &cfg.CAkeyformat, }, { .name = "CAserial", .argname = "file", .desc = "Serial file", .type = OPTION_ARG, - .opt.arg = &x509_config.CAserial, + .opt.arg = &cfg.CAserial, }, { .name = "certopt", @@ -403,21 +403,21 @@ static const struct option x509_options[] = { .name = "clrext", .desc = "Clear all extensions", .type = OPTION_FLAG, - .opt.flag = &x509_config.clrext, + .opt.flag = &cfg.clrext, }, { .name = "clrreject", .desc = "Clear all rejected purposes", .type = OPTION_ORDER, - .opt.order = &x509_config.clrreject, - .order = &x509_config.num, + .opt.order = &cfg.clrreject, + .order = &cfg.num, }, { .name = "clrtrust", .desc = "Clear all trusted purposes", .type = OPTION_ORDER, - .opt.order = &x509_config.clrtrust, - .order = &x509_config.num, + .opt.order = &cfg.clrtrust, + .order = &cfg.num, }, { .name = "dates", @@ -436,79 +436,79 @@ static const struct option x509_options[] = { .name = "email", .desc = "Print email address(es)", .type = OPTION_ORDER, - .opt.order = &x509_config.email, - .order = &x509_config.num, + .opt.order = &cfg.email, + .order = &cfg.num, }, { .name = "enddate", .desc = "Print notAfter field", .type = OPTION_ORDER, - .opt.order = &x509_config.enddate, - .order = &x509_config.num, + .opt.order = &cfg.enddate, + .order = &cfg.num, }, { .name = "extensions", .argname = "section", .desc = "Section from config file with X509V3 extensions to add", .type = OPTION_ARG, - .opt.arg = &x509_config.extsect, + .opt.arg = &cfg.extsect, }, { .name = "extfile", .argname = "file", .desc = "Configuration file with X509V3 extensions to add", .type = OPTION_ARG, - .opt.arg = &x509_config.extfile, + .opt.arg = &cfg.extfile, }, { .name = "fingerprint", .desc = "Print the certificate fingerprint", .type = OPTION_ORDER, - .opt.order = &x509_config.fingerprint, - .order = &x509_config.num, + .opt.order = &cfg.fingerprint, + .order = &cfg.num, }, { .name = "hash", .desc = "Synonym for -subject_hash", .type = OPTION_ORDER, - .opt.order = &x509_config.subject_hash, - .order = &x509_config.num, + .opt.order = &cfg.subject_hash, + .order = &cfg.num, }, { .name = "in", .argname = "file", .desc = "Input file - default stdin", .type = OPTION_ARG, - .opt.arg = &x509_config.infile, + .opt.arg = &cfg.infile, }, { .name = "inform", .argname = "fmt", .desc = "Input format - default PEM (one of DER, NET or PEM)", .type = OPTION_ARG_FORMAT, - .opt.value = &x509_config.informat, + .opt.value = &cfg.informat, }, { .name = "issuer", .desc = "Print issuer name", .type = OPTION_ORDER, - .opt.order = &x509_config.issuer, - .order = &x509_config.num, + .opt.order = &cfg.issuer, + .order = &cfg.num, }, { .name = "issuer_hash", .desc = "Print issuer hash value", .type = OPTION_ORDER, - .opt.order = &x509_config.issuer_hash, - .order = &x509_config.num, + .opt.order = &cfg.issuer_hash, + .order = &cfg.num, }, #ifndef OPENSSL_NO_MD5 { .name = "issuer_hash_old", .desc = "Print old-style (MD5) issuer hash value", .type = OPTION_ORDER, - .opt.order = &x509_config.issuer_hash_old, - .order = &x509_config.num, + .opt.order = &cfg.issuer_hash_old, + .order = &cfg.num, }, #endif { @@ -516,14 +516,14 @@ static const struct option x509_options[] = { .argname = "fmt", .desc = "Private key format - default PEM", .type = OPTION_ARG_FORMAT, - .opt.value = &x509_config.keyformat, + .opt.value = &cfg.keyformat, }, { .name = "modulus", .desc = "Print the RSA key modulus", .type = OPTION_ORDER, - .opt.order = &x509_config.modulus, - .order = &x509_config.num, + .opt.order = &cfg.modulus, + .order = &cfg.num, }, { .name = "nameopt", @@ -536,77 +536,77 @@ static const struct option x509_options[] = { .name = "next_serial", .desc = "Print the next serial number", .type = OPTION_ORDER, - .opt.order = &x509_config.next_serial, - .order = &x509_config.num, + .opt.order = &cfg.next_serial, + .order = &cfg.num, }, { .name = "noout", .desc = "No certificate output", .type = OPTION_ORDER, - .opt.order = &x509_config.noout, - .order = &x509_config.num, + .opt.order = &cfg.noout, + .order = &cfg.num, }, { .name = "ocsp_uri", .desc = "Print OCSP Responder URL(s)", .type = OPTION_ORDER, - .opt.order = &x509_config.ocsp_uri, - .order = &x509_config.num, + .opt.order = &cfg.ocsp_uri, + .order = &cfg.num, }, { .name = "ocspid", .desc = "Print OCSP hash values for the subject name and public key", .type = OPTION_ORDER, - .opt.order = &x509_config.ocspid, - .order = &x509_config.num, + .opt.order = &cfg.ocspid, + .order = &cfg.num, }, { .name = "out", .argname = "file", .desc = "Output file - default stdout", .type = OPTION_ARG, - .opt.arg = &x509_config.outfile, + .opt.arg = &cfg.outfile, }, { .name = "outform", .argname = "fmt", .desc = "Output format - default PEM (one of DER, NET or PEM)", .type = OPTION_ARG_FORMAT, - .opt.value = &x509_config.outformat, + .opt.value = &cfg.outformat, }, { .name = "passin", .argname = "src", .desc = "Private key password source", .type = OPTION_ARG, - .opt.arg = &x509_config.passargin, + .opt.arg = &cfg.passargin, }, { .name = "pubkey", .desc = "Output the public key", .type = OPTION_ORDER, - .opt.order = &x509_config.pubkey, - .order = &x509_config.num, + .opt.order = &cfg.pubkey, + .order = &cfg.num, }, { .name = "purpose", .desc = "Print out certificate purposes", .type = OPTION_ORDER, - .opt.order = &x509_config.pprint, - .order = &x509_config.num, + .opt.order = &cfg.pprint, + .order = &cfg.num, }, { .name = "req", .desc = "Input is a certificate request, sign and output", .type = OPTION_FLAG, - .opt.flag = &x509_config.reqfile, + .opt.flag = &cfg.reqfile, }, { .name = "serial", .desc = "Print serial number value", .type = OPTION_ORDER, - .opt.order = &x509_config.serial, - .order = &x509_config.num, + .opt.order = &cfg.serial, + .order = &cfg.num, }, { .name = "set_serial", @@ -640,51 +640,51 @@ static const struct option x509_options[] = { .name = "startdate", .desc = "Print notBefore field", .type = OPTION_ORDER, - .opt.order = &x509_config.startdate, - .order = &x509_config.num, + .opt.order = &cfg.startdate, + .order = &cfg.num, }, { .name = "subject", .desc = "Print subject name", .type = OPTION_ORDER, - .opt.order = &x509_config.subject, - .order = &x509_config.num, + .opt.order = &cfg.subject, + .order = &cfg.num, }, { .name = "subject_hash", .desc = "Print subject hash value", .type = OPTION_ORDER, - .opt.order = &x509_config.subject_hash, - .order = &x509_config.num, + .opt.order = &cfg.subject_hash, + .order = &cfg.num, }, #ifndef OPENSSL_NO_MD5 { .name = "subject_hash_old", .desc = "Print old-style (MD5) subject hash value", .type = OPTION_ORDER, - .opt.order = &x509_config.subject_hash_old, - .order = &x509_config.num, + .opt.order = &cfg.subject_hash_old, + .order = &cfg.num, }, #endif { .name = "text", .desc = "Print the certificate in text form", .type = OPTION_ORDER, - .opt.order = &x509_config.text, - .order = &x509_config.num, + .opt.order = &cfg.text, + .order = &cfg.num, }, { .name = "trustout", .desc = "Output a trusted certificate", .type = OPTION_FLAG, - .opt.flag = &x509_config.trustout, + .opt.flag = &cfg.trustout, }, { .name = "x509toreq", .desc = "Output a certification request object", .type = OPTION_ORDER, - .opt.order = &x509_config.x509req, - .order = &x509_config.num, + .opt.order = &cfg.x509req, + .order = &cfg.num, }, { .name = NULL, @@ -735,20 +735,18 @@ x509_main(int argc, char **argv) CONF *extconf = NULL; char *passin = NULL; - if (single_execution) { - if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { - perror("pledge"); - exit(1); - } + if (pledge("stdio cpath wpath rpath tty", NULL) == -1) { + perror("pledge"); + exit(1); } - memset(&x509_config, 0, sizeof(x509_config)); - x509_config.days = DEF_DAYS; - x509_config.informat = FORMAT_PEM; - x509_config.outformat = FORMAT_PEM; - x509_config.keyformat = FORMAT_PEM; - x509_config.CAformat = FORMAT_PEM; - x509_config.CAkeyformat = FORMAT_PEM; + memset(&cfg, 0, sizeof(cfg)); + cfg.days = DEF_DAYS; + cfg.informat = FORMAT_PEM; + cfg.outformat = FORMAT_PEM; + cfg.keyformat = FORMAT_PEM; + cfg.CAformat = FORMAT_PEM; + cfg.CAkeyformat = FORMAT_PEM; STDout = BIO_new_fp(stdout, BIO_NOCLOSE); @@ -760,13 +758,13 @@ x509_main(int argc, char **argv) if (options_parse(argc, argv, x509_options, NULL, NULL) != 0) goto bad; - if (x509_config.badops) { + if (cfg.badops) { bad: x509_usage(); goto end; } - if (!app_passwd(bio_err, x509_config.passargin, NULL, &passin, NULL)) { + if (!app_passwd(bio_err, cfg.passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } @@ -774,53 +772,53 @@ x509_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if ((x509_config.CAkeyfile == NULL) && (x509_config.CA_flag) && - (x509_config.CAformat == FORMAT_PEM)) { - x509_config.CAkeyfile = x509_config.CAfile; - } else if ((x509_config.CA_flag) && (x509_config.CAkeyfile == NULL)) { + if ((cfg.CAkeyfile == NULL) && (cfg.CA_flag) && + (cfg.CAformat == FORMAT_PEM)) { + cfg.CAkeyfile = cfg.CAfile; + } else if ((cfg.CA_flag) && (cfg.CAkeyfile == NULL)) { BIO_printf(bio_err, "need to specify a CAkey if using the CA command\n"); goto end; } - if (x509_config.extfile != NULL) { + if (cfg.extfile != NULL) { long errorline = -1; X509V3_CTX ctx2; extconf = NCONF_new(NULL); - if (!NCONF_load(extconf, x509_config.extfile, &errorline)) { + if (!NCONF_load(extconf, cfg.extfile, &errorline)) { if (errorline <= 0) BIO_printf(bio_err, "error loading the config file '%s'\n", - x509_config.extfile); + cfg.extfile); else BIO_printf(bio_err, "error on line %ld of config file '%s'\n", - errorline, x509_config.extfile); + errorline, cfg.extfile); goto end; } - if (x509_config.extsect == NULL) { - x509_config.extsect = NCONF_get_string(extconf, + if (cfg.extsect == NULL) { + cfg.extsect = NCONF_get_string(extconf, "default", "extensions"); - if (x509_config.extsect == NULL) { + if (cfg.extsect == NULL) { ERR_clear_error(); - x509_config.extsect = "default"; + cfg.extsect = "default"; } } X509V3_set_ctx_test(&ctx2); X509V3_set_nconf(&ctx2, extconf); - if (!X509V3_EXT_add_nconf(extconf, &ctx2, x509_config.extsect, + if (!X509V3_EXT_add_nconf(extconf, &ctx2, cfg.extsect, NULL)) { BIO_printf(bio_err, "Error Loading extension section %s\n", - x509_config.extsect); + cfg.extsect); ERR_print_errors(bio_err); goto end; } } - if (x509_config.reqfile) { + if (cfg.reqfile) { EVP_PKEY *pkey; BIO *in; - if (!x509_config.sign_flag && !x509_config.CA_flag) { + if (!cfg.sign_flag && !cfg.CA_flag) { BIO_printf(bio_err, "We need a private key to sign with\n"); goto end; @@ -830,11 +828,11 @@ x509_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (x509_config.infile == NULL) + if (cfg.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE | BIO_FP_TEXT); else { - if (BIO_read_filename(in, x509_config.infile) <= 0) { - perror(x509_config.infile); + if (BIO_read_filename(in, cfg.infile) <= 0) { + perror(cfg.infile); BIO_free(in); goto end; } @@ -864,21 +862,21 @@ x509_main(int argc, char **argv) BIO_printf(bio_err, "Signature ok\n"); print_name(bio_err, "subject=", X509_REQ_get_subject_name(req), - x509_config.nmflag); + cfg.nmflag); if ((x = X509_new()) == NULL) goto end; - if (x509_config.sno == NULL) { - x509_config.sno = ASN1_INTEGER_new(); - if (x509_config.sno == NULL || - !rand_serial(NULL, x509_config.sno)) + if (cfg.sno == NULL) { + cfg.sno = ASN1_INTEGER_new(); + if (cfg.sno == NULL || + !rand_serial(NULL, cfg.sno)) goto end; - if (!X509_set_serialNumber(x, x509_config.sno)) + if (!X509_set_serialNumber(x, cfg.sno)) goto end; - ASN1_INTEGER_free(x509_config.sno); - x509_config.sno = NULL; - } else if (!X509_set_serialNumber(x, x509_config.sno)) + ASN1_INTEGER_free(cfg.sno); + cfg.sno = NULL; + } else if (!X509_set_serialNumber(x, cfg.sno)) goto end; if (!X509_set_issuer_name(x, X509_REQ_get_subject_name(req))) @@ -888,7 +886,7 @@ x509_main(int argc, char **argv) if (X509_gmtime_adj(X509_get_notBefore(x), 0) == NULL) goto end; - if (X509_time_adj_ex(X509_get_notAfter(x), x509_config.days, 0, + if (X509_time_adj_ex(X509_get_notAfter(x), cfg.days, 0, NULL) == NULL) goto end; @@ -899,19 +897,19 @@ x509_main(int argc, char **argv) goto end; } } else { - x = load_cert(bio_err, x509_config.infile, x509_config.informat, + x = load_cert(bio_err, cfg.infile, cfg.informat, NULL, "Certificate"); } if (x == NULL) goto end; - if (x509_config.CA_flag) { - xca = load_cert(bio_err, x509_config.CAfile, - x509_config.CAformat, NULL, "CA Certificate"); + if (cfg.CA_flag) { + xca = load_cert(bio_err, cfg.CAfile, + cfg.CAformat, NULL, "CA Certificate"); if (xca == NULL) goto end; } - if (!x509_config.noout || x509_config.text || x509_config.next_serial) { + if (!cfg.noout || cfg.text || cfg.next_serial) { OBJ_create("2.99999.3", "SET.ex3", "SET x509v3 extension 3"); out = BIO_new(BIO_s_file()); @@ -919,57 +917,57 @@ x509_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if (x509_config.outfile == NULL) { + if (cfg.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { - if (BIO_write_filename(out, x509_config.outfile) <= 0) { - perror(x509_config.outfile); + if (BIO_write_filename(out, cfg.outfile) <= 0) { + perror(cfg.outfile); goto end; } } } - if (x509_config.alias != NULL) { - if (!X509_alias_set1(x, (unsigned char *)x509_config.alias, -1)) + if (cfg.alias != NULL) { + if (!X509_alias_set1(x, (unsigned char *)cfg.alias, -1)) goto end; } - if (x509_config.clrtrust) + if (cfg.clrtrust) X509_trust_clear(x); - if (x509_config.clrreject) + if (cfg.clrreject) X509_reject_clear(x); - if (x509_config.trust != NULL) { - for (i = 0; i < sk_ASN1_OBJECT_num(x509_config.trust); i++) { - x509_config.objtmp = sk_ASN1_OBJECT_value( - x509_config.trust, i); - if (!X509_add1_trust_object(x, x509_config.objtmp)) + if (cfg.trust != NULL) { + for (i = 0; i < sk_ASN1_OBJECT_num(cfg.trust); i++) { + cfg.objtmp = sk_ASN1_OBJECT_value( + cfg.trust, i); + if (!X509_add1_trust_object(x, cfg.objtmp)) goto end; } } - if (x509_config.reject != NULL) { - for (i = 0; i < sk_ASN1_OBJECT_num(x509_config.reject); i++) { - x509_config.objtmp = sk_ASN1_OBJECT_value( - x509_config.reject, i); - if (!X509_add1_reject_object(x, x509_config.objtmp)) + if (cfg.reject != NULL) { + for (i = 0; i < sk_ASN1_OBJECT_num(cfg.reject); i++) { + cfg.objtmp = sk_ASN1_OBJECT_value( + cfg.reject, i); + if (!X509_add1_reject_object(x, cfg.objtmp)) goto end; } } - if (x509_config.num) { - for (i = 1; i <= x509_config.num; i++) { - if (x509_config.issuer == i) { + if (cfg.num) { + for (i = 1; i <= cfg.num; i++) { + if (cfg.issuer == i) { print_name(STDout, "issuer= ", X509_get_issuer_name(x), - x509_config.nmflag); - } else if (x509_config.subject == i) { + cfg.nmflag); + } else if (cfg.subject == i) { print_name(STDout, "subject= ", X509_get_subject_name(x), - x509_config.nmflag); - } else if (x509_config.serial == i) { + cfg.nmflag); + } else if (cfg.serial == i) { BIO_printf(STDout, "serial="); i2a_ASN1_INTEGER(STDout, X509_get_serialNumber(x)); BIO_printf(STDout, "\n"); - } else if (x509_config.next_serial == i) { + } else if (cfg.next_serial == i) { BIGNUM *bnser; ASN1_INTEGER *ser; ser = X509_get_serialNumber(x); @@ -991,11 +989,11 @@ x509_main(int argc, char **argv) i2a_ASN1_INTEGER(out, ser); ASN1_INTEGER_free(ser); BIO_puts(out, "\n"); - } else if ((x509_config.email == i) || - (x509_config.ocsp_uri == i)) { + } else if ((cfg.email == i) || + (cfg.ocsp_uri == i)) { int j; STACK_OF(OPENSSL_STRING) *emlst; - if (x509_config.email == i) + if (cfg.email == i) emlst = X509_get1_email(x); else emlst = X509_get1_ocsp(x); @@ -1003,7 +1001,7 @@ x509_main(int argc, char **argv) BIO_printf(STDout, "%s\n", sk_OPENSSL_STRING_value(emlst, j)); X509_email_free(emlst); - } else if (x509_config.aliasout == i) { + } else if (cfg.aliasout == i) { unsigned char *albuf; int buflen; albuf = X509_alias_get0(x, &buflen); @@ -1012,27 +1010,27 @@ x509_main(int argc, char **argv) buflen, albuf); else BIO_puts(STDout, "\n"); - } else if (x509_config.subject_hash == i) { + } else if (cfg.subject_hash == i) { BIO_printf(STDout, "%08lx\n", X509_subject_name_hash(x)); } #ifndef OPENSSL_NO_MD5 - else if (x509_config.subject_hash_old == i) { + else if (cfg.subject_hash_old == i) { BIO_printf(STDout, "%08lx\n", X509_subject_name_hash_old(x)); } #endif - else if (x509_config.issuer_hash == i) { + else if (cfg.issuer_hash == i) { BIO_printf(STDout, "%08lx\n", X509_issuer_name_hash(x)); } #ifndef OPENSSL_NO_MD5 - else if (x509_config.issuer_hash_old == i) { + else if (cfg.issuer_hash_old == i) { BIO_printf(STDout, "%08lx\n", X509_issuer_name_hash_old(x)); } #endif - else if (x509_config.pprint == i) { + else if (cfg.pprint == i) { X509_PURPOSE *ptmp; int j; BIO_printf(STDout, "Certificate purposes:\n"); @@ -1040,7 +1038,7 @@ x509_main(int argc, char **argv) ptmp = X509_PURPOSE_get0(j); purpose_print(STDout, x, ptmp); } - } else if (x509_config.modulus == i) { + } else if (cfg.modulus == i) { EVP_PKEY *pkey; pkey = X509_get0_pubkey(x); @@ -1068,7 +1066,7 @@ x509_main(int argc, char **argv) BIO_printf(STDout, "Wrong Algorithm type"); BIO_printf(STDout, "\n"); - } else if (x509_config.pubkey == i) { + } else if (cfg.pubkey == i) { EVP_PKEY *pkey; pkey = X509_get0_pubkey(x); @@ -1079,7 +1077,7 @@ x509_main(int argc, char **argv) goto end; } PEM_write_bio_PUBKEY(STDout, pkey); - } else if (x509_config.C == i) { + } else if (cfg.C == i) { unsigned char *d; char *m; int y, z; @@ -1158,11 +1156,11 @@ x509_main(int argc, char **argv) BIO_printf(STDout, "};\n"); free(m); - } else if (x509_config.text == i) { - if(!X509_print_ex(STDout, x, x509_config.nmflag, - x509_config.certflag)) + } else if (cfg.text == i) { + if(!X509_print_ex(STDout, x, cfg.nmflag, + cfg.certflag)) goto end; - } else if (x509_config.startdate == i) { + } else if (cfg.startdate == i) { ASN1_TIME *nB = X509_get_notBefore(x); BIO_puts(STDout, "notBefore="); if (ASN1_time_parse(nB->data, nB->length, NULL, @@ -1172,7 +1170,7 @@ x509_main(int argc, char **argv) else ASN1_TIME_print(STDout, nB); BIO_puts(STDout, "\n"); - } else if (x509_config.enddate == i) { + } else if (cfg.enddate == i) { ASN1_TIME *nA = X509_get_notAfter(x); BIO_puts(STDout, "notAfter="); if (ASN1_time_parse(nA->data, nA->length, NULL, @@ -1182,11 +1180,11 @@ x509_main(int argc, char **argv) else ASN1_TIME_print(STDout, nA); BIO_puts(STDout, "\n"); - } else if (x509_config.fingerprint == i) { + } else if (cfg.fingerprint == i) { int j; unsigned int n; unsigned char md[EVP_MAX_MD_SIZE]; - const EVP_MD *fdig = x509_config.digest; + const EVP_MD *fdig = cfg.digest; if (fdig == NULL) fdig = EVP_sha256(); @@ -1203,52 +1201,52 @@ x509_main(int argc, char **argv) } /* should be in the library */ - } else if ((x509_config.sign_flag == i) && - (x509_config.x509req == 0)) { + } else if ((cfg.sign_flag == i) && + (cfg.x509req == 0)) { BIO_printf(bio_err, "Getting Private key\n"); if (Upkey == NULL) { Upkey = load_key(bio_err, - x509_config.keyfile, - x509_config.keyformat, 0, passin, + cfg.keyfile, + cfg.keyformat, 0, passin, "Private key"); if (Upkey == NULL) goto end; } - if (!sign(x, Upkey, x509_config.days, - x509_config.clrext, x509_config.digest, - extconf, x509_config.extsect)) + if (!sign(x, Upkey, cfg.days, + cfg.clrext, cfg.digest, + extconf, cfg.extsect)) goto end; - } else if (x509_config.CA_flag == i) { + } else if (cfg.CA_flag == i) { BIO_printf(bio_err, "Getting CA Private Key\n"); - if (x509_config.CAkeyfile != NULL) { + if (cfg.CAkeyfile != NULL) { CApkey = load_key(bio_err, - x509_config.CAkeyfile, - x509_config.CAkeyformat, 0, passin, + cfg.CAkeyfile, + cfg.CAkeyformat, 0, passin, "CA Private Key"); if (CApkey == NULL) goto end; } - if (!x509_certify(ctx, x509_config.CAfile, - x509_config.digest, x, xca, CApkey, - x509_config.sigopts, x509_config.CAserial, - x509_config.CA_createserial, - x509_config.days, x509_config.clrext, - extconf, x509_config.extsect, - x509_config.sno)) + if (!x509_certify(ctx, cfg.CAfile, + cfg.digest, x, xca, CApkey, + cfg.sigopts, cfg.CAserial, + cfg.CA_createserial, + cfg.days, cfg.clrext, + extconf, cfg.extsect, + cfg.sno)) goto end; - } else if (x509_config.x509req == i) { + } else if (cfg.x509req == i) { EVP_PKEY *pk; BIO_printf(bio_err, "Getting request Private Key\n"); - if (x509_config.keyfile == NULL) { + if (cfg.keyfile == NULL) { BIO_printf(bio_err, "no request key file specified\n"); goto end; } else { pk = load_key(bio_err, - x509_config.keyfile, - x509_config.keyformat, 0, passin, + cfg.keyfile, + cfg.keyformat, 0, passin, "request key"); if (pk == NULL) goto end; @@ -1257,27 +1255,27 @@ x509_main(int argc, char **argv) BIO_printf(bio_err, "Generating certificate request\n"); - rq = X509_to_X509_REQ(x, pk, x509_config.digest); + rq = X509_to_X509_REQ(x, pk, cfg.digest); EVP_PKEY_free(pk); if (rq == NULL) { ERR_print_errors(bio_err); goto end; } - if (!x509_config.noout) { + if (!cfg.noout) { if (!X509_REQ_print(out, rq)) goto end; if (!PEM_write_bio_X509_REQ(out, rq)) goto end; } - x509_config.noout = 1; - } else if (x509_config.ocspid == i) { + cfg.noout = 1; + } else if (cfg.ocspid == i) { if (!X509_ocspid_print(out, x)) goto end; } } } - if (x509_config.checkend) { - time_t tcheck = time(NULL) + x509_config.checkoffset; + if (cfg.checkend) { + time_t tcheck = time(NULL) + cfg.checkoffset; int timecheck = X509_cmp_time(X509_get_notAfter(x), &tcheck); if (timecheck == 0) { BIO_printf(out, "Certificate expiry time is invalid\n"); @@ -1291,14 +1289,14 @@ x509_main(int argc, char **argv) } goto end; } - if (x509_config.noout) { + if (cfg.noout) { ret = 0; goto end; } - if (x509_config.outformat == FORMAT_ASN1) + if (cfg.outformat == FORMAT_ASN1) i = i2d_X509_bio(out, x); - else if (x509_config.outformat == FORMAT_PEM) { - if (x509_config.trustout) + else if (cfg.outformat == FORMAT_PEM) { + if (cfg.trustout) i = PEM_write_bio_X509_AUX(out, x); else i = PEM_write_bio_X509(out, x); @@ -1325,11 +1323,11 @@ x509_main(int argc, char **argv) X509_free(xca); EVP_PKEY_free(Upkey); EVP_PKEY_free(CApkey); - sk_OPENSSL_STRING_free(x509_config.sigopts); + sk_OPENSSL_STRING_free(cfg.sigopts); X509_REQ_free(rq); - ASN1_INTEGER_free(x509_config.sno); - sk_ASN1_OBJECT_pop_free(x509_config.trust, ASN1_OBJECT_free); - sk_ASN1_OBJECT_pop_free(x509_config.reject, ASN1_OBJECT_free); + ASN1_INTEGER_free(cfg.sno); + sk_ASN1_OBJECT_pop_free(cfg.trust, ASN1_OBJECT_free); + sk_ASN1_OBJECT_pop_free(cfg.reject, ASN1_OBJECT_free); free(passin); return (ret); @@ -1414,7 +1412,7 @@ x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest, X509 *x, */ X509_STORE_CTX_set_cert(xsc, x); X509_STORE_CTX_set_flags(xsc, X509_V_FLAG_CHECK_SS_SIGNATURE); - if (!x509_config.reqfile && X509_verify_cert(xsc) <= 0) + if (!cfg.reqfile && X509_verify_cert(xsc) <= 0) goto end; if (!X509_check_private_key(xca, pkey)) { diff --git a/config.guess b/config.guess index b82ee231..980b0208 100644 --- a/config.guess +++ b/config.guess @@ -1,12 +1,14 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2022 Free Software Foundation, Inc. -timestamp='2015-12-14' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2022-09-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -15,7 +17,7 @@ timestamp='2015-12-14' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,11 +29,19 @@ timestamp='2015-12-14' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to . +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -39,7 +49,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +60,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,7 +94,8 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 +# Just in case it came from the environment. +GUESS= # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires @@ -96,66 +107,90 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039,SC3028 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD=$driver + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case $UNAME_SYSTEM in Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu + LIBC=unknown - eval $set_cc_for_build - cat <<-EOF > $dummy.c + set_cc_for_build + cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc - #else + #elif defined(__GLIBC__) LIBC=gnu + #else + #include + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$cc_set_libc" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -167,29 +202,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case $UNAME_MACHINE_ARCH in + aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + *) machine=$UNAME_MACHINE_ARCH-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + # to ELF recently (or will in the future) and ABI. + case $UNAME_MACHINE_ARCH in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -205,10 +243,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in + case $UNAME_MACHINE_ARCH in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -216,43 +254,68 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case $UNAME_VERSION in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" - exit ;; + GUESS=$machine-${os}${release}${abi-} + ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE + ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE + ;; + *:SecBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE + ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE + ;; + *:MidnightBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE + ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE + ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE + ;; + *:OS108:*:*) + GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE + ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; + GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE + ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE + ;; *:Sortix:*:*) - echo ${UNAME_MACHINE}-unknown-sortix - exit ;; + GUESS=$UNAME_MACHINE-unknown-sortix + ;; + *:Twizzler:*:*) + GUESS=$UNAME_MACHINE-unknown-twizzler + ;; + *:Redox:*:*) + GUESS=$UNAME_MACHINE-unknown-redox + ;; + mips:OSF1:*.*) + GUESS=mips-dec-osf1 + ;; alpha:OSF1:*:*) + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + trap '' 0 case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` @@ -266,163 +329,158 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in + case $ALPHA_CPU_TYPE in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; + OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + GUESS=$UNAME_MACHINE-dec-osf$OSF_REL + ;; Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; + GUESS=m68k-unknown-sysv4 + ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; + GUESS=$UNAME_MACHINE-unknown-amigaos + ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; + GUESS=$UNAME_MACHINE-unknown-morphos + ;; *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; + GUESS=i370-ibm-openedition + ;; *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; + GUESS=s390-ibm-zvmoe + ;; *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; + GUESS=powerpc-ibm-os400 + ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; + GUESS=arm-acorn-riscix$UNAME_RELEASE + ;; arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; + GUESS=arm-unknown-riscos + ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; + GUESS=hppa1.1-hitachi-hiuxmpp + ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; + case `(/bin/universe) 2>/dev/null` in + att) GUESS=pyramid-pyramid-sysv3 ;; + *) GUESS=pyramid-pyramid-bsd ;; + esac + ;; NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; + GUESS=pyramid-pyramid-svr4 + ;; DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; + GUESS=sparc-icl-nx6 + ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; + sparc) GUESS=sparc-icl-nx7 ;; + esac + ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL + ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-hal-solaris2$SUN_REL + ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris2$SUN_REL + ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; + GUESS=i386-pc-auroraux$UNAME_RELEASE + ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" + set_cc_for_build + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$SUN_ARCH-pc-solaris2$SUN_REL + ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris3$SUN_REL + ;; sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in + case `/usr/bin/arch -k` in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` + GUESS=sparc-sun-sunos$SUN_REL + ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case `/bin/arch` in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + GUESS=sparc-sun-sunos$UNAME_RELEASE ;; esac - exit ;; + ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; + GUESS=sparc-auspex-sunos$UNAME_RELEASE + ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -432,44 +490,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-milan-mint$UNAME_RELEASE + ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-hades-mint$UNAME_RELEASE + ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-unknown-mint$UNAME_RELEASE + ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; + GUESS=m68k-apple-machten$UNAME_RELEASE + ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; + GUESS=powerpc-apple-machten$UNAME_RELEASE + ;; RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; + GUESS=mips-dec-mach_bsd4.3 + ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; + GUESS=mips-dec-ultrix$UNAME_RELEASE + ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; + GUESS=vax-dec-ultrix$UNAME_RELEASE + ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; + GUESS=clipper-intergraph-clix$UNAME_RELEASE + ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -478,95 +536,96 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; + GUESS=mips-mips-riscos$UNAME_RELEASE + ;; Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; + GUESS=powerpc-motorola-powermax + ;; Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; + GUESS=powerpc-harris-powerunix + ;; m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; + GUESS=m88k-harris-cxux7 + ;; m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; + GUESS=m88k-motorola-sysv4 + ;; m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x then - echo m88k-dg-dgux${UNAME_RELEASE} + GUESS=m88k-dg-dgux$UNAME_RELEASE else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + GUESS=m88k-dg-dguxbcs$UNAME_RELEASE fi else - echo i586-dg-dgux${UNAME_RELEASE} + GUESS=i586-dg-dgux$UNAME_RELEASE fi - exit ;; + ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; + GUESS=m88k-dolphin-sysv3 + ;; M88*:*:R3*:*) # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; + GUESS=m88k-tektronix-sysv3 + ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; + GUESS=m68k-tektronix-bsd + ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; + IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` + GUESS=mips-sgi-irix$IRIX_REL + ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id + ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; + GUESS=i386-ibm-aix + ;; ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then + if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; + GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV + ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -577,77 +636,77 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then - echo "$SYSTEM_NAME" + GUESS=$SYSTEM_NAME else - echo rs6000-ibm-aix3.2.5 + GUESS=rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 + GUESS=rs6000-ibm-aix3.2.4 else - echo rs6000-ibm-aix3.2 + GUESS=rs6000-ibm-aix3.2 fi - exit ;; + ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + if test -x /usr/bin/lslpp ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; + GUESS=$IBM_ARCH-ibm-aix$IBM_REV + ;; *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; + GUESS=rs6000-ibm-aix + ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + GUESS=romp-ibm-bsd4.4 + ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 + GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to + ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; + GUESS=rs6000-bull-bosx + ;; DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; + GUESS=m68k-bull-sysv3 + ;; 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; + GUESS=m68k-hp-bsd + ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; + GUESS=m68k-hp-bsd4.4 + ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + case $UNAME_MACHINE in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then + if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + case $sc_cpu_version in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + case $sc_kernel_bits in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if test "$HP_ARCH" = ""; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include @@ -680,13 +739,13 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if test "$HP_ARCH" = hppa2.0w then - eval $set_cc_for_build + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -697,23 +756,23 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; + GUESS=$HP_ARCH-hp-hpux$HPUX_REV + ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + GUESS=ia64-hp-hpux$HPUX_REV + ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -738,38 +797,38 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; + GUESS=unknown-hitachi-hiuxwe2 + ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + GUESS=hppa1.1-hp-bsd + ;; 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; + GUESS=hppa1.0-hp-bsd + ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; + GUESS=hppa1.0-hp-mpeix + ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + GUESS=hppa1.1-hp-osf + ;; hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; + GUESS=hppa1.0-hp-osf + ;; i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + if test -x /usr/sbin/sysversion ; then + GUESS=$UNAME_MACHINE-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + GUESS=$UNAME_MACHINE-unknown-osf1 fi - exit ;; + ;; parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; + GUESS=hppa1.1-hp-lites + ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; + GUESS=c1-convex-bsd + ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd @@ -777,139 +836,154 @@ EOF fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; + GUESS=c34-convex-bsd + ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; + GUESS=c38-convex-bsd + ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; + GUESS=c4-convex-bsd + ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=ymp-cray-unicos$CRAY_REL + ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=t90-cray-unicos$CRAY_REL + ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=alphaev5-cray-unicosmk$CRAY_REL + ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=sv1-cray-unicos$CRAY_REL + ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=craynv-cray-unicosmp$CRAY_REL + ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE + ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; + GUESS=sparc-unknown-bsdi$UNAME_RELEASE + ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE + ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi + else + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf + fi + ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case $UNAME_PROCESSOR in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac - exit ;; + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL + ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; + GUESS=$UNAME_MACHINE-pc-cygwin + ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw64 + ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw32 + ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-msys + ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-pw32 + ;; + *:SerenityOS:*:*) + GUESS=$UNAME_MACHINE-pc-serenity + ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case $UNAME_MACHINE in x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; + GUESS=i586-pc-interix$UNAME_RELEASE + ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; + GUESS=x86_64-unknown-interix$UNAME_RELEASE + ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; + GUESS=ia64-unknown-interix$UNAME_RELEASE + ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; + GUESS=$UNAME_MACHINE-pc-uwin + ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; + GUESS=x86_64-pc-cygwin + ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=powerpcle-unknown-solaris2$SUN_REL + ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; + GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` + GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL + ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; + GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC + ;; + x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-pc-managarm-mlibc" + ;; + *:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" + ;; + *:Minix:*:*) + GUESS=$UNAME_MACHINE-unknown-minix + ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -919,178 +993,237 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; arm*:Linux:*:*) - eval $set_cc_for_build + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf fi fi - exit ;; + ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; e2k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-pc-linux-$LIBC + ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; k1om:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` + eval "$cc_set_vars" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } + ;; + mips64el:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} - exit ;; + GUESS=or1k-unknown-linux-$LIBC + ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; + GUESS=sparc-unknown-linux-$LIBC + ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - exit ;; + GUESS=hppa64-unknown-linux-$LIBC + ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; + PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; + *) GUESS=hppa-unknown-linux-$LIBC ;; esac - exit ;; + ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; + GUESS=powerpc64-unknown-linux-$LIBC + ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; + GUESS=powerpc-unknown-linux-$LIBC + ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} - exit ;; + GUESS=powerpc64le-unknown-linux-$LIBC + ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} - exit ;; + GUESS=powerpcle-unknown-linux-$LIBC + ;; + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-ibm-linux-$LIBC + ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-dec-linux-$LIBC + ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __i386__ + ABI=x86 + #else + #ifdef __ILP32__ + ABI=x32 + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + x86) CPU=i686 ;; + x32) LIBCABI=${LIBC}x32 ;; + esac + fi + GUESS=$CPU-pc-linux-$LIBCABI + ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; + GUESS=i386-sequent-sysv4 + ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; + GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION + ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; + GUESS=$UNAME_MACHINE-pc-os2-emx + ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; + GUESS=$UNAME_MACHINE-unknown-stop + ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; + GUESS=$UNAME_MACHINE-unknown-atheos + ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; + GUESS=$UNAME_MACHINE-pc-syllable + ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=i386-unknown-lynxos$UNAME_RELEASE + ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + GUESS=$UNAME_MACHINE-pc-msdosdjgpp + ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL fi - exit ;; + ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in @@ -1098,12 +1231,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; + GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1113,11 +1246,11 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL else - echo ${UNAME_MACHINE}-pc-sysv32 + GUESS=$UNAME_MACHINE-pc-sysv32 fi - exit ;; + ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -1125,31 +1258,31 @@ EOF # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; + GUESS=i586-pc-msdosdjgpp + ;; Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; + GUESS=i386-pc-mach3 + ;; paragon:*:*:*) - echo i860-intel-osf1 - exit ;; + GUESS=i860-intel-osf1 + ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 fi - exit ;; + ;; mini*:CTIX:SYS*5:*) # "miniframe" - echo m68010-convergent-sysv - exit ;; + GUESS=m68010-convergent-sysv + ;; mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; + GUESS=m68k-convergent-sysv + ;; M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; + GUESS=m68k-diab-dnix + ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) @@ -1157,9 +1290,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1168,251 +1301,444 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=m68k-unknown-lynxos$UNAME_RELEASE + ;; mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; + GUESS=m68k-atari-sysv4 + ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=sparc-unknown-lynxos$UNAME_RELEASE + ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=rs6000-unknown-lynxos$UNAME_RELEASE + ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=powerpc-unknown-lynxos$UNAME_RELEASE + ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; + GUESS=mips-dde-sysv$UNAME_RELEASE + ;; RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + GUESS=$UNAME_MACHINE-sni-sysv4 else - echo ns32k-sni-sysv + GUESS=ns32k-sni-sysv fi - exit ;; + ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says - echo i586-unisys-sysv4 - exit ;; + GUESS=i586-unisys-sysv4 + ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; + GUESS=hppa1.1-stratus-sysv4 + ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; + GUESS=i860-stratus-sysv4 + ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; + GUESS=$UNAME_MACHINE-stratus-vos + ;; *:VOS:*:*) # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; + GUESS=hppa1.1-stratus-vos + ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; + GUESS=m68k-apple-aux$UNAME_RELEASE + ;; news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; + GUESS=mips-sony-newsos6 + ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + if test -d /usr/nec; then + GUESS=mips-nec-sysv$UNAME_RELEASE else - echo mips-unknown-sysv${UNAME_RELEASE} + GUESS=mips-unknown-sysv$UNAME_RELEASE fi - exit ;; + ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; + GUESS=powerpc-be-beos + ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; + GUESS=powerpc-apple-beos + ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; + GUESS=i586-pc-beos + ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; + GUESS=i586-pc-haiku + ;; + ppc:Haiku:*:*) # Haiku running on Apple PowerPC + GUESS=powerpc-apple-haiku + ;; + *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat) + GUESS=$UNAME_MACHINE-unknown-haiku + ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx4-nec-superux$UNAME_RELEASE + ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx5-nec-superux$UNAME_RELEASE + ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx6-nec-superux$UNAME_RELEASE + ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx7-nec-superux$UNAME_RELEASE + ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx8-nec-superux$UNAME_RELEASE + ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx8r-nec-superux$UNAME_RELEASE + ;; + SX-ACE:SUPER-UX:*:*) + GUESS=sxace-nec-superux$UNAME_RELEASE + ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; + GUESS=powerpc-apple-rhapsody$UNAME_RELEASE + ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE + ;; + arm64:Darwin:*:*) + GUESS=aarch64-apple-darwin$UNAME_RELEASE + ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE + ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE + ;; *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; + GUESS=i386-pc-qnx + ;; + NEO-*:NONSTOP_KERNEL:*:*) + GUESS=neo-tandem-nsk$UNAME_RELEASE + ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; + GUESS=nse-tandem-nsk$UNAME_RELEASE + ;; + NSR-*:NONSTOP_KERNEL:*:*) + GUESS=nsr-tandem-nsk$UNAME_RELEASE + ;; + NSV-*:NONSTOP_KERNEL:*:*) + GUESS=nsv-tandem-nsk$UNAME_RELEASE + ;; + NSX-*:NONSTOP_KERNEL:*:*) + GUESS=nsx-tandem-nsk$UNAME_RELEASE + ;; *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; + GUESS=mips-compaq-nonstopux + ;; BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; + GUESS=bs2000-siemens-sysv + ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE + ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "${cputype-}" = 386; then UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" + elif test "x${cputype-}" != x; then + UNAME_MACHINE=$cputype fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; + GUESS=$UNAME_MACHINE-unknown-plan9 + ;; *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; + GUESS=pdp10-unknown-tops10 + ;; *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; + GUESS=pdp10-unknown-tenex + ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; + GUESS=pdp10-dec-tops20 + ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; + GUESS=pdp10-xkl-tops20 + ;; *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; + GUESS=pdp10-unknown-tops20 + ;; *:ITS:*:*) - echo pdp10-unknown-its - exit ;; + GUESS=pdp10-unknown-its + ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; + GUESS=mips-sei-seiux$UNAME_RELEASE + ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; + DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL + ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; + case $UNAME_MACHINE in + A*) GUESS=alpha-dec-vms ;; + I*) GUESS=ia64-dec-vms ;; + V*) GUESS=vax-dec-vms ;; esac ;; *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; + GUESS=i386-pc-xenix + ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; + SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` + GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL + ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; + GUESS=$UNAME_MACHINE-pc-rdos + ;; + i*86:Fiwix:*:*) + GUESS=$UNAME_MACHINE-pc-fiwix + ;; + *:AROS:*:*) + GUESS=$UNAME_MACHINE-unknown-aros + ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; + GUESS=$UNAME_MACHINE-unknown-esx + ;; amd64:Isilon\ OneFS:*:*) - echo x86_64-unknown-onefs - exit ;; + GUESS=x86_64-unknown-onefs + ;; + *:Unleashed:*:*) + GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE + ;; +esac + +# Do we have a guess based on uname results? +if test "x$GUESS" != x; then + echo "$GUESS" + exit +fi + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case $UNAME_MACHINE:$UNAME_SYSTEM in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 < in order to provide the needed -information to handle your system. +our_year=`echo $timestamp | sed 's,-.*,,'` +thisyear=`date +%Y` +# shellcheck disable=SC2003 +script_age=`expr "$thisyear" - "$our_year"` +if test "$script_age" -lt 3 ; then + cat >&2 </dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF +fi exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/config.sub b/config.sub index 0cd70165..baf1512b 100644 --- a/config.sub +++ b/config.sub @@ -1,12 +1,14 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2022 Free Software Foundation, Inc. -timestamp='2015-12-14' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2022-09-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -15,7 +17,7 @@ timestamp='2015-12-14' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +35,7 @@ timestamp='2015-12-14' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -50,6 +52,13 @@ timestamp='2015-12-14' # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -57,7 +66,7 @@ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -67,7 +76,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -89,12 +98,12 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -110,1234 +119,1186 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +# shellcheck disable=SC2162 +saved_IFS=$IFS +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova* | managarm-*) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac ;; - -psos*) - os=-psos + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + zephyr*) + basic_machine=$field1-unknown + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + op50n) + cpu=hppa1.1 + vendor=oki ;; - ms1) - basic_machine=mt-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown + ibm*) + cpu=i370 + vendor=ibm ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none + orion105) + cpu=clipper + vendor=highlevel ;; - xscaleeb) - basic_machine=armeb-unknown + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple ;; - - xscaleel) - basic_machine=armel-unknown + pmac | pmac-mpw) + cpu=powerpc + vendor=apple ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att + cpu=m68000 + vendor=att ;; 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=we32k + vendor=att ;; bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec + cpu=powerpc + vendor=ibm + basic_os=cnk ;; decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 + cpu=pdp10 + vendor=dec + basic_os=tops10 ;; decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 + cpu=pdp10 + vendor=dec + basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp + cpu=m68k + vendor=motorola ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 ;; encore | umax | mmax) - basic_machine=ns32k-encore + cpu=ns32k + vendor=encore ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} ;; fx2800) - basic_machine=i860-alliant + cpu=i860 + vendor=alliant ;; genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 + cpu=ns32k + vendor=ns ;; h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp + cpu=m68000 + vendor=hp ;; hp9k3[2-9][0-9]) - basic_machine=m68k-hp + cpu=m68k + vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm + cpu=hppa1.0 + vendor=hp ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} ;; iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) + cpu=mips + vendor=sgi + case $basic_os in + irix*) ;; *) - os=-irix4 + basic_os=irix4 ;; esac ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + cpu=m68000 + vendor=convergent ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint ;; news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) ;; - -ns2*) - os=-nextstep2 + ns2*) + basic_os=nextstep2 ;; *) - os=-nextstep3 + basic_os=nextstep3 ;; esac ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem + cpu=np1 + vendor=gould ;; op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k + cpu=hppa1.1 + vendor=oki + basic_os=proelf ;; pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; pbd) - basic_machine=sparc-tti + cpu=sparc + vendor=tti ;; pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc + cpu=m68k + vendor=tti ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + pc532) + cpu=ns32k + vendor=pc532 ;; pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + cpu=pn + vendor=gould ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + power) + cpu=power + vendor=ibm ;; ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff + cpu=i386 + vendor=ibm ;; rm[46]00) - basic_machine=mips-siemens + cpu=mips + vendor=siemens ;; rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm + cpu=romp + vendor=ibm ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi + sde) + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} ;; - sb1) - basic_machine=mipsisa64sb1-unknown + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown + tower | tower-32) + cpu=m68k + vendor=ncr ;; - sde) - basic_machine=mipsisa32-sde - os=-elf + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu ;; - sei) - basic_machine=mips-sei - os=-seiux + w65) + cpu=w65 + vendor=wdc ;; - sequent) - basic_machine=i386-sequent + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf ;; - sh) - basic_machine=sh-hitachi - os=-hms + none) + cpu=none + vendor=none ;; - sh5el) - basic_machine=sh5le-unknown + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine ;; - sh64) - basic_machine=sh64-unknown + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks + + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read cpu vendor <&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb | arc32 | arc64 \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | loongarch32 | loongarch64 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r3 | mipsisa32r3el \ + | mipsisa32r5 | mipsisa32r5el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r3 | mipsisa64r3el \ + | mipsisa64r5 | mipsisa64r5el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ + | rl78 | romp | rs6000 | rx \ + | s390 | s390x \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | thumbv7* \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1345,201 +1306,219 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if test x$basic_os != x then + +# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` + ;; + os2-emx) + kernel=os2 + os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` + ;; + nto-qnx*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read kernel os <&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1552,261 +1531,376 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +kernel= +case $cpu-$vendor in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + kernel=linux + os=gnu ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; - *-be) - os=-beos + pru-*) + os=elf ;; - *-haiku) - os=-haiku + *-be) + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna + os=luna ;; - *-next ) - os=-nextstep + *-next) + os=nextstep ;; *-sequent) - os=-ptx + os=ptx ;; *-crds) - os=-unos + os=unos ;; *-ns) - os=-genix + os=genix ;; i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-libc", so those need to count as OSes. + musl* | newlib* | relibc* | uclibc*) + ;; + # Likewise for "kernel-abi" + eabi* | gnueabi*) + ;; + # VxWorks passes extra cpu info in the 4th filed. + simlinux | simwindows | spe) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* | serenity* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ + | fiwix* | mlibc* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + kernel* ) + # Restricted further below + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ + | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* ) + ;; + uclinux-uclibc* ) + ;; + managarm-mlibc* | managarm-kernel* ) + ;; + -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + -kernel* ) + echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + *-kernel* ) + echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + vxworks-simlinux | vxworks-simwindows | vxworks-spe) + ;; + nto-qnx*) + ;; + os2-emx) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - -sunos*) + *-sunos*) vendor=sun ;; - -cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - -beos*) + *-beos*) vendor=be ;; - -hpux*) + *-hpux*) vendor=hp ;; - -mpeix*) + *-mpeix*) vendor=hp ;; - -hiux*) + *-hiux*) vendor=hitachi ;; - -unos*) + *-unos*) vendor=crds ;; - -dgux*) + *-dgux*) vendor=dg ;; - -luna*) + *-luna*) vendor=omron ;; - -genix*) + *-genix*) vendor=ns ;; - -mvs* | -opened*) + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) vendor=ibm ;; - -os400*) + s390-* | s390x-*) vendor=ibm ;; - -ptx*) + *-ptx*) vendor=sequent ;; - -tpf*) + *-tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - -aux*) + *-aux*) vendor=apple ;; - -hms*) + *-hms*) vendor=hitachi ;; - -mpw* | -macos*) + *-mpw* | *-macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - -vos*) + *-vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/configure b/configure index 17db7861..1ca44e72 100644 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libressl 3.6.2. +# Generated by GNU Autoconf 2.69 for libressl 3.7.2. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -587,8 +587,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libressl' PACKAGE_TARNAME='libressl' -PACKAGE_VERSION='3.6.2' -PACKAGE_STRING='libressl 3.6.2' +PACKAGE_VERSION='3.7.2' +PACKAGE_STRING='libressl 3.7.2' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -646,10 +646,34 @@ HOST_ASM_MACOSX_X86_64_FALSE HOST_ASM_MACOSX_X86_64_TRUE HOST_ASM_ELF_X86_64_FALSE HOST_ASM_ELF_X86_64_TRUE +HOST_ASM_ELF_MIPS64_FALSE +HOST_ASM_ELF_MIPS64_TRUE +HOST_ASM_ELF_MIPS_FALSE +HOST_ASM_ELF_MIPS_TRUE HOST_ASM_ELF_ARM_FALSE HOST_ASM_ELF_ARM_TRUE OPENSSL_NO_ASM_FALSE OPENSSL_NO_ASM_TRUE +HOST_X86_64_FALSE +HOST_X86_64_TRUE +HOST_SPARC64_FALSE +HOST_SPARC64_TRUE +HOST_RISCV64_FALSE +HOST_RISCV64_TRUE +HOST_POWERPC64_FALSE +HOST_POWERPC64_TRUE +HOST_POWERPC_FALSE +HOST_POWERPC_TRUE +HOST_MIPS64_FALSE +HOST_MIPS64_TRUE +HOST_MIPS_FALSE +HOST_MIPS_TRUE +HOST_I386_FALSE +HOST_I386_TRUE +HOST_ARM_FALSE +HOST_ARM_TRUE +HOST_AARCH64_FALSE +HOST_AARCH64_TRUE HOST_CPU_IS_INTEL_FALSE HOST_CPU_IS_INTEL_TRUE ENABLE_TESTS_FALSE @@ -1455,7 +1479,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libressl 3.6.2 to adapt to many kinds of systems. +\`configure' configures libressl 3.7.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1526,7 +1550,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libressl 3.6.2:";; + short | recursive ) echo "Configuration of libressl 3.7.2:";; esac cat <<\_ACEOF @@ -1644,7 +1668,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libressl configure 3.6.2 +libressl configure 3.7.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2192,7 +2216,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libressl $as_me 3.6.2, which was +It was created by libressl $as_me 3.7.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2540,11 +2564,11 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -LIBCRYPTO_VERSION=50:0:0 +LIBCRYPTO_VERSION=50:2:0 -LIBSSL_VERSION=53:0:0 +LIBSSL_VERSION=53:2:0 -LIBTLS_VERSION=26:0:0 +LIBTLS_VERSION=26:2:0 ac_aux_dir= @@ -3128,7 +3152,7 @@ fi # Define the identity of the package. PACKAGE='libressl' - VERSION='3.6.2' + VERSION='3.7.2' cat >>confdefs.h <<_ACEOF @@ -13754,12 +13778,22 @@ fi case $host_cpu in #( + arm64) : + host_cpu=aarch64 ;; #( *arm*) : host_cpu=arm ;; #( *amd64*) : host_cpu=x86_64 HOSTARCH=intel ;; #( i?86) : - HOSTARCH=intel ;; #( + host_cpu=i386 HOSTARCH=intel enable_asm=no ;; #( + mips64*) : + host_cpu=mips64 enable_asm=no ;; #( + mips*) : + host_cpu=mips enable_asm=no ;; #( + powerpc*) : + host_cpu=powerpc ;; #( + ppc64*) : + host_cpu=powerpc64 ;; #( x86_64) : HOSTARCH=intel ;; #( @@ -13775,6 +13809,87 @@ else fi + if test "$host_cpu" = "aarch64"; then + HOST_AARCH64_TRUE= + HOST_AARCH64_FALSE='#' +else + HOST_AARCH64_TRUE='#' + HOST_AARCH64_FALSE= +fi + + if test "$host_cpu" = "arm"; then + HOST_ARM_TRUE= + HOST_ARM_FALSE='#' +else + HOST_ARM_TRUE='#' + HOST_ARM_FALSE= +fi + + if test "$host_cpu" = "i386"; then + HOST_I386_TRUE= + HOST_I386_FALSE='#' +else + HOST_I386_TRUE='#' + HOST_I386_FALSE= +fi + + if test "$host_cpu" = "mips"; then + HOST_MIPS_TRUE= + HOST_MIPS_FALSE='#' +else + HOST_MIPS_TRUE='#' + HOST_MIPS_FALSE= +fi + + if test "$host_cpu" = "mips64"; then + HOST_MIPS64_TRUE= + HOST_MIPS64_FALSE='#' +else + HOST_MIPS64_TRUE='#' + HOST_MIPS64_FALSE= +fi + + if test "$host_cpu" = "powerpc"; then + HOST_POWERPC_TRUE= + HOST_POWERPC_FALSE='#' +else + HOST_POWERPC_TRUE='#' + HOST_POWERPC_FALSE= +fi + + if test "$host_cpu" = "ppc64"; then + HOST_POWERPC64_TRUE= + HOST_POWERPC64_FALSE='#' +else + HOST_POWERPC64_TRUE='#' + HOST_POWERPC64_FALSE= +fi + + if test "$host_cpu" = "riscv64"; then + HOST_RISCV64_TRUE= + HOST_RISCV64_FALSE='#' +else + HOST_RISCV64_TRUE='#' + HOST_RISCV64_FALSE= +fi + + if test "$host_cpu" = "sparc64"; then + HOST_SPARC64_TRUE= + HOST_SPARC64_FALSE='#' +else + HOST_SPARC64_TRUE='#' + HOST_SPARC64_FALSE= +fi + + if test "$host_cpu" = "x86_64"; then + HOST_X86_64_TRUE= + HOST_X86_64_FALSE='#' +else + HOST_X86_64_TRUE='#' + HOST_X86_64_FALSE= +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if .gnu.warning accepts long strings" >&5 $as_echo_n "checking if .gnu.warning accepts long strings... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13825,6 +13940,22 @@ else HOST_ASM_ELF_ARM_FALSE= fi + if test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "mips" -a "x$enable_asm" != "xno"; then + HOST_ASM_ELF_MIPS_TRUE= + HOST_ASM_ELF_MIPS_FALSE='#' +else + HOST_ASM_ELF_MIPS_TRUE='#' + HOST_ASM_ELF_MIPS_FALSE= +fi + + if test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "mips64" -a "x$enable_asm" != "xno"; then + HOST_ASM_ELF_MIPS64_TRUE= + HOST_ASM_ELF_MIPS64_FALSE='#' +else + HOST_ASM_ELF_MIPS64_TRUE='#' + HOST_ASM_ELF_MIPS64_FALSE= +fi + if test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "x86_64" -a "x$enable_asm" != "xno"; then HOST_ASM_ELF_X86_64_TRUE= HOST_ASM_ELF_X86_64_FALSE='#' @@ -14268,6 +14399,46 @@ if test -z "${HOST_CPU_IS_INTEL_TRUE}" && test -z "${HOST_CPU_IS_INTEL_FALSE}"; as_fn_error $? "conditional \"HOST_CPU_IS_INTEL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HOST_AARCH64_TRUE}" && test -z "${HOST_AARCH64_FALSE}"; then + as_fn_error $? "conditional \"HOST_AARCH64\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HOST_ARM_TRUE}" && test -z "${HOST_ARM_FALSE}"; then + as_fn_error $? "conditional \"HOST_ARM\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HOST_I386_TRUE}" && test -z "${HOST_I386_FALSE}"; then + as_fn_error $? "conditional \"HOST_I386\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HOST_MIPS_TRUE}" && test -z "${HOST_MIPS_FALSE}"; then + as_fn_error $? "conditional \"HOST_MIPS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HOST_MIPS64_TRUE}" && test -z "${HOST_MIPS64_FALSE}"; then + as_fn_error $? "conditional \"HOST_MIPS64\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HOST_POWERPC_TRUE}" && test -z "${HOST_POWERPC_FALSE}"; then + as_fn_error $? "conditional \"HOST_POWERPC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HOST_POWERPC64_TRUE}" && test -z "${HOST_POWERPC64_FALSE}"; then + as_fn_error $? "conditional \"HOST_POWERPC64\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HOST_RISCV64_TRUE}" && test -z "${HOST_RISCV64_FALSE}"; then + as_fn_error $? "conditional \"HOST_RISCV64\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HOST_SPARC64_TRUE}" && test -z "${HOST_SPARC64_FALSE}"; then + as_fn_error $? "conditional \"HOST_SPARC64\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HOST_X86_64_TRUE}" && test -z "${HOST_X86_64_FALSE}"; then + as_fn_error $? "conditional \"HOST_X86_64\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${OPENSSL_NO_ASM_TRUE}" && test -z "${OPENSSL_NO_ASM_FALSE}"; then as_fn_error $? "conditional \"OPENSSL_NO_ASM\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -14276,6 +14447,14 @@ if test -z "${HOST_ASM_ELF_ARM_TRUE}" && test -z "${HOST_ASM_ELF_ARM_FALSE}"; th as_fn_error $? "conditional \"HOST_ASM_ELF_ARM\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HOST_ASM_ELF_MIPS_TRUE}" && test -z "${HOST_ASM_ELF_MIPS_FALSE}"; then + as_fn_error $? "conditional \"HOST_ASM_ELF_MIPS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HOST_ASM_ELF_MIPS64_TRUE}" && test -z "${HOST_ASM_ELF_MIPS64_FALSE}"; then + as_fn_error $? "conditional \"HOST_ASM_ELF_MIPS64\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${HOST_ASM_ELF_X86_64_TRUE}" && test -z "${HOST_ASM_ELF_X86_64_FALSE}"; then as_fn_error $? "conditional \"HOST_ASM_ELF_X86_64\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -14701,7 +14880,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libressl $as_me 3.6.2, which was +This file was extended by libressl $as_me 3.7.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14758,7 +14937,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libressl config.status 3.6.2 +libressl config.status 3.7.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 81195086..51e096bd 100644 --- a/configure.ac +++ b/configure.ac @@ -74,13 +74,29 @@ AC_ARG_ENABLE([tests], AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = xyes]) AS_CASE([$host_cpu], + [arm64], [host_cpu=aarch64], [*arm*], [host_cpu=arm], [*amd64*], [host_cpu=x86_64 HOSTARCH=intel], - [i?86], [HOSTARCH=intel], + [i?86], [host_cpu=i386 HOSTARCH=intel enable_asm=no], + [mips64*], [host_cpu=mips64 enable_asm=no], + [mips*], [host_cpu=mips enable_asm=no], + [powerpc*], [host_cpu=powerpc], + [ppc64*], [host_cpu=powerpc64], [x86_64], [HOSTARCH=intel] ) AM_CONDITIONAL([HOST_CPU_IS_INTEL], [test "x$HOSTARCH" = "xintel"]) +AM_CONDITIONAL([HOST_AARCH64], [test "$host_cpu" = "aarch64"]) +AM_CONDITIONAL([HOST_ARM], [test "$host_cpu" = "arm"]) +AM_CONDITIONAL([HOST_I386], [test "$host_cpu" = "i386"]) +AM_CONDITIONAL([HOST_MIPS], [test "$host_cpu" = "mips"]) +AM_CONDITIONAL([HOST_MIPS64], [test "$host_cpu" = "mips64"]) +AM_CONDITIONAL([HOST_POWERPC], [test "$host_cpu" = "powerpc"]) +AM_CONDITIONAL([HOST_POWERPC64], [test "$host_cpu" = "ppc64"]) +AM_CONDITIONAL([HOST_RISCV64], [test "$host_cpu" = "riscv64"]) +AM_CONDITIONAL([HOST_SPARC64], [test "$host_cpu" = "sparc64"]) +AM_CONDITIONAL([HOST_X86_64], [test "$host_cpu" = "x86_64"]) + AC_MSG_CHECKING([if .gnu.warning accepts long strings]) AC_LINK_IFELSE([AC_LANG_SOURCE([[ extern void SSLv3_method(); @@ -93,13 +109,16 @@ int main() {return 0;} AC_MSG_RESULT(no) ]) -AC_ARG_ENABLE([asm], - AS_HELP_STRING([--disable-asm], [Disable assembly])) +AC_ARG_ENABLE([asm], AS_HELP_STRING([--disable-asm], [Disable assembly])) AM_CONDITIONAL([OPENSSL_NO_ASM], [test "x$enable_asm" = "xno"]) # Conditionally enable assembly by default AM_CONDITIONAL([HOST_ASM_ELF_ARM], [test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "arm" -a "x$enable_asm" != "xno"]) +AM_CONDITIONAL([HOST_ASM_ELF_MIPS], + [test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "mips" -a "x$enable_asm" != "xno"]) +AM_CONDITIONAL([HOST_ASM_ELF_MIPS64], + [test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "mips64" -a "x$enable_asm" != "xno"]) AM_CONDITIONAL([HOST_ASM_ELF_X86_64], [test "x$HOST_ABI" = "xelf" -a "$host_cpu" = "x86_64" -a "x$enable_asm" != "xno"]) AM_CONDITIONAL([HOST_ASM_MACOSX_X86_64], diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 2c0268c7..a364e868 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -47,6 +47,19 @@ if(HOST_ASM_ELF_X86_64) sha/sha512-elf-x86_64.S whrlpool/wp-elf-x86_64.S cpuid-elf-x86_64.S + + bn/arch/amd64/bignum_add.S + bn/arch/amd64/bignum_cmadd.S + bn/arch/amd64/bignum_cmul.S + bn/arch/amd64/bignum_mul.S + bn/arch/amd64/bignum_mul_4_8_alt.S + bn/arch/amd64/bignum_mul_8_16_alt.S + bn/arch/amd64/bignum_sqr.S + bn/arch/amd64/bignum_sqr_4_8_alt.S + bn/arch/amd64/bignum_sqr_8_16_alt.S + bn/arch/amd64/bignum_sub.S + bn/arch/amd64/word_clz.S + bn/arch/amd64/bn_arch.c ) add_definitions(-DAES_ASM) add_definitions(-DBSAES_ASM) @@ -89,6 +102,19 @@ if(HOST_ASM_MACOSX_X86_64) sha/sha512-macosx-x86_64.S whrlpool/wp-macosx-x86_64.S cpuid-macosx-x86_64.S + + bn/arch/amd64/bignum_add.S + bn/arch/amd64/bignum_cmadd.S + bn/arch/amd64/bignum_cmul.S + bn/arch/amd64/bignum_mul.S + bn/arch/amd64/bignum_mul_4_8_alt.S + bn/arch/amd64/bignum_mul_8_16_alt.S + bn/arch/amd64/bignum_sqr.S + bn/arch/amd64/bignum_sqr_4_8_alt.S + bn/arch/amd64/bignum_sqr_8_16_alt.S + bn/arch/amd64/bignum_sub.S + bn/arch/amd64/word_clz.S + bn/arch/amd64/bn_arch.c ) add_definitions(-DAES_ASM) add_definitions(-DBSAES_ASM) @@ -236,7 +262,6 @@ set( o_fips.c o_init.c o_str.c - o_time.c aes/aes_cfb.c aes/aes_ctr.c aes/aes_ecb.c @@ -257,6 +282,7 @@ set( asn1/a_string.c asn1/a_strnid.c asn1/a_time.c + asn1/a_time_posix.c asn1/a_time_tm.c asn1/a_type.c asn1/a_utf8.c @@ -331,16 +357,13 @@ set( bio/bss_null.c bio/bss_sock.c bn/bn_add.c - bn/bn_asm.c bn/bn_blind.c bn/bn_bpsw.c bn/bn_const.c bn/bn_ctx.c - bn/bn_depr.c bn/bn_div.c bn/bn_err.c bn/bn_exp.c - bn/bn_exp2.c bn/bn_gcd.c bn/bn_gf2m.c bn/bn_isqrt.c @@ -356,6 +379,7 @@ set( bn/bn_rand.c bn/bn_recp.c bn/bn_shift.c + bn/bn_small_primes.c bn/bn_sqr.c bn/bn_sqrt.c bn/bn_word.c @@ -460,8 +484,6 @@ set( dsa/dsa_ossl.c dsa/dsa_pmeth.c dsa/dsa_prn.c - dsa/dsa_sign.c - dsa/dsa_vrf.c dso/dso_dlfcn.c dso/dso_err.c dso/dso_lib.c @@ -488,6 +510,7 @@ set( ec/ecp_nist.c ec/ecp_oct.c ec/ecp_smpl.c + ec/ecx_methods.c ecdh/ecdh_kdf.c ecdh/ech_err.c ecdh/ech_key.c @@ -529,6 +552,7 @@ set( evp/bio_enc.c evp/bio_md.c evp/c_all.c + evp/cipher_method_lib.c evp/digest.c evp/e_aes.c evp/e_aes_cbc_hmac_sha1.c @@ -720,6 +744,7 @@ set( txt_db/txt_db.c ui/ui_err.c ui/ui_lib.c + ui/ui_null.c ui/ui_util.c whrlpool/wp_dgst.c x509/by_dir.c @@ -992,10 +1017,12 @@ target_include_directories(crypto_obj bytestring dh dsa + curve25519 ec ecdh ecdsa evp + hidden hmac modes ocsp @@ -1006,7 +1033,27 @@ target_include_directories(crypto_obj PUBLIC ../include) -add_library(crypto $) +if(HOST_AARCH64) + target_include_directories(crypto_obj PRIVATE bn/arch/aarch64/) +elseif(HOST_ARM) + target_include_directories(crypto_obj PRIVATE bn/arch/arm/) +elseif(HOST_I386) + target_include_directories(crypto_obj PRIVATE bn/arch/i386/) +elseif(HOST_MIPS64) + target_include_directories(crypto_obj PRIVATE bn/arch/mips64) +elseif(HOST_POWERPC) + target_include_directories(crypto_obj PRIVATE bn/arch/powerpc) +elseif(HOST_POWERPC64) + target_include_directories(crypto_obj PRIVATE bn/arch/powerpc64) +elseif(HOST_RISCV64) + target_include_directories(crypto_obj PRIVATE bn/arch/riscv64) +elseif(HOST_SPARC64) + target_include_directories(crypto_obj PRIVATE bn/arch/sparc64) +elseif(HOST_X86_64) + target_include_directories(crypto_obj PRIVATE bn/arch/amd64) +endif() + +add_library(crypto $ empty.c) export_symbol(crypto ${CMAKE_CURRENT_BINARY_DIR}/crypto_p.sym) target_link_libraries(crypto ${PLATFORM_LIBS}) diff --git a/crypto/Makefile.am b/crypto/Makefile.am index 01833d2e..39398029 100644 --- a/crypto/Makefile.am +++ b/crypto/Makefile.am @@ -1,11 +1,11 @@ include $(top_srcdir)/Makefile.am.common AM_CPPFLAGS += -DLIBRESSL_CRYPTO_INTERNAL - AM_CPPFLAGS += -I$(top_srcdir)/crypto/asn1 AM_CPPFLAGS += -I$(top_srcdir)/crypto/bio AM_CPPFLAGS += -I$(top_srcdir)/crypto/bn AM_CPPFLAGS += -I$(top_srcdir)/crypto/bytestring +AM_CPPFLAGS += -I$(top_srcdir)/crypto/curve25519 AM_CPPFLAGS += -I$(top_srcdir)/crypto/dh AM_CPPFLAGS += -I$(top_srcdir)/crypto/dsa AM_CPPFLAGS += -I$(top_srcdir)/crypto/ec @@ -31,6 +31,7 @@ endif EXTRA_DIST = VERSION EXTRA_DIST += CMakeLists.txt EXTRA_DIST += crypto.sym +EXTRA_DIST += empty.c # needed for a CMake target EXTRA_DIST += compat/strcasecmp.c @@ -132,13 +133,9 @@ libcrypto_la_LIBADD = libcompat.la if !HAVE_EXPLICIT_BZERO libcrypto_la_LIBADD += libcompatnoopt.la endif -libcrypto_la_CPPFLAGS = $(AM_CPPFLAGS) +libcrypto_la_CPPFLAGS = -I$(top_srcdir)/crypto/hidden ${AM_CPPFLAGS} libcrypto_la_CPPFLAGS += -DLIBRESSL_INTERNAL libcrypto_la_CPPFLAGS += -DOPENSSL_NO_HW_PADLOCK -if OPENSSL_NO_ASM -libcrypto_la_CPPFLAGS += -DOPENSSL_NO_ASM -else -endif if OPENSSLDIR_DEFINED libcrypto_la_CPPFLAGS += -DOPENSSLDIR=\"@OPENSSLDIR@\" @@ -246,16 +243,21 @@ libcrypto_la_SOURCES = EXTRA_libcrypto_la_SOURCES = include Makefile.am.elf-arm +include Makefile.am.elf-mips +include Makefile.am.elf-mips64 include Makefile.am.elf-x86_64 include Makefile.am.macosx-x86_64 include Makefile.am.masm-x86_64 include Makefile.am.mingw64-x86_64 if !HOST_ASM_ELF_ARM +if !HOST_ASM_ELF_MIPS +if !HOST_ASM_ELF_MIPS64 if !HOST_ASM_ELF_X86_64 if !HOST_ASM_MACOSX_X86_64 if !HOST_ASM_MASM_X86_64 if !HOST_ASM_MINGW64_X86_64 +libcrypto_la_CPPFLAGS += -DOPENSSL_NO_ASM libcrypto_la_SOURCES += aes/aes_cbc.c libcrypto_la_SOURCES += aes/aes_core.c libcrypto_la_SOURCES += camellia/camellia.c @@ -268,6 +270,8 @@ endif endif endif endif +endif +endif libcrypto_la_SOURCES += cpt_err.c libcrypto_la_SOURCES += cryptlib.c @@ -285,12 +289,10 @@ libcrypto_la_SOURCES += mem_dbg.c libcrypto_la_SOURCES += o_fips.c libcrypto_la_SOURCES += o_init.c libcrypto_la_SOURCES += o_str.c -libcrypto_la_SOURCES += o_time.c noinst_HEADERS += arm_arch.h -noinst_HEADERS += constant_time_locl.h +noinst_HEADERS += constant_time.h noinst_HEADERS += cryptlib.h noinst_HEADERS += md32_common.h -noinst_HEADERS += o_time.h noinst_HEADERS += x86_arch.h # aes @@ -301,7 +303,7 @@ libcrypto_la_SOURCES += aes/aes_ige.c libcrypto_la_SOURCES += aes/aes_misc.c libcrypto_la_SOURCES += aes/aes_ofb.c libcrypto_la_SOURCES += aes/aes_wrap.c -noinst_HEADERS += aes/aes_locl.h +noinst_HEADERS += aes/aes_local.h # asn1 libcrypto_la_SOURCES += asn1/a_bitstr.c @@ -317,6 +319,7 @@ libcrypto_la_SOURCES += asn1/a_strex.c libcrypto_la_SOURCES += asn1/a_string.c libcrypto_la_SOURCES += asn1/a_strnid.c libcrypto_la_SOURCES += asn1/a_time.c +libcrypto_la_SOURCES += asn1/a_time_posix.c libcrypto_la_SOURCES += asn1/a_time_tm.c libcrypto_la_SOURCES += asn1/a_type.c libcrypto_la_SOURCES += asn1/a_utf8.c @@ -366,7 +369,7 @@ libcrypto_la_SOURCES += asn1/x_spki.c libcrypto_la_SOURCES += asn1/x_val.c libcrypto_la_SOURCES += asn1/x_x509.c libcrypto_la_SOURCES += asn1/x_x509a.c -noinst_HEADERS += asn1/asn1_locl.h +noinst_HEADERS += asn1/asn1_local.h noinst_HEADERS += asn1/charmap.h # bf @@ -375,8 +378,7 @@ libcrypto_la_SOURCES += bf/bf_ecb.c libcrypto_la_SOURCES += bf/bf_enc.c libcrypto_la_SOURCES += bf/bf_ofb64.c libcrypto_la_SOURCES += bf/bf_skey.c -noinst_HEADERS += bf/bf_locl.h -noinst_HEADERS += bf/bf_pi.h +noinst_HEADERS += bf/bf_local.h # bio libcrypto_la_SOURCES += bio/b_dump.c @@ -411,16 +413,13 @@ noinst_HEADERS += bio/bio_local.h # bn libcrypto_la_SOURCES += bn/bn_add.c -libcrypto_la_SOURCES += bn/bn_asm.c libcrypto_la_SOURCES += bn/bn_blind.c libcrypto_la_SOURCES += bn/bn_bpsw.c libcrypto_la_SOURCES += bn/bn_const.c libcrypto_la_SOURCES += bn/bn_ctx.c -libcrypto_la_SOURCES += bn/bn_depr.c libcrypto_la_SOURCES += bn/bn_div.c libcrypto_la_SOURCES += bn/bn_err.c libcrypto_la_SOURCES += bn/bn_exp.c -libcrypto_la_SOURCES += bn/bn_exp2.c libcrypto_la_SOURCES += bn/bn_gcd.c libcrypto_la_SOURCES += bn/bn_gf2m.c libcrypto_la_SOURCES += bn/bn_isqrt.c @@ -436,12 +435,67 @@ libcrypto_la_SOURCES += bn/bn_print.c libcrypto_la_SOURCES += bn/bn_rand.c libcrypto_la_SOURCES += bn/bn_recp.c libcrypto_la_SOURCES += bn/bn_shift.c +libcrypto_la_SOURCES += bn/bn_small_primes.c libcrypto_la_SOURCES += bn/bn_sqr.c libcrypto_la_SOURCES += bn/bn_sqrt.c libcrypto_la_SOURCES += bn/bn_word.c libcrypto_la_SOURCES += bn/bn_x931p.c -noinst_HEADERS += bn/bn_lcl.h +noinst_HEADERS += bn/bn_internal.h +noinst_HEADERS += bn/bn_local.h noinst_HEADERS += bn/bn_prime.h +noinst_HEADERS += bn/s2n_bignum.h +noinst_HEADERS += bn/s2n_bignum_internal.h + +# bn/arch +if HOST_AARCH64 +libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/aarch64/ +endif +noinst_HEADERS += bn/arch/aarch64/bn_arch.h + +if HOST_ARM +libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/arm/ +endif +noinst_HEADERS += bn/arch/arm/bn_arch.h + +if HOST_I386 +libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/i386/ +endif +noinst_HEADERS += bn/arch/i386/bn_arch.h + +if HOST_MIPS +libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/mips/ +endif +noinst_HEADERS += bn/arch/mips/bn_arch.h + +if HOST_MIPS64 +libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/mips64/ +endif +noinst_HEADERS += bn/arch/mips64/bn_arch.h + +if HOST_POWERPC +libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/powerpc/ +endif +noinst_HEADERS += bn/arch/powerpc/bn_arch.h + +if HOST_POWERPC64 +libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/powerpc64/ +endif +noinst_HEADERS += bn/arch/powerpc64/bn_arch.h + +if HOST_RISCV64 +libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/riscv64/ +endif +noinst_HEADERS += bn/arch/riscv64/bn_arch.h + +if HOST_SPARC64 +libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/sparc64/ +endif +noinst_HEADERS += bn/arch/sparc64/bn_arch.h + +if HOST_X86_64 +libcrypto_la_CPPFLAGS += -I$(top_srcdir)/crypto/bn/arch/amd64/ +endif +noinst_HEADERS += bn/arch/amd64/bn_arch.h # buffer libcrypto_la_SOURCES += buffer/buf_err.c @@ -461,7 +515,7 @@ libcrypto_la_SOURCES += camellia/cmll_ecb.c libcrypto_la_SOURCES += camellia/cmll_misc.c libcrypto_la_SOURCES += camellia/cmll_ofb.c noinst_HEADERS += camellia/camellia.h -noinst_HEADERS += camellia/cmll_locl.h +noinst_HEADERS += camellia/cmll_local.h # cast libcrypto_la_SOURCES += cast/c_cfb64.c @@ -469,7 +523,7 @@ libcrypto_la_SOURCES += cast/c_ecb.c libcrypto_la_SOURCES += cast/c_enc.c libcrypto_la_SOURCES += cast/c_ofb64.c libcrypto_la_SOURCES += cast/c_skey.c -noinst_HEADERS += cast/cast_lcl.h +noinst_HEADERS += cast/cast_local.h noinst_HEADERS += cast/cast_s.h # chacha @@ -496,7 +550,7 @@ libcrypto_la_SOURCES += cms/cms_lib.c libcrypto_la_SOURCES += cms/cms_pwri.c libcrypto_la_SOURCES += cms/cms_sd.c libcrypto_la_SOURCES += cms/cms_smime.c -noinst_HEADERS += cms/cms_lcl.h +noinst_HEADERS += cms/cms_local.h # comp libcrypto_la_SOURCES += comp/c_rle.c @@ -558,7 +612,7 @@ libcrypto_la_SOURCES += des/rand_key.c libcrypto_la_SOURCES += des/set_key.c libcrypto_la_SOURCES += des/str2key.c libcrypto_la_SOURCES += des/xcbc_enc.c -noinst_HEADERS += des/des_locl.h +noinst_HEADERS += des/des_local.h noinst_HEADERS += des/spr.h # dh @@ -586,9 +640,7 @@ libcrypto_la_SOURCES += dsa/dsa_meth.c libcrypto_la_SOURCES += dsa/dsa_ossl.c libcrypto_la_SOURCES += dsa/dsa_pmeth.c libcrypto_la_SOURCES += dsa/dsa_prn.c -libcrypto_la_SOURCES += dsa/dsa_sign.c -libcrypto_la_SOURCES += dsa/dsa_vrf.c -noinst_HEADERS += dsa/dsa_locl.h +noinst_HEADERS += dsa/dsa_local.h # dso libcrypto_la_SOURCES += dso/dso_dlfcn.c @@ -619,14 +671,15 @@ libcrypto_la_SOURCES += ec/ecp_mont.c libcrypto_la_SOURCES += ec/ecp_nist.c libcrypto_la_SOURCES += ec/ecp_oct.c libcrypto_la_SOURCES += ec/ecp_smpl.c -noinst_HEADERS += ec/ec_lcl.h +libcrypto_la_SOURCES += ec/ecx_methods.c +noinst_HEADERS += ec/ec_local.h # ecdh libcrypto_la_SOURCES += ecdh/ecdh_kdf.c libcrypto_la_SOURCES += ecdh/ech_err.c libcrypto_la_SOURCES += ecdh/ech_key.c libcrypto_la_SOURCES += ecdh/ech_lib.c -noinst_HEADERS += ecdh/ech_locl.h +noinst_HEADERS += ecdh/ech_local.h # ecdsa libcrypto_la_SOURCES += ecdsa/ecs_asn1.c @@ -635,7 +688,7 @@ libcrypto_la_SOURCES += ecdsa/ecs_lib.c libcrypto_la_SOURCES += ecdsa/ecs_ossl.c libcrypto_la_SOURCES += ecdsa/ecs_sign.c libcrypto_la_SOURCES += ecdsa/ecs_vrf.c -noinst_HEADERS += ecdsa/ecs_locl.h +noinst_HEADERS += ecdsa/ecs_local.h # engine libcrypto_la_SOURCES += engine/eng_all.c @@ -674,6 +727,7 @@ libcrypto_la_SOURCES += evp/bio_b64.c libcrypto_la_SOURCES += evp/bio_enc.c libcrypto_la_SOURCES += evp/bio_md.c libcrypto_la_SOURCES += evp/c_all.c +libcrypto_la_SOURCES += evp/cipher_method_lib.c libcrypto_la_SOURCES += evp/digest.c libcrypto_la_SOURCES += evp/e_aes.c libcrypto_la_SOURCES += evp/e_aes_cbc_hmac_sha1.c @@ -726,7 +780,7 @@ libcrypto_la_SOURCES += evp/p_verify.c libcrypto_la_SOURCES += evp/pmeth_fn.c libcrypto_la_SOURCES += evp/pmeth_gn.c libcrypto_la_SOURCES += evp/pmeth_lib.c -noinst_HEADERS += evp/evp_locl.h +noinst_HEADERS += evp/evp_local.h # gost libcrypto_la_SOURCES += gost/gost2814789.c @@ -744,7 +798,18 @@ libcrypto_la_SOURCES += gost/gostr341001_pmeth.c libcrypto_la_SOURCES += gost/gostr341194.c libcrypto_la_SOURCES += gost/streebog.c noinst_HEADERS += gost/gost_asn1.h -noinst_HEADERS += gost/gost_locl.h +noinst_HEADERS += gost/gost_local.h + +# hidden +noinst_HEADERS += hidden/crypto_namespace.h +noinst_HEADERS += hidden/openssl/hmac.h +noinst_HEADERS += hidden/openssl/pkcs12.h +noinst_HEADERS += hidden/openssl/pkcs7.h +noinst_HEADERS += hidden/openssl/stack.h +noinst_HEADERS += hidden/openssl/ui.h +noinst_HEADERS += hidden/openssl/x509.h +noinst_HEADERS += hidden/openssl/x509_vfy.h +noinst_HEADERS += hidden/openssl/x509v3.h # hkdf libcrypto_la_SOURCES += hkdf/hkdf.c @@ -761,7 +826,7 @@ libcrypto_la_SOURCES += idea/i_cfb64.c libcrypto_la_SOURCES += idea/i_ecb.c libcrypto_la_SOURCES += idea/i_ofb64.c libcrypto_la_SOURCES += idea/i_skey.c -noinst_HEADERS += idea/idea_lcl.h +noinst_HEADERS += idea/idea_local.h # kdf libcrypto_la_SOURCES += kdf/hkdf_evp.c @@ -774,12 +839,12 @@ libcrypto_la_SOURCES += lhash/lhash.c # md4 libcrypto_la_SOURCES += md4/md4_dgst.c libcrypto_la_SOURCES += md4/md4_one.c -noinst_HEADERS += md4/md4_locl.h +noinst_HEADERS += md4/md4_local.h # md5 libcrypto_la_SOURCES += md5/md5_dgst.c libcrypto_la_SOURCES += md5/md5_one.c -noinst_HEADERS += md5/md5_locl.h +noinst_HEADERS += md5/md5_local.h # modes libcrypto_la_SOURCES += modes/cbc128.c @@ -790,7 +855,7 @@ libcrypto_la_SOURCES += modes/cts128.c libcrypto_la_SOURCES += modes/gcm128.c libcrypto_la_SOURCES += modes/ofb128.c libcrypto_la_SOURCES += modes/xts128.c -noinst_HEADERS += modes/modes_lcl.h +noinst_HEADERS += modes/modes_local.h # objects libcrypto_la_SOURCES += objects/o_names.c @@ -870,15 +935,15 @@ libcrypto_la_SOURCES += rc2/rc2_ecb.c libcrypto_la_SOURCES += rc2/rc2_skey.c libcrypto_la_SOURCES += rc2/rc2cfb64.c libcrypto_la_SOURCES += rc2/rc2ofb64.c -noinst_HEADERS += rc2/rc2_locl.h +noinst_HEADERS += rc2/rc2_local.h # rc4 -noinst_HEADERS += rc4/rc4_locl.h +noinst_HEADERS += rc4/rc4_local.h # ripemd libcrypto_la_SOURCES += ripemd/rmd_dgst.c libcrypto_la_SOURCES += ripemd/rmd_one.c -noinst_HEADERS += ripemd/rmd_locl.h +noinst_HEADERS += ripemd/rmd_local.h noinst_HEADERS += ripemd/rmdconst.h # rsa @@ -901,18 +966,18 @@ libcrypto_la_SOURCES += rsa/rsa_pss.c libcrypto_la_SOURCES += rsa/rsa_saos.c libcrypto_la_SOURCES += rsa/rsa_sign.c libcrypto_la_SOURCES += rsa/rsa_x931.c -noinst_HEADERS += rsa/rsa_locl.h +noinst_HEADERS += rsa/rsa_local.h # sha libcrypto_la_SOURCES += sha/sha1_one.c libcrypto_la_SOURCES += sha/sha1dgst.c libcrypto_la_SOURCES += sha/sha256.c libcrypto_la_SOURCES += sha/sha512.c -noinst_HEADERS += sha/sha_locl.h +noinst_HEADERS += sha/sha_local.h # sm3 libcrypto_la_SOURCES += sm3/sm3.c -noinst_HEADERS += sm3/sm3_locl.h +noinst_HEADERS += sm3/sm3_local.h # sm4 libcrypto_la_SOURCES += sm4/sm4.c @@ -940,6 +1005,7 @@ libcrypto_la_SOURCES += txt_db/txt_db.c # ui libcrypto_la_SOURCES += ui/ui_err.c libcrypto_la_SOURCES += ui/ui_lib.c +libcrypto_la_SOURCES += ui/ui_null.c if !HOST_WIN libcrypto_la_SOURCES += ui/ui_openssl.c endif @@ -947,11 +1013,11 @@ if HOST_WIN libcrypto_la_SOURCES += ui/ui_openssl_win.c endif libcrypto_la_SOURCES += ui/ui_util.c -noinst_HEADERS += ui/ui_locl.h +noinst_HEADERS += ui/ui_local.h # whrlpool libcrypto_la_SOURCES += whrlpool/wp_dgst.c -noinst_HEADERS += whrlpool/wp_locl.h +noinst_HEADERS += whrlpool/wp_local.h # x509 libcrypto_la_SOURCES += x509/by_dir.c @@ -1022,4 +1088,5 @@ noinst_HEADERS += x509/pcy_int.h noinst_HEADERS += x509/vpm_int.h noinst_HEADERS += x509/x509_internal.h noinst_HEADERS += x509/x509_issuer_cache.h -noinst_HEADERS += x509/x509_lcl.h +noinst_HEADERS += x509/x509_local.h +noinst_HEADERS += x509/x509_verify.h diff --git a/crypto/Makefile.am.elf-mips b/crypto/Makefile.am.elf-mips new file mode 100644 index 00000000..9c4a70f1 --- /dev/null +++ b/crypto/Makefile.am.elf-mips @@ -0,0 +1,24 @@ +ASM_MIPS_ELF = aes/aes-mips.S +ASM_MIPS_ELF += bn/bn-mips.S +ASM_MIPS_ELF += bn/mont-mips.S +ASM_MIPS_ELF += sha/sha1-mips.S +ASM_MIPS_ELF += sha/sha512-mips.S +ASM_MIPS_ELF += sha/sha256-mips.S + +ASM_MIPS_ELF += aes/aes_cbc.c +ASM_MIPS_ELF += camellia/camellia.c +ASM_MIPS_ELF += camellia/cmll_cbc.c +ASM_MIPS_ELF += rc4/rc4_enc.c +ASM_MIPS_ELF += rc4/rc4_skey.c +ASM_MIPS_ELF += whrlpool/wp_block.c + +EXTRA_DIST += $(ASM_MIPS_ELF) + +if HOST_ASM_ELF_MIPS +libcrypto_la_CPPFLAGS += -DAES_ASM +libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT +libcrypto_la_CPPFLAGS += -DSHA1_ASM +libcrypto_la_CPPFLAGS += -DSHA256_ASM +libcrypto_la_CPPFLAGS += -DSHA512_ASM +libcrypto_la_SOURCES += $(ASM_MIPS_ELF) +endif diff --git a/crypto/Makefile.am.elf-mips64 b/crypto/Makefile.am.elf-mips64 new file mode 100644 index 00000000..c599fa83 --- /dev/null +++ b/crypto/Makefile.am.elf-mips64 @@ -0,0 +1,24 @@ +ASM_MIPS64_ELF = aes/aes-mips.S +ASM_MIPS64_ELF += bn/bn-mips.S +ASM_MIPS64_ELF += bn/mont-mips.S +ASM_MIPS64_ELF += sha/sha1-mips.S +ASM_MIPS64_ELF += sha/sha512-mips.S +ASM_MIPS64_ELF += sha/sha256-mips.S + +ASM_MIPS64_ELF += aes/aes_cbc.c +ASM_MIPS64_ELF += camellia/camellia.c +ASM_MIPS64_ELF += camellia/cmll_cbc.c +ASM_MIPS64_ELF += rc4/rc4_enc.c +ASM_MIPS64_ELF += rc4/rc4_skey.c +ASM_MIPS64_ELF += whrlpool/wp_block.c + +EXTRA_DIST += $(ASM_MIPS64_ELF) + +if HOST_ASM_ELF_MIPS64 +libcrypto_la_CPPFLAGS += -DAES_ASM +libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT +libcrypto_la_CPPFLAGS += -DSHA1_ASM +libcrypto_la_CPPFLAGS += -DSHA256_ASM +libcrypto_la_CPPFLAGS += -DSHA512_ASM +libcrypto_la_SOURCES += $(ASM_MIPS64_ELF) +endif diff --git a/crypto/Makefile.am.elf-x86_64 b/crypto/Makefile.am.elf-x86_64 index 4cd34e25..20cc0cca 100644 --- a/crypto/Makefile.am.elf-x86_64 +++ b/crypto/Makefile.am.elf-x86_64 @@ -19,6 +19,19 @@ ASM_X86_64_ELF += sha/sha512-elf-x86_64.S ASM_X86_64_ELF += whrlpool/wp-elf-x86_64.S ASM_X86_64_ELF += cpuid-elf-x86_64.S +ASM_X86_64_ELF += bn/arch/amd64/bignum_add.S +ASM_X86_64_ELF += bn/arch/amd64/bignum_cmadd.S +ASM_X86_64_ELF += bn/arch/amd64/bignum_cmul.S +ASM_X86_64_ELF += bn/arch/amd64/bignum_mul.S +ASM_X86_64_ELF += bn/arch/amd64/bignum_mul_4_8_alt.S +ASM_X86_64_ELF += bn/arch/amd64/bignum_mul_8_16_alt.S +ASM_X86_64_ELF += bn/arch/amd64/bignum_sqr.S +ASM_X86_64_ELF += bn/arch/amd64/bignum_sqr_4_8_alt.S +ASM_X86_64_ELF += bn/arch/amd64/bignum_sqr_8_16_alt.S +ASM_X86_64_ELF += bn/arch/amd64/bignum_sub.S +ASM_X86_64_ELF += bn/arch/amd64/word_clz.S +ASM_X86_64_ELF += bn/arch/amd64/bn_arch.c + EXTRA_DIST += $(ASM_X86_64_ELF) if HOST_ASM_ELF_X86_64 diff --git a/crypto/Makefile.am.macosx-x86_64 b/crypto/Makefile.am.macosx-x86_64 index 21181564..f3990a5f 100644 --- a/crypto/Makefile.am.macosx-x86_64 +++ b/crypto/Makefile.am.macosx-x86_64 @@ -19,6 +19,19 @@ ASM_X86_64_MACOSX += sha/sha512-macosx-x86_64.S ASM_X86_64_MACOSX += whrlpool/wp-macosx-x86_64.S ASM_X86_64_MACOSX += cpuid-macosx-x86_64.S +ASM_X86_64_MACOSX += bn/arch/amd64/bignum_add.S +ASM_X86_64_MACOSX += bn/arch/amd64/bignum_cmadd.S +ASM_X86_64_MACOSX += bn/arch/amd64/bignum_cmul.S +ASM_X86_64_MACOSX += bn/arch/amd64/bignum_mul.S +ASM_X86_64_MACOSX += bn/arch/amd64/bignum_mul_4_8_alt.S +ASM_X86_64_MACOSX += bn/arch/amd64/bignum_mul_8_16_alt.S +ASM_X86_64_MACOSX += bn/arch/amd64/bignum_sqr.S +ASM_X86_64_MACOSX += bn/arch/amd64/bignum_sqr_4_8_alt.S +ASM_X86_64_MACOSX += bn/arch/amd64/bignum_sqr_8_16_alt.S +ASM_X86_64_MACOSX += bn/arch/amd64/bignum_sub.S +ASM_X86_64_MACOSX += bn/arch/amd64/word_clz.S +ASM_X86_64_MACOSX += bn/arch/amd64/bn_arch.c + EXTRA_DIST += $(ASM_X86_64_MACOSX) if HOST_ASM_MACOSX_X86_64 diff --git a/crypto/Makefile.in b/crypto/Makefile.in index 2bcf6ef0..045551d0 100644 --- a/crypto/Makefile.in +++ b/crypto/Makefile.in @@ -91,50 +91,57 @@ build_triplet = @build@ host_triplet = @host@ @ENABLE_LIBTLS_ONLY_TRUE@am__append_1 = libcrypto.la @HAVE_EXPLICIT_BZERO_FALSE@am__append_2 = libcompatnoopt.la -@OPENSSL_NO_ASM_TRUE@am__append_3 = -DOPENSSL_NO_ASM -@OPENSSLDIR_DEFINED_TRUE@am__append_4 = -DOPENSSLDIR=\"@OPENSSLDIR@\" -@OPENSSLDIR_DEFINED_FALSE@am__append_5 = -DOPENSSLDIR=\"$(sysconfdir)/ssl\" +@OPENSSLDIR_DEFINED_TRUE@am__append_3 = -DOPENSSLDIR=\"@OPENSSLDIR@\" +@OPENSSLDIR_DEFINED_FALSE@am__append_4 = -DOPENSSLDIR=\"$(sysconfdir)/ssl\" # compatibility functions that need to be built without optimizations -@HAVE_EXPLICIT_BZERO_FALSE@am__append_6 = libcompatnoopt.la -@HAVE_EXPLICIT_BZERO_FALSE@@HOST_WIN_TRUE@am__append_7 = compat/explicit_bzero_win.c -@HAVE_EXPLICIT_BZERO_FALSE@@HOST_WIN_FALSE@am__append_8 = compat/explicit_bzero.c -@HAVE_STRLCAT_FALSE@am__append_9 = compat/strlcat.c -@HAVE_STRLCPY_FALSE@am__append_10 = compat/strlcpy.c -@HAVE_STRNDUP_FALSE@am__append_11 = compat/strndup.c +@HAVE_EXPLICIT_BZERO_FALSE@am__append_5 = libcompatnoopt.la +@HAVE_EXPLICIT_BZERO_FALSE@@HOST_WIN_TRUE@am__append_6 = compat/explicit_bzero_win.c +@HAVE_EXPLICIT_BZERO_FALSE@@HOST_WIN_FALSE@am__append_7 = compat/explicit_bzero.c +@HAVE_STRLCAT_FALSE@am__append_8 = compat/strlcat.c +@HAVE_STRLCPY_FALSE@am__append_9 = compat/strlcpy.c +@HAVE_STRNDUP_FALSE@am__append_10 = compat/strndup.c # the only user of strnlen is strndup, so only build it if needed -@HAVE_STRNDUP_FALSE@@HAVE_STRNLEN_FALSE@am__append_12 = compat/strnlen.c -@HAVE_STRSEP_FALSE@am__append_13 = compat/strsep.c -@HAVE_STRTONUM_FALSE@am__append_14 = compat/strtonum.c -@HAVE_ASPRINTF_FALSE@am__append_15 = compat/bsd-asprintf.c -@HAVE_FREEZERO_FALSE@am__append_16 = compat/freezero.c -@HAVE_GETPAGESIZE_FALSE@am__append_17 = compat/getpagesize.c -@HAVE_GETPROGNAME_FALSE@@HOST_LINUX_TRUE@am__append_18 = compat/getprogname_linux.c -@HAVE_GETPROGNAME_FALSE@@HOST_LINUX_FALSE@@HOST_WIN_TRUE@am__append_19 = compat/getprogname_windows.c -@HAVE_GETPROGNAME_FALSE@@HOST_LINUX_FALSE@@HOST_WIN_FALSE@am__append_20 = compat/getprogname_unimpl.c -@HAVE_TIMEGM_FALSE@am__append_21 = compat/timegm.c -@HAVE_REALLOCARRAY_FALSE@am__append_22 = compat/reallocarray.c -@HAVE_RECALLOCARRAY_FALSE@am__append_23 = compat/recallocarray.c -@HAVE_SYSLOG_R_FALSE@am__append_24 = compat/syslog_r.c -@HAVE_TIMINGSAFE_MEMCMP_FALSE@am__append_25 = compat/timingsafe_memcmp.c -@HAVE_TIMINGSAFE_BCMP_FALSE@am__append_26 = compat/timingsafe_bcmp.c -@HOST_WIN_TRUE@am__append_27 = compat/posix_win.c -@HAVE_ARC4RANDOM_BUF_FALSE@am__append_28 = compat/arc4random.c \ +@HAVE_STRNDUP_FALSE@@HAVE_STRNLEN_FALSE@am__append_11 = compat/strnlen.c +@HAVE_STRSEP_FALSE@am__append_12 = compat/strsep.c +@HAVE_STRTONUM_FALSE@am__append_13 = compat/strtonum.c +@HAVE_ASPRINTF_FALSE@am__append_14 = compat/bsd-asprintf.c +@HAVE_FREEZERO_FALSE@am__append_15 = compat/freezero.c +@HAVE_GETPAGESIZE_FALSE@am__append_16 = compat/getpagesize.c +@HAVE_GETPROGNAME_FALSE@@HOST_LINUX_TRUE@am__append_17 = compat/getprogname_linux.c +@HAVE_GETPROGNAME_FALSE@@HOST_LINUX_FALSE@@HOST_WIN_TRUE@am__append_18 = compat/getprogname_windows.c +@HAVE_GETPROGNAME_FALSE@@HOST_LINUX_FALSE@@HOST_WIN_FALSE@am__append_19 = compat/getprogname_unimpl.c +@HAVE_TIMEGM_FALSE@am__append_20 = compat/timegm.c +@HAVE_REALLOCARRAY_FALSE@am__append_21 = compat/reallocarray.c +@HAVE_RECALLOCARRAY_FALSE@am__append_22 = compat/recallocarray.c +@HAVE_SYSLOG_R_FALSE@am__append_23 = compat/syslog_r.c +@HAVE_TIMINGSAFE_MEMCMP_FALSE@am__append_24 = compat/timingsafe_memcmp.c +@HAVE_TIMINGSAFE_BCMP_FALSE@am__append_25 = compat/timingsafe_bcmp.c +@HOST_WIN_TRUE@am__append_26 = compat/posix_win.c +@HAVE_ARC4RANDOM_BUF_FALSE@am__append_27 = compat/arc4random.c \ @HAVE_ARC4RANDOM_BUF_FALSE@ compat/arc4random_uniform.c -@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_AIX_TRUE@am__append_29 = compat/getentropy_aix.c -@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_FREEBSD_TRUE@am__append_30 = compat/getentropy_freebsd.c -@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_HPUX_TRUE@am__append_31 = compat/getentropy_hpux.c -@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_LINUX_TRUE@am__append_32 = compat/getentropy_linux.c -@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_NETBSD_TRUE@am__append_33 = compat/getentropy_netbsd.c -@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_DARWIN_TRUE@am__append_34 = compat/getentropy_osx.c -@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_SOLARIS_TRUE@am__append_35 = compat/getentropy_solaris.c -@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_WIN_TRUE@am__append_36 = compat/getentropy_win.c -@HOST_ASM_ELF_ARM_TRUE@am__append_37 = -DAES_ASM -DOPENSSL_BN_ASM_MONT \ +@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_AIX_TRUE@am__append_28 = compat/getentropy_aix.c +@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_FREEBSD_TRUE@am__append_29 = compat/getentropy_freebsd.c +@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_HPUX_TRUE@am__append_30 = compat/getentropy_hpux.c +@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_LINUX_TRUE@am__append_31 = compat/getentropy_linux.c +@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_NETBSD_TRUE@am__append_32 = compat/getentropy_netbsd.c +@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_DARWIN_TRUE@am__append_33 = compat/getentropy_osx.c +@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_SOLARIS_TRUE@am__append_34 = compat/getentropy_solaris.c +@HAVE_ARC4RANDOM_BUF_FALSE@@HAVE_GETENTROPY_FALSE@@HOST_WIN_TRUE@am__append_35 = compat/getentropy_win.c +@HOST_ASM_ELF_ARM_TRUE@am__append_36 = -DAES_ASM -DOPENSSL_BN_ASM_MONT \ @HOST_ASM_ELF_ARM_TRUE@ -DOPENSSL_BN_ASM_GF2m -DGHASH_ASM \ @HOST_ASM_ELF_ARM_TRUE@ -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM \ @HOST_ASM_ELF_ARM_TRUE@ -DOPENSSL_CPUID_OBJ -@HOST_ASM_ELF_ARM_TRUE@am__append_38 = $(ASM_ARM_ELF) -@HOST_ASM_ELF_X86_64_TRUE@am__append_39 = -DAES_ASM -DBSAES_ASM \ +@HOST_ASM_ELF_ARM_TRUE@am__append_37 = $(ASM_ARM_ELF) +@HOST_ASM_ELF_MIPS_TRUE@am__append_38 = -DAES_ASM \ +@HOST_ASM_ELF_MIPS_TRUE@ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM \ +@HOST_ASM_ELF_MIPS_TRUE@ -DSHA256_ASM -DSHA512_ASM +@HOST_ASM_ELF_MIPS_TRUE@am__append_39 = $(ASM_MIPS_ELF) +@HOST_ASM_ELF_MIPS64_TRUE@am__append_40 = -DAES_ASM \ +@HOST_ASM_ELF_MIPS64_TRUE@ -DOPENSSL_BN_ASM_MONT -DSHA1_ASM \ +@HOST_ASM_ELF_MIPS64_TRUE@ -DSHA256_ASM -DSHA512_ASM +@HOST_ASM_ELF_MIPS64_TRUE@am__append_41 = $(ASM_MIPS64_ELF) +@HOST_ASM_ELF_X86_64_TRUE@am__append_42 = -DAES_ASM -DBSAES_ASM \ @HOST_ASM_ELF_X86_64_TRUE@ -DVPAES_ASM -DOPENSSL_IA32_SSE2 \ @HOST_ASM_ELF_X86_64_TRUE@ -DOPENSSL_BN_ASM_MONT \ @HOST_ASM_ELF_X86_64_TRUE@ -DOPENSSL_BN_ASM_MONT5 \ @@ -142,8 +149,8 @@ host_triplet = @host@ @HOST_ASM_ELF_X86_64_TRUE@ -DGHASH_ASM -DRSA_ASM -DSHA1_ASM \ @HOST_ASM_ELF_X86_64_TRUE@ -DSHA256_ASM -DSHA512_ASM \ @HOST_ASM_ELF_X86_64_TRUE@ -DWHIRLPOOL_ASM -DOPENSSL_CPUID_OBJ -@HOST_ASM_ELF_X86_64_TRUE@am__append_40 = $(ASM_X86_64_ELF) -@HOST_ASM_MACOSX_X86_64_TRUE@am__append_41 = -DAES_ASM -DBSAES_ASM \ +@HOST_ASM_ELF_X86_64_TRUE@am__append_43 = $(ASM_X86_64_ELF) +@HOST_ASM_MACOSX_X86_64_TRUE@am__append_44 = -DAES_ASM -DBSAES_ASM \ @HOST_ASM_MACOSX_X86_64_TRUE@ -DVPAES_ASM -DOPENSSL_IA32_SSE2 \ @HOST_ASM_MACOSX_X86_64_TRUE@ -DOPENSSL_BN_ASM_MONT \ @HOST_ASM_MACOSX_X86_64_TRUE@ -DOPENSSL_BN_ASM_MONT5 \ @@ -152,8 +159,8 @@ host_triplet = @host@ @HOST_ASM_MACOSX_X86_64_TRUE@ -DSHA256_ASM -DSHA512_ASM \ @HOST_ASM_MACOSX_X86_64_TRUE@ -DWHIRLPOOL_ASM \ @HOST_ASM_MACOSX_X86_64_TRUE@ -DOPENSSL_CPUID_OBJ -@HOST_ASM_MACOSX_X86_64_TRUE@am__append_42 = $(ASM_X86_64_MACOSX) -@HOST_ASM_MASM_X86_64_TRUE@am__append_43 = -DAES_ASM -DBSAES_ASM \ +@HOST_ASM_MACOSX_X86_64_TRUE@am__append_45 = $(ASM_X86_64_MACOSX) +@HOST_ASM_MASM_X86_64_TRUE@am__append_46 = -DAES_ASM -DBSAES_ASM \ @HOST_ASM_MASM_X86_64_TRUE@ -DVPAES_ASM -DOPENSSL_IA32_SSE2 \ @HOST_ASM_MASM_X86_64_TRUE@ -DOPENSSL_BN_ASM_MONT \ @HOST_ASM_MASM_X86_64_TRUE@ -DOPENSSL_BN_ASM_MONT5 \ @@ -161,31 +168,44 @@ host_triplet = @host@ @HOST_ASM_MASM_X86_64_TRUE@ -DGHASH_ASM -DRSA_ASM -DSHA1_ASM \ @HOST_ASM_MASM_X86_64_TRUE@ -DSHA256_ASM -DSHA512_ASM \ @HOST_ASM_MASM_X86_64_TRUE@ -DWHIRLPOOL_ASM -DOPENSSL_CPUID_OBJ -@HOST_ASM_MASM_X86_64_TRUE@am__append_44 = $(ASM_X86_64_MASM) +@HOST_ASM_MASM_X86_64_TRUE@am__append_47 = $(ASM_X86_64_MASM) #libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT #libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_MONT5 #libcrypto_la_CPPFLAGS += -DOPENSSL_BN_ASM_GF2m -@HOST_ASM_MINGW64_X86_64_TRUE@am__append_45 = -DAES_ASM -DBSAES_ASM \ +@HOST_ASM_MINGW64_X86_64_TRUE@am__append_48 = -DAES_ASM -DBSAES_ASM \ @HOST_ASM_MINGW64_X86_64_TRUE@ -DVPAES_ASM -DOPENSSL_IA32_SSE2 \ @HOST_ASM_MINGW64_X86_64_TRUE@ -DMD5_ASM -DGHASH_ASM -DRSA_ASM \ @HOST_ASM_MINGW64_X86_64_TRUE@ -DSHA1_ASM -DSHA256_ASM \ @HOST_ASM_MINGW64_X86_64_TRUE@ -DSHA512_ASM -DWHIRLPOOL_ASM \ @HOST_ASM_MINGW64_X86_64_TRUE@ -DOPENSSL_CPUID_OBJ -@HOST_ASM_MINGW64_X86_64_TRUE@am__append_46 = $(ASM_X86_64_MINGW64) -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@am__append_47 = aes/aes_cbc.c \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ aes/aes_core.c \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ camellia/camellia.c \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ camellia/cmll_cbc.c \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ rc4/rc4_enc.c \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ rc4/rc4_skey.c \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ whrlpool/wp_block.c -@HOST_WIN_FALSE@am__append_48 = crypto_lock.c -@HOST_WIN_TRUE@am__append_49 = compat/crypto_lock_win.c -@HOST_WIN_FALSE@am__append_50 = bio/b_posix.c -@HOST_WIN_TRUE@am__append_51 = bio/b_win.c -@HOST_WIN_FALSE@am__append_52 = bio/bss_log.c -@HOST_WIN_FALSE@am__append_53 = ui/ui_openssl.c -@HOST_WIN_TRUE@am__append_54 = ui/ui_openssl_win.c +@HOST_ASM_MINGW64_X86_64_TRUE@am__append_49 = $(ASM_X86_64_MINGW64) +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@am__append_50 = -DOPENSSL_NO_ASM +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@am__append_51 = aes/aes_cbc.c \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ aes/aes_core.c \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ camellia/camellia.c \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ camellia/cmll_cbc.c \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ rc4/rc4_enc.c \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ rc4/rc4_skey.c \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ whrlpool/wp_block.c +@HOST_WIN_FALSE@am__append_52 = crypto_lock.c +@HOST_WIN_TRUE@am__append_53 = compat/crypto_lock_win.c +@HOST_WIN_FALSE@am__append_54 = bio/b_posix.c +@HOST_WIN_TRUE@am__append_55 = bio/b_win.c +@HOST_WIN_FALSE@am__append_56 = bio/bss_log.c + +# bn/arch +@HOST_AARCH64_TRUE@am__append_57 = -I$(top_srcdir)/crypto/bn/arch/aarch64/ +@HOST_ARM_TRUE@am__append_58 = -I$(top_srcdir)/crypto/bn/arch/arm/ +@HOST_I386_TRUE@am__append_59 = -I$(top_srcdir)/crypto/bn/arch/i386/ +@HOST_MIPS_TRUE@am__append_60 = -I$(top_srcdir)/crypto/bn/arch/mips/ +@HOST_MIPS64_TRUE@am__append_61 = -I$(top_srcdir)/crypto/bn/arch/mips64/ +@HOST_POWERPC_TRUE@am__append_62 = -I$(top_srcdir)/crypto/bn/arch/powerpc/ +@HOST_POWERPC64_TRUE@am__append_63 = -I$(top_srcdir)/crypto/bn/arch/powerpc64/ +@HOST_RISCV64_TRUE@am__append_64 = -I$(top_srcdir)/crypto/bn/arch/riscv64/ +@HOST_SPARC64_TRUE@am__append_65 = -I$(top_srcdir)/crypto/bn/arch/sparc64/ +@HOST_X86_64_TRUE@am__append_66 = -I$(top_srcdir)/crypto/bn/arch/amd64/ +@HOST_WIN_FALSE@am__append_67 = ui/ui_openssl.c +@HOST_WIN_TRUE@am__append_68 = ui/ui_openssl_win.c subdir = crypto ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_add_fortify_source.m4 \ @@ -315,16 +335,24 @@ am__libcrypto_la_SOURCES_DIST = aes/aes-elf-armv4.S \ sha/sha512-elf-armv4.S sha/sha256-elf-armv4.S \ modes/ghash-elf-armv4.S armv4cpuid.S armcap.c aes/aes_cbc.c \ camellia/camellia.c camellia/cmll_cbc.c rc4/rc4_enc.c \ - rc4/rc4_skey.c whrlpool/wp_block.c aes/aes-elf-x86_64.S \ - aes/bsaes-elf-x86_64.S aes/vpaes-elf-x86_64.S \ - aes/aesni-elf-x86_64.S aes/aesni-sha1-elf-x86_64.S \ - bn/modexp512-elf-x86_64.S bn/mont-elf-x86_64.S \ - bn/mont5-elf-x86_64.S bn/gf2m-elf-x86_64.S \ - camellia/cmll-elf-x86_64.S md5/md5-elf-x86_64.S \ - modes/ghash-elf-x86_64.S rc4/rc4-elf-x86_64.S \ - rc4/rc4-md5-elf-x86_64.S sha/sha1-elf-x86_64.S \ - sha/sha256-elf-x86_64.S sha/sha512-elf-x86_64.S \ - whrlpool/wp-elf-x86_64.S cpuid-elf-x86_64.S \ + rc4/rc4_skey.c whrlpool/wp_block.c aes/aes-mips.S bn/bn-mips.S \ + bn/mont-mips.S sha/sha1-mips.S sha/sha512-mips.S \ + sha/sha256-mips.S aes/aes-elf-x86_64.S aes/bsaes-elf-x86_64.S \ + aes/vpaes-elf-x86_64.S aes/aesni-elf-x86_64.S \ + aes/aesni-sha1-elf-x86_64.S bn/modexp512-elf-x86_64.S \ + bn/mont-elf-x86_64.S bn/mont5-elf-x86_64.S \ + bn/gf2m-elf-x86_64.S camellia/cmll-elf-x86_64.S \ + md5/md5-elf-x86_64.S modes/ghash-elf-x86_64.S \ + rc4/rc4-elf-x86_64.S rc4/rc4-md5-elf-x86_64.S \ + sha/sha1-elf-x86_64.S sha/sha256-elf-x86_64.S \ + sha/sha512-elf-x86_64.S whrlpool/wp-elf-x86_64.S \ + cpuid-elf-x86_64.S bn/arch/amd64/bignum_add.S \ + bn/arch/amd64/bignum_cmadd.S bn/arch/amd64/bignum_cmul.S \ + bn/arch/amd64/bignum_mul.S bn/arch/amd64/bignum_mul_4_8_alt.S \ + bn/arch/amd64/bignum_mul_8_16_alt.S bn/arch/amd64/bignum_sqr.S \ + bn/arch/amd64/bignum_sqr_4_8_alt.S \ + bn/arch/amd64/bignum_sqr_8_16_alt.S bn/arch/amd64/bignum_sub.S \ + bn/arch/amd64/word_clz.S bn/arch/amd64/bn_arch.c \ aes/aes-macosx-x86_64.S aes/bsaes-macosx-x86_64.S \ aes/vpaes-macosx-x86_64.S aes/aesni-macosx-x86_64.S \ aes/aesni-sha1-macosx-x86_64.S bn/modexp512-macosx-x86_64.S \ @@ -354,38 +382,38 @@ am__libcrypto_la_SOURCES_DIST = aes/aes-elf-armv4.S \ cpuid-mingw64-x86_64.S aes/aes_core.c cpt_err.c cryptlib.c \ crypto_init.c crypto_lock.c compat/crypto_lock_win.c \ cversion.c ex_data.c malloc-wrapper.c mem_clr.c mem_dbg.c \ - o_fips.c o_init.c o_str.c o_time.c aes/aes_cfb.c aes/aes_ctr.c \ + o_fips.c o_init.c o_str.c aes/aes_cfb.c aes/aes_ctr.c \ aes/aes_ecb.c aes/aes_ige.c aes/aes_misc.c aes/aes_ofb.c \ aes/aes_wrap.c asn1/a_bitstr.c asn1/a_enum.c asn1/a_int.c \ asn1/a_mbstr.c asn1/a_object.c asn1/a_octet.c asn1/a_pkey.c \ asn1/a_print.c asn1/a_pubkey.c asn1/a_strex.c asn1/a_string.c \ - asn1/a_strnid.c asn1/a_time.c asn1/a_time_tm.c asn1/a_type.c \ - asn1/a_utf8.c asn1/ameth_lib.c asn1/asn1_err.c asn1/asn1_gen.c \ - asn1/asn1_item.c asn1/asn1_lib.c asn1/asn1_old.c \ - asn1/asn1_old_lib.c asn1/asn1_par.c asn1/asn1_types.c \ - asn1/asn_mime.c asn1/asn_moid.c asn1/bio_asn1.c \ - asn1/bio_ndef.c asn1/nsseq.c asn1/p5_pbe.c asn1/p5_pbev2.c \ - asn1/p8_pkey.c asn1/t_crl.c asn1/t_pkey.c asn1/t_req.c \ - asn1/t_spki.c asn1/t_x509.c asn1/t_x509a.c asn1/tasn_dec.c \ - asn1/tasn_enc.c asn1/tasn_fre.c asn1/tasn_new.c \ - asn1/tasn_prn.c asn1/tasn_typ.c asn1/tasn_utl.c asn1/x_algor.c \ - asn1/x_attrib.c asn1/x_bignum.c asn1/x_crl.c asn1/x_exten.c \ - asn1/x_info.c asn1/x_long.c asn1/x_name.c asn1/x_pkey.c \ - asn1/x_pubkey.c asn1/x_req.c asn1/x_sig.c asn1/x_spki.c \ - asn1/x_val.c asn1/x_x509.c asn1/x_x509a.c bf/bf_cfb64.c \ - bf/bf_ecb.c bf/bf_enc.c bf/bf_ofb64.c bf/bf_skey.c \ - bio/b_dump.c bio/b_posix.c bio/b_print.c bio/b_sock.c \ - bio/b_win.c bio/bf_buff.c bio/bf_nbio.c bio/bf_null.c \ - bio/bio_cb.c bio/bio_err.c bio/bio_lib.c bio/bio_meth.c \ - bio/bss_acpt.c bio/bss_bio.c bio/bss_conn.c bio/bss_dgram.c \ - bio/bss_fd.c bio/bss_file.c bio/bss_log.c bio/bss_mem.c \ - bio/bss_null.c bio/bss_sock.c bn/bn_add.c bn/bn_asm.c \ - bn/bn_blind.c bn/bn_bpsw.c bn/bn_const.c bn/bn_ctx.c \ - bn/bn_depr.c bn/bn_div.c bn/bn_err.c bn/bn_exp.c bn/bn_exp2.c \ - bn/bn_gcd.c bn/bn_gf2m.c bn/bn_isqrt.c bn/bn_kron.c \ - bn/bn_lib.c bn/bn_mod.c bn/bn_mont.c bn/bn_mpi.c bn/bn_mul.c \ - bn/bn_nist.c bn/bn_prime.c bn/bn_print.c bn/bn_rand.c \ - bn/bn_recp.c bn/bn_shift.c bn/bn_sqr.c bn/bn_sqrt.c \ + asn1/a_strnid.c asn1/a_time.c asn1/a_time_posix.c \ + asn1/a_time_tm.c asn1/a_type.c asn1/a_utf8.c asn1/ameth_lib.c \ + asn1/asn1_err.c asn1/asn1_gen.c asn1/asn1_item.c \ + asn1/asn1_lib.c asn1/asn1_old.c asn1/asn1_old_lib.c \ + asn1/asn1_par.c asn1/asn1_types.c asn1/asn_mime.c \ + asn1/asn_moid.c asn1/bio_asn1.c asn1/bio_ndef.c asn1/nsseq.c \ + asn1/p5_pbe.c asn1/p5_pbev2.c asn1/p8_pkey.c asn1/t_crl.c \ + asn1/t_pkey.c asn1/t_req.c asn1/t_spki.c asn1/t_x509.c \ + asn1/t_x509a.c asn1/tasn_dec.c asn1/tasn_enc.c asn1/tasn_fre.c \ + asn1/tasn_new.c asn1/tasn_prn.c asn1/tasn_typ.c \ + asn1/tasn_utl.c asn1/x_algor.c asn1/x_attrib.c asn1/x_bignum.c \ + asn1/x_crl.c asn1/x_exten.c asn1/x_info.c asn1/x_long.c \ + asn1/x_name.c asn1/x_pkey.c asn1/x_pubkey.c asn1/x_req.c \ + asn1/x_sig.c asn1/x_spki.c asn1/x_val.c asn1/x_x509.c \ + asn1/x_x509a.c bf/bf_cfb64.c bf/bf_ecb.c bf/bf_enc.c \ + bf/bf_ofb64.c bf/bf_skey.c bio/b_dump.c bio/b_posix.c \ + bio/b_print.c bio/b_sock.c bio/b_win.c bio/bf_buff.c \ + bio/bf_nbio.c bio/bf_null.c bio/bio_cb.c bio/bio_err.c \ + bio/bio_lib.c bio/bio_meth.c bio/bss_acpt.c bio/bss_bio.c \ + bio/bss_conn.c bio/bss_dgram.c bio/bss_fd.c bio/bss_file.c \ + bio/bss_log.c bio/bss_mem.c bio/bss_null.c bio/bss_sock.c \ + bn/bn_add.c bn/bn_blind.c bn/bn_bpsw.c bn/bn_const.c \ + bn/bn_ctx.c bn/bn_div.c bn/bn_err.c bn/bn_exp.c bn/bn_gcd.c \ + bn/bn_gf2m.c bn/bn_isqrt.c bn/bn_kron.c bn/bn_lib.c \ + bn/bn_mod.c bn/bn_mont.c bn/bn_mpi.c bn/bn_mul.c bn/bn_nist.c \ + bn/bn_prime.c bn/bn_print.c bn/bn_rand.c bn/bn_recp.c \ + bn/bn_shift.c bn/bn_small_primes.c bn/bn_sqr.c bn/bn_sqrt.c \ bn/bn_word.c bn/bn_x931p.c buffer/buf_err.c buffer/buf_str.c \ buffer/buffer.c bytestring/bs_ber.c bytestring/bs_cbb.c \ bytestring/bs_cbs.c camellia/cmll_cfb.c camellia/cmll_ctr.c \ @@ -412,27 +440,27 @@ am__libcrypto_la_SOURCES_DIST = aes/aes-elf-armv4.S \ dh/dh_lib.c dh/dh_pmeth.c dh/dh_prn.c dsa/dsa_ameth.c \ dsa/dsa_asn1.c dsa/dsa_depr.c dsa/dsa_err.c dsa/dsa_gen.c \ dsa/dsa_key.c dsa/dsa_lib.c dsa/dsa_meth.c dsa/dsa_ossl.c \ - dsa/dsa_pmeth.c dsa/dsa_prn.c dsa/dsa_sign.c dsa/dsa_vrf.c \ - dso/dso_dlfcn.c dso/dso_err.c dso/dso_lib.c dso/dso_null.c \ - dso/dso_openssl.c ec/ec2_mult.c ec/ec2_oct.c ec/ec2_smpl.c \ - ec/ec_ameth.c ec/ec_asn1.c ec/ec_check.c ec/ec_curve.c \ - ec/ec_cvt.c ec/ec_err.c ec/ec_key.c ec/ec_kmeth.c ec/ec_lib.c \ - ec/ec_mult.c ec/ec_oct.c ec/ec_pmeth.c ec/ec_print.c \ - ec/eck_prn.c ec/ecp_mont.c ec/ecp_nist.c ec/ecp_oct.c \ - ec/ecp_smpl.c ecdh/ecdh_kdf.c ecdh/ech_err.c ecdh/ech_key.c \ - ecdh/ech_lib.c ecdsa/ecs_asn1.c ecdsa/ecs_err.c \ - ecdsa/ecs_lib.c ecdsa/ecs_ossl.c ecdsa/ecs_sign.c \ - ecdsa/ecs_vrf.c engine/eng_all.c engine/eng_cnf.c \ - engine/eng_ctrl.c engine/eng_dyn.c engine/eng_err.c \ - engine/eng_fat.c engine/eng_init.c engine/eng_lib.c \ - engine/eng_list.c engine/eng_openssl.c engine/eng_pkey.c \ - engine/eng_table.c engine/tb_asnmth.c engine/tb_cipher.c \ - engine/tb_dh.c engine/tb_digest.c engine/tb_dsa.c \ - engine/tb_ecdh.c engine/tb_ecdsa.c engine/tb_eckey.c \ - engine/tb_pkmeth.c engine/tb_rand.c engine/tb_rsa.c \ - engine/tb_store.c err/err.c err/err_all.c err/err_prn.c \ - evp/bio_b64.c evp/bio_enc.c evp/bio_md.c evp/c_all.c \ - evp/digest.c evp/e_aes.c evp/e_aes_cbc_hmac_sha1.c evp/e_bf.c \ + dsa/dsa_pmeth.c dsa/dsa_prn.c dso/dso_dlfcn.c dso/dso_err.c \ + dso/dso_lib.c dso/dso_null.c dso/dso_openssl.c ec/ec2_mult.c \ + ec/ec2_oct.c ec/ec2_smpl.c ec/ec_ameth.c ec/ec_asn1.c \ + ec/ec_check.c ec/ec_curve.c ec/ec_cvt.c ec/ec_err.c \ + ec/ec_key.c ec/ec_kmeth.c ec/ec_lib.c ec/ec_mult.c ec/ec_oct.c \ + ec/ec_pmeth.c ec/ec_print.c ec/eck_prn.c ec/ecp_mont.c \ + ec/ecp_nist.c ec/ecp_oct.c ec/ecp_smpl.c ec/ecx_methods.c \ + ecdh/ecdh_kdf.c ecdh/ech_err.c ecdh/ech_key.c ecdh/ech_lib.c \ + ecdsa/ecs_asn1.c ecdsa/ecs_err.c ecdsa/ecs_lib.c \ + ecdsa/ecs_ossl.c ecdsa/ecs_sign.c ecdsa/ecs_vrf.c \ + engine/eng_all.c engine/eng_cnf.c engine/eng_ctrl.c \ + engine/eng_dyn.c engine/eng_err.c engine/eng_fat.c \ + engine/eng_init.c engine/eng_lib.c engine/eng_list.c \ + engine/eng_openssl.c engine/eng_pkey.c engine/eng_table.c \ + engine/tb_asnmth.c engine/tb_cipher.c engine/tb_dh.c \ + engine/tb_digest.c engine/tb_dsa.c engine/tb_ecdh.c \ + engine/tb_ecdsa.c engine/tb_eckey.c engine/tb_pkmeth.c \ + engine/tb_rand.c engine/tb_rsa.c engine/tb_store.c err/err.c \ + err/err_all.c err/err_prn.c evp/bio_b64.c evp/bio_enc.c \ + evp/bio_md.c evp/c_all.c evp/cipher_method_lib.c evp/digest.c \ + evp/e_aes.c evp/e_aes_cbc_hmac_sha1.c evp/e_bf.c \ evp/e_camellia.c evp/e_cast.c evp/e_chacha.c \ evp/e_chacha20poly1305.c evp/e_des.c evp/e_des3.c \ evp/e_gost2814789.c evp/e_idea.c evp/e_null.c evp/e_old.c \ @@ -485,25 +513,25 @@ am__libcrypto_la_SOURCES_DIST = aes/aes-elf-armv4.S \ ts/ts_err.c ts/ts_lib.c ts/ts_req_print.c ts/ts_req_utils.c \ ts/ts_rsp_print.c ts/ts_rsp_sign.c ts/ts_rsp_utils.c \ ts/ts_rsp_verify.c ts/ts_verify_ctx.c txt_db/txt_db.c \ - ui/ui_err.c ui/ui_lib.c ui/ui_openssl.c ui/ui_openssl_win.c \ - ui/ui_util.c whrlpool/wp_dgst.c x509/by_dir.c x509/by_file.c \ - x509/by_mem.c x509/pcy_cache.c x509/pcy_data.c x509/pcy_lib.c \ - x509/pcy_map.c x509/pcy_node.c x509/pcy_tree.c \ - x509/x509_addr.c x509/x509_akey.c x509/x509_akeya.c \ - x509/x509_alt.c x509/x509_att.c x509/x509_asid.c \ - x509/x509_bcons.c x509/x509_bitst.c x509/x509_cmp.c \ - x509/x509_conf.c x509/x509_constraints.c x509/x509_cpols.c \ - x509/x509_crld.c x509/x509_d2.c x509/x509_def.c \ - x509/x509_enum.c x509/x509_err.c x509/x509_ext.c \ - x509/x509_extku.c x509/x509_genn.c x509/x509_ia5.c \ - x509/x509_info.c x509/x509_int.c x509/x509_issuer_cache.c \ - x509/x509_lib.c x509/x509_lu.c x509/x509_ncons.c \ - x509/x509_obj.c x509/x509_ocsp.c x509/x509_pci.c \ - x509/x509_pcia.c x509/x509_pcons.c x509/x509_pku.c \ - x509/x509_pmaps.c x509/x509_prn.c x509/x509_purp.c \ - x509/x509_r2x.c x509/x509_req.c x509/x509_set.c \ - x509/x509_skey.c x509/x509_sxnet.c x509/x509_trs.c \ - x509/x509_txt.c x509/x509_utl.c x509/x509_v3.c \ + ui/ui_err.c ui/ui_lib.c ui/ui_null.c ui/ui_openssl.c \ + ui/ui_openssl_win.c ui/ui_util.c whrlpool/wp_dgst.c \ + x509/by_dir.c x509/by_file.c x509/by_mem.c x509/pcy_cache.c \ + x509/pcy_data.c x509/pcy_lib.c x509/pcy_map.c x509/pcy_node.c \ + x509/pcy_tree.c x509/x509_addr.c x509/x509_akey.c \ + x509/x509_akeya.c x509/x509_alt.c x509/x509_att.c \ + x509/x509_asid.c x509/x509_bcons.c x509/x509_bitst.c \ + x509/x509_cmp.c x509/x509_conf.c x509/x509_constraints.c \ + x509/x509_cpols.c x509/x509_crld.c x509/x509_d2.c \ + x509/x509_def.c x509/x509_enum.c x509/x509_err.c \ + x509/x509_ext.c x509/x509_extku.c x509/x509_genn.c \ + x509/x509_ia5.c x509/x509_info.c x509/x509_int.c \ + x509/x509_issuer_cache.c x509/x509_lib.c x509/x509_lu.c \ + x509/x509_ncons.c x509/x509_obj.c x509/x509_ocsp.c \ + x509/x509_pci.c x509/x509_pcia.c x509/x509_pcons.c \ + x509/x509_pku.c x509/x509_pmaps.c x509/x509_prn.c \ + x509/x509_purp.c x509/x509_r2x.c x509/x509_req.c \ + x509/x509_set.c x509/x509_skey.c x509/x509_sxnet.c \ + x509/x509_trs.c x509/x509_txt.c x509/x509_utl.c x509/x509_v3.c \ x509/x509_verify.c x509/x509_vfy.c x509/x509_vpm.c \ x509/x509cset.c x509/x509name.c x509/x509rset.c \ x509/x509spki.c x509/x509type.c x509/x_all.c @@ -519,7 +547,16 @@ am__objects_31 = aes/libcrypto_la-aes-elf-armv4.lo \ camellia/libcrypto_la-cmll_cbc.lo rc4/libcrypto_la-rc4_enc.lo \ rc4/libcrypto_la-rc4_skey.lo whrlpool/libcrypto_la-wp_block.lo @HOST_ASM_ELF_ARM_TRUE@am__objects_32 = $(am__objects_31) -am__objects_33 = aes/libcrypto_la-aes-elf-x86_64.lo \ +am__objects_33 = aes/libcrypto_la-aes-mips.lo \ + bn/libcrypto_la-bn-mips.lo bn/libcrypto_la-mont-mips.lo \ + sha/libcrypto_la-sha1-mips.lo sha/libcrypto_la-sha512-mips.lo \ + sha/libcrypto_la-sha256-mips.lo aes/libcrypto_la-aes_cbc.lo \ + camellia/libcrypto_la-camellia.lo \ + camellia/libcrypto_la-cmll_cbc.lo rc4/libcrypto_la-rc4_enc.lo \ + rc4/libcrypto_la-rc4_skey.lo whrlpool/libcrypto_la-wp_block.lo +@HOST_ASM_ELF_MIPS_TRUE@am__objects_34 = $(am__objects_33) +@HOST_ASM_ELF_MIPS64_TRUE@am__objects_35 = $(am__objects_33) +am__objects_36 = aes/libcrypto_la-aes-elf-x86_64.lo \ aes/libcrypto_la-bsaes-elf-x86_64.lo \ aes/libcrypto_la-vpaes-elf-x86_64.lo \ aes/libcrypto_la-aesni-elf-x86_64.lo \ @@ -537,9 +574,21 @@ am__objects_33 = aes/libcrypto_la-aes-elf-x86_64.lo \ sha/libcrypto_la-sha256-elf-x86_64.lo \ sha/libcrypto_la-sha512-elf-x86_64.lo \ whrlpool/libcrypto_la-wp-elf-x86_64.lo \ - libcrypto_la-cpuid-elf-x86_64.lo -@HOST_ASM_ELF_X86_64_TRUE@am__objects_34 = $(am__objects_33) -am__objects_35 = aes/libcrypto_la-aes-macosx-x86_64.lo \ + libcrypto_la-cpuid-elf-x86_64.lo \ + bn/arch/amd64/libcrypto_la-bignum_add.lo \ + bn/arch/amd64/libcrypto_la-bignum_cmadd.lo \ + bn/arch/amd64/libcrypto_la-bignum_cmul.lo \ + bn/arch/amd64/libcrypto_la-bignum_mul.lo \ + bn/arch/amd64/libcrypto_la-bignum_mul_4_8_alt.lo \ + bn/arch/amd64/libcrypto_la-bignum_mul_8_16_alt.lo \ + bn/arch/amd64/libcrypto_la-bignum_sqr.lo \ + bn/arch/amd64/libcrypto_la-bignum_sqr_4_8_alt.lo \ + bn/arch/amd64/libcrypto_la-bignum_sqr_8_16_alt.lo \ + bn/arch/amd64/libcrypto_la-bignum_sub.lo \ + bn/arch/amd64/libcrypto_la-word_clz.lo \ + bn/arch/amd64/libcrypto_la-bn_arch.lo +@HOST_ASM_ELF_X86_64_TRUE@am__objects_37 = $(am__objects_36) +am__objects_38 = aes/libcrypto_la-aes-macosx-x86_64.lo \ aes/libcrypto_la-bsaes-macosx-x86_64.lo \ aes/libcrypto_la-vpaes-macosx-x86_64.lo \ aes/libcrypto_la-aesni-macosx-x86_64.lo \ @@ -557,9 +606,21 @@ am__objects_35 = aes/libcrypto_la-aes-macosx-x86_64.lo \ sha/libcrypto_la-sha256-macosx-x86_64.lo \ sha/libcrypto_la-sha512-macosx-x86_64.lo \ whrlpool/libcrypto_la-wp-macosx-x86_64.lo \ - libcrypto_la-cpuid-macosx-x86_64.lo -@HOST_ASM_MACOSX_X86_64_TRUE@am__objects_36 = $(am__objects_35) -am__objects_37 = aes/libcrypto_la-aes-masm-x86_64.lo \ + libcrypto_la-cpuid-macosx-x86_64.lo \ + bn/arch/amd64/libcrypto_la-bignum_add.lo \ + bn/arch/amd64/libcrypto_la-bignum_cmadd.lo \ + bn/arch/amd64/libcrypto_la-bignum_cmul.lo \ + bn/arch/amd64/libcrypto_la-bignum_mul.lo \ + bn/arch/amd64/libcrypto_la-bignum_mul_4_8_alt.lo \ + bn/arch/amd64/libcrypto_la-bignum_mul_8_16_alt.lo \ + bn/arch/amd64/libcrypto_la-bignum_sqr.lo \ + bn/arch/amd64/libcrypto_la-bignum_sqr_4_8_alt.lo \ + bn/arch/amd64/libcrypto_la-bignum_sqr_8_16_alt.lo \ + bn/arch/amd64/libcrypto_la-bignum_sub.lo \ + bn/arch/amd64/libcrypto_la-word_clz.lo \ + bn/arch/amd64/libcrypto_la-bn_arch.lo +@HOST_ASM_MACOSX_X86_64_TRUE@am__objects_39 = $(am__objects_38) +am__objects_40 = aes/libcrypto_la-aes-masm-x86_64.lo \ aes/libcrypto_la-bsaes-masm-x86_64.lo \ aes/libcrypto_la-vpaes-masm-x86_64.lo \ aes/libcrypto_la-aesni-masm-x86_64.lo \ @@ -578,8 +639,8 @@ am__objects_37 = aes/libcrypto_la-aes-masm-x86_64.lo \ sha/libcrypto_la-sha512-masm-x86_64.lo \ whrlpool/libcrypto_la-wp-masm-x86_64.lo \ libcrypto_la-cpuid-masm-x86_64.lo -@HOST_ASM_MASM_X86_64_TRUE@am__objects_38 = $(am__objects_37) -am__objects_39 = aes/libcrypto_la-aes-mingw64-x86_64.lo \ +@HOST_ASM_MASM_X86_64_TRUE@am__objects_41 = $(am__objects_40) +am__objects_42 = aes/libcrypto_la-aes-mingw64-x86_64.lo \ aes/libcrypto_la-bsaes-mingw64-x86_64.lo \ aes/libcrypto_la-vpaes-mingw64-x86_64.lo \ aes/libcrypto_la-aesni-mingw64-x86_64.lo \ @@ -594,41 +655,42 @@ am__objects_39 = aes/libcrypto_la-aes-mingw64-x86_64.lo \ sha/libcrypto_la-sha512-mingw64-x86_64.lo \ whrlpool/libcrypto_la-wp-mingw64-x86_64.lo \ libcrypto_la-cpuid-mingw64-x86_64.lo -@HOST_ASM_MINGW64_X86_64_TRUE@am__objects_40 = $(am__objects_39) -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@am__objects_41 = aes/libcrypto_la-aes_cbc.lo \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ aes/libcrypto_la-aes_core.lo \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ camellia/libcrypto_la-camellia.lo \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ camellia/libcrypto_la-cmll_cbc.lo \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ rc4/libcrypto_la-rc4_enc.lo \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ rc4/libcrypto_la-rc4_skey.lo \ -@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ whrlpool/libcrypto_la-wp_block.lo -@HOST_WIN_FALSE@am__objects_42 = libcrypto_la-crypto_lock.lo -@HOST_WIN_TRUE@am__objects_43 = \ +@HOST_ASM_MINGW64_X86_64_TRUE@am__objects_43 = $(am__objects_42) +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@am__objects_44 = aes/libcrypto_la-aes_cbc.lo \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ aes/libcrypto_la-aes_core.lo \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ camellia/libcrypto_la-camellia.lo \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ camellia/libcrypto_la-cmll_cbc.lo \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ rc4/libcrypto_la-rc4_enc.lo \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ rc4/libcrypto_la-rc4_skey.lo \ +@HOST_ASM_ELF_ARM_FALSE@@HOST_ASM_ELF_MIPS64_FALSE@@HOST_ASM_ELF_MIPS_FALSE@@HOST_ASM_ELF_X86_64_FALSE@@HOST_ASM_MACOSX_X86_64_FALSE@@HOST_ASM_MASM_X86_64_FALSE@@HOST_ASM_MINGW64_X86_64_FALSE@ whrlpool/libcrypto_la-wp_block.lo +@HOST_WIN_FALSE@am__objects_45 = libcrypto_la-crypto_lock.lo +@HOST_WIN_TRUE@am__objects_46 = \ @HOST_WIN_TRUE@ compat/libcrypto_la-crypto_lock_win.lo -@HOST_WIN_FALSE@am__objects_44 = bio/libcrypto_la-b_posix.lo -@HOST_WIN_TRUE@am__objects_45 = bio/libcrypto_la-b_win.lo -@HOST_WIN_FALSE@am__objects_46 = bio/libcrypto_la-bss_log.lo -@HOST_WIN_FALSE@am__objects_47 = ui/libcrypto_la-ui_openssl.lo -@HOST_WIN_TRUE@am__objects_48 = ui/libcrypto_la-ui_openssl_win.lo +@HOST_WIN_FALSE@am__objects_47 = bio/libcrypto_la-b_posix.lo +@HOST_WIN_TRUE@am__objects_48 = bio/libcrypto_la-b_win.lo +@HOST_WIN_FALSE@am__objects_49 = bio/libcrypto_la-bss_log.lo +@HOST_WIN_FALSE@am__objects_50 = ui/libcrypto_la-ui_openssl.lo +@HOST_WIN_TRUE@am__objects_51 = ui/libcrypto_la-ui_openssl_win.lo am_libcrypto_la_OBJECTS = $(am__objects_32) $(am__objects_34) \ - $(am__objects_36) $(am__objects_38) $(am__objects_40) \ - $(am__objects_41) libcrypto_la-cpt_err.lo \ - libcrypto_la-cryptlib.lo libcrypto_la-crypto_init.lo \ - $(am__objects_42) $(am__objects_43) libcrypto_la-cversion.lo \ + $(am__objects_35) $(am__objects_37) $(am__objects_39) \ + $(am__objects_41) $(am__objects_43) $(am__objects_44) \ + libcrypto_la-cpt_err.lo libcrypto_la-cryptlib.lo \ + libcrypto_la-crypto_init.lo $(am__objects_45) \ + $(am__objects_46) libcrypto_la-cversion.lo \ libcrypto_la-ex_data.lo libcrypto_la-malloc-wrapper.lo \ libcrypto_la-mem_clr.lo libcrypto_la-mem_dbg.lo \ libcrypto_la-o_fips.lo libcrypto_la-o_init.lo \ - libcrypto_la-o_str.lo libcrypto_la-o_time.lo \ - aes/libcrypto_la-aes_cfb.lo aes/libcrypto_la-aes_ctr.lo \ - aes/libcrypto_la-aes_ecb.lo aes/libcrypto_la-aes_ige.lo \ - aes/libcrypto_la-aes_misc.lo aes/libcrypto_la-aes_ofb.lo \ - aes/libcrypto_la-aes_wrap.lo asn1/libcrypto_la-a_bitstr.lo \ - asn1/libcrypto_la-a_enum.lo asn1/libcrypto_la-a_int.lo \ - asn1/libcrypto_la-a_mbstr.lo asn1/libcrypto_la-a_object.lo \ - asn1/libcrypto_la-a_octet.lo asn1/libcrypto_la-a_pkey.lo \ - asn1/libcrypto_la-a_print.lo asn1/libcrypto_la-a_pubkey.lo \ - asn1/libcrypto_la-a_strex.lo asn1/libcrypto_la-a_string.lo \ - asn1/libcrypto_la-a_strnid.lo asn1/libcrypto_la-a_time.lo \ + libcrypto_la-o_str.lo aes/libcrypto_la-aes_cfb.lo \ + aes/libcrypto_la-aes_ctr.lo aes/libcrypto_la-aes_ecb.lo \ + aes/libcrypto_la-aes_ige.lo aes/libcrypto_la-aes_misc.lo \ + aes/libcrypto_la-aes_ofb.lo aes/libcrypto_la-aes_wrap.lo \ + asn1/libcrypto_la-a_bitstr.lo asn1/libcrypto_la-a_enum.lo \ + asn1/libcrypto_la-a_int.lo asn1/libcrypto_la-a_mbstr.lo \ + asn1/libcrypto_la-a_object.lo asn1/libcrypto_la-a_octet.lo \ + asn1/libcrypto_la-a_pkey.lo asn1/libcrypto_la-a_print.lo \ + asn1/libcrypto_la-a_pubkey.lo asn1/libcrypto_la-a_strex.lo \ + asn1/libcrypto_la-a_string.lo asn1/libcrypto_la-a_strnid.lo \ + asn1/libcrypto_la-a_time.lo asn1/libcrypto_la-a_time_posix.lo \ asn1/libcrypto_la-a_time_tm.lo asn1/libcrypto_la-a_type.lo \ asn1/libcrypto_la-a_utf8.lo asn1/libcrypto_la-ameth_lib.lo \ asn1/libcrypto_la-asn1_err.lo asn1/libcrypto_la-asn1_gen.lo \ @@ -657,30 +719,29 @@ am_libcrypto_la_OBJECTS = $(am__objects_32) $(am__objects_34) \ asn1/libcrypto_la-x_x509a.lo bf/libcrypto_la-bf_cfb64.lo \ bf/libcrypto_la-bf_ecb.lo bf/libcrypto_la-bf_enc.lo \ bf/libcrypto_la-bf_ofb64.lo bf/libcrypto_la-bf_skey.lo \ - bio/libcrypto_la-b_dump.lo $(am__objects_44) \ + bio/libcrypto_la-b_dump.lo $(am__objects_47) \ bio/libcrypto_la-b_print.lo bio/libcrypto_la-b_sock.lo \ - $(am__objects_45) bio/libcrypto_la-bf_buff.lo \ + $(am__objects_48) bio/libcrypto_la-bf_buff.lo \ bio/libcrypto_la-bf_nbio.lo bio/libcrypto_la-bf_null.lo \ bio/libcrypto_la-bio_cb.lo bio/libcrypto_la-bio_err.lo \ bio/libcrypto_la-bio_lib.lo bio/libcrypto_la-bio_meth.lo \ bio/libcrypto_la-bss_acpt.lo bio/libcrypto_la-bss_bio.lo \ bio/libcrypto_la-bss_conn.lo bio/libcrypto_la-bss_dgram.lo \ bio/libcrypto_la-bss_fd.lo bio/libcrypto_la-bss_file.lo \ - $(am__objects_46) bio/libcrypto_la-bss_mem.lo \ + $(am__objects_49) bio/libcrypto_la-bss_mem.lo \ bio/libcrypto_la-bss_null.lo bio/libcrypto_la-bss_sock.lo \ - bn/libcrypto_la-bn_add.lo bn/libcrypto_la-bn_asm.lo \ - bn/libcrypto_la-bn_blind.lo bn/libcrypto_la-bn_bpsw.lo \ - bn/libcrypto_la-bn_const.lo bn/libcrypto_la-bn_ctx.lo \ - bn/libcrypto_la-bn_depr.lo bn/libcrypto_la-bn_div.lo \ + bn/libcrypto_la-bn_add.lo bn/libcrypto_la-bn_blind.lo \ + bn/libcrypto_la-bn_bpsw.lo bn/libcrypto_la-bn_const.lo \ + bn/libcrypto_la-bn_ctx.lo bn/libcrypto_la-bn_div.lo \ bn/libcrypto_la-bn_err.lo bn/libcrypto_la-bn_exp.lo \ - bn/libcrypto_la-bn_exp2.lo bn/libcrypto_la-bn_gcd.lo \ - bn/libcrypto_la-bn_gf2m.lo bn/libcrypto_la-bn_isqrt.lo \ - bn/libcrypto_la-bn_kron.lo bn/libcrypto_la-bn_lib.lo \ - bn/libcrypto_la-bn_mod.lo bn/libcrypto_la-bn_mont.lo \ - bn/libcrypto_la-bn_mpi.lo bn/libcrypto_la-bn_mul.lo \ - bn/libcrypto_la-bn_nist.lo bn/libcrypto_la-bn_prime.lo \ - bn/libcrypto_la-bn_print.lo bn/libcrypto_la-bn_rand.lo \ - bn/libcrypto_la-bn_recp.lo bn/libcrypto_la-bn_shift.lo \ + bn/libcrypto_la-bn_gcd.lo bn/libcrypto_la-bn_gf2m.lo \ + bn/libcrypto_la-bn_isqrt.lo bn/libcrypto_la-bn_kron.lo \ + bn/libcrypto_la-bn_lib.lo bn/libcrypto_la-bn_mod.lo \ + bn/libcrypto_la-bn_mont.lo bn/libcrypto_la-bn_mpi.lo \ + bn/libcrypto_la-bn_mul.lo bn/libcrypto_la-bn_nist.lo \ + bn/libcrypto_la-bn_prime.lo bn/libcrypto_la-bn_print.lo \ + bn/libcrypto_la-bn_rand.lo bn/libcrypto_la-bn_recp.lo \ + bn/libcrypto_la-bn_shift.lo bn/libcrypto_la-bn_small_primes.lo \ bn/libcrypto_la-bn_sqr.lo bn/libcrypto_la-bn_sqrt.lo \ bn/libcrypto_la-bn_word.lo bn/libcrypto_la-bn_x931p.lo \ buffer/libcrypto_la-buf_err.lo buffer/libcrypto_la-buf_str.lo \ @@ -738,8 +799,7 @@ am_libcrypto_la_OBJECTS = $(am__objects_32) $(am__objects_34) \ dsa/libcrypto_la-dsa_gen.lo dsa/libcrypto_la-dsa_key.lo \ dsa/libcrypto_la-dsa_lib.lo dsa/libcrypto_la-dsa_meth.lo \ dsa/libcrypto_la-dsa_ossl.lo dsa/libcrypto_la-dsa_pmeth.lo \ - dsa/libcrypto_la-dsa_prn.lo dsa/libcrypto_la-dsa_sign.lo \ - dsa/libcrypto_la-dsa_vrf.lo dso/libcrypto_la-dso_dlfcn.lo \ + dsa/libcrypto_la-dsa_prn.lo dso/libcrypto_la-dso_dlfcn.lo \ dso/libcrypto_la-dso_err.lo dso/libcrypto_la-dso_lib.lo \ dso/libcrypto_la-dso_null.lo dso/libcrypto_la-dso_openssl.lo \ ec/libcrypto_la-ec2_mult.lo ec/libcrypto_la-ec2_oct.lo \ @@ -752,16 +812,17 @@ am_libcrypto_la_OBJECTS = $(am__objects_32) $(am__objects_34) \ ec/libcrypto_la-ec_pmeth.lo ec/libcrypto_la-ec_print.lo \ ec/libcrypto_la-eck_prn.lo ec/libcrypto_la-ecp_mont.lo \ ec/libcrypto_la-ecp_nist.lo ec/libcrypto_la-ecp_oct.lo \ - ec/libcrypto_la-ecp_smpl.lo ecdh/libcrypto_la-ecdh_kdf.lo \ - ecdh/libcrypto_la-ech_err.lo ecdh/libcrypto_la-ech_key.lo \ - ecdh/libcrypto_la-ech_lib.lo ecdsa/libcrypto_la-ecs_asn1.lo \ - ecdsa/libcrypto_la-ecs_err.lo ecdsa/libcrypto_la-ecs_lib.lo \ - ecdsa/libcrypto_la-ecs_ossl.lo ecdsa/libcrypto_la-ecs_sign.lo \ - ecdsa/libcrypto_la-ecs_vrf.lo engine/libcrypto_la-eng_all.lo \ - engine/libcrypto_la-eng_cnf.lo engine/libcrypto_la-eng_ctrl.lo \ - engine/libcrypto_la-eng_dyn.lo engine/libcrypto_la-eng_err.lo \ - engine/libcrypto_la-eng_fat.lo engine/libcrypto_la-eng_init.lo \ - engine/libcrypto_la-eng_lib.lo engine/libcrypto_la-eng_list.lo \ + ec/libcrypto_la-ecp_smpl.lo ec/libcrypto_la-ecx_methods.lo \ + ecdh/libcrypto_la-ecdh_kdf.lo ecdh/libcrypto_la-ech_err.lo \ + ecdh/libcrypto_la-ech_key.lo ecdh/libcrypto_la-ech_lib.lo \ + ecdsa/libcrypto_la-ecs_asn1.lo ecdsa/libcrypto_la-ecs_err.lo \ + ecdsa/libcrypto_la-ecs_lib.lo ecdsa/libcrypto_la-ecs_ossl.lo \ + ecdsa/libcrypto_la-ecs_sign.lo ecdsa/libcrypto_la-ecs_vrf.lo \ + engine/libcrypto_la-eng_all.lo engine/libcrypto_la-eng_cnf.lo \ + engine/libcrypto_la-eng_ctrl.lo engine/libcrypto_la-eng_dyn.lo \ + engine/libcrypto_la-eng_err.lo engine/libcrypto_la-eng_fat.lo \ + engine/libcrypto_la-eng_init.lo engine/libcrypto_la-eng_lib.lo \ + engine/libcrypto_la-eng_list.lo \ engine/libcrypto_la-eng_openssl.lo \ engine/libcrypto_la-eng_pkey.lo \ engine/libcrypto_la-eng_table.lo \ @@ -776,6 +837,7 @@ am_libcrypto_la_OBJECTS = $(am__objects_32) $(am__objects_34) \ err/libcrypto_la-err_all.lo err/libcrypto_la-err_prn.lo \ evp/libcrypto_la-bio_b64.lo evp/libcrypto_la-bio_enc.lo \ evp/libcrypto_la-bio_md.lo evp/libcrypto_la-c_all.lo \ + evp/libcrypto_la-cipher_method_lib.lo \ evp/libcrypto_la-digest.lo evp/libcrypto_la-e_aes.lo \ evp/libcrypto_la-e_aes_cbc_hmac_sha1.lo \ evp/libcrypto_la-e_bf.lo evp/libcrypto_la-e_camellia.lo \ @@ -883,16 +945,16 @@ am_libcrypto_la_OBJECTS = $(am__objects_32) $(am__objects_34) \ ts/libcrypto_la-ts_rsp_verify.lo \ ts/libcrypto_la-ts_verify_ctx.lo txt_db/libcrypto_la-txt_db.lo \ ui/libcrypto_la-ui_err.lo ui/libcrypto_la-ui_lib.lo \ - $(am__objects_47) $(am__objects_48) ui/libcrypto_la-ui_util.lo \ - whrlpool/libcrypto_la-wp_dgst.lo x509/libcrypto_la-by_dir.lo \ - x509/libcrypto_la-by_file.lo x509/libcrypto_la-by_mem.lo \ - x509/libcrypto_la-pcy_cache.lo x509/libcrypto_la-pcy_data.lo \ - x509/libcrypto_la-pcy_lib.lo x509/libcrypto_la-pcy_map.lo \ - x509/libcrypto_la-pcy_node.lo x509/libcrypto_la-pcy_tree.lo \ - x509/libcrypto_la-x509_addr.lo x509/libcrypto_la-x509_akey.lo \ - x509/libcrypto_la-x509_akeya.lo x509/libcrypto_la-x509_alt.lo \ - x509/libcrypto_la-x509_att.lo x509/libcrypto_la-x509_asid.lo \ - x509/libcrypto_la-x509_bcons.lo \ + ui/libcrypto_la-ui_null.lo $(am__objects_50) $(am__objects_51) \ + ui/libcrypto_la-ui_util.lo whrlpool/libcrypto_la-wp_dgst.lo \ + x509/libcrypto_la-by_dir.lo x509/libcrypto_la-by_file.lo \ + x509/libcrypto_la-by_mem.lo x509/libcrypto_la-pcy_cache.lo \ + x509/libcrypto_la-pcy_data.lo x509/libcrypto_la-pcy_lib.lo \ + x509/libcrypto_la-pcy_map.lo x509/libcrypto_la-pcy_node.lo \ + x509/libcrypto_la-pcy_tree.lo x509/libcrypto_la-x509_addr.lo \ + x509/libcrypto_la-x509_akey.lo x509/libcrypto_la-x509_akeya.lo \ + x509/libcrypto_la-x509_alt.lo x509/libcrypto_la-x509_att.lo \ + x509/libcrypto_la-x509_asid.lo x509/libcrypto_la-x509_bcons.lo \ x509/libcrypto_la-x509_bitst.lo x509/libcrypto_la-x509_cmp.lo \ x509/libcrypto_la-x509_conf.lo \ x509/libcrypto_la-x509_constraints.lo \ @@ -957,12 +1019,12 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ ./$(DEPDIR)/libcrypto_la-o_fips.Plo \ ./$(DEPDIR)/libcrypto_la-o_init.Plo \ ./$(DEPDIR)/libcrypto_la-o_str.Plo \ - ./$(DEPDIR)/libcrypto_la-o_time.Plo \ aes/$(DEPDIR)/libcrypto_la-aes-elf-armv4.Plo \ aes/$(DEPDIR)/libcrypto_la-aes-elf-x86_64.Plo \ aes/$(DEPDIR)/libcrypto_la-aes-macosx-x86_64.Plo \ aes/$(DEPDIR)/libcrypto_la-aes-masm-x86_64.Plo \ aes/$(DEPDIR)/libcrypto_la-aes-mingw64-x86_64.Plo \ + aes/$(DEPDIR)/libcrypto_la-aes-mips.Plo \ aes/$(DEPDIR)/libcrypto_la-aes_cbc.Plo \ aes/$(DEPDIR)/libcrypto_la-aes_cfb.Plo \ aes/$(DEPDIR)/libcrypto_la-aes_core.Plo \ @@ -1001,6 +1063,7 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ asn1/$(DEPDIR)/libcrypto_la-a_string.Plo \ asn1/$(DEPDIR)/libcrypto_la-a_strnid.Plo \ asn1/$(DEPDIR)/libcrypto_la-a_time.Plo \ + asn1/$(DEPDIR)/libcrypto_la-a_time_posix.Plo \ asn1/$(DEPDIR)/libcrypto_la-a_time_tm.Plo \ asn1/$(DEPDIR)/libcrypto_la-a_type.Plo \ asn1/$(DEPDIR)/libcrypto_la-a_utf8.Plo \ @@ -1077,17 +1140,15 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ bio/$(DEPDIR)/libcrypto_la-bss_mem.Plo \ bio/$(DEPDIR)/libcrypto_la-bss_null.Plo \ bio/$(DEPDIR)/libcrypto_la-bss_sock.Plo \ + bn/$(DEPDIR)/libcrypto_la-bn-mips.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_add.Plo \ - bn/$(DEPDIR)/libcrypto_la-bn_asm.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_blind.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_bpsw.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_const.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_ctx.Plo \ - bn/$(DEPDIR)/libcrypto_la-bn_depr.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_div.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_err.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_exp.Plo \ - bn/$(DEPDIR)/libcrypto_la-bn_exp2.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_gcd.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_gf2m.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_isqrt.Plo \ @@ -1103,6 +1164,7 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_rand.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_recp.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_shift.Plo \ + bn/$(DEPDIR)/libcrypto_la-bn_small_primes.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_sqr.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_sqrt.Plo \ bn/$(DEPDIR)/libcrypto_la-bn_word.Plo \ @@ -1118,9 +1180,22 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ bn/$(DEPDIR)/libcrypto_la-mont-elf-x86_64.Plo \ bn/$(DEPDIR)/libcrypto_la-mont-macosx-x86_64.Plo \ bn/$(DEPDIR)/libcrypto_la-mont-masm-x86_64.Plo \ + bn/$(DEPDIR)/libcrypto_la-mont-mips.Plo \ bn/$(DEPDIR)/libcrypto_la-mont5-elf-x86_64.Plo \ bn/$(DEPDIR)/libcrypto_la-mont5-macosx-x86_64.Plo \ bn/$(DEPDIR)/libcrypto_la-mont5-masm-x86_64.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_add.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmadd.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmul.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_4_8_alt.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_8_16_alt.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_4_8_alt.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_8_16_alt.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sub.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-bn_arch.Plo \ + bn/arch/amd64/$(DEPDIR)/libcrypto_la-word_clz.Plo \ buffer/$(DEPDIR)/libcrypto_la-buf_err.Plo \ buffer/$(DEPDIR)/libcrypto_la-buf_str.Plo \ buffer/$(DEPDIR)/libcrypto_la-buffer.Plo \ @@ -1257,8 +1332,6 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ dsa/$(DEPDIR)/libcrypto_la-dsa_ossl.Plo \ dsa/$(DEPDIR)/libcrypto_la-dsa_pmeth.Plo \ dsa/$(DEPDIR)/libcrypto_la-dsa_prn.Plo \ - dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Plo \ - dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Plo \ dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Plo \ dso/$(DEPDIR)/libcrypto_la-dso_err.Plo \ dso/$(DEPDIR)/libcrypto_la-dso_lib.Plo \ @@ -1285,6 +1358,7 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ ec/$(DEPDIR)/libcrypto_la-ecp_nist.Plo \ ec/$(DEPDIR)/libcrypto_la-ecp_oct.Plo \ ec/$(DEPDIR)/libcrypto_la-ecp_smpl.Plo \ + ec/$(DEPDIR)/libcrypto_la-ecx_methods.Plo \ ecdh/$(DEPDIR)/libcrypto_la-ecdh_kdf.Plo \ ecdh/$(DEPDIR)/libcrypto_la-ech_err.Plo \ ecdh/$(DEPDIR)/libcrypto_la-ech_key.Plo \ @@ -1326,6 +1400,7 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ evp/$(DEPDIR)/libcrypto_la-bio_enc.Plo \ evp/$(DEPDIR)/libcrypto_la-bio_md.Plo \ evp/$(DEPDIR)/libcrypto_la-c_all.Plo \ + evp/$(DEPDIR)/libcrypto_la-cipher_method_lib.Plo \ evp/$(DEPDIR)/libcrypto_la-digest.Plo \ evp/$(DEPDIR)/libcrypto_la-e_aes.Plo \ evp/$(DEPDIR)/libcrypto_la-e_aes_cbc_hmac_sha1.Plo \ @@ -1521,6 +1596,7 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ sha/$(DEPDIR)/libcrypto_la-sha1-macosx-x86_64.Plo \ sha/$(DEPDIR)/libcrypto_la-sha1-masm-x86_64.Plo \ sha/$(DEPDIR)/libcrypto_la-sha1-mingw64-x86_64.Plo \ + sha/$(DEPDIR)/libcrypto_la-sha1-mips.Plo \ sha/$(DEPDIR)/libcrypto_la-sha1_one.Plo \ sha/$(DEPDIR)/libcrypto_la-sha1dgst.Plo \ sha/$(DEPDIR)/libcrypto_la-sha256-elf-armv4.Plo \ @@ -1528,12 +1604,14 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ sha/$(DEPDIR)/libcrypto_la-sha256-macosx-x86_64.Plo \ sha/$(DEPDIR)/libcrypto_la-sha256-masm-x86_64.Plo \ sha/$(DEPDIR)/libcrypto_la-sha256-mingw64-x86_64.Plo \ + sha/$(DEPDIR)/libcrypto_la-sha256-mips.Plo \ sha/$(DEPDIR)/libcrypto_la-sha256.Plo \ sha/$(DEPDIR)/libcrypto_la-sha512-elf-armv4.Plo \ sha/$(DEPDIR)/libcrypto_la-sha512-elf-x86_64.Plo \ sha/$(DEPDIR)/libcrypto_la-sha512-macosx-x86_64.Plo \ sha/$(DEPDIR)/libcrypto_la-sha512-masm-x86_64.Plo \ sha/$(DEPDIR)/libcrypto_la-sha512-mingw64-x86_64.Plo \ + sha/$(DEPDIR)/libcrypto_la-sha512-mips.Plo \ sha/$(DEPDIR)/libcrypto_la-sha512.Plo \ sm3/$(DEPDIR)/libcrypto_la-sm3.Plo \ sm4/$(DEPDIR)/libcrypto_la-sm4.Plo \ @@ -1552,6 +1630,7 @@ am__depfiles_remade = ./$(DEPDIR)/libcrypto_la-armcap.Plo \ txt_db/$(DEPDIR)/libcrypto_la-txt_db.Plo \ ui/$(DEPDIR)/libcrypto_la-ui_err.Plo \ ui/$(DEPDIR)/libcrypto_la-ui_lib.Plo \ + ui/$(DEPDIR)/libcrypto_la-ui_null.Plo \ ui/$(DEPDIR)/libcrypto_la-ui_openssl.Plo \ ui/$(DEPDIR)/libcrypto_la-ui_openssl_win.Plo \ ui/$(DEPDIR)/libcrypto_la-ui_util.Plo \ @@ -1682,7 +1761,9 @@ am__define_uniq_tagged_files = \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` am__DIST_COMMON = $(srcdir)/Makefile.am.arc4random \ - $(srcdir)/Makefile.am.elf-arm $(srcdir)/Makefile.am.elf-x86_64 \ + $(srcdir)/Makefile.am.elf-arm $(srcdir)/Makefile.am.elf-mips \ + $(srcdir)/Makefile.am.elf-mips64 \ + $(srcdir)/Makefile.am.elf-x86_64 \ $(srcdir)/Makefile.am.macosx-x86_64 \ $(srcdir)/Makefile.am.masm-x86_64 \ $(srcdir)/Makefile.am.mingw64-x86_64 $(srcdir)/Makefile.in \ @@ -1816,24 +1897,26 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ - -DLIBRESSL_INTERNAL -D__BEGIN_HIDDEN_DECLS= \ - -D__END_HIDDEN_DECLS= -DLIBRESSL_CRYPTO_INTERNAL \ - -I$(top_srcdir)/crypto/asn1 -I$(top_srcdir)/crypto/bio \ - -I$(top_srcdir)/crypto/bn -I$(top_srcdir)/crypto/bytestring \ - -I$(top_srcdir)/crypto/dh -I$(top_srcdir)/crypto/dsa \ - -I$(top_srcdir)/crypto/ec -I$(top_srcdir)/crypto/ecdh \ - -I$(top_srcdir)/crypto/ecdsa -I$(top_srcdir)/crypto/evp \ - -I$(top_srcdir)/crypto/hmac -I$(top_srcdir)/crypto/modes \ - -I$(top_srcdir)/crypto/ocsp -I$(top_srcdir)/crypto/pkcs12 \ - -I$(top_srcdir)/crypto/rsa -I$(top_srcdir)/crypto/x509 \ - -I$(top_srcdir)/crypto -noinst_LTLIBRARIES = libcompat.la $(am__append_1) $(am__append_6) +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(abs_top_builddir)/include \ + -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL \ + -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= \ + -DLIBRESSL_CRYPTO_INTERNAL -I$(top_srcdir)/crypto/asn1 \ + -I$(top_srcdir)/crypto/bio -I$(top_srcdir)/crypto/bn \ + -I$(top_srcdir)/crypto/bytestring \ + -I$(top_srcdir)/crypto/curve25519 -I$(top_srcdir)/crypto/dh \ + -I$(top_srcdir)/crypto/dsa -I$(top_srcdir)/crypto/ec \ + -I$(top_srcdir)/crypto/ecdh -I$(top_srcdir)/crypto/ecdsa \ + -I$(top_srcdir)/crypto/evp -I$(top_srcdir)/crypto/hmac \ + -I$(top_srcdir)/crypto/modes -I$(top_srcdir)/crypto/ocsp \ + -I$(top_srcdir)/crypto/pkcs12 -I$(top_srcdir)/crypto/rsa \ + -I$(top_srcdir)/crypto/x509 -I$(top_srcdir)/crypto +noinst_LTLIBRARIES = libcompat.la $(am__append_1) $(am__append_5) @ENABLE_LIBTLS_ONLY_FALSE@lib_LTLIBRARIES = libcrypto.la # needed for a CMake target -EXTRA_DIST = VERSION CMakeLists.txt crypto.sym compat/strcasecmp.c \ - $(ASM_ARM_ELF) $(ASM_X86_64_ELF) $(ASM_X86_64_MACOSX) \ +EXTRA_DIST = VERSION CMakeLists.txt crypto.sym empty.c \ + compat/strcasecmp.c $(ASM_ARM_ELF) $(ASM_MIPS_ELF) \ + $(ASM_MIPS64_ELF) $(ASM_X86_64_ELF) $(ASM_X86_64_MACOSX) \ $(ASM_X86_64_MASM) $(ASM_X86_64_MINGW64) BUILT_SOURCES = crypto_portable.sym CLEANFILES = crypto_portable.sym libcrypto_la_objects.mk @@ -1841,51 +1924,69 @@ libcrypto_la_LDFLAGS = -version-info @LIBCRYPTO_VERSION@ -no-undefined -export-s EXTRA_libcrypto_la_DEPENDENCIES = crypto_portable.sym \ libcrypto_la_objects.mk libcrypto_la_LIBADD = libcompat.la $(am__append_2) -libcrypto_la_CPPFLAGS = $(AM_CPPFLAGS) -DLIBRESSL_INTERNAL \ - -DOPENSSL_NO_HW_PADLOCK $(am__append_3) $(am__append_4) \ - $(am__append_5) $(am__append_37) $(am__append_39) \ - $(am__append_41) $(am__append_43) $(am__append_45) +libcrypto_la_CPPFLAGS = -I$(top_srcdir)/crypto/hidden ${AM_CPPFLAGS} \ + -DLIBRESSL_INTERNAL -DOPENSSL_NO_HW_PADLOCK $(am__append_3) \ + $(am__append_4) $(am__append_36) $(am__append_38) \ + $(am__append_40) $(am__append_42) $(am__append_44) \ + $(am__append_46) $(am__append_48) $(am__append_50) \ + $(am__append_57) $(am__append_58) $(am__append_59) \ + $(am__append_60) $(am__append_61) $(am__append_62) \ + $(am__append_63) $(am__append_64) $(am__append_65) \ + $(am__append_66) @HAVE_EXPLICIT_BZERO_FALSE@libcompatnoopt_la_CFLAGS = -O0 @HAVE_EXPLICIT_BZERO_FALSE@libcompatnoopt_la_SOURCES = \ -@HAVE_EXPLICIT_BZERO_FALSE@ $(am__append_7) $(am__append_8) +@HAVE_EXPLICIT_BZERO_FALSE@ $(am__append_6) $(am__append_7) # other compatibility functions -libcompat_la_SOURCES = $(am__append_9) $(am__append_10) \ - $(am__append_11) $(am__append_12) $(am__append_13) \ - $(am__append_14) $(am__append_15) $(am__append_16) \ - $(am__append_17) $(am__append_18) $(am__append_19) \ - $(am__append_20) $(am__append_21) $(am__append_22) \ - $(am__append_23) $(am__append_24) $(am__append_25) \ - $(am__append_26) $(am__append_27) $(am__append_28) \ - $(am__append_29) $(am__append_30) $(am__append_31) \ - $(am__append_32) $(am__append_33) $(am__append_34) \ - $(am__append_35) $(am__append_36) +libcompat_la_SOURCES = $(am__append_8) $(am__append_9) \ + $(am__append_10) $(am__append_11) $(am__append_12) \ + $(am__append_13) $(am__append_14) $(am__append_15) \ + $(am__append_16) $(am__append_17) $(am__append_18) \ + $(am__append_19) $(am__append_20) $(am__append_21) \ + $(am__append_22) $(am__append_23) $(am__append_24) \ + $(am__append_25) $(am__append_26) $(am__append_27) \ + $(am__append_28) $(am__append_29) $(am__append_30) \ + $(am__append_31) $(am__append_32) $(am__append_33) \ + $(am__append_34) $(am__append_35) libcompat_la_LIBADD = $(PLATFORM_LDADD) +# hidden + # rc4 noinst_HEADERS = compat/arc4random.h compat/arc4random_aix.h \ compat/arc4random_freebsd.h compat/arc4random_hpux.h \ compat/arc4random_linux.h compat/arc4random_netbsd.h \ compat/arc4random_osx.h compat/arc4random_solaris.h \ compat/arc4random_win.h compat/chacha_private.h arm_arch.h \ - constant_time_locl.h cryptlib.h md32_common.h o_time.h \ - x86_arch.h aes/aes_locl.h asn1/asn1_locl.h asn1/charmap.h \ - bf/bf_locl.h bf/bf_pi.h bio/bio_local.h bn/bn_lcl.h \ - bn/bn_prime.h bytestring/bytestring.h camellia/camellia.h \ - camellia/cmll_locl.h cast/cast_lcl.h cast/cast_s.h \ - cms/cms_lcl.h comp/comp_local.h conf/conf_def.h ct/ct_local.h \ - curve25519/curve25519_internal.h des/des_locl.h des/spr.h \ - dh/dh_local.h dsa/dsa_locl.h ec/ec_lcl.h ecdh/ech_locl.h \ - ecdsa/ecs_locl.h engine/eng_int.h evp/evp_locl.h \ - gost/gost_asn1.h gost/gost_locl.h hmac/hmac_local.h \ - idea/idea_lcl.h md4/md4_locl.h md5/md5_locl.h \ - modes/modes_lcl.h objects/obj_dat.h objects/obj_xref.h \ - ocsp/ocsp_local.h pkcs12/pkcs12_local.h rc2/rc2_locl.h \ - rc4/rc4_locl.h ripemd/rmd_locl.h ripemd/rmdconst.h \ - rsa/rsa_locl.h sha/sha_locl.h sm3/sm3_locl.h ts/ts_local.h \ - ui/ui_locl.h whrlpool/wp_locl.h x509/ext_dat.h x509/pcy_int.h \ + constant_time.h cryptlib.h md32_common.h x86_arch.h \ + aes/aes_local.h asn1/asn1_local.h asn1/charmap.h bf/bf_local.h \ + bio/bio_local.h bn/bn_internal.h bn/bn_local.h bn/bn_prime.h \ + bn/s2n_bignum.h bn/s2n_bignum_internal.h \ + bn/arch/aarch64/bn_arch.h bn/arch/arm/bn_arch.h \ + bn/arch/i386/bn_arch.h bn/arch/mips/bn_arch.h \ + bn/arch/mips64/bn_arch.h bn/arch/powerpc/bn_arch.h \ + bn/arch/powerpc64/bn_arch.h bn/arch/riscv64/bn_arch.h \ + bn/arch/sparc64/bn_arch.h bn/arch/amd64/bn_arch.h \ + bytestring/bytestring.h camellia/camellia.h \ + camellia/cmll_local.h cast/cast_local.h cast/cast_s.h \ + cms/cms_local.h comp/comp_local.h conf/conf_def.h \ + ct/ct_local.h curve25519/curve25519_internal.h des/des_local.h \ + des/spr.h dh/dh_local.h dsa/dsa_local.h ec/ec_local.h \ + ecdh/ech_local.h ecdsa/ecs_local.h engine/eng_int.h \ + evp/evp_local.h gost/gost_asn1.h gost/gost_local.h \ + hidden/crypto_namespace.h hidden/openssl/hmac.h \ + hidden/openssl/pkcs12.h hidden/openssl/pkcs7.h \ + hidden/openssl/stack.h hidden/openssl/ui.h \ + hidden/openssl/x509.h hidden/openssl/x509_vfy.h \ + hidden/openssl/x509v3.h hmac/hmac_local.h idea/idea_local.h \ + md4/md4_local.h md5/md5_local.h modes/modes_local.h \ + objects/obj_dat.h objects/obj_xref.h ocsp/ocsp_local.h \ + pkcs12/pkcs12_local.h rc2/rc2_local.h rc4/rc4_local.h \ + ripemd/rmd_local.h ripemd/rmdconst.h rsa/rsa_local.h \ + sha/sha_local.h sm3/sm3_local.h ts/ts_local.h ui/ui_local.h \ + whrlpool/wp_local.h x509/ext_dat.h x509/pcy_int.h \ x509/vpm_int.h x509/x509_internal.h x509/x509_issuer_cache.h \ - x509/x509_lcl.h + x509/x509_local.h x509/x509_verify.h # aes @@ -1990,43 +2091,43 @@ noinst_HEADERS = compat/arc4random.h compat/arc4random_aix.h \ # whrlpool # x509 -libcrypto_la_SOURCES = $(am__append_38) $(am__append_40) \ - $(am__append_42) $(am__append_44) $(am__append_46) \ - $(am__append_47) cpt_err.c cryptlib.c crypto_init.c \ - $(am__append_48) $(am__append_49) cversion.c ex_data.c \ - malloc-wrapper.c mem_clr.c mem_dbg.c o_fips.c o_init.c o_str.c \ - o_time.c aes/aes_cfb.c aes/aes_ctr.c aes/aes_ecb.c \ - aes/aes_ige.c aes/aes_misc.c aes/aes_ofb.c aes/aes_wrap.c \ - asn1/a_bitstr.c asn1/a_enum.c asn1/a_int.c asn1/a_mbstr.c \ - asn1/a_object.c asn1/a_octet.c asn1/a_pkey.c asn1/a_print.c \ - asn1/a_pubkey.c asn1/a_strex.c asn1/a_string.c asn1/a_strnid.c \ - asn1/a_time.c asn1/a_time_tm.c asn1/a_type.c asn1/a_utf8.c \ - asn1/ameth_lib.c asn1/asn1_err.c asn1/asn1_gen.c \ - asn1/asn1_item.c asn1/asn1_lib.c asn1/asn1_old.c \ - asn1/asn1_old_lib.c asn1/asn1_par.c asn1/asn1_types.c \ - asn1/asn_mime.c asn1/asn_moid.c asn1/bio_asn1.c \ - asn1/bio_ndef.c asn1/nsseq.c asn1/p5_pbe.c asn1/p5_pbev2.c \ - asn1/p8_pkey.c asn1/t_crl.c asn1/t_pkey.c asn1/t_req.c \ - asn1/t_spki.c asn1/t_x509.c asn1/t_x509a.c asn1/tasn_dec.c \ - asn1/tasn_enc.c asn1/tasn_fre.c asn1/tasn_new.c \ - asn1/tasn_prn.c asn1/tasn_typ.c asn1/tasn_utl.c asn1/x_algor.c \ - asn1/x_attrib.c asn1/x_bignum.c asn1/x_crl.c asn1/x_exten.c \ - asn1/x_info.c asn1/x_long.c asn1/x_name.c asn1/x_pkey.c \ - asn1/x_pubkey.c asn1/x_req.c asn1/x_sig.c asn1/x_spki.c \ - asn1/x_val.c asn1/x_x509.c asn1/x_x509a.c bf/bf_cfb64.c \ - bf/bf_ecb.c bf/bf_enc.c bf/bf_ofb64.c bf/bf_skey.c \ - bio/b_dump.c $(am__append_50) bio/b_print.c bio/b_sock.c \ - $(am__append_51) bio/bf_buff.c bio/bf_nbio.c bio/bf_null.c \ - bio/bio_cb.c bio/bio_err.c bio/bio_lib.c bio/bio_meth.c \ - bio/bss_acpt.c bio/bss_bio.c bio/bss_conn.c bio/bss_dgram.c \ - bio/bss_fd.c bio/bss_file.c $(am__append_52) bio/bss_mem.c \ - bio/bss_null.c bio/bss_sock.c bn/bn_add.c bn/bn_asm.c \ - bn/bn_blind.c bn/bn_bpsw.c bn/bn_const.c bn/bn_ctx.c \ - bn/bn_depr.c bn/bn_div.c bn/bn_err.c bn/bn_exp.c bn/bn_exp2.c \ - bn/bn_gcd.c bn/bn_gf2m.c bn/bn_isqrt.c bn/bn_kron.c \ - bn/bn_lib.c bn/bn_mod.c bn/bn_mont.c bn/bn_mpi.c bn/bn_mul.c \ - bn/bn_nist.c bn/bn_prime.c bn/bn_print.c bn/bn_rand.c \ - bn/bn_recp.c bn/bn_shift.c bn/bn_sqr.c bn/bn_sqrt.c \ +libcrypto_la_SOURCES = $(am__append_37) $(am__append_39) \ + $(am__append_41) $(am__append_43) $(am__append_45) \ + $(am__append_47) $(am__append_49) $(am__append_51) cpt_err.c \ + cryptlib.c crypto_init.c $(am__append_52) $(am__append_53) \ + cversion.c ex_data.c malloc-wrapper.c mem_clr.c mem_dbg.c \ + o_fips.c o_init.c o_str.c aes/aes_cfb.c aes/aes_ctr.c \ + aes/aes_ecb.c aes/aes_ige.c aes/aes_misc.c aes/aes_ofb.c \ + aes/aes_wrap.c asn1/a_bitstr.c asn1/a_enum.c asn1/a_int.c \ + asn1/a_mbstr.c asn1/a_object.c asn1/a_octet.c asn1/a_pkey.c \ + asn1/a_print.c asn1/a_pubkey.c asn1/a_strex.c asn1/a_string.c \ + asn1/a_strnid.c asn1/a_time.c asn1/a_time_posix.c \ + asn1/a_time_tm.c asn1/a_type.c asn1/a_utf8.c asn1/ameth_lib.c \ + asn1/asn1_err.c asn1/asn1_gen.c asn1/asn1_item.c \ + asn1/asn1_lib.c asn1/asn1_old.c asn1/asn1_old_lib.c \ + asn1/asn1_par.c asn1/asn1_types.c asn1/asn_mime.c \ + asn1/asn_moid.c asn1/bio_asn1.c asn1/bio_ndef.c asn1/nsseq.c \ + asn1/p5_pbe.c asn1/p5_pbev2.c asn1/p8_pkey.c asn1/t_crl.c \ + asn1/t_pkey.c asn1/t_req.c asn1/t_spki.c asn1/t_x509.c \ + asn1/t_x509a.c asn1/tasn_dec.c asn1/tasn_enc.c asn1/tasn_fre.c \ + asn1/tasn_new.c asn1/tasn_prn.c asn1/tasn_typ.c \ + asn1/tasn_utl.c asn1/x_algor.c asn1/x_attrib.c asn1/x_bignum.c \ + asn1/x_crl.c asn1/x_exten.c asn1/x_info.c asn1/x_long.c \ + asn1/x_name.c asn1/x_pkey.c asn1/x_pubkey.c asn1/x_req.c \ + asn1/x_sig.c asn1/x_spki.c asn1/x_val.c asn1/x_x509.c \ + asn1/x_x509a.c bf/bf_cfb64.c bf/bf_ecb.c bf/bf_enc.c \ + bf/bf_ofb64.c bf/bf_skey.c bio/b_dump.c $(am__append_54) \ + bio/b_print.c bio/b_sock.c $(am__append_55) bio/bf_buff.c \ + bio/bf_nbio.c bio/bf_null.c bio/bio_cb.c bio/bio_err.c \ + bio/bio_lib.c bio/bio_meth.c bio/bss_acpt.c bio/bss_bio.c \ + bio/bss_conn.c bio/bss_dgram.c bio/bss_fd.c bio/bss_file.c \ + $(am__append_56) bio/bss_mem.c bio/bss_null.c bio/bss_sock.c \ + bn/bn_add.c bn/bn_blind.c bn/bn_bpsw.c bn/bn_const.c \ + bn/bn_ctx.c bn/bn_div.c bn/bn_err.c bn/bn_exp.c bn/bn_gcd.c \ + bn/bn_gf2m.c bn/bn_isqrt.c bn/bn_kron.c bn/bn_lib.c \ + bn/bn_mod.c bn/bn_mont.c bn/bn_mpi.c bn/bn_mul.c bn/bn_nist.c \ + bn/bn_prime.c bn/bn_print.c bn/bn_rand.c bn/bn_recp.c \ + bn/bn_shift.c bn/bn_small_primes.c bn/bn_sqr.c bn/bn_sqrt.c \ bn/bn_word.c bn/bn_x931p.c buffer/buf_err.c buffer/buf_str.c \ buffer/buffer.c bytestring/bs_ber.c bytestring/bs_cbb.c \ bytestring/bs_cbs.c camellia/cmll_cfb.c camellia/cmll_ctr.c \ @@ -2053,27 +2154,27 @@ libcrypto_la_SOURCES = $(am__append_38) $(am__append_40) \ dh/dh_lib.c dh/dh_pmeth.c dh/dh_prn.c dsa/dsa_ameth.c \ dsa/dsa_asn1.c dsa/dsa_depr.c dsa/dsa_err.c dsa/dsa_gen.c \ dsa/dsa_key.c dsa/dsa_lib.c dsa/dsa_meth.c dsa/dsa_ossl.c \ - dsa/dsa_pmeth.c dsa/dsa_prn.c dsa/dsa_sign.c dsa/dsa_vrf.c \ - dso/dso_dlfcn.c dso/dso_err.c dso/dso_lib.c dso/dso_null.c \ - dso/dso_openssl.c ec/ec2_mult.c ec/ec2_oct.c ec/ec2_smpl.c \ - ec/ec_ameth.c ec/ec_asn1.c ec/ec_check.c ec/ec_curve.c \ - ec/ec_cvt.c ec/ec_err.c ec/ec_key.c ec/ec_kmeth.c ec/ec_lib.c \ - ec/ec_mult.c ec/ec_oct.c ec/ec_pmeth.c ec/ec_print.c \ - ec/eck_prn.c ec/ecp_mont.c ec/ecp_nist.c ec/ecp_oct.c \ - ec/ecp_smpl.c ecdh/ecdh_kdf.c ecdh/ech_err.c ecdh/ech_key.c \ - ecdh/ech_lib.c ecdsa/ecs_asn1.c ecdsa/ecs_err.c \ - ecdsa/ecs_lib.c ecdsa/ecs_ossl.c ecdsa/ecs_sign.c \ - ecdsa/ecs_vrf.c engine/eng_all.c engine/eng_cnf.c \ - engine/eng_ctrl.c engine/eng_dyn.c engine/eng_err.c \ - engine/eng_fat.c engine/eng_init.c engine/eng_lib.c \ - engine/eng_list.c engine/eng_openssl.c engine/eng_pkey.c \ - engine/eng_table.c engine/tb_asnmth.c engine/tb_cipher.c \ - engine/tb_dh.c engine/tb_digest.c engine/tb_dsa.c \ - engine/tb_ecdh.c engine/tb_ecdsa.c engine/tb_eckey.c \ - engine/tb_pkmeth.c engine/tb_rand.c engine/tb_rsa.c \ - engine/tb_store.c err/err.c err/err_all.c err/err_prn.c \ - evp/bio_b64.c evp/bio_enc.c evp/bio_md.c evp/c_all.c \ - evp/digest.c evp/e_aes.c evp/e_aes_cbc_hmac_sha1.c evp/e_bf.c \ + dsa/dsa_pmeth.c dsa/dsa_prn.c dso/dso_dlfcn.c dso/dso_err.c \ + dso/dso_lib.c dso/dso_null.c dso/dso_openssl.c ec/ec2_mult.c \ + ec/ec2_oct.c ec/ec2_smpl.c ec/ec_ameth.c ec/ec_asn1.c \ + ec/ec_check.c ec/ec_curve.c ec/ec_cvt.c ec/ec_err.c \ + ec/ec_key.c ec/ec_kmeth.c ec/ec_lib.c ec/ec_mult.c ec/ec_oct.c \ + ec/ec_pmeth.c ec/ec_print.c ec/eck_prn.c ec/ecp_mont.c \ + ec/ecp_nist.c ec/ecp_oct.c ec/ecp_smpl.c ec/ecx_methods.c \ + ecdh/ecdh_kdf.c ecdh/ech_err.c ecdh/ech_key.c ecdh/ech_lib.c \ + ecdsa/ecs_asn1.c ecdsa/ecs_err.c ecdsa/ecs_lib.c \ + ecdsa/ecs_ossl.c ecdsa/ecs_sign.c ecdsa/ecs_vrf.c \ + engine/eng_all.c engine/eng_cnf.c engine/eng_ctrl.c \ + engine/eng_dyn.c engine/eng_err.c engine/eng_fat.c \ + engine/eng_init.c engine/eng_lib.c engine/eng_list.c \ + engine/eng_openssl.c engine/eng_pkey.c engine/eng_table.c \ + engine/tb_asnmth.c engine/tb_cipher.c engine/tb_dh.c \ + engine/tb_digest.c engine/tb_dsa.c engine/tb_ecdh.c \ + engine/tb_ecdsa.c engine/tb_eckey.c engine/tb_pkmeth.c \ + engine/tb_rand.c engine/tb_rsa.c engine/tb_store.c err/err.c \ + err/err_all.c err/err_prn.c evp/bio_b64.c evp/bio_enc.c \ + evp/bio_md.c evp/c_all.c evp/cipher_method_lib.c evp/digest.c \ + evp/e_aes.c evp/e_aes_cbc_hmac_sha1.c evp/e_bf.c \ evp/e_camellia.c evp/e_cast.c evp/e_chacha.c \ evp/e_chacha20poly1305.c evp/e_des.c evp/e_des3.c \ evp/e_gost2814789.c evp/e_idea.c evp/e_null.c evp/e_old.c \ @@ -2126,10 +2227,10 @@ libcrypto_la_SOURCES = $(am__append_38) $(am__append_40) \ ts/ts_err.c ts/ts_lib.c ts/ts_req_print.c ts/ts_req_utils.c \ ts/ts_rsp_print.c ts/ts_rsp_sign.c ts/ts_rsp_utils.c \ ts/ts_rsp_verify.c ts/ts_verify_ctx.c txt_db/txt_db.c \ - ui/ui_err.c ui/ui_lib.c $(am__append_53) $(am__append_54) \ - ui/ui_util.c whrlpool/wp_dgst.c x509/by_dir.c x509/by_file.c \ - x509/by_mem.c x509/pcy_cache.c x509/pcy_data.c x509/pcy_lib.c \ - x509/pcy_map.c x509/pcy_node.c x509/pcy_tree.c \ + ui/ui_err.c ui/ui_lib.c ui/ui_null.c $(am__append_67) \ + $(am__append_68) ui/ui_util.c whrlpool/wp_dgst.c x509/by_dir.c \ + x509/by_file.c x509/by_mem.c x509/pcy_cache.c x509/pcy_data.c \ + x509/pcy_lib.c x509/pcy_map.c x509/pcy_node.c x509/pcy_tree.c \ x509/x509_addr.c x509/x509_akey.c x509/x509_akeya.c \ x509/x509_alt.c x509/x509_att.c x509/x509_asid.c \ x509/x509_bcons.c x509/x509_bitst.c x509/x509_cmp.c \ @@ -2160,6 +2261,14 @@ ASM_ARM_ELF = aes/aes-elf-armv4.S bn/gf2m-elf-armv4.S \ modes/ghash-elf-armv4.S armv4cpuid.S armcap.c aes/aes_cbc.c \ camellia/camellia.c camellia/cmll_cbc.c rc4/rc4_enc.c \ rc4/rc4_skey.c whrlpool/wp_block.c +ASM_MIPS_ELF = aes/aes-mips.S bn/bn-mips.S bn/mont-mips.S \ + sha/sha1-mips.S sha/sha512-mips.S sha/sha256-mips.S \ + aes/aes_cbc.c camellia/camellia.c camellia/cmll_cbc.c \ + rc4/rc4_enc.c rc4/rc4_skey.c whrlpool/wp_block.c +ASM_MIPS64_ELF = aes/aes-mips.S bn/bn-mips.S bn/mont-mips.S \ + sha/sha1-mips.S sha/sha512-mips.S sha/sha256-mips.S \ + aes/aes_cbc.c camellia/camellia.c camellia/cmll_cbc.c \ + rc4/rc4_enc.c rc4/rc4_skey.c whrlpool/wp_block.c ASM_X86_64_ELF = aes/aes-elf-x86_64.S aes/bsaes-elf-x86_64.S \ aes/vpaes-elf-x86_64.S aes/aesni-elf-x86_64.S \ aes/aesni-sha1-elf-x86_64.S bn/modexp512-elf-x86_64.S \ @@ -2169,7 +2278,13 @@ ASM_X86_64_ELF = aes/aes-elf-x86_64.S aes/bsaes-elf-x86_64.S \ rc4/rc4-elf-x86_64.S rc4/rc4-md5-elf-x86_64.S \ sha/sha1-elf-x86_64.S sha/sha256-elf-x86_64.S \ sha/sha512-elf-x86_64.S whrlpool/wp-elf-x86_64.S \ - cpuid-elf-x86_64.S + cpuid-elf-x86_64.S bn/arch/amd64/bignum_add.S \ + bn/arch/amd64/bignum_cmadd.S bn/arch/amd64/bignum_cmul.S \ + bn/arch/amd64/bignum_mul.S bn/arch/amd64/bignum_mul_4_8_alt.S \ + bn/arch/amd64/bignum_mul_8_16_alt.S bn/arch/amd64/bignum_sqr.S \ + bn/arch/amd64/bignum_sqr_4_8_alt.S \ + bn/arch/amd64/bignum_sqr_8_16_alt.S bn/arch/amd64/bignum_sub.S \ + bn/arch/amd64/word_clz.S bn/arch/amd64/bn_arch.c ASM_X86_64_MACOSX = aes/aes-macosx-x86_64.S aes/bsaes-macosx-x86_64.S \ aes/vpaes-macosx-x86_64.S aes/aesni-macosx-x86_64.S \ aes/aesni-sha1-macosx-x86_64.S bn/modexp512-macosx-x86_64.S \ @@ -2179,7 +2294,13 @@ ASM_X86_64_MACOSX = aes/aes-macosx-x86_64.S aes/bsaes-macosx-x86_64.S \ rc4/rc4-macosx-x86_64.S rc4/rc4-md5-macosx-x86_64.S \ sha/sha1-macosx-x86_64.S sha/sha256-macosx-x86_64.S \ sha/sha512-macosx-x86_64.S whrlpool/wp-macosx-x86_64.S \ - cpuid-macosx-x86_64.S + cpuid-macosx-x86_64.S bn/arch/amd64/bignum_add.S \ + bn/arch/amd64/bignum_cmadd.S bn/arch/amd64/bignum_cmul.S \ + bn/arch/amd64/bignum_mul.S bn/arch/amd64/bignum_mul_4_8_alt.S \ + bn/arch/amd64/bignum_mul_8_16_alt.S bn/arch/amd64/bignum_sqr.S \ + bn/arch/amd64/bignum_sqr_4_8_alt.S \ + bn/arch/amd64/bignum_sqr_8_16_alt.S bn/arch/amd64/bignum_sub.S \ + bn/arch/amd64/word_clz.S bn/arch/amd64/bn_arch.c ASM_X86_64_MASM = aes/aes-masm-x86_64.S aes/bsaes-masm-x86_64.S \ aes/vpaes-masm-x86_64.S aes/aesni-masm-x86_64.S \ aes/aesni-sha1-masm-x86_64.S bn/modexp512-masm-x86_64.S \ @@ -2207,7 +2328,7 @@ all: $(BUILT_SOURCES) .SUFFIXES: .SUFFIXES: .S .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(srcdir)/Makefile.am.arc4random $(srcdir)/Makefile.am.elf-arm $(srcdir)/Makefile.am.elf-x86_64 $(srcdir)/Makefile.am.macosx-x86_64 $(srcdir)/Makefile.am.masm-x86_64 $(srcdir)/Makefile.am.mingw64-x86_64 $(am__configure_deps) +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(srcdir)/Makefile.am.arc4random $(srcdir)/Makefile.am.elf-arm $(srcdir)/Makefile.am.elf-mips $(srcdir)/Makefile.am.elf-mips64 $(srcdir)/Makefile.am.elf-x86_64 $(srcdir)/Makefile.am.macosx-x86_64 $(srcdir)/Makefile.am.masm-x86_64 $(srcdir)/Makefile.am.mingw64-x86_64 $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -2227,7 +2348,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; -$(top_srcdir)/Makefile.am.common $(srcdir)/Makefile.am.arc4random $(srcdir)/Makefile.am.elf-arm $(srcdir)/Makefile.am.elf-x86_64 $(srcdir)/Makefile.am.macosx-x86_64 $(srcdir)/Makefile.am.masm-x86_64 $(srcdir)/Makefile.am.mingw64-x86_64 $(am__empty): +$(top_srcdir)/Makefile.am.common $(srcdir)/Makefile.am.arc4random $(srcdir)/Makefile.am.elf-arm $(srcdir)/Makefile.am.elf-mips $(srcdir)/Makefile.am.elf-mips64 $(srcdir)/Makefile.am.elf-x86_64 $(srcdir)/Makefile.am.macosx-x86_64 $(srcdir)/Makefile.am.masm-x86_64 $(srcdir)/Makefile.am.mingw64-x86_64 $(am__empty): $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh @@ -2425,6 +2546,18 @@ whrlpool/$(DEPDIR)/$(am__dirstamp): @: > whrlpool/$(DEPDIR)/$(am__dirstamp) whrlpool/libcrypto_la-wp_block.lo: whrlpool/$(am__dirstamp) \ whrlpool/$(DEPDIR)/$(am__dirstamp) +aes/libcrypto_la-aes-mips.lo: aes/$(am__dirstamp) \ + aes/$(DEPDIR)/$(am__dirstamp) +bn/libcrypto_la-bn-mips.lo: bn/$(am__dirstamp) \ + bn/$(DEPDIR)/$(am__dirstamp) +bn/libcrypto_la-mont-mips.lo: bn/$(am__dirstamp) \ + bn/$(DEPDIR)/$(am__dirstamp) +sha/libcrypto_la-sha1-mips.lo: sha/$(am__dirstamp) \ + sha/$(DEPDIR)/$(am__dirstamp) +sha/libcrypto_la-sha512-mips.lo: sha/$(am__dirstamp) \ + sha/$(DEPDIR)/$(am__dirstamp) +sha/libcrypto_la-sha256-mips.lo: sha/$(am__dirstamp) \ + sha/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes-elf-x86_64.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-bsaes-elf-x86_64.lo: aes/$(am__dirstamp) \ @@ -2467,6 +2600,46 @@ sha/libcrypto_la-sha512-elf-x86_64.lo: sha/$(am__dirstamp) \ sha/$(DEPDIR)/$(am__dirstamp) whrlpool/libcrypto_la-wp-elf-x86_64.lo: whrlpool/$(am__dirstamp) \ whrlpool/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/$(am__dirstamp): + @$(MKDIR_P) bn/arch/amd64 + @: > bn/arch/amd64/$(am__dirstamp) +bn/arch/amd64/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) bn/arch/amd64/$(DEPDIR) + @: > bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bignum_add.lo: \ + bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bignum_cmadd.lo: \ + bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bignum_cmul.lo: \ + bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bignum_mul.lo: \ + bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bignum_mul_4_8_alt.lo: \ + bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bignum_mul_8_16_alt.lo: \ + bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bignum_sqr.lo: \ + bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bignum_sqr_4_8_alt.lo: \ + bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bignum_sqr_8_16_alt.lo: \ + bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bignum_sub.lo: \ + bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-word_clz.lo: bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) +bn/arch/amd64/libcrypto_la-bn_arch.lo: bn/arch/amd64/$(am__dirstamp) \ + bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-aes-macosx-x86_64.lo: aes/$(am__dirstamp) \ aes/$(DEPDIR)/$(am__dirstamp) aes/libcrypto_la-bsaes-macosx-x86_64.lo: aes/$(am__dirstamp) \ @@ -2617,6 +2790,8 @@ asn1/libcrypto_la-a_strnid.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_time.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) +asn1/libcrypto_la-a_time_posix.lo: asn1/$(am__dirstamp) \ + asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_time_tm.lo: asn1/$(am__dirstamp) \ asn1/$(DEPDIR)/$(am__dirstamp) asn1/libcrypto_la-a_type.lo: asn1/$(am__dirstamp) \ @@ -2783,8 +2958,6 @@ bio/libcrypto_la-bss_sock.lo: bio/$(am__dirstamp) \ bio/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_add.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) -bn/libcrypto_la-bn_asm.lo: bn/$(am__dirstamp) \ - bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_blind.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_bpsw.lo: bn/$(am__dirstamp) \ @@ -2793,16 +2966,12 @@ bn/libcrypto_la-bn_const.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_ctx.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) -bn/libcrypto_la-bn_depr.lo: bn/$(am__dirstamp) \ - bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_div.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_err.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_exp.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) -bn/libcrypto_la-bn_exp2.lo: bn/$(am__dirstamp) \ - bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_gcd.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_gf2m.lo: bn/$(am__dirstamp) \ @@ -2833,6 +3002,8 @@ bn/libcrypto_la-bn_recp.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_shift.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) +bn/libcrypto_la-bn_small_primes.lo: bn/$(am__dirstamp) \ + bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_sqr.lo: bn/$(am__dirstamp) \ bn/$(DEPDIR)/$(am__dirstamp) bn/libcrypto_la-bn_sqrt.lo: bn/$(am__dirstamp) \ @@ -3120,10 +3291,6 @@ dsa/libcrypto_la-dsa_pmeth.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) dsa/libcrypto_la-dsa_prn.lo: dsa/$(am__dirstamp) \ dsa/$(DEPDIR)/$(am__dirstamp) -dsa/libcrypto_la-dsa_sign.lo: dsa/$(am__dirstamp) \ - dsa/$(DEPDIR)/$(am__dirstamp) -dsa/libcrypto_la-dsa_vrf.lo: dsa/$(am__dirstamp) \ - dsa/$(DEPDIR)/$(am__dirstamp) dso/$(am__dirstamp): @$(MKDIR_P) dso @: > dso/$(am__dirstamp) @@ -3188,6 +3355,8 @@ ec/libcrypto_la-ecp_oct.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) ec/libcrypto_la-ecp_smpl.lo: ec/$(am__dirstamp) \ ec/$(DEPDIR)/$(am__dirstamp) +ec/libcrypto_la-ecx_methods.lo: ec/$(am__dirstamp) \ + ec/$(DEPDIR)/$(am__dirstamp) ecdh/$(am__dirstamp): @$(MKDIR_P) ecdh @: > ecdh/$(am__dirstamp) @@ -3300,6 +3469,8 @@ evp/libcrypto_la-bio_md.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-c_all.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) +evp/libcrypto_la-cipher_method_lib.lo: evp/$(am__dirstamp) \ + evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-digest.lo: evp/$(am__dirstamp) \ evp/$(DEPDIR)/$(am__dirstamp) evp/libcrypto_la-e_aes.lo: evp/$(am__dirstamp) \ @@ -3820,6 +3991,8 @@ ui/libcrypto_la-ui_err.lo: ui/$(am__dirstamp) \ ui/$(DEPDIR)/$(am__dirstamp) ui/libcrypto_la-ui_lib.lo: ui/$(am__dirstamp) \ ui/$(DEPDIR)/$(am__dirstamp) +ui/libcrypto_la-ui_null.lo: ui/$(am__dirstamp) \ + ui/$(DEPDIR)/$(am__dirstamp) ui/libcrypto_la-ui_openssl.lo: ui/$(am__dirstamp) \ ui/$(DEPDIR)/$(am__dirstamp) ui/libcrypto_la-ui_openssl_win.lo: ui/$(am__dirstamp) \ @@ -3982,6 +4155,8 @@ mostlyclean-compile: -rm -f bio/*.lo -rm -f bn/*.$(OBJEXT) -rm -f bn/*.lo + -rm -f bn/arch/amd64/*.$(OBJEXT) + -rm -f bn/arch/amd64/*.lo -rm -f buffer/*.$(OBJEXT) -rm -f buffer/*.lo -rm -f bytestring/*.$(OBJEXT) @@ -4106,12 +4281,12 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-o_fips.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-o_init.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-o_str.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcrypto_la-o_time.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes-elf-armv4.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes-elf-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes-macosx-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes-masm-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes-mingw64-x86_64.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes-mips.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_cbc.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_cfb.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@aes/$(DEPDIR)/libcrypto_la-aes_core.Plo@am__quote@ # am--include-marker @@ -4150,6 +4325,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_string.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_strnid.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_time.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_time_posix.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_time_tm.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_type.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@asn1/$(DEPDIR)/libcrypto_la-a_utf8.Plo@am__quote@ # am--include-marker @@ -4226,17 +4402,15 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_mem.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_null.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bio/$(DEPDIR)/libcrypto_la-bss_sock.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn-mips.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_add.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_asm.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_blind.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_bpsw.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_const.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_ctx.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_depr.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_div.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_err.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_exp.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_exp2.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_gcd.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_gf2m.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_isqrt.Plo@am__quote@ # am--include-marker @@ -4252,6 +4426,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_rand.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_recp.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_shift.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_small_primes.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_sqr.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_sqrt.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-bn_word.Plo@am__quote@ # am--include-marker @@ -4267,9 +4442,22 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-mont-elf-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-mont-macosx-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-mont-masm-x86_64.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-mont-mips.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-mont5-elf-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-mont5-macosx-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bn/$(DEPDIR)/libcrypto_la-mont5-masm-x86_64.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_add.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmadd.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmul.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_4_8_alt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_8_16_alt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_4_8_alt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_8_16_alt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sub.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-bn_arch.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@bn/arch/amd64/$(DEPDIR)/libcrypto_la-word_clz.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@buffer/$(DEPDIR)/libcrypto_la-buf_err.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@buffer/$(DEPDIR)/libcrypto_la-buf_str.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@buffer/$(DEPDIR)/libcrypto_la-buffer.Plo@am__quote@ # am--include-marker @@ -4410,8 +4598,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_ossl.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_pmeth.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_prn.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@dso/$(DEPDIR)/libcrypto_la-dso_err.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@dso/$(DEPDIR)/libcrypto_la-dso_lib.Plo@am__quote@ # am--include-marker @@ -4438,6 +4624,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ecp_nist.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ecp_oct.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ecp_smpl.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@ec/$(DEPDIR)/libcrypto_la-ecx_methods.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ecdh/$(DEPDIR)/libcrypto_la-ecdh_kdf.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ecdh/$(DEPDIR)/libcrypto_la-ech_err.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ecdh/$(DEPDIR)/libcrypto_la-ech_key.Plo@am__quote@ # am--include-marker @@ -4479,6 +4666,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-bio_enc.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-bio_md.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-c_all.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-cipher_method_lib.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-digest.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_aes.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@evp/$(DEPDIR)/libcrypto_la-e_aes_cbc_hmac_sha1.Plo@am__quote@ # am--include-marker @@ -4674,6 +4862,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha1-macosx-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha1-masm-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha1-mingw64-x86_64.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha1-mips.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha1_one.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha1dgst.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha256-elf-armv4.Plo@am__quote@ # am--include-marker @@ -4681,12 +4870,14 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha256-macosx-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha256-masm-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha256-mingw64-x86_64.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha256-mips.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha256.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha512-elf-armv4.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha512-elf-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha512-macosx-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha512-masm-x86_64.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha512-mingw64-x86_64.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha512-mips.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sha/$(DEPDIR)/libcrypto_la-sha512.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sm3/$(DEPDIR)/libcrypto_la-sm3.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@sm4/$(DEPDIR)/libcrypto_la-sm4.Plo@am__quote@ # am--include-marker @@ -4705,6 +4896,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@txt_db/$(DEPDIR)/libcrypto_la-txt_db.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/libcrypto_la-ui_err.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/libcrypto_la-ui_lib.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/libcrypto_la-ui_null.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/libcrypto_la-ui_openssl.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/libcrypto_la-ui_openssl_win.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@ui/$(DEPDIR)/libcrypto_la-ui_util.Plo@am__quote@ # am--include-marker @@ -4864,6 +5056,48 @@ libcrypto_la-armv4cpuid.lo: armv4cpuid.S @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o libcrypto_la-armv4cpuid.lo `test -f 'armv4cpuid.S' || echo '$(srcdir)/'`armv4cpuid.S +aes/libcrypto_la-aes-mips.lo: aes/aes-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT aes/libcrypto_la-aes-mips.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes-mips.Tpo -c -o aes/libcrypto_la-aes-mips.lo `test -f 'aes/aes-mips.S' || echo '$(srcdir)/'`aes/aes-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes-mips.Tpo aes/$(DEPDIR)/libcrypto_la-aes-mips.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='aes/aes-mips.S' object='aes/libcrypto_la-aes-mips.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o aes/libcrypto_la-aes-mips.lo `test -f 'aes/aes-mips.S' || echo '$(srcdir)/'`aes/aes-mips.S + +bn/libcrypto_la-bn-mips.lo: bn/bn-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/libcrypto_la-bn-mips.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn-mips.Tpo -c -o bn/libcrypto_la-bn-mips.lo `test -f 'bn/bn-mips.S' || echo '$(srcdir)/'`bn/bn-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn-mips.Tpo bn/$(DEPDIR)/libcrypto_la-bn-mips.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/bn-mips.S' object='bn/libcrypto_la-bn-mips.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/libcrypto_la-bn-mips.lo `test -f 'bn/bn-mips.S' || echo '$(srcdir)/'`bn/bn-mips.S + +bn/libcrypto_la-mont-mips.lo: bn/mont-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/libcrypto_la-mont-mips.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-mont-mips.Tpo -c -o bn/libcrypto_la-mont-mips.lo `test -f 'bn/mont-mips.S' || echo '$(srcdir)/'`bn/mont-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-mont-mips.Tpo bn/$(DEPDIR)/libcrypto_la-mont-mips.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/mont-mips.S' object='bn/libcrypto_la-mont-mips.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/libcrypto_la-mont-mips.lo `test -f 'bn/mont-mips.S' || echo '$(srcdir)/'`bn/mont-mips.S + +sha/libcrypto_la-sha1-mips.lo: sha/sha1-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT sha/libcrypto_la-sha1-mips.lo -MD -MP -MF sha/$(DEPDIR)/libcrypto_la-sha1-mips.Tpo -c -o sha/libcrypto_la-sha1-mips.lo `test -f 'sha/sha1-mips.S' || echo '$(srcdir)/'`sha/sha1-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) sha/$(DEPDIR)/libcrypto_la-sha1-mips.Tpo sha/$(DEPDIR)/libcrypto_la-sha1-mips.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='sha/sha1-mips.S' object='sha/libcrypto_la-sha1-mips.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o sha/libcrypto_la-sha1-mips.lo `test -f 'sha/sha1-mips.S' || echo '$(srcdir)/'`sha/sha1-mips.S + +sha/libcrypto_la-sha512-mips.lo: sha/sha512-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT sha/libcrypto_la-sha512-mips.lo -MD -MP -MF sha/$(DEPDIR)/libcrypto_la-sha512-mips.Tpo -c -o sha/libcrypto_la-sha512-mips.lo `test -f 'sha/sha512-mips.S' || echo '$(srcdir)/'`sha/sha512-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) sha/$(DEPDIR)/libcrypto_la-sha512-mips.Tpo sha/$(DEPDIR)/libcrypto_la-sha512-mips.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='sha/sha512-mips.S' object='sha/libcrypto_la-sha512-mips.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o sha/libcrypto_la-sha512-mips.lo `test -f 'sha/sha512-mips.S' || echo '$(srcdir)/'`sha/sha512-mips.S + +sha/libcrypto_la-sha256-mips.lo: sha/sha256-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT sha/libcrypto_la-sha256-mips.lo -MD -MP -MF sha/$(DEPDIR)/libcrypto_la-sha256-mips.Tpo -c -o sha/libcrypto_la-sha256-mips.lo `test -f 'sha/sha256-mips.S' || echo '$(srcdir)/'`sha/sha256-mips.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) sha/$(DEPDIR)/libcrypto_la-sha256-mips.Tpo sha/$(DEPDIR)/libcrypto_la-sha256-mips.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='sha/sha256-mips.S' object='sha/libcrypto_la-sha256-mips.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o sha/libcrypto_la-sha256-mips.lo `test -f 'sha/sha256-mips.S' || echo '$(srcdir)/'`sha/sha256-mips.S + aes/libcrypto_la-aes-elf-x86_64.lo: aes/aes-elf-x86_64.S @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT aes/libcrypto_la-aes-elf-x86_64.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes-elf-x86_64.Tpo -c -o aes/libcrypto_la-aes-elf-x86_64.lo `test -f 'aes/aes-elf-x86_64.S' || echo '$(srcdir)/'`aes/aes-elf-x86_64.S @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes-elf-x86_64.Tpo aes/$(DEPDIR)/libcrypto_la-aes-elf-x86_64.Plo @@ -4997,6 +5231,83 @@ libcrypto_la-cpuid-elf-x86_64.lo: cpuid-elf-x86_64.S @AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o libcrypto_la-cpuid-elf-x86_64.lo `test -f 'cpuid-elf-x86_64.S' || echo '$(srcdir)/'`cpuid-elf-x86_64.S +bn/arch/amd64/libcrypto_la-bignum_add.lo: bn/arch/amd64/bignum_add.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-bignum_add.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_add.Tpo -c -o bn/arch/amd64/libcrypto_la-bignum_add.lo `test -f 'bn/arch/amd64/bignum_add.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_add.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_add.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_add.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/bignum_add.S' object='bn/arch/amd64/libcrypto_la-bignum_add.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-bignum_add.lo `test -f 'bn/arch/amd64/bignum_add.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_add.S + +bn/arch/amd64/libcrypto_la-bignum_cmadd.lo: bn/arch/amd64/bignum_cmadd.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-bignum_cmadd.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmadd.Tpo -c -o bn/arch/amd64/libcrypto_la-bignum_cmadd.lo `test -f 'bn/arch/amd64/bignum_cmadd.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_cmadd.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmadd.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmadd.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/bignum_cmadd.S' object='bn/arch/amd64/libcrypto_la-bignum_cmadd.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-bignum_cmadd.lo `test -f 'bn/arch/amd64/bignum_cmadd.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_cmadd.S + +bn/arch/amd64/libcrypto_la-bignum_cmul.lo: bn/arch/amd64/bignum_cmul.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-bignum_cmul.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmul.Tpo -c -o bn/arch/amd64/libcrypto_la-bignum_cmul.lo `test -f 'bn/arch/amd64/bignum_cmul.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_cmul.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmul.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmul.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/bignum_cmul.S' object='bn/arch/amd64/libcrypto_la-bignum_cmul.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-bignum_cmul.lo `test -f 'bn/arch/amd64/bignum_cmul.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_cmul.S + +bn/arch/amd64/libcrypto_la-bignum_mul.lo: bn/arch/amd64/bignum_mul.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-bignum_mul.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul.Tpo -c -o bn/arch/amd64/libcrypto_la-bignum_mul.lo `test -f 'bn/arch/amd64/bignum_mul.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_mul.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/bignum_mul.S' object='bn/arch/amd64/libcrypto_la-bignum_mul.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-bignum_mul.lo `test -f 'bn/arch/amd64/bignum_mul.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_mul.S + +bn/arch/amd64/libcrypto_la-bignum_mul_4_8_alt.lo: bn/arch/amd64/bignum_mul_4_8_alt.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-bignum_mul_4_8_alt.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_4_8_alt.Tpo -c -o bn/arch/amd64/libcrypto_la-bignum_mul_4_8_alt.lo `test -f 'bn/arch/amd64/bignum_mul_4_8_alt.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_mul_4_8_alt.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_4_8_alt.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_4_8_alt.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/bignum_mul_4_8_alt.S' object='bn/arch/amd64/libcrypto_la-bignum_mul_4_8_alt.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-bignum_mul_4_8_alt.lo `test -f 'bn/arch/amd64/bignum_mul_4_8_alt.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_mul_4_8_alt.S + +bn/arch/amd64/libcrypto_la-bignum_mul_8_16_alt.lo: bn/arch/amd64/bignum_mul_8_16_alt.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-bignum_mul_8_16_alt.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_8_16_alt.Tpo -c -o bn/arch/amd64/libcrypto_la-bignum_mul_8_16_alt.lo `test -f 'bn/arch/amd64/bignum_mul_8_16_alt.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_mul_8_16_alt.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_8_16_alt.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_8_16_alt.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/bignum_mul_8_16_alt.S' object='bn/arch/amd64/libcrypto_la-bignum_mul_8_16_alt.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-bignum_mul_8_16_alt.lo `test -f 'bn/arch/amd64/bignum_mul_8_16_alt.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_mul_8_16_alt.S + +bn/arch/amd64/libcrypto_la-bignum_sqr.lo: bn/arch/amd64/bignum_sqr.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-bignum_sqr.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr.Tpo -c -o bn/arch/amd64/libcrypto_la-bignum_sqr.lo `test -f 'bn/arch/amd64/bignum_sqr.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_sqr.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/bignum_sqr.S' object='bn/arch/amd64/libcrypto_la-bignum_sqr.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-bignum_sqr.lo `test -f 'bn/arch/amd64/bignum_sqr.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_sqr.S + +bn/arch/amd64/libcrypto_la-bignum_sqr_4_8_alt.lo: bn/arch/amd64/bignum_sqr_4_8_alt.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-bignum_sqr_4_8_alt.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_4_8_alt.Tpo -c -o bn/arch/amd64/libcrypto_la-bignum_sqr_4_8_alt.lo `test -f 'bn/arch/amd64/bignum_sqr_4_8_alt.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_sqr_4_8_alt.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_4_8_alt.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_4_8_alt.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/bignum_sqr_4_8_alt.S' object='bn/arch/amd64/libcrypto_la-bignum_sqr_4_8_alt.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-bignum_sqr_4_8_alt.lo `test -f 'bn/arch/amd64/bignum_sqr_4_8_alt.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_sqr_4_8_alt.S + +bn/arch/amd64/libcrypto_la-bignum_sqr_8_16_alt.lo: bn/arch/amd64/bignum_sqr_8_16_alt.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-bignum_sqr_8_16_alt.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_8_16_alt.Tpo -c -o bn/arch/amd64/libcrypto_la-bignum_sqr_8_16_alt.lo `test -f 'bn/arch/amd64/bignum_sqr_8_16_alt.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_sqr_8_16_alt.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_8_16_alt.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_8_16_alt.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/bignum_sqr_8_16_alt.S' object='bn/arch/amd64/libcrypto_la-bignum_sqr_8_16_alt.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-bignum_sqr_8_16_alt.lo `test -f 'bn/arch/amd64/bignum_sqr_8_16_alt.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_sqr_8_16_alt.S + +bn/arch/amd64/libcrypto_la-bignum_sub.lo: bn/arch/amd64/bignum_sub.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-bignum_sub.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sub.Tpo -c -o bn/arch/amd64/libcrypto_la-bignum_sub.lo `test -f 'bn/arch/amd64/bignum_sub.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_sub.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sub.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sub.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/bignum_sub.S' object='bn/arch/amd64/libcrypto_la-bignum_sub.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-bignum_sub.lo `test -f 'bn/arch/amd64/bignum_sub.S' || echo '$(srcdir)/'`bn/arch/amd64/bignum_sub.S + +bn/arch/amd64/libcrypto_la-word_clz.lo: bn/arch/amd64/word_clz.S +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT bn/arch/amd64/libcrypto_la-word_clz.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-word_clz.Tpo -c -o bn/arch/amd64/libcrypto_la-word_clz.lo `test -f 'bn/arch/amd64/word_clz.S' || echo '$(srcdir)/'`bn/arch/amd64/word_clz.S +@am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-word_clz.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-word_clz.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='bn/arch/amd64/word_clz.S' object='bn/arch/amd64/libcrypto_la-word_clz.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -c -o bn/arch/amd64/libcrypto_la-word_clz.lo `test -f 'bn/arch/amd64/word_clz.S' || echo '$(srcdir)/'`bn/arch/amd64/word_clz.S + aes/libcrypto_la-aes-macosx-x86_64.lo: aes/aes-macosx-x86_64.S @am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) -MT aes/libcrypto_la-aes-macosx-x86_64.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes-macosx-x86_64.Tpo -c -o aes/libcrypto_la-aes-macosx-x86_64.lo `test -f 'aes/aes-macosx-x86_64.S' || echo '$(srcdir)/'`aes/aes-macosx-x86_64.S @am__fastdepCCAS_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes-macosx-x86_64.Tpo aes/$(DEPDIR)/libcrypto_la-aes-macosx-x86_64.Plo @@ -5455,6 +5766,13 @@ whrlpool/libcrypto_la-wp_block.lo: whrlpool/wp_block.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o whrlpool/libcrypto_la-wp_block.lo `test -f 'whrlpool/wp_block.c' || echo '$(srcdir)/'`whrlpool/wp_block.c +bn/arch/amd64/libcrypto_la-bn_arch.lo: bn/arch/amd64/bn_arch.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn/arch/amd64/libcrypto_la-bn_arch.lo -MD -MP -MF bn/arch/amd64/$(DEPDIR)/libcrypto_la-bn_arch.Tpo -c -o bn/arch/amd64/libcrypto_la-bn_arch.lo `test -f 'bn/arch/amd64/bn_arch.c' || echo '$(srcdir)/'`bn/arch/amd64/bn_arch.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/arch/amd64/$(DEPDIR)/libcrypto_la-bn_arch.Tpo bn/arch/amd64/$(DEPDIR)/libcrypto_la-bn_arch.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/arch/amd64/bn_arch.c' object='bn/arch/amd64/libcrypto_la-bn_arch.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn/arch/amd64/libcrypto_la-bn_arch.lo `test -f 'bn/arch/amd64/bn_arch.c' || echo '$(srcdir)/'`bn/arch/amd64/bn_arch.c + aes/libcrypto_la-aes_core.lo: aes/aes_core.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_core.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_core.Tpo -c -o aes/libcrypto_la-aes_core.lo `test -f 'aes/aes_core.c' || echo '$(srcdir)/'`aes/aes_core.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_core.Tpo aes/$(DEPDIR)/libcrypto_la-aes_core.Plo @@ -5553,13 +5871,6 @@ libcrypto_la-o_str.lo: o_str.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcrypto_la-o_str.lo `test -f 'o_str.c' || echo '$(srcdir)/'`o_str.c -libcrypto_la-o_time.lo: o_time.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcrypto_la-o_time.lo -MD -MP -MF $(DEPDIR)/libcrypto_la-o_time.Tpo -c -o libcrypto_la-o_time.lo `test -f 'o_time.c' || echo '$(srcdir)/'`o_time.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcrypto_la-o_time.Tpo $(DEPDIR)/libcrypto_la-o_time.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='o_time.c' object='libcrypto_la-o_time.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcrypto_la-o_time.lo `test -f 'o_time.c' || echo '$(srcdir)/'`o_time.c - aes/libcrypto_la-aes_cfb.lo: aes/aes_cfb.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT aes/libcrypto_la-aes_cfb.lo -MD -MP -MF aes/$(DEPDIR)/libcrypto_la-aes_cfb.Tpo -c -o aes/libcrypto_la-aes_cfb.lo `test -f 'aes/aes_cfb.c' || echo '$(srcdir)/'`aes/aes_cfb.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) aes/$(DEPDIR)/libcrypto_la-aes_cfb.Tpo aes/$(DEPDIR)/libcrypto_la-aes_cfb.Plo @@ -5700,6 +6011,13 @@ asn1/libcrypto_la-a_time.lo: asn1/a_time.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_time.lo `test -f 'asn1/a_time.c' || echo '$(srcdir)/'`asn1/a_time.c +asn1/libcrypto_la-a_time_posix.lo: asn1/a_time_posix.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_time_posix.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_time_posix.Tpo -c -o asn1/libcrypto_la-a_time_posix.lo `test -f 'asn1/a_time_posix.c' || echo '$(srcdir)/'`asn1/a_time_posix.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_time_posix.Tpo asn1/$(DEPDIR)/libcrypto_la-a_time_posix.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='asn1/a_time_posix.c' object='asn1/libcrypto_la-a_time_posix.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o asn1/libcrypto_la-a_time_posix.lo `test -f 'asn1/a_time_posix.c' || echo '$(srcdir)/'`asn1/a_time_posix.c + asn1/libcrypto_la-a_time_tm.lo: asn1/a_time_tm.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT asn1/libcrypto_la-a_time_tm.lo -MD -MP -MF asn1/$(DEPDIR)/libcrypto_la-a_time_tm.Tpo -c -o asn1/libcrypto_la-a_time_tm.lo `test -f 'asn1/a_time_tm.c' || echo '$(srcdir)/'`asn1/a_time_tm.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) asn1/$(DEPDIR)/libcrypto_la-a_time_tm.Tpo asn1/$(DEPDIR)/libcrypto_la-a_time_tm.Plo @@ -6239,13 +6557,6 @@ bn/libcrypto_la-bn_add.lo: bn/bn_add.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_add.lo `test -f 'bn/bn_add.c' || echo '$(srcdir)/'`bn/bn_add.c -bn/libcrypto_la-bn_asm.lo: bn/bn_asm.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_asm.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_asm.Tpo -c -o bn/libcrypto_la-bn_asm.lo `test -f 'bn/bn_asm.c' || echo '$(srcdir)/'`bn/bn_asm.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_asm.Tpo bn/$(DEPDIR)/libcrypto_la-bn_asm.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_asm.c' object='bn/libcrypto_la-bn_asm.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_asm.lo `test -f 'bn/bn_asm.c' || echo '$(srcdir)/'`bn/bn_asm.c - bn/libcrypto_la-bn_blind.lo: bn/bn_blind.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_blind.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_blind.Tpo -c -o bn/libcrypto_la-bn_blind.lo `test -f 'bn/bn_blind.c' || echo '$(srcdir)/'`bn/bn_blind.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_blind.Tpo bn/$(DEPDIR)/libcrypto_la-bn_blind.Plo @@ -6274,13 +6585,6 @@ bn/libcrypto_la-bn_ctx.lo: bn/bn_ctx.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_ctx.lo `test -f 'bn/bn_ctx.c' || echo '$(srcdir)/'`bn/bn_ctx.c -bn/libcrypto_la-bn_depr.lo: bn/bn_depr.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_depr.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_depr.Tpo -c -o bn/libcrypto_la-bn_depr.lo `test -f 'bn/bn_depr.c' || echo '$(srcdir)/'`bn/bn_depr.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_depr.Tpo bn/$(DEPDIR)/libcrypto_la-bn_depr.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_depr.c' object='bn/libcrypto_la-bn_depr.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_depr.lo `test -f 'bn/bn_depr.c' || echo '$(srcdir)/'`bn/bn_depr.c - bn/libcrypto_la-bn_div.lo: bn/bn_div.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_div.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_div.Tpo -c -o bn/libcrypto_la-bn_div.lo `test -f 'bn/bn_div.c' || echo '$(srcdir)/'`bn/bn_div.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_div.Tpo bn/$(DEPDIR)/libcrypto_la-bn_div.Plo @@ -6302,13 +6606,6 @@ bn/libcrypto_la-bn_exp.lo: bn/bn_exp.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_exp.lo `test -f 'bn/bn_exp.c' || echo '$(srcdir)/'`bn/bn_exp.c -bn/libcrypto_la-bn_exp2.lo: bn/bn_exp2.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_exp2.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_exp2.Tpo -c -o bn/libcrypto_la-bn_exp2.lo `test -f 'bn/bn_exp2.c' || echo '$(srcdir)/'`bn/bn_exp2.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_exp2.Tpo bn/$(DEPDIR)/libcrypto_la-bn_exp2.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_exp2.c' object='bn/libcrypto_la-bn_exp2.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_exp2.lo `test -f 'bn/bn_exp2.c' || echo '$(srcdir)/'`bn/bn_exp2.c - bn/libcrypto_la-bn_gcd.lo: bn/bn_gcd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_gcd.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_gcd.Tpo -c -o bn/libcrypto_la-bn_gcd.lo `test -f 'bn/bn_gcd.c' || echo '$(srcdir)/'`bn/bn_gcd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_gcd.Tpo bn/$(DEPDIR)/libcrypto_la-bn_gcd.Plo @@ -6414,6 +6711,13 @@ bn/libcrypto_la-bn_shift.lo: bn/bn_shift.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_shift.lo `test -f 'bn/bn_shift.c' || echo '$(srcdir)/'`bn/bn_shift.c +bn/libcrypto_la-bn_small_primes.lo: bn/bn_small_primes.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_small_primes.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_small_primes.Tpo -c -o bn/libcrypto_la-bn_small_primes.lo `test -f 'bn/bn_small_primes.c' || echo '$(srcdir)/'`bn/bn_small_primes.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_small_primes.Tpo bn/$(DEPDIR)/libcrypto_la-bn_small_primes.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn/bn_small_primes.c' object='bn/libcrypto_la-bn_small_primes.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn/libcrypto_la-bn_small_primes.lo `test -f 'bn/bn_small_primes.c' || echo '$(srcdir)/'`bn/bn_small_primes.c + bn/libcrypto_la-bn_sqr.lo: bn/bn_sqr.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn/libcrypto_la-bn_sqr.lo -MD -MP -MF bn/$(DEPDIR)/libcrypto_la-bn_sqr.Tpo -c -o bn/libcrypto_la-bn_sqr.lo `test -f 'bn/bn_sqr.c' || echo '$(srcdir)/'`bn/bn_sqr.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) bn/$(DEPDIR)/libcrypto_la-bn_sqr.Tpo bn/$(DEPDIR)/libcrypto_la-bn_sqr.Plo @@ -7142,20 +7446,6 @@ dsa/libcrypto_la-dsa_prn.lo: dsa/dsa_prn.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_prn.lo `test -f 'dsa/dsa_prn.c' || echo '$(srcdir)/'`dsa/dsa_prn.c -dsa/libcrypto_la-dsa_sign.lo: dsa/dsa_sign.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_sign.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Tpo -c -o dsa/libcrypto_la-dsa_sign.lo `test -f 'dsa/dsa_sign.c' || echo '$(srcdir)/'`dsa/dsa_sign.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_sign.c' object='dsa/libcrypto_la-dsa_sign.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_sign.lo `test -f 'dsa/dsa_sign.c' || echo '$(srcdir)/'`dsa/dsa_sign.c - -dsa/libcrypto_la-dsa_vrf.lo: dsa/dsa_vrf.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dsa/libcrypto_la-dsa_vrf.lo -MD -MP -MF dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Tpo -c -o dsa/libcrypto_la-dsa_vrf.lo `test -f 'dsa/dsa_vrf.c' || echo '$(srcdir)/'`dsa/dsa_vrf.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Tpo dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dsa/dsa_vrf.c' object='dsa/libcrypto_la-dsa_vrf.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dsa/libcrypto_la-dsa_vrf.lo `test -f 'dsa/dsa_vrf.c' || echo '$(srcdir)/'`dsa/dsa_vrf.c - dso/libcrypto_la-dso_dlfcn.lo: dso/dso_dlfcn.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dso/libcrypto_la-dso_dlfcn.lo -MD -MP -MF dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Tpo -c -o dso/libcrypto_la-dso_dlfcn.lo `test -f 'dso/dso_dlfcn.c' || echo '$(srcdir)/'`dso/dso_dlfcn.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Tpo dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Plo @@ -7338,6 +7628,13 @@ ec/libcrypto_la-ecp_smpl.lo: ec/ecp_smpl.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ecp_smpl.lo `test -f 'ec/ecp_smpl.c' || echo '$(srcdir)/'`ec/ecp_smpl.c +ec/libcrypto_la-ecx_methods.lo: ec/ecx_methods.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ec/libcrypto_la-ecx_methods.lo -MD -MP -MF ec/$(DEPDIR)/libcrypto_la-ecx_methods.Tpo -c -o ec/libcrypto_la-ecx_methods.lo `test -f 'ec/ecx_methods.c' || echo '$(srcdir)/'`ec/ecx_methods.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ec/$(DEPDIR)/libcrypto_la-ecx_methods.Tpo ec/$(DEPDIR)/libcrypto_la-ecx_methods.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ec/ecx_methods.c' object='ec/libcrypto_la-ecx_methods.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ec/libcrypto_la-ecx_methods.lo `test -f 'ec/ecx_methods.c' || echo '$(srcdir)/'`ec/ecx_methods.c + ecdh/libcrypto_la-ecdh_kdf.lo: ecdh/ecdh_kdf.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ecdh/libcrypto_la-ecdh_kdf.lo -MD -MP -MF ecdh/$(DEPDIR)/libcrypto_la-ecdh_kdf.Tpo -c -o ecdh/libcrypto_la-ecdh_kdf.lo `test -f 'ecdh/ecdh_kdf.c' || echo '$(srcdir)/'`ecdh/ecdh_kdf.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ecdh/$(DEPDIR)/libcrypto_la-ecdh_kdf.Tpo ecdh/$(DEPDIR)/libcrypto_la-ecdh_kdf.Plo @@ -7625,6 +7922,13 @@ evp/libcrypto_la-c_all.lo: evp/c_all.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-c_all.lo `test -f 'evp/c_all.c' || echo '$(srcdir)/'`evp/c_all.c +evp/libcrypto_la-cipher_method_lib.lo: evp/cipher_method_lib.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-cipher_method_lib.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-cipher_method_lib.Tpo -c -o evp/libcrypto_la-cipher_method_lib.lo `test -f 'evp/cipher_method_lib.c' || echo '$(srcdir)/'`evp/cipher_method_lib.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-cipher_method_lib.Tpo evp/$(DEPDIR)/libcrypto_la-cipher_method_lib.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='evp/cipher_method_lib.c' object='evp/libcrypto_la-cipher_method_lib.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o evp/libcrypto_la-cipher_method_lib.lo `test -f 'evp/cipher_method_lib.c' || echo '$(srcdir)/'`evp/cipher_method_lib.c + evp/libcrypto_la-digest.lo: evp/digest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT evp/libcrypto_la-digest.lo -MD -MP -MF evp/$(DEPDIR)/libcrypto_la-digest.Tpo -c -o evp/libcrypto_la-digest.lo `test -f 'evp/digest.c' || echo '$(srcdir)/'`evp/digest.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) evp/$(DEPDIR)/libcrypto_la-digest.Tpo evp/$(DEPDIR)/libcrypto_la-digest.Plo @@ -8962,6 +9266,13 @@ ui/libcrypto_la-ui_lib.lo: ui/ui_lib.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ui/libcrypto_la-ui_lib.lo `test -f 'ui/ui_lib.c' || echo '$(srcdir)/'`ui/ui_lib.c +ui/libcrypto_la-ui_null.lo: ui/ui_null.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ui/libcrypto_la-ui_null.lo -MD -MP -MF ui/$(DEPDIR)/libcrypto_la-ui_null.Tpo -c -o ui/libcrypto_la-ui_null.lo `test -f 'ui/ui_null.c' || echo '$(srcdir)/'`ui/ui_null.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ui/$(DEPDIR)/libcrypto_la-ui_null.Tpo ui/$(DEPDIR)/libcrypto_la-ui_null.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ui/ui_null.c' object='ui/libcrypto_la-ui_null.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ui/libcrypto_la-ui_null.lo `test -f 'ui/ui_null.c' || echo '$(srcdir)/'`ui/ui_null.c + ui/libcrypto_la-ui_openssl.lo: ui/ui_openssl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcrypto_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ui/libcrypto_la-ui_openssl.lo -MD -MP -MF ui/$(DEPDIR)/libcrypto_la-ui_openssl.Tpo -c -o ui/libcrypto_la-ui_openssl.lo `test -f 'ui/ui_openssl.c' || echo '$(srcdir)/'`ui/ui_openssl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) ui/$(DEPDIR)/libcrypto_la-ui_openssl.Tpo ui/$(DEPDIR)/libcrypto_la-ui_openssl.Plo @@ -9462,6 +9773,7 @@ clean-libtool: -rm -rf bf/.libs bf/_libs -rm -rf bio/.libs bio/_libs -rm -rf bn/.libs bn/_libs + -rm -rf bn/arch/amd64/.libs bn/arch/amd64/_libs -rm -rf buffer/.libs buffer/_libs -rm -rf bytestring/.libs bytestring/_libs -rm -rf camellia/.libs camellia/_libs @@ -9645,6 +9957,8 @@ distclean-generic: -rm -f bio/$(am__dirstamp) -rm -f bn/$(DEPDIR)/$(am__dirstamp) -rm -f bn/$(am__dirstamp) + -rm -f bn/arch/amd64/$(DEPDIR)/$(am__dirstamp) + -rm -f bn/arch/amd64/$(am__dirstamp) -rm -f buffer/$(DEPDIR)/$(am__dirstamp) -rm -f buffer/$(am__dirstamp) -rm -f bytestring/$(DEPDIR)/$(am__dirstamp) @@ -9776,12 +10090,12 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/libcrypto_la-o_fips.Plo -rm -f ./$(DEPDIR)/libcrypto_la-o_init.Plo -rm -f ./$(DEPDIR)/libcrypto_la-o_str.Plo - -rm -f ./$(DEPDIR)/libcrypto_la-o_time.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes-elf-armv4.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes-elf-x86_64.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes-macosx-x86_64.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes-masm-x86_64.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes-mingw64-x86_64.Plo + -rm -f aes/$(DEPDIR)/libcrypto_la-aes-mips.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes_cbc.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes_cfb.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes_core.Plo @@ -9820,6 +10134,7 @@ distclean: distclean-am -rm -f asn1/$(DEPDIR)/libcrypto_la-a_string.Plo -rm -f asn1/$(DEPDIR)/libcrypto_la-a_strnid.Plo -rm -f asn1/$(DEPDIR)/libcrypto_la-a_time.Plo + -rm -f asn1/$(DEPDIR)/libcrypto_la-a_time_posix.Plo -rm -f asn1/$(DEPDIR)/libcrypto_la-a_time_tm.Plo -rm -f asn1/$(DEPDIR)/libcrypto_la-a_type.Plo -rm -f asn1/$(DEPDIR)/libcrypto_la-a_utf8.Plo @@ -9896,17 +10211,15 @@ distclean: distclean-am -rm -f bio/$(DEPDIR)/libcrypto_la-bss_mem.Plo -rm -f bio/$(DEPDIR)/libcrypto_la-bss_null.Plo -rm -f bio/$(DEPDIR)/libcrypto_la-bss_sock.Plo + -rm -f bn/$(DEPDIR)/libcrypto_la-bn-mips.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_add.Plo - -rm -f bn/$(DEPDIR)/libcrypto_la-bn_asm.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_blind.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_bpsw.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_const.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_ctx.Plo - -rm -f bn/$(DEPDIR)/libcrypto_la-bn_depr.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_div.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_err.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_exp.Plo - -rm -f bn/$(DEPDIR)/libcrypto_la-bn_exp2.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_gcd.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_gf2m.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_isqrt.Plo @@ -9922,6 +10235,7 @@ distclean: distclean-am -rm -f bn/$(DEPDIR)/libcrypto_la-bn_rand.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_recp.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_shift.Plo + -rm -f bn/$(DEPDIR)/libcrypto_la-bn_small_primes.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_sqr.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_sqrt.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_word.Plo @@ -9937,9 +10251,22 @@ distclean: distclean-am -rm -f bn/$(DEPDIR)/libcrypto_la-mont-elf-x86_64.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-mont-macosx-x86_64.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-mont-masm-x86_64.Plo + -rm -f bn/$(DEPDIR)/libcrypto_la-mont-mips.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-mont5-elf-x86_64.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-mont5-macosx-x86_64.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-mont5-masm-x86_64.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_add.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmadd.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmul.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_4_8_alt.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_8_16_alt.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_4_8_alt.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_8_16_alt.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sub.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bn_arch.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-word_clz.Plo -rm -f buffer/$(DEPDIR)/libcrypto_la-buf_err.Plo -rm -f buffer/$(DEPDIR)/libcrypto_la-buf_str.Plo -rm -f buffer/$(DEPDIR)/libcrypto_la-buffer.Plo @@ -10080,8 +10407,6 @@ distclean: distclean-am -rm -f dsa/$(DEPDIR)/libcrypto_la-dsa_ossl.Plo -rm -f dsa/$(DEPDIR)/libcrypto_la-dsa_pmeth.Plo -rm -f dsa/$(DEPDIR)/libcrypto_la-dsa_prn.Plo - -rm -f dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Plo - -rm -f dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Plo -rm -f dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Plo -rm -f dso/$(DEPDIR)/libcrypto_la-dso_err.Plo -rm -f dso/$(DEPDIR)/libcrypto_la-dso_lib.Plo @@ -10108,6 +10433,7 @@ distclean: distclean-am -rm -f ec/$(DEPDIR)/libcrypto_la-ecp_nist.Plo -rm -f ec/$(DEPDIR)/libcrypto_la-ecp_oct.Plo -rm -f ec/$(DEPDIR)/libcrypto_la-ecp_smpl.Plo + -rm -f ec/$(DEPDIR)/libcrypto_la-ecx_methods.Plo -rm -f ecdh/$(DEPDIR)/libcrypto_la-ecdh_kdf.Plo -rm -f ecdh/$(DEPDIR)/libcrypto_la-ech_err.Plo -rm -f ecdh/$(DEPDIR)/libcrypto_la-ech_key.Plo @@ -10149,6 +10475,7 @@ distclean: distclean-am -rm -f evp/$(DEPDIR)/libcrypto_la-bio_enc.Plo -rm -f evp/$(DEPDIR)/libcrypto_la-bio_md.Plo -rm -f evp/$(DEPDIR)/libcrypto_la-c_all.Plo + -rm -f evp/$(DEPDIR)/libcrypto_la-cipher_method_lib.Plo -rm -f evp/$(DEPDIR)/libcrypto_la-digest.Plo -rm -f evp/$(DEPDIR)/libcrypto_la-e_aes.Plo -rm -f evp/$(DEPDIR)/libcrypto_la-e_aes_cbc_hmac_sha1.Plo @@ -10344,6 +10671,7 @@ distclean: distclean-am -rm -f sha/$(DEPDIR)/libcrypto_la-sha1-macosx-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha1-masm-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha1-mingw64-x86_64.Plo + -rm -f sha/$(DEPDIR)/libcrypto_la-sha1-mips.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha1_one.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha1dgst.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha256-elf-armv4.Plo @@ -10351,12 +10679,14 @@ distclean: distclean-am -rm -f sha/$(DEPDIR)/libcrypto_la-sha256-macosx-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha256-masm-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha256-mingw64-x86_64.Plo + -rm -f sha/$(DEPDIR)/libcrypto_la-sha256-mips.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha256.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-elf-armv4.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-elf-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-macosx-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-masm-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-mingw64-x86_64.Plo + -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-mips.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512.Plo -rm -f sm3/$(DEPDIR)/libcrypto_la-sm3.Plo -rm -f sm4/$(DEPDIR)/libcrypto_la-sm4.Plo @@ -10375,6 +10705,7 @@ distclean: distclean-am -rm -f txt_db/$(DEPDIR)/libcrypto_la-txt_db.Plo -rm -f ui/$(DEPDIR)/libcrypto_la-ui_err.Plo -rm -f ui/$(DEPDIR)/libcrypto_la-ui_lib.Plo + -rm -f ui/$(DEPDIR)/libcrypto_la-ui_null.Plo -rm -f ui/$(DEPDIR)/libcrypto_la-ui_openssl.Plo -rm -f ui/$(DEPDIR)/libcrypto_la-ui_openssl_win.Plo -rm -f ui/$(DEPDIR)/libcrypto_la-ui_util.Plo @@ -10510,12 +10841,12 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/libcrypto_la-o_fips.Plo -rm -f ./$(DEPDIR)/libcrypto_la-o_init.Plo -rm -f ./$(DEPDIR)/libcrypto_la-o_str.Plo - -rm -f ./$(DEPDIR)/libcrypto_la-o_time.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes-elf-armv4.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes-elf-x86_64.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes-macosx-x86_64.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes-masm-x86_64.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes-mingw64-x86_64.Plo + -rm -f aes/$(DEPDIR)/libcrypto_la-aes-mips.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes_cbc.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes_cfb.Plo -rm -f aes/$(DEPDIR)/libcrypto_la-aes_core.Plo @@ -10554,6 +10885,7 @@ maintainer-clean: maintainer-clean-am -rm -f asn1/$(DEPDIR)/libcrypto_la-a_string.Plo -rm -f asn1/$(DEPDIR)/libcrypto_la-a_strnid.Plo -rm -f asn1/$(DEPDIR)/libcrypto_la-a_time.Plo + -rm -f asn1/$(DEPDIR)/libcrypto_la-a_time_posix.Plo -rm -f asn1/$(DEPDIR)/libcrypto_la-a_time_tm.Plo -rm -f asn1/$(DEPDIR)/libcrypto_la-a_type.Plo -rm -f asn1/$(DEPDIR)/libcrypto_la-a_utf8.Plo @@ -10630,17 +10962,15 @@ maintainer-clean: maintainer-clean-am -rm -f bio/$(DEPDIR)/libcrypto_la-bss_mem.Plo -rm -f bio/$(DEPDIR)/libcrypto_la-bss_null.Plo -rm -f bio/$(DEPDIR)/libcrypto_la-bss_sock.Plo + -rm -f bn/$(DEPDIR)/libcrypto_la-bn-mips.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_add.Plo - -rm -f bn/$(DEPDIR)/libcrypto_la-bn_asm.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_blind.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_bpsw.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_const.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_ctx.Plo - -rm -f bn/$(DEPDIR)/libcrypto_la-bn_depr.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_div.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_err.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_exp.Plo - -rm -f bn/$(DEPDIR)/libcrypto_la-bn_exp2.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_gcd.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_gf2m.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_isqrt.Plo @@ -10656,6 +10986,7 @@ maintainer-clean: maintainer-clean-am -rm -f bn/$(DEPDIR)/libcrypto_la-bn_rand.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_recp.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_shift.Plo + -rm -f bn/$(DEPDIR)/libcrypto_la-bn_small_primes.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_sqr.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_sqrt.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-bn_word.Plo @@ -10671,9 +11002,22 @@ maintainer-clean: maintainer-clean-am -rm -f bn/$(DEPDIR)/libcrypto_la-mont-elf-x86_64.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-mont-macosx-x86_64.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-mont-masm-x86_64.Plo + -rm -f bn/$(DEPDIR)/libcrypto_la-mont-mips.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-mont5-elf-x86_64.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-mont5-macosx-x86_64.Plo -rm -f bn/$(DEPDIR)/libcrypto_la-mont5-masm-x86_64.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_add.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmadd.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_cmul.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_4_8_alt.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_mul_8_16_alt.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_4_8_alt.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sqr_8_16_alt.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bignum_sub.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-bn_arch.Plo + -rm -f bn/arch/amd64/$(DEPDIR)/libcrypto_la-word_clz.Plo -rm -f buffer/$(DEPDIR)/libcrypto_la-buf_err.Plo -rm -f buffer/$(DEPDIR)/libcrypto_la-buf_str.Plo -rm -f buffer/$(DEPDIR)/libcrypto_la-buffer.Plo @@ -10814,8 +11158,6 @@ maintainer-clean: maintainer-clean-am -rm -f dsa/$(DEPDIR)/libcrypto_la-dsa_ossl.Plo -rm -f dsa/$(DEPDIR)/libcrypto_la-dsa_pmeth.Plo -rm -f dsa/$(DEPDIR)/libcrypto_la-dsa_prn.Plo - -rm -f dsa/$(DEPDIR)/libcrypto_la-dsa_sign.Plo - -rm -f dsa/$(DEPDIR)/libcrypto_la-dsa_vrf.Plo -rm -f dso/$(DEPDIR)/libcrypto_la-dso_dlfcn.Plo -rm -f dso/$(DEPDIR)/libcrypto_la-dso_err.Plo -rm -f dso/$(DEPDIR)/libcrypto_la-dso_lib.Plo @@ -10842,6 +11184,7 @@ maintainer-clean: maintainer-clean-am -rm -f ec/$(DEPDIR)/libcrypto_la-ecp_nist.Plo -rm -f ec/$(DEPDIR)/libcrypto_la-ecp_oct.Plo -rm -f ec/$(DEPDIR)/libcrypto_la-ecp_smpl.Plo + -rm -f ec/$(DEPDIR)/libcrypto_la-ecx_methods.Plo -rm -f ecdh/$(DEPDIR)/libcrypto_la-ecdh_kdf.Plo -rm -f ecdh/$(DEPDIR)/libcrypto_la-ech_err.Plo -rm -f ecdh/$(DEPDIR)/libcrypto_la-ech_key.Plo @@ -10883,6 +11226,7 @@ maintainer-clean: maintainer-clean-am -rm -f evp/$(DEPDIR)/libcrypto_la-bio_enc.Plo -rm -f evp/$(DEPDIR)/libcrypto_la-bio_md.Plo -rm -f evp/$(DEPDIR)/libcrypto_la-c_all.Plo + -rm -f evp/$(DEPDIR)/libcrypto_la-cipher_method_lib.Plo -rm -f evp/$(DEPDIR)/libcrypto_la-digest.Plo -rm -f evp/$(DEPDIR)/libcrypto_la-e_aes.Plo -rm -f evp/$(DEPDIR)/libcrypto_la-e_aes_cbc_hmac_sha1.Plo @@ -11078,6 +11422,7 @@ maintainer-clean: maintainer-clean-am -rm -f sha/$(DEPDIR)/libcrypto_la-sha1-macosx-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha1-masm-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha1-mingw64-x86_64.Plo + -rm -f sha/$(DEPDIR)/libcrypto_la-sha1-mips.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha1_one.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha1dgst.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha256-elf-armv4.Plo @@ -11085,12 +11430,14 @@ maintainer-clean: maintainer-clean-am -rm -f sha/$(DEPDIR)/libcrypto_la-sha256-macosx-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha256-masm-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha256-mingw64-x86_64.Plo + -rm -f sha/$(DEPDIR)/libcrypto_la-sha256-mips.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha256.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-elf-armv4.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-elf-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-macosx-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-masm-x86_64.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-mingw64-x86_64.Plo + -rm -f sha/$(DEPDIR)/libcrypto_la-sha512-mips.Plo -rm -f sha/$(DEPDIR)/libcrypto_la-sha512.Plo -rm -f sm3/$(DEPDIR)/libcrypto_la-sm3.Plo -rm -f sm4/$(DEPDIR)/libcrypto_la-sm4.Plo @@ -11109,6 +11456,7 @@ maintainer-clean: maintainer-clean-am -rm -f txt_db/$(DEPDIR)/libcrypto_la-txt_db.Plo -rm -f ui/$(DEPDIR)/libcrypto_la-ui_err.Plo -rm -f ui/$(DEPDIR)/libcrypto_la-ui_lib.Plo + -rm -f ui/$(DEPDIR)/libcrypto_la-ui_null.Plo -rm -f ui/$(DEPDIR)/libcrypto_la-ui_openssl.Plo -rm -f ui/$(DEPDIR)/libcrypto_la-ui_openssl_win.Plo -rm -f ui/$(DEPDIR)/libcrypto_la-ui_util.Plo diff --git a/crypto/VERSION b/crypto/VERSION index 5525aec1..a7a78691 100644 --- a/crypto/VERSION +++ b/crypto/VERSION @@ -1 +1 @@ -50:0:0 +50:2:0 diff --git a/crypto/aes/aes-elf-x86_64.S b/crypto/aes/aes-elf-x86_64.S index 83c0053a..5f9ccf69 100644 --- a/crypto/aes/aes-elf-x86_64.S +++ b/crypto/aes/aes-elf-x86_64.S @@ -1756,6 +1756,7 @@ AES_cbc_encrypt: .Lcbc_epilogue: retq .size AES_cbc_encrypt,.-AES_cbc_encrypt +.section .rodata .align 64 .LAES_Te: .long 0xa56363c6,0xa56363c6 @@ -2540,8 +2541,8 @@ AES_cbc_encrypt: .byte 0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d .long 0x80808080, 0x80808080, 0xfefefefe, 0xfefefefe .long 0x1b1b1b1b, 0x1b1b1b1b, 0, 0 -.byte 65,69,83,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 64 +.text #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/aes/aes-macosx-x86_64.S b/crypto/aes/aes-macosx-x86_64.S index 8a9c36eb..9e9d1137 100644 --- a/crypto/aes/aes-macosx-x86_64.S +++ b/crypto/aes/aes-macosx-x86_64.S @@ -1756,6 +1756,7 @@ L$cbc_popfq: L$cbc_epilogue: retq +.section __DATA,__const .p2align 6 L$AES_Te: .long 0xa56363c6,0xa56363c6 @@ -2540,5 +2541,5 @@ L$AES_Td: .byte 0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d .long 0x80808080, 0x80808080, 0xfefefefe, 0xfefefefe .long 0x1b1b1b1b, 0x1b1b1b1b, 0, 0 -.byte 65,69,83,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 6 +.text diff --git a/crypto/aes/aes-masm-x86_64.S b/crypto/aes/aes-masm-x86_64.S index e99ccf67..5a18f634 100644 --- a/crypto/aes/aes-masm-x86_64.S +++ b/crypto/aes/aes-masm-x86_64.S @@ -1887,6 +1887,8 @@ $L$cbc_epilogue:: DB 0F3h,0C3h ;repret $L$SEH_end_AES_cbc_encrypt:: AES_cbc_encrypt ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 $L$AES_Te:: DD 0a56363c6h,0a56363c6h @@ -2671,11 +2673,9 @@ DB 017h,02bh,004h,07eh,0bah,077h,0d6h,026h DB 0e1h,069h,014h,063h,055h,021h,00ch,07dh DD 080808080h,080808080h,0fefefefeh,0fefefefeh DD 01b1b1b1bh,01b1b1b1bh,0,0 -DB 65,69,83,32,102,111,114,32,120,56,54,95,54,52,44,32 -DB 67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97 -DB 112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103 -DB 62,0 ALIGN 64 +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 diff --git a/crypto/aes/aes-mingw64-x86_64.S b/crypto/aes/aes-mingw64-x86_64.S index ca2d60f9..93214d83 100644 --- a/crypto/aes/aes-mingw64-x86_64.S +++ b/crypto/aes/aes-mingw64-x86_64.S @@ -1809,6 +1809,7 @@ AES_cbc_encrypt: movq 16(%rsp),%rsi retq .LSEH_end_AES_cbc_encrypt: +.section .rodata .p2align 6 .LAES_Te: .long 0xa56363c6,0xa56363c6 @@ -2593,8 +2594,8 @@ AES_cbc_encrypt: .byte 0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d .long 0x80808080, 0x80808080, 0xfefefefe, 0xfefefefe .long 0x1b1b1b1b, 0x1b1b1b1b, 0, 0 -.byte 65,69,83,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 6 +.text .def block_se_handler; .scl 3; .type 32; .endef .p2align 4 diff --git a/crypto/aes/aes-mips.S b/crypto/aes/aes-mips.S new file mode 100644 index 00000000..2a8e3e48 --- /dev/null +++ b/crypto/aes/aes-mips.S @@ -0,0 +1,1336 @@ +.text +#if !defined(__vxworks) || defined(__pic__) +.option pic2 +#endif +.set noat +.align 5 +.ent _mips_AES_encrypt +_mips_AES_encrypt: + .frame $29,0,$31 + .set reorder + lw $12,0($6) + lw $13,4($6) + lw $14,8($6) + lw $15,12($6) + lw $30,240($6) + add $3,$6,16 + + xor $8,$12 + xor $9,$13 + xor $10,$14 + xor $11,$15 + + sub $30,1 + srl $1,$9,6 +.Loop_enc: + srl $2,$10,6 + srl $24,$11,6 + srl $25,$8,6 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lwl $12,2($1) # Te1[s1>>16] + lwl $13,2($2) # Te1[s2>>16] + lwl $14,2($24) # Te1[s3>>16] + lwl $15,2($25) # Te1[s0>>16] + lwr $12,3($1) # Te1[s1>>16] + lwr $13,3($2) # Te1[s2>>16] + lwr $14,3($24) # Te1[s3>>16] + lwr $15,3($25) # Te1[s0>>16] + + srl $1,$10,14 + srl $2,$11,14 + srl $24,$8,14 + srl $25,$9,14 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lwl $16,1($1) # Te2[s2>>8] + lwl $17,1($2) # Te2[s3>>8] + lwl $18,1($24) # Te2[s0>>8] + lwl $19,1($25) # Te2[s1>>8] + lwr $16,2($1) # Te2[s2>>8] + lwr $17,2($2) # Te2[s3>>8] + lwr $18,2($24) # Te2[s0>>8] + lwr $19,2($25) # Te2[s1>>8] + + srl $1,$11,22 + srl $2,$8,22 + srl $24,$9,22 + srl $25,$10,22 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lwl $20,0($1) # Te3[s3] + lwl $21,0($2) # Te3[s0] + lwl $22,0($24) # Te3[s1] + lwl $23,0($25) # Te3[s2] + lwr $20,1($1) # Te3[s3] + lwr $21,1($2) # Te3[s0] + lwr $22,1($24) # Te3[s1] + lwr $23,1($25) # Te3[s2] + + sll $1,$8,2 + sll $2,$9,2 + sll $24,$10,2 + sll $25,$11,2 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + xor $12,$16 + xor $13,$17 + xor $14,$18 + xor $15,$19 + lw $16,0($1) # Te0[s0>>24] + lw $17,0($2) # Te0[s1>>24] + lw $18,0($24) # Te0[s2>>24] + lw $19,0($25) # Te0[s3>>24] + + lw $8,0($3) + lw $9,4($3) + lw $10,8($3) + lw $11,12($3) + + xor $12,$20 + xor $13,$21 + xor $14,$22 + xor $15,$23 + + xor $12,$16 + xor $13,$17 + xor $14,$18 + xor $15,$19 + + sub $30,1 + add $3,16 + xor $8,$12 + xor $9,$13 + xor $10,$14 + xor $11,$15 + .set noreorder + bnez $30,.Loop_enc + srl $1,$9,6 + + .set reorder + srl $2,$10,6 + srl $24,$11,6 + srl $25,$8,6 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $12,2($1) # Te4[s1>>16] + lbu $13,2($2) # Te4[s2>>16] + lbu $14,2($24) # Te4[s3>>16] + lbu $15,2($25) # Te4[s0>>16] + + srl $1,$10,14 + srl $2,$11,14 + srl $24,$8,14 + srl $25,$9,14 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $16,2($1) # Te4[s2>>8] + lbu $17,2($2) # Te4[s3>>8] + lbu $18,2($24) # Te4[s0>>8] + lbu $19,2($25) # Te4[s1>>8] + + sll $1,$8,2 + sll $2,$9,2 + sll $24,$10,2 + sll $25,$11,2 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $20,2($1) # Te4[s0>>24] + lbu $21,2($2) # Te4[s1>>24] + lbu $22,2($24) # Te4[s2>>24] + lbu $23,2($25) # Te4[s3>>24] + + srl $1,$11,22 + srl $2,$8,22 + srl $24,$9,22 + srl $25,$10,22 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + + sll $12,$12,8 + sll $13,$13,8 + sll $14,$14,8 + sll $15,$15,8 + + sll $16,$16,16 + sll $17,$17,16 + sll $18,$18,16 + sll $19,$19,16 + + xor $12,$16 + xor $13,$17 + xor $14,$18 + xor $15,$19 + + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $16,2($1) # Te4[s3] + lbu $17,2($2) # Te4[s0] + lbu $18,2($24) # Te4[s1] + lbu $19,2($25) # Te4[s2] + + #sll $20,$20,0 + #sll $21,$21,0 + #sll $22,$22,0 + #sll $23,$23,0 + + lw $8,0($3) + lw $9,4($3) + lw $10,8($3) + lw $11,12($3) + + xor $12,$20 + xor $13,$21 + xor $14,$22 + xor $15,$23 + + sll $16,$16,24 + sll $17,$17,24 + sll $18,$18,24 + sll $19,$19,24 + + xor $12,$16 + xor $13,$17 + xor $14,$18 + xor $15,$19 + + xor $8,$12 + xor $9,$13 + xor $10,$14 + xor $11,$15 + + jr $31 +.end _mips_AES_encrypt + +.align 5 +.globl AES_encrypt +.ent AES_encrypt +AES_encrypt: + .frame $29,64,$31 + .mask 3237937152,-4 + .set noreorder + .cpload $25 + sub $29,64 + sw $31,64-1*4($29) + sw $30,64-2*4($29) + sw $23,64-3*4($29) + sw $22,64-4*4($29) + sw $21,64-5*4($29) + sw $20,64-6*4($29) + sw $19,64-7*4($29) + sw $18,64-8*4($29) + sw $17,64-9*4($29) + sw $16,64-10*4($29) + .set reorder + la $7,AES_Te # PIC-ified 'load address' + + lwl $8,0+3($4) + lwl $9,4+3($4) + lwl $10,8+3($4) + lwl $11,12+3($4) + lwr $8,0+0($4) + lwr $9,4+0($4) + lwr $10,8+0($4) + lwr $11,12+0($4) + + bal _mips_AES_encrypt + + swr $8,0+0($5) + swr $9,4+0($5) + swr $10,8+0($5) + swr $11,12+0($5) + swl $8,0+3($5) + swl $9,4+3($5) + swl $10,8+3($5) + swl $11,12+3($5) + + .set noreorder + lw $31,64-1*4($29) + lw $30,64-2*4($29) + lw $23,64-3*4($29) + lw $22,64-4*4($29) + lw $21,64-5*4($29) + lw $20,64-6*4($29) + lw $19,64-7*4($29) + lw $18,64-8*4($29) + lw $17,64-9*4($29) + lw $16,64-10*4($29) + jr $31 + add $29,64 +.end AES_encrypt +.align 5 +.ent _mips_AES_decrypt +_mips_AES_decrypt: + .frame $29,0,$31 + .set reorder + lw $12,0($6) + lw $13,4($6) + lw $14,8($6) + lw $15,12($6) + lw $30,240($6) + add $3,$6,16 + + xor $8,$12 + xor $9,$13 + xor $10,$14 + xor $11,$15 + + sub $30,1 + srl $1,$11,6 +.Loop_dec: + srl $2,$8,6 + srl $24,$9,6 + srl $25,$10,6 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lwl $12,2($1) # Td1[s3>>16] + lwl $13,2($2) # Td1[s0>>16] + lwl $14,2($24) # Td1[s1>>16] + lwl $15,2($25) # Td1[s2>>16] + lwr $12,3($1) # Td1[s3>>16] + lwr $13,3($2) # Td1[s0>>16] + lwr $14,3($24) # Td1[s1>>16] + lwr $15,3($25) # Td1[s2>>16] + + srl $1,$10,14 + srl $2,$11,14 + srl $24,$8,14 + srl $25,$9,14 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lwl $16,1($1) # Td2[s2>>8] + lwl $17,1($2) # Td2[s3>>8] + lwl $18,1($24) # Td2[s0>>8] + lwl $19,1($25) # Td2[s1>>8] + lwr $16,2($1) # Td2[s2>>8] + lwr $17,2($2) # Td2[s3>>8] + lwr $18,2($24) # Td2[s0>>8] + lwr $19,2($25) # Td2[s1>>8] + + srl $1,$9,22 + srl $2,$10,22 + srl $24,$11,22 + srl $25,$8,22 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lwl $20,0($1) # Td3[s1] + lwl $21,0($2) # Td3[s2] + lwl $22,0($24) # Td3[s3] + lwl $23,0($25) # Td3[s0] + lwr $20,1($1) # Td3[s1] + lwr $21,1($2) # Td3[s2] + lwr $22,1($24) # Td3[s3] + lwr $23,1($25) # Td3[s0] + + sll $1,$8,2 + sll $2,$9,2 + sll $24,$10,2 + sll $25,$11,2 + and $1,0x3fc + and $2,0x3fc + and $24,0x3fc + and $25,0x3fc + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + + xor $12,$16 + xor $13,$17 + xor $14,$18 + xor $15,$19 + + + lw $16,0($1) # Td0[s0>>24] + lw $17,0($2) # Td0[s1>>24] + lw $18,0($24) # Td0[s2>>24] + lw $19,0($25) # Td0[s3>>24] + + lw $8,0($3) + lw $9,4($3) + lw $10,8($3) + lw $11,12($3) + + xor $12,$20 + xor $13,$21 + xor $14,$22 + xor $15,$23 + + xor $12,$16 + xor $13,$17 + xor $14,$18 + xor $15,$19 + + sub $30,1 + add $3,16 + xor $8,$12 + xor $9,$13 + xor $10,$14 + xor $11,$15 + .set noreorder + bnez $30,.Loop_dec + srl $1,$11,6 + + .set reorder + lw $16,1024($7) # prefetch Td4 + lw $17,1024+32($7) + lw $18,1024+64($7) + lw $19,1024+96($7) + lw $20,1024+128($7) + lw $21,1024+160($7) + lw $22,1024+192($7) + lw $23,1024+224($7) + + srl $1,$11,8 + srl $2,$8,8 + srl $24,$9,8 + srl $25,$10,8 + and $1,0xff + and $2,0xff + and $24,0xff + and $25,0xff + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $12,1024($1) # Td4[s3>>16] + lbu $13,1024($2) # Td4[s0>>16] + lbu $14,1024($24) # Td4[s1>>16] + lbu $15,1024($25) # Td4[s2>>16] + + srl $1,$10,16 + srl $2,$11,16 + srl $24,$8,16 + srl $25,$9,16 + and $1,0xff + and $2,0xff + and $24,0xff + and $25,0xff + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $16,1024($1) # Td4[s2>>8] + lbu $17,1024($2) # Td4[s3>>8] + lbu $18,1024($24) # Td4[s0>>8] + lbu $19,1024($25) # Td4[s1>>8] + + and $1,$8,0xff + and $2,$9,0xff + and $24,$10,0xff + and $25,$11,0xff + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $20,1024($1) # Td4[s0>>24] + lbu $21,1024($2) # Td4[s1>>24] + lbu $22,1024($24) # Td4[s2>>24] + lbu $23,1024($25) # Td4[s3>>24] + + srl $1,$9,24 + srl $2,$10,24 + srl $24,$11,24 + srl $25,$8,24 + + sll $12,$12,8 + sll $13,$13,8 + sll $14,$14,8 + sll $15,$15,8 + + sll $16,$16,16 + sll $17,$17,16 + sll $18,$18,16 + sll $19,$19,16 + + xor $12,$16 + xor $13,$17 + xor $14,$18 + xor $15,$19 + + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $16,1024($1) # Td4[s1] + lbu $17,1024($2) # Td4[s2] + lbu $18,1024($24) # Td4[s3] + lbu $19,1024($25) # Td4[s0] + + #sll $20,$20,0 + #sll $21,$21,0 + #sll $22,$22,0 + #sll $23,$23,0 + + lw $8,0($3) + lw $9,4($3) + lw $10,8($3) + lw $11,12($3) + + sll $16,$16,24 + sll $17,$17,24 + sll $18,$18,24 + sll $19,$19,24 + + + xor $12,$20 + xor $13,$21 + xor $14,$22 + xor $15,$23 + + xor $12,$16 + xor $13,$17 + xor $14,$18 + xor $15,$19 + + xor $8,$12 + xor $9,$13 + xor $10,$14 + xor $11,$15 + + jr $31 +.end _mips_AES_decrypt + +.align 5 +.globl AES_decrypt +.ent AES_decrypt +AES_decrypt: + .frame $29,64,$31 + .mask 3237937152,-4 + .set noreorder + .cpload $25 + sub $29,64 + sw $31,64-1*4($29) + sw $30,64-2*4($29) + sw $23,64-3*4($29) + sw $22,64-4*4($29) + sw $21,64-5*4($29) + sw $20,64-6*4($29) + sw $19,64-7*4($29) + sw $18,64-8*4($29) + sw $17,64-9*4($29) + sw $16,64-10*4($29) + .set reorder + la $7,AES_Td # PIC-ified 'load address' + + lwl $8,0+3($4) + lwl $9,4+3($4) + lwl $10,8+3($4) + lwl $11,12+3($4) + lwr $8,0+0($4) + lwr $9,4+0($4) + lwr $10,8+0($4) + lwr $11,12+0($4) + + bal _mips_AES_decrypt + + swr $8,0+0($5) + swr $9,4+0($5) + swr $10,8+0($5) + swr $11,12+0($5) + swl $8,0+3($5) + swl $9,4+3($5) + swl $10,8+3($5) + swl $11,12+3($5) + + .set noreorder + lw $31,64-1*4($29) + lw $30,64-2*4($29) + lw $23,64-3*4($29) + lw $22,64-4*4($29) + lw $21,64-5*4($29) + lw $20,64-6*4($29) + lw $19,64-7*4($29) + lw $18,64-8*4($29) + lw $17,64-9*4($29) + lw $16,64-10*4($29) + jr $31 + add $29,64 +.end AES_decrypt +.align 5 +.ent _mips_AES_set_encrypt_key +_mips_AES_set_encrypt_key: + .frame $29,0,$31 + .set noreorder + beqz $4,.Lekey_done + li $2,-1 + beqz $6,.Lekey_done + add $3,$7,1024+256 + + .set reorder + lwl $8,0+3($4) # load 128 bits + lwl $9,4+3($4) + lwl $10,8+3($4) + lwl $11,12+3($4) + li $1,128 + lwr $8,0+0($4) + lwr $9,4+0($4) + lwr $10,8+0($4) + lwr $11,12+0($4) + .set noreorder + beq $5,$1,.L128bits + li $30,10 + + .set reorder + lwl $12,16+3($4) # load 192 bits + lwl $13,20+3($4) + li $1,192 + lwr $12,16+0($4) + lwr $13,20+0($4) + .set noreorder + beq $5,$1,.L192bits + li $30,8 + + .set reorder + lwl $14,24+3($4) # load 256 bits + lwl $15,28+3($4) + li $1,256 + lwr $14,24+0($4) + lwr $15,28+0($4) + .set noreorder + beq $5,$1,.L256bits + li $30,7 + + b .Lekey_done + li $2,-2 + +.align 4 +.L128bits: + .set reorder + srl $1,$11,16 + srl $2,$11,8 + and $1,0xff + and $2,0xff + and $24,$11,0xff + srl $25,$11,24 + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $1,1024($1) + lbu $2,1024($2) + lbu $24,1024($24) + lbu $25,1024($25) + + sw $8,0($6) + sw $9,4($6) + sw $10,8($6) + sw $11,12($6) + sub $30,1 + add $6,16 + + sll $1,$1,8 + #sll $2,$2,0 + sll $24,$24,24 + sll $25,$25,16 + + xor $8,$1 + lw $1,0($3) + xor $8,$2 + xor $8,$24 + xor $8,$25 + xor $8,$1 + + xor $9,$8 + xor $10,$9 + xor $11,$10 + + .set noreorder + bnez $30,.L128bits + add $3,4 + + sw $8,0($6) + sw $9,4($6) + sw $10,8($6) + li $30,10 + sw $11,12($6) + li $2,0 + sw $30,80($6) + b .Lekey_done + sub $6,10*16 + +.align 4 +.L192bits: + .set reorder + srl $1,$13,16 + srl $2,$13,8 + and $1,0xff + and $2,0xff + and $24,$13,0xff + srl $25,$13,24 + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $1,1024($1) + lbu $2,1024($2) + lbu $24,1024($24) + lbu $25,1024($25) + + sw $8,0($6) + sw $9,4($6) + sw $10,8($6) + sw $11,12($6) + sw $12,16($6) + sw $13,20($6) + sub $30,1 + add $6,24 + + sll $1,$1,8 + #sll $2,$2,0 + sll $24,$24,24 + sll $25,$25,16 + + xor $8,$1 + lw $1,0($3) + xor $8,$2 + xor $8,$24 + xor $8,$25 + xor $8,$1 + + xor $9,$8 + xor $10,$9 + xor $11,$10 + xor $12,$11 + xor $13,$12 + + .set noreorder + bnez $30,.L192bits + add $3,4 + + sw $8,0($6) + sw $9,4($6) + sw $10,8($6) + li $30,12 + sw $11,12($6) + li $2,0 + sw $30,48($6) + b .Lekey_done + sub $6,12*16 + +.align 4 +.L256bits: + .set reorder + srl $1,$15,16 + srl $2,$15,8 + and $1,0xff + and $2,0xff + and $24,$15,0xff + srl $25,$15,24 + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $1,1024($1) + lbu $2,1024($2) + lbu $24,1024($24) + lbu $25,1024($25) + + sw $8,0($6) + sw $9,4($6) + sw $10,8($6) + sw $11,12($6) + sw $12,16($6) + sw $13,20($6) + sw $14,24($6) + sw $15,28($6) + sub $30,1 + + sll $1,$1,8 + #sll $2,$2,0 + sll $24,$24,24 + sll $25,$25,16 + + xor $8,$1 + lw $1,0($3) + xor $8,$2 + xor $8,$24 + xor $8,$25 + xor $8,$1 + + xor $9,$8 + xor $10,$9 + xor $11,$10 + beqz $30,.L256bits_done + + srl $1,$11,24 + srl $2,$11,16 + srl $24,$11,8 + and $25,$11,0xff + and $2,0xff + and $24,0xff + add $1,$7 + add $2,$7 + add $24,$7 + add $25,$7 + lbu $1,1024($1) + lbu $2,1024($2) + lbu $24,1024($24) + lbu $25,1024($25) + sll $1,24 + sll $2,16 + sll $24,8 + + xor $12,$1 + xor $12,$2 + xor $12,$24 + xor $12,$25 + + xor $13,$12 + xor $14,$13 + xor $15,$14 + + add $6,32 + .set noreorder + b .L256bits + add $3,4 + +.L256bits_done: + sw $8,32($6) + sw $9,36($6) + sw $10,40($6) + li $30,14 + sw $11,44($6) + li $2,0 + sw $30,48($6) + sub $6,12*16 + +.Lekey_done: + jr $31 + nop +.end _mips_AES_set_encrypt_key + +.globl AES_set_encrypt_key +.ent AES_set_encrypt_key +AES_set_encrypt_key: + .frame $29,32,$31 + .mask 3221225472,-4 + .set noreorder + .cpload $25 + sub $29,32 + sw $31,32-1*4($29) + sw $30,32-2*4($29) + .set reorder + la $7,AES_Te # PIC-ified 'load address' + + bal _mips_AES_set_encrypt_key + + .set noreorder + move $4,$2 + lw $31,32-1*4($29) + lw $30,32-2*4($29) + jr $31 + add $29,32 +.end AES_set_encrypt_key +.align 5 +.globl AES_set_decrypt_key +.ent AES_set_decrypt_key +AES_set_decrypt_key: + .frame $29,32,$31 + .mask 3221225472,-4 + .set noreorder + .cpload $25 + sub $29,32 + sw $31,32-1*4($29) + sw $30,32-2*4($29) + .set reorder + la $7,AES_Te # PIC-ified 'load address' + + bal _mips_AES_set_encrypt_key + + bltz $2,.Ldkey_done + + sll $1,$30,4 + add $4,$6,0 + add $5,$6,$1 +.align 4 +.Lswap: + lw $8,0($4) + lw $9,4($4) + lw $10,8($4) + lw $11,12($4) + lw $12,0($5) + lw $13,4($5) + lw $14,8($5) + lw $15,12($5) + sw $8,0($5) + sw $9,4($5) + sw $10,8($5) + sw $11,12($5) + add $4,16 + sub $5,16 + sw $12,-16($4) + sw $13,-12($4) + sw $14,-8($4) + sw $15,-4($4) + bne $4,$5,.Lswap + + lw $8,16($6) # modulo-scheduled + lui $2,0x8080 + sub $30,1 + or $2,0x8080 + sll $30,2 + add $6,16 + lui $25,0x1b1b + nor $24,$0,$2 + or $25,0x1b1b +.align 4 +.Lmix: + and $1,$8,$2 + and $9,$8,$24 + srl $10,$1,7 + addu $9,$9 # tp2<<1 + subu $1,$10 + and $1,$25 + xor $9,$1 + + and $1,$9,$2 + and $10,$9,$24 + srl $11,$1,7 + addu $10,$10 # tp4<<1 + subu $1,$11 + and $1,$25 + xor $10,$1 + + and $1,$10,$2 + and $11,$10,$24 + srl $12,$1,7 + addu $11,$11 # tp8<<1 + subu $1,$12 + and $1,$25 + xor $11,$1 + + xor $12,$11,$8 + xor $15,$11,$10 + xor $13,$12,$9 + xor $14,$12,$10 + + sll $8,$14,16 + xor $15,$9 + srl $9,$14,16 + xor $15,$8 + sll $8,$12,8 + xor $15,$9 + srl $9,$12,24 + xor $15,$8 + sll $8,$13,24 + xor $15,$9 + srl $9,$13,8 + xor $15,$8 + lw $8,4($6) # modulo-scheduled + xor $15,$9 + sub $30,1 + sw $15,0($6) + add $6,4 + bnez $30,.Lmix + + li $2,0 +.Ldkey_done: + .set noreorder + move $4,$2 + lw $31,32-1*4($29) + lw $30,32-2*4($29) + jr $31 + add $29,32 +.end AES_set_decrypt_key +.rdata +.align 6 +AES_Te: +.byte 0xc6,0x63,0x63,0xa5, 0xf8,0x7c,0x7c,0x84 # Te0 +.byte 0xee,0x77,0x77,0x99, 0xf6,0x7b,0x7b,0x8d +.byte 0xff,0xf2,0xf2,0x0d, 0xd6,0x6b,0x6b,0xbd +.byte 0xde,0x6f,0x6f,0xb1, 0x91,0xc5,0xc5,0x54 +.byte 0x60,0x30,0x30,0x50, 0x02,0x01,0x01,0x03 +.byte 0xce,0x67,0x67,0xa9, 0x56,0x2b,0x2b,0x7d +.byte 0xe7,0xfe,0xfe,0x19, 0xb5,0xd7,0xd7,0x62 +.byte 0x4d,0xab,0xab,0xe6, 0xec,0x76,0x76,0x9a +.byte 0x8f,0xca,0xca,0x45, 0x1f,0x82,0x82,0x9d +.byte 0x89,0xc9,0xc9,0x40, 0xfa,0x7d,0x7d,0x87 +.byte 0xef,0xfa,0xfa,0x15, 0xb2,0x59,0x59,0xeb +.byte 0x8e,0x47,0x47,0xc9, 0xfb,0xf0,0xf0,0x0b +.byte 0x41,0xad,0xad,0xec, 0xb3,0xd4,0xd4,0x67 +.byte 0x5f,0xa2,0xa2,0xfd, 0x45,0xaf,0xaf,0xea +.byte 0x23,0x9c,0x9c,0xbf, 0x53,0xa4,0xa4,0xf7 +.byte 0xe4,0x72,0x72,0x96, 0x9b,0xc0,0xc0,0x5b +.byte 0x75,0xb7,0xb7,0xc2, 0xe1,0xfd,0xfd,0x1c +.byte 0x3d,0x93,0x93,0xae, 0x4c,0x26,0x26,0x6a +.byte 0x6c,0x36,0x36,0x5a, 0x7e,0x3f,0x3f,0x41 +.byte 0xf5,0xf7,0xf7,0x02, 0x83,0xcc,0xcc,0x4f +.byte 0x68,0x34,0x34,0x5c, 0x51,0xa5,0xa5,0xf4 +.byte 0xd1,0xe5,0xe5,0x34, 0xf9,0xf1,0xf1,0x08 +.byte 0xe2,0x71,0x71,0x93, 0xab,0xd8,0xd8,0x73 +.byte 0x62,0x31,0x31,0x53, 0x2a,0x15,0x15,0x3f +.byte 0x08,0x04,0x04,0x0c, 0x95,0xc7,0xc7,0x52 +.byte 0x46,0x23,0x23,0x65, 0x9d,0xc3,0xc3,0x5e +.byte 0x30,0x18,0x18,0x28, 0x37,0x96,0x96,0xa1 +.byte 0x0a,0x05,0x05,0x0f, 0x2f,0x9a,0x9a,0xb5 +.byte 0x0e,0x07,0x07,0x09, 0x24,0x12,0x12,0x36 +.byte 0x1b,0x80,0x80,0x9b, 0xdf,0xe2,0xe2,0x3d +.byte 0xcd,0xeb,0xeb,0x26, 0x4e,0x27,0x27,0x69 +.byte 0x7f,0xb2,0xb2,0xcd, 0xea,0x75,0x75,0x9f +.byte 0x12,0x09,0x09,0x1b, 0x1d,0x83,0x83,0x9e +.byte 0x58,0x2c,0x2c,0x74, 0x34,0x1a,0x1a,0x2e +.byte 0x36,0x1b,0x1b,0x2d, 0xdc,0x6e,0x6e,0xb2 +.byte 0xb4,0x5a,0x5a,0xee, 0x5b,0xa0,0xa0,0xfb +.byte 0xa4,0x52,0x52,0xf6, 0x76,0x3b,0x3b,0x4d +.byte 0xb7,0xd6,0xd6,0x61, 0x7d,0xb3,0xb3,0xce +.byte 0x52,0x29,0x29,0x7b, 0xdd,0xe3,0xe3,0x3e +.byte 0x5e,0x2f,0x2f,0x71, 0x13,0x84,0x84,0x97 +.byte 0xa6,0x53,0x53,0xf5, 0xb9,0xd1,0xd1,0x68 +.byte 0x00,0x00,0x00,0x00, 0xc1,0xed,0xed,0x2c +.byte 0x40,0x20,0x20,0x60, 0xe3,0xfc,0xfc,0x1f +.byte 0x79,0xb1,0xb1,0xc8, 0xb6,0x5b,0x5b,0xed +.byte 0xd4,0x6a,0x6a,0xbe, 0x8d,0xcb,0xcb,0x46 +.byte 0x67,0xbe,0xbe,0xd9, 0x72,0x39,0x39,0x4b +.byte 0x94,0x4a,0x4a,0xde, 0x98,0x4c,0x4c,0xd4 +.byte 0xb0,0x58,0x58,0xe8, 0x85,0xcf,0xcf,0x4a +.byte 0xbb,0xd0,0xd0,0x6b, 0xc5,0xef,0xef,0x2a +.byte 0x4f,0xaa,0xaa,0xe5, 0xed,0xfb,0xfb,0x16 +.byte 0x86,0x43,0x43,0xc5, 0x9a,0x4d,0x4d,0xd7 +.byte 0x66,0x33,0x33,0x55, 0x11,0x85,0x85,0x94 +.byte 0x8a,0x45,0x45,0xcf, 0xe9,0xf9,0xf9,0x10 +.byte 0x04,0x02,0x02,0x06, 0xfe,0x7f,0x7f,0x81 +.byte 0xa0,0x50,0x50,0xf0, 0x78,0x3c,0x3c,0x44 +.byte 0x25,0x9f,0x9f,0xba, 0x4b,0xa8,0xa8,0xe3 +.byte 0xa2,0x51,0x51,0xf3, 0x5d,0xa3,0xa3,0xfe +.byte 0x80,0x40,0x40,0xc0, 0x05,0x8f,0x8f,0x8a +.byte 0x3f,0x92,0x92,0xad, 0x21,0x9d,0x9d,0xbc +.byte 0x70,0x38,0x38,0x48, 0xf1,0xf5,0xf5,0x04 +.byte 0x63,0xbc,0xbc,0xdf, 0x77,0xb6,0xb6,0xc1 +.byte 0xaf,0xda,0xda,0x75, 0x42,0x21,0x21,0x63 +.byte 0x20,0x10,0x10,0x30, 0xe5,0xff,0xff,0x1a +.byte 0xfd,0xf3,0xf3,0x0e, 0xbf,0xd2,0xd2,0x6d +.byte 0x81,0xcd,0xcd,0x4c, 0x18,0x0c,0x0c,0x14 +.byte 0x26,0x13,0x13,0x35, 0xc3,0xec,0xec,0x2f +.byte 0xbe,0x5f,0x5f,0xe1, 0x35,0x97,0x97,0xa2 +.byte 0x88,0x44,0x44,0xcc, 0x2e,0x17,0x17,0x39 +.byte 0x93,0xc4,0xc4,0x57, 0x55,0xa7,0xa7,0xf2 +.byte 0xfc,0x7e,0x7e,0x82, 0x7a,0x3d,0x3d,0x47 +.byte 0xc8,0x64,0x64,0xac, 0xba,0x5d,0x5d,0xe7 +.byte 0x32,0x19,0x19,0x2b, 0xe6,0x73,0x73,0x95 +.byte 0xc0,0x60,0x60,0xa0, 0x19,0x81,0x81,0x98 +.byte 0x9e,0x4f,0x4f,0xd1, 0xa3,0xdc,0xdc,0x7f +.byte 0x44,0x22,0x22,0x66, 0x54,0x2a,0x2a,0x7e +.byte 0x3b,0x90,0x90,0xab, 0x0b,0x88,0x88,0x83 +.byte 0x8c,0x46,0x46,0xca, 0xc7,0xee,0xee,0x29 +.byte 0x6b,0xb8,0xb8,0xd3, 0x28,0x14,0x14,0x3c +.byte 0xa7,0xde,0xde,0x79, 0xbc,0x5e,0x5e,0xe2 +.byte 0x16,0x0b,0x0b,0x1d, 0xad,0xdb,0xdb,0x76 +.byte 0xdb,0xe0,0xe0,0x3b, 0x64,0x32,0x32,0x56 +.byte 0x74,0x3a,0x3a,0x4e, 0x14,0x0a,0x0a,0x1e +.byte 0x92,0x49,0x49,0xdb, 0x0c,0x06,0x06,0x0a +.byte 0x48,0x24,0x24,0x6c, 0xb8,0x5c,0x5c,0xe4 +.byte 0x9f,0xc2,0xc2,0x5d, 0xbd,0xd3,0xd3,0x6e +.byte 0x43,0xac,0xac,0xef, 0xc4,0x62,0x62,0xa6 +.byte 0x39,0x91,0x91,0xa8, 0x31,0x95,0x95,0xa4 +.byte 0xd3,0xe4,0xe4,0x37, 0xf2,0x79,0x79,0x8b +.byte 0xd5,0xe7,0xe7,0x32, 0x8b,0xc8,0xc8,0x43 +.byte 0x6e,0x37,0x37,0x59, 0xda,0x6d,0x6d,0xb7 +.byte 0x01,0x8d,0x8d,0x8c, 0xb1,0xd5,0xd5,0x64 +.byte 0x9c,0x4e,0x4e,0xd2, 0x49,0xa9,0xa9,0xe0 +.byte 0xd8,0x6c,0x6c,0xb4, 0xac,0x56,0x56,0xfa +.byte 0xf3,0xf4,0xf4,0x07, 0xcf,0xea,0xea,0x25 +.byte 0xca,0x65,0x65,0xaf, 0xf4,0x7a,0x7a,0x8e +.byte 0x47,0xae,0xae,0xe9, 0x10,0x08,0x08,0x18 +.byte 0x6f,0xba,0xba,0xd5, 0xf0,0x78,0x78,0x88 +.byte 0x4a,0x25,0x25,0x6f, 0x5c,0x2e,0x2e,0x72 +.byte 0x38,0x1c,0x1c,0x24, 0x57,0xa6,0xa6,0xf1 +.byte 0x73,0xb4,0xb4,0xc7, 0x97,0xc6,0xc6,0x51 +.byte 0xcb,0xe8,0xe8,0x23, 0xa1,0xdd,0xdd,0x7c +.byte 0xe8,0x74,0x74,0x9c, 0x3e,0x1f,0x1f,0x21 +.byte 0x96,0x4b,0x4b,0xdd, 0x61,0xbd,0xbd,0xdc +.byte 0x0d,0x8b,0x8b,0x86, 0x0f,0x8a,0x8a,0x85 +.byte 0xe0,0x70,0x70,0x90, 0x7c,0x3e,0x3e,0x42 +.byte 0x71,0xb5,0xb5,0xc4, 0xcc,0x66,0x66,0xaa +.byte 0x90,0x48,0x48,0xd8, 0x06,0x03,0x03,0x05 +.byte 0xf7,0xf6,0xf6,0x01, 0x1c,0x0e,0x0e,0x12 +.byte 0xc2,0x61,0x61,0xa3, 0x6a,0x35,0x35,0x5f +.byte 0xae,0x57,0x57,0xf9, 0x69,0xb9,0xb9,0xd0 +.byte 0x17,0x86,0x86,0x91, 0x99,0xc1,0xc1,0x58 +.byte 0x3a,0x1d,0x1d,0x27, 0x27,0x9e,0x9e,0xb9 +.byte 0xd9,0xe1,0xe1,0x38, 0xeb,0xf8,0xf8,0x13 +.byte 0x2b,0x98,0x98,0xb3, 0x22,0x11,0x11,0x33 +.byte 0xd2,0x69,0x69,0xbb, 0xa9,0xd9,0xd9,0x70 +.byte 0x07,0x8e,0x8e,0x89, 0x33,0x94,0x94,0xa7 +.byte 0x2d,0x9b,0x9b,0xb6, 0x3c,0x1e,0x1e,0x22 +.byte 0x15,0x87,0x87,0x92, 0xc9,0xe9,0xe9,0x20 +.byte 0x87,0xce,0xce,0x49, 0xaa,0x55,0x55,0xff +.byte 0x50,0x28,0x28,0x78, 0xa5,0xdf,0xdf,0x7a +.byte 0x03,0x8c,0x8c,0x8f, 0x59,0xa1,0xa1,0xf8 +.byte 0x09,0x89,0x89,0x80, 0x1a,0x0d,0x0d,0x17 +.byte 0x65,0xbf,0xbf,0xda, 0xd7,0xe6,0xe6,0x31 +.byte 0x84,0x42,0x42,0xc6, 0xd0,0x68,0x68,0xb8 +.byte 0x82,0x41,0x41,0xc3, 0x29,0x99,0x99,0xb0 +.byte 0x5a,0x2d,0x2d,0x77, 0x1e,0x0f,0x0f,0x11 +.byte 0x7b,0xb0,0xb0,0xcb, 0xa8,0x54,0x54,0xfc +.byte 0x6d,0xbb,0xbb,0xd6, 0x2c,0x16,0x16,0x3a + +.byte 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5 # Te4 +.byte 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76 +.byte 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0 +.byte 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0 +.byte 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc +.byte 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15 +.byte 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a +.byte 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75 +.byte 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0 +.byte 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84 +.byte 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b +.byte 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf +.byte 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85 +.byte 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8 +.byte 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5 +.byte 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2 +.byte 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17 +.byte 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73 +.byte 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88 +.byte 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb +.byte 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c +.byte 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79 +.byte 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9 +.byte 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08 +.byte 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6 +.byte 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a +.byte 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e +.byte 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e +.byte 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94 +.byte 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf +.byte 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68 +.byte 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 + +.byte 0x01,0x00,0x00,0x00, 0x02,0x00,0x00,0x00 # rcon +.byte 0x04,0x00,0x00,0x00, 0x08,0x00,0x00,0x00 +.byte 0x10,0x00,0x00,0x00, 0x20,0x00,0x00,0x00 +.byte 0x40,0x00,0x00,0x00, 0x80,0x00,0x00,0x00 +.byte 0x1B,0x00,0x00,0x00, 0x36,0x00,0x00,0x00 + +.align 6 +AES_Td: +.byte 0x51,0xf4,0xa7,0x50, 0x7e,0x41,0x65,0x53 # Td0 +.byte 0x1a,0x17,0xa4,0xc3, 0x3a,0x27,0x5e,0x96 +.byte 0x3b,0xab,0x6b,0xcb, 0x1f,0x9d,0x45,0xf1 +.byte 0xac,0xfa,0x58,0xab, 0x4b,0xe3,0x03,0x93 +.byte 0x20,0x30,0xfa,0x55, 0xad,0x76,0x6d,0xf6 +.byte 0x88,0xcc,0x76,0x91, 0xf5,0x02,0x4c,0x25 +.byte 0x4f,0xe5,0xd7,0xfc, 0xc5,0x2a,0xcb,0xd7 +.byte 0x26,0x35,0x44,0x80, 0xb5,0x62,0xa3,0x8f +.byte 0xde,0xb1,0x5a,0x49, 0x25,0xba,0x1b,0x67 +.byte 0x45,0xea,0x0e,0x98, 0x5d,0xfe,0xc0,0xe1 +.byte 0xc3,0x2f,0x75,0x02, 0x81,0x4c,0xf0,0x12 +.byte 0x8d,0x46,0x97,0xa3, 0x6b,0xd3,0xf9,0xc6 +.byte 0x03,0x8f,0x5f,0xe7, 0x15,0x92,0x9c,0x95 +.byte 0xbf,0x6d,0x7a,0xeb, 0x95,0x52,0x59,0xda +.byte 0xd4,0xbe,0x83,0x2d, 0x58,0x74,0x21,0xd3 +.byte 0x49,0xe0,0x69,0x29, 0x8e,0xc9,0xc8,0x44 +.byte 0x75,0xc2,0x89,0x6a, 0xf4,0x8e,0x79,0x78 +.byte 0x99,0x58,0x3e,0x6b, 0x27,0xb9,0x71,0xdd +.byte 0xbe,0xe1,0x4f,0xb6, 0xf0,0x88,0xad,0x17 +.byte 0xc9,0x20,0xac,0x66, 0x7d,0xce,0x3a,0xb4 +.byte 0x63,0xdf,0x4a,0x18, 0xe5,0x1a,0x31,0x82 +.byte 0x97,0x51,0x33,0x60, 0x62,0x53,0x7f,0x45 +.byte 0xb1,0x64,0x77,0xe0, 0xbb,0x6b,0xae,0x84 +.byte 0xfe,0x81,0xa0,0x1c, 0xf9,0x08,0x2b,0x94 +.byte 0x70,0x48,0x68,0x58, 0x8f,0x45,0xfd,0x19 +.byte 0x94,0xde,0x6c,0x87, 0x52,0x7b,0xf8,0xb7 +.byte 0xab,0x73,0xd3,0x23, 0x72,0x4b,0x02,0xe2 +.byte 0xe3,0x1f,0x8f,0x57, 0x66,0x55,0xab,0x2a +.byte 0xb2,0xeb,0x28,0x07, 0x2f,0xb5,0xc2,0x03 +.byte 0x86,0xc5,0x7b,0x9a, 0xd3,0x37,0x08,0xa5 +.byte 0x30,0x28,0x87,0xf2, 0x23,0xbf,0xa5,0xb2 +.byte 0x02,0x03,0x6a,0xba, 0xed,0x16,0x82,0x5c +.byte 0x8a,0xcf,0x1c,0x2b, 0xa7,0x79,0xb4,0x92 +.byte 0xf3,0x07,0xf2,0xf0, 0x4e,0x69,0xe2,0xa1 +.byte 0x65,0xda,0xf4,0xcd, 0x06,0x05,0xbe,0xd5 +.byte 0xd1,0x34,0x62,0x1f, 0xc4,0xa6,0xfe,0x8a +.byte 0x34,0x2e,0x53,0x9d, 0xa2,0xf3,0x55,0xa0 +.byte 0x05,0x8a,0xe1,0x32, 0xa4,0xf6,0xeb,0x75 +.byte 0x0b,0x83,0xec,0x39, 0x40,0x60,0xef,0xaa +.byte 0x5e,0x71,0x9f,0x06, 0xbd,0x6e,0x10,0x51 +.byte 0x3e,0x21,0x8a,0xf9, 0x96,0xdd,0x06,0x3d +.byte 0xdd,0x3e,0x05,0xae, 0x4d,0xe6,0xbd,0x46 +.byte 0x91,0x54,0x8d,0xb5, 0x71,0xc4,0x5d,0x05 +.byte 0x04,0x06,0xd4,0x6f, 0x60,0x50,0x15,0xff +.byte 0x19,0x98,0xfb,0x24, 0xd6,0xbd,0xe9,0x97 +.byte 0x89,0x40,0x43,0xcc, 0x67,0xd9,0x9e,0x77 +.byte 0xb0,0xe8,0x42,0xbd, 0x07,0x89,0x8b,0x88 +.byte 0xe7,0x19,0x5b,0x38, 0x79,0xc8,0xee,0xdb +.byte 0xa1,0x7c,0x0a,0x47, 0x7c,0x42,0x0f,0xe9 +.byte 0xf8,0x84,0x1e,0xc9, 0x00,0x00,0x00,0x00 +.byte 0x09,0x80,0x86,0x83, 0x32,0x2b,0xed,0x48 +.byte 0x1e,0x11,0x70,0xac, 0x6c,0x5a,0x72,0x4e +.byte 0xfd,0x0e,0xff,0xfb, 0x0f,0x85,0x38,0x56 +.byte 0x3d,0xae,0xd5,0x1e, 0x36,0x2d,0x39,0x27 +.byte 0x0a,0x0f,0xd9,0x64, 0x68,0x5c,0xa6,0x21 +.byte 0x9b,0x5b,0x54,0xd1, 0x24,0x36,0x2e,0x3a +.byte 0x0c,0x0a,0x67,0xb1, 0x93,0x57,0xe7,0x0f +.byte 0xb4,0xee,0x96,0xd2, 0x1b,0x9b,0x91,0x9e +.byte 0x80,0xc0,0xc5,0x4f, 0x61,0xdc,0x20,0xa2 +.byte 0x5a,0x77,0x4b,0x69, 0x1c,0x12,0x1a,0x16 +.byte 0xe2,0x93,0xba,0x0a, 0xc0,0xa0,0x2a,0xe5 +.byte 0x3c,0x22,0xe0,0x43, 0x12,0x1b,0x17,0x1d +.byte 0x0e,0x09,0x0d,0x0b, 0xf2,0x8b,0xc7,0xad +.byte 0x2d,0xb6,0xa8,0xb9, 0x14,0x1e,0xa9,0xc8 +.byte 0x57,0xf1,0x19,0x85, 0xaf,0x75,0x07,0x4c +.byte 0xee,0x99,0xdd,0xbb, 0xa3,0x7f,0x60,0xfd +.byte 0xf7,0x01,0x26,0x9f, 0x5c,0x72,0xf5,0xbc +.byte 0x44,0x66,0x3b,0xc5, 0x5b,0xfb,0x7e,0x34 +.byte 0x8b,0x43,0x29,0x76, 0xcb,0x23,0xc6,0xdc +.byte 0xb6,0xed,0xfc,0x68, 0xb8,0xe4,0xf1,0x63 +.byte 0xd7,0x31,0xdc,0xca, 0x42,0x63,0x85,0x10 +.byte 0x13,0x97,0x22,0x40, 0x84,0xc6,0x11,0x20 +.byte 0x85,0x4a,0x24,0x7d, 0xd2,0xbb,0x3d,0xf8 +.byte 0xae,0xf9,0x32,0x11, 0xc7,0x29,0xa1,0x6d +.byte 0x1d,0x9e,0x2f,0x4b, 0xdc,0xb2,0x30,0xf3 +.byte 0x0d,0x86,0x52,0xec, 0x77,0xc1,0xe3,0xd0 +.byte 0x2b,0xb3,0x16,0x6c, 0xa9,0x70,0xb9,0x99 +.byte 0x11,0x94,0x48,0xfa, 0x47,0xe9,0x64,0x22 +.byte 0xa8,0xfc,0x8c,0xc4, 0xa0,0xf0,0x3f,0x1a +.byte 0x56,0x7d,0x2c,0xd8, 0x22,0x33,0x90,0xef +.byte 0x87,0x49,0x4e,0xc7, 0xd9,0x38,0xd1,0xc1 +.byte 0x8c,0xca,0xa2,0xfe, 0x98,0xd4,0x0b,0x36 +.byte 0xa6,0xf5,0x81,0xcf, 0xa5,0x7a,0xde,0x28 +.byte 0xda,0xb7,0x8e,0x26, 0x3f,0xad,0xbf,0xa4 +.byte 0x2c,0x3a,0x9d,0xe4, 0x50,0x78,0x92,0x0d +.byte 0x6a,0x5f,0xcc,0x9b, 0x54,0x7e,0x46,0x62 +.byte 0xf6,0x8d,0x13,0xc2, 0x90,0xd8,0xb8,0xe8 +.byte 0x2e,0x39,0xf7,0x5e, 0x82,0xc3,0xaf,0xf5 +.byte 0x9f,0x5d,0x80,0xbe, 0x69,0xd0,0x93,0x7c +.byte 0x6f,0xd5,0x2d,0xa9, 0xcf,0x25,0x12,0xb3 +.byte 0xc8,0xac,0x99,0x3b, 0x10,0x18,0x7d,0xa7 +.byte 0xe8,0x9c,0x63,0x6e, 0xdb,0x3b,0xbb,0x7b +.byte 0xcd,0x26,0x78,0x09, 0x6e,0x59,0x18,0xf4 +.byte 0xec,0x9a,0xb7,0x01, 0x83,0x4f,0x9a,0xa8 +.byte 0xe6,0x95,0x6e,0x65, 0xaa,0xff,0xe6,0x7e +.byte 0x21,0xbc,0xcf,0x08, 0xef,0x15,0xe8,0xe6 +.byte 0xba,0xe7,0x9b,0xd9, 0x4a,0x6f,0x36,0xce +.byte 0xea,0x9f,0x09,0xd4, 0x29,0xb0,0x7c,0xd6 +.byte 0x31,0xa4,0xb2,0xaf, 0x2a,0x3f,0x23,0x31 +.byte 0xc6,0xa5,0x94,0x30, 0x35,0xa2,0x66,0xc0 +.byte 0x74,0x4e,0xbc,0x37, 0xfc,0x82,0xca,0xa6 +.byte 0xe0,0x90,0xd0,0xb0, 0x33,0xa7,0xd8,0x15 +.byte 0xf1,0x04,0x98,0x4a, 0x41,0xec,0xda,0xf7 +.byte 0x7f,0xcd,0x50,0x0e, 0x17,0x91,0xf6,0x2f +.byte 0x76,0x4d,0xd6,0x8d, 0x43,0xef,0xb0,0x4d +.byte 0xcc,0xaa,0x4d,0x54, 0xe4,0x96,0x04,0xdf +.byte 0x9e,0xd1,0xb5,0xe3, 0x4c,0x6a,0x88,0x1b +.byte 0xc1,0x2c,0x1f,0xb8, 0x46,0x65,0x51,0x7f +.byte 0x9d,0x5e,0xea,0x04, 0x01,0x8c,0x35,0x5d +.byte 0xfa,0x87,0x74,0x73, 0xfb,0x0b,0x41,0x2e +.byte 0xb3,0x67,0x1d,0x5a, 0x92,0xdb,0xd2,0x52 +.byte 0xe9,0x10,0x56,0x33, 0x6d,0xd6,0x47,0x13 +.byte 0x9a,0xd7,0x61,0x8c, 0x37,0xa1,0x0c,0x7a +.byte 0x59,0xf8,0x14,0x8e, 0xeb,0x13,0x3c,0x89 +.byte 0xce,0xa9,0x27,0xee, 0xb7,0x61,0xc9,0x35 +.byte 0xe1,0x1c,0xe5,0xed, 0x7a,0x47,0xb1,0x3c +.byte 0x9c,0xd2,0xdf,0x59, 0x55,0xf2,0x73,0x3f +.byte 0x18,0x14,0xce,0x79, 0x73,0xc7,0x37,0xbf +.byte 0x53,0xf7,0xcd,0xea, 0x5f,0xfd,0xaa,0x5b +.byte 0xdf,0x3d,0x6f,0x14, 0x78,0x44,0xdb,0x86 +.byte 0xca,0xaf,0xf3,0x81, 0xb9,0x68,0xc4,0x3e +.byte 0x38,0x24,0x34,0x2c, 0xc2,0xa3,0x40,0x5f +.byte 0x16,0x1d,0xc3,0x72, 0xbc,0xe2,0x25,0x0c +.byte 0x28,0x3c,0x49,0x8b, 0xff,0x0d,0x95,0x41 +.byte 0x39,0xa8,0x01,0x71, 0x08,0x0c,0xb3,0xde +.byte 0xd8,0xb4,0xe4,0x9c, 0x64,0x56,0xc1,0x90 +.byte 0x7b,0xcb,0x84,0x61, 0xd5,0x32,0xb6,0x70 +.byte 0x48,0x6c,0x5c,0x74, 0xd0,0xb8,0x57,0x42 + +.byte 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38 # Td4 +.byte 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb +.byte 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87 +.byte 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb +.byte 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d +.byte 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e +.byte 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2 +.byte 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25 +.byte 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16 +.byte 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92 +.byte 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda +.byte 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84 +.byte 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a +.byte 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06 +.byte 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02 +.byte 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b +.byte 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea +.byte 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73 +.byte 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85 +.byte 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e +.byte 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89 +.byte 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b +.byte 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20 +.byte 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4 +.byte 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31 +.byte 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f +.byte 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d +.byte 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef +.byte 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0 +.byte 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61 +.byte 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26 +.byte 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d +#if defined(HAVE_GNU_STACK) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/aes/aes_core.c b/crypto/aes/aes_core.c index 1b8a24c7..e3fdb4fd 100644 --- a/crypto/aes/aes_core.c +++ b/crypto/aes/aes_core.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aes_core.c,v 1.13 2015/11/05 21:59:13 miod Exp $ */ +/* $OpenBSD: aes_core.c,v 1.14 2022/11/26 16:08:50 tb Exp $ */ /** * rijndael-alg-fst.c * @@ -36,7 +36,7 @@ #include #include -#include "aes_locl.h" +#include "aes_local.h" #ifndef AES_ASM /* diff --git a/crypto/aes/aes_ecb.c b/crypto/aes/aes_ecb.c index b05e5399..e3bb40b5 100644 --- a/crypto/aes/aes_ecb.c +++ b/crypto/aes/aes_ecb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aes_ecb.c,v 1.6 2015/02/10 09:46:30 miod Exp $ */ +/* $OpenBSD: aes_ecb.c,v 1.7 2022/11/26 16:08:50 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -56,7 +56,7 @@ #endif #include -#include "aes_locl.h" +#include "aes_local.h" void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, diff --git a/crypto/aes/aes_ige.c b/crypto/aes/aes_ige.c index 244a5a36..ef7d7662 100644 --- a/crypto/aes/aes_ige.c +++ b/crypto/aes/aes_ige.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aes_ige.c,v 1.8 2022/01/22 00:43:41 inoguchi Exp $ */ +/* $OpenBSD: aes_ige.c,v 1.9 2022/11/26 16:08:50 tb Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * @@ -52,7 +52,7 @@ #include #include -#include "aes_locl.h" +#include "aes_local.h" #define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long)) typedef struct { diff --git a/crypto/aes/aes_locl.h b/crypto/aes/aes_local.h similarity index 95% rename from crypto/aes/aes_locl.h rename to crypto/aes/aes_local.h index c47f65da..ef74e713 100644 --- a/crypto/aes/aes_locl.h +++ b/crypto/aes/aes_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: aes_locl.h,v 1.11 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: aes_local.h,v 1.2 2022/11/26 17:23:17 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -49,8 +49,8 @@ * */ -#ifndef HEADER_AES_LOCL_H -#define HEADER_AES_LOCL_H +#ifndef HEADER_AES_LOCAL_H +#define HEADER_AES_LOCAL_H #include @@ -80,4 +80,4 @@ typedef unsigned char u8; __END_HIDDEN_DECLS -#endif /* !HEADER_AES_LOCL_H */ +#endif /* !HEADER_AES_LOCAL_H */ diff --git a/crypto/aes/aes_misc.c b/crypto/aes/aes_misc.c index 6c1506dd..4ed55b1e 100644 --- a/crypto/aes/aes_misc.c +++ b/crypto/aes/aes_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aes_misc.c,v 1.10 2014/07/09 11:10:50 bcook Exp $ */ +/* $OpenBSD: aes_misc.c,v 1.11 2022/11/26 16:08:50 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -52,7 +52,7 @@ #include #include #include -#include "aes_locl.h" +#include "aes_local.h" const char * AES_options(void) diff --git a/crypto/aes/aesni-elf-x86_64.S b/crypto/aes/aesni-elf-x86_64.S index 6d06f547..b18b2e06 100644 --- a/crypto/aes/aesni-elf-x86_64.S +++ b/crypto/aes/aesni-elf-x86_64.S @@ -2543,6 +2543,7 @@ __aesni_set_encrypt_key: retq .size aesni_set_encrypt_key,.-aesni_set_encrypt_key .size __aesni_set_encrypt_key,.-__aesni_set_encrypt_key +.section .rodata .align 64 .Lbswap_mask: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -2552,9 +2553,8 @@ __aesni_set_encrypt_key: .long 1,0,0,0 .Lxts_magic: .long 0x87,0,1,0 - -.byte 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69,83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 64 +.text #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/aes/aesni-macosx-x86_64.S b/crypto/aes/aesni-macosx-x86_64.S index f6c81ca4..9edf39bc 100644 --- a/crypto/aes/aesni-macosx-x86_64.S +++ b/crypto/aes/aesni-macosx-x86_64.S @@ -2543,6 +2543,7 @@ L$key_expansion_256b: retq +.section __DATA,__const .p2align 6 L$bswap_mask: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -2552,6 +2553,5 @@ L$increment64: .long 1,0,0,0 L$xts_magic: .long 0x87,0,1,0 - -.byte 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69,83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 6 +.text diff --git a/crypto/aes/aesni-masm-x86_64.S b/crypto/aes/aesni-masm-x86_64.S index df5a191e..5a950b20 100644 --- a/crypto/aes/aesni-masm-x86_64.S +++ b/crypto/aes/aesni-masm-x86_64.S @@ -2810,6 +2810,8 @@ $L$key_expansion_256b:: DB 0F3h,0C3h ;repret aesni_set_encrypt_key ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 $L$bswap_mask:: DB 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -2819,12 +2821,9 @@ $L$increment64:: DD 1,0,0,0 $L$xts_magic:: DD 087h,0,1,0 - -DB 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69 -DB 83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83 -DB 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115 -DB 115,108,46,111,114,103,62,0 ALIGN 64 +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 diff --git a/crypto/aes/aesni-mingw64-x86_64.S b/crypto/aes/aesni-mingw64-x86_64.S index 4eca1698..5e210053 100644 --- a/crypto/aes/aesni-mingw64-x86_64.S +++ b/crypto/aes/aesni-mingw64-x86_64.S @@ -2728,6 +2728,7 @@ __aesni_set_encrypt_key: retq +.section .rodata .p2align 6 .Lbswap_mask: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -2737,9 +2738,8 @@ __aesni_set_encrypt_key: .long 1,0,0,0 .Lxts_magic: .long 0x87,0,1,0 - -.byte 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69,83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 6 +.text .def ecb_se_handler; .scl 3; .type 32; .endef .p2align 4 diff --git a/crypto/aes/aesni-sha1-elf-x86_64.S b/crypto/aes/aesni-sha1-elf-x86_64.S index c0b3e5f6..03981730 100644 --- a/crypto/aes/aesni-sha1-elf-x86_64.S +++ b/crypto/aes/aesni-sha1-elf-x86_64.S @@ -1386,6 +1386,7 @@ aesni_cbc_sha1_enc_ssse3: .Lepilogue_ssse3: retq .size aesni_cbc_sha1_enc_ssse3,.-aesni_cbc_sha1_enc_ssse3 +.section .rodata .align 64 K_XX_XX: .long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 @@ -1393,9 +1394,8 @@ K_XX_XX: .long 0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc .long 0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6 .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f - -.byte 65,69,83,78,73,45,67,66,67,43,83,72,65,49,32,115,116,105,116,99,104,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 64 +.text #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/aes/aesni-sha1-macosx-x86_64.S b/crypto/aes/aesni-sha1-macosx-x86_64.S index 3e88b1ac..f8f5bb75 100644 --- a/crypto/aes/aesni-sha1-macosx-x86_64.S +++ b/crypto/aes/aesni-sha1-macosx-x86_64.S @@ -1386,6 +1386,7 @@ L$aesenclast5: L$epilogue_ssse3: retq +.section __DATA,__const .p2align 6 K_XX_XX: .long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 @@ -1393,6 +1394,5 @@ K_XX_XX: .long 0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc .long 0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6 .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f - -.byte 65,69,83,78,73,45,67,66,67,43,83,72,65,49,32,115,116,105,116,99,104,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 6 +.text diff --git a/crypto/aes/aesni-sha1-masm-x86_64.S b/crypto/aes/aesni-sha1-masm-x86_64.S index b87202ad..17c00449 100644 --- a/crypto/aes/aesni-sha1-masm-x86_64.S +++ b/crypto/aes/aesni-sha1-masm-x86_64.S @@ -1490,6 +1490,8 @@ $L$epilogue_ssse3:: DB 0F3h,0C3h ;repret $L$SEH_end_aesni_cbc_sha1_enc_ssse3:: aesni_cbc_sha1_enc_ssse3 ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 K_XX_XX:: DD 05a827999h,05a827999h,05a827999h,05a827999h @@ -1497,13 +1499,9 @@ K_XX_XX:: DD 08f1bbcdch,08f1bbcdch,08f1bbcdch,08f1bbcdch DD 0ca62c1d6h,0ca62c1d6h,0ca62c1d6h,0ca62c1d6h DD 000010203h,004050607h,008090a0bh,00c0d0e0fh - -DB 65,69,83,78,73,45,67,66,67,43,83,72,65,49,32,115 -DB 116,105,116,99,104,32,102,111,114,32,120,56,54,95,54,52 -DB 44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32 -DB 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111 -DB 114,103,62,0 ALIGN 64 +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 diff --git a/crypto/aes/aesni-sha1-mingw64-x86_64.S b/crypto/aes/aesni-sha1-mingw64-x86_64.S index c7a2d5cb..a6b7768d 100644 --- a/crypto/aes/aesni-sha1-mingw64-x86_64.S +++ b/crypto/aes/aesni-sha1-mingw64-x86_64.S @@ -1420,6 +1420,7 @@ aesni_cbc_sha1_enc_ssse3: movq 16(%rsp),%rsi retq .LSEH_end_aesni_cbc_sha1_enc_ssse3: +.section .rodata .p2align 6 K_XX_XX: .long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 @@ -1427,9 +1428,8 @@ K_XX_XX: .long 0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc .long 0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6 .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f - -.byte 65,69,83,78,73,45,67,66,67,43,83,72,65,49,32,115,116,105,116,99,104,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 6 +.text .def ssse3_handler; .scl 3; .type 32; .endef .p2align 4 diff --git a/crypto/aes/bsaes-elf-x86_64.S b/crypto/aes/bsaes-elf-x86_64.S index 903e3745..945d5e7c 100644 --- a/crypto/aes/bsaes-elf-x86_64.S +++ b/crypto/aes/bsaes-elf-x86_64.S @@ -2442,6 +2442,7 @@ bsaes_xts_decrypt: .Lxts_dec_epilogue: retq .size bsaes_xts_decrypt,.-bsaes_xts_decrypt +.section .rodata .type _bsaes_const,@object .align 64 _bsaes_const: @@ -2494,9 +2495,9 @@ _bsaes_const: .quad 0x02060a0e03070b0f, 0x0004080c0105090d .L63: .quad 0x6363636363636363, 0x6363636363636363 -.byte 66,105,116,45,115,108,105,99,101,100,32,65,69,83,32,102,111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44,32,69,109,105,108,105,97,32,75,195,164,115,112,101,114,44,32,80,101,116,101,114,32,83,99,104,119,97,98,101,44,32,65,110,100,121,32,80,111,108,121,97,107,111,118,0 .align 64 .size _bsaes_const,.-_bsaes_const +.text #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/aes/bsaes-macosx-x86_64.S b/crypto/aes/bsaes-macosx-x86_64.S index 5f780f0e..fa37ee16 100644 --- a/crypto/aes/bsaes-macosx-x86_64.S +++ b/crypto/aes/bsaes-macosx-x86_64.S @@ -2442,6 +2442,7 @@ L$xts_dec_bzero: L$xts_dec_epilogue: retq +.section __DATA,__const .p2align 6 _bsaes_const: @@ -2494,6 +2495,6 @@ L$M0: .quad 0x02060a0e03070b0f, 0x0004080c0105090d L$63: .quad 0x6363636363636363, 0x6363636363636363 -.byte 66,105,116,45,115,108,105,99,101,100,32,65,69,83,32,102,111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44,32,69,109,105,108,105,97,32,75,195,164,115,112,101,114,44,32,80,101,116,101,114,32,83,99,104,119,97,98,101,44,32,65,110,100,121,32,80,111,108,121,97,107,111,118,0 .p2align 6 +.text diff --git a/crypto/aes/bsaes-masm-x86_64.S b/crypto/aes/bsaes-masm-x86_64.S index 7049860e..065c6053 100644 --- a/crypto/aes/bsaes-masm-x86_64.S +++ b/crypto/aes/bsaes-masm-x86_64.S @@ -2609,6 +2609,8 @@ $L$xts_dec_bzero:: $L$xts_dec_epilogue:: DB 0F3h,0C3h ;repret bsaes_xts_decrypt ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 _bsaes_const:: @@ -2661,13 +2663,10 @@ $L$M0:: DQ 002060a0e03070b0fh,00004080c0105090dh $L$63:: DQ 06363636363636363h,06363636363636363h -DB 66,105,116,45,115,108,105,99,101,100,32,65,69,83,32,102 -DB 111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44 -DB 32,69,109,105,108,105,97,32,75,195,164,115,112,101,114,44 -DB 32,80,101,116,101,114,32,83,99,104,119,97,98,101,44,32 -DB 65,110,100,121,32,80,111,108,121,97,107,111,118,0 ALIGN 64 +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 diff --git a/crypto/aes/bsaes-mingw64-x86_64.S b/crypto/aes/bsaes-mingw64-x86_64.S index f0b07cba..1b44e80b 100644 --- a/crypto/aes/bsaes-mingw64-x86_64.S +++ b/crypto/aes/bsaes-mingw64-x86_64.S @@ -2541,6 +2541,7 @@ bsaes_xts_decrypt: .Lxts_dec_epilogue: retq +.section .rodata .p2align 6 _bsaes_const: @@ -2593,9 +2594,9 @@ _bsaes_const: .quad 0x02060a0e03070b0f, 0x0004080c0105090d .L63: .quad 0x6363636363636363, 0x6363636363636363 -.byte 66,105,116,45,115,108,105,99,101,100,32,65,69,83,32,102,111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44,32,69,109,105,108,105,97,32,75,195,164,115,112,101,114,44,32,80,101,116,101,114,32,83,99,104,119,97,98,101,44,32,65,110,100,121,32,80,111,108,121,97,107,111,118,0 .p2align 6 +.text .def se_handler; .scl 3; .type 32; .endef .p2align 4 diff --git a/crypto/aes/vpaes-elf-x86_64.S b/crypto/aes/vpaes-elf-x86_64.S index 1e1a6e85..4e65ee98 100644 --- a/crypto/aes/vpaes-elf-x86_64.S +++ b/crypto/aes/vpaes-elf-x86_64.S @@ -728,6 +728,7 @@ _vpaes_preheat: +.section .rodata .type _vpaes_consts,@object .align 64 _vpaes_consts: @@ -824,9 +825,9 @@ _vpaes_consts: .Lk_dsbo: .quad 0x1387EA537EF94000, 0xC7AA6DB9D4943E2D .quad 0x12D7560F93441D00, 0xCA4B8159D8C58E9C -.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44,32,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 .align 64 .size _vpaes_consts,.-_vpaes_consts +.text #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/aes/vpaes-macosx-x86_64.S b/crypto/aes/vpaes-macosx-x86_64.S index 0a892a9d..ec179081 100644 --- a/crypto/aes/vpaes-macosx-x86_64.S +++ b/crypto/aes/vpaes-macosx-x86_64.S @@ -728,6 +728,7 @@ _vpaes_preheat: +.section __DATA,__const .p2align 6 _vpaes_consts: @@ -824,6 +825,6 @@ L$k_dsbe: L$k_dsbo: .quad 0x1387EA537EF94000, 0xC7AA6DB9D4943E2D .quad 0x12D7560F93441D00, 0xCA4B8159D8C58E9C -.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44,32,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 .p2align 6 +.text diff --git a/crypto/aes/vpaes-masm-x86_64.S b/crypto/aes/vpaes-masm-x86_64.S index fa24314e..c0c2dabf 100644 --- a/crypto/aes/vpaes-masm-x86_64.S +++ b/crypto/aes/vpaes-masm-x86_64.S @@ -979,6 +979,8 @@ _vpaes_preheat ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 _vpaes_consts:: @@ -1075,13 +1077,10 @@ $L$k_dsbe:: $L$k_dsbo:: DQ 01387EA537EF94000h,0C7AA6DB9D4943E2Dh DQ 012D7560F93441D00h,0CA4B8159D8C58E9Ch -DB 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105 -DB 111,110,32,65,69,83,32,102,111,114,32,120,56,54,95,54 -DB 52,47,83,83,83,69,51,44,32,77,105,107,101,32,72,97 -DB 109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32 -DB 85,110,105,118,101,114,115,105,116,121,41,0 ALIGN 64 +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 diff --git a/crypto/aes/vpaes-mingw64-x86_64.S b/crypto/aes/vpaes-mingw64-x86_64.S index d6cb8605..f755f72d 100644 --- a/crypto/aes/vpaes-mingw64-x86_64.S +++ b/crypto/aes/vpaes-mingw64-x86_64.S @@ -901,6 +901,7 @@ _vpaes_preheat: +.section .rodata .p2align 6 _vpaes_consts: @@ -997,9 +998,9 @@ _vpaes_consts: .Lk_dsbo: .quad 0x1387EA537EF94000, 0xC7AA6DB9D4943E2D .quad 0x12D7560F93441D00, 0xCA4B8159D8C58E9C -.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44,32,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 .p2align 6 +.text .def se_handler; .scl 3; .type 32; .endef .p2align 4 diff --git a/crypto/armv4cpuid.S b/crypto/armv4cpuid.S index bb9abafe..db0b54e4 100644 --- a/crypto/armv4cpuid.S +++ b/crypto/armv4cpuid.S @@ -9,43 +9,6 @@ #undef __thumb2__ #endif -.align 5 -.globl OPENSSL_atomic_add -.type OPENSSL_atomic_add,%function -OPENSSL_atomic_add: -#if __ARM_ARCH__>=6 -.Ladd: ldrex r2,[r0] - add r3,r2,r1 - strex r2,r3,[r0] - cmp r2,#0 - bne .Ladd - mov r0,r3 - bx lr -#else - stmdb sp!,{r4,r5,r6,lr} - ldr r2,.Lspinlock - adr r3,.Lspinlock - mov r4,r0 - mov r5,r1 - add r6,r3,r2 @ &spinlock - b .+8 -.Lspin: bl sched_yield - mov r0,#-1 - swp r0,r0,[r6] - cmp r0,#0 - bne .Lspin - - ldr r2,[r4] - add r2,r2,r5 - str r2,[r4] - str r0,[r6] @ release spinlock - ldmia sp!,{r4,r5,r6,lr} - tst lr,#1 - moveq pc,lr -.word 0xe12fff1e @ bx lr -#endif -.size OPENSSL_atomic_add,.-OPENSSL_atomic_add - #if __ARM_ARCH__>=7 .arch armv7-a .fpu neon @@ -102,64 +65,5 @@ _armv8_pmull_probe: .size _armv8_pmull_probe,.-_armv8_pmull_probe #endif -.globl OPENSSL_wipe_cpu -.type OPENSSL_wipe_cpu,%function -OPENSSL_wipe_cpu: -#if __ARM_ARCH__>=7 - ldr r0,.LOPENSSL_armcap - adr r1,.LOPENSSL_armcap - ldr r0,[r1,r0] -#ifdef __APPLE__ - ldr r0,[r0] -#endif -#endif - eor r2,r2,r2 - eor r3,r3,r3 - eor ip,ip,ip -#if __ARM_ARCH__>=7 - tst r0,#1 - beq .Lwipe_done - veor q0, q0, q0 - veor q1, q1, q1 - veor q2, q2, q2 - veor q3, q3, q3 - veor q8, q8, q8 - veor q9, q9, q9 - veor q10, q10, q10 - veor q11, q11, q11 - veor q12, q12, q12 - veor q13, q13, q13 - veor q14, q14, q14 - veor q15, q15, q15 -.Lwipe_done: -#endif - mov r0,sp -#if __ARM_ARCH__>=5 - bx lr -#else - tst lr,#1 - moveq pc,lr -.word 0xe12fff1e @ bx lr -#endif -.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu - -.align 5 -#if __ARM_ARCH__>=7 -.LOPENSSL_armcap: -.word OPENSSL_armcap_P-. -#endif -#if __ARM_ARCH__>=6 -.align 5 -#else -.Lspinlock: -.word atomic_add_spinlock-.Lspinlock -.align 5 - -.data -.align 2 -atomic_add_spinlock: -.word 0 -#endif - .comm OPENSSL_armcap_P,4,4 .hidden OPENSSL_armcap_P diff --git a/crypto/asn1/a_bitstr.c b/crypto/asn1/a_bitstr.c index c30b8f5b..76705514 100644 --- a/crypto/asn1/a_bitstr.c +++ b/crypto/asn1/a_bitstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_bitstr.c,v 1.36 2022/05/17 09:17:20 tb Exp $ */ +/* $OpenBSD: a_bitstr.c,v 1.38 2023/01/13 14:46:08 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -241,17 +241,27 @@ i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) if (a == NULL) return (0); + if (a->length == INT_MAX) + return (0); + + ret = a->length + 1; + + if (pp == NULL) + return (ret); + len = a->length; if (len > 0) { if (a->flags & ASN1_STRING_FLAG_BITS_LEFT) { bits = (int)a->flags & 0x07; } else { + j = 0; for (; len > 0; len--) { if (a->data[len - 1]) break; } - j = a->data[len - 1]; + if (len > 0) + j = a->data[len - 1]; if (j & 0x01) bits = 0; else if (j & 0x02) @@ -274,10 +284,6 @@ i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) } else bits = 0; - ret = 1 + len; - if (pp == NULL) - return (ret); - p= *pp; *(p++) = (unsigned char)bits; diff --git a/crypto/asn1/a_enum.c b/crypto/asn1/a_enum.c index b35fe436..d7c8181e 100644 --- a/crypto/asn1/a_enum.c +++ b/crypto/asn1/a_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_enum.c,v 1.27 2022/09/03 18:45:51 jsing Exp $ */ +/* $OpenBSD: a_enum.c,v 1.28 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,7 +65,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" #include "bytestring.h" /* diff --git a/crypto/asn1/a_mbstr.c b/crypto/asn1/a_mbstr.c index 8cff3ae1..32b39ad5 100644 --- a/crypto/asn1/a_mbstr.c +++ b/crypto/asn1/a_mbstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_mbstr.c,v 1.24 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: a_mbstr.c,v 1.26 2022/12/26 07:18:51 jmc Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -63,7 +63,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" static int traverse_string(const unsigned char *p, int len, int inform, int (*rfunc)(unsigned long value, void *in), void *arg); @@ -276,7 +276,7 @@ traverse_string(const unsigned char *p, int len, int inform, case MBSTRING_BMP: value = *p++ << 8; value |= *p++; - /* BMP is explictly defined to not support surrogates */ + /* BMP is explicitly defined to not support surrogates */ if (UNICODE_IS_SURROGATE(value)) return -1; len -= 2; diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c index 2ee6c17d..8c8ca853 100644 --- a/crypto/asn1/a_object.c +++ b/crypto/asn1/a_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_object.c,v 1.48 2022/05/13 16:32:10 tb Exp $ */ +/* $OpenBSD: a_object.c,v 1.49 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,7 +66,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" const ASN1_ITEM ASN1_OBJECT_it = { .itype = ASN1_ITYPE_PRIMITIVE, diff --git a/crypto/asn1/a_pkey.c b/crypto/asn1/a_pkey.c index 3b8dea7d..c4408614 100644 --- a/crypto/asn1/a_pkey.c +++ b/crypto/asn1/a_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_pkey.c,v 1.3 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: a_pkey.c,v 1.4 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,8 +71,8 @@ #include #endif -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" EVP_PKEY * d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) diff --git a/crypto/asn1/a_print.c b/crypto/asn1/a_print.c index ddcee54c..979f5f4d 100644 --- a/crypto/asn1/a_print.c +++ b/crypto/asn1/a_print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_print.c,v 1.11 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: a_print.c,v 1.12 2023/03/12 11:49:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -72,7 +72,7 @@ ASN1_PRINTABLE_type(const unsigned char *s, int len) if (s == NULL) return (V_ASN1_PRINTABLESTRING); - while ((*s) && (len-- != 0)) { + while (len-- > 0 && *s != '\0') { c= *(s++); if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || diff --git a/crypto/asn1/a_pubkey.c b/crypto/asn1/a_pubkey.c index f3bb5d81..5f5df103 100644 --- a/crypto/asn1/a_pubkey.c +++ b/crypto/asn1/a_pubkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_pubkey.c,v 1.3 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: a_pubkey.c,v 1.4 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -76,7 +76,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" EVP_PKEY * d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) diff --git a/crypto/asn1/a_strex.c b/crypto/asn1/a_strex.c index 848d1bff..91aa8d26 100644 --- a/crypto/asn1/a_strex.c +++ b/crypto/asn1/a_strex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_strex.c,v 1.31 2021/12/25 12:11:57 jsing Exp $ */ +/* $OpenBSD: a_strex.c,v 1.32 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -63,7 +63,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" #include "charmap.h" diff --git a/crypto/asn1/a_string.c b/crypto/asn1/a_string.c index ef36f50c..d0e917b8 100644 --- a/crypto/asn1/a_string.c +++ b/crypto/asn1/a_string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_string.c,v 1.11 2022/05/20 08:04:21 tb Exp $ */ +/* $OpenBSD: a_string.c,v 1.13 2022/11/28 07:50:47 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" ASN1_STRING * ASN1_STRING_new(void) @@ -199,12 +199,6 @@ ASN1_STRING_set0(ASN1_STRING *astr, void *data, int len) astr->length = len; } -void -asn1_add_error(const unsigned char *address, int offset) -{ - ERR_asprintf_error_data("offset=%d", offset); -} - int ASN1_STRING_length(const ASN1_STRING *astr) { diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index 03311e1b..fda06d4b 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_time.c,v 1.34 2022/06/27 13:54:57 beck Exp $ */ +/* $OpenBSD: a_time.c,v 1.36 2022/11/26 16:08:50 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * @@ -67,8 +67,7 @@ #include #include -#include "o_time.h" -#include "asn1_locl.h" +#include "asn1_local.h" const ASN1_ITEM ASN1_TIME_it = { .itype = ASN1_ITYPE_MSTRING, @@ -103,7 +102,7 @@ ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm) time(&now); memset(tm, 0, sizeof(*tm)); - return gmtime_r(&now, tm) != NULL; + return asn1_time_time_t_to_tm(&now, tm); } int diff --git a/crypto/asn1/a_time_posix.c b/crypto/asn1/a_time_posix.c new file mode 100644 index 00000000..9327aa8b --- /dev/null +++ b/crypto/asn1/a_time_posix.c @@ -0,0 +1,274 @@ +/* $OpenBSD: a_time_posix.c,v 1.3 2023/01/01 16:58:23 miod Exp $ */ +/* + * Copyright (c) 2022, Google Inc. + * Copyright (c) 2022, Bob Beck + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Time conversion to/from POSIX time_t and struct tm, with no support + * for time zones other than UTC + */ + +#include +#include +#include +#include + +#define SECS_PER_HOUR (int64_t)(60 * 60) +#define SECS_PER_DAY (int64_t)(24 * SECS_PER_HOUR) + +/* + * Is a year/month/day combination valid, in the range from year 0000 + * to 9999? + */ +static int +is_valid_date(int year, int month, int day) +{ + int days_in_month; + if (day < 1 || month < 1 || year < 0 || year > 9999) + return 0; + switch (month) { + case 1: + case 3: + case 5: + case 7: + case 8: + case 10: + case 12: + days_in_month = 31; + break; + case 4: + case 6: + case 9: + case 11: + days_in_month = 30; + break; + case 2: + if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) + days_in_month = 29; + else + days_in_month = 28; + break; + default: + return 0; + } + return day <= days_in_month; +} + +/* + * Is a time valid? Leap seconds of 60 are not considered valid, as + * the POSIX time in seconds does not include them. + */ +static int +is_valid_time(int hours, int minutes, int seconds) +{ + return hours >= 0 && minutes >= 0 && seconds >= 0 && hours <= 23 && + minutes <= 59 && seconds <= 59; +} + +/* Is a int64 time representing a time within our expected range? */ +static int +is_valid_epoch_time(int64_t time) +{ + /* 0000-01-01 00:00:00 UTC to 9999-12-31 23:59:59 UTC */ + return (int64_t)-62167219200LL <= time && + time <= (int64_t)253402300799LL; +} + +/* + * Inspired by algorithms presented in + * https://howardhinnant.github.io/date_algorithms.html + * (Public Domain) + */ +static int +posix_time_from_utc(int year, int month, int day, int hours, int minutes, + int seconds, int64_t *out_time) +{ + int64_t era, year_of_era, day_of_year, day_of_era, posix_days; + + if (!is_valid_date(year, month, day) || + !is_valid_time(hours, minutes, seconds)) + return 0; + if (month <= 2) + year--; /* Start years on Mar 1, so leap days end a year. */ + + /* At this point year will be in the range -1 and 9999.*/ + era = (year >= 0 ? year : year - 399) / 400; + year_of_era = year - era * 400; + day_of_year = (153 * (month > 2 ? month - 3 : month + 9) + 2) / + 5 + day - 1; + day_of_era = year_of_era * 365 + year_of_era / 4 - year_of_era / + 100 + day_of_year; + posix_days = era * 146097 + day_of_era - 719468; + *out_time = posix_days * SECS_PER_DAY + hours * SECS_PER_HOUR + + minutes * 60 + seconds; + + return 1; +} + +/* + * Inspired by algorithms presented in + * https://howardhinnant.github.io/date_algorithms.html + * (Public Domain) + */ +static int +utc_from_posix_time(int64_t time, int *out_year, int *out_month, int *out_day, + int *out_hours, int *out_minutes, int *out_seconds) +{ + int64_t days, leftover_seconds, era, day_of_era, year_of_era, + day_of_year, month_of_year; + + if (!is_valid_epoch_time(time)) + return 0; + + days = time / SECS_PER_DAY; + leftover_seconds = time % SECS_PER_DAY; + if (leftover_seconds < 0) { + days--; + leftover_seconds += SECS_PER_DAY; + } + days += 719468; /* Shift to starting epoch of Mar 1 0000. */ + + /* At this point, days will be in the range -61 and 3652364. */ + era = (days > 0 ? days : days - 146096) / 146097; + day_of_era = days - era * 146097; + year_of_era = (day_of_era - day_of_era / 1460 + day_of_era / 36524 - + day_of_era / 146096) / + 365; + *out_year = year_of_era + era * 400; /* Year starts on Mar 1 */ + day_of_year = day_of_era - (365 * year_of_era + year_of_era / 4 - + year_of_era / 100); + month_of_year = (5 * day_of_year + 2) / 153; + *out_month = (month_of_year < 10 ? month_of_year + 3 : + month_of_year - 9); + if (*out_month <= 2) + (*out_year)++; /* Adjust year back to Jan 1 start of year. */ + + *out_day = day_of_year - (153 * month_of_year + 2) / 5 + 1; + *out_hours = leftover_seconds / SECS_PER_HOUR; + leftover_seconds %= SECS_PER_HOUR; + *out_minutes = leftover_seconds / 60; + *out_seconds = leftover_seconds % 60; + + return 1; +} + +static int +asn1_time_tm_to_posix(const struct tm *tm, int64_t *out) +{ + /* Ensure additions below do not overflow */ + if (tm->tm_year > 9999) + return 0; + if (tm->tm_mon > 12) + return 0; + + return posix_time_from_utc(tm->tm_year + 1900, tm->tm_mon + 1, + tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, out); +} + +static int +asn1_time_posix_to_tm(int64_t time, struct tm *out_tm) +{ + memset(out_tm, 0, sizeof(struct tm)); + if (!utc_from_posix_time(time, &out_tm->tm_year, &out_tm->tm_mon, + &out_tm->tm_mday, &out_tm->tm_hour, &out_tm->tm_min, + &out_tm->tm_sec)) + return 0; + + out_tm->tm_year -= 1900; + out_tm->tm_mon -= 1; + + return 1; +} + +int +asn1_time_tm_to_time_t(const struct tm *tm, time_t *out) +{ + int64_t posix_time; + + if (!asn1_time_tm_to_posix(tm, &posix_time)) + return 0; + +#ifdef SMALL_TIME_T + /* For portable. */ + if (sizeof(time_t) == sizeof(int32_t) && + (posix_time > INT32_MAX || posix_time < INT32_MIN)) + return 0; +#endif + + *out = posix_time; + return 1; +} + +int +asn1_time_time_t_to_tm(const time_t *time, struct tm *out_tm) +{ + int64_t posix_time = *time; + + return asn1_time_posix_to_tm(posix_time, out_tm); +} + +int +OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec) +{ + int64_t posix_time; + + /* Ensure additions below do not overflow */ + if (tm->tm_year > 9999) + return 0; + if (tm->tm_mon > 12) + return 0; + + if (!posix_time_from_utc(tm->tm_year + 1900, tm->tm_mon + 1, + tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, &posix_time)) + return 0; + + if (!utc_from_posix_time(posix_time + off_day * SECS_PER_DAY + + offset_sec, &tm->tm_year, &tm->tm_mon, &tm->tm_mday, &tm->tm_hour, + &tm->tm_min, &tm->tm_sec)) + return 0; + + tm->tm_year -= 1900; + tm->tm_mon -= 1; + + return 1; +} + +int +OPENSSL_gmtime_diff(int *out_days, int *out_secs, const struct tm *from, + const struct tm *to) +{ + int64_t time_to, time_from, timediff, daydiff; + + if (!posix_time_from_utc(to->tm_year + 1900, to->tm_mon + 1, + to->tm_mday, to->tm_hour, to->tm_min, to->tm_sec, &time_to)) + return 0; + + if (!posix_time_from_utc(from->tm_year + 1900, from->tm_mon + 1, + from->tm_mday, from->tm_hour, from->tm_min, + from->tm_sec, &time_from)) + return 0; + + timediff = time_to - time_from; + daydiff = timediff / SECS_PER_DAY; + timediff %= SECS_PER_DAY; + if (daydiff > INT_MAX || daydiff < INT_MIN) + return 0; + + *out_secs = timediff; + *out_days = daydiff; + + return 1; +} diff --git a/crypto/asn1/a_time_tm.c b/crypto/asn1/a_time_tm.c index cb677ae9..c8b01726 100644 --- a/crypto/asn1/a_time_tm.c +++ b/crypto/asn1/a_time_tm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_time_tm.c,v 1.24 2022/07/04 14:39:43 tb Exp $ */ +/* $OpenBSD: a_time_tm.c,v 1.27 2022/11/26 16:08:50 tb Exp $ */ /* * Copyright (c) 2015 Bob Beck * @@ -25,7 +25,7 @@ #include #include "bytestring.h" -#include "o_time.h" +#include "asn1_local.h" #define RFC5280 0 #define GENTIME_LENGTH 15 @@ -68,7 +68,7 @@ ASN1_time_tm_clamp_notafter(struct tm *tm) struct tm broken_os_epoch_tm; time_t broken_os_epoch_time = INT_MAX; - if (gmtime_r(&broken_os_epoch_time, &broken_os_epoch_tm) == NULL) + if (!asn1_time_time_t_to_tm(&broken_os_epoch_time, &broken_os_epoch_tm)) return 0; if (ASN1_time_tm_cmp(tm, &broken_os_epoch_tm) == 1) @@ -379,7 +379,7 @@ ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec, { struct tm tm; - if (gmtime_r(&t, &tm) == NULL) + if (!asn1_time_time_t_to_tm(&t, &tm)) return (NULL); if (offset_day != 0 || offset_sec != 0) { @@ -410,7 +410,7 @@ ASN1_TIME_set_tm(ASN1_TIME *s, struct tm *tm) { time_t t; - if ((t = timegm(tm)) == -1) + if (!asn1_time_tm_to_time_t(tm, &t)) return NULL; return (ASN1_TIME_adj(s, t, 0, 0)); } @@ -475,7 +475,7 @@ ASN1_TIME_cmp_time_t_internal(const ASN1_TIME *s, time_t t2, int mode) if (ASN1_time_parse(s->data, s->length, &tm1, mode) == -1) return -2; - if (gmtime_r(&t2, &tm2) == NULL) + if (!asn1_time_time_t_to_tm(&t2, &tm2)) return -2; return ASN1_time_tm_cmp(&tm1, &tm2); diff --git a/crypto/asn1/a_type.c b/crypto/asn1/a_type.c index 61609c38..a382cd71 100644 --- a/crypto/asn1/a_type.c +++ b/crypto/asn1/a_type.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_type.c,v 1.23 2021/12/25 12:19:16 jsing Exp $ */ +/* $OpenBSD: a_type.c,v 1.25 2023/03/11 14:05:02 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -104,10 +104,14 @@ ASN1_TYPE_free(ASN1_TYPE *a) int ASN1_TYPE_get(const ASN1_TYPE *a) { - if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL)) - return (a->type); - else - return (0); + /* Special non-pointer types. */ + if (a->type == V_ASN1_BOOLEAN || a->type == V_ASN1_NULL) + return a->type; + + if (a->value.ptr != NULL) + return a->type; + + return 0; } void diff --git a/crypto/asn1/a_utf8.c b/crypto/asn1/a_utf8.c index 113a3a2e..51ab1bdb 100644 --- a/crypto/asn1/a_utf8.c +++ b/crypto/asn1/a_utf8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_utf8.c,v 1.8 2014/07/11 08:44:47 jsing Exp $ */ +/* $OpenBSD: a_utf8.c,v 1.9 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -60,7 +60,7 @@ #include -#include "asn1_locl.h" +#include "asn1_local.h" /* UTF8 utilities */ diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index 313440e0..e9f99276 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ameth_lib.c,v 1.26 2022/06/27 12:36:05 tb Exp $ */ +/* $OpenBSD: ameth_lib.c,v 1.30 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -68,140 +68,106 @@ #include #endif -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" -extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[]; -extern const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[]; +extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth; extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[]; extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD gostr01_asn1_meths[]; +extern const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth; extern const EVP_PKEY_ASN1_METHOD gostimit_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD gostr01_asn1_meths[]; extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[]; +extern const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD x25519_asn1_meth; -/* Keep this sorted in type order !! */ -static const EVP_PKEY_ASN1_METHOD *standard_methods[] = { -#ifndef OPENSSL_NO_RSA - &rsa_asn1_meths[0], - &rsa_asn1_meths[1], -#endif -#ifndef OPENSSL_NO_DH +static const EVP_PKEY_ASN1_METHOD *asn1_methods[] = { + &cmac_asn1_meth, &dh_asn1_meth, -#endif -#ifndef OPENSSL_NO_DSA &dsa_asn1_meths[0], &dsa_asn1_meths[1], &dsa_asn1_meths[2], &dsa_asn1_meths[3], &dsa_asn1_meths[4], -#endif -#ifndef OPENSSL_NO_EC &eckey_asn1_meth, -#endif -#ifndef OPENSSL_NO_GOST - &gostr01_asn1_meths[0], + &ed25519_asn1_meth, &gostimit_asn1_meth, -#endif - &hmac_asn1_meth, - &cmac_asn1_meth, -#ifndef OPENSSL_NO_RSA - &rsa_pss_asn1_meth, -#endif -#ifndef OPENSSL_NO_GOST + &gostr01_asn1_meths[0], &gostr01_asn1_meths[1], &gostr01_asn1_meths[2], -#endif + &hmac_asn1_meth, + &rsa_asn1_meths[0], + &rsa_asn1_meths[1], + &rsa_pss_asn1_meth, + &x25519_asn1_meth, }; -typedef int sk_cmp_fn_type(const char * const *a, const char * const *b); -DECLARE_STACK_OF(EVP_PKEY_ASN1_METHOD) -static STACK_OF(EVP_PKEY_ASN1_METHOD) *app_methods = NULL; - -static int ameth_cmp_BSEARCH_CMP_FN(const void *, const void *); -static int ameth_cmp(const EVP_PKEY_ASN1_METHOD * const *, const EVP_PKEY_ASN1_METHOD * const *); -static const EVP_PKEY_ASN1_METHOD * *OBJ_bsearch_ameth(const EVP_PKEY_ASN1_METHOD * *key, const EVP_PKEY_ASN1_METHOD * const *base, int num); +static const size_t asn1_methods_count = + sizeof(asn1_methods) / sizeof(asn1_methods[0]); -static int -ameth_cmp(const EVP_PKEY_ASN1_METHOD * const *a, - const EVP_PKEY_ASN1_METHOD * const *b) -{ - return ((*a)->pkey_id - (*b)->pkey_id); -} - - -static int -ameth_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) -{ - const EVP_PKEY_ASN1_METHOD * const *a = a_; - const EVP_PKEY_ASN1_METHOD * const *b = b_; - return ameth_cmp(a, b); -} - -static const EVP_PKEY_ASN1_METHOD * * -OBJ_bsearch_ameth(const EVP_PKEY_ASN1_METHOD * *key, const EVP_PKEY_ASN1_METHOD * const *base, int num) -{ - return (const EVP_PKEY_ASN1_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const EVP_PKEY_ASN1_METHOD *), - ameth_cmp_BSEARCH_CMP_FN); -} +DECLARE_STACK_OF(EVP_PKEY_ASN1_METHOD) +static STACK_OF(EVP_PKEY_ASN1_METHOD) *asn1_app_methods = NULL; int EVP_PKEY_asn1_get_count(void) { - int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *); - if (app_methods) - num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods); + int num = asn1_methods_count; + + if (asn1_app_methods != NULL) + num += sk_EVP_PKEY_ASN1_METHOD_num(asn1_app_methods); + return num; } const EVP_PKEY_ASN1_METHOD * EVP_PKEY_asn1_get0(int idx) { - int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *); + int num = asn1_methods_count; + if (idx < 0) return NULL; if (idx < num) - return standard_methods[idx]; + return asn1_methods[idx]; + idx -= num; - return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx); + + return sk_EVP_PKEY_ASN1_METHOD_value(asn1_app_methods, idx); } static const EVP_PKEY_ASN1_METHOD * -pkey_asn1_find(int type) +pkey_asn1_find(int pkey_id) { - EVP_PKEY_ASN1_METHOD tmp; - const EVP_PKEY_ASN1_METHOD *t = &tmp, **ret; - tmp.pkey_id = type; - if (app_methods) { - int idx; - idx = sk_EVP_PKEY_ASN1_METHOD_find(app_methods, &tmp); - if (idx >= 0) - return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx); + const EVP_PKEY_ASN1_METHOD *ameth; + int i; + + for (i = EVP_PKEY_asn1_get_count() - 1; i >= 0; i--) { + ameth = EVP_PKEY_asn1_get0(i); + if (ameth->pkey_id == pkey_id) + return ameth; } - ret = OBJ_bsearch_ameth(&t, standard_methods, - sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *)); - if (!ret || !*ret) - return NULL; - return *ret; + + return NULL; } -/* Find an implementation of an ASN1 algorithm. If 'pe' is not NULL +/* + * Find an implementation of an ASN1 algorithm. If 'pe' is not NULL * also search through engines and set *pe to a functional reference * to the engine implementing 'type' or NULL if no engine implements * it. */ - const EVP_PKEY_ASN1_METHOD * EVP_PKEY_asn1_find(ENGINE **pe, int type) { - const EVP_PKEY_ASN1_METHOD *t; + const EVP_PKEY_ASN1_METHOD *mp; for (;;) { - t = pkey_asn1_find(type); - if (!t || !(t->pkey_flags & ASN1_PKEY_ALIAS)) + if ((mp = pkey_asn1_find(type)) == NULL) + break; + if ((mp->pkey_flags & ASN1_PKEY_ALIAS) == 0) break; - type = t->pkey_base_id; + type = mp->pkey_base_id; } if (pe) { #ifndef OPENSSL_NO_ENGINE @@ -215,14 +181,15 @@ EVP_PKEY_asn1_find(ENGINE **pe, int type) #endif *pe = NULL; } - return t; + return mp; } const EVP_PKEY_ASN1_METHOD * EVP_PKEY_asn1_find_str(ENGINE **pe, const char *str, int len) { - int i; const EVP_PKEY_ASN1_METHOD *ameth; + int i; + if (len == -1) len = strlen(str); if (pe) { @@ -242,7 +209,7 @@ EVP_PKEY_asn1_find_str(ENGINE **pe, const char *str, int len) #endif *pe = NULL; } - for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) { + for (i = EVP_PKEY_asn1_get_count() - 1; i >= 0; i--) { ameth = EVP_PKEY_asn1_get0(i); if (ameth->pkey_flags & ASN1_PKEY_ALIAS) continue; @@ -256,14 +223,15 @@ EVP_PKEY_asn1_find_str(ENGINE **pe, const char *str, int len) int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth) { - if (app_methods == NULL) { - app_methods = sk_EVP_PKEY_ASN1_METHOD_new(ameth_cmp); - if (!app_methods) + if (asn1_app_methods == NULL) { + asn1_app_methods = sk_EVP_PKEY_ASN1_METHOD_new(NULL); + if (asn1_app_methods == NULL) return 0; } - if (!sk_EVP_PKEY_ASN1_METHOD_push(app_methods, ameth)) + + if (!sk_EVP_PKEY_ASN1_METHOD_push(asn1_app_methods, ameth)) return 0; - sk_EVP_PKEY_ASN1_METHOD_sort(app_methods); + return 1; } @@ -273,8 +241,9 @@ EVP_PKEY_asn1_add_alias(int to, int from) EVP_PKEY_ASN1_METHOD *ameth; ameth = EVP_PKEY_asn1_new(from, ASN1_PKEY_ALIAS, NULL, NULL); - if (!ameth) + if (ameth == NULL) return 0; + ameth->pkey_base_id = to; if (!EVP_PKEY_asn1_add0(ameth)) { EVP_PKEY_asn1_free(ameth); diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c index a37091ce..b64aa896 100644 --- a/crypto/asn1/asn1_gen.c +++ b/crypto/asn1/asn1_gen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_gen.c,v 1.19 2022/05/24 19:56:13 tb Exp $ */ +/* $OpenBSD: asn1_gen.c,v 1.20 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2002. */ @@ -62,7 +62,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" #define ASN1_GEN_FLAG 0x10000 #define ASN1_GEN_FLAG_IMP (ASN1_GEN_FLAG|1) diff --git a/crypto/asn1/asn1_item.c b/crypto/asn1/asn1_item.c index f133f9b4..9e7f308e 100644 --- a/crypto/asn1/asn1_item.c +++ b/crypto/asn1/asn1_item.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_item.c,v 1.5 2022/05/24 20:20:19 tb Exp $ */ +/* $OpenBSD: asn1_item.c,v 1.6 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -116,8 +116,8 @@ #include #include -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" /* * ASN1_ITEM version of dup: this follows the model above except we don't need diff --git a/crypto/asn1/asn1_locl.h b/crypto/asn1/asn1_local.h similarity index 92% rename from crypto/asn1/asn1_locl.h rename to crypto/asn1/asn1_local.h index ca0b7d7d..ed40e18e 100644 --- a/crypto/asn1/asn1_locl.h +++ b/crypto/asn1/asn1_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_locl.h,v 1.39 2022/09/11 17:22:52 tb Exp $ */ +/* $OpenBSD: asn1_local.h,v 1.1 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -142,6 +142,15 @@ struct evp_pkey_asn1_method_st { int (*pkey_check)(const EVP_PKEY *pk); int (*pkey_public_check)(const EVP_PKEY *pk); int (*pkey_param_check)(const EVP_PKEY *pk); + + int (*set_priv_key)(EVP_PKEY *pk, const unsigned char *private_key, + size_t len); + int (*set_pub_key)(EVP_PKEY *pk, const unsigned char *public_key, + size_t len); + int (*get_priv_key)(const EVP_PKEY *pk, unsigned char *out_private_key, + size_t *out_len); + int (*get_pub_key)(const EVP_PKEY *pk, unsigned char *out_public_key, + size_t *out_len); } /* EVP_PKEY_ASN1_METHOD */; /* Method to handle CRL access. @@ -233,5 +242,10 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp); ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, long length); +int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); +int OPENSSL_gmtime_diff(int *pday, int *psec, const struct tm *from, + const struct tm *to); +int asn1_time_time_t_to_tm(const time_t *time, struct tm *out_tm); +int asn1_time_tm_to_time_t(const struct tm *tm, time_t *out); __END_HIDDEN_DECLS diff --git a/crypto/asn1/asn1_old.c b/crypto/asn1/asn1_old.c index 59e9cdb1..d7f0d968 100644 --- a/crypto/asn1/asn1_old.c +++ b/crypto/asn1/asn1_old.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_old.c,v 1.2 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: asn1_old.c,v 1.3 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" #ifndef NO_OLD_ASN1 diff --git a/crypto/asn1/asn1_old_lib.c b/crypto/asn1/asn1_old_lib.c index a4d3cc71..f19cb1ca 100644 --- a/crypto/asn1/asn1_old_lib.c +++ b/crypto/asn1/asn1_old_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_old_lib.c,v 1.4 2022/05/05 19:18:56 jsing Exp $ */ +/* $OpenBSD: asn1_old_lib.c,v 1.5 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" static void asn1_put_length(unsigned char **pp, int length); diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c index 31502143..48bd9d1e 100644 --- a/crypto/asn1/asn_mime.c +++ b/crypto/asn1/asn_mime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn_mime.c,v 1.29 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: asn_mime.c,v 1.30 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -62,8 +62,8 @@ #include #include -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" /* Generalised MIME like utilities for streaming ASN1. Although many * have a PKCS7/CMS like flavour others are more general purpose. diff --git a/crypto/asn1/asn_moid.c b/crypto/asn1/asn_moid.c index c672f0ae..166ebae3 100644 --- a/crypto/asn1/asn_moid.c +++ b/crypto/asn1/asn_moid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn_moid.c,v 1.14 2022/01/07 11:13:54 tb Exp $ */ +/* $OpenBSD: asn_moid.c,v 1.15 2022/11/26 16:08:50 tb Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -65,7 +65,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" /* Simple ASN1 OID module: add all objects in a given section */ diff --git a/crypto/asn1/bio_asn1.c b/crypto/asn1/bio_asn1.c index 9017786f..21f33ecf 100644 --- a/crypto/asn1/bio_asn1.c +++ b/crypto/asn1/bio_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_asn1.c,v 1.17 2022/01/14 08:40:57 tb Exp $ */ +/* $OpenBSD: bio_asn1.c,v 1.19 2023/03/10 11:55:38 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -177,6 +177,12 @@ asn1_bio_free(BIO *b) ctx = (BIO_ASN1_BUF_CTX *) b->ptr; if (ctx == NULL) return 0; + + if (ctx->prefix_free != NULL) + ctx->prefix_free(b, &ctx->ex_buf, &ctx->ex_len, &ctx->ex_arg); + if (ctx->suffix_free != NULL) + ctx->suffix_free(b, &ctx->ex_buf, &ctx->ex_len, &ctx->ex_arg); + free(ctx->buf); free(ctx); b->init = 0; @@ -254,7 +260,7 @@ asn1_bio_write(BIO *b, const char *in , int inl) wrmax = inl; ret = BIO_write(b->next_bio, in, wrmax); if (ret <= 0) - break; + goto done; wrlen += ret; ctx->copylen -= ret; in += ret; diff --git a/crypto/asn1/bio_ndef.c b/crypto/asn1/bio_ndef.c index 88b204e8..b1fcc4dd 100644 --- a/crypto/asn1/bio_ndef.c +++ b/crypto/asn1/bio_ndef.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_ndef.c,v 1.11 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: bio_ndef.c,v 1.20 2023/03/15 06:30:21 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -101,32 +101,49 @@ BIO * BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it) { NDEF_SUPPORT *ndef_aux = NULL; - BIO *asn_bio = NULL; + BIO *asn_bio = NULL, *pop_bio = NULL; const ASN1_AUX *aux = it->funcs; ASN1_STREAM_ARG sarg; - if (!aux || !aux->asn1_cb) { + if (aux == NULL || aux->asn1_cb == NULL) { ASN1error(ASN1_R_STREAMING_NOT_SUPPORTED); - return NULL; + goto err; } - ndef_aux = malloc(sizeof(NDEF_SUPPORT)); - asn_bio = BIO_new(BIO_f_asn1()); - /* ASN1 bio needs to be next to output BIO */ + if ((asn_bio = BIO_new(BIO_f_asn1())) == NULL) + goto err; - out = BIO_push(asn_bio, out); + if (BIO_push(asn_bio, out) == NULL) + goto err; + pop_bio = asn_bio; - if (!ndef_aux || !asn_bio || !out) + /* + * Set up prefix and suffix handlers first. This ensures that ndef_aux + * is freed as part of asn_bio once it is the asn_bio's ex_arg. + */ + if (BIO_asn1_set_prefix(asn_bio, ndef_prefix, ndef_prefix_free) <= 0) + goto err; + if (BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free) <= 0) goto err; - BIO_asn1_set_prefix(asn_bio, ndef_prefix, ndef_prefix_free); - BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free); + /* + * Allocate early to avoid the tricky cleanup after the asn1_cb(). + * Ownership of ndef_aux is transferred to asn_bio in BIO_ctrl(). + * Keep a reference to populate it after callback success. + */ + if ((ndef_aux = calloc(1, sizeof(*ndef_aux))) == NULL) + goto err; + if (BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux) <= 0) { + free(ndef_aux); + goto err; + } - /* Now let callback prepend any digest, cipher etc BIOs - * ASN1 structure needs. + /* + * The callback prepends BIOs to the chain starting at asn_bio for + * digest, cipher, etc. The resulting chain starts at sarg.ndef_bio. */ - sarg.out = out; + sarg.out = asn_bio; sarg.ndef_bio = NULL; sarg.boundary = NULL; @@ -137,15 +154,13 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it) ndef_aux->it = it; ndef_aux->ndef_bio = sarg.ndef_bio; ndef_aux->boundary = sarg.boundary; - ndef_aux->out = out; - - BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux); + ndef_aux->out = asn_bio; return sarg.ndef_bio; err: + BIO_pop(pop_bio); BIO_free(asn_bio); - free(ndef_aux); return NULL; } @@ -178,29 +193,34 @@ ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg) static int ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg) { - NDEF_SUPPORT *ndef_aux; + NDEF_SUPPORT **pndef_aux = parg; - if (!parg) + if (pndef_aux == NULL || *pndef_aux == NULL) return 0; - ndef_aux = *(NDEF_SUPPORT **)parg; + free((*pndef_aux)->derbuf); + (*pndef_aux)->derbuf = NULL; - free(ndef_aux->derbuf); - - ndef_aux->derbuf = NULL; *pbuf = NULL; *plen = 0; + return 1; } static int ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg) { - NDEF_SUPPORT **pndef_aux = (NDEF_SUPPORT **)parg; + NDEF_SUPPORT **pndef_aux = parg; + + /* Ensure ndef_prefix_free() won't fail, so we won't leak *pndef_aux. */ + if (pndef_aux == NULL || *pndef_aux == NULL) + return 0; if (!ndef_prefix_free(b, pbuf, plen, parg)) return 0; + free(*pndef_aux); *pndef_aux = NULL; + return 1; } diff --git a/crypto/asn1/p5_pbev2.c b/crypto/asn1/p5_pbev2.c index d88a4dfc..85818a90 100644 --- a/crypto/asn1/p5_pbev2.c +++ b/crypto/asn1/p5_pbev2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p5_pbev2.c,v 1.27 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: p5_pbev2.c,v 1.28 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999-2004. */ @@ -64,7 +64,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* PKCS#5 v2.0 password based encryption structures */ diff --git a/crypto/asn1/p8_pkey.c b/crypto/asn1/p8_pkey.c index 18659a6f..24f14574 100644 --- a/crypto/asn1/p8_pkey.c +++ b/crypto/asn1/p8_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p8_pkey.c,v 1.20 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: p8_pkey.c,v 1.21 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -62,7 +62,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" /* Minor tweak to operation: zero private key data */ static int diff --git a/crypto/asn1/t_crl.c b/crypto/asn1/t_crl.c index 3ded015d..34c9200a 100644 --- a/crypto/asn1/t_crl.c +++ b/crypto/asn1/t_crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_crl.c,v 1.20 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: t_crl.c,v 1.21 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -66,7 +66,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" int X509_CRL_print_fp(FILE *fp, X509_CRL *x) diff --git a/crypto/asn1/t_pkey.c b/crypto/asn1/t_pkey.c index a3073812..0392dc41 100644 --- a/crypto/asn1/t_pkey.c +++ b/crypto/asn1/t_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_pkey.c,v 1.17 2021/12/04 16:08:32 tb Exp $ */ +/* $OpenBSD: t_pkey.c,v 1.19 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, @@ -114,3 +114,32 @@ ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, } return (1); } + +#define ASN1_BUF_PRINT_WIDTH 15 +#define ASN1_BUF_PRINT_MAX_INDENT 64 + +int +ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int indent) +{ + size_t i; + + for (i = 0; i < buflen; i++) { + if ((i % ASN1_BUF_PRINT_WIDTH) == 0) { + if (i > 0 && BIO_puts(bp, "\n") <= 0) + return 0; + if (!BIO_indent(bp, indent, ASN1_BUF_PRINT_MAX_INDENT)) + return 0; + } + /* + * Use colon separators for each octet for compatibility as + * this function is used to print out key components. + */ + if (BIO_printf(bp, "%02x%s", buf[i], + (i == buflen - 1) ? "" : ":") <= 0) + return 0; + } + if (BIO_write(bp, "\n", 1) <= 0) + return 0; + + return 1; +} diff --git a/crypto/asn1/t_req.c b/crypto/asn1/t_req.c index 81f7dd29..0ede4ceb 100644 --- a/crypto/asn1/t_req.c +++ b/crypto/asn1/t_req.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_req.c,v 1.23 2022/08/30 08:45:06 tb Exp $ */ +/* $OpenBSD: t_req.c,v 1.24 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -74,7 +74,7 @@ #include #endif -#include "x509_lcl.h" +#include "x509_local.h" int X509_REQ_print_fp(FILE *fp, X509_REQ *x) diff --git a/crypto/asn1/t_spki.c b/crypto/asn1/t_spki.c index 56c0956c..2da8717a 100644 --- a/crypto/asn1/t_spki.c +++ b/crypto/asn1/t_spki.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_spki.c,v 1.13 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: t_spki.c,v 1.14 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -71,7 +71,7 @@ #include #endif -#include "x509_lcl.h" +#include "x509_local.h" /* Print out an SPKI */ diff --git a/crypto/asn1/t_x509.c b/crypto/asn1/t_x509.c index 5f520f5c..d0fbf904 100644 --- a/crypto/asn1/t_x509.c +++ b/crypto/asn1/t_x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_x509.c,v 1.40 2022/08/11 10:36:32 tb Exp $ */ +/* $OpenBSD: t_x509.c,v 1.41 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -77,8 +77,8 @@ #include #endif -#include "asn1_locl.h" -#include "x509_lcl.h" +#include "asn1_local.h" +#include "x509_local.h" int X509_print_fp(FILE *fp, X509 *x) diff --git a/crypto/asn1/t_x509a.c b/crypto/asn1/t_x509a.c index 6745318b..09e5ecd3 100644 --- a/crypto/asn1/t_x509a.c +++ b/crypto/asn1/t_x509a.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_x509a.c,v 1.10 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: t_x509a.c,v 1.11 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -62,7 +62,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" /* X509_CERT_AUX and string set routines */ diff --git a/crypto/asn1/tasn_dec.c b/crypto/asn1/tasn_dec.c index 5e0692e0..0c2357c2 100644 --- a/crypto/asn1/tasn_dec.c +++ b/crypto/asn1/tasn_dec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_dec.c,v 1.83 2022/09/03 19:15:23 jsing Exp $ */ +/* $OpenBSD: tasn_dec.c,v 1.84 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -66,7 +66,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" #include "bytestring.h" /* diff --git a/crypto/asn1/tasn_enc.c b/crypto/asn1/tasn_enc.c index 8e17d666..6e0524c3 100644 --- a/crypto/asn1/tasn_enc.c +++ b/crypto/asn1/tasn_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_enc.c,v 1.25.2.1 2022/10/20 09:47:01 tb Exp $ */ +/* $OpenBSD: tasn_enc.c,v 1.29 2023/03/06 12:00:27 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -64,7 +64,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); @@ -106,22 +106,28 @@ static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it, int flags) { - if (out && !*out) { - unsigned char *p, *buf; - int len; - len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags); - if (len <= 0) - return len; - buf = malloc(len); - if (!buf) - return -1; - p = buf; - ASN1_item_ex_i2d(&val, &p, it, -1, flags); - *out = buf; + unsigned char *p, *buf; + int len; + + if (out == NULL || *out != NULL) + return ASN1_item_ex_i2d(&val, out, it, -1, flags); + + if ((len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags)) <= 0) return len; + + if ((buf = calloc(1, len)) == NULL) + return -1; + + p = buf; + if (ASN1_item_ex_i2d(&val, &p, it, -1, flags) != len) { + freezero(buf, len); + ASN1error(ASN1_R_LENGTH_ERROR); + return -1; } - return ASN1_item_ex_i2d(&val, out, it, -1, flags); + *out = buf; + + return len; } /* Encode an item, taking care of IMPLICIT tagging (if any). diff --git a/crypto/asn1/tasn_fre.c b/crypto/asn1/tasn_fre.c index cc7b838c..38f3764f 100644 --- a/crypto/asn1/tasn_fre.c +++ b/crypto/asn1/tasn_fre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_fre.c,v 1.20 2022/05/12 19:55:58 jsing Exp $ */ +/* $OpenBSD: tasn_fre.c,v 1.21 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -62,7 +62,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" static void asn1_item_free(ASN1_VALUE **pval, const ASN1_ITEM *it); diff --git a/crypto/asn1/tasn_new.c b/crypto/asn1/tasn_new.c index 83b0fce5..5d436cf2 100644 --- a/crypto/asn1/tasn_new.c +++ b/crypto/asn1/tasn_new.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_new.c,v 1.22 2022/05/10 05:19:22 jsing Exp $ */ +/* $OpenBSD: tasn_new.c,v 1.23 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -64,7 +64,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" static int asn1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); diff --git a/crypto/asn1/tasn_prn.c b/crypto/asn1/tasn_prn.c index 54ec56ec..7f93e487 100644 --- a/crypto/asn1/tasn_prn.c +++ b/crypto/asn1/tasn_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_prn.c,v 1.22 2021/12/03 17:10:49 jsing Exp $ */ +/* $OpenBSD: tasn_prn.c,v 1.23 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -65,7 +65,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" /* Print routines. */ diff --git a/crypto/asn1/tasn_utl.c b/crypto/asn1/tasn_utl.c index 86cd42ee..ae546edd 100644 --- a/crypto/asn1/tasn_utl.c +++ b/crypto/asn1/tasn_utl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_utl.c,v 1.17 2022/05/12 19:55:58 jsing Exp $ */ +/* $OpenBSD: tasn_utl.c,v 1.18 2022/12/26 07:18:51 jmc Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -100,7 +100,7 @@ asn1_set_choice_selector(ASN1_VALUE **pval, int value, const ASN1_ITEM *it) /* Do reference counting. The value 'op' decides what to do. * if it is +1 then the count is incremented. If op is 0 count is * set to 1. If op is -1 count is decremented and the return value - * is the current refrence count or 0 if no reference count exists. + * is the current reference count or 0 if no reference count exists. */ int diff --git a/crypto/asn1/x_attrib.c b/crypto/asn1/x_attrib.c index e8822a33..d116094c 100644 --- a/crypto/asn1/x_attrib.c +++ b/crypto/asn1/x_attrib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_attrib.c,v 1.17 2022/05/09 19:19:33 jsing Exp $ */ +/* $OpenBSD: x_attrib.c,v 1.18 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" /* * XXX - remove X509_ATTRIBUTE_SET_it with next major bump. diff --git a/crypto/asn1/x_bignum.c b/crypto/asn1/x_bignum.c index d1f735b4..bfcf9419 100644 --- a/crypto/asn1/x_bignum.c +++ b/crypto/asn1/x_bignum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_bignum.c,v 1.12 2022/07/30 13:42:25 jsing Exp $ */ +/* $OpenBSD: x_bignum.c,v 1.13 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -61,7 +61,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" #include "bytestring.h" /* diff --git a/crypto/asn1/x_crl.c b/crypto/asn1/x_crl.c index 35d9007f..f637bddd 100644 --- a/crypto/asn1/x_crl.c +++ b/crypto/asn1/x_crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_crl.c,v 1.37 2022/02/24 22:05:06 beck Exp $ */ +/* $OpenBSD: x_crl.c,v 1.39 2022/12/26 16:00:36 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,8 +65,8 @@ #include #include -#include "asn1_locl.h" -#include "x509_lcl.h" +#include "asn1_local.h" +#include "x509_local.h" static int X509_REVOKED_cmp(const X509_REVOKED * const *a, const X509_REVOKED * const *b); @@ -755,3 +755,9 @@ X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig, if (palg != NULL) *palg = crl->sig_alg; } + +const X509_ALGOR * +X509_CRL_get0_tbs_sigalg(const X509_CRL *crl) +{ + return crl->crl->sig_alg; +} diff --git a/crypto/asn1/x_exten.c b/crypto/asn1/x_exten.c index aba89736..fc54b497 100644 --- a/crypto/asn1/x_exten.c +++ b/crypto/asn1/x_exten.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_exten.c,v 1.17 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x_exten.c,v 1.18 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -61,7 +61,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static const ASN1_TEMPLATE X509_EXTENSION_seq_tt[] = { { diff --git a/crypto/asn1/x_long.c b/crypto/asn1/x_long.c index 543c56a5..aafdb9c2 100644 --- a/crypto/asn1/x_long.c +++ b/crypto/asn1/x_long.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_long.c,v 1.18 2022/07/02 18:14:35 jsing Exp $ */ +/* $OpenBSD: x_long.c,v 1.19 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -63,7 +63,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" /* * Custom primitive type for long handling. This converts between an diff --git a/crypto/asn1/x_name.c b/crypto/asn1/x_name.c index 4c698ac2..ea3a3c87 100644 --- a/crypto/asn1/x_name.c +++ b/crypto/asn1/x_name.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_name.c,v 1.37 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: x_name.c,v 1.38 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -64,8 +64,8 @@ #include #include -#include "asn1_locl.h" -#include "x509_lcl.h" +#include "asn1_local.h" +#include "x509_local.h" typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY; DECLARE_STACK_OF(STACK_OF_X509_NAME_ENTRY) diff --git a/crypto/asn1/x_pubkey.c b/crypto/asn1/x_pubkey.c index a2c3d88e..4c255d63 100644 --- a/crypto/asn1/x_pubkey.c +++ b/crypto/asn1/x_pubkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_pubkey.c,v 1.32 2022/05/24 19:59:14 tb Exp $ */ +/* $OpenBSD: x_pubkey.c,v 1.33 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,9 +71,9 @@ #include #endif -#include "asn1_locl.h" -#include "evp_locl.h" -#include "x509_lcl.h" +#include "asn1_local.h" +#include "evp_local.h" +#include "x509_local.h" /* Minor tweak to operation: free up EVP_PKEY */ static int diff --git a/crypto/asn1/x_req.c b/crypto/asn1/x_req.c index 38e3790b..42b91733 100644 --- a/crypto/asn1/x_req.c +++ b/crypto/asn1/x_req.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_req.c,v 1.18 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x_req.c,v 1.19 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -61,7 +61,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" /* X509_REQ_INFO is handled in an unusual way to get round * invalid encodings. Some broken certificate requests don't diff --git a/crypto/asn1/x_sig.c b/crypto/asn1/x_sig.c index 6a842da5..9406a2d6 100644 --- a/crypto/asn1/x_sig.c +++ b/crypto/asn1/x_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_sig.c,v 1.13 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x_sig.c,v 1.14 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -61,7 +61,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static const ASN1_TEMPLATE X509_SIG_seq_tt[] = { { diff --git a/crypto/asn1/x_x509.c b/crypto/asn1/x_x509.c index 7147069e..227af88e 100644 --- a/crypto/asn1/x_x509.c +++ b/crypto/asn1/x_x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_x509.c,v 1.30 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: x_x509.c,v 1.31 2022/11/26 16:08:50 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,7 +65,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static const ASN1_AUX X509_CINF_aux = { .flags = ASN1_AFLG_ENCODING, diff --git a/crypto/asn1/x_x509a.c b/crypto/asn1/x_x509a.c index 87dc045a..a5e1f71e 100644 --- a/crypto/asn1/x_x509a.c +++ b/crypto/asn1/x_x509a.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_x509a.c,v 1.18 2021/12/25 13:17:48 jsing Exp $ */ +/* $OpenBSD: x_x509a.c,v 1.19 2022/11/26 16:08:50 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -62,7 +62,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" /* X509_CERT_AUX routines. These are used to encode additional * user modifiable data about a certificate. This data is diff --git a/crypto/bf/bf_cfb64.c b/crypto/bf/bf_cfb64.c index 6cc0bb99..87dccae2 100644 --- a/crypto/bf/bf_cfb64.c +++ b/crypto/bf/bf_cfb64.c @@ -1,25 +1,25 @@ -/* $OpenBSD: bf_cfb64.c,v 1.5 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: bf_cfb64.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -57,65 +57,68 @@ */ #include -#include "bf_locl.h" -/* The input and output encrypted as though 64bit cfb mode is being +#include "bf_local.h" + +/* + * The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ -void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt) - { - BF_LONG v0,v1,t; +void +BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt) +{ + BF_LONG v0, v1, t; int n= *num; - long l=length; + long l = length; BF_LONG ti[2]; - unsigned char *iv,c,cc; + unsigned char *iv, c, cc; - iv=(unsigned char *)ivec; - if (encrypt) - { - while (l--) - { - if (n == 0) - { - n2l(iv,v0); ti[0]=v0; - n2l(iv,v1); ti[1]=v1; - BF_encrypt((BF_LONG *)ti,schedule); - iv=(unsigned char *)ivec; - t=ti[0]; l2n(t,iv); - t=ti[1]; l2n(t,iv); - iv=(unsigned char *)ivec; - } - c= *(in++)^iv[n]; - *(out++)=c; - iv[n]=c; - n=(n+1)&0x07; + iv = (unsigned char *)ivec; + if (encrypt) { + while (l--) { + if (n == 0) { + n2l(iv, v0); + ti[0] = v0; + n2l(iv, v1); + ti[1] = v1; + BF_encrypt((BF_LONG *)ti, schedule); + iv = (unsigned char *)ivec; + t = ti[0]; + l2n(t, iv); + t = ti[1]; + l2n(t, iv); + iv = (unsigned char *)ivec; } + c= *(in++)^iv[n]; + *(out++) = c; + iv[n] = c; + n = (n + 1)&0x07; } - else - { - while (l--) - { - if (n == 0) - { - n2l(iv,v0); ti[0]=v0; - n2l(iv,v1); ti[1]=v1; - BF_encrypt((BF_LONG *)ti,schedule); - iv=(unsigned char *)ivec; - t=ti[0]; l2n(t,iv); - t=ti[1]; l2n(t,iv); - iv=(unsigned char *)ivec; - } - cc= *(in++); - c=iv[n]; - iv[n]=cc; - *(out++)=c^cc; - n=(n+1)&0x07; + } else { + while (l--) { + if (n == 0) { + n2l(iv, v0); + ti[0] = v0; + n2l(iv, v1); + ti[1] = v1; + BF_encrypt((BF_LONG *)ti, schedule); + iv = (unsigned char *)ivec; + t = ti[0]; + l2n(t, iv); + t = ti[1]; + l2n(t, iv); + iv = (unsigned char *)ivec; } + cc= *(in++); + c = iv[n]; + iv[n] = cc; + *(out++) = c^cc; + n = (n + 1)&0x07; } - v0=v1=ti[0]=ti[1]=t=c=cc=0; - *num=n; } - + v0 = v1 = ti[0] = ti[1] = t=c = cc = 0; + *num = n; +} diff --git a/crypto/bf/bf_ecb.c b/crypto/bf/bf_ecb.c index 305bd782..99e50b0f 100644 --- a/crypto/bf/bf_ecb.c +++ b/crypto/bf/bf_ecb.c @@ -1,25 +1,25 @@ -/* $OpenBSD: bf_ecb.c,v 1.6 2014/07/09 11:10:50 bcook Exp $ */ +/* $OpenBSD: bf_ecb.c,v 1.9 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -57,16 +57,19 @@ */ #include -#include "bf_locl.h" #include -/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' +#include "bf_local.h" + +/* + * Blowfish as implemented from 'Blowfish: Springer-Verlag paper' * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) */ -const char *BF_options(void) - { +const char * +BF_options(void) +{ #ifdef BF_PTR return("blowfish(ptr)"); #elif defined(BF_PTR2) @@ -74,21 +77,25 @@ const char *BF_options(void) #else return("blowfish(idx)"); #endif - } +} -void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, - const BF_KEY *key, int encrypt) - { - BF_LONG l,d[2]; +void +BF_ecb_encrypt(const unsigned char *in, unsigned char *out, + const BF_KEY *key, int encrypt) +{ + BF_LONG l, d[2]; - n2l(in,l); d[0]=l; - n2l(in,l); d[1]=l; + n2l(in, l); + d[0] = l; + n2l(in, l); + d[1] = l; if (encrypt) - BF_encrypt(d,key); + BF_encrypt(d, key); else - BF_decrypt(d,key); - l=d[0]; l2n(l,out); - l=d[1]; l2n(l,out); - l=d[0]=d[1]=0; - } - + BF_decrypt(d, key); + l = d[0]; + l2n(l, out); + l = d[1]; + l2n(l, out); + l = d[0] = d[1] = 0; +} diff --git a/crypto/bf/bf_enc.c b/crypto/bf/bf_enc.c index 2cf1c860..bbefe7d5 100644 --- a/crypto/bf/bf_enc.c +++ b/crypto/bf/bf_enc.c @@ -1,25 +1,25 @@ -/* $OpenBSD: bf_enc.c,v 1.6 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: bf_enc.c,v 1.9 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -57,9 +57,11 @@ */ #include -#include "bf_locl.h" -/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' +#include "bf_local.h" + +/* + * Blowfish as implemented from 'Blowfish: Springer-Verlag paper' * (From LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, * CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993) */ @@ -69,238 +71,234 @@ to modify the code. #endif -void BF_encrypt(BF_LONG *data, const BF_KEY *key) - { +void +BF_encrypt(BF_LONG *data, const BF_KEY *key) +{ #ifndef BF_PTR2 - BF_LONG l,r; - const BF_LONG *p,*s; + BF_LONG l, r; + const BF_LONG *p, *s; - p=key->P; - s= &(key->S[0]); - l=data[0]; - r=data[1]; + p = key->P; + s = &(key->S[0]); + l = data[0]; + r = data[1]; - l^=p[0]; - BF_ENC(r,l,s,p[ 1]); - BF_ENC(l,r,s,p[ 2]); - BF_ENC(r,l,s,p[ 3]); - BF_ENC(l,r,s,p[ 4]); - BF_ENC(r,l,s,p[ 5]); - BF_ENC(l,r,s,p[ 6]); - BF_ENC(r,l,s,p[ 7]); - BF_ENC(l,r,s,p[ 8]); - BF_ENC(r,l,s,p[ 9]); - BF_ENC(l,r,s,p[10]); - BF_ENC(r,l,s,p[11]); - BF_ENC(l,r,s,p[12]); - BF_ENC(r,l,s,p[13]); - BF_ENC(l,r,s,p[14]); - BF_ENC(r,l,s,p[15]); - BF_ENC(l,r,s,p[16]); + l ^= p[0]; + BF_ENC(r, l,s, p[1]); + BF_ENC(l, r,s, p[2]); + BF_ENC(r, l,s, p[3]); + BF_ENC(l, r,s, p[4]); + BF_ENC(r, l,s, p[5]); + BF_ENC(l, r,s, p[6]); + BF_ENC(r, l,s, p[7]); + BF_ENC(l, r,s, p[8]); + BF_ENC(r, l,s, p[9]); + BF_ENC(l, r,s, p[10]); + BF_ENC(r, l,s, p[11]); + BF_ENC(l, r,s, p[12]); + BF_ENC(r, l,s, p[13]); + BF_ENC(l, r,s, p[14]); + BF_ENC(r, l,s, p[15]); + BF_ENC(l, r,s, p[16]); #if BF_ROUNDS == 20 - BF_ENC(r,l,s,p[17]); - BF_ENC(l,r,s,p[18]); - BF_ENC(r,l,s,p[19]); - BF_ENC(l,r,s,p[20]); + BF_ENC(r, l,s, p[17]); + BF_ENC(l, r,s, p[18]); + BF_ENC(r, l,s, p[19]); + BF_ENC(l, r,s, p[20]); #endif - r^=p[BF_ROUNDS+1]; + r ^= p[BF_ROUNDS + 1]; - data[1]=l&0xffffffffL; - data[0]=r&0xffffffffL; + data[1] = l&0xffffffffL; + data[0] = r&0xffffffffL; #else - BF_LONG l,r,t,*k; + BF_LONG l, r,t, *k; - l=data[0]; - r=data[1]; - k=(BF_LONG*)key; + l = data[0]; + r = data[1]; + k = (BF_LONG*)key; - l^=k[0]; - BF_ENC(r,l,k, 1); - BF_ENC(l,r,k, 2); - BF_ENC(r,l,k, 3); - BF_ENC(l,r,k, 4); - BF_ENC(r,l,k, 5); - BF_ENC(l,r,k, 6); - BF_ENC(r,l,k, 7); - BF_ENC(l,r,k, 8); - BF_ENC(r,l,k, 9); - BF_ENC(l,r,k,10); - BF_ENC(r,l,k,11); - BF_ENC(l,r,k,12); - BF_ENC(r,l,k,13); - BF_ENC(l,r,k,14); - BF_ENC(r,l,k,15); - BF_ENC(l,r,k,16); + l ^= k[0]; + BF_ENC(r, l, k, 1); + BF_ENC(l, r, k, 2); + BF_ENC(r, l, k, 3); + BF_ENC(l, r, k, 4); + BF_ENC(r, l, k, 5); + BF_ENC(l, r, k, 6); + BF_ENC(r, l, k, 7); + BF_ENC(l, r, k, 8); + BF_ENC(r, l, k, 9); + BF_ENC(l, r,k, 10); + BF_ENC(r, l,k, 11); + BF_ENC(l, r,k, 12); + BF_ENC(r, l,k, 13); + BF_ENC(l, r,k, 14); + BF_ENC(r, l,k, 15); + BF_ENC(l, r,k, 16); #if BF_ROUNDS == 20 - BF_ENC(r,l,k,17); - BF_ENC(l,r,k,18); - BF_ENC(r,l,k,19); - BF_ENC(l,r,k,20); + BF_ENC(r, l,k, 17); + BF_ENC(l, r,k, 18); + BF_ENC(r, l,k, 19); + BF_ENC(l, r,k, 20); #endif - r^=k[BF_ROUNDS+1]; + r ^= k[BF_ROUNDS + 1]; - data[1]=l&0xffffffffL; - data[0]=r&0xffffffffL; + data[1] = l&0xffffffffL; + data[0] = r&0xffffffffL; #endif - } +} #ifndef BF_DEFAULT_OPTIONS -void BF_decrypt(BF_LONG *data, const BF_KEY *key) - { +void +BF_decrypt(BF_LONG *data, const BF_KEY *key) +{ #ifndef BF_PTR2 - BF_LONG l,r; - const BF_LONG *p,*s; + BF_LONG l, r; + const BF_LONG *p, *s; - p=key->P; - s= &(key->S[0]); - l=data[0]; - r=data[1]; + p = key->P; + s = &(key->S[0]); + l = data[0]; + r = data[1]; - l^=p[BF_ROUNDS+1]; + l ^= p[BF_ROUNDS + 1]; #if BF_ROUNDS == 20 - BF_ENC(r,l,s,p[20]); - BF_ENC(l,r,s,p[19]); - BF_ENC(r,l,s,p[18]); - BF_ENC(l,r,s,p[17]); + BF_ENC(r, l,s, p[20]); + BF_ENC(l, r,s, p[19]); + BF_ENC(r, l,s, p[18]); + BF_ENC(l, r,s, p[17]); #endif - BF_ENC(r,l,s,p[16]); - BF_ENC(l,r,s,p[15]); - BF_ENC(r,l,s,p[14]); - BF_ENC(l,r,s,p[13]); - BF_ENC(r,l,s,p[12]); - BF_ENC(l,r,s,p[11]); - BF_ENC(r,l,s,p[10]); - BF_ENC(l,r,s,p[ 9]); - BF_ENC(r,l,s,p[ 8]); - BF_ENC(l,r,s,p[ 7]); - BF_ENC(r,l,s,p[ 6]); - BF_ENC(l,r,s,p[ 5]); - BF_ENC(r,l,s,p[ 4]); - BF_ENC(l,r,s,p[ 3]); - BF_ENC(r,l,s,p[ 2]); - BF_ENC(l,r,s,p[ 1]); - r^=p[0]; + BF_ENC(r, l,s, p[16]); + BF_ENC(l, r,s, p[15]); + BF_ENC(r, l,s, p[14]); + BF_ENC(l, r,s, p[13]); + BF_ENC(r, l,s, p[12]); + BF_ENC(l, r,s, p[11]); + BF_ENC(r, l,s, p[10]); + BF_ENC(l, r,s, p[9]); + BF_ENC(r, l,s, p[8]); + BF_ENC(l, r,s, p[7]); + BF_ENC(r, l,s, p[6]); + BF_ENC(l, r,s, p[5]); + BF_ENC(r, l,s, p[4]); + BF_ENC(l, r,s, p[3]); + BF_ENC(r, l,s, p[2]); + BF_ENC(l, r,s, p[1]); + r ^= p[0]; - data[1]=l&0xffffffffL; - data[0]=r&0xffffffffL; + data[1] = l&0xffffffffL; + data[0] = r&0xffffffffL; #else - BF_LONG l,r,t,*k; + BF_LONG l, r,t, *k; - l=data[0]; - r=data[1]; - k=(BF_LONG *)key; + l = data[0]; + r = data[1]; + k = (BF_LONG *)key; - l^=k[BF_ROUNDS+1]; + l ^= k[BF_ROUNDS + 1]; #if BF_ROUNDS == 20 - BF_ENC(r,l,k,20); - BF_ENC(l,r,k,19); - BF_ENC(r,l,k,18); - BF_ENC(l,r,k,17); + BF_ENC(r, l,k, 20); + BF_ENC(l, r,k, 19); + BF_ENC(r, l,k, 18); + BF_ENC(l, r,k, 17); #endif - BF_ENC(r,l,k,16); - BF_ENC(l,r,k,15); - BF_ENC(r,l,k,14); - BF_ENC(l,r,k,13); - BF_ENC(r,l,k,12); - BF_ENC(l,r,k,11); - BF_ENC(r,l,k,10); - BF_ENC(l,r,k, 9); - BF_ENC(r,l,k, 8); - BF_ENC(l,r,k, 7); - BF_ENC(r,l,k, 6); - BF_ENC(l,r,k, 5); - BF_ENC(r,l,k, 4); - BF_ENC(l,r,k, 3); - BF_ENC(r,l,k, 2); - BF_ENC(l,r,k, 1); - r^=k[0]; + BF_ENC(r, l,k, 16); + BF_ENC(l, r,k, 15); + BF_ENC(r, l,k, 14); + BF_ENC(l, r,k, 13); + BF_ENC(r, l,k, 12); + BF_ENC(l, r,k, 11); + BF_ENC(r, l,k, 10); + BF_ENC(l, r, k, 9); + BF_ENC(r, l, k, 8); + BF_ENC(l, r, k, 7); + BF_ENC(r, l, k, 6); + BF_ENC(l, r, k, 5); + BF_ENC(r, l, k, 4); + BF_ENC(l, r, k, 3); + BF_ENC(r, l, k, 2); + BF_ENC(l, r, k, 1); + r ^= k[0]; - data[1]=l&0xffffffffL; - data[0]=r&0xffffffffL; + data[1] = l&0xffffffffL; + data[0] = r&0xffffffffL; #endif - } +} -void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int encrypt) - { - BF_LONG tin0,tin1; - BF_LONG tout0,tout1,xor0,xor1; - long l=length; +void +BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int encrypt) +{ + BF_LONG tin0, tin1; + BF_LONG tout0, tout1, xor0, xor1; + long l = length; BF_LONG tin[2]; - if (encrypt) - { - n2l(ivec,tout0); - n2l(ivec,tout1); - ivec-=8; - for (l-=8; l>=0; l-=8) - { - n2l(in,tin0); - n2l(in,tin1); - tin0^=tout0; - tin1^=tout1; - tin[0]=tin0; - tin[1]=tin1; - BF_encrypt(tin,schedule); - tout0=tin[0]; - tout1=tin[1]; - l2n(tout0,out); - l2n(tout1,out); - } - if (l != -8) - { - n2ln(in,tin0,tin1,l+8); - tin0^=tout0; - tin1^=tout1; - tin[0]=tin0; - tin[1]=tin1; - BF_encrypt(tin,schedule); - tout0=tin[0]; - tout1=tin[1]; - l2n(tout0,out); - l2n(tout1,out); - } - l2n(tout0,ivec); - l2n(tout1,ivec); + if (encrypt) { + n2l(ivec, tout0); + n2l(ivec, tout1); + ivec -= 8; + for (l -= 8; l >= 0; l -= 8) { + n2l(in, tin0); + n2l(in, tin1); + tin0 ^= tout0; + tin1 ^= tout1; + tin[0] = tin0; + tin[1] = tin1; + BF_encrypt(tin, schedule); + tout0 = tin[0]; + tout1 = tin[1]; + l2n(tout0, out); + l2n(tout1, out); + } + if (l != -8) { + n2ln(in, tin0, tin1, l + 8); + tin0 ^= tout0; + tin1 ^= tout1; + tin[0] = tin0; + tin[1] = tin1; + BF_encrypt(tin, schedule); + tout0 = tin[0]; + tout1 = tin[1]; + l2n(tout0, out); + l2n(tout1, out); + } + l2n(tout0, ivec); + l2n(tout1, ivec); + } else { + n2l(ivec, xor0); + n2l(ivec, xor1); + ivec -= 8; + for (l -= 8; l >= 0; l -= 8) { + n2l(in, tin0); + n2l(in, tin1); + tin[0] = tin0; + tin[1] = tin1; + BF_decrypt(tin, schedule); + tout0 = tin[0]^xor0; + tout1 = tin[1]^xor1; + l2n(tout0, out); + l2n(tout1, out); + xor0 = tin0; + xor1 = tin1; } - else - { - n2l(ivec,xor0); - n2l(ivec,xor1); - ivec-=8; - for (l-=8; l>=0; l-=8) - { - n2l(in,tin0); - n2l(in,tin1); - tin[0]=tin0; - tin[1]=tin1; - BF_decrypt(tin,schedule); - tout0=tin[0]^xor0; - tout1=tin[1]^xor1; - l2n(tout0,out); - l2n(tout1,out); - xor0=tin0; - xor1=tin1; - } - if (l != -8) - { - n2l(in,tin0); - n2l(in,tin1); - tin[0]=tin0; - tin[1]=tin1; - BF_decrypt(tin,schedule); - tout0=tin[0]^xor0; - tout1=tin[1]^xor1; - l2nn(tout0,tout1,out,l+8); - xor0=tin0; - xor1=tin1; - } - l2n(xor0,ivec); - l2n(xor1,ivec); + if (l != -8) { + n2l(in, tin0); + n2l(in, tin1); + tin[0] = tin0; + tin[1] = tin1; + BF_decrypt(tin, schedule); + tout0 = tin[0]^xor0; + tout1 = tin[1]^xor1; + l2nn(tout0, tout1, out, l + 8); + xor0 = tin0; + xor1 = tin1; } - tin0=tin1=tout0=tout1=xor0=xor1=0; - tin[0]=tin[1]=0; + l2n(xor0, ivec); + l2n(xor1, ivec); } + tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0; + tin[0] = tin[1] = 0; +} #endif diff --git a/crypto/bf/bf_locl.h b/crypto/bf/bf_local.h similarity index 98% rename from crypto/bf/bf_locl.h rename to crypto/bf/bf_local.h index 0b663622..1cc29525 100644 --- a/crypto/bf/bf_locl.h +++ b/crypto/bf/bf_local.h @@ -1,25 +1,25 @@ -/* $OpenBSD: bf_locl.h,v 1.3 2014/06/12 15:49:28 deraadt Exp $ */ +/* $OpenBSD: bf_local.h,v 1.1 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence diff --git a/crypto/bf/bf_ofb64.c b/crypto/bf/bf_ofb64.c index 9e33162a..8fe24782 100644 --- a/crypto/bf/bf_ofb64.c +++ b/crypto/bf/bf_ofb64.c @@ -1,25 +1,25 @@ -/* $OpenBSD: bf_ofb64.c,v 1.5 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: bf_ofb64.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -57,54 +57,55 @@ */ #include -#include "bf_locl.h" -/* The input and output encrypted as though 64bit ofb mode is being +#include "bf_local.h" + +/* + * The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ -void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int *num) - { - BF_LONG v0,v1,t; +void +BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, + const BF_KEY *schedule, unsigned char *ivec, int *num) +{ + BF_LONG v0, v1, t; int n= *num; - long l=length; + long l = length; unsigned char d[8]; char *dp; BF_LONG ti[2]; unsigned char *iv; - int save=0; + int save = 0; - iv=(unsigned char *)ivec; - n2l(iv,v0); - n2l(iv,v1); - ti[0]=v0; - ti[1]=v1; - dp=(char *)d; - l2n(v0,dp); - l2n(v1,dp); - while (l--) - { - if (n == 0) - { - BF_encrypt((BF_LONG *)ti,schedule); - dp=(char *)d; - t=ti[0]; l2n(t,dp); - t=ti[1]; l2n(t,dp); + iv = (unsigned char *)ivec; + n2l(iv, v0); + n2l(iv, v1); + ti[0] = v0; + ti[1] = v1; + dp = (char *)d; + l2n(v0, dp); + l2n(v1, dp); + while (l--) { + if (n == 0) { + BF_encrypt((BF_LONG *)ti, schedule); + dp = (char *)d; + t = ti[0]; + l2n(t, dp); + t = ti[1]; + l2n(t, dp); save++; - } - *(out++)= *(in++)^d[n]; - n=(n+1)&0x07; - } - if (save) - { - v0=ti[0]; - v1=ti[1]; - iv=(unsigned char *)ivec; - l2n(v0,iv); - l2n(v1,iv); } - t=v0=v1=ti[0]=ti[1]=0; - *num=n; + *(out++)= *(in++)^d[n]; + n = (n + 1)&0x07; } - + if (save) { + v0 = ti[0]; + v1 = ti[1]; + iv = (unsigned char *)ivec; + l2n(v0, iv); + l2n(v1, iv); + } + t = v0 = v1 = ti[0] = ti[1] = 0; + *num = n; +} diff --git a/crypto/bf/bf_pi.h b/crypto/bf/bf_pi.h deleted file mode 100644 index ce4843a6..00000000 --- a/crypto/bf/bf_pi.h +++ /dev/null @@ -1,328 +0,0 @@ -/* $OpenBSD: bf_pi.h,v 1.4 2016/12/21 15:49:29 jsing Exp $ */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -__BEGIN_HIDDEN_DECLS - -static const BF_KEY bf_init= { - { - 0x243f6a88L, 0x85a308d3L, 0x13198a2eL, 0x03707344L, - 0xa4093822L, 0x299f31d0L, 0x082efa98L, 0xec4e6c89L, - 0x452821e6L, 0x38d01377L, 0xbe5466cfL, 0x34e90c6cL, - 0xc0ac29b7L, 0xc97c50ddL, 0x3f84d5b5L, 0xb5470917L, - 0x9216d5d9L, 0x8979fb1b - },{ - 0xd1310ba6L, 0x98dfb5acL, 0x2ffd72dbL, 0xd01adfb7L, - 0xb8e1afedL, 0x6a267e96L, 0xba7c9045L, 0xf12c7f99L, - 0x24a19947L, 0xb3916cf7L, 0x0801f2e2L, 0x858efc16L, - 0x636920d8L, 0x71574e69L, 0xa458fea3L, 0xf4933d7eL, - 0x0d95748fL, 0x728eb658L, 0x718bcd58L, 0x82154aeeL, - 0x7b54a41dL, 0xc25a59b5L, 0x9c30d539L, 0x2af26013L, - 0xc5d1b023L, 0x286085f0L, 0xca417918L, 0xb8db38efL, - 0x8e79dcb0L, 0x603a180eL, 0x6c9e0e8bL, 0xb01e8a3eL, - 0xd71577c1L, 0xbd314b27L, 0x78af2fdaL, 0x55605c60L, - 0xe65525f3L, 0xaa55ab94L, 0x57489862L, 0x63e81440L, - 0x55ca396aL, 0x2aab10b6L, 0xb4cc5c34L, 0x1141e8ceL, - 0xa15486afL, 0x7c72e993L, 0xb3ee1411L, 0x636fbc2aL, - 0x2ba9c55dL, 0x741831f6L, 0xce5c3e16L, 0x9b87931eL, - 0xafd6ba33L, 0x6c24cf5cL, 0x7a325381L, 0x28958677L, - 0x3b8f4898L, 0x6b4bb9afL, 0xc4bfe81bL, 0x66282193L, - 0x61d809ccL, 0xfb21a991L, 0x487cac60L, 0x5dec8032L, - 0xef845d5dL, 0xe98575b1L, 0xdc262302L, 0xeb651b88L, - 0x23893e81L, 0xd396acc5L, 0x0f6d6ff3L, 0x83f44239L, - 0x2e0b4482L, 0xa4842004L, 0x69c8f04aL, 0x9e1f9b5eL, - 0x21c66842L, 0xf6e96c9aL, 0x670c9c61L, 0xabd388f0L, - 0x6a51a0d2L, 0xd8542f68L, 0x960fa728L, 0xab5133a3L, - 0x6eef0b6cL, 0x137a3be4L, 0xba3bf050L, 0x7efb2a98L, - 0xa1f1651dL, 0x39af0176L, 0x66ca593eL, 0x82430e88L, - 0x8cee8619L, 0x456f9fb4L, 0x7d84a5c3L, 0x3b8b5ebeL, - 0xe06f75d8L, 0x85c12073L, 0x401a449fL, 0x56c16aa6L, - 0x4ed3aa62L, 0x363f7706L, 0x1bfedf72L, 0x429b023dL, - 0x37d0d724L, 0xd00a1248L, 0xdb0fead3L, 0x49f1c09bL, - 0x075372c9L, 0x80991b7bL, 0x25d479d8L, 0xf6e8def7L, - 0xe3fe501aL, 0xb6794c3bL, 0x976ce0bdL, 0x04c006baL, - 0xc1a94fb6L, 0x409f60c4L, 0x5e5c9ec2L, 0x196a2463L, - 0x68fb6fafL, 0x3e6c53b5L, 0x1339b2ebL, 0x3b52ec6fL, - 0x6dfc511fL, 0x9b30952cL, 0xcc814544L, 0xaf5ebd09L, - 0xbee3d004L, 0xde334afdL, 0x660f2807L, 0x192e4bb3L, - 0xc0cba857L, 0x45c8740fL, 0xd20b5f39L, 0xb9d3fbdbL, - 0x5579c0bdL, 0x1a60320aL, 0xd6a100c6L, 0x402c7279L, - 0x679f25feL, 0xfb1fa3ccL, 0x8ea5e9f8L, 0xdb3222f8L, - 0x3c7516dfL, 0xfd616b15L, 0x2f501ec8L, 0xad0552abL, - 0x323db5faL, 0xfd238760L, 0x53317b48L, 0x3e00df82L, - 0x9e5c57bbL, 0xca6f8ca0L, 0x1a87562eL, 0xdf1769dbL, - 0xd542a8f6L, 0x287effc3L, 0xac6732c6L, 0x8c4f5573L, - 0x695b27b0L, 0xbbca58c8L, 0xe1ffa35dL, 0xb8f011a0L, - 0x10fa3d98L, 0xfd2183b8L, 0x4afcb56cL, 0x2dd1d35bL, - 0x9a53e479L, 0xb6f84565L, 0xd28e49bcL, 0x4bfb9790L, - 0xe1ddf2daL, 0xa4cb7e33L, 0x62fb1341L, 0xcee4c6e8L, - 0xef20cadaL, 0x36774c01L, 0xd07e9efeL, 0x2bf11fb4L, - 0x95dbda4dL, 0xae909198L, 0xeaad8e71L, 0x6b93d5a0L, - 0xd08ed1d0L, 0xafc725e0L, 0x8e3c5b2fL, 0x8e7594b7L, - 0x8ff6e2fbL, 0xf2122b64L, 0x8888b812L, 0x900df01cL, - 0x4fad5ea0L, 0x688fc31cL, 0xd1cff191L, 0xb3a8c1adL, - 0x2f2f2218L, 0xbe0e1777L, 0xea752dfeL, 0x8b021fa1L, - 0xe5a0cc0fL, 0xb56f74e8L, 0x18acf3d6L, 0xce89e299L, - 0xb4a84fe0L, 0xfd13e0b7L, 0x7cc43b81L, 0xd2ada8d9L, - 0x165fa266L, 0x80957705L, 0x93cc7314L, 0x211a1477L, - 0xe6ad2065L, 0x77b5fa86L, 0xc75442f5L, 0xfb9d35cfL, - 0xebcdaf0cL, 0x7b3e89a0L, 0xd6411bd3L, 0xae1e7e49L, - 0x00250e2dL, 0x2071b35eL, 0x226800bbL, 0x57b8e0afL, - 0x2464369bL, 0xf009b91eL, 0x5563911dL, 0x59dfa6aaL, - 0x78c14389L, 0xd95a537fL, 0x207d5ba2L, 0x02e5b9c5L, - 0x83260376L, 0x6295cfa9L, 0x11c81968L, 0x4e734a41L, - 0xb3472dcaL, 0x7b14a94aL, 0x1b510052L, 0x9a532915L, - 0xd60f573fL, 0xbc9bc6e4L, 0x2b60a476L, 0x81e67400L, - 0x08ba6fb5L, 0x571be91fL, 0xf296ec6bL, 0x2a0dd915L, - 0xb6636521L, 0xe7b9f9b6L, 0xff34052eL, 0xc5855664L, - 0x53b02d5dL, 0xa99f8fa1L, 0x08ba4799L, 0x6e85076aL, - 0x4b7a70e9L, 0xb5b32944L, 0xdb75092eL, 0xc4192623L, - 0xad6ea6b0L, 0x49a7df7dL, 0x9cee60b8L, 0x8fedb266L, - 0xecaa8c71L, 0x699a17ffL, 0x5664526cL, 0xc2b19ee1L, - 0x193602a5L, 0x75094c29L, 0xa0591340L, 0xe4183a3eL, - 0x3f54989aL, 0x5b429d65L, 0x6b8fe4d6L, 0x99f73fd6L, - 0xa1d29c07L, 0xefe830f5L, 0x4d2d38e6L, 0xf0255dc1L, - 0x4cdd2086L, 0x8470eb26L, 0x6382e9c6L, 0x021ecc5eL, - 0x09686b3fL, 0x3ebaefc9L, 0x3c971814L, 0x6b6a70a1L, - 0x687f3584L, 0x52a0e286L, 0xb79c5305L, 0xaa500737L, - 0x3e07841cL, 0x7fdeae5cL, 0x8e7d44ecL, 0x5716f2b8L, - 0xb03ada37L, 0xf0500c0dL, 0xf01c1f04L, 0x0200b3ffL, - 0xae0cf51aL, 0x3cb574b2L, 0x25837a58L, 0xdc0921bdL, - 0xd19113f9L, 0x7ca92ff6L, 0x94324773L, 0x22f54701L, - 0x3ae5e581L, 0x37c2dadcL, 0xc8b57634L, 0x9af3dda7L, - 0xa9446146L, 0x0fd0030eL, 0xecc8c73eL, 0xa4751e41L, - 0xe238cd99L, 0x3bea0e2fL, 0x3280bba1L, 0x183eb331L, - 0x4e548b38L, 0x4f6db908L, 0x6f420d03L, 0xf60a04bfL, - 0x2cb81290L, 0x24977c79L, 0x5679b072L, 0xbcaf89afL, - 0xde9a771fL, 0xd9930810L, 0xb38bae12L, 0xdccf3f2eL, - 0x5512721fL, 0x2e6b7124L, 0x501adde6L, 0x9f84cd87L, - 0x7a584718L, 0x7408da17L, 0xbc9f9abcL, 0xe94b7d8cL, - 0xec7aec3aL, 0xdb851dfaL, 0x63094366L, 0xc464c3d2L, - 0xef1c1847L, 0x3215d908L, 0xdd433b37L, 0x24c2ba16L, - 0x12a14d43L, 0x2a65c451L, 0x50940002L, 0x133ae4ddL, - 0x71dff89eL, 0x10314e55L, 0x81ac77d6L, 0x5f11199bL, - 0x043556f1L, 0xd7a3c76bL, 0x3c11183bL, 0x5924a509L, - 0xf28fe6edL, 0x97f1fbfaL, 0x9ebabf2cL, 0x1e153c6eL, - 0x86e34570L, 0xeae96fb1L, 0x860e5e0aL, 0x5a3e2ab3L, - 0x771fe71cL, 0x4e3d06faL, 0x2965dcb9L, 0x99e71d0fL, - 0x803e89d6L, 0x5266c825L, 0x2e4cc978L, 0x9c10b36aL, - 0xc6150ebaL, 0x94e2ea78L, 0xa5fc3c53L, 0x1e0a2df4L, - 0xf2f74ea7L, 0x361d2b3dL, 0x1939260fL, 0x19c27960L, - 0x5223a708L, 0xf71312b6L, 0xebadfe6eL, 0xeac31f66L, - 0xe3bc4595L, 0xa67bc883L, 0xb17f37d1L, 0x018cff28L, - 0xc332ddefL, 0xbe6c5aa5L, 0x65582185L, 0x68ab9802L, - 0xeecea50fL, 0xdb2f953bL, 0x2aef7dadL, 0x5b6e2f84L, - 0x1521b628L, 0x29076170L, 0xecdd4775L, 0x619f1510L, - 0x13cca830L, 0xeb61bd96L, 0x0334fe1eL, 0xaa0363cfL, - 0xb5735c90L, 0x4c70a239L, 0xd59e9e0bL, 0xcbaade14L, - 0xeecc86bcL, 0x60622ca7L, 0x9cab5cabL, 0xb2f3846eL, - 0x648b1eafL, 0x19bdf0caL, 0xa02369b9L, 0x655abb50L, - 0x40685a32L, 0x3c2ab4b3L, 0x319ee9d5L, 0xc021b8f7L, - 0x9b540b19L, 0x875fa099L, 0x95f7997eL, 0x623d7da8L, - 0xf837889aL, 0x97e32d77L, 0x11ed935fL, 0x16681281L, - 0x0e358829L, 0xc7e61fd6L, 0x96dedfa1L, 0x7858ba99L, - 0x57f584a5L, 0x1b227263L, 0x9b83c3ffL, 0x1ac24696L, - 0xcdb30aebL, 0x532e3054L, 0x8fd948e4L, 0x6dbc3128L, - 0x58ebf2efL, 0x34c6ffeaL, 0xfe28ed61L, 0xee7c3c73L, - 0x5d4a14d9L, 0xe864b7e3L, 0x42105d14L, 0x203e13e0L, - 0x45eee2b6L, 0xa3aaabeaL, 0xdb6c4f15L, 0xfacb4fd0L, - 0xc742f442L, 0xef6abbb5L, 0x654f3b1dL, 0x41cd2105L, - 0xd81e799eL, 0x86854dc7L, 0xe44b476aL, 0x3d816250L, - 0xcf62a1f2L, 0x5b8d2646L, 0xfc8883a0L, 0xc1c7b6a3L, - 0x7f1524c3L, 0x69cb7492L, 0x47848a0bL, 0x5692b285L, - 0x095bbf00L, 0xad19489dL, 0x1462b174L, 0x23820e00L, - 0x58428d2aL, 0x0c55f5eaL, 0x1dadf43eL, 0x233f7061L, - 0x3372f092L, 0x8d937e41L, 0xd65fecf1L, 0x6c223bdbL, - 0x7cde3759L, 0xcbee7460L, 0x4085f2a7L, 0xce77326eL, - 0xa6078084L, 0x19f8509eL, 0xe8efd855L, 0x61d99735L, - 0xa969a7aaL, 0xc50c06c2L, 0x5a04abfcL, 0x800bcadcL, - 0x9e447a2eL, 0xc3453484L, 0xfdd56705L, 0x0e1e9ec9L, - 0xdb73dbd3L, 0x105588cdL, 0x675fda79L, 0xe3674340L, - 0xc5c43465L, 0x713e38d8L, 0x3d28f89eL, 0xf16dff20L, - 0x153e21e7L, 0x8fb03d4aL, 0xe6e39f2bL, 0xdb83adf7L, - 0xe93d5a68L, 0x948140f7L, 0xf64c261cL, 0x94692934L, - 0x411520f7L, 0x7602d4f7L, 0xbcf46b2eL, 0xd4a20068L, - 0xd4082471L, 0x3320f46aL, 0x43b7d4b7L, 0x500061afL, - 0x1e39f62eL, 0x97244546L, 0x14214f74L, 0xbf8b8840L, - 0x4d95fc1dL, 0x96b591afL, 0x70f4ddd3L, 0x66a02f45L, - 0xbfbc09ecL, 0x03bd9785L, 0x7fac6dd0L, 0x31cb8504L, - 0x96eb27b3L, 0x55fd3941L, 0xda2547e6L, 0xabca0a9aL, - 0x28507825L, 0x530429f4L, 0x0a2c86daL, 0xe9b66dfbL, - 0x68dc1462L, 0xd7486900L, 0x680ec0a4L, 0x27a18deeL, - 0x4f3ffea2L, 0xe887ad8cL, 0xb58ce006L, 0x7af4d6b6L, - 0xaace1e7cL, 0xd3375fecL, 0xce78a399L, 0x406b2a42L, - 0x20fe9e35L, 0xd9f385b9L, 0xee39d7abL, 0x3b124e8bL, - 0x1dc9faf7L, 0x4b6d1856L, 0x26a36631L, 0xeae397b2L, - 0x3a6efa74L, 0xdd5b4332L, 0x6841e7f7L, 0xca7820fbL, - 0xfb0af54eL, 0xd8feb397L, 0x454056acL, 0xba489527L, - 0x55533a3aL, 0x20838d87L, 0xfe6ba9b7L, 0xd096954bL, - 0x55a867bcL, 0xa1159a58L, 0xcca92963L, 0x99e1db33L, - 0xa62a4a56L, 0x3f3125f9L, 0x5ef47e1cL, 0x9029317cL, - 0xfdf8e802L, 0x04272f70L, 0x80bb155cL, 0x05282ce3L, - 0x95c11548L, 0xe4c66d22L, 0x48c1133fL, 0xc70f86dcL, - 0x07f9c9eeL, 0x41041f0fL, 0x404779a4L, 0x5d886e17L, - 0x325f51ebL, 0xd59bc0d1L, 0xf2bcc18fL, 0x41113564L, - 0x257b7834L, 0x602a9c60L, 0xdff8e8a3L, 0x1f636c1bL, - 0x0e12b4c2L, 0x02e1329eL, 0xaf664fd1L, 0xcad18115L, - 0x6b2395e0L, 0x333e92e1L, 0x3b240b62L, 0xeebeb922L, - 0x85b2a20eL, 0xe6ba0d99L, 0xde720c8cL, 0x2da2f728L, - 0xd0127845L, 0x95b794fdL, 0x647d0862L, 0xe7ccf5f0L, - 0x5449a36fL, 0x877d48faL, 0xc39dfd27L, 0xf33e8d1eL, - 0x0a476341L, 0x992eff74L, 0x3a6f6eabL, 0xf4f8fd37L, - 0xa812dc60L, 0xa1ebddf8L, 0x991be14cL, 0xdb6e6b0dL, - 0xc67b5510L, 0x6d672c37L, 0x2765d43bL, 0xdcd0e804L, - 0xf1290dc7L, 0xcc00ffa3L, 0xb5390f92L, 0x690fed0bL, - 0x667b9ffbL, 0xcedb7d9cL, 0xa091cf0bL, 0xd9155ea3L, - 0xbb132f88L, 0x515bad24L, 0x7b9479bfL, 0x763bd6ebL, - 0x37392eb3L, 0xcc115979L, 0x8026e297L, 0xf42e312dL, - 0x6842ada7L, 0xc66a2b3bL, 0x12754cccL, 0x782ef11cL, - 0x6a124237L, 0xb79251e7L, 0x06a1bbe6L, 0x4bfb6350L, - 0x1a6b1018L, 0x11caedfaL, 0x3d25bdd8L, 0xe2e1c3c9L, - 0x44421659L, 0x0a121386L, 0xd90cec6eL, 0xd5abea2aL, - 0x64af674eL, 0xda86a85fL, 0xbebfe988L, 0x64e4c3feL, - 0x9dbc8057L, 0xf0f7c086L, 0x60787bf8L, 0x6003604dL, - 0xd1fd8346L, 0xf6381fb0L, 0x7745ae04L, 0xd736fcccL, - 0x83426b33L, 0xf01eab71L, 0xb0804187L, 0x3c005e5fL, - 0x77a057beL, 0xbde8ae24L, 0x55464299L, 0xbf582e61L, - 0x4e58f48fL, 0xf2ddfda2L, 0xf474ef38L, 0x8789bdc2L, - 0x5366f9c3L, 0xc8b38e74L, 0xb475f255L, 0x46fcd9b9L, - 0x7aeb2661L, 0x8b1ddf84L, 0x846a0e79L, 0x915f95e2L, - 0x466e598eL, 0x20b45770L, 0x8cd55591L, 0xc902de4cL, - 0xb90bace1L, 0xbb8205d0L, 0x11a86248L, 0x7574a99eL, - 0xb77f19b6L, 0xe0a9dc09L, 0x662d09a1L, 0xc4324633L, - 0xe85a1f02L, 0x09f0be8cL, 0x4a99a025L, 0x1d6efe10L, - 0x1ab93d1dL, 0x0ba5a4dfL, 0xa186f20fL, 0x2868f169L, - 0xdcb7da83L, 0x573906feL, 0xa1e2ce9bL, 0x4fcd7f52L, - 0x50115e01L, 0xa70683faL, 0xa002b5c4L, 0x0de6d027L, - 0x9af88c27L, 0x773f8641L, 0xc3604c06L, 0x61a806b5L, - 0xf0177a28L, 0xc0f586e0L, 0x006058aaL, 0x30dc7d62L, - 0x11e69ed7L, 0x2338ea63L, 0x53c2dd94L, 0xc2c21634L, - 0xbbcbee56L, 0x90bcb6deL, 0xebfc7da1L, 0xce591d76L, - 0x6f05e409L, 0x4b7c0188L, 0x39720a3dL, 0x7c927c24L, - 0x86e3725fL, 0x724d9db9L, 0x1ac15bb4L, 0xd39eb8fcL, - 0xed545578L, 0x08fca5b5L, 0xd83d7cd3L, 0x4dad0fc4L, - 0x1e50ef5eL, 0xb161e6f8L, 0xa28514d9L, 0x6c51133cL, - 0x6fd5c7e7L, 0x56e14ec4L, 0x362abfceL, 0xddc6c837L, - 0xd79a3234L, 0x92638212L, 0x670efa8eL, 0x406000e0L, - 0x3a39ce37L, 0xd3faf5cfL, 0xabc27737L, 0x5ac52d1bL, - 0x5cb0679eL, 0x4fa33742L, 0xd3822740L, 0x99bc9bbeL, - 0xd5118e9dL, 0xbf0f7315L, 0xd62d1c7eL, 0xc700c47bL, - 0xb78c1b6bL, 0x21a19045L, 0xb26eb1beL, 0x6a366eb4L, - 0x5748ab2fL, 0xbc946e79L, 0xc6a376d2L, 0x6549c2c8L, - 0x530ff8eeL, 0x468dde7dL, 0xd5730a1dL, 0x4cd04dc6L, - 0x2939bbdbL, 0xa9ba4650L, 0xac9526e8L, 0xbe5ee304L, - 0xa1fad5f0L, 0x6a2d519aL, 0x63ef8ce2L, 0x9a86ee22L, - 0xc089c2b8L, 0x43242ef6L, 0xa51e03aaL, 0x9cf2d0a4L, - 0x83c061baL, 0x9be96a4dL, 0x8fe51550L, 0xba645bd6L, - 0x2826a2f9L, 0xa73a3ae1L, 0x4ba99586L, 0xef5562e9L, - 0xc72fefd3L, 0xf752f7daL, 0x3f046f69L, 0x77fa0a59L, - 0x80e4a915L, 0x87b08601L, 0x9b09e6adL, 0x3b3ee593L, - 0xe990fd5aL, 0x9e34d797L, 0x2cf0b7d9L, 0x022b8b51L, - 0x96d5ac3aL, 0x017da67dL, 0xd1cf3ed6L, 0x7c7d2d28L, - 0x1f9f25cfL, 0xadf2b89bL, 0x5ad6b472L, 0x5a88f54cL, - 0xe029ac71L, 0xe019a5e6L, 0x47b0acfdL, 0xed93fa9bL, - 0xe8d3c48dL, 0x283b57ccL, 0xf8d56629L, 0x79132e28L, - 0x785f0191L, 0xed756055L, 0xf7960e44L, 0xe3d35e8cL, - 0x15056dd4L, 0x88f46dbaL, 0x03a16125L, 0x0564f0bdL, - 0xc3eb9e15L, 0x3c9057a2L, 0x97271aecL, 0xa93a072aL, - 0x1b3f6d9bL, 0x1e6321f5L, 0xf59c66fbL, 0x26dcf319L, - 0x7533d928L, 0xb155fdf5L, 0x03563482L, 0x8aba3cbbL, - 0x28517711L, 0xc20ad9f8L, 0xabcc5167L, 0xccad925fL, - 0x4de81751L, 0x3830dc8eL, 0x379d5862L, 0x9320f991L, - 0xea7a90c2L, 0xfb3e7bceL, 0x5121ce64L, 0x774fbe32L, - 0xa8b6e37eL, 0xc3293d46L, 0x48de5369L, 0x6413e680L, - 0xa2ae0810L, 0xdd6db224L, 0x69852dfdL, 0x09072166L, - 0xb39a460aL, 0x6445c0ddL, 0x586cdecfL, 0x1c20c8aeL, - 0x5bbef7ddL, 0x1b588d40L, 0xccd2017fL, 0x6bb4e3bbL, - 0xdda26a7eL, 0x3a59ff45L, 0x3e350a44L, 0xbcb4cdd5L, - 0x72eacea8L, 0xfa6484bbL, 0x8d6612aeL, 0xbf3c6f47L, - 0xd29be463L, 0x542f5d9eL, 0xaec2771bL, 0xf64e6370L, - 0x740e0d8dL, 0xe75b1357L, 0xf8721671L, 0xaf537d5dL, - 0x4040cb08L, 0x4eb4e2ccL, 0x34d2466aL, 0x0115af84L, - 0xe1b00428L, 0x95983a1dL, 0x06b89fb4L, 0xce6ea048L, - 0x6f3f3b82L, 0x3520ab82L, 0x011a1d4bL, 0x277227f8L, - 0x611560b1L, 0xe7933fdcL, 0xbb3a792bL, 0x344525bdL, - 0xa08839e1L, 0x51ce794bL, 0x2f32c9b7L, 0xa01fbac9L, - 0xe01cc87eL, 0xbcc7d1f6L, 0xcf0111c3L, 0xa1e8aac7L, - 0x1a908749L, 0xd44fbd9aL, 0xd0dadecbL, 0xd50ada38L, - 0x0339c32aL, 0xc6913667L, 0x8df9317cL, 0xe0b12b4fL, - 0xf79e59b7L, 0x43f5bb3aL, 0xf2d519ffL, 0x27d9459cL, - 0xbf97222cL, 0x15e6fc2aL, 0x0f91fc71L, 0x9b941525L, - 0xfae59361L, 0xceb69cebL, 0xc2a86459L, 0x12baa8d1L, - 0xb6c1075eL, 0xe3056a0cL, 0x10d25065L, 0xcb03a442L, - 0xe0ec6e0eL, 0x1698db3bL, 0x4c98a0beL, 0x3278e964L, - 0x9f1f9532L, 0xe0d392dfL, 0xd3a0342bL, 0x8971f21eL, - 0x1b0a7441L, 0x4ba3348cL, 0xc5be7120L, 0xc37632d8L, - 0xdf359f8dL, 0x9b992f2eL, 0xe60b6f47L, 0x0fe3f11dL, - 0xe54cda54L, 0x1edad891L, 0xce6279cfL, 0xcd3e7e6fL, - 0x1618b166L, 0xfd2c1d05L, 0x848fd2c5L, 0xf6fb2299L, - 0xf523f357L, 0xa6327623L, 0x93a83531L, 0x56cccd02L, - 0xacf08162L, 0x5a75ebb5L, 0x6e163697L, 0x88d273ccL, - 0xde966292L, 0x81b949d0L, 0x4c50901bL, 0x71c65614L, - 0xe6c6c7bdL, 0x327a140aL, 0x45e1d006L, 0xc3f27b9aL, - 0xc9aa53fdL, 0x62a80f00L, 0xbb25bfe2L, 0x35bdd2f6L, - 0x71126905L, 0xb2040222L, 0xb6cbcf7cL, 0xcd769c2bL, - 0x53113ec0L, 0x1640e3d3L, 0x38abbd60L, 0x2547adf0L, - 0xba38209cL, 0xf746ce76L, 0x77afa1c5L, 0x20756060L, - 0x85cbfe4eL, 0x8ae88dd8L, 0x7aaaf9b0L, 0x4cf9aa7eL, - 0x1948c25cL, 0x02fb8a8cL, 0x01c36ae4L, 0xd6ebe1f9L, - 0x90d4f869L, 0xa65cdea0L, 0x3f09252dL, 0xc208e69fL, - 0xb74e6132L, 0xce77e25bL, 0x578fdfe3L, 0x3ac372e6L, - } - }; - -__END_HIDDEN_DECLS diff --git a/crypto/bf/bf_skey.c b/crypto/bf/bf_skey.c index 8191d17d..cc31034f 100644 --- a/crypto/bf/bf_skey.c +++ b/crypto/bf/bf_skey.c @@ -1,25 +1,25 @@ -/* $OpenBSD: bf_skey.c,v 1.12 2014/06/12 15:49:28 deraadt Exp $ */ +/* $OpenBSD: bf_skey.c,v 1.17 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -58,60 +58,330 @@ #include #include + #include #include -#include "bf_locl.h" -#include "bf_pi.h" -void BF_set_key(BF_KEY *key, int len, const unsigned char *data) - { - int i; - BF_LONG *p,ri,in[2]; - const unsigned char *d,*end; +#include "bf_local.h" +static const BF_KEY bf_init = { + .P = { + 0x243f6a88L, 0x85a308d3L, 0x13198a2eL, 0x03707344L, + 0xa4093822L, 0x299f31d0L, 0x082efa98L, 0xec4e6c89L, + 0x452821e6L, 0x38d01377L, 0xbe5466cfL, 0x34e90c6cL, + 0xc0ac29b7L, 0xc97c50ddL, 0x3f84d5b5L, 0xb5470917L, + 0x9216d5d9L, 0x8979fb1b + }, + .S = { + 0xd1310ba6L, 0x98dfb5acL, 0x2ffd72dbL, 0xd01adfb7L, + 0xb8e1afedL, 0x6a267e96L, 0xba7c9045L, 0xf12c7f99L, + 0x24a19947L, 0xb3916cf7L, 0x0801f2e2L, 0x858efc16L, + 0x636920d8L, 0x71574e69L, 0xa458fea3L, 0xf4933d7eL, + 0x0d95748fL, 0x728eb658L, 0x718bcd58L, 0x82154aeeL, + 0x7b54a41dL, 0xc25a59b5L, 0x9c30d539L, 0x2af26013L, + 0xc5d1b023L, 0x286085f0L, 0xca417918L, 0xb8db38efL, + 0x8e79dcb0L, 0x603a180eL, 0x6c9e0e8bL, 0xb01e8a3eL, + 0xd71577c1L, 0xbd314b27L, 0x78af2fdaL, 0x55605c60L, + 0xe65525f3L, 0xaa55ab94L, 0x57489862L, 0x63e81440L, + 0x55ca396aL, 0x2aab10b6L, 0xb4cc5c34L, 0x1141e8ceL, + 0xa15486afL, 0x7c72e993L, 0xb3ee1411L, 0x636fbc2aL, + 0x2ba9c55dL, 0x741831f6L, 0xce5c3e16L, 0x9b87931eL, + 0xafd6ba33L, 0x6c24cf5cL, 0x7a325381L, 0x28958677L, + 0x3b8f4898L, 0x6b4bb9afL, 0xc4bfe81bL, 0x66282193L, + 0x61d809ccL, 0xfb21a991L, 0x487cac60L, 0x5dec8032L, + 0xef845d5dL, 0xe98575b1L, 0xdc262302L, 0xeb651b88L, + 0x23893e81L, 0xd396acc5L, 0x0f6d6ff3L, 0x83f44239L, + 0x2e0b4482L, 0xa4842004L, 0x69c8f04aL, 0x9e1f9b5eL, + 0x21c66842L, 0xf6e96c9aL, 0x670c9c61L, 0xabd388f0L, + 0x6a51a0d2L, 0xd8542f68L, 0x960fa728L, 0xab5133a3L, + 0x6eef0b6cL, 0x137a3be4L, 0xba3bf050L, 0x7efb2a98L, + 0xa1f1651dL, 0x39af0176L, 0x66ca593eL, 0x82430e88L, + 0x8cee8619L, 0x456f9fb4L, 0x7d84a5c3L, 0x3b8b5ebeL, + 0xe06f75d8L, 0x85c12073L, 0x401a449fL, 0x56c16aa6L, + 0x4ed3aa62L, 0x363f7706L, 0x1bfedf72L, 0x429b023dL, + 0x37d0d724L, 0xd00a1248L, 0xdb0fead3L, 0x49f1c09bL, + 0x075372c9L, 0x80991b7bL, 0x25d479d8L, 0xf6e8def7L, + 0xe3fe501aL, 0xb6794c3bL, 0x976ce0bdL, 0x04c006baL, + 0xc1a94fb6L, 0x409f60c4L, 0x5e5c9ec2L, 0x196a2463L, + 0x68fb6fafL, 0x3e6c53b5L, 0x1339b2ebL, 0x3b52ec6fL, + 0x6dfc511fL, 0x9b30952cL, 0xcc814544L, 0xaf5ebd09L, + 0xbee3d004L, 0xde334afdL, 0x660f2807L, 0x192e4bb3L, + 0xc0cba857L, 0x45c8740fL, 0xd20b5f39L, 0xb9d3fbdbL, + 0x5579c0bdL, 0x1a60320aL, 0xd6a100c6L, 0x402c7279L, + 0x679f25feL, 0xfb1fa3ccL, 0x8ea5e9f8L, 0xdb3222f8L, + 0x3c7516dfL, 0xfd616b15L, 0x2f501ec8L, 0xad0552abL, + 0x323db5faL, 0xfd238760L, 0x53317b48L, 0x3e00df82L, + 0x9e5c57bbL, 0xca6f8ca0L, 0x1a87562eL, 0xdf1769dbL, + 0xd542a8f6L, 0x287effc3L, 0xac6732c6L, 0x8c4f5573L, + 0x695b27b0L, 0xbbca58c8L, 0xe1ffa35dL, 0xb8f011a0L, + 0x10fa3d98L, 0xfd2183b8L, 0x4afcb56cL, 0x2dd1d35bL, + 0x9a53e479L, 0xb6f84565L, 0xd28e49bcL, 0x4bfb9790L, + 0xe1ddf2daL, 0xa4cb7e33L, 0x62fb1341L, 0xcee4c6e8L, + 0xef20cadaL, 0x36774c01L, 0xd07e9efeL, 0x2bf11fb4L, + 0x95dbda4dL, 0xae909198L, 0xeaad8e71L, 0x6b93d5a0L, + 0xd08ed1d0L, 0xafc725e0L, 0x8e3c5b2fL, 0x8e7594b7L, + 0x8ff6e2fbL, 0xf2122b64L, 0x8888b812L, 0x900df01cL, + 0x4fad5ea0L, 0x688fc31cL, 0xd1cff191L, 0xb3a8c1adL, + 0x2f2f2218L, 0xbe0e1777L, 0xea752dfeL, 0x8b021fa1L, + 0xe5a0cc0fL, 0xb56f74e8L, 0x18acf3d6L, 0xce89e299L, + 0xb4a84fe0L, 0xfd13e0b7L, 0x7cc43b81L, 0xd2ada8d9L, + 0x165fa266L, 0x80957705L, 0x93cc7314L, 0x211a1477L, + 0xe6ad2065L, 0x77b5fa86L, 0xc75442f5L, 0xfb9d35cfL, + 0xebcdaf0cL, 0x7b3e89a0L, 0xd6411bd3L, 0xae1e7e49L, + 0x00250e2dL, 0x2071b35eL, 0x226800bbL, 0x57b8e0afL, + 0x2464369bL, 0xf009b91eL, 0x5563911dL, 0x59dfa6aaL, + 0x78c14389L, 0xd95a537fL, 0x207d5ba2L, 0x02e5b9c5L, + 0x83260376L, 0x6295cfa9L, 0x11c81968L, 0x4e734a41L, + 0xb3472dcaL, 0x7b14a94aL, 0x1b510052L, 0x9a532915L, + 0xd60f573fL, 0xbc9bc6e4L, 0x2b60a476L, 0x81e67400L, + 0x08ba6fb5L, 0x571be91fL, 0xf296ec6bL, 0x2a0dd915L, + 0xb6636521L, 0xe7b9f9b6L, 0xff34052eL, 0xc5855664L, + 0x53b02d5dL, 0xa99f8fa1L, 0x08ba4799L, 0x6e85076aL, + 0x4b7a70e9L, 0xb5b32944L, 0xdb75092eL, 0xc4192623L, + 0xad6ea6b0L, 0x49a7df7dL, 0x9cee60b8L, 0x8fedb266L, + 0xecaa8c71L, 0x699a17ffL, 0x5664526cL, 0xc2b19ee1L, + 0x193602a5L, 0x75094c29L, 0xa0591340L, 0xe4183a3eL, + 0x3f54989aL, 0x5b429d65L, 0x6b8fe4d6L, 0x99f73fd6L, + 0xa1d29c07L, 0xefe830f5L, 0x4d2d38e6L, 0xf0255dc1L, + 0x4cdd2086L, 0x8470eb26L, 0x6382e9c6L, 0x021ecc5eL, + 0x09686b3fL, 0x3ebaefc9L, 0x3c971814L, 0x6b6a70a1L, + 0x687f3584L, 0x52a0e286L, 0xb79c5305L, 0xaa500737L, + 0x3e07841cL, 0x7fdeae5cL, 0x8e7d44ecL, 0x5716f2b8L, + 0xb03ada37L, 0xf0500c0dL, 0xf01c1f04L, 0x0200b3ffL, + 0xae0cf51aL, 0x3cb574b2L, 0x25837a58L, 0xdc0921bdL, + 0xd19113f9L, 0x7ca92ff6L, 0x94324773L, 0x22f54701L, + 0x3ae5e581L, 0x37c2dadcL, 0xc8b57634L, 0x9af3dda7L, + 0xa9446146L, 0x0fd0030eL, 0xecc8c73eL, 0xa4751e41L, + 0xe238cd99L, 0x3bea0e2fL, 0x3280bba1L, 0x183eb331L, + 0x4e548b38L, 0x4f6db908L, 0x6f420d03L, 0xf60a04bfL, + 0x2cb81290L, 0x24977c79L, 0x5679b072L, 0xbcaf89afL, + 0xde9a771fL, 0xd9930810L, 0xb38bae12L, 0xdccf3f2eL, + 0x5512721fL, 0x2e6b7124L, 0x501adde6L, 0x9f84cd87L, + 0x7a584718L, 0x7408da17L, 0xbc9f9abcL, 0xe94b7d8cL, + 0xec7aec3aL, 0xdb851dfaL, 0x63094366L, 0xc464c3d2L, + 0xef1c1847L, 0x3215d908L, 0xdd433b37L, 0x24c2ba16L, + 0x12a14d43L, 0x2a65c451L, 0x50940002L, 0x133ae4ddL, + 0x71dff89eL, 0x10314e55L, 0x81ac77d6L, 0x5f11199bL, + 0x043556f1L, 0xd7a3c76bL, 0x3c11183bL, 0x5924a509L, + 0xf28fe6edL, 0x97f1fbfaL, 0x9ebabf2cL, 0x1e153c6eL, + 0x86e34570L, 0xeae96fb1L, 0x860e5e0aL, 0x5a3e2ab3L, + 0x771fe71cL, 0x4e3d06faL, 0x2965dcb9L, 0x99e71d0fL, + 0x803e89d6L, 0x5266c825L, 0x2e4cc978L, 0x9c10b36aL, + 0xc6150ebaL, 0x94e2ea78L, 0xa5fc3c53L, 0x1e0a2df4L, + 0xf2f74ea7L, 0x361d2b3dL, 0x1939260fL, 0x19c27960L, + 0x5223a708L, 0xf71312b6L, 0xebadfe6eL, 0xeac31f66L, + 0xe3bc4595L, 0xa67bc883L, 0xb17f37d1L, 0x018cff28L, + 0xc332ddefL, 0xbe6c5aa5L, 0x65582185L, 0x68ab9802L, + 0xeecea50fL, 0xdb2f953bL, 0x2aef7dadL, 0x5b6e2f84L, + 0x1521b628L, 0x29076170L, 0xecdd4775L, 0x619f1510L, + 0x13cca830L, 0xeb61bd96L, 0x0334fe1eL, 0xaa0363cfL, + 0xb5735c90L, 0x4c70a239L, 0xd59e9e0bL, 0xcbaade14L, + 0xeecc86bcL, 0x60622ca7L, 0x9cab5cabL, 0xb2f3846eL, + 0x648b1eafL, 0x19bdf0caL, 0xa02369b9L, 0x655abb50L, + 0x40685a32L, 0x3c2ab4b3L, 0x319ee9d5L, 0xc021b8f7L, + 0x9b540b19L, 0x875fa099L, 0x95f7997eL, 0x623d7da8L, + 0xf837889aL, 0x97e32d77L, 0x11ed935fL, 0x16681281L, + 0x0e358829L, 0xc7e61fd6L, 0x96dedfa1L, 0x7858ba99L, + 0x57f584a5L, 0x1b227263L, 0x9b83c3ffL, 0x1ac24696L, + 0xcdb30aebL, 0x532e3054L, 0x8fd948e4L, 0x6dbc3128L, + 0x58ebf2efL, 0x34c6ffeaL, 0xfe28ed61L, 0xee7c3c73L, + 0x5d4a14d9L, 0xe864b7e3L, 0x42105d14L, 0x203e13e0L, + 0x45eee2b6L, 0xa3aaabeaL, 0xdb6c4f15L, 0xfacb4fd0L, + 0xc742f442L, 0xef6abbb5L, 0x654f3b1dL, 0x41cd2105L, + 0xd81e799eL, 0x86854dc7L, 0xe44b476aL, 0x3d816250L, + 0xcf62a1f2L, 0x5b8d2646L, 0xfc8883a0L, 0xc1c7b6a3L, + 0x7f1524c3L, 0x69cb7492L, 0x47848a0bL, 0x5692b285L, + 0x095bbf00L, 0xad19489dL, 0x1462b174L, 0x23820e00L, + 0x58428d2aL, 0x0c55f5eaL, 0x1dadf43eL, 0x233f7061L, + 0x3372f092L, 0x8d937e41L, 0xd65fecf1L, 0x6c223bdbL, + 0x7cde3759L, 0xcbee7460L, 0x4085f2a7L, 0xce77326eL, + 0xa6078084L, 0x19f8509eL, 0xe8efd855L, 0x61d99735L, + 0xa969a7aaL, 0xc50c06c2L, 0x5a04abfcL, 0x800bcadcL, + 0x9e447a2eL, 0xc3453484L, 0xfdd56705L, 0x0e1e9ec9L, + 0xdb73dbd3L, 0x105588cdL, 0x675fda79L, 0xe3674340L, + 0xc5c43465L, 0x713e38d8L, 0x3d28f89eL, 0xf16dff20L, + 0x153e21e7L, 0x8fb03d4aL, 0xe6e39f2bL, 0xdb83adf7L, + 0xe93d5a68L, 0x948140f7L, 0xf64c261cL, 0x94692934L, + 0x411520f7L, 0x7602d4f7L, 0xbcf46b2eL, 0xd4a20068L, + 0xd4082471L, 0x3320f46aL, 0x43b7d4b7L, 0x500061afL, + 0x1e39f62eL, 0x97244546L, 0x14214f74L, 0xbf8b8840L, + 0x4d95fc1dL, 0x96b591afL, 0x70f4ddd3L, 0x66a02f45L, + 0xbfbc09ecL, 0x03bd9785L, 0x7fac6dd0L, 0x31cb8504L, + 0x96eb27b3L, 0x55fd3941L, 0xda2547e6L, 0xabca0a9aL, + 0x28507825L, 0x530429f4L, 0x0a2c86daL, 0xe9b66dfbL, + 0x68dc1462L, 0xd7486900L, 0x680ec0a4L, 0x27a18deeL, + 0x4f3ffea2L, 0xe887ad8cL, 0xb58ce006L, 0x7af4d6b6L, + 0xaace1e7cL, 0xd3375fecL, 0xce78a399L, 0x406b2a42L, + 0x20fe9e35L, 0xd9f385b9L, 0xee39d7abL, 0x3b124e8bL, + 0x1dc9faf7L, 0x4b6d1856L, 0x26a36631L, 0xeae397b2L, + 0x3a6efa74L, 0xdd5b4332L, 0x6841e7f7L, 0xca7820fbL, + 0xfb0af54eL, 0xd8feb397L, 0x454056acL, 0xba489527L, + 0x55533a3aL, 0x20838d87L, 0xfe6ba9b7L, 0xd096954bL, + 0x55a867bcL, 0xa1159a58L, 0xcca92963L, 0x99e1db33L, + 0xa62a4a56L, 0x3f3125f9L, 0x5ef47e1cL, 0x9029317cL, + 0xfdf8e802L, 0x04272f70L, 0x80bb155cL, 0x05282ce3L, + 0x95c11548L, 0xe4c66d22L, 0x48c1133fL, 0xc70f86dcL, + 0x07f9c9eeL, 0x41041f0fL, 0x404779a4L, 0x5d886e17L, + 0x325f51ebL, 0xd59bc0d1L, 0xf2bcc18fL, 0x41113564L, + 0x257b7834L, 0x602a9c60L, 0xdff8e8a3L, 0x1f636c1bL, + 0x0e12b4c2L, 0x02e1329eL, 0xaf664fd1L, 0xcad18115L, + 0x6b2395e0L, 0x333e92e1L, 0x3b240b62L, 0xeebeb922L, + 0x85b2a20eL, 0xe6ba0d99L, 0xde720c8cL, 0x2da2f728L, + 0xd0127845L, 0x95b794fdL, 0x647d0862L, 0xe7ccf5f0L, + 0x5449a36fL, 0x877d48faL, 0xc39dfd27L, 0xf33e8d1eL, + 0x0a476341L, 0x992eff74L, 0x3a6f6eabL, 0xf4f8fd37L, + 0xa812dc60L, 0xa1ebddf8L, 0x991be14cL, 0xdb6e6b0dL, + 0xc67b5510L, 0x6d672c37L, 0x2765d43bL, 0xdcd0e804L, + 0xf1290dc7L, 0xcc00ffa3L, 0xb5390f92L, 0x690fed0bL, + 0x667b9ffbL, 0xcedb7d9cL, 0xa091cf0bL, 0xd9155ea3L, + 0xbb132f88L, 0x515bad24L, 0x7b9479bfL, 0x763bd6ebL, + 0x37392eb3L, 0xcc115979L, 0x8026e297L, 0xf42e312dL, + 0x6842ada7L, 0xc66a2b3bL, 0x12754cccL, 0x782ef11cL, + 0x6a124237L, 0xb79251e7L, 0x06a1bbe6L, 0x4bfb6350L, + 0x1a6b1018L, 0x11caedfaL, 0x3d25bdd8L, 0xe2e1c3c9L, + 0x44421659L, 0x0a121386L, 0xd90cec6eL, 0xd5abea2aL, + 0x64af674eL, 0xda86a85fL, 0xbebfe988L, 0x64e4c3feL, + 0x9dbc8057L, 0xf0f7c086L, 0x60787bf8L, 0x6003604dL, + 0xd1fd8346L, 0xf6381fb0L, 0x7745ae04L, 0xd736fcccL, + 0x83426b33L, 0xf01eab71L, 0xb0804187L, 0x3c005e5fL, + 0x77a057beL, 0xbde8ae24L, 0x55464299L, 0xbf582e61L, + 0x4e58f48fL, 0xf2ddfda2L, 0xf474ef38L, 0x8789bdc2L, + 0x5366f9c3L, 0xc8b38e74L, 0xb475f255L, 0x46fcd9b9L, + 0x7aeb2661L, 0x8b1ddf84L, 0x846a0e79L, 0x915f95e2L, + 0x466e598eL, 0x20b45770L, 0x8cd55591L, 0xc902de4cL, + 0xb90bace1L, 0xbb8205d0L, 0x11a86248L, 0x7574a99eL, + 0xb77f19b6L, 0xe0a9dc09L, 0x662d09a1L, 0xc4324633L, + 0xe85a1f02L, 0x09f0be8cL, 0x4a99a025L, 0x1d6efe10L, + 0x1ab93d1dL, 0x0ba5a4dfL, 0xa186f20fL, 0x2868f169L, + 0xdcb7da83L, 0x573906feL, 0xa1e2ce9bL, 0x4fcd7f52L, + 0x50115e01L, 0xa70683faL, 0xa002b5c4L, 0x0de6d027L, + 0x9af88c27L, 0x773f8641L, 0xc3604c06L, 0x61a806b5L, + 0xf0177a28L, 0xc0f586e0L, 0x006058aaL, 0x30dc7d62L, + 0x11e69ed7L, 0x2338ea63L, 0x53c2dd94L, 0xc2c21634L, + 0xbbcbee56L, 0x90bcb6deL, 0xebfc7da1L, 0xce591d76L, + 0x6f05e409L, 0x4b7c0188L, 0x39720a3dL, 0x7c927c24L, + 0x86e3725fL, 0x724d9db9L, 0x1ac15bb4L, 0xd39eb8fcL, + 0xed545578L, 0x08fca5b5L, 0xd83d7cd3L, 0x4dad0fc4L, + 0x1e50ef5eL, 0xb161e6f8L, 0xa28514d9L, 0x6c51133cL, + 0x6fd5c7e7L, 0x56e14ec4L, 0x362abfceL, 0xddc6c837L, + 0xd79a3234L, 0x92638212L, 0x670efa8eL, 0x406000e0L, + 0x3a39ce37L, 0xd3faf5cfL, 0xabc27737L, 0x5ac52d1bL, + 0x5cb0679eL, 0x4fa33742L, 0xd3822740L, 0x99bc9bbeL, + 0xd5118e9dL, 0xbf0f7315L, 0xd62d1c7eL, 0xc700c47bL, + 0xb78c1b6bL, 0x21a19045L, 0xb26eb1beL, 0x6a366eb4L, + 0x5748ab2fL, 0xbc946e79L, 0xc6a376d2L, 0x6549c2c8L, + 0x530ff8eeL, 0x468dde7dL, 0xd5730a1dL, 0x4cd04dc6L, + 0x2939bbdbL, 0xa9ba4650L, 0xac9526e8L, 0xbe5ee304L, + 0xa1fad5f0L, 0x6a2d519aL, 0x63ef8ce2L, 0x9a86ee22L, + 0xc089c2b8L, 0x43242ef6L, 0xa51e03aaL, 0x9cf2d0a4L, + 0x83c061baL, 0x9be96a4dL, 0x8fe51550L, 0xba645bd6L, + 0x2826a2f9L, 0xa73a3ae1L, 0x4ba99586L, 0xef5562e9L, + 0xc72fefd3L, 0xf752f7daL, 0x3f046f69L, 0x77fa0a59L, + 0x80e4a915L, 0x87b08601L, 0x9b09e6adL, 0x3b3ee593L, + 0xe990fd5aL, 0x9e34d797L, 0x2cf0b7d9L, 0x022b8b51L, + 0x96d5ac3aL, 0x017da67dL, 0xd1cf3ed6L, 0x7c7d2d28L, + 0x1f9f25cfL, 0xadf2b89bL, 0x5ad6b472L, 0x5a88f54cL, + 0xe029ac71L, 0xe019a5e6L, 0x47b0acfdL, 0xed93fa9bL, + 0xe8d3c48dL, 0x283b57ccL, 0xf8d56629L, 0x79132e28L, + 0x785f0191L, 0xed756055L, 0xf7960e44L, 0xe3d35e8cL, + 0x15056dd4L, 0x88f46dbaL, 0x03a16125L, 0x0564f0bdL, + 0xc3eb9e15L, 0x3c9057a2L, 0x97271aecL, 0xa93a072aL, + 0x1b3f6d9bL, 0x1e6321f5L, 0xf59c66fbL, 0x26dcf319L, + 0x7533d928L, 0xb155fdf5L, 0x03563482L, 0x8aba3cbbL, + 0x28517711L, 0xc20ad9f8L, 0xabcc5167L, 0xccad925fL, + 0x4de81751L, 0x3830dc8eL, 0x379d5862L, 0x9320f991L, + 0xea7a90c2L, 0xfb3e7bceL, 0x5121ce64L, 0x774fbe32L, + 0xa8b6e37eL, 0xc3293d46L, 0x48de5369L, 0x6413e680L, + 0xa2ae0810L, 0xdd6db224L, 0x69852dfdL, 0x09072166L, + 0xb39a460aL, 0x6445c0ddL, 0x586cdecfL, 0x1c20c8aeL, + 0x5bbef7ddL, 0x1b588d40L, 0xccd2017fL, 0x6bb4e3bbL, + 0xdda26a7eL, 0x3a59ff45L, 0x3e350a44L, 0xbcb4cdd5L, + 0x72eacea8L, 0xfa6484bbL, 0x8d6612aeL, 0xbf3c6f47L, + 0xd29be463L, 0x542f5d9eL, 0xaec2771bL, 0xf64e6370L, + 0x740e0d8dL, 0xe75b1357L, 0xf8721671L, 0xaf537d5dL, + 0x4040cb08L, 0x4eb4e2ccL, 0x34d2466aL, 0x0115af84L, + 0xe1b00428L, 0x95983a1dL, 0x06b89fb4L, 0xce6ea048L, + 0x6f3f3b82L, 0x3520ab82L, 0x011a1d4bL, 0x277227f8L, + 0x611560b1L, 0xe7933fdcL, 0xbb3a792bL, 0x344525bdL, + 0xa08839e1L, 0x51ce794bL, 0x2f32c9b7L, 0xa01fbac9L, + 0xe01cc87eL, 0xbcc7d1f6L, 0xcf0111c3L, 0xa1e8aac7L, + 0x1a908749L, 0xd44fbd9aL, 0xd0dadecbL, 0xd50ada38L, + 0x0339c32aL, 0xc6913667L, 0x8df9317cL, 0xe0b12b4fL, + 0xf79e59b7L, 0x43f5bb3aL, 0xf2d519ffL, 0x27d9459cL, + 0xbf97222cL, 0x15e6fc2aL, 0x0f91fc71L, 0x9b941525L, + 0xfae59361L, 0xceb69cebL, 0xc2a86459L, 0x12baa8d1L, + 0xb6c1075eL, 0xe3056a0cL, 0x10d25065L, 0xcb03a442L, + 0xe0ec6e0eL, 0x1698db3bL, 0x4c98a0beL, 0x3278e964L, + 0x9f1f9532L, 0xe0d392dfL, 0xd3a0342bL, 0x8971f21eL, + 0x1b0a7441L, 0x4ba3348cL, 0xc5be7120L, 0xc37632d8L, + 0xdf359f8dL, 0x9b992f2eL, 0xe60b6f47L, 0x0fe3f11dL, + 0xe54cda54L, 0x1edad891L, 0xce6279cfL, 0xcd3e7e6fL, + 0x1618b166L, 0xfd2c1d05L, 0x848fd2c5L, 0xf6fb2299L, + 0xf523f357L, 0xa6327623L, 0x93a83531L, 0x56cccd02L, + 0xacf08162L, 0x5a75ebb5L, 0x6e163697L, 0x88d273ccL, + 0xde966292L, 0x81b949d0L, 0x4c50901bL, 0x71c65614L, + 0xe6c6c7bdL, 0x327a140aL, 0x45e1d006L, 0xc3f27b9aL, + 0xc9aa53fdL, 0x62a80f00L, 0xbb25bfe2L, 0x35bdd2f6L, + 0x71126905L, 0xb2040222L, 0xb6cbcf7cL, 0xcd769c2bL, + 0x53113ec0L, 0x1640e3d3L, 0x38abbd60L, 0x2547adf0L, + 0xba38209cL, 0xf746ce76L, 0x77afa1c5L, 0x20756060L, + 0x85cbfe4eL, 0x8ae88dd8L, 0x7aaaf9b0L, 0x4cf9aa7eL, + 0x1948c25cL, 0x02fb8a8cL, 0x01c36ae4L, 0xd6ebe1f9L, + 0x90d4f869L, 0xa65cdea0L, 0x3f09252dL, 0xc208e69fL, + 0xb74e6132L, 0xce77e25bL, 0x578fdfe3L, 0x3ac372e6L, + } +}; + +void +BF_set_key(BF_KEY *key, int len, const unsigned char *data) +{ + int i; + BF_LONG *p, ri, in[2]; + const unsigned char *d, *end; - memcpy(key,&bf_init,sizeof(BF_KEY)); - p=key->P; + memcpy(key, &bf_init, sizeof(BF_KEY)); + p = key->P; - if (len > ((BF_ROUNDS+2)*4)) len=(BF_ROUNDS+2)*4; + if (len > ((BF_ROUNDS + 2)*4)) + len = (BF_ROUNDS + 2)*4; - d=data; - end= &(data[len]); - for (i=0; i<(BF_ROUNDS+2); i++) - { + d = data; + end = &(data[len]); + for (i = 0; i < (BF_ROUNDS + 2); i++) { ri= *(d++); - if (d >= end) d=data; + if (d >= end) + d = data; - ri<<=8; - ri|= *(d++); - if (d >= end) d=data; + ri <<= 8; + ri |= *(d++); + if (d >= end) + d = data; - ri<<=8; - ri|= *(d++); - if (d >= end) d=data; + ri <<= 8; + ri |= *(d++); + if (d >= end) + d = data; - ri<<=8; - ri|= *(d++); - if (d >= end) d=data; + ri <<= 8; + ri |= *(d++); + if (d >= end) + d = data; p[i]^=ri; - } - - in[0]=0L; - in[1]=0L; - for (i=0; i<(BF_ROUNDS+2); i+=2) - { - BF_encrypt(in,key); - p[i ]=in[0]; - p[i+1]=in[1]; - } + } - p=key->S; - for (i=0; i<4*256; i+=2) - { - BF_encrypt(in,key); - p[i ]=in[0]; - p[i+1]=in[1]; - } + in[0] = 0L; + in[1] = 0L; + for (i = 0; i < (BF_ROUNDS + 2); i += 2) { + BF_encrypt(in, key); + p[i ] = in[0]; + p[i + 1] = in[1]; } + p = key->S; + for (i = 0; i < 4*256; i += 2) { + BF_encrypt(in, key); + p[i ] = in[0]; + p[i + 1] = in[1]; + } +} diff --git a/crypto/bio/b_dump.c b/crypto/bio/b_dump.c index 7e1c2d79..61a83fc4 100644 --- a/crypto/bio/b_dump.c +++ b/crypto/bio/b_dump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: b_dump.c,v 1.22 2021/07/11 20:18:07 beck Exp $ */ +/* $OpenBSD: b_dump.c,v 1.23 2022/10/17 18:26:41 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -80,11 +80,11 @@ int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), void *u, const char *s, int len, int indent) { - int ret = 0; char buf[288 + 1], tmp[20], str[128 + 1]; int i, j, rows, trc, written; unsigned char ch; int dump_width; + int ret = 0; trc = 0; @@ -95,14 +95,13 @@ BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u), if (indent < 0) indent = 0; - if (indent) { - if (indent > 128) - indent = 128; - memset(str, ' ', indent); - } + if (indent > 64) + indent = 64; + memset(str, ' ', indent); str[indent] = '\0'; - dump_width = DUMP_WIDTH_LESS_INDENT(indent); + if ((dump_width = DUMP_WIDTH_LESS_INDENT(indent)) <= 0) + return -1; rows = (len / dump_width); if ((rows * dump_width) < len) rows++; diff --git a/crypto/bio/b_sock.c b/crypto/bio/b_sock.c index 152b0809..301f7391 100644 --- a/crypto/bio/b_sock.c +++ b/crypto/bio/b_sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: b_sock.c,v 1.69 2018/02/07 00:52:05 bluhm Exp $ */ +/* $OpenBSD: b_sock.c,v 1.70 2022/12/22 20:13:45 schwarze Exp $ */ /* * Copyright (c) 2017 Bob Beck * @@ -47,6 +47,7 @@ BIO_get_host_ip(const char *str, unsigned char *ip) int error; if (str == NULL) { + BIOerror(BIO_R_BAD_HOSTNAME_LOOKUP); ERR_asprintf_error_data("NULL host provided"); return (0); } @@ -79,6 +80,7 @@ BIO_get_port(const char *str, unsigned short *port_ptr) } if ((error = getaddrinfo(NULL, str, &hints, &res)) != 0) { + BIOerror(BIO_R_INVALID_ARGUMENT); ERR_asprintf_error_data("getaddrinfo: service='%s' : %s'", str, gai_strerror(error)); return (0); @@ -129,8 +131,14 @@ BIO_get_accept_socket(char *host, int bind_mode) char *h, *p, *str = NULL; int error, ret = 0, s = -1; - if (host == NULL || (str = strdup(host)) == NULL) + if (host == NULL) { + BIOerror(BIO_R_NO_PORT_SPECIFIED); + return (-1); + } + if ((str = strdup(host)) == NULL) { + BIOerror(ERR_R_MALLOC_FAILURE); return (-1); + } p = NULL; h = str; if ((p = strrchr(str, ':')) == NULL) { @@ -148,6 +156,7 @@ BIO_get_accept_socket(char *host, int bind_mode) } if ((error = getaddrinfo(h, p, &hints, &res)) != 0) { + BIOerror(BIO_R_BAD_HOSTNAME_LOOKUP); ERR_asprintf_error_data("getaddrinfo: '%s:%s': %s'", h, p, gai_strerror(error)); goto err; @@ -203,9 +212,10 @@ BIO_accept(int sock, char **addr) socklen_t sin_len = sizeof(sin); int ret = -1; - if (addr == NULL) + if (addr == NULL) { + BIOerror(BIO_R_NULL_PARAMETER); goto end; - + } ret = accept(sock, (struct sockaddr *)&sin, &sin_len); if (ret == -1) { if (BIO_sock_should_retry(ret)) diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index 2ac0abd8..d1450788 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_lib.c,v 1.36 2022/08/15 10:48:45 tb Exp $ */ +/* $OpenBSD: bio_lib.c,v 1.44 2023/03/15 06:14:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -323,12 +323,19 @@ BIO_read(BIO *b, void *out, int outl) size_t readbytes = 0; int ret; - if (b == NULL) - return (0); + if (b == NULL) { + BIOerror(ERR_R_PASSED_NULL_PARAMETER); + return (-1); + } - if (out == NULL || outl <= 0) + if (outl <= 0) return (0); + if (out == NULL) { + BIOerror(ERR_R_PASSED_NULL_PARAMETER); + return (-1); + } + if (b->method == NULL || b->method->bread == NULL) { BIOerror(BIO_R_UNSUPPORTED_METHOD); return (-2); @@ -373,12 +380,18 @@ BIO_write(BIO *b, const void *in, int inl) size_t writebytes = 0; int ret; + /* Not an error. Things like SMIME_text() assume that this succeeds. */ if (b == NULL) return (0); - if (in == NULL || inl <= 0) + if (inl <= 0) return (0); + if (in == NULL) { + BIOerror(ERR_R_PASSED_NULL_PARAMETER); + return (-1); + } + if (b->method == NULL || b->method->bwrite == NULL) { BIOerror(BIO_R_UNSUPPORTED_METHOD); return (-2); @@ -611,7 +624,11 @@ BIO_ctrl_wpending(BIO *bio) } -/* put the 'bio' on the end of b's list of operators */ +/* + * Append "bio" to the end of the chain containing "b": + * Two chains "b -> lb" and "oldhead -> bio" + * become two chains "b -> lb -> bio" and "oldhead". + */ BIO * BIO_push(BIO *b, BIO *bio) { @@ -623,8 +640,11 @@ BIO_push(BIO *b, BIO *bio) while (lb->next_bio != NULL) lb = lb->next_bio; lb->next_bio = bio; - if (bio != NULL) + if (bio != NULL) { + if (bio->prev_bio != NULL) + bio->prev_bio->next_bio = NULL; bio->prev_bio = lb; + } /* called to do internal processing */ BIO_ctrl(b, BIO_CTRL_PUSH, 0, lb); return (b); @@ -713,10 +733,25 @@ BIO_next(BIO *b) return b->next_bio; } +/* + * Two chains "bio -> oldtail" and "oldhead -> next" become + * three chains "oldtail", "bio -> next", and "oldhead". + */ void -BIO_set_next(BIO *b, BIO *next) +BIO_set_next(BIO *bio, BIO *next) { - b->next_bio = next; + /* Cut off the tail of the chain containing bio after bio. */ + if (bio->next_bio != NULL) + bio->next_bio->prev_bio = NULL; + + /* Cut off the head of the chain containing next before next. */ + if (next != NULL && next->prev_bio != NULL) + next->prev_bio->next_bio = NULL; + + /* Append the chain starting at next to the chain ending at bio. */ + bio->next_bio = next; + if (next != NULL) + next->prev_bio = bio; } void diff --git a/crypto/bio/bio_local.h b/crypto/bio/bio_local.h index 7e1885f3..4eecf7e0 100644 --- a/crypto/bio/bio_local.h +++ b/crypto/bio/bio_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_local.h,v 1.3 2022/01/14 08:40:57 tb Exp $ */ +/* $OpenBSD: bio_local.h,v 1.5 2022/12/02 19:44:04 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index fa6e2db9..0d70daa2 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bss_dgram.c,v 1.43 2022/01/07 09:02:17 tb Exp $ */ +/* $OpenBSD: bss_dgram.c,v 1.44 2022/12/26 07:18:51 jmc Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -214,7 +214,7 @@ dgram_adjust_rcv_timeout(BIO *b) timeleft.tv_usec = 1; } - /* Adjust socket timeout if next handhake message timer + /* Adjust socket timeout if next handshake message timer * will expire earlier. */ if ((data->socket_timeout.tv_sec == 0 && diff --git a/crypto/bn/arch/aarch64/bn_arch.h b/crypto/bn/arch/aarch64/bn_arch.h new file mode 100644 index 00000000..b382d1a8 --- /dev/null +++ b/crypto/bn/arch/aarch64/bn_arch.h @@ -0,0 +1,84 @@ +/* $OpenBSD: bn_arch.h,v 1.6 2023/02/25 15:39:40 bcook Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#ifndef HEADER_BN_ARCH_H +#define HEADER_BN_ARCH_H + +#ifndef OPENSSL_NO_ASM + +#if defined(__GNUC__) + +#define HAVE_BN_ADDW + +static inline void +bn_addw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG carry, r0; + + __asm__ ( + "adds %1, %2, %3 \n" + "cset %0, cs" + : "=r"(carry), "=r"(r0) + : "r"(a), "r"(b) + : "cc"); + + *out_r1 = carry; + *out_r0 = r0; +} + +#define HAVE_BN_MULW + +static inline void +bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG r1, r0; + + /* Unsigned multiplication using a umulh/mul pair. */ + __asm__ ( + "umulh %0, %2, %3 \n" + "mul %1, %2, %3" + : "=&r"(r1), "=r"(r0) + : "r"(a), "r"(b)); + + *out_r1 = r1; + *out_r0 = r0; +} + +#define HAVE_BN_SUBW + +static inline void +bn_subw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_borrow, BN_ULONG *out_r0) +{ + BN_ULONG borrow, r0; + + __asm__ ( + "subs %1, %2, %3 \n" + "cset %0, cc" + : "=r"(borrow), "=r"(r0) + : "r"(a), "r"(b) + : "cc"); + + *out_borrow = borrow; + *out_r0 = r0; +} + +#endif /* __GNUC__ */ + +#endif +#endif diff --git a/crypto/bn/arch/amd64/bignum_add.S b/crypto/bn/arch/amd64/bignum_add.S new file mode 100644 index 00000000..d56fa5e3 --- /dev/null +++ b/crypto/bn/arch/amd64/bignum_add.S @@ -0,0 +1,164 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Add, z := x + y +// Inputs x[m], y[n]; outputs function return (carry-out) and z[p] +// +// extern uint64_t bignum_add +// (uint64_t p, uint64_t *z, +// uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); +// +// Does the z := x + y operation, truncating modulo p words in general and +// returning a top carry (0 or 1) in the p'th place, only adding the input +// words below p (as well as m and n respectively) to get the sum and carry. +// +// Standard x86-64 ABI: RDI = p, RSI = z, RDX = m, RCX = x, R8 = n, R9 = y, returns RAX +// Microsoft x64 ABI: RCX = p, RDX = z, R8 = m, R9 = x, [RSP+40] = n, [RSP+48] = y, returns RAX +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_add) + S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_add) + .text + +#define p rdi +#define z rsi +#define m rdx +#define x rcx +#define n r8 +#define y r9 +#define i r10 +#define a rax + +#define ashort eax + + + +S2N_BN_SYMBOL(bignum_add): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx + mov rsi, rdx + mov rdx, r8 + mov rcx, r9 + mov r8, [rsp+56] + mov r9, [rsp+64] +#endif + +// Zero the main index counter for both branches + + xor i, i + +// First clamp the two input sizes m := min(p,m) and n := min(p,n) since +// we'll never need words past the p'th. Can now assume m <= p and n <= p. +// Then compare the modified m and n and branch accordingly + + cmp p, m + cmovc m, p + cmp p, n + cmovc n, p + cmp m, n + jc ylonger + +// The case where x is longer or of the same size (p >= m >= n) + + sub p, m + sub m, n + inc m + test n, n + jz xtest +xmainloop: + mov a, [x+8*i] + adc a, [y+8*i] + mov [z+8*i],a + inc i + dec n + jnz xmainloop + jmp xtest +xtoploop: + mov a, [x+8*i] + adc a, 0 + mov [z+8*i],a + inc i +xtest: + dec m + jnz xtoploop + mov ashort, 0 + adc a, 0 + test p, p + jnz tails +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +// The case where y is longer (p >= n > m) + +ylonger: + + sub p, n + sub n, m + test m, m + jz ytoploop +ymainloop: + mov a, [x+8*i] + adc a, [y+8*i] + mov [z+8*i],a + inc i + dec m + jnz ymainloop +ytoploop: + mov a, [y+8*i] + adc a, 0 + mov [z+8*i],a + inc i + dec n + jnz ytoploop + mov ashort, 0 + adc a, 0 + test p, p + jnz tails +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +// Adding a non-trivial tail, when p > max(m,n) + +tails: + mov [z+8*i],a + xor a, a + jmp tail +tailloop: + mov [z+8*i],a +tail: + inc i + dec p + jnz tailloop +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/amd64/bignum_cmadd.S b/crypto/bn/arch/amd64/bignum_cmadd.S new file mode 100644 index 00000000..1dc1e587 --- /dev/null +++ b/crypto/bn/arch/amd64/bignum_cmadd.S @@ -0,0 +1,154 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Multiply-add with single-word multiplier, z := z + c * y +// Inputs c, y[n]; outputs function return (carry-out) and z[k] +// +// extern uint64_t bignum_cmadd +// (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, uint64_t *y); +// +// Does the "z := z + c * y" operation where y is n digits, result z is p. +// Truncates the result in general. +// +// The return value is a high/carry word that is meaningful when p = n + 1, or +// more generally when n <= p and the result fits in p + 1 digits. In these +// cases it gives the top digit of the (p + 1)-digit result. +// +// Standard x86-64 ABI: RDI = k, RSI = z, RDX = c, RCX = n, R8 = y, returns RAX +// Microsoft x64 ABI: RCX = k, RDX = z, R8 = c, R9 = n, [RSP+40] = y, returns RAX +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_cmadd) + S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_cmadd) + .text + +#define p rdi +#define z rsi +#define c r9 +#define n rcx +#define x r8 + +#define i r10 +#define h r11 + +#define r rbx + +#define hshort r11d +#define ishort r10d + + + +S2N_BN_SYMBOL(bignum_cmadd): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx + mov rsi, rdx + mov rdx, r8 + mov rcx, r9 + mov r8, [rsp+56] +#endif + +// Seems hard to avoid one more register + + push rbx + +// First clamp the input size n := min(p,n) since we can never need to read +// past the p'th term of the input to generate p-digit output. +// Subtract p := p - min(n,p) so it holds the size of the extra tail needed + + cmp p, n + cmovc n, p + sub p, n + +// Initialize high part h = 0; if n = 0 do nothing but return that zero + + xor h, h + test n, n + jz end + +// Move c into a safer register as multiplies overwrite rdx + + mov c, rdx + +// Initialization of the loop: 2^64 * CF + [h,z_0'] = z_0 + c * x_0 + + mov rax, [x] + mul c + add [z], rax + mov h, rdx + mov ishort, 1 + dec n + jz hightail + +// Main loop, where we always have CF + previous high part h to add in + +loop: + adc h, [z+8*i] + sbb r, r + mov rax, [x+8*i] + mul c + sub rdx, r + add rax, h + mov [z+8*i], rax + mov h, rdx + inc i + dec n + jnz loop + +hightail: + adc h, 0 + +// Propagate the carry all the way to the end with h as extra carry word + +tail: + test p, p + jz end + + add [z+8*i], h + mov hshort, 0 + inc i + dec p + jz highend + +tloop: + adc [z+8*i], h + inc i + dec p + jnz tloop + +highend: + + adc h, 0 + +// Return the high/carry word + +end: + mov rax, h + + pop rbx +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/amd64/bignum_cmul.S b/crypto/bn/arch/amd64/bignum_cmul.S new file mode 100644 index 00000000..c1a23cce --- /dev/null +++ b/crypto/bn/arch/amd64/bignum_cmul.S @@ -0,0 +1,137 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Multiply by a single word, z := c * y +// Inputs c, y[n]; outputs function return (carry-out) and z[k] +// +// extern uint64_t bignum_cmul +// (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, uint64_t *y); +// +// Does the "z := c * y" operation where y is n digits, result z is p. +// Truncates the result in general unless p >= n + 1. +// +// The return value is a high/carry word that is meaningful when p >= n as +// giving the high part of the result. Since this is always zero if p > n, +// it is mainly of interest in the special case p = n, i.e. where the source +// and destination have the same nominal size, when it gives the extra word +// of the full result. +// +// Standard x86-64 ABI: RDI = k, RSI = z, RDX = c, RCX = n, R8 = y, returns RAX +// Microsoft x64 ABI: RCX = k, RDX = z, R8 = c, R9 = n, [RSP+40] = y, returns RAX +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_cmul) + S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_cmul) + .text + +#define p rdi +#define z rsi +#define c r9 +#define n rcx +#define x r8 + +#define i r10 +#define h r11 + + + +S2N_BN_SYMBOL(bignum_cmul): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx + mov rsi, rdx + mov rdx, r8 + mov rcx, r9 + mov r8, [rsp+56] +#endif + +// First clamp the input size n := min(p,n) since we can never need to read +// past the p'th term of the input to generate p-digit output. Now we can +// assume that n <= p + + cmp p, n + cmovc n, p + +// Initialize current input/output pointer offset i and high part h. +// But then if n = 0 skip the multiplication and go to the tail part + + xor h, h + xor i, i + test n, n + jz tail + +// Move c into a safer register as multiplies overwrite rdx + + mov c, rdx + +// Initialization of the loop: [h,l] = c * x_0 + + mov rax, [x] + mul c + mov [z], rax + mov h, rdx + inc i + cmp i, n + jz tail + +// Main loop doing the multiplications + +loop: + mov rax, [x+8*i] + mul c + add rax, h + adc rdx, 0 + mov [z+8*i], rax + mov h, rdx + inc i + cmp i, n + jc loop + +// Add a tail when the destination is longer + +tail: + cmp i, p + jnc end + mov [z+8*i], h + xor h, h + inc i + cmp i, p + jnc end + +tloop: + mov [z+8*i], h + inc i + cmp i, p + jc tloop + +// Return the high/carry word + +end: + mov rax, h + +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/amd64/bignum_mul.S b/crypto/bn/arch/amd64/bignum_mul.S new file mode 100644 index 00000000..42ac988a --- /dev/null +++ b/crypto/bn/arch/amd64/bignum_mul.S @@ -0,0 +1,166 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Multiply z := x * y +// Inputs x[m], y[n]; output z[k] +// +// extern void bignum_mul +// (uint64_t k, uint64_t *z, +// uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); +// +// Does the "z := x * y" operation where x is m digits, y is n, result z is k. +// Truncates the result in general unless k >= m + n +// +// Standard x86-64 ABI: RDI = k, RSI = z, RDX = m, RCX = x, R8 = n, R9 = y +// Microsoft x64 ABI: RCX = k, RDX = z, R8 = m, R9 = x, [RSP+40] = n, [RSP+48] = y +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_mul) + S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_mul) + .text + +// These are actually right + +#define p rdi +#define z rsi +#define n r8 + +// These are not + +#define c r15 +#define h r14 +#define l r13 +#define x r12 +#define y r11 +#define i rbx +#define k r10 +#define m rbp + +// These are always local scratch since multiplier result is in these + +#define a rax +#define d rdx + + + +S2N_BN_SYMBOL(bignum_mul): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx + mov rsi, rdx + mov rdx, r8 + mov rcx, r9 + mov r8, [rsp+56] + mov r9, [rsp+64] +#endif + +// We use too many registers, and also we need rax:rdx for multiplications + + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + mov m, rdx + +// If the result size is zero, do nothing +// Note that even if either or both inputs has size zero, we can't +// just give up because we at least need to zero the output array +// If we did a multiply-add variant, however, then we could + + test p, p + jz end + +// Set initial 2-part sum to zero (we zero c inside the body) + + xor h,h + xor l,l + +// Otherwise do outer loop k = 0 ... k = p - 1 + + xor k, k + +outerloop: + +// Zero our carry term first; we eventually want it and a zero is useful now +// Set a = max 0 (k + 1 - n), i = min (k + 1) m +// This defines the range a <= j < i for the inner summation +// Note that since k < p < 2^64 we can assume k + 1 doesn't overflow +// And since we want to increment it anyway, we might as well do it now + + xor c, c // c = 0 + inc k // k = k + 1 + + mov a, k // a = k + 1 + sub a, n // a = k + 1 - n + cmovc a, c // a = max 0 (k + 1 - n) + + mov i, m // i = m + cmp k, m // CF <=> k + 1 < m + cmovc i, k // i = min (k + 1) m + +// Turn i into a loop count, and skip things if it's <= 0 +// Otherwise set up initial pointers x -> x0[a] and y -> y0[k - a] +// and then launch into the main inner loop, postdecrementing i + + mov d, k + sub d, i + sub i, a + jbe innerend + lea x,[rcx+8*a] + lea y,[r9+8*d-8] + +innerloop: + mov rax, [y+8*i] + mul QWORD PTR [x] + add x, 8 + add l, rax + adc h, rdx + adc c, 0 + dec i + jnz innerloop + +innerend: + + mov [z], l + mov l, h + mov h, c + add z, 8 + + cmp k, p + jc outerloop + +end: + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/amd64/bignum_mul_4_8_alt.S b/crypto/bn/arch/amd64/bignum_mul_4_8_alt.S new file mode 100644 index 00000000..3b7848b2 --- /dev/null +++ b/crypto/bn/arch/amd64/bignum_mul_4_8_alt.S @@ -0,0 +1,156 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Multiply z := x * y +// Inputs x[4], y[4]; output z[8] +// +// extern void bignum_mul_4_8_alt +// (uint64_t z[static 8], uint64_t x[static 4], uint64_t y[static 4]); +// +// Standard x86-64 ABI: RDI = z, RSI = x, RDX = y +// Microsoft x64 ABI: RCX = z, RDX = x, R8 = y +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_mul_4_8_alt) + S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_mul_4_8_alt) + .text + +// These are actually right + +#define z rdi +#define x rsi + +// This is moved from rdx to free it for muls + +#define y rcx + +// Other variables used as a rotating 3-word window to add terms to + +#define t0 r8 +#define t1 r9 +#define t2 r10 + +// Macro for the key "multiply and add to (c,h,l)" step + +#define combadd(c,h,l,numa,numb) \ + mov rax, numa; \ + mul QWORD PTR numb; \ + add l, rax; \ + adc h, rdx; \ + adc c, 0 + +// A minutely shorter form for when c = 0 initially + +#define combadz(c,h,l,numa,numb) \ + mov rax, numa; \ + mul QWORD PTR numb; \ + add l, rax; \ + adc h, rdx; \ + adc c, c + +// A short form where we don't expect a top carry + +#define combads(h,l,numa,numb) \ + mov rax, numa; \ + mul QWORD PTR numb; \ + add l, rax; \ + adc h, rdx + +S2N_BN_SYMBOL(bignum_mul_4_8_alt): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx + mov rsi, rdx + mov rdx, r8 +#endif + +// Copy y into a safe register to start with + + mov y, rdx + +// Result term 0 + + mov rax, [x] + mul QWORD PTR [y] + + mov [z], rax + mov t0, rdx + xor t1, t1 + +// Result term 1 + + xor t2, t2 + combads(t1,t0,[x],[y+8]) + combadz(t2,t1,t0,[x+8],[y]) + mov [z+8], t0 + +// Result term 2 + + xor t0, t0 + combadz(t0,t2,t1,[x],[y+16]) + combadd(t0,t2,t1,[x+8],[y+8]) + combadd(t0,t2,t1,[x+16],[y]) + mov [z+16], t1 + +// Result term 3 + + xor t1, t1 + combadz(t1,t0,t2,[x],[y+24]) + combadd(t1,t0,t2,[x+8],[y+16]) + combadd(t1,t0,t2,[x+16],[y+8]) + combadd(t1,t0,t2,[x+24],[y]) + mov [z+24], t2 + +// Result term 4 + + xor t2, t2 + combadz(t2,t1,t0,[x+8],[y+24]) + combadd(t2,t1,t0,[x+16],[y+16]) + combadd(t2,t1,t0,[x+24],[y+8]) + mov [z+32], t0 + +// Result term 5 + + xor t0, t0 + combadz(t0,t2,t1,[x+16],[y+24]) + combadd(t0,t2,t1,[x+24],[y+16]) + mov [z+40], t1 + +// Result term 6 + + xor t1, t1 + combads(t0,t2,[x+24],[y+24]) + mov [z+48], t2 + +// Result term 7 + + mov [z+56], t0 + +// Return + +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/amd64/bignum_mul_8_16_alt.S b/crypto/bn/arch/amd64/bignum_mul_8_16_alt.S new file mode 100644 index 00000000..1be37840 --- /dev/null +++ b/crypto/bn/arch/amd64/bignum_mul_8_16_alt.S @@ -0,0 +1,243 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Multiply z := x * y +// Inputs x[8], y[8]; output z[16] +// +// extern void bignum_mul_8_16_alt +// (uint64_t z[static 16], uint64_t x[static 8], uint64_t y[static 8]); +// +// Standard x86-64 ABI: RDI = z, RSI = x, RDX = y +// Microsoft x64 ABI: RCX = z, RDX = x, R8 = y +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_mul_8_16_alt) + S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_mul_8_16_alt) + .text + +// These are actually right + +#define z rdi +#define x rsi + +// This is moved from rdx to free it for muls + +#define y rcx + +// Other variables used as a rotating 3-word window to add terms to + +#define t0 r8 +#define t1 r9 +#define t2 r10 + +// Macro for the key "multiply and add to (c,h,l)" step + +#define combadd(c,h,l,numa,numb) \ + mov rax, numa; \ + mul QWORD PTR numb; \ + add l, rax; \ + adc h, rdx; \ + adc c, 0 + +// A minutely shorter form for when c = 0 initially + +#define combadz(c,h,l,numa,numb) \ + mov rax, numa; \ + mul QWORD PTR numb; \ + add l, rax; \ + adc h, rdx; \ + adc c, c + +// A short form where we don't expect a top carry + +#define combads(h,l,numa,numb) \ + mov rax, numa; \ + mul QWORD PTR numb; \ + add l, rax; \ + adc h, rdx + +S2N_BN_SYMBOL(bignum_mul_8_16_alt): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx + mov rsi, rdx + mov rdx, r8 +#endif + +// Copy y into a safe register to start with + + mov y, rdx + +// Result term 0 + + mov rax, [x] + mul QWORD PTR [y] + + mov [z], rax + mov t0, rdx + xor t1, t1 + +// Result term 1 + + xor t2, t2 + combads(t1,t0,[x],[y+8]) + combadz(t2,t1,t0,[x+8],[y]) + mov [z+8], t0 + +// Result term 2 + + xor t0, t0 + combadz(t0,t2,t1,[x],[y+16]) + combadd(t0,t2,t1,[x+8],[y+8]) + combadd(t0,t2,t1,[x+16],[y]) + mov [z+16], t1 + +// Result term 3 + + xor t1, t1 + combadz(t1,t0,t2,[x],[y+24]) + combadd(t1,t0,t2,[x+8],[y+16]) + combadd(t1,t0,t2,[x+16],[y+8]) + combadd(t1,t0,t2,[x+24],[y]) + mov [z+24], t2 + +// Result term 4 + + xor t2, t2 + combadz(t2,t1,t0,[x],[y+32]) + combadd(t2,t1,t0,[x+8],[y+24]) + combadd(t2,t1,t0,[x+16],[y+16]) + combadd(t2,t1,t0,[x+24],[y+8]) + combadd(t2,t1,t0,[x+32],[y]) + mov [z+32], t0 + +// Result term 5 + + xor t0, t0 + combadz(t0,t2,t1,[x],[y+40]) + combadd(t0,t2,t1,[x+8],[y+32]) + combadd(t0,t2,t1,[x+16],[y+24]) + combadd(t0,t2,t1,[x+24],[y+16]) + combadd(t0,t2,t1,[x+32],[y+8]) + combadd(t0,t2,t1,[x+40],[y]) + mov [z+40], t1 + +// Result term 6 + + xor t1, t1 + combadz(t1,t0,t2,[x],[y+48]) + combadd(t1,t0,t2,[x+8],[y+40]) + combadd(t1,t0,t2,[x+16],[y+32]) + combadd(t1,t0,t2,[x+24],[y+24]) + combadd(t1,t0,t2,[x+32],[y+16]) + combadd(t1,t0,t2,[x+40],[y+8]) + combadd(t1,t0,t2,[x+48],[y]) + mov [z+48], t2 + +// Result term 7 + + xor t2, t2 + combadz(t2,t1,t0,[x],[y+56]) + combadd(t2,t1,t0,[x+8],[y+48]) + combadd(t2,t1,t0,[x+16],[y+40]) + combadd(t2,t1,t0,[x+24],[y+32]) + combadd(t2,t1,t0,[x+32],[y+24]) + combadd(t2,t1,t0,[x+40],[y+16]) + combadd(t2,t1,t0,[x+48],[y+8]) + combadd(t2,t1,t0,[x+56],[y]) + mov [z+56], t0 + +// Result term 8 + + xor t0, t0 + combadz(t0,t2,t1,[x+8],[y+56]) + combadd(t0,t2,t1,[x+16],[y+48]) + combadd(t0,t2,t1,[x+24],[y+40]) + combadd(t0,t2,t1,[x+32],[y+32]) + combadd(t0,t2,t1,[x+40],[y+24]) + combadd(t0,t2,t1,[x+48],[y+16]) + combadd(t0,t2,t1,[x+56],[y+8]) + mov [z+64], t1 + +// Result term 9 + + xor t1, t1 + combadz(t1,t0,t2,[x+16],[y+56]) + combadd(t1,t0,t2,[x+24],[y+48]) + combadd(t1,t0,t2,[x+32],[y+40]) + combadd(t1,t0,t2,[x+40],[y+32]) + combadd(t1,t0,t2,[x+48],[y+24]) + combadd(t1,t0,t2,[x+56],[y+16]) + mov [z+72], t2 + +// Result term 10 + + xor t2, t2 + combadz(t2,t1,t0,[x+24],[y+56]) + combadd(t2,t1,t0,[x+32],[y+48]) + combadd(t2,t1,t0,[x+40],[y+40]) + combadd(t2,t1,t0,[x+48],[y+32]) + combadd(t2,t1,t0,[x+56],[y+24]) + mov [z+80], t0 + +// Result term 11 + + xor t0, t0 + combadz(t0,t2,t1,[x+32],[y+56]) + combadd(t0,t2,t1,[x+40],[y+48]) + combadd(t0,t2,t1,[x+48],[y+40]) + combadd(t0,t2,t1,[x+56],[y+32]) + mov [z+88], t1 + +// Result term 12 + + xor t1, t1 + combadz(t1,t0,t2,[x+40],[y+56]) + combadd(t1,t0,t2,[x+48],[y+48]) + combadd(t1,t0,t2,[x+56],[y+40]) + mov [z+96], t2 + +// Result term 13 + + xor t2, t2 + combadz(t2,t1,t0,[x+48],[y+56]) + combadd(t2,t1,t0,[x+56],[y+48]) + mov [z+104], t0 + +// Result term 14 + + combads(t2,t1,[x+56],[y+56]) + mov [z+112], t1 + +// Result term 11 + + mov [z+120], t2 + +// Return + +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/amd64/bignum_sqr.S b/crypto/bn/arch/amd64/bignum_sqr.S new file mode 100644 index 00000000..2e05b9c1 --- /dev/null +++ b/crypto/bn/arch/amd64/bignum_sqr.S @@ -0,0 +1,196 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Square z := x^2 +// Input x[n]; output z[k] +// +// extern void bignum_sqr +// (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x); +// +// Does the "z := x^2" operation where x is n digits and result z is k. +// Truncates the result in general unless k >= 2 * n +// +// Standard x86-64 ABI: RDI = k, RSI = z, RDX = n, RCX = x +// Microsoft x64 ABI: RCX = k, RDX = z, R8 = n, R9 = x +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_sqr) + S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_sqr) + .text + +// First three are where arguments come in, but n is moved. + +#define p rdi +#define z rsi +#define x rcx +#define n r8 + +// These are always local scratch since multiplier result is in these + +#define a rax +#define d rdx + +// Other variables + +#define i rbx +#define ll rbp +#define hh r9 +#define k r10 +#define y r11 +#define htop r12 +#define l r13 +#define h r14 +#define c r15 + +// Short versions + +#define llshort ebp + +S2N_BN_SYMBOL(bignum_sqr): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx + mov rsi, rdx + mov rdx, r8 + mov rcx, r9 +#endif + +// We use too many registers, and also we need rax:rdx for multiplications + + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + mov n, rdx + +// If p = 0 the result is trivial and nothing needs doing + + test p, p + jz end + +// initialize (hh,ll) = 0 + + xor llshort, llshort + xor hh, hh + +// Iterate outer loop from k = 0 ... k = p - 1 producing result digits + + xor k, k + +outerloop: + +// First let bot = MAX 0 (k + 1 - n) and top = MIN (k + 1) n +// We want to accumulate all x[i] * x[k - i] for bot <= i < top +// For the optimization of squaring we avoid duplication and do +// 2 * x[i] * x[k - i] for i < htop, where htop = MIN ((k+1)/2) n +// Initialize i = bot; in fact just compute bot as i directly. + + xor c, c + lea i, [k+1] + mov htop, i + shr htop, 1 + sub i, n + cmovc i, c + cmp htop, n + cmovnc htop, n + +// Initialize the three-part local sum (c,h,l); c was already done above + + xor l, l + xor h, h + +// If htop <= bot then main doubled part of the sum is empty + + cmp i, htop + jnc nosumming + +// Use a moving pointer for [y] = x[k-i] for the cofactor + + mov a, k + sub a, i + lea y, [x+8*a] + +// Do the main part of the sum x[i] * x[k - i] for 2 * i < k + +innerloop: + mov a, [x+8*i] + mul QWORD PTR [y] + add l, a + adc h, d + adc c, 0 + sub y, 8 + inc i + cmp i, htop + jc innerloop + +// Now double it + + add l, l + adc h, h + adc c, c + +// If k is even (which means 2 * i = k) and i < n add the extra x[i]^2 term + +nosumming: + test k, 1 + jnz innerend + cmp i, n + jnc innerend + + mov a, [x+8*i] + mul a + add l, a + adc h, d + adc c, 0 + +// Now add the local sum into the global sum, store and shift + +innerend: + add l, ll + mov [z+8*k], l + adc h, hh + mov ll, h + adc c, 0 + mov hh, c + + inc k + cmp k, p + jc outerloop + +// Restore registers and return + +end: + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/amd64/bignum_sqr_4_8_alt.S b/crypto/bn/arch/amd64/bignum_sqr_4_8_alt.S new file mode 100644 index 00000000..a635177c --- /dev/null +++ b/crypto/bn/arch/amd64/bignum_sqr_4_8_alt.S @@ -0,0 +1,144 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Square, z := x^2 +// Input x[4]; output z[8] +// +// extern void bignum_sqr_4_8_alt +// (uint64_t z[static 8], uint64_t x[static 4]); +// +// Standard x86-64 ABI: RDI = z, RSI = x +// Microsoft x64 ABI: RCX = z, RDX = x +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_sqr_4_8_alt) + S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_sqr_4_8_alt) + .text + +// Input arguments + +#define z rdi +#define x rsi + +// Other variables used as a rotating 3-word window to add terms to + +#define t0 rcx +#define t1 r8 +#define t2 r9 + +// Macro for the key "multiply and add to (c,h,l)" step, for square term + +#define combadd1(c,h,l,numa) \ + mov rax, numa; \ + mul rax; \ + add l, rax; \ + adc h, rdx; \ + adc c, 0 + +// A short form where we don't expect a top carry + +#define combads(h,l,numa) \ + mov rax, numa; \ + mul rax; \ + add l, rax; \ + adc h, rdx + +// A version doubling before adding, for non-square terms + +#define combadd2(c,h,l,numa,numb) \ + mov rax, numa; \ + mul QWORD PTR numb; \ + add rax, rax; \ + adc rdx, rdx; \ + adc c, 0; \ + add l, rax; \ + adc h, rdx; \ + adc c, 0 + +S2N_BN_SYMBOL(bignum_sqr_4_8_alt): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx + mov rsi, rdx +#endif + +// Result term 0 + + mov rax, [x] + mul rax + + mov [z], rax + mov t0, rdx + xor t1, t1 + +// Result term 1 + + xor t2, t2 + combadd2(t2,t1,t0,[x],[x+8]) + mov [z+8], t0 + +// Result term 2 + + xor t0, t0 + combadd1(t0,t2,t1,[x+8]) + combadd2(t0,t2,t1,[x],[x+16]) + mov [z+16], t1 + +// Result term 3 + + xor t1, t1 + combadd2(t1,t0,t2,[x],[x+24]) + combadd2(t1,t0,t2,[x+8],[x+16]) + mov [z+24], t2 + +// Result term 4 + + xor t2, t2 + combadd2(t2,t1,t0,[x+8],[x+24]) + combadd1(t2,t1,t0,[x+16]) + mov [z+32], t0 + +// Result term 5 + + xor t0, t0 + combadd2(t0,t2,t1,[x+16],[x+24]) + mov [z+40], t1 + +// Result term 6 + + xor t1, t1 + combads(t0,t2,[x+24]) + mov [z+48], t2 + +// Result term 7 + + mov [z+56], t0 + +// Return + +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/amd64/bignum_sqr_8_16_alt.S b/crypto/bn/arch/amd64/bignum_sqr_8_16_alt.S new file mode 100644 index 00000000..f698202d --- /dev/null +++ b/crypto/bn/arch/amd64/bignum_sqr_8_16_alt.S @@ -0,0 +1,241 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Square, z := x^2 +// Input x[8]; output z[16] +// +// extern void bignum_sqr_8_16_alt (uint64_t z[static 16], uint64_t x[static 8]); +// +// Standard x86-64 ABI: RDI = z, RSI = x +// Microsoft x64 ABI: RCX = z, RDX = x +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_sqr_8_16_alt) + S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_sqr_8_16_alt) + .text + +// Input arguments + +#define z rdi +#define x rsi + +// Other variables used as a rotating 3-word window to add terms to + +#define t0 r8 +#define t1 r9 +#define t2 r10 + +// Additional temporaries for local windows to share doublings + +#define u0 rcx +#define u1 r11 + +// Macro for the key "multiply and add to (c,h,l)" step + +#define combadd(c,h,l,numa,numb) \ + mov rax, numa; \ + mul QWORD PTR numb; \ + add l, rax; \ + adc h, rdx; \ + adc c, 0 + +// Set up initial window (c,h,l) = numa * numb + +#define combaddz(c,h,l,numa,numb) \ + mov rax, numa; \ + mul QWORD PTR numb; \ + xor c, c; \ + mov l, rax; \ + mov h, rdx + +// Doubling step (c,h,l) = 2 * (c,hh,ll) + (0,h,l) + +#define doubladd(c,h,l,hh,ll) \ + add ll, ll; \ + adc hh, hh; \ + adc c, c; \ + add l, ll; \ + adc h, hh; \ + adc c, 0 + +// Square term incorporation (c,h,l) += numba^2 + +#define combadd1(c,h,l,numa) \ + mov rax, numa; \ + mul rax; \ + add l, rax; \ + adc h, rdx; \ + adc c, 0 + +// A short form where we don't expect a top carry + +#define combads(h,l,numa) \ + mov rax, numa; \ + mul rax; \ + add l, rax; \ + adc h, rdx + +// A version doubling directly before adding, for single non-square terms + +#define combadd2(c,h,l,numa,numb) \ + mov rax, numa; \ + mul QWORD PTR numb; \ + add rax, rax; \ + adc rdx, rdx; \ + adc c, 0; \ + add l, rax; \ + adc h, rdx; \ + adc c, 0 + +S2N_BN_SYMBOL(bignum_sqr_8_16_alt): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx + mov rsi, rdx +#endif + +// Result term 0 + + mov rax, [x] + mul rax + + mov [z], rax + mov t0, rdx + xor t1, t1 + +// Result term 1 + + xor t2, t2 + combadd2(t2,t1,t0,[x],[x+8]) + mov [z+8], t0 + +// Result term 2 + + xor t0, t0 + combadd1(t0,t2,t1,[x+8]) + combadd2(t0,t2,t1,[x],[x+16]) + mov [z+16], t1 + +// Result term 3 + + combaddz(t1,u1,u0,[x],[x+24]) + combadd(t1,u1,u0,[x+8],[x+16]) + doubladd(t1,t0,t2,u1,u0) + mov [z+24], t2 + +// Result term 4 + + combaddz(t2,u1,u0,[x],[x+32]) + combadd(t2,u1,u0,[x+8],[x+24]) + doubladd(t2,t1,t0,u1,u0) + combadd1(t2,t1,t0,[x+16]) + mov [z+32], t0 + +// Result term 5 + + combaddz(t0,u1,u0,[x],[x+40]) + combadd(t0,u1,u0,[x+8],[x+32]) + combadd(t0,u1,u0,[x+16],[x+24]) + doubladd(t0,t2,t1,u1,u0) + mov [z+40], t1 + +// Result term 6 + + combaddz(t1,u1,u0,[x],[x+48]) + combadd(t1,u1,u0,[x+8],[x+40]) + combadd(t1,u1,u0,[x+16],[x+32]) + doubladd(t1,t0,t2,u1,u0) + combadd1(t1,t0,t2,[x+24]) + mov [z+48], t2 + +// Result term 7 + + combaddz(t2,u1,u0,[x],[x+56]) + combadd(t2,u1,u0,[x+8],[x+48]) + combadd(t2,u1,u0,[x+16],[x+40]) + combadd(t2,u1,u0,[x+24],[x+32]) + doubladd(t2,t1,t0,u1,u0) + mov [z+56], t0 + +// Result term 8 + + combaddz(t0,u1,u0,[x+8],[x+56]) + combadd(t0,u1,u0,[x+16],[x+48]) + combadd(t0,u1,u0,[x+24],[x+40]) + doubladd(t0,t2,t1,u1,u0) + combadd1(t0,t2,t1,[x+32]) + mov [z+64], t1 + +// Result term 9 + + combaddz(t1,u1,u0,[x+16],[x+56]) + combadd(t1,u1,u0,[x+24],[x+48]) + combadd(t1,u1,u0,[x+32],[x+40]) + doubladd(t1,t0,t2,u1,u0) + mov [z+72], t2 + +// Result term 10 + + combaddz(t2,u1,u0,[x+24],[x+56]) + combadd(t2,u1,u0,[x+32],[x+48]) + doubladd(t2,t1,t0,u1,u0) + combadd1(t2,t1,t0,[x+40]) + mov [z+80], t0 + +// Result term 11 + + combaddz(t0,u1,u0,[x+32],[x+56]) + combadd(t0,u1,u0,[x+40],[x+48]) + doubladd(t0,t2,t1,u1,u0) + mov [z+88], t1 + +// Result term 12 + + xor t1, t1 + combadd2(t1,t0,t2,[x+40],[x+56]) + combadd1(t1,t0,t2,[x+48]) + mov [z+96], t2 + +// Result term 13 + + xor t2, t2 + combadd2(t2,t1,t0,[x+48],[x+56]) + mov [z+104], t0 + +// Result term 14 + + combads(t2,t1,[x+56]) + mov [z+112], t1 + +// Result term 15 + + mov [z+120], t2 + +// Return + +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/amd64/bignum_sub.S b/crypto/bn/arch/amd64/bignum_sub.S new file mode 100644 index 00000000..f8e1fe35 --- /dev/null +++ b/crypto/bn/arch/amd64/bignum_sub.S @@ -0,0 +1,152 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Subtract, z := x - y +// Inputs x[m], y[n]; outputs function return (carry-out) and z[p] +// +// extern uint64_t bignum_sub +// (uint64_t p, uint64_t *z, +// uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); +// +// Does the z := x - y operation, truncating modulo p words in general and +// returning a top borrow (0 or 1) in the p'th place, only subtracting input +// words below p (as well as m and n respectively) to get the diff and borrow. +// +// Standard x86-64 ABI: RDI = p, RSI = z, RDX = m, RCX = x, R8 = n, R9 = y, returns RAX +// Microsoft x64 ABI: RCX = p, RDX = z, R8 = m, R9 = x, [RSP+40] = n, [RSP+48] = y, returns RAX +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(bignum_sub) + S2N_BN_SYM_PRIVACY_DIRECTIVE(bignum_sub) + .text + +#define p rdi +#define z rsi +#define m rdx +#define x rcx +#define n r8 +#define y r9 +#define i r10 +#define a rax + +#define ashort eax + + + +S2N_BN_SYMBOL(bignum_sub): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx + mov rsi, rdx + mov rdx, r8 + mov rcx, r9 + mov r8, [rsp+56] + mov r9, [rsp+64] +#endif + +// Zero the main index counter for both branches + + xor i, i + +// First clamp the two input sizes m := min(p,m) and n := min(p,n) since +// we'll never need words past the p'th. Can now assume m <= p and n <= p. +// Then compare the modified m and n and branch accordingly + + cmp p, m + cmovc m, p + cmp p, n + cmovc n, p + cmp m, n + jc ylonger + +// The case where x is longer or of the same size (p >= m >= n) + + sub p, m + sub m, n + inc m + test n, n + jz xtest +xmainloop: + mov a, [x+8*i] + sbb a, [y+8*i] + mov [z+8*i],a + inc i + dec n + jnz xmainloop + jmp xtest +xtoploop: + mov a, [x+8*i] + sbb a, 0 + mov [z+8*i],a + inc i +xtest: + dec m + jnz xtoploop + sbb a, a + test p, p + jz tailskip +tailloop: + mov [z+8*i],a + inc i + dec p + jnz tailloop +tailskip: + neg a +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +// The case where y is longer (p >= n > m) + +ylonger: + + sub p, n + sub n, m + test m, m + jz ytoploop +ymainloop: + mov a, [x+8*i] + sbb a, [y+8*i] + mov [z+8*i],a + inc i + dec m + jnz ymainloop +ytoploop: + mov ashort, 0 + sbb a, [y+8*i] + mov [z+8*i],a + inc i + dec n + jnz ytoploop + sbb a, a + test p, p + jnz tailloop + neg a +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/amd64/bn_arch.c b/crypto/bn/arch/amd64/bn_arch.c new file mode 100644 index 00000000..55275aa1 --- /dev/null +++ b/crypto/bn/arch/amd64/bn_arch.c @@ -0,0 +1,131 @@ +/* $OpenBSD: bn_arch.c,v 1.6 2023/02/22 05:46:37 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include "bn_arch.h" +#include "bn_local.h" +#include "s2n_bignum.h" + +#ifdef HAVE_BN_ADD +BN_ULONG +bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, + int b_len) +{ + return bignum_add(r_len, (uint64_t *)r, a_len, (uint64_t *)a, + b_len, (uint64_t *)b); +} +#endif + + +#ifdef HAVE_BN_ADD_WORDS +BN_ULONG +bn_add_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) +{ + return bignum_add(n, (uint64_t *)rd, n, (uint64_t *)ad, n, + (uint64_t *)bd); +} +#endif + +#ifdef HAVE_BN_SUB +BN_ULONG +bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, + int b_len) +{ + return bignum_sub(r_len, (uint64_t *)r, a_len, (uint64_t *)a, + b_len, (uint64_t *)b); +} +#endif + +#ifdef HAVE_BN_SUB_WORDS +BN_ULONG +bn_sub_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) +{ + return bignum_sub(n, (uint64_t *)rd, n, (uint64_t *)ad, n, + (uint64_t *)bd); +} +#endif + +#ifdef HAVE_BN_MUL_ADD_WORDS +BN_ULONG +bn_mul_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) +{ + return bignum_cmadd(num, (uint64_t *)rd, w, num, (uint64_t *)ad); +} +#endif + +#ifdef HAVE_BN_MUL_WORDS +BN_ULONG +bn_mul_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) +{ + return bignum_cmul(num, (uint64_t *)rd, w, num, (uint64_t *)ad); +} +#endif + +#ifdef HAVE_BN_MUL_COMBA4 +void +bn_mul_comba4(BN_ULONG *rd, BN_ULONG *ad, BN_ULONG *bd) +{ + /* XXX - consider using non-alt on CPUs that have the ADX extension. */ + bignum_mul_4_8_alt((uint64_t *)rd, (uint64_t *)ad, (uint64_t *)bd); +} +#endif + +#ifdef HAVE_BN_MUL_COMBA8 +void +bn_mul_comba8(BN_ULONG *rd, BN_ULONG *ad, BN_ULONG *bd) +{ + /* XXX - consider using non-alt on CPUs that have the ADX extension. */ + bignum_mul_8_16_alt((uint64_t *)rd, (uint64_t *)ad, (uint64_t *)bd); +} +#endif + +#ifdef HAVE_BN_SQR +int +bn_sqr(BIGNUM *r, const BIGNUM *a, int rn, BN_CTX *ctx) +{ + bignum_sqr(rn, (uint64_t *)r->d, a->top, (uint64_t *)a->d); + + return 1; +} +#endif + +#ifdef HAVE_BN_SQR_COMBA4 +void +bn_sqr_comba4(BN_ULONG *rd, const BN_ULONG *ad) +{ + /* XXX - consider using non-alt on CPUs that have the ADX extension. */ + bignum_sqr_4_8_alt((uint64_t *)rd, (uint64_t *)ad); +} +#endif + +#ifdef HAVE_BN_SQR_COMBA8 +void +bn_sqr_comba8(BN_ULONG *rd, const BN_ULONG *ad) +{ + /* XXX - consider using non-alt on CPUs that have the ADX extension. */ + bignum_sqr_8_16_alt((uint64_t *)rd, (uint64_t *)ad); +} +#endif + +#ifdef HAVE_BN_WORD_CLZ +int +bn_word_clz(BN_ULONG w) +{ + return word_clz(w); +} +#endif diff --git a/crypto/bn/arch/amd64/bn_arch.h b/crypto/bn/arch/amd64/bn_arch.h new file mode 100644 index 00000000..9d491e27 --- /dev/null +++ b/crypto/bn/arch/amd64/bn_arch.h @@ -0,0 +1,95 @@ +/* $OpenBSD: bn_arch.h,v 1.13 2023/02/16 11:13:05 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#ifndef HEADER_BN_ARCH_H +#define HEADER_BN_ARCH_H + +#ifdef _WIN32 +#define OPENSSL_NO_ASM +#else + +#ifndef OPENSSL_NO_ASM + +#define HAVE_BN_ADD +#define HAVE_BN_ADD_WORDS + +#define HAVE_BN_DIV_WORDS + +#define HAVE_BN_MUL_ADD_WORDS +#define HAVE_BN_MUL_COMBA4 +#define HAVE_BN_MUL_COMBA8 +#define HAVE_BN_MUL_WORDS + +#define HAVE_BN_SQR +#define HAVE_BN_SQR_COMBA4 +#define HAVE_BN_SQR_COMBA8 + +#define HAVE_BN_SUB +#define HAVE_BN_SUB_WORDS + +#define HAVE_BN_WORD_CLZ + +#if defined(__GNUC__) +#define HAVE_BN_DIV_REM_WORDS_INLINE + +static inline void +bn_div_rem_words_inline(BN_ULONG h, BN_ULONG l, BN_ULONG d, BN_ULONG *out_q, + BN_ULONG *out_r) +{ + BN_ULONG q, r; + + /* + * Unsigned division of %rdx:%rax by d with quotient being stored in + * %rax and remainder in %rdx. + */ + __asm__ volatile ("divq %4" + : "=a"(q), "=d"(r) + : "d"(h), "a"(l), "rm"(d) + : "cc"); + + *out_q = q; + *out_r = r; +} +#endif /* __GNUC__ */ + +#if defined(__GNUC__) +#define HAVE_BN_MULW + +static inline void +bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG r1, r0; + + /* + * Unsigned multiplication of %rax, with the double word result being + * stored in %rdx:%rax. + */ + __asm__ ("mulq %3" + : "=d"(r1), "=a"(r0) + : "a"(a), "rm"(b) + : "cc"); + + *out_r1 = r1; + *out_r0 = r0; +} +#endif /* __GNUC__ */ +#endif /* _WIN32 */ + +#endif +#endif diff --git a/crypto/bn/arch/amd64/word_clz.S b/crypto/bn/arch/amd64/word_clz.S new file mode 100644 index 00000000..025e98f9 --- /dev/null +++ b/crypto/bn/arch/amd64/word_clz.S @@ -0,0 +1,59 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// Count leading zero bits in a single word +// Input a; output function return +// +// extern uint64_t word_clz (uint64_t a); +// +// Standard x86-64 ABI: RDI = a, returns RAX +// Microsoft x64 ABI: RCX = a, returns RAX +// ---------------------------------------------------------------------------- + +#include "s2n_bignum_internal.h" + + .intel_syntax noprefix + S2N_BN_SYM_VISIBILITY_DIRECTIVE(word_clz) + S2N_BN_SYM_PRIVACY_DIRECTIVE(word_clz) + .text + +S2N_BN_SYMBOL(word_clz): + +#if WINDOWS_ABI + push rdi + push rsi + mov rdi, rcx +#endif + +// First do rax = 63 - bsr(a), which is right except (maybe) for zero inputs + + bsr rax, rdi + xor rax, 63 + +// Force return of 64 in the zero-input case + + mov edx, 64 + test rdi, rdi + cmove rax, rdx + +#if WINDOWS_ABI + pop rsi + pop rdi +#endif + ret + +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/arch/arm/bn_arch.h b/crypto/bn/arch/arm/bn_arch.h new file mode 100644 index 00000000..136adf0e --- /dev/null +++ b/crypto/bn/arch/arm/bn_arch.h @@ -0,0 +1,24 @@ +/* $OpenBSD: bn_arch.h,v 1.1 2023/01/20 10:04:33 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef HEADER_BN_ARCH_H +#define HEADER_BN_ARCH_H + +#ifndef OPENSSL_NO_ASM + +#endif +#endif diff --git a/crypto/bn/arch/i386/bn_arch.h b/crypto/bn/arch/i386/bn_arch.h new file mode 100644 index 00000000..eef519fc --- /dev/null +++ b/crypto/bn/arch/i386/bn_arch.h @@ -0,0 +1,86 @@ +/* $OpenBSD: bn_arch.h,v 1.9 2023/02/16 10:41:03 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#ifndef HEADER_BN_ARCH_H +#define HEADER_BN_ARCH_H + +#ifndef OPENSSL_NO_ASM + +#define HAVE_BN_ADD_WORDS + +#define HAVE_BN_DIV_WORDS + +#define HAVE_BN_MUL_ADD_WORDS +#define HAVE_BN_MUL_COMBA4 +#define HAVE_BN_MUL_COMBA8 +#define HAVE_BN_MUL_WORDS + +#define HAVE_BN_SQR_COMBA4 +#define HAVE_BN_SQR_COMBA8 +#define HAVE_BN_SQR_WORDS + +#define HAVE_BN_SUB_WORDS + +#if defined(__GNUC__) +#define HAVE_BN_DIV_REM_WORDS_INLINE + +static inline void +bn_div_rem_words_inline(BN_ULONG h, BN_ULONG l, BN_ULONG d, BN_ULONG *out_q, + BN_ULONG *out_r) +{ + BN_ULONG q, r; + + /* + * Unsigned division of %edx:%eax by d with quotient being stored in + * %eax and remainder in %edx. + */ + __asm__ volatile ("divl %4" + : "=a"(q), "=d"(r) + : "a"(l), "d"(h), "rm"(d) + : "cc"); + + *out_q = q; + *out_r = r; +} +#endif /* __GNUC__ */ + +#if defined(__GNUC__) +#define HAVE_BN_MULW + +static inline void +bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG r1, r0; + + /* + * Unsigned multiplication of %eax, with the double word result being + * stored in %edx:%eax. + */ + __asm__ ("mull %3" + : "=d"(r1), "=a"(r0) + : "a"(a), "rm"(b) + : "cc"); + + *out_r1 = r1; + *out_r0 = r0; +} +#endif /* __GNUC__ */ + +#endif +#endif diff --git a/crypto/bn/arch/mips/bn_arch.h b/crypto/bn/arch/mips/bn_arch.h new file mode 100644 index 00000000..4d6571f9 --- /dev/null +++ b/crypto/bn/arch/mips/bn_arch.h @@ -0,0 +1,24 @@ +/* $OpenBSD: bn_arch.h,v 1.1 2023/01/20 10:04:34 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef HEADER_BN_ARCH_H +#define HEADER_BN_ARCH_H + +#ifndef OPENSSL_NO_ASM + +#endif +#endif diff --git a/crypto/bn/arch/mips64/bn_arch.h b/crypto/bn/arch/mips64/bn_arch.h new file mode 100644 index 00000000..53771bce --- /dev/null +++ b/crypto/bn/arch/mips64/bn_arch.h @@ -0,0 +1,40 @@ +/* $OpenBSD: bn_arch.h,v 1.7 2023/01/23 12:17:58 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef HEADER_BN_ARCH_H +#define HEADER_BN_ARCH_H + +#ifndef OPENSSL_NO_ASM + +#define HAVE_BN_ADD_WORDS + +#define HAVE_BN_DIV_WORDS +#define HAVE_BN_DIV_3_WORDS + +#define HAVE_BN_MUL_ADD_WORDS +#define HAVE_BN_MUL_COMBA4 +#define HAVE_BN_MUL_COMBA8 +#define HAVE_BN_MUL_WORDS + +#define HAVE_BN_SQR_COMBA4 +#define HAVE_BN_SQR_COMBA8 +#define HAVE_BN_SQR_WORDS + +#define HAVE_BN_SUB_WORDS + +#endif +#endif diff --git a/crypto/bn/arch/powerpc/bn_arch.h b/crypto/bn/arch/powerpc/bn_arch.h new file mode 100644 index 00000000..46e932a2 --- /dev/null +++ b/crypto/bn/arch/powerpc/bn_arch.h @@ -0,0 +1,39 @@ +/* $OpenBSD: bn_arch.h,v 1.6 2023/01/23 12:17:58 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef HEADER_BN_ARCH_H +#define HEADER_BN_ARCH_H + +#ifndef OPENSSL_NO_ASM + +#define HAVE_BN_ADD_WORDS + +#define HAVE_BN_DIV_WORDS + +#define HAVE_BN_MUL_ADD_WORDS +#define HAVE_BN_MUL_COMBA4 +#define HAVE_BN_MUL_COMBA8 +#define HAVE_BN_MUL_WORDS + +#define HAVE_BN_SQR_COMBA4 +#define HAVE_BN_SQR_COMBA8 +#define HAVE_BN_SQR_WORDS + +#define HAVE_BN_SUB_WORDS + +#endif +#endif diff --git a/crypto/bn/arch/powerpc64/bn_arch.h b/crypto/bn/arch/powerpc64/bn_arch.h new file mode 100644 index 00000000..18bac203 --- /dev/null +++ b/crypto/bn/arch/powerpc64/bn_arch.h @@ -0,0 +1,44 @@ +/* $OpenBSD: bn_arch.h,v 1.4 2023/02/16 10:41:03 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef HEADER_BN_ARCH_H +#define HEADER_BN_ARCH_H + +#ifndef OPENSSL_NO_ASM + +#if 0 /* Needs testing and enabling. */ +#if defined(__GNUC__) +#define HAVE_BN_MULW + +static inline void +bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG r1, r0; + + /* Unsigned multiplication using a mulhdu/mul pair. */ + __asm__ ("mulhdu %0, %2, %3; mul %1, %2, %3" + : "=&r"(r1), "=r"(r0) + : "r"(a), "r"(b)); + + *out_r1 = r1; + *out_r0 = r0; +} +#endif /* __GNUC__ */ +#endif + +#endif +#endif diff --git a/crypto/bn/arch/riscv64/bn_arch.h b/crypto/bn/arch/riscv64/bn_arch.h new file mode 100644 index 00000000..354774cd --- /dev/null +++ b/crypto/bn/arch/riscv64/bn_arch.h @@ -0,0 +1,48 @@ +/* $OpenBSD: bn_arch.h,v 1.4 2023/02/16 10:41:03 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef HEADER_BN_ARCH_H +#define HEADER_BN_ARCH_H + +#ifndef OPENSSL_NO_ASM + +#if 0 /* Needs testing and enabling. */ +#if defined(__GNUC__) +#define HAVE_BN_MULW + +static inline void +bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG r1, r0; + + /* + * Unsigned multiplication using a mulh/mul pair. Note that the order + * of these instructions is important, as they can potentially be fused + * into a single operation. + */ + __asm__ ("mulh %0, %2, %3; mul %1, %2, %3" + : "=&r"(r1), "=r"(r0) + : "r"(a), "r"(b)); + + *out_r1 = r1; + *out_r0 = r0; +} +#endif /* __GNUC__ */ +#endif + +#endif +#endif diff --git a/crypto/bn/arch/sparc64/bn_arch.h b/crypto/bn/arch/sparc64/bn_arch.h new file mode 100644 index 00000000..4d6571f9 --- /dev/null +++ b/crypto/bn/arch/sparc64/bn_arch.h @@ -0,0 +1,24 @@ +/* $OpenBSD: bn_arch.h,v 1.1 2023/01/20 10:04:34 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef HEADER_BN_ARCH_H +#define HEADER_BN_ARCH_H + +#ifndef OPENSSL_NO_ASM + +#endif +#endif diff --git a/crypto/bn/bn-mips.S b/crypto/bn/bn-mips.S new file mode 100644 index 00000000..eb4ac9b9 --- /dev/null +++ b/crypto/bn/bn-mips.S @@ -0,0 +1,2162 @@ +.set mips2 +.rdata +.asciiz "mips3.s, Version 1.2" +.asciiz "MIPS II/III/IV ISA artwork by Andy Polyakov " + +.text +.set noat + +.align 5 +.globl bn_mul_add_words +.ent bn_mul_add_words +bn_mul_add_words: + .set noreorder + bgtz $6,bn_mul_add_words_internal + move $2,$0 + jr $31 + move $4,$2 +.end bn_mul_add_words + +.align 5 +.ent bn_mul_add_words_internal +bn_mul_add_words_internal: + .set reorder + li $3,-4 + and $8,$6,$3 + beqz $8,.L_bn_mul_add_words_tail + +.L_bn_mul_add_words_loop: + lw $12,0($5) + multu $12,$7 + lw $13,0($4) + lw $14,4($5) + lw $15,4($4) + lw $8,2*4($5) + lw $9,2*4($4) + addu $13,$2 + sltu $2,$13,$2 # All manuals say it "compares 32-bit + # values", but it seems to work fine + # even on 64-bit registers. + mflo $1 + mfhi $12 + addu $13,$1 + addu $2,$12 + multu $14,$7 + sltu $1,$13,$1 + sw $13,0($4) + addu $2,$1 + + lw $10,3*4($5) + lw $11,3*4($4) + addu $15,$2 + sltu $2,$15,$2 + mflo $1 + mfhi $14 + addu $15,$1 + addu $2,$14 + multu $8,$7 + sltu $1,$15,$1 + sw $15,4($4) + addu $2,$1 + + subu $6,4 + addu $4,4*4 + addu $5,4*4 + addu $9,$2 + sltu $2,$9,$2 + mflo $1 + mfhi $8 + addu $9,$1 + addu $2,$8 + multu $10,$7 + sltu $1,$9,$1 + sw $9,-2*4($4) + addu $2,$1 + + + and $8,$6,$3 + addu $11,$2 + sltu $2,$11,$2 + mflo $1 + mfhi $10 + addu $11,$1 + addu $2,$10 + sltu $1,$11,$1 + sw $11,-4($4) + .set noreorder + bgtz $8,.L_bn_mul_add_words_loop + addu $2,$1 + + beqz $6,.L_bn_mul_add_words_return + nop + +.L_bn_mul_add_words_tail: + .set reorder + lw $12,0($5) + multu $12,$7 + lw $13,0($4) + subu $6,1 + addu $13,$2 + sltu $2,$13,$2 + mflo $1 + mfhi $12 + addu $13,$1 + addu $2,$12 + sltu $1,$13,$1 + sw $13,0($4) + addu $2,$1 + beqz $6,.L_bn_mul_add_words_return + + lw $12,4($5) + multu $12,$7 + lw $13,4($4) + subu $6,1 + addu $13,$2 + sltu $2,$13,$2 + mflo $1 + mfhi $12 + addu $13,$1 + addu $2,$12 + sltu $1,$13,$1 + sw $13,4($4) + addu $2,$1 + beqz $6,.L_bn_mul_add_words_return + + lw $12,2*4($5) + multu $12,$7 + lw $13,2*4($4) + addu $13,$2 + sltu $2,$13,$2 + mflo $1 + mfhi $12 + addu $13,$1 + addu $2,$12 + sltu $1,$13,$1 + sw $13,2*4($4) + addu $2,$1 + +.L_bn_mul_add_words_return: + .set noreorder + jr $31 + move $4,$2 +.end bn_mul_add_words_internal + +.align 5 +.globl bn_mul_words +.ent bn_mul_words +bn_mul_words: + .set noreorder + bgtz $6,bn_mul_words_internal + move $2,$0 + jr $31 + move $4,$2 +.end bn_mul_words + +.align 5 +.ent bn_mul_words_internal +bn_mul_words_internal: + .set reorder + li $3,-4 + and $8,$6,$3 + beqz $8,.L_bn_mul_words_tail + +.L_bn_mul_words_loop: + lw $12,0($5) + multu $12,$7 + lw $14,4($5) + lw $8,2*4($5) + lw $10,3*4($5) + mflo $1 + mfhi $12 + addu $2,$1 + sltu $13,$2,$1 + multu $14,$7 + sw $2,0($4) + addu $2,$13,$12 + + subu $6,4 + addu $4,4*4 + addu $5,4*4 + mflo $1 + mfhi $14 + addu $2,$1 + sltu $15,$2,$1 + multu $8,$7 + sw $2,-3*4($4) + addu $2,$15,$14 + + mflo $1 + mfhi $8 + addu $2,$1 + sltu $9,$2,$1 + multu $10,$7 + sw $2,-2*4($4) + addu $2,$9,$8 + + and $8,$6,$3 + mflo $1 + mfhi $10 + addu $2,$1 + sltu $11,$2,$1 + sw $2,-4($4) + .set noreorder + bgtz $8,.L_bn_mul_words_loop + addu $2,$11,$10 + + beqz $6,.L_bn_mul_words_return + nop + +.L_bn_mul_words_tail: + .set reorder + lw $12,0($5) + multu $12,$7 + subu $6,1 + mflo $1 + mfhi $12 + addu $2,$1 + sltu $13,$2,$1 + sw $2,0($4) + addu $2,$13,$12 + beqz $6,.L_bn_mul_words_return + + lw $12,4($5) + multu $12,$7 + subu $6,1 + mflo $1 + mfhi $12 + addu $2,$1 + sltu $13,$2,$1 + sw $2,4($4) + addu $2,$13,$12 + beqz $6,.L_bn_mul_words_return + + lw $12,2*4($5) + multu $12,$7 + mflo $1 + mfhi $12 + addu $2,$1 + sltu $13,$2,$1 + sw $2,2*4($4) + addu $2,$13,$12 + +.L_bn_mul_words_return: + .set noreorder + jr $31 + move $4,$2 +.end bn_mul_words_internal + +.align 5 +.globl bn_sqr_words +.ent bn_sqr_words +bn_sqr_words: + .set noreorder + bgtz $6,bn_sqr_words_internal + move $2,$0 + jr $31 + move $4,$2 +.end bn_sqr_words + +.align 5 +.ent bn_sqr_words_internal +bn_sqr_words_internal: + .set reorder + li $3,-4 + and $8,$6,$3 + beqz $8,.L_bn_sqr_words_tail + +.L_bn_sqr_words_loop: + lw $12,0($5) + multu $12,$12 + lw $14,4($5) + lw $8,2*4($5) + lw $10,3*4($5) + mflo $13 + mfhi $12 + sw $13,0($4) + sw $12,4($4) + + multu $14,$14 + subu $6,4 + addu $4,8*4 + addu $5,4*4 + mflo $15 + mfhi $14 + sw $15,-6*4($4) + sw $14,-5*4($4) + + multu $8,$8 + mflo $9 + mfhi $8 + sw $9,-4*4($4) + sw $8,-3*4($4) + + + multu $10,$10 + and $8,$6,$3 + mflo $11 + mfhi $10 + sw $11,-2*4($4) + + .set noreorder + bgtz $8,.L_bn_sqr_words_loop + sw $10,-4($4) + + beqz $6,.L_bn_sqr_words_return + nop + +.L_bn_sqr_words_tail: + .set reorder + lw $12,0($5) + multu $12,$12 + subu $6,1 + mflo $13 + mfhi $12 + sw $13,0($4) + sw $12,4($4) + beqz $6,.L_bn_sqr_words_return + + lw $12,4($5) + multu $12,$12 + subu $6,1 + mflo $13 + mfhi $12 + sw $13,2*4($4) + sw $12,3*4($4) + beqz $6,.L_bn_sqr_words_return + + lw $12,2*4($5) + multu $12,$12 + mflo $13 + mfhi $12 + sw $13,4*4($4) + sw $12,5*4($4) + +.L_bn_sqr_words_return: + .set noreorder + jr $31 + move $4,$2 + +.end bn_sqr_words_internal + +.align 5 +.globl bn_add_words +.ent bn_add_words +bn_add_words: + .set noreorder + bgtz $7,bn_add_words_internal + move $2,$0 + jr $31 + move $4,$2 +.end bn_add_words + +.align 5 +.ent bn_add_words_internal +bn_add_words_internal: + .set reorder + li $3,-4 + and $1,$7,$3 + beqz $1,.L_bn_add_words_tail + +.L_bn_add_words_loop: + lw $12,0($5) + lw $8,0($6) + subu $7,4 + lw $13,4($5) + and $1,$7,$3 + lw $14,2*4($5) + addu $6,4*4 + lw $15,3*4($5) + addu $4,4*4 + lw $9,-3*4($6) + addu $5,4*4 + lw $10,-2*4($6) + lw $11,-4($6) + addu $8,$12 + sltu $24,$8,$12 + addu $12,$8,$2 + sltu $2,$12,$8 + sw $12,-4*4($4) + addu $2,$24 + + addu $9,$13 + sltu $25,$9,$13 + addu $13,$9,$2 + sltu $2,$13,$9 + sw $13,-3*4($4) + addu $2,$25 + + addu $10,$14 + sltu $24,$10,$14 + addu $14,$10,$2 + sltu $2,$14,$10 + sw $14,-2*4($4) + addu $2,$24 + + addu $11,$15 + sltu $25,$11,$15 + addu $15,$11,$2 + sltu $2,$15,$11 + sw $15,-4($4) + + .set noreorder + bgtz $1,.L_bn_add_words_loop + addu $2,$25 + + beqz $7,.L_bn_add_words_return + nop + +.L_bn_add_words_tail: + .set reorder + lw $12,0($5) + lw $8,0($6) + addu $8,$12 + subu $7,1 + sltu $24,$8,$12 + addu $12,$8,$2 + sltu $2,$12,$8 + sw $12,0($4) + addu $2,$24 + beqz $7,.L_bn_add_words_return + + lw $13,4($5) + lw $9,4($6) + addu $9,$13 + subu $7,1 + sltu $25,$9,$13 + addu $13,$9,$2 + sltu $2,$13,$9 + sw $13,4($4) + addu $2,$25 + beqz $7,.L_bn_add_words_return + + lw $14,2*4($5) + lw $10,2*4($6) + addu $10,$14 + sltu $24,$10,$14 + addu $14,$10,$2 + sltu $2,$14,$10 + sw $14,2*4($4) + addu $2,$24 + +.L_bn_add_words_return: + .set noreorder + jr $31 + move $4,$2 + +.end bn_add_words_internal + +.align 5 +.globl bn_sub_words +.ent bn_sub_words +bn_sub_words: + .set noreorder + bgtz $7,bn_sub_words_internal + move $2,$0 + jr $31 + move $4,$0 +.end bn_sub_words + +.align 5 +.ent bn_sub_words_internal +bn_sub_words_internal: + .set reorder + li $3,-4 + and $1,$7,$3 + beqz $1,.L_bn_sub_words_tail + +.L_bn_sub_words_loop: + lw $12,0($5) + lw $8,0($6) + subu $7,4 + lw $13,4($5) + and $1,$7,$3 + lw $14,2*4($5) + addu $6,4*4 + lw $15,3*4($5) + addu $4,4*4 + lw $9,-3*4($6) + addu $5,4*4 + lw $10,-2*4($6) + lw $11,-4($6) + sltu $24,$12,$8 + subu $8,$12,$8 + subu $12,$8,$2 + sgtu $2,$12,$8 + sw $12,-4*4($4) + addu $2,$24 + + sltu $25,$13,$9 + subu $9,$13,$9 + subu $13,$9,$2 + sgtu $2,$13,$9 + sw $13,-3*4($4) + addu $2,$25 + + + sltu $24,$14,$10 + subu $10,$14,$10 + subu $14,$10,$2 + sgtu $2,$14,$10 + sw $14,-2*4($4) + addu $2,$24 + + sltu $25,$15,$11 + subu $11,$15,$11 + subu $15,$11,$2 + sgtu $2,$15,$11 + sw $15,-4($4) + + .set noreorder + bgtz $1,.L_bn_sub_words_loop + addu $2,$25 + + beqz $7,.L_bn_sub_words_return + nop + +.L_bn_sub_words_tail: + .set reorder + lw $12,0($5) + lw $8,0($6) + subu $7,1 + sltu $24,$12,$8 + subu $8,$12,$8 + subu $12,$8,$2 + sgtu $2,$12,$8 + sw $12,0($4) + addu $2,$24 + beqz $7,.L_bn_sub_words_return + + lw $13,4($5) + subu $7,1 + lw $9,4($6) + sltu $25,$13,$9 + subu $9,$13,$9 + subu $13,$9,$2 + sgtu $2,$13,$9 + sw $13,4($4) + addu $2,$25 + beqz $7,.L_bn_sub_words_return + + lw $14,2*4($5) + lw $10,2*4($6) + sltu $24,$14,$10 + subu $10,$14,$10 + subu $14,$10,$2 + sgtu $2,$14,$10 + sw $14,2*4($4) + addu $2,$24 + +.L_bn_sub_words_return: + .set noreorder + jr $31 + move $4,$2 +.end bn_sub_words_internal + +.align 5 +.globl bn_div_3_words +.ent bn_div_3_words +bn_div_3_words: + .set noreorder + move $7,$4 # we know that bn_div_words does not + # touch $7, $10, $11 and preserves $6 + # so that we can save two arguments + # and return address in registers + # instead of stack:-) + + lw $4,($7) + move $10,$5 + bne $4,$6,bn_div_3_words_internal + lw $5,-4($7) + li $2,-1 + jr $31 + move $4,$2 +.end bn_div_3_words + +.align 5 +.ent bn_div_3_words_internal +bn_div_3_words_internal: + .set reorder + move $11,$31 + bal bn_div_words_internal + move $31,$11 + multu $10,$2 + lw $14,-2*4($7) + move $8,$0 + mfhi $13 + mflo $12 + sltu $24,$13,$5 +.L_bn_div_3_words_inner_loop: + bnez $24,.L_bn_div_3_words_inner_loop_done + sgeu $1,$14,$12 + seq $25,$13,$5 + and $1,$25 + sltu $15,$12,$10 + addu $5,$6 + subu $13,$15 + subu $12,$10 + sltu $24,$13,$5 + sltu $8,$5,$6 + or $24,$8 + .set noreorder + beqz $1,.L_bn_div_3_words_inner_loop + subu $2,1 + addu $2,1 + .set reorder +.L_bn_div_3_words_inner_loop_done: + .set noreorder + jr $31 + move $4,$2 +.end bn_div_3_words_internal + +.align 5 +.globl bn_div_words +.ent bn_div_words +bn_div_words: + .set noreorder + bnez $6,bn_div_words_internal + li $2,-1 # I would rather signal div-by-zero + # which can be done with 'break 7' + jr $31 + move $4,$2 +.end bn_div_words + +.align 5 +.ent bn_div_words_internal +bn_div_words_internal: + move $3,$0 + bltz $6,.L_bn_div_words_body + move $25,$3 + sll $6,1 + bgtz $6,.-4 + addu $25,1 + + .set reorder + negu $13,$25 + li $14,-1 + sll $14,$13 + and $14,$4 + srl $1,$5,$13 + .set noreorder + beqz $14,.+12 + nop + break 6 # signal overflow + .set reorder + sll $4,$25 + sll $5,$25 + or $4,$1 +.L_bn_div_words_body: + srl $3,$6,4*4 # bits + sgeu $1,$4,$6 + .set noreorder + beqz $1,.+12 + nop + subu $4,$6 + .set reorder + + li $8,-1 + srl $9,$4,4*4 # bits + srl $8,4*4 # q=0xffffffff + beq $3,$9,.L_bn_div_words_skip_div1 + divu $0,$4,$3 + mflo $8 +.L_bn_div_words_skip_div1: + multu $6,$8 + sll $15,$4,4*4 # bits + srl $1,$5,4*4 # bits + or $15,$1 + mflo $12 + mfhi $13 +.L_bn_div_words_inner_loop1: + sltu $14,$15,$12 + seq $24,$9,$13 + sltu $1,$9,$13 + and $14,$24 + sltu $2,$12,$6 + or $1,$14 + .set noreorder + beqz $1,.L_bn_div_words_inner_loop1_done + subu $13,$2 + subu $12,$6 + b .L_bn_div_words_inner_loop1 + subu $8,1 + .set reorder +.L_bn_div_words_inner_loop1_done: + + sll $5,4*4 # bits + subu $4,$15,$12 + sll $2,$8,4*4 # bits + + li $8,-1 + srl $9,$4,4*4 # bits + srl $8,4*4 # q=0xffffffff + beq $3,$9,.L_bn_div_words_skip_div2 + divu $0,$4,$3 + mflo $8 +.L_bn_div_words_skip_div2: + multu $6,$8 + sll $15,$4,4*4 # bits + srl $1,$5,4*4 # bits + or $15,$1 + mflo $12 + mfhi $13 +.L_bn_div_words_inner_loop2: + sltu $14,$15,$12 + seq $24,$9,$13 + sltu $1,$9,$13 + and $14,$24 + sltu $3,$12,$6 + or $1,$14 + .set noreorder + beqz $1,.L_bn_div_words_inner_loop2_done + subu $13,$3 + subu $12,$6 + b .L_bn_div_words_inner_loop2 + subu $8,1 + .set reorder +.L_bn_div_words_inner_loop2_done: + + subu $4,$15,$12 + or $2,$8 + srl $3,$4,$25 # $3 contains remainder if anybody wants it + srl $6,$25 # restore $6 + + .set noreorder + move $5,$3 + jr $31 + move $4,$2 +.end bn_div_words_internal + +.align 5 +.globl bn_mul_comba8 +.ent bn_mul_comba8 +bn_mul_comba8: + .set noreorder + .frame $29,6*4,$31 + .mask 0x003f0000,-4 + subu $29,6*4 + sw $21,5*4($29) + sw $20,4*4($29) + sw $19,3*4($29) + sw $18,2*4($29) + sw $17,1*4($29) + sw $16,0*4($29) + + .set reorder + lw $12,0($5) # If compiled with -mips3 option on + # R5000 box assembler barks on this + # 1ine with "should not have mult/div + # as last instruction in bb (R10K + # bug)" warning. If anybody out there + # has a clue about how to circumvent + # this do send me a note. + # + + lw $8,0($6) + lw $13,4($5) + lw $14,2*4($5) + multu $12,$8 # mul_add_c(a[0],b[0],c1,c2,c3); + lw $15,3*4($5) + lw $9,4($6) + lw $10,2*4($6) + lw $11,3*4($6) + mflo $2 + mfhi $3 + + lw $16,4*4($5) + lw $18,5*4($5) + multu $12,$9 # mul_add_c(a[0],b[1],c2,c3,c1); + lw $20,6*4($5) + lw $5,7*4($5) + lw $17,4*4($6) + lw $19,5*4($6) + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $13,$8 # mul_add_c(a[1],b[0],c2,c3,c1); + addu $7,$25,$1 + lw $21,6*4($6) + lw $6,7*4($6) + sw $2,0($4) # r[0]=c1; + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $14,$8 # mul_add_c(a[2],b[0],c3,c1,c2); + addu $25,$1 + addu $7,$25 + sltu $2,$7,$25 + sw $3,4($4) # r[1]=c2; + + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $13,$9 # mul_add_c(a[1],b[1],c3,c1,c2); + addu $25,$1 + addu $2,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $12,$10 # mul_add_c(a[0],b[2],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $3,$2,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $12,$11 # mul_add_c(a[0],b[3],c1,c2,c3); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + sw $7,2*4($4) # r[2]=c3; + + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $13,$10 # mul_add_c(a[1],b[2],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $7,$3,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $14,$9 # mul_add_c(a[2],b[1],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $15,$8 # mul_add_c(a[3],b[0],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $16,$8 # mul_add_c(a[4],b[0],c2,c3,c1); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + sw $2,3*4($4) # r[3]=c1; + + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $15,$9 # mul_add_c(a[3],b[1],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $2,$7,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $14,$10 # mul_add_c(a[2],b[2],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $13,$11 # mul_add_c(a[1],b[3],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $12,$17 # mul_add_c(a[0],b[4],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $12,$19 # mul_add_c(a[0],b[5],c3,c1,c2); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + sw $3,4*4($4) # r[4]=c2; + + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $13,$17 # mul_add_c(a[1],b[4],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $3,$2,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $14,$11 # mul_add_c(a[2],b[3],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $15,$10 # mul_add_c(a[3],b[2],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $16,$9 # mul_add_c(a[4],b[1],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $18,$8 # mul_add_c(a[5],b[0],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $20,$8 # mul_add_c(a[6],b[0],c1,c2,c3); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + sw $7,5*4($4) # r[5]=c3; + + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $18,$9 # mul_add_c(a[5],b[1],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $7,$3,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $16,$10 # mul_add_c(a[4],b[2],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $15,$11 # mul_add_c(a[3],b[3],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $14,$17 # mul_add_c(a[2],b[4],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $13,$19 # mul_add_c(a[1],b[5],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $12,$21 # mul_add_c(a[0],b[6],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $12,$6 # mul_add_c(a[0],b[7],c2,c3,c1); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + sw $2,6*4($4) # r[6]=c1; + + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $13,$21 # mul_add_c(a[1],b[6],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $2,$7,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $14,$19 # mul_add_c(a[2],b[5],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $15,$17 # mul_add_c(a[3],b[4],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $16,$11 # mul_add_c(a[4],b[3],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $18,$10 # mul_add_c(a[5],b[2],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $20,$9 # mul_add_c(a[6],b[1],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $5,$8 # mul_add_c(a[7],b[0],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $5,$9 # mul_add_c(a[7],b[1],c3,c1,c2); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + sw $3,7*4($4) # r[7]=c2; + + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $20,$10 # mul_add_c(a[6],b[2],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $3,$2,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $18,$11 # mul_add_c(a[5],b[3],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $16,$17 # mul_add_c(a[4],b[4],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $15,$19 # mul_add_c(a[3],b[5],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $14,$21 # mul_add_c(a[2],b[6],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $13,$6 # mul_add_c(a[1],b[7],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $14,$6 # mul_add_c(a[2],b[7],c1,c2,c3); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + sw $7,8*4($4) # r[8]=c3; + + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $15,$21 # mul_add_c(a[3],b[6],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $7,$3,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $16,$19 # mul_add_c(a[4],b[5],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $18,$17 # mul_add_c(a[5],b[4],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $20,$11 # mul_add_c(a[6],b[3],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $5,$10 # mul_add_c(a[7],b[2],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $5,$11 # mul_add_c(a[7],b[3],c2,c3,c1); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + sw $2,9*4($4) # r[9]=c1; + + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $20,$17 # mul_add_c(a[6],b[4],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $2,$7,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $18,$19 # mul_add_c(a[5],b[5],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $16,$21 # mul_add_c(a[4],b[6],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $15,$6 # mul_add_c(a[3],b[7],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $16,$6 # mul_add_c(a[4],b[7],c3,c1,c2); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + sw $3,10*4($4) # r[10]=c2; + + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $18,$21 # mul_add_c(a[5],b[6],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $3,$2,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $20,$19 # mul_add_c(a[6],b[5],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $5,$17 # mul_add_c(a[7],b[4],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $5,$19 # mul_add_c(a[7],b[5],c1,c2,c3); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + sw $7,11*4($4) # r[11]=c3; + + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $20,$21 # mul_add_c(a[6],b[6],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $7,$3,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $18,$6 # mul_add_c(a[5],b[7],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $20,$6 # mul_add_c(a[6],b[7],c2,c3,c1); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + sw $2,12*4($4) # r[12]=c1; + + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $5,$21 # mul_add_c(a[7],b[6],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $2,$7,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $5,$6 # mul_add_c(a[7],b[7],c3,c1,c2); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + sw $3,13*4($4) # r[13]=c2; + + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + addu $25,$1 + addu $2,$25 + sw $7,14*4($4) # r[14]=c3; + sw $2,15*4($4) # r[15]=c1; + + .set noreorder + lw $21,5*4($29) + lw $20,4*4($29) + lw $19,3*4($29) + lw $18,2*4($29) + lw $17,1*4($29) + lw $16,0*4($29) + jr $31 + addu $29,6*4 +.end bn_mul_comba8 + +.align 5 +.globl bn_mul_comba4 +.ent bn_mul_comba4 +bn_mul_comba4: + .set reorder + lw $12,0($5) + lw $8,0($6) + lw $13,4($5) + lw $14,2*4($5) + multu $12,$8 # mul_add_c(a[0],b[0],c1,c2,c3); + lw $15,3*4($5) + lw $9,4($6) + lw $10,2*4($6) + lw $11,3*4($6) + mflo $2 + mfhi $3 + sw $2,0($4) + + multu $12,$9 # mul_add_c(a[0],b[1],c2,c3,c1); + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $13,$8 # mul_add_c(a[1],b[0],c2,c3,c1); + addu $7,$25,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $14,$8 # mul_add_c(a[2],b[0],c3,c1,c2); + addu $25,$1 + addu $7,$25 + sltu $2,$7,$25 + sw $3,4($4) + + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $13,$9 # mul_add_c(a[1],b[1],c3,c1,c2); + addu $25,$1 + addu $2,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $12,$10 # mul_add_c(a[0],b[2],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $3,$2,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $12,$11 # mul_add_c(a[0],b[3],c1,c2,c3); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + sw $7,2*4($4) + + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $13,$10 # mul_add_c(a[1],b[2],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $7,$3,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $14,$9 # mul_add_c(a[2],b[1],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $15,$8 # mul_add_c(a[3],b[0],c1,c2,c3); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $15,$9 # mul_add_c(a[3],b[1],c2,c3,c1); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + sw $2,3*4($4) + + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $14,$10 # mul_add_c(a[2],b[2],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $2,$7,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $13,$11 # mul_add_c(a[1],b[3],c2,c3,c1); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $14,$11 # mul_add_c(a[2],b[3],c3,c1,c2); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + sw $3,4*4($4) + + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $15,$10 # mul_add_c(a[3],b[2],c3,c1,c2); + addu $25,$1 + addu $2,$25 + sltu $3,$2,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $15,$11 # mul_add_c(a[3],b[3],c1,c2,c3); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + sw $7,5*4($4) + + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + addu $25,$1 + addu $3,$25 + sw $2,6*4($4) + sw $3,7*4($4) + + .set noreorder + jr $31 + nop +.end bn_mul_comba4 + +.align 5 +.globl bn_sqr_comba8 +.ent bn_sqr_comba8 +bn_sqr_comba8: + .set reorder + lw $12,0($5) + lw $13,4($5) + lw $14,2*4($5) + lw $15,3*4($5) + + multu $12,$12 # mul_add_c(a[0],b[0],c1,c2,c3); + lw $8,4*4($5) + lw $9,5*4($5) + lw $10,6*4($5) + lw $11,7*4($5) + mflo $2 + mfhi $3 + sw $2,0($4) + + multu $12,$13 # mul_add_c2(a[0],b[1],c2,c3,c1); + mflo $24 + mfhi $25 + slt $2,$25,$0 + sll $25,1 + multu $14,$12 # mul_add_c2(a[2],b[0],c3,c1,c2); + slt $6,$24,$0 + addu $25,$6 + sll $24,1 + addu $3,$24 + sltu $1,$3,$24 + addu $7,$25,$1 + sw $3,4($4) + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $13,$13 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $3,$2,$1 + addu $2,$25 + sltu $25,$2,$25 + addu $3,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $12,$15 # mul_add_c2(a[0],b[3],c1,c2,c3); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + sw $7,2*4($4) + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $13,$14 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $7,$3,$1 + addu $3,$25 + sltu $25,$3,$25 + addu $7,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $8,$12 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $1,$3,$1 + addu $3,$25 + addu $7,$1 + sltu $25,$3,$25 + addu $7,$25 + sw $2,3*4($4) + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $15,$13 # forward multiplication + addu $3,$24 + addu $1,$25 + sltu $24,$3,$24 + addu $7,$1 + addu $25,$24 + sltu $2,$7,$1 + addu $7,$25 + sltu $25,$7,$25 + addu $2,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $14,$14 # forward multiplication + addu $3,$24 + addu $1,$25 + sltu $24,$3,$24 + addu $7,$1 + addu $25,$24 + sltu $1,$7,$1 + addu $7,$25 + addu $2,$1 + sltu $25,$7,$25 + addu $2,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $12,$9 # mul_add_c2(a[0],b[5],c3,c1,c2); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + sw $3,4*4($4) + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $13,$8 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $3,$2,$1 + addu $2,$25 + sltu $25,$2,$25 + addu $3,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $14,$15 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $1,$2,$1 + addu $2,$25 + addu $3,$1 + sltu $25,$2,$25 + addu $3,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $10,$12 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $1,$2,$1 + addu $2,$25 + addu $3,$1 + sltu $25,$2,$25 + addu $3,$25 + sw $7,5*4($4) + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $9,$13 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $7,$3,$1 + addu $3,$25 + sltu $25,$3,$25 + addu $7,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $8,$14 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $1,$3,$1 + addu $3,$25 + addu $7,$1 + sltu $25,$3,$25 + addu $7,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $15,$15 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $1,$3,$1 + addu $3,$25 + addu $7,$1 + sltu $25,$3,$25 + addu $7,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $12,$11 # mul_add_c2(a[0],b[7],c2,c3,c1); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + sw $2,6*4($4) + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $13,$10 # forward multiplication + addu $3,$24 + addu $1,$25 + sltu $24,$3,$24 + addu $7,$1 + addu $25,$24 + sltu $2,$7,$1 + addu $7,$25 + sltu $25,$7,$25 + addu $2,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $14,$9 # forward multiplication + addu $3,$24 + addu $1,$25 + sltu $24,$3,$24 + addu $7,$1 + addu $25,$24 + sltu $1,$7,$1 + addu $7,$25 + addu $2,$1 + sltu $25,$7,$25 + addu $2,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $15,$8 # forward multiplication + addu $3,$24 + addu $1,$25 + sltu $24,$3,$24 + addu $7,$1 + addu $25,$24 + sltu $1,$7,$1 + addu $7,$25 + addu $2,$1 + sltu $25,$7,$25 + addu $2,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $11,$13 # forward multiplication + addu $3,$24 + addu $1,$25 + sltu $24,$3,$24 + addu $7,$1 + addu $25,$24 + sltu $1,$7,$1 + addu $7,$25 + addu $2,$1 + sltu $25,$7,$25 + addu $2,$25 + sw $3,7*4($4) + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $10,$14 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $3,$2,$1 + addu $2,$25 + sltu $25,$2,$25 + addu $3,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $9,$15 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $1,$2,$1 + addu $2,$25 + addu $3,$1 + sltu $25,$2,$25 + addu $3,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $8,$8 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $1,$2,$1 + addu $2,$25 + addu $3,$1 + sltu $25,$2,$25 + addu $3,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $14,$11 # mul_add_c2(a[2],b[7],c1,c2,c3); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + sw $7,8*4($4) + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $15,$10 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $7,$3,$1 + addu $3,$25 + sltu $25,$3,$25 + addu $7,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $8,$9 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $1,$3,$1 + addu $3,$25 + addu $7,$1 + sltu $25,$3,$25 + addu $7,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $11,$15 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $1,$3,$1 + addu $3,$25 + addu $7,$1 + sltu $25,$3,$25 + addu $7,$25 + sw $2,9*4($4) + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $10,$8 # forward multiplication + addu $3,$24 + addu $1,$25 + sltu $24,$3,$24 + addu $7,$1 + addu $25,$24 + sltu $2,$7,$1 + addu $7,$25 + sltu $25,$7,$25 + addu $2,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $9,$9 # forward multiplication + addu $3,$24 + addu $1,$25 + sltu $24,$3,$24 + addu $7,$1 + addu $25,$24 + sltu $1,$7,$1 + addu $7,$25 + addu $2,$1 + sltu $25,$7,$25 + addu $2,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $8,$11 # mul_add_c2(a[4],b[7],c3,c1,c2); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + sw $3,10*4($4) + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $9,$10 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $3,$2,$1 + addu $2,$25 + sltu $25,$2,$25 + addu $3,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $11,$9 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $1,$2,$1 + addu $2,$25 + addu $3,$1 + sltu $25,$2,$25 + addu $3,$25 + sw $7,11*4($4) + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $10,$10 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $7,$3,$1 + addu $3,$25 + sltu $25,$3,$25 + addu $7,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $10,$11 # mul_add_c2(a[6],b[7],c2,c3,c1); + addu $25,$1 + addu $3,$25 + sltu $1,$3,$25 + addu $7,$1 + sw $2,12*4($4) + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $11,$11 # forward multiplication + addu $3,$24 + addu $1,$25 + sltu $24,$3,$24 + addu $7,$1 + addu $25,$24 + sltu $2,$7,$1 + addu $7,$25 + sltu $25,$7,$25 + addu $2,$25 + sw $3,13*4($4) + + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + addu $25,$1 + addu $2,$25 + sw $7,14*4($4) + sw $2,15*4($4) + + .set noreorder + jr $31 + nop +.end bn_sqr_comba8 + +.align 5 +.globl bn_sqr_comba4 +.ent bn_sqr_comba4 +bn_sqr_comba4: + .set reorder + lw $12,0($5) + lw $13,4($5) + multu $12,$12 # mul_add_c(a[0],b[0],c1,c2,c3); + lw $14,2*4($5) + lw $15,3*4($5) + mflo $2 + mfhi $3 + sw $2,0($4) + + multu $12,$13 # mul_add_c2(a[0],b[1],c2,c3,c1); + mflo $24 + mfhi $25 + slt $2,$25,$0 + sll $25,1 + multu $14,$12 # mul_add_c2(a[2],b[0],c3,c1,c2); + slt $6,$24,$0 + addu $25,$6 + sll $24,1 + addu $3,$24 + sltu $1,$3,$24 + addu $7,$25,$1 + sw $3,4($4) + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $13,$13 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $3,$2,$1 + addu $2,$25 + sltu $25,$2,$25 + addu $3,$25 + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $12,$15 # mul_add_c2(a[0],b[3],c1,c2,c3); + addu $25,$1 + addu $2,$25 + sltu $1,$2,$25 + addu $3,$1 + sw $7,2*4($4) + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $13,$14 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $7,$3,$1 + addu $3,$25 + sltu $25,$3,$25 + addu $7,$25 + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + multu $15,$13 # forward multiplication + addu $2,$24 + addu $1,$25 + sltu $24,$2,$24 + addu $3,$1 + addu $25,$24 + sltu $1,$3,$1 + addu $3,$25 + addu $7,$1 + sltu $25,$3,$25 + addu $7,$25 + sw $2,3*4($4) + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $14,$14 # forward multiplication + addu $3,$24 + addu $1,$25 + sltu $24,$3,$24 + addu $7,$1 + addu $25,$24 + sltu $2,$7,$1 + addu $7,$25 + sltu $25,$7,$25 + addu $2,$25 + mflo $24 + mfhi $25 + addu $3,$24 + sltu $1,$3,$24 + multu $14,$15 # mul_add_c2(a[2],b[3],c3,c1,c2); + addu $25,$1 + addu $7,$25 + sltu $1,$7,$25 + addu $2,$1 + sw $3,4*4($4) + mflo $24 + mfhi $25 + addu $7,$24 + sltu $1,$7,$24 + multu $15,$15 # forward multiplication + addu $7,$24 + addu $1,$25 + sltu $24,$7,$24 + addu $2,$1 + addu $25,$24 + sltu $3,$2,$1 + addu $2,$25 + sltu $25,$2,$25 + addu $3,$25 + sw $7,5*4($4) + + mflo $24 + mfhi $25 + addu $2,$24 + sltu $1,$2,$24 + addu $25,$1 + addu $3,$25 + sw $2,6*4($4) + sw $3,7*4($4) + + .set noreorder + jr $31 + nop +.end bn_sqr_comba4 +#if defined(HAVE_GNU_STACK) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/bn_add.c b/crypto/bn/bn_add.c index 048a136b..92489b7d 100644 --- a/crypto/bn/bn_add.c +++ b/crypto/bn/bn_add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_add.c,v 1.13 2018/07/23 18:07:21 tb Exp $ */ +/* $OpenBSD: bn_add.c,v 1.24 2023/02/22 05:46:37 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,138 +56,263 @@ * [including the GNU Public Licence.] */ +#include +#include #include #include -#include "bn_lcl.h" +#include "bn_arch.h" +#include "bn_local.h" +#include "bn_internal.h" -int -BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) +/* + * bn_add_words() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b + * are both arrays of words. Any carry resulting from the addition is returned. + */ +#ifndef HAVE_BN_ADD_WORDS +BN_ULONG +bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n) { - int ret, r_neg; + BN_ULONG carry = 0; - bn_check_top(a); - bn_check_top(b); - - if (a->neg == b->neg) { - r_neg = a->neg; - ret = BN_uadd(r, a, b); - } else { - int cmp = BN_ucmp(a, b); + assert(n >= 0); + if (n <= 0) + return 0; - if (cmp > 0) { - r_neg = a->neg; - ret = BN_usub(r, a, b); - } else if (cmp < 0) { - r_neg = b->neg; - ret = BN_usub(r, b, a); - } else { - r_neg = 0; - BN_zero(r); - ret = 1; - } +#ifndef OPENSSL_SMALL_FOOTPRINT + while (n & ~3) { + bn_addw_addw(a[0], b[0], carry, &carry, &r[0]); + bn_addw_addw(a[1], b[1], carry, &carry, &r[1]); + bn_addw_addw(a[2], b[2], carry, &carry, &r[2]); + bn_addw_addw(a[3], b[3], carry, &carry, &r[3]); + a += 4; + b += 4; + r += 4; + n -= 4; } - - r->neg = r_neg; - bn_check_top(r); - return ret; +#endif + while (n) { + bn_addw_addw(a[0], b[0], carry, &carry, &r[0]); + a++; + b++; + r++; + n--; + } + return carry; } +#endif -int -BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) +/* + * bn_add() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b are both + * arrays of words (r may be the same as a or b). The length of a and b may + * differ, while r must be at least max(a_len, b_len) in length. Any carry + * resulting from the addition is returned. + */ +#ifndef HAVE_BN_ADD +BN_ULONG +bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, + int b_len) { - int max, min, dif; - const BN_ULONG *ap, *bp; - BN_ULONG *rp, carry, t1, t2; + int min_len, diff_len; + BN_ULONG carry = 0; - bn_check_top(a); - bn_check_top(b); + if ((min_len = a_len) > b_len) + min_len = b_len; - if (a->top < b->top) { - const BIGNUM *tmp; + diff_len = a_len - b_len; + + carry = bn_add_words(r, a, b, min_len); + + a += min_len; + b += min_len; + r += min_len; - tmp = a; - a = b; - b = tmp; + /* XXX - consider doing four at a time to match bn_add_words(). */ + while (diff_len < 0) { + /* Compute r[0] = 0 + b[0] + carry. */ + bn_addw(b[0], carry, &carry, &r[0]); + diff_len++; + b++; + r++; } - max = a->top; - min = b->top; - dif = max - min; - if (bn_wexpand(r, max + 1) == NULL) + /* XXX - consider doing four at a time to match bn_add_words(). */ + while (diff_len > 0) { + /* Compute r[0] = a[0] + 0 + carry. */ + bn_addw(a[0], carry, &carry, &r[0]); + diff_len--; + a++; + r++; + } + + return carry; +} +#endif + +/* + * bn_sub_words() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b + * are both arrays of words. Any borrow resulting from the subtraction is + * returned. + */ +#ifndef HAVE_BN_SUB_WORDS +BN_ULONG +bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n) +{ + BN_ULONG borrow = 0; + + assert(n >= 0); + if (n <= 0) return 0; - r->top = max; +#ifndef OPENSSL_SMALL_FOOTPRINT + while (n & ~3) { + bn_subw_subw(a[0], b[0], borrow, &borrow, &r[0]); + bn_subw_subw(a[1], b[1], borrow, &borrow, &r[1]); + bn_subw_subw(a[2], b[2], borrow, &borrow, &r[2]); + bn_subw_subw(a[3], b[3], borrow, &borrow, &r[3]); + a += 4; + b += 4; + r += 4; + n -= 4; + } +#endif + while (n) { + bn_subw_subw(a[0], b[0], borrow, &borrow, &r[0]); + a++; + b++; + r++; + n--; + } + return borrow; +} +#endif + +/* + * bn_sub() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b are both + * arrays of words (r may be the same as a or b). The length of a and b may + * differ, while r must be at least max(a_len, b_len) in length. Any borrow + * resulting from the subtraction is returned. + */ +#ifndef HAVE_BN_SUB +BN_ULONG +bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, + int b_len) +{ + int min_len, diff_len; + BN_ULONG borrow = 0; + + if ((min_len = a_len) > b_len) + min_len = b_len; + + diff_len = a_len - b_len; - ap = a->d; - bp = b->d; - rp = r->d; + borrow = bn_sub_words(r, a, b, min_len); - carry = bn_add_words(rp, ap, bp, min); - rp += min; - ap += min; + a += min_len; + b += min_len; + r += min_len; - while (dif) { - dif--; - t1 = *(ap++); - t2 = (t1 + carry) & BN_MASK2; - *(rp++) = t2; - carry &= (t2 == 0); + /* XXX - consider doing four at a time to match bn_sub_words. */ + while (diff_len < 0) { + /* Compute r[0] = 0 - b[0] - borrow. */ + bn_subw(0 - b[0], borrow, &borrow, &r[0]); + diff_len++; + b++; + r++; } - *rp = carry; - r->top += carry; + /* XXX - consider doing four at a time to match bn_sub_words. */ + while (diff_len > 0) { + /* Compute r[0] = a[0] - 0 - borrow. */ + bn_subw(a[0], borrow, &borrow, &r[0]); + diff_len--; + a++; + r++; + } + + return borrow; +} +#endif + +int +BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) +{ + BN_ULONG carry; + int rn; + + if ((rn = a->top) < b->top) + rn = b->top; + if (rn == INT_MAX) + return 0; + if (!bn_wexpand(r, rn + 1)) + return 0; + + carry = bn_add(r->d, rn, a->d, a->top, b->d, b->top); + r->d[rn] = carry; + + r->top = rn + (carry & 1); r->neg = 0; - bn_check_top(r); + return 1; } int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { - int max, min, dif; - const BN_ULONG *ap, *bp; - BN_ULONG t1, t2, borrow, *rp; + BN_ULONG borrow; + int rn; - bn_check_top(a); - bn_check_top(b); + if (a->top < b->top) { + BNerror(BN_R_ARG2_LT_ARG3); + return 0; + } + rn = a->top; - max = a->top; - min = b->top; - dif = max - min; + if (!bn_wexpand(r, rn)) + return 0; - if (dif < 0) { + borrow = bn_sub(r->d, rn, a->d, a->top, b->d, b->top); + if (borrow > 0) { BNerror(BN_R_ARG2_LT_ARG3); return 0; } - if (bn_wexpand(r, max) == NULL) - return 0; + r->top = rn; + r->neg = 0; + + bn_correct_top(r); + + return 1; +} - ap = a->d; - bp = b->d; - rp = r->d; +int +BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) +{ + int ret, r_neg; - borrow = bn_sub_words(rp, ap, bp, min); - ap += min; - rp += min; + if (a->neg == b->neg) { + r_neg = a->neg; + ret = BN_uadd(r, a, b); + } else { + int cmp = BN_ucmp(a, b); - while (dif) { - dif--; - t1 = *(ap++); - t2 = (t1 - borrow) & BN_MASK2; - *(rp++) = t2; - borrow &= (t1 == 0); + if (cmp > 0) { + r_neg = a->neg; + ret = BN_usub(r, a, b); + } else if (cmp < 0) { + r_neg = b->neg; + ret = BN_usub(r, b, a); + } else { + r_neg = 0; + BN_zero(r); + ret = 1; + } } - while (max > 0 && *--rp == 0) - max--; + BN_set_negative(r, r_neg); - r->top = max; - r->neg = 0; - bn_correct_top(r); - return 1; + return ret; } int @@ -195,9 +320,6 @@ BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) { int ret, r_neg; - bn_check_top(a); - bn_check_top(b); - if (a->neg != b->neg) { r_neg = a->neg; ret = BN_uadd(r, a, b); @@ -217,7 +339,7 @@ BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) } } - r->neg = r_neg; - bn_check_top(r); + BN_set_negative(r, r_neg); + return ret; } diff --git a/crypto/bn/bn_asm.c b/crypto/bn/bn_asm.c deleted file mode 100644 index 993fbb3d..00000000 --- a/crypto/bn/bn_asm.c +++ /dev/null @@ -1,1096 +0,0 @@ -/* $OpenBSD: bn_asm.c,v 1.15 2017/05/02 03:59:44 deraadt Exp $ */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#ifndef BN_DEBUG -# undef NDEBUG /* avoid conflicting definitions */ -# define NDEBUG -#endif - -#include -#include - -#include - -#include "bn_lcl.h" - -#if defined(BN_LLONG) || defined(BN_UMULT_HIGH) - -BN_ULONG -bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w) -{ - BN_ULONG c1 = 0; - - assert(num >= 0); - if (num <= 0) - return (c1); - -#ifndef OPENSSL_SMALL_FOOTPRINT - while (num & ~3) { - mul_add(rp[0], ap[0], w, c1); - mul_add(rp[1], ap[1], w, c1); - mul_add(rp[2], ap[2], w, c1); - mul_add(rp[3], ap[3], w, c1); - ap += 4; - rp += 4; - num -= 4; - } -#endif - while (num) { - mul_add(rp[0], ap[0], w, c1); - ap++; - rp++; - num--; - } - - return (c1); -} - -BN_ULONG -bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w) -{ - BN_ULONG c1 = 0; - - assert(num >= 0); - if (num <= 0) - return (c1); - -#ifndef OPENSSL_SMALL_FOOTPRINT - while (num & ~3) { - mul(rp[0], ap[0], w, c1); - mul(rp[1], ap[1], w, c1); - mul(rp[2], ap[2], w, c1); - mul(rp[3], ap[3], w, c1); - ap += 4; - rp += 4; - num -= 4; - } -#endif - while (num) { - mul(rp[0], ap[0], w, c1); - ap++; - rp++; - num--; - } - return (c1); -} - -void -bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n) -{ - assert(n >= 0); - if (n <= 0) - return; - -#ifndef OPENSSL_SMALL_FOOTPRINT - while (n & ~3) { - sqr(r[0], r[1], a[0]); - sqr(r[2], r[3], a[1]); - sqr(r[4], r[5], a[2]); - sqr(r[6], r[7], a[3]); - a += 4; - r += 8; - n -= 4; - } -#endif - while (n) { - sqr(r[0], r[1], a[0]); - a++; - r += 2; - n--; - } -} - -#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */ - -BN_ULONG -bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w) -{ - BN_ULONG c = 0; - BN_ULONG bl, bh; - - assert(num >= 0); - if (num <= 0) - return ((BN_ULONG)0); - - bl = LBITS(w); - bh = HBITS(w); - -#ifndef OPENSSL_SMALL_FOOTPRINT - while (num & ~3) { - mul_add(rp[0], ap[0], bl, bh, c); - mul_add(rp[1], ap[1], bl, bh, c); - mul_add(rp[2], ap[2], bl, bh, c); - mul_add(rp[3], ap[3], bl, bh, c); - ap += 4; - rp += 4; - num -= 4; - } -#endif - while (num) { - mul_add(rp[0], ap[0], bl, bh, c); - ap++; - rp++; - num--; - } - return (c); -} - -BN_ULONG -bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w) -{ - BN_ULONG carry = 0; - BN_ULONG bl, bh; - - assert(num >= 0); - if (num <= 0) - return ((BN_ULONG)0); - - bl = LBITS(w); - bh = HBITS(w); - -#ifndef OPENSSL_SMALL_FOOTPRINT - while (num & ~3) { - mul(rp[0], ap[0], bl, bh, carry); - mul(rp[1], ap[1], bl, bh, carry); - mul(rp[2], ap[2], bl, bh, carry); - mul(rp[3], ap[3], bl, bh, carry); - ap += 4; - rp += 4; - num -= 4; - } -#endif - while (num) { - mul(rp[0], ap[0], bl, bh, carry); - ap++; - rp++; - num--; - } - return (carry); -} - -void -bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n) -{ - assert(n >= 0); - if (n <= 0) - return; - -#ifndef OPENSSL_SMALL_FOOTPRINT - while (n & ~3) { - sqr64(r[0], r[1], a[0]); - sqr64(r[2], r[3], a[1]); - sqr64(r[4], r[5], a[2]); - sqr64(r[6], r[7], a[3]); - a += 4; - r += 8; - n -= 4; - } -#endif - while (n) { - sqr64(r[0], r[1], a[0]); - a++; - r += 2; - n--; - } -} - -#endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */ - -#if defined(BN_LLONG) && defined(BN_DIV2W) - -BN_ULONG -bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) -{ - return ((BN_ULONG)(((((BN_ULLONG)h) << BN_BITS2)|l)/(BN_ULLONG)d)); -} - -#else - -/* Divide h,l by d and return the result. */ -/* I need to test this some more :-( */ -BN_ULONG -bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) -{ - BN_ULONG dh, dl, q,ret = 0, th, tl, t; - int i, count = 2; - - if (d == 0) - return (BN_MASK2); - - i = BN_num_bits_word(d); - assert((i == BN_BITS2) || (h <= (BN_ULONG)1 << i)); - - i = BN_BITS2 - i; - if (h >= d) - h -= d; - - if (i) { - d <<= i; - h = (h << i) | (l >> (BN_BITS2 - i)); - l <<= i; - } - dh = (d & BN_MASK2h) >> BN_BITS4; - dl = (d & BN_MASK2l); - for (;;) { - if ((h >> BN_BITS4) == dh) - q = BN_MASK2l; - else - q = h / dh; - - th = q * dh; - tl = dl * q; - for (;;) { - t = h - th; - if ((t & BN_MASK2h) || - ((tl) <= ( - (t << BN_BITS4) | - ((l & BN_MASK2h) >> BN_BITS4)))) - break; - q--; - th -= dh; - tl -= dl; - } - t = (tl >> BN_BITS4); - tl = (tl << BN_BITS4) & BN_MASK2h; - th += t; - - if (l < tl) - th++; - l -= tl; - if (h < th) { - h += d; - q--; - } - h -= th; - - if (--count == 0) - break; - - ret = q << BN_BITS4; - h = ((h << BN_BITS4) | (l >> BN_BITS4)) & BN_MASK2; - l = (l & BN_MASK2l) << BN_BITS4; - } - ret |= q; - return (ret); -} -#endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */ - -#ifdef BN_LLONG -BN_ULONG -bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n) -{ - BN_ULLONG ll = 0; - - assert(n >= 0); - if (n <= 0) - return ((BN_ULONG)0); - -#ifndef OPENSSL_SMALL_FOOTPRINT - while (n & ~3) { - ll += (BN_ULLONG)a[0] + b[0]; - r[0] = (BN_ULONG)ll & BN_MASK2; - ll >>= BN_BITS2; - ll += (BN_ULLONG)a[1] + b[1]; - r[1] = (BN_ULONG)ll & BN_MASK2; - ll >>= BN_BITS2; - ll += (BN_ULLONG)a[2] + b[2]; - r[2] = (BN_ULONG)ll & BN_MASK2; - ll >>= BN_BITS2; - ll += (BN_ULLONG)a[3] + b[3]; - r[3] = (BN_ULONG)ll & BN_MASK2; - ll >>= BN_BITS2; - a += 4; - b += 4; - r += 4; - n -= 4; - } -#endif - while (n) { - ll += (BN_ULLONG)a[0] + b[0]; - r[0] = (BN_ULONG)ll & BN_MASK2; - ll >>= BN_BITS2; - a++; - b++; - r++; - n--; - } - return ((BN_ULONG)ll); -} -#else /* !BN_LLONG */ -BN_ULONG -bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n) -{ - BN_ULONG c, l, t; - - assert(n >= 0); - if (n <= 0) - return ((BN_ULONG)0); - - c = 0; -#ifndef OPENSSL_SMALL_FOOTPRINT - while (n & ~3) { - t = a[0]; - t = (t + c) & BN_MASK2; - c = (t < c); - l = (t + b[0]) & BN_MASK2; - c += (l < t); - r[0] = l; - t = a[1]; - t = (t + c) & BN_MASK2; - c = (t < c); - l = (t + b[1]) & BN_MASK2; - c += (l < t); - r[1] = l; - t = a[2]; - t = (t + c) & BN_MASK2; - c = (t < c); - l = (t + b[2]) & BN_MASK2; - c += (l < t); - r[2] = l; - t = a[3]; - t = (t + c) & BN_MASK2; - c = (t < c); - l = (t + b[3]) & BN_MASK2; - c += (l < t); - r[3] = l; - a += 4; - b += 4; - r += 4; - n -= 4; - } -#endif - while (n) { - t = a[0]; - t = (t + c) & BN_MASK2; - c = (t < c); - l = (t + b[0]) & BN_MASK2; - c += (l < t); - r[0] = l; - a++; - b++; - r++; - n--; - } - return ((BN_ULONG)c); -} -#endif /* !BN_LLONG */ - -BN_ULONG -bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n) -{ - BN_ULONG t1, t2; - int c = 0; - - assert(n >= 0); - if (n <= 0) - return ((BN_ULONG)0); - -#ifndef OPENSSL_SMALL_FOOTPRINT - while (n&~3) { - t1 = a[0]; - t2 = b[0]; - r[0] = (t1 - t2 - c) & BN_MASK2; - if (t1 != t2) - c = (t1 < t2); - t1 = a[1]; - t2 = b[1]; - r[1] = (t1 - t2 - c) & BN_MASK2; - if (t1 != t2) - c = (t1 < t2); - t1 = a[2]; - t2 = b[2]; - r[2] = (t1 - t2 - c) & BN_MASK2; - if (t1 != t2) - c = (t1 < t2); - t1 = a[3]; - t2 = b[3]; - r[3] = (t1 - t2 - c) & BN_MASK2; - if (t1 != t2) - c = (t1 < t2); - a += 4; - b += 4; - r += 4; - n -= 4; - } -#endif - while (n) { - t1 = a[0]; - t2 = b[0]; - r[0] = (t1 - t2 - c) & BN_MASK2; - if (t1 != t2) - c = (t1 < t2); - a++; - b++; - r++; - n--; - } - return (c); -} - -#if defined(BN_MUL_COMBA) && !defined(OPENSSL_SMALL_FOOTPRINT) - -#undef bn_mul_comba8 -#undef bn_mul_comba4 -#undef bn_sqr_comba8 -#undef bn_sqr_comba4 - -/* mul_add_c(a,b,c0,c1,c2) -- c+=a*b for three word number c=(c2,c1,c0) */ -/* mul_add_c2(a,b,c0,c1,c2) -- c+=2*a*b for three word number c=(c2,c1,c0) */ -/* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */ -/* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */ - -#ifdef BN_LLONG -/* - * Keep in mind that additions to multiplication result can not - * overflow, because its high half cannot be all-ones. - */ -#define mul_add_c(a,b,c0,c1,c2) do { \ - BN_ULONG hi; \ - BN_ULLONG t = (BN_ULLONG)(a)*(b); \ - t += c0; /* no carry */ \ - c0 = (BN_ULONG)Lw(t); \ - hi = (BN_ULONG)Hw(t); \ - c1 = (c1+hi)&BN_MASK2; if (c1= np[num - 1]) { - c0 = bn_sub_words(rp, tp, np, num); - if (tp[num] != 0 || c0 == 0) { - goto out; - } - } - memcpy(rp, tp, num * sizeof(BN_ULONG)); -out: - freezero(tp, (num + 2) * sizeof(BN_ULONG)); - return 1; -} -#else -/* - * Return value of 0 indicates that multiplication/convolution was not - * performed to signal the caller to fall down to alternative/original - * code-path. - */ -int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num) - { return 0; -} -#endif /* OPENSSL_BN_ASM_MONT */ -#endif - -#else /* !BN_MUL_COMBA */ - -/* hmm... is it faster just to do a multiply? */ -#undef bn_sqr_comba4 -void -bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a) -{ - BN_ULONG t[8]; - bn_sqr_normal(r, a, 4, t); -} - -#undef bn_sqr_comba8 -void -bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a) -{ - BN_ULONG t[16]; - bn_sqr_normal(r, a, 8, t); -} - -void -bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) -{ - r[4] = bn_mul_words(&(r[0]), a, 4, b[0]); - r[5] = bn_mul_add_words(&(r[1]), a, 4, b[1]); - r[6] = bn_mul_add_words(&(r[2]), a, 4, b[2]); - r[7] = bn_mul_add_words(&(r[3]), a, 4, b[3]); -} - -void -bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) -{ - r[8] = bn_mul_words(&(r[0]), a, 8, b[0]); - r[9] = bn_mul_add_words(&(r[1]), a, 8, b[1]); - r[10] = bn_mul_add_words(&(r[2]), a, 8, b[2]); - r[11] = bn_mul_add_words(&(r[3]), a, 8, b[3]); - r[12] = bn_mul_add_words(&(r[4]), a, 8, b[4]); - r[13] = bn_mul_add_words(&(r[5]), a, 8, b[5]); - r[14] = bn_mul_add_words(&(r[6]), a, 8, b[6]); - r[15] = bn_mul_add_words(&(r[7]), a, 8, b[7]); -} - -#ifdef OPENSSL_NO_ASM -#ifdef OPENSSL_BN_ASM_MONT -int -bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, - const BN_ULONG *np, const BN_ULONG *n0p, int num) -{ - BN_ULONG c0, c1, *tp, n0 = *n0p; - int i = 0, j; - - tp = calloc(NULL, num + 2, sizeof(BN_ULONG)); - if (tp == NULL) - return 0; - - for (i = 0; i < num; i++) { - c0 = bn_mul_add_words(tp, ap, num, bp[i]); - c1 = (tp[num] + c0) & BN_MASK2; - tp[num] = c1; - tp[num + 1] = (c1 < c0 ? 1 : 0); - - c0 = bn_mul_add_words(tp, np, num, tp[0] * n0); - c1 = (tp[num] + c0) & BN_MASK2; - tp[num] = c1; - tp[num + 1] += (c1 < c0 ? 1 : 0); - for (j = 0; j <= num; j++) - tp[j] = tp[j + 1]; - } - - if (tp[num] != 0 || tp[num - 1] >= np[num - 1]) { - c0 = bn_sub_words(rp, tp, np, num); - if (tp[num] != 0 || c0 == 0) { - goto out; - } - } - memcpy(rp, tp, num * sizeof(BN_ULONG)); -out: - freezero(tp, (num + 2) * sizeof(BN_ULONG)); - return 1; -} -#else -int -bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, - const BN_ULONG *np, const BN_ULONG *n0, int num) -{ - return 0; -} -#endif /* OPENSSL_BN_ASM_MONT */ -#endif - -#endif /* !BN_MUL_COMBA */ diff --git a/crypto/bn/bn_blind.c b/crypto/bn/bn_blind.c index ecd67182..61d0cf7a 100644 --- a/crypto/bn/bn_blind.c +++ b/crypto/bn/bn_blind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_blind.c,v 1.17 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bn_blind.c,v 1.20 2023/03/07 09:27:10 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -115,7 +115,7 @@ #include -#include "bn_lcl.h" +#include "bn_local.h" #define BN_BLINDING_COUNTER 32 @@ -141,7 +141,6 @@ BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod) { BN_BLINDING *ret = NULL; - bn_check_top(mod); if ((ret = calloc(1, sizeof(BN_BLINDING))) == NULL) { BNerror(ERR_R_MALLOC_FAILURE); @@ -181,10 +180,10 @@ BN_BLINDING_free(BN_BLINDING *r) if (r == NULL) return; - BN_clear_free(r->A); - BN_clear_free(r->Ai); - BN_clear_free(r->e); - BN_clear_free(r->mod); + BN_free(r->A); + BN_free(r->Ai); + BN_free(r->e); + BN_free(r->mod); free(r); } @@ -232,7 +231,6 @@ BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) { int ret = 1; - bn_check_top(n); if ((b->A == NULL) || (b->Ai == NULL)) { BNerror(BN_R_NOT_INITIALIZED); @@ -267,7 +265,6 @@ BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) { int ret; - bn_check_top(n); if (r != NULL) ret = BN_mod_mul(n, n, r, b->mod, ctx); @@ -279,7 +276,6 @@ BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx); } - bn_check_top(n); return (ret); } diff --git a/crypto/bn/bn_bpsw.c b/crypto/bn/bn_bpsw.c index 2f8cbba3..9220339f 100644 --- a/crypto/bn/bn_bpsw.c +++ b/crypto/bn/bn_bpsw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_bpsw.c,v 1.7 2022/08/31 21:34:14 tb Exp $ */ +/* $OpenBSD: bn_bpsw.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ /* * Copyright (c) 2022 Martin Grenouilloux * Copyright (c) 2022 Theo Buehler @@ -18,7 +18,7 @@ #include -#include "bn_lcl.h" +#include "bn_local.h" #include "bn_prime.h" /* diff --git a/crypto/bn/bn_ctx.c b/crypto/bn/bn_ctx.c index 0d64ccab..5b05e018 100644 --- a/crypto/bn/bn_ctx.c +++ b/crypto/bn/bn_ctx.c @@ -1,481 +1,162 @@ -/* $OpenBSD: bn_ctx.c,v 1.16 2019/08/20 10:59:09 schwarze Exp $ */ -/* Written by Ulf Moeller for the OpenSSL project. */ -/* ==================================================================== - * Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. +/* $OpenBSD: bn_ctx.c,v 1.20 2023/01/14 15:23:27 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#if !defined(BN_CTX_DEBUG) && !defined(BN_DEBUG) -#ifndef NDEBUG -#define NDEBUG -#endif -#endif - -#include +#include #include #include - #include -#include "bn_lcl.h" - -/* TODO list - * - * 1. Check a bunch of "(words+1)" type hacks in various bignum functions and - * check they can be safely removed. - * - Check +1 and other ugliness in BN_from_montgomery() - * - * 2. Consider allowing a BN_new_ex() that, at least, lets you specify an - * appropriate 'block' size that will be honoured by bn_expand_internal() to - * prevent piddly little reallocations. OTOH, profiling bignum expansions in - * BN_CTX doesn't show this to be a big issue. - */ - -/* How many bignums are in each "pool item"; */ -#define BN_CTX_POOL_SIZE 16 -/* The stack frame info is resizing, set a first-time expansion size; */ -#define BN_CTX_START_FRAMES 32 - -/***********/ -/* BN_POOL */ -/***********/ - -/* A bundle of bignums that can be linked with other bundles */ -typedef struct bignum_pool_item { - /* The bignum values */ - BIGNUM vals[BN_CTX_POOL_SIZE]; - /* Linked-list admin */ - struct bignum_pool_item *prev, *next; -} BN_POOL_ITEM; - -/* A linked-list of bignums grouped in bundles */ -typedef struct bignum_pool { - /* Linked-list admin */ - BN_POOL_ITEM *head, *current, *tail; - /* Stack depth and allocation size */ - unsigned used, size; -} BN_POOL; - -static void BN_POOL_init(BN_POOL *); -static void BN_POOL_finish(BN_POOL *); -#ifndef OPENSSL_NO_DEPRECATED -static void BN_POOL_reset(BN_POOL *); -#endif -static BIGNUM * BN_POOL_get(BN_POOL *); -static void BN_POOL_release(BN_POOL *, unsigned int); - -/************/ -/* BN_STACK */ -/************/ - -/* A wrapper to manage the "stack frames" */ -typedef struct bignum_ctx_stack { - /* Array of indexes into the bignum stack */ - unsigned int *indexes; - /* Number of stack frames, and the size of the allocated array */ - unsigned int depth, size; -} BN_STACK; - -static void BN_STACK_init(BN_STACK *); -static void BN_STACK_finish(BN_STACK *); -#ifndef OPENSSL_NO_DEPRECATED -static void BN_STACK_reset(BN_STACK *); -#endif -static int BN_STACK_push(BN_STACK *, unsigned int); -static unsigned int BN_STACK_pop(BN_STACK *); +#include "bn_local.h" -/**********/ -/* BN_CTX */ -/**********/ +#define BN_CTX_INITIAL_LEN 8 -/* The opaque BN_CTX type */ struct bignum_ctx { - /* The bignum bundles */ - BN_POOL pool; - /* The "stack frames", if you will */ - BN_STACK stack; - /* The number of bignums currently assigned */ - unsigned int used; - /* Depth of stack overflow */ - int err_stack; - /* Block "gets" until an "end" (compatibility behaviour) */ - int too_many; -}; + BIGNUM **bignums; + uint8_t *groups; + uint8_t group; + size_t index; + size_t len; -/* Enable this to find BN_CTX bugs */ -#ifdef BN_CTX_DEBUG -static const char *ctxdbg_cur = NULL; + int error; +}; -static void -ctxdbg(BN_CTX *ctx) +static int +bn_ctx_grow(BN_CTX *bctx) { - unsigned int bnidx = 0, fpidx = 0; - BN_POOL_ITEM *item = ctx->pool.head; - BN_STACK *stack = &ctx->stack; + BIGNUM **bignums = NULL; + uint8_t *groups = NULL; + size_t len; - fprintf(stderr, "(%08x): ", (unsigned int)ctx); - while (bnidx < ctx->used) { - fprintf(stderr, "%03x ", - item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax); - if (!(bnidx % BN_CTX_POOL_SIZE)) - item = item->next; - } - fprintf(stderr, "\n"); - bnidx = 0; - fprintf(stderr, " : "); - while (fpidx < stack->depth) { - while (bnidx++ < stack->indexes[fpidx]) - fprintf(stderr, " "); - fprintf(stderr, "^^^ "); - bnidx++; - fpidx++; + if ((len = bctx->len) == 0) { + len = BN_CTX_INITIAL_LEN; + } else { + if (SIZE_MAX - len < len) + return 0; + len *= 2; } - fprintf(stderr, "\n"); -} -#define CTXDBG_ENTRY(str, ctx) \ - do { \ - ctxdbg_cur = (str); \ - fprintf(stderr, "Starting %s\n", ctxdbg_cur); \ - ctxdbg(ctx); \ - } while(0) -#define CTXDBG_EXIT(ctx) \ - do { \ - fprintf(stderr, "Ending %s\n", ctxdbg_cur); \ - ctxdbg(ctx); \ - } while(0) + if ((bignums = recallocarray(bctx->bignums, bctx->len, len, + sizeof(bctx->bignums[0]))) == NULL) + return 0; + bctx->bignums = bignums; -#define CTXDBG_RET(ctx,ret) -#else -#define CTXDBG_ENTRY(str, ctx) -#define CTXDBG_EXIT(ctx) -#define CTXDBG_RET(ctx,ret) -#endif + if ((groups = reallocarray(bctx->groups, len, + sizeof(bctx->groups[0]))) == NULL) + return 0; + bctx->groups = groups; -/* This function is an evil legacy and should not be used. This implementation - * is WYSIWYG, though I've done my best. */ -#ifndef OPENSSL_NO_DEPRECATED -void -BN_CTX_init(BN_CTX *ctx) -{ - /* Assume the caller obtained the context via BN_CTX_new() and so is - * trying to reset it for use. Nothing else makes sense, least of all - * binary compatibility from a time when they could declare a static - * variable. */ - BN_POOL_reset(&ctx->pool); - BN_STACK_reset(&ctx->stack); - ctx->used = 0; - ctx->err_stack = 0; - ctx->too_many = 0; + bctx->len = len; + + return 1; } -#endif BN_CTX * BN_CTX_new(void) { - BN_CTX *ret = malloc(sizeof(BN_CTX)); - if (!ret) { - BNerror(ERR_R_MALLOC_FAILURE); - return NULL; - } - - /* Initialise the structure */ - BN_POOL_init(&ret->pool); - BN_STACK_init(&ret->stack); - ret->used = 0; - ret->err_stack = 0; - ret->too_many = 0; - return ret; + return calloc(1, sizeof(struct bignum_ctx)); } void -BN_CTX_free(BN_CTX *ctx) +BN_CTX_init(BN_CTX *bctx) { - if (ctx == NULL) - return; -#ifdef BN_CTX_DEBUG - { - BN_POOL_ITEM *pool = ctx->pool.head; - fprintf(stderr, "BN_CTX_free, stack-size=%d, pool-bignums=%d\n", - ctx->stack.size, ctx->pool.size); - fprintf(stderr, "dmaxs: "); - while (pool) { - unsigned loop = 0; - while (loop < BN_CTX_POOL_SIZE) - fprintf(stderr, "%02x ", - pool->vals[loop++].dmax); - pool = pool->next; - } - fprintf(stderr, "\n"); - } -#endif - BN_STACK_finish(&ctx->stack); - BN_POOL_finish(&ctx->pool); - free(ctx); + memset(bctx, 0, sizeof(*bctx)); } void -BN_CTX_start(BN_CTX *ctx) +BN_CTX_free(BN_CTX *bctx) { - CTXDBG_ENTRY("BN_CTX_start", ctx); + size_t i; - /* If we're already overflowing ... */ - if (ctx->err_stack || ctx->too_many) - ctx->err_stack++; - /* (Try to) get a new frame pointer */ - else if (!BN_STACK_push(&ctx->stack, ctx->used)) { - BNerror(BN_R_TOO_MANY_TEMPORARY_VARIABLES); - ctx->err_stack++; - } - CTXDBG_EXIT(ctx); -} - -void -BN_CTX_end(BN_CTX *ctx) -{ - if (ctx == NULL) + if (bctx == NULL) return; - CTXDBG_ENTRY("BN_CTX_end", ctx); - - if (ctx->err_stack) - ctx->err_stack--; - else { - unsigned int fp = BN_STACK_pop(&ctx->stack); - /* Does this stack frame have anything to release? */ - if (fp < ctx->used) - BN_POOL_release(&ctx->pool, ctx->used - fp); - ctx->used = fp; - /* Unjam "too_many" in case "get" had failed */ - ctx->too_many = 0; - } - CTXDBG_EXIT(ctx); -} - -BIGNUM * -BN_CTX_get(BN_CTX *ctx) -{ - BIGNUM *ret; - - CTXDBG_ENTRY("BN_CTX_get", ctx); - - if (ctx->err_stack || ctx->too_many) - return NULL; - if ((ret = BN_POOL_get(&ctx->pool)) == NULL) { - /* Setting too_many prevents repeated "get" attempts from - * cluttering the error stack. */ - ctx->too_many = 1; - BNerror(BN_R_TOO_MANY_TEMPORARY_VARIABLES); - return NULL; + for (i = 0; i < bctx->len; i++) { + BN_free(bctx->bignums[i]); + bctx->bignums[i] = NULL; } - /* OK, make sure the returned bignum is "zero" */ - BN_zero(ret); - ctx->used++; - CTXDBG_RET(ctx, ret); - return ret; -} -/************/ -/* BN_STACK */ -/************/ + free(bctx->bignums); + free(bctx->groups); -static void -BN_STACK_init(BN_STACK *st) -{ - st->indexes = NULL; - st->depth = st->size = 0; + freezero(bctx, sizeof(*bctx)); } -static void -BN_STACK_finish(BN_STACK *st) +void +BN_CTX_start(BN_CTX *bctx) { - if (st->size) - free(st->indexes); -} + bctx->group++; -#ifndef OPENSSL_NO_DEPRECATED -static void -BN_STACK_reset(BN_STACK *st) -{ - st->depth = 0; -} -#endif - -static int -BN_STACK_push(BN_STACK *st, unsigned int idx) -{ - if (st->depth == st->size) - /* Need to expand */ - { - unsigned int newsize = (st->size ? - (st->size * 3 / 2) : BN_CTX_START_FRAMES); - unsigned int *newitems = reallocarray(NULL, - newsize, sizeof(unsigned int)); - if (!newitems) - return 0; - if (st->depth) - memcpy(newitems, st->indexes, st->depth * - sizeof(unsigned int)); - if (st->size) - free(st->indexes); - st->indexes = newitems; - st->size = newsize; + if (bctx->group == 0) { + BNerror(BN_R_TOO_MANY_TEMPORARY_VARIABLES); + bctx->error = 1; + return; } - st->indexes[(st->depth)++] = idx; - return 1; } -static unsigned int -BN_STACK_pop(BN_STACK *st) +BIGNUM * +BN_CTX_get(BN_CTX *bctx) { - return st->indexes[--(st->depth)]; -} - -/***********/ -/* BN_POOL */ -/***********/ + BIGNUM *bn = NULL; -static void -BN_POOL_init(BN_POOL *p) -{ - p->head = p->current = p->tail = NULL; - p->used = p->size = 0; -} + if (bctx->error) + return NULL; -static void -BN_POOL_finish(BN_POOL *p) -{ - while (p->head) { - unsigned int loop = 0; - BIGNUM *bn = p->head->vals; - while (loop++ < BN_CTX_POOL_SIZE) { - if (bn->d) - BN_clear_free(bn); - bn++; - } - p->current = p->head->next; - free(p->head); - p->head = p->current; + if (bctx->group == 0) { + BNerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + bctx->error = 1; + return NULL; } -} -#ifndef OPENSSL_NO_DEPRECATED -static void -BN_POOL_reset(BN_POOL *p) -{ - BN_POOL_ITEM *item = p->head; - while (item) { - unsigned int loop = 0; - BIGNUM *bn = item->vals; - while (loop++ < BN_CTX_POOL_SIZE) { - if (bn->d) - BN_clear(bn); - bn++; + if (bctx->index == bctx->len) { + if (!bn_ctx_grow(bctx)) { + BNerror(BN_R_TOO_MANY_TEMPORARY_VARIABLES); + bctx->error = 1; + return NULL; } - item = item->next; } - p->current = p->head; - p->used = 0; -} -#endif -static BIGNUM * -BN_POOL_get(BN_POOL *p) -{ - if (p->used == p->size) { - BIGNUM *bn; - unsigned int loop = 0; - BN_POOL_ITEM *item = malloc(sizeof(BN_POOL_ITEM)); - if (!item) + if ((bn = bctx->bignums[bctx->index]) == NULL) { + if ((bn = BN_new()) == NULL) { + BNerror(BN_R_TOO_MANY_TEMPORARY_VARIABLES); + bctx->error = 1; return NULL; - /* Initialise the structure */ - bn = item->vals; - while (loop++ < BN_CTX_POOL_SIZE) - BN_init(bn++); - item->prev = p->tail; - item->next = NULL; - /* Link it in */ - if (!p->head) - p->head = p->current = p->tail = item; - else { - p->tail->next = item; - p->tail = item; - p->current = item; } - p->size += BN_CTX_POOL_SIZE; - p->used++; - /* Return the first bignum from the new pool */ - return item->vals; + bctx->bignums[bctx->index] = bn; } - if (!p->used) - p->current = p->head; - else if ((p->used % BN_CTX_POOL_SIZE) == 0) - p->current = p->current->next; - return p->current->vals + ((p->used++) % BN_CTX_POOL_SIZE); + bctx->groups[bctx->index] = bctx->group; + bctx->index++; + + BN_zero(bn); + + return bn; } -static void -BN_POOL_release(BN_POOL *p, unsigned int num) +void +BN_CTX_end(BN_CTX *bctx) { - unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE; + if (bctx == NULL || bctx->error || bctx->group == 0) + return; - p->used -= num; - while (num--) { - bn_check_top(p->current->vals + offset); - if (!offset) { - offset = BN_CTX_POOL_SIZE - 1; - p->current = p->current->prev; - } else - offset--; + while (bctx->index > 0 && bctx->groups[bctx->index - 1] == bctx->group) { + BN_zero(bctx->bignums[bctx->index - 1]); + bctx->groups[bctx->index - 1] = 0; + bctx->index--; } + + bctx->group--; } diff --git a/crypto/bn/bn_depr.c b/crypto/bn/bn_depr.c deleted file mode 100644 index dc5c2abe..00000000 --- a/crypto/bn/bn_depr.c +++ /dev/null @@ -1,115 +0,0 @@ -/* $OpenBSD: bn_depr.c,v 1.7 2014/10/18 17:20:40 jsing Exp $ */ -/* ==================================================================== - * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -/* Support for deprecated functions goes here - static linkage will only slurp - * this code if applications are using them directly. */ - -#include -#include - -#include - -#include "bn_lcl.h" - -#ifndef OPENSSL_NO_DEPRECATED -BIGNUM * -BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add, - const BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg) -{ - BN_GENCB cb; - BIGNUM *rnd = NULL; - int found = 0; - - BN_GENCB_set_old(&cb, callback, cb_arg); - - if (ret == NULL) { - if ((rnd = BN_new()) == NULL) - goto err; - } else - rnd = ret; - if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb)) - goto err; - - /* we have a prime :-) */ - found = 1; - -err: - if (!found && (ret == NULL) && (rnd != NULL)) - BN_free(rnd); - return (found ? rnd : NULL); -} - -int -BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int, void *), - BN_CTX *ctx_passed, void *cb_arg) -{ - BN_GENCB cb; - - BN_GENCB_set_old(&cb, callback, cb_arg); - return BN_is_prime_ex(a, checks, ctx_passed, &cb); -} - -int -BN_is_prime_fasttest(const BIGNUM *a, int checks, - void (*callback)(int, int, void *), BN_CTX *ctx_passed, void *cb_arg, - int do_trial_division) -{ - BN_GENCB cb; - - BN_GENCB_set_old(&cb, callback, cb_arg); - return BN_is_prime_fasttest_ex(a, checks, ctx_passed, - do_trial_division, &cb); -} -#endif diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c index 1249a119..692e6184 100644 --- a/crypto/bn/bn_div.c +++ b/crypto/bn/bn_div.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_div.c,v 1.25 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bn_div.c,v 1.39 2023/02/16 10:41:03 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,6 +56,7 @@ * [including the GNU Public Licence.] */ +#include #include #include @@ -63,149 +64,264 @@ #include #include -#include "bn_lcl.h" - -#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \ - && !defined(BN_DIV3W) -# if defined(__GNUC__) && __GNUC__>=2 -# if defined(__i386) || defined (__i386__) - /* - * There were two reasons for implementing this template: - * - GNU C generates a call to a function (__udivdi3 to be exact) - * in reply to ((((BN_ULLONG)n0)< - */ -#undef bn_div_words -# define bn_div_words(n0,n1,d0) \ - ({ asm volatile ( \ - "divl %4" \ - : "=a"(q), "=d"(rem) \ - : "a"(n1), "d"(n0), "g"(d0) \ - : "cc"); \ - q; \ - }) -# define REMAINDER_IS_ALREADY_CALCULATED -# elif defined(__x86_64) && defined(_LP64) - /* - * Same story here, but it's 128-bit by 64-bit division. Wow! - * - */ -# undef bn_div_words -# define bn_div_words(n0,n1,d0) \ - ({ asm volatile ( \ - "divq %4" \ - : "=a"(q), "=d"(rem) \ - : "a"(n1), "d"(n0), "g"(d0) \ - : "cc"); \ - q; \ - }) -# define REMAINDER_IS_ALREADY_CALCULATED -# endif /* __ */ -# endif /* __GNUC__ */ -#endif /* OPENSSL_NO_ASM */ - - -/* BN_div computes dv := num / divisor, rounding towards - * zero, and sets up rm such that dv*divisor + rm = num holds. - * Thus: - * dv->neg == num->neg ^ divisor->neg (unless the result is zero) - * rm->neg == num->neg (unless the remainder is zero) - * If 'dv' or 'rm' is NULL, the respective value is not returned. +#include "bn_arch.h" +#include "bn_local.h" +#include "bn_internal.h" + +BN_ULONG bn_div_3_words(const BN_ULONG *m, BN_ULONG d1, BN_ULONG d0); + +#ifndef HAVE_BN_DIV_WORDS +#if defined(BN_LLONG) && defined(BN_DIV2W) + +BN_ULONG +bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) +{ + return ((BN_ULONG)(((((BN_ULLONG)h) << BN_BITS2)|l)/(BN_ULLONG)d)); +} + +#else + +/* Divide h,l by d and return the result. */ +/* I need to test this some more :-( */ +BN_ULONG +bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) +{ + BN_ULONG dh, dl, q,ret = 0, th, tl, t; + int i, count = 2; + + if (d == 0) + return (BN_MASK2); + + i = BN_num_bits_word(d); + assert((i == BN_BITS2) || (h <= (BN_ULONG)1 << i)); + + i = BN_BITS2 - i; + if (h >= d) + h -= d; + + if (i) { + d <<= i; + h = (h << i) | (l >> (BN_BITS2 - i)); + l <<= i; + } + dh = (d & BN_MASK2h) >> BN_BITS4; + dl = (d & BN_MASK2l); + for (;;) { + if ((h >> BN_BITS4) == dh) + q = BN_MASK2l; + else + q = h / dh; + + th = q * dh; + tl = dl * q; + for (;;) { + t = h - th; + if ((t & BN_MASK2h) || + ((tl) <= ( + (t << BN_BITS4) | + ((l & BN_MASK2h) >> BN_BITS4)))) + break; + q--; + th -= dh; + tl -= dl; + } + t = (tl >> BN_BITS4); + tl = (tl << BN_BITS4) & BN_MASK2h; + th += t; + + if (l < tl) + th++; + l -= tl; + if (h < th) { + h += d; + q--; + } + h -= th; + + if (--count == 0) + break; + + ret = q << BN_BITS4; + h = ((h << BN_BITS4) | (l >> BN_BITS4)) & BN_MASK2; + l = (l & BN_MASK2l) << BN_BITS4; + } + ret |= q; + return (ret); +} +#endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */ +#endif + +/* + * Divide a double word (h:l) by d, returning the quotient q and the remainder + * r, such that q * d + r is equal to the numerator. + */ +#ifndef HAVE_BN_DIV_REM_WORDS +#ifndef HAVE_BN_DIV_REM_WORDS_INLINE +static inline void +bn_div_rem_words_inline(BN_ULONG h, BN_ULONG l, BN_ULONG d, BN_ULONG *out_q, + BN_ULONG *out_r) +{ + BN_ULONG q, r; + + q = bn_div_words(h, l, d); + r = (l - q * d) & BN_MASK2; + + *out_q = q; + *out_r = r; +} +#endif + +void +bn_div_rem_words(BN_ULONG h, BN_ULONG l, BN_ULONG d, BN_ULONG *out_q, + BN_ULONG *out_r) +{ + bn_div_rem_words_inline(h, l, d, out_q, out_r); +} +#endif + +#ifndef HAVE_BN_DIV_3_WORDS + +/* + * Interface is somewhat quirky, |m| is pointer to most significant limb, + * and less significant limb is referred at |m[-1]|. This means that caller + * is responsible for ensuring that |m[-1]| is valid. Second condition that + * has to be met is that |d0|'s most significant bit has to be set. Or in + * other words divisor has to be "bit-aligned to the left." The subroutine + * considers four limbs, two of which are "overlapping," hence the name... + */ +BN_ULONG +bn_div_3_words(const BN_ULONG *m, BN_ULONG d1, BN_ULONG d0) +{ + BN_ULONG n0, n1, q, t2h, t2l; + BN_ULONG rem = 0; + + n0 = m[0]; + n1 = m[-1]; + + if (n0 == d0) + return BN_MASK2; + + /* n0 < d0 */ + bn_div_rem_words(n0, n1, d0, &q, &rem); + + bn_mulw(d1, q, &t2h, &t2l); + + for (;;) { + if (t2h < rem || (t2h == rem && t2l <= m[-2])) + break; + q--; + rem += d0; + if (rem < d0) + break; /* don't let rem overflow */ + if (t2l < d1) + t2h--; + t2l -= d1; + } + + return q; +} +#endif /* !HAVE_BN_DIV_3_WORDS */ + +/* + * BN_div_internal computes quotient := numerator / divisor, rounding towards + * zero and setting remainder such that quotient * divisor + remainder equals + * the numerator. Thus: + * + * quotient->neg == numerator->neg ^ divisor->neg (unless result is zero) + * remainder->neg == numerator->neg (unless the remainder is zero) + * + * If either the quotient or remainder is NULL, the respective value is not + * returned. */ static int -BN_div_internal(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, - BN_CTX *ctx, int ct) +BN_div_internal(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, + const BIGNUM *divisor, BN_CTX *ctx, int ct) { - int norm_shift, i, loop; + int norm_shift, i, loop, r_neg; BIGNUM *tmp, wnum, *snum, *sdiv, *res; BN_ULONG *resp, *wnump; BN_ULONG d0, d1; int num_n, div_n; int no_branch = 0; + int ret = 0; + + BN_CTX_start(ctx); - /* Invalid zero-padding would have particularly bad consequences - * in the case of 'num', so don't just rely on bn_check_top() for this one - * (bn_check_top() works only for BN_DEBUG builds) */ - if (num->top > 0 && num->d[num->top - 1] == 0) { + /* Invalid zero-padding would have particularly bad consequences. */ + if (numerator->top > 0 && numerator->d[numerator->top - 1] == 0) { BNerror(BN_R_NOT_INITIALIZED); - return 0; + goto err; } - bn_check_top(num); - if (ct) no_branch = 1; - bn_check_top(dv); - bn_check_top(rm); - /* bn_check_top(num); */ /* 'num' has been checked already */ - bn_check_top(divisor); - if (BN_is_zero(divisor)) { BNerror(BN_R_DIV_BY_ZERO); - return (0); + goto err; } - if (!no_branch && BN_ucmp(num, divisor) < 0) { - if (rm != NULL) { - if (BN_copy(rm, num) == NULL) - return (0); + if (!no_branch) { + if (BN_ucmp(numerator, divisor) < 0) { + if (remainder != NULL) { + if (BN_copy(remainder, numerator) == NULL) + goto err; + } + if (quotient != NULL) + BN_zero(quotient); + + goto done; } - if (dv != NULL) - BN_zero(dv); - return (1); } - BN_CTX_start(ctx); - tmp = BN_CTX_get(ctx); - snum = BN_CTX_get(ctx); - sdiv = BN_CTX_get(ctx); - if (dv == NULL) - res = BN_CTX_get(ctx); - else - res = dv; - if (tmp == NULL || snum == NULL || sdiv == NULL || res == NULL) + if ((tmp = BN_CTX_get(ctx)) == NULL) goto err; + if ((snum = BN_CTX_get(ctx)) == NULL) + goto err; + if ((sdiv = BN_CTX_get(ctx)) == NULL) + goto err; + if ((res = quotient) == NULL) { + if ((res = BN_CTX_get(ctx)) == NULL) + goto err; + } - /* First we normalise the numbers */ - norm_shift = BN_BITS2 - ((BN_num_bits(divisor)) % BN_BITS2); - if (!(BN_lshift(sdiv, divisor, norm_shift))) + /* First we normalise the numbers. */ + norm_shift = BN_BITS2 - BN_num_bits(divisor) % BN_BITS2; + if (!BN_lshift(sdiv, divisor, norm_shift)) goto err; sdiv->neg = 0; norm_shift += BN_BITS2; - if (!(BN_lshift(snum, num, norm_shift))) + if (!BN_lshift(snum, numerator, norm_shift)) goto err; snum->neg = 0; if (no_branch) { - /* Since we don't know whether snum is larger than sdiv, - * we pad snum with enough zeroes without changing its - * value. + /* + * Since we don't know whether snum is larger than sdiv, we pad + * snum with enough zeroes without changing its value. */ if (snum->top <= sdiv->top + 1) { - if (bn_wexpand(snum, sdiv->top + 2) == NULL) + if (!bn_wexpand(snum, sdiv->top + 2)) goto err; for (i = snum->top; i < sdiv->top + 2; i++) snum->d[i] = 0; snum->top = sdiv->top + 2; } else { - if (bn_wexpand(snum, snum->top + 1) == NULL) + if (!bn_wexpand(snum, snum->top + 1)) goto err; snum->d[snum->top] = 0; - snum->top ++; + snum->top++; } } div_n = sdiv->top; num_n = snum->top; loop = num_n - div_n; - /* Lets setup a 'window' into snum - * This is the part that corresponds to the current - * 'area' being divided */ + + /* + * Setup a 'window' into snum - this is the part that corresponds to the + * current 'area' being divided. + */ wnum.neg = 0; wnum.d = &(snum->d[loop]); wnum.top = div_n; @@ -222,10 +338,10 @@ BN_div_internal(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor wnump = &(snum->d[num_n - 1]); /* Setup to 'res' */ - res->neg = (num->neg ^ divisor->neg); if (!bn_wexpand(res, (loop + 1))) goto err; res->top = loop - no_branch; + r_neg = numerator->neg ^ divisor->neg; resp = &(res->d[loop - 1]); /* space for temp */ @@ -234,18 +350,16 @@ BN_div_internal(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor if (!no_branch) { if (BN_ucmp(&wnum, sdiv) >= 0) { - /* If BN_DEBUG_RAND is defined BN_ucmp changes (via - * bn_pollute) the const bignum arguments => - * clean the values between top and max again */ - bn_clear_top2max(&wnum); bn_sub_words(wnum.d, wnum.d, sdiv->d, div_n); *resp = 1; } else res->top--; } - /* if res->top == 0 then clear the neg value otherwise decrease - * the resp pointer */ + /* + * If res->top == 0 then clear the neg value otherwise decrease the resp + * pointer. + */ if (res->top == 0) res->neg = 0; else @@ -253,151 +367,91 @@ BN_div_internal(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor for (i = 0; i < loop - 1; i++, wnump--, resp--) { BN_ULONG q, l0; - /* the first part of the loop uses the top two words of - * snum and sdiv to calculate a BN_ULONG q such that - * | wnum - sdiv * q | < sdiv */ -#if defined(BN_DIV3W) && !defined(OPENSSL_NO_ASM) - BN_ULONG bn_div_3_words(BN_ULONG*, BN_ULONG, BN_ULONG); - q = bn_div_3_words(wnump, d1, d0); -#else - BN_ULONG n0, n1, rem = 0; - - n0 = wnump[0]; - n1 = wnump[-1]; - if (n0 == d0) - q = BN_MASK2; - else /* n0 < d0 */ - { -#ifdef BN_LLONG - BN_ULLONG t2; - -#if defined(BN_DIV2W) && !defined(bn_div_words) - q = (BN_ULONG)(((((BN_ULLONG)n0) << BN_BITS2)|n1)/d0); -#else - q = bn_div_words(n0, n1, d0); -#endif - -#ifndef REMAINDER_IS_ALREADY_CALCULATED - /* - * rem doesn't have to be BN_ULLONG. The least we - * know it's less that d0, isn't it? - */ - rem = (n1 - q * d0) & BN_MASK2; -#endif - t2 = (BN_ULLONG)d1*q; - - for (;;) { - if (t2 <= ((((BN_ULLONG)rem) << BN_BITS2) | - wnump[-2])) - break; - q--; - rem += d0; - if (rem < d0) break; /* don't let rem overflow */ - t2 -= d1; - } -#else /* !BN_LLONG */ - BN_ULONG t2l, t2h; - - q = bn_div_words(n0, n1, d0); -#ifndef REMAINDER_IS_ALREADY_CALCULATED - rem = (n1 - q*d0)&BN_MASK2; -#endif - -#if defined(BN_UMULT_LOHI) - BN_UMULT_LOHI(t2l, t2h, d1, q); -#elif defined(BN_UMULT_HIGH) - t2l = d1 * q; - t2h = BN_UMULT_HIGH(d1, q); -#else - { - BN_ULONG ql, qh; - t2l = LBITS(d1); - t2h = HBITS(d1); - ql = LBITS(q); - qh = HBITS(q); - mul64(t2l, t2h, ql, qh); /* t2=(BN_ULLONG)d1*q; */ - } -#endif - - for (;;) { - if ((t2h < rem) || - ((t2h == rem) && (t2l <= wnump[-2]))) - break; - q--; - rem += d0; - if (rem < d0) - break; /* don't let rem overflow */ - if (t2l < d1) - t2h--; - t2l -= d1; - } -#endif /* !BN_LLONG */ - } -#endif /* !BN_DIV3W */ + /* + * The first part of the loop uses the top two words of snum and + * sdiv to calculate a BN_ULONG q such that: + * + * | wnum - sdiv * q | < sdiv + */ + q = bn_div_3_words(wnump, d1, d0); l0 = bn_mul_words(tmp->d, sdiv->d, div_n, q); tmp->d[div_n] = l0; wnum.d--; - /* ingore top values of the bignums just sub the two - * BN_ULONG arrays with bn_sub_words */ + + /* + * Ignore top values of the bignums just sub the two BN_ULONG + * arrays with bn_sub_words. + */ if (bn_sub_words(wnum.d, wnum.d, tmp->d, div_n + 1)) { - /* Note: As we have considered only the leading - * two BN_ULONGs in the calculation of q, sdiv * q - * might be greater than wnum (but then (q-1) * sdiv - * is less or equal than wnum) + /* + * Note: As we have considered only the leading two + * BN_ULONGs in the calculation of q, sdiv * q might be + * greater than wnum (but then (q-1) * sdiv is less or + * equal than wnum). */ q--; - if (bn_add_words(wnum.d, wnum.d, sdiv->d, div_n)) - /* we can't have an overflow here (assuming + if (bn_add_words(wnum.d, wnum.d, sdiv->d, div_n)) { + /* + * We can't have an overflow here (assuming * that q != 0, but if q == 0 then tmp is - * zero anyway) */ + * zero anyway). + */ (*wnump)++; + } } /* store part of the result */ *resp = q; } + bn_correct_top(snum); - if (rm != NULL) { - /* Keep a copy of the neg flag in num because if rm==num - * BN_rshift() will overwrite it. + + if (remainder != NULL) { + /* + * Keep a copy of the neg flag in numerator because if + * remainder == numerator, BN_rshift() will overwrite it. */ - int neg = num->neg; - BN_rshift(rm, snum, norm_shift); - if (!BN_is_zero(rm)) - rm->neg = neg; - bn_check_top(rm); + int neg = numerator->neg; + + BN_rshift(remainder, snum, norm_shift); + BN_set_negative(remainder, neg); } + if (no_branch) bn_correct_top(res); - BN_CTX_end(ctx); - return (1); -err: - bn_check_top(rm); + BN_set_negative(res, r_neg); + + done: + ret = 1; + err: BN_CTX_end(ctx); - return (0); + + return ret; } int -BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, - BN_CTX *ctx) +BN_div(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, + const BIGNUM *divisor, BN_CTX *ctx) { - int ct = ((BN_get_flags(num, BN_FLG_CONSTTIME) != 0) || - (BN_get_flags(divisor, BN_FLG_CONSTTIME) != 0)); + int ct; + + ct = BN_get_flags(numerator, BN_FLG_CONSTTIME) != 0 || + BN_get_flags(divisor, BN_FLG_CONSTTIME) != 0; - return BN_div_internal(dv, rm, num, divisor, ctx, ct); + return BN_div_internal(quotient, remainder, numerator, divisor, ctx, ct); } int -BN_div_nonct(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, - BN_CTX *ctx) +BN_div_nonct(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, + const BIGNUM *divisor, BN_CTX *ctx) { - return BN_div_internal(dv, rm, num, divisor, ctx, 0); + return BN_div_internal(quotient, remainder, numerator, divisor, ctx, 0); } int -BN_div_ct(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, - BN_CTX *ctx) +BN_div_ct(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, + const BIGNUM *divisor, BN_CTX *ctx) { - return BN_div_internal(dv, rm, num, divisor, ctx, 1); + return BN_div_internal(quotient, remainder, numerator, divisor, ctx, 1); } diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c index 3525b503..9abf574b 100644 --- a/crypto/bn/bn_exp.c +++ b/crypto/bn/bn_exp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_exp.c,v 1.32 2022/04/20 13:32:34 tb Exp $ */ +/* $OpenBSD: bn_exp.c,v 1.38 2023/03/15 04:30:20 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -114,8 +114,8 @@ #include -#include "bn_lcl.h" -#include "constant_time_locl.h" +#include "bn_local.h" +#include "constant_time.h" /* maximum precomputation table size for *variable* sliding windows */ #define TABLE_SIZE 32 @@ -168,98 +168,19 @@ BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) if (r != rr && rr != NULL) BN_copy(r, rr); BN_CTX_end(ctx); - bn_check_top(r); return (ret); } -static int -BN_mod_exp_internal(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx, int ct) -{ - int ret; - - bn_check_top(a); - bn_check_top(p); - bn_check_top(m); - - /* For even modulus m = 2^k*m_odd, it might make sense to compute - * a^p mod m_odd and a^p mod 2^k separately (with Montgomery - * exponentiation for the odd part), using appropriate exponent - * reductions, and combine the results using the CRT. - * - * For now, we use Montgomery only if the modulus is odd; otherwise, - * exponentiation using the reciprocal-based quick remaindering - * algorithm is used. - * - * (Timing obtained with expspeed.c [computations a^p mod m - * where a, p, m are of the same length: 256, 512, 1024, 2048, - * 4096, 8192 bits], compared to the running time of the - * standard algorithm: - * - * BN_mod_exp_mont 33 .. 40 % [AMD K6-2, Linux, debug configuration] - * 55 .. 77 % [UltraSparc processor, but - * debug-solaris-sparcv8-gcc conf.] - * - * BN_mod_exp_recp 50 .. 70 % [AMD K6-2, Linux, debug configuration] - * 62 .. 118 % [UltraSparc, debug-solaris-sparcv8-gcc] - * - * On the Sparc, BN_mod_exp_recp was faster than BN_mod_exp_mont - * at 2048 and more bits, but at 512 and 1024 bits, it was - * slower even than the standard algorithm! - * - * "Real" timings [linux-elf, solaris-sparcv9-gcc configurations] - * should be obtained when the new Montgomery reduction code - * has been integrated into OpenSSL.) - */ - - if (BN_is_odd(m)) { - if (a->top == 1 && !a->neg && !ct) { - BN_ULONG A = a->d[0]; - ret = BN_mod_exp_mont_word(r, A,p, m,ctx, NULL); - } else - ret = BN_mod_exp_mont_ct(r, a,p, m,ctx, NULL); - } else { - ret = BN_mod_exp_recp(r, a,p, m, ctx); - } - - bn_check_top(r); - return (ret); -} - -int -BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx) -{ - return BN_mod_exp_internal(r, a, p, m, ctx, - (BN_get_flags(p, BN_FLG_CONSTTIME) != 0)); -} - -int -BN_mod_exp_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx) -{ - return BN_mod_exp_internal(r, a, p, m, ctx, 1); -} - - -int -BN_mod_exp_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx) -{ - return BN_mod_exp_internal(r, a, p, m, ctx, 0); -} - - +/* The old fallback, simple version :-) */ int -BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, +BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx) { int i, j, bits, ret = 0, wstart, wend, window, wvalue; int start = 1; - BIGNUM *aa; + BIGNUM *d; /* Table of variables obtained from 'ctx' */ BIGNUM *val[TABLE_SIZE]; - BN_RECP_CTX recp; if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */ @@ -278,27 +199,13 @@ BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, return ret; } - BN_RECP_CTX_init(&recp); - BN_CTX_start(ctx); - if ((aa = BN_CTX_get(ctx)) == NULL) + if ((d = BN_CTX_get(ctx)) == NULL) goto err; if ((val[0] = BN_CTX_get(ctx)) == NULL) goto err; - if (m->neg) { - /* ignore sign of 'm' */ - if (!BN_copy(aa, m)) - goto err; - aa->neg = 0; - if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0) - goto err; - } else { - if (BN_RECP_CTX_set(&recp, m, ctx) <= 0) - goto err; - } - - if (!BN_nnmod(val[0], a, m, ctx)) + if (!BN_nnmod(val[0],a,m,ctx)) goto err; /* 1 */ if (BN_is_zero(val[0])) { BN_zero(r); @@ -308,13 +215,12 @@ BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, window = BN_window_bits_for_exponent_size(bits); if (window > 1) { - if (!BN_mod_mul_reciprocal(aa, val[0], val[0], &recp, ctx)) + if (!BN_mod_mul(d, val[0], val[0], m, ctx)) goto err; /* 2 */ j = 1 << (window - 1); for (i = 1; i < j; i++) { if (((val[i] = BN_CTX_get(ctx)) == NULL) || - !BN_mod_mul_reciprocal(val[i], val[i - 1], - aa, &recp, ctx)) + !BN_mod_mul(val[i], val[i - 1], d,m, ctx)) goto err; } } @@ -332,157 +238,8 @@ BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, for (;;) { if (BN_is_bit_set(p, wstart) == 0) { if (!start) - if (!BN_mod_mul_reciprocal(r, r,r, &recp, ctx)) - goto err; - if (wstart == 0) - break; - wstart--; - continue; - } - /* We now have wstart on a 'set' bit, we now need to work out - * how bit a window to do. To do this we need to scan - * forward until the last set bit before the end of the - * window */ - j = wstart; - wvalue = 1; - wend = 0; - for (i = 1; i < window; i++) { - if (wstart - i < 0) - break; - if (BN_is_bit_set(p, wstart - i)) { - wvalue <<= (i - wend); - wvalue |= 1; - wend = i; - } - } - - /* wend is the size of the current window */ - j = wend + 1; - /* add the 'bytes above' */ - if (!start) - for (i = 0; i < j; i++) { - if (!BN_mod_mul_reciprocal(r, r,r, &recp, ctx)) - goto err; - } - - /* wvalue will be an odd number < 2^window */ - if (!BN_mod_mul_reciprocal(r, r,val[wvalue >> 1], &recp, ctx)) - goto err; - - /* move the 'window' down further */ - wstart -= wend + 1; - wvalue = 0; - start = 0; - if (wstart < 0) - break; - } - ret = 1; - -err: - BN_CTX_end(ctx); - BN_RECP_CTX_free(&recp); - bn_check_top(r); - return (ret); -} - -static int -BN_mod_exp_mont_internal(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont, int ct) -{ - int i, j, bits, ret = 0, wstart, wend, window, wvalue; - int start = 1; - BIGNUM *d, *r; - const BIGNUM *aa; - /* Table of variables obtained from 'ctx' */ - BIGNUM *val[TABLE_SIZE]; - BN_MONT_CTX *mont = NULL; - - if (ct) { - return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont); - } - - bn_check_top(a); - bn_check_top(p); - bn_check_top(m); - - if (!BN_is_odd(m)) { - BNerror(BN_R_CALLED_WITH_EVEN_MODULUS); - return (0); - } - - bits = BN_num_bits(p); - if (bits == 0) { - /* x**0 mod 1 is still zero. */ - if (BN_is_one(m)) { - ret = 1; - BN_zero(rr); - } else - ret = BN_one(rr); - return ret; - } - - BN_CTX_start(ctx); - if ((d = BN_CTX_get(ctx)) == NULL) - goto err; - if ((r = BN_CTX_get(ctx)) == NULL) - goto err; - if ((val[0] = BN_CTX_get(ctx)) == NULL) - goto err; - - /* If this is not done, things will break in the montgomery - * part */ - - if (in_mont != NULL) - mont = in_mont; - else { - if ((mont = BN_MONT_CTX_new()) == NULL) - goto err; - if (!BN_MONT_CTX_set(mont, m, ctx)) - goto err; - } - - if (a->neg || BN_ucmp(a, m) >= 0) { - if (!BN_nnmod(val[0], a,m, ctx)) - goto err; - aa = val[0]; - } else - aa = a; - if (BN_is_zero(aa)) { - BN_zero(rr); - ret = 1; - goto err; - } - if (!BN_to_montgomery(val[0], aa, mont, ctx)) - goto err; /* 1 */ - - window = BN_window_bits_for_exponent_size(bits); - if (window > 1) { - if (!BN_mod_mul_montgomery(d, val[0], val[0], mont, ctx)) - goto err; /* 2 */ - j = 1 << (window - 1); - for (i = 1; i < j; i++) { - if (((val[i] = BN_CTX_get(ctx)) == NULL) || - !BN_mod_mul_montgomery(val[i], val[i - 1], - d, mont, ctx)) - goto err; - } - } - - start = 1; /* This is used to avoid multiplication etc - * when there is only the value '1' in the - * buffer. */ - wvalue = 0; /* The 'value' of the window */ - wstart = bits - 1; /* The top bit of the window */ - wend = 0; /* The bottom bit of the window */ - - if (!BN_to_montgomery(r, BN_value_one(), mont, ctx)) - goto err; - for (;;) { - if (BN_is_bit_set(p, wstart) == 0) { - if (!start) { - if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)) + if (!BN_mod_mul(r, r, r, m, ctx)) goto err; - } if (wstart == 0) break; wstart--; @@ -510,12 +267,12 @@ BN_mod_exp_mont_internal(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIG /* add the 'bytes above' */ if (!start) for (i = 0; i < j; i++) { - if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)) + if (!BN_mod_mul(r, r, r, m, ctx)) goto err; } /* wvalue will be an odd number < 2^window */ - if (!BN_mod_mul_montgomery(r, r, val[wvalue >> 1], mont, ctx)) + if (!BN_mod_mul(r, r, val[wvalue >> 1], m, ctx)) goto err; /* move the 'window' down further */ @@ -525,40 +282,13 @@ BN_mod_exp_mont_internal(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIG if (wstart < 0) break; } - if (!BN_from_montgomery(rr, r,mont, ctx)) - goto err; ret = 1; err: - if ((in_mont == NULL) && (mont != NULL)) - BN_MONT_CTX_free(mont); BN_CTX_end(ctx); - bn_check_top(rr); return (ret); } -int -BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont) -{ - return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, - (BN_get_flags(p, BN_FLG_CONSTTIME) != 0)); -} - -int -BN_mod_exp_mont_ct(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont) -{ - return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, 1); -} - -int -BN_mod_exp_mont_nonct(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *in_mont) -{ - return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, 0); -} - /* BN_mod_exp_mont_consttime() stores the precomputed powers in a specific layout * so that accessing any of these table values shows the same access pattern as far * as cache lines are concerned. The following functions are used to transfer a BIGNUM @@ -590,7 +320,7 @@ MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, int width = 1 << window; volatile BN_ULONG *table = (volatile BN_ULONG *)buf; - if (bn_wexpand(b, top) == NULL) + if (!bn_wexpand(b, top)) return 0; if (window <= 3) { @@ -658,9 +388,6 @@ BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, unsigned char *powerbuf = NULL; BIGNUM tmp, am; - bn_check_top(a); - bn_check_top(p); - bn_check_top(m); if (!BN_is_odd(m)) { BNerror(BN_R_CALLED_WITH_EVEN_MODULUS); @@ -732,12 +459,9 @@ BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, #endif /* prepare a^1 in Montgomery domain */ - if (a->neg || BN_ucmp(a, m) >= 0) { - if (!BN_mod_ct(&am, a,m, ctx)) - goto err; - if (!BN_to_montgomery(&am, &am, mont, ctx)) - goto err; - } else if (!BN_to_montgomery(&am, a,mont, ctx)) + if (!BN_nnmod(&am, a, m, ctx)) + goto err; + if (!BN_to_montgomery(&am, &am, mont, ctx)) goto err; #if defined(OPENSSL_BN_ASM_MONT5) @@ -878,33 +602,203 @@ BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, if (!BN_mod_mul_montgomery(&tmp, &tmp, &tmp, mont, ctx)) goto err; - wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); + wvalue = (wvalue << 1) + BN_is_bit_set(p, bits); + } + + /* Fetch the appropriate pre-computed value from the pre-buf */ + if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&am, top, powerbuf, + wvalue, window)) + goto err; + + /* Multiply the result into the intermediate result */ + if (!BN_mod_mul_montgomery(&tmp, &tmp, &am, mont, ctx)) + goto err; + } + } + + /* Convert the final result from montgomery to standard format */ + if (!BN_from_montgomery(rr, &tmp, mont, ctx)) + goto err; + ret = 1; + +err: + if ((in_mont == NULL) && (mont != NULL)) + BN_MONT_CTX_free(mont); + freezero(powerbufFree, powerbufLen + MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH); + BN_CTX_end(ctx); + return (ret); +} + +static int +BN_mod_exp_mont_internal(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, + BN_CTX *ctx, BN_MONT_CTX *in_mont, int ct) +{ + int i, j, bits, ret = 0, wstart, wend, window, wvalue; + int start = 1; + BIGNUM *d, *r; + const BIGNUM *aa; + /* Table of variables obtained from 'ctx' */ + BIGNUM *val[TABLE_SIZE]; + BN_MONT_CTX *mont = NULL; + + if (ct) { + return BN_mod_exp_mont_consttime(rr, a, p, m, ctx, in_mont); + } + + + if (!BN_is_odd(m)) { + BNerror(BN_R_CALLED_WITH_EVEN_MODULUS); + return (0); + } + + bits = BN_num_bits(p); + if (bits == 0) { + /* x**0 mod 1 is still zero. */ + if (BN_is_one(m)) { + ret = 1; + BN_zero(rr); + } else + ret = BN_one(rr); + return ret; + } + + BN_CTX_start(ctx); + if ((d = BN_CTX_get(ctx)) == NULL) + goto err; + if ((r = BN_CTX_get(ctx)) == NULL) + goto err; + if ((val[0] = BN_CTX_get(ctx)) == NULL) + goto err; + + /* If this is not done, things will break in the montgomery + * part */ + + if (in_mont != NULL) + mont = in_mont; + else { + if ((mont = BN_MONT_CTX_new()) == NULL) + goto err; + if (!BN_MONT_CTX_set(mont, m, ctx)) + goto err; + } + + if (a->neg || BN_ucmp(a, m) >= 0) { + if (!BN_nnmod(val[0], a,m, ctx)) + goto err; + aa = val[0]; + } else + aa = a; + if (BN_is_zero(aa)) { + BN_zero(rr); + ret = 1; + goto err; + } + if (!BN_to_montgomery(val[0], aa, mont, ctx)) + goto err; /* 1 */ + + window = BN_window_bits_for_exponent_size(bits); + if (window > 1) { + if (!BN_mod_mul_montgomery(d, val[0], val[0], mont, ctx)) + goto err; /* 2 */ + j = 1 << (window - 1); + for (i = 1; i < j; i++) { + if (((val[i] = BN_CTX_get(ctx)) == NULL) || + !BN_mod_mul_montgomery(val[i], val[i - 1], + d, mont, ctx)) + goto err; + } + } + + start = 1; /* This is used to avoid multiplication etc + * when there is only the value '1' in the + * buffer. */ + wvalue = 0; /* The 'value' of the window */ + wstart = bits - 1; /* The top bit of the window */ + wend = 0; /* The bottom bit of the window */ + + if (!BN_to_montgomery(r, BN_value_one(), mont, ctx)) + goto err; + for (;;) { + if (BN_is_bit_set(p, wstart) == 0) { + if (!start) { + if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)) + goto err; + } + if (wstart == 0) + break; + wstart--; + continue; + } + /* We now have wstart on a 'set' bit, we now need to work out + * how bit a window to do. To do this we need to scan + * forward until the last set bit before the end of the + * window */ + j = wstart; + wvalue = 1; + wend = 0; + for (i = 1; i < window; i++) { + if (wstart - i < 0) + break; + if (BN_is_bit_set(p, wstart - i)) { + wvalue <<= (i - wend); + wvalue |= 1; + wend = i; + } + } + + /* wend is the size of the current window */ + j = wend + 1; + /* add the 'bytes above' */ + if (!start) + for (i = 0; i < j; i++) { + if (!BN_mod_mul_montgomery(r, r, r, mont, ctx)) + goto err; } - /* Fetch the appropriate pre-computed value from the pre-buf */ - if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&am, top, powerbuf, - wvalue, window)) - goto err; + /* wvalue will be an odd number < 2^window */ + if (!BN_mod_mul_montgomery(r, r, val[wvalue >> 1], mont, ctx)) + goto err; - /* Multiply the result into the intermediate result */ - if (!BN_mod_mul_montgomery(&tmp, &tmp, &am, mont, ctx)) - goto err; - } + /* move the 'window' down further */ + wstart -= wend + 1; + wvalue = 0; + start = 0; + if (wstart < 0) + break; } - - /* Convert the final result from montgomery to standard format */ - if (!BN_from_montgomery(rr, &tmp, mont, ctx)) + if (!BN_from_montgomery(rr, r,mont, ctx)) goto err; ret = 1; err: if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); - freezero(powerbufFree, powerbufLen + MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH); BN_CTX_end(ctx); return (ret); } +int +BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, + BN_CTX *ctx, BN_MONT_CTX *in_mont) +{ + return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, + (BN_get_flags(p, BN_FLG_CONSTTIME) != 0)); +} + +int +BN_mod_exp_mont_ct(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, + BN_CTX *ctx, BN_MONT_CTX *in_mont) +{ + return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, 1); +} + +int +BN_mod_exp_mont_nonct(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, + BN_CTX *ctx, BN_MONT_CTX *in_mont) +{ + return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, 0); +} + int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) @@ -937,8 +831,6 @@ BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, const BIGNUM *m, return -1; } - bn_check_top(p); - bn_check_top(m); if (!BN_is_odd(m)) { BNerror(BN_R_CALLED_WITH_EVEN_MODULUS); @@ -1052,21 +944,19 @@ BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, const BIGNUM *m, if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont); BN_CTX_end(ctx); - bn_check_top(rr); return (ret); } - -/* The old fallback, simple version :-) */ int -BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, +BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx) { int i, j, bits, ret = 0, wstart, wend, window, wvalue; int start = 1; - BIGNUM *d; + BIGNUM *aa; /* Table of variables obtained from 'ctx' */ BIGNUM *val[TABLE_SIZE]; + BN_RECP_CTX recp; if (BN_get_flags(p, BN_FLG_CONSTTIME) != 0) { /* BN_FLG_CONSTTIME only supported by BN_mod_exp_mont() */ @@ -1085,13 +975,27 @@ BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, return ret; } + BN_RECP_CTX_init(&recp); + BN_CTX_start(ctx); - if ((d = BN_CTX_get(ctx)) == NULL) + if ((aa = BN_CTX_get(ctx)) == NULL) goto err; if ((val[0] = BN_CTX_get(ctx)) == NULL) goto err; - if (!BN_nnmod(val[0],a,m,ctx)) + if (m->neg) { + /* ignore sign of 'm' */ + if (!BN_copy(aa, m)) + goto err; + aa->neg = 0; + if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0) + goto err; + } else { + if (BN_RECP_CTX_set(&recp, m, ctx) <= 0) + goto err; + } + + if (!BN_nnmod(val[0], a, m, ctx)) goto err; /* 1 */ if (BN_is_zero(val[0])) { BN_zero(r); @@ -1101,12 +1005,13 @@ BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, window = BN_window_bits_for_exponent_size(bits); if (window > 1) { - if (!BN_mod_mul(d, val[0], val[0], m, ctx)) + if (!BN_mod_mul_reciprocal(aa, val[0], val[0], &recp, ctx)) goto err; /* 2 */ j = 1 << (window - 1); for (i = 1; i < j; i++) { if (((val[i] = BN_CTX_get(ctx)) == NULL) || - !BN_mod_mul(val[i], val[i - 1], d,m, ctx)) + !BN_mod_mul_reciprocal(val[i], val[i - 1], + aa, &recp, ctx)) goto err; } } @@ -1124,7 +1029,7 @@ BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, for (;;) { if (BN_is_bit_set(p, wstart) == 0) { if (!start) - if (!BN_mod_mul(r, r, r, m, ctx)) + if (!BN_mod_mul_reciprocal(r, r,r, &recp, ctx)) goto err; if (wstart == 0) break; @@ -1153,12 +1058,12 @@ BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, /* add the 'bytes above' */ if (!start) for (i = 0; i < j; i++) { - if (!BN_mod_mul(r, r, r, m, ctx)) + if (!BN_mod_mul_reciprocal(r, r,r, &recp, ctx)) goto err; } /* wvalue will be an odd number < 2^window */ - if (!BN_mod_mul(r, r, val[wvalue >> 1], m, ctx)) + if (!BN_mod_mul_reciprocal(r, r,val[wvalue >> 1], &recp, ctx)) goto err; /* move the 'window' down further */ @@ -1172,6 +1077,262 @@ BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, err: BN_CTX_end(ctx); - bn_check_top(r); + BN_RECP_CTX_free(&recp); + return (ret); +} + +static int +BN_mod_exp_internal(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, + BN_CTX *ctx, int ct) +{ + int ret; + + + /* For even modulus m = 2^k*m_odd, it might make sense to compute + * a^p mod m_odd and a^p mod 2^k separately (with Montgomery + * exponentiation for the odd part), using appropriate exponent + * reductions, and combine the results using the CRT. + * + * For now, we use Montgomery only if the modulus is odd; otherwise, + * exponentiation using the reciprocal-based quick remaindering + * algorithm is used. + * + * (Timing obtained with expspeed.c [computations a^p mod m + * where a, p, m are of the same length: 256, 512, 1024, 2048, + * 4096, 8192 bits], compared to the running time of the + * standard algorithm: + * + * BN_mod_exp_mont 33 .. 40 % [AMD K6-2, Linux, debug configuration] + * 55 .. 77 % [UltraSparc processor, but + * debug-solaris-sparcv8-gcc conf.] + * + * BN_mod_exp_recp 50 .. 70 % [AMD K6-2, Linux, debug configuration] + * 62 .. 118 % [UltraSparc, debug-solaris-sparcv8-gcc] + * + * On the Sparc, BN_mod_exp_recp was faster than BN_mod_exp_mont + * at 2048 and more bits, but at 512 and 1024 bits, it was + * slower even than the standard algorithm! + * + * "Real" timings [linux-elf, solaris-sparcv9-gcc configurations] + * should be obtained when the new Montgomery reduction code + * has been integrated into OpenSSL.) + */ + + if (BN_is_odd(m)) { + if (a->top == 1 && !a->neg && !ct) { + BN_ULONG A = a->d[0]; + ret = BN_mod_exp_mont_word(r, A,p, m,ctx, NULL); + } else + ret = BN_mod_exp_mont_ct(r, a,p, m,ctx, NULL); + } else { + ret = BN_mod_exp_recp(r, a,p, m, ctx); + } + + return (ret); +} + +int +BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, + BN_CTX *ctx) +{ + return BN_mod_exp_internal(r, a, p, m, ctx, + (BN_get_flags(p, BN_FLG_CONSTTIME) != 0)); +} + +int +BN_mod_exp_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, + BN_CTX *ctx) +{ + return BN_mod_exp_internal(r, a, p, m, ctx, 1); +} + +int +BN_mod_exp_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, + BN_CTX *ctx) +{ + return BN_mod_exp_internal(r, a, p, m, ctx, 0); +} + +int +BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1, + const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont) +{ + int i, j, bits, b, bits1, bits2, ret = 0, wpos1, wpos2, window1, window2, wvalue1, wvalue2; + int r_is_one = 1; + BIGNUM *d, *r; + const BIGNUM *a_mod_m; + /* Tables of variables obtained from 'ctx' */ + BIGNUM *val1[TABLE_SIZE], *val2[TABLE_SIZE]; + BN_MONT_CTX *mont = NULL; + + + if (!BN_is_odd(m)) { + BNerror(BN_R_CALLED_WITH_EVEN_MODULUS); + return (0); + } + bits1 = BN_num_bits(p1); + bits2 = BN_num_bits(p2); + if ((bits1 == 0) && (bits2 == 0)) { + ret = BN_one(rr); + return ret; + } + + bits = (bits1 > bits2) ? bits1 : bits2; + + BN_CTX_start(ctx); + if ((d = BN_CTX_get(ctx)) == NULL) + goto err; + if ((r = BN_CTX_get(ctx)) == NULL) + goto err; + if ((val1[0] = BN_CTX_get(ctx)) == NULL) + goto err; + if ((val2[0] = BN_CTX_get(ctx)) == NULL) + goto err; + + if (in_mont != NULL) + mont = in_mont; + else { + if ((mont = BN_MONT_CTX_new()) == NULL) + goto err; + if (!BN_MONT_CTX_set(mont, m, ctx)) + goto err; + } + + window1 = BN_window_bits_for_exponent_size(bits1); + window2 = BN_window_bits_for_exponent_size(bits2); + + /* + * Build table for a1: val1[i] := a1^(2*i + 1) mod m for i = 0 .. 2^(window1-1) + */ + if (a1->neg || BN_ucmp(a1, m) >= 0) { + if (!BN_mod_ct(val1[0], a1, m, ctx)) + goto err; + a_mod_m = val1[0]; + } else + a_mod_m = a1; + if (BN_is_zero(a_mod_m)) { + BN_zero(rr); + ret = 1; + goto err; + } + + if (!BN_to_montgomery(val1[0], a_mod_m, mont, ctx)) + goto err; + if (window1 > 1) { + if (!BN_mod_mul_montgomery(d, val1[0], val1[0], mont, ctx)) + goto err; + + j = 1 << (window1 - 1); + for (i = 1; i < j; i++) { + if (((val1[i] = BN_CTX_get(ctx)) == NULL) || + !BN_mod_mul_montgomery(val1[i], val1[i - 1], + d, mont, ctx)) + goto err; + } + } + + + /* + * Build table for a2: val2[i] := a2^(2*i + 1) mod m for i = 0 .. 2^(window2-1) + */ + if (a2->neg || BN_ucmp(a2, m) >= 0) { + if (!BN_mod_ct(val2[0], a2, m, ctx)) + goto err; + a_mod_m = val2[0]; + } else + a_mod_m = a2; + if (BN_is_zero(a_mod_m)) { + BN_zero(rr); + ret = 1; + goto err; + } + if (!BN_to_montgomery(val2[0], a_mod_m, mont, ctx)) + goto err; + if (window2 > 1) { + if (!BN_mod_mul_montgomery(d, val2[0], val2[0], mont, ctx)) + goto err; + + j = 1 << (window2 - 1); + for (i = 1; i < j; i++) { + if (((val2[i] = BN_CTX_get(ctx)) == NULL) || + !BN_mod_mul_montgomery(val2[i], val2[i - 1], + d, mont, ctx)) + goto err; + } + } + + + /* Now compute the power product, using independent windows. */ + r_is_one = 1; + wvalue1 = 0; /* The 'value' of the first window */ + wvalue2 = 0; /* The 'value' of the second window */ + wpos1 = 0; /* If wvalue1 > 0, the bottom bit of the first window */ + wpos2 = 0; /* If wvalue2 > 0, the bottom bit of the second window */ + + if (!BN_to_montgomery(r, BN_value_one(), mont, ctx)) + goto err; + for (b = bits - 1; b >= 0; b--) { + if (!r_is_one) { + if (!BN_mod_mul_montgomery(r, r,r, mont, ctx)) + goto err; + } + + if (!wvalue1) + if (BN_is_bit_set(p1, b)) { + /* consider bits b-window1+1 .. b for this window */ + i = b - window1 + 1; + while (!BN_is_bit_set(p1, i)) /* works for i<0 */ + i++; + wpos1 = i; + wvalue1 = 1; + for (i = b - 1; i >= wpos1; i--) { + wvalue1 <<= 1; + if (BN_is_bit_set(p1, i)) + wvalue1++; + } + } + + if (!wvalue2) + if (BN_is_bit_set(p2, b)) { + /* consider bits b-window2+1 .. b for this window */ + i = b - window2 + 1; + while (!BN_is_bit_set(p2, i)) + i++; + wpos2 = i; + wvalue2 = 1; + for (i = b - 1; i >= wpos2; i--) { + wvalue2 <<= 1; + if (BN_is_bit_set(p2, i)) + wvalue2++; + } + } + + if (wvalue1 && b == wpos1) { + /* wvalue1 is odd and < 2^window1 */ + if (!BN_mod_mul_montgomery(r, r, val1[wvalue1 >> 1], + mont, ctx)) + goto err; + wvalue1 = 0; + r_is_one = 0; + } + + if (wvalue2 && b == wpos2) { + /* wvalue2 is odd and < 2^window2 */ + if (!BN_mod_mul_montgomery(r, r, val2[wvalue2 >> 1], + mont, ctx)) + goto err; + wvalue2 = 0; + r_is_one = 0; + } + } + if (!BN_from_montgomery(rr, r,mont, ctx)) + goto err; + ret = 1; + +err: + if ((in_mont == NULL) && (mont != NULL)) + BN_MONT_CTX_free(mont); + BN_CTX_end(ctx); return (ret); } diff --git a/crypto/bn/bn_exp2.c b/crypto/bn/bn_exp2.c deleted file mode 100644 index c63503f9..00000000 --- a/crypto/bn/bn_exp2.c +++ /dev/null @@ -1,308 +0,0 @@ -/* $OpenBSD: bn_exp2.c,v 1.13 2022/02/07 19:49:56 tb Exp $ */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ -/* ==================================================================== - * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * openssl-core@openssl.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.openssl.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include - -#include - -#include "bn_lcl.h" - -#define TABLE_SIZE 32 - -int -BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1, - const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *in_mont) -{ - int i, j, bits, b, bits1, bits2, ret = 0, wpos1, wpos2, window1, window2, wvalue1, wvalue2; - int r_is_one = 1; - BIGNUM *d, *r; - const BIGNUM *a_mod_m; - /* Tables of variables obtained from 'ctx' */ - BIGNUM *val1[TABLE_SIZE], *val2[TABLE_SIZE]; - BN_MONT_CTX *mont = NULL; - - bn_check_top(a1); - bn_check_top(p1); - bn_check_top(a2); - bn_check_top(p2); - bn_check_top(m); - - if (!BN_is_odd(m)) { - BNerror(BN_R_CALLED_WITH_EVEN_MODULUS); - return (0); - } - bits1 = BN_num_bits(p1); - bits2 = BN_num_bits(p2); - if ((bits1 == 0) && (bits2 == 0)) { - ret = BN_one(rr); - return ret; - } - - bits = (bits1 > bits2) ? bits1 : bits2; - - BN_CTX_start(ctx); - if ((d = BN_CTX_get(ctx)) == NULL) - goto err; - if ((r = BN_CTX_get(ctx)) == NULL) - goto err; - if ((val1[0] = BN_CTX_get(ctx)) == NULL) - goto err; - if ((val2[0] = BN_CTX_get(ctx)) == NULL) - goto err; - - if (in_mont != NULL) - mont = in_mont; - else { - if ((mont = BN_MONT_CTX_new()) == NULL) - goto err; - if (!BN_MONT_CTX_set(mont, m, ctx)) - goto err; - } - - window1 = BN_window_bits_for_exponent_size(bits1); - window2 = BN_window_bits_for_exponent_size(bits2); - - /* - * Build table for a1: val1[i] := a1^(2*i + 1) mod m for i = 0 .. 2^(window1-1) - */ - if (a1->neg || BN_ucmp(a1, m) >= 0) { - if (!BN_mod_ct(val1[0], a1, m, ctx)) - goto err; - a_mod_m = val1[0]; - } else - a_mod_m = a1; - if (BN_is_zero(a_mod_m)) { - BN_zero(rr); - ret = 1; - goto err; - } - - if (!BN_to_montgomery(val1[0], a_mod_m, mont, ctx)) - goto err; - if (window1 > 1) { - if (!BN_mod_mul_montgomery(d, val1[0], val1[0], mont, ctx)) - goto err; - - j = 1 << (window1 - 1); - for (i = 1; i < j; i++) { - if (((val1[i] = BN_CTX_get(ctx)) == NULL) || - !BN_mod_mul_montgomery(val1[i], val1[i - 1], - d, mont, ctx)) - goto err; - } - } - - - /* - * Build table for a2: val2[i] := a2^(2*i + 1) mod m for i = 0 .. 2^(window2-1) - */ - if (a2->neg || BN_ucmp(a2, m) >= 0) { - if (!BN_mod_ct(val2[0], a2, m, ctx)) - goto err; - a_mod_m = val2[0]; - } else - a_mod_m = a2; - if (BN_is_zero(a_mod_m)) { - BN_zero(rr); - ret = 1; - goto err; - } - if (!BN_to_montgomery(val2[0], a_mod_m, mont, ctx)) - goto err; - if (window2 > 1) { - if (!BN_mod_mul_montgomery(d, val2[0], val2[0], mont, ctx)) - goto err; - - j = 1 << (window2 - 1); - for (i = 1; i < j; i++) { - if (((val2[i] = BN_CTX_get(ctx)) == NULL) || - !BN_mod_mul_montgomery(val2[i], val2[i - 1], - d, mont, ctx)) - goto err; - } - } - - - /* Now compute the power product, using independent windows. */ - r_is_one = 1; - wvalue1 = 0; /* The 'value' of the first window */ - wvalue2 = 0; /* The 'value' of the second window */ - wpos1 = 0; /* If wvalue1 > 0, the bottom bit of the first window */ - wpos2 = 0; /* If wvalue2 > 0, the bottom bit of the second window */ - - if (!BN_to_montgomery(r, BN_value_one(), mont, ctx)) - goto err; - for (b = bits - 1; b >= 0; b--) { - if (!r_is_one) { - if (!BN_mod_mul_montgomery(r, r,r, mont, ctx)) - goto err; - } - - if (!wvalue1) - if (BN_is_bit_set(p1, b)) { - /* consider bits b-window1+1 .. b for this window */ - i = b - window1 + 1; - while (!BN_is_bit_set(p1, i)) /* works for i<0 */ - i++; - wpos1 = i; - wvalue1 = 1; - for (i = b - 1; i >= wpos1; i--) { - wvalue1 <<= 1; - if (BN_is_bit_set(p1, i)) - wvalue1++; - } - } - - if (!wvalue2) - if (BN_is_bit_set(p2, b)) { - /* consider bits b-window2+1 .. b for this window */ - i = b - window2 + 1; - while (!BN_is_bit_set(p2, i)) - i++; - wpos2 = i; - wvalue2 = 1; - for (i = b - 1; i >= wpos2; i--) { - wvalue2 <<= 1; - if (BN_is_bit_set(p2, i)) - wvalue2++; - } - } - - if (wvalue1 && b == wpos1) { - /* wvalue1 is odd and < 2^window1 */ - if (!BN_mod_mul_montgomery(r, r, val1[wvalue1 >> 1], - mont, ctx)) - goto err; - wvalue1 = 0; - r_is_one = 0; - } - - if (wvalue2 && b == wpos2) { - /* wvalue2 is odd and < 2^window2 */ - if (!BN_mod_mul_montgomery(r, r, val2[wvalue2 >> 1], - mont, ctx)) - goto err; - wvalue2 = 0; - r_is_one = 0; - } - } - if (!BN_from_montgomery(rr, r,mont, ctx)) - goto err; - ret = 1; - -err: - if ((in_mont == NULL) && (mont != NULL)) - BN_MONT_CTX_free(mont); - BN_CTX_end(ctx); - bn_check_top(rr); - return (ret); -} diff --git a/crypto/bn/bn_gcd.c b/crypto/bn/bn_gcd.c index d756398c..84c3d858 100644 --- a/crypto/bn/bn_gcd.c +++ b/crypto/bn/bn_gcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_gcd.c,v 1.16 2021/12/26 15:16:50 tb Exp $ */ +/* $OpenBSD: bn_gcd.c,v 1.21 2023/01/21 09:21:11 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -111,67 +111,7 @@ #include -#include "bn_lcl.h" - -static BIGNUM *euclid(BIGNUM *a, BIGNUM *b); -static BIGNUM *BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, - BN_CTX *ctx); - -int -BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) -{ - BIGNUM *a, *b, *t; - int ret = 0; - - bn_check_top(in_a); - bn_check_top(in_b); - - BN_CTX_start(ctx); - if ((a = BN_CTX_get(ctx)) == NULL) - goto err; - if ((b = BN_CTX_get(ctx)) == NULL) - goto err; - - if (BN_copy(a, in_a) == NULL) - goto err; - if (BN_copy(b, in_b) == NULL) - goto err; - a->neg = 0; - b->neg = 0; - - if (BN_cmp(a, b) < 0) { - t = a; - a = b; - b = t; - } - t = euclid(a, b); - if (t == NULL) - goto err; - - if (BN_copy(r, t) == NULL) - goto err; - ret = 1; - -err: - BN_CTX_end(ctx); - bn_check_top(r); - return (ret); -} - -int -BN_gcd_ct(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) -{ - if (BN_gcd_no_branch(r, in_a, in_b, ctx) == NULL) - return 0; - return 1; -} - -int -BN_gcd_nonct(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) -{ - return BN_gcd(r, in_a, in_b, ctx); -} - +#include "bn_local.h" static BIGNUM * euclid(BIGNUM *a, BIGNUM *b) @@ -179,8 +119,6 @@ euclid(BIGNUM *a, BIGNUM *b) BIGNUM *t; int shifts = 0; - bn_check_top(a); - bn_check_top(b); /* 0 <= b <= a */ while (!BN_is_zero(b)) { @@ -236,31 +174,33 @@ euclid(BIGNUM *a, BIGNUM *b) if (!BN_lshift(a, a, shifts)) goto err; } - bn_check_top(a); return (a); err: return (NULL); } - -/* solves ax == 1 (mod n) */ -static BIGNUM *BN_mod_inverse_no_branch(BIGNUM *in, const BIGNUM *a, - const BIGNUM *n, BN_CTX *ctx); - +/* + * BN_gcd_no_branch is a special version of BN_mod_inverse_no_branch. + * that returns the GCD. + */ static BIGNUM * -BN_mod_inverse_internal(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx, - int ct) +BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, + BN_CTX *ctx) { BIGNUM *A, *B, *X, *Y, *M, *D, *T, *R = NULL; + BIGNUM local_A, local_B; + BIGNUM *pA, *pB; BIGNUM *ret = NULL; int sign; - if (ct) - return BN_mod_inverse_no_branch(in, a, n, ctx); + if (in == NULL) + goto err; + R = in; + + BN_init(&local_A); + BN_init(&local_B); - bn_check_top(a); - bn_check_top(n); BN_CTX_start(ctx); if ((A = BN_CTX_get(ctx)) == NULL) @@ -278,22 +218,24 @@ BN_mod_inverse_internal(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ct if ((T = BN_CTX_get(ctx)) == NULL) goto err; - if (in == NULL) - R = BN_new(); - else - R = in; - if (R == NULL) + if (!BN_one(X)) goto err; - - BN_one(X); BN_zero(Y); if (BN_copy(B, a) == NULL) goto err; if (BN_copy(A, n) == NULL) goto err; A->neg = 0; + if (B->neg || (BN_ucmp(B, A) >= 0)) { - if (!BN_nnmod(B, B, A, ctx)) + /* + * Turn BN_FLG_CONSTTIME flag on, so that when BN_div is invoked, + * BN_div_no_branch will be called eventually. + */ + pB = &local_B; + /* BN_init() done at the top of the function. */ + BN_with_flags(pB, B, BN_FLG_CONSTTIME); + if (!BN_nnmod(B, pB, A, ctx)) goto err; } sign = -1; @@ -304,260 +246,134 @@ BN_mod_inverse_internal(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ct * sign*Y*a == A (mod |n|). */ - if (BN_is_odd(n) && (BN_num_bits(n) <= (BN_BITS <= 32 ? 450 : 2048))) { - /* Binary inversion algorithm; requires odd modulus. - * This is faster than the general algorithm if the modulus - * is sufficiently small (about 400 .. 500 bits on 32-bit - * sytems, but much more on 64-bit systems) */ - int shift; + while (!BN_is_zero(B)) { + BIGNUM *tmp; - while (!BN_is_zero(B)) { - /* - * 0 < B < |n|, - * 0 < A <= |n|, - * (1) -sign*X*a == B (mod |n|), - * (2) sign*Y*a == A (mod |n|) - */ + /* + * 0 < B < A, + * (*) -sign*X*a == B (mod |n|), + * sign*Y*a == A (mod |n|) + */ - /* Now divide B by the maximum possible power of two in the integers, - * and divide X by the same value mod |n|. - * When we're done, (1) still holds. */ - shift = 0; - while (!BN_is_bit_set(B, shift)) /* note that 0 < B */ - { - shift++; + /* + * Turn BN_FLG_CONSTTIME flag on, so that when BN_div is invoked, + * BN_div_no_branch will be called eventually. + */ + pA = &local_A; + /* BN_init() done at the top of the function. */ + BN_with_flags(pA, A, BN_FLG_CONSTTIME); - if (BN_is_odd(X)) { - if (!BN_uadd(X, X, n)) - goto err; - } - /* now X is even, so we can easily divide it by two */ - if (!BN_rshift1(X, X)) - goto err; - } - if (shift > 0) { - if (!BN_rshift(B, B, shift)) - goto err; - } + /* (D, M) := (A/B, A%B) ... */ + if (!BN_div_ct(D, M, pA, B, ctx)) + goto err; + /* Now + * A = D*B + M; + * thus we have + * (**) sign*Y*a == D*B + M (mod |n|). + */ + tmp = A; /* keep the BIGNUM object, the value does not matter */ - /* Same for A and Y. Afterwards, (2) still holds. */ - shift = 0; - while (!BN_is_bit_set(A, shift)) /* note that 0 < A */ - { - shift++; + /* (A, B) := (B, A mod B) ... */ + A = B; + B = M; + /* ... so we have 0 <= B < A again */ - if (BN_is_odd(Y)) { - if (!BN_uadd(Y, Y, n)) - goto err; - } - /* now Y is even */ - if (!BN_rshift1(Y, Y)) - goto err; - } - if (shift > 0) { - if (!BN_rshift(A, A, shift)) - goto err; - } + /* Since the former M is now B and the former B is now A, + * (**) translates into + * sign*Y*a == D*A + B (mod |n|), + * i.e. + * sign*Y*a - D*A == B (mod |n|). + * Similarly, (*) translates into + * -sign*X*a == A (mod |n|). + * + * Thus, + * sign*Y*a + D*sign*X*a == B (mod |n|), + * i.e. + * sign*(Y + D*X)*a == B (mod |n|). + * + * So if we set (X, Y, sign) := (Y + D*X, X, -sign), we arrive back at + * -sign*X*a == B (mod |n|), + * sign*Y*a == A (mod |n|). + * Note that X and Y stay non-negative all the time. + */ + if (!BN_mul(tmp, D, X, ctx)) + goto err; + if (!BN_add(tmp, tmp, Y)) + goto err; - /* We still have (1) and (2). - * Both A and B are odd. - * The following computations ensure that - * - * 0 <= B < |n|, - * 0 < A < |n|, - * (1) -sign*X*a == B (mod |n|), - * (2) sign*Y*a == A (mod |n|), - * - * and that either A or B is even in the next iteration. - */ - if (BN_ucmp(B, A) >= 0) { - /* -sign*(X + Y)*a == B - A (mod |n|) */ - if (!BN_uadd(X, X, Y)) - goto err; - /* NB: we could use BN_mod_add_quick(X, X, Y, n), but that - * actually makes the algorithm slower */ - if (!BN_usub(B, B, A)) - goto err; - } else { - /* sign*(X + Y)*a == A - B (mod |n|) */ - if (!BN_uadd(Y, Y, X)) - goto err; - /* as above, BN_mod_add_quick(Y, Y, X, n) would slow things down */ - if (!BN_usub(A, A, B)) - goto err; - } - } - } else { - /* general inversion algorithm */ + M = Y; /* keep the BIGNUM object, the value does not matter */ + Y = X; + X = tmp; + sign = -sign; + } - while (!BN_is_zero(B)) { - BIGNUM *tmp; + /* + * The while loop (Euclid's algorithm) ends when + * A == gcd(a,n); + */ - /* - * 0 < B < A, - * (*) -sign*X*a == B (mod |n|), - * sign*Y*a == A (mod |n|) - */ + if (!BN_copy(R, A)) + goto err; + ret = R; +err: + if ((ret == NULL) && (in == NULL)) + BN_free(R); + BN_CTX_end(ctx); + return (ret); +} - /* (D, M) := (A/B, A%B) ... */ - if (BN_num_bits(A) == BN_num_bits(B)) { - if (!BN_one(D)) - goto err; - if (!BN_sub(M, A, B)) - goto err; - } else if (BN_num_bits(A) == BN_num_bits(B) + 1) { - /* A/B is 1, 2, or 3 */ - if (!BN_lshift1(T, B)) - goto err; - if (BN_ucmp(A, T) < 0) { - /* A < 2*B, so D=1 */ - if (!BN_one(D)) - goto err; - if (!BN_sub(M, A, B)) - goto err; - } else { - /* A >= 2*B, so D=2 or D=3 */ - if (!BN_sub(M, A, T)) - goto err; - if (!BN_add(D,T,B)) goto err; /* use D (:= 3*B) as temp */ - if (BN_ucmp(A, D) < 0) { - /* A < 3*B, so D=2 */ - if (!BN_set_word(D, 2)) - goto err; - /* M (= A - 2*B) already has the correct value */ - } else { - /* only D=3 remains */ - if (!BN_set_word(D, 3)) - goto err; - /* currently M = A - 2*B, but we need M = A - 3*B */ - if (!BN_sub(M, M, B)) - goto err; - } - } - } else { - if (!BN_div_nonct(D, M, A, B, ctx)) - goto err; - } - - /* Now - * A = D*B + M; - * thus we have - * (**) sign*Y*a == D*B + M (mod |n|). - */ - tmp = A; /* keep the BIGNUM object, the value does not matter */ - - /* (A, B) := (B, A mod B) ... */ - A = B; - B = M; - /* ... so we have 0 <= B < A again */ - - /* Since the former M is now B and the former B is now A, - * (**) translates into - * sign*Y*a == D*A + B (mod |n|), - * i.e. - * sign*Y*a - D*A == B (mod |n|). - * Similarly, (*) translates into - * -sign*X*a == A (mod |n|). - * - * Thus, - * sign*Y*a + D*sign*X*a == B (mod |n|), - * i.e. - * sign*(Y + D*X)*a == B (mod |n|). - * - * So if we set (X, Y, sign) := (Y + D*X, X, -sign), we arrive back at - * -sign*X*a == B (mod |n|), - * sign*Y*a == A (mod |n|). - * Note that X and Y stay non-negative all the time. - */ +int +BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) +{ + BIGNUM *a, *b, *t; + int ret = 0; - /* most of the time D is very small, so we can optimize tmp := D*X+Y */ - if (BN_is_one(D)) { - if (!BN_add(tmp, X, Y)) - goto err; - } else { - if (BN_is_word(D, 2)) { - if (!BN_lshift1(tmp, X)) - goto err; - } else if (BN_is_word(D, 4)) { - if (!BN_lshift(tmp, X, 2)) - goto err; - } else if (D->top == 1) { - if (!BN_copy(tmp, X)) - goto err; - if (!BN_mul_word(tmp, D->d[0])) - goto err; - } else { - if (!BN_mul(tmp, D,X, ctx)) - goto err; - } - if (!BN_add(tmp, tmp, Y)) - goto err; - } - M = Y; /* keep the BIGNUM object, the value does not matter */ - Y = X; - X = tmp; - sign = -sign; - } - } + BN_CTX_start(ctx); + if ((a = BN_CTX_get(ctx)) == NULL) + goto err; + if ((b = BN_CTX_get(ctx)) == NULL) + goto err; - /* - * The while loop (Euclid's algorithm) ends when - * A == gcd(a,n); - * we have - * sign*Y*a == A (mod |n|), - * where Y is non-negative. - */ + if (BN_copy(a, in_a) == NULL) + goto err; + if (BN_copy(b, in_b) == NULL) + goto err; + a->neg = 0; + b->neg = 0; - if (sign < 0) { - if (!BN_sub(Y, n, Y)) - goto err; + if (BN_cmp(a, b) < 0) { + t = a; + a = b; + b = t; } - /* Now Y*a == A (mod |n|). */ + t = euclid(a, b); + if (t == NULL) + goto err; - if (BN_is_one(A)) { - /* Y*a == 1 (mod |n|) */ - if (!Y->neg && BN_ucmp(Y, n) < 0) { - if (!BN_copy(R, Y)) - goto err; - } else { - if (!BN_nnmod(R, Y,n, ctx)) - goto err; - } - } else { - BNerror(BN_R_NO_INVERSE); + if (BN_copy(r, t) == NULL) goto err; - } - ret = R; + ret = 1; err: - if ((ret == NULL) && (in == NULL)) - BN_free(R); BN_CTX_end(ctx); - bn_check_top(ret); return (ret); } -BIGNUM * -BN_mod_inverse(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) -{ - int ct = ((BN_get_flags(a, BN_FLG_CONSTTIME) != 0) || - (BN_get_flags(n, BN_FLG_CONSTTIME) != 0)); - return BN_mod_inverse_internal(in, a, n, ctx, ct); -} - -BIGNUM * -BN_mod_inverse_nonct(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) +int +BN_gcd_ct(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) { - return BN_mod_inverse_internal(in, a, n, ctx, 0); + if (BN_gcd_no_branch(r, in_a, in_b, ctx) == NULL) + return 0; + return 1; } -BIGNUM * -BN_mod_inverse_ct(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) +int +BN_gcd_nonct(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) { - return BN_mod_inverse_internal(in, a, n, ctx, 1); + return BN_gcd(r, in_a, in_b, ctx); } /* BN_mod_inverse_no_branch is a special version of BN_mod_inverse. @@ -573,8 +389,6 @@ BN_mod_inverse_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BIGNUM *ret = NULL; int sign; - bn_check_top(a); - bn_check_top(n); BN_init(&local_A); BN_init(&local_B); @@ -602,7 +416,8 @@ BN_mod_inverse_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, if (R == NULL) goto err; - BN_one(X); + if (!BN_one(X)) + goto err; BN_zero(Y); if (BN_copy(B, a) == NULL) goto err; @@ -725,33 +540,21 @@ BN_mod_inverse_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, if ((ret == NULL) && (in == NULL)) BN_free(R); BN_CTX_end(ctx); - bn_check_top(ret); return (ret); } -/* - * BN_gcd_no_branch is a special version of BN_mod_inverse_no_branch. - * that returns the GCD. - */ +/* solves ax == 1 (mod n) */ static BIGNUM * -BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, - BN_CTX *ctx) +BN_mod_inverse_internal(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx, + int ct) { BIGNUM *A, *B, *X, *Y, *M, *D, *T, *R = NULL; - BIGNUM local_A, local_B; - BIGNUM *pA, *pB; BIGNUM *ret = NULL; int sign; - if (in == NULL) - goto err; - R = in; - - BN_init(&local_A); - BN_init(&local_B); + if (ct) + return BN_mod_inverse_no_branch(in, a, n, ctx); - bn_check_top(a); - bn_check_top(n); BN_CTX_start(ctx); if ((A = BN_CTX_get(ctx)) == NULL) @@ -769,23 +572,23 @@ BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, if ((T = BN_CTX_get(ctx)) == NULL) goto err; - BN_one(X); + if (in == NULL) + R = BN_new(); + else + R = in; + if (R == NULL) + goto err; + + if (!BN_one(X)) + goto err; BN_zero(Y); if (BN_copy(B, a) == NULL) goto err; if (BN_copy(A, n) == NULL) goto err; A->neg = 0; - if (B->neg || (BN_ucmp(B, A) >= 0)) { - /* - * Turn BN_FLG_CONSTTIME flag on, so that when BN_div is invoked, - * BN_div_no_branch will be called eventually. - */ - pB = &local_B; - /* BN_init() done at the top of the function. */ - BN_with_flags(pB, B, BN_FLG_CONSTTIME); - if (!BN_nnmod(B, pB, A, ctx)) + if (!BN_nnmod(B, B, A, ctx)) goto err; } sign = -1; @@ -796,81 +599,257 @@ BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, * sign*Y*a == A (mod |n|). */ - while (!BN_is_zero(B)) { - BIGNUM *tmp; + if (BN_is_odd(n) && (BN_num_bits(n) <= (BN_BITS <= 32 ? 450 : 2048))) { + /* Binary inversion algorithm; requires odd modulus. + * This is faster than the general algorithm if the modulus + * is sufficiently small (about 400 .. 500 bits on 32-bit + * systems, but much more on 64-bit systems) */ + int shift; - /* - * 0 < B < A, - * (*) -sign*X*a == B (mod |n|), - * sign*Y*a == A (mod |n|) - */ + while (!BN_is_zero(B)) { + /* + * 0 < B < |n|, + * 0 < A <= |n|, + * (1) -sign*X*a == B (mod |n|), + * (2) sign*Y*a == A (mod |n|) + */ - /* - * Turn BN_FLG_CONSTTIME flag on, so that when BN_div is invoked, - * BN_div_no_branch will be called eventually. - */ - pA = &local_A; - /* BN_init() done at the top of the function. */ - BN_with_flags(pA, A, BN_FLG_CONSTTIME); + /* Now divide B by the maximum possible power of two in the integers, + * and divide X by the same value mod |n|. + * When we're done, (1) still holds. */ + shift = 0; + while (!BN_is_bit_set(B, shift)) /* note that 0 < B */ + { + shift++; - /* (D, M) := (A/B, A%B) ... */ - if (!BN_div_ct(D, M, pA, B, ctx)) - goto err; + if (BN_is_odd(X)) { + if (!BN_uadd(X, X, n)) + goto err; + } + /* now X is even, so we can easily divide it by two */ + if (!BN_rshift1(X, X)) + goto err; + } + if (shift > 0) { + if (!BN_rshift(B, B, shift)) + goto err; + } - /* Now - * A = D*B + M; - * thus we have - * (**) sign*Y*a == D*B + M (mod |n|). - */ - tmp = A; /* keep the BIGNUM object, the value does not matter */ - /* (A, B) := (B, A mod B) ... */ - A = B; - B = M; - /* ... so we have 0 <= B < A again */ + /* Same for A and Y. Afterwards, (2) still holds. */ + shift = 0; + while (!BN_is_bit_set(A, shift)) /* note that 0 < A */ + { + shift++; - /* Since the former M is now B and the former B is now A, - * (**) translates into - * sign*Y*a == D*A + B (mod |n|), - * i.e. - * sign*Y*a - D*A == B (mod |n|). - * Similarly, (*) translates into - * -sign*X*a == A (mod |n|). - * - * Thus, - * sign*Y*a + D*sign*X*a == B (mod |n|), - * i.e. - * sign*(Y + D*X)*a == B (mod |n|). - * - * So if we set (X, Y, sign) := (Y + D*X, X, -sign), we arrive back at - * -sign*X*a == B (mod |n|), - * sign*Y*a == A (mod |n|). - * Note that X and Y stay non-negative all the time. - */ + if (BN_is_odd(Y)) { + if (!BN_uadd(Y, Y, n)) + goto err; + } + /* now Y is even */ + if (!BN_rshift1(Y, Y)) + goto err; + } + if (shift > 0) { + if (!BN_rshift(A, A, shift)) + goto err; + } - if (!BN_mul(tmp, D, X, ctx)) - goto err; - if (!BN_add(tmp, tmp, Y)) - goto err; - M = Y; /* keep the BIGNUM object, the value does not matter */ - Y = X; - X = tmp; - sign = -sign; + /* We still have (1) and (2). + * Both A and B are odd. + * The following computations ensure that + * + * 0 <= B < |n|, + * 0 < A < |n|, + * (1) -sign*X*a == B (mod |n|), + * (2) sign*Y*a == A (mod |n|), + * + * and that either A or B is even in the next iteration. + */ + if (BN_ucmp(B, A) >= 0) { + /* -sign*(X + Y)*a == B - A (mod |n|) */ + if (!BN_uadd(X, X, Y)) + goto err; + /* NB: we could use BN_mod_add_quick(X, X, Y, n), but that + * actually makes the algorithm slower */ + if (!BN_usub(B, B, A)) + goto err; + } else { + /* sign*(X + Y)*a == A - B (mod |n|) */ + if (!BN_uadd(Y, Y, X)) + goto err; + /* as above, BN_mod_add_quick(Y, Y, X, n) would slow things down */ + if (!BN_usub(A, A, B)) + goto err; + } + } + } else { + /* general inversion algorithm */ + + while (!BN_is_zero(B)) { + BIGNUM *tmp; + + /* + * 0 < B < A, + * (*) -sign*X*a == B (mod |n|), + * sign*Y*a == A (mod |n|) + */ + + /* (D, M) := (A/B, A%B) ... */ + if (BN_num_bits(A) == BN_num_bits(B)) { + if (!BN_one(D)) + goto err; + if (!BN_sub(M, A, B)) + goto err; + } else if (BN_num_bits(A) == BN_num_bits(B) + 1) { + /* A/B is 1, 2, or 3 */ + if (!BN_lshift1(T, B)) + goto err; + if (BN_ucmp(A, T) < 0) { + /* A < 2*B, so D=1 */ + if (!BN_one(D)) + goto err; + if (!BN_sub(M, A, B)) + goto err; + } else { + /* A >= 2*B, so D=2 or D=3 */ + if (!BN_sub(M, A, T)) + goto err; + if (!BN_add(D,T,B)) goto err; /* use D (:= 3*B) as temp */ + if (BN_ucmp(A, D) < 0) { + /* A < 3*B, so D=2 */ + if (!BN_set_word(D, 2)) + goto err; + /* M (= A - 2*B) already has the correct value */ + } else { + /* only D=3 remains */ + if (!BN_set_word(D, 3)) + goto err; + /* currently M = A - 2*B, but we need M = A - 3*B */ + if (!BN_sub(M, M, B)) + goto err; + } + } + } else { + if (!BN_div_nonct(D, M, A, B, ctx)) + goto err; + } + + /* Now + * A = D*B + M; + * thus we have + * (**) sign*Y*a == D*B + M (mod |n|). + */ + tmp = A; /* keep the BIGNUM object, the value does not matter */ + + /* (A, B) := (B, A mod B) ... */ + A = B; + B = M; + /* ... so we have 0 <= B < A again */ + + /* Since the former M is now B and the former B is now A, + * (**) translates into + * sign*Y*a == D*A + B (mod |n|), + * i.e. + * sign*Y*a - D*A == B (mod |n|). + * Similarly, (*) translates into + * -sign*X*a == A (mod |n|). + * + * Thus, + * sign*Y*a + D*sign*X*a == B (mod |n|), + * i.e. + * sign*(Y + D*X)*a == B (mod |n|). + * + * So if we set (X, Y, sign) := (Y + D*X, X, -sign), we arrive back at + * -sign*X*a == B (mod |n|), + * sign*Y*a == A (mod |n|). + * Note that X and Y stay non-negative all the time. + */ + + /* most of the time D is very small, so we can optimize tmp := D*X+Y */ + if (BN_is_one(D)) { + if (!BN_add(tmp, X, Y)) + goto err; + } else { + if (BN_is_word(D, 2)) { + if (!BN_lshift1(tmp, X)) + goto err; + } else if (BN_is_word(D, 4)) { + if (!BN_lshift(tmp, X, 2)) + goto err; + } else if (D->top == 1) { + if (!BN_copy(tmp, X)) + goto err; + if (!BN_mul_word(tmp, D->d[0])) + goto err; + } else { + if (!BN_mul(tmp, D,X, ctx)) + goto err; + } + if (!BN_add(tmp, tmp, Y)) + goto err; + } + + M = Y; /* keep the BIGNUM object, the value does not matter */ + Y = X; + X = tmp; + sign = -sign; + } } /* * The while loop (Euclid's algorithm) ends when * A == gcd(a,n); + * we have + * sign*Y*a == A (mod |n|), + * where Y is non-negative. */ - if (!BN_copy(R, A)) + if (sign < 0) { + if (!BN_sub(Y, n, Y)) + goto err; + } + /* Now Y*a == A (mod |n|). */ + + if (BN_is_one(A)) { + /* Y*a == 1 (mod |n|) */ + if (!Y->neg && BN_ucmp(Y, n) < 0) { + if (!BN_copy(R, Y)) + goto err; + } else { + if (!BN_nnmod(R, Y,n, ctx)) + goto err; + } + } else { + BNerror(BN_R_NO_INVERSE); goto err; + } ret = R; + err: if ((ret == NULL) && (in == NULL)) BN_free(R); BN_CTX_end(ctx); - bn_check_top(ret); return (ret); } + +BIGNUM * +BN_mod_inverse(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) +{ + int ct = ((BN_get_flags(a, BN_FLG_CONSTTIME) != 0) || + (BN_get_flags(n, BN_FLG_CONSTTIME) != 0)); + return BN_mod_inverse_internal(in, a, n, ctx, ct); +} + +BIGNUM * +BN_mod_inverse_nonct(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) +{ + return BN_mod_inverse_internal(in, a, n, ctx, 0); +} + +BIGNUM * +BN_mod_inverse_ct(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) +{ + return BN_mod_inverse_internal(in, a, n, ctx, 1); +} diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index 8562b3f8..5ee35308 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_gf2m.c,v 1.23 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bn_gf2m.c,v 1.29 2022/11/30 01:47:19 jsing Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -95,7 +95,7 @@ #include -#include "bn_lcl.h" +#include "bn_local.h" #ifndef OPENSSL_NO_EC2M @@ -325,8 +325,6 @@ BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) int i; const BIGNUM *at, *bt; - bn_check_top(a); - bn_check_top(b); if (a->top < b->top) { at = b; @@ -336,7 +334,7 @@ BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) bt = b; } - if (bn_wexpand(r, at->top) == NULL) + if (!bn_wexpand(r, at->top)) return 0; for (i = 0; i < bt->top; i++) { @@ -368,7 +366,6 @@ BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]) int n, dN, d0, d1; BN_ULONG zz, *z; - bn_check_top(a); if (!p[0]) { /* reduction mod 1 => return 0 */ @@ -464,17 +461,20 @@ int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p) { int ret = 0; - int arr[6]; + const int max = BN_num_bits(p) + 1; + int *arr = NULL; - bn_check_top(a); - bn_check_top(p); - ret = BN_GF2m_poly2arr(p, arr, sizeof(arr) / sizeof(arr[0])); - if (!ret || ret > (int)(sizeof(arr) / sizeof(arr[0]))) { + if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) + goto err; + ret = BN_GF2m_poly2arr(p, arr, max); + if (!ret || ret > max) { BNerror(BN_R_INVALID_LENGTH); - return 0; + goto err; } ret = BN_GF2m_mod_arr(r, a, arr); - bn_check_top(r); + + err: + free(arr); return ret; } @@ -490,8 +490,6 @@ BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], BIGNUM *s; BN_ULONG x1, x0, y1, y0, zz[4]; - bn_check_top(a); - bn_check_top(b); if (a == b) { return BN_GF2m_mod_sqr_arr(r, a, p, ctx); @@ -524,7 +522,6 @@ BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], bn_correct_top(s); if (BN_GF2m_mod_arr(r, s, p)) ret = 1; - bn_check_top(r); err: BN_CTX_end(ctx); @@ -546,9 +543,6 @@ BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, const int max = BN_num_bits(p) + 1; int *arr = NULL; - bn_check_top(a); - bn_check_top(b); - bn_check_top(p); if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); @@ -557,7 +551,6 @@ BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, goto err; } ret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx); - bn_check_top(r); err: free(arr); @@ -572,7 +565,6 @@ BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx) int i, ret = 0; BIGNUM *s; - bn_check_top(a); BN_CTX_start(ctx); if ((s = BN_CTX_get(ctx)) == NULL) goto err; @@ -588,7 +580,6 @@ BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx) bn_correct_top(s); if (!BN_GF2m_mod_arr(r, s, p)) goto err; - bn_check_top(r); ret = 1; err: @@ -609,8 +600,6 @@ BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) const int max = BN_num_bits(p) + 1; int *arr = NULL; - bn_check_top(a); - bn_check_top(p); if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); @@ -619,7 +608,6 @@ BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) goto err; } ret = BN_GF2m_mod_sqr_arr(r, a, arr, ctx); - bn_check_top(r); err: free(arr); @@ -638,8 +626,6 @@ BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) BIGNUM *b, *c = NULL, *u = NULL, *v = NULL, *tmp; int ret = 0; - bn_check_top(a); - bn_check_top(p); BN_CTX_start(ctx); @@ -789,15 +775,9 @@ BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) if (!BN_copy(r, b)) goto err; - bn_check_top(r); ret = 1; err: -#ifdef BN_DEBUG /* BN_CTX_end would complain about the expanded form */ - bn_correct_top(c); - bn_correct_top(u); - bn_correct_top(v); -#endif BN_CTX_end(ctx); return ret; } @@ -814,7 +794,6 @@ BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *xx, const int p[], BN_CTX *ctx) BIGNUM *field; int ret = 0; - bn_check_top(xx); BN_CTX_start(ctx); if ((field = BN_CTX_get(ctx)) == NULL) goto err; @@ -822,7 +801,6 @@ BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *xx, const int p[], BN_CTX *ctx) goto err; ret = BN_GF2m_mod_inv(r, xx, field, ctx); - bn_check_top(r); err: BN_CTX_end(ctx); @@ -841,9 +819,6 @@ BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, BIGNUM *xinv = NULL; int ret = 0; - bn_check_top(y); - bn_check_top(x); - bn_check_top(p); BN_CTX_start(ctx); if ((xinv = BN_CTX_get(ctx)) == NULL) @@ -853,7 +828,6 @@ BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, goto err; if (!BN_GF2m_mod_mul(r, y, xinv, p, ctx)) goto err; - bn_check_top(r); ret = 1; err: @@ -874,9 +848,6 @@ BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, BIGNUM *a, *b, *u, *v; int ret = 0; - bn_check_top(y); - bn_check_top(x); - bn_check_top(p); BN_CTX_start(ctx); @@ -943,7 +914,6 @@ BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, if (!BN_copy(r, u)) goto err; - bn_check_top(r); ret = 1; err: @@ -966,8 +936,6 @@ BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *yy, const BIGNUM *xx, BIGNUM *field; int ret = 0; - bn_check_top(yy); - bn_check_top(xx); BN_CTX_start(ctx); if ((field = BN_CTX_get(ctx)) == NULL) @@ -976,7 +944,6 @@ BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *yy, const BIGNUM *xx, goto err; ret = BN_GF2m_mod_div(r, yy, xx, field, ctx); - bn_check_top(r); err: BN_CTX_end(ctx); @@ -995,8 +962,6 @@ BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], int ret = 0, i, n; BIGNUM *u; - bn_check_top(a); - bn_check_top(b); if (BN_is_zero(b)) return (BN_one(r)); @@ -1022,7 +987,6 @@ BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], } if (!BN_copy(r, u)) goto err; - bn_check_top(r); ret = 1; err: @@ -1045,9 +1009,6 @@ BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, const int max = BN_num_bits(p) + 1; int *arr = NULL; - bn_check_top(a); - bn_check_top(b); - bn_check_top(p); if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); @@ -1056,7 +1017,6 @@ BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, goto err; } ret = BN_GF2m_mod_exp_arr(r, a, b, arr, ctx); - bn_check_top(r); err: free(arr); @@ -1073,7 +1033,6 @@ BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx) int ret = 0; BIGNUM *u; - bn_check_top(a); if (!p[0]) { /* reduction mod 1 => return 0 */ @@ -1088,7 +1047,6 @@ BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, const int p[], BN_CTX *ctx) if (!BN_set_bit(u, p[0] - 1)) goto err; ret = BN_GF2m_mod_exp_arr(r, a, u, p, ctx); - bn_check_top(r); err: BN_CTX_end(ctx); @@ -1108,8 +1066,6 @@ BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) int ret = 0; const int max = BN_num_bits(p) + 1; int *arr = NULL; - bn_check_top(a); - bn_check_top(p); if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); @@ -1118,7 +1074,6 @@ BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) goto err; } ret = BN_GF2m_mod_sqrt_arr(r, a, arr, ctx); - bn_check_top(r); err: free(arr); @@ -1135,7 +1090,6 @@ BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[], int ret = 0, count = 0, j; BIGNUM *a, *z, *rho, *w, *w2, *tmp; - bn_check_top(a_); if (!p[0]) { /* reduction mod 1 => return 0 */ @@ -1222,7 +1176,6 @@ BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[], if (!BN_copy(r, z)) goto err; - bn_check_top(r); ret = 1; @@ -1244,8 +1197,6 @@ BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) const int max = BN_num_bits(p) + 1; int *arr = NULL; - bn_check_top(a); - bn_check_top(p); if ((arr = reallocarray(NULL, max, sizeof(int))) == NULL) goto err; ret = BN_GF2m_poly2arr(p, arr, max); @@ -1254,7 +1205,6 @@ BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) goto err; } ret = BN_GF2m_mod_solve_quad_arr(r, a, arr, ctx); - bn_check_top(r); err: free(arr); @@ -1291,10 +1241,9 @@ BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max) } } - if (k < max) { + if (k < max) p[k] = -1; - k++; - } + k++; return k; } @@ -1307,13 +1256,11 @@ BN_GF2m_arr2poly(const int p[], BIGNUM *a) { int i; - bn_check_top(a); BN_zero(a); for (i = 0; p[i] != -1; i++) { if (BN_set_bit(a, p[i]) == 0) return 0; } - bn_check_top(a); return 1; } diff --git a/crypto/bn/bn_internal.h b/crypto/bn/bn_internal.h new file mode 100644 index 00000000..8a729b8e --- /dev/null +++ b/crypto/bn/bn_internal.h @@ -0,0 +1,390 @@ +/* $OpenBSD: bn_internal.h,v 1.11 2023/03/07 09:35:55 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include "bn_arch.h" + +#ifndef HEADER_BN_INTERNAL_H +#define HEADER_BN_INTERNAL_H + +#ifndef HAVE_BN_CT_NE_ZERO +static inline int +bn_ct_ne_zero(BN_ULONG w) +{ + return (w | ~(w - 1)) >> (BN_BITS2 - 1); +} +#endif + +#ifndef HAVE_BN_CT_NE_ZERO_MASK +static inline BN_ULONG +bn_ct_ne_zero_mask(BN_ULONG w) +{ + return 0 - bn_ct_ne_zero(w); +} +#endif + +#ifndef HAVE_BN_CT_EQ_ZERO +static inline int +bn_ct_eq_zero(BN_ULONG w) +{ + return 1 - bn_ct_ne_zero(w); +} +#endif + +#ifndef HAVE_BN_CT_EQ_ZERO_MASK +static inline BN_ULONG +bn_ct_eq_zero_mask(BN_ULONG w) +{ + return 0 - bn_ct_eq_zero(w); +} +#endif + +/* + * Big number primitives are named as the operation followed by a suffix + * that indicates the number of words that it operates on, where 'w' means + * single word, 'dw' means double word, 'tw' means triple word and 'qw' means + * quadruple word. Unless otherwise noted, the size of the output is implied + * based on its inputs, for example bn_mulw() takes two single word inputs + * and is going to produce a double word result. + * + * Where a function implements multiple operations, these are listed in order. + * For example, a function that computes (r1:r0) = a * b + c is named + * bn_mulw_addw(), producing a double word result. + */ + +/* + * bn_addw() computes (r1:r0) = a + b, where both inputs are single words, + * producing a double word result. The value of r1 is the carry from the + * addition. + */ +#ifndef HAVE_BN_ADDW +#ifdef BN_LLONG +static inline void +bn_addw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULLONG r; + + r = (BN_ULLONG)a + (BN_ULLONG)b; + + *out_r1 = r >> BN_BITS2; + *out_r0 = r & BN_MASK2; +} +#else + +static inline void +bn_addw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG r1, r0, c1, c2; + + c1 = a | b; + c2 = a & b; + r0 = a + b; + r1 = ((c1 & ~r0) | c2) >> (BN_BITS2 - 1); /* carry */ + + *out_r1 = r1; + *out_r0 = r0; +} +#endif +#endif + +/* + * bn_addw_addw() computes (r1:r0) = a + b + c, where all inputs are single + * words, producing a double word result. + */ +#ifndef HAVE_BN_ADDW_ADDW +static inline void +bn_addw_addw(BN_ULONG a, BN_ULONG b, BN_ULONG c, BN_ULONG *out_r1, + BN_ULONG *out_r0) +{ + BN_ULONG carry, r1, r0; + + bn_addw(a, b, &r1, &r0); + bn_addw(r0, c, &carry, &r0); + r1 += carry; + + *out_r1 = r1; + *out_r0 = r0; +} +#endif + +/* + * bn_subw() computes r0 = a - b, where both inputs are single words, + * producing a single word result and borrow. + */ +#ifndef HAVE_BN_SUBW +static inline void +bn_subw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_borrow, BN_ULONG *out_r0) +{ + BN_ULONG borrow, r0; + + r0 = a - b; + borrow = ((r0 | (b & ~a)) & (b | ~a)) >> (BN_BITS2 - 1); + + *out_borrow = borrow; + *out_r0 = r0; +} +#endif + +/* + * bn_subw_subw() computes r0 = a - b - c, where all inputs are single words, + * producing a single word result and borrow. + */ +#ifndef HAVE_BN_SUBW_SUBW +static inline void +bn_subw_subw(BN_ULONG a, BN_ULONG b, BN_ULONG c, BN_ULONG *out_borrow, + BN_ULONG *out_r0) +{ + BN_ULONG b1, b2, r0; + + bn_subw(a, b, &b1, &r0); + bn_subw(r0, c, &b2, &r0); + + *out_borrow = b1 + b2; + *out_r0 = r0; +} +#endif + +/* + * bn_mulw() computes (r1:r0) = a * b, where both inputs are single words, + * producing a double word result. + */ +#ifndef HAVE_BN_MULW +#ifdef BN_LLONG +static inline void +bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULLONG r; + + r = (BN_ULLONG)a * (BN_ULLONG)b; + + *out_r1 = r >> BN_BITS2; + *out_r0 = r & BN_MASK2; +} + +#else /* !BN_LLONG */ +/* + * Multiply two words (a * b) producing a double word result (h:l). + * + * This can be rewritten as: + * + * a * b = (hi32(a) * 2^32 + lo32(a)) * (hi32(b) * 2^32 + lo32(b)) + * = hi32(a) * hi32(b) * 2^64 + + * hi32(a) * lo32(b) * 2^32 + + * hi32(b) * lo32(a) * 2^32 + + * lo32(a) * lo32(b) + * + * The multiplication for each part of a and b can be calculated for each of + * these four terms without overflowing a BN_ULONG, as the maximum value of a + * 32 bit x 32 bit multiplication is 32 + 32 = 64 bits. Once these + * multiplications have been performed the result can be partitioned and summed + * into a double word (h:l). The same applies on a 32 bit system, substituting + * 16 for 32 and 32 for 64. + */ +#if 1 +static inline void +bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG a1, a0, b1, b0, r1, r0; + BN_ULONG carry, x; + + a1 = a >> BN_BITS4; + a0 = a & BN_MASK2l; + b1 = b >> BN_BITS4; + b0 = b & BN_MASK2l; + + r1 = a1 * b1; + r0 = a0 * b0; + + /* (a1 * b0) << BN_BITS4, partition the result across r1:r0 with carry. */ + x = a1 * b0; + r1 += x >> BN_BITS4; + bn_addw(r0, x << BN_BITS4, &carry, &r0); + r1 += carry; + + /* (b1 * a0) << BN_BITS4, partition the result across r1:r0 with carry. */ + x = b1 * a0; + r1 += x >> BN_BITS4; + bn_addw(r0, x << BN_BITS4, &carry, &r0); + r1 += carry; + + *out_r1 = r1; + *out_r0 = r0; +} +#else + +/* + * XXX - this accumulator based version uses fewer instructions, however + * requires more variables/registers. It seems to be slower on at least amd64 + * and i386, however may be faster on other architectures that have more + * registers available. Further testing is required and one of the two + * implementations should eventually be removed. + */ +static inline void +bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG a1, a0, b1, b0, r1, r0, x; + BN_ULONG acc0, acc1, acc2, acc3; + + a1 = a >> BN_BITS4; + b1 = b >> BN_BITS4; + a0 = a & BN_MASK2l; + b0 = b & BN_MASK2l; + + r1 = a1 * b1; + r0 = a0 * b0; + + acc0 = r0 & BN_MASK2l; + acc1 = r0 >> BN_BITS4; + acc2 = r1 & BN_MASK2l; + acc3 = r1 >> BN_BITS4; + + /* (a1 * b0) << BN_BITS4, partition the result across r1:r0. */ + x = a1 * b0; + acc1 += x & BN_MASK2l; + acc2 += (acc1 >> BN_BITS4) + (x >> BN_BITS4); + acc1 &= BN_MASK2l; + acc3 += acc2 >> BN_BITS4; + acc2 &= BN_MASK2l; + + /* (b1 * a0) << BN_BITS4, partition the result across r1:r0. */ + x = b1 * a0; + acc1 += x & BN_MASK2l; + acc2 += (acc1 >> BN_BITS4) + (x >> BN_BITS4); + acc1 &= BN_MASK2l; + acc3 += acc2 >> BN_BITS4; + acc2 &= BN_MASK2l; + + *out_r1 = (acc3 << BN_BITS4) | acc2; + *out_r0 = (acc1 << BN_BITS4) | acc0; +} +#endif +#endif /* !BN_LLONG */ +#endif + +#ifndef HAVE_BN_MULW_LO +static inline BN_ULONG +bn_mulw_lo(BN_ULONG a, BN_ULONG b) +{ + return a * b; +} +#endif + +#ifndef HAVE_BN_MULW_HI +static inline BN_ULONG +bn_mulw_hi(BN_ULONG a, BN_ULONG b) +{ + BN_ULONG h, l; + + bn_mulw(a, b, &h, &l); + + return h; +} +#endif + +/* + * bn_mulw_addw() computes (r1:r0) = a * b + c with all inputs being single + * words, producing a double word result. + */ +#ifndef HAVE_BN_MULW_ADDW +static inline void +bn_mulw_addw(BN_ULONG a, BN_ULONG b, BN_ULONG c, BN_ULONG *out_r1, + BN_ULONG *out_r0) +{ + BN_ULONG carry, r1, r0; + + bn_mulw(a, b, &r1, &r0); + bn_addw(r0, c, &carry, &r0); + r1 += carry; + + *out_r1 = r1; + *out_r0 = r0; +} +#endif + +/* + * bn_mulw_addw_addw() computes (r1:r0) = a * b + c + d with all inputs being + * single words, producing a double word result. + */ +#ifndef HAVE_BN_MULW_ADDW_ADDW +static inline void +bn_mulw_addw_addw(BN_ULONG a, BN_ULONG b, BN_ULONG c, BN_ULONG d, + BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG carry, r1, r0; + + bn_mulw_addw(a, b, c, &r1, &r0); + bn_addw(r0, d, &carry, &r0); + r1 += carry; + + *out_r1 = r1; + *out_r0 = r0; +} +#endif + +/* + * bn_mulw_addtw() computes (r2:r1:r0) = a * b + (c2:c1:c0), where a and b are + * single words and (c2:c1:c0) is a triple word, producing a triple word result. + * The caller must ensure that the inputs provided do not result in c2 + * overflowing. + */ +#ifndef HAVE_BN_MULW_ADDTW +static inline void +bn_mulw_addtw(BN_ULONG a, BN_ULONG b, BN_ULONG c2, BN_ULONG c1, BN_ULONG c0, + BN_ULONG *out_r2, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG carry, r2, r1, r0, x1; + + bn_mulw_addw(a, b, c0, &x1, &r0); + bn_addw(c1, x1, &carry, &r1); + r2 = c2 + carry; + + *out_r2 = r2; + *out_r1 = r1; + *out_r0 = r0; +} +#endif + +/* + * bn_mul2_mulw_addtw() computes (r2:r1:r0) = 2 * a * b + (c2:c1:c0), where a + * and b are single words and (c2:c1:c0) is a triple word, producing a triple + * word result. The caller must ensure that the inputs provided do not result + * in c2 overflowing. + */ +#ifndef HAVE_BN_MUL2_MULW_ADDTW +static inline void +bn_mul2_mulw_addtw(BN_ULONG a, BN_ULONG b, BN_ULONG c2, BN_ULONG c1, BN_ULONG c0, + BN_ULONG *out_r2, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG r2, r1, r0, x1, x0; + BN_ULONG carry; + + bn_mulw(a, b, &x1, &x0); + bn_addw(c0, x0, &carry, &r0); + bn_addw(c1, x1 + carry, &r2, &r1); + bn_addw(c2, r2, &carry, &r2); + bn_addw(r0, x0, &carry, &r0); + bn_addw(r1, x1 + carry, &carry, &r1); + r2 += carry; + + *out_r2 = r2; + *out_r1 = r1; + *out_r0 = r0; +} +#endif + +#endif diff --git a/crypto/bn/bn_isqrt.c b/crypto/bn/bn_isqrt.c index 19e31eab..ec77e1b0 100644 --- a/crypto/bn/bn_isqrt.c +++ b/crypto/bn/bn_isqrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_isqrt.c,v 1.2 2022/07/13 11:20:00 tb Exp $ */ +/* $OpenBSD: bn_isqrt.c,v 1.6 2022/12/17 15:56:25 jsing Exp $ */ /* * Copyright (c) 2022 Theo Buehler * @@ -21,7 +21,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" #define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \ __attribute__((__unused__)) @@ -74,8 +74,7 @@ bn_isqrt(BIGNUM *out_sqrt, int *out_perfect, const BIGNUM *n, BN_CTX *in_ctx) if (BN_is_zero(n)) { perfect = 1; - if (!BN_zero(a)) - goto err; + BN_zero(a); goto done; } diff --git a/crypto/bn/bn_kron.c b/crypto/bn/bn_kron.c index 998adedc..c991cd2f 100644 --- a/crypto/bn/bn_kron.c +++ b/crypto/bn/bn_kron.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_kron.c,v 1.10 2022/07/12 16:08:19 tb Exp $ */ +/* $OpenBSD: bn_kron.c,v 1.12 2022/11/26 16:08:51 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. * @@ -53,7 +53,7 @@ * */ -#include "bn_lcl.h" +#include "bn_local.h" /* * Kronecker symbol, implemented according to Henri Cohen, "A Course in @@ -71,8 +71,6 @@ BN_kronecker(const BIGNUM *A, const BIGNUM *B, BN_CTX *ctx) int k, v; int ret = -2; - bn_check_top(A); - bn_check_top(B); BN_CTX_start(ctx); diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index 599a7448..89e2713a 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lib.c,v 1.54 2022/06/27 12:25:49 tb Exp $ */ +/* $OpenBSD: bn_lib.c,v 1.76 2023/02/14 18:22:35 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,11 +56,6 @@ * [including the GNU Public Licence.] */ -#ifndef BN_DEBUG -# undef NDEBUG /* avoid conflicting definitions */ -# define NDEBUG -#endif - #include #include #include @@ -70,57 +65,32 @@ #include -#include "bn_lcl.h" - -/* This stuff appears to be completely unused, so is deprecated */ -#ifndef OPENSSL_NO_DEPRECATED -/* For a 32 bit machine - * 2 - 4 == 128 - * 3 - 8 == 256 - * 4 - 16 == 512 - * 5 - 32 == 1024 - * 6 - 64 == 2048 - * 7 - 128 == 4096 - * 8 - 256 == 8192 - */ -static int bn_limit_bits = 0; -static int bn_limit_num = 8; /* (1<flags = BN_FLG_MALLOCED; - ret->top = 0; - ret->neg = 0; - ret->dmax = 0; - ret->d = NULL; - bn_check_top(ret); - return (ret); + bn->flags = BN_FLG_MALLOCED; + + return bn; } void BN_init(BIGNUM *a) { memset(a, 0, sizeof(BIGNUM)); - bn_check_top(a); } void BN_clear(BIGNUM *a) { - bn_check_top(a); if (a->d != NULL) explicit_bzero(a->d, a->dmax * sizeof(a->d[0])); a->top = 0; @@ -128,27 +98,48 @@ BN_clear(BIGNUM *a) } void -BN_clear_free(BIGNUM *a) +BN_free(BIGNUM *bn) { - int i; + if (bn == NULL) + return; - if (a == NULL) + if (!BN_get_flags(bn, BN_FLG_STATIC_DATA)) + freezero(bn->d, bn->dmax * sizeof(bn->d[0])); + + if (!BN_get_flags(bn, BN_FLG_MALLOCED)) { + explicit_bzero(bn, sizeof(*bn)); return; - bn_check_top(a); - if (a->d != NULL && !(BN_get_flags(a, BN_FLG_STATIC_DATA))) - freezero(a->d, a->dmax * sizeof(a->d[0])); - i = BN_get_flags(a, BN_FLG_MALLOCED); - explicit_bzero(a, sizeof(BIGNUM)); - if (i) - free(a); + } + + freezero(bn, sizeof(*bn)); } void -BN_free(BIGNUM *a) +BN_clear_free(BIGNUM *bn) { - BN_clear_free(a); + BN_free(bn); } +/* This stuff appears to be completely unused, so is deprecated */ +#ifndef OPENSSL_NO_DEPRECATED +/* For a 32 bit machine + * 2 - 4 == 128 + * 3 - 8 == 256 + * 4 - 16 == 512 + * 5 - 32 == 1024 + * 6 - 64 == 2048 + * 7 - 128 == 4096 + * 8 - 256 == 8192 + */ +static int bn_limit_bits = 0; +static int bn_limit_num = 8; /* (1<> shift; - /* If x is 0, set mask to 0, otherwise set it to all 1s. */ - mask = ((~x & (x - 1)) >> (BN_BITS2 - 1)) - 1; - bits += shift & mask; - /* If x is 0, leave l alone, otherwise set l = x. */ - l ^= (x ^ l) & mask; - } while ((shift /= 2) != 0); - - return bits; + BN_ULONG bits, mask, shift; + + bits = shift = BN_BITS2; + mask = 0; + + while ((shift >>= 1) != 0) { + bits += (shift & mask) - (shift & ~mask); + mask = bn_ct_ne_zero_mask(w >> bits); + } + bits += 1 & mask; + + bits -= bn_ct_eq_zero(w); + + return BN_BITS2 - bits; +} +#endif + +int +BN_num_bits_word(BN_ULONG w) +{ + return BN_BITS2 - bn_word_clz(w); } int @@ -256,174 +252,74 @@ BN_num_bits(const BIGNUM *a) { int i = a->top - 1; - bn_check_top(a); - if (BN_is_zero(a)) return 0; return ((i * BN_BITS2) + BN_num_bits_word(a->d[i])); } -/* This is used both by bn_expand2() and bn_dup_expand() */ -/* The caller MUST check that words > b->dmax before calling this */ -static BN_ULONG * -bn_expand_internal(const BIGNUM *b, int words) +void +bn_correct_top(BIGNUM *a) { - BN_ULONG *A, *a = NULL; - const BN_ULONG *B; - int i; + while (a->top > 0 && a->d[a->top - 1] == 0) + a->top--; +} - bn_check_top(b); +static int +bn_expand_internal(BIGNUM *bn, int words) +{ + BN_ULONG *d; - if (words > (INT_MAX/(4*BN_BITS2))) { + if (words < 0) { + BNerror(BN_R_BIGNUM_TOO_LONG); // XXX + return 0; + } + + if (words > INT_MAX / (4 * BN_BITS2)) { BNerror(BN_R_BIGNUM_TOO_LONG); - return NULL; + return 0; } - if (BN_get_flags(b, BN_FLG_STATIC_DATA)) { + if (BN_get_flags(bn, BN_FLG_STATIC_DATA)) { BNerror(BN_R_EXPAND_ON_STATIC_BIGNUM_DATA); - return (NULL); + return 0; } - a = A = reallocarray(NULL, words, sizeof(BN_ULONG)); - if (A == NULL) { + + d = recallocarray(bn->d, bn->dmax, words, sizeof(BN_ULONG)); + if (d == NULL) { BNerror(ERR_R_MALLOC_FAILURE); - return (NULL); - } -#if 1 - B = b->d; - /* Check if the previous number needs to be copied */ - if (B != NULL) { - for (i = b->top >> 2; i > 0; i--, A += 4, B += 4) { - /* - * The fact that the loop is unrolled - * 4-wise is a tribute to Intel. It's - * the one that doesn't have enough - * registers to accommodate more data. - * I'd unroll it 8-wise otherwise:-) - * - * - */ - BN_ULONG a0, a1, a2, a3; - a0 = B[0]; - a1 = B[1]; - a2 = B[2]; - a3 = B[3]; - A[0] = a0; - A[1] = a1; - A[2] = a2; - A[3] = a3; - } - switch (b->top & 3) { - case 3: - A[2] = B[2]; - case 2: - A[1] = B[1]; - case 1: - A[0] = B[0]; - } + return 0; } + bn->d = d; + bn->dmax = words; -#else - memset(A, 0, sizeof(BN_ULONG) * words); - memcpy(A, b->d, sizeof(b->d[0]) * b->top); -#endif - - return (a); + return 1; } -/* This is an internal function that can be used instead of bn_expand2() - * when there is a need to copy BIGNUMs instead of only expanding the - * data part, while still expanding them. - * Especially useful when needing to expand BIGNUMs that are declared - * 'const' and should therefore not be changed. - * The reason to use this instead of a BN_dup() followed by a bn_expand2() - * is memory allocation overhead. A BN_dup() followed by a bn_expand2() - * will allocate new memory for the BIGNUM data twice, and free it once, - * while bn_dup_expand() makes sure allocation is made only once. - */ - -#ifndef OPENSSL_NO_DEPRECATED -BIGNUM * -bn_dup_expand(const BIGNUM *b, int words) +int +bn_expand(BIGNUM *bn, int bits) { - BIGNUM *r = NULL; + int words; - bn_check_top(b); + if (bits < 0) + return 0; - /* This function does not work if - * words <= b->dmax && top < words - * because BN_dup() does not preserve 'dmax'! - * (But bn_dup_expand() is not used anywhere yet.) - */ + if (bits > (INT_MAX - BN_BITS2 + 1)) + return 0; - if (words > b->dmax) { - BN_ULONG *a = bn_expand_internal(b, words); - - if (a) { - r = BN_new(); - if (r) { - r->top = b->top; - r->dmax = words; - r->neg = b->neg; - r->d = a; - } else { - /* r == NULL, BN_new failure */ - free(a); - } - } - /* If a == NULL, there was an error in allocation in - bn_expand_internal(), and NULL should be returned */ - } else { - r = BN_dup(b); - } + words = (bits + BN_BITS2 - 1) / BN_BITS2; - bn_check_top(r); - return r; + return bn_wexpand(bn, words); } -#endif -/* This is an internal function that should not be used in applications. - * It ensures that 'b' has enough room for a 'words' word number - * and initialises any unused part of b->d with leading zeros. - * It is mostly used by the various BIGNUM routines. If there is an error, - * NULL is returned. If not, 'b' is returned. */ - -BIGNUM * -bn_expand2(BIGNUM *b, int words) +int +bn_wexpand(BIGNUM *bn, int words) { - bn_check_top(b); - - if (words > b->dmax) { - BN_ULONG *a = bn_expand_internal(b, words); - if (!a) - return NULL; - if (b->d) - freezero(b->d, b->dmax * sizeof(b->d[0])); - b->d = a; - b->dmax = words; - } + if (words < 0) + return 0; -/* None of this should be necessary because of what b->top means! */ -#if 0 - /* NB: bn_wexpand() calls this only if the BIGNUM really has to grow */ - if (b->top < b->dmax) { - int i; - BN_ULONG *A = &(b->d[b->top]); - for (i = (b->dmax - b->top) >> 3; i > 0; i--, A += 8) { - A[0] = 0; - A[1] = 0; - A[2] = 0; - A[3] = 0; - A[4] = 0; - A[5] = 0; - A[6] = 0; - A[7] = 0; - } - for (i = (b->dmax - b->top)&7; i > 0; i--, A++) - A[0] = 0; - assert(A == &(b->d[b->dmax])); - } -#endif - bn_check_top(b); - return b; + if (words <= bn->dmax) + return 1; + + return bn_expand_internal(bn, words); } BIGNUM * @@ -433,7 +329,6 @@ BN_dup(const BIGNUM *a) if (a == NULL) return NULL; - bn_check_top(a); t = BN_new(); if (t == NULL) @@ -442,7 +337,6 @@ BN_dup(const BIGNUM *a) BN_free(t); return NULL; } - bn_check_top(t); return t; } @@ -453,11 +347,10 @@ BN_copy(BIGNUM *a, const BIGNUM *b) BN_ULONG *A; const BN_ULONG *B; - bn_check_top(b); if (a == b) return (a); - if (bn_wexpand(a, b->top) == NULL) + if (!bn_wexpand(a, b->top)) return (NULL); #if 1 @@ -488,7 +381,6 @@ BN_copy(BIGNUM *a, const BIGNUM *b) a->top = b->top; a->neg = b->neg; - bn_check_top(a); return (a); } @@ -499,8 +391,6 @@ BN_swap(BIGNUM *a, BIGNUM *b) BN_ULONG *tmp_d; int tmp_top, tmp_dmax, tmp_neg; - bn_check_top(a); - bn_check_top(b); flags_old_a = a->flags; flags_old_b = b->flags; @@ -524,8 +414,6 @@ BN_swap(BIGNUM *a, BIGNUM *b) (flags_old_b & BN_FLG_STATIC_DATA); b->flags = (flags_old_b & BN_FLG_MALLOCED) | (flags_old_a & BN_FLG_STATIC_DATA); - bn_check_top(a); - bn_check_top(b); } BN_ULONG @@ -539,28 +427,14 @@ BN_get_word(const BIGNUM *a) return 0; } -BIGNUM * -bn_expand(BIGNUM *a, int bits) -{ - if (bits > (INT_MAX - BN_BITS2 + 1)) - return (NULL); - - if (((bits + BN_BITS2 - 1) / BN_BITS2) <= a->dmax) - return (a); - - return bn_expand2(a, (bits + BN_BITS2 - 1) / BN_BITS2); -} - int BN_set_word(BIGNUM *a, BN_ULONG w) { - bn_check_top(a); - if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL) + if (!bn_wexpand(a, 1)) return (0); a->neg = 0; a->d[0] = w; a->top = (w ? 1 : 0); - bn_check_top(a); return (1); } @@ -578,7 +452,6 @@ BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret) ret = bn = BN_new(); if (ret == NULL) return (NULL); - bn_check_top(ret); l = 0; n = len; if (n == 0) { @@ -587,7 +460,7 @@ BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret) } i = ((n - 1) / BN_BYTES) + 1; m = ((n - 1) % (BN_BYTES)); - if (bn_wexpand(ret, (int)i) == NULL) { + if (!bn_wexpand(ret, (int)i)) { BN_free(bn); return NULL; } @@ -695,7 +568,6 @@ BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret) if (ret == NULL) return NULL; - bn_check_top(ret); s += len; /* Skip trailing zeroes. */ @@ -710,7 +582,7 @@ BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret) i = ((n - 1) / BN_BYTES) + 1; m = (n - 1) % BN_BYTES; - if (bn_wexpand(ret, (int)i) == NULL) { + if (!bn_wexpand(ret, (int)i)) { BN_free(bn); return NULL; } @@ -750,71 +622,38 @@ int BN_ucmp(const BIGNUM *a, const BIGNUM *b) { int i; - BN_ULONG t1, t2, *ap, *bp; - bn_check_top(a); - bn_check_top(b); + if (a->top < b->top) + return -1; + if (a->top > b->top) + return 1; - i = a->top - b->top; - if (i != 0) - return (i); - ap = a->d; - bp = b->d; for (i = a->top - 1; i >= 0; i--) { - t1 = ap[i]; - t2 = bp[i]; - if (t1 != t2) - return ((t1 > t2) ? 1 : -1); + if (a->d[i] != b->d[i]) + return (a->d[i] > b->d[i] ? 1 : -1); } - return (0); + + return 0; } int BN_cmp(const BIGNUM *a, const BIGNUM *b) { - int i; - int gt, lt; - BN_ULONG t1, t2; - - if ((a == NULL) || (b == NULL)) { + if (a == NULL || b == NULL) { if (a != NULL) - return (-1); - else if (b != NULL) - return (1); - else - return (0); + return -1; + if (b != NULL) + return 1; + return 0; } - bn_check_top(a); - bn_check_top(b); + if (a->neg != b->neg) + return b->neg - a->neg; - if (a->neg != b->neg) { - if (a->neg) - return (-1); - else - return (1); - } - if (a->neg == 0) { - gt = 1; - lt = -1; - } else { - gt = -1; - lt = 1; - } + if (a->neg) + return BN_ucmp(b, a); - if (a->top > b->top) - return (gt); - if (a->top < b->top) - return (lt); - for (i = a->top - 1; i >= 0; i--) { - t1 = a->d[i]; - t2 = b->d[i]; - if (t1 > t2) - return (gt); - if (t1 < t2) - return (lt); - } - return (0); + return BN_ucmp(a, b); } int @@ -828,7 +667,7 @@ BN_set_bit(BIGNUM *a, int n) i = n / BN_BITS2; j = n % BN_BITS2; if (a->top <= i) { - if (bn_wexpand(a, i + 1) == NULL) + if (!bn_wexpand(a, i + 1)) return (0); for (k = a->top; k < i + 1; k++) a->d[k] = 0; @@ -836,7 +675,6 @@ BN_set_bit(BIGNUM *a, int n) } a->d[i] |= (((BN_ULONG)1) << j); - bn_check_top(a); return (1); } @@ -845,7 +683,6 @@ BN_clear_bit(BIGNUM *a, int n) { int i, j; - bn_check_top(a); if (n < 0) return 0; @@ -864,7 +701,6 @@ BN_is_bit_set(const BIGNUM *a, int n) { int i, j; - bn_check_top(a); if (n < 0) return 0; i = n / BN_BITS2; @@ -879,7 +715,6 @@ BN_mask_bits(BIGNUM *a, int n) { int b, w; - bn_check_top(a); if (n < 0) return 0; @@ -898,12 +733,9 @@ BN_mask_bits(BIGNUM *a, int n) } void -BN_set_negative(BIGNUM *a, int b) +BN_set_negative(BIGNUM *bn, int neg) { - if (b && !BN_is_zero(a)) - a->neg = 1; - else - a->neg = 0; + bn->neg = ~BN_is_zero(bn) & bn_ct_ne_zero(neg); } int @@ -969,9 +801,6 @@ BN_consttime_swap(BN_ULONG condition, BIGNUM *a, BIGNUM *b, int nwords) BN_ULONG t; int i; - bn_wcheck_size(a, nwords); - bn_wcheck_size(b, nwords); - assert(a != b); assert((condition & (condition - 1)) == 0); assert(sizeof(BN_ULONG) >= sizeof(int)); @@ -1026,7 +855,7 @@ BN_swap_ct(BN_ULONG condition, BIGNUM *a, BIGNUM *b, size_t nwords) if (nwords > INT_MAX) return 0; words = (int)nwords; - if (bn_wexpand(a, words) == NULL || bn_wexpand(b, words) == NULL) + if (!bn_wexpand(a, words) || !bn_wexpand(b, words)) return 0; if (a->top > words || b->top > words) { BNerror(BN_R_INVALID_LENGTH); @@ -1062,11 +891,22 @@ BN_swap_ct(BN_ULONG condition, BIGNUM *a, BIGNUM *b, size_t nwords) } void -BN_zero_ex(BIGNUM *a) +BN_zero(BIGNUM *a) { a->neg = 0; a->top = 0; - /* XXX: a->flags &= ~BN_FIXED_TOP */ +} + +void +BN_zero_ex(BIGNUM *a) +{ + BN_zero(a); +} + +int +BN_one(BIGNUM *a) +{ + return BN_set_word(a, 1); } int @@ -1076,9 +916,15 @@ BN_abs_is_word(const BIGNUM *a, const BN_ULONG w) } int -BN_is_zero(const BIGNUM *a) +BN_is_zero(const BIGNUM *bn) { - return a->top == 0; + BN_ULONG bits = 0; + int i; + + for (i = 0; i < bn->top; i++) + bits |= bn->d[i]; + + return bits == 0; } int diff --git a/crypto/bn/bn_lcl.h b/crypto/bn/bn_local.h similarity index 52% rename from crypto/bn/bn_lcl.h rename to crypto/bn/bn_local.h index 9ddfbbbe..4576c36c 100644 --- a/crypto/bn/bn_lcl.h +++ b/crypto/bn/bn_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lcl.h,v 1.35 2022/07/15 06:10:00 tb Exp $ */ +/* $OpenBSD: bn_local.h,v 1.17 2023/02/22 05:57:19 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -109,8 +109,8 @@ * */ -#ifndef HEADER_BN_LCL_H -#define HEADER_BN_LCL_H +#ifndef HEADER_BN_LOCAL_H +#define HEADER_BN_LOCAL_H #include @@ -127,15 +127,14 @@ struct bignum_st { int flags; }; -/* Used for montgomery multiplication */ struct bn_mont_ctx_st { - int ri; /* number of bits in R */ - BIGNUM RR; /* used to convert to montgomery form */ - BIGNUM N; /* The modulus */ - BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 - * (Ni is only stored for bignum algorithm) */ - BN_ULONG n0[2];/* least significant word(s) of Ni; - (type changed with 0.9.9, was "BN_ULONG n0;" before) */ + int ri; /* Number of bits in R */ + BIGNUM RR; /* Used to convert to Montgomery form */ + BIGNUM N; /* Modulus */ + + /* Least significant word(s) of Ni; R*(1/R mod N) - N*Ni = 1 */ + BN_ULONG n0[2]; + int flags; }; @@ -241,267 +240,22 @@ struct bn_gencb_st { #define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32) /* 32 */ #define BN_MONT_CTX_SET_SIZE_WORD (64) /* 32 */ -#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) -/* - * BN_UMULT_HIGH section. - * - * No, I'm not trying to overwhelm you when stating that the - * product of N-bit numbers is 2*N bits wide:-) No, I don't expect - * you to be impressed when I say that if the compiler doesn't - * support 2*N integer type, then you have to replace every N*N - * multiplication with 4 (N/2)*(N/2) accompanied by some shifts - * and additions which unavoidably results in severe performance - * penalties. Of course provided that the hardware is capable of - * producing 2*N result... That's when you normally start - * considering assembler implementation. However! It should be - * pointed out that some CPUs (most notably Alpha, PowerPC and - * upcoming IA-64 family:-) provide *separate* instruction - * calculating the upper half of the product placing the result - * into a general purpose register. Now *if* the compiler supports - * inline assembler, then it's not impossible to implement the - * "bignum" routines (and have the compiler optimize 'em) - * exhibiting "native" performance in C. That's what BN_UMULT_HIGH - * macro is about:-) - * - * - */ -# if defined(__alpha) -# if defined(__GNUC__) && __GNUC__>=2 -# define BN_UMULT_HIGH(a,b) ({ \ - BN_ULONG ret; \ - asm ("umulh %1,%2,%0" \ - : "=r"(ret) \ - : "r"(a), "r"(b)); \ - ret; }) -# endif /* compiler */ -# elif defined(_ARCH_PPC) && defined(_LP64) -# if defined(__GNUC__) && __GNUC__>=2 -# define BN_UMULT_HIGH(a,b) ({ \ - BN_ULONG ret; \ - asm ("mulhdu %0,%1,%2" \ - : "=r"(ret) \ - : "r"(a), "r"(b)); \ - ret; }) -# endif /* compiler */ -# elif (defined(__x86_64) || defined(__x86_64__)) && defined(_LP64) -# if defined(__GNUC__) && __GNUC__>=2 -# define BN_UMULT_HIGH(a,b) ({ \ - BN_ULONG ret,discard; \ - asm ("mulq %3" \ - : "=a"(discard),"=d"(ret) \ - : "a"(a), "g"(b) \ - : "cc"); \ - ret; }) -# define BN_UMULT_LOHI(low,high,a,b) \ - asm ("mulq %3" \ - : "=a"(low),"=d"(high) \ - : "a"(a),"g"(b) \ - : "cc"); -# endif -# elif defined(__mips) && defined(_LP64) -# if defined(__GNUC__) && __GNUC__>=2 -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) /* "h" constraint is no more since 4.4 */ -# define BN_UMULT_HIGH(a,b) (((__uint128_t)(a)*(b))>>64) -# define BN_UMULT_LOHI(low,high,a,b) ({ \ - __uint128_t ret=(__uint128_t)(a)*(b); \ - (high)=ret>>64; (low)=ret; }) -# else -# define BN_UMULT_HIGH(a,b) ({ \ - BN_ULONG ret; \ - asm ("dmultu %1,%2" \ - : "=h"(ret) \ - : "r"(a), "r"(b) : "l"); \ - ret; }) -# define BN_UMULT_LOHI(low,high,a,b)\ - asm ("dmultu %2,%3" \ - : "=l"(low),"=h"(high) \ - : "r"(a), "r"(b)); -# endif -# endif -# endif /* cpu */ -#endif /* OPENSSL_NO_ASM */ - -/************************************************************* - * Using the long long type - */ -#define Lw(t) (((BN_ULONG)(t))&BN_MASK2) -#define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2) - -#ifdef BN_DEBUG_RAND -#define bn_clear_top2max(a) \ - { \ - int ind = (a)->dmax - (a)->top; \ - BN_ULONG *ftl = &(a)->d[(a)->top-1]; \ - for (; ind != 0; ind--) \ - *(++ftl) = 0x0; \ - } -#else -#define bn_clear_top2max(a) -#endif - -#ifdef BN_LLONG -#define mul_add(r,a,w,c) { \ - BN_ULLONG t; \ - t=(BN_ULLONG)w * (a) + (r) + (c); \ - (r)= Lw(t); \ - (c)= Hw(t); \ - } - -#define mul(r,a,w,c) { \ - BN_ULLONG t; \ - t=(BN_ULLONG)w * (a) + (c); \ - (r)= Lw(t); \ - (c)= Hw(t); \ - } - -#define sqr(r0,r1,a) { \ - BN_ULLONG t; \ - t=(BN_ULLONG)(a)*(a); \ - (r0)=Lw(t); \ - (r1)=Hw(t); \ - } - -#elif defined(BN_UMULT_LOHI) -#define mul_add(r,a,w,c) { \ - BN_ULONG high,low,ret,tmp=(a); \ - ret = (r); \ - BN_UMULT_LOHI(low,high,w,tmp); \ - ret += (c); \ - (c) = (ret<(c))?1:0; \ - (c) += high; \ - ret += low; \ - (c) += (ret>BN_BITS4)&BN_MASK2l) -#define L2HBITS(a) (((a)<>(BN_BITS4-1); \ - m =(m&BN_MASK2l)<<(BN_BITS4+1); \ - l=(l+m)&BN_MASK2; if (l < m) h++; \ - (lo)=l; \ - (ho)=h; \ - } - -#define mul_add(r,a,bl,bh,c) { \ - BN_ULONG l,h; \ - \ - h= (a); \ - l=LBITS(h); \ - h=HBITS(h); \ - mul64(l,h,(bl),(bh)); \ - \ - /* non-multiply part */ \ - l=(l+(c))&BN_MASK2; if (l < (c)) h++; \ - (c)=(r); \ - l=(l+(c))&BN_MASK2; if (l < (c)) h++; \ - (c)=h&BN_MASK2; \ - (r)=l; \ - } - -#define mul(r,a,bl,bh,c) { \ - BN_ULONG l,h; \ - \ - h= (a); \ - l=LBITS(h); \ - h=HBITS(h); \ - mul64(l,h,(bl),(bh)); \ - \ - /* non-multiply part */ \ - l+=(c); if ((l&BN_MASK2) < (c)) h++; \ - (c)=h&BN_MASK2; \ - (r)=l&BN_MASK2; \ - } -#endif /* !BN_LLONG */ - /* The least significant word of a BIGNUM. */ #define BN_lsw(n) (((n)->top == 0) ? (BN_ULONG) 0 : (n)->d[0]) +BN_ULONG bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, + const BN_ULONG *b, int b_len); +BN_ULONG bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, + const BN_ULONG *b, int b_len); + void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb); -void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); +void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b); + void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp); -void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a); void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a); +void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a); + int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n); int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl); @@ -510,124 +264,25 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, int tna, int tnb, BN_ULONG *t); void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t); -void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n); -void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, - BN_ULONG *t); -void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2, - BN_ULONG *t); -BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, - int cl, int dl); -BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, - int cl, int dl); -int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num); - -#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) -BIGNUM *bn_expand2(BIGNUM *a, int words); -BIGNUM *bn_expand(BIGNUM *a, int bits); - -BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */ - -/* Bignum consistency macros - * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from - * bignum data after direct manipulations on the data. There is also an - * "internal" macro, bn_check_top(), for verifying that there are no leading - * zeroes. Unfortunately, some auditing is required due to the fact that - * bn_fix_top() has become an overabused duct-tape because bignum data is - * occasionally passed around in an inconsistent state. So the following - * changes have been made to sort this out; - * - bn_fix_top()s implementation has been moved to bn_correct_top() - * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and - * bn_check_top() is as before. - * - if BN_DEBUG *is* defined; - * - bn_check_top() tries to pollute unused words even if the bignum 'top' is - * consistent. (ed: only if BN_DEBUG_RAND is defined) - * - bn_fix_top() maps to bn_check_top() rather than "fixing" anything. - * The idea is to have debug builds flag up inconsistent bignums when they - * occur. If that occurs in a bn_fix_top(), we examine the code in question; if - * the use of bn_fix_top() was appropriate (ie. it follows directly after code - * that manipulates the bignum) it is converted to bn_correct_top(), and if it - * was not appropriate, we convert it permanently to bn_check_top() and track - * down the cause of the bug. Eventually, no internal code should be using the - * bn_fix_top() macro. External applications and libraries should try this with - * their own code too, both in terms of building against the openssl headers - * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it - * defined. This not only improves external code, it provides more test - * coverage for openssl's own code. - */ - -#ifdef BN_DEBUG - -/* We only need assert() when debugging */ -#include - -#ifdef BN_DEBUG_RAND -#define bn_pollute(a) \ - do { \ - const BIGNUM *_bnum1 = (a); \ - if(_bnum1->top < _bnum1->dmax) { \ - unsigned char _tmp_char; \ - /* We cast away const without the compiler knowing, any \ - * *genuinely* constant variables that aren't mutable \ - * wouldn't be constructed with top!=dmax. */ \ - BN_ULONG *_not_const; \ - memcpy(&_not_const, &_bnum1->d, sizeof(BN_ULONG*)); \ - arc4random_buf(&_tmp_char, 1); \ - memset((unsigned char *)(_not_const + _bnum1->top), _tmp_char, \ - (_bnum1->dmax - _bnum1->top) * sizeof(BN_ULONG)); \ - } \ - } while(0) -#else -#define bn_pollute(a) -#endif +int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, const BN_ULONG *n0, int num); -#define bn_check_top(a) \ - do { \ - const BIGNUM *_bnum2 = (a); \ - if (_bnum2 != NULL) { \ - assert((_bnum2->top == 0) || \ - (_bnum2->d[_bnum2->top - 1] != 0)); \ - bn_pollute(_bnum2); \ - } \ - } while(0) - -#define bn_fix_top(a) bn_check_top(a) - -#define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2) -#define bn_wcheck_size(bn, words) \ - do { \ - const BIGNUM *_bnum2 = (bn); \ - assert(words <= (_bnum2)->dmax && words >= (_bnum2)->top); \ - } while(0) - -#else /* !BN_DEBUG */ - -#define bn_pollute(a) -#define bn_check_top(a) -#define bn_fix_top(a) bn_correct_top(a) -#define bn_check_size(bn, bits) -#define bn_wcheck_size(bn, words) +int bn_word_clz(BN_ULONG w); -#endif - -#define bn_correct_top(a) \ - { \ - BN_ULONG *ftl; \ - int tmp_top = (a)->top; \ - if (tmp_top > 0) \ - { \ - for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \ - if (*(ftl--)) break; \ - (a)->top = tmp_top; \ - } \ - bn_pollute(a); \ - } +void bn_correct_top(BIGNUM *a); +int bn_expand(BIGNUM *a, int bits); +int bn_wexpand(BIGNUM *a, int words); +BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + int num); +BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + int num); BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); -BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, int num); -BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, int num); +void bn_div_rem_words(BN_ULONG h, BN_ULONG l, BN_ULONG d, BN_ULONG *out_q, + BN_ULONG *out_r); int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom); int bn_rand_interval(BIGNUM *rnd, const BIGNUM *lower_inc, const BIGNUM *upper_exc); @@ -641,12 +296,13 @@ int BN_mod_exp_mont_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); int BN_mod_exp_mont_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_div_nonct(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, +int BN_div_nonct(BIGNUM *q, BIGNUM *r, const BIGNUM *n, const BIGNUM *d, BN_CTX *ctx); -int BN_div_ct(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, +int BN_div_ct(BIGNUM *q, BIGNUM *r, const BIGNUM *n, const BIGNUM *d, BN_CTX *ctx); -#define BN_mod_ct(rem,m,d,ctx) BN_div_ct(NULL,(rem),(m),(d),(ctx)) -#define BN_mod_nonct(rem,m,d,ctx) BN_div_nonct(NULL,(rem),(m),(d),(ctx)) +int BN_mod_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); + BIGNUM *BN_mod_inverse_ct(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); BIGNUM *BN_mod_inverse_nonct(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n, @@ -662,4 +318,4 @@ int bn_is_perfect_square(int *out_perfect, const BIGNUM *n, BN_CTX *ctx); int bn_is_prime_bpsw(int *is_prime, const BIGNUM *n, BN_CTX *in_ctx); __END_HIDDEN_DECLS -#endif +#endif /* !HEADER_BN_LOCAL_H */ diff --git a/crypto/bn/bn_mod.c b/crypto/bn/bn_mod.c index 897ff434..2072dd90 100644 --- a/crypto/bn/bn_mod.c +++ b/crypto/bn/bn_mod.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mod.c,v 1.12 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bn_mod.c,v 1.19 2023/02/03 05:15:40 jsing Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. */ /* ==================================================================== @@ -113,23 +113,34 @@ #include -#include "bn_lcl.h" +#include "bn_local.h" int -BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) +BN_mod_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) { - /* like BN_mod, but returns non-negative remainder - * (i.e., 0 <= r < |d| always holds) */ + return BN_div_ct(NULL, r, a, m, ctx); +} + +int +BN_mod_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) +{ + return BN_div_nonct(NULL, r, a, m, ctx); +} - if (!(BN_mod_ct(r, m,d, ctx))) +/* + * BN_nnmod() is like BN_mod(), but always returns a non-negative remainder + * (that is 0 <= r < |m| always holds). If both a and m have the same sign then + * the result is already non-negative. Otherwise, -|m| < r < 0, which needs to + * be adjusted as r := r + |m|. This equates to r := |m| - |r|. + */ +int +BN_nnmod(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) +{ + if (!BN_mod_ct(r, a, m, ctx)) return 0; - if (!r->neg) - return 1; - /* now -|d| < r < 0, so we have to set r := r + |d| */ - if (d->neg) - return BN_sub(r, r, d); - else - return BN_add(r, r, d); + if (BN_is_negative(r)) + return BN_usub(r, m, r); + return 1; } int @@ -141,8 +152,10 @@ BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, return BN_nnmod(r, r, m, ctx); } -/* BN_mod_add variant that may be used if both a and b are non-negative - * and less than m */ +/* + * BN_mod_add() variant that may only be used if both a and b are non-negative + * and have already been reduced (less than m). + */ int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m) { @@ -162,57 +175,57 @@ BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, return BN_nnmod(r, r, m, ctx); } -/* BN_mod_sub variant that may be used if both a and b are non-negative - * and less than m */ +/* + * BN_mod_sub() variant that may only be used if both a and b are non-negative + * and have already been reduced (less than m). + */ int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m) { - if (!BN_sub(r, a, b)) + if (BN_ucmp(a, b) >= 0) + return BN_usub(r, a, b); + if (!BN_usub(r, b, a)) return 0; - if (r->neg) - return BN_add(r, r, m); - return 1; + return BN_usub(r, m, r); } -/* slow but works */ int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx) { - BIGNUM *t; + BIGNUM *rr; int ret = 0; - bn_check_top(a); - bn_check_top(b); - bn_check_top(m); - BN_CTX_start(ctx); - if ((t = BN_CTX_get(ctx)) == NULL) + + rr = r; + if (rr == a || rr == b) + rr = BN_CTX_get(ctx); + if (rr == NULL) goto err; + if (a == b) { - if (!BN_sqr(t, a, ctx)) + if (!BN_sqr(rr, a, ctx)) goto err; } else { - if (!BN_mul(t, a,b, ctx)) + if (!BN_mul(rr, a, b, ctx)) goto err; } - if (!BN_nnmod(r, t,m, ctx)) + if (!BN_nnmod(r, rr, m, ctx)) goto err; - bn_check_top(r); + ret = 1; -err: + err: BN_CTX_end(ctx); - return (ret); + + return ret; } int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) { - if (!BN_sqr(r, a, ctx)) - return 0; - /* r->neg == 0, thus we don't need BN_nnmod */ - return BN_mod_ct(r, r, m, ctx); + return BN_mod_mul(r, a, a, m, ctx); } int @@ -220,89 +233,83 @@ BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) { if (!BN_lshift1(r, a)) return 0; - bn_check_top(r); return BN_nnmod(r, r, m, ctx); } -/* BN_mod_lshift1 variant that may be used if a is non-negative - * and less than m */ +/* + * BN_mod_lshift1() variant that may be used if a is non-negative + * and has already been reduced (less than m). + */ int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m) { if (!BN_lshift1(r, a)) return 0; - bn_check_top(r); - if (BN_cmp(r, m) >= 0) - return BN_sub(r, r, m); + if (BN_ucmp(r, m) >= 0) + return BN_usub(r, r, m); return 1; } int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx) { - BIGNUM *abs_m = NULL; - int ret; + BIGNUM *abs_m; + int ret = 0; + + BN_CTX_start(ctx); if (!BN_nnmod(r, a, m, ctx)) - return 0; + goto err; - if (m->neg) { - abs_m = BN_dup(m); - if (abs_m == NULL) - return 0; - abs_m->neg = 0; + if (BN_is_negative(m)) { + if ((abs_m = BN_CTX_get(ctx)) == NULL) + goto err; + if (BN_copy(abs_m, m) == NULL) + goto err; + BN_set_negative(abs_m, 0); + m = abs_m; } + if (!BN_mod_lshift_quick(r, r, n, m)) + goto err; - ret = BN_mod_lshift_quick(r, r, n, (abs_m ? abs_m : m)); - bn_check_top(r); + ret = 1; + err: + BN_CTX_end(ctx); - BN_free(abs_m); return ret; } -/* BN_mod_lshift variant that may be used if a is non-negative - * and less than m */ +/* + * BN_mod_lshift() variant that may be used if a is non-negative + * and has already been reduced (less than m). + */ int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m) { - if (r != a) { - if (BN_copy(r, a) == NULL) - return 0; - } - - while (n > 0) { - int max_shift; + int max_shift; - /* 0 < r < m */ - max_shift = BN_num_bits(m) - BN_num_bits(r); - /* max_shift >= 0 */ + if (BN_copy(r, a) == NULL) + return 0; - if (max_shift < 0) { + while (n > 0) { + if ((max_shift = BN_num_bits(m) - BN_num_bits(r)) < 0) { BNerror(BN_R_INPUT_NOT_REDUCED); return 0; } - + if (max_shift == 0) + max_shift = 1; if (max_shift > n) max_shift = n; - if (max_shift) { - if (!BN_lshift(r, r, max_shift)) - return 0; - n -= max_shift; - } else { - if (!BN_lshift1(r, r)) - return 0; - --n; - } - - /* BN_num_bits(r) <= BN_num_bits(m) */ + if (!BN_lshift(r, r, max_shift)) + return 0; + n -= max_shift; - if (BN_cmp(r, m) >= 0) { - if (!BN_sub(r, r, m)) + if (BN_ucmp(r, m) >= 0) { + if (!BN_usub(r, r, m)) return 0; } } - bn_check_top(r); return 1; } diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c index e01af702..ed49ec83 100644 --- a/crypto/bn/bn_mont.c +++ b/crypto/bn/bn_mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mont.c,v 1.28 2022/02/07 19:44:23 tb Exp $ */ +/* $OpenBSD: bn_mont.c,v 1.52 2023/03/07 09:42:09 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -118,430 +118,457 @@ #include #include +#include -#include "bn_lcl.h" +#include "bn_internal.h" +#include "bn_local.h" -#define MONT_WORD /* use the faster word-based algorithm */ +BN_MONT_CTX * +BN_MONT_CTX_new(void) +{ + BN_MONT_CTX *mctx; -#ifdef MONT_WORD -static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont); -#endif + if ((mctx = calloc(1, sizeof(BN_MONT_CTX))) == NULL) + return NULL; + mctx->flags = BN_FLG_MALLOCED; + + BN_init(&mctx->RR); + BN_init(&mctx->N); + + return mctx; +} + +void +BN_MONT_CTX_init(BN_MONT_CTX *mctx) +{ + memset(mctx, 0, sizeof(*mctx)); + + BN_init(&mctx->RR); + BN_init(&mctx->N); +} + +void +BN_MONT_CTX_free(BN_MONT_CTX *mctx) +{ + if (mctx == NULL) + return; + + BN_free(&mctx->RR); + BN_free(&mctx->N); + + if (mctx->flags & BN_FLG_MALLOCED) + free(mctx); +} + +BN_MONT_CTX * +BN_MONT_CTX_copy(BN_MONT_CTX *dst, BN_MONT_CTX *src) +{ + if (dst == src) + return dst; + + if (!BN_copy(&dst->RR, &src->RR)) + return NULL; + if (!BN_copy(&dst->N, &src->N)) + return NULL; + + dst->ri = src->ri; + dst->n0[0] = src->n0[0]; + dst->n0[1] = src->n0[1]; + + return dst; +} int -BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - BN_MONT_CTX *mont, BN_CTX *ctx) +BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) { - BIGNUM *tmp; + BIGNUM *N, *Ninv, *Rinv, *R; int ret = 0; -#if defined(OPENSSL_BN_ASM_MONT) && defined(MONT_WORD) - int num = mont->N.top; - - if (num > 1 && a->top == num && b->top == num) { - if (bn_wexpand(r, num) == NULL) - return (0); - if (bn_mul_mont(r->d, a->d, b->d, mont->N.d, mont->n0, num)) { - r->neg = a->neg^b->neg; - r->top = num; - bn_correct_top(r); - return (1); - } + + BN_CTX_start(ctx); + + if ((N = BN_CTX_get(ctx)) == NULL) + goto err; + if ((Ninv = BN_CTX_get(ctx)) == NULL) + goto err; + if ((R = BN_CTX_get(ctx)) == NULL) + goto err; + if ((Rinv = BN_CTX_get(ctx)) == NULL) + goto err; + + /* Save modulus and determine length of R. */ + if (BN_is_zero(mod)) + goto err; + if (!BN_copy(&mont->N, mod)) + goto err; + mont->N.neg = 0; + mont->ri = ((BN_num_bits(mod) + BN_BITS2 - 1) / BN_BITS2) * BN_BITS2; + if (mont->ri * 2 < mont->ri) + goto err; + + /* + * Compute Ninv = (R * Rinv - 1)/N mod R, for R = 2^64. This provides + * a single or double word result (dependent on BN word size), that is + * later used to implement Montgomery reduction. + */ + BN_zero(R); + if (!BN_set_bit(R, 64)) + goto err; + + /* N = N mod R. */ + if (!bn_wexpand(N, 2)) + goto err; + if (!BN_set_word(N, mod->d[0])) + goto err; +#if BN_BITS2 == 32 + if (mod->top > 1) { + N->d[1] = mod->d[1]; + N->top += bn_ct_ne_zero(N->d[1]); } #endif - BN_CTX_start(ctx); - if ((tmp = BN_CTX_get(ctx)) == NULL) + /* Rinv = R^-1 mod N */ + if ((BN_mod_inverse_ct(Rinv, R, N, ctx)) == NULL) goto err; - bn_check_top(tmp); - if (a == b) { - if (!BN_sqr(tmp, a, ctx)) - goto err; - } else { - if (!BN_mul(tmp, a,b, ctx)) + /* Ninv = (R * Rinv - 1) / N */ + if (!BN_lshift(Ninv, Rinv, 64)) + goto err; + if (BN_is_zero(Ninv)) { + /* R * Rinv == 0, set to R so that R * Rinv - 1 is mod R. */ + if (!BN_set_bit(Ninv, 64)) goto err; } - /* reduce from aRR to aR */ -#ifdef MONT_WORD - if (!BN_from_montgomery_word(r, tmp, mont)) + if (!BN_sub_word(Ninv, 1)) goto err; -#else - if (!BN_from_montgomery(r, tmp, mont, ctx)) + if (!BN_div_ct(Ninv, NULL, Ninv, N, ctx)) goto err; + + /* Store least significant word(s) of Ninv. */ + mont->n0[0] = mont->n0[1] = 0; + if (Ninv->top > 0) + mont->n0[0] = Ninv->d[0]; +#if BN_BITS2 == 32 + /* Some BN_BITS2 == 32 platforms (namely parisc) use two words of Ninv. */ + if (Ninv->top > 1) + mont->n0[1] = Ninv->d[1]; #endif - bn_check_top(r); + + /* Compute RR = R * R mod N, for use when converting to Montgomery form. */ + BN_zero(&mont->RR); + if (!BN_set_bit(&mont->RR, mont->ri * 2)) + goto err; + if (!BN_mod_ct(&mont->RR, &mont->RR, &mont->N, ctx)) + goto err; + ret = 1; -err: + err: BN_CTX_end(ctx); - return (ret); + + return ret; } -int -BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx) +BN_MONT_CTX * +BN_MONT_CTX_set_locked(BN_MONT_CTX **pmctx, int lock, const BIGNUM *mod, + BN_CTX *ctx) { - return BN_mod_mul_montgomery(r, a, &mont->RR, mont, ctx); + BN_MONT_CTX *mctx = NULL; + + CRYPTO_r_lock(lock); + mctx = *pmctx; + CRYPTO_r_unlock(lock); + + if (mctx != NULL) + goto done; + + if ((mctx = BN_MONT_CTX_new()) == NULL) + goto err; + if (!BN_MONT_CTX_set(mctx, mod, ctx)) + goto err; + + CRYPTO_w_lock(lock); + if (*pmctx != NULL) { + /* Someone else raced us... */ + BN_MONT_CTX_free(mctx); + mctx = *pmctx; + } else { + *pmctx = mctx; + } + CRYPTO_w_unlock(lock); + + goto done; + err: + BN_MONT_CTX_free(mctx); + mctx = NULL; + done: + return mctx; } -#ifdef MONT_WORD +static int bn_montgomery_reduce(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mctx); + static int -BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont) +bn_mod_mul_montgomery_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + BN_MONT_CTX *mctx, BN_CTX *ctx) { - BIGNUM *n; - BN_ULONG *ap, *np, *rp, n0, v, carry; - int nl, max, i; - - n = &(mont->N); - nl = n->top; - if (nl == 0) { - ret->top = 0; - return (1); - } + BIGNUM *tmp; + int ret = 0; - max = (2 * nl); /* carry is stored separately */ - if (bn_wexpand(r, max) == NULL) - return (0); + BN_CTX_start(ctx); - r->neg ^= n->neg; - np = n->d; - rp = r->d; + if ((tmp = BN_CTX_get(ctx)) == NULL) + goto err; - /* clear the top words of T */ -#if 1 - for (i=r->top; itop]), 0, (max - r->top) * sizeof(BN_ULONG)); -#endif + if (a == b) { + if (!BN_sqr(tmp, a, ctx)) + goto err; + } else { + if (!BN_mul(tmp, a, b, ctx)) + goto err; + } - r->top = max; - n0 = mont->n0[0]; + /* Reduce from aRR to aR. */ + if (!bn_montgomery_reduce(r, tmp, mctx)) + goto err; -#ifdef BN_COUNT - fprintf(stderr, "word BN_from_montgomery_word %d * %d\n", nl, nl); -#endif - for (carry = 0, i = 0; i < nl; i++, rp++) { - v = bn_mul_add_words(rp, np, nl, (rp[0] * n0) & BN_MASK2); - v = (v + carry + rp[nl]) & BN_MASK2; - carry |= (v != rp[nl]); - carry &= (v <= rp[nl]); - rp[nl] = v; - } + ret = 1; + err: + BN_CTX_end(ctx); - if (bn_wexpand(ret, nl) == NULL) - return (0); - ret->top = nl; - ret->neg = r->neg; - - rp = ret->d; - ap = &(r->d[nl]); - -#define BRANCH_FREE 1 -#if BRANCH_FREE - { - BN_ULONG *nrp; - size_t m; - - v = bn_sub_words(rp, ap, np, nl) - carry; - /* if subtraction result is real, then - * trick unconditional memcpy below to perform in-place - * "refresh" instead of actual copy. */ - m = (0 - (size_t)v); - nrp = (BN_ULONG *)(((uintptr_t)rp & ~m)|((uintptr_t)ap & m)); - - for (i = 0, nl -= 4; i < nl; i += 4) { - BN_ULONG t1, t2, t3, t4; - - t1 = nrp[i + 0]; - t2 = nrp[i + 1]; - t3 = nrp[i + 2]; - ap[i + 0] = 0; - t4 = nrp[i + 3]; - ap[i + 1] = 0; - rp[i + 0] = t1; - ap[i + 2] = 0; - rp[i + 1] = t2; - ap[i + 3] = 0; - rp[i + 2] = t3; - rp[i + 3] = t4; + return ret; +} + +/* + * bn_montgomery_multiply_words() computes r = aR * bR * R^-1 = abR for the + * given word arrays. The caller must ensure that rp, ap, bp and np are all + * n_len words in length, while tp must be n_len * 2 + 2 words in length. + */ +void +bn_montgomery_multiply_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, BN_ULONG *tp, BN_ULONG n0, int n_len) +{ + BN_ULONG carry1, carry2, mask, w, x; + int i, j; + + for (i = 0; i <= n_len; i++) + tp[i] = 0; + + for (i = 0; i < n_len; i++) { + /* Compute new t[0] * n0, as we need it inside the loop. */ + w = (ap[0] * bp[i] + tp[0]) * n0; + + carry1 = carry2 = 0; + for (j = 0; j < n_len; j++) { + bn_mulw_addw_addw(ap[j], bp[i], tp[j], carry1, &carry1, &x); + bn_mulw_addw_addw(np[j], w, x, carry2, &carry2, &tp[j]); } - for (nl += 4; i < nl; i++) - rp[i] = nrp[i], ap[i] = 0; + bn_addw_addw(carry1, carry2, tp[n_len], &tp[n_len + 1], &tp[n_len]); + + tp++; } -#else - if (bn_sub_words (rp, ap, np, nl) - carry) - memcpy(rp, ap, nl*sizeof(BN_ULONG)); -#endif - bn_correct_top(r); - bn_correct_top(ret); - bn_check_top(ret); - return (1); + /* + * The output is now in the range of [0, 2N). Attempt to reduce once by + * subtracting the modulus. If the reduction was necessary then the + * result is already in r, otherwise copy the value prior to reduction + * from tp. + */ + mask = bn_ct_ne_zero(tp[n_len]) - bn_sub_words(rp, tp, np, n_len); + + for (i = 0; i < n_len; i++) { + *rp = (*rp & ~mask) | (*tp & mask); + rp++; + tp++; + } } -#endif /* MONT_WORD */ +/* + * bn_montgomery_multiply() computes r = aR * bR * R^-1 = abR for the given + * BIGNUMs. The caller must ensure that the modulus is two or more words in + * length and that a and b have the same number of words as the modulus. + */ int -BN_from_montgomery(BIGNUM *ret, const BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx) +bn_montgomery_multiply(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + BN_MONT_CTX *mctx, BN_CTX *ctx) { - int retn = 0; -#ifdef MONT_WORD BIGNUM *t; + int ret = 0; BN_CTX_start(ctx); - if ((t = BN_CTX_get(ctx)) && BN_copy(t, a)) - retn = BN_from_montgomery_word(ret, t, mont); - BN_CTX_end(ctx); -#else /* !MONT_WORD */ - BIGNUM *t1, *t2; - BN_CTX_start(ctx); - if ((t1 = BN_CTX_get(ctx)) == NULL) + if (mctx->N.top <= 1 || a->top != mctx->N.top || b->top != mctx->N.top) goto err; - if ((t2 = BN_CTX_get(ctx)) == NULL) + if (!bn_wexpand(r, mctx->N.top)) goto err; - if (!BN_copy(t1, a)) + if ((t = BN_CTX_get(ctx)) == NULL) goto err; - BN_mask_bits(t1, mont->ri); - - if (!BN_mul(t2, t1, &mont->Ni, ctx)) + if (!bn_wexpand(t, mctx->N.top * 2 + 2)) goto err; - BN_mask_bits(t2, mont->ri); - if (!BN_mul(t1, t2, &mont->N, ctx)) - goto err; - if (!BN_add(t2, a, t1)) - goto err; - if (!BN_rshift(ret, t2, mont->ri)) - goto err; + bn_montgomery_multiply_words(r->d, a->d, b->d, mctx->N.d, t->d, + mctx->n0[0], mctx->N.top); - if (BN_ucmp(ret, &(mont->N)) >= 0) { - if (!BN_usub(ret, ret, &(mont->N))) - goto err; - } - retn = 1; - bn_check_top(ret); + r->top = mctx->N.top; + bn_correct_top(r); + + BN_set_negative(r, a->neg ^ b->neg); -err: + ret = 1; + err: BN_CTX_end(ctx); -#endif /* MONT_WORD */ - return (retn); + + return ret; } -BN_MONT_CTX * -BN_MONT_CTX_new(void) +#ifndef OPENSSL_BN_ASM_MONT +int +bn_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + BN_MONT_CTX *mctx, BN_CTX *ctx) { - BN_MONT_CTX *ret; + if (mctx->N.top <= 1 || a->top != mctx->N.top || b->top != mctx->N.top) + return bn_mod_mul_montgomery_simple(r, a, b, mctx, ctx); - if ((ret = malloc(sizeof(BN_MONT_CTX))) == NULL) - return (NULL); - - BN_MONT_CTX_init(ret); - ret->flags = BN_FLG_MALLOCED; - return (ret); + return bn_montgomery_multiply(r, a, b, mctx, ctx); } +#else -void -BN_MONT_CTX_init(BN_MONT_CTX *ctx) +int +bn_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + BN_MONT_CTX *mctx, BN_CTX *ctx) { - ctx->ri = 0; - BN_init(&(ctx->RR)); - BN_init(&(ctx->N)); - BN_init(&(ctx->Ni)); - ctx->n0[0] = ctx->n0[1] = 0; - ctx->flags = 0; -} + if (mctx->N.top <= 1 || a->top != mctx->N.top || b->top != mctx->N.top) + return bn_mod_mul_montgomery_simple(r, a, b, mctx, ctx); + + /* + * Legacy bn_mul_mont() performs stack based allocation, without + * size limitation. Allowing a large size results in the stack + * being blown. + */ + if (mctx->N.top > (8 * 1024 / sizeof(BN_ULONG))) + return bn_montgomery_multiply(r, a, b, mctx, ctx); + + if (!bn_wexpand(r, mctx->N.top)) + return 0; -void -BN_MONT_CTX_free(BN_MONT_CTX *mont) -{ - if (mont == NULL) - return; + /* + * Legacy bn_mul_mont() can indicate that we should "fallback" to + * another implementation. + */ + if (!bn_mul_mont(r->d, a->d, b->d, mctx->N.d, mctx->n0, mctx->N.top)) + return bn_montgomery_multiply(r, a, b, mctx, ctx); - BN_clear_free(&(mont->RR)); - BN_clear_free(&(mont->N)); - BN_clear_free(&(mont->Ni)); - if (mont->flags & BN_FLG_MALLOCED) - free(mont); + r->top = mctx->N.top; + bn_correct_top(r); + + BN_set_negative(r, a->neg ^ b->neg); + + return (1); } +#endif int -BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) +BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + BN_MONT_CTX *mctx, BN_CTX *ctx) { - int ret = 0; - BIGNUM *Ri, *R; - - if (BN_is_zero(mod)) - return 0; + /* Compute r = aR * bR * R^-1 mod N = abR mod N */ + return bn_mod_mul_montgomery(r, a, b, mctx, ctx); +} - BN_CTX_start(ctx); - if ((Ri = BN_CTX_get(ctx)) == NULL) - goto err; - R = &(mont->RR); /* grab RR as a temp */ - if (!BN_copy(&(mont->N), mod)) - goto err; /* Set N */ - mont->N.neg = 0; +int +BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mctx, BN_CTX *ctx) +{ + /* Compute r = a * R * R * R^-1 mod N = aR mod N */ + return bn_mod_mul_montgomery(r, a, &mctx->RR, mctx, ctx); +} -#ifdef MONT_WORD - { - BIGNUM tmod; - BN_ULONG buf[2]; +/* + * bn_montgomery_reduce() performs Montgomery reduction, reducing the input + * from its Montgomery form aR to a, returning the result in r. Note that the + * input is mutated in the process of performing the reduction, destroying its + * original value. + */ +static int +bn_montgomery_reduce(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mctx) +{ + BIGNUM *n; + BN_ULONG *ap, *rp, n0, v, carry, mask; + int i, max, n_len; - BN_init(&tmod); - tmod.d = buf; - tmod.dmax = 2; - tmod.neg = 0; + n = &mctx->N; + n_len = mctx->N.top; - mont->ri = (BN_num_bits(mod) + - (BN_BITS2 - 1)) / BN_BITS2 * BN_BITS2; + if (n_len == 0) { + BN_zero(r); + return 1; + } -#if defined(OPENSSL_BN_ASM_MONT) && (BN_BITS2<=32) - /* Only certain BN_BITS2<=32 platforms actually make use of - * n0[1], and we could use the #else case (with a shorter R - * value) for the others. However, currently only the assembler - * files do know which is which. */ + if (!bn_wexpand(r, n_len)) + return 0; - BN_zero(R); - if (!(BN_set_bit(R, 2 * BN_BITS2))) - goto err; + /* + * Expand a to twice the length of the modulus, zero if necessary. + * XXX - make this a requirement of the caller. + */ + if ((max = 2 * n_len) < n_len) + return 0; + if (!bn_wexpand(a, max)) + return 0; + for (i = a->top; i < max; i++) + a->d[i] = 0; - tmod.top = 0; - if ((buf[0] = mod->d[0])) - tmod.top = 1; - if ((buf[1] = mod->top > 1 ? mod->d[1] : 0)) - tmod.top = 2; + carry = 0; + n0 = mctx->n0[0]; - if ((BN_mod_inverse_ct(Ri, R, &tmod, ctx)) == NULL) - goto err; - if (!BN_lshift(Ri, Ri, 2 * BN_BITS2)) - goto err; /* R*Ri */ - if (!BN_is_zero(Ri)) { - if (!BN_sub_word(Ri, 1)) - goto err; - } - else /* if N mod word size == 1 */ - { - if (bn_expand(Ri, (int)sizeof(BN_ULONG) * 2) == NULL) - goto err; - /* Ri-- (mod double word size) */ - Ri->neg = 0; - Ri->d[0] = BN_MASK2; - Ri->d[1] = BN_MASK2; - Ri->top = 2; - } - if (!BN_div_ct(Ri, NULL, Ri, &tmod, ctx)) - goto err; - /* Ni = (R*Ri-1)/N, - * keep only couple of least significant words: */ - mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0; - mont->n0[1] = (Ri->top > 1) ? Ri->d[1] : 0; -#else - BN_zero(R); - if (!(BN_set_bit(R, BN_BITS2))) - goto err; /* R */ - - buf[0] = mod->d[0]; /* tmod = N mod word size */ - buf[1] = 0; - tmod.top = buf[0] != 0 ? 1 : 0; - /* Ri = R^-1 mod N*/ - if ((BN_mod_inverse_ct(Ri, R, &tmod, ctx)) == NULL) - goto err; - if (!BN_lshift(Ri, Ri, BN_BITS2)) - goto err; /* R*Ri */ - if (!BN_is_zero(Ri)) { - if (!BN_sub_word(Ri, 1)) - goto err; - } - else /* if N mod word size == 1 */ - { - if (!BN_set_word(Ri, BN_MASK2)) - goto err; /* Ri-- (mod word size) */ - } - if (!BN_div_ct(Ri, NULL, Ri, &tmod, ctx)) - goto err; - /* Ni = (R*Ri-1)/N, - * keep only least significant word: */ - mont->n0[0] = (Ri->top > 0) ? Ri->d[0] : 0; - mont->n0[1] = 0; -#endif + /* Add multiples of the modulus, so that it becomes divisable by R. */ + for (i = 0; i < n_len; i++) { + v = bn_mul_add_words(&a->d[i], n->d, n_len, a->d[i] * n0); + bn_addw_addw(v, a->d[i + n_len], carry, &carry, + &a->d[i + n_len]); } -#else /* !MONT_WORD */ - { /* bignum version */ - mont->ri = BN_num_bits(&mont->N); - BN_zero(R); - if (!BN_set_bit(R, mont->ri)) - goto err; /* R = 2^ri */ - /* Ri = R^-1 mod N*/ - if ((BN_mod_inverse_ct(Ri, R, &mont->N, ctx)) == NULL) - goto err; - if (!BN_lshift(Ri, Ri, mont->ri)) - goto err; /* R*Ri */ - if (!BN_sub_word(Ri, 1)) - goto err; - /* Ni = (R*Ri-1) / N */ - if (!BN_div_ct(&(mont->Ni), NULL, Ri, &mont->N, ctx)) - goto err; - } -#endif - /* setup RR for conversions */ - BN_zero(&(mont->RR)); - if (!BN_set_bit(&(mont->RR), mont->ri*2)) - goto err; - if (!BN_mod_ct(&(mont->RR), &(mont->RR), &(mont->N), ctx)) - goto err; + /* Divide by R (this is the equivalent of right shifting by n_len). */ + ap = &a->d[n_len]; - ret = 1; + /* + * The output is now in the range of [0, 2N). Attempt to reduce once by + * subtracting the modulus. If the reduction was necessary then the + * result is already in r, otherwise copy the value prior to reduction + * from the top half of a. + */ + mask = carry - bn_sub_words(r->d, ap, n->d, n_len); -err: - BN_CTX_end(ctx); - return ret; -} + rp = r->d; + for (i = 0; i < n_len; i++) { + *rp = (*rp & ~mask) | (*ap & mask); + rp++; + ap++; + } + r->top = n_len; -BN_MONT_CTX * -BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from) -{ - if (to == from) - return (to); + bn_correct_top(r); - if (!BN_copy(&(to->RR), &(from->RR))) - return NULL; - if (!BN_copy(&(to->N), &(from->N))) - return NULL; - if (!BN_copy(&(to->Ni), &(from->Ni))) - return NULL; - to->ri = from->ri; - to->n0[0] = from->n0[0]; - to->n0[1] = from->n0[1]; - return (to); + BN_set_negative(r, a->neg ^ n->neg); + + return 1; } -BN_MONT_CTX * -BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, const BIGNUM *mod, - BN_CTX *ctx) +int +BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mctx, BN_CTX *ctx) { - int got_write_lock = 0; - BN_MONT_CTX *ret; + BIGNUM *tmp; + int ret = 0; - CRYPTO_r_lock(lock); - if (!*pmont) { - CRYPTO_r_unlock(lock); - CRYPTO_w_lock(lock); - got_write_lock = 1; - - if (!*pmont) { - ret = BN_MONT_CTX_new(); - if (ret && !BN_MONT_CTX_set(ret, mod, ctx)) - BN_MONT_CTX_free(ret); - else - *pmont = ret; - } - } + BN_CTX_start(ctx); - ret = *pmont; + if ((tmp = BN_CTX_get(ctx)) == NULL) + goto err; + if (BN_copy(tmp, a) == NULL) + goto err; + if (!bn_montgomery_reduce(r, tmp, mctx)) + goto err; - if (got_write_lock) - CRYPTO_w_unlock(lock); - else - CRYPTO_r_unlock(lock); + ret = 1; + err: + BN_CTX_end(ctx); return ret; } diff --git a/crypto/bn/bn_mpi.c b/crypto/bn/bn_mpi.c index 4801192b..e3b9ba0d 100644 --- a/crypto/bn/bn_mpi.c +++ b/crypto/bn/bn_mpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mpi.c,v 1.8 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bn_mpi.c,v 1.12 2023/02/13 04:25:37 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -60,7 +60,7 @@ #include -#include "bn_lcl.h" +#include "bn_local.h" int BN_bn2mpi(const BIGNUM *a, unsigned char *d) @@ -92,8 +92,9 @@ BN_bn2mpi(const BIGNUM *a, unsigned char *d) } BIGNUM * -BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a) +BN_mpi2bn(const unsigned char *d, int n, BIGNUM *ain) { + BIGNUM *a = ain; long len; int neg = 0; @@ -121,12 +122,14 @@ BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a) d += 4; if ((*d) & 0x80) neg = 1; - if (BN_bin2bn(d, (int)len, a) == NULL) + if (BN_bin2bn(d, (int)len, a) == NULL) { + if (ain == NULL) + BN_free(a); return (NULL); - a->neg = neg; + } + BN_set_negative(a, neg); if (neg) { BN_clear_bit(a, BN_num_bits(a) - 1); } - bn_check_top(a); return (a); } diff --git a/crypto/bn/bn_mul.c b/crypto/bn/bn_mul.c index 7794d597..5e270b98 100644 --- a/crypto/bn/bn_mul.c +++ b/crypto/bn/bn_mul.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mul.c,v 1.20 2015/02/09 15:49:22 jsing Exp $ */ +/* $OpenBSD: bn_mul.c,v 1.34 2023/02/22 05:57:19 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,364 +56,261 @@ * [including the GNU Public Licence.] */ -#ifndef BN_DEBUG -# undef NDEBUG /* avoid conflicting definitions */ -# define NDEBUG -#endif - #include #include #include #include -#include "bn_lcl.h" - -#if defined(OPENSSL_NO_ASM) || !defined(OPENSSL_BN_ASM_PART_WORDS) -/* Here follows specialised variants of bn_add_words() and - bn_sub_words(). They have the property performing operations on - arrays of different sizes. The sizes of those arrays is expressed through - cl, which is the common length ( basicall, min(len(a),len(b)) ), and dl, - which is the delta between the two lengths, calculated as len(a)-len(b). - All lengths are the number of BN_ULONGs... For the operations that require - a result array as parameter, it must have the length cl+abs(dl). - These functions should probably end up in bn_asm.c as soon as there are - assembler counterparts for the systems that use assembler files. */ +#include "bn_arch.h" +#include "bn_internal.h" +#include "bn_local.h" -BN_ULONG -bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int cl, - int dl) +/* + * bn_mul_comba4() computes r[] = a[] * b[] using Comba multiplication + * (https://everything2.com/title/Comba+multiplication), where a and b are both + * four word arrays, producing an eight word array result. + */ +#ifndef HAVE_BN_MUL_COMBA4 +void +bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) { - BN_ULONG c, t; + BN_ULONG c0, c1, c2; - assert(cl >= 0); - c = bn_sub_words(r, a, b, cl); + bn_mulw_addtw(a[0], b[0], 0, 0, 0, &c2, &c1, &r[0]); - if (dl == 0) - return c; + bn_mulw_addtw(a[0], b[1], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[0], c2, c1, c0, &c2, &c1, &r[1]); - r += cl; - a += cl; - b += cl; + bn_mulw_addtw(a[2], b[0], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[1], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[0], b[2], c2, c1, c0, &c2, &c1, &r[2]); - if (dl < 0) { -#ifdef BN_COUNT - fprintf(stderr, - " bn_sub_part_words %d + %d (dl < 0, c = %d)\n", - cl, dl, c); -#endif - for (;;) { - t = b[0]; - r[0] = (0 - t - c) & BN_MASK2; - if (t != 0) - c = 1; - if (++dl >= 0) - break; - - t = b[1]; - r[1] = (0 - t - c) & BN_MASK2; - if (t != 0) - c = 1; - if (++dl >= 0) - break; - - t = b[2]; - r[2] = (0 - t - c) & BN_MASK2; - if (t != 0) - c = 1; - if (++dl >= 0) - break; - - t = b[3]; - r[3] = (0 - t - c) & BN_MASK2; - if (t != 0) - c = 1; - if (++dl >= 0) - break; - - b += 4; - r += 4; - } - } else { - int save_dl = dl; -#ifdef BN_COUNT - fprintf(stderr, - " bn_sub_part_words %d + %d (dl > 0, c = %d)\n", - cl, dl, c); + bn_mulw_addtw(a[0], b[3], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[2], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[2], b[1], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[3], b[0], c2, c1, c0, &c2, &c1, &r[3]); + + bn_mulw_addtw(a[3], b[1], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[2], b[2], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[3], c2, c1, c0, &c2, &c1, &r[4]); + + bn_mulw_addtw(a[2], b[3], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[3], b[2], c2, c1, c0, &c2, &c1, &r[5]); + + bn_mulw_addtw(a[3], b[3], 0, c2, c1, &c2, &r[7], &r[6]); +} #endif - while (c) { - t = a[0]; - r[0] = (t - c) & BN_MASK2; - if (t != 0) - c = 0; - if (--dl <= 0) - break; - - t = a[1]; - r[1] = (t - c) & BN_MASK2; - if (t != 0) - c = 0; - if (--dl <= 0) - break; - - t = a[2]; - r[2] = (t - c) & BN_MASK2; - if (t != 0) - c = 0; - if (--dl <= 0) - break; - - t = a[3]; - r[3] = (t - c) & BN_MASK2; - if (t != 0) - c = 0; - if (--dl <= 0) - break; - - save_dl = dl; - a += 4; - r += 4; - } - if (dl > 0) { -#ifdef BN_COUNT - fprintf(stderr, - " bn_sub_part_words %d + %d (dl > 0, c == 0)\n", - cl, dl); + +/* + * bn_mul_comba8() computes r[] = a[] * b[] using Comba multiplication + * (https://everything2.com/title/Comba+multiplication), where a and b are both + * eight word arrays, producing a 16 word array result. + */ +#ifndef HAVE_BN_MUL_COMBA8 +void +bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) +{ + BN_ULONG c0, c1, c2; + + bn_mulw_addtw(a[0], b[0], 0, 0, 0, &c2, &c1, &r[0]); + + bn_mulw_addtw(a[0], b[1], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[0], c2, c1, c0, &c2, &c1, &r[1]); + + bn_mulw_addtw(a[2], b[0], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[1], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[0], b[2], c2, c1, c0, &c2, &c1, &r[2]); + + bn_mulw_addtw(a[0], b[3], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[2], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[2], b[1], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[3], b[0], c2, c1, c0, &c2, &c1, &r[3]); + + bn_mulw_addtw(a[4], b[0], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[3], b[1], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[2], b[2], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[3], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[0], b[4], c2, c1, c0, &c2, &c1, &r[4]); + + bn_mulw_addtw(a[0], b[5], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[4], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[2], b[3], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[3], b[2], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[4], b[1], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[5], b[0], c2, c1, c0, &c2, &c1, &r[5]); + + bn_mulw_addtw(a[6], b[0], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[5], b[1], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[4], b[2], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[3], b[3], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[2], b[4], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[5], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[0], b[6], c2, c1, c0, &c2, &c1, &r[6]); + + bn_mulw_addtw(a[0], b[7], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[6], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[2], b[5], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[3], b[4], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[4], b[3], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[5], b[2], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[6], b[1], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[7], b[0], c2, c1, c0, &c2, &c1, &r[7]); + + bn_mulw_addtw(a[7], b[1], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[6], b[2], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[5], b[3], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[4], b[4], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[3], b[5], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[2], b[6], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[1], b[7], c2, c1, c0, &c2, &c1, &r[8]); + + bn_mulw_addtw(a[2], b[7], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[3], b[6], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[4], b[5], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[5], b[4], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[6], b[3], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[7], b[2], c2, c1, c0, &c2, &c1, &r[9]); + + bn_mulw_addtw(a[7], b[3], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[6], b[4], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[5], b[5], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[4], b[6], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[3], b[7], c2, c1, c0, &c2, &c1, &r[10]); + + bn_mulw_addtw(a[4], b[7], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[5], b[6], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[6], b[5], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[7], b[4], c2, c1, c0, &c2, &c1, &r[11]); + + bn_mulw_addtw(a[7], b[5], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[6], b[6], c2, c1, c0, &c2, &c1, &c0); + bn_mulw_addtw(a[5], b[7], c2, c1, c0, &c2, &c1, &r[12]); + + bn_mulw_addtw(a[6], b[7], 0, c2, c1, &c2, &c1, &c0); + bn_mulw_addtw(a[7], b[6], c2, c1, c0, &c2, &c1, &r[13]); + + bn_mulw_addtw(a[7], b[7], 0, c2, c1, &c2, &r[15], &r[14]); +} #endif - if (save_dl > dl) { - switch (save_dl - dl) { - case 1: - r[1] = a[1]; - if (--dl <= 0) - break; - case 2: - r[2] = a[2]; - if (--dl <= 0) - break; - case 3: - r[3] = a[3]; - if (--dl <= 0) - break; - } - a += 4; - r += 4; - } - } - if (dl > 0) { -#ifdef BN_COUNT - fprintf(stderr, - " bn_sub_part_words %d + %d (dl > 0, copy)\n", - cl, dl); + +/* + * bn_mul_words() computes (carry:r[i]) = a[i] * w + carry, where a is an array + * of words and w is a single word. This should really be called bn_mulw_words() + * since only one input is an array. This is used as a step in the multiplication + * of word arrays. + */ +#ifndef HAVE_BN_MUL_WORDS +BN_ULONG +bn_mul_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) +{ + BN_ULONG carry = 0; + + assert(num >= 0); + if (num <= 0) + return 0; + +#ifndef OPENSSL_SMALL_FOOTPRINT + while (num & ~3) { + bn_mulw_addw(a[0], w, carry, &carry, &r[0]); + bn_mulw_addw(a[1], w, carry, &carry, &r[1]); + bn_mulw_addw(a[2], w, carry, &carry, &r[2]); + bn_mulw_addw(a[3], w, carry, &carry, &r[3]); + a += 4; + r += 4; + num -= 4; + } #endif - for (;;) { - r[0] = a[0]; - if (--dl <= 0) - break; - r[1] = a[1]; - if (--dl <= 0) - break; - r[2] = a[2]; - if (--dl <= 0) - break; - r[3] = a[3]; - if (--dl <= 0) - break; - - a += 4; - r += 4; - } - } + while (num) { + bn_mulw_addw(a[0], w, carry, &carry, &r[0]); + a++; + r++; + num--; } - return c; + return carry; } #endif +/* + * bn_mul_add_words() computes (carry:r[i]) = a[i] * w + r[i] + carry, where + * a is an array of words and w is a single word. This should really be called + * bn_mulw_add_words() since only one input is an array. This is used as a step + * in the multiplication of word arrays. + */ +#ifndef HAVE_BN_MUL_ADD_WORDS BN_ULONG -bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int cl, - int dl) +bn_mul_add_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) { - BN_ULONG c, l, t; + BN_ULONG carry = 0; + + assert(num >= 0); + if (num <= 0) + return 0; + +#ifndef OPENSSL_SMALL_FOOTPRINT + while (num & ~3) { + bn_mulw_addw_addw(a[0], w, r[0], carry, &carry, &r[0]); + bn_mulw_addw_addw(a[1], w, r[1], carry, &carry, &r[1]); + bn_mulw_addw_addw(a[2], w, r[2], carry, &carry, &r[2]); + bn_mulw_addw_addw(a[3], w, r[3], carry, &carry, &r[3]); + a += 4; + r += 4; + num -= 4; + } +#endif + while (num) { + bn_mulw_addw_addw(a[0], w, r[0], carry, &carry, &r[0]); + a++; + r++; + num--; + } - assert(cl >= 0); - c = bn_add_words(r, a, b, cl); + return carry; +} +#endif - if (dl == 0) - return c; +void +bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb) +{ + BN_ULONG *rr; - r += cl; - a += cl; - b += cl; - if (dl < 0) { - int save_dl = dl; -#ifdef BN_COUNT - fprintf(stderr, - " bn_add_part_words %d + %d (dl < 0, c = %d)\n", - cl, dl, c); -#endif - while (c) { - l = (c + b[0]) & BN_MASK2; - c = (l < c); - r[0] = l; - if (++dl >= 0) - break; - - l = (c + b[1]) & BN_MASK2; - c = (l < c); - r[1] = l; - if (++dl >= 0) - break; - - l = (c + b[2]) & BN_MASK2; - c = (l < c); - r[2] = l; - if (++dl >= 0) - break; - - l = (c + b[3]) & BN_MASK2; - c = (l < c); - r[3] = l; - if (++dl >= 0) - break; - - save_dl = dl; - b += 4; - r += 4; - } - if (dl < 0) { -#ifdef BN_COUNT - fprintf(stderr, - " bn_add_part_words %d + %d (dl < 0, c == 0)\n", - cl, dl); -#endif - if (save_dl < dl) { - switch (dl - save_dl) { - case 1: - r[1] = b[1]; - if (++dl >= 0) - break; - case 2: - r[2] = b[2]; - if (++dl >= 0) - break; - case 3: - r[3] = b[3]; - if (++dl >= 0) - break; - } - b += 4; - r += 4; - } - } - if (dl < 0) { -#ifdef BN_COUNT - fprintf(stderr, - " bn_add_part_words %d + %d (dl < 0, copy)\n", - cl, dl); -#endif - for (;;) { - r[0] = b[0]; - if (++dl >= 0) - break; - r[1] = b[1]; - if (++dl >= 0) - break; - r[2] = b[2]; - if (++dl >= 0) - break; - r[3] = b[3]; - if (++dl >= 0) - break; - - b += 4; - r += 4; - } - } - } else { - int save_dl = dl; -#ifdef BN_COUNT - fprintf(stderr, - " bn_add_part_words %d + %d (dl > 0)\n", cl, dl); -#endif - while (c) { - t = (a[0] + c) & BN_MASK2; - c = (t < c); - r[0] = t; - if (--dl <= 0) - break; - - t = (a[1] + c) & BN_MASK2; - c = (t < c); - r[1] = t; - if (--dl <= 0) - break; - - t = (a[2] + c) & BN_MASK2; - c = (t < c); - r[2] = t; - if (--dl <= 0) - break; - - t = (a[3] + c) & BN_MASK2; - c = (t < c); - r[3] = t; - if (--dl <= 0) - break; - - save_dl = dl; - a += 4; - r += 4; - } -#ifdef BN_COUNT - fprintf(stderr, - " bn_add_part_words %d + %d (dl > 0, c == 0)\n", cl, dl); -#endif - if (dl > 0) { - if (save_dl > dl) { - switch (save_dl - dl) { - case 1: - r[1] = a[1]; - if (--dl <= 0) - break; - case 2: - r[2] = a[2]; - if (--dl <= 0) - break; - case 3: - r[3] = a[3]; - if (--dl <= 0) - break; - } - a += 4; - r += 4; - } - } - if (dl > 0) { -#ifdef BN_COUNT - fprintf(stderr, - " bn_add_part_words %d + %d (dl > 0, copy)\n", - cl, dl); -#endif - for (;;) { - r[0] = a[0]; - if (--dl <= 0) - break; - r[1] = a[1]; - if (--dl <= 0) - break; - r[2] = a[2]; - if (--dl <= 0) - break; - r[3] = a[3]; - if (--dl <= 0) - break; - - a += 4; - r += 4; - } - } + if (na < nb) { + int itmp; + BN_ULONG *ltmp; + + itmp = na; + na = nb; + nb = itmp; + ltmp = a; + a = b; + b = ltmp; + + } + rr = &(r[na]); + if (nb <= 0) { + (void)bn_mul_words(r, a, na, 0); + return; + } else + rr[0] = bn_mul_words(r, a, na, b[0]); + + for (;;) { + if (--nb <= 0) + return; + rr[1] = bn_mul_add_words(&(r[1]), a, na, b[1]); + if (--nb <= 0) + return; + rr[2] = bn_mul_add_words(&(r[2]), a, na, b[2]); + if (--nb <= 0) + return; + rr[3] = bn_mul_add_words(&(r[3]), a, na, b[3]); + if (--nb <= 0) + return; + rr[4] = bn_mul_add_words(&(r[4]), a, na, b[4]); + rr += 4; + r += 4; + b += 4; } - return c; } #ifdef BN_RECURSION @@ -440,9 +337,6 @@ bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, int dna, unsigned int neg, zero; BN_ULONG ln, lo, *p; -# ifdef BN_COUNT - fprintf(stderr, " bn_mul_recursive %d%+d * %d%+d\n",n2,dna,n2,dnb); -# endif # ifdef BN_MUL_COMBA # if 0 if (n2 == 4) { @@ -472,15 +366,15 @@ bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, int dna, zero = neg = 0; switch (c1 * 3 + c2) { case -4: - bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */ - bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */ + bn_sub(t, n, &a[n], tna, a, n); /* - */ + bn_sub(&t[n], n, b, n, &b[n], tnb); /* - */ break; case -3: zero = 1; break; case -2: - bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */ - bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n); /* + */ + bn_sub(t, n, &a[n], tna, a, n); /* - */ + bn_sub(&t[n], n, &b[n], tnb, b, n); /* + */ neg = 1; break; case -1: @@ -489,16 +383,16 @@ bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, int dna, zero = 1; break; case 2: - bn_sub_part_words(t, a, &(a[n]), tna, n - tna); /* + */ - bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */ + bn_sub(t, n, a, n, &a[n], tna); /* + */ + bn_sub(&t[n], n, b, n, &b[n], tnb); /* - */ neg = 1; break; case 3: zero = 1; break; case 4: - bn_sub_part_words(t, a, &(a[n]), tna, n - tna); - bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n); + bn_sub(t, n, a, n, &a[n], tna); + bn_sub(&t[n], n, &b[n], tnb, b, n); break; } @@ -587,10 +481,6 @@ bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, int tna, int c1, c2, neg; BN_ULONG ln, lo, *p; -# ifdef BN_COUNT - fprintf(stderr, " bn_mul_part_recursive (%d%+d) * (%d%+d)\n", - n, tna, n, tnb); -# endif if (n < 8) { bn_mul_normal(r, a, n + tna, b, n + tnb); return; @@ -602,14 +492,14 @@ bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, int tna, neg = 0; switch (c1 * 3 + c2) { case -4: - bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */ - bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */ + bn_sub(t, n, &a[n], tna, a, n); /* - */ + bn_sub(&t[n], n, b, n, &b[n], tnb); /* - */ break; case -3: /* break; */ case -2: - bn_sub_part_words(t, &(a[n]), a, tna, tna - n); /* - */ - bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n); /* + */ + bn_sub(t, n, &a[n], tna, a, n); /* - */ + bn_sub(&t[n], n, &b[n], tnb, b, n); /* + */ neg = 1; break; case -1: @@ -617,15 +507,15 @@ bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, int tna, case 1: /* break; */ case 2: - bn_sub_part_words(t, a, &(a[n]), tna, n - tna); /* + */ - bn_sub_part_words(&(t[n]), b, &(b[n]), tnb, n - tnb); /* - */ + bn_sub(t, n, a, n, &a[n], tna); /* + */ + bn_sub(&t[n], n, b, n, &b[n], tnb); /* - */ neg = 1; break; case 3: /* break; */ case 4: - bn_sub_part_words(t, a, &(a[n]), tna, n - tna); - bn_sub_part_words(&(t[n]), &(b[n]), b, tnb, tnb - n); + bn_sub(t, n, a, n, &a[n], tna); + bn_sub(&t[n], n, &b[n], tnb, b, n); break; } /* The zero case isn't yet implemented here. The speedup @@ -736,269 +626,34 @@ bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n, int tna, } } } +#endif /* BN_RECURSION */ -/* a and b must be the same size, which is n2. - * r needs to be n2 words and t needs to be n2*2 - */ -void -bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, BN_ULONG *t) -{ - int n = n2 / 2; - -# ifdef BN_COUNT - fprintf(stderr, " bn_mul_low_recursive %d * %d\n",n2,n2); -# endif - - bn_mul_recursive(r, a, b, n, 0, 0, &(t[0])); - if (n >= BN_MUL_LOW_RECURSIVE_SIZE_NORMAL) { - bn_mul_low_recursive(&(t[0]), &(a[0]), &(b[n]), n, &(t[n2])); - bn_add_words(&(r[n]), &(r[n]), &(t[0]), n); - bn_mul_low_recursive(&(t[0]), &(a[n]), &(b[0]), n, &(t[n2])); - bn_add_words(&(r[n]), &(r[n]), &(t[0]), n); - } else { - bn_mul_low_normal(&(t[0]), &(a[0]), &(b[n]), n); - bn_mul_low_normal(&(t[n]), &(a[n]), &(b[0]), n); - bn_add_words(&(r[n]), &(r[n]), &(t[0]), n); - bn_add_words(&(r[n]), &(r[n]), &(t[n]), n); - } -} - -/* a and b must be the same size, which is n2. - * r needs to be n2 words and t needs to be n2*2 - * l is the low words of the output. - * t needs to be n2*3 - */ -void -bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2, - BN_ULONG *t) +#ifndef HAVE_BN_MUL +#ifndef BN_RECURSION +int +bn_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, int rn, BN_CTX *ctx) { - int i, n; - int c1, c2; - int neg, oneg, zero; - BN_ULONG ll, lc, *lp, *mp; - -# ifdef BN_COUNT - fprintf(stderr, " bn_mul_high %d * %d\n",n2,n2); -# endif - n = n2 / 2; - - /* Calculate (al-ah)*(bh-bl) */ - neg = zero = 0; - c1 = bn_cmp_words(&(a[0]), &(a[n]), n); - c2 = bn_cmp_words(&(b[n]), &(b[0]), n); - switch (c1 * 3 + c2) { - case -4: - bn_sub_words(&(r[0]), &(a[n]), &(a[0]), n); - bn_sub_words(&(r[n]), &(b[0]), &(b[n]), n); - break; - case -3: - zero = 1; - break; - case -2: - bn_sub_words(&(r[0]), &(a[n]), &(a[0]), n); - bn_sub_words(&(r[n]), &(b[n]), &(b[0]), n); - neg = 1; - break; - case -1: - case 0: - case 1: - zero = 1; - break; - case 2: - bn_sub_words(&(r[0]), &(a[0]), &(a[n]), n); - bn_sub_words(&(r[n]), &(b[0]), &(b[n]), n); - neg = 1; - break; - case 3: - zero = 1; - break; - case 4: - bn_sub_words(&(r[0]), &(a[0]), &(a[n]), n); - bn_sub_words(&(r[n]), &(b[n]), &(b[0]), n); - break; - } - - oneg = neg; - /* t[10] = (a[0]-a[1])*(b[1]-b[0]) */ - /* r[10] = (a[1]*b[1]) */ -# ifdef BN_MUL_COMBA - if (n == 8) { - bn_mul_comba8(&(t[0]), &(r[0]), &(r[n])); - bn_mul_comba8(r, &(a[n]), &(b[n])); - } else -# endif - { - bn_mul_recursive(&(t[0]), &(r[0]), &(r[n]), n, 0, 0, &(t[n2])); - bn_mul_recursive(r, &(a[n]), &(b[n]), n, 0, 0, &(t[n2])); - } - - /* s0 == low(al*bl) - * s1 == low(ah*bh)+low((al-ah)*(bh-bl))+low(al*bl)+high(al*bl) - * We know s0 and s1 so the only unknown is high(al*bl) - * high(al*bl) == s1 - low(ah*bh+s0+(al-ah)*(bh-bl)) - * high(al*bl) == s1 - (r[0]+l[0]+t[0]) - */ - if (l != NULL) { - lp = &(t[n2 + n]); - c1 = (int)(bn_add_words(lp, &(r[0]), &(l[0]), n)); - } else { - c1 = 0; - lp = &(r[0]); - } - - if (neg) - neg = (int)(bn_sub_words(&(t[n2]), lp, &(t[0]), n)); - else { - bn_add_words(&(t[n2]), lp, &(t[0]), n); - neg = 0; - } - - if (l != NULL) { - bn_sub_words(&(t[n2 + n]), &(l[n]), &(t[n2]), n); - } else { - lp = &(t[n2 + n]); - mp = &(t[n2]); - for (i = 0; i < n; i++) - lp[i] = ((~mp[i]) + 1) & BN_MASK2; - } + bn_mul_normal(r->d, a->d, a->top, b->d, b->top); - /* s[0] = low(al*bl) - * t[3] = high(al*bl) - * t[10] = (a[0]-a[1])*(b[1]-b[0]) neg is the sign - * r[10] = (a[1]*b[1]) - */ - /* R[10] = al*bl - * R[21] = al*bl + ah*bh + (a[0]-a[1])*(b[1]-b[0]) - * R[32] = ah*bh - */ - /* R[1]=t[3]+l[0]+r[0](+-)t[0] (have carry/borrow) - * R[2]=r[0]+t[3]+r[1](+-)t[1] (have carry/borrow) - * R[3]=r[1]+(carry/borrow) - */ - if (l != NULL) { - lp = &(t[n2]); - c1 = (int)(bn_add_words(lp, &(t[n2 + n]), &(l[0]), n)); - } else { - lp = &(t[n2 + n]); - c1 = 0; - } - c1 += (int)(bn_add_words(&(t[n2]), lp, &(r[0]), n)); - if (oneg) - c1 -= (int)(bn_sub_words(&(t[n2]), &(t[n2]), &(t[0]), n)); - else - c1 += (int)(bn_add_words(&(t[n2]), &(t[n2]), &(t[0]), n)); - - c2 = (int)(bn_add_words(&(r[0]), &(r[0]), &(t[n2 + n]), n)); - c2 += (int)(bn_add_words(&(r[0]), &(r[0]), &(r[n]), n)); - if (oneg) - c2 -= (int)(bn_sub_words(&(r[0]), &(r[0]), &(t[n]), n)); - else - c2 += (int)(bn_add_words(&(r[0]), &(r[0]), &(t[n]), n)); - - if (c1 != 0) /* Add starting at r[0], could be +ve or -ve */ - { - i = 0; - if (c1 > 0) { - lc = c1; - do { - ll = (r[i] + lc) & BN_MASK2; - r[i++] = ll; - lc = (lc > ll); - } while (lc); - } else { - lc = -c1; - do { - ll = r[i]; - r[i++] = (ll - lc) & BN_MASK2; - lc = (lc > ll); - } while (lc); - } - } - if (c2 != 0) /* Add starting at r[1] */ - { - i = n; - if (c2 > 0) { - lc = c2; - do { - ll = (r[i] + lc) & BN_MASK2; - r[i++] = ll; - lc = (lc > ll); - } while (lc); - } else { - lc = -c2; - do { - ll = r[i]; - r[i++] = (ll - lc) & BN_MASK2; - lc = (lc > ll); - } while (lc); - } - } + return 1; } -#endif /* BN_RECURSION */ +#else /* BN_RECURSION */ int -BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) +bn_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, int rn, BN_CTX *ctx) { - int ret = 0; - int top, al, bl; - BIGNUM *rr; -#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) - int i; -#endif -#ifdef BN_RECURSION BIGNUM *t = NULL; - int j = 0, k; -#endif - -#ifdef BN_COUNT - fprintf(stderr, "BN_mul %d * %d\n",a->top,b->top); -#endif + int al, bl, i, k; + int j = 0; + int ret = 0; - bn_check_top(a); - bn_check_top(b); - bn_check_top(r); + BN_CTX_start(ctx); al = a->top; bl = b->top; - if ((al == 0) || (bl == 0)) { - BN_zero(r); - return (1); - } - top = al + bl; - - BN_CTX_start(ctx); - if ((r == a) || (r == b)) { - if ((rr = BN_CTX_get(ctx)) == NULL) - goto err; - } else - rr = r; - rr->neg = a->neg ^ b->neg; - -#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) i = al - bl; -#endif -#ifdef BN_MUL_COMBA - if (i == 0) { -# if 0 - if (al == 4) { - if (bn_wexpand(rr, 8) == NULL) - goto err; - rr->top = 8; - bn_mul_comba4(rr->d, a->d, b->d); - goto end; - } -# endif - if (al == 8) { - if (bn_wexpand(rr, 16) == NULL) - goto err; - rr->top = 16; - bn_mul_comba8(rr->d, a->d, b->d); - goto end; - } - } -#endif /* BN_MUL_COMBA */ -#ifdef BN_RECURSION + if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) { if (i >= -1 && i <= 1) { /* Find out the power of two lower or equal @@ -1015,36 +670,36 @@ BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) if ((t = BN_CTX_get(ctx)) == NULL) goto err; if (al > j || bl > j) { - if (bn_wexpand(t, k * 4) == NULL) + if (!bn_wexpand(t, k * 4)) goto err; - if (bn_wexpand(rr, k * 4) == NULL) + if (!bn_wexpand(r, k * 4)) goto err; - bn_mul_part_recursive(rr->d, a->d, b->d, + bn_mul_part_recursive(r->d, a->d, b->d, j, al - j, bl - j, t->d); } else /* al <= j || bl <= j */ { - if (bn_wexpand(t, k * 2) == NULL) + if (!bn_wexpand(t, k * 2)) goto err; - if (bn_wexpand(rr, k * 2) == NULL) + if (!bn_wexpand(r, k * 2)) goto err; - bn_mul_recursive(rr->d, a->d, b->d, + bn_mul_recursive(r->d, a->d, b->d, j, al - j, bl - j, t->d); } - rr->top = top; + r->top = rn; goto end; } #if 0 if (i == 1 && !BN_get_flags(b, BN_FLG_STATIC_DATA)) { BIGNUM *tmp_bn = (BIGNUM *)b; - if (bn_wexpand(tmp_bn, al) == NULL) + if (!bn_wexpand(tmp_bn, al)) goto err; tmp_bn->d[bl] = 0; bl++; i--; } else if (i == -1 && !BN_get_flags(a, BN_FLG_STATIC_DATA)) { BIGNUM *tmp_bn = (BIGNUM *)a; - if (bn_wexpand(tmp_bn, bl) == NULL) + if (!bn_wexpand(tmp_bn, bl)) goto err; tmp_bn->d[al] = 0; al++; @@ -1060,112 +715,83 @@ BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) goto err; if (al == j) /* exact multiple */ { - if (bn_wexpand(t, k * 2) == NULL) + if (!bn_wexpand(t, k * 2)) goto err; - if (bn_wexpand(rr, k * 2) == NULL) + if (!bn_wexpand(r, k * 2)) goto err; - bn_mul_recursive(rr->d, a->d, b->d, al, t->d); + bn_mul_recursive(r->d, a->d, b->d, al, t->d); } else { - if (bn_wexpand(t, k * 4) == NULL) + if (!bn_wexpand(t, k * 4)) goto err; - if (bn_wexpand(rr, k * 4) == NULL) + if (!bn_wexpand(r, k * 4)) goto err; - bn_mul_part_recursive(rr->d, a->d, b->d, + bn_mul_part_recursive(r->d, a->d, b->d, al - j, j, t->d); } - rr->top = top; + r->top = top; goto end; } #endif } -#endif /* BN_RECURSION */ - if (bn_wexpand(rr, top) == NULL) - goto err; - rr->top = top; - bn_mul_normal(rr->d, a->d, al, b->d, bl); -#if defined(BN_MUL_COMBA) || defined(BN_RECURSION) -end: -#endif - bn_correct_top(rr); - if (r != rr) - BN_copy(r, rr); + bn_mul_normal(r->d, a->d, al, b->d, bl); + + end: ret = 1; -err: - bn_check_top(r); + err: BN_CTX_end(ctx); - return (ret); + + return ret; } +#endif /* BN_RECURSION */ +#endif /* HAVE_BN_MUL */ -void -bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb) +int +BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { - BN_ULONG *rr; + BIGNUM *rr; + int rn; + int ret = 0; -#ifdef BN_COUNT - fprintf(stderr, " bn_mul_normal %d * %d\n", na, nb); -#endif + BN_CTX_start(ctx); - if (na < nb) { - int itmp; - BN_ULONG *ltmp; + if (BN_is_zero(a) || BN_is_zero(b)) { + BN_zero(r); + goto done; + } - itmp = na; - na = nb; - nb = itmp; - ltmp = a; - a = b; - b = ltmp; + rr = r; + if (rr == a || rr == b) + rr = BN_CTX_get(ctx); + if (rr == NULL) + goto err; - } - rr = &(r[na]); - if (nb <= 0) { - (void)bn_mul_words(r, a, na, 0); - return; - } else - rr[0] = bn_mul_words(r, a, na, b[0]); + rn = a->top + b->top; + if (rn < a->top) + goto err; + if (!bn_wexpand(rr, rn)) + goto err; - for (;;) { - if (--nb <= 0) - return; - rr[1] = bn_mul_add_words(&(r[1]), a, na, b[1]); - if (--nb <= 0) - return; - rr[2] = bn_mul_add_words(&(r[2]), a, na, b[2]); - if (--nb <= 0) - return; - rr[3] = bn_mul_add_words(&(r[3]), a, na, b[3]); - if (--nb <= 0) - return; - rr[4] = bn_mul_add_words(&(r[4]), a, na, b[4]); - rr += 4; - r += 4; - b += 4; + if (a->top == 4 && b->top == 4) { + bn_mul_comba4(rr->d, a->d, b->d); + } else if (a->top == 8 && b->top == 8) { + bn_mul_comba8(rr->d, a->d, b->d); + } else { + if (!bn_mul(rr, a, b, rn, ctx)) + goto err; } -} -void -bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) -{ -#ifdef BN_COUNT - fprintf(stderr, " bn_mul_low_normal %d * %d\n", n, n); -#endif - bn_mul_words(r, a, n, b[0]); + rr->top = rn; + bn_correct_top(rr); - for (;;) { - if (--n <= 0) - return; - bn_mul_add_words(&(r[1]), a, n, b[1]); - if (--n <= 0) - return; - bn_mul_add_words(&(r[2]), a, n, b[2]); - if (--n <= 0) - return; - bn_mul_add_words(&(r[3]), a, n, b[3]); - if (--n <= 0) - return; - bn_mul_add_words(&(r[4]), a, n, b[4]); - r += 4; - b += 4; - } + BN_set_negative(rr, a->neg ^ b->neg); + + if (r != rr) + BN_copy(r, rr); + done: + ret = 1; + err: + BN_CTX_end(ctx); + + return ret; } diff --git a/crypto/bn/bn_nist.c b/crypto/bn/bn_nist.c index 6b51bb10..bad59ee3 100644 --- a/crypto/bn/bn_nist.c +++ b/crypto/bn/bn_nist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_nist.c,v 1.22 2022/07/31 14:38:38 jsing Exp $ */ +/* $OpenBSD: bn_nist.c,v 1.24 2022/11/30 01:47:19 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ @@ -60,7 +60,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" #define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \ __attribute__((__unused__)) @@ -401,9 +401,6 @@ nist_cp_bn_0(BN_ULONG *dst, const BN_ULONG *src, int top, int max) { int i; -#ifdef BN_DEBUG - OPENSSL_assert(top <= max); -#endif for (i = 0; i < top; i++) dst[i] = src[i]; for (; i < max; i++) diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c index e9a73358..6e46a391 100644 --- a/crypto/bn/bn_prime.c +++ b/crypto/bn/bn_prime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_prime.c,v 1.22 2022/07/19 16:19:19 tb Exp $ */ +/* $OpenBSD: bn_prime.c,v 1.30 2023/01/28 17:13:26 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -114,14 +114,7 @@ #include -#include "bn_lcl.h" - -#define LIBRESSL_HAS_BPSW - -/* NB: these functions have been "upgraded", the deprecated versions (which are - * compatibility wrappers using these functions) are in bn_depr.c. - * - Geoff - */ +#include "bn_local.h" /* The quick sieve algorithm approach to weeding out primes is * Philip Zimmermann's, as implemented in PGP. I have had a read of @@ -129,8 +122,6 @@ */ #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); static int probable_prime_dh(BIGNUM *rnd, int bits, const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx); @@ -160,15 +151,44 @@ BN_GENCB_call(BN_GENCB *cb, int a, int b) return 0; } +#ifndef OPENSSL_NO_DEPRECATED +BIGNUM * +BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add, + const BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg) +{ + BN_GENCB cb; + BIGNUM *rnd = NULL; + int found = 0; + + BN_GENCB_set_old(&cb, callback, cb_arg); + + if (ret == NULL) { + if ((rnd = BN_new()) == NULL) + goto err; + } else + rnd = ret; + if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb)) + goto err; + + /* we have a prime :-) */ + found = 1; + +err: + if (!found && (ret == NULL) && (rnd != NULL)) + BN_free(rnd); + return (found ? rnd : NULL); +} +#endif + int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb) { - BIGNUM *t; - int found = 0; - int i, j, c1 = 0; BN_CTX *ctx; - int checks = 1; + BIGNUM *p; + int is_prime; + int loops = 0; + int found = 0; if (bits < 2 || (bits == 2 && safe)) { /* @@ -179,19 +199,14 @@ BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, return 0; } - ctx = BN_CTX_new(); - if (ctx == NULL) + if ((ctx = BN_CTX_new()) == NULL) goto err; BN_CTX_start(ctx); - if ((t = BN_CTX_get(ctx)) == NULL) + if ((p = BN_CTX_get(ctx)) == NULL) goto err; -#ifndef LIBRESSL_HAS_BPSW - checks = BN_prime_checks_for_size(bits); -#endif - -loop: - /* make a random number and set the top and bottom bits */ + loop: + /* Make a random number and set the top and bottom bits. */ if (add == NULL) { if (!probable_prime(ret, bits)) goto err; @@ -204,73 +219,83 @@ BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, goto err; } } - /* if (BN_mod_word(ret,(BN_ULONG)3) == 1) goto loop; */ - if (!BN_GENCB_call(cb, 0, c1++)) - /* aborted */ + + if (!BN_GENCB_call(cb, 0, loops++)) goto err; if (!safe) { - i = BN_is_prime_fasttest_ex(ret, checks, ctx, 0, cb); - if (i == -1) + if (!bn_is_prime_bpsw(&is_prime, ret, ctx)) goto err; - if (i == 0) + if (!is_prime) goto loop; } else { - /* for "safe prime" generation, - * check that (p-1)/2 is prime. - * Since a prime is odd, We just - * need to divide by 2 */ - if (!BN_rshift1(t, ret)) + if (!bn_is_prime_bpsw(&is_prime, ret, ctx)) goto err; + if (!is_prime) + goto loop; - for (i = 0; i < checks; i++) { - j = BN_is_prime_fasttest_ex(ret, 1, ctx, 0, cb); - if (j == -1) - goto err; - if (j == 0) - goto loop; + /* + * For safe prime generation, check that p = (ret-1)/2 is prime. + * Since this prime has >= 3 bits, it is odd, and we can simply + * divide by 2. + */ + if (!BN_rshift1(p, ret)) + goto err; - j = BN_is_prime_fasttest_ex(t, 1, ctx, 0, cb); - if (j == -1) - goto err; - if (j == 0) - goto loop; + if (!bn_is_prime_bpsw(&is_prime, p, ctx)) + goto err; + if (!is_prime) + goto loop; - if (!BN_GENCB_call(cb, 2, c1 - 1)) - goto err; - /* We have a safe prime test pass */ - } + if (!BN_GENCB_call(cb, 2, loops - 1)) + goto err; } - /* we have a prime :-) */ + found = 1; -err: - if (ctx != NULL) { - BN_CTX_end(ctx); - BN_CTX_free(ctx); - } - bn_check_top(ret); + err: + BN_CTX_end(ctx); + BN_CTX_free(ctx); + return found; } +#ifndef OPENSSL_NO_DEPRECATED +int +BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int, void *), + BN_CTX *ctx_passed, void *cb_arg) +{ + BN_GENCB cb; + + BN_GENCB_set_old(&cb, callback, cb_arg); + return BN_is_prime_ex(a, checks, ctx_passed, &cb); +} +#endif + int BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb) { return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 0, cb); } +#ifndef OPENSSL_NO_DEPRECATED +int +BN_is_prime_fasttest(const BIGNUM *a, int checks, + void (*callback)(int, int, void *), BN_CTX *ctx_passed, void *cb_arg, + int do_trial_division) +{ + BN_GENCB cb; + + BN_GENCB_set_old(&cb, callback, cb_arg); + return BN_is_prime_fasttest_ex(a, checks, ctx_passed, + do_trial_division, &cb); +} +#endif + int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, int do_trial_division, BN_GENCB *cb) { - BN_CTX *ctx = NULL; - BIGNUM *A1, *A1_odd, *check; /* taken from ctx */ - BN_MONT_CTX *mont = NULL; - const BIGNUM *A = NULL; - int i, j, k; - int ret = -1; - -#ifdef LIBRESSL_HAS_BPSW int is_prime; /* XXX - tickle BN_GENCB in bn_is_prime_bpsw(). */ @@ -278,138 +303,13 @@ BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, return -1; return is_prime; -#endif - - if (BN_cmp(a, BN_value_one()) <= 0) - return 0; - - if (checks == BN_prime_checks) - checks = BN_prime_checks_for_size(BN_num_bits(a)); - - /* first look for small factors */ - if (!BN_is_odd(a)) - /* a is even => a is prime if and only if a == 2 */ - return BN_is_word(a, 2); - if (do_trial_division) { - for (i = 1; i < NUMPRIMES; i++) { - BN_ULONG mod = BN_mod_word(a, primes[i]); - if (mod == (BN_ULONG)-1) - goto err; - if (mod == 0) - return BN_is_word(a, primes[i]); - } - if (!BN_GENCB_call(cb, 1, -1)) - goto err; - } - - if (ctx_passed != NULL) - ctx = ctx_passed; - else if ((ctx = BN_CTX_new()) == NULL) - goto err; - BN_CTX_start(ctx); - - /* A := abs(a) */ - if (a->neg) { - BIGNUM *t; - if ((t = BN_CTX_get(ctx)) == NULL) - goto err; - BN_copy(t, a); - t->neg = 0; - A = t; - } else - A = a; - if ((A1 = BN_CTX_get(ctx)) == NULL) - goto err; - if ((A1_odd = BN_CTX_get(ctx)) == NULL) - goto err; - if ((check = BN_CTX_get(ctx)) == NULL) - goto err; - - /* compute A1 := A - 1 */ - if (!BN_copy(A1, A)) - goto err; - if (!BN_sub_word(A1, 1)) - goto err; - if (BN_is_zero(A1)) { - ret = 0; - 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)) - 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)) - goto err; - - for (i = 0; i < checks; i++) { - if (!BN_pseudo_rand_range(check, A1)) - goto err; - if (!BN_add_word(check, 1)) - goto err; - /* now 1 <= check < A */ - - j = witness(check, A, A1, A1_odd, k, ctx, mont); - if (j == -1) - goto err; - if (j) { - ret = 0; - goto err; - } - if (!BN_GENCB_call(cb, 1, i)) - goto err; - } - ret = 1; - -err: - if (ctx != NULL) { - BN_CTX_end(ctx); - if (ctx_passed == NULL) - BN_CTX_free(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_ct(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) { int i; - prime_t mods[NUMPRIMES]; + BN_ULONG mods[NUMPRIMES]; BN_ULONG delta, maxdelta; again: @@ -417,10 +317,10 @@ probable_prime(BIGNUM *rnd, int bits) return (0); /* we now have a random number 'rand' to test. */ for (i = 1; i < NUMPRIMES; i++) { - BN_ULONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]); + BN_ULONG mod = BN_mod_word(rnd, primes[i]); if (mod == (BN_ULONG)-1) return (0); - mods[i] = (prime_t)mod; + mods[i] = mod; } maxdelta = BN_MASK2 - primes[NUMPRIMES - 1]; delta = 0; @@ -437,7 +337,6 @@ probable_prime(BIGNUM *rnd, int bits) } if (!BN_add_word(rnd, delta)) return (0); - bn_check_top(rnd); return (1); } @@ -474,7 +373,7 @@ probable_prime_dh(BIGNUM *rnd, int bits, const BIGNUM *add, const BIGNUM *rem, loop: for (i = 1; i < NUMPRIMES; i++) { /* check that rnd is a prime */ - BN_LONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]); + BN_LONG mod = BN_mod_word(rnd, primes[i]); if (mod == (BN_ULONG)-1) goto err; if (mod <= 1) { @@ -487,7 +386,6 @@ probable_prime_dh(BIGNUM *rnd, int bits, const BIGNUM *add, const BIGNUM *rem, err: BN_CTX_end(ctx); - bn_check_top(rnd); return (ret); } @@ -539,8 +437,8 @@ probable_prime_dh_safe(BIGNUM *p, int bits, const BIGNUM *padd, /* check that p and q are prime */ /* check that for p and q * gcd(p-1,primes) == 1 (except for 2) */ - BN_ULONG pmod = BN_mod_word(p, (BN_ULONG)primes[i]); - BN_ULONG qmod = BN_mod_word(q, (BN_ULONG)primes[i]); + BN_ULONG pmod = BN_mod_word(p, primes[i]); + BN_ULONG qmod = BN_mod_word(q, primes[i]); if (pmod == (BN_ULONG)-1 || qmod == (BN_ULONG)-1) goto err; if (pmod == 0 || qmod == 0) { @@ -555,6 +453,5 @@ probable_prime_dh_safe(BIGNUM *p, int bits, const BIGNUM *padd, err: BN_CTX_end(ctx); - bn_check_top(p); return (ret); } diff --git a/crypto/bn/bn_prime.h b/crypto/bn/bn_prime.h index d5199008..4ea2d479 100644 --- a/crypto/bn/bn_prime.h +++ b/crypto/bn/bn_prime.h @@ -1,323 +1,14 @@ -/* $OpenBSD: bn_prime.h,v 1.7 2016/12/21 15:49:29 jsing Exp $ */ -/* Auto generated by bn_prime.pl */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] +/* $OpenBSD: bn_prime.h,v 1.9 2022/11/10 10:24:50 tb Exp $ */ +/* + * Public domain. */ +#include + __BEGIN_HIDDEN_DECLS #define NUMPRIMES 2048 -typedef unsigned short prime_t; -static const prime_t primes[NUMPRIMES] = { - 2, 3, 5, 7, 11, 13, 17, 19, - 23, 29, 31, 37, 41, 43, 47, 53, - 59, 61, 67, 71, 73, 79, 83, 89, - 97, 101, 103, 107, 109, 113, 127, 131, - 137, 139, 149, 151, 157, 163, 167, 173, - 179, 181, 191, 193, 197, 199, 211, 223, - 227, 229, 233, 239, 241, 251, 257, 263, - 269, 271, 277, 281, 283, 293, 307, 311, - 313, 317, 331, 337, 347, 349, 353, 359, - 367, 373, 379, 383, 389, 397, 401, 409, - 419, 421, 431, 433, 439, 443, 449, 457, - 461, 463, 467, 479, 487, 491, 499, 503, - 509, 521, 523, 541, 547, 557, 563, 569, - 571, 577, 587, 593, 599, 601, 607, 613, - 617, 619, 631, 641, 643, 647, 653, 659, - 661, 673, 677, 683, 691, 701, 709, 719, - 727, 733, 739, 743, 751, 757, 761, 769, - 773, 787, 797, 809, 811, 821, 823, 827, - 829, 839, 853, 857, 859, 863, 877, 881, - 883, 887, 907, 911, 919, 929, 937, 941, - 947, 953, 967, 971, 977, 983, 991, 997, - 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, - 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, - 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, - 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, - 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, - 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, - 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, - 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, - 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, - 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, - 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, - 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, - 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, - 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, - 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, - 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, - 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, - 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, - 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, - 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, - 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, - 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, - 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, - 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, - 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, - 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, - 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, - 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, - 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, - 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, - 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, - 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, - 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, - 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, - 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, - 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, - 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, - 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, - 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, - 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, - 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, - 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, - 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, - 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, - 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, - 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, - 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, - 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, - 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, - 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, - 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, - 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, - 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, - 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, - 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, - 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, - 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, - 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, - 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, - 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, - 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, - 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, - 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, - 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, - 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, - 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, - 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, - 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, - 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, - 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, - 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, - 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, - 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, - 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, - 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, - 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, - 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, - 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, - 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, - 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, - 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, - 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, - 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, - 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, - 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, - 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, - 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, - 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, - 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, - 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, - 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, - 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, - 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, - 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, - 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, - 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, - 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, - 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, - 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, - 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, - 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, - 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, - 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, - 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, - 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, - 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, - 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, - 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, - 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, - 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, - 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, - 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, - 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, - 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, - 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, - 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, - 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, - 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, - 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, - 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, - 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, - 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, - 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, - 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, - 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, - 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, - 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, - 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, - 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, - 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, - 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, - 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, - 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, - 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, - 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, - 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, - 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, - 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, - 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, - 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, - 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, - 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, - 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, - 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, - 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, - 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, - 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, - 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, - 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, - 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, - 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, - 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, - 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, - 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, - 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, - 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, - 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, - 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, - 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, - 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, - 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, - 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, - 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, - 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, - 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, - 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, - 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, - 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, - 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, - 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, - 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, - 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, - 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, - 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, - 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, - 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, - 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, - 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, - 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, - 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, - 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, - 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, - 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, - 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, - 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, - 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, - 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, - 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, - 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, - 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, - 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, - 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, - 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, - 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, - 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, - 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, - 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, - 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, - 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, - 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, - 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, - 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, - 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, - 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, - 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, - 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, - 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, - 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, - 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, - 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, - 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, - 15923, 15937, 15959, 15971, 15973, 15991, 16001, 16007, - 16033, 16057, 16061, 16063, 16067, 16069, 16073, 16087, - 16091, 16097, 16103, 16111, 16127, 16139, 16141, 16183, - 16187, 16189, 16193, 16217, 16223, 16229, 16231, 16249, - 16253, 16267, 16273, 16301, 16319, 16333, 16339, 16349, - 16361, 16363, 16369, 16381, 16411, 16417, 16421, 16427, - 16433, 16447, 16451, 16453, 16477, 16481, 16487, 16493, - 16519, 16529, 16547, 16553, 16561, 16567, 16573, 16603, - 16607, 16619, 16631, 16633, 16649, 16651, 16657, 16661, - 16673, 16691, 16693, 16699, 16703, 16729, 16741, 16747, - 16759, 16763, 16787, 16811, 16823, 16829, 16831, 16843, - 16871, 16879, 16883, 16889, 16901, 16903, 16921, 16927, - 16931, 16937, 16943, 16963, 16979, 16981, 16987, 16993, - 17011, 17021, 17027, 17029, 17033, 17041, 17047, 17053, - 17077, 17093, 17099, 17107, 17117, 17123, 17137, 17159, - 17167, 17183, 17189, 17191, 17203, 17207, 17209, 17231, - 17239, 17257, 17291, 17293, 17299, 17317, 17321, 17327, - 17333, 17341, 17351, 17359, 17377, 17383, 17387, 17389, - 17393, 17401, 17417, 17419, 17431, 17443, 17449, 17467, - 17471, 17477, 17483, 17489, 17491, 17497, 17509, 17519, - 17539, 17551, 17569, 17573, 17579, 17581, 17597, 17599, - 17609, 17623, 17627, 17657, 17659, 17669, 17681, 17683, - 17707, 17713, 17729, 17737, 17747, 17749, 17761, 17783, - 17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863, -}; + +extern const uint16_t primes[NUMPRIMES]; __END_HIDDEN_DECLS diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c index 9b5c7533..7e0683b6 100644 --- a/crypto/bn/bn_print.c +++ b/crypto/bn/bn_print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_print.c,v 1.33 2022/01/20 10:53:33 inoguchi Exp $ */ +/* $OpenBSD: bn_print.c,v 1.38 2023/02/13 04:25:37 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,7 +66,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" static const char Hex[]="0123456789ABCDEF"; @@ -205,7 +205,7 @@ BN_hex2bn(BIGNUM **bn, const char *a) for (i = 0; i <= (INT_MAX / 4) && isxdigit((unsigned char)a[i]); i++) ; if (i > INT_MAX / 4) - goto err; + return (0); num = i + neg; if (bn == NULL) @@ -221,7 +221,7 @@ BN_hex2bn(BIGNUM **bn, const char *a) } /* i is the number of hex digits */ - if (bn_expand(ret, i * 4) == NULL) + if (!bn_expand(ret, i * 4)) goto err; j = i; /* least significant 'hex' */ @@ -251,10 +251,10 @@ BN_hex2bn(BIGNUM **bn, const char *a) } ret->top = h; bn_correct_top(ret); - ret->neg = neg; + + BN_set_negative(ret, neg); *bn = ret; - bn_check_top(ret); return (num); err: @@ -281,7 +281,7 @@ BN_dec2bn(BIGNUM **bn, const char *a) for (i = 0; i <= (INT_MAX / 4) && isdigit((unsigned char)a[i]); i++) ; if (i > INT_MAX / 4) - goto err; + return (0); num = i + neg; if (bn == NULL) @@ -298,7 +298,7 @@ BN_dec2bn(BIGNUM **bn, const char *a) } /* i is the number of digits, a bit of an over expand */ - if (bn_expand(ret, i * 4) == NULL) + if (!bn_expand(ret, i * 4)) goto err; j = BN_DEC_NUM - (i % BN_DEC_NUM); @@ -318,11 +318,12 @@ BN_dec2bn(BIGNUM **bn, const char *a) j = 0; } } - ret->neg = neg; bn_correct_top(ret); + + BN_set_negative(ret, neg); + *bn = ret; - bn_check_top(ret); return (num); err: @@ -346,7 +347,7 @@ BN_asc2bn(BIGNUM **bn, const char *a) return 0; } if (*a == '-') - (*bn)->neg = 1; + BN_set_negative(*bn, 1); return 1; } diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c index b21692c9..a03d7005 100644 --- a/crypto/bn/bn_rand.c +++ b/crypto/bn/bn_rand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_rand.c,v 1.25 2021/08/31 11:19:19 tb Exp $ */ +/* $OpenBSD: bn_rand.c,v 1.27 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -116,7 +116,7 @@ #include -#include "bn_lcl.h" +#include "bn_local.h" static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) @@ -190,7 +190,6 @@ bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) err: freezero(buf, bytes); - bn_check_top(rnd); return (ret); } @@ -272,7 +271,6 @@ bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range) } while (BN_cmp(r, range) >= 0); } - bn_check_top(r); return 1; } diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c index 6588d330..117f8933 100644 --- a/crypto/bn/bn_recp.c +++ b/crypto/bn/bn_recp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_recp.c,v 1.15 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: bn_recp.c,v 1.18 2023/02/13 04:25:37 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -60,7 +60,7 @@ #include -#include "bn_lcl.h" +#include "bn_local.h" void BN_RECP_CTX_init(BN_RECP_CTX *recp) @@ -134,7 +134,6 @@ BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, err: BN_CTX_end(ctx); - bn_check_top(r); return (ret); } @@ -222,14 +221,13 @@ BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp, } #endif - r->neg = BN_is_zero(r) ? 0 : m->neg; - d->neg = m->neg^recp->N.neg; + BN_set_negative(r, m->neg); + BN_set_negative(d, m->neg ^ recp->N.neg); + ret = 1; err: BN_CTX_end(ctx); - bn_check_top(dv); - bn_check_top(rem); return (ret); } @@ -257,7 +255,6 @@ BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx) ret = len; err: - bn_check_top(r); BN_CTX_end(ctx); return (ret); } diff --git a/crypto/bn/bn_shift.c b/crypto/bn/bn_shift.c index e89e1574..eee34367 100644 --- a/crypto/bn/bn_shift.c +++ b/crypto/bn/bn_shift.c @@ -1,230 +1,171 @@ -/* $OpenBSD: bn_shift.c,v 1.14 2022/06/22 09:03:06 tb Exp $ */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. +/* $OpenBSD: bn_shift.c,v 1.21 2023/02/13 04:25:37 jsing Exp $ */ +/* + * Copyright (c) 2022, 2023 Joel Sing * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - +#include #include -#include "bn_lcl.h" +#include "bn_local.h" -int -BN_lshift1(BIGNUM *r, const BIGNUM *a) +static inline int +bn_lshift(BIGNUM *r, const BIGNUM *a, int n) { - BN_ULONG *ap, *rp, t, c; - int i; - - bn_check_top(r); - bn_check_top(a); - - if (r != a) { - r->neg = a->neg; - if (bn_wexpand(r, a->top + 1) == NULL) - return (0); - r->top = a->top; - } else { - if (bn_wexpand(r, a->top + 1) == NULL) - return (0); - } - ap = a->d; - rp = r->d; - c = 0; - for (i = 0; i < a->top; i++) { - t= *(ap++); - *(rp++) = ((t << 1) | c) & BN_MASK2; - c = (t & BN_TBIT) ? 1 : 0; + size_t count, shift_bits, shift_words; + size_t lshift, rshift; + ssize_t rstride; + BN_ULONG *dst, *src; + + if (n < 0) { + BNerror(BN_R_INVALID_LENGTH); + return 0; } - if (c) { - *rp = 1; - r->top++; + shift_bits = n; + + /* + * Left bit shift, potentially across word boundaries. + * + * When shift is not an exact multiple of BN_BITS2, the bottom bits of + * the previous word need to be right shifted and combined with the left + * shifted bits using bitwise OR. If shift is an exact multiple of + * BN_BITS2, the source for the left and right shifts are the same + * and the shifts become zero bits (which is effectively a memmove). + */ + shift_words = shift_bits / BN_BITS2; + lshift = shift_bits % BN_BITS2; + rshift = (BN_BITS2 - lshift) % BN_BITS2; + rstride = 0 - (lshift + rshift) / BN_BITS2; + + if (a->top < 1) { + BN_zero(r); + return 1; } - bn_check_top(r); - return (1); -} -int -BN_rshift1(BIGNUM *r, const BIGNUM *a) -{ - BN_ULONG *ap, *rp, t, c; - int i, j; + count = a->top + shift_words + 1; - bn_check_top(r); - bn_check_top(a); + if (count < shift_words) + return 0; - if (BN_is_zero(a)) { - BN_zero(r); - return (1); - } - i = a->top; - ap = a->d; - j = i - (ap[i - 1]==1); - if (a != r) { - if (bn_wexpand(r, j) == NULL) - return (0); - r->neg = a->neg; + if (!bn_wexpand(r, count)) + return 0; + + src = a->d + a->top - 1; + dst = r->d + a->top + shift_words; + + /* Handle right shift for top most word. */ + *dst = (*src >> rshift) & rstride; + dst--; + + /* Handle left shift and right shift for remaining words. */ + while (src > a->d) { + *dst = *src << lshift | src[rstride] >> rshift; + src--; + dst--; } - rp = r->d; - t = ap[--i]; - c = (t & 1) ? BN_TBIT : 0; - if (t >>= 1) - rp[i] = t; - while (i > 0) { - t = ap[--i]; - rp[i] = ((t >> 1) & BN_MASK2) | c; - c = (t & 1) ? BN_TBIT : 0; + *dst = *src << lshift; + + /* Zero any additional words resulting from the left shift. */ + while (dst > r->d) { + dst--; + *dst = 0; } - r->top = j; - bn_check_top(r); - return (1); + + r->top = count; + bn_correct_top(r); + + BN_set_negative(r, a->neg); + + return 1; } -int -BN_lshift(BIGNUM *r, const BIGNUM *a, int n) +static inline int +bn_rshift(BIGNUM *r, const BIGNUM *a, int n) { - int i, nw, lb, rb; - BN_ULONG *t, *f; - BN_ULONG l; + size_t count, shift_bits, shift_words; + size_t lshift, rshift; + ssize_t lstride; + BN_ULONG *dst, *src; + size_t i; if (n < 0) { BNerror(BN_R_INVALID_LENGTH); return 0; } + shift_bits = n; + + /* + * Right bit shift, potentially across word boundaries. + * + * When shift is not an exact multiple of BN_BITS2, the top bits of + * the next word need to be left shifted and combined with the right + * shifted bits using bitwise OR. If shift is an exact multiple of + * BN_BITS2, the source for the left and right shifts are the same + * and the shifts become zero (which is effectively a memmove). + */ + shift_words = shift_bits / BN_BITS2; + rshift = shift_bits % BN_BITS2; + lshift = (BN_BITS2 - rshift) % BN_BITS2; + lstride = (lshift + rshift) / BN_BITS2; + + if (a->top <= shift_words) { + BN_zero(r); + return 1; + } + count = a->top - shift_words; + + if (!bn_wexpand(r, count)) + return 0; + + src = a->d + shift_words; + dst = r->d; - bn_check_top(r); - bn_check_top(a); - - r->neg = a->neg; - nw = n / BN_BITS2; - if (bn_wexpand(r, a->top + nw + 1) == NULL) - return (0); - lb = n % BN_BITS2; - rb = BN_BITS2 - lb; - f = a->d; - t = r->d; - t[a->top + nw] = 0; - if (lb == 0) - for (i = a->top - 1; i >= 0; i--) - t[nw + i] = f[i]; - else - for (i = a->top - 1; i >= 0; i--) { - l = f[i]; - t[nw + i + 1] |= (l >> rb) & BN_MASK2; - t[nw + i] = (l << lb) & BN_MASK2; - } - memset(t, 0, nw * sizeof(t[0])); -/* for (i=0; itop = a->top + nw + 1; + for (i = 1; i < count; i++) { + *dst = src[lstride] << lshift | *src >> rshift; + src++; + dst++; + } + *dst = *src >> rshift; + + r->top = count; bn_correct_top(r); - bn_check_top(r); - return (1); + + BN_set_negative(r, a->neg); + + return 1; } int -BN_rshift(BIGNUM *r, const BIGNUM *a, int n) +BN_lshift1(BIGNUM *r, const BIGNUM *a) { - int i, j, nw, lb, rb; - BN_ULONG *t, *f; - BN_ULONG l, tmp; - - if (n < 0) { - BNerror(BN_R_INVALID_LENGTH); - return 0; - } + return bn_lshift(r, a, 1); +} - bn_check_top(r); - bn_check_top(a); +int +BN_lshift(BIGNUM *r, const BIGNUM *a, int n) +{ + return bn_lshift(r, a, n); +} - nw = n / BN_BITS2; - rb = n % BN_BITS2; - lb = BN_BITS2 - rb; - if (nw >= a->top || a->top == 0) { - BN_zero(r); - return (1); - } - i = (BN_num_bits(a) - n + (BN_BITS2 - 1)) / BN_BITS2; - if (r != a) { - r->neg = a->neg; - if (bn_wexpand(r, i) == NULL) - return (0); - } else { - if (n == 0) - return 1; /* or the copying loop will go berserk */ - } +int +BN_rshift1(BIGNUM *r, const BIGNUM *a) +{ + return bn_rshift(r, a, 1); +} - f = &(a->d[nw]); - t = r->d; - j = a->top - nw; - r->top = i; - - if (rb == 0) { - for (i = j; i != 0; i--) - *(t++) = *(f++); - } else { - l = *(f++); - for (i = j - 1; i != 0; i--) { - tmp = (l >> rb) & BN_MASK2; - l = *(f++); - *(t++) = (tmp|(l << lb)) & BN_MASK2; - } - if ((l = (l >> rb) & BN_MASK2)) - *(t) = l; - } - bn_check_top(r); - return (1); +int +BN_rshift(BIGNUM *r, const BIGNUM *a, int n) +{ + return bn_rshift(r, a, n); } diff --git a/crypto/bn/bn_small_primes.c b/crypto/bn/bn_small_primes.c new file mode 100644 index 00000000..bfb7903a --- /dev/null +++ b/crypto/bn/bn_small_primes.c @@ -0,0 +1,265 @@ +/* $OpenBSD: bn_small_primes.c,v 1.1 2022/11/09 22:52:51 tb Exp $ */ +/* + * Public domain, generated by bn_prime.pl. + */ + +#include "bn_prime.h" + +const uint16_t primes[NUMPRIMES] = { + 2, 3, 5, 7, 11, 13, 17, 19, + 23, 29, 31, 37, 41, 43, 47, 53, + 59, 61, 67, 71, 73, 79, 83, 89, + 97, 101, 103, 107, 109, 113, 127, 131, + 137, 139, 149, 151, 157, 163, 167, 173, + 179, 181, 191, 193, 197, 199, 211, 223, + 227, 229, 233, 239, 241, 251, 257, 263, + 269, 271, 277, 281, 283, 293, 307, 311, + 313, 317, 331, 337, 347, 349, 353, 359, + 367, 373, 379, 383, 389, 397, 401, 409, + 419, 421, 431, 433, 439, 443, 449, 457, + 461, 463, 467, 479, 487, 491, 499, 503, + 509, 521, 523, 541, 547, 557, 563, 569, + 571, 577, 587, 593, 599, 601, 607, 613, + 617, 619, 631, 641, 643, 647, 653, 659, + 661, 673, 677, 683, 691, 701, 709, 719, + 727, 733, 739, 743, 751, 757, 761, 769, + 773, 787, 797, 809, 811, 821, 823, 827, + 829, 839, 853, 857, 859, 863, 877, 881, + 883, 887, 907, 911, 919, 929, 937, 941, + 947, 953, 967, 971, 977, 983, 991, 997, + 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, + 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, + 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, + 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, + 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, + 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, + 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, + 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, + 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, + 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, + 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, + 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, + 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, + 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, + 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, + 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, + 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, + 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, + 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, + 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, + 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, + 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, + 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, + 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, + 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, + 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, + 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, + 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, + 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, + 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, + 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, + 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, + 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, + 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, + 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, + 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, + 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, + 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, + 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, + 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, + 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, + 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, + 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, + 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, + 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, + 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, + 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, + 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, + 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, + 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, + 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, + 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, + 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, + 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, + 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, + 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, + 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, + 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, + 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, + 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, + 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, + 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, + 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, + 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, + 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, + 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, + 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, + 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, + 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, + 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, + 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, + 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, + 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, + 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, + 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, + 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, + 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, + 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, + 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, + 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, + 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, + 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, + 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, + 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, + 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, + 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, + 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, + 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, + 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, + 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, + 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, + 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, + 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, + 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, + 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, + 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, + 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, + 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, + 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, + 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, + 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, + 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, + 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, + 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, + 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, + 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, + 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, + 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, + 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, + 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, + 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, + 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, + 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, + 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, + 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, + 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, + 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, + 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, + 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, + 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, + 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, + 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, + 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, + 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, + 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, + 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, + 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, + 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, + 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, + 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, + 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, + 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, + 9931, 9941, 9949, 9967, 9973, 10007, 10009, 10037, + 10039, 10061, 10067, 10069, 10079, 10091, 10093, 10099, + 10103, 10111, 10133, 10139, 10141, 10151, 10159, 10163, + 10169, 10177, 10181, 10193, 10211, 10223, 10243, 10247, + 10253, 10259, 10267, 10271, 10273, 10289, 10301, 10303, + 10313, 10321, 10331, 10333, 10337, 10343, 10357, 10369, + 10391, 10399, 10427, 10429, 10433, 10453, 10457, 10459, + 10463, 10477, 10487, 10499, 10501, 10513, 10529, 10531, + 10559, 10567, 10589, 10597, 10601, 10607, 10613, 10627, + 10631, 10639, 10651, 10657, 10663, 10667, 10687, 10691, + 10709, 10711, 10723, 10729, 10733, 10739, 10753, 10771, + 10781, 10789, 10799, 10831, 10837, 10847, 10853, 10859, + 10861, 10867, 10883, 10889, 10891, 10903, 10909, 10937, + 10939, 10949, 10957, 10973, 10979, 10987, 10993, 11003, + 11027, 11047, 11057, 11059, 11069, 11071, 11083, 11087, + 11093, 11113, 11117, 11119, 11131, 11149, 11159, 11161, + 11171, 11173, 11177, 11197, 11213, 11239, 11243, 11251, + 11257, 11261, 11273, 11279, 11287, 11299, 11311, 11317, + 11321, 11329, 11351, 11353, 11369, 11383, 11393, 11399, + 11411, 11423, 11437, 11443, 11447, 11467, 11471, 11483, + 11489, 11491, 11497, 11503, 11519, 11527, 11549, 11551, + 11579, 11587, 11593, 11597, 11617, 11621, 11633, 11657, + 11677, 11681, 11689, 11699, 11701, 11717, 11719, 11731, + 11743, 11777, 11779, 11783, 11789, 11801, 11807, 11813, + 11821, 11827, 11831, 11833, 11839, 11863, 11867, 11887, + 11897, 11903, 11909, 11923, 11927, 11933, 11939, 11941, + 11953, 11959, 11969, 11971, 11981, 11987, 12007, 12011, + 12037, 12041, 12043, 12049, 12071, 12073, 12097, 12101, + 12107, 12109, 12113, 12119, 12143, 12149, 12157, 12161, + 12163, 12197, 12203, 12211, 12227, 12239, 12241, 12251, + 12253, 12263, 12269, 12277, 12281, 12289, 12301, 12323, + 12329, 12343, 12347, 12373, 12377, 12379, 12391, 12401, + 12409, 12413, 12421, 12433, 12437, 12451, 12457, 12473, + 12479, 12487, 12491, 12497, 12503, 12511, 12517, 12527, + 12539, 12541, 12547, 12553, 12569, 12577, 12583, 12589, + 12601, 12611, 12613, 12619, 12637, 12641, 12647, 12653, + 12659, 12671, 12689, 12697, 12703, 12713, 12721, 12739, + 12743, 12757, 12763, 12781, 12791, 12799, 12809, 12821, + 12823, 12829, 12841, 12853, 12889, 12893, 12899, 12907, + 12911, 12917, 12919, 12923, 12941, 12953, 12959, 12967, + 12973, 12979, 12983, 13001, 13003, 13007, 13009, 13033, + 13037, 13043, 13049, 13063, 13093, 13099, 13103, 13109, + 13121, 13127, 13147, 13151, 13159, 13163, 13171, 13177, + 13183, 13187, 13217, 13219, 13229, 13241, 13249, 13259, + 13267, 13291, 13297, 13309, 13313, 13327, 13331, 13337, + 13339, 13367, 13381, 13397, 13399, 13411, 13417, 13421, + 13441, 13451, 13457, 13463, 13469, 13477, 13487, 13499, + 13513, 13523, 13537, 13553, 13567, 13577, 13591, 13597, + 13613, 13619, 13627, 13633, 13649, 13669, 13679, 13681, + 13687, 13691, 13693, 13697, 13709, 13711, 13721, 13723, + 13729, 13751, 13757, 13759, 13763, 13781, 13789, 13799, + 13807, 13829, 13831, 13841, 13859, 13873, 13877, 13879, + 13883, 13901, 13903, 13907, 13913, 13921, 13931, 13933, + 13963, 13967, 13997, 13999, 14009, 14011, 14029, 14033, + 14051, 14057, 14071, 14081, 14083, 14087, 14107, 14143, + 14149, 14153, 14159, 14173, 14177, 14197, 14207, 14221, + 14243, 14249, 14251, 14281, 14293, 14303, 14321, 14323, + 14327, 14341, 14347, 14369, 14387, 14389, 14401, 14407, + 14411, 14419, 14423, 14431, 14437, 14447, 14449, 14461, + 14479, 14489, 14503, 14519, 14533, 14537, 14543, 14549, + 14551, 14557, 14561, 14563, 14591, 14593, 14621, 14627, + 14629, 14633, 14639, 14653, 14657, 14669, 14683, 14699, + 14713, 14717, 14723, 14731, 14737, 14741, 14747, 14753, + 14759, 14767, 14771, 14779, 14783, 14797, 14813, 14821, + 14827, 14831, 14843, 14851, 14867, 14869, 14879, 14887, + 14891, 14897, 14923, 14929, 14939, 14947, 14951, 14957, + 14969, 14983, 15013, 15017, 15031, 15053, 15061, 15073, + 15077, 15083, 15091, 15101, 15107, 15121, 15131, 15137, + 15139, 15149, 15161, 15173, 15187, 15193, 15199, 15217, + 15227, 15233, 15241, 15259, 15263, 15269, 15271, 15277, + 15287, 15289, 15299, 15307, 15313, 15319, 15329, 15331, + 15349, 15359, 15361, 15373, 15377, 15383, 15391, 15401, + 15413, 15427, 15439, 15443, 15451, 15461, 15467, 15473, + 15493, 15497, 15511, 15527, 15541, 15551, 15559, 15569, + 15581, 15583, 15601, 15607, 15619, 15629, 15641, 15643, + 15647, 15649, 15661, 15667, 15671, 15679, 15683, 15727, + 15731, 15733, 15737, 15739, 15749, 15761, 15767, 15773, + 15787, 15791, 15797, 15803, 15809, 15817, 15823, 15859, + 15877, 15881, 15887, 15889, 15901, 15907, 15913, 15919, + 15923, 15937, 15959, 15971, 15973, 15991, 16001, 16007, + 16033, 16057, 16061, 16063, 16067, 16069, 16073, 16087, + 16091, 16097, 16103, 16111, 16127, 16139, 16141, 16183, + 16187, 16189, 16193, 16217, 16223, 16229, 16231, 16249, + 16253, 16267, 16273, 16301, 16319, 16333, 16339, 16349, + 16361, 16363, 16369, 16381, 16411, 16417, 16421, 16427, + 16433, 16447, 16451, 16453, 16477, 16481, 16487, 16493, + 16519, 16529, 16547, 16553, 16561, 16567, 16573, 16603, + 16607, 16619, 16631, 16633, 16649, 16651, 16657, 16661, + 16673, 16691, 16693, 16699, 16703, 16729, 16741, 16747, + 16759, 16763, 16787, 16811, 16823, 16829, 16831, 16843, + 16871, 16879, 16883, 16889, 16901, 16903, 16921, 16927, + 16931, 16937, 16943, 16963, 16979, 16981, 16987, 16993, + 17011, 17021, 17027, 17029, 17033, 17041, 17047, 17053, + 17077, 17093, 17099, 17107, 17117, 17123, 17137, 17159, + 17167, 17183, 17189, 17191, 17203, 17207, 17209, 17231, + 17239, 17257, 17291, 17293, 17299, 17317, 17321, 17327, + 17333, 17341, 17351, 17359, 17377, 17383, 17387, 17389, + 17393, 17401, 17417, 17419, 17431, 17443, 17449, 17467, + 17471, 17477, 17483, 17489, 17491, 17497, 17509, 17519, + 17539, 17551, 17569, 17573, 17579, 17581, 17597, 17599, + 17609, 17623, 17627, 17657, 17659, 17669, 17681, 17683, + 17707, 17713, 17729, 17737, 17747, 17749, 17761, 17783, + 17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863, +}; diff --git a/crypto/bn/bn_sqr.c b/crypto/bn/bn_sqr.c index a0dce6ea..6e784541 100644 --- a/crypto/bn/bn_sqr.c +++ b/crypto/bn/bn_sqr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_sqr.c,v 1.12 2015/02/09 15:49:22 jsing Exp $ */ +/* $OpenBSD: bn_sqr.c,v 1.27 2023/02/17 05:13:34 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,101 +56,140 @@ * [including the GNU Public Licence.] */ +#include #include #include -#include "bn_lcl.h" +#include "bn_arch.h" +#include "bn_local.h" +#include "bn_internal.h" -/* r must not be a */ -/* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */ -int -BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) +int bn_sqr(BIGNUM *r, const BIGNUM *a, int max, BN_CTX *ctx); + +/* + * bn_sqr_comba4() computes r[] = a[] * a[] using Comba multiplication + * (https://everything2.com/title/Comba+multiplication), where a is a + * four word array, producing an eight word array result. + */ +#ifndef HAVE_BN_SQR_COMBA4 +void +bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a) { - int max, al; - int ret = 0; - BIGNUM *tmp, *rr; + BN_ULONG c2, c1, c0; -#ifdef BN_COUNT - fprintf(stderr, "BN_sqr %d * %d\n", a->top, a->top); -#endif - bn_check_top(a); + bn_mulw_addtw(a[0], a[0], 0, 0, 0, &c2, &c1, &r[0]); - al = a->top; - if (al <= 0) { - r->top = 0; - r->neg = 0; - return 1; - } + bn_mul2_mulw_addtw(a[1], a[0], 0, c2, c1, &c2, &c1, &r[1]); - BN_CTX_start(ctx); - rr = (a != r) ? r : BN_CTX_get(ctx); - tmp = BN_CTX_get(ctx); - if (rr == NULL || tmp == NULL) - goto err; + bn_mulw_addtw(a[1], a[1], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[2], a[0], c2, c1, c0, &c2, &c1, &r[2]); - max = 2 * al; /* Non-zero (from above) */ - if (bn_wexpand(rr, max) == NULL) - goto err; + bn_mul2_mulw_addtw(a[3], a[0], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[2], a[1], c2, c1, c0, &c2, &c1, &r[3]); - if (al == 4) { -#ifndef BN_SQR_COMBA - BN_ULONG t[8]; - bn_sqr_normal(rr->d, a->d, 4, t); -#else - bn_sqr_comba4(rr->d, a->d); -#endif - } else if (al == 8) { -#ifndef BN_SQR_COMBA - BN_ULONG t[16]; - bn_sqr_normal(rr->d, a->d, 8, t); -#else - bn_sqr_comba8(rr->d, a->d); + bn_mulw_addtw(a[2], a[2], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[3], a[1], c2, c1, c0, &c2, &c1, &r[4]); + + bn_mul2_mulw_addtw(a[3], a[2], 0, c2, c1, &c2, &c1, &r[5]); + + bn_mulw_addtw(a[3], a[3], 0, c2, c1, &c2, &r[7], &r[6]); +} #endif - } else { -#if defined(BN_RECURSION) - if (al < BN_SQR_RECURSIVE_SIZE_NORMAL) { - BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL*2]; - bn_sqr_normal(rr->d, a->d, al, t); - } else { - int j, k; - - j = BN_num_bits_word((BN_ULONG)al); - j = 1 << (j - 1); - k = j + j; - if (al == j) { - if (bn_wexpand(tmp, k * 2) == NULL) - goto err; - bn_sqr_recursive(rr->d, a->d, al, tmp->d); - } else { - if (bn_wexpand(tmp, max) == NULL) - goto err; - bn_sqr_normal(rr->d, a->d, al, tmp->d); - } - } -#else - if (bn_wexpand(tmp, max) == NULL) - goto err; - bn_sqr_normal(rr->d, a->d, al, tmp->d); + +/* + * bn_sqr_comba8() computes r[] = a[] * a[] using Comba multiplication + * (https://everything2.com/title/Comba+multiplication), where a is an + * eight word array, producing an 16 word array result. + */ +#ifndef HAVE_BN_SQR_COMBA8 +void +bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a) +{ + BN_ULONG c2, c1, c0; + + bn_mulw_addtw(a[0], a[0], 0, 0, 0, &c2, &c1, &r[0]); + + bn_mul2_mulw_addtw(a[1], a[0], 0, c2, c1, &c2, &c1, &r[1]); + + bn_mulw_addtw(a[1], a[1], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[2], a[0], c2, c1, c0, &c2, &c1, &r[2]); + + bn_mul2_mulw_addtw(a[3], a[0], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[2], a[1], c2, c1, c0, &c2, &c1, &r[3]); + + bn_mulw_addtw(a[2], a[2], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[3], a[1], c2, c1, c0, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[4], a[0], c2, c1, c0, &c2, &c1, &r[4]); + + bn_mul2_mulw_addtw(a[5], a[0], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[4], a[1], c2, c1, c0, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[3], a[2], c2, c1, c0, &c2, &c1, &r[5]); + + bn_mulw_addtw(a[3], a[3], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[4], a[2], c2, c1, c0, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[5], a[1], c2, c1, c0, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[6], a[0], c2, c1, c0, &c2, &c1, &r[6]); + + bn_mul2_mulw_addtw(a[7], a[0], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[6], a[1], c2, c1, c0, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[5], a[2], c2, c1, c0, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[4], a[3], c2, c1, c0, &c2, &c1, &r[7]); + + bn_mulw_addtw(a[4], a[4], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[5], a[3], c2, c1, c0, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[6], a[2], c2, c1, c0, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[7], a[1], c2, c1, c0, &c2, &c1, &r[8]); + + bn_mul2_mulw_addtw(a[7], a[2], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[6], a[3], c2, c1, c0, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[5], a[4], c2, c1, c0, &c2, &c1, &r[9]); + + bn_mulw_addtw(a[5], a[5], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[6], a[4], c2, c1, c0, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[7], a[3], c2, c1, c0, &c2, &c1, &r[10]); + + bn_mul2_mulw_addtw(a[7], a[4], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[6], a[5], c2, c1, c0, &c2, &c1, &r[11]); + + bn_mulw_addtw(a[6], a[6], 0, c2, c1, &c2, &c1, &c0); + bn_mul2_mulw_addtw(a[7], a[5], c2, c1, c0, &c2, &c1, &r[12]); + + bn_mul2_mulw_addtw(a[7], a[6], 0, c2, c1, &c2, &c1, &r[13]); + + bn_mulw_addtw(a[7], a[7], 0, c2, c1, &c2, &r[15], &r[14]); +} #endif - } - rr->neg = 0; - /* If the most-significant half of the top word of 'a' is zero, then - * the square of 'a' will max-1 words. */ - if (a->d[al - 1] == (a->d[al - 1] & BN_MASK2l)) - rr->top = max - 1; - else - rr->top = max; - if (rr != r) - BN_copy(r, rr); - ret = 1; +#ifndef HAVE_BN_SQR_WORDS +/* + * bn_sqr_words() computes (r[i*2+1]:r[i*2]) = a[i] * a[i]. + */ +void +bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n) +{ + assert(n >= 0); + if (n <= 0) + return; -err: - bn_check_top(rr); - bn_check_top(tmp); - BN_CTX_end(ctx); - return (ret); +#ifndef OPENSSL_SMALL_FOOTPRINT + while (n & ~3) { + bn_mulw(a[0], a[0], &r[1], &r[0]); + bn_mulw(a[1], a[1], &r[3], &r[2]); + bn_mulw(a[2], a[2], &r[5], &r[4]); + bn_mulw(a[3], a[3], &r[7], &r[6]); + a += 4; + r += 8; + n -= 4; + } +#endif + while (n) { + bn_mulw(a[0], a[0], &r[1], &r[0]); + a++; + r += 2; + n--; + } } +#endif /* tmp must have 2*n words */ void @@ -207,22 +246,11 @@ bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t) int zero, c1; BN_ULONG ln, lo, *p; -#ifdef BN_COUNT - fprintf(stderr, " bn_sqr_recursive %d * %d\n", n2, n2); -#endif if (n2 == 4) { -#ifndef BN_SQR_COMBA - bn_sqr_normal(r, a, 4, t); -#else bn_sqr_comba4(r, a); -#endif return; } else if (n2 == 8) { -#ifndef BN_SQR_COMBA - bn_sqr_normal(r, a, 8, t); -#else bn_sqr_comba8(r, a); -#endif return; } if (n2 < BN_SQR_RECURSIVE_SIZE_NORMAL) { @@ -284,3 +312,105 @@ bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t) } } #endif + +/* + * bn_sqr() computes a * a, storing the result in r. The caller must ensure that + * r is not the same BIGNUM as a and that r has been expanded to rn = a->top * 2 + * words. + */ +#ifndef HAVE_BN_SQR +int +bn_sqr(BIGNUM *r, const BIGNUM *a, int rn, BN_CTX *ctx) +{ + BIGNUM *tmp; + int ret = 0; + + BN_CTX_start(ctx); + + if ((tmp = BN_CTX_get(ctx)) == NULL) + goto err; + +#if defined(BN_RECURSION) + if (a->top < BN_SQR_RECURSIVE_SIZE_NORMAL) { + BN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL*2]; + bn_sqr_normal(r->d, a->d, a->top, t); + } else { + int j, k; + + j = BN_num_bits_word((BN_ULONG)a->top); + j = 1 << (j - 1); + k = j + j; + if (a->top == j) { + if (!bn_wexpand(tmp, k * 2)) + goto err; + bn_sqr_recursive(r->d, a->d, a->top, tmp->d); + } else { + if (!bn_wexpand(tmp, rn)) + goto err; + bn_sqr_normal(r->d, a->d, a->top, tmp->d); + } + } +#else + if (!bn_wexpand(tmp, rn)) + goto err; + bn_sqr_normal(r->d, a->d, a->top, tmp->d); +#endif + + ret = 1; + + err: + BN_CTX_end(ctx); + + return ret; +} +#endif + +int +BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) +{ + BIGNUM *rr; + int rn; + int ret = 1; + + BN_CTX_start(ctx); + + if (BN_is_zero(a)) { + BN_zero(r); + goto done; + } + + if ((rr = r) == a) + rr = BN_CTX_get(ctx); + if (rr == NULL) + goto err; + + rn = a->top * 2; + if (rn < a->top) + goto err; + if (!bn_wexpand(rr, rn)) + goto err; + + if (a->top == 4) { + bn_sqr_comba4(rr->d, a->d); + } else if (a->top == 8) { + bn_sqr_comba8(rr->d, a->d); + } else { + if (!bn_sqr(rr, a, rn, ctx)) + goto err; + } + + rr->top = rn; + bn_correct_top(rr); + + rr->neg = 0; + + if (rr != r) + BN_copy(r, rr); + + done: + ret = 1; + err: + BN_CTX_end(ctx); + + return ret; +} diff --git a/crypto/bn/bn_sqrt.c b/crypto/bn/bn_sqrt.c index 644797d6..9bbca426 100644 --- a/crypto/bn/bn_sqrt.c +++ b/crypto/bn/bn_sqrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_sqrt.c,v 1.11 2022/06/20 15:02:21 tb Exp $ */ +/* $OpenBSD: bn_sqrt.c,v 1.15 2023/03/07 09:27:10 jsing Exp $ */ /* Written by Lenka Fibikova * and Bodo Moeller for the OpenSSL project. */ /* ==================================================================== @@ -57,16 +57,18 @@ #include -#include "bn_lcl.h" +#include "bn_local.h" + +/* + * Returns 'ret' such that ret^2 == a (mod p), if it exists, using the + * Tonelli-Shanks algorithm following Henri Cohen, "A Course in Computational + * Algebraic Number Theory", algorithm 1.5.1, Springer, Berlin, 1996. + * + * Note: 'p' must be prime! + */ BIGNUM * BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) -/* Returns 'ret' such that - * ret^2 == a (mod p), - * using the Tonelli/Shanks algorithm (cf. Henri Cohen, "A Course - * in Algebraic Computational Number Theory", algorithm 1.5.1). - * 'p' must be prime! - */ { BIGNUM *ret = in; int err = 1; @@ -85,7 +87,6 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) BN_free(ret); return NULL; } - bn_check_top(ret); return ret; } @@ -103,7 +104,6 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) BN_free(ret); return NULL; } - bn_check_top(ret); return ret; } @@ -400,11 +400,10 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) end: if (err) { if (ret != NULL && ret != in) { - BN_clear_free(ret); + BN_free(ret); } ret = NULL; } BN_CTX_end(ctx); - bn_check_top(ret); return ret; } diff --git a/crypto/bn/bn_word.c b/crypto/bn/bn_word.c index 71654586..68d5c2a4 100644 --- a/crypto/bn/bn_word.c +++ b/crypto/bn/bn_word.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_word.c,v 1.13 2016/07/05 02:54:35 bcook Exp $ */ +/* $OpenBSD: bn_word.c,v 1.20 2023/03/11 14:14:54 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -58,7 +58,7 @@ #include -#include "bn_lcl.h" +#include "bn_local.h" BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w) @@ -87,7 +87,6 @@ BN_mod_word(const BIGNUM *a, BN_ULONG w) } #endif - bn_check_top(a); w &= BN_MASK2; for (i = a->top - 1; i >= 0; i--) { #ifndef BN_LLONG @@ -108,7 +107,6 @@ BN_div_word(BIGNUM *a, BN_ULONG w) BN_ULONG ret = 0; int i, j; - bn_check_top(a); w &= BN_MASK2; if (!w) @@ -127,14 +125,16 @@ BN_div_word(BIGNUM *a, BN_ULONG w) BN_ULONG l, d; l = a->d[i]; - d = bn_div_words(ret, l, w); - ret = (l - ((d*w)&BN_MASK2))&BN_MASK2; + bn_div_rem_words(ret, l, w, &d, &ret); a->d[i] = d; } if ((a->top > 0) && (a->d[a->top - 1] == 0)) a->top--; ret >>= j; - bn_check_top(a); + + /* Set negative again, to handle -0 case. */ + BN_set_negative(a, a->neg); + return (ret); } @@ -144,7 +144,6 @@ BN_add_word(BIGNUM *a, BN_ULONG w) BN_ULONG l; int i; - bn_check_top(a); w &= BN_MASK2; /* degenerate case: w is zero */ @@ -157,8 +156,7 @@ BN_add_word(BIGNUM *a, BN_ULONG w) if (a->neg) { a->neg = 0; i = BN_sub_word(a, w); - if (!BN_is_zero(a)) - a->neg=!(a->neg); + BN_set_negative(a, !a->neg); return (i); } for (i = 0; w != 0 && i < a->top; i++) { @@ -166,12 +164,11 @@ BN_add_word(BIGNUM *a, BN_ULONG w) w = (w > l) ? 1 : 0; } if (w && i == a->top) { - if (bn_wexpand(a, a->top + 1) == NULL) + if (!bn_wexpand(a, a->top + 1)) return 0; a->top++; a->d[i] = w; } - bn_check_top(a); return (1); } @@ -180,7 +177,6 @@ BN_sub_word(BIGNUM *a, BN_ULONG w) { int i; - bn_check_top(a); w &= BN_MASK2; /* degenerate case: w is zero */ @@ -197,13 +193,13 @@ BN_sub_word(BIGNUM *a, BN_ULONG w) if (a->neg) { a->neg = 0; i = BN_add_word(a, w); - a->neg = 1; + BN_set_negative(a, !a->neg); return (i); } if ((a->top == 1) && (a->d[0] < w)) { a->d[0] = w - a->d[0]; - a->neg = 1; + BN_set_negative(a, 1); return (1); } i = 0; @@ -219,7 +215,6 @@ BN_sub_word(BIGNUM *a, BN_ULONG w) } if ((a->d[i] == 0) && (i == (a->top - 1))) a->top--; - bn_check_top(a); return (1); } @@ -228,7 +223,6 @@ BN_mul_word(BIGNUM *a, BN_ULONG w) { BN_ULONG ll; - bn_check_top(a); w &= BN_MASK2; if (a->top) { if (w == 0) @@ -236,12 +230,11 @@ BN_mul_word(BIGNUM *a, BN_ULONG w) else { ll = bn_mul_words(a->d, a->d, a->top, w); if (ll) { - if (bn_wexpand(a, a->top + 1) == NULL) + if (!bn_wexpand(a, a->top + 1)) return (0); a->d[a->top++] = ll; } } } - bn_check_top(a); return (1); } diff --git a/crypto/bn/bn_x931p.c b/crypto/bn/bn_x931p.c index 7fc3b5c2..e73c416e 100644 --- a/crypto/bn/bn_x931p.c +++ b/crypto/bn/bn_x931p.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_x931p.c,v 1.13 2022/01/20 10:56:22 inoguchi Exp $ */ +/* $OpenBSD: bn_x931p.c,v 1.15 2022/12/26 07:18:51 jmc Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ @@ -59,7 +59,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" /* X9.31 routines for prime derivation */ @@ -80,7 +80,7 @@ bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx, BN_GENCB *cb) for (;;) { i++; BN_GENCB_call(cb, 0, i); - /* NB 27 MR is specificed in X9.31 */ + /* NB 27 MR is specified in X9.31 */ is_prime = BN_is_prime_fasttest_ex(pi, 27, ctx, 1, cb); if (is_prime < 0) return 0; @@ -205,8 +205,8 @@ BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, const BIGNUM *Xp, return ret; } -/* Generate pair of paramters Xp, Xq for X9.31 prime generation. - * Note: nbits paramter is sum of number of bits in both. +/* Generate pair of parameters Xp, Xq for X9.31 prime generation. + * Note: nbits parameter is sum of number of bits in both. */ int diff --git a/crypto/bn/gf2m-elf-x86_64.S b/crypto/bn/gf2m-elf-x86_64.S index c53a2c0d..aa28a7be 100644 --- a/crypto/bn/gf2m-elf-x86_64.S +++ b/crypto/bn/gf2m-elf-x86_64.S @@ -289,7 +289,6 @@ bn_GF2m_mul_2x2: retq .Lend_mul_2x2: .size bn_GF2m_mul_2x2,.-bn_GF2m_mul_2x2 -.byte 71,70,40,50,94,109,41,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 16 #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits diff --git a/crypto/bn/gf2m-macosx-x86_64.S b/crypto/bn/gf2m-macosx-x86_64.S index 693e1592..591afd89 100644 --- a/crypto/bn/gf2m-macosx-x86_64.S +++ b/crypto/bn/gf2m-macosx-x86_64.S @@ -289,5 +289,4 @@ L$body_mul_2x2: retq L$end_mul_2x2: -.byte 71,70,40,50,94,109,41,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 4 diff --git a/crypto/bn/gf2m-masm-x86_64.S b/crypto/bn/gf2m-masm-x86_64.S index a3ce027b..d8f1eed8 100644 --- a/crypto/bn/gf2m-masm-x86_64.S +++ b/crypto/bn/gf2m-masm-x86_64.S @@ -362,11 +362,6 @@ $L$body_mul_2x2:: DB 0F3h,0C3h ;repret $L$end_mul_2x2:: bn_GF2m_mul_2x2 ENDP -DB 71,70,40,50,94,109,41,32,77,117,108,116,105,112,108,105 -DB 99,97,116,105,111,110,32,102,111,114,32,120,56,54,95,54 -DB 52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121 -DB 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46 -DB 111,114,103,62,0 ALIGN 16 EXTERN __imp_RtlVirtualUnwind:NEAR diff --git a/crypto/bn/mont-elf-x86_64.S b/crypto/bn/mont-elf-x86_64.S index 35765456..668bd30e 100644 --- a/crypto/bn/mont-elf-x86_64.S +++ b/crypto/bn/mont-elf-x86_64.S @@ -1371,8 +1371,6 @@ bn_sqr4x_mont: .Lsqr4x_epilogue: retq .size bn_sqr4x_mont,.-bn_sqr4x_mont -.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 -.align 16 #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/bn/mont-macosx-x86_64.S b/crypto/bn/mont-macosx-x86_64.S index 7de69d90..cce67ae4 100644 --- a/crypto/bn/mont-macosx-x86_64.S +++ b/crypto/bn/mont-macosx-x86_64.S @@ -1371,5 +1371,3 @@ L$sqr4x_copy: L$sqr4x_epilogue: retq -.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 -.p2align 4 diff --git a/crypto/bn/mont-masm-x86_64.S b/crypto/bn/mont-masm-x86_64.S index 4896acd1..a34b77b4 100644 --- a/crypto/bn/mont-masm-x86_64.S +++ b/crypto/bn/mont-masm-x86_64.S @@ -1484,12 +1484,6 @@ $L$sqr4x_epilogue:: DB 0F3h,0C3h ;repret $L$SEH_end_bn_sqr4x_mont:: bn_sqr4x_mont ENDP -DB 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105 -DB 112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56 -DB 54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83 -DB 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115 -DB 115,108,46,111,114,103,62,0 -ALIGN 16 .text$ ENDS END diff --git a/crypto/bn/mont-mips.S b/crypto/bn/mont-mips.S new file mode 100644 index 00000000..65f7b226 --- /dev/null +++ b/crypto/bn/mont-mips.S @@ -0,0 +1,287 @@ +.text + +.set noat +.set noreorder + +.align 5 +.globl bn_mul_mont +.ent bn_mul_mont +bn_mul_mont: + lw $8,16($29) + lw $9,20($29) + slt $1,$9,4 + bnez $1,1f + li $2,0 + slt $1,$9,17 # on in-order CPU + bnez $1,bn_mul_mont_internal + nop +1: jr $31 + li $4,0 +.end bn_mul_mont + +.align 5 +.ent bn_mul_mont_internal +bn_mul_mont_internal: + .frame $30,14*4,$31 + .mask 0x40000000|16711680,-4 + sub $29,14*4 + sw $30,(14-1)*4($29) + sw $23,(14-2)*4($29) + sw $22,(14-3)*4($29) + sw $21,(14-4)*4($29) + sw $20,(14-5)*4($29) + sw $19,(14-6)*4($29) + sw $18,(14-7)*4($29) + sw $17,(14-8)*4($29) + sw $16,(14-9)*4($29) + move $30,$29 + + .set reorder + lw $8,0($8) + lw $13,0($6) # bp[0] + lw $12,0($5) # ap[0] + lw $14,0($7) # np[0] + + sub $29,2*4 # place for two extra words + sll $9,2 + li $1,-4096 + sub $29,$9 + and $29,$1 + + multu $12,$13 + lw $16,4($5) + lw $18,4($7) + mflo $10 + mfhi $11 + multu $10,$8 + mflo $23 + + multu $16,$13 + mflo $16 + mfhi $17 + + multu $14,$23 + mflo $24 + mfhi $25 + multu $18,$23 + addu $24,$10 + sltu $1,$24,$10 + addu $25,$1 + mflo $18 + mfhi $19 + + move $15,$29 + li $22,2*4 +.align 4 +.L1st: + .set noreorder + add $12,$5,$22 + add $14,$7,$22 + lw $12,($12) + lw $14,($14) + + multu $12,$13 + addu $10,$16,$11 + addu $24,$18,$25 + sltu $1,$10,$11 + sltu $2,$24,$25 + addu $11,$17,$1 + addu $25,$19,$2 + mflo $16 + mfhi $17 + + addu $24,$10 + sltu $1,$24,$10 + multu $14,$23 + addu $25,$1 + addu $22,4 + sw $24,($15) + sltu $2,$22,$9 + mflo $18 + mfhi $19 + + bnez $2,.L1st + add $15,4 + .set reorder + + addu $10,$16,$11 + sltu $1,$10,$11 + addu $11,$17,$1 + + addu $24,$18,$25 + sltu $2,$24,$25 + addu $25,$19,$2 + addu $24,$10 + sltu $1,$24,$10 + addu $25,$1 + + sw $24,($15) + + addu $25,$11 + sltu $1,$25,$11 + sw $25,4($15) + sw $1,2*4($15) + + li $21,4 +.align 4 +.Louter: + add $13,$6,$21 + lw $13,($13) + lw $12,($5) + lw $16,4($5) + lw $20,($29) + + multu $12,$13 + lw $14,($7) + lw $18,4($7) + mflo $10 + mfhi $11 + addu $10,$20 + multu $10,$8 + sltu $1,$10,$20 + addu $11,$1 + mflo $23 + + multu $16,$13 + mflo $16 + mfhi $17 + + multu $14,$23 + mflo $24 + mfhi $25 + + multu $18,$23 + addu $24,$10 + sltu $1,$24,$10 + addu $25,$1 + mflo $18 + mfhi $19 + + move $15,$29 + li $22,2*4 + lw $20,4($15) +.align 4 +.Linner: + .set noreorder + add $12,$5,$22 + add $14,$7,$22 + lw $12,($12) + lw $14,($14) + + multu $12,$13 + addu $10,$16,$11 + addu $24,$18,$25 + sltu $1,$10,$11 + sltu $2,$24,$25 + addu $11,$17,$1 + addu $25,$19,$2 + mflo $16 + mfhi $17 + + addu $10,$20 + addu $22,4 + multu $14,$23 + sltu $1,$10,$20 + addu $24,$10 + addu $11,$1 + sltu $2,$24,$10 + lw $20,2*4($15) + addu $25,$2 + sltu $1,$22,$9 + mflo $18 + mfhi $19 + sw $24,($15) + bnez $1,.Linner + add $15,4 + .set reorder + + addu $10,$16,$11 + sltu $1,$10,$11 + addu $11,$17,$1 + addu $10,$20 + sltu $2,$10,$20 + addu $11,$2 + + lw $20,2*4($15) + addu $24,$18,$25 + sltu $1,$24,$25 + addu $25,$19,$1 + addu $24,$10 + sltu $2,$24,$10 + addu $25,$2 + sw $24,($15) + + addu $24,$25,$11 + sltu $25,$24,$11 + addu $24,$20 + sltu $1,$24,$20 + addu $25,$1 + sw $24,4($15) + sw $25,2*4($15) + + addu $21,4 + sltu $2,$21,$9 + bnez $2,.Louter + + .set noreorder + add $20,$29,$9 # &tp[num] + move $15,$29 + move $5,$29 + li $11,0 # clear borrow bit + +.align 4 +.Lsub: lw $10,($15) + lw $24,($7) + add $15,4 + add $7,4 + subu $24,$10,$24 # tp[i]-np[i] + sgtu $1,$24,$10 + subu $10,$24,$11 + sgtu $11,$10,$24 + sw $10,($4) + or $11,$1 + sltu $1,$15,$20 + bnez $1,.Lsub + add $4,4 + + subu $11,$25,$11 # handle upmost overflow bit + move $15,$29 + sub $4,$9 # restore rp + not $25,$11 + + and $5,$11,$29 + and $6,$25,$4 + or $5,$5,$6 # ap=borrow?tp:rp + +.align 4 +.Lcopy: lw $12,($5) + add $5,4 + sw $0,($15) + add $15,4 + sltu $1,$15,$20 + sw $12,($4) + bnez $1,.Lcopy + add $4,4 + + li $4,1 + li $2,1 + + .set noreorder + move $29,$30 + lw $30,(14-1)*4($29) + lw $23,(14-2)*4($29) + lw $22,(14-3)*4($29) + lw $21,(14-4)*4($29) + lw $20,(14-5)*4($29) + lw $19,(14-6)*4($29) + lw $18,(14-7)*4($29) + lw $17,(14-8)*4($29) + lw $16,(14-9)*4($29) + jr $31 + add $29,14*4 +.end bn_mul_mont_internal +.rdata +.asciiz "Montgomery Multiplication for MIPS, CRYPTOGAMS by " +#if defined(HAVE_GNU_STACK) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/bn/mont5-elf-x86_64.S b/crypto/bn/mont5-elf-x86_64.S index 48cc771e..95000d47 100644 --- a/crypto/bn/mont5-elf-x86_64.S +++ b/crypto/bn/mont5-elf-x86_64.S @@ -1167,11 +1167,12 @@ bn_gather5: retq .LSEH_end_bn_gather5: .size bn_gather5,.-bn_gather5 +.section .rodata .align 64 .Linc: .long 0,0, 1,1 .long 2,2, 2,2 -.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,119,105,116,104,32,115,99,97,116,116,101,114,47,103,97,116,104,101,114,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/bn/mont5-macosx-x86_64.S b/crypto/bn/mont5-macosx-x86_64.S index 039229fd..6dcd5ca1 100644 --- a/crypto/bn/mont5-macosx-x86_64.S +++ b/crypto/bn/mont5-macosx-x86_64.S @@ -1167,8 +1167,9 @@ L$gather: retq L$SEH_end_bn_gather5: +.section __DATA,__const .p2align 6 L$inc: .long 0,0, 1,1 .long 2,2, 2,2 -.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,119,105,116,104,32,115,99,97,116,116,101,114,47,103,97,116,104,101,114,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text diff --git a/crypto/bn/mont5-masm-x86_64.S b/crypto/bn/mont5-masm-x86_64.S index cc709e67..54d87c14 100644 --- a/crypto/bn/mont5-masm-x86_64.S +++ b/crypto/bn/mont5-masm-x86_64.S @@ -1265,16 +1265,14 @@ $L$gather:: DB 0F3h,0C3h ;repret $L$SEH_end_bn_gather5:: bn_gather5 ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 $L$inc:: DD 0,0,1,1 DD 2,2,2,2 -DB 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105 -DB 112,108,105,99,97,116,105,111,110,32,119,105,116,104,32,115 -DB 99,97,116,116,101,114,47,103,97,116,104,101,114,32,102,111 -DB 114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79 -DB 71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111 -DB 112,101,110,115,115,108,46,111,114,103,62,0 +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 diff --git a/crypto/bn/s2n_bignum.h b/crypto/bn/s2n_bignum.h new file mode 100644 index 00000000..ce6e8cdc --- /dev/null +++ b/crypto/bn/s2n_bignum.h @@ -0,0 +1,856 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// ---------------------------------------------------------------------------- +// C prototypes for s2n-bignum functions, so you can use them in C programs via +// +// #include "s2n-bignum.h" +// +// The functions are listed in alphabetical order with a brief description +// in comments for each one. For more detailed documentation see the comment +// banner at the top of the corresponding assembly (.S) file, and +// for the last word in what properties it satisfies see the spec in the +// formal proof (the .ml file in the architecture-specific directory). +// +// For some functions there are additional variants with names ending in +// "_alt". These have the same core mathematical functionality as their +// non-"alt" versions, but can be better suited to some microarchitectures: +// +// - On x86, the "_alt" forms avoid BMI and ADX instruction set +// extensions, so will run on any x86_64 machine, even older ones +// +// - On ARM, the "_alt" forms target machines with higher multiplier +// throughput, generally offering higher performance there. +// ---------------------------------------------------------------------------- + +// Add, z := x + y +// Inputs x[m], y[n]; outputs function return (carry-out) and z[p] +extern uint64_t bignum_add (uint64_t p, uint64_t *z, uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); + +// Add modulo p_25519, z := (x + y) mod p_25519, assuming x and y reduced +// Inputs x[4], y[4]; output z[4] +extern void bignum_add_p25519 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); + +// Add modulo p_256, z := (x + y) mod p_256, assuming x and y reduced +// Inputs x[4], y[4]; output z[4] +extern void bignum_add_p256 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); + +// Add modulo p_256k1, z := (x + y) mod p_256k1, assuming x and y reduced +// Inputs x[4], y[4]; output z[4] +extern void bignum_add_p256k1 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); + +// Add modulo p_384, z := (x + y) mod p_384, assuming x and y reduced +// Inputs x[6], y[6]; output z[6] +extern void bignum_add_p384 (uint64_t z[static 6], uint64_t x[static 6], uint64_t y[static 6]); + +// Add modulo p_521, z := (x + y) mod p_521, assuming x and y reduced +// Inputs x[9], y[9]; output z[9] +extern void bignum_add_p521 (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); + +// Compute "amontification" constant z :== 2^{128k} (congruent mod m) +// Input m[k]; output z[k]; temporary buffer t[>=k] +extern void bignum_amontifier (uint64_t k, uint64_t *z, uint64_t *m, uint64_t *t); + +// Almost-Montgomery multiply, z :== (x * y / 2^{64k}) (congruent mod m) +// Inputs x[k], y[k], m[k]; output z[k] +extern void bignum_amontmul (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *y, uint64_t *m); + +// Almost-Montgomery reduce, z :== (x' / 2^{64p}) (congruent mod m) +// Inputs x[n], m[k], p; output z[k] +extern void bignum_amontredc (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t *m, uint64_t p); + +// Almost-Montgomery square, z :== (x^2 / 2^{64k}) (congruent mod m) +// Inputs x[k], m[k]; output z[k] +extern void bignum_amontsqr (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *m); + +// Convert 4-digit (256-bit) bignum to/from big-endian form +// Input x[4]; output z[4] +extern void bignum_bigendian_4 (uint64_t z[static 4], uint64_t x[static 4]); + +// Convert 6-digit (384-bit) bignum to/from big-endian form +// Input x[6]; output z[6] +extern void bignum_bigendian_6 (uint64_t z[static 6], uint64_t x[static 6]); + +// Select bitfield starting at bit n with length l <= 64 +// Inputs x[k], n, l; output function return +extern uint64_t bignum_bitfield (uint64_t k, uint64_t *x, uint64_t n, uint64_t l); + +// Return size of bignum in bits +// Input x[k]; output function return +extern uint64_t bignum_bitsize (uint64_t k, uint64_t *x); + +// Divide by a single (nonzero) word, z := x / m and return x mod m +// Inputs x[n], m; outputs function return (remainder) and z[k] +extern uint64_t bignum_cdiv (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t m); + +// Divide by a single word, z := x / m when known to be exact +// Inputs x[n], m; output z[k] +extern void bignum_cdiv_exact (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t m); + +// Count leading zero digits (64-bit words) +// Input x[k]; output function return +extern uint64_t bignum_cld (uint64_t k, uint64_t *x); + +// Count leading zero bits +// Input x[k]; output function return +extern uint64_t bignum_clz (uint64_t k, uint64_t *x); + +// Multiply-add with single-word multiplier, z := z + c * y +// Inputs c, y[n]; outputs function return (carry-out) and z[k] +extern uint64_t bignum_cmadd (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, uint64_t *y); + +// Negated multiply-add with single-word multiplier, z := z - c * y +// Inputs c, y[n]; outputs function return (negative carry-out) and z[k] +extern uint64_t bignum_cmnegadd (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, uint64_t *y); + +// Find modulus of bignum w.r.t. single nonzero word m, returning x mod m +// Input x[k], m; output function return +extern uint64_t bignum_cmod (uint64_t k, uint64_t *x, uint64_t m); + +// Multiply by a single word, z := c * y +// Inputs c, y[n]; outputs function return (carry-out) and z[k] +extern uint64_t bignum_cmul (uint64_t k, uint64_t *z, uint64_t c, uint64_t n, uint64_t *y); + +// Multiply by a single word modulo p_25519, z := (c * x) mod p_25519, assuming x reduced +// Inputs c, x[4]; output z[4] +extern void bignum_cmul_p25519 (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); +extern void bignum_cmul_p25519_alt (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); + +// Multiply by a single word modulo p_256, z := (c * x) mod p_256, assuming x reduced +// Inputs c, x[4]; output z[4] +extern void bignum_cmul_p256 (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); +extern void bignum_cmul_p256_alt (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); + +// Multiply by a single word modulo p_256k1, z := (c * x) mod p_256k1, assuming x reduced +// Inputs c, x[4]; output z[4] +extern void bignum_cmul_p256k1 (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); +extern void bignum_cmul_p256k1_alt (uint64_t z[static 4], uint64_t c, uint64_t x[static 4]); + +// Multiply by a single word modulo p_384, z := (c * x) mod p_384, assuming x reduced +// Inputs c, x[6]; output z[6] +extern void bignum_cmul_p384 (uint64_t z[static 6], uint64_t c, uint64_t x[static 6]); +extern void bignum_cmul_p384_alt (uint64_t z[static 6], uint64_t c, uint64_t x[static 6]); + +// Multiply by a single word modulo p_521, z := (c * x) mod p_521, assuming x reduced +// Inputs c, x[9]; output z[9] +extern void bignum_cmul_p521 (uint64_t z[static 9], uint64_t c, uint64_t x[static 9]); +extern void bignum_cmul_p521_alt (uint64_t z[static 9], uint64_t c, uint64_t x[static 9]); + +// Test bignums for coprimality, gcd(x,y) = 1 +// Inputs x[m], y[n]; output function return; temporary buffer t[>=2*max(m,n)] +extern uint64_t bignum_coprime (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y, uint64_t *t); + +// Copy bignum with zero-extension or truncation, z := x +// Input x[n]; output z[k] +extern void bignum_copy (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x); + +// Count trailing zero digits (64-bit words) +// Input x[k]; output function return +extern uint64_t bignum_ctd (uint64_t k, uint64_t *x); + +// Count trailing zero bits +// Input x[k]; output function return +extern uint64_t bignum_ctz (uint64_t k, uint64_t *x); + +// Convert from almost-Montgomery form, z := (x / 2^256) mod p_256 +// Input x[4]; output z[4] +extern void bignum_deamont_p256 (uint64_t z[static 4], uint64_t x[static 4]); +extern void bignum_deamont_p256_alt (uint64_t z[static 4], uint64_t x[static 4]); + +// Convert from almost-Montgomery form, z := (x / 2^256) mod p_256k1 +// Input x[4]; output z[4] +extern void bignum_deamont_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); + +// Convert from almost-Montgomery form, z := (x / 2^384) mod p_384 +// Input x[6]; output z[6] +extern void bignum_deamont_p384 (uint64_t z[static 6], uint64_t x[static 6]); +extern void bignum_deamont_p384_alt (uint64_t z[static 6], uint64_t x[static 6]); + +// Convert from almost-Montgomery form z := (x / 2^576) mod p_521 +// Input x[9]; output z[9] +extern void bignum_deamont_p521 (uint64_t z[static 9], uint64_t x[static 9]); + +// Convert from (almost-)Montgomery form z := (x / 2^{64k}) mod m +// Inputs x[k], m[k]; output z[k] +extern void bignum_demont (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *m); + +// Convert from Montgomery form z := (x / 2^256) mod p_256, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_demont_p256 (uint64_t z[static 4], uint64_t x[static 4]); +extern void bignum_demont_p256_alt (uint64_t z[static 4], uint64_t x[static 4]); + +// Convert from Montgomery form z := (x / 2^256) mod p_256k1, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_demont_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); + +// Convert from Montgomery form z := (x / 2^384) mod p_384, assuming x reduced +// Input x[6]; output z[6] +extern void bignum_demont_p384 (uint64_t z[static 6], uint64_t x[static 6]); +extern void bignum_demont_p384_alt (uint64_t z[static 6], uint64_t x[static 6]); + +// Convert from Montgomery form z := (x / 2^576) mod p_521, assuming x reduced +// Input x[9]; output z[9] +extern void bignum_demont_p521 (uint64_t z[static 9], uint64_t x[static 9]); + +// Select digit x[n] +// Inputs x[k], n; output function return +extern uint64_t bignum_digit (uint64_t k, uint64_t *x, uint64_t n); + +// Return size of bignum in digits (64-bit word) +// Input x[k]; output function return +extern uint64_t bignum_digitsize (uint64_t k, uint64_t *x); + +// Divide bignum by 10: z' := z div 10, returning remainder z mod 10 +// Inputs z[k]; outputs function return (remainder) and z[k] +extern uint64_t bignum_divmod10 (uint64_t k, uint64_t *z); + +// Double modulo p_25519, z := (2 * x) mod p_25519, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_double_p25519 (uint64_t z[static 4], uint64_t x[static 4]); + +// Double modulo p_256, z := (2 * x) mod p_256, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_double_p256 (uint64_t z[static 4], uint64_t x[static 4]); + +// Double modulo p_256k1, z := (2 * x) mod p_256k1, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_double_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); + +// Double modulo p_384, z := (2 * x) mod p_384, assuming x reduced +// Input x[6]; output z[6] +extern void bignum_double_p384 (uint64_t z[static 6], uint64_t x[static 6]); + +// Double modulo p_521, z := (2 * x) mod p_521, assuming x reduced +// Input x[9]; output z[9] +extern void bignum_double_p521 (uint64_t z[static 9], uint64_t x[static 9]); + +// Extended Montgomery reduce, returning results in input-output buffer +// Inputs z[2*k], m[k], w; outputs function return (extra result bit) and z[2*k] +extern uint64_t bignum_emontredc (uint64_t k, uint64_t *z, uint64_t *m, uint64_t w); + +// Extended Montgomery reduce in 8-digit blocks, results in input-output buffer +// Inputs z[2*k], m[k], w; outputs function return (extra result bit) and z[2*k] +extern uint64_t bignum_emontredc_8n (uint64_t k, uint64_t *z, uint64_t *m, uint64_t w); + +// Test bignums for equality, x = y +// Inputs x[m], y[n]; output function return +extern uint64_t bignum_eq (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); + +// Test bignum for even-ness +// Input x[k]; output function return +extern uint64_t bignum_even (uint64_t k, uint64_t *x); + +// Convert 4-digit (256-bit) bignum from big-endian bytes +// Input x[32] (bytes); output z[4] +extern void bignum_frombebytes_4 (uint64_t z[static 4], uint8_t x[static 32]); + +// Convert 6-digit (384-bit) bignum from big-endian bytes +// Input x[48] (bytes); output z[6] +extern void bignum_frombebytes_6 (uint64_t z[static 6], uint8_t x[static 48]); + +// Convert 4-digit (256-bit) bignum from little-endian bytes +// Input x[32] (bytes); output z[4] +extern void bignum_fromlebytes_4 (uint64_t z[static 4], uint8_t x[static 32]); + +// Convert 6-digit (384-bit) bignum from little-endian bytes +// Input x[48] (bytes); output z[6] +extern void bignum_fromlebytes_6 (uint64_t z[static 6], uint8_t x[static 48]); + +// Convert little-endian bytes to 9-digit 528-bit bignum +// Input x[66] (bytes); output z[9] +extern void bignum_fromlebytes_p521 (uint64_t z[static 9],uint8_t x[static 66]); + +// Compare bignums, x >= y +// Inputs x[m], y[n]; output function return +extern uint64_t bignum_ge (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); + +// Compare bignums, x > y +// Inputs x[m], y[n]; output function return +extern uint64_t bignum_gt (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); + +// Halve modulo p_256, z := (x / 2) mod p_256, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_half_p256 (uint64_t z[static 4], uint64_t x[static 4]); + +// Halve modulo p_256k1, z := (x / 2) mod p_256k1, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_half_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); + +// Halve modulo p_384, z := (x / 2) mod p_384, assuming x reduced +// Input x[6]; output z[6] +extern void bignum_half_p384 (uint64_t z[static 6], uint64_t x[static 6]); + +// Halve modulo p_521, z := (x / 2) mod p_521, assuming x reduced +// Input x[9]; output z[9] +extern void bignum_half_p521 (uint64_t z[static 9], uint64_t x[static 9]); + +// Test bignum for zero-ness, x = 0 +// Input x[k]; output function return +extern uint64_t bignum_iszero (uint64_t k, uint64_t *x); + +// Multiply z := x * y +// Inputs x[16], y[16]; output z[32]; temporary buffer t[>=32] +extern void bignum_kmul_16_32 (uint64_t z[static 32], uint64_t x[static 16], uint64_t y[static 16], uint64_t t[static 32]); + +// Multiply z := x * y +// Inputs x[32], y[32]; output z[64]; temporary buffer t[>=96] +extern void bignum_kmul_32_64 (uint64_t z[static 64], uint64_t x[static 32], uint64_t y[static 32], uint64_t t[static 96]); + +// Square, z := x^2 +// Input x[16]; output z[32]; temporary buffer t[>=24] +extern void bignum_ksqr_16_32 (uint64_t z[static 32], uint64_t x[static 16], uint64_t t[static 24]); + +// Square, z := x^2 +// Input x[32]; output z[64]; temporary buffer t[>=72] +extern void bignum_ksqr_32_64 (uint64_t z[static 64], uint64_t x[static 32], uint64_t t[static 72]); + +// Compare bignums, x <= y +// Inputs x[m], y[n]; output function return +extern uint64_t bignum_le (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); + +// Convert 4-digit (256-bit) bignum to/from little-endian form +// Input x[4]; output z[4] +extern void bignum_littleendian_4 (uint64_t z[static 4], uint64_t x[static 4]); + +// Convert 6-digit (384-bit) bignum to/from little-endian form +// Input x[6]; output z[6] +extern void bignum_littleendian_6 (uint64_t z[static 6], uint64_t x[static 6]); + +// Compare bignums, x < y +// Inputs x[m], y[n]; output function return +extern uint64_t bignum_lt (uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); + +// Multiply-add, z := z + x * y +// Inputs x[m], y[n]; outputs function return (carry-out) and z[k] +extern uint64_t bignum_madd (uint64_t k, uint64_t *z, uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); + +// Reduce modulo group order, z := x mod n_256 +// Input x[k]; output z[4] +extern void bignum_mod_n256 (uint64_t z[static 4], uint64_t k, uint64_t *x); +extern void bignum_mod_n256_alt (uint64_t z[static 4], uint64_t k, uint64_t *x); + +// Reduce modulo group order, z := x mod n_256 +// Input x[4]; output z[4] +extern void bignum_mod_n256_4 (uint64_t z[static 4], uint64_t x[static 4]); + +// Reduce modulo group order, z := x mod n_256k1 +// Input x[4]; output z[4] +extern void bignum_mod_n256k1_4 (uint64_t z[static 4], uint64_t x[static 4]); + +// Reduce modulo group order, z := x mod n_384 +// Input x[k]; output z[6] +extern void bignum_mod_n384 (uint64_t z[static 6], uint64_t k, uint64_t *x); +extern void bignum_mod_n384_alt (uint64_t z[static 6], uint64_t k, uint64_t *x); + +// Reduce modulo group order, z := x mod n_384 +// Input x[6]; output z[6] +extern void bignum_mod_n384_6 (uint64_t z[static 6], uint64_t x[static 6]); + +// Reduce modulo group order, z := x mod n_521 +// Input x[9]; output z[9] +extern void bignum_mod_n521_9 (uint64_t z[static 9], uint64_t x[static 9]); +extern void bignum_mod_n521_9_alt (uint64_t z[static 9], uint64_t x[static 9]); + +// Reduce modulo field characteristic, z := x mod p_25519 +// Input x[4]; output z[4] +extern void bignum_mod_p25519_4 (uint64_t z[static 4], uint64_t x[static 4]); + +// Reduce modulo field characteristic, z := x mod p_256 +// Input x[k]; output z[4] +extern void bignum_mod_p256 (uint64_t z[static 4], uint64_t k, uint64_t *x); +extern void bignum_mod_p256_alt (uint64_t z[static 4], uint64_t k, uint64_t *x); + +// Reduce modulo field characteristic, z := x mod p_256 +// Input x[4]; output z[4] +extern void bignum_mod_p256_4 (uint64_t z[static 4], uint64_t x[static 4]); + +// Reduce modulo field characteristic, z := x mod p_256k1 +// Input x[4]; output z[4] +extern void bignum_mod_p256k1_4 (uint64_t z[static 4], uint64_t x[static 4]); + +// Reduce modulo field characteristic, z := x mod p_384 +// Input x[k]; output z[6] +extern void bignum_mod_p384 (uint64_t z[static 6], uint64_t k, uint64_t *x); +extern void bignum_mod_p384_alt (uint64_t z[static 6], uint64_t k, uint64_t *x); + +// Reduce modulo field characteristic, z := x mod p_384 +// Input x[6]; output z[6] +extern void bignum_mod_p384_6 (uint64_t z[static 6], uint64_t x[static 6]); + +// Reduce modulo field characteristic, z := x mod p_521 +// Input x[9]; output z[9] +extern void bignum_mod_p521_9 (uint64_t z[static 9], uint64_t x[static 9]); + +// Add modulo m, z := (x + y) mod m, assuming x and y reduced +// Inputs x[k], y[k], m[k]; output z[k] +extern void bignum_modadd (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *y, uint64_t *m); + +// Double modulo m, z := (2 * x) mod m, assuming x reduced +// Inputs x[k], m[k]; output z[k] +extern void bignum_moddouble (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *m); + +// Compute "modification" constant z := 2^{64k} mod m +// Input m[k]; output z[k]; temporary buffer t[>=k] +extern void bignum_modifier (uint64_t k, uint64_t *z, uint64_t *m, uint64_t *t); + +// Invert modulo m, z = (1/a) mod b, assuming b is an odd number > 1, a coprime to b +// Inputs a[k], b[k]; output z[k]; temporary buffer t[>=3*k] +extern void bignum_modinv (uint64_t k, uint64_t *z, uint64_t *a, uint64_t *b, uint64_t *t); + +// Optionally negate modulo m, z := (-x) mod m (if p nonzero) or z := x (if p zero), assuming x reduced +// Inputs p, x[k], m[k]; output z[k] +extern void bignum_modoptneg (uint64_t k, uint64_t *z, uint64_t p, uint64_t *x, uint64_t *m); + +// Subtract modulo m, z := (x - y) mod m, assuming x and y reduced +// Inputs x[k], y[k], m[k]; output z[k] +extern void bignum_modsub (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *y, uint64_t *m); + +// Compute "montification" constant z := 2^{128k} mod m +// Input m[k]; output z[k]; temporary buffer t[>=k] +extern void bignum_montifier (uint64_t k, uint64_t *z, uint64_t *m, uint64_t *t); + +// Montgomery multiply, z := (x * y / 2^{64k}) mod m +// Inputs x[k], y[k], m[k]; output z[k] +extern void bignum_montmul (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *y, uint64_t *m); + +// Montgomery multiply, z := (x * y / 2^256) mod p_256 +// Inputs x[4], y[4]; output z[4] +extern void bignum_montmul_p256 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); +extern void bignum_montmul_p256_alt (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); + +// Montgomery multiply, z := (x * y / 2^256) mod p_256k1 +// Inputs x[4], y[4]; output z[4] +extern void bignum_montmul_p256k1 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); +extern void bignum_montmul_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); + +// Montgomery multiply, z := (x * y / 2^384) mod p_384 +// Inputs x[6], y[6]; output z[6] +extern void bignum_montmul_p384 (uint64_t z[static 6], uint64_t x[static 6], uint64_t y[static 6]); +extern void bignum_montmul_p384_alt (uint64_t z[static 6], uint64_t x[static 6], uint64_t y[static 6]); + +// Montgomery multiply, z := (x * y / 2^576) mod p_521 +// Inputs x[9], y[9]; output z[9] +extern void bignum_montmul_p521 (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); +extern void bignum_montmul_p521_alt (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); + +// Montgomery reduce, z := (x' / 2^{64p}) MOD m +// Inputs x[n], m[k], p; output z[k] +extern void bignum_montredc (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t *m, uint64_t p); + +// Montgomery square, z := (x^2 / 2^{64k}) mod m +// Inputs x[k], m[k]; output z[k] +extern void bignum_montsqr (uint64_t k, uint64_t *z, uint64_t *x, uint64_t *m); + +// Montgomery square, z := (x^2 / 2^256) mod p_256 +// Input x[4]; output z[4] +extern void bignum_montsqr_p256 (uint64_t z[static 4], uint64_t x[static 4]); +extern void bignum_montsqr_p256_alt (uint64_t z[static 4], uint64_t x[static 4]); + +// Montgomery square, z := (x^2 / 2^256) mod p_256k1 +// Input x[4]; output z[4] +extern void bignum_montsqr_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); +extern void bignum_montsqr_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4]); + +// Montgomery square, z := (x^2 / 2^384) mod p_384 +// Input x[6]; output z[6] +extern void bignum_montsqr_p384 (uint64_t z[static 6], uint64_t x[static 6]); +extern void bignum_montsqr_p384_alt (uint64_t z[static 6], uint64_t x[static 6]); + +// Montgomery square, z := (x^2 / 2^576) mod p_521 +// Input x[9]; output z[9] +extern void bignum_montsqr_p521 (uint64_t z[static 9], uint64_t x[static 9]); +extern void bignum_montsqr_p521_alt (uint64_t z[static 9], uint64_t x[static 9]); + +// Multiply z := x * y +// Inputs x[m], y[n]; output z[k] +extern void bignum_mul (uint64_t k, uint64_t *z, uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); + +// Multiply z := x * y +// Inputs x[4], y[4]; output z[8] +extern void bignum_mul_4_8 (uint64_t z[static 8], uint64_t x[static 4], uint64_t y[static 4]); +extern void bignum_mul_4_8_alt (uint64_t z[static 8], uint64_t x[static 4], uint64_t y[static 4]); + +// Multiply z := x * y +// Inputs x[6], y[6]; output z[12] +extern void bignum_mul_6_12 (uint64_t z[static 12], uint64_t x[static 6], uint64_t y[static 6]); +extern void bignum_mul_6_12_alt (uint64_t z[static 12], uint64_t x[static 6], uint64_t y[static 6]); + +// Multiply z := x * y +// Inputs x[8], y[8]; output z[16] +extern void bignum_mul_8_16 (uint64_t z[static 16], uint64_t x[static 8], uint64_t y[static 8]); +extern void bignum_mul_8_16_alt (uint64_t z[static 16], uint64_t x[static 8], uint64_t y[static 8]); + +// Multiply modulo p_25519, z := (x * y) mod p_25519 +// Inputs x[4], y[4]; output z[4] +extern void bignum_mul_p25519 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); +extern void bignum_mul_p25519_alt (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); + +// Multiply modulo p_256k1, z := (x * y) mod p_256k1 +// Inputs x[4], y[4]; output z[4] +extern void bignum_mul_p256k1 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); +extern void bignum_mul_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); + +// Multiply modulo p_521, z := (x * y) mod p_521, assuming x and y reduced +// Inputs x[9], y[9]; output z[9] +extern void bignum_mul_p521 (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); +extern void bignum_mul_p521_alt (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); + +// Multiply bignum by 10 and add word: z := 10 * z + d +// Inputs z[k], d; outputs function return (carry) and z[k] +extern uint64_t bignum_muladd10 (uint64_t k, uint64_t *z, uint64_t d); + +// Multiplex/select z := x (if p nonzero) or z := y (if p zero) +// Inputs p, x[k], y[k]; output z[k] +extern void bignum_mux (uint64_t p, uint64_t k, uint64_t *z, uint64_t *x, uint64_t *y); + +// 256-bit multiplex/select z := x (if p nonzero) or z := y (if p zero) +// Inputs p, x[4], y[4]; output z[4] +extern void bignum_mux_4 (uint64_t p, uint64_t z[static 4],uint64_t x[static 4], uint64_t y[static 4]); + +// 384-bit multiplex/select z := x (if p nonzero) or z := y (if p zero) +// Inputs p, x[6], y[6]; output z[6] +extern void bignum_mux_6 (uint64_t p, uint64_t z[static 6],uint64_t x[static 6], uint64_t y[static 6]); + +// Select element from 16-element table, z := xs[k*i] +// Inputs xs[16*k], i; output z[k] +extern void bignum_mux16 (uint64_t k, uint64_t *z, uint64_t *xs, uint64_t i); + +// Negate modulo p_25519, z := (-x) mod p_25519, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_neg_p25519 (uint64_t z[static 4], uint64_t x[static 4]); + +// Negate modulo p_256, z := (-x) mod p_256, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_neg_p256 (uint64_t z[static 4], uint64_t x[static 4]); + +// Negate modulo p_256k1, z := (-x) mod p_256k1, assuming x reduced +// Input x[4]; output z[4] +extern void bignum_neg_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); + +// Negate modulo p_384, z := (-x) mod p_384, assuming x reduced +// Input x[6]; output z[6] +extern void bignum_neg_p384 (uint64_t z[static 6], uint64_t x[static 6]); + +// Negate modulo p_521, z := (-x) mod p_521, assuming x reduced +// Input x[9]; output z[9] +extern void bignum_neg_p521 (uint64_t z[static 9], uint64_t x[static 9]); + +// Negated modular inverse, z := (-1/x) mod 2^{64k} +// Input x[k]; output z[k] +extern void bignum_negmodinv (uint64_t k, uint64_t *z, uint64_t *x); + +// Test bignum for nonzero-ness x =/= 0 +// Input x[k]; output function return +extern uint64_t bignum_nonzero (uint64_t k, uint64_t *x); + +// Test 256-bit bignum for nonzero-ness x =/= 0 +// Input x[4]; output function return +extern uint64_t bignum_nonzero_4(uint64_t x[static 4]); + +// Test 384-bit bignum for nonzero-ness x =/= 0 +// Input x[6]; output function return +extern uint64_t bignum_nonzero_6(uint64_t x[static 6]); + +// Normalize bignum in-place by shifting left till top bit is 1 +// Input z[k]; outputs function return (bits shifted left) and z[k] +extern uint64_t bignum_normalize (uint64_t k, uint64_t *z); + +// Test bignum for odd-ness +// Input x[k]; output function return +extern uint64_t bignum_odd (uint64_t k, uint64_t *x); + +// Convert single digit to bignum, z := n +// Input n; output z[k] +extern void bignum_of_word (uint64_t k, uint64_t *z, uint64_t n); + +// Optionally add, z := x + y (if p nonzero) or z := x (if p zero) +// Inputs x[k], p, y[k]; outputs function return (carry-out) and z[k] +extern uint64_t bignum_optadd (uint64_t k, uint64_t *z, uint64_t *x, uint64_t p, uint64_t *y); + +// Optionally negate, z := -x (if p nonzero) or z := x (if p zero) +// Inputs p, x[k]; outputs function return (nonzero input) and z[k] +extern uint64_t bignum_optneg (uint64_t k, uint64_t *z, uint64_t p, uint64_t *x); + +// Optionally negate modulo p_25519, z := (-x) mod p_25519 (if p nonzero) or z := x (if p zero), assuming x reduced +// Inputs p, x[4]; output z[4] +extern void bignum_optneg_p25519 (uint64_t z[static 4], uint64_t p, uint64_t x[static 4]); + +// Optionally negate modulo p_256, z := (-x) mod p_256 (if p nonzero) or z := x (if p zero), assuming x reduced +// Inputs p, x[4]; output z[4] +extern void bignum_optneg_p256 (uint64_t z[static 4], uint64_t p, uint64_t x[static 4]); + +// Optionally negate modulo p_256k1, z := (-x) mod p_256k1 (if p nonzero) or z := x (if p zero), assuming x reduced +// Inputs p, x[4]; output z[4] +extern void bignum_optneg_p256k1 (uint64_t z[static 4], uint64_t p, uint64_t x[static 4]); + +// Optionally negate modulo p_384, z := (-x) mod p_384 (if p nonzero) or z := x (if p zero), assuming x reduced +// Inputs p, x[6]; output z[6] +extern void bignum_optneg_p384 (uint64_t z[static 6], uint64_t p, uint64_t x[static 6]); + +// Optionally negate modulo p_521, z := (-x) mod p_521 (if p nonzero) or z := x (if p zero), assuming x reduced +// Inputs p, x[9]; output z[9] +extern void bignum_optneg_p521 (uint64_t z[static 9], uint64_t p, uint64_t x[static 9]); + +// Optionally subtract, z := x - y (if p nonzero) or z := x (if p zero) +// Inputs x[k], p, y[k]; outputs function return (carry-out) and z[k] +extern uint64_t bignum_optsub (uint64_t k, uint64_t *z, uint64_t *x, uint64_t p, uint64_t *y); + +// Optionally subtract or add, z := x + sgn(p) * y interpreting p as signed +// Inputs x[k], p, y[k]; outputs function return (carry-out) and z[k] +extern uint64_t bignum_optsubadd (uint64_t k, uint64_t *z, uint64_t *x, uint64_t p, uint64_t *y); + +// Return bignum of power of 2, z := 2^n +// Input n; output z[k] +extern void bignum_pow2 (uint64_t k, uint64_t *z, uint64_t n); + +// Shift bignum left by c < 64 bits z := x * 2^c +// Inputs x[n], c; outputs function return (carry-out) and z[k] +extern uint64_t bignum_shl_small (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t c); + +// Shift bignum right by c < 64 bits z := floor(x / 2^c) +// Inputs x[n], c; outputs function return (bits shifted out) and z[k] +extern uint64_t bignum_shr_small (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x, uint64_t c); + +// Square, z := x^2 +// Input x[n]; output z[k] +extern void bignum_sqr (uint64_t k, uint64_t *z, uint64_t n, uint64_t *x); + +// Square, z := x^2 +// Input x[4]; output z[8] +extern void bignum_sqr_4_8 (uint64_t z[static 8], uint64_t x[static 4]); +extern void bignum_sqr_4_8_alt (uint64_t z[static 8], uint64_t x[static 4]); + +// Square, z := x^2 +// Input x[6]; output z[12] +extern void bignum_sqr_6_12 (uint64_t z[static 12], uint64_t x[static 6]); +extern void bignum_sqr_6_12_alt (uint64_t z[static 12], uint64_t x[static 6]); + +// Square, z := x^2 +// Input x[8]; output z[16] +extern void bignum_sqr_8_16 (uint64_t z[static 16], uint64_t x[static 8]); +extern void bignum_sqr_8_16_alt (uint64_t z[static 16], uint64_t x[static 8]); + +// Square modulo p_25519, z := (x^2) mod p_25519 +// Input x[4]; output z[4] +extern void bignum_sqr_p25519 (uint64_t z[static 4], uint64_t x[static 4]); +extern void bignum_sqr_p25519_alt (uint64_t z[static 4], uint64_t x[static 4]); + +// Square modulo p_256k1, z := (x^2) mod p_256k1 +// Input x[4]; output z[4] +extern void bignum_sqr_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); +extern void bignum_sqr_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4]); + +// Square modulo p_521, z := (x^2) mod p_521, assuming x reduced +// Input x[9]; output z[9] +extern void bignum_sqr_p521 (uint64_t z[static 9], uint64_t x[static 9]); +extern void bignum_sqr_p521_alt (uint64_t z[static 9], uint64_t x[static 9]); + +// Subtract, z := x - y +// Inputs x[m], y[n]; outputs function return (carry-out) and z[p] +extern uint64_t bignum_sub (uint64_t p, uint64_t *z, uint64_t m, uint64_t *x, uint64_t n, uint64_t *y); + +// Subtract modulo p_25519, z := (x - y) mod p_25519, assuming x and y reduced +// Inputs x[4], y[4]; output z[4] +extern void bignum_sub_p25519 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); + +// Subtract modulo p_256, z := (x - y) mod p_256, assuming x and y reduced +// Inputs x[4], y[4]; output z[4] +extern void bignum_sub_p256 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); + +// Subtract modulo p_256k1, z := (x - y) mod p_256k1, assuming x and y reduced +// Inputs x[4], y[4]; output z[4] +extern void bignum_sub_p256k1 (uint64_t z[static 4], uint64_t x[static 4], uint64_t y[static 4]); + +// Subtract modulo p_384, z := (x - y) mod p_384, assuming x and y reduced +// Inputs x[6], y[6]; output z[6] +extern void bignum_sub_p384 (uint64_t z[static 6], uint64_t x[static 6], uint64_t y[static 6]); + +// Subtract modulo p_521, z := (x - y) mod p_521, assuming x and y reduced +// Inputs x[9], y[9]; output z[9] +extern void bignum_sub_p521 (uint64_t z[static 9], uint64_t x[static 9], uint64_t y[static 9]); + +// Convert 4-digit (256-bit) bignum to big-endian bytes +// Input x[4]; output z[32] (bytes) +extern void bignum_tobebytes_4 (uint8_t z[static 32], uint64_t x[static 4]); + +// Convert 6-digit (384-bit) bignum to big-endian bytes +// Input x[6]; output z[48] (bytes) +extern void bignum_tobebytes_6 (uint8_t z[static 48], uint64_t x[static 6]); + +// Convert 4-digit (256-bit) bignum to little-endian bytes +// Input x[4]; output z[32] (bytes) +extern void bignum_tolebytes_4 (uint8_t z[static 32], uint64_t x[static 4]); + +// Convert 6-digit (384-bit) bignum to little-endian bytes +// Input x[6]; output z[48] (bytes) +extern void bignum_tolebytes_6 (uint8_t z[static 48], uint64_t x[static 6]); + +// Convert 9-digit 528-bit bignum to little-endian bytes +// Input x[6]; output z[66] (bytes) +extern void bignum_tolebytes_p521 (uint8_t z[static 66], uint64_t x[static 9]); + +// Convert to Montgomery form z := (2^256 * x) mod p_256 +// Input x[4]; output z[4] +extern void bignum_tomont_p256 (uint64_t z[static 4], uint64_t x[static 4]); +extern void bignum_tomont_p256_alt (uint64_t z[static 4], uint64_t x[static 4]); + +// Convert to Montgomery form z := (2^256 * x) mod p_256k1 +// Input x[4]; output z[4] +extern void bignum_tomont_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); +extern void bignum_tomont_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4]); + +// Convert to Montgomery form z := (2^384 * x) mod p_384 +// Input x[6]; output z[6] +extern void bignum_tomont_p384 (uint64_t z[static 6], uint64_t x[static 6]); +extern void bignum_tomont_p384_alt (uint64_t z[static 6], uint64_t x[static 6]); + +// Convert to Montgomery form z := (2^576 * x) mod p_521 +// Input x[9]; output z[9] +extern void bignum_tomont_p521 (uint64_t z[static 9], uint64_t x[static 9]); + +// Triple modulo p_256, z := (3 * x) mod p_256 +// Input x[4]; output z[4] +extern void bignum_triple_p256 (uint64_t z[static 4], uint64_t x[static 4]); +extern void bignum_triple_p256_alt (uint64_t z[static 4], uint64_t x[static 4]); + +// Triple modulo p_256k1, z := (3 * x) mod p_256k1 +// Input x[4]; output z[4] +extern void bignum_triple_p256k1 (uint64_t z[static 4], uint64_t x[static 4]); +extern void bignum_triple_p256k1_alt (uint64_t z[static 4], uint64_t x[static 4]); + +// Triple modulo p_384, z := (3 * x) mod p_384 +// Input x[6]; output z[6] +extern void bignum_triple_p384 (uint64_t z[static 6], uint64_t x[static 6]); +extern void bignum_triple_p384_alt (uint64_t z[static 6], uint64_t x[static 6]); + +// Triple modulo p_521, z := (3 * x) mod p_521, assuming x reduced +// Input x[9]; output z[9] +extern void bignum_triple_p521 (uint64_t z[static 9], uint64_t x[static 9]); +extern void bignum_triple_p521_alt (uint64_t z[static 9], uint64_t x[static 9]); + +// Montgomery ladder step for curve25519 +// Inputs point[8], pp[16], b; output rr[16] +extern void curve25519_ladderstep(uint64_t rr[16],uint64_t point[8],uint64_t pp[16],uint64_t b); +extern void curve25519_ladderstep_alt(uint64_t rr[16],uint64_t point[8],uint64_t pp[16],uint64_t b); + +// Projective scalar multiplication, x coordinate only, for curve25519 +// Inputs scalar[4], point[4]; output res[8] +extern void curve25519_pxscalarmul(uint64_t res[static 8],uint64_t scalar[static 4],uint64_t point[static 4]); +extern void curve25519_pxscalarmul_alt(uint64_t res[static 8],uint64_t scalar[static 4],uint64_t point[static 4]); + +// x25519 function for curve25519 +// Inputs scalar[4], point[4]; output res[4] +extern void curve25519_x25519(uint64_t res[static 4],uint64_t scalar[static 4],uint64_t point[static 4]); +extern void curve25519_x25519_alt(uint64_t res[static 4],uint64_t scalar[static 4],uint64_t point[static 4]); + +// x25519 function for curve25519 on base element 9 +// Input scalar[4]; output res[4] +extern void curve25519_x25519base(uint64_t res[static 4],uint64_t scalar[static 4]); +extern void curve25519_x25519base_alt(uint64_t res[static 4],uint64_t scalar[static 4]); + +// Extended projective addition for edwards25519 +// Inputs p1[16], p2[16]; output p3[16] +extern void edwards25519_epadd(uint64_t p3[static 16],uint64_t p1[static 16],uint64_t p2[static 16]); +extern void edwards25519_epadd_alt(uint64_t p3[static 16],uint64_t p1[static 16],uint64_t p2[static 16]); + +// Extended projective doubling for edwards25519 +// Inputs p1[12]; output p3[16] +extern void edwards25519_epdouble(uint64_t p3[static 16],uint64_t p1[static 12]); +extern void edwards25519_epdouble_alt(uint64_t p3[static 16],uint64_t p1[static 12]); + +// Projective doubling for edwards25519 +// Inputs p1[12]; output p3[12] +extern void edwards25519_pdouble(uint64_t p3[static 12],uint64_t p1[static 12]); +extern void edwards25519_pdouble_alt(uint64_t p3[static 12],uint64_t p1[static 12]); + +// Extended projective + precomputed mixed addition for edwards25519 +// Inputs p1[16], p2[12]; output p3[16] +extern void edwards25519_pepadd(uint64_t p3[static 16],uint64_t p1[static 16],uint64_t p2[static 12]); +extern void edwards25519_pepadd_alt(uint64_t p3[static 16],uint64_t p1[static 16],uint64_t p2[static 12]); + +// Point addition on NIST curve P-256 in Montgomery-Jacobian coordinates +// Inputs p1[12], p2[12]; output p3[12] +extern void p256_montjadd(uint64_t p3[static 12],uint64_t p1[static 12],uint64_t p2[static 12]); + +// Point doubling on NIST curve P-256 in Montgomery-Jacobian coordinates +// Inputs p1[12]; output p3[12] +extern void p256_montjdouble(uint64_t p3[static 12],uint64_t p1[static 12]); + +// Point mixed addition on NIST curve P-256 in Montgomery-Jacobian coordinates +// Inputs p1[12], p2[8]; output p3[12] +extern void p256_montjmixadd(uint64_t p3[static 12],uint64_t p1[static 12],uint64_t p2[static 8]); + +// Point addition on NIST curve P-384 in Montgomery-Jacobian coordinates +// Inputs p1[18], p2[18]; output p3[18] +extern void p384_montjadd(uint64_t p3[static 18],uint64_t p1[static 18],uint64_t p2[static 18]); + +// Point doubling on NIST curve P-384 in Montgomery-Jacobian coordinates +// Inputs p1[18]; output p3[18] +extern void p384_montjdouble(uint64_t p3[static 18],uint64_t p1[static 18]); + +// Point mixed addition on NIST curve P-384 in Montgomery-Jacobian coordinates +// Inputs p1[18], p2[12]; output p3[18] +extern void p384_montjmixadd(uint64_t p3[static 18],uint64_t p1[static 18],uint64_t p2[static 12]); + +// Point addition on NIST curve P-521 in Jacobian coordinates +// Inputs p1[27], p2[27]; output p3[27] +extern void p521_jadd(uint64_t p3[static 27],uint64_t p1[static 27],uint64_t p2[static 27]); + +// Point doubling on NIST curve P-521 in Jacobian coordinates +// Input p1[27]; output p3[27] +extern void p521_jdouble(uint64_t p3[static 27],uint64_t p1[static 27]); + +// Point mixed addition on NIST curve P-521 in Jacobian coordinates +// Inputs p1[27], p2[18]; output p3[27] +extern void p521_jmixadd(uint64_t p3[static 27],uint64_t p1[static 27],uint64_t p2[static 18]); + +// Point addition on SECG curve secp256k1 in Jacobian coordinates +// Inputs p1[12], p2[12]; output p3[12] +extern void secp256k1_jadd(uint64_t p3[static 12],uint64_t p1[static 12],uint64_t p2[static 12]); + +// Point doubling on SECG curve secp256k1 in Jacobian coordinates +// Input p1[12]; output p3[12] +extern void secp256k1_jdouble(uint64_t p3[static 12],uint64_t p1[static 12]); + +// Point mixed addition on SECG curve secp256k1 in Jacobian coordinates +// Inputs p1[12], p2[8]; output p3[12] +extern void secp256k1_jmixadd(uint64_t p3[static 12],uint64_t p1[static 12],uint64_t p2[static 8]); + +// Reverse the bytes in a single word +// Input a; output function return +extern uint64_t word_bytereverse (uint64_t a); + +// Count leading zero bits in a single word +// Input a; output function return +extern uint64_t word_clz (uint64_t a); + +// Count trailing zero bits in a single word +// Input a; output function return +extern uint64_t word_ctz (uint64_t a); + +// Return maximum of two unsigned 64-bit words +// Inputs a, b; output function return +extern uint64_t word_max (uint64_t a, uint64_t b); + +// Return minimum of two unsigned 64-bit words +// Inputs a, b; output function return +extern uint64_t word_min (uint64_t a, uint64_t b); + +// Single-word negated modular inverse (-1/a) mod 2^64 +// Input a; output function return +extern uint64_t word_negmodinv (uint64_t a); + +// Single-word reciprocal, 2^64 + ret = ceil(2^128/a) - 1 if MSB of "a" is set +// Input a; output function return +extern uint64_t word_recip (uint64_t a); diff --git a/crypto/bn/s2n_bignum_internal.h b/crypto/bn/s2n_bignum_internal.h new file mode 100644 index 00000000..f4136883 --- /dev/null +++ b/crypto/bn/s2n_bignum_internal.h @@ -0,0 +1,30 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#ifdef __APPLE__ +# define S2N_BN_SYMBOL(NAME) _##NAME +#else +# define S2N_BN_SYMBOL(name) name +#endif + +#define S2N_BN_SYM_VISIBILITY_DIRECTIVE(name) .globl S2N_BN_SYMBOL(name) +#ifdef S2N_BN_HIDE_SYMBOLS +# ifdef __APPLE__ +# define S2N_BN_SYM_PRIVACY_DIRECTIVE(name) .private_extern S2N_BN_SYMBOL(name) +# else +# define S2N_BN_SYM_PRIVACY_DIRECTIVE(name) .hidden S2N_BN_SYMBOL(name) +# endif +#else +# define S2N_BN_SYM_PRIVACY_DIRECTIVE(name) /* NO-OP: S2N_BN_SYM_PRIVACY_DIRECTIVE */ +#endif diff --git a/crypto/bytestring/bytestring.h b/crypto/bytestring/bytestring.h index d8ef8ffd..d80e89c9 100644 --- a/crypto/bytestring/bytestring.h +++ b/crypto/bytestring/bytestring.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bytestring.h,v 1.3 2022/01/06 14:32:55 jsing Exp $ */ +/* $OpenBSD: bytestring.h,v 1.4 2022/11/09 19:05:42 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -80,11 +80,9 @@ int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len); /* * CBS_strdup copies the current contents of |cbs| into |*out_ptr| as a * NUL-terminated C string. If |*out_ptr| is not NULL, the contents are freed - * with free. It returns one on success and zero on allocation - * failure. On success, |*out_ptr| should be freed with free. - * - * NOTE: If |cbs| contains NUL bytes, the string will be truncated. Call - * |CBS_contains_zero_byte(cbs)| to check for NUL bytes. + * with free. It returns one on success and zero on failure. On success, + * |*out_ptr| should be freed with free. If |cbs| contains NUL bytes, + * CBS_strdup will fail. */ int CBS_strdup(const CBS *cbs, char **out_ptr); diff --git a/crypto/camellia/camellia.c b/crypto/camellia/camellia.c index 5f754ff7..336074ad 100644 --- a/crypto/camellia/camellia.c +++ b/crypto/camellia/camellia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: camellia.c,v 1.11 2016/09/04 14:31:29 jsing Exp $ */ +/* $OpenBSD: camellia.c,v 1.12 2022/11/26 16:08:51 tb Exp $ */ /* ==================================================================== * Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) . * ALL RIGHTS RESERVED. @@ -87,7 +87,7 @@ #include #include -#include "cmll_locl.h" +#include "cmll_local.h" /* 32-bit rotations */ #if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) diff --git a/crypto/camellia/cmll-elf-x86_64.S b/crypto/camellia/cmll-elf-x86_64.S index 64a1af05..29bd92dc 100644 --- a/crypto/camellia/cmll-elf-x86_64.S +++ b/crypto/camellia/cmll-elf-x86_64.S @@ -1083,6 +1083,7 @@ Camellia_Ekeygen: .Lkey_epilogue: retq .size Camellia_Ekeygen,.-Camellia_Ekeygen +.section .rodata .align 64 .LCamellia_SIGMA: .long 0x3bcc908b, 0xa09e667f, 0x4caa73b2, 0xb67ae858 @@ -1602,6 +1603,7 @@ Camellia_Ekeygen: .long 0x008f8f8f,0xe300e3e3 .long 0x00010101,0x40004040 .long 0x003d3d3d,0x4f004f4f +.text .globl Camellia_cbc_encrypt .type Camellia_cbc_encrypt,@function .align 16 @@ -1835,8 +1837,6 @@ Camellia_cbc_encrypt: .Lcbc_abort: retq .size Camellia_cbc_encrypt,.-Camellia_cbc_encrypt - -.byte 67,97,109,101,108,108,105,97,32,102,111,114,32,120,56,54,95,54,52,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/camellia/cmll-macosx-x86_64.S b/crypto/camellia/cmll-macosx-x86_64.S index 5e7a1b7b..d0c7db98 100644 --- a/crypto/camellia/cmll-macosx-x86_64.S +++ b/crypto/camellia/cmll-macosx-x86_64.S @@ -1083,6 +1083,7 @@ L$done: L$key_epilogue: retq +.section __DATA,__const .p2align 6 L$Camellia_SIGMA: .long 0x3bcc908b, 0xa09e667f, 0x4caa73b2, 0xb67ae858 @@ -1602,6 +1603,7 @@ L$Camellia_SBOX: .long 0x008f8f8f,0xe300e3e3 .long 0x00010101,0x40004040 .long 0x003d3d3d,0x4f004f4f +.text .globl _Camellia_cbc_encrypt .p2align 4 @@ -1835,5 +1837,3 @@ L$cbc_done: L$cbc_abort: retq - -.byte 67,97,109,101,108,108,105,97,32,102,111,114,32,120,56,54,95,54,52,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 diff --git a/crypto/camellia/cmll-masm-x86_64.S b/crypto/camellia/cmll-masm-x86_64.S index e1871b50..0c681540 100644 --- a/crypto/camellia/cmll-masm-x86_64.S +++ b/crypto/camellia/cmll-masm-x86_64.S @@ -1189,6 +1189,8 @@ $L$key_epilogue:: DB 0F3h,0C3h ;repret $L$SEH_end_Camellia_Ekeygen:: Camellia_Ekeygen ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 $L$Camellia_SIGMA:: DD 03bcc908bh,0a09e667fh,04caa73b2h,0b67ae858h @@ -1708,6 +1710,8 @@ $L$Camellia_SBOX:: DD 0008f8f8fh,0e300e3e3h DD 000010101h,040004040h DD 0003d3d3dh,04f004f4fh +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' PUBLIC Camellia_cbc_encrypt ALIGN 16 @@ -1957,10 +1961,6 @@ $L$cbc_abort:: $L$SEH_end_Camellia_cbc_encrypt:: Camellia_cbc_encrypt ENDP -DB 67,97,109,101,108,108,105,97,32,102,111,114,32,120,56,54 -DB 95,54,52,32,98,121,32,60,97,112,112,114,111,64,111,112 -DB 101,110,115,115,108,46,111,114,103,62,0 - .text$ ENDS END diff --git a/crypto/camellia/cmll-mingw64-x86_64.S b/crypto/camellia/cmll-mingw64-x86_64.S index 75966f43..8ce6447c 100644 --- a/crypto/camellia/cmll-mingw64-x86_64.S +++ b/crypto/camellia/cmll-mingw64-x86_64.S @@ -1115,6 +1115,7 @@ Camellia_Ekeygen: movq 16(%rsp),%rsi retq .LSEH_end_Camellia_Ekeygen: +.section .rodata .p2align 6 .LCamellia_SIGMA: .long 0x3bcc908b, 0xa09e667f, 0x4caa73b2, 0xb67ae858 @@ -1634,6 +1635,7 @@ Camellia_Ekeygen: .long 0x008f8f8f,0xe300e3e3 .long 0x00010101,0x40004040 .long 0x003d3d3d,0x4f004f4f +.text .globl Camellia_cbc_encrypt .def Camellia_cbc_encrypt; .scl 2; .type 32; .endef .p2align 4 @@ -1880,5 +1882,3 @@ Camellia_cbc_encrypt: movq 16(%rsp),%rsi retq .LSEH_end_Camellia_cbc_encrypt: - -.byte 67,97,109,101,108,108,105,97,32,102,111,114,32,120,56,54,95,54,52,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 diff --git a/crypto/camellia/cmll_ecb.c b/crypto/camellia/cmll_ecb.c index 1a654452..b47ece73 100644 --- a/crypto/camellia/cmll_ecb.c +++ b/crypto/camellia/cmll_ecb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmll_ecb.c,v 1.4 2014/11/13 20:01:58 miod Exp $ */ +/* $OpenBSD: cmll_ecb.c,v 1.5 2022/11/26 16:08:51 tb Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * @@ -50,7 +50,7 @@ */ #include -#include "cmll_locl.h" +#include "cmll_local.h" void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, diff --git a/crypto/camellia/cmll_locl.h b/crypto/camellia/cmll_local.h similarity index 95% rename from crypto/camellia/cmll_locl.h rename to crypto/camellia/cmll_local.h index 325b6e2d..ed9807c0 100644 --- a/crypto/camellia/cmll_locl.h +++ b/crypto/camellia/cmll_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cmll_locl.h,v 1.6 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: cmll_local.h,v 1.2 2022/11/26 17:23:17 tb Exp $ */ /* ==================================================================== * Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) . * ALL RIGHTS RESERVED. @@ -65,8 +65,8 @@ * ==================================================================== */ -#ifndef HEADER_CAMELLIA_LOCL_H -#define HEADER_CAMELLIA_LOCL_H +#ifndef HEADER_CAMELLIA_LOCAL_H +#define HEADER_CAMELLIA_LOCAL_H __BEGIN_HIDDEN_DECLS @@ -86,4 +86,4 @@ void Camellia_DecryptBlock(int keyBitLength, const u8 ciphertext[], __END_HIDDEN_DECLS -#endif /* #ifndef HEADER_CAMELLIA_LOCL_H */ +#endif /* !HEADER_CAMELLIA_LOCAL_H */ diff --git a/crypto/camellia/cmll_misc.c b/crypto/camellia/cmll_misc.c index 2fa61dc6..9fce92df 100644 --- a/crypto/camellia/cmll_misc.c +++ b/crypto/camellia/cmll_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmll_misc.c,v 1.6 2014/11/13 20:01:58 miod Exp $ */ +/* $OpenBSD: cmll_misc.c,v 1.7 2022/11/26 16:08:51 tb Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * @@ -52,7 +52,7 @@ #include #include #include -#include "cmll_locl.h" +#include "cmll_local.h" int Camellia_set_key(const unsigned char *userKey, const int bits, diff --git a/crypto/cast/c_cfb64.c b/crypto/cast/c_cfb64.c index 726d19e0..9586f932 100644 --- a/crypto/cast/c_cfb64.c +++ b/crypto/cast/c_cfb64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_cfb64.c,v 1.5 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: c_cfb64.c,v 1.6 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "cast_lcl.h" +#include "cast_local.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the diff --git a/crypto/cast/c_ecb.c b/crypto/cast/c_ecb.c index c3a01b71..e4ad05c2 100644 --- a/crypto/cast/c_ecb.c +++ b/crypto/cast/c_ecb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_ecb.c,v 1.7 2014/07/09 11:10:50 bcook Exp $ */ +/* $OpenBSD: c_ecb.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "cast_lcl.h" +#include "cast_local.h" #include void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, diff --git a/crypto/cast/c_enc.c b/crypto/cast/c_enc.c index 5999a590..cc28991b 100644 --- a/crypto/cast/c_enc.c +++ b/crypto/cast/c_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_enc.c,v 1.7 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: c_enc.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "cast_lcl.h" +#include "cast_local.h" #ifndef OPENBSD_CAST_ASM void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key) diff --git a/crypto/cast/c_ofb64.c b/crypto/cast/c_ofb64.c index 611425a6..d5859150 100644 --- a/crypto/cast/c_ofb64.c +++ b/crypto/cast/c_ofb64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_ofb64.c,v 1.5 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: c_ofb64.c,v 1.6 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "cast_lcl.h" +#include "cast_local.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the diff --git a/crypto/cast/c_skey.c b/crypto/cast/c_skey.c index 1cea8c8a..5f86effc 100644 --- a/crypto/cast/c_skey.c +++ b/crypto/cast/c_skey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_skey.c,v 1.11 2014/06/12 15:49:28 deraadt Exp $ */ +/* $OpenBSD: c_skey.c,v 1.12 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -58,7 +58,7 @@ #include #include -#include "cast_lcl.h" +#include "cast_local.h" #include "cast_s.h" #define CAST_exp(l,A,a,n) \ diff --git a/crypto/cast/cast_lcl.h b/crypto/cast/cast_local.h similarity index 99% rename from crypto/cast/cast_lcl.h rename to crypto/cast/cast_local.h index 100ff1f2..2ee72a9e 100644 --- a/crypto/cast/cast_lcl.h +++ b/crypto/cast/cast_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cast_lcl.h,v 1.12 2020/01/26 11:49:21 inoguchi Exp $ */ +/* $OpenBSD: cast_local.h,v 1.1 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * diff --git a/crypto/cmac/cm_ameth.c b/crypto/cmac/cm_ameth.c index 26956465..04e0eb83 100644 --- a/crypto/cmac/cm_ameth.c +++ b/crypto/cmac/cm_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cm_ameth.c,v 1.8 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: cm_ameth.c,v 1.10 2022/11/26 16:08:51 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2010. */ @@ -56,8 +56,8 @@ #include #include -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" /* CMAC "ASN1" method. This is just here to indicate the * maximum CMAC output length and to free up a CMAC @@ -73,9 +73,7 @@ cmac_size(const EVP_PKEY *pkey) static void cmac_key_free(EVP_PKEY *pkey) { - CMAC_CTX *cmctx = (CMAC_CTX *)pkey->pkey.ptr; - - CMAC_CTX_free(cmctx); + CMAC_CTX_free(pkey->pkey.ptr); } const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = { diff --git a/crypto/cmac/cm_pmeth.c b/crypto/cmac/cm_pmeth.c index d9059ca4..d47cfb7b 100644 --- a/crypto/cmac/cm_pmeth.c +++ b/crypto/cmac/cm_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cm_pmeth.c,v 1.8 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: cm_pmeth.c,v 1.10 2022/11/26 16:08:51 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2010. */ @@ -59,7 +59,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* The context structure and "key" is simply a CMAC_CTX */ @@ -148,8 +148,7 @@ pkey_cmac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) break; case EVP_PKEY_CTRL_MD: - if (ctx->pkey && !CMAC_CTX_copy(ctx->data, - (CMAC_CTX *)ctx->pkey->pkey.ptr)) + if (ctx->pkey && !CMAC_CTX_copy(ctx->data, ctx->pkey->pkey.ptr)) return 0; if (!CMAC_Init(cmctx, NULL, 0, NULL, NULL)) return 0; diff --git a/crypto/cmac/cmac.c b/crypto/cmac/cmac.c index cd286f88..7135f530 100644 --- a/crypto/cmac/cmac.c +++ b/crypto/cmac/cmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmac.c,v 1.11 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: cmac.c,v 1.13 2022/12/26 07:18:51 jmc Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -57,7 +57,7 @@ #include -#include "evp_locl.h" +#include "evp_local.h" struct CMAC_CTX_st { /* Cipher context to use */ @@ -167,7 +167,7 @@ CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, ctx->nlast_block = 0; return 1; } - /* Initialiase context */ + /* Initialise context */ if (cipher && !EVP_EncryptInit_ex(&ctx->cctx, cipher, impl, NULL, NULL)) return 0; /* Non-NULL key means initialisation complete */ diff --git a/crypto/cms/cms_asn1.c b/crypto/cms/cms_asn1.c index cc00aef0..5285afd7 100644 --- a/crypto/cms/cms_asn1.c +++ b/crypto/cms/cms_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_asn1.c,v 1.19 2022/01/14 08:16:13 tb Exp $ */ +/* $OpenBSD: cms_asn1.c,v 1.21 2023/03/12 17:29:02 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -56,7 +56,7 @@ #include #include #include -#include "cms_lcl.h" +#include "cms_local.h" static const ASN1_TEMPLATE CMS_IssuerAndSerialNumber_seq_tt[] = { @@ -1335,16 +1335,18 @@ cms_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) { ASN1_STREAM_ARG *sarg = exarg; CMS_ContentInfo *cms = NULL; + if (pval) cms = (CMS_ContentInfo *)*pval; else return 1; - switch (operation) { + switch (operation) { case ASN1_OP_STREAM_PRE: if (CMS_stream(&sarg->boundary, cms) <= 0) return 0; - /* fall thru */ + /* FALLTHROUGH */ + case ASN1_OP_DETACHED_PRE: sarg->ndef_bio = CMS_dataInit(cms, sarg->out); if (!sarg->ndef_bio) @@ -1356,8 +1358,8 @@ cms_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) if (CMS_dataFinal(cms, sarg->ndef_bio) <= 0) return 0; break; - } + return 1; } diff --git a/crypto/cms/cms_att.c b/crypto/cms/cms_att.c index b03c7437..0fb077f7 100644 --- a/crypto/cms/cms_att.c +++ b/crypto/cms/cms_att.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_att.c,v 1.9 2019/08/10 18:15:52 jsing Exp $ */ +/* $OpenBSD: cms_att.c,v 1.10 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -57,7 +57,7 @@ #include #include #include -#include "cms_lcl.h" +#include "cms_local.h" /* CMS SignedData Attribute utilities */ diff --git a/crypto/cms/cms_cd.c b/crypto/cms/cms_cd.c index ec67cf11..3ecf801b 100644 --- a/crypto/cms/cms_cd.c +++ b/crypto/cms/cms_cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_cd.c,v 1.15 2019/08/11 11:04:18 jsing Exp $ */ +/* $OpenBSD: cms_cd.c,v 1.16 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -60,7 +60,7 @@ #include #include #include -#include "cms_lcl.h" +#include "cms_local.h" #ifdef ZLIB diff --git a/crypto/cms/cms_dd.c b/crypto/cms/cms_dd.c index f1aafe39..a08fccc2 100644 --- a/crypto/cms/cms_dd.c +++ b/crypto/cms/cms_dd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_dd.c,v 1.14 2019/08/11 11:04:18 jsing Exp $ */ +/* $OpenBSD: cms_dd.c,v 1.15 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -60,7 +60,7 @@ #include #include #include -#include "cms_lcl.h" +#include "cms_local.h" /* CMS DigestedData Utilities */ diff --git a/crypto/cms/cms_enc.c b/crypto/cms/cms_enc.c index ccbb6a5d..06dffcbe 100644 --- a/crypto/cms/cms_enc.c +++ b/crypto/cms/cms_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_enc.c,v 1.21 2022/01/20 10:58:35 inoguchi Exp $ */ +/* $OpenBSD: cms_enc.c,v 1.22 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -61,7 +61,7 @@ #include #include #include -#include "cms_lcl.h" +#include "cms_local.h" /* CMS EncryptedData Utilities */ diff --git a/crypto/cms/cms_env.c b/crypto/cms/cms_env.c index a88ea636..1d534e3d 100644 --- a/crypto/cms/cms_env.c +++ b/crypto/cms/cms_env.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_env.c,v 1.24 2021/09/08 14:33:02 tb Exp $ */ +/* $OpenBSD: cms_env.c,v 1.25 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -61,9 +61,9 @@ #include #include #include -#include "cms_lcl.h" -#include "asn1/asn1_locl.h" -#include "evp/evp_locl.h" +#include "cms_local.h" +#include "asn1/asn1_local.h" +#include "evp/evp_local.h" /* CMS EnvelopedData Utilities */ diff --git a/crypto/cms/cms_ess.c b/crypto/cms/cms_ess.c index 9420405d..88ea6e96 100644 --- a/crypto/cms/cms_ess.c +++ b/crypto/cms/cms_ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_ess.c,v 1.21 2019/08/11 14:19:09 jsing Exp $ */ +/* $OpenBSD: cms_ess.c,v 1.22 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -61,7 +61,7 @@ #include #include #include -#include "cms_lcl.h" +#include "cms_local.h" CMS_ReceiptRequest * diff --git a/crypto/cms/cms_io.c b/crypto/cms/cms_io.c index 4466d6ac..8a6b12e9 100644 --- a/crypto/cms/cms_io.c +++ b/crypto/cms/cms_io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_io.c,v 1.11 2019/08/11 10:38:27 jsing Exp $ */ +/* $OpenBSD: cms_io.c,v 1.12 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -57,7 +57,7 @@ #include #include #include -#include "cms_lcl.h" +#include "cms_local.h" int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) diff --git a/crypto/cms/cms_kari.c b/crypto/cms/cms_kari.c index 21e3ce82..02940077 100644 --- a/crypto/cms/cms_kari.c +++ b/crypto/cms/cms_kari.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_kari.c,v 1.13 2019/08/11 14:27:01 jsing Exp $ */ +/* $OpenBSD: cms_kari.c,v 1.14 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -61,8 +61,8 @@ #include #include #include -#include "cms_lcl.h" -#include "asn1/asn1_locl.h" +#include "cms_local.h" +#include "asn1/asn1_local.h" /* Key Agreement Recipient Info (KARI) routines */ diff --git a/crypto/cms/cms_lib.c b/crypto/cms/cms_lib.c index 21adef7a..ee938591 100644 --- a/crypto/cms/cms_lib.c +++ b/crypto/cms/cms_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_lib.c,v 1.15 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: cms_lib.c,v 1.16 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -60,8 +60,8 @@ #include #include -#include "cms_lcl.h" -#include "x509_lcl.h" +#include "cms_local.h" +#include "x509_local.h" CMS_ContentInfo * d2i_CMS_ContentInfo(CMS_ContentInfo **a, const unsigned char **in, long len) diff --git a/crypto/cms/cms_lcl.h b/crypto/cms/cms_local.h similarity index 99% rename from crypto/cms/cms_lcl.h rename to crypto/cms/cms_local.h index 8083e553..65a684e9 100644 --- a/crypto/cms/cms_lcl.h +++ b/crypto/cms/cms_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_lcl.h,v 1.12 2019/10/04 18:03:56 tb Exp $ */ +/* $OpenBSD: cms_local.h,v 1.2 2022/11/26 17:23:17 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -52,8 +52,8 @@ * ==================================================================== */ -#ifndef HEADER_CMS_LCL_H -#define HEADER_CMS_LCL_H +#ifndef HEADER_CMS_LOCAL_H +#define HEADER_CMS_LOCAL_H #include @@ -481,4 +481,4 @@ extern const ASN1_ITEM CMS_RevocationInfoChoice_it; extern const ASN1_ITEM CMS_SignedData_it; extern const ASN1_ITEM CMS_CompressedData_it; -#endif +#endif /* !HEADER_CMS_LOCAL_H */ diff --git a/crypto/cms/cms_pwri.c b/crypto/cms/cms_pwri.c index eb241a60..3348b60f 100644 --- a/crypto/cms/cms_pwri.c +++ b/crypto/cms/cms_pwri.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_pwri.c,v 1.27 2022/01/19 13:47:44 inoguchi Exp $ */ +/* $OpenBSD: cms_pwri.c,v 1.28 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -62,8 +62,8 @@ #include #include #include -#include "cms_lcl.h" -#include "asn1/asn1_locl.h" +#include "cms_local.h" +#include "asn1/asn1_local.h" int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, unsigned char *pass, diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c index 29dbfb2d..8df78fe3 100644 --- a/crypto/cms/cms_sd.c +++ b/crypto/cms/cms_sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_sd.c,v 1.24 2022/08/28 18:27:47 tb Exp $ */ +/* $OpenBSD: cms_sd.c,v 1.25 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -61,9 +61,9 @@ #include #include #include -#include "cms_lcl.h" -#include "asn1/asn1_locl.h" -#include "evp/evp_locl.h" +#include "cms_local.h" +#include "asn1/asn1_local.h" +#include "evp/evp_local.h" /* CMS SignedData Utilities */ diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index 367810f4..d21ff124 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_smime.c,v 1.24 2019/10/04 18:03:56 tb Exp $ */ +/* $OpenBSD: cms_smime.c,v 1.25 2022/11/26 16:08:51 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -58,8 +58,8 @@ #include #include #include -#include "cms_lcl.h" -#include "asn1/asn1_locl.h" +#include "cms_local.h" +#include "asn1/asn1_local.h" static BIO * cms_get_text_bio(BIO *out, unsigned int flags) diff --git a/crypto/comp/c_rle.c b/crypto/comp/c_rle.c index 93b2f3c7..c2c279dc 100644 --- a/crypto/comp/c_rle.c +++ b/crypto/comp/c_rle.c @@ -1,7 +1,121 @@ -/* $OpenBSD: c_rle.c,v 1.9 2022/01/09 23:50:10 tb Exp $ */ +/* $OpenBSD: c_rle.c,v 1.11 2022/12/24 07:12:09 tb Exp $ */ +/* + * --------------------------------------------------------------------------- + * Patches to this file were contributed by + * Ulf Moeller and Bodo Moeller . + * --------------------------------------------------------------------------- + * Copyright (c) 1999, 2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --------------------------------------------------------------------------- + * Parts of this file are derived from SSLeay code + * which is covered by the following Copyright and license: + * --------------------------------------------------------------------------- + * Copyright (c) 1998 Eric Young + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young . + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson . + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given + * attribution as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young " + * The word 'cryptographic' can be left out if the rouines from the + * library being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) + * from the apps directory (application code) you must include an + * acknowledgement: "This product includes software written + * by Tim Hudson " + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version + * or derivative of this code cannot be changed. i.e. this code cannot + * simply be copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + #include #include #include + #include #include diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c index bdcd7e0f..9db0ae26 100644 --- a/crypto/comp/c_zlib.c +++ b/crypto/comp/c_zlib.c @@ -1,7 +1,123 @@ -/* $OpenBSD: c_zlib.c,v 1.22 2022/01/14 08:40:57 tb Exp $ */ +/* $OpenBSD: c_zlib.c,v 1.25 2022/12/26 07:18:51 jmc Exp $ */ +/* + * --------------------------------------------------------------------------- + * Major patches to this file were contributed by + * Richard Levitte , Nils Larsch , + * and Dr. Stephen Henson . + * --------------------------------------------------------------------------- + * Copyright (c) 2002, 2003, 2007, 2008, 2010 The OpenSSL Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --------------------------------------------------------------------------- + * Parts of this file are derived from SSLeay code + * which is covered by the following Copyright and license: + * --------------------------------------------------------------------------- + * Copyright (c) 1998 Eric Young + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young . + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson . + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given + * attribution as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young " + * The word 'cryptographic' can be left out if the rouines from the + * library being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) + * from the apps directory (application code) you must include an + * acknowledgement: "This product includes software written + * by Tim Hudson " + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version + * or derivative of this code cannot be changed. i.e. this code cannot + * simply be copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + #include #include #include + #include #include #include @@ -27,7 +143,7 @@ static int zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen); -/* memory allocations functions for zlib intialization */ +/* memory allocations functions for zlib initialization */ static void* zlib_zalloc(void* opaque, unsigned int no, unsigned int size) { @@ -181,7 +297,7 @@ COMP_zlib(void) #ifdef ZLIB { /* init zlib_stateful_ex_idx here so that in a multi-process - * application it's enough to intialize openssl before forking + * application it's enough to initialize openssl before forking * (idx will be inherited in all the children) */ if (zlib_stateful_ex_idx == -1) { CRYPTO_w_lock(CRYPTO_LOCK_COMP); diff --git a/crypto/comp/comp_err.c b/crypto/comp/comp_err.c index eb5fc0ad..5ec5039f 100644 --- a/crypto/comp/comp_err.c +++ b/crypto/comp/comp_err.c @@ -1,6 +1,7 @@ -/* $OpenBSD: comp_err.c,v 1.12 2022/07/12 14:42:48 kn Exp $ */ +/* $OpenBSD: comp_err.c,v 1.13 2022/12/23 23:23:02 schwarze Exp $ */ /* ==================================================================== - * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. + * This file was written by Dr. Stephen Henson . + * Copyright (c) 1999, 2005, 2008 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/crypto/comp/comp_lib.c b/crypto/comp/comp_lib.c index 3f914a75..5cb2335b 100644 --- a/crypto/comp/comp_lib.c +++ b/crypto/comp/comp_lib.c @@ -1,7 +1,121 @@ -/* $OpenBSD: comp_lib.c,v 1.9 2022/01/09 23:50:10 tb Exp $ */ +/* $OpenBSD: comp_lib.c,v 1.11 2022/12/24 07:12:09 tb Exp $ */ +/* + * --------------------------------------------------------------------------- + * Patches to this file were contributed by + * Ben Laurie and Ulf Moeller . + * --------------------------------------------------------------------------- + * Copyright (c) 1999 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --------------------------------------------------------------------------- + * Parts of this file are derived from SSLeay code + * which is covered by the following Copyright and license: + * --------------------------------------------------------------------------- + * Copyright (c) 1998 Eric Young + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young . + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson . + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given + * attribution as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young " + * The word 'cryptographic' can be left out if the rouines from the + * library being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) + * from the apps directory (application code) you must include an + * acknowledgement: "This product includes software written + * by Tim Hudson " + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version + * or derivative of this code cannot be changed. i.e. this code cannot + * simply be copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + #include #include #include + #include #include diff --git a/crypto/comp/comp_local.h b/crypto/comp/comp_local.h index fc188871..e26a800b 100644 --- a/crypto/comp/comp_local.h +++ b/crypto/comp/comp_local.h @@ -1,4 +1,116 @@ -/* $OpenBSD: comp_local.h,v 1.2 2022/01/14 08:21:12 tb Exp $ */ +/* $OpenBSD: comp_local.h,v 1.4 2022/12/24 07:12:09 tb Exp $ */ +/* + * --------------------------------------------------------------------------- + * Patches to this file were contributed by + * Richard Levitte . + * --------------------------------------------------------------------------- + * Copyright (c) 1999, 2000, 2003 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --------------------------------------------------------------------------- + * Parts of this file are derived from SSLeay code + * which is covered by the following Copyright and license: + * --------------------------------------------------------------------------- + * Copyright (c) 1998 Eric Young + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young . + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson . + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given + * attribution as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young " + * The word 'cryptographic' can be left out if the rouines from the + * library being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) + * from the apps directory (application code) you must include an + * acknowledgement: "This product includes software written + * by Tim Hudson " + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version + * or derivative of this code cannot be changed. i.e. this code cannot + * simply be copied and put under another distribution licence + * [including the GNU Public Licence.] + */ #ifndef HEADER_COMP_LOCAL_H #define HEADER_COMP_LOCAL_H diff --git a/crypto/compat/getentropy_aix.c b/crypto/compat/getentropy_aix.c index 7fb857e6..9d085cf5 100644 --- a/crypto/compat/getentropy_aix.c +++ b/crypto/compat/getentropy_aix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getentropy_aix.c,v 1.8 2021/10/24 21:24:20 deraadt Exp $ */ +/* $OpenBSD: getentropy_aix.c,v 1.9 2022/12/26 07:18:50 jmc Exp $ */ /* * Copyright (c) 2015 Michael Felt @@ -21,7 +21,7 @@ * http://man.openbsd.org/getentropy.2 */ /* - * -lperfstat is needed for the psuedo entropy data + * -lperfstat is needed for the pseudo entropy data */ #include diff --git a/crypto/constant_time_locl.h b/crypto/constant_time.h similarity index 98% rename from crypto/constant_time_locl.h rename to crypto/constant_time.h index 2d511cc0..6546526b 100644 --- a/crypto/constant_time_locl.h +++ b/crypto/constant_time.h @@ -44,8 +44,8 @@ * [including the GNU Public Licence.] */ -#ifndef HEADER_CONSTANT_TIME_LOCL_H -# define HEADER_CONSTANT_TIME_LOCL_H +#ifndef HEADER_CONSTANT_TIME_H +#define HEADER_CONSTANT_TIME_H __BEGIN_HIDDEN_DECLS @@ -204,4 +204,4 @@ void err_clear_last_constant_time(int clear); __END_HIDDEN_DECLS -#endif /* HEADER_CONSTANT_TIME_LOCL_H */ +#endif /* !HEADER_CONSTANT_TIME_H */ diff --git a/crypto/cpuid-elf-x86_64.S b/crypto/cpuid-elf-x86_64.S index c0e13668..20eeb45c 100644 --- a/crypto/cpuid-elf-x86_64.S +++ b/crypto/cpuid-elf-x86_64.S @@ -9,20 +9,6 @@ .text -.globl OPENSSL_atomic_add -.type OPENSSL_atomic_add,@function -.align 16 -OPENSSL_atomic_add: - movl (%rdi),%eax -.Lspin: leaq (%rsi,%rax,1),%r8 -.byte 0xf0 - cmpxchgl %r8d,(%rdi) - jne .Lspin - movl %r8d,%eax -.byte 0x48,0x98 - retq -.size OPENSSL_atomic_add,.-OPENSSL_atomic_add - .globl OPENSSL_ia32_cpuid .type OPENSSL_ia32_cpuid,@function .align 16 @@ -147,37 +133,6 @@ OPENSSL_ia32_cpuid: orq %r9,%rax retq .size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid -.globl OPENSSL_wipe_cpu -.type OPENSSL_wipe_cpu,@function -.align 16 -OPENSSL_wipe_cpu: - pxor %xmm0,%xmm0 - pxor %xmm1,%xmm1 - pxor %xmm2,%xmm2 - pxor %xmm3,%xmm3 - pxor %xmm4,%xmm4 - pxor %xmm5,%xmm5 - pxor %xmm6,%xmm6 - pxor %xmm7,%xmm7 - pxor %xmm8,%xmm8 - pxor %xmm9,%xmm9 - pxor %xmm10,%xmm10 - pxor %xmm11,%xmm11 - pxor %xmm12,%xmm12 - pxor %xmm13,%xmm13 - pxor %xmm14,%xmm14 - pxor %xmm15,%xmm15 - xorq %rcx,%rcx - xorq %rdx,%rdx - xorq %rsi,%rsi - xorq %rdi,%rdi - xorq %r8,%r8 - xorq %r9,%r9 - xorq %r10,%r10 - xorq %r11,%r11 - leaq 8(%rsp),%rax - retq -.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/cpuid-macosx-x86_64.S b/crypto/cpuid-macosx-x86_64.S index 75317706..76566d78 100644 --- a/crypto/cpuid-macosx-x86_64.S +++ b/crypto/cpuid-macosx-x86_64.S @@ -10,20 +10,6 @@ .text -.globl _OPENSSL_atomic_add - -.p2align 4 -_OPENSSL_atomic_add: - movl (%rdi),%eax -L$spin: leaq (%rsi,%rax,1),%r8 -.byte 0xf0 - cmpxchgl %r8d,(%rdi) - jne L$spin - movl %r8d,%eax -.byte 0x48,0x98 - retq - - .globl _OPENSSL_ia32_cpuid .p2align 4 @@ -148,34 +134,3 @@ L$done: orq %r9,%rax retq -.globl _OPENSSL_wipe_cpu - -.p2align 4 -_OPENSSL_wipe_cpu: - pxor %xmm0,%xmm0 - pxor %xmm1,%xmm1 - pxor %xmm2,%xmm2 - pxor %xmm3,%xmm3 - pxor %xmm4,%xmm4 - pxor %xmm5,%xmm5 - pxor %xmm6,%xmm6 - pxor %xmm7,%xmm7 - pxor %xmm8,%xmm8 - pxor %xmm9,%xmm9 - pxor %xmm10,%xmm10 - pxor %xmm11,%xmm11 - pxor %xmm12,%xmm12 - pxor %xmm13,%xmm13 - pxor %xmm14,%xmm14 - pxor %xmm15,%xmm15 - xorq %rcx,%rcx - xorq %rdx,%rdx - xorq %rsi,%rsi - xorq %rdi,%rdi - xorq %r8,%r8 - xorq %r9,%r9 - xorq %r10,%r10 - xorq %r11,%r11 - leaq 8(%rsp),%rax - retq - diff --git a/crypto/cpuid-masm-x86_64.S b/crypto/cpuid-masm-x86_64.S index 0dd7baf3..a0b2b50f 100644 --- a/crypto/cpuid-masm-x86_64.S +++ b/crypto/cpuid-masm-x86_64.S @@ -78,20 +78,6 @@ EXTERN OPENSSL_ia32cap_P:NEAR .CRT$XCU ENDS .text$ SEGMENT ALIGN(64) 'CODE' -PUBLIC OPENSSL_atomic_add - -ALIGN 16 -OPENSSL_atomic_add PROC PUBLIC - mov eax,DWORD PTR[rdi] -$L$spin:: lea r8,QWORD PTR[rax*1+rsi] -DB 0f0h - cmpxchg DWORD PTR[rdi],r8d - jne $L$spin - mov eax,r8d -DB 048h,098h - DB 0F3h,0C3h ;repret -OPENSSL_atomic_add ENDP - PUBLIC OPENSSL_ia32_cpuid ALIGN 16 @@ -216,37 +202,6 @@ $L$done:: or rax,r9 DB 0F3h,0C3h ;repret OPENSSL_ia32_cpuid ENDP -PUBLIC OPENSSL_wipe_cpu - -ALIGN 16 -OPENSSL_wipe_cpu PROC PUBLIC - pxor xmm0,xmm0 - pxor xmm1,xmm1 - pxor xmm2,xmm2 - pxor xmm3,xmm3 - pxor xmm4,xmm4 - pxor xmm5,xmm5 - pxor xmm6,xmm6 - pxor xmm7,xmm7 - pxor xmm8,xmm8 - pxor xmm9,xmm9 - pxor xmm10,xmm10 - pxor xmm11,xmm11 - pxor xmm12,xmm12 - pxor xmm13,xmm13 - pxor xmm14,xmm14 - pxor xmm15,xmm15 - xor rcx,rcx - xor rdx,rdx - xor rsi,rsi - xor rdi,rdi - xor r8,r8 - xor r9,r9 - xor r10,r10 - xor r11,r11 - lea rax,QWORD PTR[8+rsp] - DB 0F3h,0C3h ;repret -OPENSSL_wipe_cpu ENDP .text$ ENDS END diff --git a/crypto/cpuid-mingw64-x86_64.S b/crypto/cpuid-mingw64-x86_64.S index db9578c9..ec86af8f 100644 --- a/crypto/cpuid-mingw64-x86_64.S +++ b/crypto/cpuid-mingw64-x86_64.S @@ -10,20 +10,6 @@ .text -.globl OPENSSL_atomic_add -.def OPENSSL_atomic_add; .scl 2; .type 32; .endef -.p2align 4 -OPENSSL_atomic_add: - movl (%rdi),%eax -.Lspin: leaq (%rsi,%rax,1),%r8 -.byte 0xf0 - cmpxchgl %r8d,(%rdi) - jne .Lspin - movl %r8d,%eax -.byte 0x48,0x98 - retq - - .globl OPENSSL_ia32_cpuid .def OPENSSL_ia32_cpuid; .scl 2; .type 32; .endef .p2align 4 @@ -148,34 +134,3 @@ OPENSSL_ia32_cpuid: orq %r9,%rax retq -.globl OPENSSL_wipe_cpu -.def OPENSSL_wipe_cpu; .scl 2; .type 32; .endef -.p2align 4 -OPENSSL_wipe_cpu: - pxor %xmm0,%xmm0 - pxor %xmm1,%xmm1 - pxor %xmm2,%xmm2 - pxor %xmm3,%xmm3 - pxor %xmm4,%xmm4 - pxor %xmm5,%xmm5 - pxor %xmm6,%xmm6 - pxor %xmm7,%xmm7 - pxor %xmm8,%xmm8 - pxor %xmm9,%xmm9 - pxor %xmm10,%xmm10 - pxor %xmm11,%xmm11 - pxor %xmm12,%xmm12 - pxor %xmm13,%xmm13 - pxor %xmm14,%xmm14 - pxor %xmm15,%xmm15 - xorq %rcx,%rcx - xorq %rdx,%rdx - xorq %rsi,%rsi - xorq %rdi,%rdi - xorq %r8,%r8 - xorq %r9,%r9 - xorq %r10,%r10 - xorq %r11,%r11 - leaq 8(%rsp),%rax - retq - diff --git a/crypto/crypto.sym b/crypto/crypto.sym index 0402d678..68bc6381 100644 --- a/crypto/crypto.sym +++ b/crypto/crypto.sym @@ -183,6 +183,7 @@ ASN1_VISIBLESTRING_it ASN1_VISIBLESTRING_new ASN1_add_oid_module ASN1_bn_print +ASN1_buf_print ASN1_d2i_bio ASN1_d2i_fp ASN1_dup @@ -1242,6 +1243,9 @@ EC_PRIVATEKEY_new EC_curve_nid2nist EC_curve_nist2nid EC_get_builtin_curves +ED25519_keypair +ED25519_sign +ED25519_verify EDIPARTYNAME_free EDIPARTYNAME_it EDIPARTYNAME_new @@ -1514,6 +1518,18 @@ EVP_CIPHER_flags EVP_CIPHER_get_asn1_iv EVP_CIPHER_iv_length EVP_CIPHER_key_length +EVP_CIPHER_meth_dup +EVP_CIPHER_meth_free +EVP_CIPHER_meth_new +EVP_CIPHER_meth_set_cleanup +EVP_CIPHER_meth_set_ctrl +EVP_CIPHER_meth_set_do_cipher +EVP_CIPHER_meth_set_flags +EVP_CIPHER_meth_set_get_asn1_params +EVP_CIPHER_meth_set_impl_ctx_size +EVP_CIPHER_meth_set_init +EVP_CIPHER_meth_set_iv_length +EVP_CIPHER_meth_set_set_asn1_params EVP_CIPHER_nid EVP_CIPHER_param_to_asn1 EVP_CIPHER_set_asn1_iv @@ -1676,6 +1692,8 @@ EVP_PKEY_get_attr_by_NID EVP_PKEY_get_attr_by_OBJ EVP_PKEY_get_attr_count EVP_PKEY_get_default_digest_nid +EVP_PKEY_get_raw_private_key +EVP_PKEY_get_raw_public_key EVP_PKEY_id EVP_PKEY_keygen EVP_PKEY_keygen_init @@ -1706,6 +1724,8 @@ EVP_PKEY_missing_parameters EVP_PKEY_new EVP_PKEY_new_CMAC_key EVP_PKEY_new_mac_key +EVP_PKEY_new_raw_private_key +EVP_PKEY_new_raw_public_key EVP_PKEY_param_check EVP_PKEY_paramgen EVP_PKEY_paramgen_init @@ -2945,6 +2965,7 @@ UI_method_set_reader UI_method_set_writer UI_new UI_new_method +UI_null UI_process UI_set_default_method UI_set_ex_data @@ -3053,6 +3074,7 @@ X509_CRL_get0_extensions X509_CRL_get0_lastUpdate X509_CRL_get0_nextUpdate X509_CRL_get0_signature +X509_CRL_get0_tbs_sigalg X509_CRL_get_REVOKED X509_CRL_get_ext X509_CRL_get_ext_by_NID @@ -3260,6 +3282,7 @@ X509_STORE_CTX_get1_chain X509_STORE_CTX_get1_issuer X509_STORE_CTX_get_by_subject X509_STORE_CTX_get_chain +X509_STORE_CTX_get_check_issued X509_STORE_CTX_get_current_cert X509_STORE_CTX_get_error X509_STORE_CTX_get_error_depth @@ -3301,6 +3324,7 @@ X509_STORE_get0_objects X509_STORE_get0_param X509_STORE_get1_certs X509_STORE_get1_crls +X509_STORE_get_check_issued X509_STORE_get_ex_data X509_STORE_get_verify X509_STORE_get_verify_cb @@ -3308,6 +3332,7 @@ X509_STORE_load_locations X509_STORE_load_mem X509_STORE_new X509_STORE_set1_param +X509_STORE_set_check_issued X509_STORE_set_default_paths X509_STORE_set_depth X509_STORE_set_ex_data @@ -3396,6 +3421,7 @@ X509_get0_pubkey_bitstr X509_get0_serialNumber X509_get0_signature X509_get0_tbs_sigalg +X509_get0_uids X509_get1_email X509_get1_ocsp X509_get_X509_PUBKEY diff --git a/crypto/crypto_init.c b/crypto/crypto_init.c index 69ba6299..351b8ce0 100644 --- a/crypto/crypto_init.c +++ b/crypto/crypto_init.c @@ -77,6 +77,7 @@ OPENSSL_cleanup(void) /* This currently calls init... */ ERR_free_strings(); + CRYPTO_cleanup_all_ex_data(); ENGINE_cleanup(); EVP_cleanup(); x509_issuer_cache_free(); diff --git a/crypto/curve25519/curve25519.c b/crypto/curve25519/curve25519.c index 6df03a3a..cd1b0c58 100644 --- a/crypto/curve25519/curve25519.c +++ b/crypto/curve25519/curve25519.c @@ -1,4 +1,4 @@ -/* $OpenBSD: curve25519.c,v 1.6 2022/02/08 16:44:23 tb Exp $ */ +/* $OpenBSD: curve25519.c,v 1.14 2022/11/17 19:01:59 tb Exp $ */ /* * Copyright (c) 2015, Google Inc. * @@ -24,14 +24,12 @@ * The field functions are shared by Ed25519 and X25519 where possible. */ +#include #include #include #include - -#ifdef ED25519 #include -#endif #include "curve25519_internal.h" @@ -644,9 +642,6 @@ static void fe_invert(fe out, const fe z) { int i; fe_sq(t0, z); - for (i = 1; i < 1; ++i) { - fe_sq(t0, t0); - } fe_sq(t1, t0); for (i = 1; i < 2; ++i) { fe_sq(t1, t1); @@ -654,9 +649,6 @@ static void fe_invert(fe out, const fe z) { fe_mul(t1, z, t1); fe_mul(t0, t0, t1); fe_sq(t2, t0); - for (i = 1; i < 1; ++i) { - fe_sq(t2, t2); - } fe_mul(t1, t1, t2); fe_sq(t2, t1); for (i = 1; i < 5; ++i) { @@ -911,9 +903,6 @@ static void fe_pow22523(fe out, const fe z) { int i; fe_sq(t0, z); - for (i = 1; i < 1; ++i) { - fe_sq(t0, t0); - } fe_sq(t1, t0); for (i = 1; i < 2; ++i) { fe_sq(t1, t1); @@ -921,9 +910,6 @@ static void fe_pow22523(fe out, const fe z) { fe_mul(t1, z, t1); fe_mul(t0, t0, t1); fe_sq(t0, t0); - for (i = 1; i < 1; ++i) { - fe_sq(t0, t0); - } fe_mul(t0, t1, t0); fe_sq(t1, t0); for (i = 1; i < 5; ++i) { @@ -979,7 +965,6 @@ void x25519_ge_tobytes(uint8_t *s, const ge_p2 *h) { s[31] ^= fe_isnegative(x) << 7; } -#ifdef ED25519 static void ge_p3_tobytes(uint8_t *s, const ge_p3 *h) { fe recip; fe x; @@ -991,7 +976,6 @@ static void ge_p3_tobytes(uint8_t *s, const ge_p3 *h) { fe_tobytes(s, y); s[31] ^= fe_isnegative(x) << 7; } -#endif static const fe d = {-10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116}; @@ -1146,7 +1130,6 @@ static void ge_madd(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q) { fe_sub(r->T, t0, r->T); } -#ifdef ED25519 /* r = p - q */ static void ge_msub(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q) { fe t0; @@ -1162,7 +1145,6 @@ static void ge_msub(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q) { fe_sub(r->Z, t0, r->T); fe_add(r->T, t0, r->T); } -#endif /* r = p + q */ void x25519_ge_add(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q) { @@ -3513,7 +3495,7 @@ static void table_select(ge_precomp *t, int pos, signed char b) { * * Preconditions: * a[31] <= 127 */ -void x25519_ge_scalarmult_base(ge_p3 *h, const uint8_t a[32]) { +void x25519_ge_scalarmult_base(ge_p3 *h, const uint8_t *a) { signed char e[64]; signed char carry; ge_p1p1 r; @@ -3624,7 +3606,6 @@ void x25519_ge_scalarmult(ge_p2 *r, const uint8_t *scalar, const ge_p3 *A) { } } -#ifdef ED25519 static void slide(signed char *r, const uint8_t *a) { int i; int b; @@ -3799,7 +3780,6 @@ ge_double_scalarmult_vartime(ge_p2 *r, const uint8_t *a, x25519_ge_p1p1_to_p2(r, &t); } } -#endif /* The set of scalars is \Z/l * where l = 2^252 + 27742317777372353535851937790883648493. */ @@ -4145,7 +4125,6 @@ x25519_sc_reduce(uint8_t *s) { s[31] = s11 >> 17; } -#ifdef ED25519 /* Input: * a[0]+256*a[1]+...+256^31*a[31] = a * b[0]+256*b[1]+...+256^31*b[31] = b @@ -4636,15 +4615,11 @@ sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b, s[30] = s11 >> 9; s[31] = s11 >> 17; } -#endif - -#ifdef ED25519 -void ED25519_keypair(uint8_t out_public_key[32], uint8_t out_private_key[64]) { - uint8_t seed[32]; - arc4random_buf(seed, 32); +void ED25519_public_from_private(uint8_t out_public_key[ED25519_PUBLIC_KEY_LENGTH], + const uint8_t private_key[ED25519_PRIVATE_KEY_LENGTH]) { uint8_t az[SHA512_DIGEST_LENGTH]; - SHA512(seed, 32, az); + SHA512(private_key, 32, az); az[0] &= 248; az[31] &= 63; @@ -4653,13 +4628,18 @@ void ED25519_keypair(uint8_t out_public_key[32], uint8_t out_private_key[64]) { ge_p3 A; x25519_ge_scalarmult_base(&A, az); ge_p3_tobytes(out_public_key, &A); +} + +void ED25519_keypair(uint8_t out_public_key[ED25519_PUBLIC_KEY_LENGTH], + uint8_t out_private_key[ED25519_PRIVATE_KEY_LENGTH]) { + arc4random_buf(out_private_key, 32); - memcpy(out_private_key, seed, 32); - memmove(out_private_key + 32, out_public_key, 32); + ED25519_public_from_private(out_public_key, out_private_key); } int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, - const uint8_t private_key[64]) { + const uint8_t public_key[ED25519_PUBLIC_KEY_LENGTH], + const uint8_t private_key[ED25519_PRIVATE_KEY_LENGTH]) { uint8_t az[SHA512_DIGEST_LENGTH]; SHA512(private_key, 32, az); @@ -4681,7 +4661,7 @@ int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, SHA512_Init(&hash_ctx); SHA512_Update(&hash_ctx, out_sig, 32); - SHA512_Update(&hash_ctx, private_key + 32, 32); + SHA512_Update(&hash_ctx, public_key, 32); SHA512_Update(&hash_ctx, message, message_len); uint8_t hram[SHA512_DIGEST_LENGTH]; SHA512_Final(hram, &hash_ctx); @@ -4692,9 +4672,22 @@ int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, return 1; } +/* + * Little endian representation of the order of edwards25519, + * see https://www.rfc-editor.org/rfc/rfc7748#section-4.1 + */ +static const uint8_t order[] = { + 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, + 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, +}; + int ED25519_verify(const uint8_t *message, size_t message_len, - const uint8_t signature[64], const uint8_t public_key[32]) { + const uint8_t signature[ED25519_SIGNATURE_LENGTH], + const uint8_t public_key[ED25519_PUBLIC_KEY_LENGTH]) { ge_p3 A; + int i; if ((signature[63] & 224) != 0 || x25519_ge_frombytes_vartime(&A, public_key) != 0) { return 0; @@ -4710,6 +4703,20 @@ int ED25519_verify(const uint8_t *message, size_t message_len, uint8_t scopy[32]; memcpy(scopy, signature + 32, 32); + /* + * https://tools.ietf.org/html/rfc8032#section-5.1.7 requires that scopy be + * in the range [0, order) to prevent signature malleability. This value is + * public, so there is no need to make this constant time. + */ + for (i = 31; i >= 0; i--) { + if (scopy[i] > order[i]) + return 0; + if (scopy[i] < order[i]) + break; + if (i == 0) + return 0; + } + SHA512_CTX hash_ctx; SHA512_Init(&hash_ctx); SHA512_Update(&hash_ctx, signature, 32); @@ -4728,7 +4735,6 @@ int ED25519_verify(const uint8_t *message, size_t message_len, return timingsafe_memcmp(rcheck, rcopy, sizeof(rcheck)) == 0; } -#endif /* Replace (f,g) with (g,f) if b == 1; * replace (f,g) with (f,g) if b == 0. @@ -4862,7 +4868,7 @@ x25519_scalar_mult_generic(uint8_t out[32], const uint8_t scalar[32], #ifdef unused void -x25519_public_from_private_generic(uint8_t out_public_value[32], +x25519_public_from_private_generic(uint8_t out_public_key[32], const uint8_t private_key[32]) { uint8_t e[32]; @@ -4882,21 +4888,21 @@ x25519_public_from_private_generic(uint8_t out_public_value[32], fe_sub(zminusy, A.Z, A.Y); fe_invert(zminusy_inv, zminusy); fe_mul(zplusy, zplusy, zminusy_inv); - fe_tobytes(out_public_value, zplusy); + fe_tobytes(out_public_key, zplusy); } #endif void -x25519_public_from_private(uint8_t out_public_value[32], - const uint8_t private_key[32]) +X25519_public_from_private(uint8_t out_public_key[X25519_KEY_LENGTH], + const uint8_t private_key[X25519_KEY_LENGTH]) { static const uint8_t kMongomeryBasePoint[32] = {9}; - x25519_scalar_mult(out_public_value, private_key, kMongomeryBasePoint); + x25519_scalar_mult(out_public_key, private_key, kMongomeryBasePoint); } void -X25519_keypair(uint8_t out_public_value[X25519_KEY_LENGTH], +X25519_keypair(uint8_t out_public_key[X25519_KEY_LENGTH], uint8_t out_private_key[X25519_KEY_LENGTH]) { /* All X25519 implementations should decode scalars correctly (see @@ -4918,17 +4924,17 @@ X25519_keypair(uint8_t out_public_value[X25519_KEY_LENGTH], out_private_key[31] &= 63; out_private_key[31] |= 128; - x25519_public_from_private(out_public_value, out_private_key); + X25519_public_from_private(out_public_key, out_private_key); } int X25519(uint8_t out_shared_key[X25519_KEY_LENGTH], const uint8_t private_key[X25519_KEY_LENGTH], - const uint8_t peer_public_value[X25519_KEY_LENGTH]) + const uint8_t peer_public_key[X25519_KEY_LENGTH]) { static const uint8_t kZeros[32] = {0}; - x25519_scalar_mult(out_shared_key, private_key, peer_public_value); + x25519_scalar_mult(out_shared_key, private_key, peer_public_key); /* The all-zero output results when the input is a point of small order. */ return timingsafe_memcmp(kZeros, out_shared_key, 32) != 0; diff --git a/crypto/curve25519/curve25519_internal.h b/crypto/curve25519/curve25519_internal.h index 09d20a4f..abfaaaf5 100644 --- a/crypto/curve25519/curve25519_internal.h +++ b/crypto/curve25519/curve25519_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curve25519_internal.h,v 1.3 2019/05/11 15:55:52 tb Exp $ */ +/* $OpenBSD: curve25519_internal.h,v 1.6 2022/11/09 17:45:55 jsing Exp $ */ /* * Copyright (c) 2015, Google Inc. * @@ -94,6 +94,12 @@ void x25519_scalar_mult(uint8_t out[32], const uint8_t scalar[32], void x25519_scalar_mult_generic(uint8_t out[32], const uint8_t scalar[32], const uint8_t point[32]); +void ED25519_public_from_private(uint8_t out_public_key[32], + const uint8_t private_key[32]); + +void X25519_public_from_private(uint8_t out_public_key[32], + const uint8_t private_key[32]); + __END_HIDDEN_DECLS #endif /* HEADER_CURVE25519_INTERNAL_H */ diff --git a/crypto/des/cbc_cksm.c b/crypto/des/cbc_cksm.c index 20553ef0..2c1c4aa8 100644 --- a/crypto/des/cbc_cksm.c +++ b/crypto/des/cbc_cksm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cbc_cksm.c,v 1.7 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: cbc_cksm.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output, long length, DES_key_schedule *schedule, diff --git a/crypto/des/cfb64ede.c b/crypto/des/cfb64ede.c index 6d4d2877..f2b2fe2d 100644 --- a/crypto/des/cfb64ede.c +++ b/crypto/des/cfb64ede.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfb64ede.c,v 1.9 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: cfb64ede.c,v 1.10 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the diff --git a/crypto/des/cfb64enc.c b/crypto/des/cfb64enc.c index 6c8f99e8..4e928459 100644 --- a/crypto/des/cfb64enc.c +++ b/crypto/des/cfb64enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfb64enc.c,v 1.6 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: cfb64enc.c,v 1.7 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the diff --git a/crypto/des/cfb_enc.c b/crypto/des/cfb_enc.c index 4231f469..9ba31f4e 100644 --- a/crypto/des/cfb_enc.c +++ b/crypto/des/cfb_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfb_enc.c,v 1.14 2021/11/09 18:40:21 bcook Exp $ */ +/* $OpenBSD: cfb_enc.c,v 1.15 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" #include /* The input and output are loaded in multiples of 8 bits. diff --git a/crypto/des/des_enc.c b/crypto/des/des_enc.c index 1de35e1e..8d6232bb 100644 --- a/crypto/des/des_enc.c +++ b/crypto/des/des_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: des_enc.c,v 1.12 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: des_enc.c,v 1.13 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" #include "spr.h" #ifndef OPENBSD_DES_ASM diff --git a/crypto/des/des_locl.h b/crypto/des/des_local.h similarity index 99% rename from crypto/des/des_locl.h rename to crypto/des/des_local.h index 34a76098..a058ac2c 100644 --- a/crypto/des/des_locl.h +++ b/crypto/des/des_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: des_locl.h,v 1.19 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: des_local.h,v 1.1 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * diff --git a/crypto/des/ecb3_enc.c b/crypto/des/ecb3_enc.c index 97de804c..c2d8329f 100644 --- a/crypto/des/ecb3_enc.c +++ b/crypto/des/ecb3_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecb3_enc.c,v 1.7 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: ecb3_enc.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, DES_key_schedule *ks1, DES_key_schedule *ks2, diff --git a/crypto/des/ecb_enc.c b/crypto/des/ecb_enc.c index dac37de8..35ce7113 100644 --- a/crypto/des/ecb_enc.c +++ b/crypto/des/ecb_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecb_enc.c,v 1.16 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: ecb_enc.c,v 1.17 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" #include #include diff --git a/crypto/des/ede_cbcm_enc.c b/crypto/des/ede_cbcm_enc.c index 9a9f51e3..3f1609d7 100644 --- a/crypto/des/ede_cbcm_enc.c +++ b/crypto/des/ede_cbcm_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ede_cbcm_enc.c,v 1.6 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: ede_cbcm_enc.c,v 1.7 2022/11/26 16:08:51 tb Exp $ */ /* Written by Ben Laurie for the OpenSSL * project 13 Feb 1999. */ @@ -71,7 +71,7 @@ a lot of work: #include /* To see if OPENSSL_NO_DESCBCM is defined */ #ifndef OPENSSL_NO_DESCBCM -#include "des_locl.h" +#include "des_local.h" void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, long length, DES_key_schedule *ks1, DES_key_schedule *ks2, diff --git a/crypto/des/enc_read.c b/crypto/des/enc_read.c index f5659150..a9010f6f 100644 --- a/crypto/des/enc_read.c +++ b/crypto/des/enc_read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enc_read.c,v 1.15 2015/02/12 03:54:07 jsing Exp $ */ +/* $OpenBSD: enc_read.c,v 1.16 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -61,7 +61,7 @@ #include -#include "des_locl.h" +#include "des_local.h" /* This has some uglies in it but it works - even over sockets. */ /*extern int errno;*/ diff --git a/crypto/des/enc_writ.c b/crypto/des/enc_writ.c index 59f3878d..65fa720c 100644 --- a/crypto/des/enc_writ.c +++ b/crypto/des/enc_writ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enc_writ.c,v 1.14 2015/02/12 03:54:07 jsing Exp $ */ +/* $OpenBSD: enc_writ.c,v 1.15 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include -#include "des_locl.h" +#include "des_local.h" /* * WARNINGS: diff --git a/crypto/des/fcrypt.c b/crypto/des/fcrypt.c index f8c9935a..537562cd 100644 --- a/crypto/des/fcrypt.c +++ b/crypto/des/fcrypt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fcrypt.c,v 1.12 2016/12/26 21:30:10 jca Exp $ */ +/* $OpenBSD: fcrypt.c,v 1.13 2022/11/26 16:08:51 tb Exp $ */ #include @@ -15,7 +15,7 @@ * defined 24. */ -#include "des_locl.h" +#include "des_local.h" /* Added more values to handle illegal salt values the way normal * crypt() implementations do. The patch was sent by diff --git a/crypto/des/fcrypt_b.c b/crypto/des/fcrypt_b.c index ad11a47d..903c6de9 100644 --- a/crypto/des/fcrypt_b.c +++ b/crypto/des/fcrypt_b.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fcrypt_b.c,v 1.9 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: fcrypt_b.c,v 1.10 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,7 +65,7 @@ */ #define DES_FCRYPT -#include "des_locl.h" +#include "des_local.h" #undef DES_FCRYPT #ifndef OPENBSD_DES_ASM diff --git a/crypto/des/ncbc_enc.c b/crypto/des/ncbc_enc.c index 21279623..f2e1274b 100644 --- a/crypto/des/ncbc_enc.c +++ b/crypto/des/ncbc_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncbc_enc.c,v 1.7 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: ncbc_enc.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ /* * #included by: * cbc_enc.c (DES_cbc_encrypt) @@ -61,7 +61,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" #ifdef CBC_ENC_C__DONT_UPDATE_IV void DES_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, diff --git a/crypto/des/ofb64ede.c b/crypto/des/ofb64ede.c index 474d38ca..65969313 100644 --- a/crypto/des/ofb64ede.c +++ b/crypto/des/ofb64ede.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofb64ede.c,v 1.6 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: ofb64ede.c,v 1.7 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the diff --git a/crypto/des/ofb64enc.c b/crypto/des/ofb64enc.c index de1a26b9..10deca00 100644 --- a/crypto/des/ofb64enc.c +++ b/crypto/des/ofb64enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofb64enc.c,v 1.6 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: ofb64enc.c,v 1.7 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the diff --git a/crypto/des/ofb_enc.c b/crypto/des/ofb_enc.c index 8cc5bbcb..25abb6db 100644 --- a/crypto/des/ofb_enc.c +++ b/crypto/des/ofb_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofb_enc.c,v 1.6 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: ofb_enc.c,v 1.7 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" /* The input and output are loaded in multiples of 8 bits. * What this means is that if you hame numbits=12 and length=2 diff --git a/crypto/des/pcbc_enc.c b/crypto/des/pcbc_enc.c index fda18ba8..1f8688d1 100644 --- a/crypto/des/pcbc_enc.c +++ b/crypto/des/pcbc_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcbc_enc.c,v 1.6 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: pcbc_enc.c,v 1.7 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, long length, DES_key_schedule *schedule, diff --git a/crypto/des/qud_cksm.c b/crypto/des/qud_cksm.c index e2409d8b..7ff43620 100644 --- a/crypto/des/qud_cksm.c +++ b/crypto/des/qud_cksm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qud_cksm.c,v 1.7 2014/06/12 15:49:28 deraadt Exp $ */ +/* $OpenBSD: qud_cksm.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -61,7 +61,7 @@ * This module in only based on the code in this paper and is * almost definitely not the same as the MIT implementation. */ -#include "des_locl.h" +#include "des_local.h" /* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */ #define Q_B0(a) (((DES_LONG)(a))) diff --git a/crypto/des/set_key.c b/crypto/des/set_key.c index 7d2c6b43..5196a64f 100644 --- a/crypto/des/set_key.c +++ b/crypto/des/set_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: set_key.c,v 1.20 2017/02/09 03:43:05 dtucker Exp $ */ +/* $OpenBSD: set_key.c,v 1.21 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -64,7 +64,7 @@ * 1.0 First working version */ #include -#include "des_locl.h" +#include "des_local.h" int DES_check_key = 0; /* defaults to false */ diff --git a/crypto/des/str2key.c b/crypto/des/str2key.c index ce17e265..316e8039 100644 --- a/crypto/des/str2key.c +++ b/crypto/des/str2key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: str2key.c,v 1.10 2015/09/10 15:56:25 jsing Exp $ */ +/* $OpenBSD: str2key.c,v 1.11 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "des_locl.h" +#include "des_local.h" void DES_string_to_key(const char *str, DES_cblock *key) { diff --git a/crypto/des/xcbc_enc.c b/crypto/des/xcbc_enc.c index 4f7a0701..0152f3ef 100644 --- a/crypto/des/xcbc_enc.c +++ b/crypto/des/xcbc_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xcbc_enc.c,v 1.9 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: xcbc_enc.c,v 1.10 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include "des_local.h" /* RSA's DESX */ diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c index 3701946c..a0bcf8a7 100644 --- a/crypto/dh/dh_ameth.c +++ b/crypto/dh/dh_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_ameth.c,v 1.24 2022/06/27 12:36:05 tb Exp $ */ +/* $OpenBSD: dh_ameth.c,v 1.26 2022/12/26 07:18:51 jmc Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -64,9 +64,9 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" #include "dh_local.h" -#include "evp_locl.h" +#include "evp_local.h" static void int_dh_free(EVP_PKEY *pkey) @@ -177,7 +177,7 @@ dh_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) /* * PKCS#8 DH is defined in PKCS#11 of all places. It is similar to DH in - * that the AlgorithmIdentifier contains the paramaters, the private key + * that the AlgorithmIdentifier contains the parameters, the private key * is explcitly included and the pubkey must be recalculated. */ diff --git a/crypto/dh/dh_check.c b/crypto/dh/dh_check.c index ee405f92..9bbbd55b 100644 --- a/crypto/dh/dh_check.c +++ b/crypto/dh/dh_check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_check.c,v 1.25 2022/07/13 18:38:20 tb Exp $ */ +/* $OpenBSD: dh_check.c,v 1.26 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" #include "dh_local.h" #define DH_NUMBER_ITERATIONS_FOR_PRIME 64 diff --git a/crypto/dh/dh_depr.c b/crypto/dh/dh_depr.c index 717482ca..3c4804a1 100644 --- a/crypto/dh/dh_depr.c +++ b/crypto/dh/dh_depr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_depr.c,v 1.7 2021/12/04 16:08:32 tb Exp $ */ +/* $OpenBSD: dh_depr.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -62,7 +62,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" #ifndef OPENSSL_NO_DEPRECATED DH * diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c index 92429318..89ae5f0f 100644 --- a/crypto/dh/dh_key.c +++ b/crypto/dh/dh_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_key.c,v 1.37 2022/01/07 09:27:13 tb Exp $ */ +/* $OpenBSD: dh_key.c,v 1.38 2022/11/26 16:08:51 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" #include "dh_local.h" static int generate_key(DH *dh); diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c index 35a22d1e..e5cb4648 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_lib.c,v 1.37 2022/06/27 12:31:38 tb Exp $ */ +/* $OpenBSD: dh_lib.c,v 1.38 2023/03/07 09:27:10 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -194,14 +194,14 @@ DH_free(DH *r) CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data); - BN_clear_free(r->p); - BN_clear_free(r->g); - BN_clear_free(r->q); - BN_clear_free(r->j); + BN_free(r->p); + BN_free(r->g); + BN_free(r->q); + BN_free(r->j); free(r->seed); - BN_clear_free(r->counter); - BN_clear_free(r->pub_key); - BN_clear_free(r->priv_key); + BN_free(r->counter); + BN_free(r->pub_key); + BN_free(r->priv_key); free(r); } diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c index d2052a81..7a598da2 100644 --- a/crypto/dh/dh_pmeth.c +++ b/crypto/dh/dh_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_pmeth.c,v 1.12 2022/01/07 09:27:13 tb Exp $ */ +/* $OpenBSD: dh_pmeth.c,v 1.13 2022/11/26 16:08:51 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -67,9 +67,9 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" #include "dh_local.h" -#include "evp_locl.h" +#include "evp_local.h" /* DH pkey context structure */ diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c index 372966b3..f282caae 100644 --- a/crypto/dsa/dsa_ameth.c +++ b/crypto/dsa/dsa_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_ameth.c,v 1.37 2022/06/27 12:36:05 tb Exp $ */ +/* $OpenBSD: dsa_ameth.c,v 1.42 2023/03/04 21:42:49 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -67,10 +67,10 @@ #include #include -#include "asn1_locl.h" -#include "bn_lcl.h" -#include "dsa_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "bn_local.h" +#include "dsa_local.h" +#include "evp_local.h" static int dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) @@ -118,6 +118,12 @@ dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) goto err; } + /* We can only check for key consistency if we have parameters. */ + if (ptype == V_ASN1_SEQUENCE) { + if (!dsa_check_key(dsa)) + goto err; + } + ASN1_INTEGER_free(public_key); EVP_PKEY_assign_DSA(pkey, dsa); return 1; @@ -192,7 +198,6 @@ dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) ASN1_INTEGER *privkey = NULL; BN_CTX *ctx = NULL; DSA *dsa = NULL; - int ret = 0; if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8)) @@ -216,16 +221,24 @@ dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) DSAerror(DSA_R_BN_ERROR); goto dsaerr; } + + /* Check the key for basic consistency before doing expensive things. */ + if (!dsa_check_key(dsa)) + goto dsaerr; + /* Calculate public key */ if (!(dsa->pub_key = BN_new())) { DSAerror(ERR_R_MALLOC_FAILURE); goto dsaerr; } - if (!(ctx = BN_CTX_new())) { + + if ((ctx = BN_CTX_new()) == NULL) { DSAerror(ERR_R_MALLOC_FAILURE); goto dsaerr; } + BN_CTX_start(ctx); + if (!BN_mod_exp_ct(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) { DSAerror(DSA_R_BN_ERROR); goto dsaerr; @@ -242,8 +255,10 @@ dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) dsaerr: DSA_free(dsa); done: + BN_CTX_end(ctx); BN_CTX_free(ctx); ASN1_INTEGER_free(privkey); + return ret; } @@ -452,6 +467,10 @@ dsa_param_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) DSAerror(ERR_R_DSA_LIB); return 0; } + if (!dsa_check_key(dsa)) { + DSA_free(dsa); + return 0; + } EVP_PKEY_assign_DSA(pkey, dsa); return 1; } @@ -485,56 +504,34 @@ old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) { DSA *dsa; BN_CTX *ctx = NULL; - BIGNUM *j, *p1, *newp1, *powg; - int qbits; + BIGNUM *result; - if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) { + if ((dsa = d2i_DSAPrivateKey(NULL, pder, derlen)) == NULL) { DSAerror(ERR_R_DSA_LIB); - return 0; - } - - /* FIPS 186-3 allows only three different sizes for q. */ - qbits = BN_num_bits(dsa->q); - if (qbits != 160 && qbits != 224 && qbits != 256) { - DSAerror(DSA_R_BAD_Q_VALUE); goto err; } - if (BN_num_bits(dsa->p) > OPENSSL_DSA_MAX_MODULUS_BITS) { - DSAerror(DSA_R_MODULUS_TOO_LARGE); + + if (!dsa_check_key(dsa)) goto err; - } - /* Check that 1 < g < p. */ - if (BN_cmp(dsa->g, BN_value_one()) <= 0 || - BN_cmp(dsa->g, dsa->p) >= 0) { - DSAerror(DSA_R_PARAMETER_ENCODING_ERROR); /* XXX */ + if ((ctx = BN_CTX_new()) == NULL) goto err; - } - ctx = BN_CTX_new(); - if (ctx == NULL) + BN_CTX_start(ctx); + + if ((result = BN_CTX_get(ctx)) == NULL) goto err; /* - * Check that p and q are consistent with each other. + * Check that p and q are consistent with each other. dsa_check_key() + * ensures that 1 < q < p. Now check that q divides p - 1. */ - j = BN_CTX_get(ctx); - p1 = BN_CTX_get(ctx); - newp1 = BN_CTX_get(ctx); - powg = BN_CTX_get(ctx); - if (j == NULL || p1 == NULL || newp1 == NULL || powg == NULL) - goto err; - /* p1 = p - 1 */ - if (BN_sub(p1, dsa->p, BN_value_one()) == 0) - goto err; - /* j = (p - 1) / q */ - if (BN_div_ct(j, NULL, p1, dsa->q, ctx) == 0) + if (!BN_sub(result, dsa->p, BN_value_one())) goto err; - /* q * j should == p - 1 */ - if (BN_mul(newp1, dsa->q, j, ctx) == 0) + if (!BN_mod_ct(result, result, dsa->q, ctx)) goto err; - if (BN_cmp(newp1, p1) != 0) { + if (!BN_is_zero(result)) { DSAerror(DSA_R_BAD_Q_VALUE); goto err; } @@ -545,10 +542,10 @@ old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) * Once we know that q is prime, this is enough. */ - if (!BN_mod_exp_ct(powg, dsa->g, dsa->q, dsa->p, ctx)) + if (!BN_mod_exp_ct(result, dsa->g, dsa->q, dsa->p, ctx)) goto err; - if (BN_cmp(powg, BN_value_one()) != 0) { - DSAerror(DSA_R_PARAMETER_ENCODING_ERROR); /* XXX */ + if (BN_cmp(result, BN_value_one()) != 0) { + DSAerror(DSA_R_INVALID_PARAMETERS); goto err; } @@ -561,12 +558,14 @@ old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) goto err; } + BN_CTX_end(ctx); BN_CTX_free(ctx); EVP_PKEY_assign_DSA(pkey, dsa); return 1; err: + BN_CTX_end(ctx); BN_CTX_free(ctx); DSA_free(dsa); return 0; diff --git a/crypto/dsa/dsa_asn1.c b/crypto/dsa/dsa_asn1.c index 47e544c9..f6c66cec 100644 --- a/crypto/dsa/dsa_asn1.c +++ b/crypto/dsa/dsa_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_asn1.c,v 1.25 2022/09/03 16:01:23 jsing Exp $ */ +/* $OpenBSD: dsa_asn1.c,v 1.29 2023/03/07 09:27:10 jsing Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -64,7 +64,7 @@ #include #include -#include "dsa_locl.h" +#include "dsa_local.h" /* Override the default new methods */ static int @@ -147,9 +147,9 @@ DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s) if (r == NULL || s == NULL) return 0; - BN_clear_free(sig->r); + BN_free(sig->r); sig->r = r; - BN_clear_free(sig->s); + BN_free(sig->s); sig->s = s; return 1; @@ -399,18 +399,27 @@ DSAparams_dup(DSA *dsa) int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, - unsigned int *siglen, DSA *dsa) + unsigned int *out_siglen, DSA *dsa) { DSA_SIG *s; + int siglen; + int ret = 0; - s = DSA_do_sign(dgst, dlen, dsa); - if (s == NULL) { - *siglen = 0; - return 0; - } - *siglen = i2d_DSA_SIG(s,&sig); + *out_siglen = 0; + + if ((s = DSA_do_sign(dgst, dlen, dsa)) == NULL) + goto err; + + if ((siglen = i2d_DSA_SIG(s, &sig)) < 0) + goto err; + + *out_siglen = siglen; + + ret = 1; + err: DSA_SIG_free(s); - return 1; + + return ret; } /* @@ -424,24 +433,26 @@ int DSA_verify(int type, const unsigned char *dgst, int dgst_len, const unsigned char *sigbuf, int siglen, DSA *dsa) { - DSA_SIG *s; + DSA_SIG *s = NULL; unsigned char *der = NULL; - const unsigned char *p = sigbuf; - int derlen = -1; + const unsigned char *p; int ret = -1; - s = DSA_SIG_new(); - if (s == NULL) - return ret; - if (d2i_DSA_SIG(&s, &p, siglen) == NULL) + p = sigbuf; + if ((s = d2i_DSA_SIG(NULL, &p, siglen)) == NULL) goto err; + /* Ensure signature uses DER and doesn't have trailing garbage */ - derlen = i2d_DSA_SIG(s, &der); - if (derlen != siglen || memcmp(sigbuf, der, derlen)) + if (i2d_DSA_SIG(s, &der) != siglen) goto err; + + if (memcmp(der, sigbuf, siglen) != 0) + goto err; + ret = DSA_do_verify(dgst, dgst_len, s, dsa); -err: - freezero(der, derlen); + err: + free(der); DSA_SIG_free(s); + return ret; } diff --git a/crypto/dsa/dsa_depr.c b/crypto/dsa/dsa_depr.c index 673e7000..790db668 100644 --- a/crypto/dsa/dsa_depr.c +++ b/crypto/dsa/dsa_depr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_depr.c,v 1.8 2021/12/04 16:08:32 tb Exp $ */ +/* $OpenBSD: dsa_depr.c,v 1.10 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -68,7 +68,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" #ifndef OPENSSL_NO_DEPRECATED DSA * diff --git a/crypto/dsa/dsa_err.c b/crypto/dsa/dsa_err.c index 494773c8..8f105a87 100644 --- a/crypto/dsa/dsa_err.c +++ b/crypto/dsa/dsa_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_err.c,v 1.16 2022/07/12 14:42:49 kn Exp $ */ +/* $OpenBSD: dsa_err.c,v 1.18 2023/03/04 20:47:04 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -7,7 +7,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -78,6 +78,7 @@ static ERR_STRING_DATA DSA_str_reasons[]= {ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"}, {ERR_REASON(DSA_R_DECODE_ERROR) ,"decode error"}, {ERR_REASON(DSA_R_INVALID_DIGEST_TYPE) ,"invalid digest type"}, +{ERR_REASON(DSA_R_INVALID_PARAMETERS) ,"invalid parameters"}, {ERR_REASON(DSA_R_MISSING_PARAMETERS) ,"missing parameters"}, {ERR_REASON(DSA_R_MODULUS_TOO_LARGE) ,"modulus too large"}, {ERR_REASON(DSA_R_NEED_NEW_SETUP_VALUES) ,"need new setup values"}, diff --git a/crypto/dsa/dsa_gen.c b/crypto/dsa/dsa_gen.c index b6bbb8ab..1f918941 100644 --- a/crypto/dsa/dsa_gen.c +++ b/crypto/dsa/dsa_gen.c @@ -1,25 +1,25 @@ -/* $OpenBSD: dsa_gen.c,v 1.24 2017/01/21 10:38:29 beck Exp $ */ +/* $OpenBSD: dsa_gen.c,v 1.27 2023/01/11 04:39:42 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -68,8 +68,8 @@ #include #include -#include "bn_lcl.h" -#include "dsa_locl.h" +#include "bn_local.h" +#include "dsa_local.h" int DSA_generate_parameters_ex(DSA *ret, int bits, const unsigned char *seed_in, @@ -135,18 +135,19 @@ dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, const EVP_MD *evpmd, * App. 2.2 of FIPS PUB 186 allows larger SEED, * but our internal buffers are restricted to 160 bits */ - if (seed_len > (size_t)qsize) + if (seed_len > (size_t)qsize) seed_len = qsize; if (seed_in != NULL) memcpy(seed, seed_in, seed_len); else if (seed_len != 0) goto err; - if ((mont=BN_MONT_CTX_new()) == NULL) + if ((mont = BN_MONT_CTX_new()) == NULL) goto err; - if ((ctx=BN_CTX_new()) == NULL) + if ((ctx = BN_CTX_new()) == NULL) goto err; + BN_CTX_start(ctx); if ((r0 = BN_CTX_get(ctx)) == NULL) @@ -348,11 +349,10 @@ dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, const EVP_MD *evpmd, if (seed_out != NULL) memcpy(seed_out, seed, qsize); } - if (ctx) { - BN_CTX_end(ctx); - BN_CTX_free(ctx); - } + BN_CTX_end(ctx); + BN_CTX_free(ctx); BN_MONT_CTX_free(mont); + return ok; } #endif diff --git a/crypto/dsa/dsa_key.c b/crypto/dsa/dsa_key.c index a5053ec2..890f991d 100644 --- a/crypto/dsa/dsa_key.c +++ b/crypto/dsa/dsa_key.c @@ -1,25 +1,25 @@ -/* $OpenBSD: dsa_key.c,v 1.30 2022/01/07 09:35:36 tb Exp $ */ +/* $OpenBSD: dsa_key.c,v 1.33 2023/01/11 04:35:26 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -66,8 +66,8 @@ #include #include -#include "bn_lcl.h" -#include "dsa_locl.h" +#include "bn_local.h" +#include "dsa_local.h" static int dsa_builtin_keygen(DSA *dsa); @@ -82,39 +82,38 @@ DSA_generate_key(DSA *dsa) static int dsa_builtin_keygen(DSA *dsa) { - int ok = 0; - BN_CTX *ctx = NULL; BIGNUM *pub_key = NULL, *priv_key = NULL; + BN_CTX *ctx = NULL; + int ok = 0; - if ((ctx = BN_CTX_new()) == NULL) + if ((priv_key = BN_new()) == NULL) + goto err; + if ((pub_key = BN_new()) == NULL) goto err; - if ((priv_key = dsa->priv_key) == NULL) { - if ((priv_key = BN_new()) == NULL) - goto err; - } + if ((ctx = BN_CTX_new()) == NULL) + goto err; if (!bn_rand_interval(priv_key, BN_value_one(), dsa->q)) goto err; - - if ((pub_key = dsa->pub_key) == NULL) { - if ((pub_key = BN_new()) == NULL) - goto err; - } - if (!BN_mod_exp_ct(pub_key, dsa->g, priv_key, dsa->p, ctx)) goto err; + BN_free(dsa->priv_key); dsa->priv_key = priv_key; + priv_key = NULL; + + BN_free(dsa->pub_key); dsa->pub_key = pub_key; + pub_key = NULL; + ok = 1; err: - if (dsa->pub_key == NULL) - BN_free(pub_key); - if (dsa->priv_key == NULL) - BN_free(priv_key); + BN_free(pub_key); + BN_free(priv_key); BN_CTX_free(ctx); + return ok; } #endif diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index 87994fe6..6986f9ad 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_lib.c,v 1.37 2022/08/31 13:28:39 tb Exp $ */ +/* $OpenBSD: dsa_lib.c,v 1.42 2023/03/11 15:29:03 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -75,7 +75,7 @@ #endif #include "dh_local.h" -#include "dsa_locl.h" +#include "dsa_local.h" static const DSA_METHOD *default_DSA_method = NULL; @@ -106,18 +106,18 @@ DSA_set_method(DSA *dsa, const DSA_METHOD *meth) * NB: The caller is specifically setting a method, so it's not up to us * to deal with which ENGINE it comes from. */ - const DSA_METHOD *mtmp; - mtmp = dsa->meth; - if (mtmp->finish) + const DSA_METHOD *mtmp; + mtmp = dsa->meth; + if (mtmp->finish) mtmp->finish(dsa); #ifndef OPENSSL_NO_ENGINE ENGINE_finish(dsa->engine); dsa->engine = NULL; #endif - dsa->meth = meth; - if (meth->init) + dsa->meth = meth; + if (meth->init) meth->init(dsa); - return 1; + return 1; } DSA * @@ -200,13 +200,13 @@ DSA_free(DSA *r) CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); - BN_clear_free(r->p); - BN_clear_free(r->q); - BN_clear_free(r->g); - BN_clear_free(r->pub_key); - BN_clear_free(r->priv_key); - BN_clear_free(r->kinv); - BN_clear_free(r->r); + BN_free(r->p); + BN_free(r->q); + BN_free(r->g); + BN_free(r->pub_key); + BN_free(r->priv_key); + BN_free(r->kinv); + BN_free(r->r); free(r); } @@ -423,3 +423,76 @@ DSA_bits(const DSA *dsa) { return BN_num_bits(dsa->p); } + +int +dsa_check_key(const DSA *dsa) +{ + int p_bits, q_bits; + + if (dsa->p == NULL || dsa->q == NULL || dsa->g == NULL) { + DSAerror(DSA_R_MISSING_PARAMETERS); + return 0; + } + + /* Checking that p and q are primes is expensive. Check they are odd. */ + if (!BN_is_odd(dsa->p) || !BN_is_odd(dsa->q)) { + DSAerror(DSA_R_INVALID_PARAMETERS); + return 0; + } + + /* FIPS 186-4: 1 < g < p. */ + if (BN_cmp(dsa->g, BN_value_one()) <= 0 || + BN_cmp(dsa->g, dsa->p) >= 0) { + DSAerror(DSA_R_INVALID_PARAMETERS); + return 0; + } + + /* We know p and g are positive. The next two checks imply q > 0. */ + if (BN_is_negative(dsa->q)) { + DSAerror(DSA_R_BAD_Q_VALUE); + return 0; + } + + /* FIPS 186-4 only allows three sizes for q. */ + q_bits = BN_num_bits(dsa->q); + if (q_bits != 160 && q_bits != 224 && q_bits != 256) { + DSAerror(DSA_R_BAD_Q_VALUE); + return 0; + } + + /* + * XXX - FIPS 186-4 only allows 1024, 2048, and 3072 bits for p. + * Cap the size to reduce DoS risks. Poor defaults make keys with + * incorrect p sizes >= 512 bits common, so only enforce a weak + * lower bound. + */ + p_bits = BN_num_bits(dsa->p); + if (p_bits > OPENSSL_DSA_MAX_MODULUS_BITS) { + DSAerror(DSA_R_MODULUS_TOO_LARGE); + return 0; + } + if (p_bits < 512) { + DSAerror(DSA_R_INVALID_PARAMETERS); + return 0; + } + + /* The public key must be in the multiplicative group (mod p). */ + if (dsa->pub_key != NULL) { + if (BN_cmp(dsa->pub_key, BN_value_one()) <= 0 || + BN_cmp(dsa->pub_key, dsa->p) >= 0) { + DSAerror(DSA_R_INVALID_PARAMETERS); + return 0; + } + } + + /* The private key must be nonzero and in GF(q). */ + if (dsa->priv_key != NULL) { + if (BN_cmp(dsa->priv_key, BN_value_one()) < 0 || + BN_cmp(dsa->priv_key, dsa->q) >= 0) { + DSAerror(DSA_R_INVALID_PARAMETERS); + return 0; + } + } + + return 1; +} diff --git a/crypto/dsa/dsa_locl.h b/crypto/dsa/dsa_local.h similarity index 97% rename from crypto/dsa/dsa_locl.h rename to crypto/dsa/dsa_local.h index f78ff818..a413db97 100644 --- a/crypto/dsa/dsa_locl.h +++ b/crypto/dsa/dsa_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_locl.h,v 1.6 2022/07/04 12:22:32 tb Exp $ */ +/* $OpenBSD: dsa_local.h,v 1.2 2023/03/04 20:54:52 tb Exp $ */ /* ==================================================================== * Copyright (c) 2007 The OpenSSL Project. All rights reserved. * @@ -115,4 +115,6 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, unsigned char *seed_out, int *counter_ret, unsigned long *h_ret, BN_GENCB *cb); +int dsa_check_key(const DSA *dsa); + __END_HIDDEN_DECLS diff --git a/crypto/dsa/dsa_meth.c b/crypto/dsa/dsa_meth.c index 40cd0593..392afb84 100644 --- a/crypto/dsa/dsa_meth.c +++ b/crypto/dsa/dsa_meth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_meth.c,v 1.5 2022/07/11 05:33:14 bcook Exp $ */ +/* $OpenBSD: dsa_meth.c,v 1.6 2022/11/26 16:08:52 tb Exp $ */ /* * Copyright (c) 2018 Theo Buehler * @@ -21,7 +21,7 @@ #include #include -#include "dsa_locl.h" +#include "dsa_local.h" DSA_METHOD * DSA_meth_new(const char *name, int flags) diff --git a/crypto/dsa/dsa_ossl.c b/crypto/dsa/dsa_ossl.c index c306fc2d..ece1026f 100644 --- a/crypto/dsa/dsa_ossl.c +++ b/crypto/dsa/dsa_ossl.c @@ -1,25 +1,25 @@ -/* $OpenBSD: dsa_ossl.c,v 1.44 2022/02/24 08:35:45 tb Exp $ */ +/* $OpenBSD: dsa_ossl.c,v 1.50 2023/03/04 21:30:23 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -66,8 +66,8 @@ #include #include -#include "bn_lcl.h" -#include "dsa_locl.h" +#include "bn_local.h" +#include "dsa_local.h" static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, @@ -92,31 +92,49 @@ DSA_OpenSSL(void) return &openssl_dsa_meth; } +/* + * Since DSA parameters are entirely arbitrary and checking them to be + * consistent is very expensive, we cannot do so on every sign operation. + * Instead, cap the number of retries so we do not loop indefinitely if + * the generator of the multiplicative group happens to be nilpotent. + * The probability of needing a retry with valid parameters is negligible, + * so trying 32 times is amply enough. + */ +#define DSA_MAX_SIGN_ITERATIONS 32 + static DSA_SIG * dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) { - BIGNUM b, bm, bxr, binv, m, *kinv = NULL, *r = NULL, *s = NULL; + BIGNUM *b = NULL, *bm = NULL, *bxr = NULL, *binv = NULL, *m = NULL; + BIGNUM *kinv = NULL, *r = NULL, *s = NULL; BN_CTX *ctx = NULL; int reason = ERR_R_BN_LIB; DSA_SIG *ret = NULL; + int attempts = 0; int noredo = 0; - BN_init(&b); - BN_init(&binv); - BN_init(&bm); - BN_init(&bxr); - BN_init(&m); - - if (!dsa->p || !dsa->q || !dsa->g) { - reason = DSA_R_MISSING_PARAMETERS; + if (!dsa_check_key(dsa)) { + reason = DSA_R_INVALID_PARAMETERS; goto err; } - s = BN_new(); - if (s == NULL) + if ((s = BN_new()) == NULL) goto err; - ctx = BN_CTX_new(); - if (ctx == NULL) + + if ((ctx = BN_CTX_new()) == NULL) + goto err; + + BN_CTX_start(ctx); + + if ((b = BN_CTX_get(ctx)) == NULL) + goto err; + if ((binv = BN_CTX_get(ctx)) == NULL) + goto err; + if ((bm = BN_CTX_get(ctx)) == NULL) + goto err; + if ((bxr = BN_CTX_get(ctx)) == NULL) + goto err; + if ((m = BN_CTX_get(ctx)) == NULL) goto err; /* @@ -126,7 +144,7 @@ dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) */ if (dlen > BN_num_bytes(dsa->q)) dlen = BN_num_bytes(dsa->q); - if (BN_bin2bn(dgst, dlen, &m) == NULL) + if (BN_bin2bn(dgst, dlen, m) == NULL) goto err; redo: @@ -153,22 +171,22 @@ dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) * * Where b is a random value in the range [1, q). */ - if (!bn_rand_interval(&b, BN_value_one(), dsa->q)) + if (!bn_rand_interval(b, BN_value_one(), dsa->q)) goto err; - if (BN_mod_inverse_ct(&binv, &b, dsa->q, ctx) == NULL) + if (BN_mod_inverse_ct(binv, b, dsa->q, ctx) == NULL) goto err; - if (!BN_mod_mul(&bxr, &b, dsa->priv_key, dsa->q, ctx)) /* bx */ + if (!BN_mod_mul(bxr, b, dsa->priv_key, dsa->q, ctx)) /* bx */ goto err; - if (!BN_mod_mul(&bxr, &bxr, r, dsa->q, ctx)) /* bxr */ + if (!BN_mod_mul(bxr, bxr, r, dsa->q, ctx)) /* bxr */ goto err; - if (!BN_mod_mul(&bm, &b, &m, dsa->q, ctx)) /* bm */ + if (!BN_mod_mul(bm, b, m, dsa->q, ctx)) /* bm */ goto err; - if (!BN_mod_add(s, &bxr, &bm, dsa->q, ctx)) /* s = bm + bxr */ + if (!BN_mod_add(s, bxr, bm, dsa->q, ctx)) /* s = bm + bxr */ goto err; if (!BN_mod_mul(s, s, kinv, dsa->q, ctx)) /* s = b(m + xr)k^-1 */ goto err; - if (!BN_mod_mul(s, s, &binv, dsa->q, ctx)) /* s = (m + xr)k^-1 */ + if (!BN_mod_mul(s, s, binv, dsa->q, ctx)) /* s = (m + xr)k^-1 */ goto err; /* @@ -180,6 +198,10 @@ dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) reason = DSA_R_NEED_NEW_SETUP_VALUES; goto err; } + if (++attempts > DSA_MAX_SIGN_ITERATIONS) { + reason = DSA_R_INVALID_PARAMETERS; + goto err; + } goto redo; } @@ -189,20 +211,16 @@ dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) } ret->r = r; ret->s = s; - + err: if (!ret) { DSAerror(reason); BN_free(r); BN_free(s); } + BN_CTX_end(ctx); BN_CTX_free(ctx); - BN_clear_free(&b); - BN_clear_free(&bm); - BN_clear_free(&bxr); - BN_clear_free(&binv); - BN_clear_free(&m); - BN_clear_free(kinv); + BN_free(kinv); return ret; } @@ -210,39 +228,42 @@ dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) { - BN_CTX *ctx; - BIGNUM k, l, m, *kinv = NULL, *r = NULL; - int q_bits, ret = 0; + BIGNUM *k = NULL, *l = NULL, *m = NULL, *kinv = NULL, *r = NULL; + BN_CTX *ctx = NULL; + int q_bits; + int ret = 0; - if (!dsa->p || !dsa->q || !dsa->g) { - DSAerror(DSA_R_MISSING_PARAMETERS); - return 0; - } + if (!dsa_check_key(dsa)) + goto err; - BN_init(&k); - BN_init(&l); - BN_init(&m); + if ((r = BN_new()) == NULL) + goto err; - if (ctx_in == NULL) { - if ((ctx = BN_CTX_new()) == NULL) - goto err; - } else - ctx = ctx_in; + if ((ctx = ctx_in) == NULL) + ctx = BN_CTX_new(); + if (ctx == NULL) + goto err; - if ((r = BN_new()) == NULL) + BN_CTX_start(ctx); + + if ((k = BN_CTX_get(ctx)) == NULL) + goto err; + if ((l = BN_CTX_get(ctx)) == NULL) + goto err; + if ((m = BN_CTX_get(ctx)) == NULL) goto err; /* Preallocate space */ q_bits = BN_num_bits(dsa->q); - if (!BN_set_bit(&k, q_bits) || - !BN_set_bit(&l, q_bits) || - !BN_set_bit(&m, q_bits)) + if (!BN_set_bit(k, q_bits) || + !BN_set_bit(l, q_bits) || + !BN_set_bit(m, q_bits)) goto err; - if (!bn_rand_interval(&k, BN_value_one(), dsa->q)) + if (!bn_rand_interval(k, BN_value_one(), dsa->q)) goto err; - BN_set_flags(&k, BN_FLG_CONSTTIME); + BN_set_flags(k, BN_FLG_CONSTTIME); if (dsa->flags & DSA_FLAG_CACHE_MONT_P) { if (!BN_MONT_CTX_set_locked(&dsa->method_mont_p, @@ -265,17 +286,17 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) * conditional copy. */ - if (!BN_add(&l, &k, dsa->q) || - !BN_add(&m, &l, dsa->q) || - !BN_copy(&k, BN_num_bits(&l) > q_bits ? &l : &m)) + if (!BN_add(l, k, dsa->q) || + !BN_add(m, l, dsa->q) || + !BN_copy(k, BN_num_bits(l) > q_bits ? l : m)) goto err; if (dsa->meth->bn_mod_exp != NULL) { - if (!dsa->meth->bn_mod_exp(dsa, r, dsa->g, &k, dsa->p, ctx, + if (!dsa->meth->bn_mod_exp(dsa, r, dsa->g, k, dsa->p, ctx, dsa->method_mont_p)) goto err; } else { - if (!BN_mod_exp_mont_ct(r, dsa->g, &k, dsa->p, ctx, + if (!BN_mod_exp_mont_ct(r, dsa->g, k, dsa->p, ctx, dsa->method_mont_p)) goto err; } @@ -284,13 +305,14 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) goto err; /* Compute part of 's = inv(k) (m + xr) mod q' */ - if ((kinv = BN_mod_inverse_ct(NULL, &k, dsa->q, ctx)) == NULL) + if ((kinv = BN_mod_inverse_ct(NULL, k, dsa->q, ctx)) == NULL) goto err; - BN_clear_free(*kinvp); + BN_free(*kinvp); *kinvp = kinv; kinv = NULL; - BN_clear_free(*rp); + + BN_free(*rp); *rp = r; ret = 1; @@ -298,13 +320,11 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) err: if (!ret) { DSAerror(ERR_R_BN_LIB); - BN_clear_free(r); + BN_free(r); } - if (ctx_in == NULL) + BN_CTX_end(ctx); + if (ctx != ctx_in) BN_CTX_free(ctx); - BN_clear_free(&k); - BN_clear_free(&l); - BN_clear_free(&m); return ret; } @@ -312,33 +332,25 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) { - BN_CTX *ctx; - BIGNUM u1, u2, t1; + BIGNUM *u1 = NULL, *u2 = NULL, *t1 = NULL; + BN_CTX *ctx = NULL; BN_MONT_CTX *mont = NULL; int qbits; int ret = -1; - if (!dsa->p || !dsa->q || !dsa->g) { - DSAerror(DSA_R_MISSING_PARAMETERS); - return -1; - } + if (!dsa_check_key(dsa)) + goto err; - /* FIPS 186-3 allows only three different sizes for q. */ - qbits = BN_num_bits(dsa->q); - if (qbits != 160 && qbits != 224 && qbits != 256) { - DSAerror(DSA_R_BAD_Q_VALUE); - return -1; - } - if (BN_num_bits(dsa->p) > OPENSSL_DSA_MAX_MODULUS_BITS) { - DSAerror(DSA_R_MODULUS_TOO_LARGE); - return -1; - } + if ((ctx = BN_CTX_new()) == NULL) + goto err; - BN_init(&u1); - BN_init(&u2); - BN_init(&t1); + BN_CTX_start(ctx); - if ((ctx = BN_CTX_new()) == NULL) + if ((u1 = BN_CTX_get(ctx)) == NULL) + goto err; + if ((u2 = BN_CTX_get(ctx)) == NULL) + goto err; + if ((t1 = BN_CTX_get(ctx)) == NULL) goto err; if (BN_is_zero(sig->r) || BN_is_negative(sig->r) || @@ -353,26 +365,27 @@ dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) } /* Calculate w = inv(s) mod q, saving w in u2. */ - if ((BN_mod_inverse_ct(&u2, sig->s, dsa->q, ctx)) == NULL) + if ((BN_mod_inverse_ct(u2, sig->s, dsa->q, ctx)) == NULL) goto err; /* * If the digest length is greater than the size of q use the - * BN_num_bits(dsa->q) leftmost bits of the digest, see FIPS 186-3, 4.2. + * BN_num_bits(dsa->q) leftmost bits of the digest, see FIPS 186-4, 4.2. */ + qbits = BN_num_bits(dsa->q); if (dgst_len > (qbits >> 3)) dgst_len = (qbits >> 3); /* Save m in u1. */ - if (BN_bin2bn(dgst, dgst_len, &u1) == NULL) + if (BN_bin2bn(dgst, dgst_len, u1) == NULL) goto err; /* u1 = m * w mod q */ - if (!BN_mod_mul(&u1, &u1, &u2, dsa->q, ctx)) + if (!BN_mod_mul(u1, u1, u2, dsa->q, ctx)) goto err; /* u2 = r * w mod q */ - if (!BN_mod_mul(&u2, sig->r, &u2, dsa->q, ctx)) + if (!BN_mod_mul(u2, sig->r, u2, dsa->q, ctx)) goto err; if (dsa->flags & DSA_FLAG_CACHE_MONT_P) { @@ -383,30 +396,27 @@ dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) } if (dsa->meth->dsa_mod_exp != NULL) { - if (!dsa->meth->dsa_mod_exp(dsa, &t1, dsa->g, &u1, dsa->pub_key, - &u2, dsa->p, ctx, mont)) + if (!dsa->meth->dsa_mod_exp(dsa, t1, dsa->g, u1, dsa->pub_key, + u2, dsa->p, ctx, mont)) goto err; } else { - if (!BN_mod_exp2_mont(&t1, dsa->g, &u1, dsa->pub_key, &u2, + if (!BN_mod_exp2_mont(t1, dsa->g, u1, dsa->pub_key, u2, dsa->p, ctx, mont)) goto err; } - /* BN_copy(&u1,&t1); */ /* let u1 = u1 mod q */ - if (!BN_mod_ct(&u1, &t1, dsa->q, ctx)) + if (!BN_mod_ct(u1, t1, dsa->q, ctx)) goto err; /* v is in u1 - if the signature is correct, it will be equal to r. */ - ret = BN_ucmp(&u1, sig->r) == 0; + ret = BN_ucmp(u1, sig->r) == 0; err: if (ret < 0) DSAerror(ERR_R_BN_LIB); + BN_CTX_end(ctx); BN_CTX_free(ctx); - BN_free(&u1); - BN_free(&u2); - BN_free(&t1); return ret; } @@ -425,3 +435,37 @@ dsa_finish(DSA *dsa) return 1; } +DSA_SIG * +DSA_SIG_new(void) +{ + return calloc(1, sizeof(DSA_SIG)); +} + +void +DSA_SIG_free(DSA_SIG *sig) +{ + if (sig == NULL) + return; + + BN_free(sig->r); + BN_free(sig->s); + free(sig); +} + +int +DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) +{ + return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); +} + +DSA_SIG * +DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) +{ + return dsa->meth->dsa_do_sign(dgst, dlen, dsa); +} + +int +DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) +{ + return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); +} diff --git a/crypto/dsa/dsa_pmeth.c b/crypto/dsa/dsa_pmeth.c index ef89e2be..66f4ddbe 100644 --- a/crypto/dsa/dsa_pmeth.c +++ b/crypto/dsa/dsa_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_pmeth.c,v 1.13 2021/12/04 16:08:32 tb Exp $ */ +/* $OpenBSD: dsa_pmeth.c,v 1.16 2022/11/26 16:08:52 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -66,9 +66,9 @@ #include #include -#include "bn_lcl.h" -#include "dsa_locl.h" -#include "evp_locl.h" +#include "bn_local.h" +#include "dsa_local.h" +#include "evp_local.h" /* DSA pkey context structure */ @@ -99,7 +99,7 @@ pkey_dsa_init(EVP_PKEY_CTX *ctx) ctx->data = dctx; ctx->keygen_info = dctx->gentmp; ctx->keygen_info_count = 2; - + return 1; } @@ -110,7 +110,7 @@ pkey_dsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) if (!pkey_dsa_init(dst)) return 0; - sctx = src->data; + sctx = src->data; dctx = dst->data; dctx->nbits = sctx->nbits; dctx->qbits = sctx->qbits; @@ -128,24 +128,28 @@ pkey_dsa_cleanup(EVP_PKEY_CTX *ctx) } static int -pkey_dsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, +pkey_dsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *out_siglen, const unsigned char *tbs, size_t tbslen) { - int ret, type; - unsigned int sltmp; - DSA_PKEY_CTX *dctx = ctx->data; DSA *dsa = ctx->pkey->pkey.dsa; + DSA_PKEY_CTX *dctx = ctx->data; + unsigned int siglen; - if (dctx->md) - type = EVP_MD_type(dctx->md); - else - type = NID_sha1; + *out_siglen = 0; + + if (tbslen > INT_MAX) + return 0; + + if (dctx->md != NULL) { + if (tbslen != EVP_MD_size(dctx->md)) + return 0; + } + + if (!DSA_sign(0, tbs, tbslen, sig, &siglen, dsa)) + return 0; - ret = DSA_sign(type, tbs, tbslen, sig, &sltmp, dsa); + *out_siglen = siglen; - if (ret <= 0) - return ret; - *siglen = sltmp; return 1; } @@ -153,18 +157,18 @@ static int pkey_dsa_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, size_t tbslen) { - int ret, type; - DSA_PKEY_CTX *dctx = ctx->data; DSA *dsa = ctx->pkey->pkey.dsa; + DSA_PKEY_CTX *dctx = ctx->data; - if (dctx->md) - type = EVP_MD_type(dctx->md); - else - type = NID_sha1; + if (tbslen > INT_MAX || siglen > INT_MAX) + return 0; - ret = DSA_verify(type, tbs, tbslen, sig, siglen, dsa); + if (dctx->md != NULL) { + if (tbslen != EVP_MD_size(dctx->md)) + return 0; + } - return ret; + return DSA_verify(0, tbs, tbslen, sig, siglen, dsa); } static int @@ -223,19 +227,19 @@ pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) case EVP_PKEY_CTRL_PKCS7_SIGN: case EVP_PKEY_CTRL_CMS_SIGN: return 1; - + case EVP_PKEY_CTRL_PEER_KEY: DSAerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); - return -2; + return -2; default: return -2; } } - + static int pkey_dsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { - long lval; + long lval; char *ep; if (!strcmp(type, "dsa_paramgen_bits")) { @@ -268,7 +272,7 @@ pkey_dsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) qbits, NULL); } else if (!strcmp(type, "dsa_paramgen_md")) { return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, - EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, + EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)EVP_get_digestbyname(value)); } not_a_number: diff --git a/crypto/dsa/dsa_prn.c b/crypto/dsa/dsa_prn.c index fb5e35f9..4ed656a0 100644 --- a/crypto/dsa/dsa_prn.c +++ b/crypto/dsa/dsa_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_prn.c,v 1.6 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: dsa_prn.c,v 1.9 2022/11/19 06:33:00 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -98,12 +98,16 @@ int DSA_print(BIO *bp, const DSA *x, int off) { EVP_PKEY *pk; - int ret; + int ret = 0; + + if ((pk = EVP_PKEY_new()) == NULL) + goto err; + + if (!EVP_PKEY_set1_DSA(pk, (DSA *)x)) + goto err; - pk = EVP_PKEY_new(); - if (!pk || !EVP_PKEY_set1_DSA(pk, (DSA *)x)) - return 0; ret = EVP_PKEY_print_private(bp, pk, off, NULL); + err: EVP_PKEY_free(pk); return ret; } @@ -112,12 +116,16 @@ int DSAparams_print(BIO *bp, const DSA *x) { EVP_PKEY *pk; - int ret; + int ret = 0; + + if ((pk = EVP_PKEY_new()) == NULL) + goto err; + + if (!EVP_PKEY_set1_DSA(pk, (DSA *)x)) + goto err; - pk = EVP_PKEY_new(); - if (!pk || !EVP_PKEY_set1_DSA(pk, (DSA *)x)) - return 0; ret = EVP_PKEY_print_params(bp, pk, 4, NULL); + err: EVP_PKEY_free(pk); return ret; } diff --git a/crypto/dsa/dsa_sign.c b/crypto/dsa/dsa_sign.c deleted file mode 100644 index b1fc1dbb..00000000 --- a/crypto/dsa/dsa_sign.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $OpenBSD: dsa_sign.c,v 1.21 2022/01/07 09:35:36 tb Exp $ */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -/* Original version from Steven Schoch */ - -#include -#include - -#include "dsa_locl.h" - -DSA_SIG * -DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) -{ - return dsa->meth->dsa_do_sign(dgst, dlen, dsa); -} - -int -DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) -{ - return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); -} - -DSA_SIG * -DSA_SIG_new(void) -{ - return calloc(1, sizeof(DSA_SIG)); -} - -void -DSA_SIG_free(DSA_SIG *sig) -{ - if (sig != NULL) { - BN_free(sig->r); - BN_free(sig->s); - free(sig); - } -} diff --git a/crypto/dsa/dsa_vrf.c b/crypto/dsa/dsa_vrf.c deleted file mode 100644 index 38f8450e..00000000 --- a/crypto/dsa/dsa_vrf.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $OpenBSD: dsa_vrf.c,v 1.17 2022/01/07 09:35:36 tb Exp $ */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -/* Original version from Steven Schoch */ - -#include - -#include "dsa_locl.h" - -int -DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) -{ - return dsa->meth->dsa_do_verify(dgst, dgst_len, sig, dsa); -} diff --git a/crypto/ec/ec2_mult.c b/crypto/ec/ec2_mult.c index 3e5d1dca..8b8aaf71 100644 --- a/crypto/ec/ec2_mult.c +++ b/crypto/ec/ec2_mult.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_mult.c,v 1.13 2018/07/23 18:24:22 tb Exp $ */ +/* $OpenBSD: ec2_mult.c,v 1.15 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -71,8 +71,8 @@ #include -#include "bn_lcl.h" -#include "ec_lcl.h" +#include "bn_local.h" +#include "ec_local.h" #ifndef OPENSSL_NO_EC2M @@ -441,13 +441,13 @@ ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, * because ec_GF2m_simple_mul() uses ec_wNAF_mul() if appropriate */ int -ec_GF2m_precompute_mult(EC_GROUP * group, BN_CTX * ctx) +ec_GF2m_precompute_mult(EC_GROUP *group, BN_CTX *ctx) { return ec_wNAF_precompute_mult(group, ctx); } int -ec_GF2m_have_precompute_mult(const EC_GROUP * group) +ec_GF2m_have_precompute_mult(const EC_GROUP *group) { return ec_wNAF_have_precompute_mult(group); } diff --git a/crypto/ec/ec2_oct.c b/crypto/ec/ec2_oct.c index 832083c6..d3fbc127 100644 --- a/crypto/ec/ec2_oct.c +++ b/crypto/ec/ec2_oct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_oct.c,v 1.16 2021/05/03 14:42:45 tb Exp $ */ +/* $OpenBSD: ec2_oct.c,v 1.19 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -71,7 +71,7 @@ #include -#include "ec_lcl.h" +#include "ec_local.h" #ifndef OPENSSL_NO_EC2M @@ -90,7 +90,7 @@ * the same method, but claim no priority date earlier than July 29, 1994 * (and additionally fail to cite the EUROCRYPT '92 publication as prior art). */ -int +int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point, const BIGNUM *x_, int y_bit, BN_CTX *ctx) { @@ -172,10 +172,10 @@ ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point * If buf is NULL, the encoded length will be returned. * If the length len of buf is smaller than required an error will be returned. */ -size_t +size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, - unsigned char *buf, size_t len, BN_CTX * ctx) + unsigned char *buf, size_t len, BN_CTX *ctx) { size_t ret; BN_CTX *new_ctx = NULL; diff --git a/crypto/ec/ec2_smpl.c b/crypto/ec/ec2_smpl.c index 9f3b380b..84cba1b8 100644 --- a/crypto/ec/ec2_smpl.c +++ b/crypto/ec/ec2_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_smpl.c,v 1.23 2021/09/08 17:29:21 tb Exp $ */ +/* $OpenBSD: ec2_smpl.c,v 1.33 2023/03/08 05:45:31 jsing Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -71,63 +71,16 @@ #include -#include "ec_lcl.h" +#include "ec_local.h" #ifndef OPENSSL_NO_EC2M -const EC_METHOD * -EC_GF2m_simple_method(void) -{ - static const EC_METHOD ret = { - .flags = EC_FLAGS_DEFAULT_OCT, - .field_type = NID_X9_62_characteristic_two_field, - .group_init = ec_GF2m_simple_group_init, - .group_finish = ec_GF2m_simple_group_finish, - .group_clear_finish = ec_GF2m_simple_group_clear_finish, - .group_copy = ec_GF2m_simple_group_copy, - .group_set_curve = ec_GF2m_simple_group_set_curve, - .group_get_curve = ec_GF2m_simple_group_get_curve, - .group_get_degree = ec_GF2m_simple_group_get_degree, - .group_order_bits = ec_group_simple_order_bits, - .group_check_discriminant = - ec_GF2m_simple_group_check_discriminant, - .point_init = ec_GF2m_simple_point_init, - .point_finish = ec_GF2m_simple_point_finish, - .point_clear_finish = ec_GF2m_simple_point_clear_finish, - .point_copy = ec_GF2m_simple_point_copy, - .point_set_to_infinity = ec_GF2m_simple_point_set_to_infinity, - .point_set_affine_coordinates = - ec_GF2m_simple_point_set_affine_coordinates, - .point_get_affine_coordinates = - ec_GF2m_simple_point_get_affine_coordinates, - .add = ec_GF2m_simple_add, - .dbl = ec_GF2m_simple_dbl, - .invert = ec_GF2m_simple_invert, - .is_at_infinity = ec_GF2m_simple_is_at_infinity, - .is_on_curve = ec_GF2m_simple_is_on_curve, - .point_cmp = ec_GF2m_simple_cmp, - .make_affine = ec_GF2m_simple_make_affine, - .points_make_affine = ec_GF2m_simple_points_make_affine, - .mul_generator_ct = ec_GFp_simple_mul_generator_ct, - .mul_single_ct = ec_GFp_simple_mul_single_ct, - .mul_double_nonct = ec_GFp_simple_mul_double_nonct, - .precompute_mult = ec_GF2m_precompute_mult, - .have_precompute_mult = ec_GF2m_have_precompute_mult, - .field_mul = ec_GF2m_simple_field_mul, - .field_sqr = ec_GF2m_simple_field_sqr, - .field_div = ec_GF2m_simple_field_div, - .blind_coordinates = NULL, - }; - - return &ret; -} - - -/* Initialize a GF(2^m)-based EC_GROUP structure. +/* + * Initialize a GF(2^m)-based EC_GROUP structure. * Note that all other members are handled by EC_GROUP_new. */ -int -ec_GF2m_simple_group_init(EC_GROUP * group) +static int +ec_GF2m_simple_group_init(EC_GROUP *group) { BN_init(&group->field); BN_init(&group->a); @@ -135,28 +88,16 @@ ec_GF2m_simple_group_init(EC_GROUP * group) return 1; } - -/* Free a GF(2^m)-based EC_GROUP structure. +/* + * Clear and free a GF(2^m)-based EC_GROUP structure. * Note that all other members are handled by EC_GROUP_free. */ -void -ec_GF2m_simple_group_finish(EC_GROUP * group) +static void +ec_GF2m_simple_group_finish(EC_GROUP *group) { BN_free(&group->field); BN_free(&group->a); BN_free(&group->b); -} - - -/* Clear and free a GF(2^m)-based EC_GROUP structure. - * Note that all other members are handled by EC_GROUP_clear_free. - */ -void -ec_GF2m_simple_group_clear_finish(EC_GROUP * group) -{ - BN_clear_free(&group->field); - BN_clear_free(&group->a); - BN_clear_free(&group->b); group->poly[0] = 0; group->poly[1] = 0; group->poly[2] = 0; @@ -165,12 +106,12 @@ ec_GF2m_simple_group_clear_finish(EC_GROUP * group) group->poly[5] = -1; } - -/* Copy a GF(2^m)-based EC_GROUP structure. +/* + * Copy a GF(2^m)-based EC_GROUP structure. * Note that all other members are handled by EC_GROUP_copy. */ -int -ec_GF2m_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) +static int +ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) { int i; @@ -186,9 +127,9 @@ ec_GF2m_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) dest->poly[3] = src->poly[3]; dest->poly[4] = src->poly[4]; dest->poly[5] = src->poly[5]; - if (bn_wexpand(&dest->a, (int) (dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) + if (!bn_expand(&dest->a, dest->poly[0])) return 0; - if (bn_wexpand(&dest->b, (int) (dest->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) + if (!bn_expand(&dest->b, dest->poly[0])) return 0; for (i = dest->a.top; i < dest->a.dmax; i++) dest->a.d[i] = 0; @@ -197,11 +138,10 @@ ec_GF2m_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) return 1; } - /* Set the curve parameters of an EC_GROUP structure. */ -int -ec_GF2m_simple_group_set_curve(EC_GROUP * group, - const BIGNUM * p, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) +static int +ec_GF2m_simple_group_set_curve(EC_GROUP *group, + const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { int ret = 0, i; @@ -216,7 +156,7 @@ ec_GF2m_simple_group_set_curve(EC_GROUP * group, /* group->a */ if (!BN_GF2m_mod_arr(&group->a, a, group->poly)) goto err; - if (bn_wexpand(&group->a, (int) (group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) + if (!bn_expand(&group->a, group->poly[0])) goto err; for (i = group->a.top; i < group->a.dmax; i++) group->a.d[i] = 0; @@ -224,7 +164,7 @@ ec_GF2m_simple_group_set_curve(EC_GROUP * group, /* group->b */ if (!BN_GF2m_mod_arr(&group->b, b, group->poly)) goto err; - if (bn_wexpand(&group->b, (int) (group->poly[0] + BN_BITS2 - 1) / BN_BITS2) == NULL) + if (!bn_expand(&group->b, group->poly[0])) goto err; for (i = group->b.top; i < group->b.dmax; i++) group->b.d[i] = 0; @@ -234,11 +174,11 @@ ec_GF2m_simple_group_set_curve(EC_GROUP * group, return ret; } - -/* Get the curve parameters of an EC_GROUP structure. +/* + * Get the curve parameters of an EC_GROUP structure. * If p, a, or b are NULL then there values will not be set but the method will return with success. */ -int +static int ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) { @@ -262,20 +202,19 @@ ec_GF2m_simple_group_get_curve(const EC_GROUP *group, return ret; } - /* Gets the degree of the field. For a curve over GF(2^m) this is the value m. */ -int -ec_GF2m_simple_group_get_degree(const EC_GROUP * group) +static int +ec_GF2m_simple_group_get_degree(const EC_GROUP *group) { return BN_num_bits(&group->field) - 1; } - -/* Checks the discriminant of the curve. +/* + * Checks the discriminant of the curve. * y^2 + x*y = x^3 + a*x^2 + b is an elliptic curve <=> b != 0 (mod p) */ -int -ec_GF2m_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) +static int +ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) { int ret = 0; BIGNUM *b; @@ -311,10 +250,9 @@ ec_GF2m_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) return ret; } - /* Initializes an EC_POINT. */ -int -ec_GF2m_simple_point_init(EC_POINT * point) +static int +ec_GF2m_simple_point_init(EC_POINT *point) { BN_init(&point->X); BN_init(&point->Y); @@ -322,31 +260,19 @@ ec_GF2m_simple_point_init(EC_POINT * point) return 1; } - -/* Frees an EC_POINT. */ -void -ec_GF2m_simple_point_finish(EC_POINT * point) +/* Clears and frees an EC_POINT. */ +static void +ec_GF2m_simple_point_finish(EC_POINT *point) { BN_free(&point->X); BN_free(&point->Y); BN_free(&point->Z); -} - - -/* Clears and frees an EC_POINT. */ -void -ec_GF2m_simple_point_clear_finish(EC_POINT * point) -{ - BN_clear_free(&point->X); - BN_clear_free(&point->Y); - BN_clear_free(&point->Z); point->Z_is_one = 0; } - /* Copy the contents of one EC_POINT into another. Assumes dest is initialized. */ -int -ec_GF2m_simple_point_copy(EC_POINT * dest, const EC_POINT * src) +static int +ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src) { if (!BN_copy(&dest->X, &src->X)) return 0; @@ -359,25 +285,25 @@ ec_GF2m_simple_point_copy(EC_POINT * dest, const EC_POINT * src) return 1; } - -/* Set an EC_POINT to the point at infinity. +/* + * Set an EC_POINT to the point at infinity. * A point at infinity is represented by having Z=0. */ -int -ec_GF2m_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point) +static int +ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point) { point->Z_is_one = 0; BN_zero(&point->Z); return 1; } - -/* Set the coordinates of an EC_POINT using affine coordinates. +/* + * Set the coordinates of an EC_POINT using affine coordinates. * Note that the simple implementation only uses affine coordinates. */ -int -ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * point, - const BIGNUM * x, const BIGNUM * y, BN_CTX * ctx) +static int +ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx) { int ret = 0; if (x == NULL || y == NULL) { @@ -400,11 +326,11 @@ ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * p return ret; } - -/* Gets the affine coordinates of an EC_POINT. +/* + * Gets the affine coordinates of an EC_POINT. * Note that the simple implementation only uses affine coordinates. */ -int +static int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx) { @@ -434,10 +360,11 @@ ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, return ret; } -/* Computes a + b and stores the result in r. r could be a or b, a could be b. +/* + * Computes a + b and stores the result in r. r could be a or b, a could be b. * Uses algorithm A.10.2 of IEEE P1363. */ -int +static int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) { @@ -497,7 +424,6 @@ ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, goto err; } - if (BN_GF2m_cmp(x0, x1)) { if (!BN_GF2m_add(t, x0, x1)) goto err; @@ -553,18 +479,18 @@ ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, return ret; } - -/* Computes 2 * a and stores the result in r. r could be a. +/* + * Computes 2 * a and stores the result in r. r could be a. * Uses algorithm A.10.2 of IEEE P1363. */ -int +static int ec_GF2m_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx) { return ec_GF2m_simple_add(group, r, a, a, ctx); } -int +static int ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) { if (EC_POINT_is_at_infinity(group, point) > 0 || BN_is_zero(&point->Y)) @@ -576,20 +502,19 @@ ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) return BN_GF2m_add(&point->Y, &point->X, &point->Y); } - /* Indicates whether the given point is the point at infinity. */ -int +static int ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) { return BN_is_zero(&point->Z); } - -/* Determines whether the given EC_POINT is an actual point on the curve defined +/* + * Determines whether the given EC_POINT is an actual point on the curve defined * in the EC_GROUP. A point is valid if it satisfies the Weierstrass equation: * y^2 + x*y = x^3 + a*x^2 + b. */ -int +static int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) { int ret = -1; @@ -646,14 +571,14 @@ ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX return ret; } - -/* Indicates whether two points are equal. +/* + * Indicates whether two points are equal. * Return values: * -1 error * 0 equal (in affine coordinates) * 1 not equal */ -int +static int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) { @@ -698,10 +623,9 @@ ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, return ret; } - /* Forces the given EC_POINT to internally use affine coordinates. */ -int -ec_GF2m_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) +static int +ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) { BN_CTX *new_ctx = NULL; BIGNUM *x, *y; @@ -739,9 +663,8 @@ ec_GF2m_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ct return ret; } - /* Forces each of the EC_POINTs in the given array to use affine coordinates. */ -int +static int ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx) { @@ -755,31 +678,74 @@ ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, return 1; } - /* Wrapper to simple binary polynomial field multiplication implementation. */ -int +static int ec_GF2m_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { return BN_GF2m_mod_mul_arr(r, a, b, group->poly, ctx); } - /* Wrapper to simple binary polynomial field squaring implementation. */ -int +static int ec_GF2m_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { return BN_GF2m_mod_sqr_arr(r, a, group->poly, ctx); } - /* Wrapper to simple binary polynomial field division implementation. */ -int +static int ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { return BN_GF2m_mod_div(r, a, b, &group->field, ctx); } +static const EC_METHOD ec_GF2m_simple_method = { + .field_type = NID_X9_62_characteristic_two_field, + .group_init = ec_GF2m_simple_group_init, + .group_finish = ec_GF2m_simple_group_finish, + .group_copy = ec_GF2m_simple_group_copy, + .group_set_curve = ec_GF2m_simple_group_set_curve, + .group_get_curve = ec_GF2m_simple_group_get_curve, + .group_get_degree = ec_GF2m_simple_group_get_degree, + .group_order_bits = ec_group_simple_order_bits, + .group_check_discriminant = ec_GF2m_simple_group_check_discriminant, + .point_init = ec_GF2m_simple_point_init, + .point_finish = ec_GF2m_simple_point_finish, + .point_copy = ec_GF2m_simple_point_copy, + .point_set_to_infinity = ec_GF2m_simple_point_set_to_infinity, + .point_set_affine_coordinates = + ec_GF2m_simple_point_set_affine_coordinates, + .point_get_affine_coordinates = + ec_GF2m_simple_point_get_affine_coordinates, + .point_set_compressed_coordinates = + ec_GF2m_simple_set_compressed_coordinates, + .point2oct = ec_GF2m_simple_point2oct, + .oct2point = ec_GF2m_simple_oct2point, + .add = ec_GF2m_simple_add, + .dbl = ec_GF2m_simple_dbl, + .invert = ec_GF2m_simple_invert, + .is_at_infinity = ec_GF2m_simple_is_at_infinity, + .is_on_curve = ec_GF2m_simple_is_on_curve, + .point_cmp = ec_GF2m_simple_cmp, + .make_affine = ec_GF2m_simple_make_affine, + .points_make_affine = ec_GF2m_simple_points_make_affine, + .mul_generator_ct = ec_GFp_simple_mul_generator_ct, + .mul_single_ct = ec_GFp_simple_mul_single_ct, + .mul_double_nonct = ec_GFp_simple_mul_double_nonct, + .precompute_mult = ec_GF2m_precompute_mult, + .have_precompute_mult = ec_GF2m_have_precompute_mult, + .field_mul = ec_GF2m_simple_field_mul, + .field_sqr = ec_GF2m_simple_field_sqr, + .field_div = ec_GF2m_simple_field_div, + .blind_coordinates = NULL, +}; + +const EC_METHOD * +EC_GF2m_simple_method(void) +{ + return &ec_GF2m_simple_method; +} #endif diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index 5c9a76c8..e47dcbc7 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_ameth.c,v 1.33 2022/06/27 12:36:05 tb Exp $ */ +/* $OpenBSD: ec_ameth.c,v 1.38 2023/03/07 07:01:35 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -66,17 +66,17 @@ #include #include -#include "asn1_locl.h" -#include "ec_lcl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "ec_local.h" +#include "evp_local.h" #ifndef OPENSSL_NO_CMS static int ecdh_cms_decrypt(CMS_RecipientInfo *ri); static int ecdh_cms_encrypt(CMS_RecipientInfo *ri); #endif -static int -eckey_param2type(int *pptype, void **ppval, EC_KEY * ec_key) +static int +eckey_param2type(int *pptype, void **ppval, EC_KEY *ec_key) { const EC_GROUP *group; int nid; @@ -107,8 +107,8 @@ eckey_param2type(int *pptype, void **ppval, EC_KEY * ec_key) return 1; } -static int -eckey_pub_encode(X509_PUBKEY * pk, const EVP_PKEY * pkey) +static int +eckey_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) { EC_KEY *ec_key = pkey->pkey.ec; void *pval = NULL; @@ -190,8 +190,8 @@ eckey_type2param(int ptype, const void *pval) return NULL; } -static int -eckey_pub_decode(EVP_PKEY * pkey, X509_PUBKEY * pubkey) +static int +eckey_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) { const unsigned char *p = NULL; const void *pval; @@ -223,8 +223,8 @@ eckey_pub_decode(EVP_PKEY * pkey, X509_PUBKEY * pubkey) return 0; } -static int -eckey_pub_cmp(const EVP_PKEY * a, const EVP_PKEY * b) +static int +eckey_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) { int r; const EC_GROUP *group = EC_KEY_get0_group(b->pkey.ec); @@ -238,8 +238,8 @@ eckey_pub_cmp(const EVP_PKEY * a, const EVP_PKEY * b) return -2; } -static int -eckey_priv_decode(EVP_PKEY * pkey, const PKCS8_PRIV_KEY_INFO * p8) +static int +eckey_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) { const unsigned char *p = NULL; const void *pval; @@ -305,8 +305,8 @@ eckey_priv_decode(EVP_PKEY * pkey, const PKCS8_PRIV_KEY_INFO * p8) return 0; } -static int -eckey_priv_encode(PKCS8_PRIV_KEY_INFO * p8, const EVP_PKEY * pkey) +static int +eckey_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) { EC_KEY *ec_key; unsigned char *ep, *p; @@ -358,14 +358,14 @@ eckey_priv_encode(PKCS8_PRIV_KEY_INFO * p8, const EVP_PKEY * pkey) return 1; } -static int -int_ec_size(const EVP_PKEY * pkey) +static int +int_ec_size(const EVP_PKEY *pkey) { return ECDSA_size(pkey->pkey.ec); } -static int -ec_bits(const EVP_PKEY * pkey) +static int +ec_bits(const EVP_PKEY *pkey) { BIGNUM *order = BN_new(); const EC_GROUP *group; @@ -405,22 +405,22 @@ ec_security_bits(const EVP_PKEY *pkey) return ecbits / 2; } -static int -ec_missing_parameters(const EVP_PKEY * pkey) +static int +ec_missing_parameters(const EVP_PKEY *pkey) { if (EC_KEY_get0_group(pkey->pkey.ec) == NULL) return 1; return 0; } -static int -ec_copy_parameters(EVP_PKEY * to, const EVP_PKEY * from) +static int +ec_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) { return EC_KEY_set_group(to->pkey.ec, EC_KEY_get0_group(from->pkey.ec)); } -static int -ec_cmp_parameters(const EVP_PKEY * a, const EVP_PKEY * b) +static int +ec_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) { const EC_GROUP *group_a = EC_KEY_get0_group(a->pkey.ec), *group_b = EC_KEY_get0_group(b->pkey.ec); if (EC_GROUP_cmp(group_a, group_b, NULL)) @@ -429,14 +429,14 @@ ec_cmp_parameters(const EVP_PKEY * a, const EVP_PKEY * b) return 1; } -static void -int_ec_free(EVP_PKEY * pkey) +static void +int_ec_free(EVP_PKEY *pkey) { EC_KEY_free(pkey->pkey.ec); } -static int -do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype) +static int +do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) { unsigned char *buffer = NULL; const char *ecstr; @@ -519,8 +519,8 @@ do_EC_KEY_print(BIO * bp, const EC_KEY * x, int off, int ktype) return (ret); } -static int -eckey_param_decode(EVP_PKEY * pkey, +static int +eckey_param_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) { EC_KEY *eckey; @@ -532,36 +532,36 @@ eckey_param_decode(EVP_PKEY * pkey, return 1; } -static int -eckey_param_encode(const EVP_PKEY * pkey, unsigned char **pder) +static int +eckey_param_encode(const EVP_PKEY *pkey, unsigned char **pder) { return i2d_ECParameters(pkey->pkey.ec, pder); } -static int -eckey_param_print(BIO * bp, const EVP_PKEY * pkey, int indent, - ASN1_PCTX * ctx) +static int +eckey_param_print(BIO *bp, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *ctx) { return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 0); } -static int -eckey_pub_print(BIO * bp, const EVP_PKEY * pkey, int indent, - ASN1_PCTX * ctx) +static int +eckey_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *ctx) { return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 1); } -static int -eckey_priv_print(BIO * bp, const EVP_PKEY * pkey, int indent, - ASN1_PCTX * ctx) +static int +eckey_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *ctx) { return do_EC_KEY_print(bp, pkey->pkey.ec, indent, 2); } -static int -old_ec_priv_decode(EVP_PKEY * pkey, +static int +old_ec_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) { EC_KEY *ec; @@ -573,14 +573,14 @@ old_ec_priv_decode(EVP_PKEY * pkey, return 1; } -static int -old_ec_priv_encode(const EVP_PKEY * pkey, unsigned char **pder) +static int +old_ec_priv_encode(const EVP_PKEY *pkey, unsigned char **pder) { return i2d_ECPrivateKey(pkey->pkey.ec, pder); } -static int -ec_pkey_ctrl(EVP_PKEY * pkey, int op, long arg1, void *arg2) +static int +ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) { switch (op) { case ASN1_PKEY_CTRL_PKCS7_SIGN: @@ -814,7 +814,7 @@ ecdh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri) goto err; plen = CMS_SharedInfo_encode(&der, kekalg, ukm, keylen); - if (!plen) + if (plen <= 0) goto err; if (EVP_PKEY_CTX_set0_ecdh_kdf_ukm(pctx, der, plen) <= 0) @@ -976,7 +976,7 @@ ecdh_cms_encrypt(CMS_RecipientInfo *ri) goto err; penclen = CMS_SharedInfo_encode(&penc, wrap_alg, ukm, keylen); - if (!penclen) + if (penclen <= 0) goto err; if (EVP_PKEY_CTX_set0_ecdh_kdf_ukm(pctx, penc, penclen) <= 0) @@ -988,7 +988,7 @@ ecdh_cms_encrypt(CMS_RecipientInfo *ri) * of another AlgorithmIdentifier. */ penclen = i2d_X509_ALGOR(wrap_alg, &penc); - if (!penc || !penclen) + if (penclen <= 0) goto err; wrap_str = ASN1_STRING_new(); if (wrap_str == NULL) diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index 6bf7e47d..fb6a8e84 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_asn1.c,v 1.37 2022/05/24 20:06:32 tb Exp $ */ +/* $OpenBSD: ec_asn1.c,v 1.41 2023/03/08 05:45:31 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -64,11 +64,11 @@ #include #include -#include "asn1_locl.h" -#include "ec_lcl.h" +#include "asn1_local.h" +#include "ec_local.h" -int -EC_GROUP_get_basis_type(const EC_GROUP * group) +int +EC_GROUP_get_basis_type(const EC_GROUP *group) { int i = 0; @@ -90,8 +90,8 @@ EC_GROUP_get_basis_type(const EC_GROUP * group) } #ifndef OPENSSL_NO_EC2M -int -EC_GROUP_get_trinomial_basis(const EC_GROUP * group, unsigned int *k) +int +EC_GROUP_get_trinomial_basis(const EC_GROUP *group, unsigned int *k) { if (group == NULL) return 0; @@ -108,8 +108,8 @@ EC_GROUP_get_trinomial_basis(const EC_GROUP * group, unsigned int *k) return 1; } -int -EC_GROUP_get_pentanomial_basis(const EC_GROUP * group, unsigned int *k1, +int +EC_GROUP_get_pentanomial_basis(const EC_GROUP *group, unsigned int *k1, unsigned int *k2, unsigned int *k3) { if (group == NULL) @@ -268,7 +268,7 @@ static const ASN1_ADB_TABLE X9_62_CHARACTERISTIC_TWO_adbtbl[] = { .field_name = "p.onBasis", .item = &ASN1_NULL_it, }, - + }, { .value = NID_X9_62_tpBasis, @@ -279,7 +279,7 @@ static const ASN1_ADB_TABLE X9_62_CHARACTERISTIC_TWO_adbtbl[] = { .field_name = "p.tpBasis", .item = &ASN1_INTEGER_it, }, - + }, { .value = NID_X9_62_ppBasis, @@ -290,7 +290,7 @@ static const ASN1_ADB_TABLE X9_62_CHARACTERISTIC_TWO_adbtbl[] = { .field_name = "p.ppBasis", .item = &X9_62_PENTANOMIAL_it, }, - + }, }; @@ -370,7 +370,7 @@ static const ASN1_ADB_TABLE X9_62_FIELDID_adbtbl[] = { .field_name = "p.prime", .item = &ASN1_INTEGER_it, }, - + }, { .value = NID_X9_62_characteristic_two_field, @@ -381,7 +381,7 @@ static const ASN1_ADB_TABLE X9_62_FIELDID_adbtbl[] = { .field_name = "p.char_two", .item = &X9_62_CHARACTERISTIC_TWO_it, }, - + }, }; @@ -683,7 +683,7 @@ static ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *, /* the function definitions */ static int -ec_asn1_group2fieldid(const EC_GROUP * group, X9_62_FIELDID * field) +ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) { int ok = 0, nid; BIGNUM *tmp = NULL; @@ -798,8 +798,8 @@ ec_asn1_group2fieldid(const EC_GROUP * group, X9_62_FIELDID * field) return (ok); } -static int -ec_asn1_group2curve(const EC_GROUP * group, X9_62_CURVE * curve) +static int +ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve) { BIGNUM *tmp_1 = NULL, *tmp_2 = NULL; unsigned char *buffer_1 = NULL, *buffer_2 = NULL, *a_buf = NULL, @@ -894,7 +894,7 @@ ec_asn1_group2curve(const EC_GROUP * group, X9_62_CURVE * curve) } static ECPARAMETERS * -ec_asn1_group2parameters(const EC_GROUP * group, ECPARAMETERS * param) +ec_asn1_group2parameters(const EC_GROUP *group, ECPARAMETERS *param) { int ok = 0; size_t len = 0; @@ -989,7 +989,7 @@ ec_asn1_group2parameters(const EC_GROUP * group, ECPARAMETERS * param) } ECPKPARAMETERS * -ec_asn1_group2pkparameters(const EC_GROUP * group, ECPKPARAMETERS * params) +ec_asn1_group2pkparameters(const EC_GROUP *group, ECPKPARAMETERS *params) { int ok = 1, tmp; ECPKPARAMETERS *ret = params; @@ -1035,7 +1035,7 @@ ec_asn1_group2pkparameters(const EC_GROUP * group, ECPKPARAMETERS * params) } static EC_GROUP * -ec_asn1_parameters2group(const ECPARAMETERS * params) +ec_asn1_parameters2group(const ECPARAMETERS *params) { int ok = 0, tmp; EC_GROUP *ret = NULL; @@ -1236,7 +1236,7 @@ ec_asn1_parameters2group(const ECPARAMETERS * params) err: if (!ok) { - EC_GROUP_clear_free(ret); + EC_GROUP_free(ret); ret = NULL; } BN_free(p); @@ -1247,7 +1247,7 @@ ec_asn1_parameters2group(const ECPARAMETERS * params) } EC_GROUP * -ec_asn1_pkparameters2group(const ECPKPARAMETERS * params) +ec_asn1_pkparameters2group(const ECPKPARAMETERS *params) { EC_GROUP *ret = NULL; int tmp = 0; @@ -1299,7 +1299,7 @@ d2i_ECPKParameters(EC_GROUP ** a, const unsigned char **in, long len) } if (a != NULL) { - EC_GROUP_clear_free(*a); + EC_GROUP_free(*a); *a = group; } @@ -1308,8 +1308,8 @@ d2i_ECPKParameters(EC_GROUP ** a, const unsigned char **in, long len) return (group); } -int -i2d_ECPKParameters(const EC_GROUP * a, unsigned char **out) +int +i2d_ECPKParameters(const EC_GROUP *a, unsigned char **out) { int ret = 0; ECPKPARAMETERS *tmp = ec_asn1_group2pkparameters(a, NULL); @@ -1347,7 +1347,7 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len) ret = *a; if (priv_key->parameters) { - EC_GROUP_clear_free(ret->group); + EC_GROUP_free(ret->group); ret->group = ec_asn1_pkparameters2group(priv_key->parameters); } if (ret->group == NULL) { @@ -1371,7 +1371,7 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len) } if (ret->pub_key) - EC_POINT_clear_free(ret->pub_key); + EC_POINT_free(ret->pub_key); ret->pub_key = EC_POINT_new(ret->group); if (ret->pub_key == NULL) { ECerror(ERR_R_EC_LIB); @@ -1420,8 +1420,8 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len) return (NULL); } -int -i2d_ECPrivateKey(EC_KEY * a, unsigned char **out) +int +i2d_ECPrivateKey(EC_KEY *a, unsigned char **out) { int ret = 0, ok = 0; unsigned char *buffer = NULL; @@ -1504,8 +1504,8 @@ i2d_ECPrivateKey(EC_KEY * a, unsigned char **out) return (ok ? ret : 0); } -int -i2d_ECParameters(EC_KEY * a, unsigned char **out) +int +i2d_ECParameters(EC_KEY *a, unsigned char **out) { if (a == NULL) { ECerror(ERR_R_PASSED_NULL_PARAMETER); @@ -1569,8 +1569,8 @@ o2i_ECPublicKey(EC_KEY ** a, const unsigned char **in, long len) return ret; } -int -i2o_ECPublicKey(const EC_KEY * a, unsigned char **out) +int +i2o_ECPublicKey(const EC_KEY *a, unsigned char **out) { size_t buf_len = 0; int new_buffer = 0; diff --git a/crypto/ec/ec_check.c b/crypto/ec/ec_check.c index dcca6616..5c6165e1 100644 --- a/crypto/ec/ec_check.c +++ b/crypto/ec/ec_check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_check.c,v 1.9 2018/07/15 16:27:39 tb Exp $ */ +/* $OpenBSD: ec_check.c,v 1.12 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -53,11 +53,11 @@ * */ -#include "ec_lcl.h" +#include "ec_local.h" #include -int -EC_GROUP_check(const EC_GROUP * group, BN_CTX * ctx) +int +EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx) { int ret = 0; BIGNUM *order; diff --git a/crypto/ec/ec_curve.c b/crypto/ec/ec_curve.c index 09f8cfe9..324abe8e 100644 --- a/crypto/ec/ec_curve.c +++ b/crypto/ec/ec_curve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_curve.c,v 1.22 2022/06/30 11:14:47 tb Exp $ */ +/* $OpenBSD: ec_curve.c,v 1.26 2023/03/04 14:53:23 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -76,7 +76,7 @@ #include #include -#include "ec_lcl.h" +#include "ec_local.h" typedef struct { int field_type, /* either NID_X9_62_prime_field or @@ -3183,19 +3183,11 @@ static const ec_list_element curve_list[] = { /* SECG secp192r1 is the same as X9.62 prime192v1 and hence omitted */ {NID_secp192k1, &_EC_SECG_PRIME_192K1.h, 0, "SECG curve over a 192 bit prime field"}, {NID_secp224k1, &_EC_SECG_PRIME_224K1.h, 0, "SECG curve over a 224 bit prime field"}, -#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 - {NID_secp224r1, &_EC_NIST_PRIME_224.h, EC_GFp_nistp224_method, "NIST/SECG curve over a 224 bit prime field"}, -#else {NID_secp224r1, &_EC_NIST_PRIME_224.h, 0, "NIST/SECG curve over a 224 bit prime field"}, -#endif {NID_secp256k1, &_EC_SECG_PRIME_256K1.h, 0, "SECG curve over a 256 bit prime field"}, /* SECG secp256r1 is the same as X9.62 prime256v1 and hence omitted */ {NID_secp384r1, &_EC_NIST_PRIME_384.h, 0, "NIST/SECG curve over a 384 bit prime field"}, -#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 - {NID_secp521r1, &_EC_NIST_PRIME_521.h, EC_GFp_nistp521_method, "NIST/SECG curve over a 521 bit prime field"}, -#else {NID_secp521r1, &_EC_NIST_PRIME_521.h, 0, "NIST/SECG curve over a 521 bit prime field"}, -#endif /* X9.62 curves */ {NID_X9_62_prime192v1, &_EC_NIST_PRIME_192.h, 0, "NIST/X9.62/SECG curve over a 192 bit prime field"}, {NID_X9_62_prime192v2, &_EC_X9_62_PRIME_192V2.h, 0, "X9.62 curve over a 192 bit prime field"}, @@ -3203,15 +3195,7 @@ static const ec_list_element curve_list[] = { {NID_X9_62_prime239v1, &_EC_X9_62_PRIME_239V1.h, 0, "X9.62 curve over a 239 bit prime field"}, {NID_X9_62_prime239v2, &_EC_X9_62_PRIME_239V2.h, 0, "X9.62 curve over a 239 bit prime field"}, {NID_X9_62_prime239v3, &_EC_X9_62_PRIME_239V3.h, 0, "X9.62 curve over a 239 bit prime field"}, - {NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, -#if defined(ECP_NISTZ256_ASM) - EC_GFp_nistz256_method, -#elif !defined(OPENSSL_NO_EC_NISTP_64_GCC_128) - EC_GFp_nistp256_method, -#else - 0, -#endif - "X9.62/SECG curve over a 256 bit prime field"}, + {NID_X9_62_prime256v1, &_EC_X9_62_PRIME_256V1.h, 0, "X9.62/SECG curve over a 256 bit prime field"}, #ifndef OPENSSL_NO_EC2M /* characteristic two field curves */ /* NIST/SECG curves */ @@ -3433,8 +3417,8 @@ EC_GROUP_new_by_curve_name(int nid) return ret; } -size_t -EC_get_builtin_curves(EC_builtin_curve * r, size_t nitems) +size_t +EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems) { size_t i, min; diff --git a/crypto/ec/ec_cvt.c b/crypto/ec/ec_cvt.c index 05c7dd1b..30e843e6 100644 --- a/crypto/ec/ec_cvt.c +++ b/crypto/ec/ec_cvt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_cvt.c,v 1.7 2021/04/20 17:04:13 tb Exp $ */ +/* $OpenBSD: ec_cvt.c,v 1.10 2023/03/08 07:15:42 jsing Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -72,76 +72,33 @@ #include #include -#include "ec_lcl.h" +#include "ec_local.h" -EC_GROUP * -EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, - BN_CTX *ctx) +static EC_GROUP * +ec_group_new_curve(const EC_METHOD *method, const BIGNUM *p, const BIGNUM *a, + const BIGNUM *b, BN_CTX *ctx) { - const EC_METHOD *meth; - EC_GROUP *ret; - -#if defined(OPENSSL_BN_ASM_MONT) - /* - * This might appear controversial, but the fact is that generic - * prime method was observed to deliver better performance even - * for NIST primes on a range of platforms, e.g.: 60%-15% - * improvement on IA-64, ~25% on ARM, 30%-90% on P4, 20%-25% - * in 32-bit build and 35%--12% in 64-bit build on Core2... - * Coefficients are relative to optimized bn_nist.c for most - * intensive ECDSA verify and ECDH operations for 192- and 521- - * bit keys respectively. Choice of these boundary values is - * arguable, because the dependency of improvement coefficient - * from key length is not a "monotone" curve. For example while - * 571-bit result is 23% on ARM, 384-bit one is -1%. But it's - * generally faster, sometimes "respectfully" faster, sometimes - * "tolerably" slower... What effectively happens is that loop - * with bn_mul_add_words is put against bn_mul_mont, and the - * latter "wins" on short vectors. Correct solution should be - * implementing dedicated NxN multiplication subroutines for - * small N. But till it materializes, let's stick to generic - * prime method... - * - */ - meth = EC_GFp_mont_method(); -#else - meth = EC_GFp_nist_method(); -#endif - - ret = EC_GROUP_new(meth); - if (ret == NULL) - return NULL; - - if (!EC_GROUP_set_curve(ret, p, a, b, ctx)) { - unsigned long err; - - err = ERR_peek_last_error(); + EC_GROUP *group; - if (!(ERR_GET_LIB(err) == ERR_LIB_EC && - ((ERR_GET_REASON(err) == EC_R_NOT_A_NIST_PRIME) || - (ERR_GET_REASON(err) == EC_R_NOT_A_SUPPORTED_NIST_PRIME)))) { - /* real error */ + if ((group = EC_GROUP_new(method)) == NULL) + goto err; - EC_GROUP_clear_free(ret); - return NULL; - } - /* not an actual error, we just cannot use EC_GFp_nist_method */ + if (!EC_GROUP_set_curve(group, p, a, b, ctx)) + goto err; - ERR_clear_error(); + return group; - EC_GROUP_clear_free(ret); - meth = EC_GFp_mont_method(); + err: + EC_GROUP_free(group); - ret = EC_GROUP_new(meth); - if (ret == NULL) - return NULL; + return NULL; +} - if (!EC_GROUP_set_curve(ret, p, a, b, ctx)) { - EC_GROUP_clear_free(ret); - return NULL; - } - } - return ret; +EC_GROUP * +EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, + BN_CTX *ctx) +{ + return ec_group_new_curve(EC_GFp_mont_method(), p, a, b, ctx); } #ifndef OPENSSL_NO_EC2M @@ -149,19 +106,6 @@ EC_GROUP * EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { - const EC_METHOD *meth; - EC_GROUP *ret; - - meth = EC_GF2m_simple_method(); - - ret = EC_GROUP_new(meth); - if (ret == NULL) - return NULL; - - if (!EC_GROUP_set_curve(ret, p, a, b, ctx)) { - EC_GROUP_clear_free(ret); - return NULL; - } - return ret; + return ec_group_new_curve(EC_GF2m_simple_method(), p, a, b, ctx); } #endif diff --git a/crypto/ec/ec_err.c b/crypto/ec/ec_err.c index d8ead963..be6a2845 100644 --- a/crypto/ec/ec_err.c +++ b/crypto/ec/ec_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_err.c,v 1.13 2022/07/12 14:42:49 kn Exp $ */ +/* $OpenBSD: ec_err.c,v 1.15 2022/11/19 07:00:57 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -96,6 +96,8 @@ static ERR_STRING_DATA EC_str_reasons[] = {ERR_REASON(EC_R_INVALID_FIELD), "invalid field"}, {ERR_REASON(EC_R_INVALID_FORM), "invalid form"}, {ERR_REASON(EC_R_INVALID_GROUP_ORDER), "invalid group order"}, + {ERR_REASON(EC_R_INVALID_KEY), "invalid key"}, + {ERR_REASON(EC_R_INVALID_PEER_KEY), "invalid peer key"}, {ERR_REASON(EC_R_INVALID_PENTANOMIAL_BASIS), "invalid pentanomial basis"}, {ERR_REASON(EC_R_INVALID_PRIVATE_KEY), "invalid private key"}, {ERR_REASON(EC_R_INVALID_TRINOMIAL_BASIS), "invalid trinomial basis"}, @@ -129,7 +131,7 @@ static ERR_STRING_DATA EC_str_reasons[] = #endif -void +void ERR_load_EC_strings(void) { #ifndef OPENSSL_NO_ERR diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index 27b8f266..3799498a 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_key.c,v 1.26 2021/04/20 17:23:37 tb Exp $ */ +/* $OpenBSD: ec_key.c,v 1.31 2023/03/07 09:27:10 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -70,8 +70,8 @@ #endif #include -#include "bn_lcl.h" -#include "ec_lcl.h" +#include "bn_local.h" +#include "ec_local.h" EC_KEY * EC_KEY_new(void) @@ -98,8 +98,8 @@ EC_KEY_new_by_curve_name(int nid) return ret; } -void -EC_KEY_free(EC_KEY * r) +void +EC_KEY_free(EC_KEY *r) { int i; @@ -120,7 +120,7 @@ EC_KEY_free(EC_KEY * r) EC_GROUP_free(r->group); EC_POINT_free(r->pub_key); - BN_clear_free(r->priv_key); + BN_free(r->priv_key); EC_EX_DATA_free_all_data(&r->method_data); @@ -128,7 +128,7 @@ EC_KEY_free(EC_KEY * r) } EC_KEY * -EC_KEY_copy(EC_KEY * dest, const EC_KEY * src) +EC_KEY_copy(EC_KEY *dest, const EC_KEY *src) { EC_EXTRA_DATA *d; @@ -215,7 +215,7 @@ EC_KEY_copy(EC_KEY * dest, const EC_KEY * src) } EC_KEY * -EC_KEY_dup(const EC_KEY * ec_key) +EC_KEY_dup(const EC_KEY *ec_key) { EC_KEY *ret; @@ -228,8 +228,8 @@ EC_KEY_dup(const EC_KEY * ec_key) return ret; } -int -EC_KEY_up_ref(EC_KEY * r) +int +EC_KEY_up_ref(EC_KEY *r) { int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC); return ((i > 1) ? 1 : 0); @@ -259,84 +259,93 @@ EC_KEY_generate_key(EC_KEY *eckey) int ossl_ec_key_gen(EC_KEY *eckey) { - int ok = 0; BN_CTX *ctx = NULL; - BIGNUM *priv_key = NULL, *order = NULL; + BIGNUM *priv_key = NULL; EC_POINT *pub_key = NULL; + BIGNUM *order; + int ret = 0; - if (!eckey || !eckey->group) { + if (eckey == NULL || eckey->group == NULL) { ECerror(ERR_R_PASSED_NULL_PARAMETER); - return 0; + goto err; } - if ((order = BN_new()) == NULL) + if ((priv_key = BN_new()) == NULL) + goto err; + if ((pub_key = EC_POINT_new(eckey->group)) == NULL) goto err; + if ((ctx = BN_CTX_new()) == NULL) goto err; - if ((priv_key = eckey->priv_key) == NULL) { - if ((priv_key = BN_new()) == NULL) - goto err; - } + BN_CTX_start(ctx); - if (!EC_GROUP_get_order(eckey->group, order, ctx)) + if ((order = BN_CTX_get(ctx)) == NULL) goto err; + if (!EC_GROUP_get_order(eckey->group, order, ctx)) + goto err; if (!bn_rand_interval(priv_key, BN_value_one(), order)) goto err; - - if ((pub_key = eckey->pub_key) == NULL) { - if ((pub_key = EC_POINT_new(eckey->group)) == NULL) - goto err; - } - if (!EC_POINT_mul(eckey->group, pub_key, priv_key, NULL, NULL, ctx)) goto err; + BN_free(eckey->priv_key); eckey->priv_key = priv_key; + priv_key = NULL; + + EC_POINT_free(eckey->pub_key); eckey->pub_key = pub_key; + pub_key = NULL; - ok = 1; + ret = 1; err: - BN_free(order); - if (eckey->pub_key == NULL) - EC_POINT_free(pub_key); - if (eckey->priv_key == NULL) - BN_free(priv_key); + EC_POINT_free(pub_key); + BN_free(priv_key); + BN_CTX_end(ctx); BN_CTX_free(ctx); - return (ok); + + return ret; } -int -EC_KEY_check_key(const EC_KEY * eckey) +int +EC_KEY_check_key(const EC_KEY *eckey) { - int ok = 0; BN_CTX *ctx = NULL; - const BIGNUM *order = NULL; EC_POINT *point = NULL; + BIGNUM *order; + int ret = 0; - if (!eckey || !eckey->group || !eckey->pub_key) { + if (eckey == NULL || eckey->group == NULL || eckey->pub_key == NULL) { ECerror(ERR_R_PASSED_NULL_PARAMETER); - return 0; + goto err; } + if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key) > 0) { ECerror(EC_R_POINT_AT_INFINITY); goto err; } + if ((ctx = BN_CTX_new()) == NULL) goto err; + + BN_CTX_start(ctx); + + if ((order = BN_CTX_get(ctx)) == NULL) + goto err; + if ((point = EC_POINT_new(eckey->group)) == NULL) goto err; - /* testing whether the pub_key is on the elliptic curve */ + /* Ensure public key is on the elliptic curve. */ if (EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx) <= 0) { ECerror(EC_R_POINT_IS_NOT_ON_CURVE); goto err; } - /* testing whether pub_key * order is the point at infinity */ - order = &eckey->group->order; - if (BN_is_zero(order)) { + + /* Ensure public key multiplied by the order is the point at infinity. */ + if (!EC_GROUP_get_order(eckey->group, order, ctx)) { ECerror(EC_R_INVALID_GROUP_ORDER); goto err; } @@ -348,94 +357,100 @@ EC_KEY_check_key(const EC_KEY * eckey) ECerror(EC_R_WRONG_ORDER); goto err; } + /* - * in case the priv_key is present : check if generator * priv_key == - * pub_key + * If the private key is present, ensure that the private key multiplied + * by the generator matches the public key. */ - if (eckey->priv_key) { + if (eckey->priv_key != NULL) { if (BN_cmp(eckey->priv_key, order) >= 0) { ECerror(EC_R_WRONG_ORDER); goto err; } - if (!EC_POINT_mul(eckey->group, point, eckey->priv_key, - NULL, NULL, ctx)) { + if (!EC_POINT_mul(eckey->group, point, eckey->priv_key, NULL, + NULL, ctx)) { ECerror(ERR_R_EC_LIB); goto err; } if (EC_POINT_cmp(eckey->group, point, eckey->pub_key, - ctx) != 0) { + ctx) != 0) { ECerror(EC_R_INVALID_PRIVATE_KEY); goto err; } } - ok = 1; + + ret = 1; + err: + BN_CTX_end(ctx); BN_CTX_free(ctx); EC_POINT_free(point); - return (ok); + + return ret; } -int -EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y) +int +EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *y) { BN_CTX *ctx = NULL; - BIGNUM *tx, *ty; EC_POINT *point = NULL; - int ok = 0; + BIGNUM *tx, *ty; + int ret = 0; - if (!key || !key->group || !x || !y) { + if (key == NULL || key->group == NULL || x == NULL || y == NULL) { ECerror(ERR_R_PASSED_NULL_PARAMETER); - return 0; - } - ctx = BN_CTX_new(); - if (!ctx) goto err; + } - point = EC_POINT_new(key->group); - - if (!point) + if ((ctx = BN_CTX_new()) == NULL) goto err; + BN_CTX_start(ctx); + if ((tx = BN_CTX_get(ctx)) == NULL) goto err; if ((ty = BN_CTX_get(ctx)) == NULL) goto err; + if ((point = EC_POINT_new(key->group)) == NULL) + goto err; + if (!EC_POINT_set_affine_coordinates(key->group, point, x, y, ctx)) goto err; if (!EC_POINT_get_affine_coordinates(key->group, point, tx, ty, ctx)) goto err; + /* * Check if retrieved coordinates match originals: if not values are * out of range. */ - if (BN_cmp(x, tx) || BN_cmp(y, ty)) { + if (BN_cmp(x, tx) != 0 || BN_cmp(y, ty) != 0) { ECerror(EC_R_COORDINATES_OUT_OF_RANGE); goto err; } if (!EC_KEY_set_public_key(key, point)) goto err; - if (EC_KEY_check_key(key) == 0) goto err; - ok = 1; + ret = 1; err: + BN_CTX_end(ctx); BN_CTX_free(ctx); EC_POINT_free(point); - return ok; + return ret; } const EC_GROUP * -EC_KEY_get0_group(const EC_KEY * key) +EC_KEY_get0_group(const EC_KEY *key) { return key->group; } -int -EC_KEY_set_group(EC_KEY * key, const EC_GROUP * group) +int +EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group) { if (key->meth->set_group != NULL && key->meth->set_group(key, group) == 0) @@ -446,59 +461,65 @@ EC_KEY_set_group(EC_KEY * key, const EC_GROUP * group) } const BIGNUM * -EC_KEY_get0_private_key(const EC_KEY * key) +EC_KEY_get0_private_key(const EC_KEY *key) { return key->priv_key; } -int -EC_KEY_set_private_key(EC_KEY * key, const BIGNUM * priv_key) +int +EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *priv_key) { if (key->meth->set_private != NULL && key->meth->set_private(key, priv_key) == 0) return 0; - BN_clear_free(key->priv_key); - key->priv_key = BN_dup(priv_key); - return (key->priv_key == NULL) ? 0 : 1; + + BN_free(key->priv_key); + if ((key->priv_key = BN_dup(priv_key)) == NULL) + return 0; + + return 1; } const EC_POINT * -EC_KEY_get0_public_key(const EC_KEY * key) +EC_KEY_get0_public_key(const EC_KEY *key) { return key->pub_key; } -int -EC_KEY_set_public_key(EC_KEY * key, const EC_POINT * pub_key) +int +EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub_key) { if (key->meth->set_public != NULL && key->meth->set_public(key, pub_key) == 0) return 0; + EC_POINT_free(key->pub_key); - key->pub_key = EC_POINT_dup(pub_key, key->group); - return (key->pub_key == NULL) ? 0 : 1; + if ((key->pub_key = EC_POINT_dup(pub_key, key->group)) == NULL) + return 0; + + return 1; } -unsigned int -EC_KEY_get_enc_flags(const EC_KEY * key) +unsigned int +EC_KEY_get_enc_flags(const EC_KEY *key) { return key->enc_flag; } -void -EC_KEY_set_enc_flags(EC_KEY * key, unsigned int flags) +void +EC_KEY_set_enc_flags(EC_KEY *key, unsigned int flags) { key->enc_flag = flags; } -point_conversion_form_t -EC_KEY_get_conv_form(const EC_KEY * key) +point_conversion_form_t +EC_KEY_get_conv_form(const EC_KEY *key) { return key->conv_form; } -void -EC_KEY_set_conv_form(EC_KEY * key, point_conversion_form_t cform) +void +EC_KEY_set_conv_form(EC_KEY *key, point_conversion_form_t cform) { key->conv_form = cform; if (key->group != NULL) @@ -521,7 +542,7 @@ EC_KEY_get_key_method_data(EC_KEY *key, } void * -EC_KEY_insert_key_method_data(EC_KEY * key, void *data, +EC_KEY_insert_key_method_data(EC_KEY *key, void *data, void *(*dup_func) (void *), void (*free_func) (void *), void (*clear_free_func) (void *)) @@ -537,35 +558,35 @@ EC_KEY_insert_key_method_data(EC_KEY * key, void *data, return ex_data; } -void -EC_KEY_set_asn1_flag(EC_KEY * key, int flag) +void +EC_KEY_set_asn1_flag(EC_KEY *key, int flag) { if (key->group != NULL) EC_GROUP_set_asn1_flag(key->group, flag); } -int -EC_KEY_precompute_mult(EC_KEY * key, BN_CTX * ctx) +int +EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx) { if (key->group == NULL) return 0; return EC_GROUP_precompute_mult(key->group, ctx); } -int -EC_KEY_get_flags(const EC_KEY * key) +int +EC_KEY_get_flags(const EC_KEY *key) { return key->flags; } -void -EC_KEY_set_flags(EC_KEY * key, int flags) +void +EC_KEY_set_flags(EC_KEY *key, int flags) { key->flags |= flags; } -void -EC_KEY_clear_flags(EC_KEY * key, int flags) +void +EC_KEY_clear_flags(EC_KEY *key, int flags) { key->flags &= ~flags; } diff --git a/crypto/ec/ec_kmeth.c b/crypto/ec/ec_kmeth.c index 4203dff2..56fb4370 100644 --- a/crypto/ec/ec_kmeth.c +++ b/crypto/ec/ec_kmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_kmeth.c,v 1.6 2021/12/04 16:08:32 tb Exp $ */ +/* $OpenBSD: ec_kmeth.c,v 1.7 2022/11/26 16:08:52 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -58,9 +58,9 @@ #endif #include -#include "bn_lcl.h" -#include "ec_lcl.h" -#include "ecs_locl.h" +#include "bn_local.h" +#include "ec_local.h" +#include "ecs_local.h" static const EC_KEY_METHOD openssl_ec_key_method = { .name = "OpenSSL EC_KEY method", diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c index 4ec17d5d..2d14f9c9 100644 --- a/crypto/ec/ec_lib.c +++ b/crypto/ec/ec_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lib.c,v 1.45 2022/04/07 17:37:25 tb Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.51 2023/03/08 06:47:30 jsing Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -68,13 +68,13 @@ #include #include -#include "bn_lcl.h" -#include "ec_lcl.h" +#include "bn_local.h" +#include "ec_local.h" /* functions for EC_GROUP objects */ EC_GROUP * -EC_GROUP_new(const EC_METHOD * meth) +EC_GROUP_new(const EC_METHOD *meth) { EC_GROUP *ret; @@ -115,50 +115,32 @@ EC_GROUP_new(const EC_METHOD * meth) void -EC_GROUP_free(EC_GROUP * group) +EC_GROUP_free(EC_GROUP *group) { - if (!group) + if (group == NULL) return; - if (group->meth->group_finish != 0) + if (group->meth->group_finish != NULL) group->meth->group_finish(group); - EC_EX_DATA_free_all_data(&group->extra_data); + EC_EX_DATA_clear_free_all_data(&group->extra_data); EC_POINT_free(group->generator); BN_free(&group->order); BN_free(&group->cofactor); - free(group->seed); - - free(group); + freezero(group->seed, group->seed_len); + freezero(group, sizeof *group); } - void -EC_GROUP_clear_free(EC_GROUP * group) +EC_GROUP_clear_free(EC_GROUP *group) { - if (!group) - return; - - if (group->meth->group_clear_finish != 0) - group->meth->group_clear_finish(group); - else if (group->meth->group_finish != 0) - group->meth->group_finish(group); - - EC_EX_DATA_clear_free_all_data(&group->extra_data); - - EC_POINT_clear_free(group->generator); - BN_clear_free(&group->order); - BN_clear_free(&group->cofactor); - - freezero(group->seed, group->seed_len); - freezero(group, sizeof *group); + EC_GROUP_free(group); } - int -EC_GROUP_copy(EC_GROUP * dest, const EC_GROUP * src) +EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) { EC_EXTRA_DATA *d; @@ -195,7 +177,7 @@ EC_GROUP_copy(EC_GROUP * dest, const EC_GROUP * src) return 0; } else { /* src->generator == NULL */ - EC_POINT_clear_free(dest->generator); + EC_POINT_free(dest->generator); dest->generator = NULL; } @@ -227,7 +209,7 @@ EC_GROUP_copy(EC_GROUP * dest, const EC_GROUP * src) EC_GROUP * -EC_GROUP_dup(const EC_GROUP * a) +EC_GROUP_dup(const EC_GROUP *a) { EC_GROUP *t = NULL; @@ -428,35 +410,35 @@ EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx) void -EC_GROUP_set_curve_name(EC_GROUP * group, int nid) +EC_GROUP_set_curve_name(EC_GROUP *group, int nid) { group->curve_name = nid; } int -EC_GROUP_get_curve_name(const EC_GROUP * group) +EC_GROUP_get_curve_name(const EC_GROUP *group) { return group->curve_name; } void -EC_GROUP_set_asn1_flag(EC_GROUP * group, int flag) +EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag) { group->asn1_flag = flag; } int -EC_GROUP_get_asn1_flag(const EC_GROUP * group) +EC_GROUP_get_asn1_flag(const EC_GROUP *group) { return group->asn1_flag; } void -EC_GROUP_set_point_conversion_form(EC_GROUP * group, +EC_GROUP_set_point_conversion_form(EC_GROUP *group, point_conversion_form_t form) { group->asn1_form = form; @@ -464,14 +446,14 @@ EC_GROUP_set_point_conversion_form(EC_GROUP * group, point_conversion_form_t -EC_GROUP_get_point_conversion_form(const EC_GROUP * group) +EC_GROUP_get_point_conversion_form(const EC_GROUP *group) { return group->asn1_form; } size_t -EC_GROUP_set_seed(EC_GROUP * group, const unsigned char *p, size_t len) +EC_GROUP_set_seed(EC_GROUP *group, const unsigned char *p, size_t len) { if (group->seed) { free(group->seed); @@ -491,14 +473,14 @@ EC_GROUP_set_seed(EC_GROUP * group, const unsigned char *p, size_t len) unsigned char * -EC_GROUP_get0_seed(const EC_GROUP * group) +EC_GROUP_get0_seed(const EC_GROUP *group) { return group->seed; } size_t -EC_GROUP_get_seed_len(const EC_GROUP * group) +EC_GROUP_get_seed_len(const EC_GROUP *group) { return group->seed_len; } @@ -556,7 +538,7 @@ EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, #endif int -EC_GROUP_get_degree(const EC_GROUP * group) +EC_GROUP_get_degree(const EC_GROUP *group) { if (group->meth->group_get_degree == 0) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); @@ -567,7 +549,7 @@ EC_GROUP_get_degree(const EC_GROUP * group) int -EC_GROUP_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) +EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) { if (group->meth->group_check_discriminant == 0) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); @@ -578,7 +560,7 @@ EC_GROUP_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) int -EC_GROUP_cmp(const EC_GROUP * a, const EC_GROUP * b, BN_CTX * ctx) +EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx) { int r = 0; BIGNUM *a1, *a2, *a3, *b1, *b2, *b3; @@ -710,7 +692,7 @@ EC_EX_DATA_set_data(EC_EXTRA_DATA ** ex_data, void *data, /* this has 'package' visibility */ void * -EC_EX_DATA_get_data(const EC_EXTRA_DATA * ex_data, +EC_EX_DATA_get_data(const EC_EXTRA_DATA *ex_data, void *(*dup_func) (void *), void (*free_func) (void *), void (*clear_free_func) (void *)) @@ -825,7 +807,7 @@ EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA ** ex_data) /* functions for EC_POINT objects */ EC_POINT * -EC_POINT_new(const EC_GROUP * group) +EC_POINT_new(const EC_GROUP *group) { EC_POINT *ret; @@ -851,35 +833,26 @@ EC_POINT_new(const EC_GROUP * group) return ret; } - void -EC_POINT_free(EC_POINT * point) +EC_POINT_free(EC_POINT *point) { - if (!point) + if (point == NULL) return; - if (point->meth->point_finish != 0) + if (point->meth->point_finish != NULL) point->meth->point_finish(point); - free(point); -} + freezero(point, sizeof *point); +} void -EC_POINT_clear_free(EC_POINT * point) +EC_POINT_clear_free(EC_POINT *point) { - if (!point) - return; - - if (point->meth->point_clear_finish != 0) - point->meth->point_clear_finish(point); - else if (point->meth->point_finish != 0) - point->meth->point_finish(point); - freezero(point, sizeof *point); + EC_POINT_free(point); } - int -EC_POINT_copy(EC_POINT * dest, const EC_POINT * src) +EC_POINT_copy(EC_POINT *dest, const EC_POINT *src) { if (dest->meth->point_copy == 0) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); @@ -896,7 +869,7 @@ EC_POINT_copy(EC_POINT * dest, const EC_POINT * src) EC_POINT * -EC_POINT_dup(const EC_POINT * a, const EC_GROUP * group) +EC_POINT_dup(const EC_POINT *a, const EC_GROUP *group) { EC_POINT *t; int r; @@ -917,14 +890,14 @@ EC_POINT_dup(const EC_POINT * a, const EC_GROUP * group) const EC_METHOD * -EC_POINT_method_of(const EC_POINT * point) +EC_POINT_method_of(const EC_POINT *point) { return point->meth; } int -EC_POINT_set_to_infinity(const EC_GROUP * group, EC_POINT * point) +EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point) { if (group->meth->point_set_to_infinity == 0) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); @@ -949,8 +922,14 @@ EC_POINT_set_Jprojective_coordinates(const EC_GROUP *group, EC_POINT *point, ECerror(EC_R_INCOMPATIBLE_OBJECTS); return 0; } - return group->meth->point_set_Jprojective_coordinates(group, point, - x, y, z, ctx); + if (!group->meth->point_set_Jprojective_coordinates(group, point, + x, y, z, ctx)) + return 0; + if (EC_POINT_is_on_curve(group, point, ctx) <= 0) { + ECerror(EC_R_POINT_IS_NOT_ON_CURVE); + return 0; + } + return 1; } int @@ -1113,7 +1092,7 @@ EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) int -EC_POINT_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx) +EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) { if (group->meth->is_on_curve == 0) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); @@ -1129,7 +1108,7 @@ EC_POINT_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ct int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, - BN_CTX * ctx) + BN_CTX *ctx) { if (group->meth->point_cmp == 0) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); @@ -1258,7 +1237,7 @@ EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar, } int -EC_GROUP_precompute_mult(EC_GROUP * group, BN_CTX * ctx) +EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx) { if (group->meth->precompute_mult != 0) return group->meth->precompute_mult(group, ctx); @@ -1267,7 +1246,7 @@ EC_GROUP_precompute_mult(EC_GROUP * group, BN_CTX * ctx) } int -EC_GROUP_have_precompute_mult(const EC_GROUP * group) +EC_GROUP_have_precompute_mult(const EC_GROUP *group) { if (group->meth->have_precompute_mult != 0) return group->meth->have_precompute_mult(group); diff --git a/crypto/ec/ec_lcl.h b/crypto/ec/ec_local.h similarity index 51% rename from crypto/ec/ec_lcl.h rename to crypto/ec/ec_local.h index f0a5618b..d26ec47a 100644 --- a/crypto/ec/ec_lcl.h +++ b/crypto/ec/ec_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lcl.h,v 1.20 2022/06/30 11:14:47 tb Exp $ */ +/* $OpenBSD: ec_local.h,v 1.11 2023/03/08 05:45:31 jsing Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -58,13 +58,13 @@ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * - * Portions of the attached software ("Contribution") are developed by + * Portions of the attached software ("Contribution") are developed by * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. * * The Contribution is licensed pursuant to the OpenSSL open source * license provided above. * - * The elliptic curve binary polynomial software is originally written by + * The elliptic curve binary polynomial software is originally written by * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. * */ @@ -76,7 +76,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" __BEGIN_HIDDEN_DECLS @@ -86,107 +86,93 @@ __BEGIN_HIDDEN_DECLS # endif #endif -#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) -BIGNUM *bn_expand2(BIGNUM *a, int words); - -/* Use default functions for poin2oct, oct2point and compressed coordinates */ -#define EC_FLAGS_DEFAULT_OCT 0x1 - -/* Structure details are not part of the exported interface, - * so all this may change in future versions. */ - struct ec_method_st { - /* Various method flags */ - int flags; - /* used by EC_METHOD_get_field_type: */ - int field_type; /* a NID */ + int field_type; - /* used by EC_GROUP_new, EC_GROUP_free, EC_GROUP_clear_free, EC_GROUP_copy: */ int (*group_init)(EC_GROUP *); void (*group_finish)(EC_GROUP *); - void (*group_clear_finish)(EC_GROUP *); int (*group_copy)(EC_GROUP *, const EC_GROUP *); - /* used by EC_GROUP_{get,set}_curve */ - int (*group_set_curve)(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); - int (*group_get_curve)(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); + int (*group_set_curve)(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, + const BIGNUM *b, BN_CTX *); + int (*group_get_curve)(const EC_GROUP *, BIGNUM *p, BIGNUM *a, + BIGNUM *b, BN_CTX *); - /* used by EC_GROUP_get_degree: */ int (*group_get_degree)(const EC_GROUP *); - /* used by EC_GROUP_order_bits: */ int (*group_order_bits)(const EC_GROUP *); - /* used by EC_GROUP_check: */ int (*group_check_discriminant)(const EC_GROUP *, BN_CTX *); - /* used by EC_POINT_new, EC_POINT_free, EC_POINT_clear_free, EC_POINT_copy: */ int (*point_init)(EC_POINT *); void (*point_finish)(EC_POINT *); - void (*point_clear_finish)(EC_POINT *); int (*point_copy)(EC_POINT *, const EC_POINT *); - /* - * used by EC_POINT_set_to_infinity, - * EC_POINT_set_Jprojective_coordinates, - * EC_POINT_get_Jprojective_coordinates, - * EC_POINT_set_affine_coordinates, - * EC_POINT_get_affine_coordinates, - * EC_POINT_set_compressed_coordinates: - */ int (*point_set_to_infinity)(const EC_GROUP *, EC_POINT *); int (*point_set_Jprojective_coordinates)(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); - int (*point_get_Jprojective_coordinates)(const EC_GROUP *, const EC_POINT *, - BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); + const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *); + int (*point_get_Jprojective_coordinates)(const EC_GROUP *, + const EC_POINT *, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *); int (*point_set_affine_coordinates)(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, const BIGNUM *y, BN_CTX *); + const BIGNUM *x, const BIGNUM *y, BN_CTX *); int (*point_get_affine_coordinates)(const EC_GROUP *, const EC_POINT *, - BIGNUM *x, BIGNUM *y, BN_CTX *); + BIGNUM *x, BIGNUM *y, BN_CTX *); int (*point_set_compressed_coordinates)(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, int y_bit, BN_CTX *); + const BIGNUM *x, int y_bit, BN_CTX *); - /* used by EC_POINT_point2oct, EC_POINT_oct2point: */ - size_t (*point2oct)(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, - unsigned char *buf, size_t len, BN_CTX *); - int (*oct2point)(const EC_GROUP *, EC_POINT *, - const unsigned char *buf, size_t len, BN_CTX *); + size_t (*point2oct)(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, unsigned char *buf, size_t len, + BN_CTX *); + int (*oct2point)(const EC_GROUP *, EC_POINT *, const unsigned char *buf, + size_t len, BN_CTX *); - /* used by EC_POINT_add, EC_POINT_dbl, ECP_POINT_invert: */ - int (*add)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); + int (*add)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, + const EC_POINT *b, BN_CTX *); int (*dbl)(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); int (*invert)(const EC_GROUP *, EC_POINT *, BN_CTX *); - /* used by EC_POINT_is_at_infinity, EC_POINT_is_on_curve, EC_POINT_cmp: */ int (*is_at_infinity)(const EC_GROUP *, const EC_POINT *); int (*is_on_curve)(const EC_GROUP *, const EC_POINT *, BN_CTX *); - int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); + int (*point_cmp)(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, + BN_CTX *); - /* used by EC_POINT_make_affine, EC_POINTs_make_affine: */ int (*make_affine)(const EC_GROUP *, EC_POINT *, BN_CTX *); - int (*points_make_affine)(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); - - /* used by EC_POINTs_mul, EC_POINT_mul, EC_POINT_precompute_mult, EC_POINT_have_precompute_mult */ - int (*mul_generator_ct)(const EC_GROUP *, EC_POINT *r, const BIGNUM *scalar, BN_CTX *); - int (*mul_single_ct)(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, - const EC_POINT *point, BN_CTX *); - int (*mul_double_nonct)(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar, - const BIGNUM *p_scalar, const EC_POINT *point, BN_CTX *); + int (*points_make_affine)(const EC_GROUP *, size_t num, EC_POINT *[], + BN_CTX *); + + int (*mul_generator_ct)(const EC_GROUP *, EC_POINT *r, + const BIGNUM *scalar, BN_CTX *); + int (*mul_single_ct)(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *scalar, const EC_POINT *point, BN_CTX *); + int (*mul_double_nonct)(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *g_scalar, const BIGNUM *p_scalar, + const EC_POINT *point, BN_CTX *); int (*precompute_mult)(EC_GROUP *group, BN_CTX *); int (*have_precompute_mult)(const EC_GROUP *group); + /* + * Internal methods. + */ - /* internal functions */ - - /* 'field_mul', 'field_sqr', and 'field_div' can be used by 'add' and 'dbl' so that - * the same implementations of point operations can be used with different - * optimized implementations of expensive field operations: */ - int (*field_mul)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); - int (*field_sqr)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); - int (*field_div)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); + /* + * These can be used by 'add' and 'dbl' so that the same implementations + * of point operations can be used with different optimized versions of + * expensive field operations. + */ + int (*field_mul)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, + const BIGNUM *b, BN_CTX *); + int (*field_sqr)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, + BN_CTX *); + int (*field_div)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, + const BIGNUM *b, BN_CTX *); + + /* Encode to and decode from other forms (e.g. Montgomery). */ + int (*field_encode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, + BN_CTX *); + int (*field_decode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, + BN_CTX *); - int (*field_encode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); /* e.g. to Montgomery */ - int (*field_decode)(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); /* e.g. from Montgomery */ int (*field_set_to_one)(const EC_GROUP *, BIGNUM *r, BN_CTX *); - int (*blind_coordinates)(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx); + int (*blind_coordinates)(const EC_GROUP *group, EC_POINT *p, + BN_CTX *ctx); } /* EC_METHOD */; typedef struct ec_extra_data_st { @@ -198,54 +184,67 @@ typedef struct ec_extra_data_st { } EC_EXTRA_DATA; /* used in EC_GROUP */ struct ec_group_st { + /* + * Methods and members exposed via the public API. + */ + const EC_METHOD *meth; - EC_POINT *generator; /* optional */ - BIGNUM order, cofactor; + EC_POINT *generator; /* Optional */ + BIGNUM order; + BIGNUM cofactor; + + int curve_name; /* Optional NID for named curve. */ - int curve_name;/* optional NID for named curve */ - int asn1_flag; /* flag to control the asn1 encoding */ + /* ASN.1 encoding controls. */ + int asn1_flag; point_conversion_form_t asn1_form; - unsigned char *seed; /* optional seed for parameters (appears in ASN1) */ + /* Optional seed for parameters (appears in ASN.1). */ + unsigned char *seed; size_t seed_len; - EC_EXTRA_DATA *extra_data; /* linked list */ - - /* The following members are handled by the method functions, - * even if they appear generic */ - - BIGNUM field; /* Field specification. - * For curves over GF(p), this is the modulus; - * for curves over GF(2^m), this is the - * irreducible polynomial defining the field. - */ - - int poly[6]; /* Field specification for curves over GF(2^m). - * The irreducible f(t) is then of the form: - * t^poly[0] + t^poly[1] + ... + t^poly[k] - * where m = poly[0] > poly[1] > ... > poly[k] = 0. - * The array is terminated with poly[k+1]=-1. - * All elliptic curve irreducibles have at most 5 - * non-zero terms. - */ - - BIGNUM a, b; /* Curve coefficients. - * (Here the assumption is that BIGNUMs can be used - * or abused for all kinds of fields, not just GF(p).) - * For characteristic > 3, the curve is defined - * by a Weierstrass equation of the form - * y^2 = x^3 + a*x + b. - * For characteristic 2, the curve is defined by - * an equation of the form - * y^2 + x*y = x^3 + a*x^2 + b. - */ - - int a_is_minus3; /* enable optimized point arithmetics for special case */ - - void *field_data1; /* method-specific (e.g., Montgomery structure) */ - void *field_data2; /* method-specific */ - int (*field_mod_func)(BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); /* method-specific */ + /* + * Internal methods and members. Handled by the method functions, even + * if they appear to be generic. + */ + + EC_EXTRA_DATA *extra_data; + + /* + * Field specification. For GF(p) this is the modulus; for GF(2^m), + * this is the irreducible polynomial defining the field. + */ + BIGNUM field; + + /* + * Field specification for GF(2^m). The irreducible polynomial is + * f(t) = t^poly[0] + t^poly[1] + ... + t^poly[k], + * where + * m = poly[0] > poly[1] > ... > poly[k] = 0, + * and the array is terminated with poly[k+1] = -1. All elliptic curve + * irreducibles have at most 5 non-zero terms. + */ + int poly[6]; + + /* + * Curve coefficients. In characteristic > 3, the curve is defined by a + * Weierstrass equation of the form + * y^2 = x^3 + a*x + b. + * For characteristic 2, the curve is defined by an equation of the form + * y^2 + x*y = x^3 + a*x^2 + b. + */ + BIGNUM a, b; + + /* Enables optimized point arithmetics for special case. */ + int a_is_minus3; + + /* Montgomery context and values used by EC_GFp_mont_method. */ + BN_MONT_CTX *mont_ctx; + BIGNUM *mont_one; + + int (*field_mod_func)(BIGNUM *, const BIGNUM *, const BIGNUM *, + BN_CTX *); } /* EC_GROUP */; struct ec_key_st { @@ -262,7 +261,7 @@ struct ec_key_st { unsigned int enc_flag; point_conversion_form_t conv_form; - int references; + int references; int flags; EC_EXTRA_DATA *method_data; @@ -290,13 +289,18 @@ int ec_group_simple_order_bits(const EC_GROUP *group); struct ec_point_st { const EC_METHOD *meth; - /* All members except 'meth' are handled by the method functions, - * even if they appear generic */ + /* + * All members except 'meth' are handled by the method functions, + * even if they appear generic. + */ + /* + * Jacobian projective coordinates: (X, Y, Z) represents (X/Z^2, Y/Z^3) + * if Z != 0 + */ BIGNUM X; BIGNUM Y; - BIGNUM Z; /* Jacobian projective coordinates: - * (X, Y, Z) represents (X/Z^2, Y/Z^3) if Z != 0 */ + BIGNUM Z; int Z_is_one; /* enable optimized point arithmetics for special case */ } /* EC_POINT */; @@ -311,7 +315,6 @@ int ec_wNAF_have_precompute_mult(const EC_GROUP *group); /* method functions in ecp_smpl.c */ int ec_GFp_simple_group_init(EC_GROUP *); void ec_GFp_simple_group_finish(EC_GROUP *); -void ec_GFp_simple_group_clear_finish(EC_GROUP *); int ec_GFp_simple_group_copy(EC_GROUP *, const EC_GROUP *); int ec_GFp_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); @@ -319,7 +322,6 @@ int ec_GFp_simple_group_get_degree(const EC_GROUP *); int ec_GFp_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *); int ec_GFp_simple_point_init(EC_POINT *); void ec_GFp_simple_point_finish(EC_POINT *); -void ec_GFp_simple_point_clear_finish(EC_POINT *); int ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *); int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *); int ec_GFp_simple_set_Jprojective_coordinates(const EC_GROUP *, EC_POINT *, @@ -353,100 +355,20 @@ int ec_GFp_simple_mul_single_ct(const EC_GROUP *, EC_POINT *r, const BIGNUM *sca int ec_GFp_simple_mul_double_nonct(const EC_GROUP *, EC_POINT *r, const BIGNUM *g_scalar, const BIGNUM *p_scalar, const EC_POINT *point, BN_CTX *); - -/* method functions in ecp_mont.c */ -int ec_GFp_mont_group_init(EC_GROUP *); -int ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); -void ec_GFp_mont_group_finish(EC_GROUP *); -void ec_GFp_mont_group_clear_finish(EC_GROUP *); -int ec_GFp_mont_group_copy(EC_GROUP *, const EC_GROUP *); -int ec_GFp_mont_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); -int ec_GFp_mont_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); -int ec_GFp_mont_field_encode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); -int ec_GFp_mont_field_decode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); -int ec_GFp_mont_field_set_to_one(const EC_GROUP *, BIGNUM *r, BN_CTX *); - int ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx); -/* method functions in ecp_nist.c */ -int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src); -int ec_GFp_nist_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); -int ec_GFp_nist_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); -int ec_GFp_nist_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); - - -/* method functions in ec2_smpl.c */ -int ec_GF2m_simple_group_init(EC_GROUP *); -void ec_GF2m_simple_group_finish(EC_GROUP *); -void ec_GF2m_simple_group_clear_finish(EC_GROUP *); -int ec_GF2m_simple_group_copy(EC_GROUP *, const EC_GROUP *); -int ec_GF2m_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); -int ec_GF2m_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *); -int ec_GF2m_simple_group_get_degree(const EC_GROUP *); -int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *); -int ec_GF2m_simple_point_init(EC_POINT *); -void ec_GF2m_simple_point_finish(EC_POINT *); -void ec_GF2m_simple_point_clear_finish(EC_POINT *); -int ec_GF2m_simple_point_copy(EC_POINT *, const EC_POINT *); -int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *); -int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, const BIGNUM *y, BN_CTX *); -int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *, const EC_POINT *, - BIGNUM *x, BIGNUM *y, BN_CTX *); int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *, const BIGNUM *x, int y_bit, BN_CTX *); size_t ec_GF2m_simple_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form, unsigned char *buf, size_t len, BN_CTX *); int ec_GF2m_simple_oct2point(const EC_GROUP *, EC_POINT *, const unsigned char *buf, size_t len, BN_CTX *); -int ec_GF2m_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *); -int ec_GF2m_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); -int ec_GF2m_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); -int ec_GF2m_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *); -int ec_GF2m_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); -int ec_GF2m_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *); -int ec_GF2m_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); -int ec_GF2m_simple_points_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *); -int ec_GF2m_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); -int ec_GF2m_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); -int ec_GF2m_simple_field_div(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *); - - -/* method functions in ec2_mult.c */ -int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, - size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); -int ec_GF2m_precompute_mult(EC_GROUP *group, BN_CTX *ctx); -int ec_GF2m_have_precompute_mult(const EC_GROUP *group); -/* method functions in ec2_mult.c */ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); int ec_GF2m_precompute_mult(EC_GROUP *group, BN_CTX *ctx); int ec_GF2m_have_precompute_mult(const EC_GROUP *group); -#ifndef OPENSSL_EC_NISTP_64_GCC_128 -/* method functions in ecp_nistp224.c */ -int ec_GFp_nistp224_group_init(EC_GROUP *group); -int ec_GFp_nistp224_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *n, BN_CTX *); -int ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); -int ec_GFp_nistp224_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); -int ec_GFp_nistp224_points_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx); -int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx); -int ec_GFp_nistp224_have_precompute_mult(const EC_GROUP *group); - -/* method functions in ecp_nistp256.c */ -int ec_GFp_nistp256_group_init(EC_GROUP *group); -int ec_GFp_nistp256_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *n, BN_CTX *); -int ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); -int ec_GFp_nistp256_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); -int ec_GFp_nistp256_points_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx); -int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx); -int ec_GFp_nistp256_have_precompute_mult(const EC_GROUP *group); - -#ifdef ECP_NISTZ256_ASM -const EC_METHOD *EC_GFp_nistz256_method(void); -#endif - /* EC_METHOD definitions */ struct ec_key_method_st { @@ -485,27 +407,4 @@ int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len, int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, EC_KEY *eckey); -/* method functions in ecp_nistp521.c */ -int ec_GFp_nistp521_group_init(EC_GROUP *group); -int ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *n, BN_CTX *); -int ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); -int ec_GFp_nistp521_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *); -int ec_GFp_nistp521_points_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx); -int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx); -int ec_GFp_nistp521_have_precompute_mult(const EC_GROUP *group); - -/* utility functions in ecp_nistputil.c */ -void ec_GFp_nistp_points_make_affine_internal(size_t num, void *point_array, - size_t felem_size, void *tmp_felems, - void (*felem_one)(void *out), - int (*felem_is_zero)(const void *in), - void (*felem_assign)(void *out, const void *in), - void (*felem_square)(void *out, const void *in), - void (*felem_mul)(void *out, const void *in1, const void *in2), - void (*felem_inv)(void *out, const void *in), - void (*felem_contract)(void *out, const void *in)); -void ec_GFp_nistp_recode_scalar_bits(unsigned char *sign, unsigned char *digit, unsigned char in); - -#endif - __END_HIDDEN_DECLS diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c index 05f89a57..c7927256 100644 --- a/crypto/ec/ec_mult.c +++ b/crypto/ec/ec_mult.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_mult.c,v 1.24 2018/07/15 16:27:39 tb Exp $ */ +/* $OpenBSD: ec_mult.c,v 1.28 2023/03/08 05:45:31 jsing Exp $ */ /* * Originally written by Bodo Moeller and Nils Larsch for the OpenSSL project. */ @@ -65,7 +65,7 @@ #include -#include "ec_lcl.h" +#include "ec_local.h" /* @@ -98,7 +98,7 @@ static void ec_pre_comp_free(void *); static void ec_pre_comp_clear_free(void *); static EC_PRE_COMP * -ec_pre_comp_new(const EC_GROUP * group) +ec_pre_comp_new(const EC_GROUP *group) { EC_PRE_COMP *ret = NULL; @@ -132,7 +132,7 @@ ec_pre_comp_dup(void *src_) return src_; } -static void +static void ec_pre_comp_free(void *pre_) { int i; @@ -155,7 +155,7 @@ ec_pre_comp_free(void *pre_) free(pre); } -static void +static void ec_pre_comp_clear_free(void *pre_) { int i; @@ -172,7 +172,7 @@ ec_pre_comp_clear_free(void *pre_) EC_POINT **p; for (p = pre->points; *p != NULL; p++) { - EC_POINT_clear_free(*p); + EC_POINT_free(*p); explicit_bzero(p, sizeof *p); } free(pre->points); @@ -192,7 +192,7 @@ ec_pre_comp_clear_free(void *pre_) * w-1 zeros away from that next non-zero digit. */ static signed char * -compute_wNAF(const BIGNUM * scalar, int w, size_t * ret_len) +compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len) { int window_val; int ok = 0; @@ -331,9 +331,9 @@ compute_wNAF(const BIGNUM * scalar, int w, size_t * ret_len) * scalar*generator * in the addition if scalar != NULL */ -int -ec_wNAF_mul(const EC_GROUP * group, EC_POINT * r, const BIGNUM * scalar, - size_t num, const EC_POINT * points[], const BIGNUM * scalars[], BN_CTX * ctx) +int +ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + size_t num, const EC_POINT *points[], const BIGNUM *scalars[], BN_CTX *ctx) { BN_CTX *new_ctx = NULL; const EC_POINT *generator = NULL; @@ -694,7 +694,7 @@ ec_wNAF_mul(const EC_GROUP * group, EC_POINT * r, const BIGNUM * scalar, } if (val != NULL) { for (v = val; *v != NULL; v++) - EC_POINT_clear_free(*v); + EC_POINT_free(*v); free(val); } free(val_sub); @@ -721,8 +721,8 @@ ec_wNAF_mul(const EC_GROUP * group, EC_POINT * r, const BIGNUM * scalar, * points[2^(w-1)*numblocks-1] = (2^(w-1)) * 2^(blocksize*(numblocks-1)) * generator * points[2^(w-1)*numblocks] = NULL */ -int -ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) +int +ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx) { const EC_POINT *generator; EC_POINT *tmp_point = NULL, *base = NULL, **var; @@ -764,7 +764,7 @@ ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) /* * The following parameters mean we precompute (approximately) one * point per bit. - * + * * TBD: The combination 8, 4 is perfect for 160 bits; for other bit * lengths, other parameter combinations might provide better * efficiency. @@ -875,8 +875,8 @@ ec_wNAF_precompute_mult(EC_GROUP * group, BN_CTX * ctx) } -int -ec_wNAF_have_precompute_mult(const EC_GROUP * group) +int +ec_wNAF_have_precompute_mult(const EC_GROUP *group) { if (EC_EX_DATA_get_data(group->extra_data, ec_pre_comp_dup, ec_pre_comp_free, ec_pre_comp_clear_free) != NULL) return 1; diff --git a/crypto/ec/ec_oct.c b/crypto/ec/ec_oct.c index 45968219..ef17ec59 100644 --- a/crypto/ec/ec_oct.c +++ b/crypto/ec/ec_oct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_oct.c,v 1.8 2021/04/20 17:34:33 tb Exp $ */ +/* $OpenBSD: ec_oct.c,v 1.10 2023/03/08 04:50:27 jsing Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -68,14 +68,13 @@ #include #include -#include "ec_lcl.h" +#include "ec_local.h" int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point, const BIGNUM *x, int y_bit, BN_CTX *ctx) { - if (group->meth->point_set_compressed_coordinates == NULL && - !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { + if (group->meth->point_set_compressed_coordinates == NULL) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } @@ -83,29 +82,8 @@ EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point, ECerror(EC_R_INCOMPATIBLE_OBJECTS); return 0; } - if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { - if (group->meth->field_type == NID_X9_62_prime_field) - return ec_GFp_simple_set_compressed_coordinates( - group, point, x, y_bit, ctx); - else -#ifdef OPENSSL_NO_EC2M - { - ECerror(EC_R_GF2M_NOT_SUPPORTED); - return 0; - } -#else - return ec_GF2m_simple_set_compressed_coordinates( - group, point, x, y_bit, ctx); -#endif - } - if (!group->meth->point_set_compressed_coordinates(group, point, x, - y_bit, ctx)) - return 0; - if (EC_POINT_is_on_curve(group, point, ctx) <= 0) { - ECerror(EC_R_POINT_IS_NOT_ON_CURVE); - return 0; - } - return 1; + return group->meth->point_set_compressed_coordinates(group, point, + x, y_bit, ctx); } int @@ -129,8 +107,7 @@ EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, unsigned char *buf, size_t len, BN_CTX *ctx) { - if (group->meth->point2oct == 0 - && !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { + if (group->meth->point2oct == NULL) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } @@ -138,21 +115,6 @@ EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, ECerror(EC_R_INCOMPATIBLE_OBJECTS); return 0; } - if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { - if (group->meth->field_type == NID_X9_62_prime_field) - return ec_GFp_simple_point2oct(group, point, - form, buf, len, ctx); - else -#ifdef OPENSSL_NO_EC2M - { - ECerror(EC_R_GF2M_NOT_SUPPORTED); - return 0; - } -#else - return ec_GF2m_simple_point2oct(group, point, - form, buf, len, ctx); -#endif - } return group->meth->point2oct(group, point, form, buf, len, ctx); } @@ -160,8 +122,7 @@ int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, const unsigned char *buf, size_t len, BN_CTX *ctx) { - if (group->meth->oct2point == 0 && - !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { + if (group->meth->oct2point == NULL) { ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); return 0; } @@ -169,20 +130,5 @@ EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, ECerror(EC_R_INCOMPATIBLE_OBJECTS); return 0; } - if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { - if (group->meth->field_type == NID_X9_62_prime_field) - return ec_GFp_simple_oct2point(group, point, - buf, len, ctx); - else -#ifdef OPENSSL_NO_EC2M - { - ECerror(EC_R_GF2M_NOT_SUPPORTED); - return 0; - } -#else - return ec_GF2m_simple_oct2point(group, point, - buf, len, ctx); -#endif - } return group->meth->oct2point(group, point, buf, len, ctx); } diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c index 63e63592..95822240 100644 --- a/crypto/ec/ec_pmeth.c +++ b/crypto/ec/ec_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_pmeth.c,v 1.13 2021/12/04 16:08:32 tb Exp $ */ +/* $OpenBSD: ec_pmeth.c,v 1.16 2022/11/26 16:08:52 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -66,10 +66,10 @@ #include #include -#include "bn_lcl.h" -#include "ec_lcl.h" -#include "ech_locl.h" -#include "evp_locl.h" +#include "bn_local.h" +#include "ec_local.h" +#include "ech_local.h" +#include "evp_local.h" /* EC pkey context structure */ @@ -93,8 +93,8 @@ typedef struct { size_t kdf_outlen; } EC_PKEY_CTX; -static int -pkey_ec_init(EVP_PKEY_CTX * ctx) +static int +pkey_ec_init(EVP_PKEY_CTX *ctx) { EC_PKEY_CTX *dctx; @@ -111,8 +111,8 @@ pkey_ec_init(EVP_PKEY_CTX * ctx) return 1; } -static int -pkey_ec_copy(EVP_PKEY_CTX * dst, EVP_PKEY_CTX * src) +static int +pkey_ec_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) { EC_PKEY_CTX *dctx, *sctx; if (!pkey_ec_init(dst)) @@ -146,8 +146,8 @@ pkey_ec_copy(EVP_PKEY_CTX * dst, EVP_PKEY_CTX * src) return 1; } -static void -pkey_ec_cleanup(EVP_PKEY_CTX * ctx) +static void +pkey_ec_cleanup(EVP_PKEY_CTX *ctx) { EC_PKEY_CTX *dctx = ctx->data; @@ -160,8 +160,8 @@ pkey_ec_cleanup(EVP_PKEY_CTX * ctx) } } -static int -pkey_ec_sign(EVP_PKEY_CTX * ctx, unsigned char *sig, size_t * siglen, +static int +pkey_ec_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, const unsigned char *tbs, size_t tbslen) { int ret, type; @@ -188,8 +188,8 @@ pkey_ec_sign(EVP_PKEY_CTX * ctx, unsigned char *sig, size_t * siglen, return 1; } -static int -pkey_ec_verify(EVP_PKEY_CTX * ctx, +static int +pkey_ec_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, size_t tbslen) { @@ -207,8 +207,8 @@ pkey_ec_verify(EVP_PKEY_CTX * ctx, return ret; } -static int -pkey_ec_derive(EVP_PKEY_CTX * ctx, unsigned char *key, size_t * keylen) +static int +pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen) { int ret; size_t outlen; @@ -283,8 +283,8 @@ pkey_ec_kdf_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen) return rv; } -static int -pkey_ec_ctrl(EVP_PKEY_CTX * ctx, int type, int p1, void *p2) +static int +pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) { EC_PKEY_CTX *dctx = ctx->data; EC_GROUP *group; @@ -410,8 +410,8 @@ pkey_ec_ctrl(EVP_PKEY_CTX * ctx, int type, int p1, void *p2) } } -static int -pkey_ec_ctrl_str(EVP_PKEY_CTX * ctx, const char *type, const char *value) +static int +pkey_ec_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { if (!strcmp(type, "ec_paramgen_curve")) { int nid; @@ -449,8 +449,8 @@ pkey_ec_ctrl_str(EVP_PKEY_CTX * ctx, const char *type, const char *value) return -2; } -static int -pkey_ec_paramgen(EVP_PKEY_CTX * ctx, EVP_PKEY * pkey) +static int +pkey_ec_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) { EC_KEY *ec = NULL; EC_PKEY_CTX *dctx = ctx->data; @@ -470,8 +470,8 @@ pkey_ec_paramgen(EVP_PKEY_CTX * ctx, EVP_PKEY * pkey) return ret; } -static int -pkey_ec_keygen(EVP_PKEY_CTX * ctx, EVP_PKEY * pkey) +static int +pkey_ec_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) { EC_KEY *ec = NULL; EC_PKEY_CTX *dctx = ctx->data; diff --git a/crypto/ec/ec_print.c b/crypto/ec/ec_print.c index af4d1996..2aa0aa66 100644 --- a/crypto/ec/ec_print.c +++ b/crypto/ec/ec_print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_print.c,v 1.7 2014/12/03 19:53:20 deraadt Exp $ */ +/* $OpenBSD: ec_print.c,v 1.11 2023/03/08 05:45:31 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -54,11 +54,11 @@ */ #include -#include "ec_lcl.h" +#include "ec_local.h" BIGNUM * -EC_POINT_point2bn(const EC_GROUP * group, const EC_POINT * point, - point_conversion_form_t form, BIGNUM * ret, BN_CTX * ctx) +EC_POINT_point2bn(const EC_GROUP *group, const EC_POINT *point, + point_conversion_form_t form, BIGNUM *ret, BN_CTX *ctx) { size_t buf_len = 0; unsigned char *buf; @@ -83,8 +83,8 @@ EC_POINT_point2bn(const EC_GROUP * group, const EC_POINT * point, } EC_POINT * -EC_POINT_bn2point(const EC_GROUP * group, - const BIGNUM * bn, EC_POINT * point, BN_CTX * ctx) +EC_POINT_bn2point(const EC_GROUP *group, + const BIGNUM *bn, EC_POINT *point, BN_CTX *ctx) { size_t buf_len = 0; unsigned char *buf; @@ -110,7 +110,7 @@ EC_POINT_bn2point(const EC_GROUP * group, if (!EC_POINT_oct2point(group, ret, buf, buf_len, ctx)) { if (point == NULL) - EC_POINT_clear_free(ret); + EC_POINT_free(ret); free(buf); return NULL; } @@ -122,8 +122,8 @@ static const char *HEX_DIGITS = "0123456789ABCDEF"; /* the return value must be freed (using free()) */ char * -EC_POINT_point2hex(const EC_GROUP * group, const EC_POINT * point, - point_conversion_form_t form, BN_CTX * ctx) +EC_POINT_point2hex(const EC_GROUP *group, const EC_POINT *point, + point_conversion_form_t form, BN_CTX *ctx) { char *ret, *p; size_t buf_len = 0, i; @@ -161,8 +161,8 @@ EC_POINT_point2hex(const EC_GROUP * group, const EC_POINT * point, } EC_POINT * -EC_POINT_hex2point(const EC_GROUP * group, const char *buf, - EC_POINT * point, BN_CTX * ctx) +EC_POINT_hex2point(const EC_GROUP *group, const char *buf, + EC_POINT *point, BN_CTX *ctx) { EC_POINT *ret = NULL; BIGNUM *tmp_bn = NULL; @@ -172,7 +172,7 @@ EC_POINT_hex2point(const EC_GROUP * group, const char *buf, ret = EC_POINT_bn2point(group, tmp_bn, point, ctx); - BN_clear_free(tmp_bn); + BN_free(tmp_bn); return ret; } diff --git a/crypto/ec/eck_prn.c b/crypto/ec/eck_prn.c index c2fd2ebc..f7ce8deb 100644 --- a/crypto/ec/eck_prn.c +++ b/crypto/ec/eck_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eck_prn.c,v 1.17 2021/04/20 17:12:43 tb Exp $ */ +/* $OpenBSD: eck_prn.c,v 1.20 2022/11/19 07:29:29 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -69,8 +69,8 @@ #include #include -int -ECPKParameters_print_fp(FILE * fp, const EC_GROUP * x, int off) +int +ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off) { BIO *b; int ret; @@ -85,8 +85,8 @@ ECPKParameters_print_fp(FILE * fp, const EC_GROUP * x, int off) return (ret); } -int -EC_KEY_print_fp(FILE * fp, const EC_KEY * x, int off) +int +EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off) { BIO *b; int ret; @@ -101,8 +101,8 @@ EC_KEY_print_fp(FILE * fp, const EC_KEY * x, int off) return (ret); } -int -ECParameters_print_fp(FILE * fp, const EC_KEY * x) +int +ECParameters_print_fp(FILE *fp, const EC_KEY *x) { BIO *b; int ret; @@ -117,38 +117,48 @@ ECParameters_print_fp(FILE * fp, const EC_KEY * x) return (ret); } -int -EC_KEY_print(BIO * bp, const EC_KEY * x, int off) +int +EC_KEY_print(BIO *bp, const EC_KEY *x, int off) { EVP_PKEY *pk; - int ret; - pk = EVP_PKEY_new(); - if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) - return 0; + int ret = 0; + + if ((pk = EVP_PKEY_new()) == NULL) + goto err; + + if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) + goto err; + ret = EVP_PKEY_print_private(bp, pk, off, NULL); + err: EVP_PKEY_free(pk); return ret; } -int -ECParameters_print(BIO * bp, const EC_KEY * x) +int +ECParameters_print(BIO *bp, const EC_KEY *x) { EVP_PKEY *pk; - int ret; - pk = EVP_PKEY_new(); - if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) - return 0; + int ret = 0; + + if ((pk = EVP_PKEY_new()) == NULL) + goto err; + + if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) + goto err; + ret = EVP_PKEY_print_params(bp, pk, 4, NULL); + err: EVP_PKEY_free(pk); return ret; } -static int -print_bin(BIO * fp, const char *str, const unsigned char *num, +static int +print_bin(BIO *fp, const char *str, const unsigned char *num, size_t len, int off); -int -ECPKParameters_print(BIO * bp, const EC_GROUP * x, int off) +int +ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off) { unsigned char *buffer = NULL; size_t buf_len = 0, i; @@ -323,8 +333,8 @@ ECPKParameters_print(BIO * bp, const EC_GROUP * x, int off) return (ret); } -static int -print_bin(BIO * fp, const char *name, const unsigned char *buf, +static int +print_bin(BIO *fp, const char *name, const unsigned char *buf, size_t len, int off) { size_t i; diff --git a/crypto/ec/ecp_mont.c b/crypto/ec/ecp_mont.c index 0da3083d..8b85bf32 100644 --- a/crypto/ec/ecp_mont.c +++ b/crypto/ec/ecp_mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_mont.c,v 1.20 2021/09/08 17:29:21 tb Exp $ */ +/* $OpenBSD: ecp_mont.c,v 1.27 2023/03/08 05:45:31 jsing Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -63,130 +63,67 @@ #include -#include "ec_lcl.h" +#include "ec_local.h" - -const EC_METHOD * -EC_GFp_mont_method(void) +static void +ec_GFp_mont_group_clear(EC_GROUP *group) { - static const EC_METHOD ret = { - .flags = EC_FLAGS_DEFAULT_OCT, - .field_type = NID_X9_62_prime_field, - .group_init = ec_GFp_mont_group_init, - .group_finish = ec_GFp_mont_group_finish, - .group_clear_finish = ec_GFp_mont_group_clear_finish, - .group_copy = ec_GFp_mont_group_copy, - .group_set_curve = ec_GFp_mont_group_set_curve, - .group_get_curve = ec_GFp_simple_group_get_curve, - .group_get_degree = ec_GFp_simple_group_get_degree, - .group_order_bits = ec_group_simple_order_bits, - .group_check_discriminant = - ec_GFp_simple_group_check_discriminant, - .point_init = ec_GFp_simple_point_init, - .point_finish = ec_GFp_simple_point_finish, - .point_clear_finish = ec_GFp_simple_point_clear_finish, - .point_copy = ec_GFp_simple_point_copy, - .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, - .point_set_Jprojective_coordinates = - ec_GFp_simple_set_Jprojective_coordinates, - .point_get_Jprojective_coordinates = - ec_GFp_simple_get_Jprojective_coordinates, - .point_set_affine_coordinates = - ec_GFp_simple_point_set_affine_coordinates, - .point_get_affine_coordinates = - ec_GFp_simple_point_get_affine_coordinates, - .add = ec_GFp_simple_add, - .dbl = ec_GFp_simple_dbl, - .invert = ec_GFp_simple_invert, - .is_at_infinity = ec_GFp_simple_is_at_infinity, - .is_on_curve = ec_GFp_simple_is_on_curve, - .point_cmp = ec_GFp_simple_cmp, - .make_affine = ec_GFp_simple_make_affine, - .points_make_affine = ec_GFp_simple_points_make_affine, - .mul_generator_ct = ec_GFp_simple_mul_generator_ct, - .mul_single_ct = ec_GFp_simple_mul_single_ct, - .mul_double_nonct = ec_GFp_simple_mul_double_nonct, - .field_mul = ec_GFp_mont_field_mul, - .field_sqr = ec_GFp_mont_field_sqr, - .field_encode = ec_GFp_mont_field_encode, - .field_decode = ec_GFp_mont_field_decode, - .field_set_to_one = ec_GFp_mont_field_set_to_one, - .blind_coordinates = ec_GFp_simple_blind_coordinates, - }; + BN_MONT_CTX_free(group->mont_ctx); + group->mont_ctx = NULL; - return &ret; + BN_free(group->mont_one); + group->mont_one = NULL; } - -int -ec_GFp_mont_group_init(EC_GROUP * group) +static int +ec_GFp_mont_group_init(EC_GROUP *group) { int ok; ok = ec_GFp_simple_group_init(group); - group->field_data1 = NULL; - group->field_data2 = NULL; + group->mont_ctx = NULL; + group->mont_one = NULL; return ok; } - -void -ec_GFp_mont_group_finish(EC_GROUP * group) +static void +ec_GFp_mont_group_finish(EC_GROUP *group) { - BN_MONT_CTX_free(group->field_data1); - group->field_data1 = NULL; - BN_free(group->field_data2); - group->field_data2 = NULL; + ec_GFp_mont_group_clear(group); ec_GFp_simple_group_finish(group); } - -void -ec_GFp_mont_group_clear_finish(EC_GROUP * group) +static int +ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src) { - BN_MONT_CTX_free(group->field_data1); - group->field_data1 = NULL; - BN_clear_free(group->field_data2); - group->field_data2 = NULL; - ec_GFp_simple_group_clear_finish(group); -} - - -int -ec_GFp_mont_group_copy(EC_GROUP * dest, const EC_GROUP * src) -{ - BN_MONT_CTX_free(dest->field_data1); - dest->field_data1 = NULL; - BN_clear_free(dest->field_data2); - dest->field_data2 = NULL; + ec_GFp_mont_group_clear(dest); if (!ec_GFp_simple_group_copy(dest, src)) return 0; - if (src->field_data1 != NULL) { - dest->field_data1 = BN_MONT_CTX_new(); - if (dest->field_data1 == NULL) + if (src->mont_ctx != NULL) { + dest->mont_ctx = BN_MONT_CTX_new(); + if (dest->mont_ctx == NULL) return 0; - if (!BN_MONT_CTX_copy(dest->field_data1, src->field_data1)) + if (!BN_MONT_CTX_copy(dest->mont_ctx, src->mont_ctx)) goto err; } - if (src->field_data2 != NULL) { - dest->field_data2 = BN_dup(src->field_data2); - if (dest->field_data2 == NULL) + if (src->mont_one != NULL) { + dest->mont_one = BN_dup(src->mont_one); + if (dest->mont_one == NULL) goto err; } return 1; err: - if (dest->field_data1 != NULL) { - BN_MONT_CTX_free(dest->field_data1); - dest->field_data1 = NULL; + if (dest->mont_ctx != NULL) { + BN_MONT_CTX_free(dest->mont_ctx); + dest->mont_ctx = NULL; } return 0; } - -int +static int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { @@ -195,10 +132,8 @@ ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, BIGNUM *one = NULL; int ret = 0; - BN_MONT_CTX_free(group->field_data1); - group->field_data1 = NULL; - BN_free(group->field_data2); - group->field_data2 = NULL; + ec_GFp_mont_group_clear(group); + if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) @@ -217,19 +152,16 @@ ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, if (!BN_to_montgomery(one, BN_value_one(), mont, ctx)) goto err; - group->field_data1 = mont; + group->mont_ctx = mont; mont = NULL; - group->field_data2 = one; + group->mont_one = one; one = NULL; ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); - if (!ret) { - BN_MONT_CTX_free(group->field_data1); - group->field_data1 = NULL; - BN_free(group->field_data2); - group->field_data2 = NULL; - } + if (!ret) + ec_GFp_mont_group_clear(group); + err: BN_CTX_free(new_ctx); BN_MONT_CTX_free(mont); @@ -237,63 +169,109 @@ ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, return ret; } - -int +static int ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { - if (group->field_data1 == NULL) { + if (group->mont_ctx == NULL) { ECerror(EC_R_NOT_INITIALIZED); return 0; } - return BN_mod_mul_montgomery(r, a, b, group->field_data1, ctx); + return BN_mod_mul_montgomery(r, a, b, group->mont_ctx, ctx); } - -int +static int ec_GFp_mont_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { - if (group->field_data1 == NULL) { + if (group->mont_ctx == NULL) { ECerror(EC_R_NOT_INITIALIZED); return 0; } - return BN_mod_mul_montgomery(r, a, a, group->field_data1, ctx); + return BN_mod_mul_montgomery(r, a, a, group->mont_ctx, ctx); } - -int +static int ec_GFp_mont_field_encode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { - if (group->field_data1 == NULL) { + if (group->mont_ctx == NULL) { ECerror(EC_R_NOT_INITIALIZED); return 0; } - return BN_to_montgomery(r, a, (BN_MONT_CTX *) group->field_data1, ctx); + return BN_to_montgomery(r, a, group->mont_ctx, ctx); } - -int +static int ec_GFp_mont_field_decode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { - if (group->field_data1 == NULL) { + if (group->mont_ctx == NULL) { ECerror(EC_R_NOT_INITIALIZED); return 0; } - return BN_from_montgomery(r, a, group->field_data1, ctx); + return BN_from_montgomery(r, a, group->mont_ctx, ctx); } - -int +static int ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx) { - if (group->field_data2 == NULL) { + if (group->mont_one == NULL) { ECerror(EC_R_NOT_INITIALIZED); return 0; } - if (!BN_copy(r, group->field_data2)) + if (!BN_copy(r, group->mont_one)) return 0; return 1; } + +static const EC_METHOD ec_GFp_mont_method = { + .field_type = NID_X9_62_prime_field, + .group_init = ec_GFp_mont_group_init, + .group_finish = ec_GFp_mont_group_finish, + .group_copy = ec_GFp_mont_group_copy, + .group_set_curve = ec_GFp_mont_group_set_curve, + .group_get_curve = ec_GFp_simple_group_get_curve, + .group_get_degree = ec_GFp_simple_group_get_degree, + .group_order_bits = ec_group_simple_order_bits, + .group_check_discriminant = ec_GFp_simple_group_check_discriminant, + .point_init = ec_GFp_simple_point_init, + .point_finish = ec_GFp_simple_point_finish, + .point_copy = ec_GFp_simple_point_copy, + .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, + .point_set_Jprojective_coordinates = + ec_GFp_simple_set_Jprojective_coordinates, + .point_get_Jprojective_coordinates = + ec_GFp_simple_get_Jprojective_coordinates, + .point_set_affine_coordinates = + ec_GFp_simple_point_set_affine_coordinates, + .point_get_affine_coordinates = + ec_GFp_simple_point_get_affine_coordinates, + .point_set_compressed_coordinates = + ec_GFp_simple_set_compressed_coordinates, + .point2oct = ec_GFp_simple_point2oct, + .oct2point = ec_GFp_simple_oct2point, + .add = ec_GFp_simple_add, + .dbl = ec_GFp_simple_dbl, + .invert = ec_GFp_simple_invert, + .is_at_infinity = ec_GFp_simple_is_at_infinity, + .is_on_curve = ec_GFp_simple_is_on_curve, + .point_cmp = ec_GFp_simple_cmp, + .make_affine = ec_GFp_simple_make_affine, + .points_make_affine = ec_GFp_simple_points_make_affine, + .mul_generator_ct = ec_GFp_simple_mul_generator_ct, + .mul_single_ct = ec_GFp_simple_mul_single_ct, + .mul_double_nonct = ec_GFp_simple_mul_double_nonct, + .field_mul = ec_GFp_mont_field_mul, + .field_sqr = ec_GFp_mont_field_sqr, + .field_encode = ec_GFp_mont_field_encode, + .field_decode = ec_GFp_mont_field_decode, + .field_set_to_one = ec_GFp_mont_field_set_to_one, + .blind_coordinates = ec_GFp_simple_blind_coordinates, +}; + +const EC_METHOD * +EC_GFp_mont_method(void) +{ + return &ec_GFp_mont_method; +} diff --git a/crypto/ec/ecp_nist.c b/crypto/ec/ecp_nist.c index b3cea0c4..b8fb5dc9 100644 --- a/crypto/ec/ecp_nist.c +++ b/crypto/ec/ecp_nist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nist.c,v 1.19 2022/06/30 11:14:47 tb Exp $ */ +/* $OpenBSD: ecp_nist.c,v 1.24 2023/03/08 05:45:31 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -66,65 +66,17 @@ #include #include -#include "ec_lcl.h" +#include "ec_local.h" -const EC_METHOD * -EC_GFp_nist_method(void) -{ - static const EC_METHOD ret = { - .flags = EC_FLAGS_DEFAULT_OCT, - .field_type = NID_X9_62_prime_field, - .group_init = ec_GFp_simple_group_init, - .group_finish = ec_GFp_simple_group_finish, - .group_clear_finish = ec_GFp_simple_group_clear_finish, - .group_copy = ec_GFp_nist_group_copy, - .group_set_curve = ec_GFp_nist_group_set_curve, - .group_get_curve = ec_GFp_simple_group_get_curve, - .group_get_degree = ec_GFp_simple_group_get_degree, - .group_order_bits = ec_group_simple_order_bits, - .group_check_discriminant = - ec_GFp_simple_group_check_discriminant, - .point_init = ec_GFp_simple_point_init, - .point_finish = ec_GFp_simple_point_finish, - .point_clear_finish = ec_GFp_simple_point_clear_finish, - .point_copy = ec_GFp_simple_point_copy, - .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, - .point_set_Jprojective_coordinates = - ec_GFp_simple_set_Jprojective_coordinates, - .point_get_Jprojective_coordinates = - ec_GFp_simple_get_Jprojective_coordinates, - .point_set_affine_coordinates = - ec_GFp_simple_point_set_affine_coordinates, - .point_get_affine_coordinates = - ec_GFp_simple_point_get_affine_coordinates, - .add = ec_GFp_simple_add, - .dbl = ec_GFp_simple_dbl, - .invert = ec_GFp_simple_invert, - .is_at_infinity = ec_GFp_simple_is_at_infinity, - .is_on_curve = ec_GFp_simple_is_on_curve, - .point_cmp = ec_GFp_simple_cmp, - .make_affine = ec_GFp_simple_make_affine, - .points_make_affine = ec_GFp_simple_points_make_affine, - .mul_generator_ct = ec_GFp_simple_mul_generator_ct, - .mul_single_ct = ec_GFp_simple_mul_single_ct, - .mul_double_nonct = ec_GFp_simple_mul_double_nonct, - .field_mul = ec_GFp_nist_field_mul, - .field_sqr = ec_GFp_nist_field_sqr, - .blind_coordinates = ec_GFp_simple_blind_coordinates, - }; - - return &ret; -} - -int -ec_GFp_nist_group_copy(EC_GROUP * dest, const EC_GROUP * src) +static int +ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src) { dest->field_mod_func = src->field_mod_func; return ec_GFp_simple_group_copy(dest, src); } -int +static int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { @@ -163,8 +115,7 @@ ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p, return ret; } - -int +static int ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { @@ -190,10 +141,9 @@ ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, return ret; } - -int -ec_GFp_nist_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, - BN_CTX * ctx) +static int +ec_GFp_nist_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, + BN_CTX *ctx) { int ret = 0; BN_CTX *ctx_new = NULL; @@ -216,3 +166,51 @@ ec_GFp_nist_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN_CTX_free(ctx_new); return ret; } + +static const EC_METHOD ec_GFp_nist_method = { + .field_type = NID_X9_62_prime_field, + .group_init = ec_GFp_simple_group_init, + .group_finish = ec_GFp_simple_group_finish, + .group_copy = ec_GFp_nist_group_copy, + .group_set_curve = ec_GFp_nist_group_set_curve, + .group_get_curve = ec_GFp_simple_group_get_curve, + .group_get_degree = ec_GFp_simple_group_get_degree, + .group_order_bits = ec_group_simple_order_bits, + .group_check_discriminant = ec_GFp_simple_group_check_discriminant, + .point_init = ec_GFp_simple_point_init, + .point_finish = ec_GFp_simple_point_finish, + .point_copy = ec_GFp_simple_point_copy, + .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, + .point_set_Jprojective_coordinates = + ec_GFp_simple_set_Jprojective_coordinates, + .point_get_Jprojective_coordinates = + ec_GFp_simple_get_Jprojective_coordinates, + .point_set_affine_coordinates = + ec_GFp_simple_point_set_affine_coordinates, + .point_get_affine_coordinates = + ec_GFp_simple_point_get_affine_coordinates, + .point_set_compressed_coordinates = + ec_GFp_simple_set_compressed_coordinates, + .point2oct = ec_GFp_simple_point2oct, + .oct2point = ec_GFp_simple_oct2point, + .add = ec_GFp_simple_add, + .dbl = ec_GFp_simple_dbl, + .invert = ec_GFp_simple_invert, + .is_at_infinity = ec_GFp_simple_is_at_infinity, + .is_on_curve = ec_GFp_simple_is_on_curve, + .point_cmp = ec_GFp_simple_cmp, + .make_affine = ec_GFp_simple_make_affine, + .points_make_affine = ec_GFp_simple_points_make_affine, + .mul_generator_ct = ec_GFp_simple_mul_generator_ct, + .mul_single_ct = ec_GFp_simple_mul_single_ct, + .mul_double_nonct = ec_GFp_simple_mul_double_nonct, + .field_mul = ec_GFp_nist_field_mul, + .field_sqr = ec_GFp_nist_field_sqr, + .blind_coordinates = ec_GFp_simple_blind_coordinates, +}; + +const EC_METHOD * +EC_GFp_nist_method(void) +{ + return &ec_GFp_nist_method; +} diff --git a/crypto/ec/ecp_oct.c b/crypto/ec/ecp_oct.c index 177bbe15..f2f1929e 100644 --- a/crypto/ec/ecp_oct.c +++ b/crypto/ec/ecp_oct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_oct.c,v 1.14 2021/04/20 17:32:57 tb Exp $ */ +/* $OpenBSD: ecp_oct.c,v 1.19 2022/11/26 16:08:52 tb Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -64,11 +64,11 @@ #include -#include "ec_lcl.h" +#include "ec_local.h" -int -ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, - EC_POINT * point, const BIGNUM * x_, int y_bit, BN_CTX * ctx) +int +ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group, + EC_POINT *point, const BIGNUM *x_, int y_bit, BN_CTX *ctx) { BN_CTX *new_ctx = NULL; BIGNUM *tmp1, *tmp2, *x, *y; @@ -162,28 +162,15 @@ ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, } if (y_bit != BN_is_odd(y)) { if (BN_is_zero(y)) { - int kron; - - kron = BN_kronecker(x, &group->field, ctx); - if (kron == -2) - goto err; - - if (kron == 1) - ECerror(EC_R_INVALID_COMPRESSION_BIT); - else - /* - * BN_mod_sqrt() should have cought this - * error (not a square) - */ - ECerror(EC_R_INVALID_COMPRESSED_POINT); + ECerror(EC_R_INVALID_COMPRESSION_BIT); goto err; } if (!BN_usub(y, &group->field, y)) goto err; - } - if (y_bit != BN_is_odd(y)) { - ECerror(ERR_R_INTERNAL_ERROR); - goto err; + if (y_bit != BN_is_odd(y)) { + ECerror(ERR_R_INTERNAL_ERROR); + goto err; + } } if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)) goto err; @@ -197,9 +184,9 @@ ec_GFp_simple_set_compressed_coordinates(const EC_GROUP * group, } -size_t -ec_GFp_simple_point2oct(const EC_GROUP * group, const EC_POINT * point, point_conversion_form_t form, - unsigned char *buf, size_t len, BN_CTX * ctx) +size_t +ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *ctx) { size_t ret; BN_CTX *new_ctx = NULL; @@ -302,9 +289,9 @@ ec_GFp_simple_point2oct(const EC_GROUP * group, const EC_POINT * point, point_co } -int -ec_GFp_simple_oct2point(const EC_GROUP * group, EC_POINT * point, - const unsigned char *buf, size_t len, BN_CTX * ctx) +int +ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point, + const unsigned char *buf, size_t len, BN_CTX *ctx) { point_conversion_form_t form; int y_bit; diff --git a/crypto/ec/ecp_smpl.c b/crypto/ec/ecp_smpl.c index 6f5280bb..9af60346 100644 --- a/crypto/ec/ecp_smpl.c +++ b/crypto/ec/ecp_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_smpl.c,v 1.34 2022/01/20 11:02:44 inoguchi Exp $ */ +/* $OpenBSD: ecp_smpl.c,v 1.42 2023/03/08 05:45:31 jsing Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -64,74 +64,25 @@ #include -#include "bn_lcl.h" -#include "ec_lcl.h" +#include "bn_local.h" +#include "ec_local.h" -const EC_METHOD * -EC_GFp_simple_method(void) -{ - static const EC_METHOD ret = { - .flags = EC_FLAGS_DEFAULT_OCT, - .field_type = NID_X9_62_prime_field, - .group_init = ec_GFp_simple_group_init, - .group_finish = ec_GFp_simple_group_finish, - .group_clear_finish = ec_GFp_simple_group_clear_finish, - .group_copy = ec_GFp_simple_group_copy, - .group_set_curve = ec_GFp_simple_group_set_curve, - .group_get_curve = ec_GFp_simple_group_get_curve, - .group_get_degree = ec_GFp_simple_group_get_degree, - .group_order_bits = ec_group_simple_order_bits, - .group_check_discriminant = - ec_GFp_simple_group_check_discriminant, - .point_init = ec_GFp_simple_point_init, - .point_finish = ec_GFp_simple_point_finish, - .point_clear_finish = ec_GFp_simple_point_clear_finish, - .point_copy = ec_GFp_simple_point_copy, - .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, - .point_set_Jprojective_coordinates = - ec_GFp_simple_set_Jprojective_coordinates, - .point_get_Jprojective_coordinates = - ec_GFp_simple_get_Jprojective_coordinates, - .point_set_affine_coordinates = - ec_GFp_simple_point_set_affine_coordinates, - .point_get_affine_coordinates = - ec_GFp_simple_point_get_affine_coordinates, - .add = ec_GFp_simple_add, - .dbl = ec_GFp_simple_dbl, - .invert = ec_GFp_simple_invert, - .is_at_infinity = ec_GFp_simple_is_at_infinity, - .is_on_curve = ec_GFp_simple_is_on_curve, - .point_cmp = ec_GFp_simple_cmp, - .make_affine = ec_GFp_simple_make_affine, - .points_make_affine = ec_GFp_simple_points_make_affine, - .mul_generator_ct = ec_GFp_simple_mul_generator_ct, - .mul_single_ct = ec_GFp_simple_mul_single_ct, - .mul_double_nonct = ec_GFp_simple_mul_double_nonct, - .field_mul = ec_GFp_simple_field_mul, - .field_sqr = ec_GFp_simple_field_sqr, - .blind_coordinates = ec_GFp_simple_blind_coordinates, - }; - - return &ret; -} - - -/* Most method functions in this file are designed to work with +/* + * Most method functions in this file are designed to work with * non-trivial representations of field elements if necessary * (see ecp_mont.c): while standard modular addition and subtraction * are used, the field_mul and field_sqr methods will be used for * multiplication, and field_encode and field_decode (if defined) * will be used for converting between representations. - + * * Functions ec_GFp_simple_points_make_affine() and * ec_GFp_simple_point_get_affine_coordinates() specifically assume * that if a non-trivial representation is used, it is a Montgomery * representation (i.e. 'encoding' means multiplying by some factor R). */ - int -ec_GFp_simple_group_init(EC_GROUP * group) +ec_GFp_simple_group_init(EC_GROUP *group) { BN_init(&group->field); BN_init(&group->a); @@ -140,27 +91,16 @@ ec_GFp_simple_group_init(EC_GROUP * group) return 1; } - void -ec_GFp_simple_group_finish(EC_GROUP * group) +ec_GFp_simple_group_finish(EC_GROUP *group) { BN_free(&group->field); BN_free(&group->a); BN_free(&group->b); } - -void -ec_GFp_simple_group_clear_finish(EC_GROUP * group) -{ - BN_clear_free(&group->field); - BN_clear_free(&group->a); - BN_clear_free(&group->b); -} - - int -ec_GFp_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) +ec_GFp_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) { if (!BN_copy(&dest->field, &src->field)) return 0; @@ -174,10 +114,9 @@ ec_GFp_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) return 1; } - int -ec_GFp_simple_group_set_curve(EC_GROUP * group, - const BIGNUM * p, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) +ec_GFp_simple_group_set_curve(EC_GROUP *group, + const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { int ret = 0; BN_CTX *new_ctx = NULL; @@ -231,9 +170,8 @@ ec_GFp_simple_group_set_curve(EC_GROUP * group, return ret; } - int -ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BIGNUM * b, BN_CTX * ctx) +ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) { int ret = 0; BN_CTX *new_ctx = NULL; @@ -275,16 +213,14 @@ ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BI return ret; } - int -ec_GFp_simple_group_get_degree(const EC_GROUP * group) +ec_GFp_simple_group_get_degree(const EC_GROUP *group) { return BN_num_bits(&group->field); } - int -ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) +ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) { int ret = 0; BIGNUM *a, *b, *order, *tmp_1, *tmp_2; @@ -358,7 +294,6 @@ ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) return ret; } - int ec_GFp_simple_point_init(EC_POINT * point) { @@ -370,28 +305,17 @@ ec_GFp_simple_point_init(EC_POINT * point) return 1; } - void -ec_GFp_simple_point_finish(EC_POINT * point) +ec_GFp_simple_point_finish(EC_POINT *point) { BN_free(&point->X); BN_free(&point->Y); BN_free(&point->Z); -} - - -void -ec_GFp_simple_point_clear_finish(EC_POINT * point) -{ - BN_clear_free(&point->X); - BN_clear_free(&point->Y); - BN_clear_free(&point->Z); point->Z_is_one = 0; } - int -ec_GFp_simple_point_copy(EC_POINT * dest, const EC_POINT * src) +ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src) { if (!BN_copy(&dest->X, &src->X)) return 0; @@ -404,16 +328,14 @@ ec_GFp_simple_point_copy(EC_POINT * dest, const EC_POINT * src) return 1; } - int -ec_GFp_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point) +ec_GFp_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point) { point->Z_is_one = 0; BN_zero(&point->Z); return 1; } - int ec_GFp_simple_set_Jprojective_coordinates(const EC_GROUP *group, EC_POINT *point, const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, @@ -515,8 +437,8 @@ ec_GFp_simple_get_Jprojective_coordinates(const EC_GROUP *group, } int -ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * point, - const BIGNUM * x, const BIGNUM * y, BN_CTX * ctx) +ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point, + const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx) { if (x == NULL || y == NULL) { /* unlike for projective coordinates, we do not tolerate this */ @@ -528,8 +450,8 @@ ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP * group, EC_POINT * po } int -ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POINT * point, - BIGNUM * x, BIGNUM * y, BN_CTX * ctx) +ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point, + BIGNUM *x, BIGNUM *y, BN_CTX *ctx) { BN_CTX *new_ctx = NULL; BIGNUM *Z, *Z_1, *Z_2, *Z_3; @@ -635,7 +557,7 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POIN } int -ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) +ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) { int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); @@ -822,9 +744,8 @@ ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, cons return ret; } - int -ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_CTX * ctx) +ec_GFp_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx) { int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); @@ -964,9 +885,8 @@ ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_C return ret; } - int -ec_GFp_simple_invert(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) +ec_GFp_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) { if (EC_POINT_is_at_infinity(group, point) > 0 || BN_is_zero(&point->Y)) /* point is its own inverse */ @@ -975,16 +895,14 @@ ec_GFp_simple_invert(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) return BN_usub(&point->Y, &group->field, &point->Y); } - int -ec_GFp_simple_is_at_infinity(const EC_GROUP * group, const EC_POINT * point) +ec_GFp_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point) { return BN_is_zero(&point->Z); } - int -ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx) +ec_GFp_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx) { int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); @@ -1085,9 +1003,8 @@ ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX return ret; } - int -ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) +ec_GFp_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx) { /* * return values: -1 error 0 equal (in affine coordinates) 1 @@ -1187,9 +1104,8 @@ ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b return ret; } - int -ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) +ec_GFp_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) { BN_CTX *new_ctx = NULL; BIGNUM *x, *y; @@ -1225,9 +1141,8 @@ ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx return ret; } - int -ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * points[], BN_CTX * ctx) +ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx) { BN_CTX *new_ctx = NULL; BIGNUM *tmp0, *tmp1; @@ -1393,22 +1308,21 @@ ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * * locally! */ for (i = pow2 / 2 - 1; i > 0; i--) { - BN_clear_free(heap[i]); + BN_free(heap[i]); } free(heap); } return ret; } - int -ec_GFp_simple_field_mul(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) +ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { return BN_mod_mul(r, a, b, &group->field, ctx); } int -ec_GFp_simple_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN_CTX * ctx) +ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { return BN_mod_sqr(r, a, &group->field, ctx); } @@ -1416,7 +1330,7 @@ ec_GFp_simple_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN /* * Apply randomization of EC point projective coordinates: * - * (X, Y, Z) = (lambda^2 * X, lambda^3 * Y, lambda * Z) + * (X, Y, Z) = (lambda^2 * X, lambda^3 * Y, lambda * Z) * * where lambda is in the interval [1, group->field). */ @@ -1471,16 +1385,15 @@ ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx) return ret; } - #define EC_POINT_BN_set_flags(P, flags) do { \ - BN_set_flags(&(P)->X, (flags)); \ - BN_set_flags(&(P)->Y, (flags)); \ - BN_set_flags(&(P)->Z, (flags)); \ + BN_set_flags(&(P)->X, (flags)); \ + BN_set_flags(&(P)->Y, (flags)); \ + BN_set_flags(&(P)->Z, (flags)); \ } while(0) -#define EC_POINT_CSWAP(c, a, b, w, t) do { \ +#define EC_POINT_CSWAP(c, a, b, w, t) do { \ if (!BN_swap_ct(c, &(a)->X, &(b)->X, w) || \ - !BN_swap_ct(c, &(a)->Y, &(b)->Y, w) || \ + !BN_swap_ct(c, &(a)->Y, &(b)->Y, w) || \ !BN_swap_ct(c, &(a)->Z, &(b)->Z, w)) \ goto err; \ t = ((a)->Z_is_one ^ (b)->Z_is_one) & (c); \ @@ -1556,8 +1469,8 @@ ec_GFp_simple_mul_ct(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, */ cardinality_bits = BN_num_bits(cardinality); group_top = cardinality->top; - if ((bn_wexpand(k, group_top + 2) == NULL) || - (bn_wexpand(lambda, group_top + 2) == NULL)) + if (!bn_wexpand(k, group_top + 2) || + !bn_wexpand(lambda, group_top + 2)) goto err; if (!BN_copy(k, scalar)) @@ -1588,12 +1501,12 @@ ec_GFp_simple_mul_ct(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, goto err; group_top = group->field.top; - if ((bn_wexpand(&s->X, group_top) == NULL) || - (bn_wexpand(&s->Y, group_top) == NULL) || - (bn_wexpand(&s->Z, group_top) == NULL) || - (bn_wexpand(&r->X, group_top) == NULL) || - (bn_wexpand(&r->Y, group_top) == NULL) || - (bn_wexpand(&r->Z, group_top) == NULL)) + if (!bn_wexpand(&s->X, group_top) || + !bn_wexpand(&s->Y, group_top) || + !bn_wexpand(&s->Z, group_top) || + !bn_wexpand(&r->X, group_top) || + !bn_wexpand(&r->Y, group_top) || + !bn_wexpand(&r->Z, group_top)) goto err; /* @@ -1723,3 +1636,51 @@ ec_GFp_simple_mul_double_nonct(const EC_GROUP *group, EC_POINT *r, { return ec_wNAF_mul(group, r, g_scalar, 1, &point, &p_scalar, ctx); } + +static const EC_METHOD ec_GFp_simple_method = { + .field_type = NID_X9_62_prime_field, + .group_init = ec_GFp_simple_group_init, + .group_finish = ec_GFp_simple_group_finish, + .group_copy = ec_GFp_simple_group_copy, + .group_set_curve = ec_GFp_simple_group_set_curve, + .group_get_curve = ec_GFp_simple_group_get_curve, + .group_get_degree = ec_GFp_simple_group_get_degree, + .group_order_bits = ec_group_simple_order_bits, + .group_check_discriminant = ec_GFp_simple_group_check_discriminant, + .point_init = ec_GFp_simple_point_init, + .point_finish = ec_GFp_simple_point_finish, + .point_copy = ec_GFp_simple_point_copy, + .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, + .point_set_Jprojective_coordinates = + ec_GFp_simple_set_Jprojective_coordinates, + .point_get_Jprojective_coordinates = + ec_GFp_simple_get_Jprojective_coordinates, + .point_set_affine_coordinates = + ec_GFp_simple_point_set_affine_coordinates, + .point_get_affine_coordinates = + ec_GFp_simple_point_get_affine_coordinates, + .point_set_compressed_coordinates = + ec_GFp_simple_set_compressed_coordinates, + .point2oct = ec_GFp_simple_point2oct, + .oct2point = ec_GFp_simple_oct2point, + .add = ec_GFp_simple_add, + .dbl = ec_GFp_simple_dbl, + .invert = ec_GFp_simple_invert, + .is_at_infinity = ec_GFp_simple_is_at_infinity, + .is_on_curve = ec_GFp_simple_is_on_curve, + .point_cmp = ec_GFp_simple_cmp, + .make_affine = ec_GFp_simple_make_affine, + .points_make_affine = ec_GFp_simple_points_make_affine, + .mul_generator_ct = ec_GFp_simple_mul_generator_ct, + .mul_single_ct = ec_GFp_simple_mul_single_ct, + .mul_double_nonct = ec_GFp_simple_mul_double_nonct, + .field_mul = ec_GFp_simple_field_mul, + .field_sqr = ec_GFp_simple_field_sqr, + .blind_coordinates = ec_GFp_simple_blind_coordinates, +}; + +const EC_METHOD * +EC_GFp_simple_method(void) +{ + return &ec_GFp_simple_method; +} diff --git a/crypto/ec/ecx_methods.c b/crypto/ec/ecx_methods.c new file mode 100644 index 00000000..8510d1a4 --- /dev/null +++ b/crypto/ec/ecx_methods.c @@ -0,0 +1,864 @@ +/* $OpenBSD: ecx_methods.c,v 1.5 2023/03/15 06:34:07 tb Exp $ */ +/* + * Copyright (c) 2022 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include +#include +#include +#include +#include + +#include "asn1_local.h" +#include "bytestring.h" +#include "curve25519_internal.h" +#include "evp_local.h" + +/* + * EVP PKEY and PKEY ASN.1 methods Ed25519 and X25519. + * + * RFC 7748 - Elliptic Curves for Security. + * RFC 8032 - Edwards-Curve Digital Signature Algorithm (EdDSA). + */ + +#define ED25519_BITS 253 +#define ED25519_SECURITY_BITS 128 +#define ED25519_SIG_SIZE 64 + +#define X25519_BITS 253 +#define X25519_SECURITY_BITS 128 + +static int +ecx_key_len(int nid) +{ + switch (nid) { + case NID_ED25519: + return ED25519_KEYLEN; + case NID_X25519: + return X25519_KEYLEN; + } + + return 0; +} + +static struct ecx_key_st * +ecx_key_new(int nid) +{ + struct ecx_key_st *ecx_key; + int key_len; + + if ((key_len = ecx_key_len(nid)) == 0) + return NULL; + + if ((ecx_key = calloc(1, sizeof(*ecx_key))) == NULL) + return NULL; + + ecx_key->nid = nid; + ecx_key->key_len = key_len; + + return ecx_key; +} + +static void +ecx_key_clear(struct ecx_key_st *ecx_key) +{ + freezero(ecx_key->priv_key, ecx_key->priv_key_len); + ecx_key->priv_key = NULL; + ecx_key->priv_key_len = 0; + + freezero(ecx_key->pub_key, ecx_key->pub_key_len); + ecx_key->pub_key = NULL; + ecx_key->pub_key_len = 0; +} + +static void +ecx_key_free(struct ecx_key_st *ecx_key) +{ + if (ecx_key == NULL) + return; + + ecx_key_clear(ecx_key); + + freezero(ecx_key, sizeof(*ecx_key)); +} + +static int +ecx_key_generate(struct ecx_key_st *ecx_key) +{ + uint8_t *pub_key = NULL, *priv_key = NULL; + int ret = 0; + + ecx_key_clear(ecx_key); + + if ((pub_key = calloc(1, ecx_key->key_len)) == NULL) + goto err; + if ((priv_key = calloc(1, ecx_key->key_len)) == NULL) + goto err; + + switch (ecx_key->nid) { + case NID_ED25519: + ED25519_keypair(pub_key, priv_key); + break; + case NID_X25519: + X25519_keypair(pub_key, priv_key); + break; + default: + goto err; + } + + ecx_key->priv_key = priv_key; + ecx_key->priv_key_len = ecx_key->key_len; + priv_key = NULL; + + ecx_key->pub_key = pub_key; + ecx_key->pub_key_len = ecx_key->key_len; + pub_key = NULL; + + ret = 1; + + err: + freezero(pub_key, ecx_key->key_len); + freezero(priv_key, ecx_key->key_len); + + return ret; +} + +static int +ecx_key_set_priv(struct ecx_key_st *ecx_key, const uint8_t *priv_key, + size_t priv_key_len) +{ + uint8_t *pub_key = NULL; + CBS cbs; + + ecx_key_clear(ecx_key); + + if (priv_key_len != ecx_key->key_len) + goto err; + + if ((pub_key = calloc(1, ecx_key->key_len)) == NULL) + goto err; + + switch (ecx_key->nid) { + case NID_ED25519: + ED25519_public_from_private(pub_key, priv_key); + break; + case NID_X25519: + X25519_public_from_private(pub_key, priv_key); + break; + default: + goto err; + } + + CBS_init(&cbs, priv_key, priv_key_len); + if (!CBS_stow(&cbs, &ecx_key->priv_key, &ecx_key->priv_key_len)) + goto err; + + ecx_key->pub_key = pub_key; + ecx_key->pub_key_len = ecx_key->key_len; + pub_key = NULL; + + err: + freezero(pub_key, ecx_key->key_len); + + return 1; +} + +static int +ecx_key_set_pub(struct ecx_key_st *ecx_key, const uint8_t *pub_key, + size_t pub_key_len) +{ + CBS cbs; + + ecx_key_clear(ecx_key); + + if (pub_key_len != ecx_key->key_len) + return 0; + + CBS_init(&cbs, pub_key, pub_key_len); + if (!CBS_stow(&cbs, &ecx_key->pub_key, &ecx_key->pub_key_len)) + return 0; + + return 1; +} + +static int +ecx_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *xpubkey) +{ + struct ecx_key_st *ecx_key = NULL; + X509_ALGOR *algor; + int algor_type; + const uint8_t *param; + int param_len; + int ret = 0; + + if (!X509_PUBKEY_get0_param(NULL, ¶m, ¶m_len, &algor, xpubkey)) + goto err; + + /* Ensure that parameters have not been specified in the encoding. */ + if (algor != NULL) { + X509_ALGOR_get0(NULL, &algor_type, NULL, algor); + if (algor_type != V_ASN1_UNDEF) { + ECerror(EC_R_INVALID_ENCODING); + goto err; + } + } + + if (param == NULL || param_len != ecx_key_len(pkey->ameth->pkey_id)) { + ECerror(EC_R_INVALID_ENCODING); + goto err; + } + + if ((ecx_key = ecx_key_new(pkey->ameth->pkey_id)) == NULL) + goto err; + if (!ecx_key_set_pub(ecx_key, param, param_len)) + goto err; + if (!EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, ecx_key)) + goto err; + ecx_key = NULL; + + ret = 1; + + err: + ecx_key_free(ecx_key); + + return ret; +} + +static int +ecx_pub_encode(X509_PUBKEY *xpubkey, const EVP_PKEY *pkey) +{ + const struct ecx_key_st *ecx_key = pkey->pkey.ecx; + uint8_t *pub_key = NULL; + size_t pub_key_len = 0; + ASN1_OBJECT *aobj; + CBS cbs; + int ret = 0; + + if (ecx_key == NULL) { + ECerror(EC_R_INVALID_KEY); + goto err; + } + + if (ecx_key->pub_key_len != ecx_key->key_len) + goto err; + + if ((aobj = OBJ_nid2obj(pkey->ameth->pkey_id)) == NULL) + goto err; + + CBS_init(&cbs, ecx_key->pub_key, ecx_key->pub_key_len); + if (!CBS_stow(&cbs, &pub_key, &pub_key_len)) + goto err; + + if (!X509_PUBKEY_set0_param(xpubkey, aobj, V_ASN1_UNDEF, NULL, + pub_key, pub_key_len)) + goto err; + + pub_key = NULL; + pub_key_len = 0; + + ret = 1; + + err: + free(pub_key); + + return ret; +} + +static int +ecx_pub_cmp(const EVP_PKEY *pkey1, const EVP_PKEY *pkey2) +{ + if (pkey1->pkey.ecx == NULL || pkey1->pkey.ecx->pub_key == NULL) + return -2; + if (pkey2->pkey.ecx == NULL || pkey2->pkey.ecx->pub_key == NULL) + return -2; + if (pkey1->pkey.ecx->pub_key_len != pkey2->pkey.ecx->pub_key_len) + return -2; + + return timingsafe_memcmp(pkey1->pkey.ecx->pub_key, pkey2->pkey.ecx->pub_key, + pkey1->pkey.ecx->pub_key_len) == 0; +} + +static int +ecx_pub_print(BIO *bio, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) +{ + struct ecx_key_st *ecx_key = pkey->pkey.ecx; + const char *name; + + if ((name = OBJ_nid2ln(pkey->ameth->pkey_id)) == NULL) + return 0; + + if (ecx_key == NULL || ecx_key->pub_key == NULL) + return BIO_printf(bio, "%*s\n", + indent, "") > 0; + + if (BIO_printf(bio, "%*s%s Public-Key:\n", indent, "", name) <= 0) + return 0; + if (BIO_printf(bio, "%*spub:\n", indent, "") <= 0) + return 0; + if (ASN1_buf_print(bio, ecx_key->pub_key, ecx_key->pub_key_len, + indent + 4) == 0) + return 0; + + return 1; +} + +static int +ecx_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8pki) +{ + struct ecx_key_st *ecx_key = NULL; + ASN1_OCTET_STRING *aos = NULL; + const X509_ALGOR *algor; + int algor_type; + const uint8_t *param; + int param_len; + int ret = 0; + + if (!PKCS8_pkey_get0(NULL, ¶m, ¶m_len, &algor, p8pki)) + goto err; + if ((aos = d2i_ASN1_OCTET_STRING(NULL, ¶m, param_len)) == NULL) + goto err; + + /* Ensure that parameters have not been specified in the encoding. */ + if (algor != NULL) { + X509_ALGOR_get0(NULL, &algor_type, NULL, algor); + if (algor_type != V_ASN1_UNDEF) { + ECerror(EC_R_INVALID_ENCODING); + goto err; + } + } + + if (ASN1_STRING_get0_data(aos) == NULL || + ASN1_STRING_length(aos) != ecx_key_len(pkey->ameth->pkey_id)) { + ECerror(EC_R_INVALID_ENCODING); + goto err; + } + + if ((ecx_key = ecx_key_new(pkey->ameth->pkey_id)) == NULL) + goto err; + if (!ecx_key_set_priv(ecx_key, ASN1_STRING_get0_data(aos), + ASN1_STRING_length(aos))) + goto err; + if (!EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, ecx_key)) + goto err; + ecx_key = NULL; + + ret = 1; + + err: + ASN1_OCTET_STRING_free(aos); + ecx_key_free(ecx_key); + + return ret; +} + +static int +ecx_priv_encode(PKCS8_PRIV_KEY_INFO *p8pki, const EVP_PKEY *pkey) +{ + struct ecx_key_st *ecx_key = pkey->pkey.ecx; + ASN1_OCTET_STRING *aos = NULL; + ASN1_OBJECT *aobj; + uint8_t *der = NULL; + int der_len = 0; + int ret = 0; + + if (ecx_key == NULL || ecx_key->priv_key == NULL) { + ECerror(EC_R_INVALID_PRIVATE_KEY); + goto err; + } + + if ((aobj = OBJ_nid2obj(pkey->ameth->pkey_id)) == NULL) + goto err; + + if ((aos = ASN1_OCTET_STRING_new()) == NULL) + goto err; + if (!ASN1_OCTET_STRING_set(aos, ecx_key->priv_key, + ecx_key->priv_key_len)) + goto err; + if ((der_len = i2d_ASN1_OCTET_STRING(aos, &der)) < 0) + goto err; + if (!PKCS8_pkey_set0(p8pki, aobj, 0, V_ASN1_UNDEF, NULL, der, der_len)) + goto err; + + der = NULL; + der_len = 0; + + ret = 1; + + err: + freezero(der, der_len); + ASN1_OCTET_STRING_free(aos); + + return ret; +} + +static int +ecx_priv_print(BIO *bio, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) +{ + struct ecx_key_st *ecx_key = pkey->pkey.ecx; + const char *name; + + if ((name = OBJ_nid2ln(pkey->ameth->pkey_id)) == NULL) + return 0; + + if (ecx_key == NULL || ecx_key->priv_key == NULL) + return BIO_printf(bio, "%*s\n", + indent, "") > 0; + + if (BIO_printf(bio, "%*s%s Private-Key:\n", indent, "", name) <= 0) + return 0; + if (BIO_printf(bio, "%*spriv:\n", indent, "") <= 0) + return 0; + if (ASN1_buf_print(bio, ecx_key->priv_key, ecx_key->priv_key_len, + indent + 4) == 0) + return 0; + if (BIO_printf(bio, "%*spub:\n", indent, "") <= 0) + return 0; + if (ASN1_buf_print(bio, ecx_key->pub_key, ecx_key->pub_key_len, + indent + 4) == 0) + return 0; + + return 1; +} + +static int +ecx_size(const EVP_PKEY *pkey) +{ + return ecx_key_len(pkey->ameth->pkey_id); +} + +static int +ecx_sig_size(const EVP_PKEY *pkey) +{ + switch (pkey->ameth->pkey_id) { + case EVP_PKEY_ED25519: + return ED25519_SIG_SIZE; + } + return 0; +} + +static int +ecx_bits(const EVP_PKEY *pkey) +{ + switch (pkey->ameth->pkey_id) { + case EVP_PKEY_ED25519: + return ED25519_BITS; + case EVP_PKEY_X25519: + return X25519_BITS; + } + return 0; +} + +static int +ecx_security_bits(const EVP_PKEY *pkey) +{ + switch (pkey->ameth->pkey_id) { + case EVP_PKEY_ED25519: + return ED25519_SECURITY_BITS; + case EVP_PKEY_X25519: + return X25519_SECURITY_BITS; + } + return 0; +} + +static int +ecx_param_cmp(const EVP_PKEY *pkey1, const EVP_PKEY *pkey2) +{ + /* No parameters, so always equivalent. */ + return 1; +} + +static void +ecx_free(EVP_PKEY *pkey) +{ + struct ecx_key_st *ecx_key = pkey->pkey.ecx; + + return ecx_key_free(ecx_key); +} + +static int +ecx_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) +{ + /* Not supported. */ + return -2; +} + +static int +ecx_sign_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) +{ + switch (op) { + case ASN1_PKEY_CTRL_DEFAULT_MD_NID: + /* PureEdDSA does its own hashing. */ + *(int *)arg2 = NID_undef; + return 2; + } + return -2; +} + +static int +ecx_set_priv_key(EVP_PKEY *pkey, const uint8_t *priv, size_t len) +{ + struct ecx_key_st *ecx_key = NULL; + int ret = 0; + + if (priv == NULL || len != ecx_key_len(pkey->ameth->pkey_id)) { + ECerror(EC_R_INVALID_ENCODING); + goto err; + } + + if ((ecx_key = ecx_key_new(pkey->ameth->pkey_id)) == NULL) + goto err; + if (!ecx_key_set_priv(ecx_key, priv, len)) + goto err; + if (!EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, ecx_key)) + goto err; + ecx_key = NULL; + + ret = 1; + + err: + ecx_key_free(ecx_key); + + return ret; +} + +static int +ecx_set_pub_key(EVP_PKEY *pkey, const uint8_t *pub, size_t len) +{ + struct ecx_key_st *ecx_key = NULL; + int ret = 0; + + if (pub == NULL || len != ecx_key_len(pkey->ameth->pkey_id)) { + ECerror(EC_R_INVALID_ENCODING); + goto err; + } + + if ((ecx_key = ecx_key_new(pkey->ameth->pkey_id)) == NULL) + goto err; + if (!ecx_key_set_pub(ecx_key, pub, len)) + goto err; + if (!EVP_PKEY_assign(pkey, pkey->ameth->pkey_id, ecx_key)) + goto err; + ecx_key = NULL; + + ret = 1; + + err: + ecx_key_free(ecx_key); + + return ret; +} + +static int +ecx_get_priv_key(const EVP_PKEY *pkey, unsigned char *out_priv, size_t *out_len) +{ + struct ecx_key_st *ecx_key = pkey->pkey.ecx; + CBS cbs; + + if (out_priv == NULL) { + *out_len = ecx_key_len(pkey->ameth->pkey_id); + return 1; + } + + if (ecx_key == NULL || ecx_key->priv_key == NULL) + return 0; + + CBS_init(&cbs, ecx_key->priv_key, ecx_key->priv_key_len); + if (!CBS_write_bytes(&cbs, out_priv, *out_len, out_len)) + return 0; + + return 1; +} + +static int +ecx_get_pub_key(const EVP_PKEY *pkey, unsigned char *out_pub, size_t *out_len) +{ + struct ecx_key_st *ecx_key = pkey->pkey.ecx; + CBS cbs; + + if (out_pub == NULL) { + *out_len = ecx_key_len(pkey->ameth->pkey_id); + return 1; + } + + if (ecx_key == NULL || ecx_key->pub_key == NULL) + return 0; + + CBS_init(&cbs, ecx_key->pub_key, ecx_key->pub_key_len); + if (!CBS_write_bytes(&cbs, out_pub, *out_len, out_len)) + return 0; + + return 1; +} + +static int +pkey_ecx_keygen(EVP_PKEY_CTX *pkey_ctx, EVP_PKEY *pkey) +{ + struct ecx_key_st *ecx_key = NULL; + int ret = 0; + + if ((ecx_key = ecx_key_new(pkey_ctx->pmeth->pkey_id)) == NULL) + goto err; + if (!ecx_key_generate(ecx_key)) + goto err; + if (!EVP_PKEY_assign(pkey, pkey_ctx->pmeth->pkey_id, ecx_key)) + goto err; + ecx_key = NULL; + + ret = 1; + + err: + ecx_key_free(ecx_key); + + return ret; +} + +static int +pkey_ecx_derive(EVP_PKEY_CTX *pkey_ctx, unsigned char *out_key, + size_t *out_key_len) +{ + struct ecx_key_st *ecx_key, *ecx_peer_key; + + if (pkey_ctx->pkey == NULL || pkey_ctx->peerkey == NULL) { + ECerror(EC_R_KEYS_NOT_SET); + return 0; + } + + if ((ecx_key = pkey_ctx->pkey->pkey.ecx) == NULL) { + ECerror(EC_R_INVALID_PRIVATE_KEY); + return 0; + } + if (ecx_key->priv_key == NULL) { + ECerror(EC_R_INVALID_PRIVATE_KEY); + return 0; + } + + if ((ecx_peer_key = pkey_ctx->peerkey->pkey.ecx) == NULL) { + ECerror(EC_R_INVALID_PEER_KEY); + return 0; + } + + if (out_key != NULL) { + if (!X25519(out_key, ecx_key->priv_key, ecx_peer_key->pub_key)) + return 0; + } + + *out_key_len = X25519_KEYLEN; + + return 1; +} + +static int +pkey_ecx_ctrl(EVP_PKEY_CTX *pkey_ctx, int op, int arg1, void *arg2) +{ + if (op == EVP_PKEY_CTRL_PEER_KEY) + return 1; + + return -2; +} + +static int +ecx_item_verify(EVP_MD_CTX *md_ctx, const ASN1_ITEM *it, void *asn, + X509_ALGOR *algor, ASN1_BIT_STRING *abs, EVP_PKEY *pkey) +{ + const ASN1_OBJECT *aobj; + int nid, param_type; + + X509_ALGOR_get0(&aobj, ¶m_type, NULL, algor); + + nid = OBJ_obj2nid(aobj); + + if (nid != NID_ED25519 || param_type != V_ASN1_UNDEF) { + ECerror(EC_R_INVALID_ENCODING); + return 0; + } + + if (!EVP_DigestVerifyInit(md_ctx, NULL, NULL, NULL, pkey)) + return 0; + + return 2; +} + +static int +ecx_item_sign(EVP_MD_CTX *md_ctx, const ASN1_ITEM *it, void *asn, + X509_ALGOR *algor1, X509_ALGOR *algor2, ASN1_BIT_STRING *abs) +{ + ASN1_OBJECT *aobj; + + if ((aobj = OBJ_nid2obj(NID_ED25519)) == NULL) + return 0; + + if (!X509_ALGOR_set0(algor1, aobj, V_ASN1_UNDEF, NULL)) + return 0; + + if (algor2 != NULL) { + if (!X509_ALGOR_set0(algor2, aobj, V_ASN1_UNDEF, NULL)) + return 0; + } + + /* Tell ASN1_item_sign_ctx() that identifiers are set and it needs to sign. */ + return 3; +} + +static int +pkey_ecx_digestsign(EVP_MD_CTX *md_ctx, unsigned char *out_sig, + size_t *out_sig_len, const unsigned char *message, size_t message_len) +{ + struct ecx_key_st *ecx_key; + EVP_PKEY_CTX *pkey_ctx; + + pkey_ctx = EVP_MD_CTX_pkey_ctx(md_ctx); + ecx_key = pkey_ctx->pkey->pkey.ecx; + + if (out_sig == NULL) { + *out_sig_len = ecx_sig_size(pkey_ctx->pkey); + return 1; + } + if (*out_sig_len < ecx_sig_size(pkey_ctx->pkey)) { + ECerror(EC_R_BUFFER_TOO_SMALL); + return 0; + } + + if (ecx_key == NULL) + return 0; + if (ecx_key->priv_key == NULL || ecx_key->pub_key == NULL) + return 0; + + if (!ED25519_sign(out_sig, message, message_len, ecx_key->pub_key, + ecx_key->priv_key)) + return 0; + + *out_sig_len = ecx_sig_size(pkey_ctx->pkey); + + return 1; +} + +static int +pkey_ecx_digestverify(EVP_MD_CTX *md_ctx, const unsigned char *sig, + size_t sig_len, const unsigned char *message, size_t message_len) +{ + struct ecx_key_st *ecx_key; + EVP_PKEY_CTX *pkey_ctx; + + pkey_ctx = EVP_MD_CTX_pkey_ctx(md_ctx); + ecx_key = pkey_ctx->pkey->pkey.ecx; + + if (ecx_key == NULL || ecx_key->pub_key == NULL) + return 0; + if (sig_len != ecx_sig_size(pkey_ctx->pkey)) + return 0; + + return ED25519_verify(message, message_len, sig, ecx_key->pub_key); +} + +static int +pkey_ecx_ed_ctrl(EVP_PKEY_CTX *pkey_ctx, int op, int arg1, void *arg2) +{ + switch (op) { + case EVP_PKEY_CTRL_MD: + /* PureEdDSA does its own hashing. */ + if (arg2 != NULL && (const EVP_MD *)arg2 != EVP_md_null()) { + ECerror(EC_R_INVALID_DIGEST_TYPE); + return 0; + } + return 1; + + case EVP_PKEY_CTRL_DIGESTINIT: + return 1; + } + return -2; +} + +const EVP_PKEY_ASN1_METHOD x25519_asn1_meth = { + .pkey_id = EVP_PKEY_X25519, + .pkey_base_id = EVP_PKEY_X25519, + .pkey_flags = 0, + .pem_str = "X25519", + .info = "OpenSSL X25519 algorithm", + + .pub_decode = ecx_pub_decode, + .pub_encode = ecx_pub_encode, + .pub_cmp = ecx_pub_cmp, + .pub_print = ecx_pub_print, + + .priv_decode = ecx_priv_decode, + .priv_encode = ecx_priv_encode, + .priv_print = ecx_priv_print, + + .pkey_size = ecx_size, + .pkey_bits = ecx_bits, + .pkey_security_bits = ecx_security_bits, + + .param_cmp = ecx_param_cmp, + + .pkey_free = ecx_free, + .pkey_ctrl = ecx_ctrl, + + .set_priv_key = ecx_set_priv_key, + .set_pub_key = ecx_set_pub_key, + .get_priv_key = ecx_get_priv_key, + .get_pub_key = ecx_get_pub_key, +}; + +const EVP_PKEY_METHOD x25519_pkey_meth = { + .pkey_id = EVP_PKEY_X25519, + .keygen = pkey_ecx_keygen, + .derive = pkey_ecx_derive, + .ctrl = pkey_ecx_ctrl, +}; + +const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth = { + .pkey_id = EVP_PKEY_ED25519, + .pkey_base_id = EVP_PKEY_ED25519, + .pkey_flags = 0, + .pem_str = "ED25519", + .info = "OpenSSL ED25519 algorithm", + + .pub_decode = ecx_pub_decode, + .pub_encode = ecx_pub_encode, + .pub_cmp = ecx_pub_cmp, + .pub_print = ecx_pub_print, + + .priv_decode = ecx_priv_decode, + .priv_encode = ecx_priv_encode, + .priv_print = ecx_priv_print, + + .pkey_size = ecx_sig_size, + .pkey_bits = ecx_bits, + .pkey_security_bits = ecx_security_bits, + + .param_cmp = ecx_param_cmp, + + .pkey_free = ecx_free, + .pkey_ctrl = ecx_sign_ctrl, + + .item_verify = ecx_item_verify, + .item_sign = ecx_item_sign, + + .set_priv_key = ecx_set_priv_key, + .set_pub_key = ecx_set_pub_key, + .get_priv_key = ecx_get_priv_key, + .get_pub_key = ecx_get_pub_key, +}; + +const EVP_PKEY_METHOD ed25519_pkey_meth = { + .pkey_id = EVP_PKEY_ED25519, + .flags = EVP_PKEY_FLAG_SIGCTX_CUSTOM, + .keygen = pkey_ecx_keygen, + .ctrl = pkey_ecx_ed_ctrl, + .digestsign = pkey_ecx_digestsign, + .digestverify = pkey_ecx_digestverify, +}; diff --git a/crypto/ecdh/ecdh_kdf.c b/crypto/ecdh/ecdh_kdf.c index 25398626..5c22e9c8 100644 --- a/crypto/ecdh/ecdh_kdf.c +++ b/crypto/ecdh/ecdh_kdf.c @@ -55,7 +55,7 @@ #include #include -#include "ech_locl.h" +#include "ech_local.h" /* * Key derivation function from X9.63/SECG. diff --git a/crypto/ecdh/ech_key.c b/crypto/ecdh/ech_key.c index ee789058..a5c6371f 100644 --- a/crypto/ecdh/ech_key.c +++ b/crypto/ecdh/ech_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ech_key.c,v 1.13 2022/06/30 11:14:47 tb Exp $ */ +/* $OpenBSD: ech_key.c,v 1.14 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -77,9 +77,9 @@ #include #include -#include "bn_lcl.h" -#include "ech_locl.h" -#include "ec_lcl.h" +#include "bn_local.h" +#include "ech_local.h" +#include "ec_local.h" static int ecdh_compute_key(void *out, size_t len, const EC_POINT *pub_key, EC_KEY *ecdh, diff --git a/crypto/ecdh/ech_lib.c b/crypto/ecdh/ech_lib.c index cc8edafa..6caef598 100644 --- a/crypto/ecdh/ech_lib.c +++ b/crypto/ecdh/ech_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ech_lib.c,v 1.14 2018/04/14 07:09:21 tb Exp $ */ +/* $OpenBSD: ech_lib.c,v 1.15 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -71,7 +71,7 @@ #include -#include "ech_locl.h" +#include "ech_local.h" #ifndef OPENSSL_NO_ENGINE #include #endif diff --git a/crypto/ecdh/ech_locl.h b/crypto/ecdh/ech_local.h similarity index 96% rename from crypto/ecdh/ech_locl.h rename to crypto/ecdh/ech_local.h index b04d325e..3c2a2673 100644 --- a/crypto/ecdh/ech_locl.h +++ b/crypto/ecdh/ech_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ech_locl.h,v 1.6 2019/09/05 16:12:36 jsing Exp $ */ +/* $OpenBSD: ech_local.h,v 1.2 2022/11/26 17:23:17 tb Exp $ */ /* ==================================================================== * Copyright (c) 2000-2005 The OpenSSL Project. All rights reserved. * @@ -53,8 +53,8 @@ * */ -#ifndef HEADER_ECH_LOCL_H -#define HEADER_ECH_LOCL_H +#ifndef HEADER_ECH_LOCAL_H +#define HEADER_ECH_LOCAL_H #include @@ -96,4 +96,4 @@ int ecdh_KDF_X9_63(unsigned char *out, size_t outlen, const unsigned char *Z, __END_HIDDEN_DECLS -#endif /* HEADER_ECH_LOCL_H */ +#endif /* !HEADER_ECH_LOCAL_H */ diff --git a/crypto/ecdsa/ecs_asn1.c b/crypto/ecdsa/ecs_asn1.c index d4cbf1e3..9db114a2 100644 --- a/crypto/ecdsa/ecs_asn1.c +++ b/crypto/ecdsa/ecs_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_asn1.c,v 1.11 2022/09/03 16:01:23 jsing Exp $ */ +/* $OpenBSD: ecs_asn1.c,v 1.13 2023/03/07 09:27:10 jsing Exp $ */ /* ==================================================================== * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved. * @@ -53,7 +53,7 @@ * */ -#include "ecs_locl.h" +#include "ecs_local.h" #include #include @@ -141,8 +141,8 @@ ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) if (r == NULL || s == NULL) return 0; - BN_clear_free(sig->r); - BN_clear_free(sig->s); + BN_free(sig->r); + BN_free(sig->s); sig->r = r; sig->s = s; return 1; diff --git a/crypto/ecdsa/ecs_lib.c b/crypto/ecdsa/ecs_lib.c index 18eecba7..5c44c793 100644 --- a/crypto/ecdsa/ecs_lib.c +++ b/crypto/ecdsa/ecs_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_lib.c,v 1.14 2022/08/31 13:01:01 tb Exp $ */ +/* $OpenBSD: ecs_lib.c,v 1.16 2023/03/07 09:27:10 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * @@ -57,7 +57,7 @@ #include -#include "ecs_locl.h" +#include "ecs_local.h" #ifndef OPENSSL_NO_ENGINE #include #endif @@ -221,7 +221,7 @@ ECDSA_size(const EC_KEY *r) ret = 0; err: - BN_clear_free(order); + BN_free(order); return ret; } diff --git a/crypto/ecdsa/ecs_locl.h b/crypto/ecdsa/ecs_local.h similarity index 96% rename from crypto/ecdsa/ecs_locl.h rename to crypto/ecdsa/ecs_local.h index a53ec379..5cdf2645 100644 --- a/crypto/ecdsa/ecs_locl.h +++ b/crypto/ecdsa/ecs_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_locl.h,v 1.7 2022/01/14 08:31:03 tb Exp $ */ +/* $OpenBSD: ecs_local.h,v 1.2 2022/11/26 17:23:17 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ @@ -56,8 +56,8 @@ * */ -#ifndef HEADER_ECS_LOCL_H -#define HEADER_ECS_LOCL_H +#ifndef HEADER_ECS_LOCAL_H +#define HEADER_ECS_LOCAL_H #include @@ -96,4 +96,4 @@ ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len, __END_HIDDEN_DECLS -#endif /* HEADER_ECS_LOCL_H */ +#endif /* !HEADER_ECS_LOCAL_H */ diff --git a/crypto/ecdsa/ecs_ossl.c b/crypto/ecdsa/ecs_ossl.c index 48ef1312..271c8435 100644 --- a/crypto/ecdsa/ecs_ossl.c +++ b/crypto/ecdsa/ecs_ossl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_ossl.c,v 1.25 2022/06/30 11:14:47 tb Exp $ */ +/* $OpenBSD: ecs_ossl.c,v 1.29 2023/03/07 09:27:10 jsing Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ @@ -64,8 +64,8 @@ #include #include -#include "bn_lcl.h" -#include "ecs_locl.h" +#include "bn_local.h" +#include "ecs_local.h" static int ecdsa_prepare_digest(const unsigned char *dgst, int dgst_len, BIGNUM *order, BIGNUM *ret); @@ -168,8 +168,13 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) goto err; } + /* Reject curves with an order that is smaller than 80 bits. */ + if ((order_bits = BN_num_bits(order)) < 80) { + ECDSAerror(EC_R_INVALID_GROUP_ORDER); + goto err; + } + /* Preallocate space. */ - order_bits = BN_num_bits(order); if (!BN_set_bit(k, order_bits) || !BN_set_bit(r, order_bits) || !BN_set_bit(X, order_bits)) @@ -225,22 +230,22 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) ECDSAerror(ERR_R_BN_LIB); goto err; } - BN_clear_free(*rp); - BN_clear_free(*kinvp); + BN_free(*rp); + BN_free(*kinvp); *rp = r; *kinvp = k; ret = 1; err: if (ret == 0) { - BN_clear_free(k); - BN_clear_free(r); + BN_free(k); + BN_free(r); } if (ctx_in == NULL) BN_CTX_free(ctx); BN_free(order); EC_POINT_free(point); - BN_clear_free(X); + BN_free(X); return (ret); } @@ -255,6 +260,14 @@ ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp return ecdsa->meth->ecdsa_sign_setup(eckey, ctx_in, kinvp, rp); } + +/* + * It is too expensive to check curve parameters on every sign operation. + * Instead, cap the number of retries. A single retry is very unlikely, so + * allowing 32 retries is amply enough. + */ +#define ECDSA_MAX_SIGN_ITERATIONS 32 + static ECDSA_SIG * ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey) @@ -266,6 +279,7 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, const EC_GROUP *group; ECDSA_SIG *ret; ECDSA_DATA *ecdsa; + int attempts = 0; int ok = 0; ecdsa = ecdsa_check(eckey); @@ -380,6 +394,11 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, ECDSAerror(ECDSA_R_NEED_NEW_SETUP_VALUES); goto err; } + + if (++attempts > ECDSA_MAX_SIGN_ITERATIONS) { + ECDSAerror(EC_R_WRONG_CURVE_PARAMETERS); + goto err; + } } else /* s != 0 => we have a valid signature */ break; @@ -393,12 +412,12 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, ret = NULL; } BN_CTX_free(ctx); - BN_clear_free(b); - BN_clear_free(binv); - BN_clear_free(bm); - BN_clear_free(bxr); - BN_clear_free(kinv); - BN_clear_free(m); + BN_free(b); + BN_free(binv); + BN_free(bm); + BN_free(bxr); + BN_free(kinv); + BN_free(m); BN_free(order); BN_free(range); return ret; diff --git a/crypto/ecdsa/ecs_sign.c b/crypto/ecdsa/ecs_sign.c index 6424a3ca..9aab20b0 100644 --- a/crypto/ecdsa/ecs_sign.c +++ b/crypto/ecdsa/ecs_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_sign.c,v 1.9 2022/01/27 20:30:29 tb Exp $ */ +/* $OpenBSD: ecs_sign.c,v 1.10 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -61,9 +61,9 @@ #include #include -#include "bn_lcl.h" -#include "ecs_locl.h" -#include "ec_lcl.h" +#include "bn_local.h" +#include "ecs_local.h" +#include "ec_local.h" ECDSA_SIG * ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) diff --git a/crypto/ecdsa/ecs_vrf.c b/crypto/ecdsa/ecs_vrf.c index 7db5a937..4be4c89d 100644 --- a/crypto/ecdsa/ecs_vrf.c +++ b/crypto/ecdsa/ecs_vrf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_vrf.c,v 1.9 2022/01/27 20:30:29 tb Exp $ */ +/* $OpenBSD: ecs_vrf.c,v 1.10 2022/11/26 16:08:52 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ @@ -64,9 +64,9 @@ #include #include -#include "bn_lcl.h" -#include "ecs_locl.h" -#include "ec_lcl.h" +#include "bn_local.h" +#include "ecs_local.h" +#include "ec_local.h" /* returns * 1: correct signature diff --git a/crypto/empty.c b/crypto/empty.c new file mode 100644 index 00000000..e69de29b diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c index b29b4102..451c8616 100644 --- a/crypto/engine/eng_list.c +++ b/crypto/engine/eng_list.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_list.c,v 1.24 2019/01/19 01:07:00 tb Exp $ */ +/* $OpenBSD: eng_list.c,v 1.25 2022/12/26 07:18:51 jmc Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -223,7 +223,7 @@ ENGINE_get_next(ENGINE *e) CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); ret = e->next; if (ret) { - /* Return a valid structural refernce to the next ENGINE */ + /* Return a valid structural reference to the next ENGINE */ ret->struct_ref++; engine_ref_debug(ret, 0, 1) } diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c index 1a6113ba..c632279f 100644 --- a/crypto/engine/eng_openssl.c +++ b/crypto/engine/eng_openssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_openssl.c,v 1.15 2022/01/09 23:55:31 tb Exp $ */ +/* $OpenBSD: eng_openssl.c,v 1.16 2022/11/26 16:08:52 tb Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -84,7 +84,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" /* This testing gunk is implemented (and explained) lower down. It also assumes * the application explicitly calls "ENGINE_load_openssl()" because this is no diff --git a/crypto/engine/eng_table.c b/crypto/engine/eng_table.c index a8aded5a..0e7ea3b6 100644 --- a/crypto/engine/eng_table.c +++ b/crypto/engine/eng_table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_table.c,v 1.9 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: eng_table.c,v 1.10 2022/12/26 07:18:52 jmc Exp $ */ /* ==================================================================== * Copyright (c) 2001 The OpenSSL Project. All rights reserved. * @@ -163,7 +163,7 @@ engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, fnd->funct = NULL; (void)lh_ENGINE_PILE_insert(&(*table)->piles, fnd); } - /* A registration shouldn't add duplciate entries */ + /* A registration shouldn't add duplicate entries */ (void)sk_ENGINE_delete_ptr(fnd->sk, e); /* if 'setdefault', this ENGINE goes to the head of the list */ if (!sk_ENGINE_push(fnd->sk, e)) @@ -193,7 +193,7 @@ int_unregister_cb_doall_arg(ENGINE_PILE *pile, ENGINE *e) { int n; - /* Iterate the 'c->sk' stack removing any occurance of 'e' */ + /* Iterate the 'c->sk' stack removing any occurrence of 'e' */ while ((n = sk_ENGINE_find(pile->sk, e)) >= 0) { (void)sk_ENGINE_delete(pile->sk, n); pile->uptodate = 0; diff --git a/crypto/engine/tb_asnmth.c b/crypto/engine/tb_asnmth.c index 51e5198b..913230f6 100644 --- a/crypto/engine/tb_asnmth.c +++ b/crypto/engine/tb_asnmth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tb_asnmth.c,v 1.6 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: tb_asnmth.c,v 1.7 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * @@ -58,7 +58,7 @@ #include #include "eng_int.h" -#include "asn1_locl.h" +#include "asn1_local.h" #include /* If this symbol is defined then ENGINE_get_pkey_asn1_meth_engine(), the diff --git a/crypto/err/err.c b/crypto/err/err.c index 34914054..403fcd46 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: err.c,v 1.49 2022/08/29 06:49:24 jsing Exp $ */ +/* $OpenBSD: err.c,v 1.50 2022/12/26 07:18:52 jmc Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1075,7 +1075,7 @@ ERR_get_state(void) ERR_STATE_free(ret); /* could not insert it */ return (&fallback); } - /* If a race occured in this function and we came second, tmpp + /* If a race occurred in this function and we came second, tmpp * is the first one that we just replaced. */ if (tmpp) ERR_STATE_free(tmpp); diff --git a/crypto/evp/bio_b64.c b/crypto/evp/bio_b64.c index b61a342a..8880a283 100644 --- a/crypto/evp/bio_b64.c +++ b/crypto/evp/bio_b64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_b64.c,v 1.25 2022/01/14 08:40:57 tb Exp $ */ +/* $OpenBSD: bio_b64.c,v 1.26 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -64,7 +64,7 @@ #include #include "bio_local.h" -#include "evp_locl.h" +#include "evp_local.h" static int b64_write(BIO *h, const char *buf, int num); static int b64_read(BIO *h, char *buf, int size); diff --git a/crypto/evp/bio_enc.c b/crypto/evp/bio_enc.c index 2a0f76fc..098b1ea3 100644 --- a/crypto/evp/bio_enc.c +++ b/crypto/evp/bio_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_enc.c,v 1.26 2022/01/14 08:40:57 tb Exp $ */ +/* $OpenBSD: bio_enc.c,v 1.27 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -64,7 +64,7 @@ #include #include "bio_local.h" -#include "evp_locl.h" +#include "evp_local.h" static int enc_write(BIO *h, const char *buf, int num); static int enc_read(BIO *h, char *buf, int size); diff --git a/crypto/evp/bio_md.c b/crypto/evp/bio_md.c index 4ae5f1f4..4b7ca445 100644 --- a/crypto/evp/bio_md.c +++ b/crypto/evp/bio_md.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_md.c,v 1.18 2022/01/14 08:40:57 tb Exp $ */ +/* $OpenBSD: bio_md.c,v 1.19 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include #include "bio_local.h" -#include "evp_locl.h" +#include "evp_local.h" /* BIO_put and BIO_get both add to the digest, * BIO_gets returns the digest */ diff --git a/crypto/evp/c_all.c b/crypto/evp/c_all.c index 690215c8..8fc1aa6a 100644 --- a/crypto/evp/c_all.c +++ b/crypto/evp/c_all.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_all.c,v 1.27 2022/01/14 08:38:05 tb Exp $ */ +/* $OpenBSD: c_all.c,v 1.28 2022/10/21 13:39:35 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -224,6 +224,9 @@ OpenSSL_add_all_ciphers_internal(void) #ifndef OPENSSL_NO_CHACHA EVP_add_cipher(EVP_chacha20()); #endif +#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) + EVP_add_cipher(EVP_chacha20_poly1305()); +#endif #ifndef OPENSSL_NO_GOST EVP_add_cipher(EVP_gost2814789_ecb()); diff --git a/crypto/o_time.h b/crypto/evp/cipher_method_lib.c similarity index 53% rename from crypto/o_time.h rename to crypto/evp/cipher_method_lib.c index 064f2cc2..55dc6b78 100644 --- a/crypto/o_time.h +++ b/crypto/evp/cipher_method_lib.c @@ -1,9 +1,10 @@ -/* $OpenBSD: o_time.h,v 1.8 2021/10/27 09:50:56 beck Exp $ */ -/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL - * project 2001. +/* $OpenBSD: cipher_method_lib.c,v 1.8 2023/03/01 11:27:37 tb Exp $ */ +/* + * Written by Richard Levitte (levitte@openssl.org) for the OpenSSL project + * 2015. */ /* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. + * Copyright (c) 2015 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -56,16 +57,122 @@ * */ -#ifndef HEADER_O_TIME_H -#define HEADER_O_TIME_H +#include -#include +#include -__BEGIN_HIDDEN_DECLS +#include "evp_local.h" -int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); -int OPENSSL_gmtime_diff(int *pday, int *psec, const struct tm *from, - const struct tm *to); +EVP_CIPHER * +EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len) +{ + EVP_CIPHER *cipher; -__END_HIDDEN_DECLS -#endif + if ((cipher = calloc(1, sizeof(*cipher))) == NULL) + return NULL; + + cipher->nid = cipher_type; + cipher->block_size = block_size; + cipher->key_len = key_len; + + return cipher; +} + +EVP_CIPHER * +EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher) +{ + EVP_CIPHER *copy; + + if ((copy = calloc(1, sizeof(*copy))) == NULL) + return NULL; + + *copy = *cipher; + + return copy; +} + +void +EVP_CIPHER_meth_free(EVP_CIPHER *cipher) +{ + free(cipher); +} + +int +EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len) +{ + cipher->iv_len = iv_len; + + return 1; +} + +int +EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags) +{ + cipher->flags = flags; + + return 1; +} + +int +EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size) +{ + cipher->ctx_size = ctx_size; + + return 1; +} + +int +EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher, + int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, + const unsigned char *iv, int enc)) +{ + cipher->init = init; + + return 1; +} + +int +EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher, + int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, size_t inl)) +{ + cipher->do_cipher = do_cipher; + + return 1; +} + +int +EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher, + int (*cleanup)(EVP_CIPHER_CTX *)) +{ + cipher->cleanup = cleanup; + + return 1; +} + +int +EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher, + int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)) +{ + cipher->set_asn1_parameters = set_asn1_parameters; + + return 1; +} + +int +EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher, + int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)) +{ + cipher->get_asn1_parameters = get_asn1_parameters; + + return 1; +} + +int +EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher, + int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr)) +{ + cipher->ctrl = ctrl; + + return 1; +} diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index ecb52925..7c129f02 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: digest.c,v 1.34 2022/01/10 10:51:31 tb Exp $ */ +/* $OpenBSD: digest.c,v 1.36 2022/12/26 07:18:52 jmc Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -122,7 +122,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type) @@ -140,7 +140,7 @@ EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts * so this context may already have an ENGINE! Try to avoid releasing * the previous handle, re-querying for an ENGINE, and having a - * reinitialisation, when it may all be unecessary. */ + * reinitialisation, when it may all be unnecessary. */ if (ctx->engine && ctx->digest && (!type || (type && (type->type == ctx->digest->type)))) goto skip_to_init; diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c index d674be38..790b2638 100644 --- a/crypto/evp/e_aes.c +++ b/crypto/evp/e_aes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_aes.c,v 1.49 2022/09/13 04:59:18 jsing Exp $ */ +/* $OpenBSD: e_aes.c,v 1.51 2023/03/01 11:16:06 tb Exp $ */ /* ==================================================================== * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. * @@ -60,8 +60,8 @@ #include #include -#include "evp_locl.h" -#include "modes_lcl.h" +#include "evp_local.h" +#include "modes_local.h" typedef struct { AES_KEY ks; @@ -1255,7 +1255,7 @@ EVP_aes_256_ctr(void) #endif } -static void +static int aes_gcm_cleanup(EVP_CIPHER_CTX *c) { EVP_AES_GCM_CTX *gctx = c->cipher_data; @@ -1264,6 +1264,8 @@ aes_gcm_cleanup(EVP_CIPHER_CTX *c) free(gctx->iv); explicit_bzero(gctx, sizeof(*gctx)); + + return 1; } /* increment counter (64-bit int) by 1 */ diff --git a/crypto/evp/e_aes_cbc_hmac_sha1.c b/crypto/evp/e_aes_cbc_hmac_sha1.c index eef9c280..9cde3861 100644 --- a/crypto/evp/e_aes_cbc_hmac_sha1.c +++ b/crypto/evp/e_aes_cbc_hmac_sha1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_aes_cbc_hmac_sha1.c,v 1.16 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: e_aes_cbc_hmac_sha1.c,v 1.17 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright (c) 2011-2013 The OpenSSL Project. All rights reserved. * @@ -60,8 +60,8 @@ #include #include -#include "constant_time_locl.h" -#include "evp_locl.h" +#include "constant_time.h" +#include "evp_local.h" #define TLS1_1_VERSION 0x0302 diff --git a/crypto/evp/e_bf.c b/crypto/evp/e_bf.c index 4632b523..c2ab3178 100644 --- a/crypto/evp/e_bf.c +++ b/crypto/evp/e_bf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_bf.c,v 1.14 2022/09/15 07:04:19 jsing Exp $ */ +/* $OpenBSD: e_bf.c,v 1.15 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -67,7 +67,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" typedef struct { BF_KEY ks; diff --git a/crypto/evp/e_camellia.c b/crypto/evp/e_camellia.c index 3976baaa..884f8cef 100644 --- a/crypto/evp/e_camellia.c +++ b/crypto/evp/e_camellia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_camellia.c,v 1.15 2022/09/10 17:39:47 jsing Exp $ */ +/* $OpenBSD: e_camellia.c,v 1.16 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright (c) 2006 The OpenSSL Project. All rights reserved. * @@ -62,7 +62,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* Camellia subkey Structure */ typedef struct { diff --git a/crypto/evp/e_cast.c b/crypto/evp/e_cast.c index 702c26e0..98683e1d 100644 --- a/crypto/evp/e_cast.c +++ b/crypto/evp/e_cast.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_cast.c,v 1.13 2022/09/15 07:04:19 jsing Exp $ */ +/* $OpenBSD: e_cast.c,v 1.14 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -67,7 +67,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" typedef struct { CAST_KEY ks; diff --git a/crypto/evp/e_chacha.c b/crypto/evp/e_chacha.c index 447ce7e9..f27ed1d3 100644 --- a/crypto/evp/e_chacha.c +++ b/crypto/evp/e_chacha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_chacha.c,v 1.9 2022/07/30 17:11:38 jsing Exp $ */ +/* $OpenBSD: e_chacha.c,v 1.10 2022/11/26 16:08:52 tb Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -23,7 +23,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" static int chacha_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, diff --git a/crypto/evp/e_chacha20poly1305.c b/crypto/evp/e_chacha20poly1305.c index 45026484..1bd04c1f 100644 --- a/crypto/evp/e_chacha20poly1305.c +++ b/crypto/evp/e_chacha20poly1305.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_chacha20poly1305.c,v 1.26 2022/09/13 04:59:18 jsing Exp $ */ +/* $OpenBSD: e_chacha20poly1305.c,v 1.28 2023/03/01 11:16:06 tb Exp $ */ /* * Copyright (c) 2022 Joel Sing @@ -31,7 +31,7 @@ #include #include "bytestring.h" -#include "evp_locl.h" +#include "evp_local.h" #define POLY1305_TAG_LEN 16 @@ -530,12 +530,14 @@ chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, return len; } -static void +static int chacha20_poly1305_cleanup(EVP_CIPHER_CTX *ctx) { struct chacha20_poly1305_ctx *cpx = ctx->cipher_data; explicit_bzero(cpx, sizeof(*cpx)); + + return 1; } static int diff --git a/crypto/evp/e_des.c b/crypto/evp/e_des.c index 8fcab72e..dffabc81 100644 --- a/crypto/evp/e_des.c +++ b/crypto/evp/e_des.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_des.c,v 1.19 2022/09/15 07:04:19 jsing Exp $ */ +/* $OpenBSD: e_des.c,v 1.20 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -67,7 +67,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c index 6a5d03fe..d6c7537a 100644 --- a/crypto/evp/e_des3.c +++ b/crypto/evp/e_des3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_des3.c,v 1.25 2022/09/15 07:04:19 jsing Exp $ */ +/* $OpenBSD: e_des3.c,v 1.26 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -68,7 +68,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" typedef struct { DES_key_schedule ks1;/* key schedule */ diff --git a/crypto/evp/e_gost2814789.c b/crypto/evp/e_gost2814789.c index cff66e8c..6344a11e 100644 --- a/crypto/evp/e_gost2814789.c +++ b/crypto/evp/e_gost2814789.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_gost2814789.c,v 1.10 2022/09/10 17:39:47 jsing Exp $ */ +/* $OpenBSD: e_gost2814789.c,v 1.11 2022/11/26 16:08:52 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -58,7 +58,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" typedef struct { GOST2814789_KEY ks; diff --git a/crypto/evp/e_idea.c b/crypto/evp/e_idea.c index b45ffd56..b8349ee9 100644 --- a/crypto/evp/e_idea.c +++ b/crypto/evp/e_idea.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_idea.c,v 1.17 2022/09/15 07:04:19 jsing Exp $ */ +/* $OpenBSD: e_idea.c,v 1.18 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -68,7 +68,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* NB idea_ecb_encrypt doesn't take an 'encrypt' argument so we treat it as a special * case diff --git a/crypto/evp/e_null.c b/crypto/evp/e_null.c index db79e1ec..ddd633dc 100644 --- a/crypto/evp/e_null.c +++ b/crypto/evp/e_null.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_null.c,v 1.15 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: e_null.c,v 1.16 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); diff --git a/crypto/evp/e_rc2.c b/crypto/evp/e_rc2.c index 1af17a7c..78697d08 100644 --- a/crypto/evp/e_rc2.c +++ b/crypto/evp/e_rc2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_rc2.c,v 1.19 2022/09/15 07:04:19 jsing Exp $ */ +/* $OpenBSD: e_rc2.c,v 1.20 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -68,7 +68,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); diff --git a/crypto/evp/e_rc4.c b/crypto/evp/e_rc4.c index e77a2931..7afc6af9 100644 --- a/crypto/evp/e_rc4.c +++ b/crypto/evp/e_rc4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_rc4.c,v 1.14 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: e_rc4.c,v 1.15 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,7 +66,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* FIXME: surely this is available elsewhere? */ #define EVP_RC4_KEY_SIZE 16 diff --git a/crypto/evp/e_rc4_hmac_md5.c b/crypto/evp/e_rc4_hmac_md5.c index b8a6b449..b3be57d5 100644 --- a/crypto/evp/e_rc4_hmac_md5.c +++ b/crypto/evp/e_rc4_hmac_md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_rc4_hmac_md5.c,v 1.9 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: e_rc4_hmac_md5.c,v 1.10 2022/11/26 16:08:52 tb Exp $ */ /* ==================================================================== * Copyright (c) 2011 The OpenSSL Project. All rights reserved. * @@ -60,7 +60,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* FIXME: surely this is available elsewhere? */ #define EVP_RC4_KEY_SIZE 16 diff --git a/crypto/evp/e_sm4.c b/crypto/evp/e_sm4.c index 11e9a74d..0d374481 100644 --- a/crypto/evp/e_sm4.c +++ b/crypto/evp/e_sm4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_sm4.c,v 1.6 2022/09/10 17:39:47 jsing Exp $ */ +/* $OpenBSD: e_sm4.c,v 1.7 2022/11/26 16:08:52 tb Exp $ */ /* * Copyright (c) 2017, 2019 Ribose Inc * @@ -22,7 +22,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" typedef struct { SM4_KEY ks; diff --git a/crypto/evp/e_xcbc_d.c b/crypto/evp/e_xcbc_d.c index 2aae0a91..bbbc3a1e 100644 --- a/crypto/evp/e_xcbc_d.c +++ b/crypto/evp/e_xcbc_d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_xcbc_d.c,v 1.12 2014/07/11 08:44:48 jsing Exp $ */ +/* $OpenBSD: e_xcbc_d.c,v 1.13 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -67,7 +67,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); diff --git a/crypto/evp/encode.c b/crypto/evp/encode.c index 30fcd858..718bdb5f 100644 --- a/crypto/evp/encode.c +++ b/crypto/evp/encode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: encode.c,v 1.29 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: encode.c,v 1.30 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include -#include "evp_locl.h" +#include "evp_local.h" static unsigned char conv_ascii2bin(unsigned char a); #define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f]) diff --git a/crypto/evp/evp_aead.c b/crypto/evp/evp_aead.c index 93d523af..58f1c872 100644 --- a/crypto/evp/evp_aead.c +++ b/crypto/evp/evp_aead.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_aead.c,v 1.7 2022/01/07 21:58:17 tb Exp $ */ +/* $OpenBSD: evp_aead.c,v 1.8 2022/11/26 16:08:52 tb Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -21,7 +21,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" size_t EVP_AEAD_key_length(const EVP_AEAD *aead) diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 49e0ffa1..df818e3a 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_enc.c,v 1.47 2022/09/13 04:59:18 jsing Exp $ */ +/* $OpenBSD: evp_enc.c,v 1.50 2023/03/01 11:16:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -72,7 +72,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, @@ -98,7 +98,7 @@ EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts * so this context may already have an ENGINE! Try to avoid releasing * the previous handle, re-querying for an ENGINE, and having a - * reinitialisation, when it may all be unecessary. */ + * reinitialisation, when it may all be unnecessary. */ if (ctx->engine && ctx->cipher && (!cipher || (cipher && (cipher->nid == ctx->cipher->nid)))) goto skip_to_init; @@ -601,6 +601,7 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c) { if (c->cipher != NULL) { + /* XXX - Avoid leaks, so ignore return value of cleanup()... */ if (c->cipher->cleanup != NULL) c->cipher->cleanup(c); if (c->cipher_data != NULL) diff --git a/crypto/evp/evp_err.c b/crypto/evp/evp_err.c index 4feea1aa..9cf89f47 100644 --- a/crypto/evp/evp_err.c +++ b/crypto/evp/evp_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_err.c,v 1.28 2022/07/12 14:42:49 kn Exp $ */ +/* $OpenBSD: evp_err.c,v 1.30 2022/11/10 15:17:30 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -101,6 +101,7 @@ static ERR_STRING_DATA EVP_str_reasons[] = { {ERR_REASON(EVP_R_EXPECTING_A_ECDSA_KEY) , "expecting a ecdsa key"}, {ERR_REASON(EVP_R_EXPECTING_A_EC_KEY) , "expecting a ec key"}, {ERR_REASON(EVP_R_FIPS_MODE_NOT_SUPPORTED), "fips mode not supported"}, + {ERR_REASON(EVP_R_GET_RAW_KEY_FAILED) , "get raw key failed"}, {ERR_REASON(EVP_R_INITIALIZATION_ERROR) , "initialization error"}, {ERR_REASON(EVP_R_INPUT_NOT_INITIALIZED) , "input not initialized"}, {ERR_REASON(EVP_R_INVALID_DIGEST) , "invalid digest"}, @@ -122,6 +123,7 @@ static ERR_STRING_DATA EVP_str_reasons[] = { {ERR_REASON(EVP_R_NO_OPERATION_SET) , "no operation set"}, {ERR_REASON(EVP_R_NO_SIGN_FUNCTION_CONFIGURED), "no sign function configured"}, {ERR_REASON(EVP_R_NO_VERIFY_FUNCTION_CONFIGURED), "no verify function configured"}, + {ERR_REASON(EVP_R_ONLY_ONESHOT_SUPPORTED), "only oneshot supported"}, {ERR_REASON(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE), "operation not supported for this keytype"}, {ERR_REASON(EVP_R_OPERATON_NOT_INITIALIZED), "operaton not initialized"}, {ERR_REASON(EVP_R_OUTPUT_ALIASES_INPUT) , "output aliases input"}, diff --git a/crypto/evp/evp_key.c b/crypto/evp/evp_key.c index dcfb94e3..6fc8588c 100644 --- a/crypto/evp/evp_key.c +++ b/crypto/evp/evp_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_key.c,v 1.27 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: evp_key.c,v 1.28 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,7 +65,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* should be init to zeros. */ static char prompt_string[80]; diff --git a/crypto/evp/evp_lib.c b/crypto/evp/evp_lib.c index 0e354d62..f64842b8 100644 --- a/crypto/evp/evp_lib.c +++ b/crypto/evp/evp_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_lib.c,v 1.24 2022/01/10 13:42:28 tb Exp $ */ +/* $OpenBSD: evp_lib.c,v 1.25 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,8 +63,8 @@ #include #include -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) diff --git a/crypto/evp/evp_locl.h b/crypto/evp/evp_local.h similarity index 94% rename from crypto/evp/evp_locl.h rename to crypto/evp/evp_local.h index 1e79af4c..9905b82d 100644 --- a/crypto/evp/evp_locl.h +++ b/crypto/evp/evp_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_locl.h,v 1.28 2022/09/13 04:59:18 jsing Exp $ */ +/* $OpenBSD: evp_local.h,v 1.3 2023/03/01 11:16:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -56,8 +56,8 @@ * */ -#ifndef HEADER_EVP_LOCL_H -#define HEADER_EVP_LOCL_H +#ifndef HEADER_EVP_LOCAL_H +#define HEADER_EVP_LOCAL_H __BEGIN_HIDDEN_DECLS @@ -74,6 +74,15 @@ typedef int evp_verify_method(int type, const unsigned char *m, unsigned int m_length, const unsigned char *sigbuf, unsigned int siglen, void *key); +struct ecx_key_st { + int nid; + int key_len; + uint8_t *priv_key; + size_t priv_key_len; + uint8_t *pub_key; + size_t pub_key_len; +}; + /* Type needs to be a bit field * Sub-type needs to be for variations on the method, as in, can it do * arbitrary encryption.... */ @@ -84,7 +93,7 @@ struct evp_pkey_st { const EVP_PKEY_ASN1_METHOD *ameth; ENGINE *engine; union { - char *ptr; + void *ptr; #ifndef OPENSSL_NO_RSA struct rsa_st *rsa; /* RSA */ #endif @@ -96,6 +105,7 @@ struct evp_pkey_st { #endif #ifndef OPENSSL_NO_EC struct ec_key_st *ec; /* ECC */ + struct ecx_key_st *ecx; /* ECX */ #endif #ifndef OPENSSL_NO_GOST struct gost_key_st *gost; /* GOST */ @@ -143,7 +153,7 @@ struct evp_cipher_st { const unsigned char *iv, int enc); /* init key */ int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl);/* encrypt/decrypt data */ - void (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ + int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ int ctx_size; /* how big ctx->cipher_data needs to be */ int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */ @@ -260,6 +270,11 @@ struct evp_pkey_method_st { int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2); int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value); + int (*digestsign)(EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen); + int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen, const unsigned char *tbs, size_t tbslen); + int (*check)(EVP_PKEY *pkey); int (*public_check)(EVP_PKEY *pkey); int (*param_check)(EVP_PKEY *pkey); @@ -306,4 +321,4 @@ int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name) __END_HIDDEN_DECLS -#endif /* !HEADER_EVP_LOCL_H */ +#endif /* !HEADER_EVP_LOCAL_H */ diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index 65e9e45e..56595552 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_pbe.c,v 1.26 2020/06/05 17:30:41 jsing Exp $ */ +/* $OpenBSD: evp_pbe.c,v 1.27 2022/11/26 16:08:52 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -66,7 +66,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* Password based encryption (PBE) functions */ diff --git a/crypto/evp/evp_pkey.c b/crypto/evp/evp_pkey.c index 3ba0e1dd..d2fbdee4 100644 --- a/crypto/evp/evp_pkey.c +++ b/crypto/evp/evp_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_pkey.c,v 1.24 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: evp_pkey.c,v 1.25 2022/11/26 16:08:52 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -62,8 +62,8 @@ #include #include -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" /* Extract a private key from a PKCS8 structure */ diff --git a/crypto/evp/m_gost2814789.c b/crypto/evp/m_gost2814789.c index 7d11ec8c..ca303dab 100644 --- a/crypto/evp/m_gost2814789.c +++ b/crypto/evp/m_gost2814789.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_gost2814789.c,v 1.3 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: m_gost2814789.c,v 1.4 2022/11/26 16:08:52 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -57,7 +57,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" static int gost2814789_init(EVP_MD_CTX *ctx) diff --git a/crypto/evp/m_gostr341194.c b/crypto/evp/m_gostr341194.c index f479675b..33e96a5a 100644 --- a/crypto/evp/m_gostr341194.c +++ b/crypto/evp/m_gostr341194.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_gostr341194.c,v 1.4 2022/01/14 08:38:05 tb Exp $ */ +/* $OpenBSD: m_gostr341194.c,v 1.5 2022/11/26 16:08:52 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -59,7 +59,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" static int gostr341194_init(EVP_MD_CTX *ctx) diff --git a/crypto/evp/m_md4.c b/crypto/evp/m_md4.c index 97756528..c1e0256b 100644 --- a/crypto/evp/m_md4.c +++ b/crypto/evp/m_md4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_md4.c,v 1.18 2022/01/14 08:38:05 tb Exp $ */ +/* $OpenBSD: m_md4.c,v 1.19 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,7 +71,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" static int init(EVP_MD_CTX *ctx) diff --git a/crypto/evp/m_md5.c b/crypto/evp/m_md5.c index daa7aee7..b66b25ba 100644 --- a/crypto/evp/m_md5.c +++ b/crypto/evp/m_md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_md5.c,v 1.17 2022/01/14 08:38:06 tb Exp $ */ +/* $OpenBSD: m_md5.c,v 1.18 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,7 +71,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" static int init(EVP_MD_CTX *ctx) diff --git a/crypto/evp/m_md5_sha1.c b/crypto/evp/m_md5_sha1.c index f8bec10d..b1944b88 100644 --- a/crypto/evp/m_md5_sha1.c +++ b/crypto/evp/m_md5_sha1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_md5_sha1.c,v 1.4 2022/01/14 08:38:06 tb Exp $ */ +/* $OpenBSD: m_md5_sha1.c,v 1.5 2022/11/26 16:08:52 tb Exp $ */ /* * Copyright (c) 2017 Joel Sing * @@ -24,7 +24,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" struct md5_sha1_ctx { MD5_CTX md5; diff --git a/crypto/evp/m_null.c b/crypto/evp/m_null.c index 4334decb..d09c0007 100644 --- a/crypto/evp/m_null.c +++ b/crypto/evp/m_null.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_null.c,v 1.11 2022/01/14 08:38:06 tb Exp $ */ +/* $OpenBSD: m_null.c,v 1.12 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" static int init(EVP_MD_CTX *ctx) diff --git a/crypto/evp/m_ripemd.c b/crypto/evp/m_ripemd.c index 47397833..896de59d 100644 --- a/crypto/evp/m_ripemd.c +++ b/crypto/evp/m_ripemd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_ripemd.c,v 1.14 2022/01/14 08:38:06 tb Exp $ */ +/* $OpenBSD: m_ripemd.c,v 1.15 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,7 +71,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" static int init(EVP_MD_CTX *ctx) diff --git a/crypto/evp/m_sha1.c b/crypto/evp/m_sha1.c index a6fb5364..5b386668 100644 --- a/crypto/evp/m_sha1.c +++ b/crypto/evp/m_sha1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_sha1.c,v 1.19 2022/01/14 08:38:06 tb Exp $ */ +/* $OpenBSD: m_sha1.c,v 1.20 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -70,7 +70,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" static int init(EVP_MD_CTX *ctx) diff --git a/crypto/evp/m_sigver.c b/crypto/evp/m_sigver.c index bd937465..49b1ce29 100644 --- a/crypto/evp/m_sigver.c +++ b/crypto/evp/m_sigver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_sigver.c,v 1.9 2021/05/09 14:25:40 tb Exp $ */ +/* $OpenBSD: m_sigver.c,v 1.11 2022/11/26 16:08:52 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -63,7 +63,14 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" + +static int +update_oneshot_only(EVP_MD_CTX *ctx, const void *data, size_t datalen) +{ + EVPerror(EVP_R_ONLY_ONESHOT_SUPPORTED); + return 0; +} static int do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, @@ -93,6 +100,9 @@ do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ctx) <=0) return 0; ctx->pctx->operation = EVP_PKEY_OP_VERIFYCTX; + } else if (ctx->pctx->pmeth->digestverify != NULL) { + ctx->pctx->operation = EVP_PKEY_OP_VERIFY; + ctx->update = update_oneshot_only; } else if (EVP_PKEY_verify_init(ctx->pctx) <= 0) return 0; } else { @@ -100,6 +110,9 @@ do_sigver_init(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, if (ctx->pctx->pmeth->signctx_init(ctx->pctx, ctx) <= 0) return 0; ctx->pctx->operation = EVP_PKEY_OP_SIGNCTX; + } else if (ctx->pctx->pmeth->digestsign != NULL) { + ctx->pctx->operation = EVP_PKEY_OP_SIGN; + ctx->update = update_oneshot_only; } else if (EVP_PKEY_sign_init(ctx->pctx) <= 0) return 0; } @@ -190,6 +203,10 @@ int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, size_t *siglen, const unsigned char *tbs, size_t tbslen) { + if (ctx->pctx->pmeth->digestsign != NULL) + return ctx->pctx->pmeth->digestsign(ctx, sigret, siglen, + tbs, tbslen); + if (sigret != NULL) { if (EVP_DigestSignUpdate(ctx, tbs, tbslen) <= 0) return 0; @@ -229,6 +246,10 @@ int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret, size_t siglen, const unsigned char *tbs, size_t tbslen) { + if (ctx->pctx->pmeth->digestverify != NULL) + return ctx->pctx->pmeth->digestverify(ctx, sigret, siglen, + tbs, tbslen); + if (EVP_DigestVerifyUpdate(ctx, tbs, tbslen) <= 0) return -1; diff --git a/crypto/evp/m_sm3.c b/crypto/evp/m_sm3.c index ae8b342e..bf0ef527 100644 --- a/crypto/evp/m_sm3.c +++ b/crypto/evp/m_sm3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_sm3.c,v 1.3 2022/01/14 08:38:06 tb Exp $ */ +/* $OpenBSD: m_sm3.c,v 1.4 2022/11/26 16:08:52 tb Exp $ */ /* * Copyright (c) 2018, Ribose Inc * @@ -25,7 +25,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" static int sm3_init(EVP_MD_CTX *ctx) diff --git a/crypto/evp/m_streebog.c b/crypto/evp/m_streebog.c index 3f825e3a..5a0dece5 100644 --- a/crypto/evp/m_streebog.c +++ b/crypto/evp/m_streebog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_streebog.c,v 1.4 2022/01/14 08:38:06 tb Exp $ */ +/* $OpenBSD: m_streebog.c,v 1.5 2022/11/26 16:08:52 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -57,7 +57,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" static int streebog_init256(EVP_MD_CTX *ctx) diff --git a/crypto/evp/m_wp.c b/crypto/evp/m_wp.c index 07ae7ca5..2e0b46d5 100644 --- a/crypto/evp/m_wp.c +++ b/crypto/evp/m_wp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m_wp.c,v 1.10 2022/01/14 08:38:06 tb Exp $ */ +/* $OpenBSD: m_wp.c,v 1.11 2022/11/26 16:08:52 tb Exp $ */ #include @@ -11,7 +11,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" static int init(EVP_MD_CTX *ctx) diff --git a/crypto/evp/names.c b/crypto/evp/names.c index 02529eef..a27a1875 100644 --- a/crypto/evp/names.c +++ b/crypto/evp/names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: names.c,v 1.15 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: names.c,v 1.16 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" int EVP_add_cipher(const EVP_CIPHER *c) diff --git a/crypto/evp/p5_crpt.c b/crypto/evp/p5_crpt.c index b9482e08..e85a60f5 100644 --- a/crypto/evp/p5_crpt.c +++ b/crypto/evp/p5_crpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p5_crpt.c,v 1.20 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: p5_crpt.c,v 1.21 2022/11/26 16:08:52 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -64,7 +64,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* Doesn't do anything now: Builtin PBE algorithms in static table. */ diff --git a/crypto/evp/p5_crpt2.c b/crypto/evp/p5_crpt2.c index f3585ff3..6c0cf529 100644 --- a/crypto/evp/p5_crpt2.c +++ b/crypto/evp/p5_crpt2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p5_crpt2.c,v 1.24 2021/12/12 21:27:37 tb Exp $ */ +/* $OpenBSD: p5_crpt2.c,v 1.25 2022/11/26 16:08:52 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -69,7 +69,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" #include "hmac_local.h" /* This is an implementation of PKCS#5 v2.0 password based encryption key diff --git a/crypto/evp/p_dec.c b/crypto/evp/p_dec.c index c19cc651..33dd3019 100644 --- a/crypto/evp/p_dec.c +++ b/crypto/evp/p_dec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_dec.c,v 1.12 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: p_dec.c,v 1.13 2022/11/26 16:08:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -69,7 +69,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" int EVP_PKEY_decrypt_old(unsigned char *key, const unsigned char *ek, int ekl, diff --git a/crypto/evp/p_enc.c b/crypto/evp/p_enc.c index 5553429c..4685f55c 100644 --- a/crypto/evp/p_enc.c +++ b/crypto/evp/p_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_enc.c,v 1.12 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: p_enc.c,v 1.13 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -69,7 +69,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" int EVP_PKEY_encrypt_old(unsigned char *ek, const unsigned char *key, int key_len, diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index b6cef5a1..e1760122 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_lib.c,v 1.29 2022/06/27 12:36:05 tb Exp $ */ +/* $OpenBSD: p_lib.c,v 1.32 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -81,8 +81,8 @@ #include #endif -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" static void EVP_PKEY_free_it(EVP_PKEY *x); @@ -278,6 +278,96 @@ EVP_PKEY_set_type(EVP_PKEY *pkey, int type) return pkey_set_type(pkey, NULL, type, NULL, -1); } +EVP_PKEY * +EVP_PKEY_new_raw_private_key(int type, ENGINE *engine, + const unsigned char *private_key, size_t len) +{ + EVP_PKEY *ret; + + if ((ret = EVP_PKEY_new()) == NULL) + goto err; + + if (!pkey_set_type(ret, engine, type, NULL, -1)) + goto err; + + if (ret->ameth->set_priv_key == NULL) { + EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); + goto err; + } + if (!ret->ameth->set_priv_key(ret, private_key, len)) { + EVPerror(EVP_R_KEY_SETUP_FAILED); + goto err; + } + + return ret; + + err: + EVP_PKEY_free(ret); + + return NULL; +} + +EVP_PKEY * +EVP_PKEY_new_raw_public_key(int type, ENGINE *engine, + const unsigned char *public_key, size_t len) +{ + EVP_PKEY *ret; + + if ((ret = EVP_PKEY_new()) == NULL) + goto err; + + if (!pkey_set_type(ret, engine, type, NULL, -1)) + goto err; + + if (ret->ameth->set_pub_key == NULL) { + EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); + goto err; + } + if (!ret->ameth->set_pub_key(ret, public_key, len)) { + EVPerror(EVP_R_KEY_SETUP_FAILED); + goto err; + } + + return ret; + + err: + EVP_PKEY_free(ret); + + return NULL; +} + +int +EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, + unsigned char *out_private_key, size_t *out_len) +{ + if (pkey->ameth->get_priv_key == NULL) { + EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); + return 0; + } + if (!pkey->ameth->get_priv_key(pkey, out_private_key, out_len)) { + EVPerror(EVP_R_GET_RAW_KEY_FAILED); + return 0; + } + + return 1; +} + +int +EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, + unsigned char *out_public_key, size_t *out_len) +{ + if (pkey->ameth->get_pub_key == NULL) { + EVPerror(EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); + return 0; + } + if (!pkey->ameth->get_pub_key(pkey, out_public_key, out_len)) { + EVPerror(EVP_R_GET_RAW_KEY_FAILED); + return 0; + } + + return 1; +} + EVP_PKEY * EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv, size_t len, const EVP_CIPHER *cipher) @@ -298,7 +388,7 @@ EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv, size_t len, goto err; } - ret->pkey.ptr = (char *)cmctx; + ret->pkey.ptr = cmctx; return ret; @@ -581,4 +671,3 @@ EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid) return pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_DEFAULT_MD_NID, 0, pnid); } - diff --git a/crypto/evp/p_open.c b/crypto/evp/p_open.c index e4c59e68..bce900b9 100644 --- a/crypto/evp/p_open.c +++ b/crypto/evp/p_open.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_open.c,v 1.20 2021/12/12 21:30:13 tb Exp $ */ +/* $OpenBSD: p_open.c,v 1.21 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -69,7 +69,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, diff --git a/crypto/evp/p_sign.c b/crypto/evp/p_sign.c index 1e33cfbe..1f78d1ef 100644 --- a/crypto/evp/p_sign.c +++ b/crypto/evp/p_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_sign.c,v 1.16 2022/01/14 08:38:06 tb Exp $ */ +/* $OpenBSD: p_sign.c,v 1.17 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, diff --git a/crypto/evp/p_verify.c b/crypto/evp/p_verify.c index d51d1b4a..54571532 100644 --- a/crypto/evp/p_verify.c +++ b/crypto/evp/p_verify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_verify.c,v 1.15 2022/01/14 08:38:06 tb Exp $ */ +/* $OpenBSD: p_verify.c,v 1.16 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, diff --git a/crypto/evp/pmeth_fn.c b/crypto/evp/pmeth_fn.c index c9117eed..cab1dfab 100644 --- a/crypto/evp/pmeth_fn.c +++ b/crypto/evp/pmeth_fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_fn.c,v 1.6 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: pmeth_fn.c,v 1.7 2022/11/26 16:08:53 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -63,7 +63,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" #define M_check_autoarg(ctx, arg, arglen, err) \ if (ctx->pmeth->flags & EVP_PKEY_FLAG_AUTOARGLEN) \ diff --git a/crypto/evp/pmeth_gn.c b/crypto/evp/pmeth_gn.c index 7d921d23..d31bb7c0 100644 --- a/crypto/evp/pmeth_gn.c +++ b/crypto/evp/pmeth_gn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_gn.c,v 1.10 2022/01/10 12:10:26 tb Exp $ */ +/* $OpenBSD: pmeth_gn.c,v 1.11 2022/11/26 16:08:53 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -64,9 +64,9 @@ #include #include -#include "asn1_locl.h" -#include "bn_lcl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "bn_local.h" +#include "evp_local.h" int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx) diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index 96024492..bec899ce 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmeth_lib.c,v 1.22 2022/05/05 08:51:21 tb Exp $ */ +/* $OpenBSD: pmeth_lib.c,v 1.27 2022/12/26 07:18:52 jmc Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -72,89 +72,82 @@ #include #endif -#include "asn1_locl.h" -#include "evp_locl.h" - -typedef int sk_cmp_fn_type(const char * const *a, const char * const *b); +#include "asn1_local.h" +#include "evp_local.h" DECLARE_STACK_OF(EVP_PKEY_METHOD) -STACK_OF(EVP_PKEY_METHOD) *app_pkey_methods = NULL; - -extern const EVP_PKEY_METHOD rsa_pkey_meth, rsa_pss_pkey_meth; -extern const EVP_PKEY_METHOD dh_pkey_meth, dsa_pkey_meth; -extern const EVP_PKEY_METHOD ec_pkey_meth, hmac_pkey_meth, cmac_pkey_meth; -extern const EVP_PKEY_METHOD gostimit_pkey_meth, gostr01_pkey_meth; +STACK_OF(EVP_PKEY_METHOD) *pkey_app_methods = NULL; + +extern const EVP_PKEY_METHOD cmac_pkey_meth; +extern const EVP_PKEY_METHOD dh_pkey_meth; +extern const EVP_PKEY_METHOD dsa_pkey_meth; +extern const EVP_PKEY_METHOD ec_pkey_meth; +extern const EVP_PKEY_METHOD ed25519_pkey_meth; +extern const EVP_PKEY_METHOD gostimit_pkey_meth; +extern const EVP_PKEY_METHOD gostr01_pkey_meth; extern const EVP_PKEY_METHOD hkdf_pkey_meth; +extern const EVP_PKEY_METHOD hmac_pkey_meth; +extern const EVP_PKEY_METHOD rsa_pkey_meth; +extern const EVP_PKEY_METHOD rsa_pss_pkey_meth; +extern const EVP_PKEY_METHOD x25519_pkey_meth; -static const EVP_PKEY_METHOD *standard_methods[] = { -#ifndef OPENSSL_NO_RSA - &rsa_pkey_meth, -#endif -#ifndef OPENSSL_NO_DH +static const EVP_PKEY_METHOD *pkey_methods[] = { + &cmac_pkey_meth, &dh_pkey_meth, -#endif -#ifndef OPENSSL_NO_DSA &dsa_pkey_meth, -#endif -#ifndef OPENSSL_NO_EC &ec_pkey_meth, -#endif -#ifndef OPENSSL_NO_GOST - &gostr01_pkey_meth, + &ed25519_pkey_meth, &gostimit_pkey_meth, -#endif + &gostr01_pkey_meth, + &hkdf_pkey_meth, &hmac_pkey_meth, - &cmac_pkey_meth, -#ifndef OPENSSL_NO_RSA + &rsa_pkey_meth, &rsa_pss_pkey_meth, -#endif - &hkdf_pkey_meth, + &x25519_pkey_meth, }; -static int pmeth_cmp_BSEARCH_CMP_FN(const void *, const void *); -static int pmeth_cmp(const EVP_PKEY_METHOD * const *, const EVP_PKEY_METHOD * const *); -static const EVP_PKEY_METHOD * *OBJ_bsearch_pmeth(const EVP_PKEY_METHOD * *key, const EVP_PKEY_METHOD * const *base, int num); +static const size_t pkey_methods_count = + sizeof(pkey_methods) / sizeof(pkey_methods[0]); -static int -pmeth_cmp(const EVP_PKEY_METHOD * const *a, const EVP_PKEY_METHOD * const *b) +int +evp_pkey_meth_get_count(void) { - return ((*a)->pkey_id - (*b)->pkey_id); -} + int num = pkey_methods_count; + if (pkey_app_methods != NULL) + num += sk_EVP_PKEY_METHOD_num(pkey_app_methods); -static int -pmeth_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) -{ - const EVP_PKEY_METHOD * const *a = a_; - const EVP_PKEY_METHOD * const *b = b_; - return pmeth_cmp(a, b); + return num; } -static const EVP_PKEY_METHOD * * -OBJ_bsearch_pmeth(const EVP_PKEY_METHOD * *key, const EVP_PKEY_METHOD * const *base, int num) +const EVP_PKEY_METHOD * +evp_pkey_meth_get0(int idx) { - return (const EVP_PKEY_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const EVP_PKEY_METHOD *), - pmeth_cmp_BSEARCH_CMP_FN); + int num = pkey_methods_count; + + if (idx < 0) + return NULL; + if (idx < num) + return pkey_methods[idx]; + + idx -= num; + + return sk_EVP_PKEY_METHOD_value(pkey_app_methods, idx); } const EVP_PKEY_METHOD * EVP_PKEY_meth_find(int type) { - EVP_PKEY_METHOD tmp; - const EVP_PKEY_METHOD *t = &tmp, **ret; + const EVP_PKEY_METHOD *pmeth; + int i; - tmp.pkey_id = type; - if (app_pkey_methods) { - int idx; - idx = sk_EVP_PKEY_METHOD_find(app_pkey_methods, &tmp); - if (idx >= 0) - return sk_EVP_PKEY_METHOD_value(app_pkey_methods, idx); + for (i = evp_pkey_meth_get_count() - 1; i >= 0; i--) { + pmeth = evp_pkey_meth_get0(i); + if (pmeth->pkey_id == type) + return pmeth; } - ret = OBJ_bsearch_pmeth(&t, standard_methods, - sizeof(standard_methods)/sizeof(EVP_PKEY_METHOD *)); - if (!ret || !*ret) - return NULL; - return *ret; + + return NULL; } static EVP_PKEY_CTX * @@ -180,7 +173,7 @@ int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) } else e = ENGINE_get_pkey_meth_engine(id); - /* If an ENGINE handled this method look it up. Othewise + /* If an ENGINE handled this method look it up. Otherwise * use internal tables. */ @@ -326,14 +319,15 @@ EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx) int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth) { - if (app_pkey_methods == NULL) { - app_pkey_methods = sk_EVP_PKEY_METHOD_new(pmeth_cmp); - if (!app_pkey_methods) + if (pkey_app_methods == NULL) { + pkey_app_methods = sk_EVP_PKEY_METHOD_new(NULL); + if (pkey_app_methods == NULL) return 0; } - if (!sk_EVP_PKEY_METHOD_push(app_pkey_methods, pmeth)) + + if (!sk_EVP_PKEY_METHOD_push(pkey_app_methods, pmeth)) return 0; - sk_EVP_PKEY_METHOD_sort(app_pkey_methods); + return 1; } diff --git a/crypto/gost/gost2814789.c b/crypto/gost/gost2814789.c index 0841a03b..1e0f17da 100644 --- a/crypto/gost/gost2814789.c +++ b/crypto/gost/gost2814789.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gost2814789.c,v 1.7 2021/11/09 18:40:21 bcook Exp $ */ +/* $OpenBSD: gost2814789.c,v 1.8 2022/11/26 16:08:53 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -58,7 +58,7 @@ #include #include -#include "gost_locl.h" +#include "gost_local.h" static inline unsigned int f(const GOST2814789_KEY *c, unsigned int x) diff --git a/crypto/gost/gost89_keywrap.c b/crypto/gost/gost89_keywrap.c index a754c4d5..9bfc5b4c 100644 --- a/crypto/gost/gost89_keywrap.c +++ b/crypto/gost/gost89_keywrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gost89_keywrap.c,v 1.3 2014/11/09 19:28:44 miod Exp $ */ +/* $OpenBSD: gost89_keywrap.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -57,7 +57,7 @@ #include -#include "gost_locl.h" +#include "gost_local.h" static void key_diversify_crypto_pro(GOST2814789_KEY *ctx, const unsigned char *inputKey, diff --git a/crypto/gost/gost89_params.c b/crypto/gost/gost89_params.c index 35d8f62f..9c4a97ee 100644 --- a/crypto/gost/gost89_params.c +++ b/crypto/gost/gost89_params.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gost89_params.c,v 1.2 2014/11/09 23:06:52 miod Exp $ */ +/* $OpenBSD: gost89_params.c,v 1.3 2022/11/26 16:08:53 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -57,7 +57,7 @@ #include #include -#include "gost_locl.h" +#include "gost_local.h" /* Substitution blocks from test examples for GOST R 34.11-94*/ static const gost_subst_block GostR3411_94_TestParamSet = { diff --git a/crypto/gost/gost89imit_ameth.c b/crypto/gost/gost89imit_ameth.c index 3fdfa3ee..e300b528 100644 --- a/crypto/gost/gost89imit_ameth.c +++ b/crypto/gost/gost89imit_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gost89imit_ameth.c,v 1.3 2021/12/12 21:30:14 tb Exp $ */ +/* $OpenBSD: gost89imit_ameth.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -54,8 +54,8 @@ #ifndef OPENSSL_NO_GOST #include -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" static void mackey_free_gost(EVP_PKEY *pk) diff --git a/crypto/gost/gost89imit_pmeth.c b/crypto/gost/gost89imit_pmeth.c index 1959b361..63b7ef59 100644 --- a/crypto/gost/gost89imit_pmeth.c +++ b/crypto/gost/gost89imit_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gost89imit_pmeth.c,v 1.4 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: gost89imit_pmeth.c,v 1.5 2022/11/26 16:08:53 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -59,8 +59,8 @@ #include #include /* For string_to_hex */ -#include "evp_locl.h" -#include "gost_locl.h" +#include "evp_local.h" +#include "gost_local.h" struct gost_mac_pmeth_data { EVP_MD *md; diff --git a/crypto/gost/gost_asn1.c b/crypto/gost/gost_asn1.c index 26521627..d83ded55 100644 --- a/crypto/gost/gost_asn1.c +++ b/crypto/gost/gost_asn1.c @@ -14,7 +14,7 @@ #include #include -#include "gost_locl.h" +#include "gost_local.h" #include "gost_asn1.h" static const ASN1_TEMPLATE GOST_KEY_TRANSPORT_seq_tt[] = { diff --git a/crypto/gost/gost_locl.h b/crypto/gost/gost_local.h similarity index 96% rename from crypto/gost/gost_locl.h rename to crypto/gost/gost_local.h index b2e2c136..830f1414 100644 --- a/crypto/gost/gost_locl.h +++ b/crypto/gost/gost_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gost_locl.h,v 1.4 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: gost_local.h,v 1.2 2022/11/26 17:23:18 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -49,8 +49,8 @@ * ==================================================================== */ -#ifndef HEADER_GOST_LOCL_H -#define HEADER_GOST_LOCL_H +#ifndef HEADER_GOST_LOCAL_H +#define HEADER_GOST_LOCAL_H #include #include @@ -114,4 +114,4 @@ extern int GostR3410_512_param_id(const char *value); __END_HIDDEN_DECLS -#endif +#endif /* !HEADER_GOST_LOCAL_H */ diff --git a/crypto/gost/gostr341001.c b/crypto/gost/gostr341001.c index a6082568..79fddb11 100644 --- a/crypto/gost/gostr341001.c +++ b/crypto/gost/gostr341001.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341001.c,v 1.9 2022/01/07 09:40:03 tb Exp $ */ +/* $OpenBSD: gostr341001.c,v 1.11 2022/12/01 02:58:31 jsing Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -58,9 +58,9 @@ #include #include -#include "bn_lcl.h" -#include "ecs_locl.h" -#include "gost_locl.h" +#include "bn_local.h" +#include "ecs_local.h" +#include "gost_local.h" /* Convert little-endian byte array into bignum */ BIGNUM * @@ -178,8 +178,10 @@ gost2001_do_sign(BIGNUM *md, GOST_KEY *eckey) goto err; if (BN_mod_ct(e, md, order, ctx) == 0) goto err; - if (BN_is_zero(e)) - BN_one(e); + if (BN_is_zero(e)) { + if (!BN_one(e)) + goto err; + } if ((k = BN_CTX_get(ctx)) == NULL) goto err; if ((X = BN_CTX_get(ctx)) == NULL) @@ -289,8 +291,10 @@ gost2001_do_verify(BIGNUM *md, ECDSA_SIG *sig, GOST_KEY *ec) if (BN_mod_ct(e, md, order, ctx) == 0) goto err; - if (BN_is_zero(e)) - BN_one(e); + if (BN_is_zero(e)) { + if (!BN_one(e)) + goto err; + } if ((v = BN_mod_inverse_ct(v, e, order, ctx)) == NULL) goto err; if (BN_mod_mul(z1, sig->s, v, order, ctx) == 0) diff --git a/crypto/gost/gostr341001_ameth.c b/crypto/gost/gostr341001_ameth.c index ce203a6c..9ef7cdf4 100644 --- a/crypto/gost/gostr341001_ameth.c +++ b/crypto/gost/gostr341001_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341001_ameth.c,v 1.19 2021/12/26 15:38:49 tb Exp $ */ +/* $OpenBSD: gostr341001_ameth.c,v 1.20 2022/11/26 16:08:53 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -62,9 +62,9 @@ #include -#include "asn1_locl.h" -#include "evp_locl.h" -#include "gost_locl.h" +#include "asn1_local.h" +#include "evp_local.h" +#include "gost_local.h" #include "gost_asn1.h" static void diff --git a/crypto/gost/gostr341001_key.c b/crypto/gost/gostr341001_key.c index d5d885c2..62694318 100644 --- a/crypto/gost/gostr341001_key.c +++ b/crypto/gost/gostr341001_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341001_key.c,v 1.9 2021/04/20 17:16:38 tb Exp $ */ +/* $OpenBSD: gostr341001_key.c,v 1.12 2023/03/07 09:27:10 jsing Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -58,7 +58,7 @@ #include #include #include -#include "gost_locl.h" +#include "gost_local.h" struct gost_key_st { EC_GROUP *group; @@ -103,7 +103,7 @@ GOST_KEY_free(GOST_KEY *r) EC_GROUP_free(r->group); EC_POINT_free(r->pub_key); - BN_clear_free(r->priv_key); + BN_free(r->priv_key); freezero(r, sizeof(GOST_KEY)); } @@ -193,6 +193,8 @@ GOST_KEY_set_public_key_affine_coordinates(GOST_KEY *key, BIGNUM *x, BIGNUM *y) if (ctx == NULL) goto err; + BN_CTX_start(ctx); + point = EC_POINT_new(key->group); if (point == NULL) goto err; @@ -225,6 +227,7 @@ GOST_KEY_set_public_key_affine_coordinates(GOST_KEY *key, BIGNUM *x, BIGNUM *y) err: EC_POINT_free(point); + BN_CTX_end(ctx); BN_CTX_free(ctx); return ok; @@ -253,7 +256,7 @@ GOST_KEY_get0_private_key(const GOST_KEY *key) int GOST_KEY_set_private_key(GOST_KEY *key, const BIGNUM *priv_key) { - BN_clear_free(key->priv_key); + BN_free(key->priv_key); key->priv_key = BN_dup(priv_key); return (key->priv_key == NULL) ? 0 : 1; } @@ -307,12 +310,12 @@ GOST_KEY_get_size(const GOST_KEY *r) return 0; if (EC_GROUP_get_order(group, order, NULL) == 0) { - BN_clear_free(order); + BN_free(order); return 0; } i = BN_num_bytes(order); - BN_clear_free(order); + BN_free(order); return (i); } #endif diff --git a/crypto/gost/gostr341001_params.c b/crypto/gost/gostr341001_params.c index 282a2104..ca8a27d7 100644 --- a/crypto/gost/gostr341001_params.c +++ b/crypto/gost/gostr341001_params.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341001_params.c,v 1.4 2020/06/05 17:12:09 jsing Exp $ */ +/* $OpenBSD: gostr341001_params.c,v 1.5 2022/11/26 16:08:53 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -57,7 +57,7 @@ #include #include -#include "gost_locl.h" +#include "gost_local.h" int GostR3410_get_md_digest(int nid) diff --git a/crypto/gost/gostr341001_pmeth.c b/crypto/gost/gostr341001_pmeth.c index ae39b059..38f94ecd 100644 --- a/crypto/gost/gostr341001_pmeth.c +++ b/crypto/gost/gostr341001_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341001_pmeth.c,v 1.16 2022/03/30 07:17:48 tb Exp $ */ +/* $OpenBSD: gostr341001_pmeth.c,v 1.17 2022/11/26 16:08:53 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -62,9 +62,9 @@ #include #include -#include "ecs_locl.h" -#include "evp_locl.h" -#include "gost_locl.h" +#include "ecs_local.h" +#include "evp_local.h" +#include "gost_local.h" #include "gost_asn1.h" static ECDSA_SIG * diff --git a/crypto/gost/gostr341194.c b/crypto/gost/gostr341194.c index 2a462185..63058300 100644 --- a/crypto/gost/gostr341194.c +++ b/crypto/gost/gostr341194.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gostr341194.c,v 1.5 2015/09/10 15:56:25 jsing Exp $ */ +/* $OpenBSD: gostr341194.c,v 1.6 2022/11/26 16:08:53 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -58,7 +58,7 @@ #include #include -#include "gost_locl.h" +#include "gost_local.h" /* Following functions are various bit meshing routines used in * GOST R 34.11-94 algorithms */ diff --git a/crypto/gost/streebog.c b/crypto/gost/streebog.c index b237a2c5..2785fca6 100644 --- a/crypto/gost/streebog.c +++ b/crypto/gost/streebog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: streebog.c,v 1.7 2021/11/09 18:40:21 bcook Exp $ */ +/* $OpenBSD: streebog.c,v 1.8 2022/11/26 16:08:53 tb Exp $ */ /* * Copyright (c) 2014 Dmitry Eremin-Solenikov * Copyright (c) 2005-2006 Cryptocom LTD @@ -60,7 +60,7 @@ #include #include -#include "gost_locl.h" +#include "gost_local.h" static const STREEBOG_LONG64 A_PI_table[8][256] = { { /* 0 */ diff --git a/crypto/hidden/crypto_namespace.h b/crypto/hidden/crypto_namespace.h new file mode 100644 index 00000000..85e62ba0 --- /dev/null +++ b/crypto/hidden/crypto_namespace.h @@ -0,0 +1,51 @@ +/* $OpenBSD: crypto_namespace.h,v 1.2 2023/02/16 08:38:17 tb Exp $ */ +/* + * Copyright (c) 2016 Philip Guenther + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_CRYPTO_NAMESPACE_H_ +#define _LIBCRYPTO_CRYPTO_NAMESPACE_H_ + +/* + * If marked as 'used', then internal calls use the name with prefix "_lcry_" + * and we alias that to the normal name *and* the name with prefix "_libre_"; + * external calls use the latter name. + */ + +#ifdef _MSC_VER +# define LCRYPTO_UNUSED(x) +# define LCRYPTO_USED(x) +# define LCRYPTO_ALIAS1(pre, x) +# define LCRYPTO_ALIAS(x) +#else +#ifdef LIBRESSL_NAMESPACE +# define LCRYPTO_UNUSED(x) typeof(x) x __attribute__((deprecated)) +#ifdef LIBRESSL_CRYPTO_NAMESPACE +# define LCRYPTO_USED(x) __attribute__((visibility("hidden"))) \ + typeof(x) x asm("_lcry_"#x) +# define LCRYPTO_ALIAS1(pre,x) asm(".global "#pre#x"; "#pre#x" = _lcry_"#x) +# define LCRYPTO_ALIAS(x) LCRYPTO_ALIAS1(,x); LCRYPTO_ALIAS1(_libre_,x) +#else +# define LCRYPTO_USED(x) typeof(x) x asm("_libre_"#x) +#endif +#else +# define LCRYPTO_UNUSED(x) +# define LCRYPTO_USED(x) +# define LCRYPTO_ALIAS1(pre,x) +# define LCRYPTO_ALIAS(x) asm("") +#endif +#endif /* _MSC_VER */ + +#endif /* _LIBCRYPTO_CRYPTO_NAMESPACE_H_ */ diff --git a/crypto/hidden/openssl/hmac.h b/crypto/hidden/openssl/hmac.h new file mode 100644 index 00000000..c387d1db --- /dev/null +++ b/crypto/hidden/openssl/hmac.h @@ -0,0 +1,40 @@ +/* $OpenBSD: hmac.h,v 1.1 2022/11/11 11:25:18 beck Exp $ */ +/* + * Copyright (c) 2016 Philip Guenther + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_HMAC_H_ +#define _LIBCRYPTO_HMAC_H_ + +#ifdef _MSC_VER +#include <../include/openssl/hmac.h> +#else +#include_next +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(HMAC_CTX_new); +LCRYPTO_USED(HMAC_CTX_free); +LCRYPTO_UNUSED(HMAC_CTX_reset); +LCRYPTO_UNUSED(HMAC_Init); +LCRYPTO_USED(HMAC_Init_ex); +LCRYPTO_USED(HMAC_Update); +LCRYPTO_USED(HMAC_Final); +LCRYPTO_USED(HMAC); +LCRYPTO_USED(HMAC_CTX_copy); +LCRYPTO_USED(HMAC_CTX_set_flags); +LCRYPTO_USED(HMAC_CTX_get_md); + +#endif /* _LIBCRYPTO_HMAC_H_ */ diff --git a/crypto/hidden/openssl/pkcs12.h b/crypto/hidden/openssl/pkcs12.h new file mode 100644 index 00000000..94078435 --- /dev/null +++ b/crypto/hidden/openssl/pkcs12.h @@ -0,0 +1,106 @@ +/* $OpenBSD: pkcs12.h,v 1.1 2022/11/12 13:03:28 beck Exp $ */ +/* + * Copyright (c) 2022 Bob Beck + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_PKCS12_H +#define _LIBCRYPTO_PKCS12_H + +#ifdef _MSC_VER +#include <../include/openssl/pkcs12.h> +#else +#include_next +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(PKCS12_SAFEBAG_get0_attr); +LCRYPTO_USED(PKCS12_SAFEBAG_get0_attrs); +LCRYPTO_USED(PKCS12_SAFEBAG_get_nid); +LCRYPTO_USED(PKCS12_SAFEBAG_get_bag_nid); +LCRYPTO_USED(PKCS12_SAFEBAG_get1_cert); +LCRYPTO_USED(PKCS12_SAFEBAG_get1_crl); +LCRYPTO_USED(PKCS8_get_attr); +LCRYPTO_USED(PKCS12_mac_present); +LCRYPTO_USED(PKCS12_get0_mac); +LCRYPTO_USED(PKCS12_SAFEBAG_create_cert); +LCRYPTO_USED(PKCS12_SAFEBAG_create_crl); +LCRYPTO_USED(PKCS12_SAFEBAG_create0_p8inf); +LCRYPTO_USED(PKCS12_SAFEBAG_create0_pkcs8); +LCRYPTO_USED(PKCS12_SAFEBAG_create_pkcs8_encrypt); +LCRYPTO_USED(PKCS12_SAFEBAG_get0_p8inf); +LCRYPTO_USED(PKCS12_SAFEBAG_get0_pkcs8); +LCRYPTO_USED(PKCS12_SAFEBAG_get0_safes); +LCRYPTO_USED(PKCS12_SAFEBAG_get0_type); +LCRYPTO_USED(PKCS12_item_pack_safebag); +LCRYPTO_USED(PKCS8_decrypt); +LCRYPTO_USED(PKCS12_decrypt_skey); +LCRYPTO_USED(PKCS8_encrypt); +LCRYPTO_USED(PKCS12_pack_p7data); +LCRYPTO_USED(PKCS12_unpack_p7data); +LCRYPTO_USED(PKCS12_pack_p7encdata); +LCRYPTO_USED(PKCS12_unpack_p7encdata); +LCRYPTO_USED(PKCS12_pack_authsafes); +LCRYPTO_USED(PKCS12_unpack_authsafes); +LCRYPTO_USED(PKCS12_add_localkeyid); +LCRYPTO_USED(PKCS12_add_friendlyname_asc); +LCRYPTO_USED(PKCS12_add_CSPName_asc); +LCRYPTO_USED(PKCS12_add_friendlyname_uni); +LCRYPTO_USED(PKCS8_add_keyusage); +LCRYPTO_USED(PKCS12_get_attr_gen); +LCRYPTO_USED(PKCS12_get_friendlyname); +LCRYPTO_USED(PKCS12_pbe_crypt); +LCRYPTO_USED(PKCS12_item_decrypt_d2i); +LCRYPTO_USED(PKCS12_item_i2d_encrypt); +LCRYPTO_USED(PKCS12_init); +LCRYPTO_USED(PKCS12_key_gen_asc); +LCRYPTO_USED(PKCS12_key_gen_uni); +LCRYPTO_USED(PKCS12_PBE_keyivgen); +LCRYPTO_USED(PKCS12_gen_mac); +LCRYPTO_USED(PKCS12_verify_mac); +LCRYPTO_USED(PKCS12_set_mac); +LCRYPTO_USED(PKCS12_setup_mac); +LCRYPTO_USED(OPENSSL_asc2uni); +LCRYPTO_USED(OPENSSL_uni2asc); +LCRYPTO_USED(PKCS12_new); +LCRYPTO_USED(PKCS12_free); +LCRYPTO_USED(d2i_PKCS12); +LCRYPTO_USED(i2d_PKCS12); +LCRYPTO_USED(PKCS12_MAC_DATA_new); +LCRYPTO_USED(PKCS12_MAC_DATA_free); +LCRYPTO_USED(d2i_PKCS12_MAC_DATA); +LCRYPTO_USED(i2d_PKCS12_MAC_DATA); +LCRYPTO_USED(PKCS12_SAFEBAG_new); +LCRYPTO_USED(PKCS12_SAFEBAG_free); +LCRYPTO_USED(d2i_PKCS12_SAFEBAG); +LCRYPTO_USED(i2d_PKCS12_SAFEBAG); +LCRYPTO_USED(PKCS12_BAGS_new); +LCRYPTO_USED(PKCS12_BAGS_free); +LCRYPTO_USED(d2i_PKCS12_BAGS); +LCRYPTO_USED(i2d_PKCS12_BAGS); +LCRYPTO_USED(PKCS12_PBE_add); +LCRYPTO_USED(PKCS12_parse); +LCRYPTO_USED(PKCS12_create); +LCRYPTO_USED(PKCS12_add_cert); +LCRYPTO_USED(PKCS12_add_key); +LCRYPTO_USED(PKCS12_add_safe); +LCRYPTO_USED(PKCS12_add_safes); +LCRYPTO_USED(i2d_PKCS12_bio); +LCRYPTO_USED(i2d_PKCS12_fp); +LCRYPTO_USED(d2i_PKCS12_bio); +LCRYPTO_USED(d2i_PKCS12_fp); +LCRYPTO_USED(PKCS12_newpass); +LCRYPTO_USED(ERR_load_PKCS12_strings); + +#endif /* _LIBCRYPTO_PKCS12_H */ diff --git a/crypto/hidden/openssl/pkcs7.h b/crypto/hidden/openssl/pkcs7.h new file mode 100644 index 00000000..2ef008d2 --- /dev/null +++ b/crypto/hidden/openssl/pkcs7.h @@ -0,0 +1,130 @@ +/* $OpenBSD: pkcs7.h,v 1.1 2022/11/12 12:11:14 beck Exp $ */ +/* + * Copyright (c) 2022 Bob Beck + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_PKCS7_H +#define _LIBCRYPTO_PKCS7_H + +#ifdef _MSC_VER +#include <../include/openssl/pkcs7.h> +#else +#include_next +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(PKCS7_ISSUER_AND_SERIAL_new); +LCRYPTO_USED(PKCS7_ISSUER_AND_SERIAL_free); +LCRYPTO_USED(d2i_PKCS7_ISSUER_AND_SERIAL); +LCRYPTO_USED(i2d_PKCS7_ISSUER_AND_SERIAL); +LCRYPTO_USED(PKCS7_ISSUER_AND_SERIAL_digest); +LCRYPTO_USED(d2i_PKCS7_fp); +LCRYPTO_USED(i2d_PKCS7_fp); +LCRYPTO_USED(PKCS7_dup); +LCRYPTO_USED(d2i_PKCS7_bio); +LCRYPTO_USED(i2d_PKCS7_bio); +LCRYPTO_USED(i2d_PKCS7_bio_stream); +LCRYPTO_USED(PEM_write_bio_PKCS7_stream); +LCRYPTO_USED(PKCS7_SIGNER_INFO_new); +LCRYPTO_USED(PKCS7_SIGNER_INFO_free); +LCRYPTO_USED(d2i_PKCS7_SIGNER_INFO); +LCRYPTO_USED(i2d_PKCS7_SIGNER_INFO); +LCRYPTO_USED(PKCS7_RECIP_INFO_new); +LCRYPTO_USED(PKCS7_RECIP_INFO_free); +LCRYPTO_USED(d2i_PKCS7_RECIP_INFO); +LCRYPTO_USED(i2d_PKCS7_RECIP_INFO); +LCRYPTO_USED(PKCS7_SIGNED_new); +LCRYPTO_USED(PKCS7_SIGNED_free); +LCRYPTO_USED(d2i_PKCS7_SIGNED); +LCRYPTO_USED(i2d_PKCS7_SIGNED); +LCRYPTO_USED(PKCS7_ENC_CONTENT_new); +LCRYPTO_USED(PKCS7_ENC_CONTENT_free); +LCRYPTO_USED(d2i_PKCS7_ENC_CONTENT); +LCRYPTO_USED(i2d_PKCS7_ENC_CONTENT); +LCRYPTO_USED(PKCS7_ENVELOPE_new); +LCRYPTO_USED(PKCS7_ENVELOPE_free); +LCRYPTO_USED(d2i_PKCS7_ENVELOPE); +LCRYPTO_USED(i2d_PKCS7_ENVELOPE); +LCRYPTO_USED(PKCS7_SIGN_ENVELOPE_new); +LCRYPTO_USED(PKCS7_SIGN_ENVELOPE_free); +LCRYPTO_USED(d2i_PKCS7_SIGN_ENVELOPE); +LCRYPTO_USED(i2d_PKCS7_SIGN_ENVELOPE); +LCRYPTO_USED(PKCS7_DIGEST_new); +LCRYPTO_USED(PKCS7_DIGEST_free); +LCRYPTO_USED(d2i_PKCS7_DIGEST); +LCRYPTO_USED(i2d_PKCS7_DIGEST); +LCRYPTO_USED(PKCS7_ENCRYPT_new); +LCRYPTO_USED(PKCS7_ENCRYPT_free); +LCRYPTO_USED(d2i_PKCS7_ENCRYPT); +LCRYPTO_USED(i2d_PKCS7_ENCRYPT); +LCRYPTO_USED(PKCS7_new); +LCRYPTO_USED(PKCS7_free); +LCRYPTO_USED(d2i_PKCS7); +LCRYPTO_USED(i2d_PKCS7); +LCRYPTO_USED(i2d_PKCS7_NDEF); +LCRYPTO_USED(PKCS7_print_ctx); +LCRYPTO_USED(PKCS7_ctrl); +LCRYPTO_USED(PKCS7_set_type); +LCRYPTO_USED(PKCS7_set0_type_other); +LCRYPTO_USED(PKCS7_set_content); +LCRYPTO_USED(PKCS7_SIGNER_INFO_set); +LCRYPTO_USED(PKCS7_SIGNER_INFO_sign); +LCRYPTO_USED(PKCS7_add_signer); +LCRYPTO_USED(PKCS7_add_certificate); +LCRYPTO_USED(PKCS7_add_crl); +LCRYPTO_USED(PKCS7_content_new); +LCRYPTO_USED(PKCS7_dataVerify); +LCRYPTO_USED(PKCS7_signatureVerify); +LCRYPTO_USED(PKCS7_dataInit); +LCRYPTO_USED(PKCS7_dataFinal); +LCRYPTO_USED(PKCS7_dataDecode); +LCRYPTO_USED(PKCS7_add_signature); +LCRYPTO_USED(PKCS7_cert_from_signer_info); +LCRYPTO_USED(PKCS7_set_digest); +LCRYPTO_USED(PKCS7_get_signer_info); +LCRYPTO_USED(PKCS7_add_recipient); +LCRYPTO_USED(PKCS7_SIGNER_INFO_get0_algs); +LCRYPTO_USED(PKCS7_RECIP_INFO_get0_alg); +LCRYPTO_USED(PKCS7_add_recipient_info); +LCRYPTO_USED(PKCS7_RECIP_INFO_set); +LCRYPTO_USED(PKCS7_set_cipher); +LCRYPTO_USED(PKCS7_stream); +LCRYPTO_USED(PKCS7_get_issuer_and_serial); +LCRYPTO_USED(PKCS7_digest_from_attributes); +LCRYPTO_USED(PKCS7_add_signed_attribute); +LCRYPTO_USED(PKCS7_add_attribute); +LCRYPTO_USED(PKCS7_get_attribute); +LCRYPTO_USED(PKCS7_get_signed_attribute); +LCRYPTO_USED(PKCS7_set_signed_attributes); +LCRYPTO_USED(PKCS7_set_attributes); +LCRYPTO_USED(PKCS7_sign); +LCRYPTO_USED(PKCS7_sign_add_signer); +LCRYPTO_USED(PKCS7_final); +LCRYPTO_USED(PKCS7_verify); +LCRYPTO_USED(PKCS7_get0_signers); +LCRYPTO_USED(PKCS7_encrypt); +LCRYPTO_USED(PKCS7_decrypt); +LCRYPTO_USED(PKCS7_add_attrib_smimecap); +LCRYPTO_USED(PKCS7_get_smimecap); +LCRYPTO_USED(PKCS7_simple_smimecap); +LCRYPTO_USED(PKCS7_add_attrib_content_type); +LCRYPTO_USED(PKCS7_add0_attrib_signing_time); +LCRYPTO_USED(PKCS7_add1_attrib_digest); +LCRYPTO_USED(SMIME_write_PKCS7); +LCRYPTO_USED(SMIME_read_PKCS7); +LCRYPTO_USED(BIO_new_PKCS7); +LCRYPTO_USED(ERR_load_PKCS7_strings); + +#endif /* _LIBCRYPTO_PKCS7_H */ diff --git a/crypto/hidden/openssl/stack.h b/crypto/hidden/openssl/stack.h new file mode 100644 index 00000000..a1674fec --- /dev/null +++ b/crypto/hidden/openssl/stack.h @@ -0,0 +1,50 @@ +/* $OpenBSD: stack.h,v 1.1 2022/11/11 19:18:55 beck Exp $ */ +/* + * Copyright (c) 2022 Bob Beck + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_STACK_H +#define _LIBCRYPTO_STACK_H + +#ifdef _MSC_VER +#include <../include/openssl/stack.h> +#else +#include_next +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(sk_num); +LCRYPTO_USED(sk_value); +LCRYPTO_USED(sk_set); +LCRYPTO_USED(sk_new); +LCRYPTO_USED(sk_new_null); +LCRYPTO_USED(sk_free); +LCRYPTO_USED(sk_pop_free); +LCRYPTO_USED(sk_insert); +LCRYPTO_USED(sk_delete); +LCRYPTO_USED(sk_delete_ptr); +LCRYPTO_USED(sk_find); +LCRYPTO_USED(sk_find_ex); +LCRYPTO_USED(sk_push); +LCRYPTO_USED(sk_unshift); +LCRYPTO_USED(sk_shift); +LCRYPTO_USED(sk_pop); +LCRYPTO_USED(sk_zero); +LCRYPTO_USED(sk_set_cmp_func); +LCRYPTO_USED(sk_dup); +LCRYPTO_USED(sk_sort); +LCRYPTO_USED(sk_is_sorted); + +#endif /* _LIBCRYPTO_STACK_H */ diff --git a/crypto/hidden/openssl/ui.h b/crypto/hidden/openssl/ui.h new file mode 100644 index 00000000..ee13b0a6 --- /dev/null +++ b/crypto/hidden/openssl/ui.h @@ -0,0 +1,83 @@ +/* $OpenBSD: ui.h,v 1.2 2022/12/17 21:59:39 tb Exp $ */ +/* + * Copyright (c) 2022 Bob Beck + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_UI_H +#define _LIBCRYPTO_UI_H + +#ifdef _MSC_VER +#include <../include/openssl/ui.h> +#else +#include_next +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(UI_new); +LCRYPTO_USED(UI_new_method); +LCRYPTO_USED(UI_free); +LCRYPTO_USED(UI_add_input_string); +LCRYPTO_USED(UI_dup_input_string); +LCRYPTO_USED(UI_add_verify_string); +LCRYPTO_USED(UI_dup_verify_string); +LCRYPTO_USED(UI_add_input_boolean); +LCRYPTO_USED(UI_dup_input_boolean); +LCRYPTO_USED(UI_add_info_string); +LCRYPTO_USED(UI_dup_info_string); +LCRYPTO_USED(UI_add_error_string); +LCRYPTO_USED(UI_dup_error_string); +LCRYPTO_USED(UI_construct_prompt); +LCRYPTO_USED(UI_add_user_data); +LCRYPTO_USED(UI_get0_user_data); +LCRYPTO_USED(UI_get0_result); +LCRYPTO_USED(UI_process); +LCRYPTO_USED(UI_ctrl); +LCRYPTO_USED(UI_get_ex_new_index); +LCRYPTO_USED(UI_set_ex_data); +LCRYPTO_USED(UI_get_ex_data); +LCRYPTO_USED(UI_set_default_method); +LCRYPTO_USED(UI_get_default_method); +LCRYPTO_USED(UI_get_method); +LCRYPTO_USED(UI_set_method); +LCRYPTO_USED(UI_OpenSSL); +LCRYPTO_USED(UI_null); +LCRYPTO_USED(UI_create_method); +LCRYPTO_USED(UI_destroy_method); +LCRYPTO_USED(UI_method_set_opener); +LCRYPTO_USED(UI_method_set_writer); +LCRYPTO_USED(UI_method_set_flusher); +LCRYPTO_USED(UI_method_set_reader); +LCRYPTO_USED(UI_method_set_closer); +LCRYPTO_USED(UI_method_set_prompt_constructor); +LCRYPTO_USED(UI_method_get_opener); +LCRYPTO_USED(UI_method_get_writer); +LCRYPTO_USED(UI_method_get_flusher); +LCRYPTO_USED(UI_method_get_reader); +LCRYPTO_USED(UI_method_get_closer); +LCRYPTO_USED(UI_get_string_type); +LCRYPTO_USED(UI_get_input_flags); +LCRYPTO_USED(UI_get0_output_string); +LCRYPTO_USED(UI_get0_action_string); +LCRYPTO_USED(UI_get0_result_string); +LCRYPTO_USED(UI_get0_test_string); +LCRYPTO_USED(UI_get_result_minsize); +LCRYPTO_USED(UI_get_result_maxsize); +LCRYPTO_USED(UI_set_result); +LCRYPTO_USED(UI_UTIL_read_pw_string); +LCRYPTO_USED(UI_UTIL_read_pw); +LCRYPTO_USED(ERR_load_UI_strings); +LCRYPTO_USED(UI_method_get_prompt_constructor); + +#endif /* _LIBCRYPTO_UI_H */ diff --git a/crypto/hidden/openssl/x509.h b/crypto/hidden/openssl/x509.h new file mode 100644 index 00000000..bbc28af0 --- /dev/null +++ b/crypto/hidden/openssl/x509.h @@ -0,0 +1,283 @@ +/* $OpenBSD: x509.h,v 1.2 2023/02/23 18:12:32 job Exp $ */ +/* + * Copyright (c) 2022 Bob Beck + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_X509_H +#define _LIBCRYPTO_X509_H + +#ifdef _MSC_VER +#include <../include/openssl/x509.h> +#else +#include_next +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(X509_CRL_up_ref); +LCRYPTO_USED(i2d_re_X509_CRL_tbs); +LCRYPTO_USED(X509_get_X509_PUBKEY); +LCRYPTO_USED(X509_verify_cert_error_string); +LCRYPTO_USED(X509_verify); +LCRYPTO_USED(X509_REQ_verify); +LCRYPTO_USED(NETSCAPE_SPKI_verify); +LCRYPTO_USED(NETSCAPE_SPKI_b64_decode); +LCRYPTO_USED(NETSCAPE_SPKI_b64_encode); +LCRYPTO_USED(NETSCAPE_SPKI_get_pubkey); +LCRYPTO_USED(NETSCAPE_SPKI_set_pubkey); +LCRYPTO_USED(X509_sign); +LCRYPTO_USED(X509_sign_ctx); +LCRYPTO_USED(X509_REQ_sign); +LCRYPTO_USED(X509_REQ_sign_ctx); +LCRYPTO_USED(X509_CRL_sign); +LCRYPTO_USED(X509_CRL_sign_ctx); +LCRYPTO_USED(NETSCAPE_SPKI_sign); +LCRYPTO_USED(X509_pubkey_digest); +LCRYPTO_USED(X509_digest); +LCRYPTO_USED(X509_CRL_digest); +LCRYPTO_USED(X509_REQ_digest); +LCRYPTO_USED(X509_NAME_digest); +LCRYPTO_USED(d2i_X509_fp); +LCRYPTO_USED(i2d_X509_fp); +LCRYPTO_USED(d2i_X509_CRL_fp); +LCRYPTO_USED(i2d_X509_CRL_fp); +LCRYPTO_USED(d2i_X509_REQ_fp); +LCRYPTO_USED(i2d_X509_REQ_fp); +LCRYPTO_USED(d2i_RSAPrivateKey_fp); +LCRYPTO_USED(i2d_RSAPrivateKey_fp); +LCRYPTO_USED(d2i_RSAPublicKey_fp); +LCRYPTO_USED(i2d_RSAPublicKey_fp); +LCRYPTO_USED(d2i_DSAPrivateKey_fp); +LCRYPTO_USED(i2d_DSAPrivateKey_fp); +LCRYPTO_USED(d2i_ECPrivateKey_fp); +LCRYPTO_USED(i2d_ECPrivateKey_fp); +LCRYPTO_USED(d2i_PKCS8_fp); +LCRYPTO_USED(i2d_PKCS8_fp); +LCRYPTO_USED(d2i_PKCS8_PRIV_KEY_INFO_fp); +LCRYPTO_USED(i2d_PKCS8_PRIV_KEY_INFO_fp); +LCRYPTO_USED(i2d_PKCS8PrivateKeyInfo_fp); +LCRYPTO_USED(i2d_PrivateKey_fp); +LCRYPTO_USED(d2i_PrivateKey_fp); +LCRYPTO_USED(d2i_X509_bio); +LCRYPTO_USED(i2d_X509_bio); +LCRYPTO_USED(d2i_X509_CRL_bio); +LCRYPTO_USED(i2d_X509_CRL_bio); +LCRYPTO_USED(d2i_X509_REQ_bio); +LCRYPTO_USED(i2d_X509_REQ_bio); +LCRYPTO_USED(d2i_RSAPrivateKey_bio); +LCRYPTO_USED(i2d_RSAPrivateKey_bio); +LCRYPTO_USED(d2i_RSAPublicKey_bio); +LCRYPTO_USED(i2d_RSAPublicKey_bio); +LCRYPTO_USED(d2i_DSAPrivateKey_bio); +LCRYPTO_USED(i2d_DSAPrivateKey_bio); +LCRYPTO_USED(d2i_ECPrivateKey_bio); +LCRYPTO_USED(i2d_ECPrivateKey_bio); +LCRYPTO_USED(d2i_PKCS8_bio); +LCRYPTO_USED(i2d_PKCS8_bio); +LCRYPTO_USED(d2i_PKCS8_PRIV_KEY_INFO_bio); +LCRYPTO_USED(i2d_PKCS8_PRIV_KEY_INFO_bio); +LCRYPTO_USED(i2d_PKCS8PrivateKeyInfo_bio); +LCRYPTO_USED(i2d_PrivateKey_bio); +LCRYPTO_USED(d2i_PrivateKey_bio); +LCRYPTO_USED(X509_cmp_time); +LCRYPTO_USED(X509_cmp_current_time); +LCRYPTO_USED(X509_time_adj); +LCRYPTO_USED(X509_time_adj_ex); +LCRYPTO_USED(X509_gmtime_adj); +LCRYPTO_USED(X509_get_default_cert_area); +LCRYPTO_USED(X509_get_default_cert_dir); +LCRYPTO_USED(X509_get_default_cert_file); +LCRYPTO_USED(X509_get_default_cert_dir_env); +LCRYPTO_USED(X509_get_default_cert_file_env); +LCRYPTO_USED(X509_get_default_private_dir); +LCRYPTO_USED(X509_to_X509_REQ); +LCRYPTO_USED(X509_REQ_to_X509); +LCRYPTO_USED(X509_get_pubkey_parameters); +LCRYPTO_USED(X509_TRUST_set_default); +LCRYPTO_USED(X509_TRUST_set); +LCRYPTO_USED(X509_NAME_oneline); +LCRYPTO_USED(X509_get0_extensions); +LCRYPTO_USED(X509_get0_tbs_sigalg); +LCRYPTO_USED(X509_get0_uids); +LCRYPTO_USED(X509_set_version); +LCRYPTO_USED(X509_get_version); +LCRYPTO_USED(X509_set_serialNumber); +LCRYPTO_USED(X509_get_serialNumber); +LCRYPTO_USED(X509_get0_serialNumber); +LCRYPTO_USED(X509_set_issuer_name); +LCRYPTO_USED(X509_get_issuer_name); +LCRYPTO_USED(X509_set_subject_name); +LCRYPTO_USED(X509_get_subject_name); +LCRYPTO_USED(X509_set_notBefore); +LCRYPTO_USED(X509_set1_notBefore); +LCRYPTO_USED(X509_set_notAfter); +LCRYPTO_USED(X509_set1_notAfter); +LCRYPTO_USED(X509_get0_notBefore); +LCRYPTO_USED(X509_getm_notBefore); +LCRYPTO_USED(X509_get0_notAfter); +LCRYPTO_USED(X509_getm_notAfter); +LCRYPTO_USED(X509_set_pubkey); +LCRYPTO_USED(X509_get_pubkey); +LCRYPTO_USED(X509_get0_pubkey); +LCRYPTO_USED(X509_get0_pubkey_bitstr); +LCRYPTO_USED(X509_certificate_type); +LCRYPTO_USED(X509_get_signature_type); +LCRYPTO_USED(X509_REQ_set_version); +LCRYPTO_USED(X509_REQ_get_version); +LCRYPTO_USED(X509_REQ_set_subject_name); +LCRYPTO_USED(X509_REQ_get_subject_name); +LCRYPTO_USED(X509_REQ_set_pubkey); +LCRYPTO_USED(X509_REQ_get_pubkey); +LCRYPTO_USED(i2d_re_X509_REQ_tbs); +LCRYPTO_USED(X509_REQ_get0_pubkey); +LCRYPTO_USED(X509_REQ_extension_nid); +LCRYPTO_USED(X509_REQ_get_extension_nids); +LCRYPTO_USED(X509_REQ_set_extension_nids); +LCRYPTO_USED(X509_REQ_get_extensions); +LCRYPTO_USED(X509_REQ_add_extensions_nid); +LCRYPTO_USED(X509_REQ_add_extensions); +LCRYPTO_USED(X509_REQ_get_attr_count); +LCRYPTO_USED(X509_REQ_get_attr_by_NID); +LCRYPTO_USED(X509_REQ_get_attr_by_OBJ); +LCRYPTO_USED(X509_REQ_get_attr); +LCRYPTO_USED(X509_REQ_delete_attr); +LCRYPTO_USED(X509_REQ_add1_attr); +LCRYPTO_USED(X509_REQ_add1_attr_by_OBJ); +LCRYPTO_USED(X509_REQ_add1_attr_by_NID); +LCRYPTO_USED(X509_REQ_add1_attr_by_txt); +LCRYPTO_USED(X509_CRL_set_version); +LCRYPTO_USED(X509_CRL_set_issuer_name); +LCRYPTO_USED(X509_CRL_set_lastUpdate); +LCRYPTO_USED(X509_CRL_set1_lastUpdate); +LCRYPTO_USED(X509_CRL_set_nextUpdate); +LCRYPTO_USED(X509_CRL_set1_nextUpdate); +LCRYPTO_USED(X509_CRL_sort); +LCRYPTO_USED(X509_REVOKED_get0_extensions); +LCRYPTO_USED(X509_REVOKED_get0_revocationDate); +LCRYPTO_USED(X509_REVOKED_get0_serialNumber); +LCRYPTO_USED(X509_REVOKED_set_revocationDate); +LCRYPTO_USED(X509_REVOKED_set_serialNumber); +LCRYPTO_USED(X509_REQ_check_private_key); +LCRYPTO_USED(X509_check_private_key); +LCRYPTO_USED(X509_issuer_and_serial_cmp); +LCRYPTO_USED(X509_issuer_and_serial_hash); +LCRYPTO_USED(X509_issuer_name_cmp); +LCRYPTO_USED(X509_issuer_name_hash); +LCRYPTO_USED(X509_subject_name_cmp); +LCRYPTO_USED(X509_subject_name_hash); +LCRYPTO_USED(X509_issuer_name_hash_old); +LCRYPTO_USED(X509_subject_name_hash_old); +LCRYPTO_USED(X509_cmp); +LCRYPTO_USED(X509_NAME_cmp); +LCRYPTO_USED(X509_NAME_hash); +LCRYPTO_USED(X509_NAME_hash_old); +LCRYPTO_USED(X509_CRL_cmp); +LCRYPTO_USED(X509_CRL_match); +LCRYPTO_USED(X509_NAME_entry_count); +LCRYPTO_USED(X509_NAME_get_text_by_NID); +LCRYPTO_USED(X509_NAME_get_text_by_OBJ); +LCRYPTO_USED(X509_NAME_get_index_by_NID); +LCRYPTO_USED(X509_NAME_get_index_by_OBJ); +LCRYPTO_USED(X509_NAME_get_entry); +LCRYPTO_USED(X509_NAME_delete_entry); +LCRYPTO_USED(X509_NAME_add_entry); +LCRYPTO_USED(X509_NAME_add_entry_by_OBJ); +LCRYPTO_USED(X509_NAME_add_entry_by_NID); +LCRYPTO_USED(X509_NAME_ENTRY_create_by_txt); +LCRYPTO_USED(X509_NAME_ENTRY_create_by_NID); +LCRYPTO_USED(X509_NAME_add_entry_by_txt); +LCRYPTO_USED(X509_NAME_ENTRY_create_by_OBJ); +LCRYPTO_USED(X509_NAME_ENTRY_set_object); +LCRYPTO_USED(X509_NAME_ENTRY_set_data); +LCRYPTO_USED(X509_NAME_ENTRY_get_object); +LCRYPTO_USED(X509_NAME_ENTRY_get_data); +LCRYPTO_USED(X509_NAME_ENTRY_set); +LCRYPTO_USED(X509v3_get_ext_count); +LCRYPTO_USED(X509v3_get_ext_by_NID); +LCRYPTO_USED(X509v3_get_ext_by_OBJ); +LCRYPTO_USED(X509v3_get_ext_by_critical); +LCRYPTO_USED(X509v3_get_ext); +LCRYPTO_USED(X509v3_delete_ext); +LCRYPTO_USED(X509v3_add_ext); +LCRYPTO_USED(X509_get_ext_count); +LCRYPTO_USED(X509_get_ext_by_NID); +LCRYPTO_USED(X509_get_ext_by_OBJ); +LCRYPTO_USED(X509_get_ext_by_critical); +LCRYPTO_USED(X509_get_ext); +LCRYPTO_USED(X509_delete_ext); +LCRYPTO_USED(X509_add_ext); +LCRYPTO_USED(X509_get_ext_d2i); +LCRYPTO_USED(X509_add1_ext_i2d); +LCRYPTO_USED(X509_CRL_get_ext_count); +LCRYPTO_USED(X509_CRL_get_ext_by_NID); +LCRYPTO_USED(X509_CRL_get_ext_by_OBJ); +LCRYPTO_USED(X509_CRL_get_ext_by_critical); +LCRYPTO_USED(X509_CRL_get_ext); +LCRYPTO_USED(X509_CRL_delete_ext); +LCRYPTO_USED(X509_CRL_add_ext); +LCRYPTO_USED(X509_CRL_get_ext_d2i); +LCRYPTO_USED(X509_CRL_add1_ext_i2d); +LCRYPTO_USED(X509_REVOKED_get_ext_count); +LCRYPTO_USED(X509_REVOKED_get_ext_by_NID); +LCRYPTO_USED(X509_REVOKED_get_ext_by_OBJ); +LCRYPTO_USED(X509_REVOKED_get_ext_by_critical); +LCRYPTO_USED(X509_REVOKED_get_ext); +LCRYPTO_USED(X509_REVOKED_delete_ext); +LCRYPTO_USED(X509_REVOKED_add_ext); +LCRYPTO_USED(X509_REVOKED_get_ext_d2i); +LCRYPTO_USED(X509_REVOKED_add1_ext_i2d); +LCRYPTO_USED(X509_EXTENSION_create_by_NID); +LCRYPTO_USED(X509_EXTENSION_create_by_OBJ); +LCRYPTO_USED(X509_EXTENSION_set_object); +LCRYPTO_USED(X509_EXTENSION_set_critical); +LCRYPTO_USED(X509_EXTENSION_set_data); +LCRYPTO_USED(X509_EXTENSION_get_object); +LCRYPTO_USED(X509_EXTENSION_get_data); +LCRYPTO_USED(X509_EXTENSION_get_critical); +LCRYPTO_USED(X509at_get_attr_count); +LCRYPTO_USED(X509at_get_attr_by_NID); +LCRYPTO_USED(X509at_get_attr_by_OBJ); +LCRYPTO_USED(X509at_get_attr); +LCRYPTO_USED(X509at_delete_attr); +LCRYPTO_USED(X509at_add1_attr); +LCRYPTO_USED(X509at_add1_attr_by_OBJ); +LCRYPTO_USED(X509at_add1_attr_by_NID); +LCRYPTO_USED(X509at_add1_attr_by_txt); +LCRYPTO_USED(X509at_get0_data_by_OBJ); +LCRYPTO_USED(X509_ATTRIBUTE_create_by_NID); +LCRYPTO_USED(X509_ATTRIBUTE_create_by_OBJ); +LCRYPTO_USED(X509_ATTRIBUTE_create_by_txt); +LCRYPTO_USED(X509_ATTRIBUTE_set1_object); +LCRYPTO_USED(X509_ATTRIBUTE_set1_data); +LCRYPTO_USED(X509_ATTRIBUTE_get0_data); +LCRYPTO_USED(X509_ATTRIBUTE_count); +LCRYPTO_USED(X509_ATTRIBUTE_get0_object); +LCRYPTO_USED(X509_ATTRIBUTE_get0_type); +LCRYPTO_USED(X509_verify_cert); +LCRYPTO_USED(X509_find_by_issuer_and_serial); +LCRYPTO_USED(X509_find_by_subject); +LCRYPTO_USED(X509_check_trust); +LCRYPTO_USED(X509_TRUST_get_count); +LCRYPTO_USED(X509_TRUST_get0); +LCRYPTO_USED(X509_TRUST_get_by_id); +LCRYPTO_USED(X509_TRUST_add); +LCRYPTO_USED(X509_TRUST_cleanup); +LCRYPTO_USED(X509_TRUST_get_flags); +LCRYPTO_USED(X509_TRUST_get0_name); +LCRYPTO_USED(X509_TRUST_get_trust); +LCRYPTO_USED(X509_up_ref); +LCRYPTO_USED(X509_chain_up_ref); +LCRYPTO_USED(ERR_load_X509_strings); + +#endif /* _LIBCRYPTO_X509_H */ diff --git a/crypto/hidden/openssl/x509_vfy.h b/crypto/hidden/openssl/x509_vfy.h new file mode 100644 index 00000000..783cd9d4 --- /dev/null +++ b/crypto/hidden/openssl/x509_vfy.h @@ -0,0 +1,169 @@ +/* $OpenBSD: x509_vfy.h,v 1.2 2022/12/01 05:16:08 tb Exp $ */ +/* + * Copyright (c) 2022 Bob Beck + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_X509_VFY_H +#define _LIBCRYPTO_X509_VFY_H + +#ifdef _MSC_VER +#include <../include/openssl/x509_vfy.h> +#else +#include_next +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(X509_STORE_set_depth); +LCRYPTO_USED(X509_STORE_CTX_set_depth); +LCRYPTO_USED(X509_OBJECT_new); +LCRYPTO_USED(X509_OBJECT_free); +LCRYPTO_USED(X509_OBJECT_idx_by_subject); +LCRYPTO_USED(X509_OBJECT_retrieve_by_subject); +LCRYPTO_USED(X509_OBJECT_retrieve_match); +LCRYPTO_USED(X509_OBJECT_up_ref_count); +LCRYPTO_USED(X509_OBJECT_get_type); +LCRYPTO_USED(X509_OBJECT_get0_X509); +LCRYPTO_USED(X509_OBJECT_get0_X509_CRL); +LCRYPTO_USED(X509_STORE_new); +LCRYPTO_USED(X509_STORE_free); +LCRYPTO_USED(X509_STORE_up_ref); +LCRYPTO_USED(X509_STORE_get1_certs); +LCRYPTO_USED(X509_STORE_get1_crls); +LCRYPTO_USED(X509_STORE_get0_objects); +LCRYPTO_USED(X509_STORE_get_ex_data); +LCRYPTO_USED(X509_STORE_set_ex_data); +LCRYPTO_USED(X509_STORE_set_flags); +LCRYPTO_USED(X509_STORE_set_purpose); +LCRYPTO_USED(X509_STORE_set_trust); +LCRYPTO_USED(X509_STORE_set1_param); +LCRYPTO_USED(X509_STORE_get0_param); +LCRYPTO_USED(X509_STORE_get_verify_cb); +LCRYPTO_USED(X509_STORE_set_verify_cb); +LCRYPTO_USED(X509_STORE_get_check_issued); +LCRYPTO_USED(X509_STORE_set_check_issued); +LCRYPTO_USED(X509_STORE_CTX_get_check_issued); +LCRYPTO_USED(X509_STORE_CTX_new); +LCRYPTO_USED(X509_STORE_CTX_get1_issuer); +LCRYPTO_USED(X509_STORE_CTX_free); +LCRYPTO_USED(X509_STORE_CTX_init); +LCRYPTO_USED(X509_STORE_CTX_get0_cert); +LCRYPTO_USED(X509_STORE_CTX_get0_chain); +LCRYPTO_USED(X509_STORE_CTX_get0_store); +LCRYPTO_USED(X509_STORE_CTX_get0_untrusted); +LCRYPTO_USED(X509_STORE_CTX_set0_untrusted); +LCRYPTO_USED(X509_STORE_CTX_trusted_stack); +LCRYPTO_USED(X509_STORE_CTX_set0_trusted_stack); +LCRYPTO_USED(X509_STORE_CTX_cleanup); +LCRYPTO_USED(X509_STORE_add_lookup); +LCRYPTO_USED(X509_LOOKUP_hash_dir); +LCRYPTO_USED(X509_LOOKUP_file); +LCRYPTO_USED(X509_LOOKUP_mem); +LCRYPTO_USED(X509_STORE_add_cert); +LCRYPTO_USED(X509_STORE_add_crl); +LCRYPTO_USED(X509_STORE_CTX_get_by_subject); +LCRYPTO_USED(X509_STORE_CTX_get_obj_by_subject); +LCRYPTO_USED(X509_LOOKUP_ctrl); +LCRYPTO_USED(X509_load_cert_file); +LCRYPTO_USED(X509_load_crl_file); +LCRYPTO_USED(X509_load_cert_crl_file); +LCRYPTO_USED(X509_LOOKUP_new); +LCRYPTO_USED(X509_LOOKUP_free); +LCRYPTO_USED(X509_LOOKUP_init); +LCRYPTO_USED(X509_LOOKUP_by_subject); +LCRYPTO_USED(X509_LOOKUP_by_issuer_serial); +LCRYPTO_USED(X509_LOOKUP_by_fingerprint); +LCRYPTO_USED(X509_LOOKUP_by_alias); +LCRYPTO_USED(X509_LOOKUP_shutdown); +LCRYPTO_USED(X509_STORE_load_locations); +LCRYPTO_USED(X509_STORE_load_mem); +LCRYPTO_USED(X509_STORE_set_default_paths); +LCRYPTO_USED(X509_STORE_CTX_get_ex_new_index); +LCRYPTO_USED(X509_STORE_CTX_set_ex_data); +LCRYPTO_USED(X509_STORE_CTX_get_ex_data); +LCRYPTO_USED(X509_STORE_CTX_get_error); +LCRYPTO_USED(X509_STORE_CTX_set_error); +LCRYPTO_USED(X509_STORE_CTX_get_error_depth); +LCRYPTO_USED(X509_STORE_CTX_set_error_depth); +LCRYPTO_USED(X509_STORE_CTX_get_current_cert); +LCRYPTO_USED(X509_STORE_CTX_set_current_cert); +LCRYPTO_USED(X509_STORE_CTX_get0_current_issuer); +LCRYPTO_USED(X509_STORE_CTX_get0_current_crl); +LCRYPTO_USED(X509_STORE_CTX_get0_parent_ctx); +LCRYPTO_USED(X509_STORE_CTX_get_chain); +LCRYPTO_USED(X509_STORE_CTX_get1_chain); +LCRYPTO_USED(X509_STORE_CTX_set_cert); +LCRYPTO_USED(X509_STORE_CTX_set_chain); +LCRYPTO_USED(X509_STORE_CTX_set0_crls); +LCRYPTO_USED(X509_STORE_CTX_set_purpose); +LCRYPTO_USED(X509_STORE_CTX_set_trust); +LCRYPTO_USED(X509_STORE_CTX_purpose_inherit); +LCRYPTO_USED(X509_STORE_CTX_set_flags); +LCRYPTO_USED(X509_STORE_CTX_set_time); +LCRYPTO_USED(X509_STORE_CTX_set0_verified_chain); +LCRYPTO_USED(X509_STORE_CTX_get_verify); +LCRYPTO_USED(X509_STORE_CTX_set_verify); +LCRYPTO_USED(X509_STORE_CTX_get_verify_cb); +LCRYPTO_USED(X509_STORE_CTX_set_verify_cb); +LCRYPTO_USED(X509_STORE_set_verify); +LCRYPTO_USED(X509_STORE_get_verify); +LCRYPTO_USED(X509_STORE_CTX_get0_policy_tree); +LCRYPTO_USED(X509_STORE_CTX_get_explicit_policy); +LCRYPTO_USED(X509_STORE_CTX_get_num_untrusted); +LCRYPTO_USED(X509_STORE_CTX_get0_param); +LCRYPTO_USED(X509_STORE_CTX_set0_param); +LCRYPTO_USED(X509_STORE_CTX_set_default); +LCRYPTO_USED(X509_VERIFY_PARAM_new); +LCRYPTO_USED(X509_VERIFY_PARAM_free); +LCRYPTO_USED(X509_VERIFY_PARAM_inherit); +LCRYPTO_USED(X509_VERIFY_PARAM_set1); +LCRYPTO_USED(X509_VERIFY_PARAM_set1_name); +LCRYPTO_USED(X509_VERIFY_PARAM_set_flags); +LCRYPTO_USED(X509_VERIFY_PARAM_clear_flags); +LCRYPTO_USED(X509_VERIFY_PARAM_get_flags); +LCRYPTO_USED(X509_VERIFY_PARAM_set_purpose); +LCRYPTO_USED(X509_VERIFY_PARAM_set_trust); +LCRYPTO_USED(X509_VERIFY_PARAM_set_depth); +LCRYPTO_USED(X509_VERIFY_PARAM_set_auth_level); +LCRYPTO_USED(X509_VERIFY_PARAM_get_time); +LCRYPTO_USED(X509_VERIFY_PARAM_set_time); +LCRYPTO_USED(X509_VERIFY_PARAM_add0_policy); +LCRYPTO_USED(X509_VERIFY_PARAM_set1_policies); +LCRYPTO_USED(X509_VERIFY_PARAM_get_depth); +LCRYPTO_USED(X509_VERIFY_PARAM_set1_host); +LCRYPTO_USED(X509_VERIFY_PARAM_add1_host); +LCRYPTO_USED(X509_VERIFY_PARAM_set_hostflags); +LCRYPTO_USED(X509_VERIFY_PARAM_get0_peername); +LCRYPTO_USED(X509_VERIFY_PARAM_set1_email); +LCRYPTO_USED(X509_VERIFY_PARAM_set1_ip); +LCRYPTO_USED(X509_VERIFY_PARAM_set1_ip_asc); +LCRYPTO_USED(X509_VERIFY_PARAM_get0_name); +LCRYPTO_USED(X509_VERIFY_PARAM_get0); +LCRYPTO_USED(X509_VERIFY_PARAM_get_count); +LCRYPTO_USED(X509_VERIFY_PARAM_add0_table); +LCRYPTO_USED(X509_VERIFY_PARAM_lookup); +LCRYPTO_USED(X509_VERIFY_PARAM_table_cleanup); +LCRYPTO_USED(X509_policy_check); +LCRYPTO_USED(X509_policy_tree_free); +LCRYPTO_USED(X509_policy_tree_level_count); +LCRYPTO_USED(X509_policy_tree_get0_level); +LCRYPTO_USED(X509_policy_tree_get0_policies); +LCRYPTO_USED(X509_policy_tree_get0_user_policies); +LCRYPTO_USED(X509_policy_level_node_count); +LCRYPTO_USED(X509_policy_level_get0_node); +LCRYPTO_USED(X509_policy_node_get0_policy); +LCRYPTO_USED(X509_policy_node_get0_qualifiers); +LCRYPTO_USED(X509_policy_node_get0_parent); + +#endif /* _LIBCRYPTO_X509_VFY_H */ diff --git a/crypto/hidden/openssl/x509v3.h b/crypto/hidden/openssl/x509v3.h new file mode 100644 index 00000000..1b4102ea --- /dev/null +++ b/crypto/hidden/openssl/x509v3.h @@ -0,0 +1,288 @@ +/* $OpenBSD: x509v3.h,v 1.1 2022/11/14 17:48:49 beck Exp $ */ +/* + * Copyright (c) 2022 Bob Beck + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_X509V3_H +#define _LIBCRYPTO_X509V3_H + +#ifdef _MSC_VER +#include <../include/openssl/x509v3.h> +#else +#include_next +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(PROXY_POLICY_new); +LCRYPTO_USED(PROXY_POLICY_free); +LCRYPTO_USED(d2i_PROXY_POLICY); +LCRYPTO_USED(i2d_PROXY_POLICY); +LCRYPTO_USED(PROXY_CERT_INFO_EXTENSION_new); +LCRYPTO_USED(PROXY_CERT_INFO_EXTENSION_free); +LCRYPTO_USED(d2i_PROXY_CERT_INFO_EXTENSION); +LCRYPTO_USED(i2d_PROXY_CERT_INFO_EXTENSION); +LCRYPTO_USED(BASIC_CONSTRAINTS_new); +LCRYPTO_USED(BASIC_CONSTRAINTS_free); +LCRYPTO_USED(d2i_BASIC_CONSTRAINTS); +LCRYPTO_USED(i2d_BASIC_CONSTRAINTS); +LCRYPTO_USED(SXNET_new); +LCRYPTO_USED(SXNET_free); +LCRYPTO_USED(d2i_SXNET); +LCRYPTO_USED(i2d_SXNET); +LCRYPTO_USED(SXNETID_new); +LCRYPTO_USED(SXNETID_free); +LCRYPTO_USED(d2i_SXNETID); +LCRYPTO_USED(i2d_SXNETID); +LCRYPTO_USED(SXNET_add_id_asc); +LCRYPTO_USED(SXNET_add_id_ulong); +LCRYPTO_USED(SXNET_add_id_INTEGER); +LCRYPTO_USED(SXNET_get_id_asc); +LCRYPTO_USED(SXNET_get_id_ulong); +LCRYPTO_USED(SXNET_get_id_INTEGER); +LCRYPTO_USED(AUTHORITY_KEYID_new); +LCRYPTO_USED(AUTHORITY_KEYID_free); +LCRYPTO_USED(d2i_AUTHORITY_KEYID); +LCRYPTO_USED(i2d_AUTHORITY_KEYID); +LCRYPTO_USED(PKEY_USAGE_PERIOD_new); +LCRYPTO_USED(PKEY_USAGE_PERIOD_free); +LCRYPTO_USED(d2i_PKEY_USAGE_PERIOD); +LCRYPTO_USED(i2d_PKEY_USAGE_PERIOD); +LCRYPTO_USED(GENERAL_NAME_new); +LCRYPTO_USED(GENERAL_NAME_free); +LCRYPTO_USED(d2i_GENERAL_NAME); +LCRYPTO_USED(i2d_GENERAL_NAME); +LCRYPTO_USED(GENERAL_NAME_dup); +LCRYPTO_USED(GENERAL_NAME_cmp); +LCRYPTO_USED(v2i_ASN1_BIT_STRING); +LCRYPTO_USED(i2v_ASN1_BIT_STRING); +LCRYPTO_USED(i2v_GENERAL_NAME); +LCRYPTO_USED(GENERAL_NAME_print); +LCRYPTO_USED(GENERAL_NAMES_new); +LCRYPTO_USED(GENERAL_NAMES_free); +LCRYPTO_USED(d2i_GENERAL_NAMES); +LCRYPTO_USED(i2d_GENERAL_NAMES); +LCRYPTO_USED(i2v_GENERAL_NAMES); +LCRYPTO_USED(v2i_GENERAL_NAMES); +LCRYPTO_USED(OTHERNAME_new); +LCRYPTO_USED(OTHERNAME_free); +LCRYPTO_USED(d2i_OTHERNAME); +LCRYPTO_USED(i2d_OTHERNAME); +LCRYPTO_USED(EDIPARTYNAME_new); +LCRYPTO_USED(EDIPARTYNAME_free); +LCRYPTO_USED(d2i_EDIPARTYNAME); +LCRYPTO_USED(i2d_EDIPARTYNAME); +LCRYPTO_USED(OTHERNAME_cmp); +LCRYPTO_USED(GENERAL_NAME_set0_value); +LCRYPTO_USED(GENERAL_NAME_get0_value); +LCRYPTO_USED(GENERAL_NAME_set0_othername); +LCRYPTO_USED(GENERAL_NAME_get0_otherName); +LCRYPTO_USED(i2s_ASN1_OCTET_STRING); +LCRYPTO_USED(s2i_ASN1_OCTET_STRING); +LCRYPTO_USED(EXTENDED_KEY_USAGE_new); +LCRYPTO_USED(EXTENDED_KEY_USAGE_free); +LCRYPTO_USED(d2i_EXTENDED_KEY_USAGE); +LCRYPTO_USED(i2d_EXTENDED_KEY_USAGE); +LCRYPTO_USED(i2a_ACCESS_DESCRIPTION); +LCRYPTO_USED(CERTIFICATEPOLICIES_new); +LCRYPTO_USED(CERTIFICATEPOLICIES_free); +LCRYPTO_USED(d2i_CERTIFICATEPOLICIES); +LCRYPTO_USED(i2d_CERTIFICATEPOLICIES); +LCRYPTO_USED(POLICYINFO_new); +LCRYPTO_USED(POLICYINFO_free); +LCRYPTO_USED(d2i_POLICYINFO); +LCRYPTO_USED(i2d_POLICYINFO); +LCRYPTO_USED(POLICYQUALINFO_new); +LCRYPTO_USED(POLICYQUALINFO_free); +LCRYPTO_USED(d2i_POLICYQUALINFO); +LCRYPTO_USED(i2d_POLICYQUALINFO); +LCRYPTO_USED(USERNOTICE_new); +LCRYPTO_USED(USERNOTICE_free); +LCRYPTO_USED(d2i_USERNOTICE); +LCRYPTO_USED(i2d_USERNOTICE); +LCRYPTO_USED(NOTICEREF_new); +LCRYPTO_USED(NOTICEREF_free); +LCRYPTO_USED(d2i_NOTICEREF); +LCRYPTO_USED(i2d_NOTICEREF); +LCRYPTO_USED(CRL_DIST_POINTS_new); +LCRYPTO_USED(CRL_DIST_POINTS_free); +LCRYPTO_USED(d2i_CRL_DIST_POINTS); +LCRYPTO_USED(i2d_CRL_DIST_POINTS); +LCRYPTO_USED(DIST_POINT_new); +LCRYPTO_USED(DIST_POINT_free); +LCRYPTO_USED(d2i_DIST_POINT); +LCRYPTO_USED(i2d_DIST_POINT); +LCRYPTO_USED(DIST_POINT_NAME_new); +LCRYPTO_USED(DIST_POINT_NAME_free); +LCRYPTO_USED(d2i_DIST_POINT_NAME); +LCRYPTO_USED(i2d_DIST_POINT_NAME); +LCRYPTO_USED(ISSUING_DIST_POINT_new); +LCRYPTO_USED(ISSUING_DIST_POINT_free); +LCRYPTO_USED(d2i_ISSUING_DIST_POINT); +LCRYPTO_USED(i2d_ISSUING_DIST_POINT); +LCRYPTO_USED(DIST_POINT_set_dpname); +LCRYPTO_USED(NAME_CONSTRAINTS_check); +LCRYPTO_USED(ACCESS_DESCRIPTION_new); +LCRYPTO_USED(ACCESS_DESCRIPTION_free); +LCRYPTO_USED(d2i_ACCESS_DESCRIPTION); +LCRYPTO_USED(i2d_ACCESS_DESCRIPTION); +LCRYPTO_USED(AUTHORITY_INFO_ACCESS_new); +LCRYPTO_USED(AUTHORITY_INFO_ACCESS_free); +LCRYPTO_USED(d2i_AUTHORITY_INFO_ACCESS); +LCRYPTO_USED(i2d_AUTHORITY_INFO_ACCESS); +LCRYPTO_USED(POLICY_MAPPING_new); +LCRYPTO_USED(POLICY_MAPPING_free); +LCRYPTO_USED(GENERAL_SUBTREE_new); +LCRYPTO_USED(GENERAL_SUBTREE_free); +LCRYPTO_USED(NAME_CONSTRAINTS_new); +LCRYPTO_USED(NAME_CONSTRAINTS_free); +LCRYPTO_USED(POLICY_CONSTRAINTS_new); +LCRYPTO_USED(POLICY_CONSTRAINTS_free); +LCRYPTO_USED(a2i_GENERAL_NAME); +LCRYPTO_USED(v2i_GENERAL_NAME); +LCRYPTO_USED(v2i_GENERAL_NAME_ex); +LCRYPTO_USED(X509V3_conf_free); +LCRYPTO_USED(X509V3_EXT_nconf_nid); +LCRYPTO_USED(X509V3_EXT_nconf); +LCRYPTO_USED(X509V3_EXT_add_nconf_sk); +LCRYPTO_USED(X509V3_EXT_add_nconf); +LCRYPTO_USED(X509V3_EXT_REQ_add_nconf); +LCRYPTO_USED(X509V3_EXT_CRL_add_nconf); +LCRYPTO_USED(X509V3_EXT_conf_nid); +LCRYPTO_USED(X509V3_EXT_conf); +LCRYPTO_USED(X509V3_EXT_add_conf); +LCRYPTO_USED(X509V3_EXT_REQ_add_conf); +LCRYPTO_USED(X509V3_EXT_CRL_add_conf); +LCRYPTO_USED(X509V3_add_value_bool_nf); +LCRYPTO_USED(X509V3_get_value_bool); +LCRYPTO_USED(X509V3_get_value_int); +LCRYPTO_USED(X509V3_set_nconf); +LCRYPTO_USED(X509V3_set_conf_lhash); +LCRYPTO_USED(X509V3_get_string); +LCRYPTO_USED(X509V3_get_section); +LCRYPTO_USED(X509V3_string_free); +LCRYPTO_USED(X509V3_section_free); +LCRYPTO_USED(X509V3_set_ctx); +LCRYPTO_USED(X509V3_add_value); +LCRYPTO_USED(X509V3_add_value_uchar); +LCRYPTO_USED(X509V3_add_value_bool); +LCRYPTO_USED(X509V3_add_value_int); +LCRYPTO_USED(i2s_ASN1_INTEGER); +LCRYPTO_USED(s2i_ASN1_INTEGER); +LCRYPTO_USED(i2s_ASN1_ENUMERATED); +LCRYPTO_USED(i2s_ASN1_ENUMERATED_TABLE); +LCRYPTO_USED(X509V3_EXT_add); +LCRYPTO_USED(X509V3_EXT_add_list); +LCRYPTO_USED(X509V3_EXT_add_alias); +LCRYPTO_USED(X509V3_EXT_cleanup); +LCRYPTO_USED(X509V3_EXT_get); +LCRYPTO_USED(X509V3_EXT_get_nid); +LCRYPTO_USED(X509V3_add_standard_extensions); +LCRYPTO_USED(X509V3_parse_list); +LCRYPTO_USED(X509V3_EXT_d2i); +LCRYPTO_USED(X509V3_get_d2i); +LCRYPTO_USED(X509V3_EXT_i2d); +LCRYPTO_USED(X509V3_add1_i2d); +LCRYPTO_USED(hex_to_string); +LCRYPTO_USED(string_to_hex); +LCRYPTO_USED(X509V3_EXT_val_prn); +LCRYPTO_USED(X509V3_EXT_print); +LCRYPTO_USED(X509V3_EXT_print_fp); +LCRYPTO_USED(X509V3_extensions_print); +LCRYPTO_USED(X509_check_ca); +LCRYPTO_USED(X509_check_purpose); +LCRYPTO_USED(X509_supported_extension); +LCRYPTO_USED(X509_PURPOSE_set); +LCRYPTO_USED(X509_check_issued); +LCRYPTO_USED(X509_check_akid); +LCRYPTO_USED(X509_PURPOSE_get_count); +LCRYPTO_USED(X509_PURPOSE_get0); +LCRYPTO_USED(X509_PURPOSE_get_by_sname); +LCRYPTO_USED(X509_PURPOSE_get_by_id); +LCRYPTO_USED(X509_PURPOSE_add); +LCRYPTO_USED(X509_PURPOSE_get0_name); +LCRYPTO_USED(X509_PURPOSE_get0_sname); +LCRYPTO_USED(X509_PURPOSE_get_trust); +LCRYPTO_USED(X509_PURPOSE_cleanup); +LCRYPTO_USED(X509_PURPOSE_get_id); +LCRYPTO_USED(X509_get_extension_flags); +LCRYPTO_USED(X509_get_key_usage); +LCRYPTO_USED(X509_get_extended_key_usage); +LCRYPTO_USED(X509_get1_email); +LCRYPTO_USED(X509_REQ_get1_email); +LCRYPTO_USED(X509_email_free); +LCRYPTO_USED(X509_get1_ocsp); +LCRYPTO_USED(X509_check_host); +LCRYPTO_USED(X509_check_email); +LCRYPTO_USED(X509_check_ip); +LCRYPTO_USED(X509_check_ip_asc); +LCRYPTO_USED(a2i_IPADDRESS); +LCRYPTO_USED(a2i_IPADDRESS_NC); +LCRYPTO_USED(a2i_ipadd); +LCRYPTO_USED(X509V3_NAME_from_section); +LCRYPTO_USED(X509_POLICY_NODE_print); +LCRYPTO_USED(ASRange_new); +LCRYPTO_USED(ASRange_free); +LCRYPTO_USED(d2i_ASRange); +LCRYPTO_USED(i2d_ASRange); +LCRYPTO_USED(ASIdOrRange_new); +LCRYPTO_USED(ASIdOrRange_free); +LCRYPTO_USED(d2i_ASIdOrRange); +LCRYPTO_USED(i2d_ASIdOrRange); +LCRYPTO_USED(ASIdentifierChoice_new); +LCRYPTO_USED(ASIdentifierChoice_free); +LCRYPTO_USED(d2i_ASIdentifierChoice); +LCRYPTO_USED(i2d_ASIdentifierChoice); +LCRYPTO_USED(ASIdentifiers_new); +LCRYPTO_USED(ASIdentifiers_free); +LCRYPTO_USED(d2i_ASIdentifiers); +LCRYPTO_USED(i2d_ASIdentifiers); +LCRYPTO_USED(IPAddressRange_new); +LCRYPTO_USED(IPAddressRange_free); +LCRYPTO_USED(d2i_IPAddressRange); +LCRYPTO_USED(i2d_IPAddressRange); +LCRYPTO_USED(IPAddressOrRange_new); +LCRYPTO_USED(IPAddressOrRange_free); +LCRYPTO_USED(d2i_IPAddressOrRange); +LCRYPTO_USED(i2d_IPAddressOrRange); +LCRYPTO_USED(IPAddressChoice_new); +LCRYPTO_USED(IPAddressChoice_free); +LCRYPTO_USED(d2i_IPAddressChoice); +LCRYPTO_USED(i2d_IPAddressChoice); +LCRYPTO_USED(IPAddressFamily_new); +LCRYPTO_USED(IPAddressFamily_free); +LCRYPTO_USED(d2i_IPAddressFamily); +LCRYPTO_USED(i2d_IPAddressFamily); +LCRYPTO_USED(X509v3_asid_add_inherit); +LCRYPTO_USED(X509v3_asid_add_id_or_range); +LCRYPTO_USED(X509v3_addr_add_inherit); +LCRYPTO_USED(X509v3_addr_add_prefix); +LCRYPTO_USED(X509v3_addr_add_range); +LCRYPTO_USED(X509v3_addr_get_afi); +LCRYPTO_USED(X509v3_addr_get_range); +LCRYPTO_USED(X509v3_asid_is_canonical); +LCRYPTO_USED(X509v3_addr_is_canonical); +LCRYPTO_USED(X509v3_asid_canonize); +LCRYPTO_USED(X509v3_addr_canonize); +LCRYPTO_USED(X509v3_asid_inherits); +LCRYPTO_USED(X509v3_addr_inherits); +LCRYPTO_USED(X509v3_asid_subset); +LCRYPTO_USED(X509v3_addr_subset); +LCRYPTO_USED(X509v3_asid_validate_path); +LCRYPTO_USED(X509v3_addr_validate_path); +LCRYPTO_USED(X509v3_asid_validate_resource_set); +LCRYPTO_USED(X509v3_addr_validate_resource_set); +LCRYPTO_USED(ERR_load_X509V3_strings); + +#endif /* _LIBCRYPTO_X509V3_H */ diff --git a/crypto/hkdf/hkdf.c b/crypto/hkdf/hkdf.c index 9adf1260..47ad4ec1 100644 --- a/crypto/hkdf/hkdf.c +++ b/crypto/hkdf/hkdf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hkdf.c,v 1.7 2021/12/12 21:30:14 tb Exp $ */ +/* $OpenBSD: hkdf.c,v 1.8 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (c) 2014, Google Inc. * * Permission to use, copy, modify, and/or distribute this software for any @@ -21,7 +21,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" #include "hmac_local.h" /* https://tools.ietf.org/html/rfc5869#section-2 */ diff --git a/crypto/hmac/hm_ameth.c b/crypto/hmac/hm_ameth.c index 84bb5f0c..7e6ad6d6 100644 --- a/crypto/hmac/hm_ameth.c +++ b/crypto/hmac/hm_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hm_ameth.c,v 1.12 2021/12/12 21:30:14 tb Exp $ */ +/* $OpenBSD: hm_ameth.c,v 1.19 2022/11/26 16:08:53 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2007. */ @@ -56,22 +56,24 @@ * */ +#include #include #include #include #include -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "bytestring.h" +#include "evp_local.h" #include "hmac_local.h" -#define HMAC_TEST_PRIVATE_KEY_FORMAT - -/* HMAC "ASN1" method. This is just here to indicate the - * maximum HMAC output length and to free up an HMAC - * key. - */ +static int +hmac_pkey_public_cmp(const EVP_PKEY *a, const EVP_PKEY *b) +{ + /* The ameth pub_cmp must return 1 on match, 0 on mismatch. */ + return ASN1_OCTET_STRING_cmp(a->pkey.ptr, b->pkey.ptr) == 0; +} static int hmac_size(const EVP_PKEY *pkey) @@ -82,13 +84,15 @@ hmac_size(const EVP_PKEY *pkey) static void hmac_key_free(EVP_PKEY *pkey) { - ASN1_OCTET_STRING *os = (ASN1_OCTET_STRING *)pkey->pkey.ptr; + ASN1_OCTET_STRING *os; - if (os) { - if (os->data) - explicit_bzero(os->data, os->length); - ASN1_OCTET_STRING_free(os); - } + if ((os = pkey->pkey.ptr) == NULL) + return; + + if (os->data != NULL) + explicit_bzero(os->data, os->length); + + ASN1_OCTET_STRING_free(os); } static int @@ -103,57 +107,51 @@ hmac_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) } } -#ifdef HMAC_TEST_PRIVATE_KEY_FORMAT -/* A bogus private key format for test purposes. This is simply the - * HMAC key with "HMAC PRIVATE KEY" in the headers. When enabled the - * genpkey utility can be used to "generate" HMAC keys. - */ - static int -old_hmac_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) +hmac_set_priv_key(EVP_PKEY *pkey, const unsigned char *priv, size_t len) { - ASN1_OCTET_STRING *os; + ASN1_OCTET_STRING *os = NULL; - os = ASN1_OCTET_STRING_new(); - if (os == NULL) + if (pkey->pkey.ptr != NULL) goto err; - if (ASN1_OCTET_STRING_set(os, *pder, derlen) == 0) + + if (len > INT_MAX) goto err; - if (EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os) == 0) + + if ((os = ASN1_OCTET_STRING_new()) == NULL) + goto err; + + if (!ASN1_OCTET_STRING_set(os, priv, len)) goto err; + + pkey->pkey.ptr = os; + return 1; -err: + err: ASN1_OCTET_STRING_free(os); + return 0; } static int -old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder) +hmac_get_priv_key(const EVP_PKEY *pkey, unsigned char *priv, size_t *len) { - int inc; - ASN1_OCTET_STRING *os = (ASN1_OCTET_STRING *)pkey->pkey.ptr; - - if (pder) { - if (!*pder) { - *pder = malloc(os->length); - if (*pder == NULL) - return -1; - inc = 0; - } else - inc = 1; - - memcpy(*pder, os->data, os->length); - - if (inc) - *pder += os->length; + ASN1_OCTET_STRING *os; + CBS cbs; + + if ((os = pkey->pkey.ptr) == NULL) + return 0; + + if (priv == NULL) { + *len = os->length; + return 1; } - return os->length; + CBS_init(&cbs, os->data, os->length); + return CBS_write_bytes(&cbs, priv, *len, len); } -#endif - const EVP_PKEY_ASN1_METHOD hmac_asn1_meth = { .pkey_id = EVP_PKEY_HMAC, .pkey_base_id = EVP_PKEY_HMAC, @@ -161,12 +159,13 @@ const EVP_PKEY_ASN1_METHOD hmac_asn1_meth = { .pem_str = "HMAC", .info = "OpenSSL HMAC method", + .pub_cmp = hmac_pkey_public_cmp, + .pkey_size = hmac_size, .pkey_free = hmac_key_free, .pkey_ctrl = hmac_pkey_ctrl, -#ifdef HMAC_TEST_PRIVATE_KEY_FORMAT - .old_priv_decode = old_hmac_decode, - .old_priv_encode = old_hmac_encode -#endif + + .set_priv_key = hmac_set_priv_key, + .get_priv_key = hmac_get_priv_key, }; diff --git a/crypto/hmac/hm_pmeth.c b/crypto/hmac/hm_pmeth.c index 4017f570..bb043d1a 100644 --- a/crypto/hmac/hm_pmeth.c +++ b/crypto/hmac/hm_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hm_pmeth.c,v 1.13 2022/03/30 07:17:48 tb Exp $ */ +/* $OpenBSD: hm_pmeth.c,v 1.15 2022/11/26 16:08:53 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2007. */ @@ -64,7 +64,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" #include "hmac_local.h" /* HMAC pkey context structure */ @@ -202,7 +202,7 @@ pkey_hmac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) break; case EVP_PKEY_CTRL_DIGESTINIT: - key = (ASN1_OCTET_STRING *)ctx->pkey->pkey.ptr; + key = ctx->pkey->pkey.ptr; if (!HMAC_Init_ex(&hctx->ctx, key->data, key->length, hctx->md, ctx->engine)) return 0; diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c index 3421119b..ea3a1b4a 100644 --- a/crypto/hmac/hmac.c +++ b/crypto/hmac/hmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hmac.c,v 1.28 2022/05/05 18:29:34 tb Exp $ */ +/* $OpenBSD: hmac.c,v 1.31 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" #include "hmac_local.h" int @@ -134,6 +134,7 @@ HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md, err: return 0; } +LCRYPTO_ALIAS(HMAC_Init_ex); int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md) @@ -151,6 +152,7 @@ HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len) return EVP_DigestUpdate(&ctx->md_ctx, data, len); } +LCRYPTO_ALIAS(HMAC_Update); int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) @@ -173,6 +175,7 @@ HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) err: return 0; } +LCRYPTO_ALIAS(HMAC_Final); HMAC_CTX * HMAC_CTX_new(void) @@ -186,6 +189,7 @@ HMAC_CTX_new(void) return ctx; } +LCRYPTO_ALIAS(HMAC_CTX_new); void HMAC_CTX_free(HMAC_CTX *ctx) @@ -197,6 +201,7 @@ HMAC_CTX_free(HMAC_CTX *ctx) free(ctx); } +LCRYPTO_ALIAS(HMAC_CTX_free); int HMAC_CTX_reset(HMAC_CTX *ctx) @@ -231,6 +236,7 @@ HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx) err: return 0; } +LCRYPTO_ALIAS(HMAC_CTX_copy); void HMAC_CTX_cleanup(HMAC_CTX *ctx) @@ -248,12 +254,14 @@ HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags) EVP_MD_CTX_set_flags(&ctx->o_ctx, flags); EVP_MD_CTX_set_flags(&ctx->md_ctx, flags); } +LCRYPTO_ALIAS(HMAC_CTX_set_flags); const EVP_MD * HMAC_CTX_get_md(const HMAC_CTX *ctx) { return ctx->md; } +LCRYPTO_ALIAS(HMAC_CTX_get_md); unsigned char * HMAC(const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *d, @@ -282,3 +290,4 @@ HMAC(const EVP_MD *evp_md, const void *key, int key_len, const unsigned char *d, HMAC_CTX_cleanup(&c); return NULL; } +LCRYPTO_ALIAS(HMAC); diff --git a/crypto/hmac/hmac_local.h b/crypto/hmac/hmac_local.h index 5900bc1c..e06cd6a6 100644 --- a/crypto/hmac/hmac_local.h +++ b/crypto/hmac/hmac_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hmac_local.h,v 1.3 2022/01/14 08:06:03 tb Exp $ */ +/* $OpenBSD: hmac_local.h,v 1.4 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include -#include "evp_locl.h" +#include "evp_local.h" __BEGIN_HIDDEN_DECLS diff --git a/crypto/idea/i_cbc.c b/crypto/idea/i_cbc.c index 5bb9640c..e382a0a6 100644 --- a/crypto/idea/i_cbc.c +++ b/crypto/idea/i_cbc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i_cbc.c,v 1.3 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: i_cbc.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "idea_lcl.h" +#include "idea_local.h" void idea_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, int encrypt) diff --git a/crypto/idea/i_cfb64.c b/crypto/idea/i_cfb64.c index b979aaef..d6b64119 100644 --- a/crypto/idea/i_cfb64.c +++ b/crypto/idea/i_cfb64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i_cfb64.c,v 1.3 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: i_cfb64.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "idea_lcl.h" +#include "idea_local.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the diff --git a/crypto/idea/i_ecb.c b/crypto/idea/i_ecb.c index dac456cd..6fada765 100644 --- a/crypto/idea/i_ecb.c +++ b/crypto/idea/i_ecb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i_ecb.c,v 1.3 2014/07/09 11:10:51 bcook Exp $ */ +/* $OpenBSD: i_ecb.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "idea_lcl.h" +#include "idea_local.h" #include const char *idea_options(void) diff --git a/crypto/idea/i_ofb64.c b/crypto/idea/i_ofb64.c index 376dad9f..b63144b6 100644 --- a/crypto/idea/i_ofb64.c +++ b/crypto/idea/i_ofb64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i_ofb64.c,v 1.3 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: i_ofb64.c,v 1.4 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "idea_lcl.h" +#include "idea_local.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the diff --git a/crypto/idea/i_skey.c b/crypto/idea/i_skey.c index 2824d261..43381651 100644 --- a/crypto/idea/i_skey.c +++ b/crypto/idea/i_skey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i_skey.c,v 1.4 2014/10/28 07:35:58 jsg Exp $ */ +/* $OpenBSD: i_skey.c,v 1.5 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -58,7 +58,7 @@ #include #include -#include "idea_lcl.h" +#include "idea_local.h" static IDEA_INT inverse(unsigned int xin); void idea_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks) diff --git a/crypto/idea/idea_lcl.h b/crypto/idea/idea_local.h similarity index 98% rename from crypto/idea/idea_lcl.h rename to crypto/idea/idea_local.h index e46c9608..2663516c 100644 --- a/crypto/idea/idea_lcl.h +++ b/crypto/idea/idea_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: idea_lcl.h,v 1.3 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: idea_local.h,v 1.1 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * diff --git a/crypto/kdf/hkdf_evp.c b/crypto/kdf/hkdf_evp.c index 736208de..992c66a1 100644 --- a/crypto/kdf/hkdf_evp.c +++ b/crypto/kdf/hkdf_evp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hkdf_evp.c,v 1.18 2022/05/05 19:48:06 tb Exp $ */ +/* $OpenBSD: hkdf_evp.c,v 1.19 2022/11/26 16:08:53 tb Exp $ */ /* ==================================================================== * Copyright (c) 2016-2018 The OpenSSL Project. All rights reserved. * @@ -56,7 +56,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" #define HKDF_MAXBUF 1024 diff --git a/crypto/md32_common.h b/crypto/md32_common.h index 0dca6171..a8b0d9ab 100644 --- a/crypto/md32_common.h +++ b/crypto/md32_common.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md32_common.h,v 1.22 2016/11/04 13:56:04 miod Exp $ */ +/* $OpenBSD: md32_common.h,v 1.23 2022/12/26 07:18:50 jmc Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * @@ -316,7 +316,7 @@ int HASH_FINAL (unsigned char *md, HASH_CTX *c) #if defined(__alpha) || defined(__sparcv9) || defined(__mips) #define MD32_REG_T long /* - * This comment was originaly written for MD5, which is why it + * This comment was originally written for MD5, which is why it * discusses A-D. But it basically applies to all 32-bit digests, * which is why it was moved to common header file. * diff --git a/crypto/md4/md4_dgst.c b/crypto/md4/md4_dgst.c index 4d3801fc..aa7b7f79 100644 --- a/crypto/md4/md4_dgst.c +++ b/crypto/md4/md4_dgst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md4_dgst.c,v 1.16 2015/09/14 01:45:03 doug Exp $ */ +/* $OpenBSD: md4_dgst.c,v 1.17 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -59,7 +59,7 @@ #include #include #include -#include "md4_locl.h" +#include "md4_local.h" /* Implemented from RFC1186 The MD4 Message-Digest Algorithm */ diff --git a/crypto/md4/md4_locl.h b/crypto/md4/md4_local.h similarity index 98% rename from crypto/md4/md4_locl.h rename to crypto/md4/md4_local.h index 6cf69ded..a5aa123c 100644 --- a/crypto/md4/md4_locl.h +++ b/crypto/md4/md4_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md4_locl.h,v 1.10 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: md4_local.h,v 1.1 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * diff --git a/crypto/md5/md5_dgst.c b/crypto/md5/md5_dgst.c index f5511372..5acdcd20 100644 --- a/crypto/md5/md5_dgst.c +++ b/crypto/md5/md5_dgst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5_dgst.c,v 1.14 2014/10/28 07:35:59 jsg Exp $ */ +/* $OpenBSD: md5_dgst.c,v 1.15 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "md5_locl.h" +#include "md5_local.h" #include #include diff --git a/crypto/md5/md5_locl.h b/crypto/md5/md5_local.h similarity index 98% rename from crypto/md5/md5_locl.h rename to crypto/md5/md5_local.h index 325c5314..6026733a 100644 --- a/crypto/md5/md5_locl.h +++ b/crypto/md5/md5_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md5_locl.h,v 1.14 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: md5_local.h,v 1.1 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * diff --git a/crypto/modes/cbc128.c b/crypto/modes/cbc128.c index c5cf5a63..f2eebc6e 100644 --- a/crypto/modes/cbc128.c +++ b/crypto/modes/cbc128.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cbc128.c,v 1.5 2022/01/22 00:45:17 inoguchi Exp $ */ +/* $OpenBSD: cbc128.c,v 1.6 2022/11/26 16:08:53 tb Exp $ */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * @@ -50,7 +50,7 @@ */ #include -#include "modes_lcl.h" +#include "modes_local.h" #include #ifndef MODES_DEBUG diff --git a/crypto/modes/ccm128.c b/crypto/modes/ccm128.c index 12c6e616..978259e1 100644 --- a/crypto/modes/ccm128.c +++ b/crypto/modes/ccm128.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ccm128.c,v 1.5 2019/05/08 14:18:25 tb Exp $ */ +/* $OpenBSD: ccm128.c,v 1.6 2022/11/26 16:08:53 tb Exp $ */ /* ==================================================================== * Copyright (c) 2011 The OpenSSL Project. All rights reserved. * @@ -49,7 +49,7 @@ */ #include -#include "modes_lcl.h" +#include "modes_local.h" #include #ifndef MODES_DEBUG diff --git a/crypto/modes/cfb128.c b/crypto/modes/cfb128.c index 8399f0c5..8555ce05 100644 --- a/crypto/modes/cfb128.c +++ b/crypto/modes/cfb128.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfb128.c,v 1.4 2015/02/10 09:46:30 miod Exp $ */ +/* $OpenBSD: cfb128.c,v 1.5 2022/11/26 16:08:53 tb Exp $ */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * @@ -50,7 +50,7 @@ */ #include -#include "modes_lcl.h" +#include "modes_local.h" #include #ifndef MODES_DEBUG diff --git a/crypto/modes/ctr128.c b/crypto/modes/ctr128.c index 23979d64..eadb8044 100644 --- a/crypto/modes/ctr128.c +++ b/crypto/modes/ctr128.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ctr128.c,v 1.7 2017/08/13 17:46:24 bcook Exp $ */ +/* $OpenBSD: ctr128.c,v 1.9 2022/12/26 07:18:52 jmc Exp $ */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * @@ -50,7 +50,7 @@ */ #include -#include "modes_lcl.h" +#include "modes_local.h" #include #ifndef MODES_DEBUG @@ -109,7 +109,7 @@ ctr128_inc_aligned(unsigned char *counter) * This algorithm assumes that the counter is in the x lower bits * of the IV (ivec), and that the application has full control over * overflow and the rest of the IV. This implementation takes NO - * responsability for checking that the counter doesn't overflow + * responsibility for checking that the counter doesn't overflow * into the rest of the IV when incremented. */ void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out, @@ -228,7 +228,7 @@ void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out, (*func)(in,out,blocks,key,ivec); /* (*ctr) does not update ivec, caller does: */ PUTU32(ivec+12,ctr32); - /* ... overflow was detected, propogate carry. */ + /* ... overflow was detected, propagate carry. */ if (ctr32 == 0) ctr96_inc(ivec); blocks *= 16; len -= blocks; diff --git a/crypto/modes/cts128.c b/crypto/modes/cts128.c index 802aa77c..ec81dd24 100644 --- a/crypto/modes/cts128.c +++ b/crypto/modes/cts128.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cts128.c,v 1.5 2015/07/19 18:27:26 miod Exp $ */ +/* $OpenBSD: cts128.c,v 1.6 2022/11/26 16:08:53 tb Exp $ */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * @@ -7,7 +7,7 @@ */ #include -#include "modes_lcl.h" +#include "modes_local.h" #include #ifndef MODES_DEBUG diff --git a/crypto/modes/gcm128.c b/crypto/modes/gcm128.c index 74362e6a..36aac413 100644 --- a/crypto/modes/gcm128.c +++ b/crypto/modes/gcm128.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gcm128.c,v 1.22 2018/01/24 23:03:37 kettenis Exp $ */ +/* $OpenBSD: gcm128.c,v 1.23 2022/11/26 16:08:53 tb Exp $ */ /* ==================================================================== * Copyright (c) 2010 The OpenSSL Project. All rights reserved. * @@ -51,7 +51,7 @@ #define OPENSSL_FIPSAPI #include -#include "modes_lcl.h" +#include "modes_local.h" #include #ifndef MODES_DEBUG diff --git a/crypto/modes/ghash-elf-x86_64.S b/crypto/modes/ghash-elf-x86_64.S index 5f316261..224450b3 100644 --- a/crypto/modes/ghash-elf-x86_64.S +++ b/crypto/modes/ghash-elf-x86_64.S @@ -976,6 +976,7 @@ gcm_ghash_clmul: retq .LSEH_end_gcm_ghash_clmul: .size gcm_ghash_clmul,.-gcm_ghash_clmul +.section .rodata .align 64 .Lbswap_mask: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -1022,9 +1023,8 @@ gcm_ghash_clmul: .value 0xA7D0,0xA612,0xA454,0xA596,0xA0D8,0xA11A,0xA35C,0xA29E .value 0xB5E0,0xB422,0xB664,0xB7A6,0xB2E8,0xB32A,0xB16C,0xB0AE .value 0xBBF0,0xBA32,0xB874,0xB9B6,0xBCF8,0xBD3A,0xBF7C,0xBEBE - -.byte 71,72,65,83,72,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 64 +.text #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/modes/ghash-macosx-x86_64.S b/crypto/modes/ghash-macosx-x86_64.S index e6840a78..ed843ea7 100644 --- a/crypto/modes/ghash-macosx-x86_64.S +++ b/crypto/modes/ghash-macosx-x86_64.S @@ -976,6 +976,7 @@ L$done: retq L$SEH_end_gcm_ghash_clmul: +.section __DATA,__const .p2align 6 L$bswap_mask: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -1022,6 +1023,5 @@ L$rem_8bit: .value 0xA7D0,0xA612,0xA454,0xA596,0xA0D8,0xA11A,0xA35C,0xA29E .value 0xB5E0,0xB422,0xB664,0xB7A6,0xB2E8,0xB32A,0xB16C,0xB0AE .value 0xBBF0,0xBA32,0xB874,0xB9B6,0xBCF8,0xBD3A,0xBF7C,0xBEBE - -.byte 71,72,65,83,72,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 6 +.text diff --git a/crypto/modes/ghash-masm-x86_64.S b/crypto/modes/ghash-masm-x86_64.S index 09ee8e0f..86316821 100644 --- a/crypto/modes/ghash-masm-x86_64.S +++ b/crypto/modes/ghash-masm-x86_64.S @@ -1082,6 +1082,8 @@ DB 102,15,56,0,197 DB 0F3h,0C3h ;repret $L$SEH_end_gcm_ghash_clmul:: gcm_ghash_clmul ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 $L$bswap_mask:: DB 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -1128,12 +1130,9 @@ $L$rem_8bit:: DW 0A7D0h,0A612h,0A454h,0A596h,0A0D8h,0A11Ah,0A35Ch,0A29Eh DW 0B5E0h,0B422h,0B664h,0B7A6h,0B2E8h,0B32Ah,0B16Ch,0B0AEh DW 0BBF0h,0BA32h,0B874h,0B9B6h,0BCF8h,0BD3Ah,0BF7Ch,0BEBEh - -DB 71,72,65,83,72,32,102,111,114,32,120,56,54,95,54,52 -DB 44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32 -DB 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111 -DB 114,103,62,0 ALIGN 64 +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 diff --git a/crypto/modes/ghash-mingw64-x86_64.S b/crypto/modes/ghash-mingw64-x86_64.S index cd0823b4..29918f59 100644 --- a/crypto/modes/ghash-mingw64-x86_64.S +++ b/crypto/modes/ghash-mingw64-x86_64.S @@ -1010,6 +1010,7 @@ gcm_ghash_clmul: retq .LSEH_end_gcm_ghash_clmul: +.section .rodata .p2align 6 .Lbswap_mask: .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 @@ -1056,9 +1057,8 @@ gcm_ghash_clmul: .value 0xA7D0,0xA612,0xA454,0xA596,0xA0D8,0xA11A,0xA35C,0xA29E .value 0xB5E0,0xB422,0xB664,0xB7A6,0xB2E8,0xB32A,0xB16C,0xB0AE .value 0xBBF0,0xBA32,0xB874,0xB9B6,0xBCF8,0xBD3A,0xBF7C,0xBEBE - -.byte 71,72,65,83,72,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 6 +.text .def se_handler; .scl 3; .type 32; .endef .p2align 4 diff --git a/crypto/modes/modes_lcl.h b/crypto/modes/modes_local.h similarity index 97% rename from crypto/modes/modes_lcl.h rename to crypto/modes/modes_local.h index d0126e87..11efc5aa 100644 --- a/crypto/modes/modes_lcl.h +++ b/crypto/modes/modes_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: modes_lcl.h,v 1.11 2021/11/09 18:40:21 bcook Exp $ */ +/* $OpenBSD: modes_local.h,v 1.1 2022/11/26 16:08:53 tb Exp $ */ /* ==================================================================== * Copyright (c) 2010 The OpenSSL Project. All rights reserved. * diff --git a/crypto/modes/ofb128.c b/crypto/modes/ofb128.c index 1b8a6fd5..3cf5d981 100644 --- a/crypto/modes/ofb128.c +++ b/crypto/modes/ofb128.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofb128.c,v 1.4 2015/02/10 09:46:30 miod Exp $ */ +/* $OpenBSD: ofb128.c,v 1.5 2022/11/26 16:08:53 tb Exp $ */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * @@ -50,7 +50,7 @@ */ #include -#include "modes_lcl.h" +#include "modes_local.h" #include #ifndef MODES_DEBUG diff --git a/crypto/modes/xts128.c b/crypto/modes/xts128.c index 2084892e..dfd3bc43 100644 --- a/crypto/modes/xts128.c +++ b/crypto/modes/xts128.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xts128.c,v 1.8 2021/11/09 18:40:21 bcook Exp $ */ +/* $OpenBSD: xts128.c,v 1.9 2022/11/26 16:08:53 tb Exp $ */ /* ==================================================================== * Copyright (c) 2011 The OpenSSL Project. All rights reserved. * @@ -49,7 +49,7 @@ */ #include -#include "modes_lcl.h" +#include "modes_local.h" #include #include diff --git a/crypto/o_time.c b/crypto/o_time.c deleted file mode 100644 index 3f164c7f..00000000 --- a/crypto/o_time.c +++ /dev/null @@ -1,242 +0,0 @@ -/* $OpenBSD: o_time.c,v 1.16 2021/10/27 09:50:56 beck Exp $ */ -/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL - * project 2001. - */ -/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL - * project 2008. - */ -/* ==================================================================== - * Copyright (c) 2001 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - * This product includes cryptographic software written by Eric Young - * (eay@cryptsoft.com). This product includes software written by Tim - * Hudson (tjh@cryptsoft.com). - * - */ - -#include - -#include "o_time.h" - -/* Take a tm structure and add an offset to it. This avoids any OS issues - * with restricted date types and overflows which cause the year 2038 - * problem. - */ - -#define SECS_PER_DAY (24 * 60 * 60) - -static long date_to_julian(int y, int m, int d); -static void julian_to_date(long jd, int *y, int *m, int *d); -static int julian_adj(const struct tm *tm, int off_day, long offset_sec, - long *pday, int *psec); - -int -OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec) -{ - int offset_hms, offset_day; - long time_jd; - int time_year, time_month, time_day; - /* split offset into days and day seconds */ - offset_day = offset_sec / SECS_PER_DAY; - /* Avoid sign issues with % operator */ - offset_hms = offset_sec - (offset_day * SECS_PER_DAY); - offset_day += off_day; - /* Add current time seconds to offset */ - offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec; - /* Adjust day seconds if overflow */ - if (offset_hms >= SECS_PER_DAY) { - offset_day++; - offset_hms -= SECS_PER_DAY; - } else if (offset_hms < 0) { - offset_day--; - offset_hms += SECS_PER_DAY; - } - - /* Convert date of time structure into a Julian day number. - */ - - time_year = tm->tm_year + 1900; - time_month = tm->tm_mon + 1; - time_day = tm->tm_mday; - - time_jd = date_to_julian(time_year, time_month, time_day); - - /* Work out Julian day of new date */ - time_jd += offset_day; - - if (time_jd < 0) - return 0; - - /* Convert Julian day back to date */ - - julian_to_date(time_jd, &time_year, &time_month, &time_day); - - if (time_year < 1900 || time_year > 9999) - return 0; - - /* Update tm structure */ - - tm->tm_year = time_year - 1900; - tm->tm_mon = time_month - 1; - tm->tm_mday = time_day; - - tm->tm_hour = offset_hms / 3600; - tm->tm_min = (offset_hms / 60) % 60; - tm->tm_sec = offset_hms % 60; - - return 1; - -} - -int -OPENSSL_gmtime_diff(int *pday, int *psec, const struct tm *from, - const struct tm *to) -{ - int from_sec, to_sec, diff_sec; - long from_jd, to_jd, diff_day; - - if (!julian_adj(from, 0, 0, &from_jd, &from_sec)) - return 0; - if (!julian_adj(to, 0, 0, &to_jd, &to_sec)) - return 0; - diff_day = to_jd - from_jd; - diff_sec = to_sec - from_sec; - /* Adjust differences so both positive or both negative */ - if (diff_day > 0 && diff_sec < 0) { - diff_day--; - diff_sec += SECS_PER_DAY; - } - if (diff_day < 0 && diff_sec > 0) { - diff_day++; - diff_sec -= SECS_PER_DAY; - } - - if (pday) - *pday = (int)diff_day; - if (psec) - *psec = diff_sec; - - return 1; - -} - -/* Convert tm structure and offset into julian day and seconds */ -static int -julian_adj(const struct tm *tm, int off_day, long offset_sec, long *pday, - int *psec) -{ - int time_year, time_month, time_day; - long offset_day, time_jd; - int offset_hms; - - /* split offset into days and day seconds */ - offset_day = offset_sec / SECS_PER_DAY; - /* Avoid sign issues with % operator */ - offset_hms = offset_sec - (offset_day * SECS_PER_DAY); - offset_day += off_day; - /* Add current time seconds to offset */ - offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec; - /* Adjust day seconds if overflow */ - if (offset_hms >= SECS_PER_DAY) { - offset_day++; - offset_hms -= SECS_PER_DAY; - } else if (offset_hms < 0) { - offset_day--; - offset_hms += SECS_PER_DAY; - } - - /* - * Convert date of time structure into a Julian day number. - */ - - time_year = tm->tm_year + 1900; - time_month = tm->tm_mon + 1; - time_day = tm->tm_mday; - - time_jd = date_to_julian(time_year, time_month, time_day); - - /* Work out Julian day of new date */ - time_jd += offset_day; - - if (time_jd < 0) - return 0; - - *pday = time_jd; - *psec = offset_hms; - - return 1; -} - -/* Convert date to and from julian day - * Uses Fliegel & Van Flandern algorithm - */ -static long -date_to_julian(int y, int m, int d) -{ - return (1461 * (y + 4800 + (m - 14) / 12)) / 4 + - (367 * (m - 2 - 12 * ((m - 14) / 12))) / 12 - - (3 * ((y + 4900 + (m - 14) / 12) / 100)) / 4 + - d - 32075; -} - -static void -julian_to_date(long jd, int *y, int *m, int *d) -{ - long L = jd + 68569; - long n = (4 * L) / 146097; - long i, j; - - L = L - (146097 * n + 3) / 4; - i = (4000 * (L + 1)) / 1461001; - L = L - (1461 * i) / 4 + 31; - j = (80 * L) / 2447; - *d = L - (2447 * j) / 80; - L = j / 11; - *m = j + 2 - (12 * L); - *y = 100 * (n - 49) + i + L; -} diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index a9e5f859..2cdd2f3a 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: o_names.c,v 1.22 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: o_names.c,v 1.23 2022/11/08 23:19:09 mbuhl Exp $ */ #include #include #include @@ -197,6 +197,7 @@ OBJ_NAME_add(const char *name, int type, const char *data) free(ret); } else { if (lh_OBJ_NAME_error(names_lh)) { + free(onp); /* ERROR */ return (0); } diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index bcb7ee2d..6adc4068 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_dat.c,v 1.49 2022/03/19 17:49:32 jsing Exp $ */ +/* $OpenBSD: obj_dat.c,v 1.51 2022/12/26 07:18:52 jmc Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -69,7 +69,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" /* obj_dat.h is generated from objects.h by obj_dat.pl */ #include "obj_dat.h" @@ -251,7 +251,7 @@ static IMPLEMENT_LHASH_DOALL_FN(cleanup2, ADDED_OBJ) static IMPLEMENT_LHASH_DOALL_FN(cleanup3, ADDED_OBJ) /* The purpose of obj_cleanup_defer is to avoid EVP_cleanup() attempting - * to use freed up OIDs. If neccessary the actual freeing up of OIDs is + * to use freed up OIDs. If necessary the actual freeing up of OIDs is * delayed. */ @@ -320,7 +320,7 @@ OBJ_add_object(const ASN1_OBJECT *obj) ao[i]->type = i; ao[i]->obj = o; aop = lh_ADDED_OBJ_insert(added, ao[i]); - /* memory leak, buit should not normally matter */ + /* memory leak, but should not normally matter */ free(aop); } } diff --git a/crypto/objects/obj_lib.c b/crypto/objects/obj_lib.c index 39cd4124..eb06adfb 100644 --- a/crypto/objects/obj_lib.c +++ b/crypto/objects/obj_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_lib.c,v 1.16 2022/01/07 11:13:54 tb Exp $ */ +/* $OpenBSD: obj_lib.c,v 1.17 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -64,7 +64,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o) diff --git a/crypto/ocsp/ocsp_cl.c b/crypto/ocsp/ocsp_cl.c index bcc484c3..77470202 100644 --- a/crypto/ocsp/ocsp_cl.c +++ b/crypto/ocsp/ocsp_cl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp_cl.c,v 1.21 2022/01/07 09:45:52 tb Exp $ */ +/* $OpenBSD: ocsp_cl.c,v 1.22 2022/12/26 07:18:52 jmc Exp $ */ /* Written by Tom Titchener for the OpenSSL * project. */ @@ -215,7 +215,7 @@ OCSP_response_get1_basic(OCSP_RESPONSE *resp) return ASN1_item_unpack(rb->response, &OCSP_BASICRESP_it); } -/* Return number of OCSP_SINGLERESP reponses present in +/* Return number of OCSP_SINGLERESP responses present in * a basic response. */ int diff --git a/crypto/ocsp/ocsp_ext.c b/crypto/ocsp/ocsp_ext.c index 1400ad70..9605d859 100644 --- a/crypto/ocsp/ocsp_ext.c +++ b/crypto/ocsp/ocsp_ext.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp_ext.c,v 1.20 2022/01/07 09:45:52 tb Exp $ */ +/* $OpenBSD: ocsp_ext.c,v 1.22 2022/12/26 07:18:52 jmc Exp $ */ /* Written by Tom Titchener for the OpenSSL * project. */ @@ -71,7 +71,7 @@ #include #include "ocsp_local.h" -#include "x509_lcl.h" +#include "x509_local.h" /* Standard wrapper functions for extensions */ @@ -321,7 +321,7 @@ OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc) /* Nonce handling functions */ -/* Add a nonce to an extension stack. A nonce can be specificed or if NULL +/* Add a nonce to an extension stack. A nonce can be specified or if NULL * a random nonce will be generated. * Note: OpenSSL 0.9.7d and later create an OCTET STRING containing the * nonce, previous versions used the raw nonce. diff --git a/crypto/ocsp/ocsp_vfy.c b/crypto/ocsp/ocsp_vfy.c index 0da402fd..3c123188 100644 --- a/crypto/ocsp/ocsp_vfy.c +++ b/crypto/ocsp/ocsp_vfy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ocsp_vfy.c,v 1.21 2022/01/22 00:33:02 inoguchi Exp $ */ +/* $OpenBSD: ocsp_vfy.c,v 1.22 2022/11/26 16:08:53 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -61,7 +61,7 @@ #include #include "ocsp_local.h" -#include "x509_lcl.h" +#include "x509_local.h" static int ocsp_find_signer(X509 **psigner, OCSP_BASICRESP *bs, STACK_OF(X509) *certs, X509_STORE *st, unsigned long flags); diff --git a/crypto/pem/pem_info.c b/crypto/pem/pem_info.c index aecdbb2e..3cca828c 100644 --- a/crypto/pem/pem_info.c +++ b/crypto/pem/pem_info.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pem_info.c,v 1.25 2021/12/12 21:30:14 tb Exp $ */ +/* $OpenBSD: pem_info.c,v 1.26 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -75,7 +75,7 @@ #include #endif -#include "evp_locl.h" +#include "evp_local.h" STACK_OF(X509_INFO) * PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c index 7076023e..72cdd41b 100644 --- a/crypto/pem/pem_lib.c +++ b/crypto/pem/pem_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pem_lib.c,v 1.51 2022/07/31 09:48:27 tb Exp $ */ +/* $OpenBSD: pem_lib.c,v 1.52 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -78,8 +78,8 @@ #include #endif -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" #define MIN_LENGTH 4 diff --git a/crypto/pem/pem_pkey.c b/crypto/pem/pem_pkey.c index 2e580039..fa2d38f5 100644 --- a/crypto/pem/pem_pkey.c +++ b/crypto/pem/pem_pkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pem_pkey.c,v 1.25 2021/12/24 12:59:18 tb Exp $ */ +/* $OpenBSD: pem_pkey.c,v 1.26 2022/11/26 16:08:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -73,8 +73,8 @@ #include #endif -#include "asn1_locl.h" -#include "evp_locl.h" +#include "asn1_local.h" +#include "evp_local.h" int pem_check_suffix(const char *pem_str, const char *suffix); diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c index dffe1a36..1417a7b3 100644 --- a/crypto/pem/pvkfmt.c +++ b/crypto/pem/pvkfmt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pvkfmt.c,v 1.25 2022/01/07 09:55:31 tb Exp $ */ +/* $OpenBSD: pvkfmt.c,v 1.26 2022/11/26 16:08:53 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ @@ -73,10 +73,10 @@ #include #include -#include "bn_lcl.h" -#include "dsa_locl.h" -#include "evp_locl.h" -#include "rsa_locl.h" +#include "bn_local.h" +#include "dsa_local.h" +#include "evp_local.h" +#include "rsa_local.h" /* Utility function: read a DWORD (4 byte unsigned integer) in little endian * format diff --git a/crypto/pkcs12/p12_add.c b/crypto/pkcs12/p12_add.c index a7b8c1ea..93c7c722 100644 --- a/crypto/pkcs12/p12_add.c +++ b/crypto/pkcs12/p12_add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_add.c,v 1.20 2022/09/11 17:30:13 tb Exp $ */ +/* $OpenBSD: p12_add.c,v 1.22 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -90,6 +90,7 @@ PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, int nid1, int nid2) safebag->type = OBJ_nid2obj(nid2); return safebag; } +LCRYPTO_ALIAS(PKCS12_item_pack_safebag); /* Turn a stack of SAFEBAGS into a PKCS#7 data Contentinfo */ PKCS7 * @@ -117,6 +118,7 @@ PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk) PKCS7_free(p7); return NULL; } +LCRYPTO_ALIAS(PKCS12_pack_p7data); /* Unpack SAFEBAGS from PKCS#7 data ContentInfo */ STACK_OF(PKCS12_SAFEBAG) * @@ -128,6 +130,7 @@ PKCS12_unpack_p7data(PKCS7 *p7) } return ASN1_item_unpack(p7->d.data, &PKCS12_SAFEBAGS_it); } +LCRYPTO_ALIAS(PKCS12_unpack_p7data); /* Turn a stack of SAFEBAGS into a PKCS#7 encrypted data ContentInfo */ @@ -174,6 +177,7 @@ PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, PKCS7_free(p7); return NULL; } +LCRYPTO_ALIAS(PKCS12_pack_p7encdata); STACK_OF(PKCS12_SAFEBAG) * PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen) @@ -184,12 +188,14 @@ PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, int passlen) &PKCS12_SAFEBAGS_it, pass, passlen, p7->d.encrypted->enc_data->enc_data, 1); } +LCRYPTO_ALIAS(PKCS12_unpack_p7encdata); PKCS8_PRIV_KEY_INFO * PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag, const char *pass, int passlen) { return PKCS8_decrypt(bag->value.shkeybag, pass, passlen); } +LCRYPTO_ALIAS(PKCS12_decrypt_skey); int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes) @@ -199,6 +205,7 @@ PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes) return 1; return 0; } +LCRYPTO_ALIAS(PKCS12_pack_authsafes); STACK_OF(PKCS7) * PKCS12_unpack_authsafes(const PKCS12 *p12) @@ -210,3 +217,4 @@ PKCS12_unpack_authsafes(const PKCS12 *p12) return ASN1_item_unpack(p12->authsafes->d.data, &PKCS12_AUTHSAFES_it); } +LCRYPTO_ALIAS(PKCS12_unpack_authsafes); diff --git a/crypto/pkcs12/p12_asn.c b/crypto/pkcs12/p12_asn.c index f8239eac..a9decccb 100644 --- a/crypto/pkcs12/p12_asn.c +++ b/crypto/pkcs12/p12_asn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_asn.c,v 1.12 2022/08/20 09:16:18 tb Exp $ */ +/* $OpenBSD: p12_asn.c,v 1.14 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -106,24 +106,28 @@ d2i_PKCS12(PKCS12 **a, const unsigned char **in, long len) return (PKCS12 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS12_it); } +LCRYPTO_ALIAS(d2i_PKCS12); int i2d_PKCS12(PKCS12 *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS12_it); } +LCRYPTO_ALIAS(i2d_PKCS12); PKCS12 * PKCS12_new(void) { return (PKCS12 *)ASN1_item_new(&PKCS12_it); } +LCRYPTO_ALIAS(PKCS12_new); void PKCS12_free(PKCS12 *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS12_it); } +LCRYPTO_ALIAS(PKCS12_free); static const ASN1_TEMPLATE PKCS12_MAC_DATA_seq_tt[] = { { @@ -166,24 +170,28 @@ d2i_PKCS12_MAC_DATA(PKCS12_MAC_DATA **a, const unsigned char **in, long len) return (PKCS12_MAC_DATA *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS12_MAC_DATA_it); } +LCRYPTO_ALIAS(d2i_PKCS12_MAC_DATA); int i2d_PKCS12_MAC_DATA(PKCS12_MAC_DATA *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS12_MAC_DATA_it); } +LCRYPTO_ALIAS(i2d_PKCS12_MAC_DATA); PKCS12_MAC_DATA * PKCS12_MAC_DATA_new(void) { return (PKCS12_MAC_DATA *)ASN1_item_new(&PKCS12_MAC_DATA_it); } +LCRYPTO_ALIAS(PKCS12_MAC_DATA_new); void PKCS12_MAC_DATA_free(PKCS12_MAC_DATA *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS12_MAC_DATA_it); } +LCRYPTO_ALIAS(PKCS12_MAC_DATA_free); static const ASN1_TEMPLATE bag_default_tt = { .flags = ASN1_TFLG_EXPLICIT, @@ -272,24 +280,28 @@ d2i_PKCS12_BAGS(PKCS12_BAGS **a, const unsigned char **in, long len) return (PKCS12_BAGS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS12_BAGS_it); } +LCRYPTO_ALIAS(d2i_PKCS12_BAGS); int i2d_PKCS12_BAGS(PKCS12_BAGS *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS12_BAGS_it); } +LCRYPTO_ALIAS(i2d_PKCS12_BAGS); PKCS12_BAGS * PKCS12_BAGS_new(void) { return (PKCS12_BAGS *)ASN1_item_new(&PKCS12_BAGS_it); } +LCRYPTO_ALIAS(PKCS12_BAGS_new); void PKCS12_BAGS_free(PKCS12_BAGS *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS12_BAGS_it); } +LCRYPTO_ALIAS(PKCS12_BAGS_free); static const ASN1_TEMPLATE safebag_default_tt = { .flags = ASN1_TFLG_EXPLICIT, @@ -417,24 +429,28 @@ d2i_PKCS12_SAFEBAG(PKCS12_SAFEBAG **a, const unsigned char **in, long len) return (PKCS12_SAFEBAG *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS12_SAFEBAG_it); } +LCRYPTO_ALIAS(d2i_PKCS12_SAFEBAG); int i2d_PKCS12_SAFEBAG(PKCS12_SAFEBAG *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS12_SAFEBAG_it); } +LCRYPTO_ALIAS(i2d_PKCS12_SAFEBAG); PKCS12_SAFEBAG * PKCS12_SAFEBAG_new(void) { return (PKCS12_SAFEBAG *)ASN1_item_new(&PKCS12_SAFEBAG_it); } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_new); void PKCS12_SAFEBAG_free(PKCS12_SAFEBAG *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS12_SAFEBAG_it); } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_free); /* SEQUENCE OF SafeBag */ static const ASN1_TEMPLATE PKCS12_SAFEBAGS_item_tt = { @@ -473,4 +489,3 @@ const ASN1_ITEM PKCS12_AUTHSAFES_it = { .size = 0, .sname = "PKCS12_AUTHSAFES", }; - diff --git a/crypto/pkcs12/p12_attr.c b/crypto/pkcs12/p12_attr.c index 989a1476..d43b205a 100644 --- a/crypto/pkcs12/p12_attr.c +++ b/crypto/pkcs12/p12_attr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_attr.c,v 1.17 2022/08/20 09:16:18 tb Exp $ */ +/* $OpenBSD: p12_attr.c,v 1.20 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -61,7 +61,7 @@ #include #include "pkcs12_local.h" -#include "x509_lcl.h" +#include "x509_local.h" /* Add a local keyid to a safebag */ @@ -74,6 +74,7 @@ PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, int namelen) else return 0; } +LCRYPTO_ALIAS(PKCS12_add_localkeyid); /* Add key usage to PKCS#8 structure */ @@ -85,6 +86,7 @@ PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage) return PKCS8_pkey_add1_attr_by_NID(p8, NID_key_usage, V_ASN1_BIT_STRING, &us_val, 1); } +LCRYPTO_ALIAS(PKCS8_add_keyusage); /* Add a friendlyname to a safebag */ @@ -97,6 +99,7 @@ PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, int namelen) else return 0; } +LCRYPTO_ALIAS(PKCS12_add_friendlyname_asc); int @@ -109,6 +112,7 @@ PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, const unsigned char *name, else return 0; } +LCRYPTO_ALIAS(PKCS12_add_friendlyname_uni); int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, int namelen) @@ -119,6 +123,7 @@ PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, int namelen) else return 0; } +LCRYPTO_ALIAS(PKCS12_add_CSPName_asc); ASN1_TYPE * PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid) @@ -135,6 +140,7 @@ PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs, int attr_nid) } return NULL; } +LCRYPTO_ALIAS(PKCS12_get_attr_gen); char * PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag) @@ -148,9 +154,11 @@ PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag) return OPENSSL_uni2asc(atype->value.bmpstring->data, atype->value.bmpstring->length); } +LCRYPTO_ALIAS(PKCS12_get_friendlyname); const STACK_OF(X509_ATTRIBUTE) * PKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag) { return bag->attrib; } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_get0_attrs); diff --git a/crypto/pkcs12/p12_crpt.c b/crypto/pkcs12/p12_crpt.c index d21c9c17..e7d30101 100644 --- a/crypto/pkcs12/p12_crpt.c +++ b/crypto/pkcs12/p12_crpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_crpt.c,v 1.15 2021/07/09 14:07:59 tb Exp $ */ +/* $OpenBSD: p12_crpt.c,v 1.17 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -68,6 +68,7 @@ void PKCS12_PBE_add(void) { } +LCRYPTO_ALIAS(PKCS12_PBE_add); int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, @@ -119,3 +120,4 @@ PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, explicit_bzero(iv, EVP_MAX_IV_LENGTH); return ret; } +LCRYPTO_ALIAS(PKCS12_PBE_keyivgen); diff --git a/crypto/pkcs12/p12_crt.c b/crypto/pkcs12/p12_crt.c index 794b749f..90a0cbe5 100644 --- a/crypto/pkcs12/p12_crt.c +++ b/crypto/pkcs12/p12_crt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_crt.c,v 1.20 2022/08/20 09:16:18 tb Exp $ */ +/* $OpenBSD: p12_crt.c,v 1.23 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -113,7 +113,8 @@ PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 *cert, if (pkey && cert) { if (!X509_check_private_key(cert, pkey)) return NULL; - X509_digest(cert, EVP_sha1(), keyid, &keyidlen); + if (!X509_digest(cert, EVP_sha1(), keyid, &keyidlen)) + return NULL; } if (cert) { @@ -183,6 +184,7 @@ PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 *cert, sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free); return NULL; } +LCRYPTO_ALIAS(PKCS12_create); PKCS12_SAFEBAG * PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert) @@ -220,6 +222,7 @@ PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert) return NULL; } +LCRYPTO_ALIAS(PKCS12_add_cert); PKCS12_SAFEBAG * PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, int key_usage, @@ -260,6 +263,7 @@ PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, EVP_PKEY *key, int key_usage, return NULL; } +LCRYPTO_ALIAS(PKCS12_add_key); int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, @@ -303,6 +307,7 @@ PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, return 0; } +LCRYPTO_ALIAS(PKCS12_add_safe); static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags, PKCS12_SAFEBAG *bag) @@ -349,3 +354,4 @@ PKCS12_add_safes(STACK_OF(PKCS7) *safes, int nid_p7) return p12; } +LCRYPTO_ALIAS(PKCS12_add_safes); diff --git a/crypto/pkcs12/p12_decr.c b/crypto/pkcs12/p12_decr.c index c352ba56..ea7f6a5f 100644 --- a/crypto/pkcs12/p12_decr.c +++ b/crypto/pkcs12/p12_decr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_decr.c,v 1.21 2021/12/12 21:30:14 tb Exp $ */ +/* $OpenBSD: p12_decr.c,v 1.24 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -62,7 +62,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* Encrypt/Decrypt a buffer based on password and algor, result in a * malloc'ed buffer @@ -116,6 +116,7 @@ PKCS12_pbe_crypt(const X509_ALGOR *algor, const char *pass, int passlen, return out; } +LCRYPTO_ALIAS(PKCS12_pbe_crypt); /* Decrypt an OCTET STRING and decode ASN1 structure * if zbuf set zero buffer after use. @@ -144,6 +145,7 @@ PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it, free(out); return ret; } +LCRYPTO_ALIAS(PKCS12_item_decrypt_d2i); /* Encode ASN1 structure and encrypt, return OCTET STRING * if zbuf set zero encoding. @@ -182,5 +184,6 @@ PKCS12_item_i2d_encrypt(X509_ALGOR *algor, const ASN1_ITEM *it, ASN1_OCTET_STRING_free(oct); return NULL; } +LCRYPTO_ALIAS(PKCS12_item_i2d_encrypt); IMPLEMENT_PKCS12_STACK_OF(PKCS7) diff --git a/crypto/pkcs12/p12_init.c b/crypto/pkcs12/p12_init.c index e305bde1..09ff0d55 100644 --- a/crypto/pkcs12/p12_init.c +++ b/crypto/pkcs12/p12_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_init.c,v 1.14 2022/08/20 09:16:18 tb Exp $ */ +/* $OpenBSD: p12_init.c,v 1.16 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -98,3 +98,4 @@ PKCS12_init(int mode) PKCS12_free(pkcs12); return NULL; } +LCRYPTO_ALIAS(PKCS12_init); diff --git a/crypto/pkcs12/p12_key.c b/crypto/pkcs12/p12_key.c index d226525b..8812f1c0 100644 --- a/crypto/pkcs12/p12_key.c +++ b/crypto/pkcs12/p12_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_key.c,v 1.31 2022/07/30 11:27:06 tb Exp $ */ +/* $OpenBSD: p12_key.c,v 1.34 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -63,7 +63,7 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" /* PKCS12 compatible key/IV generation */ #ifndef min @@ -93,6 +93,7 @@ PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, freezero(unipass, uniplen); return ret; } +LCRYPTO_ALIAS(PKCS12_key_gen_asc); int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, @@ -193,3 +194,4 @@ PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, return ret; } +LCRYPTO_ALIAS(PKCS12_key_gen_uni); diff --git a/crypto/pkcs12/p12_kiss.c b/crypto/pkcs12/p12_kiss.c index f7551856..48bbd137 100644 --- a/crypto/pkcs12/p12_kiss.c +++ b/crypto/pkcs12/p12_kiss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_kiss.c,v 1.25 2022/08/20 09:16:18 tb Exp $ */ +/* $OpenBSD: p12_kiss.c,v 1.27 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -168,6 +168,7 @@ PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, return 0; } +LCRYPTO_ALIAS(PKCS12_parse); /* Parse the outer PKCS#12 structure */ diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c index b1aafe9b..f0e6df9e 100644 --- a/crypto/pkcs12/p12_mutl.c +++ b/crypto/pkcs12/p12_mutl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_mutl.c,v 1.32 2022/08/20 09:16:18 tb Exp $ */ +/* $OpenBSD: p12_mutl.c,v 1.35 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -68,16 +68,17 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" #include "hmac_local.h" #include "pkcs12_local.h" -#include "x509_lcl.h" +#include "x509_local.h" int PKCS12_mac_present(const PKCS12 *p12) { return p12->mac != NULL; } +LCRYPTO_ALIAS(PKCS12_mac_present); void PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac, const X509_ALGOR **pmacalg, @@ -105,6 +106,7 @@ PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac, const X509_ALGOR **pmacalg, if (piter != NULL) *piter = p12->mac->iter; } +LCRYPTO_ALIAS(PKCS12_get0_mac); /* Generate a MAC */ int @@ -167,6 +169,7 @@ PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, return ret; } +LCRYPTO_ALIAS(PKCS12_gen_mac); /* Verify the mac */ int @@ -188,6 +191,7 @@ PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen) return 0; return 1; } +LCRYPTO_ALIAS(PKCS12_verify_mac); /* Set a mac */ @@ -215,6 +219,7 @@ PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, unsigned char *salt, } return 1; } +LCRYPTO_ALIAS(PKCS12_set_mac); /* Set up a mac structure */ int @@ -254,4 +259,5 @@ PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, return 1; } +LCRYPTO_ALIAS(PKCS12_setup_mac); #endif diff --git a/crypto/pkcs12/p12_npas.c b/crypto/pkcs12/p12_npas.c index 7141e3ce..30dd2ef8 100644 --- a/crypto/pkcs12/p12_npas.c +++ b/crypto/pkcs12/p12_npas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_npas.c,v 1.15 2022/08/20 09:16:18 tb Exp $ */ +/* $OpenBSD: p12_npas.c,v 1.18 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -64,7 +64,7 @@ #include #include "pkcs12_local.h" -#include "x509_lcl.h" +#include "x509_local.h" /* PKCS#12 password change routine */ @@ -103,6 +103,7 @@ PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass) return 1; } +LCRYPTO_ALIAS(PKCS12_newpass); /* Parse the outer PKCS#12 structure */ diff --git a/crypto/pkcs12/p12_p8d.c b/crypto/pkcs12/p12_p8d.c index ce1b28bc..dd5e8d98 100644 --- a/crypto/pkcs12/p12_p8d.c +++ b/crypto/pkcs12/p12_p8d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_p8d.c,v 1.8 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: p12_p8d.c,v 1.11 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -60,7 +60,7 @@ #include -#include "x509_lcl.h" +#include "x509_local.h" PKCS8_PRIV_KEY_INFO * PKCS8_decrypt(const X509_SIG *p8, const char *pass, int passlen) @@ -68,3 +68,4 @@ PKCS8_decrypt(const X509_SIG *p8, const char *pass, int passlen) return PKCS12_item_decrypt_d2i(p8->algor, &PKCS8_PRIV_KEY_INFO_it, pass, passlen, p8->digest, 1); } +LCRYPTO_ALIAS(PKCS8_decrypt); diff --git a/crypto/pkcs12/p12_p8e.c b/crypto/pkcs12/p12_p8e.c index 7f5f61d6..87c4be56 100644 --- a/crypto/pkcs12/p12_p8e.c +++ b/crypto/pkcs12/p12_p8e.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_p8e.c,v 1.9 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: p12_p8e.c,v 1.12 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -61,7 +61,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" X509_SIG * PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, @@ -100,3 +100,4 @@ PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, X509_SIG_free(p8); return NULL; } +LCRYPTO_ALIAS(PKCS8_encrypt); diff --git a/crypto/pkcs12/p12_sbag.c b/crypto/pkcs12/p12_sbag.c index cbcb02d2..b7772b67 100644 --- a/crypto/pkcs12/p12_sbag.c +++ b/crypto/pkcs12/p12_sbag.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_sbag.c,v 1.5 2022/08/20 09:16:18 tb Exp $ */ +/* $OpenBSD: p12_sbag.c,v 1.8 2023/02/16 08:38:17 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project * 1999-2018. @@ -63,19 +63,21 @@ #include #include "pkcs12_local.h" -#include "x509_lcl.h" +#include "x509_local.h" const ASN1_TYPE * PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag, int attr_nid) { return PKCS12_get_attr_gen(bag->attrib, attr_nid); } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_get0_attr); ASN1_TYPE * PKCS8_get_attr(PKCS8_PRIV_KEY_INFO *p8, int attr_nid) { return PKCS12_get_attr_gen(p8->attributes, attr_nid); } +LCRYPTO_ALIAS(PKCS8_get_attr); const PKCS8_PRIV_KEY_INFO * PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag) @@ -85,6 +87,7 @@ PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag) return bag->value.keybag; } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_get0_p8inf); const X509_SIG * PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag) @@ -94,6 +97,7 @@ PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag) return bag->value.shkeybag; } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_get0_pkcs8); const STACK_OF(PKCS12_SAFEBAG) * PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag) @@ -103,18 +107,21 @@ PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag) return bag->value.safes; } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_get0_safes); const ASN1_OBJECT * PKCS12_SAFEBAG_get0_type(const PKCS12_SAFEBAG *bag) { return bag->type; } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_get0_type); int PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag) { return OBJ_obj2nid(bag->type); } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_get_nid); int PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag) @@ -129,6 +136,7 @@ PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag) return -1; } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_get_bag_nid); X509 * PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag) @@ -139,6 +147,7 @@ PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag) return NULL; return ASN1_item_unpack(bag->value.bag->value.octet, &X509_it); } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_get1_cert); X509_CRL * PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag) @@ -149,6 +158,7 @@ PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag) return NULL; return ASN1_item_unpack(bag->value.bag->value.octet, &X509_CRL_it); } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_get1_crl); PKCS12_SAFEBAG * PKCS12_SAFEBAG_create_cert(X509 *x509) @@ -156,6 +166,7 @@ PKCS12_SAFEBAG_create_cert(X509 *x509) return PKCS12_item_pack_safebag(x509, &X509_it, NID_x509Certificate, NID_certBag); } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_create_cert); PKCS12_SAFEBAG * PKCS12_SAFEBAG_create_crl(X509_CRL *crl) @@ -163,6 +174,7 @@ PKCS12_SAFEBAG_create_crl(X509_CRL *crl) return PKCS12_item_pack_safebag(crl, &X509_CRL_it, NID_x509Crl, NID_crlBag); } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_create_crl); /* Turn PKCS8 object into a keybag */ @@ -181,6 +193,7 @@ PKCS12_SAFEBAG_create0_p8inf(PKCS8_PRIV_KEY_INFO *p8) return bag; } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_create0_p8inf); /* Turn PKCS8 object into a shrouded keybag */ @@ -200,6 +213,7 @@ PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8) return bag; } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_create0_pkcs8); PKCS12_SAFEBAG * PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid, const char *pass, int passlen, @@ -223,3 +237,4 @@ PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid, const char *pass, int passlen, return bag; } +LCRYPTO_ALIAS(PKCS12_SAFEBAG_create_pkcs8_encrypt); diff --git a/crypto/pkcs12/p12_utl.c b/crypto/pkcs12/p12_utl.c index 4fe557f6..72692a9e 100644 --- a/crypto/pkcs12/p12_utl.c +++ b/crypto/pkcs12/p12_utl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p12_utl.c,v 1.19 2022/09/11 17:30:13 tb Exp $ */ +/* $OpenBSD: p12_utl.c,v 1.21 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -100,6 +100,7 @@ OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen) *uni = unitmp; return unitmp; } +LCRYPTO_ALIAS(OPENSSL_asc2uni); char * OPENSSL_uni2asc(const unsigned char *uni, int unilen) @@ -125,27 +126,32 @@ OPENSSL_uni2asc(const unsigned char *uni, int unilen) asctmp[asclen - 1] = '\0'; return asctmp; } +LCRYPTO_ALIAS(OPENSSL_uni2asc); int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12) { return ASN1_item_i2d_bio(&PKCS12_it, bp, p12); } +LCRYPTO_ALIAS(i2d_PKCS12_bio); int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12) { return ASN1_item_i2d_fp(&PKCS12_it, fp, p12); } +LCRYPTO_ALIAS(i2d_PKCS12_fp); PKCS12 * d2i_PKCS12_bio(BIO *bp, PKCS12 **p12) { return ASN1_item_d2i_bio(&PKCS12_it, bp, p12); } +LCRYPTO_ALIAS(d2i_PKCS12_bio); PKCS12 * d2i_PKCS12_fp(FILE *fp, PKCS12 **p12) { return ASN1_item_d2i_fp(&PKCS12_it, fp, p12); } +LCRYPTO_ALIAS(d2i_PKCS12_fp); diff --git a/crypto/pkcs12/pk12err.c b/crypto/pkcs12/pk12err.c index 23166bfd..3af03528 100644 --- a/crypto/pkcs12/pk12err.c +++ b/crypto/pkcs12/pk12err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk12err.c,v 1.12 2022/07/12 14:42:50 kn Exp $ */ +/* $OpenBSD: pk12err.c,v 1.14 2023/02/16 08:38:17 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -108,3 +108,4 @@ ERR_load_PKCS12_strings(void) } #endif } +LCRYPTO_ALIAS(ERR_load_PKCS12_strings); diff --git a/crypto/pkcs12/pkcs12_local.h b/crypto/pkcs12/pkcs12_local.h index 8723fdb2..1d6f0558 100644 --- a/crypto/pkcs12/pkcs12_local.h +++ b/crypto/pkcs12/pkcs12_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pkcs12_local.h,v 1.2 2022/09/11 17:30:13 tb Exp $ */ +/* $OpenBSD: pkcs12_local.h,v 1.3 2022/11/26 17:23:18 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -98,4 +98,4 @@ struct pkcs12_bag_st { __END_HIDDEN_DECLS -#endif /* HEADER_PKCS12_LOCAL_H */ +#endif /* !HEADER_PKCS12_LOCAL_H */ diff --git a/crypto/pkcs7/bio_pk7.c b/crypto/pkcs7/bio_pk7.c index ad3c5e26..83cf70fd 100644 --- a/crypto/pkcs7/bio_pk7.c +++ b/crypto/pkcs7/bio_pk7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_pk7.c,v 1.5 2016/12/30 15:38:13 jsing Exp $ */ +/* $OpenBSD: bio_pk7.c,v 1.7 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -64,3 +64,4 @@ BIO_new_PKCS7(BIO *out, PKCS7 *p7) { return BIO_new_NDEF(out, (ASN1_VALUE *)p7, &PKCS7_it); } +LCRYPTO_ALIAS(BIO_new_PKCS7); diff --git a/crypto/pkcs7/pk7_asn1.c b/crypto/pkcs7/pk7_asn1.c index 66659051..f24f6be3 100644 --- a/crypto/pkcs7/pk7_asn1.c +++ b/crypto/pkcs7/pk7_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_asn1.c,v 1.13 2022/01/14 08:16:13 tb Exp $ */ +/* $OpenBSD: pk7_asn1.c,v 1.16 2023/03/12 17:29:02 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -163,6 +163,7 @@ pk7_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) case ASN1_OP_STREAM_PRE: if (PKCS7_stream(&sarg->boundary, *pp7) <= 0) return 0; + /* FALLTHROUGH */ case ASN1_OP_DETACHED_PRE: sarg->ndef_bio = PKCS7_dataInit(*pp7, sarg->out); @@ -221,36 +222,42 @@ d2i_PKCS7(PKCS7 **a, const unsigned char **in, long len) return (PKCS7 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS7_it); } +LCRYPTO_ALIAS(d2i_PKCS7); int i2d_PKCS7(PKCS7 *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_it); } +LCRYPTO_ALIAS(i2d_PKCS7); PKCS7 * PKCS7_new(void) { return (PKCS7 *)ASN1_item_new(&PKCS7_it); } +LCRYPTO_ALIAS(PKCS7_new); void PKCS7_free(PKCS7 *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS7_it); } +LCRYPTO_ALIAS(PKCS7_free); int i2d_PKCS7_NDEF(PKCS7 *a, unsigned char **out) { return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, &PKCS7_it); } +LCRYPTO_ALIAS(i2d_PKCS7_NDEF); PKCS7 * PKCS7_dup(PKCS7 *x) { return ASN1_item_dup(&PKCS7_it, x); } +LCRYPTO_ALIAS(PKCS7_dup); static const ASN1_TEMPLATE PKCS7_SIGNED_seq_tt[] = { { @@ -314,24 +321,28 @@ d2i_PKCS7_SIGNED(PKCS7_SIGNED **a, const unsigned char **in, long len) return (PKCS7_SIGNED *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS7_SIGNED_it); } +LCRYPTO_ALIAS(d2i_PKCS7_SIGNED); int i2d_PKCS7_SIGNED(PKCS7_SIGNED *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_SIGNED_it); } +LCRYPTO_ALIAS(i2d_PKCS7_SIGNED); PKCS7_SIGNED * PKCS7_SIGNED_new(void) { return (PKCS7_SIGNED *)ASN1_item_new(&PKCS7_SIGNED_it); } +LCRYPTO_ALIAS(PKCS7_SIGNED_new); void PKCS7_SIGNED_free(PKCS7_SIGNED *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS7_SIGNED_it); } +LCRYPTO_ALIAS(PKCS7_SIGNED_free); /* Minor tweak to operation: free up EVP_PKEY */ static int @@ -426,24 +437,28 @@ d2i_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO **a, const unsigned char **in, long len) return (PKCS7_SIGNER_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS7_SIGNER_INFO_it); } +LCRYPTO_ALIAS(d2i_PKCS7_SIGNER_INFO); int i2d_PKCS7_SIGNER_INFO(PKCS7_SIGNER_INFO *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_SIGNER_INFO_it); } +LCRYPTO_ALIAS(i2d_PKCS7_SIGNER_INFO); PKCS7_SIGNER_INFO * PKCS7_SIGNER_INFO_new(void) { return (PKCS7_SIGNER_INFO *)ASN1_item_new(&PKCS7_SIGNER_INFO_it); } +LCRYPTO_ALIAS(PKCS7_SIGNER_INFO_new); void PKCS7_SIGNER_INFO_free(PKCS7_SIGNER_INFO *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS7_SIGNER_INFO_it); } +LCRYPTO_ALIAS(PKCS7_SIGNER_INFO_free); static const ASN1_TEMPLATE PKCS7_ISSUER_AND_SERIAL_seq_tt[] = { { @@ -479,24 +494,28 @@ d2i_PKCS7_ISSUER_AND_SERIAL(PKCS7_ISSUER_AND_SERIAL **a, const unsigned char **i return (PKCS7_ISSUER_AND_SERIAL *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS7_ISSUER_AND_SERIAL_it); } +LCRYPTO_ALIAS(d2i_PKCS7_ISSUER_AND_SERIAL); int i2d_PKCS7_ISSUER_AND_SERIAL(PKCS7_ISSUER_AND_SERIAL *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ISSUER_AND_SERIAL_it); } +LCRYPTO_ALIAS(i2d_PKCS7_ISSUER_AND_SERIAL); PKCS7_ISSUER_AND_SERIAL * PKCS7_ISSUER_AND_SERIAL_new(void) { return (PKCS7_ISSUER_AND_SERIAL *)ASN1_item_new(&PKCS7_ISSUER_AND_SERIAL_it); } +LCRYPTO_ALIAS(PKCS7_ISSUER_AND_SERIAL_new); void PKCS7_ISSUER_AND_SERIAL_free(PKCS7_ISSUER_AND_SERIAL *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ISSUER_AND_SERIAL_it); } +LCRYPTO_ALIAS(PKCS7_ISSUER_AND_SERIAL_free); static const ASN1_TEMPLATE PKCS7_ENVELOPE_seq_tt[] = { { @@ -539,24 +558,28 @@ d2i_PKCS7_ENVELOPE(PKCS7_ENVELOPE **a, const unsigned char **in, long len) return (PKCS7_ENVELOPE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS7_ENVELOPE_it); } +LCRYPTO_ALIAS(d2i_PKCS7_ENVELOPE); int i2d_PKCS7_ENVELOPE(PKCS7_ENVELOPE *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ENVELOPE_it); } +LCRYPTO_ALIAS(i2d_PKCS7_ENVELOPE); PKCS7_ENVELOPE * PKCS7_ENVELOPE_new(void) { return (PKCS7_ENVELOPE *)ASN1_item_new(&PKCS7_ENVELOPE_it); } +LCRYPTO_ALIAS(PKCS7_ENVELOPE_new); void PKCS7_ENVELOPE_free(PKCS7_ENVELOPE *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ENVELOPE_it); } +LCRYPTO_ALIAS(PKCS7_ENVELOPE_free); /* Minor tweak to operation: free up X509 */ static int @@ -625,24 +648,28 @@ d2i_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO **a, const unsigned char **in, long len) return (PKCS7_RECIP_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS7_RECIP_INFO_it); } +LCRYPTO_ALIAS(d2i_PKCS7_RECIP_INFO); int i2d_PKCS7_RECIP_INFO(PKCS7_RECIP_INFO *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_RECIP_INFO_it); } +LCRYPTO_ALIAS(i2d_PKCS7_RECIP_INFO); PKCS7_RECIP_INFO * PKCS7_RECIP_INFO_new(void) { return (PKCS7_RECIP_INFO *)ASN1_item_new(&PKCS7_RECIP_INFO_it); } +LCRYPTO_ALIAS(PKCS7_RECIP_INFO_new); void PKCS7_RECIP_INFO_free(PKCS7_RECIP_INFO *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS7_RECIP_INFO_it); } +LCRYPTO_ALIAS(PKCS7_RECIP_INFO_free); static const ASN1_TEMPLATE PKCS7_ENC_CONTENT_seq_tt[] = { { @@ -685,24 +712,28 @@ d2i_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT **a, const unsigned char **in, long len) return (PKCS7_ENC_CONTENT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS7_ENC_CONTENT_it); } +LCRYPTO_ALIAS(d2i_PKCS7_ENC_CONTENT); int i2d_PKCS7_ENC_CONTENT(PKCS7_ENC_CONTENT *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ENC_CONTENT_it); } +LCRYPTO_ALIAS(i2d_PKCS7_ENC_CONTENT); PKCS7_ENC_CONTENT * PKCS7_ENC_CONTENT_new(void) { return (PKCS7_ENC_CONTENT *)ASN1_item_new(&PKCS7_ENC_CONTENT_it); } +LCRYPTO_ALIAS(PKCS7_ENC_CONTENT_new); void PKCS7_ENC_CONTENT_free(PKCS7_ENC_CONTENT *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ENC_CONTENT_it); } +LCRYPTO_ALIAS(PKCS7_ENC_CONTENT_free); static const ASN1_TEMPLATE PKCS7_SIGN_ENVELOPE_seq_tt[] = { { @@ -773,24 +804,28 @@ d2i_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE **a, const unsigned char **in, long return (PKCS7_SIGN_ENVELOPE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS7_SIGN_ENVELOPE_it); } +LCRYPTO_ALIAS(d2i_PKCS7_SIGN_ENVELOPE); int i2d_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_SIGN_ENVELOPE_it); } +LCRYPTO_ALIAS(i2d_PKCS7_SIGN_ENVELOPE); PKCS7_SIGN_ENVELOPE * PKCS7_SIGN_ENVELOPE_new(void) { return (PKCS7_SIGN_ENVELOPE *)ASN1_item_new(&PKCS7_SIGN_ENVELOPE_it); } +LCRYPTO_ALIAS(PKCS7_SIGN_ENVELOPE_new); void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS7_SIGN_ENVELOPE_it); } +LCRYPTO_ALIAS(PKCS7_SIGN_ENVELOPE_free); static const ASN1_TEMPLATE PKCS7_ENCRYPT_seq_tt[] = { { @@ -826,24 +861,28 @@ d2i_PKCS7_ENCRYPT(PKCS7_ENCRYPT **a, const unsigned char **in, long len) return (PKCS7_ENCRYPT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS7_ENCRYPT_it); } +LCRYPTO_ALIAS(d2i_PKCS7_ENCRYPT); int i2d_PKCS7_ENCRYPT(PKCS7_ENCRYPT *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_ENCRYPT_it); } +LCRYPTO_ALIAS(i2d_PKCS7_ENCRYPT); PKCS7_ENCRYPT * PKCS7_ENCRYPT_new(void) { return (PKCS7_ENCRYPT *)ASN1_item_new(&PKCS7_ENCRYPT_it); } +LCRYPTO_ALIAS(PKCS7_ENCRYPT_new); void PKCS7_ENCRYPT_free(PKCS7_ENCRYPT *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS7_ENCRYPT_it); } +LCRYPTO_ALIAS(PKCS7_ENCRYPT_free); static const ASN1_TEMPLATE PKCS7_DIGEST_seq_tt[] = { { @@ -893,24 +932,28 @@ d2i_PKCS7_DIGEST(PKCS7_DIGEST **a, const unsigned char **in, long len) return (PKCS7_DIGEST *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKCS7_DIGEST_it); } +LCRYPTO_ALIAS(d2i_PKCS7_DIGEST); int i2d_PKCS7_DIGEST(PKCS7_DIGEST *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKCS7_DIGEST_it); } +LCRYPTO_ALIAS(i2d_PKCS7_DIGEST); PKCS7_DIGEST * PKCS7_DIGEST_new(void) { return (PKCS7_DIGEST *)ASN1_item_new(&PKCS7_DIGEST_it); } +LCRYPTO_ALIAS(PKCS7_DIGEST_new); void PKCS7_DIGEST_free(PKCS7_DIGEST *a) { ASN1_item_free((ASN1_VALUE *)a, &PKCS7_DIGEST_it); } +LCRYPTO_ALIAS(PKCS7_DIGEST_free); /* Specials for authenticated attributes */ @@ -965,3 +1008,41 @@ PKCS7_print_ctx(BIO *out, PKCS7 *x, int indent, const ASN1_PCTX *pctx) return ASN1_item_print(out, (ASN1_VALUE *)x, indent, &PKCS7_it, pctx); } +LCRYPTO_ALIAS(PKCS7_print_ctx); + +PKCS7 * +d2i_PKCS7_bio(BIO *bp, PKCS7 **p7) +{ + return ASN1_item_d2i_bio(&PKCS7_it, bp, p7); +} +LCRYPTO_ALIAS(d2i_PKCS7_bio); + +int +i2d_PKCS7_bio(BIO *bp, PKCS7 *p7) +{ + return ASN1_item_i2d_bio(&PKCS7_it, bp, p7); +} +LCRYPTO_ALIAS(i2d_PKCS7_bio); + +PKCS7 * +d2i_PKCS7_fp(FILE *fp, PKCS7 **p7) +{ + return ASN1_item_d2i_fp(&PKCS7_it, fp, p7); +} +LCRYPTO_ALIAS(d2i_PKCS7_fp); + +int +i2d_PKCS7_fp(FILE *fp, PKCS7 *p7) +{ + return ASN1_item_i2d_fp(&PKCS7_it, fp, p7); +} +LCRYPTO_ALIAS(i2d_PKCS7_fp); + +int +PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, + const EVP_MD *type, unsigned char *md, unsigned int *len) +{ + return(ASN1_item_digest(&PKCS7_ISSUER_AND_SERIAL_it, type, + (char *)data, md, len)); +} +LCRYPTO_ALIAS(PKCS7_ISSUER_AND_SERIAL_digest); diff --git a/crypto/pkcs7/pk7_attr.c b/crypto/pkcs7/pk7_attr.c index f882ba77..5eff5241 100644 --- a/crypto/pkcs7/pk7_attr.c +++ b/crypto/pkcs7/pk7_attr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_attr.c,v 1.12 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: pk7_attr.c,v 1.14 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -79,6 +79,7 @@ PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, STACK_OF(X509_ALGOR) *cap) return PKCS7_add_signed_attribute(si, NID_SMIMECapabilities, V_ASN1_SEQUENCE, seq); } +LCRYPTO_ALIAS(PKCS7_add_attrib_smimecap); STACK_OF(X509_ALGOR) * PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si) @@ -94,6 +95,7 @@ PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si) ASN1_item_d2i(NULL, &p, cap->value.sequence->length, &X509_ALGORS_it); } +LCRYPTO_ALIAS(PKCS7_get_smimecap); /* Basic smime-capabilities OID and optional integer arg */ int @@ -130,6 +132,7 @@ PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg) X509_ALGOR_free(alg); return 0; } +LCRYPTO_ALIAS(PKCS7_simple_smimecap); int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid) @@ -141,6 +144,7 @@ PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid) return PKCS7_add_signed_attribute(si, NID_pkcs9_contentType, V_ASN1_OBJECT, coid); } +LCRYPTO_ALIAS(PKCS7_add_attrib_content_type); int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t) @@ -152,6 +156,7 @@ PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t) return PKCS7_add_signed_attribute(si, NID_pkcs9_signingTime, V_ASN1_UTCTIME, t); } +LCRYPTO_ALIAS(PKCS7_add0_attrib_signing_time); int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, const unsigned char *md, @@ -170,3 +175,4 @@ PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, const unsigned char *md, } return 1; } +LCRYPTO_ALIAS(PKCS7_add1_attrib_digest); diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c index b3140696..d5edaedb 100644 --- a/crypto/pkcs7/pk7_doit.c +++ b/crypto/pkcs7/pk7_doit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_doit.c,v 1.47 2022/05/09 19:19:33 jsing Exp $ */ +/* $OpenBSD: pk7_doit.c,v 1.52 2023/03/09 18:20:10 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,8 +65,8 @@ #include #include -#include "evp_locl.h" -#include "x509_lcl.h" +#include "evp_local.h" +#include "x509_local.h" static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype, void *value); @@ -112,6 +112,7 @@ PKCS7_bio_add_digest(BIO **pbio, X509_ALGOR *alg) { BIO *btmp; const EVP_MD *md; + if ((btmp = BIO_new(BIO_f_md())) == NULL) { PKCS7error(ERR_R_BIO_LIB); goto err; @@ -123,7 +124,11 @@ PKCS7_bio_add_digest(BIO **pbio, X509_ALGOR *alg) goto err; } - BIO_set_md(btmp, md); + if (BIO_set_md(btmp, md) <= 0) { + PKCS7error(ERR_R_BIO_LIB); + goto err; + } + if (*pbio == NULL) *pbio = btmp; else if (!BIO_push(*pbio, btmp)) { @@ -404,6 +409,7 @@ PKCS7_dataInit(PKCS7 *p7, BIO *bio) } return (out); } +LCRYPTO_ALIAS(PKCS7_dataInit); static int pkcs7_cmp_ri(PKCS7_RECIP_INFO *ri, X509 *pcert) @@ -496,7 +502,10 @@ PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) goto err; } - BIO_set_md(btmp, evp_md); + if (BIO_set_md(btmp, evp_md) <= 0) { + PKCS7error(ERR_R_BIO_LIB); + goto err; + } if (out == NULL) out = btmp; else @@ -533,7 +542,7 @@ PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) /* If we haven't got a certificate try each ri in turn */ if (pcert == NULL) { /* Always attempt to decrypt all rinfo even - * after sucess as a defence against MMA timing + * after success as a defence against MMA timing * attacks. */ for (i = 0; i < sk_PKCS7_RECIP_INFO_num(rsk); i++) { @@ -629,6 +638,7 @@ PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert) } return (out); } +LCRYPTO_ALIAS(PKCS7_dataDecode); static BIO * PKCS7_find_digest(EVP_MD_CTX **pmd, BIO *bio, int nid) @@ -857,6 +867,7 @@ PKCS7_dataFinal(PKCS7 *p7, BIO *bio) EVP_MD_CTX_cleanup(&ctx_tmp); return (ret); } +LCRYPTO_ALIAS(PKCS7_dataFinal); int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si) @@ -915,6 +926,7 @@ PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si) EVP_MD_CTX_cleanup(&mctx); return 0; } +LCRYPTO_ALIAS(PKCS7_SIGNER_INFO_sign); int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio, @@ -976,6 +988,7 @@ PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, BIO *bio, return ret; } +LCRYPTO_ALIAS(PKCS7_dataVerify); int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, X509 *x509) @@ -1082,6 +1095,7 @@ PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, X509 *x509) EVP_MD_CTX_cleanup(&mdc_tmp); return (ret); } +LCRYPTO_ALIAS(PKCS7_signatureVerify); PKCS7_ISSUER_AND_SERIAL * PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx) @@ -1104,18 +1118,21 @@ PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx) ri = sk_PKCS7_RECIP_INFO_value(rsk, idx); return (ri->issuer_and_serial); } +LCRYPTO_ALIAS(PKCS7_get_issuer_and_serial); ASN1_TYPE * PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid) { return (get_attribute(si->auth_attr, nid)); } +LCRYPTO_ALIAS(PKCS7_get_signed_attribute); ASN1_TYPE * PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid) { return (get_attribute(si->unauth_attr, nid)); } +LCRYPTO_ALIAS(PKCS7_get_attribute); static ASN1_TYPE * get_attribute(STACK_OF(X509_ATTRIBUTE) *sk, int nid) @@ -1146,6 +1163,7 @@ PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk) return NULL; return astype->value.octet_string; } +LCRYPTO_ALIAS(PKCS7_digest_from_attributes); int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, @@ -1167,6 +1185,7 @@ PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, } return (1); } +LCRYPTO_ALIAS(PKCS7_set_signed_attributes); int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, STACK_OF(X509_ATTRIBUTE) *sk) @@ -1187,6 +1206,7 @@ PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, STACK_OF(X509_ATTRIBUTE) *sk) } return (1); } +LCRYPTO_ALIAS(PKCS7_set_attributes); int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, @@ -1194,12 +1214,14 @@ PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, { return (add_attribute(&(p7si->auth_attr), nid, atrtype, value)); } +LCRYPTO_ALIAS(PKCS7_add_signed_attribute); int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, void *value) { return (add_attribute(&(p7si->unauth_attr), nid, atrtype, value)); } +LCRYPTO_ALIAS(PKCS7_add_attribute); static int add_attribute(STACK_OF(X509_ATTRIBUTE) **sk, int nid, int atrtype, void *value) diff --git a/crypto/pkcs7/pk7_lib.c b/crypto/pkcs7/pk7_lib.c index 7e92df1e..6eda698c 100644 --- a/crypto/pkcs7/pk7_lib.c +++ b/crypto/pkcs7/pk7_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_lib.c,v 1.23 2021/12/12 21:30:14 tb Exp $ */ +/* $OpenBSD: pk7_lib.c,v 1.26 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,9 +62,9 @@ #include #include -#include "asn1_locl.h" -#include "evp_locl.h" -#include "x509_lcl.h" +#include "asn1_local.h" +#include "evp_local.h" +#include "x509_local.h" long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg) @@ -109,6 +109,7 @@ PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg) } return (ret); } +LCRYPTO_ALIAS(PKCS7_ctrl); int PKCS7_content_new(PKCS7 *p7, int type) @@ -128,6 +129,7 @@ PKCS7_content_new(PKCS7 *p7, int type) PKCS7_free(ret); return (0); } +LCRYPTO_ALIAS(PKCS7_content_new); int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data) @@ -158,6 +160,7 @@ PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data) err: return (0); } +LCRYPTO_ALIAS(PKCS7_set_content); int PKCS7_set_type(PKCS7 *p7, int type) @@ -227,6 +230,7 @@ PKCS7_set_type(PKCS7 *p7, int type) err: return (0); } +LCRYPTO_ALIAS(PKCS7_set_type); int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other) @@ -235,6 +239,7 @@ PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other) p7->d.other = other; return 1; } +LCRYPTO_ALIAS(PKCS7_set0_type_other); int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *psi) @@ -290,6 +295,7 @@ PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *psi) return 0; return (1); } +LCRYPTO_ALIAS(PKCS7_add_signer); int PKCS7_add_certificate(PKCS7 *p7, X509 *x509) @@ -323,6 +329,7 @@ PKCS7_add_certificate(PKCS7 *p7, X509 *x509) } return (1); } +LCRYPTO_ALIAS(PKCS7_add_certificate); int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl) @@ -357,6 +364,7 @@ PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl) } return (1); } +LCRYPTO_ALIAS(PKCS7_add_crl); int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, @@ -401,6 +409,7 @@ PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, err: return 0; } +LCRYPTO_ALIAS(PKCS7_SIGNER_INFO_set); PKCS7_SIGNER_INFO * PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey, const EVP_MD *dgst) @@ -430,6 +439,7 @@ PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey, const EVP_MD *dgst) PKCS7_SIGNER_INFO_free(si); return (NULL); } +LCRYPTO_ALIAS(PKCS7_add_signature); int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md) @@ -447,6 +457,7 @@ PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md) PKCS7error(PKCS7_R_WRONG_CONTENT_TYPE); return 1; } +LCRYPTO_ALIAS(PKCS7_set_digest); STACK_OF(PKCS7_SIGNER_INFO) * PKCS7_get_signer_info(PKCS7 *p7) @@ -460,6 +471,7 @@ PKCS7_get_signer_info(PKCS7 *p7) } else return (NULL); } +LCRYPTO_ALIAS(PKCS7_get_signer_info); void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk, @@ -472,6 +484,7 @@ PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk, if (psig) *psig = si->digest_enc_alg; } +LCRYPTO_ALIAS(PKCS7_SIGNER_INFO_get0_algs); void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc) @@ -479,6 +492,7 @@ PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc) if (penc) *penc = ri->key_enc_algor; } +LCRYPTO_ALIAS(PKCS7_RECIP_INFO_get0_alg); PKCS7_RECIP_INFO * PKCS7_add_recipient(PKCS7 *p7, X509 *x509) @@ -497,6 +511,7 @@ PKCS7_add_recipient(PKCS7 *p7, X509 *x509) PKCS7_RECIP_INFO_free(ri); return NULL; } +LCRYPTO_ALIAS(PKCS7_add_recipient); int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri) @@ -521,6 +536,7 @@ PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri) return 0; return (1); } +LCRYPTO_ALIAS(PKCS7_add_recipient_info); int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509) @@ -567,6 +583,7 @@ PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509) EVP_PKEY_free(pkey); return 0; } +LCRYPTO_ALIAS(PKCS7_RECIP_INFO_set); X509 * PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si) @@ -578,6 +595,7 @@ PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si) else return (NULL); } +LCRYPTO_ALIAS(PKCS7_cert_from_signer_info); int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher) @@ -608,6 +626,7 @@ PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher) ec->cipher = cipher; return 1; } +LCRYPTO_ALIAS(PKCS7_set_cipher); int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7) @@ -652,3 +671,4 @@ PKCS7_stream(unsigned char ***boundary, PKCS7 *p7) return 1; } +LCRYPTO_ALIAS(PKCS7_stream); diff --git a/crypto/pkcs7/pk7_mime.c b/crypto/pkcs7/pk7_mime.c index fad331bf..d5bc031e 100644 --- a/crypto/pkcs7/pk7_mime.c +++ b/crypto/pkcs7/pk7_mime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_mime.c,v 1.13 2016/12/30 15:38:13 jsing Exp $ */ +/* $OpenBSD: pk7_mime.c,v 1.15 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -66,6 +66,7 @@ i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags) return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)p7, in, flags, &PKCS7_it); } +LCRYPTO_ALIAS(i2d_PKCS7_bio_stream); int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags) @@ -73,6 +74,7 @@ PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags) return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *) p7, in, flags, "PKCS7", &PKCS7_it); } +LCRYPTO_ALIAS(PEM_write_bio_PKCS7_stream); int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) @@ -90,9 +92,11 @@ SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags) return SMIME_write_ASN1(bio, (ASN1_VALUE *)p7, data, flags, ctype_nid, NID_undef, mdalgs, &PKCS7_it); } +LCRYPTO_ALIAS(SMIME_write_PKCS7); PKCS7 * SMIME_read_PKCS7(BIO *bio, BIO **bcont) { return (PKCS7 *)SMIME_read_ASN1(bio, bcont, &PKCS7_it); } +LCRYPTO_ALIAS(SMIME_read_PKCS7); diff --git a/crypto/pkcs7/pk7_smime.c b/crypto/pkcs7/pk7_smime.c index f11d23e3..c113ac39 100644 --- a/crypto/pkcs7/pk7_smime.c +++ b/crypto/pkcs7/pk7_smime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_smime.c,v 1.23 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: pk7_smime.c,v 1.26 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -64,7 +64,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static int pkcs7_copy_existing_digest(PKCS7 *p7, PKCS7_SIGNER_INFO *si); @@ -111,6 +111,7 @@ PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, PKCS7_free(p7); return NULL; } +LCRYPTO_ALIAS(PKCS7_sign); int PKCS7_final(PKCS7 *p7, BIO *data, int flags) @@ -139,6 +140,7 @@ PKCS7_final(PKCS7 *p7, BIO *data, int flags) return ret; } +LCRYPTO_ALIAS(PKCS7_final); /* Check to see if a cipher exists and if so add S/MIME capabilities */ @@ -221,6 +223,7 @@ PKCS7_sign_add_signer(PKCS7 *p7, X509 *signcert, EVP_PKEY *pkey, sk_X509_ALGOR_pop_free(smcap, X509_ALGOR_free); return NULL; } +LCRYPTO_ALIAS(PKCS7_sign_add_signer); /* Search for a digest matching SignerInfo digest type and if found * copy across. @@ -423,6 +426,7 @@ PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, BIO *indata, return ret; } +LCRYPTO_ALIAS(PKCS7_verify); STACK_OF(X509) * PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags) @@ -481,6 +485,7 @@ PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags) } return signers; } +LCRYPTO_ALIAS(PKCS7_get0_signers); /* Build a complete PKCS#7 enveloped data */ @@ -524,6 +529,7 @@ PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, PKCS7_free(p7); return NULL; } +LCRYPTO_ALIAS(PKCS7_encrypt); int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags) @@ -590,3 +596,4 @@ PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags) return ret; } } +LCRYPTO_ALIAS(PKCS7_decrypt); diff --git a/crypto/pkcs7/pkcs7err.c b/crypto/pkcs7/pkcs7err.c index bd3791e3..d3ca0ec6 100644 --- a/crypto/pkcs7/pkcs7err.c +++ b/crypto/pkcs7/pkcs7err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkcs7err.c,v 1.13 2022/07/12 14:42:50 kn Exp $ */ +/* $OpenBSD: pkcs7err.c,v 1.15 2023/02/16 08:38:17 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * @@ -140,3 +140,4 @@ ERR_load_PKCS7_strings(void) } #endif } +LCRYPTO_ALIAS(ERR_load_PKCS7_strings); diff --git a/crypto/rc2/rc2_cbc.c b/crypto/rc2/rc2_cbc.c index a947f1d3..44204aff 100644 --- a/crypto/rc2/rc2_cbc.c +++ b/crypto/rc2/rc2_cbc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc2_cbc.c,v 1.5 2014/10/28 07:35:59 jsg Exp $ */ +/* $OpenBSD: rc2_cbc.c,v 1.6 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "rc2_locl.h" +#include "rc2_local.h" void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, RC2_KEY *ks, unsigned char *iv, int encrypt) diff --git a/crypto/rc2/rc2_ecb.c b/crypto/rc2/rc2_ecb.c index 76873752..84a671a5 100644 --- a/crypto/rc2/rc2_ecb.c +++ b/crypto/rc2/rc2_ecb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc2_ecb.c,v 1.6 2014/07/09 11:10:51 bcook Exp $ */ +/* $OpenBSD: rc2_ecb.c,v 1.7 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "rc2_locl.h" +#include "rc2_local.h" #include /* RC2 as implemented frm a posting from diff --git a/crypto/rc2/rc2_locl.h b/crypto/rc2/rc2_local.h similarity index 99% rename from crypto/rc2/rc2_locl.h rename to crypto/rc2/rc2_local.h index 73d8c68c..c8bb468d 100644 --- a/crypto/rc2/rc2_locl.h +++ b/crypto/rc2/rc2_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rc2_locl.h,v 1.2 2014/06/12 15:49:30 deraadt Exp $ */ +/* $OpenBSD: rc2_local.h,v 1.1 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * diff --git a/crypto/rc2/rc2_skey.c b/crypto/rc2/rc2_skey.c index 964db098..82161b16 100644 --- a/crypto/rc2/rc2_skey.c +++ b/crypto/rc2/rc2_skey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc2_skey.c,v 1.12 2014/06/12 15:49:30 deraadt Exp $ */ +/* $OpenBSD: rc2_skey.c,v 1.13 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -58,7 +58,7 @@ #include #include -#include "rc2_locl.h" +#include "rc2_local.h" static const unsigned char key_table[256]={ 0xd9,0x78,0xf9,0xc4,0x19,0xdd,0xb5,0xed,0x28,0xe9,0xfd,0x79, diff --git a/crypto/rc2/rc2cfb64.c b/crypto/rc2/rc2cfb64.c index 95366444..ebdeb9ba 100644 --- a/crypto/rc2/rc2cfb64.c +++ b/crypto/rc2/rc2cfb64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc2cfb64.c,v 1.5 2014/10/28 07:35:59 jsg Exp $ */ +/* $OpenBSD: rc2cfb64.c,v 1.6 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "rc2_locl.h" +#include "rc2_local.h" /* The input and output encrypted as though 64bit cfb mode is being * used. The extra state information to record how much of the diff --git a/crypto/rc2/rc2ofb64.c b/crypto/rc2/rc2ofb64.c index c47b4137..2aa24135 100644 --- a/crypto/rc2/rc2ofb64.c +++ b/crypto/rc2/rc2ofb64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc2ofb64.c,v 1.5 2014/10/28 07:35:59 jsg Exp $ */ +/* $OpenBSD: rc2ofb64.c,v 1.6 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "rc2_locl.h" +#include "rc2_local.h" /* The input and output encrypted as though 64bit ofb mode is being * used. The extra state information to record how much of the diff --git a/crypto/rc4/rc4-elf-x86_64.S b/crypto/rc4/rc4-elf-x86_64.S index 4f90dd5f..9d9e8aec 100644 --- a/crypto/rc4/rc4-elf-x86_64.S +++ b/crypto/rc4/rc4-elf-x86_64.S @@ -607,13 +607,14 @@ RC4_options: addq $12,%rax .Ldone: retq +.section .rodata .align 64 .Lopts: .byte 114,99,52,40,56,120,44,105,110,116,41,0 .byte 114,99,52,40,56,120,44,99,104,97,114,41,0 .byte 114,99,52,40,49,54,120,44,105,110,116,41,0 -.byte 82,67,52,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .align 64 +.text .size RC4_options,.-RC4_options #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits diff --git a/crypto/rc4/rc4-macosx-x86_64.S b/crypto/rc4/rc4-macosx-x86_64.S index ce58e4ab..f1e2388e 100644 --- a/crypto/rc4/rc4-macosx-x86_64.S +++ b/crypto/rc4/rc4-macosx-x86_64.S @@ -607,11 +607,12 @@ L$8xchar: addq $12,%rax L$done: retq +.section __DATA,__const .p2align 6 L$opts: .byte 114,99,52,40,56,120,44,105,110,116,41,0 .byte 114,99,52,40,56,120,44,99,104,97,114,41,0 .byte 114,99,52,40,49,54,120,44,105,110,116,41,0 -.byte 82,67,52,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 6 +.text diff --git a/crypto/rc4/rc4-masm-x86_64.S b/crypto/rc4/rc4-masm-x86_64.S index a15566ee..d13a5c6a 100644 --- a/crypto/rc4/rc4-masm-x86_64.S +++ b/crypto/rc4/rc4-masm-x86_64.S @@ -702,16 +702,16 @@ $L$8xchar:: add rax,12 $L$done:: DB 0F3h,0C3h ;repret +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 $L$opts:: DB 114,99,52,40,56,120,44,105,110,116,41,0 DB 114,99,52,40,56,120,44,99,104,97,114,41,0 DB 114,99,52,40,49,54,120,44,105,110,116,41,0 -DB 82,67,52,32,102,111,114,32,120,56,54,95,54,52,44,32 -DB 67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97 -DB 112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103 -DB 62,0 ALIGN 64 +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' RC4_options ENDP .text$ ENDS diff --git a/crypto/rc4/rc4-mingw64-x86_64.S b/crypto/rc4/rc4-mingw64-x86_64.S index c149d7eb..e7917e69 100644 --- a/crypto/rc4/rc4-mingw64-x86_64.S +++ b/crypto/rc4/rc4-mingw64-x86_64.S @@ -630,11 +630,12 @@ RC4_options: addq $12,%rax .Ldone: retq +.section .rodata .p2align 6 .Lopts: .byte 114,99,52,40,56,120,44,105,110,116,41,0 .byte 114,99,52,40,56,120,44,99,104,97,114,41,0 .byte 114,99,52,40,49,54,120,44,105,110,116,41,0 -.byte 82,67,52,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 .p2align 6 +.text diff --git a/crypto/rc4/rc4_enc.c b/crypto/rc4/rc4_enc.c index aa2766a1..3763bfa3 100644 --- a/crypto/rc4/rc4_enc.c +++ b/crypto/rc4/rc4_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc4_enc.c,v 1.17 2021/11/09 18:40:21 bcook Exp $ */ +/* $OpenBSD: rc4_enc.c,v 1.18 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -59,7 +59,7 @@ #include #include -#include "rc4_locl.h" +#include "rc4_local.h" /* RC4 as implemented from a posting from * Newsgroups: sci.crypt diff --git a/crypto/rc4/rc4_local.h b/crypto/rc4/rc4_local.h new file mode 100644 index 00000000..61d08a4d --- /dev/null +++ b/crypto/rc4/rc4_local.h @@ -0,0 +1,5 @@ +/* $OpenBSD: rc4_local.h,v 1.1 2022/11/26 16:08:54 tb Exp $ */ + +#ifndef HEADER_RC4_LOCL_H +#define HEADER_RC4_LOCL_H +#endif diff --git a/crypto/rc4/rc4_locl.h b/crypto/rc4/rc4_locl.h deleted file mode 100644 index d2b08064..00000000 --- a/crypto/rc4/rc4_locl.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $OpenBSD: rc4_locl.h,v 1.4 2014/07/11 08:44:49 jsing Exp $ */ - -#ifndef HEADER_RC4_LOCL_H -#define HEADER_RC4_LOCL_H -#endif diff --git a/crypto/rc4/rc4_skey.c b/crypto/rc4/rc4_skey.c index 861941fb..e32a6e84 100644 --- a/crypto/rc4/rc4_skey.c +++ b/crypto/rc4/rc4_skey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc4_skey.c,v 1.14 2015/10/20 15:50:13 jsing Exp $ */ +/* $OpenBSD: rc4_skey.c,v 1.15 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "rc4_locl.h" +#include "rc4_local.h" #include const char * diff --git a/crypto/ripemd/rmd_dgst.c b/crypto/ripemd/rmd_dgst.c index 458968d4..d794a7c1 100644 --- a/crypto/ripemd/rmd_dgst.c +++ b/crypto/ripemd/rmd_dgst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rmd_dgst.c,v 1.17 2014/10/28 07:35:59 jsg Exp $ */ +/* $OpenBSD: rmd_dgst.c,v 1.18 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,7 +57,7 @@ */ #include -#include "rmd_locl.h" +#include "rmd_local.h" #include #include diff --git a/crypto/ripemd/rmd_locl.h b/crypto/ripemd/rmd_local.h similarity index 98% rename from crypto/ripemd/rmd_locl.h rename to crypto/ripemd/rmd_local.h index f38b101c..1e468167 100644 --- a/crypto/ripemd/rmd_locl.h +++ b/crypto/ripemd/rmd_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rmd_locl.h,v 1.13 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: rmd_local.h,v 1.1 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c index 448458f8..4ae41aeb 100644 --- a/crypto/rsa/rsa_ameth.c +++ b/crypto/rsa/rsa_ameth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_ameth.c,v 1.26 2022/06/27 12:36:06 tb Exp $ */ +/* $OpenBSD: rsa_ameth.c,v 1.27 2022/11/26 16:08:54 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -66,10 +66,10 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" #include "cryptlib.h" -#include "evp_locl.h" -#include "rsa_locl.h" +#include "evp_local.h" +#include "rsa_local.h" #ifndef OPENSSL_NO_CMS static int rsa_cms_sign(CMS_SignerInfo *si); diff --git a/crypto/rsa/rsa_asn1.c b/crypto/rsa/rsa_asn1.c index 4b8eda24..63c3637f 100644 --- a/crypto/rsa/rsa_asn1.c +++ b/crypto/rsa/rsa_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_asn1.c,v 1.15 2019/10/25 14:40:18 jsing Exp $ */ +/* $OpenBSD: rsa_asn1.c,v 1.16 2022/11/26 16:08:54 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -63,7 +63,7 @@ #include #include -#include "rsa_locl.h" +#include "rsa_local.h" /* Override the default free and new methods */ static int diff --git a/crypto/rsa/rsa_chk.c b/crypto/rsa/rsa_chk.c index ac9dbf7a..5d7f7b30 100644 --- a/crypto/rsa/rsa_chk.c +++ b/crypto/rsa/rsa_chk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_chk.c,v 1.16 2022/01/20 11:08:12 inoguchi Exp $ */ +/* $OpenBSD: rsa_chk.c,v 1.17 2022/11/26 16:08:54 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * @@ -52,8 +52,8 @@ #include #include -#include "bn_lcl.h" -#include "rsa_locl.h" +#include "bn_local.h" +#include "rsa_local.h" int RSA_check_key(const RSA *key) diff --git a/crypto/rsa/rsa_crpt.c b/crypto/rsa/rsa_crpt.c index 4fd21cd7..a1b2eec6 100644 --- a/crypto/rsa/rsa_crpt.c +++ b/crypto/rsa/rsa_crpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_crpt.c,v 1.20 2022/01/07 09:55:32 tb Exp $ */ +/* $OpenBSD: rsa_crpt.c,v 1.21 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,8 +66,8 @@ #include #include -#include "bn_lcl.h" -#include "rsa_locl.h" +#include "bn_local.h" +#include "rsa_local.h" #ifndef OPENSSL_NO_ENGINE #include diff --git a/crypto/rsa/rsa_depr.c b/crypto/rsa/rsa_depr.c index 54a669cc..8a432b34 100644 --- a/crypto/rsa/rsa_depr.c +++ b/crypto/rsa/rsa_depr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_depr.c,v 1.9 2021/12/04 16:08:32 tb Exp $ */ +/* $OpenBSD: rsa_depr.c,v 1.10 2022/11/26 16:08:54 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -64,7 +64,7 @@ #include #include -#include "bn_lcl.h" +#include "bn_local.h" #ifndef OPENSSL_NO_DEPRECATED diff --git a/crypto/rsa/rsa_eay.c b/crypto/rsa/rsa_eay.c index 0f8c324d..a1920172 100644 --- a/crypto/rsa/rsa_eay.c +++ b/crypto/rsa/rsa_eay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_eay.c,v 1.54 2022/01/20 11:10:11 inoguchi Exp $ */ +/* $OpenBSD: rsa_eay.c,v 1.56 2022/12/26 07:18:52 jmc Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -118,8 +118,8 @@ #include #include -#include "bn_lcl.h" -#include "rsa_locl.h" +#include "bn_local.h" +#include "rsa_local.h" static int RSA_eay_public_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding); @@ -716,7 +716,7 @@ RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) BIGNUM p, q; /* - * Make sure BN_mod_inverse in Montgomery intialization uses the + * Make sure BN_mod_inverse in Montgomery initialization uses the * BN_FLG_CONSTTIME flag */ BN_init(&p); diff --git a/crypto/rsa/rsa_gen.c b/crypto/rsa/rsa_gen.c index 5f062a7a..7aefa730 100644 --- a/crypto/rsa/rsa_gen.c +++ b/crypto/rsa/rsa_gen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_gen.c,v 1.25 2022/01/20 11:11:17 inoguchi Exp $ */ +/* $OpenBSD: rsa_gen.c,v 1.26 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -69,8 +69,8 @@ #include #include -#include "bn_lcl.h" -#include "rsa_locl.h" +#include "bn_local.h" +#include "rsa_local.h" static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb); diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c index 570bb6c0..9656252d 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_lib.c,v 1.43 2022/06/27 12:30:28 tb Exp $ */ +/* $OpenBSD: rsa_lib.c,v 1.46 2023/03/11 21:14:26 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -67,8 +67,8 @@ #include #include -#include "evp_locl.h" -#include "rsa_locl.h" +#include "evp_local.h" +#include "rsa_local.h" #ifndef OPENSSL_NO_ENGINE #include @@ -200,14 +200,14 @@ RSA_free(RSA *r) CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data); - BN_clear_free(r->n); - BN_clear_free(r->e); - BN_clear_free(r->d); - BN_clear_free(r->p); - BN_clear_free(r->q); - BN_clear_free(r->dmp1); - BN_clear_free(r->dmq1); - BN_clear_free(r->iqmp); + BN_free(r->n); + BN_free(r->e); + BN_free(r->d); + BN_free(r->p); + BN_free(r->q); + BN_free(r->dmp1); + BN_free(r->dmq1); + BN_free(r->iqmp); BN_BLINDING_free(r->blinding); BN_BLINDING_free(r->mt_blinding); RSA_PSS_PARAMS_free(r->pss); @@ -298,7 +298,7 @@ RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) if ((r->dmp1 == NULL && dmp1 == NULL) || (r->dmq1 == NULL && dmq1 == NULL) || (r->iqmp == NULL && iqmp == NULL)) - return 0; + return 0; if (dmp1 != NULL) { BN_free(r->dmp1); diff --git a/crypto/rsa/rsa_locl.h b/crypto/rsa/rsa_local.h similarity index 98% rename from crypto/rsa/rsa_locl.h rename to crypto/rsa/rsa_local.h index 1a2412ad..b438ab4e 100644 --- a/crypto/rsa/rsa_locl.h +++ b/crypto/rsa/rsa_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_locl.h,v 1.13 2022/07/04 12:23:30 tb Exp $ */ +/* $OpenBSD: rsa_local.h,v 1.1 2022/11/26 16:08:54 tb Exp $ */ __BEGIN_HIDDEN_DECLS diff --git a/crypto/rsa/rsa_meth.c b/crypto/rsa/rsa_meth.c index d6be1ea0..a0119273 100644 --- a/crypto/rsa/rsa_meth.c +++ b/crypto/rsa/rsa_meth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_meth.c,v 1.5 2022/07/04 12:23:30 tb Exp $ */ +/* $OpenBSD: rsa_meth.c,v 1.6 2022/11/26 16:08:54 tb Exp $ */ /* * Copyright (c) 2018 Theo Buehler * @@ -21,7 +21,7 @@ #include #include -#include "rsa_locl.h" +#include "rsa_local.h" RSA_METHOD * RSA_meth_new(const char *name, int flags) diff --git a/crypto/rsa/rsa_oaep.c b/crypto/rsa/rsa_oaep.c index 93269500..083f4a6c 100644 --- a/crypto/rsa/rsa_oaep.c +++ b/crypto/rsa/rsa_oaep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_oaep.c,v 1.35 2022/02/20 19:16:34 tb Exp $ */ +/* $OpenBSD: rsa_oaep.c,v 1.36 2022/11/26 16:08:54 tb Exp $ */ /* * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. * @@ -79,9 +79,9 @@ #include #include -#include "constant_time_locl.h" -#include "evp_locl.h" -#include "rsa_locl.h" +#include "constant_time.h" +#include "evp_local.h" +#include "rsa_local.h" int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, diff --git a/crypto/rsa/rsa_pmeth.c b/crypto/rsa/rsa_pmeth.c index 36a2a277..3747f1dd 100644 --- a/crypto/rsa/rsa_pmeth.c +++ b/crypto/rsa/rsa_pmeth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_pmeth.c,v 1.33 2021/12/04 16:08:32 tb Exp $ */ +/* $OpenBSD: rsa_pmeth.c,v 1.35 2023/03/06 08:31:34 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -70,9 +70,9 @@ #include #include -#include "bn_lcl.h" -#include "evp_locl.h" -#include "rsa_locl.h" +#include "bn_local.h" +#include "evp_local.h" +#include "rsa_local.h" /* RSA pkey context structure */ @@ -326,12 +326,16 @@ pkey_rsa_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, return -1; } } else { + int ret; + if (!setup_tbuf(rctx, ctx)) return -1; - rslen = RSA_public_decrypt(siglen, sig, rctx->tbuf, rsa, - rctx->pad_mode); - if (rslen == 0) + + if ((ret = RSA_public_decrypt(siglen, sig, rctx->tbuf, rsa, + rctx->pad_mode)) <= 0) return 0; + + rslen = ret; } if (rslen != tbslen || timingsafe_bcmp(tbs, rctx->tbuf, rslen)) diff --git a/crypto/rsa/rsa_prn.c b/crypto/rsa/rsa_prn.c index c46b08c0..12f600d6 100644 --- a/crypto/rsa/rsa_prn.c +++ b/crypto/rsa/rsa_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_prn.c,v 1.7 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: rsa_prn.c,v 1.9 2022/11/08 19:19:08 tobhe Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -82,12 +82,16 @@ int RSA_print(BIO *bp, const RSA *x, int off) { EVP_PKEY *pk; - int ret; + int ret = 0; + + if ((pk = EVP_PKEY_new()) == NULL) + goto err; + + if (!EVP_PKEY_set1_RSA(pk, (RSA *)x)) + goto err; - pk = EVP_PKEY_new(); - if (!pk || !EVP_PKEY_set1_RSA(pk, (RSA *)x)) - return 0; ret = EVP_PKEY_print_private(bp, pk, off, NULL); + err: EVP_PKEY_free(pk); return ret; } diff --git a/crypto/rsa/rsa_pss.c b/crypto/rsa/rsa_pss.c index cce38efa..72c79e3b 100644 --- a/crypto/rsa/rsa_pss.c +++ b/crypto/rsa/rsa_pss.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_pss.c,v 1.15 2022/01/07 09:55:32 tb Exp $ */ +/* $OpenBSD: rsa_pss.c,v 1.16 2022/11/26 16:08:54 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ @@ -66,8 +66,8 @@ #include #include -#include "evp_locl.h" -#include "rsa_locl.h" +#include "evp_local.h" +#include "rsa_local.h" static const unsigned char zeroes[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; diff --git a/crypto/rsa/rsa_sign.c b/crypto/rsa/rsa_sign.c index bd45a95d..d517fcbc 100644 --- a/crypto/rsa/rsa_sign.c +++ b/crypto/rsa/rsa_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsa_sign.c,v 1.34 2022/01/07 11:13:55 tb Exp $ */ +/* $OpenBSD: rsa_sign.c,v 1.35 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,9 +65,9 @@ #include #include -#include "asn1_locl.h" -#include "rsa_locl.h" -#include "x509_lcl.h" +#include "asn1_local.h" +#include "rsa_local.h" +#include "x509_local.h" /* Size of an SSL signature: MD5+SHA1 */ #define SSL_SIG_LENGTH 36 diff --git a/crypto/sha/sha1-elf-x86_64.S b/crypto/sha/sha1-elf-x86_64.S index 5a37019a..c0179ad2 100644 --- a/crypto/sha/sha1-elf-x86_64.S +++ b/crypto/sha/sha1-elf-x86_64.S @@ -2477,6 +2477,7 @@ _ssse3_shortcut: .Lepilogue_ssse3: retq .size sha1_block_data_order_ssse3,.-sha1_block_data_order_ssse3 +.section .rodata .align 64 K_XX_XX: .long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 @@ -2484,7 +2485,7 @@ K_XX_XX: .long 0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc .long 0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6 .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f -.byte 83,72,65,49,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text .align 64 #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits diff --git a/crypto/sha/sha1-macosx-x86_64.S b/crypto/sha/sha1-macosx-x86_64.S index 04a8affb..43e14c13 100644 --- a/crypto/sha/sha1-macosx-x86_64.S +++ b/crypto/sha/sha1-macosx-x86_64.S @@ -2477,6 +2477,7 @@ L$done_ssse3: L$epilogue_ssse3: retq +.section __DATA,__const .p2align 6 K_XX_XX: .long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 @@ -2484,5 +2485,5 @@ K_XX_XX: .long 0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc .long 0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6 .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f -.byte 83,72,65,49,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text .p2align 6 diff --git a/crypto/sha/sha1-masm-x86_64.S b/crypto/sha/sha1-masm-x86_64.S index f520b5a8..a09981a5 100644 --- a/crypto/sha/sha1-masm-x86_64.S +++ b/crypto/sha/sha1-masm-x86_64.S @@ -2580,6 +2580,8 @@ $L$epilogue_ssse3:: DB 0F3h,0C3h ;repret $L$SEH_end_sha1_block_data_order_ssse3:: sha1_block_data_order_ssse3 ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 K_XX_XX:: DD 05a827999h,05a827999h,05a827999h,05a827999h @@ -2587,11 +2589,8 @@ K_XX_XX:: DD 08f1bbcdch,08f1bbcdch,08f1bbcdch,08f1bbcdch DD 0ca62c1d6h,0ca62c1d6h,0ca62c1d6h,0ca62c1d6h DD 000010203h,004050607h,008090a0bh,00c0d0e0fh -DB 83,72,65,49,32,98,108,111,99,107,32,116,114,97,110,115 -DB 102,111,114,109,32,102,111,114,32,120,56,54,95,54,52,44 -DB 32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60 -DB 97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114 -DB 103,62,0 +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' ALIGN 64 EXTERN __imp_RtlVirtualUnwind:NEAR diff --git a/crypto/sha/sha1-mingw64-x86_64.S b/crypto/sha/sha1-mingw64-x86_64.S index 3ce9fc9b..a01fc75c 100644 --- a/crypto/sha/sha1-mingw64-x86_64.S +++ b/crypto/sha/sha1-mingw64-x86_64.S @@ -2508,6 +2508,7 @@ _ssse3_shortcut: movq 16(%rsp),%rsi retq .LSEH_end_sha1_block_data_order_ssse3: +.section .rodata .p2align 6 K_XX_XX: .long 0x5a827999,0x5a827999,0x5a827999,0x5a827999 @@ -2515,7 +2516,7 @@ K_XX_XX: .long 0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc,0x8f1bbcdc .long 0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6 .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f -.byte 83,72,65,49,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text .p2align 6 .def se_handler; .scl 3; .type 32; .endef diff --git a/crypto/sha/sha1-mips.S b/crypto/sha/sha1-mips.S new file mode 100644 index 00000000..dddb5785 --- /dev/null +++ b/crypto/sha/sha1-mips.S @@ -0,0 +1,1663 @@ +.text + +.set noat +.set noreorder +.align 5 +.globl sha1_block_data_order +.ent sha1_block_data_order +sha1_block_data_order: + .frame $29,16*4,$31 + .mask 3237937152,-4 + .set noreorder + sub $29,16*4 + sw $31,(16-1)*4($29) + sw $30,(16-2)*4($29) + sw $23,(16-3)*4($29) + sw $22,(16-4)*4($29) + sw $21,(16-5)*4($29) + sw $20,(16-6)*4($29) + sw $19,(16-7)*4($29) + sw $18,(16-8)*4($29) + sw $17,(16-9)*4($29) + sw $16,(16-10)*4($29) + sll $6,6 + add $6,$5 + sw $6,0($29) + lw $1,0($4) + lw $2,4($4) + lw $3,8($4) + lw $7,12($4) + b .Loop + lw $24,16($4) +.align 4 +.Loop: + .set reorder + lwl $8,3($5) + lui $31,0x5a82 + lwr $8,0($5) + ori $31,0x7999 # K_00_19 + srl $25,$8,24 # byte swap(0) + srl $6,$8,8 + andi $30,$8,0xFF00 + sll $8,$8,24 + andi $6,0xFF00 + sll $30,$30,8 + or $8,$25 + or $6,$30 + or $8,$6 + lwl $9,1*4+3($5) + sll $25,$1,5 # 0 + addu $24,$31 + lwr $9,1*4+0($5) + srl $6,$1,27 + addu $24,$25 + xor $25,$3,$7 + addu $24,$6 + sll $30,$2,30 + and $25,$2 + srl $2,$2,2 + xor $25,$7 + addu $24,$8 + or $2,$30 + addu $24,$25 + srl $25,$9,24 # byte swap(1) + srl $6,$9,8 + andi $30,$9,0xFF00 + sll $9,$9,24 + andi $6,0xFF00 + sll $30,$30,8 + or $9,$25 + or $6,$30 + or $9,$6 + lwl $10,2*4+3($5) + sll $25,$24,5 # 1 + addu $7,$31 + lwr $10,2*4+0($5) + srl $6,$24,27 + addu $7,$25 + xor $25,$2,$3 + addu $7,$6 + sll $30,$1,30 + and $25,$1 + srl $1,$1,2 + xor $25,$3 + addu $7,$9 + or $1,$30 + addu $7,$25 + srl $25,$10,24 # byte swap(2) + srl $6,$10,8 + andi $30,$10,0xFF00 + sll $10,$10,24 + andi $6,0xFF00 + sll $30,$30,8 + or $10,$25 + or $6,$30 + or $10,$6 + lwl $11,3*4+3($5) + sll $25,$7,5 # 2 + addu $3,$31 + lwr $11,3*4+0($5) + srl $6,$7,27 + addu $3,$25 + xor $25,$1,$2 + addu $3,$6 + sll $30,$24,30 + and $25,$24 + srl $24,$24,2 + xor $25,$2 + addu $3,$10 + or $24,$30 + addu $3,$25 + srl $25,$11,24 # byte swap(3) + srl $6,$11,8 + andi $30,$11,0xFF00 + sll $11,$11,24 + andi $6,0xFF00 + sll $30,$30,8 + or $11,$25 + or $6,$30 + or $11,$6 + lwl $12,4*4+3($5) + sll $25,$3,5 # 3 + addu $2,$31 + lwr $12,4*4+0($5) + srl $6,$3,27 + addu $2,$25 + xor $25,$24,$1 + addu $2,$6 + sll $30,$7,30 + and $25,$7 + srl $7,$7,2 + xor $25,$1 + addu $2,$11 + or $7,$30 + addu $2,$25 + srl $25,$12,24 # byte swap(4) + srl $6,$12,8 + andi $30,$12,0xFF00 + sll $12,$12,24 + andi $6,0xFF00 + sll $30,$30,8 + or $12,$25 + or $6,$30 + or $12,$6 + lwl $13,5*4+3($5) + sll $25,$2,5 # 4 + addu $1,$31 + lwr $13,5*4+0($5) + srl $6,$2,27 + addu $1,$25 + xor $25,$7,$24 + addu $1,$6 + sll $30,$3,30 + and $25,$3 + srl $3,$3,2 + xor $25,$24 + addu $1,$12 + or $3,$30 + addu $1,$25 + srl $25,$13,24 # byte swap(5) + srl $6,$13,8 + andi $30,$13,0xFF00 + sll $13,$13,24 + andi $6,0xFF00 + sll $30,$30,8 + or $13,$25 + or $6,$30 + or $13,$6 + lwl $14,6*4+3($5) + sll $25,$1,5 # 5 + addu $24,$31 + lwr $14,6*4+0($5) + srl $6,$1,27 + addu $24,$25 + xor $25,$3,$7 + addu $24,$6 + sll $30,$2,30 + and $25,$2 + srl $2,$2,2 + xor $25,$7 + addu $24,$13 + or $2,$30 + addu $24,$25 + srl $25,$14,24 # byte swap(6) + srl $6,$14,8 + andi $30,$14,0xFF00 + sll $14,$14,24 + andi $6,0xFF00 + sll $30,$30,8 + or $14,$25 + or $6,$30 + or $14,$6 + lwl $15,7*4+3($5) + sll $25,$24,5 # 6 + addu $7,$31 + lwr $15,7*4+0($5) + srl $6,$24,27 + addu $7,$25 + xor $25,$2,$3 + addu $7,$6 + sll $30,$1,30 + and $25,$1 + srl $1,$1,2 + xor $25,$3 + addu $7,$14 + or $1,$30 + addu $7,$25 + srl $25,$15,24 # byte swap(7) + srl $6,$15,8 + andi $30,$15,0xFF00 + sll $15,$15,24 + andi $6,0xFF00 + sll $30,$30,8 + or $15,$25 + or $6,$30 + or $15,$6 + lwl $16,8*4+3($5) + sll $25,$7,5 # 7 + addu $3,$31 + lwr $16,8*4+0($5) + srl $6,$7,27 + addu $3,$25 + xor $25,$1,$2 + addu $3,$6 + sll $30,$24,30 + and $25,$24 + srl $24,$24,2 + xor $25,$2 + addu $3,$15 + or $24,$30 + addu $3,$25 + srl $25,$16,24 # byte swap(8) + srl $6,$16,8 + andi $30,$16,0xFF00 + sll $16,$16,24 + andi $6,0xFF00 + sll $30,$30,8 + or $16,$25 + or $6,$30 + or $16,$6 + lwl $17,9*4+3($5) + sll $25,$3,5 # 8 + addu $2,$31 + lwr $17,9*4+0($5) + srl $6,$3,27 + addu $2,$25 + xor $25,$24,$1 + addu $2,$6 + sll $30,$7,30 + and $25,$7 + srl $7,$7,2 + xor $25,$1 + addu $2,$16 + or $7,$30 + addu $2,$25 + srl $25,$17,24 # byte swap(9) + srl $6,$17,8 + andi $30,$17,0xFF00 + sll $17,$17,24 + andi $6,0xFF00 + sll $30,$30,8 + or $17,$25 + or $6,$30 + or $17,$6 + lwl $18,10*4+3($5) + sll $25,$2,5 # 9 + addu $1,$31 + lwr $18,10*4+0($5) + srl $6,$2,27 + addu $1,$25 + xor $25,$7,$24 + addu $1,$6 + sll $30,$3,30 + and $25,$3 + srl $3,$3,2 + xor $25,$24 + addu $1,$17 + or $3,$30 + addu $1,$25 + srl $25,$18,24 # byte swap(10) + srl $6,$18,8 + andi $30,$18,0xFF00 + sll $18,$18,24 + andi $6,0xFF00 + sll $30,$30,8 + or $18,$25 + or $6,$30 + or $18,$6 + lwl $19,11*4+3($5) + sll $25,$1,5 # 10 + addu $24,$31 + lwr $19,11*4+0($5) + srl $6,$1,27 + addu $24,$25 + xor $25,$3,$7 + addu $24,$6 + sll $30,$2,30 + and $25,$2 + srl $2,$2,2 + xor $25,$7 + addu $24,$18 + or $2,$30 + addu $24,$25 + srl $25,$19,24 # byte swap(11) + srl $6,$19,8 + andi $30,$19,0xFF00 + sll $19,$19,24 + andi $6,0xFF00 + sll $30,$30,8 + or $19,$25 + or $6,$30 + or $19,$6 + lwl $20,12*4+3($5) + sll $25,$24,5 # 11 + addu $7,$31 + lwr $20,12*4+0($5) + srl $6,$24,27 + addu $7,$25 + xor $25,$2,$3 + addu $7,$6 + sll $30,$1,30 + and $25,$1 + srl $1,$1,2 + xor $25,$3 + addu $7,$19 + or $1,$30 + addu $7,$25 + srl $25,$20,24 # byte swap(12) + srl $6,$20,8 + andi $30,$20,0xFF00 + sll $20,$20,24 + andi $6,0xFF00 + sll $30,$30,8 + or $20,$25 + or $6,$30 + or $20,$6 + lwl $21,13*4+3($5) + sll $25,$7,5 # 12 + addu $3,$31 + lwr $21,13*4+0($5) + srl $6,$7,27 + addu $3,$25 + xor $25,$1,$2 + addu $3,$6 + sll $30,$24,30 + and $25,$24 + srl $24,$24,2 + xor $25,$2 + addu $3,$20 + or $24,$30 + addu $3,$25 + srl $25,$21,24 # byte swap(13) + srl $6,$21,8 + andi $30,$21,0xFF00 + sll $21,$21,24 + andi $6,0xFF00 + sll $30,$30,8 + or $21,$25 + or $6,$30 + or $21,$6 + lwl $22,14*4+3($5) + sll $25,$3,5 # 13 + addu $2,$31 + lwr $22,14*4+0($5) + srl $6,$3,27 + addu $2,$25 + xor $25,$24,$1 + addu $2,$6 + sll $30,$7,30 + and $25,$7 + srl $7,$7,2 + xor $25,$1 + addu $2,$21 + or $7,$30 + addu $2,$25 + srl $25,$22,24 # byte swap(14) + srl $6,$22,8 + andi $30,$22,0xFF00 + sll $22,$22,24 + andi $6,0xFF00 + sll $30,$30,8 + or $22,$25 + or $6,$30 + or $22,$6 + lwl $23,15*4+3($5) + sll $25,$2,5 # 14 + addu $1,$31 + lwr $23,15*4+0($5) + srl $6,$2,27 + addu $1,$25 + xor $25,$7,$24 + addu $1,$6 + sll $30,$3,30 + and $25,$3 + srl $3,$3,2 + xor $25,$24 + addu $1,$22 + or $3,$30 + addu $1,$25 + srl $25,$23,24 # byte swap(15) + srl $6,$23,8 + andi $30,$23,0xFF00 + sll $23,$23,24 + andi $6,0xFF00 + sll $30,$30,8 + or $23,$25 + or $23,$6 + or $23,$30 + xor $8,$10 + sll $25,$1,5 # 15 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $8,$16 + xor $25,$3,$7 + addu $24,$6 + xor $8,$21 + sll $30,$2,30 + and $25,$2 + srl $6,$8,31 + addu $8,$8 + srl $2,$2,2 + xor $25,$7 + or $8,$6 + addu $24,$23 + or $2,$30 + addu $24,$25 + xor $9,$11 + sll $25,$24,5 # 16 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $9,$17 + xor $25,$2,$3 + addu $7,$6 + xor $9,$22 + sll $30,$1,30 + and $25,$1 + srl $6,$9,31 + addu $9,$9 + srl $1,$1,2 + xor $25,$3 + or $9,$6 + addu $7,$8 + or $1,$30 + addu $7,$25 + xor $10,$12 + sll $25,$7,5 # 17 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $10,$18 + xor $25,$1,$2 + addu $3,$6 + xor $10,$23 + sll $30,$24,30 + and $25,$24 + srl $6,$10,31 + addu $10,$10 + srl $24,$24,2 + xor $25,$2 + or $10,$6 + addu $3,$9 + or $24,$30 + addu $3,$25 + xor $11,$13 + sll $25,$3,5 # 18 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $11,$19 + xor $25,$24,$1 + addu $2,$6 + xor $11,$8 + sll $30,$7,30 + and $25,$7 + srl $6,$11,31 + addu $11,$11 + srl $7,$7,2 + xor $25,$1 + or $11,$6 + addu $2,$10 + or $7,$30 + addu $2,$25 + xor $12,$14 + sll $25,$2,5 # 19 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $12,$20 + xor $25,$7,$24 + addu $1,$6 + xor $12,$9 + sll $30,$3,30 + and $25,$3 + srl $6,$12,31 + addu $12,$12 + srl $3,$3,2 + xor $25,$24 + or $12,$6 + addu $1,$11 + or $3,$30 + addu $1,$25 + lui $31,0x6ed9 + ori $31,0xeba1 # K_20_39 + xor $13,$15 + sll $25,$1,5 # 20 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $13,$21 + xor $25,$3,$7 + addu $24,$6 + xor $13,$10 + sll $30,$2,30 + xor $25,$2 + srl $6,$13,31 + addu $13,$13 + srl $2,$2,2 + addu $24,$12 + or $13,$6 + or $2,$30 + addu $24,$25 + xor $14,$16 + sll $25,$24,5 # 21 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $14,$22 + xor $25,$2,$3 + addu $7,$6 + xor $14,$11 + sll $30,$1,30 + xor $25,$1 + srl $6,$14,31 + addu $14,$14 + srl $1,$1,2 + addu $7,$13 + or $14,$6 + or $1,$30 + addu $7,$25 + xor $15,$17 + sll $25,$7,5 # 22 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $15,$23 + xor $25,$1,$2 + addu $3,$6 + xor $15,$12 + sll $30,$24,30 + xor $25,$24 + srl $6,$15,31 + addu $15,$15 + srl $24,$24,2 + addu $3,$14 + or $15,$6 + or $24,$30 + addu $3,$25 + xor $16,$18 + sll $25,$3,5 # 23 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $16,$8 + xor $25,$24,$1 + addu $2,$6 + xor $16,$13 + sll $30,$7,30 + xor $25,$7 + srl $6,$16,31 + addu $16,$16 + srl $7,$7,2 + addu $2,$15 + or $16,$6 + or $7,$30 + addu $2,$25 + xor $17,$19 + sll $25,$2,5 # 24 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $17,$9 + xor $25,$7,$24 + addu $1,$6 + xor $17,$14 + sll $30,$3,30 + xor $25,$3 + srl $6,$17,31 + addu $17,$17 + srl $3,$3,2 + addu $1,$16 + or $17,$6 + or $3,$30 + addu $1,$25 + xor $18,$20 + sll $25,$1,5 # 25 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $18,$10 + xor $25,$3,$7 + addu $24,$6 + xor $18,$15 + sll $30,$2,30 + xor $25,$2 + srl $6,$18,31 + addu $18,$18 + srl $2,$2,2 + addu $24,$17 + or $18,$6 + or $2,$30 + addu $24,$25 + xor $19,$21 + sll $25,$24,5 # 26 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $19,$11 + xor $25,$2,$3 + addu $7,$6 + xor $19,$16 + sll $30,$1,30 + xor $25,$1 + srl $6,$19,31 + addu $19,$19 + srl $1,$1,2 + addu $7,$18 + or $19,$6 + or $1,$30 + addu $7,$25 + xor $20,$22 + sll $25,$7,5 # 27 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $20,$12 + xor $25,$1,$2 + addu $3,$6 + xor $20,$17 + sll $30,$24,30 + xor $25,$24 + srl $6,$20,31 + addu $20,$20 + srl $24,$24,2 + addu $3,$19 + or $20,$6 + or $24,$30 + addu $3,$25 + xor $21,$23 + sll $25,$3,5 # 28 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $21,$13 + xor $25,$24,$1 + addu $2,$6 + xor $21,$18 + sll $30,$7,30 + xor $25,$7 + srl $6,$21,31 + addu $21,$21 + srl $7,$7,2 + addu $2,$20 + or $21,$6 + or $7,$30 + addu $2,$25 + xor $22,$8 + sll $25,$2,5 # 29 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $22,$14 + xor $25,$7,$24 + addu $1,$6 + xor $22,$19 + sll $30,$3,30 + xor $25,$3 + srl $6,$22,31 + addu $22,$22 + srl $3,$3,2 + addu $1,$21 + or $22,$6 + or $3,$30 + addu $1,$25 + xor $23,$9 + sll $25,$1,5 # 30 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $23,$15 + xor $25,$3,$7 + addu $24,$6 + xor $23,$20 + sll $30,$2,30 + xor $25,$2 + srl $6,$23,31 + addu $23,$23 + srl $2,$2,2 + addu $24,$22 + or $23,$6 + or $2,$30 + addu $24,$25 + xor $8,$10 + sll $25,$24,5 # 31 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $8,$16 + xor $25,$2,$3 + addu $7,$6 + xor $8,$21 + sll $30,$1,30 + xor $25,$1 + srl $6,$8,31 + addu $8,$8 + srl $1,$1,2 + addu $7,$23 + or $8,$6 + or $1,$30 + addu $7,$25 + xor $9,$11 + sll $25,$7,5 # 32 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $9,$17 + xor $25,$1,$2 + addu $3,$6 + xor $9,$22 + sll $30,$24,30 + xor $25,$24 + srl $6,$9,31 + addu $9,$9 + srl $24,$24,2 + addu $3,$8 + or $9,$6 + or $24,$30 + addu $3,$25 + xor $10,$12 + sll $25,$3,5 # 33 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $10,$18 + xor $25,$24,$1 + addu $2,$6 + xor $10,$23 + sll $30,$7,30 + xor $25,$7 + srl $6,$10,31 + addu $10,$10 + srl $7,$7,2 + addu $2,$9 + or $10,$6 + or $7,$30 + addu $2,$25 + xor $11,$13 + sll $25,$2,5 # 34 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $11,$19 + xor $25,$7,$24 + addu $1,$6 + xor $11,$8 + sll $30,$3,30 + xor $25,$3 + srl $6,$11,31 + addu $11,$11 + srl $3,$3,2 + addu $1,$10 + or $11,$6 + or $3,$30 + addu $1,$25 + xor $12,$14 + sll $25,$1,5 # 35 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $12,$20 + xor $25,$3,$7 + addu $24,$6 + xor $12,$9 + sll $30,$2,30 + xor $25,$2 + srl $6,$12,31 + addu $12,$12 + srl $2,$2,2 + addu $24,$11 + or $12,$6 + or $2,$30 + addu $24,$25 + xor $13,$15 + sll $25,$24,5 # 36 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $13,$21 + xor $25,$2,$3 + addu $7,$6 + xor $13,$10 + sll $30,$1,30 + xor $25,$1 + srl $6,$13,31 + addu $13,$13 + srl $1,$1,2 + addu $7,$12 + or $13,$6 + or $1,$30 + addu $7,$25 + xor $14,$16 + sll $25,$7,5 # 37 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $14,$22 + xor $25,$1,$2 + addu $3,$6 + xor $14,$11 + sll $30,$24,30 + xor $25,$24 + srl $6,$14,31 + addu $14,$14 + srl $24,$24,2 + addu $3,$13 + or $14,$6 + or $24,$30 + addu $3,$25 + xor $15,$17 + sll $25,$3,5 # 38 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $15,$23 + xor $25,$24,$1 + addu $2,$6 + xor $15,$12 + sll $30,$7,30 + xor $25,$7 + srl $6,$15,31 + addu $15,$15 + srl $7,$7,2 + addu $2,$14 + or $15,$6 + or $7,$30 + addu $2,$25 + xor $16,$18 + sll $25,$2,5 # 39 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $16,$8 + xor $25,$7,$24 + addu $1,$6 + xor $16,$13 + sll $30,$3,30 + xor $25,$3 + srl $6,$16,31 + addu $16,$16 + srl $3,$3,2 + addu $1,$15 + or $16,$6 + or $3,$30 + addu $1,$25 + lui $31,0x8f1b + ori $31,0xbcdc # K_40_59 + xor $17,$19 + sll $25,$1,5 # 40 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $17,$9 + and $25,$3,$7 + addu $24,$6 + xor $17,$14 + sll $30,$2,30 + addu $24,$25 + srl $6,$17,31 + xor $25,$3,$7 + addu $17,$17 + and $25,$2 + srl $2,$2,2 + or $17,$6 + addu $24,$16 + or $2,$30 + addu $24,$25 + xor $18,$20 + sll $25,$24,5 # 41 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $18,$10 + and $25,$2,$3 + addu $7,$6 + xor $18,$15 + sll $30,$1,30 + addu $7,$25 + srl $6,$18,31 + xor $25,$2,$3 + addu $18,$18 + and $25,$1 + srl $1,$1,2 + or $18,$6 + addu $7,$17 + or $1,$30 + addu $7,$25 + xor $19,$21 + sll $25,$7,5 # 42 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $19,$11 + and $25,$1,$2 + addu $3,$6 + xor $19,$16 + sll $30,$24,30 + addu $3,$25 + srl $6,$19,31 + xor $25,$1,$2 + addu $19,$19 + and $25,$24 + srl $24,$24,2 + or $19,$6 + addu $3,$18 + or $24,$30 + addu $3,$25 + xor $20,$22 + sll $25,$3,5 # 43 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $20,$12 + and $25,$24,$1 + addu $2,$6 + xor $20,$17 + sll $30,$7,30 + addu $2,$25 + srl $6,$20,31 + xor $25,$24,$1 + addu $20,$20 + and $25,$7 + srl $7,$7,2 + or $20,$6 + addu $2,$19 + or $7,$30 + addu $2,$25 + xor $21,$23 + sll $25,$2,5 # 44 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $21,$13 + and $25,$7,$24 + addu $1,$6 + xor $21,$18 + sll $30,$3,30 + addu $1,$25 + srl $6,$21,31 + xor $25,$7,$24 + addu $21,$21 + and $25,$3 + srl $3,$3,2 + or $21,$6 + addu $1,$20 + or $3,$30 + addu $1,$25 + xor $22,$8 + sll $25,$1,5 # 45 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $22,$14 + and $25,$3,$7 + addu $24,$6 + xor $22,$19 + sll $30,$2,30 + addu $24,$25 + srl $6,$22,31 + xor $25,$3,$7 + addu $22,$22 + and $25,$2 + srl $2,$2,2 + or $22,$6 + addu $24,$21 + or $2,$30 + addu $24,$25 + xor $23,$9 + sll $25,$24,5 # 46 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $23,$15 + and $25,$2,$3 + addu $7,$6 + xor $23,$20 + sll $30,$1,30 + addu $7,$25 + srl $6,$23,31 + xor $25,$2,$3 + addu $23,$23 + and $25,$1 + srl $1,$1,2 + or $23,$6 + addu $7,$22 + or $1,$30 + addu $7,$25 + xor $8,$10 + sll $25,$7,5 # 47 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $8,$16 + and $25,$1,$2 + addu $3,$6 + xor $8,$21 + sll $30,$24,30 + addu $3,$25 + srl $6,$8,31 + xor $25,$1,$2 + addu $8,$8 + and $25,$24 + srl $24,$24,2 + or $8,$6 + addu $3,$23 + or $24,$30 + addu $3,$25 + xor $9,$11 + sll $25,$3,5 # 48 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $9,$17 + and $25,$24,$1 + addu $2,$6 + xor $9,$22 + sll $30,$7,30 + addu $2,$25 + srl $6,$9,31 + xor $25,$24,$1 + addu $9,$9 + and $25,$7 + srl $7,$7,2 + or $9,$6 + addu $2,$8 + or $7,$30 + addu $2,$25 + xor $10,$12 + sll $25,$2,5 # 49 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $10,$18 + and $25,$7,$24 + addu $1,$6 + xor $10,$23 + sll $30,$3,30 + addu $1,$25 + srl $6,$10,31 + xor $25,$7,$24 + addu $10,$10 + and $25,$3 + srl $3,$3,2 + or $10,$6 + addu $1,$9 + or $3,$30 + addu $1,$25 + xor $11,$13 + sll $25,$1,5 # 50 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $11,$19 + and $25,$3,$7 + addu $24,$6 + xor $11,$8 + sll $30,$2,30 + addu $24,$25 + srl $6,$11,31 + xor $25,$3,$7 + addu $11,$11 + and $25,$2 + srl $2,$2,2 + or $11,$6 + addu $24,$10 + or $2,$30 + addu $24,$25 + xor $12,$14 + sll $25,$24,5 # 51 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $12,$20 + and $25,$2,$3 + addu $7,$6 + xor $12,$9 + sll $30,$1,30 + addu $7,$25 + srl $6,$12,31 + xor $25,$2,$3 + addu $12,$12 + and $25,$1 + srl $1,$1,2 + or $12,$6 + addu $7,$11 + or $1,$30 + addu $7,$25 + xor $13,$15 + sll $25,$7,5 # 52 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $13,$21 + and $25,$1,$2 + addu $3,$6 + xor $13,$10 + sll $30,$24,30 + addu $3,$25 + srl $6,$13,31 + xor $25,$1,$2 + addu $13,$13 + and $25,$24 + srl $24,$24,2 + or $13,$6 + addu $3,$12 + or $24,$30 + addu $3,$25 + xor $14,$16 + sll $25,$3,5 # 53 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $14,$22 + and $25,$24,$1 + addu $2,$6 + xor $14,$11 + sll $30,$7,30 + addu $2,$25 + srl $6,$14,31 + xor $25,$24,$1 + addu $14,$14 + and $25,$7 + srl $7,$7,2 + or $14,$6 + addu $2,$13 + or $7,$30 + addu $2,$25 + xor $15,$17 + sll $25,$2,5 # 54 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $15,$23 + and $25,$7,$24 + addu $1,$6 + xor $15,$12 + sll $30,$3,30 + addu $1,$25 + srl $6,$15,31 + xor $25,$7,$24 + addu $15,$15 + and $25,$3 + srl $3,$3,2 + or $15,$6 + addu $1,$14 + or $3,$30 + addu $1,$25 + xor $16,$18 + sll $25,$1,5 # 55 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $16,$8 + and $25,$3,$7 + addu $24,$6 + xor $16,$13 + sll $30,$2,30 + addu $24,$25 + srl $6,$16,31 + xor $25,$3,$7 + addu $16,$16 + and $25,$2 + srl $2,$2,2 + or $16,$6 + addu $24,$15 + or $2,$30 + addu $24,$25 + xor $17,$19 + sll $25,$24,5 # 56 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $17,$9 + and $25,$2,$3 + addu $7,$6 + xor $17,$14 + sll $30,$1,30 + addu $7,$25 + srl $6,$17,31 + xor $25,$2,$3 + addu $17,$17 + and $25,$1 + srl $1,$1,2 + or $17,$6 + addu $7,$16 + or $1,$30 + addu $7,$25 + xor $18,$20 + sll $25,$7,5 # 57 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $18,$10 + and $25,$1,$2 + addu $3,$6 + xor $18,$15 + sll $30,$24,30 + addu $3,$25 + srl $6,$18,31 + xor $25,$1,$2 + addu $18,$18 + and $25,$24 + srl $24,$24,2 + or $18,$6 + addu $3,$17 + or $24,$30 + addu $3,$25 + xor $19,$21 + sll $25,$3,5 # 58 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $19,$11 + and $25,$24,$1 + addu $2,$6 + xor $19,$16 + sll $30,$7,30 + addu $2,$25 + srl $6,$19,31 + xor $25,$24,$1 + addu $19,$19 + and $25,$7 + srl $7,$7,2 + or $19,$6 + addu $2,$18 + or $7,$30 + addu $2,$25 + xor $20,$22 + sll $25,$2,5 # 59 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $20,$12 + and $25,$7,$24 + addu $1,$6 + xor $20,$17 + sll $30,$3,30 + addu $1,$25 + srl $6,$20,31 + xor $25,$7,$24 + addu $20,$20 + and $25,$3 + srl $3,$3,2 + or $20,$6 + addu $1,$19 + or $3,$30 + addu $1,$25 + lui $31,0xca62 + ori $31,0xc1d6 # K_60_79 + xor $21,$23 + sll $25,$1,5 # 60 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $21,$13 + xor $25,$3,$7 + addu $24,$6 + xor $21,$18 + sll $30,$2,30 + xor $25,$2 + srl $6,$21,31 + addu $21,$21 + srl $2,$2,2 + addu $24,$20 + or $21,$6 + or $2,$30 + addu $24,$25 + xor $22,$8 + sll $25,$24,5 # 61 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $22,$14 + xor $25,$2,$3 + addu $7,$6 + xor $22,$19 + sll $30,$1,30 + xor $25,$1 + srl $6,$22,31 + addu $22,$22 + srl $1,$1,2 + addu $7,$21 + or $22,$6 + or $1,$30 + addu $7,$25 + xor $23,$9 + sll $25,$7,5 # 62 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $23,$15 + xor $25,$1,$2 + addu $3,$6 + xor $23,$20 + sll $30,$24,30 + xor $25,$24 + srl $6,$23,31 + addu $23,$23 + srl $24,$24,2 + addu $3,$22 + or $23,$6 + or $24,$30 + addu $3,$25 + xor $8,$10 + sll $25,$3,5 # 63 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $8,$16 + xor $25,$24,$1 + addu $2,$6 + xor $8,$21 + sll $30,$7,30 + xor $25,$7 + srl $6,$8,31 + addu $8,$8 + srl $7,$7,2 + addu $2,$23 + or $8,$6 + or $7,$30 + addu $2,$25 + xor $9,$11 + sll $25,$2,5 # 64 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $9,$17 + xor $25,$7,$24 + addu $1,$6 + xor $9,$22 + sll $30,$3,30 + xor $25,$3 + srl $6,$9,31 + addu $9,$9 + srl $3,$3,2 + addu $1,$8 + or $9,$6 + or $3,$30 + addu $1,$25 + xor $10,$12 + sll $25,$1,5 # 65 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $10,$18 + xor $25,$3,$7 + addu $24,$6 + xor $10,$23 + sll $30,$2,30 + xor $25,$2 + srl $6,$10,31 + addu $10,$10 + srl $2,$2,2 + addu $24,$9 + or $10,$6 + or $2,$30 + addu $24,$25 + xor $11,$13 + sll $25,$24,5 # 66 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $11,$19 + xor $25,$2,$3 + addu $7,$6 + xor $11,$8 + sll $30,$1,30 + xor $25,$1 + srl $6,$11,31 + addu $11,$11 + srl $1,$1,2 + addu $7,$10 + or $11,$6 + or $1,$30 + addu $7,$25 + xor $12,$14 + sll $25,$7,5 # 67 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $12,$20 + xor $25,$1,$2 + addu $3,$6 + xor $12,$9 + sll $30,$24,30 + xor $25,$24 + srl $6,$12,31 + addu $12,$12 + srl $24,$24,2 + addu $3,$11 + or $12,$6 + or $24,$30 + addu $3,$25 + xor $13,$15 + sll $25,$3,5 # 68 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $13,$21 + xor $25,$24,$1 + addu $2,$6 + xor $13,$10 + sll $30,$7,30 + xor $25,$7 + srl $6,$13,31 + addu $13,$13 + srl $7,$7,2 + addu $2,$12 + or $13,$6 + or $7,$30 + addu $2,$25 + xor $14,$16 + sll $25,$2,5 # 69 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $14,$22 + xor $25,$7,$24 + addu $1,$6 + xor $14,$11 + sll $30,$3,30 + xor $25,$3 + srl $6,$14,31 + addu $14,$14 + srl $3,$3,2 + addu $1,$13 + or $14,$6 + or $3,$30 + addu $1,$25 + xor $15,$17 + sll $25,$1,5 # 70 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $15,$23 + xor $25,$3,$7 + addu $24,$6 + xor $15,$12 + sll $30,$2,30 + xor $25,$2 + srl $6,$15,31 + addu $15,$15 + srl $2,$2,2 + addu $24,$14 + or $15,$6 + or $2,$30 + addu $24,$25 + xor $16,$18 + sll $25,$24,5 # 71 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $16,$8 + xor $25,$2,$3 + addu $7,$6 + xor $16,$13 + sll $30,$1,30 + xor $25,$1 + srl $6,$16,31 + addu $16,$16 + srl $1,$1,2 + addu $7,$15 + or $16,$6 + or $1,$30 + addu $7,$25 + xor $17,$19 + sll $25,$7,5 # 72 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $17,$9 + xor $25,$1,$2 + addu $3,$6 + xor $17,$14 + sll $30,$24,30 + xor $25,$24 + srl $6,$17,31 + addu $17,$17 + srl $24,$24,2 + addu $3,$16 + or $17,$6 + or $24,$30 + addu $3,$25 + xor $18,$20 + sll $25,$3,5 # 73 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $18,$10 + xor $25,$24,$1 + addu $2,$6 + xor $18,$15 + sll $30,$7,30 + xor $25,$7 + srl $6,$18,31 + addu $18,$18 + srl $7,$7,2 + addu $2,$17 + or $18,$6 + or $7,$30 + addu $2,$25 + xor $19,$21 + sll $25,$2,5 # 74 + addu $1,$31 + srl $6,$2,27 + addu $1,$25 + xor $19,$11 + xor $25,$7,$24 + addu $1,$6 + xor $19,$16 + sll $30,$3,30 + xor $25,$3 + srl $6,$19,31 + addu $19,$19 + srl $3,$3,2 + addu $1,$18 + or $19,$6 + or $3,$30 + addu $1,$25 + xor $20,$22 + sll $25,$1,5 # 75 + addu $24,$31 + srl $6,$1,27 + addu $24,$25 + xor $20,$12 + xor $25,$3,$7 + addu $24,$6 + xor $20,$17 + sll $30,$2,30 + xor $25,$2 + srl $6,$20,31 + addu $20,$20 + srl $2,$2,2 + addu $24,$19 + or $20,$6 + or $2,$30 + addu $24,$25 + xor $21,$23 + sll $25,$24,5 # 76 + addu $7,$31 + srl $6,$24,27 + addu $7,$25 + xor $21,$13 + xor $25,$2,$3 + addu $7,$6 + xor $21,$18 + sll $30,$1,30 + xor $25,$1 + srl $6,$21,31 + addu $21,$21 + srl $1,$1,2 + addu $7,$20 + or $21,$6 + or $1,$30 + addu $7,$25 + xor $22,$8 + sll $25,$7,5 # 77 + addu $3,$31 + srl $6,$7,27 + addu $3,$25 + xor $22,$14 + xor $25,$1,$2 + addu $3,$6 + xor $22,$19 + sll $30,$24,30 + xor $25,$24 + srl $6,$22,31 + addu $22,$22 + srl $24,$24,2 + addu $3,$21 + or $22,$6 + or $24,$30 + addu $3,$25 + xor $23,$9 + sll $25,$3,5 # 78 + addu $2,$31 + srl $6,$3,27 + addu $2,$25 + xor $23,$15 + xor $25,$24,$1 + addu $2,$6 + xor $23,$20 + sll $30,$7,30 + xor $25,$7 + srl $6,$23,31 + addu $23,$23 + srl $7,$7,2 + addu $2,$22 + or $23,$6 + or $7,$30 + addu $2,$25 + lw $8,0($4) + sll $25,$2,5 # 79 + addu $1,$31 + lw $9,4($4) + srl $6,$2,27 + addu $1,$25 + lw $10,8($4) + xor $25,$7,$24 + addu $1,$6 + lw $11,12($4) + sll $30,$3,30 + xor $25,$3 + lw $12,16($4) + srl $3,$3,2 + addu $1,$23 + or $3,$30 + addu $1,$25 + add $5,64 + lw $6,0($29) + + addu $1,$8 + addu $2,$9 + sw $1,0($4) + addu $3,$10 + addu $7,$11 + sw $2,4($4) + addu $24,$12 + sw $3,8($4) + sw $7,12($4) + sw $24,16($4) + .set noreorder + bne $5,$6,.Loop + nop + + .set noreorder + lw $31,(16-1)*4($29) + lw $30,(16-2)*4($29) + lw $23,(16-3)*4($29) + lw $22,(16-4)*4($29) + lw $21,(16-5)*4($29) + lw $20,(16-6)*4($29) + lw $19,(16-7)*4($29) + lw $18,(16-8)*4($29) + lw $17,(16-9)*4($29) + lw $16,(16-10)*4($29) + jr $31 + add $29,16*4 +.end sha1_block_data_order +.rdata +.asciiz "SHA1 for MIPS, CRYPTOGAMS by " +#if defined(HAVE_GNU_STACK) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/sha/sha1dgst.c b/crypto/sha/sha1dgst.c index 583d1068..16580dcb 100644 --- a/crypto/sha/sha1dgst.c +++ b/crypto/sha/sha1dgst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha1dgst.c,v 1.14 2015/09/13 21:09:56 doug Exp $ */ +/* $OpenBSD: sha1dgst.c,v 1.15 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,7 +66,7 @@ /* The implementation is in ../md32_common.h */ -#include "sha_locl.h" +#include "sha_local.h" #endif diff --git a/crypto/sha/sha256-elf-x86_64.S b/crypto/sha/sha256-elf-x86_64.S index 9eea6a7c..a99ff271 100644 --- a/crypto/sha/sha256-elf-x86_64.S +++ b/crypto/sha/sha256-elf-x86_64.S @@ -1758,6 +1758,7 @@ sha256_block_data_order: .Lepilogue: retq .size sha256_block_data_order,.-sha256_block_data_order +.section .rodata .align 64 .type K256,@object K256: @@ -1777,6 +1778,7 @@ K256: .long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 .long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 .long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +.text #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/sha/sha256-macosx-x86_64.S b/crypto/sha/sha256-macosx-x86_64.S index 4b468b7f..8001a01c 100644 --- a/crypto/sha/sha256-macosx-x86_64.S +++ b/crypto/sha/sha256-macosx-x86_64.S @@ -1758,6 +1758,7 @@ L$rounds_16_xx: L$epilogue: retq +.section __DATA,__const .p2align 6 K256: @@ -1777,3 +1778,4 @@ K256: .long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 .long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 .long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +.text diff --git a/crypto/sha/sha256-masm-x86_64.S b/crypto/sha/sha256-masm-x86_64.S index 7c182f90..5c58db3b 100644 --- a/crypto/sha/sha256-masm-x86_64.S +++ b/crypto/sha/sha256-masm-x86_64.S @@ -1839,6 +1839,8 @@ $L$epilogue:: DB 0F3h,0C3h ;repret $L$SEH_end_sha256_block_data_order:: sha256_block_data_order ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 K256:: @@ -1858,6 +1860,8 @@ K256:: DD 0391c0cb3h,04ed8aa4ah,05b9cca4fh,0682e6ff3h DD 0748f82eeh,078a5636fh,084c87814h,08cc70208h DD 090befffah,0a4506cebh,0bef9a3f7h,0c67178f2h +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' .text$ ENDS END diff --git a/crypto/sha/sha256-mingw64-x86_64.S b/crypto/sha/sha256-mingw64-x86_64.S index 3de981b8..9db03f60 100644 --- a/crypto/sha/sha256-mingw64-x86_64.S +++ b/crypto/sha/sha256-mingw64-x86_64.S @@ -1769,6 +1769,7 @@ sha256_block_data_order: movq 16(%rsp),%rsi retq .LSEH_end_sha256_block_data_order: +.section .rodata .p2align 6 K256: @@ -1788,3 +1789,4 @@ K256: .long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 .long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 .long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +.text diff --git a/crypto/sha/sha256-mips.S b/crypto/sha/sha256-mips.S new file mode 100644 index 00000000..3070f55e --- /dev/null +++ b/crypto/sha/sha256-mips.S @@ -0,0 +1,1997 @@ +.text +.set noat +#if !defined(__vxworks) || defined(__pic__) +.option pic2 +#endif + +.align 5 +.globl sha256_block_data_order +.ent sha256_block_data_order +sha256_block_data_order: + .frame $29,128,$31 + .mask 3237937152,-4 + .set noreorder + .cpload $25 + sub $29,128 + sw $31,128-1*4($29) + sw $30,128-2*4($29) + sw $23,128-3*4($29) + sw $22,128-4*4($29) + sw $21,128-5*4($29) + sw $20,128-6*4($29) + sw $19,128-7*4($29) + sw $18,128-8*4($29) + sw $17,128-9*4($29) + sw $16,128-10*4($29) + sll $23,$6,6 + .set reorder + la $6,K256 # PIC-ified 'load address' + + lw $1,0*4($4) # load context + lw $2,1*4($4) + lw $3,2*4($4) + lw $7,3*4($4) + lw $24,4*4($4) + lw $25,5*4($4) + lw $30,6*4($4) + lw $31,7*4($4) + + add $23,$5 # pointer to the end of input + sw $23,16*4($29) + b .Loop + +.align 5 +.Loop: + lwl $8,3($5) + lwr $8,0($5) + lwl $9,7($5) + lwr $9,4($5) + srl $13,$8,24 # byte swap(0) + srl $14,$8,8 + andi $15,$8,0xFF00 + sll $8,$8,24 + andi $14,0xFF00 + sll $15,$15,8 + or $8,$13 + or $14,$15 + or $8,$14 + addu $12,$8,$31 # 0 + srl $31,$24,6 + xor $15,$25,$30 + sll $14,$24,7 + and $15,$24 + srl $13,$24,11 + xor $31,$14 + sll $14,$24,21 + xor $31,$13 + srl $13,$24,25 + xor $31,$14 + sll $14,$24,26 + xor $31,$13 + xor $15,$30 # Ch(e,f,g) + xor $13,$14,$31 # Sigma1(e) + + srl $31,$1,2 + addu $12,$15 + lw $15,0($6) # K[0] + sll $14,$1,10 + addu $12,$13 + srl $13,$1,13 + xor $31,$14 + sll $14,$1,19 + xor $31,$13 + srl $13,$1,22 + xor $31,$14 + sll $14,$1,30 + xor $31,$13 + sw $8,0($29) # offload to ring buffer + xor $31,$14 # Sigma0(a) + + or $13,$1,$2 + and $14,$1,$2 + and $13,$3 + or $14,$13 # Maj(a,b,c) + addu $12,$15 # +=K[0] + addu $31,$14 + + addu $7,$12 + addu $31,$12 + lwl $10,11($5) + lwr $10,8($5) + srl $14,$9,24 # byte swap(1) + srl $15,$9,8 + andi $16,$9,0xFF00 + sll $9,$9,24 + andi $15,0xFF00 + sll $16,$16,8 + or $9,$14 + or $15,$16 + or $9,$15 + addu $13,$9,$30 # 1 + srl $30,$7,6 + xor $16,$24,$25 + sll $15,$7,7 + and $16,$7 + srl $14,$7,11 + xor $30,$15 + sll $15,$7,21 + xor $30,$14 + srl $14,$7,25 + xor $30,$15 + sll $15,$7,26 + xor $30,$14 + xor $16,$25 # Ch(e,f,g) + xor $14,$15,$30 # Sigma1(e) + + srl $30,$31,2 + addu $13,$16 + lw $16,4($6) # K[1] + sll $15,$31,10 + addu $13,$14 + srl $14,$31,13 + xor $30,$15 + sll $15,$31,19 + xor $30,$14 + srl $14,$31,22 + xor $30,$15 + sll $15,$31,30 + xor $30,$14 + sw $9,4($29) # offload to ring buffer + xor $30,$15 # Sigma0(a) + + or $14,$31,$1 + and $15,$31,$1 + and $14,$2 + or $15,$14 # Maj(a,b,c) + addu $13,$16 # +=K[1] + addu $30,$15 + + addu $3,$13 + addu $30,$13 + lwl $11,15($5) + lwr $11,12($5) + srl $15,$10,24 # byte swap(2) + srl $16,$10,8 + andi $17,$10,0xFF00 + sll $10,$10,24 + andi $16,0xFF00 + sll $17,$17,8 + or $10,$15 + or $16,$17 + or $10,$16 + addu $14,$10,$25 # 2 + srl $25,$3,6 + xor $17,$7,$24 + sll $16,$3,7 + and $17,$3 + srl $15,$3,11 + xor $25,$16 + sll $16,$3,21 + xor $25,$15 + srl $15,$3,25 + xor $25,$16 + sll $16,$3,26 + xor $25,$15 + xor $17,$24 # Ch(e,f,g) + xor $15,$16,$25 # Sigma1(e) + + srl $25,$30,2 + addu $14,$17 + lw $17,8($6) # K[2] + sll $16,$30,10 + addu $14,$15 + srl $15,$30,13 + xor $25,$16 + sll $16,$30,19 + xor $25,$15 + srl $15,$30,22 + xor $25,$16 + sll $16,$30,30 + xor $25,$15 + sw $10,8($29) # offload to ring buffer + xor $25,$16 # Sigma0(a) + + or $15,$30,$31 + and $16,$30,$31 + and $15,$1 + or $16,$15 # Maj(a,b,c) + addu $14,$17 # +=K[2] + addu $25,$16 + + addu $2,$14 + addu $25,$14 + lwl $12,19($5) + lwr $12,16($5) + srl $16,$11,24 # byte swap(3) + srl $17,$11,8 + andi $18,$11,0xFF00 + sll $11,$11,24 + andi $17,0xFF00 + sll $18,$18,8 + or $11,$16 + or $17,$18 + or $11,$17 + addu $15,$11,$24 # 3 + srl $24,$2,6 + xor $18,$3,$7 + sll $17,$2,7 + and $18,$2 + srl $16,$2,11 + xor $24,$17 + sll $17,$2,21 + xor $24,$16 + srl $16,$2,25 + xor $24,$17 + sll $17,$2,26 + xor $24,$16 + xor $18,$7 # Ch(e,f,g) + xor $16,$17,$24 # Sigma1(e) + + srl $24,$25,2 + addu $15,$18 + lw $18,12($6) # K[3] + sll $17,$25,10 + addu $15,$16 + srl $16,$25,13 + xor $24,$17 + sll $17,$25,19 + xor $24,$16 + srl $16,$25,22 + xor $24,$17 + sll $17,$25,30 + xor $24,$16 + sw $11,12($29) # offload to ring buffer + xor $24,$17 # Sigma0(a) + + or $16,$25,$30 + and $17,$25,$30 + and $16,$31 + or $17,$16 # Maj(a,b,c) + addu $15,$18 # +=K[3] + addu $24,$17 + + addu $1,$15 + addu $24,$15 + lwl $13,23($5) + lwr $13,20($5) + srl $17,$12,24 # byte swap(4) + srl $18,$12,8 + andi $19,$12,0xFF00 + sll $12,$12,24 + andi $18,0xFF00 + sll $19,$19,8 + or $12,$17 + or $18,$19 + or $12,$18 + addu $16,$12,$7 # 4 + srl $7,$1,6 + xor $19,$2,$3 + sll $18,$1,7 + and $19,$1 + srl $17,$1,11 + xor $7,$18 + sll $18,$1,21 + xor $7,$17 + srl $17,$1,25 + xor $7,$18 + sll $18,$1,26 + xor $7,$17 + xor $19,$3 # Ch(e,f,g) + xor $17,$18,$7 # Sigma1(e) + + srl $7,$24,2 + addu $16,$19 + lw $19,16($6) # K[4] + sll $18,$24,10 + addu $16,$17 + srl $17,$24,13 + xor $7,$18 + sll $18,$24,19 + xor $7,$17 + srl $17,$24,22 + xor $7,$18 + sll $18,$24,30 + xor $7,$17 + sw $12,16($29) # offload to ring buffer + xor $7,$18 # Sigma0(a) + + or $17,$24,$25 + and $18,$24,$25 + and $17,$30 + or $18,$17 # Maj(a,b,c) + addu $16,$19 # +=K[4] + addu $7,$18 + + addu $31,$16 + addu $7,$16 + lwl $14,27($5) + lwr $14,24($5) + srl $18,$13,24 # byte swap(5) + srl $19,$13,8 + andi $20,$13,0xFF00 + sll $13,$13,24 + andi $19,0xFF00 + sll $20,$20,8 + or $13,$18 + or $19,$20 + or $13,$19 + addu $17,$13,$3 # 5 + srl $3,$31,6 + xor $20,$1,$2 + sll $19,$31,7 + and $20,$31 + srl $18,$31,11 + xor $3,$19 + sll $19,$31,21 + xor $3,$18 + srl $18,$31,25 + xor $3,$19 + sll $19,$31,26 + xor $3,$18 + xor $20,$2 # Ch(e,f,g) + xor $18,$19,$3 # Sigma1(e) + + srl $3,$7,2 + addu $17,$20 + lw $20,20($6) # K[5] + sll $19,$7,10 + addu $17,$18 + srl $18,$7,13 + xor $3,$19 + sll $19,$7,19 + xor $3,$18 + srl $18,$7,22 + xor $3,$19 + sll $19,$7,30 + xor $3,$18 + sw $13,20($29) # offload to ring buffer + xor $3,$19 # Sigma0(a) + + or $18,$7,$24 + and $19,$7,$24 + and $18,$25 + or $19,$18 # Maj(a,b,c) + addu $17,$20 # +=K[5] + addu $3,$19 + + addu $30,$17 + addu $3,$17 + lwl $15,31($5) + lwr $15,28($5) + srl $19,$14,24 # byte swap(6) + srl $20,$14,8 + andi $21,$14,0xFF00 + sll $14,$14,24 + andi $20,0xFF00 + sll $21,$21,8 + or $14,$19 + or $20,$21 + or $14,$20 + addu $18,$14,$2 # 6 + srl $2,$30,6 + xor $21,$31,$1 + sll $20,$30,7 + and $21,$30 + srl $19,$30,11 + xor $2,$20 + sll $20,$30,21 + xor $2,$19 + srl $19,$30,25 + xor $2,$20 + sll $20,$30,26 + xor $2,$19 + xor $21,$1 # Ch(e,f,g) + xor $19,$20,$2 # Sigma1(e) + + srl $2,$3,2 + addu $18,$21 + lw $21,24($6) # K[6] + sll $20,$3,10 + addu $18,$19 + srl $19,$3,13 + xor $2,$20 + sll $20,$3,19 + xor $2,$19 + srl $19,$3,22 + xor $2,$20 + sll $20,$3,30 + xor $2,$19 + sw $14,24($29) # offload to ring buffer + xor $2,$20 # Sigma0(a) + + or $19,$3,$7 + and $20,$3,$7 + and $19,$24 + or $20,$19 # Maj(a,b,c) + addu $18,$21 # +=K[6] + addu $2,$20 + + addu $25,$18 + addu $2,$18 + lwl $16,35($5) + lwr $16,32($5) + srl $20,$15,24 # byte swap(7) + srl $21,$15,8 + andi $22,$15,0xFF00 + sll $15,$15,24 + andi $21,0xFF00 + sll $22,$22,8 + or $15,$20 + or $21,$22 + or $15,$21 + addu $19,$15,$1 # 7 + srl $1,$25,6 + xor $22,$30,$31 + sll $21,$25,7 + and $22,$25 + srl $20,$25,11 + xor $1,$21 + sll $21,$25,21 + xor $1,$20 + srl $20,$25,25 + xor $1,$21 + sll $21,$25,26 + xor $1,$20 + xor $22,$31 # Ch(e,f,g) + xor $20,$21,$1 # Sigma1(e) + + srl $1,$2,2 + addu $19,$22 + lw $22,28($6) # K[7] + sll $21,$2,10 + addu $19,$20 + srl $20,$2,13 + xor $1,$21 + sll $21,$2,19 + xor $1,$20 + srl $20,$2,22 + xor $1,$21 + sll $21,$2,30 + xor $1,$20 + sw $15,28($29) # offload to ring buffer + xor $1,$21 # Sigma0(a) + + or $20,$2,$3 + and $21,$2,$3 + and $20,$7 + or $21,$20 # Maj(a,b,c) + addu $19,$22 # +=K[7] + addu $1,$21 + + addu $24,$19 + addu $1,$19 + lwl $17,39($5) + lwr $17,36($5) + srl $21,$16,24 # byte swap(8) + srl $22,$16,8 + andi $23,$16,0xFF00 + sll $16,$16,24 + andi $22,0xFF00 + sll $23,$23,8 + or $16,$21 + or $22,$23 + or $16,$22 + addu $20,$16,$31 # 8 + srl $31,$24,6 + xor $23,$25,$30 + sll $22,$24,7 + and $23,$24 + srl $21,$24,11 + xor $31,$22 + sll $22,$24,21 + xor $31,$21 + srl $21,$24,25 + xor $31,$22 + sll $22,$24,26 + xor $31,$21 + xor $23,$30 # Ch(e,f,g) + xor $21,$22,$31 # Sigma1(e) + + srl $31,$1,2 + addu $20,$23 + lw $23,32($6) # K[8] + sll $22,$1,10 + addu $20,$21 + srl $21,$1,13 + xor $31,$22 + sll $22,$1,19 + xor $31,$21 + srl $21,$1,22 + xor $31,$22 + sll $22,$1,30 + xor $31,$21 + sw $16,32($29) # offload to ring buffer + xor $31,$22 # Sigma0(a) + + or $21,$1,$2 + and $22,$1,$2 + and $21,$3 + or $22,$21 # Maj(a,b,c) + addu $20,$23 # +=K[8] + addu $31,$22 + + addu $7,$20 + addu $31,$20 + lwl $18,43($5) + lwr $18,40($5) + srl $22,$17,24 # byte swap(9) + srl $23,$17,8 + andi $8,$17,0xFF00 + sll $17,$17,24 + andi $23,0xFF00 + sll $8,$8,8 + or $17,$22 + or $23,$8 + or $17,$23 + addu $21,$17,$30 # 9 + srl $30,$7,6 + xor $8,$24,$25 + sll $23,$7,7 + and $8,$7 + srl $22,$7,11 + xor $30,$23 + sll $23,$7,21 + xor $30,$22 + srl $22,$7,25 + xor $30,$23 + sll $23,$7,26 + xor $30,$22 + xor $8,$25 # Ch(e,f,g) + xor $22,$23,$30 # Sigma1(e) + + srl $30,$31,2 + addu $21,$8 + lw $8,36($6) # K[9] + sll $23,$31,10 + addu $21,$22 + srl $22,$31,13 + xor $30,$23 + sll $23,$31,19 + xor $30,$22 + srl $22,$31,22 + xor $30,$23 + sll $23,$31,30 + xor $30,$22 + sw $17,36($29) # offload to ring buffer + xor $30,$23 # Sigma0(a) + + or $22,$31,$1 + and $23,$31,$1 + and $22,$2 + or $23,$22 # Maj(a,b,c) + addu $21,$8 # +=K[9] + addu $30,$23 + + addu $3,$21 + addu $30,$21 + lwl $19,47($5) + lwr $19,44($5) + srl $23,$18,24 # byte swap(10) + srl $8,$18,8 + andi $9,$18,0xFF00 + sll $18,$18,24 + andi $8,0xFF00 + sll $9,$9,8 + or $18,$23 + or $8,$9 + or $18,$8 + addu $22,$18,$25 # 10 + srl $25,$3,6 + xor $9,$7,$24 + sll $8,$3,7 + and $9,$3 + srl $23,$3,11 + xor $25,$8 + sll $8,$3,21 + xor $25,$23 + srl $23,$3,25 + xor $25,$8 + sll $8,$3,26 + xor $25,$23 + xor $9,$24 # Ch(e,f,g) + xor $23,$8,$25 # Sigma1(e) + + srl $25,$30,2 + addu $22,$9 + lw $9,40($6) # K[10] + sll $8,$30,10 + addu $22,$23 + srl $23,$30,13 + xor $25,$8 + sll $8,$30,19 + xor $25,$23 + srl $23,$30,22 + xor $25,$8 + sll $8,$30,30 + xor $25,$23 + sw $18,40($29) # offload to ring buffer + xor $25,$8 # Sigma0(a) + + or $23,$30,$31 + and $8,$30,$31 + and $23,$1 + or $8,$23 # Maj(a,b,c) + addu $22,$9 # +=K[10] + addu $25,$8 + + addu $2,$22 + addu $25,$22 + lwl $20,51($5) + lwr $20,48($5) + srl $8,$19,24 # byte swap(11) + srl $9,$19,8 + andi $10,$19,0xFF00 + sll $19,$19,24 + andi $9,0xFF00 + sll $10,$10,8 + or $19,$8 + or $9,$10 + or $19,$9 + addu $23,$19,$24 # 11 + srl $24,$2,6 + xor $10,$3,$7 + sll $9,$2,7 + and $10,$2 + srl $8,$2,11 + xor $24,$9 + sll $9,$2,21 + xor $24,$8 + srl $8,$2,25 + xor $24,$9 + sll $9,$2,26 + xor $24,$8 + xor $10,$7 # Ch(e,f,g) + xor $8,$9,$24 # Sigma1(e) + + srl $24,$25,2 + addu $23,$10 + lw $10,44($6) # K[11] + sll $9,$25,10 + addu $23,$8 + srl $8,$25,13 + xor $24,$9 + sll $9,$25,19 + xor $24,$8 + srl $8,$25,22 + xor $24,$9 + sll $9,$25,30 + xor $24,$8 + sw $19,44($29) # offload to ring buffer + xor $24,$9 # Sigma0(a) + + or $8,$25,$30 + and $9,$25,$30 + and $8,$31 + or $9,$8 # Maj(a,b,c) + addu $23,$10 # +=K[11] + addu $24,$9 + + addu $1,$23 + addu $24,$23 + lwl $21,55($5) + lwr $21,52($5) + srl $9,$20,24 # byte swap(12) + srl $10,$20,8 + andi $11,$20,0xFF00 + sll $20,$20,24 + andi $10,0xFF00 + sll $11,$11,8 + or $20,$9 + or $10,$11 + or $20,$10 + addu $8,$20,$7 # 12 + srl $7,$1,6 + xor $11,$2,$3 + sll $10,$1,7 + and $11,$1 + srl $9,$1,11 + xor $7,$10 + sll $10,$1,21 + xor $7,$9 + srl $9,$1,25 + xor $7,$10 + sll $10,$1,26 + xor $7,$9 + xor $11,$3 # Ch(e,f,g) + xor $9,$10,$7 # Sigma1(e) + + srl $7,$24,2 + addu $8,$11 + lw $11,48($6) # K[12] + sll $10,$24,10 + addu $8,$9 + srl $9,$24,13 + xor $7,$10 + sll $10,$24,19 + xor $7,$9 + srl $9,$24,22 + xor $7,$10 + sll $10,$24,30 + xor $7,$9 + sw $20,48($29) # offload to ring buffer + xor $7,$10 # Sigma0(a) + + or $9,$24,$25 + and $10,$24,$25 + and $9,$30 + or $10,$9 # Maj(a,b,c) + addu $8,$11 # +=K[12] + addu $7,$10 + + addu $31,$8 + addu $7,$8 + lwl $22,59($5) + lwr $22,56($5) + srl $10,$21,24 # byte swap(13) + srl $11,$21,8 + andi $12,$21,0xFF00 + sll $21,$21,24 + andi $11,0xFF00 + sll $12,$12,8 + or $21,$10 + or $11,$12 + or $21,$11 + addu $9,$21,$3 # 13 + srl $3,$31,6 + xor $12,$1,$2 + sll $11,$31,7 + and $12,$31 + srl $10,$31,11 + xor $3,$11 + sll $11,$31,21 + xor $3,$10 + srl $10,$31,25 + xor $3,$11 + sll $11,$31,26 + xor $3,$10 + xor $12,$2 # Ch(e,f,g) + xor $10,$11,$3 # Sigma1(e) + + srl $3,$7,2 + addu $9,$12 + lw $12,52($6) # K[13] + sll $11,$7,10 + addu $9,$10 + srl $10,$7,13 + xor $3,$11 + sll $11,$7,19 + xor $3,$10 + srl $10,$7,22 + xor $3,$11 + sll $11,$7,30 + xor $3,$10 + sw $21,52($29) # offload to ring buffer + xor $3,$11 # Sigma0(a) + + or $10,$7,$24 + and $11,$7,$24 + and $10,$25 + or $11,$10 # Maj(a,b,c) + addu $9,$12 # +=K[13] + addu $3,$11 + + addu $30,$9 + addu $3,$9 + lw $8,0($29) # prefetch from ring buffer + lwl $23,63($5) + lwr $23,60($5) + srl $11,$22,24 # byte swap(14) + srl $12,$22,8 + andi $13,$22,0xFF00 + sll $22,$22,24 + andi $12,0xFF00 + sll $13,$13,8 + or $22,$11 + or $12,$13 + or $22,$12 + addu $10,$22,$2 # 14 + srl $2,$30,6 + xor $13,$31,$1 + sll $12,$30,7 + and $13,$30 + srl $11,$30,11 + xor $2,$12 + sll $12,$30,21 + xor $2,$11 + srl $11,$30,25 + xor $2,$12 + sll $12,$30,26 + xor $2,$11 + xor $13,$1 # Ch(e,f,g) + xor $11,$12,$2 # Sigma1(e) + + srl $2,$3,2 + addu $10,$13 + lw $13,56($6) # K[14] + sll $12,$3,10 + addu $10,$11 + srl $11,$3,13 + xor $2,$12 + sll $12,$3,19 + xor $2,$11 + srl $11,$3,22 + xor $2,$12 + sll $12,$3,30 + xor $2,$11 + sw $22,56($29) # offload to ring buffer + xor $2,$12 # Sigma0(a) + + or $11,$3,$7 + and $12,$3,$7 + and $11,$24 + or $12,$11 # Maj(a,b,c) + addu $10,$13 # +=K[14] + addu $2,$12 + + addu $25,$10 + addu $2,$10 + lw $9,4($29) # prefetch from ring buffer + srl $12,$23,24 # byte swap(15) + srl $13,$23,8 + andi $14,$23,0xFF00 + sll $23,$23,24 + andi $13,0xFF00 + sll $14,$14,8 + or $23,$12 + or $13,$14 + or $23,$13 + addu $11,$23,$1 # 15 + srl $1,$25,6 + xor $14,$30,$31 + sll $13,$25,7 + and $14,$25 + srl $12,$25,11 + xor $1,$13 + sll $13,$25,21 + xor $1,$12 + srl $12,$25,25 + xor $1,$13 + sll $13,$25,26 + xor $1,$12 + xor $14,$31 # Ch(e,f,g) + xor $12,$13,$1 # Sigma1(e) + + srl $1,$2,2 + addu $11,$14 + lw $14,60($6) # K[15] + sll $13,$2,10 + addu $11,$12 + srl $12,$2,13 + xor $1,$13 + sll $13,$2,19 + xor $1,$12 + srl $12,$2,22 + xor $1,$13 + sll $13,$2,30 + xor $1,$12 + sw $23,60($29) # offload to ring buffer + xor $1,$13 # Sigma0(a) + + or $12,$2,$3 + and $13,$2,$3 + and $12,$7 + or $13,$12 # Maj(a,b,c) + addu $11,$14 # +=K[15] + addu $1,$13 + + addu $24,$11 + addu $1,$11 + lw $10,8($29) # prefetch from ring buffer + b .L16_xx +.align 4 +.L16_xx: + srl $14,$9,3 # Xupdate(16) + addu $8,$17 # +=X[i+9] + sll $13,$9,14 + srl $12,$9,7 + xor $14,$13 + sll $13,11 + xor $14,$12 + srl $12,$9,18 + xor $14,$13 + + srl $15,$22,10 + xor $14,$12 # sigma0(X[i+1]) + sll $13,$22,13 + addu $8,$14 + srl $12,$22,17 + xor $15,$13 + sll $13,2 + xor $15,$12 + srl $12,$22,19 + xor $15,$13 + + xor $15,$12 # sigma1(X[i+14]) + addu $8,$15 + addu $12,$8,$31 # 16 + srl $31,$24,6 + xor $15,$25,$30 + sll $14,$24,7 + and $15,$24 + srl $13,$24,11 + xor $31,$14 + sll $14,$24,21 + xor $31,$13 + srl $13,$24,25 + xor $31,$14 + sll $14,$24,26 + xor $31,$13 + xor $15,$30 # Ch(e,f,g) + xor $13,$14,$31 # Sigma1(e) + + srl $31,$1,2 + addu $12,$15 + lw $15,64($6) # K[16] + sll $14,$1,10 + addu $12,$13 + srl $13,$1,13 + xor $31,$14 + sll $14,$1,19 + xor $31,$13 + srl $13,$1,22 + xor $31,$14 + sll $14,$1,30 + xor $31,$13 + sw $8,0($29) # offload to ring buffer + xor $31,$14 # Sigma0(a) + + or $13,$1,$2 + and $14,$1,$2 + and $13,$3 + or $14,$13 # Maj(a,b,c) + addu $12,$15 # +=K[16] + addu $31,$14 + + addu $7,$12 + addu $31,$12 + lw $11,12($29) # prefetch from ring buffer + srl $15,$10,3 # Xupdate(17) + addu $9,$18 # +=X[i+9] + sll $14,$10,14 + srl $13,$10,7 + xor $15,$14 + sll $14,11 + xor $15,$13 + srl $13,$10,18 + xor $15,$14 + + srl $16,$23,10 + xor $15,$13 # sigma0(X[i+1]) + sll $14,$23,13 + addu $9,$15 + srl $13,$23,17 + xor $16,$14 + sll $14,2 + xor $16,$13 + srl $13,$23,19 + xor $16,$14 + + xor $16,$13 # sigma1(X[i+14]) + addu $9,$16 + addu $13,$9,$30 # 17 + srl $30,$7,6 + xor $16,$24,$25 + sll $15,$7,7 + and $16,$7 + srl $14,$7,11 + xor $30,$15 + sll $15,$7,21 + xor $30,$14 + srl $14,$7,25 + xor $30,$15 + sll $15,$7,26 + xor $30,$14 + xor $16,$25 # Ch(e,f,g) + xor $14,$15,$30 # Sigma1(e) + + srl $30,$31,2 + addu $13,$16 + lw $16,68($6) # K[17] + sll $15,$31,10 + addu $13,$14 + srl $14,$31,13 + xor $30,$15 + sll $15,$31,19 + xor $30,$14 + srl $14,$31,22 + xor $30,$15 + sll $15,$31,30 + xor $30,$14 + sw $9,4($29) # offload to ring buffer + xor $30,$15 # Sigma0(a) + + or $14,$31,$1 + and $15,$31,$1 + and $14,$2 + or $15,$14 # Maj(a,b,c) + addu $13,$16 # +=K[17] + addu $30,$15 + + addu $3,$13 + addu $30,$13 + lw $12,16($29) # prefetch from ring buffer + srl $16,$11,3 # Xupdate(18) + addu $10,$19 # +=X[i+9] + sll $15,$11,14 + srl $14,$11,7 + xor $16,$15 + sll $15,11 + xor $16,$14 + srl $14,$11,18 + xor $16,$15 + + srl $17,$8,10 + xor $16,$14 # sigma0(X[i+1]) + sll $15,$8,13 + addu $10,$16 + srl $14,$8,17 + xor $17,$15 + sll $15,2 + xor $17,$14 + srl $14,$8,19 + xor $17,$15 + + xor $17,$14 # sigma1(X[i+14]) + addu $10,$17 + addu $14,$10,$25 # 18 + srl $25,$3,6 + xor $17,$7,$24 + sll $16,$3,7 + and $17,$3 + srl $15,$3,11 + xor $25,$16 + sll $16,$3,21 + xor $25,$15 + srl $15,$3,25 + xor $25,$16 + sll $16,$3,26 + xor $25,$15 + xor $17,$24 # Ch(e,f,g) + xor $15,$16,$25 # Sigma1(e) + + srl $25,$30,2 + addu $14,$17 + lw $17,72($6) # K[18] + sll $16,$30,10 + addu $14,$15 + srl $15,$30,13 + xor $25,$16 + sll $16,$30,19 + xor $25,$15 + srl $15,$30,22 + xor $25,$16 + sll $16,$30,30 + xor $25,$15 + sw $10,8($29) # offload to ring buffer + xor $25,$16 # Sigma0(a) + + or $15,$30,$31 + and $16,$30,$31 + and $15,$1 + or $16,$15 # Maj(a,b,c) + addu $14,$17 # +=K[18] + addu $25,$16 + + addu $2,$14 + addu $25,$14 + lw $13,20($29) # prefetch from ring buffer + srl $17,$12,3 # Xupdate(19) + addu $11,$20 # +=X[i+9] + sll $16,$12,14 + srl $15,$12,7 + xor $17,$16 + sll $16,11 + xor $17,$15 + srl $15,$12,18 + xor $17,$16 + + srl $18,$9,10 + xor $17,$15 # sigma0(X[i+1]) + sll $16,$9,13 + addu $11,$17 + srl $15,$9,17 + xor $18,$16 + sll $16,2 + xor $18,$15 + srl $15,$9,19 + xor $18,$16 + + xor $18,$15 # sigma1(X[i+14]) + addu $11,$18 + addu $15,$11,$24 # 19 + srl $24,$2,6 + xor $18,$3,$7 + sll $17,$2,7 + and $18,$2 + srl $16,$2,11 + xor $24,$17 + sll $17,$2,21 + xor $24,$16 + srl $16,$2,25 + xor $24,$17 + sll $17,$2,26 + xor $24,$16 + xor $18,$7 # Ch(e,f,g) + xor $16,$17,$24 # Sigma1(e) + + srl $24,$25,2 + addu $15,$18 + lw $18,76($6) # K[19] + sll $17,$25,10 + addu $15,$16 + srl $16,$25,13 + xor $24,$17 + sll $17,$25,19 + xor $24,$16 + srl $16,$25,22 + xor $24,$17 + sll $17,$25,30 + xor $24,$16 + sw $11,12($29) # offload to ring buffer + xor $24,$17 # Sigma0(a) + + or $16,$25,$30 + and $17,$25,$30 + and $16,$31 + or $17,$16 # Maj(a,b,c) + addu $15,$18 # +=K[19] + addu $24,$17 + + addu $1,$15 + addu $24,$15 + lw $14,24($29) # prefetch from ring buffer + srl $18,$13,3 # Xupdate(20) + addu $12,$21 # +=X[i+9] + sll $17,$13,14 + srl $16,$13,7 + xor $18,$17 + sll $17,11 + xor $18,$16 + srl $16,$13,18 + xor $18,$17 + + srl $19,$10,10 + xor $18,$16 # sigma0(X[i+1]) + sll $17,$10,13 + addu $12,$18 + srl $16,$10,17 + xor $19,$17 + sll $17,2 + xor $19,$16 + srl $16,$10,19 + xor $19,$17 + + xor $19,$16 # sigma1(X[i+14]) + addu $12,$19 + addu $16,$12,$7 # 20 + srl $7,$1,6 + xor $19,$2,$3 + sll $18,$1,7 + and $19,$1 + srl $17,$1,11 + xor $7,$18 + sll $18,$1,21 + xor $7,$17 + srl $17,$1,25 + xor $7,$18 + sll $18,$1,26 + xor $7,$17 + xor $19,$3 # Ch(e,f,g) + xor $17,$18,$7 # Sigma1(e) + + srl $7,$24,2 + addu $16,$19 + lw $19,80($6) # K[20] + sll $18,$24,10 + addu $16,$17 + srl $17,$24,13 + xor $7,$18 + sll $18,$24,19 + xor $7,$17 + srl $17,$24,22 + xor $7,$18 + sll $18,$24,30 + xor $7,$17 + sw $12,16($29) # offload to ring buffer + xor $7,$18 # Sigma0(a) + + or $17,$24,$25 + and $18,$24,$25 + and $17,$30 + or $18,$17 # Maj(a,b,c) + addu $16,$19 # +=K[20] + addu $7,$18 + + addu $31,$16 + addu $7,$16 + lw $15,28($29) # prefetch from ring buffer + srl $19,$14,3 # Xupdate(21) + addu $13,$22 # +=X[i+9] + sll $18,$14,14 + srl $17,$14,7 + xor $19,$18 + sll $18,11 + xor $19,$17 + srl $17,$14,18 + xor $19,$18 + + srl $20,$11,10 + xor $19,$17 # sigma0(X[i+1]) + sll $18,$11,13 + addu $13,$19 + srl $17,$11,17 + xor $20,$18 + sll $18,2 + xor $20,$17 + srl $17,$11,19 + xor $20,$18 + + xor $20,$17 # sigma1(X[i+14]) + addu $13,$20 + addu $17,$13,$3 # 21 + srl $3,$31,6 + xor $20,$1,$2 + sll $19,$31,7 + and $20,$31 + srl $18,$31,11 + xor $3,$19 + sll $19,$31,21 + xor $3,$18 + srl $18,$31,25 + xor $3,$19 + sll $19,$31,26 + xor $3,$18 + xor $20,$2 # Ch(e,f,g) + xor $18,$19,$3 # Sigma1(e) + + srl $3,$7,2 + addu $17,$20 + lw $20,84($6) # K[21] + sll $19,$7,10 + addu $17,$18 + srl $18,$7,13 + xor $3,$19 + sll $19,$7,19 + xor $3,$18 + srl $18,$7,22 + xor $3,$19 + sll $19,$7,30 + xor $3,$18 + sw $13,20($29) # offload to ring buffer + xor $3,$19 # Sigma0(a) + + or $18,$7,$24 + and $19,$7,$24 + and $18,$25 + or $19,$18 # Maj(a,b,c) + addu $17,$20 # +=K[21] + addu $3,$19 + + addu $30,$17 + addu $3,$17 + lw $16,32($29) # prefetch from ring buffer + srl $20,$15,3 # Xupdate(22) + addu $14,$23 # +=X[i+9] + sll $19,$15,14 + srl $18,$15,7 + xor $20,$19 + sll $19,11 + xor $20,$18 + srl $18,$15,18 + xor $20,$19 + + srl $21,$12,10 + xor $20,$18 # sigma0(X[i+1]) + sll $19,$12,13 + addu $14,$20 + srl $18,$12,17 + xor $21,$19 + sll $19,2 + xor $21,$18 + srl $18,$12,19 + xor $21,$19 + + xor $21,$18 # sigma1(X[i+14]) + addu $14,$21 + addu $18,$14,$2 # 22 + srl $2,$30,6 + xor $21,$31,$1 + sll $20,$30,7 + and $21,$30 + srl $19,$30,11 + xor $2,$20 + sll $20,$30,21 + xor $2,$19 + srl $19,$30,25 + xor $2,$20 + sll $20,$30,26 + xor $2,$19 + xor $21,$1 # Ch(e,f,g) + xor $19,$20,$2 # Sigma1(e) + + srl $2,$3,2 + addu $18,$21 + lw $21,88($6) # K[22] + sll $20,$3,10 + addu $18,$19 + srl $19,$3,13 + xor $2,$20 + sll $20,$3,19 + xor $2,$19 + srl $19,$3,22 + xor $2,$20 + sll $20,$3,30 + xor $2,$19 + sw $14,24($29) # offload to ring buffer + xor $2,$20 # Sigma0(a) + + or $19,$3,$7 + and $20,$3,$7 + and $19,$24 + or $20,$19 # Maj(a,b,c) + addu $18,$21 # +=K[22] + addu $2,$20 + + addu $25,$18 + addu $2,$18 + lw $17,36($29) # prefetch from ring buffer + srl $21,$16,3 # Xupdate(23) + addu $15,$8 # +=X[i+9] + sll $20,$16,14 + srl $19,$16,7 + xor $21,$20 + sll $20,11 + xor $21,$19 + srl $19,$16,18 + xor $21,$20 + + srl $22,$13,10 + xor $21,$19 # sigma0(X[i+1]) + sll $20,$13,13 + addu $15,$21 + srl $19,$13,17 + xor $22,$20 + sll $20,2 + xor $22,$19 + srl $19,$13,19 + xor $22,$20 + + xor $22,$19 # sigma1(X[i+14]) + addu $15,$22 + addu $19,$15,$1 # 23 + srl $1,$25,6 + xor $22,$30,$31 + sll $21,$25,7 + and $22,$25 + srl $20,$25,11 + xor $1,$21 + sll $21,$25,21 + xor $1,$20 + srl $20,$25,25 + xor $1,$21 + sll $21,$25,26 + xor $1,$20 + xor $22,$31 # Ch(e,f,g) + xor $20,$21,$1 # Sigma1(e) + + srl $1,$2,2 + addu $19,$22 + lw $22,92($6) # K[23] + sll $21,$2,10 + addu $19,$20 + srl $20,$2,13 + xor $1,$21 + sll $21,$2,19 + xor $1,$20 + srl $20,$2,22 + xor $1,$21 + sll $21,$2,30 + xor $1,$20 + sw $15,28($29) # offload to ring buffer + xor $1,$21 # Sigma0(a) + + or $20,$2,$3 + and $21,$2,$3 + and $20,$7 + or $21,$20 # Maj(a,b,c) + addu $19,$22 # +=K[23] + addu $1,$21 + + addu $24,$19 + addu $1,$19 + lw $18,40($29) # prefetch from ring buffer + srl $22,$17,3 # Xupdate(24) + addu $16,$9 # +=X[i+9] + sll $21,$17,14 + srl $20,$17,7 + xor $22,$21 + sll $21,11 + xor $22,$20 + srl $20,$17,18 + xor $22,$21 + + srl $23,$14,10 + xor $22,$20 # sigma0(X[i+1]) + sll $21,$14,13 + addu $16,$22 + srl $20,$14,17 + xor $23,$21 + sll $21,2 + xor $23,$20 + srl $20,$14,19 + xor $23,$21 + + xor $23,$20 # sigma1(X[i+14]) + addu $16,$23 + addu $20,$16,$31 # 24 + srl $31,$24,6 + xor $23,$25,$30 + sll $22,$24,7 + and $23,$24 + srl $21,$24,11 + xor $31,$22 + sll $22,$24,21 + xor $31,$21 + srl $21,$24,25 + xor $31,$22 + sll $22,$24,26 + xor $31,$21 + xor $23,$30 # Ch(e,f,g) + xor $21,$22,$31 # Sigma1(e) + + srl $31,$1,2 + addu $20,$23 + lw $23,96($6) # K[24] + sll $22,$1,10 + addu $20,$21 + srl $21,$1,13 + xor $31,$22 + sll $22,$1,19 + xor $31,$21 + srl $21,$1,22 + xor $31,$22 + sll $22,$1,30 + xor $31,$21 + sw $16,32($29) # offload to ring buffer + xor $31,$22 # Sigma0(a) + + or $21,$1,$2 + and $22,$1,$2 + and $21,$3 + or $22,$21 # Maj(a,b,c) + addu $20,$23 # +=K[24] + addu $31,$22 + + addu $7,$20 + addu $31,$20 + lw $19,44($29) # prefetch from ring buffer + srl $23,$18,3 # Xupdate(25) + addu $17,$10 # +=X[i+9] + sll $22,$18,14 + srl $21,$18,7 + xor $23,$22 + sll $22,11 + xor $23,$21 + srl $21,$18,18 + xor $23,$22 + + srl $8,$15,10 + xor $23,$21 # sigma0(X[i+1]) + sll $22,$15,13 + addu $17,$23 + srl $21,$15,17 + xor $8,$22 + sll $22,2 + xor $8,$21 + srl $21,$15,19 + xor $8,$22 + + xor $8,$21 # sigma1(X[i+14]) + addu $17,$8 + addu $21,$17,$30 # 25 + srl $30,$7,6 + xor $8,$24,$25 + sll $23,$7,7 + and $8,$7 + srl $22,$7,11 + xor $30,$23 + sll $23,$7,21 + xor $30,$22 + srl $22,$7,25 + xor $30,$23 + sll $23,$7,26 + xor $30,$22 + xor $8,$25 # Ch(e,f,g) + xor $22,$23,$30 # Sigma1(e) + + srl $30,$31,2 + addu $21,$8 + lw $8,100($6) # K[25] + sll $23,$31,10 + addu $21,$22 + srl $22,$31,13 + xor $30,$23 + sll $23,$31,19 + xor $30,$22 + srl $22,$31,22 + xor $30,$23 + sll $23,$31,30 + xor $30,$22 + sw $17,36($29) # offload to ring buffer + xor $30,$23 # Sigma0(a) + + or $22,$31,$1 + and $23,$31,$1 + and $22,$2 + or $23,$22 # Maj(a,b,c) + addu $21,$8 # +=K[25] + addu $30,$23 + + addu $3,$21 + addu $30,$21 + lw $20,48($29) # prefetch from ring buffer + srl $8,$19,3 # Xupdate(26) + addu $18,$11 # +=X[i+9] + sll $23,$19,14 + srl $22,$19,7 + xor $8,$23 + sll $23,11 + xor $8,$22 + srl $22,$19,18 + xor $8,$23 + + srl $9,$16,10 + xor $8,$22 # sigma0(X[i+1]) + sll $23,$16,13 + addu $18,$8 + srl $22,$16,17 + xor $9,$23 + sll $23,2 + xor $9,$22 + srl $22,$16,19 + xor $9,$23 + + xor $9,$22 # sigma1(X[i+14]) + addu $18,$9 + addu $22,$18,$25 # 26 + srl $25,$3,6 + xor $9,$7,$24 + sll $8,$3,7 + and $9,$3 + srl $23,$3,11 + xor $25,$8 + sll $8,$3,21 + xor $25,$23 + srl $23,$3,25 + xor $25,$8 + sll $8,$3,26 + xor $25,$23 + xor $9,$24 # Ch(e,f,g) + xor $23,$8,$25 # Sigma1(e) + + srl $25,$30,2 + addu $22,$9 + lw $9,104($6) # K[26] + sll $8,$30,10 + addu $22,$23 + srl $23,$30,13 + xor $25,$8 + sll $8,$30,19 + xor $25,$23 + srl $23,$30,22 + xor $25,$8 + sll $8,$30,30 + xor $25,$23 + sw $18,40($29) # offload to ring buffer + xor $25,$8 # Sigma0(a) + + or $23,$30,$31 + and $8,$30,$31 + and $23,$1 + or $8,$23 # Maj(a,b,c) + addu $22,$9 # +=K[26] + addu $25,$8 + + addu $2,$22 + addu $25,$22 + lw $21,52($29) # prefetch from ring buffer + srl $9,$20,3 # Xupdate(27) + addu $19,$12 # +=X[i+9] + sll $8,$20,14 + srl $23,$20,7 + xor $9,$8 + sll $8,11 + xor $9,$23 + srl $23,$20,18 + xor $9,$8 + + srl $10,$17,10 + xor $9,$23 # sigma0(X[i+1]) + sll $8,$17,13 + addu $19,$9 + srl $23,$17,17 + xor $10,$8 + sll $8,2 + xor $10,$23 + srl $23,$17,19 + xor $10,$8 + + xor $10,$23 # sigma1(X[i+14]) + addu $19,$10 + addu $23,$19,$24 # 27 + srl $24,$2,6 + xor $10,$3,$7 + sll $9,$2,7 + and $10,$2 + srl $8,$2,11 + xor $24,$9 + sll $9,$2,21 + xor $24,$8 + srl $8,$2,25 + xor $24,$9 + sll $9,$2,26 + xor $24,$8 + xor $10,$7 # Ch(e,f,g) + xor $8,$9,$24 # Sigma1(e) + + srl $24,$25,2 + addu $23,$10 + lw $10,108($6) # K[27] + sll $9,$25,10 + addu $23,$8 + srl $8,$25,13 + xor $24,$9 + sll $9,$25,19 + xor $24,$8 + srl $8,$25,22 + xor $24,$9 + sll $9,$25,30 + xor $24,$8 + sw $19,44($29) # offload to ring buffer + xor $24,$9 # Sigma0(a) + + or $8,$25,$30 + and $9,$25,$30 + and $8,$31 + or $9,$8 # Maj(a,b,c) + addu $23,$10 # +=K[27] + addu $24,$9 + + addu $1,$23 + addu $24,$23 + lw $22,56($29) # prefetch from ring buffer + srl $10,$21,3 # Xupdate(28) + addu $20,$13 # +=X[i+9] + sll $9,$21,14 + srl $8,$21,7 + xor $10,$9 + sll $9,11 + xor $10,$8 + srl $8,$21,18 + xor $10,$9 + + srl $11,$18,10 + xor $10,$8 # sigma0(X[i+1]) + sll $9,$18,13 + addu $20,$10 + srl $8,$18,17 + xor $11,$9 + sll $9,2 + xor $11,$8 + srl $8,$18,19 + xor $11,$9 + + xor $11,$8 # sigma1(X[i+14]) + addu $20,$11 + addu $8,$20,$7 # 28 + srl $7,$1,6 + xor $11,$2,$3 + sll $10,$1,7 + and $11,$1 + srl $9,$1,11 + xor $7,$10 + sll $10,$1,21 + xor $7,$9 + srl $9,$1,25 + xor $7,$10 + sll $10,$1,26 + xor $7,$9 + xor $11,$3 # Ch(e,f,g) + xor $9,$10,$7 # Sigma1(e) + + srl $7,$24,2 + addu $8,$11 + lw $11,112($6) # K[28] + sll $10,$24,10 + addu $8,$9 + srl $9,$24,13 + xor $7,$10 + sll $10,$24,19 + xor $7,$9 + srl $9,$24,22 + xor $7,$10 + sll $10,$24,30 + xor $7,$9 + sw $20,48($29) # offload to ring buffer + xor $7,$10 # Sigma0(a) + + or $9,$24,$25 + and $10,$24,$25 + and $9,$30 + or $10,$9 # Maj(a,b,c) + addu $8,$11 # +=K[28] + addu $7,$10 + + addu $31,$8 + addu $7,$8 + lw $23,60($29) # prefetch from ring buffer + srl $11,$22,3 # Xupdate(29) + addu $21,$14 # +=X[i+9] + sll $10,$22,14 + srl $9,$22,7 + xor $11,$10 + sll $10,11 + xor $11,$9 + srl $9,$22,18 + xor $11,$10 + + srl $12,$19,10 + xor $11,$9 # sigma0(X[i+1]) + sll $10,$19,13 + addu $21,$11 + srl $9,$19,17 + xor $12,$10 + sll $10,2 + xor $12,$9 + srl $9,$19,19 + xor $12,$10 + + xor $12,$9 # sigma1(X[i+14]) + addu $21,$12 + addu $9,$21,$3 # 29 + srl $3,$31,6 + xor $12,$1,$2 + sll $11,$31,7 + and $12,$31 + srl $10,$31,11 + xor $3,$11 + sll $11,$31,21 + xor $3,$10 + srl $10,$31,25 + xor $3,$11 + sll $11,$31,26 + xor $3,$10 + xor $12,$2 # Ch(e,f,g) + xor $10,$11,$3 # Sigma1(e) + + srl $3,$7,2 + addu $9,$12 + lw $12,116($6) # K[29] + sll $11,$7,10 + addu $9,$10 + srl $10,$7,13 + xor $3,$11 + sll $11,$7,19 + xor $3,$10 + srl $10,$7,22 + xor $3,$11 + sll $11,$7,30 + xor $3,$10 + sw $21,52($29) # offload to ring buffer + xor $3,$11 # Sigma0(a) + + or $10,$7,$24 + and $11,$7,$24 + and $10,$25 + or $11,$10 # Maj(a,b,c) + addu $9,$12 # +=K[29] + addu $3,$11 + + addu $30,$9 + addu $3,$9 + lw $8,0($29) # prefetch from ring buffer + srl $12,$23,3 # Xupdate(30) + addu $22,$15 # +=X[i+9] + sll $11,$23,14 + srl $10,$23,7 + xor $12,$11 + sll $11,11 + xor $12,$10 + srl $10,$23,18 + xor $12,$11 + + srl $13,$20,10 + xor $12,$10 # sigma0(X[i+1]) + sll $11,$20,13 + addu $22,$12 + srl $10,$20,17 + xor $13,$11 + sll $11,2 + xor $13,$10 + srl $10,$20,19 + xor $13,$11 + + xor $13,$10 # sigma1(X[i+14]) + addu $22,$13 + addu $10,$22,$2 # 30 + srl $2,$30,6 + xor $13,$31,$1 + sll $12,$30,7 + and $13,$30 + srl $11,$30,11 + xor $2,$12 + sll $12,$30,21 + xor $2,$11 + srl $11,$30,25 + xor $2,$12 + sll $12,$30,26 + xor $2,$11 + xor $13,$1 # Ch(e,f,g) + xor $11,$12,$2 # Sigma1(e) + + srl $2,$3,2 + addu $10,$13 + lw $13,120($6) # K[30] + sll $12,$3,10 + addu $10,$11 + srl $11,$3,13 + xor $2,$12 + sll $12,$3,19 + xor $2,$11 + srl $11,$3,22 + xor $2,$12 + sll $12,$3,30 + xor $2,$11 + sw $22,56($29) # offload to ring buffer + xor $2,$12 # Sigma0(a) + + or $11,$3,$7 + and $12,$3,$7 + and $11,$24 + or $12,$11 # Maj(a,b,c) + addu $10,$13 # +=K[30] + addu $2,$12 + + addu $25,$10 + addu $2,$10 + lw $9,4($29) # prefetch from ring buffer + srl $13,$8,3 # Xupdate(31) + addu $23,$16 # +=X[i+9] + sll $12,$8,14 + srl $11,$8,7 + xor $13,$12 + sll $12,11 + xor $13,$11 + srl $11,$8,18 + xor $13,$12 + + srl $14,$21,10 + xor $13,$11 # sigma0(X[i+1]) + sll $12,$21,13 + addu $23,$13 + srl $11,$21,17 + xor $14,$12 + sll $12,2 + xor $14,$11 + srl $11,$21,19 + xor $14,$12 + + xor $14,$11 # sigma1(X[i+14]) + addu $23,$14 + addu $11,$23,$1 # 31 + srl $1,$25,6 + xor $14,$30,$31 + sll $13,$25,7 + and $14,$25 + srl $12,$25,11 + xor $1,$13 + sll $13,$25,21 + xor $1,$12 + srl $12,$25,25 + xor $1,$13 + sll $13,$25,26 + xor $1,$12 + xor $14,$31 # Ch(e,f,g) + xor $12,$13,$1 # Sigma1(e) + + srl $1,$2,2 + addu $11,$14 + lw $14,124($6) # K[31] + sll $13,$2,10 + addu $11,$12 + srl $12,$2,13 + xor $1,$13 + sll $13,$2,19 + xor $1,$12 + srl $12,$2,22 + xor $1,$13 + sll $13,$2,30 + xor $1,$12 + sw $23,60($29) # offload to ring buffer + xor $1,$13 # Sigma0(a) + + or $12,$2,$3 + and $13,$2,$3 + and $12,$7 + or $13,$12 # Maj(a,b,c) + addu $11,$14 # +=K[31] + addu $1,$13 + + addu $24,$11 + addu $1,$11 + lw $10,8($29) # prefetch from ring buffer + and $14,0xfff + li $15,2290 + .set noreorder + bne $14,$15,.L16_xx + add $6,16*4 # Ktbl+=16 + + lw $23,16*4($29) # restore pointer to the end of input + lw $8,0*4($4) + lw $9,1*4($4) + lw $10,2*4($4) + add $5,16*4 + lw $11,3*4($4) + addu $1,$8 + lw $12,4*4($4) + addu $2,$9 + lw $13,5*4($4) + addu $3,$10 + lw $14,6*4($4) + addu $7,$11 + lw $15,7*4($4) + addu $24,$12 + sw $1,0*4($4) + addu $25,$13 + sw $2,1*4($4) + addu $30,$14 + sw $3,2*4($4) + addu $31,$15 + sw $7,3*4($4) + sw $24,4*4($4) + sw $25,5*4($4) + sw $30,6*4($4) + sw $31,7*4($4) + + bne $5,$23,.Loop + sub $6,192 # rewind $6 + + lw $31,128-1*4($29) + lw $30,128-2*4($29) + lw $23,128-3*4($29) + lw $22,128-4*4($29) + lw $21,128-5*4($29) + lw $20,128-6*4($29) + lw $19,128-7*4($29) + lw $18,128-8*4($29) + lw $17,128-9*4($29) + lw $16,128-10*4($29) + jr $31 + add $29,128 +.end sha256_block_data_order + +.rdata +.align 5 +K256: + .word 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5 + .word 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5 + .word 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3 + .word 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174 + .word 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc + .word 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da + .word 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7 + .word 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967 + .word 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13 + .word 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85 + .word 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3 + .word 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070 + .word 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5 + .word 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3 + .word 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208 + .word 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +.asciiz "SHA256 for MIPS, CRYPTOGAMS by " +.align 5 + +#if defined(HAVE_GNU_STACK) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/sha/sha512-elf-x86_64.S b/crypto/sha/sha512-elf-x86_64.S index 11734072..c3246de9 100644 --- a/crypto/sha/sha512-elf-x86_64.S +++ b/crypto/sha/sha512-elf-x86_64.S @@ -1758,6 +1758,7 @@ sha512_block_data_order: .Lepilogue: retq .size sha512_block_data_order,.-sha512_block_data_order +.section .rodata .align 64 .type K512,@object K512: @@ -1801,6 +1802,7 @@ K512: .quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c .quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a .quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 +.text #if defined(HAVE_GNU_STACK) .section .note.GNU-stack,"",%progbits #endif diff --git a/crypto/sha/sha512-macosx-x86_64.S b/crypto/sha/sha512-macosx-x86_64.S index 7581da47..a6b1a85d 100644 --- a/crypto/sha/sha512-macosx-x86_64.S +++ b/crypto/sha/sha512-macosx-x86_64.S @@ -1758,6 +1758,7 @@ L$rounds_16_xx: L$epilogue: retq +.section __DATA,__const .p2align 6 K512: @@ -1801,3 +1802,4 @@ K512: .quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c .quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a .quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 +.text diff --git a/crypto/sha/sha512-masm-x86_64.S b/crypto/sha/sha512-masm-x86_64.S index e964d9c8..cd4c9666 100644 --- a/crypto/sha/sha512-masm-x86_64.S +++ b/crypto/sha/sha512-masm-x86_64.S @@ -1839,6 +1839,8 @@ $L$epilogue:: DB 0F3h,0C3h ;repret $L$SEH_end_sha512_block_data_order:: sha512_block_data_order ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 K512:: @@ -1882,6 +1884,8 @@ K512:: DQ 03c9ebe0a15c9bebch,0431d67c49c100d4ch DQ 04cc5d4becb3e42b6h,0597f299cfc657e2ah DQ 05fcb6fab3ad6faech,06c44198c4a475817h +.rdata ENDS +.text$ SEGMENT ALIGN(64) 'CODE' .text$ ENDS END diff --git a/crypto/sha/sha512-mingw64-x86_64.S b/crypto/sha/sha512-mingw64-x86_64.S index 51539524..a4680727 100644 --- a/crypto/sha/sha512-mingw64-x86_64.S +++ b/crypto/sha/sha512-mingw64-x86_64.S @@ -1769,6 +1769,7 @@ sha512_block_data_order: movq 16(%rsp),%rsi retq .LSEH_end_sha512_block_data_order: +.section .rodata .p2align 6 K512: @@ -1812,3 +1813,4 @@ K512: .quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c .quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a .quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 +.text diff --git a/crypto/sha/sha512-mips.S b/crypto/sha/sha512-mips.S new file mode 100644 index 00000000..da903b65 --- /dev/null +++ b/crypto/sha/sha512-mips.S @@ -0,0 +1,2165 @@ +.text +.set noat +#if !defined(__vxworks) || defined(__pic__) +.option pic2 +#endif + +.align 5 +.globl sha512_block_data_order +.ent sha512_block_data_order +sha512_block_data_order: + .frame $29,192,$31 + .mask 3237937152,-4 + .set noreorder + .cpload $25 + sub $29,192 + sw $31,192-1*4($29) + sw $30,192-2*4($29) + sw $23,192-3*4($29) + sw $22,192-4*4($29) + sw $21,192-5*4($29) + sw $20,192-6*4($29) + sw $19,192-7*4($29) + sw $18,192-8*4($29) + sw $17,192-9*4($29) + sw $16,192-10*4($29) + sll $23,$6,7 + .set reorder + la $6,K512 # PIC-ified 'load address' + + ld $1,0*8($4) # load context + ld $2,1*8($4) + ld $3,2*8($4) + ld $7,3*8($4) + ld $24,4*8($4) + ld $25,5*8($4) + ld $30,6*8($4) + ld $31,7*8($4) + + add $23,$5 # pointer to the end of input + sw $23,16*8($29) + b .Loop + +.align 5 +.Loop: + ldl $8,7($5) + ldr $8,0($5) + ldl $9,15($5) + ldr $9,8($5) + ori $13,$0,0xFF + dsll $15,$13,32 + or $13,$15 # 0x000000FF000000FF + and $14,$8,$13 # byte swap(0) + dsrl $15,$8,24 + dsll $14,24 + and $15,$13 + dsll $13,8 # 0x0000FF000000FF00 + or $14,$15 + and $15,$8,$13 + dsrl $8,8 + dsll $15,8 + and $8,$13 + or $14,$15 + or $8,$14 + dsrl $14,$8,32 + dsll $8,32 + or $8,$14 + daddu $12,$8,$31 # 0 + dsrl $31,$24,14 + xor $15,$25,$30 + dsll $14,$24,23 + and $15,$24 + dsrl $13,$24,18 + xor $31,$14 + dsll $14,$24,46 + xor $31,$13 + dsrl $13,$24,41 + xor $31,$14 + dsll $14,$24,50 + xor $31,$13 + xor $15,$30 # Ch(e,f,g) + xor $13,$14,$31 # Sigma1(e) + + dsrl $31,$1,28 + daddu $12,$15 + ld $15,0($6) # K[0] + dsll $14,$1,25 + daddu $12,$13 + dsrl $13,$1,34 + xor $31,$14 + dsll $14,$1,30 + xor $31,$13 + dsrl $13,$1,39 + xor $31,$14 + dsll $14,$1,36 + xor $31,$13 + sd $8,0($29) # offload to ring buffer + xor $31,$14 # Sigma0(a) + + or $13,$1,$2 + and $14,$1,$2 + and $13,$3 + or $14,$13 # Maj(a,b,c) + daddu $12,$15 # +=K[0] + daddu $31,$14 + + daddu $7,$12 + daddu $31,$12 + ldl $10,23($5) + ldr $10,16($5) + ori $14,$0,0xFF + dsll $16,$14,32 + or $14,$16 # 0x000000FF000000FF + and $15,$9,$14 # byte swap(1) + dsrl $16,$9,24 + dsll $15,24 + and $16,$14 + dsll $14,8 # 0x0000FF000000FF00 + or $15,$16 + and $16,$9,$14 + dsrl $9,8 + dsll $16,8 + and $9,$14 + or $15,$16 + or $9,$15 + dsrl $15,$9,32 + dsll $9,32 + or $9,$15 + daddu $13,$9,$30 # 1 + dsrl $30,$7,14 + xor $16,$24,$25 + dsll $15,$7,23 + and $16,$7 + dsrl $14,$7,18 + xor $30,$15 + dsll $15,$7,46 + xor $30,$14 + dsrl $14,$7,41 + xor $30,$15 + dsll $15,$7,50 + xor $30,$14 + xor $16,$25 # Ch(e,f,g) + xor $14,$15,$30 # Sigma1(e) + + dsrl $30,$31,28 + daddu $13,$16 + ld $16,8($6) # K[1] + dsll $15,$31,25 + daddu $13,$14 + dsrl $14,$31,34 + xor $30,$15 + dsll $15,$31,30 + xor $30,$14 + dsrl $14,$31,39 + xor $30,$15 + dsll $15,$31,36 + xor $30,$14 + sd $9,8($29) # offload to ring buffer + xor $30,$15 # Sigma0(a) + + or $14,$31,$1 + and $15,$31,$1 + and $14,$2 + or $15,$14 # Maj(a,b,c) + daddu $13,$16 # +=K[1] + daddu $30,$15 + + daddu $3,$13 + daddu $30,$13 + ldl $11,31($5) + ldr $11,24($5) + ori $15,$0,0xFF + dsll $17,$15,32 + or $15,$17 # 0x000000FF000000FF + and $16,$10,$15 # byte swap(2) + dsrl $17,$10,24 + dsll $16,24 + and $17,$15 + dsll $15,8 # 0x0000FF000000FF00 + or $16,$17 + and $17,$10,$15 + dsrl $10,8 + dsll $17,8 + and $10,$15 + or $16,$17 + or $10,$16 + dsrl $16,$10,32 + dsll $10,32 + or $10,$16 + daddu $14,$10,$25 # 2 + dsrl $25,$3,14 + xor $17,$7,$24 + dsll $16,$3,23 + and $17,$3 + dsrl $15,$3,18 + xor $25,$16 + dsll $16,$3,46 + xor $25,$15 + dsrl $15,$3,41 + xor $25,$16 + dsll $16,$3,50 + xor $25,$15 + xor $17,$24 # Ch(e,f,g) + xor $15,$16,$25 # Sigma1(e) + + dsrl $25,$30,28 + daddu $14,$17 + ld $17,16($6) # K[2] + dsll $16,$30,25 + daddu $14,$15 + dsrl $15,$30,34 + xor $25,$16 + dsll $16,$30,30 + xor $25,$15 + dsrl $15,$30,39 + xor $25,$16 + dsll $16,$30,36 + xor $25,$15 + sd $10,16($29) # offload to ring buffer + xor $25,$16 # Sigma0(a) + + or $15,$30,$31 + and $16,$30,$31 + and $15,$1 + or $16,$15 # Maj(a,b,c) + daddu $14,$17 # +=K[2] + daddu $25,$16 + + daddu $2,$14 + daddu $25,$14 + ldl $12,39($5) + ldr $12,32($5) + ori $16,$0,0xFF + dsll $18,$16,32 + or $16,$18 # 0x000000FF000000FF + and $17,$11,$16 # byte swap(3) + dsrl $18,$11,24 + dsll $17,24 + and $18,$16 + dsll $16,8 # 0x0000FF000000FF00 + or $17,$18 + and $18,$11,$16 + dsrl $11,8 + dsll $18,8 + and $11,$16 + or $17,$18 + or $11,$17 + dsrl $17,$11,32 + dsll $11,32 + or $11,$17 + daddu $15,$11,$24 # 3 + dsrl $24,$2,14 + xor $18,$3,$7 + dsll $17,$2,23 + and $18,$2 + dsrl $16,$2,18 + xor $24,$17 + dsll $17,$2,46 + xor $24,$16 + dsrl $16,$2,41 + xor $24,$17 + dsll $17,$2,50 + xor $24,$16 + xor $18,$7 # Ch(e,f,g) + xor $16,$17,$24 # Sigma1(e) + + dsrl $24,$25,28 + daddu $15,$18 + ld $18,24($6) # K[3] + dsll $17,$25,25 + daddu $15,$16 + dsrl $16,$25,34 + xor $24,$17 + dsll $17,$25,30 + xor $24,$16 + dsrl $16,$25,39 + xor $24,$17 + dsll $17,$25,36 + xor $24,$16 + sd $11,24($29) # offload to ring buffer + xor $24,$17 # Sigma0(a) + + or $16,$25,$30 + and $17,$25,$30 + and $16,$31 + or $17,$16 # Maj(a,b,c) + daddu $15,$18 # +=K[3] + daddu $24,$17 + + daddu $1,$15 + daddu $24,$15 + ldl $13,47($5) + ldr $13,40($5) + ori $17,$0,0xFF + dsll $19,$17,32 + or $17,$19 # 0x000000FF000000FF + and $18,$12,$17 # byte swap(4) + dsrl $19,$12,24 + dsll $18,24 + and $19,$17 + dsll $17,8 # 0x0000FF000000FF00 + or $18,$19 + and $19,$12,$17 + dsrl $12,8 + dsll $19,8 + and $12,$17 + or $18,$19 + or $12,$18 + dsrl $18,$12,32 + dsll $12,32 + or $12,$18 + daddu $16,$12,$7 # 4 + dsrl $7,$1,14 + xor $19,$2,$3 + dsll $18,$1,23 + and $19,$1 + dsrl $17,$1,18 + xor $7,$18 + dsll $18,$1,46 + xor $7,$17 + dsrl $17,$1,41 + xor $7,$18 + dsll $18,$1,50 + xor $7,$17 + xor $19,$3 # Ch(e,f,g) + xor $17,$18,$7 # Sigma1(e) + + dsrl $7,$24,28 + daddu $16,$19 + ld $19,32($6) # K[4] + dsll $18,$24,25 + daddu $16,$17 + dsrl $17,$24,34 + xor $7,$18 + dsll $18,$24,30 + xor $7,$17 + dsrl $17,$24,39 + xor $7,$18 + dsll $18,$24,36 + xor $7,$17 + sd $12,32($29) # offload to ring buffer + xor $7,$18 # Sigma0(a) + + or $17,$24,$25 + and $18,$24,$25 + and $17,$30 + or $18,$17 # Maj(a,b,c) + daddu $16,$19 # +=K[4] + daddu $7,$18 + + daddu $31,$16 + daddu $7,$16 + ldl $14,55($5) + ldr $14,48($5) + ori $18,$0,0xFF + dsll $20,$18,32 + or $18,$20 # 0x000000FF000000FF + and $19,$13,$18 # byte swap(5) + dsrl $20,$13,24 + dsll $19,24 + and $20,$18 + dsll $18,8 # 0x0000FF000000FF00 + or $19,$20 + and $20,$13,$18 + dsrl $13,8 + dsll $20,8 + and $13,$18 + or $19,$20 + or $13,$19 + dsrl $19,$13,32 + dsll $13,32 + or $13,$19 + daddu $17,$13,$3 # 5 + dsrl $3,$31,14 + xor $20,$1,$2 + dsll $19,$31,23 + and $20,$31 + dsrl $18,$31,18 + xor $3,$19 + dsll $19,$31,46 + xor $3,$18 + dsrl $18,$31,41 + xor $3,$19 + dsll $19,$31,50 + xor $3,$18 + xor $20,$2 # Ch(e,f,g) + xor $18,$19,$3 # Sigma1(e) + + dsrl $3,$7,28 + daddu $17,$20 + ld $20,40($6) # K[5] + dsll $19,$7,25 + daddu $17,$18 + dsrl $18,$7,34 + xor $3,$19 + dsll $19,$7,30 + xor $3,$18 + dsrl $18,$7,39 + xor $3,$19 + dsll $19,$7,36 + xor $3,$18 + sd $13,40($29) # offload to ring buffer + xor $3,$19 # Sigma0(a) + + or $18,$7,$24 + and $19,$7,$24 + and $18,$25 + or $19,$18 # Maj(a,b,c) + daddu $17,$20 # +=K[5] + daddu $3,$19 + + daddu $30,$17 + daddu $3,$17 + ldl $15,63($5) + ldr $15,56($5) + ori $19,$0,0xFF + dsll $21,$19,32 + or $19,$21 # 0x000000FF000000FF + and $20,$14,$19 # byte swap(6) + dsrl $21,$14,24 + dsll $20,24 + and $21,$19 + dsll $19,8 # 0x0000FF000000FF00 + or $20,$21 + and $21,$14,$19 + dsrl $14,8 + dsll $21,8 + and $14,$19 + or $20,$21 + or $14,$20 + dsrl $20,$14,32 + dsll $14,32 + or $14,$20 + daddu $18,$14,$2 # 6 + dsrl $2,$30,14 + xor $21,$31,$1 + dsll $20,$30,23 + and $21,$30 + dsrl $19,$30,18 + xor $2,$20 + dsll $20,$30,46 + xor $2,$19 + dsrl $19,$30,41 + xor $2,$20 + dsll $20,$30,50 + xor $2,$19 + xor $21,$1 # Ch(e,f,g) + xor $19,$20,$2 # Sigma1(e) + + dsrl $2,$3,28 + daddu $18,$21 + ld $21,48($6) # K[6] + dsll $20,$3,25 + daddu $18,$19 + dsrl $19,$3,34 + xor $2,$20 + dsll $20,$3,30 + xor $2,$19 + dsrl $19,$3,39 + xor $2,$20 + dsll $20,$3,36 + xor $2,$19 + sd $14,48($29) # offload to ring buffer + xor $2,$20 # Sigma0(a) + + or $19,$3,$7 + and $20,$3,$7 + and $19,$24 + or $20,$19 # Maj(a,b,c) + daddu $18,$21 # +=K[6] + daddu $2,$20 + + daddu $25,$18 + daddu $2,$18 + ldl $16,71($5) + ldr $16,64($5) + ori $20,$0,0xFF + dsll $22,$20,32 + or $20,$22 # 0x000000FF000000FF + and $21,$15,$20 # byte swap(7) + dsrl $22,$15,24 + dsll $21,24 + and $22,$20 + dsll $20,8 # 0x0000FF000000FF00 + or $21,$22 + and $22,$15,$20 + dsrl $15,8 + dsll $22,8 + and $15,$20 + or $21,$22 + or $15,$21 + dsrl $21,$15,32 + dsll $15,32 + or $15,$21 + daddu $19,$15,$1 # 7 + dsrl $1,$25,14 + xor $22,$30,$31 + dsll $21,$25,23 + and $22,$25 + dsrl $20,$25,18 + xor $1,$21 + dsll $21,$25,46 + xor $1,$20 + dsrl $20,$25,41 + xor $1,$21 + dsll $21,$25,50 + xor $1,$20 + xor $22,$31 # Ch(e,f,g) + xor $20,$21,$1 # Sigma1(e) + + dsrl $1,$2,28 + daddu $19,$22 + ld $22,56($6) # K[7] + dsll $21,$2,25 + daddu $19,$20 + dsrl $20,$2,34 + xor $1,$21 + dsll $21,$2,30 + xor $1,$20 + dsrl $20,$2,39 + xor $1,$21 + dsll $21,$2,36 + xor $1,$20 + sd $15,56($29) # offload to ring buffer + xor $1,$21 # Sigma0(a) + + or $20,$2,$3 + and $21,$2,$3 + and $20,$7 + or $21,$20 # Maj(a,b,c) + daddu $19,$22 # +=K[7] + daddu $1,$21 + + daddu $24,$19 + daddu $1,$19 + ldl $17,79($5) + ldr $17,72($5) + ori $21,$0,0xFF + dsll $23,$21,32 + or $21,$23 # 0x000000FF000000FF + and $22,$16,$21 # byte swap(8) + dsrl $23,$16,24 + dsll $22,24 + and $23,$21 + dsll $21,8 # 0x0000FF000000FF00 + or $22,$23 + and $23,$16,$21 + dsrl $16,8 + dsll $23,8 + and $16,$21 + or $22,$23 + or $16,$22 + dsrl $22,$16,32 + dsll $16,32 + or $16,$22 + daddu $20,$16,$31 # 8 + dsrl $31,$24,14 + xor $23,$25,$30 + dsll $22,$24,23 + and $23,$24 + dsrl $21,$24,18 + xor $31,$22 + dsll $22,$24,46 + xor $31,$21 + dsrl $21,$24,41 + xor $31,$22 + dsll $22,$24,50 + xor $31,$21 + xor $23,$30 # Ch(e,f,g) + xor $21,$22,$31 # Sigma1(e) + + dsrl $31,$1,28 + daddu $20,$23 + ld $23,64($6) # K[8] + dsll $22,$1,25 + daddu $20,$21 + dsrl $21,$1,34 + xor $31,$22 + dsll $22,$1,30 + xor $31,$21 + dsrl $21,$1,39 + xor $31,$22 + dsll $22,$1,36 + xor $31,$21 + sd $16,64($29) # offload to ring buffer + xor $31,$22 # Sigma0(a) + + or $21,$1,$2 + and $22,$1,$2 + and $21,$3 + or $22,$21 # Maj(a,b,c) + daddu $20,$23 # +=K[8] + daddu $31,$22 + + daddu $7,$20 + daddu $31,$20 + ldl $18,87($5) + ldr $18,80($5) + ori $22,$0,0xFF + dsll $8,$22,32 + or $22,$8 # 0x000000FF000000FF + and $23,$17,$22 # byte swap(9) + dsrl $8,$17,24 + dsll $23,24 + and $8,$22 + dsll $22,8 # 0x0000FF000000FF00 + or $23,$8 + and $8,$17,$22 + dsrl $17,8 + dsll $8,8 + and $17,$22 + or $23,$8 + or $17,$23 + dsrl $23,$17,32 + dsll $17,32 + or $17,$23 + daddu $21,$17,$30 # 9 + dsrl $30,$7,14 + xor $8,$24,$25 + dsll $23,$7,23 + and $8,$7 + dsrl $22,$7,18 + xor $30,$23 + dsll $23,$7,46 + xor $30,$22 + dsrl $22,$7,41 + xor $30,$23 + dsll $23,$7,50 + xor $30,$22 + xor $8,$25 # Ch(e,f,g) + xor $22,$23,$30 # Sigma1(e) + + dsrl $30,$31,28 + daddu $21,$8 + ld $8,72($6) # K[9] + dsll $23,$31,25 + daddu $21,$22 + dsrl $22,$31,34 + xor $30,$23 + dsll $23,$31,30 + xor $30,$22 + dsrl $22,$31,39 + xor $30,$23 + dsll $23,$31,36 + xor $30,$22 + sd $17,72($29) # offload to ring buffer + xor $30,$23 # Sigma0(a) + + or $22,$31,$1 + and $23,$31,$1 + and $22,$2 + or $23,$22 # Maj(a,b,c) + daddu $21,$8 # +=K[9] + daddu $30,$23 + + daddu $3,$21 + daddu $30,$21 + ldl $19,95($5) + ldr $19,88($5) + ori $23,$0,0xFF + dsll $9,$23,32 + or $23,$9 # 0x000000FF000000FF + and $8,$18,$23 # byte swap(10) + dsrl $9,$18,24 + dsll $8,24 + and $9,$23 + dsll $23,8 # 0x0000FF000000FF00 + or $8,$9 + and $9,$18,$23 + dsrl $18,8 + dsll $9,8 + and $18,$23 + or $8,$9 + or $18,$8 + dsrl $8,$18,32 + dsll $18,32 + or $18,$8 + daddu $22,$18,$25 # 10 + dsrl $25,$3,14 + xor $9,$7,$24 + dsll $8,$3,23 + and $9,$3 + dsrl $23,$3,18 + xor $25,$8 + dsll $8,$3,46 + xor $25,$23 + dsrl $23,$3,41 + xor $25,$8 + dsll $8,$3,50 + xor $25,$23 + xor $9,$24 # Ch(e,f,g) + xor $23,$8,$25 # Sigma1(e) + + dsrl $25,$30,28 + daddu $22,$9 + ld $9,80($6) # K[10] + dsll $8,$30,25 + daddu $22,$23 + dsrl $23,$30,34 + xor $25,$8 + dsll $8,$30,30 + xor $25,$23 + dsrl $23,$30,39 + xor $25,$8 + dsll $8,$30,36 + xor $25,$23 + sd $18,80($29) # offload to ring buffer + xor $25,$8 # Sigma0(a) + + or $23,$30,$31 + and $8,$30,$31 + and $23,$1 + or $8,$23 # Maj(a,b,c) + daddu $22,$9 # +=K[10] + daddu $25,$8 + + daddu $2,$22 + daddu $25,$22 + ldl $20,103($5) + ldr $20,96($5) + ori $8,$0,0xFF + dsll $10,$8,32 + or $8,$10 # 0x000000FF000000FF + and $9,$19,$8 # byte swap(11) + dsrl $10,$19,24 + dsll $9,24 + and $10,$8 + dsll $8,8 # 0x0000FF000000FF00 + or $9,$10 + and $10,$19,$8 + dsrl $19,8 + dsll $10,8 + and $19,$8 + or $9,$10 + or $19,$9 + dsrl $9,$19,32 + dsll $19,32 + or $19,$9 + daddu $23,$19,$24 # 11 + dsrl $24,$2,14 + xor $10,$3,$7 + dsll $9,$2,23 + and $10,$2 + dsrl $8,$2,18 + xor $24,$9 + dsll $9,$2,46 + xor $24,$8 + dsrl $8,$2,41 + xor $24,$9 + dsll $9,$2,50 + xor $24,$8 + xor $10,$7 # Ch(e,f,g) + xor $8,$9,$24 # Sigma1(e) + + dsrl $24,$25,28 + daddu $23,$10 + ld $10,88($6) # K[11] + dsll $9,$25,25 + daddu $23,$8 + dsrl $8,$25,34 + xor $24,$9 + dsll $9,$25,30 + xor $24,$8 + dsrl $8,$25,39 + xor $24,$9 + dsll $9,$25,36 + xor $24,$8 + sd $19,88($29) # offload to ring buffer + xor $24,$9 # Sigma0(a) + + or $8,$25,$30 + and $9,$25,$30 + and $8,$31 + or $9,$8 # Maj(a,b,c) + daddu $23,$10 # +=K[11] + daddu $24,$9 + + daddu $1,$23 + daddu $24,$23 + ldl $21,111($5) + ldr $21,104($5) + ori $9,$0,0xFF + dsll $11,$9,32 + or $9,$11 # 0x000000FF000000FF + and $10,$20,$9 # byte swap(12) + dsrl $11,$20,24 + dsll $10,24 + and $11,$9 + dsll $9,8 # 0x0000FF000000FF00 + or $10,$11 + and $11,$20,$9 + dsrl $20,8 + dsll $11,8 + and $20,$9 + or $10,$11 + or $20,$10 + dsrl $10,$20,32 + dsll $20,32 + or $20,$10 + daddu $8,$20,$7 # 12 + dsrl $7,$1,14 + xor $11,$2,$3 + dsll $10,$1,23 + and $11,$1 + dsrl $9,$1,18 + xor $7,$10 + dsll $10,$1,46 + xor $7,$9 + dsrl $9,$1,41 + xor $7,$10 + dsll $10,$1,50 + xor $7,$9 + xor $11,$3 # Ch(e,f,g) + xor $9,$10,$7 # Sigma1(e) + + dsrl $7,$24,28 + daddu $8,$11 + ld $11,96($6) # K[12] + dsll $10,$24,25 + daddu $8,$9 + dsrl $9,$24,34 + xor $7,$10 + dsll $10,$24,30 + xor $7,$9 + dsrl $9,$24,39 + xor $7,$10 + dsll $10,$24,36 + xor $7,$9 + sd $20,96($29) # offload to ring buffer + xor $7,$10 # Sigma0(a) + + or $9,$24,$25 + and $10,$24,$25 + and $9,$30 + or $10,$9 # Maj(a,b,c) + daddu $8,$11 # +=K[12] + daddu $7,$10 + + daddu $31,$8 + daddu $7,$8 + ldl $22,119($5) + ldr $22,112($5) + ori $10,$0,0xFF + dsll $12,$10,32 + or $10,$12 # 0x000000FF000000FF + and $11,$21,$10 # byte swap(13) + dsrl $12,$21,24 + dsll $11,24 + and $12,$10 + dsll $10,8 # 0x0000FF000000FF00 + or $11,$12 + and $12,$21,$10 + dsrl $21,8 + dsll $12,8 + and $21,$10 + or $11,$12 + or $21,$11 + dsrl $11,$21,32 + dsll $21,32 + or $21,$11 + daddu $9,$21,$3 # 13 + dsrl $3,$31,14 + xor $12,$1,$2 + dsll $11,$31,23 + and $12,$31 + dsrl $10,$31,18 + xor $3,$11 + dsll $11,$31,46 + xor $3,$10 + dsrl $10,$31,41 + xor $3,$11 + dsll $11,$31,50 + xor $3,$10 + xor $12,$2 # Ch(e,f,g) + xor $10,$11,$3 # Sigma1(e) + + dsrl $3,$7,28 + daddu $9,$12 + ld $12,104($6) # K[13] + dsll $11,$7,25 + daddu $9,$10 + dsrl $10,$7,34 + xor $3,$11 + dsll $11,$7,30 + xor $3,$10 + dsrl $10,$7,39 + xor $3,$11 + dsll $11,$7,36 + xor $3,$10 + sd $21,104($29) # offload to ring buffer + xor $3,$11 # Sigma0(a) + + or $10,$7,$24 + and $11,$7,$24 + and $10,$25 + or $11,$10 # Maj(a,b,c) + daddu $9,$12 # +=K[13] + daddu $3,$11 + + daddu $30,$9 + daddu $3,$9 + ld $8,0($29) # prefetch from ring buffer + ldl $23,127($5) + ldr $23,120($5) + ori $11,$0,0xFF + dsll $13,$11,32 + or $11,$13 # 0x000000FF000000FF + and $12,$22,$11 # byte swap(14) + dsrl $13,$22,24 + dsll $12,24 + and $13,$11 + dsll $11,8 # 0x0000FF000000FF00 + or $12,$13 + and $13,$22,$11 + dsrl $22,8 + dsll $13,8 + and $22,$11 + or $12,$13 + or $22,$12 + dsrl $12,$22,32 + dsll $22,32 + or $22,$12 + daddu $10,$22,$2 # 14 + dsrl $2,$30,14 + xor $13,$31,$1 + dsll $12,$30,23 + and $13,$30 + dsrl $11,$30,18 + xor $2,$12 + dsll $12,$30,46 + xor $2,$11 + dsrl $11,$30,41 + xor $2,$12 + dsll $12,$30,50 + xor $2,$11 + xor $13,$1 # Ch(e,f,g) + xor $11,$12,$2 # Sigma1(e) + + dsrl $2,$3,28 + daddu $10,$13 + ld $13,112($6) # K[14] + dsll $12,$3,25 + daddu $10,$11 + dsrl $11,$3,34 + xor $2,$12 + dsll $12,$3,30 + xor $2,$11 + dsrl $11,$3,39 + xor $2,$12 + dsll $12,$3,36 + xor $2,$11 + sd $22,112($29) # offload to ring buffer + xor $2,$12 # Sigma0(a) + + or $11,$3,$7 + and $12,$3,$7 + and $11,$24 + or $12,$11 # Maj(a,b,c) + daddu $10,$13 # +=K[14] + daddu $2,$12 + + daddu $25,$10 + daddu $2,$10 + ld $9,8($29) # prefetch from ring buffer + ori $12,$0,0xFF + dsll $14,$12,32 + or $12,$14 # 0x000000FF000000FF + and $13,$23,$12 # byte swap(15) + dsrl $14,$23,24 + dsll $13,24 + and $14,$12 + dsll $12,8 # 0x0000FF000000FF00 + or $13,$14 + and $14,$23,$12 + dsrl $23,8 + dsll $14,8 + and $23,$12 + or $13,$14 + or $23,$13 + dsrl $13,$23,32 + dsll $23,32 + or $23,$13 + daddu $11,$23,$1 # 15 + dsrl $1,$25,14 + xor $14,$30,$31 + dsll $13,$25,23 + and $14,$25 + dsrl $12,$25,18 + xor $1,$13 + dsll $13,$25,46 + xor $1,$12 + dsrl $12,$25,41 + xor $1,$13 + dsll $13,$25,50 + xor $1,$12 + xor $14,$31 # Ch(e,f,g) + xor $12,$13,$1 # Sigma1(e) + + dsrl $1,$2,28 + daddu $11,$14 + ld $14,120($6) # K[15] + dsll $13,$2,25 + daddu $11,$12 + dsrl $12,$2,34 + xor $1,$13 + dsll $13,$2,30 + xor $1,$12 + dsrl $12,$2,39 + xor $1,$13 + dsll $13,$2,36 + xor $1,$12 + sd $23,120($29) # offload to ring buffer + xor $1,$13 # Sigma0(a) + + or $12,$2,$3 + and $13,$2,$3 + and $12,$7 + or $13,$12 # Maj(a,b,c) + daddu $11,$14 # +=K[15] + daddu $1,$13 + + daddu $24,$11 + daddu $1,$11 + ld $10,16($29) # prefetch from ring buffer + b .L16_xx +.align 4 +.L16_xx: + dsrl $14,$9,7 # Xupdate(16) + daddu $8,$17 # +=X[i+9] + dsll $13,$9,56 + dsrl $12,$9,1 + xor $14,$13 + dsll $13,7 + xor $14,$12 + dsrl $12,$9,8 + xor $14,$13 + + dsrl $15,$22,6 + xor $14,$12 # sigma0(X[i+1]) + dsll $13,$22,3 + daddu $8,$14 + dsrl $12,$22,19 + xor $15,$13 + dsll $13,42 + xor $15,$12 + dsrl $12,$22,61 + xor $15,$13 + + xor $15,$12 # sigma1(X[i+14]) + daddu $8,$15 + daddu $12,$8,$31 # 16 + dsrl $31,$24,14 + xor $15,$25,$30 + dsll $14,$24,23 + and $15,$24 + dsrl $13,$24,18 + xor $31,$14 + dsll $14,$24,46 + xor $31,$13 + dsrl $13,$24,41 + xor $31,$14 + dsll $14,$24,50 + xor $31,$13 + xor $15,$30 # Ch(e,f,g) + xor $13,$14,$31 # Sigma1(e) + + dsrl $31,$1,28 + daddu $12,$15 + ld $15,128($6) # K[16] + dsll $14,$1,25 + daddu $12,$13 + dsrl $13,$1,34 + xor $31,$14 + dsll $14,$1,30 + xor $31,$13 + dsrl $13,$1,39 + xor $31,$14 + dsll $14,$1,36 + xor $31,$13 + sd $8,0($29) # offload to ring buffer + xor $31,$14 # Sigma0(a) + + or $13,$1,$2 + and $14,$1,$2 + and $13,$3 + or $14,$13 # Maj(a,b,c) + daddu $12,$15 # +=K[16] + daddu $31,$14 + + daddu $7,$12 + daddu $31,$12 + ld $11,24($29) # prefetch from ring buffer + dsrl $15,$10,7 # Xupdate(17) + daddu $9,$18 # +=X[i+9] + dsll $14,$10,56 + dsrl $13,$10,1 + xor $15,$14 + dsll $14,7 + xor $15,$13 + dsrl $13,$10,8 + xor $15,$14 + + dsrl $16,$23,6 + xor $15,$13 # sigma0(X[i+1]) + dsll $14,$23,3 + daddu $9,$15 + dsrl $13,$23,19 + xor $16,$14 + dsll $14,42 + xor $16,$13 + dsrl $13,$23,61 + xor $16,$14 + + xor $16,$13 # sigma1(X[i+14]) + daddu $9,$16 + daddu $13,$9,$30 # 17 + dsrl $30,$7,14 + xor $16,$24,$25 + dsll $15,$7,23 + and $16,$7 + dsrl $14,$7,18 + xor $30,$15 + dsll $15,$7,46 + xor $30,$14 + dsrl $14,$7,41 + xor $30,$15 + dsll $15,$7,50 + xor $30,$14 + xor $16,$25 # Ch(e,f,g) + xor $14,$15,$30 # Sigma1(e) + + dsrl $30,$31,28 + daddu $13,$16 + ld $16,136($6) # K[17] + dsll $15,$31,25 + daddu $13,$14 + dsrl $14,$31,34 + xor $30,$15 + dsll $15,$31,30 + xor $30,$14 + dsrl $14,$31,39 + xor $30,$15 + dsll $15,$31,36 + xor $30,$14 + sd $9,8($29) # offload to ring buffer + xor $30,$15 # Sigma0(a) + + or $14,$31,$1 + and $15,$31,$1 + and $14,$2 + or $15,$14 # Maj(a,b,c) + daddu $13,$16 # +=K[17] + daddu $30,$15 + + daddu $3,$13 + daddu $30,$13 + ld $12,32($29) # prefetch from ring buffer + dsrl $16,$11,7 # Xupdate(18) + daddu $10,$19 # +=X[i+9] + dsll $15,$11,56 + dsrl $14,$11,1 + xor $16,$15 + dsll $15,7 + xor $16,$14 + dsrl $14,$11,8 + xor $16,$15 + + dsrl $17,$8,6 + xor $16,$14 # sigma0(X[i+1]) + dsll $15,$8,3 + daddu $10,$16 + dsrl $14,$8,19 + xor $17,$15 + dsll $15,42 + xor $17,$14 + dsrl $14,$8,61 + xor $17,$15 + + xor $17,$14 # sigma1(X[i+14]) + daddu $10,$17 + daddu $14,$10,$25 # 18 + dsrl $25,$3,14 + xor $17,$7,$24 + dsll $16,$3,23 + and $17,$3 + dsrl $15,$3,18 + xor $25,$16 + dsll $16,$3,46 + xor $25,$15 + dsrl $15,$3,41 + xor $25,$16 + dsll $16,$3,50 + xor $25,$15 + xor $17,$24 # Ch(e,f,g) + xor $15,$16,$25 # Sigma1(e) + + dsrl $25,$30,28 + daddu $14,$17 + ld $17,144($6) # K[18] + dsll $16,$30,25 + daddu $14,$15 + dsrl $15,$30,34 + xor $25,$16 + dsll $16,$30,30 + xor $25,$15 + dsrl $15,$30,39 + xor $25,$16 + dsll $16,$30,36 + xor $25,$15 + sd $10,16($29) # offload to ring buffer + xor $25,$16 # Sigma0(a) + + or $15,$30,$31 + and $16,$30,$31 + and $15,$1 + or $16,$15 # Maj(a,b,c) + daddu $14,$17 # +=K[18] + daddu $25,$16 + + daddu $2,$14 + daddu $25,$14 + ld $13,40($29) # prefetch from ring buffer + dsrl $17,$12,7 # Xupdate(19) + daddu $11,$20 # +=X[i+9] + dsll $16,$12,56 + dsrl $15,$12,1 + xor $17,$16 + dsll $16,7 + xor $17,$15 + dsrl $15,$12,8 + xor $17,$16 + + dsrl $18,$9,6 + xor $17,$15 # sigma0(X[i+1]) + dsll $16,$9,3 + daddu $11,$17 + dsrl $15,$9,19 + xor $18,$16 + dsll $16,42 + xor $18,$15 + dsrl $15,$9,61 + xor $18,$16 + + xor $18,$15 # sigma1(X[i+14]) + daddu $11,$18 + daddu $15,$11,$24 # 19 + dsrl $24,$2,14 + xor $18,$3,$7 + dsll $17,$2,23 + and $18,$2 + dsrl $16,$2,18 + xor $24,$17 + dsll $17,$2,46 + xor $24,$16 + dsrl $16,$2,41 + xor $24,$17 + dsll $17,$2,50 + xor $24,$16 + xor $18,$7 # Ch(e,f,g) + xor $16,$17,$24 # Sigma1(e) + + dsrl $24,$25,28 + daddu $15,$18 + ld $18,152($6) # K[19] + dsll $17,$25,25 + daddu $15,$16 + dsrl $16,$25,34 + xor $24,$17 + dsll $17,$25,30 + xor $24,$16 + dsrl $16,$25,39 + xor $24,$17 + dsll $17,$25,36 + xor $24,$16 + sd $11,24($29) # offload to ring buffer + xor $24,$17 # Sigma0(a) + + or $16,$25,$30 + and $17,$25,$30 + and $16,$31 + or $17,$16 # Maj(a,b,c) + daddu $15,$18 # +=K[19] + daddu $24,$17 + + daddu $1,$15 + daddu $24,$15 + ld $14,48($29) # prefetch from ring buffer + dsrl $18,$13,7 # Xupdate(20) + daddu $12,$21 # +=X[i+9] + dsll $17,$13,56 + dsrl $16,$13,1 + xor $18,$17 + dsll $17,7 + xor $18,$16 + dsrl $16,$13,8 + xor $18,$17 + + dsrl $19,$10,6 + xor $18,$16 # sigma0(X[i+1]) + dsll $17,$10,3 + daddu $12,$18 + dsrl $16,$10,19 + xor $19,$17 + dsll $17,42 + xor $19,$16 + dsrl $16,$10,61 + xor $19,$17 + + xor $19,$16 # sigma1(X[i+14]) + daddu $12,$19 + daddu $16,$12,$7 # 20 + dsrl $7,$1,14 + xor $19,$2,$3 + dsll $18,$1,23 + and $19,$1 + dsrl $17,$1,18 + xor $7,$18 + dsll $18,$1,46 + xor $7,$17 + dsrl $17,$1,41 + xor $7,$18 + dsll $18,$1,50 + xor $7,$17 + xor $19,$3 # Ch(e,f,g) + xor $17,$18,$7 # Sigma1(e) + + dsrl $7,$24,28 + daddu $16,$19 + ld $19,160($6) # K[20] + dsll $18,$24,25 + daddu $16,$17 + dsrl $17,$24,34 + xor $7,$18 + dsll $18,$24,30 + xor $7,$17 + dsrl $17,$24,39 + xor $7,$18 + dsll $18,$24,36 + xor $7,$17 + sd $12,32($29) # offload to ring buffer + xor $7,$18 # Sigma0(a) + + or $17,$24,$25 + and $18,$24,$25 + and $17,$30 + or $18,$17 # Maj(a,b,c) + daddu $16,$19 # +=K[20] + daddu $7,$18 + + daddu $31,$16 + daddu $7,$16 + ld $15,56($29) # prefetch from ring buffer + dsrl $19,$14,7 # Xupdate(21) + daddu $13,$22 # +=X[i+9] + dsll $18,$14,56 + dsrl $17,$14,1 + xor $19,$18 + dsll $18,7 + xor $19,$17 + dsrl $17,$14,8 + xor $19,$18 + + dsrl $20,$11,6 + xor $19,$17 # sigma0(X[i+1]) + dsll $18,$11,3 + daddu $13,$19 + dsrl $17,$11,19 + xor $20,$18 + dsll $18,42 + xor $20,$17 + dsrl $17,$11,61 + xor $20,$18 + + xor $20,$17 # sigma1(X[i+14]) + daddu $13,$20 + daddu $17,$13,$3 # 21 + dsrl $3,$31,14 + xor $20,$1,$2 + dsll $19,$31,23 + and $20,$31 + dsrl $18,$31,18 + xor $3,$19 + dsll $19,$31,46 + xor $3,$18 + dsrl $18,$31,41 + xor $3,$19 + dsll $19,$31,50 + xor $3,$18 + xor $20,$2 # Ch(e,f,g) + xor $18,$19,$3 # Sigma1(e) + + dsrl $3,$7,28 + daddu $17,$20 + ld $20,168($6) # K[21] + dsll $19,$7,25 + daddu $17,$18 + dsrl $18,$7,34 + xor $3,$19 + dsll $19,$7,30 + xor $3,$18 + dsrl $18,$7,39 + xor $3,$19 + dsll $19,$7,36 + xor $3,$18 + sd $13,40($29) # offload to ring buffer + xor $3,$19 # Sigma0(a) + + or $18,$7,$24 + and $19,$7,$24 + and $18,$25 + or $19,$18 # Maj(a,b,c) + daddu $17,$20 # +=K[21] + daddu $3,$19 + + daddu $30,$17 + daddu $3,$17 + ld $16,64($29) # prefetch from ring buffer + dsrl $20,$15,7 # Xupdate(22) + daddu $14,$23 # +=X[i+9] + dsll $19,$15,56 + dsrl $18,$15,1 + xor $20,$19 + dsll $19,7 + xor $20,$18 + dsrl $18,$15,8 + xor $20,$19 + + dsrl $21,$12,6 + xor $20,$18 # sigma0(X[i+1]) + dsll $19,$12,3 + daddu $14,$20 + dsrl $18,$12,19 + xor $21,$19 + dsll $19,42 + xor $21,$18 + dsrl $18,$12,61 + xor $21,$19 + + xor $21,$18 # sigma1(X[i+14]) + daddu $14,$21 + daddu $18,$14,$2 # 22 + dsrl $2,$30,14 + xor $21,$31,$1 + dsll $20,$30,23 + and $21,$30 + dsrl $19,$30,18 + xor $2,$20 + dsll $20,$30,46 + xor $2,$19 + dsrl $19,$30,41 + xor $2,$20 + dsll $20,$30,50 + xor $2,$19 + xor $21,$1 # Ch(e,f,g) + xor $19,$20,$2 # Sigma1(e) + + dsrl $2,$3,28 + daddu $18,$21 + ld $21,176($6) # K[22] + dsll $20,$3,25 + daddu $18,$19 + dsrl $19,$3,34 + xor $2,$20 + dsll $20,$3,30 + xor $2,$19 + dsrl $19,$3,39 + xor $2,$20 + dsll $20,$3,36 + xor $2,$19 + sd $14,48($29) # offload to ring buffer + xor $2,$20 # Sigma0(a) + + or $19,$3,$7 + and $20,$3,$7 + and $19,$24 + or $20,$19 # Maj(a,b,c) + daddu $18,$21 # +=K[22] + daddu $2,$20 + + daddu $25,$18 + daddu $2,$18 + ld $17,72($29) # prefetch from ring buffer + dsrl $21,$16,7 # Xupdate(23) + daddu $15,$8 # +=X[i+9] + dsll $20,$16,56 + dsrl $19,$16,1 + xor $21,$20 + dsll $20,7 + xor $21,$19 + dsrl $19,$16,8 + xor $21,$20 + + dsrl $22,$13,6 + xor $21,$19 # sigma0(X[i+1]) + dsll $20,$13,3 + daddu $15,$21 + dsrl $19,$13,19 + xor $22,$20 + dsll $20,42 + xor $22,$19 + dsrl $19,$13,61 + xor $22,$20 + + xor $22,$19 # sigma1(X[i+14]) + daddu $15,$22 + daddu $19,$15,$1 # 23 + dsrl $1,$25,14 + xor $22,$30,$31 + dsll $21,$25,23 + and $22,$25 + dsrl $20,$25,18 + xor $1,$21 + dsll $21,$25,46 + xor $1,$20 + dsrl $20,$25,41 + xor $1,$21 + dsll $21,$25,50 + xor $1,$20 + xor $22,$31 # Ch(e,f,g) + xor $20,$21,$1 # Sigma1(e) + + dsrl $1,$2,28 + daddu $19,$22 + ld $22,184($6) # K[23] + dsll $21,$2,25 + daddu $19,$20 + dsrl $20,$2,34 + xor $1,$21 + dsll $21,$2,30 + xor $1,$20 + dsrl $20,$2,39 + xor $1,$21 + dsll $21,$2,36 + xor $1,$20 + sd $15,56($29) # offload to ring buffer + xor $1,$21 # Sigma0(a) + + or $20,$2,$3 + and $21,$2,$3 + and $20,$7 + or $21,$20 # Maj(a,b,c) + daddu $19,$22 # +=K[23] + daddu $1,$21 + + daddu $24,$19 + daddu $1,$19 + ld $18,80($29) # prefetch from ring buffer + dsrl $22,$17,7 # Xupdate(24) + daddu $16,$9 # +=X[i+9] + dsll $21,$17,56 + dsrl $20,$17,1 + xor $22,$21 + dsll $21,7 + xor $22,$20 + dsrl $20,$17,8 + xor $22,$21 + + dsrl $23,$14,6 + xor $22,$20 # sigma0(X[i+1]) + dsll $21,$14,3 + daddu $16,$22 + dsrl $20,$14,19 + xor $23,$21 + dsll $21,42 + xor $23,$20 + dsrl $20,$14,61 + xor $23,$21 + + xor $23,$20 # sigma1(X[i+14]) + daddu $16,$23 + daddu $20,$16,$31 # 24 + dsrl $31,$24,14 + xor $23,$25,$30 + dsll $22,$24,23 + and $23,$24 + dsrl $21,$24,18 + xor $31,$22 + dsll $22,$24,46 + xor $31,$21 + dsrl $21,$24,41 + xor $31,$22 + dsll $22,$24,50 + xor $31,$21 + xor $23,$30 # Ch(e,f,g) + xor $21,$22,$31 # Sigma1(e) + + dsrl $31,$1,28 + daddu $20,$23 + ld $23,192($6) # K[24] + dsll $22,$1,25 + daddu $20,$21 + dsrl $21,$1,34 + xor $31,$22 + dsll $22,$1,30 + xor $31,$21 + dsrl $21,$1,39 + xor $31,$22 + dsll $22,$1,36 + xor $31,$21 + sd $16,64($29) # offload to ring buffer + xor $31,$22 # Sigma0(a) + + or $21,$1,$2 + and $22,$1,$2 + and $21,$3 + or $22,$21 # Maj(a,b,c) + daddu $20,$23 # +=K[24] + daddu $31,$22 + + daddu $7,$20 + daddu $31,$20 + ld $19,88($29) # prefetch from ring buffer + dsrl $23,$18,7 # Xupdate(25) + daddu $17,$10 # +=X[i+9] + dsll $22,$18,56 + dsrl $21,$18,1 + xor $23,$22 + dsll $22,7 + xor $23,$21 + dsrl $21,$18,8 + xor $23,$22 + + dsrl $8,$15,6 + xor $23,$21 # sigma0(X[i+1]) + dsll $22,$15,3 + daddu $17,$23 + dsrl $21,$15,19 + xor $8,$22 + dsll $22,42 + xor $8,$21 + dsrl $21,$15,61 + xor $8,$22 + + xor $8,$21 # sigma1(X[i+14]) + daddu $17,$8 + daddu $21,$17,$30 # 25 + dsrl $30,$7,14 + xor $8,$24,$25 + dsll $23,$7,23 + and $8,$7 + dsrl $22,$7,18 + xor $30,$23 + dsll $23,$7,46 + xor $30,$22 + dsrl $22,$7,41 + xor $30,$23 + dsll $23,$7,50 + xor $30,$22 + xor $8,$25 # Ch(e,f,g) + xor $22,$23,$30 # Sigma1(e) + + dsrl $30,$31,28 + daddu $21,$8 + ld $8,200($6) # K[25] + dsll $23,$31,25 + daddu $21,$22 + dsrl $22,$31,34 + xor $30,$23 + dsll $23,$31,30 + xor $30,$22 + dsrl $22,$31,39 + xor $30,$23 + dsll $23,$31,36 + xor $30,$22 + sd $17,72($29) # offload to ring buffer + xor $30,$23 # Sigma0(a) + + or $22,$31,$1 + and $23,$31,$1 + and $22,$2 + or $23,$22 # Maj(a,b,c) + daddu $21,$8 # +=K[25] + daddu $30,$23 + + daddu $3,$21 + daddu $30,$21 + ld $20,96($29) # prefetch from ring buffer + dsrl $8,$19,7 # Xupdate(26) + daddu $18,$11 # +=X[i+9] + dsll $23,$19,56 + dsrl $22,$19,1 + xor $8,$23 + dsll $23,7 + xor $8,$22 + dsrl $22,$19,8 + xor $8,$23 + + dsrl $9,$16,6 + xor $8,$22 # sigma0(X[i+1]) + dsll $23,$16,3 + daddu $18,$8 + dsrl $22,$16,19 + xor $9,$23 + dsll $23,42 + xor $9,$22 + dsrl $22,$16,61 + xor $9,$23 + + xor $9,$22 # sigma1(X[i+14]) + daddu $18,$9 + daddu $22,$18,$25 # 26 + dsrl $25,$3,14 + xor $9,$7,$24 + dsll $8,$3,23 + and $9,$3 + dsrl $23,$3,18 + xor $25,$8 + dsll $8,$3,46 + xor $25,$23 + dsrl $23,$3,41 + xor $25,$8 + dsll $8,$3,50 + xor $25,$23 + xor $9,$24 # Ch(e,f,g) + xor $23,$8,$25 # Sigma1(e) + + dsrl $25,$30,28 + daddu $22,$9 + ld $9,208($6) # K[26] + dsll $8,$30,25 + daddu $22,$23 + dsrl $23,$30,34 + xor $25,$8 + dsll $8,$30,30 + xor $25,$23 + dsrl $23,$30,39 + xor $25,$8 + dsll $8,$30,36 + xor $25,$23 + sd $18,80($29) # offload to ring buffer + xor $25,$8 # Sigma0(a) + + or $23,$30,$31 + and $8,$30,$31 + and $23,$1 + or $8,$23 # Maj(a,b,c) + daddu $22,$9 # +=K[26] + daddu $25,$8 + + daddu $2,$22 + daddu $25,$22 + ld $21,104($29) # prefetch from ring buffer + dsrl $9,$20,7 # Xupdate(27) + daddu $19,$12 # +=X[i+9] + dsll $8,$20,56 + dsrl $23,$20,1 + xor $9,$8 + dsll $8,7 + xor $9,$23 + dsrl $23,$20,8 + xor $9,$8 + + dsrl $10,$17,6 + xor $9,$23 # sigma0(X[i+1]) + dsll $8,$17,3 + daddu $19,$9 + dsrl $23,$17,19 + xor $10,$8 + dsll $8,42 + xor $10,$23 + dsrl $23,$17,61 + xor $10,$8 + + xor $10,$23 # sigma1(X[i+14]) + daddu $19,$10 + daddu $23,$19,$24 # 27 + dsrl $24,$2,14 + xor $10,$3,$7 + dsll $9,$2,23 + and $10,$2 + dsrl $8,$2,18 + xor $24,$9 + dsll $9,$2,46 + xor $24,$8 + dsrl $8,$2,41 + xor $24,$9 + dsll $9,$2,50 + xor $24,$8 + xor $10,$7 # Ch(e,f,g) + xor $8,$9,$24 # Sigma1(e) + + dsrl $24,$25,28 + daddu $23,$10 + ld $10,216($6) # K[27] + dsll $9,$25,25 + daddu $23,$8 + dsrl $8,$25,34 + xor $24,$9 + dsll $9,$25,30 + xor $24,$8 + dsrl $8,$25,39 + xor $24,$9 + dsll $9,$25,36 + xor $24,$8 + sd $19,88($29) # offload to ring buffer + xor $24,$9 # Sigma0(a) + + or $8,$25,$30 + and $9,$25,$30 + and $8,$31 + or $9,$8 # Maj(a,b,c) + daddu $23,$10 # +=K[27] + daddu $24,$9 + + daddu $1,$23 + daddu $24,$23 + ld $22,112($29) # prefetch from ring buffer + dsrl $10,$21,7 # Xupdate(28) + daddu $20,$13 # +=X[i+9] + dsll $9,$21,56 + dsrl $8,$21,1 + xor $10,$9 + dsll $9,7 + xor $10,$8 + dsrl $8,$21,8 + xor $10,$9 + + dsrl $11,$18,6 + xor $10,$8 # sigma0(X[i+1]) + dsll $9,$18,3 + daddu $20,$10 + dsrl $8,$18,19 + xor $11,$9 + dsll $9,42 + xor $11,$8 + dsrl $8,$18,61 + xor $11,$9 + + xor $11,$8 # sigma1(X[i+14]) + daddu $20,$11 + daddu $8,$20,$7 # 28 + dsrl $7,$1,14 + xor $11,$2,$3 + dsll $10,$1,23 + and $11,$1 + dsrl $9,$1,18 + xor $7,$10 + dsll $10,$1,46 + xor $7,$9 + dsrl $9,$1,41 + xor $7,$10 + dsll $10,$1,50 + xor $7,$9 + xor $11,$3 # Ch(e,f,g) + xor $9,$10,$7 # Sigma1(e) + + dsrl $7,$24,28 + daddu $8,$11 + ld $11,224($6) # K[28] + dsll $10,$24,25 + daddu $8,$9 + dsrl $9,$24,34 + xor $7,$10 + dsll $10,$24,30 + xor $7,$9 + dsrl $9,$24,39 + xor $7,$10 + dsll $10,$24,36 + xor $7,$9 + sd $20,96($29) # offload to ring buffer + xor $7,$10 # Sigma0(a) + + or $9,$24,$25 + and $10,$24,$25 + and $9,$30 + or $10,$9 # Maj(a,b,c) + daddu $8,$11 # +=K[28] + daddu $7,$10 + + daddu $31,$8 + daddu $7,$8 + ld $23,120($29) # prefetch from ring buffer + dsrl $11,$22,7 # Xupdate(29) + daddu $21,$14 # +=X[i+9] + dsll $10,$22,56 + dsrl $9,$22,1 + xor $11,$10 + dsll $10,7 + xor $11,$9 + dsrl $9,$22,8 + xor $11,$10 + + dsrl $12,$19,6 + xor $11,$9 # sigma0(X[i+1]) + dsll $10,$19,3 + daddu $21,$11 + dsrl $9,$19,19 + xor $12,$10 + dsll $10,42 + xor $12,$9 + dsrl $9,$19,61 + xor $12,$10 + + xor $12,$9 # sigma1(X[i+14]) + daddu $21,$12 + daddu $9,$21,$3 # 29 + dsrl $3,$31,14 + xor $12,$1,$2 + dsll $11,$31,23 + and $12,$31 + dsrl $10,$31,18 + xor $3,$11 + dsll $11,$31,46 + xor $3,$10 + dsrl $10,$31,41 + xor $3,$11 + dsll $11,$31,50 + xor $3,$10 + xor $12,$2 # Ch(e,f,g) + xor $10,$11,$3 # Sigma1(e) + + dsrl $3,$7,28 + daddu $9,$12 + ld $12,232($6) # K[29] + dsll $11,$7,25 + daddu $9,$10 + dsrl $10,$7,34 + xor $3,$11 + dsll $11,$7,30 + xor $3,$10 + dsrl $10,$7,39 + xor $3,$11 + dsll $11,$7,36 + xor $3,$10 + sd $21,104($29) # offload to ring buffer + xor $3,$11 # Sigma0(a) + + or $10,$7,$24 + and $11,$7,$24 + and $10,$25 + or $11,$10 # Maj(a,b,c) + daddu $9,$12 # +=K[29] + daddu $3,$11 + + daddu $30,$9 + daddu $3,$9 + ld $8,0($29) # prefetch from ring buffer + dsrl $12,$23,7 # Xupdate(30) + daddu $22,$15 # +=X[i+9] + dsll $11,$23,56 + dsrl $10,$23,1 + xor $12,$11 + dsll $11,7 + xor $12,$10 + dsrl $10,$23,8 + xor $12,$11 + + dsrl $13,$20,6 + xor $12,$10 # sigma0(X[i+1]) + dsll $11,$20,3 + daddu $22,$12 + dsrl $10,$20,19 + xor $13,$11 + dsll $11,42 + xor $13,$10 + dsrl $10,$20,61 + xor $13,$11 + + xor $13,$10 # sigma1(X[i+14]) + daddu $22,$13 + daddu $10,$22,$2 # 30 + dsrl $2,$30,14 + xor $13,$31,$1 + dsll $12,$30,23 + and $13,$30 + dsrl $11,$30,18 + xor $2,$12 + dsll $12,$30,46 + xor $2,$11 + dsrl $11,$30,41 + xor $2,$12 + dsll $12,$30,50 + xor $2,$11 + xor $13,$1 # Ch(e,f,g) + xor $11,$12,$2 # Sigma1(e) + + dsrl $2,$3,28 + daddu $10,$13 + ld $13,240($6) # K[30] + dsll $12,$3,25 + daddu $10,$11 + dsrl $11,$3,34 + xor $2,$12 + dsll $12,$3,30 + xor $2,$11 + dsrl $11,$3,39 + xor $2,$12 + dsll $12,$3,36 + xor $2,$11 + sd $22,112($29) # offload to ring buffer + xor $2,$12 # Sigma0(a) + + or $11,$3,$7 + and $12,$3,$7 + and $11,$24 + or $12,$11 # Maj(a,b,c) + daddu $10,$13 # +=K[30] + daddu $2,$12 + + daddu $25,$10 + daddu $2,$10 + ld $9,8($29) # prefetch from ring buffer + dsrl $13,$8,7 # Xupdate(31) + daddu $23,$16 # +=X[i+9] + dsll $12,$8,56 + dsrl $11,$8,1 + xor $13,$12 + dsll $12,7 + xor $13,$11 + dsrl $11,$8,8 + xor $13,$12 + + dsrl $14,$21,6 + xor $13,$11 # sigma0(X[i+1]) + dsll $12,$21,3 + daddu $23,$13 + dsrl $11,$21,19 + xor $14,$12 + dsll $12,42 + xor $14,$11 + dsrl $11,$21,61 + xor $14,$12 + + xor $14,$11 # sigma1(X[i+14]) + daddu $23,$14 + daddu $11,$23,$1 # 31 + dsrl $1,$25,14 + xor $14,$30,$31 + dsll $13,$25,23 + and $14,$25 + dsrl $12,$25,18 + xor $1,$13 + dsll $13,$25,46 + xor $1,$12 + dsrl $12,$25,41 + xor $1,$13 + dsll $13,$25,50 + xor $1,$12 + xor $14,$31 # Ch(e,f,g) + xor $12,$13,$1 # Sigma1(e) + + dsrl $1,$2,28 + daddu $11,$14 + ld $14,248($6) # K[31] + dsll $13,$2,25 + daddu $11,$12 + dsrl $12,$2,34 + xor $1,$13 + dsll $13,$2,30 + xor $1,$12 + dsrl $12,$2,39 + xor $1,$13 + dsll $13,$2,36 + xor $1,$12 + sd $23,120($29) # offload to ring buffer + xor $1,$13 # Sigma0(a) + + or $12,$2,$3 + and $13,$2,$3 + and $12,$7 + or $13,$12 # Maj(a,b,c) + daddu $11,$14 # +=K[31] + daddu $1,$13 + + daddu $24,$11 + daddu $1,$11 + ld $10,16($29) # prefetch from ring buffer + and $14,0xfff + li $15,2071 + .set noreorder + bne $14,$15,.L16_xx + add $6,16*8 # Ktbl+=16 + + lw $23,16*8($29) # restore pointer to the end of input + ld $8,0*8($4) + ld $9,1*8($4) + ld $10,2*8($4) + add $5,16*8 + ld $11,3*8($4) + daddu $1,$8 + ld $12,4*8($4) + daddu $2,$9 + ld $13,5*8($4) + daddu $3,$10 + ld $14,6*8($4) + daddu $7,$11 + ld $15,7*8($4) + daddu $24,$12 + sd $1,0*8($4) + daddu $25,$13 + sd $2,1*8($4) + daddu $30,$14 + sd $3,2*8($4) + daddu $31,$15 + sd $7,3*8($4) + sd $24,4*8($4) + sd $25,5*8($4) + sd $30,6*8($4) + sd $31,7*8($4) + + bne $5,$23,.Loop + sub $6,512 # rewind $6 + + lw $31,192-1*4($29) + lw $30,192-2*4($29) + lw $23,192-3*4($29) + lw $22,192-4*4($29) + lw $21,192-5*4($29) + lw $20,192-6*4($29) + lw $19,192-7*4($29) + lw $18,192-8*4($29) + lw $17,192-9*4($29) + lw $16,192-10*4($29) + jr $31 + add $29,192 +.end sha512_block_data_order + +.rdata +.align 5 +K512: + .dword 0x428a2f98d728ae22, 0x7137449123ef65cd + .dword 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc + .dword 0x3956c25bf348b538, 0x59f111f1b605d019 + .dword 0x923f82a4af194f9b, 0xab1c5ed5da6d8118 + .dword 0xd807aa98a3030242, 0x12835b0145706fbe + .dword 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2 + .dword 0x72be5d74f27b896f, 0x80deb1fe3b1696b1 + .dword 0x9bdc06a725c71235, 0xc19bf174cf692694 + .dword 0xe49b69c19ef14ad2, 0xefbe4786384f25e3 + .dword 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65 + .dword 0x2de92c6f592b0275, 0x4a7484aa6ea6e483 + .dword 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5 + .dword 0x983e5152ee66dfab, 0xa831c66d2db43210 + .dword 0xb00327c898fb213f, 0xbf597fc7beef0ee4 + .dword 0xc6e00bf33da88fc2, 0xd5a79147930aa725 + .dword 0x06ca6351e003826f, 0x142929670a0e6e70 + .dword 0x27b70a8546d22ffc, 0x2e1b21385c26c926 + .dword 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df + .dword 0x650a73548baf63de, 0x766a0abb3c77b2a8 + .dword 0x81c2c92e47edaee6, 0x92722c851482353b + .dword 0xa2bfe8a14cf10364, 0xa81a664bbc423001 + .dword 0xc24b8b70d0f89791, 0xc76c51a30654be30 + .dword 0xd192e819d6ef5218, 0xd69906245565a910 + .dword 0xf40e35855771202a, 0x106aa07032bbd1b8 + .dword 0x19a4c116b8d2d0c8, 0x1e376c085141ab53 + .dword 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8 + .dword 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb + .dword 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3 + .dword 0x748f82ee5defb2fc, 0x78a5636f43172f60 + .dword 0x84c87814a1f0ab72, 0x8cc702081a6439ec + .dword 0x90befffa23631e28, 0xa4506cebde82bde9 + .dword 0xbef9a3f7b2c67915, 0xc67178f2e372532b + .dword 0xca273eceea26619c, 0xd186b8c721c0c207 + .dword 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178 + .dword 0x06f067aa72176fba, 0x0a637dc5a2c898a6 + .dword 0x113f9804bef90dae, 0x1b710b35131c471b + .dword 0x28db77f523047d84, 0x32caab7b40c72493 + .dword 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c + .dword 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a + .dword 0x5fcb6fab3ad6faec, 0x6c44198c4a475817 +.asciiz "SHA512 for MIPS, CRYPTOGAMS by " +.align 5 + +#if defined(HAVE_GNU_STACK) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/crypto/sha/sha_locl.h b/crypto/sha/sha_local.h similarity index 99% rename from crypto/sha/sha_locl.h rename to crypto/sha/sha_local.h index 5daab29f..97b98075 100644 --- a/crypto/sha/sha_locl.h +++ b/crypto/sha/sha_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sha_locl.h,v 1.24 2021/11/09 18:40:21 bcook Exp $ */ +/* $OpenBSD: sha_local.h,v 1.1 2022/11/26 16:08:54 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * diff --git a/crypto/sm3/sm3.c b/crypto/sm3/sm3.c index ff6240a0..1a961468 100644 --- a/crypto/sm3/sm3.c +++ b/crypto/sm3/sm3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sm3.c,v 1.1 2018/11/11 06:53:31 tb Exp $ */ +/* $OpenBSD: sm3.c,v 1.2 2022/11/26 16:08:54 tb Exp $ */ /* * Copyright (c) 2018, Ribose Inc * @@ -19,7 +19,7 @@ #include -#include "sm3_locl.h" +#include "sm3_local.h" int SM3_Init(SM3_CTX *c) diff --git a/crypto/sm3/sm3_locl.h b/crypto/sm3/sm3_local.h similarity index 97% rename from crypto/sm3/sm3_locl.h rename to crypto/sm3/sm3_local.h index 6ecf8094..a941e59c 100644 --- a/crypto/sm3/sm3_locl.h +++ b/crypto/sm3/sm3_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sm3_locl.h,v 1.1 2018/11/11 06:53:31 tb Exp $ */ +/* $OpenBSD: sm3_local.h,v 1.1 2022/11/26 16:08:54 tb Exp $ */ /* * Copyright (c) 2018, Ribose Inc * diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c index b76a0d72..bc5b2f6e 100644 --- a/crypto/stack/stack.c +++ b/crypto/stack/stack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stack.c,v 1.20 2018/04/01 00:36:28 schwarze Exp $ */ +/* $OpenBSD: stack.c,v 1.22 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -79,6 +79,7 @@ int return old; } +LCRYPTO_ALIAS(sk_set_cmp_func); _STACK * sk_dup(_STACK *sk) @@ -105,12 +106,14 @@ sk_dup(_STACK *sk) sk_free(ret); return (NULL); } +LCRYPTO_ALIAS(sk_dup); _STACK * sk_new_null(void) { return sk_new((int (*)(const void *, const void *))0); } +LCRYPTO_ALIAS(sk_new_null); _STACK * sk_new(int (*c)(const void *, const void *)) @@ -134,6 +137,7 @@ sk_new(int (*c)(const void *, const void *)) free(ret); return (NULL); } +LCRYPTO_ALIAS(sk_new); int sk_insert(_STACK *st, void *data, int loc) @@ -160,6 +164,7 @@ sk_insert(_STACK *st, void *data, int loc) st->sorted = 0; return (st->num); } +LCRYPTO_ALIAS(sk_insert); void * sk_delete_ptr(_STACK *st, void *p) @@ -171,6 +176,7 @@ sk_delete_ptr(_STACK *st, void *p) return (sk_delete(st, i)); return (NULL); } +LCRYPTO_ALIAS(sk_delete_ptr); void * sk_delete(_STACK *st, int loc) @@ -188,6 +194,7 @@ sk_delete(_STACK *st, int loc) st->num--; return (ret); } +LCRYPTO_ALIAS(sk_delete); static int internal_find(_STACK *st, void *data, int ret_val_options) @@ -219,24 +226,28 @@ sk_find(_STACK *st, void *data) { return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH); } +LCRYPTO_ALIAS(sk_find); int sk_find_ex(_STACK *st, void *data) { return internal_find(st, data, OBJ_BSEARCH_VALUE_ON_NOMATCH); } +LCRYPTO_ALIAS(sk_find_ex); int sk_push(_STACK *st, void *data) { return (sk_insert(st, data, st->num)); } +LCRYPTO_ALIAS(sk_push); int sk_unshift(_STACK *st, void *data) { return (sk_insert(st, data, 0)); } +LCRYPTO_ALIAS(sk_unshift); void * sk_shift(_STACK *st) @@ -247,6 +258,7 @@ sk_shift(_STACK *st) return (NULL); return (sk_delete(st, 0)); } +LCRYPTO_ALIAS(sk_shift); void * sk_pop(_STACK *st) @@ -257,6 +269,7 @@ sk_pop(_STACK *st) return (NULL); return (sk_delete(st, st->num - 1)); } +LCRYPTO_ALIAS(sk_pop); void sk_zero(_STACK *st) @@ -268,6 +281,7 @@ sk_zero(_STACK *st) memset(st->data, 0, sizeof(st->data)*st->num); st->num = 0; } +LCRYPTO_ALIAS(sk_zero); void sk_pop_free(_STACK *st, void (*func)(void *)) @@ -281,6 +295,7 @@ sk_pop_free(_STACK *st, void (*func)(void *)) func(st->data[i]); sk_free(st); } +LCRYPTO_ALIAS(sk_pop_free); void sk_free(_STACK *st) @@ -290,6 +305,7 @@ sk_free(_STACK *st) free(st->data); free(st); } +LCRYPTO_ALIAS(sk_free); int sk_num(const _STACK *st) @@ -298,6 +314,7 @@ sk_num(const _STACK *st) return -1; return st->num; } +LCRYPTO_ALIAS(sk_num); void * sk_value(const _STACK *st, int i) @@ -306,6 +323,7 @@ sk_value(const _STACK *st, int i) return NULL; return st->data[i]; } +LCRYPTO_ALIAS(sk_value); void * sk_set(_STACK *st, int i, void *value) @@ -315,6 +333,7 @@ sk_set(_STACK *st, int i, void *value) st->sorted = 0; return (st->data[i] = value); } +LCRYPTO_ALIAS(sk_set); void sk_sort(_STACK *st) @@ -332,6 +351,7 @@ sk_sort(_STACK *st) st->sorted = 1; } } +LCRYPTO_ALIAS(sk_sort); int sk_is_sorted(const _STACK *st) @@ -340,3 +360,4 @@ sk_is_sorted(const _STACK *st) return 1; return st->sorted; } +LCRYPTO_ALIAS(sk_is_sorted); diff --git a/crypto/ts/ts_lib.c b/crypto/ts/ts_lib.c index b6d50a36..ae715fb6 100644 --- a/crypto/ts/ts_lib.c +++ b/crypto/ts/ts_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_lib.c,v 1.12 2021/12/04 16:08:32 tb Exp $ */ +/* $OpenBSD: ts_lib.c,v 1.13 2022/11/26 16:08:54 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -64,8 +64,8 @@ #include #include -#include "bn_lcl.h" -#include "x509_lcl.h" +#include "bn_local.h" +#include "x509_local.h" /* Local function declarations. */ diff --git a/crypto/ts/ts_local.h b/crypto/ts/ts_local.h index cf1e9e05..07c9861e 100644 --- a/crypto/ts/ts_local.h +++ b/crypto/ts/ts_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_local.h,v 1.2 2022/09/11 17:31:19 tb Exp $ */ +/* $OpenBSD: ts_local.h,v 1.3 2022/11/26 17:23:18 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@opentsa.org) for the OpenSSL * project 2002, 2003, 2004. */ @@ -313,4 +313,4 @@ ESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_dup(ESS_SIGNING_CERT_V2 *a); __END_HIDDEN_DECLS -#endif /* HEADER_TS_LOCAL_H */ +#endif /* !HEADER_TS_LOCAL_H */ diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c index 5e152954..7ebadb10 100644 --- a/crypto/ts/ts_rsp_sign.c +++ b/crypto/ts/ts_rsp_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_rsp_sign.c,v 1.29 2022/07/24 20:02:04 tb Exp $ */ +/* $OpenBSD: ts_rsp_sign.c,v 1.30 2022/11/26 16:08:54 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -65,9 +65,9 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" #include "ts_local.h" -#include "x509_lcl.h" +#include "x509_local.h" /* Private function declarations. */ diff --git a/crypto/ts/ts_rsp_verify.c b/crypto/ts/ts_rsp_verify.c index a5829b35..dc467d86 100644 --- a/crypto/ts/ts_rsp_verify.c +++ b/crypto/ts/ts_rsp_verify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_rsp_verify.c,v 1.28 2022/07/24 08:16:47 tb Exp $ */ +/* $OpenBSD: ts_rsp_verify.c,v 1.29 2022/11/26 16:08:54 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -64,9 +64,9 @@ #include #include -#include "evp_locl.h" +#include "evp_local.h" #include "ts_local.h" -#include "x509_lcl.h" +#include "x509_local.h" /* Private function declarations. */ diff --git a/crypto/ui/ui_err.c b/crypto/ui/ui_err.c index 691403af..3f875da7 100644 --- a/crypto/ui/ui_err.c +++ b/crypto/ui/ui_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_err.c,v 1.10 2022/07/12 14:42:50 kn Exp $ */ +/* $OpenBSD: ui_err.c,v 1.12 2023/02/16 08:38:17 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -93,3 +93,4 @@ ERR_load_UI_strings(void) } #endif } +LCRYPTO_ALIAS(ERR_load_UI_strings); diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c index 09522e71..73d899af 100644 --- a/crypto/ui/ui_lib.c +++ b/crypto/ui/ui_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_lib.c,v 1.44 2020/09/25 11:25:31 tb Exp $ */ +/* $OpenBSD: ui_lib.c,v 1.51 2023/02/16 08:38:17 tb Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ @@ -64,7 +64,7 @@ #include #include -#include "ui_locl.h" +#include "ui_local.h" static const UI_METHOD *default_UI_meth = NULL; @@ -73,6 +73,7 @@ UI_new(void) { return (UI_new_method(NULL)); } +LCRYPTO_ALIAS(UI_new); UI * UI_new_method(const UI_METHOD *method) @@ -89,6 +90,7 @@ UI_new_method(const UI_METHOD *method) return ret; } +LCRYPTO_ALIAS(UI_new_method); static void free_string(UI_STRING *uis) @@ -115,10 +117,12 @@ UI_free(UI *ui) { if (ui == NULL) return; + sk_UI_STRING_pop_free(ui->strings, free_string); CRYPTO_free_ex_data(CRYPTO_EX_INDEX_UI, ui, &ui->ex_data); free(ui); } +LCRYPTO_ALIAS(UI_free); static int allocate_string_stack(UI *ui) @@ -265,6 +269,7 @@ UI_add_input_string(UI *ui, const char *prompt, int flags, char *result_buf, return general_allocate_string(ui, prompt, 0, UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); } +LCRYPTO_ALIAS(UI_add_input_string); /* Same as UI_add_input_string(), excepts it takes a copy of the prompt. */ int @@ -274,6 +279,7 @@ UI_dup_input_string(UI *ui, const char *prompt, int flags, char *result_buf, return general_allocate_string(ui, prompt, 1, UIT_PROMPT, flags, result_buf, minsize, maxsize, NULL); } +LCRYPTO_ALIAS(UI_dup_input_string); int UI_add_verify_string(UI *ui, const char *prompt, int flags, char *result_buf, @@ -282,6 +288,7 @@ UI_add_verify_string(UI *ui, const char *prompt, int flags, char *result_buf, return general_allocate_string(ui, prompt, 0, UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); } +LCRYPTO_ALIAS(UI_add_verify_string); int UI_dup_verify_string(UI *ui, const char *prompt, int flags, @@ -290,6 +297,7 @@ UI_dup_verify_string(UI *ui, const char *prompt, int flags, return general_allocate_string(ui, prompt, 1, UIT_VERIFY, flags, result_buf, minsize, maxsize, test_buf); } +LCRYPTO_ALIAS(UI_dup_verify_string); int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, @@ -298,6 +306,7 @@ UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, return general_allocate_boolean(ui, prompt, action_desc, ok_chars, cancel_chars, 0, UIT_BOOLEAN, flags, result_buf); } +LCRYPTO_ALIAS(UI_add_input_boolean); int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, @@ -306,6 +315,7 @@ UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, return general_allocate_boolean(ui, prompt, action_desc, ok_chars, cancel_chars, 1, UIT_BOOLEAN, flags, result_buf); } +LCRYPTO_ALIAS(UI_dup_input_boolean); int UI_add_info_string(UI *ui, const char *text) @@ -313,6 +323,7 @@ UI_add_info_string(UI *ui, const char *text) return general_allocate_string(ui, text, 0, UIT_INFO, 0, NULL, 0, 0, NULL); } +LCRYPTO_ALIAS(UI_add_info_string); int UI_dup_info_string(UI *ui, const char *text) @@ -320,6 +331,7 @@ UI_dup_info_string(UI *ui, const char *text) return general_allocate_string(ui, text, 1, UIT_INFO, 0, NULL, 0, 0, NULL); } +LCRYPTO_ALIAS(UI_dup_info_string); int UI_add_error_string(UI *ui, const char *text) @@ -327,6 +339,7 @@ UI_add_error_string(UI *ui, const char *text) return general_allocate_string(ui, text, 0, UIT_ERROR, 0, NULL, 0, 0, NULL); } +LCRYPTO_ALIAS(UI_add_error_string); int UI_dup_error_string(UI *ui, const char *text) @@ -334,6 +347,7 @@ UI_dup_error_string(UI *ui, const char *text) return general_allocate_string(ui, text, 1, UIT_ERROR, 0, NULL, 0, 0, NULL); } +LCRYPTO_ALIAS(UI_dup_error_string); char * UI_construct_prompt(UI *ui, const char *object_desc, const char *object_name) @@ -358,6 +372,7 @@ UI_construct_prompt(UI *ui, const char *object_desc, const char *object_name) return prompt; } +LCRYPTO_ALIAS(UI_construct_prompt); void * UI_add_user_data(UI *ui, void *user_data) @@ -365,14 +380,17 @@ UI_add_user_data(UI *ui, void *user_data) void *old_data = ui->user_data; ui->user_data = user_data; + return old_data; } +LCRYPTO_ALIAS(UI_add_user_data); void * UI_get0_user_data(UI *ui) { return ui->user_data; } +LCRYPTO_ALIAS(UI_get0_user_data); const char * UI_get0_result(UI *ui, int i) @@ -387,6 +405,7 @@ UI_get0_result(UI *ui, int i) } return UI_get0_result_string(sk_UI_STRING_value(ui->strings, i)); } +LCRYPTO_ALIAS(UI_get0_result); static int print_error(const char *str, size_t len, void *arg) @@ -460,6 +479,7 @@ UI_process(UI *ui) return -1; return ok; } +LCRYPTO_ALIAS(UI_process); int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void)) @@ -468,6 +488,7 @@ UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void)) UIerror(ERR_R_PASSED_NULL_PARAMETER); return -1; } + switch (cmd) { case UI_CTRL_PRINT_ERRORS: { @@ -486,6 +507,7 @@ UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void)) UIerror(UI_R_UNKNOWN_CONTROL_COMMAND); return -1; } +LCRYPTO_ALIAS(UI_ctrl); int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, @@ -494,212 +516,259 @@ UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, argl, argp, new_func, dup_func, free_func); } +LCRYPTO_ALIAS(UI_get_ex_new_index); int UI_set_ex_data(UI *r, int idx, void *arg) { return (CRYPTO_set_ex_data(&r->ex_data, idx, arg)); } +LCRYPTO_ALIAS(UI_set_ex_data); void * UI_get_ex_data(UI *r, int idx) { return (CRYPTO_get_ex_data(&r->ex_data, idx)); } +LCRYPTO_ALIAS(UI_get_ex_data); void -UI_set_default_method(const UI_METHOD *meth) +UI_set_default_method(const UI_METHOD *method) { - default_UI_meth = meth; + default_UI_meth = method; } +LCRYPTO_ALIAS(UI_set_default_method); const UI_METHOD * UI_get_default_method(void) { - if (default_UI_meth == NULL) { + if (default_UI_meth == NULL) default_UI_meth = UI_OpenSSL(); - } + return default_UI_meth; } +LCRYPTO_ALIAS(UI_get_default_method); const UI_METHOD * UI_get_method(UI *ui) { return ui->meth; } +LCRYPTO_ALIAS(UI_get_method); const UI_METHOD * -UI_set_method(UI *ui, const UI_METHOD *meth) +UI_set_method(UI *ui, const UI_METHOD *method) { - ui->meth = meth; + ui->meth = method; + return ui->meth; } - +LCRYPTO_ALIAS(UI_set_method); UI_METHOD * UI_create_method(const char *name) { - UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD)); + UI_METHOD *method = NULL; - if (ui_method && name) - ui_method->name = strdup(name); + if ((method = calloc(1, sizeof(UI_METHOD))) == NULL) + goto err; + + if (name != NULL) { + if ((method->name = strdup(name)) == NULL) + goto err; + } + + return method; - return ui_method; + err: + UI_destroy_method(method); + + return NULL; } +LCRYPTO_ALIAS(UI_create_method); -/* - * BIG FSCKING WARNING!!!! If you use this on a statically allocated method - * (that is, it hasn't been allocated using UI_create_method(), you deserve - * anything Murphy can throw at you and more! You have been warned. - */ void -UI_destroy_method(UI_METHOD *ui_method) +UI_destroy_method(UI_METHOD *method) { - free(ui_method->name); - ui_method->name = NULL; - free(ui_method); + if (method == NULL) + return; + + free(method->name); + free(method); } +LCRYPTO_ALIAS(UI_destroy_method); int UI_method_set_opener(UI_METHOD *method, int (*opener)(UI *ui)) { - if (method) { - method->ui_open_session = opener; - return 0; - } - return -1; + if (method == NULL) + return -1; + + method->ui_open_session = opener; + + return 0; } +LCRYPTO_ALIAS(UI_method_set_opener); int UI_method_set_writer(UI_METHOD *method, int (*writer)(UI *ui, UI_STRING *uis)) { - if (method) { - method->ui_write_string = writer; - return 0; - } - return -1; + if (method == NULL) + return -1; + + method->ui_write_string = writer; + + return 0; } +LCRYPTO_ALIAS(UI_method_set_writer); int UI_method_set_flusher(UI_METHOD *method, int (*flusher)(UI *ui)) { - if (method) { - method->ui_flush = flusher; - return 0; - } - return -1; + if (method == NULL) + return -1; + + method->ui_flush = flusher; + + return 0; } +LCRYPTO_ALIAS(UI_method_set_flusher); int UI_method_set_reader(UI_METHOD *method, int (*reader)(UI *ui, UI_STRING *uis)) { - if (method) { - method->ui_read_string = reader; - return 0; - } - return -1; + if (method == NULL) + return -1; + + method->ui_read_string = reader; + + return 0; } +LCRYPTO_ALIAS(UI_method_set_reader); int UI_method_set_closer(UI_METHOD *method, int (*closer)(UI *ui)) { - if (method) { - method->ui_close_session = closer; - return 0; - } - return -1; + if (method == NULL) + return -1; + + method->ui_close_session = closer; + + return 0; } +LCRYPTO_ALIAS(UI_method_set_closer); int UI_method_set_prompt_constructor(UI_METHOD *method, char *(*prompt_constructor)(UI *ui, const char *object_desc, const char *object_name)) { - if (method) { - method->ui_construct_prompt = prompt_constructor; - return 0; - } - return -1; + if (method == NULL) + return -1; + + method->ui_construct_prompt = prompt_constructor; + + return 0; } +LCRYPTO_ALIAS(UI_method_set_prompt_constructor); int (*UI_method_get_opener(const UI_METHOD * method))(UI *) { - if (method) - return method->ui_open_session; - return NULL; + if (method == NULL) + return NULL; + + return method->ui_open_session; } +LCRYPTO_ALIAS(UI_method_get_opener); int (*UI_method_get_writer(const UI_METHOD *method))(UI *, UI_STRING *) { - if (method) - return method->ui_write_string; - return NULL; + if (method == NULL) + return NULL; + + return method->ui_write_string; } +LCRYPTO_ALIAS(UI_method_get_writer); int (*UI_method_get_flusher(const UI_METHOD *method)) (UI *) { - if (method) - return method->ui_flush; - return NULL; + if (method == NULL) + return NULL; + + return method->ui_flush; } +LCRYPTO_ALIAS(UI_method_get_flusher); int (*UI_method_get_reader(const UI_METHOD *method))(UI *, UI_STRING *) { - if (method) - return method->ui_read_string; - return NULL; + if (method == NULL) + return NULL; + + return method->ui_read_string; } +LCRYPTO_ALIAS(UI_method_get_reader); int (*UI_method_get_closer(const UI_METHOD *method))(UI *) { - if (method) - return method->ui_close_session; - return NULL; + if (method == NULL) + return NULL; + + return method->ui_close_session; } +LCRYPTO_ALIAS(UI_method_get_closer); char * (*UI_method_get_prompt_constructor(const UI_METHOD *method))(UI *, const char *, const char *) { - if (method) - return method->ui_construct_prompt; - return NULL; + if (method == NULL) + return NULL; + + return method->ui_construct_prompt; } +LCRYPTO_ALIAS(UI_method_get_prompt_constructor); enum UI_string_types UI_get_string_type(UI_STRING *uis) { - if (!uis) + if (uis == NULL) return UIT_NONE; + return uis->type; } +LCRYPTO_ALIAS(UI_get_string_type); int UI_get_input_flags(UI_STRING *uis) { - if (!uis) + if (uis == NULL) return 0; + return uis->input_flags; } +LCRYPTO_ALIAS(UI_get_input_flags); const char * UI_get0_output_string(UI_STRING *uis) { - if (!uis) + if (uis == NULL) return NULL; + return uis->out_string; } +LCRYPTO_ALIAS(UI_get0_output_string); const char * UI_get0_action_string(UI_STRING *uis) { - if (!uis) + if (uis == NULL) return NULL; + switch (uis->type) { case UIT_PROMPT: case UIT_BOOLEAN: @@ -708,12 +777,14 @@ UI_get0_action_string(UI_STRING *uis) return NULL; } } +LCRYPTO_ALIAS(UI_get0_action_string); const char * UI_get0_result_string(UI_STRING *uis) { - if (!uis) + if (uis == NULL) return NULL; + switch (uis->type) { case UIT_PROMPT: case UIT_VERIFY: @@ -722,12 +793,14 @@ UI_get0_result_string(UI_STRING *uis) return NULL; } } +LCRYPTO_ALIAS(UI_get0_result_string); const char * UI_get0_test_string(UI_STRING *uis) { - if (!uis) + if (uis == NULL) return NULL; + switch (uis->type) { case UIT_VERIFY: return uis->_.string_data.test_buf; @@ -735,12 +808,14 @@ UI_get0_test_string(UI_STRING *uis) return NULL; } } +LCRYPTO_ALIAS(UI_get0_test_string); int UI_get_result_minsize(UI_STRING *uis) { - if (!uis) + if (uis == NULL) return -1; + switch (uis->type) { case UIT_PROMPT: case UIT_VERIFY: @@ -749,12 +824,14 @@ UI_get_result_minsize(UI_STRING *uis) return -1; } } +LCRYPTO_ALIAS(UI_get_result_minsize); int UI_get_result_maxsize(UI_STRING *uis) { - if (!uis) + if (uis == NULL) return -1; + switch (uis->type) { case UIT_PROMPT: case UIT_VERIFY: @@ -763,6 +840,7 @@ UI_get_result_maxsize(UI_STRING *uis) return -1; } } +LCRYPTO_ALIAS(UI_get_result_maxsize); int UI_set_result(UI *ui, UI_STRING *uis, const char *result) @@ -772,8 +850,9 @@ UI_set_result(UI *ui, UI_STRING *uis, const char *result) ui->flags &= ~UI_FLAG_REDOABLE; - if (!uis) + if (uis == NULL) return -1; + switch (uis->type) { case UIT_PROMPT: case UIT_VERIFY: @@ -825,3 +904,4 @@ UI_set_result(UI *ui, UI_STRING *uis, const char *result) } return 0; } +LCRYPTO_ALIAS(UI_set_result); diff --git a/crypto/ui/ui_locl.h b/crypto/ui/ui_local.h similarity index 97% rename from crypto/ui/ui_locl.h rename to crypto/ui/ui_local.h index c424be65..460b5600 100644 --- a/crypto/ui/ui_locl.h +++ b/crypto/ui/ui_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_locl.h,v 1.7 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: ui_local.h,v 1.2 2022/11/26 17:23:18 tb Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. @@ -57,8 +57,8 @@ * */ -#ifndef HEADER_UI_LOCL_H -#define HEADER_UI_LOCL_H +#ifndef HEADER_UI_LOCAL_H +#define HEADER_UI_LOCAL_H #include #include @@ -149,4 +149,4 @@ struct ui_st { __END_HIDDEN_DECLS -#endif +#endif /* !HEADER_UI_LOCAL_H */ diff --git a/crypto/ui/ui_null.c b/crypto/ui/ui_null.c new file mode 100644 index 00000000..cbc9a502 --- /dev/null +++ b/crypto/ui/ui_null.c @@ -0,0 +1,18 @@ +/* $OpenBSD: ui_null.c,v 1.2 2023/02/16 08:38:17 tb Exp $ */ + +/* + * Written by Theo Buehler. Public domain. + */ + +#include "ui_local.h" + +static const UI_METHOD ui_null = { + .name = "OpenSSL NULL UI", +}; + +const UI_METHOD * +UI_null(void) +{ + return &ui_null; +} +LCRYPTO_ALIAS(UI_null); diff --git a/crypto/ui/ui_openssl.c b/crypto/ui/ui_openssl.c index 9562c2c9..0b917005 100644 --- a/crypto/ui/ui_openssl.c +++ b/crypto/ui/ui_openssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_openssl.c,v 1.25 2015/09/10 15:56:26 jsing Exp $ */ +/* $OpenBSD: ui_openssl.c,v 1.28 2023/02/16 08:38:17 tb Exp $ */ /* Written by Richard Levitte (richard@levitte.org) and others * for the OpenSSL project 2001. */ @@ -125,7 +125,7 @@ #include #include -#include "ui_locl.h" +#include "ui_local.h" #ifndef NX509_SIG #define NX509_SIG 32 @@ -167,6 +167,7 @@ UI_OpenSSL(void) { return &ui_openssl; } +LCRYPTO_ALIAS(UI_OpenSSL); /* The following function makes sure that info and error strings are printed before any prompt. */ diff --git a/crypto/ui/ui_openssl_win.c b/crypto/ui/ui_openssl_win.c index ad9e9156..c245111d 100644 --- a/crypto/ui/ui_openssl_win.c +++ b/crypto/ui/ui_openssl_win.c @@ -124,7 +124,7 @@ #include #include -#include "ui_locl.h" +#include "ui_local.h" #ifndef NX509_SIG #define NX509_SIG 32 diff --git a/crypto/ui/ui_util.c b/crypto/ui/ui_util.c index d1040c98..4fa4058c 100644 --- a/crypto/ui/ui_util.c +++ b/crypto/ui/ui_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_util.c,v 1.10 2015/09/10 15:56:26 jsing Exp $ */ +/* $OpenBSD: ui_util.c,v 1.14 2023/02/16 08:38:17 tb Exp $ */ /* ==================================================================== * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved. * @@ -57,7 +57,7 @@ #include -#include "ui_locl.h" +#include "ui_local.h" int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify) @@ -70,6 +70,7 @@ UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, int verify) explicit_bzero(buff, BUFSIZ); return (ret); } +LCRYPTO_ALIAS(UI_UTIL_read_pw_string); int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) @@ -94,18 +95,4 @@ UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) ok = 0; return (ok); } - -/* - * Old compatibility glue - see comment in ui_compat.h. - */ -int -_ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify) -{ - return UI_UTIL_read_pw_string(buf, length, prompt, verify); -} - -int -_ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) -{ - return UI_UTIL_read_pw(buf, buff, size, prompt, verify); -} +LCRYPTO_ALIAS(UI_UTIL_read_pw); diff --git a/crypto/whrlpool/wp-elf-x86_64.S b/crypto/whrlpool/wp-elf-x86_64.S index 2b37a988..21ef2a7d 100644 --- a/crypto/whrlpool/wp-elf-x86_64.S +++ b/crypto/whrlpool/wp-elf-x86_64.S @@ -588,6 +588,7 @@ whirlpool_block: retq .size whirlpool_block,.-whirlpool_block +.section .rodata .align 64 .type .Ltable,@object .Ltable: diff --git a/crypto/whrlpool/wp-macosx-x86_64.S b/crypto/whrlpool/wp-macosx-x86_64.S index 6df325ad..30724cd3 100644 --- a/crypto/whrlpool/wp-macosx-x86_64.S +++ b/crypto/whrlpool/wp-macosx-x86_64.S @@ -588,6 +588,7 @@ L$epilogue: retq +.section __DATA,__const .p2align 6 L$table: diff --git a/crypto/whrlpool/wp-masm-x86_64.S b/crypto/whrlpool/wp-masm-x86_64.S index 71f0c012..961a1171 100644 --- a/crypto/whrlpool/wp-masm-x86_64.S +++ b/crypto/whrlpool/wp-masm-x86_64.S @@ -668,6 +668,8 @@ $L$epilogue:: $L$SEH_end_whirlpool_block:: whirlpool_block ENDP +.text$ ENDS +.rdata SEGMENT READONLY ALIGN(8) ALIGN 64 $L$table:: @@ -938,6 +940,6 @@ DB 228,39,65,139,167,125,149,216 DB 251,238,124,102,221,23,71,158 DB 202,45,191,7,173,90,131,51 -.text$ ENDS +.rdata ENDS END diff --git a/crypto/whrlpool/wp-mingw64-x86_64.S b/crypto/whrlpool/wp-mingw64-x86_64.S index ea9f6cf9..c5bad4e6 100644 --- a/crypto/whrlpool/wp-mingw64-x86_64.S +++ b/crypto/whrlpool/wp-mingw64-x86_64.S @@ -598,6 +598,7 @@ whirlpool_block: retq .LSEH_end_whirlpool_block: +.section .rodata .p2align 6 .Ltable: diff --git a/crypto/whrlpool/wp_block.c b/crypto/whrlpool/wp_block.c index b2137d64..ad814a34 100644 --- a/crypto/whrlpool/wp_block.c +++ b/crypto/whrlpool/wp_block.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wp_block.c,v 1.14 2021/11/09 18:40:21 bcook Exp $ */ +/* $OpenBSD: wp_block.c,v 1.15 2022/11/26 16:08:54 tb Exp $ */ /** * The Whirlpool hashing function. * @@ -40,7 +40,7 @@ #include #include -#include "wp_locl.h" +#include "wp_local.h" typedef unsigned char u8; #if defined(_LP64) diff --git a/crypto/whrlpool/wp_dgst.c b/crypto/whrlpool/wp_dgst.c index 663f2ef5..fd074c18 100644 --- a/crypto/whrlpool/wp_dgst.c +++ b/crypto/whrlpool/wp_dgst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wp_dgst.c,v 1.4 2014/07/12 11:25:25 miod Exp $ */ +/* $OpenBSD: wp_dgst.c,v 1.5 2022/11/26 16:08:54 tb Exp $ */ /** * The Whirlpool hashing function. * @@ -52,7 +52,7 @@ * input. This is done for performance. */ -#include "wp_locl.h" +#include "wp_local.h" #include #include diff --git a/crypto/whrlpool/wp_locl.h b/crypto/whrlpool/wp_local.h similarity index 67% rename from crypto/whrlpool/wp_locl.h rename to crypto/whrlpool/wp_local.h index 771c65e4..2d3bc9c6 100644 --- a/crypto/whrlpool/wp_locl.h +++ b/crypto/whrlpool/wp_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: wp_locl.h,v 1.3 2016/12/21 15:49:29 jsing Exp $ */ +/* $OpenBSD: wp_local.h,v 1.1 2022/11/26 16:08:54 tb Exp $ */ #include diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index fa05f552..9fa6a100 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: by_dir.c,v 1.41 2021/11/10 14:34:21 schwarze Exp $ */ +/* $OpenBSD: by_dir.c,v 1.44 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -70,7 +70,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" typedef struct lookup_dir_hashes_st { unsigned long hash; @@ -117,6 +117,7 @@ X509_LOOKUP_hash_dir(void) { return &x509_dir_lookup; } +LCRYPTO_ALIAS(X509_LOOKUP_hash_dir); static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, diff --git a/crypto/x509/by_file.c b/crypto/x509/by_file.c index 3116b7cf..606f4c8d 100644 --- a/crypto/x509/by_file.c +++ b/crypto/x509/by_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: by_file.c,v 1.25 2021/11/10 13:57:42 schwarze Exp $ */ +/* $OpenBSD: by_file.c,v 1.28 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,7 +66,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); @@ -89,6 +89,7 @@ X509_LOOKUP_file(void) { return &x509_file_lookup; } +LCRYPTO_ALIAS(X509_LOOKUP_file); static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, @@ -173,6 +174,7 @@ X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type) BIO_free(in); return ret; } +LCRYPTO_ALIAS(X509_load_cert_file); int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type) @@ -229,6 +231,7 @@ X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type) BIO_free(in); return ret; } +LCRYPTO_ALIAS(X509_load_crl_file); int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type) @@ -267,4 +270,4 @@ X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type) sk_X509_INFO_pop_free(inf, X509_INFO_free); return count; } - +LCRYPTO_ALIAS(X509_load_cert_crl_file); diff --git a/crypto/x509/by_mem.c b/crypto/x509/by_mem.c index 272877f8..579eecd3 100644 --- a/crypto/x509/by_mem.c +++ b/crypto/x509/by_mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: by_mem.c,v 1.5 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: by_mem.c,v 1.8 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -68,7 +68,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static int by_mem_ctrl(X509_LOOKUP *, int, const char *, long, char **); @@ -90,6 +90,7 @@ X509_LOOKUP_mem(void) { return (&x509_mem_lookup); } +LCRYPTO_ALIAS(X509_LOOKUP_mem); static int by_mem_ctrl(X509_LOOKUP *lu, int cmd, const char *buf, diff --git a/crypto/x509/pcy_cache.c b/crypto/x509/pcy_cache.c index debca302..6424160d 100644 --- a/crypto/x509/pcy_cache.c +++ b/crypto/x509/pcy_cache.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcy_cache.c,v 1.2 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: pcy_cache.c,v 1.3 2022/11/26 16:08:54 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ @@ -60,7 +60,7 @@ #include #include "pcy_int.h" -#include "x509_lcl.h" +#include "x509_local.h" static int policy_data_cmp(const X509_POLICY_DATA * const *a, const X509_POLICY_DATA * const *b); diff --git a/crypto/x509/pcy_lib.c b/crypto/x509/pcy_lib.c index 3d5c58d7..e4d3fd9f 100644 --- a/crypto/x509/pcy_lib.c +++ b/crypto/x509/pcy_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcy_lib.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ +/* $OpenBSD: pcy_lib.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ @@ -72,6 +72,7 @@ X509_policy_tree_level_count(const X509_POLICY_TREE *tree) return 0; return tree->nlevel; } +LCRYPTO_ALIAS(X509_policy_tree_level_count); X509_POLICY_LEVEL * X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i) @@ -80,6 +81,7 @@ X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, int i) return NULL; return tree->levels + i; } +LCRYPTO_ALIAS(X509_policy_tree_get0_level); STACK_OF(X509_POLICY_NODE) * X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree) @@ -88,6 +90,7 @@ X509_policy_tree_get0_policies(const X509_POLICY_TREE *tree) return NULL; return tree->auth_policies; } +LCRYPTO_ALIAS(X509_policy_tree_get0_policies); STACK_OF(X509_POLICY_NODE) * X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree) @@ -99,6 +102,7 @@ X509_policy_tree_get0_user_policies(const X509_POLICY_TREE *tree) else return tree->user_policies; } +LCRYPTO_ALIAS(X509_policy_tree_get0_user_policies); /* X509_POLICY_LEVEL stuff */ @@ -116,6 +120,7 @@ X509_policy_level_node_count(X509_POLICY_LEVEL *level) n += sk_X509_POLICY_NODE_num(level->nodes); return n; } +LCRYPTO_ALIAS(X509_policy_level_node_count); X509_POLICY_NODE * X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i) @@ -129,6 +134,7 @@ X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i) } return sk_X509_POLICY_NODE_value(level->nodes, i); } +LCRYPTO_ALIAS(X509_policy_level_get0_node); /* X509_POLICY_NODE stuff */ @@ -139,6 +145,7 @@ X509_policy_node_get0_policy(const X509_POLICY_NODE *node) return NULL; return node->data->valid_policy; } +LCRYPTO_ALIAS(X509_policy_node_get0_policy); STACK_OF(POLICYQUALINFO) * X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node) @@ -147,6 +154,7 @@ X509_policy_node_get0_qualifiers(const X509_POLICY_NODE *node) return NULL; return node->data->qualifier_set; } +LCRYPTO_ALIAS(X509_policy_node_get0_qualifiers); const X509_POLICY_NODE * X509_policy_node_get0_parent(const X509_POLICY_NODE *node) @@ -155,3 +163,4 @@ X509_policy_node_get0_parent(const X509_POLICY_NODE *node) return NULL; return node->parent; } +LCRYPTO_ALIAS(X509_policy_node_get0_parent); diff --git a/crypto/x509/pcy_map.c b/crypto/x509/pcy_map.c index f2e5d325..fe21ba14 100644 --- a/crypto/x509/pcy_map.c +++ b/crypto/x509/pcy_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcy_map.c,v 1.2 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: pcy_map.c,v 1.3 2022/11/26 16:08:54 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ @@ -60,7 +60,7 @@ #include #include "pcy_int.h" -#include "x509_lcl.h" +#include "x509_local.h" /* Set policy mapping entries in cache. * Note: this modifies the passed POLICY_MAPPINGS structure diff --git a/crypto/x509/pcy_tree.c b/crypto/x509/pcy_tree.c index 284c08e6..56e05910 100644 --- a/crypto/x509/pcy_tree.c +++ b/crypto/x509/pcy_tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcy_tree.c,v 1.2 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: pcy_tree.c,v 1.6 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ @@ -60,7 +60,7 @@ #include #include "pcy_int.h" -#include "x509_lcl.h" +#include "x509_local.h" /* Enable this to print out the complete policy tree at various point during * evaluation. @@ -131,7 +131,7 @@ tree_print(char *str, X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr) #endif /* Initialize policy tree. Return values: - * 0 Some internal error occured. + * 0 Some internal error occurred. * -1 Inconsistent or invalid extensions in certificates. * 1 Tree initialized OK. * 2 Policy tree is empty. @@ -657,6 +657,7 @@ X509_policy_tree_free(X509_POLICY_TREE *tree) free(tree->levels); free(tree); } +LCRYPTO_ALIAS(X509_policy_tree_free); /* Application policy checking function. * Return codes: @@ -769,3 +770,4 @@ X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, return 0; } +LCRYPTO_ALIAS(X509_policy_check); diff --git a/crypto/x509/x509_addr.c b/crypto/x509/x509_addr.c index e15bf821..2d8cc0b3 100644 --- a/crypto/x509/x509_addr.c +++ b/crypto/x509/x509_addr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_addr.c,v 1.83 2022/05/25 17:10:30 tb Exp $ */ +/* $OpenBSD: x509_addr.c,v 1.86 2023/02/16 08:38:17 tb Exp $ */ /* * Contributed to the OpenSSL Project by the American Registry for * Internet Numbers ("ARIN"). @@ -73,9 +73,9 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" #include "bytestring.h" -#include "x509_lcl.h" +#include "x509_local.h" #ifndef OPENSSL_NO_RFC3779 @@ -215,24 +215,28 @@ d2i_IPAddressRange(IPAddressRange **a, const unsigned char **in, long len) return (IPAddressRange *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &IPAddressRange_it); } +LCRYPTO_ALIAS(d2i_IPAddressRange); int i2d_IPAddressRange(IPAddressRange *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &IPAddressRange_it); } +LCRYPTO_ALIAS(i2d_IPAddressRange); IPAddressRange * IPAddressRange_new(void) { return (IPAddressRange *)ASN1_item_new(&IPAddressRange_it); } +LCRYPTO_ALIAS(IPAddressRange_new); void IPAddressRange_free(IPAddressRange *a) { ASN1_item_free((ASN1_VALUE *)a, &IPAddressRange_it); } +LCRYPTO_ALIAS(IPAddressRange_free); IPAddressOrRange * d2i_IPAddressOrRange(IPAddressOrRange **a, const unsigned char **in, long len) @@ -240,24 +244,28 @@ d2i_IPAddressOrRange(IPAddressOrRange **a, const unsigned char **in, long len) return (IPAddressOrRange *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &IPAddressOrRange_it); } +LCRYPTO_ALIAS(d2i_IPAddressOrRange); int i2d_IPAddressOrRange(IPAddressOrRange *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &IPAddressOrRange_it); } +LCRYPTO_ALIAS(i2d_IPAddressOrRange); IPAddressOrRange * IPAddressOrRange_new(void) { return (IPAddressOrRange *)ASN1_item_new(&IPAddressOrRange_it); } +LCRYPTO_ALIAS(IPAddressOrRange_new); void IPAddressOrRange_free(IPAddressOrRange *a) { ASN1_item_free((ASN1_VALUE *)a, &IPAddressOrRange_it); } +LCRYPTO_ALIAS(IPAddressOrRange_free); IPAddressChoice * d2i_IPAddressChoice(IPAddressChoice **a, const unsigned char **in, long len) @@ -265,24 +273,28 @@ d2i_IPAddressChoice(IPAddressChoice **a, const unsigned char **in, long len) return (IPAddressChoice *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &IPAddressChoice_it); } +LCRYPTO_ALIAS(d2i_IPAddressChoice); int i2d_IPAddressChoice(IPAddressChoice *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &IPAddressChoice_it); } +LCRYPTO_ALIAS(i2d_IPAddressChoice); IPAddressChoice * IPAddressChoice_new(void) { return (IPAddressChoice *)ASN1_item_new(&IPAddressChoice_it); } +LCRYPTO_ALIAS(IPAddressChoice_new); void IPAddressChoice_free(IPAddressChoice *a) { ASN1_item_free((ASN1_VALUE *)a, &IPAddressChoice_it); } +LCRYPTO_ALIAS(IPAddressChoice_free); IPAddressFamily * d2i_IPAddressFamily(IPAddressFamily **a, const unsigned char **in, long len) @@ -290,24 +302,28 @@ d2i_IPAddressFamily(IPAddressFamily **a, const unsigned char **in, long len) return (IPAddressFamily *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &IPAddressFamily_it); } +LCRYPTO_ALIAS(d2i_IPAddressFamily); int i2d_IPAddressFamily(IPAddressFamily *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &IPAddressFamily_it); } +LCRYPTO_ALIAS(i2d_IPAddressFamily); IPAddressFamily * IPAddressFamily_new(void) { return (IPAddressFamily *)ASN1_item_new(&IPAddressFamily_it); } +LCRYPTO_ALIAS(IPAddressFamily_new); void IPAddressFamily_free(IPAddressFamily *a) { ASN1_item_free((ASN1_VALUE *)a, &IPAddressFamily_it); } +LCRYPTO_ALIAS(IPAddressFamily_free); /* * Convenience accessors for IPAddressFamily. @@ -518,6 +534,7 @@ X509v3_addr_get_afi(const IPAddressFamily *af) return afi; } +LCRYPTO_ALIAS(X509v3_addr_get_afi); /* * Expand the bitstring form (RFC 3779, section 2.1.2) of an address into @@ -1093,6 +1110,7 @@ X509v3_addr_add_inherit(IPAddrBlocks *addr, const unsigned afi, return IPAddressFamily_set_inheritance(af); } +LCRYPTO_ALIAS(X509v3_addr_add_inherit); /* * Construct an IPAddressOrRange sequence, or return an existing one. @@ -1156,6 +1174,7 @@ X509v3_addr_add_prefix(IPAddrBlocks *addr, const unsigned afi, return 1; } +LCRYPTO_ALIAS(X509v3_addr_add_prefix); /* * Add a range. @@ -1183,6 +1202,7 @@ X509v3_addr_add_range(IPAddrBlocks *addr, const unsigned afi, return 1; } +LCRYPTO_ALIAS(X509v3_addr_add_range); static int extract_min_max_bitstr(IPAddressOrRange *aor, ASN1_BIT_STRING **out_min, @@ -1242,6 +1262,7 @@ X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, return afi_len; } +LCRYPTO_ALIAS(X509v3_addr_get_range); /* * Check whether an IPAddrBLocks is in canonical form. @@ -1360,6 +1381,7 @@ X509v3_addr_is_canonical(IPAddrBlocks *addr) */ return 1; } +LCRYPTO_ALIAS(X509v3_addr_is_canonical); /* * Whack an IPAddressOrRanges into canonical form. @@ -1466,6 +1488,7 @@ X509v3_addr_canonize(IPAddrBlocks *addr) return X509v3_addr_is_canonical(addr); } +LCRYPTO_ALIAS(X509v3_addr_canonize); /* * v2i handler for the IPAddrBlocks extension. @@ -1709,6 +1732,7 @@ X509v3_addr_inherits(IPAddrBlocks *addr) return 0; } +LCRYPTO_ALIAS(X509v3_addr_inherits); /* * Figure out whether parent contains child. @@ -1792,6 +1816,7 @@ X509v3_addr_subset(IPAddrBlocks *child, IPAddrBlocks *parent) } return 1; } +LCRYPTO_ALIAS(X509v3_addr_subset); static int verify_error(X509_STORE_CTX *ctx, X509 *cert, int error, int depth) @@ -1997,6 +2022,7 @@ X509v3_addr_validate_path(X509_STORE_CTX *ctx) } return addr_validate_path_internal(ctx, ctx->chain, NULL); } +LCRYPTO_ALIAS(X509v3_addr_validate_path); /* * RFC 3779 2.3 path validation of an extension. @@ -2014,5 +2040,6 @@ X509v3_addr_validate_resource_set(STACK_OF(X509) *chain, IPAddrBlocks *ext, return 0; return addr_validate_path_internal(NULL, chain, ext); } +LCRYPTO_ALIAS(X509v3_addr_validate_resource_set); #endif /* OPENSSL_NO_RFC3779 */ diff --git a/crypto/x509/x509_akeya.c b/crypto/x509/x509_akeya.c index aba8923c..52eca42c 100644 --- a/crypto/x509/x509_akeya.c +++ b/crypto/x509/x509_akeya.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_akeya.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ +/* $OpenBSD: x509_akeya.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -104,21 +104,25 @@ d2i_AUTHORITY_KEYID(AUTHORITY_KEYID **a, const unsigned char **in, long len) return (AUTHORITY_KEYID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &AUTHORITY_KEYID_it); } +LCRYPTO_ALIAS(d2i_AUTHORITY_KEYID); int i2d_AUTHORITY_KEYID(AUTHORITY_KEYID *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &AUTHORITY_KEYID_it); } +LCRYPTO_ALIAS(i2d_AUTHORITY_KEYID); AUTHORITY_KEYID * AUTHORITY_KEYID_new(void) { return (AUTHORITY_KEYID *)ASN1_item_new(&AUTHORITY_KEYID_it); } +LCRYPTO_ALIAS(AUTHORITY_KEYID_new); void AUTHORITY_KEYID_free(AUTHORITY_KEYID *a) { ASN1_item_free((ASN1_VALUE *)a, &AUTHORITY_KEYID_it); } +LCRYPTO_ALIAS(AUTHORITY_KEYID_free); diff --git a/crypto/x509/x509_alt.c b/crypto/x509/x509_alt.c index 8656df82..c4c5fcab 100644 --- a/crypto/x509/x509_alt.c +++ b/crypto/x509/x509_alt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_alt.c,v 1.12 2022/03/26 16:34:21 tb Exp $ */ +/* $OpenBSD: x509_alt.c,v 1.15 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -152,6 +152,7 @@ i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, GENERAL_NAMES *gens, return NULL; } +LCRYPTO_ALIAS(i2v_GENERAL_NAMES); STACK_OF(CONF_VALUE) * i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, @@ -244,6 +245,7 @@ i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, GENERAL_NAME *gen, return NULL; } +LCRYPTO_ALIAS(i2v_GENERAL_NAME); int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen) @@ -310,6 +312,7 @@ GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen) } return 1; } +LCRYPTO_ALIAS(GENERAL_NAME_print); static GENERAL_NAMES * v2i_issuer_alt(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, @@ -512,6 +515,7 @@ v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); return NULL; } +LCRYPTO_ALIAS(v2i_GENERAL_NAMES); GENERAL_NAME * v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, @@ -519,6 +523,7 @@ v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, { return v2i_GENERAL_NAME_ex(NULL, method, ctx, cnf, 0); } +LCRYPTO_ALIAS(v2i_GENERAL_NAME); GENERAL_NAME * a2i_GENERAL_NAME(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, @@ -609,6 +614,7 @@ a2i_GENERAL_NAME(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, GENERAL_NAME_free(gen); return NULL; } +LCRYPTO_ALIAS(a2i_GENERAL_NAME); GENERAL_NAME * v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, @@ -619,6 +625,7 @@ v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, GENERAL_NAME *ret; size_t len = 0; int type; + CBS cbs; name = cnf->name; value = cnf->value; @@ -669,9 +676,10 @@ v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, } type = x509_constraints_general_to_bytes(ret, &bytes, &len); + CBS_init(&cbs, bytes, len); switch (type) { case GEN_DNS: - if (!x509_constraints_valid_sandns(bytes, len)) { + if (!x509_constraints_valid_sandns(&cbs)) { X509V3error(X509V3_R_BAD_OBJECT); ERR_asprintf_error_data("name=%s value='%.*s'", name, (int)len, bytes); @@ -687,7 +695,7 @@ v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, } break; case GEN_EMAIL: - if (!x509_constraints_parse_mailbox(bytes, len, NULL)) { + if (!x509_constraints_parse_mailbox(&cbs, NULL)) { X509V3error(X509V3_R_BAD_OBJECT); ERR_asprintf_error_data("name=%s value='%.*s'", name, (int)len, bytes); @@ -710,6 +718,7 @@ v2i_GENERAL_NAME_ex(GENERAL_NAME *out, const X509V3_EXT_METHOD *method, GENERAL_NAME_free(ret); return NULL; } +LCRYPTO_ALIAS(v2i_GENERAL_NAME_ex); static int do_othername(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx) diff --git a/crypto/x509/x509_asid.c b/crypto/x509/x509_asid.c index 6c73018b..cc36cc1a 100644 --- a/crypto/x509/x509_asid.c +++ b/crypto/x509/x509_asid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_asid.c,v 1.35 2022/07/30 17:50:17 tb Exp $ */ +/* $OpenBSD: x509_asid.c,v 1.39 2023/02/16 08:38:17 tb Exp $ */ /* * Contributed to the OpenSSL Project by the American Registry for * Internet Numbers ("ARIN"). @@ -73,7 +73,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" #ifndef OPENSSL_NO_RFC3779 @@ -191,24 +191,28 @@ d2i_ASRange(ASRange **a, const unsigned char **in, long len) return (ASRange *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &ASRange_it); } +LCRYPTO_ALIAS(d2i_ASRange); int i2d_ASRange(ASRange *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASRange_it); } +LCRYPTO_ALIAS(i2d_ASRange); ASRange * ASRange_new(void) { return (ASRange *)ASN1_item_new(&ASRange_it); } +LCRYPTO_ALIAS(ASRange_new); void ASRange_free(ASRange *a) { ASN1_item_free((ASN1_VALUE *)a, &ASRange_it); } +LCRYPTO_ALIAS(ASRange_free); ASIdOrRange * d2i_ASIdOrRange(ASIdOrRange **a, const unsigned char **in, long len) @@ -216,24 +220,28 @@ d2i_ASIdOrRange(ASIdOrRange **a, const unsigned char **in, long len) return (ASIdOrRange *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &ASIdOrRange_it); } +LCRYPTO_ALIAS(d2i_ASIdOrRange); int i2d_ASIdOrRange(ASIdOrRange *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASIdOrRange_it); } +LCRYPTO_ALIAS(i2d_ASIdOrRange); ASIdOrRange * ASIdOrRange_new(void) { return (ASIdOrRange *)ASN1_item_new(&ASIdOrRange_it); } +LCRYPTO_ALIAS(ASIdOrRange_new); void ASIdOrRange_free(ASIdOrRange *a) { ASN1_item_free((ASN1_VALUE *)a, &ASIdOrRange_it); } +LCRYPTO_ALIAS(ASIdOrRange_free); ASIdentifierChoice * d2i_ASIdentifierChoice(ASIdentifierChoice **a, const unsigned char **in, @@ -242,24 +250,28 @@ d2i_ASIdentifierChoice(ASIdentifierChoice **a, const unsigned char **in, return (ASIdentifierChoice *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &ASIdentifierChoice_it); } +LCRYPTO_ALIAS(d2i_ASIdentifierChoice); int i2d_ASIdentifierChoice(ASIdentifierChoice *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASIdentifierChoice_it); } +LCRYPTO_ALIAS(i2d_ASIdentifierChoice); ASIdentifierChoice * ASIdentifierChoice_new(void) { return (ASIdentifierChoice *)ASN1_item_new(&ASIdentifierChoice_it); } +LCRYPTO_ALIAS(ASIdentifierChoice_new); void ASIdentifierChoice_free(ASIdentifierChoice *a) { ASN1_item_free((ASN1_VALUE *)a, &ASIdentifierChoice_it); } +LCRYPTO_ALIAS(ASIdentifierChoice_free); ASIdentifiers * d2i_ASIdentifiers(ASIdentifiers **a, const unsigned char **in, long len) @@ -267,24 +279,28 @@ d2i_ASIdentifiers(ASIdentifiers **a, const unsigned char **in, long len) return (ASIdentifiers *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &ASIdentifiers_it); } +LCRYPTO_ALIAS(d2i_ASIdentifiers); int i2d_ASIdentifiers(ASIdentifiers *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &ASIdentifiers_it); } +LCRYPTO_ALIAS(i2d_ASIdentifiers); ASIdentifiers * ASIdentifiers_new(void) { return (ASIdentifiers *)ASN1_item_new(&ASIdentifiers_it); } +LCRYPTO_ALIAS(ASIdentifiers_new); void ASIdentifiers_free(ASIdentifiers *a) { ASN1_item_free((ASN1_VALUE *)a, &ASIdentifiers_it); } +LCRYPTO_ALIAS(ASIdentifiers_free); /* * i2r method for an ASIdentifierChoice. @@ -412,6 +428,7 @@ X509v3_asid_add_inherit(ASIdentifiers *asid, int which) } return (*choice)->type == ASIdentifierChoice_inherit; } +LCRYPTO_ALIAS(X509v3_asid_add_inherit); /* * Add an ID or range to an ASIdentifierChoice. @@ -466,6 +483,7 @@ X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which, ASN1_INTEGER *min, ASIdOrRange_free(aor); return 0; } +LCRYPTO_ALIAS(X509v3_asid_add_id_or_range); /* * Extract min and max values from an ASIdOrRange. @@ -562,8 +580,8 @@ ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice) } /* - * Check for inverted range. - */ + * Check for inverted range. + */ i = sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1; { ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, @@ -594,6 +612,7 @@ X509v3_asid_is_canonical(ASIdentifiers *asid) (ASIdentifierChoice_is_canonical(asid->asnum) && ASIdentifierChoice_is_canonical(asid->rdi))); } +LCRYPTO_ALIAS(X509v3_asid_is_canonical); /* * Whack an ASIdentifierChoice into canonical form. @@ -761,6 +780,7 @@ X509v3_asid_canonize(ASIdentifiers *asid) return ASIdentifierChoice_canonize(asid->rdi); } +LCRYPTO_ALIAS(X509v3_asid_canonize); /* * v2i method for an ASIdentifier extension. @@ -919,6 +939,7 @@ X509v3_asid_inherits(ASIdentifiers *asid) return 0; } +LCRYPTO_ALIAS(X509v3_asid_inherits); /* * Figure out whether parent contains child. @@ -992,6 +1013,7 @@ X509v3_asid_subset(ASIdentifiers *child, ASIdentifiers *parent) return 1; } +LCRYPTO_ALIAS(X509v3_asid_subset); /* * Validation error handling via callback. @@ -1159,6 +1181,7 @@ X509v3_asid_validate_path(X509_STORE_CTX *ctx) } return asid_validate_path_internal(ctx, ctx->chain, NULL); } +LCRYPTO_ALIAS(X509v3_asid_validate_path); /* * RFC 3779 3.3 path validation of an extension. @@ -1176,5 +1199,6 @@ X509v3_asid_validate_resource_set(STACK_OF(X509) *chain, ASIdentifiers *ext, return 0; return asid_validate_path_internal(NULL, chain, ext); } +LCRYPTO_ALIAS(X509v3_asid_validate_resource_set); #endif /* OPENSSL_NO_RFC3779 */ diff --git a/crypto/x509/x509_att.c b/crypto/x509/x509_att.c index 8d369df9..0c9d55f7 100644 --- a/crypto/x509/x509_att.c +++ b/crypto/x509/x509_att.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_att.c,v 1.19 2022/05/09 19:19:33 jsing Exp $ */ +/* $OpenBSD: x509_att.c,v 1.22 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,13 +66,14 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x) { return sk_X509_ATTRIBUTE_num(x); } +LCRYPTO_ALIAS(X509at_get_attr_count); int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, int lastpos) @@ -84,6 +85,7 @@ X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, int lastpos) return (-2); return (X509at_get_attr_by_OBJ(x, obj, lastpos)); } +LCRYPTO_ALIAS(X509at_get_attr_by_NID); int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, @@ -105,6 +107,7 @@ X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, } return (-1); } +LCRYPTO_ALIAS(X509at_get_attr_by_OBJ); X509_ATTRIBUTE * X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc) @@ -114,6 +117,7 @@ X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc) else return sk_X509_ATTRIBUTE_value(x, loc); } +LCRYPTO_ALIAS(X509at_get_attr); X509_ATTRIBUTE * X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc) @@ -125,6 +129,7 @@ X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc) ret = sk_X509_ATTRIBUTE_delete(x, loc); return (ret); } +LCRYPTO_ALIAS(X509at_delete_attr); STACK_OF(X509_ATTRIBUTE) * X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, X509_ATTRIBUTE *attr) @@ -160,6 +165,7 @@ X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, X509_ATTRIBUTE *attr) sk_X509_ATTRIBUTE_free(sk); return (NULL); } +LCRYPTO_ALIAS(X509at_add1_attr); STACK_OF(X509_ATTRIBUTE) * X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, const ASN1_OBJECT *obj, @@ -175,6 +181,7 @@ X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) **x, const ASN1_OBJECT *obj, X509_ATTRIBUTE_free(attr); return ret; } +LCRYPTO_ALIAS(X509at_add1_attr_by_OBJ); STACK_OF(X509_ATTRIBUTE) * X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, int nid, int type, @@ -190,6 +197,7 @@ X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) **x, int nid, int type, X509_ATTRIBUTE_free(attr); return ret; } +LCRYPTO_ALIAS(X509at_add1_attr_by_NID); STACK_OF(X509_ATTRIBUTE) * X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, const char *attrname, @@ -205,6 +213,7 @@ X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) **x, const char *attrname, X509_ATTRIBUTE_free(attr); return ret; } +LCRYPTO_ALIAS(X509at_add1_attr_by_txt); void * X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, const ASN1_OBJECT *obj, @@ -223,6 +232,7 @@ X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, const ASN1_OBJECT *obj, return NULL; return X509_ATTRIBUTE_get0_data(at, 0, type, NULL); } +LCRYPTO_ALIAS(X509at_get0_data_by_OBJ); X509_ATTRIBUTE * X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, int atrtype, @@ -241,6 +251,7 @@ X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, int atrtype, ASN1_OBJECT_free(obj); return (ret); } +LCRYPTO_ALIAS(X509_ATTRIBUTE_create_by_NID); X509_ATTRIBUTE * X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, const ASN1_OBJECT *obj, @@ -270,6 +281,7 @@ X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, const ASN1_OBJECT *obj, X509_ATTRIBUTE_free(ret); return (NULL); } +LCRYPTO_ALIAS(X509_ATTRIBUTE_create_by_OBJ); X509_ATTRIBUTE * X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, const char *atrname, @@ -288,6 +300,7 @@ X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, const char *atrname, ASN1_OBJECT_free(obj); return nattr; } +LCRYPTO_ALIAS(X509_ATTRIBUTE_create_by_txt); int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj) @@ -298,6 +311,7 @@ X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj) attr->object = OBJ_dup(obj); return attr->object != NULL; } +LCRYPTO_ALIAS(X509_ATTRIBUTE_set1_object); int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, @@ -351,6 +365,7 @@ X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, X509error(ERR_R_MALLOC_FAILURE); return 0; } +LCRYPTO_ALIAS(X509_ATTRIBUTE_set1_data); int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr) @@ -360,6 +375,7 @@ X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr) return sk_ASN1_TYPE_num(attr->set); } +LCRYPTO_ALIAS(X509_ATTRIBUTE_count); ASN1_OBJECT * X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr) @@ -368,6 +384,7 @@ X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr) return (NULL); return (attr->object); } +LCRYPTO_ALIAS(X509_ATTRIBUTE_get0_object); void * X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype, void *data) @@ -383,6 +400,7 @@ X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype, void *data) } return ttmp->value.ptr; } +LCRYPTO_ALIAS(X509_ATTRIBUTE_get0_data); ASN1_TYPE * X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx) @@ -392,3 +410,4 @@ X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx) return sk_ASN1_TYPE_value(attr->set, idx); } +LCRYPTO_ALIAS(X509_ATTRIBUTE_get0_type); diff --git a/crypto/x509/x509_bcons.c b/crypto/x509/x509_bcons.c index 48ce7d60..a39ae0aa 100644 --- a/crypto/x509/x509_bcons.c +++ b/crypto/x509/x509_bcons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_bcons.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ +/* $OpenBSD: x509_bcons.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -121,24 +121,28 @@ d2i_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS **a, const unsigned char **in, long len) return (BASIC_CONSTRAINTS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &BASIC_CONSTRAINTS_it); } +LCRYPTO_ALIAS(d2i_BASIC_CONSTRAINTS); int i2d_BASIC_CONSTRAINTS(BASIC_CONSTRAINTS *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &BASIC_CONSTRAINTS_it); } +LCRYPTO_ALIAS(i2d_BASIC_CONSTRAINTS); BASIC_CONSTRAINTS * BASIC_CONSTRAINTS_new(void) { return (BASIC_CONSTRAINTS *)ASN1_item_new(&BASIC_CONSTRAINTS_it); } +LCRYPTO_ALIAS(BASIC_CONSTRAINTS_new); void BASIC_CONSTRAINTS_free(BASIC_CONSTRAINTS *a) { ASN1_item_free((ASN1_VALUE *)a, &BASIC_CONSTRAINTS_it); } +LCRYPTO_ALIAS(BASIC_CONSTRAINTS_free); static STACK_OF(CONF_VALUE) * diff --git a/crypto/x509/x509_bitst.c b/crypto/x509/x509_bitst.c index 3d998188..cacbe8ef 100644 --- a/crypto/x509/x509_bitst.c +++ b/crypto/x509/x509_bitst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_bitst.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ +/* $OpenBSD: x509_bitst.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -148,6 +148,7 @@ i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, ASN1_BIT_STRING *bits, return NULL; } +LCRYPTO_ALIAS(i2v_ASN1_BIT_STRING); ASN1_BIT_STRING * v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, @@ -185,3 +186,4 @@ v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, } return bs; } +LCRYPTO_ALIAS(v2i_ASN1_BIT_STRING); diff --git a/crypto/x509/x509_cmp.c b/crypto/x509/x509_cmp.c index 4fd8d78f..3ee4fd4a 100644 --- a/crypto/x509/x509_cmp.c +++ b/crypto/x509/x509_cmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_cmp.c,v 1.39 2022/02/24 22:05:06 beck Exp $ */ +/* $OpenBSD: x509_cmp.c,v 1.42 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -68,8 +68,8 @@ #include #include -#include "evp_locl.h" -#include "x509_lcl.h" +#include "evp_local.h" +#include "x509_local.h" int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b) @@ -84,6 +84,7 @@ X509_issuer_and_serial_cmp(const X509 *a, const X509 *b) return (i); return (X509_NAME_cmp(ai->issuer, bi->issuer)); } +LCRYPTO_ALIAS(X509_issuer_and_serial_cmp); #ifndef OPENSSL_NO_MD5 unsigned long @@ -119,6 +120,7 @@ X509_issuer_and_serial_hash(X509 *a) free(f); return (ret); } +LCRYPTO_ALIAS(X509_issuer_and_serial_hash); #endif int @@ -126,18 +128,21 @@ X509_issuer_name_cmp(const X509 *a, const X509 *b) { return (X509_NAME_cmp(a->cert_info->issuer, b->cert_info->issuer)); } +LCRYPTO_ALIAS(X509_issuer_name_cmp); int X509_subject_name_cmp(const X509 *a, const X509 *b) { return (X509_NAME_cmp(a->cert_info->subject, b->cert_info->subject)); } +LCRYPTO_ALIAS(X509_subject_name_cmp); int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b) { return (X509_NAME_cmp(a->crl->issuer, b->crl->issuer)); } +LCRYPTO_ALIAS(X509_CRL_cmp); #ifndef OPENSSL_NO_SHA int @@ -145,6 +150,7 @@ X509_CRL_match(const X509_CRL *a, const X509_CRL *b) { return memcmp(a->hash, b->hash, X509_CRL_HASH_LEN); } +LCRYPTO_ALIAS(X509_CRL_match); #endif X509_NAME * @@ -152,12 +158,14 @@ X509_get_issuer_name(const X509 *a) { return (a->cert_info->issuer); } +LCRYPTO_ALIAS(X509_get_issuer_name); unsigned long X509_issuer_name_hash(X509 *x) { return (X509_NAME_hash(x->cert_info->issuer)); } +LCRYPTO_ALIAS(X509_issuer_name_hash); #ifndef OPENSSL_NO_MD5 unsigned long @@ -165,6 +173,7 @@ X509_issuer_name_hash_old(X509 *x) { return (X509_NAME_hash_old(x->cert_info->issuer)); } +LCRYPTO_ALIAS(X509_issuer_name_hash_old); #endif X509_NAME * @@ -172,24 +181,28 @@ X509_get_subject_name(const X509 *a) { return (a->cert_info->subject); } +LCRYPTO_ALIAS(X509_get_subject_name); ASN1_INTEGER * X509_get_serialNumber(X509 *a) { return (a->cert_info->serialNumber); } +LCRYPTO_ALIAS(X509_get_serialNumber); const ASN1_INTEGER * X509_get0_serialNumber(const X509 *a) { return (a->cert_info->serialNumber); } +LCRYPTO_ALIAS(X509_get0_serialNumber); unsigned long X509_subject_name_hash(X509 *x) { return (X509_NAME_hash(x->cert_info->subject)); } +LCRYPTO_ALIAS(X509_subject_name_hash); #ifndef OPENSSL_NO_MD5 unsigned long @@ -197,6 +210,7 @@ X509_subject_name_hash_old(X509 *x) { return (X509_NAME_hash_old(x->cert_info->subject)); } +LCRYPTO_ALIAS(X509_subject_name_hash_old); #endif #ifndef OPENSSL_NO_SHA @@ -218,6 +232,7 @@ X509_cmp(const X509 *a, const X509 *b) return memcmp(a->hash, b->hash, X509_CERT_HASH_LEN); } +LCRYPTO_ALIAS(X509_cmp); #endif int @@ -241,6 +256,7 @@ X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b) return ret; return memcmp(a->canon_enc, b->canon_enc, a->canon_enclen); } +LCRYPTO_ALIAS(X509_NAME_cmp); unsigned long X509_NAME_hash(X509_NAME *x) @@ -259,6 +275,7 @@ X509_NAME_hash(X509_NAME *x) 0xffffffffL; return (ret); } +LCRYPTO_ALIAS(X509_NAME_hash); #ifndef OPENSSL_NO_MD5 @@ -287,6 +304,7 @@ X509_NAME_hash_old(X509_NAME *x) return (ret); } +LCRYPTO_ALIAS(X509_NAME_hash_old); #endif /* Search a stack of X509 for a match */ @@ -312,6 +330,7 @@ X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name, } return (NULL); } +LCRYPTO_ALIAS(X509_find_by_issuer_and_serial); X509 * X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name) @@ -326,6 +345,7 @@ X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name) } return (NULL); } +LCRYPTO_ALIAS(X509_find_by_subject); EVP_PKEY * X509_get_pubkey(X509 *x) @@ -334,6 +354,7 @@ X509_get_pubkey(X509 *x) return (NULL); return (X509_PUBKEY_get(x->cert_info->key)); } +LCRYPTO_ALIAS(X509_get_pubkey); EVP_PKEY * X509_get0_pubkey(const X509 *x) @@ -342,6 +363,7 @@ X509_get0_pubkey(const X509 *x) return (NULL); return (X509_PUBKEY_get0(x->cert_info->key)); } +LCRYPTO_ALIAS(X509_get0_pubkey); ASN1_BIT_STRING * X509_get0_pubkey_bitstr(const X509 *x) @@ -350,6 +372,7 @@ X509_get0_pubkey_bitstr(const X509 *x) return NULL; return x->cert_info->key->public_key; } +LCRYPTO_ALIAS(X509_get0_pubkey_bitstr); int X509_check_private_key(const X509 *x, const EVP_PKEY *k) @@ -380,6 +403,7 @@ X509_check_private_key(const X509 *x, const EVP_PKEY *k) return 1; return 0; } +LCRYPTO_ALIAS(X509_check_private_key); /* * Not strictly speaking an "up_ref" as a STACK doesn't have a reference @@ -398,3 +422,4 @@ X509_chain_up_ref(STACK_OF(X509) *chain) return ret; } +LCRYPTO_ALIAS(X509_chain_up_ref); diff --git a/crypto/x509/x509_conf.c b/crypto/x509/x509_conf.c index cd703fc1..189bf644 100644 --- a/crypto/x509/x509_conf.c +++ b/crypto/x509/x509_conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_conf.c,v 1.2 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509_conf.c,v 1.5 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -66,7 +66,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static int v3_check_critical(const char **value); static int v3_check_generic(const char **value); @@ -104,6 +104,7 @@ X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name, } return ret; } +LCRYPTO_ALIAS(X509V3_EXT_nconf); /* CONF *conf: Config file */ /* char *value: Value */ @@ -120,6 +121,7 @@ X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, value, crit, ext_type, ctx); return do_ext_nconf(conf, ctx, ext_nid, crit, value); } +LCRYPTO_ALIAS(X509V3_EXT_nconf_nid); /* CONF *conf: Config file */ /* char *value: Value */ @@ -238,6 +240,7 @@ X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc) } return do_ext_i2d(method, ext_nid, crit, ext_struc); } +LCRYPTO_ALIAS(X509V3_EXT_i2d); /* Check the extension string for critical flag */ static int @@ -364,6 +367,7 @@ X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section, } return 1; } +LCRYPTO_ALIAS(X509V3_EXT_add_nconf_sk); /* Convenience functions to add extensions to a certificate, CRL and request */ @@ -377,6 +381,7 @@ X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, sk = &cert->cert_info->extensions; return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk); } +LCRYPTO_ALIAS(X509V3_EXT_add_nconf); /* Same as above but for a CRL */ @@ -390,6 +395,7 @@ X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, sk = &crl->crl->extensions; return X509V3_EXT_add_nconf_sk(conf, ctx, section, sk); } +LCRYPTO_ALIAS(X509V3_EXT_CRL_add_nconf); /* Add extensions to certificate request */ @@ -409,6 +415,7 @@ X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, sk_X509_EXTENSION_pop_free(extlist, X509_EXTENSION_free); return i; } +LCRYPTO_ALIAS(X509V3_EXT_REQ_add_nconf); /* Config database functions */ @@ -421,6 +428,7 @@ X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section) } return ctx->db_meth->get_string(ctx->db, name, section); } +LCRYPTO_ALIAS(X509V3_get_string); STACK_OF(CONF_VALUE) * X509V3_get_section(X509V3_CTX *ctx, const char *section) @@ -431,6 +439,7 @@ X509V3_get_section(X509V3_CTX *ctx, const char *section) } return ctx->db_meth->get_section(ctx->db, section); } +LCRYPTO_ALIAS(X509V3_get_section); void X509V3_string_free(X509V3_CTX *ctx, char *str) @@ -440,6 +449,7 @@ X509V3_string_free(X509V3_CTX *ctx, char *str) if (ctx->db_meth->free_string) ctx->db_meth->free_string(ctx->db, str); } +LCRYPTO_ALIAS(X509V3_string_free); void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section) @@ -449,6 +459,7 @@ X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section) if (ctx->db_meth->free_section) ctx->db_meth->free_section(ctx->db, section); } +LCRYPTO_ALIAS(X509V3_section_free); static char * nconf_get_string(void *db, const char *section, const char *value) @@ -475,6 +486,7 @@ X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf) ctx->db_meth = &nconf_method; ctx->db = conf; } +LCRYPTO_ALIAS(X509V3_set_nconf); void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req, @@ -486,6 +498,7 @@ X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subj, X509_REQ *req, ctx->subject_req = req; ctx->flags = flags; } +LCRYPTO_ALIAS(X509V3_set_ctx); /* Old conf compatibility functions */ @@ -498,6 +511,7 @@ X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, const char *name, CONF_set_nconf(&ctmp, conf); return X509V3_EXT_nconf(&ctmp, ctx, name, value); } +LCRYPTO_ALIAS(X509V3_EXT_conf); /* LHASH *conf: Config file */ /* char *value: Value */ @@ -510,6 +524,7 @@ X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, int ext_nid, CONF_set_nconf(&ctmp, conf); return X509V3_EXT_nconf_nid(&ctmp, ctx, ext_nid, value); } +LCRYPTO_ALIAS(X509V3_EXT_conf_nid); static char * conf_lhash_get_string(void *db, const char *section, const char *value) @@ -536,6 +551,7 @@ X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash) ctx->db_meth = &conf_lhash_method; ctx->db = lhash; } +LCRYPTO_ALIAS(X509V3_set_conf_lhash); int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, @@ -546,6 +562,7 @@ X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, CONF_set_nconf(&ctmp, conf); return X509V3_EXT_add_nconf(&ctmp, ctx, section, cert); } +LCRYPTO_ALIAS(X509V3_EXT_add_conf); /* Same as above but for a CRL */ @@ -558,6 +575,7 @@ X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, CONF_set_nconf(&ctmp, conf); return X509V3_EXT_CRL_add_nconf(&ctmp, ctx, section, crl); } +LCRYPTO_ALIAS(X509V3_EXT_CRL_add_conf); /* Add extensions to certificate request */ @@ -570,3 +588,4 @@ X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, CONF_set_nconf(&ctmp, conf); return X509V3_EXT_REQ_add_nconf(&ctmp, ctx, section, req); } +LCRYPTO_ALIAS(X509V3_EXT_REQ_add_conf); diff --git a/crypto/x509/x509_constraints.c b/crypto/x509/x509_constraints.c index 8cd8413d..346cab0a 100644 --- a/crypto/x509/x509_constraints.c +++ b/crypto/x509/x509_constraints.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_constraints.c,v 1.28 2022/06/27 15:03:11 beck Exp $ */ +/* $OpenBSD: x509_constraints.c,v 1.31 2022/12/26 07:18:53 jmc Exp $ */ /* * Copyright (c) 2020 Bob Beck * @@ -29,11 +29,33 @@ #include #include +#include "bytestring.h" #include "x509_internal.h" /* RFC 2821 section 4.5.3.1 */ -#define LOCAL_PART_MAX_LEN 64 -#define DOMAIN_PART_MAX_LEN 255 +#define LOCAL_PART_MAX_LEN (size_t)64 +#define DOMAIN_PART_MAX_LEN (size_t)255 +#define MAX_IP_ADDRESS_LENGTH (size_t)46 + +static int +cbs_is_ip_address(CBS *cbs) +{ + struct sockaddr_in6 sin6; + struct sockaddr_in sin4; + char *name = NULL; + int ret = 0; + + if (CBS_len(cbs) > MAX_IP_ADDRESS_LENGTH) + return 0; + if (!CBS_strdup(cbs, &name)) + return 0; + if (inet_pton(AF_INET, name, &sin4) == 1 || + inet_pton(AF_INET6, name, &sin6) == 1) + ret = 1; + + free(name); + return ret; +} struct x509_constraints_name * x509_constraints_name_new(void) @@ -165,31 +187,34 @@ x509_constraints_names_dup(struct x509_constraints_names *names) return NULL; } - /* * Validate that the name contains only a hostname consisting of RFC * 5890 compliant A-labels (see RFC 6066 section 3). This is more * permissive to allow for a leading '.' for a subdomain based * constraint, as well as allowing for '_' which is commonly accepted - * by nonconformant DNS implementaitons. + * by nonconformant DNS implementations. * * if "wildcards" is set it allows '*' to occur in the string at the end of a * component. */ static int -x509_constraints_valid_domain_internal(uint8_t *name, size_t len, int wildcards) +x509_constraints_valid_domain_internal(CBS *cbs, int wildcards) { + int first, component = 0; uint8_t prev, c = 0; - int component = 0; - int first; - size_t i; + size_t i, len; + CBS copy; + + CBS_dup(cbs, ©); + + len = CBS_len(cbs); if (len > DOMAIN_PART_MAX_LEN) return 0; - for (i = 0; i < len; i++) { prev = c; - c = name[i]; + if (!CBS_get_u8(©, &c)) + return 0; first = (i == 0); @@ -234,61 +259,42 @@ x509_constraints_valid_domain_internal(uint8_t *name, size_t len, int wildcards) if (++component > 63) return 0; } + return 1; } int -x509_constraints_valid_domain(uint8_t *name, size_t len) +x509_constraints_valid_host(CBS *cbs) { - if (len == 0) - return 0; - /* - * A domain may not be less than two characters, so you can't - * have a require subdomain name with less than that. - */ - if (len < 3 && name[0] == '.') - return 0; - return x509_constraints_valid_domain_internal(name, len, 0); -} + uint8_t first; -int -x509_constraints_valid_host(uint8_t *name, size_t len) -{ - struct sockaddr_in sin4; - struct sockaddr_in6 sin6; - - if (len == 0) - return 0; - if (name[0] == '.') /* leading . not allowed in a host name*/ + if (!CBS_peek_u8(cbs, &first)) return 0; - if (inet_pton(AF_INET, name, &sin4) == 1) + if (first == '.') + return 0; /* leading . not allowed in a host name */ + if (cbs_is_ip_address(cbs)) return 0; - if (inet_pton(AF_INET6, name, &sin6) == 1) - return 0; - return x509_constraints_valid_domain_internal(name, len, 0); + + return x509_constraints_valid_domain_internal(cbs, 0); } int -x509_constraints_valid_sandns(uint8_t *name, size_t len) +x509_constraints_valid_sandns(CBS *cbs) { - if (len == 0) - return 0; + uint8_t first; - if (name[0] == '.') /* leading . not allowed in a SAN DNS name */ + if (!CBS_peek_u8(cbs, &first)) return 0; + if (first == '.') + return 0; /* leading . not allowed in a SAN DNS name */ /* * A domain may not be less than two characters, so you * can't wildcard a single domain of less than that */ - if (len < 4 && name[0] == '*') - return 0; - /* - * A wildcard may only be followed by a '.' - */ - if (len >= 4 && name[0] == '*' && name[1] != '.') + if (CBS_len(cbs) < 4 && first == '*') return 0; - return x509_constraints_valid_domain_internal(name, len, 1); + return x509_constraints_valid_domain_internal(cbs, 1); } static inline int @@ -297,7 +303,7 @@ local_part_ok(char c) return (('0' <= c && c <= '9') || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '!' || c == '#' || c == '$' || c == '%' || c == '&' || c == '\'' || c == '*' || c == '+' || - c == '-' || c == '/' || c == '=' || c == '?' || c == '^' || + c == '-' || c == '/' || c == '=' || c == '?' || c == '^' || c == '_' || c == '`' || c == '{' || c == '|' || c == '}' || c == '~' || c == '.'); } @@ -309,25 +315,35 @@ local_part_ok(char c) * local and domain parts of the mailbox to "name->local" and name->name" */ int -x509_constraints_parse_mailbox(uint8_t *candidate, size_t len, +x509_constraints_parse_mailbox(CBS *candidate, struct x509_constraints_name *name) { char working[DOMAIN_PART_MAX_LEN + 1] = { 0 }; char *candidate_local = NULL; char *candidate_domain = NULL; - size_t i, wi = 0; + CBS domain_cbs; + size_t i, len, wi = 0; int accept = 0; int quoted = 0; + CBS copy; + /* XXX This should not be necessary - revisit and remove */ if (candidate == NULL) return 0; + CBS_dup(candidate, ©); + + if ((len = CBS_len(©)) == 0) + return 0; + /* It can't be bigger than the local part, domain part and the '@' */ if (len > LOCAL_PART_MAX_LEN + DOMAIN_PART_MAX_LEN + 1) return 0; for (i = 0; i < len; i++) { - char c = candidate[i]; + char c; + if (!CBS_get_u8(©, &c)) + goto bad; /* non ascii, cr, lf, or nul is never allowed */ if (!isascii(c) || c == '\r' || c == '\n' || c == '\0') goto bad; @@ -372,8 +388,11 @@ x509_constraints_parse_mailbox(uint8_t *candidate, size_t len, continue; } if (c == '"' && i != 0) { + uint8_t next; /* end the quoted part. @ must be next */ - if (i + 1 == len || candidate[i + 1] != '@') + if (!CBS_peek_u8(©, &next)) + goto bad; + if (next != '@') goto bad; quoted = 0; } @@ -401,14 +420,15 @@ x509_constraints_parse_mailbox(uint8_t *candidate, size_t len, continue; } if (c == '\\') { + uint8_t next; /* - * RFC 3936 hints these can happen outside of - * quotend string. don't include the \ but + * RFC 2821 hints these can happen outside of + * quoted string. Don't include the \ but * next character must be ok. */ - if (i + 1 == len) + if (!CBS_peek_u8(©, &next)) goto bad; - if (!local_part_ok(candidate[i + 1])) + if (!local_part_ok(next)) goto bad; accept = 1; } @@ -420,8 +440,8 @@ x509_constraints_parse_mailbox(uint8_t *candidate, size_t len, } if (candidate_local == NULL || candidate_domain == NULL) goto bad; - if (!x509_constraints_valid_host(candidate_domain, - strlen(candidate_domain))) + CBS_init(&domain_cbs, candidate_domain, strlen(candidate_domain)); + if (!x509_constraints_valid_host(&domain_cbs)) goto bad; if (name != NULL) { @@ -440,18 +460,24 @@ x509_constraints_parse_mailbox(uint8_t *candidate, size_t len, } int -x509_constraints_valid_domain_constraint(uint8_t *constraint, size_t len) +x509_constraints_valid_domain_constraint(CBS *cbs) { - if (len == 0) + uint8_t first; + + if (CBS_len(cbs) == 0) return 1; /* empty constraints match */ /* * A domain may not be less than two characters, so you * can't match a single domain of less than that */ - if (len < 3 && constraint[0] == '.') - return 0; - return x509_constraints_valid_domain_internal(constraint, len, 0); + if (CBS_len(cbs) < 3) { + if (!CBS_peek_u8(cbs, &first)) + return 0; + if (first == '.') + return 0; + } + return x509_constraints_valid_domain_internal(cbs, 0); } /* @@ -480,6 +506,7 @@ x509_constraints_uri_host(uint8_t *uri, size_t len, char **hostpart) size_t i, hostlen = 0; uint8_t *authority = NULL; char *host = NULL; + CBS host_cbs; /* * Find first '//'. there must be at least a '//' and @@ -503,7 +530,8 @@ x509_constraints_uri_host(uint8_t *uri, size_t len, char **hostpart) * we indicate that we have a URI with an empty * host part, and succeed. */ - *hostpart = strdup(""); + if (hostpart != NULL) + *hostpart = strdup(""); return 1; } for (i = authority - uri; i < len; i++) { @@ -529,10 +557,11 @@ x509_constraints_uri_host(uint8_t *uri, size_t len, char **hostpart) return 0; if (host == NULL) host = authority; - if (!x509_constraints_valid_host(host, hostlen)) + CBS_init(&host_cbs, host, hostlen); + if (!x509_constraints_valid_host(&host_cbs)) + return 0; + if (hostpart != NULL && !CBS_strdup(&host_cbs, hostpart)) return 0; - if (hostpart != NULL) - *hostpart = strndup(host, hostlen); return 1; } @@ -558,7 +587,7 @@ x509_constraints_sandns(char *sandns, size_t dlen, char *constraint, size_t len) * returns 1 if the domain and constraint match. * returns 0 otherwise. * - * an empty constraint matches everyting. + * an empty constraint matches everything. * constraint will be matched against the domain as a suffix if it * starts with a '.'. * domain will be matched against the constraint as a suffix if it @@ -593,12 +622,15 @@ x509_constraints_domain(char *domain, size_t dlen, char *constraint, size_t len) } int -x509_constraints_uri(uint8_t *uri, size_t ulen, uint8_t *constraint, size_t len, +x509_constraints_uri(uint8_t *uri, size_t ulen, uint8_t *constraint, + size_t len, int *error) { int ret = 0; char *hostpart = NULL; + CBS cbs; + CBS_init(&cbs, constraint, len); if (!x509_constraints_uri_host(uri, ulen, &hostpart)) { *error = X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; goto err; @@ -607,7 +639,7 @@ x509_constraints_uri(uint8_t *uri, size_t ulen, uint8_t *constraint, size_t len, *error = X509_V_ERR_OUT_OF_MEM; goto err; } - if (!x509_constraints_valid_domain_constraint(constraint, len)) { + if (!x509_constraints_valid_domain_constraint(&cbs)) { *error = X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX; goto err; } @@ -619,10 +651,10 @@ x509_constraints_uri(uint8_t *uri, size_t ulen, uint8_t *constraint, size_t len, } /* - * Verify a validated address of size alen with a validated contraint + * Verify a validated address of size alen with a validated constraint * of size constraint_len. returns 1 if matching, 0 if not. * Addresses are assumed to be pre-validated for a length of 4 and 8 - * respectively for ipv4 addreses and constraints, and a length of + * respectively for ipv4 addresses and constraints, and a length of * 16 and 32 respectively for ipv6 address constraints by the caller. */ int @@ -714,7 +746,6 @@ x509_constraints_general_to_bytes(GENERAL_NAME *name, uint8_t **bytes, return 0; } - /* * Extract the relevant names for constraint checking from "cert", * validate them, and add them to the list of cert names for "chain". @@ -734,6 +765,7 @@ x509_constraints_extract_names(struct x509_constraints_names *names, while ((name = sk_GENERAL_NAME_value(cert->altname, i++)) != NULL) { uint8_t *bytes = NULL; size_t len = 0; + CBS cbs; if ((vname = x509_constraints_name_new()) == NULL) { *error = X509_V_ERR_OUT_OF_MEM; @@ -742,30 +774,31 @@ x509_constraints_extract_names(struct x509_constraints_names *names, name_type = x509_constraints_general_to_bytes(name, &bytes, &len); - switch(name_type) { + CBS_init(&cbs, bytes, len); + switch (name_type) { case GEN_DNS: - if (!x509_constraints_valid_sandns(bytes, len)) { + if (!x509_constraints_valid_sandns(&cbs)) { *error = X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; goto err; } - if ((vname->name = strndup(bytes, len)) == NULL) { + if (!CBS_strdup(&cbs, &vname->name)) { *error = X509_V_ERR_OUT_OF_MEM; goto err; } vname->type = GEN_DNS; - include_cn = 0; /* don't use cn from subject */ + include_cn = 0; /* Don't use cn from subject */ break; case GEN_EMAIL: - if (!x509_constraints_parse_mailbox(bytes, len, - vname)) { + if (!x509_constraints_parse_mailbox(&cbs, vname)) { *error = X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; goto err; } vname->type = GEN_EMAIL; - include_email = 0; /* don't use email from subject */ + include_email = 0; /* Don't use email from subject */ break; case GEN_URI: - if (!x509_constraints_uri_host(bytes, len, &vname->name)) { + if (!x509_constraints_uri_host(bytes, len, + &vname->name)) { *error = X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; goto err; } @@ -850,19 +883,21 @@ x509_constraints_extract_names(struct x509_constraints_names *names, */ while (include_email && (i = X509_NAME_get_index_by_NID(subject_name, - NID_pkcs9_emailAddress, i)) >= 0) { + NID_pkcs9_emailAddress, i)) >= 0) { ASN1_STRING *aname; - if ((email = X509_NAME_get_entry(subject_name, i)) == NULL || + CBS cbs; + if ((email = X509_NAME_get_entry(subject_name, i)) == + NULL || (aname = X509_NAME_ENTRY_get_data(email)) == NULL) { *error = X509_V_ERR_OUT_OF_MEM; goto err; } + CBS_init(&cbs, aname->data, aname->length); if ((vname = x509_constraints_name_new()) == NULL) { *error = X509_V_ERR_OUT_OF_MEM; goto err; } - if (!x509_constraints_parse_mailbox(aname->data, - aname->length, vname)) { + if (!x509_constraints_parse_mailbox(&cbs, vname)) { *error = X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; goto err; } @@ -874,27 +909,28 @@ x509_constraints_extract_names(struct x509_constraints_names *names, vname = NULL; } /* - * Include the CN as a hostname to be checked againt + * Include the CN as a hostname to be checked against * name constraints if it looks like a hostname. */ while (include_cn && (i = X509_NAME_get_index_by_NID(subject_name, - NID_commonName, i)) >= 0) { + NID_commonName, i)) >= 0) { + CBS cbs; ASN1_STRING *aname; - if ((cn = X509_NAME_get_entry(subject_name, i)) == NULL || + if ((cn = X509_NAME_get_entry(subject_name, i)) == + NULL || (aname = X509_NAME_ENTRY_get_data(cn)) == NULL) { *error = X509_V_ERR_OUT_OF_MEM; goto err; } - if (!x509_constraints_valid_host(aname->data, - aname->length)) + CBS_init(&cbs, aname->data, aname->length); + if (!x509_constraints_valid_host(&cbs)) continue; /* ignore it if not a hostname */ if ((vname = x509_constraints_name_new()) == NULL) { *error = X509_V_ERR_OUT_OF_MEM; goto err; } - if ((vname->name = strndup(aname->data, - aname->length)) == NULL) { + if (!CBS_strdup(&cbs, &vname->name)) { *error = X509_V_ERR_OUT_OF_MEM; goto err; } @@ -923,11 +959,12 @@ int x509_constraints_validate(GENERAL_NAME *constraint, struct x509_constraints_name **out_name, int *out_error) { - uint8_t *bytes = NULL; + uint8_t next, *bytes = NULL; size_t len = 0; struct x509_constraints_name *name; int error = X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX; int name_type; + CBS cbs; if (out_name == NULL || *out_name != NULL) return 0; @@ -941,6 +978,7 @@ x509_constraints_validate(GENERAL_NAME *constraint, } name_type = x509_constraints_general_to_bytes(constraint, &bytes, &len); + CBS_init(&cbs, bytes, len); switch (name_type) { case GEN_DIRNAME: if (len == 0) @@ -954,7 +992,7 @@ x509_constraints_validate(GENERAL_NAME *constraint, name->type = GEN_DIRNAME; break; case GEN_DNS: - if (!x509_constraints_valid_domain_constraint(bytes, len)) + if (!x509_constraints_valid_domain_constraint(&cbs)) goto err; if ((name->name = strndup(bytes, len)) == NULL) { error = X509_V_ERR_OUT_OF_MEM; @@ -964,7 +1002,7 @@ x509_constraints_validate(GENERAL_NAME *constraint, break; case GEN_EMAIL: if (len > 0 && memchr(bytes + 1, '@', len - 1) != NULL) { - if (!x509_constraints_parse_mailbox(bytes, len, name)) + if (!x509_constraints_parse_mailbox(&cbs, name)) goto err; break; } @@ -972,13 +1010,17 @@ x509_constraints_validate(GENERAL_NAME *constraint, * Mail constraints of the form @domain.com are accepted by * OpenSSL and Microsoft. */ - if (len > 0 && bytes[0] == '@') { - bytes++; - len--; + if (CBS_len(&cbs) > 0) { + if (!CBS_peek_u8(&cbs, &next)) + goto err; + if (next == '@') { + if (!CBS_skip(&cbs, 1)) + goto err; + } } - if (!x509_constraints_valid_domain_constraint(bytes, len)) + if (!x509_constraints_valid_domain_constraint(&cbs)) goto err; - if ((name->name = strndup(bytes, len)) == NULL) { + if (!CBS_strdup(&cbs, &name->name)) { error = X509_V_ERR_OUT_OF_MEM; goto err; } @@ -996,7 +1038,7 @@ x509_constraints_validate(GENERAL_NAME *constraint, name->type = GEN_IPADD; break; case GEN_URI: - if (!x509_constraints_valid_domain_constraint(bytes, len)) + if (!x509_constraints_valid_domain_constraint(&cbs)) goto err; if ((name->name = strndup(bytes, len)) == NULL) { error = X509_V_ERR_OUT_OF_MEM; @@ -1035,7 +1077,6 @@ x509_constraints_extract_constraints(X509 *cert, return 1; for (i = 0; i < sk_GENERAL_SUBTREE_num(nc->permittedSubtrees); i++) { - subtree = sk_GENERAL_SUBTREE_value(nc->permittedSubtrees, i); if (subtree->minimum || subtree->maximum) { *error = X509_V_ERR_SUBTREE_MINMAX; @@ -1169,7 +1210,7 @@ x509_constraints_check(struct x509_constraints_names *names, /* * Walk a validated chain of X509 certs, starting at the leaf, and * validate the name constraints in the chain. Intended for use with - * the legacy X509 validtion code in x509_vfy.c + * the legacy X509 validation code in x509_vfy.c * * returns 1 if the constraints are ok, 0 otherwise, setting error and * depth diff --git a/crypto/x509/x509_cpols.c b/crypto/x509/x509_cpols.c index 93527a43..3f106c69 100644 --- a/crypto/x509/x509_cpols.c +++ b/crypto/x509/x509_cpols.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_cpols.c,v 1.4 2022/01/14 08:16:13 tb Exp $ */ +/* $OpenBSD: x509_cpols.c,v 1.7 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -66,7 +66,7 @@ #include #include "pcy_int.h" -#include "x509_lcl.h" +#include "x509_local.h" /* Certificate policies extension support: this one is a bit complex... */ @@ -125,24 +125,28 @@ d2i_CERTIFICATEPOLICIES(CERTIFICATEPOLICIES **a, const unsigned char **in, long return (CERTIFICATEPOLICIES *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &CERTIFICATEPOLICIES_it); } +LCRYPTO_ALIAS(d2i_CERTIFICATEPOLICIES); int i2d_CERTIFICATEPOLICIES(CERTIFICATEPOLICIES *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &CERTIFICATEPOLICIES_it); } +LCRYPTO_ALIAS(i2d_CERTIFICATEPOLICIES); CERTIFICATEPOLICIES * CERTIFICATEPOLICIES_new(void) { return (CERTIFICATEPOLICIES *)ASN1_item_new(&CERTIFICATEPOLICIES_it); } +LCRYPTO_ALIAS(CERTIFICATEPOLICIES_new); void CERTIFICATEPOLICIES_free(CERTIFICATEPOLICIES *a) { ASN1_item_free((ASN1_VALUE *)a, &CERTIFICATEPOLICIES_it); } +LCRYPTO_ALIAS(CERTIFICATEPOLICIES_free); static const ASN1_TEMPLATE POLICYINFO_seq_tt[] = { { @@ -178,24 +182,28 @@ d2i_POLICYINFO(POLICYINFO **a, const unsigned char **in, long len) return (POLICYINFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &POLICYINFO_it); } +LCRYPTO_ALIAS(d2i_POLICYINFO); int i2d_POLICYINFO(POLICYINFO *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &POLICYINFO_it); } +LCRYPTO_ALIAS(i2d_POLICYINFO); POLICYINFO * POLICYINFO_new(void) { return (POLICYINFO *)ASN1_item_new(&POLICYINFO_it); } +LCRYPTO_ALIAS(POLICYINFO_new); void POLICYINFO_free(POLICYINFO *a) { ASN1_item_free((ASN1_VALUE *)a, &POLICYINFO_it); } +LCRYPTO_ALIAS(POLICYINFO_free); static const ASN1_TEMPLATE policydefault_tt = { .flags = 0, @@ -273,24 +281,28 @@ d2i_POLICYQUALINFO(POLICYQUALINFO **a, const unsigned char **in, long len) return (POLICYQUALINFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &POLICYQUALINFO_it); } +LCRYPTO_ALIAS(d2i_POLICYQUALINFO); int i2d_POLICYQUALINFO(POLICYQUALINFO *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &POLICYQUALINFO_it); } +LCRYPTO_ALIAS(i2d_POLICYQUALINFO); POLICYQUALINFO * POLICYQUALINFO_new(void) { return (POLICYQUALINFO *)ASN1_item_new(&POLICYQUALINFO_it); } +LCRYPTO_ALIAS(POLICYQUALINFO_new); void POLICYQUALINFO_free(POLICYQUALINFO *a) { ASN1_item_free((ASN1_VALUE *)a, &POLICYQUALINFO_it); } +LCRYPTO_ALIAS(POLICYQUALINFO_free); static const ASN1_TEMPLATE USERNOTICE_seq_tt[] = { { @@ -326,24 +338,28 @@ d2i_USERNOTICE(USERNOTICE **a, const unsigned char **in, long len) return (USERNOTICE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &USERNOTICE_it); } +LCRYPTO_ALIAS(d2i_USERNOTICE); int i2d_USERNOTICE(USERNOTICE *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &USERNOTICE_it); } +LCRYPTO_ALIAS(i2d_USERNOTICE); USERNOTICE * USERNOTICE_new(void) { return (USERNOTICE *)ASN1_item_new(&USERNOTICE_it); } +LCRYPTO_ALIAS(USERNOTICE_new); void USERNOTICE_free(USERNOTICE *a) { ASN1_item_free((ASN1_VALUE *)a, &USERNOTICE_it); } +LCRYPTO_ALIAS(USERNOTICE_free); static const ASN1_TEMPLATE NOTICEREF_seq_tt[] = { { @@ -379,24 +395,28 @@ d2i_NOTICEREF(NOTICEREF **a, const unsigned char **in, long len) return (NOTICEREF *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &NOTICEREF_it); } +LCRYPTO_ALIAS(d2i_NOTICEREF); int i2d_NOTICEREF(NOTICEREF *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &NOTICEREF_it); } +LCRYPTO_ALIAS(i2d_NOTICEREF); NOTICEREF * NOTICEREF_new(void) { return (NOTICEREF *)ASN1_item_new(&NOTICEREF_it); } +LCRYPTO_ALIAS(NOTICEREF_new); void NOTICEREF_free(NOTICEREF *a) { ASN1_item_free((ASN1_VALUE *)a, &NOTICEREF_it); } +LCRYPTO_ALIAS(NOTICEREF_free); static STACK_OF(POLICYINFO) * r2i_certpol(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *value) @@ -762,3 +782,4 @@ X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent) else BIO_printf(out, "%*sNo Qualifiers\n", indent + 2, ""); } +LCRYPTO_ALIAS(X509_POLICY_NODE_print); diff --git a/crypto/x509/x509_crld.c b/crypto/x509/x509_crld.c index 6b6f7953..7887ccd6 100644 --- a/crypto/x509/x509_crld.c +++ b/crypto/x509/x509_crld.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_crld.c,v 1.2 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509_crld.c,v 1.5 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -65,7 +65,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static void *v2i_crld(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); @@ -426,24 +426,28 @@ d2i_DIST_POINT_NAME(DIST_POINT_NAME **a, const unsigned char **in, long len) return (DIST_POINT_NAME *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &DIST_POINT_NAME_it); } +LCRYPTO_ALIAS(d2i_DIST_POINT_NAME); int i2d_DIST_POINT_NAME(DIST_POINT_NAME *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &DIST_POINT_NAME_it); } +LCRYPTO_ALIAS(i2d_DIST_POINT_NAME); DIST_POINT_NAME * DIST_POINT_NAME_new(void) { return (DIST_POINT_NAME *)ASN1_item_new(&DIST_POINT_NAME_it); } +LCRYPTO_ALIAS(DIST_POINT_NAME_new); void DIST_POINT_NAME_free(DIST_POINT_NAME *a) { ASN1_item_free((ASN1_VALUE *)a, &DIST_POINT_NAME_it); } +LCRYPTO_ALIAS(DIST_POINT_NAME_free); static const ASN1_TEMPLATE DIST_POINT_seq_tt[] = { { @@ -486,24 +490,28 @@ d2i_DIST_POINT(DIST_POINT **a, const unsigned char **in, long len) return (DIST_POINT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &DIST_POINT_it); } +LCRYPTO_ALIAS(d2i_DIST_POINT); int i2d_DIST_POINT(DIST_POINT *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &DIST_POINT_it); } +LCRYPTO_ALIAS(i2d_DIST_POINT); DIST_POINT * DIST_POINT_new(void) { return (DIST_POINT *)ASN1_item_new(&DIST_POINT_it); } +LCRYPTO_ALIAS(DIST_POINT_new); void DIST_POINT_free(DIST_POINT *a) { ASN1_item_free((ASN1_VALUE *)a, &DIST_POINT_it); } +LCRYPTO_ALIAS(DIST_POINT_free); static const ASN1_TEMPLATE CRL_DIST_POINTS_item_tt = { .flags = ASN1_TFLG_SEQUENCE_OF, @@ -530,24 +538,28 @@ d2i_CRL_DIST_POINTS(CRL_DIST_POINTS **a, const unsigned char **in, long len) return (CRL_DIST_POINTS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &CRL_DIST_POINTS_it); } +LCRYPTO_ALIAS(d2i_CRL_DIST_POINTS); int i2d_CRL_DIST_POINTS(CRL_DIST_POINTS *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &CRL_DIST_POINTS_it); } +LCRYPTO_ALIAS(i2d_CRL_DIST_POINTS); CRL_DIST_POINTS * CRL_DIST_POINTS_new(void) { return (CRL_DIST_POINTS *)ASN1_item_new(&CRL_DIST_POINTS_it); } +LCRYPTO_ALIAS(CRL_DIST_POINTS_new); void CRL_DIST_POINTS_free(CRL_DIST_POINTS *a) { ASN1_item_free((ASN1_VALUE *)a, &CRL_DIST_POINTS_it); } +LCRYPTO_ALIAS(CRL_DIST_POINTS_free); static const ASN1_TEMPLATE ISSUING_DIST_POINT_seq_tt[] = { { @@ -611,24 +623,28 @@ d2i_ISSUING_DIST_POINT(ISSUING_DIST_POINT **a, const unsigned char **in, long le return (ISSUING_DIST_POINT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &ISSUING_DIST_POINT_it); } +LCRYPTO_ALIAS(d2i_ISSUING_DIST_POINT); int i2d_ISSUING_DIST_POINT(ISSUING_DIST_POINT *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &ISSUING_DIST_POINT_it); } +LCRYPTO_ALIAS(i2d_ISSUING_DIST_POINT); ISSUING_DIST_POINT * ISSUING_DIST_POINT_new(void) { return (ISSUING_DIST_POINT *)ASN1_item_new(&ISSUING_DIST_POINT_it); } +LCRYPTO_ALIAS(ISSUING_DIST_POINT_new); void ISSUING_DIST_POINT_free(ISSUING_DIST_POINT *a) { ASN1_item_free((ASN1_VALUE *)a, &ISSUING_DIST_POINT_it); } +LCRYPTO_ALIAS(ISSUING_DIST_POINT_free); static int i2r_idp(const X509V3_EXT_METHOD *method, void *pidp, BIO *out, int indent); @@ -809,3 +825,4 @@ DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname) } return 1; } +LCRYPTO_ALIAS(DIST_POINT_set_dpname); diff --git a/crypto/x509/x509_d2.c b/crypto/x509/x509_d2.c index 5b0f80ad..bf358ec2 100644 --- a/crypto/x509/x509_d2.c +++ b/crypto/x509/x509_d2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_d2.c,v 1.10 2015/01/22 09:06:39 reyk Exp $ */ +/* $OpenBSD: x509_d2.c,v 1.12 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -83,6 +83,7 @@ X509_STORE_set_default_paths(X509_STORE *ctx) return (1); } +LCRYPTO_ALIAS(X509_STORE_set_default_paths); int X509_STORE_load_locations(X509_STORE *ctx, const char *file, const char *path) @@ -107,6 +108,7 @@ X509_STORE_load_locations(X509_STORE *ctx, const char *file, const char *path) return (0); return (1); } +LCRYPTO_ALIAS(X509_STORE_load_locations); int X509_STORE_load_mem(X509_STORE *ctx, void *buf, int len) @@ -126,3 +128,4 @@ X509_STORE_load_mem(X509_STORE *ctx, void *buf, int len) return (1); } +LCRYPTO_ALIAS(X509_STORE_load_mem); diff --git a/crypto/x509/x509_def.c b/crypto/x509/x509_def.c index 5e570eb9..f85781af 100644 --- a/crypto/x509/x509_def.c +++ b/crypto/x509/x509_def.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_def.c,v 1.5 2014/06/12 15:49:31 deraadt Exp $ */ +/* $OpenBSD: x509_def.c,v 1.7 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,33 +66,39 @@ X509_get_default_private_dir(void) { return (X509_PRIVATE_DIR); } +LCRYPTO_ALIAS(X509_get_default_private_dir); const char * X509_get_default_cert_area(void) { return (X509_CERT_AREA); } +LCRYPTO_ALIAS(X509_get_default_cert_area); const char * X509_get_default_cert_dir(void) { return (X509_CERT_DIR); } +LCRYPTO_ALIAS(X509_get_default_cert_dir); const char * X509_get_default_cert_file(void) { return (X509_CERT_FILE); } +LCRYPTO_ALIAS(X509_get_default_cert_file); const char * X509_get_default_cert_dir_env(void) { return (X509_CERT_DIR_EVP); } +LCRYPTO_ALIAS(X509_get_default_cert_dir_env); const char * X509_get_default_cert_file_env(void) { return (X509_CERT_FILE_EVP); } +LCRYPTO_ALIAS(X509_get_default_cert_file_env); diff --git a/crypto/x509/x509_enum.c b/crypto/x509/x509_enum.c index f18eea53..432239e0 100644 --- a/crypto/x509/x509_enum.c +++ b/crypto/x509/x509_enum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_enum.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ +/* $OpenBSD: x509_enum.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -105,3 +105,4 @@ i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *method, const ASN1_ENUMERATED *e) } return i2s_ASN1_ENUMERATED(method, e); } +LCRYPTO_ALIAS(i2s_ASN1_ENUMERATED_TABLE); diff --git a/crypto/x509/x509_err.c b/crypto/x509/x509_err.c index 588ed854..272d2894 100644 --- a/crypto/x509/x509_err.c +++ b/crypto/x509/x509_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_err.c,v 1.17 2022/07/12 14:42:50 kn Exp $ */ +/* $OpenBSD: x509_err.c,v 1.19 2023/02/16 08:38:17 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. * @@ -191,6 +191,7 @@ ERR_load_X509_strings(void) } #endif } +LCRYPTO_ALIAS(ERR_load_X509_strings); void @@ -203,3 +204,4 @@ ERR_load_X509V3_strings(void) } #endif } +LCRYPTO_ALIAS(ERR_load_X509V3_strings); diff --git a/crypto/x509/x509_ext.c b/crypto/x509/x509_ext.c index 14459511..ce316d25 100644 --- a/crypto/x509/x509_ext.c +++ b/crypto/x509/x509_ext.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_ext.c,v 1.13 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509_ext.c,v 1.16 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,49 +65,56 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" int X509_CRL_get_ext_count(const X509_CRL *x) { return (X509v3_get_ext_count(x->crl->extensions)); } +LCRYPTO_ALIAS(X509_CRL_get_ext_count); int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->crl->extensions, nid, lastpos)); } +LCRYPTO_ALIAS(X509_CRL_get_ext_by_NID); int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj, int lastpos) { return (X509v3_get_ext_by_OBJ(x->crl->extensions, obj, lastpos)); } +LCRYPTO_ALIAS(X509_CRL_get_ext_by_OBJ); int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos) { return (X509v3_get_ext_by_critical(x->crl->extensions, crit, lastpos)); } +LCRYPTO_ALIAS(X509_CRL_get_ext_by_critical); X509_EXTENSION * X509_CRL_get_ext(const X509_CRL *x, int loc) { return (X509v3_get_ext(x->crl->extensions, loc)); } +LCRYPTO_ALIAS(X509_CRL_get_ext); X509_EXTENSION * X509_CRL_delete_ext(X509_CRL *x, int loc) { return (X509v3_delete_ext(x->crl->extensions, loc)); } +LCRYPTO_ALIAS(X509_CRL_delete_ext); void * X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->crl->extensions, nid, crit, idx); } +LCRYPTO_ALIAS(X509_CRL_get_ext_d2i); int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, @@ -115,30 +122,35 @@ X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, { return X509V3_add1_i2d(&x->crl->extensions, nid, value, crit, flags); } +LCRYPTO_ALIAS(X509_CRL_add1_ext_i2d); int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc) { return (X509v3_add_ext(&(x->crl->extensions), ex, loc) != NULL); } +LCRYPTO_ALIAS(X509_CRL_add_ext); int X509_get_ext_count(const X509 *x) { return (X509v3_get_ext_count(x->cert_info->extensions)); } +LCRYPTO_ALIAS(X509_get_ext_count); int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->cert_info->extensions, nid, lastpos)); } +LCRYPTO_ALIAS(X509_get_ext_by_NID); int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos) { return (X509v3_get_ext_by_OBJ(x->cert_info->extensions, obj, lastpos)); } +LCRYPTO_ALIAS(X509_get_ext_by_OBJ); int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos) @@ -146,30 +158,35 @@ X509_get_ext_by_critical(const X509 *x, int crit, int lastpos) return (X509v3_get_ext_by_critical(x->cert_info->extensions, crit, lastpos)); } +LCRYPTO_ALIAS(X509_get_ext_by_critical); X509_EXTENSION * X509_get_ext(const X509 *x, int loc) { return (X509v3_get_ext(x->cert_info->extensions, loc)); } +LCRYPTO_ALIAS(X509_get_ext); X509_EXTENSION * X509_delete_ext(X509 *x, int loc) { return (X509v3_delete_ext(x->cert_info->extensions, loc)); } +LCRYPTO_ALIAS(X509_delete_ext); int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc) { return (X509v3_add_ext(&(x->cert_info->extensions), ex, loc) != NULL); } +LCRYPTO_ALIAS(X509_add_ext); void * X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->cert_info->extensions, nid, crit, idx); } +LCRYPTO_ALIAS(X509_get_ext_d2i); int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, unsigned long flags) @@ -177,18 +194,21 @@ X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, unsigned long flags) return X509V3_add1_i2d(&x->cert_info->extensions, nid, value, crit, flags); } +LCRYPTO_ALIAS(X509_add1_ext_i2d); int X509_REVOKED_get_ext_count(const X509_REVOKED *x) { return (X509v3_get_ext_count(x->extensions)); } +LCRYPTO_ALIAS(X509_REVOKED_get_ext_count); int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->extensions, nid, lastpos)); } +LCRYPTO_ALIAS(X509_REVOKED_get_ext_by_NID); int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj, @@ -196,36 +216,42 @@ X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj, { return (X509v3_get_ext_by_OBJ(x->extensions, obj, lastpos)); } +LCRYPTO_ALIAS(X509_REVOKED_get_ext_by_OBJ); int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit, int lastpos) { return (X509v3_get_ext_by_critical(x->extensions, crit, lastpos)); } +LCRYPTO_ALIAS(X509_REVOKED_get_ext_by_critical); X509_EXTENSION * X509_REVOKED_get_ext(const X509_REVOKED *x, int loc) { return (X509v3_get_ext(x->extensions, loc)); } +LCRYPTO_ALIAS(X509_REVOKED_get_ext); X509_EXTENSION * X509_REVOKED_delete_ext(X509_REVOKED *x, int loc) { return (X509v3_delete_ext(x->extensions, loc)); } +LCRYPTO_ALIAS(X509_REVOKED_delete_ext); int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc) { return (X509v3_add_ext(&(x->extensions), ex, loc) != NULL); } +LCRYPTO_ALIAS(X509_REVOKED_add_ext); void * X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit, int *idx) { return X509V3_get_d2i(x->extensions, nid, crit, idx); } +LCRYPTO_ALIAS(X509_REVOKED_get_ext_d2i); int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, @@ -233,3 +259,4 @@ X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, { return X509V3_add1_i2d(&x->extensions, nid, value, crit, flags); } +LCRYPTO_ALIAS(X509_REVOKED_add1_ext_i2d); diff --git a/crypto/x509/x509_extku.c b/crypto/x509/x509_extku.c index 09bec675..94032f62 100644 --- a/crypto/x509/x509_extku.c +++ b/crypto/x509/x509_extku.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_extku.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ +/* $OpenBSD: x509_extku.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -128,24 +128,28 @@ d2i_EXTENDED_KEY_USAGE(EXTENDED_KEY_USAGE **a, const unsigned char **in, long le return (EXTENDED_KEY_USAGE *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &EXTENDED_KEY_USAGE_it); } +LCRYPTO_ALIAS(d2i_EXTENDED_KEY_USAGE); int i2d_EXTENDED_KEY_USAGE(EXTENDED_KEY_USAGE *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &EXTENDED_KEY_USAGE_it); } +LCRYPTO_ALIAS(i2d_EXTENDED_KEY_USAGE); EXTENDED_KEY_USAGE * EXTENDED_KEY_USAGE_new(void) { return (EXTENDED_KEY_USAGE *)ASN1_item_new(&EXTENDED_KEY_USAGE_it); } +LCRYPTO_ALIAS(EXTENDED_KEY_USAGE_new); void EXTENDED_KEY_USAGE_free(EXTENDED_KEY_USAGE *a) { ASN1_item_free((ASN1_VALUE *)a, &EXTENDED_KEY_USAGE_it); } +LCRYPTO_ALIAS(EXTENDED_KEY_USAGE_free); static STACK_OF(CONF_VALUE) * i2v_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, void *a, diff --git a/crypto/x509/x509_genn.c b/crypto/x509/x509_genn.c index 1905e8ca..0c03396e 100644 --- a/crypto/x509/x509_genn.c +++ b/crypto/x509/x509_genn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_genn.c,v 1.2 2020/12/08 15:06:42 tb Exp $ */ +/* $OpenBSD: x509_genn.c,v 1.5 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -98,24 +98,28 @@ d2i_OTHERNAME(OTHERNAME **a, const unsigned char **in, long len) return (OTHERNAME *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &OTHERNAME_it); } +LCRYPTO_ALIAS(d2i_OTHERNAME); int i2d_OTHERNAME(OTHERNAME *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &OTHERNAME_it); } +LCRYPTO_ALIAS(i2d_OTHERNAME); OTHERNAME * OTHERNAME_new(void) { return (OTHERNAME *)ASN1_item_new(&OTHERNAME_it); } +LCRYPTO_ALIAS(OTHERNAME_new); void OTHERNAME_free(OTHERNAME *a) { ASN1_item_free((ASN1_VALUE *)a, &OTHERNAME_it); } +LCRYPTO_ALIAS(OTHERNAME_free); /* Uses explicit tagging since DIRECTORYSTRING is a CHOICE type */ static const ASN1_TEMPLATE EDIPARTYNAME_seq_tt[] = { @@ -152,24 +156,28 @@ d2i_EDIPARTYNAME(EDIPARTYNAME **a, const unsigned char **in, long len) return (EDIPARTYNAME *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &EDIPARTYNAME_it); } +LCRYPTO_ALIAS(d2i_EDIPARTYNAME); int i2d_EDIPARTYNAME(EDIPARTYNAME *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &EDIPARTYNAME_it); } +LCRYPTO_ALIAS(i2d_EDIPARTYNAME); EDIPARTYNAME * EDIPARTYNAME_new(void) { return (EDIPARTYNAME *)ASN1_item_new(&EDIPARTYNAME_it); } +LCRYPTO_ALIAS(EDIPARTYNAME_new); void EDIPARTYNAME_free(EDIPARTYNAME *a) { ASN1_item_free((ASN1_VALUE *)a, &EDIPARTYNAME_it); } +LCRYPTO_ALIAS(EDIPARTYNAME_free); static const ASN1_TEMPLATE GENERAL_NAME_ch_tt[] = { { @@ -256,24 +264,28 @@ d2i_GENERAL_NAME(GENERAL_NAME **a, const unsigned char **in, long len) return (GENERAL_NAME *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &GENERAL_NAME_it); } +LCRYPTO_ALIAS(d2i_GENERAL_NAME); int i2d_GENERAL_NAME(GENERAL_NAME *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &GENERAL_NAME_it); } +LCRYPTO_ALIAS(i2d_GENERAL_NAME); GENERAL_NAME * GENERAL_NAME_new(void) { return (GENERAL_NAME *)ASN1_item_new(&GENERAL_NAME_it); } +LCRYPTO_ALIAS(GENERAL_NAME_new); void GENERAL_NAME_free(GENERAL_NAME *a) { ASN1_item_free((ASN1_VALUE *)a, &GENERAL_NAME_it); } +LCRYPTO_ALIAS(GENERAL_NAME_free); static const ASN1_TEMPLATE GENERAL_NAMES_item_tt = { .flags = ASN1_TFLG_SEQUENCE_OF, @@ -300,30 +312,35 @@ d2i_GENERAL_NAMES(GENERAL_NAMES **a, const unsigned char **in, long len) return (GENERAL_NAMES *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &GENERAL_NAMES_it); } +LCRYPTO_ALIAS(d2i_GENERAL_NAMES); int i2d_GENERAL_NAMES(GENERAL_NAMES *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &GENERAL_NAMES_it); } +LCRYPTO_ALIAS(i2d_GENERAL_NAMES); GENERAL_NAMES * GENERAL_NAMES_new(void) { return (GENERAL_NAMES *)ASN1_item_new(&GENERAL_NAMES_it); } +LCRYPTO_ALIAS(GENERAL_NAMES_new); void GENERAL_NAMES_free(GENERAL_NAMES *a) { ASN1_item_free((ASN1_VALUE *)a, &GENERAL_NAMES_it); } +LCRYPTO_ALIAS(GENERAL_NAMES_free); GENERAL_NAME * GENERAL_NAME_dup(GENERAL_NAME *a) { return ASN1_item_dup(&GENERAL_NAME_it, a); } +LCRYPTO_ALIAS(GENERAL_NAME_dup); static int EDIPARTYNAME_cmp(const EDIPARTYNAME *a, const EDIPARTYNAME *b) @@ -398,6 +415,7 @@ GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) } return result; } +LCRYPTO_ALIAS(GENERAL_NAME_cmp); /* Returns 0 if they are equal, != 0 otherwise. */ int @@ -414,6 +432,7 @@ OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b) result = ASN1_TYPE_cmp(a->value, b->value); return result; } +LCRYPTO_ALIAS(OTHERNAME_cmp); void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) @@ -451,6 +470,7 @@ GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value) } a->type = type; } +LCRYPTO_ALIAS(GENERAL_NAME_set0_value); void * GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) @@ -485,6 +505,7 @@ GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype) return NULL; } } +LCRYPTO_ALIAS(GENERAL_NAME_get0_value); int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, ASN1_OBJECT *oid, @@ -500,6 +521,7 @@ GENERAL_NAME_set0_othername(GENERAL_NAME *gen, ASN1_OBJECT *oid, GENERAL_NAME_set0_value(gen, GEN_OTHERNAME, oth); return 1; } +LCRYPTO_ALIAS(GENERAL_NAME_set0_othername); int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, ASN1_OBJECT **poid, @@ -513,3 +535,4 @@ GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, ASN1_OBJECT **poid, *pvalue = gen->d.otherName->value; return 1; } +LCRYPTO_ALIAS(GENERAL_NAME_get0_otherName); diff --git a/crypto/x509/x509_info.c b/crypto/x509/x509_info.c index 86ed6fad..a3d4d1bc 100644 --- a/crypto/x509/x509_info.c +++ b/crypto/x509/x509_info.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_info.c,v 1.1 2020/06/04 15:19:31 jsing Exp $ */ +/* $OpenBSD: x509_info.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -139,24 +139,28 @@ d2i_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION **a, const unsigned char **in, long le return (ACCESS_DESCRIPTION *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &ACCESS_DESCRIPTION_it); } +LCRYPTO_ALIAS(d2i_ACCESS_DESCRIPTION); int i2d_ACCESS_DESCRIPTION(ACCESS_DESCRIPTION *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &ACCESS_DESCRIPTION_it); } +LCRYPTO_ALIAS(i2d_ACCESS_DESCRIPTION); ACCESS_DESCRIPTION * ACCESS_DESCRIPTION_new(void) { return (ACCESS_DESCRIPTION *)ASN1_item_new(&ACCESS_DESCRIPTION_it); } +LCRYPTO_ALIAS(ACCESS_DESCRIPTION_new); void ACCESS_DESCRIPTION_free(ACCESS_DESCRIPTION *a) { ASN1_item_free((ASN1_VALUE *)a, &ACCESS_DESCRIPTION_it); } +LCRYPTO_ALIAS(ACCESS_DESCRIPTION_free); static const ASN1_TEMPLATE AUTHORITY_INFO_ACCESS_item_tt = { .flags = ASN1_TFLG_SEQUENCE_OF, @@ -183,24 +187,28 @@ d2i_AUTHORITY_INFO_ACCESS(AUTHORITY_INFO_ACCESS **a, const unsigned char **in, l return (AUTHORITY_INFO_ACCESS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &AUTHORITY_INFO_ACCESS_it); } +LCRYPTO_ALIAS(d2i_AUTHORITY_INFO_ACCESS); int i2d_AUTHORITY_INFO_ACCESS(AUTHORITY_INFO_ACCESS *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &AUTHORITY_INFO_ACCESS_it); } +LCRYPTO_ALIAS(i2d_AUTHORITY_INFO_ACCESS); AUTHORITY_INFO_ACCESS * AUTHORITY_INFO_ACCESS_new(void) { return (AUTHORITY_INFO_ACCESS *)ASN1_item_new(&AUTHORITY_INFO_ACCESS_it); } +LCRYPTO_ALIAS(AUTHORITY_INFO_ACCESS_new); void AUTHORITY_INFO_ACCESS_free(AUTHORITY_INFO_ACCESS *a) { ASN1_item_free((ASN1_VALUE *)a, &AUTHORITY_INFO_ACCESS_it); } +LCRYPTO_ALIAS(AUTHORITY_INFO_ACCESS_free); static STACK_OF(CONF_VALUE) * i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD *method, @@ -306,3 +314,4 @@ i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION* a) i2a_ASN1_OBJECT(bp, a->method); return 2; } +LCRYPTO_ALIAS(i2a_ACCESS_DESCRIPTION); diff --git a/crypto/x509/x509_internal.h b/crypto/x509/x509_internal.h index 030f24c4..c4222bcf 100644 --- a/crypto/x509/x509_internal.h +++ b/crypto/x509/x509_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_internal.h,v 1.19 2022/06/27 14:10:22 tb Exp $ */ +/* $OpenBSD: x509_internal.h,v 1.25 2023/01/28 19:08:09 tb Exp $ */ /* * Copyright (c) 2020 Bob Beck * @@ -20,9 +20,9 @@ /* Internal use only, not public API */ #include -#include - -#include "x509_lcl.h" +#include "bytestring.h" +#include "x509_local.h" +#include "x509_verify.h" /* Hard limits on structure size and number of signature checks. */ #define X509_VERIFY_MAX_CHAINS 8 /* Max validated chains */ @@ -93,7 +93,7 @@ int x509_vfy_check_policy(X509_STORE_CTX *ctx); int x509_vfy_check_trust(X509_STORE_CTX *ctx); int x509_vfy_check_chain_extensions(X509_STORE_CTX *ctx); int x509_vfy_callback_indicate_completion(X509_STORE_CTX *ctx); -void x509v3_cache_extensions(X509 *x); +int x509v3_cache_extensions(X509 *x); X509 *x509_vfy_lookup_cert_match(X509_STORE_CTX *ctx, X509 *x); time_t x509_verify_asn1_time_to_time_t(const ASN1_TIME *atime, int notafter); @@ -111,14 +111,13 @@ struct x509_constraints_names *x509_constraints_names_new(size_t names_max); int x509_constraints_general_to_bytes(GENERAL_NAME *name, uint8_t **bytes, size_t *len); void x509_constraints_names_free(struct x509_constraints_names *names); -int x509_constraints_valid_host(uint8_t *name, size_t len); -int x509_constraints_valid_sandns(uint8_t *name, size_t len); +int x509_constraints_valid_host(CBS *cbs); +int x509_constraints_valid_sandns(CBS *cbs); int x509_constraints_domain(char *domain, size_t dlen, char *constraint, size_t len); -int x509_constraints_parse_mailbox(uint8_t *candidate, size_t len, +int x509_constraints_parse_mailbox(CBS *candidate, struct x509_constraints_name *name); -int x509_constraints_valid_domain_constraint(uint8_t *constraint, - size_t len); +int x509_constraints_valid_domain_constraint(CBS *cbs); int x509_constraints_uri_host(uint8_t *uri, size_t len, char **hostp); int x509_constraints_uri(uint8_t *uri, size_t ulen, uint8_t *constraint, size_t len, int *error); diff --git a/crypto/x509/x509_issuer_cache.c b/crypto/x509/x509_issuer_cache.c index 4f78e1e6..f7fbd54c 100644 --- a/crypto/x509/x509_issuer_cache.c +++ b/crypto/x509/x509_issuer_cache.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_issuer_cache.c,v 1.3 2022/06/27 14:23:40 beck Exp $ */ +/* $OpenBSD: x509_issuer_cache.c,v 1.4 2022/12/26 07:18:53 jmc Exp $ */ /* * Copyright (c) 2020 Bob Beck * @@ -75,7 +75,7 @@ x509_issuer_cache_set_max(size_t max) /* * Free the oldest entry in the issuer cache. Returns 1 - * if an entry was successfuly freed, 0 otherwise. Must + * if an entry was successfully freed, 0 otherwise. Must * be called with x509_issuer_tree_mutex held. */ void diff --git a/crypto/x509/x509_lib.c b/crypto/x509/x509_lib.c index e265d30f..97d54edd 100644 --- a/crypto/x509/x509_lib.c +++ b/crypto/x509/x509_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_lib.c,v 1.4 2022/07/24 21:41:29 tb Exp $ */ +/* $OpenBSD: x509_lib.c,v 1.7 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -64,7 +64,7 @@ #include #include "ext_dat.h" -#include "x509_lcl.h" +#include "x509_local.h" static STACK_OF(X509V3_EXT_METHOD) *ext_list = NULL; @@ -85,6 +85,7 @@ X509V3_EXT_add(X509V3_EXT_METHOD *ext) } return 1; } +LCRYPTO_ALIAS(X509V3_EXT_add); static int ext_cmp(const X509V3_EXT_METHOD * const *a, const X509V3_EXT_METHOD * const *b) @@ -132,6 +133,7 @@ X509V3_EXT_get_nid(int nid) return NULL; return sk_X509V3_EXT_METHOD_value(ext_list, idx); } +LCRYPTO_ALIAS(X509V3_EXT_get_nid); const X509V3_EXT_METHOD * X509V3_EXT_get(X509_EXTENSION *ext) @@ -142,6 +144,7 @@ X509V3_EXT_get(X509_EXTENSION *ext) return NULL; return X509V3_EXT_get_nid(nid); } +LCRYPTO_ALIAS(X509V3_EXT_get); int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist) @@ -151,6 +154,7 @@ X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist) return 0; return 1; } +LCRYPTO_ALIAS(X509V3_EXT_add_list); int X509V3_EXT_add_alias(int nid_to, int nid_from) @@ -175,6 +179,7 @@ X509V3_EXT_add_alias(int nid_to, int nid_from) } return 1; } +LCRYPTO_ALIAS(X509V3_EXT_add_alias); void X509V3_EXT_cleanup(void) @@ -182,6 +187,7 @@ X509V3_EXT_cleanup(void) sk_X509V3_EXT_METHOD_pop_free(ext_list, ext_list_free); ext_list = NULL; } +LCRYPTO_ALIAS(X509V3_EXT_cleanup); static void ext_list_free(X509V3_EXT_METHOD *ext) @@ -199,6 +205,7 @@ X509V3_add_standard_extensions(void) { return 1; } +LCRYPTO_ALIAS(X509V3_add_standard_extensions); /* Return an extension internal structure */ @@ -216,6 +223,7 @@ X509V3_EXT_d2i(X509_EXTENSION *ext) method->it); return method->d2i(NULL, &p, ext->value->length); } +LCRYPTO_ALIAS(X509V3_EXT_d2i); /* Get critical flag and decoded version of extension from a NID. * The "idx" variable returns the last found extension and can @@ -281,6 +289,7 @@ X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) *crit = -1; return NULL; } +LCRYPTO_ALIAS(X509V3_get_d2i); /* This function is a general extension append, replace and delete utility. * The precise operation is governed by the 'flags' value. The 'crit' and @@ -362,3 +371,4 @@ X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, X509V3error(errcode); return 0; } +LCRYPTO_ALIAS(X509V3_add1_i2d); diff --git a/crypto/x509/x509_lcl.h b/crypto/x509/x509_local.h similarity index 98% rename from crypto/x509/x509_lcl.h rename to crypto/x509/x509_local.h index 8aa2db59..b0c7a197 100644 --- a/crypto/x509/x509_lcl.h +++ b/crypto/x509/x509_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_lcl.h,v 1.16 2022/08/15 11:52:37 tb Exp $ */ +/* $OpenBSD: x509_local.h,v 1.2 2022/11/26 17:23:18 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2013. */ @@ -56,8 +56,8 @@ * */ -#ifndef HEADER_X509_LCL_H -#define HEADER_X509_LCL_H +#ifndef HEADER_X509_LOCAL_H +#define HEADER_X509_LOCAL_H __BEGIN_HIDDEN_DECLS @@ -377,4 +377,4 @@ int name_cmp(const char *name, const char *cmp); __END_HIDDEN_DECLS -#endif /* !HEADER_X509_LCL_H */ +#endif /* !HEADER_X509_LOCAL_H */ diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index 90d75497..65d11d91 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_lu.c,v 1.55 2022/01/14 07:53:45 tb Exp $ */ +/* $OpenBSD: x509_lu.c,v 1.58 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include #include #include -#include "x509_lcl.h" +#include "x509_local.h" X509_LOOKUP * X509_LOOKUP_new(X509_LOOKUP_METHOD *method) @@ -84,6 +84,7 @@ X509_LOOKUP_new(X509_LOOKUP_METHOD *method) return lu; } +LCRYPTO_ALIAS(X509_LOOKUP_new); void X509_LOOKUP_free(X509_LOOKUP *ctx) @@ -94,6 +95,7 @@ X509_LOOKUP_free(X509_LOOKUP *ctx) ctx->method->free(ctx); free(ctx); } +LCRYPTO_ALIAS(X509_LOOKUP_free); int X509_LOOKUP_init(X509_LOOKUP *ctx) @@ -104,6 +106,7 @@ X509_LOOKUP_init(X509_LOOKUP *ctx) return 1; return ctx->method->init(ctx); } +LCRYPTO_ALIAS(X509_LOOKUP_init); int X509_LOOKUP_shutdown(X509_LOOKUP *ctx) @@ -114,6 +117,7 @@ X509_LOOKUP_shutdown(X509_LOOKUP *ctx) return 1; return ctx->method->shutdown(ctx); } +LCRYPTO_ALIAS(X509_LOOKUP_shutdown); int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, @@ -125,6 +129,7 @@ X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, return 1; return ctx->method->ctrl(ctx, cmd, argc, argl, ret); } +LCRYPTO_ALIAS(X509_LOOKUP_ctrl); int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, X509_NAME *name, @@ -134,6 +139,7 @@ X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, X509_NAME *name, return 0; return ctx->method->get_by_subject(ctx, type, name, ret); } +LCRYPTO_ALIAS(X509_LOOKUP_by_subject); int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, @@ -143,6 +149,7 @@ X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, return 0; return ctx->method->get_by_issuer_serial(ctx, type, name, serial, ret); } +LCRYPTO_ALIAS(X509_LOOKUP_by_issuer_serial); int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, @@ -152,6 +159,7 @@ X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, return 0; return ctx->method->get_by_fingerprint(ctx, type, bytes, len, ret); } +LCRYPTO_ALIAS(X509_LOOKUP_by_fingerprint); int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const char *str, @@ -161,6 +169,7 @@ X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, const char *str, return 0; return ctx->method->get_by_alias(ctx, type, str, len, ret); } +LCRYPTO_ALIAS(X509_LOOKUP_by_alias); static int x509_object_cmp(const X509_OBJECT * const *a, const X509_OBJECT * const *b) @@ -208,6 +217,7 @@ X509_STORE_new(void) return NULL; } +LCRYPTO_ALIAS(X509_STORE_new); X509_OBJECT * X509_OBJECT_new(void) @@ -223,6 +233,7 @@ X509_OBJECT_new(void) return obj; } +LCRYPTO_ALIAS(X509_OBJECT_new); void X509_OBJECT_free(X509_OBJECT *a) @@ -241,6 +252,7 @@ X509_OBJECT_free(X509_OBJECT *a) free(a); } +LCRYPTO_ALIAS(X509_OBJECT_free); void X509_STORE_free(X509_STORE *store) @@ -268,12 +280,14 @@ X509_STORE_free(X509_STORE *store) X509_VERIFY_PARAM_free(store->param); free(store); } +LCRYPTO_ALIAS(X509_STORE_free); int X509_STORE_up_ref(X509_STORE *store) { return CRYPTO_add(&store->references, 1, CRYPTO_LOCK_X509_STORE) > 1; } +LCRYPTO_ALIAS(X509_STORE_up_ref); X509_LOOKUP * X509_STORE_add_lookup(X509_STORE *store, X509_LOOKUP_METHOD *method) @@ -302,6 +316,7 @@ X509_STORE_add_lookup(X509_STORE *store, X509_LOOKUP_METHOD *method) return lu; } +LCRYPTO_ALIAS(X509_STORE_add_lookup); X509_OBJECT * X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type, @@ -318,6 +333,7 @@ X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type, return obj; } +LCRYPTO_ALIAS(X509_STORE_CTX_get_obj_by_subject); int X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type, @@ -356,6 +372,7 @@ X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type, return 1; } +LCRYPTO_ALIAS(X509_STORE_CTX_get_by_subject); /* Add obj to the store. Takes ownership of obj. */ static int @@ -407,6 +424,7 @@ X509_STORE_add_cert(X509_STORE *store, X509 *x) return X509_STORE_add_object(store, obj); } +LCRYPTO_ALIAS(X509_STORE_add_cert); int X509_STORE_add_crl(X509_STORE *store, X509_CRL *x) @@ -429,6 +447,7 @@ X509_STORE_add_crl(X509_STORE *store, X509_CRL *x) return X509_STORE_add_object(store, obj); } +LCRYPTO_ALIAS(X509_STORE_add_crl); int X509_OBJECT_up_ref_count(X509_OBJECT *a) @@ -441,12 +460,14 @@ X509_OBJECT_up_ref_count(X509_OBJECT *a) } return 1; } +LCRYPTO_ALIAS(X509_OBJECT_up_ref_count); X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a) { return a->type; } +LCRYPTO_ALIAS(X509_OBJECT_get_type); static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type, @@ -498,6 +519,7 @@ X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type, { return x509_object_idx_cnt(h, type, name, NULL); } +LCRYPTO_ALIAS(X509_OBJECT_idx_by_subject); X509_OBJECT * X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type, @@ -510,6 +532,7 @@ X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type, return NULL; return sk_X509_OBJECT_value(h, idx); } +LCRYPTO_ALIAS(X509_OBJECT_retrieve_by_subject); X509 * X509_OBJECT_get0_X509(const X509_OBJECT *xo) @@ -518,6 +541,7 @@ X509_OBJECT_get0_X509(const X509_OBJECT *xo) return xo->data.x509; return NULL; } +LCRYPTO_ALIAS(X509_OBJECT_get0_X509); X509_CRL * X509_OBJECT_get0_X509_CRL(X509_OBJECT *xo) @@ -526,6 +550,7 @@ X509_OBJECT_get0_X509_CRL(X509_OBJECT *xo) return xo->data.crl; return NULL; } +LCRYPTO_ALIAS(X509_OBJECT_get0_X509_CRL); static STACK_OF(X509) * X509_get1_certs_from_cache(X509_STORE *store, X509_NAME *name) @@ -589,6 +614,7 @@ X509_STORE_get1_certs(X509_STORE_CTX *ctx, X509_NAME *name) return X509_get1_certs_from_cache(store, name); } +LCRYPTO_ALIAS(X509_STORE_get1_certs); STACK_OF(X509_CRL) * X509_STORE_get1_crls(X509_STORE_CTX *ctx, X509_NAME *name) @@ -639,6 +665,7 @@ X509_STORE_get1_crls(X509_STORE_CTX *ctx, X509_NAME *name) sk_X509_CRL_pop_free(sk, X509_CRL_free); return NULL; } +LCRYPTO_ALIAS(X509_STORE_get1_crls); X509_OBJECT * X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x) @@ -667,6 +694,7 @@ X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, X509_OBJECT *x) } return NULL; } +LCRYPTO_ALIAS(X509_OBJECT_retrieve_match); /* Try to get issuer certificate from store. Due to limitations * of the API this can only retrieve a single certificate matching @@ -757,30 +785,35 @@ X509_STORE_CTX_get1_issuer(X509 **out_issuer, X509_STORE_CTX *ctx, X509 *x) CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE); return ret; } +LCRYPTO_ALIAS(X509_STORE_CTX_get1_issuer); STACK_OF(X509_OBJECT) * X509_STORE_get0_objects(X509_STORE *xs) { return xs->objs; } +LCRYPTO_ALIAS(X509_STORE_get0_objects); void * X509_STORE_get_ex_data(X509_STORE *xs, int idx) { return CRYPTO_get_ex_data(&xs->ex_data, idx); } +LCRYPTO_ALIAS(X509_STORE_get_ex_data); int X509_STORE_set_ex_data(X509_STORE *xs, int idx, void *data) { return CRYPTO_set_ex_data(&xs->ex_data, idx, data); } +LCRYPTO_ALIAS(X509_STORE_set_ex_data); int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags) { return X509_VERIFY_PARAM_set_flags(ctx->param, flags); } +LCRYPTO_ALIAS(X509_STORE_set_flags); int X509_STORE_set_depth(X509_STORE *ctx, int depth) @@ -788,51 +821,60 @@ X509_STORE_set_depth(X509_STORE *ctx, int depth) X509_VERIFY_PARAM_set_depth(ctx->param, depth); return 1; } +LCRYPTO_ALIAS(X509_STORE_set_depth); int X509_STORE_set_purpose(X509_STORE *ctx, int purpose) { return X509_VERIFY_PARAM_set_purpose(ctx->param, purpose); } +LCRYPTO_ALIAS(X509_STORE_set_purpose); int X509_STORE_set_trust(X509_STORE *ctx, int trust) { return X509_VERIFY_PARAM_set_trust(ctx->param, trust); } +LCRYPTO_ALIAS(X509_STORE_set_trust); int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *param) { return X509_VERIFY_PARAM_set1(ctx->param, param); } +LCRYPTO_ALIAS(X509_STORE_set1_param); X509_VERIFY_PARAM * X509_STORE_get0_param(X509_STORE *ctx) { return ctx->param; } +LCRYPTO_ALIAS(X509_STORE_get0_param); void X509_STORE_set_verify(X509_STORE *store, X509_STORE_CTX_verify_fn verify) { store->verify = verify; } +LCRYPTO_ALIAS(X509_STORE_set_verify); X509_STORE_CTX_verify_fn X509_STORE_get_verify(X509_STORE *store) { return store->verify; } +LCRYPTO_ALIAS(X509_STORE_get_verify); void X509_STORE_set_verify_cb(X509_STORE *store, X509_STORE_CTX_verify_cb verify_cb) { store->verify_cb = verify_cb; } +LCRYPTO_ALIAS(X509_STORE_set_verify_cb); X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(X509_STORE *store) { return store->verify_cb; } +LCRYPTO_ALIAS(X509_STORE_get_verify_cb); diff --git a/crypto/x509/x509_ncons.c b/crypto/x509/x509_ncons.c index 61352700..159e3c25 100644 --- a/crypto/x509/x509_ncons.c +++ b/crypto/x509/x509_ncons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_ncons.c,v 1.5 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509_ncons.c,v 1.9 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -64,7 +64,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); @@ -165,24 +165,28 @@ GENERAL_SUBTREE_new(void) { return (GENERAL_SUBTREE*)ASN1_item_new(&GENERAL_SUBTREE_it); } +LCRYPTO_ALIAS(GENERAL_SUBTREE_new); void GENERAL_SUBTREE_free(GENERAL_SUBTREE *a) { ASN1_item_free((ASN1_VALUE *)a, &GENERAL_SUBTREE_it); } +LCRYPTO_ALIAS(GENERAL_SUBTREE_free); NAME_CONSTRAINTS * NAME_CONSTRAINTS_new(void) { return (NAME_CONSTRAINTS*)ASN1_item_new(&NAME_CONSTRAINTS_it); } +LCRYPTO_ALIAS(NAME_CONSTRAINTS_new); void NAME_CONSTRAINTS_free(NAME_CONSTRAINTS *a) { ASN1_item_free((ASN1_VALUE *)a, &NAME_CONSTRAINTS_it); } +LCRYPTO_ALIAS(NAME_CONSTRAINTS_free); static void * v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx, @@ -349,6 +353,7 @@ NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc) } return X509_V_OK; } +LCRYPTO_ALIAS(NAME_CONSTRAINTS_check); static int nc_match(GENERAL_NAME *gen, NAME_CONSTRAINTS *nc) { @@ -477,7 +482,7 @@ nc_email(ASN1_IA5STRING *eml, ASN1_IA5STRING *base) if (!emlat) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; - /* Special case: inital '.' is RHS match */ + /* Special case: initial '.' is RHS match */ if (!baseat && (*baseptr == '.')) { if (eml->length > base->length) { emlptr += eml->length - base->length; @@ -538,7 +543,7 @@ nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) if (hostlen == 0) return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; - /* Special case: inital '.' is RHS match */ + /* Special case: initial '.' is RHS match */ if (*baseptr == '.') { if (hostlen > base->length) { p = hostptr + hostlen - base->length; diff --git a/crypto/x509/x509_obj.c b/crypto/x509/x509_obj.c index 58ffa3a2..ea4ae6b9 100644 --- a/crypto/x509/x509_obj.c +++ b/crypto/x509/x509_obj.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_obj.c,v 1.19 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509_obj.c,v 1.22 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,7 +65,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" char * X509_NAME_oneline(const X509_NAME *a, char *buf, int len) @@ -179,3 +179,4 @@ X509_NAME_oneline(const X509_NAME *a, char *buf, int len) BUF_MEM_free(b); return (NULL); } +LCRYPTO_ALIAS(X509_NAME_oneline); diff --git a/crypto/x509/x509_pcia.c b/crypto/x509/x509_pcia.c index b639aa33..ec8d03a8 100644 --- a/crypto/x509/x509_pcia.c +++ b/crypto/x509/x509_pcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_pcia.c,v 1.1 2020/06/04 15:19:32 jsing Exp $ */ +/* $OpenBSD: x509_pcia.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Contributed to the OpenSSL Project 2004 * by Richard Levitte (richard@levitte.org) */ @@ -72,24 +72,28 @@ d2i_PROXY_POLICY(PROXY_POLICY **a, const unsigned char **in, long len) return (PROXY_POLICY *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PROXY_POLICY_it); } +LCRYPTO_ALIAS(d2i_PROXY_POLICY); int i2d_PROXY_POLICY(PROXY_POLICY *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PROXY_POLICY_it); } +LCRYPTO_ALIAS(i2d_PROXY_POLICY); PROXY_POLICY * PROXY_POLICY_new(void) { return (PROXY_POLICY *)ASN1_item_new(&PROXY_POLICY_it); } +LCRYPTO_ALIAS(PROXY_POLICY_new); void PROXY_POLICY_free(PROXY_POLICY *a) { ASN1_item_free((ASN1_VALUE *)a, &PROXY_POLICY_it); } +LCRYPTO_ALIAS(PROXY_POLICY_free); static const ASN1_TEMPLATE PROXY_CERT_INFO_EXTENSION_seq_tt[] = { { @@ -125,21 +129,25 @@ d2i_PROXY_CERT_INFO_EXTENSION(PROXY_CERT_INFO_EXTENSION **a, const unsigned char return (PROXY_CERT_INFO_EXTENSION *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PROXY_CERT_INFO_EXTENSION_it); } +LCRYPTO_ALIAS(d2i_PROXY_CERT_INFO_EXTENSION); int i2d_PROXY_CERT_INFO_EXTENSION(PROXY_CERT_INFO_EXTENSION *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PROXY_CERT_INFO_EXTENSION_it); } +LCRYPTO_ALIAS(i2d_PROXY_CERT_INFO_EXTENSION); PROXY_CERT_INFO_EXTENSION * PROXY_CERT_INFO_EXTENSION_new(void) { return (PROXY_CERT_INFO_EXTENSION *)ASN1_item_new(&PROXY_CERT_INFO_EXTENSION_it); } +LCRYPTO_ALIAS(PROXY_CERT_INFO_EXTENSION_new); void PROXY_CERT_INFO_EXTENSION_free(PROXY_CERT_INFO_EXTENSION *a) { ASN1_item_free((ASN1_VALUE *)a, &PROXY_CERT_INFO_EXTENSION_it); } +LCRYPTO_ALIAS(PROXY_CERT_INFO_EXTENSION_free); diff --git a/crypto/x509/x509_pcons.c b/crypto/x509/x509_pcons.c index 69bf4337..0ee93554 100644 --- a/crypto/x509/x509_pcons.c +++ b/crypto/x509/x509_pcons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_pcons.c,v 1.1 2020/06/04 15:19:32 jsing Exp $ */ +/* $OpenBSD: x509_pcons.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -121,12 +121,14 @@ POLICY_CONSTRAINTS_new(void) { return (POLICY_CONSTRAINTS*)ASN1_item_new(&POLICY_CONSTRAINTS_it); } +LCRYPTO_ALIAS(POLICY_CONSTRAINTS_new); void POLICY_CONSTRAINTS_free(POLICY_CONSTRAINTS *a) { ASN1_item_free((ASN1_VALUE *)a, &POLICY_CONSTRAINTS_it); } +LCRYPTO_ALIAS(POLICY_CONSTRAINTS_free); static STACK_OF(CONF_VALUE) * i2v_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method, void *a, diff --git a/crypto/x509/x509_pku.c b/crypto/x509/x509_pku.c index 9b82ad3d..dd28077d 100644 --- a/crypto/x509/x509_pku.c +++ b/crypto/x509/x509_pku.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_pku.c,v 1.1 2020/06/04 15:19:32 jsing Exp $ */ +/* $OpenBSD: x509_pku.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -116,24 +116,28 @@ d2i_PKEY_USAGE_PERIOD(PKEY_USAGE_PERIOD **a, const unsigned char **in, long len) return (PKEY_USAGE_PERIOD *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &PKEY_USAGE_PERIOD_it); } +LCRYPTO_ALIAS(d2i_PKEY_USAGE_PERIOD); int i2d_PKEY_USAGE_PERIOD(PKEY_USAGE_PERIOD *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &PKEY_USAGE_PERIOD_it); } +LCRYPTO_ALIAS(i2d_PKEY_USAGE_PERIOD); PKEY_USAGE_PERIOD * PKEY_USAGE_PERIOD_new(void) { return (PKEY_USAGE_PERIOD *)ASN1_item_new(&PKEY_USAGE_PERIOD_it); } +LCRYPTO_ALIAS(PKEY_USAGE_PERIOD_new); void PKEY_USAGE_PERIOD_free(PKEY_USAGE_PERIOD *a) { ASN1_item_free((ASN1_VALUE *)a, &PKEY_USAGE_PERIOD_it); } +LCRYPTO_ALIAS(PKEY_USAGE_PERIOD_free); static int i2r_PKEY_USAGE_PERIOD(X509V3_EXT_METHOD *method, PKEY_USAGE_PERIOD *usage, diff --git a/crypto/x509/x509_pmaps.c b/crypto/x509/x509_pmaps.c index 352f85a0..39aebfee 100644 --- a/crypto/x509/x509_pmaps.c +++ b/crypto/x509/x509_pmaps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_pmaps.c,v 1.1 2020/06/04 15:19:32 jsing Exp $ */ +/* $OpenBSD: x509_pmaps.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -137,12 +137,14 @@ POLICY_MAPPING_new(void) { return (POLICY_MAPPING*)ASN1_item_new(&POLICY_MAPPING_it); } +LCRYPTO_ALIAS(POLICY_MAPPING_new); void POLICY_MAPPING_free(POLICY_MAPPING *a) { ASN1_item_free((ASN1_VALUE *)a, &POLICY_MAPPING_it); } +LCRYPTO_ALIAS(POLICY_MAPPING_free); static STACK_OF(CONF_VALUE) * i2v_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method, void *a, diff --git a/crypto/x509/x509_prn.c b/crypto/x509/x509_prn.c index 4977051d..2d7afb9f 100644 --- a/crypto/x509/x509_prn.c +++ b/crypto/x509/x509_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_prn.c,v 1.2 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509_prn.c,v 1.5 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -62,7 +62,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" /* Extension printing routines */ @@ -99,6 +99,7 @@ X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, int ml) BIO_puts(out, "\n"); } } +LCRYPTO_ALIAS(X509V3_EXT_val_prn); /* Main routine: print out a general extension */ @@ -152,6 +153,7 @@ X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, int indent) method->ext_free(ext_str); return ok; } +LCRYPTO_ALIAS(X509V3_EXT_print); int X509V3_extensions_print(BIO *bp, const char *title, @@ -187,6 +189,7 @@ X509V3_extensions_print(BIO *bp, const char *title, } return 1; } +LCRYPTO_ALIAS(X509V3_extensions_print); static int unknown_ext_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, @@ -225,3 +228,4 @@ X509V3_EXT_print_fp(FILE *fp, X509_EXTENSION *ext, int flag, int indent) BIO_free(bio_tmp); return ret; } +LCRYPTO_ALIAS(X509V3_EXT_print_fp); diff --git a/crypto/x509/x509_purp.c b/crypto/x509/x509_purp.c index ab5e7cb3..176d9d67 100644 --- a/crypto/x509/x509_purp.c +++ b/crypto/x509/x509_purp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_purp.c,v 1.16 2022/05/10 19:42:52 tb Exp $ */ +/* $OpenBSD: x509_purp.c,v 1.21 2023/02/16 10:18:59 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -66,7 +66,7 @@ #include #include "x509_internal.h" -#include "x509_lcl.h" +#include "x509_local.h" #define V1_ROOT (EXFLAG_V1|EXFLAG_SS) #define ku_reject(x, usage) \ @@ -76,8 +76,6 @@ #define ns_reject(x, usage) \ (((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage))) -void x509v3_cache_extensions(X509 *x); - static int check_ssl_ca(const X509 *x); static int check_purpose_ssl_client(const X509_PURPOSE *xp, const X509 *x, int ca); @@ -131,13 +129,9 @@ X509_check_purpose(X509 *x, int id, int ca) int idx; const X509_PURPOSE *pt; - if (!(x->ex_flags & EXFLAG_SET)) { - CRYPTO_w_lock(CRYPTO_LOCK_X509); - x509v3_cache_extensions(x); - CRYPTO_w_unlock(CRYPTO_LOCK_X509); - if (x->ex_flags & EXFLAG_INVALID) - return -1; - } + if (!x509v3_cache_extensions(x)) + return -1; + if (id == -1) return 1; idx = X509_PURPOSE_get_by_id(id); @@ -146,6 +140,7 @@ X509_check_purpose(X509 *x, int id, int ca) pt = X509_PURPOSE_get0(idx); return pt->check_purpose(pt, x, ca); } +LCRYPTO_ALIAS(X509_check_purpose); int X509_PURPOSE_set(int *p, int purpose) @@ -157,6 +152,7 @@ X509_PURPOSE_set(int *p, int purpose) *p = purpose; return 1; } +LCRYPTO_ALIAS(X509_PURPOSE_set); int X509_PURPOSE_get_count(void) @@ -165,6 +161,7 @@ X509_PURPOSE_get_count(void) return X509_PURPOSE_COUNT; return sk_X509_PURPOSE_num(xptable) + X509_PURPOSE_COUNT; } +LCRYPTO_ALIAS(X509_PURPOSE_get_count); X509_PURPOSE * X509_PURPOSE_get0(int idx) @@ -175,6 +172,7 @@ X509_PURPOSE_get0(int idx) return xstandard + idx; return sk_X509_PURPOSE_value(xptable, idx - X509_PURPOSE_COUNT); } +LCRYPTO_ALIAS(X509_PURPOSE_get0); int X509_PURPOSE_get_by_sname(const char *sname) @@ -189,6 +187,7 @@ X509_PURPOSE_get_by_sname(const char *sname) } return -1; } +LCRYPTO_ALIAS(X509_PURPOSE_get_by_sname); int X509_PURPOSE_get_by_id(int purpose) @@ -206,6 +205,7 @@ X509_PURPOSE_get_by_id(int purpose) return -1; return idx + X509_PURPOSE_COUNT; } +LCRYPTO_ALIAS(X509_PURPOSE_get_by_id); int X509_PURPOSE_add(int id, int trust, int flags, @@ -280,6 +280,7 @@ X509_PURPOSE_add(int id, int trust, int flags, X509V3error(ERR_R_MALLOC_FAILURE); return 0; } +LCRYPTO_ALIAS(X509_PURPOSE_add); static void xptable_free(X509_PURPOSE *p) @@ -301,30 +302,35 @@ X509_PURPOSE_cleanup(void) sk_X509_PURPOSE_pop_free(xptable, xptable_free); xptable = NULL; } +LCRYPTO_ALIAS(X509_PURPOSE_cleanup); int X509_PURPOSE_get_id(const X509_PURPOSE *xp) { return xp->purpose; } +LCRYPTO_ALIAS(X509_PURPOSE_get_id); char * X509_PURPOSE_get0_name(const X509_PURPOSE *xp) { return xp->name; } +LCRYPTO_ALIAS(X509_PURPOSE_get0_name); char * X509_PURPOSE_get0_sname(const X509_PURPOSE *xp) { return xp->sname; } +LCRYPTO_ALIAS(X509_PURPOSE_get0_sname); int X509_PURPOSE_get_trust(const X509_PURPOSE *xp) { return xp->trust; } +LCRYPTO_ALIAS(X509_PURPOSE_get_trust); static int nid_cmp(const int *a, const int *b) @@ -390,6 +396,7 @@ X509_supported_extension(X509_EXTENSION *ex) return 1; return 0; } +LCRYPTO_ALIAS(X509_supported_extension); static void setup_dp(X509 *x, DIST_POINT *dp) @@ -418,7 +425,6 @@ setup_dp(X509 *x, DIST_POINT *dp) iname = X509_get_issuer_name(x); DIST_POINT_set_dpname(dp->distpoint, iname); - } static void @@ -436,8 +442,8 @@ setup_crldp(X509 *x) setup_dp(x, sk_DIST_POINT_value(x->crldp, i)); } -void -x509v3_cache_extensions(X509 *x) +static void +x509v3_cache_extensions_internal(X509 *x) { BASIC_CONSTRAINTS *bs; PROXY_CERT_INFO_EXTENSION *pci; @@ -627,6 +633,18 @@ x509v3_cache_extensions(X509 *x) x->ex_flags |= EXFLAG_SET; } +int +x509v3_cache_extensions(X509 *x) +{ + if ((x->ex_flags & EXFLAG_SET) == 0) { + CRYPTO_w_lock(CRYPTO_LOCK_X509); + x509v3_cache_extensions_internal(x); + CRYPTO_w_unlock(CRYPTO_LOCK_X509); + } + + return (x->ex_flags & EXFLAG_INVALID) == 0; +} + /* CA checks common to all purposes * return codes: * 0 not a CA @@ -667,14 +685,11 @@ check_ca(const X509 *x) int X509_check_ca(X509 *x) { - if (!(x->ex_flags & EXFLAG_SET)) { - CRYPTO_w_lock(CRYPTO_LOCK_X509); - x509v3_cache_extensions(x); - CRYPTO_w_unlock(CRYPTO_LOCK_X509); - } + x509v3_cache_extensions(x); return check_ca(x); } +LCRYPTO_ALIAS(X509_check_ca); /* Check SSL CA: common checks for SSL client and server */ static int @@ -881,19 +896,10 @@ X509_check_issued(X509 *issuer, X509 *subject) if (X509_NAME_cmp(X509_get_subject_name(issuer), X509_get_issuer_name(subject))) return X509_V_ERR_SUBJECT_ISSUER_MISMATCH; - if (!(issuer->ex_flags & EXFLAG_SET)) { - CRYPTO_w_lock(CRYPTO_LOCK_X509); - x509v3_cache_extensions(issuer); - CRYPTO_w_unlock(CRYPTO_LOCK_X509); - } - if (issuer->ex_flags & EXFLAG_INVALID) + + if (!x509v3_cache_extensions(issuer)) return X509_V_ERR_UNSPECIFIED; - if (!(subject->ex_flags & EXFLAG_SET)) { - CRYPTO_w_lock(CRYPTO_LOCK_X509); - x509v3_cache_extensions(subject); - CRYPTO_w_unlock(CRYPTO_LOCK_X509); - } - if (subject->ex_flags & EXFLAG_INVALID) + if (!x509v3_cache_extensions(subject)) return X509_V_ERR_UNSPECIFIED; if (subject->akid) { @@ -909,6 +915,7 @@ X509_check_issued(X509 *issuer, X509 *subject) return X509_V_ERR_KEYUSAGE_NO_CERTSIGN; return X509_V_OK; } +LCRYPTO_ALIAS(X509_check_issued); int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid) @@ -948,6 +955,7 @@ X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid) } return X509_V_OK; } +LCRYPTO_ALIAS(X509_check_akid); uint32_t X509_get_extension_flags(X509 *x) @@ -958,6 +966,7 @@ X509_get_extension_flags(X509 *x) return x->ex_flags; } +LCRYPTO_ALIAS(X509_get_extension_flags); uint32_t X509_get_key_usage(X509 *x) @@ -971,6 +980,7 @@ X509_get_key_usage(X509 *x) return UINT32_MAX; } +LCRYPTO_ALIAS(X509_get_key_usage); uint32_t X509_get_extended_key_usage(X509 *x) @@ -984,3 +994,4 @@ X509_get_extended_key_usage(X509 *x) return UINT32_MAX; } +LCRYPTO_ALIAS(X509_get_extended_key_usage); diff --git a/crypto/x509/x509_r2x.c b/crypto/x509/x509_r2x.c index b3b8aa75..99c423d8 100644 --- a/crypto/x509/x509_r2x.c +++ b/crypto/x509/x509_r2x.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_r2x.c,v 1.13 2021/11/03 14:36:21 schwarze Exp $ */ +/* $OpenBSD: x509_r2x.c,v 1.16 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,7 +66,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" X509 * X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey) @@ -116,3 +116,4 @@ X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey) X509_free(ret); return NULL; } +LCRYPTO_ALIAS(X509_REQ_to_X509); diff --git a/crypto/x509/x509_req.c b/crypto/x509/x509_req.c index c0a2a64a..0fea7e68 100644 --- a/crypto/x509/x509_req.c +++ b/crypto/x509/x509_req.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_req.c,v 1.29 2022/08/18 16:26:33 tb Exp $ */ +/* $OpenBSD: x509_req.c,v 1.32 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -70,8 +70,8 @@ #include #include -#include "evp_locl.h" -#include "x509_lcl.h" +#include "evp_local.h" +#include "x509_local.h" X509_REQ * X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) @@ -115,6 +115,7 @@ X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) X509_REQ_free(ret); return (NULL); } +LCRYPTO_ALIAS(X509_to_X509_REQ); EVP_PKEY * X509_REQ_get_pubkey(X509_REQ *req) @@ -123,6 +124,7 @@ X509_REQ_get_pubkey(X509_REQ *req) return (NULL); return (X509_PUBKEY_get(req->req_info->pubkey)); } +LCRYPTO_ALIAS(X509_REQ_get_pubkey); EVP_PKEY * X509_REQ_get0_pubkey(X509_REQ *req) @@ -131,6 +133,7 @@ X509_REQ_get0_pubkey(X509_REQ *req) return NULL; return X509_PUBKEY_get0(req->req_info->pubkey); } +LCRYPTO_ALIAS(X509_REQ_get0_pubkey); int X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k) @@ -170,6 +173,7 @@ X509_REQ_check_private_key(X509_REQ *x, EVP_PKEY *k) return (ok); } +LCRYPTO_ALIAS(X509_REQ_check_private_key); /* It seems several organisations had the same idea of including a list of * extensions in a certificate request. There are at least two OIDs that are @@ -193,18 +197,21 @@ X509_REQ_extension_nid(int req_nid) return 1; } } +LCRYPTO_ALIAS(X509_REQ_extension_nid); int * X509_REQ_get_extension_nids(void) { return ext_nids; } +LCRYPTO_ALIAS(X509_REQ_get_extension_nids); void X509_REQ_set_extension_nids(int *nids) { ext_nids = nids; } +LCRYPTO_ALIAS(X509_REQ_set_extension_nids); STACK_OF(X509_EXTENSION) * X509_REQ_get_extensions(X509_REQ *req) @@ -231,6 +238,7 @@ X509_REQ_get_extensions(X509_REQ *req) p = ext->value.sequence->data; return d2i_X509_EXTENSIONS(NULL, &p, ext->value.sequence->length); } +LCRYPTO_ALIAS(X509_REQ_get_extensions); /* * Add a STACK_OF extensions to a certificate request: allow alternative OIDs @@ -254,6 +262,7 @@ X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, return rv; } +LCRYPTO_ALIAS(X509_REQ_add_extensions_nid); /* This is the normal usage: use the "official" OID */ int @@ -261,6 +270,7 @@ X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts) { return X509_REQ_add_extensions_nid(req, exts, NID_ext_req); } +LCRYPTO_ALIAS(X509_REQ_add_extensions); /* Request attribute functions */ @@ -269,12 +279,14 @@ X509_REQ_get_attr_count(const X509_REQ *req) { return X509at_get_attr_count(req->req_info->attributes); } +LCRYPTO_ALIAS(X509_REQ_get_attr_count); int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos) { return X509at_get_attr_by_NID(req->req_info->attributes, nid, lastpos); } +LCRYPTO_ALIAS(X509_REQ_get_attr_by_NID); int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj, @@ -282,18 +294,21 @@ X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj, { return X509at_get_attr_by_OBJ(req->req_info->attributes, obj, lastpos); } +LCRYPTO_ALIAS(X509_REQ_get_attr_by_OBJ); X509_ATTRIBUTE * X509_REQ_get_attr(const X509_REQ *req, int loc) { return X509at_get_attr(req->req_info->attributes, loc); } +LCRYPTO_ALIAS(X509_REQ_get_attr); X509_ATTRIBUTE * X509_REQ_delete_attr(X509_REQ *req, int loc) { return X509at_delete_attr(req->req_info->attributes, loc); } +LCRYPTO_ALIAS(X509_REQ_delete_attr); int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr) @@ -302,6 +317,7 @@ X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr) return 1; return 0; } +LCRYPTO_ALIAS(X509_REQ_add1_attr); int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, const ASN1_OBJECT *obj, int type, @@ -312,6 +328,7 @@ X509_REQ_add1_attr_by_OBJ(X509_REQ *req, const ASN1_OBJECT *obj, int type, return 1; return 0; } +LCRYPTO_ALIAS(X509_REQ_add1_attr_by_OBJ); int X509_REQ_add1_attr_by_NID(X509_REQ *req, int nid, int type, @@ -322,6 +339,7 @@ X509_REQ_add1_attr_by_NID(X509_REQ *req, int nid, int type, return 1; return 0; } +LCRYPTO_ALIAS(X509_REQ_add1_attr_by_NID); int X509_REQ_add1_attr_by_txt(X509_REQ *req, const char *attrname, int type, @@ -332,6 +350,7 @@ X509_REQ_add1_attr_by_txt(X509_REQ *req, const char *attrname, int type, return 1; return 0; } +LCRYPTO_ALIAS(X509_REQ_add1_attr_by_txt); int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp) @@ -339,3 +358,4 @@ i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp) req->req_info->enc.modified = 1; return i2d_X509_REQ_INFO(req->req_info, pp); } +LCRYPTO_ALIAS(i2d_re_X509_REQ_tbs); diff --git a/crypto/x509/x509_set.c b/crypto/x509/x509_set.c index 5784f220..19e0f2b5 100644 --- a/crypto/x509/x509_set.c +++ b/crypto/x509/x509_set.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_set.c,v 1.20 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509_set.c,v 1.24 2023/02/23 18:12:32 job Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,19 +63,21 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" const STACK_OF(X509_EXTENSION) * X509_get0_extensions(const X509 *x) { return x->cert_info->extensions; } +LCRYPTO_ALIAS(X509_get0_extensions); const X509_ALGOR * X509_get0_tbs_sigalg(const X509 *x) { return x->cert_info->signature; } +LCRYPTO_ALIAS(X509_get0_tbs_sigalg); int X509_set_version(X509 *x, long version) @@ -88,12 +90,14 @@ X509_set_version(X509 *x, long version) } return (ASN1_INTEGER_set(x->cert_info->version, version)); } +LCRYPTO_ALIAS(X509_set_version); long X509_get_version(const X509 *x) { return ASN1_INTEGER_get(x->cert_info->version); } +LCRYPTO_ALIAS(X509_get_version); int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) @@ -112,6 +116,7 @@ X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial) } return (in != NULL); } +LCRYPTO_ALIAS(X509_set_serialNumber); int X509_set_issuer_name(X509 *x, X509_NAME *name) @@ -120,6 +125,7 @@ X509_set_issuer_name(X509 *x, X509_NAME *name) return (0); return (X509_NAME_set(&x->cert_info->issuer, name)); } +LCRYPTO_ALIAS(X509_set_issuer_name); int X509_set_subject_name(X509 *x, X509_NAME *name) @@ -128,12 +134,14 @@ X509_set_subject_name(X509 *x, X509_NAME *name) return (0); return (X509_NAME_set(&x->cert_info->subject, name)); } +LCRYPTO_ALIAS(X509_set_subject_name); const ASN1_TIME * X509_get0_notBefore(const X509 *x) { return X509_getm_notBefore(x); } +LCRYPTO_ALIAS(X509_get0_notBefore); ASN1_TIME * X509_getm_notBefore(const X509 *x) @@ -142,6 +150,7 @@ X509_getm_notBefore(const X509 *x) return (NULL); return x->cert_info->validity->notBefore; } +LCRYPTO_ALIAS(X509_getm_notBefore); int X509_set_notBefore(X509 *x, const ASN1_TIME *tm) @@ -160,18 +169,21 @@ X509_set_notBefore(X509 *x, const ASN1_TIME *tm) } return (in != NULL); } +LCRYPTO_ALIAS(X509_set_notBefore); int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm) { return X509_set_notBefore(x, tm); } +LCRYPTO_ALIAS(X509_set1_notBefore); const ASN1_TIME * X509_get0_notAfter(const X509 *x) { return X509_getm_notAfter(x); } +LCRYPTO_ALIAS(X509_get0_notAfter); ASN1_TIME * X509_getm_notAfter(const X509 *x) @@ -180,6 +192,7 @@ X509_getm_notAfter(const X509 *x) return (NULL); return x->cert_info->validity->notAfter; } +LCRYPTO_ALIAS(X509_getm_notAfter); int X509_set_notAfter(X509 *x, const ASN1_TIME *tm) @@ -198,12 +211,14 @@ X509_set_notAfter(X509 *x, const ASN1_TIME *tm) } return (in != NULL); } +LCRYPTO_ALIAS(X509_set_notAfter); int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm) { return X509_set_notAfter(x, tm); } +LCRYPTO_ALIAS(X509_set1_notAfter); int X509_set_pubkey(X509 *x, EVP_PKEY *pkey) @@ -212,15 +227,29 @@ X509_set_pubkey(X509 *x, EVP_PKEY *pkey) return (0); return (X509_PUBKEY_set(&(x->cert_info->key), pkey)); } +LCRYPTO_ALIAS(X509_set_pubkey); int X509_get_signature_type(const X509 *x) { return EVP_PKEY_type(OBJ_obj2nid(x->sig_alg->algorithm)); } +LCRYPTO_ALIAS(X509_get_signature_type); X509_PUBKEY * X509_get_X509_PUBKEY(const X509 *x) { return x->cert_info->key; } +LCRYPTO_ALIAS(X509_get_X509_PUBKEY); + +void +X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid, + const ASN1_BIT_STRING **psuid) +{ + if (piuid != NULL) + *piuid = x->cert_info->issuerUID; + if (psuid != NULL) + *psuid = x->cert_info->subjectUID; +} +LCRYPTO_ALIAS(X509_get0_uids); diff --git a/crypto/x509/x509_skey.c b/crypto/x509/x509_skey.c index 58bb66bc..245ba515 100644 --- a/crypto/x509/x509_skey.c +++ b/crypto/x509/x509_skey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_skey.c,v 1.2 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509_skey.c,v 1.5 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -62,7 +62,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str); @@ -89,6 +89,7 @@ i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, const ASN1_OCTET_STRING *oct) { return hex_to_string(oct->data, oct->length); } +LCRYPTO_ALIAS(i2s_ASN1_OCTET_STRING); ASN1_OCTET_STRING * s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, @@ -111,6 +112,7 @@ s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, return oct; } +LCRYPTO_ALIAS(s2i_ASN1_OCTET_STRING); static ASN1_OCTET_STRING * s2i_skey_id(X509V3_EXT_METHOD *method, X509V3_CTX *ctx, char *str) diff --git a/crypto/x509/x509_sxnet.c b/crypto/x509/x509_sxnet.c index e5e98bce..77c792d2 100644 --- a/crypto/x509/x509_sxnet.c +++ b/crypto/x509/x509_sxnet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_sxnet.c,v 1.1 2020/06/04 15:19:32 jsing Exp $ */ +/* $OpenBSD: x509_sxnet.c,v 1.3 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -131,24 +131,28 @@ d2i_SXNETID(SXNETID **a, const unsigned char **in, long len) return (SXNETID *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &SXNETID_it); } +LCRYPTO_ALIAS(d2i_SXNETID); int i2d_SXNETID(SXNETID *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &SXNETID_it); } +LCRYPTO_ALIAS(i2d_SXNETID); SXNETID * SXNETID_new(void) { return (SXNETID *)ASN1_item_new(&SXNETID_it); } +LCRYPTO_ALIAS(SXNETID_new); void SXNETID_free(SXNETID *a) { ASN1_item_free((ASN1_VALUE *)a, &SXNETID_it); } +LCRYPTO_ALIAS(SXNETID_free); static const ASN1_TEMPLATE SXNET_seq_tt[] = { { @@ -184,24 +188,28 @@ d2i_SXNET(SXNET **a, const unsigned char **in, long len) return (SXNET *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, &SXNET_it); } +LCRYPTO_ALIAS(d2i_SXNET); int i2d_SXNET(SXNET *a, unsigned char **out) { return ASN1_item_i2d((ASN1_VALUE *)a, out, &SXNET_it); } +LCRYPTO_ALIAS(i2d_SXNET); SXNET * SXNET_new(void) { return (SXNET *)ASN1_item_new(&SXNET_it); } +LCRYPTO_ALIAS(SXNET_new); void SXNET_free(SXNET *a) { ASN1_item_free((ASN1_VALUE *)a, &SXNET_it); } +LCRYPTO_ALIAS(SXNET_free); static int sxnet_i2r(X509V3_EXT_METHOD *method, SXNET *sx, BIO *out, int indent) @@ -263,6 +271,7 @@ SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userlen) } return SXNET_add_id_INTEGER(psx, izone, user, userlen); } +LCRYPTO_ALIAS(SXNET_add_id_asc); /* Add an id given the zone as an unsigned long */ @@ -280,6 +289,7 @@ SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user, } return SXNET_add_id_INTEGER(psx, izone, user, userlen); } +LCRYPTO_ALIAS(SXNET_add_id_ulong); /* Add an id given the zone as an ASN1_INTEGER. * Note this version uses the passed integer and doesn't make a copy so don't @@ -335,6 +345,7 @@ SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *zone, const char *user, *psx = NULL; return 0; } +LCRYPTO_ALIAS(SXNET_add_id_INTEGER); ASN1_OCTET_STRING * SXNET_get_id_asc(SXNET *sx, const char *zone) @@ -350,6 +361,7 @@ SXNET_get_id_asc(SXNET *sx, const char *zone) ASN1_INTEGER_free(izone); return oct; } +LCRYPTO_ALIAS(SXNET_get_id_asc); ASN1_OCTET_STRING * SXNET_get_id_ulong(SXNET *sx, unsigned long lzone) @@ -367,6 +379,7 @@ SXNET_get_id_ulong(SXNET *sx, unsigned long lzone) ASN1_INTEGER_free(izone); return oct; } +LCRYPTO_ALIAS(SXNET_get_id_ulong); ASN1_OCTET_STRING * SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone) @@ -381,3 +394,4 @@ SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone) } return NULL; } +LCRYPTO_ALIAS(SXNET_get_id_INTEGER); diff --git a/crypto/x509/x509_trs.c b/crypto/x509/x509_trs.c index 72d616a1..e3265918 100644 --- a/crypto/x509/x509_trs.c +++ b/crypto/x509/x509_trs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_trs.c,v 1.25 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509_trs.c,v 1.31 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -62,7 +62,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" static int tr_cmp(const X509_TRUST * const *a, const X509_TRUST * const *b); static void trtable_free(X509_TRUST *p); @@ -109,6 +109,7 @@ int default_trust = trust; return oldtrust; } +LCRYPTO_ALIAS(X509_TRUST_set_default); int X509_check_trust(X509 *x, int id, int flags) @@ -140,6 +141,7 @@ X509_check_trust(X509 *x, int id, int flags) pt = X509_TRUST_get0(idx); return pt->check_trust(pt, x, flags); } +LCRYPTO_ALIAS(X509_check_trust); int X509_TRUST_get_count(void) @@ -148,6 +150,7 @@ X509_TRUST_get_count(void) return X509_TRUST_COUNT; return sk_X509_TRUST_num(trtable) + X509_TRUST_COUNT; } +LCRYPTO_ALIAS(X509_TRUST_get_count); X509_TRUST * X509_TRUST_get0(int idx) @@ -158,6 +161,7 @@ X509_TRUST_get0(int idx) return trstandard + idx; return sk_X509_TRUST_value(trtable, idx - X509_TRUST_COUNT); } +LCRYPTO_ALIAS(X509_TRUST_get0); int X509_TRUST_get_by_id(int id) @@ -175,6 +179,7 @@ X509_TRUST_get_by_id(int id) return -1; return idx + X509_TRUST_COUNT; } +LCRYPTO_ALIAS(X509_TRUST_get_by_id); int X509_TRUST_set(int *t, int trust) @@ -186,6 +191,7 @@ X509_TRUST_set(int *t, int trust) *t = trust; return 1; } +LCRYPTO_ALIAS(X509_TRUST_set); int X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), @@ -251,6 +257,7 @@ X509_TRUST_add(int id, int flags, int (*ck)(X509_TRUST *, X509 *, int), X509error(ERR_R_MALLOC_FAILURE); return 0; } +LCRYPTO_ALIAS(X509_TRUST_add); static void trtable_free(X509_TRUST *p) @@ -270,24 +277,28 @@ X509_TRUST_cleanup(void) sk_X509_TRUST_pop_free(trtable, trtable_free); trtable = NULL; } +LCRYPTO_ALIAS(X509_TRUST_cleanup); int X509_TRUST_get_flags(const X509_TRUST *xp) { return xp->flags; } +LCRYPTO_ALIAS(X509_TRUST_get_flags); char * X509_TRUST_get0_name(const X509_TRUST *xp) { return xp->name; } +LCRYPTO_ALIAS(X509_TRUST_get0_name); int X509_TRUST_get_trust(const X509_TRUST *xp) { return xp->trust; } +LCRYPTO_ALIAS(X509_TRUST_get_trust); static int trust_1oidany(X509_TRUST *trust, X509 *x, int flags) @@ -322,7 +333,7 @@ static int obj_trust(int id, X509 *x, int flags) { ASN1_OBJECT *obj; - int i; + int i, nid; X509_CERT_AUX *ax; ax = x->aux; @@ -331,14 +342,16 @@ obj_trust(int id, X509 *x, int flags) if (ax->reject) { for (i = 0; i < sk_ASN1_OBJECT_num(ax->reject); i++) { obj = sk_ASN1_OBJECT_value(ax->reject, i); - if (OBJ_obj2nid(obj) == id) + nid = OBJ_obj2nid(obj); + if (nid == id || nid == NID_anyExtendedKeyUsage) return X509_TRUST_REJECTED; } } if (ax->trust) { for (i = 0; i < sk_ASN1_OBJECT_num(ax->trust); i++) { obj = sk_ASN1_OBJECT_value(ax->trust, i); - if (OBJ_obj2nid(obj) == id) + nid = OBJ_obj2nid(obj); + if (nid == id || nid == NID_anyExtendedKeyUsage) return X509_TRUST_TRUSTED; } } diff --git a/crypto/x509/x509_txt.c b/crypto/x509/x509_txt.c index 2dfadf6b..5f5bc5ae 100644 --- a/crypto/x509/x509_txt.c +++ b/crypto/x509/x509_txt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_txt.c,v 1.20 2022/07/05 20:31:46 tb Exp $ */ +/* $OpenBSD: x509_txt.c,v 1.28 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,150 +56,141 @@ * [including the GNU Public Licence.] */ -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include const char * X509_verify_cert_error_string(long n) { - static char buf[100]; - switch ((int)n) { case X509_V_OK: - return("ok"); + return "ok"; + case X509_V_ERR_UNSPECIFIED: + return "Unspecified certificate verification error"; case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: - return("unable to get issuer certificate"); + return "unable to get issuer certificate"; case X509_V_ERR_UNABLE_TO_GET_CRL: - return("unable to get certificate CRL"); + return "unable to get certificate CRL"; case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: - return("unable to decrypt certificate's signature"); + return "unable to decrypt certificate's signature"; case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: - return("unable to decrypt CRL's signature"); + return "unable to decrypt CRL's signature"; case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: - return("unable to decode issuer public key"); + return "unable to decode issuer public key"; case X509_V_ERR_CERT_SIGNATURE_FAILURE: - return("certificate signature failure"); + return "certificate signature failure"; case X509_V_ERR_CRL_SIGNATURE_FAILURE: - return("CRL signature failure"); + return "CRL signature failure"; case X509_V_ERR_CERT_NOT_YET_VALID: - return("certificate is not yet valid"); - case X509_V_ERR_CRL_NOT_YET_VALID: - return("CRL is not yet valid"); + return "certificate is not yet valid"; case X509_V_ERR_CERT_HAS_EXPIRED: - return("certificate has expired"); + return "certificate has expired"; + case X509_V_ERR_CRL_NOT_YET_VALID: + return "CRL is not yet valid"; case X509_V_ERR_CRL_HAS_EXPIRED: - return("CRL has expired"); + return "CRL has expired"; case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: - return("format error in certificate's notBefore field"); + return "format error in certificate's notBefore field"; case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: - return("format error in certificate's notAfter field"); + return "format error in certificate's notAfter field"; case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: - return("format error in CRL's lastUpdate field"); + return "format error in CRL's lastUpdate field"; case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: - return("format error in CRL's nextUpdate field"); + return "format error in CRL's nextUpdate field"; case X509_V_ERR_OUT_OF_MEM: - return("out of memory"); + return "out of memory"; case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: - return("self signed certificate"); + return "self signed certificate"; case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: - return("self signed certificate in certificate chain"); + return "self signed certificate in certificate chain"; case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: - return("unable to get local issuer certificate"); + return "unable to get local issuer certificate"; case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: - return("unable to verify the first certificate"); + return "unable to verify the first certificate"; case X509_V_ERR_CERT_CHAIN_TOO_LONG: - return("certificate chain too long"); + return "certificate chain too long"; case X509_V_ERR_CERT_REVOKED: - return("certificate revoked"); + return "certificate revoked"; case X509_V_ERR_INVALID_CA: - return ("invalid CA certificate"); - case X509_V_ERR_INVALID_NON_CA: - return ("invalid non-CA certificate (has CA markings)"); + return "invalid CA certificate"; case X509_V_ERR_PATH_LENGTH_EXCEEDED: - return ("path length constraint exceeded"); - case X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED: - return("proxy path length constraint exceeded"); - case X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED: - return("proxy certificates not allowed, please set the appropriate flag"); + return "path length constraint exceeded"; case X509_V_ERR_INVALID_PURPOSE: - return ("unsupported certificate purpose"); + return "unsupported certificate purpose"; case X509_V_ERR_CERT_UNTRUSTED: - return ("certificate not trusted"); + return "certificate not trusted"; case X509_V_ERR_CERT_REJECTED: - return ("certificate rejected"); - case X509_V_ERR_APPLICATION_VERIFICATION: - return("application verification failure"); + return "certificate rejected"; case X509_V_ERR_SUBJECT_ISSUER_MISMATCH: - return("subject issuer mismatch"); + return "subject issuer mismatch"; case X509_V_ERR_AKID_SKID_MISMATCH: - return("authority and subject key identifier mismatch"); + return "authority and subject key identifier mismatch"; case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: - return("authority and issuer serial number mismatch"); + return "authority and issuer serial number mismatch"; case X509_V_ERR_KEYUSAGE_NO_CERTSIGN: - return("key usage does not include certificate signing"); + return "key usage does not include certificate signing"; case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER: - return("unable to get CRL issuer certificate"); + return "unable to get CRL issuer certificate"; case X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION: - return("unhandled critical extension"); + return "unhandled critical extension"; case X509_V_ERR_KEYUSAGE_NO_CRL_SIGN: - return("key usage does not include CRL signing"); - case X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE: - return("key usage does not include digital signature"); + return "key usage does not include CRL signing"; case X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION: - return("unhandled critical CRL extension"); + return "unhandled critical CRL extension"; + case X509_V_ERR_INVALID_NON_CA: + return "invalid non-CA certificate (has CA markings)"; + case X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED: + return "proxy path length constraint exceeded"; + case X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE: + return "key usage does not include digital signature"; + case X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED: + return "proxy certificates not allowed, " + "please set the appropriate flag"; case X509_V_ERR_INVALID_EXTENSION: - return("invalid or inconsistent certificate extension"); + return "invalid or inconsistent certificate extension"; case X509_V_ERR_INVALID_POLICY_EXTENSION: - return("invalid or inconsistent certificate policy extension"); + return "invalid or inconsistent certificate policy extension"; case X509_V_ERR_NO_EXPLICIT_POLICY: - return("no explicit policy"); + return "no explicit policy"; case X509_V_ERR_DIFFERENT_CRL_SCOPE: - return("Different CRL scope"); + return "Different CRL scope"; case X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: - return("Unsupported extension feature"); + return "Unsupported extension feature"; case X509_V_ERR_UNNESTED_RESOURCE: - return("RFC 3779 resource not subset of parent's resources"); + return "RFC 3779 resource not subset of parent's resources"; case X509_V_ERR_PERMITTED_VIOLATION: - return("permitted subtree violation"); + return "permitted subtree violation"; case X509_V_ERR_EXCLUDED_VIOLATION: - return("excluded subtree violation"); + return "excluded subtree violation"; case X509_V_ERR_SUBTREE_MINMAX: - return("name constraints minimum and maximum not supported"); + return "name constraints minimum and maximum not supported"; case X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: - return("unsupported name constraint type"); + return "unsupported name constraint type"; case X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: - return("unsupported or invalid name constraint syntax"); + return "unsupported or invalid name constraint syntax"; case X509_V_ERR_UNSUPPORTED_NAME_SYNTAX: - return("unsupported or invalid name syntax"); + return "unsupported or invalid name syntax"; case X509_V_ERR_CRL_PATH_VALIDATION_ERROR: - return("CRL path validation error"); + return "CRL path validation error"; + case X509_V_ERR_APPLICATION_VERIFICATION: + return "application verification failure"; case X509_V_ERR_HOSTNAME_MISMATCH: - return("Hostname mismatch"); + return "Hostname mismatch"; case X509_V_ERR_EMAIL_MISMATCH: - return("Email address mismatch"); + return "Email address mismatch"; case X509_V_ERR_IP_ADDRESS_MISMATCH: - return("IP address mismatch"); + return "IP address mismatch"; case X509_V_ERR_INVALID_CALL: - return("Invalid certificate verification context"); + return "Invalid certificate verification context"; case X509_V_ERR_STORE_LOOKUP: - return("Issuer certificate lookup error"); + return "Issuer certificate lookup error"; case X509_V_ERR_EE_KEY_TOO_SMALL: - return("EE certificate key too weak"); + return "EE certificate key too weak"; case X509_V_ERR_CA_KEY_TOO_SMALL: - return("CA certificate key too weak"); + return "CA certificate key too weak"; case X509_V_ERR_CA_MD_TOO_WEAK: - return("CA signature digest algorithm too weak"); - + return "CA signature digest algorithm too weak"; default: - (void) snprintf(buf, sizeof buf, "error number %ld", n); - return(buf); + return "Unknown certificate verification error"; } } +LCRYPTO_ALIAS(X509_verify_cert_error_string); diff --git a/crypto/x509/x509_utl.c b/crypto/x509/x509_utl.c index 47b25fe6..ec67ae09 100644 --- a/crypto/x509/x509_utl.c +++ b/crypto/x509/x509_utl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_utl.c,v 1.3 2022/05/20 07:58:54 tb Exp $ */ +/* $OpenBSD: x509_utl.c,v 1.6 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -117,6 +117,7 @@ X509V3_add_value(const char *name, const char *value, } return 0; } +LCRYPTO_ALIAS(X509V3_add_value); int X509V3_add_value_uchar(const char *name, const unsigned char *value, @@ -124,6 +125,7 @@ X509V3_add_value_uchar(const char *name, const unsigned char *value, { return X509V3_add_value(name, (const char *)value, extlist); } +LCRYPTO_ALIAS(X509V3_add_value_uchar); /* Free function for STACK_OF(CONF_VALUE) */ @@ -137,6 +139,7 @@ X509V3_conf_free(CONF_VALUE *conf) free(conf->section); free(conf); } +LCRYPTO_ALIAS(X509V3_conf_free); int X509V3_add_value_bool(const char *name, int asn1_bool, @@ -146,6 +149,7 @@ X509V3_add_value_bool(const char *name, int asn1_bool, return X509V3_add_value(name, "TRUE", extlist); return X509V3_add_value(name, "FALSE", extlist); } +LCRYPTO_ALIAS(X509V3_add_value_bool); int X509V3_add_value_bool_nf(const char *name, int asn1_bool, @@ -155,6 +159,7 @@ X509V3_add_value_bool_nf(const char *name, int asn1_bool, return X509V3_add_value(name, "TRUE", extlist); return 1; } +LCRYPTO_ALIAS(X509V3_add_value_bool_nf); char * bn_to_string(const BIGNUM *bn) @@ -197,6 +202,7 @@ i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *method, const ASN1_ENUMERATED *a) BN_free(bntmp); return strtmp; } +LCRYPTO_ALIAS(i2s_ASN1_ENUMERATED); char * i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, const ASN1_INTEGER *a) @@ -212,6 +218,7 @@ i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, const ASN1_INTEGER *a) BN_free(bntmp); return strtmp; } +LCRYPTO_ALIAS(i2s_ASN1_INTEGER); ASN1_INTEGER * s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, const char *value) @@ -262,6 +269,7 @@ s2i_ASN1_INTEGER(X509V3_EXT_METHOD *method, const char *value) aint->type |= V_ASN1_NEG; return aint; } +LCRYPTO_ALIAS(s2i_ASN1_INTEGER); int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint, @@ -278,6 +286,7 @@ X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint, free(strtmp); return ret; } +LCRYPTO_ALIAS(X509V3_add_value_int); int X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool) @@ -303,6 +312,7 @@ X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool) X509V3_conf_err(value); return 0; } +LCRYPTO_ALIAS(X509V3_get_value_bool); int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint) @@ -316,6 +326,7 @@ X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint) *aint = itmp; return 1; } +LCRYPTO_ALIAS(X509V3_get_value_int); #define HDR_NAME 1 #define HDR_VALUE 2 @@ -407,6 +418,7 @@ X509V3_parse_list(const char *line) return NULL; } +LCRYPTO_ALIAS(X509V3_parse_list); /* Delete leading and trailing spaces from a string */ static char * @@ -458,6 +470,7 @@ hex_to_string(const unsigned char *buffer, long len) q[-1] = 0; return tmp; } +LCRYPTO_ALIAS(hex_to_string); /* Give a string of hex digits convert to * a buffer @@ -519,6 +532,7 @@ string_to_hex(const char *str, long *len) X509V3error(X509V3_R_ILLEGAL_HEX_DIGIT); return NULL; } +LCRYPTO_ALIAS(string_to_hex); /* V2I name comparison function: returns zero if 'name' matches * cmp or cmp.* @@ -556,6 +570,7 @@ X509_get1_email(X509 *x) sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free); return ret; } +LCRYPTO_ALIAS(X509_get1_email); STACK_OF(OPENSSL_STRING) * X509_get1_ocsp(X509 *x) @@ -580,6 +595,7 @@ X509_get1_ocsp(X509 *x) AUTHORITY_INFO_ACCESS_free(info); return ret; } +LCRYPTO_ALIAS(X509_get1_ocsp); STACK_OF(OPENSSL_STRING) * X509_REQ_get1_email(X509_REQ *x) @@ -595,6 +611,7 @@ X509_REQ_get1_email(X509_REQ *x) sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); return ret; } +LCRYPTO_ALIAS(X509_REQ_get1_email); static STACK_OF(OPENSSL_STRING) * @@ -664,6 +681,7 @@ X509_email_free(STACK_OF(OPENSSL_STRING) *sk) { sk_OPENSSL_STRING_pop_free(sk, str_free); } +LCRYPTO_ALIAS(X509_email_free); typedef int (*equal_fn)(const unsigned char *pattern, size_t pattern_len, const unsigned char *subject, size_t subject_len, unsigned int flags); @@ -705,7 +723,7 @@ skip_prefix(const unsigned char **p, size_t *plen, const unsigned char *subject, * "equal_nocase" function is a hand-rolled strncasecmp that does not * allow \0 in the pattern. Since an embedded \0 is likely a sign of * problems, we simply don't allow it in either case, and then we use - * standard libc funcitons. + * standard libc functions. */ /* Compare using strncasecmp */ @@ -1065,6 +1083,7 @@ X509_check_host(X509 *x, const char *chk, size_t chklen, unsigned int flags, return -2; return do_x509_check(x, chk, chklen, flags, GEN_DNS, peername); } +LCRYPTO_ALIAS(X509_check_host); int X509_check_email(X509 *x, const char *chk, size_t chklen, unsigned int flags) @@ -1077,6 +1096,7 @@ X509_check_email(X509 *x, const char *chk, size_t chklen, unsigned int flags) return -2; return do_x509_check(x, chk, chklen, flags, GEN_EMAIL, NULL); } +LCRYPTO_ALIAS(X509_check_email); int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, @@ -1086,6 +1106,7 @@ X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, return -2; return do_x509_check(x, (char *)chk, chklen, flags, GEN_IPADD, NULL); } +LCRYPTO_ALIAS(X509_check_ip); int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags) @@ -1100,6 +1121,7 @@ X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags) return -2; return do_x509_check(x, (char *)ipout, iplen, flags, GEN_IPADD, NULL); } +LCRYPTO_ALIAS(X509_check_ip_asc); /* Convert IP addresses both IPv4 and IPv6 into an * OCTET STRING compatible with RFC3280. @@ -1128,6 +1150,7 @@ a2i_IPADDRESS(const char *ipasc) } return ret; } +LCRYPTO_ALIAS(a2i_IPADDRESS); ASN1_OCTET_STRING * a2i_IPADDRESS_NC(const char *ipasc) @@ -1173,6 +1196,7 @@ a2i_IPADDRESS_NC(const char *ipasc) ASN1_OCTET_STRING_free(ret); return NULL; } +LCRYPTO_ALIAS(a2i_IPADDRESS_NC); int @@ -1190,6 +1214,7 @@ a2i_ipadd(unsigned char *ipout, const char *ipasc) return 4; } } +LCRYPTO_ALIAS(a2i_ipadd); static int ipv4_from_asc(unsigned char *v4, const char *in) @@ -1386,3 +1411,4 @@ X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE)*dn_sk, } return 1; } +LCRYPTO_ALIAS(X509V3_NAME_from_section); diff --git a/crypto/x509/x509_v3.c b/crypto/x509/x509_v3.c index 9aefb8d9..8dddb463 100644 --- a/crypto/x509/x509_v3.c +++ b/crypto/x509/x509_v3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_v3.c,v 1.18 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509_v3.c,v 1.21 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,7 +66,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x) @@ -75,6 +75,7 @@ X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x) return (0); return (sk_X509_EXTENSION_num(x)); } +LCRYPTO_ALIAS(X509v3_get_ext_count); int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, int nid, int lastpos) @@ -86,6 +87,7 @@ X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, int nid, int lastpos) return (-2); return (X509v3_get_ext_by_OBJ(x, obj, lastpos)); } +LCRYPTO_ALIAS(X509v3_get_ext_by_NID); int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *sk, @@ -107,6 +109,7 @@ X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *sk, } return (-1); } +LCRYPTO_ALIAS(X509v3_get_ext_by_OBJ); int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit, @@ -129,6 +132,7 @@ X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *sk, int crit, } return (-1); } +LCRYPTO_ALIAS(X509v3_get_ext_by_critical); X509_EXTENSION * X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc) @@ -138,6 +142,7 @@ X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc) else return sk_X509_EXTENSION_value(x, loc); } +LCRYPTO_ALIAS(X509v3_get_ext); X509_EXTENSION * X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc) @@ -149,6 +154,7 @@ X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc) ret = sk_X509_EXTENSION_delete(x, loc); return (ret); } +LCRYPTO_ALIAS(X509v3_delete_ext); STACK_OF(X509_EXTENSION) * X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ex, int loc) @@ -191,6 +197,7 @@ X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, X509_EXTENSION *ex, int loc) sk_X509_EXTENSION_free(sk); return (NULL); } +LCRYPTO_ALIAS(X509v3_add_ext); X509_EXTENSION * X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, int crit, @@ -209,6 +216,7 @@ X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, int nid, int crit, ASN1_OBJECT_free(obj); return (ret); } +LCRYPTO_ALIAS(X509_EXTENSION_create_by_NID); X509_EXTENSION * X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, const ASN1_OBJECT *obj, @@ -240,6 +248,7 @@ X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, const ASN1_OBJECT *obj, X509_EXTENSION_free(ret); return (NULL); } +LCRYPTO_ALIAS(X509_EXTENSION_create_by_OBJ); int X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj) @@ -250,6 +259,7 @@ X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj) ex->object = OBJ_dup(obj); return ex->object != NULL; } +LCRYPTO_ALIAS(X509_EXTENSION_set_object); int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit) @@ -259,6 +269,7 @@ X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit) ex->critical = (crit) ? 0xFF : -1; return (1); } +LCRYPTO_ALIAS(X509_EXTENSION_set_critical); int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data) @@ -272,6 +283,7 @@ X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data) return (0); return (1); } +LCRYPTO_ALIAS(X509_EXTENSION_set_data); ASN1_OBJECT * X509_EXTENSION_get_object(X509_EXTENSION *ex) @@ -280,6 +292,7 @@ X509_EXTENSION_get_object(X509_EXTENSION *ex) return (NULL); return (ex->object); } +LCRYPTO_ALIAS(X509_EXTENSION_get_object); ASN1_OCTET_STRING * X509_EXTENSION_get_data(X509_EXTENSION *ex) @@ -288,6 +301,7 @@ X509_EXTENSION_get_data(X509_EXTENSION *ex) return (NULL); return (ex->value); } +LCRYPTO_ALIAS(X509_EXTENSION_get_data); int X509_EXTENSION_get_critical(const X509_EXTENSION *ex) @@ -298,3 +312,4 @@ X509_EXTENSION_get_critical(const X509_EXTENSION *ex) return 1; return 0; } +LCRYPTO_ALIAS(X509_EXTENSION_get_critical); diff --git a/crypto/x509/x509_verify.c b/crypto/x509/x509_verify.c index c212ab4e..c60bdf74 100644 --- a/crypto/x509/x509_verify.c +++ b/crypto/x509/x509_verify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_verify.c,v 1.60.2.1 2022/10/20 09:45:18 tb Exp $ */ +/* $OpenBSD: x509_verify.c,v 1.63 2023/01/20 22:00:47 job Exp $ */ /* * Copyright (c) 2020-2021 Bob Beck * @@ -241,15 +241,7 @@ x509_verify_ctx_clear(struct x509_verify_ctx *ctx) static int x509_verify_cert_cache_extensions(X509 *cert) { - if (!(cert->ex_flags & EXFLAG_SET)) { - CRYPTO_w_lock(CRYPTO_LOCK_X509); - x509v3_cache_extensions(cert); - CRYPTO_w_unlock(CRYPTO_LOCK_X509); - } - if (cert->ex_flags & EXFLAG_INVALID) - return 0; - - return (cert->ex_flags & EXFLAG_SET); + return x509v3_cache_extensions(cert); } static int @@ -447,7 +439,8 @@ x509_verify_ctx_validate_legacy_chain(struct x509_verify_ctx *ctx, if (!x509_vfy_check_revocation(ctx->xsc)) goto err; - if (!x509_vfy_check_policy(ctx->xsc)) + if (ctx->xsc->param->flags & X509_V_FLAG_POLICY_CHECK && + !x509_vfy_check_policy(ctx->xsc)) goto err; ret = 1; diff --git a/include/openssl/x509_verify.h b/crypto/x509/x509_verify.h similarity index 100% rename from include/openssl/x509_verify.h rename to crypto/x509/x509_verify.h diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index fb87877e..8bba7961 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_vfy.c,v 1.103 2022/08/31 07:15:31 tb Exp $ */ +/* $OpenBSD: x509_vfy.c,v 1.111 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -73,7 +73,7 @@ #include #include #include -#include "asn1_locl.h" +#include "asn1_local.h" #include "vpm_int.h" #include "x509_internal.h" @@ -116,7 +116,7 @@ #define CRL_SCORE_TIME_DELTA 0x002 static int null_callback(int ok, X509_STORE_CTX *e); -static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer); +static int check_issued(X509_STORE_CTX *ctx, X509 *subject, X509 *issuer); static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x, int allow_expired); static int check_chain_extensions(X509_STORE_CTX *ctx); @@ -312,7 +312,7 @@ X509_verify_cert_legacy_build_chain(X509_STORE_CTX *ctx, int *bad, int *out_ok) if (ctx->untrusted != NULL) { /* * If we do not find a non-expired untrusted cert, peek - * ahead and see if we can satisify this from the trusted + * ahead and see if we can satisfy this from the trusted * store. If not, see if we have an expired untrusted cert. */ xtmp = find_issuer(ctx, sktmp, x, 0); @@ -668,6 +668,7 @@ X509_verify_cert(X509_STORE_CTX *ctx) /* if we succeed we have a chain in ctx->chain */ return (chain_count > 0 && ctx->chain != NULL); } +LCRYPTO_ALIAS(X509_verify_cert); /* Given a STACK_OF(X509) find the issuer of cert (if any) */ @@ -694,21 +695,13 @@ find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x, /* Given a possible certificate and issuer check them */ static int -check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer) +check_issued(X509_STORE_CTX *ctx, X509 *subject, X509 *issuer) { - int ret; - - ret = X509_check_issued(issuer, x); - if (ret == X509_V_OK) - return 1; - /* If we haven't asked for issuer errors don't set ctx */ - if (!(ctx->param->flags & X509_V_FLAG_CB_ISSUER_CHECK)) - return 0; - - ctx->error = ret; - ctx->current_cert = x; - ctx->current_issuer = issuer; - return ctx->verify_cb(0, ctx); + /* + * Yes, the arguments of X509_STORE_CTX_check_issued_fn were exposed in + * reverse order compared to the already public X509_check_issued()... + */ + return X509_check_issued(issuer, subject) == X509_V_OK; } /* Alternative lookup method: look from a STACK stored in other_ctx */ @@ -2019,6 +2012,7 @@ X509_cmp_current_time(const ASN1_TIME *ctm) { return X509_cmp_time(ctm, NULL); } +LCRYPTO_ALIAS(X509_cmp_current_time); /* * Compare a possibly unvalidated ASN1_TIME string against a time_t @@ -2058,6 +2052,7 @@ X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time) { return X509_cmp_time_internal(ctm, cmp_time, 0); } +LCRYPTO_ALIAS(X509_cmp_time); ASN1_TIME * @@ -2065,12 +2060,14 @@ X509_gmtime_adj(ASN1_TIME *s, long adj) { return X509_time_adj(s, adj, NULL); } +LCRYPTO_ALIAS(X509_gmtime_adj); ASN1_TIME * X509_time_adj(ASN1_TIME *s, long offset_sec, time_t *in_time) { return X509_time_adj_ex(s, 0, offset_sec, in_time); } +LCRYPTO_ALIAS(X509_time_adj); ASN1_TIME * X509_time_adj_ex(ASN1_TIME *s, int offset_day, long offset_sec, time_t *in_time) @@ -2083,6 +2080,7 @@ X509_time_adj_ex(ASN1_TIME *s, int offset_day, long offset_sec, time_t *in_time) return ASN1_TIME_adj(s, t, offset_day, offset_sec); } +LCRYPTO_ALIAS(X509_time_adj_ex); int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain) @@ -2122,6 +2120,7 @@ X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain) return 0; return 1; } +LCRYPTO_ALIAS(X509_get_pubkey_parameters); int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, @@ -2132,66 +2131,77 @@ X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, argl, argp, new_func, dup_func, free_func); } +LCRYPTO_ALIAS(X509_STORE_CTX_get_ex_new_index); int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data) { return CRYPTO_set_ex_data(&ctx->ex_data, idx, data); } +LCRYPTO_ALIAS(X509_STORE_CTX_set_ex_data); void * X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx) { return CRYPTO_get_ex_data(&ctx->ex_data, idx); } +LCRYPTO_ALIAS(X509_STORE_CTX_get_ex_data); int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx) { return ctx->error; } +LCRYPTO_ALIAS(X509_STORE_CTX_get_error); void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int err) { ctx->error = err; } +LCRYPTO_ALIAS(X509_STORE_CTX_set_error); int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx) { return ctx->error_depth; } +LCRYPTO_ALIAS(X509_STORE_CTX_get_error_depth); void X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth) { ctx->error_depth = depth; } +LCRYPTO_ALIAS(X509_STORE_CTX_set_error_depth); X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx) { return ctx->current_cert; } +LCRYPTO_ALIAS(X509_STORE_CTX_get_current_cert); void X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x) { ctx->current_cert = x; } +LCRYPTO_ALIAS(X509_STORE_CTX_set_current_cert); STACK_OF(X509) * X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx) { return ctx->chain; } +LCRYPTO_ALIAS(X509_STORE_CTX_get_chain); STACK_OF(X509) * X509_STORE_CTX_get0_chain(X509_STORE_CTX *xs) { return xs->chain; } +LCRYPTO_ALIAS(X509_STORE_CTX_get0_chain); STACK_OF(X509) * X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx) @@ -2208,60 +2218,70 @@ X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx) } return chain; } +LCRYPTO_ALIAS(X509_STORE_CTX_get1_chain); X509 * X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx) { return ctx->current_issuer; } +LCRYPTO_ALIAS(X509_STORE_CTX_get0_current_issuer); X509_CRL * X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx) { return ctx->current_crl; } +LCRYPTO_ALIAS(X509_STORE_CTX_get0_current_crl); X509_STORE_CTX * X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx) { return ctx->parent; } +LCRYPTO_ALIAS(X509_STORE_CTX_get0_parent_ctx); X509_STORE * X509_STORE_CTX_get0_store(X509_STORE_CTX *xs) { return xs->store; } +LCRYPTO_ALIAS(X509_STORE_CTX_get0_store); void X509_STORE_CTX_set_cert(X509_STORE_CTX *ctx, X509 *x) { ctx->cert = x; } +LCRYPTO_ALIAS(X509_STORE_CTX_set_cert); void X509_STORE_CTX_set_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *sk) { ctx->untrusted = sk; } +LCRYPTO_ALIAS(X509_STORE_CTX_set_chain); void X509_STORE_CTX_set0_crls(X509_STORE_CTX *ctx, STACK_OF(X509_CRL) *sk) { ctx->crls = sk; } +LCRYPTO_ALIAS(X509_STORE_CTX_set0_crls); int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose) { return X509_STORE_CTX_purpose_inherit(ctx, 0, purpose, 0); } +LCRYPTO_ALIAS(X509_STORE_CTX_set_purpose); int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust) { return X509_STORE_CTX_purpose_inherit(ctx, 0, 0, trust); } +LCRYPTO_ALIAS(X509_STORE_CTX_set_trust); /* This function is used to set the X509_STORE_CTX purpose and trust * values. This is intended to be used when another structure has its @@ -2317,6 +2337,7 @@ X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, ctx->param->trust = trust; return 1; } +LCRYPTO_ALIAS(X509_STORE_CTX_purpose_inherit); X509_STORE_CTX * X509_STORE_CTX_new(void) @@ -2330,6 +2351,7 @@ X509_STORE_CTX_new(void) } return ctx; } +LCRYPTO_ALIAS(X509_STORE_CTX_new); void X509_STORE_CTX_free(X509_STORE_CTX *ctx) @@ -2340,6 +2362,7 @@ X509_STORE_CTX_free(X509_STORE_CTX *ctx) X509_STORE_CTX_cleanup(ctx); free(ctx); } +LCRYPTO_ALIAS(X509_STORE_CTX_free); int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, @@ -2461,6 +2484,7 @@ X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, X509 *x509, } return 1; } +LCRYPTO_ALIAS(X509_STORE_CTX_init); /* Set alternative lookup method: just a STACK of trusted certificates. * This avoids X509_STORE nastiness where it isn't needed. @@ -2472,12 +2496,14 @@ X509_STORE_CTX_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk) ctx->other_ctx = sk; ctx->get_issuer = get_issuer_sk; } +LCRYPTO_ALIAS(X509_STORE_CTX_trusted_stack); void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk) { X509_STORE_CTX_trusted_stack(ctx, sk); } +LCRYPTO_ALIAS(X509_STORE_CTX_set0_trusted_stack); void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx) @@ -2501,30 +2527,35 @@ X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx) ctx, &(ctx->ex_data)); memset(&ctx->ex_data, 0, sizeof(CRYPTO_EX_DATA)); } +LCRYPTO_ALIAS(X509_STORE_CTX_cleanup); void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth) { X509_VERIFY_PARAM_set_depth(ctx->param, depth); } +LCRYPTO_ALIAS(X509_STORE_CTX_set_depth); void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags) { X509_VERIFY_PARAM_set_flags(ctx->param, flags); } +LCRYPTO_ALIAS(X509_STORE_CTX_set_flags); void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, time_t t) { X509_VERIFY_PARAM_set_time(ctx->param, t); } +LCRYPTO_ALIAS(X509_STORE_CTX_set_time); int (*X509_STORE_CTX_get_verify_cb(X509_STORE_CTX *ctx))(int, X509_STORE_CTX *) { return ctx->verify_cb; } +LCRYPTO_ALIAS(X509_STORE_CTX_get_verify_cb); void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, @@ -2532,36 +2563,64 @@ X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, { ctx->verify_cb = verify_cb; } +LCRYPTO_ALIAS(X509_STORE_CTX_set_verify_cb); int (*X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx))(X509_STORE_CTX *) { return ctx->verify; } +LCRYPTO_ALIAS(X509_STORE_CTX_get_verify); void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, int (*verify)(X509_STORE_CTX *)) { ctx->verify = verify; } +LCRYPTO_ALIAS(X509_STORE_CTX_set_verify); + +X509_STORE_CTX_check_issued_fn +X509_STORE_get_check_issued(X509_STORE *store) +{ + return store->check_issued; +} +LCRYPTO_ALIAS(X509_STORE_get_check_issued); + +void +X509_STORE_set_check_issued(X509_STORE *store, + X509_STORE_CTX_check_issued_fn check_issued) +{ + store->check_issued = check_issued; +} +LCRYPTO_ALIAS(X509_STORE_set_check_issued); + +X509_STORE_CTX_check_issued_fn +X509_STORE_CTX_get_check_issued(X509_STORE_CTX *ctx) +{ + return ctx->check_issued; +} +LCRYPTO_ALIAS(X509_STORE_CTX_get_check_issued); X509 * X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx) { return ctx->cert; } +LCRYPTO_ALIAS(X509_STORE_CTX_get0_cert); STACK_OF(X509) * X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx) { return ctx->untrusted; } +LCRYPTO_ALIAS(X509_STORE_CTX_get0_untrusted); void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk) { ctx->untrusted = sk; } +LCRYPTO_ALIAS(X509_STORE_CTX_set0_untrusted); void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *sk) @@ -2569,24 +2628,28 @@ X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *ctx, STACK_OF(X509) *sk) sk_X509_pop_free(ctx->chain, X509_free); ctx->chain = sk; } +LCRYPTO_ALIAS(X509_STORE_CTX_set0_verified_chain); X509_POLICY_TREE * X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx) { return ctx->tree; } +LCRYPTO_ALIAS(X509_STORE_CTX_get0_policy_tree); int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx) { return ctx->explicit_policy; } +LCRYPTO_ALIAS(X509_STORE_CTX_get_explicit_policy); int X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx) { return ctx->num_untrusted; } +LCRYPTO_ALIAS(X509_STORE_CTX_get_num_untrusted); int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name) @@ -2597,12 +2660,14 @@ X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name) return 0; return X509_VERIFY_PARAM_inherit(ctx->param, param); } +LCRYPTO_ALIAS(X509_STORE_CTX_set_default); X509_VERIFY_PARAM * X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx) { return ctx->param; } +LCRYPTO_ALIAS(X509_STORE_CTX_get0_param); void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param) @@ -2611,6 +2676,7 @@ X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param) X509_VERIFY_PARAM_free(ctx->param); ctx->param = param; } +LCRYPTO_ALIAS(X509_STORE_CTX_set0_param); /* * Check if |bits| are adequate for |security level|. diff --git a/crypto/x509/x509_vpm.c b/crypto/x509/x509_vpm.c index e14d7a36..cb13267b 100644 --- a/crypto/x509/x509_vpm.c +++ b/crypto/x509/x509_vpm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_vpm.c,v 1.30 2022/07/04 12:17:32 tb Exp $ */ +/* $OpenBSD: x509_vpm.c,v 1.33 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ @@ -67,7 +67,7 @@ #include #include "vpm_int.h" -#include "x509_lcl.h" +#include "x509_local.h" /* X509_VERIFY_PARAM functions */ @@ -218,6 +218,7 @@ X509_VERIFY_PARAM_new(void) x509_verify_param_zero(param); return param; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_new); void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param) @@ -228,6 +229,7 @@ X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param) free(param->id); free(param); } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_free); /* * This function determines how parameters are "inherited" from one structure @@ -356,6 +358,7 @@ X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *dest, const X509_VERIFY_PARAM *src) return 1; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_inherit); int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, const X509_VERIFY_PARAM *from) @@ -368,6 +371,7 @@ X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, const X509_VERIFY_PARAM *from) to->inh_flags = save_flags; return ret; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set1); static int x509_param_set1_internal(char **pdest, size_t *pdestlen, const char *src, @@ -412,6 +416,7 @@ X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name) return 1; return 0; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set1_name); int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags) @@ -421,6 +426,7 @@ X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, unsigned long flags) param->flags |= X509_V_FLAG_POLICY_CHECK; return 1; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set_flags); int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, unsigned long flags) @@ -428,42 +434,49 @@ X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, unsigned long flags) param->flags &= ~flags; return 1; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_clear_flags); unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param) { return param->flags; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_get_flags); int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose) { return X509_PURPOSE_set(¶m->purpose, purpose); } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set_purpose); int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust) { return X509_TRUST_set(¶m->trust, trust); } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set_trust); void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth) { param->depth = depth; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set_depth); void X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level) { param->security_level = auth_level; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set_auth_level); time_t X509_VERIFY_PARAM_get_time(const X509_VERIFY_PARAM *param) { return param->check_time; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_get_time); void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t) @@ -471,6 +484,7 @@ X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t) param->check_time = t; param->flags |= X509_V_FLAG_USE_CHECK_TIME; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set_time); int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, ASN1_OBJECT *policy) @@ -484,6 +498,7 @@ X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, ASN1_OBJECT *policy) return 0; return 1; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_add0_policy); int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, @@ -519,6 +534,7 @@ X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, param->flags |= X509_V_FLAG_POLICY_CHECK; return 1; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set1_policies); int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, @@ -529,6 +545,7 @@ X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, param->id->poisoned = 1; return 0; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set1_host); int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, @@ -539,18 +556,21 @@ X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, param->id->poisoned = 1; return 0; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_add1_host); void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param, unsigned int flags) { param->id->hostflags = flags; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set_hostflags); char * X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *param) { return param->id->peername; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_get0_peername); int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, const char *email, @@ -562,6 +582,7 @@ X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, const char *email, param->id->poisoned = 1; return 0; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set1_email); int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, const unsigned char *ip, @@ -576,6 +597,7 @@ X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, const unsigned char *ip, param->id->poisoned = 1; return 0; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set1_ip); int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param, const char *ipasc) @@ -586,18 +608,21 @@ X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param, const char *ipasc) iplen = (size_t)a2i_ipadd(ipout, ipasc); return X509_VERIFY_PARAM_set1_ip(param, ipout, iplen); } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_set1_ip_asc); int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param) { return param->depth; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_get_depth); const char * X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param) { return param->name; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_get0_name); static const X509_VERIFY_PARAM_ID _empty_id = { NULL }; @@ -679,6 +704,7 @@ X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param) return 0; return 1; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_add0_table); int X509_VERIFY_PARAM_get_count(void) @@ -688,6 +714,7 @@ X509_VERIFY_PARAM_get_count(void) num += sk_X509_VERIFY_PARAM_num(param_table); return num; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_get_count); const X509_VERIFY_PARAM * X509_VERIFY_PARAM_get0(int id) @@ -697,6 +724,7 @@ X509_VERIFY_PARAM_get0(int id) return default_table + id; return sk_X509_VERIFY_PARAM_value(param_table, id - num); } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_get0); const X509_VERIFY_PARAM * X509_VERIFY_PARAM_lookup(const char *name) @@ -719,6 +747,7 @@ X509_VERIFY_PARAM_lookup(const char *name) } return NULL; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_lookup); void X509_VERIFY_PARAM_table_cleanup(void) @@ -728,3 +757,4 @@ X509_VERIFY_PARAM_table_cleanup(void) X509_VERIFY_PARAM_free); param_table = NULL; } +LCRYPTO_ALIAS(X509_VERIFY_PARAM_table_cleanup); diff --git a/crypto/x509/x509cset.c b/crypto/x509/x509cset.c index b3af77d9..7904a7d6 100644 --- a/crypto/x509/x509cset.c +++ b/crypto/x509/x509cset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509cset.c,v 1.16 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509cset.c,v 1.19 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -63,7 +63,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" int X509_CRL_up_ref(X509_CRL *x) @@ -71,6 +71,7 @@ X509_CRL_up_ref(X509_CRL *x) int refs = CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509_CRL); return (refs > 1) ? 1 : 0; } +LCRYPTO_ALIAS(X509_CRL_up_ref); int X509_CRL_set_version(X509_CRL *x, long version) @@ -83,6 +84,7 @@ X509_CRL_set_version(X509_CRL *x, long version) } return (ASN1_INTEGER_set(x->crl->version, version)); } +LCRYPTO_ALIAS(X509_CRL_set_version); int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name) @@ -91,6 +93,7 @@ X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name) return (0); return (X509_NAME_set(&x->crl->issuer, name)); } +LCRYPTO_ALIAS(X509_CRL_set_issuer_name); int X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm) @@ -109,12 +112,14 @@ X509_CRL_set_lastUpdate(X509_CRL *x, const ASN1_TIME *tm) } return (in != NULL); } +LCRYPTO_ALIAS(X509_CRL_set_lastUpdate); int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm) { return X509_CRL_set_lastUpdate(x, tm); } +LCRYPTO_ALIAS(X509_CRL_set1_lastUpdate); int X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm) @@ -133,12 +138,14 @@ X509_CRL_set_nextUpdate(X509_CRL *x, const ASN1_TIME *tm) } return (in != NULL); } +LCRYPTO_ALIAS(X509_CRL_set_nextUpdate); int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm) { return X509_CRL_set_nextUpdate(x, tm); } +LCRYPTO_ALIAS(X509_CRL_set1_nextUpdate); int X509_CRL_sort(X509_CRL *c) @@ -156,24 +163,28 @@ X509_CRL_sort(X509_CRL *c) c->crl->enc.modified = 1; return 1; } +LCRYPTO_ALIAS(X509_CRL_sort); const STACK_OF(X509_EXTENSION) * X509_REVOKED_get0_extensions(const X509_REVOKED *x) { return x->extensions; } +LCRYPTO_ALIAS(X509_REVOKED_get0_extensions); const ASN1_TIME * X509_REVOKED_get0_revocationDate(const X509_REVOKED *x) { return x->revocationDate; } +LCRYPTO_ALIAS(X509_REVOKED_get0_revocationDate); const ASN1_INTEGER * X509_REVOKED_get0_serialNumber(const X509_REVOKED *x) { return x->serialNumber; } +LCRYPTO_ALIAS(X509_REVOKED_get0_serialNumber); int X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm) @@ -192,6 +203,7 @@ X509_REVOKED_set_revocationDate(X509_REVOKED *x, ASN1_TIME *tm) } return (in != NULL); } +LCRYPTO_ALIAS(X509_REVOKED_set_revocationDate); int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial) @@ -210,6 +222,7 @@ X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial) } return (in != NULL); } +LCRYPTO_ALIAS(X509_REVOKED_set_serialNumber); int i2d_re_X509_CRL_tbs(X509_CRL *crl, unsigned char **pp) @@ -217,3 +230,4 @@ i2d_re_X509_CRL_tbs(X509_CRL *crl, unsigned char **pp) crl->crl->enc.modified = 1; return i2d_X509_CRL_INFO(crl->crl, pp); } +LCRYPTO_ALIAS(i2d_re_X509_CRL_tbs); diff --git a/crypto/x509/x509name.c b/crypto/x509/x509name.c index 878d7878..a6e4dbef 100644 --- a/crypto/x509/x509name.c +++ b/crypto/x509/x509name.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509name.c,v 1.27 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509name.c,v 1.31 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -66,7 +66,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len) @@ -78,6 +78,7 @@ X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len) return (-1); return (X509_NAME_get_text_by_OBJ(name, obj, buf, len)); } +LCRYPTO_ALIAS(X509_NAME_get_text_by_NID); int X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, char *buf, @@ -99,6 +100,7 @@ X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, char *buf, } return (i); } +LCRYPTO_ALIAS(X509_NAME_get_text_by_OBJ); int X509_NAME_entry_count(const X509_NAME *name) @@ -107,6 +109,7 @@ X509_NAME_entry_count(const X509_NAME *name) return (0); return (sk_X509_NAME_ENTRY_num(name->entries)); } +LCRYPTO_ALIAS(X509_NAME_entry_count); int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos) @@ -118,8 +121,9 @@ X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos) return (-2); return (X509_NAME_get_index_by_OBJ(name, obj, lastpos)); } +LCRYPTO_ALIAS(X509_NAME_get_index_by_NID); -/* NOTE: you should be passsing -1, not 0 as lastpos */ +/* NOTE: you should be passing -1, not 0 as lastpos */ int X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj, int lastpos) @@ -141,6 +145,7 @@ X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj, } return (-1); } +LCRYPTO_ALIAS(X509_NAME_get_index_by_OBJ); X509_NAME_ENTRY * X509_NAME_get_entry(const X509_NAME *name, int loc) @@ -151,6 +156,7 @@ X509_NAME_get_entry(const X509_NAME *name, int loc) else return (sk_X509_NAME_ENTRY_value(name->entries, loc)); } +LCRYPTO_ALIAS(X509_NAME_get_entry); X509_NAME_ENTRY * X509_NAME_delete_entry(X509_NAME *name, int loc) @@ -189,6 +195,7 @@ X509_NAME_delete_entry(X509_NAME *name, int loc) sk_X509_NAME_ENTRY_value(sk, i)->set--; return (ret); } +LCRYPTO_ALIAS(X509_NAME_delete_entry); int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, @@ -204,6 +211,7 @@ X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, X509_NAME_ENTRY_free(ne); return ret; } +LCRYPTO_ALIAS(X509_NAME_add_entry_by_OBJ); int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, @@ -219,6 +227,7 @@ X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, X509_NAME_ENTRY_free(ne); return ret; } +LCRYPTO_ALIAS(X509_NAME_add_entry_by_NID); int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, @@ -234,6 +243,7 @@ X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, X509_NAME_ENTRY_free(ne); return ret; } +LCRYPTO_ALIAS(X509_NAME_add_entry_by_txt); /* if set is -1, append to previous set, 0 'a new one', and 1, * prepend to the guy we are about to stomp on. */ @@ -292,6 +302,7 @@ X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, X509_NAME_ENTRY_free(new_name); return (0); } +LCRYPTO_ALIAS(X509_NAME_add_entry); X509_NAME_ENTRY * X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, @@ -310,6 +321,7 @@ X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, ASN1_OBJECT_free(obj); return nentry; } +LCRYPTO_ALIAS(X509_NAME_ENTRY_create_by_txt); X509_NAME_ENTRY * X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type, @@ -327,6 +339,7 @@ X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, int type, ASN1_OBJECT_free(obj); return nentry; } +LCRYPTO_ALIAS(X509_NAME_ENTRY_create_by_NID); X509_NAME_ENTRY * X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, const ASN1_OBJECT *obj, @@ -354,6 +367,7 @@ X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, const ASN1_OBJECT *obj, X509_NAME_ENTRY_free(ret); return (NULL); } +LCRYPTO_ALIAS(X509_NAME_ENTRY_create_by_OBJ); int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj) @@ -366,6 +380,7 @@ X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj) ne->object = OBJ_dup(obj); return ((ne->object == NULL) ? 0 : 1); } +LCRYPTO_ALIAS(X509_NAME_ENTRY_set_object); int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, @@ -391,6 +406,7 @@ X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, } return (1); } +LCRYPTO_ALIAS(X509_NAME_ENTRY_set_data); ASN1_OBJECT * X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne) @@ -399,6 +415,7 @@ X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne) return (NULL); return (ne->object); } +LCRYPTO_ALIAS(X509_NAME_ENTRY_get_object); ASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne) @@ -407,9 +424,11 @@ X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne) return (NULL); return (ne->value); } +LCRYPTO_ALIAS(X509_NAME_ENTRY_get_data); int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne) { return (ne->set); } +LCRYPTO_ALIAS(X509_NAME_ENTRY_set); diff --git a/crypto/x509/x509rset.c b/crypto/x509/x509rset.c index a2dd9e4c..f097a379 100644 --- a/crypto/x509/x509rset.c +++ b/crypto/x509/x509rset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509rset.c,v 1.9 2021/11/01 20:53:08 tb Exp $ */ +/* $OpenBSD: x509rset.c,v 1.12 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -63,7 +63,7 @@ #include #include -#include "x509_lcl.h" +#include "x509_local.h" int X509_REQ_set_version(X509_REQ *x, long version) @@ -73,12 +73,14 @@ X509_REQ_set_version(X509_REQ *x, long version) x->req_info->enc.modified = 1; return (ASN1_INTEGER_set(x->req_info->version, version)); } +LCRYPTO_ALIAS(X509_REQ_set_version); long X509_REQ_get_version(const X509_REQ *x) { return ASN1_INTEGER_get(x->req_info->version); } +LCRYPTO_ALIAS(X509_REQ_get_version); int X509_REQ_set_subject_name(X509_REQ *x, X509_NAME *name) @@ -88,12 +90,14 @@ X509_REQ_set_subject_name(X509_REQ *x, X509_NAME *name) x->req_info->enc.modified = 1; return (X509_NAME_set(&x->req_info->subject, name)); } +LCRYPTO_ALIAS(X509_REQ_set_subject_name); X509_NAME * X509_REQ_get_subject_name(const X509_REQ *x) { return x->req_info->subject; } +LCRYPTO_ALIAS(X509_REQ_get_subject_name); int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey) @@ -103,3 +107,4 @@ X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey) x->req_info->enc.modified = 1; return (X509_PUBKEY_set(&x->req_info->pubkey, pkey)); } +LCRYPTO_ALIAS(X509_REQ_set_pubkey); diff --git a/crypto/x509/x509spki.c b/crypto/x509/x509spki.c index 66bbd1e0..04c9a6f0 100644 --- a/crypto/x509/x509spki.c +++ b/crypto/x509/x509spki.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509spki.c,v 1.14 2019/05/23 02:08:34 bcook Exp $ */ +/* $OpenBSD: x509spki.c,v 1.16 2023/02/16 08:38:17 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -70,6 +70,7 @@ NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey) return (0); return (X509_PUBKEY_set(&(x->spkac->pubkey), pkey)); } +LCRYPTO_ALIAS(NETSCAPE_SPKI_set_pubkey); EVP_PKEY * NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x) @@ -78,6 +79,7 @@ NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x) return (NULL); return (X509_PUBKEY_get(x->spkac->pubkey)); } +LCRYPTO_ALIAS(NETSCAPE_SPKI_get_pubkey); /* Load a Netscape SPKI from a base64 encoded string */ @@ -106,6 +108,7 @@ NETSCAPE_SPKI_b64_decode(const char *str, int len) free(spki_der); return spki; } +LCRYPTO_ALIAS(NETSCAPE_SPKI_b64_decode); /* Generate a base64 encoded string from an SPKI */ @@ -130,3 +133,4 @@ NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *spki) free(der_spki); return b64_str; } +LCRYPTO_ALIAS(NETSCAPE_SPKI_b64_encode); diff --git a/crypto/x509/x509type.c b/crypto/x509/x509type.c index 7495b9ef..ebc02c59 100644 --- a/crypto/x509/x509type.c +++ b/crypto/x509/x509type.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509type.c,v 1.15 2021/12/12 21:30:14 tb Exp $ */ +/* $OpenBSD: x509type.c,v 1.18 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,8 +62,8 @@ #include #include -#include "evp_locl.h" -#include "x509_lcl.h" +#include "evp_local.h" +#include "x509_local.h" int X509_certificate_type(const X509 *x, const EVP_PKEY *pkey) @@ -124,3 +124,4 @@ X509_certificate_type(const X509 *x, const EVP_PKEY *pkey) ret |= EVP_PKT_EXP; return (ret); } +LCRYPTO_ALIAS(X509_certificate_type); diff --git a/crypto/x509/x_all.c b/crypto/x509/x_all.c index 0af130f3..cd6da9f4 100644 --- a/crypto/x509/x_all.c +++ b/crypto/x509/x_all.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x_all.c,v 1.26 2022/06/26 04:14:43 tb Exp $ */ +/* $OpenBSD: x_all.c,v 1.30 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -73,103 +73,91 @@ #include #endif -#include "x509_lcl.h" +#include "x509_local.h" X509 * d2i_X509_bio(BIO *bp, X509 **x509) { return ASN1_item_d2i_bio(&X509_it, bp, x509); } +LCRYPTO_ALIAS(d2i_X509_bio); int i2d_X509_bio(BIO *bp, X509 *x509) { return ASN1_item_i2d_bio(&X509_it, bp, x509); } +LCRYPTO_ALIAS(i2d_X509_bio); X509 * d2i_X509_fp(FILE *fp, X509 **x509) { return ASN1_item_d2i_fp(&X509_it, fp, x509); } +LCRYPTO_ALIAS(d2i_X509_fp); int i2d_X509_fp(FILE *fp, X509 *x509) { return ASN1_item_i2d_fp(&X509_it, fp, x509); } +LCRYPTO_ALIAS(i2d_X509_fp); X509_CRL * d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl) { return ASN1_item_d2i_bio(&X509_CRL_it, bp, crl); } +LCRYPTO_ALIAS(d2i_X509_CRL_bio); int i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl) { return ASN1_item_i2d_bio(&X509_CRL_it, bp, crl); } +LCRYPTO_ALIAS(i2d_X509_CRL_bio); X509_CRL * d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl) { return ASN1_item_d2i_fp(&X509_CRL_it, fp, crl); } +LCRYPTO_ALIAS(d2i_X509_CRL_fp); int i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl) { return ASN1_item_i2d_fp(&X509_CRL_it, fp, crl); } - -PKCS7 * -d2i_PKCS7_bio(BIO *bp, PKCS7 **p7) -{ - return ASN1_item_d2i_bio(&PKCS7_it, bp, p7); -} - -int -i2d_PKCS7_bio(BIO *bp, PKCS7 *p7) -{ - return ASN1_item_i2d_bio(&PKCS7_it, bp, p7); -} - -PKCS7 * -d2i_PKCS7_fp(FILE *fp, PKCS7 **p7) -{ - return ASN1_item_d2i_fp(&PKCS7_it, fp, p7); -} - -int -i2d_PKCS7_fp(FILE *fp, PKCS7 *p7) -{ - return ASN1_item_i2d_fp(&PKCS7_it, fp, p7); -} +LCRYPTO_ALIAS(i2d_X509_CRL_fp); X509_REQ * d2i_X509_REQ_bio(BIO *bp, X509_REQ **req) { return ASN1_item_d2i_bio(&X509_REQ_it, bp, req); } +LCRYPTO_ALIAS(d2i_X509_REQ_bio); int i2d_X509_REQ_bio(BIO *bp, X509_REQ *req) { return ASN1_item_i2d_bio(&X509_REQ_it, bp, req); } +LCRYPTO_ALIAS(i2d_X509_REQ_bio); X509_REQ * d2i_X509_REQ_fp(FILE *fp, X509_REQ **req) { return ASN1_item_d2i_fp(&X509_REQ_it, fp, req); } +LCRYPTO_ALIAS(d2i_X509_REQ_fp); int i2d_X509_REQ_fp(FILE *fp, X509_REQ *req) { return ASN1_item_i2d_fp(&X509_REQ_it, fp, req); } +LCRYPTO_ALIAS(i2d_X509_REQ_fp); #ifndef OPENSSL_NO_RSA RSA * @@ -177,48 +165,56 @@ d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa) { return ASN1_item_d2i_bio(&RSAPrivateKey_it, bp, rsa); } +LCRYPTO_ALIAS(d2i_RSAPrivateKey_bio); int i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa) { return ASN1_item_i2d_bio(&RSAPrivateKey_it, bp, rsa); } +LCRYPTO_ALIAS(i2d_RSAPrivateKey_bio); RSA * d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa) { return ASN1_item_d2i_fp(&RSAPrivateKey_it, fp, rsa); } +LCRYPTO_ALIAS(d2i_RSAPrivateKey_fp); int i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa) { return ASN1_item_i2d_fp(&RSAPrivateKey_it, fp, rsa); } +LCRYPTO_ALIAS(i2d_RSAPrivateKey_fp); RSA * d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa) { return ASN1_item_d2i_bio(&RSAPublicKey_it, bp, rsa); } +LCRYPTO_ALIAS(d2i_RSAPublicKey_bio); int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa) { return ASN1_item_i2d_bio(&RSAPublicKey_it, bp, rsa); } +LCRYPTO_ALIAS(i2d_RSAPublicKey_bio); RSA * d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa) { return ASN1_item_d2i_fp(&RSAPublicKey_it, fp, rsa); } +LCRYPTO_ALIAS(d2i_RSAPublicKey_fp); int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa) { return ASN1_item_i2d_fp(&RSAPublicKey_it, fp, rsa); } +LCRYPTO_ALIAS(i2d_RSAPublicKey_fp); #endif #ifndef OPENSSL_NO_DSA @@ -227,24 +223,28 @@ d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa) { return ASN1_item_d2i_bio(&DSAPrivateKey_it, bp, dsa); } +LCRYPTO_ALIAS(d2i_DSAPrivateKey_bio); int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa) { return ASN1_item_i2d_bio(&DSAPrivateKey_it, bp, dsa); } +LCRYPTO_ALIAS(i2d_DSAPrivateKey_bio); DSA * d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa) { return ASN1_item_d2i_fp(&DSAPrivateKey_it, fp, dsa); } +LCRYPTO_ALIAS(d2i_DSAPrivateKey_fp); int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa) { return ASN1_item_i2d_fp(&DSAPrivateKey_it, fp, dsa); } +LCRYPTO_ALIAS(i2d_DSAPrivateKey_fp); #endif #ifndef OPENSSL_NO_EC @@ -253,24 +253,28 @@ d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey) { return ASN1_d2i_bio_of(EC_KEY, EC_KEY_new, d2i_ECPrivateKey, bp, eckey); } +LCRYPTO_ALIAS(d2i_ECPrivateKey_bio); int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey) { return ASN1_i2d_bio_of(EC_KEY, i2d_ECPrivateKey, bp, eckey); } +LCRYPTO_ALIAS(i2d_ECPrivateKey_bio); EC_KEY * d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey) { return ASN1_d2i_fp_of(EC_KEY, EC_KEY_new, d2i_ECPrivateKey, fp, eckey); } +LCRYPTO_ALIAS(d2i_ECPrivateKey_fp); int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey) { return ASN1_i2d_fp_of(EC_KEY, i2d_ECPrivateKey, fp, eckey); } +LCRYPTO_ALIAS(i2d_ECPrivateKey_fp); #endif X509_SIG * @@ -278,24 +282,28 @@ d2i_PKCS8_bio(BIO *bp, X509_SIG **p8) { return ASN1_item_d2i_bio(&X509_SIG_it, bp, p8); } +LCRYPTO_ALIAS(d2i_PKCS8_bio); int i2d_PKCS8_bio(BIO *bp, X509_SIG *p8) { return ASN1_item_i2d_bio(&X509_SIG_it, bp, p8); } +LCRYPTO_ALIAS(i2d_PKCS8_bio); X509_SIG * d2i_PKCS8_fp(FILE *fp, X509_SIG **p8) { return ASN1_item_d2i_fp(&X509_SIG_it, fp, p8); } +LCRYPTO_ALIAS(d2i_PKCS8_fp); int i2d_PKCS8_fp(FILE *fp, X509_SIG *p8) { return ASN1_item_i2d_fp(&X509_SIG_it, fp, p8); } +LCRYPTO_ALIAS(i2d_PKCS8_fp); PKCS8_PRIV_KEY_INFO * d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO **p8inf) @@ -303,6 +311,7 @@ d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO **p8inf) return ASN1_item_d2i_bio(&PKCS8_PRIV_KEY_INFO_it, bp, p8inf); } +LCRYPTO_ALIAS(d2i_PKCS8_PRIV_KEY_INFO_bio); int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf) @@ -310,6 +319,7 @@ i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf) return ASN1_item_i2d_bio(&PKCS8_PRIV_KEY_INFO_it, bp, p8inf); } +LCRYPTO_ALIAS(i2d_PKCS8_PRIV_KEY_INFO_bio); PKCS8_PRIV_KEY_INFO * d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO **p8inf) @@ -317,6 +327,7 @@ d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO **p8inf) return ASN1_item_d2i_fp(&PKCS8_PRIV_KEY_INFO_it, fp, p8inf); } +LCRYPTO_ALIAS(d2i_PKCS8_PRIV_KEY_INFO_fp); int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf) @@ -324,6 +335,7 @@ i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf) return ASN1_item_i2d_fp(&PKCS8_PRIV_KEY_INFO_it, fp, p8inf); } +LCRYPTO_ALIAS(i2d_PKCS8_PRIV_KEY_INFO_fp); EVP_PKEY * d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a) @@ -331,12 +343,14 @@ d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a) return ASN1_d2i_bio_of(EVP_PKEY, EVP_PKEY_new, d2i_AutoPrivateKey, bp, a); } +LCRYPTO_ALIAS(d2i_PrivateKey_bio); int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey) { return ASN1_i2d_bio_of(EVP_PKEY, i2d_PrivateKey, bp, pkey); } +LCRYPTO_ALIAS(i2d_PrivateKey_bio); EVP_PKEY * d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a) @@ -344,12 +358,14 @@ d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a) return ASN1_d2i_fp_of(EVP_PKEY, EVP_PKEY_new, d2i_AutoPrivateKey, fp, a); } +LCRYPTO_ALIAS(d2i_PrivateKey_fp); int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey) { return ASN1_i2d_fp_of(EVP_PKEY, i2d_PrivateKey, fp, pkey); } +LCRYPTO_ALIAS(i2d_PrivateKey_fp); int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key) @@ -364,6 +380,7 @@ i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key) PKCS8_PRIV_KEY_INFO_free(p8inf); return ret; } +LCRYPTO_ALIAS(i2d_PKCS8PrivateKeyInfo_bio); int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key) @@ -377,6 +394,7 @@ i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key) PKCS8_PRIV_KEY_INFO_free(p8inf); return ret; } +LCRYPTO_ALIAS(i2d_PKCS8PrivateKeyInfo_fp); int X509_verify(X509 *a, EVP_PKEY *r) @@ -386,6 +404,7 @@ X509_verify(X509 *a, EVP_PKEY *r) return (ASN1_item_verify(&X509_CINF_it, a->sig_alg, a->signature, a->cert_info, r)); } +LCRYPTO_ALIAS(X509_verify); int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r) @@ -393,6 +412,7 @@ X509_REQ_verify(X509_REQ *a, EVP_PKEY *r) return (ASN1_item_verify(&X509_REQ_INFO_it, a->sig_alg, a->signature, a->req_info, r)); } +LCRYPTO_ALIAS(X509_REQ_verify); int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r) @@ -400,6 +420,7 @@ NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r) return (ASN1_item_verify(&NETSCAPE_SPKAC_it, a->sig_algor, a->signature, a->spkac, r)); } +LCRYPTO_ALIAS(NETSCAPE_SPKI_verify); int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) @@ -409,6 +430,7 @@ X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md) x->cert_info->signature, x->sig_alg, x->signature, x->cert_info, pkey, md)); } +LCRYPTO_ALIAS(X509_sign); int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx) @@ -418,6 +440,7 @@ X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx) x->cert_info->signature, x->sig_alg, x->signature, x->cert_info, ctx); } +LCRYPTO_ALIAS(X509_sign_ctx); int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md) @@ -425,6 +448,7 @@ X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md) return (ASN1_item_sign(&X509_REQ_INFO_it, x->sig_alg, NULL, x->signature, x->req_info, pkey, md)); } +LCRYPTO_ALIAS(X509_REQ_sign); int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx) @@ -432,6 +456,7 @@ X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx) return ASN1_item_sign_ctx(&X509_REQ_INFO_it, x->sig_alg, NULL, x->signature, x->req_info, ctx); } +LCRYPTO_ALIAS(X509_REQ_sign_ctx); int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md) @@ -440,6 +465,7 @@ X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md) return(ASN1_item_sign(&X509_CRL_INFO_it, x->crl->sig_alg, x->sig_alg, x->signature, x->crl, pkey, md)); } +LCRYPTO_ALIAS(X509_CRL_sign); int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx) @@ -448,6 +474,7 @@ X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx) return ASN1_item_sign_ctx(&X509_CRL_INFO_it, x->crl->sig_alg, x->sig_alg, x->signature, x->crl, ctx); } +LCRYPTO_ALIAS(X509_CRL_sign_ctx); int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md) @@ -455,6 +482,7 @@ NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md) return (ASN1_item_sign(&NETSCAPE_SPKAC_it, x->sig_algor, NULL, x->signature, x->spkac, pkey, md)); } +LCRYPTO_ALIAS(NETSCAPE_SPKI_sign); int X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md, @@ -466,6 +494,7 @@ X509_pubkey_digest(const X509 *data, const EVP_MD *type, unsigned char *md, return 0; return EVP_Digest(key->data, key->length, md, len, type, NULL); } +LCRYPTO_ALIAS(X509_pubkey_digest); int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, @@ -474,6 +503,7 @@ X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, return (ASN1_item_digest(&X509_it, type, (char *)data, md, len)); } +LCRYPTO_ALIAS(X509_digest); int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, @@ -482,6 +512,7 @@ X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, return (ASN1_item_digest(&X509_CRL_it, type, (char *)data, md, len)); } +LCRYPTO_ALIAS(X509_CRL_digest); int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, unsigned char *md, @@ -490,6 +521,7 @@ X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, unsigned char *md, return (ASN1_item_digest(&X509_REQ_it, type, (char *)data, md, len)); } +LCRYPTO_ALIAS(X509_REQ_digest); int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, unsigned char *md, @@ -498,14 +530,7 @@ X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, unsigned char *md, return (ASN1_item_digest(&X509_NAME_it, type, (char *)data, md, len)); } - -int -PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, - const EVP_MD *type, unsigned char *md, unsigned int *len) -{ - return(ASN1_item_digest(&PKCS7_ISSUER_AND_SERIAL_it, type, - (char *)data, md, len)); -} +LCRYPTO_ALIAS(X509_NAME_digest); int X509_up_ref(X509 *x) @@ -513,3 +538,4 @@ X509_up_ref(X509 *x) int i = CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); return i > 1 ? 1 : 0; } +LCRYPTO_ALIAS(X509_up_ref); diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 1d1a1593..44ab86b4 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -6,3 +6,26 @@ if(ENABLE_LIBRESSL_INSTALL) PATTERN "pqueue.h" EXCLUDE PATTERN "Makefile*" EXCLUDE) endif(ENABLE_LIBRESSL_INSTALL) + +if(HOST_AARCH64) + file(READ arch/aarch64/opensslconf.h OPENSSLCONF) +elseif(HOST_ARM) + file(READ arch/arm/opensslconf.h OPENSSLCONF) +elseif(HOST_I386) + file(READ arch/i386/opensslconf.h OPENSSLCONF) +elseif(HOST_MIPS) + file(READ arch/mips/opensslconf.h OPENSSLCONF) +elseif(HOST_MIPS64) + file(READ arch/mips64/opensslconf.h OPENSSLCONF) +elseif(HOST_POWERPC) + file(READ arch/powerpc/opensslconf.h OPENSSLCONF) +elseif(HOST_POWERPC64) + file(READ arch/powerpc64/opensslconf.h OPENSSLCONF) +elseif(HOST_RISCV64) + file(READ arch/riscv64/opensslconf.h OPENSSLCONF) +elseif(HOST_SPARC64) + file(READ arch/sparc64/opensslconf.h OPENSSLCONF) +elseif(HOST_X86_64) + file(READ arch/amd64/opensslconf.h OPENSSLCONF) +endif() +file(WRITE openssl/opensslconf.h "${OPENSSLCONF}") diff --git a/include/Makefile.am b/include/Makefile.am index aed67211..077637df 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -44,4 +44,19 @@ noinst_HEADERS += compat/sys/time.h noinst_HEADERS += compat/sys/types.h noinst_HEADERS += compat/sys/uio.h +noinst_HEADERS += arch/aarch64/opensslconf.h +noinst_HEADERS += arch/alpha/opensslconf.h +noinst_HEADERS += arch/amd64/opensslconf.h +noinst_HEADERS += arch/arm/opensslconf.h +noinst_HEADERS += arch/hppa/opensslconf.h +noinst_HEADERS += arch/i386/opensslconf.h +noinst_HEADERS += arch/m88k/opensslconf.h +noinst_HEADERS += arch/mips/opensslconf.h +noinst_HEADERS += arch/mips64/opensslconf.h +noinst_HEADERS += arch/powerpc/opensslconf.h +noinst_HEADERS += arch/powerpc64/opensslconf.h +noinst_HEADERS += arch/riscv64/opensslconf.h +noinst_HEADERS += arch/sh/opensslconf.h +noinst_HEADERS += arch/sparc64/opensslconf.h + include_HEADERS = tls.h diff --git a/include/Makefile.in b/include/Makefile.in index 7834ca8d..e15c5ab9 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -344,9 +344,9 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ - -DLIBRESSL_INTERNAL -D__BEGIN_HIDDEN_DECLS= \ - -D__END_HIDDEN_DECLS= +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(abs_top_builddir)/include \ + -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL \ + -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= EXTRA_DIST = CMakeLists.txt SUBDIRS = openssl noinst_HEADERS = pqueue.h compat/dirent.h compat/dirent_msvc.h \ @@ -360,7 +360,14 @@ noinst_HEADERS = pqueue.h compat/dirent.h compat/dirent_msvc.h \ compat/sys/mman.h compat/sys/param.h compat/sys/queue.h \ compat/sys/select.h compat/sys/socket.h compat/sys/stat.h \ compat/sys/tree.h compat/sys/time.h compat/sys/types.h \ - compat/sys/uio.h + compat/sys/uio.h arch/aarch64/opensslconf.h \ + arch/alpha/opensslconf.h arch/amd64/opensslconf.h \ + arch/arm/opensslconf.h arch/hppa/opensslconf.h \ + arch/i386/opensslconf.h arch/m88k/opensslconf.h \ + arch/mips/opensslconf.h arch/mips64/opensslconf.h \ + arch/powerpc/opensslconf.h arch/powerpc64/opensslconf.h \ + arch/riscv64/opensslconf.h arch/sh/opensslconf.h \ + arch/sparc64/opensslconf.h include_HEADERS = tls.h all: all-recursive diff --git a/include/arch/aarch64/opensslconf.h b/include/arch/aarch64/opensslconf.h new file mode 100644 index 00000000..748ed8f8 --- /dev/null +++ b/include/arch/aarch64/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#define RC4_CHUNK unsigned long +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#undef BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#define SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#undef THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/alpha/opensslconf.h b/include/arch/alpha/opensslconf.h new file mode 100644 index 00000000..47f2aa8f --- /dev/null +++ b/include/arch/alpha/opensslconf.h @@ -0,0 +1,152 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#define RC4_CHUNK unsigned long +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#undef BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#define SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#undef THIRTY_TWO_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#define BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#define DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#define DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#undef DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/amd64/opensslconf.h b/include/arch/amd64/opensslconf.h new file mode 100644 index 00000000..5cad089a --- /dev/null +++ b/include/arch/amd64/opensslconf.h @@ -0,0 +1,149 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#define RC4_CHUNK unsigned long +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#undef BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +#define SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#undef THIRTY_TWO_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/arm/opensslconf.h b/include/arch/arm/opensslconf.h new file mode 100644 index 00000000..f17d3d28 --- /dev/null +++ b/include/arch/arm/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/hppa/opensslconf.h b/include/arch/hppa/opensslconf.h new file mode 100644 index 00000000..f17d3d28 --- /dev/null +++ b/include/arch/hppa/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/i386/opensslconf.h b/include/arch/i386/opensslconf.h new file mode 100644 index 00000000..3b3827cd --- /dev/null +++ b/include/arch/i386/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned long +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#define DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#define DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/m88k/opensslconf.h b/include/arch/m88k/opensslconf.h new file mode 100644 index 00000000..f17d3d28 --- /dev/null +++ b/include/arch/m88k/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/mips/opensslconf.h b/include/arch/mips/opensslconf.h new file mode 100644 index 00000000..f17d3d28 --- /dev/null +++ b/include/arch/mips/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/mips64/opensslconf.h b/include/arch/mips64/opensslconf.h new file mode 100644 index 00000000..ed1204c8 --- /dev/null +++ b/include/arch/mips64/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#define RC4_CHUNK unsigned long +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#undef BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#define SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#undef THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#define BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#define DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#define DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#undef DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/powerpc/opensslconf.h b/include/arch/powerpc/opensslconf.h new file mode 100644 index 00000000..f17d3d28 --- /dev/null +++ b/include/arch/powerpc/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/powerpc64/opensslconf.h b/include/arch/powerpc64/opensslconf.h new file mode 100644 index 00000000..5cad089a --- /dev/null +++ b/include/arch/powerpc64/opensslconf.h @@ -0,0 +1,149 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#define RC4_CHUNK unsigned long +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#undef BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +#define SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#undef THIRTY_TWO_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/riscv64/opensslconf.h b/include/arch/riscv64/opensslconf.h new file mode 100644 index 00000000..748ed8f8 --- /dev/null +++ b/include/arch/riscv64/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#define RC4_CHUNK unsigned long +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#undef BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#define SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#undef THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/sh/opensslconf.h b/include/arch/sh/opensslconf.h new file mode 100644 index 00000000..f17d3d28 --- /dev/null +++ b/include/arch/sh/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#undef RC4_CHUNK +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#define BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#undef SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#define THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#define RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#undef BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#undef DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#undef DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#define DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/arch/sparc64/opensslconf.h b/include/arch/sparc64/opensslconf.h new file mode 100644 index 00000000..ed1204c8 --- /dev/null +++ b/include/arch/sparc64/opensslconf.h @@ -0,0 +1,154 @@ +#include +/* crypto/opensslconf.h.in */ + +#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) +#define OPENSSLDIR "/etc/ssl" +#endif + +#undef OPENSSL_UNISTD +#define OPENSSL_UNISTD + +#undef OPENSSL_EXPORT_VAR_AS_FUNCTION + +#if defined(HEADER_IDEA_H) && !defined(IDEA_INT) +#define IDEA_INT unsigned int +#endif + +#if defined(HEADER_MD2_H) && !defined(MD2_INT) +#define MD2_INT unsigned int +#endif + +#if defined(HEADER_RC2_H) && !defined(RC2_INT) +/* I need to put in a mod for the alpha - eay */ +#define RC2_INT unsigned int +#endif + +#if defined(HEADER_RC4_H) +#if !defined(RC4_INT) +/* using int types make the structure larger but make the code faster + * on most boxes I have tested - up to %20 faster. */ +/* + * I don't know what does "most" mean, but declaring "int" is a must on: + * - Intel P6 because partial register stalls are very expensive; + * - elder Alpha because it lacks byte load/store instructions; + */ +#define RC4_INT unsigned int +#endif +#if !defined(RC4_CHUNK) +/* + * This enables code handling data aligned at natural CPU word + * boundary. See crypto/rc4/rc4_enc.c for further details. + */ +#define RC4_CHUNK unsigned long +#endif +#endif + +#if (defined(HEADER_NEW_DES_H) || defined(HEADER_DES_H)) && !defined(DES_LONG) +/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a + * %20 speed up (longs are 8 bytes, int's are 4). */ +#ifndef DES_LONG +#define DES_LONG unsigned int +#endif +#endif + +#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) +#define CONFIG_HEADER_BN_H +#undef BN_LLONG + +/* Should we define BN_DIV2W here? */ + +/* Only one for the following should be defined */ +/* The prime number generation stuff may not work when + * EIGHT_BIT but I don't care since I've only used this mode + * for debugging the bignum libraries */ +#define SIXTY_FOUR_BIT_LONG +#undef SIXTY_FOUR_BIT +#undef THIRTY_TWO_BIT +#undef SIXTEEN_BIT +#undef EIGHT_BIT +#endif + +#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H) +#define CONFIG_HEADER_RC4_LOCL_H +/* if this is defined data[i] is used instead of *data, this is a %20 + * speedup on x86 */ +#undef RC4_INDEX +#endif + +#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H) +#define CONFIG_HEADER_BF_LOCL_H +#define BF_PTR +#endif /* HEADER_BF_LOCL_H */ + +#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H) +#define CONFIG_HEADER_DES_LOCL_H +#ifndef DES_DEFAULT_OPTIONS +/* the following is tweaked from a config script, that is why it is a + * protected undef/define */ +#ifndef DES_PTR +#define DES_PTR +#endif + +/* This helps C compiler generate the correct code for multiple functional + * units. It reduces register dependencies at the expense of 2 more + * registers */ +#ifndef DES_RISC1 +#undef DES_RISC1 +#endif + +#ifndef DES_RISC2 +#define DES_RISC2 +#endif + +#if defined(DES_RISC1) && defined(DES_RISC2) +YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! +#endif + +/* Unroll the inner loop, this sometimes helps, sometimes hinders. + * Very much CPU dependent */ +#ifndef DES_UNROLL +#undef DES_UNROLL +#endif + +/* These default values were supplied by + * Peter Gutman + * They are only used if nothing else has been defined */ +#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL) +/* Special defines which change the way the code is built depending on the + CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find + even newer MIPS CPU's, but at the moment one size fits all for + optimization options. Older Sparc's work better with only UNROLL, but + there's no way to tell at compile time what it is you're running on */ + +#if defined( sun ) /* Newer Sparc's */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#elif defined( __ultrix ) /* Older MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined( __osf1__ ) /* Alpha */ +# define DES_PTR +# define DES_RISC2 +#elif defined ( _AIX ) /* RS6000 */ + /* Unknown */ +#elif defined( __hpux ) /* HP-PA */ + /* Unknown */ +#elif defined( __aux ) /* 68K */ + /* Unknown */ +#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */ +# define DES_UNROLL +#elif defined( __sgi ) /* Newer MIPS */ +# define DES_PTR +# define DES_RISC2 +# define DES_UNROLL +#elif defined(i386) || defined(__i386__) /* x86 boxes, should be gcc */ +# define DES_PTR +# define DES_RISC1 +# define DES_UNROLL +#endif /* Systems-specific speed defines */ +#endif + +#endif /* DES_DEFAULT_OPTIONS */ +#endif /* HEADER_DES_LOCL_H */ diff --git a/include/openssl/Makefile.am b/include/openssl/Makefile.am index 7e73fd0e..fe363a0b 100644 --- a/include/openssl/Makefile.am +++ b/include/openssl/Makefile.am @@ -3,7 +3,43 @@ include $(top_srcdir)/Makefile.am.common if !ENABLE_LIBTLS_ONLY opensslincludedir=$(includedir)/openssl -opensslinclude_HEADERS = +BUILT_SOURCES = opensslconf.h +CLEANFILES = opensslconf.h + +opensslconf.h: Makefile + -echo "generating opensslconf.h ..." +if HOST_AARCH64 + -cp $(top_srcdir)/include/arch/aarch64/opensslconf.h opensslconf.h +endif +if HOST_ARM + -cp $(top_srcdir)/include/arch/arm/opensslconf.h opensslconf.h +endif +if HOST_I386 + -cp $(top_srcdir)/include/arch/i386/opensslconf.h opensslconf.h +endif +if HOST_MIPS + -cp $(top_srcdir)/include/arch/mips/opensslconf.h opensslconf.h +endif +if HOST_MIPS64 + -cp $(top_srcdir)/include/arch/mips64/opensslconf.h opensslconf.h +endif +if HOST_POWERPC + -cp $(top_srcdir)/include/arch/powerpc/opensslconf.h opensslconf.h +endif +if HOST_POWERPC64 + -cp $(top_srcdir)/include/arch/powerpc64/opensslconf.h opensslconf.h +endif +if HOST_RISCV64 + -cp $(top_srcdir)/include/arch/riscv64/opensslconf.h opensslconf.h +endif +if HOST_SPARC64 + -cp $(top_srcdir)/include/arch/sparc64/opensslconf.h opensslconf.h +endif +if HOST_X86_64 + -cp $(top_srcdir)/include/arch/amd64/opensslconf.h opensslconf.h +endif + +opensslinclude_HEADERS = opensslconf.h opensslinclude_HEADERS += aes.h opensslinclude_HEADERS += asn1.h opensslinclude_HEADERS += asn1t.h @@ -45,7 +81,6 @@ opensslinclude_HEADERS += modes.h opensslinclude_HEADERS += obj_mac.h opensslinclude_HEADERS += objects.h opensslinclude_HEADERS += ocsp.h -opensslinclude_HEADERS += opensslconf.h opensslinclude_HEADERS += opensslfeatures.h opensslinclude_HEADERS += opensslv.h opensslinclude_HEADERS += ossl_typ.h @@ -76,7 +111,6 @@ opensslinclude_HEADERS += ui.h opensslinclude_HEADERS += ui_compat.h opensslinclude_HEADERS += whrlpool.h opensslinclude_HEADERS += x509.h -opensslinclude_HEADERS += x509_verify.h opensslinclude_HEADERS += x509_vfy.h opensslinclude_HEADERS += x509v3.h endif diff --git a/include/openssl/Makefile.in b/include/openssl/Makefile.in index 679bfe06..286517b6 100644 --- a/include/openssl/Makefile.in +++ b/include/openssl/Makefile.in @@ -125,17 +125,17 @@ am__can_run_installinfo = \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac -am__opensslinclude_HEADERS_DIST = aes.h asn1.h asn1t.h bio.h \ - blowfish.h bn.h buffer.h camellia.h cast.h chacha.h cmac.h \ - cms.h comp.h conf.h conf_api.h crypto.h ct.h curve25519.h \ - des.h dh.h dsa.h dso.h dtls1.h ec.h ecdh.h ecdsa.h engine.h \ - err.h evp.h gost.h hkdf.h hmac.h idea.h kdf.h lhash.h md4.h \ - md5.h modes.h obj_mac.h objects.h ocsp.h opensslconf.h \ +am__opensslinclude_HEADERS_DIST = opensslconf.h aes.h asn1.h asn1t.h \ + bio.h blowfish.h bn.h buffer.h camellia.h cast.h chacha.h \ + cmac.h cms.h comp.h conf.h conf_api.h crypto.h ct.h \ + curve25519.h des.h dh.h dsa.h dso.h dtls1.h ec.h ecdh.h \ + ecdsa.h engine.h err.h evp.h gost.h hkdf.h hmac.h idea.h kdf.h \ + lhash.h md4.h md5.h modes.h obj_mac.h objects.h ocsp.h \ opensslfeatures.h opensslv.h ossl_typ.h pem.h pem2.h pkcs12.h \ pkcs7.h poly1305.h rand.h rc2.h rc4.h ripemd.h rsa.h \ safestack.h sha.h sm3.h sm4.h srtp.h ssl.h ssl2.h ssl23.h \ ssl3.h stack.h tls1.h ts.h txt_db.h ui.h ui_compat.h \ - whrlpool.h x509.h x509_verify.h x509_vfy.h x509v3.h + whrlpool.h x509.h x509_vfy.h x509v3.h am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -313,12 +313,14 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ - -DLIBRESSL_INTERNAL -D__BEGIN_HIDDEN_DECLS= \ - -D__END_HIDDEN_DECLS= +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(abs_top_builddir)/include \ + -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL \ + -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= @ENABLE_LIBTLS_ONLY_FALSE@opensslincludedir = $(includedir)/openssl -@ENABLE_LIBTLS_ONLY_FALSE@opensslinclude_HEADERS = aes.h asn1.h \ -@ENABLE_LIBTLS_ONLY_FALSE@ asn1t.h bio.h blowfish.h bn.h \ +@ENABLE_LIBTLS_ONLY_FALSE@BUILT_SOURCES = opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@CLEANFILES = opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@opensslinclude_HEADERS = opensslconf.h aes.h \ +@ENABLE_LIBTLS_ONLY_FALSE@ asn1.h asn1t.h bio.h blowfish.h bn.h \ @ENABLE_LIBTLS_ONLY_FALSE@ buffer.h camellia.h cast.h chacha.h \ @ENABLE_LIBTLS_ONLY_FALSE@ cmac.h cms.h comp.h conf.h \ @ENABLE_LIBTLS_ONLY_FALSE@ conf_api.h crypto.h ct.h \ @@ -327,16 +329,17 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ @ENABLE_LIBTLS_ONLY_FALSE@ err.h evp.h gost.h hkdf.h hmac.h \ @ENABLE_LIBTLS_ONLY_FALSE@ idea.h kdf.h lhash.h md4.h md5.h \ @ENABLE_LIBTLS_ONLY_FALSE@ modes.h obj_mac.h objects.h ocsp.h \ -@ENABLE_LIBTLS_ONLY_FALSE@ opensslconf.h opensslfeatures.h \ -@ENABLE_LIBTLS_ONLY_FALSE@ opensslv.h ossl_typ.h pem.h pem2.h \ -@ENABLE_LIBTLS_ONLY_FALSE@ pkcs12.h pkcs7.h poly1305.h rand.h \ -@ENABLE_LIBTLS_ONLY_FALSE@ rc2.h rc4.h ripemd.h rsa.h \ -@ENABLE_LIBTLS_ONLY_FALSE@ safestack.h sha.h sm3.h sm4.h srtp.h \ -@ENABLE_LIBTLS_ONLY_FALSE@ ssl.h ssl2.h ssl23.h ssl3.h stack.h \ -@ENABLE_LIBTLS_ONLY_FALSE@ tls1.h ts.h txt_db.h ui.h \ -@ENABLE_LIBTLS_ONLY_FALSE@ ui_compat.h whrlpool.h x509.h \ -@ENABLE_LIBTLS_ONLY_FALSE@ x509_verify.h x509_vfy.h x509v3.h -all: all-am +@ENABLE_LIBTLS_ONLY_FALSE@ opensslfeatures.h opensslv.h \ +@ENABLE_LIBTLS_ONLY_FALSE@ ossl_typ.h pem.h pem2.h pkcs12.h \ +@ENABLE_LIBTLS_ONLY_FALSE@ pkcs7.h poly1305.h rand.h rc2.h \ +@ENABLE_LIBTLS_ONLY_FALSE@ rc4.h ripemd.h rsa.h safestack.h \ +@ENABLE_LIBTLS_ONLY_FALSE@ sha.h sm3.h sm4.h srtp.h ssl.h \ +@ENABLE_LIBTLS_ONLY_FALSE@ ssl2.h ssl23.h ssl3.h stack.h tls1.h \ +@ENABLE_LIBTLS_ONLY_FALSE@ ts.h txt_db.h ui.h ui_compat.h \ +@ENABLE_LIBTLS_ONLY_FALSE@ whrlpool.h x509.h x509_vfy.h \ +@ENABLE_LIBTLS_ONLY_FALSE@ x509v3.h +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.common $(am__configure_deps) @@ -482,14 +485,17 @@ distdir-am: $(DISTFILES) fi; \ done check-am: all-am -check: check-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(HEADERS) installdirs: for dir in "$(DESTDIR)$(opensslincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: install-am -install-exec: install-exec-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -510,6 +516,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -518,6 +525,7 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am @@ -584,7 +592,7 @@ ps-am: uninstall-am: uninstall-opensslincludeHEADERS -.MAKE: install-am install-strip +.MAKE: all check install install-am install-exec install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool cscopelist-am ctags ctags-am distclean \ @@ -603,6 +611,19 @@ uninstall-am: uninstall-opensslincludeHEADERS .PRECIOUS: Makefile +@ENABLE_LIBTLS_ONLY_FALSE@opensslconf.h: Makefile +@ENABLE_LIBTLS_ONLY_FALSE@ -echo "generating opensslconf.h ..." +@ENABLE_LIBTLS_ONLY_FALSE@@HOST_AARCH64_TRUE@ -cp $(top_srcdir)/include/arch/aarch64/opensslconf.h opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@@HOST_ARM_TRUE@ -cp $(top_srcdir)/include/arch/arm/opensslconf.h opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@@HOST_I386_TRUE@ -cp $(top_srcdir)/include/arch/i386/opensslconf.h opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@@HOST_MIPS_TRUE@ -cp $(top_srcdir)/include/arch/mips/opensslconf.h opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@@HOST_MIPS64_TRUE@ -cp $(top_srcdir)/include/arch/mips64/opensslconf.h opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@@HOST_POWERPC_TRUE@ -cp $(top_srcdir)/include/arch/powerpc/opensslconf.h opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@@HOST_POWERPC64_TRUE@ -cp $(top_srcdir)/include/arch/powerpc64/opensslconf.h opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@@HOST_RISCV64_TRUE@ -cp $(top_srcdir)/include/arch/riscv64/opensslconf.h opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@@HOST_SPARC64_TRUE@ -cp $(top_srcdir)/include/arch/sparc64/opensslconf.h opensslconf.h +@ENABLE_LIBTLS_ONLY_FALSE@@HOST_X86_64_TRUE@ -cp $(top_srcdir)/include/arch/amd64/opensslconf.h opensslconf.h + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/include/openssl/asn1.h b/include/openssl/asn1.h index ff42e456..fc1d4be0 100644 --- a/include/openssl/asn1.h +++ b/include/openssl/asn1.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1.h,v 1.70 2022/09/11 17:22:52 tb Exp $ */ +/* $OpenBSD: asn1.h,v 1.72 2022/11/13 13:59:46 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -838,6 +838,7 @@ int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v); int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags); int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, unsigned char *buf, int off); +int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int indent); int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent); int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, int dump); #endif diff --git a/include/openssl/blowfish.h b/include/openssl/blowfish.h index 260545e6..592bd831 100644 --- a/include/openssl/blowfish.h +++ b/include/openssl/blowfish.h @@ -1,25 +1,25 @@ -/* $OpenBSD: blowfish.h,v 1.15 2021/11/30 18:31:36 tb Exp $ */ +/* $OpenBSD: blowfish.h,v 1.16 2022/11/11 12:08:29 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. - * + * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * + * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -34,10 +34,10 @@ * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from + * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * + * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -49,7 +49,7 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * + * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence @@ -85,23 +85,23 @@ extern "C" { #define BF_BLOCK 8 typedef struct bf_key_st { - BF_LONG P[BF_ROUNDS+2]; + BF_LONG P[BF_ROUNDS + 2]; BF_LONG S[4*256]; } BF_KEY; void BF_set_key(BF_KEY *key, int len, const unsigned char *data); -void BF_encrypt(BF_LONG *data,const BF_KEY *key); -void BF_decrypt(BF_LONG *data,const BF_KEY *key); +void BF_encrypt(BF_LONG *data, const BF_KEY *key); +void BF_decrypt(BF_LONG *data, const BF_KEY *key); void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, - const BF_KEY *key, int enc); + const BF_KEY *key, int enc); void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int enc); + const BF_KEY *schedule, unsigned char *ivec, int enc); void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); + const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int *num); + const BF_KEY *schedule, unsigned char *ivec, int *num); const char *BF_options(void); #ifdef __cplusplus diff --git a/include/openssl/bn.h b/include/openssl/bn.h index 5ac41438..ba6c25ba 100644 --- a/include/openssl/bn.h +++ b/include/openssl/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.55 2022/07/12 14:42:48 kn Exp $ */ +/* $OpenBSD: bn.h,v 1.57 2022/12/17 15:56:25 jsing Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -138,18 +138,6 @@ extern "C" { #endif -/* These preprocessor symbols control various aspects of the bignum headers and - * library code. They're not defined by any "normal" configuration, as they are - * intended for development and testing purposes. NB: defining all three can be - * useful for debugging application code as well as openssl itself. - * - * BN_DEBUG - turn on various debugging alterations to the bignum code - * BN_DEBUG_RAND - uses random poisoning of unused words to trip up - * mismanagement of bignum internals. You must also define BN_DEBUG. - */ -/* #define BN_DEBUG */ -/* #define BN_DEBUG_RAND */ - #ifndef OPENSSL_SMALL_FOOTPRINT #define BN_MUL_COMBA #define BN_SQR_COMBA @@ -341,6 +329,10 @@ int BN_is_one(const BIGNUM *a); int BN_is_word(const BIGNUM *a, const BN_ULONG w); int BN_is_odd(const BIGNUM *a); +#if defined(LIBRESSL_INTERNAL) || defined(LIBRESSL_NEXT_API) +void BN_zero(BIGNUM *a); +int BN_one(BIGNUM *a); +#else #define BN_one(a) BN_set_word((a), 1) void BN_zero_ex(BIGNUM *a); @@ -350,6 +342,7 @@ void BN_zero_ex(BIGNUM *a); #else #define BN_zero(a) (BN_set_word((a),0)) #endif +#endif const BIGNUM *BN_value_one(void); char * BN_options(void); diff --git a/include/openssl/comp.h b/include/openssl/comp.h index 7c99ead3..58b51c6e 100644 --- a/include/openssl/comp.h +++ b/include/openssl/comp.h @@ -1,4 +1,116 @@ -/* $OpenBSD: comp.h,v 1.9 2022/01/14 08:21:12 tb Exp $ */ +/* $OpenBSD: comp.h,v 1.11 2022/12/24 07:12:09 tb Exp $ */ +/* + * --------------------------------------------------------------------------- + * Patches to this file were contributed by + * Dr. Stephen Henson . + * --------------------------------------------------------------------------- + * Copyright (c) 1999, 2002, 2008 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * licensing@OpenSSL.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --------------------------------------------------------------------------- + * Parts of this file are derived from SSLeay code + * which is covered by the following Copyright and license: + * --------------------------------------------------------------------------- + * Copyright (c) 1998 Eric Young + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young . + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson . + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given + * attribution as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young " + * The word 'cryptographic' can be left out if the rouines from the + * library being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) + * from the apps directory (application code) you must include an + * acknowledgement: "This product includes software written + * by Tim Hudson " + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version + * or derivative of this code cannot be changed. i.e. this code cannot + * simply be copied and put under another distribution licence + * [including the GNU Public Licence.] + */ #ifndef HEADER_COMP_H #define HEADER_COMP_H diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h index 3b00f039..066f6246 100644 --- a/include/openssl/crypto.h +++ b/include/openssl/crypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.h,v 1.57 2022/09/11 17:26:51 tb Exp $ */ +/* $OpenBSD: crypto.h,v 1.58 2022/12/26 07:18:50 jmc Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -248,8 +248,8 @@ DECLARE_STACK_OF(void) * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ typedef struct crypto_ex_data_func_st { - long argl; /* Arbitary long */ - void *argp; /* Arbitary void * */ + long argl; /* Arbitrary long */ + void *argp; /* Arbitrary void * */ CRYPTO_EX_new *new_func; CRYPTO_EX_free *free_func; CRYPTO_EX_dup *dup_func; @@ -540,7 +540,7 @@ void ERR_load_CRYPTO_strings(void); #define _OPENSSL_INIT_FLAG_NOOP 0x80000000L /* - * These are provided for compatibiliy, but have no effect + * These are provided for compatibility, but have no effect * on how LibreSSL is initialized. */ #define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS _OPENSSL_INIT_FLAG_NOOP diff --git a/include/openssl/curve25519.h b/include/openssl/curve25519.h index c16a4e26..e42bc22c 100644 --- a/include/openssl/curve25519.h +++ b/include/openssl/curve25519.h @@ -1,4 +1,4 @@ -/* $OpenBSD: curve25519.h,v 1.3 2019/05/11 15:55:52 tb Exp $ */ +/* $OpenBSD: curve25519.h,v 1.7 2022/11/13 14:05:04 tb Exp $ */ /* * Copyright (c) 2015, Google Inc. * @@ -61,6 +61,42 @@ int X25519(uint8_t out_shared_key[X25519_KEY_LENGTH], const uint8_t private_key[X25519_KEY_LENGTH], const uint8_t peers_public_value[X25519_KEY_LENGTH]); +/* + * ED25519 + * + * Ed25519 is a signature scheme using a twisted Edwards curve that is + * birationally equivalent to curve25519. + */ + +#define ED25519_PRIVATE_KEY_LENGTH 32 +#define ED25519_PUBLIC_KEY_LENGTH 32 +#define ED25519_SIGNATURE_LENGTH 64 + +/* + * ED25519_keypair sets |out_public_key| and |out_private_key| to a freshly + * generated, public/private key pair. + */ +void ED25519_keypair(uint8_t out_public_key[ED25519_PUBLIC_KEY_LENGTH], + uint8_t out_private_key[ED25519_PRIVATE_KEY_LENGTH]); + +/* + * ED25519_sign sets |out_sig| to be a signature of |message_len| bytes from + * |message| using |public_key| and |private_key|. It returns one on success + * or zero on allocation failure. + */ +int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, + const uint8_t public_key[ED25519_PUBLIC_KEY_LENGTH], + const uint8_t private_key_seed[ED25519_PRIVATE_KEY_LENGTH]); + +/* + * ED25519_verify returns one iff |signature| is a valid signature by + * |public_key| of |message_len| bytes from |message|. It returns zero + * otherwise. + */ +int ED25519_verify(const uint8_t *message, size_t message_len, + const uint8_t signature[ED25519_SIGNATURE_LENGTH], + const uint8_t public_key[ED25519_PUBLIC_KEY_LENGTH]); + #if defined(__cplusplus) } /* extern C */ #endif diff --git a/include/openssl/dsa.h b/include/openssl/dsa.h index eab35a6f..1fa5fc31 100644 --- a/include/openssl/dsa.h +++ b/include/openssl/dsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa.h,v 1.39 2022/07/12 14:42:49 kn Exp $ */ +/* $OpenBSD: dsa.h,v 1.40 2023/03/04 20:47:04 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -272,6 +272,7 @@ void ERR_load_DSA_strings(void); #define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100 #define DSA_R_DECODE_ERROR 104 #define DSA_R_INVALID_DIGEST_TYPE 106 +#define DSA_R_INVALID_PARAMETERS 112 #define DSA_R_MISSING_PARAMETERS 101 #define DSA_R_MODULUS_TOO_LARGE 103 #define DSA_R_NEED_NEW_SETUP_VALUES 110 diff --git a/include/openssl/dso.h b/include/openssl/dso.h index ae07b0a5..c3963a8e 100644 --- a/include/openssl/dso.h +++ b/include/openssl/dso.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dso.h,v 1.13 2022/07/12 14:42:49 kn Exp $ */ +/* $OpenBSD: dso.h,v 1.14 2022/12/26 07:18:51 jmc Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -109,14 +109,14 @@ typedef struct dso_st DSO; /* The function prototype used for method functions (or caller-provided * callbacks) that transform filenames. They are passed a DSO structure pointer - * (or NULL if they are to be used independantly of a DSO object) and a + * (or NULL if they are to be used independently of a DSO object) and a * filename to transform. They should either return NULL (if there is an error * condition) or a newly allocated string containing the transformed form that * the caller will need to free with free() when done. */ typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *); /* The function prototype used for method functions (or caller-provided * callbacks) that merge two file specifications. They are passed a - * DSO structure pointer (or NULL if they are to be used independantly of + * DSO structure pointer (or NULL if they are to be used independently of * a DSO object) and two file specifications to merge. They should * either return NULL (if there is an error condition) or a newly allocated * string containing the result of merging that the caller will need @@ -285,7 +285,7 @@ DSO_METHOD *DSO_METHOD_dlfcn(void); * containing 'addr' into 'sz' large caller-provided 'path' and * returns the number of characters [including trailing zero] * written to it. If 'sz' is 0 or negative, 'path' is ignored and - * required amount of charachers [including trailing zero] to + * required amount of characters [including trailing zero] to * accommodate pathname is returned. If 'addr' is NULL, then * pathname of cryptolib itself is returned. Negative or zero * return value denotes error. diff --git a/include/openssl/ec.h b/include/openssl/ec.h index 52c8f2f3..8ba62c87 100644 --- a/include/openssl/ec.h +++ b/include/openssl/ec.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ec.h,v 1.28 2022/07/12 14:42:49 kn Exp $ */ +/* $OpenBSD: ec.h,v 1.31 2023/03/08 05:45:31 jsing Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -198,7 +198,9 @@ void EC_GROUP_free(EC_GROUP *group); /** Clears and frees a EC_GROUP object * \param group EC_GROUP object to be cleared and freed. */ +#ifndef LIBRESSL_INTERNAL void EC_GROUP_clear_free(EC_GROUP *group); +#endif /** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD. * \param dst destination EC_GROUP object @@ -232,7 +234,7 @@ int EC_METHOD_get_field_type(const EC_METHOD *meth); * \param order the order of the group generated by the generator. * \param cofactor the index of the sub-group generated by the generator * in the group of all points on the elliptic curve. - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIGNUM *order, const BIGNUM *cofactor); @@ -246,7 +248,7 @@ const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); * \param group EC_GROUP object * \param order BIGNUM to which the order is copied * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); @@ -256,7 +258,7 @@ int EC_GROUP_order_bits(const EC_GROUP *group); * \param group EC_GROUP object * \param cofactor BIGNUM to which the cofactor is copied * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx); @@ -293,7 +295,7 @@ int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, * \param a BIGNUM with parameter a of the equation * \param b BIGNUM with parameter b of the equation * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); @@ -303,7 +305,7 @@ int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, co * \param a BIGNUM for parameter a of the equation * \param b BIGNUM for parameter b of the equation * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); @@ -314,7 +316,7 @@ int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM * * \param a BIGNUM with parameter a of the equation * \param b BIGNUM with parameter b of the equation * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); @@ -324,7 +326,7 @@ int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, c * \param a BIGNUM for parameter a of the equation * \param b BIGNUM for parameter b of the equation * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); #endif @@ -425,12 +427,14 @@ void EC_POINT_free(EC_POINT *point); /** Clears and frees a EC_POINT object * \param point EC_POINT object to be cleared and freed */ +#ifndef LIBRESSL_INTERNAL void EC_POINT_clear_free(EC_POINT *point); +#endif /** Copies EC_POINT object * \param dst destination EC_POINT object * \param src source EC_POINT object - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); @@ -451,7 +455,7 @@ const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); /** Sets a point to infinity (neutral element) * \param group underlying EC_GROUP object * \param point EC_POINT to set to infinity - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); @@ -478,7 +482,7 @@ int EC_POINT_get_Jprojective_coordinates(const EC_GROUP *group, * \param y BIGNUM with the y-coordinate * \param z BIGNUM with the z-coordinate * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, const BIGNUM *y, const BIGNUM *z, BN_CTX *ctx); @@ -490,7 +494,7 @@ int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, * \param y BIGNUM for the y-coordinate * \param z BIGNUM for the z-coordinate * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); @@ -501,7 +505,7 @@ int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, * \param x BIGNUM with the x-coordinate * \param y BIGNUM with the y-coordinate * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); @@ -512,7 +516,7 @@ int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, * \param x BIGNUM for the x-coordinate * \param y BIGNUM for the y-coordinate * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); @@ -523,7 +527,7 @@ int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, * \param x BIGNUM with x-coordinate * \param y_bit integer with the y-Bit (either 0 or 1) * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, int y_bit, BN_CTX *ctx); @@ -535,7 +539,7 @@ int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, * \param x BIGNUM with the x-coordinate * \param y BIGNUM with the y-coordinate * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx); @@ -546,7 +550,7 @@ int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, * \param x BIGNUM for the x-coordinate * \param y BIGNUM for the y-coordinate * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx); @@ -557,7 +561,7 @@ int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, * \param x BIGNUM with x-coordinate * \param y_bit integer with the y-Bit (either 0 or 1) * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, const BIGNUM *x, int y_bit, BN_CTX *ctx); @@ -584,7 +588,7 @@ size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, * \param buf memory buffer with the encoded ec point * \param len length of the encoded ec point * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, const unsigned char *buf, size_t len, BN_CTX *ctx); @@ -610,7 +614,7 @@ EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, * \param a EC_POINT object with the first summand * \param b EC_POINT object with the second summand * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx); @@ -619,7 +623,7 @@ int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC * \param r EC_POINT object for the result (r = 2 * a) * \param a EC_POINT object * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx); @@ -627,7 +631,7 @@ int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX * * \param group underlying EC_GROUP object * \param a EC_POINT object to be inverted (it's used for the result as well) * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); @@ -662,11 +666,11 @@ int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], * \param group underlying EC_GROUP object * \param r EC_POINT object for the result * \param n BIGNUM with the multiplier for the group generator (optional) - * \param num number futher summands + * \param num number further summands * \param p array of size num of EC_POINT objects * \param m array of size num of BIGNUM objects * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t num, const EC_POINT *p[], const BIGNUM *m[], BN_CTX *ctx); @@ -677,14 +681,14 @@ int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, size_t nu * \param q EC_POINT object with the first factor of the second summand * \param m BIGNUM with the second factor of the second summand * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); /** Stores multiples of generator for faster point multiplication * \param group EC_GROUP object * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occured + * \return 1 on success and 0 if an error occurred */ int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); @@ -869,8 +873,8 @@ int EC_KEY_generate_key(EC_KEY *key); */ int EC_KEY_check_key(const EC_KEY *key); -/** Sets a public key from affine coordindates performing - * neccessary NIST PKV tests. +/** Sets a public key from affine coordinates performing + * necessary NIST PKV tests. * \param key the EC_KEY object * \param x public key x coordinate * \param y public key y coordinate @@ -914,7 +918,7 @@ int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out); EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); /** Encodes ec parameter and stores the result in a buffer. - * \param key the EC_KEY object with ec paramters to encode + * \param key the EC_KEY object with ec parameters to encode * \param out the buffer for the result (if NULL the function returns number * of bytes needed). * \return 1 on success and 0 if an error occurred. @@ -1289,6 +1293,8 @@ void ERR_load_EC_strings(void); #define EC_R_INVALID_FIELD 103 #define EC_R_INVALID_FORM 104 #define EC_R_INVALID_GROUP_ORDER 122 +#define EC_R_INVALID_KEY 165 +#define EC_R_INVALID_PEER_KEY 152 #define EC_R_INVALID_PENTANOMIAL_BASIS 132 #define EC_R_INVALID_PRIVATE_KEY 123 #define EC_R_INVALID_TRINOMIAL_BASIS 137 diff --git a/include/openssl/ecdsa.h b/include/openssl/ecdsa.h index 29ee8729..3f0eb3b6 100644 --- a/include/openssl/ecdsa.h +++ b/include/openssl/ecdsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ecdsa.h,v 1.12 2022/07/12 14:42:49 kn Exp $ */ +/* $OpenBSD: ecdsa.h,v 1.13 2022/12/26 07:18:51 jmc Exp $ */ /** * \file crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions * \author Written by Nils Larsch for the OpenSSL project @@ -156,7 +156,7 @@ ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len, * \param dgst pointer to the hash value to sign * \param dgstlen length of the hash value * \param kinv BIGNUM with a pre-computed inverse k (optional) - * \param rp BIGNUM with a pre-computed rp value (optioanl), + * \param rp BIGNUM with a pre-computed rp value (optional), * see ECDSA_sign_setup * \param eckey EC_KEY object containing a private EC key * \return pointer to a ECDSA_SIG structure or NULL if an error occurred @@ -233,7 +233,7 @@ int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, * \param sig buffer to hold the DER encoded signature * \param siglen pointer to the length of the returned signature * \param kinv BIGNUM with a pre-computed inverse k (optional) - * \param rp BIGNUM with a pre-computed rp value (optioanl), + * \param rp BIGNUM with a pre-computed rp value (optional), * see ECDSA_sign_setup * \param eckey EC_KEY object containing a private EC key * \return 1 on success and 0 otherwise diff --git a/include/openssl/engine.h b/include/openssl/engine.h index 5c21647f..41f05d48 100644 --- a/include/openssl/engine.h +++ b/include/openssl/engine.h @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.h,v 1.34 2022/07/12 14:42:49 kn Exp $ */ +/* $OpenBSD: engine.h,v 1.35 2022/12/26 07:18:52 jmc Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -631,7 +631,7 @@ typedef struct st_dynamic_MEM_fns { dyn_MEM_free_cb free_cb; } dynamic_MEM_fns; /* FIXME: Perhaps the memory and locking code (crypto.h) should declare and use - * these types so we (and any other dependant code) can simplify a bit?? */ + * these types so we (and any other dependent code) can simplify a bit?? */ typedef void (*dyn_lock_locking_cb)(int, int, const char *, int); typedef int (*dyn_lock_add_lock_cb)(int*, int, int, const char *, int); typedef struct CRYPTO_dynlock_value *(*dyn_dynlock_create_cb)( diff --git a/include/openssl/evp.h b/include/openssl/evp.h index d2bb376c..035b4ad2 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: evp.h,v 1.107 2022/09/11 17:29:24 tb Exp $ */ +/* $OpenBSD: evp.h,v 1.114 2023/03/10 16:41:07 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -97,24 +97,26 @@ #define EVP_PKS_EC 0x0400 #define EVP_PKT_EXP 0x1000 /* <= 512 bit key */ -#define EVP_PKEY_NONE NID_undef -#define EVP_PKEY_RSA NID_rsaEncryption -#define EVP_PKEY_RSA_PSS NID_rsassaPss -#define EVP_PKEY_RSA2 NID_rsa -#define EVP_PKEY_DSA NID_dsa -#define EVP_PKEY_DSA1 NID_dsa_2 -#define EVP_PKEY_DSA2 NID_dsaWithSHA -#define EVP_PKEY_DSA3 NID_dsaWithSHA1 -#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 -#define EVP_PKEY_DH NID_dhKeyAgreement -#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey -#define EVP_PKEY_GOSTR01 NID_id_GostR3410_2001 -#define EVP_PKEY_GOSTIMIT NID_id_Gost28147_89_MAC -#define EVP_PKEY_HMAC NID_hmac -#define EVP_PKEY_CMAC NID_cmac -#define EVP_PKEY_HKDF NID_hkdf -#define EVP_PKEY_GOSTR12_256 NID_id_tc26_gost3410_2012_256 -#define EVP_PKEY_GOSTR12_512 NID_id_tc26_gost3410_2012_512 +#define EVP_PKEY_NONE NID_undef +#define EVP_PKEY_RSA NID_rsaEncryption +#define EVP_PKEY_RSA_PSS NID_rsassaPss +#define EVP_PKEY_RSA2 NID_rsa +#define EVP_PKEY_DSA NID_dsa +#define EVP_PKEY_DSA1 NID_dsa_2 +#define EVP_PKEY_DSA2 NID_dsaWithSHA +#define EVP_PKEY_DSA3 NID_dsaWithSHA1 +#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 +#define EVP_PKEY_DH NID_dhKeyAgreement +#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey +#define EVP_PKEY_GOSTR01 NID_id_GostR3410_2001 +#define EVP_PKEY_GOSTIMIT NID_id_Gost28147_89_MAC +#define EVP_PKEY_HMAC NID_hmac +#define EVP_PKEY_CMAC NID_cmac +#define EVP_PKEY_HKDF NID_hkdf +#define EVP_PKEY_GOSTR12_256 NID_id_tc26_gost3410_2012_256 +#define EVP_PKEY_GOSTR12_512 NID_id_tc26_gost3410_2012_512 +#define EVP_PKEY_ED25519 NID_ED25519 +#define EVP_PKEY_X25519 NID_X25519 #ifdef __cplusplus extern "C" { @@ -297,6 +299,12 @@ extern "C" { /* Length of tag for TLS */ #define EVP_CHACHAPOLY_TLS_TAG_LEN 16 +/* XXX - do we want to expose these? */ +#if defined(LIBRESSL_INTERNAL) +#define ED25519_KEYLEN 32 +#define X25519_KEYLEN 32 +#endif + typedef struct evp_cipher_info_st { const EVP_CIPHER *cipher; unsigned char iv[EVP_MAX_IV_LENGTH]; @@ -399,6 +407,37 @@ unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx); unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx); #define EVP_CIPHER_CTX_mode(e) (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE) +EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len); +EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher); +void EVP_CIPHER_meth_free(EVP_CIPHER *cipher); + +int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len); +int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags); +int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size); +int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher, + int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, + const unsigned char *iv, int enc)); +int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher, + int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, size_t inl)); +int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher, + int (*cleanup)(EVP_CIPHER_CTX *)); +int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher, + int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)); +int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher, + int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)); +int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher, + int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr)); + +EVP_PKEY *EVP_PKEY_new_raw_private_key(int type, ENGINE *engine, + const unsigned char *private_key, size_t len); +EVP_PKEY *EVP_PKEY_new_raw_public_key(int type, ENGINE *engine, + const unsigned char *public_key, size_t len); +int EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, + unsigned char *out_private_key, size_t *out_len); +int EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, + unsigned char *out_public_key, size_t *out_len); + #define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) #define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) @@ -1414,6 +1453,7 @@ void ERR_load_EVP_strings(void); #define EVP_R_EXPECTING_A_ECDSA_KEY 141 #define EVP_R_EXPECTING_A_EC_KEY 142 #define EVP_R_FIPS_MODE_NOT_SUPPORTED 167 +#define EVP_R_GET_RAW_KEY_FAILED 182 #define EVP_R_INITIALIZATION_ERROR 134 #define EVP_R_INPUT_NOT_INITIALIZED 111 #define EVP_R_INVALID_DIGEST 152 @@ -1435,6 +1475,7 @@ void ERR_load_EVP_strings(void); #define EVP_R_NO_OPERATION_SET 149 #define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 #define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 +#define EVP_R_ONLY_ONESHOT_SUPPORTED 177 #define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 150 #define EVP_R_OPERATON_NOT_INITIALIZED 151 #define EVP_R_OUTPUT_ALIASES_INPUT 172 diff --git a/include/openssl/objects.h b/include/openssl/objects.h index fe3d7774..7fc11fa5 100644 --- a/include/openssl/objects.h +++ b/include/openssl/objects.h @@ -1,4 +1,4 @@ -/* $OpenBSD: objects.h,v 1.18 2022/07/12 14:42:49 kn Exp $ */ +/* $OpenBSD: objects.h,v 1.21 2022/11/13 14:03:13 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -59,902 +59,11 @@ #ifndef HEADER_OBJECTS_H #define HEADER_OBJECTS_H -#define USE_OBJ_MAC - -#ifdef USE_OBJ_MAC #include -#else -#define SN_undef "UNDEF" -#define LN_undef "undefined" -#define NID_undef 0 -#define OBJ_undef 0L - -#define SN_Algorithm "Algorithm" -#define LN_algorithm "algorithm" -#define NID_algorithm 38 -#define OBJ_algorithm 1L,3L,14L,3L,2L - -#define LN_rsadsi "rsadsi" -#define NID_rsadsi 1 -#define OBJ_rsadsi 1L,2L,840L,113549L - -#define LN_pkcs "pkcs" -#define NID_pkcs 2 -#define OBJ_pkcs OBJ_rsadsi,1L - -#define SN_md2 "MD2" -#define LN_md2 "md2" -#define NID_md2 3 -#define OBJ_md2 OBJ_rsadsi,2L,2L - -#define SN_md5 "MD5" -#define LN_md5 "md5" -#define NID_md5 4 -#define OBJ_md5 OBJ_rsadsi,2L,5L - -#define SN_rc4 "RC4" -#define LN_rc4 "rc4" -#define NID_rc4 5 -#define OBJ_rc4 OBJ_rsadsi,3L,4L - -#define LN_rsaEncryption "rsaEncryption" -#define NID_rsaEncryption 6 -#define OBJ_rsaEncryption OBJ_pkcs,1L,1L - -#define SN_md2WithRSAEncryption "RSA-MD2" -#define LN_md2WithRSAEncryption "md2WithRSAEncryption" -#define NID_md2WithRSAEncryption 7 -#define OBJ_md2WithRSAEncryption OBJ_pkcs,1L,2L - -#define SN_md5WithRSAEncryption "RSA-MD5" -#define LN_md5WithRSAEncryption "md5WithRSAEncryption" -#define NID_md5WithRSAEncryption 8 -#define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L - -#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" -#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" -#define NID_pbeWithMD2AndDES_CBC 9 -#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L - -#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" -#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" -#define NID_pbeWithMD5AndDES_CBC 10 -#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L - -#define LN_X500 "X500" -#define NID_X500 11 -#define OBJ_X500 2L,5L - -#define LN_X509 "X509" -#define NID_X509 12 -#define OBJ_X509 OBJ_X500,4L - -#define SN_commonName "CN" -#define LN_commonName "commonName" -#define NID_commonName 13 -#define OBJ_commonName OBJ_X509,3L - -#define SN_countryName "C" -#define LN_countryName "countryName" -#define NID_countryName 14 -#define OBJ_countryName OBJ_X509,6L - -#define SN_localityName "L" -#define LN_localityName "localityName" -#define NID_localityName 15 -#define OBJ_localityName OBJ_X509,7L - -/* Postal Address? PA */ - -/* should be "ST" (rfc1327) but MS uses 'S' */ -#define SN_stateOrProvinceName "ST" -#define LN_stateOrProvinceName "stateOrProvinceName" -#define NID_stateOrProvinceName 16 -#define OBJ_stateOrProvinceName OBJ_X509,8L - -#define SN_organizationName "O" -#define LN_organizationName "organizationName" -#define NID_organizationName 17 -#define OBJ_organizationName OBJ_X509,10L - -#define SN_organizationalUnitName "OU" -#define LN_organizationalUnitName "organizationalUnitName" -#define NID_organizationalUnitName 18 -#define OBJ_organizationalUnitName OBJ_X509,11L - -#define SN_rsa "RSA" -#define LN_rsa "rsa" -#define NID_rsa 19 -#define OBJ_rsa OBJ_X500,8L,1L,1L - -#define LN_pkcs7 "pkcs7" -#define NID_pkcs7 20 -#define OBJ_pkcs7 OBJ_pkcs,7L - -#define LN_pkcs7_data "pkcs7-data" -#define NID_pkcs7_data 21 -#define OBJ_pkcs7_data OBJ_pkcs7,1L - -#define LN_pkcs7_signed "pkcs7-signedData" -#define NID_pkcs7_signed 22 -#define OBJ_pkcs7_signed OBJ_pkcs7,2L - -#define LN_pkcs7_enveloped "pkcs7-envelopedData" -#define NID_pkcs7_enveloped 23 -#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L - -#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" -#define NID_pkcs7_signedAndEnveloped 24 -#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L - -#define LN_pkcs7_digest "pkcs7-digestData" -#define NID_pkcs7_digest 25 -#define OBJ_pkcs7_digest OBJ_pkcs7,5L - -#define LN_pkcs7_encrypted "pkcs7-encryptedData" -#define NID_pkcs7_encrypted 26 -#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L - -#define LN_pkcs3 "pkcs3" -#define NID_pkcs3 27 -#define OBJ_pkcs3 OBJ_pkcs,3L - -#define LN_dhKeyAgreement "dhKeyAgreement" -#define NID_dhKeyAgreement 28 -#define OBJ_dhKeyAgreement OBJ_pkcs3,1L - -#define SN_des_ecb "DES-ECB" -#define LN_des_ecb "des-ecb" -#define NID_des_ecb 29 -#define OBJ_des_ecb OBJ_algorithm,6L - -#define SN_des_cfb64 "DES-CFB" -#define LN_des_cfb64 "des-cfb" -#define NID_des_cfb64 30 -/* IV + num */ -#define OBJ_des_cfb64 OBJ_algorithm,9L - -#define SN_des_cbc "DES-CBC" -#define LN_des_cbc "des-cbc" -#define NID_des_cbc 31 -/* IV */ -#define OBJ_des_cbc OBJ_algorithm,7L - -#define SN_des_ede "DES-EDE" -#define LN_des_ede "des-ede" -#define NID_des_ede 32 -/* ?? */ -#define OBJ_des_ede OBJ_algorithm,17L - -#define SN_des_ede3 "DES-EDE3" -#define LN_des_ede3 "des-ede3" -#define NID_des_ede3 33 - -#define SN_idea_cbc "IDEA-CBC" -#define LN_idea_cbc "idea-cbc" -#define NID_idea_cbc 34 -#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L - -#define SN_idea_cfb64 "IDEA-CFB" -#define LN_idea_cfb64 "idea-cfb" -#define NID_idea_cfb64 35 - -#define SN_idea_ecb "IDEA-ECB" -#define LN_idea_ecb "idea-ecb" -#define NID_idea_ecb 36 - -#define SN_rc2_cbc "RC2-CBC" -#define LN_rc2_cbc "rc2-cbc" -#define NID_rc2_cbc 37 -#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L - -#define SN_rc2_ecb "RC2-ECB" -#define LN_rc2_ecb "rc2-ecb" -#define NID_rc2_ecb 38 - -#define SN_rc2_cfb64 "RC2-CFB" -#define LN_rc2_cfb64 "rc2-cfb" -#define NID_rc2_cfb64 39 - -#define SN_rc2_ofb64 "RC2-OFB" -#define LN_rc2_ofb64 "rc2-ofb" -#define NID_rc2_ofb64 40 - -#define SN_sha "SHA" -#define LN_sha "sha" -#define NID_sha 41 -#define OBJ_sha OBJ_algorithm,18L - -#define SN_shaWithRSAEncryption "RSA-SHA" -#define LN_shaWithRSAEncryption "shaWithRSAEncryption" -#define NID_shaWithRSAEncryption 42 -#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L - -#define SN_des_ede_cbc "DES-EDE-CBC" -#define LN_des_ede_cbc "des-ede-cbc" -#define NID_des_ede_cbc 43 - -#define SN_des_ede3_cbc "DES-EDE3-CBC" -#define LN_des_ede3_cbc "des-ede3-cbc" -#define NID_des_ede3_cbc 44 -#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L - -#define SN_des_ofb64 "DES-OFB" -#define LN_des_ofb64 "des-ofb" -#define NID_des_ofb64 45 -#define OBJ_des_ofb64 OBJ_algorithm,8L - -#define SN_idea_ofb64 "IDEA-OFB" -#define LN_idea_ofb64 "idea-ofb" -#define NID_idea_ofb64 46 - -#define LN_pkcs9 "pkcs9" -#define NID_pkcs9 47 -#define OBJ_pkcs9 OBJ_pkcs,9L - -#define SN_pkcs9_emailAddress "Email" -#define LN_pkcs9_emailAddress "emailAddress" -#define NID_pkcs9_emailAddress 48 -#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L - -#define LN_pkcs9_unstructuredName "unstructuredName" -#define NID_pkcs9_unstructuredName 49 -#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L - -#define LN_pkcs9_contentType "contentType" -#define NID_pkcs9_contentType 50 -#define OBJ_pkcs9_contentType OBJ_pkcs9,3L - -#define LN_pkcs9_messageDigest "messageDigest" -#define NID_pkcs9_messageDigest 51 -#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L - -#define LN_pkcs9_signingTime "signingTime" -#define NID_pkcs9_signingTime 52 -#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L - -#define LN_pkcs9_countersignature "countersignature" -#define NID_pkcs9_countersignature 53 -#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L - -#define LN_pkcs9_challengePassword "challengePassword" -#define NID_pkcs9_challengePassword 54 -#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L - -#define LN_pkcs9_unstructuredAddress "unstructuredAddress" -#define NID_pkcs9_unstructuredAddress 55 -#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L - -#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" -#define NID_pkcs9_extCertAttributes 56 -#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L - -#define SN_netscape "Netscape" -#define LN_netscape "Netscape Communications Corp." -#define NID_netscape 57 -#define OBJ_netscape 2L,16L,840L,1L,113730L - -#define SN_netscape_cert_extension "nsCertExt" -#define LN_netscape_cert_extension "Netscape Certificate Extension" -#define NID_netscape_cert_extension 58 -#define OBJ_netscape_cert_extension OBJ_netscape,1L - -#define SN_netscape_data_type "nsDataType" -#define LN_netscape_data_type "Netscape Data Type" -#define NID_netscape_data_type 59 -#define OBJ_netscape_data_type OBJ_netscape,2L - -#define SN_des_ede_cfb64 "DES-EDE-CFB" -#define LN_des_ede_cfb64 "des-ede-cfb" -#define NID_des_ede_cfb64 60 - -#define SN_des_ede3_cfb64 "DES-EDE3-CFB" -#define LN_des_ede3_cfb64 "des-ede3-cfb" -#define NID_des_ede3_cfb64 61 - -#define SN_des_ede_ofb64 "DES-EDE-OFB" -#define LN_des_ede_ofb64 "des-ede-ofb" -#define NID_des_ede_ofb64 62 - -#define SN_des_ede3_ofb64 "DES-EDE3-OFB" -#define LN_des_ede3_ofb64 "des-ede3-ofb" -#define NID_des_ede3_ofb64 63 - -/* I'm not sure about the object ID */ -#define SN_sha1 "SHA1" -#define LN_sha1 "sha1" -#define NID_sha1 64 -#define OBJ_sha1 OBJ_algorithm,26L -/* 28 Jun 1996 - eay */ -/* #define OBJ_sha1 1L,3L,14L,2L,26L,05L <- wrong */ - -#define SN_sha1WithRSAEncryption "RSA-SHA1" -#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" -#define NID_sha1WithRSAEncryption 65 -#define OBJ_sha1WithRSAEncryption OBJ_pkcs,1L,5L - -#define SN_dsaWithSHA "DSA-SHA" -#define LN_dsaWithSHA "dsaWithSHA" -#define NID_dsaWithSHA 66 -#define OBJ_dsaWithSHA OBJ_algorithm,13L - -#define SN_dsa_2 "DSA-old" -#define LN_dsa_2 "dsaEncryption-old" -#define NID_dsa_2 67 -#define OBJ_dsa_2 OBJ_algorithm,12L - -/* proposed by microsoft to RSA */ -#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" -#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" -#define NID_pbeWithSHA1AndRC2_CBC 68 -#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L - -/* proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now - * defined explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something - * completely different. - */ -#define LN_id_pbkdf2 "PBKDF2" -#define NID_id_pbkdf2 69 -#define OBJ_id_pbkdf2 OBJ_pkcs,5L,12L - -#define SN_dsaWithSHA1_2 "DSA-SHA1-old" -#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" -#define NID_dsaWithSHA1_2 70 -/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */ -#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L - -#define SN_netscape_cert_type "nsCertType" -#define LN_netscape_cert_type "Netscape Cert Type" -#define NID_netscape_cert_type 71 -#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L - -#define SN_netscape_base_url "nsBaseUrl" -#define LN_netscape_base_url "Netscape Base Url" -#define NID_netscape_base_url 72 -#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L - -#define SN_netscape_revocation_url "nsRevocationUrl" -#define LN_netscape_revocation_url "Netscape Revocation Url" -#define NID_netscape_revocation_url 73 -#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L - -#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" -#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" -#define NID_netscape_ca_revocation_url 74 -#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L - -#define SN_netscape_renewal_url "nsRenewalUrl" -#define LN_netscape_renewal_url "Netscape Renewal Url" -#define NID_netscape_renewal_url 75 -#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L - -#define SN_netscape_ca_policy_url "nsCaPolicyUrl" -#define LN_netscape_ca_policy_url "Netscape CA Policy Url" -#define NID_netscape_ca_policy_url 76 -#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L - -#define SN_netscape_ssl_server_name "nsSslServerName" -#define LN_netscape_ssl_server_name "Netscape SSL Server Name" -#define NID_netscape_ssl_server_name 77 -#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L - -#define SN_netscape_comment "nsComment" -#define LN_netscape_comment "Netscape Comment" -#define NID_netscape_comment 78 -#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L - -#define SN_netscape_cert_sequence "nsCertSequence" -#define LN_netscape_cert_sequence "Netscape Certificate Sequence" -#define NID_netscape_cert_sequence 79 -#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L - -#define SN_desx_cbc "DESX-CBC" -#define LN_desx_cbc "desx-cbc" -#define NID_desx_cbc 80 - -#define SN_id_ce "id-ce" -#define NID_id_ce 81 -#define OBJ_id_ce 2L,5L,29L - -#define SN_subject_key_identifier "subjectKeyIdentifier" -#define LN_subject_key_identifier "X509v3 Subject Key Identifier" -#define NID_subject_key_identifier 82 -#define OBJ_subject_key_identifier OBJ_id_ce,14L - -#define SN_key_usage "keyUsage" -#define LN_key_usage "X509v3 Key Usage" -#define NID_key_usage 83 -#define OBJ_key_usage OBJ_id_ce,15L - -#define SN_private_key_usage_period "privateKeyUsagePeriod" -#define LN_private_key_usage_period "X509v3 Private Key Usage Period" -#define NID_private_key_usage_period 84 -#define OBJ_private_key_usage_period OBJ_id_ce,16L - -#define SN_subject_alt_name "subjectAltName" -#define LN_subject_alt_name "X509v3 Subject Alternative Name" -#define NID_subject_alt_name 85 -#define OBJ_subject_alt_name OBJ_id_ce,17L - -#define SN_issuer_alt_name "issuerAltName" -#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" -#define NID_issuer_alt_name 86 -#define OBJ_issuer_alt_name OBJ_id_ce,18L - -#define SN_basic_constraints "basicConstraints" -#define LN_basic_constraints "X509v3 Basic Constraints" -#define NID_basic_constraints 87 -#define OBJ_basic_constraints OBJ_id_ce,19L - -#define SN_crl_number "crlNumber" -#define LN_crl_number "X509v3 CRL Number" -#define NID_crl_number 88 -#define OBJ_crl_number OBJ_id_ce,20L - -#define SN_certificate_policies "certificatePolicies" -#define LN_certificate_policies "X509v3 Certificate Policies" -#define NID_certificate_policies 89 -#define OBJ_certificate_policies OBJ_id_ce,32L - -#define SN_authority_key_identifier "authorityKeyIdentifier" -#define LN_authority_key_identifier "X509v3 Authority Key Identifier" -#define NID_authority_key_identifier 90 -#define OBJ_authority_key_identifier OBJ_id_ce,35L - -#define SN_bf_cbc "BF-CBC" -#define LN_bf_cbc "bf-cbc" -#define NID_bf_cbc 91 -#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L - -#define SN_bf_ecb "BF-ECB" -#define LN_bf_ecb "bf-ecb" -#define NID_bf_ecb 92 - -#define SN_bf_cfb64 "BF-CFB" -#define LN_bf_cfb64 "bf-cfb" -#define NID_bf_cfb64 93 - -#define SN_bf_ofb64 "BF-OFB" -#define LN_bf_ofb64 "bf-ofb" -#define NID_bf_ofb64 94 - -#define SN_mdc2 "MDC2" -#define LN_mdc2 "mdc2" -#define NID_mdc2 95 -#define OBJ_mdc2 2L,5L,8L,3L,101L -/* An alternative? 1L,3L,14L,3L,2L,19L */ - -#define SN_mdc2WithRSA "RSA-MDC2" -#define LN_mdc2WithRSA "mdc2withRSA" -#define NID_mdc2WithRSA 96 -#define OBJ_mdc2WithRSA 2L,5L,8L,3L,100L - -#define SN_rc4_40 "RC4-40" -#define LN_rc4_40 "rc4-40" -#define NID_rc4_40 97 - -#define SN_rc2_40_cbc "RC2-40-CBC" -#define LN_rc2_40_cbc "rc2-40-cbc" -#define NID_rc2_40_cbc 98 - -#define SN_givenName "G" -#define LN_givenName "givenName" -#define NID_givenName 99 -#define OBJ_givenName OBJ_X509,42L - -#define SN_surname "S" -#define LN_surname "surname" -#define NID_surname 100 -#define OBJ_surname OBJ_X509,4L - -#define SN_initials "I" -#define LN_initials "initials" -#define NID_initials 101 -#define OBJ_initials OBJ_X509,43L - -#define SN_uniqueIdentifier "UID" -#define LN_uniqueIdentifier "uniqueIdentifier" -#define NID_uniqueIdentifier 102 -#define OBJ_uniqueIdentifier OBJ_X509,45L - -#define SN_crl_distribution_points "crlDistributionPoints" -#define LN_crl_distribution_points "X509v3 CRL Distribution Points" -#define NID_crl_distribution_points 103 -#define OBJ_crl_distribution_points OBJ_id_ce,31L - -#define SN_md5WithRSA "RSA-NP-MD5" -#define LN_md5WithRSA "md5WithRSA" -#define NID_md5WithRSA 104 -#define OBJ_md5WithRSA OBJ_algorithm,3L - -#define SN_serialNumber "SN" -#define LN_serialNumber "serialNumber" -#define NID_serialNumber 105 -#define OBJ_serialNumber OBJ_X509,5L - -#define SN_title "T" -#define LN_title "title" -#define NID_title 106 -#define OBJ_title OBJ_X509,12L - -#define SN_description "D" -#define LN_description "description" -#define NID_description 107 -#define OBJ_description OBJ_X509,13L - -/* CAST5 is CAST-128, I'm just sticking with the documentation */ -#define SN_cast5_cbc "CAST5-CBC" -#define LN_cast5_cbc "cast5-cbc" -#define NID_cast5_cbc 108 -#define OBJ_cast5_cbc 1L,2L,840L,113533L,7L,66L,10L - -#define SN_cast5_ecb "CAST5-ECB" -#define LN_cast5_ecb "cast5-ecb" -#define NID_cast5_ecb 109 - -#define SN_cast5_cfb64 "CAST5-CFB" -#define LN_cast5_cfb64 "cast5-cfb" -#define NID_cast5_cfb64 110 - -#define SN_cast5_ofb64 "CAST5-OFB" -#define LN_cast5_ofb64 "cast5-ofb" -#define NID_cast5_ofb64 111 - -#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" -#define NID_pbeWithMD5AndCast5_CBC 112 -#define OBJ_pbeWithMD5AndCast5_CBC 1L,2L,840L,113533L,7L,66L,12L - -/* This is one sun will soon be using :-( - * id-dsa-with-sha1 ID ::= { - * iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 } - */ -#define SN_dsaWithSHA1 "DSA-SHA1" -#define LN_dsaWithSHA1 "dsaWithSHA1" -#define NID_dsaWithSHA1 113 -#define OBJ_dsaWithSHA1 1L,2L,840L,10040L,4L,3L - -#define NID_md5_sha1 114 -#define SN_md5_sha1 "MD5-SHA1" -#define LN_md5_sha1 "md5-sha1" - -#define SN_sha1WithRSA "RSA-SHA1-2" -#define LN_sha1WithRSA "sha1WithRSA" -#define NID_sha1WithRSA 115 -#define OBJ_sha1WithRSA OBJ_algorithm,29L - -#define SN_dsa "DSA" -#define LN_dsa "dsaEncryption" -#define NID_dsa 116 -#define OBJ_dsa 1L,2L,840L,10040L,4L,1L - -#define SN_ripemd160 "RIPEMD160" -#define LN_ripemd160 "ripemd160" -#define NID_ripemd160 117 -#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L - -/* The name should actually be rsaSignatureWithripemd160, but I'm going - * to continue using the convention I'm using with the other ciphers */ -#define SN_ripemd160WithRSA "RSA-RIPEMD160" -#define LN_ripemd160WithRSA "ripemd160WithRSA" -#define NID_ripemd160WithRSA 119 -#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L - -/* Taken from rfc2040 - * RC5_CBC_Parameters ::= SEQUENCE { - * version INTEGER (v1_0(16)), - * rounds INTEGER (8..127), - * blockSizeInBits INTEGER (64, 128), - * iv OCTET STRING OPTIONAL - * } - */ -#define SN_rc5_cbc "RC5-CBC" -#define LN_rc5_cbc "rc5-cbc" -#define NID_rc5_cbc 120 -#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L - -#define SN_rc5_ecb "RC5-ECB" -#define LN_rc5_ecb "rc5-ecb" -#define NID_rc5_ecb 121 - -#define SN_rc5_cfb64 "RC5-CFB" -#define LN_rc5_cfb64 "rc5-cfb" -#define NID_rc5_cfb64 122 - -#define SN_rc5_ofb64 "RC5-OFB" -#define LN_rc5_ofb64 "rc5-ofb" -#define NID_rc5_ofb64 123 - -#define SN_rle_compression "RLE" -#define LN_rle_compression "run length compression" -#define NID_rle_compression 124 -#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L - -#define SN_zlib_compression "ZLIB" -#define LN_zlib_compression "zlib compression" -#define NID_zlib_compression 125 -#define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L - -#define SN_ext_key_usage "extendedKeyUsage" -#define LN_ext_key_usage "X509v3 Extended Key Usage" -#define NID_ext_key_usage 126 -#define OBJ_ext_key_usage OBJ_id_ce,37 - -#define SN_id_pkix "PKIX" -#define NID_id_pkix 127 -#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L - -#define SN_id_kp "id-kp" -#define NID_id_kp 128 -#define OBJ_id_kp OBJ_id_pkix,3L - -/* PKIX extended key usage OIDs */ - -#define SN_server_auth "serverAuth" -#define LN_server_auth "TLS Web Server Authentication" -#define NID_server_auth 129 -#define OBJ_server_auth OBJ_id_kp,1L - -#define SN_client_auth "clientAuth" -#define LN_client_auth "TLS Web Client Authentication" -#define NID_client_auth 130 -#define OBJ_client_auth OBJ_id_kp,2L - -#define SN_code_sign "codeSigning" -#define LN_code_sign "Code Signing" -#define NID_code_sign 131 -#define OBJ_code_sign OBJ_id_kp,3L - -#define SN_email_protect "emailProtection" -#define LN_email_protect "E-mail Protection" -#define NID_email_protect 132 -#define OBJ_email_protect OBJ_id_kp,4L - -#define SN_time_stamp "timeStamping" -#define LN_time_stamp "Time Stamping" -#define NID_time_stamp 133 -#define OBJ_time_stamp OBJ_id_kp,8L - -/* Additional extended key usage OIDs: Microsoft */ - -#define SN_ms_code_ind "msCodeInd" -#define LN_ms_code_ind "Microsoft Individual Code Signing" -#define NID_ms_code_ind 134 -#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L - -#define SN_ms_code_com "msCodeCom" -#define LN_ms_code_com "Microsoft Commercial Code Signing" -#define NID_ms_code_com 135 -#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L - -#define SN_ms_ctl_sign "msCTLSign" -#define LN_ms_ctl_sign "Microsoft Trust List Signing" -#define NID_ms_ctl_sign 136 -#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L - -#define SN_ms_sgc "msSGC" -#define LN_ms_sgc "Microsoft Server Gated Crypto" -#define NID_ms_sgc 137 -#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L - -#define SN_ms_efs "msEFS" -#define LN_ms_efs "Microsoft Encrypted File System" -#define NID_ms_efs 138 -#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L - -/* Additional usage: Netscape */ - -#define SN_ns_sgc "nsSGC" -#define LN_ns_sgc "Netscape Server Gated Crypto" -#define NID_ns_sgc 139 -#define OBJ_ns_sgc OBJ_netscape,4L,1L - -#define SN_delta_crl "deltaCRL" -#define LN_delta_crl "X509v3 Delta CRL Indicator" -#define NID_delta_crl 140 -#define OBJ_delta_crl OBJ_id_ce,27L - -#define SN_crl_reason "CRLReason" -#define LN_crl_reason "CRL Reason Code" -#define NID_crl_reason 141 -#define OBJ_crl_reason OBJ_id_ce,21L - -#define SN_invalidity_date "invalidityDate" -#define LN_invalidity_date "Invalidity Date" -#define NID_invalidity_date 142 -#define OBJ_invalidity_date OBJ_id_ce,24L - -#define SN_sxnet "SXNetID" -#define LN_sxnet "Strong Extranet ID" -#define NID_sxnet 143 -#define OBJ_sxnet 1L,3L,101L,1L,4L,1L - -/* PKCS12 and related OBJECT IDENTIFIERS */ - -#define OBJ_pkcs12 OBJ_pkcs,12L -#define OBJ_pkcs12_pbeids OBJ_pkcs12, 1 - -#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" -#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" -#define NID_pbe_WithSHA1And128BitRC4 144 -#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L - -#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" -#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" -#define NID_pbe_WithSHA1And40BitRC4 145 -#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L - -#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" -#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 -#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L - -#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" -#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 -#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L - -#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" -#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" -#define NID_pbe_WithSHA1And128BitRC2_CBC 148 -#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L - -#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" -#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" -#define NID_pbe_WithSHA1And40BitRC2_CBC 149 -#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L - -#define OBJ_pkcs12_Version1 OBJ_pkcs12, 10L - -#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1, 1L - -#define LN_keyBag "keyBag" -#define NID_keyBag 150 -#define OBJ_keyBag OBJ_pkcs12_BagIds, 1L - -#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" -#define NID_pkcs8ShroudedKeyBag 151 -#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L - -#define LN_certBag "certBag" -#define NID_certBag 152 -#define OBJ_certBag OBJ_pkcs12_BagIds, 3L - -#define LN_crlBag "crlBag" -#define NID_crlBag 153 -#define OBJ_crlBag OBJ_pkcs12_BagIds, 4L - -#define LN_secretBag "secretBag" -#define NID_secretBag 154 -#define OBJ_secretBag OBJ_pkcs12_BagIds, 5L - -#define LN_safeContentsBag "safeContentsBag" -#define NID_safeContentsBag 155 -#define OBJ_safeContentsBag OBJ_pkcs12_BagIds, 6L - -#define LN_friendlyName "friendlyName" -#define NID_friendlyName 156 -#define OBJ_friendlyName OBJ_pkcs9, 20L - -#define LN_localKeyID "localKeyID" -#define NID_localKeyID 157 -#define OBJ_localKeyID OBJ_pkcs9, 21L - -#define OBJ_certTypes OBJ_pkcs9, 22L - -#define LN_x509Certificate "x509Certificate" -#define NID_x509Certificate 158 -#define OBJ_x509Certificate OBJ_certTypes, 1L - -#define LN_sdsiCertificate "sdsiCertificate" -#define NID_sdsiCertificate 159 -#define OBJ_sdsiCertificate OBJ_certTypes, 2L - -#define OBJ_crlTypes OBJ_pkcs9, 23L - -#define LN_x509Crl "x509Crl" -#define NID_x509Crl 160 -#define OBJ_x509Crl OBJ_crlTypes, 1L - -/* PKCS#5 v2 OIDs */ - -#define LN_pbes2 "PBES2" -#define NID_pbes2 161 -#define OBJ_pbes2 OBJ_pkcs,5L,13L - -#define LN_pbmac1 "PBMAC1" -#define NID_pbmac1 162 -#define OBJ_pbmac1 OBJ_pkcs,5L,14L - -#define LN_hmacWithSHA1 "hmacWithSHA1" -#define NID_hmacWithSHA1 163 -#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L - -/* Policy Qualifier Ids */ - -#define LN_id_qt_cps "Policy Qualifier CPS" -#define SN_id_qt_cps "id-qt-cps" -#define NID_id_qt_cps 164 -#define OBJ_id_qt_cps OBJ_id_pkix,2L,1L - -#define LN_id_qt_unotice "Policy Qualifier User Notice" -#define SN_id_qt_unotice "id-qt-unotice" -#define NID_id_qt_unotice 165 -#define OBJ_id_qt_unotice OBJ_id_pkix,2L,2L - -#define SN_rc2_64_cbc "RC2-64-CBC" -#define LN_rc2_64_cbc "rc2-64-cbc" -#define NID_rc2_64_cbc 166 - -#define SN_SMIMECapabilities "SMIME-CAPS" -#define LN_SMIMECapabilities "S/MIME Capabilities" -#define NID_SMIMECapabilities 167 -#define OBJ_SMIMECapabilities OBJ_pkcs9,15L - -#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" -#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" -#define NID_pbeWithMD2AndRC2_CBC 168 -#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L - -#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" -#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" -#define NID_pbeWithMD5AndRC2_CBC 169 -#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L - -#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" -#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" -#define NID_pbeWithSHA1AndDES_CBC 170 -#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L - -/* Extension request OIDs */ - -#define LN_ms_ext_req "Microsoft Extension Request" -#define SN_ms_ext_req "msExtReq" -#define NID_ms_ext_req 171 -#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L - -#define LN_ext_req "Extension Request" -#define SN_ext_req "extReq" -#define NID_ext_req 172 -#define OBJ_ext_req OBJ_pkcs9,14L - -#define SN_name "name" -#define LN_name "name" -#define NID_name 173 -#define OBJ_name OBJ_X509,41L - -#define SN_dnQualifier "dnQualifier" -#define LN_dnQualifier "dnQualifier" -#define NID_dnQualifier 174 -#define OBJ_dnQualifier OBJ_X509,46L - -#define SN_id_pe "id-pe" -#define NID_id_pe 175 -#define OBJ_id_pe OBJ_id_pkix,1L - -#define SN_id_ad "id-ad" -#define NID_id_ad 176 -#define OBJ_id_ad OBJ_id_pkix,48L - -#define SN_info_access "authorityInfoAccess" -#define LN_info_access "Authority Information Access" -#define NID_info_access 177 -#define OBJ_info_access OBJ_id_pe,1L - -#define SN_ad_OCSP "OCSP" -#define LN_ad_OCSP "OCSP" -#define NID_ad_OCSP 178 -#define OBJ_ad_OCSP OBJ_id_ad,1L - -#define SN_ad_ca_issuers "caIssuers" -#define LN_ad_ca_issuers "CA Issuers" -#define NID_ad_ca_issuers 179 -#define OBJ_ad_ca_issuers OBJ_id_ad,2L -#define SN_OCSP_sign "OCSPSigning" -#define LN_OCSP_sign "OCSP Signing" -#define NID_OCSP_sign 180 -#define OBJ_OCSP_sign OBJ_id_kp,9L -#endif /* USE_OBJ_MAC */ +#define SN_ED25519 SN_Ed25519 +#define NID_ED25519 NID_Ed25519 +#define OBJ_ED25519 OBJ_Ed25519 #include #include diff --git a/include/openssl/opensslconf.h b/include/openssl/opensslconf.h index 6e88a6e0..5cad089a 100644 --- a/include/openssl/opensslconf.h +++ b/include/openssl/opensslconf.h @@ -1,10 +1,6 @@ #include /* crypto/opensslconf.h.in */ -#if defined(_MSC_VER) && !defined(__clang__) && !defined(__attribute__) -#define __attribute__(a) -#endif - #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR) #define OPENSSLDIR "/etc/ssl" #endif @@ -89,7 +85,7 @@ #endif /* This helps C compiler generate the correct code for multiple functional - * units. It reduces register dependancies at the expense of 2 more + * units. It reduces register dependencies at the expense of 2 more * registers */ #ifndef DES_RISC1 #undef DES_RISC1 @@ -104,7 +100,7 @@ YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!! #endif /* Unroll the inner loop, this sometimes helps, sometimes hinders. - * Very mucy CPU dependant */ + * Very much CPU dependent */ #ifndef DES_UNROLL #define DES_UNROLL #endif diff --git a/include/openssl/opensslfeatures.h b/include/openssl/opensslfeatures.h index 48fcf40b..ee9d4fb1 100644 --- a/include/openssl/opensslfeatures.h +++ b/include/openssl/opensslfeatures.h @@ -7,6 +7,13 @@ #define LIBRESSL_HAS_TLS1_3 #define LIBRESSL_HAS_DTLS1_2 +/* + * Used for compatibility with compilers lacking __attribute__ + */ +#if defined(_MSC_VER) && !defined(__clang__) && !defined(__attribute__) +#define __attribute__(a) +#endif + #define OPENSSL_THREADS #define OPENSSL_NO_BUF_FREELISTS diff --git a/include/openssl/opensslv.h b/include/openssl/opensslv.h index dc38457b..b0efec80 100644 --- a/include/openssl/opensslv.h +++ b/include/openssl/opensslv.h @@ -1,11 +1,11 @@ -/* $OpenBSD: opensslv.h,v 1.70 2022/07/04 12:31:55 tb Exp $ */ +/* $OpenBSD: opensslv.h,v 1.73 2023/03/16 08:16:21 tb Exp $ */ #ifndef HEADER_OPENSSLV_H #define HEADER_OPENSSLV_H /* These will change with each release of LibreSSL-portable */ -#define LIBRESSL_VERSION_NUMBER 0x3060200fL +#define LIBRESSL_VERSION_NUMBER 0x3070200fL /* ^ Patch starts here */ -#define LIBRESSL_VERSION_TEXT "LibreSSL 3.6.2" +#define LIBRESSL_VERSION_TEXT "LibreSSL 3.7.2" /* These will never change */ #define OPENSSL_VERSION_NUMBER 0x20000000L diff --git a/include/openssl/ossl_typ.h b/include/openssl/ossl_typ.h index f4796ba8..03f024fa 100644 --- a/include/openssl/ossl_typ.h +++ b/include/openssl/ossl_typ.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ossl_typ.h,v 1.21 2022/01/14 08:59:30 tb Exp $ */ +/* $OpenBSD: ossl_typ.h,v 1.22 2022/12/26 07:18:50 jmc Exp $ */ /* ==================================================================== * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. * @@ -186,7 +186,7 @@ typedef struct DIST_POINT_st DIST_POINT; typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT; typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS; -/* If placed in pkcs12.h, we end up with a circular depency with pkcs7.h */ +/* If placed in pkcs12.h, we end up with a circular dependency with pkcs7.h */ #define DECLARE_PKCS12_STACK_OF(type) /* Nothing */ #define IMPLEMENT_PKCS12_STACK_OF(type) /* Nothing */ diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 4a89bfd8..acde94c7 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.h,v 1.229 2022/09/11 17:39:46 tb Exp $ */ +/* $OpenBSD: ssl.h,v 1.230 2022/12/26 07:31:44 jmc Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -2348,7 +2348,7 @@ void ERR_load_SSL_strings(void); */ /* - * These are provided for compatibiliy, but have no effect + * These are provided for compatibility, but have no effect * on how LibreSSL is initialized. */ #define OPENSSL_INIT_LOAD_SSL_STRINGS _OPENSSL_INIT_FLAG_NOOP diff --git a/include/openssl/ui.h b/include/openssl/ui.h index 7755cf4a..79d807f0 100644 --- a/include/openssl/ui.h +++ b/include/openssl/ui.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ui.h,v 1.14 2022/07/12 18:43:56 jsing Exp $ */ +/* $OpenBSD: ui.h,v 1.17 2023/03/10 16:41:32 tb Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ @@ -257,6 +257,7 @@ const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); /* The method with all the built-in thingies */ UI_METHOD *UI_OpenSSL(void); +const UI_METHOD *UI_null(void); /* * ---------- For method writers ---------- @@ -273,7 +274,7 @@ UI_METHOD *UI_OpenSSL(void); * display a dialog box after it has been built. * a reader This function is called to read a given prompt, * maybe from the tty, maybe from a field in a - * window. Note that it's called wth all string + * window. Note that it's called with all string * structures, not only the prompt ones, so it must * check such things itself. * a closer This function closes the session, maybe by closing diff --git a/include/openssl/ui_compat.h b/include/openssl/ui_compat.h index 860e80c8..6484bf6b 100644 --- a/include/openssl/ui_compat.h +++ b/include/openssl/ui_compat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ui_compat.h,v 1.4 2014/06/12 15:49:31 deraadt Exp $ */ +/* $OpenBSD: ui_compat.h,v 1.5 2022/12/23 02:20:28 jsing Exp $ */ /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL * project 2001. */ @@ -62,22 +62,4 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - -/* The following functions were previously part of the DES section, - and are provided here for backward compatibility reasons. */ - -#define des_read_pw_string(b,l,p,v) \ - _ossl_old_des_read_pw_string((b),(l),(p),(v)) -#define des_read_pw(b,bf,s,p,v) \ - _ossl_old_des_read_pw((b),(bf),(s),(p),(v)) - -int _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify); -int _ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify); - -#ifdef __cplusplus -} -#endif #endif diff --git a/include/openssl/x509.h b/include/openssl/x509.h index bac1341a..9bcff069 100644 --- a/include/openssl/x509.h +++ b/include/openssl/x509.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.h,v 1.90 2022/07/12 14:42:50 kn Exp $ */ +/* $OpenBSD: x509.h,v 1.94 2023/03/10 16:43:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -413,6 +413,8 @@ STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl); void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig, const X509_ALGOR **palg); +const X509_ALGOR *X509_CRL_get0_tbs_sigalg(const X509_CRL *crl); + int X509_REQ_get_signature_nid(const X509_REQ *req); void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig, @@ -780,6 +782,8 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it, #endif const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x); +void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid, + const ASN1_BIT_STRING **psuid); const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x); int X509_set_version(X509 *x, long version); long X509_get_version(const X509 *x); @@ -906,7 +910,7 @@ int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, int X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, char *buf,int len); -/* NOTE: you should be passsing -1, not 0 as lastpos. The functions that use +/* NOTE: you should be passing -1, not 0 as lastpos. The functions that use * lastpos, search after that position on. */ int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos); diff --git a/include/openssl/x509_vfy.h b/include/openssl/x509_vfy.h index 98b1cf5e..9e3c263a 100644 --- a/include/openssl/x509_vfy.h +++ b/include/openssl/x509_vfy.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_vfy.h,v 1.54 2022/07/07 13:01:28 tb Exp $ */ +/* $OpenBSD: x509_vfy.h,v 1.58 2023/03/10 16:44:07 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -212,8 +212,8 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); /* Certificate verify flags */ -/* Send issuer+subject checks to verify_cb */ -#define X509_V_FLAG_CB_ISSUER_CHECK 0x1 +/* Deprecated in 1.1.0, has no effect. Various FFI bindings still expose it. */ +#define X509_V_FLAG_CB_ISSUER_CHECK 0x0 /* Use check time instead of current time */ #define X509_V_FLAG_USE_CHECK_TIME 0x2 /* Lookup CRLs */ @@ -255,7 +255,7 @@ void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); /* Do not check certificate or CRL validity against current time. */ #define X509_V_FLAG_NO_CHECK_TIME 0x200000 -/* Force the use of the legacy certificate verifcation */ +/* Force the use of the legacy certificate verification */ #define X509_V_FLAG_LEGACY_VERIFY 0x400000 #define X509_VP_FLAG_DEFAULT 0x1 @@ -310,6 +310,15 @@ void X509_STORE_set_verify_cb(X509_STORE *ctx, #define X509_STORE_set_verify_cb_func(ctx, func) \ X509_STORE_set_verify_cb((ctx), (func)) +typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx, + X509 *subject, X509 *issuer); + +X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(X509_STORE *store); +void X509_STORE_set_check_issued(X509_STORE *store, + X509_STORE_CTX_check_issued_fn check_issued); +X509_STORE_CTX_check_issued_fn + X509_STORE_CTX_get_check_issued(X509_STORE_CTX *ctx); + X509_STORE_CTX *X509_STORE_CTX_new(void); int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); diff --git a/include/openssl/x509v3.h b/include/openssl/x509v3.h index 2bc87f60..1aff27cd 100644 --- a/include/openssl/x509v3.h +++ b/include/openssl/x509v3.h @@ -1,4 +1,4 @@ -/* $OpenBSD: x509v3.h,v 1.15 2022/07/12 14:42:50 kn Exp $ */ +/* $OpenBSD: x509v3.h,v 1.16 2022/11/07 19:42:24 schwarze Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -10,7 +10,7 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in @@ -335,17 +335,15 @@ typedef struct POLICY_CONSTRAINTS_st { } POLICY_CONSTRAINTS; /* Proxy certificate structures, see RFC 3820 */ -typedef struct PROXY_POLICY_st - { +typedef struct PROXY_POLICY_st { ASN1_OBJECT *policyLanguage; ASN1_OCTET_STRING *policy; - } PROXY_POLICY; +} PROXY_POLICY; -typedef struct PROXY_CERT_INFO_EXTENSION_st - { +typedef struct PROXY_CERT_INFO_EXTENSION_st { ASN1_INTEGER *pcPathLengthConstraint; PROXY_POLICY *proxyPolicy; - } PROXY_CERT_INFO_EXTENSION; +} PROXY_CERT_INFO_EXTENSION; PROXY_POLICY *PROXY_POLICY_new(void); void PROXY_POLICY_free(PROXY_POLICY *a); @@ -358,15 +356,14 @@ PROXY_CERT_INFO_EXTENSION *d2i_PROXY_CERT_INFO_EXTENSION(PROXY_CERT_INFO_EXTENSI int i2d_PROXY_CERT_INFO_EXTENSION(PROXY_CERT_INFO_EXTENSION *a, unsigned char **out); extern const ASN1_ITEM PROXY_CERT_INFO_EXTENSION_it; -struct ISSUING_DIST_POINT_st - { +struct ISSUING_DIST_POINT_st { DIST_POINT_NAME *distpoint; int onlyuser; int onlyCA; ASN1_BIT_STRING *onlysomereasons; int indirectCRL; int onlyattr; - }; +}; /* Values in idp_flags field */ /* IDP present */ @@ -527,11 +524,11 @@ int i2d_SXNETID(SXNETID *a, unsigned char **out); extern const ASN1_ITEM SXNETID_it; int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, - int userlen); + int userlen); int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user, - int userlen); + int userlen); int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user, - int userlen); + int userlen); ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, const char *zone); ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); @@ -594,7 +591,7 @@ void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value); void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype); int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, ASN1_OBJECT *oid, ASN1_TYPE *value); -int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, +int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, ASN1_OBJECT **poid, ASN1_TYPE **pvalue); char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, diff --git a/man/ASN1_TIME_set.3 b/man/ASN1_TIME_set.3 index cd6ab937..4f6a9967 100644 --- a/man/ASN1_TIME_set.3 +++ b/man/ASN1_TIME_set.3 @@ -1,8 +1,26 @@ -.\" $OpenBSD: ASN1_TIME_set.3,v 1.17 2022/03/31 17:27:16 naddy Exp $ -.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 +.\" $OpenBSD: ASN1_TIME_set.3,v 1.19 2022/11/13 22:11:44 schwarze Exp $ +.\" full merge up to: OpenSSL 3d0f1cb9 Jul 11 03:01:24 2017 +0800 .\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 .\" -.\" This file was written by Dr. Stephen Henson +.\" This file is a derived work. +.\" The changes are covered by the following Copyright and license: +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" Copyright (c) 2022 Bob Beck +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" The original file was written by Dr. Stephen Henson .\" and Todd Short . .\" Copyright (c) 2015, 2017 The OpenSSL Project. All rights reserved. .\" @@ -50,7 +68,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 31 2022 $ +.Dd $Mdocdate: November 13 2022 $ .Dt ASN1_TIME_SET 3 .Os .Sh NAME @@ -61,16 +79,21 @@ .Nm ASN1_UTCTIME_adj , .Nm ASN1_GENERALIZEDTIME_adj , .Nm ASN1_TIME_set_string , +.Nm ASN1_TIME_set_string_X509 , .Nm ASN1_UTCTIME_set_string , .Nm ASN1_GENERALIZEDTIME_set_string , +.Nm ASN1_TIME_normalize , .Nm ASN1_TIME_check , .Nm ASN1_UTCTIME_check , .Nm ASN1_GENERALIZEDTIME_check , .Nm ASN1_TIME_print , .Nm ASN1_UTCTIME_print , .Nm ASN1_GENERALIZEDTIME_print , +.Nm ASN1_TIME_to_tm , .Nm ASN1_TIME_diff , +.Nm ASN1_TIME_cmp_time_t , .Nm ASN1_UTCTIME_cmp_time_t , +.Nm ASN1_TIME_compare , .Nm ASN1_TIME_to_generalizedtime .Nd ASN.1 Time functions .Sh SYNOPSIS @@ -117,6 +140,11 @@ .Fa "const char *str" .Fc .Ft int +.Fo ASN1_TIME_set_string_X509 +.Fa "ASN1_TIME *s" +.Fa "const char *str" +.Fc +.Ft int .Fo ASN1_UTCTIME_set_string .Fa "ASN1_UTCTIME *s" .Fa "const char *str" @@ -127,6 +155,10 @@ .Fa "const char *str" .Fc .Ft int +.Fo ASN1_TIME_normalize +.Fa "ASN1_TIME *s" +.Fc +.Ft int .Fo ASN1_TIME_check .Fa "const ASN1_TIME *t" .Fc @@ -154,6 +186,11 @@ .Fa "const ASN1_GENERALIZEDTIME *s" .Fc .Ft int +.Fo ASN1_TIME_to_tm +.Fa "const ASN1_TIME *s" +.Fa "struct tm *tm" +.Fc +.Ft int .Fo ASN1_TIME_diff .Fa "int *pday" .Fa "int *psec" @@ -161,22 +198,55 @@ .Fa "const ASN1_TIME *to" .Fc .Ft int +.Fo ASN1_TIME_cmp_time_t +.Fa "const ASN1_TIME *s" +.Fa "time_t t" +.Fc +.Ft int .Fo ASN1_UTCTIME_cmp_time_t .Fa "const ASN1_UTCTIME *s" .Fa "time_t t" .Fc +.Ft int +.Fo ASN1_TIME_compare +.Fa "const ASN1_TIME *s" +.Fa "const ASN1_TIME *t" +.Fc .Ft ASN1_GENERALIZEDTIME * .Fo ASN1_TIME_to_generalizedtime .Fa "const ASN1_TIME *t" .Fa "ASN1_GENERALIZEDTIME **out" .Fc .Sh DESCRIPTION +An +.Vt ASN1_TIME +object is a shallow wrapper around a string containing an ASN.1 +.Vt Time +value in the restricted format valid in X.509 certificates. +An +.Vt ASN1_TIME +object is either an +.Vt ASN1_UTCTIME +object containing a string of the format +.Ar YYMMDDHHMMSS Ns Cm Z +which is valid for the years 1950 to 2049, or an +.Vt ASN1_GENERALIZEDTIME +object containing a string of the format +.Ar YYYYMMDDHHMMSS Ns Cm Z +which is valid for the years 0000 to 1949 and 2050 to 9999. +In both cases, the mandatory suffix +.Sq Cm Z +represents the GMT time zone. +LibreSSL by design does not support the full syntax of ASN.1 times. +In particular, it neither supports fractional seconds +nor any other time zone. +.Pp The functions .Fn ASN1_TIME_set , .Fn ASN1_UTCTIME_set , and .Fn ASN1_GENERALIZEDTIME_set -set the time structure +set the time object .Fa s to the time represented by the .Vt time_t @@ -186,14 +256,14 @@ If .Fa s is .Dv NULL , -a new time structure is allocated and returned. +a new time object is allocated and returned. .Pp The functions .Fn ASN1_TIME_adj , .Fn ASN1_UTCTIME_adj , and .Fn ASN1_GENERALIZEDTIME_adj -set the time structure +set the time object .Fa s to the time represented by the time .Fa offset_day @@ -216,7 +286,7 @@ If .Fa s is .Dv NULL , -a new time structure is allocated and returned. +a new time object is allocated and returned. .Pp .Fn ASN1_TIME_adj may change the type from @@ -228,19 +298,25 @@ The functions .Fn ASN1_UTCTIME_adj and .Fn ASN1_GENERALIZEDTIME_adj -do not modify the type of the return structure. +do not modify the type of the return object. .Pp The functions .Fn ASN1_TIME_set_string , +.Fn ASN1_TIME_set_string_X509 , .Fn ASN1_UTCTIME_set_string , and .Fn ASN1_GENERALIZEDTIME_set_string -set the time structure +set the time object .Fa s -to the time represented by the string +to the time string .Fa str , -which must be in appropriate ASN.1 time format (for example -YYMMDDHHMMSSZ or YYYYMMDDHHMMSSZ). +which must be in appropriate ASN.1 time format: +YYMMDDHHMMSSZ for +.Vt ASN1_UTCTIME , +YYYYMMDDHHMMSSZ for +.Vt ASN1_GENERALIZEDTIME , +or either of the two for +.Vt ASN1_TIME . The string .Fa str is copied into @@ -252,12 +328,32 @@ is these functions only perform a format check on .Fa str . .Pp +In LibreSSL, +.Fn ASN1_TIME_set_string +and +.Fn ASN1_TIME_set_string_X509 +behave identically and always set the time object +to a valid value to use in an X.509 certificate. +.Fn ASN1_GENERALIZEDTIME_set_string +may encode a time string that is not valid in an X.509 certificate. +.Pp +The function +.Fn ASN1_TIME_normalize +converts an +.Vt ASN1_GENERALIZEDTIME +into a time value that can be used in a certificate +by changing it to an +.Vt ASN1_UTCTIME +if possible. +It has no effect on an +.Vt ASN1_UTCTIME . +.Pp The functions .Fn ASN1_TIME_check , .Fn ASN1_UTCTIME_check , and .Fn ASN1_GENERALIZEDTIME_check -check the syntax of the time structure +check the syntax of the time string contained in the object .Fa s . .Pp The functions @@ -274,11 +370,37 @@ in human readable format. It will be of the format MMM DD HH:MM:SS YYYY [GMT], for example "Feb 3 00:55:52 2015 GMT". It does not include a newline. -If the time structure has an invalid format, +If the time string has an invalid format, it prints out "Bad time value" and returns an error. -The output of -.Fn ASN1_GENERALIZEDTIME_print -may include a fractional part following the second. +.Pp +The function +.Fn ASN1_TIME_to_tm +converts the time +.Fa s +to the standard +.Vt tm +structure. +If +.Fa s +is +.Dv NULL , +then the current time is converted. +The output time is always in the GMT time zone. +The +.Fa tm_sec , tm_min , tm_hour , tm_mday , tm_mon , +and +.Fa tm_year +fields of the +.Vt tm +structure are set to the proper values, +whereas all other fields are set to 0. +If +.Fa tm +is +.Dv NULL , +this function performs a format check on +.Fa s +only. .Pp The function .Fn ASN1_TIME_diff @@ -333,9 +455,12 @@ is .Dv NULL , the current time is used. .Pp -The function -.Fn ASN1_UTCTIME_cmp_time_t -compares the two times represented by +The functions +.Fn ASN1_TIME_cmp_time_t , +.Fn ASN1_UTCTIME_cmp_time_t , +and +.Fn ASN1_TIME_compare +compare the two times represented by .Fa s and .Fa t . @@ -357,33 +482,15 @@ is then a new object is allocated and must be freed after use. .Pp The -.Vt ASN1_TIME -structure corresponds to the ASN.1 structure -.Sy Time -defined in RFC 5280 et al. -The time setting functions obey the rules outlined in RFC 5280: if the -date can be represented by UTCTime it is used, otherwise GeneralizedTime is -used. -.Pp -The .Vt ASN1_TIME , .Vt ASN1_UTCTIME , and .Vt ASN1_GENERALIZEDTIME -structures are represented as +objects are represented as .Vt ASN1_STRING -structures internally and can be freed using +objects internally and can be freed using .Xr ASN1_STRING_free 3 . .Pp -The -.Vt ASN1_TIME -structure can represent years from 0000 to 9999 but no attempt is -made to correct ancient calendar changes (for example from Julian -to Gregorian calendars). -.Pp -.Vt ASN1_UTCTIME -is limited to a year range of 1950 through 2049. -.Pp It is recommended that .Vt ASN1_TIME functions be used instead of @@ -406,21 +513,26 @@ functions operate on either format. .Fn ASN1_GENERALIZEDTIME_adj , and .Fn ASN1_TIME_to_generalizedtime -return a pointer to a time structure or +return a pointer to a time object or .Dv NULL if an error occurred. .Pp .Fn ASN1_TIME_set_string , +.Fn ASN1_TIME_set_string_X509 , .Fn ASN1_UTCTIME_set_string , and .Fn ASN1_GENERALIZEDTIME_set_string return 1 if the time value is successfully set or 0 otherwise. .Pp +.Fn ASN1_TIME_normalize +returns 1 on success or 0 on error. +.Pp .Fn ASN1_TIME_check , .Fn ASN1_UTCTIME_check , and .Fn ASN1_GENERALIZEDTIME_check -return 1 if the time structure is syntactically correct or 0 otherwise. +return 1 if the time string contained in the object is syntactically +correct or 0 otherwise. .Pp .Fn ASN1_TIME_print , .Fn ASN1_UTCTIME_print , @@ -429,12 +541,19 @@ and return 1 if the time is successfully printed or 0 if an error occurred (I/O error or invalid time format). .Pp +.Fn ASN1_TIME_to_tm +returns 1 if the time is successfully parsed +or 0 if an error occurred, usually due to an invalid time format. +.Pp .Fn ASN1_TIME_diff returns 1 for success or 0 for failure. -It can for example fail if a time structure passed in has invalid syntax. +It can for example fail if a time string passed in has invalid syntax. .Pp -.Fn ASN1_UTCTIME_cmp_time_t -returns \-1 if +.Fn ASN1_TIME_cmp_time_t , +.Fn ASN1_UTCTIME_cmp_time_t , +and +.Fn ASN1_TIME_compare +return \-1 if .Fa s is earlier than .Fa t , @@ -444,27 +563,42 @@ is later than .Fa t , or \-2 on error. .Sh EXAMPLES -Set a time structure to one hour after the current time and print it +Set a time object to one hour after the current time and print it out: .Bd -literal -offset indent #include #include -ASN1_TIME *tm; +ASN1_TIME *asn1_time; time_t t; BIO *b; t = time(NULL); -tm = ASN1_TIME_adj(NULL, t, 0, 60 * 60); +asn1_time = ASN1_TIME_adj(NULL, t, 0, 60 * 60); b = BIO_new_fp(stdout, BIO_NOCLOSE); -ASN1_TIME_print(b, tm); -ASN1_STRING_free(tm); +if (asn1_time != NULL) { + ASN1_TIME_print(b, asn1_time); + BIO_printf(b, "\en"); +} else { + BIO_printf(b, "Time out of range or un-representable\en"); +} +ASN1_STRING_free(asn1_time); BIO_free(b); .Ed .Sh SEE ALSO .Xr ASN1_TIME_new 3 , .Xr ASN1_time_parse 3 , .Xr X509_cmp_time 3 +.Sh STANDARDS +The usage of the ASN.1 +.Vt Time , +.Vt UTCTime , +and +.Vt GeneralizedTime +data types in X.509 certificates is specified in +RFC 5280, Internet X.509 Public Key Infrastructure Certificate and +Certificate Revocation List (CRL) Profile, +section 4.1.2.5 (TBS Certificate Validity). .Sh HISTORY .Fn ASN1_UTCTIME_check and @@ -508,6 +642,15 @@ first appeared in OpenSSL 1.0.0 and have been available since .Fn ASN1_TIME_diff first appeared in OpenSSL 1.0.2 and have been available since .Ox 7.1 . +.Pp +.Fn ASN1_TIME_set_string_X509 , +.Fn ASN1_TIME_normalize , +.Fn ASN1_TIME_to_tm , +.Fn ASN1_TIME_cmp_time_t , +and +.Fn ASN1_TIME_compare +first appeared in OpenSSL 1.1.1 and have been available since +.Ox 7.2 . .Sh CAVEATS Some applications add offset times directly to a .Vt time_t @@ -526,10 +669,3 @@ and parameters instead of directly manipulating a .Vt time_t value. -.Sh BUGS -.Fn ASN1_TIME_print , -.Fn ASN1_UTCTIME_print , -and -.Fn ASN1_GENERALIZEDTIME_print -do not print the time zone: they either print "GMT" or nothing. -But all certificates complying with RFC 5280 et al use GMT anyway. diff --git a/man/ASN1_bn_print.3 b/man/ASN1_bn_print.3 index 75944917..45e57211 100644 --- a/man/ASN1_bn_print.3 +++ b/man/ASN1_bn_print.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ASN1_bn_print.3,v 1.1 2021/12/08 21:52:29 schwarze Exp $ +.\" $OpenBSD: ASN1_bn_print.3,v 1.2 2022/12/14 20:27:28 schwarze Exp $ .\" .\" Copyright (c) 2021 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 8 2021 $ +.Dd $Mdocdate: December 14 2022 $ .Dt ASN1_BN_PRINT 3 .Os .Sh NAME @@ -105,6 +105,7 @@ is a pointer. It returns 0 if printing fails. .Sh SEE ALSO +.Xr ASN1_buf_print 3 , .Xr BIO_new 3 , .Xr BIO_write 3 , .Xr BN_is_negative 3 , diff --git a/man/ASN1_buf_print.3 b/man/ASN1_buf_print.3 new file mode 100644 index 00000000..12ee84ad --- /dev/null +++ b/man/ASN1_buf_print.3 @@ -0,0 +1,70 @@ +.\" $OpenBSD: ASN1_buf_print.3,v 1.1 2022/12/14 20:27:28 schwarze Exp $ +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: December 14 2022 $ +.Dt ASN1_BUF_PRINT 3 +.Os +.Sh NAME +.Nm ASN1_buf_print +.Nd pretty-print a byte array +.Sh SYNOPSIS +.In openssl/asn1.h +.Ft int +.Fo ASN1_buf_print +.Fa "BIO *bio_out" +.Fa "const unsigned char *buf" +.Fa "size_t buflen" +.Fa "int indent" +.Fc +.Sh DESCRIPTION +.Fn ASN1_buf_print +prints a hexadecimal representation of the first +.Fa buflen +bytes from +.Fa buf +to +.Fa bio_out . +Despite its name and the header file, +this function has nothing to do with ASN.1. +.Pp +Each byte from +.Fa buf +is represented by two lower-case hexadecimal digits. +Fifteen pairs of digits are printed per output line, +or at most fifteen on the last output line. +Every output line including the last one ends with a newline character. +Every pair except the last is followed by a colon +.Pq Sq \&: . +If +.Fa indent +is greater than zero, +every output line is indented by +.Fa indent +space characters, but not by more than 64 characters. +.Sh RETURN VALUES +.Fn ASN1_buf_print +returns 1 if successful or 0 if printing fails. +.Sh SEE ALSO +.Xr ASN1_bn_print 3 , +.Xr ASN1_item_print 3 , +.Xr ASN1_STRING_print_ex 3 , +.Xr ASN1_TIME_print 3 , +.Xr BIO_new 3 , +.Xr BIO_write 3 +.Sh HISTORY +.Fn ASN1_buf_print +first appeared in OpenSSL 1.1.0 and has been available since +.Ox 7.3 . diff --git a/man/BIO_accept.3 b/man/BIO_accept.3 new file mode 100644 index 00000000..7e9839c1 --- /dev/null +++ b/man/BIO_accept.3 @@ -0,0 +1,382 @@ +.\" $OpenBSD: BIO_accept.3,v 1.1 2022/12/22 21:05:48 schwarze Exp $ +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: December 22 2022 $ +.Dt BIO_ACCEPT 3 +.Os +.Sh NAME +.\" mentioned in OpenSSL documentation and still used internally in LibreSSL +.Nm BIO_get_host_ip , +.Nm BIO_get_port , +.Nm BIO_get_accept_socket , +.Nm BIO_accept , +.Nm BIO_sock_error , +.Nm BIO_sock_non_fatal_error , +.Nm BIO_sock_should_retry , +.\" used internally in LibreSSL and OpenSSL and not deprecated in OpenSSL +.Nm BIO_socket_nbio , +.\" mentioned in OpenSSL documentation and not deprecated in OpenSSL +.Nm BIO_set_tcp_ndelay +.\" deprecated in OpenSSL and unused anywhere, hence intentionally undocumented +.\" .Nm BIO_gethostbyname +.\" .Nm BIO_socket_ioctl +.\" does almost nothing and used very rarely, hence intentionally undocumented +.\" .Nm BIO_sock_init +.\" .Nm BIO_sock_cleanup +.Nd wrappers for socket operations +.Sh SYNOPSIS +.In openssl/bio.h +.Ft int +.Fo BIO_get_host_ip +.Fa "const char *hostname" +.Fa "unsigned char *in_addr_buffer" +.Fc +.Ft int +.Fo BIO_get_port +.Fa "const char *servname" +.Fa "unsigned short *port" +.Fc +.Ft int +.Fo BIO_get_accept_socket +.Fa "char *host_port" +.Fa "int bind_mode" +.Fc +.Ft int +.Fo BIO_accept +.Fa "int socket" +.Fa "char **addr" +.Fc +.Ft int +.Fn BIO_sock_error "int socket" +.Ft int +.Fn BIO_sock_non_fatal_error "int errnum" +.Ft int +.Fn BIO_sock_should_retry "int retval" +.Ft int +.Fn BIO_socket_nbio "int socket" "int mode" +.Ft int +.Fn BIO_set_tcp_ndelay "int socket" "int on" +.Sh DESCRIPTION +.Fn BIO_get_host_ip +looks up one IPv4 address for the given +.Fa hostname +using +.Xr getaddrinfo 3 +and writes the first returned IPv4 address into +.Pf * Fa in_addr_buffer . +The caller is responsible for providing a buffer that is at least +.Fn sizeof in_addr_t +bytes long. +After a successful call, the caller needs to cast +.Fa in_addr_buffer +to +.Pq Vt in_addr_t * . +.Pp +.Fn BIO_get_port +looks up +.Fa servname +in the +.Xr services 5 +database using +.Xr getaddrinfo 3 +and stores the associated port number at the location specified by the +.Fa port +argument. +.Pp +.Fn BIO_get_accept_socket +creates an IPv4 TCP socket and +.Xr listen 2 Ns s +for incoming connections. +The string +.Fa host_port +is parsed. +If it contains a colon, the substring before the colon is interpreted +as a local hostname of the interface to +.Xr bind 2 +to. +If the hostname is empty, consists of a single asterisk +.Pq Qq *:... , +or if there is no colon, +.Dv INADDR_ANY +is used instead of a local hostname. +The rest of the string +.Fa host_port , +or the whole string if it contains no colon, +is treated as a service name. +The hostname and the service name are converted to a local IP address +and port number using +.Xr getaddrinfo 3 . +If +.Fa bind_mode +is the constant +.Dv BIO_BIND_REUSEADDR , +allowing local address reuse is attempted using +.Xr setsockopt 2 +with an argument of +.Dv SO_REUSEADDR +before calling +.Xr bind 2 . +.Pp +.Fn BIO_accept +calls +.Xr accept 2 +to receive one connection on the +.Fa socket . +When it receives a connection, it +.Xr free 3 Ns s +.Pf * Fa addr , +and if it is an IPv4 connection, it allocates a new string, +writes the peer IP address in dotted decimal form, a colon, +and the decimal port number into the string, and stores a pointer +to the string in +.Pf * Fa addr . +For other address families or if +.Xr getnameinfo 3 +or memory allocation fails, +.Pf * Fa addr +is set to +.Dv NULL +but +.Fn BIO_accept +succeeds anyway. +.Pp +.Fn BIO_sock_error +retrieves, clears, and returns the error status code of the +.Fa socket +by calling +.Xr getsockopt 2 +with arguments +.Dv SOL_SOCKET +and +.Dv SO_ERROR . +.Pp +.Fn BIO_sock_non_fatal_error +determines whether the error status code +.Fa errnum +represents a recoverable error. +.Pp +.Fn BIO_sock_should_retry +determines whether a recoverable error occurred by inspecting both +.Xr errno 2 +and +.Fa retval , +which is supposed to usually be +the return value of a previously called function like +.Fn BIO_accept , +.Xr BIO_read 3 , +or +.Xr BIO_write 3 . +.Pp +If +.Fa mode +is non-zero, +.Fn BIO_socket_nbio +switches the +.Fa socket +to non-blocking mode using +.Xr fcntl 2 . +If +.Fa mode +is 0, it switches to blocking mode. +.Pp +.Fn BIO_set_tcp_ndelay +sets the +.Dv TCP_NODELAY +option on the +.Fa socket +if +.Fa on +is 1 or clears it if +.Fa on +is 0; see +.Xr tcp 4 +for details. +.Sh RETURN VALUES +.Fn BIO_get_host_ip , +.Fn BIO_get_port , +and +.Fn BIO_socket_nbio +return 1 on success or 0 on failure. +.Pp +.Fn BIO_get_accept_socket +returns the file descriptor of the newly created listening socket or \-1 if +.Fa host_port +is +.Dv NULL , +no service is specified, or +.Xr getaddrinfo 3 , +.Xr socket 2 , +.Xr bind 2 , +.Xr listen 2 , +or memory allocation fails. +.Pp +.Fn BIO_accept +returns the file descriptor of the received connection, +\-1 on fatal errors, that is, when +.Fa addr +is +.Dv NULL +or +.Xr accept 2 +fails fatally, or \-2 when +.Xr accept 2 +fails in a non-fatal way and might succeed when retried later. +.Pp +.Fn BIO_sock_error +returns an error status code like +.Dv EAGAIN , +.Dv ECONNABORTED , +.Dv ECONNREFUSED , +.Dv ECONNRESET , +.Dv ELOOP , +.Dv EMSGSIZE , +.Dv ENOBUFS , +.Dv ENOTCONN , +.Dv EPIPE , +.Dv ETIMEDOUT , +or others, 0 if the +.Fa socket +is not in an error state, or 1 if +.Xr getsockopt 2 +fails. +.Pp +.Fn BIO_sock_non_fatal_error +returns 1 if +.Fa errnum +is +.Dv EAGAIN , +.Dv EALREADY , +.Dv EINPROGRESS , +.Dv EINTR , +or +.Dv ENOTCONN +and 0 otherwise, even if +.Fa errnum +is 0. +.Pp +.Fn BIO_sock_should_retry +returns 1 if +.Fn BIO_sock_non_fatal_error errno +is 1 and +.Fa retval +is either 0 or \-1, or 0 otherwise. +.Pp +.Fn BIO_set_tcp_ndelay +returns 0 on success or \-1 on failure. +.Sh ERRORS +If +.Fn BIO_get_host_ip , +.Fn BIO_get_port , +or +.Fn BIO_get_accept_socket +fail or +.Fn BIO_accept +fails fatally, the following diagnostics can be retrieved with +.Xr ERR_get_error 3 , +.Xr ERR_GET_REASON 3 , +and +.Xr ERR_reason_error_string 3 : +.Bl -tag -width Ds +.It Dv BIO_R_ACCEPT_ERROR Qq "accept error" +.Xr accept 2 +failed fatally in +.Fn BIO_accept . +.It Dv BIO_R_BAD_HOSTNAME_LOOKUP Qq "bad hostname lookup" +.Xr getaddrinfo 3 +failed or +.Fa hostname +was +.Dv NULL +in +.Fn BIO_get_host_ip , +or +.Xr getaddrinfo 3 +failed in +.Fn BIO_get_accept_socket . +.It Dv BIO_R_INVALID_ARGUMENT Qq "invalid argument" +.Xr getaddrinfo 3 +failed in +.Fn BIO_get_port . +.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure" +Memory allocation failed in +.Fn BIO_get_accept_socket , +or +.Fn BIO_accept +.Em succeeded +but was unable to allocate memory for +.Pf * Fa addr . +For +.Fn BIO_accept , +the returned file descriptor is valid, +and communication with the peer can be attempted using it. +.It Dv BIO_R_NO_PORT_SPECIFIED Qq "no port specified" +The +.Fa servname +argument was +.Dv NULL +in +.Fn BIO_get_port , +or +.Fa host_port +was +.Dv NULL +or ended after the first colon in +.Fn BIO_get_accept_socket . +.It Dv BIO_R_NULL_PARAMETER Qq "null parameter" +The +.Fa addr +argument was +.Dv NULL +in +.Fn BIO_accept . +.It Dv BIO_R_UNABLE_TO_BIND_SOCKET Qq "unable to bind socket" +.Xr bind 2 +failed in +.Fn BIO_get_accept_socket . +.It Dv BIO_R_UNABLE_TO_CREATE_SOCKET Qq "unable to create socket" +.Xr socket 2 +failed in +.Fn BIO_get_accept_socket . +.It Dv BIO_R_UNABLE_TO_LISTEN_SOCKET Qq "unable to listen socket" +.Xr listen 2 +failed in +.Fn BIO_get_accept_socket . +.El +.Sh SEE ALSO +.Xr bind 2 , +.Xr connect 2 , +.Xr errno 2 , +.Xr fcntl 2 , +.Xr getsockopt 2 , +.Xr listen 2 , +.Xr sigaction 2 , +.Xr socket 2 , +.Xr BIO_new 3 , +.Xr BIO_read 3 , +.Xr getaddrinfo 3 , +.Xr ip 4 , +.Xr tcp 4 +.Sh HISTORY +.Fn BIO_sock_should_retry +first appeared in SSLeay 0.6.5 and the other functions except +.Fn BIO_socket_nbio +in SSLeay 0.8.0. +They have all been available since +.Ox 2.4 . +.Pp +.Fn BIO_socket_nbio +first appeared in SSLeay 0.9.1 and has been available since +.Ox 2.6 . diff --git a/man/BIO_dump.3 b/man/BIO_dump.3 index b2145e22..8817f0c4 100644 --- a/man/BIO_dump.3 +++ b/man/BIO_dump.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_dump.3,v 1.3 2022/01/15 23:38:50 jsg Exp $ +.\" $OpenBSD: BIO_dump.3,v 1.4 2022/12/20 15:34:03 schwarze Exp $ .\" .\" Copyright (c) 2021 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: January 15 2022 $ +.Dd $Mdocdate: December 20 2022 $ .Dt BIO_DUMP 3 .Os .Sh NAME @@ -22,6 +22,9 @@ .Nm BIO_dump_indent , .Nm BIO_dump_fp , .Nm BIO_dump_indent_fp +.\" intentionally undocumented because nothing uses these two functions: +.\" .Nm BIO_dump_cb +.\" .Nm BIO_dump_indent_cb .Nd hexadecimal printout of arbitrary byte arrays .Sh SYNOPSIS .In openssl/bio.h diff --git a/man/BIO_dup_chain.3 b/man/BIO_dup_chain.3 new file mode 100644 index 00000000..561c811d --- /dev/null +++ b/man/BIO_dup_chain.3 @@ -0,0 +1,141 @@ +.\" $OpenBSD: BIO_dup_chain.3,v 1.1 2022/12/18 19:35:36 schwarze Exp $ +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: December 18 2022 $ +.Dt BIO_DUP_CHAIN 3 +.Os +.Sh NAME +.Nm BIO_dup_chain , +.Nm BIO_dup_state +.Nd copy a BIO chain +.Sh SYNOPSIS +.In openssl/bio.h +.Ft BIO * +.Fn BIO_dup_chain "BIO *b" +.Ft long +.Fn BIO_dup_state "BIO *b" "BIO *new_bio" +.Sh DESCRIPTION +.Fn BIO_dup_chain +copies the chain starting at +.Fa b +by iteratively copying +.Fa b +and all the BIOs following it +and joining the copies in the same order as in the original chain. +The copying operation is neither a deep copy nor a shallow copy. +.Pp +Some parts of the state of each BIO are copied, +in particular with respect to the values returned by +.Xr BIO_get_init 3 , +.Xr BIO_test_flags 3 , +and +.Xr BIO_get_shutdown 3 . +.\" XXX new_bio->num = bio->num; +Other parts of the state of the BIOs are not copied +but instead initialized to 0, +in particular with respect to the values returned by +.Xr BIO_number_read 3 , +.Xr BIO_number_written 3 , +and +.Xr BIO_get_retry_reason 3 . +The custom data pointer that can be used by custom BIO types +and that can be retrieved with +.Xr BIO_get_data 3 +is set set to +.Dv NULL +in the copied BIO objects rather than copied. +The reference count of each BIO in the copied chain is set to 1. +.Pp +For each BIO in the chain, copying the data that was set with +.Xr BIO_set_ex_data 3 +is attempted, which may involve calling application-defined +callback functions. +.Pp +The following pointers are copied +rather than creating deep copies of the objects pointed to: +.Bl -bullet +.It +The +.Fa type +pointer used for creating each BIO with +.Xr BIO_new 3 , +implying that functions like +.Xr BIO_method_name 3 +return pointers to the same strings for the BIOs in the copied chain, +and that these strings are not copied. +.It +All function pointers, in particular those installed with +.Xr BIO_set_callback_ex 3 +and +.Xr BIO_get_callback_ex 3 . +.It +The pointer installed with +.Xr BIO_set_callback_arg 3 , +which implies that for BIOs using +.Xr BIO_debug_callback 3 , +those in the copied chain use the same BIOs for debugging output +as the corresponding ones in the original chain, +and none of the debugging output BIOs are copied. +.El +.Pp +.Fn BIO_dup_state +is a macro that calls +.Xr BIO_ctrl 3 +with a +.Fa cmd +argument of +.Dv BIO_CTRL_DUP . +It is automatically called for each BIO during +.Fn BIO_dup_chain +after the copied BIO is initialized and data copied into it, +but before the data set with +.Xr BIO_set_ex_data 3 +is copied into the new BIO and before it is linked into the new chain. +.Pp +This control operation may modify the operation of +.Fn BIO_dup_chain +for particular types of BIOs contained in the chain, +for example initializing or copying additional data. +For BIO types provided by the library, such additional effects +are documented in the respective manual pages, in particular in +.Xr BIO_f_buffer 3 , +.Xr BIO_f_cipher 3 , +.Xr BIO_f_md 3 , +.Xr BIO_f_ssl 3 , +.Xr BIO_s_bio 3 , +and +.Xr BIO_s_connect 3 . +.Sh RETURN VALUES +.Fn BIO_dup_chain +returns a pointer to the newly allocated copy of the BIO +.Fa b +on success or +.Dv NULL +on failure . +.Pp +.Fn BIO_dup_state +returns 1 on success or a value less than or equal to zero on failure. +.Sh SEE ALSO +.Xr BIO_get_data 3 , +.Xr BIO_new 3 , +.Xr BIO_next 3 , +.Xr BIO_push 3 +.Sh HISTORY +.Fn BIO_dup_chain +and +.Fn BIO_dup_state +first appeared in SSLeay 0.8.0 and have been available since +.Ox 2.4 . diff --git a/man/BIO_f_base64.3 b/man/BIO_f_base64.3 index 68265b6c..5e0d4b8a 100644 --- a/man/BIO_f_base64.3 +++ b/man/BIO_f_base64.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_f_base64.3,v 1.11 2019/06/06 01:06:58 schwarze Exp $ +.\" $OpenBSD: BIO_f_base64.3,v 1.12 2022/12/07 17:17:29 tb Exp $ .\" OpenSSL fc1d88f0 Wed Jul 2 22:42:40 2014 -0400 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: June 6 2019 $ +.Dd $Mdocdate: December 7 2022 $ .Dt BIO_F_BASE64 3 .Os .Sh NAME @@ -88,11 +88,11 @@ BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); .Fn BIO_f_base64 returns the base64 BIO method. .Sh EXAMPLES -Base64 encode the string "Hello World\en" +Base64 encode the string "hello, world\en" and write the result to standard output: .Bd -literal -offset indent BIO *bio, *b64; -char message[] = "Hello World \en"; +char message[] = "hello, world\en"; b64 = BIO_new(BIO_f_base64()); bio = BIO_new_fp(stdout, BIO_NOCLOSE); diff --git a/man/BIO_f_buffer.3 b/man/BIO_f_buffer.3 index 27baf727..b84bb944 100644 --- a/man/BIO_f_buffer.3 +++ b/man/BIO_f_buffer.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: BIO_f_buffer.3,v 1.11 2022/03/31 17:27:16 naddy Exp $ -.\" OpenSSL 9b86974e Mar 19 12:32:14 2016 -0400 +.\" $OpenBSD: BIO_f_buffer.3,v 1.13 2022/12/23 17:27:53 schwarze Exp $ +.\" full merge up to OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . .\" Copyright (c) 2000, 2010, 2015, 2016 The OpenSSL Project. @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 31 2022 $ +.Dd $Mdocdate: December 23 2022 $ .Dt BIO_F_BUFFER 3 .Os .Sh NAME @@ -59,6 +59,9 @@ .Nm BIO_set_write_buffer_size , .Nm BIO_set_buffer_size , .Nm BIO_set_buffer_read_data +.\" .Nm BIO_buffer_get_num_lines is intentionally undocumented. +.\" Contrary to what bio.h says, it does not *not* get some "IO type", +.\" whatever that is supposed to be, but is a NOOP, and nothing uses it. .Nd buffering BIO .Sh SYNOPSIS .In openssl/bio.h @@ -159,6 +162,14 @@ such as when removing a buffering BIO using .Xr BIO_pop 3 . .Xr BIO_flush 3 may need to be retried if the ultimate source/sink BIO is non-blocking. +.Pp +When a chain containing a buffering BIO is copied with +.Xr BIO_dup_chain 3 , +.Fn BIO_set_read_buffer_size +and +.Fn BIO_set_write_buffer_size +are called internally to automatically copy both buffer sizes from the +original BIO object to the new one. .Sh RETURN VALUES .Fn BIO_f_buffer returns the buffering BIO method. diff --git a/man/BIO_f_cipher.3 b/man/BIO_f_cipher.3 index 6a4e7c53..79416668 100644 --- a/man/BIO_f_cipher.3 +++ b/man/BIO_f_cipher.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: BIO_f_cipher.3,v 1.12 2019/06/06 01:06:58 schwarze Exp $ -.\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700 +.\" $OpenBSD: BIO_f_cipher.3,v 1.13 2022/12/18 19:35:36 schwarze Exp $ +.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 .\" .\" This file was written by Dr. Stephen Henson . .\" Copyright (c) 2000, 2003, 2015, 2016 The OpenSSL Project. @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: June 6 2019 $ +.Dd $Mdocdate: December 18 2022 $ .Dt BIO_F_CIPHER 3 .Os .Sh NAME @@ -133,6 +133,13 @@ This is useful when .Fn BIO_set_cipher is not flexible enough for the applications needs. .Pp +When a chain containing a cipher BIO is copied with +.Xr BIO_dup_chain 3 , +the cipher context is automatically copied from the existing BIO object +to the new one and the init flag that can be retrieved with +.Xr BIO_get_init 3 +is set to 1. +.Pp When encrypting, .Xr BIO_flush 3 must be called to flush the final block through the BIO. diff --git a/man/BIO_f_md.3 b/man/BIO_f_md.3 index d1519bb0..d98111f4 100644 --- a/man/BIO_f_md.3 +++ b/man/BIO_f_md.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: BIO_f_md.3,v 1.11 2019/06/06 01:06:58 schwarze Exp $ -.\" OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 +.\" $OpenBSD: BIO_f_md.3,v 1.12 2022/12/18 19:35:36 schwarze Exp $ +.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by Dr. Stephen Henson . .\" Copyright (c) 2000, 2006, 2009, 2016 The OpenSSL Project. @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: June 6 2019 $ +.Dd $Mdocdate: December 18 2022 $ .Dt BIO_F_MD 3 .Os .Sh NAME @@ -145,6 +145,15 @@ is an internal context structure. Changes made to this context will affect the digest BIO itself, and the context pointer will become invalid when the digest BIO is freed. .Pp +When a chain containing a message digest BIO is copied with +.Xr BIO_dup_chain 3 , +.Xr EVP_MD_CTX_copy_ex 3 +is called internally to automatically copy the message digest context +from the existing BIO object to the new one, +and the init flag that can be retrieved with +.Xr BIO_get_init 3 +is set to 1. +.Pp After the digest has been retrieved from a digest BIO, it must be reinitialized by calling .Xr BIO_reset 3 diff --git a/man/BIO_f_null.3 b/man/BIO_f_null.3 index 755f37da..4944ced3 100644 --- a/man/BIO_f_null.3 +++ b/man/BIO_f_null.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: BIO_f_null.3,v 1.9 2018/05/01 17:05:05 schwarze Exp $ -.\" OpenSSL e117a890 Sep 14 12:14:41 2000 +0000 +.\" $OpenBSD: BIO_f_null.3,v 1.11 2022/12/23 16:59:39 schwarze Exp $ +.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 .\" .\" This file was written by Dr. Stephen Henson . .\" Copyright (c) 2000 The OpenSSL Project. All rights reserved. @@ -48,11 +48,14 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: May 1 2018 $ +.Dd $Mdocdate: December 23 2022 $ .Dt BIO_F_NULL 3 .Os .Sh NAME .Nm BIO_f_null +.\" .Nm BIO_f_nbio_test is intentionally undocumented +.\" because it exposes absurd functionality that is unused +.\" except in openssl(1) s_client/s_server -nbio_test. .Nd null filter .Sh SYNOPSIS .In openssl/bio.h @@ -69,6 +72,11 @@ As may be apparent, a null filter BIO is not particularly useful. All requests to a null filter BIO are passed through to the next BIO in the chain: this means that a BIO chain containing a null filter BIO behaves just as though the BIO was not there. +.Pp +A chain containing a null filter BIO cannot be copied with +.Xr BIO_dup_chain 3 , +and any attempt to do so fails and returns +.Dv NULL . .Sh RETURN VALUES .Fn BIO_f_null returns the null filter BIO method. diff --git a/man/BIO_f_ssl.3 b/man/BIO_f_ssl.3 index 5e18a85b..7292e63f 100644 --- a/man/BIO_f_ssl.3 +++ b/man/BIO_f_ssl.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_f_ssl.3,v 1.12 2022/03/31 17:27:18 naddy Exp $ +.\" $OpenBSD: BIO_f_ssl.3,v 1.13 2022/12/18 20:24:52 schwarze Exp $ .\" full merge up to: OpenSSL f672aee4 Feb 9 11:52:40 2016 -0500 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 31 2022 $ +.Dd $Mdocdate: December 18 2022 $ .Dt BIO_F_SSL 3 .Os .Sh NAME @@ -305,6 +305,18 @@ should be used for non blocking connect to determine if the call should be retried. If an SSL connection has already been established, this call has no effect. .Pp +When a chain containing an SSL BIO is copied with +.Xr BIO_dup_chain 3 , +.Xr SSL_dup 3 +is called internally to copy the +.Vt SSL +object from the existing BIO object to the new BIO object, +and the internal data related to +.Fn BIO_set_ssl_renegotiate_bytes +and +.Fn BIO_set_ssl_renegotiate_timeout +is also copied. +.Pp .Vt SSL .Vt BIO Ns s are exceptional in that if the underlying transport is non-blocking they can diff --git a/man/BIO_get_data.3 b/man/BIO_get_data.3 index 70944255..b4b0014d 100644 --- a/man/BIO_get_data.3 +++ b/man/BIO_get_data.3 @@ -1,10 +1,10 @@ -.\" $OpenBSD: BIO_get_data.3,v 1.3 2018/03/23 23:18:17 schwarze Exp $ -.\" selective merge up to: OpenSSL e90fc053 Jul 15 09:39:45 2017 -0400 +.\" $OpenBSD: BIO_get_data.3,v 1.7 2022/12/19 14:40:14 schwarze Exp $ +.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 .\" .\" This file is a derived work. .\" The changes are covered by the following Copyright and license: .\" -.\" Copyright (c) 2018 Ingo Schwarze +.\" Copyright (c) 2018, 2022 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -65,13 +65,24 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: December 19 2022 $ .Dt BIO_GET_DATA 3 .Os .Sh NAME .Nm BIO_set_data , .Nm BIO_get_data , +.Nm BIO_set_flags , +.Nm BIO_clear_flags , +.Nm BIO_test_flags , +.Nm BIO_get_flags , +.Nm BIO_set_retry_read , +.Nm BIO_set_retry_write , +.Nm BIO_set_retry_special , +.Nm BIO_clear_retry_flags , +.Nm BIO_get_retry_flags , +.Nm BIO_copy_next_retry , .Nm BIO_set_init , +.Nm BIO_get_init , .Nm BIO_set_shutdown , .Nm BIO_get_shutdown .Nd manage BIO state information @@ -87,10 +98,57 @@ .Fa "BIO *a" .Fc .Ft void +.Fo BIO_set_flags +.Fa "BIO *a" +.Fa "int flags" +.Fc +.Ft void +.Fo BIO_clear_flags +.Fa "BIO *a" +.Fa "int flags" +.Fc +.Ft int +.Fo BIO_test_flags +.Fa "const BIO *a" +.Fa "int flags" +.Fc +.Ft int +.Fo BIO_get_flags +.Fa "const BIO *a" +.Fc +.Ft void +.Fo BIO_set_retry_read +.Fa "BIO *a" +.Fc +.Ft void +.Fo BIO_set_retry_write +.Fa "BIO *a" +.Fc +.Ft void +.Fo BIO_set_retry_special +.Fa "BIO *a" +.Fc +.Ft void +.Fo BIO_clear_retry_flags +.Fa "BIO *a" +.Fc +.Ft int +.Fo BIO_get_retry_flags +.Fa "BIO *a" +.Fc +.Ft void +.Fo BIO_copy_next_retry +.Fa "BIO *a" +.Fc +.Ft void .Fo BIO_set_init .Fa "BIO *a" .Fa "int init" .Fc +.Ft int +.Fo BIO_get_init +.Fa "BIO *a" +.Fc .Ft void .Fo BIO_set_shutdown .Fa "BIO *a" @@ -114,6 +172,115 @@ This data can subsequently be retrieved via a call to This can be used by custom BIOs for storing implementation specific information. .Pp +.Fn BIO_set_flags +sets all the bits contained in the +.Fa flags +argument in the flags stored in +.Fa a . +The value of a flag neither changes when it is already set in +.Fa a +nor when it is unset in the +.Fa flags +argument. +.Pp +.Fn BIO_clear_flags +clears all the bits contained in the +.Fa flags +argument from the flags stored in +.Fa a . +The value of a flag neither changes when it is already unset in +.Fa a +nor when it is unset in the +.Fa flags +argument. +.Pp +.Fn BIO_test_flags +checks whether any of the bits contained in the +.Fa flags +argument are set in the flags stored in +.Fa a . +Application programs usually call macros like those documented in +.Xr BIO_should_retry 3 +rather than calling +.Fn BIO_test_flags +directly. +Flag bits correspond to accessor functions as follows: +.Pp +.Bl -tag -width BIO_FLAGS_SHOULD_RETRY -compact +.It Dv BIO_FLAGS_READ +.Xr BIO_should_read 3 +.It Dv BIO_FLAGS_WRITE +.Xr BIO_should_write 3 +.It Dv BIO_FLAGS_IO_SPECIAL +.Xr BIO_should_io_special 3 +.It Dv BIO_FLAGS_RWS +.Xr BIO_retry_type 3 +.It Dv BIO_FLAGS_SHOULD_RETRY +.Xr BIO_should_retry 3 +.It Dv BIO_FLAGS_BASE64_NO_NL +see +.Xr BIO_f_base64 3 +.It Dv BIO_FLAGS_MEM_RDONLY +see +.Xr BIO_s_mem 3 +.El +.Pp +In particular, +.Dv BIO_FLAGS_RWS +is the bitwise OR of +.Dv BIO_FLAGS_READ , +.Dv BIO_FLAGS_WRITE , +and +.Dv BIO_FLAGS_IO_SPECIAL . +.Pp +.Fn BIO_set_retry_read , +.Fn BIO_set_retry_write , +and +.Fn BIO_set_retry_special +set the +.Dv BIO_FLAGS_READ , +.Dv BIO_FLAGS_WRITE , +and +.Dv BIO_FLAGS_IO_SPECIAL +flag bit in +.Fa a , +respectively. +They all set the +.Dv BIO_FLAGS_SHOULD_RETRY +flag bit, too. +.Pp +.Fn BIO_clear_retry_flags +clears the flag bits +.Dv BIO_FLAGS_READ , +.Dv BIO_FLAGS_WRITE , +.Dv BIO_FLAGS_IO_SPECIAL , +and +.Dv BIO_FLAGS_SHOULD_RETRY +in +.Fa a . +.Pp +.Fn BIO_copy_next_retry +copies retry-related state data from the BIO that follows +.Fa a +in its chain to +.Fa a , +that is, the data accessible with +.Fn BIO_get_retry_flags +and +.Xr BIO_get_retry_reason 3 . +Flags which are already set in +.Fa a +are not cleared. +Before calling +.Fn BIO_copy_next_retry , +making sure that +.Fa a +is not the last BIO in its chain is the responsibility of the caller, +for example by checking that +.Xr BIO_next 3 +does not return +.Dv NULL . +.Pp The .Fn BIO_set_init function sets the @@ -161,6 +328,30 @@ or .Dv NULL if none is set. .Pp +.Fn BIO_test_flags +returns the bitwise AND of the +.Fa flags +argument and the flags stored in +.Fa a . +Consequently, it returns a non-zero value +if and only if at least one of the requested +.Fa flags +is set. +.Pp +.Fn BIO_get_flags +returns all the flags currently stored in +.Fa a . +.Pp +.Fn BIO_get_retry_flags +returns the bitwise AND of +.Pq Dv BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY +and the flags stored in +.Fa a . +.Pp +.Fn BIO_get_init +returns the value of the init flag of +.Fa a . +.Pp .Fn BIO_get_shutdown returns the value previously set with .Fn BIO_set_shutdown @@ -169,8 +360,38 @@ or with .Sh SEE ALSO .Xr BIO_meth_new 3 , .Xr BIO_new 3 , -.Xr BIO_set_close 3 +.Xr BIO_set_close 3 , +.Xr BIO_should_retry 3 .Sh HISTORY -These functions first appeared in OpenSSL 1.1.0 -and have been available since +.Fn BIO_set_flags , +.Fn BIO_clear_flags , +.Fn BIO_set_retry_read , +.Fn BIO_set_retry_write , +.Fn BIO_set_retry_special , +.Fn BIO_clear_retry_flags , +and +.Fn BIO_get_retry_flags +first appeared in SSLeay 0.8.0, +.Fn BIO_copy_next_retry +in SSLeay 0.8.1, and +.Fn BIO_get_flags +in SSLeay 0.9.0. +These functions have been available since +.Ox 2.4 . +.Pp +.Fn BIO_test_flags +first appeared in OpenSSL 0.9.8e and has been available since +.Ox 4.5 . +.Pp +.Fn BIO_set_data , +.Fn BIO_get_data , +.Fn BIO_set_init , +.Fn BIO_set_shutdown , +and +.Fn BIO_get_shutdown +first appeared in OpenSSL 1.1.0 and have been available since .Ox 6.3 . +.Pp +.Fn BIO_get_init +first appeared in OpenSSL 1.1.0 and has been available since +.Ox 7.1 . diff --git a/man/BIO_get_ex_new_index.3 b/man/BIO_get_ex_new_index.3 index a0bed0ea..fd584f6b 100644 --- a/man/BIO_get_ex_new_index.3 +++ b/man/BIO_get_ex_new_index.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_get_ex_new_index.3,v 1.12 2019/08/16 12:16:22 schwarze Exp $ +.\" $OpenBSD: BIO_get_ex_new_index.3,v 1.13 2022/12/23 17:52:32 schwarze Exp $ .\" full merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" .\" This file was written by Rich Salz . @@ -48,13 +48,15 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: August 16 2019 $ +.Dd $Mdocdate: December 23 2022 $ .Dt BIO_GET_EX_NEW_INDEX 3 .Os .Sh NAME .Nm BIO_get_ex_new_index , .Nm BIO_set_ex_data , .Nm BIO_get_ex_data , +.Nm BIO_set_app_data , +.Nm BIO_get_app_data , .Nm ENGINE_get_ex_new_index , .Nm ENGINE_set_ex_data , .Nm ENGINE_get_ex_data , @@ -101,6 +103,15 @@ .Fa "TYPE *d" .Fa "int idx" .Fc +.Ft int +.Fo TYPE_set_app_data +.Fa "TYPE *d" +.Fa "void *arg" +.Fc +.Ft void * +.Fo TYPE_get_app_data +.Fa "TYPE *d" +.Fc .Sh DESCRIPTION In the description here, .Vt TYPE @@ -133,15 +144,30 @@ is a function that calls with an offset into the opaque exdata part of the .Vt TYPE object. +.Pp +.Fn TYPE_set_app_data +and +.Fn TYPE_get_app_data +are deprecated wrappers that call +.Fn TYPE_set_ex_data +and +.Fn TYPE_get_ex_data +with +.Fa idx +set to 0. .Sh RETURN VALUES .Fn TYPE_get_new_ex_index returns a new index on success or \-1 on error. .Pp .Fn TYPE_set_ex_data -returns 1 on success or 0 on error. +and +.Fn TYPE_set_app_data +return 1 on success or 0 on error. .Pp .Fn TYPE_get_ex_data -returns the application data or +and +.Fn TYPE_get_app_data +return the application data or .Dv NULL if an error occurred. .Sh SEE ALSO @@ -150,11 +176,16 @@ if an error occurred. .Xr RSA_get_ex_new_index 3 , .Xr X509_new 3 .Sh HISTORY +.Fn BIO_set_app_data +and +.Fn BIO_get_app_data +first appeared in SSLeay 0.8.1. .Fn BIO_get_ex_new_index , .Fn BIO_set_ex_data , and .Fn BIO_get_ex_data -first appeared in SSLeay 0.9.0 and have been available since +first appeared in SSLeay 0.9.0. +These functions have been available since .Ox 2.4 . .Pp .Fn X509_get_ex_new_index , diff --git a/man/BIO_new.3 b/man/BIO_new.3 index 17f5a708..f9581499 100644 --- a/man/BIO_new.3 +++ b/man/BIO_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_new.3,v 1.22 2021/11/27 16:18:03 schwarze Exp $ +.\" $OpenBSD: BIO_new.3,v 1.26 2022/12/23 15:59:34 schwarze Exp $ .\" full merge up to: .\" OpenSSL man3/BIO_new.pod fb46be03 Feb 26 11:51:31 2016 +0000 .\" OpenSSL man7/bio.pod 631c37be Dec 12 16:56:50 2017 +0100 @@ -52,7 +52,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: November 27 2021 $ +.Dd $Mdocdate: December 23 2022 $ .Dt BIO_NEW 3 .Os .Sh NAME @@ -228,8 +228,11 @@ Create a memory BIO: .Pp .Dl BIO *mem = BIO_new(BIO_s_mem()); .Sh SEE ALSO +.Xr ASN1_buf_print 3 , +.Xr BIO_accept 3 , .Xr BIO_ctrl 3 , .Xr BIO_dump 3 , +.Xr BIO_dup_chain 3 , .Xr BIO_f_asn1 3 , .Xr BIO_f_base64 3 , .Xr BIO_f_buffer 3 , @@ -247,6 +250,7 @@ Create a memory BIO: .Xr BIO_s_accept 3 , .Xr BIO_s_bio 3 , .Xr BIO_s_connect 3 , +.Xr BIO_s_datagram 3 , .Xr BIO_s_fd 3 , .Xr BIO_s_file 3 , .Xr BIO_s_mem 3 , diff --git a/man/BIO_push.3 b/man/BIO_push.3 index 768f4d85..46c736e2 100644 --- a/man/BIO_push.3 +++ b/man/BIO_push.3 @@ -1,8 +1,26 @@ -.\" $OpenBSD: BIO_push.3,v 1.7 2018/03/27 17:35:50 schwarze Exp $ -.\" OpenSSL doc/man3/BIO_push.pod 76ed5a42 Jun 29 13:38:55 2014 +0100 -.\" OpenSSL doc/man7/bio.pod a9c85cea Nov 11 09:33:55 2016 +0100 +.\" $OpenBSD: BIO_push.3,v 1.14 2022/12/16 16:02:17 schwarze Exp $ +.\" full merge up to: +.\" OpenSSL doc/man3/BIO_push.pod 791bfd91 Nov 19 20:38:27 2021 +0100 +.\" OpenSSL doc/man7/bio.pod 1cb7eff4 Sep 10 13:56:40 2019 +0100 .\" -.\" This file was written by Dr. Stephen Henson . +.\" This file is a derived work. +.\" The changes are covered by the following Copyright and license: +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" The original file was written by Dr. Stephen Henson . .\" Copyright (c) 2000, 2014 The OpenSSL Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -49,75 +67,164 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 27 2018 $ +.Dd $Mdocdate: December 16 2022 $ .Dt BIO_PUSH 3 .Os .Sh NAME .Nm BIO_push , -.Nm BIO_pop -.Nd add and remove BIOs from a chain +.Nm BIO_pop , +.Nm BIO_set_next +.Nd manipulate BIO chains .Sh SYNOPSIS .In openssl/bio.h .Ft BIO * .Fo BIO_push .Fa "BIO *b" -.Fa "BIO *append" +.Fa "BIO *new_tail" .Fc .Ft BIO * .Fo BIO_pop .Fa "BIO *b" .Fc +.Ft void +.Fo BIO_set_next +.Fa "BIO *b" +.Fa "BIO *new_tail" +.Fc .Sh DESCRIPTION BIOs can be joined together to form chains. -A chain normally consist of one or more filter BIOs +A chain normally consists of one or more filter BIOs and one source/sink BIO at the end. Data read from or written to the first BIO traverses the chain to the end. -A single BIO can be regarded as a chain with one component. .Pp -The +Every BIO is a member of exactly one chain. +It is either at the beginning of its chain +or there is exactly one preceding BIO. +It is either at the end of its chain +or there is exactly one following BIO. +If there is neither a preceding nor a following BIO, +it can be regarded as a chain with one member. +Every chain has exactly one beginning and exactly one end. +.Pp .Fn BIO_push -function appends the BIO -.Fa append -to -.Fa b -and returns +appends the chain starting at +.Fa new_tail +to the end of the chain that contains .Fa b . +Unless +.Fa b +is +.Dv NULL , +it then calls +.Xr BIO_ctrl 3 +on +.Fa b +with an argument of +.Dv BIO_CTRL_PUSH . +If +.Fa b +or +.Fa new_tail +is +.Dv NULL , +nothing is appended. +.Pp +In LibreSSL, if +.Fa new_tail +is not at the beginning of its chain, +the head of that chain up to but not including +.Fa new_tail +is cut off and becomes a separate chain. +For portability, it is best to make sure that +.Fa new_tail +is at the beginning of its chain before calling +.Fn BIO_push . .Pp .Fn BIO_pop removes the BIO .Fa b -from a chain and returns the next BIO in the chain, or -.Dv NULL -if there is no next BIO. -The removed BIO then becomes a single BIO with no association with the -original chain. -it can thus be freed or attached to a different chain. +from its chain. +Despite the word +.Dq pop +in the function name, +.Fa b +can be at the beginning, in the middle, or at the end of its chain. +Before removal, +.Xr BIO_ctrl 3 +is called on +.Fa b +with an argument of +.Dv BIO_CTRL_POP . +The removed BIO +.Fa b +becomes the only member of its own chain and can thus be freed +or attached to a different chain. +If +.Fa b +is +.Dv NULL , +no action occurs. .Pp -The names of these functions are perhaps a little misleading. -.Fn BIO_push -joins two BIO chains whereas -.Fn BIO_pop -deletes a single BIO from a chain; -the deleted BIO does not need to be at the end of a chain. +.Fn BIO_set_next +appends the chain starting with +.Fa new_tail +to the chain ending with +.Fa b . .Pp -The process of calling -.Fn BIO_push -and +In LibreSSL, if +.Fa new_tail +is not at the beginning of its chain, +the head of that chain up to but not including +.Fa new_tail +is cut off and becomes a separate chain, +and if +.Fa b +is not at the end of its chain, +the tail of that chain starting after +.Fa b +is cut off and becomes a separate chain. +.Pp +For portability, it is best to make sure that +.Fa b +is at the end of its chain and that +.Fa new_tail +is at the beginning of its chain before calling +.Fn BIO_set_next +and to avoid calling .Fn BIO_pop -on a BIO may have additional consequences: a +on +.Fa new_tail +afterwards. +.Pp +In LibreSSL, the only built-in BIO type for which .Xr BIO_ctrl 3 -call is made to the affected BIOs. -Any effects will be noted in the descriptions of individual BIOs. +calls with an argument of +.Dv BIO_CTRL_PUSH +or +.Dv BIO_CTRL_POP +have any effect is +.Xr BIO_f_ssl 3 . .Sh RETURN VALUES .Fn BIO_push -returns the beginning of the chain, -.Fa b . +returns +.Fa b +if it is not +.Dv NULL +or +.Fa new_tail +if it is. .Pp .Fn BIO_pop -returns the next BIO in the chain, or +returns the BIO that followed +.Fa b +in its chain, or .Dv NULL -if there is no next BIO. +if +.Fa b +is +.Dv NULL +or was at the end of its chain. .Sh EXAMPLES For these examples suppose .Sy md1 @@ -127,7 +234,12 @@ are digest BIOs, .Sy b64 is a Base64 BIO and .Sy f -is a file BIO. +is a file BIO (see +.Xr BIO_f_md 3 , +.Xr BIO_f_base64 3 , +and +.Xr BIO_s_file 3 , +respectively). .Pp If the call .Pp @@ -183,3 +295,41 @@ first appeared in SSLeay 0.6.0. first appeared in SSLeay 0.6.4. Both functions have been available since .Ox 2.4 . +.Pp +.Fn BIO_set_next +first appeared in OpenSSL 1.1.0 +and has been available since +.Ox 7.1 . +.Sh CAVEATS +Creating a cyclic chain results in undefined behavior. +For example, infinite recursion or infinite loops may ensue. +.Pp +If it is unknown whether +.Fa b +and +.Fa new_tail +are already members of the same chain and whether joining them would +create a cycle, the calling code can use the following safe idiom: +.Bd -literal -offset indent +BIO *btest; + +for (btest = new_tail; btest != NULL; btest = BIO_next(btest)) + if (btest == b) + /* Bail out because this would create a cycle. */ +BIO_push(b, new_tail); /* This is now safe. */ +.Ed +.Pp +The same idiom can be used with +.Fn BIO_set_next +instead of +.Fn BIO_push . +.Pp +Often, the safe idiom is not needed because it is already known that +.Fa b +and +.Fa new_tail +are not members of the same chain, for example when +.Fa b +or +.Fa new_tail +was created right before. diff --git a/man/BIO_read.3 b/man/BIO_read.3 index ac809bc7..5fea9f72 100644 --- a/man/BIO_read.3 +++ b/man/BIO_read.3 @@ -1,10 +1,10 @@ -.\" $OpenBSD: BIO_read.3,v 1.10 2021/12/08 16:31:10 schwarze Exp $ +.\" $OpenBSD: BIO_read.3,v 1.11 2022/12/18 17:40:55 schwarze Exp $ .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file is a derived work. .\" The changes are covered by the following Copyright and license: .\" -.\" Copyright (c) 2021 Ingo Schwarze +.\" Copyright (c) 2021, 2022 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -65,15 +65,17 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: December 8 2021 $ +.Dd $Mdocdate: December 18 2022 $ .Dt BIO_READ 3 .Os .Sh NAME .Nm BIO_read , +.Nm BIO_number_read , .Nm BIO_gets , .Nm BIO_write , .Nm BIO_puts , -.Nm BIO_indent +.Nm BIO_indent , +.Nm BIO_number_written .Nd BIO I/O functions .Sh SYNOPSIS .In openssl/bio.h @@ -83,6 +85,10 @@ .Fa "void *buf" .Fa "int len" .Fc +.Ft unsigned long +.Fo BIO_number_read +.Fa "BIO *b" +.Fc .Ft int .Fo BIO_gets .Fa "BIO *b" @@ -106,6 +112,10 @@ .Fa "int indent" .Fa "int max" .Fc +.Ft unsigned long +.Fo BIO_number_written +.Fa "BIO *b" +.Fc .Sh DESCRIPTION .Fn BIO_read attempts to read @@ -115,6 +125,26 @@ bytes from and places the data in .Fa buf . .Pp +.Fn BIO_number_read +returns the grand total of bytes read from +.Fa b +using +.Fn BIO_read +so far. +Bytes read with +.Fn BIO_gets +do +.Sy not +count. +.Xr BIO_new 3 +and +.Xr BIO_set 3 +initialize the counter to 0. +When reading very large amounts of data, +the counter will eventually wrap around from +.Dv ULONG_MAX +to 0. +.Pp .Fn BIO_gets performs the BIOs "gets" operation and places the data in .Fa buf . @@ -152,6 +182,24 @@ but not more than .Fa max characters. .Pp +.Fn BIO_number_written +returns the grand total of bytes written to +.Fa b +using +.Fn BIO_write , +.Fn BIO_puts , +and +.Fn BIO_indent +so far. +.Xr BIO_new 3 +and +.Xr BIO_set 3 +initialize the counter to 0. +When writing very large amounts of data, +the counter will eventually wrap around from +.Dv ULONG_MAX +to 0. +.Pp One technique sometimes used with blocking sockets is to use a system call (such as .Xr select 2 , @@ -189,6 +237,15 @@ to the chain. returns 1 if successful, even if nothing was written, or 0 if writing fails. .Pp +.Fn BIO_number_read +and +.Fn BIO_number_written +return a number of bytes or 0 if +.Fa b +is a +.Dv NULL +pointer. +.Pp The other functions return either the amount of data successfully read or written (if the return value is positive) or that no data was successfully read or written if the result is 0 or \-1. @@ -211,7 +268,12 @@ the application should retry the operation later. .Fn BIO_write , and .Fn BIO_puts -first appeared in SSLeay 0.6.0 and have been available since +first appeared in SSLeay 0.6.0. +.Fn BIO_number_read +and +.Fn BIO_number_written +first appeared in SSLeay 0.6.5. +These functions have been available since .Ox 2.4 . .Pp .Fn BIO_indent diff --git a/man/BIO_s_bio.3 b/man/BIO_s_bio.3 index bf4e8738..227828e2 100644 --- a/man/BIO_s_bio.3 +++ b/man/BIO_s_bio.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: BIO_s_bio.3,v 1.14 2022/03/31 17:27:16 naddy Exp $ -.\" OpenSSL c03726ca Aug 27 12:28:08 2015 -0400 +.\" $OpenBSD: BIO_s_bio.3,v 1.16 2022/12/21 15:08:37 schwarze Exp $ +.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" .\" This file was written by .\" Lutz Jaenicke , @@ -53,7 +53,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 31 2022 $ +.Dd $Mdocdate: December 21 2022 $ .Dt BIO_S_BIO 3 .Os .Sh NAME @@ -69,6 +69,12 @@ .Nm BIO_get_read_request , .Nm BIO_ctrl_get_read_request , .Nm BIO_ctrl_reset_read_request +.\" The following non-copying I/O functions are intentionally undocumented +.\" because they seem fragile and unused by anything: +.\" .Nm BIO_nread0 +.\" .Nm BIO_nread +.\" .Nm BIO_nwrite0 +.\" .Nm BIO_nwrite .Nd BIO pair BIO .Sh SYNOPSIS .In openssl/bio.h @@ -184,6 +190,10 @@ to .Fa size . If the size is not initialized, a default value is used. This is currently 17K, sufficient for a maximum size TLS record. +When a chain containing a BIO pair is copied with +.Xr BIO_dup_chain 3 , +the write buffer size is automatically copied +from the original BIO object to the new one. .Pp .Fn BIO_get_write_buf_size returns the size of the write buffer. diff --git a/man/BIO_s_connect.3 b/man/BIO_s_connect.3 index 2732e9bc..ee6d4e38 100644 --- a/man/BIO_s_connect.3 +++ b/man/BIO_s_connect.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: BIO_s_connect.3,v 1.12 2022/03/31 17:27:16 naddy Exp $ -.\" OpenSSL 186bb907 Apr 13 11:05:13 2015 -0700 +.\" $OpenBSD: BIO_s_connect.3,v 1.14 2022/12/18 19:35:36 schwarze Exp $ +.\" full merge up to: OpenSSL 0e474b8b Nov 1 15:45:49 2015 +0100 .\" .\" This file was written by Dr. Stephen Henson . .\" Copyright (c) 2000, 2015 The OpenSSL Project. All rights reserved. @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 31 2022 $ +.Dd $Mdocdate: December 18 2022 $ .Dt BIO_S_CONNECT 3 .Os .Sh NAME @@ -106,12 +106,10 @@ .Ft char * .Fo BIO_get_conn_ip .Fa "BIO *b" -.Fa "dummy" .Fc .Ft long .Fo BIO_get_conn_int_port .Fa "BIO *b" -.Fa "int port" .Fc .Ft long .Fo BIO_set_nbio @@ -292,6 +290,17 @@ that a connection attempt would block. The application should then take appropriate action to wait until the underlying socket has connected and retry the call. .Pp +When a chain containing a connect BIO is copied with +.Xr BIO_dup_chain 3 , +.Fn BIO_set_conn_hostname , +.Fn BIO_set_conn_port , +.Fn BIO_set_nbio , +and +.Xr BIO_set_info_callback 3 +are called internally to automatically copy the hostname, port, +non-blocking I/O flag, and info callback from the original BIO object +to the new one. +.Pp .Fn BIO_set_conn_hostname , .Fn BIO_set_conn_port , .Fn BIO_set_conn_ip , diff --git a/man/BIO_s_datagram.3 b/man/BIO_s_datagram.3 new file mode 100644 index 00000000..5ee6fca1 --- /dev/null +++ b/man/BIO_s_datagram.3 @@ -0,0 +1,572 @@ +.\" $OpenBSD: BIO_s_datagram.3,v 1.2 2022/12/28 07:59:13 jsg Exp $ +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: December 28 2022 $ +.Dt BIO_S_DATAGRAM 3 +.Os +.Sh NAME +.Nm BIO_s_datagram , +.Nm BIO_new_dgram , +.Nm BIO_dgram_set_peer , +.Nm BIO_ctrl_dgram_connect , +.Nm BIO_dgram_get_peer , +.Nm BIO_ctrl_set_connected , +.Nm BIO_dgram_recv_timedout , +.Nm BIO_dgram_send_timedout , +.Nm BIO_dgram_non_fatal_error +.Nd datagram socket BIO +.Sh SYNOPSIS +.In openssl/bio.h +.Ft const BIO_METHOD * +.Fn BIO_s_datagram void +.Ft BIO * +.Fo BIO_new_dgram +.Fa "int fd" +.Fa "int close_flag" +.Fc +.Ft int +.Fo BIO_dgram_set_peer +.Fa "BIO *b" +.Fa "struct sockaddr *sa" +.Fc +.Ft int +.Fo BIO_ctrl_dgram_connect +.Fa "BIO *b" +.Fa "struct sockaddr *sa" +.Fc +.Ft int +.Fo BIO_dgram_get_peer +.Fa "BIO *b" +.Fa "struct sockaddr *sa" +.Fc +.Ft int +.Fo BIO_ctrl_set_connected +.Fa "BIO *b" +.Fa "long argl" +.Fa "struct sockaddr *sa" +.Fc +.Ft int +.Fn BIO_dgram_recv_timedout "BIO *b" +.Ft int +.Fn BIO_dgram_send_timedout "BIO *b" +.Ft int +.Fn BIO_dgram_non_fatal_error "int errnum" +.Sh DESCRIPTION +.Fn BIO_s_datagram +returns the datagram socket BIO method. +The usual application is to transmit data using the IPv4 or IPv6 +.Xr udp 4 +protocol. +.Pp +When called on a datagram socket BIO object, +.Xr BIO_method_type 3 +returns the constant +.Dv BIO_TYPE_DGRAM +and +.Xr BIO_method_name 3 +returns a pointer to the static string +.Qq datagram socket . +.Ss Constructors and destructors +.Xr BIO_new 3 +allocates a new datagram socket BIO object and initializes all its data +to zero, including the datagram socket file descriptor, the peer address, +the init flag that can be retrieved with +.Xr BIO_get_init 3 , +the connected flag, the MTU, and all timeout and error information. +The reference count and the close flag are set to 1. +.Pp +.Fn BIO_new_dgram +allocates and initializes a new datagram socket BIO object with +.Xr BIO_new 3 , +sets the datagram socket file descriptor and the close flag +according to its arguments, and sets the init flag to 1. +.Pp +If the reference count reaches 0 in +.Xr BIO_free 3 +and the close and init flags are set, +.Xr shutdown 2 +and +.Xr close 2 +are called on the datagram socket file descriptor before freeing the +storage used by the BIO object. +.Pp +When a chain containing a datagram socket BIO is copied with +.Xr BIO_dup_chain 3 , +the datagram socket file descriptor, the init flag, the close flag, +the flags accessible with +.Xr BIO_test_flags 3 , +and any data that was set with +.Xr BIO_set_ex_data 3 +are automatically copied from the original BIO object to the new one, +but the peer address, the connected flag, the MTU and all timeout and +error information are not copied but instead initialized to zero. +.Ss Initialization and configuration +If the close flag is set in +.Fa b , +.Xr BIO_set_fd 3 +clears all flags that are set in +.Fa b +and if the init flag was set, it calls +.Xr shutdown 2 +and +.Xr close 2 +on the previously assigned file descriptor. +In any case, +.Xr BIO_set_fd 3 +then sets the new file descriptor and the new close flag according to +its arguments and sets the init flag to 1. +.Pp +If the init flag is set in +.Fa b , +.Xr BIO_get_fd 3 +returns its datagram socket file descriptor, and unless the +.Fa c +argument is a +.Dv NULL +pointer, it also stores the file descriptor in +.Pf * Fa c . +If the init flag is not set, +.Xr BIO_get_fd 3 +fails and returns \-1. +.Pp +.Xr BIO_set_close 3 +sets the close flag in +.Fa b +to the +.Fa flag +argument. +.Xr BIO_get_close 3 +returns the value of the close flag from +.Fa b . +.Pp +For datagram socket BIO objects, +the shutdown flag is the same flag as the close flag. +Consequently, +.Xr BIO_set_shutdown 3 +has the same effect as +.Xr BIO_set_close 3 +and +.Xr BIO_get_shutdown 3 +has the same effect as +.Xr BIO_get_close 3 . +.Pp +.Fn BIO_dgram_set_peer +copies +.Fa sa +as the peer address into +.Fa b . +.Pp +.Fn BIO_ctrl_dgram_connect +does exactly the same as +.Fn BIO_dgram_set_peer . +Its name is even more misleading than the name of +.Fn BIO_ctrl_set_connected . +In addition to what is said there, +.Fn BIO_ctrl_dgram_connect +does not even set the connected flag in +.Fa b . +.Pp +.Fn BIO_dgram_get_peer +copies the peer address from +.Fa b +to +.Pf * Fa sa . +Before calling this function, the caller has to make sure +that the peer address is indeed set in +.Fa b +and that sufficient memory is available starting at +.Fa sa +to copy a complete +.Vt struct sockaddr , +.Vt struct sockaddr_in , +or +.Vt struct sockaddr_in6 +to that place, depending on which address family +.Fa b +is currently used for. +.Pp +Unless +.Fa sa +is +.Dv NULL , +.Fn BIO_ctrl_set_connected +sets the connected flag in +.Fa b +and copies +.Fa sa +as the peer address into +.Fa b . +If +.Fa sa +is +.Dv NULL , +.Fn BIO_ctrl_set_connected +clears the connected flag and the peer address in +.Fa b . +Considering that communication using a datagram protocol is connectionless, +the name of this function is misleading. +It is neither establishing or terminating a connection nor changing +anything with respect to the state of the datagram socket, but merely +modifying some purely informational data in the wrapping BIO object. +The additional +.Fa argl +argument is passed through to the callbacks documented in +.Xr BIO_set_callback 3 +if any such callbacks are installed, but it is otherwise ignored. +.Pp +.Xr BIO_ctrl 3 +with a +.Fa cmd +of +.Dv BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT +interprets the +.Fa parg +argument as a pointer to a +.Vt struct timeval +and sets the read timeout to the specified absolute UTC time. +.Pp +.Xr BIO_ctrl 3 +with a +.Fa cmd +of +.Dv BIO_CTRL_DGRAM_SET_RECV_TIMEOUT , +.Dv BIO_CTRL_DGRAM_GET_RECV_TIMEOUT , +.Dv BIO_CTRL_DGRAM_SET_SEND_TIMEOUT , +or +.Dv BIO_CTRL_DGRAM_GET_SEND_TIMEOUT +interprets the +.Fa parg +argument as a pointer to a +.Vt struct timeval +and calls +.Xr setsockopt 2 +or +.Xr getsockopt 2 +on the datagram socket file descriptor of +.Fa b +with an argument of +.Dv SO_RCVTIMEO +or +.Dv SO_SNDTIMEO , +respectively. +.Dv BIO_CTRL_DGRAM_SET_RECV_TIMEOUT +and +.Dv BIO_CTRL_DGRAM_SET_SEND_TIMEOUT +return 1 on success, +.Dv BIO_CTRL_DGRAM_GET_RECV_TIMEOUT +and +.Dv BIO_CTRL_DGRAM_GET_SEND_TIMEOUT +the number of bytes written to +.Pf * Fa parg . +All four return \-1 on failure. +Remember that +.Xr BIO_read 3 +may actually use a shorter timeout when +.Dv BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT +is in effect. +.Pp +.Xr BIO_ctrl 3 +with a +.Fa cmd +of +.Dv BIO_CTRL_DGRAM_GET_FALLBACK_MTU +returns 1232 if the peer address is an IPv6 address that is not IPv4 mapped +or 548 otherwise. +Making sure that a peer address is set before issuing this command +is the responsibility of the caller. +.Pp +.Xr BIO_ctrl 3 +with a +.Fa cmd +of +.Dv BIO_CTRL_DGRAM_SET_MTU +sets the MTU attribute of +.Fa b +to the value of the +.Fa larg +argument and also returns that argument. +.Xr BIO_ctrl 3 +with a +.Fa cmd +of +.Dv BIO_CTRL_DGRAM_GET_MTU +returns the MTU attribute of +.Fa b +or 0 if it was not set. +.Pp +.Xr BIO_ctrl 3 +with a +.Fa cmd +of +.Dv BIO_CTRL_DGRAM_MTU_EXCEEDED +returns 1 if the most recent non-fatal failure of +.Xr BIO_read 3 +or +.Xr BIO_write 3 +was caused by +.Er EMSGSIZE +or 0 otherwise. +This command also clears the +.Xr errno 2 +value that was saved internally for this particular purpose, so that +issuing the same command again will return 0 until the next +.Er EMSGSIZE +failure occurs. +.Pp +.Fn BIO_dgram_recv_timedout +and +.Fn BIO_dgram_send_timedout +check whether the most recent non-fatal failure of +.Xr BIO_read 3 +or +.Xr BIO_write 3 +was caused by +.Er EAGAIN . +Despite having different names, both functions do exactly the same, +and both inspect the most recent non-fatal I/O failure, no matter +whether it occurred during a receive or send operation. +Both functions also clear the +.Xr errno 2 +value that was saved internally for this particular purpose, +so that calling these functions again will return 0 until the next +.Er EAGAIN +failure occurs. +.Pp +Datagram socket BIOs do not support +.Xr BIO_eof 3 , +.Xr BIO_get_mem_data 3 , +.Xr BIO_pending 3 , +.Xr BIO_reset 3 , +.Xr BIO_seek 3 , +.Xr BIO_tell 3 , +and +.Xr BIO_wpending 3 , +and attempting any such operation results in failure +and returns a value of 0. +.Pp +Control commands correspond to accessor functions as follows: +.Pp +.Bl -tag -width BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP -compact +.It Dv BIO_C_GET_FD +.Xr BIO_get_fd 3 +.It Dv BIO_C_SET_FD +.Xr BIO_set_fd 3 +.It Dv BIO_CTRL_DGRAM_CONNECT +.Fn BIO_ctrl_dgram_connect Pq deprecated +.It Dv BIO_CTRL_DGRAM_GET_PEER +.Fn BIO_dgram_get_peer +.It BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP +.Fn BIO_dgram_recv_timedout +.It BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP +.Fn BIO_dgram_send_timedout +.It Dv BIO_CTRL_DGRAM_SET_CONNECTED +.Fn BIO_ctrl_set_connected +.It Dv BIO_CTRL_DGRAM_SET_PEER +.Fn BIO_dgram_set_peer +.It Dv BIO_CTRL_GET_CLOSE +.Xr BIO_get_close 3 +.It Dv BIO_CTRL_SET_CLOSE +.Xr BIO_set_close 3 +.El +.\" OpenBSD does not appear to support +.\" BIO_CTRL_DGRAM_MTU_DISCOVER and BIO_CTRL_DGRAM_QUERY_MTU. +.Ss Input and output operations +.Xr BIO_read 3 +attempts to read up to +.Fa len +bytes into +.Fa buf +from the datagram socket file descriptor using +.Xr recvfrom 2 . +If a read timeout is set, +.Xr setsockopt 2 +is used with an argument of +.Dv SO_RCVTIMEO +to temporarily shorten the timeout on the datagram socket during the +.Xr recvfrom 2 +call such that it returns before the read timeout expires. +.Pp +If +.Xr recvfrom 2 +succeeds and the connected flag is not yet set, +.Xr BIO_read 3 +also copies the peer address received from +.Xr recvfrom 2 +into +.Fa b . +.Pp +If +.Xr recvfrom 2 +is attempted, +.Xr BIO_read 3 +clears the flags +.Dv BIO_FLAGS_WRITE +and +.Dv BIO_FLAGS_IO_SPECIAL +in +.Fa b +and clears or sets the flags +.Dv BIO_FLAGS_READ +and +.Dv BIO_FLAGS_SHOULD_RETRY +as appropriate. +.Pp +If the connected flag is set in +.Fa b , +.Xr BIO_write 3 +attempts to +.Xr write 2 +.Fa len +bytes from +.Fa buf +to the datagram socket file descriptor. +If the connected flag is not set, it attempts to transmit +.Fa len +bytes from +.Fa buf +to the peer using +.Xr sendto 2 . +.Pp +If +.Xr write 2 +or +.Xr sendto 2 +is attempted, +.Xr BIO_write 3 +clears the flags +.Dv BIO_FLAGS_READ +and +.Dv BIO_FLAGS_IO_SPECIAL +in +.Fa b +and clears or sets the flags +.Dv BIO_FLAGS_WRITE +and +.Dv BIO_FLAGS_SHOULD_RETRY +as appropriate. +.Pp +The effect of +.Xr BIO_puts 3 +is similar to the effect of +.Xr BIO_write 3 +with a +.Fa len +argument of +.Fn strlen string . +.Pp +Datagram socket BIOs do not support +.Xr BIO_gets 3 . +Calling this function fails and returns \-2. +.Pp +.Xr BIO_flush 3 +has no effect on a datagram socket BIO. +It always succeeds and returns 1. +.Sh RETURN VALUES +.Fn BIO_s_datagram +returns the datagram socket BIO method. +.Pp +.Fn BIO_new_dgram +returns a newly allocated datagram socket BIO object or +.Dv NULL +on failure. +.Pp +.Fn BIO_dgram_set_peer , +.Fn BIO_ctrl_dgram_connect , +and +.Fn BIO_ctrl_set_connected +return 1 on success or a value less than or equal to zero on failure. +They can only fail if +.Fa b +is not a datagram socket BIO object. +.Pp +.Fn BIO_dgram_get_peer +returns the number of bytes copied to +.Fa sa +or a value less than or equal to zero on failure. +It can only fail if +.Fa b +is not a datagram socket BIO object. +.Pp +.Fn BIO_dgram_recv_timedout +and +.Fn BIO_dgram_send_timedout +return 1 if the most recent non-fatal I/O error was caused by +.Er EAGAIN +or 0 otherwise. +.Pp +.Fn BIO_dgram_non_fatal_error +returns 1 if +.Fa errnum +is +.Er EAGAIN , +.Er EALREADY , +.Er EINPROGRESS , +or +.Er EINTR +or 0 otherwise, even if +.Fa errnum +is 0. +.Sh SEE ALSO +.Xr close 2 , +.Xr getsockopt 2 , +.Xr recvfrom 2 , +.Xr sendto 2 , +.Xr shutdown 2 , +.Xr BIO_ctrl 3 , +.Xr BIO_get_init 3 , +.Xr BIO_new 3 , +.Xr BIO_read 3 , +.Xr BIO_s_connect 3 , +.Xr BIO_set_fd 3 , +.Xr BIO_should_retry 3 , +.Xr udp 4 +.Sh HISTORY +.Fn BIO_s_datagram , +.Fn BIO_new_dgram , +.Fn BIO_dgram_set_peer , +.Fn BIO_ctrl_dgram_connect , +.Fn BIO_ctrl_set_connected , +.Fn BIO_dgram_recv_timedout , +.Fn BIO_dgram_send_timedout , +and +.Fn BIO_dgram_non_fatal_error +first appeared in OpenSSL 0.9.8 and have been available since +.Ox 4.5 . +.Pp +.Fn BIO_dgram_get_peer +first appeared in OpenSSL 0.9.8m and has been available since +.Ox 4.9 . +.Sh BUGS +If +.Xr getsockopt 2 +or +.Xr setsockopt 2 +fails during +.Xr BIO_read 3 , +the library prints an error message to standard error output +but otherwise ignores the problem, thus possibly using unintended +timeout values. +.Pp +.Xr BIO_read 3 +and +.Xr BIO_write 3 +may clear the global variable +.Xr errno 2 +before attempting the +.Xr recvfrom 2 +or +.Xr sendto 2 +system call but may not clear it if they fail before reaching this point. diff --git a/man/BIO_s_fd.3 b/man/BIO_s_fd.3 index 5ac33e77..a22ba5d6 100644 --- a/man/BIO_s_fd.3 +++ b/man/BIO_s_fd.3 @@ -1,7 +1,24 @@ -.\" $OpenBSD: BIO_s_fd.3,v 1.9 2018/05/01 17:05:05 schwarze Exp $ -.\" OpenSSL 9b86974e Aug 17 15:21:33 2015 -0400 +.\" $OpenBSD: BIO_s_fd.3,v 1.10 2022/12/20 14:55:45 schwarze Exp $ +.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" -.\" This file was written by Dr. Stephen Henson . +.\" This file is a derived work. +.\" The changes are covered by the following Copyright and license: +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" The original file was written by Dr. Stephen Henson . .\" Copyright (c) 2000 The OpenSSL Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -48,14 +65,16 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: May 1 2018 $ +.Dd $Mdocdate: December 20 2022 $ .Dt BIO_S_FD 3 .Os .Sh NAME .Nm BIO_s_fd , .Nm BIO_set_fd , .Nm BIO_get_fd , -.Nm BIO_new_fd +.Nm BIO_new_fd , +.Nm BIO_fd_non_fatal_error , +.Nm BIO_fd_should_retry .Nd file descriptor BIO .Sh SYNOPSIS .In openssl/bio.h @@ -79,6 +98,10 @@ .Fa "int fd" .Fa "int close_flag" .Fc +.Ft int +.Fn BIO_fd_non_fatal_error "int errnum" +.Ft int +.Fn BIO_fd_should_retry "int retval" .Sh DESCRIPTION .Fn BIO_s_fd returns the file descriptor BIO method. @@ -140,6 +163,25 @@ returns a file descriptor BIO using and .Fa close_flag . .Pp +.Fn BIO_fd_non_fatal_error +determines whether the error status code +.Fa errnum +represents a recoverable error. +.Fn BIO_fd_should_retry +determines whether a recoverable error occurred by inspecting both +.Xr errno 2 +and +.Fa retval , +which is supposed to usually be +the return value of a previously called function like +.Xr BIO_read 3 +or +.Xr BIO_write 3 . +These two functions are mostly used internally; in application code, +it is usually easier and more robust to use +.Xr BIO_should_retry 3 , +which works for any BIO type. +.Pp The behaviour of .Xr BIO_read 3 and @@ -181,6 +223,27 @@ returns the newly allocated or .Dv NULL if an error occurred. +.Pp +.Fn BIO_fd_non_fatal_error +returns 1 if +.Fa errnum +is +.Dv EAGAIN , +.Dv EALREADY , +.Dv EINPROGRESS , +.Dv EINTR , +or +.Dv ENOTCONN +and 0 otherwise, even if +.Fa errnum +is 0. +.Pp +.Fn BIO_fd_should_retry +returns 1 if +.Fn BIO_fd_non_fatal_error errno +is 1 and +.Fa retval +is either 0 or \-1, or 0 otherwise. .Sh EXAMPLES This is a file descriptor BIO version of "Hello World": .Bd -literal -offset indent @@ -193,14 +256,19 @@ BIO_free(out); .Xr BIO_new 3 , .Xr BIO_read 3 , .Xr BIO_s_socket 3 , -.Xr BIO_seek 3 +.Xr BIO_seek 3 , +.Xr BIO_should_retry 3 .Sh HISTORY .Fn BIO_s_fd , .Fn BIO_set_fd , and .Fn BIO_get_fd -first appeared in SSLeay 0.6.0. +first appeared in SSLeay 0.6.0, +.Fn BIO_fd_should_retry +in SSLeay 0.6.5, and .Fn BIO_new_fd -first appeared in SSLeay 0.8.0. +and +.Fn BIO_fd_non_fatal_error +in SSLeay 0.8.0. All these functions have been available since .Ox 2.4 . diff --git a/man/BIO_s_mem.3 b/man/BIO_s_mem.3 index f2522a80..43763213 100644 --- a/man/BIO_s_mem.3 +++ b/man/BIO_s_mem.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BIO_s_mem.3,v 1.15 2022/02/19 16:00:14 jsing Exp $ +.\" $OpenBSD: BIO_s_mem.3,v 1.16 2022/12/18 22:27:10 schwarze Exp $ .\" full merge up to: OpenSSL 8711efb4 Mon Apr 20 11:33:12 2009 +0000 .\" selective merge up to: OpenSSL 36359cec Mar 7 14:37:23 2018 +0100 .\" @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: February 19 2022 $ +.Dd $Mdocdate: December 18 2022 $ .Dt BIO_S_MEM 3 .Os .Sh NAME @@ -104,6 +104,10 @@ structure which is extended as appropriate to accommodate the stored data. Any data written to a memory BIO can be recalled by reading from it. Unless the memory BIO is read only, any data read from it is deleted from the BIO. +To find out whether a memory BIO is read only, +.Xr BIO_test_flags 3 +can be called with an argument of +.Dv BIO_FLAGS_MEM_RDONLY . .Pp Memory BIOs support .Xr BIO_gets 3 @@ -262,6 +266,17 @@ first appeared in SSLeay 0.9.1 and have been available since .Fn BIO_new_mem_buf first appeared in OpenSSL 0.9.5 and has been available since .Ox 2.7 . +.Sh CAVEATS +Do not manually switch a writable memory BIO to read-only mode: calling +.Xr BIO_set_flags 3 +with an argument of +.Dv BIO_FLAGS_MEM_RDONLY +will ultimately result in a memory leak when the BIO object is +finally handed to +.Xr BIO_free 3 . +It might also cause security issues because it prevents +.Xr BIO_reset 3 +from clearing the data. .Sh BUGS There should be an option to set the maximum size of a memory BIO. .Pp diff --git a/man/BIO_s_null.3 b/man/BIO_s_null.3 index c991bd73..260d2799 100644 --- a/man/BIO_s_null.3 +++ b/man/BIO_s_null.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: BIO_s_null.3,v 1.8 2018/05/01 17:05:05 schwarze Exp $ -.\" OpenSSL e117a890 Sep 14 12:14:41 2000 +0000 +.\" $OpenBSD: BIO_s_null.3,v 1.9 2022/12/22 16:38:45 schwarze Exp $ +.\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 .\" .\" This file was written by Dr. Stephen Henson . .\" Copyright (c) 2000 The OpenSSL Project. All rights reserved. @@ -48,11 +48,12 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: May 1 2018 $ +.Dd $Mdocdate: December 22 2022 $ .Dt BIO_S_NULL 3 .Os .Sh NAME .Nm BIO_s_null +.\" .Nm BIO_s_log is intentionally undocumented because it is unused .Nd null data sink .Sh SYNOPSIS .In openssl/bio.h diff --git a/man/BIO_set_callback.3 b/man/BIO_set_callback.3 index 34b7c07a..248cdb51 100644 --- a/man/BIO_set_callback.3 +++ b/man/BIO_set_callback.3 @@ -1,11 +1,10 @@ -.\" $OpenBSD: BIO_set_callback.3,v 1.9 2018/03/29 20:42:17 schwarze Exp $ -.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 -.\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 +.\" $OpenBSD: BIO_set_callback.3,v 1.10 2022/12/16 23:56:57 schwarze Exp $ +.\" full merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 .\" .\" This file is a derived work. .\" The changes are covered by the following Copyright and license: .\" -.\" Copyright (c) 2018 Ingo Schwarze +.\" Copyright (c) 2018, 2022 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -66,10 +65,14 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 29 2018 $ +.Dd $Mdocdate: December 16 2022 $ .Dt BIO_SET_CALLBACK 3 .Os .Sh NAME +.Nm BIO_callback_fn_ex , +.Nm BIO_set_callback_ex , +.Nm BIO_get_callback_ex , +.Nm BIO_callback_fn , .Nm BIO_set_callback , .Nm BIO_get_callback , .Nm BIO_set_callback_arg , @@ -78,6 +81,35 @@ .Nd BIO callback functions .Sh SYNOPSIS .In openssl/bio.h +.Ft typedef long +.Fo (*BIO_callback_fn_ex) +.Fa "BIO *b" +.Fa "int oper" +.Fa "const char *argp" +.Fa "size_t len" +.Fa "int argi" +.Fa "long argl" +.Fa "int ret" +.Fa "size_t *processed" +.Fc +.Ft void +.Fo BIO_set_callback_ex +.Fa "BIO *b" +.Fa "BIO_callback_fn_ex cb_ex" +.Fc +.Ft BIO_callback_fn_ex +.Fo BIO_get_callback_ex +.Fa "const BIO *b" +.Fc +.Ft typedef long +.Fo (*BIO_callback_fn) +.Fa "BIO *b" +.Fa "int oper" +.Fa "const char *argp" +.Fa "int argi" +.Fa "long argl" +.Fa "long ret" +.Fc .Ft void .Fo BIO_set_callback .Fa "BIO *b" @@ -90,7 +122,7 @@ .Ft void .Fo BIO_set_callback_arg .Fa "BIO *b" -.Fa "char *arg" +.Fa "char *pointer" .Fc .Ft char * .Fo BIO_get_callback_arg @@ -105,60 +137,75 @@ .Fa "long argl" .Fa "long ret" .Fc -.Ft typedef long -.Fo "(*BIO_callback_fn)" -.Fa "BIO *b" -.Fa "int oper" -.Fa "const char *argp" -.Fa "int argi" -.Fa "long argl" -.Fa "long ret" -.Fc .Sh DESCRIPTION -.Fn BIO_set_callback +.Fn BIO_set_callback_ex and -.Fn BIO_get_callback +.Fn BIO_get_callback_ex set and retrieve the BIO callback. -The callback is called during most high level BIO operations. +The callback is called during most high-level BIO operations. It can be used for debugging purposes to trace operations on a BIO or to modify its operation. .Pp +.Fn BIO_set_callback +and +.Fn BIO_get_callback +are deprecated functions that set and retrieve the old-style BIO callback, +which is only used if no new-style callback is set with +.Fn BIO_set_callback_ex . +.Pp .Fn BIO_set_callback_arg +stores the +.Fa pointer +internally in +.Fa b and .Fn BIO_get_callback_arg -set and retrieve an argument for use in the callback. +retrieves it from +.Fa b . +The name of these two functions is badly misleading: the +.Fa pointer +is never passed as an argument to any callback function. +But of course, callback functions can call +.Fn BIO_get_callback_arg +and access the pointer, just like any other code can. .Pp .Fn BIO_debug_callback is a standard debugging callback which prints -out information relating to each BIO operation. -If the callback argument is set, it is interpreted as a BIO -to send the information to, otherwise stderr is used. -.Pp -.Fn BIO_callback_fn -is the type of the callback function. -The meaning of each argument is described below. -.Pp -The BIO the callback is attached to is passed in -.Fa b . +out information related to each BIO operation. +If +.Fn BIO_set_callback_arg +was called with a +.Pf non- Dv NULL +argument, information is sent to the BIO pointed to by the +.Fa pointer ; +otherwise, standard error output is used. .Pp -.Fa oper -is set to the operation being performed. -For some operations the callback is called twice, +The arguments of the callback functions are as follows: +.Bl -tag -width Ds +.It Fa b +The BIO the callback is attached to. +.It Fa oper +The operation being performed. +For some operations, the callback is called twice, once before and once after the actual operation. The latter case has .Fa oper -or'ed with +OR'ed with .Dv BIO_CB_RETURN . -.Pp -The meaning of the arguments -.Fa argp , -.Fa argi -and -.Fa argl -depends on the value of +.It Fa argp , argi , argl +The meaning of these three arguments depends on the value of +.Fa oper , +that is on the operation being performed. +.It Fa len +The length of the data requested to be read or written. +This is only useful if .Fa oper -(i.e. the operation being performed). -.Pp +is +.Dv BIO_CB_READ , +.Dv BIO_CB_WRITE , +or +.Dv BIO_CB_GETS . +.It Fa ret When .Fa oper does not include @@ -185,43 +232,101 @@ if no callback were present. When a callback is present, the operation only passes this value to the callback and instead of it returns the return value of the callback to the application. +.It Fa processed +The location pointed to is updated with the number of bytes +actually read or written. +Only used for +.Dv BIO_CB_READ , +.Dv BIO_CB_WRITE , +.Dv BIO_CB_GETS , +and +.Dv BIO_CB_PUTS . +.El .Pp The callback should normally simply return .Fa ret when it has finished processing, unless it specifically wishes to abort the operation or to modify the value returned to the application. -.Ss Callback operations -.Bl -tag -width Ds -.It Fn BIO_free b -.Fn callback b BIO_CB_FREE NULL 0L 0L 1L -is called before the free operation. -.It Fn BIO_read b out outl -.Fn callback b BIO_CB_READ out outl 0L 1L -is called before the read and -.Fn callback b BIO_CB_READ|BIO_CB_RETURN out outl 0L ret -after. -.It Fn BIO_write b in inl -.Fn callback b BIO_CB_WRITE in inl 0L 1L -is called before the write and -.Fn callback b BIO_CB_WRITE|BIO_CB_RETURN in inl 0L ret -after. -.It Fn BIO_gets b out outl -.Fn callback b BIO_CB_GETS out outl 0L 1L -is called before the operation and -.Fn callback b BIO_CB_GETS|BIO_CB_RETURN out outl 0L ret -after. -.It Fn BIO_puts b in -.Fn callback b BIO_CB_PUTS in 0 0L 1L -is called before the operation and -.Fn callback b BIO_CB_PUTS|BIO_CB_RETURN in 0 0L ret -after. -.It Fn BIO_ctrl b oper larg parg -.Fn callback b BIO_CB_CTRL parg oper larg 1L -is called before the call and -.Fn callback b BIO_CB_CTRL|BIO_CB_RETURN parg oper larg ret -after. +.Pp +The callbacks are called as follows: +.Bl -tag -width 1n +.It \&In Fn BIO_free "BIO *b" : +.Bd -literal +before the free operation: +cb_ex(b, BIO_CB_FREE, NULL, 0, 0, 0, 1, NULL) +or cb(b, BIO_CB_FREE, NULL, 0, 0, 1) +.Ed +.It \&In Fn BIO_read "BIO *b" "void *out" "int outl" : +.Bd -literal +before the read operation: +cb_ex(b, BIO_CB_READ, out, outl, 0, 0, 1, NULL) +or cb(b, BIO_CB_READ, out, outl, 0, 1) + +after the read operation: +cb_ex(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0, 0, ret, &bytes) +or cb(b, BIO_CB_READ|BIO_CB_RETURN, out, outl, 0, ret) +.Ed +.It \&In Fn BIO_write "BIO *b" "const void *in" "int inl" : +.Bd -literal +before the write operation: +cb_ex(b, BIO_CB_WRITE, in, inl, 0, 0, 1, NULL) +or cb(b, BIO_CB_WRITE, in, inl, 0, 1) + +after the write operation: +cb_ex(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0, 0, ret, &bytes) +or cb(b, BIO_CB_WRITE|BIO_CB_RETURN, in, inl, 0, ret) +.Ed +.It \&In Fn BIO_gets "BIO *b" "char *out" "int outl" : +.Bd -literal +before the read operation: +cb_ex(b, BIO_CB_GETS, out, outl, 0, 0, 1, NULL) +or cb(b, BIO_CB_GETS, out, outl, 0, 1) + +after the read operation: +cb_ex(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0, 0, ret, &bytes) +or cb(b, BIO_CB_GETS|BIO_CB_RETURN, out, outl, 0, ret) +.Ed +.It \&In Fn BIO_puts "BIO *b" "const char *in" : +.Bd -literal +before the write operation: +cb_ex(b, BIO_CB_PUTS, in, 0, 0, 0, 1, NULL) +or cb(b, BIO_CB_PUTS, in, 0, 0, 1) + +after the write operation: +cb_ex(b, BIO_CB_PUTS|BIO_CB_RETURN, in, 0, 0, 0, ret, &bytes) +or cb(b, BIO_CB_PUTS|BIO_CB_RETURN, in, 0, 0, ret) +.Ed +.It \&In Fn BIO_ctrl "BIO *b" "int cmd" "long larg" "void *parg" : +.Bd -literal +before the control operation: +cb_ex(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1, NULL) +or cb(b, BIO_CB_CTRL, parg, cmd, larg, 1) + +after the control operation: +cb_ex(b, BIO_CB_CTRL|BIO_CB_RETURN, parg, 0, cmd, larg, ret, NULL) +or cb(b, BIO_CB_CTRL|BIO_CB_RETURN, parg, cmd, larg, ret) +.Ed +.It \&In Fn BIO_callback_ctrl "BIO *b" "int cmd" "BIO_info_cb *fp" : +.Bd -literal +before the control operation: +cb_ex(b, BIO_CB_CTRL, fp, 0, cmd, 0, 1, NULL) +or cb(b, BIO_CB_CTRL, fp, cmd, 0, 1) + +after the control operation: +cb_ex(b, BIO_CB_CTRL|BIO_CB_RETURN, fp, 0, cmd, 0, ret, NULL) +or cb(b, BIO_CB_CTRL|BIO_CB_RETURN, fp, cmd, 0, ret) +.Ed .El .Sh RETURN VALUES +.Fn BIO_get_callback_ex +returns a pointer to the function +.Fa cb_ex +previously installed with +.Fn BIO_set_callback_cb , +or +.Dv NULL +if no such callback was installed. +.Pp .Fn BIO_get_callback returns a pointer to the function .Fa cb @@ -229,16 +334,16 @@ previously installed with .Fn BIO_set_callback , or .Dv NULL -if no callback was installed. +if no such callback was installed. .Pp .Fn BIO_get_callback_arg -returns a pointer to the -.Fa arg +returns the +.Fa pointer previously set with .Fn BIO_set_callback_arg , or .Dv NULL -if no such argument was set. +if no such pointer was set. .Pp .Fn BIO_debug_callback returns @@ -265,5 +370,15 @@ and first appeared in SSLeay 0.6.0. .Fn BIO_get_callback_arg first appeared in SSLeay 0.8.0. -All these functions have been available since +These functions have been available since .Ox 2.4 . +.Pp +.Fn BIO_callback_fn +first appeared in OpenSSL 1.1.0. +.Fn BIO_callback_fn_ex , +.Fn BIO_set_callback_ex , +and +.Fn BIO_get_callback_ex +first appeared in OpenSSL 1.1.1. +These functions have been available since +.Ox 7.1 . diff --git a/man/BIO_should_retry.3 b/man/BIO_should_retry.3 index 43b19b89..4d7a214d 100644 --- a/man/BIO_should_retry.3 +++ b/man/BIO_should_retry.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: BIO_should_retry.3,v 1.9 2018/12/19 21:12:58 schwarze Exp $ -.\" full merge up to: OpenSSL 60e24554 Apr 6 14:45:18 2010 +0000 +.\" $OpenBSD: BIO_should_retry.3,v 1.10 2022/11/27 19:11:11 schwarze Exp $ +.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" selective merge up to: OpenSSL 57fd5170 May 13 11:24:11 2018 +0200 .\" .\" This file was written by Dr. Stephen Henson . @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: December 19 2018 $ +.Dd $Mdocdate: November 27 2022 $ .Dt BIO_SHOULD_RETRY 3 .Os .Sh NAME @@ -59,7 +59,8 @@ .Nm BIO_retry_type , .Nm BIO_should_retry , .Nm BIO_get_retry_BIO , -.Nm BIO_get_retry_reason +.Nm BIO_get_retry_reason , +.Nm BIO_set_retry_reason .Nd BIO retry functions .Sh SYNOPSIS .In openssl/bio.h @@ -98,6 +99,11 @@ .Fo BIO_get_retry_reason .Fa "BIO *bio" .Fc +.Ft void +.Fo BIO_set_retry_reason +.Fa "BIO *bio" +.Fa "int reason" +.Fc .Sh DESCRIPTION These functions determine why a BIO is not able to read or write data. They will typically be called after a failed @@ -147,6 +153,12 @@ returns the reason for a special condition if passed the relevant BIO, for example as returned by .Fn BIO_get_retry_BIO . .Pp +.Fn BIO_set_retry_reason +sets the retry reason for a special condition for the given +.Fa bio . +It is intended to be called by functions implementing a BIO type +rather than by functions merely using BIOs. +.Pp .Fn BIO_should_retry , .Fn BIO_should_read , .Fn BIO_should_write , @@ -229,6 +241,10 @@ and first appeared in SSLeay 0.8.0. All these functions have been available since .Ox 2.4 . +.Pp +.Fn BIO_set_retry_reason +first appeared in OpenSSL 1.1.0 and has been available since +.Ox 7.1 . .Sh BUGS The OpenSSL ASN.1 functions cannot gracefully deal with non-blocking I/O: they cannot retry after a partial read or write. diff --git a/man/BN_GF2m_add.3 b/man/BN_GF2m_add.3 new file mode 100644 index 00000000..5b143cb4 --- /dev/null +++ b/man/BN_GF2m_add.3 @@ -0,0 +1,514 @@ +.\" $OpenBSD: BN_GF2m_add.3,v 1.5 2022/12/06 02:12:05 jsg Exp $ +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: December 6 2022 $ +.Dt BN_GF2M_ADD 3 +.Os +.Sh NAME +.Nm BN_GF2m_add , +.Nm BN_GF2m_sub , +.Nm BN_GF2m_cmp , +.Nm BN_GF2m_mod_arr , +.Nm BN_GF2m_mod , +.Nm BN_GF2m_mod_mul_arr , +.Nm BN_GF2m_mod_mul , +.Nm BN_GF2m_mod_sqr_arr , +.Nm BN_GF2m_mod_sqr , +.Nm BN_GF2m_mod_inv , +.Nm BN_GF2m_mod_inv_arr , +.Nm BN_GF2m_mod_div , +.Nm BN_GF2m_mod_div_arr , +.Nm BN_GF2m_mod_exp_arr , +.Nm BN_GF2m_mod_exp , +.Nm BN_GF2m_mod_sqrt_arr , +.Nm BN_GF2m_mod_sqrt , +.Nm BN_GF2m_mod_solve_quad_arr , +.Nm BN_GF2m_mod_solve_quad , +.Nm BN_GF2m_poly2arr , +.Nm BN_GF2m_arr2poly +.Nd arithmetic in Galois fields of power-of-2 order +.Sh SYNOPSIS +.In openssl/bn.h +.Ft int +.Fo BN_GF2m_add +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *b" +.Fc +.Ft int +.Fo BN_GF2m_sub +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *b" +.Fc +.Ft int +.Fo BN_GF2m_cmp +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *b" +.Fc +.Ft int +.Fo BN_GF2m_mod_arr +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const int p[]" +.Fc +.Ft int +.Fo BN_GF2m_mod +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *p" +.Fc +.Ft int +.Fo BN_GF2m_mod_mul_arr +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *b" +.Fa "const int p[]" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_mul +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *b" +.Fa "const BIGNUM *p" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_sqr_arr +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const int p[]" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_sqr +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *p" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_inv +.Fa "BIGNUM *r" +.Fa "const BIGNUM *b" +.Fa "const BIGNUM *p" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_inv_arr +.Fa "BIGNUM *r" +.Fa "const BIGNUM *b" +.Fa "const int p[]" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_div +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *b" +.Fa "const BIGNUM *p" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_div_arr +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *b" +.Fa "const int p[]" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_exp_arr +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *exponent" +.Fa "const int p[]" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_exp +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *exponent" +.Fa "const BIGNUM *p" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_sqrt_arr +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const int p[]" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_sqrt +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *p" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_solve_quad_arr +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const int p[]" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_mod_solve_quad +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *p" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_GF2m_poly2arr +.Fa "const BIGNUM *poly_in" +.Fa "int arr_out[]" +.Fa "int arr_size" +.Fc +.Ft int +.Fo BN_GF2m_arr2poly +.Fa "const int arr_in[]" +.Fa "BIGNUM *poly_out" +.Fc +.Sh DESCRIPTION +Two fields containing the same, finite number of elements are isomorphic, +and the number of elements is called their order. +The unique field of a given finite order is called the Galois field +of that order. +.EQ +delim $$ +.EN +The following functions perform arithmetic operations +on $roman GF left ( 2 sup m right )$, the Galois fields of order $2 sup m$, +where $m$ is a natural number. +.Pp +The $2 sup m$ elements of $roman GF left ( 2 sup m right )$ +are usually represented by the $2 sup m$ polynomials +of a degrees less than $m$ with binary coefficients. +Such a polynomial can either be specified by storing the coefficients +in a +.Vt BIGNUM +object, using the $m$ lowest bits with bit numbers corresponding to degrees, +or by storing the degrees that have +coefficients of 1 in an integer array of at most $m + 1$ elements. +For the functions below, the array needs to be sorted in decreasing +order and terminated by the delimiter element \-1. +.Pp +A specific representation of $roman GF left ( 2 sup m right )$ +is selected by choosing a polynomial of degree $m$ that is irreducible +with binary coefficients, called the reducing polynomial. +Making sure that $p$ is of the correct degree and indeed irreducible +is the responsibility of the user. +Typically, the following functions silently produce nonsensical results +when given a +.Fa p +argument that is of the wrong degree or that is reducible. +Storing the reducing polynomial requires $m + 1$ bits in a +.Vt BIGNUM +object or an +.Vt int +array of up to $m + 2$ elements, including the terminating \-1 element. +.Pp +All functions produce correct results even if some or all of the arguments +.Fa r , +.Fa a , +and +.Fa b +point to the same object. +.Pp +.Fn BN_GF2m_add +adds the two polynomials +.Fa a +and +.Fa b +with binary coefficients, which is equivalent to a pairwise exclusive OR +operation on the coefficients, and places the result into +.Fa r . +In particular, if +.Fa a +and +.Fa b +are elements of the same representation +of the same $roman GF left ( 2 sup m right )$ field, +the sum of both in that representation of that field is computed +.Po +$r = a + b$ +.Pc . +In contrast to most of the other functions described here, no modulo +operation is performed. +Consequently, if the degree of at least one of the arguments may be larger +than or equal to $m$, a follow-up call to +.Fn BN_GF2m_mod_arr +or +.Fn BN_GF2m_mod +may occasionally be useful. +.Pp +.Fn BN_GF2m_sub +calculates the difference of +.Fa a +and +.Fa b +.Po +$r = a - b = a + b$ +.Pc . +Since \-1 is the same as 1 in binary arithmetic, +.Fn BN_GF2m_sub +does exactly the same as +.Fn BN_GF2m_add . +It is implemented as a macro. +.Pp +.Fn BN_GF2m_cmp +is an alias for +.Xr BN_ucmp 3 . +Despite its name, it does not attempt to find out whether the two +polynomials belong to the same congruence class with respect to some +Galois field. +.Pp +.Fn BN_GF2m_mod_arr +and its wrapper +.Fn BN_GF2m_mod +divide the polynomial with binary coefficients +.Fa a +by the polynomial with binary coefficients +.Fa p +and place the remainder into +.Fa r +.Po +$r = a ( roman mod p )$ +.Pc . +If +.Fa r +and +.Fa a +point to the same object, the modular reduction is done in place. +.Pp +.Fn BN_GF2m_mod_mul_arr +and its wrapper +.Fn BN_GF2m_mod_mul +multiply +.Fa a +and +.Fa b , +divide the result by +.Fa p , +and place the remainder in +.Fa r +.Po +$r = a * b ( roman mod p )$ +.Pc . +.Pp +.Fn BN_GF2m_mod_sqr_arr +and its wrapper +.Fn BN_GF2m_mod_sqr +divide the square of +.Fa a +by +.Fa p +and place the remainder in +.Fa r +.Po +$r = a * a ( roman mod p )$ +.Pc . +.Pp +.Fn BN_GF2m_mod_inv +and its wrapper +.Fn BN_GF2m_mod_inv_arr +reduce +.Fa b +modulo +.Fa p , +find the multiplicative inverse element +in $roman GF left ( 2 sup m right )$ using the reducing polynomial $p$, +and place the result into +.Fa r +.Po +$r = 1 / b ( roman mod p )$ +.Pc . +.Pp +.Fn BN_GF2m_mod_div +and its wrapper +.Fn BN_GF2m_mod_div_arr +reduce +.Fa a +and +.Fa b +modulo +.Fa p , +compute their quotient +in $roman GF left ( 2 sup m right )$ using the reducing polynomial $p$, +and place the result into +.Fa r +.Po +$r = a / b ( roman mod p )$ +.Pc . +.Pp +.Fn BN_GF2m_mod_exp_arr +and its wrapper +.Fn BN_GF2m_mod_exp +reduce +.Fa a +modulo +.Fa p , +raise it to the power of +.Fa exponent +in $roman GF left ( 2 sup m right )$ using the reducing polynomial $p$, +and place the result into +.Fa r +.Po +$r = a sup exponent ( roman mod p )$ +.Pc . +.Pp +.Fn BN_GF2m_mod_sqrt_arr +and its wrapper +.Fn BN_GF2m_mod_sqrt +reduce +.Fa a +modulo +.Fa p , +calculate the square root +in $roman GF left ( 2 sup m right )$ using the reducing polynomial $p$ +by raising it to the power of $2 sup { m - 1 }$, +and place the result into +.Fa r +.Po +$r = sqrt a ( roman mod p )$ +.Pc . +This works because of the identity $a sup {2 sup m} = a$ +which holds for all field elements $a$. +.Pp +.Fn BN_GF2m_mod_solve_quad_arr +and its wrapper +.Fn BN_GF2m_mod_solve_quad +reduce +.Fa a +modulo +.Fa p , +solve the quadratic equation $r sup 2 + r = a ( roman mod p )$ +in $roman GF left ( 2 sup m right )$ using the reducing polynomial $p$, +and place the solution into +.Fa r . +.Pp +.Fn BN_GF2m_poly2arr +converts a polynomial from a bit string stored in the +.Vt BIGNUM +object +.Fa poly_in +to an array containing the degrees of the non-zero terms. +It is the responsibility of the caller to provide an array +.Fa arr_out +of sufficient size and to provide the number of elements +that can be stored in the array as the +.Fa arr_size +argument. +The array is filled with the degrees in decreasing order, +followed by an element with the value \-1. +.Pp +.Fn BN_GF2m_arr2poly +converts a polynomial from the array +.Fa arr_in +containing degrees to a bit string placed in the +.Vt BIGNUM +object +.Ft poly_out . +It is the responsibility of the caller to provide the storage for +.Fa poly_out +and to make sure that +.Fa arr_in +is terminated with a \-1 element. +.Sh RETURN VALUES +.Fn BN_GF2m_cmp +interprets +.Fa a +and +.Fa b +as integer numbers and returns +\-1 if $left | a right | < left | b right |$, +0 if $left | a right | = left | b right |$, +or 1 if $left | a right | > left | b right |$. +.Pp +.Fn BN_GF2m_poly2arr +returns: +.Bl -bullet -compact -offset 2n -width 1n +.It +0 if +.Fa poly_in +has the value 0; +.It +a number in the range from 2 to +.Fa arr_size , +inclusive, in case of success, specifying the number of elements +that have been stored into the array; +.It +a number greater than +.Fa arr_size +if the function failed because the array was too small, +specifying the array size that would have been needed. +.El +.Pp +The other functions return 1 for success or 0 for failure. +.Sh ERRORS +After some cases of failure, the following diagnostics can be retrieved with +.Xr ERR_get_error 3 , +.Xr ERR_GET_REASON 3 , +and +.Xr ERR_reason_error_string 3 : +.Bl -tag -width Ds +.It Dv BN_R_NO_SOLUTION Qq "no solution" +No solution exists for the equation that +.Fn BN_GF2m_mod_solve_quad_arr +or +.Fn BN_GF2m_mod_solve_quad +attempted to solve. +.It Dv BN_R_INVALID_LENGTH Qq "invalid length" +In one of the functions wrapping an +.Fn *_arr +variant, the +.Fa "BIGNUM *p" +argument had a value of zero. +.El +.Sh SEE ALSO +.Xr BN_add 3 , +.Xr BN_CTX_new 3 , +.Xr BN_new 3 , +.Xr BN_set_bit 3 , +.Xr EC_POINT_new 3 +.Rs +.%A Darrel Hankerson +.%A Julio L\('opez Hernandez +.%A Alfred Menezes +.%T Software Implementation of Elliptic Curve Cryptography over Binary Fields +.%B CHES 2000: International Workshop on Cryptographic Hardware\ + and Embedded Systems +.%U https://doi.org/10.1007/3-540-44499-8_1 +.%C Worcester, MA, USA +.%D August 2000 +.%I Springer +.%J Lecture Notes in Computer Science +.%V vol 1965 +.%O Algorithm 10: Modified Almost Inverse Algorithm for inversion in FP(2\(ham) +.Re +.Rs +.%V IEEE Standard 1363 +.%B Specifications for Public-Key Cryptography +.%D August 29, 2000 +.%U https://doi.org/10.1109/IEEESTD.2000.92292 +.%O square-and-multiply algorithm A.5.1 for exponentiation,\ + exponentiation algorithm A.4.1 for square roots, and\ + algorithms A.4.7 and A.4.6 for the quadratic equation +.Re diff --git a/man/BN_add.3 b/man/BN_add.3 index ab2d3433..a06b8af3 100644 --- a/man/BN_add.3 +++ b/man/BN_add.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_add.3,v 1.16 2021/12/20 15:02:13 schwarze Exp $ +.\" $OpenBSD: BN_add.3,v 1.18 2023/01/31 05:16:52 jsing Exp $ .\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 .\" .\" This file is a derived work. @@ -66,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: December 20 2021 $ +.Dd $Mdocdate: January 31 2023 $ .Dt BN_ADD 3 .Os .Sh NAME @@ -92,11 +92,12 @@ .Nm BN_exp , .Nm BN_mod_exp , .\" The following are public, but intentionally undocumented for now: +.\" .Nm BN_mod_exp_mont , r \(== a ^ p (mod m) .\" .Nm BN_mod_exp_mont_consttime , -.\" .Nm BN_mod_exp_mont , .\" .Nm BN_mod_exp_mont_word , .\" .Nm BN_mod_exp_recp , .\" .Nm BN_mod_exp_simple , +.\" .Nm BN_mod_exp2_mont r \(== (a1 ^ p1) * (a2 ^ p2) (mod m) .\" Maybe they should be deleted from . .Nm BN_gcd .Nd arithmetic operations on BIGNUMs @@ -317,8 +318,7 @@ It requires the absolute value of .Fa a to be greater than the absolute value of .Fa b ; -otherwise, it will sometimes fail -and sometimes silently produce wrong results. +otherwise it will fail. .Fa r may be the same .Vt BIGNUM diff --git a/man/BN_add_word.3 b/man/BN_add_word.3 index 1156fe37..161029c3 100644 --- a/man/BN_add_word.3 +++ b/man/BN_add_word.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: BN_add_word.3,v 1.9 2019/06/10 14:58:48 schwarze Exp $ -.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 +.\" $OpenBSD: BN_add_word.3,v 1.10 2022/11/22 19:02:07 schwarze Exp $ +.\" full merge up to: OpenSSL 9e183d22 Mar 11 08:56:44 2017 -0500 .\" .\" This file was written by Ulf Moeller . .\" Copyright (c) 2000, 2005 The OpenSSL Project. All rights reserved. @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: June 10 2019 $ +.Dd $Mdocdate: November 22 2022 $ .Dt BN_ADD_WORD 3 .Os .Sh NAME @@ -91,6 +91,15 @@ integers. They are much more efficient than the normal BIGNUM arithmetic operations. .Pp +.Vt BN_ULONG +is a macro that expands to +.Vt unsigned long Pq = Vt uint64_t +on +.Dv _LP64 +platforms and +.Vt unsigned int Pq = Vt uint32_t +elsewhere. +.Pp .Fn BN_add_word adds .Fa w diff --git a/man/BN_cmp.3 b/man/BN_cmp.3 index 9ca73a62..ba973313 100644 --- a/man/BN_cmp.3 +++ b/man/BN_cmp.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_cmp.3,v 1.9 2021/12/18 21:11:50 schwarze Exp $ +.\" $OpenBSD: BN_cmp.3,v 1.10 2022/11/22 19:02:07 schwarze Exp $ .\" full merge up to: OpenSSL 5b31b9df Aug 4 10:45:52 2021 +0300 .\" .\" This file was written by Ulf Moeller . @@ -48,7 +48,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: December 18 2021 $ +.Dd $Mdocdate: November 22 2022 $ .Dt BN_CMP 3 .Os .Sh NAME @@ -119,6 +119,15 @@ equals .Fa w . .Fn BN_is_odd tests if a is odd. +.Pp +.Vt BN_ULONG +is a macro that expands to +.Vt unsigned long Pq = Vt uint64_t +on +.Dv _LP64 +platforms and +.Vt unsigned int Pq = Vt uint32_t +elsewhere. .Sh RETURN VALUES .Fn BN_cmp returns -1 if diff --git a/man/BN_generate_prime.3 b/man/BN_generate_prime.3 index 764ea6f8..df28d377 100644 --- a/man/BN_generate_prime.3 +++ b/man/BN_generate_prime.3 @@ -1,7 +1,24 @@ -.\" $OpenBSD: BN_generate_prime.3,v 1.19 2020/06/24 18:15:00 jmc Exp $ +.\" $OpenBSD: BN_generate_prime.3,v 1.20 2022/11/24 19:06:38 schwarze Exp $ .\" full merge up to: OpenSSL f987a4dd Jun 27 10:12:08 2019 +0200 .\" -.\" This file was written by Ulf Moeller +.\" This file is a derived work. +.\" The changes are covered by the following Copyright and license: +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" The original file was written by Ulf Moeller .\" Bodo Moeller , and Matt Caswell . .\" Copyright (c) 2000, 2003, 2013, 2014, 2018 The OpenSSL Project. .\" All rights reserved. @@ -50,54 +67,56 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: June 24 2020 $ +.Dd $Mdocdate: November 24 2022 $ .Dt BN_GENERATE_PRIME 3 .Os .Sh NAME -.Nm BN_generate_prime_ex , .Nm BN_is_prime_ex , .Nm BN_is_prime_fasttest_ex , +.Nm BN_generate_prime_ex , .Nm BN_GENCB_call , .Nm BN_GENCB_new , .Nm BN_GENCB_free , -.Nm BN_GENCB_set_old , .Nm BN_GENCB_set , .Nm BN_GENCB_get_arg , +.Nm BN_GENCB_set_old , .Nm BN_generate_prime , .Nm BN_is_prime , .Nm BN_is_prime_fasttest +.\" Nm BN_prime_checks_for_size is intentionally undocumented +.\" because it is no longer used by LibreSSL. .Nd generate primes and test for primality .Sh SYNOPSIS .In openssl/bn.h .Ft int -.Fo BN_generate_prime_ex -.Fa "BIGNUM *ret" -.Fa "int bits" -.Fa "int safe" -.Fa "const BIGNUM *add" -.Fa "const BIGNUM *rem" -.Fa "BN_GENCB *cb" -.Fc -.Ft int .Fo BN_is_prime_ex -.Fa "const BIGNUM *p" +.Fa "const BIGNUM *a" .Fa "int nchecks" .Fa "BN_CTX *ctx" .Fa "BN_GENCB *cb" .Fc .Ft int .Fo BN_is_prime_fasttest_ex -.Fa "const BIGNUM *p" +.Fa "const BIGNUM *a" .Fa "int nchecks" .Fa "BN_CTX *ctx" .Fa "int do_trial_division" .Fa "BN_GENCB *cb" .Fc .Ft int +.Fo BN_generate_prime_ex +.Fa "BIGNUM *ret" +.Fa "int bits" +.Fa "int safe" +.Fa "const BIGNUM *modulus" +.Fa "const BIGNUM *remainder" +.Fa "BN_GENCB *cb" +.Fc +.Ft int .Fo BN_GENCB_call .Fa "BN_GENCB *cb" -.Fa "int a" -.Fa "int b" +.Fa "int state_code" +.Fa "int serial_number" .Fc .Ft BN_GENCB * .Fn BN_GENCB_new void @@ -106,15 +125,9 @@ .Fa "BN_GENCB *cb" .Fc .Ft void -.Fo BN_GENCB_set_old -.Fa "BN_GENCB *gencb" -.Fa "void (*callback)(int, int, void *)" -.Fa "void *cb_arg" -.Fc -.Ft void .Fo BN_GENCB_set -.Fa "BN_GENCB *gencb" -.Fa "int (*callback)(int, int, BN_GENCB *)" +.Fa "BN_GENCB *cb" +.Fa "int (*cb_fp)(int, int, BN_GENCB *)" .Fa "void *cb_arg" .Fc .Ft void * @@ -124,21 +137,27 @@ .Pp Deprecated: .Pp +.Ft void +.Fo BN_GENCB_set_old +.Fa "BN_GENCB *cb" +.Fa "void (*cb_fp)(int, int, void *)" +.Fa "void *cb_arg" +.Fc .Ft BIGNUM * .Fo BN_generate_prime .Fa "BIGNUM *ret" .Fa "int num" .Fa "int safe" -.Fa "BIGNUM *add" -.Fa "BIGNUM *rem" -.Fa "void (*callback)(int, int, void *)" +.Fa "BIGNUM *modulus" +.Fa "BIGNUM *remainder" +.Fa "void (*cb_fp)(int, int, void *)" .Fa "void *cb_arg" .Fc .Ft int .Fo BN_is_prime .Fa "const BIGNUM *a" .Fa "int checks" -.Fa "void (*callback)(int, int, void *)" +.Fa "void (*cb_fp)(int, int, void *)" .Fa "BN_CTX *ctx" .Fa "void *cb_arg" .Fc @@ -146,22 +165,84 @@ Deprecated: .Fo BN_is_prime_fasttest .Fa "const BIGNUM *a" .Fa "int checks" -.Fa "void (*callback)(int, int, void *)" +.Fa "void (*cb_fp)(int, int, void *)" .Fa "BN_CTX *ctx" .Fa "void *cb_arg" .Fa "int do_trial_division" .Fc .Sh DESCRIPTION +.Fn BN_is_prime_ex +and +.Fn BN_is_prime_fasttest_ex +test whether the number +.Fa a +is prime. +In LibreSSL, both functions behave identically, +use the Baillie-Pomerance-Selfridge-Wagstaff algorithm, +and ignore the +.Fa checks +and +.Fa do_trial_division +arguments. +.Pp +It is unknown whether any composite number exists that the +Baillie-PSW algorithm misclassifies as a prime. +Some suspect that there may be infinitely many such numbers, +but not a single one is currently known. +It is known that no such number exists below 2\(ha64. +.Pp +If +.Dv NULL +is passed for the +.Fa ctx +argument, these function allocate a +.Vt BN_CTX +object internally when they need one and free it before returning. +Alternatively, to save the overhead of allocating and freeing +that object for each call, the caller can pre-allocate a +.Vt BN_CTX +object and pass it in the +.Fa ctx +argument. +.Pp .Fn BN_generate_prime_ex generates a pseudo-random prime number of at least bit length -.Fa bits . -The returned number is probably prime, but there is a very small -probability of returning a non-prime number. -If +.Fa bits +and places it in +.Fa ret . +Primality of .Fa ret +is tested internally using +.Fn BN_is_prime_ex . +Consequently, for +.Fa bits +larger than 64, it is theoretically possible +that this function might place a composite number into +.Fa ret ; +the probability of such an event is unknown but very small. +.Pp +The prime may have to fulfill additional requirements for use in +Diffie-Hellman key exchange: +.Bl -bullet +.It +If +.Fa modulus is not .Dv NULL , -it will be used to store the number. +a prime is generated that fulfills the condition +.Fa ret No % Fa modulus No = Fa remainder . +If the +.Fa remainder +argument is +.Dv NULL , +1 is used as the desired remainder. +.It +If the +.Fa safe +argument is non-zero, a safe prime is generated, that is, +.Po Fa ret No \- 1 Pc Ns /2 +is also prime. +.El .Pp If .Fa cb @@ -170,15 +251,18 @@ is not it is used as follows: .Bl -bullet .It -.Fn BN_GENCB_call cb 0 i -is called after generating the i-th potential prime number. +.Fn BN_GENCB_call cb 0 serial_number +is called after generating a potential prime number. .It -While the number is being tested for primality, -.Fn BN_GENCB_call cb 1 j -is called as described below. +The +.Fa state_code +of 1 is reserved for callbacks during primality testing, +but LibreSSL performs no such callbacks. .It -When a prime has been found, -.Fn BN_GENCB_call cb 2 i +When +.Fa safe +is non-zero and a safe prime has been found, +.Fn BN_GENCB_call cb 2 serial_number is called. .It The callers of @@ -189,207 +273,129 @@ with other values as described in their respective manual pages; see .Sx SEE ALSO . .El .Pp -The prime may have to fulfill additional requirements for use in -Diffie-Hellman key exchange: -.Pp -If -.Fa add -is not -.Dv NULL , -the prime will fulfill the condition p % -.Fa add -== -.Fa rem -(p % -.Fa add -== 1 if -.Fa rem -== -.Dv NULL ) -in order to suit a given generator. -.Pp -If -.Fa safe -is true, it will be a safe prime (i.e. a prime p so that (p-1)/2 -is also prime). -.Pp -.Fn BN_is_prime_ex -and -.Fn BN_is_prime_fasttest_ex -test if the number -.Fa p -is prime. -The following tests are performed until one of them shows that -.Fa p -is composite; if -.Fa p -passes all these tests, it is considered prime. +In all cases, the +.Fa serial_number +is the number of candidates that have already been discarded +for not being prime; that is, +.Fa serial_number +is 0 for the first candidate +and then incremented whenever a new candidate is generated. .Pp -.Fn BN_is_prime_fasttest_ex , -when called with -.Fa do_trial_division -== 1, first attempts trial division by a number of small primes; -if no divisors are found by this test and +.Fn BN_GENCB_call +calls the callback function held in .Fa cb -is not -.Dv NULL , -.Sy BN_GENCB_call(cb, 1, -1) -is called. -If -.Fa do_trial_division -== 0, this test is skipped. -.Pp -Both -.Fn BN_is_prime_ex -and -.Fn BN_is_prime_fasttest_ex -perform a Miller-Rabin probabilistic primality test with -.Fa nchecks -iterations. +and passes the +.Fa state_code +and the +.Fa serial_number +as arguments. If -.Fa nchecks -== -.Dv BN_prime_checks , -a number of iterations is used that yields a false positive rate -of at most 2\(ha-64 for random input. -The error rate depends on the size of the prime -and goes down for bigger primes. -The rate is 2\(ha-80 starting at 308 bits, 2\(ha-112 at 852 bits, -2\(ha-128 at 1080 bits, 2\(ha-192 at 3747 bits -and 2\(ha-256 at 6394 bits. +.Fa cb +is +.Dv NULL +or does not contain a callback function, no action occurs. .Pp -When the source of the prime is not random or not trusted, the -number of checks needs to be much higher to reach the same level -of assurance: It should equal half of the targeted security level -in bits (rounded up to the next integer if necessary). -For instance, to reach the 128-bit security level, -.Fa nchecks -should be set to 64. +.Fn BN_GENCB_new +allocates a new +.Vt BN_GENCB +object. .Pp +.Fn BN_GENCB_free +frees +.Fa cb . If .Fa cb -is not +is .Dv NULL , -.Fa BN_GENCB_call cb 1 j -is called after the j-th iteration (j = 0, 1, ...). -.Fa ctx -is a pre-allocated -.Vt BN_CTX -(to save the overhead of allocating and freeing the structure in a -loop), or -.Dv NULL . +no action occurs. .Pp -.Fn BN_GENCB_call -calls the callback function held in the -.Vt BN_GENCB -structure and passes the ints -.Fa a -and -.Fa b -as arguments. -There are two types of -.Vt BN_GENCB -structures that are supported: "new" style and "old" style. -New programs should prefer the "new" style, whilst the "old" style is -provided for backwards compatibility purposes. +.Fn BN_GENCB_set +initialises +.Fa cb +to use the callback function pointer +.Fa cb_fp +and the additional callback argument +.Fa cb_arg . .Pp -A -.Vt BN_GENCB -structure should be created through a call to -.Fn BN_GENCB_new -and freed through a call to -.Fn BN_GENCB_free . +The deprecated function +.Fn BN_GENCB_set_old +initialises +.Fa cb +to use the old-style callback function pointer +.Fa cb_fp +and the additional callback argument +.Fa cb_arg . .Pp -For "new" style callbacks a -.Vt BN_GENCB -structure should be initialised with a call to -.Fn BN_GENCB_set , -where -.Fa gencb -is a -.Vt BN_GENCB * , -.Fa callback -is of type -.Vt int (*callback)(int, int, BN_GENCB *) -and -.Fa cb_arg -is a -.Vt void * . -"Old" style callbacks are the same except they are initialised with a -call to +.Fn BN_generate_prime +is a deprecated wrapper around .Fn BN_GENCB_set_old and -.Fa callback -is of type -.Vt void (*callback)(int, int, void *) . -.Pp -A callback is invoked through a call to -.Fn BN_GENCB_call . -This will check the type of the callback and will invoke -.Fn callback a b gencb -for new style callbacks or -.Fn callback a b cb_arg -for old style. -.Pp -It is possible to obtain the argument associated with a -.Vt BN_GENCB -structure (set via a call to -.Fn BN_GENCB_set -or -.Fn BN_GENCB_set_old ) -using -.Fn BN_GENCB_get_arg . +.Fn BN_generate_prime_ex . +In contrast to +.Fn BN_generate_prime_ex , +if +.Dv NULL +is passed for the +.Fa ret +argument, a new +.Vt BIGNUM +object is allocated and returned. .Pp -.Fn BN_generate_prime -(deprecated) works in the same way as -.Fn BN_generate_prime_ex -but expects an old style callback function directly in the -.Fa callback -parameter, and an argument to pass to it in the -.Fa cb_arg . -Similarly +Similarly, .Fn BN_is_prime and .Fn BN_is_prime_fasttest -are deprecated and can be compared to -.Fn BN_is_prime_ex +are deprecated wrappers around +.Fn BN_GENCB_set_old and -.Fn BN_is_prime_fasttest_ex -respectively. +.Fn BN_is_prime_ex . .Sh RETURN VALUES -.Fn BN_generate_prime_ex -returns 1 on success or 0 on error. -.Pp .Fn BN_is_prime_ex , .Fn BN_is_prime_fasttest_ex , .Fn BN_is_prime , and .Fn BN_is_prime_fasttest -return 0 if the number is composite, 1 if it is prime with an error -probability of less than -.Pf 0.25^ Fa nchecks , -and -1 on error. +return 0 if the number is composite, 1 if it is prime with a very small +error probability, or \-1 on error. .Pp -.Fn BN_generate_prime -returns the prime number on success, +.Fn BN_generate_prime_ex +returns 1 on success or 0 on error. +.Pp +.Fn BN_GENCB_call +returns 1 on success, including when +.Fa cb +is .Dv NULL -otherwise. +or does not contain a callback function, +or 0 on error. .Pp .Fn BN_GENCB_new -returns a pointer to a +returns a pointer to the newly allocated .Vt BN_GENCB -structure on success, or +object or .Dv NULL -otherwise. +if memory allocation fails. +.Pp +The callback functions pointed to by the +.Fa cb_fp +arguments are supposed to return 1 on success or 0 on error. .Pp .Fn BN_GENCB_get_arg -returns the argument previously associated with a -.Vt BN_GENCB -structure. +returns the +.Fa cb_arg +pointer that was previously stored in +.Fa cb +using +.Fn BN_GENCB_set +or +.Fn BN_GENCB_set_old . .Pp -Callback functions should return 1 on success or 0 on error. +.Fn BN_generate_prime +returns the prime number on success or +.Dv NULL +on failure. .Pp -The error codes can be obtained by +In some cases, error codes can be obtained by .Xr ERR_get_error 3 . .Sh SEE ALSO .Xr BN_new 3 , diff --git a/man/BN_kronecker.3 b/man/BN_kronecker.3 new file mode 100644 index 00000000..90b7f432 --- /dev/null +++ b/man/BN_kronecker.3 @@ -0,0 +1,57 @@ +.\" $OpenBSD: BN_kronecker.3,v 1.2 2022/11/15 17:55:00 schwarze Exp $ +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: November 15 2022 $ +.Dt BN_KRONECKER 3 +.Os +.Sh NAME +.Nm BN_kronecker +.Nd Kronecker symbol +.Sh SYNOPSIS +.In openssl/bn.h +.Ft int +.Fo BN_kronecker +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *b" +.Fa "BN_CTX *ctx" +.Fc +.Sh DESCRIPTION +.Fn BN_kronecker +computes the Kronecker symbol +.Pq a | b , +which generalizes the Legendre and Jacobi symbols +for arbitrary integer numbers +.Fa b . +.Sh RETURN VALUES +.Fn BN_kronecker +returns \-1, 0, or 1 in case of success or \-2 on error. +.Sh SEE ALSO +.Xr BN_CTX_new 3 , +.Xr BN_gcd 3 , +.Xr BN_mod_sqrt 3 , +.Xr BN_new 3 +.Rs +.%A Henri Cohen +.%B A Course in Computational Algebraic Number Theory +.%I Springer +.%C Berlin +.%D 1993 +.%O Algorithm 1.4.10 +.Re +.Sh HISTORY +.Fn BN_kronecker +first appeared in OpenSSL 0.9.7 and has been available since +.Ox 3.2 . diff --git a/man/BN_mod_mul_reciprocal.3 b/man/BN_mod_mul_reciprocal.3 index 77c29327..f28ade2a 100644 --- a/man/BN_mod_mul_reciprocal.3 +++ b/man/BN_mod_mul_reciprocal.3 @@ -1,7 +1,25 @@ -.\" $OpenBSD: BN_mod_mul_reciprocal.3,v 1.11 2021/11/30 18:34:35 tb Exp $ -.\" OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000 +.\" $OpenBSD: BN_mod_mul_reciprocal.3,v 1.12 2022/11/14 18:28:29 schwarze Exp $ +.\" full merge up to: OpenSSL 6859cf74 Sep 25 13:33:28 2002 +0000 +.\" selective merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 .\" -.\" This file was written by Ulf Moeller . +.\" This file is a derived work. +.\" The changes are covered by the following Copyright and license: +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" The original file was written by Ulf Moeller . .\" Copyright (c) 2000 The OpenSSL Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -48,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: November 30 2021 $ +.Dd $Mdocdate: November 14 2022 $ .Dt BN_MOD_MUL_RECIPROCAL 3 .Os .Sh NAME @@ -57,7 +75,8 @@ .Nm BN_RECP_CTX_init , .Nm BN_RECP_CTX_free , .Nm BN_RECP_CTX_set , -.Nm BN_div_recp +.Nm BN_div_recp , +.Nm BN_reciprocal .Nd modular multiplication using reciprocal .Sh SYNOPSIS .In openssl/bn.h @@ -95,6 +114,13 @@ .Fa "BN_RECP_CTX *recp" .Fa "BN_CTX *ctx" .Fc +.Ft int +.Fo BN_reciprocal +.Fa "BIGNUM *r" +.Fa "const BIGNUM *m" +.Fa "int len" +.Fa "BN_CTX *ctx" +.Fc .Sh DESCRIPTION .Fn BN_mod_mul_reciprocal can be used to perform an efficient @@ -160,6 +186,15 @@ It places the quotient in and the remainder in .Fa rem . .Pp +.Fn BN_reciprocal +divides the +.Fa len Ap th +power of two by +.Fa m +and places the quotient in +.Fa r , +rounding it towards zero to the closest integer. +.Pp The .Vt BN_RECP_CTX structure is defined as follows: @@ -182,7 +217,17 @@ or .Dv NULL on error. .Pp -For the other functions, 1 is returned for success or 0 on error. +.Fn BN_mod_mul_reciprocal , +.Fn BN_RECP_CTX_set , +and +.Fn BN_div_recp +return 1 for success or 0 on error. +.Pp +.Fn BN_reciprocal +returns +.Fa len +for success or \-1 on error. +.Pp The error codes can be obtained by .Xr ERR_get_error 3 . .Sh SEE ALSO @@ -191,14 +236,14 @@ The error codes can be obtained by .Xr BN_new 3 .Sh HISTORY .Fn BN_mod_mul_reciprocal -first appeared in SSLeay 0.5.1 and has been available since +and +.Fn BN_reciprocal +first appeared in SSLeay 0.5.1 and have been available since .Ox 2.4 . .Pp .Vt BN_RECP_CTX was added in SSLeay 0.9.0. -Before that, a function -.Fn BN_reciprocal -was used instead, and the +Before that, the .Fn BN_mod_mul_reciprocal arguments were different. .Pp diff --git a/man/BN_mod_sqrt.3 b/man/BN_mod_sqrt.3 new file mode 100644 index 00000000..7247d907 --- /dev/null +++ b/man/BN_mod_sqrt.3 @@ -0,0 +1,111 @@ +.\" $OpenBSD: BN_mod_sqrt.3,v 1.2 2022/12/06 22:22:42 tb Exp $ +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: December 6 2022 $ +.Dt BN_MOD_SQRT 3 +.Os +.Sh NAME +.Nm BN_mod_sqrt +.Nd square root in a prime field +.Sh SYNOPSIS +.In openssl/bn.h +.Ft BIGNUM * +.Fo BN_mod_sqrt +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *p" +.Fa "BN_CTX *ctx" +.Fc +.Sh DESCRIPTION +.Fn BN_mod_sqrt +solves +.Bd -unfilled -offset indent +.EQ +r sup 2 == a ( roman mod p ) +.EN +.Ed +.Pp +for +.Fa r +in the prime field of characteristic +.Fa p +using the Tonelli-Shanks algorithm if needed +and places one of the two solutions into +.Fa r . +The other solution is +.Fa p +\- +.Fa r . +.Pp +The argument +.Fa p +is expected to be a prime number. +.Sh RETURN VALUES +In case of success, +.Fn BN_mod_sqrt +returns +.Fa r , +or a newly allocated +.Vt BIGNUM +object if the +.Fa r +argument is +.Dv NULL . +.Pp +In case of failure, +.Dv NULL +is returned. +This for example happens if +.Fa a +is not a quadratic residue or if memory allocation fails. +.Sh SEE ALSO +.Xr BN_CTX_new 3 , +.Xr BN_kronecker 3 , +.Xr BN_mod_sqr 3 , +.Xr BN_new 3 +.Rs +.%A Henri Cohen +.%B A Course in Computational Algebraic Number Theory +.%I Springer +.%C Berlin +.%D 1993 +.%O Algorithm 1.5.1 +.Re +.Sh HISTORY +.Fn BN_mod_sqrt +first appeared in OpenSSL 0.9.7 and has been available since +.Ox 3.2 . +.Sh CAVEATS +If +.Fa p +is not prime, +.Fn BN_mod_sqrt +may succeed or fail. +If it succeeds, the square of the returned value is congruent to +.Fa a +modulo +.Fa p . +If it fails, the reason reported by +.Xr ERR_get_error 3 +is often misleading. +In particular, even if +.Fa a +is a perfect square, +.Fn BN_mod_sqrt +often reports +.Dq not a square +instead of +.Dq p is not prime . diff --git a/man/BN_new.3 b/man/BN_new.3 index e8d268e8..7e343277 100644 --- a/man/BN_new.3 +++ b/man/BN_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: BN_new.3,v 1.18 2022/07/13 21:51:35 schwarze Exp $ +.\" $OpenBSD: BN_new.3,v 1.22 2022/11/21 22:04:04 schwarze Exp $ .\" full merge up to: OpenSSL man3/BN_new 2457c19d Mar 6 08:43:36 2004 +0000 .\" selective merge up to: man3/BN_new 681acb31 Sep 29 13:10:34 2017 +0200 .\" full merge up to: OpenSSL man7/bn 05ea606a May 20 20:52:46 2016 -0400 @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 13 2022 $ +.Dd $Mdocdate: November 21 2022 $ .Dt BN_NEW 3 .Os .Sh NAME @@ -155,9 +155,13 @@ and sets an error code that can be obtained by .Xr BN_CTX_start 3 , .Xr BN_generate_prime 3 , .Xr BN_get0_nist_prime_521 3 , +.Xr BN_GF2m_add 3 , +.Xr BN_kronecker 3 , .Xr BN_mod_inverse 3 , .Xr BN_mod_mul_montgomery 3 , .Xr BN_mod_mul_reciprocal 3 , +.Xr BN_mod_sqrt 3 , +.Xr BN_nist_mod_521 3 , .Xr BN_num_bytes 3 , .Xr BN_rand 3 , .Xr BN_security_bits 3 , diff --git a/man/BN_nist_mod_521.3 b/man/BN_nist_mod_521.3 new file mode 100644 index 00000000..72dd4a71 --- /dev/null +++ b/man/BN_nist_mod_521.3 @@ -0,0 +1,113 @@ +.\" $OpenBSD: BN_nist_mod_521.3,v 1.1 2022/11/21 22:04:04 schwarze Exp $ +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: November 21 2022 $ +.Dt BN_NIST_MOD_521 3 +.Os +.Sh NAME +.Nm BN_nist_mod_192 , +.Nm BN_nist_mod_224 , +.Nm BN_nist_mod_256 , +.Nm BN_nist_mod_384 , +.Nm BN_nist_mod_521 +.Nd reduction modulo NIST-recommended primes +.Sh SYNOPSIS +.In openssl/bn.h +.Ft int +.Fo BN_nist_mod_192 +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *m" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_nist_mod_224 +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *m" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_nist_mod_256 +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *m" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_nist_mod_384 +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *m" +.Fa "BN_CTX *ctx" +.Fc +.Ft int +.Fo BN_nist_mod_521 +.Fa "BIGNUM *r" +.Fa "const BIGNUM *a" +.Fa "const BIGNUM *m" +.Fa "BN_CTX *ctx" +.Fc +.Sh DESCRIPTION +These functions are optimized versions of +.Xr BN_nnmod 3 +using precomputed tables. +They ignore their +.Fa m +argument and use the following moduli instead: +.Pp +.Bl -tag -width BN_nist_mod_521() -offset indent -compact +.It Fn BN_nist_mod_192 +.Xr BN_get0_nist_prime_192 3 +.It Fn BN_nist_mod_224 +.Xr BN_get0_nist_prime_224 3 +.It Fn BN_nist_mod_256 +.Xr BN_get0_nist_prime_256 3 +.It Fn BN_nist_mod_384 +.Xr BN_get0_nist_prime_384 3 +.It Fn BN_nist_mod_521 +.Xr BN_get0_nist_prime_521 3 +.El +.Pp +They reduce +.Fa a +modulo the respective prime number and place the non-negative remainder in +.Fa r . +.Pp +These functions are designed to save time when performing multiplications +in prime fields of these specific orders. +Consequently, if +.Fa a +is negative or larger than the square of the modulus being used, they call +.Xr BN_nnmod 3 +instead of attempting any optimization. +.Sh RETURN VALUES +These functions return 1 on success or 0 on error. +.Sh SEE ALSO +.Xr BN_get0_nist_prime_521 3 , +.Xr BN_nnmod 3 , +.Xr EC_GFp_nist_method 3 +.Sh STANDARDS +.Rs +.%T Digital Signature Standard (DSS) +.%I National Institute of Standards and Technology +.%R FIPS PUB 186-4 +.%U https://doi.org/10.6028/NIST.FIPS.186-4 +.%Q Information Technology Laboratory +.%C Gaithersburg, Maryland +.%D July 2013 +.%O Appendix D.1.2 Curves over Prime Fields +.Re diff --git a/man/BN_num_bytes.3 b/man/BN_num_bytes.3 index f1a995f0..785f43e2 100644 --- a/man/BN_num_bytes.3 +++ b/man/BN_num_bytes.3 @@ -1,7 +1,24 @@ -.\" $OpenBSD: BN_num_bytes.3,v 1.8 2022/07/13 21:51:35 schwarze Exp $ -.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 +.\" $OpenBSD: BN_num_bytes.3,v 1.9 2022/11/22 18:55:04 schwarze Exp $ +.\" full merge up to: OpenSSL 9e183d22 Mar 11 08:56:44 2017 -0500 .\" -.\" This file was written by Ulf Moeller +.\" This file is a derived work. +.\" The changes are covered by the following Copyright and license: +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" The original file was written by Ulf Moeller .\" and Richard Levitte . .\" Copyright (c) 2000, 2004 The OpenSSL Project. All rights reserved. .\" @@ -49,71 +66,83 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 13 2022 $ +.Dd $Mdocdate: November 22 2022 $ .Dt BN_NUM_BYTES 3 .Os .Sh NAME -.Nm BN_num_bytes , +.Nm BN_num_bits_word , .Nm BN_num_bits , -.Nm BN_num_bits_word +.Nm BN_num_bytes .Nd get BIGNUM size .Sh SYNOPSIS .In openssl/bn.h .Ft int -.Fo BN_num_bytes -.Fa "const BIGNUM *a" +.Fo BN_num_bits_word +.Fa "BN_ULONG w" .Fc .Ft int .Fo BN_num_bits .Fa "const BIGNUM *a" .Fc .Ft int -.Fo BN_num_bits_word -.Fa "BN_ULONG w" +.Fo BN_num_bytes +.Fa "const BIGNUM *a" .Fc .Sh DESCRIPTION -.Fn BN_num_bytes -returns the size of a -.Vt BIGNUM -in bytes. -.Pp .Fn BN_num_bits_word -returns the number of significant bits in a word. -As an example, 0x00000432 returns 11, not 16 or 32. -Basically, except for a zero, it returns +returns the number of significant bits in +.Fa w , +that is, the minimum number of digits needed to write +.Fa w +as a binary number. +Except for an argument of 0, this is .Pp .D1 floor(log2( Ns Fa w ) ) No + 1 . .Pp +.Vt BN_ULONG +is a macro that expands to +.Vt unsigned long Pq = Vt uint64_t +on +.Dv _LP64 +platforms and +.Vt unsigned int Pq = Vt uint32_t +elsewhere. +.Pp .Fn BN_num_bits -returns the number of significant bits in a -.Sy BIGNUM , +returns the number of significant bits in the value of the +.Fa "BIGNUM *a" , following the same principle as .Fn BN_num_bits_word . .Pp .Fn BN_num_bytes -is a macro. +is a macro that returns the number of significant bytes in +.Fa a , +i.e. the minimum number of bytes needed to store the value of +.Fa a , +that is, +.Fn BN_num_bits a +divided by eight and rounded up to the next integer number. +.Sh RETURN VALUES +.Fn BN_num_bits_word +returns the number of significant bits in +.Fa w +or 0 if +.Fa w +is 0. +The maximum return value that can occur is +.Dv BN_BITS2 , +which is 64 on +.Dv _LP64 +platforms and 32 elsewhere. .Pp -Some have tried using .Fn BN_num_bits -on individual numbers in RSA keys, DH keys and DSA keys, and found that -they don't always come up with the number of bits they expected -(something like 512, 1024, 2048, ...). This is because generating a -number with some specific number of bits doesn't always set the highest -bits, thereby making the number of -.Em significant -bits a little lower. -If you want to know the "key size" of such a key, either use functions -like -.Xr RSA_size 3 , -.Xr DH_size 3 , -and -.Xr DSA_size 3 , -or use +returns the number of significant bits and .Fn BN_num_bytes -and multiply with 8 (although there's no real guarantee that will match -the "key size", just a lot more probability). -.Sh RETURN VALUES -The size. +the number of significant bytes in +.Fa a , +or 0 if the value of +.Fa a +is 0. .Sh SEE ALSO .Xr BN_new 3 , .Xr BN_security_bits 3 , @@ -129,3 +158,18 @@ first appeared in SSLeay 0.5.1. first appeared in SSLeay 0.5.2. These functions have been available since .Ox 2.4 . +.Sh CAVEATS +Some have tried using +.Fn BN_num_bits +on individual numbers in RSA keys, DH keys and DSA keys, and found that +they don't always come up with the number of bits they expected +(something like 512, 1024, 2048, ...). +This is because generating a number with some specific number of bits +doesn't always set the highest bits, thereby making the number of +.Em significant +bits a little smaller. +If you want to know the "key size" of such a key, use functions like +.Xr RSA_size 3 , +.Xr DH_size 3 , +and +.Xr DSA_size 3 . diff --git a/man/BN_zero.3 b/man/BN_zero.3 index aa3e8a06..876e1c3f 100644 --- a/man/BN_zero.3 +++ b/man/BN_zero.3 @@ -1,11 +1,11 @@ -.\" $OpenBSD: BN_zero.3,v 1.11 2021/12/19 16:18:34 schwarze Exp $ +.\" $OpenBSD: BN_zero.3,v 1.12 2022/11/22 19:02:07 schwarze Exp $ .\" full merge up to: OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 .\" selective merge up to: OpenSSL b713c4ff Jan 22 14:41:09 2018 -0500 .\" .\" This file is a derived work. .\" The changes are covered by the following Copyright and license: .\" -.\" Copyright (c) 2021 Ingo Schwarze +.\" Copyright (c) 2021, 2022 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -67,7 +67,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: December 19 2021 $ +.Dd $Mdocdate: November 22 2022 $ .Dt BN_ZERO 3 .Os .Sh NAME @@ -109,6 +109,13 @@ .Vt BN_ULONG is a macro that expands to an unsigned integral type optimized for the most efficient implementation on the local platform. +It is +.Vt unsigned long Pq = Vt uint64_t +on +.Dv _LP64 +platforms and +.Vt unsigned int Pq = Vt uint32_t +elsewhere. .Pp .Fn BN_zero_ex , .Fn BN_one , diff --git a/man/DH_get0_pqg.3 b/man/DH_get0_pqg.3 index b7dccfc9..340d5075 100644 --- a/man/DH_get0_pqg.3 +++ b/man/DH_get0_pqg.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DH_get0_pqg.3,v 1.6 2022/07/13 21:51:35 schwarze Exp $ +.\" $OpenBSD: DH_get0_pqg.3,v 1.7 2023/03/06 13:25:46 tb Exp $ .\" selective merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100 .\" .\" This file was written by Matt Caswell . @@ -48,13 +48,18 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 13 2022 $ +.Dd $Mdocdate: March 6 2023 $ .Dt DH_GET0_PQG 3 .Os .Sh NAME .Nm DH_get0_pqg , +.Nm DH_get0_p , +.Nm DH_get0_q , +.Nm DH_get0_g , .Nm DH_set0_pqg , .Nm DH_get0_key , +.Nm DH_get0_pub_key , +.Nm DH_get0_priv_key , .Nm DH_set0_key , .Nm DH_clear_flags , .Nm DH_test_flags , @@ -71,6 +76,18 @@ .Fa "const BIGNUM **q" .Fa "const BIGNUM **g" .Fc +.Ft "const BIGNUM *" +.Fo DH_get0_p +.Fa "const DH *dh" +.Fc +.Ft "const BIGNUM *" +.Fo DH_get0_q +.Fa "const DH *dh" +.Fc +.Ft "const BIGNUM *" +.Fo DH_get0_g +.Fa "const DH *dh" +.Fc .Ft int .Fo DH_set0_pqg .Fa "DH *dh" @@ -84,6 +101,14 @@ .Fa "const BIGNUM **pub_key" .Fa "const BIGNUM **priv_key" .Fc +.Ft "const BIGNUM *" +.Fo DH_get0_pub_key +.Fa "const DH *dh" +.Fc +.Ft "const BIGNUM *" +.Fo DH_get0_priv_key +.Fa "const DH *dh" +.Fc .Ft int .Fo DH_set0_key .Fa "DH *dh" @@ -211,6 +236,25 @@ If needed, duplicate the received values using .Xr BN_dup 3 and pass the duplicates. .Pp +Any of the values +.Fa p , +.Fa q , +.Fa g , +.Fa pub_key , +and +.Fa priv_key +can also be retrieved separately by the corresponding functions +.Fn DH_get0_p , +.Fn DH_get0_q , +.Fn DH_get0_g , +.Fn DH_get0_pub_key , +and +.Fn DH_get0_priv_key , +respectively. +The pointers are owned by the +.Vt DH +object. +.Pp .Fn DH_clear_flags clears the specified .Fa flags @@ -236,6 +280,17 @@ sets the optional length attribute of indicating the length of the secret exponent (private key) in bits. If the length attribute is non-zero, it is used, otherwise it is ignored. .Sh RETURN VALUES ++.Fn DH_get0_p , ++.Fn DH_get0_q , ++.Fn DH_get0_g , ++.Fn DH_get0_pub_key , ++and ++.Fn DH_get0_priv_key , ++return a pointer owned by the ++.Vt DH ++object if the corresponding value has been set, ++otherwise they return ++.Dv NULL . .Fn DH_set0_pqg , .Fn DH_set0_key , and @@ -269,6 +324,26 @@ if no engine was set for this object. .Xr DH_size 3 , .Xr DHparams_print 3 .Sh HISTORY -These functions first appeared in OpenSSL 1.1.0 +.Fn DH_get0_pqg , +.Fn DH_set0_pqg , +.Fn DH_get0_key , +.Fn DH_set0_key , +.Fn DH_clear_flags , +.Fn DH_test_flags , +.Fn DH_set_flags , +.Fn DH_get0_engine , +and +.Fn DH_set_length +first appeared in OpenSSL 1.1.0 and have been available since .Ox 6.3 . +.Pp +.Fn DH_get0_p , +.Fn DH_get0_q , +.Fn DH_get0_g , +.Fn DH_get0_pub_key , +and +.Fn DH_get0_priv_key +first appeared in OpenSSL 1.1.1 +and have been available since +.Ox 7.1 . diff --git a/man/DSA_get0_pqg.3 b/man/DSA_get0_pqg.3 index e2cf7405..b5250d9f 100644 --- a/man/DSA_get0_pqg.3 +++ b/man/DSA_get0_pqg.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: DSA_get0_pqg.3,v 1.5 2022/07/13 21:51:35 schwarze Exp $ +.\" $OpenBSD: DSA_get0_pqg.3,v 1.7 2023/03/07 06:15:07 tb Exp $ .\" full merge up to: OpenSSL e90fc053 Jul 15 09:39:45 2017 -0400 .\" .\" This file was written by Matt Caswell . @@ -48,13 +48,18 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 13 2022 $ +.Dd $Mdocdate: March 7 2023 $ .Dt DSA_GET0_PQG 3 .Os .Sh NAME .Nm DSA_get0_pqg , +.Nm DSA_get0_p , +.Nm DSA_get0_q , +.Nm DSA_get0_g , .Nm DSA_set0_pqg , .Nm DSA_get0_key , +.Nm DSA_get0_pub_key , +.Nm DSA_get0_priv_key , .Nm DSA_set0_key , .Nm DSA_clear_flags , .Nm DSA_test_flags , @@ -70,6 +75,18 @@ .Fa "const BIGNUM **q" .Fa "const BIGNUM **g" .Fc +.Ft "const BIGNUM *" +.Fo DSA_get0_p +.Fa "const DSA *d" +.Fc +.Ft "const BIGNUM *" +.Fo DSA_get0_q +.Fa "const DSA *d" +.Fc +.Ft "const BIGNUM *" +.Fo DSA_get0_g +.Fa "const DSA *d" +.Fc .Ft int .Fo DSA_set0_pqg .Fa "DSA *d" @@ -83,6 +100,14 @@ .Fa "const BIGNUM **pub_key" .Fa "const BIGNUM **priv_key" .Fc +.Ft "const BIGNUM *" +.Fo DSA_get0_pub_key +.Fa "const DSA *d" +.Fc +.Ft "const BIGNUM *" +.Fo DSA_get0_priv_key +.Fa "const DSA *d" +.Fc .Ft int .Fo DSA_set0_key .Fa "DSA *d" @@ -194,6 +219,25 @@ If needed, duplicate the received values using .Xr BN_dup 3 and pass the duplicates. .Pp +Any of the values +.Fa p , +.Fa q , +.Fa g , +.Fa pub_key , +and +.Fa priv_key +can also be retrieved separately by the corresponding functions +.Fn DSA_get0_p , +.Fn DSA_get0_q , +.Fn DSA_get0_g , +.Fn DSA_get0_pub_key , +and +.Fn DSA_get0_priv_key , +respectively. +The pointers are owned by the +.Vt DSA +object. +.Pp .Fn DSA_clear_flags clears the specified .Fa flags @@ -213,6 +257,17 @@ any flags already set remain set. For all three functions, multiple flags can be passed in one call, OR'ed together bitwise. .Sh RETURN VALUES +.Fn DSA_get0_p , +.Fn DSA_get0_q , +.Fn DSA_get0_g , +.Fn DSA_get0_pub_key , +and +.Fn DSA_get0_priv_key +return a pointer owned by the +.Vt DSA +object if the corresponding value has been set, +otherwise they return +.Dv NULL . .Fn DSA_set0_pqg and .Fn DSA_set0_key @@ -248,6 +303,25 @@ if no engine was set for this object. .Xr DSA_sign 3 , .Xr DSA_size 3 .Sh HISTORY -These functions first appeared in OpenSSL 1.1.0 +.Fn DSA_get0_pqg , +.Fn DSA_set0_pqg , +.Fn DSA_get0_key , +.Fn DSA_set0_key , +.Fn DSA_clear_flags , +.Fn DSA_test_flags , +.Fn DSA_set_flags , +and +.Fn DSA_get0_engine +first appeared in OpenSSL 1.1.0 and have been available since .Ox 6.3 . +.Pp +.Fn DSA_get0_p , +.Fn DSA_get0_q , +.Fn DSA_get0_g , +.Fn DSA_get0_pub_key , +and +.Fn DSA_get0_priv_key +first appeared in OpenSSL 1.1.1 +and have been available since +.Ox 7.1 . diff --git a/man/ECDSA_SIG_new.3 b/man/ECDSA_SIG_new.3 index 72802155..61815128 100644 --- a/man/ECDSA_SIG_new.3 +++ b/man/ECDSA_SIG_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ECDSA_SIG_new.3,v 1.15 2019/08/25 14:11:41 schwarze Exp $ +.\" $OpenBSD: ECDSA_SIG_new.3,v 1.17 2023/03/07 06:12:27 tb Exp $ .\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 .\" selective merge up to: OpenSSL da4ea0cf Aug 5 16:13:24 2019 +0100 .\" @@ -50,13 +50,15 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: August 25 2019 $ +.Dd $Mdocdate: March 7 2023 $ .Dt ECDSA_SIG_NEW 3 .Os .Sh NAME .Nm ECDSA_SIG_new , .Nm ECDSA_SIG_free , .Nm ECDSA_SIG_get0 , +.Nm ECDSA_SIG_get0_r , +.Nm ECDSA_SIG_get0_s , .Nm ECDSA_SIG_set0 , .Nm i2d_ECDSA_SIG , .Nm d2i_ECDSA_SIG , @@ -89,6 +91,14 @@ .Fa "const BIGNUM **r" .Fa "const BIGNUM **s" .Fc +.Ft "const BIGNUM *" +.Fo ECDSA_SIG_get0_r +.Fa "const ECDSA_SIG *sig" +.Fc +.Ft "const BIGNUM *" +.Fo ECDSA_SIG_get0_s +.Fa "const ECDSA_SIG *sig" +.Fc .Ft int .Fo ECDSA_SIG_set0 .Fa "ECDSA_SIG *sig" @@ -232,6 +242,15 @@ and .Fa s values contained in .Fa sig . +The values +.Fa r +and +.Fa s +can also be retrieved separately by the corresponding function +.Fn ECDSA_SIG_get0_r +and +.Fn ECDSA_SIG_get0_s , +respectively. .Pp .Fn ECDSA_SIG_set0 sets the @@ -390,6 +409,15 @@ if an error occurs. .Fn ECDSA_size returns the maximum length signature or 0 on error. .Pp +.Fn ECDSA_SIG_get0_r +and +.Fn ECDSA_SIG_get0_s +return a pointer owned by the +.Vt ECDSA_SIG +object if it has been set or +.Dv NULL +otherwise. +.Pp .Fn ECDSA_SIG_set0 , .Fn ECDSA_sign , .Fn ECDSA_sign_ex , @@ -521,6 +549,11 @@ and .Fn ECDSA_SIG_set0 first appeared in OpenSSL 1.1.0 and have been available since .Ox 6.3 . +.Fn ECDSA_SIG_get0_r +and +.Fn ECDSA_SIG_get0_s +first appeared in OpenSSL 1.1.1 and have been available since +.Ox 7.1 . .Sh AUTHORS .An Nils Larsch for the OpenSSL project. diff --git a/man/EVP_CIPHER_meth_new.3 b/man/EVP_CIPHER_meth_new.3 new file mode 100644 index 00000000..21555edf --- /dev/null +++ b/man/EVP_CIPHER_meth_new.3 @@ -0,0 +1,335 @@ +.\" $OpenBSD: EVP_CIPHER_meth_new.3,v 1.1 2023/03/16 15:05:23 tb Exp $ +.\" selective merge up to: OpenSSL b0edda11 Mar 20 13:00:17 2018 +0000 +.\" +.\" The original file was written by Richard Levitte +.\" Copyright (c) 2015 The OpenSSL Project. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" +.\" 3. All advertising materials mentioning features or use of this +.\" software must display the following acknowledgment: +.\" "This product includes software developed by the OpenSSL Project +.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" +.\" +.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to +.\" endorse or promote products derived from this software without +.\" prior written permission. For written permission, please contact +.\" openssl-core@openssl.org. +.\" +.\" 5. Products derived from this software may not be called "OpenSSL" +.\" nor may "OpenSSL" appear in their names without prior written +.\" permission of the OpenSSL Project. +.\" +.\" 6. Redistributions of any form whatsoever must retain the following +.\" acknowledgment: +.\" "This product includes software developed by the OpenSSL Project +.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY +.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR +.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +.\" OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd $Mdocdate: March 16 2023 $ +.Dt EVP_CIPHER_METH_NEW 3 +.Os +.Sh NAME +.Nm EVP_CIPHER_meth_new , +.Nm EVP_CIPHER_meth_dup , +.Nm EVP_CIPHER_meth_free , +.Nm EVP_CIPHER_meth_set_iv_length , +.Nm EVP_CIPHER_meth_set_flags , +.Nm EVP_CIPHER_meth_set_impl_ctx_size , +.Nm EVP_CIPHER_meth_set_init , +.Nm EVP_CIPHER_meth_set_do_cipher , +.Nm EVP_CIPHER_meth_set_cleanup , +.Nm EVP_CIPHER_meth_set_set_asn1_params , +.Nm EVP_CIPHER_meth_set_get_asn1_params , +.Nm EVP_CIPHER_meth_set_ctrl +.Nd Routines to build up EVP_CIPHER methods +.Sh SYNOPSIS +.In openssl/evp.h +.Ft EVP_CIPHER * +.Fo EVP_CIPHER_meth_new +.Fa "int cipher_type" +.Fa "int block_size" +.Fa "int key_len" +.Fc +.Ft EVP_CIPHER * +.Fo EVP_CIPHER_meth_dup +.Fa "const EVP_CIPHER *cipher" +.Fc +.Ft void +.Fo EVP_CIPHER_meth_free +.Fa "EVP_CIPHER *cipher" +.Fc +.Ft int +.Fo EVP_CIPHER_meth_set_iv_length +.Fa "EVP_CIPHER *cipher" +.Fa "int iv_len" +.Fc +.Ft int +.Fo EVP_CIPHER_meth_set_flags +.Fa "EVP_CIPHER *cipher" +.Fa "unsigned long flags" +.Fc +.Ft int +.Fo EVP_CIPHER_meth_set_impl_ctx_size +.Fa "EVP_CIPHER *cipher" +.Fa "int ctx_size" +.Fc +.Ft int +.Fo EVP_CIPHER_meth_set_init +.Fa "EVP_CIPHER *cipher" +.Fa "int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,\ + const unsigned char *iv, int enc)" +.Fc +.Ft int +.Fo EVP_CIPHER_meth_set_do_cipher +.Fa "EVP_CIPHER *cipher" +.Fa "int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,\ + const unsigned char *in, size_t inl)" +.Fc +.Ft int +.Fo EVP_CIPHER_meth_set_cleanup +.Fa "EVP_CIPHER *cipher" +.Fa "int (*cleanup)(EVP_CIPHER_CTX *)" +.Fc +.Ft int +.Fo EVP_CIPHER_meth_set_set_asn1_params +.Fa "EVP_CIPHER *cipher" +.Fa "int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)" +.Fc +.Ft int +.Fo EVP_CIPHER_meth_set_get_asn1_params +.Fa "EVP_CIPHER *cipher" +.Fa "int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *)" +.Fc +.Ft int +.Fo EVP_CIPHER_meth_set_ctrl +.Fa "EVP_CIPHER *cipher" +.Fa "int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr)" +.Fc +.Sh DESCRIPTION +The +.Vt EVP_CIPHER +type is a structure holding function pointers for +a symmetric cipher implementation. +.Pp +.Fn EVP_CIPHER_meth_new +allocates a new +.Vt EVP_CIPHER +structure. +The cipher's NID (see +.Xr EVP_CIPHER_nid 3 ) +is set to +.Fa cipher_type , +the block size and key length are set to +.Fa block_size +and +.Fa key_len , +respectively. +.Pp +.Fn EVP_CIPHER_meth_dup +creates a copy of +.Fa cipher . +.Pp +.Fn EVP_CIPHER_meth_free +frees an +.Vt EVP_CIPHER +structure. +.Pp +.Fn EVP_CIPHER_meth_set_iv_length +sets the length of the initialization vector. +This is only needed when the implemented cipher mode requires it. +.Pp +.Fn EVP_CIPHER_meth_set_flags +overwrites the flags to describe optional behaviours in +.Fa cipher +with +.Fa flags . +At most one of the following cipher modes can be set: +.Dv EVP_CIPH_STREAM_CIPHER , +.Dv EVP_CIPH_ECB_MODE , +.Dv EVP_CIPH_CBC_MODE , +.Dv EVP_CIPH_CFB_MODE , +.Dv EVP_CIPH_OFB_MODE , +.Dv EVP_CIPH_CTR_MODE , +.Dv EVP_CIPH_GCM_MODE , +.Dv EVP_CIPH_CCM_MODE , +.Dv EVP_CIPH_XTS_MODE , +and +.Dv EVP_CIPH_WRAP_MODE . +The available flags are: +.Bl -tag -width Ds +.It EVP_CIPH_VARIABLE_LENGTH +This cipher is of variable length. +.It EVP_CIPH_CUSTOM_IV +Storing and initialising the IV is left entirely to the implementation. +.It EVP_CIPH_ALWAYS_CALL_INIT +Set this if the implementation's +.Fn init +function should be called even if +.Fa key +is +.Dv NULL . +.It EVP_CIPH_CTRL_INIT +Set this to have the implementation's +.Fn ctrl +function called with command code +.Dv EVP_CTRL_INIT +early in its setup. +.It EVP_CIPH_CUSTOM_KEY_LENGTH +Checking and setting the key length after creating the +.Vt EVP_CIPHER +is left to the implementation. +Whenever someone uses +.Xr EVP_CIPHER_CTX_set_key_length 3 +on a +.Vt EVP_CIPHER +with this flag set, the implementation's +.Fn ctrl +function will be called with the control code +.Dv EVP_CTRL_SET_KEY_LENGTH +and the key length in +.Fa arg . +.It EVP_CIPH_NO_PADDING +Don't use standard block padding. +.It EVP_CIPH_RAND_KEY +Making a key with random content is left to the implementation. +This is done by calling the implementation's +.Fn ctrl +function with the control code +.Dv EVP_CTRL_RAND_KEY +and the pointer to the key memory storage in +.Fa ptr . +.It EVP_CIPH_CUSTOM_COPY +Set this to have the implementation's +.Fn ctrl +function called with command code +.Dv EVP_CTRL_COPY +at the end of +.Xr EVP_CIPHER_CTX_copy 3 . +The intended use is for further things to deal with after the +implementation specific data block has been copied. +The destination +.Vt EVP_CIPHER_CTX +object is passed to the control with the +.Fa ptr +parameter. +The implementation-specific data block is reached with +.Xr EVP_CIPHER_CTX_get_cipher_data 3 . +.It EVP_CIPH_FLAG_DEFAULT_ASN1 +Use the default EVP routines to pass IV to and from ASN.1. +.It EVP_CIPH_FLAG_LENGTH_BITS +Signals that the length of the input buffer for encryption / decryption +is to be understood as the number of bits instead of bytes for this +implementation. +This is only useful for CFB1 ciphers. +.It EVP_CIPH_FLAG_CUSTOM_CIPHER +This indicates that the implementation takes care of everything, +including padding, buffering and finalization. +The EVP routines will simply give them control and do nothing more. +.It EVP_CIPH_FLAG_AEAD_CIPHER +This indicates that this is an AEAD cipher implementation. +.El +.Pp +.Fn EVP_CIPHER_meth_set_impl_ctx_size +sets the size of the EVP_CIPHER's implementation context so that it can +be automatically allocated. +.Pp +.Fn EVP_CIPHER_meth_set_init +sets the cipher init function for +.Fa cipher . +The cipher init function is called by +.Xr EVP_CipherInit 3 , +.Xr EVP_CipherInit_ex 3 , +.Xr EVP_EncryptInit 3 , +.Xr EVP_EncryptInit_ex 3 , +.Xr EVP_DecryptInit 3 , +.Xr EVP_DecryptInit_ex 3 . +.Pp +.Fn EVP_CIPHER_meth_set_do_cipher +sets the cipher function for +.Fa cipher . +The cipher function is called by +.Xr EVP_CipherUpdate 3 , +.Xr EVP_EncryptUpdate 3 , +.Xr EVP_DecryptUpdate 3 , +.Xr EVP_CipherFinal 3 , +.Xr EVP_EncryptFinal 3 , +.Xr EVP_EncryptFinal_ex 3 , +.Xr EVP_DecryptFinal 3 +and +.Xr EVP_DecryptFinal_ex 3 . +.Pp +.Fn EVP_CIPHER_meth_set_cleanup +sets the function for +.Fa cipher +to do extra cleanup before the method's private data structure is +cleaned out and freed. +Note that the cleanup function is passed a +.Sy EVP_CIPHER_CTX * , +the private data structure is then available with +.Xr EVP_CIPHER_CTX_get_cipher_data 3 . +This cleanup function is called by +.Xr EVP_CIPHER_CTX_reset 3 +and +.Xr EVP_CIPHER_CTX_free 3 . +.Pp +.Fn EVP_CIPHER_meth_set_set_asn1_params +sets the function for +.Fa cipher +to set the AlgorithmIdentifier "parameter" based on the passed cipher. +This function is called by +.Xr EVP_CIPHER_param_to_asn1 3 . +.Fn EVP_CIPHER_meth_set_get_asn1_params +sets the function for +.Fa cipher +that sets the cipher parameters based on an ASN.1 AlgorithmIdentifier +"parameter". +Both these functions are needed when there is a need for custom data +(more or other than the cipher IV). They are called by +.Xr EVP_CIPHER_param_to_asn1 3 +and +.Xr EVP_CIPHER_asn1_to_param 3 +respectively if defined. +.Pp +.Fn EVP_CIPHER_meth_set_ctrl +sets the control function for +.Fa cipher . +.Sh RETURN VALUES +.Fn EVP_CIPHER_meth_new +and +.Fn EVP_CIPHER_meth_dup +return a pointer to a newly created +.Vt EVP_CIPHER , +or NULL on failure. +.Pp +All +.Fn EVP_CIPHER_meth_set_* +functions return 1. +.Sh SEE ALSO +.Xr EVP_EncryptInit 3 +.Sh HISTORY +These functions first appeared in OpenSSL 1.1.0 and have been available since +.Ox 7.3 . diff --git a/man/EVP_PKEY_keygen.3 b/man/EVP_PKEY_keygen.3 index 6173a1c4..8994496a 100644 --- a/man/EVP_PKEY_keygen.3 +++ b/man/EVP_PKEY_keygen.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: EVP_PKEY_keygen.3,v 1.9 2018/03/23 04:34:23 schwarze Exp $ +.\" $OpenBSD: EVP_PKEY_keygen.3,v 1.10 2022/11/16 15:34:41 schwarze Exp $ .\" full merge up to: OpenSSL e9b77246 Jan 20 19:58:49 2017 +0100 .\" selective merge up to: OpenSSL 48e5119a Jan 19 10:49:22 2018 +0100 .\" @@ -50,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 23 2018 $ +.Dd $Mdocdate: November 16 2022 $ .Dt EVP_PKEY_KEYGEN 3 .Os .Sh NAME @@ -64,6 +64,12 @@ .Nm EVP_PKEY_CTX_get_keygen_info , .Nm EVP_PKEY_CTX_set_app_data , .Nm EVP_PKEY_CTX_get_app_data +.\" The following functions are intentionally undocumented: +.\" .Nm BN_X931_derive_prime_ex , +.\" .Nm BN_X931_generate_prime_ex , +.\" .Nm BN_X931_generate_Xpq +.\" They are unused outside OpenSSL/LibreSSL and deprecated in OpenSSL 3.0, +.\" see https://github.com/openssl/openssl/issues/10111 .Nd key and parameter generation functions .Sh SYNOPSIS .In openssl/evp.h diff --git a/man/EVP_PKEY_new.3 b/man/EVP_PKEY_new.3 index c5673a66..3b961199 100644 --- a/man/EVP_PKEY_new.3 +++ b/man/EVP_PKEY_new.3 @@ -1,10 +1,26 @@ -.\" $OpenBSD: EVP_PKEY_new.3,v 1.17 2022/07/13 21:51:35 schwarze Exp $ -.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 -.\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 +.\" $OpenBSD: EVP_PKEY_new.3,v 1.18 2022/12/14 22:37:07 schwarze Exp $ +.\" full merge up to: OpenSSL 4dcfdfce May 27 11:50:05 2020 +0100 .\" -.\" This file was written by Dr. Stephen Henson +.\" This file is a derived work. +.\" The changes are covered by the following Copyright and license: +.\" +.\" Copyright (c) 2022 Ingo Schwarze +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" The original file was written by Dr. Stephen Henson .\" and Matt Caswell . -.\" Copyright (c) 2002, 2018 The OpenSSL Project. All rights reserved. +.\" Copyright (c) 2002, 2018, 2020 The OpenSSL Project. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -50,47 +66,77 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 13 2022 $ +.Dd $Mdocdate: December 14 2022 $ .Dt EVP_PKEY_NEW 3 .Os .Sh NAME .Nm EVP_PKEY_new , .Nm EVP_PKEY_up_ref , .Nm EVP_PKEY_free , +.Nm EVP_PKEY_new_raw_private_key , +.Nm EVP_PKEY_new_raw_public_key , .Nm EVP_PKEY_new_CMAC_key , -.Nm EVP_PKEY_new_mac_key -.Nd private key allocation functions +.Nm EVP_PKEY_new_mac_key , +.Nm EVP_PKEY_get_raw_private_key , +.Nm EVP_PKEY_get_raw_public_key +.Nd public and private key allocation and raw key handling functions .Sh SYNOPSIS .In openssl/evp.h .Ft EVP_PKEY * .Fn EVP_PKEY_new void .Ft int .Fo EVP_PKEY_up_ref -.Fa "EVP_PKEY *key" +.Fa "EVP_PKEY *pkey" .Fc .Ft void .Fo EVP_PKEY_free -.Fa "EVP_PKEY *key" +.Fa "EVP_PKEY *pkey" +.Fc +.Ft EVP_PKEY * +.Fo EVP_PKEY_new_raw_private_key +.Fa "int type" +.Fa "ENGINE *e" +.Fa "const unsigned char *rawpriv" +.Fa "size_t rawlen" +.Fc +.Ft EVP_PKEY * +.Fo EVP_PKEY_new_raw_public_key +.Fa "int type" +.Fa "ENGINE *e" +.Fa "const unsigned char *rawpub" +.Fa "size_t rawlen" .Fc .Ft EVP_PKEY * .Fo EVP_PKEY_new_CMAC_key .Fa "ENGINE *e" -.Fa "const unsigned char *priv" -.Fa "size_t len" +.Fa "const unsigned char *rawpriv" +.Fa "size_t rawlen" .Fa "const EVP_CIPHER *cipher" .Fc .Ft EVP_PKEY * .Fo EVP_PKEY_new_mac_key .Fa "int type" .Fa "ENGINE *e" -.Fa "const unsigned char *key" -.Fa "int keylen" +.Fa "const unsigned char *rawpriv" +.Fa "int rawlen" +.Fc +.Ft int +.Fo EVP_PKEY_get_raw_private_key +.Fa "const EVP_PKEY *pkey" +.Fa "unsigned char *rawpriv" +.Fa "size_t *rawlen" +.Fc +.Ft int +.Fo EVP_PKEY_get_raw_public_key +.Fa "const EVP_PKEY *pkey" +.Fa "unsigned char *rawpub" +.Fa "size_t *rawlen" .Fc .Sh DESCRIPTION The .Vt EVP_PKEY structure is used by various OpenSSL functions which require a general -private key without reference to any particular algorithm. +private or public key without reference to any particular algorithm. .Pp The .Fn EVP_PKEY_new @@ -103,72 +149,108 @@ To add a private or public key to it, use the functions described in .Pp .Fn EVP_PKEY_up_ref increments the reference count of -.Fa key +.Fa pkey by 1. .Pp .Fn EVP_PKEY_free decrements the reference count of -.Fa key +.Fa pkey by 1, and if the reference count reaches zero, frees it up. If -.Fa key +.Fa pkey is a .Dv NULL pointer, no action occurs. .Pp -.Fn EVP_PKEY_new_CMAC_key +.Fn EVP_PKEY_new_raw_private_key allocates a new -.Vt EVP_PKEY -for the -.Dv EVP_PKEY_CMAC -algorithm type. +.Vt EVP_PKEY . If .Fa e is .Pf non- Dv NULL , -then the new -.Vt EVP_PKEY -is associated with the engine +the new structure is associated with the engine .Fa e . -.Fa priv -points to the raw private key data -of length -.Fa len -for this -.Vt EVP_PKEY . -.Fa cipher -specifies a cipher algorithm to be used during creation of the CMAC. +The NID of a public key algorithm that supports raw private keys, i.e.\& +.Dv EVP_PKEY_HMAC , +.Dv EVP_PKEY_X25519 , +or +.Dv EVP_PKEY_ED25519 , +is provided in the +.Fa type +argument and +.Fa rawlen +bytes of raw private key data of that type in +.Fa rawpriv . +The public key data is automatically derived from the given private +key data, if appropriate for the algorithm type. +.Pp +.Fn EVP_PKEY_new_raw_public_key +works in the same way as +.Fn EVP_PKEY_new_raw_private_key +except that +.Fa rawpub +points to the raw public key data. +The +.Vt EVP_PKEY +structure is initialised without any private key information. +Algorithm types that support raw public keys are +.Dv EVP_PKEY_X25519 +and +.Dv EVP_PKEY_ED25519 . +.Pp +.Fn EVP_PKEY_new_CMAC_key +works in the same way as +.Fn EVP_PKEY_new_raw_private_key +except that it only handles the +.Dv EVP_PKEY_CMAC +algorithm type. +The additional .Fa cipher -should be a standard encryption only cipher. +argument specifies the cipher algorithm +to be used during the creation of the CMAC. +It should be a standard encryption only cipher. For example, AEAD and XTS ciphers should not be used. .Pp .Fn EVP_PKEY_new_mac_key -allocates a new -.Vt EVP_PKEY . -If -.Fa e -is -.Pf non- Dv NULL , -then the new -.Vt EVP_PKEY -structure is associated with the engine -.Fa e . -The -.Fa type -argument indicates what kind of key this is. -The value should be a NID for a public key algorithm that supports -raw private keys, for example -.Dv EVP_PKEY_HMAC . -.Fa key -points to the raw private key data for this -.Vt EVP_PKEY -which should be of length -.Fa keylen . -The length should be appropriate for the type of the key. -The public key data will be automatically derived from the given -private key data (if appropriate for the algorithm type). +is a deprecated function that works in the same way as +.Fn EVP_PKEY_new_raw_private_key . +.Pp +.Fn EVP_PKEY_get_raw_private_key +writes up to +.Pf * Fa rawlen +bytes of raw private key data to the buffer starting at +.Fa rawpriv +and stores the number of bytes written in +.Pf * Fa rawlen . +The calling application is responsible for ensuring that the buffer +is large enough to receive the private key data. +If the +.Fa rawpriv +argument is +.Dv NULL , +the number of bytes required to hold the key is stored in +.Pf * Fa rawlen . +This function only works for algorithms that support raw private keys. +Currently these are +.Dv EVP_PKEY_HMAC , +.Dv EVP_PKEY_X25519 , +and +.Dv EVP_PKEY_ED25519 . +.Pp +.Fn EVP_PKEY_get_raw_public_key +is similar to +.Fn EVP_PKEY_get_raw_private_key +except that it writes raw public key data. +This function only works for algorithms that support raw public keys. +Currently these are +.Dv EVP_PKEY_X25519 +and +.Dv EVP_PKEY_ED25519 . .Sh RETURN VALUES .Fn EVP_PKEY_new , +.Fn EVP_PKEY_new_raw_private_key , +.Fn EVP_PKEY_new_raw_public_key , .Fn EVP_PKEY_new_CMAC_key , and .Fn EVP_PKEY_new_mac_key @@ -178,8 +260,11 @@ structure or .Dv NULL if an error occurred. .Pp -.Fn EVP_PKEY_up_ref -returns 1 for success or 0 for failure. +.Fn EVP_PKEY_up_ref , +.Fn EVP_PKEY_get_raw_private_key , +and +.Fn EVP_PKEY_get_raw_public_key +return 1 for success or 0 for failure. .Sh SEE ALSO .Xr CMAC_Init 3 , .Xr d2i_PrivateKey 3 , @@ -214,3 +299,11 @@ first appeared in OpenSSL 1.0.0 and has been available since .Fn EVP_PKEY_up_ref first appeared in OpenSSL 1.1.0 and has been available since .Ox 6.3 . +.Pp +.Fn EVP_PKEY_new_raw_private_key , +.Fn EVP_PKEY_new_raw_public_key , +.Fn EVP_PKEY_get_raw_private_key , +and +.Fn EVP_PKEY_get_raw_public_key +first appeared in OpenSSL 1.1.1 and have been available since +.Ox 7.3 . diff --git a/man/Makefile.am b/man/Makefile.am index 9ce0a2ea..4c56008b 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -143,6 +143,7 @@ dist_man3_MANS += ASN1_TIME_set.3 dist_man3_MANS += ASN1_TYPE_get.3 dist_man3_MANS += ASN1_UNIVERSALSTRING_to_string.3 dist_man3_MANS += ASN1_bn_print.3 +dist_man3_MANS += ASN1_buf_print.3 dist_man3_MANS += ASN1_generate_nconf.3 dist_man3_MANS += ASN1_get_object.3 dist_man3_MANS += ASN1_item_d2i.3 @@ -158,8 +159,10 @@ dist_man3_MANS += ASN1_time_parse.3 dist_man3_MANS += AUTHORITY_KEYID_new.3 dist_man3_MANS += BASIC_CONSTRAINTS_new.3 dist_man3_MANS += BF_set_key.3 +dist_man3_MANS += BIO_accept.3 dist_man3_MANS += BIO_ctrl.3 dist_man3_MANS += BIO_dump.3 +dist_man3_MANS += BIO_dup_chain.3 dist_man3_MANS += BIO_f_asn1.3 dist_man3_MANS += BIO_f_base64.3 dist_man3_MANS += BIO_f_buffer.3 @@ -179,6 +182,7 @@ dist_man3_MANS += BIO_read.3 dist_man3_MANS += BIO_s_accept.3 dist_man3_MANS += BIO_s_bio.3 dist_man3_MANS += BIO_s_connect.3 +dist_man3_MANS += BIO_s_datagram.3 dist_man3_MANS += BIO_s_fd.3 dist_man3_MANS += BIO_s_file.3 dist_man3_MANS += BIO_s_mem.3 @@ -189,6 +193,7 @@ dist_man3_MANS += BIO_should_retry.3 dist_man3_MANS += BN_BLINDING_new.3 dist_man3_MANS += BN_CTX_new.3 dist_man3_MANS += BN_CTX_start.3 +dist_man3_MANS += BN_GF2m_add.3 dist_man3_MANS += BN_add.3 dist_man3_MANS += BN_add_word.3 dist_man3_MANS += BN_bn2bin.3 @@ -196,10 +201,13 @@ dist_man3_MANS += BN_cmp.3 dist_man3_MANS += BN_copy.3 dist_man3_MANS += BN_generate_prime.3 dist_man3_MANS += BN_get0_nist_prime_521.3 +dist_man3_MANS += BN_kronecker.3 dist_man3_MANS += BN_mod_inverse.3 dist_man3_MANS += BN_mod_mul_montgomery.3 dist_man3_MANS += BN_mod_mul_reciprocal.3 +dist_man3_MANS += BN_mod_sqrt.3 dist_man3_MANS += BN_new.3 +dist_man3_MANS += BN_nist_mod_521.3 dist_man3_MANS += BN_num_bytes.3 dist_man3_MANS += BN_rand.3 dist_man3_MANS += BN_set_bit.3 @@ -289,6 +297,7 @@ dist_man3_MANS += ERR_set_mark.3 dist_man3_MANS += ESS_SIGNING_CERT_new.3 dist_man3_MANS += EVP_AEAD_CTX_init.3 dist_man3_MANS += EVP_BytesToKey.3 +dist_man3_MANS += EVP_CIPHER_meth_new.3 dist_man3_MANS += EVP_DigestInit.3 dist_man3_MANS += EVP_DigestSignInit.3 dist_man3_MANS += EVP_DigestVerifyInit.3 @@ -661,10 +670,15 @@ install-data-hook: ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_GENERALIZEDTIME_set_string.3" ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_adj.3" ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_check.3" + ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_cmp_time_t.3" + ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_compare.3" ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_diff.3" + ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_normalize.3" ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_print.3" ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_set_string.3" + ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_set_string_X509.3" ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_to_generalizedtime.3" + ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_to_tm.3" ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_adj.3" ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_check.3" ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_cmp_time_t.3" @@ -714,6 +728,14 @@ install-data-hook: ln -sf "BF_set_key.3" "$(DESTDIR)$(mandir)/man3/BF_encrypt.3" ln -sf "BF_set_key.3" "$(DESTDIR)$(mandir)/man3/BF_ofb64_encrypt.3" ln -sf "BF_set_key.3" "$(DESTDIR)$(mandir)/man3/BF_options.3" + ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_get_accept_socket.3" + ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_get_host_ip.3" + ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_get_port.3" + ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_set_tcp_ndelay.3" + ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_sock_error.3" + ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_sock_non_fatal_error.3" + ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_sock_should_retry.3" + ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_socket_nbio.3" ln -sf "BIO_ctrl.3" "$(DESTDIR)$(mandir)/man3/BIO_callback_ctrl.3" ln -sf "BIO_ctrl.3" "$(DESTDIR)$(mandir)/man3/BIO_ctrl_pending.3" ln -sf "BIO_ctrl.3" "$(DESTDIR)$(mandir)/man3/BIO_ctrl_wpending.3" @@ -734,6 +756,7 @@ install-data-hook: ln -sf "BIO_dump.3" "$(DESTDIR)$(mandir)/man3/BIO_dump_fp.3" ln -sf "BIO_dump.3" "$(DESTDIR)$(mandir)/man3/BIO_dump_indent.3" ln -sf "BIO_dump.3" "$(DESTDIR)$(mandir)/man3/BIO_dump_indent_fp.3" + ln -sf "BIO_dup_chain.3" "$(DESTDIR)$(mandir)/man3/BIO_dup_state.3" ln -sf "BIO_f_asn1.3" "$(DESTDIR)$(mandir)/man3/BIO_asn1_get_prefix.3" ln -sf "BIO_f_asn1.3" "$(DESTDIR)$(mandir)/man3/BIO_asn1_get_suffix.3" ln -sf "BIO_f_asn1.3" "$(DESTDIR)$(mandir)/man3/BIO_asn1_set_prefix.3" @@ -765,11 +788,24 @@ install-data-hook: ln -sf "BIO_find_type.3" "$(DESTDIR)$(mandir)/man3/BIO_method_name.3" ln -sf "BIO_find_type.3" "$(DESTDIR)$(mandir)/man3/BIO_method_type.3" ln -sf "BIO_find_type.3" "$(DESTDIR)$(mandir)/man3/BIO_next.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_clear_flags.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_clear_retry_flags.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_copy_next_retry.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_get_flags.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_get_init.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_get_retry_flags.3" ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_get_shutdown.3" ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_data.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_flags.3" ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_init.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_retry_read.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_retry_special.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_retry_write.3" ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_shutdown.3" + ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_test_flags.3" + ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/BIO_get_app_data.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/BIO_get_ex_data.3" + ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/BIO_set_app_data.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/BIO_set_ex_data.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/ECDH_get_ex_data.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/ECDH_get_ex_new_index.3" @@ -783,8 +819,10 @@ install-data-hook: ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/ENGINE_get_ex_data.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/ENGINE_get_ex_new_index.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/ENGINE_set_ex_data.3" + ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/TYPE_get_app_data.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/TYPE_get_ex_data.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/TYPE_get_ex_new_index.3" + ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/TYPE_set_app_data.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/TYPE_set_ex_data.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/UI_get_ex_data.3" ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/UI_get_ex_new_index.3" @@ -819,8 +857,11 @@ install-data-hook: ln -sf "BIO_printf.3" "$(DESTDIR)$(mandir)/man3/BIO_vprintf.3" ln -sf "BIO_printf.3" "$(DESTDIR)$(mandir)/man3/BIO_vsnprintf.3" ln -sf "BIO_push.3" "$(DESTDIR)$(mandir)/man3/BIO_pop.3" + ln -sf "BIO_push.3" "$(DESTDIR)$(mandir)/man3/BIO_set_next.3" ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_gets.3" ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_indent.3" + ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_number_read.3" + ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_number_written.3" ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_puts.3" ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_write.3" ln -sf "BIO_s_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_do_accept.3" @@ -853,6 +894,16 @@ install-data-hook: ln -sf "BIO_s_connect.3" "$(DESTDIR)$(mandir)/man3/BIO_set_conn_ip.3" ln -sf "BIO_s_connect.3" "$(DESTDIR)$(mandir)/man3/BIO_set_conn_port.3" ln -sf "BIO_s_connect.3" "$(DESTDIR)$(mandir)/man3/BIO_set_nbio.3" + ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_ctrl_dgram_connect.3" + ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_ctrl_set_connected.3" + ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_dgram_get_peer.3" + ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_dgram_non_fatal_error.3" + ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_dgram_recv_timedout.3" + ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_dgram_send_timedout.3" + ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_dgram_set_peer.3" + ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_new_dgram.3" + ln -sf "BIO_s_fd.3" "$(DESTDIR)$(mandir)/man3/BIO_fd_non_fatal_error.3" + ln -sf "BIO_s_fd.3" "$(DESTDIR)$(mandir)/man3/BIO_fd_should_retry.3" ln -sf "BIO_s_fd.3" "$(DESTDIR)$(mandir)/man3/BIO_get_fd.3" ln -sf "BIO_s_fd.3" "$(DESTDIR)$(mandir)/man3/BIO_new_fd.3" ln -sf "BIO_s_fd.3" "$(DESTDIR)$(mandir)/man3/BIO_set_fd.3" @@ -871,13 +922,17 @@ install-data-hook: ln -sf "BIO_s_mem.3" "$(DESTDIR)$(mandir)/man3/BIO_set_mem_eof_return.3" ln -sf "BIO_s_socket.3" "$(DESTDIR)$(mandir)/man3/BIO_new_socket.3" ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_callback_fn.3" + ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_callback_fn_ex.3" ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_debug_callback.3" ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_get_callback.3" ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_get_callback_arg.3" + ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_get_callback_ex.3" ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_set_callback_arg.3" + ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_set_callback_ex.3" ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_get_retry_BIO.3" ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_get_retry_reason.3" ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_retry_type.3" + ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_set_retry_reason.3" ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_should_io_special.3" ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_should_read.3" ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_should_write.3" @@ -897,6 +952,26 @@ install-data-hook: ln -sf "BN_CTX_new.3" "$(DESTDIR)$(mandir)/man3/BN_CTX_init.3" ln -sf "BN_CTX_start.3" "$(DESTDIR)$(mandir)/man3/BN_CTX_end.3" ln -sf "BN_CTX_start.3" "$(DESTDIR)$(mandir)/man3/BN_CTX_get.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_arr2poly.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_cmp.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_arr.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_div.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_div_arr.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_exp.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_exp_arr.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_inv.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_inv_arr.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_mul.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_mul_arr.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_solve_quad.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_solve_quad_arr.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqr.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqr_arr.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqrt.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqrt_arr.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_poly2arr.3" + ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_sub.3" ln -sf "BN_add.3" "$(DESTDIR)$(mandir)/man3/BN_div.3" ln -sf "BN_add.3" "$(DESTDIR)$(mandir)/man3/BN_exp.3" ln -sf "BN_add.3" "$(DESTDIR)$(mandir)/man3/BN_gcd.3" @@ -971,10 +1046,15 @@ install-data-hook: ln -sf "BN_mod_mul_reciprocal.3" "$(DESTDIR)$(mandir)/man3/BN_RECP_CTX_new.3" ln -sf "BN_mod_mul_reciprocal.3" "$(DESTDIR)$(mandir)/man3/BN_RECP_CTX_set.3" ln -sf "BN_mod_mul_reciprocal.3" "$(DESTDIR)$(mandir)/man3/BN_div_recp.3" + ln -sf "BN_mod_mul_reciprocal.3" "$(DESTDIR)$(mandir)/man3/BN_reciprocal.3" ln -sf "BN_new.3" "$(DESTDIR)$(mandir)/man3/BN_clear.3" ln -sf "BN_new.3" "$(DESTDIR)$(mandir)/man3/BN_clear_free.3" ln -sf "BN_new.3" "$(DESTDIR)$(mandir)/man3/BN_free.3" ln -sf "BN_new.3" "$(DESTDIR)$(mandir)/man3/BN_init.3" + ln -sf "BN_nist_mod_521.3" "$(DESTDIR)$(mandir)/man3/BN_nist_mod_192.3" + ln -sf "BN_nist_mod_521.3" "$(DESTDIR)$(mandir)/man3/BN_nist_mod_224.3" + ln -sf "BN_nist_mod_521.3" "$(DESTDIR)$(mandir)/man3/BN_nist_mod_256.3" + ln -sf "BN_nist_mod_521.3" "$(DESTDIR)$(mandir)/man3/BN_nist_mod_384.3" ln -sf "BN_num_bytes.3" "$(DESTDIR)$(mandir)/man3/BN_num_bits.3" ln -sf "BN_num_bytes.3" "$(DESTDIR)$(mandir)/man3/BN_num_bits_word.3" ln -sf "BN_rand.3" "$(DESTDIR)$(mandir)/man3/BN_pseudo_rand.3" @@ -1109,7 +1189,12 @@ install-data-hook: ln -sf "DH_generate_parameters.3" "$(DESTDIR)$(mandir)/man3/DH_generate_parameters_ex.3" ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_clear_flags.3" ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_engine.3" + ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_g.3" ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_key.3" + ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_p.3" + ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_priv_key.3" + ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_pub_key.3" + ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_q.3" ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_set0_key.3" ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_set0_pqg.3" ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_set_flags.3" @@ -1138,7 +1223,12 @@ install-data-hook: ln -sf "DSA_generate_parameters.3" "$(DESTDIR)$(mandir)/man3/DSA_generate_parameters_ex.3" ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_clear_flags.3" ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_engine.3" + ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_g.3" ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_key.3" + ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_p.3" + ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_priv_key.3" + ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_pub_key.3" + ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_q.3" ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_set0_key.3" ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_set0_pqg.3" ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_set_flags.3" @@ -1164,6 +1254,8 @@ install-data-hook: ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_OpenSSL.3" ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_free.3" ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0.3" + ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0_r.3" + ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0_s.3" ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_set0.3" ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_do_sign.3" ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_do_sign_ex.3" @@ -1439,6 +1531,17 @@ install-data-hook: ln -sf "EVP_AEAD_CTX_init.3" "$(DESTDIR)$(mandir)/man3/EVP_aead_aes_256_gcm.3" ln -sf "EVP_AEAD_CTX_init.3" "$(DESTDIR)$(mandir)/man3/EVP_aead_chacha20_poly1305.3" ln -sf "EVP_AEAD_CTX_init.3" "$(DESTDIR)$(mandir)/man3/EVP_aead_xchacha20_poly1305.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_dup.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_free.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_cleanup.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_ctrl.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_do_cipher.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_flags.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_get_asn1_params.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_impl_ctx_size.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_init.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_iv_length.3" + ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_set_asn1_params.3" ln -sf "EVP_DigestInit.3" "$(DESTDIR)$(mandir)/man3/EVP_Digest.3" ln -sf "EVP_DigestInit.3" "$(DESTDIR)$(mandir)/man3/EVP_DigestFinal.3" ln -sf "EVP_DigestInit.3" "$(DESTDIR)$(mandir)/man3/EVP_DigestFinal_ex.3" @@ -1662,8 +1765,12 @@ install-data-hook: ln -sf "EVP_PKEY_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_meth_set_verify_recover.3" ln -sf "EVP_PKEY_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_meth_set_verifyctx.3" ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_free.3" + ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_get_raw_private_key.3" + ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_get_raw_public_key.3" ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_CMAC_key.3" ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_mac_key.3" + ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_raw_private_key.3" + ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_raw_public_key.3" ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_up_ref.3" ln -sf "EVP_PKEY_print_private.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_print_params.3" ln -sf "EVP_PKEY_print_private.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_print_public.3" @@ -2123,7 +2230,15 @@ install-data-hook: ln -sf "RSA_generate_key.3" "$(DESTDIR)$(mandir)/man3/RSA_generate_key_ex.3" ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_clear_flags.3" ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_crt_params.3" + ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_d.3" + ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_dmp1.3" + ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_dmq1.3" + ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_e.3" ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_factors.3" + ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_iqmp.3" + ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_n.3" + ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_p.3" + ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_q.3" ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_set0_crt_params.3" ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_set0_factors.3" ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_set0_key.3" @@ -2582,9 +2697,13 @@ install-data-hook: ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_get_default_method.3" ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_get_method.3" ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_new_method.3" + ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_null.3" ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_process.3" ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_set_default_method.3" ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_set_method.3" + ln -sf "X25519.3" "$(DESTDIR)$(mandir)/man3/ED25519_keypair.3" + ln -sf "X25519.3" "$(DESTDIR)$(mandir)/man3/ED25519_sign.3" + ln -sf "X25519.3" "$(DESTDIR)$(mandir)/man3/ED25519_verify.3" ln -sf "X25519.3" "$(DESTDIR)$(mandir)/man3/X25519_keypair.3" ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509V3_EXT_d2i.3" ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509V3_EXT_i2d.3" @@ -2597,6 +2716,7 @@ install-data-hook: ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509_REVOKED_get_ext_d2i.3" ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509_add1_ext_i2d.3" ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509_get0_extensions.3" + ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509_get0_uids.3" ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509_get_ext_d2i.3" ln -sf "X509_ALGOR_dup.3" "$(DESTDIR)$(mandir)/man3/X509_ALGOR_cmp.3" ln -sf "X509_ALGOR_dup.3" "$(DESTDIR)$(mandir)/man3/X509_ALGOR_free.3" @@ -2790,8 +2910,17 @@ install-data-hook: ln -sf "X509_STORE_CTX_set_flags.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_purpose.3" ln -sf "X509_STORE_CTX_set_flags.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_time.3" ln -sf "X509_STORE_CTX_set_flags.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_trust.3" + ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_check_issued_fn.3" + ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_check_issued.3" ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_verify.3" + ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_verify_fn.3" + ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_get_check_issued.3" + ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_get_verify.3" + ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_check_issued.3" + ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify.3" + ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_func.3" ln -sf "X509_STORE_CTX_set_verify_cb.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_verify_cb.3" + ln -sf "X509_STORE_CTX_set_verify_cb.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_verify_cb.3" ln -sf "X509_STORE_get_by_subject.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get1_issuer.3" ln -sf "X509_STORE_get_by_subject.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_by_subject.3" ln -sf "X509_STORE_get_by_subject.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_obj_by_subject.3" @@ -2813,6 +2942,7 @@ install-data-hook: ln -sf "X509_STORE_set1_param.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_flags.3" ln -sf "X509_STORE_set1_param.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_purpose.3" ln -sf "X509_STORE_set1_param.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_trust.3" + ln -sf "X509_STORE_set_verify_cb_func.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_get_verify_cb.3" ln -sf "X509_STORE_set_verify_cb_func.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_cb.3" ln -sf "X509_TRUST_set.3" "$(DESTDIR)$(mandir)/man3/X509_TRUST_add.3" ln -sf "X509_TRUST_set.3" "$(DESTDIR)$(mandir)/man3/X509_TRUST_cleanup.3" @@ -2892,6 +3022,7 @@ install-data-hook: ln -sf "X509_get0_notBefore.3" "$(DESTDIR)$(mandir)/man3/X509_set_notAfter.3" ln -sf "X509_get0_notBefore.3" "$(DESTDIR)$(mandir)/man3/X509_set_notBefore.3" ln -sf "X509_get0_signature.3" "$(DESTDIR)$(mandir)/man3/X509_CRL_get0_signature.3" + ln -sf "X509_get0_signature.3" "$(DESTDIR)$(mandir)/man3/X509_CRL_get0_tbs_sigalg.3" ln -sf "X509_get0_signature.3" "$(DESTDIR)$(mandir)/man3/X509_CRL_get_signature_nid.3" ln -sf "X509_get0_signature.3" "$(DESTDIR)$(mandir)/man3/X509_REQ_get0_signature.3" ln -sf "X509_get0_signature.3" "$(DESTDIR)$(mandir)/man3/X509_REQ_get_signature_nid.3" @@ -3001,9 +3132,6 @@ install-data-hook: ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_add_words.3" ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_comba4.3" ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_comba8.3" - ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_high.3" - ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_low_normal.3" - ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_low_recursive.3" ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_normal.3" ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_part_recursive.3" ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_recursive.3" @@ -3367,14 +3495,6 @@ install-data-hook: ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/LHASH_DOALL_ARG_FN_TYPE.3" ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/LHASH_DOALL_FN_TYPE.3" ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/LHASH_HASH_FN_TYPE.3" - ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__delete.3" - ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__doall.3" - ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__doall_arg.3" - ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__error.3" - ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__free.3" - ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__insert.3" - ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__new.3" - ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__retrieve.3" ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh_delete.3" ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh_doall.3" ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh_doall_arg.3" @@ -3570,10 +3690,15 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_GENERALIZEDTIME_set_string.3" -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_adj.3" -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_check.3" + -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_cmp_time_t.3" + -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_compare.3" -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_diff.3" + -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_normalize.3" -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_print.3" -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_set_string.3" + -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_set_string_X509.3" -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_to_generalizedtime.3" + -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_to_tm.3" -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_adj.3" -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_check.3" -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_cmp_time_t.3" @@ -3623,6 +3748,14 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/BF_encrypt.3" -rm -f "$(DESTDIR)$(mandir)/man3/BF_ofb64_encrypt.3" -rm -f "$(DESTDIR)$(mandir)/man3/BF_options.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_accept_socket.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_host_ip.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_port.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_tcp_ndelay.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_sock_error.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_sock_non_fatal_error.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_sock_should_retry.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_socket_nbio.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_callback_ctrl.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_ctrl_pending.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_ctrl_wpending.3" @@ -3643,6 +3776,7 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dump_fp.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dump_indent.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dump_indent_fp.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dup_state.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_asn1_get_prefix.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_asn1_get_suffix.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_asn1_set_prefix.3" @@ -3674,11 +3808,24 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/BIO_method_name.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_method_type.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_next.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_clear_flags.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_clear_retry_flags.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_copy_next_retry.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_flags.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_init.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_retry_flags.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_shutdown.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_data.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_flags.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_init.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_retry_read.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_retry_special.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_retry_write.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_shutdown.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_test_flags.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_app_data.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_ex_data.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_app_data.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_ex_data.3" -rm -f "$(DESTDIR)$(mandir)/man3/ECDH_get_ex_data.3" -rm -f "$(DESTDIR)$(mandir)/man3/ECDH_get_ex_new_index.3" @@ -3692,8 +3839,10 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/ENGINE_get_ex_data.3" -rm -f "$(DESTDIR)$(mandir)/man3/ENGINE_get_ex_new_index.3" -rm -f "$(DESTDIR)$(mandir)/man3/ENGINE_set_ex_data.3" + -rm -f "$(DESTDIR)$(mandir)/man3/TYPE_get_app_data.3" -rm -f "$(DESTDIR)$(mandir)/man3/TYPE_get_ex_data.3" -rm -f "$(DESTDIR)$(mandir)/man3/TYPE_get_ex_new_index.3" + -rm -f "$(DESTDIR)$(mandir)/man3/TYPE_set_app_data.3" -rm -f "$(DESTDIR)$(mandir)/man3/TYPE_set_ex_data.3" -rm -f "$(DESTDIR)$(mandir)/man3/UI_get_ex_data.3" -rm -f "$(DESTDIR)$(mandir)/man3/UI_get_ex_new_index.3" @@ -3728,8 +3877,11 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/BIO_vprintf.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_vsnprintf.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_pop.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_next.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_gets.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_indent.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_number_read.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_number_written.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_puts.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_write.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_do_accept.3" @@ -3762,6 +3914,16 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_conn_ip.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_conn_port.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_nbio.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_ctrl_dgram_connect.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_ctrl_set_connected.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dgram_get_peer.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dgram_non_fatal_error.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dgram_recv_timedout.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dgram_send_timedout.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dgram_set_peer.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_new_dgram.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_fd_non_fatal_error.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_fd_should_retry.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_fd.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_new_fd.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_fd.3" @@ -3780,13 +3942,17 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_mem_eof_return.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_new_socket.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_callback_fn.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_callback_fn_ex.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_debug_callback.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_callback.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_callback_arg.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_callback_ex.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_callback_arg.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_callback_ex.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_retry_BIO.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_retry_reason.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_retry_type.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_retry_reason.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_should_io_special.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_should_read.3" -rm -f "$(DESTDIR)$(mandir)/man3/BIO_should_write.3" @@ -3806,6 +3972,26 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/BN_CTX_init.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_CTX_end.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_CTX_get.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_arr2poly.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_cmp.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_arr.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_div.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_div_arr.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_exp.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_exp_arr.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_inv.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_inv_arr.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_mul.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_mul_arr.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_solve_quad.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_solve_quad_arr.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqr.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqr_arr.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqrt.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqrt_arr.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_poly2arr.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_sub.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_div.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_exp.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_gcd.3" @@ -3880,10 +4066,15 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/BN_RECP_CTX_new.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_RECP_CTX_set.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_div_recp.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_reciprocal.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_clear.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_clear_free.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_free.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_init.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_nist_mod_192.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_nist_mod_224.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_nist_mod_256.3" + -rm -f "$(DESTDIR)$(mandir)/man3/BN_nist_mod_384.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_num_bits.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_num_bits_word.3" -rm -f "$(DESTDIR)$(mandir)/man3/BN_pseudo_rand.3" @@ -4018,7 +4209,12 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/DH_generate_parameters_ex.3" -rm -f "$(DESTDIR)$(mandir)/man3/DH_clear_flags.3" -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_engine.3" + -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_g.3" -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_key.3" + -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_p.3" + -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_priv_key.3" + -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_pub_key.3" + -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_q.3" -rm -f "$(DESTDIR)$(mandir)/man3/DH_set0_key.3" -rm -f "$(DESTDIR)$(mandir)/man3/DH_set0_pqg.3" -rm -f "$(DESTDIR)$(mandir)/man3/DH_set_flags.3" @@ -4047,7 +4243,12 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/DSA_generate_parameters_ex.3" -rm -f "$(DESTDIR)$(mandir)/man3/DSA_clear_flags.3" -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_engine.3" + -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_g.3" -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_key.3" + -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_p.3" + -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_priv_key.3" + -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_pub_key.3" + -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_q.3" -rm -f "$(DESTDIR)$(mandir)/man3/DSA_set0_key.3" -rm -f "$(DESTDIR)$(mandir)/man3/DSA_set0_pqg.3" -rm -f "$(DESTDIR)$(mandir)/man3/DSA_set_flags.3" @@ -4073,6 +4274,8 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_OpenSSL.3" -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_free.3" -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0.3" + -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0_r.3" + -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0_s.3" -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_set0.3" -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_do_sign.3" -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_do_sign_ex.3" @@ -4348,6 +4551,17 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/EVP_aead_aes_256_gcm.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_aead_chacha20_poly1305.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_aead_xchacha20_poly1305.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_dup.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_free.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_cleanup.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_ctrl.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_do_cipher.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_flags.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_get_asn1_params.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_impl_ctx_size.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_init.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_iv_length.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_set_asn1_params.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_Digest.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_DigestFinal.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_DigestFinal_ex.3" @@ -4571,8 +4785,12 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_meth_set_verify_recover.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_meth_set_verifyctx.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_free.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_get_raw_private_key.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_get_raw_public_key.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_CMAC_key.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_mac_key.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_raw_private_key.3" + -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_raw_public_key.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_up_ref.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_print_params.3" -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_print_public.3" @@ -5032,7 +5250,15 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/RSA_generate_key_ex.3" -rm -f "$(DESTDIR)$(mandir)/man3/RSA_clear_flags.3" -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_crt_params.3" + -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_d.3" + -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_dmp1.3" + -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_dmq1.3" + -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_e.3" -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_factors.3" + -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_iqmp.3" + -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_n.3" + -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_p.3" + -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_q.3" -rm -f "$(DESTDIR)$(mandir)/man3/RSA_set0_crt_params.3" -rm -f "$(DESTDIR)$(mandir)/man3/RSA_set0_factors.3" -rm -f "$(DESTDIR)$(mandir)/man3/RSA_set0_key.3" @@ -5491,9 +5717,13 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/UI_get_default_method.3" -rm -f "$(DESTDIR)$(mandir)/man3/UI_get_method.3" -rm -f "$(DESTDIR)$(mandir)/man3/UI_new_method.3" + -rm -f "$(DESTDIR)$(mandir)/man3/UI_null.3" -rm -f "$(DESTDIR)$(mandir)/man3/UI_process.3" -rm -f "$(DESTDIR)$(mandir)/man3/UI_set_default_method.3" -rm -f "$(DESTDIR)$(mandir)/man3/UI_set_method.3" + -rm -f "$(DESTDIR)$(mandir)/man3/ED25519_keypair.3" + -rm -f "$(DESTDIR)$(mandir)/man3/ED25519_sign.3" + -rm -f "$(DESTDIR)$(mandir)/man3/ED25519_verify.3" -rm -f "$(DESTDIR)$(mandir)/man3/X25519_keypair.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509V3_EXT_d2i.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509V3_EXT_i2d.3" @@ -5506,6 +5736,7 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/X509_REVOKED_get_ext_d2i.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_add1_ext_i2d.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_get0_extensions.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_get0_uids.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_get_ext_d2i.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_ALGOR_cmp.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_ALGOR_free.3" @@ -5699,8 +5930,17 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_purpose.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_time.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_trust.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_check_issued_fn.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_check_issued.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_verify.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_verify_fn.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_get_check_issued.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_get_verify.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_check_issued.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_func.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_verify_cb.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_verify_cb.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get1_issuer.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_by_subject.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_obj_by_subject.3" @@ -5722,6 +5962,7 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_flags.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_purpose.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_trust.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_get_verify_cb.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_cb.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_TRUST_add.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_TRUST_cleanup.3" @@ -5801,6 +6042,7 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/X509_set_notAfter.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_set_notBefore.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_CRL_get0_signature.3" + -rm -f "$(DESTDIR)$(mandir)/man3/X509_CRL_get0_tbs_sigalg.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_CRL_get_signature_nid.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_REQ_get0_signature.3" -rm -f "$(DESTDIR)$(mandir)/man3/X509_REQ_get_signature_nid.3" @@ -5910,9 +6152,6 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_add_words.3" -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_comba4.3" -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_comba8.3" - -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_high.3" - -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_low_normal.3" - -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_low_recursive.3" -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_normal.3" -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_part_recursive.3" -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_recursive.3" @@ -6276,14 +6515,6 @@ uninstall-local: -rm -f "$(DESTDIR)$(mandir)/man3/LHASH_DOALL_ARG_FN_TYPE.3" -rm -f "$(DESTDIR)$(mandir)/man3/LHASH_DOALL_FN_TYPE.3" -rm -f "$(DESTDIR)$(mandir)/man3/LHASH_HASH_FN_TYPE.3" - -rm -f "$(DESTDIR)$(mandir)/man3/lh__delete.3" - -rm -f "$(DESTDIR)$(mandir)/man3/lh__doall.3" - -rm -f "$(DESTDIR)$(mandir)/man3/lh__doall_arg.3" - -rm -f "$(DESTDIR)$(mandir)/man3/lh__error.3" - -rm -f "$(DESTDIR)$(mandir)/man3/lh__free.3" - -rm -f "$(DESTDIR)$(mandir)/man3/lh__insert.3" - -rm -f "$(DESTDIR)$(mandir)/man3/lh__new.3" - -rm -f "$(DESTDIR)$(mandir)/man3/lh__retrieve.3" -rm -f "$(DESTDIR)$(mandir)/man3/lh_delete.3" -rm -f "$(DESTDIR)$(mandir)/man3/lh_doall.3" -rm -f "$(DESTDIR)$(mandir)/man3/lh_doall_arg.3" diff --git a/man/Makefile.in b/man/Makefile.in index 36eba9f1..1e28800c 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -407,7 +407,7 @@ EXTRA_DIST = CMakeLists.txt @ENABLE_LIBTLS_ONLY_FALSE@ ASN1_STRING_print_ex.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ ASN1_TIME_set.3 ASN1_TYPE_get.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ ASN1_UNIVERSALSTRING_to_string.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ ASN1_bn_print.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ ASN1_bn_print.3 ASN1_buf_print.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ ASN1_generate_nconf.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ ASN1_get_object.3 ASN1_item_d2i.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ ASN1_item_digest.3 ASN1_item_new.3 \ @@ -418,7 +418,8 @@ EXTRA_DIST = CMakeLists.txt @ENABLE_LIBTLS_ONLY_FALSE@ ASN1_time_parse.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ AUTHORITY_KEYID_new.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BASIC_CONSTRAINTS_new.3 BF_set_key.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BIO_ctrl.3 BIO_dump.3 BIO_f_asn1.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BIO_accept.3 BIO_ctrl.3 BIO_dump.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BIO_dup_chain.3 BIO_f_asn1.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BIO_f_base64.3 BIO_f_buffer.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BIO_f_cipher.3 BIO_f_md.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BIO_f_null.3 BIO_find_type.3 \ @@ -428,23 +429,25 @@ EXTRA_DIST = CMakeLists.txt @ENABLE_LIBTLS_ONLY_FALSE@ BIO_new_CMS.3 BIO_new_NDEF.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BIO_printf.3 BIO_push.3 BIO_read.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BIO_s_accept.3 BIO_s_bio.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BIO_s_connect.3 BIO_s_fd.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BIO_s_file.3 BIO_s_mem.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BIO_s_connect.3 BIO_s_datagram.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BIO_s_fd.3 BIO_s_file.3 BIO_s_mem.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BIO_s_null.3 BIO_s_socket.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BIO_set_callback.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BIO_should_retry.3 BN_BLINDING_new.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BN_CTX_new.3 BN_CTX_start.3 BN_add.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BN_add_word.3 BN_bn2bin.3 BN_cmp.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BN_copy.3 BN_generate_prime.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_CTX_new.3 BN_CTX_start.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_GF2m_add.3 BN_add.3 BN_add_word.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_bn2bin.3 BN_cmp.3 BN_copy.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_generate_prime.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BN_get0_nist_prime_521.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BN_mod_inverse.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_kronecker.3 BN_mod_inverse.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ BN_mod_mul_montgomery.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BN_mod_mul_reciprocal.3 BN_new.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BN_num_bytes.3 BN_rand.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BN_set_bit.3 BN_set_flags.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BN_set_negative.3 BN_swap.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ BN_zero.3 BUF_MEM_new.3 CMAC_Init.3 \ -@ENABLE_LIBTLS_ONLY_FALSE@ CMS_ContentInfo_new.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_mod_mul_reciprocal.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_mod_sqrt.3 BN_new.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_nist_mod_521.3 BN_num_bytes.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_rand.3 BN_set_bit.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_set_flags.3 BN_set_negative.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ BN_swap.3 BN_zero.3 BUF_MEM_new.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ CMAC_Init.3 CMS_ContentInfo_new.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ CMS_add0_cert.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ CMS_add1_recipient_cert.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ CMS_add1_signer.3 CMS_compress.3 \ @@ -498,6 +501,7 @@ EXTRA_DIST = CMakeLists.txt @ENABLE_LIBTLS_ONLY_FALSE@ ERR_remove_state.3 ERR_set_mark.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ ESS_SIGNING_CERT_new.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ EVP_AEAD_CTX_init.3 EVP_BytesToKey.3 \ +@ENABLE_LIBTLS_ONLY_FALSE@ EVP_CIPHER_meth_new.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ EVP_DigestInit.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ EVP_DigestSignInit.3 \ @ENABLE_LIBTLS_ONLY_FALSE@ EVP_DigestVerifyInit.3 \ @@ -1074,10 +1078,15 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_GENERALIZEDTIME_set_string.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_adj.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_check.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_cmp_time_t.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_compare.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_diff.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_normalize.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_print.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_set_string.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_set_string_X509.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_to_generalizedtime.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_TIME_to_tm.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_adj.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_check.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ASN1_TIME_set.3" "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_cmp_time_t.3" @@ -1127,6 +1136,14 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BF_set_key.3" "$(DESTDIR)$(mandir)/man3/BF_encrypt.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BF_set_key.3" "$(DESTDIR)$(mandir)/man3/BF_ofb64_encrypt.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BF_set_key.3" "$(DESTDIR)$(mandir)/man3/BF_options.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_get_accept_socket.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_get_host_ip.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_get_port.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_set_tcp_ndelay.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_sock_error.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_sock_non_fatal_error.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_sock_should_retry.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_socket_nbio.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_ctrl.3" "$(DESTDIR)$(mandir)/man3/BIO_callback_ctrl.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_ctrl.3" "$(DESTDIR)$(mandir)/man3/BIO_ctrl_pending.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_ctrl.3" "$(DESTDIR)$(mandir)/man3/BIO_ctrl_wpending.3" @@ -1147,6 +1164,7 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_dump.3" "$(DESTDIR)$(mandir)/man3/BIO_dump_fp.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_dump.3" "$(DESTDIR)$(mandir)/man3/BIO_dump_indent.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_dump.3" "$(DESTDIR)$(mandir)/man3/BIO_dump_indent_fp.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_dup_chain.3" "$(DESTDIR)$(mandir)/man3/BIO_dup_state.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_f_asn1.3" "$(DESTDIR)$(mandir)/man3/BIO_asn1_get_prefix.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_f_asn1.3" "$(DESTDIR)$(mandir)/man3/BIO_asn1_get_suffix.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_f_asn1.3" "$(DESTDIR)$(mandir)/man3/BIO_asn1_set_prefix.3" @@ -1178,11 +1196,24 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_find_type.3" "$(DESTDIR)$(mandir)/man3/BIO_method_name.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_find_type.3" "$(DESTDIR)$(mandir)/man3/BIO_method_type.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_find_type.3" "$(DESTDIR)$(mandir)/man3/BIO_next.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_clear_flags.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_clear_retry_flags.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_copy_next_retry.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_get_flags.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_get_init.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_get_retry_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_get_shutdown.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_data.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_init.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_retry_read.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_retry_special.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_retry_write.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_set_shutdown.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_data.3" "$(DESTDIR)$(mandir)/man3/BIO_test_flags.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/BIO_get_app_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/BIO_get_ex_data.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/BIO_set_app_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/BIO_set_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/ECDH_get_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/ECDH_get_ex_new_index.3" @@ -1196,8 +1227,10 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/ENGINE_get_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/ENGINE_get_ex_new_index.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/ENGINE_set_ex_data.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/TYPE_get_app_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/TYPE_get_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/TYPE_get_ex_new_index.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/TYPE_set_app_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/TYPE_set_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/UI_get_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_get_ex_new_index.3" "$(DESTDIR)$(mandir)/man3/UI_get_ex_new_index.3" @@ -1232,8 +1265,11 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_printf.3" "$(DESTDIR)$(mandir)/man3/BIO_vprintf.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_printf.3" "$(DESTDIR)$(mandir)/man3/BIO_vsnprintf.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_push.3" "$(DESTDIR)$(mandir)/man3/BIO_pop.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_push.3" "$(DESTDIR)$(mandir)/man3/BIO_set_next.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_gets.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_indent.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_number_read.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_number_written.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_puts.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_read.3" "$(DESTDIR)$(mandir)/man3/BIO_write.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_accept.3" "$(DESTDIR)$(mandir)/man3/BIO_do_accept.3" @@ -1266,6 +1302,16 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_connect.3" "$(DESTDIR)$(mandir)/man3/BIO_set_conn_ip.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_connect.3" "$(DESTDIR)$(mandir)/man3/BIO_set_conn_port.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_connect.3" "$(DESTDIR)$(mandir)/man3/BIO_set_nbio.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_ctrl_dgram_connect.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_ctrl_set_connected.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_dgram_get_peer.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_dgram_non_fatal_error.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_dgram_recv_timedout.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_dgram_send_timedout.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_dgram_set_peer.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_datagram.3" "$(DESTDIR)$(mandir)/man3/BIO_new_dgram.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_fd.3" "$(DESTDIR)$(mandir)/man3/BIO_fd_non_fatal_error.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_fd.3" "$(DESTDIR)$(mandir)/man3/BIO_fd_should_retry.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_fd.3" "$(DESTDIR)$(mandir)/man3/BIO_get_fd.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_fd.3" "$(DESTDIR)$(mandir)/man3/BIO_new_fd.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_fd.3" "$(DESTDIR)$(mandir)/man3/BIO_set_fd.3" @@ -1284,13 +1330,17 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_mem.3" "$(DESTDIR)$(mandir)/man3/BIO_set_mem_eof_return.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_s_socket.3" "$(DESTDIR)$(mandir)/man3/BIO_new_socket.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_callback_fn.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_callback_fn_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_debug_callback.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_get_callback.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_get_callback_arg.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_get_callback_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_set_callback_arg.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_set_callback.3" "$(DESTDIR)$(mandir)/man3/BIO_set_callback_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_get_retry_BIO.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_get_retry_reason.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_retry_type.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_set_retry_reason.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_should_io_special.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_should_read.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BIO_should_retry.3" "$(DESTDIR)$(mandir)/man3/BIO_should_write.3" @@ -1310,6 +1360,26 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_CTX_new.3" "$(DESTDIR)$(mandir)/man3/BN_CTX_init.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_CTX_start.3" "$(DESTDIR)$(mandir)/man3/BN_CTX_end.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_CTX_start.3" "$(DESTDIR)$(mandir)/man3/BN_CTX_get.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_arr2poly.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_cmp.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_div.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_div_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_exp.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_exp_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_inv.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_inv_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_mul.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_mul_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_solve_quad.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_solve_quad_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqr_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqrt.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqrt_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_poly2arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_GF2m_add.3" "$(DESTDIR)$(mandir)/man3/BN_GF2m_sub.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_add.3" "$(DESTDIR)$(mandir)/man3/BN_div.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_add.3" "$(DESTDIR)$(mandir)/man3/BN_exp.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_add.3" "$(DESTDIR)$(mandir)/man3/BN_gcd.3" @@ -1384,10 +1454,15 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_mod_mul_reciprocal.3" "$(DESTDIR)$(mandir)/man3/BN_RECP_CTX_new.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_mod_mul_reciprocal.3" "$(DESTDIR)$(mandir)/man3/BN_RECP_CTX_set.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_mod_mul_reciprocal.3" "$(DESTDIR)$(mandir)/man3/BN_div_recp.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_mod_mul_reciprocal.3" "$(DESTDIR)$(mandir)/man3/BN_reciprocal.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_new.3" "$(DESTDIR)$(mandir)/man3/BN_clear.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_new.3" "$(DESTDIR)$(mandir)/man3/BN_clear_free.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_new.3" "$(DESTDIR)$(mandir)/man3/BN_free.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_new.3" "$(DESTDIR)$(mandir)/man3/BN_init.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_nist_mod_521.3" "$(DESTDIR)$(mandir)/man3/BN_nist_mod_192.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_nist_mod_521.3" "$(DESTDIR)$(mandir)/man3/BN_nist_mod_224.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_nist_mod_521.3" "$(DESTDIR)$(mandir)/man3/BN_nist_mod_256.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_nist_mod_521.3" "$(DESTDIR)$(mandir)/man3/BN_nist_mod_384.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_num_bytes.3" "$(DESTDIR)$(mandir)/man3/BN_num_bits.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_num_bytes.3" "$(DESTDIR)$(mandir)/man3/BN_num_bits_word.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "BN_rand.3" "$(DESTDIR)$(mandir)/man3/BN_pseudo_rand.3" @@ -1522,7 +1597,12 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_generate_parameters.3" "$(DESTDIR)$(mandir)/man3/DH_generate_parameters_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_clear_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_engine.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_g.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_p.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_priv_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_pub_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_get0_q.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_set0_key.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_set0_pqg.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DH_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DH_set_flags.3" @@ -1551,7 +1631,12 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_generate_parameters.3" "$(DESTDIR)$(mandir)/man3/DSA_generate_parameters_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_clear_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_engine.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_g.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_p.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_priv_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_pub_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_get0_q.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_set0_key.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_set0_pqg.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "DSA_get0_pqg.3" "$(DESTDIR)$(mandir)/man3/DSA_set_flags.3" @@ -1577,6 +1662,8 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_OpenSSL.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_free.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0_r.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0_s.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_set0.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_do_sign.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "ECDSA_SIG_new.3" "$(DESTDIR)$(mandir)/man3/ECDSA_do_sign_ex.3" @@ -1852,6 +1939,17 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_AEAD_CTX_init.3" "$(DESTDIR)$(mandir)/man3/EVP_aead_aes_256_gcm.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_AEAD_CTX_init.3" "$(DESTDIR)$(mandir)/man3/EVP_aead_chacha20_poly1305.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_AEAD_CTX_init.3" "$(DESTDIR)$(mandir)/man3/EVP_aead_xchacha20_poly1305.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_dup.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_free.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_cleanup.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_ctrl.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_do_cipher.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_flags.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_get_asn1_params.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_impl_ctx_size.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_init.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_iv_length.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_CIPHER_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_set_asn1_params.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_DigestInit.3" "$(DESTDIR)$(mandir)/man3/EVP_Digest.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_DigestInit.3" "$(DESTDIR)$(mandir)/man3/EVP_DigestFinal.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_DigestInit.3" "$(DESTDIR)$(mandir)/man3/EVP_DigestFinal_ex.3" @@ -2075,8 +2173,12 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_meth_set_verify_recover.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_meth_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_meth_set_verifyctx.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_free.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_get_raw_private_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_get_raw_public_key.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_CMAC_key.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_mac_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_raw_private_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_raw_public_key.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_new.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_up_ref.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_print_private.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_print_params.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "EVP_PKEY_print_private.3" "$(DESTDIR)$(mandir)/man3/EVP_PKEY_print_public.3" @@ -2536,7 +2638,15 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_generate_key.3" "$(DESTDIR)$(mandir)/man3/RSA_generate_key_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_clear_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_crt_params.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_d.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_dmp1.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_dmq1.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_e.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_factors.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_iqmp.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_n.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_p.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_get0_q.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_set0_crt_params.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_set0_factors.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "RSA_get0_key.3" "$(DESTDIR)$(mandir)/man3/RSA_set0_key.3" @@ -2995,9 +3105,13 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_get_default_method.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_get_method.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_new_method.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_null.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_process.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_set_default_method.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "UI_new.3" "$(DESTDIR)$(mandir)/man3/UI_set_method.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X25519.3" "$(DESTDIR)$(mandir)/man3/ED25519_keypair.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X25519.3" "$(DESTDIR)$(mandir)/man3/ED25519_sign.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X25519.3" "$(DESTDIR)$(mandir)/man3/ED25519_verify.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X25519.3" "$(DESTDIR)$(mandir)/man3/X25519_keypair.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509V3_EXT_d2i.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509V3_EXT_i2d.3" @@ -3010,6 +3124,7 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509_REVOKED_get_ext_d2i.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509_add1_ext_i2d.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509_get0_extensions.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509_get0_uids.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509V3_get_d2i.3" "$(DESTDIR)$(mandir)/man3/X509_get_ext_d2i.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_ALGOR_dup.3" "$(DESTDIR)$(mandir)/man3/X509_ALGOR_cmp.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_ALGOR_dup.3" "$(DESTDIR)$(mandir)/man3/X509_ALGOR_free.3" @@ -3203,8 +3318,17 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_flags.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_purpose.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_flags.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_time.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_flags.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_trust.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_check_issued_fn.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_check_issued.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_verify.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_verify_fn.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_get_check_issued.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_get_verify.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_check_issued.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_func.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify_cb.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_verify_cb.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_CTX_set_verify_cb.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_verify_cb.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_get_by_subject.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get1_issuer.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_get_by_subject.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_by_subject.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_get_by_subject.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_obj_by_subject.3" @@ -3226,6 +3350,7 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_set1_param.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_set1_param.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_purpose.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_set1_param.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_trust.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_set_verify_cb_func.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_get_verify_cb.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_STORE_set_verify_cb_func.3" "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_cb.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_TRUST_set.3" "$(DESTDIR)$(mandir)/man3/X509_TRUST_add.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_TRUST_set.3" "$(DESTDIR)$(mandir)/man3/X509_TRUST_cleanup.3" @@ -3305,6 +3430,7 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_get0_notBefore.3" "$(DESTDIR)$(mandir)/man3/X509_set_notAfter.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_get0_notBefore.3" "$(DESTDIR)$(mandir)/man3/X509_set_notBefore.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_get0_signature.3" "$(DESTDIR)$(mandir)/man3/X509_CRL_get0_signature.3" +@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_get0_signature.3" "$(DESTDIR)$(mandir)/man3/X509_CRL_get0_tbs_sigalg.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_get0_signature.3" "$(DESTDIR)$(mandir)/man3/X509_CRL_get_signature_nid.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_get0_signature.3" "$(DESTDIR)$(mandir)/man3/X509_REQ_get0_signature.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "X509_get0_signature.3" "$(DESTDIR)$(mandir)/man3/X509_REQ_get_signature_nid.3" @@ -3414,9 +3540,6 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_add_words.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_comba4.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_comba8.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_high.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_low_normal.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_low_recursive.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_normal.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_part_recursive.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "bn_dump.3" "$(DESTDIR)$(mandir)/man3/bn_mul_recursive.3" @@ -3780,14 +3903,6 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/LHASH_DOALL_ARG_FN_TYPE.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/LHASH_DOALL_FN_TYPE.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/LHASH_HASH_FN_TYPE.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__delete.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__doall.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__doall_arg.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__error.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__free.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__insert.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__new.3" -@ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh__retrieve.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh_delete.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh_doall.3" @ENABLE_LIBTLS_ONLY_FALSE@ ln -sf "lh_new.3" "$(DESTDIR)$(mandir)/man3/lh_doall_arg.3" @@ -3983,10 +4098,15 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_GENERALIZEDTIME_set_string.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_adj.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_check.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_cmp_time_t.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_compare.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_diff.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_normalize.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_print.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_set_string.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_set_string_X509.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_to_generalizedtime.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_TIME_to_tm.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_adj.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_check.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ASN1_UTCTIME_cmp_time_t.3" @@ -4036,6 +4156,14 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BF_encrypt.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BF_ofb64_encrypt.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BF_options.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_accept_socket.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_host_ip.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_port.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_tcp_ndelay.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_sock_error.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_sock_non_fatal_error.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_sock_should_retry.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_socket_nbio.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_callback_ctrl.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_ctrl_pending.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_ctrl_wpending.3" @@ -4056,6 +4184,7 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dump_fp.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dump_indent.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dump_indent_fp.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dup_state.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_asn1_get_prefix.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_asn1_get_suffix.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_asn1_set_prefix.3" @@ -4087,11 +4216,24 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_method_name.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_method_type.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_next.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_clear_flags.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_clear_retry_flags.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_copy_next_retry.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_flags.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_init.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_retry_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_shutdown.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_data.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_init.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_retry_read.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_retry_special.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_retry_write.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_shutdown.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_test_flags.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_app_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_ex_data.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_app_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ECDH_get_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ECDH_get_ex_new_index.3" @@ -4105,8 +4247,10 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ENGINE_get_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ENGINE_get_ex_new_index.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ENGINE_set_ex_data.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/TYPE_get_app_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/TYPE_get_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/TYPE_get_ex_new_index.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/TYPE_set_app_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/TYPE_set_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/UI_get_ex_data.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/UI_get_ex_new_index.3" @@ -4141,8 +4285,11 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_vprintf.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_vsnprintf.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_pop.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_next.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_gets.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_indent.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_number_read.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_number_written.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_puts.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_write.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_do_accept.3" @@ -4175,6 +4322,16 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_conn_ip.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_conn_port.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_nbio.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_ctrl_dgram_connect.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_ctrl_set_connected.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dgram_get_peer.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dgram_non_fatal_error.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dgram_recv_timedout.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dgram_send_timedout.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_dgram_set_peer.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_new_dgram.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_fd_non_fatal_error.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_fd_should_retry.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_fd.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_new_fd.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_fd.3" @@ -4193,13 +4350,17 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_mem_eof_return.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_new_socket.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_callback_fn.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_callback_fn_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_debug_callback.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_callback.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_callback_arg.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_callback_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_callback_arg.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_callback_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_retry_BIO.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_get_retry_reason.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_retry_type.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_set_retry_reason.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_should_io_special.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_should_read.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BIO_should_write.3" @@ -4219,6 +4380,26 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_CTX_init.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_CTX_end.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_CTX_get.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_arr2poly.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_cmp.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_div.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_div_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_exp.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_exp_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_inv.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_inv_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_mul.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_mul_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_solve_quad.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_solve_quad_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqr_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqrt.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_mod_sqrt_arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_poly2arr.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_GF2m_sub.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_div.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_exp.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_gcd.3" @@ -4293,10 +4474,15 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_RECP_CTX_new.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_RECP_CTX_set.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_div_recp.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_reciprocal.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_clear.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_clear_free.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_free.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_init.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_nist_mod_192.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_nist_mod_224.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_nist_mod_256.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_nist_mod_384.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_num_bits.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_num_bits_word.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/BN_pseudo_rand.3" @@ -4431,7 +4617,12 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_generate_parameters_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_clear_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_engine.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_g.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_p.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_priv_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_pub_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_get0_q.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_set0_key.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_set0_pqg.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DH_set_flags.3" @@ -4460,7 +4651,12 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_generate_parameters_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_clear_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_engine.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_g.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_p.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_priv_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_pub_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_get0_q.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_set0_key.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_set0_pqg.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/DSA_set_flags.3" @@ -4486,6 +4682,8 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_OpenSSL.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_free.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0_r.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_get0_s.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_SIG_set0.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_do_sign.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ECDSA_do_sign_ex.3" @@ -4761,6 +4959,17 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_aead_aes_256_gcm.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_aead_chacha20_poly1305.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_aead_xchacha20_poly1305.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_dup.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_free.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_cleanup.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_ctrl.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_do_cipher.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_flags.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_get_asn1_params.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_impl_ctx_size.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_init.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_iv_length.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_CIPHER_meth_set_set_asn1_params.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_Digest.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_DigestFinal.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_DigestFinal_ex.3" @@ -4984,8 +5193,12 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_meth_set_verify_recover.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_meth_set_verifyctx.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_free.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_get_raw_private_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_get_raw_public_key.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_CMAC_key.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_mac_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_raw_private_key.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_new_raw_public_key.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_up_ref.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_print_params.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/EVP_PKEY_print_public.3" @@ -5445,7 +5658,15 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_generate_key_ex.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_clear_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_crt_params.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_d.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_dmp1.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_dmq1.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_e.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_factors.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_iqmp.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_n.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_p.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_get0_q.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_set0_crt_params.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_set0_factors.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/RSA_set0_key.3" @@ -5904,9 +6125,13 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/UI_get_default_method.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/UI_get_method.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/UI_new_method.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/UI_null.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/UI_process.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/UI_set_default_method.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/UI_set_method.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ED25519_keypair.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ED25519_sign.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/ED25519_verify.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X25519_keypair.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509V3_EXT_d2i.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509V3_EXT_i2d.3" @@ -5919,6 +6144,7 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_REVOKED_get_ext_d2i.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_add1_ext_i2d.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_get0_extensions.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_get0_uids.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_get_ext_d2i.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_ALGOR_cmp.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_ALGOR_free.3" @@ -6112,8 +6338,17 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_purpose.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_time.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_set_trust.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_check_issued_fn.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_check_issued.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_verify.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_verify_fn.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_get_check_issued.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_get_verify.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_check_issued.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_func.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_verify_cb.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_verify_cb.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get1_issuer.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_by_subject.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_CTX_get_obj_by_subject.3" @@ -6135,6 +6370,7 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_flags.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_purpose.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_trust.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_get_verify_cb.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_STORE_set_verify_cb.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_TRUST_add.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_TRUST_cleanup.3" @@ -6214,6 +6450,7 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_set_notAfter.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_set_notBefore.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_CRL_get0_signature.3" +@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_CRL_get0_tbs_sigalg.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_CRL_get_signature_nid.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_REQ_get0_signature.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/X509_REQ_get_signature_nid.3" @@ -6323,9 +6560,6 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_add_words.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_comba4.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_comba8.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_high.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_low_normal.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_low_recursive.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_normal.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_part_recursive.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/bn_mul_recursive.3" @@ -6689,14 +6923,6 @@ uninstall-man: uninstall-man3 uninstall-man5 @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/LHASH_DOALL_ARG_FN_TYPE.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/LHASH_DOALL_FN_TYPE.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/LHASH_HASH_FN_TYPE.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh__delete.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh__doall.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh__doall_arg.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh__error.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh__free.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh__insert.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh__new.3" -@ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh__retrieve.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh_delete.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh_doall.3" @ENABLE_LIBTLS_ONLY_FALSE@ -rm -f "$(DESTDIR)$(mandir)/man3/lh_doall_arg.3" diff --git a/man/OPENSSL_malloc.3 b/man/OPENSSL_malloc.3 index e6dba165..87f8d81e 100644 --- a/man/OPENSSL_malloc.3 +++ b/man/OPENSSL_malloc.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OPENSSL_malloc.3,v 1.9 2019/06/10 09:49:48 schwarze Exp $ +.\" $OpenBSD: OPENSSL_malloc.3,v 1.10 2022/11/06 18:31:15 tb Exp $ .\" .\" Copyright (c) 2016 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 10 2019 $ +.Dd $Mdocdate: November 6 2022 $ .Dt OPENSSL_MALLOC 3 .Os .Sh NAME @@ -108,3 +108,7 @@ and .Fn OPENSSL_strdup first appeared in OpenSSL 0.9.8j and have been available since .Ox 4.5 . +.Sh CAVEATS +If interoperability with other implementations is required, +memory returned by the library as bare pointers must be freed with +.Fn OPENSSL_free . diff --git a/man/PKCS7_dataFinal.3 b/man/PKCS7_dataFinal.3 index e2e088d9..1a01b2ff 100644 --- a/man/PKCS7_dataFinal.3 +++ b/man/PKCS7_dataFinal.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: PKCS7_dataFinal.3,v 1.2 2020/06/03 13:41:27 schwarze Exp $ +.\" $OpenBSD: PKCS7_dataFinal.3,v 1.3 2022/12/26 07:18:52 jmc Exp $ .\" .\" Copyright (c) 2020 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 3 2020 $ +.Dd $Mdocdate: December 26 2022 $ .Dt PKCS7_DATAFINAL 3 .Os .Sh NAME @@ -122,7 +122,7 @@ Signing or digesting is requested and is not configured to store a detached signature, but does not contain the required field to store the content either. .It -At least one signer lacks a useable digest algorithm. +At least one signer lacks a usable digest algorithm. .It Signing or digesting fails. .It diff --git a/man/PKCS7_final.3 b/man/PKCS7_final.3 index 7c9e5152..775b84d9 100644 --- a/man/PKCS7_final.3 +++ b/man/PKCS7_final.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: PKCS7_final.3,v 1.2 2020/06/04 10:24:27 schwarze Exp $ +.\" $OpenBSD: PKCS7_final.3,v 1.3 2022/12/26 07:18:52 jmc Exp $ .\" .\" Copyright (c) 2020 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 4 2020 $ +.Dd $Mdocdate: December 26 2022 $ .Dt PKCS7_FINAL 3 .Os .Sh NAME @@ -172,7 +172,7 @@ Signing or digesting is requested and is not configured to store a detached signature, but does not contain the required field to store the content either. .It -At least one signer lacks a useable digest algorithm. +At least one signer lacks a usable digest algorithm. .It A cipher is required but none is configured. .It diff --git a/man/RSA_get0_key.3 b/man/RSA_get0_key.3 index 9b58fad8..3fb74b19 100644 --- a/man/RSA_get0_key.3 +++ b/man/RSA_get0_key.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: RSA_get0_key.3,v 1.6 2019/07/13 17:26:38 schwarze Exp $ +.\" $OpenBSD: RSA_get0_key.3,v 1.7 2023/03/06 13:05:32 tb Exp $ .\" selective merge up to: OpenSSL 665d899f Aug 2 02:19:43 2017 +0800 .\" .\" This file is a derived work. @@ -65,15 +65,23 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 13 2019 $ +.Dd $Mdocdate: March 6 2023 $ .Dt RSA_GET0_KEY 3 .Os .Sh NAME .Nm RSA_get0_key , +.Nm RSA_get0_n , +.Nm RSA_get0_e , +.Nm RSA_get0_d , .Nm RSA_set0_key , .Nm RSA_get0_factors , +.Nm RSA_get0_p , +.Nm RSA_get0_q , .Nm RSA_set0_factors , .Nm RSA_get0_crt_params , +.Nm RSA_get0_dmp1 , +.Nm RSA_get0_dmq1 , +.Nm RSA_get0_iqmp , .Nm RSA_set0_crt_params , .Nm RSA_clear_flags , .Nm RSA_test_flags , @@ -88,6 +96,18 @@ .Fa "const BIGNUM **e" .Fa "const BIGNUM **d" .Fc +.Ft "const BIGNUM *" +.Fo RSA_get0_n +.Fa "const RSA *r" +.Fc +.Ft "const BIGNUM *" +.Fo RSA_get0_e +.Fa "const RSA *r" +.Fc +.Ft "const BIGNUM *" +.Fo RSA_get0_d +.Fa "const RSA *r" +.Fc .Ft int .Fo RSA_set0_key .Fa "RSA *r" @@ -101,6 +121,14 @@ .Fa "const BIGNUM **p" .Fa "const BIGNUM **q" .Fc +.Ft "const BIGNUM *" +.Fo RSA_get0_p +.Fa "const RSA *r" +.Fc +.Ft "const BIGNUM *" +.Fo RSA_get0_q +.Fa "const RSA *r" +.Fc .Ft int .Fo RSA_set0_factors .Fa "RSA *r" @@ -114,6 +142,18 @@ .Fa "const BIGNUM **dmq1" .Fa "const BIGNUM **iqmp" .Fc +.Ft "const BIGNUM *" +.Fo RSA_get0_dmp1 +.Fa "const RSA *r" +.Fc +.Ft "const BIGNUM *" +.Fo RSA_get0_dmq1 +.Fa "const RSA *r" +.Fc +.Ft "const BIGNUM *" +.Fo RSA_get0_iqmp +.Fa "const RSA *r" +.Fc .Ft int .Fo RSA_set0_crt_params .Fa "RSA *r" @@ -263,6 +303,31 @@ If needed, duplicate the received value using .Xr BN_dup 3 and pass the duplicate. .Pp +Any of the values +.Fa n , +.Fa e , +.Fa d , +.Fa p , +.Fa q , +.Fa dmp1 , +.Fa dmq1 , +and +.Fa iqmp +can also be retrieved separately by the corresponding functions +.Fn RSA_get0_n , +.Fn RSA_get0_e , +.Fn RSA_get0_d , +.Fn RSA_get0_p , +.Fn RSA_get0_q , +.Fn RSA_get0_dmp1 , +.Fn RSA_get0_dmq1 , +and +.Fn RSA_get0_iqmp , +respectively. +The pointers are owned by the +.Vt RSA +object. +.Pp .Fn RSA_clear_flags clears the specified .Fa flags @@ -338,6 +403,21 @@ and .Dv RSA_FLAG_THREAD_SAFE are defined for compatibility with existing code but have no effect. .Sh RETURN VALUES +.Fn RSA_get0_n , +.Fn RSA_get0_e , +.Fn RSA_get0_d , +.Fn RSA_get0_p , +.Fn RSA_get0_q , +.Fn RSA_get0_dmp1 , +.Fn RSA_get0_dmq1 , +and +.Fn RSA_get0_iqmp +return a pointer owned by the +.Vt RSA +object if the corresponding value has been set, +otherwise they return +.Dv NULL . +.Pp .Fn RSA_set0_key , .Fn RSA_set0_factors , and @@ -359,6 +439,29 @@ are set. .Xr RSA_print 3 , .Xr RSA_size 3 .Sh HISTORY -These functions first appeared in OpenSSL 1.1.0 +.Fn RSA_get0_key , +.Fn RSA_set0_key , +.Fn RSA_get0_factors , +.Fn RSA_set0_factors , +.Fn RSA_get0_crt_params , +.Fn RSA_set0_crt_params , +.Fn RSA_clear_flags , +.Fn RSA_test_flags , +and +.Fn RSA_set_flags +first appeared in OpenSSL 1.1.0 and have been available since .Ox 6.3 . +.Pp +.Fn RSA_get0_n , +.Fn RSA_get0_e , +.Fn RSA_get0_d , +.Fn RSA_get0_p , +.Fn RSA_get0_q , +.Fn RSA_get0_dmp1 , +.Fn RSA_get0_dmq1 , +and +.Fn RSA_get0_iqmp +first appeared in OpenSSL 1.1.1 +and have been available since +.Ox 7.1 . diff --git a/man/SSL_CTX_set_cipher_list.3 b/man/SSL_CTX_set_cipher_list.3 index 95f22b1d..9d24e008 100644 --- a/man/SSL_CTX_set_cipher_list.3 +++ b/man/SSL_CTX_set_cipher_list.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: SSL_CTX_set_cipher_list.3,v 1.15 2020/04/25 14:03:38 schwarze Exp $ +.\" $OpenBSD: SSL_CTX_set_cipher_list.3,v 1.16 2022/12/11 20:53:27 tb Exp $ .\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 .\" .\" This file is a derived work. @@ -65,7 +65,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: April 25 2020 $ +.Dd $Mdocdate: December 11 2022 $ .Dt SSL_CTX_SET_CIPHER_LIST 3 .Os .Sh NAME @@ -140,6 +140,12 @@ cipher list can be displayed with the .Xr openssl 1 .Cm ciphers command. +.It Cm @SECLEVEL=n +Set the security level to n, which should be a number between +zero and five. +See +.Xr SSL_CTX_set_security_level 3 +for details. .It Cm @STRENGTH Sort the list by decreasing encryption strength, preserving the order of cipher suites that have the same strength. diff --git a/man/UI_new.3 b/man/UI_new.3 index ab7dfb36..d7113591 100644 --- a/man/UI_new.3 +++ b/man/UI_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: UI_new.3,v 1.10 2020/06/19 17:17:13 schwarze Exp $ +.\" $OpenBSD: UI_new.3,v 1.11 2022/12/17 22:23:31 tb Exp $ .\" full merge up to: OpenSSL 78b19e90 Jan 11 00:12:01 2017 +0100 .\" selective merge up to: OpenSSL 61f805c1 Jan 16 01:01:46 2018 +0800 .\" @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: June 19 2020 $ +.Dd $Mdocdate: December 17 2022 $ .Dt UI_NEW 3 .Os .Sh NAME @@ -76,7 +76,8 @@ .Nm UI_get_default_method , .Nm UI_get_method , .Nm UI_set_method , -.Nm UI_OpenSSL +.Nm UI_OpenSSL , +.Nm UI_null .Nd New User Interface .Sh SYNOPSIS .In openssl/ui.h @@ -226,6 +227,10 @@ .Fo UI_OpenSSL .Fa void .Fc +.Ft const UI_METHOD * +.Fo UI_null +.Fa void +.Fc .Sh DESCRIPTION UI stands for User Interface, and is a general purpose set of routines to prompt the user for text-based information. @@ -298,6 +303,12 @@ See further on). This method is the most machine/OS dependent part of OpenSSL and normally generates the most problems when porting. .Pp +.Fn UI_null +returns a UI method that does nothing. +Its use is to avoid getting internal defaults for passed +.Vt UI_METHOD +pointers. +.Pp .Fn UI_free removes .Fa ui @@ -478,9 +489,10 @@ returns 0 on success or a negative value on error. .Fn UI_ctrl returns a mask on success or \-1 on error. .Pp -.Fn UI_get_default_method -and +.Fn UI_get_default_method , .Fn UI_OpenSSL +and +.Fn UI_null always return a pointer to a valid .Vt UI_METHOD structure. @@ -509,6 +521,10 @@ argument. These functions first appeared in OpenSSL 0.9.7 and have been available since .Ox 3.2 . +.Pp +.Fn UI_null +first appeared in OpenSSL 1.1.1 and has been available since +.Ox 7.3 . .Sh AUTHORS .An Richard Levitte Aq Mt richard@levitte.org for the OpenSSL project. diff --git a/man/X25519.3 b/man/X25519.3 index 8d8006fe..a327f8c7 100644 --- a/man/X25519.3 +++ b/man/X25519.3 @@ -1,9 +1,9 @@ -.\" $OpenBSD: X25519.3,v 1.6 2022/02/18 10:24:32 jsg Exp $ +.\" $OpenBSD: X25519.3,v 1.7 2022/12/15 17:20:48 schwarze Exp $ .\" contains some text from: BoringSSL curve25519.h, curve25519.c .\" content also checked up to: OpenSSL f929439f Mar 15 12:19:16 2018 +0000 .\" .\" Copyright (c) 2015 Google Inc. -.\" Copyright (c) 2018 Ingo Schwarze +.\" Copyright (c) 2018, 2022 Ingo Schwarze .\" .\" Permission to use, copy, modify, and/or distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -17,13 +17,23 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 18 2022 $ +.\" According to the BoringSSL git history, those parts of the text in +.\" the present manual page that are Copyrighted by Google were probably +.\" written by Adam Langley in 2015. +.\" I fail to see any such text in the public domain files written +.\" by Daniel J. Bernstein and others that are included in SUPERCOP +.\" and that Adam Langley's BoringSSL implementation is based on. +.\" +.Dd $Mdocdate: December 15 2022 $ .Dt X25519 3 .Os .Sh NAME .Nm X25519 , -.Nm X25519_keypair -.Nd Elliptic Curve Diffie-Hellman primitive based on Curve25519 +.Nm X25519_keypair , +.Nm ED25519_keypair , +.Nm ED25519_sign , +.Nm ED25519_verify +.Nd Elliptic Curve Diffie-Hellman and signature primitives based on Curve25519 .Sh SYNOPSIS .In openssl/curve25519.h .Ft int @@ -37,11 +47,32 @@ .Fa "uint8_t out_public_value[X25519_KEY_LENGTH]" .Fa "uint8_t out_private_key[X25519_KEY_LENGTH]" .Fc +.Ft void +.Fo ED25519_keypair +.Fa "uint8_t out_public_key[ED25519_PUBLIC_KEY_LENGTH]" +.Fa "uint8_t out_private_key[ED25519_PRIVATE_KEY_LENGTH]" +.Fc +.Ft int +.Fo ED25519_sign +.Fa "uint8_t *out_sig" +.Fa "const uint8_t *message" +.Fa "size_t message_len" +.Fa "const uint8_t public_key[ED25519_PUBLIC_KEY_LENGTH]" +.Fa "const uint8_t private_key_seed[ED25519_PRIVATE_KEY_LENGTH]" +.Fc +.Ft int +.Fo ED25519_verify +.Fa "const uint8_t *message" +.Fa "size_t message_len" +.Fa "const uint8_t signature[ED25519_SIGNATURE_LENGTH]" +.Fa "const uint8_t public_key[ED25519_PUBLIC_KEY_LENGTH]" +.Fc .Sh DESCRIPTION -Curve25519 is an elliptic curve over a prime field specified in RFC 7748. +Curve25519 is an elliptic curve over a prime field +specified in RFC 7748 section 4.1. The prime field is defined by the prime number 2^255 - 19. .Pp -.Fn X25519 +X25519 is the Diffie-Hellman primitive built from Curve25519 as described in RFC 7748 section 5. Section 6.1 describes the intended use in an Elliptic Curve Diffie-Hellman @@ -85,17 +116,96 @@ by multiplying it with the Montgomery base point The size of a public and private key is .Dv X25519_KEY_LENGTH No = 32 bytes each. +.Pp +Ed25519 is a signature scheme using a twisted Edwards curve +that is birationally equivalent to Curve25519. +.Pp +.Fn ED25519_keypair +sets +.Fa out_public_key +and +.Fa out_private_key +to a freshly generated public/private key pair. +First, the +.Fa out_private_key +is generated with +.Xr arc4random_buf 3 . +Then, the +.Fa out_public_key +is calculated from the private key. +.Pp +.Fn ED25519_sign +signs the +.Fa message +of +.Fa message_len +bytes using the +.Fa public_key +and the +.Fa private_key +and writes the signature to +.Fa out_sig . +.Pp +.Fn ED25519_verify +checks that signing the +.Fa message +of +.Fa message_len +bytes using the +.Fa public_key +would indeed result in the given +.Fa signature . +.Pp +The sizes of a public and private keys are +.Dv ED25519_PUBLIC_KEY_LENGTH +and +.Dv ED25519_PRIVATE_KEY_LENGTH , +which are both 32 bytes, and the size of a signature is +.Dv ED25519_SIGNATURE_LENGTH No = 64 +bytes. .Sh RETURN VALUES .Fn X25519 -returns 1 on success or 0 on error. -Failure can occur when the input is a point of small order. +and +.Fn ED25519_sign +return 1 on success or 0 on error. +.Fn X25519 +can fail if the input is a point of small order. +.Fn ED25519_sign +always succeeds in LibreSSL, but the API reserves the return value 0 +for memory allocation failure. +.Pp +.Fn ED25519_verify +returns 1 if the +.Fa signature +is valid or 0 otherwise. .Sh SEE ALSO -.Xr ECDH_compute_key 3 +.Xr ECDH_compute_key 3 , +.Xr EVP_DigestSign 3 , +.Xr EVP_DigestVerify 3 , +.Xr EVP_PKEY_derive 3 , +.Xr EVP_PKEY_keygen 3 .Rs -.%A D. J. Bernstein +.%A Daniel J. Bernstein .%R A state-of-the-art Diffie-Hellman function:\ How do I use Curve25519 in my own software? .%U https://cr.yp.to/ecdh.html .Re +.Rs +.%A Daniel J. Bernstein +.%A Niels Duif +.%A Tanja Lange +.%A Peter Schwabe +.%A Bo-Yin Yang +.%T High-Speed High-Security Signatures +.%B Cryptographic Hardware and Embedded Systems \(em CHES 2011 +.%I Springer +.%J Lecture Notes in Computer Science +.%V vol 6917 +.%U https://doi.org/10.1007/978-3-642-23951-9_9 +.%C Nara, Japan +.%D September 29, 2011 +.Re .Sh STANDARDS RFC 7748: Elliptic Curves for Security +.Pp +RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA) diff --git a/man/X509V3_get_d2i.3 b/man/X509V3_get_d2i.3 index 4e1a0033..30f03c63 100644 --- a/man/X509V3_get_d2i.3 +++ b/man/X509V3_get_d2i.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509V3_get_d2i.3,v 1.19 2021/07/12 14:54:00 schwarze Exp $ +.\" $OpenBSD: X509V3_get_d2i.3,v 1.20 2023/02/23 18:12:32 job Exp $ .\" full merge up to: OpenSSL ff7fbfd5 Nov 2 11:52:01 2015 +0000 .\" selective merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 .\" @@ -49,7 +49,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 12 2021 $ +.Dd $Mdocdate: February 23 2023 $ .Dt X509V3_GET_D2I 3 .Os .Sh NAME @@ -65,7 +65,8 @@ .Nm X509_REVOKED_add1_ext_i2d , .Nm X509_get0_extensions , .Nm X509_CRL_get0_extensions , -.Nm X509_REVOKED_get0_extensions +.Nm X509_REVOKED_get0_extensions , +.Nm X509_get0_uids .Nd X509 extension decode and encode functions .Sh SYNOPSIS .In openssl/x509v3.h @@ -151,6 +152,12 @@ .Fo X509_REVOKED_get0_extensions .Fa "const X509_REVOKED *r" .Fc +.Ft void +.Fo X509_get0_uids +.Fa "const X509 *x" +.Fa "const ASN1_BIT_STRING **piuid" +.Fa "const ASN1_BIT_STRING **psuid" +.Fc .Sh DESCRIPTION .Fn X509V3_get_d2i looks for an extension with OID @@ -300,6 +307,16 @@ if the extension is not found, occurs multiple times or cannot be decoded. It is possible to determine the precise reason by checking the value of .Pf * Fa crit . +.Pp +.Fn X509_get0_uids +sets +.Fa *piuid +and +.Fa *psuid +to the issuer and subject unique identifiers of certificate +.Fa x +or NULL if the fields are not present. +These fields are rarely used. .Sh SUPPORTED EXTENSIONS The following sections contain a list of all supported extensions including their name and NID. @@ -449,3 +466,7 @@ and .Fn X509_REVOKED_get0_extensions first appeared in OpenSSL 1.1.0 and have been available since .Ox 6.3 . +.Pp +.Fn X509_get0_uids +first appeared in OpenSSL 1.1.0 and has been available since +.Ox 7.3 . diff --git a/man/X509_STORE_CTX_get_error.3 b/man/X509_STORE_CTX_get_error.3 index dda35ac4..48af7d9a 100644 --- a/man/X509_STORE_CTX_get_error.3 +++ b/man/X509_STORE_CTX_get_error.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_STORE_CTX_get_error.3,v 1.23 2022/05/19 07:04:41 tb Exp $ +.\" $OpenBSD: X509_STORE_CTX_get_error.3,v 1.25 2022/11/29 19:52:48 tb Exp $ .\" full merge up to: .\" OpenSSL man3/X509_STORE_CTX_get_error 24a535ea Sep 22 13:14:20 2020 +0100 .\" OpenSSL man3/X509_STORE_CTX_new 24a535ea Sep 22 13:14:20 2020 +0100 @@ -68,7 +68,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: May 19 2022 $ +.Dd $Mdocdate: November 29 2022 $ .Dt X509_STORE_CTX_GET_ERROR 3 .Os .Sh NAME @@ -296,9 +296,9 @@ debugging information relating to the current certificate. .Pp If an unrecognised error code is passed to .Fn X509_verify_cert_error_string , -the numerical value of the unknown code is returned in a static buffer. -This is not thread safe but will never happen unless an invalid code is -passed. +"Unknown certificate verification error" +is returned. +This should never happen unless an invalid code is passed. .Sh RETURN VALUES .Fn X509_STORE_CTX_get_error returns @@ -365,6 +365,10 @@ these are described as "unused". .Bl -tag -width Ds .It Dv X509_V_OK : No ok The operation was successful. +.It Dv X509_V_ERR_UNSPECIFIED : \ + No Unspecified certificate verification error +An error was encountered during certificate verification and +the internal routines failed to set a more specific error. .It Dv X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT : \ No unable to get issuer certificate The issuer certificate of a locally looked up certificate could not be found. @@ -434,7 +438,6 @@ No signatures could be verified because the chain contains only one certificate and it is not self signed. .It Dv X509_V_ERR_CERT_CHAIN_TOO_LONG : No certificate chain too long The certificate chain length is greater than the supplied maximum depth. -Unused. .It Dv X509_V_ERR_CERT_REVOKED : No certificate revoked The certificate has been revoked. .It Dv X509_V_ERR_INVALID_CA : No invalid CA certificate @@ -482,6 +485,22 @@ This is only set if issuer check debugging is enabled it is used for status notification and is .Sy not in itself an error. +.\" .It Dv X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER : \ +.\" No unable to get CRL issuer certificate +.\" .It Dv X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION : \ +.\" No unhandled critical extension +.\" .It Dv X509_V_ERR_KEYUSAGE_NO_CRL_SIGN : \ +.\" No key usage does not include CRL signing +.\" .It Dv X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION : \ +.\" No unhandled critical CRL extension +.\" .It Dv X509_V_ERR_INVALID_NON_CA : \ +.\" No invalid non-CA certificate (has CA markings) +.\" .It Dv X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED : \ +.\" No proxy path length constraint exceeded +.\" .It Dv X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE : \ +.\" No key usage does not include digital signature +.\" .It Dv X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED : \ +.\" No proxy certificates not allowed, please set the appropriate flag .It Dv X509_V_ERR_INVALID_EXTENSION : \ No invalid or inconsistent certificate extension A certificate extension had an invalid value (for example an incorrect @@ -501,6 +520,13 @@ certificate. No unsupported extension feature Some feature of a certificate extension is not supported. Unused. +.It Dv X509_V_ERR_UNNESTED_RESOURCE : \ + No RFC 3779 resource not subset of parent's resources +When walking up a certificate chain, all resources specified in +RFC 3779 extensions must be contained in the resources delegated in +the issuer's RFC 3779 extensions. +The error indicates that this is not the case or that the trust anchor +has inheritance. .It Dv X509_V_ERR_PERMITTED_VIOLATION : No permitted subtree violation A name constraint violation occurred in the permitted subtrees. .It Dv X509_V_ERR_EXCLUDED_VIOLATION : No excluded subtree violation @@ -509,13 +535,6 @@ A name constraint violation occurred in the excluded subtrees. No name constraints minimum and maximum not supported A certificate name constraints extension included a minimum or maximum field: this is not supported. -.It Dv X509_V_ERR_UNNESTED_RESOURCE : \ - RFC 3779 resource not subset of parent's resources -When walking up a certificate chain, all resources specified in -RFC 3779 extensions must be contained in the resources delegated in -the issuer's RFC 3779 extensions. -The error indicates that this is not the case or that the trust anchor -has inheritance. .It Dv X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE : \ No unsupported name constraint type An unsupported name constraint type was encountered. @@ -527,6 +546,7 @@ The format of the name constraint is not recognised: for example an email address format of a form not mentioned in RFC 3280. This could be caused by a garbage extension or some new feature not currently supported. +.\" X509_V_ERR_UNSUPPORTED_NAME_SYNTAX : No unsupported or invalid name syntax .It Dv X509_V_ERR_CRL_PATH_VALIDATION_ERROR : No CRL path validation error An error occurred when attempting to verify the CRL path. This error can only happen if extended CRL checking is enabled. @@ -534,6 +554,16 @@ This error can only happen if extended CRL checking is enabled. No application verification failure An application specific error. This will never be returned unless explicitly set by an application. +.\" .It Dv X509_V_ERR_HOSTNAME_MISMATCH : No Hostname mismatch +.\" .It Dv X509_V_ERR_EMAIL_MISMATCH : No Email address mismatch +.\" .It Dv X509_V_ERR_IP_ADDRESS_MISMATCH : No IP address mismatch +.\" .It Dv X509_V_ERR_INVALID_CALL : \ +.\" No Invalid certificate verification context +.\" .It Dv X509_V_ERR_STORE_LOOKUP : No Issuer certificate lookup error +.\" .It Dv X509_V_ERR_EE_KEY_TOO_SMALL : No EE certificate key too weak +.\" .It Dv X509_V_ERR_CA_KEY_TOO_SMALL : No CA certificate key too weak +.\" .It Dv X509_V_ERR_CA_MD_TOO_WEAK : \ +.\" No CA signature digest algorithm too weak .El .Sh SEE ALSO .Xr X509_policy_check 3 , diff --git a/man/X509_STORE_CTX_new.3 b/man/X509_STORE_CTX_new.3 index a10742ff..96af7a8a 100644 --- a/man/X509_STORE_CTX_new.3 +++ b/man/X509_STORE_CTX_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_STORE_CTX_new.3,v 1.26 2021/11/17 16:08:32 schwarze Exp $ +.\" $OpenBSD: X509_STORE_CTX_new.3,v 1.27 2022/11/16 14:55:40 schwarze Exp $ .\" full merge up to: OpenSSL aae41f8c Jun 25 09:47:15 2015 +0100 .\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 .\" @@ -67,7 +67,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: November 17 2021 $ +.Dd $Mdocdate: November 16 2022 $ .Dt X509_STORE_CTX_NEW 3 .Os .Sh NAME @@ -85,6 +85,8 @@ .Nm X509_STORE_CTX_set0_untrusted , .Nm X509_STORE_CTX_get0_untrusted , .Nm X509_STORE_CTX_set0_crls +.\" X509_STORE_CTX_verify_fn moved to X509_STORE_CTX_set_verify(3) +.\" X509_STORE_CTX_set_verify moved to X509_STORE_CTX_set_verify(3) .Nd X509_STORE_CTX initialisation .Sh SYNOPSIS .In openssl/x509_vfy.h diff --git a/man/X509_STORE_CTX_set_verify.3 b/man/X509_STORE_CTX_set_verify.3 index ccce6a0e..b2febbde 100644 --- a/man/X509_STORE_CTX_set_verify.3 +++ b/man/X509_STORE_CTX_set_verify.3 @@ -1,6 +1,6 @@ -.\" $OpenBSD: X509_STORE_CTX_set_verify.3,v 1.2 2021/11/23 17:06:05 tb Exp $ +.\" $OpenBSD: X509_STORE_CTX_set_verify.3,v 1.6 2023/03/18 08:20:20 jsg Exp $ .\" -.\" Copyright (c) 2021 Ingo Schwarze +.\" Copyright (c) 2021, 2022 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -14,53 +14,35 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 23 2021 $ +.Dd $Mdocdate: March 18 2023 $ .Dt X509_STORE_CTX_SET_VERIFY 3 .Os -.\" ds LIBRESSL_NEXT_API .Sh NAME -.if dLIBRESSL_NEXT_API \{\ .Nm X509_STORE_CTX_verify_fn , -.\} .Nm X509_STORE_CTX_set_verify , -.ie dLIBRESSL_NEXT_API \{\ .Nm X509_STORE_CTX_get_verify , .Nm X509_STORE_set_verify , -.Nm X509_STORE_set_verify_func -.\} -.el \{\ -.Nm X509_STORE_CTX_get_verify -.\} +.Nm X509_STORE_set_verify_func , +.Nm X509_STORE_get_verify , +.Nm X509_STORE_set_check_issued , +.Nm X509_STORE_get_check_issued , +.Nm X509_STORE_CTX_get_check_issued .Nd user-defined certificate chain verification function .Sh SYNOPSIS .In openssl/x509_vfy.h -.if dLIBRESSL_NEXT_API \{\ .Ft typedef int -.Fo "(*X509_STORE_CTX_verify_fn)" +.Fo (*X509_STORE_CTX_verify_fn) .Fa "X509_STORE_CTX *ctx" .Fc -.\} .Ft void .Fo X509_STORE_CTX_set_verify .Fa "X509_STORE_CTX *ctx" -.ie dLIBRESSL_NEXT_API \{\ .Fa "X509_STORE_CTX_verify_fn verify" -.\} -.el \{\ -.Fa "int (*verify)(X509_STORE_CTX *)" -.\} .Fc -.ie dLIBRESSL_NEXT_API \{\ .Ft X509_STORE_CTX_verify_fn .Fo X509_STORE_CTX_get_verify -.\} -.el \{\ -.Ft int -.Fo "(*X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx))" -.\} .Fa "X509_STORE_CTX *ctx" .Fc -.if dLIBRESSL_NEXT_API \{\ .Ft void .Fo X509_STORE_set_verify .Fa "X509_STORE *store" @@ -71,7 +53,29 @@ .Fa "X509_STORE *store" .Fa "X509_STORE_CTX_verify_fn verify" .Fc -.\} +.Ft X509_STORE_CTX_verify_fn +.Fo X509_STORE_get_verify +.Fa "X509_STORE_CTX *ctx" +.Fc +.Ft typedef int +.Fo (*X509_STORE_CTX_check_issued_fn) +.Fa "X509_STORE_CTX *ctx" +.Fa "X509 *subject" +.Fa "X509 *issuer" +.Fc +.Ft void +.Fo X509_STORE_set_check_issued +.Fa "X509_STORE *store" +.Fa "X509_STORE_CTX_check_issued_fn check_issued" +.Fc +.Ft X509_STORE_CTX_check_issued_fn +.Fo X509_STORE_get_check_issued +.Fa "X509_STORE *store" +.Fc +.Ft X509_STORE_CTX_check_issued_fn +.Fo X509_STORE_CTX_get_check_issued +.Fa "X509_STORE_CTX *ctx" +.Fc .Sh DESCRIPTION .Fn X509_STORE_CTX_set_verify configures @@ -97,7 +101,6 @@ or .Xr X509_VERIFY_PARAM_set_flags 3 . Otherwise, it is ignored and a different algorithm is used that does not support replacing the verification function. -.if dLIBRESSL_NEXT_API \{\ .Pp .Fn X509_STORE_set_verify saves the function pointer @@ -116,16 +119,34 @@ is later passed as an argument to is an alias for .Fn X509_STORE_set_verify implemented as a macro. -.\} +.Pp +.Fn X509_STORE_set_check_issued +saves the function pointer +.Fa check_issued +in the given +.Fa store +object. +That pointer will be copied to an +.Vt X509_STORE_CTX +object when +.Fa store +is later passed as an argument to +.Fn X509_STORE_CTX_init 3 . +.Pp +The +.Fa check_issued +function provided by the user should check whether a given certificate +.Fa subject +was issued using the CA certificate +.Fa issuer , +and must return 0 on failure and 1 on success. .Sh RETURN VALUES -.if dLIBRESSL_NEXT_API \{\ .Fn X509_STORE_CTX_verify_fn is supposed to return 1 to indicate that the chain is valid or 0 if it is not or if an error occurred. .Pp -.\} .Fn X509_STORE_CTX_get_verify -returns a function pointer to the function previously set with +returns a function pointer previously set with .Fn X509_STORE_CTX_set_verify or .Xr X509_STORE_CTX_init 3 , @@ -134,7 +155,37 @@ or if .Fa ctx is uninitialized. +.Pp +.Fn X509_STORE_get_verify +returns the function pointer previously set with +.Fn X509_STORE_set_verify , +or +.Dv NULL +if that function was not called on the +.Fa store . +.Pp +.Fn X509_STORE_get_check_issued +returns the function pointer previously set with +.Fn X509_STORE_set_check_issued , +or +.Dv NULL +if that function was not called on the +.Fa store . +.Pp +.Fn X509_STORE_CTX_get_check_issued +returns the +.Fn check_issued +function pointer set on the +.Vt X509_STORE_CTX . +This is either the +.Fn check_issued +function inherited from the +.Fa store +used in +.Xr X509_STORE_CTX_init 3 +or the library's default implementation. .Sh SEE ALSO +.Xr X509_check_issued 3 , .Xr X509_STORE_CTX_init 3 , .Xr X509_STORE_CTX_set_error 3 , .Xr X509_STORE_CTX_set_flags 3 , @@ -145,23 +196,26 @@ is uninitialized. .Xr X509_verify_cert 3 , .Xr X509_VERIFY_PARAM_set_flags 3 .Sh HISTORY -.if dLIBRESSL_NEXT_API \{\ .Fn X509_STORE_set_verify_func first appeared in SSLeay 0.8.0 and has been available since .Ox 2.4 . .Pp -.\} .Fn X509_STORE_CTX_set_verify and .Fn X509_STORE_CTX_get_verify first appeared in OpenSSL 1.1.0 and have been available since .Ox 7.1 . -.if dLIBRESSL_NEXT_API \{\ .Pp -.Fn X509_STORE_CTX_verify_fn +.Fn X509_STORE_CTX_verify_fn , +.Fn X509_STORE_set_verify , and -.Fn X509_STORE_set_verify +.Fn X509_STORE_get_verify first appeared in OpenSSL 1.1.0 and have been available since -.reminder Check the version number! -.Ox 7.1 . -.\} +.Ox 7.2 . +.Pp +.Fn X509_STORE_set_check_issued , +.Fn X509_STORE_get_check_issued , +and +.Fn X509_STORE_CTX_get_check_issued +first appeared in OpenSSL 1.1.0 and have been available since +.Ox 7.3 . diff --git a/man/X509_STORE_CTX_set_verify_cb.3 b/man/X509_STORE_CTX_set_verify_cb.3 index c4afb893..9ae3d029 100644 --- a/man/X509_STORE_CTX_set_verify_cb.3 +++ b/man/X509_STORE_CTX_set_verify_cb.3 @@ -1,5 +1,5 @@ -.\" $OpenBSD: X509_STORE_CTX_set_verify_cb.3,v 1.8 2022/01/02 21:00:37 tb Exp $ -.\" full merge up to: OpenSSL a528d4f0 Oct 27 13:40:11 2015 -0400 +.\" $OpenBSD: X509_STORE_CTX_set_verify_cb.3,v 1.9 2022/11/16 14:51:08 schwarze Exp $ +.\" full merge up to: OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400 .\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 .\" .\" This file is a derived work. @@ -66,23 +66,28 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: January 2 2022 $ +.Dd $Mdocdate: November 16 2022 $ .Dt X509_STORE_CTX_SET_VERIFY_CB 3 .Os .Sh NAME +.Nm X509_STORE_CTX_verify_cb , .Nm X509_STORE_CTX_set_verify_cb , .Nm X509_STORE_CTX_get_verify_cb .Nd set and retrieve verification callback .Sh SYNOPSIS .In openssl/x509_vfy.h +.Ft typedef int +.Fo (*X509_STORE_CTX_verify_cb) +.Fa "int ok" +.Fa "X509_STORE_CTX *ctx" +.Fc .Ft void .Fo X509_STORE_CTX_set_verify_cb .Fa "X509_STORE_CTX *ctx" -.Fa "int (*verify_cb)(int ok, X509_STORE_CTX *ctx)" +.Fa "X509_STORE_CTX_verify_cb verify_cb" .Fc -.Ft int -.Fo "(*X509_STORE_CTX_get_verify_cb(X509_STORE_CTX *ctx))" -.Fa "int ok" +.Ft X509_STORE_CTX_verify_cb +.Fo X509_STORE_CTX_get_verify_cb .Fa "X509_STORE_CTX *ctx" .Fc .Sh DESCRIPTION @@ -98,7 +103,7 @@ certificate verification, either by overriding error conditions or logging errors for debugging purposes. .Pp However, a verification callback is -.Sy not +.Em not essential and the default operation is often sufficient. .Pp The @@ -256,6 +261,7 @@ verify_callback(int ok, X509_STORE_CTX *ctx) .Xr X509_STORE_CTX_new 3 , .Xr X509_STORE_CTX_set_error 3 , .Xr X509_STORE_CTX_set_flags 3 , +.Xr X509_STORE_CTX_set_verify 3 , .Xr X509_STORE_set_verify_cb 3 , .Xr X509_verify_cert 3 , .Xr X509_VERIFY_PARAM_set_flags 3 @@ -267,6 +273,10 @@ first appeared in OpenSSL 0.9.6c and has been available since .Fn X509_STORE_CTX_get_verify_cb first appeared in OpenSSL 1.1.0 and has been available since .Ox 7.1 . +.Pp +.Fn X509_STORE_CTX_verify_cb +first appeared in OpenSSL 1.1.0 and has been available since +.Ox 7.2 . .Sh CAVEATS In general a verification callback should .Sy NOT diff --git a/man/X509_STORE_set_verify_cb_func.3 b/man/X509_STORE_set_verify_cb_func.3 index f6d534bb..bdd5ea50 100644 --- a/man/X509_STORE_set_verify_cb_func.3 +++ b/man/X509_STORE_set_verify_cb_func.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_STORE_set_verify_cb_func.3,v 1.11 2021/11/17 16:08:32 schwarze Exp $ +.\" $OpenBSD: X509_STORE_set_verify_cb_func.3,v 1.12 2022/11/16 14:51:08 schwarze Exp $ .\" full merge up to: OpenSSL 05ea606a May 20 20:52:46 2016 -0400 .\" selective merge up to: OpenSSL 315c47e0 Dec 1 14:22:16 2020 +0100 .\" @@ -49,24 +49,29 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: November 17 2021 $ +.Dd $Mdocdate: November 16 2022 $ .Dt X509_STORE_SET_VERIFY_CB_FUNC 3 .Os .Sh NAME .Nm X509_STORE_set_verify_cb , -.Nm X509_STORE_set_verify_cb_func +.Nm X509_STORE_set_verify_cb_func , +.Nm X509_STORE_get_verify_cb .Nd set verification callback .Sh SYNOPSIS .In openssl/x509_vfy.h .Ft void .Fo X509_STORE_set_verify_cb .Fa "X509_STORE *st" -.Fa "int (*verify_cb)(int ok, X509_STORE_CTX *ctx)" +.Fa "X509_STORE_CTX_verify_cb verify_cb" .Fc .Ft void .Fo X509_STORE_set_verify_cb_func .Fa "X509_STORE *st" -.Fa "int (*verify_cb)(int ok, X509_STORE_CTX *ctx)" +.Fa "X509_STORE_CTX_verify_cb verify_cb" +.Fc +.Ft X509_STORE_CTX_verify_cb +.Fo X509_STORE_get_verify_cb +.Fa "X509_STORE *st" .Fc .Sh DESCRIPTION .Fn X509_STORE_set_verify_cb @@ -87,6 +92,14 @@ structure when it is initialized. This can be used to set the verification callback when the .Vt X509_STORE_CTX is otherwise inaccessible (for example during S/MIME verification). +.Sh RETURN VALUES +.Fn X509_STORE_get_verify_cb +returns the function pointer set with +.Fn X509_STORE_set_verify_cb , +or +.Dv NULL +if that function was not called on +.Fa st . .Sh SEE ALSO .Xr X509_STORE_CTX_new 3 , .Xr X509_STORE_CTX_set_verify 3 , @@ -102,3 +115,7 @@ first appeared in SSLeay 0.8.0 and has been available since .Fn X509_STORE_set_verify_cb first appeared in OpenSSL 1.0.0 and has been available since .Ox 4.9 . +.Pp +.Fn X509_STORE_get_verify_cb +first appeared in OpenSSL 1.1.0 and has been available since +.Ox 7.2 . diff --git a/man/X509_VERIFY_PARAM_set_flags.3 b/man/X509_VERIFY_PARAM_set_flags.3 index 7a39050c..08961eb4 100644 --- a/man/X509_VERIFY_PARAM_set_flags.3 +++ b/man/X509_VERIFY_PARAM_set_flags.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_VERIFY_PARAM_set_flags.3,v 1.26 2022/07/13 21:17:03 schwarze Exp $ +.\" $OpenBSD: X509_VERIFY_PARAM_set_flags.3,v 1.27 2022/12/01 05:33:55 tb Exp $ .\" full merge up to: OpenSSL d33def66 Feb 9 14:17:13 2016 -0500 .\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 .\" @@ -68,7 +68,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 13 2022 $ +.Dd $Mdocdate: December 1 2022 $ .Dt X509_VERIFY_PARAM_SET_FLAGS 3 .Os .Sh NAME @@ -590,16 +590,10 @@ A side effect of not checking the root CA signature is that disabled or unsupported message digests on the root CA are not treated as fatal errors. .Pp -The +The deprecated .Dv X509_V_FLAG_CB_ISSUER_CHECK -flag enables debugging of certificate issuer checks. -It is -.Sy not -needed unless you are logging certificate verification. -If this flag is set then additional status codes will be sent to the -verification callback and it -.Sy must -be prepared to handle such cases without assuming they are hard errors. +flag used to enable debugging of certificate issuer checks. +It is provided for binary backwards compatibility and has no effect. .Pp When .Dv X509_V_FLAG_TRUSTED_FIRST diff --git a/man/X509_check_purpose.3 b/man/X509_check_purpose.3 index e0737251..611697fa 100644 --- a/man/X509_check_purpose.3 +++ b/man/X509_check_purpose.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_check_purpose.3,v 1.7 2021/10/29 14:29:24 schwarze Exp $ +.\" $OpenBSD: X509_check_purpose.3,v 1.9 2022/12/17 12:48:53 tb Exp $ .\" .\" Copyright (c) 2019, 2021 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 29 2021 $ +.Dd $Mdocdate: December 17 2022 $ .Dt X509_CHECK_PURPOSE 3 .Os .Sh NAME @@ -30,10 +30,26 @@ .Fc .Sh DESCRIPTION If the +.Fa purpose +argument is \-1, +.Fn X509_check_purpose +ignores the +.Fa ca +argument and checks that all the extensions of the +.Fa certificate +can be parsed and pass minimal sanity checks, ensuring that +extensions that must not occur more than once do not. +It also makes sure that all extensions are cached in the +.Vt X509 +object. +.Pp +If the +.Fa purpose +argument is not \-1 and the .Fa ca flag is 0, .Fn X509_check_purpose -checks whether the public key contained in the +also checks whether the public key contained in the .Fa certificate is intended to be used for the given .Fa purpose , @@ -205,10 +221,12 @@ bits is set, and no other bits are set. .El .Pp If the +.Fa purpose +argument is not \-1 and the .Fa ca flag is non-zero, .Fn X509_check_purpose -instead checks whether the +instead checks, in addition to the minimal sanity checks, whether the .Fa certificate can be used as a certificate authority certificate in the context of the given @@ -334,14 +352,6 @@ The check even succeeds if the three other common conditions cited above this list are violated. .El .Pp -If parsing of any extensions that are present succeeds and the -.Fa purpose -argument is \-1, -.Fn X509_check_purpose -always succeeds, no matter whether or not the -.Fa ca -flag is set. -.Pp If the function .Xr X509_PURPOSE_add 3 was called before @@ -352,22 +362,28 @@ installed additional, user-supplied checking functions for user-defined .Fa purpose identifiers not listed above. .Sh RETURN VALUES +If the parsing of certificate extensions fails, sanity checks fail or the +.Fa purpose +is invalid, .Fn X509_check_purpose -returns the following values: -.Bl -column -1 Failure -compact -.It \-1 Ta Error Ta Parsing of certificate extensions failed or the +returns \-1 to indicate the error. +.Pp +If the .Fa purpose -is invalid. -.It 0 Ta Failure Ta The -.Fa certificate -cannot be used for the -.Fa purpose . -.El +argument is \-1 and parsing and minimal sanity checks succeed, +.Fn X509_check_purpose +returns 1 to indicate success. +.Pp +Otherwise, it returns the following values: .Pp If .Fa ca -is 0, the following values can also be returned: +is 0: .Bl -column -1 Failure -compact +.It 0 Ta Failure Ta The +.Fa certificate +cannot be used for the +.Fa purpose . .It 1 Ta Success Ta The .Fa certificate can be used for the @@ -377,8 +393,12 @@ can be used for the .Pp If .Fa ca -is non-zero, the following values can also be returned: +is non-zero: .Bl -column -1 Failure -compact +.It 0 Ta Failure Ta The +.Fa certificate +cannot be used as a CA for the +.Fa purpose . .It 1 Ta Success Ta The .Fa certificate can be used as a CA for the diff --git a/man/X509_check_trust.3 b/man/X509_check_trust.3 index 286dcdd5..be4489e9 100644 --- a/man/X509_check_trust.3 +++ b/man/X509_check_trust.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_check_trust.3,v 1.6 2022/09/10 10:22:46 jsg Exp $ +.\" $OpenBSD: X509_check_trust.3,v 1.7 2022/12/26 07:18:52 jmc Exp $ .\" .\" Copyright (c) 2021 Ingo Schwarze .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 10 2022 $ +.Dd $Mdocdate: December 26 2022 $ .Dt X509_CHECK_TRUST 3 .Os .Sh NAME @@ -140,7 +140,7 @@ identifiers, the standard algorithm is modified: and .Xr X509_add1_trust_object 3 settings are completely ignored -and all steps before the compatibility step are skippped. +and all steps before the compatibility step are skipped. The .Fa certificate is trusted if and only if it is self-signed. diff --git a/man/X509_get0_signature.3 b/man/X509_get0_signature.3 index 7082db16..f3ad3982 100644 --- a/man/X509_get0_signature.3 +++ b/man/X509_get0_signature.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: X509_get0_signature.3,v 1.7 2021/07/06 16:05:44 schwarze Exp $ +.\" $OpenBSD: X509_get0_signature.3,v 1.8 2023/03/16 12:01:47 job Exp $ .\" selective merge up to: .\" OpenSSL man3/X509_get0_signature 2f7a2520 Apr 25 17:28:08 2017 +0100 .\" @@ -66,7 +66,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: July 6 2021 $ +.Dd $Mdocdate: March 16 2023 $ .Dt X509_GET0_SIGNATURE 3 .Os .Sh NAME @@ -74,6 +74,7 @@ .Nm X509_REQ_get0_signature , .Nm X509_CRL_get0_signature , .Nm X509_get0_tbs_sigalg , +.Nm X509_CRL_get0_tbs_sigalg , .Nm X509_get_signature_type , .Nm X509_get_signature_nid , .Nm X509_REQ_get_signature_nid , @@ -103,6 +104,10 @@ .Fo X509_get0_tbs_sigalg .Fa "const X509 *x" .Fc +.Ft const X509_ALGOR * +.Fo X509_CRL_get0_tbs_sigalg +.Fa "const X509_CRL *crl" +.Fc .Ft int .Fo X509_get_signature_type .Fa "const X509 *x" @@ -135,8 +140,13 @@ or .Fa crl , respectively. .Fn X509_get0_tbs_sigalg -returns the signature algorithm in the signed portion of -.Fa x . +and +.Fn X509_CRL_get0_tbs_sigalg +return the signature algorithm in the signed portion of +.Fa x +or +.Fa crl , +respectively. The values returned are internal pointers that must not be freed by the caller. .Pp @@ -197,3 +207,7 @@ and first appeared in OpenSSL 1.1.0. All these functions have been available since .Ox 6.3 . +.Pp +.Fn X509_CRL_get0_tbs_sigalg +first appeared in LibreSSL 3.7.1 and has been available since +.Ox 7.3 . diff --git a/man/bn_dump.3 b/man/bn_dump.3 index 6deac4db..cfe707b7 100644 --- a/man/bn_dump.3 +++ b/man/bn_dump.3 @@ -1,5 +1,6 @@ -.\" $OpenBSD: bn_dump.3,v 1.6 2016/12/10 21:32:14 schwarze Exp $ -.\" OpenSSL crypto/bn/README.pod aebb9aac Jul 19 09:27:53 2016 -0400 +.\" $OpenBSD: bn_dump.3,v 1.8 2023/01/20 12:16:46 jsing Exp $ +.\" full merge up to: +.\" OpenSSL crypto/bn/README.pod aebb9aac Jul 19 09:27:53 2016 -0400 .\" .\" This file was written by Ulf Moeller . .\" Copyright (c) 2000, 2003, 2006, 2009 The OpenSSL Project. @@ -49,7 +50,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED .\" OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: December 10 2016 $ +.Dd $Mdocdate: January 20 2023 $ .Dt BN_DUMP 3 .Os .Sh NAME @@ -65,11 +66,8 @@ .Nm bn_sqr_comba8 , .Nm bn_cmp_words , .Nm bn_mul_normal , -.Nm bn_mul_low_normal , .Nm bn_mul_recursive , .Nm bn_mul_part_recursive , -.Nm bn_mul_low_recursive , -.Nm bn_mul_high , .Nm bn_sqr_normal , .Nm bn_sqr_recursive , .Nm bn_expand , @@ -165,13 +163,6 @@ .Fa "int nb" .Fc .Ft void -.Fo bn_mul_low_normal -.Fa "BN_ULONG *r" -.Fa "BN_ULONG *a" -.Fa "BN_ULONG *b" -.Fa "int n" -.Fc -.Ft void .Fo bn_mul_recursive .Fa "BN_ULONG *r" .Fa "BN_ULONG *a" @@ -192,23 +183,6 @@ .Fa "BN_ULONG *tmp" .Fc .Ft void -.Fo bn_mul_low_recursive -.Fa "BN_ULONG *r" -.Fa "BN_ULONG *a" -.Fa "BN_ULONG *b" -.Fa "int n2" -.Fa "BN_ULONG *tmp" -.Fc -.Ft void -.Fo bn_mul_high -.Fa "BN_ULONG *r" -.Fa "BN_ULONG *a" -.Fa "BN_ULONG *b" -.Fa "BN_ULONG *l" -.Fa "int n2" -.Fa "BN_ULONG *tmp" -.Fc -.Ft void .Fo bn_sqr_normal .Fa "BN_ULONG *r" .Fa "BN_ULONG *a" @@ -320,13 +294,14 @@ a array of words .Pq Vt BN_ULONG , least significant word first. -A .Vt BN_ULONG -can be either 16, 32 or 64 bits in size, depending on the 'number of -bits' -.Pq Dv BITS2 -specified in -.In openssl/bn.h . +is a macro that expands to +.Vt unsigned long Pq = Vt uint64_t +on +.Dv _LP64 +platforms and +.Vt unsigned int Pq = Vt uint32_t +elsewhere. .Pp .Fa dmax is the size of the @@ -543,21 +518,6 @@ It computes and places the result in .Fa r . .Pp -.Fn bn_mul_low_normal r a b n -operates on the -.Fa n -word arrays -.Fa r , -.Fa a -and -.Fa b . -It computes the -.Fa n -low words of -.Fa a Ns * Ns Fa b -and places the result in -.Fa r . -.Pp .Fn bn_mul_recursive r a b n2 dna dnb t operates on the word arrays .Fa a @@ -599,34 +559,6 @@ word arrays and .Fa tmp . .Pp -.Fn bn_mul_low_recursive r a b n2 tmp -operates on the -.Fa n2 -word arrays -.Fa r -and -.Fa tmp -and the -.Fa n2 Ns /2 -word arrays -.Fa a -and -.Fa b . -.Pp -.Fn bn_mul_high r a b l n2 tmp -operates on the -.Fa n2 -word arrays -.Fa r , -.Fa a , -.Fa b -and -.Fa l -(?) and the -.Pf 3* Fa n2 -word array -.Fa tmp . -.Pp .Xr BN_mul 3 calls .Fn bn_mul_normal , diff --git a/scripts/config.guess b/scripts/config.guess index b82ee231..980b0208 100644 --- a/scripts/config.guess +++ b/scripts/config.guess @@ -1,12 +1,14 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2022 Free Software Foundation, Inc. -timestamp='2015-12-14' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2022-09-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -15,7 +17,7 @@ timestamp='2015-12-14' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,11 +29,19 @@ timestamp='2015-12-14' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to . +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -39,7 +49,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +60,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,7 +94,8 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 +# Just in case it came from the environment. +GUESS= # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires @@ -96,66 +107,90 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039,SC3028 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD=$driver + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case $UNAME_SYSTEM in Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu + LIBC=unknown - eval $set_cc_for_build - cat <<-EOF > $dummy.c + set_cc_for_build + cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc - #else + #elif defined(__GLIBC__) LIBC=gnu + #else + #include + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$cc_set_libc" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -167,29 +202,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case $UNAME_MACHINE_ARCH in + aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + *) machine=$UNAME_MACHINE_ARCH-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in - arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + # to ELF recently (or will in the future) and ABI. + case $UNAME_MACHINE_ARCH in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -205,10 +243,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in + case $UNAME_MACHINE_ARCH in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -216,43 +254,68 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case $UNAME_VERSION in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" - exit ;; + GUESS=$machine-${os}${release}${abi-} + ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE + ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE + ;; + *:SecBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE + ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE + ;; + *:MidnightBSD:*:*) + GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE + ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE + ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE + ;; + *:OS108:*:*) + GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE + ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} - exit ;; + GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE + ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE + ;; *:Sortix:*:*) - echo ${UNAME_MACHINE}-unknown-sortix - exit ;; + GUESS=$UNAME_MACHINE-unknown-sortix + ;; + *:Twizzler:*:*) + GUESS=$UNAME_MACHINE-unknown-twizzler + ;; + *:Redox:*:*) + GUESS=$UNAME_MACHINE-unknown-redox + ;; + mips:OSF1:*.*) + GUESS=mips-dec-osf1 + ;; alpha:OSF1:*:*) + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + trap '' 0 case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` @@ -266,163 +329,158 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in + case $ALPHA_CPU_TYPE in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; + OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + GUESS=$UNAME_MACHINE-dec-osf$OSF_REL + ;; Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; + GUESS=m68k-unknown-sysv4 + ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos - exit ;; + GUESS=$UNAME_MACHINE-unknown-amigaos + ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos - exit ;; + GUESS=$UNAME_MACHINE-unknown-morphos + ;; *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; + GUESS=i370-ibm-openedition + ;; *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; + GUESS=s390-ibm-zvmoe + ;; *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; + GUESS=powerpc-ibm-os400 + ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; + GUESS=arm-acorn-riscix$UNAME_RELEASE + ;; arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; + GUESS=arm-unknown-riscos + ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; + GUESS=hppa1.1-hitachi-hiuxmpp + ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; + case `(/bin/universe) 2>/dev/null` in + att) GUESS=pyramid-pyramid-sysv3 ;; + *) GUESS=pyramid-pyramid-bsd ;; + esac + ;; NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; + GUESS=pyramid-pyramid-svr4 + ;; DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; + GUESS=sparc-icl-nx6 + ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; + sparc) GUESS=sparc-icl-nx7 ;; + esac + ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL + ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-hal-solaris2$SUN_REL + ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris2$SUN_REL + ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; + GUESS=i386-pc-auroraux$UNAME_RELEASE + ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" + set_cc_for_build + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$SUN_ARCH-pc-solaris2$SUN_REL + ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris3$SUN_REL + ;; sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in + case `/usr/bin/arch -k` in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` + GUESS=sparc-sun-sunos$SUN_REL + ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 - case "`/bin/arch`" in + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case `/bin/arch` in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + GUESS=sparc-sun-sunos$UNAME_RELEASE ;; esac - exit ;; + ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; + GUESS=sparc-auspex-sunos$UNAME_RELEASE + ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -432,44 +490,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-milan-mint$UNAME_RELEASE + ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-hades-mint$UNAME_RELEASE + ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-unknown-mint$UNAME_RELEASE + ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; + GUESS=m68k-apple-machten$UNAME_RELEASE + ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; + GUESS=powerpc-apple-machten$UNAME_RELEASE + ;; RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; + GUESS=mips-dec-mach_bsd4.3 + ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; + GUESS=mips-dec-ultrix$UNAME_RELEASE + ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; + GUESS=vax-dec-ultrix$UNAME_RELEASE + ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; + GUESS=clipper-intergraph-clix$UNAME_RELEASE + ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -478,95 +536,96 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; + GUESS=mips-mips-riscos$UNAME_RELEASE + ;; Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; + GUESS=powerpc-motorola-powermax + ;; Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; + GUESS=powerpc-harris-powerunix + ;; m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; + GUESS=m88k-harris-cxux7 + ;; m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; + GUESS=m88k-motorola-sysv4 + ;; m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x then - echo m88k-dg-dgux${UNAME_RELEASE} + GUESS=m88k-dg-dgux$UNAME_RELEASE else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + GUESS=m88k-dg-dguxbcs$UNAME_RELEASE fi else - echo i586-dg-dgux${UNAME_RELEASE} + GUESS=i586-dg-dgux$UNAME_RELEASE fi - exit ;; + ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; + GUESS=m88k-dolphin-sysv3 + ;; M88*:*:R3*:*) # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; + GUESS=m88k-tektronix-sysv3 + ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; + GUESS=m68k-tektronix-bsd + ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; + IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` + GUESS=mips-sgi-irix$IRIX_REL + ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id + ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; + GUESS=i386-ibm-aix + ;; ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then + if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; + GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV + ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -577,77 +636,77 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then - echo "$SYSTEM_NAME" + GUESS=$SYSTEM_NAME else - echo rs6000-ibm-aix3.2.5 + GUESS=rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 + GUESS=rs6000-ibm-aix3.2.4 else - echo rs6000-ibm-aix3.2 + GUESS=rs6000-ibm-aix3.2 fi - exit ;; + ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + if test -x /usr/bin/lslpp ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; + GUESS=$IBM_ARCH-ibm-aix$IBM_REV + ;; *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; + GUESS=rs6000-ibm-aix + ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + GUESS=romp-ibm-bsd4.4 + ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 + GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to + ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; + GUESS=rs6000-bull-bosx + ;; DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; + GUESS=m68k-bull-sysv3 + ;; 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; + GUESS=m68k-hp-bsd + ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; + GUESS=m68k-hp-bsd4.4 + ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + case $UNAME_MACHINE in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then + if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + case $sc_cpu_version in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + case $sc_kernel_bits in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if test "$HP_ARCH" = ""; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include @@ -680,13 +739,13 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if test "$HP_ARCH" = hppa2.0w then - eval $set_cc_for_build + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -697,23 +756,23 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; + GUESS=$HP_ARCH-hp-hpux$HPUX_REV + ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + GUESS=ia64-hp-hpux$HPUX_REV + ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -738,38 +797,38 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; + GUESS=unknown-hitachi-hiuxwe2 + ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + GUESS=hppa1.1-hp-bsd + ;; 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; + GUESS=hppa1.0-hp-bsd + ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; + GUESS=hppa1.0-hp-mpeix + ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + GUESS=hppa1.1-hp-osf + ;; hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; + GUESS=hppa1.0-hp-osf + ;; i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + if test -x /usr/sbin/sysversion ; then + GUESS=$UNAME_MACHINE-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + GUESS=$UNAME_MACHINE-unknown-osf1 fi - exit ;; + ;; parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; + GUESS=hppa1.1-hp-lites + ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; + GUESS=c1-convex-bsd + ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd @@ -777,139 +836,154 @@ EOF fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; + GUESS=c34-convex-bsd + ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; + GUESS=c38-convex-bsd + ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; + GUESS=c4-convex-bsd + ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=ymp-cray-unicos$CRAY_REL + ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=t90-cray-unicos$CRAY_REL + ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=alphaev5-cray-unicosmk$CRAY_REL + ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=sv1-cray-unicos$CRAY_REL + ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=craynv-cray-unicosmp$CRAY_REL + ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE + ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} - exit ;; + GUESS=sparc-unknown-bsdi$UNAME_RELEASE + ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE + ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi + else + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf + fi + ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case $UNAME_PROCESSOR in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac - exit ;; + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL + ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; + GUESS=$UNAME_MACHINE-pc-cygwin + ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw64 + ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw32 + ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-msys + ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-pw32 + ;; + *:SerenityOS:*:*) + GUESS=$UNAME_MACHINE-pc-serenity + ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case $UNAME_MACHINE in x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; + GUESS=i586-pc-interix$UNAME_RELEASE + ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; + GUESS=x86_64-unknown-interix$UNAME_RELEASE + ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} - exit ;; + GUESS=ia64-unknown-interix$UNAME_RELEASE + ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; + GUESS=$UNAME_MACHINE-pc-uwin + ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; + GUESS=x86_64-pc-cygwin + ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=powerpcle-unknown-solaris2$SUN_REL + ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; + GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` + GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL + ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; + GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC + ;; + x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-pc-managarm-mlibc" + ;; + *:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" + ;; + *:Minix:*:*) + GUESS=$UNAME_MACHINE-unknown-minix + ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -919,178 +993,237 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="gnulibc1" ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; arm*:Linux:*:*) - eval $set_cc_for_build + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf fi fi - exit ;; + ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; e2k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-pc-linux-$LIBC + ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; k1om:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` + eval "$cc_set_vars" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } + ;; + mips64el:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} - exit ;; + GUESS=or1k-unknown-linux-$LIBC + ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} - exit ;; + GUESS=sparc-unknown-linux-$LIBC + ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} - exit ;; + GUESS=hppa64-unknown-linux-$LIBC + ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; + PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; + *) GUESS=hppa-unknown-linux-$LIBC ;; esac - exit ;; + ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} - exit ;; + GUESS=powerpc64-unknown-linux-$LIBC + ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} - exit ;; + GUESS=powerpc-unknown-linux-$LIBC + ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} - exit ;; + GUESS=powerpc64le-unknown-linux-$LIBC + ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} - exit ;; + GUESS=powerpcle-unknown-linux-$LIBC + ;; + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-ibm-linux-$LIBC + ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-dec-linux-$LIBC + ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __i386__ + ABI=x86 + #else + #ifdef __ILP32__ + ABI=x32 + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + x86) CPU=i686 ;; + x32) LIBCABI=${LIBC}x32 ;; + esac + fi + GUESS=$CPU-pc-linux-$LIBCABI + ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; + GUESS=i386-sequent-sysv4 + ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; + GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION + ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; + GUESS=$UNAME_MACHINE-pc-os2-emx + ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop - exit ;; + GUESS=$UNAME_MACHINE-unknown-stop + ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos - exit ;; + GUESS=$UNAME_MACHINE-unknown-atheos + ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; + GUESS=$UNAME_MACHINE-pc-syllable + ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=i386-unknown-lynxos$UNAME_RELEASE + ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + GUESS=$UNAME_MACHINE-pc-msdosdjgpp + ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL fi - exit ;; + ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in @@ -1098,12 +1231,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; + GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1113,11 +1246,11 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL else - echo ${UNAME_MACHINE}-pc-sysv32 + GUESS=$UNAME_MACHINE-pc-sysv32 fi - exit ;; + ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -1125,31 +1258,31 @@ EOF # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; + GUESS=i586-pc-msdosdjgpp + ;; Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; + GUESS=i386-pc-mach3 + ;; paragon:*:*:*) - echo i860-intel-osf1 - exit ;; + GUESS=i860-intel-osf1 + ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 fi - exit ;; + ;; mini*:CTIX:SYS*5:*) # "miniframe" - echo m68010-convergent-sysv - exit ;; + GUESS=m68010-convergent-sysv + ;; mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; + GUESS=m68k-convergent-sysv + ;; M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; + GUESS=m68k-diab-dnix + ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) @@ -1157,9 +1290,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1168,251 +1301,444 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=m68k-unknown-lynxos$UNAME_RELEASE + ;; mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; + GUESS=m68k-atari-sysv4 + ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=sparc-unknown-lynxos$UNAME_RELEASE + ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=rs6000-unknown-lynxos$UNAME_RELEASE + ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit ;; + GUESS=powerpc-unknown-lynxos$UNAME_RELEASE + ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; + GUESS=mips-dde-sysv$UNAME_RELEASE + ;; RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + GUESS=$UNAME_MACHINE-sni-sysv4 else - echo ns32k-sni-sysv + GUESS=ns32k-sni-sysv fi - exit ;; + ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says - echo i586-unisys-sysv4 - exit ;; + GUESS=i586-unisys-sysv4 + ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; + GUESS=hppa1.1-stratus-sysv4 + ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; + GUESS=i860-stratus-sysv4 + ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; + GUESS=$UNAME_MACHINE-stratus-vos + ;; *:VOS:*:*) # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; + GUESS=hppa1.1-stratus-vos + ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; + GUESS=m68k-apple-aux$UNAME_RELEASE + ;; news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; + GUESS=mips-sony-newsos6 + ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + if test -d /usr/nec; then + GUESS=mips-nec-sysv$UNAME_RELEASE else - echo mips-unknown-sysv${UNAME_RELEASE} + GUESS=mips-unknown-sysv$UNAME_RELEASE fi - exit ;; + ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; + GUESS=powerpc-be-beos + ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; + GUESS=powerpc-apple-beos + ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; + GUESS=i586-pc-beos + ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; + GUESS=i586-pc-haiku + ;; + ppc:Haiku:*:*) # Haiku running on Apple PowerPC + GUESS=powerpc-apple-haiku + ;; + *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat) + GUESS=$UNAME_MACHINE-unknown-haiku + ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx4-nec-superux$UNAME_RELEASE + ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx5-nec-superux$UNAME_RELEASE + ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx6-nec-superux$UNAME_RELEASE + ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx7-nec-superux$UNAME_RELEASE + ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx8-nec-superux$UNAME_RELEASE + ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx8r-nec-superux$UNAME_RELEASE + ;; + SX-ACE:SUPER-UX:*:*) + GUESS=sxace-nec-superux$UNAME_RELEASE + ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; + GUESS=powerpc-apple-rhapsody$UNAME_RELEASE + ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE + ;; + arm64:Darwin:*:*) + GUESS=aarch64-apple-darwin$UNAME_RELEASE + ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE + ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE + ;; *:QNX:*:4*) - echo i386-pc-qnx - exit ;; - NEO-?:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; + GUESS=i386-pc-qnx + ;; + NEO-*:NONSTOP_KERNEL:*:*) + GUESS=neo-tandem-nsk$UNAME_RELEASE + ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; + GUESS=nse-tandem-nsk$UNAME_RELEASE + ;; + NSR-*:NONSTOP_KERNEL:*:*) + GUESS=nsr-tandem-nsk$UNAME_RELEASE + ;; + NSV-*:NONSTOP_KERNEL:*:*) + GUESS=nsv-tandem-nsk$UNAME_RELEASE + ;; + NSX-*:NONSTOP_KERNEL:*:*) + GUESS=nsx-tandem-nsk$UNAME_RELEASE + ;; *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; + GUESS=mips-compaq-nonstopux + ;; BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; + GUESS=bs2000-siemens-sysv + ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE + ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "${cputype-}" = 386; then UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" + elif test "x${cputype-}" != x; then + UNAME_MACHINE=$cputype fi - echo ${UNAME_MACHINE}-unknown-plan9 - exit ;; + GUESS=$UNAME_MACHINE-unknown-plan9 + ;; *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; + GUESS=pdp10-unknown-tops10 + ;; *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; + GUESS=pdp10-unknown-tenex + ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; + GUESS=pdp10-dec-tops20 + ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; + GUESS=pdp10-xkl-tops20 + ;; *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; + GUESS=pdp10-unknown-tops20 + ;; *:ITS:*:*) - echo pdp10-unknown-its - exit ;; + GUESS=pdp10-unknown-its + ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; + GUESS=mips-sei-seiux$UNAME_RELEASE + ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; + DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL + ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; + case $UNAME_MACHINE in + A*) GUESS=alpha-dec-vms ;; + I*) GUESS=ia64-dec-vms ;; + V*) GUESS=vax-dec-vms ;; esac ;; *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; + GUESS=i386-pc-xenix + ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' - exit ;; + SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` + GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL + ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; + GUESS=$UNAME_MACHINE-pc-rdos + ;; + i*86:Fiwix:*:*) + GUESS=$UNAME_MACHINE-pc-fiwix + ;; + *:AROS:*:*) + GUESS=$UNAME_MACHINE-unknown-aros + ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx - exit ;; + GUESS=$UNAME_MACHINE-unknown-esx + ;; amd64:Isilon\ OneFS:*:*) - echo x86_64-unknown-onefs - exit ;; + GUESS=x86_64-unknown-onefs + ;; + *:Unleashed:*:*) + GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE + ;; +esac + +# Do we have a guess based on uname results? +if test "x$GUESS" != x; then + echo "$GUESS" + exit +fi + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case $UNAME_MACHINE:$UNAME_SYSTEM in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 < in order to provide the needed -information to handle your system. +our_year=`echo $timestamp | sed 's,-.*,,'` +thisyear=`date +%Y` +# shellcheck disable=SC2003 +script_age=`expr "$thisyear" - "$our_year"` +if test "$script_age" -lt 3 ; then + cat >&2 </dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF +fi exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/scripts/config.sub b/scripts/config.sub index 0cd70165..baf1512b 100644 --- a/scripts/config.sub +++ b/scripts/config.sub @@ -1,12 +1,14 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2015 Free Software Foundation, Inc. +# Copyright 1992-2022 Free Software Foundation, Inc. -timestamp='2015-12-14' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2022-09-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -15,7 +17,7 @@ timestamp='2015-12-14' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +35,7 @@ timestamp='2015-12-14' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -50,6 +52,13 @@ timestamp='2015-12-14' # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -57,7 +66,7 @@ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -67,7 +76,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2015 Free Software Foundation, Inc. +Copyright 1992-2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -89,12 +98,12 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -110,1234 +119,1186 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +# shellcheck disable=SC2162 +saved_IFS=$IFS +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova* | managarm-*) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac ;; - -psos*) - os=-psos + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + zephyr*) + basic_machine=$field1-unknown + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + op50n) + cpu=hppa1.1 + vendor=oki ;; - ms1) - basic_machine=mt-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown + ibm*) + cpu=i370 + vendor=ibm ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none + orion105) + cpu=clipper + vendor=highlevel ;; - xscaleeb) - basic_machine=armeb-unknown + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple ;; - - xscaleel) - basic_machine=armel-unknown + pmac | pmac-mpw) + cpu=powerpc + vendor=apple ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att + cpu=m68000 + vendor=att ;; 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=we32k + vendor=att ;; bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec + cpu=powerpc + vendor=ibm + basic_os=cnk ;; decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 + cpu=pdp10 + vendor=dec + basic_os=tops10 ;; decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 + cpu=pdp10 + vendor=dec + basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp + cpu=m68k + vendor=motorola ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 ;; encore | umax | mmax) - basic_machine=ns32k-encore + cpu=ns32k + vendor=encore ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} ;; fx2800) - basic_machine=i860-alliant + cpu=i860 + vendor=alliant ;; genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 + cpu=ns32k + vendor=ns ;; h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp + cpu=m68000 + vendor=hp ;; hp9k3[2-9][0-9]) - basic_machine=m68k-hp + cpu=m68k + vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm + cpu=hppa1.0 + vendor=hp ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} ;; iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) + cpu=mips + vendor=sgi + case $basic_os in + irix*) ;; *) - os=-irix4 + basic_os=irix4 ;; esac ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + cpu=m68000 + vendor=convergent ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint ;; news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) ;; - -ns2*) - os=-nextstep2 + ns2*) + basic_os=nextstep2 ;; *) - os=-nextstep3 + basic_os=nextstep3 ;; esac ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem + cpu=np1 + vendor=gould ;; op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k + cpu=hppa1.1 + vendor=oki + basic_os=proelf ;; pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; pbd) - basic_machine=sparc-tti + cpu=sparc + vendor=tti ;; pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc + cpu=m68k + vendor=tti ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + pc532) + cpu=ns32k + vendor=pc532 ;; pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + cpu=pn + vendor=gould ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + power) + cpu=power + vendor=ibm ;; ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff + cpu=i386 + vendor=ibm ;; rm[46]00) - basic_machine=mips-siemens + cpu=mips + vendor=siemens ;; rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm + cpu=romp + vendor=ibm ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi + sde) + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} ;; - sb1) - basic_machine=mipsisa64sb1-unknown + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown + tower | tower-32) + cpu=m68k + vendor=ncr ;; - sde) - basic_machine=mipsisa32-sde - os=-elf + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu ;; - sei) - basic_machine=mips-sei - os=-seiux + w65) + cpu=w65 + vendor=wdc ;; - sequent) - basic_machine=i386-sequent + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf ;; - sh) - basic_machine=sh-hitachi - os=-hms + none) + cpu=none + vendor=none ;; - sh5el) - basic_machine=sh5le-unknown + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine ;; - sh64) - basic_machine=sh64-unknown + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks + + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read cpu vendor <&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb | arc32 | arc64 \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | loongarch32 | loongarch64 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r3 | mipsisa32r3el \ + | mipsisa32r5 | mipsisa32r5el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r3 | mipsisa64r3el \ + | mipsisa64r5 | mipsisa64r5el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ + | rl78 | romp | rs6000 | rx \ + | s390 | s390x \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | thumbv7* \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1345,201 +1306,219 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if test x$basic_os != x then + +# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` + ;; + os2-emx) + kernel=os2 + os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` + ;; + nto-qnx*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read kernel os <&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1552,261 +1531,376 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +kernel= +case $cpu-$vendor in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + kernel=linux + os=gnu ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; - *-be) - os=-beos + pru-*) + os=elf ;; - *-haiku) - os=-haiku + *-be) + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna + os=luna ;; - *-next ) - os=-nextstep + *-next) + os=nextstep ;; *-sequent) - os=-ptx + os=ptx ;; *-crds) - os=-unos + os=unos ;; *-ns) - os=-genix + os=genix ;; i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-libc", so those need to count as OSes. + musl* | newlib* | relibc* | uclibc*) + ;; + # Likewise for "kernel-abi" + eabi* | gnueabi*) + ;; + # VxWorks passes extra cpu info in the 4th filed. + simlinux | simwindows | spe) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* | serenity* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ + | fiwix* | mlibc* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + kernel* ) + # Restricted further below + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ + | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* ) + ;; + uclinux-uclibc* ) + ;; + managarm-mlibc* | managarm-kernel* ) + ;; + -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + -kernel* ) + echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + *-kernel* ) + echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + vxworks-simlinux | vxworks-simwindows | vxworks-spe) + ;; + nto-qnx*) + ;; + os2-emx) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - -sunos*) + *-sunos*) vendor=sun ;; - -cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - -beos*) + *-beos*) vendor=be ;; - -hpux*) + *-hpux*) vendor=hp ;; - -mpeix*) + *-mpeix*) vendor=hp ;; - -hiux*) + *-hiux*) vendor=hitachi ;; - -unos*) + *-unos*) vendor=crds ;; - -dgux*) + *-dgux*) vendor=dg ;; - -luna*) + *-luna*) vendor=omron ;; - -genix*) + *-genix*) vendor=ns ;; - -mvs* | -opened*) + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) vendor=ibm ;; - -os400*) + s390-* | s390x-*) vendor=ibm ;; - -ptx*) + *-ptx*) vendor=sequent ;; - -tpf*) + *-tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - -aux*) + *-aux*) vendor=apple ;; - -hms*) + *-hms*) vendor=hitachi ;; - -mpw* | -macos*) + *-mpw* | *-macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - -vos*) + *-vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/scripts/i686-w64-mingw32.cmake b/scripts/i686-w64-mingw32.cmake index 58efd58c..bad60db7 100644 --- a/scripts/i686-w64-mingw32.cmake +++ b/scripts/i686-w64-mingw32.cmake @@ -1,4 +1,5 @@ SET(CMAKE_SYSTEM_NAME Windows) +SET(CMAKE_SYSTEM_PROCESSOR i386) SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc) SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres) diff --git a/scripts/test b/scripts/test index f2f0cb84..144930f0 100644 --- a/scripts/test +++ b/scripts/test @@ -1,6 +1,14 @@ #!/bin/sh set -e +unset CC + +if type apt-get >/dev/null +then + sudo apt-get update + sudo apt-get install -y cmake ninja-build +fi + ./autogen.sh if [ "x$ARCH" = "xnative" ]; then @@ -28,9 +36,6 @@ if [ "x$ARCH" = "xnative" ]; then make -j 4 make test else - sudo apt-get update - sudo apt-get install -y cmake ninja-build - cmake -GNinja .. ninja -j 4 ninja test @@ -42,20 +47,12 @@ if [ "x$ARCH" = "xnative" ]; then fi elif [ "x$ARCH" = "xmingw32" -o "x$ARCH" = "xmingw64" ]; then - sudo apt-get update - sudo apt-get install -y cmake ninja-build - CPU=i686 if [ "x$ARCH" = "xmingw64" ]; then CPU=x86_64 fi - export CC=$CPU-w64-mingw32-gcc - if [ -z $(which $CC) ]; then - sudo apt-get update - sudo apt-get install -y mingw-w64 make - export PATH=$PATH:/opt/$ARCH/bin - fi + sudo apt-get install -y mingw-w64 ./configure --host=$CPU-w64-mingw32 make -j 4 @@ -76,30 +73,40 @@ elif [ "x$ARCH" = "xmingw32" -o "x$ARCH" = "xmingw64" ]; then ) elif [ "x$ARCH" = "xarm32" -o "x$ARCH" = "xarm64" ]; then - sudo apt-get update sudo apt-get install -y qemu-user-static binfmt-support if [ "x$ARCH" = "xarm32" ]; then sudo apt-get install -y g++-arm-linux-gnueabihf - sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-*.*.so /lib/ld-linux-armhf.so.3 - export LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib - export CC=arm-linux-gnueabihf-gcc - ./configure --host=arm-linux + sudo ln -sf /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 /lib/ + ./configure --host=arm-linux-gnueabihf + LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib make -j 4 check else sudo apt-get install -y g++-aarch64-linux-gnu - sudo ln -s /usr/aarch64-linux-gnu/lib/ld-*.*.so /lib/ld-linux-aarch64.so.1 - export LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib - export CC=aarch64-linux-gnu-gcc - ./configure --host=aarch64-linux + sudo ln -sf /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 /lib/ + ./configure --host=aarch64-linux-gnu + LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib make -j 4 check fi - make -j 4 check file apps/openssl/.libs/openssl -elif [ "x$ARCH" = "xandroid" ]; then - sudo apt-get update - sudo apt-get install -y cmake ninja-build +elif [ "x$ARCH" = "xmips32" -o "x$ARCH" = "xmips64" ]; then + sudo apt-get install -y qemu-user-static binfmt-support + + if [ "x$ARCH" = "xmips32" ]; then + sudo apt-get install -y g++-mips-linux-gnu + sudo ln -sf /usr/mipsel-linux-gnu/lib/ld.so.1 /lib/ + ./configure --host=mipsel-linux-gnu + LD_LIBRARY_PATH=/usr/mipsel-linux-gnu/lib make -j 4 check + else + sudo apt-get install -y g++-mips64el-linux-gnuabi64 + sudo ln -sf /usr/mips64el-linux-gnuabi64/lib64/ld.so.1 /lib64 + ./configure --host=mips64el-linux-gnuabi64 + LD_LIBRARY_PATH=/usr/mips64el-linux-gnuabi64/lib make -j 4 check + fi + file apps/openssl/.libs/openssl + +elif [ "x$ARCH" = "xandroid" ]; then export TC_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake # set target API level and architecture @@ -125,10 +132,11 @@ elif [ "x$ARCH" = "xandroid" ]; then echo "##### Date: `date`, Native API level: $NAL, ABI: $ABI" ( - build_dir=build_$NAL_$ABI - rm -fr $build_dir + build_dir=build-$NAL_$ABI + rm -fr $build_dir include/openssl/opensslconf.h mkdir $build_dir cd $build_dir + echo "##### cmake -GNinja -DCMAKE_MAKE_PROGRAM=ninja -DANDROID_NDK=$ANDROID_NDK_HOME -DCMAKE_TOOLCHAIN_FILE=$TC_FILE -DANDROID_ABI=$ABI -DANDROID_NATIVE_API_LEVEL=$NAL .." cmake -GNinja -DCMAKE_MAKE_PROGRAM=ninja \ -DANDROID_NDK=$ANDROID_NDK_HOME \ -DCMAKE_TOOLCHAIN_FILE=$TC_FILE \ diff --git a/scripts/x86_64-w64-mingw32.cmake b/scripts/x86_64-w64-mingw32.cmake index c52b6065..df65165f 100644 --- a/scripts/x86_64-w64-mingw32.cmake +++ b/scripts/x86_64-w64-mingw32.cmake @@ -1,4 +1,5 @@ SET(CMAKE_SYSTEM_NAME Windows) +SET(CMAKE_SYSTEM_PROCESSOR amd64) SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt index 8e974a84..f5d52f77 100644 --- a/ssl/CMakeLists.txt +++ b/ssl/CMakeLists.txt @@ -65,6 +65,7 @@ add_library(ssl_obj OBJECT ${SSL_SRC}) target_include_directories(ssl_obj PRIVATE . + hidden ../crypto/bio ../include/compat PUBLIC @@ -79,7 +80,7 @@ target_include_directories(bs_obj if(BUILD_SHARED_LIBS) add_library(ssl $ $) else() - add_library(ssl $) + add_library(ssl $ empty.c) endif() export_symbol(ssl ${CMAKE_CURRENT_SOURCE_DIR}/ssl.sym) diff --git a/ssl/Makefile.am b/ssl/Makefile.am index d5c04665..d27e2af8 100644 --- a/ssl/Makefile.am +++ b/ssl/Makefile.am @@ -15,6 +15,7 @@ noinst_DATA = remove_bs_objects EXTRA_DIST = VERSION EXTRA_DIST += CMakeLists.txt EXTRA_DIST += ssl.sym +EXTRA_DIST += empty.c CLEANFILES = libssl_la_objects.mk @@ -30,6 +31,7 @@ remove_bs_objects: libssl.la -$(AR) dv $(abs_top_builddir)/ssl/.libs/libssl.a \ bs_ber.o bs_cbb.o bs_cbs.o +libssl_la_CPPFLAGS = -I$(top_srcdir)/ssl/hidden ${AM_CPPFLAGS} libssl_la_LDFLAGS = -version-info @LIBSSL_VERSION@ -no-undefined -export-symbols $(top_srcdir)/ssl/ssl.sym libssl_la_LIBADD = $(abs_top_builddir)/crypto/libcrypto.la $(PLATFORM_LDADD) libssl_la_LIBADD += libbs.la @@ -39,6 +41,9 @@ libbs_la_SOURCES += bs_cbb.c libbs_la_SOURCES += bs_cbs.c noinst_HEADERS = bytestring.h +noinst_HEADERS += hidden/ssl_namespace.h +noinst_HEADERS += hidden/openssl/ssl.h + libssl_la_SOURCES = bio_ssl.c libssl_la_SOURCES += d1_both.c libssl_la_SOURCES += d1_lib.c @@ -93,12 +98,13 @@ libssl_la_SOURCES += tls13_record_layer.c libssl_la_SOURCES += tls13_server.c noinst_HEADERS += srtp.h -noinst_HEADERS += dtls_locl.h -noinst_HEADERS += ssl_locl.h +noinst_HEADERS += dtls_local.h +noinst_HEADERS += ssl_local.h noinst_HEADERS += ssl_sigalgs.h noinst_HEADERS += ssl_tlsext.h noinst_HEADERS += tls_content.h noinst_HEADERS += tls_internal.h +noinst_HEADERS += tls12_internal.h noinst_HEADERS += tls13_internal.h noinst_HEADERS += tls13_handshake.h noinst_HEADERS += tls13_record.h diff --git a/ssl/Makefile.in b/ssl/Makefile.in index 12b52459..77ae788c 100644 --- a/ssl/Makefile.in +++ b/ssl/Makefile.in @@ -148,20 +148,32 @@ am__v_lt_1 = am__DEPENDENCIES_1 = libssl_la_DEPENDENCIES = $(abs_top_builddir)/crypto/libcrypto.la \ $(am__DEPENDENCIES_1) libbs.la -am_libssl_la_OBJECTS = bio_ssl.lo d1_both.lo d1_lib.lo d1_pkt.lo \ - d1_srtp.lo pqueue.lo s3_cbc.lo s3_lib.lo ssl_algs.lo \ - ssl_asn1.lo ssl_both.lo ssl_cert.lo ssl_ciph.lo ssl_ciphers.lo \ - ssl_clnt.lo ssl_err.lo ssl_init.lo ssl_kex.lo ssl_lib.lo \ - ssl_methods.lo ssl_packet.lo ssl_pkt.lo ssl_rsa.lo \ - ssl_seclevel.lo ssl_sess.lo ssl_sigalgs.lo ssl_srvr.lo \ - ssl_stat.lo ssl_tlsext.lo ssl_transcript.lo ssl_txt.lo \ - ssl_versions.lo t1_enc.lo t1_lib.lo tls_buffer.lo \ - tls_content.lo tls_key_share.lo tls_lib.lo \ - tls12_key_schedule.lo tls12_lib.lo tls12_record_layer.lo \ - tls13_client.lo tls13_error.lo tls13_handshake.lo \ - tls13_handshake_msg.lo tls13_key_schedule.lo tls13_legacy.lo \ - tls13_lib.lo tls13_quic.lo tls13_record.lo \ - tls13_record_layer.lo tls13_server.lo +am_libssl_la_OBJECTS = libssl_la-bio_ssl.lo libssl_la-d1_both.lo \ + libssl_la-d1_lib.lo libssl_la-d1_pkt.lo libssl_la-d1_srtp.lo \ + libssl_la-pqueue.lo libssl_la-s3_cbc.lo libssl_la-s3_lib.lo \ + libssl_la-ssl_algs.lo libssl_la-ssl_asn1.lo \ + libssl_la-ssl_both.lo libssl_la-ssl_cert.lo \ + libssl_la-ssl_ciph.lo libssl_la-ssl_ciphers.lo \ + libssl_la-ssl_clnt.lo libssl_la-ssl_err.lo \ + libssl_la-ssl_init.lo libssl_la-ssl_kex.lo \ + libssl_la-ssl_lib.lo libssl_la-ssl_methods.lo \ + libssl_la-ssl_packet.lo libssl_la-ssl_pkt.lo \ + libssl_la-ssl_rsa.lo libssl_la-ssl_seclevel.lo \ + libssl_la-ssl_sess.lo libssl_la-ssl_sigalgs.lo \ + libssl_la-ssl_srvr.lo libssl_la-ssl_stat.lo \ + libssl_la-ssl_tlsext.lo libssl_la-ssl_transcript.lo \ + libssl_la-ssl_txt.lo libssl_la-ssl_versions.lo \ + libssl_la-t1_enc.lo libssl_la-t1_lib.lo \ + libssl_la-tls_buffer.lo libssl_la-tls_content.lo \ + libssl_la-tls_key_share.lo libssl_la-tls_lib.lo \ + libssl_la-tls12_key_schedule.lo libssl_la-tls12_lib.lo \ + libssl_la-tls12_record_layer.lo libssl_la-tls13_client.lo \ + libssl_la-tls13_error.lo libssl_la-tls13_handshake.lo \ + libssl_la-tls13_handshake_msg.lo \ + libssl_la-tls13_key_schedule.lo libssl_la-tls13_legacy.lo \ + libssl_la-tls13_lib.lo libssl_la-tls13_quic.lo \ + libssl_la-tls13_record.lo libssl_la-tls13_record_layer.lo \ + libssl_la-tls13_server.lo libssl_la_OBJECTS = $(am_libssl_la_OBJECTS) libssl_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -183,36 +195,59 @@ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ./$(DEPDIR)/bio_ssl.Plo ./$(DEPDIR)/bs_ber.Plo \ - ./$(DEPDIR)/bs_cbb.Plo ./$(DEPDIR)/bs_cbs.Plo \ - ./$(DEPDIR)/d1_both.Plo ./$(DEPDIR)/d1_lib.Plo \ - ./$(DEPDIR)/d1_pkt.Plo ./$(DEPDIR)/d1_srtp.Plo \ - ./$(DEPDIR)/pqueue.Plo ./$(DEPDIR)/s3_cbc.Plo \ - ./$(DEPDIR)/s3_lib.Plo ./$(DEPDIR)/ssl_algs.Plo \ - ./$(DEPDIR)/ssl_asn1.Plo ./$(DEPDIR)/ssl_both.Plo \ - ./$(DEPDIR)/ssl_cert.Plo ./$(DEPDIR)/ssl_ciph.Plo \ - ./$(DEPDIR)/ssl_ciphers.Plo ./$(DEPDIR)/ssl_clnt.Plo \ - ./$(DEPDIR)/ssl_err.Plo ./$(DEPDIR)/ssl_init.Plo \ - ./$(DEPDIR)/ssl_kex.Plo ./$(DEPDIR)/ssl_lib.Plo \ - ./$(DEPDIR)/ssl_methods.Plo ./$(DEPDIR)/ssl_packet.Plo \ - ./$(DEPDIR)/ssl_pkt.Plo ./$(DEPDIR)/ssl_rsa.Plo \ - ./$(DEPDIR)/ssl_seclevel.Plo ./$(DEPDIR)/ssl_sess.Plo \ - ./$(DEPDIR)/ssl_sigalgs.Plo ./$(DEPDIR)/ssl_srvr.Plo \ - ./$(DEPDIR)/ssl_stat.Plo ./$(DEPDIR)/ssl_tlsext.Plo \ - ./$(DEPDIR)/ssl_transcript.Plo ./$(DEPDIR)/ssl_txt.Plo \ - ./$(DEPDIR)/ssl_versions.Plo ./$(DEPDIR)/t1_enc.Plo \ - ./$(DEPDIR)/t1_lib.Plo ./$(DEPDIR)/tls12_key_schedule.Plo \ - ./$(DEPDIR)/tls12_lib.Plo ./$(DEPDIR)/tls12_record_layer.Plo \ - ./$(DEPDIR)/tls13_client.Plo ./$(DEPDIR)/tls13_error.Plo \ - ./$(DEPDIR)/tls13_handshake.Plo \ - ./$(DEPDIR)/tls13_handshake_msg.Plo \ - ./$(DEPDIR)/tls13_key_schedule.Plo \ - ./$(DEPDIR)/tls13_legacy.Plo ./$(DEPDIR)/tls13_lib.Plo \ - ./$(DEPDIR)/tls13_quic.Plo ./$(DEPDIR)/tls13_record.Plo \ - ./$(DEPDIR)/tls13_record_layer.Plo \ - ./$(DEPDIR)/tls13_server.Plo ./$(DEPDIR)/tls_buffer.Plo \ - ./$(DEPDIR)/tls_content.Plo ./$(DEPDIR)/tls_key_share.Plo \ - ./$(DEPDIR)/tls_lib.Plo +am__depfiles_remade = ./$(DEPDIR)/bs_ber.Plo ./$(DEPDIR)/bs_cbb.Plo \ + ./$(DEPDIR)/bs_cbs.Plo ./$(DEPDIR)/libssl_la-bio_ssl.Plo \ + ./$(DEPDIR)/libssl_la-d1_both.Plo \ + ./$(DEPDIR)/libssl_la-d1_lib.Plo \ + ./$(DEPDIR)/libssl_la-d1_pkt.Plo \ + ./$(DEPDIR)/libssl_la-d1_srtp.Plo \ + ./$(DEPDIR)/libssl_la-pqueue.Plo \ + ./$(DEPDIR)/libssl_la-s3_cbc.Plo \ + ./$(DEPDIR)/libssl_la-s3_lib.Plo \ + ./$(DEPDIR)/libssl_la-ssl_algs.Plo \ + ./$(DEPDIR)/libssl_la-ssl_asn1.Plo \ + ./$(DEPDIR)/libssl_la-ssl_both.Plo \ + ./$(DEPDIR)/libssl_la-ssl_cert.Plo \ + ./$(DEPDIR)/libssl_la-ssl_ciph.Plo \ + ./$(DEPDIR)/libssl_la-ssl_ciphers.Plo \ + ./$(DEPDIR)/libssl_la-ssl_clnt.Plo \ + ./$(DEPDIR)/libssl_la-ssl_err.Plo \ + ./$(DEPDIR)/libssl_la-ssl_init.Plo \ + ./$(DEPDIR)/libssl_la-ssl_kex.Plo \ + ./$(DEPDIR)/libssl_la-ssl_lib.Plo \ + ./$(DEPDIR)/libssl_la-ssl_methods.Plo \ + ./$(DEPDIR)/libssl_la-ssl_packet.Plo \ + ./$(DEPDIR)/libssl_la-ssl_pkt.Plo \ + ./$(DEPDIR)/libssl_la-ssl_rsa.Plo \ + ./$(DEPDIR)/libssl_la-ssl_seclevel.Plo \ + ./$(DEPDIR)/libssl_la-ssl_sess.Plo \ + ./$(DEPDIR)/libssl_la-ssl_sigalgs.Plo \ + ./$(DEPDIR)/libssl_la-ssl_srvr.Plo \ + ./$(DEPDIR)/libssl_la-ssl_stat.Plo \ + ./$(DEPDIR)/libssl_la-ssl_tlsext.Plo \ + ./$(DEPDIR)/libssl_la-ssl_transcript.Plo \ + ./$(DEPDIR)/libssl_la-ssl_txt.Plo \ + ./$(DEPDIR)/libssl_la-ssl_versions.Plo \ + ./$(DEPDIR)/libssl_la-t1_enc.Plo \ + ./$(DEPDIR)/libssl_la-t1_lib.Plo \ + ./$(DEPDIR)/libssl_la-tls12_key_schedule.Plo \ + ./$(DEPDIR)/libssl_la-tls12_lib.Plo \ + ./$(DEPDIR)/libssl_la-tls12_record_layer.Plo \ + ./$(DEPDIR)/libssl_la-tls13_client.Plo \ + ./$(DEPDIR)/libssl_la-tls13_error.Plo \ + ./$(DEPDIR)/libssl_la-tls13_handshake.Plo \ + ./$(DEPDIR)/libssl_la-tls13_handshake_msg.Plo \ + ./$(DEPDIR)/libssl_la-tls13_key_schedule.Plo \ + ./$(DEPDIR)/libssl_la-tls13_legacy.Plo \ + ./$(DEPDIR)/libssl_la-tls13_lib.Plo \ + ./$(DEPDIR)/libssl_la-tls13_quic.Plo \ + ./$(DEPDIR)/libssl_la-tls13_record.Plo \ + ./$(DEPDIR)/libssl_la-tls13_record_layer.Plo \ + ./$(DEPDIR)/libssl_la-tls13_server.Plo \ + ./$(DEPDIR)/libssl_la-tls_buffer.Plo \ + ./$(DEPDIR)/libssl_la-tls_content.Plo \ + ./$(DEPDIR)/libssl_la-tls_key_share.Plo \ + ./$(DEPDIR)/libssl_la-tls_lib.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -389,22 +424,26 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ - -DLIBRESSL_INTERNAL -D__BEGIN_HIDDEN_DECLS= \ - -D__END_HIDDEN_DECLS= -I$(top_srcdir)/crypto/bio +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(abs_top_builddir)/include \ + -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL \ + -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= \ + -I$(top_srcdir)/crypto/bio noinst_LTLIBRARIES = libbs.la $(am__append_1) @ENABLE_LIBTLS_ONLY_FALSE@lib_LTLIBRARIES = libssl.la noinst_DATA = remove_bs_objects -EXTRA_DIST = VERSION CMakeLists.txt ssl.sym +EXTRA_DIST = VERSION CMakeLists.txt ssl.sym empty.c CLEANFILES = libssl_la_objects.mk EXTRA_libssl_la_DEPENDENCIES = libssl_la_objects.mk +libssl_la_CPPFLAGS = -I$(top_srcdir)/ssl/hidden ${AM_CPPFLAGS} libssl_la_LDFLAGS = -version-info @LIBSSL_VERSION@ -no-undefined -export-symbols $(top_srcdir)/ssl/ssl.sym libssl_la_LIBADD = $(abs_top_builddir)/crypto/libcrypto.la \ $(PLATFORM_LDADD) libbs.la libbs_la_SOURCES = bs_ber.c bs_cbb.c bs_cbs.c -noinst_HEADERS = bytestring.h srtp.h dtls_locl.h ssl_locl.h \ +noinst_HEADERS = bytestring.h hidden/ssl_namespace.h \ + hidden/openssl/ssl.h srtp.h dtls_local.h ssl_local.h \ ssl_sigalgs.h ssl_tlsext.h tls_content.h tls_internal.h \ - tls13_internal.h tls13_handshake.h tls13_record.h + tls12_internal.h tls13_internal.h tls13_handshake.h \ + tls13_record.h libssl_la_SOURCES = bio_ssl.c d1_both.c d1_lib.c d1_pkt.c d1_srtp.c \ pqueue.c s3_cbc.c s3_lib.c ssl_algs.c ssl_asn1.c ssl_both.c \ ssl_cert.c ssl_ciph.c ssl_ciphers.c ssl_clnt.c ssl_err.c \ @@ -510,61 +549,61 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bio_ssl.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bs_ber.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bs_cbb.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bs_cbs.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/d1_both.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/d1_lib.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/d1_pkt.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/d1_srtp.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pqueue.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s3_cbc.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s3_lib.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_algs.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_asn1.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_both.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_cert.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_ciph.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_ciphers.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_clnt.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_err.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_init.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_kex.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_lib.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_methods.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_packet.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_pkt.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_rsa.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_seclevel.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_sess.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_sigalgs.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_srvr.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_stat.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_tlsext.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_transcript.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_txt.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ssl_versions.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t1_enc.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t1_lib.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls12_key_schedule.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls12_lib.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls12_record_layer.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_client.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_error.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_handshake.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_handshake_msg.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_key_schedule.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_legacy.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_lib.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_quic.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_record.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_record_layer.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls13_server.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_buffer.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_content.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_key_share.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls_lib.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-bio_ssl.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_both.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_lib.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_pkt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-d1_srtp.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-pqueue.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s3_cbc.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-s3_lib.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_algs.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_asn1.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_both.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_cert.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_ciph.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_ciphers.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_clnt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_err.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_init.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_kex.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_lib.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_methods.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_packet.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_pkt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_rsa.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_seclevel.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_sess.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_sigalgs.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_srvr.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_stat.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_tlsext.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_transcript.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_txt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-ssl_versions.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-t1_enc.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-t1_lib.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls12_key_schedule.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls12_lib.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls12_record_layer.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_client.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_error.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_handshake.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_handshake_msg.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_key_schedule.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_legacy.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_lib.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_quic.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_record.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_record_layer.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls13_server.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls_buffer.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls_content.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls_key_share.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssl_la-tls_lib.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -596,6 +635,370 @@ am--depfiles: $(am__depfiles_remade) @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< +libssl_la-bio_ssl.lo: bio_ssl.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-bio_ssl.lo -MD -MP -MF $(DEPDIR)/libssl_la-bio_ssl.Tpo -c -o libssl_la-bio_ssl.lo `test -f 'bio_ssl.c' || echo '$(srcdir)/'`bio_ssl.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-bio_ssl.Tpo $(DEPDIR)/libssl_la-bio_ssl.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bio_ssl.c' object='libssl_la-bio_ssl.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-bio_ssl.lo `test -f 'bio_ssl.c' || echo '$(srcdir)/'`bio_ssl.c + +libssl_la-d1_both.lo: d1_both.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-d1_both.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_both.Tpo -c -o libssl_la-d1_both.lo `test -f 'd1_both.c' || echo '$(srcdir)/'`d1_both.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_both.Tpo $(DEPDIR)/libssl_la-d1_both.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_both.c' object='libssl_la-d1_both.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_both.lo `test -f 'd1_both.c' || echo '$(srcdir)/'`d1_both.c + +libssl_la-d1_lib.lo: d1_lib.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-d1_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_lib.Tpo -c -o libssl_la-d1_lib.lo `test -f 'd1_lib.c' || echo '$(srcdir)/'`d1_lib.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_lib.Tpo $(DEPDIR)/libssl_la-d1_lib.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_lib.c' object='libssl_la-d1_lib.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_lib.lo `test -f 'd1_lib.c' || echo '$(srcdir)/'`d1_lib.c + +libssl_la-d1_pkt.lo: d1_pkt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-d1_pkt.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_pkt.Tpo -c -o libssl_la-d1_pkt.lo `test -f 'd1_pkt.c' || echo '$(srcdir)/'`d1_pkt.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_pkt.Tpo $(DEPDIR)/libssl_la-d1_pkt.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_pkt.c' object='libssl_la-d1_pkt.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_pkt.lo `test -f 'd1_pkt.c' || echo '$(srcdir)/'`d1_pkt.c + +libssl_la-d1_srtp.lo: d1_srtp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-d1_srtp.lo -MD -MP -MF $(DEPDIR)/libssl_la-d1_srtp.Tpo -c -o libssl_la-d1_srtp.lo `test -f 'd1_srtp.c' || echo '$(srcdir)/'`d1_srtp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-d1_srtp.Tpo $(DEPDIR)/libssl_la-d1_srtp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='d1_srtp.c' object='libssl_la-d1_srtp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-d1_srtp.lo `test -f 'd1_srtp.c' || echo '$(srcdir)/'`d1_srtp.c + +libssl_la-pqueue.lo: pqueue.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-pqueue.lo -MD -MP -MF $(DEPDIR)/libssl_la-pqueue.Tpo -c -o libssl_la-pqueue.lo `test -f 'pqueue.c' || echo '$(srcdir)/'`pqueue.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-pqueue.Tpo $(DEPDIR)/libssl_la-pqueue.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pqueue.c' object='libssl_la-pqueue.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-pqueue.lo `test -f 'pqueue.c' || echo '$(srcdir)/'`pqueue.c + +libssl_la-s3_cbc.lo: s3_cbc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-s3_cbc.lo -MD -MP -MF $(DEPDIR)/libssl_la-s3_cbc.Tpo -c -o libssl_la-s3_cbc.lo `test -f 's3_cbc.c' || echo '$(srcdir)/'`s3_cbc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s3_cbc.Tpo $(DEPDIR)/libssl_la-s3_cbc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s3_cbc.c' object='libssl_la-s3_cbc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-s3_cbc.lo `test -f 's3_cbc.c' || echo '$(srcdir)/'`s3_cbc.c + +libssl_la-s3_lib.lo: s3_lib.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-s3_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-s3_lib.Tpo -c -o libssl_la-s3_lib.lo `test -f 's3_lib.c' || echo '$(srcdir)/'`s3_lib.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-s3_lib.Tpo $(DEPDIR)/libssl_la-s3_lib.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='s3_lib.c' object='libssl_la-s3_lib.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-s3_lib.lo `test -f 's3_lib.c' || echo '$(srcdir)/'`s3_lib.c + +libssl_la-ssl_algs.lo: ssl_algs.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_algs.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_algs.Tpo -c -o libssl_la-ssl_algs.lo `test -f 'ssl_algs.c' || echo '$(srcdir)/'`ssl_algs.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_algs.Tpo $(DEPDIR)/libssl_la-ssl_algs.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_algs.c' object='libssl_la-ssl_algs.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_algs.lo `test -f 'ssl_algs.c' || echo '$(srcdir)/'`ssl_algs.c + +libssl_la-ssl_asn1.lo: ssl_asn1.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_asn1.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_asn1.Tpo -c -o libssl_la-ssl_asn1.lo `test -f 'ssl_asn1.c' || echo '$(srcdir)/'`ssl_asn1.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_asn1.Tpo $(DEPDIR)/libssl_la-ssl_asn1.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_asn1.c' object='libssl_la-ssl_asn1.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_asn1.lo `test -f 'ssl_asn1.c' || echo '$(srcdir)/'`ssl_asn1.c + +libssl_la-ssl_both.lo: ssl_both.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_both.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_both.Tpo -c -o libssl_la-ssl_both.lo `test -f 'ssl_both.c' || echo '$(srcdir)/'`ssl_both.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_both.Tpo $(DEPDIR)/libssl_la-ssl_both.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_both.c' object='libssl_la-ssl_both.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_both.lo `test -f 'ssl_both.c' || echo '$(srcdir)/'`ssl_both.c + +libssl_la-ssl_cert.lo: ssl_cert.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_cert.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_cert.Tpo -c -o libssl_la-ssl_cert.lo `test -f 'ssl_cert.c' || echo '$(srcdir)/'`ssl_cert.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_cert.Tpo $(DEPDIR)/libssl_la-ssl_cert.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_cert.c' object='libssl_la-ssl_cert.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_cert.lo `test -f 'ssl_cert.c' || echo '$(srcdir)/'`ssl_cert.c + +libssl_la-ssl_ciph.lo: ssl_ciph.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_ciph.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_ciph.Tpo -c -o libssl_la-ssl_ciph.lo `test -f 'ssl_ciph.c' || echo '$(srcdir)/'`ssl_ciph.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_ciph.Tpo $(DEPDIR)/libssl_la-ssl_ciph.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_ciph.c' object='libssl_la-ssl_ciph.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_ciph.lo `test -f 'ssl_ciph.c' || echo '$(srcdir)/'`ssl_ciph.c + +libssl_la-ssl_ciphers.lo: ssl_ciphers.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_ciphers.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_ciphers.Tpo -c -o libssl_la-ssl_ciphers.lo `test -f 'ssl_ciphers.c' || echo '$(srcdir)/'`ssl_ciphers.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_ciphers.Tpo $(DEPDIR)/libssl_la-ssl_ciphers.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_ciphers.c' object='libssl_la-ssl_ciphers.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_ciphers.lo `test -f 'ssl_ciphers.c' || echo '$(srcdir)/'`ssl_ciphers.c + +libssl_la-ssl_clnt.lo: ssl_clnt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_clnt.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_clnt.Tpo -c -o libssl_la-ssl_clnt.lo `test -f 'ssl_clnt.c' || echo '$(srcdir)/'`ssl_clnt.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_clnt.Tpo $(DEPDIR)/libssl_la-ssl_clnt.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_clnt.c' object='libssl_la-ssl_clnt.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_clnt.lo `test -f 'ssl_clnt.c' || echo '$(srcdir)/'`ssl_clnt.c + +libssl_la-ssl_err.lo: ssl_err.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_err.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_err.Tpo -c -o libssl_la-ssl_err.lo `test -f 'ssl_err.c' || echo '$(srcdir)/'`ssl_err.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_err.Tpo $(DEPDIR)/libssl_la-ssl_err.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_err.c' object='libssl_la-ssl_err.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_err.lo `test -f 'ssl_err.c' || echo '$(srcdir)/'`ssl_err.c + +libssl_la-ssl_init.lo: ssl_init.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_init.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_init.Tpo -c -o libssl_la-ssl_init.lo `test -f 'ssl_init.c' || echo '$(srcdir)/'`ssl_init.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_init.Tpo $(DEPDIR)/libssl_la-ssl_init.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_init.c' object='libssl_la-ssl_init.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_init.lo `test -f 'ssl_init.c' || echo '$(srcdir)/'`ssl_init.c + +libssl_la-ssl_kex.lo: ssl_kex.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_kex.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_kex.Tpo -c -o libssl_la-ssl_kex.lo `test -f 'ssl_kex.c' || echo '$(srcdir)/'`ssl_kex.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_kex.Tpo $(DEPDIR)/libssl_la-ssl_kex.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_kex.c' object='libssl_la-ssl_kex.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_kex.lo `test -f 'ssl_kex.c' || echo '$(srcdir)/'`ssl_kex.c + +libssl_la-ssl_lib.lo: ssl_lib.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_lib.Tpo -c -o libssl_la-ssl_lib.lo `test -f 'ssl_lib.c' || echo '$(srcdir)/'`ssl_lib.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_lib.Tpo $(DEPDIR)/libssl_la-ssl_lib.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_lib.c' object='libssl_la-ssl_lib.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_lib.lo `test -f 'ssl_lib.c' || echo '$(srcdir)/'`ssl_lib.c + +libssl_la-ssl_methods.lo: ssl_methods.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_methods.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_methods.Tpo -c -o libssl_la-ssl_methods.lo `test -f 'ssl_methods.c' || echo '$(srcdir)/'`ssl_methods.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_methods.Tpo $(DEPDIR)/libssl_la-ssl_methods.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_methods.c' object='libssl_la-ssl_methods.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_methods.lo `test -f 'ssl_methods.c' || echo '$(srcdir)/'`ssl_methods.c + +libssl_la-ssl_packet.lo: ssl_packet.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_packet.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_packet.Tpo -c -o libssl_la-ssl_packet.lo `test -f 'ssl_packet.c' || echo '$(srcdir)/'`ssl_packet.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_packet.Tpo $(DEPDIR)/libssl_la-ssl_packet.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_packet.c' object='libssl_la-ssl_packet.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_packet.lo `test -f 'ssl_packet.c' || echo '$(srcdir)/'`ssl_packet.c + +libssl_la-ssl_pkt.lo: ssl_pkt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_pkt.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_pkt.Tpo -c -o libssl_la-ssl_pkt.lo `test -f 'ssl_pkt.c' || echo '$(srcdir)/'`ssl_pkt.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_pkt.Tpo $(DEPDIR)/libssl_la-ssl_pkt.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_pkt.c' object='libssl_la-ssl_pkt.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_pkt.lo `test -f 'ssl_pkt.c' || echo '$(srcdir)/'`ssl_pkt.c + +libssl_la-ssl_rsa.lo: ssl_rsa.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_rsa.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_rsa.Tpo -c -o libssl_la-ssl_rsa.lo `test -f 'ssl_rsa.c' || echo '$(srcdir)/'`ssl_rsa.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_rsa.Tpo $(DEPDIR)/libssl_la-ssl_rsa.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_rsa.c' object='libssl_la-ssl_rsa.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_rsa.lo `test -f 'ssl_rsa.c' || echo '$(srcdir)/'`ssl_rsa.c + +libssl_la-ssl_seclevel.lo: ssl_seclevel.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_seclevel.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_seclevel.Tpo -c -o libssl_la-ssl_seclevel.lo `test -f 'ssl_seclevel.c' || echo '$(srcdir)/'`ssl_seclevel.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_seclevel.Tpo $(DEPDIR)/libssl_la-ssl_seclevel.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_seclevel.c' object='libssl_la-ssl_seclevel.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_seclevel.lo `test -f 'ssl_seclevel.c' || echo '$(srcdir)/'`ssl_seclevel.c + +libssl_la-ssl_sess.lo: ssl_sess.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_sess.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_sess.Tpo -c -o libssl_la-ssl_sess.lo `test -f 'ssl_sess.c' || echo '$(srcdir)/'`ssl_sess.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_sess.Tpo $(DEPDIR)/libssl_la-ssl_sess.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_sess.c' object='libssl_la-ssl_sess.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_sess.lo `test -f 'ssl_sess.c' || echo '$(srcdir)/'`ssl_sess.c + +libssl_la-ssl_sigalgs.lo: ssl_sigalgs.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_sigalgs.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_sigalgs.Tpo -c -o libssl_la-ssl_sigalgs.lo `test -f 'ssl_sigalgs.c' || echo '$(srcdir)/'`ssl_sigalgs.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_sigalgs.Tpo $(DEPDIR)/libssl_la-ssl_sigalgs.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_sigalgs.c' object='libssl_la-ssl_sigalgs.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_sigalgs.lo `test -f 'ssl_sigalgs.c' || echo '$(srcdir)/'`ssl_sigalgs.c + +libssl_la-ssl_srvr.lo: ssl_srvr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_srvr.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_srvr.Tpo -c -o libssl_la-ssl_srvr.lo `test -f 'ssl_srvr.c' || echo '$(srcdir)/'`ssl_srvr.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_srvr.Tpo $(DEPDIR)/libssl_la-ssl_srvr.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_srvr.c' object='libssl_la-ssl_srvr.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_srvr.lo `test -f 'ssl_srvr.c' || echo '$(srcdir)/'`ssl_srvr.c + +libssl_la-ssl_stat.lo: ssl_stat.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_stat.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_stat.Tpo -c -o libssl_la-ssl_stat.lo `test -f 'ssl_stat.c' || echo '$(srcdir)/'`ssl_stat.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_stat.Tpo $(DEPDIR)/libssl_la-ssl_stat.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_stat.c' object='libssl_la-ssl_stat.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_stat.lo `test -f 'ssl_stat.c' || echo '$(srcdir)/'`ssl_stat.c + +libssl_la-ssl_tlsext.lo: ssl_tlsext.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_tlsext.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_tlsext.Tpo -c -o libssl_la-ssl_tlsext.lo `test -f 'ssl_tlsext.c' || echo '$(srcdir)/'`ssl_tlsext.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_tlsext.Tpo $(DEPDIR)/libssl_la-ssl_tlsext.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_tlsext.c' object='libssl_la-ssl_tlsext.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_tlsext.lo `test -f 'ssl_tlsext.c' || echo '$(srcdir)/'`ssl_tlsext.c + +libssl_la-ssl_transcript.lo: ssl_transcript.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_transcript.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_transcript.Tpo -c -o libssl_la-ssl_transcript.lo `test -f 'ssl_transcript.c' || echo '$(srcdir)/'`ssl_transcript.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_transcript.Tpo $(DEPDIR)/libssl_la-ssl_transcript.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_transcript.c' object='libssl_la-ssl_transcript.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_transcript.lo `test -f 'ssl_transcript.c' || echo '$(srcdir)/'`ssl_transcript.c + +libssl_la-ssl_txt.lo: ssl_txt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_txt.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_txt.Tpo -c -o libssl_la-ssl_txt.lo `test -f 'ssl_txt.c' || echo '$(srcdir)/'`ssl_txt.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_txt.Tpo $(DEPDIR)/libssl_la-ssl_txt.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_txt.c' object='libssl_la-ssl_txt.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_txt.lo `test -f 'ssl_txt.c' || echo '$(srcdir)/'`ssl_txt.c + +libssl_la-ssl_versions.lo: ssl_versions.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-ssl_versions.lo -MD -MP -MF $(DEPDIR)/libssl_la-ssl_versions.Tpo -c -o libssl_la-ssl_versions.lo `test -f 'ssl_versions.c' || echo '$(srcdir)/'`ssl_versions.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-ssl_versions.Tpo $(DEPDIR)/libssl_la-ssl_versions.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ssl_versions.c' object='libssl_la-ssl_versions.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-ssl_versions.lo `test -f 'ssl_versions.c' || echo '$(srcdir)/'`ssl_versions.c + +libssl_la-t1_enc.lo: t1_enc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-t1_enc.lo -MD -MP -MF $(DEPDIR)/libssl_la-t1_enc.Tpo -c -o libssl_la-t1_enc.lo `test -f 't1_enc.c' || echo '$(srcdir)/'`t1_enc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-t1_enc.Tpo $(DEPDIR)/libssl_la-t1_enc.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t1_enc.c' object='libssl_la-t1_enc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-t1_enc.lo `test -f 't1_enc.c' || echo '$(srcdir)/'`t1_enc.c + +libssl_la-t1_lib.lo: t1_lib.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-t1_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-t1_lib.Tpo -c -o libssl_la-t1_lib.lo `test -f 't1_lib.c' || echo '$(srcdir)/'`t1_lib.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-t1_lib.Tpo $(DEPDIR)/libssl_la-t1_lib.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t1_lib.c' object='libssl_la-t1_lib.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-t1_lib.lo `test -f 't1_lib.c' || echo '$(srcdir)/'`t1_lib.c + +libssl_la-tls_buffer.lo: tls_buffer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls_buffer.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls_buffer.Tpo -c -o libssl_la-tls_buffer.lo `test -f 'tls_buffer.c' || echo '$(srcdir)/'`tls_buffer.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls_buffer.Tpo $(DEPDIR)/libssl_la-tls_buffer.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls_buffer.c' object='libssl_la-tls_buffer.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls_buffer.lo `test -f 'tls_buffer.c' || echo '$(srcdir)/'`tls_buffer.c + +libssl_la-tls_content.lo: tls_content.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls_content.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls_content.Tpo -c -o libssl_la-tls_content.lo `test -f 'tls_content.c' || echo '$(srcdir)/'`tls_content.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls_content.Tpo $(DEPDIR)/libssl_la-tls_content.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls_content.c' object='libssl_la-tls_content.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls_content.lo `test -f 'tls_content.c' || echo '$(srcdir)/'`tls_content.c + +libssl_la-tls_key_share.lo: tls_key_share.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls_key_share.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls_key_share.Tpo -c -o libssl_la-tls_key_share.lo `test -f 'tls_key_share.c' || echo '$(srcdir)/'`tls_key_share.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls_key_share.Tpo $(DEPDIR)/libssl_la-tls_key_share.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls_key_share.c' object='libssl_la-tls_key_share.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls_key_share.lo `test -f 'tls_key_share.c' || echo '$(srcdir)/'`tls_key_share.c + +libssl_la-tls_lib.lo: tls_lib.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls_lib.Tpo -c -o libssl_la-tls_lib.lo `test -f 'tls_lib.c' || echo '$(srcdir)/'`tls_lib.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls_lib.Tpo $(DEPDIR)/libssl_la-tls_lib.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls_lib.c' object='libssl_la-tls_lib.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls_lib.lo `test -f 'tls_lib.c' || echo '$(srcdir)/'`tls_lib.c + +libssl_la-tls12_key_schedule.lo: tls12_key_schedule.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls12_key_schedule.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls12_key_schedule.Tpo -c -o libssl_la-tls12_key_schedule.lo `test -f 'tls12_key_schedule.c' || echo '$(srcdir)/'`tls12_key_schedule.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls12_key_schedule.Tpo $(DEPDIR)/libssl_la-tls12_key_schedule.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls12_key_schedule.c' object='libssl_la-tls12_key_schedule.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls12_key_schedule.lo `test -f 'tls12_key_schedule.c' || echo '$(srcdir)/'`tls12_key_schedule.c + +libssl_la-tls12_lib.lo: tls12_lib.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls12_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls12_lib.Tpo -c -o libssl_la-tls12_lib.lo `test -f 'tls12_lib.c' || echo '$(srcdir)/'`tls12_lib.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls12_lib.Tpo $(DEPDIR)/libssl_la-tls12_lib.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls12_lib.c' object='libssl_la-tls12_lib.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls12_lib.lo `test -f 'tls12_lib.c' || echo '$(srcdir)/'`tls12_lib.c + +libssl_la-tls12_record_layer.lo: tls12_record_layer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls12_record_layer.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls12_record_layer.Tpo -c -o libssl_la-tls12_record_layer.lo `test -f 'tls12_record_layer.c' || echo '$(srcdir)/'`tls12_record_layer.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls12_record_layer.Tpo $(DEPDIR)/libssl_la-tls12_record_layer.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls12_record_layer.c' object='libssl_la-tls12_record_layer.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls12_record_layer.lo `test -f 'tls12_record_layer.c' || echo '$(srcdir)/'`tls12_record_layer.c + +libssl_la-tls13_client.lo: tls13_client.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_client.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_client.Tpo -c -o libssl_la-tls13_client.lo `test -f 'tls13_client.c' || echo '$(srcdir)/'`tls13_client.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_client.Tpo $(DEPDIR)/libssl_la-tls13_client.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_client.c' object='libssl_la-tls13_client.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_client.lo `test -f 'tls13_client.c' || echo '$(srcdir)/'`tls13_client.c + +libssl_la-tls13_error.lo: tls13_error.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_error.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_error.Tpo -c -o libssl_la-tls13_error.lo `test -f 'tls13_error.c' || echo '$(srcdir)/'`tls13_error.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_error.Tpo $(DEPDIR)/libssl_la-tls13_error.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_error.c' object='libssl_la-tls13_error.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_error.lo `test -f 'tls13_error.c' || echo '$(srcdir)/'`tls13_error.c + +libssl_la-tls13_handshake.lo: tls13_handshake.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_handshake.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_handshake.Tpo -c -o libssl_la-tls13_handshake.lo `test -f 'tls13_handshake.c' || echo '$(srcdir)/'`tls13_handshake.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_handshake.Tpo $(DEPDIR)/libssl_la-tls13_handshake.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_handshake.c' object='libssl_la-tls13_handshake.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_handshake.lo `test -f 'tls13_handshake.c' || echo '$(srcdir)/'`tls13_handshake.c + +libssl_la-tls13_handshake_msg.lo: tls13_handshake_msg.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_handshake_msg.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_handshake_msg.Tpo -c -o libssl_la-tls13_handshake_msg.lo `test -f 'tls13_handshake_msg.c' || echo '$(srcdir)/'`tls13_handshake_msg.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_handshake_msg.Tpo $(DEPDIR)/libssl_la-tls13_handshake_msg.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_handshake_msg.c' object='libssl_la-tls13_handshake_msg.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_handshake_msg.lo `test -f 'tls13_handshake_msg.c' || echo '$(srcdir)/'`tls13_handshake_msg.c + +libssl_la-tls13_key_schedule.lo: tls13_key_schedule.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_key_schedule.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_key_schedule.Tpo -c -o libssl_la-tls13_key_schedule.lo `test -f 'tls13_key_schedule.c' || echo '$(srcdir)/'`tls13_key_schedule.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_key_schedule.Tpo $(DEPDIR)/libssl_la-tls13_key_schedule.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_key_schedule.c' object='libssl_la-tls13_key_schedule.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_key_schedule.lo `test -f 'tls13_key_schedule.c' || echo '$(srcdir)/'`tls13_key_schedule.c + +libssl_la-tls13_legacy.lo: tls13_legacy.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_legacy.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_legacy.Tpo -c -o libssl_la-tls13_legacy.lo `test -f 'tls13_legacy.c' || echo '$(srcdir)/'`tls13_legacy.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_legacy.Tpo $(DEPDIR)/libssl_la-tls13_legacy.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_legacy.c' object='libssl_la-tls13_legacy.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_legacy.lo `test -f 'tls13_legacy.c' || echo '$(srcdir)/'`tls13_legacy.c + +libssl_la-tls13_lib.lo: tls13_lib.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_lib.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_lib.Tpo -c -o libssl_la-tls13_lib.lo `test -f 'tls13_lib.c' || echo '$(srcdir)/'`tls13_lib.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_lib.Tpo $(DEPDIR)/libssl_la-tls13_lib.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_lib.c' object='libssl_la-tls13_lib.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_lib.lo `test -f 'tls13_lib.c' || echo '$(srcdir)/'`tls13_lib.c + +libssl_la-tls13_quic.lo: tls13_quic.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_quic.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_quic.Tpo -c -o libssl_la-tls13_quic.lo `test -f 'tls13_quic.c' || echo '$(srcdir)/'`tls13_quic.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_quic.Tpo $(DEPDIR)/libssl_la-tls13_quic.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_quic.c' object='libssl_la-tls13_quic.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_quic.lo `test -f 'tls13_quic.c' || echo '$(srcdir)/'`tls13_quic.c + +libssl_la-tls13_record.lo: tls13_record.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_record.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_record.Tpo -c -o libssl_la-tls13_record.lo `test -f 'tls13_record.c' || echo '$(srcdir)/'`tls13_record.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_record.Tpo $(DEPDIR)/libssl_la-tls13_record.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_record.c' object='libssl_la-tls13_record.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_record.lo `test -f 'tls13_record.c' || echo '$(srcdir)/'`tls13_record.c + +libssl_la-tls13_record_layer.lo: tls13_record_layer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_record_layer.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_record_layer.Tpo -c -o libssl_la-tls13_record_layer.lo `test -f 'tls13_record_layer.c' || echo '$(srcdir)/'`tls13_record_layer.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_record_layer.Tpo $(DEPDIR)/libssl_la-tls13_record_layer.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_record_layer.c' object='libssl_la-tls13_record_layer.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_record_layer.lo `test -f 'tls13_record_layer.c' || echo '$(srcdir)/'`tls13_record_layer.c + +libssl_la-tls13_server.lo: tls13_server.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libssl_la-tls13_server.lo -MD -MP -MF $(DEPDIR)/libssl_la-tls13_server.Tpo -c -o libssl_la-tls13_server.lo `test -f 'tls13_server.c' || echo '$(srcdir)/'`tls13_server.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libssl_la-tls13_server.Tpo $(DEPDIR)/libssl_la-tls13_server.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tls13_server.c' object='libssl_la-tls13_server.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libssl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libssl_la-tls13_server.lo `test -f 'tls13_server.c' || echo '$(srcdir)/'`tls13_server.c + mostlyclean-libtool: -rm -f *.lo @@ -730,61 +1133,61 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-am - -rm -f ./$(DEPDIR)/bio_ssl.Plo - -rm -f ./$(DEPDIR)/bs_ber.Plo + -rm -f ./$(DEPDIR)/bs_ber.Plo -rm -f ./$(DEPDIR)/bs_cbb.Plo -rm -f ./$(DEPDIR)/bs_cbs.Plo - -rm -f ./$(DEPDIR)/d1_both.Plo - -rm -f ./$(DEPDIR)/d1_lib.Plo - -rm -f ./$(DEPDIR)/d1_pkt.Plo - -rm -f ./$(DEPDIR)/d1_srtp.Plo - -rm -f ./$(DEPDIR)/pqueue.Plo - -rm -f ./$(DEPDIR)/s3_cbc.Plo - -rm -f ./$(DEPDIR)/s3_lib.Plo - -rm -f ./$(DEPDIR)/ssl_algs.Plo - -rm -f ./$(DEPDIR)/ssl_asn1.Plo - -rm -f ./$(DEPDIR)/ssl_both.Plo - -rm -f ./$(DEPDIR)/ssl_cert.Plo - -rm -f ./$(DEPDIR)/ssl_ciph.Plo - -rm -f ./$(DEPDIR)/ssl_ciphers.Plo - -rm -f ./$(DEPDIR)/ssl_clnt.Plo - -rm -f ./$(DEPDIR)/ssl_err.Plo - -rm -f ./$(DEPDIR)/ssl_init.Plo - -rm -f ./$(DEPDIR)/ssl_kex.Plo - -rm -f ./$(DEPDIR)/ssl_lib.Plo - -rm -f ./$(DEPDIR)/ssl_methods.Plo - -rm -f ./$(DEPDIR)/ssl_packet.Plo - -rm -f ./$(DEPDIR)/ssl_pkt.Plo - -rm -f ./$(DEPDIR)/ssl_rsa.Plo - -rm -f ./$(DEPDIR)/ssl_seclevel.Plo - -rm -f ./$(DEPDIR)/ssl_sess.Plo - -rm -f ./$(DEPDIR)/ssl_sigalgs.Plo - -rm -f ./$(DEPDIR)/ssl_srvr.Plo - -rm -f ./$(DEPDIR)/ssl_stat.Plo - -rm -f ./$(DEPDIR)/ssl_tlsext.Plo - -rm -f ./$(DEPDIR)/ssl_transcript.Plo - -rm -f ./$(DEPDIR)/ssl_txt.Plo - -rm -f ./$(DEPDIR)/ssl_versions.Plo - -rm -f ./$(DEPDIR)/t1_enc.Plo - -rm -f ./$(DEPDIR)/t1_lib.Plo - -rm -f ./$(DEPDIR)/tls12_key_schedule.Plo - -rm -f ./$(DEPDIR)/tls12_lib.Plo - -rm -f ./$(DEPDIR)/tls12_record_layer.Plo - -rm -f ./$(DEPDIR)/tls13_client.Plo - -rm -f ./$(DEPDIR)/tls13_error.Plo - -rm -f ./$(DEPDIR)/tls13_handshake.Plo - -rm -f ./$(DEPDIR)/tls13_handshake_msg.Plo - -rm -f ./$(DEPDIR)/tls13_key_schedule.Plo - -rm -f ./$(DEPDIR)/tls13_legacy.Plo - -rm -f ./$(DEPDIR)/tls13_lib.Plo - -rm -f ./$(DEPDIR)/tls13_quic.Plo - -rm -f ./$(DEPDIR)/tls13_record.Plo - -rm -f ./$(DEPDIR)/tls13_record_layer.Plo - -rm -f ./$(DEPDIR)/tls13_server.Plo - -rm -f ./$(DEPDIR)/tls_buffer.Plo - -rm -f ./$(DEPDIR)/tls_content.Plo - -rm -f ./$(DEPDIR)/tls_key_share.Plo - -rm -f ./$(DEPDIR)/tls_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-bio_ssl.Plo + -rm -f ./$(DEPDIR)/libssl_la-d1_both.Plo + -rm -f ./$(DEPDIR)/libssl_la-d1_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-d1_pkt.Plo + -rm -f ./$(DEPDIR)/libssl_la-d1_srtp.Plo + -rm -f ./$(DEPDIR)/libssl_la-pqueue.Plo + -rm -f ./$(DEPDIR)/libssl_la-s3_cbc.Plo + -rm -f ./$(DEPDIR)/libssl_la-s3_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_algs.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_asn1.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_both.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_cert.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_ciph.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_ciphers.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_clnt.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_err.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_init.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_kex.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_methods.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_packet.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_pkt.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_rsa.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_seclevel.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_sess.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_sigalgs.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_srvr.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_stat.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_tlsext.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_transcript.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_txt.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_versions.Plo + -rm -f ./$(DEPDIR)/libssl_la-t1_enc.Plo + -rm -f ./$(DEPDIR)/libssl_la-t1_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls12_key_schedule.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls12_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls12_record_layer.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_client.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_error.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_handshake.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_handshake_msg.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_key_schedule.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_legacy.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_quic.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_record.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_record_layer.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_server.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls_buffer.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls_content.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls_key_share.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls_lib.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -830,61 +1233,61 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -f ./$(DEPDIR)/bio_ssl.Plo - -rm -f ./$(DEPDIR)/bs_ber.Plo + -rm -f ./$(DEPDIR)/bs_ber.Plo -rm -f ./$(DEPDIR)/bs_cbb.Plo -rm -f ./$(DEPDIR)/bs_cbs.Plo - -rm -f ./$(DEPDIR)/d1_both.Plo - -rm -f ./$(DEPDIR)/d1_lib.Plo - -rm -f ./$(DEPDIR)/d1_pkt.Plo - -rm -f ./$(DEPDIR)/d1_srtp.Plo - -rm -f ./$(DEPDIR)/pqueue.Plo - -rm -f ./$(DEPDIR)/s3_cbc.Plo - -rm -f ./$(DEPDIR)/s3_lib.Plo - -rm -f ./$(DEPDIR)/ssl_algs.Plo - -rm -f ./$(DEPDIR)/ssl_asn1.Plo - -rm -f ./$(DEPDIR)/ssl_both.Plo - -rm -f ./$(DEPDIR)/ssl_cert.Plo - -rm -f ./$(DEPDIR)/ssl_ciph.Plo - -rm -f ./$(DEPDIR)/ssl_ciphers.Plo - -rm -f ./$(DEPDIR)/ssl_clnt.Plo - -rm -f ./$(DEPDIR)/ssl_err.Plo - -rm -f ./$(DEPDIR)/ssl_init.Plo - -rm -f ./$(DEPDIR)/ssl_kex.Plo - -rm -f ./$(DEPDIR)/ssl_lib.Plo - -rm -f ./$(DEPDIR)/ssl_methods.Plo - -rm -f ./$(DEPDIR)/ssl_packet.Plo - -rm -f ./$(DEPDIR)/ssl_pkt.Plo - -rm -f ./$(DEPDIR)/ssl_rsa.Plo - -rm -f ./$(DEPDIR)/ssl_seclevel.Plo - -rm -f ./$(DEPDIR)/ssl_sess.Plo - -rm -f ./$(DEPDIR)/ssl_sigalgs.Plo - -rm -f ./$(DEPDIR)/ssl_srvr.Plo - -rm -f ./$(DEPDIR)/ssl_stat.Plo - -rm -f ./$(DEPDIR)/ssl_tlsext.Plo - -rm -f ./$(DEPDIR)/ssl_transcript.Plo - -rm -f ./$(DEPDIR)/ssl_txt.Plo - -rm -f ./$(DEPDIR)/ssl_versions.Plo - -rm -f ./$(DEPDIR)/t1_enc.Plo - -rm -f ./$(DEPDIR)/t1_lib.Plo - -rm -f ./$(DEPDIR)/tls12_key_schedule.Plo - -rm -f ./$(DEPDIR)/tls12_lib.Plo - -rm -f ./$(DEPDIR)/tls12_record_layer.Plo - -rm -f ./$(DEPDIR)/tls13_client.Plo - -rm -f ./$(DEPDIR)/tls13_error.Plo - -rm -f ./$(DEPDIR)/tls13_handshake.Plo - -rm -f ./$(DEPDIR)/tls13_handshake_msg.Plo - -rm -f ./$(DEPDIR)/tls13_key_schedule.Plo - -rm -f ./$(DEPDIR)/tls13_legacy.Plo - -rm -f ./$(DEPDIR)/tls13_lib.Plo - -rm -f ./$(DEPDIR)/tls13_quic.Plo - -rm -f ./$(DEPDIR)/tls13_record.Plo - -rm -f ./$(DEPDIR)/tls13_record_layer.Plo - -rm -f ./$(DEPDIR)/tls13_server.Plo - -rm -f ./$(DEPDIR)/tls_buffer.Plo - -rm -f ./$(DEPDIR)/tls_content.Plo - -rm -f ./$(DEPDIR)/tls_key_share.Plo - -rm -f ./$(DEPDIR)/tls_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-bio_ssl.Plo + -rm -f ./$(DEPDIR)/libssl_la-d1_both.Plo + -rm -f ./$(DEPDIR)/libssl_la-d1_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-d1_pkt.Plo + -rm -f ./$(DEPDIR)/libssl_la-d1_srtp.Plo + -rm -f ./$(DEPDIR)/libssl_la-pqueue.Plo + -rm -f ./$(DEPDIR)/libssl_la-s3_cbc.Plo + -rm -f ./$(DEPDIR)/libssl_la-s3_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_algs.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_asn1.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_both.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_cert.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_ciph.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_ciphers.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_clnt.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_err.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_init.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_kex.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_methods.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_packet.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_pkt.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_rsa.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_seclevel.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_sess.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_sigalgs.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_srvr.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_stat.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_tlsext.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_transcript.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_txt.Plo + -rm -f ./$(DEPDIR)/libssl_la-ssl_versions.Plo + -rm -f ./$(DEPDIR)/libssl_la-t1_enc.Plo + -rm -f ./$(DEPDIR)/libssl_la-t1_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls12_key_schedule.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls12_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls12_record_layer.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_client.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_error.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_handshake.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_handshake_msg.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_key_schedule.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_legacy.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_lib.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_quic.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_record.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_record_layer.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls13_server.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls_buffer.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls_content.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls_key_share.Plo + -rm -f ./$(DEPDIR)/libssl_la-tls_lib.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/ssl/VERSION b/ssl/VERSION index d10daf35..c0f571e1 100644 --- a/ssl/VERSION +++ b/ssl/VERSION @@ -1 +1 @@ -53:0:0 +53:2:0 diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c index e86b9d83..1a8cda84 100644 --- a/ssl/bio_ssl.c +++ b/ssl/bio_ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_ssl.c,v 1.33 2022/01/14 09:12:53 tb Exp $ */ +/* $OpenBSD: bio_ssl.c,v 1.38 2023/02/16 08:38:17 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -67,7 +67,7 @@ #include #include "bio_local.h" -#include "ssl_locl.h" +#include "ssl_local.h" static int ssl_write(BIO *h, const char *buf, int num); static int ssl_read(BIO *h, char *buf, int size); @@ -103,6 +103,7 @@ BIO_f_ssl(void) { return (&methods_sslp); } +LSSL_ALIAS(BIO_f_ssl); static int ssl_new(BIO *bi) @@ -294,11 +295,9 @@ ssl_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_CTRL_RESET: SSL_shutdown(ssl); - if (ssl->internal->handshake_func == - ssl->method->ssl_connect) + if (ssl->handshake_func == ssl->method->ssl_connect) SSL_set_connect_state(ssl); - else if (ssl->internal->handshake_func == - ssl->method->ssl_accept) + else if (ssl->handshake_func == ssl->method->ssl_accept) SSL_set_accept_state(ssl); SSL_clear(ssl); @@ -534,6 +533,7 @@ BIO_new_ssl_connect(SSL_CTX *ctx) BIO_free(ssl); return (NULL); } +LSSL_ALIAS(BIO_new_ssl_connect); BIO * BIO_new_ssl(SSL_CTX *ctx, int client) @@ -558,6 +558,7 @@ BIO_new_ssl(SSL_CTX *ctx, int client) BIO_free(ret); return (NULL); } +LSSL_ALIAS(BIO_new_ssl); int BIO_ssl_copy_session_id(BIO *t, BIO *f) diff --git a/ssl/bytestring.h b/ssl/bytestring.h index 022bc683..51284da8 100644 --- a/ssl/bytestring.h +++ b/ssl/bytestring.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bytestring.h,v 1.23 2022/01/06 14:30:30 jsing Exp $ */ +/* $OpenBSD: bytestring.h,v 1.24 2022/11/09 23:14:51 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -80,11 +80,9 @@ int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len); /* * CBS_strdup copies the current contents of |cbs| into |*out_ptr| as a * NUL-terminated C string. If |*out_ptr| is not NULL, the contents are freed - * with free. It returns one on success and zero on allocation - * failure. On success, |*out_ptr| should be freed with free. - * - * NOTE: If |cbs| contains NUL bytes, the string will be truncated. Call - * |CBS_contains_zero_byte(cbs)| to check for NUL bytes. + * with free. It returns one on success and zero on failure. On success, + * |*out_ptr| should be freed with free. If |cbs| contains NUL bytes, + * CBS_strdup will fail. */ int CBS_strdup(const CBS *cbs, char **out_ptr); diff --git a/ssl/d1_both.c b/ssl/d1_both.c index fd7c07a4..b5c68a17 100644 --- a/ssl/d1_both.c +++ b/ssl/d1_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_both.c,v 1.81 2022/02/05 14:54:10 jsing Exp $ */ +/* $OpenBSD: d1_both.c,v 1.84 2022/12/26 07:31:44 jmc Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -123,9 +123,9 @@ #include #include "bytestring.h" -#include "dtls_locl.h" +#include "dtls_local.h" #include "pqueue.h" -#include "ssl_locl.h" +#include "ssl_local.h" #define RSMBLY_BITMASK_SIZE(msg_len) (((msg_len) + 7) / 8) @@ -206,7 +206,7 @@ dtls1_hm_fragment_free(hm_fragment *frag) free(frag); } -/* send s->internal->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or SSL3_RT_CHANGE_CIPHER_SPEC) */ +/* send s->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or SSL3_RT_CHANGE_CIPHER_SPEC) */ int dtls1_do_write(SSL *s, int type) { @@ -237,15 +237,15 @@ dtls1_do_write(SSL *s, int type) OPENSSL_assert(s->d1->mtu >= dtls1_min_mtu()); /* should have something reasonable now */ - if (s->internal->init_off == 0 && type == SSL3_RT_HANDSHAKE) - OPENSSL_assert(s->internal->init_num == + if (s->init_off == 0 && type == SSL3_RT_HANDSHAKE) + OPENSSL_assert(s->init_num == (int)s->d1->w_msg_hdr.msg_len + DTLS1_HM_HEADER_LENGTH); - if (!tls12_record_layer_write_overhead(s->internal->rl, &overhead)) + if (!tls12_record_layer_write_overhead(s->rl, &overhead)) return -1; frag_off = 0; - while (s->internal->init_num) { + while (s->init_num) { curr_mtu = s->d1->mtu - BIO_wpending(SSL_get_wbio(s)) - DTLS1_RT_HEADER_LENGTH - overhead; @@ -258,22 +258,22 @@ dtls1_do_write(SSL *s, int type) overhead; } - if (s->internal->init_num > curr_mtu) + if (s->init_num > curr_mtu) len = curr_mtu; else - len = s->internal->init_num; + len = s->init_num; /* XDTLS: this function is too long. split out the CCS part */ if (type == SSL3_RT_HANDSHAKE) { - if (s->internal->init_off != 0) { - OPENSSL_assert(s->internal->init_off > DTLS1_HM_HEADER_LENGTH); - s->internal->init_off -= DTLS1_HM_HEADER_LENGTH; - s->internal->init_num += DTLS1_HM_HEADER_LENGTH; + if (s->init_off != 0) { + OPENSSL_assert(s->init_off > DTLS1_HM_HEADER_LENGTH); + s->init_off -= DTLS1_HM_HEADER_LENGTH; + s->init_num += DTLS1_HM_HEADER_LENGTH; - if (s->internal->init_num > curr_mtu) + if (s->init_num > curr_mtu) len = curr_mtu; else - len = s->internal->init_num; + len = s->init_num; } dtls1_fix_message_header(s, frag_off, @@ -281,14 +281,14 @@ dtls1_do_write(SSL *s, int type) if (!dtls1_write_message_header(&s->d1->w_msg_hdr, s->d1->w_msg_hdr.frag_off, s->d1->w_msg_hdr.frag_len, - (unsigned char *)&s->internal->init_buf->data[s->internal->init_off])) + (unsigned char *)&s->init_buf->data[s->init_off])) return -1; OPENSSL_assert(len >= DTLS1_HM_HEADER_LENGTH); } ret = dtls1_write_bytes(s, type, - &s->internal->init_buf->data[s->internal->init_off], len); + &s->init_buf->data[s->init_off], len); if (ret < 0) { /* * Might need to update MTU here, but we don't know @@ -319,7 +319,7 @@ dtls1_do_write(SSL *s, int type) * but in that case we'll ignore the result * anyway */ - unsigned char *p = (unsigned char *)&s->internal->init_buf->data[s->internal->init_off]; + unsigned char *p = (unsigned char *)&s->init_buf->data[s->init_off]; const struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr; int xlen; @@ -340,21 +340,21 @@ dtls1_do_write(SSL *s, int type) tls1_transcript_record(s, p, xlen); } - if (ret == s->internal->init_num) { - if (s->internal->msg_callback) - s->internal->msg_callback(1, s->version, type, - s->internal->init_buf->data, - (size_t)(s->internal->init_off + s->internal->init_num), - s, s->internal->msg_callback_arg); + if (ret == s->init_num) { + if (s->msg_callback) + s->msg_callback(1, s->version, type, + s->init_buf->data, + (size_t)(s->init_off + s->init_num), + s, s->msg_callback_arg); - s->internal->init_off = 0; + s->init_off = 0; /* done writing this message */ - s->internal->init_num = 0; + s->init_num = 0; return (1); } - s->internal->init_off += ret; - s->internal->init_num -= ret; + s->init_off += ret; + s->init_num -= ret; frag_off += (ret -= DTLS1_HM_HEADER_LENGTH); } } @@ -377,7 +377,7 @@ dtls1_get_message(SSL *s, int st1, int stn, int mt, long max) int i, al, ok; /* - * s3->internal->tmp is used to store messages that are unexpected, caused + * s3->tmp is used to store messages that are unexpected, caused * by the absence of an optional handshake message */ if (s->s3->hs.tls12.reuse_message) { @@ -387,8 +387,8 @@ dtls1_get_message(SSL *s, int st1, int stn, int mt, long max) SSLerror(s, SSL_R_UNEXPECTED_MESSAGE); goto fatal_err; } - s->internal->init_msg = s->internal->init_buf->data + DTLS1_HM_HEADER_LENGTH; - s->internal->init_num = (int)s->s3->hs.tls12.message_size; + s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH; + s->init_num = (int)s->s3->hs.tls12.message_size; return 1; } @@ -403,7 +403,7 @@ dtls1_get_message(SSL *s, int st1, int stn, int mt, long max) else if (i <= 0 && !ok) return i; - p = (unsigned char *)s->internal->init_buf->data; + p = (unsigned char *)s->init_buf->data; msg_len = msg_hdr->msg_len; /* reconstruct message header */ @@ -413,9 +413,9 @@ dtls1_get_message(SSL *s, int st1, int stn, int mt, long max) msg_len += DTLS1_HM_HEADER_LENGTH; tls1_transcript_record(s, p, msg_len); - if (s->internal->msg_callback) - s->internal->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, p, msg_len, - s, s->internal->msg_callback_arg); + if (s->msg_callback) + s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, p, msg_len, + s, s->msg_callback_arg); memset(msg_hdr, 0, sizeof(struct hm_header_st)); @@ -423,7 +423,7 @@ dtls1_get_message(SSL *s, int st1, int stn, int mt, long max) if (!s->d1->listen) s->d1->handshake_read_seq++; - s->internal->init_msg = s->internal->init_buf->data + DTLS1_HM_HEADER_LENGTH; + s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH; return 1; fatal_err: @@ -457,7 +457,7 @@ dtls1_preprocess_fragment(SSL *s, struct hm_header_st *msg_hdr, int max) * msg_len is limited to 2^24, but is effectively checked * against max above */ - if (!BUF_MEM_grow_clean(s->internal->init_buf, + if (!BUF_MEM_grow_clean(s->init_buf, msg_len + DTLS1_HM_HEADER_LENGTH)) { SSLerror(s, ERR_R_BUF_LIB); return SSL_AD_INTERNAL_ERROR; @@ -486,8 +486,8 @@ dtls1_retrieve_buffered_fragment(SSL *s, long max, int *ok) /* * (0) check whether the desired fragment is available * if so: - * (1) copy over the fragment to s->internal->init_buf->data[] - * (2) update s->internal->init_num + * (1) copy over the fragment to s->init_buf->data[] + * (2) update s->init_num */ pitem *item; hm_fragment *frag; @@ -512,7 +512,7 @@ dtls1_retrieve_buffered_fragment(SSL *s, long max, int *ok) if (al == 0) /* no alert */ { - unsigned char *p = (unsigned char *)s->internal->init_buf->data + DTLS1_HM_HEADER_LENGTH; + unsigned char *p = (unsigned char *)s->init_buf->data + DTLS1_HM_HEADER_LENGTH; memcpy(&p[frag->msg_header.frag_off], frag->fragment, frag->msg_header.frag_len); } @@ -526,7 +526,7 @@ dtls1_retrieve_buffered_fragment(SSL *s, long max, int *ok) } ssl3_send_alert(s, SSL3_AL_FATAL, al); - s->internal->init_num = 0; + s->init_num = 0; *ok = 0; return -1; } else @@ -544,8 +544,8 @@ dtls1_max_handshake_message_len(const SSL *s) unsigned long max_len; max_len = DTLS1_HM_HEADER_LENGTH + SSL3_RT_MAX_ENCRYPTED_LENGTH; - if (max_len < (unsigned long)s->internal->max_cert_list) - return s->internal->max_cert_list; + if (max_len < (unsigned long)s->max_cert_list) + return s->max_cert_list; return max_len; } @@ -749,7 +749,7 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok) /* see if we have the required fragment already */ if ((frag_len = dtls1_retrieve_buffered_fragment(s, max, ok)) || *ok) { if (*ok) - s->internal->init_num = frag_len; + s->init_num = frag_len; return frag_len; } @@ -758,7 +758,7 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok) DTLS1_HM_HEADER_LENGTH, 0); if (i <= 0) { /* nbio, or an error */ - s->internal->rwstate = SSL_READING; + s->rwstate = SSL_READING; *ok = 0; return i; } @@ -797,16 +797,16 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok) * 'Finished' MAC. */ if (wire[1] == 0 && wire[2] == 0 && wire[3] == 0) { - if (s->internal->msg_callback) - s->internal->msg_callback(0, s->version, + if (s->msg_callback) + s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, wire, DTLS1_HM_HEADER_LENGTH, s, - s->internal->msg_callback_arg); + s->msg_callback_arg); - s->internal->init_num = 0; + s->init_num = 0; goto again; } - else /* Incorrectly formated Hello request */ + else /* Incorrectly formatted Hello request */ { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerror(s, SSL_R_UNEXPECTED_MESSAGE); @@ -817,17 +817,17 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok) if ((al = dtls1_preprocess_fragment(s, &msg_hdr, max))) goto fatal_err; - /* XDTLS: ressurect this when restart is in place */ + /* XDTLS: resurrect this when restart is in place */ s->s3->hs.state = stn; if (frag_len > 0) { - unsigned char *p = (unsigned char *)s->internal->init_buf->data + DTLS1_HM_HEADER_LENGTH; + unsigned char *p = (unsigned char *)s->init_buf->data + DTLS1_HM_HEADER_LENGTH; i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &p[frag_off], frag_len, 0); /* XDTLS: fix this--message fragments cannot span multiple packets */ if (i <= 0) { - s->internal->rwstate = SSL_READING; + s->rwstate = SSL_READING; *ok = 0; return i; } @@ -845,18 +845,18 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok) } /* - * Note that s->internal->init_num is *not* used as current offset in - * s->internal->init_buf->data, but as a counter summing up fragments' + * Note that s->init_num is *not* used as current offset in + * s->init_buf->data, but as a counter summing up fragments' * lengths: as soon as they sum up to handshake packet * length, we assume we have got all the fragments. */ - s->internal->init_num = frag_len; + s->init_num = frag_len; *ok = 1; return frag_len; fatal_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); - s->internal->init_num = 0; + s->init_num = 0; *ok = 0; return (-1); @@ -942,23 +942,23 @@ dtls1_buffer_message(SSL *s, int is_ccs) hm_fragment *frag; unsigned char seq64be[8]; - /* Buffer the messsage in order to handle DTLS retransmissions. */ + /* Buffer the message in order to handle DTLS retransmissions. */ /* * This function is called immediately after a message has * been serialized */ - OPENSSL_assert(s->internal->init_off == 0); + OPENSSL_assert(s->init_off == 0); - frag = dtls1_hm_fragment_new(s->internal->init_num, 0); + frag = dtls1_hm_fragment_new(s->init_num, 0); if (frag == NULL) return 0; - memcpy(frag->fragment, s->internal->init_buf->data, s->internal->init_num); + memcpy(frag->fragment, s->init_buf->data, s->init_num); OPENSSL_assert(s->d1->w_msg_hdr.msg_len + (is_ccs ? DTLS1_CCS_HEADER_LENGTH : DTLS1_HM_HEADER_LENGTH) == - (unsigned int)s->internal->init_num); + (unsigned int)s->init_num); frag->msg_header.msg_len = s->d1->w_msg_hdr.msg_len; frag->msg_header.seq = s->d1->w_msg_hdr.seq; @@ -970,7 +970,7 @@ dtls1_buffer_message(SSL *s, int is_ccs) /* save current state*/ frag->msg_header.saved_retransmit_state.session = s->session; frag->msg_header.saved_retransmit_state.epoch = - tls12_record_layer_write_epoch(s->internal->rl); + tls12_record_layer_write_epoch(s->rl); memset(seq64be, 0, sizeof(seq64be)); seq64be[6] = (unsigned char)(dtls1_get_queue_priority( @@ -1001,8 +1001,8 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, struct dtls1_retransmit_state saved_state; /* - OPENSSL_assert(s->internal->init_num == 0); - OPENSSL_assert(s->internal->init_off == 0); + OPENSSL_assert(s->init_num == 0); + OPENSSL_assert(s->init_off == 0); */ /* XDTLS: the requested message ought to be found, otherwise error */ @@ -1027,9 +1027,9 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, else header_length = DTLS1_HM_HEADER_LENGTH; - memcpy(s->internal->init_buf->data, frag->fragment, + memcpy(s->init_buf->data, frag->fragment, frag->msg_header.msg_len + header_length); - s->internal->init_num = frag->msg_header.msg_len + header_length; + s->init_num = frag->msg_header.msg_len + header_length; dtls1_set_message_header_int(s, frag->msg_header.type, frag->msg_header.msg_len, frag->msg_header.seq, 0, @@ -1037,13 +1037,13 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, /* save current state */ saved_state.session = s->session; - saved_state.epoch = tls12_record_layer_write_epoch(s->internal->rl); + saved_state.epoch = tls12_record_layer_write_epoch(s->rl); s->d1->retransmitting = 1; /* restore state in which the message was originally sent */ s->session = frag->msg_header.saved_retransmit_state.session; - if (!tls12_record_layer_use_write_epoch(s->internal->rl, + if (!tls12_record_layer_use_write_epoch(s->rl, frag->msg_header.saved_retransmit_state.epoch)) return 0; @@ -1052,7 +1052,7 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off, /* restore current state */ s->session = saved_state.session; - if (!tls12_record_layer_use_write_epoch(s->internal->rl, + if (!tls12_record_layer_use_write_epoch(s->rl, saved_state.epoch)) return 0; @@ -1073,7 +1073,7 @@ dtls1_clear_record_buffer(SSL *s) item = pqueue_pop(s->d1->sent_messages)) { frag = item->data; if (frag->msg_header.is_ccs) - tls12_record_layer_write_epoch_done(s->internal->rl, + tls12_record_layer_write_epoch_done(s->rl, frag->msg_header.saved_retransmit_state.epoch); dtls1_hm_fragment_free(frag); pitem_free(item); diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c index 770734e6..ae6a6650 100644 --- a/ssl/d1_lib.c +++ b/ssl/d1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_lib.c,v 1.61 2021/10/23 13:36:03 jsing Exp $ */ +/* $OpenBSD: d1_lib.c,v 1.64 2022/11/26 16:08:55 tb Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -67,9 +67,9 @@ #include -#include "dtls_locl.h" +#include "dtls_local.h" #include "pqueue.h" -#include "ssl_locl.h" +#include "ssl_local.h" void dtls1_hm_fragment_free(hm_fragment *frag); @@ -104,6 +104,23 @@ dtls1_new(SSL *s) return (0); } +static void +dtls1_drain_rcontents(pqueue queue) +{ + DTLS1_RCONTENT_DATA_INTERNAL *rdata; + pitem *item; + + if (queue == NULL) + return; + + while ((item = pqueue_pop(queue)) != NULL) { + rdata = (DTLS1_RCONTENT_DATA_INTERNAL *)item->data; + tls_content_free(rdata->rcontent); + free(item->data); + pitem_free(item); + } +} + static void dtls1_drain_records(pqueue queue) { @@ -141,7 +158,7 @@ dtls1_clear_queues(SSL *s) dtls1_drain_records(s->d1->unprocessed_rcds.q); dtls1_drain_fragments(s->d1->buffered_messages); dtls1_drain_fragments(s->d1->sent_messages); - dtls1_drain_records(s->d1->buffered_app_data.q); + dtls1_drain_rcontents(s->d1->buffered_app_data.q); } void @@ -187,7 +204,7 @@ dtls1_clear(SSL *s) memset(s->d1, 0, sizeof(*s->d1)); s->d1->unprocessed_rcds.epoch = - tls12_record_layer_read_epoch(s->internal->rl) + 1; + tls12_record_layer_read_epoch(s->rl) + 1; if (s->server) { s->d1->cookie_len = sizeof(s->d1->cookie); diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c index 456f871a..5409d392 100644 --- a/ssl/d1_pkt.c +++ b/ssl/d1_pkt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_pkt.c,v 1.123 2022/03/26 15:05:53 jsing Exp $ */ +/* $OpenBSD: d1_pkt.c,v 1.127 2022/11/26 16:08:55 tb Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -115,15 +115,17 @@ #include #include +#include #include #include #include #include "bytestring.h" -#include "dtls_locl.h" +#include "dtls_local.h" #include "pqueue.h" -#include "ssl_locl.h" +#include "ssl_local.h" +#include "tls_content.h" /* mod 128 saturating subtract of two 64-bit values in big-endian order */ static int @@ -193,8 +195,8 @@ dtls1_copy_record(SSL *s, DTLS1_RECORD_DATA_INTERNAL *rdata) { ssl3_release_buffer(&s->s3->rbuf); - s->internal->packet = rdata->packet; - s->internal->packet_length = rdata->packet_length; + s->packet = rdata->packet; + s->packet_length = rdata->packet_length; memcpy(&(s->s3->rbuf), &(rdata->rbuf), sizeof(SSL3_BUFFER_INTERNAL)); memcpy(&(s->s3->rrec), &(rdata->rrec), sizeof(SSL3_RECORD_INTERNAL)); @@ -216,15 +218,15 @@ dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority) if (rdata == NULL || item == NULL) goto init_err; - rdata->packet = s->internal->packet; - rdata->packet_length = s->internal->packet_length; + rdata->packet = s->packet; + rdata->packet_length = s->packet_length; memcpy(&(rdata->rbuf), &(s->s3->rbuf), sizeof(SSL3_BUFFER_INTERNAL)); memcpy(&(rdata->rrec), &(s->s3->rrec), sizeof(SSL3_RECORD_INTERNAL)); item->data = rdata; - s->internal->packet = NULL; - s->internal->packet_length = 0; + s->packet = NULL; + s->packet_length = 0; memset(&(s->s3->rbuf), 0, sizeof(SSL3_BUFFER_INTERNAL)); memset(&(s->s3->rrec), 0, sizeof(SSL3_RECORD_INTERNAL)); @@ -247,6 +249,44 @@ dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority) return (-1); } +static int +dtls1_buffer_rcontent(SSL *s, rcontent_pqueue *queue, unsigned char *priority) +{ + DTLS1_RCONTENT_DATA_INTERNAL *rdata; + pitem *item; + + /* Limit the size of the queue to prevent DOS attacks */ + if (pqueue_size(queue->q) >= 100) + return 0; + + rdata = malloc(sizeof(DTLS1_RCONTENT_DATA_INTERNAL)); + item = pitem_new(priority, rdata); + if (rdata == NULL || item == NULL) + goto init_err; + + rdata->rcontent = s->s3->rcontent; + s->s3->rcontent = NULL; + + item->data = rdata; + + /* insert should not fail, since duplicates are dropped */ + if (pqueue_insert(queue->q, item) == NULL) + goto err; + + if ((s->s3->rcontent = tls_content_new()) == NULL) + goto err; + + return (1); + + err: + tls_content_free(rdata->rcontent); + + init_err: + SSLerror(s, ERR_R_INTERNAL_ERROR); + free(rdata); + pitem_free(item); + return (-1); +} static int dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue) @@ -266,18 +306,41 @@ dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue) return (0); } +static int +dtls1_retrieve_buffered_rcontent(SSL *s, rcontent_pqueue *queue) +{ + DTLS1_RCONTENT_DATA_INTERNAL *rdata; + pitem *item; + + item = pqueue_pop(queue->q); + if (item) { + rdata = item->data; + + tls_content_free(s->s3->rcontent); + s->s3->rcontent = rdata->rcontent; + s->s3->rrec.epoch = tls_content_epoch(s->s3->rcontent); + + free(item->data); + pitem_free(item); + + return (1); + } + + return (0); +} + static int dtls1_process_buffered_record(SSL *s) { /* Check if epoch is current. */ if (s->d1->unprocessed_rcds.epoch != - tls12_record_layer_read_epoch(s->internal->rl)) + tls12_record_layer_read_epoch(s->rl)) return (0); /* Update epoch once all unprocessed records have been processed. */ if (pqueue_peek(s->d1->unprocessed_rcds.q) == NULL) { s->d1->unprocessed_rcds.epoch = - tls12_record_layer_read_epoch(s->internal->rl) + 1; + tls12_record_layer_read_epoch(s->rl) + 1; return (0); } @@ -295,14 +358,12 @@ dtls1_process_record(SSL *s) { SSL3_RECORD_INTERNAL *rr = &(s->s3->rrec); uint8_t alert_desc; - uint8_t *out; - size_t out_len; - tls12_record_layer_set_version(s->internal->rl, s->version); + tls12_record_layer_set_version(s->rl, s->version); - if (!tls12_record_layer_open_record(s->internal->rl, s->internal->packet, - s->internal->packet_length, &out, &out_len)) { - tls12_record_layer_alert(s->internal->rl, &alert_desc); + if (!tls12_record_layer_open_record(s->rl, s->packet, s->packet_length, + s->s3->rcontent)) { + tls12_record_layer_alert(s->rl, &alert_desc); if (alert_desc == 0) goto err; @@ -311,10 +372,8 @@ dtls1_process_record(SSL *s) * DTLS should silently discard invalid records, including those * with a bad MAC, as per RFC 6347 section 4.1.2.1. */ - if (alert_desc == SSL_AD_BAD_RECORD_MAC) { - out_len = 0; + if (alert_desc == SSL_AD_BAD_RECORD_MAC) goto done; - } if (alert_desc == SSL_AD_RECORD_OVERFLOW) SSLerror(s, SSL_R_ENCRYPTED_LENGTH_TOO_LONG); @@ -322,12 +381,11 @@ dtls1_process_record(SSL *s) goto fatal_err; } - done: - rr->data = out; - rr->length = out_len; - rr->off = 0; + /* XXX move to record layer. */ + tls_content_set_epoch(s->s3->rcontent, rr->epoch); - s->internal->packet_length = 0; + done: + s->packet_length = 0; return (1); @@ -341,9 +399,9 @@ dtls1_process_record(SSL *s) * It will return <= 0 if more data is needed, normally due to an error * or non-blocking IO. * When it finishes, one packet has been decoded and can be found in - * ssl->s3->internal->rrec.type - is the type of record - * ssl->s3->internal->rrec.data, - data - * ssl->s3->internal->rrec.length, - number of bytes + * ssl->s3->rrec.type - is the type of record + * ssl->s3->rrec.data, - data + * ssl->s3->rrec.length, - number of bytes */ /* used only by dtls1_read_bytes */ int @@ -364,12 +422,12 @@ dtls1_get_record(SSL *s) again: /* dump this record on all retries */ rr->length = 0; - s->internal->packet_length = 0; + s->packet_length = 0; } /* check if we have the header */ - if ((s->internal->rstate != SSL_ST_READ_BODY) || - (s->internal->packet_length < DTLS1_RT_HEADER_LENGTH)) { + if ((s->rstate != SSL_ST_READ_BODY) || + (s->packet_length < DTLS1_RT_HEADER_LENGTH)) { CBS header, seq_no; uint16_t epoch, len, ssl_version; uint8_t type; @@ -382,9 +440,9 @@ dtls1_get_record(SSL *s) if (n != DTLS1_RT_HEADER_LENGTH) goto again; - s->internal->rstate = SSL_ST_READ_BODY; + s->rstate = SSL_ST_READ_BODY; - CBS_init(&header, s->internal->packet, s->internal->packet_length); + CBS_init(&header, s->packet, s->packet_length); /* Pull apart the header into the DTLS1_RECORD */ if (!CBS_get_u8(&header, &type)) @@ -409,7 +467,7 @@ dtls1_get_record(SSL *s) rr->length = len; /* unexpected version, silently discard */ - if (!s->internal->first_packet && ssl_version != s->version) + if (!s->first_packet && ssl_version != s->version) goto again; /* wrong version, silently discard record */ @@ -420,11 +478,11 @@ dtls1_get_record(SSL *s) if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH) goto again; - /* now s->internal->rstate == SSL_ST_READ_BODY */ + /* now s->rstate == SSL_ST_READ_BODY */ p = (unsigned char *)CBS_data(&header); } - /* s->internal->rstate == SSL_ST_READ_BODY, get and decode the data */ + /* s->rstate == SSL_ST_READ_BODY, get and decode the data */ n = ssl3_packet_extend(s, DTLS1_RT_HEADER_LENGTH + rr->length); if (n <= 0) @@ -434,7 +492,7 @@ dtls1_get_record(SSL *s) if (n != DTLS1_RT_HEADER_LENGTH + rr->length) goto again; - s->internal->rstate = SSL_ST_READ_HEADER; /* set state for later operations */ + s->rstate = SSL_ST_READ_HEADER; /* set state for later operations */ /* match epochs. NULL means the packet is dropped on the floor */ bitmap = dtls1_get_bitmap(s, rr, &is_next_epoch); @@ -463,7 +521,7 @@ dtls1_get_record(SSL *s) * anything while listening. */ if (is_next_epoch) { - if ((SSL_in_init(s) || s->internal->in_handshake) && !s->d1->listen) { + if ((SSL_in_init(s) || s->in_handshake) && !s->d1->listen) { if (dtls1_buffer_record(s, &(s->d1->unprocessed_rcds), rr->seq_num) < 0) return (-1); @@ -485,29 +543,25 @@ dtls1_get_record(SSL *s) static int dtls1_read_handshake_unexpected(SSL *s) { - SSL3_RECORD_INTERNAL *rr = &s->s3->rrec; struct hm_header_st hs_msg_hdr; CBS cbs; int ret; - if (s->internal->in_handshake) { - SSLerror(s, ERR_R_INTERNAL_ERROR); - return -1; - } - - if (rr->off != 0) { + if (s->in_handshake) { SSLerror(s, ERR_R_INTERNAL_ERROR); return -1; } /* Parse handshake message header. */ - CBS_init(&cbs, rr->data, rr->length); + CBS_dup(tls_content_cbs(s->s3->rcontent), &cbs); if (!dtls1_get_message_header(&cbs, &hs_msg_hdr)) return -1; /* XXX - probably should drop/continue. */ /* This may just be a stale retransmit. */ - if (rr->epoch != tls12_record_layer_read_epoch(s->internal->rl)) { - rr->length = 0; + if (tls_content_epoch(s->s3->rcontent) != + tls12_record_layer_read_epoch(s->rl)) { + tls_content_clear(s->s3->rcontent); + s->s3->rrec.length = 0; return 1; } @@ -532,10 +586,11 @@ dtls1_read_handshake_unexpected(SSL *s) return -1; } - ssl_msg_callback(s, 0, SSL3_RT_HANDSHAKE, rr->data, - DTLS1_HM_HEADER_LENGTH); + ssl_msg_callback_cbs(s, 0, SSL3_RT_HANDSHAKE, + tls_content_cbs(s->s3->rcontent)); - rr->length = 0; + tls_content_clear(s->s3->rcontent); + s->s3->rrec.length = 0; /* * It should be impossible to hit this, but keep the safety @@ -556,7 +611,7 @@ dtls1_read_handshake_unexpected(SSL *s) s->d1->handshake_read_seq++; /* XXX - why is this set here but not in ssl3? */ - s->internal->new_session = 1; + s->new_session = 1; if (!ssl3_renegotiate(s)) return 1; @@ -589,7 +644,7 @@ dtls1_read_handshake_unexpected(SSL *s) return -1; } - if ((s->internal->options & SSL_OP_NO_CLIENT_RENEGOTIATION) != 0) { + if ((s->options & SSL_OP_NO_CLIENT_RENEGOTIATION) != 0) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_NO_RENEGOTIATION); return -1; @@ -609,8 +664,8 @@ dtls1_read_handshake_unexpected(SSL *s) } s->s3->hs.state = SSL_ST_ACCEPT; - s->internal->renegotiate = 1; - s->internal->new_session = 1; + s->renegotiate = 1; + s->new_session = 1; } else if (hs_msg_hdr.type == SSL3_MT_FINISHED && s->server) { /* @@ -624,7 +679,8 @@ dtls1_read_handshake_unexpected(SSL *s) dtls1_retransmit_buffered_messages(s); - rr->length = 0; + tls_content_clear(s->s3->rcontent); + s->s3->rrec.length = 0; return 1; @@ -634,14 +690,14 @@ dtls1_read_handshake_unexpected(SSL *s) return -1; } - if ((ret = s->internal->handshake_func(s)) < 0) + if ((ret = s->handshake_func(s)) < 0) return ret; if (ret == 0) { SSLerror(s, SSL_R_SSL_HANDSHAKE_FAILURE); return -1; } - if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { + if (!(s->mode & SSL_MODE_AUTO_RETRY)) { if (s->s3->rbuf.left == 0) { ssl_force_want_read(s); return -1; @@ -685,9 +741,8 @@ dtls1_read_handshake_unexpected(SSL *s) int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) { - SSL3_RECORD_INTERNAL *rr; int rrcount = 0; - unsigned int n; + ssize_t ssret; int ret; if (s->s3->rbuf.buf == NULL) { @@ -695,6 +750,11 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) return -1; } + if (s->s3->rcontent == NULL) { + if ((s->s3->rcontent = tls_content_new()) == NULL) + return -1; + } + if (len < 0) { SSLerror(s, ERR_R_INTERNAL_ERROR); return -1; @@ -710,8 +770,8 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) return -1; } - if (SSL_in_init(s) && !s->internal->in_handshake) { - if ((ret = s->internal->handshake_func(s)) < 0) + if (SSL_in_init(s) && !s->in_handshake) { + if ((ret = s->handshake_func(s)) < 0) return ret; if (ret == 0) { SSLerror(s, SSL_R_SSL_HANDSHAKE_FAILURE); @@ -733,21 +793,20 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) return -1; } - s->internal->rwstate = SSL_NOTHING; - - rr = &s->s3->rrec; + s->rwstate = SSL_NOTHING; /* * We are not handshaking and have no data yet, so process data buffered * during the last handshake in advance, if any. */ - if (s->s3->hs.state == SSL_ST_OK && rr->length == 0) - dtls1_retrieve_buffered_record(s, &s->d1->buffered_app_data); + if (s->s3->hs.state == SSL_ST_OK && + tls_content_remaining(s->s3->rcontent) == 0) + dtls1_retrieve_buffered_rcontent(s, &s->d1->buffered_app_data); if (dtls1_handle_timeout(s) > 0) goto start; - if (rr->length == 0 || s->internal->rstate == SSL_ST_READ_BODY) { + if (tls_content_remaining(s->s3->rcontent) == 0) { if ((ret = dtls1_get_record(s)) <= 0) { /* Anything other than a timeout is an error. */ if ((ret = dtls1_read_failed(s, ret)) <= 0) @@ -756,26 +815,30 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) } } - if (s->d1->listen && rr->type != SSL3_RT_HANDSHAKE) { - rr->length = 0; + if (s->d1->listen && + tls_content_type(s->s3->rcontent) != SSL3_RT_HANDSHAKE) { + tls_content_clear(s->s3->rcontent); + s->s3->rrec.length = 0; goto start; } /* We now have a packet which can be read and processed. */ - if (s->s3->change_cipher_spec && rr->type != SSL3_RT_HANDSHAKE) { + if (s->s3->change_cipher_spec && + tls_content_type(s->s3->rcontent) != SSL3_RT_HANDSHAKE) { /* * We now have application data between CCS and Finished. * Most likely the packets were reordered on their way, so * buffer the application data for later processing rather * than dropping the connection. */ - if (dtls1_buffer_record(s, &s->d1->buffered_app_data, - rr->seq_num) < 0) { + if (dtls1_buffer_rcontent(s, &s->d1->buffered_app_data, + s->s3->rrec.seq_num) < 0) { SSLerror(s, ERR_R_INTERNAL_ERROR); return (-1); } - rr->length = 0; + tls_content_clear(s->s3->rcontent); + s->s3->rrec.length = 0; goto start; } @@ -783,20 +846,21 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) * If the other end has shut down, throw anything we read away (even in * 'peek' mode). */ - if (s->internal->shutdown & SSL_RECEIVED_SHUTDOWN) { - s->internal->rwstate = SSL_NOTHING; - rr->length = 0; + if (s->shutdown & SSL_RECEIVED_SHUTDOWN) { + s->rwstate = SSL_NOTHING; + tls_content_clear(s->s3->rcontent); + s->s3->rrec.length = 0; return 0; } /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */ - if (type == rr->type) { + if (tls_content_type(s->s3->rcontent) == type) { /* * Make sure that we are not getting application data when we * are doing a handshake for the first time. */ if (SSL_in_init(s) && type == SSL3_RT_APPLICATION_DATA && - !tls12_record_layer_read_protected(s->internal->rl)) { + !tls12_record_layer_read_protected(s->rl)) { SSLerror(s, SSL_R_APP_DATA_IN_HANDSHAKE); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE); @@ -806,43 +870,36 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) if (len <= 0) return len; - if ((unsigned int)len > rr->length) - n = rr->length; - else - n = (unsigned int)len; - - memcpy(buf, &rr->data[rr->off], n); - if (!peek) { - memset(&rr->data[rr->off], 0, n); - rr->length -= n; - rr->off += n; - if (rr->length == 0) { - s->internal->rstate = SSL_ST_READ_HEADER; - rr->off = 0; - } + if (peek) { + ssret = tls_content_peek(s->s3->rcontent, buf, len); + } else { + ssret = tls_content_read(s->s3->rcontent, buf, len); } + if (ssret < INT_MIN || ssret > INT_MAX) + return -1; + if (ssret < 0) + return (int)ssret; - return n; - } + if (tls_content_remaining(s->s3->rcontent) == 0) + s->rstate = SSL_ST_READ_HEADER; - /* - * If we get here, then type != rr->type; if we have a handshake - * message, then it was unexpected (Hello Request or Client Hello). - */ + return (int)ssret; + } - if (rr->type == SSL3_RT_ALERT) { + if (tls_content_type(s->s3->rcontent) == SSL3_RT_ALERT) { if ((ret = ssl3_read_alert(s)) <= 0) return ret; goto start; } - if (s->internal->shutdown & SSL_SENT_SHUTDOWN) { - s->internal->rwstate = SSL_NOTHING; - rr->length = 0; + if (s->shutdown & SSL_SENT_SHUTDOWN) { + s->rwstate = SSL_NOTHING; + tls_content_clear(s->s3->rcontent); + s->s3->rrec.length = 0; return (0); } - if (rr->type == SSL3_RT_APPLICATION_DATA) { + if (tls_content_type(s->s3->rcontent) == SSL3_RT_APPLICATION_DATA) { /* * At this point, we were expecting handshake data, but have * application data. If the library was running inside @@ -868,13 +925,13 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) } } - if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) { + if (tls_content_type(s->s3->rcontent) == SSL3_RT_CHANGE_CIPHER_SPEC) { if ((ret = ssl3_read_change_cipher_spec(s)) <= 0) return ret; goto start; } - if (rr->type == SSL3_RT_HANDSHAKE) { + if (tls_content_type(s->s3->rcontent) == SSL3_RT_HANDSHAKE) { if ((ret = dtls1_read_handshake_unexpected(s)) <= 0) return ret; goto start; @@ -891,9 +948,8 @@ dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, int len) { int i; - if (SSL_in_init(s) && !s->internal->in_handshake) - { - i = s->internal->handshake_func(s); + if (SSL_in_init(s) && !s->in_handshake) { + i = s->handshake_func(s); if (i < 0) return (i); if (i == 0) { @@ -920,7 +976,7 @@ dtls1_write_bytes(SSL *s, int type, const void *buf, int len) int i; OPENSSL_assert(len <= SSL3_RT_MAX_PLAIN_LENGTH); - s->internal->rwstate = SSL_NOTHING; + s->rwstate = SSL_NOTHING; i = do_dtls1_write(s, type, buf, len); return i; } @@ -959,9 +1015,9 @@ do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len) if (!CBB_init_fixed(&cbb, wb->buf, wb->len)) goto err; - tls12_record_layer_set_version(s->internal->rl, s->version); + tls12_record_layer_set_version(s->rl, s->version); - if (!tls12_record_layer_seal_record(s->internal->rl, type, buf, len, &cbb)) + if (!tls12_record_layer_seal_record(s->rl, type, buf, len, &cbb)) goto err; if (!CBB_finish(&cbb, NULL, &out_len)) @@ -1035,7 +1091,7 @@ dtls1_get_bitmap(SSL *s, SSL3_RECORD_INTERNAL *rr, unsigned int *is_next_epoch) *is_next_epoch = 0; - read_epoch = tls12_record_layer_read_epoch(s->internal->rl); + read_epoch = tls12_record_layer_read_epoch(s->rl); read_epoch_next = read_epoch + 1; /* In current epoch, accept HM, CCS, DATA, & ALERT */ diff --git a/ssl/d1_srtp.c b/ssl/d1_srtp.c index 793fa868..6073f0d2 100644 --- a/ssl/d1_srtp.c +++ b/ssl/d1_srtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_srtp.c,v 1.30 2022/01/28 13:11:56 inoguchi Exp $ */ +/* $OpenBSD: d1_srtp.c,v 1.32 2022/11/26 16:08:55 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -123,8 +123,8 @@ #ifndef OPENSSL_NO_SRTP #include "bytestring.h" -#include "dtls_locl.h" -#include "ssl_locl.h" +#include "dtls_local.h" +#include "ssl_local.h" #include "srtp.h" static const SRTP_PROTECTION_PROFILE srtp_known_profiles[] = { @@ -227,13 +227,13 @@ ssl_ctx_make_profiles(const char *profiles_string, int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles) { - return ssl_ctx_make_profiles(profiles, &ctx->internal->srtp_profiles); + return ssl_ctx_make_profiles(profiles, &ctx->srtp_profiles); } int SSL_set_tlsext_use_srtp(SSL *s, const char *profiles) { - return ssl_ctx_make_profiles(profiles, &s->internal->srtp_profiles); + return ssl_ctx_make_profiles(profiles, &s->srtp_profiles); } @@ -241,11 +241,11 @@ STACK_OF(SRTP_PROTECTION_PROFILE) * SSL_get_srtp_profiles(SSL *s) { if (s != NULL) { - if (s->internal->srtp_profiles != NULL) { - return s->internal->srtp_profiles; + if (s->srtp_profiles != NULL) { + return s->srtp_profiles; } else if ((s->ctx != NULL) && - (s->ctx->internal->srtp_profiles != NULL)) { - return s->ctx->internal->srtp_profiles; + (s->ctx->srtp_profiles != NULL)) { + return s->ctx->srtp_profiles; } } @@ -256,7 +256,7 @@ SRTP_PROTECTION_PROFILE * SSL_get_selected_srtp_profile(SSL *s) { /* XXX cast away the const */ - return (SRTP_PROTECTION_PROFILE *)s->internal->srtp_profile; + return (SRTP_PROTECTION_PROFILE *)s->srtp_profile; } #endif diff --git a/ssl/dtls_locl.h b/ssl/dtls_local.h similarity index 94% rename from ssl/dtls_locl.h rename to ssl/dtls_local.h index da5c259a..c7c413fe 100644 --- a/ssl/dtls_locl.h +++ b/ssl/dtls_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dtls_locl.h,v 1.10 2021/10/23 13:45:44 jsing Exp $ */ +/* $OpenBSD: dtls_local.h,v 1.2 2022/11/26 17:23:18 tb Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -64,7 +64,8 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" +#include "tls_content.h" __BEGIN_HIDDEN_DECLS @@ -109,6 +110,11 @@ typedef struct record_pqueue_st { struct _pqueue *q; } record_pqueue; +typedef struct rcontent_pqueue_st { + unsigned short epoch; + struct _pqueue *q; +} rcontent_pqueue; + typedef struct hm_fragment_st { struct hm_header_st msg_header; unsigned char *fragment; @@ -122,6 +128,10 @@ typedef struct dtls1_record_data_internal_st { SSL3_RECORD_INTERNAL rrec; } DTLS1_RECORD_DATA_INTERNAL; +typedef struct dtls1_rcontent_data_internal_st { + struct tls_content *rcontent; +} DTLS1_RCONTENT_DATA_INTERNAL; + struct dtls1_state_st { /* Buffered (sent) handshake records */ struct _pqueue *sent_messages; @@ -160,7 +170,7 @@ struct dtls1_state_st { * to prevent either protocol violation or * unnecessary message loss. */ - record_pqueue buffered_app_data; + rcontent_pqueue buffered_app_data; /* Is set when listening for new connections with dtls1_listen() */ unsigned int listen; @@ -219,4 +229,4 @@ int dtls1_get_record(SSL *s); __END_HIDDEN_DECLS -#endif +#endif /* !HEADER_DTLS_LOCL_H */ diff --git a/ssl/empty.c b/ssl/empty.c new file mode 100644 index 00000000..e69de29b diff --git a/ssl/hidden/openssl/ssl.h b/ssl/hidden/openssl/ssl.h new file mode 100644 index 00000000..f171ec20 --- /dev/null +++ b/ssl/hidden/openssl/ssl.h @@ -0,0 +1,35 @@ +/* $OpenBSD: ssl.h,v 1.1 2022/11/11 11:25:18 beck Exp $ */ +/* + * Copyright (c) 2022 Philip Guenther + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBSSL_SSL_H_ +#define _LIBSSL_SSL_H_ + +#ifdef _MSC_VER +#include <../include/openssl/ssl.h> +#else +#include_next +#endif +#include "ssl_namespace.h" + +LSSL_USED(BIO_f_ssl); +LSSL_USED(BIO_new_ssl); +LSSL_USED(BIO_new_ssl_connect); +LSSL_UNUSED(BIO_new_buffer_ssl_connect); +LSSL_UNUSED(BIO_ssl_copy_session_id); +LSSL_UNUSED(BIO_ssl_shutdown); + +#endif /* _LIBSSL_SSL_H_ */ diff --git a/ssl/hidden/ssl_namespace.h b/ssl/hidden/ssl_namespace.h new file mode 100644 index 00000000..b79f7ccd --- /dev/null +++ b/ssl/hidden/ssl_namespace.h @@ -0,0 +1,43 @@ +/* $OpenBSD: ssl_namespace.h,v 1.2 2023/02/16 08:38:17 tb Exp $ */ +/* + * Copyright (c) 2016 Philip Guenther + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBSSL_SSL_NAMESPACE_H_ +#define _LIBSSL_SSL_NAMESPACE_H_ + +/* + * If marked as 'used', then internal calls use the name with prefix "_lssl_" + * and we alias that to the normal name. + */ + +#ifdef _MSC_VER +#define LSSL_UNUSED(x) +#define LSSL_USED(x) +#define LSSL_ALIAS(x) +#else +#ifdef LIBRESSL_NAMESPACE +#define LSSL_UNUSED(x) typeof(x) x __attribute__((deprecated)) +#define LSSL_USED(x) __attribute__((visibility("hidden"))) \ + typeof(x) x asm("_lssl_"#x) +#define LSSL_ALIAS(x) asm(".global "#x"; "#x" = _lssl_"#x) +#else +#define LSSL_UNUSED(x) +#define LSSL_USED(x) +#define LSSL_ALIAS(x) asm("") +#endif +#endif /* _MSC_VER */ + +#endif /* _LIBSSL_SSL_NAMESPACE_H_ */ diff --git a/ssl/s3_cbc.c b/ssl/s3_cbc.c index e0289d89..32b74608 100644 --- a/ssl/s3_cbc.c +++ b/ssl/s3_cbc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_cbc.c,v 1.25 2021/12/09 17:45:49 tb Exp $ */ +/* $OpenBSD: s3_cbc.c,v 1.26 2022/11/26 16:08:55 tb Exp $ */ /* ==================================================================== * Copyright (c) 2012 The OpenSSL Project. All rights reserved. * @@ -56,7 +56,7 @@ #include #include -#include "ssl_locl.h" +#include "ssl_local.h" /* MAX_HASH_BIT_COUNT_BYTES is the maximum number of bytes in the hash's length * field. (SHA-384/512 have 128-bit length.) */ diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 989165b2..9e76cf93 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_lib.c,v 1.238 2022/08/21 19:39:44 jsing Exp $ */ +/* $OpenBSD: s3_lib.c,v 1.242 2022/11/26 16:08:55 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -159,10 +159,11 @@ #include #include "bytestring.h" -#include "dtls_locl.h" -#include "ssl_locl.h" +#include "dtls_local.h" +#include "ssl_local.h" #include "ssl_sigalgs.h" #include "ssl_tlsext.h" +#include "tls_content.h" #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers) / sizeof(SSL_CIPHER)) @@ -1441,11 +1442,12 @@ ssl3_cipher_get_value(const SSL_CIPHER *c) int ssl3_pending(const SSL *s) { - if (s->internal->rstate == SSL_ST_READ_BODY) + if (s->s3->rcontent == NULL) + return 0; + if (tls_content_type(s->s3->rcontent) != SSL3_RT_APPLICATION_DATA) return 0; - return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? - s->s3->rrec.length : 0; + return tls_content_remaining(s->s3->rcontent); } int @@ -1493,13 +1495,13 @@ ssl3_handshake_msg_finish(SSL *s, CBB *handshake) if (outlen > INT_MAX) goto err; - if (!BUF_MEM_grow_clean(s->internal->init_buf, outlen)) + if (!BUF_MEM_grow_clean(s->init_buf, outlen)) goto err; - memcpy(s->internal->init_buf->data, data, outlen); + memcpy(s->init_buf->data, data, outlen); - s->internal->init_num = (int)outlen; - s->internal->init_off = 0; + s->init_num = (int)outlen; + s->init_off = 0; if (SSL_is_dtls(s)) { unsigned long len; @@ -1560,6 +1562,11 @@ ssl3_free(SSL *s) ssl3_release_read_buffer(s); ssl3_release_write_buffer(s); + tls_content_free(s->s3->rcontent); + + tls_buffer_free(s->s3->alert_fragment); + tls_buffer_free(s->s3->handshake_fragment); + freezero(s->s3->hs.sigalgs, s->s3->hs.sigalgs_len); sk_X509_pop_free(s->s3->hs.peer_certs, X509_free); sk_X509_pop_free(s->s3->hs.peer_certs_no_leaf, X509_free); @@ -1572,7 +1579,7 @@ ssl3_free(SSL *s) tls_buffer_free(s->s3->hs.tls13.quic_read_buffer); sk_X509_NAME_pop_free(s->s3->hs.tls12.ca_names, X509_NAME_free); - sk_X509_pop_free(s->internal->verified_chain, X509_free); + sk_X509_pop_free(s->verified_chain, X509_free); tls1_transcript_free(s); tls1_transcript_hash_free(s); @@ -1595,8 +1602,13 @@ ssl3_clear(SSL *s) tls1_cleanup_key_block(s); sk_X509_NAME_pop_free(s->s3->hs.tls12.ca_names, X509_NAME_free); - sk_X509_pop_free(s->internal->verified_chain, X509_free); - s->internal->verified_chain = NULL; + sk_X509_pop_free(s->verified_chain, X509_free); + s->verified_chain = NULL; + + tls_buffer_free(s->s3->alert_fragment); + s->s3->alert_fragment = NULL; + tls_buffer_free(s->s3->handshake_fragment); + s->s3->handshake_fragment = NULL; freezero(s->s3->hs.sigalgs, s->s3->hs.sigalgs_len); s->s3->hs.sigalgs = NULL; @@ -1629,6 +1641,9 @@ ssl3_clear(SSL *s) rlen = s->s3->rbuf.len; wlen = s->s3->wbuf.len; + tls_content_free(s->s3->rcontent); + s->s3->rcontent = NULL; + tls1_transcript_free(s); tls1_transcript_hash_free(s); @@ -1656,7 +1671,7 @@ ssl3_clear(SSL *s) s->s3->num_renegotiations = 0; s->s3->in_read_app_data = 0; - s->internal->packet_length = 0; + s->packet_length = 0; s->version = TLS1_VERSION; s->s3->hs.state = SSL_ST_BEFORE|((s->server) ? SSL_ST_ACCEPT : SSL_ST_CONNECT); @@ -1725,7 +1740,7 @@ _SSL_get_peer_tmp_key(SSL *s, EVP_PKEY **key) static int _SSL_session_reused(SSL *s) { - return s->internal->hit; + return s->hit; } static int @@ -1834,7 +1849,7 @@ _SSL_set_tlsext_host_name(SSL *s, const char *name) static int _SSL_set_tlsext_debug_arg(SSL *s, void *arg) { - s->internal->tlsext_debug_arg = arg; + s->tlsext_debug_arg = arg; return 1; } @@ -1854,7 +1869,7 @@ _SSL_set_tlsext_status_type(SSL *s, int type) static int _SSL_get_tlsext_status_exts(SSL *s, STACK_OF(X509_EXTENSION) **exts) { - *exts = s->internal->tlsext_ocsp_exts; + *exts = s->tlsext_ocsp_exts; return 1; } @@ -1862,14 +1877,14 @@ static int _SSL_set_tlsext_status_exts(SSL *s, STACK_OF(X509_EXTENSION) *exts) { /* XXX - leak... */ - s->internal->tlsext_ocsp_exts = exts; + s->tlsext_ocsp_exts = exts; return 1; } static int _SSL_get_tlsext_status_ids(SSL *s, STACK_OF(OCSP_RESPID) **ids) { - *ids = s->internal->tlsext_ocsp_ids; + *ids = s->tlsext_ocsp_ids; return 1; } @@ -1877,17 +1892,17 @@ static int _SSL_set_tlsext_status_ids(SSL *s, STACK_OF(OCSP_RESPID) *ids) { /* XXX - leak... */ - s->internal->tlsext_ocsp_ids = ids; + s->tlsext_ocsp_ids = ids; return 1; } static int _SSL_get_tlsext_status_ocsp_resp(SSL *s, unsigned char **resp) { - if (s->internal->tlsext_ocsp_resp != NULL && - s->internal->tlsext_ocsp_resp_len < INT_MAX) { - *resp = s->internal->tlsext_ocsp_resp; - return (int)s->internal->tlsext_ocsp_resp_len; + if (s->tlsext_ocsp_resp != NULL && + s->tlsext_ocsp_resp_len < INT_MAX) { + *resp = s->tlsext_ocsp_resp; + return (int)s->tlsext_ocsp_resp_len; } *resp = NULL; @@ -1898,15 +1913,15 @@ _SSL_get_tlsext_status_ocsp_resp(SSL *s, unsigned char **resp) static int _SSL_set_tlsext_status_ocsp_resp(SSL *s, unsigned char *resp, int resp_len) { - free(s->internal->tlsext_ocsp_resp); - s->internal->tlsext_ocsp_resp = NULL; - s->internal->tlsext_ocsp_resp_len = 0; + free(s->tlsext_ocsp_resp); + s->tlsext_ocsp_resp = NULL; + s->tlsext_ocsp_resp_len = 0; if (resp_len < 0) return 0; - s->internal->tlsext_ocsp_resp = resp; - s->internal->tlsext_ocsp_resp_len = (size_t)resp_len; + s->tlsext_ocsp_resp = resp; + s->tlsext_ocsp_resp_len = (size_t)resp_len; return 1; } @@ -1955,15 +1970,15 @@ SSL_clear_chain_certs(SSL *ssl) int SSL_set1_groups(SSL *s, const int *groups, size_t groups_len) { - return tls1_set_groups(&s->internal->tlsext_supportedgroups, - &s->internal->tlsext_supportedgroups_length, groups, groups_len); + return tls1_set_groups(&s->tlsext_supportedgroups, + &s->tlsext_supportedgroups_length, groups, groups_len); } int SSL_set1_groups_list(SSL *s, const char *groups) { - return tls1_set_group_list(&s->internal->tlsext_supportedgroups, - &s->internal->tlsext_supportedgroups_length, groups); + return tls1_set_group_list(&s->tlsext_supportedgroups, + &s->tlsext_supportedgroups_length, groups); } static int @@ -2183,7 +2198,7 @@ ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void)) return 1; case SSL_CTRL_SET_TLSEXT_DEBUG_CB: - s->internal->tlsext_debug_cb = (void (*)(SSL *, int , int, + s->tlsext_debug_cb = (void (*)(SSL *, int , int, unsigned char *, int, void *))fp; return 1; } @@ -2211,8 +2226,8 @@ _SSL_CTX_set_tmp_dh(SSL_CTX *ctx, DH *dh) return 0; } - DH_free(ctx->internal->cert->dhe_params); - ctx->internal->cert->dhe_params = dhe_params; + DH_free(ctx->cert->dhe_params); + ctx->cert->dhe_params = dhe_params; return 1; } @@ -2220,7 +2235,7 @@ _SSL_CTX_set_tmp_dh(SSL_CTX *ctx, DH *dh) static int _SSL_CTX_set_dh_auto(SSL_CTX *ctx, int state) { - ctx->internal->cert->dhe_params_auto = state; + ctx->cert->dhe_params_auto = state; return 1; } @@ -2248,7 +2263,7 @@ _SSL_CTX_set_ecdh_auto(SSL_CTX *ctx, int state) static int _SSL_CTX_set_tlsext_servername_arg(SSL_CTX *ctx, void *arg) { - ctx->internal->tlsext_servername_arg = arg; + ctx->tlsext_servername_arg = arg; return 1; } @@ -2263,9 +2278,9 @@ _SSL_CTX_get_tlsext_ticket_keys(SSL_CTX *ctx, unsigned char *keys, int keys_len) return 0; } - memcpy(keys, ctx->internal->tlsext_tick_key_name, 16); - memcpy(keys + 16, ctx->internal->tlsext_tick_hmac_key, 16); - memcpy(keys + 32, ctx->internal->tlsext_tick_aes_key, 16); + memcpy(keys, ctx->tlsext_tick_key_name, 16); + memcpy(keys + 16, ctx->tlsext_tick_hmac_key, 16); + memcpy(keys + 32, ctx->tlsext_tick_aes_key, 16); return 1; } @@ -2281,9 +2296,9 @@ _SSL_CTX_set_tlsext_ticket_keys(SSL_CTX *ctx, unsigned char *keys, int keys_len) return 0; } - memcpy(ctx->internal->tlsext_tick_key_name, keys, 16); - memcpy(ctx->internal->tlsext_tick_hmac_key, keys + 16, 16); - memcpy(ctx->internal->tlsext_tick_aes_key, keys + 32, 16); + memcpy(ctx->tlsext_tick_key_name, keys, 16); + memcpy(ctx->tlsext_tick_hmac_key, keys + 16, 16); + memcpy(ctx->tlsext_tick_aes_key, keys + 32, 16); return 1; } @@ -2291,14 +2306,14 @@ _SSL_CTX_set_tlsext_ticket_keys(SSL_CTX *ctx, unsigned char *keys, int keys_len) static int _SSL_CTX_get_tlsext_status_arg(SSL_CTX *ctx, void **arg) { - *arg = ctx->internal->tlsext_status_arg; + *arg = ctx->tlsext_status_arg; return 1; } static int _SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg) { - ctx->internal->tlsext_status_arg = arg; + ctx->tlsext_status_arg = arg; return 1; } @@ -2331,8 +2346,8 @@ SSL_CTX_get0_chain_certs(const SSL_CTX *ctx, STACK_OF(X509) **out_chain) { *out_chain = NULL; - if (ctx->internal->cert->key != NULL) - *out_chain = ctx->internal->cert->key->chain; + if (ctx->cert->key != NULL) + *out_chain = ctx->cert->key->chain; return 1; } @@ -2361,7 +2376,7 @@ _SSL_CTX_get_extra_chain_certs(SSL_CTX *ctx, STACK_OF(X509) **certs) { *certs = ctx->extra_certs; if (*certs == NULL) - *certs = ctx->internal->cert->key->chain; + *certs = ctx->cert->key->chain; return 1; } @@ -2384,15 +2399,15 @@ _SSL_CTX_clear_extra_chain_certs(SSL_CTX *ctx) int SSL_CTX_set1_groups(SSL_CTX *ctx, const int *groups, size_t groups_len) { - return tls1_set_groups(&ctx->internal->tlsext_supportedgroups, - &ctx->internal->tlsext_supportedgroups_length, groups, groups_len); + return tls1_set_groups(&ctx->tlsext_supportedgroups, + &ctx->tlsext_supportedgroups_length, groups, groups_len); } int SSL_CTX_set1_groups_list(SSL_CTX *ctx, const char *groups) { - return tls1_set_group_list(&ctx->internal->tlsext_supportedgroups, - &ctx->internal->tlsext_supportedgroups_length, groups); + return tls1_set_group_list(&ctx->tlsext_supportedgroups, + &ctx->tlsext_supportedgroups_length, groups); } long @@ -2507,7 +2522,7 @@ ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)) return 0; case SSL_CTRL_SET_TMP_DH_CB: - ctx->internal->cert->dhe_params_cb = + ctx->cert->dhe_params_cb = (DH *(*)(SSL *, int, int))fp; return 1; @@ -2515,20 +2530,20 @@ ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)) return 1; case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB: - ctx->internal->tlsext_servername_callback = + ctx->tlsext_servername_callback = (int (*)(SSL *, int *, void *))fp; return 1; case SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB: - *(int (**)(SSL *, void *))fp = ctx->internal->tlsext_status_cb; + *(int (**)(SSL *, void *))fp = ctx->tlsext_status_cb; return 1; case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB: - ctx->internal->tlsext_status_cb = (int (*)(SSL *, void *))fp; + ctx->tlsext_status_cb = (int (*)(SSL *, void *))fp; return 1; case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB: - ctx->internal->tlsext_ticket_key_cb = (int (*)(SSL *, unsigned char *, + ctx->tlsext_ticket_key_cb = (int (*)(SSL *, unsigned char *, unsigned char *, EVP_CIPHER_CTX *, HMAC_CTX *, int))fp; return 1; } @@ -2559,7 +2574,7 @@ ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt, * but would have to pay with the price of sk_SSL_CIPHER_dup(). */ - if (s->internal->options & SSL_OP_CIPHER_SERVER_PREFERENCE) { + if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE) { prio = srvr; allow = clnt; } else { @@ -2670,13 +2685,13 @@ ssl3_shutdown(SSL *s) * Don't do anything much if we have not done the handshake or * we don't want to send messages :-) */ - if ((s->internal->quiet_shutdown) || (s->s3->hs.state == SSL_ST_BEFORE)) { - s->internal->shutdown = (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); + if ((s->quiet_shutdown) || (s->s3->hs.state == SSL_ST_BEFORE)) { + s->shutdown = (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); return (1); } - if (!(s->internal->shutdown & SSL_SENT_SHUTDOWN)) { - s->internal->shutdown|=SSL_SENT_SHUTDOWN; + if (!(s->shutdown & SSL_SENT_SHUTDOWN)) { + s->shutdown|=SSL_SENT_SHUTDOWN; ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY); /* * Our shutdown alert has been sent now, and if it still needs @@ -2696,15 +2711,15 @@ ssl3_shutdown(SSL *s) */ return (ret); } - } else if (!(s->internal->shutdown & SSL_RECEIVED_SHUTDOWN)) { + } else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) { /* If we are waiting for a close from our peer, we are closed */ s->method->ssl_read_bytes(s, 0, NULL, 0, 0); - if (!(s->internal->shutdown & SSL_RECEIVED_SHUTDOWN)) { + if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) { return (-1); /* return WANT_READ */ } } - if ((s->internal->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) && + if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) && !s->s3->alert_dispatch) return (1); else @@ -2737,16 +2752,16 @@ ssl3_read_internal(SSL *s, void *buf, int len, int peek) peek); if ((ret == -1) && (s->s3->in_read_app_data == 2)) { /* - * ssl3_read_bytes decided to call s->internal->handshake_func, + * ssl3_read_bytes decided to call s->handshake_func, * which called ssl3_read_bytes to read handshake data. * However, ssl3_read_bytes actually found application data * and thinks that application data makes sense here; so disable * handshake processing and try to read application data again. */ - s->internal->in_handshake++; + s->in_handshake++; ret = s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len, peek); - s->internal->in_handshake--; + s->in_handshake--; } else s->s3->in_read_app_data = 0; @@ -2768,7 +2783,7 @@ ssl3_peek(SSL *s, void *buf, int len) int ssl3_renegotiate(SSL *s) { - if (s->internal->handshake_func == NULL) + if (s->handshake_func == NULL) return 1; if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) diff --git a/ssl/ssl.sym b/ssl/ssl.sym index 107c3552..2b9ec25e 100644 --- a/ssl/ssl.sym +++ b/ssl/ssl.sym @@ -7,34 +7,18 @@ BIO_ssl_shutdown DTLS_client_method DTLS_method DTLS_server_method -DTLSv1_client_method -DTLSv1_method -DTLSv1_server_method DTLSv1_2_client_method DTLSv1_2_method DTLSv1_2_server_method -SSLv23_client_method -SSLv23_method -SSLv23_server_method -TLS_client_method -TLS_method -TLS_server_method -TLSv1_1_client_method -TLSv1_1_method -TLSv1_1_server_method -TLSv1_2_client_method -TLSv1_2_method -TLSv1_2_server_method -TLSv1_client_method -TLSv1_method -TLSv1_server_method +DTLSv1_client_method +DTLSv1_method +DTLSv1_server_method +ERR_load_SSL_strings +OPENSSL_init_ssl PEM_read_SSL_SESSION PEM_read_bio_SSL_SESSION PEM_write_SSL_SESSION PEM_write_bio_SSL_SESSION -d2i_SSL_SESSION -i2d_SSL_SESSION -ERR_load_SSL_strings SSL_CIPHER_description SSL_CIPHER_find SSL_CIPHER_get_auth_nid @@ -361,4 +345,20 @@ SSL_want SSL_write SSL_write_early_data SSL_write_ex -OPENSSL_init_ssl +SSLv23_client_method +SSLv23_method +SSLv23_server_method +TLS_client_method +TLS_method +TLS_server_method +TLSv1_1_client_method +TLSv1_1_method +TLSv1_1_server_method +TLSv1_2_client_method +TLSv1_2_method +TLSv1_2_server_method +TLSv1_client_method +TLSv1_method +TLSv1_server_method +d2i_SSL_SESSION +i2d_SSL_SESSION diff --git a/ssl/ssl_algs.c b/ssl/ssl_algs.c index 5ecbb346..ab23f4bc 100644 --- a/ssl/ssl_algs.c +++ b/ssl/ssl_algs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_algs.c,v 1.30 2022/01/14 08:38:48 tb Exp $ */ +/* $OpenBSD: ssl_algs.c,v 1.31 2022/11/26 16:08:55 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,7 +62,7 @@ #include #include -#include "ssl_locl.h" +#include "ssl_local.h" int SSL_library_init(void) diff --git a/ssl/ssl_asn1.c b/ssl/ssl_asn1.c index 6095a737..76846021 100644 --- a/ssl/ssl_asn1.c +++ b/ssl/ssl_asn1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_asn1.c,v 1.65 2022/06/07 17:53:42 tb Exp $ */ +/* $OpenBSD: ssl_asn1.c,v 1.66 2022/11/26 16:08:55 tb Exp $ */ /* * Copyright (c) 2016 Joel Sing * @@ -21,7 +21,7 @@ #include #include "bytestring.h" -#include "ssl_locl.h" +#include "ssl_local.h" #define SSLASN1_TAG (CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC) #define SSLASN1_TIME_TAG (SSLASN1_TAG | 1) diff --git a/ssl/ssl_both.c b/ssl/ssl_both.c index cfd32387..3feedc18 100644 --- a/ssl/ssl_both.c +++ b/ssl/ssl_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_both.c,v 1.42 2022/02/05 14:54:10 jsing Exp $ */ +/* $OpenBSD: ssl_both.c,v 1.45 2022/11/26 16:08:55 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -124,11 +124,11 @@ #include #include "bytestring.h" -#include "dtls_locl.h" -#include "ssl_locl.h" +#include "dtls_local.h" +#include "ssl_local.h" /* - * Send s->internal->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or + * Send s->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or * SSL3_RT_CHANGE_CIPHER_SPEC). */ int @@ -136,8 +136,8 @@ ssl3_do_write(SSL *s, int type) { int ret; - ret = ssl3_write_bytes(s, type, &s->internal->init_buf->data[s->internal->init_off], - s->internal->init_num); + ret = ssl3_write_bytes(s, type, &s->init_buf->data[s->init_off], + s->init_num); if (ret < 0) return (-1); @@ -147,166 +147,20 @@ ssl3_do_write(SSL *s, int type) * we'll ignore the result anyway. */ tls1_transcript_record(s, - (unsigned char *)&s->internal->init_buf->data[s->internal->init_off], ret); + (unsigned char *)&s->init_buf->data[s->init_off], ret); - if (ret == s->internal->init_num) { - ssl_msg_callback(s, 1, type, s->internal->init_buf->data, - (size_t)(s->internal->init_off + s->internal->init_num)); + if (ret == s->init_num) { + ssl_msg_callback(s, 1, type, s->init_buf->data, + (size_t)(s->init_off + s->init_num)); return (1); } - s->internal->init_off += ret; - s->internal->init_num -= ret; + s->init_off += ret; + s->init_num -= ret; return (0); } -int -ssl3_send_finished(SSL *s, int state_a, int state_b) -{ - CBB cbb, finished; - - memset(&cbb, 0, sizeof(cbb)); - - if (s->s3->hs.state == state_a) { - if (!tls12_derive_finished(s)) - goto err; - - /* Copy finished so we can use it for renegotiation checks. */ - if (!s->server) { - memcpy(s->s3->previous_client_finished, - s->s3->hs.finished, s->s3->hs.finished_len); - s->s3->previous_client_finished_len = - s->s3->hs.finished_len; - } else { - memcpy(s->s3->previous_server_finished, - s->s3->hs.finished, s->s3->hs.finished_len); - s->s3->previous_server_finished_len = - s->s3->hs.finished_len; - } - - if (!ssl3_handshake_msg_start(s, &cbb, &finished, - SSL3_MT_FINISHED)) - goto err; - if (!CBB_add_bytes(&finished, s->s3->hs.finished, - s->s3->hs.finished_len)) - goto err; - if (!ssl3_handshake_msg_finish(s, &cbb)) - goto err; - - s->s3->hs.state = state_b; - } - - return (ssl3_handshake_write(s)); - - err: - CBB_cleanup(&cbb); - - return (-1); -} - -int -ssl3_get_finished(SSL *s, int a, int b) -{ - int al, md_len, ret; - CBS cbs; - - /* should actually be 36+4 :-) */ - if ((ret = ssl3_get_message(s, a, b, SSL3_MT_FINISHED, 64)) <= 0) - return ret; - - /* If this occurs, we have missed a message */ - if (!s->s3->change_cipher_spec) { - al = SSL_AD_UNEXPECTED_MESSAGE; - SSLerror(s, SSL_R_GOT_A_FIN_BEFORE_A_CCS); - goto fatal_err; - } - s->s3->change_cipher_spec = 0; - - md_len = TLS1_FINISH_MAC_LENGTH; - - if (s->internal->init_num < 0) { - al = SSL_AD_DECODE_ERROR; - SSLerror(s, SSL_R_BAD_DIGEST_LENGTH); - goto fatal_err; - } - - CBS_init(&cbs, s->internal->init_msg, s->internal->init_num); - - if (s->s3->hs.peer_finished_len != md_len || - CBS_len(&cbs) != md_len) { - al = SSL_AD_DECODE_ERROR; - SSLerror(s, SSL_R_BAD_DIGEST_LENGTH); - goto fatal_err; - } - - if (!CBS_mem_equal(&cbs, s->s3->hs.peer_finished, CBS_len(&cbs))) { - al = SSL_AD_DECRYPT_ERROR; - SSLerror(s, SSL_R_DIGEST_CHECK_FAILED); - goto fatal_err; - } - - /* Copy finished so we can use it for renegotiation checks. */ - OPENSSL_assert(md_len <= EVP_MAX_MD_SIZE); - if (s->server) { - memcpy(s->s3->previous_client_finished, - s->s3->hs.peer_finished, md_len); - s->s3->previous_client_finished_len = md_len; - } else { - memcpy(s->s3->previous_server_finished, - s->s3->hs.peer_finished, md_len); - s->s3->previous_server_finished_len = md_len; - } - - return (1); - fatal_err: - ssl3_send_alert(s, SSL3_AL_FATAL, al); - return (0); -} - -int -ssl3_send_change_cipher_spec(SSL *s, int a, int b) -{ - size_t outlen; - CBB cbb; - - memset(&cbb, 0, sizeof(cbb)); - - if (s->s3->hs.state == a) { - if (!CBB_init_fixed(&cbb, s->internal->init_buf->data, - s->internal->init_buf->length)) - goto err; - if (!CBB_add_u8(&cbb, SSL3_MT_CCS)) - goto err; - if (!CBB_finish(&cbb, NULL, &outlen)) - goto err; - - if (outlen > INT_MAX) - goto err; - - s->internal->init_num = (int)outlen; - s->internal->init_off = 0; - - if (SSL_is_dtls(s)) { - s->d1->handshake_write_seq = - s->d1->next_handshake_write_seq; - dtls1_set_message_header_int(s, SSL3_MT_CCS, 0, - s->d1->handshake_write_seq, 0, 0); - dtls1_buffer_message(s, 1); - } - - s->s3->hs.state = b; - } - - /* SSL3_ST_CW_CHANGE_B */ - return ssl3_record_write(s, SSL3_RT_CHANGE_CIPHER_SPEC); - - err: - CBB_cleanup(&cbb); - - return -1; -} - static int ssl3_add_cert(CBB *cbb, X509 *x) { @@ -353,7 +207,7 @@ ssl3_output_cert_chain(SSL *s, CBB *cbb, SSL_CERT_PKEY *cpk) if ((chain = cpk->chain) == NULL) chain = s->ctx->extra_certs; - if (chain != NULL || (s->internal->mode & SSL_MODE_NO_AUTO_CHAIN)) { + if (chain != NULL || (s->mode & SSL_MODE_NO_AUTO_CHAIN)) { if (!ssl3_add_cert(&cert_list, cpk->x509)) goto err; } else { @@ -415,27 +269,27 @@ ssl3_get_message(SSL *s, int st1, int stn, int mt, long max) SSLerror(s, SSL_R_UNEXPECTED_MESSAGE); goto fatal_err; } - s->internal->init_msg = s->internal->init_buf->data + + s->init_msg = s->init_buf->data + SSL3_HM_HEADER_LENGTH; - s->internal->init_num = (int)s->s3->hs.tls12.message_size; + s->init_num = (int)s->s3->hs.tls12.message_size; return 1; } - p = (unsigned char *)s->internal->init_buf->data; + p = (unsigned char *)s->init_buf->data; if (s->s3->hs.state == st1) { int skip_message; do { - while (s->internal->init_num < SSL3_HM_HEADER_LENGTH) { + while (s->init_num < SSL3_HM_HEADER_LENGTH) { i = s->method->ssl_read_bytes(s, - SSL3_RT_HANDSHAKE, &p[s->internal->init_num], - SSL3_HM_HEADER_LENGTH - s->internal->init_num, 0); + SSL3_RT_HANDSHAKE, &p[s->init_num], + SSL3_HM_HEADER_LENGTH - s->init_num, 0); if (i <= 0) { - s->internal->rwstate = SSL_READING; + s->rwstate = SSL_READING; return i; } - s->internal->init_num += i; + s->init_num += i; } skip_message = 0; @@ -447,7 +301,7 @@ ssl3_get_message(SSL *s, int st1, int stn, int mt, long max) * correct. Does not count for 'Finished' MAC. */ if (p[1] == 0 && p[2] == 0 &&p[3] == 0) { - s->internal->init_num = 0; + s->init_num = 0; skip_message = 1; ssl_msg_callback(s, 0, @@ -476,7 +330,7 @@ ssl3_get_message(SSL *s, int st1, int stn, int mt, long max) SSLerror(s, SSL_R_EXCESSIVE_MESSAGE_SIZE); goto fatal_err; } - if (l && !BUF_MEM_grow_clean(s->internal->init_buf, + if (l && !BUF_MEM_grow_clean(s->init_buf, l + SSL3_HM_HEADER_LENGTH)) { SSLerror(s, ERR_R_BUF_LIB); goto err; @@ -484,33 +338,33 @@ ssl3_get_message(SSL *s, int st1, int stn, int mt, long max) s->s3->hs.tls12.message_size = l; s->s3->hs.state = stn; - s->internal->init_msg = s->internal->init_buf->data + + s->init_msg = s->init_buf->data + SSL3_HM_HEADER_LENGTH; - s->internal->init_num = 0; + s->init_num = 0; } /* next state (stn) */ - p = s->internal->init_msg; - n = s->s3->hs.tls12.message_size - s->internal->init_num; + p = s->init_msg; + n = s->s3->hs.tls12.message_size - s->init_num; while (n > 0) { i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, - &p[s->internal->init_num], n, 0); + &p[s->init_num], n, 0); if (i <= 0) { - s->internal->rwstate = SSL_READING; + s->rwstate = SSL_READING; return i; } - s->internal->init_num += i; + s->init_num += i; n -= i; } /* Feed this message into MAC computation. */ - if (s->internal->mac_packet) { - tls1_transcript_record(s, (unsigned char *)s->internal->init_buf->data, - s->internal->init_num + SSL3_HM_HEADER_LENGTH); + if (s->mac_packet) { + tls1_transcript_record(s, (unsigned char *)s->init_buf->data, + s->init_num + SSL3_HM_HEADER_LENGTH); ssl_msg_callback(s, 0, SSL3_RT_HANDSHAKE, - s->internal->init_buf->data, - (size_t)s->internal->init_num + SSL3_HM_HEADER_LENGTH); + s->init_buf->data, + (size_t)s->init_num + SSL3_HM_HEADER_LENGTH); } return 1; @@ -605,7 +459,7 @@ ssl3_setup_init_buffer(SSL *s) { BUF_MEM *buf = NULL; - if (s->internal->init_buf != NULL) + if (s->init_buf != NULL) return (1); if ((buf = BUF_MEM_new()) == NULL) @@ -613,7 +467,7 @@ ssl3_setup_init_buffer(SSL *s) if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) goto err; - s->internal->init_buf = buf; + s->init_buf = buf; return (1); err: @@ -624,11 +478,11 @@ ssl3_setup_init_buffer(SSL *s) void ssl3_release_init_buffer(SSL *s) { - BUF_MEM_free(s->internal->init_buf); - s->internal->init_buf = NULL; - s->internal->init_msg = NULL; - s->internal->init_num = 0; - s->internal->init_off = 0; + BUF_MEM_free(s->init_buf); + s->init_buf = NULL; + s->init_msg = NULL; + s->init_num = 0; + s->init_off = 0; } int @@ -653,7 +507,7 @@ ssl3_setup_read_buffer(SSL *s) s->s3->rbuf.len = len; } - s->internal->packet = s->s3->rbuf.buf; + s->packet = s->s3->rbuf.buf; return 1; err: @@ -677,7 +531,7 @@ ssl3_setup_write_buffer(SSL *s) if (s->s3->wbuf.buf == NULL) { len = s->max_send_fragment + SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD + headerlen + align; - if (!(s->internal->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)) + if (!(s->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)) len += headerlen + align + SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD; diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index 453d7577..4fe80521 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_cert.c,v 1.103 2022/07/07 13:04:39 tb Exp $ */ +/* $OpenBSD: ssl_cert.c,v 1.105 2022/11/26 16:08:55 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -128,7 +128,7 @@ #include #include -#include "ssl_locl.h" +#include "ssl_local.h" int SSL_get_ex_data_X509_STORE_CTX_idx(void) @@ -304,7 +304,7 @@ ssl_get0_cert(SSL_CTX *ctx, SSL *ssl) if (ssl != NULL) return ssl->cert; - return ctx->internal->cert; + return ctx->cert; } int @@ -430,21 +430,21 @@ ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *certs) */ X509_VERIFY_PARAM_set1(param, s->param); - if (s->internal->verify_callback) - X509_STORE_CTX_set_verify_cb(ctx, s->internal->verify_callback); + if (s->verify_callback) + X509_STORE_CTX_set_verify_cb(ctx, s->verify_callback); - if (s->ctx->internal->app_verify_callback != NULL) - ret = s->ctx->internal->app_verify_callback(ctx, - s->ctx->internal->app_verify_arg); + if (s->ctx->app_verify_callback != NULL) + ret = s->ctx->app_verify_callback(ctx, + s->ctx->app_verify_arg); else ret = X509_verify_cert(ctx); s->verify_result = X509_STORE_CTX_get_error(ctx); - sk_X509_pop_free(s->internal->verified_chain, X509_free); - s->internal->verified_chain = NULL; + sk_X509_pop_free(s->verified_chain, X509_free); + s->verified_chain = NULL; if (X509_STORE_CTX_get0_chain(ctx) != NULL) { - s->internal->verified_chain = X509_STORE_CTX_get1_chain(ctx); - if (s->internal->verified_chain == NULL) { + s->verified_chain = X509_STORE_CTX_get1_chain(ctx); + if (s->verified_chain == NULL) { SSLerrorx(ERR_R_MALLOC_FAILURE); ret = 0; } @@ -491,19 +491,19 @@ SSL_dup_CA_list(const STACK_OF(X509_NAME) *sk) void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list) { - set_client_CA_list(&(s->internal->client_CA), name_list); + set_client_CA_list(&(s->client_CA), name_list); } void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list) { - set_client_CA_list(&(ctx->internal->client_CA), name_list); + set_client_CA_list(&(ctx->client_CA), name_list); } STACK_OF(X509_NAME) * SSL_CTX_get_client_CA_list(const SSL_CTX *ctx) { - return (ctx->internal->client_CA); + return (ctx->client_CA); } STACK_OF(X509_NAME) * @@ -516,10 +516,10 @@ SSL_get_client_CA_list(const SSL *s) else return (NULL); } else { - if (s->internal->client_CA != NULL) - return (s->internal->client_CA); + if (s->client_CA != NULL) + return (s->client_CA); else - return (s->ctx->internal->client_CA); + return (s->ctx->client_CA); } } @@ -546,13 +546,13 @@ add_client_CA(STACK_OF(X509_NAME) **sk, X509 *x) int SSL_add_client_CA(SSL *ssl, X509 *x) { - return (add_client_CA(&(ssl->internal->client_CA), x)); + return (add_client_CA(&(ssl->client_CA), x)); } int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x) { - return (add_client_CA(&(ctx->internal->client_CA), x)); + return (add_client_CA(&(ctx->client_CA), x)); } static int diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index f39cd2f0..a71c5042 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_ciph.c,v 1.134 2022/09/08 15:31:12 millert Exp $ */ +/* $OpenBSD: ssl_ciph.c,v 1.135 2022/11/26 16:08:55 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -149,7 +149,7 @@ #include #endif -#include "ssl_locl.h" +#include "ssl_local.h" #define CIPHER_ADD 1 #define CIPHER_KILL 2 diff --git a/ssl/ssl_ciphers.c b/ssl/ssl_ciphers.c index f77f32ab..4ec1b099 100644 --- a/ssl/ssl_ciphers.c +++ b/ssl/ssl_ciphers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_ciphers.c,v 1.15 2022/07/02 16:31:04 tb Exp $ */ +/* $OpenBSD: ssl_ciphers.c,v 1.17 2022/11/26 16:08:55 tb Exp $ */ /* * Copyright (c) 2015-2017 Doug Hogan * Copyright (c) 2015-2018, 2020 Joel Sing @@ -20,7 +20,7 @@ #include #include "bytestring.h" -#include "ssl_locl.h" +#include "ssl_local.h" int ssl_cipher_in_list(STACK_OF(SSL_CIPHER) *ciphers, const SSL_CIPHER *cipher) @@ -79,7 +79,7 @@ ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *ciphers, CBB *cbb) } /* Add SCSV if there are other ciphers and we're not renegotiating. */ - if (num_ciphers > 0 && !s->internal->renegotiate) { + if (num_ciphers > 0 && !s->renegotiate) { if (!CBB_add_u16(cbb, SSL3_CK_SCSV & SSL3_CK_VALUE_MASK)) return 0; } @@ -118,7 +118,7 @@ ssl_bytes_to_cipher_list(SSL *s, CBS *cbs) * TLS_EMPTY_RENEGOTIATION_INFO_SCSV is fatal if * renegotiating. */ - if (s->internal->renegotiate) { + if (s->renegotiate) { SSLerror(s, SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); diff --git a/ssl/ssl_clnt.c b/ssl/ssl_clnt.c index 0e502858..c721aede 100644 --- a/ssl/ssl_clnt.c +++ b/ssl/ssl_clnt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_clnt.c,v 1.153 2022/08/17 07:39:19 jsing Exp $ */ +/* $OpenBSD: ssl_clnt.c,v 1.158 2022/12/26 07:31:44 jmc Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -169,13 +169,32 @@ #endif #include "bytestring.h" -#include "dtls_locl.h" -#include "ssl_locl.h" +#include "dtls_local.h" +#include "ssl_local.h" #include "ssl_sigalgs.h" #include "ssl_tlsext.h" static int ca_dn_cmp(const X509_NAME * const *a, const X509_NAME * const *b); +static int ssl3_send_client_hello(SSL *s); +static int ssl3_get_dtls_hello_verify(SSL *s); +static int ssl3_get_server_hello(SSL *s); +static int ssl3_get_certificate_request(SSL *s); +static int ssl3_get_new_session_ticket(SSL *s); +static int ssl3_get_cert_status(SSL *s); +static int ssl3_get_server_done(SSL *s); +static int ssl3_send_client_verify(SSL *s); +static int ssl3_send_client_certificate(SSL *s); +static int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey); +static int ssl3_send_client_key_exchange(SSL *s); +static int ssl3_get_server_key_exchange(SSL *s); +static int ssl3_get_server_certificate(SSL *s); +static int ssl3_check_cert_and_algorithm(SSL *s); +static int ssl3_check_finished(SSL *s); +static int ssl3_send_client_change_cipher_spec(SSL *s); +static int ssl3_send_client_finished(SSL *s); +static int ssl3_get_server_finished(SSL *s); + int ssl3_connect(SSL *s) { @@ -185,7 +204,7 @@ ssl3_connect(SSL *s) ERR_clear_error(); errno = 0; - s->internal->in_handshake++; + s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); @@ -194,9 +213,9 @@ ssl3_connect(SSL *s) switch (s->s3->hs.state) { case SSL_ST_RENEGOTIATE: - s->internal->renegotiate = 1; + s->renegotiate = 1; s->s3->hs.state = SSL_ST_CONNECT; - s->ctx->internal->stats.sess_connect_renegotiate++; + s->ctx->stats.sess_connect_renegotiate++; /* break */ case SSL_ST_BEFORE: case SSL_ST_CONNECT: @@ -249,21 +268,21 @@ ssl3_connect(SSL *s) } s->s3->hs.state = SSL3_ST_CW_CLNT_HELLO_A; - s->ctx->internal->stats.sess_connect++; - s->internal->init_num = 0; + s->ctx->stats.sess_connect++; + s->init_num = 0; if (SSL_is_dtls(s)) { /* mark client_random uninitialized */ memset(s->s3->client_random, 0, sizeof(s->s3->client_random)); s->d1->send_cookie = 0; - s->internal->hit = 0; + s->hit = 0; } break; case SSL3_ST_CW_CLNT_HELLO_A: case SSL3_ST_CW_CLNT_HELLO_B: - s->internal->shutdown = 0; + s->shutdown = 0; if (SSL_is_dtls(s)) { /* every DTLS ClientHello resets Finished MAC */ @@ -282,7 +301,7 @@ ssl3_connect(SSL *s) } else s->s3->hs.state = SSL3_ST_CR_SRVR_HELLO_A; - s->internal->init_num = 0; + s->init_num = 0; /* turn on buffering for the next lot of output */ if (s->bbio != s->wbio) @@ -296,10 +315,10 @@ ssl3_connect(SSL *s) if (ret <= 0) goto end; - if (s->internal->hit) { + if (s->hit) { s->s3->hs.state = SSL3_ST_CR_FINISHED_A; if (!SSL_is_dtls(s)) { - if (s->internal->tlsext_ticket_expected) { + if (s->tlsext_ticket_expected) { /* receive renewed session ticket */ s->s3->hs.state = SSL3_ST_CR_SESSION_TICKET_A; } @@ -312,7 +331,7 @@ ssl3_connect(SSL *s) } else { s->s3->hs.state = SSL3_ST_CR_CERT_A; } - s->internal->init_num = 0; + s->init_num = 0; break; case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: @@ -325,7 +344,7 @@ ssl3_connect(SSL *s) s->s3->hs.state = SSL3_ST_CW_CLNT_HELLO_A; else s->s3->hs.state = SSL3_ST_CR_CERT_A; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_CR_CERT_A: @@ -334,12 +353,12 @@ ssl3_connect(SSL *s) if (ret <= 0) goto end; if (ret == 2) { - s->internal->hit = 1; - if (s->internal->tlsext_ticket_expected) + s->hit = 1; + if (s->tlsext_ticket_expected) s->s3->hs.state = SSL3_ST_CR_SESSION_TICKET_A; else s->s3->hs.state = SSL3_ST_CR_FINISHED_A; - s->internal->init_num = 0; + s->init_num = 0; break; } /* Check if it is anon DH/ECDH. */ @@ -348,7 +367,7 @@ ssl3_connect(SSL *s) ret = ssl3_get_server_certificate(s); if (ret <= 0) goto end; - if (s->internal->tlsext_status_expected) + if (s->tlsext_status_expected) s->s3->hs.state = SSL3_ST_CR_CERT_STATUS_A; else s->s3->hs.state = SSL3_ST_CR_KEY_EXCH_A; @@ -356,7 +375,7 @@ ssl3_connect(SSL *s) skip = 1; s->s3->hs.state = SSL3_ST_CR_KEY_EXCH_A; } - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_CR_KEY_EXCH_A: @@ -365,7 +384,7 @@ ssl3_connect(SSL *s) if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_CR_CERT_REQ_A; - s->internal->init_num = 0; + s->init_num = 0; /* * At this point we check that we have the @@ -383,7 +402,7 @@ ssl3_connect(SSL *s) if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_CR_SRVR_DONE_A; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_CR_SRVR_DONE_A: @@ -397,7 +416,7 @@ ssl3_connect(SSL *s) s->s3->hs.state = SSL3_ST_CW_CERT_A; else s->s3->hs.state = SSL3_ST_CW_KEY_EXCH_A; - s->internal->init_num = 0; + s->init_num = 0; break; @@ -411,7 +430,7 @@ ssl3_connect(SSL *s) if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_CW_KEY_EXCH_A; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_CW_KEY_EXCH_A: @@ -450,7 +469,7 @@ ssl3_connect(SSL *s) } } - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_CW_CERT_VRFY_A: @@ -461,21 +480,20 @@ ssl3_connect(SSL *s) if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_CW_CHANGE_A; - s->internal->init_num = 0; + s->init_num = 0; s->s3->change_cipher_spec = 0; break; case SSL3_ST_CW_CHANGE_A: case SSL3_ST_CW_CHANGE_B: - if (SSL_is_dtls(s) && !s->internal->hit) + if (SSL_is_dtls(s) && !s->hit) dtls1_start_timer(s); - ret = ssl3_send_change_cipher_spec(s, - SSL3_ST_CW_CHANGE_A, SSL3_ST_CW_CHANGE_B); + ret = ssl3_send_client_change_cipher_spec(s); if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_CW_FINISHED_A; - s->internal->init_num = 0; + s->init_num = 0; s->session->cipher = s->s3->hs.cipher; if (!tls1_setup_key_block(s)) { @@ -490,10 +508,9 @@ ssl3_connect(SSL *s) case SSL3_ST_CW_FINISHED_A: case SSL3_ST_CW_FINISHED_B: - if (SSL_is_dtls(s) && !s->internal->hit) + if (SSL_is_dtls(s) && !s->hit) dtls1_start_timer(s); - ret = ssl3_send_finished(s, SSL3_ST_CW_FINISHED_A, - SSL3_ST_CW_FINISHED_B); + ret = ssl3_send_client_finished(s); if (ret <= 0) goto end; if (!SSL_is_dtls(s)) @@ -501,18 +518,18 @@ ssl3_connect(SSL *s) s->s3->hs.state = SSL3_ST_CW_FLUSH; /* clear flags */ - if (s->internal->hit) { + if (s->hit) { s->s3->hs.tls12.next_state = SSL_ST_OK; } else { /* Allow NewSessionTicket if ticket expected */ - if (s->internal->tlsext_ticket_expected) + if (s->tlsext_ticket_expected) s->s3->hs.tls12.next_state = SSL3_ST_CR_SESSION_TICKET_A; else s->s3->hs.tls12.next_state = SSL3_ST_CR_FINISHED_A; } - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_CR_SESSION_TICKET_A: @@ -521,7 +538,7 @@ ssl3_connect(SSL *s) if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_CR_FINISHED_A; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_CR_CERT_STATUS_A: @@ -530,7 +547,7 @@ ssl3_connect(SSL *s) if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_CR_KEY_EXCH_A; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_CR_FINISHED_A: @@ -539,34 +556,33 @@ ssl3_connect(SSL *s) s->d1->change_cipher_spec_ok = 1; else s->s3->flags |= SSL3_FLAGS_CCS_OK; - ret = ssl3_get_finished(s, SSL3_ST_CR_FINISHED_A, - SSL3_ST_CR_FINISHED_B); + ret = ssl3_get_server_finished(s); if (ret <= 0) goto end; if (SSL_is_dtls(s)) dtls1_stop_timer(s); - if (s->internal->hit) + if (s->hit) s->s3->hs.state = SSL3_ST_CW_CHANGE_A; else s->s3->hs.state = SSL_ST_OK; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_CW_FLUSH: - s->internal->rwstate = SSL_WRITING; + s->rwstate = SSL_WRITING; if (BIO_flush(s->wbio) <= 0) { if (SSL_is_dtls(s)) { /* If the write error was fatal, stop trying */ if (!BIO_should_retry(s->wbio)) { - s->internal->rwstate = SSL_NOTHING; + s->rwstate = SSL_NOTHING; s->s3->hs.state = s->s3->hs.tls12.next_state; } } ret = -1; goto end; } - s->internal->rwstate = SSL_NOTHING; + s->rwstate = SSL_NOTHING; s->s3->hs.state = s->s3->hs.tls12.next_state; break; @@ -585,18 +601,18 @@ ssl3_connect(SSL *s) ssl_free_wbio_buffer(s); - s->internal->init_num = 0; - s->internal->renegotiate = 0; - s->internal->new_session = 0; + s->init_num = 0; + s->renegotiate = 0; + s->new_session = 0; ssl_update_cache(s, SSL_SESS_CACHE_CLIENT); - if (s->internal->hit) - s->ctx->internal->stats.sess_hit++; + if (s->hit) + s->ctx->stats.sess_hit++; ret = 1; /* s->server=0; */ - s->internal->handshake_func = ssl3_connect; - s->ctx->internal->stats.sess_connect_good++; + s->handshake_func = ssl3_connect; + s->ctx->stats.sess_connect_good++; ssl_info_callback(s, SSL_CB_HANDSHAKE_DONE, 1); @@ -618,7 +634,7 @@ ssl3_connect(SSL *s) /* did we do anything */ if (!s->s3->hs.tls12.reuse_message && !skip) { - if (s->internal->debug) { + if (s->debug) { if ((ret = BIO_flush(s->wbio)) <= 0) goto end; } @@ -634,13 +650,13 @@ ssl3_connect(SSL *s) } end: - s->internal->in_handshake--; + s->in_handshake--; ssl_info_callback(s, SSL_CB_CONNECT_EXIT, ret); return (ret); } -int +static int ssl3_send_client_hello(SSL *s) { CBB cbb, client_hello, session_id, cookie, cipher_suites; @@ -690,7 +706,7 @@ ssl3_send_client_hello(SSL *s) /* Session ID */ if (!CBB_add_u8_length_prefixed(&client_hello, &session_id)) goto err; - if (!s->internal->new_session && + if (!s->new_session && s->session->session_id_length > 0) { sl = s->session->session_id_length; if (sl > sizeof(s->session->session_id)) { @@ -752,7 +768,7 @@ ssl3_send_client_hello(SSL *s) return (-1); } -int +static int ssl3_get_dtls_hello_verify(SSL *s) { CBS hello_verify_request, cookie; @@ -761,7 +777,7 @@ ssl3_get_dtls_hello_verify(SSL *s) int al, ret; if ((ret = ssl3_get_message(s, DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A, - DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B, -1, s->internal->max_cert_list)) <= 0) + DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B, -1, s->max_cert_list)) <= 0) return ret; if (s->s3->hs.tls12.message_type != DTLS1_MT_HELLO_VERIFY_REQUEST) { @@ -770,11 +786,11 @@ ssl3_get_dtls_hello_verify(SSL *s) return (1); } - if (s->internal->init_num < 0) + if (s->init_num < 0) goto decode_err; - CBS_init(&hello_verify_request, s->internal->init_msg, - s->internal->init_num); + CBS_init(&hello_verify_request, s->init_msg, + s->init_num); if (!CBS_get_u16(&hello_verify_request, &ssl_version)) goto decode_err; @@ -813,7 +829,7 @@ ssl3_get_dtls_hello_verify(SSL *s) return -1; } -int +static int ssl3_get_server_hello(SSL *s) { CBS cbs, server_random, session_id; @@ -824,16 +840,16 @@ ssl3_get_server_hello(SSL *s) unsigned long alg_k; int al, ret; - s->internal->first_packet = 1; + s->first_packet = 1; if ((ret = ssl3_get_message(s, SSL3_ST_CR_SRVR_HELLO_A, SSL3_ST_CR_SRVR_HELLO_B, -1, 20000 /* ?? */)) <= 0) return ret; - s->internal->first_packet = 0; + s->first_packet = 0; - if (s->internal->init_num < 0) + if (s->init_num < 0) goto decode_err; - CBS_init(&cbs, s->internal->init_msg, s->internal->init_num); + CBS_init(&cbs, s->init_msg, s->init_num); if (SSL_is_dtls(s)) { if (s->s3->hs.tls12.message_type == DTLS1_MT_HELLO_VERIFY_REQUEST) { @@ -928,13 +944,13 @@ ssl3_get_server_hello(SSL *s) * Check if we want to resume the session based on external * pre-shared secret. */ - if (s->internal->tls_session_secret_cb != NULL) { + if (s->tls_session_secret_cb != NULL) { SSL_CIPHER *pref_cipher = NULL; int master_key_length = sizeof(s->session->master_key); - if (!s->internal->tls_session_secret_cb(s, + if (!s->tls_session_secret_cb(s, s->session->master_key, &master_key_length, NULL, - &pref_cipher, s->internal->tls_session_secret_cb_arg)) { + &pref_cipher, s->tls_session_secret_cb_arg)) { SSLerror(s, ERR_R_INTERNAL_ERROR); goto err; } @@ -962,13 +978,13 @@ ssl3_get_server_hello(SSL *s) goto fatal_err; } s->s3->flags |= SSL3_FLAGS_CCS_OK; - s->internal->hit = 1; + s->hit = 1; } else { /* a miss or crap from the other end */ /* If we were trying for session-id reuse, make a new * SSL_SESSION so we don't stuff up other people */ - s->internal->hit = 0; + s->hit = 0; if (s->session->session_id_length > 0) { if (!ssl_get_new_session(s, 0)) { al = SSL_AD_INTERNAL_ERROR; @@ -1016,7 +1032,7 @@ ssl3_get_server_hello(SSL *s) */ if (s->session->cipher) s->session->cipher_id = s->session->cipher->id; - if (s->internal->hit && (s->session->cipher_id != cipher->id)) { + if (s->hit && (s->session->cipher_id != cipher->id)) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerror(s, SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED); goto fatal_err; @@ -1060,7 +1076,7 @@ ssl3_get_server_hello(SSL *s) * absence on initial connect only. */ if (!s->s3->renegotiate_seen && - !(s->internal->options & SSL_OP_LEGACY_SERVER_CONNECT)) { + !(s->options & SSL_OP_LEGACY_SERVER_CONNECT)) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerror(s, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); goto fatal_err; @@ -1083,7 +1099,7 @@ ssl3_get_server_hello(SSL *s) return (-1); } -int +static int ssl3_get_server_certificate(SSL *s) { CBS cbs, cert_list, cert_data; @@ -1093,7 +1109,7 @@ ssl3_get_server_certificate(SSL *s) int al, ret; if ((ret = ssl3_get_message(s, SSL3_ST_CR_CERT_A, - SSL3_ST_CR_CERT_B, -1, s->internal->max_cert_list)) <= 0) + SSL3_ST_CR_CERT_B, -1, s->max_cert_list)) <= 0) return ret; ret = -1; @@ -1114,10 +1130,10 @@ ssl3_get_server_certificate(SSL *s) goto err; } - if (s->internal->init_num < 0) + if (s->init_num < 0) goto decode_err; - CBS_init(&cbs, s->internal->init_msg, s->internal->init_num); + CBS_init(&cbs, s->init_msg, s->init_num); if (!CBS_get_u24_length_prefixed(&cbs, &cert_list)) goto decode_err; @@ -1280,7 +1296,7 @@ ssl3_get_server_kex_ecdhe(SSL *s, CBS *cbs) return 0; } -int +static int ssl3_get_server_key_exchange(SSL *s) { CBS cbs, signature; @@ -1298,16 +1314,16 @@ ssl3_get_server_key_exchange(SSL *s) * as ServerKeyExchange message may be skipped. */ if ((ret = ssl3_get_message(s, SSL3_ST_CR_KEY_EXCH_A, - SSL3_ST_CR_KEY_EXCH_B, -1, s->internal->max_cert_list)) <= 0) + SSL3_ST_CR_KEY_EXCH_B, -1, s->max_cert_list)) <= 0) return ret; if ((md_ctx = EVP_MD_CTX_new()) == NULL) goto err; - if (s->internal->init_num < 0) + if (s->init_num < 0) goto err; - CBS_init(&cbs, s->internal->init_msg, s->internal->init_num); + CBS_init(&cbs, s->init_msg, s->init_num); if (s->s3->hs.tls12.message_type != SSL3_MT_SERVER_KEY_EXCHANGE) { /* @@ -1428,7 +1444,7 @@ ssl3_get_server_key_exchange(SSL *s) return (-1); } -int +static int ssl3_get_certificate_request(SSL *s) { CBS cert_request, cert_types, rdn_list; @@ -1438,7 +1454,7 @@ ssl3_get_certificate_request(SSL *s) int ret; if ((ret = ssl3_get_message(s, SSL3_ST_CR_CERT_REQ_A, - SSL3_ST_CR_CERT_REQ_B, -1, s->internal->max_cert_list)) <= 0) + SSL3_ST_CR_CERT_REQ_B, -1, s->max_cert_list)) <= 0) return ret; ret = 0; @@ -1468,9 +1484,9 @@ ssl3_get_certificate_request(SSL *s) goto err; } - if (s->internal->init_num < 0) + if (s->init_num < 0) goto decode_err; - CBS_init(&cert_request, s->internal->init_msg, s->internal->init_num); + CBS_init(&cert_request, s->init_msg, s->init_num); if ((ca_sk = sk_X509_NAME_new(ca_dn_cmp)) == NULL) { SSLerror(s, ERR_R_MALLOC_FAILURE); @@ -1572,7 +1588,7 @@ ca_dn_cmp(const X509_NAME * const *a, const X509_NAME * const *b) return (X509_NAME_cmp(*a, *b)); } -int +static int ssl3_get_new_session_ticket(SSL *s) { uint32_t lifetime_hint; @@ -1594,13 +1610,13 @@ ssl3_get_new_session_ticket(SSL *s) goto fatal_err; } - if (s->internal->init_num < 0) { + if (s->init_num < 0) { al = SSL_AD_DECODE_ERROR; SSLerror(s, SSL_R_LENGTH_MISMATCH); goto fatal_err; } - CBS_init(&cbs, s->internal->init_msg, s->internal->init_num); + CBS_init(&cbs, s->init_msg, s->init_num); if (!CBS_get_u32(&cbs, &lifetime_hint) || !CBS_get_u16_length_prefixed(&cbs, &session_ticket) || CBS_len(&cbs) != 0) { @@ -1617,7 +1633,7 @@ ssl3_get_new_session_ticket(SSL *s) } /* - * There are two ways to detect a resumed ticket sesion. + * There are two ways to detect a resumed ticket session. * One is to set an appropriate session ID and then the server * must return a match in ServerHello. This allows the normal * client session ID matching to work and we know much @@ -1631,6 +1647,7 @@ ssl3_get_new_session_ticket(SSL *s) * assumptions elsewhere in OpenSSL. The session ID is set * to the SHA256 hash of the ticket. */ + /* XXX - ensure this doesn't overflow session_id if hash is changed. */ if (!EVP_Digest(CBS_data(&session_ticket), CBS_len(&session_ticket), s->session->session_id, &session_id_length, EVP_sha256(), NULL)) { al = SSL_AD_INTERNAL_ERROR; @@ -1647,7 +1664,7 @@ ssl3_get_new_session_ticket(SSL *s) return (-1); } -int +static int ssl3_get_cert_status(SSL *s) { CBS cert_status, response; @@ -1663,13 +1680,13 @@ ssl3_get_cert_status(SSL *s) * Tell the callback the server did not send us an OSCP * response, and has decided to head directly to key exchange. */ - if (s->ctx->internal->tlsext_status_cb) { - free(s->internal->tlsext_ocsp_resp); - s->internal->tlsext_ocsp_resp = NULL; - s->internal->tlsext_ocsp_resp_len = 0; + if (s->ctx->tlsext_status_cb) { + free(s->tlsext_ocsp_resp); + s->tlsext_ocsp_resp = NULL; + s->tlsext_ocsp_resp_len = 0; - ret = s->ctx->internal->tlsext_status_cb(s, - s->ctx->internal->tlsext_status_arg); + ret = s->ctx->tlsext_status_cb(s, + s->ctx->tlsext_status_arg); if (ret == 0) { al = SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE; SSLerror(s, SSL_R_INVALID_STATUS_RESPONSE); @@ -1692,14 +1709,14 @@ ssl3_get_cert_status(SSL *s) goto fatal_err; } - if (s->internal->init_num < 0) { + if (s->init_num < 0) { /* need at least status type + length */ al = SSL_AD_DECODE_ERROR; SSLerror(s, SSL_R_LENGTH_MISMATCH); goto fatal_err; } - CBS_init(&cert_status, s->internal->init_msg, s->internal->init_num); + CBS_init(&cert_status, s->init_msg, s->init_num); if (!CBS_get_u8(&cert_status, &status_type) || CBS_len(&cert_status) < 3) { /* need at least status type + length */ @@ -1721,16 +1738,16 @@ ssl3_get_cert_status(SSL *s) goto fatal_err; } - if (!CBS_stow(&response, &s->internal->tlsext_ocsp_resp, - &s->internal->tlsext_ocsp_resp_len)) { + if (!CBS_stow(&response, &s->tlsext_ocsp_resp, + &s->tlsext_ocsp_resp_len)) { al = SSL_AD_INTERNAL_ERROR; SSLerror(s, ERR_R_MALLOC_FAILURE); goto fatal_err; } - if (s->ctx->internal->tlsext_status_cb) { - ret = s->ctx->internal->tlsext_status_cb(s, - s->ctx->internal->tlsext_status_arg); + if (s->ctx->tlsext_status_cb) { + ret = s->ctx->tlsext_status_cb(s, + s->ctx->tlsext_status_arg); if (ret == 0) { al = SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE; SSLerror(s, SSL_R_INVALID_STATUS_RESPONSE); @@ -1748,7 +1765,7 @@ ssl3_get_cert_status(SSL *s) return (-1); } -int +static int ssl3_get_server_done(SSL *s) { int ret; @@ -1758,7 +1775,7 @@ ssl3_get_server_done(SSL *s) 30 /* should be very small, like 0 :-) */)) <= 0) return ret; - if (s->internal->init_num != 0) { + if (s->init_num != 0) { /* should contain no data */ ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); SSLerror(s, SSL_R_LENGTH_MISMATCH); @@ -1924,7 +1941,7 @@ ssl3_send_client_kex_gost(SSL *s, CBB *cbb) int nid; int ret = 0; - /* Get server sertificate PKEY and create ctx from it */ + /* Get server certificate PKEY and create ctx from it */ pkey = X509_get0_pubkey(s->session->peer_cert); if (pkey == NULL || s->session->peer_cert_type != SSL_PKEY_GOST01) { SSLerror(s, SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER); @@ -2024,7 +2041,7 @@ ssl3_send_client_kex_gost(SSL *s, CBB *cbb) return ret; } -int +static int ssl3_send_client_key_exchange(SSL *s) { unsigned long alg_k; @@ -2283,7 +2300,7 @@ ssl3_send_client_verify_gost(SSL *s, EVP_PKEY *pkey, CBB *cert_verify) } #endif -int +static int ssl3_send_client_verify(SSL *s) { const struct ssl_sigalg *sigalg; @@ -2345,7 +2362,7 @@ ssl3_send_client_verify(SSL *s) return (-1); } -int +static int ssl3_send_client_certificate(SSL *s) { EVP_PKEY *pkey = NULL; @@ -2367,15 +2384,15 @@ ssl3_send_client_certificate(SSL *s) if (s->s3->hs.state == SSL3_ST_CW_CERT_B) { /* * If we get an error, we need to - * ssl->internal->rwstate = SSL_X509_LOOKUP; return(-1); + * ssl->rwstate = SSL_X509_LOOKUP; return(-1); * We then get retried later. */ i = ssl_do_client_cert_cb(s, &x509, &pkey); if (i < 0) { - s->internal->rwstate = SSL_X509_LOOKUP; + s->rwstate = SSL_X509_LOOKUP; return (-1); } - s->internal->rwstate = SSL_NOTHING; + s->rwstate = SSL_NOTHING; if ((i == 1) && (pkey != NULL) && (x509 != NULL)) { s->s3->hs.state = SSL3_ST_CW_CERT_B; if (!SSL_use_certificate(s, x509) || @@ -2423,7 +2440,7 @@ ssl3_send_client_certificate(SSL *s) #define has_bits(i,m) (((i)&(m)) == (m)) -int +static int ssl3_check_cert_and_algorithm(SSL *s) { long alg_k, alg_a; @@ -2481,7 +2498,7 @@ ssl3_check_cert_and_algorithm(SSL *s) * session tickets we have to check the next message to be sure. */ -int +static int ssl3_check_finished(SSL *s) { int ret; @@ -2492,7 +2509,7 @@ ssl3_check_finished(SSL *s) /* this function is called when we really expect a Certificate * message, so permit appropriate message length */ if ((ret = ssl3_get_message(s, SSL3_ST_CR_CERT_A, - SSL3_ST_CR_CERT_B, -1, s->internal->max_cert_list)) <= 0) + SSL3_ST_CR_CERT_B, -1, s->max_cert_list)) <= 0) return ret; s->s3->hs.tls12.reuse_message = 1; @@ -2503,21 +2520,155 @@ ssl3_check_finished(SSL *s) return (1); } -int +static int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey) { int i = 0; #ifndef OPENSSL_NO_ENGINE - if (s->ctx->internal->client_cert_engine) { + if (s->ctx->client_cert_engine) { i = ENGINE_load_ssl_client_cert( - s->ctx->internal->client_cert_engine, s, + s->ctx->client_cert_engine, s, SSL_get_client_CA_list(s), px509, ppkey, NULL, NULL, NULL); if (i != 0) return (i); } #endif - if (s->ctx->internal->client_cert_cb) - i = s->ctx->internal->client_cert_cb(s, px509, ppkey); + if (s->ctx->client_cert_cb) + i = s->ctx->client_cert_cb(s, px509, ppkey); return (i); } + +static int +ssl3_send_client_change_cipher_spec(SSL *s) +{ + size_t outlen; + CBB cbb; + + memset(&cbb, 0, sizeof(cbb)); + + if (s->s3->hs.state == SSL3_ST_CW_CHANGE_A) { + if (!CBB_init_fixed(&cbb, s->init_buf->data, + s->init_buf->length)) + goto err; + if (!CBB_add_u8(&cbb, SSL3_MT_CCS)) + goto err; + if (!CBB_finish(&cbb, NULL, &outlen)) + goto err; + + if (outlen > INT_MAX) + goto err; + + s->init_num = (int)outlen; + s->init_off = 0; + + if (SSL_is_dtls(s)) { + s->d1->handshake_write_seq = + s->d1->next_handshake_write_seq; + dtls1_set_message_header_int(s, SSL3_MT_CCS, 0, + s->d1->handshake_write_seq, 0, 0); + dtls1_buffer_message(s, 1); + } + + s->s3->hs.state = SSL3_ST_CW_CHANGE_B; + } + + /* SSL3_ST_CW_CHANGE_B */ + return ssl3_record_write(s, SSL3_RT_CHANGE_CIPHER_SPEC); + + err: + CBB_cleanup(&cbb); + + return -1; +} + +static int +ssl3_send_client_finished(SSL *s) +{ + CBB cbb, finished; + + memset(&cbb, 0, sizeof(cbb)); + + if (s->s3->hs.state == SSL3_ST_CW_FINISHED_A) { + if (!tls12_derive_finished(s)) + goto err; + + /* Copy finished so we can use it for renegotiation checks. */ + memcpy(s->s3->previous_client_finished, + s->s3->hs.finished, s->s3->hs.finished_len); + s->s3->previous_client_finished_len = + s->s3->hs.finished_len; + + if (!ssl3_handshake_msg_start(s, &cbb, &finished, + SSL3_MT_FINISHED)) + goto err; + if (!CBB_add_bytes(&finished, s->s3->hs.finished, + s->s3->hs.finished_len)) + goto err; + if (!ssl3_handshake_msg_finish(s, &cbb)) + goto err; + + s->s3->hs.state = SSL3_ST_CW_FINISHED_B; + } + + return (ssl3_handshake_write(s)); + + err: + CBB_cleanup(&cbb); + + return (-1); +} + +static int +ssl3_get_server_finished(SSL *s) +{ + int al, md_len, ret; + CBS cbs; + + /* should actually be 36+4 :-) */ + if ((ret = ssl3_get_message(s, SSL3_ST_CR_FINISHED_A, + SSL3_ST_CR_FINISHED_B, SSL3_MT_FINISHED, 64)) <= 0) + return ret; + + /* If this occurs, we have missed a message */ + if (!s->s3->change_cipher_spec) { + al = SSL_AD_UNEXPECTED_MESSAGE; + SSLerror(s, SSL_R_GOT_A_FIN_BEFORE_A_CCS); + goto fatal_err; + } + s->s3->change_cipher_spec = 0; + + md_len = TLS1_FINISH_MAC_LENGTH; + + if (s->init_num < 0) { + al = SSL_AD_DECODE_ERROR; + SSLerror(s, SSL_R_BAD_DIGEST_LENGTH); + goto fatal_err; + } + + CBS_init(&cbs, s->init_msg, s->init_num); + + if (s->s3->hs.peer_finished_len != md_len || + CBS_len(&cbs) != md_len) { + al = SSL_AD_DECODE_ERROR; + SSLerror(s, SSL_R_BAD_DIGEST_LENGTH); + goto fatal_err; + } + + if (!CBS_mem_equal(&cbs, s->s3->hs.peer_finished, CBS_len(&cbs))) { + al = SSL_AD_DECRYPT_ERROR; + SSLerror(s, SSL_R_DIGEST_CHECK_FAILED); + goto fatal_err; + } + + /* Copy finished so we can use it for renegotiation checks. */ + OPENSSL_assert(md_len <= EVP_MAX_MD_SIZE); + memcpy(s->s3->previous_server_finished, + s->s3->hs.peer_finished, md_len); + s->s3->previous_server_finished_len = md_len; + + return (1); + fatal_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + return (0); +} diff --git a/ssl/ssl_err.c b/ssl/ssl_err.c index 31925026..59d8119e 100644 --- a/ssl/ssl_err.c +++ b/ssl/ssl_err.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_err.c,v 1.44 2022/08/21 19:18:57 jsing Exp $ */ +/* $OpenBSD: ssl_err.c,v 1.45 2022/11/26 16:08:55 tb Exp $ */ /* ==================================================================== * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved. * @@ -59,7 +59,7 @@ #include #include -#include "ssl_locl.h" +#include "ssl_local.h" #ifndef OPENSSL_NO_ERR diff --git a/ssl/ssl_init.c b/ssl/ssl_init.c index b521d22d..65f38e25 100644 --- a/ssl/ssl_init.c +++ b/ssl/ssl_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_init.c,v 1.2 2018/03/30 14:59:46 jsing Exp $ */ +/* $OpenBSD: ssl_init.c,v 1.3 2022/11/26 16:08:55 tb Exp $ */ /* * Copyright (c) 2018 Bob Beck * @@ -22,7 +22,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" static pthread_t ssl_init_thread; diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index f5f7bf66..de4ef3fb 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_lib.c,v 1.305 2022/09/10 15:29:33 jsing Exp $ */ +/* $OpenBSD: ssl_lib.c,v 1.308 2022/11/26 16:08:55 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -159,10 +159,11 @@ #endif #include "bytestring.h" -#include "dtls_locl.h" -#include "ssl_locl.h" +#include "dtls_local.h" +#include "ssl_local.h" #include "ssl_sigalgs.h" #include "ssl_tlsext.h" +#include "tls12_internal.h" const char *SSL_version_str = OPENSSL_VERSION_TEXT; @@ -180,33 +181,33 @@ SSL_clear(SSL *s) } s->error = 0; - s->internal->hit = 0; - s->internal->shutdown = 0; + s->hit = 0; + s->shutdown = 0; - if (s->internal->renegotiate) { + if (s->renegotiate) { SSLerror(s, ERR_R_INTERNAL_ERROR); return (0); } s->version = s->method->version; s->client_version = s->version; - s->internal->rwstate = SSL_NOTHING; - s->internal->rstate = SSL_ST_READ_HEADER; + s->rwstate = SSL_NOTHING; + s->rstate = SSL_ST_READ_HEADER; - tls13_ctx_free(s->internal->tls13); - s->internal->tls13 = NULL; + tls13_ctx_free(s->tls13); + s->tls13 = NULL; ssl3_release_init_buffer(s); ssl_clear_cipher_state(s); - s->internal->first_packet = 0; + s->first_packet = 0; /* * Check to see if we were changed into a different method, if * so, revert back if we are not doing session-id reuse. */ - if (!s->internal->in_handshake && (s->session == NULL) && + if (!s->in_handshake && (s->session == NULL) && (s->method != s->ctx->method)) { s->method->ssl_free(s); s->method = s->ctx->method; @@ -227,8 +228,8 @@ SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth) ctx->method = meth; ciphers = ssl_create_cipher_list(ctx->method, &ctx->cipher_list, - ctx->internal->cipher_list_tls13, SSL_DEFAULT_CIPHER_LIST, - ctx->internal->cert); + ctx->cipher_list_tls13, SSL_DEFAULT_CIPHER_LIST, + ctx->cert); if (ciphers == NULL || sk_SSL_CIPHER_num(ciphers) <= 0) { SSLerrorx(SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS); return (0); @@ -253,87 +254,85 @@ SSL_new(SSL_CTX *ctx) if ((s = calloc(1, sizeof(*s))) == NULL) goto err; - if ((s->internal = calloc(1, sizeof(*s->internal))) == NULL) - goto err; - if ((s->internal->rl = tls12_record_layer_new()) == NULL) + if ((s->rl = tls12_record_layer_new()) == NULL) goto err; - s->internal->min_tls_version = ctx->internal->min_tls_version; - s->internal->max_tls_version = ctx->internal->max_tls_version; - s->internal->min_proto_version = ctx->internal->min_proto_version; - s->internal->max_proto_version = ctx->internal->max_proto_version; + s->min_tls_version = ctx->min_tls_version; + s->max_tls_version = ctx->max_tls_version; + s->min_proto_version = ctx->min_proto_version; + s->max_proto_version = ctx->max_proto_version; - s->internal->options = ctx->internal->options; - s->internal->mode = ctx->internal->mode; - s->internal->max_cert_list = ctx->internal->max_cert_list; - s->internal->num_tickets = ctx->internal->num_tickets; + s->options = ctx->options; + s->mode = ctx->mode; + s->max_cert_list = ctx->max_cert_list; + s->num_tickets = ctx->num_tickets; - if ((s->cert = ssl_cert_dup(ctx->internal->cert)) == NULL) + if ((s->cert = ssl_cert_dup(ctx->cert)) == NULL) goto err; - s->internal->read_ahead = ctx->internal->read_ahead; - s->internal->msg_callback = ctx->internal->msg_callback; - s->internal->msg_callback_arg = ctx->internal->msg_callback_arg; + s->read_ahead = ctx->read_ahead; + s->msg_callback = ctx->msg_callback; + s->msg_callback_arg = ctx->msg_callback_arg; s->verify_mode = ctx->verify_mode; s->sid_ctx_length = ctx->sid_ctx_length; OPENSSL_assert(s->sid_ctx_length <= sizeof s->sid_ctx); memcpy(&s->sid_ctx, &ctx->sid_ctx, sizeof(s->sid_ctx)); - s->internal->verify_callback = ctx->internal->default_verify_callback; - s->internal->generate_session_id = ctx->internal->generate_session_id; + s->verify_callback = ctx->default_verify_callback; + s->generate_session_id = ctx->generate_session_id; s->param = X509_VERIFY_PARAM_new(); if (!s->param) goto err; X509_VERIFY_PARAM_inherit(s->param, ctx->param); - s->internal->quiet_shutdown = ctx->internal->quiet_shutdown; - s->max_send_fragment = ctx->internal->max_send_fragment; + s->quiet_shutdown = ctx->quiet_shutdown; + s->max_send_fragment = ctx->max_send_fragment; CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); s->ctx = ctx; - s->internal->tlsext_debug_cb = 0; - s->internal->tlsext_debug_arg = NULL; - s->internal->tlsext_ticket_expected = 0; + s->tlsext_debug_cb = 0; + s->tlsext_debug_arg = NULL; + s->tlsext_ticket_expected = 0; s->tlsext_status_type = -1; - s->internal->tlsext_status_expected = 0; - s->internal->tlsext_ocsp_ids = NULL; - s->internal->tlsext_ocsp_exts = NULL; - s->internal->tlsext_ocsp_resp = NULL; - s->internal->tlsext_ocsp_resp_len = 0; + s->tlsext_status_expected = 0; + s->tlsext_ocsp_ids = NULL; + s->tlsext_ocsp_exts = NULL; + s->tlsext_ocsp_resp = NULL; + s->tlsext_ocsp_resp_len = 0; CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); s->initial_ctx = ctx; - if (ctx->internal->tlsext_ecpointformatlist != NULL) { - s->internal->tlsext_ecpointformatlist = - calloc(ctx->internal->tlsext_ecpointformatlist_length, - sizeof(ctx->internal->tlsext_ecpointformatlist[0])); - if (s->internal->tlsext_ecpointformatlist == NULL) + if (ctx->tlsext_ecpointformatlist != NULL) { + s->tlsext_ecpointformatlist = + calloc(ctx->tlsext_ecpointformatlist_length, + sizeof(ctx->tlsext_ecpointformatlist[0])); + if (s->tlsext_ecpointformatlist == NULL) goto err; - memcpy(s->internal->tlsext_ecpointformatlist, - ctx->internal->tlsext_ecpointformatlist, - ctx->internal->tlsext_ecpointformatlist_length * - sizeof(ctx->internal->tlsext_ecpointformatlist[0])); - s->internal->tlsext_ecpointformatlist_length = - ctx->internal->tlsext_ecpointformatlist_length; - } - if (ctx->internal->tlsext_supportedgroups != NULL) { - s->internal->tlsext_supportedgroups = - calloc(ctx->internal->tlsext_supportedgroups_length, - sizeof(ctx->internal->tlsext_supportedgroups[0])); - if (s->internal->tlsext_supportedgroups == NULL) + memcpy(s->tlsext_ecpointformatlist, + ctx->tlsext_ecpointformatlist, + ctx->tlsext_ecpointformatlist_length * + sizeof(ctx->tlsext_ecpointformatlist[0])); + s->tlsext_ecpointformatlist_length = + ctx->tlsext_ecpointformatlist_length; + } + if (ctx->tlsext_supportedgroups != NULL) { + s->tlsext_supportedgroups = + calloc(ctx->tlsext_supportedgroups_length, + sizeof(ctx->tlsext_supportedgroups[0])); + if (s->tlsext_supportedgroups == NULL) goto err; - memcpy(s->internal->tlsext_supportedgroups, - ctx->internal->tlsext_supportedgroups, - ctx->internal->tlsext_supportedgroups_length * - sizeof(ctx->internal->tlsext_supportedgroups[0])); - s->internal->tlsext_supportedgroups_length = - ctx->internal->tlsext_supportedgroups_length; - } - - CBS_init(&cbs, ctx->internal->alpn_client_proto_list, - ctx->internal->alpn_client_proto_list_len); - if (!CBS_stow(&cbs, &s->internal->alpn_client_proto_list, - &s->internal->alpn_client_proto_list_len)) + memcpy(s->tlsext_supportedgroups, + ctx->tlsext_supportedgroups, + ctx->tlsext_supportedgroups_length * + sizeof(ctx->tlsext_supportedgroups[0])); + s->tlsext_supportedgroups_length = + ctx->tlsext_supportedgroups_length; + } + + CBS_init(&cbs, ctx->alpn_client_proto_list, + ctx->alpn_client_proto_list_len); + if (!CBS_stow(&cbs, &s->alpn_client_proto_list, + &s->alpn_client_proto_list_len)) goto err; s->verify_result = X509_V_OK; @@ -349,7 +348,7 @@ SSL_new(SSL_CTX *ctx) SSL_clear(s); - CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->internal->ex_data); + CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); return (s); @@ -391,7 +390,7 @@ int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb) { CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); - ctx->internal->generate_session_id = cb; + ctx->generate_session_id = cb; CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); return (1); } @@ -400,7 +399,7 @@ int SSL_set_generate_session_id(SSL *ssl, GEN_SESSION_CB cb) { CRYPTO_w_lock(CRYPTO_LOCK_SSL); - ssl->internal->generate_session_id = cb; + ssl->generate_session_id = cb; CRYPTO_w_unlock(CRYPTO_LOCK_SSL); return (1); } @@ -426,7 +425,7 @@ SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, memcpy(r.session_id, id, id_len); CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); - p = lh_SSL_SESSION_retrieve(ssl->ctx->internal->sessions, &r); + p = lh_SSL_SESSION_retrieve(ssl->ctx->sessions, &r); CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); return (p != NULL); } @@ -519,7 +518,7 @@ SSL_free(SSL *s) X509_VERIFY_PARAM_free(s->param); - CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->internal->ex_data); + CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); if (s->bbio != NULL) { /* If the buffering BIO is in place, pop it off */ @@ -534,12 +533,12 @@ SSL_free(SSL *s) BIO_free_all(s->rbio); BIO_free_all(s->wbio); - tls13_ctx_free(s->internal->tls13); + tls13_ctx_free(s->tls13); ssl3_release_init_buffer(s); sk_SSL_CIPHER_free(s->cipher_list); - sk_SSL_CIPHER_free(s->internal->cipher_list_tls13); + sk_SSL_CIPHER_free(s->cipher_list_tls13); /* Make the next call work :-) */ if (s->session != NULL) { @@ -554,32 +553,31 @@ SSL_free(SSL *s) free(s->tlsext_hostname); SSL_CTX_free(s->initial_ctx); - free(s->internal->tlsext_ecpointformatlist); - free(s->internal->tlsext_supportedgroups); + free(s->tlsext_ecpointformatlist); + free(s->tlsext_supportedgroups); - sk_X509_EXTENSION_pop_free(s->internal->tlsext_ocsp_exts, + sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, X509_EXTENSION_free); - sk_OCSP_RESPID_pop_free(s->internal->tlsext_ocsp_ids, OCSP_RESPID_free); - free(s->internal->tlsext_ocsp_resp); + sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, OCSP_RESPID_free); + free(s->tlsext_ocsp_resp); - sk_X509_NAME_pop_free(s->internal->client_CA, X509_NAME_free); + sk_X509_NAME_pop_free(s->client_CA, X509_NAME_free); if (s->method != NULL) s->method->ssl_free(s); SSL_CTX_free(s->ctx); - free(s->internal->alpn_client_proto_list); + free(s->alpn_client_proto_list); - free(s->internal->quic_transport_params); + free(s->quic_transport_params); #ifndef OPENSSL_NO_SRTP - sk_SRTP_PROTECTION_PROFILE_free(s->internal->srtp_profiles); + sk_SRTP_PROTECTION_PROFILE_free(s->srtp_profiles); #endif - tls12_record_layer_free(s->internal->rl); + tls12_record_layer_free(s->rl); - free(s->internal); free(s); } @@ -768,25 +766,25 @@ SSL_get_verify_depth(const SSL *s) int (*SSL_get_verify_callback(const SSL *s))(int, X509_STORE_CTX *) { - return (s->internal->verify_callback); + return (s->verify_callback); } void SSL_CTX_set_keylog_callback(SSL_CTX *ctx, SSL_CTX_keylog_cb_func cb) { - ctx->internal->keylog_callback = cb; + ctx->keylog_callback = cb; } SSL_CTX_keylog_cb_func SSL_CTX_get_keylog_callback(const SSL_CTX *ctx) { - return (ctx->internal->keylog_callback); + return (ctx->keylog_callback); } int SSL_set_num_tickets(SSL *s, size_t num_tickets) { - s->internal->num_tickets = num_tickets; + s->num_tickets = num_tickets; return 1; } @@ -794,13 +792,13 @@ SSL_set_num_tickets(SSL *s, size_t num_tickets) size_t SSL_get_num_tickets(const SSL *s) { - return s->internal->num_tickets; + return s->num_tickets; } int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets) { - ctx->internal->num_tickets = num_tickets; + ctx->num_tickets = num_tickets; return 1; } @@ -808,7 +806,7 @@ SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets) size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx) { - return ctx->internal->num_tickets; + return ctx->num_tickets; } int @@ -826,7 +824,7 @@ SSL_CTX_get_verify_depth(const SSL_CTX *ctx) int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int, X509_STORE_CTX *) { - return (ctx->internal->default_verify_callback); + return (ctx->default_verify_callback); } void @@ -835,7 +833,7 @@ SSL_set_verify(SSL *s, int mode, { s->verify_mode = mode; if (callback != NULL) - s->internal->verify_callback = callback; + s->verify_callback = callback; } void @@ -847,13 +845,13 @@ SSL_set_verify_depth(SSL *s, int depth) void SSL_set_read_ahead(SSL *s, int yes) { - s->internal->read_ahead = yes; + s->read_ahead = yes; } int SSL_get_read_ahead(const SSL *s) { - return (s->internal->read_ahead); + return (s->read_ahead); } int @@ -897,7 +895,7 @@ SSL_get_peer_cert_chain(const SSL *s) STACK_OF(X509) * SSL_get0_verified_chain(const SSL *s) { - return s->internal->verified_chain; + return s->verified_chain; } /* @@ -939,17 +937,17 @@ SSL_copy_session_id(SSL *t, const SSL *f) int SSL_CTX_check_private_key(const SSL_CTX *ctx) { - if ((ctx == NULL) || (ctx->internal->cert == NULL) || - (ctx->internal->cert->key->x509 == NULL)) { + if ((ctx == NULL) || (ctx->cert == NULL) || + (ctx->cert->key->x509 == NULL)) { SSLerrorx(SSL_R_NO_CERTIFICATE_ASSIGNED); return (0); } - if (ctx->internal->cert->key->privatekey == NULL) { + if (ctx->cert->key->privatekey == NULL) { SSLerrorx(SSL_R_NO_PRIVATE_KEY_ASSIGNED); return (0); } - return (X509_check_private_key(ctx->internal->cert->key->x509, - ctx->internal->cert->key->privatekey)); + return (X509_check_private_key(ctx->cert->key->x509, + ctx->cert->key->privatekey)); } /* Fix this function so that it takes an optional type parameter */ @@ -979,7 +977,7 @@ SSL_check_private_key(const SSL *ssl) int SSL_accept(SSL *s) { - if (s->internal->handshake_func == NULL) + if (s->handshake_func == NULL) SSL_set_accept_state(s); /* Not properly initialized yet */ return (s->method->ssl_accept(s)); @@ -988,7 +986,7 @@ SSL_accept(SSL *s) int SSL_connect(SSL *s) { - if (s->internal->handshake_func == NULL) + if (s->handshake_func == NULL) SSL_set_connect_state(s); /* Not properly initialized yet */ return (s->method->ssl_connect(s)); @@ -1035,13 +1033,13 @@ SSL_read(SSL *s, void *buf, int num) return (-1); } - if (s->internal->handshake_func == NULL) { + if (s->handshake_func == NULL) { SSLerror(s, SSL_R_UNINITIALIZED); return (-1); } - if (s->internal->shutdown & SSL_RECEIVED_SHUTDOWN) { - s->internal->rwstate = SSL_NOTHING; + if (s->shutdown & SSL_RECEIVED_SHUTDOWN) { + s->rwstate = SSL_NOTHING; return (0); } return ssl3_read(s, buf, num); @@ -1079,12 +1077,12 @@ SSL_peek(SSL *s, void *buf, int num) return (-1); } - if (s->internal->handshake_func == NULL) { + if (s->handshake_func == NULL) { SSLerror(s, SSL_R_UNINITIALIZED); return (-1); } - if (s->internal->shutdown & SSL_RECEIVED_SHUTDOWN) { + if (s->shutdown & SSL_RECEIVED_SHUTDOWN) { return (0); } return ssl3_peek(s, buf, num); @@ -1122,13 +1120,13 @@ SSL_write(SSL *s, const void *buf, int num) return (-1); } - if (s->internal->handshake_func == NULL) { + if (s->handshake_func == NULL) { SSLerror(s, SSL_R_UNINITIALIZED); return (-1); } - if (s->internal->shutdown & SSL_SENT_SHUTDOWN) { - s->internal->rwstate = SSL_NOTHING; + if (s->shutdown & SSL_SENT_SHUTDOWN) { + s->rwstate = SSL_NOTHING; SSLerror(s, SSL_R_PROTOCOL_IS_SHUTDOWN); return (-1); } @@ -1221,7 +1219,7 @@ SSL_shutdown(SSL *s) * even if blocking I/O is used (see ssl3_shutdown). */ - if (s->internal->handshake_func == NULL) { + if (s->handshake_func == NULL) { SSLerror(s, SSL_R_UNINITIALIZED); return (-1); } @@ -1235,10 +1233,10 @@ SSL_shutdown(SSL *s) int SSL_renegotiate(SSL *s) { - if (s->internal->renegotiate == 0) - s->internal->renegotiate = 1; + if (s->renegotiate == 0) + s->renegotiate = 1; - s->internal->new_session = 1; + s->new_session = 1; return (s->method->ssl_renegotiate(s)); } @@ -1246,10 +1244,10 @@ SSL_renegotiate(SSL *s) int SSL_renegotiate_abbreviated(SSL *s) { - if (s->internal->renegotiate == 0) - s->internal->renegotiate = 1; + if (s->renegotiate == 0) + s->renegotiate = 1; - s->internal->new_session = 0; + s->new_session = 0; return (s->method->ssl_renegotiate(s)); } @@ -1261,7 +1259,7 @@ SSL_renegotiate_pending(SSL *s) * Becomes true when negotiation is requested; * false again once a handshake has finished. */ - return (s->internal->renegotiate != 0); + return (s->renegotiate != 0); } long @@ -1271,29 +1269,29 @@ SSL_ctrl(SSL *s, int cmd, long larg, void *parg) switch (cmd) { case SSL_CTRL_GET_READ_AHEAD: - return (s->internal->read_ahead); + return (s->read_ahead); case SSL_CTRL_SET_READ_AHEAD: - l = s->internal->read_ahead; - s->internal->read_ahead = larg; + l = s->read_ahead; + s->read_ahead = larg; return (l); case SSL_CTRL_SET_MSG_CALLBACK_ARG: - s->internal->msg_callback_arg = parg; + s->msg_callback_arg = parg; return (1); case SSL_CTRL_OPTIONS: - return (s->internal->options|=larg); + return (s->options|=larg); case SSL_CTRL_CLEAR_OPTIONS: - return (s->internal->options&=~larg); + return (s->options&=~larg); case SSL_CTRL_MODE: - return (s->internal->mode|=larg); + return (s->mode|=larg); case SSL_CTRL_CLEAR_MODE: - return (s->internal->mode &=~larg); + return (s->mode &=~larg); case SSL_CTRL_GET_MAX_CERT_LIST: - return (s->internal->max_cert_list); + return (s->max_cert_list); case SSL_CTRL_SET_MAX_CERT_LIST: - l = s->internal->max_cert_list; - s->internal->max_cert_list = larg; + l = s->max_cert_list; + s->max_cert_list = larg; return (l); case SSL_CTRL_SET_MTU: #ifndef OPENSSL_NO_DTLS1 @@ -1326,7 +1324,7 @@ SSL_callback_ctrl(SSL *s, int cmd, void (*fp)(void)) { switch (cmd) { case SSL_CTRL_SET_MSG_CALLBACK: - s->internal->msg_callback = (ssl_msg_callback_fn *)(fp); + s->msg_callback = (ssl_msg_callback_fn *)(fp); return (1); default: @@ -1337,7 +1335,7 @@ SSL_callback_ctrl(SSL *s, int cmd, void (*fp)(void)) struct lhash_st_SSL_SESSION * SSL_CTX_sessions(SSL_CTX *ctx) { - return (ctx->internal->sessions); + return (ctx->sessions); } long @@ -1347,72 +1345,72 @@ SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) switch (cmd) { case SSL_CTRL_GET_READ_AHEAD: - return (ctx->internal->read_ahead); + return (ctx->read_ahead); case SSL_CTRL_SET_READ_AHEAD: - l = ctx->internal->read_ahead; - ctx->internal->read_ahead = larg; + l = ctx->read_ahead; + ctx->read_ahead = larg; return (l); case SSL_CTRL_SET_MSG_CALLBACK_ARG: - ctx->internal->msg_callback_arg = parg; + ctx->msg_callback_arg = parg; return (1); case SSL_CTRL_GET_MAX_CERT_LIST: - return (ctx->internal->max_cert_list); + return (ctx->max_cert_list); case SSL_CTRL_SET_MAX_CERT_LIST: - l = ctx->internal->max_cert_list; - ctx->internal->max_cert_list = larg; + l = ctx->max_cert_list; + ctx->max_cert_list = larg; return (l); case SSL_CTRL_SET_SESS_CACHE_SIZE: - l = ctx->internal->session_cache_size; - ctx->internal->session_cache_size = larg; + l = ctx->session_cache_size; + ctx->session_cache_size = larg; return (l); case SSL_CTRL_GET_SESS_CACHE_SIZE: - return (ctx->internal->session_cache_size); + return (ctx->session_cache_size); case SSL_CTRL_SET_SESS_CACHE_MODE: - l = ctx->internal->session_cache_mode; - ctx->internal->session_cache_mode = larg; + l = ctx->session_cache_mode; + ctx->session_cache_mode = larg; return (l); case SSL_CTRL_GET_SESS_CACHE_MODE: - return (ctx->internal->session_cache_mode); + return (ctx->session_cache_mode); case SSL_CTRL_SESS_NUMBER: - return (lh_SSL_SESSION_num_items(ctx->internal->sessions)); + return (lh_SSL_SESSION_num_items(ctx->sessions)); case SSL_CTRL_SESS_CONNECT: - return (ctx->internal->stats.sess_connect); + return (ctx->stats.sess_connect); case SSL_CTRL_SESS_CONNECT_GOOD: - return (ctx->internal->stats.sess_connect_good); + return (ctx->stats.sess_connect_good); case SSL_CTRL_SESS_CONNECT_RENEGOTIATE: - return (ctx->internal->stats.sess_connect_renegotiate); + return (ctx->stats.sess_connect_renegotiate); case SSL_CTRL_SESS_ACCEPT: - return (ctx->internal->stats.sess_accept); + return (ctx->stats.sess_accept); case SSL_CTRL_SESS_ACCEPT_GOOD: - return (ctx->internal->stats.sess_accept_good); + return (ctx->stats.sess_accept_good); case SSL_CTRL_SESS_ACCEPT_RENEGOTIATE: - return (ctx->internal->stats.sess_accept_renegotiate); + return (ctx->stats.sess_accept_renegotiate); case SSL_CTRL_SESS_HIT: - return (ctx->internal->stats.sess_hit); + return (ctx->stats.sess_hit); case SSL_CTRL_SESS_CB_HIT: - return (ctx->internal->stats.sess_cb_hit); + return (ctx->stats.sess_cb_hit); case SSL_CTRL_SESS_MISSES: - return (ctx->internal->stats.sess_miss); + return (ctx->stats.sess_miss); case SSL_CTRL_SESS_TIMEOUTS: - return (ctx->internal->stats.sess_timeout); + return (ctx->stats.sess_timeout); case SSL_CTRL_SESS_CACHE_FULL: - return (ctx->internal->stats.sess_cache_full); + return (ctx->stats.sess_cache_full); case SSL_CTRL_OPTIONS: - return (ctx->internal->options|=larg); + return (ctx->options|=larg); case SSL_CTRL_CLEAR_OPTIONS: - return (ctx->internal->options&=~larg); + return (ctx->options&=~larg); case SSL_CTRL_MODE: - return (ctx->internal->mode|=larg); + return (ctx->mode|=larg); case SSL_CTRL_CLEAR_MODE: - return (ctx->internal->mode&=~larg); + return (ctx->mode&=~larg); case SSL_CTRL_SET_MAX_SEND_FRAGMENT: if (larg < 512 || larg > SSL3_RT_MAX_PLAIN_LENGTH) return (0); - ctx->internal->max_send_fragment = larg; + ctx->max_send_fragment = larg; return (1); default: return (ssl3_ctx_ctrl(ctx, cmd, larg, parg)); @@ -1424,7 +1422,7 @@ SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)) { switch (cmd) { case SSL_CTRL_SET_MSG_CALLBACK: - ctx->internal->msg_callback = (ssl_msg_callback_fn *)fp; + ctx->msg_callback = (ssl_msg_callback_fn *)fp; return (1); default: @@ -1562,7 +1560,7 @@ SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) * ctx->cipher_list has been updated. */ ciphers = ssl_create_cipher_list(ctx->method, &ctx->cipher_list, - ctx->internal->cipher_list_tls13, str, ctx->internal->cert); + ctx->cipher_list_tls13, str, ctx->cert); if (ciphers == NULL) { return (0); } else if (sk_SSL_CIPHER_num(ciphers) == 0) { @@ -1575,12 +1573,12 @@ SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str) { - if (!ssl_parse_ciphersuites(&ctx->internal->cipher_list_tls13, str)) { + if (!ssl_parse_ciphersuites(&ctx->cipher_list_tls13, str)) { SSLerrorx(SSL_R_NO_CIPHER_MATCH); return 0; } if (!ssl_merge_cipherlists(ctx->cipher_list, - ctx->internal->cipher_list_tls13, &ctx->cipher_list)) + ctx->cipher_list_tls13, &ctx->cipher_list)) return 0; return 1; @@ -1592,8 +1590,8 @@ SSL_set_cipher_list(SSL *s, const char *str) { STACK_OF(SSL_CIPHER) *ciphers, *ciphers_tls13; - if ((ciphers_tls13 = s->internal->cipher_list_tls13) == NULL) - ciphers_tls13 = s->ctx->internal->cipher_list_tls13; + if ((ciphers_tls13 = s->cipher_list_tls13) == NULL) + ciphers_tls13 = s->ctx->cipher_list_tls13; /* See comment in SSL_CTX_set_cipher_list. */ ciphers = ssl_create_cipher_list(s->ctx->method, &s->cipher_list, @@ -1615,11 +1613,11 @@ SSL_set_ciphersuites(SSL *s, const char *str) if ((ciphers = s->cipher_list) == NULL) ciphers = s->ctx->cipher_list; - if (!ssl_parse_ciphersuites(&s->internal->cipher_list_tls13, str)) { + if (!ssl_parse_ciphersuites(&s->cipher_list_tls13, str)) { SSLerrorx(SSL_R_NO_CIPHER_MATCH); return (0); } - if (!ssl_merge_cipherlists(ciphers, s->internal->cipher_list_tls13, + if (!ssl_merge_cipherlists(ciphers, s->cipher_list_tls13, &s->cipher_list)) return 0; @@ -1791,8 +1789,8 @@ SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, goto err; } - if (!CBS_stow(&cbs, &ctx->internal->alpn_client_proto_list, - &ctx->internal->alpn_client_proto_list_len)) + if (!CBS_stow(&cbs, &ctx->alpn_client_proto_list, + &ctx->alpn_client_proto_list_len)) goto err; failed = 0; @@ -1824,8 +1822,8 @@ SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos, goto err; } - if (!CBS_stow(&cbs, &ssl->internal->alpn_client_proto_list, - &ssl->internal->alpn_client_proto_list_len)) + if (!CBS_stow(&cbs, &ssl->alpn_client_proto_list, + &ssl->alpn_client_proto_list_len)) goto err; failed = 0; @@ -1845,8 +1843,8 @@ SSL_CTX_set_alpn_select_cb(SSL_CTX* ctx, int (*cb) (SSL *ssl, const unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg), void *arg) { - ctx->internal->alpn_select_cb = cb; - ctx->internal->alpn_select_cb_arg = arg; + ctx->alpn_select_cb = cb; + ctx->alpn_select_cb_arg = arg; } /* @@ -1870,21 +1868,21 @@ SSL_set_psk_use_session_callback(SSL *s, SSL_psk_use_session_cb_func cb) } int -SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, - const char *label, size_t llen, const unsigned char *p, size_t plen, - int use_context) +SSL_export_keying_material(SSL *s, unsigned char *out, size_t out_len, + const char *label, size_t label_len, const unsigned char *context, + size_t context_len, int use_context) { - if (s->internal->tls13 != NULL && s->version == TLS1_3_VERSION) { + if (s->tls13 != NULL && s->version == TLS1_3_VERSION) { if (!use_context) { - p = NULL; - plen = 0; + context = NULL; + context_len = 0; } - return tls13_exporter(s->internal->tls13, label, llen, p, plen, - out, olen); + return tls13_exporter(s->tls13, label, label_len, context, + context_len, out, out_len); } - return (tls1_export_keying_material(s, out, olen, label, llen, p, plen, - use_context)); + return tls12_exporter(s, label, label_len, context, context_len, + use_context, out, out_len); } static unsigned long @@ -1961,11 +1959,6 @@ SSL_CTX_new(const SSL_METHOD *meth) SSLerrorx(ERR_R_MALLOC_FAILURE); return (NULL); } - if ((ret->internal = calloc(1, sizeof(*ret->internal))) == NULL) { - free(ret); - SSLerrorx(ERR_R_MALLOC_FAILURE); - return (NULL); - } if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) { SSLerrorx(SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); @@ -1973,62 +1966,62 @@ SSL_CTX_new(const SSL_METHOD *meth) } ret->method = meth; - ret->internal->min_tls_version = meth->min_tls_version; - ret->internal->max_tls_version = meth->max_tls_version; - ret->internal->min_proto_version = 0; - ret->internal->max_proto_version = 0; - ret->internal->mode = SSL_MODE_AUTO_RETRY; + ret->min_tls_version = meth->min_tls_version; + ret->max_tls_version = meth->max_tls_version; + ret->min_proto_version = 0; + ret->max_proto_version = 0; + ret->mode = SSL_MODE_AUTO_RETRY; ret->cert_store = NULL; - ret->internal->session_cache_mode = SSL_SESS_CACHE_SERVER; - ret->internal->session_cache_size = SSL_SESSION_CACHE_MAX_SIZE_DEFAULT; - ret->internal->session_cache_head = NULL; - ret->internal->session_cache_tail = NULL; + ret->session_cache_mode = SSL_SESS_CACHE_SERVER; + ret->session_cache_size = SSL_SESSION_CACHE_MAX_SIZE_DEFAULT; + ret->session_cache_head = NULL; + ret->session_cache_tail = NULL; /* We take the system default */ ret->session_timeout = ssl_get_default_timeout(); - ret->internal->new_session_cb = 0; - ret->internal->remove_session_cb = 0; - ret->internal->get_session_cb = 0; - ret->internal->generate_session_id = 0; + ret->new_session_cb = 0; + ret->remove_session_cb = 0; + ret->get_session_cb = 0; + ret->generate_session_id = 0; - memset((char *)&ret->internal->stats, 0, sizeof(ret->internal->stats)); + memset((char *)&ret->stats, 0, sizeof(ret->stats)); ret->references = 1; - ret->internal->quiet_shutdown = 0; + ret->quiet_shutdown = 0; - ret->internal->info_callback = NULL; + ret->info_callback = NULL; - ret->internal->app_verify_callback = 0; - ret->internal->app_verify_arg = NULL; + ret->app_verify_callback = 0; + ret->app_verify_arg = NULL; - ret->internal->max_cert_list = SSL_MAX_CERT_LIST_DEFAULT; - ret->internal->read_ahead = 0; - ret->internal->msg_callback = 0; - ret->internal->msg_callback_arg = NULL; + ret->max_cert_list = SSL_MAX_CERT_LIST_DEFAULT; + ret->read_ahead = 0; + ret->msg_callback = 0; + ret->msg_callback_arg = NULL; ret->verify_mode = SSL_VERIFY_NONE; ret->sid_ctx_length = 0; - ret->internal->default_verify_callback = NULL; + ret->default_verify_callback = NULL; - if ((ret->internal->cert = ssl_cert_new()) == NULL) + if ((ret->cert = ssl_cert_new()) == NULL) goto err; ret->default_passwd_callback = 0; ret->default_passwd_callback_userdata = NULL; - ret->internal->client_cert_cb = 0; - ret->internal->app_gen_cookie_cb = 0; - ret->internal->app_verify_cookie_cb = 0; + ret->client_cert_cb = 0; + ret->app_gen_cookie_cb = 0; + ret->app_verify_cookie_cb = 0; - ret->internal->sessions = lh_SSL_SESSION_new(); - if (ret->internal->sessions == NULL) + ret->sessions = lh_SSL_SESSION_new(); + if (ret->sessions == NULL) goto err; ret->cert_store = X509_STORE_new(); if (ret->cert_store == NULL) goto err; ssl_create_cipher_list(ret->method, &ret->cipher_list, - NULL, SSL_DEFAULT_CIPHER_LIST, ret->internal->cert); + NULL, SSL_DEFAULT_CIPHER_LIST, ret->cert); if (ret->cipher_list == NULL || sk_SSL_CIPHER_num(ret->cipher_list) <= 0) { SSLerrorx(SSL_R_LIBRARY_HAS_NO_CIPHERS); @@ -2039,28 +2032,28 @@ SSL_CTX_new(const SSL_METHOD *meth) if (!ret->param) goto err; - if ((ret->internal->client_CA = sk_X509_NAME_new_null()) == NULL) + if ((ret->client_CA = sk_X509_NAME_new_null()) == NULL) goto err; - CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ret, &ret->internal->ex_data); + CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ret, &ret->ex_data); ret->extra_certs = NULL; - ret->internal->max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH; + ret->max_send_fragment = SSL3_RT_MAX_PLAIN_LENGTH; - ret->internal->tlsext_servername_callback = 0; - ret->internal->tlsext_servername_arg = NULL; + ret->tlsext_servername_callback = 0; + ret->tlsext_servername_arg = NULL; /* Setup RFC4507 ticket keys */ - arc4random_buf(ret->internal->tlsext_tick_key_name, 16); - arc4random_buf(ret->internal->tlsext_tick_hmac_key, 16); - arc4random_buf(ret->internal->tlsext_tick_aes_key, 16); + arc4random_buf(ret->tlsext_tick_key_name, 16); + arc4random_buf(ret->tlsext_tick_hmac_key, 16); + arc4random_buf(ret->tlsext_tick_aes_key, 16); - ret->internal->tlsext_status_cb = 0; - ret->internal->tlsext_status_arg = NULL; + ret->tlsext_status_cb = 0; + ret->tlsext_status_arg = NULL; #ifndef OPENSSL_NO_ENGINE - ret->internal->client_cert_engine = NULL; + ret->client_cert_engine = NULL; #ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO #define eng_strx(x) #x #define eng_str(x) eng_strx(x) @@ -2083,7 +2076,7 @@ SSL_CTX_new(const SSL_METHOD *meth) * Default is to connect to non-RI servers. When RI is more widely * deployed might change this. */ - ret->internal->options |= SSL_OP_LEGACY_SERVER_CONNECT; + ret->options |= SSL_OP_LEGACY_SERVER_CONNECT; return (ret); err: @@ -2116,35 +2109,34 @@ SSL_CTX_free(SSL_CTX *ctx) * free ex_data, then finally free the cache. * (See ticket [openssl.org #212].) */ - if (ctx->internal->sessions != NULL) + if (ctx->sessions != NULL) SSL_CTX_flush_sessions(ctx, 0); - CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ctx, &ctx->internal->ex_data); + CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ctx, &ctx->ex_data); - lh_SSL_SESSION_free(ctx->internal->sessions); + lh_SSL_SESSION_free(ctx->sessions); X509_STORE_free(ctx->cert_store); sk_SSL_CIPHER_free(ctx->cipher_list); - sk_SSL_CIPHER_free(ctx->internal->cipher_list_tls13); - ssl_cert_free(ctx->internal->cert); - sk_X509_NAME_pop_free(ctx->internal->client_CA, X509_NAME_free); + sk_SSL_CIPHER_free(ctx->cipher_list_tls13); + ssl_cert_free(ctx->cert); + sk_X509_NAME_pop_free(ctx->client_CA, X509_NAME_free); sk_X509_pop_free(ctx->extra_certs, X509_free); #ifndef OPENSSL_NO_SRTP - if (ctx->internal->srtp_profiles) - sk_SRTP_PROTECTION_PROFILE_free(ctx->internal->srtp_profiles); + if (ctx->srtp_profiles) + sk_SRTP_PROTECTION_PROFILE_free(ctx->srtp_profiles); #endif #ifndef OPENSSL_NO_ENGINE - ENGINE_finish(ctx->internal->client_cert_engine); + ENGINE_finish(ctx->client_cert_engine); #endif - free(ctx->internal->tlsext_ecpointformatlist); - free(ctx->internal->tlsext_supportedgroups); + free(ctx->tlsext_ecpointformatlist); + free(ctx->tlsext_supportedgroups); - free(ctx->internal->alpn_client_proto_list); + free(ctx->alpn_client_proto_list); - free(ctx->internal); free(ctx); } @@ -2183,15 +2175,15 @@ void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *, void *), void *arg) { - ctx->internal->app_verify_callback = cb; - ctx->internal->app_verify_arg = arg; + ctx->app_verify_callback = cb; + ctx->app_verify_arg = arg; } void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, int (*cb)(int, X509_STORE_CTX *)) { ctx->verify_mode = mode; - ctx->internal->default_verify_callback = cb; + ctx->default_verify_callback = cb; } void @@ -2363,14 +2355,14 @@ ssl_should_update_external_cache(SSL *s, int mode) { int cache_mode; - cache_mode = s->session_ctx->internal->session_cache_mode; + cache_mode = s->session_ctx->session_cache_mode; /* Don't cache if mode says not to */ if ((cache_mode & mode) == 0) return 0; /* if it is not already cached, cache it */ - if (!s->internal->hit) + if (!s->hit) return 1; /* If it's TLS 1.3, do it to match OpenSSL */ @@ -2385,14 +2377,14 @@ ssl_should_update_internal_cache(SSL *s, int mode) { int cache_mode; - cache_mode = s->session_ctx->internal->session_cache_mode; + cache_mode = s->session_ctx->session_cache_mode; /* Don't cache if mode says not to */ if ((cache_mode & mode) == 0) return 0; /* If it is already cached, don't cache it again */ - if (s->internal->hit) + if (s->hit) return 0; if ((cache_mode & SSL_SESS_CACHE_NO_INTERNAL_STORE) != 0) @@ -2415,11 +2407,11 @@ ssl_should_update_internal_cache(SSL *s, int mode) * to know about this even if it's a stateless ticket * from 1.3 so we can know when it is removed. */ - if (s->session_ctx->internal->remove_session_cb != NULL) + if (s->session_ctx->remove_session_cb != NULL) return 1; /* If we have set OP_NO_TICKET, cache it. */ - if ((s->internal->options & SSL_OP_NO_TICKET) != 0) + if ((s->options & SSL_OP_NO_TICKET) != 0) return 1; /* Otherwise do not cache */ @@ -2434,7 +2426,7 @@ ssl_update_cache(SSL *s, int mode) if (s->session->session_id_length == 0) return; - cache_mode = s->session_ctx->internal->session_cache_mode; + cache_mode = s->session_ctx->session_cache_mode; do_callback = ssl_should_update_external_cache(s, mode); if (ssl_should_update_internal_cache(s, mode)) { @@ -2455,9 +2447,9 @@ ssl_update_cache(SSL *s, int mode) * same glorious experience they expect from OpenSSL which * does it this way. */ - if (do_callback && s->session_ctx->internal->new_session_cb != NULL) { + if (do_callback && s->session_ctx->new_session_cb != NULL) { CRYPTO_add(&s->session->references, 1, CRYPTO_LOCK_SSL_SESSION); - if (!s->session_ctx->internal->new_session_cb(s, s->session)) + if (!s->session_ctx->new_session_cb(s, s->session)) SSL_SESSION_free(s->session); } @@ -2466,9 +2458,9 @@ ssl_update_cache(SSL *s, int mode) (cache_mode & mode) != 0) { int connections; if (mode & SSL_SESS_CACHE_CLIENT) - connections = s->session_ctx->internal->stats.sess_connect_good; + connections = s->session_ctx->stats.sess_connect_good; else - connections = s->session_ctx->internal->stats.sess_accept_good; + connections = s->session_ctx->stats.sess_accept_good; if ((connections & 0xff) == 0xff) SSL_CTX_flush_sessions(s->session_ctx, time(NULL)); } @@ -2489,9 +2481,9 @@ SSL_set_ssl_method(SSL *s, const SSL_METHOD *method) if (s->method == method) return (ret); - if (s->internal->handshake_func == s->method->ssl_connect) + if (s->handshake_func == s->method->ssl_connect) handshake_func = method->ssl_connect; - else if (s->internal->handshake_func == s->method->ssl_accept) + else if (s->handshake_func == s->method->ssl_accept) handshake_func = method->ssl_accept; if (s->method->version == method->version) { @@ -2501,7 +2493,7 @@ SSL_set_ssl_method(SSL *s, const SSL_METHOD *method) s->method = method; ret = s->method->ssl_new(s); } - s->internal->handshake_func = handshake_func; + s->handshake_func = handshake_func; return (ret); } @@ -2537,7 +2529,7 @@ SSL_get_error(const SSL *s, int i) * try to write to the rbio, and an application * program where rbio and wbio are separate couldn't * even know what it should wait for. However if we - * ever set s->internal->rwstate incorrectly (so that we have + * ever set s->rwstate incorrectly (so that we have * SSL_want_read(s) instead of SSL_want_write(s)) * and rbio and wbio *are* the same, this test works * around that bug; so it might be safer to keep it. @@ -2578,7 +2570,7 @@ SSL_get_error(const SSL *s, int i) if (SSL_want_x509_lookup(s)) return (SSL_ERROR_WANT_X509_LOOKUP); - if ((s->internal->shutdown & SSL_RECEIVED_SHUTDOWN) && + if ((s->shutdown & SSL_RECEIVED_SHUTDOWN) && (s->s3->warn_alert == SSL_AD_CLOSE_NOTIFY)) return (SSL_ERROR_ZERO_RETURN); @@ -2631,15 +2623,15 @@ SSL_quic_max_handshake_flight_len(const SSL *ssl, * to request client certificates. */ if ((SSL_get_verify_mode(ssl) & SSL_VERIFY_PEER) != 0 && - ssl->internal->max_cert_list > flight_len) - flight_len = ssl->internal->max_cert_list; + ssl->max_cert_list > flight_len) + flight_len = ssl->max_cert_list; } else { /* * Clients may receive both Certificate message and a * CertificateRequest message. */ - if (ssl->internal->max_cert_list * 2 > flight_len) - flight_len = ssl->internal->max_cert_list * 2; + if (ssl->max_cert_list * 2 > flight_len) + flight_len = ssl->max_cert_list * 2; } return flight_len; case ssl_encryption_application: @@ -2709,7 +2701,7 @@ SSL_process_quic_post_handshake(SSL *ssl) int SSL_do_handshake(SSL *s) { - if (s->internal->handshake_func == NULL) { + if (s->handshake_func == NULL) { SSLerror(s, SSL_R_CONNECTION_TYPE_NOT_SET); return (-1); } @@ -2719,7 +2711,7 @@ SSL_do_handshake(SSL *s) if (!SSL_in_init(s) && !SSL_in_before(s)) return 1; - return s->internal->handshake_func(s); + return s->handshake_func(s); } /* @@ -2730,9 +2722,9 @@ void SSL_set_accept_state(SSL *s) { s->server = 1; - s->internal->shutdown = 0; + s->shutdown = 0; s->s3->hs.state = SSL_ST_ACCEPT|SSL_ST_BEFORE; - s->internal->handshake_func = s->method->ssl_accept; + s->handshake_func = s->method->ssl_accept; ssl_clear_cipher_state(s); } @@ -2740,9 +2732,9 @@ void SSL_set_connect_state(SSL *s) { s->server = 0; - s->internal->shutdown = 0; + s->shutdown = 0; s->s3->hs.state = SSL_ST_CONNECT|SSL_ST_BEFORE; - s->internal->handshake_func = s->method->ssl_connect; + s->handshake_func = s->method->ssl_connect; ssl_clear_cipher_state(s); } @@ -2832,24 +2824,24 @@ SSL_dup(SSL *s) goto err; } - ret->internal->options = s->internal->options; - ret->internal->mode = s->internal->mode; + ret->options = s->options; + ret->mode = s->mode; SSL_set_max_cert_list(ret, SSL_get_max_cert_list(s)); SSL_set_read_ahead(ret, SSL_get_read_ahead(s)); - ret->internal->msg_callback = s->internal->msg_callback; - ret->internal->msg_callback_arg = s->internal->msg_callback_arg; + ret->msg_callback = s->msg_callback; + ret->msg_callback_arg = s->msg_callback_arg; SSL_set_verify(ret, SSL_get_verify_mode(s), SSL_get_verify_callback(s)); SSL_set_verify_depth(ret, SSL_get_verify_depth(s)); - ret->internal->generate_session_id = s->internal->generate_session_id; + ret->generate_session_id = s->generate_session_id; SSL_set_info_callback(ret, SSL_get_info_callback(s)); - ret->internal->debug = s->internal->debug; + ret->debug = s->debug; /* copy app data, a little dangerous perhaps */ if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_SSL, - &ret->internal->ex_data, &s->internal->ex_data)) + &ret->ex_data, &s->ex_data)) goto err; /* setup rbio, and wbio */ @@ -2864,25 +2856,25 @@ SSL_dup(SSL *s) } else ret->wbio = ret->rbio; } - ret->internal->rwstate = s->internal->rwstate; - ret->internal->in_handshake = s->internal->in_handshake; - ret->internal->handshake_func = s->internal->handshake_func; + ret->rwstate = s->rwstate; + ret->in_handshake = s->in_handshake; + ret->handshake_func = s->handshake_func; ret->server = s->server; - ret->internal->renegotiate = s->internal->renegotiate; - ret->internal->new_session = s->internal->new_session; - ret->internal->quiet_shutdown = s->internal->quiet_shutdown; - ret->internal->shutdown = s->internal->shutdown; + ret->renegotiate = s->renegotiate; + ret->new_session = s->new_session; + ret->quiet_shutdown = s->quiet_shutdown; + ret->shutdown = s->shutdown; /* SSL_dup does not really work at any state, though */ ret->s3->hs.state = s->s3->hs.state; - ret->internal->rstate = s->internal->rstate; + ret->rstate = s->rstate; /* * Would have to copy ret->init_buf, ret->init_msg, ret->init_num, * ret->init_off */ - ret->internal->init_num = 0; + ret->init_num = 0; - ret->internal->hit = s->internal->hit; + ret->hit = s->hit; X509_VERIFY_PARAM_inherit(ret->param, s->param); @@ -2891,16 +2883,16 @@ SSL_dup(SSL *s) sk_SSL_CIPHER_dup(s->cipher_list)) == NULL) goto err; } - if (s->internal->cipher_list_tls13 != NULL) { - if ((ret->internal->cipher_list_tls13 = - sk_SSL_CIPHER_dup(s->internal->cipher_list_tls13)) == NULL) + if (s->cipher_list_tls13 != NULL) { + if ((ret->cipher_list_tls13 = + sk_SSL_CIPHER_dup(s->cipher_list_tls13)) == NULL) goto err; } /* Dup the client_CA list */ - if (s->internal->client_CA != NULL) { - if ((sk = sk_X509_NAME_dup(s->internal->client_CA)) == NULL) goto err; - ret->internal->client_CA = sk; + if (s->client_CA != NULL) { + if ((sk = sk_X509_NAME_dup(s->client_CA)) == NULL) goto err; + ret->client_CA = sk; for (i = 0; i < sk_X509_NAME_num(sk); i++) { xn = sk_X509_NAME_value(sk, i); if (sk_X509_NAME_set(sk, i, @@ -2920,8 +2912,8 @@ SSL_dup(SSL *s) void ssl_clear_cipher_state(SSL *s) { - tls12_record_layer_clear_read_state(s->internal->rl); - tls12_record_layer_clear_write_state(s->internal->rl); + tls12_record_layer_clear_read_state(s->rl); + tls12_record_layer_clear_write_state(s->rl); } void @@ -2929,8 +2921,8 @@ ssl_info_callback(const SSL *s, int type, int value) { ssl_info_callback_fn *cb; - if ((cb = s->internal->info_callback) == NULL) - cb = s->ctx->internal->info_callback; + if ((cb = s->info_callback) == NULL) + cb = s->ctx->info_callback; if (cb != NULL) cb(s, type, value); } @@ -2939,11 +2931,11 @@ void ssl_msg_callback(SSL *s, int is_write, int content_type, const void *msg_buf, size_t msg_len) { - if (s->internal->msg_callback == NULL) + if (s->msg_callback == NULL) return; - s->internal->msg_callback(is_write, s->version, content_type, - msg_buf, msg_len, s, s->internal->msg_callback_arg); + s->msg_callback(is_write, s->version, content_type, + msg_buf, msg_len, s, s->msg_callback_arg); } void @@ -3068,37 +3060,37 @@ ssl_free_wbio_buffer(SSL *s) void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode) { - ctx->internal->quiet_shutdown = mode; + ctx->quiet_shutdown = mode; } int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx) { - return (ctx->internal->quiet_shutdown); + return (ctx->quiet_shutdown); } void SSL_set_quiet_shutdown(SSL *s, int mode) { - s->internal->quiet_shutdown = mode; + s->quiet_shutdown = mode; } int SSL_get_quiet_shutdown(const SSL *s) { - return (s->internal->quiet_shutdown); + return (s->quiet_shutdown); } void SSL_set_shutdown(SSL *s, int mode) { - s->internal->shutdown = mode; + s->shutdown = mode; } int SSL_get_shutdown(const SSL *s) { - return (s->internal->shutdown); + return (s->shutdown); } int @@ -3123,7 +3115,7 @@ SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx) if (ssl->ctx == ctx) return (ssl->ctx); - if ((new_cert = ssl_cert_dup(ctx->internal->cert)) == NULL) + if ((new_cert = ssl_cert_dup(ctx->cert)) == NULL) return NULL; ssl_cert_free(ssl->cert); ssl->cert = new_cert; @@ -3157,12 +3149,12 @@ SSL_CTX_load_verify_mem(SSL_CTX *ctx, void *buf, int len) void SSL_set_info_callback(SSL *ssl, void (*cb)(const SSL *ssl, int type, int val)) { - ssl->internal->info_callback = cb; + ssl->info_callback = cb; } void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl, int type, int val) { - return (ssl->internal->info_callback); + return (ssl->info_callback); } int @@ -3218,13 +3210,13 @@ SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, int SSL_set_ex_data(SSL *s, int idx, void *arg) { - return (CRYPTO_set_ex_data(&s->internal->ex_data, idx, arg)); + return (CRYPTO_set_ex_data(&s->ex_data, idx, arg)); } void * SSL_get_ex_data(const SSL *s, int idx) { - return (CRYPTO_get_ex_data(&s->internal->ex_data, idx)); + return (CRYPTO_get_ex_data(&s->ex_data, idx)); } int @@ -3238,13 +3230,13 @@ SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, int SSL_CTX_set_ex_data(SSL_CTX *s, int idx, void *arg) { - return (CRYPTO_set_ex_data(&s->internal->ex_data, idx, arg)); + return (CRYPTO_set_ex_data(&s->ex_data, idx, arg)); } void * SSL_CTX_get_ex_data(const SSL_CTX *s, int idx) { - return (CRYPTO_get_ex_data(&s->internal->ex_data, idx)); + return (CRYPTO_get_ex_data(&s->ex_data, idx)); } int @@ -3269,25 +3261,25 @@ SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store) X509 * SSL_CTX_get0_certificate(const SSL_CTX *ctx) { - if (ctx->internal->cert == NULL) + if (ctx->cert == NULL) return NULL; - return ctx->internal->cert->key->x509; + return ctx->cert->key->x509; } EVP_PKEY * SSL_CTX_get0_privatekey(const SSL_CTX *ctx) { - if (ctx->internal->cert == NULL) + if (ctx->cert == NULL) return NULL; - return ctx->internal->cert->key->privatekey; + return ctx->cert->key->privatekey; } int SSL_want(const SSL *s) { - return (s->internal->rwstate); + return (s->rwstate); } void @@ -3352,68 +3344,68 @@ SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, void SSL_set_debug(SSL *s, int debug) { - s->internal->debug = debug; + s->debug = debug; } int SSL_cache_hit(SSL *s) { - return (s->internal->hit); + return (s->hit); } int SSL_CTX_get_min_proto_version(SSL_CTX *ctx) { - return ctx->internal->min_proto_version; + return ctx->min_proto_version; } int SSL_CTX_set_min_proto_version(SSL_CTX *ctx, uint16_t version) { return ssl_version_set_min(ctx->method, version, - ctx->internal->max_tls_version, &ctx->internal->min_tls_version, - &ctx->internal->min_proto_version); + ctx->max_tls_version, &ctx->min_tls_version, + &ctx->min_proto_version); } int SSL_CTX_get_max_proto_version(SSL_CTX *ctx) { - return ctx->internal->max_proto_version; + return ctx->max_proto_version; } int SSL_CTX_set_max_proto_version(SSL_CTX *ctx, uint16_t version) { return ssl_version_set_max(ctx->method, version, - ctx->internal->min_tls_version, &ctx->internal->max_tls_version, - &ctx->internal->max_proto_version); + ctx->min_tls_version, &ctx->max_tls_version, + &ctx->max_proto_version); } int SSL_get_min_proto_version(SSL *ssl) { - return ssl->internal->min_proto_version; + return ssl->min_proto_version; } int SSL_set_min_proto_version(SSL *ssl, uint16_t version) { return ssl_version_set_min(ssl->method, version, - ssl->internal->max_tls_version, &ssl->internal->min_tls_version, - &ssl->internal->min_proto_version); + ssl->max_tls_version, &ssl->min_tls_version, + &ssl->min_proto_version); } int SSL_get_max_proto_version(SSL *ssl) { - return ssl->internal->max_proto_version; + return ssl->max_proto_version; } int SSL_set_max_proto_version(SSL *ssl, uint16_t version) { return ssl_version_set_max(ssl->method, version, - ssl->internal->min_tls_version, &ssl->internal->max_tls_version, - &ssl->internal->max_proto_version); + ssl->min_tls_version, &ssl->max_tls_version, + &ssl->max_proto_version); } const SSL_METHOD * @@ -3425,13 +3417,13 @@ SSL_CTX_get_ssl_method(const SSL_CTX *ctx) int SSL_CTX_get_security_level(const SSL_CTX *ctx) { - return ctx->internal->cert->security_level; + return ctx->cert->security_level; } void SSL_CTX_set_security_level(SSL_CTX *ctx, int level) { - ctx->internal->cert->security_level = level; + ctx->cert->security_level = level; } int @@ -3456,16 +3448,16 @@ int SSL_set_quic_transport_params(SSL *ssl, const uint8_t *params, size_t params_len) { - freezero(ssl->internal->quic_transport_params, - ssl->internal->quic_transport_params_len); - ssl->internal->quic_transport_params = NULL; - ssl->internal->quic_transport_params_len = 0; + freezero(ssl->quic_transport_params, + ssl->quic_transport_params_len); + ssl->quic_transport_params = NULL; + ssl->quic_transport_params_len = 0; - if ((ssl->internal->quic_transport_params = malloc(params_len)) == NULL) + if ((ssl->quic_transport_params = malloc(params_len)) == NULL) return 0; - memcpy(ssl->internal->quic_transport_params, params, params_len); - ssl->internal->quic_transport_params_len = params_len; + memcpy(ssl->quic_transport_params, params, params_len); + ssl->quic_transport_params_len = params_len; return 1; } diff --git a/ssl/ssl_locl.h b/ssl/ssl_local.h similarity index 96% rename from ssl/ssl_locl.h rename to ssl/ssl_local.h index a6fc6eaa..d510f80d 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_locl.h,v 1.425 2022/09/10 15:29:33 jsing Exp $ */ +/* $OpenBSD: ssl_local.h,v 1.3 2022/12/26 07:31:44 jmc Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -162,6 +162,7 @@ #include #include "bytestring.h" +#include "tls_content.h" #include "tls13_internal.h" __BEGIN_HIDDEN_DECLS @@ -502,10 +503,12 @@ struct ssl_session_st { char *tlsext_hostname; - /* RFC4507 info */ + /* Session resumption - RFC 5077 and RFC 8446. */ unsigned char *tlsext_tick; /* Session ticket */ size_t tlsext_ticklen; /* Session ticket length */ uint32_t tlsext_tick_lifetime_hint; /* Session lifetime hint in seconds */ + uint32_t tlsext_tick_age_add; /* TLSv1.3 ticket age obfuscation (in ms) */ + struct tls13_secret resumption_master_secret; CRYPTO_EX_DATA ex_data; /* application specific data */ @@ -704,7 +707,7 @@ int tls12_record_layer_change_read_cipher_state(struct tls12_record_layer *rl, int tls12_record_layer_change_write_cipher_state(struct tls12_record_layer *rl, CBS *mac_key, CBS *key, CBS *iv); int tls12_record_layer_open_record(struct tls12_record_layer *rl, - uint8_t *buf, size_t buf_len, uint8_t **out, size_t *out_len); + uint8_t *buf, size_t buf_len, struct tls_content *out); int tls12_record_layer_seal_record(struct tls12_record_layer *rl, uint8_t content_type, const uint8_t *content, size_t content_len, CBB *out); @@ -713,7 +716,42 @@ typedef void (ssl_info_callback_fn)(const SSL *s, int type, int val); typedef void (ssl_msg_callback_fn)(int is_write, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); -typedef struct ssl_ctx_internal_st { +struct ssl_ctx_st { + const SSL_METHOD *method; + const SSL_QUIC_METHOD *quic_method; + + STACK_OF(SSL_CIPHER) *cipher_list; + + struct x509_store_st /* X509_STORE */ *cert_store; + + /* If timeout is not 0, it is the default timeout value set + * when SSL_new() is called. This has been put in to make + * life easier to set things up */ + long session_timeout; + + int references; + + /* Default values to use in SSL structures follow (these are copied by SSL_new) */ + + STACK_OF(X509) *extra_certs; + + int verify_mode; + size_t sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + + X509_VERIFY_PARAM *param; + + /* + * XXX + * default_passwd_cb used by python and openvpn, need to keep it until we + * add an accessor + */ + /* Default password callback. */ + pem_password_cb *default_passwd_callback; + + /* Default password callback user data. */ + void *default_passwd_callback_userdata; + uint16_t min_tls_version; uint16_t max_tls_version; @@ -879,48 +917,72 @@ typedef struct ssl_ctx_internal_st { uint16_t *tlsext_supportedgroups; /* our list */ SSL_CTX_keylog_cb_func keylog_callback; /* Unused. For OpenSSL compatibility. */ size_t num_tickets; /* Unused, for OpenSSL compatibility */ -} SSL_CTX_INTERNAL; +}; + +struct ssl_st { + /* protocol version + * (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, DTLS1_VERSION) + */ + int version; -struct ssl_ctx_st { const SSL_METHOD *method; const SSL_QUIC_METHOD *quic_method; - STACK_OF(SSL_CIPHER) *cipher_list; + /* There are 2 BIO's even though they are normally both the + * same. This is so data can be read and written to different + * handlers */ - struct x509_store_st /* X509_STORE */ *cert_store; + BIO *rbio; /* used by SSL_read */ + BIO *wbio; /* used by SSL_write */ + BIO *bbio; /* used during session-id reuse to concatenate + * messages */ + int server; /* are we the server side? - mostly used by SSL_clear*/ - /* If timeout is not 0, it is the default timeout value set - * when SSL_new() is called. This has been put in to make - * life easier to set things up */ - long session_timeout; + struct ssl3_state_st *s3; /* SSLv3 variables */ + struct dtls1_state_st *d1; /* DTLSv1 variables */ - int references; + X509_VERIFY_PARAM *param; - /* Default values to use in SSL structures follow (these are copied by SSL_new) */ + /* crypto */ + STACK_OF(SSL_CIPHER) *cipher_list; - STACK_OF(X509) *extra_certs; + /* This is used to hold the server certificate used */ + SSL_CERT *cert; - int verify_mode; + /* the session_id_context is used to ensure sessions are only reused + * in the appropriate context */ size_t sid_ctx_length; unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; - X509_VERIFY_PARAM *param; + /* This can also be in the session once a session is established */ + SSL_SESSION *session; - /* - * XXX - * default_passwd_cb used by python and openvpn, need to keep it until we - * add an accessor - */ - /* Default password callback. */ - pem_password_cb *default_passwd_callback; + /* Used in SSL2 and SSL3 */ + int verify_mode; /* 0 don't care about verify failure. + * 1 fail if verify fails */ + int error; /* error bytes to be written */ + int error_code; /* actual code */ - /* Default password callback user data. */ - void *default_passwd_callback_userdata; + SSL_CTX *ctx; - struct ssl_ctx_internal_st *internal; -}; + long verify_result; + + int references; + + int client_version; /* what was passed, used for + * SSLv3/TLS rollback check */ + + unsigned int max_send_fragment; + + char *tlsext_hostname; + + /* certificate status request info */ + /* Status type or -1 if no status type */ + int tlsext_status_type; + + SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */ +#define session_ctx initial_ctx -typedef struct ssl_internal_st { struct tls13_ctx *tls13; uint16_t min_tls_version; @@ -1025,7 +1087,7 @@ typedef struct ssl_internal_st { STACK_OF(X509_NAME) *client_CA; /* set this flag to 1 and a sleep(1) is put into all SSL_read() - * and SSL_write() calls, good for nbio debuging :-) */ + * and SSL_write() calls, good for nbio debugging :-) */ int debug; long max_cert_list; int first_packet; @@ -1066,73 +1128,6 @@ typedef struct ssl_internal_st { size_t num_tickets; /* Unused, for OpenSSL compatibility */ STACK_OF(X509) *verified_chain; -} SSL_INTERNAL; - -struct ssl_st { - /* protocol version - * (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, DTLS1_VERSION) - */ - int version; - - const SSL_METHOD *method; - const SSL_QUIC_METHOD *quic_method; - - /* There are 2 BIO's even though they are normally both the - * same. This is so data can be read and written to different - * handlers */ - - BIO *rbio; /* used by SSL_read */ - BIO *wbio; /* used by SSL_write */ - BIO *bbio; /* used during session-id reuse to concatenate - * messages */ - int server; /* are we the server side? - mostly used by SSL_clear*/ - - struct ssl3_state_st *s3; /* SSLv3 variables */ - struct dtls1_state_st *d1; /* DTLSv1 variables */ - - X509_VERIFY_PARAM *param; - - /* crypto */ - STACK_OF(SSL_CIPHER) *cipher_list; - - /* This is used to hold the server certificate used */ - SSL_CERT *cert; - - /* the session_id_context is used to ensure sessions are only reused - * in the appropriate context */ - size_t sid_ctx_length; - unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; - - /* This can also be in the session once a session is established */ - SSL_SESSION *session; - - /* Used in SSL2 and SSL3 */ - int verify_mode; /* 0 don't care about verify failure. - * 1 fail if verify fails */ - int error; /* error bytes to be written */ - int error_code; /* actual code */ - - SSL_CTX *ctx; - - long verify_result; - - int references; - - int client_version; /* what was passed, used for - * SSLv3/TLS rollback check */ - - unsigned int max_send_fragment; - - char *tlsext_hostname; - - /* certificate status request info */ - /* Status type or -1 if no status type */ - int tlsext_status_type; - - SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */ -#define session_ctx initial_ctx - - struct ssl_internal_st *internal; }; typedef struct ssl3_record_internal_st { @@ -1163,6 +1158,10 @@ typedef struct ssl3_state_st { SSL3_BUFFER_INTERNAL rbuf; /* read IO goes into here */ SSL3_BUFFER_INTERNAL wbuf; /* write IO goes into here */ + SSL3_RECORD_INTERNAL rrec; /* each decoded record goes in here */ + + struct tls_content *rcontent; /* Content from opened TLS records. */ + /* we allow one fatal and one warning alert to be outstanding, * send close alert via the warning alert */ int alert_dispatch; @@ -1172,14 +1171,9 @@ typedef struct ssl3_state_st { int need_empty_fragments; int empty_fragment_done; - SSL3_RECORD_INTERNAL rrec; /* each decoded record goes in here */ - - /* storage for Alert/Handshake protocol data received but not - * yet processed by ssl3_read_bytes: */ - unsigned char alert_fragment[2]; - unsigned int alert_fragment_len; - unsigned char handshake_fragment[4]; - unsigned int handshake_fragment_len; + /* Unprocessed Alert/Handshake protocol data. */ + struct tls_buffer *alert_fragment; + struct tls_buffer *handshake_fragment; /* partial write - check the numbers match */ unsigned int wnum; /* number of bytes sent so far */ @@ -1319,6 +1313,7 @@ int ssl_security_cert_chain(const SSL *ssl, STACK_OF(X509) *sk, int ssl_security_shared_group(const SSL *ssl, uint16_t group_id); int ssl_security_supported_group(const SSL *ssl, uint16_t group_id); +SSL_SESSION *ssl_session_dup(SSL_SESSION *src, int include_ticket); int ssl_get_new_session(SSL *s, int session); int ssl_get_prev_session(SSL *s, CBS *session_id, CBS *ext_block, int *alert); @@ -1357,16 +1352,10 @@ int ssl_verify_alarm_type(long type); int SSL_SESSION_ticket(SSL_SESSION *ss, unsigned char **out, size_t *out_len); const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); -int ssl3_send_server_certificate(SSL *s); -int ssl3_send_newsession_ticket(SSL *s); -int ssl3_send_cert_status(SSL *s); -int ssl3_get_finished(SSL *s, int state_a, int state_b); -int ssl3_send_change_cipher_spec(SSL *s, int state_a, int state_b); int ssl3_do_write(SSL *s, int type); int ssl3_send_alert(SSL *s, int level, int desc); int ssl3_get_req_cert_types(SSL *s, CBB *cbb); int ssl3_get_message(SSL *s, int st1, int stn, int mt, long max); -int ssl3_send_finished(SSL *s, int state_a, int state_b); int ssl3_num_ciphers(void); const SSL_CIPHER *ssl3_get_cipher(unsigned int u); const SSL_CIPHER *ssl3_get_cipher_by_id(unsigned int id); @@ -1424,35 +1413,6 @@ int ssl_server_legacy_first_packet(SSL *s); int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len); -/* some client-only functions */ -int ssl3_send_client_hello(SSL *s); -int ssl3_get_dtls_hello_verify(SSL *s); -int ssl3_get_server_hello(SSL *s); -int ssl3_get_certificate_request(SSL *s); -int ssl3_get_new_session_ticket(SSL *s); -int ssl3_get_cert_status(SSL *s); -int ssl3_get_server_done(SSL *s); -int ssl3_send_client_verify(SSL *s); -int ssl3_send_client_certificate(SSL *s); -int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey); -int ssl3_send_client_key_exchange(SSL *s); -int ssl3_get_server_key_exchange(SSL *s); -int ssl3_get_server_certificate(SSL *s); -int ssl3_check_cert_and_algorithm(SSL *s); -int ssl3_check_finished(SSL *s); - -/* some server-only functions */ -int ssl3_get_client_hello(SSL *s); -int ssl3_send_dtls_hello_verify_request(SSL *s); -int ssl3_send_server_hello(SSL *s); -int ssl3_send_hello_request(SSL *s); -int ssl3_send_server_key_exchange(SSL *s); -int ssl3_send_certificate_request(SSL *s); -int ssl3_send_server_done(SSL *s); -int ssl3_get_client_certificate(SSL *s); -int ssl3_get_client_key_exchange(SSL *s); -int ssl3_get_cert_verify(SSL *s); - int ssl_kex_generate_dhe(DH *dh, DH *dh_params); int ssl_kex_generate_dhe_params_auto(DH *dh, size_t key_len); int ssl_kex_params_dhe(DH *dh, CBB *cbb); @@ -1503,9 +1463,6 @@ int tls1_change_read_cipher_state(SSL *s); int tls1_change_write_cipher_state(SSL *s); int tls1_setup_key_block(SSL *s); int tls1_generate_key_block(SSL *s, uint8_t *key_block, size_t key_block_len); -int tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen, - const char *label, size_t llen, const unsigned char *p, size_t plen, - int use_context); int ssl_ok(SSL *s); int tls12_derive_finished(SSL *s); @@ -1578,4 +1535,4 @@ int tls_process_peer_certs(SSL *s, STACK_OF(X509) *peer_certs); __END_HIDDEN_DECLS -#endif +#endif /* !HEADER_SSL_LOCL_H */ diff --git a/ssl/ssl_methods.c b/ssl/ssl_methods.c index d8ffbb7b..dac28011 100644 --- a/ssl/ssl_methods.c +++ b/ssl/ssl_methods.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_methods.c,v 1.28 2021/07/26 03:17:38 jsing Exp $ */ +/* $OpenBSD: ssl_methods.c,v 1.29 2022/11/26 16:08:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,8 +56,8 @@ * [including the GNU Public Licence.] */ -#include "dtls_locl.h" -#include "ssl_locl.h" +#include "dtls_local.h" +#include "ssl_local.h" #include "tls13_internal.h" static const SSL_METHOD DTLS_method_data = { diff --git a/ssl/ssl_packet.c b/ssl/ssl_packet.c index 091685b2..70017b46 100644 --- a/ssl/ssl_packet.c +++ b/ssl/ssl_packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_packet.c,v 1.13 2022/02/05 14:54:10 jsing Exp $ */ +/* $OpenBSD: ssl_packet.c,v 1.15 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2016, 2017 Joel Sing * @@ -16,7 +16,7 @@ */ #include "bytestring.h" -#include "ssl_locl.h" +#include "ssl_local.h" static int ssl_is_sslv2_client_hello(CBS *header) @@ -84,7 +84,7 @@ ssl_convert_sslv2_client_hello(SSL *s) memset(&cbb, 0, sizeof(cbb)); - CBS_init(&cbs, s->internal->packet, SSL3_RT_HEADER_LENGTH); + CBS_init(&cbs, s->packet, SSL3_RT_HEADER_LENGTH); if (!CBS_get_u16(&cbs, &record_length) || !CBS_get_u8(&cbs, &message_type) || @@ -119,17 +119,17 @@ ssl_convert_sslv2_client_hello(SSL *s) if (n != record_length + 2) return n; - tls1_transcript_record(s, s->internal->packet + 2, - s->internal->packet_length - 2); - s->internal->mac_packet = 0; + tls1_transcript_record(s, s->packet + 2, + s->packet_length - 2); + s->mac_packet = 0; - if (s->internal->msg_callback) - s->internal->msg_callback(0, SSL2_VERSION, 0, - s->internal->packet + 2, s->internal->packet_length - 2, s, - s->internal->msg_callback_arg); + if (s->msg_callback) + s->msg_callback(0, SSL2_VERSION, 0, + s->packet + 2, s->packet_length - 2, s, + s->msg_callback_arg); /* Decode the SSLv2 record containing the client hello. */ - CBS_init(&cbs, s->internal->packet, s->internal->packet_length); + CBS_init(&cbs, s->packet, s->packet_length); if (!CBS_get_u16(&cbs, &record_length)) return -1; @@ -212,9 +212,9 @@ ssl_convert_sslv2_client_hello(SSL *s) if (data_len > s->s3->rbuf.len) goto err; - s->internal->packet = s->s3->rbuf.buf; - s->internal->packet_length = data_len; - memcpy(s->internal->packet, data, data_len); + s->packet = s->s3->rbuf.buf; + s->packet_length = data_len; + memcpy(s->packet, data, data_len); ret = 1; err: @@ -240,7 +240,7 @@ ssl_server_legacy_first_packet(SSL *s) if (SSL_is_dtls(s)) return 1; - CBS_init(&header, s->internal->packet, SSL3_RT_HEADER_LENGTH); + CBS_init(&header, s->packet, SSL3_RT_HEADER_LENGTH); if (ssl_is_sslv3_handshake(&header) == 1) return 1; diff --git a/ssl/ssl_pkt.c b/ssl/ssl_pkt.c index d9f5a0d0..728ac141 100644 --- a/ssl/ssl_pkt.c +++ b/ssl/ssl_pkt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_pkt.c,v 1.60 2022/09/11 13:51:25 jsing Exp $ */ +/* $OpenBSD: ssl_pkt.c,v 1.65 2022/11/26 16:08:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -110,14 +110,16 @@ */ #include +#include #include #include #include #include "bytestring.h" -#include "dtls_locl.h" -#include "ssl_locl.h" +#include "dtls_local.h" +#include "ssl_local.h" +#include "tls_content.h" static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len); @@ -136,16 +138,16 @@ ssl_force_want_read(SSL *s) BIO_clear_retry_flags(bio); BIO_set_retry_read(bio); - s->internal->rwstate = SSL_READING; + s->rwstate = SSL_READING; } /* * If extend == 0, obtain new n-byte packet; if extend == 1, increase * packet by another n bytes. * The packet will be in the sub-array of s->s3->rbuf.buf specified - * by s->internal->packet and s->internal->packet_length. - * (If s->internal->read_ahead is set, 'max' bytes may be stored in rbuf - * [plus s->internal->packet_length bytes if extend == 1].) + * by s->packet and s->packet_length. + * (If s->read_ahead is set, 'max' bytes may be stored in rbuf + * [plus s->packet_length bytes if extend == 1].) */ static int ssl3_read_n(SSL *s, int n, int max, int extend) @@ -158,9 +160,12 @@ ssl3_read_n(SSL *s, int n, int max, int extend) if (n <= 0) return n; - if (rb->buf == NULL) + if (rb->buf == NULL) { if (!ssl3_setup_read_buffer(s)) return -1; + } + if (rb->buf == NULL) + return -1; left = rb->left; align = (size_t)rb->buf + SSL3_RT_HEADER_LENGTH; @@ -187,8 +192,8 @@ ssl3_read_n(SSL *s, int n, int max, int extend) rb->offset = align; } } - s->internal->packet = rb->buf + rb->offset; - s->internal->packet_length = 0; + s->packet = rb->buf + rb->offset; + s->packet_length = 0; /* ... now we can act as if 'extend' was set */ } @@ -202,7 +207,7 @@ ssl3_read_n(SSL *s, int n, int max, int extend) /* if there is enough in the buffer from a previous read, take some */ if (left >= n) { - s->internal->packet_length += n; + s->packet_length += n; rb->left = left - n; rb->offset += n; return (n); @@ -210,15 +215,15 @@ ssl3_read_n(SSL *s, int n, int max, int extend) /* else we need to read more data */ - len = s->internal->packet_length; + len = s->packet_length; pkt = rb->buf + align; /* Move any available bytes to front of buffer: * 'len' bytes already pointed to by 'packet', * 'left' extra ones at the end */ - if (s->internal->packet != pkt) { + if (s->packet != pkt) { /* len > 0 */ - memmove(pkt, s->internal->packet, len + left); - s->internal->packet = pkt; + memmove(pkt, s->packet, len + left); + s->packet = pkt; rb->offset = len + align; } @@ -228,7 +233,7 @@ ssl3_read_n(SSL *s, int n, int max, int extend) return -1; } - if (s->internal->read_ahead || SSL_is_dtls(s)) { + if (s->read_ahead || SSL_is_dtls(s)) { if (max < n) max = n; if (max > (int)(rb->len - rb->offset)) @@ -245,7 +250,7 @@ ssl3_read_n(SSL *s, int n, int max, int extend) errno = 0; if (s->rbio != NULL) { - s->internal->rwstate = SSL_READING; + s->rwstate = SSL_READING; i = BIO_read(s->rbio, pkt + len + left, max - left); } else { SSLerror(s, SSL_R_READ_BIO_NOT_SET); @@ -254,7 +259,7 @@ ssl3_read_n(SSL *s, int n, int max, int extend) if (i <= 0) { rb->left = left; - if (s->internal->mode & SSL_MODE_RELEASE_BUFFERS && + if (s->mode & SSL_MODE_RELEASE_BUFFERS && !SSL_is_dtls(s)) { if (len + left == 0) ssl3_release_read_buffer(s); @@ -277,8 +282,8 @@ ssl3_read_n(SSL *s, int n, int max, int extend) /* done reading, now the book-keeping */ rb->offset += n; rb->left = left - n; - s->internal->packet_length += n; - s->internal->rwstate = SSL_NOTHING; + s->packet_length += n; + s->rwstate = SSL_NOTHING; return (n); } @@ -291,8 +296,8 @@ ssl3_packet_read(SSL *s, int plen) n = ssl3_read_n(s, plen, s->s3->rbuf.len, 0); if (n <= 0) return n; - if (s->internal->packet_length < plen) - return s->internal->packet_length; + if (s->packet_length < plen) + return s->packet_length; return plen; } @@ -302,15 +307,15 @@ ssl3_packet_extend(SSL *s, int plen) { int rlen, n; - if (s->internal->packet_length >= plen) + if (s->packet_length >= plen) return plen; - rlen = plen - s->internal->packet_length; + rlen = plen - s->packet_length; n = ssl3_read_n(s, rlen, rlen, 1); if (n <= 0) return n; - if (s->internal->packet_length < plen) - return s->internal->packet_length; + if (s->packet_length < plen) + return s->packet_length; return plen; } @@ -319,9 +324,9 @@ ssl3_packet_extend(SSL *s, int plen) * It will return <= 0 if more data is needed, normally due to an error * or non-blocking IO. * When it finishes, one packet has been decoded and can be found in - * ssl->s3->internal->rrec.type - is the type of record - * ssl->s3->internal->rrec.data, - data - * ssl->s3->internal->rrec.length, - number of bytes + * ssl->s3->rrec.type - is the type of record + * ssl->s3->rrec.data, - data + * ssl->s3->rrec.length, - number of bytes */ /* used only by ssl3_read_bytes */ static int @@ -330,15 +335,13 @@ ssl3_get_record(SSL *s) SSL3_BUFFER_INTERNAL *rb = &(s->s3->rbuf); SSL3_RECORD_INTERNAL *rr = &(s->s3->rrec); uint8_t alert_desc; - uint8_t *out; - size_t out_len; int al, n; int ret = -1; again: /* check if we have the header */ - if ((s->internal->rstate != SSL_ST_READ_BODY) || - (s->internal->packet_length < SSL3_RT_HEADER_LENGTH)) { + if ((s->rstate != SSL_ST_READ_BODY) || + (s->packet_length < SSL3_RT_HEADER_LENGTH)) { CBS header; uint16_t len, ssl_version; uint8_t type; @@ -347,16 +350,16 @@ ssl3_get_record(SSL *s) if (n <= 0) return (n); - s->internal->mac_packet = 1; - s->internal->rstate = SSL_ST_READ_BODY; + s->mac_packet = 1; + s->rstate = SSL_ST_READ_BODY; - if (s->server && s->internal->first_packet) { + if (s->server && s->first_packet) { if ((ret = ssl_server_legacy_first_packet(s)) != 1) return (ret); ret = -1; } - CBS_init(&header, s->internal->packet, SSL3_RT_HEADER_LENGTH); + CBS_init(&header, s->packet, SSL3_RT_HEADER_LENGTH); /* Pull apart the header into the SSL3_RECORD_INTERNAL */ if (!CBS_get_u8(&header, &type) || @@ -370,9 +373,9 @@ ssl3_get_record(SSL *s) rr->length = len; /* Lets check version */ - if (!s->internal->first_packet && ssl_version != s->version) { + if (!s->first_packet && ssl_version != s->version) { if ((s->version & 0xFF00) == (ssl_version & 0xFF00) && - !tls12_record_layer_write_protected(s->internal->rl)) { + !tls12_record_layer_write_protected(s->rl)) { /* Send back error using their minor version number :-) */ s->version = ssl_version; } @@ -399,17 +402,17 @@ ssl3_get_record(SSL *s) if (n != SSL3_RT_HEADER_LENGTH + rr->length) return (n); - s->internal->rstate = SSL_ST_READ_HEADER; /* set state for later operations */ + s->rstate = SSL_ST_READ_HEADER; /* set state for later operations */ /* * A full record has now been read from the wire, which now needs * to be processed. */ - tls12_record_layer_set_version(s->internal->rl, s->version); + tls12_record_layer_set_version(s->rl, s->version); - if (!tls12_record_layer_open_record(s->internal->rl, s->internal->packet, - s->internal->packet_length, &out, &out_len)) { - tls12_record_layer_alert(s->internal->rl, &alert_desc); + if (!tls12_record_layer_open_record(s->rl, s->packet, s->packet_length, + s->s3->rcontent)) { + tls12_record_layer_alert(s->rl, &alert_desc); if (alert_desc == 0) goto err; @@ -423,14 +426,10 @@ ssl3_get_record(SSL *s) goto fatal_err; } - rr->data = out; - rr->length = out_len; - rr->off = 0; - /* we have pulled in a full packet so zero things */ - s->internal->packet_length = 0; + s->packet_length = 0; - if (rr->length == 0) { + if (tls_content_remaining(s->s3->rcontent) == 0) { /* * Zero-length fragments are only permitted for application * data, as per RFC 5246 section 6.2.1. @@ -441,23 +440,25 @@ ssl3_get_record(SSL *s) goto fatal_err; } + tls_content_clear(s->s3->rcontent); + /* * CBC countermeasures for known IV weaknesses can legitimately * insert a single empty record, so we allow ourselves to read * once past a single empty record without forcing want_read. */ - if (s->internal->empty_record_count++ > SSL_MAX_EMPTY_RECORDS) { + if (s->empty_record_count++ > SSL_MAX_EMPTY_RECORDS) { SSLerror(s, SSL_R_PEER_BEHAVING_BADLY); return -1; } - if (s->internal->empty_record_count > 1) { + if (s->empty_record_count > 1) { ssl_force_want_read(s); return -1; } goto again; } - s->internal->empty_record_count = 0; + s->empty_record_count = 0; return (1); @@ -482,12 +483,12 @@ ssl3_write_bytes(SSL *s, int type, const void *buf_, int len) return -1; } - s->internal->rwstate = SSL_NOTHING; + s->rwstate = SSL_NOTHING; tot = s->s3->wnum; s->s3->wnum = 0; - if (SSL_in_init(s) && !s->internal->in_handshake) { - i = s->internal->handshake_func(s); + if (SSL_in_init(s) && !s->in_handshake) { + i = s->handshake_func(s); if (i < 0) return (i); if (i == 0) { @@ -512,7 +513,7 @@ ssl3_write_bytes(SSL *s, int type, const void *buf_, int len) } if ((i == (int)n) || (type == SSL3_RT_APPLICATION_DATA && - (s->internal->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) { + (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) { /* * Next chunk of data should get another prepended * empty fragment in ciphersuites with known-IV @@ -573,7 +574,7 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) */ version = s->version; if (s->s3->hs.state == SSL3_ST_CW_CLNT_HELLO_B && - !s->internal->renegotiate && + !s->renegotiate && s->s3->hs.our_max_tls_version > TLS1_VERSION) version = TLS1_VERSION; @@ -582,7 +583,7 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) * (see http://www.openssl.org/~bodo/tls-cbc.txt). Note that this * is unnecessary for AEAD. */ - if (sess != NULL && tls12_record_layer_write_protected(s->internal->rl)) { + if (sess != NULL && tls12_record_layer_write_protected(s->rl)) { if (s->s3->need_empty_fragments && !s->s3->empty_fragment_done && type == SSL3_RT_APPLICATION_DATA) @@ -603,16 +604,16 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) if (!CBB_init_fixed(&cbb, wb->buf + align, wb->len - align)) goto err; - tls12_record_layer_set_version(s->internal->rl, version); + tls12_record_layer_set_version(s->rl, version); if (need_empty_fragment) { - if (!tls12_record_layer_seal_record(s->internal->rl, type, + if (!tls12_record_layer_seal_record(s->rl, type, buf, 0, &cbb)) goto err; s->s3->empty_fragment_done = 1; } - if (!tls12_record_layer_seal_record(s->internal->rl, type, buf, len, &cbb)) + if (!tls12_record_layer_seal_record(s->rl, type, buf, len, &cbb)) goto err; if (!CBB_finish(&cbb, NULL, &out_len)) @@ -647,7 +648,7 @@ ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len) /* XXXX */ if ((s->s3->wpend_tot > (int)len) || ((s->s3->wpend_buf != buf) && - !(s->internal->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)) || + !(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)) || (s->s3->wpend_type != type)) { SSLerror(s, SSL_R_BAD_WRITE_RETRY); return (-1); @@ -656,7 +657,7 @@ ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len) for (;;) { errno = 0; if (s->wbio != NULL) { - s->internal->rwstate = SSL_WRITING; + s->rwstate = SSL_WRITING; i = BIO_write(s->wbio, (char *)&(wb->buf[wb->offset]), (unsigned int)wb->left); } else { @@ -666,10 +667,10 @@ ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len) if (i == wb->left) { wb->left = 0; wb->offset += i; - if (s->internal->mode & SSL_MODE_RELEASE_BUFFERS && + if (s->mode & SSL_MODE_RELEASE_BUFFERS && !SSL_is_dtls(s)) ssl3_release_write_buffer(s); - s->internal->rwstate = SSL_NOTHING; + s->rwstate = SSL_NOTHING; return (s->s3->wpend_ret); } else if (i <= 0) { /* @@ -685,11 +686,21 @@ ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len) } } +static ssize_t +ssl3_read_cb(void *buf, size_t n, void *cb_arg) +{ + SSL *s = cb_arg; + + return tls_content_read(s->s3->rcontent, buf, n); +} + +#define SSL3_ALERT_LENGTH 2 + int ssl3_read_alert(SSL *s) { - SSL3_RECORD_INTERNAL *rr = &s->s3->rrec; uint8_t alert_level, alert_descr; + ssize_t ret; CBS cbs; /* @@ -699,13 +710,17 @@ ssl3_read_alert(SSL *s) * fragmented across multiple records, hence a full alert must be * available in the record. */ - while (rr->length > 0 && - s->s3->alert_fragment_len < sizeof(s->s3->alert_fragment)) { - s->s3->alert_fragment[s->s3->alert_fragment_len++] = - rr->data[rr->off++]; - rr->length--; + if (s->s3->alert_fragment == NULL) { + if ((s->s3->alert_fragment = tls_buffer_new(0)) == NULL) + return -1; + tls_buffer_set_capacity_limit(s->s3->alert_fragment, + SSL3_ALERT_LENGTH); } - if (s->s3->alert_fragment_len < sizeof(s->s3->alert_fragment)) { + ret = tls_buffer_extend(s->s3->alert_fragment, SSL3_ALERT_LENGTH, + ssl3_read_cb, s); + if (ret <= 0 && ret != TLS_IO_WANT_POLLIN) + return -1; + if (ret != SSL3_ALERT_LENGTH) { if (SSL_is_dtls(s)) { SSLerror(s, SSL_R_BAD_LENGTH); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); @@ -714,7 +729,8 @@ ssl3_read_alert(SSL *s) return 1; } - CBS_init(&cbs, s->s3->alert_fragment, sizeof(s->s3->alert_fragment)); + if (!tls_buffer_data(s->s3->alert_fragment, &cbs)) + return -1; ssl_msg_callback_cbs(s, 0, SSL3_RT_ALERT, &cbs); @@ -723,7 +739,8 @@ ssl3_read_alert(SSL *s) if (!CBS_get_u8(&cbs, &alert_descr)) return -1; - s->s3->alert_fragment_len = 0; + tls_buffer_free(s->s3->alert_fragment); + s->s3->alert_fragment = NULL; ssl_info_callback(s, SSL_CB_READ_ALERT, (alert_level << 8) | alert_descr); @@ -731,7 +748,7 @@ ssl3_read_alert(SSL *s) if (alert_level == SSL3_AL_WARNING) { s->s3->warn_alert = alert_descr; if (alert_descr == SSL_AD_CLOSE_NOTIFY) { - s->internal->shutdown |= SSL_RECEIVED_SHUTDOWN; + s->shutdown |= SSL_RECEIVED_SHUTDOWN; return 0; } /* We requested renegotiation and the peer rejected it. */ @@ -742,11 +759,11 @@ ssl3_read_alert(SSL *s) return -1; } } else if (alert_level == SSL3_AL_FATAL) { - s->internal->rwstate = SSL_NOTHING; + s->rwstate = SSL_NOTHING; s->s3->fatal_alert = alert_descr; SSLerror(s, SSL_AD_REASON_OFFSET + alert_descr); ERR_asprintf_error_data("SSL alert number %d", alert_descr); - s->internal->shutdown |= SSL_RECEIVED_SHUTDOWN; + s->shutdown |= SSL_RECEIVED_SHUTDOWN; SSL_CTX_remove_session(s->ctx, s->session); return 0; } else { @@ -761,21 +778,18 @@ ssl3_read_alert(SSL *s) int ssl3_read_change_cipher_spec(SSL *s) { - SSL3_RECORD_INTERNAL *rr = &s->s3->rrec; - const uint8_t ccs[] = { SSL3_MT_CCS }; - CBS cbs; + const uint8_t ccs[1] = { SSL3_MT_CCS }; /* * 'Change Cipher Spec' is just a single byte, so we know exactly what * the record payload has to look like. */ - CBS_init(&cbs, rr->data, rr->length); - if (rr->off != 0 || CBS_len(&cbs) != sizeof(ccs)) { + if (tls_content_remaining(s->s3->rcontent) != sizeof(ccs)) { SSLerror(s, SSL_R_BAD_CHANGE_CIPHER_SPEC); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_DECODE_ERROR); return -1; } - if (!CBS_mem_equal(&cbs, ccs, sizeof(ccs))) { + if (!tls_content_equal(s->s3->rcontent, ccs, sizeof(ccs))) { SSLerror(s, SSL_R_BAD_CHANGE_CIPHER_SPEC); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER); return -1; @@ -783,7 +797,8 @@ ssl3_read_change_cipher_spec(SSL *s) /* XDTLS: check that epoch is consistent */ - ssl_msg_callback_cbs(s, 0, SSL3_RT_CHANGE_CIPHER_SPEC, &cbs); + ssl_msg_callback_cbs(s, 0, SSL3_RT_CHANGE_CIPHER_SPEC, + tls_content_cbs(s->s3->rcontent)); /* Check that we have a cipher to change to. */ if (s->s3->hs.cipher == NULL) { @@ -800,7 +815,7 @@ ssl3_read_change_cipher_spec(SSL *s) * handshake messages are still missing, so just * drop it. */ - rr->length = 0; + tls_content_clear(s->s3->rcontent); return 1; } s->d1->change_cipher_spec_ok = 0; @@ -814,7 +829,7 @@ ssl3_read_change_cipher_spec(SSL *s) s->s3->flags &= ~SSL3_FLAGS_CCS_OK; } - rr->length = 0; + tls_content_clear(s->s3->rcontent); s->s3->change_cipher_spec = 1; if (!ssl3_do_change_cipher_spec(s)) @@ -826,9 +841,9 @@ ssl3_read_change_cipher_spec(SSL *s) static int ssl3_read_handshake_unexpected(SSL *s) { - SSL3_RECORD_INTERNAL *rr = &s->s3->rrec; uint32_t hs_msg_length; uint8_t hs_msg_type; + ssize_t ssret; CBS cbs; int ret; @@ -837,17 +852,20 @@ ssl3_read_handshake_unexpected(SSL *s) * header - this may be in the same record or fragmented across multiple * records. */ - while (rr->length > 0 && - s->s3->handshake_fragment_len < sizeof(s->s3->handshake_fragment)) { - s->s3->handshake_fragment[s->s3->handshake_fragment_len++] = - rr->data[rr->off++]; - rr->length--; + if (s->s3->handshake_fragment == NULL) { + if ((s->s3->handshake_fragment = tls_buffer_new(0)) == NULL) + return -1; + tls_buffer_set_capacity_limit(s->s3->handshake_fragment, + SSL3_HM_HEADER_LENGTH); } - - if (s->s3->handshake_fragment_len < sizeof(s->s3->handshake_fragment)) + ssret = tls_buffer_extend(s->s3->handshake_fragment, SSL3_HM_HEADER_LENGTH, + ssl3_read_cb, s); + if (ssret <= 0 && ssret != TLS_IO_WANT_POLLIN) + return -1; + if (ssret != SSL3_HM_HEADER_LENGTH) return 1; - if (s->internal->in_handshake) { + if (s->in_handshake) { SSLerror(s, ERR_R_INTERNAL_ERROR); return -1; } @@ -859,7 +877,8 @@ ssl3_read_handshake_unexpected(SSL *s) */ /* Parse handshake message header. */ - CBS_init(&cbs, s->s3->handshake_fragment, s->s3->handshake_fragment_len); + if (!tls_buffer_data(s->s3->handshake_fragment, &cbs)) + return -1; if (!CBS_get_u8(&cbs, &hs_msg_type)) return -1; if (!CBS_get_u24(&cbs, &hs_msg_length)) @@ -885,10 +904,12 @@ ssl3_read_handshake_unexpected(SSL *s) return -1; } - ssl_msg_callback(s, 0, SSL3_RT_HANDSHAKE, - s->s3->handshake_fragment, s->s3->handshake_fragment_len); + if (!tls_buffer_data(s->s3->handshake_fragment, &cbs)) + return -1; + ssl_msg_callback_cbs(s, 0, SSL3_RT_HANDSHAKE, &cbs); - s->s3->handshake_fragment_len = 0; + tls_buffer_free(s->s3->handshake_fragment); + s->s3->handshake_fragment = NULL; /* * It should be impossible to hit this, but keep the safety @@ -937,7 +958,7 @@ ssl3_read_handshake_unexpected(SSL *s) return -1; } - if ((s->internal->options & SSL_OP_NO_CLIENT_RENEGOTIATION) != 0) { + if ((s->options & SSL_OP_NO_CLIENT_RENEGOTIATION) != 0) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_NO_RENEGOTIATION); return -1; @@ -957,8 +978,8 @@ ssl3_read_handshake_unexpected(SSL *s) } s->s3->hs.state = SSL_ST_ACCEPT; - s->internal->renegotiate = 1; - s->internal->new_session = 1; + s->renegotiate = 1; + s->new_session = 1; } else { SSLerror(s, SSL_R_UNEXPECTED_MESSAGE); @@ -966,14 +987,14 @@ ssl3_read_handshake_unexpected(SSL *s) return -1; } - if ((ret = s->internal->handshake_func(s)) < 0) + if ((ret = s->handshake_func(s)) < 0) return ret; if (ret == 0) { SSLerror(s, SSL_R_SSL_HANDSHAKE_FAILURE); return -1; } - if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { + if (!(s->mode & SSL_MODE_AUTO_RETRY)) { if (s->s3->rbuf.left == 0) { ssl_force_want_read(s); return -1; @@ -1017,9 +1038,8 @@ ssl3_read_handshake_unexpected(SSL *s) int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) { - SSL3_RECORD_INTERNAL *rr; int rrcount = 0; - unsigned int n; + ssize_t ssret; int ret; if (s->s3->rbuf.buf == NULL) { @@ -1027,6 +1047,11 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) return -1; } + if (s->s3->rcontent == NULL) { + if ((s->s3->rcontent = tls_content_new()) == NULL) + return -1; + } + if (len < 0) { SSLerror(s, ERR_R_INTERNAL_ERROR); return -1; @@ -1042,28 +1067,25 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) return -1; } - if (type == SSL3_RT_HANDSHAKE && s->s3->handshake_fragment_len > 0) { - /* Partially satisfy request from fragment storage. */ - unsigned char *src = s->s3->handshake_fragment; - unsigned char *dst = buf; - unsigned int k; - - /* peek == 0 */ - n = 0; - while (len > 0 && s->s3->handshake_fragment_len > 0) { - *dst++ = *src++; - len--; - s->s3->handshake_fragment_len--; - n++; + if (type == SSL3_RT_HANDSHAKE && + s->s3->handshake_fragment != NULL && + tls_buffer_remaining(s->s3->handshake_fragment) > 0) { + ssize_t ssn; + + if ((ssn = tls_buffer_read(s->s3->handshake_fragment, buf, + len)) <= 0) + return -1; + + if (tls_buffer_remaining(s->s3->handshake_fragment) == 0) { + tls_buffer_free(s->s3->handshake_fragment); + s->s3->handshake_fragment = NULL; } - /* move any remaining fragment bytes: */ - for (k = 0; k < s->s3->handshake_fragment_len; k++) - s->s3->handshake_fragment[k] = *src++; - return n; + + return (int)ssn; } - if (SSL_in_init(s) && !s->internal->in_handshake) { - if ((ret = s->internal->handshake_func(s)) < 0) + if (SSL_in_init(s) && !s->in_handshake) { + if ((ret = s->handshake_func(s)) < 0) return ret; if (ret == 0) { SSLerror(s, SSL_R_SSL_HANDSHAKE_FAILURE); @@ -1085,18 +1107,17 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) return -1; } - s->internal->rwstate = SSL_NOTHING; - - rr = &s->s3->rrec; + s->rwstate = SSL_NOTHING; - if (rr->length == 0 || s->internal->rstate == SSL_ST_READ_BODY) { + if (tls_content_remaining(s->s3->rcontent) == 0) { if ((ret = ssl3_get_record(s)) <= 0) return ret; } /* We now have a packet which can be read and processed. */ - if (s->s3->change_cipher_spec && rr->type != SSL3_RT_HANDSHAKE) { + if (s->s3->change_cipher_spec && + tls_content_type(s->s3->rcontent) != SSL3_RT_HANDSHAKE) { SSLerror(s, SSL_R_DATA_BETWEEN_CCS_AND_FINISHED); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE); return -1; @@ -1106,20 +1127,21 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) * If the other end has shut down, throw anything we read away (even in * 'peek' mode). */ - if (s->internal->shutdown & SSL_RECEIVED_SHUTDOWN) { - s->internal->rwstate = SSL_NOTHING; - rr->length = 0; + if (s->shutdown & SSL_RECEIVED_SHUTDOWN) { + s->rwstate = SSL_NOTHING; + tls_content_clear(s->s3->rcontent); + s->s3->rrec.length = 0; return 0; } /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */ - if (type == rr->type) { + if (tls_content_type(s->s3->rcontent) == type) { /* * Make sure that we are not getting application data when we * are doing a handshake for the first time. */ if (SSL_in_init(s) && type == SSL3_RT_APPLICATION_DATA && - !tls12_record_layer_read_protected(s->internal->rl)) { + !tls12_record_layer_read_protected(s->rl)) { SSLerror(s, SSL_R_APP_DATA_IN_HANDSHAKE); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_UNEXPECTED_MESSAGE); @@ -1129,46 +1151,41 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) if (len <= 0) return len; - if ((unsigned int)len > rr->length) - n = rr->length; - else - n = (unsigned int)len; - - memcpy(buf, &rr->data[rr->off], n); - if (!peek) { - memset(&rr->data[rr->off], 0, n); - rr->length -= n; - rr->off += n; - if (rr->length == 0) { - s->internal->rstate = SSL_ST_READ_HEADER; - rr->off = 0; - if (s->internal->mode & SSL_MODE_RELEASE_BUFFERS && - s->s3->rbuf.left == 0) - ssl3_release_read_buffer(s); - } + if (peek) { + ssret = tls_content_peek(s->s3->rcontent, buf, len); + } else { + ssret = tls_content_read(s->s3->rcontent, buf, len); } + if (ssret < INT_MIN || ssret > INT_MAX) + return -1; + if (ssret < 0) + return (int)ssret; - return n; - } + if (tls_content_remaining(s->s3->rcontent) == 0) { + s->rstate = SSL_ST_READ_HEADER; - /* - * If we get here, then type != rr->type; if we have a handshake - * message, then it was unexpected (Hello Request or Client Hello). - */ + if (s->mode & SSL_MODE_RELEASE_BUFFERS && + s->s3->rbuf.left == 0) + ssl3_release_read_buffer(s); + } + + return ssret; + } - if (rr->type == SSL3_RT_ALERT) { + if (tls_content_type(s->s3->rcontent) == SSL3_RT_ALERT) { if ((ret = ssl3_read_alert(s)) <= 0) return ret; goto start; } - if (s->internal->shutdown & SSL_SENT_SHUTDOWN) { - s->internal->rwstate = SSL_NOTHING; - rr->length = 0; + if (s->shutdown & SSL_SENT_SHUTDOWN) { + s->rwstate = SSL_NOTHING; + tls_content_clear(s->s3->rcontent); + s->s3->rrec.length = 0; return 0; } - if (rr->type == SSL3_RT_APPLICATION_DATA) { + if (tls_content_type(s->s3->rcontent) == SSL3_RT_APPLICATION_DATA) { /* * At this point, we were expecting handshake data, but have * application data. If the library was running inside @@ -1194,13 +1211,13 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) } } - if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) { + if (tls_content_type(s->s3->rcontent) == SSL3_RT_CHANGE_CIPHER_SPEC) { if ((ret = ssl3_read_change_cipher_spec(s)) <= 0) return ret; goto start; } - if (rr->type == SSL3_RT_HANDSHAKE) { + if (tls_content_type(s->s3->rcontent) == SSL3_RT_HANDSHAKE) { if ((ret = ssl3_read_handshake_unexpected(s)) <= 0) return ret; goto start; @@ -1211,7 +1228,7 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) * earlier versions silently ignore the record. */ if (ssl_effective_tls_version(s) <= TLS1_1_VERSION) { - rr->length = 0; + tls_content_clear(s->s3->rcontent); goto start; } SSLerror(s, SSL_R_UNEXPECTED_RECORD); diff --git a/ssl/ssl_rsa.c b/ssl/ssl_rsa.c index 70c29359..f84315ba 100644 --- a/ssl/ssl_rsa.c +++ b/ssl/ssl_rsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_rsa.c,v 1.48 2022/08/31 20:49:37 tb Exp $ */ +/* $OpenBSD: ssl_rsa.c,v 1.49 2022/11/26 16:08:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -64,7 +64,7 @@ #include #include -#include "ssl_locl.h" +#include "ssl_local.h" static int ssl_get_password_cb_and_arg(SSL_CTX *ctx, SSL *ssl, pem_password_cb **passwd_cb, void **passwd_arg); diff --git a/ssl/ssl_seclevel.c b/ssl/ssl_seclevel.c index b691b9bc..1869c810 100644 --- a/ssl/ssl_seclevel.c +++ b/ssl/ssl_seclevel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_seclevel.c,v 1.25 2022/08/17 18:41:17 tb Exp $ */ +/* $OpenBSD: ssl_seclevel.c,v 1.27 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2020-2022 Theo Buehler * @@ -28,7 +28,7 @@ #include #include "bytestring.h" -#include "ssl_locl.h" +#include "ssl_local.h" static int ssl_security_normalize_level(const SSL_CTX *ctx, const SSL *ssl, int *out_level) @@ -224,8 +224,8 @@ ssl_security_default_cb(const SSL *ssl, const SSL_CTX *ctx, int secop, int bits, static int ssl_ctx_security(const SSL_CTX *ctx, int secop, int bits, int nid, void *other) { - return ctx->internal->cert->security_cb(NULL, ctx, secop, bits, nid, - other, ctx->internal->cert->security_ex_data); + return ctx->cert->security_cb(NULL, ctx, secop, bits, nid, + other, ctx->cert->security_ex_data); } static int diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 7cf36f89..5847a43d 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_sess.c,v 1.117 2022/08/17 07:39:19 jsing Exp $ */ +/* $OpenBSD: ssl_sess.c,v 1.121 2022/11/26 16:08:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -142,7 +142,7 @@ #include #endif -#include "ssl_locl.h" +#include "ssl_local.h" static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s); static void SSL_SESSION_list_add(SSL_CTX *ctx, SSL_SESSION *s); @@ -242,6 +242,111 @@ SSL_SESSION_new(void) return (ss); } +SSL_SESSION * +ssl_session_dup(SSL_SESSION *sess, int include_ticket) +{ + SSL_SESSION *copy; + CBS cbs; + + if ((copy = calloc(1, sizeof(*copy))) == NULL) { + SSLerrorx(ERR_R_MALLOC_FAILURE); + goto err; + } + + copy->ssl_version = sess->ssl_version; + + CBS_init(&cbs, sess->master_key, sess->master_key_length); + if (!CBS_write_bytes(&cbs, copy->master_key, sizeof(copy->master_key), + ©->master_key_length)) + goto err; + + CBS_init(&cbs, sess->session_id, sess->session_id_length); + if (!CBS_write_bytes(&cbs, copy->session_id, sizeof(copy->session_id), + ©->session_id_length)) + goto err; + + CBS_init(&cbs, sess->sid_ctx, sess->sid_ctx_length); + if (!CBS_write_bytes(&cbs, copy->sid_ctx, sizeof(copy->sid_ctx), + ©->sid_ctx_length)) + goto err; + + if (sess->peer_cert != NULL) { + if (!X509_up_ref(sess->peer_cert)) + goto err; + copy->peer_cert = sess->peer_cert; + } + copy->peer_cert_type = sess->peer_cert_type; + + copy->verify_result = sess->verify_result; + + copy->timeout = sess->timeout; + copy->time = sess->time; + copy->references = 1; + + copy->cipher = sess->cipher; + copy->cipher_id = sess->cipher_id; + + if (sess->ciphers != NULL) { + if ((copy->ciphers = sk_SSL_CIPHER_dup(sess->ciphers)) == NULL) + goto err; + } + + if (sess->tlsext_hostname != NULL) { + copy->tlsext_hostname = strdup(sess->tlsext_hostname); + if (copy->tlsext_hostname == NULL) + goto err; + } + + if (include_ticket) { + CBS_init(&cbs, sess->tlsext_tick, sess->tlsext_ticklen); + if (!CBS_stow(&cbs, ©->tlsext_tick, ©->tlsext_ticklen)) + goto err; + copy->tlsext_tick_lifetime_hint = + sess->tlsext_tick_lifetime_hint; + + /* + * XXX - copy sess->resumption_master_secret and all other + * TLSv1.3 info here. + */ + } + + if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, copy, + ©->ex_data)) + goto err; + + if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ©->ex_data, + &sess->ex_data)) + goto err; + + /* Omit prev/next: the new session gets its own slot in the cache. */ + + copy->not_resumable = sess->not_resumable; + + CBS_init(&cbs, sess->tlsext_ecpointformatlist, + sess->tlsext_ecpointformatlist_length); + if (!CBS_stow(&cbs, ©->tlsext_ecpointformatlist, + ©->tlsext_ecpointformatlist_length)) + goto err; + + if (sess->tlsext_supportedgroups != NULL) { + if ((copy->tlsext_supportedgroups = calloc(sizeof(uint16_t), + sess->tlsext_supportedgroups_length)) == NULL) + goto err; + memcpy(copy->tlsext_supportedgroups, + sess->tlsext_supportedgroups, + sizeof(uint16_t) * sess->tlsext_supportedgroups_length); + copy->tlsext_supportedgroups_length = + sess->tlsext_supportedgroups_length; + } + + return copy; + + err: + SSL_SESSION_free(copy); + + return NULL; +} + const unsigned char * SSL_SESSION_get_id(const SSL_SESSION *ss, unsigned int *len) { @@ -354,17 +459,17 @@ ssl_get_new_session(SSL *s, int session) } /* If RFC4507 ticket use empty session ID. */ - if (s->internal->tlsext_ticket_expected) { + if (s->tlsext_ticket_expected) { ss->session_id_length = 0; goto sess_id_done; } /* Choose which callback will set the session ID. */ CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); - if (s->internal->generate_session_id) - cb = s->internal->generate_session_id; - else if (s->session_ctx->internal->generate_session_id) - cb = s->session_ctx->internal->generate_session_id; + if (s->generate_session_id) + cb = s->generate_session_id; + else if (s->session_ctx->generate_session_id) + cb = s->session_ctx->generate_session_id; CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); /* Choose a session ID. */ @@ -430,7 +535,7 @@ ssl_session_from_cache(SSL *s, CBS *session_id) SSL_SESSION *sess; SSL_SESSION data; - if ((s->session_ctx->internal->session_cache_mode & + if ((s->session_ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) return NULL; @@ -443,13 +548,13 @@ ssl_session_from_cache(SSL *s, CBS *session_id) return NULL; CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); - sess = lh_SSL_SESSION_retrieve(s->session_ctx->internal->sessions, &data); + sess = lh_SSL_SESSION_retrieve(s->session_ctx->sessions, &data); if (sess != NULL) CRYPTO_add(&sess->references, 1, CRYPTO_LOCK_SSL_SESSION); CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); if (sess == NULL) - s->session_ctx->internal->stats.sess_miss++; + s->session_ctx->stats.sess_miss++; return sess; } @@ -460,11 +565,11 @@ ssl_session_from_callback(SSL *s, CBS *session_id) SSL_SESSION *sess; int copy; - if (s->session_ctx->internal->get_session_cb == NULL) + if (s->session_ctx->get_session_cb == NULL) return NULL; copy = 1; - if ((sess = s->session_ctx->internal->get_session_cb(s, + if ((sess = s->session_ctx->get_session_cb(s, CBS_data(session_id), CBS_len(session_id), ©)) == NULL) return NULL; /* @@ -476,10 +581,10 @@ ssl_session_from_callback(SSL *s, CBS *session_id) if (copy) CRYPTO_add(&sess->references, 1, CRYPTO_LOCK_SSL_SESSION); - s->session_ctx->internal->stats.sess_cb_hit++; + s->session_ctx->stats.sess_cb_hit++; /* Add the externally cached session to the internal cache as well. */ - if (!(s->session_ctx->internal->session_cache_mode & + if (!(s->session_ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_STORE)) { /* * The following should not return 1, @@ -523,7 +628,7 @@ ssl_session_by_id(SSL *s, CBS *session_id) * - If a session is found then s->session is pointed at it (after freeing * an existing session if need be) and s->verify_result is set from the * session. - * - For both new and resumed sessions, s->internal->tlsext_ticket_expected + * - For both new and resumed sessions, s->tlsext_ticket_expected * indicates whether the server should issue a new session ticket or not. */ int @@ -538,7 +643,7 @@ ssl_get_prev_session(SSL *s, CBS *session_id, CBS *ext_block, int *alert) if (CBS_len(session_id) > SSL_MAX_SSL_SESSION_ID_LENGTH) goto err; - /* Sets s->internal->tlsext_ticket_expected. */ + /* Sets s->tlsext_ticket_expected. */ switch (tls1_process_ticket(s, ext_block, &alert_desc, &sess)) { case TLS1_TICKET_FATAL_ERROR: fatal = 1; @@ -605,7 +710,7 @@ ssl_get_prev_session(SSL *s, CBS *session_id, CBS *ext_block, int *alert) } if (sess->timeout < (time(NULL) - sess->time)) { - s->session_ctx->internal->stats.sess_timeout++; + s->session_ctx->stats.sess_timeout++; if (!ticket_decrypted) { /* The session was from the cache, so remove it. */ SSL_CTX_remove_session(s->session_ctx, sess); @@ -613,7 +718,7 @@ ssl_get_prev_session(SSL *s, CBS *session_id, CBS *ext_block, int *alert) goto err; } - s->session_ctx->internal->stats.sess_hit++; + s->session_ctx->stats.sess_hit++; SSL_SESSION_free(s->session); s->session = sess; @@ -628,7 +733,7 @@ ssl_get_prev_session(SSL *s, CBS *session_id, CBS *ext_block, int *alert) * The session was from a ticket. Issue a ticket for the new * session. */ - s->internal->tlsext_ticket_expected = 1; + s->tlsext_ticket_expected = 1; } if (fatal) { *alert = alert_desc; @@ -655,12 +760,12 @@ SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c) * later. */ CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); - s = lh_SSL_SESSION_insert(ctx->internal->sessions, c); + s = lh_SSL_SESSION_insert(ctx->sessions, c); /* * s != NULL iff we already had a session with the given PID. * In this case, s == c should hold (then we did not really modify - * ctx->internal->sessions), or we're in trouble. + * ctx->sessions), or we're in trouble. */ if (s != NULL && s != c) { /* We *are* in trouble ... */ @@ -700,10 +805,10 @@ SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c) while (SSL_CTX_sess_number(ctx) > SSL_CTX_sess_get_cache_size(ctx)) { if (!remove_session_lock(ctx, - ctx->internal->session_cache_tail, 0)) + ctx->session_cache_tail, 0)) break; else - ctx->internal->stats.sess_cache_full++; + ctx->stats.sess_cache_full++; } } } @@ -728,9 +833,9 @@ remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck) if (lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); - if ((r = lh_SSL_SESSION_retrieve(ctx->internal->sessions, c)) == c) { + if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) { ret = 1; - r = lh_SSL_SESSION_delete(ctx->internal->sessions, c); + r = lh_SSL_SESSION_delete(ctx->sessions, c); SSL_SESSION_list_remove(ctx, c); } if (lck) @@ -738,8 +843,8 @@ remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck) if (ret) { r->not_resumable = 1; - if (ctx->internal->remove_session_cb != NULL) - ctx->internal->remove_session_cb(ctx, r); + if (ctx->remove_session_cb != NULL) + ctx->remove_session_cb(ctx, r); SSL_SESSION_free(r); } @@ -772,6 +877,8 @@ SSL_SESSION_free(SSL_SESSION *ss) free(ss->tlsext_ecpointformatlist); free(ss->tlsext_supportedgroups); + tls13_secret_cleanup(&ss->resumption_master_secret); + freezero(ss, sizeof(*ss)); } @@ -942,8 +1049,8 @@ SSL_set_session_secret_cb(SSL *s, int (*tls_session_secret_cb)(SSL *s, { if (s == NULL) return (0); - s->internal->tls_session_secret_cb = tls_session_secret_cb; - s->internal->tls_session_secret_cb_arg = arg; + s->tls_session_secret_cb = tls_session_secret_cb; + s->tls_session_secret_cb_arg = arg; return (1); } @@ -953,8 +1060,8 @@ SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb, { if (s == NULL) return (0); - s->internal->tls_session_ticket_ext_cb = cb; - s->internal->tls_session_ticket_ext_cb_arg = arg; + s->tls_session_ticket_ext_cb = cb; + s->tls_session_ticket_ext_cb_arg = arg; return (1); } @@ -962,23 +1069,23 @@ int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len) { if (s->version >= TLS1_VERSION) { - free(s->internal->tlsext_session_ticket); - s->internal->tlsext_session_ticket = + free(s->tlsext_session_ticket); + s->tlsext_session_ticket = malloc(sizeof(TLS_SESSION_TICKET_EXT) + ext_len); - if (!s->internal->tlsext_session_ticket) { + if (!s->tlsext_session_ticket) { SSLerror(s, ERR_R_MALLOC_FAILURE); return 0; } if (ext_data) { - s->internal->tlsext_session_ticket->length = ext_len; - s->internal->tlsext_session_ticket->data = - s->internal->tlsext_session_ticket + 1; - memcpy(s->internal->tlsext_session_ticket->data, + s->tlsext_session_ticket->length = ext_len; + s->tlsext_session_ticket->data = + s->tlsext_session_ticket + 1; + memcpy(s->tlsext_session_ticket->data, ext_data, ext_len); } else { - s->internal->tlsext_session_ticket->length = 0; - s->internal->tlsext_session_ticket->data = NULL; + s->tlsext_session_ticket->length = 0; + s->tlsext_session_ticket->data = NULL; } return 1; @@ -1003,8 +1110,8 @@ timeout_doall_arg(SSL_SESSION *s, TIMEOUT_PARAM *p) (void)lh_SSL_SESSION_delete(p->cache, s); SSL_SESSION_list_remove(p->ctx, s); s->not_resumable = 1; - if (p->ctx->internal->remove_session_cb != NULL) - p->ctx->internal->remove_session_cb(p->ctx, s); + if (p->ctx->remove_session_cb != NULL) + p->ctx->remove_session_cb(p->ctx, s); SSL_SESSION_free(s); } } @@ -1026,7 +1133,7 @@ SSL_CTX_flush_sessions(SSL_CTX *s, long t) TIMEOUT_PARAM tp; tp.ctx = s; - tp.cache = s->internal->sessions; + tp.cache = s->sessions; if (tp.cache == NULL) return; tp.time = t; @@ -1042,7 +1149,7 @@ SSL_CTX_flush_sessions(SSL_CTX *s, long t) int ssl_clear_bad_session(SSL *s) { - if ((s->session != NULL) && !(s->internal->shutdown & SSL_SENT_SHUTDOWN) && + if ((s->session != NULL) && !(s->shutdown & SSL_SENT_SHUTDOWN) && !(SSL_in_init(s) || SSL_in_before(s))) { SSL_CTX_remove_session(s->ctx, s->session); return (1); @@ -1057,23 +1164,23 @@ SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s) if (s->next == NULL || s->prev == NULL) return; - if (s->next == (SSL_SESSION *)&(ctx->internal->session_cache_tail)) { + if (s->next == (SSL_SESSION *)&(ctx->session_cache_tail)) { /* last element in list */ - if (s->prev == (SSL_SESSION *)&(ctx->internal->session_cache_head)) { + if (s->prev == (SSL_SESSION *)&(ctx->session_cache_head)) { /* only one element in list */ - ctx->internal->session_cache_head = NULL; - ctx->internal->session_cache_tail = NULL; + ctx->session_cache_head = NULL; + ctx->session_cache_tail = NULL; } else { - ctx->internal->session_cache_tail = s->prev; + ctx->session_cache_tail = s->prev; s->prev->next = - (SSL_SESSION *)&(ctx->internal->session_cache_tail); + (SSL_SESSION *)&(ctx->session_cache_tail); } } else { - if (s->prev == (SSL_SESSION *)&(ctx->internal->session_cache_head)) { + if (s->prev == (SSL_SESSION *)&(ctx->session_cache_head)) { /* first element in list */ - ctx->internal->session_cache_head = s->next; + ctx->session_cache_head = s->next; s->next->prev = - (SSL_SESSION *)&(ctx->internal->session_cache_head); + (SSL_SESSION *)&(ctx->session_cache_head); } else { /* middle of list */ s->next->prev = s->prev; @@ -1089,83 +1196,83 @@ SSL_SESSION_list_add(SSL_CTX *ctx, SSL_SESSION *s) if (s->next != NULL && s->prev != NULL) SSL_SESSION_list_remove(ctx, s); - if (ctx->internal->session_cache_head == NULL) { - ctx->internal->session_cache_head = s; - ctx->internal->session_cache_tail = s; - s->prev = (SSL_SESSION *)&(ctx->internal->session_cache_head); - s->next = (SSL_SESSION *)&(ctx->internal->session_cache_tail); + if (ctx->session_cache_head == NULL) { + ctx->session_cache_head = s; + ctx->session_cache_tail = s; + s->prev = (SSL_SESSION *)&(ctx->session_cache_head); + s->next = (SSL_SESSION *)&(ctx->session_cache_tail); } else { - s->next = ctx->internal->session_cache_head; + s->next = ctx->session_cache_head; s->next->prev = s; - s->prev = (SSL_SESSION *)&(ctx->internal->session_cache_head); - ctx->internal->session_cache_head = s; + s->prev = (SSL_SESSION *)&(ctx->session_cache_head); + ctx->session_cache_head = s; } } void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, int (*cb)(struct ssl_st *ssl, SSL_SESSION *sess)) { - ctx->internal->new_session_cb = cb; + ctx->new_session_cb = cb; } int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(SSL *ssl, SSL_SESSION *sess) { - return ctx->internal->new_session_cb; + return ctx->new_session_cb; } void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, void (*cb)(SSL_CTX *ctx, SSL_SESSION *sess)) { - ctx->internal->remove_session_cb = cb; + ctx->remove_session_cb = cb; } void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(SSL_CTX * ctx, SSL_SESSION *sess) { - return ctx->internal->remove_session_cb; + return ctx->remove_session_cb; } void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, SSL_SESSION *(*cb)(struct ssl_st *ssl, const unsigned char *data, int len, int *copy)) { - ctx->internal->get_session_cb = cb; + ctx->get_session_cb = cb; } SSL_SESSION * (*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(SSL *ssl, const unsigned char *data, int len, int *copy) { - return ctx->internal->get_session_cb; + return ctx->get_session_cb; } void SSL_CTX_set_info_callback(SSL_CTX *ctx, void (*cb)(const SSL *ssl, int type, int val)) { - ctx->internal->info_callback = cb; + ctx->info_callback = cb; } void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl, int type, int val) { - return ctx->internal->info_callback; + return ctx->info_callback; } void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey)) { - ctx->internal->client_cert_cb = cb; + ctx->client_cert_cb = cb; } int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL * ssl, X509 ** x509, EVP_PKEY **pkey) { - return ctx->internal->client_cert_cb; + return ctx->client_cert_cb; } #ifndef OPENSSL_NO_ENGINE @@ -1181,7 +1288,7 @@ SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e) ENGINE_finish(e); return 0; } - ctx->internal->client_cert_engine = e; + ctx->client_cert_engine = e; return 1; } #endif @@ -1190,14 +1297,14 @@ void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len)) { - ctx->internal->app_gen_cookie_cb = cb; + ctx->app_gen_cookie_cb = cb; } void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, int (*cb)(SSL *ssl, const unsigned char *cookie, unsigned int cookie_len)) { - ctx->internal->app_verify_cookie_cb = cb; + ctx->app_verify_cookie_cb = cb; } int diff --git a/ssl/ssl_sigalgs.c b/ssl/ssl_sigalgs.c index c3e07e5c..f59beb43 100644 --- a/ssl/ssl_sigalgs.c +++ b/ssl/ssl_sigalgs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_sigalgs.c,v 1.47 2022/07/02 16:31:04 tb Exp $ */ +/* $OpenBSD: ssl_sigalgs.c,v 1.48 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2018-2020 Bob Beck * Copyright (c) 2021 Joel Sing @@ -23,7 +23,7 @@ #include #include "bytestring.h" -#include "ssl_locl.h" +#include "ssl_local.h" #include "ssl_sigalgs.h" #include "tls13_internal.h" diff --git a/ssl/ssl_srvr.c b/ssl/ssl_srvr.c index acdcb153..556107f5 100644 --- a/ssl/ssl_srvr.c +++ b/ssl/ssl_srvr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_srvr.c,v 1.149 2022/08/17 07:39:19 jsing Exp $ */ +/* $OpenBSD: ssl_srvr.c,v 1.153 2022/12/26 07:31:44 jmc Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -148,6 +148,7 @@ * OTHERWISE. */ +#include #include #include @@ -166,11 +167,28 @@ #endif #include "bytestring.h" -#include "dtls_locl.h" -#include "ssl_locl.h" +#include "dtls_local.h" +#include "ssl_local.h" #include "ssl_sigalgs.h" #include "ssl_tlsext.h" +static int ssl3_get_client_hello(SSL *s); +static int ssl3_send_dtls_hello_verify_request(SSL *s); +static int ssl3_send_server_hello(SSL *s); +static int ssl3_send_hello_request(SSL *s); +static int ssl3_send_server_certificate(SSL *s); +static int ssl3_send_server_key_exchange(SSL *s); +static int ssl3_send_certificate_request(SSL *s); +static int ssl3_send_server_done(SSL *s); +static int ssl3_get_client_certificate(SSL *s); +static int ssl3_get_client_key_exchange(SSL *s); +static int ssl3_get_cert_verify(SSL *s); +static int ssl3_send_newsession_ticket(SSL *s); +static int ssl3_send_cert_status(SSL *s); +static int ssl3_send_server_change_cipher_spec(SSL *s); +static int ssl3_send_server_finished(SSL *s); +static int ssl3_get_client_finished(SSL *s); + int ssl3_accept(SSL *s) { @@ -186,7 +204,7 @@ ssl3_accept(SSL *s) listen = s->d1->listen; /* init things to blank */ - s->internal->in_handshake++; + s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); @@ -198,7 +216,7 @@ ssl3_accept(SSL *s) switch (s->s3->hs.state) { case SSL_ST_RENEGOTIATE: - s->internal->renegotiate = 1; + s->renegotiate = 1; /* s->s3->hs.state=SSL_ST_ACCEPT; */ case SSL_ST_BEFORE: @@ -239,7 +257,7 @@ ssl3_accept(SSL *s) goto end; } - s->internal->init_num = 0; + s->init_num = 0; if (s->s3->hs.state != SSL_ST_RENEGOTIATE) { /* @@ -258,7 +276,7 @@ ssl3_accept(SSL *s) } s->s3->hs.state = SSL3_ST_SR_CLNT_HELLO_A; - s->ctx->internal->stats.sess_accept++; + s->ctx->stats.sess_accept++; } else if (!SSL_is_dtls(s) && !s->s3->send_connection_binding) { /* * Server attempting to renegotiate with @@ -275,14 +293,14 @@ ssl3_accept(SSL *s) * s->s3->hs.state == SSL_ST_RENEGOTIATE, * we will just send a HelloRequest. */ - s->ctx->internal->stats.sess_accept_renegotiate++; + s->ctx->stats.sess_accept_renegotiate++; s->s3->hs.state = SSL3_ST_SW_HELLO_REQ_A; } break; case SSL3_ST_SW_HELLO_REQ_A: case SSL3_ST_SW_HELLO_REQ_B: - s->internal->shutdown = 0; + s->shutdown = 0; if (SSL_is_dtls(s)) { dtls1_clear_record_buffer(s); dtls1_start_timer(s); @@ -295,7 +313,7 @@ ssl3_accept(SSL *s) else s->s3->hs.tls12.next_state = SSL3_ST_SW_HELLO_REQ_C; s->s3->hs.state = SSL3_ST_SW_FLUSH; - s->internal->init_num = 0; + s->init_num = 0; if (SSL_is_dtls(s)) { if (!tls1_transcript_init(s)) { @@ -312,7 +330,7 @@ ssl3_accept(SSL *s) case SSL3_ST_SR_CLNT_HELLO_A: case SSL3_ST_SR_CLNT_HELLO_B: case SSL3_ST_SR_CLNT_HELLO_C: - s->internal->shutdown = 0; + s->shutdown = 0; if (SSL_is_dtls(s)) { ret = ssl3_get_client_hello(s); if (ret <= 0) @@ -325,7 +343,7 @@ ssl3_accept(SSL *s) else s->s3->hs.state = SSL3_ST_SW_SRVR_HELLO_A; - s->internal->init_num = 0; + s->init_num = 0; /* * Reflect ClientHello sequence to remain @@ -333,7 +351,7 @@ ssl3_accept(SSL *s) */ if (listen) { tls12_record_layer_reflect_seq_num( - s->internal->rl); + s->rl); } /* If we're just listening, stop here */ @@ -350,15 +368,15 @@ ssl3_accept(SSL *s) goto end; } } else { - if (s->internal->rwstate != SSL_X509_LOOKUP) { + if (s->rwstate != SSL_X509_LOOKUP) { ret = ssl3_get_client_hello(s); if (ret <= 0) goto end; } - s->internal->renegotiate = 2; + s->renegotiate = 2; s->s3->hs.state = SSL3_ST_SW_SRVR_HELLO_A; - s->internal->init_num = 0; + s->init_num = 0; } break; @@ -377,21 +395,21 @@ ssl3_accept(SSL *s) case SSL3_ST_SW_SRVR_HELLO_A: case SSL3_ST_SW_SRVR_HELLO_B: if (SSL_is_dtls(s)) { - s->internal->renegotiate = 2; + s->renegotiate = 2; dtls1_start_timer(s); } ret = ssl3_send_server_hello(s); if (ret <= 0) goto end; - if (s->internal->hit) { - if (s->internal->tlsext_ticket_expected) + if (s->hit) { + if (s->tlsext_ticket_expected) s->s3->hs.state = SSL3_ST_SW_SESSION_TICKET_A; else s->s3->hs.state = SSL3_ST_SW_CHANGE_A; } else { s->s3->hs.state = SSL3_ST_SW_CERT_A; } - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_SW_CERT_A: @@ -404,7 +422,7 @@ ssl3_accept(SSL *s) ret = ssl3_send_server_certificate(s); if (ret <= 0) goto end; - if (s->internal->tlsext_status_expected) + if (s->tlsext_status_expected) s->s3->hs.state = SSL3_ST_SW_CERT_STATUS_A; else s->s3->hs.state = SSL3_ST_SW_KEY_EXCH_A; @@ -412,7 +430,7 @@ ssl3_accept(SSL *s) skip = 1; s->s3->hs.state = SSL3_ST_SW_KEY_EXCH_A; } - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_SW_KEY_EXCH_A: @@ -437,7 +455,7 @@ ssl3_accept(SSL *s) skip = 1; s->s3->hs.state = SSL3_ST_SW_CERT_REQ_A; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_SW_CERT_REQ_A: @@ -480,7 +498,7 @@ ssl3_accept(SSL *s) if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_SW_SRVR_DONE_A; - s->internal->init_num = 0; + s->init_num = 0; } break; @@ -493,7 +511,7 @@ ssl3_accept(SSL *s) goto end; s->s3->hs.tls12.next_state = SSL3_ST_SR_CERT_A; s->s3->hs.state = SSL3_ST_SW_FLUSH; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_SW_FLUSH: @@ -507,19 +525,19 @@ ssl3_accept(SSL *s) * still exist. So instead we just flush * unconditionally. */ - s->internal->rwstate = SSL_WRITING; + s->rwstate = SSL_WRITING; if (BIO_flush(s->wbio) <= 0) { if (SSL_is_dtls(s)) { /* If the write error was fatal, stop trying. */ if (!BIO_should_retry(s->wbio)) { - s->internal->rwstate = SSL_NOTHING; + s->rwstate = SSL_NOTHING; s->s3->hs.state = s->s3->hs.tls12.next_state; } } ret = -1; goto end; } - s->internal->rwstate = SSL_NOTHING; + s->rwstate = SSL_NOTHING; s->s3->hs.state = s->s3->hs.tls12.next_state; break; @@ -530,7 +548,7 @@ ssl3_accept(SSL *s) if (ret <= 0) goto end; } - s->internal->init_num = 0; + s->init_num = 0; s->s3->hs.state = SSL3_ST_SR_KEY_EXCH_A; break; @@ -542,7 +560,7 @@ ssl3_accept(SSL *s) if (SSL_is_dtls(s)) { s->s3->hs.state = SSL3_ST_SR_CERT_VRFY_A; - s->internal->init_num = 0; + s->init_num = 0; } alg_k = s->s3->hs.cipher->algorithm_mkey; @@ -553,10 +571,10 @@ ssl3_accept(SSL *s) * the CertificateVerify message is not sent. */ s->s3->hs.state = SSL3_ST_SR_FINISHED_A; - s->internal->init_num = 0; + s->init_num = 0; } else if (SSL_USE_SIGALGS(s) || (alg_k & SSL_kGOST)) { s->s3->hs.state = SSL3_ST_SR_CERT_VRFY_A; - s->internal->init_num = 0; + s->init_num = 0; if (!s->session->peer_cert) break; /* @@ -566,7 +584,7 @@ ssl3_accept(SSL *s) tls1_transcript_freeze(s); } else { s->s3->hs.state = SSL3_ST_SR_CERT_VRFY_A; - s->internal->init_num = 0; + s->init_num = 0; tls1_transcript_free(s); @@ -596,7 +614,7 @@ ssl3_accept(SSL *s) if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_SR_FINISHED_A; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_SR_FINISHED_A: @@ -605,19 +623,18 @@ ssl3_accept(SSL *s) s->d1->change_cipher_spec_ok = 1; else s->s3->flags |= SSL3_FLAGS_CCS_OK; - ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A, - SSL3_ST_SR_FINISHED_B); + ret = ssl3_get_client_finished(s); if (ret <= 0) goto end; if (SSL_is_dtls(s)) dtls1_stop_timer(s); - if (s->internal->hit) + if (s->hit) s->s3->hs.state = SSL_ST_OK; - else if (s->internal->tlsext_ticket_expected) + else if (s->tlsext_ticket_expected) s->s3->hs.state = SSL3_ST_SW_SESSION_TICKET_A; else s->s3->hs.state = SSL3_ST_SW_CHANGE_A; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_SW_SESSION_TICKET_A: @@ -626,7 +643,7 @@ ssl3_accept(SSL *s) if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_SW_CHANGE_A; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_SW_CERT_STATUS_A: @@ -635,17 +652,16 @@ ssl3_accept(SSL *s) if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_SW_KEY_EXCH_A; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL3_ST_SW_CHANGE_A: case SSL3_ST_SW_CHANGE_B: - ret = ssl3_send_change_cipher_spec(s, - SSL3_ST_SW_CHANGE_A, SSL3_ST_SW_CHANGE_B); + ret = ssl3_send_server_change_cipher_spec(s); if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_SW_FINISHED_A; - s->internal->init_num = 0; + s->init_num = 0; s->session->cipher = s->s3->hs.cipher; if (!tls1_setup_key_block(s)) { @@ -660,17 +676,16 @@ ssl3_accept(SSL *s) case SSL3_ST_SW_FINISHED_A: case SSL3_ST_SW_FINISHED_B: - ret = ssl3_send_finished(s, SSL3_ST_SW_FINISHED_A, - SSL3_ST_SW_FINISHED_B); + ret = ssl3_send_server_finished(s); if (ret <= 0) goto end; s->s3->hs.state = SSL3_ST_SW_FLUSH; - if (s->internal->hit) { + if (s->hit) { s->s3->hs.tls12.next_state = SSL3_ST_SR_FINISHED_A; tls1_transcript_free(s); } else s->s3->hs.tls12.next_state = SSL_ST_OK; - s->internal->init_num = 0; + s->init_num = 0; break; case SSL_ST_OK: @@ -689,18 +704,18 @@ ssl3_accept(SSL *s) /* remove buffering on output */ ssl_free_wbio_buffer(s); - s->internal->init_num = 0; + s->init_num = 0; /* Skipped if we just sent a HelloRequest. */ - if (s->internal->renegotiate == 2) { - s->internal->renegotiate = 0; - s->internal->new_session = 0; + if (s->renegotiate == 2) { + s->renegotiate = 0; + s->new_session = 0; ssl_update_cache(s, SSL_SESS_CACHE_SERVER); - s->ctx->internal->stats.sess_accept_good++; + s->ctx->stats.sess_accept_good++; /* s->server=1; */ - s->internal->handshake_func = ssl3_accept; + s->handshake_func = ssl3_accept; ssl_info_callback(s, SSL_CB_HANDSHAKE_DONE, 1); } @@ -725,7 +740,7 @@ ssl3_accept(SSL *s) } if (!s->s3->hs.tls12.reuse_message && !skip) { - if (s->internal->debug) { + if (s->debug) { if ((ret = BIO_flush(s->wbio)) <= 0) goto end; } @@ -742,13 +757,13 @@ ssl3_accept(SSL *s) } end: /* BIO_flush(s->wbio); */ - s->internal->in_handshake--; + s->in_handshake--; ssl_info_callback(s, SSL_CB_ACCEPT_EXIT, ret); return (ret); } -int +static int ssl3_send_hello_request(SSL *s) { CBB cbb, hello; @@ -774,7 +789,7 @@ ssl3_send_hello_request(SSL *s) return (-1); } -int +static int ssl3_get_client_hello(SSL *s) { CBS cbs, client_random, session_id, cookie, cipher_suites; @@ -800,19 +815,19 @@ ssl3_get_client_hello(SSL *s) if (s->s3->hs.state == SSL3_ST_SR_CLNT_HELLO_A) s->s3->hs.state = SSL3_ST_SR_CLNT_HELLO_B; - s->internal->first_packet = 1; + s->first_packet = 1; if ((ret = ssl3_get_message(s, SSL3_ST_SR_CLNT_HELLO_B, SSL3_ST_SR_CLNT_HELLO_C, SSL3_MT_CLIENT_HELLO, SSL3_RT_MAX_PLAIN_LENGTH)) <= 0) return ret; - s->internal->first_packet = 0; + s->first_packet = 0; ret = -1; - if (s->internal->init_num < 0) + if (s->init_num < 0) goto err; - CBS_init(&cbs, s->internal->init_msg, s->internal->init_num); + CBS_init(&cbs, s->init_msg, s->init_num); /* Parse client hello up until the extensions (if any). */ if (!CBS_get_u16(&cbs, &client_version)) @@ -841,7 +856,7 @@ ssl3_get_client_hello(SSL *s) */ if (!ssl_max_shared_version(s, client_version, &shared_version)) { if ((client_version >> 8) == SSL3_VERSION_MAJOR && - !tls12_record_layer_write_protected(s->internal->rl)) { + !tls12_record_layer_write_protected(s->rl)) { /* * Similar to ssl3_get_record, send alert using remote * version number. @@ -883,7 +898,7 @@ ssl3_get_client_hello(SSL *s) sizeof(s->s3->client_random), NULL)) goto err; - s->internal->hit = 0; + s->hit = 0; /* * Versions before 0.9.7 always allow clients to resume sessions in @@ -895,12 +910,12 @@ ssl3_get_client_hello(SSL *s) * library versions). * * 1.0.1 and later also have a function SSL_renegotiate_abbreviated() - * to request renegotiation but not a new session (s->internal->new_session + * to request renegotiation but not a new session (s->new_session * remains unset): for servers, this essentially just means that the * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION setting will be * ignored. */ - if ((s->internal->new_session && (s->internal->options & + if ((s->new_session && (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION))) { if (!ssl_get_new_session(s, 1)) goto err; @@ -911,7 +926,7 @@ ssl3_get_client_hello(SSL *s) i = ssl_get_prev_session(s, &session_id, &ext_block, &al); if (i == 1) { /* previous session */ - s->internal->hit = 1; + s->hit = 1; } else if (i == -1) goto fatal_err; else { @@ -943,8 +958,8 @@ ssl3_get_client_hello(SSL *s) sizeof(s->d1->rcvd_cookie), &cookie_len)) goto err; - if (s->ctx->internal->app_verify_cookie_cb != NULL) { - if (s->ctx->internal->app_verify_cookie_cb(s, + if (s->ctx->app_verify_cookie_cb != NULL) { + if (s->ctx->app_verify_cookie_cb(s, s->d1->rcvd_cookie, cookie_len) == 0) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerror(s, SSL_R_COOKIE_MISMATCH); @@ -979,7 +994,7 @@ ssl3_get_client_hello(SSL *s) /* If it is a hit, check that the cipher is in the list */ /* XXX - CBS_len(&cipher_suites) will always be zero here... */ - if (s->internal->hit && CBS_len(&cipher_suites) > 0) { + if (s->hit && CBS_len(&cipher_suites) > 0) { j = 0; id = s->session->cipher->id; @@ -1022,7 +1037,7 @@ ssl3_get_client_hello(SSL *s) if (CBS_len(&cbs) != 0) goto decode_err; - if (!s->s3->renegotiate_seen && s->internal->renegotiate) { + if (!s->s3->renegotiate_seen && s->renegotiate) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerror(s, SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED); goto fatal_err; @@ -1062,13 +1077,13 @@ ssl3_get_client_hello(SSL *s) } } - if (!s->internal->hit && s->internal->tls_session_secret_cb != NULL) { + if (!s->hit && s->tls_session_secret_cb != NULL) { SSL_CIPHER *pref_cipher = NULL; int master_key_length = sizeof(s->session->master_key); - if (!s->internal->tls_session_secret_cb(s, + if (!s->tls_session_secret_cb(s, s->session->master_key, &master_key_length, ciphers, - &pref_cipher, s->internal->tls_session_secret_cb_arg)) { + &pref_cipher, s->tls_session_secret_cb_arg)) { SSLerror(s, ERR_R_INTERNAL_ERROR); goto err; } @@ -1078,7 +1093,7 @@ ssl3_get_client_hello(SSL *s) } s->session->master_key_length = master_key_length; - s->internal->hit = 1; + s->hit = 1; s->session->verify_result = X509_V_OK; sk_SSL_CIPHER_free(s->session->ciphers); @@ -1105,7 +1120,7 @@ ssl3_get_client_hello(SSL *s) * pick a cipher */ - if (!s->internal->hit) { + if (!s->hit) { if (ciphers == NULL) { al = SSL_AD_ILLEGAL_PARAMETER; SSLerror(s, SSL_R_NO_CIPHERS_PASSED); @@ -1137,12 +1152,12 @@ ssl3_get_client_hello(SSL *s) /* * We now have the following setup. * client_random - * cipher_list - our prefered list of ciphers - * ciphers - the clients prefered list of ciphers + * cipher_list - our preferred list of ciphers + * ciphers - the clients preferred list of ciphers * compression - basically ignored right now * ssl version is set - sslv3 * s->session - The ssl session has been setup. - * s->internal->hit - session reuse flag + * s->hit - session reuse flag * s->hs.cipher - the new cipher to use. */ @@ -1167,7 +1182,7 @@ ssl3_get_client_hello(SSL *s) return (ret); } -int +static int ssl3_send_dtls_hello_verify_request(SSL *s) { CBB cbb, verify, cookie; @@ -1175,8 +1190,8 @@ ssl3_send_dtls_hello_verify_request(SSL *s) memset(&cbb, 0, sizeof(cbb)); if (s->s3->hs.state == DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A) { - if (s->ctx->internal->app_gen_cookie_cb == NULL || - s->ctx->internal->app_gen_cookie_cb(s, s->d1->cookie, + if (s->ctx->app_gen_cookie_cb == NULL || + s->ctx->app_gen_cookie_cb(s, s->d1->cookie, &(s->d1->cookie_len)) == 0) { SSLerror(s, ERR_R_INTERNAL_ERROR); return 0; @@ -1211,7 +1226,7 @@ ssl3_send_dtls_hello_verify_request(SSL *s) return (-1); } -int +static int ssl3_send_server_hello(SSL *s) { CBB cbb, server_hello, session_id; @@ -1244,12 +1259,12 @@ ssl3_send_server_hello(SSL *s) * - However, if we want the new session to be single-use, * we send back a 0-length session ID. * - * s->internal->hit is non-zero in either case of session reuse, + * s->hit is non-zero in either case of session reuse, * so the following won't overwrite an ID that we're supposed * to send back. */ - if (!(s->ctx->internal->session_cache_mode & SSL_SESS_CACHE_SERVER) - && !s->internal->hit) + if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_SERVER) + && !s->hit) s->session->session_id_length = 0; sl = s->session->session_id_length; @@ -1290,7 +1305,7 @@ ssl3_send_server_hello(SSL *s) return (-1); } -int +static int ssl3_send_server_done(SSL *s) { CBB cbb, done; @@ -1413,7 +1428,7 @@ ssl3_send_server_kex_ecdhe(SSL *s, CBB *cbb) return 0; } -int +static int ssl3_send_server_key_exchange(SSL *s) { CBB cbb, cbb_params, cbb_signature, server_kex; @@ -1552,7 +1567,7 @@ ssl3_send_server_key_exchange(SSL *s) return (-1); } -int +static int ssl3_send_certificate_request(SSL *s) { CBB cbb, cert_request, cert_types, sigalgs, cert_auth, dn; @@ -1868,7 +1883,7 @@ ssl3_get_client_kex_gost(SSL *s, CBS *cbs) return 0; } -int +static int ssl3_get_client_key_exchange(SSL *s) { unsigned long alg_k; @@ -1880,10 +1895,10 @@ ssl3_get_client_key_exchange(SSL *s) SSL3_ST_SR_KEY_EXCH_B, SSL3_MT_CLIENT_KEY_EXCHANGE, 2048)) <= 0) return ret; - if (s->internal->init_num < 0) + if (s->init_num < 0) goto err; - CBS_init(&cbs, s->internal->init_msg, s->internal->init_num); + CBS_init(&cbs, s->init_msg, s->init_num); alg_k = s->s3->hs.cipher->algorithm_mkey; @@ -1919,7 +1934,7 @@ ssl3_get_client_key_exchange(SSL *s) return (-1); } -int +static int ssl3_get_cert_verify(SSL *s) { CBS cbs, signature; @@ -1940,13 +1955,13 @@ ssl3_get_cert_verify(SSL *s) ret = 0; - if (s->internal->init_num < 0) + if (s->init_num < 0) goto err; if ((mctx = EVP_MD_CTX_new()) == NULL) goto err; - CBS_init(&cbs, s->internal->init_msg, s->internal->init_num); + CBS_init(&cbs, s->init_msg, s->init_num); peer_cert = s->session->peer_cert; pkey = X509_get0_pubkey(peer_cert); @@ -2153,7 +2168,7 @@ ssl3_get_cert_verify(SSL *s) return (ret); } -int +static int ssl3_get_client_certificate(SSL *s) { CBS cbs, cert_list, cert_data; @@ -2163,7 +2178,7 @@ ssl3_get_client_certificate(SSL *s) int al, ret; if ((ret = ssl3_get_message(s, SSL3_ST_SR_CERT_A, SSL3_ST_SR_CERT_B, - -1, s->internal->max_cert_list)) <= 0) + -1, s->max_cert_list)) <= 0) return ret; ret = -1; @@ -2195,10 +2210,10 @@ ssl3_get_client_certificate(SSL *s) goto fatal_err; } - if (s->internal->init_num < 0) + if (s->init_num < 0) goto decode_err; - CBS_init(&cbs, s->internal->init_msg, s->internal->init_num); + CBS_init(&cbs, s->init_msg, s->init_num); if (!CBS_get_u24_length_prefixed(&cbs, &cert_list)) goto decode_err; @@ -2271,7 +2286,7 @@ ssl3_get_client_certificate(SSL *s) return (ret); } -int +static int ssl3_send_server_certificate(SSL *s) { CBB cbb, server_cert; @@ -2310,7 +2325,7 @@ ssl3_send_server_certificate(SSL *s) } /* send a new session ticket (not necessarily for a new session) */ -int +static int ssl3_send_newsession_ticket(SSL *s) { CBB cbb, session_ticket, ticket; @@ -2352,17 +2367,17 @@ ssl3_send_newsession_ticket(SSL *s) * it does all the work, otherwise use generated values from * parent context. */ - if (tctx->internal->tlsext_ticket_key_cb != NULL) { - if (tctx->internal->tlsext_ticket_key_cb(s, + if (tctx->tlsext_ticket_key_cb != NULL) { + if (tctx->tlsext_ticket_key_cb(s, key_name, iv, ctx, hctx, 1) < 0) goto err; } else { arc4random_buf(iv, 16); EVP_EncryptInit_ex(ctx, EVP_aes_128_cbc(), NULL, - tctx->internal->tlsext_tick_aes_key, iv); - HMAC_Init_ex(hctx, tctx->internal->tlsext_tick_hmac_key, + tctx->tlsext_tick_aes_key, iv); + HMAC_Init_ex(hctx, tctx->tlsext_tick_hmac_key, 16, EVP_sha256(), NULL); - memcpy(key_name, tctx->internal->tlsext_tick_key_name, 16); + memcpy(key_name, tctx->tlsext_tick_key_name, 16); } /* Encrypt the session state. */ @@ -2400,7 +2415,7 @@ ssl3_send_newsession_ticket(SSL *s) * sessions will live as long as their sessions. */ if (!CBB_add_u32(&session_ticket, - s->internal->hit ? 0 : s->session->timeout)) + s->hit ? 0 : s->session->timeout)) goto err; if (!CBB_add_u16_length_prefixed(&session_ticket, &ticket)) @@ -2443,7 +2458,7 @@ ssl3_send_newsession_ticket(SSL *s) return (-1); } -int +static int ssl3_send_cert_status(SSL *s) { CBB cbb, certstatus, ocspresp; @@ -2458,8 +2473,8 @@ ssl3_send_cert_status(SSL *s) goto err; if (!CBB_add_u24_length_prefixed(&certstatus, &ocspresp)) goto err; - if (!CBB_add_bytes(&ocspresp, s->internal->tlsext_ocsp_resp, - s->internal->tlsext_ocsp_resp_len)) + if (!CBB_add_bytes(&ocspresp, s->tlsext_ocsp_resp, + s->tlsext_ocsp_resp_len)) goto err; if (!ssl3_handshake_msg_finish(s, &cbb)) goto err; @@ -2475,3 +2490,136 @@ ssl3_send_cert_status(SSL *s) return (-1); } + +static int +ssl3_send_server_change_cipher_spec(SSL *s) +{ + size_t outlen; + CBB cbb; + + memset(&cbb, 0, sizeof(cbb)); + + if (s->s3->hs.state == SSL3_ST_SW_CHANGE_A) { + if (!CBB_init_fixed(&cbb, s->init_buf->data, + s->init_buf->length)) + goto err; + if (!CBB_add_u8(&cbb, SSL3_MT_CCS)) + goto err; + if (!CBB_finish(&cbb, NULL, &outlen)) + goto err; + + if (outlen > INT_MAX) + goto err; + + s->init_num = (int)outlen; + s->init_off = 0; + + if (SSL_is_dtls(s)) { + s->d1->handshake_write_seq = + s->d1->next_handshake_write_seq; + dtls1_set_message_header_int(s, SSL3_MT_CCS, 0, + s->d1->handshake_write_seq, 0, 0); + dtls1_buffer_message(s, 1); + } + + s->s3->hs.state = SSL3_ST_SW_CHANGE_B; + } + + /* SSL3_ST_SW_CHANGE_B */ + return ssl3_record_write(s, SSL3_RT_CHANGE_CIPHER_SPEC); + + err: + CBB_cleanup(&cbb); + + return -1; +} + +static int +ssl3_get_client_finished(SSL *s) +{ + int al, md_len, ret; + CBS cbs; + + /* should actually be 36+4 :-) */ + if ((ret = ssl3_get_message(s, SSL3_ST_SR_FINISHED_A, + SSL3_ST_SR_FINISHED_B, SSL3_MT_FINISHED, 64)) <= 0) + return ret; + + /* If this occurs, we have missed a message */ + if (!s->s3->change_cipher_spec) { + al = SSL_AD_UNEXPECTED_MESSAGE; + SSLerror(s, SSL_R_GOT_A_FIN_BEFORE_A_CCS); + goto fatal_err; + } + s->s3->change_cipher_spec = 0; + + md_len = TLS1_FINISH_MAC_LENGTH; + + if (s->init_num < 0) { + al = SSL_AD_DECODE_ERROR; + SSLerror(s, SSL_R_BAD_DIGEST_LENGTH); + goto fatal_err; + } + + CBS_init(&cbs, s->init_msg, s->init_num); + + if (s->s3->hs.peer_finished_len != md_len || + CBS_len(&cbs) != md_len) { + al = SSL_AD_DECODE_ERROR; + SSLerror(s, SSL_R_BAD_DIGEST_LENGTH); + goto fatal_err; + } + + if (!CBS_mem_equal(&cbs, s->s3->hs.peer_finished, CBS_len(&cbs))) { + al = SSL_AD_DECRYPT_ERROR; + SSLerror(s, SSL_R_DIGEST_CHECK_FAILED); + goto fatal_err; + } + + /* Copy finished so we can use it for renegotiation checks. */ + OPENSSL_assert(md_len <= EVP_MAX_MD_SIZE); + memcpy(s->s3->previous_client_finished, + s->s3->hs.peer_finished, md_len); + s->s3->previous_client_finished_len = md_len; + + return (1); + fatal_err: + ssl3_send_alert(s, SSL3_AL_FATAL, al); + return (0); +} + +static int +ssl3_send_server_finished(SSL *s) +{ + CBB cbb, finished; + + memset(&cbb, 0, sizeof(cbb)); + + if (s->s3->hs.state == SSL3_ST_SW_FINISHED_A) { + if (!tls12_derive_finished(s)) + goto err; + + /* Copy finished so we can use it for renegotiation checks. */ + memcpy(s->s3->previous_server_finished, + s->s3->hs.finished, s->s3->hs.finished_len); + s->s3->previous_server_finished_len = s->s3->hs.finished_len; + + if (!ssl3_handshake_msg_start(s, &cbb, &finished, + SSL3_MT_FINISHED)) + goto err; + if (!CBB_add_bytes(&finished, s->s3->hs.finished, + s->s3->hs.finished_len)) + goto err; + if (!ssl3_handshake_msg_finish(s, &cbb)) + goto err; + + s->s3->hs.state = SSL3_ST_SW_FINISHED_B; + } + + return (ssl3_handshake_write(s)); + + err: + CBB_cleanup(&cbb); + + return (-1); +} diff --git a/ssl/ssl_stat.c b/ssl/ssl_stat.c index 5d35528a..b423033e 100644 --- a/ssl/ssl_stat.c +++ b/ssl/ssl_stat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_stat.c,v 1.18 2022/02/05 14:54:10 jsing Exp $ */ +/* $OpenBSD: ssl_stat.c,v 1.20 2022/11/26 16:08:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -84,7 +84,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" const char * SSL_state_string_long(const SSL *s) @@ -325,7 +325,7 @@ SSL_rstate_string_long(const SSL *s) { const char *str; - switch (s->internal->rstate) { + switch (s->rstate) { case SSL_ST_READ_HEADER: str = "read header"; break; @@ -771,7 +771,7 @@ SSL_rstate_string(const SSL *s) { const char *str; - switch (s->internal->rstate) { + switch (s->rstate) { case SSL_ST_READ_HEADER: str = "RH"; break; diff --git a/ssl/ssl_tlsext.c b/ssl/ssl_tlsext.c index a4285626..e5763841 100644 --- a/ssl/ssl_tlsext.c +++ b/ssl/ssl_tlsext.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_tlsext.c,v 1.129 2022/08/15 10:46:53 tb Exp $ */ +/* $OpenBSD: ssl_tlsext.c,v 1.131 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2016, 2017, 2019 Joel Sing * Copyright (c) 2017 Doug Hogan @@ -28,7 +28,7 @@ #include #include "bytestring.h" -#include "ssl_locl.h" +#include "ssl_local.h" #include "ssl_sigalgs.h" #include "ssl_tlsext.h" @@ -40,7 +40,7 @@ static int tlsext_alpn_client_needs(SSL *s, uint16_t msg_type) { /* ALPN protos have been specified and this is the initial handshake */ - return s->internal->alpn_client_proto_list != NULL && + return s->alpn_client_proto_list != NULL && s->s3->hs.finished_len == 0; } @@ -52,8 +52,8 @@ tlsext_alpn_client_build(SSL *s, uint16_t msg_type, CBB *cbb) if (!CBB_add_u16_length_prefixed(cbb, &protolist)) return 0; - if (!CBB_add_bytes(&protolist, s->internal->alpn_client_proto_list, - s->internal->alpn_client_proto_list_len)) + if (!CBB_add_bytes(&protolist, s->alpn_client_proto_list, + s->alpn_client_proto_list_len)) return 0; if (!CBB_flush(cbb)) @@ -97,7 +97,7 @@ tlsext_alpn_server_parse(SSL *s, uint16_t msg_types, CBS *cbs, int *alert) if (!tlsext_alpn_check_format(&alpn)) return 0; - if (s->ctx->internal->alpn_select_cb == NULL) + if (s->ctx->alpn_select_cb == NULL) return 1; /* @@ -106,9 +106,9 @@ tlsext_alpn_server_parse(SSL *s, uint16_t msg_types, CBS *cbs, int *alert) * 2. Should the callback be called even if no ALPN extension was sent? * 3. TLSv1.2 and earlier: ensure that SNI has already been processed. */ - r = s->ctx->internal->alpn_select_cb(s, &selected, &selected_len, + r = s->ctx->alpn_select_cb(s, &selected, &selected_len, CBS_data(&alpn), CBS_len(&alpn), - s->ctx->internal->alpn_select_cb_arg); + s->ctx->alpn_select_cb_arg); if (r == SSL_TLSEXT_ERR_OK) { CBS_init(&selected_cbs, selected, selected_len); @@ -164,7 +164,7 @@ tlsext_alpn_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) { CBS list, proto; - if (s->internal->alpn_client_proto_list == NULL) { + if (s->alpn_client_proto_list == NULL) { *alert = SSL_AD_UNSUPPORTED_EXTENSION; return 0; } @@ -243,7 +243,7 @@ tlsext_supportedgroups_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, return 0; groups_len /= 2; - if (s->internal->hit) + if (s->hit) return 1; if (s->s3->hs.tls13.hrr) { @@ -365,7 +365,7 @@ tlsext_ecpf_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) return 0; } - if (!s->internal->hit) { + if (!s->hit) { if (!CBS_stow(&ecpf, &(s->session->tlsext_ecpointformatlist), &(s->session->tlsext_ecpointformatlist_length))) { *alert = SSL_AD_INTERNAL_ERROR; @@ -418,7 +418,7 @@ tlsext_ecpf_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) static int tlsext_ri_client_needs(SSL *s, uint16_t msg_type) { - return (s->internal->renegotiate); + return (s->renegotiate); } static int @@ -779,7 +779,7 @@ tlsext_sni_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) goto err; } - if (s->internal->hit || s->s3->hs.tls13.hrr) { + if (s->hit || s->s3->hs.tls13.hrr) { if (s->session->tlsext_hostname == NULL) { *alert = SSL_AD_UNRECOGNIZED_NAME; goto err; @@ -817,7 +817,7 @@ tlsext_sni_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) static int tlsext_sni_server_needs(SSL *s, uint16_t msg_type) { - if (s->internal->hit) + if (s->hit) return 0; return (s->session->tlsext_hostname != NULL); @@ -837,7 +837,7 @@ tlsext_sni_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) return 0; } - if (s->internal->hit) { + if (s->hit) { if (s->session->tlsext_hostname == NULL) { *alert = SSL_AD_UNRECOGNIZED_NAME; return 0; @@ -885,12 +885,12 @@ tlsext_ocsp_client_build(SSL *s, uint16_t msg_type, CBB *cbb) return 0; if (!CBB_add_u16_length_prefixed(cbb, &respid_list)) return 0; - for (i = 0; i < sk_OCSP_RESPID_num(s->internal->tlsext_ocsp_ids); i++) { + for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { unsigned char *respid_data; OCSP_RESPID *id; size_t id_len; - if ((id = sk_OCSP_RESPID_value(s->internal->tlsext_ocsp_ids, + if ((id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i)) == NULL) return 0; if ((id_len = i2d_OCSP_RESPID(id, NULL)) == -1) @@ -904,12 +904,12 @@ tlsext_ocsp_client_build(SSL *s, uint16_t msg_type, CBB *cbb) } if (!CBB_add_u16_length_prefixed(cbb, &exts)) return 0; - if ((ext_len = i2d_X509_EXTENSIONS(s->internal->tlsext_ocsp_exts, + if ((ext_len = i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, NULL)) == -1) return 0; if (!CBB_add_space(&exts, &ext_data, ext_len)) return 0; - if ((i2d_X509_EXTENSIONS(s->internal->tlsext_ocsp_exts, &ext_data) != + if ((i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, &ext_data) != ext_len)) return 0; if (!CBB_flush(cbb)) @@ -946,11 +946,11 @@ tlsext_ocsp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) goto err; /* XXX */ - sk_OCSP_RESPID_pop_free(s->internal->tlsext_ocsp_ids, OCSP_RESPID_free); - s->internal->tlsext_ocsp_ids = NULL; + sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, OCSP_RESPID_free); + s->tlsext_ocsp_ids = NULL; if (CBS_len(&respid_list) > 0) { - s->internal->tlsext_ocsp_ids = sk_OCSP_RESPID_new_null(); - if (s->internal->tlsext_ocsp_ids == NULL) { + s->tlsext_ocsp_ids = sk_OCSP_RESPID_new_null(); + if (s->tlsext_ocsp_ids == NULL) { alert_desc = SSL_AD_INTERNAL_ERROR; goto err; } @@ -964,7 +964,7 @@ tlsext_ocsp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) p = CBS_data(&respid); if ((id = d2i_OCSP_RESPID(NULL, &p, CBS_len(&respid))) == NULL) goto err; - if (!sk_OCSP_RESPID_push(s->internal->tlsext_ocsp_ids, id)) { + if (!sk_OCSP_RESPID_push(s->tlsext_ocsp_ids, id)) { alert_desc = SSL_AD_INTERNAL_ERROR; OCSP_RESPID_free(id); goto err; @@ -975,10 +975,10 @@ tlsext_ocsp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) if (!CBS_get_u16_length_prefixed(cbs, &exts)) goto err; if (CBS_len(&exts) > 0) { - sk_X509_EXTENSION_pop_free(s->internal->tlsext_ocsp_exts, + sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, X509_EXTENSION_free); p = CBS_data(&exts); - if ((s->internal->tlsext_ocsp_exts = d2i_X509_EXTENSIONS(NULL, + if ((s->tlsext_ocsp_exts = d2i_X509_EXTENSIONS(NULL, &p, CBS_len(&exts))) == NULL) goto err; } @@ -995,14 +995,14 @@ tlsext_ocsp_server_needs(SSL *s, uint16_t msg_type) { if (s->s3->hs.negotiated_tls_version >= TLS1_3_VERSION && s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp && - s->ctx->internal->tlsext_status_cb != NULL) { - s->internal->tlsext_status_expected = 0; - if (s->ctx->internal->tlsext_status_cb(s, - s->ctx->internal->tlsext_status_arg) == SSL_TLSEXT_ERR_OK && - s->internal->tlsext_ocsp_resp_len > 0) - s->internal->tlsext_status_expected = 1; + s->ctx->tlsext_status_cb != NULL) { + s->tlsext_status_expected = 0; + if (s->ctx->tlsext_status_cb(s, + s->ctx->tlsext_status_arg) == SSL_TLSEXT_ERR_OK && + s->tlsext_ocsp_resp_len > 0) + s->tlsext_status_expected = 1; } - return s->internal->tlsext_status_expected; + return s->tlsext_status_expected; } static int @@ -1016,8 +1016,8 @@ tlsext_ocsp_server_build(SSL *s, uint16_t msg_type, CBB *cbb) if (!CBB_add_u24_length_prefixed(cbb, &ocsp_response)) return 0; if (!CBB_add_bytes(&ocsp_response, - s->internal->tlsext_ocsp_resp, - s->internal->tlsext_ocsp_resp_len)) + s->tlsext_ocsp_resp, + s->tlsext_ocsp_resp_len)) return 0; if (!CBB_flush(cbb)) return 0; @@ -1059,8 +1059,8 @@ tlsext_ocsp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) SSLerror(s, SSL_R_DATA_LENGTH_TOO_LONG); return 0; } - if (!CBS_stow(&response, &s->internal->tlsext_ocsp_resp, - &s->internal->tlsext_ocsp_resp_len)) { + if (!CBS_stow(&response, &s->tlsext_ocsp_resp, + &s->tlsext_ocsp_resp_len)) { *alert = SSL_AD_INTERNAL_ERROR; return 0; } @@ -1070,7 +1070,7 @@ tlsext_ocsp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) return 0; } /* Set flag to expect CertificateStatus message */ - s->internal->tlsext_status_expected = 1; + s->tlsext_status_expected = 1; } return 1; } @@ -1092,11 +1092,11 @@ tlsext_sessionticket_client_needs(SSL *s, uint16_t msg_type) if (!ssl_security_tickets(s)) return 0; - if (s->internal->new_session) + if (s->new_session) return 1; - if (s->internal->tlsext_session_ticket != NULL && - s->internal->tlsext_session_ticket->data == NULL) + if (s->tlsext_session_ticket != NULL && + s->tlsext_session_ticket->data == NULL) return 0; return 1; @@ -1109,7 +1109,7 @@ tlsext_sessionticket_client_build(SSL *s, uint16_t msg_type, CBB *cbb) * Signal that we support session tickets by sending an empty * extension when renegotiating or no session found. */ - if (s->internal->new_session || s->session == NULL) + if (s->new_session || s->session == NULL) return 1; if (s->session->tlsext_tick != NULL) { @@ -1118,18 +1118,18 @@ tlsext_sessionticket_client_build(SSL *s, uint16_t msg_type, CBB *cbb) s->session->tlsext_ticklen)) return 0; - } else if (s->internal->tlsext_session_ticket != NULL) { + } else if (s->tlsext_session_ticket != NULL) { /* * Attempt to resume with a custom provided session ticket set * by SSL_set_session_ticket_ext(). */ - if (s->internal->tlsext_session_ticket->length > 0) { - size_t ticklen = s->internal->tlsext_session_ticket->length; + if (s->tlsext_session_ticket->length > 0) { + size_t ticklen = s->tlsext_session_ticket->length; if ((s->session->tlsext_tick = malloc(ticklen)) == NULL) return 0; memcpy(s->session->tlsext_tick, - s->internal->tlsext_session_ticket->data, + s->tlsext_session_ticket->data, ticklen); s->session->tlsext_ticklen = ticklen; @@ -1149,10 +1149,10 @@ static int tlsext_sessionticket_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) { - if (s->internal->tls_session_ticket_ext_cb) { - if (!s->internal->tls_session_ticket_ext_cb(s, CBS_data(cbs), + if (s->tls_session_ticket_ext_cb) { + if (!s->tls_session_ticket_ext_cb(s, CBS_data(cbs), (int)CBS_len(cbs), - s->internal->tls_session_ticket_ext_cb_arg)) { + s->tls_session_ticket_ext_cb_arg)) { *alert = SSL_AD_INTERNAL_ERROR; return 0; } @@ -1170,7 +1170,7 @@ tlsext_sessionticket_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, static int tlsext_sessionticket_server_needs(SSL *s, uint16_t msg_type) { - return (s->internal->tlsext_ticket_expected && + return (s->tlsext_ticket_expected && !(SSL_get_options(s) & SSL_OP_NO_TICKET) && ssl_security_tickets(s)); } @@ -1186,10 +1186,10 @@ static int tlsext_sessionticket_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) { - if (s->internal->tls_session_ticket_ext_cb) { - if (!s->internal->tls_session_ticket_ext_cb(s, CBS_data(cbs), + if (s->tls_session_ticket_ext_cb) { + if (!s->tls_session_ticket_ext_cb(s, CBS_data(cbs), (int)CBS_len(cbs), - s->internal->tls_session_ticket_ext_cb_arg)) { + s->tls_session_ticket_ext_cb_arg)) { *alert = SSL_AD_INTERNAL_ERROR; return 0; } @@ -1200,7 +1200,7 @@ tlsext_sessionticket_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, return 0; } - s->internal->tlsext_ticket_expected = 1; + s->tlsext_ticket_expected = 1; return 1; } @@ -1310,7 +1310,7 @@ tlsext_srtp_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) goto err; if (cprof->id == sprof->id) { - s->internal->srtp_profile = sprof; + s->srtp_profile = sprof; ret = 1; goto done; } @@ -1397,7 +1397,7 @@ tlsext_srtp_client_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) } if (prof->id == id) { - s->internal->srtp_profile = prof; + s->srtp_profile = prof; return 1; } } @@ -1899,15 +1899,15 @@ tlsext_psk_server_parse(SSL *s, uint16_t msg_type, CBS *cbs, int *alert) static int tlsext_quic_transport_parameters_client_needs(SSL *s, uint16_t msg_type) { - return SSL_is_quic(s) && s->internal->quic_transport_params_len > 0; + return SSL_is_quic(s) && s->quic_transport_params_len > 0; } static int tlsext_quic_transport_parameters_client_build(SSL *s, uint16_t msg_type, CBB *cbb) { - if (!CBB_add_bytes(cbb, s->internal->quic_transport_params, - s->internal->quic_transport_params_len)) + if (!CBB_add_bytes(cbb, s->quic_transport_params, + s->quic_transport_params_len)) return 0; return 1; @@ -1934,15 +1934,15 @@ tlsext_quic_transport_parameters_client_parse(SSL *s, uint16_t msg_type, static int tlsext_quic_transport_parameters_server_needs(SSL *s, uint16_t msg_type) { - return SSL_is_quic(s) && s->internal->quic_transport_params_len > 0; + return SSL_is_quic(s) && s->quic_transport_params_len > 0; } static int tlsext_quic_transport_parameters_server_build(SSL *s, uint16_t msg_type, CBB *cbb) { - if (!CBB_add_bytes(cbb, s->internal->quic_transport_params, - s->internal->quic_transport_params_len)) + if (!CBB_add_bytes(cbb, s->quic_transport_params, + s->quic_transport_params_len)) return 0; return 1; @@ -2294,7 +2294,7 @@ tlsext_clienthello_hash_extension(SSL *s, uint16_t type, CBS *cbs) * RFC 8446 4.1.2. For subsequent CH, early data will be removed, * cookie may be added, padding may be removed. */ - struct tls13_ctx *ctx = s->internal->tls13; + struct tls13_ctx *ctx = s->tls13; if (type == TLSEXT_TYPE_early_data || type == TLSEXT_TYPE_cookie || type == TLSEXT_TYPE_padding) @@ -2344,11 +2344,11 @@ tlsext_parse(SSL *s, int is_server, uint16_t msg_type, CBS *cbs, int *alert) if (!CBS_get_u16_length_prefixed(&extensions, &extension_data)) goto err; - if (s->internal->tlsext_debug_cb != NULL) - s->internal->tlsext_debug_cb(s, !is_server, type, + if (s->tlsext_debug_cb != NULL) + s->tlsext_debug_cb(s, !is_server, type, (unsigned char *)CBS_data(&extension_data), CBS_len(&extension_data), - s->internal->tlsext_debug_arg); + s->tlsext_debug_arg); /* Unknown extensions are ignored. */ if ((tlsext = tls_extension_find(type, &idx)) == NULL) @@ -2397,7 +2397,7 @@ tlsext_server_reset_state(SSL *s) free(s->s3->alpn_selected); s->s3->alpn_selected = NULL; s->s3->alpn_selected_len = 0; - s->internal->srtp_profile = NULL; + s->srtp_profile = NULL; } int diff --git a/ssl/ssl_transcript.c b/ssl/ssl_transcript.c index e4a041f6..22cd6c3c 100644 --- a/ssl/ssl_transcript.c +++ b/ssl/ssl_transcript.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_transcript.c,v 1.8 2022/07/22 19:54:46 jsing Exp $ */ +/* $OpenBSD: ssl_transcript.c,v 1.9 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2017 Joel Sing * @@ -17,7 +17,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" #include "tls_internal.h" int diff --git a/ssl/ssl_txt.c b/ssl/ssl_txt.c index 2b95c28f..79da59a0 100644 --- a/ssl/ssl_txt.c +++ b/ssl/ssl_txt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_txt.c,v 1.35 2022/06/07 17:55:08 tb Exp $ */ +/* $OpenBSD: ssl_txt.c,v 1.36 2022/11/26 16:08:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -87,7 +87,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x) diff --git a/ssl/ssl_versions.c b/ssl/ssl_versions.c index 4a58f14c..fbc0004f 100644 --- a/ssl/ssl_versions.c +++ b/ssl/ssl_versions.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_versions.c,v 1.24 2022/09/11 18:13:30 jsing Exp $ */ +/* $OpenBSD: ssl_versions.c,v 1.26 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2016, 2017 Joel Sing * @@ -15,7 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "ssl_locl.h" +#include "ssl_local.h" static uint16_t ssl_dtls_to_tls_version(uint16_t dtls_ver) @@ -140,13 +140,13 @@ ssl_enabled_tls_version_range(SSL *s, uint16_t *min_ver, uint16_t *max_ver) min_version = 0; max_version = TLS1_3_VERSION; - options = s->internal->options; + options = s->options; if (SSL_is_dtls(s)) { options = 0; - if (s->internal->options & SSL_OP_NO_DTLSv1) + if (s->options & SSL_OP_NO_DTLSv1) options |= SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1; - if (s->internal->options & SSL_OP_NO_DTLSv1_2) + if (s->options & SSL_OP_NO_DTLSv1_2) options |= SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_2; } @@ -174,7 +174,7 @@ ssl_enabled_tls_version_range(SSL *s, uint16_t *min_ver, uint16_t *max_ver) /* Limit to configured version range. */ if (!ssl_clamp_tls_version_range(&min_version, &max_version, - s->internal->min_tls_version, s->internal->max_tls_version)) + s->min_tls_version, s->max_tls_version)) return 0; /* QUIC requires a minimum of TLSv1.3. */ diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c index c996159a..c6140e9b 100644 --- a/ssl/t1_enc.c +++ b/ssl/t1_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_enc.c,v 1.154 2022/02/05 14:54:10 jsing Exp $ */ +/* $OpenBSD: t1_enc.c,v 1.157 2022/11/26 16:08:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -143,8 +143,8 @@ #include #include -#include "dtls_locl.h" -#include "ssl_locl.h" +#include "dtls_local.h" +#include "ssl_local.h" void tls1_cleanup_key_block(SSL *s) @@ -311,13 +311,13 @@ tls1_change_cipher_state(SSL *s, int is_write) } if (!is_write) { - if (!tls12_record_layer_change_read_cipher_state(s->internal->rl, + if (!tls12_record_layer_change_read_cipher_state(s->rl, &mac_key, &key, &iv)) goto err; if (SSL_is_dtls(s)) dtls1_reset_read_seq_numbers(s); } else { - if (!tls12_record_layer_change_write_cipher_state(s->internal->rl, + if (!tls12_record_layer_change_write_cipher_state(s->rl, &mac_key, &key, &iv)) goto err; } @@ -375,8 +375,8 @@ tls1_setup_key_block(SSL *s) if (!ssl_get_handshake_evp_md(s, &handshake_hash)) return (0); - tls12_record_layer_set_aead(s->internal->rl, aead); - tls12_record_layer_set_cipher_hash(s->internal->rl, cipher, + tls12_record_layer_set_aead(s->rl, aead); + tls12_record_layer_set_cipher_hash(s->rl, cipher, handshake_hash, mac_hash); if ((key_block = tls12_key_block_new()) == NULL) @@ -387,7 +387,7 @@ tls1_setup_key_block(SSL *s) s->s3->hs.tls12.key_block = key_block; key_block = NULL; - if (!(s->internal->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) && + if (!(s->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) && s->method->version <= TLS1_VERSION) { /* * Enable vulnerability countermeasure for CBC ciphers with @@ -413,83 +413,3 @@ tls1_setup_key_block(SSL *s) return (ret); } - -int -tls1_export_keying_material(SSL *s, unsigned char *out, size_t olen, - const char *label, size_t llen, const unsigned char *context, - size_t contextlen, int use_context) -{ - unsigned char *val = NULL; - size_t vallen, currentvalpos; - int rv; - - if (!SSL_is_init_finished(s)) { - SSLerror(s, SSL_R_BAD_STATE); - return 0; - } - - /* construct PRF arguments - * we construct the PRF argument ourself rather than passing separate - * values into the TLS PRF to ensure that the concatenation of values - * does not create a prohibited label. - */ - vallen = llen + SSL3_RANDOM_SIZE * 2; - if (use_context) { - vallen += 2 + contextlen; - } - - val = malloc(vallen); - if (val == NULL) - goto err2; - currentvalpos = 0; - memcpy(val + currentvalpos, (unsigned char *) label, llen); - currentvalpos += llen; - memcpy(val + currentvalpos, s->s3->client_random, SSL3_RANDOM_SIZE); - currentvalpos += SSL3_RANDOM_SIZE; - memcpy(val + currentvalpos, s->s3->server_random, SSL3_RANDOM_SIZE); - currentvalpos += SSL3_RANDOM_SIZE; - - if (use_context) { - val[currentvalpos] = (contextlen >> 8) & 0xff; - currentvalpos++; - val[currentvalpos] = contextlen & 0xff; - currentvalpos++; - if ((contextlen > 0) || (context != NULL)) { - memcpy(val + currentvalpos, context, contextlen); - } - } - - /* disallow prohibited labels - * note that SSL3_RANDOM_SIZE > max(prohibited label len) = - * 15, so size of val > max(prohibited label len) = 15 and the - * comparisons won't have buffer overflow - */ - if (memcmp(val, TLS_MD_CLIENT_FINISH_CONST, - TLS_MD_CLIENT_FINISH_CONST_SIZE) == 0) - goto err1; - if (memcmp(val, TLS_MD_SERVER_FINISH_CONST, - TLS_MD_SERVER_FINISH_CONST_SIZE) == 0) - goto err1; - if (memcmp(val, TLS_MD_MASTER_SECRET_CONST, - TLS_MD_MASTER_SECRET_CONST_SIZE) == 0) - goto err1; - if (memcmp(val, TLS_MD_KEY_EXPANSION_CONST, - TLS_MD_KEY_EXPANSION_CONST_SIZE) == 0) - goto err1; - - rv = tls1_PRF(s, s->session->master_key, s->session->master_key_length, - val, vallen, NULL, 0, NULL, 0, NULL, 0, NULL, 0, out, olen); - - goto ret; - err1: - SSLerror(s, SSL_R_TLS_ILLEGAL_EXPORTER_LABEL); - rv = 0; - goto ret; - err2: - SSLerror(s, ERR_R_MALLOC_FAILURE); - rv = 0; - ret: - free(val); - - return (rv); -} diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index 355c9827..85d5eaa6 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_lib.c,v 1.195 2022/08/17 18:45:25 tb Exp $ */ +/* $OpenBSD: t1_lib.c,v 1.197 2022/11/26 16:08:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -117,7 +117,7 @@ #include #include "bytestring.h" -#include "ssl_locl.h" +#include "ssl_local.h" #include "ssl_sigalgs.h" #include "ssl_tlsext.h" @@ -139,7 +139,7 @@ tls1_free(SSL *s) if (s == NULL) return; - free(s->internal->tlsext_session_ticket); + free(s->tlsext_session_ticket); ssl3_free(s); } @@ -404,8 +404,8 @@ tls1_get_formatlist(const SSL *s, int client_formats, const uint8_t **pformats, return; } - *pformats = s->internal->tlsext_ecpointformatlist; - *pformatslen = s->internal->tlsext_ecpointformatlist_length; + *pformats = s->tlsext_ecpointformatlist; + *pformatslen = s->tlsext_ecpointformatlist_length; if (*pformats == NULL) { *pformats = ecformats_default; *pformatslen = sizeof(ecformats_default); @@ -427,8 +427,8 @@ tls1_get_group_list(const SSL *s, int client_groups, const uint16_t **pgroups, return; } - *pgroups = s->internal->tlsext_supportedgroups; - *pgroupslen = s->internal->tlsext_supportedgroups_length; + *pgroups = s->tlsext_supportedgroups; + *pgroupslen = s->tlsext_supportedgroups_length; if (*pgroups != NULL) return; @@ -451,7 +451,7 @@ tls1_get_group_lists(const SSL *ssl, const uint16_t **pref, size_t *preflen, if (!ssl->server) return 0; - server_pref = (ssl->internal->options & SSL_OP_CIPHER_SERVER_PREFERENCE); + server_pref = (ssl->options & SSL_OP_CIPHER_SERVER_PREFERENCE); tls1_get_group_list(ssl, (server_pref == 0), pref, preflen); tls1_get_group_list(ssl, (server_pref != 0), supp, supplen); @@ -738,12 +738,12 @@ ssl_check_clienthello_tlsext_early(SSL *s) * ssl3_choose_cipher in s3_lib.c. */ - if (s->ctx != NULL && s->ctx->internal->tlsext_servername_callback != 0) - ret = s->ctx->internal->tlsext_servername_callback(s, &al, - s->ctx->internal->tlsext_servername_arg); - else if (s->initial_ctx != NULL && s->initial_ctx->internal->tlsext_servername_callback != 0) - ret = s->initial_ctx->internal->tlsext_servername_callback(s, &al, - s->initial_ctx->internal->tlsext_servername_arg); + if (s->ctx != NULL && s->ctx->tlsext_servername_callback != 0) + ret = s->ctx->tlsext_servername_callback(s, &al, + s->ctx->tlsext_servername_arg); + else if (s->initial_ctx != NULL && s->initial_ctx->tlsext_servername_callback != 0) + ret = s->initial_ctx->tlsext_servername_callback(s, &al, + s->initial_ctx->tlsext_servername_arg); switch (ret) { case SSL_TLSEXT_ERR_ALERT_FATAL: @@ -770,32 +770,32 @@ ssl_check_clienthello_tlsext_late(SSL *s) * has been chosen because this may influence which certificate is sent */ if ((s->tlsext_status_type != -1) && - s->ctx && s->ctx->internal->tlsext_status_cb) { + s->ctx && s->ctx->tlsext_status_cb) { int r; SSL_CERT_PKEY *certpkey; certpkey = ssl_get_server_send_pkey(s); /* If no certificate can't return certificate status */ if (certpkey == NULL) { - s->internal->tlsext_status_expected = 0; + s->tlsext_status_expected = 0; return 1; } /* Set current certificate to one we will use so * SSL_get_certificate et al can pick it up. */ s->cert->key = certpkey; - r = s->ctx->internal->tlsext_status_cb(s, - s->ctx->internal->tlsext_status_arg); + r = s->ctx->tlsext_status_cb(s, + s->ctx->tlsext_status_arg); switch (r) { /* We don't want to send a status request response */ case SSL_TLSEXT_ERR_NOACK: - s->internal->tlsext_status_expected = 0; + s->tlsext_status_expected = 0; break; /* status request response should be sent */ case SSL_TLSEXT_ERR_OK: - if (s->internal->tlsext_ocsp_resp) - s->internal->tlsext_status_expected = 1; + if (s->tlsext_ocsp_resp) + s->tlsext_status_expected = 1; else - s->internal->tlsext_status_expected = 0; + s->tlsext_status_expected = 0; break; /* something bad happened */ case SSL_TLSEXT_ERR_ALERT_FATAL: @@ -804,7 +804,7 @@ ssl_check_clienthello_tlsext_late(SSL *s) goto err; } } else - s->internal->tlsext_status_expected = 0; + s->tlsext_status_expected = 0; err: switch (ret) { @@ -827,26 +827,26 @@ ssl_check_serverhello_tlsext(SSL *s) ret = SSL_TLSEXT_ERR_OK; - if (s->ctx != NULL && s->ctx->internal->tlsext_servername_callback != 0) - ret = s->ctx->internal->tlsext_servername_callback(s, &al, - s->ctx->internal->tlsext_servername_arg); - else if (s->initial_ctx != NULL && s->initial_ctx->internal->tlsext_servername_callback != 0) - ret = s->initial_ctx->internal->tlsext_servername_callback(s, &al, - s->initial_ctx->internal->tlsext_servername_arg); + if (s->ctx != NULL && s->ctx->tlsext_servername_callback != 0) + ret = s->ctx->tlsext_servername_callback(s, &al, + s->ctx->tlsext_servername_arg); + else if (s->initial_ctx != NULL && s->initial_ctx->tlsext_servername_callback != 0) + ret = s->initial_ctx->tlsext_servername_callback(s, &al, + s->initial_ctx->tlsext_servername_arg); /* If we've requested certificate status and we wont get one * tell the callback */ - if ((s->tlsext_status_type != -1) && !(s->internal->tlsext_status_expected) && - s->ctx && s->ctx->internal->tlsext_status_cb) { + if ((s->tlsext_status_type != -1) && !(s->tlsext_status_expected) && + s->ctx && s->ctx->tlsext_status_cb) { int r; - free(s->internal->tlsext_ocsp_resp); - s->internal->tlsext_ocsp_resp = NULL; - s->internal->tlsext_ocsp_resp_len = 0; + free(s->tlsext_ocsp_resp); + s->tlsext_ocsp_resp = NULL; + s->tlsext_ocsp_resp_len = 0; - r = s->ctx->internal->tlsext_status_cb(s, - s->ctx->internal->tlsext_status_arg); + r = s->ctx->tlsext_status_cb(s, + s->ctx->tlsext_status_arg); if (r == 0) { al = SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE; ret = SSL_TLSEXT_ERR_ALERT_FATAL; @@ -878,27 +878,27 @@ ssl_check_serverhello_tlsext(SSL *s) * ret: (output) on return, if a ticket was decrypted, then this is set to * point to the resulting session. * - * If s->internal->tls_session_secret_cb is set then we are expecting a pre-shared key + * If s->tls_session_secret_cb is set then we are expecting a pre-shared key * ciphersuite, in which case we have no use for session tickets and one will - * never be decrypted, nor will s->internal->tlsext_ticket_expected be set to 1. + * never be decrypted, nor will s->tlsext_ticket_expected be set to 1. * * Returns: * TLS1_TICKET_FATAL_ERROR: error from parsing or decrypting the ticket. * TLS1_TICKET_NONE: no ticket was found (or was ignored, based on settings). * TLS1_TICKET_EMPTY: a zero length extension was found, indicating that the * client supports session tickets but doesn't currently have one to offer. - * TLS1_TICKET_NOT_DECRYPTED: either s->internal->tls_session_secret_cb was + * TLS1_TICKET_NOT_DECRYPTED: either s->tls_session_secret_cb was * set, or a ticket was offered but couldn't be decrypted because of a * non-fatal error. * TLS1_TICKET_DECRYPTED: a ticket was successfully decrypted and *ret was set. * * Side effects: - * Sets s->internal->tlsext_ticket_expected to 1 if the server will have to issue + * Sets s->tlsext_ticket_expected to 1 if the server will have to issue * a new session ticket to the client because the client indicated support - * (and s->internal->tls_session_secret_cb is NULL) but the client either doesn't have + * (and s->tls_session_secret_cb is NULL) but the client either doesn't have * a session ticket or we couldn't use the one it gave us, or if * s->ctx->tlsext_ticket_key_cb asked to renew the client's ticket. - * Otherwise, s->internal->tlsext_ticket_expected is set to 0. + * Otherwise, s->tlsext_ticket_expected is set to 0. */ int tls1_process_ticket(SSL *s, CBS *ext_block, int *alert, SSL_SESSION **ret) @@ -906,7 +906,7 @@ tls1_process_ticket(SSL *s, CBS *ext_block, int *alert, SSL_SESSION **ret) CBS extensions, ext_data; uint16_t ext_type = 0; - s->internal->tlsext_ticket_expected = 0; + s->tlsext_ticket_expected = 0; *ret = NULL; /* @@ -947,11 +947,11 @@ tls1_process_ticket(SSL *s, CBS *ext_block, int *alert, SSL_SESSION **ret) * The client will accept a ticket but does not currently * have one. */ - s->internal->tlsext_ticket_expected = 1; + s->tlsext_ticket_expected = 1; return TLS1_TICKET_EMPTY; } - if (s->internal->tls_session_secret_cb != NULL) { + if (s->tls_session_secret_cb != NULL) { /* * Indicate that the ticket could not be decrypted rather than * generating the session from ticket now, trigger abbreviated @@ -1004,7 +1004,7 @@ tls_decrypt_ticket(SSL *s, CBS *ticket, int *alert, SSL_SESSION **psess) if ((hctx = HMAC_CTX_new()) == NULL) goto err; - if (tctx->internal->tlsext_ticket_key_cb != NULL) { + if (tctx->tlsext_ticket_key_cb != NULL) { int rv; /* @@ -1016,7 +1016,7 @@ tls_decrypt_ticket(SSL *s, CBS *ticket, int *alert, SSL_SESSION **psess) if (CBS_len(ticket) < EVP_MAX_IV_LENGTH) goto derr; - if ((rv = tctx->internal->tlsext_ticket_key_cb(s, + if ((rv = tctx->tlsext_ticket_key_cb(s, (unsigned char *)CBS_data(&ticket_name), (unsigned char *)CBS_data(ticket), cctx, hctx, 0)) < 0) goto err; @@ -1024,7 +1024,7 @@ tls_decrypt_ticket(SSL *s, CBS *ticket, int *alert, SSL_SESSION **psess) goto derr; if (rv == 2) { /* Renew ticket. */ - s->internal->tlsext_ticket_expected = 1; + s->tlsext_ticket_expected = 1; } /* @@ -1037,17 +1037,17 @@ tls_decrypt_ticket(SSL *s, CBS *ticket, int *alert, SSL_SESSION **psess) } else { /* Check that the key name matches. */ if (!CBS_mem_equal(&ticket_name, - tctx->internal->tlsext_tick_key_name, - sizeof(tctx->internal->tlsext_tick_key_name))) + tctx->tlsext_tick_key_name, + sizeof(tctx->tlsext_tick_key_name))) goto derr; if (!CBS_get_bytes(ticket, &ticket_iv, EVP_CIPHER_iv_length(EVP_aes_128_cbc()))) goto derr; if (!EVP_DecryptInit_ex(cctx, EVP_aes_128_cbc(), NULL, - tctx->internal->tlsext_tick_aes_key, CBS_data(&ticket_iv))) + tctx->tlsext_tick_aes_key, CBS_data(&ticket_iv))) goto err; - if (!HMAC_Init_ex(hctx, tctx->internal->tlsext_tick_hmac_key, - sizeof(tctx->internal->tlsext_tick_hmac_key), EVP_sha256(), + if (!HMAC_Init_ex(hctx, tctx->tlsext_tick_hmac_key, + sizeof(tctx->tlsext_tick_hmac_key), EVP_sha256(), NULL)) goto err; } @@ -1113,7 +1113,7 @@ tls_decrypt_ticket(SSL *s, CBS *ticket, int *alert, SSL_SESSION **psess) derr: ERR_clear_error(); - s->internal->tlsext_ticket_expected = 1; + s->tlsext_ticket_expected = 1; ret = TLS1_TICKET_NOT_DECRYPTED; goto done; diff --git a/ssl/tls12_internal.h b/ssl/tls12_internal.h new file mode 100644 index 00000000..d416b2e3 --- /dev/null +++ b/ssl/tls12_internal.h @@ -0,0 +1,29 @@ +/* $OpenBSD: tls12_internal.h,v 1.1 2022/11/07 11:58:45 jsing Exp $ */ +/* + * Copyright (c) 2022 Joel Sing + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef HEADER_TLS12_INTERNAL_H +#define HEADER_TLS12_INTERNAL_H + +__BEGIN_HIDDEN_DECLS + +int tls12_exporter(SSL *s, const uint8_t *label, size_t label_len, + const uint8_t *context_value, size_t context_value_len, int use_context, + uint8_t *out, size_t out_len); + +__END_HIDDEN_DECLS + +#endif diff --git a/ssl/tls12_key_schedule.c b/ssl/tls12_key_schedule.c index c206460d..6d714c11 100644 --- a/ssl/tls12_key_schedule.c +++ b/ssl/tls12_key_schedule.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls12_key_schedule.c,v 1.1 2021/05/05 10:05:27 jsing Exp $ */ +/* $OpenBSD: tls12_key_schedule.c,v 1.3 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2021 Joel Sing * @@ -20,7 +20,8 @@ #include #include "bytestring.h" -#include "ssl_locl.h" +#include "ssl_local.h" +#include "tls12_internal.h" struct tls12_key_block { CBS client_write_mac_key; @@ -173,3 +174,122 @@ tls12_key_block_generate(struct tls12_key_block *kb, SSL *s, return 0; } + +struct tls12_reserved_label { + const char *label; + size_t label_len; +}; + +/* + * RFC 5705 section 6. + */ +static const struct tls12_reserved_label tls12_reserved_labels[] = { + { + .label = TLS_MD_CLIENT_FINISH_CONST, + .label_len = TLS_MD_CLIENT_FINISH_CONST_SIZE, + }, + { + .label = TLS_MD_SERVER_FINISH_CONST, + .label_len = TLS_MD_SERVER_FINISH_CONST_SIZE, + }, + { + .label = TLS_MD_MASTER_SECRET_CONST, + .label_len = TLS_MD_MASTER_SECRET_CONST_SIZE, + }, + { + .label = TLS_MD_KEY_EXPANSION_CONST, + .label_len = TLS_MD_KEY_EXPANSION_CONST_SIZE, + }, + { + .label = NULL, + .label_len = 0, + }, +}; + +int +tls12_exporter(SSL *s, const uint8_t *label, size_t label_len, + const uint8_t *context_value, size_t context_value_len, int use_context, + uint8_t *out, size_t out_len) +{ + uint8_t *data = NULL; + size_t data_len = 0; + CBB cbb, context; + CBS seed; + size_t i; + int ret = 0; + + /* + * RFC 5705 - Key Material Exporters for TLS. + */ + + memset(&cbb, 0, sizeof(cbb)); + + if (!SSL_is_init_finished(s)) { + SSLerror(s, SSL_R_BAD_STATE); + goto err; + } + + if (s->s3->hs.negotiated_tls_version >= TLS1_3_VERSION) + goto err; + + /* + * Due to exceptional design choices, we need to build a concatenation + * of the label and the seed value, before checking for reserved + * labels. This prevents a reserved label from being split across the + * label and the seed (that includes the client random), which are + * concatenated by the PRF. + */ + if (!CBB_init(&cbb, 0)) + goto err; + if (!CBB_add_bytes(&cbb, label, label_len)) + goto err; + if (!CBB_add_bytes(&cbb, s->s3->client_random, SSL3_RANDOM_SIZE)) + goto err; + if (!CBB_add_bytes(&cbb, s->s3->server_random, SSL3_RANDOM_SIZE)) + goto err; + if (use_context) { + if (!CBB_add_u16_length_prefixed(&cbb, &context)) + goto err; + if (context_value_len > 0) { + if (!CBB_add_bytes(&context, context_value, + context_value_len)) + goto err; + } + } + if (!CBB_finish(&cbb, &data, &data_len)) + goto err; + + /* + * Ensure that the block (label + seed) does not start with a reserved + * label - in an ideal world we would ensure that the label has an + * explicitly permitted prefix instead, but of course this also got + * messed up by the standards. + */ + for (i = 0; tls12_reserved_labels[i].label != NULL; i++) { + /* XXX - consider adding/using CBS_has_prefix(). */ + if (tls12_reserved_labels[i].label_len > data_len) + goto err; + if (memcmp(data, tls12_reserved_labels[i].label, + tls12_reserved_labels[i].label_len) == 0) { + SSLerror(s, SSL_R_TLS_ILLEGAL_EXPORTER_LABEL); + goto err; + } + } + + CBS_init(&seed, data, data_len); + if (!CBS_skip(&seed, label_len)) + goto err; + + if (!tls1_PRF(s, s->session->master_key, s->session->master_key_length, + label, label_len, CBS_data(&seed), CBS_len(&seed), NULL, 0, NULL, 0, + NULL, 0, out, out_len)) + goto err; + + ret = 1; + + err: + freezero(data, data_len); + CBB_cleanup(&cbb); + + return ret; +} diff --git a/ssl/tls12_lib.c b/ssl/tls12_lib.c index 14c8fd53..96b3abcd 100644 --- a/ssl/tls12_lib.c +++ b/ssl/tls12_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls12_lib.c,v 1.5 2022/06/07 17:19:09 tb Exp $ */ +/* $OpenBSD: tls12_lib.c,v 1.6 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2021 Joel Sing * @@ -15,7 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "ssl_locl.h" +#include "ssl_local.h" static int tls12_finished_verify_data(SSL *s, const char *finished_label, diff --git a/ssl/tls12_record_layer.c b/ssl/tls12_record_layer.c index 3568e187..59f5d324 100644 --- a/ssl/tls12_record_layer.c +++ b/ssl/tls12_record_layer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls12_record_layer.c,v 1.36 2022/01/14 09:12:15 tb Exp $ */ +/* $OpenBSD: tls12_record_layer.c,v 1.38 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2020 Joel Sing * @@ -20,7 +20,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" #define TLS12_RECORD_SEQ_NUM_LEN 8 #define TLS12_AEAD_FIXED_NONCE_MAX_LEN 12 @@ -864,28 +864,25 @@ tls12_record_layer_aead_xored_nonce(struct tls12_record_layer *rl, static int tls12_record_layer_open_record_plaintext(struct tls12_record_layer *rl, - uint8_t content_type, CBS *fragment, uint8_t **out, size_t *out_len) + uint8_t content_type, CBS *fragment, struct tls_content *out) { if (tls12_record_protection_engaged(rl->read)) return 0; - /* XXX - decrypt/process in place for now. */ - *out = (uint8_t *)CBS_data(fragment); - *out_len = CBS_len(fragment); - - return 1; + return tls_content_dup_data(out, content_type, CBS_data(fragment), + CBS_len(fragment)); } static int tls12_record_layer_open_record_protected_aead(struct tls12_record_layer *rl, - uint8_t content_type, CBS *seq_num, CBS *fragment, uint8_t **out, - size_t *out_len) + uint8_t content_type, CBS *seq_num, CBS *fragment, struct tls_content *out) { struct tls12_record_protection *rp = rl->read; uint8_t *header = NULL; size_t header_len = 0; - uint8_t *plain; - size_t plain_len; + uint8_t *content = NULL; + size_t content_len = 0; + size_t out_len = 0; CBS var_nonce; int ret = 0; @@ -913,43 +910,47 @@ tls12_record_layer_open_record_protected_aead(struct tls12_record_layer *rl, goto err; } - /* XXX - decrypt/process in place for now. */ - plain = (uint8_t *)CBS_data(fragment); - plain_len = CBS_len(fragment) - rp->aead_tag_len; + content_len = CBS_len(fragment) - rp->aead_tag_len; + if ((content = calloc(1, CBS_len(fragment))) == NULL) { + content_len = 0; + goto err; + } - if (!tls12_record_layer_pseudo_header(rl, content_type, plain_len, + if (!tls12_record_layer_pseudo_header(rl, content_type, content_len, seq_num, &header, &header_len)) goto err; - if (!EVP_AEAD_CTX_open(rp->aead_ctx, plain, out_len, plain_len, + if (!EVP_AEAD_CTX_open(rp->aead_ctx, content, &out_len, content_len, rp->aead_nonce, rp->aead_nonce_len, CBS_data(fragment), CBS_len(fragment), header, header_len)) { rl->alert_desc = SSL_AD_BAD_RECORD_MAC; goto err; } - if (*out_len > SSL3_RT_MAX_PLAIN_LENGTH) { + if (out_len > SSL3_RT_MAX_PLAIN_LENGTH) { rl->alert_desc = SSL_AD_RECORD_OVERFLOW; goto err; } - if (*out_len != plain_len) + if (out_len != content_len) goto err; - *out = plain; + tls_content_set_data(out, content_type, content, content_len); + content = NULL; + content_len = 0; ret = 1; err: freezero(header, header_len); + freezero(content, content_len); return ret; } static int tls12_record_layer_open_record_protected_cipher(struct tls12_record_layer *rl, - uint8_t content_type, CBS *seq_num, CBS *fragment, uint8_t **out, - size_t *out_len) + uint8_t content_type, CBS *seq_num, CBS *fragment, struct tls_content *out) { EVP_CIPHER_CTX *enc = rl->read->cipher_ctx; SSL3_RECORD_INTERNAL rrec; @@ -958,8 +959,8 @@ tls12_record_layer_open_record_protected_cipher(struct tls12_record_layer *rl, size_t mac_len = 0; uint8_t *out_mac = NULL; size_t out_mac_len = 0; - uint8_t *plain; - size_t plain_len; + uint8_t *content = NULL; + size_t content_len = 0; size_t min_len; CBB cbb_mac; int ret = 0; @@ -1001,16 +1002,16 @@ tls12_record_layer_open_record_protected_cipher(struct tls12_record_layer *rl, goto err; } - /* XXX - decrypt/process in place for now. */ - plain = (uint8_t *)CBS_data(fragment); - plain_len = CBS_len(fragment); + if ((content = calloc(1, CBS_len(fragment))) == NULL) + goto err; + content_len = CBS_len(fragment); - if (!EVP_Cipher(enc, plain, CBS_data(fragment), plain_len)) + if (!EVP_Cipher(enc, content, CBS_data(fragment), CBS_len(fragment))) goto err; - rrec.data = plain; - rrec.input = plain; - rrec.length = plain_len; + rrec.data = content; + rrec.input = content; + rrec.length = content_len; /* * We now have to remove padding, extract MAC, calculate MAC @@ -1058,8 +1059,13 @@ tls12_record_layer_open_record_protected_cipher(struct tls12_record_layer *rl, goto err; } - *out = rrec.data; - *out_len = rrec.length; + tls_content_set_data(out, content_type, content, content_len); + content = NULL; + content_len = 0; + + /* Actual content is after EIV, minus padding and MAC. */ + if (!tls_content_set_bounds(out, eiv_len, rrec.length)) + goto err; ret = 1; @@ -1067,13 +1073,14 @@ tls12_record_layer_open_record_protected_cipher(struct tls12_record_layer *rl, CBB_cleanup(&cbb_mac); freezero(mac, mac_len); freezero(out_mac, out_mac_len); + freezero(content, content_len); return ret; } int tls12_record_layer_open_record(struct tls12_record_layer *rl, uint8_t *buf, - size_t buf_len, uint8_t **out, size_t *out_len) + size_t buf_len, struct tls_content *out) { CBS cbs, fragment, seq_num; uint16_t version; @@ -1105,15 +1112,15 @@ tls12_record_layer_open_record(struct tls12_record_layer *rl, uint8_t *buf, if (rl->read->aead_ctx != NULL) { if (!tls12_record_layer_open_record_protected_aead(rl, - content_type, &seq_num, &fragment, out, out_len)) + content_type, &seq_num, &fragment, out)) return 0; } else if (rl->read->cipher_ctx != NULL) { if (!tls12_record_layer_open_record_protected_cipher(rl, - content_type, &seq_num, &fragment, out, out_len)) + content_type, &seq_num, &fragment, out)) return 0; } else { if (!tls12_record_layer_open_record_plaintext(rl, - content_type, &fragment, out, out_len)) + content_type, &fragment, out)) return 0; } diff --git a/ssl/tls13_client.c b/ssl/tls13_client.c index 33ef55d2..3555ebad 100644 --- a/ssl/tls13_client.c +++ b/ssl/tls13_client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_client.c,v 1.99 2022/09/11 14:33:07 jsing Exp $ */ +/* $OpenBSD: tls13_client.c,v 1.101 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2018, 2019 Joel Sing * @@ -18,7 +18,7 @@ #include #include "bytestring.h" -#include "ssl_locl.h" +#include "ssl_local.h" #include "ssl_sigalgs.h" #include "ssl_tlsext.h" #include "tls13_handshake.h" @@ -39,7 +39,7 @@ tls13_client_init(struct tls13_ctx *ctx) s->version = ctx->hs->our_max_tls_version; tls13_record_layer_set_retry_after_phh(ctx->rl, - (s->internal->mode & SSL_MODE_AUTO_RETRY) != 0); + (s->mode & SSL_MODE_AUTO_RETRY) != 0); if (!ssl_get_new_session(s, 0)) /* XXX */ return 0; diff --git a/ssl/tls13_handshake.c b/ssl/tls13_handshake.c index c40442fd..9723edfe 100644 --- a/ssl/tls13_handshake.c +++ b/ssl/tls13_handshake.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_handshake.c,v 1.71 2022/04/19 17:01:43 tb Exp $ */ +/* $OpenBSD: tls13_handshake.c,v 1.72 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2018-2021 Theo Buehler * Copyright (c) 2019 Joel Sing @@ -18,7 +18,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" #include "tls13_handshake.h" #include "tls13_internal.h" diff --git a/ssl/tls13_key_schedule.c b/ssl/tls13_key_schedule.c index d88faab0..05bcf0f0 100644 --- a/ssl/tls13_key_schedule.c +++ b/ssl/tls13_key_schedule.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_key_schedule.c,v 1.15 2022/07/07 17:09:45 tb Exp $ */ +/* $OpenBSD: tls13_key_schedule.c,v 1.18 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2018, Bob Beck * @@ -21,6 +21,7 @@ #include #include "bytestring.h" +#include "ssl_local.h" #include "tls13_internal.h" int @@ -175,7 +176,11 @@ tls13_hkdf_expand_label_with_length(struct tls13_secret *out, int ret; if (!CBB_init(&cbb, 256)) - return 0; + goto err; + + if (out->data == NULL || out->len == 0) + goto err; + if (!CBB_add_u16(&cbb, out->len)) goto err; if (!CBB_add_u8_length_prefixed(&cbb, &child)) @@ -381,3 +386,73 @@ tls13_update_server_traffic_secret(struct tls13_secrets *secrets) secrets->digest, &secrets->server_application_traffic, "traffic upd", &context); } + +int +tls13_exporter(struct tls13_ctx *ctx, const uint8_t *label, size_t label_len, + const uint8_t *context_value, size_t context_value_len, uint8_t *out, + size_t out_len) +{ + struct tls13_secret context, export_out, export_secret; + struct tls13_secrets *secrets = ctx->hs->tls13.secrets; + EVP_MD_CTX *md_ctx = NULL; + unsigned int md_out_len; + int md_len; + int ret = 0; + + /* + * RFC 8446 Section 7.5. + */ + + memset(&context, 0, sizeof(context)); + memset(&export_secret, 0, sizeof(export_secret)); + + export_out.data = out; + export_out.len = out_len; + + if (!ctx->handshake_completed) + return 0; + + md_len = EVP_MD_size(secrets->digest); + if (md_len <= 0 || md_len > EVP_MAX_MD_SIZE) + goto err; + + if (!tls13_secret_init(&export_secret, md_len)) + goto err; + if (!tls13_secret_init(&context, md_len)) + goto err; + + /* In TLSv1.3 no context is equivalent to an empty context. */ + if (context_value == NULL) { + context_value = ""; + context_value_len = 0; + } + + if ((md_ctx = EVP_MD_CTX_new()) == NULL) + goto err; + if (!EVP_DigestInit_ex(md_ctx, secrets->digest, NULL)) + goto err; + if (!EVP_DigestUpdate(md_ctx, context_value, context_value_len)) + goto err; + if (!EVP_DigestFinal_ex(md_ctx, context.data, &md_out_len)) + goto err; + if (md_len != md_out_len) + goto err; + + if (!tls13_derive_secret_with_label_length(&export_secret, + secrets->digest, &secrets->exporter_master, label, label_len, + &secrets->empty_hash)) + goto err; + + if (!tls13_hkdf_expand_label(&export_out, secrets->digest, + &export_secret, "exporter", &context)) + goto err; + + ret = 1; + + err: + EVP_MD_CTX_free(md_ctx); + tls13_secret_cleanup(&context); + tls13_secret_cleanup(&export_secret); + + return ret; +} diff --git a/ssl/tls13_legacy.c b/ssl/tls13_legacy.c index 545f2cd9..1d6a5a12 100644 --- a/ssl/tls13_legacy.c +++ b/ssl/tls13_legacy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_legacy.c,v 1.38 2022/07/17 15:49:20 jsing Exp $ */ +/* $OpenBSD: tls13_legacy.c,v 1.40 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2018, 2019 Joel Sing * @@ -17,7 +17,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" #include "tls13_internal.h" static ssize_t @@ -30,7 +30,7 @@ tls13_legacy_wire_read(SSL *ssl, uint8_t *buf, size_t len) return TLS13_IO_FAILURE; } - ssl->internal->rwstate = SSL_READING; + ssl->rwstate = SSL_READING; errno = 0; if ((n = BIO_read(ssl->rbio, buf, len)) <= 0) { @@ -46,7 +46,7 @@ tls13_legacy_wire_read(SSL *ssl, uint8_t *buf, size_t len) } if (n == len) - ssl->internal->rwstate = SSL_NOTHING; + ssl->rwstate = SSL_NOTHING; return n; } @@ -69,7 +69,7 @@ tls13_legacy_wire_write(SSL *ssl, const uint8_t *buf, size_t len) return TLS13_IO_FAILURE; } - ssl->internal->rwstate = SSL_WRITING; + ssl->rwstate = SSL_WRITING; errno = 0; if ((n = BIO_write(ssl->wbio, buf, len)) <= 0) { @@ -83,7 +83,7 @@ tls13_legacy_wire_write(SSL *ssl, const uint8_t *buf, size_t len) } if (n == len) - ssl->internal->rwstate = SSL_NOTHING; + ssl->rwstate = SSL_NOTHING; return n; } @@ -123,7 +123,7 @@ tls13_legacy_wire_flush_cb(void *arg) static void tls13_legacy_error(SSL *ssl) { - struct tls13_ctx *ctx = ssl->internal->tls13; + struct tls13_ctx *ctx = ssl->tls13; int reason = SSL_R_UNKNOWN; /* If we received a fatal alert we already put an error on the stack. */ @@ -171,7 +171,7 @@ tls13_legacy_return_code(SSL *ssl, ssize_t ret) if (ret > 0) return ret; - ssl->internal->rwstate = SSL_NOTHING; + ssl->rwstate = SSL_NOTHING; switch (ret) { case TLS13_IO_EOF: @@ -187,12 +187,12 @@ tls13_legacy_return_code(SSL *ssl, ssize_t ret) case TLS13_IO_WANT_POLLIN: BIO_set_retry_read(ssl->rbio); - ssl->internal->rwstate = SSL_READING; + ssl->rwstate = SSL_READING; return -1; case TLS13_IO_WANT_POLLOUT: BIO_set_retry_write(ssl->wbio); - ssl->internal->rwstate = SSL_WRITING; + ssl->rwstate = SSL_WRITING; return -1; case TLS13_IO_WANT_RETRY: @@ -207,7 +207,7 @@ tls13_legacy_return_code(SSL *ssl, ssize_t ret) int tls13_legacy_pending(const SSL *ssl) { - struct tls13_ctx *ctx = ssl->internal->tls13; + struct tls13_ctx *ctx = ssl->tls13; ssize_t ret; if (ctx == NULL) @@ -223,11 +223,11 @@ tls13_legacy_pending(const SSL *ssl) int tls13_legacy_read_bytes(SSL *ssl, int type, unsigned char *buf, int len, int peek) { - struct tls13_ctx *ctx = ssl->internal->tls13; + struct tls13_ctx *ctx = ssl->tls13; ssize_t ret; if (ctx == NULL || !ctx->handshake_completed) { - if ((ret = ssl->internal->handshake_func(ssl)) <= 0) + if ((ret = ssl->handshake_func(ssl)) <= 0) return ret; if (len == 0) return 0; @@ -235,7 +235,7 @@ tls13_legacy_read_bytes(SSL *ssl, int type, unsigned char *buf, int len, int pee } tls13_record_layer_set_retry_after_phh(ctx->rl, - (ctx->ssl->internal->mode & SSL_MODE_AUTO_RETRY) != 0); + (ctx->ssl->mode & SSL_MODE_AUTO_RETRY) != 0); if (type != SSL3_RT_APPLICATION_DATA) { SSLerror(ssl, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); @@ -257,13 +257,13 @@ tls13_legacy_read_bytes(SSL *ssl, int type, unsigned char *buf, int len, int pee int tls13_legacy_write_bytes(SSL *ssl, int type, const void *vbuf, int len) { - struct tls13_ctx *ctx = ssl->internal->tls13; + struct tls13_ctx *ctx = ssl->tls13; const uint8_t *buf = vbuf; size_t n, sent; ssize_t ret; if (ctx == NULL || !ctx->handshake_completed) { - if ((ret = ssl->internal->handshake_func(ssl)) <= 0) + if ((ret = ssl->handshake_func(ssl)) <= 0) return ret; if (len == 0) return 0; @@ -283,7 +283,7 @@ tls13_legacy_write_bytes(SSL *ssl, int type, const void *vbuf, int len) * The TLSv1.3 record layer write behaviour is the same as * SSL_MODE_ENABLE_PARTIAL_WRITE. */ - if (ssl->internal->mode & SSL_MODE_ENABLE_PARTIAL_WRITE) { + if (ssl->mode & SSL_MODE_ENABLE_PARTIAL_WRITE) { ret = tls13_write_application_data(ctx->rl, buf, len); return tls13_legacy_return_code(ssl, ret); } @@ -352,18 +352,18 @@ tls13_use_legacy_stack(struct tls13_ctx *ctx) s->s3->rbuf.left = CBS_len(&cbs); s->s3->rrec.type = SSL3_RT_HANDSHAKE; s->s3->rrec.length = CBS_len(&cbs); - s->internal->rstate = SSL_ST_READ_BODY; - s->internal->packet = s->s3->rbuf.buf; - s->internal->packet_length = SSL3_RT_HEADER_LENGTH; - s->internal->mac_packet = 1; + s->rstate = SSL_ST_READ_BODY; + s->packet = s->s3->rbuf.buf; + s->packet_length = SSL3_RT_HEADER_LENGTH; + s->mac_packet = 1; } /* Stash the current handshake message. */ tls13_handshake_msg_data(ctx->hs_msg, &cbs); - if (!BUF_MEM_grow_clean(s->internal->init_buf, CBS_len(&cbs))) + if (!BUF_MEM_grow_clean(s->init_buf, CBS_len(&cbs))) goto err; - if (!CBS_write_bytes(&cbs, s->internal->init_buf->data, - s->internal->init_buf->length, NULL)) + if (!CBS_write_bytes(&cbs, s->init_buf->data, + s->init_buf->length, NULL)) goto err; s->s3->hs.tls12.reuse_message = 1; @@ -386,7 +386,7 @@ tls13_use_legacy_client(struct tls13_ctx *ctx) if (!tls13_use_legacy_stack(ctx)) return 0; - s->internal->handshake_func = s->method->ssl_connect; + s->handshake_func = s->method->ssl_connect; s->version = s->method->max_tls_version; return 1; @@ -400,7 +400,7 @@ tls13_use_legacy_server(struct tls13_ctx *ctx) if (!tls13_use_legacy_stack(ctx)) return 0; - s->internal->handshake_func = s->method->ssl_accept; + s->handshake_func = s->method->ssl_accept; s->version = s->method->max_tls_version; s->server = 1; @@ -410,7 +410,7 @@ tls13_use_legacy_server(struct tls13_ctx *ctx) int tls13_legacy_accept(SSL *ssl) { - struct tls13_ctx *ctx = ssl->internal->tls13; + struct tls13_ctx *ctx = ssl->tls13; int ret; if (ctx == NULL) { @@ -442,7 +442,7 @@ tls13_legacy_accept(SSL *ssl) int tls13_legacy_connect(SSL *ssl) { - struct tls13_ctx *ctx = ssl->internal->tls13; + struct tls13_ctx *ctx = ssl->tls13; int ret; if (ctx == NULL) { @@ -474,7 +474,7 @@ tls13_legacy_connect(SSL *ssl) int tls13_legacy_shutdown(SSL *ssl) { - struct tls13_ctx *ctx = ssl->internal->tls13; + struct tls13_ctx *ctx = ssl->tls13; uint8_t buf[512]; /* XXX */ ssize_t ret; @@ -484,15 +484,15 @@ tls13_legacy_shutdown(SSL *ssl) * alerts. All other cases, including EOF, return -1 and set internal * state appropriately. */ - if (ctx == NULL || ssl->internal->quiet_shutdown) { - ssl->internal->shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN; + if (ctx == NULL || ssl->quiet_shutdown) { + ssl->shutdown = SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN; return 1; } if (!ctx->close_notify_sent) { /* Enqueue and send close notify. */ - if (!(ssl->internal->shutdown & SSL_SENT_SHUTDOWN)) { - ssl->internal->shutdown |= SSL_SENT_SHUTDOWN; + if (!(ssl->shutdown & SSL_SENT_SHUTDOWN)) { + ssl->shutdown |= SSL_SENT_SHUTDOWN; if ((ret = tls13_send_alert(ctx->rl, TLS13_ALERT_CLOSE_NOTIFY)) < 0) return tls13_legacy_return_code(ssl, ret); @@ -533,13 +533,13 @@ tls13_legacy_servername_process(struct tls13_ctx *ctx, uint8_t *alert) SSL_CTX *ssl_ctx = ctx->ssl->ctx; SSL *s = ctx->ssl; - if (ssl_ctx->internal->tlsext_servername_callback == NULL) + if (ssl_ctx->tlsext_servername_callback == NULL) ssl_ctx = s->initial_ctx; - if (ssl_ctx->internal->tlsext_servername_callback == NULL) + if (ssl_ctx->tlsext_servername_callback == NULL) return 1; - ret = ssl_ctx->internal->tlsext_servername_callback(s, &legacy_alert, - ssl_ctx->internal->tlsext_servername_arg); + ret = ssl_ctx->tlsext_servername_callback(s, &legacy_alert, + ssl_ctx->tlsext_servername_arg); /* * Ignore SSL_TLSEXT_ERR_ALERT_WARNING returns to match OpenSSL's diff --git a/ssl/tls13_lib.c b/ssl/tls13_lib.c index 651c34ca..05f125ad 100644 --- a/ssl/tls13_lib.c +++ b/ssl/tls13_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_lib.c,v 1.71 2022/09/10 15:29:33 jsing Exp $ */ +/* $OpenBSD: tls13_lib.c,v 1.76 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2018, 2019 Joel Sing * Copyright (c) 2019 Bob Beck @@ -20,10 +20,17 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" #include "ssl_tlsext.h" #include "tls13_internal.h" +/* + * RFC 8446, section 4.6.1. Servers must not indicate a lifetime longer than + * 7 days and clients must not cache tickets for longer than 7 days. + */ + +#define TLS13_MAX_TICKET_LIFETIME (7 * 24 * 3600) + /* * Downgrade sentinels - RFC 8446 section 4.1.3, magic values which must be set * by the server in server random if it is willing to downgrade but supports @@ -110,7 +117,7 @@ tls13_alert_received_cb(uint8_t alert_desc, void *arg) if (alert_desc == TLS13_ALERT_CLOSE_NOTIFY) { ctx->close_notify_recv = 1; - ctx->ssl->internal->shutdown |= SSL_RECEIVED_SHUTDOWN; + ctx->ssl->shutdown |= SSL_RECEIVED_SHUTDOWN; ctx->ssl->s3->warn_alert = alert_desc; return; } @@ -158,7 +165,7 @@ tls13_legacy_handshake_message_recv_cb(void *arg) SSL *s = ctx->ssl; CBS cbs; - if (s->internal->msg_callback == NULL) + if (s->msg_callback == NULL) return; tls13_handshake_msg_data(ctx->hs_msg, &cbs); @@ -172,7 +179,7 @@ tls13_legacy_handshake_message_sent_cb(void *arg) SSL *s = ctx->ssl; CBS cbs; - if (s->internal->msg_callback == NULL) + if (s->msg_callback == NULL) return; tls13_handshake_msg_data(ctx->hs_msg, &cbs); @@ -195,11 +202,11 @@ tls13_legacy_ocsp_status_recv_cb(void *arg) SSL *s = ctx->ssl; int ret; - if (s->ctx->internal->tlsext_status_cb == NULL) + if (s->ctx->tlsext_status_cb == NULL) return 1; - ret = s->ctx->internal->tlsext_status_cb(s, - s->ctx->internal->tlsext_status_arg); + ret = s->ctx->tlsext_status_cb(s, + s->ctx->tlsext_status_arg); if (ret < 0) { ctx->alert = TLS13_ALERT_INTERNAL_ERROR; SSLerror(s, ERR_R_MALLOC_FAILURE); @@ -328,6 +335,107 @@ tls13_key_update_recv(struct tls13_ctx *ctx, CBS *cbs) return tls13_send_alert(ctx->rl, alert); } +/* RFC 8446 section 4.6.1 */ +static ssize_t +tls13_new_session_ticket_recv(struct tls13_ctx *ctx, CBS *cbs) +{ + struct tls13_secrets *secrets = ctx->hs->tls13.secrets; + struct tls13_secret nonce; + uint32_t ticket_lifetime, ticket_age_add; + CBS ticket_nonce, ticket; + SSL_SESSION *sess = NULL; + int alert, session_id_length; + ssize_t ret = 0; + + memset(&nonce, 0, sizeof(nonce)); + + if (ctx->mode != TLS13_HS_CLIENT) { + alert = TLS13_ALERT_UNEXPECTED_MESSAGE; + goto err; + } + + alert = TLS13_ALERT_DECODE_ERROR; + + if (!CBS_get_u32(cbs, &ticket_lifetime)) + goto err; + if (!CBS_get_u32(cbs, &ticket_age_add)) + goto err; + if (!CBS_get_u8_length_prefixed(cbs, &ticket_nonce)) + goto err; + if (!CBS_get_u16_length_prefixed(cbs, &ticket)) + goto err; + /* Extensions can only contain early_data, which we currently ignore. */ + if (!tlsext_client_parse(ctx->ssl, SSL_TLSEXT_MSG_NST, cbs, &alert)) + goto err; + + if (CBS_len(cbs) != 0) + goto err; + + /* Zero indicates that the ticket should be discarded immediately. */ + if (ticket_lifetime == 0) { + ret = TLS13_IO_SUCCESS; + goto done; + } + + /* Servers MUST NOT use any value larger than 7 days. */ + if (ticket_lifetime > TLS13_MAX_TICKET_LIFETIME) { + alert = TLS13_ALERT_ILLEGAL_PARAMETER; + goto err; + } + + alert = TLS13_ALERT_INTERNAL_ERROR; + + /* + * Create new session instead of modifying the current session. + * The current session could already be in the session cache. + */ + if ((sess = ssl_session_dup(ctx->ssl->session, 0)) == NULL) + goto err; + + sess->time = time(NULL); + + sess->tlsext_tick_lifetime_hint = ticket_lifetime; + sess->tlsext_tick_age_add = ticket_age_add; + + if (!CBS_stow(&ticket, &sess->tlsext_tick, &sess->tlsext_ticklen)) + goto err; + + /* XXX - ensure this doesn't overflow session_id if hash is changed. */ + if (!EVP_Digest(CBS_data(&ticket), CBS_len(&ticket), + sess->session_id, &session_id_length, EVP_sha256(), NULL)) + goto err; + sess->session_id_length = session_id_length; + + if (!CBS_stow(&ticket_nonce, &nonce.data, &nonce.len)) + goto err; + + if (!tls13_secret_init(&sess->resumption_master_secret, 256)) + goto err; + + if (!tls13_derive_secret(&sess->resumption_master_secret, + secrets->digest, &secrets->resumption_master, "resumption", + &nonce)) + goto err; + + SSL_SESSION_free(ctx->ssl->session); + ctx->ssl->session = sess; + sess = NULL; + + ssl_update_cache(ctx->ssl, SSL_SESS_CACHE_CLIENT); + + ret = TLS13_IO_SUCCESS; + goto done; + + err: + ret = tls13_send_alert(ctx->rl, alert); + + done: + tls13_secret_cleanup(&nonce); + SSL_SESSION_free(sess); + + return ret; +} + ssize_t tls13_phh_received_cb(void *cb_arg) { @@ -354,7 +462,7 @@ tls13_phh_received_cb(void *cb_arg) ret = tls13_key_update_recv(ctx, &cbs); break; case TLS13_MT_NEW_SESSION_TICKET: - /* XXX do nothing for now and ignore this */ + ret = tls13_new_session_ticket_recv(ctx, &cbs); break; case TLS13_MT_CERTIFICATE_REQUEST: /* XXX add support if we choose to advertise this */ @@ -413,7 +521,7 @@ tls13_ctx_new(int mode, SSL *ssl) ctx->middlebox_compat = 1; - ssl->internal->tls13 = ctx; + ssl->tls13 = ctx; if (SSL_is_quic(ssl)) { if (!tls13_quic_init(ctx)) @@ -591,73 +699,3 @@ tls13_clienthello_hash_validate(struct tls13_ctx *ctx) return 1; } - -int -tls13_exporter(struct tls13_ctx *ctx, const uint8_t *label, size_t label_len, - const uint8_t *context_value, size_t context_value_len, uint8_t *out, - size_t out_len) -{ - struct tls13_secret context, export_out, export_secret; - struct tls13_secrets *secrets = ctx->hs->tls13.secrets; - EVP_MD_CTX *md_ctx = NULL; - unsigned int md_out_len; - int md_len; - int ret = 0; - - /* - * RFC 8446 Section 7.5. - */ - - memset(&context, 0, sizeof(context)); - memset(&export_secret, 0, sizeof(export_secret)); - - export_out.data = out; - export_out.len = out_len; - - if (!ctx->handshake_completed) - return 0; - - md_len = EVP_MD_size(secrets->digest); - if (md_len <= 0 || md_len > EVP_MAX_MD_SIZE) - goto err; - - if (!tls13_secret_init(&export_secret, md_len)) - goto err; - if (!tls13_secret_init(&context, md_len)) - goto err; - - /* In TLSv1.3 no context is equivalent to an empty context. */ - if (context_value == NULL) { - context_value = ""; - context_value_len = 0; - } - - if ((md_ctx = EVP_MD_CTX_new()) == NULL) - goto err; - if (!EVP_DigestInit_ex(md_ctx, secrets->digest, NULL)) - goto err; - if (!EVP_DigestUpdate(md_ctx, context_value, context_value_len)) - goto err; - if (!EVP_DigestFinal_ex(md_ctx, context.data, &md_out_len)) - goto err; - if (md_len != md_out_len) - goto err; - - if (!tls13_derive_secret_with_label_length(&export_secret, - secrets->digest, &secrets->exporter_master, label, label_len, - &secrets->empty_hash)) - goto err; - - if (!tls13_hkdf_expand_label(&export_out, secrets->digest, - &export_secret, "exporter", &context)) - goto err; - - ret = 1; - - err: - EVP_MD_CTX_free(md_ctx); - tls13_secret_cleanup(&context); - tls13_secret_cleanup(&export_secret); - - return ret; -} diff --git a/ssl/tls13_quic.c b/ssl/tls13_quic.c index bb7317d4..e5c386ea 100644 --- a/ssl/tls13_quic.c +++ b/ssl/tls13_quic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_quic.c,v 1.6 2022/08/30 18:23:40 tb Exp $ */ +/* $OpenBSD: tls13_quic.c,v 1.7 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2022 Joel Sing * @@ -15,8 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include - +#include "ssl_local.h" #include "tls13_internal.h" static ssize_t diff --git a/ssl/tls13_record_layer.c b/ssl/tls13_record_layer.c index 423b405c..4ae4e298 100644 --- a/ssl/tls13_record_layer.c +++ b/ssl/tls13_record_layer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_record_layer.c,v 1.71 2022/09/11 13:50:41 jsing Exp $ */ +/* $OpenBSD: tls13_record_layer.c,v 1.72 2022/11/11 17:15:27 jsing Exp $ */ /* * Copyright (c) 2018, 2019 Joel Sing * @@ -561,6 +561,7 @@ tls13_record_layer_open_record_protected(struct tls13_record_layer *rl) if (!tls13_record_content(rl->rrec, &enc_record)) goto err; + /* XXX - minus tag len? */ if ((content = calloc(1, CBS_len(&enc_record))) == NULL) goto err; content_len = CBS_len(&enc_record); diff --git a/ssl/tls13_server.c b/ssl/tls13_server.c index 82350702..75510a90 100644 --- a/ssl/tls13_server.c +++ b/ssl/tls13_server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_server.c,v 1.103 2022/09/17 17:14:06 jsing Exp $ */ +/* $OpenBSD: tls13_server.c,v 1.105 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2019, 2020 Joel Sing * Copyright (c) 2020 Bob Beck @@ -18,7 +18,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" #include "ssl_sigalgs.h" #include "ssl_tlsext.h" #include "tls13_handshake.h" @@ -37,7 +37,7 @@ tls13_server_init(struct tls13_ctx *ctx) s->version = ctx->hs->our_max_tls_version; tls13_record_layer_set_retry_after_phh(ctx->rl, - (s->internal->mode & SSL_MODE_AUTO_RETRY) != 0); + (s->mode & SSL_MODE_AUTO_RETRY) != 0); if (!ssl_get_new_session(s, 0)) /* XXX */ return 0; @@ -656,7 +656,7 @@ tls13_server_certificate_send(struct tls13_ctx *ctx, CBB *cbb) if ((chain = cpk->chain) == NULL) chain = s->ctx->extra_certs; - if (chain == NULL && !(s->internal->mode & SSL_MODE_NO_AUTO_CHAIN)) { + if (chain == NULL && !(s->mode & SSL_MODE_NO_AUTO_CHAIN)) { if ((xsc = X509_STORE_CTX_new()) == NULL) goto err; if (!X509_STORE_CTX_init(xsc, s->ctx->cert_store, cpk->x509, NULL)) diff --git a/ssl/tls_buffer.c b/ssl/tls_buffer.c index f70cfbc1..517d66d6 100644 --- a/ssl/tls_buffer.c +++ b/ssl/tls_buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_buffer.c,v 1.3 2022/07/22 19:33:53 jsing Exp $ */ +/* $OpenBSD: tls_buffer.c,v 1.4 2022/11/10 18:06:37 jsing Exp $ */ /* * Copyright (c) 2018, 2019, 2022 Joel Sing * @@ -155,6 +155,15 @@ tls_buffer_extend(struct tls_buffer *buf, size_t len, } } +size_t +tls_buffer_remaining(struct tls_buffer *buf) +{ + if (buf->offset > buf->len) + return 0; + + return buf->len - buf->offset; +} + ssize_t tls_buffer_read(struct tls_buffer *buf, uint8_t *rbuf, size_t n) { diff --git a/ssl/tls_content.c b/ssl/tls_content.c index ede178f8..726de0fd 100644 --- a/ssl/tls_content.c +++ b/ssl/tls_content.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_content.c,v 1.1 2021/09/04 16:26:12 jsing Exp $ */ +/* $OpenBSD: tls_content.c,v 1.2 2022/11/11 17:15:27 jsing Exp $ */ /* * Copyright (c) 2020 Joel Sing * @@ -26,7 +26,7 @@ struct tls_content { uint16_t epoch; const uint8_t *data; - size_t len; + size_t data_len; CBS cbs; }; @@ -39,7 +39,7 @@ tls_content_new(void) void tls_content_clear(struct tls_content *content) { - freezero((void *)content->data, content->len); + freezero((void *)content->data, content->data_len); memset(content, 0, sizeof(*content)); } @@ -113,9 +113,24 @@ tls_content_set_data(struct tls_content *content, uint8_t type, content->type = type; content->data = data; - content->len = data_len; + content->data_len = data_len; - CBS_init(&content->cbs, content->data, content->len); + CBS_init(&content->cbs, content->data, content->data_len); +} + +int +tls_content_set_bounds(struct tls_content *content, size_t offset, size_t len) +{ + size_t content_len; + + content_len = offset + len; + if (content_len < len) + return 0; + if (content_len > content->data_len) + return 0; + + CBS_init(&content->cbs, content->data, content_len); + return CBS_skip(&content->cbs, offset); } static ssize_t diff --git a/ssl/tls_content.h b/ssl/tls_content.h index 173af2a7..b807248f 100644 --- a/ssl/tls_content.h +++ b/ssl/tls_content.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_content.h,v 1.1 2021/09/04 16:26:12 jsing Exp $ */ +/* $OpenBSD: tls_content.h,v 1.2 2022/11/11 17:15:27 jsing Exp $ */ /* * Copyright (c) 2020 Joel Sing * @@ -38,6 +38,8 @@ int tls_content_dup_data(struct tls_content *content, uint8_t type, const uint8_t *data, size_t data_len); void tls_content_set_data(struct tls_content *content, uint8_t type, const uint8_t *data, size_t data_len); +int tls_content_set_bounds(struct tls_content *content, size_t offset, + size_t len); void tls_content_set_epoch(struct tls_content *content, uint16_t epoch); ssize_t tls_content_peek(struct tls_content *content, uint8_t *buf, size_t n); diff --git a/ssl/tls_internal.h b/ssl/tls_internal.h index 1d3a8133..84edde84 100644 --- a/ssl/tls_internal.h +++ b/ssl/tls_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_internal.h,v 1.9 2022/07/24 14:28:16 jsing Exp $ */ +/* $OpenBSD: tls_internal.h,v 1.10 2022/11/10 18:06:37 jsing Exp $ */ /* * Copyright (c) 2018, 2019, 2021 Joel Sing * @@ -64,6 +64,7 @@ void tls_buffer_free(struct tls_buffer *buf); void tls_buffer_set_capacity_limit(struct tls_buffer *buf, size_t limit); ssize_t tls_buffer_extend(struct tls_buffer *buf, size_t len, tls_read_cb read_cb, void *cb_arg); +size_t tls_buffer_remaining(struct tls_buffer *buf); ssize_t tls_buffer_read(struct tls_buffer *buf, uint8_t *rbuf, size_t n); ssize_t tls_buffer_write(struct tls_buffer *buf, const uint8_t *wbuf, size_t n); int tls_buffer_append(struct tls_buffer *buf, const uint8_t *wbuf, size_t n); diff --git a/ssl/tls_key_share.c b/ssl/tls_key_share.c index 048db25b..cf7b1da2 100644 --- a/ssl/tls_key_share.c +++ b/ssl/tls_key_share.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_key_share.c,v 1.7 2022/07/02 16:00:12 tb Exp $ */ +/* $OpenBSD: tls_key_share.c,v 1.8 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2020, 2021 Joel Sing * @@ -23,7 +23,7 @@ #include #include "bytestring.h" -#include "ssl_locl.h" +#include "ssl_local.h" #include "tls_internal.h" struct tls_key_share { diff --git a/ssl/tls_lib.c b/ssl/tls_lib.c index eb5ed380..db734c34 100644 --- a/ssl/tls_lib.c +++ b/ssl/tls_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_lib.c,v 1.2 2022/08/20 21:48:25 tb Exp $ */ +/* $OpenBSD: tls_lib.c,v 1.3 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2019, 2021 Joel Sing * @@ -15,7 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "ssl_locl.h" +#include "ssl_local.h" int tls_process_peer_certs(SSL *s, STACK_OF(X509) *peer_certs) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9b10b338..27a96007 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,6 +5,7 @@ include_directories( ../crypto/asn1 ../crypto/bio ../crypto/bn + ../crypto/curve25519 ../crypto/evp ../crypto/modes ../crypto/x509 @@ -29,6 +30,11 @@ else() add_test(aeadtest aeadtest aead ${CMAKE_CURRENT_SOURCE_DIR}/aeadtests.txt) endif() +# aes_test +add_executable(aes_test aes_test.c) +target_link_libraries(aes_test ${OPENSSL_TEST_LIBS}) +add_test(aes_test aes_test) + # aes_wrap add_executable(aes_wrap aes_wrap.c) target_link_libraries(aes_wrap ${OPENSSL_TEST_LIBS}) @@ -87,34 +93,61 @@ add_executable(asn1x509 asn1x509.c) target_link_libraries(asn1x509 ${OPENSSL_TEST_LIBS}) add_test(asn1x509 asn1x509) +# asn1_string_to_utf8 +add_executable(asn1_string_to_utf8 asn1_string_to_utf8.c) +target_link_libraries(asn1_string_to_utf8 ${OPENSSL_TEST_LIBS}) +add_test(asn1_string_to_utf8 asn1_string_to_utf8) + # base64test add_executable(base64test base64test.c) target_link_libraries(base64test ${OPENSSL_TEST_LIBS}) add_test(base64test base64test) -# bftest -add_executable(bftest bftest.c) -target_link_libraries(bftest ${OPENSSL_TEST_LIBS}) -add_test(bftest bftest) +# bf_test +add_executable(bf_test bf_test.c) +target_link_libraries(bf_test ${OPENSSL_TEST_LIBS}) +add_test(bf_test bf_test) + +# bio_chain +add_executable(bio_chain bio_chain.c) +target_link_libraries(bio_chain ${OPENSSL_TEST_LIBS}) +add_test(bio_chain bio_chain) -# biotest -# the BIO tests rely on resolver results that are OS and environment-specific +# bio_host +# this test relies on resolver results that are OS and environment-specific if(ENABLE_EXTRATESTS) - add_executable(biotest biotest.c) - target_link_libraries(biotest ${OPENSSL_TEST_LIBS}) - add_test(biotest biotest) + add_executable(bio_host bio_host.c) + target_link_libraries(bio_host ${OPENSSL_TEST_LIBS}) + add_test(bio_host bio_host) endif() -# bnaddsub -add_executable(bnaddsub bnaddsub.c) -target_link_libraries(bnaddsub ${OPENSSL_TEST_LIBS}) -add_test(bnaddsub bnaddsub) +# bio_mem +add_executable(bio_mem bio_mem.c) +target_link_libraries(bio_mem ${OPENSSL_TEST_LIBS}) +add_test(bio_mem bio_mem) + +# bn_add_sub +add_executable(bn_add_sub bn_add_sub.c) +target_link_libraries(bn_add_sub ${OPENSSL_TEST_LIBS}) +add_test(bn_add_sub bn_add_sub) + +# bn_cmp +add_executable(bn_cmp bn_cmp.c) +target_link_libraries(bn_cmp ${OPENSSL_TEST_LIBS}) +add_test(bn_cmp bn_cmp) # bn_isqrt add_executable(bn_isqrt bn_isqrt.c) target_link_libraries(bn_isqrt ${OPENSSL_TEST_LIBS}) add_test(bn_isqrt bn_isqrt) +# bn_mod_exp +add_executable(bn_mod_exp bn_mod_exp.c) +set_source_files_properties(bn_mod_exp.c PROPERTIES COMPILE_FLAGS + -ULIBRESSL_INTERNAL) +target_link_libraries(bn_mod_exp ${OPENSSL_TEST_LIBS}) +add_test(bn_mod_exp bn_mod_exp) + # bn_mod_exp2_mont add_executable(bn_mod_exp2_mont bn_mod_exp2_mont.c) target_link_libraries(bn_mod_exp2_mont ${OPENSSL_TEST_LIBS}) @@ -125,6 +158,11 @@ add_executable(bn_mod_sqrt bn_mod_sqrt.c) target_link_libraries(bn_mod_sqrt ${OPENSSL_TEST_LIBS}) add_test(bn_mod_sqrt bn_mod_sqrt) +# bn_mont +add_executable(bn_mont bn_mont.c) +target_link_libraries(bn_mont ${OPENSSL_TEST_LIBS}) +add_test(bn_mont bn_mont) + # bn_primes add_executable(bn_primes bn_primes.c) target_link_libraries(bn_primes ${OPENSSL_TEST_LIBS}) @@ -135,18 +173,33 @@ add_executable(bn_rand_interval bn_rand_interval.c) target_link_libraries(bn_rand_interval ${OPENSSL_TEST_LIBS}) add_test(bn_rand_interval bn_rand_interval) -# bntest -add_executable(bntest bntest.c) -set_source_files_properties(bntest.c PROPERTIES COMPILE_FLAGS +# bn_shift +add_executable(bn_shift bn_shift.c) +target_link_libraries(bn_shift ${OPENSSL_TEST_LIBS}) +add_test(bn_shift bn_shift) + +# bn_test +add_executable(bn_test bn_test.c) +set_source_files_properties(bn_test.c PROPERTIES COMPILE_FLAGS -ULIBRESSL_INTERNAL) -target_link_libraries(bntest ${OPENSSL_TEST_LIBS}) -add_test(bntest bntest) +target_link_libraries(bn_test ${OPENSSL_TEST_LIBS}) +add_test(bn_test bn_test) # bn_to_string add_executable(bn_to_string bn_to_string.c) target_link_libraries(bn_to_string ${OPENSSL_TEST_LIBS}) add_test(bn_to_string bn_to_string) +# bn_unit +add_executable(bn_unit bn_unit.c) +target_link_libraries(bn_unit ${OPENSSL_TEST_LIBS}) +add_test(bn_unit bn_unit) + +# bn_word +add_executable(bn_word bn_word.c) +target_link_libraries(bn_word ${OPENSSL_TEST_LIBS}) +add_test(bn_word bn_word) + # buffertest add_executable(buffertest buffertest.c) target_link_libraries(buffertest ${OPENSSL_TEST_LIBS}) @@ -217,13 +270,14 @@ add_executable(dsatest dsatest.c) target_link_libraries(dsatest ${OPENSSL_TEST_LIBS}) add_test(dsatest dsatest) -# dtlstest -if(NOT WIN32) - add_executable(dtlstest dtlstest.c) - target_link_libraries(dtlstest ${OPENSSL_TEST_LIBS}) - add_test(NAME dtlstest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/dtlstest.sh) - set_tests_properties(dtlstest PROPERTIES ENVIRONMENT "srcdir=${TEST_SOURCE_DIR}") -endif() +# XXX This test is too flaky for CI. Disable it until it is fixed. +# # dtlstest +# if(NOT WIN32) +# add_executable(dtlstest dtlstest.c) +# target_link_libraries(dtlstest ${OPENSSL_TEST_LIBS}) +# add_test(NAME dtlstest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/dtlstest.sh) +# set_tests_properties(dtlstest PROPERTIES ENVIRONMENT "srcdir=${TEST_SOURCE_DIR}") +# endif() # ec_asn1_test add_executable(ec_asn1_test ec_asn1_test.c) @@ -250,11 +304,21 @@ add_executable(ectest ectest.c) target_link_libraries(ectest ${OPENSSL_TEST_LIBS}) add_test(ectest ectest) +# ed25519test +add_executable(ed25519test ed25519test.c) +target_link_libraries(ed25519test ${OPENSSL_TEST_LIBS}) +add_test(ed25519test ed25519test) + # enginetest add_executable(enginetest enginetest.c) target_link_libraries(enginetest ${OPENSSL_TEST_LIBS}) add_test(enginetest enginetest) +# evp_ecx_test +add_executable(evp_ecx_test evp_ecx_test.c) +target_link_libraries(evp_ecx_test ${OPENSSL_TEST_LIBS}) +add_test(evp_ecx_test evp_ecx_test) + # evp_pkey_check add_executable(evp_pkey_check evp_pkey_check.c) target_link_libraries(evp_pkey_check ${OPENSSL_TEST_LIBS}) @@ -282,15 +346,10 @@ if(NOT WIN32) add_test(explicit_bzero explicit_bzero) endif() -# exptest -add_executable(exptest exptest.c) -set_source_files_properties(exptest.c PROPERTIES COMPILE_FLAGS - -ULIBRESSL_INTERNAL) -target_link_libraries(exptest ${OPENSSL_TEST_LIBS}) -add_test(exptest exptest) - # freenull add_executable(freenull freenull.c) +set_source_files_properties(freenull.c PROPERTIES COMPILE_FLAGS + -ULIBRESSL_INTERNAL) target_link_libraries(freenull ${OPENSSL_TEST_LIBS}) add_test(freenull freenull) @@ -347,11 +406,6 @@ add_executable(md_test md_test.c) target_link_libraries(md_test ${OPENSSL_TEST_LIBS}) add_test(md_test md_test) -# mont -add_executable(mont mont.c) -target_link_libraries(mont ${OPENSSL_TEST_LIBS}) -add_test(mont mont) - # objectstest add_executable(objectstest objectstest.c) target_link_libraries(objectstest ${OPENSSL_TEST_LIBS}) diff --git a/tests/Makefile.am b/tests/Makefile.am index 24e6f2ee..b4d50e38 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,10 +1,15 @@ include $(top_srcdir)/Makefile.am.common +-include $(abs_top_builddir)/crypto/libcrypto_la_objects.mk +-include $(abs_top_builddir)/ssl/libssl_la_objects.mk +-include $(abs_top_builddir)/tls/libtls_la_objects.mk + AM_CPPFLAGS += -DLIBRESSL_CRYPTO_INTERNAL AM_CPPFLAGS += -I $(top_srcdir)/crypto/asn1 AM_CPPFLAGS += -I $(top_srcdir)/crypto/bio AM_CPPFLAGS += -I $(top_srcdir)/crypto/bn +AM_CPPFLAGS += -I $(top_srcdir)/crypto/curve25519 AM_CPPFLAGS += -I $(top_srcdir)/crypto/evp AM_CPPFLAGS += -I $(top_srcdir)/crypto/modes AM_CPPFLAGS += -I $(top_srcdir)/crypto/x509 @@ -13,13 +18,15 @@ AM_CPPFLAGS += -I $(top_srcdir)/apps/openssl AM_CPPFLAGS += -I $(top_srcdir)/apps/openssl/compat AM_CPPFLAGS += -D_PATH_SSL_CA_FILE=\"$(top_srcdir)/cert.pem\" -LDADD = $(abs_top_builddir)/tls/.libs/libtls.a -LDADD += $(abs_top_builddir)/ssl/.libs/libssl.a -LDADD += $(abs_top_builddir)/crypto/.libs/libcrypto.a -LDADD += $(PLATFORM_LDADD) $(PROG_LDADD) -if HOST_ASM_MACOSX_X86_64 -LDADD += $(abs_top_builddir)/crypto/.libs/libcrypto_la-cpuid-macosx-x86_64.o -endif +noinst_LTLIBRARIES = libtest.la +libtest_la_LIBADD = $(libcrypto_la_objects) +libtest_la_LIBADD += $(libcompat_la_objects) +libtest_la_LIBADD += $(libcompatnoopt_la_objects) +libtest_la_LIBADD += $(libssl_la_objects) +libtest_la_LIBADD += $(libtls_la_objects) +libtest_la_SOURCES = empty.c + +LDADD = libtest.la $(PLATFORM_LDADD) $(PROG_LDADD) TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh @@ -40,6 +47,11 @@ EXTRA_DIST += aes_256_gcm_tests.txt EXTRA_DIST += chacha20_poly1305_tests.txt EXTRA_DIST += xchacha20_poly1305_tests.txt +# aes +TESTS += aes_test +check_PROGRAMS += aes_test +aes_test_SOURCES = aes_test.c + # aes_wrap TESTS += aes_wrap check_PROGRAMS += aes_wrap @@ -109,29 +121,50 @@ TESTS += base64test check_PROGRAMS += base64test base64test_SOURCES = base64test.c -# bftest -TESTS += bftest -check_PROGRAMS += bftest -bftest_SOURCES = bftest.c +# bf_test +TESTS += bf_test +check_PROGRAMS += bf_test +bf_test_SOURCES = bf_test.c + +# bio_chain +TESTS += bio_chain +check_PROGRAMS += bio_chain +bio_chain_SOURCES = bio_chain.c -# biotest -# the BIO tests rely on resolver results that are OS and environment-specific +# bio_host +# this test relies on resolver results that are OS and environment-specific if ENABLE_EXTRATESTS -TESTS += biotest -check_PROGRAMS += biotest -biotest_SOURCES = biotest.c +TESTS += bio_host +check_PROGRAMS += bio_host +bio_host_SOURCES = bio_host.c endif -# bnaddsub -TESTS += bnaddsub -check_PROGRAMS += bnaddsub -bnaddsub_SOURCES = bnaddsub.c +# bio_mem +TESTS += bio_mem +check_PROGRAMS += bio_mem +bio_mem_SOURCES = bio_mem.c + +# bn_add_sub +TESTS += bn_add_sub +check_PROGRAMS += bn_add_sub +bn_add_sub_SOURCES = bn_add_sub.c + +# bn_cmp +TESTS += bn_cmp +check_PROGRAMS += bn_cmp +bn_cmp_SOURCES = bn_cmp.c # bn_isqrt TESTS += bn_isqrt check_PROGRAMS += bn_isqrt bn_isqrt_SOURCES = bn_isqrt.c +# bn_mod_exp +TESTS += bn_mod_exp +check_PROGRAMS += bn_mod_exp +bn_mod_exp_CPPFLAGS = $(AM_CPPFLAGS) -ULIBRESSL_INTERNAL +bn_mod_exp_SOURCES = bn_mod_exp.c + # bn_mod_exp2_mont TESTS += bn_mod_exp2_mont check_PROGRAMS += bn_mod_exp2_mont @@ -142,6 +175,11 @@ TESTS += bn_mod_sqrt check_PROGRAMS += bn_mod_sqrt bn_mod_sqrt_SOURCES = bn_mod_sqrt.c +# bn_mont +TESTS += bn_mont +check_PROGRAMS += bn_mont +bn_mont_SOURCES = bn_mont.c + # bn_primes TESTS += bn_primes check_PROGRAMS += bn_primes @@ -152,17 +190,32 @@ TESTS += bn_rand_interval check_PROGRAMS += bn_rand_interval bn_rand_interval_SOURCES = bn_rand_interval.c -# bntest -TESTS += bntest -bntest_CPPFLAGS = $(AM_CPPFLAGS) -ULIBRESSL_INTERNAL -check_PROGRAMS += bntest -bntest_SOURCES = bntest.c +# bn_shift +TESTS += bn_shift +check_PROGRAMS += bn_shift +bn_shift_SOURCES = bn_shift.c + +# bn_test +TESTS += bn_test +bn_test_CPPFLAGS = $(AM_CPPFLAGS) -ULIBRESSL_INTERNAL +check_PROGRAMS += bn_test +bn_test_SOURCES = bn_test.c # bn_to_string TESTS += bn_to_string check_PROGRAMS += bn_to_string bn_to_string_SOURCES = bn_to_string.c +# bn_unit +TESTS += bn_unit +check_PROGRAMS += bn_unit +bn_unit_SOURCES = bn_unit.c + +# bn_word +TESTS += bn_word +check_PROGRAMS += bn_word +bn_word_SOURCES = bn_word.c + # buffertest TESTS += buffertest check_PROGRAMS += buffertest @@ -234,13 +287,14 @@ TESTS += dsatest check_PROGRAMS += dsatest dsatest_SOURCES = dsatest.c -# dtlstest -if !HOST_WIN -TESTS += dtlstest.sh -check_PROGRAMS += dtlstest -dtlstest_SOURCES = dtlstest.c -endif -EXTRA_DIST += dtlstest.sh +# XXX this test is too flaky for CI. Disable it until it is fixed. +## dtlstest +#if !HOST_WIN +#TESTS += dtlstest.sh +#check_PROGRAMS += dtlstest +#dtlstest_SOURCES = dtlstest.c +#endif +#EXTRA_DIST += dtlstest.sh # ec_asn1_test TESTS += ec_asn1_test @@ -267,11 +321,21 @@ TESTS += ectest check_PROGRAMS += ectest ectest_SOURCES = ectest.c +# ed25519test +TESTS += ed25519test +check_PROGRAMS += ed25519test +ed25519test_SOURCES = ed25519test.c + # enginetest TESTS += enginetest check_PROGRAMS += enginetest enginetest_SOURCES = enginetest.c +# evp_ecx_test +TESTS += evp_ecx_test +check_PROGRAMS += evp_ecx_test +evp_ecx_test_SOURCES = evp_ecx_test.c + # evp_pkey_check TESTS += evp_pkey_check check_PROGRAMS += evp_pkey_check @@ -302,14 +366,9 @@ endif endif endif -# exptest -TESTS += exptest -check_PROGRAMS += exptest -exptest_CPPFLAGS = $(AM_CPPFLAGS) -ULIBRESSL_INTERNAL -exptest_SOURCES = exptest.c - # freenull TESTS += freenull +freenull_CPPFLAGS = $(AM_CPPFLAGS) -ULIBRESSL_INTERNAL check_PROGRAMS += freenull freenull_SOURCES = freenull.c @@ -365,11 +424,6 @@ TESTS += md_test check_PROGRAMS += md_test md_test_SOURCES = md_test.c -# mont -TESTS += mont -check_PROGRAMS += mont -mont_SOURCES = mont.c - # objectstest TESTS += objectstest check_PROGRAMS += objectstest diff --git a/tests/Makefile.in b/tests/Makefile.in index c20d7c65..28cad03d 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -14,6 +14,7 @@ @SET_MAKE@ + VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ @@ -88,36 +89,38 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -@HOST_ASM_MACOSX_X86_64_TRUE@am__append_1 = $(abs_top_builddir)/crypto/.libs/libcrypto_la-cpuid-macosx-x86_64.o -TESTS = aeadtest.sh aes_wrap$(EXEEXT) $(am__append_2) \ - asn1_string_to_utf8$(EXEEXT) asn1api$(EXEEXT) \ +TESTS = aeadtest.sh aes_test$(EXEEXT) aes_wrap$(EXEEXT) \ + $(am__append_1) asn1_string_to_utf8$(EXEEXT) asn1api$(EXEEXT) \ asn1basic$(EXEEXT) asn1complex$(EXEEXT) asn1evp$(EXEEXT) \ asn1object$(EXEEXT) asn1string_copy$(EXEEXT) asn1test$(EXEEXT) \ asn1time$(EXEEXT) asn1x509$(EXEEXT) base64test$(EXEEXT) \ - bftest$(EXEEXT) $(am__EXEEXT_2) bnaddsub$(EXEEXT) \ - bn_isqrt$(EXEEXT) bn_mod_exp2_mont$(EXEEXT) \ - bn_mod_sqrt$(EXEEXT) bn_primes$(EXEEXT) \ - bn_rand_interval$(EXEEXT) bntest$(EXEEXT) \ - bn_to_string$(EXEEXT) buffertest$(EXEEXT) \ + bf_test$(EXEEXT) bio_chain$(EXEEXT) $(am__EXEEXT_2) \ + bio_mem$(EXEEXT) bn_add_sub$(EXEEXT) bn_cmp$(EXEEXT) \ + bn_isqrt$(EXEEXT) bn_mod_exp$(EXEEXT) \ + bn_mod_exp2_mont$(EXEEXT) bn_mod_sqrt$(EXEEXT) \ + bn_mont$(EXEEXT) bn_primes$(EXEEXT) bn_rand_interval$(EXEEXT) \ + bn_shift$(EXEEXT) bn_test$(EXEEXT) bn_to_string$(EXEEXT) \ + bn_unit$(EXEEXT) bn_word$(EXEEXT) buffertest$(EXEEXT) \ bytestringtest$(EXEEXT) casttest$(EXEEXT) chachatest$(EXEEXT) \ cipher_list$(EXEEXT) cipherstest$(EXEEXT) clienttest$(EXEEXT) \ cmstest$(EXEEXT) configtest$(EXEEXT) constraints$(EXEEXT) \ cts128test$(EXEEXT) destest$(EXEEXT) dhtest$(EXEEXT) \ - dsatest$(EXEEXT) $(am__append_6) ec_asn1_test$(EXEEXT) \ + dsatest$(EXEEXT) ec_asn1_test$(EXEEXT) \ ec_point_conversion$(EXEEXT) ecdhtest$(EXEEXT) \ - ecdsatest$(EXEEXT) ectest$(EXEEXT) enginetest$(EXEEXT) \ + ecdsatest$(EXEEXT) ectest$(EXEEXT) ed25519test$(EXEEXT) \ + enginetest$(EXEEXT) evp_ecx_test$(EXEEXT) \ evp_pkey_check$(EXEEXT) evp_pkey_cleanup$(EXEEXT) evptest.sh \ - $(am__EXEEXT_4) exptest$(EXEEXT) freenull$(EXEEXT) \ - gcm128test$(EXEEXT) gost2814789t$(EXEEXT) \ - handshake_table$(EXEEXT) hkdftest$(EXEEXT) hmactest$(EXEEXT) \ - ideatest$(EXEEXT) igetest$(EXEEXT) key_schedule$(EXEEXT) \ - keypairtest.sh md_test$(EXEEXT) mont$(EXEEXT) \ - objectstest$(EXEEXT) $(am__append_11) optionstest$(EXEEXT) \ - pbkdf2$(EXEEXT) $(am__append_13) pkcs7test$(EXEEXT) \ - poly1305test$(EXEEXT) pq_test.sh quictest.sh randtest$(EXEEXT) \ - rc2_test$(EXEEXT) rc4_test$(EXEEXT) recordtest$(EXEEXT) \ - record_layer_test$(EXEEXT) rfc3779$(EXEEXT) $(am__append_15) \ - $(am__EXEEXT_7) rmd_test$(EXEEXT) rsa_test$(EXEEXT) \ + $(am__EXEEXT_3) freenull$(EXEEXT) gcm128test$(EXEEXT) \ + gost2814789t$(EXEEXT) handshake_table$(EXEEXT) \ + hkdftest$(EXEEXT) hmactest$(EXEEXT) ideatest$(EXEEXT) \ + igetest$(EXEEXT) key_schedule$(EXEEXT) keypairtest.sh \ + md_test$(EXEEXT) objectstest$(EXEEXT) $(am__append_8) \ + optionstest$(EXEEXT) pbkdf2$(EXEEXT) $(am__append_10) \ + pkcs7test$(EXEEXT) poly1305test$(EXEEXT) pq_test.sh \ + quictest.sh randtest$(EXEEXT) rc2_test$(EXEEXT) \ + rc4_test$(EXEEXT) recordtest$(EXEEXT) \ + record_layer_test$(EXEEXT) rfc3779$(EXEEXT) $(am__append_12) \ + $(am__EXEEXT_6) rmd_test$(EXEEXT) rsa_test$(EXEEXT) \ servertest.sh sha_test$(EXEEXT) sm3test$(EXEEXT) \ sm4test$(EXEEXT) ssl_get_shared_ciphers$(EXEEXT) \ ssl_methods$(EXEEXT) ssl_set_alpn_protos$(EXEEXT) \ @@ -128,78 +131,76 @@ TESTS = aeadtest.sh aes_wrap$(EXEEXT) $(am__append_2) \ valid_handshakes_terminate$(EXEEXT) verifytest$(EXEEXT) \ x25519test$(EXEEXT) x509attribute$(EXEEXT) x509_info$(EXEEXT) \ x509name$(EXEEXT) x509req_ext$(EXEEXT) -check_PROGRAMS = aeadtest$(EXEEXT) aes_wrap$(EXEEXT) $(am__EXEEXT_1) \ - asn1_string_to_utf8$(EXEEXT) asn1api$(EXEEXT) \ +check_PROGRAMS = aeadtest$(EXEEXT) aes_test$(EXEEXT) aes_wrap$(EXEEXT) \ + $(am__EXEEXT_1) asn1_string_to_utf8$(EXEEXT) asn1api$(EXEEXT) \ asn1basic$(EXEEXT) asn1complex$(EXEEXT) asn1evp$(EXEEXT) \ asn1object$(EXEEXT) asn1string_copy$(EXEEXT) asn1test$(EXEEXT) \ asn1time$(EXEEXT) asn1x509$(EXEEXT) base64test$(EXEEXT) \ - bftest$(EXEEXT) $(am__EXEEXT_2) bnaddsub$(EXEEXT) \ - bn_isqrt$(EXEEXT) bn_mod_exp2_mont$(EXEEXT) \ - bn_mod_sqrt$(EXEEXT) bn_primes$(EXEEXT) \ - bn_rand_interval$(EXEEXT) bntest$(EXEEXT) \ - bn_to_string$(EXEEXT) buffertest$(EXEEXT) \ + bf_test$(EXEEXT) bio_chain$(EXEEXT) $(am__EXEEXT_2) \ + bio_mem$(EXEEXT) bn_add_sub$(EXEEXT) bn_cmp$(EXEEXT) \ + bn_isqrt$(EXEEXT) bn_mod_exp$(EXEEXT) \ + bn_mod_exp2_mont$(EXEEXT) bn_mod_sqrt$(EXEEXT) \ + bn_mont$(EXEEXT) bn_primes$(EXEEXT) bn_rand_interval$(EXEEXT) \ + bn_shift$(EXEEXT) bn_test$(EXEEXT) bn_to_string$(EXEEXT) \ + bn_unit$(EXEEXT) bn_word$(EXEEXT) buffertest$(EXEEXT) \ bytestringtest$(EXEEXT) casttest$(EXEEXT) chachatest$(EXEEXT) \ cipher_list$(EXEEXT) cipherstest$(EXEEXT) clienttest$(EXEEXT) \ cmstest$(EXEEXT) configtest$(EXEEXT) constraints$(EXEEXT) \ cts128test$(EXEEXT) destest$(EXEEXT) dhtest$(EXEEXT) \ - dsatest$(EXEEXT) $(am__EXEEXT_3) ec_asn1_test$(EXEEXT) \ + dsatest$(EXEEXT) ec_asn1_test$(EXEEXT) \ ec_point_conversion$(EXEEXT) ecdhtest$(EXEEXT) \ - ecdsatest$(EXEEXT) ectest$(EXEEXT) enginetest$(EXEEXT) \ + ecdsatest$(EXEEXT) ectest$(EXEEXT) ed25519test$(EXEEXT) \ + enginetest$(EXEEXT) evp_ecx_test$(EXEEXT) \ evp_pkey_check$(EXEEXT) evp_pkey_cleanup$(EXEEXT) \ - evptest$(EXEEXT) $(am__EXEEXT_4) exptest$(EXEEXT) \ - freenull$(EXEEXT) gcm128test$(EXEEXT) gost2814789t$(EXEEXT) \ + evptest$(EXEEXT) $(am__EXEEXT_3) freenull$(EXEEXT) \ + gcm128test$(EXEEXT) gost2814789t$(EXEEXT) \ handshake_table$(EXEEXT) hkdftest$(EXEEXT) hmactest$(EXEEXT) \ ideatest$(EXEEXT) igetest$(EXEEXT) key_schedule$(EXEEXT) \ - keypairtest$(EXEEXT) md_test$(EXEEXT) mont$(EXEEXT) \ - objectstest$(EXEEXT) $(am__EXEEXT_5) optionstest$(EXEEXT) \ - pbkdf2$(EXEEXT) $(am__EXEEXT_6) pkcs7test$(EXEEXT) \ - poly1305test$(EXEEXT) pq_test$(EXEEXT) quictest$(EXEEXT) \ - randtest$(EXEEXT) rc2_test$(EXEEXT) rc4_test$(EXEEXT) \ - recordtest$(EXEEXT) record_layer_test$(EXEEXT) \ - rfc3779$(EXEEXT) rfc5280time$(EXEEXT) rmd_test$(EXEEXT) \ - rsa_test$(EXEEXT) servertest$(EXEEXT) sha_test$(EXEEXT) \ - sm3test$(EXEEXT) sm4test$(EXEEXT) \ - ssl_get_shared_ciphers$(EXEEXT) ssl_methods$(EXEEXT) \ - ssl_set_alpn_protos$(EXEEXT) ssl_versions$(EXEEXT) \ - ssltest$(EXEEXT) string_table$(EXEEXT) timingsafe$(EXEEXT) \ - tlsexttest$(EXEEXT) tlslegacytest$(EXEEXT) tlstest$(EXEEXT) \ - tls_ext_alpn$(EXEEXT) tls_prf$(EXEEXT) utf8test$(EXEEXT) \ - valid_handshakes_terminate$(EXEEXT) verifytest$(EXEEXT) \ - x25519test$(EXEEXT) x509attribute$(EXEEXT) x509_info$(EXEEXT) \ - x509name$(EXEEXT) x509req_ext$(EXEEXT) + keypairtest$(EXEEXT) md_test$(EXEEXT) objectstest$(EXEEXT) \ + $(am__EXEEXT_4) optionstest$(EXEEXT) pbkdf2$(EXEEXT) \ + $(am__EXEEXT_5) pkcs7test$(EXEEXT) poly1305test$(EXEEXT) \ + pq_test$(EXEEXT) quictest$(EXEEXT) randtest$(EXEEXT) \ + rc2_test$(EXEEXT) rc4_test$(EXEEXT) recordtest$(EXEEXT) \ + record_layer_test$(EXEEXT) rfc3779$(EXEEXT) \ + rfc5280time$(EXEEXT) rmd_test$(EXEEXT) rsa_test$(EXEEXT) \ + servertest$(EXEEXT) sha_test$(EXEEXT) sm3test$(EXEEXT) \ + sm4test$(EXEEXT) ssl_get_shared_ciphers$(EXEEXT) \ + ssl_methods$(EXEEXT) ssl_set_alpn_protos$(EXEEXT) \ + ssl_versions$(EXEEXT) ssltest$(EXEEXT) string_table$(EXEEXT) \ + timingsafe$(EXEEXT) tlsexttest$(EXEEXT) tlslegacytest$(EXEEXT) \ + tlstest$(EXEEXT) tls_ext_alpn$(EXEEXT) tls_prf$(EXEEXT) \ + utf8test$(EXEEXT) valid_handshakes_terminate$(EXEEXT) \ + verifytest$(EXEEXT) x25519test$(EXEEXT) x509attribute$(EXEEXT) \ + x509_info$(EXEEXT) x509name$(EXEEXT) x509req_ext$(EXEEXT) # arc4randomforktest # Windows/mingw does not have fork, but Cygwin does. -@HOST_WIN_FALSE@am__append_2 = arc4randomforktest.sh -@HOST_WIN_FALSE@am__append_3 = arc4randomforktest +@HOST_WIN_FALSE@am__append_1 = arc4randomforktest.sh +@HOST_WIN_FALSE@am__append_2 = arc4randomforktest -# biotest -# the BIO tests rely on resolver results that are OS and environment-specific -@ENABLE_EXTRATESTS_TRUE@am__append_4 = biotest -@ENABLE_EXTRATESTS_TRUE@am__append_5 = biotest - -# dtlstest -@HOST_WIN_FALSE@am__append_6 = dtlstest.sh -@HOST_WIN_FALSE@am__append_7 = dtlstest +# bio_host +# this test relies on resolver results that are OS and environment-specific +@ENABLE_EXTRATESTS_TRUE@am__append_3 = bio_host +@ENABLE_EXTRATESTS_TRUE@am__append_4 = bio_host # explicit_bzero # explicit_bzero relies on SA_ONSTACK, which is unavailable on Windows -@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@am__append_8 = explicit_bzero -@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@am__append_9 = explicit_bzero -@HAVE_MEMMEM_FALSE@@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@am__append_10 = compat/memmem.c +@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@am__append_5 = explicit_bzero +@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@am__append_6 = explicit_bzero +@HAVE_MEMMEM_FALSE@@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@am__append_7 = compat/memmem.c # ocsp_test -@ENABLE_EXTRATESTS_TRUE@am__append_11 = ocsptest.sh -@ENABLE_EXTRATESTS_TRUE@am__append_12 = ocsp_test +@ENABLE_EXTRATESTS_TRUE@am__append_8 = ocsptest.sh +@ENABLE_EXTRATESTS_TRUE@am__append_9 = ocsp_test # pidwraptest # pidwraptest relies on an OS-specific way to give out pids and is generally # awkward on systems with slow fork -@ENABLE_EXTRATESTS_TRUE@am__append_13 = pidwraptest.sh -@ENABLE_EXTRATESTS_TRUE@am__append_14 = pidwraptest -@SMALL_TIME_T_TRUE@am__append_15 = rfc5280time_small.test -@SMALL_TIME_T_FALSE@am__append_16 = rfc5280time -@HAVE_PIPE2_FALSE@am__append_17 = compat/pipe2.c +@ENABLE_EXTRATESTS_TRUE@am__append_10 = pidwraptest.sh +@ENABLE_EXTRATESTS_TRUE@am__append_11 = pidwraptest +@SMALL_TIME_T_TRUE@am__append_12 = rfc5280time_small.test +@SMALL_TIME_T_FALSE@am__append_13 = rfc5280time +@HAVE_PIPE2_FALSE@am__append_14 = compat/pipe2.c subdir = tests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_add_fortify_source.m4 \ @@ -219,363 +220,313 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @HOST_WIN_FALSE@am__EXEEXT_1 = arc4randomforktest$(EXEEXT) -@ENABLE_EXTRATESTS_TRUE@am__EXEEXT_2 = biotest$(EXEEXT) -@HOST_WIN_FALSE@am__EXEEXT_3 = dtlstest$(EXEEXT) -@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@am__EXEEXT_4 = \ +@ENABLE_EXTRATESTS_TRUE@am__EXEEXT_2 = bio_host$(EXEEXT) +@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@am__EXEEXT_3 = \ @HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@ explicit_bzero$(EXEEXT) -@ENABLE_EXTRATESTS_TRUE@am__EXEEXT_5 = ocsp_test$(EXEEXT) -@ENABLE_EXTRATESTS_TRUE@am__EXEEXT_6 = pidwraptest$(EXEEXT) -am_aeadtest_OBJECTS = aeadtest.$(OBJEXT) -aeadtest_OBJECTS = $(am_aeadtest_OBJECTS) -aeadtest_LDADD = $(LDADD) -am__DEPENDENCIES_1 = -aeadtest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +@ENABLE_EXTRATESTS_TRUE@am__EXEEXT_4 = ocsp_test$(EXEEXT) +@ENABLE_EXTRATESTS_TRUE@am__EXEEXT_5 = pidwraptest$(EXEEXT) +LTLIBRARIES = $(noinst_LTLIBRARIES) +libtest_la_DEPENDENCIES = +am_libtest_la_OBJECTS = empty.lo +libtest_la_OBJECTS = $(am_libtest_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = +am_aeadtest_OBJECTS = aeadtest.$(OBJEXT) +aeadtest_OBJECTS = $(am_aeadtest_OBJECTS) +aeadtest_LDADD = $(LDADD) +am__DEPENDENCIES_1 = +aeadtest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_aes_test_OBJECTS = aes_test.$(OBJEXT) +aes_test_OBJECTS = $(am_aes_test_OBJECTS) +aes_test_LDADD = $(LDADD) +aes_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_aes_wrap_OBJECTS = aes_wrap.$(OBJEXT) aes_wrap_OBJECTS = $(am_aes_wrap_OBJECTS) aes_wrap_LDADD = $(LDADD) -aes_wrap_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +aes_wrap_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am__arc4randomforktest_SOURCES_DIST = arc4randomforktest.c @HOST_WIN_FALSE@am_arc4randomforktest_OBJECTS = \ @HOST_WIN_FALSE@ arc4randomforktest.$(OBJEXT) arc4randomforktest_OBJECTS = $(am_arc4randomforktest_OBJECTS) arc4randomforktest_LDADD = $(LDADD) -arc4randomforktest_DEPENDENCIES = \ - $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +arc4randomforktest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_asn1_string_to_utf8_OBJECTS = asn1_string_to_utf8.$(OBJEXT) asn1_string_to_utf8_OBJECTS = $(am_asn1_string_to_utf8_OBJECTS) asn1_string_to_utf8_LDADD = $(LDADD) -asn1_string_to_utf8_DEPENDENCIES = \ - $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +asn1_string_to_utf8_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_asn1api_OBJECTS = asn1api.$(OBJEXT) asn1api_OBJECTS = $(am_asn1api_OBJECTS) asn1api_LDADD = $(LDADD) -asn1api_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +asn1api_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_asn1basic_OBJECTS = asn1basic.$(OBJEXT) asn1basic_OBJECTS = $(am_asn1basic_OBJECTS) asn1basic_LDADD = $(LDADD) -asn1basic_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +asn1basic_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_asn1complex_OBJECTS = asn1complex.$(OBJEXT) asn1complex_OBJECTS = $(am_asn1complex_OBJECTS) asn1complex_LDADD = $(LDADD) -asn1complex_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +asn1complex_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_asn1evp_OBJECTS = asn1evp.$(OBJEXT) asn1evp_OBJECTS = $(am_asn1evp_OBJECTS) asn1evp_LDADD = $(LDADD) -asn1evp_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +asn1evp_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_asn1object_OBJECTS = asn1object.$(OBJEXT) asn1object_OBJECTS = $(am_asn1object_OBJECTS) asn1object_LDADD = $(LDADD) -asn1object_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +asn1object_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_asn1string_copy_OBJECTS = asn1string_copy.$(OBJEXT) asn1string_copy_OBJECTS = $(am_asn1string_copy_OBJECTS) asn1string_copy_LDADD = $(LDADD) -asn1string_copy_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +asn1string_copy_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_asn1test_OBJECTS = asn1test.$(OBJEXT) asn1test_OBJECTS = $(am_asn1test_OBJECTS) asn1test_LDADD = $(LDADD) -asn1test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +asn1test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_asn1time_OBJECTS = asn1time.$(OBJEXT) asn1time_OBJECTS = $(am_asn1time_OBJECTS) asn1time_LDADD = $(LDADD) -asn1time_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +asn1time_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_asn1x509_OBJECTS = asn1x509.$(OBJEXT) asn1x509_OBJECTS = $(am_asn1x509_OBJECTS) asn1x509_LDADD = $(LDADD) -asn1x509_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +asn1x509_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_base64test_OBJECTS = base64test.$(OBJEXT) base64test_OBJECTS = $(am_base64test_OBJECTS) base64test_LDADD = $(LDADD) -base64test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) -am_bftest_OBJECTS = bftest.$(OBJEXT) -bftest_OBJECTS = $(am_bftest_OBJECTS) -bftest_LDADD = $(LDADD) -bftest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) -am__biotest_SOURCES_DIST = biotest.c -@ENABLE_EXTRATESTS_TRUE@am_biotest_OBJECTS = biotest.$(OBJEXT) -biotest_OBJECTS = $(am_biotest_OBJECTS) -biotest_LDADD = $(LDADD) -biotest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +base64test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bf_test_OBJECTS = bf_test.$(OBJEXT) +bf_test_OBJECTS = $(am_bf_test_OBJECTS) +bf_test_LDADD = $(LDADD) +bf_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bio_chain_OBJECTS = bio_chain.$(OBJEXT) +bio_chain_OBJECTS = $(am_bio_chain_OBJECTS) +bio_chain_LDADD = $(LDADD) +bio_chain_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am__bio_host_SOURCES_DIST = bio_host.c +@ENABLE_EXTRATESTS_TRUE@am_bio_host_OBJECTS = bio_host.$(OBJEXT) +bio_host_OBJECTS = $(am_bio_host_OBJECTS) +bio_host_LDADD = $(LDADD) +bio_host_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bio_mem_OBJECTS = bio_mem.$(OBJEXT) +bio_mem_OBJECTS = $(am_bio_mem_OBJECTS) +bio_mem_LDADD = $(LDADD) +bio_mem_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bn_add_sub_OBJECTS = bn_add_sub.$(OBJEXT) +bn_add_sub_OBJECTS = $(am_bn_add_sub_OBJECTS) +bn_add_sub_LDADD = $(LDADD) +bn_add_sub_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bn_cmp_OBJECTS = bn_cmp.$(OBJEXT) +bn_cmp_OBJECTS = $(am_bn_cmp_OBJECTS) +bn_cmp_LDADD = $(LDADD) +bn_cmp_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_bn_isqrt_OBJECTS = bn_isqrt.$(OBJEXT) bn_isqrt_OBJECTS = $(am_bn_isqrt_OBJECTS) bn_isqrt_LDADD = $(LDADD) -bn_isqrt_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +bn_isqrt_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bn_mod_exp_OBJECTS = bn_mod_exp-bn_mod_exp.$(OBJEXT) +bn_mod_exp_OBJECTS = $(am_bn_mod_exp_OBJECTS) +bn_mod_exp_LDADD = $(LDADD) +bn_mod_exp_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_bn_mod_exp2_mont_OBJECTS = bn_mod_exp2_mont.$(OBJEXT) bn_mod_exp2_mont_OBJECTS = $(am_bn_mod_exp2_mont_OBJECTS) bn_mod_exp2_mont_LDADD = $(LDADD) -bn_mod_exp2_mont_DEPENDENCIES = \ - $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +bn_mod_exp2_mont_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_bn_mod_sqrt_OBJECTS = bn_mod_sqrt.$(OBJEXT) bn_mod_sqrt_OBJECTS = $(am_bn_mod_sqrt_OBJECTS) bn_mod_sqrt_LDADD = $(LDADD) -bn_mod_sqrt_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +bn_mod_sqrt_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bn_mont_OBJECTS = bn_mont.$(OBJEXT) +bn_mont_OBJECTS = $(am_bn_mont_OBJECTS) +bn_mont_LDADD = $(LDADD) +bn_mont_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_bn_primes_OBJECTS = bn_primes.$(OBJEXT) bn_primes_OBJECTS = $(am_bn_primes_OBJECTS) bn_primes_LDADD = $(LDADD) -bn_primes_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +bn_primes_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_bn_rand_interval_OBJECTS = bn_rand_interval.$(OBJEXT) bn_rand_interval_OBJECTS = $(am_bn_rand_interval_OBJECTS) bn_rand_interval_LDADD = $(LDADD) -bn_rand_interval_DEPENDENCIES = \ - $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +bn_rand_interval_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bn_shift_OBJECTS = bn_shift.$(OBJEXT) +bn_shift_OBJECTS = $(am_bn_shift_OBJECTS) +bn_shift_LDADD = $(LDADD) +bn_shift_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bn_test_OBJECTS = bn_test-bn_test.$(OBJEXT) +bn_test_OBJECTS = $(am_bn_test_OBJECTS) +bn_test_LDADD = $(LDADD) +bn_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_bn_to_string_OBJECTS = bn_to_string.$(OBJEXT) bn_to_string_OBJECTS = $(am_bn_to_string_OBJECTS) bn_to_string_LDADD = $(LDADD) -bn_to_string_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) -am_bnaddsub_OBJECTS = bnaddsub.$(OBJEXT) -bnaddsub_OBJECTS = $(am_bnaddsub_OBJECTS) -bnaddsub_LDADD = $(LDADD) -bnaddsub_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) -am_bntest_OBJECTS = bntest-bntest.$(OBJEXT) -bntest_OBJECTS = $(am_bntest_OBJECTS) -bntest_LDADD = $(LDADD) -bntest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +bn_to_string_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bn_unit_OBJECTS = bn_unit.$(OBJEXT) +bn_unit_OBJECTS = $(am_bn_unit_OBJECTS) +bn_unit_LDADD = $(LDADD) +bn_unit_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_bn_word_OBJECTS = bn_word.$(OBJEXT) +bn_word_OBJECTS = $(am_bn_word_OBJECTS) +bn_word_LDADD = $(LDADD) +bn_word_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_buffertest_OBJECTS = buffertest.$(OBJEXT) buffertest_OBJECTS = $(am_buffertest_OBJECTS) buffertest_LDADD = $(LDADD) -buffertest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +buffertest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_bytestringtest_OBJECTS = bytestringtest.$(OBJEXT) bytestringtest_OBJECTS = $(am_bytestringtest_OBJECTS) bytestringtest_LDADD = $(LDADD) -bytestringtest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +bytestringtest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_casttest_OBJECTS = casttest.$(OBJEXT) casttest_OBJECTS = $(am_casttest_OBJECTS) casttest_LDADD = $(LDADD) -casttest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +casttest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_chachatest_OBJECTS = chachatest.$(OBJEXT) chachatest_OBJECTS = $(am_chachatest_OBJECTS) chachatest_LDADD = $(LDADD) -chachatest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +chachatest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_cipher_list_OBJECTS = cipher_list.$(OBJEXT) cipher_list_OBJECTS = $(am_cipher_list_OBJECTS) cipher_list_LDADD = $(LDADD) -cipher_list_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +cipher_list_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_cipherstest_OBJECTS = cipherstest.$(OBJEXT) cipherstest_OBJECTS = $(am_cipherstest_OBJECTS) cipherstest_LDADD = $(LDADD) -cipherstest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +cipherstest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_clienttest_OBJECTS = clienttest.$(OBJEXT) clienttest_OBJECTS = $(am_clienttest_OBJECTS) clienttest_LDADD = $(LDADD) -clienttest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +clienttest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_cmstest_OBJECTS = cmstest.$(OBJEXT) cmstest_OBJECTS = $(am_cmstest_OBJECTS) cmstest_LDADD = $(LDADD) -cmstest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +cmstest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_configtest_OBJECTS = configtest.$(OBJEXT) configtest_OBJECTS = $(am_configtest_OBJECTS) configtest_LDADD = $(LDADD) -configtest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +configtest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_constraints_OBJECTS = constraints.$(OBJEXT) constraints_OBJECTS = $(am_constraints_OBJECTS) constraints_LDADD = $(LDADD) -constraints_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +constraints_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_cts128test_OBJECTS = cts128test.$(OBJEXT) cts128test_OBJECTS = $(am_cts128test_OBJECTS) cts128test_LDADD = $(LDADD) -cts128test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +cts128test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_destest_OBJECTS = destest.$(OBJEXT) destest_OBJECTS = $(am_destest_OBJECTS) destest_LDADD = $(LDADD) -destest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +destest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_dhtest_OBJECTS = dhtest.$(OBJEXT) dhtest_OBJECTS = $(am_dhtest_OBJECTS) dhtest_LDADD = $(LDADD) -dhtest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +dhtest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_dsatest_OBJECTS = dsatest.$(OBJEXT) dsatest_OBJECTS = $(am_dsatest_OBJECTS) dsatest_LDADD = $(LDADD) -dsatest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) -am__dtlstest_SOURCES_DIST = dtlstest.c -@HOST_WIN_FALSE@am_dtlstest_OBJECTS = dtlstest.$(OBJEXT) -dtlstest_OBJECTS = $(am_dtlstest_OBJECTS) -dtlstest_LDADD = $(LDADD) -dtlstest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +dsatest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ec_asn1_test_OBJECTS = ec_asn1_test.$(OBJEXT) ec_asn1_test_OBJECTS = $(am_ec_asn1_test_OBJECTS) ec_asn1_test_LDADD = $(LDADD) -ec_asn1_test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ec_asn1_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ec_point_conversion_OBJECTS = ec_point_conversion.$(OBJEXT) ec_point_conversion_OBJECTS = $(am_ec_point_conversion_OBJECTS) ec_point_conversion_LDADD = $(LDADD) -ec_point_conversion_DEPENDENCIES = \ - $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ec_point_conversion_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ecdhtest_OBJECTS = ecdhtest.$(OBJEXT) ecdhtest_OBJECTS = $(am_ecdhtest_OBJECTS) ecdhtest_LDADD = $(LDADD) -ecdhtest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ecdhtest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ecdsatest_OBJECTS = ecdsatest.$(OBJEXT) ecdsatest_OBJECTS = $(am_ecdsatest_OBJECTS) ecdsatest_LDADD = $(LDADD) -ecdsatest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ecdsatest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ectest_OBJECTS = ectest.$(OBJEXT) ectest_OBJECTS = $(am_ectest_OBJECTS) ectest_LDADD = $(LDADD) -ectest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ectest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_ed25519test_OBJECTS = ed25519test.$(OBJEXT) +ed25519test_OBJECTS = $(am_ed25519test_OBJECTS) +ed25519test_LDADD = $(LDADD) +ed25519test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_enginetest_OBJECTS = enginetest.$(OBJEXT) enginetest_OBJECTS = $(am_enginetest_OBJECTS) enginetest_LDADD = $(LDADD) -enginetest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +enginetest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_evp_ecx_test_OBJECTS = evp_ecx_test.$(OBJEXT) +evp_ecx_test_OBJECTS = $(am_evp_ecx_test_OBJECTS) +evp_ecx_test_LDADD = $(LDADD) +evp_ecx_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_evp_pkey_check_OBJECTS = evp_pkey_check.$(OBJEXT) evp_pkey_check_OBJECTS = $(am_evp_pkey_check_OBJECTS) evp_pkey_check_LDADD = $(LDADD) -evp_pkey_check_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +evp_pkey_check_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_evp_pkey_cleanup_OBJECTS = evp_pkey_cleanup.$(OBJEXT) evp_pkey_cleanup_OBJECTS = $(am_evp_pkey_cleanup_OBJECTS) evp_pkey_cleanup_LDADD = $(LDADD) -evp_pkey_cleanup_DEPENDENCIES = \ - $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +evp_pkey_cleanup_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_evptest_OBJECTS = evptest.$(OBJEXT) evptest_OBJECTS = $(am_evptest_OBJECTS) evptest_LDADD = $(LDADD) -evptest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +evptest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am__explicit_bzero_SOURCES_DIST = explicit_bzero.c compat/memmem.c am__dirstamp = $(am__leading_dot)dirstamp @HAVE_MEMMEM_FALSE@@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@am__objects_1 = compat/memmem.$(OBJEXT) @@ -584,407 +535,281 @@ am__dirstamp = $(am__leading_dot)dirstamp @HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@ $(am__objects_1) explicit_bzero_OBJECTS = $(am_explicit_bzero_OBJECTS) explicit_bzero_LDADD = $(LDADD) -explicit_bzero_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) -am_exptest_OBJECTS = exptest-exptest.$(OBJEXT) -exptest_OBJECTS = $(am_exptest_OBJECTS) -exptest_LDADD = $(LDADD) -exptest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) -am_freenull_OBJECTS = freenull.$(OBJEXT) +explicit_bzero_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_freenull_OBJECTS = freenull-freenull.$(OBJEXT) freenull_OBJECTS = $(am_freenull_OBJECTS) freenull_LDADD = $(LDADD) -freenull_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +freenull_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_gcm128test_OBJECTS = gcm128test.$(OBJEXT) gcm128test_OBJECTS = $(am_gcm128test_OBJECTS) gcm128test_LDADD = $(LDADD) -gcm128test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +gcm128test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_gost2814789t_OBJECTS = gost2814789t.$(OBJEXT) gost2814789t_OBJECTS = $(am_gost2814789t_OBJECTS) gost2814789t_LDADD = $(LDADD) -gost2814789t_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +gost2814789t_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_handshake_table_OBJECTS = handshake_table.$(OBJEXT) handshake_table_OBJECTS = $(am_handshake_table_OBJECTS) handshake_table_LDADD = $(LDADD) -handshake_table_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +handshake_table_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_hkdftest_OBJECTS = hkdf_test.$(OBJEXT) hkdftest_OBJECTS = $(am_hkdftest_OBJECTS) hkdftest_LDADD = $(LDADD) -hkdftest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +hkdftest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_hmactest_OBJECTS = hmactest.$(OBJEXT) hmactest_OBJECTS = $(am_hmactest_OBJECTS) hmactest_LDADD = $(LDADD) -hmactest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +hmactest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ideatest_OBJECTS = ideatest.$(OBJEXT) ideatest_OBJECTS = $(am_ideatest_OBJECTS) ideatest_LDADD = $(LDADD) -ideatest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ideatest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_igetest_OBJECTS = igetest.$(OBJEXT) igetest_OBJECTS = $(am_igetest_OBJECTS) igetest_LDADD = $(LDADD) -igetest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +igetest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_key_schedule_OBJECTS = key_schedule.$(OBJEXT) key_schedule_OBJECTS = $(am_key_schedule_OBJECTS) key_schedule_LDADD = $(LDADD) -key_schedule_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +key_schedule_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_keypairtest_OBJECTS = keypairtest-keypairtest.$(OBJEXT) keypairtest_OBJECTS = $(am_keypairtest_OBJECTS) keypairtest_LDADD = $(LDADD) -keypairtest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +keypairtest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_md_test_OBJECTS = md_test.$(OBJEXT) md_test_OBJECTS = $(am_md_test_OBJECTS) md_test_LDADD = $(LDADD) -md_test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) -am_mont_OBJECTS = mont.$(OBJEXT) -mont_OBJECTS = $(am_mont_OBJECTS) -mont_LDADD = $(LDADD) -mont_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +md_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_objectstest_OBJECTS = objectstest.$(OBJEXT) objectstest_OBJECTS = $(am_objectstest_OBJECTS) objectstest_LDADD = $(LDADD) -objectstest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +objectstest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am__ocsp_test_SOURCES_DIST = ocsp_test.c @ENABLE_EXTRATESTS_TRUE@am_ocsp_test_OBJECTS = ocsp_test.$(OBJEXT) ocsp_test_OBJECTS = $(am_ocsp_test_OBJECTS) ocsp_test_LDADD = $(LDADD) -ocsp_test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ocsp_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_optionstest_OBJECTS = optionstest.$(OBJEXT) optionstest_OBJECTS = $(am_optionstest_OBJECTS) optionstest_LDADD = $(LDADD) -optionstest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +optionstest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_pbkdf2_OBJECTS = pbkdf2.$(OBJEXT) pbkdf2_OBJECTS = $(am_pbkdf2_OBJECTS) pbkdf2_LDADD = $(LDADD) -pbkdf2_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +pbkdf2_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am__pidwraptest_SOURCES_DIST = pidwraptest.c @ENABLE_EXTRATESTS_TRUE@am_pidwraptest_OBJECTS = \ @ENABLE_EXTRATESTS_TRUE@ pidwraptest.$(OBJEXT) pidwraptest_OBJECTS = $(am_pidwraptest_OBJECTS) pidwraptest_LDADD = $(LDADD) -pidwraptest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +pidwraptest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_pkcs7test_OBJECTS = pkcs7test.$(OBJEXT) pkcs7test_OBJECTS = $(am_pkcs7test_OBJECTS) pkcs7test_LDADD = $(LDADD) -pkcs7test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +pkcs7test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_poly1305test_OBJECTS = poly1305test.$(OBJEXT) poly1305test_OBJECTS = $(am_poly1305test_OBJECTS) poly1305test_LDADD = $(LDADD) -poly1305test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +poly1305test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_pq_test_OBJECTS = pq_test.$(OBJEXT) pq_test_OBJECTS = $(am_pq_test_OBJECTS) pq_test_LDADD = $(LDADD) -pq_test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +pq_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_quictest_OBJECTS = quictest.$(OBJEXT) quictest_OBJECTS = $(am_quictest_OBJECTS) quictest_LDADD = $(LDADD) -quictest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +quictest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_randtest_OBJECTS = randtest.$(OBJEXT) randtest_OBJECTS = $(am_randtest_OBJECTS) randtest_LDADD = $(LDADD) -randtest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +randtest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_rc2_test_OBJECTS = rc2_test.$(OBJEXT) rc2_test_OBJECTS = $(am_rc2_test_OBJECTS) rc2_test_LDADD = $(LDADD) -rc2_test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +rc2_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_rc4_test_OBJECTS = rc4_test.$(OBJEXT) rc4_test_OBJECTS = $(am_rc4_test_OBJECTS) rc4_test_LDADD = $(LDADD) -rc4_test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +rc4_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_record_layer_test_OBJECTS = record_layer_test.$(OBJEXT) record_layer_test_OBJECTS = $(am_record_layer_test_OBJECTS) record_layer_test_LDADD = $(LDADD) -record_layer_test_DEPENDENCIES = \ - $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +record_layer_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_recordtest_OBJECTS = recordtest.$(OBJEXT) recordtest_OBJECTS = $(am_recordtest_OBJECTS) recordtest_LDADD = $(LDADD) -recordtest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +recordtest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_rfc3779_OBJECTS = rfc3779-rfc3779.$(OBJEXT) rfc3779_OBJECTS = $(am_rfc3779_OBJECTS) rfc3779_LDADD = $(LDADD) -rfc3779_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +rfc3779_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_rfc5280time_OBJECTS = rfc5280time.$(OBJEXT) rfc5280time_OBJECTS = $(am_rfc5280time_OBJECTS) rfc5280time_LDADD = $(LDADD) -rfc5280time_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +rfc5280time_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_rmd_test_OBJECTS = rmd_test.$(OBJEXT) rmd_test_OBJECTS = $(am_rmd_test_OBJECTS) rmd_test_LDADD = $(LDADD) -rmd_test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +rmd_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_rsa_test_OBJECTS = rsa_test.$(OBJEXT) rsa_test_OBJECTS = $(am_rsa_test_OBJECTS) rsa_test_LDADD = $(LDADD) -rsa_test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +rsa_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_servertest_OBJECTS = servertest.$(OBJEXT) servertest_OBJECTS = $(am_servertest_OBJECTS) servertest_LDADD = $(LDADD) -servertest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +servertest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_sha_test_OBJECTS = sha_test.$(OBJEXT) sha_test_OBJECTS = $(am_sha_test_OBJECTS) sha_test_LDADD = $(LDADD) -sha_test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +sha_test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_sm3test_OBJECTS = sm3test.$(OBJEXT) sm3test_OBJECTS = $(am_sm3test_OBJECTS) sm3test_LDADD = $(LDADD) -sm3test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +sm3test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_sm4test_OBJECTS = sm4test.$(OBJEXT) sm4test_OBJECTS = $(am_sm4test_OBJECTS) sm4test_LDADD = $(LDADD) -sm4test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +sm4test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ssl_get_shared_ciphers_OBJECTS = \ ssl_get_shared_ciphers-ssl_get_shared_ciphers.$(OBJEXT) ssl_get_shared_ciphers_OBJECTS = $(am_ssl_get_shared_ciphers_OBJECTS) ssl_get_shared_ciphers_LDADD = $(LDADD) -ssl_get_shared_ciphers_DEPENDENCIES = \ - $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ssl_get_shared_ciphers_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ssl_methods_OBJECTS = ssl_methods.$(OBJEXT) ssl_methods_OBJECTS = $(am_ssl_methods_OBJECTS) ssl_methods_LDADD = $(LDADD) -ssl_methods_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ssl_methods_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ssl_set_alpn_protos_OBJECTS = ssl_set_alpn_protos.$(OBJEXT) ssl_set_alpn_protos_OBJECTS = $(am_ssl_set_alpn_protos_OBJECTS) ssl_set_alpn_protos_LDADD = $(LDADD) -ssl_set_alpn_protos_DEPENDENCIES = \ - $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ssl_set_alpn_protos_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ssl_versions_OBJECTS = ssl_versions.$(OBJEXT) ssl_versions_OBJECTS = $(am_ssl_versions_OBJECTS) ssl_versions_LDADD = $(LDADD) -ssl_versions_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ssl_versions_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_ssltest_OBJECTS = ssltest.$(OBJEXT) ssltest_OBJECTS = $(am_ssltest_OBJECTS) ssltest_LDADD = $(LDADD) -ssltest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +ssltest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_string_table_OBJECTS = string_table.$(OBJEXT) string_table_OBJECTS = $(am_string_table_OBJECTS) string_table_LDADD = $(LDADD) -string_table_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +string_table_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_timingsafe_OBJECTS = timingsafe.$(OBJEXT) timingsafe_OBJECTS = $(am_timingsafe_OBJECTS) timingsafe_LDADD = $(LDADD) -timingsafe_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +timingsafe_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_tls_ext_alpn_OBJECTS = tls_ext_alpn.$(OBJEXT) tls_ext_alpn_OBJECTS = $(am_tls_ext_alpn_OBJECTS) tls_ext_alpn_LDADD = $(LDADD) -tls_ext_alpn_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +tls_ext_alpn_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_tls_prf_OBJECTS = tls_prf.$(OBJEXT) tls_prf_OBJECTS = $(am_tls_prf_OBJECTS) tls_prf_LDADD = $(LDADD) -tls_prf_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +tls_prf_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_tlsexttest_OBJECTS = tlsexttest.$(OBJEXT) tlsexttest_OBJECTS = $(am_tlsexttest_OBJECTS) tlsexttest_LDADD = $(LDADD) -tlsexttest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +tlsexttest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_tlslegacytest_OBJECTS = tlslegacytest.$(OBJEXT) tlslegacytest_OBJECTS = $(am_tlslegacytest_OBJECTS) tlslegacytest_LDADD = $(LDADD) -tlslegacytest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +tlslegacytest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am__tlstest_SOURCES_DIST = tlstest.c compat/pipe2.c @HAVE_PIPE2_FALSE@am__objects_2 = compat/pipe2.$(OBJEXT) am_tlstest_OBJECTS = tlstest.$(OBJEXT) $(am__objects_2) tlstest_OBJECTS = $(am_tlstest_OBJECTS) tlstest_LDADD = $(LDADD) -tlstest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +tlstest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_utf8test_OBJECTS = utf8test.$(OBJEXT) utf8test_OBJECTS = $(am_utf8test_OBJECTS) utf8test_LDADD = $(LDADD) -utf8test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +utf8test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_valid_handshakes_terminate_OBJECTS = \ valid_handshakes_terminate.$(OBJEXT) valid_handshakes_terminate_OBJECTS = \ $(am_valid_handshakes_terminate_OBJECTS) valid_handshakes_terminate_LDADD = $(LDADD) -valid_handshakes_terminate_DEPENDENCIES = \ - $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +valid_handshakes_terminate_DEPENDENCIES = libtest.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_verifytest_OBJECTS = verifytest.$(OBJEXT) verifytest_OBJECTS = $(am_verifytest_OBJECTS) verifytest_LDADD = $(LDADD) -verifytest_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +verifytest_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_x25519test_OBJECTS = x25519test.$(OBJEXT) x25519test_OBJECTS = $(am_x25519test_OBJECTS) x25519test_LDADD = $(LDADD) -x25519test_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +x25519test_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_x509_info_OBJECTS = x509_info.$(OBJEXT) x509_info_OBJECTS = $(am_x509_info_OBJECTS) x509_info_LDADD = $(LDADD) -x509_info_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +x509_info_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_x509attribute_OBJECTS = x509attribute.$(OBJEXT) x509attribute_OBJECTS = $(am_x509attribute_OBJECTS) x509attribute_LDADD = $(LDADD) -x509attribute_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +x509attribute_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_x509name_OBJECTS = x509name.$(OBJEXT) x509name_OBJECTS = $(am_x509name_OBJECTS) x509name_LDADD = $(LDADD) -x509name_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +x509name_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) am_x509req_ext_OBJECTS = x509req_ext.$(OBJEXT) x509req_ext_OBJECTS = $(am_x509req_ext_OBJECTS) x509req_ext_LDADD = $(LDADD) -x509req_ext_DEPENDENCIES = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_1) +x509req_ext_DEPENDENCIES = libtest.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -1000,49 +825,53 @@ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ./$(DEPDIR)/aeadtest.Po ./$(DEPDIR)/aes_wrap.Po \ - ./$(DEPDIR)/arc4randomforktest.Po \ +am__depfiles_remade = ./$(DEPDIR)/aeadtest.Po ./$(DEPDIR)/aes_test.Po \ + ./$(DEPDIR)/aes_wrap.Po ./$(DEPDIR)/arc4randomforktest.Po \ ./$(DEPDIR)/asn1_string_to_utf8.Po ./$(DEPDIR)/asn1api.Po \ ./$(DEPDIR)/asn1basic.Po ./$(DEPDIR)/asn1complex.Po \ ./$(DEPDIR)/asn1evp.Po ./$(DEPDIR)/asn1object.Po \ ./$(DEPDIR)/asn1string_copy.Po ./$(DEPDIR)/asn1test.Po \ ./$(DEPDIR)/asn1time.Po ./$(DEPDIR)/asn1x509.Po \ - ./$(DEPDIR)/base64test.Po ./$(DEPDIR)/bftest.Po \ - ./$(DEPDIR)/biotest.Po ./$(DEPDIR)/bn_isqrt.Po \ + ./$(DEPDIR)/base64test.Po ./$(DEPDIR)/bf_test.Po \ + ./$(DEPDIR)/bio_chain.Po ./$(DEPDIR)/bio_host.Po \ + ./$(DEPDIR)/bio_mem.Po ./$(DEPDIR)/bn_add_sub.Po \ + ./$(DEPDIR)/bn_cmp.Po ./$(DEPDIR)/bn_isqrt.Po \ + ./$(DEPDIR)/bn_mod_exp-bn_mod_exp.Po \ ./$(DEPDIR)/bn_mod_exp2_mont.Po ./$(DEPDIR)/bn_mod_sqrt.Po \ - ./$(DEPDIR)/bn_primes.Po ./$(DEPDIR)/bn_rand_interval.Po \ - ./$(DEPDIR)/bn_to_string.Po ./$(DEPDIR)/bnaddsub.Po \ - ./$(DEPDIR)/bntest-bntest.Po ./$(DEPDIR)/buffertest.Po \ - ./$(DEPDIR)/bytestringtest.Po ./$(DEPDIR)/casttest.Po \ - ./$(DEPDIR)/chachatest.Po ./$(DEPDIR)/cipher_list.Po \ - ./$(DEPDIR)/cipherstest.Po ./$(DEPDIR)/clienttest.Po \ - ./$(DEPDIR)/cmstest.Po ./$(DEPDIR)/configtest.Po \ - ./$(DEPDIR)/constraints.Po ./$(DEPDIR)/cts128test.Po \ - ./$(DEPDIR)/destest.Po ./$(DEPDIR)/dhtest.Po \ - ./$(DEPDIR)/dsatest.Po ./$(DEPDIR)/dtlstest.Po \ + ./$(DEPDIR)/bn_mont.Po ./$(DEPDIR)/bn_primes.Po \ + ./$(DEPDIR)/bn_rand_interval.Po ./$(DEPDIR)/bn_shift.Po \ + ./$(DEPDIR)/bn_test-bn_test.Po ./$(DEPDIR)/bn_to_string.Po \ + ./$(DEPDIR)/bn_unit.Po ./$(DEPDIR)/bn_word.Po \ + ./$(DEPDIR)/buffertest.Po ./$(DEPDIR)/bytestringtest.Po \ + ./$(DEPDIR)/casttest.Po ./$(DEPDIR)/chachatest.Po \ + ./$(DEPDIR)/cipher_list.Po ./$(DEPDIR)/cipherstest.Po \ + ./$(DEPDIR)/clienttest.Po ./$(DEPDIR)/cmstest.Po \ + ./$(DEPDIR)/configtest.Po ./$(DEPDIR)/constraints.Po \ + ./$(DEPDIR)/cts128test.Po ./$(DEPDIR)/destest.Po \ + ./$(DEPDIR)/dhtest.Po ./$(DEPDIR)/dsatest.Po \ ./$(DEPDIR)/ec_asn1_test.Po ./$(DEPDIR)/ec_point_conversion.Po \ ./$(DEPDIR)/ecdhtest.Po ./$(DEPDIR)/ecdsatest.Po \ - ./$(DEPDIR)/ectest.Po ./$(DEPDIR)/enginetest.Po \ - ./$(DEPDIR)/evp_pkey_check.Po ./$(DEPDIR)/evp_pkey_cleanup.Po \ - ./$(DEPDIR)/evptest.Po ./$(DEPDIR)/explicit_bzero.Po \ - ./$(DEPDIR)/exptest-exptest.Po ./$(DEPDIR)/freenull.Po \ + ./$(DEPDIR)/ectest.Po ./$(DEPDIR)/ed25519test.Po \ + ./$(DEPDIR)/empty.Plo ./$(DEPDIR)/enginetest.Po \ + ./$(DEPDIR)/evp_ecx_test.Po ./$(DEPDIR)/evp_pkey_check.Po \ + ./$(DEPDIR)/evp_pkey_cleanup.Po ./$(DEPDIR)/evptest.Po \ + ./$(DEPDIR)/explicit_bzero.Po ./$(DEPDIR)/freenull-freenull.Po \ ./$(DEPDIR)/gcm128test.Po ./$(DEPDIR)/gost2814789t.Po \ ./$(DEPDIR)/handshake_table.Po ./$(DEPDIR)/hkdf_test.Po \ ./$(DEPDIR)/hmactest.Po ./$(DEPDIR)/ideatest.Po \ ./$(DEPDIR)/igetest.Po ./$(DEPDIR)/key_schedule.Po \ ./$(DEPDIR)/keypairtest-keypairtest.Po ./$(DEPDIR)/md_test.Po \ - ./$(DEPDIR)/mont.Po ./$(DEPDIR)/objectstest.Po \ - ./$(DEPDIR)/ocsp_test.Po ./$(DEPDIR)/optionstest.Po \ - ./$(DEPDIR)/pbkdf2.Po ./$(DEPDIR)/pidwraptest.Po \ - ./$(DEPDIR)/pkcs7test.Po ./$(DEPDIR)/poly1305test.Po \ - ./$(DEPDIR)/pq_test.Po ./$(DEPDIR)/quictest.Po \ - ./$(DEPDIR)/randtest.Po ./$(DEPDIR)/rc2_test.Po \ - ./$(DEPDIR)/rc4_test.Po ./$(DEPDIR)/record_layer_test.Po \ - ./$(DEPDIR)/recordtest.Po ./$(DEPDIR)/rfc3779-rfc3779.Po \ - ./$(DEPDIR)/rfc5280time.Po ./$(DEPDIR)/rmd_test.Po \ - ./$(DEPDIR)/rsa_test.Po ./$(DEPDIR)/servertest.Po \ - ./$(DEPDIR)/sha_test.Po ./$(DEPDIR)/sm3test.Po \ - ./$(DEPDIR)/sm4test.Po \ + ./$(DEPDIR)/objectstest.Po ./$(DEPDIR)/ocsp_test.Po \ + ./$(DEPDIR)/optionstest.Po ./$(DEPDIR)/pbkdf2.Po \ + ./$(DEPDIR)/pidwraptest.Po ./$(DEPDIR)/pkcs7test.Po \ + ./$(DEPDIR)/poly1305test.Po ./$(DEPDIR)/pq_test.Po \ + ./$(DEPDIR)/quictest.Po ./$(DEPDIR)/randtest.Po \ + ./$(DEPDIR)/rc2_test.Po ./$(DEPDIR)/rc4_test.Po \ + ./$(DEPDIR)/record_layer_test.Po ./$(DEPDIR)/recordtest.Po \ + ./$(DEPDIR)/rfc3779-rfc3779.Po ./$(DEPDIR)/rfc5280time.Po \ + ./$(DEPDIR)/rmd_test.Po ./$(DEPDIR)/rsa_test.Po \ + ./$(DEPDIR)/servertest.Po ./$(DEPDIR)/sha_test.Po \ + ./$(DEPDIR)/sm3test.Po ./$(DEPDIR)/sm4test.Po \ ./$(DEPDIR)/ssl_get_shared_ciphers-ssl_get_shared_ciphers.Po \ ./$(DEPDIR)/ssl_methods.Po ./$(DEPDIR)/ssl_set_alpn_protos.Po \ ./$(DEPDIR)/ssl_versions.Po ./$(DEPDIR)/ssltest.Po \ @@ -1074,33 +903,38 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(aeadtest_SOURCES) $(aes_wrap_SOURCES) \ +SOURCES = $(libtest_la_SOURCES) $(aeadtest_SOURCES) \ + $(aes_test_SOURCES) $(aes_wrap_SOURCES) \ $(arc4randomforktest_SOURCES) $(asn1_string_to_utf8_SOURCES) \ $(asn1api_SOURCES) $(asn1basic_SOURCES) $(asn1complex_SOURCES) \ $(asn1evp_SOURCES) $(asn1object_SOURCES) \ $(asn1string_copy_SOURCES) $(asn1test_SOURCES) \ $(asn1time_SOURCES) $(asn1x509_SOURCES) $(base64test_SOURCES) \ - $(bftest_SOURCES) $(biotest_SOURCES) $(bn_isqrt_SOURCES) \ + $(bf_test_SOURCES) $(bio_chain_SOURCES) $(bio_host_SOURCES) \ + $(bio_mem_SOURCES) $(bn_add_sub_SOURCES) $(bn_cmp_SOURCES) \ + $(bn_isqrt_SOURCES) $(bn_mod_exp_SOURCES) \ $(bn_mod_exp2_mont_SOURCES) $(bn_mod_sqrt_SOURCES) \ - $(bn_primes_SOURCES) $(bn_rand_interval_SOURCES) \ - $(bn_to_string_SOURCES) $(bnaddsub_SOURCES) $(bntest_SOURCES) \ - $(buffertest_SOURCES) $(bytestringtest_SOURCES) \ - $(casttest_SOURCES) $(chachatest_SOURCES) \ - $(cipher_list_SOURCES) $(cipherstest_SOURCES) \ - $(clienttest_SOURCES) $(cmstest_SOURCES) $(configtest_SOURCES) \ + $(bn_mont_SOURCES) $(bn_primes_SOURCES) \ + $(bn_rand_interval_SOURCES) $(bn_shift_SOURCES) \ + $(bn_test_SOURCES) $(bn_to_string_SOURCES) $(bn_unit_SOURCES) \ + $(bn_word_SOURCES) $(buffertest_SOURCES) \ + $(bytestringtest_SOURCES) $(casttest_SOURCES) \ + $(chachatest_SOURCES) $(cipher_list_SOURCES) \ + $(cipherstest_SOURCES) $(clienttest_SOURCES) \ + $(cmstest_SOURCES) $(configtest_SOURCES) \ $(constraints_SOURCES) $(cts128test_SOURCES) \ $(destest_SOURCES) $(dhtest_SOURCES) $(dsatest_SOURCES) \ - $(dtlstest_SOURCES) $(ec_asn1_test_SOURCES) \ - $(ec_point_conversion_SOURCES) $(ecdhtest_SOURCES) \ - $(ecdsatest_SOURCES) $(ectest_SOURCES) $(enginetest_SOURCES) \ - $(evp_pkey_check_SOURCES) $(evp_pkey_cleanup_SOURCES) \ - $(evptest_SOURCES) $(explicit_bzero_SOURCES) \ - $(exptest_SOURCES) $(freenull_SOURCES) $(gcm128test_SOURCES) \ - $(gost2814789t_SOURCES) $(handshake_table_SOURCES) \ - $(hkdftest_SOURCES) $(hmactest_SOURCES) $(ideatest_SOURCES) \ - $(igetest_SOURCES) $(key_schedule_SOURCES) \ - $(keypairtest_SOURCES) $(md_test_SOURCES) $(mont_SOURCES) \ - $(objectstest_SOURCES) $(ocsp_test_SOURCES) \ + $(ec_asn1_test_SOURCES) $(ec_point_conversion_SOURCES) \ + $(ecdhtest_SOURCES) $(ecdsatest_SOURCES) $(ectest_SOURCES) \ + $(ed25519test_SOURCES) $(enginetest_SOURCES) \ + $(evp_ecx_test_SOURCES) $(evp_pkey_check_SOURCES) \ + $(evp_pkey_cleanup_SOURCES) $(evptest_SOURCES) \ + $(explicit_bzero_SOURCES) $(freenull_SOURCES) \ + $(gcm128test_SOURCES) $(gost2814789t_SOURCES) \ + $(handshake_table_SOURCES) $(hkdftest_SOURCES) \ + $(hmactest_SOURCES) $(ideatest_SOURCES) $(igetest_SOURCES) \ + $(key_schedule_SOURCES) $(keypairtest_SOURCES) \ + $(md_test_SOURCES) $(objectstest_SOURCES) $(ocsp_test_SOURCES) \ $(optionstest_SOURCES) $(pbkdf2_SOURCES) \ $(pidwraptest_SOURCES) $(pkcs7test_SOURCES) \ $(poly1305test_SOURCES) $(pq_test_SOURCES) $(quictest_SOURCES) \ @@ -1119,38 +953,43 @@ SOURCES = $(aeadtest_SOURCES) $(aes_wrap_SOURCES) \ $(verifytest_SOURCES) $(x25519test_SOURCES) \ $(x509_info_SOURCES) $(x509attribute_SOURCES) \ $(x509name_SOURCES) $(x509req_ext_SOURCES) -DIST_SOURCES = $(aeadtest_SOURCES) $(aes_wrap_SOURCES) \ +DIST_SOURCES = $(libtest_la_SOURCES) $(aeadtest_SOURCES) \ + $(aes_test_SOURCES) $(aes_wrap_SOURCES) \ $(am__arc4randomforktest_SOURCES_DIST) \ $(asn1_string_to_utf8_SOURCES) $(asn1api_SOURCES) \ $(asn1basic_SOURCES) $(asn1complex_SOURCES) $(asn1evp_SOURCES) \ $(asn1object_SOURCES) $(asn1string_copy_SOURCES) \ $(asn1test_SOURCES) $(asn1time_SOURCES) $(asn1x509_SOURCES) \ - $(base64test_SOURCES) $(bftest_SOURCES) \ - $(am__biotest_SOURCES_DIST) $(bn_isqrt_SOURCES) \ - $(bn_mod_exp2_mont_SOURCES) $(bn_mod_sqrt_SOURCES) \ - $(bn_primes_SOURCES) $(bn_rand_interval_SOURCES) \ - $(bn_to_string_SOURCES) $(bnaddsub_SOURCES) $(bntest_SOURCES) \ - $(buffertest_SOURCES) $(bytestringtest_SOURCES) \ - $(casttest_SOURCES) $(chachatest_SOURCES) \ - $(cipher_list_SOURCES) $(cipherstest_SOURCES) \ - $(clienttest_SOURCES) $(cmstest_SOURCES) $(configtest_SOURCES) \ + $(base64test_SOURCES) $(bf_test_SOURCES) $(bio_chain_SOURCES) \ + $(am__bio_host_SOURCES_DIST) $(bio_mem_SOURCES) \ + $(bn_add_sub_SOURCES) $(bn_cmp_SOURCES) $(bn_isqrt_SOURCES) \ + $(bn_mod_exp_SOURCES) $(bn_mod_exp2_mont_SOURCES) \ + $(bn_mod_sqrt_SOURCES) $(bn_mont_SOURCES) $(bn_primes_SOURCES) \ + $(bn_rand_interval_SOURCES) $(bn_shift_SOURCES) \ + $(bn_test_SOURCES) $(bn_to_string_SOURCES) $(bn_unit_SOURCES) \ + $(bn_word_SOURCES) $(buffertest_SOURCES) \ + $(bytestringtest_SOURCES) $(casttest_SOURCES) \ + $(chachatest_SOURCES) $(cipher_list_SOURCES) \ + $(cipherstest_SOURCES) $(clienttest_SOURCES) \ + $(cmstest_SOURCES) $(configtest_SOURCES) \ $(constraints_SOURCES) $(cts128test_SOURCES) \ $(destest_SOURCES) $(dhtest_SOURCES) $(dsatest_SOURCES) \ - $(am__dtlstest_SOURCES_DIST) $(ec_asn1_test_SOURCES) \ - $(ec_point_conversion_SOURCES) $(ecdhtest_SOURCES) \ - $(ecdsatest_SOURCES) $(ectest_SOURCES) $(enginetest_SOURCES) \ - $(evp_pkey_check_SOURCES) $(evp_pkey_cleanup_SOURCES) \ - $(evptest_SOURCES) $(am__explicit_bzero_SOURCES_DIST) \ - $(exptest_SOURCES) $(freenull_SOURCES) $(gcm128test_SOURCES) \ - $(gost2814789t_SOURCES) $(handshake_table_SOURCES) \ - $(hkdftest_SOURCES) $(hmactest_SOURCES) $(ideatest_SOURCES) \ - $(igetest_SOURCES) $(key_schedule_SOURCES) \ - $(keypairtest_SOURCES) $(md_test_SOURCES) $(mont_SOURCES) \ - $(objectstest_SOURCES) $(am__ocsp_test_SOURCES_DIST) \ - $(optionstest_SOURCES) $(pbkdf2_SOURCES) \ - $(am__pidwraptest_SOURCES_DIST) $(pkcs7test_SOURCES) \ - $(poly1305test_SOURCES) $(pq_test_SOURCES) $(quictest_SOURCES) \ - $(randtest_SOURCES) $(rc2_test_SOURCES) $(rc4_test_SOURCES) \ + $(ec_asn1_test_SOURCES) $(ec_point_conversion_SOURCES) \ + $(ecdhtest_SOURCES) $(ecdsatest_SOURCES) $(ectest_SOURCES) \ + $(ed25519test_SOURCES) $(enginetest_SOURCES) \ + $(evp_ecx_test_SOURCES) $(evp_pkey_check_SOURCES) \ + $(evp_pkey_cleanup_SOURCES) $(evptest_SOURCES) \ + $(am__explicit_bzero_SOURCES_DIST) $(freenull_SOURCES) \ + $(gcm128test_SOURCES) $(gost2814789t_SOURCES) \ + $(handshake_table_SOURCES) $(hkdftest_SOURCES) \ + $(hmactest_SOURCES) $(ideatest_SOURCES) $(igetest_SOURCES) \ + $(key_schedule_SOURCES) $(keypairtest_SOURCES) \ + $(md_test_SOURCES) $(objectstest_SOURCES) \ + $(am__ocsp_test_SOURCES_DIST) $(optionstest_SOURCES) \ + $(pbkdf2_SOURCES) $(am__pidwraptest_SOURCES_DIST) \ + $(pkcs7test_SOURCES) $(poly1305test_SOURCES) \ + $(pq_test_SOURCES) $(quictest_SOURCES) $(randtest_SOURCES) \ + $(rc2_test_SOURCES) $(rc4_test_SOURCES) \ $(record_layer_test_SOURCES) $(recordtest_SOURCES) \ $(rfc3779_SOURCES) $(rfc5280time_SOURCES) $(rmd_test_SOURCES) \ $(rsa_test_SOURCES) $(servertest_SOURCES) $(sha_test_SOURCES) \ @@ -1373,7 +1212,7 @@ am__set_TESTS_bases = \ AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck -@SMALL_TIME_T_FALSE@am__EXEEXT_7 = rfc5280time$(EXEEXT) +@SMALL_TIME_T_FALSE@am__EXEEXT_6 = rfc5280time$(EXEEXT) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver @@ -1525,32 +1364,34 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ - -DLIBRESSL_INTERNAL -D__BEGIN_HIDDEN_DECLS= \ - -D__END_HIDDEN_DECLS= -DLIBRESSL_CRYPTO_INTERNAL -I \ - $(top_srcdir)/crypto/asn1 -I $(top_srcdir)/crypto/bio -I \ - $(top_srcdir)/crypto/bn -I $(top_srcdir)/crypto/evp -I \ +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(abs_top_builddir)/include \ + -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL \ + -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= \ + -DLIBRESSL_CRYPTO_INTERNAL -I $(top_srcdir)/crypto/asn1 -I \ + $(top_srcdir)/crypto/bio -I $(top_srcdir)/crypto/bn -I \ + $(top_srcdir)/crypto/curve25519 -I $(top_srcdir)/crypto/evp -I \ $(top_srcdir)/crypto/modes -I $(top_srcdir)/crypto/x509 -I \ $(top_srcdir)/ssl -I $(top_srcdir)/apps/openssl -I \ $(top_srcdir)/apps/openssl/compat \ -D_PATH_SSL_CA_FILE=\"$(top_srcdir)/cert.pem\" -LDADD = $(abs_top_builddir)/tls/.libs/libtls.a \ - $(abs_top_builddir)/ssl/.libs/libssl.a \ - $(abs_top_builddir)/crypto/.libs/libcrypto.a $(PLATFORM_LDADD) \ - $(PROG_LDADD) $(am__append_1) +noinst_LTLIBRARIES = libtest.la +libtest_la_LIBADD = $(libcrypto_la_objects) $(libcompat_la_objects) \ + $(libcompatnoopt_la_objects) $(libssl_la_objects) \ + $(libtls_la_objects) +libtest_la_SOURCES = empty.c +LDADD = libtest.la $(PLATFORM_LDADD) $(PROG_LDADD) TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh EXTRA_DIST = CMakeLists.txt aeadtest.sh aeadtests.txt \ aes_128_gcm_tests.txt aes_192_gcm_tests.txt \ aes_256_gcm_tests.txt chacha20_poly1305_tests.txt \ - xchacha20_poly1305_tests.txt arc4randomforktest.sh dtlstest.sh \ - evptest.sh evptests.txt keypairtest.sh ocsptest.sh \ - ocsptest.bat pidwraptest.sh pq_test.sh pq_test.bat \ - pq_expected.txt quictest.sh quictest.bat \ - rfc5280time_small.test servertest.sh servertest.bat ssltest.sh \ - ssltest.bat testssl testssl.bat ca-int-ecdsa.crl \ - ca-int-ecdsa.pem ca-int-rsa.crl ca-int-rsa.pem \ - ca-root-ecdsa.pem ca-root-rsa.pem ca.pem client.pem \ - client1-ecdsa-chain.pem client1-ecdsa.pem \ + xchacha20_poly1305_tests.txt arc4randomforktest.sh evptest.sh \ + evptests.txt keypairtest.sh ocsptest.sh ocsptest.bat \ + pidwraptest.sh pq_test.sh pq_test.bat pq_expected.txt \ + quictest.sh quictest.bat rfc5280time_small.test servertest.sh \ + servertest.bat ssltest.sh ssltest.bat testssl testssl.bat \ + ca-int-ecdsa.crl ca-int-ecdsa.pem ca-int-rsa.crl \ + ca-int-rsa.pem ca-root-ecdsa.pem ca-root-rsa.pem ca.pem \ + client.pem client1-ecdsa-chain.pem client1-ecdsa.pem \ client1-rsa-chain.pem client1-rsa.pem client2-ecdsa-chain.pem \ client2-ecdsa.pem client2-rsa-chain.pem client2-rsa.pem \ client3-ecdsa-chain.pem client3-ecdsa.pem \ @@ -1564,6 +1405,7 @@ EXTRA_DIST = CMakeLists.txt aeadtest.sh aeadtests.txt \ tlstest.sh tlstest.bat DISTCLEANFILES = pidwraptest.txt aeadtest_SOURCES = aeadtest.c +aes_test_SOURCES = aes_test.c aes_wrap_SOURCES = aes_wrap.c @HOST_WIN_FALSE@arc4randomforktest_SOURCES = arc4randomforktest.c asn1_string_to_utf8_SOURCES = asn1_string_to_utf8.c @@ -1577,17 +1419,26 @@ asn1test_SOURCES = asn1test.c asn1time_SOURCES = asn1time.c asn1x509_SOURCES = asn1x509.c base64test_SOURCES = base64test.c -bftest_SOURCES = bftest.c -@ENABLE_EXTRATESTS_TRUE@biotest_SOURCES = biotest.c -bnaddsub_SOURCES = bnaddsub.c +bf_test_SOURCES = bf_test.c +bio_chain_SOURCES = bio_chain.c +@ENABLE_EXTRATESTS_TRUE@bio_host_SOURCES = bio_host.c +bio_mem_SOURCES = bio_mem.c +bn_add_sub_SOURCES = bn_add_sub.c +bn_cmp_SOURCES = bn_cmp.c bn_isqrt_SOURCES = bn_isqrt.c +bn_mod_exp_CPPFLAGS = $(AM_CPPFLAGS) -ULIBRESSL_INTERNAL +bn_mod_exp_SOURCES = bn_mod_exp.c bn_mod_exp2_mont_SOURCES = bn_mod_exp2_mont.c bn_mod_sqrt_SOURCES = bn_mod_sqrt.c +bn_mont_SOURCES = bn_mont.c bn_primes_SOURCES = bn_primes.c bn_rand_interval_SOURCES = bn_rand_interval.c -bntest_CPPFLAGS = $(AM_CPPFLAGS) -ULIBRESSL_INTERNAL -bntest_SOURCES = bntest.c +bn_shift_SOURCES = bn_shift.c +bn_test_CPPFLAGS = $(AM_CPPFLAGS) -ULIBRESSL_INTERNAL +bn_test_SOURCES = bn_test.c bn_to_string_SOURCES = bn_to_string.c +bn_unit_SOURCES = bn_unit.c +bn_word_SOURCES = bn_word.c buffertest_SOURCES = buffertest.c bytestringtest_SOURCES = bytestringtest.c casttest_SOURCES = casttest.c @@ -1603,21 +1454,21 @@ cts128test_SOURCES = cts128test.c destest_SOURCES = destest.c dhtest_SOURCES = dhtest.c dsatest_SOURCES = dsatest.c -@HOST_WIN_FALSE@dtlstest_SOURCES = dtlstest.c ec_asn1_test_SOURCES = ec_asn1_test.c ec_point_conversion_SOURCES = ec_point_conversion.c ecdhtest_SOURCES = ecdhtest.c ecdsatest_SOURCES = ecdsatest.c ectest_SOURCES = ectest.c +ed25519test_SOURCES = ed25519test.c enginetest_SOURCES = enginetest.c +evp_ecx_test_SOURCES = evp_ecx_test.c evp_pkey_check_SOURCES = evp_pkey_check.c evp_pkey_cleanup_SOURCES = evp_pkey_cleanup.c evptest_SOURCES = evptest.c @HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@explicit_bzero_SOURCES = \ @HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@ explicit_bzero.c \ -@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@ $(am__append_10) -exptest_CPPFLAGS = $(AM_CPPFLAGS) -ULIBRESSL_INTERNAL -exptest_SOURCES = exptest.c +@HOST_CYGWIN_FALSE@@HOST_WIN_FALSE@ $(am__append_7) +freenull_CPPFLAGS = $(AM_CPPFLAGS) -ULIBRESSL_INTERNAL freenull_SOURCES = freenull.c gcm128test_SOURCES = gcm128test.c gost2814789t_SOURCES = gost2814789t.c @@ -1630,7 +1481,6 @@ key_schedule_SOURCES = key_schedule.c keypairtest_CPPFLAGS = -I $(top_srcdir)/tls $(AM_CPPFLAGS) keypairtest_SOURCES = keypairtest.c md_test_SOURCES = md_test.c -mont_SOURCES = mont.c objectstest_SOURCES = objectstest.c @ENABLE_EXTRATESTS_TRUE@ocsp_test_SOURCES = ocsp_test.c optionstest_SOURCES = optionstest.c @@ -1664,7 +1514,7 @@ string_table_SOURCES = string_table.c timingsafe_SOURCES = timingsafe.c tlsexttest_SOURCES = tlsexttest.c tlslegacytest_SOURCES = tlslegacytest.c -tlstest_SOURCES = tlstest.c $(am__append_17) +tlstest_SOURCES = tlstest.c $(am__append_14) tls_ext_alpn_SOURCES = tls_ext_alpn.c tls_prf_SOURCES = tls_prf.c utf8test_SOURCES = utf8test.c @@ -1719,10 +1569,28 @@ clean-checkPROGRAMS: echo " rm -f" $$list; \ rm -f $$list +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libtest.la: $(libtest_la_OBJECTS) $(libtest_la_DEPENDENCIES) $(EXTRA_libtest_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libtest_la_OBJECTS) $(libtest_la_LIBADD) $(LIBS) + aeadtest$(EXEEXT): $(aeadtest_OBJECTS) $(aeadtest_DEPENDENCIES) $(EXTRA_aeadtest_DEPENDENCIES) @rm -f aeadtest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(aeadtest_OBJECTS) $(aeadtest_LDADD) $(LIBS) +aes_test$(EXEEXT): $(aes_test_OBJECTS) $(aes_test_DEPENDENCIES) $(EXTRA_aes_test_DEPENDENCIES) + @rm -f aes_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(aes_test_OBJECTS) $(aes_test_LDADD) $(LIBS) + aes_wrap$(EXEEXT): $(aes_wrap_OBJECTS) $(aes_wrap_DEPENDENCIES) $(EXTRA_aes_wrap_DEPENDENCIES) @rm -f aes_wrap$(EXEEXT) $(AM_V_CCLD)$(LINK) $(aes_wrap_OBJECTS) $(aes_wrap_LDADD) $(LIBS) @@ -1775,18 +1643,38 @@ base64test$(EXEEXT): $(base64test_OBJECTS) $(base64test_DEPENDENCIES) $(EXTRA_ba @rm -f base64test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(base64test_OBJECTS) $(base64test_LDADD) $(LIBS) -bftest$(EXEEXT): $(bftest_OBJECTS) $(bftest_DEPENDENCIES) $(EXTRA_bftest_DEPENDENCIES) - @rm -f bftest$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(bftest_OBJECTS) $(bftest_LDADD) $(LIBS) +bf_test$(EXEEXT): $(bf_test_OBJECTS) $(bf_test_DEPENDENCIES) $(EXTRA_bf_test_DEPENDENCIES) + @rm -f bf_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bf_test_OBJECTS) $(bf_test_LDADD) $(LIBS) + +bio_chain$(EXEEXT): $(bio_chain_OBJECTS) $(bio_chain_DEPENDENCIES) $(EXTRA_bio_chain_DEPENDENCIES) + @rm -f bio_chain$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bio_chain_OBJECTS) $(bio_chain_LDADD) $(LIBS) + +bio_host$(EXEEXT): $(bio_host_OBJECTS) $(bio_host_DEPENDENCIES) $(EXTRA_bio_host_DEPENDENCIES) + @rm -f bio_host$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bio_host_OBJECTS) $(bio_host_LDADD) $(LIBS) + +bio_mem$(EXEEXT): $(bio_mem_OBJECTS) $(bio_mem_DEPENDENCIES) $(EXTRA_bio_mem_DEPENDENCIES) + @rm -f bio_mem$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bio_mem_OBJECTS) $(bio_mem_LDADD) $(LIBS) + +bn_add_sub$(EXEEXT): $(bn_add_sub_OBJECTS) $(bn_add_sub_DEPENDENCIES) $(EXTRA_bn_add_sub_DEPENDENCIES) + @rm -f bn_add_sub$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bn_add_sub_OBJECTS) $(bn_add_sub_LDADD) $(LIBS) -biotest$(EXEEXT): $(biotest_OBJECTS) $(biotest_DEPENDENCIES) $(EXTRA_biotest_DEPENDENCIES) - @rm -f biotest$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(biotest_OBJECTS) $(biotest_LDADD) $(LIBS) +bn_cmp$(EXEEXT): $(bn_cmp_OBJECTS) $(bn_cmp_DEPENDENCIES) $(EXTRA_bn_cmp_DEPENDENCIES) + @rm -f bn_cmp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bn_cmp_OBJECTS) $(bn_cmp_LDADD) $(LIBS) bn_isqrt$(EXEEXT): $(bn_isqrt_OBJECTS) $(bn_isqrt_DEPENDENCIES) $(EXTRA_bn_isqrt_DEPENDENCIES) @rm -f bn_isqrt$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bn_isqrt_OBJECTS) $(bn_isqrt_LDADD) $(LIBS) +bn_mod_exp$(EXEEXT): $(bn_mod_exp_OBJECTS) $(bn_mod_exp_DEPENDENCIES) $(EXTRA_bn_mod_exp_DEPENDENCIES) + @rm -f bn_mod_exp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bn_mod_exp_OBJECTS) $(bn_mod_exp_LDADD) $(LIBS) + bn_mod_exp2_mont$(EXEEXT): $(bn_mod_exp2_mont_OBJECTS) $(bn_mod_exp2_mont_DEPENDENCIES) $(EXTRA_bn_mod_exp2_mont_DEPENDENCIES) @rm -f bn_mod_exp2_mont$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bn_mod_exp2_mont_OBJECTS) $(bn_mod_exp2_mont_LDADD) $(LIBS) @@ -1795,6 +1683,10 @@ bn_mod_sqrt$(EXEEXT): $(bn_mod_sqrt_OBJECTS) $(bn_mod_sqrt_DEPENDENCIES) $(EXTRA @rm -f bn_mod_sqrt$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bn_mod_sqrt_OBJECTS) $(bn_mod_sqrt_LDADD) $(LIBS) +bn_mont$(EXEEXT): $(bn_mont_OBJECTS) $(bn_mont_DEPENDENCIES) $(EXTRA_bn_mont_DEPENDENCIES) + @rm -f bn_mont$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bn_mont_OBJECTS) $(bn_mont_LDADD) $(LIBS) + bn_primes$(EXEEXT): $(bn_primes_OBJECTS) $(bn_primes_DEPENDENCIES) $(EXTRA_bn_primes_DEPENDENCIES) @rm -f bn_primes$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bn_primes_OBJECTS) $(bn_primes_LDADD) $(LIBS) @@ -1803,17 +1695,25 @@ bn_rand_interval$(EXEEXT): $(bn_rand_interval_OBJECTS) $(bn_rand_interval_DEPEND @rm -f bn_rand_interval$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bn_rand_interval_OBJECTS) $(bn_rand_interval_LDADD) $(LIBS) +bn_shift$(EXEEXT): $(bn_shift_OBJECTS) $(bn_shift_DEPENDENCIES) $(EXTRA_bn_shift_DEPENDENCIES) + @rm -f bn_shift$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bn_shift_OBJECTS) $(bn_shift_LDADD) $(LIBS) + +bn_test$(EXEEXT): $(bn_test_OBJECTS) $(bn_test_DEPENDENCIES) $(EXTRA_bn_test_DEPENDENCIES) + @rm -f bn_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bn_test_OBJECTS) $(bn_test_LDADD) $(LIBS) + bn_to_string$(EXEEXT): $(bn_to_string_OBJECTS) $(bn_to_string_DEPENDENCIES) $(EXTRA_bn_to_string_DEPENDENCIES) @rm -f bn_to_string$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bn_to_string_OBJECTS) $(bn_to_string_LDADD) $(LIBS) -bnaddsub$(EXEEXT): $(bnaddsub_OBJECTS) $(bnaddsub_DEPENDENCIES) $(EXTRA_bnaddsub_DEPENDENCIES) - @rm -f bnaddsub$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(bnaddsub_OBJECTS) $(bnaddsub_LDADD) $(LIBS) +bn_unit$(EXEEXT): $(bn_unit_OBJECTS) $(bn_unit_DEPENDENCIES) $(EXTRA_bn_unit_DEPENDENCIES) + @rm -f bn_unit$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bn_unit_OBJECTS) $(bn_unit_LDADD) $(LIBS) -bntest$(EXEEXT): $(bntest_OBJECTS) $(bntest_DEPENDENCIES) $(EXTRA_bntest_DEPENDENCIES) - @rm -f bntest$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(bntest_OBJECTS) $(bntest_LDADD) $(LIBS) +bn_word$(EXEEXT): $(bn_word_OBJECTS) $(bn_word_DEPENDENCIES) $(EXTRA_bn_word_DEPENDENCIES) + @rm -f bn_word$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(bn_word_OBJECTS) $(bn_word_LDADD) $(LIBS) buffertest$(EXEEXT): $(buffertest_OBJECTS) $(buffertest_DEPENDENCIES) $(EXTRA_buffertest_DEPENDENCIES) @rm -f buffertest$(EXEEXT) @@ -1871,10 +1771,6 @@ dsatest$(EXEEXT): $(dsatest_OBJECTS) $(dsatest_DEPENDENCIES) $(EXTRA_dsatest_DEP @rm -f dsatest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dsatest_OBJECTS) $(dsatest_LDADD) $(LIBS) -dtlstest$(EXEEXT): $(dtlstest_OBJECTS) $(dtlstest_DEPENDENCIES) $(EXTRA_dtlstest_DEPENDENCIES) - @rm -f dtlstest$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(dtlstest_OBJECTS) $(dtlstest_LDADD) $(LIBS) - ec_asn1_test$(EXEEXT): $(ec_asn1_test_OBJECTS) $(ec_asn1_test_DEPENDENCIES) $(EXTRA_ec_asn1_test_DEPENDENCIES) @rm -f ec_asn1_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ec_asn1_test_OBJECTS) $(ec_asn1_test_LDADD) $(LIBS) @@ -1895,10 +1791,18 @@ ectest$(EXEEXT): $(ectest_OBJECTS) $(ectest_DEPENDENCIES) $(EXTRA_ectest_DEPENDE @rm -f ectest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ectest_OBJECTS) $(ectest_LDADD) $(LIBS) +ed25519test$(EXEEXT): $(ed25519test_OBJECTS) $(ed25519test_DEPENDENCIES) $(EXTRA_ed25519test_DEPENDENCIES) + @rm -f ed25519test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(ed25519test_OBJECTS) $(ed25519test_LDADD) $(LIBS) + enginetest$(EXEEXT): $(enginetest_OBJECTS) $(enginetest_DEPENDENCIES) $(EXTRA_enginetest_DEPENDENCIES) @rm -f enginetest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(enginetest_OBJECTS) $(enginetest_LDADD) $(LIBS) +evp_ecx_test$(EXEEXT): $(evp_ecx_test_OBJECTS) $(evp_ecx_test_DEPENDENCIES) $(EXTRA_evp_ecx_test_DEPENDENCIES) + @rm -f evp_ecx_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(evp_ecx_test_OBJECTS) $(evp_ecx_test_LDADD) $(LIBS) + evp_pkey_check$(EXEEXT): $(evp_pkey_check_OBJECTS) $(evp_pkey_check_DEPENDENCIES) $(EXTRA_evp_pkey_check_DEPENDENCIES) @rm -f evp_pkey_check$(EXEEXT) $(AM_V_CCLD)$(LINK) $(evp_pkey_check_OBJECTS) $(evp_pkey_check_LDADD) $(LIBS) @@ -1923,10 +1827,6 @@ explicit_bzero$(EXEEXT): $(explicit_bzero_OBJECTS) $(explicit_bzero_DEPENDENCIES @rm -f explicit_bzero$(EXEEXT) $(AM_V_CCLD)$(LINK) $(explicit_bzero_OBJECTS) $(explicit_bzero_LDADD) $(LIBS) -exptest$(EXEEXT): $(exptest_OBJECTS) $(exptest_DEPENDENCIES) $(EXTRA_exptest_DEPENDENCIES) - @rm -f exptest$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(exptest_OBJECTS) $(exptest_LDADD) $(LIBS) - freenull$(EXEEXT): $(freenull_OBJECTS) $(freenull_DEPENDENCIES) $(EXTRA_freenull_DEPENDENCIES) @rm -f freenull$(EXEEXT) $(AM_V_CCLD)$(LINK) $(freenull_OBJECTS) $(freenull_LDADD) $(LIBS) @@ -1971,10 +1871,6 @@ md_test$(EXEEXT): $(md_test_OBJECTS) $(md_test_DEPENDENCIES) $(EXTRA_md_test_DEP @rm -f md_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(md_test_OBJECTS) $(md_test_LDADD) $(LIBS) -mont$(EXEEXT): $(mont_OBJECTS) $(mont_DEPENDENCIES) $(EXTRA_mont_DEPENDENCIES) - @rm -f mont$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(mont_OBJECTS) $(mont_LDADD) $(LIBS) - objectstest$(EXEEXT): $(objectstest_OBJECTS) $(objectstest_DEPENDENCIES) $(EXTRA_objectstest_DEPENDENCIES) @rm -f objectstest$(EXEEXT) $(AM_V_CCLD)$(LINK) $(objectstest_OBJECTS) $(objectstest_LDADD) $(LIBS) @@ -2153,6 +2049,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aeadtest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aes_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aes_wrap.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arc4randomforktest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asn1_string_to_utf8.Po@am__quote@ # am--include-marker @@ -2166,16 +2063,24 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asn1time.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asn1x509.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bftest.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/biotest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bf_test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bio_chain.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bio_host.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bio_mem.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_add_sub.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_cmp.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_isqrt.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_mod_exp-bn_mod_exp.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_mod_exp2_mont.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_mod_sqrt.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_mont.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_primes.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_rand_interval.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_shift.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_test-bn_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_to_string.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bnaddsub.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bntest-bntest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_unit.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bn_word.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buffertest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bytestringtest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/casttest.Po@am__quote@ # am--include-marker @@ -2190,19 +2095,20 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/destest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhtest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dsatest.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dtlstest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ec_asn1_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ec_point_conversion.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecdhtest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecdsatest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ectest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ed25519test.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/empty.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enginetest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evp_ecx_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evp_pkey_check.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evp_pkey_cleanup.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evptest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/explicit_bzero.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exptest-exptest.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freenull.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freenull-freenull.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gcm128test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gost2814789t.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/handshake_table.Po@am__quote@ # am--include-marker @@ -2213,7 +2119,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/key_schedule.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keypairtest-keypairtest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md_test.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mont.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/objectstest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ocsp_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optionstest.Po@am__quote@ # am--include-marker @@ -2289,33 +2194,47 @@ am--depfiles: $(am__depfiles_remade) @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< -bntest-bntest.o: bntest.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bntest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bntest-bntest.o -MD -MP -MF $(DEPDIR)/bntest-bntest.Tpo -c -o bntest-bntest.o `test -f 'bntest.c' || echo '$(srcdir)/'`bntest.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bntest-bntest.Tpo $(DEPDIR)/bntest-bntest.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bntest.c' object='bntest-bntest.o' libtool=no @AMDEPBACKSLASH@ +bn_mod_exp-bn_mod_exp.o: bn_mod_exp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bn_mod_exp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn_mod_exp-bn_mod_exp.o -MD -MP -MF $(DEPDIR)/bn_mod_exp-bn_mod_exp.Tpo -c -o bn_mod_exp-bn_mod_exp.o `test -f 'bn_mod_exp.c' || echo '$(srcdir)/'`bn_mod_exp.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bn_mod_exp-bn_mod_exp.Tpo $(DEPDIR)/bn_mod_exp-bn_mod_exp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn_mod_exp.c' object='bn_mod_exp-bn_mod_exp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bn_mod_exp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn_mod_exp-bn_mod_exp.o `test -f 'bn_mod_exp.c' || echo '$(srcdir)/'`bn_mod_exp.c + +bn_mod_exp-bn_mod_exp.obj: bn_mod_exp.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bn_mod_exp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn_mod_exp-bn_mod_exp.obj -MD -MP -MF $(DEPDIR)/bn_mod_exp-bn_mod_exp.Tpo -c -o bn_mod_exp-bn_mod_exp.obj `if test -f 'bn_mod_exp.c'; then $(CYGPATH_W) 'bn_mod_exp.c'; else $(CYGPATH_W) '$(srcdir)/bn_mod_exp.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bn_mod_exp-bn_mod_exp.Tpo $(DEPDIR)/bn_mod_exp-bn_mod_exp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn_mod_exp.c' object='bn_mod_exp-bn_mod_exp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bn_mod_exp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn_mod_exp-bn_mod_exp.obj `if test -f 'bn_mod_exp.c'; then $(CYGPATH_W) 'bn_mod_exp.c'; else $(CYGPATH_W) '$(srcdir)/bn_mod_exp.c'; fi` + +bn_test-bn_test.o: bn_test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bn_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn_test-bn_test.o -MD -MP -MF $(DEPDIR)/bn_test-bn_test.Tpo -c -o bn_test-bn_test.o `test -f 'bn_test.c' || echo '$(srcdir)/'`bn_test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bn_test-bn_test.Tpo $(DEPDIR)/bn_test-bn_test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn_test.c' object='bn_test-bn_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bntest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bntest-bntest.o `test -f 'bntest.c' || echo '$(srcdir)/'`bntest.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bn_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn_test-bn_test.o `test -f 'bn_test.c' || echo '$(srcdir)/'`bn_test.c -bntest-bntest.obj: bntest.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bntest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bntest-bntest.obj -MD -MP -MF $(DEPDIR)/bntest-bntest.Tpo -c -o bntest-bntest.obj `if test -f 'bntest.c'; then $(CYGPATH_W) 'bntest.c'; else $(CYGPATH_W) '$(srcdir)/bntest.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bntest-bntest.Tpo $(DEPDIR)/bntest-bntest.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bntest.c' object='bntest-bntest.obj' libtool=no @AMDEPBACKSLASH@ +bn_test-bn_test.obj: bn_test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bn_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bn_test-bn_test.obj -MD -MP -MF $(DEPDIR)/bn_test-bn_test.Tpo -c -o bn_test-bn_test.obj `if test -f 'bn_test.c'; then $(CYGPATH_W) 'bn_test.c'; else $(CYGPATH_W) '$(srcdir)/bn_test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bn_test-bn_test.Tpo $(DEPDIR)/bn_test-bn_test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bn_test.c' object='bn_test-bn_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bntest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bntest-bntest.obj `if test -f 'bntest.c'; then $(CYGPATH_W) 'bntest.c'; else $(CYGPATH_W) '$(srcdir)/bntest.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bn_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bn_test-bn_test.obj `if test -f 'bn_test.c'; then $(CYGPATH_W) 'bn_test.c'; else $(CYGPATH_W) '$(srcdir)/bn_test.c'; fi` -exptest-exptest.o: exptest.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exptest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT exptest-exptest.o -MD -MP -MF $(DEPDIR)/exptest-exptest.Tpo -c -o exptest-exptest.o `test -f 'exptest.c' || echo '$(srcdir)/'`exptest.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/exptest-exptest.Tpo $(DEPDIR)/exptest-exptest.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='exptest.c' object='exptest-exptest.o' libtool=no @AMDEPBACKSLASH@ +freenull-freenull.o: freenull.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(freenull_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT freenull-freenull.o -MD -MP -MF $(DEPDIR)/freenull-freenull.Tpo -c -o freenull-freenull.o `test -f 'freenull.c' || echo '$(srcdir)/'`freenull.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/freenull-freenull.Tpo $(DEPDIR)/freenull-freenull.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='freenull.c' object='freenull-freenull.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exptest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o exptest-exptest.o `test -f 'exptest.c' || echo '$(srcdir)/'`exptest.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(freenull_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o freenull-freenull.o `test -f 'freenull.c' || echo '$(srcdir)/'`freenull.c -exptest-exptest.obj: exptest.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exptest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT exptest-exptest.obj -MD -MP -MF $(DEPDIR)/exptest-exptest.Tpo -c -o exptest-exptest.obj `if test -f 'exptest.c'; then $(CYGPATH_W) 'exptest.c'; else $(CYGPATH_W) '$(srcdir)/exptest.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/exptest-exptest.Tpo $(DEPDIR)/exptest-exptest.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='exptest.c' object='exptest-exptest.obj' libtool=no @AMDEPBACKSLASH@ +freenull-freenull.obj: freenull.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(freenull_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT freenull-freenull.obj -MD -MP -MF $(DEPDIR)/freenull-freenull.Tpo -c -o freenull-freenull.obj `if test -f 'freenull.c'; then $(CYGPATH_W) 'freenull.c'; else $(CYGPATH_W) '$(srcdir)/freenull.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/freenull-freenull.Tpo $(DEPDIR)/freenull-freenull.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='freenull.c' object='freenull-freenull.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(exptest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o exptest-exptest.obj `if test -f 'exptest.c'; then $(CYGPATH_W) 'exptest.c'; else $(CYGPATH_W) '$(srcdir)/exptest.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(freenull_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o freenull-freenull.obj `if test -f 'freenull.c'; then $(CYGPATH_W) 'freenull.c'; else $(CYGPATH_W) '$(srcdir)/freenull.c'; fi` keypairtest-keypairtest.o: keypairtest.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(keypairtest_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT keypairtest-keypairtest.o -MD -MP -MF $(DEPDIR)/keypairtest-keypairtest.Tpo -c -o keypairtest-keypairtest.o `test -f 'keypairtest.c' || echo '$(srcdir)/'`keypairtest.c @@ -2565,6 +2484,13 @@ aeadtest.sh.log: aeadtest.sh --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +aes_test.log: aes_test$(EXEEXT) + @p='aes_test$(EXEEXT)'; \ + b='aes_test'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) aes_wrap.log: aes_wrap$(EXEEXT) @p='aes_wrap$(EXEEXT)'; \ b='aes_wrap'; \ @@ -2656,23 +2582,44 @@ base64test.log: base64test$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) -bftest.log: bftest$(EXEEXT) - @p='bftest$(EXEEXT)'; \ - b='bftest'; \ +bf_test.log: bf_test$(EXEEXT) + @p='bf_test$(EXEEXT)'; \ + b='bf_test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) -biotest.log: biotest$(EXEEXT) - @p='biotest$(EXEEXT)'; \ - b='biotest'; \ +bio_chain.log: bio_chain$(EXEEXT) + @p='bio_chain$(EXEEXT)'; \ + b='bio_chain'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) -bnaddsub.log: bnaddsub$(EXEEXT) - @p='bnaddsub$(EXEEXT)'; \ - b='bnaddsub'; \ +bio_host.log: bio_host$(EXEEXT) + @p='bio_host$(EXEEXT)'; \ + b='bio_host'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +bio_mem.log: bio_mem$(EXEEXT) + @p='bio_mem$(EXEEXT)'; \ + b='bio_mem'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +bn_add_sub.log: bn_add_sub$(EXEEXT) + @p='bn_add_sub$(EXEEXT)'; \ + b='bn_add_sub'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +bn_cmp.log: bn_cmp$(EXEEXT) + @p='bn_cmp$(EXEEXT)'; \ + b='bn_cmp'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ @@ -2684,6 +2631,13 @@ bn_isqrt.log: bn_isqrt$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +bn_mod_exp.log: bn_mod_exp$(EXEEXT) + @p='bn_mod_exp$(EXEEXT)'; \ + b='bn_mod_exp'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) bn_mod_exp2_mont.log: bn_mod_exp2_mont$(EXEEXT) @p='bn_mod_exp2_mont$(EXEEXT)'; \ b='bn_mod_exp2_mont'; \ @@ -2698,6 +2652,13 @@ bn_mod_sqrt.log: bn_mod_sqrt$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +bn_mont.log: bn_mont$(EXEEXT) + @p='bn_mont$(EXEEXT)'; \ + b='bn_mont'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) bn_primes.log: bn_primes$(EXEEXT) @p='bn_primes$(EXEEXT)'; \ b='bn_primes'; \ @@ -2712,9 +2673,16 @@ bn_rand_interval.log: bn_rand_interval$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) -bntest.log: bntest$(EXEEXT) - @p='bntest$(EXEEXT)'; \ - b='bntest'; \ +bn_shift.log: bn_shift$(EXEEXT) + @p='bn_shift$(EXEEXT)'; \ + b='bn_shift'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +bn_test.log: bn_test$(EXEEXT) + @p='bn_test$(EXEEXT)'; \ + b='bn_test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ @@ -2726,6 +2694,20 @@ bn_to_string.log: bn_to_string$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +bn_unit.log: bn_unit$(EXEEXT) + @p='bn_unit$(EXEEXT)'; \ + b='bn_unit'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +bn_word.log: bn_word$(EXEEXT) + @p='bn_word$(EXEEXT)'; \ + b='bn_word'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) buffertest.log: buffertest$(EXEEXT) @p='buffertest$(EXEEXT)'; \ b='buffertest'; \ @@ -2824,13 +2806,6 @@ dsatest.log: dsatest$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) -dtlstest.sh.log: dtlstest.sh - @p='dtlstest.sh'; \ - b='dtlstest.sh'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) ec_asn1_test.log: ec_asn1_test$(EXEEXT) @p='ec_asn1_test$(EXEEXT)'; \ b='ec_asn1_test'; \ @@ -2866,6 +2841,13 @@ ectest.log: ectest$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +ed25519test.log: ed25519test$(EXEEXT) + @p='ed25519test$(EXEEXT)'; \ + b='ed25519test'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) enginetest.log: enginetest$(EXEEXT) @p='enginetest$(EXEEXT)'; \ b='enginetest'; \ @@ -2873,6 +2855,13 @@ enginetest.log: enginetest$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +evp_ecx_test.log: evp_ecx_test$(EXEEXT) + @p='evp_ecx_test$(EXEEXT)'; \ + b='evp_ecx_test'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) evp_pkey_check.log: evp_pkey_check$(EXEEXT) @p='evp_pkey_check$(EXEEXT)'; \ b='evp_pkey_check'; \ @@ -2901,13 +2890,6 @@ explicit_bzero.log: explicit_bzero$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) -exptest.log: exptest$(EXEEXT) - @p='exptest$(EXEEXT)'; \ - b='exptest'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) freenull.log: freenull$(EXEEXT) @p='freenull$(EXEEXT)'; \ b='freenull'; \ @@ -2985,13 +2967,6 @@ md_test.log: md_test$(EXEEXT) --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) -mont.log: mont$(EXEEXT) - @p='mont$(EXEEXT)'; \ - b='mont'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) objectstest.log: objectstest$(EXEEXT) @p='objectstest$(EXEEXT)'; \ b='objectstest'; \ @@ -3358,7 +3333,7 @@ check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am -all-am: Makefile $(HEADERS) +all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: install: install-am install-exec: install-exec-am @@ -3399,10 +3374,11 @@ maintainer-clean-generic: clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ - mostlyclean-am + clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/aeadtest.Po + -rm -f ./$(DEPDIR)/aes_test.Po -rm -f ./$(DEPDIR)/aes_wrap.Po -rm -f ./$(DEPDIR)/arc4randomforktest.Po -rm -f ./$(DEPDIR)/asn1_string_to_utf8.Po @@ -3416,16 +3392,24 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/asn1time.Po -rm -f ./$(DEPDIR)/asn1x509.Po -rm -f ./$(DEPDIR)/base64test.Po - -rm -f ./$(DEPDIR)/bftest.Po - -rm -f ./$(DEPDIR)/biotest.Po + -rm -f ./$(DEPDIR)/bf_test.Po + -rm -f ./$(DEPDIR)/bio_chain.Po + -rm -f ./$(DEPDIR)/bio_host.Po + -rm -f ./$(DEPDIR)/bio_mem.Po + -rm -f ./$(DEPDIR)/bn_add_sub.Po + -rm -f ./$(DEPDIR)/bn_cmp.Po -rm -f ./$(DEPDIR)/bn_isqrt.Po + -rm -f ./$(DEPDIR)/bn_mod_exp-bn_mod_exp.Po -rm -f ./$(DEPDIR)/bn_mod_exp2_mont.Po -rm -f ./$(DEPDIR)/bn_mod_sqrt.Po + -rm -f ./$(DEPDIR)/bn_mont.Po -rm -f ./$(DEPDIR)/bn_primes.Po -rm -f ./$(DEPDIR)/bn_rand_interval.Po + -rm -f ./$(DEPDIR)/bn_shift.Po + -rm -f ./$(DEPDIR)/bn_test-bn_test.Po -rm -f ./$(DEPDIR)/bn_to_string.Po - -rm -f ./$(DEPDIR)/bnaddsub.Po - -rm -f ./$(DEPDIR)/bntest-bntest.Po + -rm -f ./$(DEPDIR)/bn_unit.Po + -rm -f ./$(DEPDIR)/bn_word.Po -rm -f ./$(DEPDIR)/buffertest.Po -rm -f ./$(DEPDIR)/bytestringtest.Po -rm -f ./$(DEPDIR)/casttest.Po @@ -3440,19 +3424,20 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/destest.Po -rm -f ./$(DEPDIR)/dhtest.Po -rm -f ./$(DEPDIR)/dsatest.Po - -rm -f ./$(DEPDIR)/dtlstest.Po -rm -f ./$(DEPDIR)/ec_asn1_test.Po -rm -f ./$(DEPDIR)/ec_point_conversion.Po -rm -f ./$(DEPDIR)/ecdhtest.Po -rm -f ./$(DEPDIR)/ecdsatest.Po -rm -f ./$(DEPDIR)/ectest.Po + -rm -f ./$(DEPDIR)/ed25519test.Po + -rm -f ./$(DEPDIR)/empty.Plo -rm -f ./$(DEPDIR)/enginetest.Po + -rm -f ./$(DEPDIR)/evp_ecx_test.Po -rm -f ./$(DEPDIR)/evp_pkey_check.Po -rm -f ./$(DEPDIR)/evp_pkey_cleanup.Po -rm -f ./$(DEPDIR)/evptest.Po -rm -f ./$(DEPDIR)/explicit_bzero.Po - -rm -f ./$(DEPDIR)/exptest-exptest.Po - -rm -f ./$(DEPDIR)/freenull.Po + -rm -f ./$(DEPDIR)/freenull-freenull.Po -rm -f ./$(DEPDIR)/gcm128test.Po -rm -f ./$(DEPDIR)/gost2814789t.Po -rm -f ./$(DEPDIR)/handshake_table.Po @@ -3463,7 +3448,6 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/key_schedule.Po -rm -f ./$(DEPDIR)/keypairtest-keypairtest.Po -rm -f ./$(DEPDIR)/md_test.Po - -rm -f ./$(DEPDIR)/mont.Po -rm -f ./$(DEPDIR)/objectstest.Po -rm -f ./$(DEPDIR)/ocsp_test.Po -rm -f ./$(DEPDIR)/optionstest.Po @@ -3554,6 +3538,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/aeadtest.Po + -rm -f ./$(DEPDIR)/aes_test.Po -rm -f ./$(DEPDIR)/aes_wrap.Po -rm -f ./$(DEPDIR)/arc4randomforktest.Po -rm -f ./$(DEPDIR)/asn1_string_to_utf8.Po @@ -3567,16 +3552,24 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/asn1time.Po -rm -f ./$(DEPDIR)/asn1x509.Po -rm -f ./$(DEPDIR)/base64test.Po - -rm -f ./$(DEPDIR)/bftest.Po - -rm -f ./$(DEPDIR)/biotest.Po + -rm -f ./$(DEPDIR)/bf_test.Po + -rm -f ./$(DEPDIR)/bio_chain.Po + -rm -f ./$(DEPDIR)/bio_host.Po + -rm -f ./$(DEPDIR)/bio_mem.Po + -rm -f ./$(DEPDIR)/bn_add_sub.Po + -rm -f ./$(DEPDIR)/bn_cmp.Po -rm -f ./$(DEPDIR)/bn_isqrt.Po + -rm -f ./$(DEPDIR)/bn_mod_exp-bn_mod_exp.Po -rm -f ./$(DEPDIR)/bn_mod_exp2_mont.Po -rm -f ./$(DEPDIR)/bn_mod_sqrt.Po + -rm -f ./$(DEPDIR)/bn_mont.Po -rm -f ./$(DEPDIR)/bn_primes.Po -rm -f ./$(DEPDIR)/bn_rand_interval.Po + -rm -f ./$(DEPDIR)/bn_shift.Po + -rm -f ./$(DEPDIR)/bn_test-bn_test.Po -rm -f ./$(DEPDIR)/bn_to_string.Po - -rm -f ./$(DEPDIR)/bnaddsub.Po - -rm -f ./$(DEPDIR)/bntest-bntest.Po + -rm -f ./$(DEPDIR)/bn_unit.Po + -rm -f ./$(DEPDIR)/bn_word.Po -rm -f ./$(DEPDIR)/buffertest.Po -rm -f ./$(DEPDIR)/bytestringtest.Po -rm -f ./$(DEPDIR)/casttest.Po @@ -3591,19 +3584,20 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/destest.Po -rm -f ./$(DEPDIR)/dhtest.Po -rm -f ./$(DEPDIR)/dsatest.Po - -rm -f ./$(DEPDIR)/dtlstest.Po -rm -f ./$(DEPDIR)/ec_asn1_test.Po -rm -f ./$(DEPDIR)/ec_point_conversion.Po -rm -f ./$(DEPDIR)/ecdhtest.Po -rm -f ./$(DEPDIR)/ecdsatest.Po -rm -f ./$(DEPDIR)/ectest.Po + -rm -f ./$(DEPDIR)/ed25519test.Po + -rm -f ./$(DEPDIR)/empty.Plo -rm -f ./$(DEPDIR)/enginetest.Po + -rm -f ./$(DEPDIR)/evp_ecx_test.Po -rm -f ./$(DEPDIR)/evp_pkey_check.Po -rm -f ./$(DEPDIR)/evp_pkey_cleanup.Po -rm -f ./$(DEPDIR)/evptest.Po -rm -f ./$(DEPDIR)/explicit_bzero.Po - -rm -f ./$(DEPDIR)/exptest-exptest.Po - -rm -f ./$(DEPDIR)/freenull.Po + -rm -f ./$(DEPDIR)/freenull-freenull.Po -rm -f ./$(DEPDIR)/gcm128test.Po -rm -f ./$(DEPDIR)/gost2814789t.Po -rm -f ./$(DEPDIR)/handshake_table.Po @@ -3614,7 +3608,6 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/key_schedule.Po -rm -f ./$(DEPDIR)/keypairtest-keypairtest.Po -rm -f ./$(DEPDIR)/md_test.Po - -rm -f ./$(DEPDIR)/mont.Po -rm -f ./$(DEPDIR)/objectstest.Po -rm -f ./$(DEPDIR)/ocsp_test.Po -rm -f ./$(DEPDIR)/optionstest.Po @@ -3681,21 +3674,26 @@ uninstall-am: .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \ check-am clean clean-checkPROGRAMS clean-generic clean-libtool \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am + clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am recheck tags tags-am uninstall \ + uninstall-am .PRECIOUS: Makefile +-include $(abs_top_builddir)/crypto/libcrypto_la_objects.mk +-include $(abs_top_builddir)/ssl/libssl_la_objects.mk +-include $(abs_top_builddir)/tls/libtls_la_objects.mk + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/tests/aes_test.c b/tests/aes_test.c new file mode 100644 index 00000000..2bbf6b2e --- /dev/null +++ b/tests/aes_test.c @@ -0,0 +1,979 @@ +/* $OpenBSD: aes_test.c,v 1.2 2022/11/07 23:09:25 joshua Exp $ */ +/* + * Copyright (c) 2022 Joshua Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include +#include + +struct aes_test { + const int mode; + const uint8_t key[64]; + const uint8_t iv[64]; + const int iv_len; + const uint8_t in[64]; + const int in_len; + const uint8_t out[64]; + const int out_len; + const int padding; +}; + +static const struct aes_test aes_tests[] = { + /* ECB - Test vectors from FIPS-197, Appendix C. */ + { + .mode = NID_aes_128_ecb, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .in = { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, + }, + .in_len = 16, + .out = { + 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, + 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a, + }, + .out_len = 16, + }, + { + .mode = NID_aes_192_ecb, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + }, + .in = { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, + }, + .in_len = 16, + .out = { + 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0, + 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91, + }, + .out_len = 16, + }, + { + .mode = NID_aes_256_ecb, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + .in = { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, + }, + .in_len = 16, + .out = { + 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, + 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89, + }, + .out_len = 16, + }, + + /* CBC - Test vectors from RFC 3602 */ + { + .mode = NID_aes_128_cbc, + .key = { + 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b, + 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06, + }, + .iv = { + 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30, + 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41, + }, + .iv_len = 16, + .in = { + 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x20, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x6d, 0x73, 0x67, + }, + .in_len = 16, + .out = { + 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8, + 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a, + }, + .out_len = 16, + }, + { + .mode = NID_aes_128_cbc, + .key = { + 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0, + 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a, + }, + .iv = { + 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28, + 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58, + }, + .iv_len = 16, + .in = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + .in_len = 32, + .out = { + 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a, + 0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a, + 0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9, + 0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1, + }, + .out_len = 32, + }, + { + .mode = NID_aes_128_cbc, + .key = { + 0x6c, 0x3e, 0xa0, 0x47, 0x76, 0x30, 0xce, 0x21, + 0xa2, 0xce, 0x33, 0x4a, 0xa7, 0x46, 0xc2, 0xcd, + }, + .iv = { + 0xc7, 0x82, 0xdc, 0x4c, 0x09, 0x8c, 0x66, 0xcb, + 0xd9, 0xcd, 0x27, 0xd8, 0x25, 0x68, 0x2c, 0x81, + }, + .iv_len = 16, + .in = { + 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, + 0x61, 0x20, 0x34, 0x38, 0x2d, 0x62, 0x79, 0x74, + 0x65, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x20, 0x28, 0x65, 0x78, 0x61, 0x63, 0x74, + 0x6c, 0x79, 0x20, 0x33, 0x20, 0x41, 0x45, 0x53, + 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x29, + }, + .in_len = 48, + .out = { + 0xd0, 0xa0, 0x2b, 0x38, 0x36, 0x45, 0x17, 0x53, + 0xd4, 0x93, 0x66, 0x5d, 0x33, 0xf0, 0xe8, 0x86, + 0x2d, 0xea, 0x54, 0xcd, 0xb2, 0x93, 0xab, 0xc7, + 0x50, 0x69, 0x39, 0x27, 0x67, 0x72, 0xf8, 0xd5, + 0x02, 0x1c, 0x19, 0x21, 0x6b, 0xad, 0x52, 0x5c, + 0x85, 0x79, 0x69, 0x5d, 0x83, 0xba, 0x26, 0x84, + }, + .out_len = 48, + }, + { + .mode = NID_aes_128_cbc, + .key = { + 0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74, + 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49, + }, + .iv = { + 0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c, + 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9, + }, + .iv_len = 16, + .in = { + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + }, + .in_len = 64, + .out = { + 0xc3, 0x0e, 0x32, 0xff, 0xed, 0xc0, 0x77, 0x4e, + 0x6a, 0xff, 0x6a, 0xf0, 0x86, 0x9f, 0x71, 0xaa, + 0x0f, 0x3a, 0xf0, 0x7a, 0x9a, 0x31, 0xa9, 0xc6, + 0x84, 0xdb, 0x20, 0x7e, 0xb0, 0xef, 0x8e, 0x4e, + 0x35, 0x90, 0x7a, 0xa6, 0x32, 0xc3, 0xff, 0xdf, + 0x86, 0x8b, 0xb7, 0xb2, 0x9d, 0x3d, 0x46, 0xad, + 0x83, 0xce, 0x9f, 0x9a, 0x10, 0x2e, 0xe9, 0x9d, + 0x49, 0xa5, 0x3e, 0x87, 0xf4, 0xc3, 0xda, 0x55, + }, + .out_len = 64, + }, + + /* CBC - Test vectors from NIST SP 800-38A */ + { + .mode = NID_aes_128_cbc, + .key = { + 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, + }, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .iv_len = 16, + .in = { + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, + }, + .in_len = 64, + .out = { + 0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46, + 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d, + 0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee, + 0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2, + 0x73, 0xbe, 0xd6, 0xb8, 0xe3, 0xc1, 0x74, 0x3b, + 0x71, 0x16, 0xe6, 0x9e, 0x22, 0x22, 0x95, 0x16, + 0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09, + 0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7, + }, + .out_len = 64, + }, + { + .mode = NID_aes_192_cbc, + .key = { + 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, + 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, + 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b, + }, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .iv_len = 16, + .in = { + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, + }, + .in_len = 64, + .out = { + 0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d, + 0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8, + 0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4, + 0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a, + 0x57, 0x1b, 0x24, 0x20, 0x12, 0xfb, 0x7a, 0xe0, + 0x7f, 0xa9, 0xba, 0xac, 0x3d, 0xf1, 0x02, 0xe0, + 0x08, 0xb0, 0xe2, 0x79, 0x88, 0x59, 0x88, 0x81, + 0xd9, 0x20, 0xa9, 0xe6, 0x4f, 0x56, 0x15, 0xcd, + }, + .out_len = 64, + }, + { + .mode = NID_aes_256_cbc, + .key = { + 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, + 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, + 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, + 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4, + }, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .iv_len = 16, + .in = { + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, + }, + .in_len = 64, + .out = { + 0xf5, 0x8c, 0x4c, 0x04, 0xd6, 0xe5, 0xf1, 0xba, + 0x77, 0x9e, 0xab, 0xfb, 0x5f, 0x7b, 0xfb, 0xd6, + 0x9c, 0xfc, 0x4e, 0x96, 0x7e, 0xdb, 0x80, 0x8d, + 0x67, 0x9f, 0x77, 0x7b, 0xc6, 0x70, 0x2c, 0x7d, + 0x39, 0xf2, 0x33, 0x69, 0xa9, 0xd9, 0xba, 0xcf, + 0xa5, 0x30, 0xe2, 0x63, 0x04, 0x23, 0x14, 0x61, + 0xb2, 0xeb, 0x05, 0xe2, 0xc3, 0x9b, 0xe9, 0xfc, + 0xda, 0x6c, 0x19, 0x07, 0x8c, 0x6a, 0x9d, 0x1b, + }, + .out_len = 64, + }, + + /* CFB128 - Test vectors from NIST SP 800-38A */ + { + .mode = NID_aes_128_cfb128, + .key = { + 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, + }, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .iv_len = 16, + .in = { + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, + }, + .in_len = 64, + .out = { + 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20, + 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a, + 0xc8, 0xa6, 0x45, 0x37, 0xa0, 0xb3, 0xa9, 0x3f, + 0xcd, 0xe3, 0xcd, 0xad, 0x9f, 0x1c, 0xe5, 0x8b, + 0x26, 0x75, 0x1f, 0x67, 0xa3, 0xcb, 0xb1, 0x40, + 0xb1, 0x80, 0x8c, 0xf1, 0x87, 0xa4, 0xf4, 0xdf, + 0xc0, 0x4b, 0x05, 0x35, 0x7c, 0x5d, 0x1c, 0x0e, + 0xea, 0xc4, 0xc6, 0x6f, 0x9f, 0xf7, 0xf2, 0xe6, + }, + .out_len = 64, + }, + { + .mode = NID_aes_192_cfb128, + .key = { + 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, + 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, + 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b, + }, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .iv_len = 16, + .in = { + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, + }, + .in_len = 64, + .out = { + 0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab, + 0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74, + 0x67, 0xce, 0x7f, 0x7f, 0x81, 0x17, 0x36, 0x21, + 0x96, 0x1a, 0x2b, 0x70, 0x17, 0x1d, 0x3d, 0x7a, + 0x2e, 0x1e, 0x8a, 0x1d, 0xd5, 0x9b, 0x88, 0xb1, + 0xc8, 0xe6, 0x0f, 0xed, 0x1e, 0xfa, 0xc4, 0xc9, + 0xc0, 0x5f, 0x9f, 0x9c, 0xa9, 0x83, 0x4f, 0xa0, + 0x42, 0xae, 0x8f, 0xba, 0x58, 0x4b, 0x09, 0xff, + }, + .out_len = 64, + }, + { + .mode = NID_aes_256_cfb128, + .key = { + 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, + 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, + 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, + 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4, + }, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .iv_len = 16, + .in = { + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, + }, + .in_len = 64, + .out = { + 0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b, + 0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60, + 0x39, 0xff, 0xed, 0x14, 0x3b, 0x28, 0xb1, 0xc8, + 0x32, 0x11, 0x3c, 0x63, 0x31, 0xe5, 0x40, 0x7b, + 0xdf, 0x10, 0x13, 0x24, 0x15, 0xe5, 0x4b, 0x92, + 0xa1, 0x3e, 0xd0, 0xa8, 0x26, 0x7a, 0xe2, 0xf9, + 0x75, 0xa3, 0x85, 0x74, 0x1a, 0xb9, 0xce, 0xf8, + 0x20, 0x31, 0x62, 0x3d, 0x55, 0xb1, 0xe4, 0x71, + }, + .out_len = 64, + }, + + /* OFB128 - Test vectors from NIST SP 800-38A */ + { + .mode = NID_aes_128_ofb128, + .key = { + 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, + 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, + }, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .iv_len = 16, + .in = { + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, + }, + .in_len = 64, + .out = { + 0x3b, 0x3f, 0xd9, 0x2e, 0xb7, 0x2d, 0xad, 0x20, + 0x33, 0x34, 0x49, 0xf8, 0xe8, 0x3c, 0xfb, 0x4a, + 0x77, 0x89, 0x50, 0x8d, 0x16, 0x91, 0x8f, 0x03, + 0xf5, 0x3c, 0x52, 0xda, 0xc5, 0x4e, 0xd8, 0x25, + 0x97, 0x40, 0x05, 0x1e, 0x9c, 0x5f, 0xec, 0xf6, + 0x43, 0x44, 0xf7, 0xa8, 0x22, 0x60, 0xed, 0xcc, + 0x30, 0x4c, 0x65, 0x28, 0xf6, 0x59, 0xc7, 0x78, + 0x66, 0xa5, 0x10, 0xd9, 0xc1, 0xd6, 0xae, 0x5e, + }, + .out_len = 64, + }, + { + .mode = NID_aes_192_ofb128, + .key = { + 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, + 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, + 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b, + }, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .iv_len = 16, + .in = { + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, + }, + .in_len = 64, + .out = { + 0xcd, 0xc8, 0x0d, 0x6f, 0xdd, 0xf1, 0x8c, 0xab, + 0x34, 0xc2, 0x59, 0x09, 0xc9, 0x9a, 0x41, 0x74, + 0xfc, 0xc2, 0x8b, 0x8d, 0x4c, 0x63, 0x83, 0x7c, + 0x09, 0xe8, 0x17, 0x00, 0xc1, 0x10, 0x04, 0x01, + 0x8d, 0x9a, 0x9a, 0xea, 0xc0, 0xf6, 0x59, 0x6f, + 0x55, 0x9c, 0x6d, 0x4d, 0xaf, 0x59, 0xa5, 0xf2, + 0x6d, 0x9f, 0x20, 0x08, 0x57, 0xca, 0x6c, 0x3e, + 0x9c, 0xac, 0x52, 0x4b, 0xd9, 0xac, 0xc9, 0x2a, + }, + .out_len = 64, + }, + { + .mode = NID_aes_256_ofb128, + .key = { + 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, + 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81, + 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, + 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4, + }, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .iv_len = 16, + .in = { + 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, + 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, + 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, + 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51, + 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, + 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, + 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, + 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10, + }, + .in_len = 64, + .out = { + 0xdc, 0x7e, 0x84, 0xbf, 0xda, 0x79, 0x16, 0x4b, + 0x7e, 0xcd, 0x84, 0x86, 0x98, 0x5d, 0x38, 0x60, + 0x4f, 0xeb, 0xdc, 0x67, 0x40, 0xd2, 0x0b, 0x3a, + 0xc8, 0x8f, 0x6a, 0xd8, 0x2a, 0x4f, 0xb0, 0x8d, + 0x71, 0xab, 0x47, 0xa0, 0x86, 0xe8, 0x6e, 0xed, + 0xf3, 0x9d, 0x1c, 0x5b, 0xba, 0x97, 0xc4, 0x08, + 0x01, 0x26, 0x14, 0x1d, 0x67, 0xf3, 0x7b, 0xe8, + 0x53, 0x8f, 0x5a, 0x8b, 0xe7, 0x40, 0xe4, 0x84, + }, + .out_len = 64, + }, +}; + +#define N_AES_TESTS (sizeof(aes_tests) / sizeof(aes_tests[0])) + +static int +aes_ecb_test(size_t test_number, const char *label, int key_bits, + const struct aes_test *at) +{ + AES_KEY key; + uint8_t out[64]; + + if (at->padding) { + /* XXX - Handle padding */ + return 1; + } + + /* Encryption */ + memset(out, 0, sizeof(out)); + AES_set_encrypt_key(at->key, key_bits, &key); + AES_ecb_encrypt(at->in, out, &key, 1); + + if (memcmp(at->out, out, at->out_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): encryption mismatch\n", + label, test_number); + return 0; + } + + /* Decryption */ + memset(out, 0, sizeof(out)); + AES_set_decrypt_key(at->key, key_bits, &key); + AES_ecb_encrypt(at->out, out, &key, 0); + + if (memcmp(at->in, out, at->in_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): decryption mismatch\n", + label, test_number); + return 0; + } + + return 1; +} + + +static int +aes_cbc_test(size_t test_number, const char *label, int key_bits, + const struct aes_test *at) +{ + AES_KEY key; + uint8_t out[64]; + uint8_t iv[16]; + + if (at->padding) { + /* XXX - Handle padding */ + return 1; + } + + /* Encryption */ + memset(out, 0, sizeof(out)); + memcpy(iv, at->iv, at->iv_len); + AES_set_encrypt_key(at->key, key_bits, &key); + AES_cbc_encrypt(at->in, out, at->in_len, &key, iv, 1); + + if (memcmp(at->out, out, at->out_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): encryption mismatch\n", + label, test_number); + return 0; + } + + /* Decryption */ + memset(out, 0, sizeof(out)); + memcpy(iv, at->iv, at->iv_len); + AES_set_decrypt_key(at->key, key_bits, &key); + AES_cbc_encrypt(at->out, out, at->out_len, &key, iv, 0); + + if (memcmp(at->in, out, at->in_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): decryption mismatch\n", + label, test_number); + return 0; + } + + return 1; +} + +static int +aes_evp_test(size_t test_number, const struct aes_test *at, const char *label, + int key_bits, const EVP_CIPHER *cipher) +{ + EVP_CIPHER_CTX *ctx; + uint8_t out[64]; + int in_len, out_len, total_len; + int i; + int success = 0; + + if ((ctx = EVP_CIPHER_CTX_new()) == NULL) { + fprintf(stderr, "FAIL (%s:%zu): EVP_CIPHER_CTX_new failed\n", + label, test_number); + goto failed; + } + + /* EVP encryption */ + total_len = 0; + memset(out, 0, sizeof(out)); + if (!EVP_EncryptInit(ctx, cipher, NULL, NULL)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_EncryptInit failed\n", + label, test_number); + goto failed; + } + + if (!EVP_CIPHER_CTX_set_padding(ctx, at->padding)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_CIPHER_CTX_set_padding failed\n", + label, test_number); + goto failed; + } + + if (!EVP_EncryptInit(ctx, NULL, at->key, at->iv)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_EncryptInit failed\n", + label, test_number); + goto failed; + } + + for (i = 0; i < at->in_len;) { + in_len = arc4random_uniform(at->in_len / 2); + if (in_len > at->in_len - i) + in_len = at->in_len - i; + + if (!EVP_EncryptUpdate(ctx, out + total_len, &out_len, + at->in + i, in_len)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_EncryptUpdate failed\n", + label, test_number); + goto failed; + } + + i += in_len; + total_len += out_len; + } + + if (!EVP_EncryptFinal_ex(ctx, out + total_len, &out_len)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_EncryptFinal_ex failed\n", + label, test_number); + goto failed; + } + total_len += out_len; + + if (!EVP_CIPHER_CTX_reset(ctx)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_CIPHER_CTX_reset failed\n", + label, test_number); + goto failed; + } + + if (total_len != at->out_len) { + fprintf(stderr, + "FAIL (%s:%zu): EVP encryption length mismatch " + "(%d != %d)\n", label, test_number, total_len, at->out_len); + goto failed; + } + + if (memcmp(at->out, out, at->out_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): EVP encryption mismatch\n", + label, test_number); + goto failed; + } + + /* EVP decryption */ + total_len = 0; + memset(out, 0, sizeof(out)); + if (!EVP_DecryptInit(ctx, cipher, NULL, NULL)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_DecryptInit failed\n", + label, test_number); + goto failed; + } + + if (!EVP_CIPHER_CTX_set_padding(ctx, at->padding)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_CIPHER_CTX_set_padding failed\n", + label, test_number); + goto failed; + } + + if (!EVP_DecryptInit(ctx, NULL, at->key, at->iv)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_DecryptInit failed\n", + label, test_number); + goto failed; + } + + for (i = 0; i < at->out_len;) { + in_len = arc4random_uniform(at->out_len / 2); + if (in_len > at->out_len - i) + in_len = at->out_len - i; + + if (!EVP_DecryptUpdate(ctx, out + total_len, &out_len, + at->out + i, in_len)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_DecryptUpdate failed\n", + label, test_number); + goto failed; + } + + i += in_len; + total_len += out_len; + } + + if (!EVP_DecryptFinal_ex(ctx, out + total_len, &out_len)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_DecryptFinal_ex failed\n", + label, test_number); + goto failed; + } + total_len += out_len; + + if (!EVP_CIPHER_CTX_reset(ctx)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_CIPHER_CTX_reset failed\n", + label, test_number); + goto failed; + } + + if (total_len != at->in_len) { + fprintf(stderr, + "FAIL (%s:%zu): EVP decryption length mismatch\n", + label, test_number); + goto failed; + } + + if (memcmp(at->in, out, at->in_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): EVP decryption mismatch\n", + label, test_number); + goto failed; + } + + success = 1; + + failed: + EVP_CIPHER_CTX_free(ctx); + return success; +} + + +static int +aes_key_bits_from_nid(int nid) +{ + switch (nid) { + case NID_aes_128_ecb: + case NID_aes_128_cbc: + case NID_aes_128_cfb128: + case NID_aes_128_ofb128: + case NID_aes_128_gcm: + case NID_aes_128_ccm: + return 128; + case NID_aes_192_ecb: + case NID_aes_192_cbc: + case NID_aes_192_cfb128: + case NID_aes_192_ofb128: + case NID_aes_192_gcm: + case NID_aes_192_ccm: + return 192; + case NID_aes_256_ecb: + case NID_aes_256_cbc: + case NID_aes_256_cfb128: + case NID_aes_256_ofb128: + case NID_aes_256_gcm: + case NID_aes_256_ccm: + return 256; + default: + return -1; + } +} + +static int +aes_cipher_from_nid(int nid, const char **out_label, + const EVP_CIPHER **out_cipher) +{ + switch (nid) { + /* ECB */ + case NID_aes_128_ecb: + *out_label = SN_aes_128_ecb; + *out_cipher = EVP_aes_128_ecb(); + break; + case NID_aes_192_ecb: + *out_label = SN_aes_192_ecb; + *out_cipher = EVP_aes_192_ecb(); + break; + case NID_aes_256_ecb: + *out_label = SN_aes_256_ecb; + *out_cipher = EVP_aes_256_ecb(); + break; + + /* CBC */ + case NID_aes_128_cbc: + *out_label = SN_aes_128_cbc; + *out_cipher = EVP_aes_128_cbc(); + break; + case NID_aes_192_cbc: + *out_label = SN_aes_192_cbc; + *out_cipher = EVP_aes_192_cbc(); + break; + case NID_aes_256_cbc: + *out_label = SN_aes_256_cbc; + *out_cipher = EVP_aes_256_cbc(); + break; + + /* CFB128 */ + case NID_aes_128_cfb128: + *out_label = SN_aes_128_cfb128; + *out_cipher = EVP_aes_128_cfb128(); + break; + case NID_aes_192_cfb128: + *out_label = SN_aes_192_cfb128; + *out_cipher = EVP_aes_192_cfb128(); + break; + case NID_aes_256_cfb128: + *out_label = SN_aes_256_cfb128; + *out_cipher = EVP_aes_256_cfb128(); + break; + + /* OFB128 */ + case NID_aes_128_ofb128: + *out_label = SN_aes_128_ofb128; + *out_cipher = EVP_aes_128_ofb(); + break; + case NID_aes_192_ofb128: + *out_label = SN_aes_192_ofb128; + *out_cipher = EVP_aes_192_ofb(); + break; + case NID_aes_256_ofb128: + *out_label = SN_aes_256_ofb128; + *out_cipher = EVP_aes_256_ofb(); + break; + + /* GCM */ + case NID_aes_128_gcm: + *out_label = SN_aes_128_gcm; + *out_cipher = EVP_aes_128_gcm(); + break; + case NID_aes_192_gcm: + *out_label = SN_aes_192_gcm; + *out_cipher = EVP_aes_192_gcm(); + break; + case NID_aes_256_gcm: + *out_label = SN_aes_256_gcm; + *out_cipher = EVP_aes_256_gcm(); + break; + + /* CCM */ + case NID_aes_128_ccm: + *out_label = SN_aes_128_ccm; + *out_cipher = EVP_aes_128_ccm(); + break; + case NID_aes_192_ccm: + *out_label = SN_aes_192_ccm; + *out_cipher = EVP_aes_192_ccm(); + break; + case NID_aes_256_ccm: + *out_label = SN_aes_256_ccm; + *out_cipher = EVP_aes_256_ccm(); + break; + + /* Unknown */ + default: + return 0; + } + + return 1; +} + +static int +aes_test(void) +{ + const struct aes_test *at; + const char *label; + const EVP_CIPHER *cipher; + int key_bits; + size_t i; + int failed = 1; + + for (i = 0; i < N_AES_TESTS; i++) { + at = &aes_tests[i]; + key_bits = aes_key_bits_from_nid(at->mode); + if (!aes_cipher_from_nid(at->mode, &label, &cipher)) + goto failed; + + switch (at->mode) { + /* ECB */ + case NID_aes_128_ecb: + case NID_aes_192_ecb: + case NID_aes_256_ecb: + if (!aes_ecb_test(i, label, key_bits, at)) + goto failed; + break; + + /* CBC */ + case NID_aes_128_cbc: + case NID_aes_192_cbc: + case NID_aes_256_cbc: + if (!aes_cbc_test(i, label, key_bits, at)) + goto failed; + break; + + /* CFB128 */ + case NID_aes_128_cfb128: + case NID_aes_192_cfb128: + case NID_aes_256_cfb128: + /* XXX - CFB128 non-EVP tests */ + break; + + /* OFB128 */ + case NID_aes_128_ofb128: + case NID_aes_192_ofb128: + case NID_aes_256_ofb128: + /* XXX - OFB128 non-EVP tests */ + break; + + /* GCM */ + case NID_aes_128_gcm: + case NID_aes_192_gcm: + case NID_aes_256_gcm: + /* GCM is EVP-only */ + break; + + /* CCM */ + case NID_aes_128_ccm: + case NID_aes_192_ccm: + case NID_aes_256_ccm: + /* XXX - CCM non-EVP tests */ + break; + + /* Unknown */ + default: + fprintf(stderr, "FAIL: unknown mode (%d)\n", + at->mode); + goto failed; + } + + if (!aes_evp_test(i, at, label, key_bits, cipher)) + goto failed; + } + + failed = 0; + + failed: + return failed; +} + +int +main(int argc, char **argv) +{ + int failed = 0; + + failed |= aes_test(); + + return failed; +} + diff --git a/tests/asn1_string_to_utf8.c b/tests/asn1_string_to_utf8.c index 2ead7b46..a87969d9 100644 --- a/tests/asn1_string_to_utf8.c +++ b/tests/asn1_string_to_utf8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_string_to_utf8.c,v 1.1 2022/05/16 20:53:20 tb Exp $ */ +/* $OpenBSD: asn1_string_to_utf8.c,v 1.2 2022/11/23 08:51:05 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * @@ -86,12 +86,18 @@ asn1_string_to_utf8_test(const struct asn1_string_to_utf8_test_case *test) goto err; } - if ((ret = ASN1_STRING_to_UTF8(&out, str)) != test->want_len) { + if ((ret = ASN1_STRING_to_UTF8(&out, str)) < 0) { warnx("ASN1_STRING_to_UTF8 failed: got %d, want %d", ret, test->want_len); goto err; } + if (ret != test->want_len) { + warnx("ASN1_STRING_to_UTF8: got %d, want %d", ret, + test->want_len); + goto err; + } + if (memcmp(out, test->want, test->want_len) != 0) { warnx("memcmp failed"); goto err; diff --git a/tests/asn1basic.c b/tests/asn1basic.c index 45f61ed8..1703ba96 100644 --- a/tests/asn1basic.c +++ b/tests/asn1basic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1basic.c,v 1.12 2022/09/05 21:06:31 tb Exp $ */ +/* $OpenBSD: asn1basic.c,v 1.13 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2017, 2021 Joel Sing * @@ -22,7 +22,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" static void hexdump(const unsigned char *buf, size_t len) diff --git a/tests/asn1object.c b/tests/asn1object.c index 3452a713..539c6aa9 100644 --- a/tests/asn1object.c +++ b/tests/asn1object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1object.c,v 1.9 2022/09/05 21:06:31 tb Exp $ */ +/* $OpenBSD: asn1object.c,v 1.10 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2017, 2021, 2022 Joel Sing * @@ -22,7 +22,7 @@ #include #include -#include "asn1_locl.h" +#include "asn1_local.h" static void hexdump(const unsigned char *buf, size_t len) diff --git a/tests/asn1test.c b/tests/asn1test.c index 4cb905a8..6e9362b3 100644 --- a/tests/asn1test.c +++ b/tests/asn1test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1test.c,v 1.11 2022/06/07 18:00:51 tb Exp $ */ +/* $OpenBSD: asn1test.c,v 1.12 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2014, 2016 Joel Sing * @@ -23,7 +23,7 @@ #include #include -#include "ssl_locl.h" +#include "ssl_local.h" int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp); SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, diff --git a/tests/asn1x509.c b/tests/asn1x509.c index bb9e2ecd..4d689aa7 100644 --- a/tests/asn1x509.c +++ b/tests/asn1x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1x509.c,v 1.3 2022/04/27 17:43:41 jsing Exp $ */ +/* $OpenBSD: asn1x509.c,v 1.4 2023/02/13 09:50:47 tb Exp $ */ /* * Copyright (c) 2017 Joel Sing * @@ -28,14 +28,14 @@ #include #include -const char *dsa_test_key = \ - "-----BEGIN DSA PRIVATE KEY-----\n" \ - "MIH5AgEAAkEAt+CNNryEe8t2SkjuP0azjOKjSMXsw3GzjLS5c+vFLQKs0zIuPp8F\n" \ - "I/z5t8vcNt/D8EyzQZWxgCfoasHqDOJvRwIVAKrJMyIMt9iJtaS31cyIJmIDVlZX\n" \ - "AkEAs1/Uy+x0+1C1n7V3eJxuBdO/LUalbrZM5PfcwDshf9kcQNLsRu5zTZkU0OX/\n" \ - "8xANz+ue2o6LON2sTAtuEfSM1QJBAIDRt0rQGGrFCRJ4O39Iqlf27yIO6Gq1ppbE\n" \ - "Wvsvz4YSIZsG02vlBlzVIhULftNnkpN59MFtIjx8RsbEQ4YTnSICFDXPf/UIRvdH\n" \ - "20NV++tnUZYUAXM+\n" \ +const char *dsa_test_key = + "-----BEGIN DSA PRIVATE KEY-----\n" + "MIH5AgEAAkEAt+CNNryEe8t2SkjuP0azjOKjSMXsw3GzjLS5c+vFLQKs0zIuPp8F\n" + "I/z5t8vcNt/D8EyzQZWxgCfoasHqDOJvRwIVAKrJMyIMt9iJtaS31cyIJmIDVlZX\n" + "AkEAs1/Uy+x0+1C1n7V3eJxuBdO/LUalbrZM5PfcwDshf9kcQNLsRu5zTZkU0OX/\n" + "8xANz+ue2o6LON2sTAtuEfSM1QJBAIDRt0rQGGrFCRJ4O39Iqlf27yIO6Gq1ppbE\n" + "Wvsvz4YSIZsG02vlBlzVIhULftNnkpN59MFtIjx8RsbEQ4YTnSICFDXPf/UIRvdH\n" + "20NV++tnUZYUAXM+\n" "-----END DSA PRIVATE KEY-----\n"; unsigned char dsa_test_asn1_pubkey[] = { @@ -72,11 +72,11 @@ unsigned char dsa_test_asn1_pubkey[] = { 0x43, 0x86, 0x13, 0x9d, 0x22, }; -const char *ec_test_key = \ - "-----BEGIN EC PRIVATE KEY-----\n" \ - "MHcCAQEEIEDkF84aPdBNu4vbPE+QV3EP9ULp4Enr1N0lz4vzuc2boAoGCCqGSM49\n" \ - "AwEHoUQDQgAEUQGHBjYwbfHvI3QqdDy8ftNU5UvQqh6TH6upIrtz4CVccxnWO2+s\n" \ - "qSMOu1z5KnGIOVf2kLQ2S2iMahyFMezr8g==\n" \ +const char *ec_test_key = + "-----BEGIN EC PRIVATE KEY-----\n" + "MHcCAQEEIEDkF84aPdBNu4vbPE+QV3EP9ULp4Enr1N0lz4vzuc2boAoGCCqGSM49\n" + "AwEHoUQDQgAEUQGHBjYwbfHvI3QqdDy8ftNU5UvQqh6TH6upIrtz4CVccxnWO2+s\n" + "qSMOu1z5KnGIOVf2kLQ2S2iMahyFMezr8g==\n" "-----END EC PRIVATE KEY-----\n"; unsigned char ec_test_asn1_pubkey[] = { @@ -94,16 +94,16 @@ unsigned char ec_test_asn1_pubkey[] = { 0xec, 0xeb, 0xf2, }; -const char *rsa_test_key = \ - "-----BEGIN PRIVATE KEY-----\n" \ - "MIIBVgIBADANBgkqhkiG9w0BAQEFAASCAUAwggE8AgEAAkEA4Fs6ljFFQw/ElDf5\n" \ - "LTghVw972PVpQuKPQvwb1cWbV3+7W5sXOcoM/RvwzO7WeppkeltVCBoKaQd+9e2Z\n" \ - "BHtYhwIDAQABAkEAhWv7dWIrrGvuHa8D0i51NU8R+b5IMOyHAfDnpMN1VByWcBdb\n" \ - "G7ZJsEYlO1Tbx1zFQOVyrDUY2hn0YttPjWys0QIhAP9+FRhHCYye/EY14zSa+lxb\n" \ - "ljOPjWgddMdJBcPOVNUNAiEA4M1QUtIcTnTnfvcxvEBIhbmSR8fRvZYAeT5EoTKM\n" \ - "puMCIQD9898X8JRHWEg9qZabVWiBoO+ddJUD5jOLWsQGKvMbiQIgBOQyxTqRJxvg\n" \ - "FaEnUeNMMKyzBCDS7X8gD4NNVvyUluUCIQC/lnO9xYi6S4BFMwHFEUY0jLr5vgsR\n" \ - "+esRU9dLkMqt+w==\n" \ +const char *rsa_test_key = + "-----BEGIN PRIVATE KEY-----\n" + "MIIBVgIBADANBgkqhkiG9w0BAQEFAASCAUAwggE8AgEAAkEA4Fs6ljFFQw/ElDf5\n" + "LTghVw972PVpQuKPQvwb1cWbV3+7W5sXOcoM/RvwzO7WeppkeltVCBoKaQd+9e2Z\n" + "BHtYhwIDAQABAkEAhWv7dWIrrGvuHa8D0i51NU8R+b5IMOyHAfDnpMN1VByWcBdb\n" + "G7ZJsEYlO1Tbx1zFQOVyrDUY2hn0YttPjWys0QIhAP9+FRhHCYye/EY14zSa+lxb\n" + "ljOPjWgddMdJBcPOVNUNAiEA4M1QUtIcTnTnfvcxvEBIhbmSR8fRvZYAeT5EoTKM\n" + "puMCIQD9898X8JRHWEg9qZabVWiBoO+ddJUD5jOLWsQGKvMbiQIgBOQyxTqRJxvg\n" + "FaEnUeNMMKyzBCDS7X8gD4NNVvyUluUCIQC/lnO9xYi6S4BFMwHFEUY0jLr5vgsR\n" + "+esRU9dLkMqt+w==\n" "-----END PRIVATE KEY-----\n"; unsigned char rsa_test_asn1_pubkey[] = { diff --git a/tests/bf_test.c b/tests/bf_test.c new file mode 100644 index 00000000..153444e9 --- /dev/null +++ b/tests/bf_test.c @@ -0,0 +1,1368 @@ +/* $OpenBSD: bf_test.c,v 1.2 2022/11/07 23:04:25 joshua Exp $ */ +/* + * Copyright (c) 2022 Joshua Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include +#include + +struct bf_test { + const int mode; + const uint8_t key[64]; + const int key_len; + const uint8_t iv[64]; + const int iv_len; + const uint8_t in[64]; + const int in_len; + const uint8_t out[64]; + const int out_len; + const int padding; +}; + +static const struct bf_test bf_tests[] = { + /* + * ECB - Test vectors from + * https://www.schneier.com/wp-content/uploads/2015/12/vectors-2.txt + */ + { + .mode = NID_bf_ecb, + .key = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .key_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 8, + .out = { + 0x4E, 0xF9, 0x97, 0x45, 0x61, 0x98, 0xDD, 0x78, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + }, + .key_len = 8, + .in = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + }, + .in_len = 8, + .out = { + 0x51, 0x86, 0x6F, 0xD5, 0xB8, 0x5E, 0xCB, 0x8A, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .key_len = 8, + .in = { + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + }, + .in_len = 8, + .out = { + 0x7D, 0x85, 0x6F, 0x9A, 0x61, 0x30, 0x63, 0xF2, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + }, + .key_len = 8, + .in = { + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + }, + .in_len = 8, + .out = { + 0x24, 0x66, 0xDD, 0x87, 0x8B, 0x96, 0x3C, 0x9D, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + }, + .key_len = 8, + .in = { + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + }, + .in_len = 8, + .out = { + 0x61, 0xF9, 0xC3, 0x80, 0x22, 0x81, 0xB0, 0x96, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + }, + .key_len = 8, + .in = { + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + }, + .in_len = 8, + .out = { + 0x7D, 0x0C, 0xC6, 0x30, 0xAF, 0xDA, 0x1E, 0xC7, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 + }, + .key_len = 8, + .in = { + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + }, + .in_len = 8, + .out = { + 0x0A, 0xCE, 0xAB, 0x0F, 0xC6, 0xA0, 0xA2, 0x8D, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x7C, 0xA1, 0x10, 0x45, 0x4A, 0x1A, 0x6E, 0x57, + }, + .key_len = 8, + .in = { + 0x01, 0xA1, 0xD6, 0xD0, 0x39, 0x77, 0x67, 0x42, + }, + .in_len = 8, + .out = { + 0x59, 0xC6, 0x82, 0x45, 0xEB, 0x05, 0x28, 0x2B, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x01, 0x31, 0xD9, 0x61, 0x9D, 0xC1, 0x37, 0x6E, + }, + .key_len = 8, + .in = { + 0x5C, 0xD5, 0x4C, 0xA8, 0x3D, 0xEF, 0x57, 0xDA, + }, + .in_len = 8, + .out = { + 0xB1, 0xB8, 0xCC, 0x0B, 0x25, 0x0F, 0x09, 0xA0, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x07, 0xA1, 0x13, 0x3E, 0x4A, 0x0B, 0x26, 0x86, + }, + .key_len = 8, + .in = { + 0x02, 0x48, 0xD4, 0x38, 0x06, 0xF6, 0x71, 0x72, + }, + .in_len = 8, + .out = { + 0x17, 0x30, 0xE5, 0x77, 0x8B, 0xEA, 0x1D, 0xA4, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x38, 0x49, 0x67, 0x4C, 0x26, 0x02, 0x31, 0x9E, + }, + .key_len = 8, + .in = { + 0x51, 0x45, 0x4B, 0x58, 0x2D, 0xDF, 0x44, 0x0A, + }, + .in_len = 8, + .out = { + 0xA2, 0x5E, 0x78, 0x56, 0xCF, 0x26, 0x51, 0xEB, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x04, 0xB9, 0x15, 0xBA, 0x43, 0xFE, 0xB5, 0xB6, + }, + .key_len = 8, + .in = { + 0x42, 0xFD, 0x44, 0x30, 0x59, 0x57, 0x7F, 0xA2, + }, + .in_len = 8, + .out = { + 0x35, 0x38, 0x82, 0xB1, 0x09, 0xCE, 0x8F, 0x1A, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x01, 0x13, 0xB9, 0x70, 0xFD, 0x34, 0xF2, 0xCE, + }, + .key_len = 8, + .in = { + 0x05, 0x9B, 0x5E, 0x08, 0x51, 0xCF, 0x14, 0x3A, + }, + .in_len = 8, + .out = { + 0x48, 0xF4, 0xD0, 0x88, 0x4C, 0x37, 0x99, 0x18, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x01, 0x70, 0xF1, 0x75, 0x46, 0x8F, 0xB5, 0xE6, + }, + .key_len = 8, + .in = { + 0x07, 0x56, 0xD8, 0xE0, 0x77, 0x47, 0x61, 0xD2, + }, + .in_len = 8, + .out = { + 0x43, 0x21, 0x93, 0xB7, 0x89, 0x51, 0xFC, 0x98, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x43, 0x29, 0x7F, 0xAD, 0x38, 0xE3, 0x73, 0xFE, + }, + .key_len = 8, + .in = { + 0x76, 0x25, 0x14, 0xB8, 0x29, 0xBF, 0x48, 0x6A, + }, + .in_len = 8, + .out = { + 0x13, 0xF0, 0x41, 0x54, 0xD6, 0x9D, 0x1A, 0xE5, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x07, 0xA7, 0x13, 0x70, 0x45, 0xDA, 0x2A, 0x16, + }, + .key_len = 8, + .in = { + 0x3B, 0xDD, 0x11, 0x90, 0x49, 0x37, 0x28, 0x02, + }, + .in_len = 8, + .out = { + 0x2E, 0xED, 0xDA, 0x93, 0xFF, 0xD3, 0x9C, 0x79, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x04, 0x68, 0x91, 0x04, 0xC2, 0xFD, 0x3B, 0x2F, + }, + .key_len = 8, + .in = { + 0x26, 0x95, 0x5F, 0x68, 0x35, 0xAF, 0x60, 0x9A, + }, + .in_len = 8, + .out = { + 0xD8, 0x87, 0xE0, 0x39, 0x3C, 0x2D, 0xA6, 0xE3, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x37, 0xD0, 0x6B, 0xB5, 0x16, 0xCB, 0x75, 0x46, + }, + .key_len = 8, + .in = { + 0x16, 0x4D, 0x5E, 0x40, 0x4F, 0x27, 0x52, 0x32, + }, + .in_len = 8, + .out = { + 0x5F, 0x99, 0xD0, 0x4F, 0x5B, 0x16, 0x39, 0x69, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x1F, 0x08, 0x26, 0x0D, 0x1A, 0xC2, 0x46, 0x5E, + }, + .key_len = 8, + .in = { + 0x6B, 0x05, 0x6E, 0x18, 0x75, 0x9F, 0x5C, 0xCA, + }, + .in_len = 8, + .out = { + 0x4A, 0x05, 0x7A, 0x3B, 0x24, 0xD3, 0x97, 0x7B, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x58, 0x40, 0x23, 0x64, 0x1A, 0xBA, 0x61, 0x76, + }, + .key_len = 8, + .in = { + 0x00, 0x4B, 0xD6, 0xEF, 0x09, 0x17, 0x60, 0x62, + }, + .in_len = 8, + .out = { + 0x45, 0x20, 0x31, 0xC1, 0xE4, 0xFA, 0xDA, 0x8E, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x02, 0x58, 0x16, 0x16, 0x46, 0x29, 0xB0, 0x07, + }, + .key_len = 8, + .in = { + 0x48, 0x0D, 0x39, 0x00, 0x6E, 0xE7, 0x62, 0xF2, + }, + .in_len = 8, + .out = { + 0x75, 0x55, 0xAE, 0x39, 0xF5, 0x9B, 0x87, 0xBD, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x49, 0x79, 0x3E, 0xBC, 0x79, 0xB3, 0x25, 0x8F, + }, + .key_len = 8, + .in = { + 0x43, 0x75, 0x40, 0xC8, 0x69, 0x8F, 0x3C, 0xFA, + }, + .in_len = 8, + .out = { + 0x53, 0xC5, 0x5F, 0x9C, 0xB4, 0x9F, 0xC0, 0x19, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x4F, 0xB0, 0x5E, 0x15, 0x15, 0xAB, 0x73, 0xA7, + }, + .key_len = 8, + .in = { + 0x07, 0x2D, 0x43, 0xA0, 0x77, 0x07, 0x52, 0x92, + }, + .in_len = 8, + .out = { + 0x7A, 0x8E, 0x7B, 0xFA, 0x93, 0x7E, 0x89, 0xA3, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBF, + }, + .key_len = 8, + .in = { + 0x02, 0xFE, 0x55, 0x77, 0x81, 0x17, 0xF1, 0x2A, + }, + .in_len = 8, + .out = { + 0xCF, 0x9C, 0x5D, 0x7A, 0x49, 0x86, 0xAD, 0xB5, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x01, 0x83, 0x10, 0xDC, 0x40, 0x9B, 0x26, 0xD6, + }, + .key_len = 8, + .in = { + 0x1D, 0x9D, 0x5C, 0x50, 0x18, 0xF7, 0x28, 0xC2, + }, + .in_len = 8, + .out = { + 0xD1, 0xAB, 0xB2, 0x90, 0x65, 0x8B, 0xC7, 0x78, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x1C, 0x58, 0x7F, 0x1C, 0x13, 0x92, 0x4F, 0xEF, + }, + .key_len = 8, + .in = { + 0x30, 0x55, 0x32, 0x28, 0x6D, 0x6F, 0x29, 0x5A, + }, + .in_len = 8, + .out = { + 0x55, 0xCB, 0x37, 0x74, 0xD1, 0x3E, 0xF2, 0x01, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + }, + .key_len = 8, + .in = { + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + }, + .in_len = 8, + .out = { + 0xFA, 0x34, 0xEC, 0x48, 0x47, 0xB2, 0x68, 0xB2, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E, + }, + .key_len = 8, + .in = { + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + }, + .in_len = 8, + .out = { + 0xA7, 0x90, 0x79, 0x51, 0x08, 0xEA, 0x3C, 0xAE, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE, + }, + .key_len = 8, + .in = { + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + }, + .in_len = 8, + .out = { + 0xC3, 0x9E, 0x07, 0x2D, 0x9F, 0xAC, 0x63, 0x1D, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .key_len = 8, + .in = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + }, + .in_len = 8, + .out = { + 0x01, 0x49, 0x33, 0xE0, 0xCD, 0xAF, 0xF6, 0xE4, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + }, + .key_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 8, + .out = { + 0xF2, 0x1E, 0x9A, 0x77, 0xB7, 0x1C, 0x49, 0xBC, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + }, + .key_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 8, + .out = { + 0x24, 0x59, 0x46, 0x88, 0x57, 0x54, 0x36, 0x9A, + }, + .out_len = 8, + }, + { + .mode = NID_bf_ecb, + .key = { + 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, + }, + .key_len = 8, + .in = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + }, + .in_len = 8, + .out = { + 0x6B, 0x5C, 0x5A, 0x9C, 0x5D, 0x9E, 0x0A, 0x5A, + }, + .out_len = 8, + }, + + /* + * CBC - Test vector from + * https://www.schneier.com/wp-content/uploads/2015/12/vectors-2.txt + */ + { + .mode = NID_bf_cbc, + .key = { + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87, + }, + .key_len = 16, + .iv = { + 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, + }, + .iv_len = 8, + .in = { + 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, + 0x4E, 0x6F, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x74, 0x69, 0x6D, 0x65, 0x20, + 0x66, 0x6F, 0x72, 0x20, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 32, + .out = { + 0x6B, 0x77, 0xB4, 0xD6, 0x30, 0x06, 0xDE, 0xE6, + 0x05, 0xB1, 0x56, 0xE2, 0x74, 0x03, 0x97, 0x93, + 0x58, 0xDE, 0xB9, 0xE7, 0x15, 0x46, 0x16, 0xD9, + 0x59, 0xF1, 0x65, 0x2B, 0xD5, 0xFF, 0x92, 0xCC, + }, + .out_len = 32, + .padding = 0, + }, + + /* CBC (generated using https://github.com/joshuasing/libressl-test-gen) */ + { + .mode = NID_bf_cbc, + .key = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .key_len = 8, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 16, + .out = { + 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78, + 0xe1, 0xc0, 0x30, 0xe7, 0x4c, 0x14, 0xd2, 0x61, + }, + .out_len = 16, + }, + { + .mode = NID_bf_cbc, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .key_len = 16, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 16, + .out = { + 0xb9, 0x95, 0xf2, 0x4d, 0xdf, 0xe8, 0x7b, 0xf0, + 0x05, 0x3c, 0x33, 0x39, 0x43, 0x35, 0x83, 0x62, + }, + .out_len = 16, + }, + { + .mode = NID_bf_cbc, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .key_len = 16, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .in_len = 16, + .out = { + 0x86, 0x6f, 0x5e, 0x72, 0xe5, 0x9a, 0x19, 0x51, + 0x56, 0xf3, 0x2f, 0x5e, 0x95, 0xfb, 0xd6, 0x52, + }, + .out_len = 16, + }, + { + .mode = NID_bf_cbc, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .key_len = 16, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + }, + .iv_len = 8, + .in = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + .in_len = 32, + .out = { + 0xb9, 0x95, 0xf2, 0x4d, 0xdf, 0xe8, 0x7b, 0xf0, + 0x00, 0xf6, 0x2e, 0xf6, 0x6a, 0x03, 0x2d, 0x40, + 0x9c, 0xc9, 0x06, 0x31, 0x67, 0x7f, 0x6e, 0x24, + 0xeb, 0x2d, 0x3b, 0x02, 0xa3, 0x53, 0x52, 0xe9, + }, + .out_len = 32, + }, + { + .mode = NID_bf_cbc, + .key = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .key_len = 8, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 16, + .out = { + 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78, + 0xe1, 0xc0, 0x30, 0xe7, 0x4c, 0x14, 0xd2, 0x61, + 0x8b, 0xa5, 0x5d, 0x18, 0x27, 0x44, 0x9c, 0xd3, + }, + .out_len = 24, + .padding = 1, + }, + { + .mode = NID_bf_cbc, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + }, + .key_len = 8, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 12, + .out = { + 0xc0, 0x1f, 0xae, 0x76, 0x86, 0x86, 0xe7, 0xb7, + 0x3b, 0x0d, 0xd9, 0x72, 0x33, 0x2b, 0x38, 0x5d, + }, + .out_len = 16, + .padding = 1, + }, + + /* CFB64 (generated using https://github.com/joshuasing/libressl-test-gen) */ + { + .mode = NID_bf_cfb64, + .key = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .key_len = 8, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 16, + .out = { + 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78, + 0xe1, 0xc0, 0x30, 0xe7, 0x4c, 0x14, 0xd2, 0x61, + }, + .out_len = 16, + }, + { + .mode = NID_bf_cfb64, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .key_len = 16, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 16, + .out = { + 0xb9, 0x95, 0xf2, 0x4d, 0xdf, 0xe8, 0x7b, 0xf0, + 0x05, 0x3c, 0x33, 0x39, 0x43, 0x35, 0x83, 0x62, + }, + .out_len = 16, + }, + { + .mode = NID_bf_cfb64, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .key_len = 16, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .in_len = 16, + .out = { + 0xb9, 0x94, 0xf0, 0x4e, 0xdb, 0xed, 0x7d, 0xf7, + 0x0a, 0xf8, 0x96, 0xbf, 0x4d, 0x3c, 0x95, 0xdf, + }, + .out_len = 16, + }, + { + .mode = NID_bf_cfb64, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .key_len = 16, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + }, + .iv_len = 8, + .in = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + .in_len = 32, + .out = { + 0x86, 0x6e, 0x5c, 0x71, 0xe1, 0x9f, 0x1f, 0x56, + 0x1f, 0x02, 0xaa, 0x8c, 0x09, 0xe0, 0x61, 0x43, + 0x91, 0x8d, 0xd2, 0x43, 0x70, 0x5d, 0xa3, 0xf1, + 0xc7, 0x96, 0x56, 0x77, 0xfc, 0x33, 0x74, 0x9e, + }, + .out_len = 32, + }, + { + .mode = NID_bf_cfb64, + .key = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .key_len = 8, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 16, + .out = { + 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78, + 0xe1, 0xc0, 0x30, 0xe7, 0x4c, 0x14, 0xd2, 0x61, + }, + .out_len = 16, + }, + { + .mode = NID_bf_cfb64, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + }, + .key_len = 8, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 12, + .out = { + 0xc0, 0x1f, 0xae, 0x76, 0x86, 0x86, 0xe7, 0xb7, + 0x05, 0xbb, 0xd4, 0x5e, + }, + .out_len = 12, + }, + + /* OFB64 (generated using https://github.com/joshuasing/libressl-test-gen) */ + { + .mode = NID_bf_ofb64, + .key = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .key_len = 8, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 16, + .out = { + 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78, + 0xe1, 0xc0, 0x30, 0xe7, 0x4c, 0x14, 0xd2, 0x61, + }, + .out_len = 16, + }, + { + .mode = NID_bf_ofb64, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .key_len = 16, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 16, + .out = { + 0xb9, 0x95, 0xf2, 0x4d, 0xdf, 0xe8, 0x7b, 0xf0, + 0x05, 0x3c, 0x33, 0x39, 0x43, 0x35, 0x83, 0x62, + }, + .out_len = 16, + }, + { + .mode = NID_bf_ofb64, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .key_len = 16, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .in_len = 16, + .out = { + 0xb9, 0x94, 0xf0, 0x4e, 0xdb, 0xed, 0x7d, 0xf7, + 0x0d, 0x35, 0x39, 0x32, 0x4f, 0x38, 0x8d, 0x6d, + }, + .out_len = 16, + }, + { + .mode = NID_bf_ofb64, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }, + .key_len = 16, + .iv = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + }, + .iv_len = 8, + .in = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + }, + .in_len = 32, + .out = { + 0x86, 0x6e, 0x5c, 0x71, 0xe1, 0x9f, 0x1f, 0x56, + 0xbb, 0xcb, 0xd9, 0x35, 0x81, 0x57, 0xea, 0xb9, + 0xd7, 0x85, 0x28, 0x4a, 0xdc, 0xeb, 0x94, 0x99, + 0xf0, 0x87, 0x7c, 0x5a, 0x56, 0x60, 0xc7, 0x60, + }, + .out_len = 32, + }, + { + .mode = NID_bf_ofb64, + .key = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .key_len = 8, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 16, + .out = { + 0x4e, 0xf9, 0x97, 0x45, 0x61, 0x98, 0xdd, 0x78, + 0xe1, 0xc0, 0x30, 0xe7, 0x4c, 0x14, 0xd2, 0x61, + }, + .out_len = 16, + }, + { + .mode = NID_bf_ofb64, + .key = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + }, + .key_len = 8, + .iv = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .iv_len = 8, + .in = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }, + .in_len = 12, + .out = { + 0xc0, 0x1f, 0xae, 0x76, 0x86, 0x86, 0xe7, 0xb7, + 0x05, 0xbb, 0xd4, 0x5e, + }, + .out_len = 12, + }, +}; + +#define N_BF_TESTS (sizeof(bf_tests) / sizeof(bf_tests[0])) + +static int +bf_ecb_test(size_t test_number, const struct bf_test *bt) +{ + BF_KEY key; + uint8_t out[8]; + + if (bt->padding) { + /* XXX - Handle padding */ + return 1; + } + + /* Encryption */ + memset(out, 0, sizeof(out)); + BF_set_key(&key, bt->key_len, bt->key); + BF_ecb_encrypt(bt->in, out, &key, 1); + + if (memcmp(bt->out, out, bt->out_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): encryption mismatch\n", + SN_bf_ecb, test_number); + return 0; + } + + /* Decryption */ + memset(out, 0, sizeof(out)); + BF_set_key(&key, bt->key_len, bt->key); + BF_ecb_encrypt(bt->out, out, &key, 0); + + if (memcmp(bt->in, out, bt->in_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): decryption mismatch\n", + SN_bf_ecb, test_number); + return 0; + } + + return 1; +} + +static int +bf_cbc_test(size_t test_number, const struct bf_test *bt) +{ + BF_KEY key; + uint8_t out[512]; + uint8_t iv[64]; + + if (bt->padding) { + /* XXX - Handle padding */ + return 1; + } + + /* Encryption */ + memset(out, 0, sizeof(out)); + memcpy(iv, bt->iv, bt->iv_len); + BF_set_key(&key, bt->key_len, bt->key); + BF_cbc_encrypt(bt->in, out, bt->in_len, &key, iv, 1); + + if (memcmp(bt->out, out, bt->out_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): encryption mismatch\n", + SN_bf_cbc, test_number); + return 0; + } + + /* Decryption */ + memset(out, 0, sizeof(out)); + memcpy(iv, bt->iv, bt->iv_len); + BF_set_key(&key, bt->key_len, bt->key); + BF_cbc_encrypt(bt->out, out, bt->out_len, &key, iv, 0); + + if (memcmp(bt->in, out, bt->in_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): decryption mismatch\n", + SN_bf_cbc, test_number); + return 0; + } + + return 1; +} + +static int +bf_cfb64_test(size_t test_number, const struct bf_test *bt) +{ + BF_KEY key; + uint8_t out[512]; + uint8_t iv[64]; + int remainder = 0; + + if (bt->padding) { + /* XXX - Handle padding */ + return 1; + } + + /* Encryption */ + memset(out, 0, sizeof(out)); + memcpy(iv, bt->iv, bt->iv_len); + BF_set_key(&key, bt->key_len, bt->key); + BF_cfb64_encrypt(bt->in, out, bt->in_len * 8, &key, iv, &remainder, 1); + + if (memcmp(bt->out, out, bt->out_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): encryption mismatch\n", + SN_bf_cfb64, test_number); + return 0; + } + + /* Decryption */ + remainder = 0; + memset(out, 0, sizeof(out)); + memcpy(iv, bt->iv, bt->iv_len); + BF_set_key(&key, bt->key_len, bt->key); + BF_cfb64_encrypt(bt->out, out, bt->out_len, &key, iv, &remainder, 0); + + if (memcmp(bt->in, out, bt->in_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): decryption mismatch\n", + SN_bf_cfb64, test_number); + return 0; + } + + return 1; +} + +static int +bf_ofb64_test(size_t test_number, const struct bf_test *bt) +{ + BF_KEY key; + uint8_t out[512]; + uint8_t iv[64]; + int remainder = 0; + + if (bt->padding) { + /* XXX - Handle padding */ + return 1; + } + + /* Encryption */ + memset(out, 0, sizeof(out)); + memcpy(iv, bt->iv, bt->iv_len); + BF_set_key(&key, bt->key_len, bt->key); + BF_ofb64_encrypt(bt->in, out, bt->in_len, &key, iv, &remainder); + + if (memcmp(bt->out, out, bt->out_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): encryption mismatch\n", + SN_bf_ofb64, test_number); + return 0; + } + + /* Decryption */ + remainder = 0; + memset(out, 0, sizeof(out)); + memcpy(iv, bt->iv, bt->iv_len); + BF_set_key(&key, bt->key_len, bt->key); + BF_ofb64_encrypt(bt->out, out, bt->out_len, &key, iv, &remainder); + + if (memcmp(bt->in, out, bt->in_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): decryption mismatch\n", + SN_bf_ofb64, test_number); + return 0; + } + + return 1; +} + +static int +bf_evp_test(size_t test_number, const struct bf_test *bt, const char *label, + const EVP_CIPHER *cipher) +{ + EVP_CIPHER_CTX *ctx; + uint8_t out[512]; + int in_len, out_len, total_len; + int i; + int success = 0; + + if ((ctx = EVP_CIPHER_CTX_new()) == NULL) { + fprintf(stderr, "FAIL (%s:%zu): EVP_CIPHER_CTX_new failed\n", + label, test_number); + goto failed; + } + + /* EVP encryption */ + total_len = 0; + memset(out, 0, sizeof(out)); + if (!EVP_EncryptInit(ctx, cipher, NULL, NULL)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_EncryptInit failed\n", + label, test_number); + goto failed; + } + + if (!EVP_CIPHER_CTX_set_key_length(ctx, bt->key_len)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_CIPHER_CTX_set_key_length failed\n", + label, test_number); + goto failed; + } + + if (!EVP_CIPHER_CTX_set_padding(ctx, bt->padding)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_CIPHER_CTX_set_padding failed\n", + label, test_number); + goto failed; + } + + if (!EVP_EncryptInit(ctx, NULL, bt->key, bt->iv)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_EncryptInit failed\n", + label, test_number); + goto failed; + } + + for (i = 0; i < bt->in_len;) { + in_len = arc4random_uniform(bt->in_len / 2); + if (in_len > bt->in_len - i) + in_len = bt->in_len - i; + + if (!EVP_EncryptUpdate(ctx, out + total_len, &out_len, + bt->in + i, in_len)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_EncryptUpdate failed\n", + label, test_number); + goto failed; + } + + i += in_len; + total_len += out_len; + } + + if (!EVP_EncryptFinal_ex(ctx, out + total_len, &out_len)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_EncryptFinal_ex failed\n", + label, test_number); + goto failed; + } + total_len += out_len; + + if (!EVP_CIPHER_CTX_reset(ctx)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_CIPHER_CTX_reset failed\n", + label, test_number); + goto failed; + } + + if (total_len != bt->out_len) { + fprintf(stderr, + "FAIL (%s:%zu): EVP encryption length mismatch " + "(%d != %d)\n", label, test_number, total_len, bt->out_len); + goto failed; + } + + if (memcmp(bt->out, out, bt->out_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): EVP encryption mismatch\n", + label, test_number); + goto failed; + } + + /* EVP decryption */ + total_len = 0; + memset(out, 0, sizeof(out)); + if (!EVP_DecryptInit(ctx, cipher, NULL, NULL)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_DecryptInit failed\n", + label, test_number); + goto failed; + } + + if (!EVP_CIPHER_CTX_set_key_length(ctx, bt->key_len)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_CIPHER_CTX_set_key_length failed\n", + label, test_number); + goto failed; + } + + if (!EVP_CIPHER_CTX_set_padding(ctx, bt->padding)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_CIPHER_CTX_set_padding failed\n", + label, test_number); + goto failed; + } + + if (!EVP_DecryptInit(ctx, NULL, bt->key, bt->iv)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_DecryptInit failed\n", + label, test_number); + goto failed; + } + + for (i = 0; i < bt->out_len;) { + in_len = arc4random_uniform(bt->out_len / 2); + if (in_len > bt->out_len - i) + in_len = bt->out_len - i; + + if (!EVP_DecryptUpdate(ctx, out + total_len, &out_len, + bt->out + i, in_len)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_DecryptUpdate failed\n", + label, test_number); + goto failed; + } + + i += in_len; + total_len += out_len; + } + + if (!EVP_DecryptFinal_ex(ctx, out + total_len, &out_len)) { + fprintf(stderr, "FAIL (%s:%zu): EVP_DecryptFinal_ex failed\n", + label, test_number); + goto failed; + } + total_len += out_len; + + if (!EVP_CIPHER_CTX_reset(ctx)) { + fprintf(stderr, + "FAIL (%s:%zu): EVP_CIPHER_CTX_reset failed\n", + label, test_number); + goto failed; + } + + if (total_len != bt->in_len) { + fprintf(stderr, + "FAIL (%s:%zu): EVP decryption length mismatch\n", + label, test_number); + goto failed; + } + + if (memcmp(bt->in, out, bt->in_len) != 0) { + fprintf(stderr, "FAIL (%s:%zu): EVP decryption mismatch\n", + label, test_number); + goto failed; + } + + success = 1; + + failed: + EVP_CIPHER_CTX_free(ctx); + return success; +} + +static int +bf_test(void) +{ + const struct bf_test *bt; + const char *label; + const EVP_CIPHER *cipher; + size_t i; + int failed = 1; + + for (i = 0; i < N_BF_TESTS; i++) { + bt = &bf_tests[i]; + switch (bt->mode) { + case NID_bf_ecb: + label = SN_bf_ecb; + cipher = EVP_bf_ecb(); + if (!bf_ecb_test(i, bt)) + goto failed; + break; + case NID_bf_cbc: + label = SN_bf_cbc; + cipher = EVP_bf_cbc(); + if (!bf_cbc_test(i, bt)) + goto failed; + break; + case NID_bf_cfb64: + label = SN_bf_cfb64; + cipher = EVP_bf_cfb64(); + if (!bf_cfb64_test(i, bt)) + goto failed; + break; + case NID_bf_ofb64: + label = SN_bf_ofb64; + cipher = EVP_bf_ofb(); + if (!bf_ofb64_test(i, bt)) + goto failed; + break; + default: + fprintf(stderr, "FAIL: unknown mode (%d)\n", + bt->mode); + goto failed; + } + + if (!bf_evp_test(i, bt, label, cipher)) + goto failed; + } + + failed = 0; + + failed: + return failed; +} + +int +main(int argc, char **argv) +{ + int failed = 0; + + failed |= bf_test(); + + return failed; +} + diff --git a/tests/bftest.c b/tests/bftest.c deleted file mode 100644 index 5239ffb2..00000000 --- a/tests/bftest.c +++ /dev/null @@ -1,513 +0,0 @@ -/* $OpenBSD: bftest.c,v 1.3 2018/07/17 17:06:49 tb Exp $ */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -/* This has been a quickly hacked 'ideatest.c'. When I add tests for other - * RC2 modes, more of the code will be uncommented. */ - -#include -#include -#include - -#include - -static char *bf_key[2]={ - "abcdefghijklmnopqrstuvwxyz", - "Who is John Galt?" - }; - -/* big endian */ -static BF_LONG bf_plain[2][2]={ - {0x424c4f57L,0x46495348L}, - {0xfedcba98L,0x76543210L} - }; - -static BF_LONG bf_cipher[2][2]={ - {0x324ed0feL,0xf413a203L}, - {0xcc91732bL,0x8022f684L} - }; -/************/ - -/* Lets use the DES test vectors :-) */ -#define NUM_TESTS 34 -static unsigned char ecb_data[NUM_TESTS][8]={ - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, - {0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, - {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, - {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}, - {0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57}, - {0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E}, - {0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86}, - {0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E}, - {0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6}, - {0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE}, - {0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6}, - {0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE}, - {0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16}, - {0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F}, - {0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46}, - {0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E}, - {0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76}, - {0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07}, - {0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F}, - {0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7}, - {0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF}, - {0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6}, - {0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF}, - {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, - {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E}, - {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, - {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, - {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}}; - -static unsigned char plain_data[NUM_TESTS][8]={ - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, - {0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01}, - {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, - {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11}, - {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, - {0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42}, - {0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA}, - {0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72}, - {0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A}, - {0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2}, - {0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A}, - {0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2}, - {0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A}, - {0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02}, - {0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A}, - {0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32}, - {0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA}, - {0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62}, - {0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2}, - {0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA}, - {0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92}, - {0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A}, - {0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2}, - {0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A}, - {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, - {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, - {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}, - {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, - {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}}; - -static unsigned char cipher_data[NUM_TESTS][8]={ - {0x4E,0xF9,0x97,0x45,0x61,0x98,0xDD,0x78}, - {0x51,0x86,0x6F,0xD5,0xB8,0x5E,0xCB,0x8A}, - {0x7D,0x85,0x6F,0x9A,0x61,0x30,0x63,0xF2}, - {0x24,0x66,0xDD,0x87,0x8B,0x96,0x3C,0x9D}, - {0x61,0xF9,0xC3,0x80,0x22,0x81,0xB0,0x96}, - {0x7D,0x0C,0xC6,0x30,0xAF,0xDA,0x1E,0xC7}, - {0x4E,0xF9,0x97,0x45,0x61,0x98,0xDD,0x78}, - {0x0A,0xCE,0xAB,0x0F,0xC6,0xA0,0xA2,0x8D}, - {0x59,0xC6,0x82,0x45,0xEB,0x05,0x28,0x2B}, - {0xB1,0xB8,0xCC,0x0B,0x25,0x0F,0x09,0xA0}, - {0x17,0x30,0xE5,0x77,0x8B,0xEA,0x1D,0xA4}, - {0xA2,0x5E,0x78,0x56,0xCF,0x26,0x51,0xEB}, - {0x35,0x38,0x82,0xB1,0x09,0xCE,0x8F,0x1A}, - {0x48,0xF4,0xD0,0x88,0x4C,0x37,0x99,0x18}, - {0x43,0x21,0x93,0xB7,0x89,0x51,0xFC,0x98}, - {0x13,0xF0,0x41,0x54,0xD6,0x9D,0x1A,0xE5}, - {0x2E,0xED,0xDA,0x93,0xFF,0xD3,0x9C,0x79}, - {0xD8,0x87,0xE0,0x39,0x3C,0x2D,0xA6,0xE3}, - {0x5F,0x99,0xD0,0x4F,0x5B,0x16,0x39,0x69}, - {0x4A,0x05,0x7A,0x3B,0x24,0xD3,0x97,0x7B}, - {0x45,0x20,0x31,0xC1,0xE4,0xFA,0xDA,0x8E}, - {0x75,0x55,0xAE,0x39,0xF5,0x9B,0x87,0xBD}, - {0x53,0xC5,0x5F,0x9C,0xB4,0x9F,0xC0,0x19}, - {0x7A,0x8E,0x7B,0xFA,0x93,0x7E,0x89,0xA3}, - {0xCF,0x9C,0x5D,0x7A,0x49,0x86,0xAD,0xB5}, - {0xD1,0xAB,0xB2,0x90,0x65,0x8B,0xC7,0x78}, - {0x55,0xCB,0x37,0x74,0xD1,0x3E,0xF2,0x01}, - {0xFA,0x34,0xEC,0x48,0x47,0xB2,0x68,0xB2}, - {0xA7,0x90,0x79,0x51,0x08,0xEA,0x3C,0xAE}, - {0xC3,0x9E,0x07,0x2D,0x9F,0xAC,0x63,0x1D}, - {0x01,0x49,0x33,0xE0,0xCD,0xAF,0xF6,0xE4}, - {0xF2,0x1E,0x9A,0x77,0xB7,0x1C,0x49,0xBC}, - {0x24,0x59,0x46,0x88,0x57,0x54,0x36,0x9A}, - {0x6B,0x5C,0x5A,0x9C,0x5D,0x9E,0x0A,0x5A}, - }; - -static unsigned char cbc_key [16]={ - 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, - 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87}; -static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; -static char cbc_data[40]="7654321 Now is the time for "; -static unsigned char cbc_ok[32]={ - 0x6B,0x77,0xB4,0xD6,0x30,0x06,0xDE,0xE6, - 0x05,0xB1,0x56,0xE2,0x74,0x03,0x97,0x93, - 0x58,0xDE,0xB9,0xE7,0x15,0x46,0x16,0xD9, - 0x59,0xF1,0x65,0x2B,0xD5,0xFF,0x92,0xCC}; - -static unsigned char cfb64_ok[]={ - 0xE7,0x32,0x14,0xA2,0x82,0x21,0x39,0xCA, - 0xF2,0x6E,0xCF,0x6D,0x2E,0xB9,0xE7,0x6E, - 0x3D,0xA3,0xDE,0x04,0xD1,0x51,0x72,0x00, - 0x51,0x9D,0x57,0xA6,0xC3}; - -static unsigned char ofb64_ok[]={ - 0xE7,0x32,0x14,0xA2,0x82,0x21,0x39,0xCA, - 0x62,0xB3,0x43,0xCC,0x5B,0x65,0x58,0x73, - 0x10,0xDD,0x90,0x8D,0x0C,0x24,0x1B,0x22, - 0x63,0xC2,0xCF,0x80,0xDA}; - -#define KEY_TEST_NUM 25 -static unsigned char key_test[KEY_TEST_NUM]={ - 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87, - 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f, - 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77, - 0x88}; - -static unsigned char key_data[8]= - {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}; - -static unsigned char key_out[KEY_TEST_NUM][8]={ - {0xF9,0xAD,0x59,0x7C,0x49,0xDB,0x00,0x5E}, - {0xE9,0x1D,0x21,0xC1,0xD9,0x61,0xA6,0xD6}, - {0xE9,0xC2,0xB7,0x0A,0x1B,0xC6,0x5C,0xF3}, - {0xBE,0x1E,0x63,0x94,0x08,0x64,0x0F,0x05}, - {0xB3,0x9E,0x44,0x48,0x1B,0xDB,0x1E,0x6E}, - {0x94,0x57,0xAA,0x83,0xB1,0x92,0x8C,0x0D}, - {0x8B,0xB7,0x70,0x32,0xF9,0x60,0x62,0x9D}, - {0xE8,0x7A,0x24,0x4E,0x2C,0xC8,0x5E,0x82}, - {0x15,0x75,0x0E,0x7A,0x4F,0x4E,0xC5,0x77}, - {0x12,0x2B,0xA7,0x0B,0x3A,0xB6,0x4A,0xE0}, - {0x3A,0x83,0x3C,0x9A,0xFF,0xC5,0x37,0xF6}, - {0x94,0x09,0xDA,0x87,0xA9,0x0F,0x6B,0xF2}, - {0x88,0x4F,0x80,0x62,0x50,0x60,0xB8,0xB4}, - {0x1F,0x85,0x03,0x1C,0x19,0xE1,0x19,0x68}, - {0x79,0xD9,0x37,0x3A,0x71,0x4C,0xA3,0x4F}, - {0x93,0x14,0x28,0x87,0xEE,0x3B,0xE1,0x5C}, - {0x03,0x42,0x9E,0x83,0x8C,0xE2,0xD1,0x4B}, - {0xA4,0x29,0x9E,0x27,0x46,0x9F,0xF6,0x7B}, - {0xAF,0xD5,0xAE,0xD1,0xC1,0xBC,0x96,0xA8}, - {0x10,0x85,0x1C,0x0E,0x38,0x58,0xDA,0x9F}, - {0xE6,0xF5,0x1E,0xD7,0x9B,0x9D,0xB2,0x1F}, - {0x64,0xA6,0xE1,0x4A,0xFD,0x36,0xB4,0x6F}, - {0x80,0xC7,0xD7,0xD4,0x5A,0x54,0x79,0xAD}, - {0x05,0x04,0x4B,0x62,0xFA,0x52,0xD0,0x80}, - }; - -static int test(void ); -static int print_test_data(void ); -int main(int argc, char *argv[]) - { - int ret; - - if (argc > 1) - ret=print_test_data(); - else - ret=test(); - - return ret; - } - -static int print_test_data(void) - { - unsigned int i,j; - - printf("ecb test data\n"); - printf("key bytes\t\tclear bytes\t\tcipher bytes\n"); - for (i=0; i + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +#include + +#include "bio_local.h" + +#ifndef nitems +#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) +#endif + +#define CHAIN_POP_LEN 5 +#define LINK_CHAIN_A_LEN 8 +#define LINK_CHAIN_B_LEN 5 + +static BIO * +BIO_prev(BIO *bio) +{ + if (bio == NULL) + return NULL; + + return bio->prev_bio; +} + +static void bio_chain_destroy(BIO **, size_t); + +static int +bio_chain_create(const BIO_METHOD *meth, BIO *chain[], size_t len) +{ + BIO *prev; + size_t i; + + memset(chain, 0, len * sizeof(BIO *)); + + prev = NULL; + for (i = 0; i < len; i++) { + if ((chain[i] = BIO_new(meth)) == NULL) { + fprintf(stderr, "BIO_new failed\n"); + goto err; + } + if ((prev = BIO_push(prev, chain[i])) == NULL) { + fprintf(stderr, "BIO_push failed\n"); + goto err; + } + } + + return 1; + + err: + bio_chain_destroy(chain, len); + + return 0; +} + +static void +bio_chain_destroy(BIO *chain[], size_t len) +{ + size_t i; + + for (i = 0; i < len; i++) + BIO_free(chain[i]); + + memset(chain, 0, len * sizeof(BIO *)); +} + +static int +bio_chain_pop_test(void) +{ + BIO *bio[CHAIN_POP_LEN]; + BIO *prev, *next; + size_t i, j; + int failed = 1; + + for (i = 0; i < nitems(bio); i++) { + memset(bio, 0, sizeof(bio)); + prev = NULL; + + if (!bio_chain_create(BIO_s_null(), bio, nitems(bio))) + goto err; + + /* Check that the doubly-linked list was set up as expected. */ + if (BIO_prev(bio[0]) != NULL) { + fprintf(stderr, + "i = %zu: first BIO has predecessor\n", i); + goto err; + } + if (BIO_next(bio[nitems(bio) - 1]) != NULL) { + fprintf(stderr, "i = %zu: last BIO has successor\n", i); + goto err; + } + for (j = 0; j < nitems(bio); j++) { + if (j > 0) { + if (BIO_prev(bio[j]) != bio[j - 1]) { + fprintf(stderr, "i = %zu: " + "BIO_prev(bio[%zu]) != bio[%zu]\n", + i, j, j - 1); + goto err; + } + } + if (j < nitems(bio) - 1) { + if (BIO_next(bio[j]) != bio[j + 1]) { + fprintf(stderr, "i = %zu: " + "BIO_next(bio[%zu]) != bio[%zu]\n", + i, j, j + 1); + goto err; + } + } + } + + /* Drop the ith bio from the chain. */ + next = BIO_pop(bio[i]); + + if (BIO_prev(bio[i]) != NULL || BIO_next(bio[i]) != NULL) { + fprintf(stderr, + "BIO_pop() didn't isolate bio[%zu]\n", i); + goto err; + } + + if (i < nitems(bio) - 1) { + if (next != bio[i + 1]) { + fprintf(stderr, "BIO_pop(bio[%zu]) did not " + "return bio[%zu]\n", i, i + 1); + goto err; + } + } else { + if (next != NULL) { + fprintf(stderr, "i = %zu: " + "BIO_pop(last) != NULL\n", i); + goto err; + } + } + + /* + * Walk the remainder of the chain and see if the doubly linked + * list checks out. + */ + if (i == 0) { + prev = bio[1]; + j = 2; + } else { + prev = bio[0]; + j = 1; + } + + for (; j < nitems(bio); j++) { + if (j == i) + continue; + if (BIO_next(prev) != bio[j]) { + fprintf(stderr, "i = %zu, j = %zu: " + "BIO_next(prev) != bio[%zu]\n", i, j, j); + goto err; + } + if (BIO_prev(bio[j]) != prev) { + fprintf(stderr, "i = %zu, j = %zu: " + "BIO_prev(bio[%zu]) != prev\n", i, j, j); + goto err; + } + prev = bio[j]; + } + + if (BIO_next(prev) != NULL) { + fprintf(stderr, "i = %zu: BIO_next(prev) != NULL\n", i); + goto err; + } + + bio_chain_destroy(bio, nitems(bio)); + } + + failed = 0; + + err: + bio_chain_destroy(bio, nitems(bio)); + + return failed; +} + +static void +walk(BIO *(*step)(BIO *), BIO *start, BIO **end, size_t *len) +{ + BIO *current = NULL; + BIO *next = start; + + *len = 0; + while (next != NULL) { + current = next; + next = step(current); + (*len)++; + } + *end = current; +} + +static int +walk_report(BIO *last, BIO *expected_last, size_t len, size_t expected_len, + size_t i, size_t j, const char *fn, const char *description, + const char *direction, const char *last_name) +{ + if (last != expected_last) { + fprintf(stderr, "%s case (%zu, %zu) %s %s has unexpected %s\n", + fn, i, j, description, direction, last_name); + return 0; + } + + if (len != expected_len) { + fprintf(stderr, "%s case (%zu, %zu) %s %s want %zu, got %zu\n", + fn, i, j, description, direction, expected_len, len); + return 0; + } + + return 1; +} + +static int +walk_forward(BIO *start, BIO *expected_end, size_t expected_len, + size_t i, size_t j, const char *fn, const char *description) +{ + BIO *end; + size_t len; + + walk(BIO_next, start, &end, &len); + + return walk_report(end, expected_end, len, expected_len, + i, j, fn, description, "forward", "end"); +} + +static int +walk_backward(BIO *expected_start, BIO *end, size_t expected_len, + size_t i, size_t j, const char *fn, const char *description) +{ + BIO *start; + size_t len; + + walk(BIO_prev, end, &start, &len); + + return walk_report(start, expected_start, len, expected_len, + i, j, fn, description, "backward", "start"); +} + +static int +check_chain(BIO *start, BIO *end, size_t expected_len, size_t i, size_t j, + const char *fn, const char *description) +{ + if (!walk_forward(start, end, expected_len, i, j, fn, description)) + return 0; + + if (!walk_backward(start, end, expected_len, i, j, fn, description)) + return 0; + + return 1; +} + +/* + * Link two linear chains of BIOs A[] and B[] together using either + * BIO_push(A[i], B[j]) or BIO_set_next(A[i], B[j]). + * + * BIO_push() first walks the chain A[] to its end and then appends the tail + * of chain B[] starting at B[j]. If j > 0, we get two chains + * + * A[0] -- ... -- A[nitems(A) - 1] -- B[j] -- ... -- B[nitems(B) - 1] + * `- link created by BIO_push() + * B[0] -- ... -- B[j-1] + * |<-- oldhead -->| + * + * of lengths nitems(A) + nitems(B) - j and j, respectively. + * If j == 0, the second chain (oldhead) is empty. One quirk of BIO_push() is + * that the outcome of BIO_push(A[i], B[j]) apart from the return value is + * independent of i. + * + * Prior to bio_lib.c r1.41, BIO_push(A[i], B[j]) would fail to dissociate the + * two chains and leave B[j] with two parents for 0 < j < nitems(B). + * B[j]->prev_bio would point at A[nitems(A) - 1], while both B[j - 1] and + * A[nitems(A) - 1] would point at B[j]. In particular, BIO_free_all(A[0]) + * followed by BIO_free_all(B[0]) results in a double free of B[j]. + * + * The result for BIO_set_next() is different: three chains are created. + * + * |--- oldtail --> + * ... -- A[i-1] -- A[i] -- A[i+1] -- ... + * \ + * \ link created by BIO_set_next() + * --- oldhead -->| \ + * ... -- B[j-1] -- B[j] -- B[j+1] -- ... + * + * After creating a new link, the new chain has length i + 1 + nitems(B) - j, + * oldtail has length nitems(A) - i - 1 and oldhead has length j. + * + * Prior to bio_lib.c r1.40, BIO_set_next(A[i], B[j]) would result in both A[i] + * and B[j - 1] pointing at B[j] while B[j] would point back at A[i]. Calling + * BIO_free_all(A[0]) and BIO_free_all(B[0]) results in a double free of B[j]. + * + * XXX: Should check that the callback is called on BIO_push() as expected. + */ + +static int +link_chains_at(size_t i, size_t j, int use_bio_push) +{ + const char *fn = use_bio_push ? "BIO_push" : "BIO_set_next"; + BIO *A[LINK_CHAIN_A_LEN], *B[LINK_CHAIN_B_LEN]; + BIO *new_start, *new_end; + BIO *oldhead_start, *oldhead_end, *oldtail_start, *oldtail_end; + size_t new_len, oldhead_len, oldtail_len; + int failed = 1; + + memset(A, 0, sizeof(A)); + memset(B, 0, sizeof(B)); + + if (i >= nitems(A) || j >= nitems(B)) + goto err; + + /* Create two linear chains of BIOs. */ + if (!bio_chain_create(BIO_s_null(), A, nitems(A))) + goto err; + if (!bio_chain_create(BIO_s_null(), B, nitems(B))) + goto err; + + /* + * Set our expectations. ... it's complicated. + */ + + new_start = A[0]; + new_end = B[nitems(B) - 1]; + /* new_len depends on use_bio_push. It is set a few lines down. */ + + oldhead_start = B[0]; + oldhead_end = BIO_prev(B[j]); + oldhead_len = j; + + /* If we push B[0] or set next to B[0], the oldhead chain is empty. */ + if (j == 0) { + oldhead_start = NULL; + oldhead_end = NULL; + oldhead_len = 0; + } + + if (use_bio_push) { + new_len = nitems(A) + nitems(B) - j; + + /* oldtail doesn't exist in the BIO_push() case. */ + oldtail_start = NULL; + oldtail_end = NULL; + oldtail_len = 0; + } else { + new_len = i + 1 + nitems(B) - j; + + oldtail_start = BIO_next(A[i]); + oldtail_end = A[nitems(A) - 1]; + oldtail_len = nitems(A) - i - 1; + + /* If we set next on end of A[], the oldtail chain is empty. */ + if (i == nitems(A) - 1) { + oldtail_start = NULL; + oldtail_end = NULL; + oldtail_len = 0; + } + } + + /* The two chains A[] and B[] are split into three disjoint pieces. */ + if (nitems(A) + nitems(B) != new_len + oldtail_len + oldhead_len) { + fprintf(stderr, "%s case (%zu, %zu) inconsistent lengths: " + "%zu + %zu != %zu + %zu + %zu\n", fn, i, j, + nitems(A), nitems(B), new_len, oldtail_len, oldhead_len); + goto err; + } + + /* + * Now actually push or set next. + */ + + if (use_bio_push) { + if (BIO_push(A[i], B[j]) != A[i]) { + fprintf(stderr, "BIO_push(A[%zu], B[%zu]) != A[%zu]\n", + i, j, i); + goto err; + } + } else { + BIO_set_next(A[i], B[j]); + } + + /* + * Check that all the chains match our expectations. + */ + + if (!check_chain(new_start, new_end, new_len, i, j, fn, "new chain")) + goto err; + + if (!check_chain(oldhead_start, oldhead_end, oldhead_len, i, j, fn, + "oldhead")) + goto err; + + if (!check_chain(oldtail_start, oldtail_end, oldtail_len, i, j, fn, + "oldtail")) + goto err; + + /* + * All sanity checks passed. We can now free the chains + * with the BIO API without risk of leaks or double frees. + */ + + BIO_free_all(new_start); + BIO_free_all(oldhead_start); + BIO_free_all(oldtail_start); + + memset(A, 0, sizeof(A)); + memset(B, 0, sizeof(B)); + + failed = 0; + + err: + bio_chain_destroy(A, nitems(A)); + bio_chain_destroy(B, nitems(B)); + + return failed; +} + +static int +link_chains(int use_bio_push) +{ + size_t i, j; + int failure = 0; + + for (i = 0; i < LINK_CHAIN_A_LEN; i++) { + for (j = 0; j < LINK_CHAIN_B_LEN; j++) { + failure |= link_chains_at(i, j, use_bio_push); + } + } + + return failure; +} + +static int +bio_push_link_test(void) +{ + int use_bio_push = 1; + + return link_chains(use_bio_push); +} + +static int +bio_set_next_link_test(void) +{ + int use_bio_push = 0; + + return link_chains(use_bio_push); +} + +int +main(int argc, char **argv) +{ + int failed = 0; + + failed |= bio_chain_pop_test(); + failed |= bio_push_link_test(); + failed |= bio_set_next_link_test(); + + return failed; +} diff --git a/tests/bio_host.c b/tests/bio_host.c new file mode 100644 index 00000000..b3a46451 --- /dev/null +++ b/tests/bio_host.c @@ -0,0 +1,154 @@ +/* $OpenBSD: bio_host.c,v 1.1 2022/12/08 17:49:02 tb Exp $ */ +/* + * Copyright (c) 2014 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +struct bio_get_host_ip_test { + char *input; + uint32_t ip; + int ret; +}; + +struct bio_get_host_ip_test bio_get_host_ip_tests[] = { + {"", 0, 0}, + {".", 0, 0}, + {"1", 0, 0}, + {"1.2", 0, 0}, + {"1.2.3", 0, 0}, + {"1.2.3.", 0, 0}, + {"1.2.3.4", 0x01020304, 1}, + {"1.2.3.256", 0, 0}, + {"1:2:3::4", 0, 0}, + {"0.0.0.0", INADDR_ANY, 1}, + {"127.0.0.1", INADDR_LOOPBACK, 1}, + {"localhost", INADDR_LOOPBACK, 1}, + {"255.255.255.255", INADDR_BROADCAST, 1}, + {"0xff.0xff.0xff.0xff", 0, 0}, +}; + +#define N_BIO_GET_IP_TESTS \ + (sizeof(bio_get_host_ip_tests) / sizeof(*bio_get_host_ip_tests)) + +struct bio_get_port_test { + char *input; + unsigned short port; + int ret; +}; + +struct bio_get_port_test bio_get_port_tests[] = { + {NULL, 0, 0}, + {"", 0, 0}, + {"-1", 0, 0}, + {"0", 0, 1}, + {"1", 1, 1}, + {"12345", 12345, 1}, + {"65535", 65535, 1}, + {"65536", 0, 0}, + {"999999999999", 0, 0}, + {"xyzzy", 0, 0}, + {"https", 443, 1}, + {"imaps", 993, 1}, + {"telnet", 23, 1}, +}; + +#define N_BIO_GET_PORT_TESTS \ + (sizeof(bio_get_port_tests) / sizeof(*bio_get_port_tests)) + +static int +do_bio_get_host_ip_tests(void) +{ + struct bio_get_host_ip_test *bgit; + union { + unsigned char c[4]; + uint32_t i; + } ip; + int failed = 0; + size_t i; + int ret; + + for (i = 0; i < N_BIO_GET_IP_TESTS; i++) { + bgit = &bio_get_host_ip_tests[i]; + memset(&ip, 0, sizeof(ip)); + + ret = BIO_get_host_ip(bgit->input, ip.c); + if (ret != bgit->ret) { + fprintf(stderr, "FAIL: test %zd (\"%s\") %s, want %s\n", + i, bgit->input, ret ? "success" : "failure", + bgit->ret ? "success" : "failure"); + failed = 1; + continue; + } + if (ret && ntohl(ip.i) != bgit->ip) { + fprintf(stderr, "FAIL: test %zd (\"%s\") returned ip " + "%x != %x\n", i, bgit->input, + ntohl(ip.i), bgit->ip); + failed = 1; + } + } + + return failed; +} + +static int +do_bio_get_port_tests(void) +{ + struct bio_get_port_test *bgpt; + unsigned short port; + int failed = 0; + size_t i; + int ret; + + for (i = 0; i < N_BIO_GET_PORT_TESTS; i++) { + bgpt = &bio_get_port_tests[i]; + port = 0; + + ret = BIO_get_port(bgpt->input, &port); + if (ret != bgpt->ret) { + fprintf(stderr, "FAIL: test %zd (\"%s\") %s, want %s\n", + i, bgpt->input, ret ? "success" : "failure", + bgpt->ret ? "success" : "failure"); + failed = 1; + continue; + } + if (ret && port != bgpt->port) { + fprintf(stderr, "FAIL: test %zd (\"%s\") returned port " + "%u != %u\n", i, bgpt->input, port, bgpt->port); + failed = 1; + } + } + + return failed; +} + +int +main(int argc, char **argv) +{ + int failed = 0; + + failed |= do_bio_get_host_ip_tests(); + failed |= do_bio_get_port_tests(); + + return failed; +} diff --git a/tests/biotest.c b/tests/bio_mem.c similarity index 74% rename from tests/biotest.c rename to tests/bio_mem.c index 53191346..0da7ee97 100644 --- a/tests/biotest.c +++ b/tests/bio_mem.c @@ -1,6 +1,6 @@ -/* $OpenBSD: biotest.c,v 1.9 2022/09/05 21:06:31 tb Exp $ */ +/* $OpenBSD: bio_mem.c,v 1.1 2022/12/08 17:49:02 tb Exp $ */ /* - * Copyright (c) 2014, 2022 Joel Sing + * Copyright (c) 2022 Joel Sing * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -15,135 +15,14 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include - #include #include +#include #include #include -#include - #include #include -#include - -struct bio_get_host_ip_test { - char *input; - uint32_t ip; - int ret; -}; - -struct bio_get_host_ip_test bio_get_host_ip_tests[] = { - {"", 0, 0}, - {".", 0, 0}, - {"1", 0, 0}, - {"1.2", 0, 0}, - {"1.2.3", 0, 0}, - {"1.2.3.", 0, 0}, - {"1.2.3.4", 0x01020304, 1}, - {"1.2.3.256", 0, 0}, - {"1:2:3::4", 0, 0}, - {"0.0.0.0", INADDR_ANY, 1}, - {"127.0.0.1", INADDR_LOOPBACK, 1}, - {"localhost", INADDR_LOOPBACK, 1}, - {"255.255.255.255", INADDR_BROADCAST, 1}, - {"0xff.0xff.0xff.0xff", 0, 0}, -}; - -#define N_BIO_GET_IP_TESTS \ - (sizeof(bio_get_host_ip_tests) / sizeof(*bio_get_host_ip_tests)) - -struct bio_get_port_test { - char *input; - unsigned short port; - int ret; -}; - -struct bio_get_port_test bio_get_port_tests[] = { - {NULL, 0, 0}, - {"", 0, 0}, - {"-1", 0, 0}, - {"0", 0, 1}, - {"1", 1, 1}, - {"12345", 12345, 1}, - {"65535", 65535, 1}, - {"65536", 0, 0}, - {"999999999999", 0, 0}, - {"xyzzy", 0, 0}, - {"https", 443, 1}, - {"imaps", 993, 1}, - {"telnet", 23, 1}, -}; - -#define N_BIO_GET_PORT_TESTS \ - (sizeof(bio_get_port_tests) / sizeof(*bio_get_port_tests)) - -static int -do_bio_get_host_ip_tests(void) -{ - struct bio_get_host_ip_test *bgit; - union { - unsigned char c[4]; - uint32_t i; - } ip; - int failed = 0; - size_t i; - int ret; - - for (i = 0; i < N_BIO_GET_IP_TESTS; i++) { - bgit = &bio_get_host_ip_tests[i]; - memset(&ip, 0, sizeof(ip)); - - ret = BIO_get_host_ip(bgit->input, ip.c); - if (ret != bgit->ret) { - fprintf(stderr, "FAIL: test %zd (\"%s\") %s, want %s\n", - i, bgit->input, ret ? "success" : "failure", - bgit->ret ? "success" : "failure"); - failed = 1; - continue; - } - if (ret && ntohl(ip.i) != bgit->ip) { - fprintf(stderr, "FAIL: test %zd (\"%s\") returned ip " - "%x != %x\n", i, bgit->input, - ntohl(ip.i), bgit->ip); - failed = 1; - } - } - - return failed; -} - -static int -do_bio_get_port_tests(void) -{ - struct bio_get_port_test *bgpt; - unsigned short port; - int failed = 0; - size_t i; - int ret; - - for (i = 0; i < N_BIO_GET_PORT_TESTS; i++) { - bgpt = &bio_get_port_tests[i]; - port = 0; - - ret = BIO_get_port(bgpt->input, &port); - if (ret != bgpt->ret) { - fprintf(stderr, "FAIL: test %zd (\"%s\") %s, want %s\n", - i, bgpt->input, ret ? "success" : "failure", - bgpt->ret ? "success" : "failure"); - failed = 1; - continue; - } - if (ret && port != bgpt->port) { - fprintf(stderr, "FAIL: test %zd (\"%s\") returned port " - "%u != %u\n", i, bgpt->input, port, bgpt->port); - failed = 1; - } - } - - return failed; -} static int bio_mem_test(void) @@ -453,8 +332,8 @@ bio_mem_readonly_test(void) return failed; } -static int -do_bio_mem_tests(void) +int +main(int argc, char **argv) { int failed = 0; @@ -464,15 +343,3 @@ do_bio_mem_tests(void) return failed; } - -int -main(int argc, char **argv) -{ - int ret = 0; - - ret |= do_bio_get_host_ip_tests(); - ret |= do_bio_get_port_tests(); - ret |= do_bio_mem_tests(); - - return (ret); -} diff --git a/tests/bnaddsub.c b/tests/bn_add_sub.c similarity index 86% rename from tests/bnaddsub.c rename to tests/bn_add_sub.c index e23821ed..2901dcbc 100644 --- a/tests/bnaddsub.c +++ b/tests/bn_add_sub.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bnaddsub.c,v 1.3 2018/07/23 17:15:21 tb Exp $ */ +/* $OpenBSD: bn_add_sub.c,v 1.3 2023/01/31 05:12:16 jsing Exp $ */ /* * Copyright (c) 2018 Theo Buehler * @@ -20,14 +20,11 @@ #include #include -#include #include #include #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) -BIO *bio_err; - struct hexinput_st { const char *a_hex; const char *b_hex; @@ -132,6 +129,13 @@ struct hexinput_st test_bn_usub[] = { 1, 1, }, + { + "11100000001", + "100000000001000000000", + "0", + 0, + 0, + }, { "100000000000000000000", "1", @@ -139,6 +143,20 @@ struct hexinput_st test_bn_usub[] = { 1, 1, }, + { + "1", + "0", + "1", + 1, + 1, + }, + { + "1", + "2", + "FFFFFFFFFFFFFFFF", + 0, + 0, + }, { "0", "1", @@ -152,16 +170,16 @@ void print_failure_case(BIGNUM *a, BIGNUM *b, BIGNUM *e, BIGNUM *r, int i, const char *testname) { - BIO_printf(bio_err, "%s #%d failed:", testname, i); - BIO_printf(bio_err, "\na = "); - BN_print(bio_err, a); - BIO_printf(bio_err, "\nb = "); - BN_print(bio_err, b); - BIO_printf(bio_err, "\nexpected: e = "); - BN_print(bio_err, e); - BIO_printf(bio_err, "\nobtained: r = "); - BN_print(bio_err, r); - BIO_printf(bio_err, "\n"); + fprintf(stderr, "%s #%d failed:", testname, i); + fprintf(stderr, "\na = "); + BN_print_fp(stderr, a); + fprintf(stderr, "\nb = "); + BN_print_fp(stderr, b); + fprintf(stderr, "\nexpected: e = "); + BN_print_fp(stderr, e); + fprintf(stderr, "\nobtained: r = "); + BN_print_fp(stderr, r); + fprintf(stderr, "\n"); } int @@ -177,7 +195,7 @@ bn_op_test(int (*bn_op)(BIGNUM *, const BIGNUM *, const BIGNUM *), ((e = BN_new()) == NULL) || ((r = BN_new()) == NULL)) { failed = 1; - ERR_print_errors(bio_err); + ERR_print_errors_fp(stderr); goto err; } @@ -188,7 +206,7 @@ bn_op_test(int (*bn_op)(BIGNUM *, const BIGNUM *, const BIGNUM *), !BN_hex2bn(&b, tests[i].b_hex) || !BN_hex2bn(&e, tests[i].e_hex)) { print = 1; - ERR_print_errors(bio_err); + ERR_print_errors_fp(stderr); } if (tests[i].ret != bn_op(r, a, b)) @@ -214,11 +232,6 @@ main(int argc, char *argv[]) { int failed = 0; - if ((bio_err = BIO_new_fp(stderr, BIO_NOCLOSE)) == NULL) { - fprintf(stderr, "bnaddsub: failed to initialize bio_err"); - return 1; - } - if (bn_op_test(BN_add, test_bn_add, nitems(test_bn_add), "BN_add with test_bn_add[]")) failed = 1; diff --git a/tests/bn_cmp.c b/tests/bn_cmp.c new file mode 100644 index 00000000..2f5c7c02 --- /dev/null +++ b/tests/bn_cmp.c @@ -0,0 +1,336 @@ +/* $OpenBSD: bn_cmp.c,v 1.1 2022/11/30 02:51:05 jsing Exp $ */ +/* + * Copyright (c) 2022 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include + +struct bn_cmp_test { + const char *a; + const char *b; + int cmp; + int ucmp; +}; + +struct bn_cmp_test bn_cmp_tests[] = { + { + .a = "0", + .b = "0", + .cmp = 0, + .ucmp = 0, + }, + { + .a = "-1", + .b = "0", + .cmp = -1, + .ucmp = 1, + }, + { + .a = "1ffffffffffffffff", + .b = "1ffffffffffffffff", + .cmp = 0, + .ucmp = 0, + }, + { + .a = "1fffffffffffffffe", + .b = "1ffffffffffffffff", + .cmp = -1, + .ucmp = -1, + }, + { + .a = "1ffffffffffffffff", + .b = "1fffffffffffffffe", + .cmp = 1, + .ucmp = 1, + }, + { + .a = "0", + .b = "1ffffffffffffffff", + .cmp = -1, + .ucmp = -1, + }, + { + .a = "1ffffffffffffffff", + .b = "0", + .cmp = 1, + .ucmp = 1, + }, + { + .a = "-1ffffffffffffffff", + .b = "0", + .cmp = -1, + .ucmp = 1, + }, +}; + +#define N_BN_CMP_TESTS \ + (sizeof(bn_cmp_tests) / sizeof(*bn_cmp_tests)) + +static int +test_bn_cmp(void) +{ + struct bn_cmp_test *bct; + BIGNUM *a = NULL, *b = NULL; + size_t i; + int ret; + int failed = 1; + + if ((a = BN_new()) == NULL) { + fprintf(stderr, "FAIL: failed to create BN\n"); + goto failure; + } + if ((b = BN_new()) == NULL) { + fprintf(stderr, "FAIL: failed to create BN\n"); + goto failure; + } + + for (i = 0; i < N_BN_CMP_TESTS; i++) { + bct = &bn_cmp_tests[i]; + + if (!BN_hex2bn(&a, bct->a)) { + fprintf(stderr, "FAIL: failed to set a from hex\n"); + goto failure; + } + if (!BN_hex2bn(&b, bct->b)) { + fprintf(stderr, "FAIL: failed to set b from hex\n"); + goto failure; + } + + if ((ret = BN_cmp(a, b)) != bct->cmp) { + fprintf(stderr, "FAIL: BN_cmp(%s, %s) = %d, want %d\n", + bct->a, bct->b, ret, bct->cmp); + goto failure; + } + if ((ret = BN_ucmp(a, b)) != bct->ucmp) { + fprintf(stderr, "FAIL: BN_ucmp(%s, %s) = %d, want %d\n", + bct->a, bct->b, ret, bct->ucmp); + goto failure; + } + } + + failed = 0; + + failure: + BN_free(a); + BN_free(b); + + return failed; +} + +static int +test_bn_cmp_null(void) +{ + BIGNUM *a = NULL; + int ret; + int failed = 1; + + if ((a = BN_new()) == NULL) { + fprintf(stderr, "FAIL: failed to create BN\n"); + goto failure; + } + + /* + * Comparison to NULL. + */ + if ((ret = BN_cmp(NULL, NULL)) != 0) { + fprintf(stderr, "FAIL: BN_cmp(NULL, NULL) == %d, want 0\n", ret); + goto failure; + } + + if ((ret = BN_cmp(a, NULL)) != -1) { + fprintf(stderr, "FAIL: BN_cmp(0, NULL) == %d, want -1\n", ret); + goto failure; + } + if ((ret = BN_cmp(NULL, a)) != 1) { + fprintf(stderr, "FAIL: BN_cmp(NULL, 0) == %d, want 1\n", ret); + goto failure; + } + + if (!BN_set_word(a, 1)) { + fprintf(stderr, "FAIL: failed to set BN to 1\n"); + goto failure; + } + if ((ret = BN_cmp(a, NULL)) != -1) { + fprintf(stderr, "FAIL: BN_cmp(1, NULL) == %d, want -1\n", ret); + goto failure; + } + if ((ret = BN_cmp(NULL, a)) != 1) { + fprintf(stderr, "FAIL: BN_cmp(NULL, 1) == %d, want 1\n", ret); + goto failure; + } + + BN_set_negative(a, 1); + if ((ret = BN_cmp(a, NULL)) != -1) { + fprintf(stderr, "FAIL: BN_cmp(-1, NULL) == %d, want -1\n", ret); + goto failure; + } + if ((ret = BN_cmp(NULL, a)) != 1) { + fprintf(stderr, "FAIL: BN_cmp(NULL, -1) == %d, want 1\n", ret); + goto failure; + } + + failed = 0; + + failure: + BN_free(a); + + return failed; +} + +struct bn_cmp_word_test { + int a; + int b; + int cmp; + int ucmp; +}; + +struct bn_cmp_word_test bn_cmp_word_tests[] = { + { + .a = -1, + .b = -1, + .cmp = 0, + .ucmp = 0, + }, + { + .a = 0, + .b = 0, + .cmp = 0, + .ucmp = 0, + }, + { + .a = 1, + .b = 1, + .cmp = 0, + .ucmp = 0, + }, + { + .a = 0, + .b = 1, + .cmp = -1, + .ucmp = -1, + }, + { + .a = 1, + .b = 0, + .cmp = 1, + .ucmp = 1, + }, + { + .a = -1, + .b = 0, + .cmp = -1, + .ucmp = 1, + }, + { + .a = 0, + .b = -1, + .cmp = 1, + .ucmp = -1, + }, + { + .a = -1, + .b = 1, + .cmp = -1, + .ucmp = 0, + }, + { + .a = 1, + .b = -1, + .cmp = 1, + .ucmp = 0, + }, +}; + +#define N_BN_CMP_WORD_TESTS \ + (sizeof(bn_cmp_word_tests) / sizeof(*bn_cmp_word_tests)) + +static int +test_bn_cmp_word(void) +{ + struct bn_cmp_word_test *bcwt; + BIGNUM *a = NULL, *b = NULL; + BN_ULONG v; + size_t i; + int ret; + int failed = 1; + + if ((a = BN_new()) == NULL) { + fprintf(stderr, "FAIL: failed to create BN\n"); + goto failure; + } + if ((b = BN_new()) == NULL) { + fprintf(stderr, "FAIL: failed to create BN\n"); + goto failure; + } + + for (i = 0; i < N_BN_CMP_WORD_TESTS; i++) { + bcwt = &bn_cmp_word_tests[i]; + + if (bcwt->a >= 0) { + v = bcwt->a; + } else { + v = 0 - bcwt->a; + } + if (!BN_set_word(a, v)) { + fprintf(stderr, "FAIL: failed to set a\n"); + goto failure; + } + BN_set_negative(a, (bcwt->a < 0)); + + if (bcwt->b >= 0) { + v = bcwt->b; + } else { + v = 0 - bcwt->b; + } + if (!BN_set_word(b, v)) { + fprintf(stderr, "FAIL: failed to set b\n"); + goto failure; + } + BN_set_negative(b, (bcwt->b < 0)); + + if ((ret = BN_cmp(a, b)) != bcwt->cmp) { + fprintf(stderr, "FAIL: BN_cmp(%d, %d) = %d, want %d\n", + bcwt->a, bcwt->b, ret, bcwt->cmp); + goto failure; + } + if ((ret = BN_ucmp(a, b)) != bcwt->ucmp) { + fprintf(stderr, "FAIL: BN_ucmp(%d, %d) = %d, want %d\n", + bcwt->a, bcwt->b, ret, bcwt->ucmp); + goto failure; + } + } + + failed = 0; + + failure: + BN_free(a); + BN_free(b); + + return failed; +} + +int +main(int argc, char **argv) +{ + int failed = 0; + + failed |= test_bn_cmp(); + failed |= test_bn_cmp_null(); + failed |= test_bn_cmp_word(); + + return failed; +} diff --git a/tests/bn_isqrt.c b/tests/bn_isqrt.c index 311b7889..e59515c1 100644 --- a/tests/bn_isqrt.c +++ b/tests/bn_isqrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_isqrt.c,v 1.6 2022/08/12 16:13:40 tb Exp $ */ +/* $OpenBSD: bn_isqrt.c,v 1.3 2023/03/08 06:28:08 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * @@ -16,14 +16,17 @@ */ #include +#include +#include +#include #include #include #include -#include "bn_lcl.h" +#include "bn_local.h" -#define N_TESTS 400 +#define N_TESTS 100 /* Sample squares between 2^128 and 2^4096. */ #define LOWER_BITS 128 @@ -148,9 +151,7 @@ validate_tables(void) fill[i]); failed |= 1; } - } - } return failed; @@ -251,7 +252,8 @@ isqrt_test(void) if (!bn_isqrt(isqrt, &is_perfect_square, testcase, ctx)) errx(1, "bn_isqrt testcase"); - if ((cmp = BN_cmp(n, isqrt)) != 0 || is_perfect_square) { + if ((cmp = BN_cmp(n, isqrt)) != 0 || + (is_perfect_square && BN_cmp(n_sqr, testcase) != 0)) { fprintf(stderr, "n = "); BN_print_fp(stderr, n); fprintf(stderr, "\ntestcase = "); @@ -326,8 +328,5 @@ main(int argc, char *argv[]) failed |= check_tables(0); failed |= validate_tables(); - if (!failed) - printf("SUCCESS\n"); - return failed; } diff --git a/tests/bn_mod_exp.c b/tests/bn_mod_exp.c new file mode 100644 index 00000000..67445c37 --- /dev/null +++ b/tests/bn_mod_exp.c @@ -0,0 +1,387 @@ +/* $OpenBSD: bn_mod_exp.c,v 1.15 2023/03/18 13:04:02 tb Exp $ */ + +/* + * Copyright (c) 2022,2023 Theo Buehler + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include +#include + +#include "bn_local.h" + +#define INIT_MOD_EXP_FN(f) { .name = #f, .mod_exp_fn = (f), } +#define INIT_MOD_EXP_MONT_FN(f) { .name = #f, .mod_exp_mont_fn = (f), } + +static const struct mod_exp_zero_test { + const char *name; + int (*mod_exp_fn)(BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, BN_CTX *); + int (*mod_exp_mont_fn)(BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, BN_CTX *, BN_MONT_CTX *); +} mod_exp_zero_test_data[] = { + INIT_MOD_EXP_FN(BN_mod_exp), + INIT_MOD_EXP_FN(BN_mod_exp_ct), + INIT_MOD_EXP_FN(BN_mod_exp_nonct), + INIT_MOD_EXP_FN(BN_mod_exp_recp), + INIT_MOD_EXP_FN(BN_mod_exp_simple), + INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont), + INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_ct), + INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_consttime), + INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_nonct), +}; + +#define N_MOD_EXP_ZERO_TESTS \ + (sizeof(mod_exp_zero_test_data) / sizeof(mod_exp_zero_test_data[0])) + +static void +print_failure(const BIGNUM *got, const BIGNUM *a, const char *name) +{ + fprintf(stderr, "%s test failed for a = ", name); + BN_print_fp(stderr, a); + fprintf(stderr, "\nwant 0, got "); + BN_print_fp(stderr, got); + fprintf(stderr, "\n"); +} + +static int +bn_mod_exp_zero_test(const struct mod_exp_zero_test *test, BN_CTX *ctx, + int use_random) +{ + const BIGNUM *one; + BIGNUM *a, *p, *got; + int failed = 1; + + BN_CTX_start(ctx); + + if ((a = BN_CTX_get(ctx)) == NULL) + errx(1, "BN_CTX_get"); + if ((p = BN_CTX_get(ctx)) == NULL) + errx(1, "BN_CTX_get"); + if ((got = BN_CTX_get(ctx)) == NULL) + errx(1, "BN_CTX_get"); + + one = BN_value_one(); + BN_zero(a); + BN_zero(p); + + if (use_random) { + if (!BN_rand(a, 1024, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY)) + errx(1, "BN_rand"); + } + + if (test->mod_exp_fn != NULL) { + if (!test->mod_exp_fn(got, a, p, one, ctx)) { + fprintf(stderr, "%s failed\n", test->name); + ERR_print_errors_fp(stderr); + goto err; + } + } else { + if (!test->mod_exp_mont_fn(got, a, p, one, ctx, NULL)) { + fprintf(stderr, "%s failed\n", test->name); + ERR_print_errors_fp(stderr); + goto err; + } + } + + if (!BN_is_zero(got)) { + print_failure(got, a, test->name); + goto err; + } + + failed = 0; + + err: + BN_CTX_end(ctx); + + return failed; +} + +static int +bn_mod_exp_zero_word_test(BN_CTX *ctx) +{ + const char *name = "BN_mod_exp_mont_word"; + const BIGNUM *one; + BIGNUM *p, *got; + int failed = 1; + + BN_CTX_start(ctx); + + if ((p = BN_CTX_get(ctx)) == NULL) + errx(1, "BN_CTX_get"); + if ((got = BN_CTX_get(ctx)) == NULL) + errx(1, "BN_CTX_get"); + + one = BN_value_one(); + BN_zero(p); + + if (!BN_mod_exp_mont_word(got, 1, p, one, ctx, NULL)) { + fprintf(stderr, "%s failed\n", name); + ERR_print_errors_fp(stderr); + goto err; + } + + if (!BN_is_zero(got)) { + print_failure(got, one, name); + goto err; + } + + failed = 0; + + err: + BN_CTX_end(ctx); + + return failed; +} + +static int +run_bn_mod_exp_zero_tests(void) +{ + BN_CTX *ctx; + size_t i; + int use_random; + int failed = 0; + + if ((ctx = BN_CTX_new()) == NULL) + errx(1, "BN_CTX_new"); + + use_random = 1; + for (i = 0; i < N_MOD_EXP_ZERO_TESTS; i++) + failed |= bn_mod_exp_zero_test(&mod_exp_zero_test_data[i], ctx, + use_random); + + use_random = 0; + for (i = 0; i < N_MOD_EXP_ZERO_TESTS; i++) + failed |= bn_mod_exp_zero_test(&mod_exp_zero_test_data[i], ctx, + use_random); + + failed |= bn_mod_exp_zero_word_test(ctx); + + BN_CTX_free(ctx); + + return failed; +} + +#define N_MOD_EXP_TESTS 400 + +static const struct mod_exp_test { + const char *name; + int (*mod_exp_fn)(BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, BN_CTX *); + int (*mod_exp_mont_fn)(BIGNUM *, const BIGNUM *, const BIGNUM *, + const BIGNUM *, BN_CTX *, BN_MONT_CTX *); +} mod_exp_fn[] = { + INIT_MOD_EXP_FN(BN_mod_exp), + INIT_MOD_EXP_FN(BN_mod_exp_ct), + INIT_MOD_EXP_FN(BN_mod_exp_nonct), + INIT_MOD_EXP_FN(BN_mod_exp_recp), + INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont), + INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_ct), + INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_consttime), + INIT_MOD_EXP_MONT_FN(BN_mod_exp_mont_nonct), +}; + +#define N_MOD_EXP_FN (sizeof(mod_exp_fn) / sizeof(mod_exp_fn[0])) + +static int +generate_bn(BIGNUM *bn, int avg_bits, int deviate, int force_odd) +{ + int bits; + + if (avg_bits <= 0 || deviate <= 0 || deviate >= avg_bits) + return 0; + + bits = avg_bits + arc4random_uniform(deviate) - deviate; + + return BN_rand(bn, bits, 0, force_odd); +} + +static int +generate_test_triple(int reduce, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx) +{ + BIGNUM *mmodified; + BN_ULONG multiple; + int avg = 2 * BN_BITS, deviate = BN_BITS / 2; + int ret = 0; + + if (!generate_bn(a, avg, deviate, 0)) + return 0; + + if (!generate_bn(p, avg, deviate, 0)) + return 0; + + if (!generate_bn(m, avg, deviate, 1)) + return 0; + + if (reduce) + return BN_mod(a, a, m, ctx); + + /* + * Add a random multiple of m to a to test unreduced exponentiation. + */ + + BN_CTX_start(ctx); + + if ((mmodified = BN_CTX_get(ctx)) == NULL) + goto err; + + if (BN_copy(mmodified, m) == NULL) + goto err; + + multiple = arc4random_uniform(1023) + 2; + + if (!BN_mul_word(mmodified, multiple)) + goto err; + + if (!BN_add(a, a, mmodified)) + goto err; + + ret = 1; + err: + BN_CTX_end(ctx); + + return ret; +} + +static void +dump_results(const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, + const BIGNUM *got, const BIGNUM *want, const char *name) +{ + printf("BN_mod_exp_simple() and %s() disagree", name); + + printf("\nwant: "); + BN_print_fp(stdout, want); + printf("\ngot: "); + BN_print_fp(stdout, got); + + printf("\na: "); + BN_print_fp(stdout, a); + printf("\nb: "); + BN_print_fp(stdout, p); + printf("\nm: "); + BN_print_fp(stdout, m); + printf("\n\n"); +} + +static int +test_mod_exp(const BIGNUM *want, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, const struct mod_exp_test *test) +{ + BIGNUM *got; + int ret = 0; + + BN_CTX_start(ctx); + + if ((got = BN_CTX_get(ctx)) == NULL) + goto err; + + if (test->mod_exp_fn != NULL) + ret = test->mod_exp_fn(got, a, p, m, ctx); + else + ret = test->mod_exp_mont_fn(got, a, p, m, ctx, NULL); + + if (!ret) + errx(1, "%s() failed", test->name); + + if (BN_cmp(want, got) != 0) { + dump_results(a, p, m, want, got, test->name); + goto err; + } + + ret = 1; + + err: + BN_CTX_end(ctx); + + return ret; +} + +static int +bn_mod_exp_test(int reduce, BIGNUM *want, BIGNUM *a, BIGNUM *p, BIGNUM *m, + BN_CTX *ctx) +{ + size_t i, j; + int failed = 0; + + if (!generate_test_triple(reduce, a, p, m, ctx)) + errx(1, "generate_test_triple"); + + for (i = 0; i < 4; i++) { + BN_set_negative(a, i & 1); + BN_set_negative(p, (i >> 1) & 1); + + if ((BN_mod_exp_simple(want, a, p, m, ctx)) <= 0) + errx(1, "BN_mod_exp_simple"); + + for (j = 0; j < N_MOD_EXP_FN; j++) { + const struct mod_exp_test *test = &mod_exp_fn[j]; + + if (!test_mod_exp(want, a, p, m, ctx, test)) + failed |= 1; + } + } + + return failed; +} + +static int +run_bn_mod_exp_tests(void) +{ + BIGNUM *a, *p, *m, *want; + BN_CTX *ctx; + int i; + int reduce; + int failed = 0; + + if ((ctx = BN_CTX_new()) == NULL) + errx(1, "BN_CTX_new"); + + BN_CTX_start(ctx); + + if ((a = BN_CTX_get(ctx)) == NULL) + errx(1, "a = BN_CTX_get()"); + if ((p = BN_CTX_get(ctx)) == NULL) + errx(1, "p = BN_CTX_get()"); + if ((m = BN_CTX_get(ctx)) == NULL) + errx(1, "m = BN_CTX_get()"); + if ((want = BN_CTX_get(ctx)) == NULL) + errx(1, "want = BN_CTX_get()"); + + reduce = 0; + for (i = 0; i < N_MOD_EXP_TESTS; i++) + failed |= bn_mod_exp_test(reduce, want, a, p, m, ctx); + + reduce = 1; + for (i = 0; i < N_MOD_EXP_TESTS; i++) + failed |= bn_mod_exp_test(reduce, want, a, p, m, ctx); + + BN_CTX_end(ctx); + BN_CTX_free(ctx); + + return failed; +} + +int +main(void) +{ + int failed = 0; + + failed |= run_bn_mod_exp_zero_tests(); + failed |= run_bn_mod_exp_tests(); + + return failed; +} diff --git a/tests/bn_mod_exp2_mont.c b/tests/bn_mod_exp2_mont.c index 60bb010b..aa1cd0e0 100644 --- a/tests/bn_mod_exp2_mont.c +++ b/tests/bn_mod_exp2_mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mod_exp2_mont.c,v 1.1 2022/03/10 04:39:49 tb Exp $ */ +/* $OpenBSD: bn_mod_exp2_mont.c,v 1.2 2022/12/17 23:41:29 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * @@ -32,14 +32,12 @@ main(void) if ((m = BN_new()) == NULL) errx(1, "BN_new"); - BN_zero_ex(m); + BN_zero(m); if (BN_mod_exp2_mont(NULL, NULL, NULL, NULL, NULL, m, NULL, NULL)) errx(1, "BN_mod_exp2_mont succeeded"); BN_free(m); - printf("SUCCESS\n"); - return 0; } diff --git a/tests/bn_mod_sqrt.c b/tests/bn_mod_sqrt.c index 2017492e..7757c2a1 100644 --- a/tests/bn_mod_sqrt.c +++ b/tests/bn_mod_sqrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mod_sqrt.c,v 1.1 2022/03/15 16:28:42 tb Exp $ */ +/* $OpenBSD: bn_mod_sqrt.c,v 1.2 2022/12/06 18:23:29 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * @@ -15,6 +15,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #include /* Test that sqrt * sqrt = A (mod p) where p is a prime */ @@ -125,8 +127,5 @@ main(void) for (i = 0; i < N_TESTS; i++) failed |= mod_sqrt_test(&mod_sqrt_test_data[i]); - if (!failed) - printf("SUCCESS\n"); - return failed; } diff --git a/tests/mont.c b/tests/bn_mont.c similarity index 96% rename from tests/mont.c rename to tests/bn_mont.c index 8b9b14a2..4bcc79d1 100644 --- a/tests/mont.c +++ b/tests/bn_mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mont.c,v 1.6 2022/01/14 09:32:27 tb Exp $ */ +/* $OpenBSD: bn_mont.c,v 1.2 2022/12/06 18:23:29 tb Exp $ */ /* * Copyright (c) 2014 Miodrag Vallat. @@ -16,10 +16,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include -#include -#include #include #include diff --git a/tests/bn_primes.c b/tests/bn_primes.c index f9d358f7..cd552dc3 100644 --- a/tests/bn_primes.c +++ b/tests/bn_primes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_primes.c,v 1.1 2022/06/18 19:53:19 tb Exp $ */ +/* $OpenBSD: bn_primes.c,v 1.2 2022/12/06 18:23:29 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * @@ -15,6 +15,10 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include +#include +#include + #include #include "bn_prime.h" @@ -24,7 +28,7 @@ test_bn_is_prime_fasttest(int do_trial_division) { BIGNUM *n = NULL; char *descr = NULL; - prime_t i, j, max; + uint16_t i, j, max; int is_prime, ret; int failed = 1; @@ -76,6 +80,101 @@ test_bn_is_prime_fasttest(int do_trial_division) return failed; } +#define BN_PRIME_FN_INIT(a) { .fn = a, .name = #a } + +static const struct test_dynamic_api { + BIGNUM *(*fn)(BIGNUM *); + const char *name; +} dynamic_api_data[] = { + BN_PRIME_FN_INIT(BN_get_rfc2409_prime_1024), + BN_PRIME_FN_INIT(BN_get_rfc2409_prime_768), + BN_PRIME_FN_INIT(BN_get_rfc3526_prime_1536), + BN_PRIME_FN_INIT(BN_get_rfc3526_prime_2048), + BN_PRIME_FN_INIT(BN_get_rfc3526_prime_3072), + BN_PRIME_FN_INIT(BN_get_rfc3526_prime_4096), + BN_PRIME_FN_INIT(BN_get_rfc3526_prime_6144), + BN_PRIME_FN_INIT(BN_get_rfc3526_prime_8192), +}; + +#define N_DYNAMIC_TESTS (sizeof(dynamic_api_data) / sizeof(dynamic_api_data[0])) + +static const struct test_const_api { + const BIGNUM *(*fn)(void); + const char *name; +} const_api_data[] = { + BN_PRIME_FN_INIT(BN_get0_nist_prime_192), + BN_PRIME_FN_INIT(BN_get0_nist_prime_224), + BN_PRIME_FN_INIT(BN_get0_nist_prime_256), + BN_PRIME_FN_INIT(BN_get0_nist_prime_384), + BN_PRIME_FN_INIT(BN_get0_nist_prime_521), +}; + +#define N_CONST_TESTS (sizeof(const_api_data) / sizeof(const_api_data[0])) + +static int +test_prime_dynamic_api(const struct test_dynamic_api *tc) +{ + BIGNUM *prime; + int ret; + int failed = 1; + + if ((prime = tc->fn(NULL)) == NULL) { + fprintf(stderr, "%s failed\n", tc->name); + goto err; + } + + if ((ret = BN_is_prime_fasttest_ex(prime, 1, NULL, 1, NULL)) != 1) { + fprintf(stderr, "%s: %s want 1, got %d\n", tc->name, + "BN_is_prime_fasttest_ex", ret); + goto err; + } + + failed = 0; + + err: + BN_free(prime); + return failed; +} + +static int +test_prime_const_api(const struct test_const_api *tc) +{ + const BIGNUM *prime; + int ret; + int failed = 1; + + if ((prime = tc->fn()) == NULL) { + fprintf(stderr, "%s failed\n", tc->name); + goto err; + } + + if ((ret = BN_is_prime_fasttest_ex(prime, 1, NULL, 1, NULL)) != 1) { + fprintf(stderr, "%s: %s: want 1, got %d\n", tc->name, + "BN_is_prime_fasttest_ex", ret); + goto err; + } + + failed = 0; + + err: + return failed; +} + +static int +test_prime_constants(void) +{ + size_t i; + int failed = 0; + + for (i = 0; i < N_DYNAMIC_TESTS; i++) + failed |= test_prime_dynamic_api(&dynamic_api_data[i]); + + for (i = 0; i < N_CONST_TESTS; i++) + failed |= test_prime_const_api(&const_api_data[i]); + + return failed; +} + int main(void) { @@ -83,8 +182,7 @@ main(void) failed |= test_bn_is_prime_fasttest(0); failed |= test_bn_is_prime_fasttest(1); - - printf("%s\n", failed ? "FAILED" : "SUCCESS"); + failed |= test_prime_constants(); return failed; } diff --git a/tests/bn_rand_interval.c b/tests/bn_rand_interval.c index 409d6574..3c5eaac0 100644 --- a/tests/bn_rand_interval.c +++ b/tests/bn_rand_interval.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_rand_interval.c,v 1.5 2022/06/19 17:10:02 tb Exp $ */ +/* $OpenBSD: bn_rand_interval.c,v 1.2 2023/03/08 06:44:45 tb Exp $ */ /* * Copyright (c) 2018 Theo Buehler * @@ -20,7 +20,7 @@ #include -#define NUM_TESTS 1000000 +#define NUM_TESTS 10000 int bn_rand_interval(BIGNUM *rnd, const BIGNUM *lower_incl, const BIGNUM *upper_excl); @@ -104,11 +104,6 @@ main(int argc, char *argv[]) } } - if (success == 1) - printf("SUCCESS\n"); - else - printf("FAIL"); - BN_free(a); BN_free(b); BN_free(x); diff --git a/tests/bn_shift.c b/tests/bn_shift.c new file mode 100644 index 00000000..95a61975 --- /dev/null +++ b/tests/bn_shift.c @@ -0,0 +1,659 @@ +/* $OpenBSD: bn_shift.c,v 1.9 2023/03/11 14:02:26 jsing Exp $ */ +/* + * Copyright (c) 2022 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include + +static const char *bn_shift_want_hex = \ + "02AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" \ + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8"; + +static int +check_shift_result(BIGNUM *bn1) +{ + BIGNUM *bn2 = NULL; + char *s = NULL; + int ret = 0; + + if (!BN_hex2bn(&bn2, bn_shift_want_hex)) { + fprintf(stderr, "FAIL: BN_hex2bn() failed\n"); + goto failure; + } + if (BN_cmp(bn1, bn2) != 0) { + fprintf(stderr, "FAIL: shifted result differs\n"); + if ((s = BN_bn2hex(bn1)) == NULL) { + fprintf(stderr, "FAIL: BN_bn2hex()\n"); + goto failure; + } + fprintf(stderr, "Got: %s\n", s); + free(s); + if ((s = BN_bn2hex(bn2)) == NULL) { + fprintf(stderr, "FAIL: BN_bn2hex()\n"); + goto failure; + } + fprintf(stderr, "Want: %s\n", s); + } + + ret = 1; + + failure: + BN_free(bn2); + free(s); + + return ret; +} + +static int +test_bn_shift1(void) +{ + BIGNUM *bn1 = NULL, *bn2 = NULL; + int i; + int failed = 1; + + if ((bn1 = BN_new()) == NULL) { + fprintf(stderr, "FAIL: failed to create BN\n"); + goto failure; + } + if ((bn2 = BN_new()) == NULL) { + fprintf(stderr, "FAIL: failed to create BN\n"); + goto failure; + } + + for (i = 1; i <= 256; i++) { + if (!BN_set_bit(bn1, 1)) { + fprintf(stderr, "FAIL: failed to set bit\n"); + goto failure; + } + if (!BN_lshift1(bn1, bn1)) { + fprintf(stderr, "FAIL: failed to BN_lshift1()\n"); + goto failure; + } + if (!BN_lshift1(bn1, bn1)) { + fprintf(stderr, "FAIL: failed to BN_lshift1()\n"); + goto failure; + } + if (!BN_rshift1(bn1, bn1)) { + fprintf(stderr, "FAIL: failed to BN_rshift1()\n"); + goto failure; + } + if (!BN_lshift1(bn1, bn1)) { + fprintf(stderr, "FAIL: failed to BN_lshift1()\n"); + goto failure; + } + } + + if (!check_shift_result(bn1)) + goto failure; + + /* + * Shift result into a different BN. + */ + if (!BN_lshift1(bn1, bn1)) { + fprintf(stderr, "FAIL: failed to BN_lshift1()\n"); + goto failure; + } + if (!BN_rshift1(bn2, bn1)) { + fprintf(stderr, "FAIL: failed to BN_rshift1()\n"); + goto failure; + } + + if (!check_shift_result(bn2)) + goto failure; + + if (!BN_rshift1(bn2, bn2)) { + fprintf(stderr, "FAIL: failed to BN_rshift1()\n"); + goto failure; + } + if (!BN_lshift1(bn1, bn2)) { + fprintf(stderr, "FAIL: failed to BN_lshift1()\n"); + goto failure; + } + + if (!check_shift_result(bn1)) + goto failure; + + failed = 0; + + failure: + BN_free(bn1); + BN_free(bn2); + + return failed; +} + +static int +test_bn_shift(void) +{ + BIGNUM *bn1 = NULL, *bn2 = NULL; + int i; + int failed = 1; + + if ((bn1 = BN_new()) == NULL) { + fprintf(stderr, "FAIL: failed to create BN 1\n"); + goto failure; + } + if ((bn2 = BN_new()) == NULL) { + fprintf(stderr, "FAIL: failed to create BN 2\n"); + goto failure; + } + + for (i = 1; i <= 256; i++) { + if (!BN_set_bit(bn1, 1)) { + fprintf(stderr, "FAIL: failed to set bit\n"); + goto failure; + } + if (!BN_lshift(bn1, bn1, i + 1)) { + fprintf(stderr, "FAIL: failed to BN_lshift()\n"); + goto failure; + } + if (!BN_rshift(bn1, bn1, i - 1)) { + fprintf(stderr, "FAIL: failed to BN_rshift()\n"); + goto failure; + } + } + + if (!check_shift_result(bn1)) + goto failure; + + for (i = 0; i <= 256; i++) { + if (!BN_lshift(bn1, bn1, i)) { + fprintf(stderr, "FAIL: failed to BN_lshift()\n"); + goto failure; + } + if (i > 1) { + if (!BN_set_bit(bn1, 1)) { + fprintf(stderr, "FAIL: failed to set bit\n"); + goto failure; + } + } + } + + if (BN_num_bytes(bn1) != 4177) { + fprintf(stderr, "FAIL: BN has %d bytes, want 4177\n", + BN_num_bytes(bn1)); + goto failure; + } + + for (i = 0; i <= 256; i++) { + if (!BN_rshift(bn1, bn1, i)) { + fprintf(stderr, "FAIL: failed to BN_rshift()\n"); + goto failure; + } + } + + if (!check_shift_result(bn1)) + goto failure; + + /* + * Shift result into a different BN. + */ + if (!BN_lshift(bn1, bn1, BN_BITS2 + 1)) { + fprintf(stderr, "FAIL: failed to BN_lshift()\n"); + goto failure; + } + if (!BN_rshift(bn2, bn1, BN_BITS2 + 1)) { + fprintf(stderr, "FAIL: failed to BN_rshift()\n"); + goto failure; + } + + if (!check_shift_result(bn2)) + goto failure; + + if (!BN_rshift(bn2, bn2, 3)) { + fprintf(stderr, "FAIL: failed to BN_rshift()\n"); + goto failure; + } + if (!BN_lshift(bn1, bn2, 3)) { + fprintf(stderr, "FAIL: failed to BN_lshift()\n"); + goto failure; + } + + if (!check_shift_result(bn1)) + goto failure; + + /* + * Shift of zero (equivalent to a copy). + */ + BN_zero(bn2); + if (!BN_lshift(bn2, bn1, 0)) { + fprintf(stderr, "FAIL: failed to BN_lshift()\n"); + goto failure; + } + + if (!check_shift_result(bn2)) + goto failure; + + if (!BN_lshift(bn2, bn2, 0)) { + fprintf(stderr, "FAIL: failed to BN_lshift()\n"); + goto failure; + } + + if (!check_shift_result(bn2)) + goto failure; + + BN_zero(bn2); + if (!BN_rshift(bn2, bn1, 0)) { + fprintf(stderr, "FAIL: failed to BN_rshift()\n"); + goto failure; + } + + if (!check_shift_result(bn2)) + goto failure; + + if (!BN_rshift(bn2, bn2, 0)) { + fprintf(stderr, "FAIL: failed to BN_rshift()\n"); + goto failure; + } + + if (!check_shift_result(bn2)) + goto failure; + + failed = 0; + + failure: + BN_free(bn1); + BN_free(bn2); + + return failed; +} + +static int +test_bn_rshift_to_zero(void) +{ + BIGNUM *bn1 = NULL, *bn2 = NULL; + int failed = 1; + + if (!BN_hex2bn(&bn1, "ffff")) { + fprintf(stderr, "FAIL: BN_hex2bn() failed\n"); + goto failure; + } + if (!BN_lshift(bn1, bn1, BN_BITS2)) { + fprintf(stderr, "FAIL: BN_lshift() failed\n"); + goto failure; + } + + if ((bn2 = BN_new()) == NULL) { + fprintf(stderr, "FAIL: BN_new() failed\n"); + goto failure; + } + + /* Shift all words. */ + if (!BN_rshift(bn2, bn1, BN_BITS2 * 2)) { + fprintf(stderr, "FAIL: BN_rshift() failed\n"); + goto failure; + } + if (BN_is_zero(bn1)) { + fprintf(stderr, "FAIL: BN is zero\n"); + goto failure; + } + if (!BN_is_zero(bn2)) { + fprintf(stderr, "FAIL: BN is not zero\n"); + goto failure; + } + + /* Shift to zero, with partial shift for top most word. */ + if (!BN_rshift(bn2, bn1, BN_BITS2 + 16)) { + fprintf(stderr, "FAIL: BN_rshift() failed\n"); + goto failure; + } + if (BN_is_zero(bn1)) { + fprintf(stderr, "FAIL: BN is zero\n"); + goto failure; + } + if (!BN_is_zero(bn2)) { + fprintf(stderr, "FAIL: BN is not zero\n"); + goto failure; + } + + /* Shift to zero of negative value. */ + if (!BN_one(bn1)) { + fprintf(stderr, "FAIL: BN_one() failed\n"); + goto failure; + } + BN_set_negative(bn1, 1); + if (!BN_rshift(bn1, bn1, 1)) { + fprintf(stderr, "FAIL: BN_rshift() failed\n"); + goto failure; + } + if (!BN_is_zero(bn1)) { + fprintf(stderr, "FAIL: BN is not zero\n"); + goto failure; + } + if (BN_is_negative(bn1)) { + fprintf(stderr, "FAIL: BN is negative zero\n"); + goto failure; + } + + failed = 0; + + failure: + BN_free(bn1); + BN_free(bn2); + + return failed; +} + +#if 0 + +static void +benchmark_bn_lshift1(BIGNUM *bn) +{ + int i; + + if (!BN_set_bit(bn, 8192)) + errx(1, "BN_set_bit"); + + if (!BN_one(bn)) + errx(1, "BN_one"); + + for (i = 0; i < 8192; i++) { + if (!BN_lshift1(bn, bn)) + errx(1, "BN_lshift1"); + } +} + +static void +benchmark_bn_lshift(BIGNUM *bn, int n) +{ + int i; + + if (!BN_set_bit(bn, 8192 * n)) + errx(1, "BN_set_bit"); + + if (!BN_one(bn)) + errx(1, "BN_one"); + + for (i = 0; i < 8192; i++) { + if (!BN_lshift(bn, bn, n)) + errx(1, "BN_lshift"); + } +} + +static void +benchmark_bn_lshift_1(BIGNUM *bn) +{ + benchmark_bn_lshift(bn, 1); +} + +static void +benchmark_bn_lshift_16(BIGNUM *bn) +{ + benchmark_bn_lshift(bn, 16); +} + +static void +benchmark_bn_lshift_32(BIGNUM *bn) +{ + benchmark_bn_lshift(bn, 32); +} + +static void +benchmark_bn_lshift_64(BIGNUM *bn) +{ + benchmark_bn_lshift(bn, 64); +} + +static void +benchmark_bn_lshift_65(BIGNUM *bn) +{ + benchmark_bn_lshift(bn, 65); +} + +static void +benchmark_bn_lshift_80(BIGNUM *bn) +{ + benchmark_bn_lshift(bn, 80); +} + +static void +benchmark_bn_lshift_127(BIGNUM *bn) +{ + benchmark_bn_lshift(bn, 127); +} + +static void +benchmark_bn_rshift1(BIGNUM *bn) +{ + int i; + + if (!BN_one(bn)) + errx(1, "BN_one"); + + if (!BN_set_bit(bn, 8192)) + errx(1, "BN_set_bit"); + + for (i = 0; i < 8192; i++) { + if (!BN_rshift1(bn, bn)) + errx(1, "BN_rshift1"); + } +} + +static void +benchmark_bn_rshift(BIGNUM *bn, int n) +{ + int i; + + if (!BN_one(bn)) + errx(1, "BN_one"); + + if (!BN_set_bit(bn, 8192 * n)) + errx(1, "BN_set_bit"); + + for (i = 0; i < 8192; i++) { + if (!BN_rshift(bn, bn, n)) + errx(1, "BN_rshift"); + } +} + +static void +benchmark_bn_rshift_1(BIGNUM *bn) +{ + benchmark_bn_rshift(bn, 1); +} + +static void +benchmark_bn_rshift_16(BIGNUM *bn) +{ + benchmark_bn_rshift(bn, 16); +} + +static void +benchmark_bn_rshift_32(BIGNUM *bn) +{ + benchmark_bn_rshift(bn, 32); +} + +static void +benchmark_bn_rshift_64(BIGNUM *bn) +{ + benchmark_bn_rshift(bn, 64); +} + +static void +benchmark_bn_rshift_65(BIGNUM *bn) +{ + benchmark_bn_rshift(bn, 65); +} + +static void +benchmark_bn_rshift_80(BIGNUM *bn) +{ + benchmark_bn_rshift(bn, 80); +} + +static void +benchmark_bn_rshift_127(BIGNUM *bn) +{ + benchmark_bn_rshift(bn, 127); +} + +struct benchmark { + const char *desc; + void (*func)(BIGNUM *); +}; + +static const struct benchmark benchmarks[] = { + { + .desc = "BN_lshift1()", + .func = benchmark_bn_lshift1, + }, + { + .desc = "BN_lshift(_, _, 1)", + .func = benchmark_bn_lshift_1, + }, + { + .desc = "BN_lshift(_, _, 16)", + .func = benchmark_bn_lshift_16, + }, + { + .desc = "BN_lshift(_, _, 32)", + .func = benchmark_bn_lshift_32, + }, + { + .desc = "BN_lshift(_, _, 64)", + .func = benchmark_bn_lshift_64, + }, + { + .desc = "BN_lshift(_, _, 65)", + .func = benchmark_bn_lshift_65, + }, + { + .desc = "BN_lshift(_, _, 80)", + .func = benchmark_bn_lshift_80, + }, + { + .desc = "BN_lshift(_, _, 127)", + .func = benchmark_bn_lshift_127, + }, + { + .desc = "BN_rshift1()", + .func = benchmark_bn_rshift1, + }, + { + .desc = "BN_rshift(_, _, 1)", + .func = benchmark_bn_rshift_1, + }, + { + .desc = "BN_rshift(_, _, 16)", + .func = benchmark_bn_rshift_16, + }, + { + .desc = "BN_rshift(_, _, 32)", + .func = benchmark_bn_rshift_32, + }, + { + .desc = "BN_rshift(_, _, 64)", + .func = benchmark_bn_rshift_64, + }, + { + .desc = "BN_rshift(_, _, 65)", + .func = benchmark_bn_rshift_65, + }, + { + .desc = "BN_rshift(_, _, 80)", + .func = benchmark_bn_rshift_80, + }, + { + .desc = "BN_rshift(_, _, 127)", + .func = benchmark_bn_rshift_127, + }, +}; + +#define N_BENCHMARKS (sizeof(benchmarks) / sizeof(benchmarks[0])) + +static volatile sig_atomic_t benchmark_stop; + +static void +benchmark_sig_alarm(int sig) +{ + benchmark_stop = 1; +} + +static void +benchmark_run(const struct benchmark *bm, int seconds) +{ + struct timespec start, end, duration; + BIGNUM *bn; + int i; + + signal(SIGALRM, benchmark_sig_alarm); + + if ((bn = BN_new()) == NULL) + errx(1, "BN_new"); + + benchmark_stop = 0; + i = 0; + alarm(seconds); + + clock_gettime(CLOCK_MONOTONIC, &start); + + fprintf(stderr, "Benchmarking %s for %ds: ", bm->desc, seconds); + while (!benchmark_stop) { + bm->func(bn); + i++; + } + clock_gettime(CLOCK_MONOTONIC, &end); + timespecsub(&end, &start, &duration); + fprintf(stderr, "%d iterations in %f seconds\n", i, + duration.tv_sec + duration.tv_nsec / 1000000000.0); + + BN_free(bn); +} + +#endif + +static void +benchmark_bn_shift(void) +{ +#if 0 + const struct benchmark *bm; + size_t i; + + for (i = 0; i < N_BENCHMARKS; i++) { + bm = &benchmarks[i]; + benchmark_run(bm, 5); + } +#else + return; +#endif +} + +int +main(int argc, char **argv) +{ + int benchmark = 0, failed = 0; + + if (argc == 2 && strcmp(argv[1], "--benchmark") == 0) + benchmark = 1; + + failed |= test_bn_shift1(); + failed |= test_bn_shift(); + failed |= test_bn_rshift_to_zero(); + + if (benchmark && !failed) + benchmark_bn_shift(); + + return failed; +} diff --git a/tests/bntest.c b/tests/bn_test.c similarity index 99% rename from tests/bntest.c rename to tests/bn_test.c index b9581a0c..ed61f86f 100644 --- a/tests/bntest.c +++ b/tests/bn_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bntest.c,v 1.25 2022/09/05 21:06:31 tb Exp $ */ +/* $OpenBSD: bn_test.c,v 1.2 2022/12/06 18:23:29 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -81,19 +81,9 @@ #include #include -#include #include -int BN_mod_exp_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); -int BN_mod_exp_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); -int BN_mod_exp_mont_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp_mont_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); - -int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom); +#include "bn_local.h" const int num0 = 100; /* number of tests */ const int num1 = 50; /* additional tests for some functions */ diff --git a/tests/bn_to_string.c b/tests/bn_to_string.c index 60b3ea31..8f990f0e 100644 --- a/tests/bn_to_string.c +++ b/tests/bn_to_string.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_to_string.c,v 1.1 2019/04/13 22:06:31 tb Exp $ */ +/* $OpenBSD: bn_to_string.c,v 1.3 2023/02/13 04:26:32 jsing Exp $ */ /* * Copyright (c) 2019 Theo Buehler * @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -30,7 +31,7 @@ struct convert_st { struct convert_st testcases[] = { {"0", "0"}, - {"-0", "-0"}, + {"-0", "0"}, {"7", "7"}, {"-7", "-7"}, {"8", "8"}, @@ -111,6 +112,5 @@ main(int argc, char *argv[]) BN_free(bn); - printf("%s\n", failed ? "FAILED" : "SUCCESS"); return failed; } diff --git a/tests/bn_unit.c b/tests/bn_unit.c new file mode 100644 index 00000000..6c5b2107 --- /dev/null +++ b/tests/bn_unit.c @@ -0,0 +1,104 @@ +/* $OpenBSD: bn_unit.c,v 1.3 2023/02/14 15:08:15 tb Exp $ */ + +/* + * Copyright (c) 2022 Theo Buehler + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + +#include + +static int +test_bn_print_wrapper(char *a, size_t size, const char *descr, + int (*to_bn)(BIGNUM **, const char *)) +{ + int ret; + + ret = to_bn(NULL, a); + if (ret != 0 && (ret < 0 || (size_t)ret != size - 1)) { + fprintf(stderr, "unexpected %s() return" + "want 0 or %zu, got %d\n", descr, size - 1, ret); + return 1; + } + + return 0; +} + +static int +test_bn_print_null_derefs(void) +{ + size_t size = INT_MAX / 4 + 4; + size_t datalimit = (size + 500 * 1024) / 1024; + char *a; + char digit; + int failed = 0; + + if ((a = malloc(size)) == NULL) { + warn("malloc(%zu) failed (make sure data limit is >= %zu KiB)", + size, datalimit); + return 0; + } + + /* Fill with a random digit since coverity doesn't like us using '0'. */ + digit = '0' + arc4random_uniform(10); + + memset(a, digit, size - 1); + a[size - 1] = '\0'; + + failed |= test_bn_print_wrapper(a, size, "BN_dec2bn", BN_dec2bn); + failed |= test_bn_print_wrapper(a, size, "BN_hex2bn", BN_hex2bn); + + free(a); + + return failed; +} + +static int +test_bn_num_bits_word(void) +{ + BN_ULONG w = 1; + int i, num_bits; + int failed = 0; + + if ((num_bits = BN_num_bits_word(0)) != 0) { + warnx("BN_num_bits_word(0): want 0, got %d", num_bits); + failed |= 1; + } + + for (i = 0; i < BN_BITS2; i++) { + if ((num_bits = BN_num_bits_word(w << i)) != i + 1) { + warnx("BN_num_bits_word(0x%llx): want %d, got %d", + (unsigned long long)(w << i), i + 1, num_bits); + failed |= 1; + } + } + + return failed; +} + +int +main(void) +{ + int failed = 0; + + failed |= test_bn_print_null_derefs(); + failed |= test_bn_num_bits_word(); + + return failed; +} diff --git a/tests/bn_word.c b/tests/bn_word.c new file mode 100644 index 00000000..0a543add --- /dev/null +++ b/tests/bn_word.c @@ -0,0 +1,617 @@ +/* $OpenBSD: bn_word.c,v 1.1 2023/03/11 14:04:21 jsing Exp $ */ +/* + * Copyright (c) 2023 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include + +struct bn_word_test { + const char *in_hex; + BN_ULONG in_word; + BN_ULONG mod_word; + BN_ULONG out_word; + const char *out_hex; + int out_is_negative; +}; + +static int +check_bn_word_test(const char *op_name, const BIGNUM *bn, + const struct bn_word_test *bwt) +{ + char *out_hex = NULL; + BN_ULONG out_word; + int failed = 1; + + if ((out_word = BN_get_word(bn)) != bwt->out_word) { + fprintf(stderr, "FAIL %s: Got word %lx, want %lx\n", + op_name, (unsigned long)out_word, + (unsigned long)bwt->out_word); + goto failure; + } + + if (BN_is_negative(bn) != bwt->out_is_negative) { + fprintf(stderr, "FAIL %s: Got is negative %d, want %d\n", + op_name, BN_is_negative(bn), bwt->out_is_negative); + goto failure; + } + + if ((out_hex = BN_bn2hex(bn)) == NULL) + errx(1, "BN_bn2hex() failed\n"); + + if (strcmp(out_hex, bwt->out_hex) != 0) { + fprintf(stderr, "FAIL %s: Got hex %s, want %s\n", + op_name, out_hex, bwt->out_hex); + goto failure; + } + + if (BN_is_zero(bn) && BN_is_negative(bn) != 0) { + fprintf(stderr, "FAIL %s: Got negative zero\n", op_name); + goto failure; + } + + failed = 0; + + failure: + free(out_hex); + + return failed; +} + +static int +test_bn_word(int (*bn_word_op)(BIGNUM *, BN_ULONG), const char *op_name, + const struct bn_word_test *bwts, size_t num_tests) +{ + const struct bn_word_test *bwt; + BIGNUM *bn; + size_t i; + int failed = 0; + + if ((bn = BN_new()) == NULL) + errx(1, "BN_new() failed\n"); + + for (i = 0; i < num_tests; i++) { + bwt = &bwts[i]; + + if (!BN_hex2bn(&bn, bwt->in_hex)) { + fprintf(stderr, "FAIL: BN_hex2bn(\"%s\") failed\n", + bwt->in_hex); + failed = 1; + continue; + } + + if (!bn_word_op(bn, bwt->in_word)) { + fprintf(stderr, "FAIL: %s(%lx) failed\n", op_name, + (unsigned long)bwt->in_word); + failed = 1; + continue; + } + + failed |= check_bn_word_test(op_name, bn, bwt); + } + + BN_free(bn); + + return failed; +} + +static const struct bn_word_test bn_add_word_tests[] = { + { + .in_hex = "1", + .in_word = 0, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "0", + .in_word = 1, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "1", + .in_word = 1, + .out_word = 2, + .out_hex = "02", + }, + { + .in_hex = "-1", + .in_word = 2, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "-1", + .in_word = 1, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "-3", + .in_word = 2, + .out_word = 1, + .out_hex = "-01", + .out_is_negative = 1, + }, + { + .in_hex = "1", + .in_word = 0xfffffffeUL, + .out_word = 0xffffffffUL, + .out_hex = "FFFFFFFF", + }, + { + .in_hex = "FFFFFFFFFFFFFFFF", + .in_word = 1, + .out_word = BN_MASK2, + .out_hex = "010000000000000000", + }, +}; + +#define N_BN_ADD_WORD_TESTS \ + (sizeof(bn_add_word_tests) / sizeof(bn_add_word_tests[0])) + +static int +test_bn_add_word(void) +{ + return test_bn_word(BN_add_word, "BN_add_word", bn_add_word_tests, + N_BN_ADD_WORD_TESTS); +} + +static const struct bn_word_test bn_sub_word_tests[] = { + { + .in_hex = "1", + .in_word = 0, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "0", + .in_word = 1, + .out_word = 1, + .out_hex = "-01", + .out_is_negative = 1, + }, + { + .in_hex = "1", + .in_word = 1, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "2", + .in_word = 1, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "-1", + .in_word = 2, + .out_word = 3, + .out_hex = "-03", + .out_is_negative = 1, + }, + { + .in_hex = "1", + .in_word = 1, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "3", + .in_word = 2, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "-3", + .in_word = 2, + .out_word = 5, + .out_hex = "-05", + .out_is_negative = 1, + }, + { + .in_hex = "-1", + .in_word = 0xfffffffeUL, + .out_word = 0xffffffffUL, + .out_hex = "-FFFFFFFF", + .out_is_negative = 1, + }, + { + .in_hex = "010000000000000000", + .in_word = 1, + .out_word = BN_MASK2, + .out_hex = "FFFFFFFFFFFFFFFF", + }, +}; + +#define N_BN_SUB_WORD_TESTS \ + (sizeof(bn_sub_word_tests) / sizeof(bn_sub_word_tests[0])) + +static int +test_bn_sub_word(void) +{ + return test_bn_word(BN_sub_word, "BN_sub_word", bn_sub_word_tests, + N_BN_SUB_WORD_TESTS); +} + +static const struct bn_word_test bn_mul_word_tests[] = { + { + .in_hex = "1", + .in_word = 0, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "0", + .in_word = 1, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "1", + .in_word = 1, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "-1", + .in_word = 0, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "-1", + .in_word = 1, + .out_word = 1, + .out_hex = "-01", + .out_is_negative = 1, + }, + { + .in_hex = "-3", + .in_word = 2, + .out_word = 6, + .out_hex = "-06", + .out_is_negative = 1, + }, + { + .in_hex = "1", + .in_word = 0xfffffffeUL, + .out_word = 0xfffffffeUL, + .out_hex = "FFFFFFFE", + }, + { + .in_hex = "010000000000000000", + .in_word = 2, + .out_word = BN_MASK2, + .out_hex = "020000000000000000", + }, +}; + +#define N_BN_MUL_WORD_TESTS \ + (sizeof(bn_mul_word_tests) / sizeof(bn_mul_word_tests[0])) + +static int +test_bn_mul_word(void) +{ + return test_bn_word(BN_mul_word, "BN_mul_word", bn_mul_word_tests, + N_BN_MUL_WORD_TESTS); +} + +static const struct bn_word_test bn_div_word_tests[] = { + { + .in_hex = "1", + .in_word = 0, + .mod_word = BN_MASK2, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "0", + .in_word = 1, + .mod_word = 0, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "4", + .in_word = 2, + .mod_word = 0, + .out_word = 2, + .out_hex = "02", + }, + { + .in_hex = "7", + .in_word = 3, + .mod_word = 1, + .out_word = 2, + .out_hex = "02", + }, + { + .in_hex = "1", + .in_word = 1, + .mod_word = 0, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "-2", + .in_word = 1, + .mod_word = 0, + .out_word = 2, + .out_hex = "-02", + .out_is_negative = 1, + }, + { + .in_hex = "-1", + .in_word = 2, + .mod_word = 1, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "-3", + .in_word = 2, + .mod_word = 1, + .out_word = 1, + .out_hex = "-01", + .out_is_negative = 1, + }, + { + .in_hex = "1", + .in_word = 0xffffffffUL, + .mod_word = 1, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "FFFFFFFF", + .in_word = 1, + .mod_word = 0, + .out_word = 0xffffffffUL, + .out_hex = "FFFFFFFF", + }, + { + .in_hex = "FFFFFFFE", + .in_word = 0xffffffffUL, + .mod_word = 0xfffffffeUL, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "FFFFFFFFFFFFFFFF", + .in_word = 1, + .mod_word = 0, + .out_word = BN_MASK2, + .out_hex = "FFFFFFFFFFFFFFFF", + }, + { + .in_hex = "FFFFFFFF", + .in_word = 0xff, + .mod_word = 0, + .out_word = 0x1010101UL, + .out_hex = "01010101", + }, + { + .in_hex = "FFFFFFFF", + .in_word = 0x10, + .mod_word = 0xf, + .out_word = 0xfffffffUL, + .out_hex = "0FFFFFFF", + }, +}; + +#define N_BN_DIV_WORD_TESTS \ + (sizeof(bn_div_word_tests) / sizeof(bn_div_word_tests[0])) + +static int +test_bn_div_word(void) +{ + const char *op_name = "BN_div_word"; + const struct bn_word_test *bwt; + BN_ULONG mod_word; + BIGNUM *bn; + size_t i; + int failed = 0; + + if ((bn = BN_new()) == NULL) + errx(1, "BN_new() failed\n"); + + for (i = 0; i < N_BN_DIV_WORD_TESTS; i++) { + bwt = &bn_div_word_tests[i]; + + if (!BN_hex2bn(&bn, bwt->in_hex)) { + fprintf(stderr, "FAIL: BN_hex2bn(\"%s\") failed\n", + bwt->in_hex); + failed = 1; + continue; + } + + if ((mod_word = BN_div_word(bn, bwt->in_word)) != bwt->mod_word) { + fprintf(stderr, "FAIL %s: Got mod word %lx, want %lx\n", + op_name, (unsigned long)mod_word, + (unsigned long)bwt->mod_word); + failed = 1; + continue; + } + + failed |= check_bn_word_test(op_name, bn, bwt); + } + + BN_free(bn); + + return failed; +} + +static const struct bn_word_test bn_mod_word_tests[] = { + { + .in_hex = "1", + .in_word = 0, + .mod_word = BN_MASK2, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "0", + .in_word = 1, + .mod_word = 0, + .out_word = 0, + .out_hex = "0", + }, + { + .in_hex = "4", + .in_word = 2, + .mod_word = 0, + .out_word = 4, + .out_hex = "04", + }, + { + .in_hex = "7", + .in_word = 3, + .mod_word = 1, + .out_word = 7, + .out_hex = "07", + }, + { + .in_hex = "1", + .in_word = 1, + .mod_word = 0, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "-2", + .in_word = 1, + .mod_word = 0, + .out_word = 2, + .out_hex = "-02", + .out_is_negative = 1, + }, + { + .in_hex = "-1", + .in_word = 2, + .mod_word = 1, + .out_word = 1, + .out_hex = "-01", + .out_is_negative = 1, + }, + { + .in_hex = "-3", + .in_word = 2, + .mod_word = 1, + .out_word = 3, + .out_hex = "-03", + .out_is_negative = 1, + }, + { + .in_hex = "1", + .in_word = 0xffffffffUL, + .mod_word = 1, + .out_word = 1, + .out_hex = "01", + }, + { + .in_hex = "FFFFFFFF", + .in_word = 1, + .mod_word = 0, + .out_word = 0xffffffffUL, + .out_hex = "FFFFFFFF", + }, + { + .in_hex = "FFFFFFFE", + .in_word = 0xffffffffUL, + .mod_word = 0xfffffffeUL, + .out_word = 0xfffffffeUL, + .out_hex = "FFFFFFFE", + }, + { + .in_hex = "FFFFFFFFFFFFFFFF", + .in_word = 1, + .mod_word = 0, + .out_word = BN_MASK2, + .out_hex = "FFFFFFFFFFFFFFFF", + }, + { + .in_hex = "FFFFFFFF", + .in_word = 0xff, + .mod_word = 0, + .out_word = 0xffffffff, + .out_hex = "FFFFFFFF", + }, + { + .in_hex = "FFFFFFFF", + .in_word = 0x10, + .mod_word = 0xf, + .out_word = 0xffffffffUL, + .out_hex = "FFFFFFFF", + }, +}; + +#define N_BN_MOD_WORD_TESTS \ + (sizeof(bn_mod_word_tests) / sizeof(bn_mod_word_tests[0])) + +static int +test_bn_mod_word(void) +{ + const char *op_name = "BN_mod_word"; + const struct bn_word_test *bwt; + BN_ULONG mod_word; + BIGNUM *bn; + size_t i; + int failed = 0; + + if ((bn = BN_new()) == NULL) + errx(1, "BN_new() failed\n"); + + for (i = 0; i < N_BN_MOD_WORD_TESTS; i++) { + bwt = &bn_mod_word_tests[i]; + + if (!BN_hex2bn(&bn, bwt->in_hex)) { + fprintf(stderr, "FAIL: BN_hex2bn(\"%s\") failed\n", + bwt->in_hex); + failed = 1; + continue; + } + + if ((mod_word = BN_mod_word(bn, bwt->in_word)) != bwt->mod_word) { + fprintf(stderr, "FAIL %s: Got mod word %lx, want %lx\n", + op_name, (unsigned long)mod_word, + (unsigned long)bwt->mod_word); + failed = 1; + continue; + } + + failed |= check_bn_word_test(op_name, bn, bwt); + } + + BN_free(bn); + + return failed; +} + +int +main(int argc, char **argv) +{ + int failed = 0; + + failed |= test_bn_add_word(); + failed |= test_bn_sub_word(); + failed |= test_bn_mul_word(); + failed |= test_bn_div_word(); + failed |= test_bn_mod_word(); + + return failed; +} diff --git a/tests/bytestringtest.c b/tests/bytestringtest.c index a0fcde0b..36f45c4b 100644 --- a/tests/bytestringtest.c +++ b/tests/bytestringtest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bytestringtest.c,v 1.16 2022/01/06 14:31:03 jsing Exp $ */ +/* $OpenBSD: bytestringtest.c,v 1.17 2023/01/01 17:43:04 miod Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -84,7 +84,7 @@ test_get_u(void) CHECK(CBS_get_u32(&data, &u32)); CHECK(u32 == 0x708090a); CHECK(CBS_get_u64(&data, &u64)); - CHECK(u64 == 0x0b0c0d0e0f101112U); + CHECK(u64 == 0x0b0c0d0e0f101112ULL); CHECK(CBS_get_last_u8(&data, &u8)); CHECK(u8 == 20); CHECK(CBS_get_last_u8(&data, &u8)); @@ -334,7 +334,7 @@ test_cbb_basic(void) CHECK_GOTO(CBB_add_u24(&cbb, 0x40506)); CHECK_GOTO(CBB_add_u32(&cbb, 0x708090a)); CHECK_GOTO(CBB_add_bytes(&cbb, (const uint8_t*) "\x0b\x0c", 2)); - CHECK_GOTO(CBB_add_u64(&cbb, 0xd0e0f1011121314)); + CHECK_GOTO(CBB_add_u64(&cbb, 0xd0e0f1011121314LL)); CHECK_GOTO(CBB_finish(&cbb, &buf, &buf_len)); ret = (buf_len == sizeof(kExpected) diff --git a/tests/cipher_list.c b/tests/cipher_list.c index 0623dd69..c715f60e 100644 --- a/tests/cipher_list.c +++ b/tests/cipher_list.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cipher_list.c,v 1.11 2022/07/07 13:11:45 tb Exp $ */ +/* $OpenBSD: cipher_list.c,v 1.14 2022/12/17 16:05:28 jsing Exp $ */ /* * Copyright (c) 2015 Doug Hogan * Copyright (c) 2015 Joel Sing @@ -39,7 +39,7 @@ #include #include -#include "ssl_locl.h" +#include "ssl_local.h" #include "tests.h" @@ -51,6 +51,12 @@ static uint8_t cipher_bytes[] = { 0x00, 0x3d, /* AES256-SHA256 */ }; +static uint8_t cipher_bytes_seclevel3[] = { + 0xcc, 0xa8, /* ECDHE-ECDSA-CHACHA20-POLY1305 */ + 0xcc, 0xa9, /* ECDHE-RSA-CHACHA20-POLY1305 */ + 0xcc, 0xaa, /* DHE-RSA-CHACHA20-POLY1305 */ +}; + static uint16_t cipher_values[] = { 0xcca8, /* ECDHE-ECDSA-CHACHA20-POLY1305 */ 0xcca9, /* ECDHE-RSA-CHACHA20-POLY1305 */ @@ -85,7 +91,8 @@ ssl_bytes_to_list_alloc(SSL *s, STACK_OF(SSL_CIPHER) **ciphers) } static int -ssl_list_to_bytes_scsv(SSL *s, STACK_OF(SSL_CIPHER) **ciphers) +ssl_list_to_bytes_scsv(SSL *s, STACK_OF(SSL_CIPHER) **ciphers, + const uint8_t *cb, size_t cb_len) { CBB cbb; unsigned char *buf = NULL; @@ -94,27 +101,31 @@ ssl_list_to_bytes_scsv(SSL *s, STACK_OF(SSL_CIPHER) **ciphers) /* Space for cipher bytes, plus reneg SCSV and two spare bytes. */ CHECK(sk_SSL_CIPHER_num(*ciphers) == N_CIPHERS); - buflen = sizeof(cipher_bytes) + 2 + 2; + buflen = cb_len + 2 + 2; CHECK((buf = calloc(1, buflen)) != NULL); - CHECK(CBB_init_fixed(&cbb, buf, buflen)); - CHECK(ssl_cipher_list_to_bytes(s, *ciphers, &cbb)); - CHECK(CBB_finish(&cbb, NULL, &outlen)); + /* Clear renegotiate so it adds SCSV */ + s->renegotiate = 0; + + CHECK_GOTO(CBB_init_fixed(&cbb, buf, buflen)); + CHECK_GOTO(ssl_cipher_list_to_bytes(s, *ciphers, &cbb)); + CHECK_GOTO(CBB_finish(&cbb, NULL, &outlen)); - CHECK_GOTO(outlen > 0 && outlen == buflen - 2); - CHECK_GOTO(memcmp(buf, cipher_bytes, sizeof(cipher_bytes)) == 0); + CHECK_GOTO(outlen > 0 && outlen == cb_len + 2); + CHECK_GOTO(memcmp(buf, cb, cb_len) == 0); CHECK_GOTO(buf[buflen - 4] == 0x00 && buf[buflen - 3] == 0xff); CHECK_GOTO(buf[buflen - 2] == 0x00 && buf[buflen - 1] == 0x00); ret = 1; -err: + err: free(buf); return ret; } static int -ssl_list_to_bytes_no_scsv(SSL *s, STACK_OF(SSL_CIPHER) **ciphers) +ssl_list_to_bytes_no_scsv(SSL *s, STACK_OF(SSL_CIPHER) **ciphers, + const uint8_t *cb, size_t cb_len) { CBB cbb; unsigned char *buf = NULL; @@ -123,25 +134,25 @@ ssl_list_to_bytes_no_scsv(SSL *s, STACK_OF(SSL_CIPHER) **ciphers) /* Space for cipher bytes and two spare bytes */ CHECK(sk_SSL_CIPHER_num(*ciphers) == N_CIPHERS); - buflen = sizeof(cipher_bytes) + 2; + buflen = cb_len + 2; CHECK((buf = calloc(1, buflen)) != NULL); buf[buflen - 2] = 0xfe; buf[buflen - 1] = 0xab; /* Set renegotiate so it doesn't add SCSV */ - s->internal->renegotiate = 1; + s->renegotiate = 1; - CHECK(CBB_init_fixed(&cbb, buf, buflen)); - CHECK(ssl_cipher_list_to_bytes(s, *ciphers, &cbb)); - CHECK(CBB_finish(&cbb, NULL, &outlen)); + CHECK_GOTO(CBB_init_fixed(&cbb, buf, buflen)); + CHECK_GOTO(ssl_cipher_list_to_bytes(s, *ciphers, &cbb)); + CHECK_GOTO(CBB_finish(&cbb, NULL, &outlen)); - CHECK_GOTO(outlen > 0 && outlen == buflen - 2); - CHECK_GOTO(memcmp(buf, cipher_bytes, sizeof(cipher_bytes)) == 0); + CHECK_GOTO(outlen > 0 && outlen == cb_len); + CHECK_GOTO(memcmp(buf, cb, cb_len) == 0); CHECK_GOTO(buf[buflen - 2] == 0xfe && buf[buflen - 1] == 0xab); ret = 1; -err: + err: free(buf); return ret; } @@ -184,20 +195,31 @@ main(void) if (!ssl_bytes_to_list_alloc(s, &ciphers)) goto err; - if (!ssl_list_to_bytes_scsv(s, &ciphers)) + if (!ssl_list_to_bytes_scsv(s, &ciphers, cipher_bytes, + sizeof(cipher_bytes))) goto err; - if (!ssl_list_to_bytes_no_scsv(s, &ciphers)) + if (!ssl_list_to_bytes_no_scsv(s, &ciphers, cipher_bytes, + sizeof(cipher_bytes))) goto err; if (!ssl_bytes_to_list_invalid(s, &ciphers)) goto err; + sk_SSL_CIPHER_free(ciphers); + ciphers = NULL; + SSL_set_security_level(s, 3); - if (ssl_list_to_bytes_scsv(s, &ciphers)) + if (!ssl_bytes_to_list_alloc(s, &ciphers)) + goto err; + if (!ssl_list_to_bytes_scsv(s, &ciphers, cipher_bytes_seclevel3, + sizeof(cipher_bytes_seclevel3))) + goto err; + if (!ssl_list_to_bytes_no_scsv(s, &ciphers, cipher_bytes_seclevel3, + sizeof(cipher_bytes_seclevel3))) goto err; rv = 0; -err: + err: sk_SSL_CIPHER_free(ciphers); SSL_CTX_free(ctx); SSL_free(s); diff --git a/tests/cmstest.c b/tests/cmstest.c index 4ff1e1ef..c207b9eb 100644 --- a/tests/cmstest.c +++ b/tests/cmstest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmstest.c,v 1.5 2022/06/22 09:56:45 tb Exp $ */ +/* $OpenBSD: cmstest.c,v 1.7 2023/03/02 21:08:14 tb Exp $ */ /* * Copyright (c) 2019 Joel Sing * @@ -29,7 +29,7 @@ static int verbose = 0; static const char cms_msg[] = "Hello CMS!\r\n"; -static const char cms_ca_1[] = \ +static const char cms_ca_1[] = "-----BEGIN CERTIFICATE-----\n" "MIICqDCCAZACCQD8ebR8e4kdvjANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDDAtU\n" "ZXN0IENNUyBDQTAeFw0xOTA1MTExNTUzNTNaFw0yOTA1MDgxNTUzNTNaMBYxFDAS\n" @@ -48,7 +48,7 @@ static const char cms_ca_1[] = \ "aaACIcEs48gnTRWc\n" "-----END CERTIFICATE-----\n"; -static const char cms_cert_1[] = \ +static const char cms_cert_1[] = "-----BEGIN CERTIFICATE-----\n" "MIICpDCCAYwCAQMwDQYJKoZIhvcNAQEFBQAwFjEUMBIGA1UEAwwLVGVzdCBDTVMg\n" "Q0EwHhcNMTkwNTExMTU1MzU0WhcNMjkwNTA4MTU1MzU0WjAaMRgwFgYDVQQDDA9U\n" @@ -67,7 +67,7 @@ static const char cms_cert_1[] = \ "6WWvmmz+rC0=\n" "-----END CERTIFICATE-----\n"; -static const char cms_key_1[] = \ +static const char cms_key_1[] = "-----BEGIN PRIVATE KEY-----\n" "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDDMLSuy+tc0Awf\n" "rlszgHJ3z7UEpJSn5mcKxquFnEC5DtchgQJ+cj5VFvB9A9G98ykQ0IrHXNUTbS2y\n" @@ -118,6 +118,7 @@ test_cms_encrypt_decrypt(void) BIO *bio_out = NULL; X509 *cert = NULL; size_t len; + long mem_len; char *p; int failed = 1; @@ -166,21 +167,26 @@ test_cms_encrypt_decrypt(void) goto failure; } - if ((len = BIO_get_mem_data(bio_mem, &p)) != strlen(cms_msg)) { - fprintf(stderr, "FAIL: CMS decrypt returned %zu bytes, " - "want %zu bytes\n", len, strlen(cms_msg)); + if ((mem_len = BIO_get_mem_data(bio_mem, &p)) <= 0) { + fprintf(stderr, "FAIL: BIO_get_mem_data returned %ld\n", + mem_len); + goto failure; + } + if ((len = strlen(cms_msg)) != (size_t)mem_len) { + fprintf(stderr, "FAIL: CMS decrypt returned %ld bytes, " + "want %zu bytes\n", mem_len, len); fprintf(stderr, "Got CMS data:\n"); - hexdump(p, len); + hexdump(p, mem_len); fprintf(stderr, "Want CMS data:\n"); - hexdump(cms_msg, strlen(cms_msg)); + hexdump(cms_msg, len); goto failure; } if (memcmp(p, cms_msg, len) != 0) { fprintf(stderr, "FAIL: CMS decrypt message differs"); fprintf(stderr, "Got CMS data:\n"); - hexdump(p, len); + hexdump(p, mem_len); fprintf(stderr, "Want CMS data:\n"); - hexdump(cms_msg, strlen(cms_msg)); + hexdump(cms_msg, len); goto failure; } @@ -209,6 +215,7 @@ test_cms_sign_verify(void) X509 *cert = NULL; X509 *ca = NULL; size_t len; + long mem_len; char *p; int failed = 1; @@ -267,21 +274,26 @@ test_cms_sign_verify(void) goto failure; } - if ((len = BIO_get_mem_data(bio_mem, &p)) != strlen(cms_msg)) { - fprintf(stderr, "FAIL: CMS verify returned %zu bytes, " - "want %zu bytes\n", len, strlen(cms_msg)); + if ((mem_len = BIO_get_mem_data(bio_mem, &p)) <= 0) { + fprintf(stderr, "FAIL: BIO_get_mem_data returned %ld\n", + mem_len); + goto failure; + } + if ((len = strlen(cms_msg)) != (size_t)mem_len) { + fprintf(stderr, "FAIL: CMS verify returned %ld bytes, " + "want %zu bytes\n", mem_len, len); fprintf(stderr, "Got CMS data:\n"); - hexdump(p, len); + hexdump(p, mem_len); fprintf(stderr, "Want CMS data:\n"); - hexdump(cms_msg, strlen(cms_msg)); + hexdump(cms_msg, len); goto failure; } if (memcmp(p, cms_msg, len) != 0) { fprintf(stderr, "FAIL: CMS verify message differs"); fprintf(stderr, "Got CMS data:\n"); - hexdump(p, len); + hexdump(p, mem_len); fprintf(stderr, "Want CMS data:\n"); - hexdump(cms_msg, strlen(cms_msg)); + hexdump(cms_msg, len); goto failure; } diff --git a/tests/constraints.c b/tests/constraints.c index d4867a36..8771367b 100644 --- a/tests/constraints.c +++ b/tests/constraints.c @@ -1,4 +1,4 @@ -/* $OpenBSD: constraints.c */ +/* $OpenBSD: constraints.c,v 1.15 2022/11/28 07:24:03 tb Exp $ */ /* * Copyright (c) 2020 Bob Beck * @@ -23,11 +23,10 @@ #include #include "x509_internal.h" - -#define FAIL(msg, ...) \ -do { \ - fprintf(stderr, "[%s:%d] FAIL: ", __FILE__, __LINE__); \ - fprintf(stderr, msg, ##__VA_ARGS__); \ +#define FAIL(msg, ...) \ +do { \ + fprintf(stderr, "[%s:%d] FAIL: ", __FILE__, __LINE__); \ + fprintf(stderr, msg, ##__VA_ARGS__); \ } while(0) unsigned char *valid_hostnames[] = { @@ -168,15 +167,16 @@ test_valid_hostnames(void) int i, failure = 0; for (i = 0; valid_hostnames[i] != NULL; i++) { - if (!x509_constraints_valid_host(valid_hostnames[i], - strlen(valid_hostnames[i]))) { + CBS cbs; + CBS_init(&cbs, valid_hostnames[i], strlen(valid_hostnames[i])); + if (!x509_constraints_valid_host(&cbs)) { FAIL("Valid hostname '%s' rejected\n", valid_hostnames[i]); failure = 1; goto done; } - if (!x509_constraints_valid_sandns(valid_hostnames[i], - strlen(valid_hostnames[i]))) { + CBS_init(&cbs, valid_hostnames[i], strlen(valid_hostnames[i])); + if (!x509_constraints_valid_sandns(&cbs)) { FAIL("Valid sandns '%s' rejected\n", valid_hostnames[i]); failure = 1; @@ -192,8 +192,10 @@ test_valid_sandns_names(void) { int i, failure = 0; for (i = 0; valid_sandns_names[i] != NULL; i++) { - if (!x509_constraints_valid_sandns(valid_sandns_names[i], - strlen(valid_sandns_names[i]))) { + CBS cbs; + CBS_init(&cbs, valid_sandns_names[i], + strlen(valid_sandns_names[i])); + if (!x509_constraints_valid_sandns(&cbs)) { FAIL("Valid dnsname '%s' rejected\n", valid_sandns_names[i]); failure = 1; @@ -209,8 +211,10 @@ test_valid_domain_constraints(void) { int i, failure = 0; for (i = 0; valid_domain_constraints[i] != NULL; i++) { - if (!x509_constraints_valid_domain_constraint(valid_domain_constraints[i], - strlen(valid_domain_constraints[i]))) { + CBS cbs; + CBS_init(&cbs, valid_domain_constraints[i], + strlen(valid_domain_constraints[i])); + if (!x509_constraints_valid_domain_constraint(&cbs)) { FAIL("Valid dnsname '%s' rejected\n", valid_domain_constraints[i]); failure = 1; @@ -227,8 +231,10 @@ test_valid_mbox_names(void) struct x509_constraints_name name = {0}; int i, failure = 0; for (i = 0; valid_mbox_names[i] != NULL; i++) { - if (!x509_constraints_parse_mailbox(valid_mbox_names[i], - strlen(valid_mbox_names[i]), &name)) { + CBS cbs; + CBS_init(&cbs, valid_mbox_names[i], + strlen(valid_mbox_names[i])); + if (!x509_constraints_parse_mailbox(&cbs, &name)) { FAIL("Valid mailbox name '%s' rejected\n", valid_mbox_names[i]); failure = 1; @@ -248,24 +254,26 @@ test_invalid_hostnames(void) { int i, failure = 0; char *nulhost = "www.openbsd.org\0"; + CBS cbs; for (i = 0; invalid_hostnames[i] != NULL; i++) { - if (x509_constraints_valid_host(invalid_hostnames[i], - strlen(invalid_hostnames[i]))) { + CBS_init(&cbs, invalid_hostnames[i], + strlen(invalid_hostnames[i])); + if (x509_constraints_valid_host(&cbs)) { FAIL("Invalid hostname '%s' accepted\n", invalid_hostnames[i]); failure = 1; goto done; } } - if (x509_constraints_valid_host(nulhost, - strlen(nulhost) + 1)) { + CBS_init(&cbs, nulhost, strlen(nulhost) + 1); + if (x509_constraints_valid_host(&cbs)) { FAIL("hostname with NUL byte accepted\n"); failure = 1; goto done; } - if (x509_constraints_valid_sandns(nulhost, - strlen(nulhost) + 1)) { + CBS_init(&cbs, nulhost, strlen(nulhost) + 1); + if (x509_constraints_valid_sandns(&cbs)) { FAIL("sandns with NUL byte accepted\n"); failure = 1; goto done; @@ -279,8 +287,10 @@ test_invalid_sandns_names(void) { int i, failure = 0; for (i = 0; invalid_sandns_names[i] != NULL; i++) { - if (x509_constraints_valid_sandns(invalid_sandns_names[i], - strlen(invalid_sandns_names[i]))) { + CBS cbs; + CBS_init(&cbs, invalid_sandns_names[i], + strlen(invalid_sandns_names[i])); + if (x509_constraints_valid_sandns(&cbs)) { FAIL("Valid dnsname '%s' rejected\n", invalid_sandns_names[i]); failure = 1; @@ -297,8 +307,10 @@ test_invalid_mbox_names(void) int i, failure = 0; struct x509_constraints_name name = {0}; for (i = 0; invalid_mbox_names[i] != NULL; i++) { - if (x509_constraints_parse_mailbox(invalid_mbox_names[i], - strlen(invalid_mbox_names[i]), &name)) { + CBS cbs; + CBS_init(&cbs, invalid_mbox_names[i], + strlen(invalid_mbox_names[i])); + if (x509_constraints_parse_mailbox(&cbs, &name)) { FAIL("invalid mailbox name '%s' accepted\n", invalid_mbox_names[i]); failure = 1; @@ -318,8 +330,10 @@ test_invalid_domain_constraints(void) { int i, failure = 0; for (i = 0; invalid_domain_constraints[i] != NULL; i++) { - if (x509_constraints_valid_domain_constraint(invalid_domain_constraints[i], - strlen(invalid_domain_constraints[i]))) { + CBS cbs; + CBS_init(&cbs, invalid_domain_constraints[i], + strlen(invalid_domain_constraints[i])); + if (x509_constraints_valid_domain_constraint(&cbs)) { FAIL("invalid dnsname '%s' accepted\n", invalid_domain_constraints[i]); failure = 1; @@ -333,12 +347,12 @@ test_invalid_domain_constraints(void) static int test_invalid_uri(void) { - int j, failure=0; + int j, failure = 0; char *hostpart = NULL; for (j = 0; invaliduri[j] != NULL; j++) { if (x509_constraints_uri_host(invaliduri[j], - strlen(invaliduri[j]), &hostpart) != 0) { + strlen(invaliduri[j]), &hostpart) != 0) { FAIL("invalid URI '%s' accepted\n", invaliduri[j]); failure = 1; @@ -355,8 +369,10 @@ test_invalid_uri(void) static int test_constraints1(void) { - char *c; size_t cl; - char *d; size_t dl; + char *c; + size_t cl; + char *d; + size_t dl; int failure = 0; int error = 0; int i, j; @@ -447,10 +463,12 @@ test_constraints1(void) } } for (j = 0; noauthority[j] != NULL; j++) { - error = 0; char *hostpart = NULL; + error = 0; if (!x509_constraints_uri_host(noauthority[j], - strlen(noauthority[j]), &hostpart)) { + strlen(noauthority[j]), NULL) || + !x509_constraints_uri_host(noauthority[j], + strlen(noauthority[j]), &hostpart)) { FAIL("name '%s' should parse as a URI", noauthority[j]); failure = 1; diff --git a/tests/dtlstest.c b/tests/dtlstest.c deleted file mode 100644 index 18df9952..00000000 --- a/tests/dtlstest.c +++ /dev/null @@ -1,1073 +0,0 @@ -/* $OpenBSD: dtlstest.c,v 1.15 2022/01/07 09:07:00 tb Exp $ */ -/* - * Copyright (c) 2020, 2021 Joel Sing - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include "bio_local.h" -#include "ssl_locl.h" - -const char *server_ca_file; -const char *server_cert_file; -const char *server_key_file; - -char dtls_cookie[32]; - -int debug = 0; - -void tls12_record_layer_set_initial_epoch(struct tls12_record_layer *rl, - uint16_t epoch); - -static void -hexdump(const unsigned char *buf, size_t len) -{ - size_t i; - - for (i = 1; i <= len; i++) - fprintf(stderr, " 0x%02hhx,%s", buf[i - 1], i % 8 ? "" : "\n"); - - if (len % 8) - fprintf(stderr, "\n"); -} - -#define BIO_C_DELAY_COUNT 1000 -#define BIO_C_DELAY_FLUSH 1001 -#define BIO_C_DELAY_PACKET 1002 -#define BIO_C_DROP_PACKET 1003 -#define BIO_C_DROP_RANDOM 1004 - -struct bio_packet_monkey_ctx { - unsigned int delay_count; - unsigned int delay_mask; - unsigned int drop_rand; - unsigned int drop_mask; - uint8_t *delayed_msg; - size_t delayed_msg_len; -}; - -static int -bio_packet_monkey_new(BIO *bio) -{ - struct bio_packet_monkey_ctx *ctx; - - if ((ctx = calloc(1, sizeof(*ctx))) == NULL) - return 0; - - bio->flags = 0; - bio->init = 1; - bio->num = 0; - bio->ptr = ctx; - - return 1; -} - -static int -bio_packet_monkey_free(BIO *bio) -{ - struct bio_packet_monkey_ctx *ctx; - - if (bio == NULL) - return 1; - - ctx = bio->ptr; - free(ctx->delayed_msg); - free(ctx); - - return 1; -} - -static int -bio_packet_monkey_delay_flush(BIO *bio) -{ - struct bio_packet_monkey_ctx *ctx = bio->ptr; - - if (ctx->delayed_msg == NULL) - return 1; - - if (debug) - fprintf(stderr, "DEBUG: flushing delayed packet...\n"); - if (debug > 1) - hexdump(ctx->delayed_msg, ctx->delayed_msg_len); - - BIO_write(bio->next_bio, ctx->delayed_msg, ctx->delayed_msg_len); - - free(ctx->delayed_msg); - ctx->delayed_msg = NULL; - - return BIO_ctrl(bio->next_bio, BIO_CTRL_FLUSH, 0, NULL); -} - -static long -bio_packet_monkey_ctrl(BIO *bio, int cmd, long num, void *ptr) -{ - struct bio_packet_monkey_ctx *ctx; - - ctx = bio->ptr; - - switch (cmd) { - case BIO_C_DELAY_COUNT: - if (num < 1 || num > 31) - return 0; - ctx->delay_count = num; - return 1; - - case BIO_C_DELAY_FLUSH: - return bio_packet_monkey_delay_flush(bio); - - case BIO_C_DELAY_PACKET: - if (num < 1 || num > 31) - return 0; - ctx->delay_mask |= 1 << ((unsigned int)num - 1); - return 1; - - case BIO_C_DROP_PACKET: - if (num < 1 || num > 31) - return 0; - ctx->drop_mask |= 1 << ((unsigned int)num - 1); - return 1; - - case BIO_C_DROP_RANDOM: - if (num < 0 || (size_t)num > UINT_MAX) - return 0; - ctx->drop_rand = (unsigned int)num; - return 1; - } - - if (bio->next_bio == NULL) - return 0; - - return BIO_ctrl(bio->next_bio, cmd, num, ptr); -} - -static int -bio_packet_monkey_read(BIO *bio, char *out, int out_len) -{ - struct bio_packet_monkey_ctx *ctx = bio->ptr; - int ret; - - if (ctx == NULL || bio->next_bio == NULL) - return 0; - - ret = BIO_read(bio->next_bio, out, out_len); - - if (ret > 0) { - if (debug) - fprintf(stderr, "DEBUG: read packet...\n"); - if (debug > 1) - hexdump(out, ret); - } - - BIO_clear_retry_flags(bio); - if (ret <= 0 && BIO_should_retry(bio->next_bio)) - BIO_set_retry_read(bio); - - return ret; -} - -static int -bio_packet_monkey_write(BIO *bio, const char *in, int in_len) -{ - struct bio_packet_monkey_ctx *ctx = bio->ptr; - const char *label = "writing"; - int delay = 0, drop = 0; - int ret; - - if (ctx == NULL || bio->next_bio == NULL) - return 0; - - if (ctx->delayed_msg != NULL && ctx->delay_count > 0) - ctx->delay_count--; - - if (ctx->delayed_msg != NULL && ctx->delay_count == 0) { - if (debug) - fprintf(stderr, "DEBUG: writing delayed packet...\n"); - if (debug > 1) - hexdump(ctx->delayed_msg, ctx->delayed_msg_len); - - ret = BIO_write(bio->next_bio, ctx->delayed_msg, - ctx->delayed_msg_len); - - BIO_clear_retry_flags(bio); - if (ret <= 0 && BIO_should_retry(bio->next_bio)) { - BIO_set_retry_write(bio); - return (ret); - } - - free(ctx->delayed_msg); - ctx->delayed_msg = NULL; - } - - if (ctx->delay_mask > 0) { - delay = ctx->delay_mask & 1; - ctx->delay_mask >>= 1; - } - if (ctx->drop_rand > 0) { - drop = arc4random_uniform(ctx->drop_rand) == 0; - } else if (ctx->drop_mask > 0) { - drop = ctx->drop_mask & 1; - ctx->drop_mask >>= 1; - } - - if (delay) - label = "delaying"; - if (drop) - label = "dropping"; - if (debug) - fprintf(stderr, "DEBUG: %s packet...\n", label); - if (debug > 1) - hexdump(in, in_len); - - if (drop) - return in_len; - - if (delay) { - if (ctx->delayed_msg != NULL) - return 0; - if ((ctx->delayed_msg = calloc(1, in_len)) == NULL) - return 0; - memcpy(ctx->delayed_msg, in, in_len); - ctx->delayed_msg_len = in_len; - return in_len; - } - - ret = BIO_write(bio->next_bio, in, in_len); - - BIO_clear_retry_flags(bio); - if (ret <= 0 && BIO_should_retry(bio->next_bio)) - BIO_set_retry_write(bio); - - return ret; -} - -static int -bio_packet_monkey_puts(BIO *bio, const char *str) -{ - return bio_packet_monkey_write(bio, str, strlen(str)); -} - -static const BIO_METHOD bio_packet_monkey = { - .type = BIO_TYPE_BUFFER, - .name = "packet monkey", - .bread = bio_packet_monkey_read, - .bwrite = bio_packet_monkey_write, - .bputs = bio_packet_monkey_puts, - .ctrl = bio_packet_monkey_ctrl, - .create = bio_packet_monkey_new, - .destroy = bio_packet_monkey_free -}; - -static const BIO_METHOD * -BIO_f_packet_monkey(void) -{ - return &bio_packet_monkey; -} - -static BIO * -BIO_new_packet_monkey(void) -{ - return BIO_new(BIO_f_packet_monkey()); -} - -static int -BIO_packet_monkey_delay(BIO *bio, int num, int count) -{ - if (!BIO_ctrl(bio, BIO_C_DELAY_COUNT, count, NULL)) - return 0; - - return BIO_ctrl(bio, BIO_C_DELAY_PACKET, num, NULL); -} - -static int -BIO_packet_monkey_delay_flush(BIO *bio) -{ - return BIO_ctrl(bio, BIO_C_DELAY_FLUSH, 0, NULL); -} - -static int -BIO_packet_monkey_drop(BIO *bio, int num) -{ - return BIO_ctrl(bio, BIO_C_DROP_PACKET, num, NULL); -} - -#if 0 -static int -BIO_packet_monkey_drop_random(BIO *bio, int num) -{ - return BIO_ctrl(bio, BIO_C_DROP_RANDOM, num, NULL); -} -#endif - -static int -datagram_pair(int *client_sock, int *server_sock, - struct sockaddr_in *server_sin) -{ - struct sockaddr_in sin; - socklen_t sock_len; - int cs = -1, ss = -1; - - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_port = 0; - sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - if ((ss = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) - err(1, "server socket"); - if (bind(ss, (struct sockaddr *)&sin, sizeof(sin)) == -1) - err(1, "server bind"); - sock_len = sizeof(sin); - if (getsockname(ss, (struct sockaddr *)&sin, &sock_len) == -1) - err(1, "server getsockname"); - - if ((cs = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) - err(1, "client socket"); - if (connect(cs, (struct sockaddr *)&sin, sizeof(sin)) == -1) - err(1, "client connect"); - - *client_sock = cs; - *server_sock = ss; - memcpy(server_sin, &sin, sizeof(sin)); - - return 1; -} - -static int -poll_timeout(SSL *client, SSL *server) -{ - int client_timeout = 0, server_timeout = 0; - struct timeval timeout; - - if (DTLSv1_get_timeout(client, &timeout)) - client_timeout = timeout.tv_sec * 1000 + timeout.tv_usec / 1000; - - if (DTLSv1_get_timeout(server, &timeout)) - server_timeout = timeout.tv_sec * 1000 + timeout.tv_usec / 1000; - - if (client_timeout <= 0) - return server_timeout; - if (client_timeout > 0 && server_timeout <= 0) - return client_timeout; - if (client_timeout < server_timeout) - return client_timeout; - - return server_timeout; -} - -static int -dtls_cookie_generate(SSL *ssl, unsigned char *cookie, - unsigned int *cookie_len) -{ - arc4random_buf(dtls_cookie, sizeof(dtls_cookie)); - memcpy(cookie, dtls_cookie, sizeof(dtls_cookie)); - *cookie_len = sizeof(dtls_cookie); - - return 1; -} - -static int -dtls_cookie_verify(SSL *ssl, const unsigned char *cookie, - unsigned int cookie_len) -{ - return cookie_len == sizeof(dtls_cookie) && - memcmp(cookie, dtls_cookie, sizeof(dtls_cookie)) == 0; -} - -static void -dtls_info_callback(const SSL *ssl, int type, int val) -{ - /* - * Squeals ahead... remove the bbio from the info callback, so we can - * drop specific messages. Ideally this would be an option for the SSL. - */ - if (ssl->wbio == ssl->bbio) - ((SSL *)ssl)->wbio = BIO_pop(ssl->wbio); -} - -static SSL * -dtls_client(int sock, struct sockaddr_in *server_sin, long mtu) -{ - SSL_CTX *ssl_ctx = NULL; - SSL *ssl = NULL; - BIO *bio = NULL; - - if ((bio = BIO_new_dgram(sock, BIO_NOCLOSE)) == NULL) - errx(1, "client bio"); - if (!BIO_socket_nbio(sock, 1)) - errx(1, "client nbio"); - if (!BIO_ctrl_set_connected(bio, 1, server_sin)) - errx(1, "client set connected"); - - if ((ssl_ctx = SSL_CTX_new(DTLS_method())) == NULL) - errx(1, "client context"); - - if ((ssl = SSL_new(ssl_ctx)) == NULL) - errx(1, "client ssl"); - - SSL_set_bio(ssl, bio, bio); - bio = NULL; - - if (mtu > 0) { - SSL_set_options(ssl, SSL_OP_NO_QUERY_MTU); - SSL_set_mtu(ssl, mtu); - } - - SSL_CTX_free(ssl_ctx); - BIO_free(bio); - - return ssl; -} - -static SSL * -dtls_server(int sock, long options, long mtu) -{ - SSL_CTX *ssl_ctx = NULL; - SSL *ssl = NULL; - BIO *bio = NULL; - - if ((bio = BIO_new_dgram(sock, BIO_NOCLOSE)) == NULL) - errx(1, "server bio"); - if (!BIO_socket_nbio(sock, 1)) - errx(1, "server nbio"); - - if ((ssl_ctx = SSL_CTX_new(DTLS_method())) == NULL) - errx(1, "server context"); - - SSL_CTX_set_cookie_generate_cb(ssl_ctx, dtls_cookie_generate); - SSL_CTX_set_cookie_verify_cb(ssl_ctx, dtls_cookie_verify); - SSL_CTX_set_dh_auto(ssl_ctx, 2); - SSL_CTX_set_options(ssl_ctx, options); - - if (SSL_CTX_use_certificate_chain_file(ssl_ctx, server_cert_file) != 1) { - fprintf(stderr, "FAIL: Failed to load server certificate"); - goto failure; - } - if (SSL_CTX_use_PrivateKey_file(ssl_ctx, server_key_file, - SSL_FILETYPE_PEM) != 1) { - fprintf(stderr, "FAIL: Failed to load server private key"); - goto failure; - } - - if ((ssl = SSL_new(ssl_ctx)) == NULL) - errx(1, "server ssl"); - - if (SSL_use_certificate_chain_file(ssl, server_cert_file) != 1) { - fprintf(stderr, "FAIL: Failed to load server certificate"); - goto failure; - } - SSL_set_bio(ssl, bio, bio); - bio = NULL; - - if (mtu > 0) { - SSL_set_options(ssl, SSL_OP_NO_QUERY_MTU); - SSL_set_mtu(ssl, mtu); - } - - failure: - SSL_CTX_free(ssl_ctx); - BIO_free(bio); - - return ssl; -} - -static int -ssl_error(SSL *ssl, const char *name, const char *desc, int ssl_ret, - short *events) -{ - int ssl_err; - - ssl_err = SSL_get_error(ssl, ssl_ret); - - if (ssl_err == SSL_ERROR_WANT_READ) { - *events = POLLIN; - } else if (ssl_err == SSL_ERROR_WANT_WRITE) { - *events = POLLOUT; - } else if (ssl_err == SSL_ERROR_SYSCALL && errno == 0) { - /* Yup, this is apparently a thing... */ - } else { - fprintf(stderr, "FAIL: %s %s failed - ssl err = %d, errno = %d\n", - name, desc, ssl_err, errno); - ERR_print_errors_fp(stderr); - return 0; - } - - return 1; -} - -static int -do_connect(SSL *ssl, const char *name, int *done, short *events) -{ - int ssl_ret; - - if ((ssl_ret = SSL_connect(ssl)) != 1) - return ssl_error(ssl, name, "connect", ssl_ret, events); - - fprintf(stderr, "INFO: %s connect done\n", name); - *done = 1; - - return 1; -} - -static int -do_connect_read(SSL *ssl, const char *name, int *done, short *events) -{ - uint8_t buf[2048]; - int ssl_ret; - int i; - - if ((ssl_ret = SSL_connect(ssl)) != 1) - return ssl_error(ssl, name, "connect", ssl_ret, events); - - fprintf(stderr, "INFO: %s connect done\n", name); - *done = 1; - - for (i = 0; i < 3; i++) { - fprintf(stderr, "INFO: %s reading after connect\n", name); - if ((ssl_ret = SSL_read(ssl, buf, sizeof(buf))) != 3) { - fprintf(stderr, "ERROR: %s read failed\n", name); - return 0; - } - } - - return 1; -} - -static int -do_connect_shutdown(SSL *ssl, const char *name, int *done, short *events) -{ - uint8_t buf[2048]; - int ssl_ret; - - if ((ssl_ret = SSL_connect(ssl)) != 1) - return ssl_error(ssl, name, "connect", ssl_ret, events); - - fprintf(stderr, "INFO: %s connect done\n", name); - *done = 1; - - ssl_ret = SSL_read(ssl, buf, sizeof(buf)); - if (SSL_get_error(ssl, ssl_ret) != SSL_ERROR_ZERO_RETURN) { - fprintf(stderr, "FAIL: %s did not receive close-notify\n", name); - return 0; - } - - fprintf(stderr, "INFO: %s received close-notify\n", name); - - return 1; -} - -static int -do_accept(SSL *ssl, const char *name, int *done, short *events) -{ - int ssl_ret; - - if ((ssl_ret = SSL_accept(ssl)) != 1) - return ssl_error(ssl, name, "accept", ssl_ret, events); - - fprintf(stderr, "INFO: %s accept done\n", name); - *done = 1; - - return 1; -} - -static int -do_accept_write(SSL *ssl, const char *name, int *done, short *events) -{ - int ssl_ret; - BIO *bio; - int i; - - if ((ssl_ret = SSL_accept(ssl)) != 1) - return ssl_error(ssl, name, "accept", ssl_ret, events); - - fprintf(stderr, "INFO: %s accept done\n", name); - - for (i = 0; i < 3; i++) { - fprintf(stderr, "INFO: %s writing after accept\n", name); - if ((ssl_ret = SSL_write(ssl, "abc", 3)) != 3) { - fprintf(stderr, "ERROR: %s write failed\n", name); - return 0; - } - } - - if ((bio = SSL_get_wbio(ssl)) == NULL) - errx(1, "SSL has NULL bio"); - - /* Flush any delayed packets. */ - BIO_packet_monkey_delay_flush(bio); - - *done = 1; - return 1; -} - -static int -do_accept_shutdown(SSL *ssl, const char *name, int *done, short *events) -{ - int ssl_ret; - BIO *bio; - - if ((ssl_ret = SSL_accept(ssl)) != 1) - return ssl_error(ssl, name, "accept", ssl_ret, events); - - fprintf(stderr, "INFO: %s accept done\n", name); - - SSL_shutdown(ssl); - - if ((bio = SSL_get_wbio(ssl)) == NULL) - errx(1, "SSL has NULL bio"); - - /* Flush any delayed packets. */ - BIO_packet_monkey_delay_flush(bio); - - *done = 1; - return 1; -} - -static int -do_read(SSL *ssl, const char *name, int *done, short *events) -{ - uint8_t buf[512]; - int ssl_ret; - - if ((ssl_ret = SSL_read(ssl, buf, sizeof(buf))) > 0) { - fprintf(stderr, "INFO: %s read done\n", name); - if (debug > 1) - hexdump(buf, ssl_ret); - *done = 1; - return 1; - } - - return ssl_error(ssl, name, "read", ssl_ret, events); -} - -static int -do_write(SSL *ssl, const char *name, int *done, short *events) -{ - const uint8_t buf[] = "Hello, World!\n"; - int ssl_ret; - - if ((ssl_ret = SSL_write(ssl, buf, sizeof(buf))) > 0) { - fprintf(stderr, "INFO: %s write done\n", name); - *done = 1; - return 1; - } - - return ssl_error(ssl, name, "write", ssl_ret, events); -} - -static int -do_shutdown(SSL *ssl, const char *name, int *done, short *events) -{ - int ssl_ret; - - ssl_ret = SSL_shutdown(ssl); - if (ssl_ret == 1) { - fprintf(stderr, "INFO: %s shutdown done\n", name); - *done = 1; - return 1; - } - return ssl_error(ssl, name, "shutdown", ssl_ret, events); -} - -typedef int (ssl_func)(SSL *ssl, const char *name, int *done, short *events); - -static int -do_client_server_loop(SSL *client, ssl_func *client_func, SSL *server, - ssl_func *server_func, struct pollfd pfd[2]) -{ - int client_done = 0, server_done = 0; - int i = 0; - - pfd[0].revents = POLLIN; - pfd[1].revents = POLLIN; - - do { - if (!client_done) { - if (debug) - fprintf(stderr, "DEBUG: client loop\n"); - if (DTLSv1_handle_timeout(client) > 0) - fprintf(stderr, "INFO: client timeout\n"); - if (!client_func(client, "client", &client_done, - &pfd[0].events)) - return 0; - if (client_done) - pfd[0].events = 0; - } - if (!server_done) { - if (debug) - fprintf(stderr, "DEBUG: server loop\n"); - if (DTLSv1_handle_timeout(server) > 0) - fprintf(stderr, "INFO: server timeout\n"); - if (!server_func(server, "server", &server_done, - &pfd[1].events)) - return 0; - if (server_done) - pfd[1].events = 0; - } - if (poll(pfd, 2, poll_timeout(client, server)) == -1) - err(1, "poll"); - - } while (i++ < 100 && (!client_done || !server_done)); - - if (!client_done || !server_done) - fprintf(stderr, "FAIL: gave up\n"); - - return client_done && server_done; -} - -#define MAX_PACKET_DELAYS 32 -#define MAX_PACKET_DROPS 32 - -struct dtls_delay { - uint8_t packet; - uint8_t count; -}; - -struct dtls_test { - const unsigned char *desc; - long mtu; - long ssl_options; - int client_bbio_off; - int server_bbio_off; - uint16_t initial_epoch; - int write_after_accept; - int shutdown_after_accept; - struct dtls_delay client_delays[MAX_PACKET_DELAYS]; - struct dtls_delay server_delays[MAX_PACKET_DELAYS]; - uint8_t client_drops[MAX_PACKET_DROPS]; - uint8_t server_drops[MAX_PACKET_DROPS]; -}; - -static const struct dtls_test dtls_tests[] = { - { - .desc = "DTLS without cookies", - .ssl_options = 0, - }, - { - .desc = "DTLS without cookies (initial epoch 0xfffe)", - .ssl_options = 0, - .initial_epoch = 0xfffe, - }, - { - .desc = "DTLS without cookies (initial epoch 0xffff)", - .ssl_options = 0, - .initial_epoch = 0xffff, - }, - { - .desc = "DTLS with cookies", - .ssl_options = SSL_OP_COOKIE_EXCHANGE, - }, - { - .desc = "DTLS with low MTU", - .mtu = 256, - .ssl_options = 0, - }, - { - .desc = "DTLS with low MTU and cookies", - .mtu = 256, - .ssl_options = SSL_OP_COOKIE_EXCHANGE, - }, - { - .desc = "DTLS with dropped server response", - .ssl_options = 0, - .server_drops = { 1 }, - }, - { - .desc = "DTLS with two dropped server responses", - .ssl_options = 0, - .server_drops = { 1, 2 }, - }, - { - .desc = "DTLS with dropped ServerHello", - .ssl_options = SSL_OP_NO_TICKET, - .server_bbio_off = 1, - .server_drops = { 1 }, - }, - { - .desc = "DTLS with dropped server Certificate", - .ssl_options = SSL_OP_NO_TICKET, - .server_bbio_off = 1, - .server_drops = { 2 }, - }, - { - .desc = "DTLS with dropped ServerKeyExchange", - .ssl_options = SSL_OP_NO_TICKET, - .server_bbio_off = 1, - .server_drops = { 3 }, - }, - { - .desc = "DTLS with dropped ServerHelloDone", - .ssl_options = SSL_OP_NO_TICKET, - .server_bbio_off = 1, - .server_drops = { 4 }, - }, -#if 0 - /* - * These two result in the server accept completing and the - * client looping on a timeout. Presumably the server should not - * complete until the client Finished is received... this due to - * a flaw in the DTLSv1.0 specification, which is addressed in - * DTLSv1.2 (see references to "last flight" in RFC 6347 section - * 4.2.4). Our DTLS server code still needs to support this. - */ - { - .desc = "DTLS with dropped server CCS", - .ssl_options = 0, - .server_bbio_off = 1, - .server_drops = { 5 }, - }, - { - .desc = "DTLS with dropped server Finished", - .ssl_options = 0, - .server_bbio_off = 1, - .server_drops = { 6 }, - }, -#endif - { - .desc = "DTLS with dropped ClientKeyExchange", - .ssl_options = 0, - .client_bbio_off = 1, - .client_drops = { 2 }, - }, - { - .desc = "DTLS with dropped client CCS", - .ssl_options = 0, - .client_bbio_off = 1, - .client_drops = { 3 }, - }, - { - .desc = "DTLS with dropped client Finished", - .ssl_options = 0, - .client_bbio_off = 1, - .client_drops = { 4 }, - }, - { - /* Send CCS after client Finished. */ - .desc = "DTLS with delayed client CCS", - .ssl_options = 0, - .client_bbio_off = 1, - .client_delays = { { 3, 2 } }, - }, - { - /* - * Send CCS after server Finished - note app data will be - * dropped if we send the CCS after app data. - */ - .desc = "DTLS with delayed server CCS", - .ssl_options = SSL_OP_NO_TICKET, - .server_bbio_off = 1, - .server_delays = { { 5, 2 } }, - .write_after_accept = 1, - }, - { - .desc = "DTLS with delayed server CCS (initial epoch 0xfffe)", - .ssl_options = SSL_OP_NO_TICKET, - .server_bbio_off = 1, - .initial_epoch = 0xfffe, - .server_delays = { { 5, 2 } }, - .write_after_accept = 1, - }, - { - .desc = "DTLS with delayed server CCS (initial epoch 0xffff)", - .ssl_options = SSL_OP_NO_TICKET, - .server_bbio_off = 1, - .initial_epoch = 0xffff, - .server_delays = { { 5, 2 } }, - .write_after_accept = 1, - }, - { - /* Send Finished after app data - this is currently buffered. */ - .desc = "DTLS with delayed server Finished", - .ssl_options = SSL_OP_NO_TICKET, - .server_bbio_off = 1, - .server_delays = { { 6, 3 } }, - .write_after_accept = 1, - }, - { - /* Send CCS after server finished and close-notify. */ - .desc = "DTLS with delayed server CCS (close-notify)", - .ssl_options = SSL_OP_NO_TICKET, - .server_bbio_off = 1, - .server_delays = { { 5, 3 } }, - .shutdown_after_accept = 1, - }, -}; - -#define N_DTLS_TESTS (sizeof(dtls_tests) / sizeof(*dtls_tests)) - -static void -dtlstest_packet_monkey(SSL *ssl, const struct dtls_delay delays[], - const uint8_t drops[]) -{ - BIO *bio_monkey; - BIO *bio; - int i; - - if ((bio_monkey = BIO_new_packet_monkey()) == NULL) - errx(1, "packet monkey"); - - for (i = 0; i < MAX_PACKET_DELAYS; i++) { - if (delays[i].packet == 0) - break; - if (!BIO_packet_monkey_delay(bio_monkey, delays[i].packet, - delays[i].count)) - errx(1, "delay failure"); - } - - for (i = 0; i < MAX_PACKET_DROPS; i++) { - if (drops[i] == 0) - break; - if (!BIO_packet_monkey_drop(bio_monkey, drops[i])) - errx(1, "drop failure"); - } - - if ((bio = SSL_get_wbio(ssl)) == NULL) - errx(1, "SSL has NULL bio"); - - BIO_up_ref(bio); - bio = BIO_push(bio_monkey, bio); - - SSL_set_bio(ssl, bio, bio); -} - -static int -dtlstest(const struct dtls_test *dt) -{ - SSL *client = NULL, *server = NULL; - ssl_func *connect_func, *accept_func; - struct sockaddr_in server_sin; - struct pollfd pfd[2]; - int client_sock = -1; - int server_sock = -1; - int failed = 1; - - fprintf(stderr, "\n== Testing %s... ==\n", dt->desc); - - if (!datagram_pair(&client_sock, &server_sock, &server_sin)) - goto failure; - - if ((client = dtls_client(client_sock, &server_sin, dt->mtu)) == NULL) - goto failure; - - if ((server = dtls_server(server_sock, dt->ssl_options, dt->mtu)) == NULL) - goto failure; - - tls12_record_layer_set_initial_epoch(client->internal->rl, - dt->initial_epoch); - tls12_record_layer_set_initial_epoch(server->internal->rl, - dt->initial_epoch); - - if (dt->client_bbio_off) - SSL_set_info_callback(client, dtls_info_callback); - if (dt->server_bbio_off) - SSL_set_info_callback(server, dtls_info_callback); - - dtlstest_packet_monkey(client, dt->client_delays, dt->client_drops); - dtlstest_packet_monkey(server, dt->server_delays, dt->server_drops); - - pfd[0].fd = client_sock; - pfd[0].events = POLLOUT; - pfd[1].fd = server_sock; - pfd[1].events = POLLIN; - - accept_func = do_accept; - connect_func = do_connect; - - if (dt->write_after_accept) { - accept_func = do_accept_write; - connect_func = do_connect_read; - } else if (dt->shutdown_after_accept) { - accept_func = do_accept_shutdown; - connect_func = do_connect_shutdown; - } - - if (!do_client_server_loop(client, connect_func, server, accept_func, pfd)) { - fprintf(stderr, "FAIL: client and server handshake failed\n"); - goto failure; - } - - if (dt->write_after_accept || dt->shutdown_after_accept) - goto done; - - pfd[0].events = POLLIN; - pfd[1].events = POLLOUT; - - if (!do_client_server_loop(client, do_read, server, do_write, pfd)) { - fprintf(stderr, "FAIL: client read and server write I/O failed\n"); - goto failure; - } - - pfd[0].events = POLLOUT; - pfd[1].events = POLLIN; - - if (!do_client_server_loop(client, do_write, server, do_read, pfd)) { - fprintf(stderr, "FAIL: client write and server read I/O failed\n"); - goto failure; - } - - pfd[0].events = POLLOUT; - pfd[1].events = POLLOUT; - - if (!do_client_server_loop(client, do_shutdown, server, do_shutdown, pfd)) { - fprintf(stderr, "FAIL: client and server shutdown failed\n"); - goto failure; - } - - done: - fprintf(stderr, "INFO: Done!\n"); - - failed = 0; - - failure: - if (client_sock != -1) - close(client_sock); - if (server_sock != -1) - close(server_sock); - - SSL_free(client); - SSL_free(server); - - return failed; -} - -int -main(int argc, char **argv) -{ - int failed = 0; - size_t i; - - if (argc != 4) { - fprintf(stderr, "usage: %s keyfile certfile cafile\n", - argv[0]); - exit(1); - } - - server_key_file = argv[1]; - server_cert_file = argv[2]; - server_ca_file = argv[3]; - - for (i = 0; i < N_DTLS_TESTS; i++) - failed |= dtlstest(&dtls_tests[i]); - - return failed; -} diff --git a/tests/dtlstest.sh b/tests/dtlstest.sh deleted file mode 100644 index ef18cfcb..00000000 --- a/tests/dtlstest.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -set -e - -dtlstest_bin=./dtlstest -if [ -e ./dtlstest.exe ]; then - dtlstest_bin=./dtlstest.exe -fi - -if [ -z $srcdir ]; then - srcdir=. -fi - -$dtlstest_bin $srcdir/server.pem $srcdir/server.pem $srcdir/ca.pem diff --git a/tests/ec_point_conversion.c b/tests/ec_point_conversion.c index 8327ac43..04177a0e 100644 --- a/tests/ec_point_conversion.c +++ b/tests/ec_point_conversion.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_point_conversion.c,v 1.6 2021/12/29 22:48:09 tb Exp $ */ +/* $OpenBSD: ec_point_conversion.c,v 1.7 2022/12/01 13:49:12 tb Exp $ */ /* * Copyright (c) 2021 Theo Buehler * Copyright (c) 2021 Joel Sing @@ -134,7 +134,7 @@ test_hybrid_corner_case(void) for (i = 0; i < N_FORMS; i++) failed |= roundtrip(group, point, forms[i], x, y); - fprintf(stderr, "%s: %s\n", __func__, failed ? "FAILED" : "SUCCESS"); + fprintf(stderr, "%s %s\n", __func__, failed ? ": FAILED" : ""); EC_GROUP_free(group); EC_POINT_free(point); @@ -229,7 +229,7 @@ test_random_points(void) for (curve_id = 0; curve_id < ncurves; curve_id++) failed |= test_random_points_on_curve(&all_curves[curve_id]); - fprintf(stderr, "%s: %s\n", __func__, failed ? "FAILED" : "SUCCESS"); + fprintf(stderr, "%s %s\n", __func__, failed ? ": FAILED" : ""); free(all_curves); return failed; @@ -869,7 +869,7 @@ test_point_conversions(void) for (i = 0; i < N_POINT_CONVERSIONS; i++) failed |= point_conversion_form_y_bit(&point_conversions[i]); - fprintf(stderr, "%s: %s\n", __func__, failed ? "FAILED" : "SUCCESS"); + fprintf(stderr, "%s %s\n", __func__, failed ? ": FAILED" : ""); return failed; } @@ -883,7 +883,5 @@ main(int argc, char **argv) failed |= test_hybrid_corner_case(); failed |= test_point_conversions(); - fprintf(stderr, "%s\n", failed ? "FAILED" : "SUCCESS"); - return failed; } diff --git a/tests/ecdhtest.c b/tests/ecdhtest.c index b3470cec..bf68a88e 100644 --- a/tests/ecdhtest.c +++ b/tests/ecdhtest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecdhtest.c,v 1.12 2021/12/29 22:58:40 tb Exp $ */ +/* $OpenBSD: ecdhtest.c,v 1.13 2023/03/08 16:51:42 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -312,7 +312,7 @@ mk_eckey(int nid, const unsigned char *p, size_t plen) goto err; ok = 1; err: - BN_clear_free(priv); + BN_free(priv); EC_POINT_free(pub); if (!ok) { EC_KEY_free(k); diff --git a/tests/ed25519test.c b/tests/ed25519test.c new file mode 100644 index 00000000..78ed85c0 --- /dev/null +++ b/tests/ed25519test.c @@ -0,0 +1,474 @@ +/* $OpenBSD: ed25519test.c,v 1.10 2022/12/01 13:55:22 tb Exp $ */ +/* + * Copyright (c) 2019, 2022 Theo Buehler + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +#include + +struct testvector { + const uint8_t sec_key[ED25519_PRIVATE_KEY_LENGTH]; + const uint8_t pub_key[ED25519_PUBLIC_KEY_LENGTH]; + const uint8_t signature[ED25519_SIGNATURE_LENGTH]; + const uint8_t message[1024]; + size_t message_len; +}; + +/* + * Test vectors from https://tools.ietf.org/html/rfc8032#section-7.1. + */ +static const struct testvector testvectors[] = { + { + .sec_key = { + 0x9d, 0x61, 0xb1, 0x9d, 0xef, 0xfd, 0x5a, 0x60, + 0xba, 0x84, 0x4a, 0xf4, 0x92, 0xec, 0x2c, 0xc4, + 0x44, 0x49, 0xc5, 0x69, 0x7b, 0x32, 0x69, 0x19, + 0x70, 0x3b, 0xac, 0x03, 0x1c, 0xae, 0x7f, 0x60, + }, + .pub_key = { + 0xd7, 0x5a, 0x98, 0x01, 0x82, 0xb1, 0x0a, 0xb7, + 0xd5, 0x4b, 0xfe, 0xd3, 0xc9, 0x64, 0x07, 0x3a, + 0x0e, 0xe1, 0x72, 0xf3, 0xda, 0xa6, 0x23, 0x25, + 0xaf, 0x02, 0x1a, 0x68, 0xf7, 0x07, 0x51, 0x1a, + }, + .message = { + 0x0, /* Windows has stupid compilers... */ + }, + .message_len = 0, + .signature = { + 0xe5, 0x56, 0x43, 0x00, 0xc3, 0x60, 0xac, 0x72, + 0x90, 0x86, 0xe2, 0xcc, 0x80, 0x6e, 0x82, 0x8a, + 0x84, 0x87, 0x7f, 0x1e, 0xb8, 0xe5, 0xd9, 0x74, + 0xd8, 0x73, 0xe0, 0x65, 0x22, 0x49, 0x01, 0x55, + 0x5f, 0xb8, 0x82, 0x15, 0x90, 0xa3, 0x3b, 0xac, + 0xc6, 0x1e, 0x39, 0x70, 0x1c, 0xf9, 0xb4, 0x6b, + 0xd2, 0x5b, 0xf5, 0xf0, 0x59, 0x5b, 0xbe, 0x24, + 0x65, 0x51, 0x41, 0x43, 0x8e, 0x7a, 0x10, 0x0b, + }, + }, + { + .sec_key = { + 0x4c, 0xcd, 0x08, 0x9b, 0x28, 0xff, 0x96, 0xda, + 0x9d, 0xb6, 0xc3, 0x46, 0xec, 0x11, 0x4e, 0x0f, + 0x5b, 0x8a, 0x31, 0x9f, 0x35, 0xab, 0xa6, 0x24, + 0xda, 0x8c, 0xf6, 0xed, 0x4f, 0xb8, 0xa6, 0xfb, + }, + .pub_key = { + 0x3d, 0x40, 0x17, 0xc3, 0xe8, 0x43, 0x89, 0x5a, + 0x92, 0xb7, 0x0a, 0xa7, 0x4d, 0x1b, 0x7e, 0xbc, + 0x9c, 0x98, 0x2c, 0xcf, 0x2e, 0xc4, 0x96, 0x8c, + 0xc0, 0xcd, 0x55, 0xf1, 0x2a, 0xf4, 0x66, 0x0c, + }, + .message = { + 0x72, + }, + .message_len = 1, + .signature = { + 0x92, 0xa0, 0x09, 0xa9, 0xf0, 0xd4, 0xca, 0xb8, + 0x72, 0x0e, 0x82, 0x0b, 0x5f, 0x64, 0x25, 0x40, + 0xa2, 0xb2, 0x7b, 0x54, 0x16, 0x50, 0x3f, 0x8f, + 0xb3, 0x76, 0x22, 0x23, 0xeb, 0xdb, 0x69, 0xda, + 0x08, 0x5a, 0xc1, 0xe4, 0x3e, 0x15, 0x99, 0x6e, + 0x45, 0x8f, 0x36, 0x13, 0xd0, 0xf1, 0x1d, 0x8c, + 0x38, 0x7b, 0x2e, 0xae, 0xb4, 0x30, 0x2a, 0xee, + 0xb0, 0x0d, 0x29, 0x16, 0x12, 0xbb, 0x0c, 0x00, + }, + }, + { + .sec_key = { + 0xc5, 0xaa, 0x8d, 0xf4, 0x3f, 0x9f, 0x83, 0x7b, + 0xed, 0xb7, 0x44, 0x2f, 0x31, 0xdc, 0xb7, 0xb1, + 0x66, 0xd3, 0x85, 0x35, 0x07, 0x6f, 0x09, 0x4b, + 0x85, 0xce, 0x3a, 0x2e, 0x0b, 0x44, 0x58, 0xf7, + }, + .pub_key = { + 0xfc, 0x51, 0xcd, 0x8e, 0x62, 0x18, 0xa1, 0xa3, + 0x8d, 0xa4, 0x7e, 0xd0, 0x02, 0x30, 0xf0, 0x58, + 0x08, 0x16, 0xed, 0x13, 0xba, 0x33, 0x03, 0xac, + 0x5d, 0xeb, 0x91, 0x15, 0x48, 0x90, 0x80, 0x25, + }, + .message = { + 0xaf, 0x82, + }, + .message_len = 2, + .signature = { + 0x62, 0x91, 0xd6, 0x57, 0xde, 0xec, 0x24, 0x02, + 0x48, 0x27, 0xe6, 0x9c, 0x3a, 0xbe, 0x01, 0xa3, + 0x0c, 0xe5, 0x48, 0xa2, 0x84, 0x74, 0x3a, 0x44, + 0x5e, 0x36, 0x80, 0xd7, 0xdb, 0x5a, 0xc3, 0xac, + 0x18, 0xff, 0x9b, 0x53, 0x8d, 0x16, 0xf2, 0x90, + 0xae, 0x67, 0xf7, 0x60, 0x98, 0x4d, 0xc6, 0x59, + 0x4a, 0x7c, 0x15, 0xe9, 0x71, 0x6e, 0xd2, 0x8d, + 0xc0, 0x27, 0xbe, 0xce, 0xea, 0x1e, 0xc4, 0x0a, + }, + }, + { + .sec_key = { + 0xf5, 0xe5, 0x76, 0x7c, 0xf1, 0x53, 0x31, 0x95, + 0x17, 0x63, 0x0f, 0x22, 0x68, 0x76, 0xb8, 0x6c, + 0x81, 0x60, 0xcc, 0x58, 0x3b, 0xc0, 0x13, 0x74, + 0x4c, 0x6b, 0xf2, 0x55, 0xf5, 0xcc, 0x0e, 0xe5, + }, + .pub_key = { + 0x27, 0x81, 0x17, 0xfc, 0x14, 0x4c, 0x72, 0x34, + 0x0f, 0x67, 0xd0, 0xf2, 0x31, 0x6e, 0x83, 0x86, + 0xce, 0xff, 0xbf, 0x2b, 0x24, 0x28, 0xc9, 0xc5, + 0x1f, 0xef, 0x7c, 0x59, 0x7f, 0x1d, 0x42, 0x6e, + }, + .message = { + 0x08, 0xb8, 0xb2, 0xb7, 0x33, 0x42, 0x42, 0x43, + 0x76, 0x0f, 0xe4, 0x26, 0xa4, 0xb5, 0x49, 0x08, + 0x63, 0x21, 0x10, 0xa6, 0x6c, 0x2f, 0x65, 0x91, + 0xea, 0xbd, 0x33, 0x45, 0xe3, 0xe4, 0xeb, 0x98, + 0xfa, 0x6e, 0x26, 0x4b, 0xf0, 0x9e, 0xfe, 0x12, + 0xee, 0x50, 0xf8, 0xf5, 0x4e, 0x9f, 0x77, 0xb1, + 0xe3, 0x55, 0xf6, 0xc5, 0x05, 0x44, 0xe2, 0x3f, + 0xb1, 0x43, 0x3d, 0xdf, 0x73, 0xbe, 0x84, 0xd8, + 0x79, 0xde, 0x7c, 0x00, 0x46, 0xdc, 0x49, 0x96, + 0xd9, 0xe7, 0x73, 0xf4, 0xbc, 0x9e, 0xfe, 0x57, + 0x38, 0x82, 0x9a, 0xdb, 0x26, 0xc8, 0x1b, 0x37, + 0xc9, 0x3a, 0x1b, 0x27, 0x0b, 0x20, 0x32, 0x9d, + 0x65, 0x86, 0x75, 0xfc, 0x6e, 0xa5, 0x34, 0xe0, + 0x81, 0x0a, 0x44, 0x32, 0x82, 0x6b, 0xf5, 0x8c, + 0x94, 0x1e, 0xfb, 0x65, 0xd5, 0x7a, 0x33, 0x8b, + 0xbd, 0x2e, 0x26, 0x64, 0x0f, 0x89, 0xff, 0xbc, + 0x1a, 0x85, 0x8e, 0xfc, 0xb8, 0x55, 0x0e, 0xe3, + 0xa5, 0xe1, 0x99, 0x8b, 0xd1, 0x77, 0xe9, 0x3a, + 0x73, 0x63, 0xc3, 0x44, 0xfe, 0x6b, 0x19, 0x9e, + 0xe5, 0xd0, 0x2e, 0x82, 0xd5, 0x22, 0xc4, 0xfe, + 0xba, 0x15, 0x45, 0x2f, 0x80, 0x28, 0x8a, 0x82, + 0x1a, 0x57, 0x91, 0x16, 0xec, 0x6d, 0xad, 0x2b, + 0x3b, 0x31, 0x0d, 0xa9, 0x03, 0x40, 0x1a, 0xa6, + 0x21, 0x00, 0xab, 0x5d, 0x1a, 0x36, 0x55, 0x3e, + 0x06, 0x20, 0x3b, 0x33, 0x89, 0x0c, 0xc9, 0xb8, + 0x32, 0xf7, 0x9e, 0xf8, 0x05, 0x60, 0xcc, 0xb9, + 0xa3, 0x9c, 0xe7, 0x67, 0x96, 0x7e, 0xd6, 0x28, + 0xc6, 0xad, 0x57, 0x3c, 0xb1, 0x16, 0xdb, 0xef, + 0xef, 0xd7, 0x54, 0x99, 0xda, 0x96, 0xbd, 0x68, + 0xa8, 0xa9, 0x7b, 0x92, 0x8a, 0x8b, 0xbc, 0x10, + 0x3b, 0x66, 0x21, 0xfc, 0xde, 0x2b, 0xec, 0xa1, + 0x23, 0x1d, 0x20, 0x6b, 0xe6, 0xcd, 0x9e, 0xc7, + 0xaf, 0xf6, 0xf6, 0xc9, 0x4f, 0xcd, 0x72, 0x04, + 0xed, 0x34, 0x55, 0xc6, 0x8c, 0x83, 0xf4, 0xa4, + 0x1d, 0xa4, 0xaf, 0x2b, 0x74, 0xef, 0x5c, 0x53, + 0xf1, 0xd8, 0xac, 0x70, 0xbd, 0xcb, 0x7e, 0xd1, + 0x85, 0xce, 0x81, 0xbd, 0x84, 0x35, 0x9d, 0x44, + 0x25, 0x4d, 0x95, 0x62, 0x9e, 0x98, 0x55, 0xa9, + 0x4a, 0x7c, 0x19, 0x58, 0xd1, 0xf8, 0xad, 0xa5, + 0xd0, 0x53, 0x2e, 0xd8, 0xa5, 0xaa, 0x3f, 0xb2, + 0xd1, 0x7b, 0xa7, 0x0e, 0xb6, 0x24, 0x8e, 0x59, + 0x4e, 0x1a, 0x22, 0x97, 0xac, 0xbb, 0xb3, 0x9d, + 0x50, 0x2f, 0x1a, 0x8c, 0x6e, 0xb6, 0xf1, 0xce, + 0x22, 0xb3, 0xde, 0x1a, 0x1f, 0x40, 0xcc, 0x24, + 0x55, 0x41, 0x19, 0xa8, 0x31, 0xa9, 0xaa, 0xd6, + 0x07, 0x9c, 0xad, 0x88, 0x42, 0x5d, 0xe6, 0xbd, + 0xe1, 0xa9, 0x18, 0x7e, 0xbb, 0x60, 0x92, 0xcf, + 0x67, 0xbf, 0x2b, 0x13, 0xfd, 0x65, 0xf2, 0x70, + 0x88, 0xd7, 0x8b, 0x7e, 0x88, 0x3c, 0x87, 0x59, + 0xd2, 0xc4, 0xf5, 0xc6, 0x5a, 0xdb, 0x75, 0x53, + 0x87, 0x8a, 0xd5, 0x75, 0xf9, 0xfa, 0xd8, 0x78, + 0xe8, 0x0a, 0x0c, 0x9b, 0xa6, 0x3b, 0xcb, 0xcc, + 0x27, 0x32, 0xe6, 0x94, 0x85, 0xbb, 0xc9, 0xc9, + 0x0b, 0xfb, 0xd6, 0x24, 0x81, 0xd9, 0x08, 0x9b, + 0xec, 0xcf, 0x80, 0xcf, 0xe2, 0xdf, 0x16, 0xa2, + 0xcf, 0x65, 0xbd, 0x92, 0xdd, 0x59, 0x7b, 0x07, + 0x07, 0xe0, 0x91, 0x7a, 0xf4, 0x8b, 0xbb, 0x75, + 0xfe, 0xd4, 0x13, 0xd2, 0x38, 0xf5, 0x55, 0x5a, + 0x7a, 0x56, 0x9d, 0x80, 0xc3, 0x41, 0x4a, 0x8d, + 0x08, 0x59, 0xdc, 0x65, 0xa4, 0x61, 0x28, 0xba, + 0xb2, 0x7a, 0xf8, 0x7a, 0x71, 0x31, 0x4f, 0x31, + 0x8c, 0x78, 0x2b, 0x23, 0xeb, 0xfe, 0x80, 0x8b, + 0x82, 0xb0, 0xce, 0x26, 0x40, 0x1d, 0x2e, 0x22, + 0xf0, 0x4d, 0x83, 0xd1, 0x25, 0x5d, 0xc5, 0x1a, + 0xdd, 0xd3, 0xb7, 0x5a, 0x2b, 0x1a, 0xe0, 0x78, + 0x45, 0x04, 0xdf, 0x54, 0x3a, 0xf8, 0x96, 0x9b, + 0xe3, 0xea, 0x70, 0x82, 0xff, 0x7f, 0xc9, 0x88, + 0x8c, 0x14, 0x4d, 0xa2, 0xaf, 0x58, 0x42, 0x9e, + 0xc9, 0x60, 0x31, 0xdb, 0xca, 0xd3, 0xda, 0xd9, + 0xaf, 0x0d, 0xcb, 0xaa, 0xaf, 0x26, 0x8c, 0xb8, + 0xfc, 0xff, 0xea, 0xd9, 0x4f, 0x3c, 0x7c, 0xa4, + 0x95, 0xe0, 0x56, 0xa9, 0xb4, 0x7a, 0xcd, 0xb7, + 0x51, 0xfb, 0x73, 0xe6, 0x66, 0xc6, 0xc6, 0x55, + 0xad, 0xe8, 0x29, 0x72, 0x97, 0xd0, 0x7a, 0xd1, + 0xba, 0x5e, 0x43, 0xf1, 0xbc, 0xa3, 0x23, 0x01, + 0x65, 0x13, 0x39, 0xe2, 0x29, 0x04, 0xcc, 0x8c, + 0x42, 0xf5, 0x8c, 0x30, 0xc0, 0x4a, 0xaf, 0xdb, + 0x03, 0x8d, 0xda, 0x08, 0x47, 0xdd, 0x98, 0x8d, + 0xcd, 0xa6, 0xf3, 0xbf, 0xd1, 0x5c, 0x4b, 0x4c, + 0x45, 0x25, 0x00, 0x4a, 0xa0, 0x6e, 0xef, 0xf8, + 0xca, 0x61, 0x78, 0x3a, 0xac, 0xec, 0x57, 0xfb, + 0x3d, 0x1f, 0x92, 0xb0, 0xfe, 0x2f, 0xd1, 0xa8, + 0x5f, 0x67, 0x24, 0x51, 0x7b, 0x65, 0xe6, 0x14, + 0xad, 0x68, 0x08, 0xd6, 0xf6, 0xee, 0x34, 0xdf, + 0xf7, 0x31, 0x0f, 0xdc, 0x82, 0xae, 0xbf, 0xd9, + 0x04, 0xb0, 0x1e, 0x1d, 0xc5, 0x4b, 0x29, 0x27, + 0x09, 0x4b, 0x2d, 0xb6, 0x8d, 0x6f, 0x90, 0x3b, + 0x68, 0x40, 0x1a, 0xde, 0xbf, 0x5a, 0x7e, 0x08, + 0xd7, 0x8f, 0xf4, 0xef, 0x5d, 0x63, 0x65, 0x3a, + 0x65, 0x04, 0x0c, 0xf9, 0xbf, 0xd4, 0xac, 0xa7, + 0x98, 0x4a, 0x74, 0xd3, 0x71, 0x45, 0x98, 0x67, + 0x80, 0xfc, 0x0b, 0x16, 0xac, 0x45, 0x16, 0x49, + 0xde, 0x61, 0x88, 0xa7, 0xdb, 0xdf, 0x19, 0x1f, + 0x64, 0xb5, 0xfc, 0x5e, 0x2a, 0xb4, 0x7b, 0x57, + 0xf7, 0xf7, 0x27, 0x6c, 0xd4, 0x19, 0xc1, 0x7a, + 0x3c, 0xa8, 0xe1, 0xb9, 0x39, 0xae, 0x49, 0xe4, + 0x88, 0xac, 0xba, 0x6b, 0x96, 0x56, 0x10, 0xb5, + 0x48, 0x01, 0x09, 0xc8, 0xb1, 0x7b, 0x80, 0xe1, + 0xb7, 0xb7, 0x50, 0xdf, 0xc7, 0x59, 0x8d, 0x5d, + 0x50, 0x11, 0xfd, 0x2d, 0xcc, 0x56, 0x00, 0xa3, + 0x2e, 0xf5, 0xb5, 0x2a, 0x1e, 0xcc, 0x82, 0x0e, + 0x30, 0x8a, 0xa3, 0x42, 0x72, 0x1a, 0xac, 0x09, + 0x43, 0xbf, 0x66, 0x86, 0xb6, 0x4b, 0x25, 0x79, + 0x37, 0x65, 0x04, 0xcc, 0xc4, 0x93, 0xd9, 0x7e, + 0x6a, 0xed, 0x3f, 0xb0, 0xf9, 0xcd, 0x71, 0xa4, + 0x3d, 0xd4, 0x97, 0xf0, 0x1f, 0x17, 0xc0, 0xe2, + 0xcb, 0x37, 0x97, 0xaa, 0x2a, 0x2f, 0x25, 0x66, + 0x56, 0x16, 0x8e, 0x6c, 0x49, 0x6a, 0xfc, 0x5f, + 0xb9, 0x32, 0x46, 0xf6, 0xb1, 0x11, 0x63, 0x98, + 0xa3, 0x46, 0xf1, 0xa6, 0x41, 0xf3, 0xb0, 0x41, + 0xe9, 0x89, 0xf7, 0x91, 0x4f, 0x90, 0xcc, 0x2c, + 0x7f, 0xff, 0x35, 0x78, 0x76, 0xe5, 0x06, 0xb5, + 0x0d, 0x33, 0x4b, 0xa7, 0x7c, 0x22, 0x5b, 0xc3, + 0x07, 0xba, 0x53, 0x71, 0x52, 0xf3, 0xf1, 0x61, + 0x0e, 0x4e, 0xaf, 0xe5, 0x95, 0xf6, 0xd9, 0xd9, + 0x0d, 0x11, 0xfa, 0xa9, 0x33, 0xa1, 0x5e, 0xf1, + 0x36, 0x95, 0x46, 0x86, 0x8a, 0x7f, 0x3a, 0x45, + 0xa9, 0x67, 0x68, 0xd4, 0x0f, 0xd9, 0xd0, 0x34, + 0x12, 0xc0, 0x91, 0xc6, 0x31, 0x5c, 0xf4, 0xfd, + 0xe7, 0xcb, 0x68, 0x60, 0x69, 0x37, 0x38, 0x0d, + 0xb2, 0xea, 0xaa, 0x70, 0x7b, 0x4c, 0x41, 0x85, + 0xc3, 0x2e, 0xdd, 0xcd, 0xd3, 0x06, 0x70, 0x5e, + 0x4d, 0xc1, 0xff, 0xc8, 0x72, 0xee, 0xee, 0x47, + 0x5a, 0x64, 0xdf, 0xac, 0x86, 0xab, 0xa4, 0x1c, + 0x06, 0x18, 0x98, 0x3f, 0x87, 0x41, 0xc5, 0xef, + 0x68, 0xd3, 0xa1, 0x01, 0xe8, 0xa3, 0xb8, 0xca, + 0xc6, 0x0c, 0x90, 0x5c, 0x15, 0xfc, 0x91, 0x08, + 0x40, 0xb9, 0x4c, 0x00, 0xa0, 0xb9, 0xd0, + }, + .message_len = 1023, + .signature = { + 0x0a, 0xab, 0x4c, 0x90, 0x05, 0x01, 0xb3, 0xe2, + 0x4d, 0x7c, 0xdf, 0x46, 0x63, 0x32, 0x6a, 0x3a, + 0x87, 0xdf, 0x5e, 0x48, 0x43, 0xb2, 0xcb, 0xdb, + 0x67, 0xcb, 0xf6, 0xe4, 0x60, 0xfe, 0xc3, 0x50, + 0xaa, 0x53, 0x71, 0xb1, 0x50, 0x8f, 0x9f, 0x45, + 0x28, 0xec, 0xea, 0x23, 0xc4, 0x36, 0xd9, 0x4b, + 0x5e, 0x8f, 0xcd, 0x4f, 0x68, 0x1e, 0x30, 0xa6, + 0xac, 0x00, 0xa9, 0x70, 0x4a, 0x18, 0x8a, 0x03, + }, + }, + { + .sec_key = { + 0x83, 0x3f, 0xe6, 0x24, 0x09, 0x23, 0x7b, 0x9d, + 0x62, 0xec, 0x77, 0x58, 0x75, 0x20, 0x91, 0x1e, + 0x9a, 0x75, 0x9c, 0xec, 0x1d, 0x19, 0x75, 0x5b, + 0x7d, 0xa9, 0x01, 0xb9, 0x6d, 0xca, 0x3d, 0x42, + }, + .pub_key = { + 0xec, 0x17, 0x2b, 0x93, 0xad, 0x5e, 0x56, 0x3b, + 0xf4, 0x93, 0x2c, 0x70, 0xe1, 0x24, 0x50, 0x34, + 0xc3, 0x54, 0x67, 0xef, 0x2e, 0xfd, 0x4d, 0x64, + 0xeb, 0xf8, 0x19, 0x68, 0x34, 0x67, 0xe2, 0xbf, + }, + .message = { + 0xdd, 0xaf, 0x35, 0xa1, 0x93, 0x61, 0x7a, 0xba, + 0xcc, 0x41, 0x73, 0x49, 0xae, 0x20, 0x41, 0x31, + 0x12, 0xe6, 0xfa, 0x4e, 0x89, 0xa9, 0x7e, 0xa2, + 0x0a, 0x9e, 0xee, 0xe6, 0x4b, 0x55, 0xd3, 0x9a, + 0x21, 0x92, 0x99, 0x2a, 0x27, 0x4f, 0xc1, 0xa8, + 0x36, 0xba, 0x3c, 0x23, 0xa3, 0xfe, 0xeb, 0xbd, + 0x45, 0x4d, 0x44, 0x23, 0x64, 0x3c, 0xe8, 0x0e, + 0x2a, 0x9a, 0xc9, 0x4f, 0xa5, 0x4c, 0xa4, 0x9f, + }, + .message_len = 64, + .signature = { + 0xdc, 0x2a, 0x44, 0x59, 0xe7, 0x36, 0x96, 0x33, + 0xa5, 0x2b, 0x1b, 0xf2, 0x77, 0x83, 0x9a, 0x00, + 0x20, 0x10, 0x09, 0xa3, 0xef, 0xbf, 0x3e, 0xcb, + 0x69, 0xbe, 0xa2, 0x18, 0x6c, 0x26, 0xb5, 0x89, + 0x09, 0x35, 0x1f, 0xc9, 0xac, 0x90, 0xb3, 0xec, + 0xfd, 0xfb, 0xc7, 0xc6, 0x64, 0x31, 0xe0, 0x30, + 0x3d, 0xca, 0x17, 0x9c, 0x13, 0x8a, 0xc1, 0x7a, + 0xd9, 0xbe, 0xf1, 0x17, 0x73, 0x31, 0xa7, 0x04, + }, + }, +}; + +const size_t num_testvectors = sizeof(testvectors) / sizeof(testvectors[0]); + +static int +test_ED25519_verify(void) +{ + size_t i; + int failed = 0; + + for (i = 0; i < num_testvectors; i++) { + const struct testvector *tc = &testvectors[i]; + + if (!ED25519_verify(tc->message, tc->message_len, tc->signature, + tc->pub_key)) { + warnx("failed verification in test case %zu", i); + failed = 1; + } + } + + return failed; +} + +static int +test_ED25519_sign(void) +{ + size_t i; + int failed = 0; + + for (i = 0; i < num_testvectors; i++) { + const struct testvector *tc = &testvectors[i]; + uint8_t signature[64]; + + if (!ED25519_sign(signature, tc->message, tc->message_len, + tc->pub_key, tc->sec_key)) { + warnx("failed signature in test case %zu", i); + failed = 1; + } + + if (memcmp(tc->signature, signature, sizeof signature) != 0) { + warnx("signature mismatch in test case %zu", i); + failed = 1; + } + } + + return failed; +} + +static void +hexdump(const unsigned char *buf, size_t len) +{ + size_t i; + + for (i = 1; i <= len; i++) + fprintf(stderr, " 0x%02hhx,%s", buf[i - 1], i % 8 ? "" : "\n"); + + if (len % 8) + fprintf(stderr, "\n"); +} + +static void +dump_info(const uint8_t *message, size_t message_len, const uint8_t *public_key, + const uint8_t *private_key, const uint8_t *signature) +{ + + fprintf(stderr, "message:\n"); + hexdump(message, message_len); + + fprintf(stderr, "public key:\n"); + hexdump(public_key, ED25519_PUBLIC_KEY_LENGTH); + fprintf(stderr, "private key:\n"); + hexdump(private_key, ED25519_PRIVATE_KEY_LENGTH); + + if (signature != NULL) { + fprintf(stderr, "signature:\n"); + hexdump(signature, ED25519_SIGNATURE_LENGTH); + } +} + +/* + * Little-endian representation of the order of edwards25519, + * see https://www.rfc-editor.org/rfc/rfc7748#section-4.1 + */ +static const uint8_t order[] = { + 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, + 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, +}; + +/* + * Modify signature by adding the group order to the upper half of the + * signature. This is caught by the check added in curve25519.c r1.14. + */ +static void +modify_signature(uint8_t *signature) +{ + uint16_t sum; + uint8_t *upper_half = &signature[32]; + uint16_t carry = 0; + size_t i; + + for (i = 0; i < sizeof(order); i++) { + sum = carry + order[i] + upper_half[i]; + carry = (sum > 0xff); + upper_half[i] = sum & 0xff; + } + + /* carry == 0 since 0 <= upper_half < order and 2 * order < 2^256. */ +} + +static int +test_ED25519_signature_malleability(void) +{ + uint8_t public_key[ED25519_PUBLIC_KEY_LENGTH]; + uint8_t private_key[ED25519_PRIVATE_KEY_LENGTH]; + uint8_t message[32]; + uint8_t signature[ED25519_SIGNATURE_LENGTH]; + int failed = 1; + + ED25519_keypair(public_key, private_key); + arc4random_buf(message, sizeof(message)); + + if (!ED25519_sign(signature, message, sizeof(message), + public_key, private_key)) { + fprintf(stderr, "Failed to sign random message\n"); + dump_info(message, sizeof(message), public_key, private_key, + NULL); + goto err; + } + + if (!ED25519_verify(message, sizeof(message), signature, public_key)) { + fprintf(stderr, "Failed to verify random message\n"); + dump_info(message, sizeof(message), public_key, private_key, + signature); + goto err; + } + + modify_signature(signature); + + if (ED25519_verify(message, sizeof(message), signature, public_key)) { + fprintf(stderr, "Verified with modified signature\n"); + dump_info(message, sizeof(message), public_key, private_key, + signature); + goto err; + } + + failed = 0; + + err: + return failed; +} + +int +main(int argc, char *argv[]) +{ + int failed = 0; + + failed |= test_ED25519_verify(); + failed |= test_ED25519_sign(); + failed |= test_ED25519_signature_malleability(); + + return failed; +} diff --git a/tests/empty.c b/tests/empty.c new file mode 100644 index 00000000..e69de29b diff --git a/tests/evp_ecx_test.c b/tests/evp_ecx_test.c new file mode 100644 index 00000000..b28378b9 --- /dev/null +++ b/tests/evp_ecx_test.c @@ -0,0 +1,831 @@ +/* $OpenBSD: evp_ecx_test.c,v 1.5 2023/03/02 20:04:42 tb Exp $ */ +/* + * Copyright (c) 2022 Joel Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include +#include +#include + +#include "curve25519_internal.h" + +static const uint8_t ed25519_priv_key_1[] = + "-----BEGIN PRIVATE KEY-----\n" + "MC4CAQAwBQYDK2VwBCIEIIkDg89yB70IpUXsAZieCcCDE2ig9nin9JJWpDQoCup8\n" + "-----END PRIVATE KEY-----\n"; + +const uint8_t ed25519_raw_priv_key_1[] = { + 0x89, 0x03, 0x83, 0xcf, 0x72, 0x07, 0xbd, 0x08, + 0xa5, 0x45, 0xec, 0x01, 0x98, 0x9e, 0x09, 0xc0, + 0x83, 0x13, 0x68, 0xa0, 0xf6, 0x78, 0xa7, 0xf4, + 0x92, 0x56, 0xa4, 0x34, 0x28, 0x0a, 0xea, 0x7c, +}; + +static const uint8_t ed25519_pub_key_1[] = + "-----BEGIN PUBLIC KEY-----\n" + "MCowBQYDK2VwAyEA1vxPpbnoC7G8vFmRjYVXUU2aln3hUZEgfW1atlTHF/o=\n" + "-----END PUBLIC KEY-----\n"; + +const uint8_t ed25519_raw_pub_key_1[] = { + 0xd6, 0xfc, 0x4f, 0xa5, 0xb9, 0xe8, 0x0b, 0xb1, + 0xbc, 0xbc, 0x59, 0x91, 0x8d, 0x85, 0x57, 0x51, + 0x4d, 0x9a, 0x96, 0x7d, 0xe1, 0x51, 0x91, 0x20, + 0x7d, 0x6d, 0x5a, 0xb6, 0x54, 0xc7, 0x17, 0xfa, +}; + +static const uint8_t message_1[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, +}; + +static const uint8_t signature_1[] = { + 0x1c, 0xba, 0x71, 0x5a, 0xbc, 0x7f, 0x3b, 0x6b, + 0xc1, 0x61, 0x04, 0x02, 0xb6, 0x37, 0x9e, 0xe1, + 0xa6, 0x7c, 0xfe, 0xcd, 0xdd, 0x68, 0x59, 0xb5, + 0xc8, 0x09, 0xa5, 0x36, 0x66, 0xfb, 0xad, 0xc5, + 0x68, 0x31, 0xd1, 0x7a, 0x48, 0x44, 0xaa, 0xa9, + 0x9c, 0xf1, 0x1a, 0xbb, 0xd5, 0x49, 0xd5, 0xe8, + 0x63, 0xe2, 0x94, 0x77, 0x16, 0x1a, 0x52, 0xfa, + 0x33, 0x6b, 0xf3, 0x57, 0x93, 0xd4, 0xc1, 0x07, +}; + +static const uint8_t x25519_priv_key_1[] = + "-----BEGIN PRIVATE KEY-----\n" + "MC4CAQAwBQYDK2VuBCIEICi6rzFFJb02mi6sopELeshEi2vr68ul4bzEHPOz+K1o\n" + "-----END PRIVATE KEY-----\n"; + +const uint8_t x25519_raw_priv_key_1[] = { + 0x28, 0xba, 0xaf, 0x31, 0x45, 0x25, 0xbd, 0x36, + 0x9a, 0x2e, 0xac, 0xa2, 0x91, 0x0b, 0x7a, 0xc8, + 0x44, 0x8b, 0x6b, 0xeb, 0xeb, 0xcb, 0xa5, 0xe1, + 0xbc, 0xc4, 0x1c, 0xf3, 0xb3, 0xf8, 0xad, 0x68, +}; + +static const uint8_t x25519_pub_key_1[] = + "-----BEGIN PUBLIC KEY-----\n" + "MCowBQYDK2VuAyEAu4WHXnAQL2YfonJhuoEO9PM2WwXjveApPmCXSiDnf1M=\n" + "-----END PUBLIC KEY-----\n"; + +static const uint8_t x25519_raw_pub_key_1[] = { + 0xbb, 0x85, 0x87, 0x5e, 0x70, 0x10, 0x2f, 0x66, + 0x1f, 0xa2, 0x72, 0x61, 0xba, 0x81, 0x0e, 0xf4, + 0xf3, 0x36, 0x5b, 0x05, 0xe3, 0xbd, 0xe0, 0x29, + 0x3e, 0x60, 0x97, 0x4a, 0x20, 0xe7, 0x7f, 0x53, +}; + +static const uint8_t x25519_priv_key_2[] = + "-----BEGIN PRIVATE KEY-----\n" + "MC4CAQAwBQYDK2VuBCIEIAg9Jbp/Ma0TO4r179WGGiv+VnGxGNRh4VNrHUij7Ql/\n" + "-----END PRIVATE KEY-----\n"; + +static const uint8_t x25519_raw_priv_key_2[] = { + 0x08, 0x3d, 0x25, 0xba, 0x7f, 0x31, 0xad, 0x13, + 0x3b, 0x8a, 0xf5, 0xef, 0xd5, 0x86, 0x1a, 0x2b, + 0xfe, 0x56, 0x71, 0xb1, 0x18, 0xd4, 0x61, 0xe1, + 0x53, 0x6b, 0x1d, 0x48, 0xa3, 0xed, 0x09, 0x7f, +}; + +static const uint8_t x25519_pub_key_2[] = + "-----BEGIN PUBLIC KEY-----\n" + "MCowBQYDK2VuAyEABvksGQRgsUXEK5CaniVZ59pPvDoABgBSdAM+EF0Q9Cw=\n" + "-----END PUBLIC KEY-----\n"; + +static const uint8_t x25519_raw_pub_key_2[] = { + 0x06, 0xf9, 0x2c, 0x19, 0x04, 0x60, 0xb1, 0x45, + 0xc4, 0x2b, 0x90, 0x9a, 0x9e, 0x25, 0x59, 0xe7, + 0xda, 0x4f, 0xbc, 0x3a, 0x00, 0x06, 0x00, 0x52, + 0x74, 0x03, 0x3e, 0x10, 0x5d, 0x10, 0xf4, 0x2c, +}; + +static const uint8_t shared_key_1[] = { + 0xa2, 0x61, 0xf5, 0x91, 0x2e, 0x82, 0xbc, 0x98, + 0x6c, 0x85, 0xb6, 0x51, 0x1f, 0x69, 0xdb, 0xfa, + 0x88, 0x6c, 0x4b, 0x9e, 0x3b, 0xb0, 0x71, 0xd1, + 0xf3, 0xea, 0x2a, 0xd0, 0xef, 0xf6, 0xa5, 0x5a, +}; + +static void +hexdump(const unsigned char *buf, size_t len) +{ + size_t i; + + for (i = 1; i <= len; i++) + fprintf(stderr, " 0x%02hhx,%s", buf[i - 1], i % 8 ? "" : "\n"); + + fprintf(stderr, "\n"); +} + +static int +ecx_ed25519_keygen_test(void) +{ + EVP_PKEY_CTX *pkey_ctx = NULL; + EVP_PKEY *pkey = NULL; + BIO *bio = NULL; + int failed = 1; + + if ((pkey_ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_ED25519, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to create ED25519 context\n"); + goto failure; + } + + if (EVP_PKEY_keygen_init(pkey_ctx) <= 0) { + fprintf(stderr, "FAIL: failed to init keygen for ED25519\n"); + goto failure; + } + if (EVP_PKEY_keygen(pkey_ctx, &pkey) <= 0) { + fprintf(stderr, "FAIL: failed to generate ED25519 key\n"); + goto failure; + } + + if ((bio = BIO_new(BIO_s_mem())) == NULL) + goto failure; + if (!PEM_write_bio_PrivateKey(bio, pkey, NULL, NULL, 0, NULL, NULL)) { + fprintf(stderr, "FAIL: failed to write ED25519 to PEM\n"); + goto failure; + } + + failed = 0; + + failure: + BIO_free(bio); + EVP_PKEY_CTX_free(pkey_ctx); + EVP_PKEY_free(pkey); + + return failed; +} + +static int +ecx_ed25519_raw_key_test(void) +{ + EVP_PKEY *pkey = NULL; + uint8_t *priv_key = NULL; + size_t priv_key_len = 0; + uint8_t *pub_key = NULL; + size_t pub_key_len = 0; + const uint8_t *pp; + BIO *bio = NULL; + int failed = 1; + + /* + * Decode private key from PEM and check raw private and raw public. + */ + + if ((bio = BIO_new_mem_buf(ed25519_priv_key_1, -1)) == NULL) + errx(1, "failed to create BIO for key"); + if ((pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to read private key\n"); + ERR_print_errors_fp(stderr); + goto failure; + } + + if (!EVP_PKEY_get_raw_private_key(pkey, NULL, &priv_key_len)) { + fprintf(stderr, "FAIL: failed to get raw private key len\n"); + goto failure; + } + if (priv_key_len != sizeof(ed25519_raw_priv_key_1)) { + fprintf(stderr, "FAIL: raw private key length differs " + "(%zu != %zu)\n", priv_key_len, + sizeof(ed25519_raw_priv_key_1)); + goto failure; + } + if ((priv_key = malloc(priv_key_len)) == NULL) + errx(1, "failed to malloc priv key"); + if (!EVP_PKEY_get_raw_private_key(pkey, priv_key, &priv_key_len)) { + fprintf(stderr, "FAIL: failed to get raw private key len\n"); + goto failure; + } + if (memcmp(priv_key, ed25519_raw_priv_key_1, priv_key_len) != 0) { + fprintf(stderr, "FAIL: get raw private key failed\n"); + fprintf(stderr, "Got:\n"); + hexdump(priv_key, priv_key_len); + fprintf(stderr, "Want:\n"); + hexdump(ed25519_raw_priv_key_1, sizeof(ed25519_raw_priv_key_1)); + goto failure; + } + + if (!EVP_PKEY_get_raw_public_key(pkey, NULL, &pub_key_len)) { + fprintf(stderr, "FAIL: failed to get raw pub key len\n"); + goto failure; + } + if (pub_key_len != sizeof(ed25519_raw_pub_key_1)) { + fprintf(stderr, "FAIL: raw public key length differs " + "(%zu != %zu)\n", pub_key_len, + sizeof(ed25519_raw_pub_key_1)); + goto failure; + } + if ((pub_key = malloc(pub_key_len)) == NULL) + errx(1, "failed to malloc private key"); + if (!EVP_PKEY_get_raw_public_key(pkey, pub_key, &pub_key_len)) { + fprintf(stderr, "FAIL: failed to get raw pub key len\n"); + goto failure; + } + if (memcmp(pub_key, ed25519_raw_pub_key_1, pub_key_len) != 0) { + fprintf(stderr, "FAIL: get raw public key failed\n"); + fprintf(stderr, "Got:\n"); + hexdump(pub_key, pub_key_len); + fprintf(stderr, "Want:\n"); + hexdump(ed25519_raw_pub_key_1, sizeof(ed25519_raw_pub_key_1)); + goto failure; + } + + BIO_free(bio); + bio = NULL; + + EVP_PKEY_free(pkey); + pkey = NULL; + + freezero(priv_key, priv_key_len); + priv_key = NULL; + priv_key_len = 0; + + freezero(pub_key, pub_key_len); + pub_key = NULL; + pub_key_len = 0; + + /* + * Decode public key from PEM and check raw private and raw public. + */ + + if ((bio = BIO_new_mem_buf(ed25519_pub_key_1, -1)) == NULL) + errx(1, "failed to create BIO for key"); + if ((pkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to read public key\n"); + ERR_print_errors_fp(stderr); + goto failure; + } + + /* + * Yet another astounding API design - we cannot tell if the private key + * is not present, or if some other failure occurred. + */ + if (!EVP_PKEY_get_raw_private_key(pkey, NULL, &priv_key_len)) { + fprintf(stderr, "FAIL: failed to get raw priv key len\n"); + goto failure; + } + if ((priv_key = malloc(priv_key_len)) == NULL) + errx(1, "failed to malloc priv key"); + if (EVP_PKEY_get_raw_private_key(pkey, priv_key, &priv_key_len)) { + fprintf(stderr, "FAIL: got raw private key, should fail\n"); + goto failure; + } + + if (!EVP_PKEY_get_raw_public_key(pkey, NULL, &pub_key_len)) { + fprintf(stderr, "FAIL: failed to get raw pub key len\n"); + goto failure; + } + if (pub_key_len != sizeof(ed25519_raw_pub_key_1)) { + fprintf(stderr, "FAIL: raw public key length differs " + "(%zu != %zu)\n", pub_key_len, + sizeof(ed25519_raw_pub_key_1)); + goto failure; + } + if ((pub_key = malloc(pub_key_len)) == NULL) + errx(1, "failed to malloc private key"); + if (!EVP_PKEY_get_raw_public_key(pkey, pub_key, &pub_key_len)) { + fprintf(stderr, "FAIL: failed to get raw pub key len\n"); + goto failure; + } + if (memcmp(pub_key, ed25519_raw_pub_key_1, pub_key_len) != 0) { + fprintf(stderr, "FAIL: get raw public key failed\n"); + fprintf(stderr, "Got:\n"); + hexdump(pub_key, pub_key_len); + fprintf(stderr, "Want:\n"); + hexdump(ed25519_raw_pub_key_1, sizeof(ed25519_raw_pub_key_1)); + goto failure; + } + + BIO_free(bio); + bio = NULL; + + EVP_PKEY_free(pkey); + pkey = NULL; + + /* + * Create PKEY from raw private, check PEM encoded private and public. + */ + if ((pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_ED25519, NULL, + ed25519_raw_priv_key_1, sizeof(ed25519_raw_priv_key_1))) == NULL) { + fprintf(stderr, "FAIL: PKEY from raw private key failed"); + goto failure; + } + if ((bio = BIO_new(BIO_s_mem())) == NULL) + goto failure; + if (!PEM_write_bio_PrivateKey(bio, pkey, NULL, NULL, 0, NULL, NULL)) { + fprintf(stderr, "FAIL: failed to write ED25519 private to PEM\n"); + goto failure; + } + BIO_get_mem_data(bio, &pp); + if (strcmp(ed25519_priv_key_1, pp) != 0) { + fprintf(stderr, "FAIL: resulting private key PEM differs\n"); + goto failure; + } + + (void)BIO_reset(bio); + if (!PEM_write_bio_PUBKEY(bio, pkey)) { + fprintf(stderr, "FAIL: failed to write ED25519 public to PEM\n"); + goto failure; + } + BIO_get_mem_data(bio, &pp); + if (strcmp(ed25519_pub_key_1, pp) != 0) { + fprintf(stderr, "FAIL: resulting public key PEM differs\n"); + fprintf(stderr, "%s\n", ed25519_pub_key_1); + fprintf(stderr, "%s\n", pp); + //goto failure; + } + + EVP_PKEY_free(pkey); + pkey = NULL; + + /* + * Create PKEY from raw public, check public key PEM. + */ + if ((pkey = EVP_PKEY_new_raw_public_key(EVP_PKEY_ED25519, NULL, + ed25519_raw_pub_key_1, sizeof(ed25519_raw_pub_key_1))) == NULL) { + fprintf(stderr, "FAIL: PKEY from raw public key failed"); + goto failure; + } + (void)BIO_reset(bio); + if (!PEM_write_bio_PUBKEY(bio, pkey)) { + fprintf(stderr, "FAIL: failed to write ED25519 public to PEM\n"); + goto failure; + } + BIO_get_mem_data(bio, &pp); + if (strcmp(ed25519_pub_key_1, pp) != 0) { + fprintf(stderr, "FAIL: resulting public key PEM differs\n"); + goto failure; + } + + failed = 0; + + failure: + BIO_free(bio); + EVP_PKEY_free(pkey); + freezero(priv_key, priv_key_len); + freezero(pub_key, pub_key_len); + + return failed; +} + +static int +ecx_ed25519_sign_test(void) +{ + EVP_MD_CTX *md_ctx = NULL; + EVP_PKEY *pkey = NULL; + uint8_t *signature = NULL; + size_t signature_len = 0; + BIO *bio = NULL; + int failed = 1; + + if ((bio = BIO_new_mem_buf(ed25519_priv_key_1, -1)) == NULL) + errx(1, "failed to create BIO for key"); + if ((pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to read private key\n"); + ERR_print_errors_fp(stderr); + goto failure; + } + + if ((md_ctx = EVP_MD_CTX_new()) == NULL) + errx(1, "failed to create MD_CTX"); + + if (!EVP_DigestSignInit(md_ctx, NULL, NULL, NULL, pkey)) { + fprintf(stderr, "FAIL: failed to init digest sign\n"); + ERR_print_errors_fp(stderr); + goto failure; + } + if (!EVP_DigestSign(md_ctx, NULL, &signature_len, NULL, 0)) { + fprintf(stderr, "FAIL: failed to digest sign update\n"); + goto failure; + } + if ((signature = calloc(1, signature_len)) == NULL) + errx(1, "failed to allocate signature"); + if (!EVP_DigestSign(md_ctx, signature, &signature_len, message_1, + sizeof(message_1))) { + fprintf(stderr, "FAIL: failed to digest sign update\n"); + goto failure; + } + + if (signature_len != sizeof(signature_1)) { + fprintf(stderr, "FAIL: signature length differs (%zu != %zu)\n", + signature_len, sizeof(signature_1)); + goto failure; + } + + if (memcmp(signature, signature_1, signature_len) != 0) { + fprintf(stderr, "FAIL: Ed25519 sign failed\n"); + fprintf(stderr, "Got:\n"); + hexdump(signature, signature_len); + fprintf(stderr, "Want:\n"); + hexdump(signature_1, sizeof(signature_1)); + goto failure; + } + + failed = 0; + + failure: + BIO_free(bio); + EVP_MD_CTX_free(md_ctx); + EVP_PKEY_free(pkey); + free(signature); + + return failed; +} + +static int +ecx_ed25519_verify_test(void) +{ + EVP_MD_CTX *md_ctx = NULL; + EVP_PKEY *pkey = NULL; + BIO *bio = NULL; + int failed = 1; + + if ((bio = BIO_new_mem_buf(ed25519_pub_key_1, -1)) == NULL) + errx(1, "failed to create BIO for key"); + if ((pkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to read public key\n"); + ERR_print_errors_fp(stderr); + goto failure; + } + + if ((md_ctx = EVP_MD_CTX_new()) == NULL) + errx(1, "failed to create MD_CTX"); + + if (!EVP_DigestVerifyInit(md_ctx, NULL, NULL, NULL, pkey)) { + fprintf(stderr, "FAIL: failed to init digest verify\n"); + ERR_print_errors_fp(stderr); + goto failure; + } + if (!EVP_DigestVerify(md_ctx, signature_1, sizeof(signature_1), + message_1, sizeof(message_1))) { + fprintf(stderr, "FAIL: failed to digest verify update\n"); + goto failure; + } + + failed = 0; + + failure: + BIO_free(bio); + EVP_MD_CTX_free(md_ctx); + EVP_PKEY_free(pkey); + + return failed; +} + +static int +ecx_x25519_keygen_test(void) +{ + EVP_PKEY_CTX *pkey_ctx = NULL; + EVP_PKEY *pkey = NULL; + BIO *bio = NULL; + int failed = 1; + + if ((pkey_ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X25519, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to create X25519 context\n"); + goto failure; + } + + if (EVP_PKEY_keygen_init(pkey_ctx) <= 0) { + fprintf(stderr, "FAIL: failed to init keygen for X25519\n"); + goto failure; + } + if (EVP_PKEY_keygen(pkey_ctx, &pkey) <= 0) { + fprintf(stderr, "FAIL: failed to generate X25519 key\n"); + goto failure; + } + + if ((bio = BIO_new(BIO_s_mem())) == NULL) + goto failure; + if (!PEM_write_bio_PrivateKey(bio, pkey, NULL, NULL, 0, NULL, NULL)) { + fprintf(stderr, "FAIL: failed to write X25519 to PEM\n"); + goto failure; + } + + failed = 0; + + failure: + BIO_free(bio); + EVP_PKEY_CTX_free(pkey_ctx); + EVP_PKEY_free(pkey); + + return failed; +} + +static int +ecx_x25519_derive_test(void) +{ + EVP_PKEY_CTX *pkey_ctx = NULL; + EVP_PKEY *pkey = NULL, *pkey_peer = NULL; + uint8_t *shared_key = NULL; + size_t shared_key_len = 0; + BIO *bio = NULL; + int failed = 1; + + if ((bio = BIO_new_mem_buf(x25519_priv_key_1, -1)) == NULL) + errx(1, "failed to create BIO for key"); + if ((pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to read private key\n"); + ERR_print_errors_fp(stderr); + goto failure; + } + + BIO_free(bio); + if ((bio = BIO_new_mem_buf(x25519_pub_key_2, -1)) == NULL) + errx(1, "failed to create BIO for key"); + if ((pkey_peer = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to read peer public key\n"); + ERR_print_errors_fp(stderr); + goto failure; + } + + if ((pkey_ctx = EVP_PKEY_CTX_new(pkey, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to create X25519 context\n"); + goto failure; + } + if (EVP_PKEY_derive_init(pkey_ctx) <= 0) { + fprintf(stderr, "FAIL: failed to init derive for X25519\n"); + goto failure; + } + if (EVP_PKEY_derive_set_peer(pkey_ctx, pkey_peer) <= 0) { + fprintf(stderr, "FAIL: failed to set peer key for X25519\n"); + goto failure; + } + if (EVP_PKEY_derive(pkey_ctx, NULL, &shared_key_len) <= 0) { + fprintf(stderr, "FAIL: failed to derive X25519 key length\n"); + goto failure; + } + if ((shared_key = malloc(shared_key_len)) == NULL) + errx(1, "failed to malloc shared key"); + if (EVP_PKEY_derive(pkey_ctx, shared_key, &shared_key_len) <= 0) { + fprintf(stderr, "FAIL: failed to derive X25519 key\n"); + goto failure; + } + + if (shared_key_len != sizeof(shared_key_1)) { + fprintf(stderr, "FAIL: shared key length differs (%zu != %zu)\n", + shared_key_len, sizeof(shared_key_1)); + goto failure; + } + + if (memcmp(shared_key, shared_key_1, shared_key_len) != 0) { + fprintf(stderr, "FAIL: X25519 derive failed\n"); + fprintf(stderr, "Got:\n"); + hexdump(shared_key, shared_key_len); + fprintf(stderr, "Want:\n"); + hexdump(shared_key_1, sizeof(shared_key_1)); + goto failure; + } + + failed = 0; + + failure: + BIO_free(bio); + EVP_PKEY_CTX_free(pkey_ctx); + EVP_PKEY_free(pkey_peer); + EVP_PKEY_free(pkey); + freezero(shared_key, shared_key_len); + + return failed; +} + +static int +ecx_x25519_raw_key_test(void) +{ + EVP_PKEY *pkey = NULL; + uint8_t *priv_key = NULL; + size_t priv_key_len = 0; + uint8_t *pub_key = NULL; + size_t pub_key_len = 0; + const uint8_t *pp; + BIO *bio = NULL; + int failed = 1; + + /* + * Decode private key from PEM and check raw private and raw public. + */ + + if ((bio = BIO_new_mem_buf(x25519_priv_key_2, -1)) == NULL) + errx(1, "failed to create BIO for key"); + if ((pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to read private key\n"); + ERR_print_errors_fp(stderr); + goto failure; + } + + if (!EVP_PKEY_get_raw_private_key(pkey, NULL, &priv_key_len)) { + fprintf(stderr, "FAIL: failed to get raw private key len\n"); + goto failure; + } + if (priv_key_len != sizeof(x25519_raw_priv_key_2)) { + fprintf(stderr, "FAIL: raw private key length differs " + "(%zu != %zu)\n", priv_key_len, + sizeof(x25519_raw_priv_key_2)); + goto failure; + } + if ((priv_key = malloc(priv_key_len)) == NULL) + errx(1, "failed to malloc priv key"); + if (!EVP_PKEY_get_raw_private_key(pkey, priv_key, &priv_key_len)) { + fprintf(stderr, "FAIL: failed to get raw private key len\n"); + goto failure; + } + if (memcmp(priv_key, x25519_raw_priv_key_2, priv_key_len) != 0) { + fprintf(stderr, "FAIL: get raw private key failed\n"); + fprintf(stderr, "Got:\n"); + hexdump(priv_key, priv_key_len); + fprintf(stderr, "Want:\n"); + hexdump(x25519_raw_priv_key_2, sizeof(x25519_raw_priv_key_2)); + goto failure; + } + + if (!EVP_PKEY_get_raw_public_key(pkey, NULL, &pub_key_len)) { + fprintf(stderr, "FAIL: failed to get raw pub key len\n"); + goto failure; + } + if (pub_key_len != sizeof(x25519_raw_pub_key_2)) { + fprintf(stderr, "FAIL: raw public key length differs " + "(%zu != %zu)\n", pub_key_len, + sizeof(x25519_raw_pub_key_2)); + goto failure; + } + if ((pub_key = malloc(pub_key_len)) == NULL) + errx(1, "failed to malloc private key"); + if (!EVP_PKEY_get_raw_public_key(pkey, pub_key, &pub_key_len)) { + fprintf(stderr, "FAIL: failed to get raw pub key len\n"); + goto failure; + } + if (memcmp(pub_key, x25519_raw_pub_key_2, pub_key_len) != 0) { + fprintf(stderr, "FAIL: get raw public key failed\n"); + fprintf(stderr, "Got:\n"); + hexdump(pub_key, pub_key_len); + fprintf(stderr, "Want:\n"); + hexdump(x25519_raw_pub_key_2, sizeof(x25519_raw_pub_key_2)); + goto failure; + } + + BIO_free(bio); + bio = NULL; + + EVP_PKEY_free(pkey); + pkey = NULL; + + freezero(priv_key, priv_key_len); + priv_key = NULL; + priv_key_len = 0; + + freezero(pub_key, pub_key_len); + pub_key = NULL; + pub_key_len = 0; + + /* + * Decode public key from PEM and check raw private and raw public. + */ + + if ((bio = BIO_new_mem_buf(x25519_pub_key_1, -1)) == NULL) + errx(1, "failed to create BIO for key"); + if ((pkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL)) == NULL) { + fprintf(stderr, "FAIL: failed to read public key\n"); + ERR_print_errors_fp(stderr); + goto failure; + } + + /* + * Yet another astounding API design - we cannot tell if the private key + * is not present, or if some other failure occurred. + */ + if (!EVP_PKEY_get_raw_private_key(pkey, NULL, &priv_key_len)) { + fprintf(stderr, "FAIL: failed to get raw priv key len\n"); + goto failure; + } + if ((priv_key = malloc(priv_key_len)) == NULL) + errx(1, "failed to malloc priv key"); + if (EVP_PKEY_get_raw_private_key(pkey, priv_key, &priv_key_len)) { + fprintf(stderr, "FAIL: got raw private key, should fail\n"); + goto failure; + } + + if (!EVP_PKEY_get_raw_public_key(pkey, NULL, &pub_key_len)) { + fprintf(stderr, "FAIL: failed to get raw pub key len\n"); + goto failure; + } + if (pub_key_len != sizeof(x25519_raw_pub_key_1)) { + fprintf(stderr, "FAIL: raw public key length differs " + "(%zu != %zu)\n", pub_key_len, + sizeof(x25519_raw_pub_key_1)); + goto failure; + } + if ((pub_key = malloc(pub_key_len)) == NULL) + errx(1, "failed to malloc private key"); + if (!EVP_PKEY_get_raw_public_key(pkey, pub_key, &pub_key_len)) { + fprintf(stderr, "FAIL: failed to get raw pub key len\n"); + goto failure; + } + if (memcmp(pub_key, x25519_raw_pub_key_1, pub_key_len) != 0) { + fprintf(stderr, "FAIL: get raw public key failed\n"); + fprintf(stderr, "Got:\n"); + hexdump(pub_key, pub_key_len); + fprintf(stderr, "Want:\n"); + hexdump(x25519_raw_pub_key_1, sizeof(x25519_raw_pub_key_1)); + goto failure; + } + + BIO_free(bio); + bio = NULL; + + EVP_PKEY_free(pkey); + pkey = NULL; + + /* + * Create PKEY from raw private, check PEM encoded private and public. + */ + if ((pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_X25519, NULL, + x25519_raw_priv_key_2, sizeof(x25519_raw_priv_key_2))) == NULL) { + fprintf(stderr, "FAIL: PKEY from raw private key failed"); + goto failure; + } + if ((bio = BIO_new(BIO_s_mem())) == NULL) + goto failure; + if (!PEM_write_bio_PrivateKey(bio, pkey, NULL, NULL, 0, NULL, NULL)) { + fprintf(stderr, "FAIL: failed to write X25519 private to PEM\n"); + goto failure; + } + BIO_get_mem_data(bio, &pp); + if (strcmp(x25519_priv_key_2, pp) != 0) { + fprintf(stderr, "FAIL: resulting private key PEM differs\n"); + goto failure; + } + + (void)BIO_reset(bio); + if (!PEM_write_bio_PUBKEY(bio, pkey)) { + fprintf(stderr, "FAIL: failed to write X25519 public to PEM\n"); + goto failure; + } + BIO_get_mem_data(bio, &pp); + if (strcmp(x25519_pub_key_2, pp) != 0) { + fprintf(stderr, "FAIL: resulting public key PEM differs\n"); + goto failure; + } + + EVP_PKEY_free(pkey); + pkey = NULL; + + /* + * Create PKEY from raw public, check public key PEM. + */ + if ((pkey = EVP_PKEY_new_raw_public_key(EVP_PKEY_X25519, NULL, + x25519_raw_pub_key_1, sizeof(x25519_raw_pub_key_1))) == NULL) { + fprintf(stderr, "FAIL: PKEY from raw public key failed"); + goto failure; + } + (void)BIO_reset(bio); + if (!PEM_write_bio_PUBKEY(bio, pkey)) { + fprintf(stderr, "FAIL: failed to write X25519 public to PEM\n"); + goto failure; + } + BIO_get_mem_data(bio, &pp); + if (strcmp(x25519_pub_key_1, pp) != 0) { + fprintf(stderr, "FAIL: resulting public key PEM differs\n"); + goto failure; + } + + failed = 0; + + failure: + BIO_free(bio); + EVP_PKEY_free(pkey); + freezero(priv_key, priv_key_len); + freezero(pub_key, pub_key_len); + + return failed; +} + +int +main(int argc, char **argv) +{ + int failed = 0; + + failed |= ecx_ed25519_raw_key_test(); + failed |= ecx_ed25519_keygen_test(); + failed |= ecx_ed25519_sign_test(); + failed |= ecx_ed25519_verify_test(); + + failed |= ecx_x25519_keygen_test(); + failed |= ecx_x25519_derive_test(); + failed |= ecx_x25519_raw_key_test(); + + return failed; +} diff --git a/tests/evp_pkey_check.c b/tests/evp_pkey_check.c index db26d3aa..7b73316b 100644 --- a/tests/evp_pkey_check.c +++ b/tests/evp_pkey_check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_pkey_check.c,v 1.2 2022/01/11 19:27:35 tb Exp $ */ +/* $OpenBSD: evp_pkey_check.c,v 1.4 2023/03/02 20:18:40 tb Exp $ */ /* * Copyright (c) 2021-2022 Theo Buehler * @@ -130,14 +130,11 @@ evp_pkey_check_rsa(void) fail_soft = 1; } - /* - * Spew some garbage to stderr. - */ - - fprintf(stderr, "We should see some errors about RSA d:\n"); - ERR_print_errors_fp(stderr); + if (ERR_peek_error() == 0) { + fprintf(stderr, "%s: expected some RSA errors\n", __func__); + fail_soft = 1; + } ERR_clear_error(); - fprintf(stderr, "EVP_PKEY_check test for RSA done.\n"); failed = 0; @@ -272,12 +269,10 @@ evp_pkey_check_ec(void) fail_soft = 1; } - /* - * Spew some garbage to stderr. - */ - - fprintf(stderr, "We should see an error about the EC private key:\n"); - ERR_print_errors_fp(stderr); + if (ERR_peek_error() == 0) { + fprintf(stderr, "%s: expected a private key error\n", __func__); + fail_soft = 1; + } ERR_clear_error(); /* EVP_PKEY_public_check checks the private key (sigh), so we fail. */ @@ -373,12 +368,12 @@ evp_pkey_check_ec(void) fail_soft = 1; } - fprintf(stderr, "We should see an error on invalid group order\n"); - ERR_print_errors_fp(stderr); + if (ERR_peek_error() == 0) { + fprintf(stderr, "%s: expected a group order error\n", __func__); + fail_soft = 1; + } ERR_clear_error(); - fprintf(stderr, "EVP_PKEY_check test for EC done.\n"); - failed = 0; err: @@ -398,7 +393,5 @@ main(void) failed |= evp_pkey_check_rsa(); failed |= evp_pkey_check_ec(); - printf("%s\n", failed ? "FAILED" : "SUCCESS"); - return failed; } diff --git a/tests/evp_pkey_cleanup.c b/tests/evp_pkey_cleanup.c index 5f8cc20d..fd922efb 100644 --- a/tests/evp_pkey_cleanup.c +++ b/tests/evp_pkey_cleanup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evp_pkey_cleanup.c,v 1.1 2022/03/30 08:57:26 tb Exp $ */ +/* $OpenBSD: evp_pkey_cleanup.c,v 1.3 2022/12/01 13:49:12 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler @@ -20,7 +20,7 @@ #include -#include "evp_locl.h" +#include "evp_local.h" struct pkey_cleanup_test { const char *name; @@ -79,8 +79,5 @@ main(void) for (i = 0; i < N_PKEY_IDS; i++) failed |= test_evp_pkey_ctx_cleanup(pkey_ids[i]); - if (!failed) - printf("SUCCESS\n"); - return failed; } diff --git a/tests/evptest.c b/tests/evptest.c index e6108de9..6f677dd9 100644 --- a/tests/evptest.c +++ b/tests/evptest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evptest.c,v 1.11 2021/11/18 21:18:28 tb Exp $ */ +/* $OpenBSD: evptest.c,v 1.12 2023/03/02 20:24:51 tb Exp $ */ /* Written by Ben Laurie, 2001 */ /* * Copyright (c) 2001 The OpenSSL Project. All rights reserved. @@ -59,6 +59,8 @@ #include #include +int verbose; + static void hexdump(FILE *f, const char *title, const unsigned char *s, int l) { @@ -147,13 +149,15 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn, const unsigned char *eiv; int outl, outl2; - printf("Testing cipher %s%s\n", EVP_CIPHER_name(c), - (encdec == 1 ? "(encrypt)" : (encdec == 0 ? "(decrypt)" : "(encrypt/decrypt)"))); - hexdump(stdout, "Key",key,kn); - if (in) - hexdump(stdout, "IV",iv,in); - hexdump(stdout, "Plaintext",plaintext,pn); - hexdump(stdout, "Ciphertext",ciphertext,cn); + if (verbose) { + printf("Testing cipher %s%s\n", EVP_CIPHER_name(c), + (encdec == 1 ? "(encrypt)" : (encdec == 0 ? "(decrypt)" : "(encrypt/decrypt)"))); + hexdump(stdout, "Key",key,kn); + if (in) + hexdump(stdout, "IV",iv,in); + hexdump(stdout, "Plaintext",plaintext,pn); + hexdump(stdout, "Ciphertext",ciphertext,cn); + } if (kn != EVP_CIPHER_key_length(c)) { fprintf(stderr, "Key length doesn't match, got %d expected %lu\n",kn, @@ -240,7 +244,8 @@ test1(const EVP_CIPHER *c, const unsigned char *key, int kn, EVP_CIPHER_CTX_free(ctx); - printf("\n"); + if (verbose) + printf("\n"); } static int @@ -272,9 +277,11 @@ test_digest(const char *digest, const unsigned char *plaintext, int pn, if (!d) return 0; - printf("Testing digest %s\n",EVP_MD_name(d)); - hexdump(stdout, "Plaintext",plaintext,pn); - hexdump(stdout, "Digest",ciphertext,cn); + if (verbose) { + printf("Testing digest %s\n",EVP_MD_name(d)); + hexdump(stdout, "Plaintext",plaintext,pn); + hexdump(stdout, "Digest",ciphertext,cn); + } if ((ctx = EVP_MD_CTX_new()) == NULL) { fprintf(stderr, "EVP_CIPHER_CTX_new failed\n"); @@ -310,8 +317,8 @@ test_digest(const char *digest, const unsigned char *plaintext, int pn, hexdump(stderr, "Expected",ciphertext,cn); exit(103); } - - printf("\n"); + if (verbose) + printf("\n"); return 1; } @@ -322,10 +329,15 @@ main(int argc, char **argv) const char *szTestFile; FILE *f; - if (argc != 2) { + if (argc != 2 && argc != 3) { fprintf(stderr, "%s \n",argv[0]); exit(1); } + if (argc == 3 && strcmp(argv[1], "-v") == 0) { + verbose = 1; + argv++; + argc--; + } szTestFile = argv[1]; @@ -390,45 +402,52 @@ main(int argc, char **argv) if (!test_cipher(cipher, key, kn, iv, in, plaintext, pn, ciphertext, cn, encdec) && !test_digest(cipher, plaintext, pn, ciphertext, cn)) { #ifdef OPENSSL_NO_AES - if (strstr(cipher, "AES") == cipher) { - fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); + if (strstr(cipher, "AES") == cipher && verbose) { + if (verbose) + fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_DES - if (strstr(cipher, "DES") == cipher) { - fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); + if (strstr(cipher, "DES") == cipher && verbose) { + if (verbose) + fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_RC4 - if (strstr(cipher, "RC4") == cipher) { - fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); + if (strstr(cipher, "RC4") == cipher && verbose) { + if (verbose) + fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_CAMELLIA - if (strstr(cipher, "CAMELLIA") == cipher) { - fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); + if (strstr(cipher, "CAMELLIA") == cipher && verbose) { + if (verbose) + fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_SEED if (strstr(cipher, "SEED") == cipher) { - fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); + if (verbose) + fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_CHACHA if (strstr(cipher, "ChaCha") == cipher) { - fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); + if (verbose) + fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif #ifdef OPENSSL_NO_GOST if (strstr(cipher, "md_gost") == cipher || strstr(cipher, "streebog") == cipher) { - fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); + if (verbose) + fprintf(stdout, "Cipher disabled, skipping %s\n", cipher); continue; } #endif diff --git a/tests/exptest.c b/tests/exptest.c deleted file mode 100644 index e6260071..00000000 --- a/tests/exptest.c +++ /dev/null @@ -1,361 +0,0 @@ -/* $OpenBSD: exptest.c,v 1.8 2021/11/18 15:17:31 tb Exp $ */ -/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - * All rights reserved. - * - * This package is an SSL implementation written - * by Eric Young (eay@cryptsoft.com). - * The implementation was written so as to conform with Netscapes SSL. - * - * This library is free for commercial and non-commercial use as long as - * the following conditions are aheared to. The following conditions - * apply to all code found in this distribution, be it the RC4, RSA, - * lhash, DES, etc., code; not just the SSL code. The SSL documentation - * included with this distribution is covered by the same copyright terms - * except that the holder is Tim Hudson (tjh@cryptsoft.com). - * - * Copyright remains Eric Young's, and as such any Copyright notices in - * the code are not to be removed. - * If this package is used in a product, Eric Young should be given attribution - * as the author of the parts of the library used. - * This can be in the form of a textual message at program startup or - * in documentation (online or textual) provided with the package. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * "This product includes cryptographic software written by - * Eric Young (eay@cryptsoft.com)" - * The word 'cryptographic' can be left out if the rouines from the library - * being used are not cryptographic related :-). - * 4. If you include any Windows specific code (or a derivative thereof) from - * the apps directory (application code) you must include an acknowledgement: - * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" - * - * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * The licence and distribution terms for any publically available version or - * derivative of this code cannot be changed. i.e. this code cannot simply be - * copied and put under another distribution licence - * [including the GNU Public Licence.] - */ - -#include -#include -#include - -#include -#include -#include - -int BN_mod_exp_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); -int BN_mod_exp_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); -int BN_mod_exp_mont_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp_mont_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); - -#define NUM_BITS (BN_BITS*2) - -/* - * Test that r == 0 in test_exp_mod_zero(). Returns one on success, - * returns zero and prints debug output otherwise. - */ -static int -a_is_zero_mod_one(const char *method, const BIGNUM *r, const BIGNUM *a) -{ - if (!BN_is_zero(r)) { - fprintf(stderr, "%s failed:\n", method); - fprintf(stderr, "a ** 0 mod 1 = r (should be 0)\n"); - fprintf(stderr, "a = "); - BN_print_fp(stderr, a); - fprintf(stderr, "\nr = "); - BN_print_fp(stderr, r); - fprintf(stderr, "\n"); - return 0; - } - return 1; -} - -/* - * test_exp_mod_zero tests that x**0 mod 1 == 0. It returns zero on success. - */ -static int -test_exp_mod_zero(void) -{ - BIGNUM *a = NULL, *p = NULL, *m = NULL, *r = NULL; - BN_ULONG one_word = 1; - BN_CTX *ctx; - int ret = 1, failed = 0; - - if ((ctx = BN_CTX_new()) == NULL) - goto err; - if ((m = BN_new()) == NULL) - goto err; - BN_one(m); - - if ((a = BN_new()) == NULL) - goto err; - BN_one(a); - - if ((p = BN_new()) == NULL) - goto err; - BN_zero(p); - - if ((r = BN_new()) == NULL) - goto err; - - if (!BN_rand(a, 1024, 0, 0)) - goto err; - - if (!BN_mod_exp(r, a, p, m, ctx)) - goto err; - - if (!a_is_zero_mod_one("BN_mod_exp", r, a)) - failed = 1; - - if (!BN_mod_exp_ct(r, a, p, m, ctx)) - goto err; - - if (!a_is_zero_mod_one("BN_mod_exp_ct", r, a)) - failed = 1; - - if (!BN_mod_exp_nonct(r, a, p, m, ctx)) - goto err; - - if (!a_is_zero_mod_one("BN_mod_exp_nonct", r, a)) - failed = 1; - - if (!BN_mod_exp_recp(r, a, p, m, ctx)) - goto err; - - if (!a_is_zero_mod_one("BN_mod_exp_recp", r, a)) - failed = 1; - - if (!BN_mod_exp_simple(r, a, p, m, ctx)) - goto err; - - if (!a_is_zero_mod_one("BN_mod_exp_simple", r, a)) - failed = 1; - - if (!BN_mod_exp_mont(r, a, p, m, ctx, NULL)) - goto err; - - if (!a_is_zero_mod_one("BN_mod_exp_mont", r, a)) - failed = 1; - - if (!BN_mod_exp_mont_ct(r, a, p, m, ctx, NULL)) - goto err; - - if (!a_is_zero_mod_one("BN_mod_exp_mont_ct", r, a)) - failed = 1; - - if (!BN_mod_exp_mont_nonct(r, a, p, m, ctx, NULL)) - goto err; - - if (!a_is_zero_mod_one("BN_mod_exp_mont_nonct", r, a)) - failed = 1; - - if (!BN_mod_exp_mont_consttime(r, a, p, m, ctx, NULL)) { - goto err; - } - - if (!a_is_zero_mod_one("BN_mod_exp_mont_consttime", r, a)) - failed = 1; - - /* - * A different codepath exists for single word multiplication - * in non-constant-time only. - */ - if (!BN_mod_exp_mont_word(r, one_word, p, m, ctx, NULL)) - goto err; - - if (!BN_is_zero(r)) { - fprintf(stderr, "BN_mod_exp_mont_word failed:\n"); - fprintf(stderr, "1 ** 0 mod 1 = r (should be 0)\n"); - fprintf(stderr, "r = "); - BN_print_fp(stderr, r); - fprintf(stderr, "\n"); - return 0; - } - - ret = failed; - - err: - BN_free(r); - BN_free(a); - BN_free(p); - BN_free(m); - BN_CTX_free(ctx); - - return ret; -} - -int main(int argc, char *argv[]) -{ - BIGNUM *r_mont, *r_mont_const, *r_recp, *r_simple; - BIGNUM *r_mont_ct, *r_mont_nonct, *a, *b, *m; - BN_CTX *ctx; - BIO *out = NULL; - unsigned char c; - int i, ret; - - ERR_load_BN_strings(); - - if ((ctx = BN_CTX_new()) == NULL) - goto err; - if ((r_mont = BN_new()) == NULL) - goto err; - if ((r_mont_const = BN_new()) == NULL) - goto err; - if ((r_mont_ct = BN_new()) == NULL) - goto err; - if ((r_mont_nonct = BN_new()) == NULL) - goto err; - if ((r_recp = BN_new()) == NULL) - goto err; - if ((r_simple = BN_new()) == NULL) - goto err; - if ((a = BN_new()) == NULL) - goto err; - if ((b = BN_new()) == NULL) - goto err; - if ((m = BN_new()) == NULL) - goto err; - - if ((out = BIO_new(BIO_s_file())) == NULL) - exit(1); - BIO_set_fp(out, stdout, BIO_NOCLOSE); - - for (i = 0; i < 200; i++) { - arc4random_buf(&c, 1); - c = (c % BN_BITS) - BN_BITS2; - BN_rand(a, NUM_BITS + c, 0, 0); - - arc4random_buf(&c, 1); - c = (c % BN_BITS) - BN_BITS2; - BN_rand(b, NUM_BITS + c, 0, 0); - - arc4random_buf(&c, 1); - c = (c % BN_BITS) - BN_BITS2; - BN_rand(m, NUM_BITS + c, 0, 1); - - BN_mod(a, a, m, ctx); - BN_mod(b, b, m, ctx); - - ret = BN_mod_exp_mont(r_mont, a, b, m, ctx, NULL); - if (ret <= 0) { - printf("BN_mod_exp_mont() problems\n"); - goto err; - } - - ret = BN_mod_exp_mont_ct(r_mont_ct, a, b, m, ctx, NULL); - if (ret <= 0) { - printf("BN_mod_exp_mont_ct() problems\n"); - goto err; - } - - ret = BN_mod_exp_mont_nonct(r_mont_nonct, a, b, m, ctx, NULL); - if (ret <= 0) { - printf("BN_mod_exp_mont_nonct() problems\n"); - goto err; - } - - ret = BN_mod_exp_recp(r_recp, a, b, m, ctx); - if (ret <= 0) { - printf("BN_mod_exp_recp() problems\n"); - goto err; - } - - ret = BN_mod_exp_simple(r_simple, a, b, m, ctx); - if (ret <= 0) { - printf("BN_mod_exp_simple() problems\n"); - goto err; - } - - ret = BN_mod_exp_mont_consttime(r_mont_const, a, b, m, ctx, NULL); - if (ret <= 0) { - printf("BN_mod_exp_mont_consttime() problems\n"); - goto err; - } - - if (BN_cmp(r_simple, r_mont) == 0 && - BN_cmp(r_simple, r_recp) == 0 && - BN_cmp(r_simple, r_mont_const) == 0) { - printf("."); - fflush(stdout); - } else { - if (BN_cmp(r_simple, r_mont) != 0) - printf("\nsimple and mont results differ\n"); - if (BN_cmp(r_simple, r_mont_const) != 0) - printf("\nsimple and mont const time results differ\n"); - if (BN_cmp(r_simple, r_recp) != 0) - printf("\nsimple and recp results differ\n"); - if (BN_cmp(r_mont, r_mont_ct) != 0) - printf("\nmont_ct and mont results differ\n"); - if (BN_cmp(r_mont_ct, r_mont_nonct) != 0) - printf("\nmont_ct and mont_nonct results differ\n"); - - printf("a (%3d) = ", BN_num_bits(a)); - BN_print(out, a); - printf("\nb (%3d) = ", BN_num_bits(b)); - BN_print(out, b); - printf("\nm (%3d) = ", BN_num_bits(m)); - BN_print(out, m); - printf("\nsimple ="); - BN_print(out, r_simple); - printf("\nrecp ="); - BN_print(out, r_recp); - printf("\nmont ="); - BN_print(out, r_mont); - printf("\nmont_ct ="); - BN_print(out, r_mont_const); - printf("\n"); - exit(1); - } - } - BN_free(r_mont); - BN_free(r_mont_const); - BN_free(r_mont_ct); - BN_free(r_mont_nonct); - BN_free(r_recp); - BN_free(r_simple); - BN_free(a); - BN_free(b); - BN_free(m); - BN_CTX_free(ctx); - ERR_remove_thread_state(NULL); - CRYPTO_mem_leaks(out); - BIO_free(out); - printf("\n"); - - if (test_exp_mod_zero() != 0) - goto err; - - printf("done\n"); - - return (0); - - err: - ERR_load_crypto_strings(); - ERR_print_errors(out); - return (1); -} diff --git a/tests/freenull.c b/tests/freenull.c index 17c3f339..c477aff9 100644 --- a/tests/freenull.c +++ b/tests/freenull.c @@ -102,6 +102,7 @@ main(int argc, char **argv) ESS_SIGNING_CERT_free(NULL); EVP_AEAD_CTX_free(NULL); EVP_CIPHER_CTX_free(NULL); + EVP_CIPHER_meth_free(NULL); EVP_ENCODE_CTX_free(NULL); EVP_MD_CTX_free(NULL); EVP_MD_meth_free(NULL); diff --git a/tests/handshake_table.c b/tests/handshake_table.c index 85dff0c5..1db40d5a 100644 --- a/tests/handshake_table.c +++ b/tests/handshake_table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: handshake_table.c,v 1.17 2022/03/08 16:59:25 tb Exp $ */ +/* $OpenBSD: handshake_table.c,v 1.18 2022/12/01 13:49:12 tb Exp $ */ /* * Copyright (c) 2019 Theo Buehler * @@ -548,8 +548,5 @@ main(int argc, char *argv[]) if (!verify_table(hs_table, print)) return 1; - if (!print) - printf("SUCCESS\n"); - return 0; } diff --git a/tests/key_schedule.c b/tests/key_schedule.c index 2746bb59..f937d042 100644 --- a/tests/key_schedule.c +++ b/tests/key_schedule.c @@ -1,4 +1,4 @@ -/* $OpenBSD: key_schedule.c,v 1.9 2019/11/18 02:09:58 beck Exp $ */ +/* $OpenBSD: key_schedule.c,v 1.10 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2018-2019 Bob Beck * @@ -17,7 +17,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" #include "bytestring.h" #include "ssl_tlsext.h" diff --git a/tests/rc2_test.c b/tests/rc2_test.c index ab95e587..2e503c5c 100644 --- a/tests/rc2_test.c +++ b/tests/rc2_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc2_test.c,v 1.5 2022/09/12 13:11:36 tb Exp $ */ +/* $OpenBSD: rc2_test.c,v 1.6 2022/11/09 12:13:08 joshua Exp $ */ /* * Copyright (c) 2022 Joshua Sing * @@ -724,7 +724,7 @@ rc2_evp_test(size_t test_number, const struct rc2_test *rt, const char *label, } for (i = 0; i < rt->in_len;) { - in_len = arc4random_uniform(sizeof(rt->in_len) / 2); + in_len = arc4random_uniform(rt->in_len / 2); if (in_len > rt->in_len - i) in_len = rt->in_len - i; @@ -804,7 +804,7 @@ rc2_evp_test(size_t test_number, const struct rc2_test *rt, const char *label, } for (i = 0; i < rt->out_len;) { - in_len = arc4random_uniform(sizeof(rt->out_len) / 2); + in_len = arc4random_uniform(rt->out_len / 2); if (in_len > rt->out_len - i) in_len = rt->out_len - i; diff --git a/tests/rc4_test.c b/tests/rc4_test.c index 4f5ea626..fc4c65ff 100644 --- a/tests/rc4_test.c +++ b/tests/rc4_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc4_test.c,v 1.5 2022/09/12 04:26:38 tb Exp $ */ +/* $OpenBSD: rc4_test.c,v 1.6 2022/11/09 12:10:17 joshua Exp $ */ /* * Copyright (c) 2022 Joshua Sing * @@ -377,7 +377,7 @@ rc4_test(void) } for (j = 0; j < rt->len;) { - in_len = arc4random_uniform(sizeof(rt->len) / 2); + in_len = arc4random_uniform(rt->len / 2); if (in_len > rt->len - j) in_len = rt->len - j; @@ -423,7 +423,7 @@ rc4_test(void) } for (j = 0; j < rt->len;) { - in_len = arc4random_uniform(sizeof(rt->len) / 2); + in_len = arc4random_uniform(rt->len / 2); if (in_len > rt->len - j) in_len = rt->len - j; diff --git a/tests/record_layer_test.c b/tests/record_layer_test.c index 95f13b8c..2db0c10f 100644 --- a/tests/record_layer_test.c +++ b/tests/record_layer_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: record_layer_test.c,v 1.5 2022/06/10 22:00:15 tb Exp $ */ +/* $OpenBSD: record_layer_test.c,v 1.6 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2019, 2020 Joel Sing * @@ -18,7 +18,7 @@ #include #include -#include "ssl_locl.h" +#include "ssl_local.h" #include "tls13_internal.h" #include "tls13_record.h" diff --git a/tests/ssl_versions.c b/tests/ssl_versions.c index 8a636055..261bed3a 100644 --- a/tests/ssl_versions.c +++ b/tests/ssl_versions.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_versions.c,v 1.17 2022/02/08 19:06:56 tb Exp $ */ +/* $OpenBSD: ssl_versions.c,v 1.19 2022/11/26 16:08:57 tb Exp $ */ /* * Copyright (c) 2016, 2017 Joel Sing * @@ -17,7 +17,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" struct version_range_test { const long options; @@ -214,8 +214,8 @@ test_ssl_enabled_version_range(void) SSL_set_options(ssl, vrt->options); minver = maxver = 0xffff; - ssl->internal->min_tls_version = vrt->minver; - ssl->internal->max_tls_version = vrt->maxver; + ssl->min_tls_version = vrt->minver; + ssl->max_tls_version = vrt->maxver; if (ssl_enabled_tls_version_range(ssl, &minver, &maxver) != 1) { if (vrt->want_minver != 0 || vrt->want_maxver != 0) { @@ -516,8 +516,8 @@ test_ssl_max_shared_version(void) SSL_set_options(ssl, svt->options); maxver = 0; - ssl->internal->min_tls_version = svt->minver; - ssl->internal->max_tls_version = svt->maxver; + ssl->min_tls_version = svt->minver; + ssl->max_tls_version = svt->maxver; if (!ssl_max_shared_version(ssl, svt->peerver, &maxver)) { if (svt->want_maxver != 0) { diff --git a/tests/ssltest.c b/tests/ssltest.c index ff5a584d..8aae9901 100644 --- a/tests/ssltest.c +++ b/tests/ssltest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssltest.c,v 1.35 2022/07/07 13:10:22 tb Exp $ */ +/* $OpenBSD: ssltest.c,v 1.37 2023/02/02 12:37:14 anton Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -176,7 +176,7 @@ #include #include -#include "ssl_locl.h" +#include "ssl_local.h" #define TEST_SERVER_CERT "../apps/server.pem" #define TEST_CLIENT_CERT "../apps/client.pem" @@ -1855,7 +1855,7 @@ app_verify_callback(X509_STORE_CTX *ctx, void *arg) * (The second function has been renamed to avoid name conflicts.) */ static DH * -get_dh1024() +get_dh1024(void) { static unsigned char dh1024_p[] = { 0xF8, 0x81, 0x89, 0x7D, 0x14, 0x24, 0xC5, 0xD1, 0xE6, 0xF7, 0xBF, 0x3A, @@ -1897,7 +1897,7 @@ get_dh1024() } static DH * -get_dh1024dsa() +get_dh1024dsa(void) { static unsigned char dh1024_p[] = { 0xC8, 0x00, 0xF7, 0x08, 0x07, 0x89, 0x4D, 0x90, 0x53, 0xF3, 0xD5, 0x00, diff --git a/tests/tls_ext_alpn.c b/tests/tls_ext_alpn.c index 378929aa..d00f3efb 100644 --- a/tests/tls_ext_alpn.c +++ b/tests/tls_ext_alpn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_ext_alpn.c,v 1.7 2020/07/03 04:14:10 tb Exp $ */ +/* $OpenBSD: tls_ext_alpn.c,v 1.9 2022/11/26 16:08:57 tb Exp $ */ /* * Copyright (c) 2015 Doug Hogan * @@ -21,7 +21,7 @@ #include #include -#include "ssl_locl.h" +#include "ssl_local.h" #include "ssl_tlsext.h" #include "tests.h" @@ -344,8 +344,8 @@ check_valid_alpn(SSL *s) SSL_CTX_set_alpn_select_cb(s->ctx, dummy_alpn_cb, NULL); /* Prerequisites to test these. */ - CHECK(s->internal->alpn_client_proto_list != NULL); - CHECK(s->ctx->internal->alpn_select_cb != NULL); + CHECK(s->alpn_client_proto_list != NULL); + CHECK(s->ctx->alpn_select_cb != NULL); //CHECK(s->s3->tmp.finish_md_len == 0); CHECK_BOTH(1, 1, proto_single); @@ -376,8 +376,8 @@ check_invalid_alpn(SSL *s) SSL_CTX_set_alpn_select_cb(s->ctx, dummy_alpn_cb, NULL); /* Prerequisites to test these. */ - CHECK(s->internal->alpn_client_proto_list != NULL); - CHECK(s->ctx->internal->alpn_select_cb != NULL); + CHECK(s->alpn_client_proto_list != NULL); + CHECK(s->ctx->alpn_select_cb != NULL); //CHECK(s->s3->tmp.finish_md_len == 0); /* None of these are valid for client or server */ diff --git a/tests/tls_prf.c b/tests/tls_prf.c index bf0de1f0..a22d0e70 100644 --- a/tests/tls_prf.c +++ b/tests/tls_prf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_prf.c,v 1.7 2022/06/10 22:00:15 tb Exp $ */ +/* $OpenBSD: tls_prf.c,v 1.8 2022/11/26 16:08:57 tb Exp $ */ /* * Copyright (c) 2017 Joel Sing * @@ -17,7 +17,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" int tls1_PRF(SSL *s, const unsigned char *secret, size_t secret_len, const void *seed1, size_t seed1_len, const void *seed2, size_t seed2_len, diff --git a/tests/tlsexttest.c b/tests/tlsexttest.c index f75c70ef..5f781e52 100644 --- a/tests/tlsexttest.c +++ b/tests/tlsexttest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tlsexttest.c,v 1.75 2022/08/21 19:46:19 jsing Exp $ */ +/* $OpenBSD: tlsexttest.c,v 1.79 2022/11/26 16:08:57 tb Exp $ */ /* * Copyright (c) 2017 Joel Sing * Copyright (c) 2017 Doug Hogan @@ -22,7 +22,7 @@ #include -#include "ssl_locl.h" +#include "ssl_local.h" #include "bytestring.h" #include "ssl_tlsext.h" @@ -187,7 +187,7 @@ test_tlsext_alpn_client(void) /* * Prereqs: - * 1) Set s->internal->alpn_client_proto_list + * 1) Set s->alpn_client_proto_list * - Using SSL_set_alpn_protos() * 2) We have not finished or renegotiated. * - s->s3->tmp.finish_md_len == 0 @@ -245,18 +245,18 @@ test_tlsext_alpn_client(void) goto err; } - if (ssl->internal->alpn_client_proto_list_len != + if (ssl->alpn_client_proto_list_len != sizeof(tlsext_alpn_single_proto_val)) { FAIL("got client ALPN with length %zu, " "want length %zu\n", dlen, sizeof(tlsext_alpn_single_proto_val)); - compare_data(ssl->internal->alpn_client_proto_list, - ssl->internal->alpn_client_proto_list_len, + compare_data(ssl->alpn_client_proto_list, + ssl->alpn_client_proto_list_len, tlsext_alpn_single_proto_val, sizeof(tlsext_alpn_single_proto_val)); goto err; } - if (memcmp(ssl->internal->alpn_client_proto_list, + if (memcmp(ssl->alpn_client_proto_list, tlsext_alpn_single_proto_val, sizeof(tlsext_alpn_single_proto_val)) != 0) { FAIL("client ALPN differs:\n"); @@ -312,18 +312,18 @@ test_tlsext_alpn_client(void) goto err; } - if (ssl->internal->alpn_client_proto_list_len != + if (ssl->alpn_client_proto_list_len != sizeof(tlsext_alpn_multiple_protos_val)) { FAIL("got client ALPN with length %zu, " "want length %zu\n", dlen, sizeof(tlsext_alpn_multiple_protos_val)); - compare_data(ssl->internal->alpn_client_proto_list, - ssl->internal->alpn_client_proto_list_len, + compare_data(ssl->alpn_client_proto_list, + ssl->alpn_client_proto_list_len, tlsext_alpn_multiple_protos_val, sizeof(tlsext_alpn_multiple_protos_val)); goto err; } - if (memcmp(ssl->internal->alpn_client_proto_list, + if (memcmp(ssl->alpn_client_proto_list, tlsext_alpn_multiple_protos_val, sizeof(tlsext_alpn_multiple_protos_val)) != 0) { FAIL("client ALPN differs:\n"); @@ -334,9 +334,9 @@ test_tlsext_alpn_client(void) /* Make sure we can remove the list and avoid ALPN */ - free(ssl->internal->alpn_client_proto_list); - ssl->internal->alpn_client_proto_list = NULL; - ssl->internal->alpn_client_proto_list_len = 0; + free(ssl->alpn_client_proto_list); + ssl->alpn_client_proto_list = NULL; + ssl->alpn_client_proto_list_len = 0; if (client_funcs->needs(ssl, SSL_TLSEXT_MSG_CH)) { FAIL("client should need ALPN by default\n"); @@ -517,7 +517,7 @@ test_tlsext_alpn_server(void) * This extension is only used by the client. */ -static uint8_t tlsext_supportedgroups_client_default[] = { +static const uint8_t tlsext_supportedgroups_client_default[] = { 0x00, 0x08, 0x00, 0x1d, /* X25519 (29) */ 0x00, 0x17, /* secp256r1 (23) */ @@ -525,20 +525,20 @@ static uint8_t tlsext_supportedgroups_client_default[] = { 0x00, 0x19, /* secp521r1 (25) */ }; -static uint16_t tlsext_supportedgroups_client_secp384r1_val[] = { +static const uint16_t tlsext_supportedgroups_client_secp384r1_val[] = { 0x0018 /* tls1_ec_nid2group_id(NID_secp384r1) */ }; -static uint8_t tlsext_supportedgroups_client_secp384r1[] = { +static const uint8_t tlsext_supportedgroups_client_secp384r1[] = { 0x00, 0x02, 0x00, 0x18 /* secp384r1 (24) */ }; /* Example from RFC 4492 section 5.1.1 */ -static uint16_t tlsext_supportedgroups_client_nistp192and224_val[] = { +static const uint16_t tlsext_supportedgroups_client_nistp192and224_val[] = { 0x0013, /* tls1_ec_nid2group_id(NID_X9_62_prime192v1) */ 0x0015 /* tls1_ec_nid2group_id(NID_secp224r1) */ }; -static uint8_t tlsext_supportedgroups_client_nistp192and224[] = { +static const uint8_t tlsext_supportedgroups_client_nistp192and224[] = { 0x00, 0x04, 0x00, 0x13, /* secp192r1 aka NIST P-192 */ 0x00, 0x15 /* secp224r1 aka NIST P-224 */ @@ -703,17 +703,17 @@ test_tlsext_supportedgroups_client(void) if ((ssl->session = SSL_SESSION_new()) == NULL) errx(1, "failed to create session"); - if ((ssl->internal->tlsext_supportedgroups = malloc(sizeof(uint16_t) * 2)) == NULL) { + if ((ssl->tlsext_supportedgroups = malloc(sizeof(uint16_t) * 2)) == NULL) { FAIL("client could not malloc\n"); goto err; } if (!tls1_ec_nid2group_id(NID_X9_62_prime192v1, - &ssl->internal->tlsext_supportedgroups[0])) + &ssl->tlsext_supportedgroups[0])) goto err; if (!tls1_ec_nid2group_id(NID_secp224r1, - &ssl->internal->tlsext_supportedgroups[1])) + &ssl->tlsext_supportedgroups[1])) goto err; - ssl->internal->tlsext_supportedgroups_length = 2; + ssl->tlsext_supportedgroups_length = 2; if (!client_funcs->needs(ssl, SSL_TLSEXT_MSG_CH)) { FAIL("client should need Ellipticcurves\n"); @@ -764,9 +764,9 @@ test_tlsext_supportedgroups_client(void) errx(1, "failed to create session"); /* Reset back to the default list. */ - free(ssl->internal->tlsext_supportedgroups); - ssl->internal->tlsext_supportedgroups = NULL; - ssl->internal->tlsext_supportedgroups_length = 0; + free(ssl->tlsext_supportedgroups); + ssl->tlsext_supportedgroups = NULL; + ssl->tlsext_supportedgroups_length = 0; CBS_init(&cbs, tlsext_supportedgroups_client_nistp192and224, sizeof(tlsext_supportedgroups_client_nistp192and224)); @@ -859,25 +859,25 @@ test_tlsext_supportedgroups_server(void) * parse but the needs differ. */ -static uint8_t tlsext_ecpf_hello_uncompressed_val[] = { +static const uint8_t tlsext_ecpf_hello_uncompressed_val[] = { TLSEXT_ECPOINTFORMAT_uncompressed }; -static uint8_t tlsext_ecpf_hello_uncompressed[] = { +static const uint8_t tlsext_ecpf_hello_uncompressed[] = { 0x01, 0x00 /* TLSEXT_ECPOINTFORMAT_uncompressed */ }; -static uint8_t tlsext_ecpf_hello_prime[] = { +static const uint8_t tlsext_ecpf_hello_prime[] = { 0x01, 0x01 /* TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime */ }; -static uint8_t tlsext_ecpf_hello_prefer_order_val[] = { +static const uint8_t tlsext_ecpf_hello_prefer_order_val[] = { TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime, TLSEXT_ECPOINTFORMAT_uncompressed, TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 }; -static uint8_t tlsext_ecpf_hello_prefer_order[] = { +static const uint8_t tlsext_ecpf_hello_prefer_order[] = { 0x03, 0x01, /* TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime */ 0x00, /* TLSEXT_ECPOINTFORMAT_uncompressed */ @@ -1025,14 +1025,14 @@ test_tlsext_ecpf_client(void) if ((ssl->session = SSL_SESSION_new()) == NULL) errx(1, "failed to create session"); - if ((ssl->internal->tlsext_ecpointformatlist = malloc(sizeof(uint8_t) * 3)) == NULL) { + if ((ssl->tlsext_ecpointformatlist = malloc(sizeof(uint8_t) * 3)) == NULL) { FAIL("client could not malloc\n"); goto err; } - ssl->internal->tlsext_ecpointformatlist[0] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime; - ssl->internal->tlsext_ecpointformatlist[1] = TLSEXT_ECPOINTFORMAT_uncompressed; - ssl->internal->tlsext_ecpointformatlist[2] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2; - ssl->internal->tlsext_ecpointformatlist_length = 3; + ssl->tlsext_ecpointformatlist[0] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime; + ssl->tlsext_ecpointformatlist[1] = TLSEXT_ECPOINTFORMAT_uncompressed; + ssl->tlsext_ecpointformatlist[2] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2; + ssl->tlsext_ecpointformatlist_length = 3; if (!client_funcs->needs(ssl, SSL_TLSEXT_MSG_CH)) { FAIL("client should need ECPointFormats with a custom " @@ -1078,9 +1078,9 @@ test_tlsext_ecpf_client(void) errx(1, "failed to create session"); /* Reset the custom list so we go back to the default uncompressed. */ - free(ssl->internal->tlsext_ecpointformatlist); - ssl->internal->tlsext_ecpointformatlist = NULL; - ssl->internal->tlsext_ecpointformatlist_length = 0; + free(ssl->tlsext_ecpointformatlist); + ssl->tlsext_ecpointformatlist = NULL; + ssl->tlsext_ecpointformatlist_length = 0; CBS_init(&cbs, tlsext_ecpf_hello_prefer_order, sizeof(tlsext_ecpf_hello_prefer_order)); @@ -1244,14 +1244,14 @@ test_tlsext_ecpf_server(void) ssl->session->tlsext_ecpointformatlist_length = 1; /* Replace the default list with a custom one. */ - if ((ssl->internal->tlsext_ecpointformatlist = malloc(sizeof(uint8_t) * 3)) == NULL) { + if ((ssl->tlsext_ecpointformatlist = malloc(sizeof(uint8_t) * 3)) == NULL) { FAIL("server could not malloc\n"); goto err; } - ssl->internal->tlsext_ecpointformatlist[0] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime; - ssl->internal->tlsext_ecpointformatlist[1] = TLSEXT_ECPOINTFORMAT_uncompressed; - ssl->internal->tlsext_ecpointformatlist[2] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2; - ssl->internal->tlsext_ecpointformatlist_length = 3; + ssl->tlsext_ecpointformatlist[0] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime; + ssl->tlsext_ecpointformatlist[1] = TLSEXT_ECPOINTFORMAT_uncompressed; + ssl->tlsext_ecpointformatlist[2] = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2; + ssl->tlsext_ecpointformatlist_length = 3; if (!server_funcs->needs(ssl, SSL_TLSEXT_MSG_SH)) { FAIL("server should need ECPointFormats\n"); @@ -1296,9 +1296,9 @@ test_tlsext_ecpf_server(void) errx(1, "failed to create session"); /* Reset back to the default (uncompressed) */ - free(ssl->internal->tlsext_ecpointformatlist); - ssl->internal->tlsext_ecpointformatlist = NULL; - ssl->internal->tlsext_ecpointformatlist_length = 0; + free(ssl->tlsext_ecpointformatlist); + ssl->tlsext_ecpointformatlist = NULL; + ssl->tlsext_ecpointformatlist_length = 0; CBS_init(&cbs, tlsext_ecpf_hello_prefer_order, sizeof(tlsext_ecpf_hello_prefer_order)); @@ -1340,23 +1340,23 @@ test_tlsext_ecpf_server(void) * Renegotiation Indication - RFC 5746. */ -static unsigned char tlsext_ri_prev_client[] = { +static const unsigned char tlsext_ri_prev_client[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, }; -static unsigned char tlsext_ri_prev_server[] = { +static const unsigned char tlsext_ri_prev_server[] = { 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00, }; -static unsigned char tlsext_ri_client[] = { +static const unsigned char tlsext_ri_client[] = { 0x10, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, }; -static unsigned char tlsext_ri_server[] = { +static const unsigned char tlsext_ri_server[] = { 0x20, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, @@ -1608,7 +1608,7 @@ test_tlsext_ri_server(void) * Signature Algorithms - RFC 5246 section 7.4.1.4.1. */ -static unsigned char tlsext_sigalgs_client[] = { +static const unsigned char tlsext_sigalgs_client[] = { 0x00, 0x16, 0x08, 0x06, 0x06, 0x01, 0x06, 0x03, 0x08, 0x05, 0x05, 0x01, 0x05, 0x03, 0x08, 0x04, 0x04, 0x01, 0x04, 0x03, 0x02, 0x01, 0x02, 0x03, @@ -1766,13 +1766,13 @@ test_tlsext_sigalgs_server(void) #define TEST_SNI_SERVERNAME "www.libressl.org" -static unsigned char tlsext_sni_client[] = { +static const unsigned char tlsext_sni_client[] = { 0x00, 0x13, 0x00, 0x00, 0x10, 0x77, 0x77, 0x77, 0x2e, 0x6c, 0x69, 0x62, 0x72, 0x65, 0x73, 0x73, 0x6c, 0x2e, 0x6f, 0x72, 0x67, }; -static unsigned char tlsext_sni_server[] = { +static const unsigned char tlsext_sni_server[] = { 0x00 }; const size_t sizeof_tlsext_sni_server = 0; @@ -1864,7 +1864,7 @@ test_tlsext_sni_client(void) goto err; } - ssl->internal->hit = 0; + ssl->hit = 0; CBS_init(&cbs, tlsext_sni_client, sizeof(tlsext_sni_client)); if (!server_funcs->parse(ssl, SSL_TLSEXT_MSG_CH, &cbs, &alert)) { @@ -1889,7 +1889,7 @@ test_tlsext_sni_client(void) goto err; } - ssl->internal->hit = 1; + ssl->hit = 1; free(ssl->session->tlsext_hostname); if ((ssl->session->tlsext_hostname = strdup("notthesame.libressl.org")) == @@ -2030,9 +2030,7 @@ test_tlsext_sni_server(void) * QUIC transport parameters extension - RFC 90210 :) */ -#define TEST_QUIC_TRANSPORT_DATA "0123456789abcdef" - -static unsigned char tlsext_quic_transport_data[] = { +static const unsigned char tlsext_quic_transport_data[] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, }; @@ -2074,7 +2072,7 @@ test_tlsext_quic_transport_parameters_client(void) } if (!SSL_set_quic_transport_params(ssl, - TEST_QUIC_TRANSPORT_DATA, strlen(TEST_QUIC_TRANSPORT_DATA))) { + tlsext_quic_transport_data, sizeof(tlsext_quic_transport_data))) { FAIL("client failed to set QUIC parametes\n"); goto err; } @@ -2140,14 +2138,14 @@ test_tlsext_quic_transport_parameters_client(void) SSL_get_peer_quic_transport_params(ssl, &out_bytes, &out_bytes_len); - if (out_bytes_len != strlen(TEST_QUIC_TRANSPORT_DATA)) { + if (out_bytes_len != sizeof(tlsext_quic_transport_data)) { FAIL("server_parse QUIC length differs, got %zu want %zu\n", out_bytes_len, sizeof(tlsext_quic_transport_data)); goto err; } - if (memcmp(out_bytes, TEST_QUIC_TRANSPORT_DATA, + if (memcmp(out_bytes, tlsext_quic_transport_data, out_bytes_len) != 0) { FAIL("server_parse QUIC differs from sent:\n"); fprintf(stderr, "received:\n"); @@ -2206,7 +2204,7 @@ test_tlsext_quic_transport_parameters_server(void) } if (!SSL_set_quic_transport_params(ssl, - TEST_QUIC_TRANSPORT_DATA, strlen(TEST_QUIC_TRANSPORT_DATA))) { + tlsext_quic_transport_data, sizeof(tlsext_quic_transport_data))) { FAIL("server failed to set QUIC parametes\n"); goto err; } @@ -2270,14 +2268,14 @@ test_tlsext_quic_transport_parameters_server(void) SSL_get_peer_quic_transport_params(ssl, &out_bytes, &out_bytes_len); - if (out_bytes_len != strlen(TEST_QUIC_TRANSPORT_DATA)) { + if (out_bytes_len != sizeof(tlsext_quic_transport_data)) { FAIL("client QUIC length differs, got %zu want %zu\n", out_bytes_len, sizeof(tlsext_quic_transport_data)); goto err; } - if (memcmp(out_bytes, TEST_QUIC_TRANSPORT_DATA, out_bytes_len) != 0) { + if (memcmp(out_bytes, tlsext_quic_transport_data, out_bytes_len) != 0) { FAIL("client QUIC differs from sent:\n"); fprintf(stderr, "received:\n"); hexdump(data, dlen); @@ -2298,7 +2296,7 @@ test_tlsext_quic_transport_parameters_server(void) return (failure); } -static unsigned char tls_ocsp_client_default[] = { +static const unsigned char tls_ocsp_client_default[] = { 0x01, 0x00, 0x00, 0x00, 0x00 }; @@ -2415,7 +2413,7 @@ test_tlsext_ocsp_server(void) goto err; } - ssl->internal->tlsext_status_expected = 1; + ssl->tlsext_status_expected = 1; if (!server_funcs->needs(ssl, SSL_TLSEXT_MSG_SH)) { FAIL("server should need TLSEXT_TYPE_status_request\n"); @@ -2618,8 +2616,8 @@ test_tlsext_sessionticket_client(void) * If you want to remove the tlsext_session_ticket behavior, you have * to do it manually. */ - free(ssl->internal->tlsext_session_ticket); - ssl->internal->tlsext_session_ticket = NULL; + free(ssl->tlsext_session_ticket); + ssl->tlsext_session_ticket = NULL; if (!client_funcs->needs(ssl, SSL_TLSEXT_MSG_CH)) { FAIL("Should need a session ticket again when the custom one is removed\n"); @@ -2726,7 +2724,7 @@ test_tlsext_sessionticket_server(void) } /* Set expected to require it. */ - ssl->internal->tlsext_ticket_expected = 1; + ssl->tlsext_ticket_expected = 1; if (!server_funcs->needs(ssl, SSL_TLSEXT_MSG_SH)) { FAIL("server should now be required for SessionTicket\n"); goto err; @@ -2953,7 +2951,7 @@ test_tlsext_srtp_client(void) /* Make sure we can parse multiple profiles (selects server preferred) */ - ssl->internal->srtp_profile = NULL; + ssl->srtp_profile = NULL; CBS_init(&cbs, tlsext_srtp_multiple, sizeof(tlsext_srtp_multiple)); @@ -2984,7 +2982,7 @@ test_tlsext_srtp_client(void) * Make sure we can parse the clienthello with multiple entries * where one is unknown. */ - ssl->internal->srtp_profile = NULL; + ssl->srtp_profile = NULL; CBS_init(&cbs, tlsext_srtp_multiple_one_valid, sizeof(tlsext_srtp_multiple_one_valid)); @@ -3013,7 +3011,7 @@ test_tlsext_srtp_client(void) /* Make sure we fall back to negotiated when none work. */ - ssl->internal->srtp_profile = NULL; + ssl->srtp_profile = NULL; CBS_init(&cbs, tlsext_srtp_multiple_invalid, sizeof(tlsext_srtp_multiple_invalid)); @@ -3087,7 +3085,7 @@ test_tlsext_srtp_server(void) FAIL("should be able to find the given profile\n"); goto err; } - ssl->internal->srtp_profile = prof; + ssl->srtp_profile = prof; if (!server_funcs->needs(ssl, SSL_TLSEXT_MSG_SH)) { FAIL("server should need SRTP by now\n"); goto err; @@ -3124,7 +3122,7 @@ test_tlsext_srtp_server(void) data = NULL; /* Make sure we can parse the single profile. */ - ssl->internal->srtp_profile = NULL; + ssl->srtp_profile = NULL; if (SSL_get_selected_srtp_profile(ssl) != NULL) { FAIL("SRTP profile should not be set yet\n"); @@ -3157,7 +3155,7 @@ test_tlsext_srtp_server(void) } /* Make sure we cannot parse multiple profiles */ - ssl->internal->srtp_profile = NULL; + ssl->srtp_profile = NULL; CBS_init(&cbs, tlsext_srtp_multiple, sizeof(tlsext_srtp_multiple)); @@ -3167,7 +3165,7 @@ test_tlsext_srtp_server(void) } /* Make sure we cannot parse a server with unknown profile */ - ssl->internal->srtp_profile = NULL; + ssl->srtp_profile = NULL; CBS_init(&cbs, tlsext_srtp_single_invalid, sizeof(tlsext_srtp_single_invalid)); @@ -3390,8 +3388,8 @@ test_tlsext_serverhello_build(void) ssl->s3->send_connection_binding = 1; ssl->s3->hs.cipher = ssl3_get_cipher_by_id(TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256); - ssl->internal->tlsext_status_expected = 1; - ssl->internal->tlsext_ticket_expected = 1; + ssl->tlsext_status_expected = 1; + ssl->tlsext_ticket_expected = 1; if ((ssl->session->tlsext_ecpointformatlist = malloc(1)) == NULL) { FAIL("malloc failed"); goto err; diff --git a/tests/tlslegacytest.c b/tests/tlslegacytest.c index f18b0eea..59429d71 100644 --- a/tests/tlslegacytest.c +++ b/tests/tlslegacytest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tlslegacytest.c,v 1.6 2022/06/10 22:00:15 tb Exp $ */ +/* $OpenBSD: tlslegacytest.c,v 1.7 2022/10/02 16:39:39 jsing Exp $ */ /* * Copyright (c) 2015, 2016, 2017, 2020 Joel Sing * @@ -17,10 +17,6 @@ #include -#include -#include -#include - #include #include #include diff --git a/tests/utf8test.c b/tests/utf8test.c index e3a47d5a..26477e88 100644 --- a/tests/utf8test.c +++ b/tests/utf8test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utf8test.c,v 1.4 2018/07/17 17:06:50 tb Exp $ */ +/* $OpenBSD: utf8test.c,v 1.5 2022/11/26 16:08:56 tb Exp $ */ /* * Copyright (c) 2014 Philip Guenther * @@ -24,7 +24,7 @@ #include #include -#include "asn1_locl.h" /* peek into the internals */ +#include "asn1_local.h" /* peek into the internals */ #define UNCHANGED 0xfedcba98 diff --git a/tests/valid_handshakes_terminate.c b/tests/valid_handshakes_terminate.c index 5f0e4f2c..286b860a 100644 --- a/tests/valid_handshakes_terminate.c +++ b/tests/valid_handshakes_terminate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: valid_handshakes_terminate.c,v 1.3 2019/04/05 20:25:42 tb Exp $ */ +/* $OpenBSD: valid_handshakes_terminate.c,v 1.4 2022/12/01 13:49:12 tb Exp $ */ /* * Copyright (c) 2019 Theo Buehler * @@ -50,8 +50,5 @@ main(int argc, char *argv[]) } } - if (!fail) - printf("SUCCESS\n"); - return fail; } diff --git a/tests/x25519test.c b/tests/x25519test.c index 02da807b..321aac4d 100644 --- a/tests/x25519test.c +++ b/tests/x25519test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x25519test.c,v 1.2 2018/07/17 17:06:49 tb Exp $ */ +/* $OpenBSD: x25519test.c,v 1.3 2022/12/01 13:55:22 tb Exp $ */ /* * Copyright (c) 2015, Google Inc. * @@ -67,16 +67,16 @@ x25519_test(void) X25519(out, kScalar1, kPoint1); if (memcmp(kExpected1, out, sizeof(out)) != 0) { fprintf(stderr, "X25519 test one failed.\n"); - return 0; + return 1; } X25519(out, kScalar2, kPoint2); if (memcmp(kExpected2, out, sizeof(out)) != 0) { fprintf(stderr, "X25519 test two failed.\n"); - return 0; + return 1; } - return 1; + return 0; } static int @@ -101,10 +101,10 @@ x25519_iterated_test(void) if (memcmp(kExpected, scalar, sizeof(kExpected)) != 0) { fprintf(stderr, "Iterated X25519 test failed\n"); - return 0; + return 1; } - return 1; + return 0; } static int @@ -122,19 +122,20 @@ x25519_small_order_test(void) memset(private_key, 0x11, sizeof(private_key)); if (X25519(out, private_key, kSmallOrderPoint)) { fprintf(stderr, "X25519 returned success with a small-order input.\n"); - return 0; + return 1; } - return 1; + return 0; } int -main(int argc, char **argv) { - if (!x25519_test() || - !x25519_iterated_test() || - !x25519_small_order_test()) - return 1; +main(int argc, char **argv) +{ + int failed = 0; - printf("PASS\n"); - return 0; + failed |= x25519_test(); + failed |= x25519_iterated_test(); + failed |= x25519_small_order_test(); + + return failed; } diff --git a/tls/CMakeLists.txt b/tls/CMakeLists.txt index 7827a5eb..62dde630 100644 --- a/tls/CMakeLists.txt +++ b/tls/CMakeLists.txt @@ -48,7 +48,7 @@ target_include_directories(tls_obj ../include) add_library(tls $ $ - $) + $ empty.c) export_symbol(tls ${CMAKE_CURRENT_BINARY_DIR}/tls.sym) target_link_libraries(tls ${PLATFORM_LIBS}) diff --git a/tls/Makefile.am b/tls/Makefile.am index 4d31c928..9b62b223 100644 --- a/tls/Makefile.am +++ b/tls/Makefile.am @@ -8,6 +8,16 @@ lib_LTLIBRARIES = libtls.la EXTRA_DIST = VERSION EXTRA_DIST += CMakeLists.txt EXTRA_DIST += tls.sym +EXTRA_DIST += empty.c + +CLEANFILES = libtls_la_objects.mk + +EXTRA_libtls_la_DEPENDENCIES = libtls_la_objects.mk + +libtls_la_objects.mk: Makefile + @echo "libtls_la_objects= $(libtls_la_OBJECTS)" \ + | sed 's/ */ $$\(abs_top_builddir\)\/tls\//g' \ + > libtls_la_objects.mk libtls_la_LDFLAGS = -version-info @LIBTLS_VERSION@ -no-undefined -export-symbols $(top_srcdir)/tls/tls.sym libtls_la_LIBADD = $(libcrypto_la_objects) diff --git a/tls/Makefile.in b/tls/Makefile.in index 17a39f28..122c4ff0 100644 --- a/tls/Makefile.in +++ b/tls/Makefile.in @@ -369,11 +369,13 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/include/compat \ - -DLIBRESSL_INTERNAL -D__BEGIN_HIDDEN_DECLS= \ - -D__END_HIDDEN_DECLS= +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(abs_top_builddir)/include \ + -I$(top_srcdir)/include/compat -DLIBRESSL_INTERNAL \ + -D__BEGIN_HIDDEN_DECLS= -D__END_HIDDEN_DECLS= lib_LTLIBRARIES = libtls.la -EXTRA_DIST = VERSION CMakeLists.txt tls.sym +EXTRA_DIST = VERSION CMakeLists.txt tls.sym empty.c +CLEANFILES = libtls_la_objects.mk +EXTRA_libtls_la_DEPENDENCIES = libtls_la_objects.mk libtls_la_LDFLAGS = -version-info @LIBTLS_VERSION@ -no-undefined -export-symbols $(top_srcdir)/tls/tls.sym libtls_la_LIBADD = $(libcrypto_la_objects) $(libcompat_la_objects) \ $(libcompatnoopt_la_objects) $(libssl_la_objects) \ @@ -747,6 +749,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -878,6 +881,11 @@ uninstall-am: uninstall-libLTLIBRARIES -include $(abs_top_builddir)/crypto/libcrypto_la_objects.mk -include $(abs_top_builddir)/ssl/libssl_la_objects.mk +libtls_la_objects.mk: Makefile + @echo "libtls_la_objects= $(libtls_la_OBJECTS)" \ + | sed 's/ */ $$\(abs_top_builddir\)\/tls\//g' \ + > libtls_la_objects.mk + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/tls/VERSION b/tls/VERSION index 69c99944..bc4eb718 100644 --- a/tls/VERSION +++ b/tls/VERSION @@ -1 +1 @@ -26:0:0 +26:2:0 diff --git a/tls/empty.c b/tls/empty.c new file mode 100644 index 00000000..e69de29b