diff options
author | tpashkin <tpashkin@yandex-team.ru> | 2022-02-10 16:46:42 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:42 +0300 |
commit | 656921707c02b816d730f31c1fdc1d615adbfe00 (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /contrib/libs/openssl | |
parent | 5475379a04e37df30085bd1724f1c57e3f40996f (diff) | |
download | ydb-656921707c02b816d730f31c1fdc1d615adbfe00.tar.gz |
Restoring authorship annotation for <tpashkin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/openssl')
697 files changed, 21473 insertions, 21473 deletions
diff --git a/contrib/libs/openssl/CHANGES b/contrib/libs/openssl/CHANGES index f3507a032e..824f421b8d 100644 --- a/contrib/libs/openssl/CHANGES +++ b/contrib/libs/openssl/CHANGES @@ -216,112 +216,112 @@ *) The Oracle Developer Studio compiler will start reporting deprecated APIs - Changes between 1.1.1f and 1.1.1g [21 Apr 2020] - - *) Fixed segmentation fault in SSL_check_chain() - Server or client applications that call the SSL_check_chain() function - during or after a TLS 1.3 handshake may crash due to a NULL pointer - dereference as a result of incorrect handling of the - "signature_algorithms_cert" TLS extension. The crash occurs if an invalid - or unrecognised signature algorithm is received from the peer. This could - be exploited by a malicious peer in a Denial of Service attack. - (CVE-2020-1967) - [Benjamin Kaduk] - - *) Added AES consttime code for no-asm configurations - an optional constant time support for AES was added - when building openssl for no-asm. - Enable with: ./config no-asm -DOPENSSL_AES_CONST_TIME - Disable with: ./config no-asm -DOPENSSL_NO_AES_CONST_TIME - At this time this feature is by default disabled. - It will be enabled by default in 3.0. - [Bernd Edlinger] - - Changes between 1.1.1e and 1.1.1f [31 Mar 2020] - - *) Revert the change of EOF detection while reading in libssl to avoid - regressions in applications depending on the current way of reporting - the EOF. As the existing method is not fully accurate the change to - reporting the EOF via SSL_ERROR_SSL is kept on the current development - branch and will be present in the 3.0 release. - [Tomas Mraz] - - *) Revised BN_generate_prime_ex to not avoid factors 3..17863 in p-1 - when primes for RSA keys are computed. - Since we previously always generated primes == 2 (mod 3) for RSA keys, - the 2-prime and 3-prime RSA modules were easy to distinguish, since - N = p*q = 1 (mod 3), but N = p*q*r = 2 (mod 3). Therefore fingerprinting - 2-prime vs. 3-prime RSA keys was possible by computing N mod 3. - This avoids possible fingerprinting of newly generated RSA modules. - [Bernd Edlinger] - - Changes between 1.1.1d and 1.1.1e [17 Mar 2020] - *) Properly detect EOF while reading in libssl. Previously if we hit an EOF - while reading in libssl then we would report an error back to the - application (SSL_ERROR_SYSCALL) but errno would be 0. We now add - an error to the stack (which means we instead return SSL_ERROR_SSL) and - therefore give a hint as to what went wrong. - [Matt Caswell] - - *) Check that ed25519 and ed448 are allowed by the security level. Previously - signature algorithms not using an MD were not being checked that they were - allowed by the security level. - [Kurt Roeckx] - - *) Fixed SSL_get_servername() behaviour. The behaviour of SSL_get_servername() - was not quite right. The behaviour was not consistent between resumption - and normal handshakes, and also not quite consistent with historical - behaviour. The behaviour in various scenarios has been clarified and - it has been updated to make it match historical behaviour as closely as - possible. - [Matt Caswell] - - *) [VMS only] The header files that the VMS compilers include automatically, - __DECC_INCLUDE_PROLOGUE.H and __DECC_INCLUDE_EPILOGUE.H, use pragmas that - the C++ compiler doesn't understand. This is a shortcoming in the - compiler, but can be worked around with __cplusplus guards. - - C++ applications that use OpenSSL libraries must be compiled using the - qualifier '/NAMES=(AS_IS,SHORTENED)' to be able to use all the OpenSSL - functions. Otherwise, only functions with symbols of less than 31 - characters can be used, as the linker will not be able to successfully - resolve symbols with longer names. - [Richard Levitte] - - *) Corrected the documentation of the return values from the EVP_DigestSign* - set of functions. The documentation mentioned negative values for some - errors, but this was never the case, so the mention of negative values - was removed. - - Code that followed the documentation and thereby check with something - like 'EVP_DigestSignInit(...) <= 0' will continue to work undisturbed. - [Richard Levitte] - - *) Fixed an an overflow bug in the x64_64 Montgomery squaring procedure - used in exponentiation with 512-bit moduli. No EC algorithms are - affected. Analysis suggests that attacks against 2-prime RSA1024, - 3-prime RSA1536, and DSA1024 as a result of this defect would be very - difficult to perform and are not believed likely. Attacks against DH512 - are considered just feasible. However, for an attack the target would - have to re-use the DH512 private key, which is not recommended anyway. - Also applications directly using the low level API BN_mod_exp may be - affected if they use BN_FLG_CONSTTIME. - (CVE-2019-1551) - [Andy Polyakov] - - *) Added a new method to gather entropy on VMS, based on SYS$GET_ENTROPY. - The presence of this system service is determined at run-time. - [Richard Levitte] - - *) Added newline escaping functionality to a filename when using openssl dgst. - This output format is to replicate the output format found in the '*sum' - checksum programs. This aims to preserve backward compatibility. - [Matt Eaton, Richard Levitte, and Paul Dale] - - *) Print all values for a PKCS#12 attribute with 'openssl pkcs12', not just - the first value. - [Jon Spillett] - + Changes between 1.1.1f and 1.1.1g [21 Apr 2020] + + *) Fixed segmentation fault in SSL_check_chain() + Server or client applications that call the SSL_check_chain() function + during or after a TLS 1.3 handshake may crash due to a NULL pointer + dereference as a result of incorrect handling of the + "signature_algorithms_cert" TLS extension. The crash occurs if an invalid + or unrecognised signature algorithm is received from the peer. This could + be exploited by a malicious peer in a Denial of Service attack. + (CVE-2020-1967) + [Benjamin Kaduk] + + *) Added AES consttime code for no-asm configurations + an optional constant time support for AES was added + when building openssl for no-asm. + Enable with: ./config no-asm -DOPENSSL_AES_CONST_TIME + Disable with: ./config no-asm -DOPENSSL_NO_AES_CONST_TIME + At this time this feature is by default disabled. + It will be enabled by default in 3.0. + [Bernd Edlinger] + + Changes between 1.1.1e and 1.1.1f [31 Mar 2020] + + *) Revert the change of EOF detection while reading in libssl to avoid + regressions in applications depending on the current way of reporting + the EOF. As the existing method is not fully accurate the change to + reporting the EOF via SSL_ERROR_SSL is kept on the current development + branch and will be present in the 3.0 release. + [Tomas Mraz] + + *) Revised BN_generate_prime_ex to not avoid factors 3..17863 in p-1 + when primes for RSA keys are computed. + Since we previously always generated primes == 2 (mod 3) for RSA keys, + the 2-prime and 3-prime RSA modules were easy to distinguish, since + N = p*q = 1 (mod 3), but N = p*q*r = 2 (mod 3). Therefore fingerprinting + 2-prime vs. 3-prime RSA keys was possible by computing N mod 3. + This avoids possible fingerprinting of newly generated RSA modules. + [Bernd Edlinger] + + Changes between 1.1.1d and 1.1.1e [17 Mar 2020] + *) Properly detect EOF while reading in libssl. Previously if we hit an EOF + while reading in libssl then we would report an error back to the + application (SSL_ERROR_SYSCALL) but errno would be 0. We now add + an error to the stack (which means we instead return SSL_ERROR_SSL) and + therefore give a hint as to what went wrong. + [Matt Caswell] + + *) Check that ed25519 and ed448 are allowed by the security level. Previously + signature algorithms not using an MD were not being checked that they were + allowed by the security level. + [Kurt Roeckx] + + *) Fixed SSL_get_servername() behaviour. The behaviour of SSL_get_servername() + was not quite right. The behaviour was not consistent between resumption + and normal handshakes, and also not quite consistent with historical + behaviour. The behaviour in various scenarios has been clarified and + it has been updated to make it match historical behaviour as closely as + possible. + [Matt Caswell] + + *) [VMS only] The header files that the VMS compilers include automatically, + __DECC_INCLUDE_PROLOGUE.H and __DECC_INCLUDE_EPILOGUE.H, use pragmas that + the C++ compiler doesn't understand. This is a shortcoming in the + compiler, but can be worked around with __cplusplus guards. + + C++ applications that use OpenSSL libraries must be compiled using the + qualifier '/NAMES=(AS_IS,SHORTENED)' to be able to use all the OpenSSL + functions. Otherwise, only functions with symbols of less than 31 + characters can be used, as the linker will not be able to successfully + resolve symbols with longer names. + [Richard Levitte] + + *) Corrected the documentation of the return values from the EVP_DigestSign* + set of functions. The documentation mentioned negative values for some + errors, but this was never the case, so the mention of negative values + was removed. + + Code that followed the documentation and thereby check with something + like 'EVP_DigestSignInit(...) <= 0' will continue to work undisturbed. + [Richard Levitte] + + *) Fixed an an overflow bug in the x64_64 Montgomery squaring procedure + used in exponentiation with 512-bit moduli. No EC algorithms are + affected. Analysis suggests that attacks against 2-prime RSA1024, + 3-prime RSA1536, and DSA1024 as a result of this defect would be very + difficult to perform and are not believed likely. Attacks against DH512 + are considered just feasible. However, for an attack the target would + have to re-use the DH512 private key, which is not recommended anyway. + Also applications directly using the low level API BN_mod_exp may be + affected if they use BN_FLG_CONSTTIME. + (CVE-2019-1551) + [Andy Polyakov] + + *) Added a new method to gather entropy on VMS, based on SYS$GET_ENTROPY. + The presence of this system service is determined at run-time. + [Richard Levitte] + + *) Added newline escaping functionality to a filename when using openssl dgst. + This output format is to replicate the output format found in the '*sum' + checksum programs. This aims to preserve backward compatibility. + [Matt Eaton, Richard Levitte, and Paul Dale] + + *) Print all values for a PKCS#12 attribute with 'openssl pkcs12', not just + the first value. + [Jon Spillett] + Changes between 1.1.1c and 1.1.1d [10 Sep 2019] *) Fixed a fork protection issue. OpenSSL 1.1.1 introduced a rewritten random @@ -948,9 +948,9 @@ bytes long. In theory it is permissible in SSLv3 - TLSv1.2 to fragment such alerts across multiple records (some of which could be empty). In practice it make no sense to send an empty alert record, or to fragment one. TLSv1.3 - prohibits this altogether and other libraries (BoringSSL, NSS) do not + prohibits this altogether and other libraries (BoringSSL, NSS) do not support this at all. Supporting it adds significant complexity to the - record layer, and its removal is unlikely to cause interoperability + record layer, and its removal is unlikely to cause interoperability issues. [Matt Caswell] @@ -3967,7 +3967,7 @@ implementations). [Emilia Käsper, Adam Langley, Bodo Moeller (Google)] - *) Use type ossl_ssize_t instead of ssize_t which isn't available on + *) Use type ossl_ssize_t instead of ssize_t which isn't available on all platforms. Move ssize_t definition from e_os.h to the public header file e_os2.h as it now appears in public header file cms.h [Steve Henson] @@ -8688,7 +8688,7 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k *) New OCSP utility. Allows OCSP requests to be generated or read. The request can be sent to a responder and the output - parsed, outputted or printed in text form. Not complete yet: + parsed, outputted or printed in text form. Not complete yet: still needs to check the OCSP response validity. [Steve Henson] @@ -9683,7 +9683,7 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k [Andy Polyakov] *) Modified SSL library such that the verify_callback that has been set - specifically for an SSL object with SSL_set_verify() is actually being + specifically for an SSL object with SSL_set_verify() is actually being used. Before the change, a verify_callback set with this function was ignored and the verify_callback() set in the SSL_CTX at the time of the call was used. New function X509_STORE_CTX_set_verify_cb() introduced @@ -10800,10 +10800,10 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k as other interfaces in OpenSSL, like the BIO interface. NCONF_dump_* dump the internal storage of the configuration file, which is useful for debugging. All other functions take the same - arguments as the old CONF_* functions with the exception of the + arguments as the old CONF_* functions with the exception of the first that must be a `CONF *' instead of a `LHASH *'. - To make it easier to use the new classes with the old CONF_* functions, + To make it easier to use the new classes with the old CONF_* functions, the function CONF_set_default_method is provided. [Richard Levitte] @@ -12646,7 +12646,7 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k than the old method: it now uses a modified version of Ulf's parser to read the ANSI prototypes in all header files (thus the old K&R definitions aren't needed for error creation any more) and do a better job of - translating function codes into names. The old 'ASN1 error code embedded + translating function codes into names. The old 'ASN1 error code embedded in a comment' is no longer necessary and it doesn't use .err files which have now been deleted. Also the error code call doesn't have to appear all on one line (which resulted in some large lines...). @@ -12947,7 +12947,7 @@ des-cbc 3624.96k 5258.21k 5530.91k 5624.30k 5628.26k *) Add a useful kludge to allow package maintainers to specify compiler and other platforms details on the command line without having to patch the - Configure script every time: One now can use ``perl Configure + Configure script every time: One now can use ``perl Configure <id>:<details>'', i.e. platform ids are allowed to have details appended to them (separated by colons). This is treated as there would be a static pre-configured entry in Configure's %table under key <id> with value diff --git a/contrib/libs/openssl/CONTRIBUTING b/contrib/libs/openssl/CONTRIBUTING index 4d6d3e3675..83c0dde128 100644 --- a/contrib/libs/openssl/CONTRIBUTING +++ b/contrib/libs/openssl/CONTRIBUTING @@ -58,7 +58,7 @@ guidelines: consider adding a note in CHANGES. This could be a summarising description of the change, and could explain the grander details. Have a look through existing entries for inspiration. - Please note that this is NOT simply a copy of git-log one-liners. + Please note that this is NOT simply a copy of git-log one-liners. Also note that security fixes get an entry in CHANGES. This file helps users get more in depth information of what comes with a specific release without having to sift through the higher diff --git a/contrib/libs/openssl/INSTALL b/contrib/libs/openssl/INSTALL index 7563c9ad0e..f3ac727183 100644 --- a/contrib/libs/openssl/INSTALL +++ b/contrib/libs/openssl/INSTALL @@ -352,9 +352,9 @@ Don't build support for datagram based BIOs. Selecting this option will also force the disabling of DTLS. - no-dso - Don't build support for loading Dynamic Shared Objects. - + no-dso + Don't build support for loading Dynamic Shared Objects. + enable-devcryptoeng Build the /dev/crypto engine. It is automatically selected on BSD implementations, in which case it can be disabled with @@ -536,9 +536,9 @@ conjunction with the "-DPEDANTIC" option (or the --strict-warnings option). - no-ui-console - Don't build with the "UI" console method (i.e. the "UI" - method that enables text based console prompts). + no-ui-console + Don't build with the "UI" console method (i.e. the "UI" + method that enables text based console prompts). enable-unit-test Enable additional unit test APIs. This should not typically @@ -609,20 +609,20 @@ Take note of the VAR=value documentation below and how these flags interact with those variables. - -xxx, +xxx, /xxx + -xxx, +xxx, /xxx Additional options that are not otherwise recognised are - passed through as they are to the compiler as well. - Unix-style options beginning with a '-' or '+' and - Windows-style options beginning with a '/' are recognized. - Again, consult your compiler documentation. - - If the option contains arguments separated by spaces, - then the URL-style notation %20 can be used for the space - character in order to avoid having to quote the option. - For example, -opt%20arg gets expanded to -opt arg. - In fact, any ASCII character can be encoded as %xx using its - hexadecimal encoding. - + passed through as they are to the compiler as well. + Unix-style options beginning with a '-' or '+' and + Windows-style options beginning with a '/' are recognized. + Again, consult your compiler documentation. + + If the option contains arguments separated by spaces, + then the URL-style notation %20 can be used for the space + character in order to avoid having to quote the option. + For example, -opt%20arg gets expanded to -opt arg. + In fact, any ASCII character can be encoded as %xx using its + hexadecimal encoding. + Take note of the VAR=value documentation below and how these flags interact with those variables. @@ -1084,7 +1084,7 @@ HASHBANGPERL The command string for the Perl executable to insert in the - #! line of perl scripts that will be publicly installed. + #! line of perl scripts that will be publicly installed. Default: /usr/bin/env perl Note: the value of this variable is added to the same scripts on all platforms, but it's only relevant on Unix-like platforms. diff --git a/contrib/libs/openssl/NEWS b/contrib/libs/openssl/NEWS index d82c954a49..5a1207c66e 100644 --- a/contrib/libs/openssl/NEWS +++ b/contrib/libs/openssl/NEWS @@ -40,21 +40,21 @@ contexts o Oracle Developer Studio will start reporting deprecation warnings - Major changes between OpenSSL 1.1.1f and OpenSSL 1.1.1g [21 Apr 2020] - - o Fixed segmentation fault in SSL_check_chain() (CVE-2020-1967) - - Major changes between OpenSSL 1.1.1e and OpenSSL 1.1.1f [31 Mar 2020] - - o Revert the unexpected EOF reporting via SSL_ERROR_SSL - - Major changes between OpenSSL 1.1.1d and OpenSSL 1.1.1e [17 Mar 2020] - - o Fixed an overflow bug in the x64_64 Montgomery squaring procedure - used in exponentiation with 512-bit moduli (CVE-2019-1551) - o Properly detect unexpected EOF while reading in libssl and report - it via SSL_ERROR_SSL - + Major changes between OpenSSL 1.1.1f and OpenSSL 1.1.1g [21 Apr 2020] + + o Fixed segmentation fault in SSL_check_chain() (CVE-2020-1967) + + Major changes between OpenSSL 1.1.1e and OpenSSL 1.1.1f [31 Mar 2020] + + o Revert the unexpected EOF reporting via SSL_ERROR_SSL + + Major changes between OpenSSL 1.1.1d and OpenSSL 1.1.1e [17 Mar 2020] + + o Fixed an overflow bug in the x64_64 Montgomery squaring procedure + used in exponentiation with 512-bit moduli (CVE-2019-1551) + o Properly detect unexpected EOF while reading in libssl and report + it via SSL_ERROR_SSL + Major changes between OpenSSL 1.1.1c and OpenSSL 1.1.1d [10 Sep 2019] o Fixed a fork protection issue (CVE-2019-1549) diff --git a/contrib/libs/openssl/NOTES.ANDROID b/contrib/libs/openssl/NOTES.ANDROID index fe42fc4e23..293ad4327c 100644 --- a/contrib/libs/openssl/NOTES.ANDROID +++ b/contrib/libs/openssl/NOTES.ANDROID @@ -15,34 +15,34 @@ Configuration ------------- - Android is a naturally cross-compiled target and you can't use ./config. + Android is a naturally cross-compiled target and you can't use ./config. You have to use ./Configure and name your target explicitly; there are android-arm, android-arm64, android-mips, android-mip64, android-x86 - and android-x86_64 (*MIPS targets are no longer supported with NDK R20+). - Do not pass --cross-compile-prefix (as you might be tempted), as it will - be "calculated" automatically based on chosen platform. Though you still - need to know the prefix to extend your PATH, in order to invoke - $(CROSS_COMPILE)clang [*gcc on NDK 19 and lower] and company. (Configure - will fail and give you a hint if you get it wrong.) Apart from PATH - adjustment you need to set ANDROID_NDK_HOME environment to point at the - NDK directory. If you're using a side-by-side NDK the path will look - something like /some/where/android-sdk/ndk/<ver>, and for a standalone - NDK the path will be something like /some/where/android-ndk-<ver>. - Both variables are significant at both configuration and compilation times. - The NDK customarily supports multiple Android API levels, e.g. android-14, - android-21, etc. By default latest API level is chosen. If you need to - target an older platform pass the argument -D__ANDROID_API__=N to Configure, - with N being the numerical value of the target platform version. For example, - to compile for Android 10 arm64 with a side-by-side NDK r20.0.5594570 - - export ANDROID_NDK_HOME=/home/whoever/Android/android-sdk/ndk/20.0.5594570 - PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH - ./Configure android-arm64 -D__ANDROID_API__=29 - make - - Older versions of the NDK have GCC under their common prebuilt tools directory, so the bin path - will be slightly different. EG: to compile for ICS on ARM with NDK 10d: - + and android-x86_64 (*MIPS targets are no longer supported with NDK R20+). + Do not pass --cross-compile-prefix (as you might be tempted), as it will + be "calculated" automatically based on chosen platform. Though you still + need to know the prefix to extend your PATH, in order to invoke + $(CROSS_COMPILE)clang [*gcc on NDK 19 and lower] and company. (Configure + will fail and give you a hint if you get it wrong.) Apart from PATH + adjustment you need to set ANDROID_NDK_HOME environment to point at the + NDK directory. If you're using a side-by-side NDK the path will look + something like /some/where/android-sdk/ndk/<ver>, and for a standalone + NDK the path will be something like /some/where/android-ndk-<ver>. + Both variables are significant at both configuration and compilation times. + The NDK customarily supports multiple Android API levels, e.g. android-14, + android-21, etc. By default latest API level is chosen. If you need to + target an older platform pass the argument -D__ANDROID_API__=N to Configure, + with N being the numerical value of the target platform version. For example, + to compile for Android 10 arm64 with a side-by-side NDK r20.0.5594570 + + export ANDROID_NDK_HOME=/home/whoever/Android/android-sdk/ndk/20.0.5594570 + PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin:$PATH + ./Configure android-arm64 -D__ANDROID_API__=29 + make + + Older versions of the NDK have GCC under their common prebuilt tools directory, so the bin path + will be slightly different. EG: to compile for ICS on ARM with NDK 10d: + export ANDROID_NDK_HOME=/some/where/android-ndk-10d PATH=$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH ./Configure android-arm -D__ANDROID_API__=14 diff --git a/contrib/libs/openssl/apps/apps.c b/contrib/libs/openssl/apps/apps.c index 18e42a5734..c06241abb9 100644 --- a/contrib/libs/openssl/apps/apps.c +++ b/contrib/libs/openssl/apps/apps.c @@ -1962,46 +1962,46 @@ unsigned char *next_protos_parse(size_t *outlen, const char *in) size_t len; unsigned char *out; size_t i, start = 0; - size_t skipped = 0; + size_t skipped = 0; len = strlen(in); - if (len == 0 || len >= 65535) + if (len == 0 || len >= 65535) return NULL; - out = app_malloc(len + 1, "NPN buffer"); + out = app_malloc(len + 1, "NPN buffer"); for (i = 0; i <= len; ++i) { if (i == len || in[i] == ',') { - /* - * Zero-length ALPN elements are invalid on the wire, we could be - * strict and reject the entire string, but just ignoring extra - * commas seems harmless and more friendly. - * - * Every comma we skip in this way puts the input buffer another - * byte ahead of the output buffer, so all stores into the output - * buffer need to be decremented by the number commas skipped. - */ - if (i == start) { - ++start; - ++skipped; - continue; - } + /* + * Zero-length ALPN elements are invalid on the wire, we could be + * strict and reject the entire string, but just ignoring extra + * commas seems harmless and more friendly. + * + * Every comma we skip in this way puts the input buffer another + * byte ahead of the output buffer, so all stores into the output + * buffer need to be decremented by the number commas skipped. + */ + if (i == start) { + ++start; + ++skipped; + continue; + } if (i - start > 255) { OPENSSL_free(out); return NULL; } - out[start-skipped] = (unsigned char)(i - start); + out[start-skipped] = (unsigned char)(i - start); start = i + 1; } else { - out[i + 1 - skipped] = in[i]; + out[i + 1 - skipped] = in[i]; } } - if (len <= skipped) { - OPENSSL_free(out); - return NULL; - } - - *outlen = len + 1 - skipped; + if (len <= skipped) { + OPENSSL_free(out); + return NULL; + } + + *outlen = len + 1 - skipped; return out; } diff --git a/contrib/libs/openssl/apps/apps.h b/contrib/libs/openssl/apps/apps.h index 99486aa622..34c3fd8633 100644 --- a/contrib/libs/openssl/apps/apps.h +++ b/contrib/libs/openssl/apps/apps.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_APPS_H -# define OSSL_APPS_H +#ifndef OSSL_APPS_H +# define OSSL_APPS_H # include "e_os.h" /* struct timeval for DTLS */ # include "internal/nelem.h" diff --git a/contrib/libs/openssl/apps/dgst.c b/contrib/libs/openssl/apps/dgst.c index 5884d2c165..e595f7d818 100644 --- a/contrib/libs/openssl/apps/dgst.c +++ b/contrib/libs/openssl/apps/dgst.c @@ -19,7 +19,7 @@ #include <openssl/x509.h> #include <openssl/pem.h> #include <openssl/hmac.h> -#include <ctype.h> +#include <ctype.h> #undef BUFSIZE #define BUFSIZE 1024*8 @@ -28,15 +28,15 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, EVP_PKEY *key, unsigned char *sigin, int siglen, const char *sig_name, const char *md_name, const char *file); -static void show_digests(const OBJ_NAME *name, void *bio_); +static void show_digests(const OBJ_NAME *name, void *bio_); + +struct doall_dgst_digests { + BIO *bio; + int n; +}; -struct doall_dgst_digests { - BIO *bio; - int n; -}; - typedef enum OPTION_choice { - OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_LIST, + OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_LIST, OPT_C, OPT_R, OPT_OUT, OPT_SIGN, OPT_PASSIN, OPT_VERIFY, OPT_PRVERIFY, OPT_SIGNATURE, OPT_KEYFORM, OPT_ENGINE, OPT_ENGINE_IMPL, OPT_HEX, OPT_BINARY, OPT_DEBUG, OPT_FIPS_FINGERPRINT, @@ -50,7 +50,7 @@ const OPTIONS dgst_options[] = { {OPT_HELP_STR, 1, '-', " file... files to digest (default is stdin)\n"}, {"help", OPT_HELP, '-', "Display this summary"}, - {"list", OPT_LIST, '-', "List digests"}, + {"list", OPT_LIST, '-', "List digests"}, {"c", OPT_C, '-', "Print the digest with separating colons"}, {"r", OPT_R, '-', "Print the digest in coreutils format"}, {"out", OPT_OUT, '>', "Output to filename rather than stdout"}, @@ -99,7 +99,7 @@ int dgst_main(int argc, char **argv) int i, ret = 1, out_bin = -1, want_pub = 0, do_verify = 0; unsigned char *buf = NULL, *sigbuf = NULL; int engine_impl = 0; - struct doall_dgst_digests dec; + struct doall_dgst_digests dec; prog = opt_progname(argv[0]); buf = app_malloc(BUFSIZE, "I/O buffer"); @@ -117,15 +117,15 @@ int dgst_main(int argc, char **argv) opt_help(dgst_options); ret = 0; goto end; - case OPT_LIST: - BIO_printf(bio_out, "Supported digests:\n"); - dec.bio = bio_out; - dec.n = 0; - OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH, - show_digests, &dec); - BIO_printf(bio_out, "\n"); - ret = 0; - goto end; + case OPT_LIST: + BIO_printf(bio_out, "Supported digests:\n"); + dec.bio = bio_out; + dec.n = 0; + OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH, + show_digests, &dec); + BIO_printf(bio_out, "\n"); + ret = 0; + goto end; case OPT_C: separator = 1; break; @@ -431,86 +431,86 @@ int dgst_main(int argc, char **argv) return ret; } -static void show_digests(const OBJ_NAME *name, void *arg) -{ - struct doall_dgst_digests *dec = (struct doall_dgst_digests *)arg; - const EVP_MD *md = NULL; - - /* Filter out signed digests (a.k.a signature algorithms) */ - if (strstr(name->name, "rsa") != NULL || strstr(name->name, "RSA") != NULL) - return; - - if (!islower((unsigned char)*name->name)) - return; - - /* Filter out message digests that we cannot use */ - md = EVP_get_digestbyname(name->name); - if (md == NULL) - return; - - BIO_printf(dec->bio, "-%-25s", name->name); - if (++dec->n == 3) { - BIO_printf(dec->bio, "\n"); - dec->n = 0; - } else { - BIO_printf(dec->bio, " "); - } -} - -/* - * The newline_escape_filename function performs newline escaping for any - * filename that contains a newline. This function also takes a pointer - * to backslash. The backslash pointer is a flag to indicating whether a newline - * is present in the filename. If a newline is present, the backslash flag is - * set and the output format will contain a backslash at the beginning of the - * digest output. This output format is to replicate the output format found - * in the '*sum' checksum programs. This aims to preserve backward - * compatibility. - */ -static const char *newline_escape_filename(const char *file, int * backslash) -{ - size_t i, e = 0, length = strlen(file), newline_count = 0, mem_len = 0; - char *file_cpy = NULL; - - for (i = 0; i < length; i++) - if (file[i] == '\n') - newline_count++; - - mem_len = length + newline_count + 1; - file_cpy = app_malloc(mem_len, file); - i = 0; - - while(e < length) { - const char c = file[e]; - if (c == '\n') { - file_cpy[i++] = '\\'; - file_cpy[i++] = 'n'; - *backslash = 1; - } else { - file_cpy[i++] = c; - } - e++; - } - file_cpy[i] = '\0'; - return (const char*)file_cpy; -} - - +static void show_digests(const OBJ_NAME *name, void *arg) +{ + struct doall_dgst_digests *dec = (struct doall_dgst_digests *)arg; + const EVP_MD *md = NULL; + + /* Filter out signed digests (a.k.a signature algorithms) */ + if (strstr(name->name, "rsa") != NULL || strstr(name->name, "RSA") != NULL) + return; + + if (!islower((unsigned char)*name->name)) + return; + + /* Filter out message digests that we cannot use */ + md = EVP_get_digestbyname(name->name); + if (md == NULL) + return; + + BIO_printf(dec->bio, "-%-25s", name->name); + if (++dec->n == 3) { + BIO_printf(dec->bio, "\n"); + dec->n = 0; + } else { + BIO_printf(dec->bio, " "); + } +} + +/* + * The newline_escape_filename function performs newline escaping for any + * filename that contains a newline. This function also takes a pointer + * to backslash. The backslash pointer is a flag to indicating whether a newline + * is present in the filename. If a newline is present, the backslash flag is + * set and the output format will contain a backslash at the beginning of the + * digest output. This output format is to replicate the output format found + * in the '*sum' checksum programs. This aims to preserve backward + * compatibility. + */ +static const char *newline_escape_filename(const char *file, int * backslash) +{ + size_t i, e = 0, length = strlen(file), newline_count = 0, mem_len = 0; + char *file_cpy = NULL; + + for (i = 0; i < length; i++) + if (file[i] == '\n') + newline_count++; + + mem_len = length + newline_count + 1; + file_cpy = app_malloc(mem_len, file); + i = 0; + + while(e < length) { + const char c = file[e]; + if (c == '\n') { + file_cpy[i++] = '\\'; + file_cpy[i++] = 'n'; + *backslash = 1; + } else { + file_cpy[i++] = c; + } + e++; + } + file_cpy[i] = '\0'; + return (const char*)file_cpy; +} + + int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, EVP_PKEY *key, unsigned char *sigin, int siglen, const char *sig_name, const char *md_name, const char *file) { - size_t len = BUFSIZE; - int i, backslash = 0, ret = 1; - unsigned char *sigbuf = NULL; + size_t len = BUFSIZE; + int i, backslash = 0, ret = 1; + unsigned char *sigbuf = NULL; while (BIO_pending(bp) || !BIO_eof(bp)) { i = BIO_read(bp, (char *)buf, BUFSIZE); if (i < 0) { BIO_printf(bio_err, "Read Error in %s\n", file); ERR_print_errors(bio_err); - goto end; + goto end; } if (i == 0) break; @@ -523,51 +523,51 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, BIO_printf(out, "Verified OK\n"); } else if (i == 0) { BIO_printf(out, "Verification Failure\n"); - goto end; + goto end; } else { BIO_printf(bio_err, "Error Verifying Data\n"); ERR_print_errors(bio_err); - goto end; + goto end; } - ret = 0; - goto end; + ret = 0; + goto end; } if (key != NULL) { EVP_MD_CTX *ctx; - int pkey_len; + int pkey_len; BIO_get_md_ctx(bp, &ctx); - pkey_len = EVP_PKEY_size(key); - if (pkey_len > BUFSIZE) { - len = pkey_len; - sigbuf = app_malloc(len, "Signature buffer"); - buf = sigbuf; - } + pkey_len = EVP_PKEY_size(key); + if (pkey_len > BUFSIZE) { + len = pkey_len; + sigbuf = app_malloc(len, "Signature buffer"); + buf = sigbuf; + } if (!EVP_DigestSignFinal(ctx, buf, &len)) { BIO_printf(bio_err, "Error Signing Data\n"); ERR_print_errors(bio_err); - goto end; + goto end; } } else { len = BIO_gets(bp, (char *)buf, BUFSIZE); if ((int)len < 0) { ERR_print_errors(bio_err); - goto end; + goto end; } } if (binout) { BIO_write(out, buf, len); } else if (sep == 2) { - file = newline_escape_filename(file, &backslash); - - if (backslash == 1) - BIO_puts(out, "\\"); - + file = newline_escape_filename(file, &backslash); + + if (backslash == 1) + BIO_puts(out, "\\"); + for (i = 0; i < (int)len; i++) BIO_printf(out, "%02x", buf[i]); - + BIO_printf(out, " *%s\n", file); - OPENSSL_free((char *)file); + OPENSSL_free((char *)file); } else { if (sig_name != NULL) { BIO_puts(out, sig_name); @@ -586,11 +586,11 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout, } BIO_printf(out, "\n"); } - - ret = 0; - end: - if (sigbuf != NULL) - OPENSSL_clear_free(sigbuf, len); - - return ret; + + ret = 0; + end: + if (sigbuf != NULL) + OPENSSL_clear_free(sigbuf, len); + + return ret; } diff --git a/contrib/libs/openssl/apps/dhparam.c b/contrib/libs/openssl/apps/dhparam.c index a2562a9779..98c73214b5 100644 --- a/contrib/libs/openssl/apps/dhparam.c +++ b/contrib/libs/openssl/apps/dhparam.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,24 +8,24 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <string.h> -#include "apps.h" -#include "progs.h" -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/bn.h> -#include <openssl/dh.h> -#include <openssl/x509.h> -#include <openssl/pem.h> - -#ifndef OPENSSL_NO_DSA -# include <openssl/dsa.h> -#endif - -#define DEFBITS 2048 +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <string.h> +#include "apps.h" +#include "progs.h" +#include <openssl/bio.h> +#include <openssl/err.h> +#include <openssl/bn.h> +#include <openssl/dh.h> +#include <openssl/x509.h> +#include <openssl/pem.h> + +#ifndef OPENSSL_NO_DSA +# include <openssl/dsa.h> +#endif + +#define DEFBITS 2048 static int dh_cb(int p, int n, BN_GENCB *cb); @@ -52,13 +52,13 @@ const OPTIONS dhparam_options[] = { {"C", OPT_C, '-', "Print C code"}, {"2", OPT_2, '-', "Generate parameters using 2 as the generator value"}, {"5", OPT_5, '-', "Generate parameters using 5 as the generator value"}, -#ifndef OPENSSL_NO_DSA +#ifndef OPENSSL_NO_DSA {"dsaparam", OPT_DSAPARAM, '-', "Read or generate DSA parameters, convert to DH"}, -#endif -#ifndef OPENSSL_NO_ENGINE +#endif +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, -#endif +#endif {NULL} }; @@ -142,13 +142,13 @@ int dhparam_main(int argc, char **argv) if (g && !num) num = DEFBITS; -#ifndef OPENSSL_NO_DSA +#ifndef OPENSSL_NO_DSA if (dsaparam && g) { BIO_printf(bio_err, "generator may not be chosen for DSA parameters\n"); goto end; } -#endif +#endif out = bio_open_default(outfile, 'w', outformat); if (out == NULL) @@ -169,7 +169,7 @@ int dhparam_main(int argc, char **argv) BN_GENCB_set(cb, dh_cb, bio_err); -#ifndef OPENSSL_NO_DSA +#ifndef OPENSSL_NO_DSA if (dsaparam) { DSA *dsa = DSA_new(); @@ -192,7 +192,7 @@ int dhparam_main(int argc, char **argv) goto end; } } else -#endif +#endif { dh = DH_new(); BIO_printf(bio_err, @@ -213,7 +213,7 @@ int dhparam_main(int argc, char **argv) if (in == NULL) goto end; -#ifndef OPENSSL_NO_DSA +#ifndef OPENSSL_NO_DSA if (dsaparam) { DSA *dsa; @@ -235,7 +235,7 @@ int dhparam_main(int argc, char **argv) goto end; } } else -#endif +#endif { if (informat == FORMAT_ASN1) { /* diff --git a/contrib/libs/openssl/apps/dsa.c b/contrib/libs/openssl/apps/dsa.c index f167af44d5..c7884df166 100644 --- a/contrib/libs/openssl/apps/dsa.c +++ b/contrib/libs/openssl/apps/dsa.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,19 +8,19 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include "apps.h" -#include "progs.h" -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/dsa.h> -#include <openssl/evp.h> -#include <openssl/x509.h> -#include <openssl/pem.h> -#include <openssl/bn.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include "apps.h" +#include "progs.h" +#include <openssl/bio.h> +#include <openssl/err.h> +#include <openssl/dsa.h> +#include <openssl/evp.h> +#include <openssl/x509.h> +#include <openssl/pem.h> +#include <openssl/bn.h> typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -45,14 +45,14 @@ const OPTIONS dsa_options[] = { {"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, {"", OPT_CIPHER, '-', "Any supported cipher"}, -#ifndef OPENSSL_NO_RC4 +#ifndef OPENSSL_NO_RC4 {"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"}, {"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"}, {"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"}, -#endif -#ifndef OPENSSL_NO_ENGINE +#endif +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, -#endif +#endif {NULL} }; @@ -67,9 +67,9 @@ int dsa_main(int argc, char **argv) OPTION_CHOICE o; int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0; int i, modulus = 0, pubin = 0, pubout = 0, ret = 1; -#ifndef OPENSSL_NO_RC4 +#ifndef OPENSSL_NO_RC4 int pvk_encr = 2; -#endif +#endif int private = 0; prog = opt_init(argc, argv, dsa_options); @@ -210,7 +210,7 @@ int dsa_main(int argc, char **argv) i = PEM_write_bio_DSAPrivateKey(out, dsa, enc, NULL, 0, NULL, passout); } -#ifndef OPENSSL_NO_RSA +#ifndef OPENSSL_NO_RSA } else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) { EVP_PKEY *pk; pk = EVP_PKEY_new(); @@ -225,13 +225,13 @@ int dsa_main(int argc, char **argv) goto end; } assert(private); -# ifdef OPENSSL_NO_RC4 +# ifdef OPENSSL_NO_RC4 BIO_printf(bio_err, "PVK format not supported\n"); EVP_PKEY_free(pk); goto end; -# else +# else i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout); -# endif +# endif } else if (pubin || pubout) { i = i2b_PublicKey_bio(out, pk); } else { @@ -239,7 +239,7 @@ int dsa_main(int argc, char **argv) i = i2b_PrivateKey_bio(out, pk); } EVP_PKEY_free(pk); -#endif +#endif } else { BIO_printf(bio_err, "bad output format specified for outfile\n"); goto end; diff --git a/contrib/libs/openssl/apps/dsaparam.c b/contrib/libs/openssl/apps/dsaparam.c index 4699f14f40..75589ac6bc 100644 --- a/contrib/libs/openssl/apps/dsaparam.c +++ b/contrib/libs/openssl/apps/dsaparam.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,18 +8,18 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <string.h> -#include "apps.h" -#include "progs.h" -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/bn.h> -#include <openssl/dsa.h> -#include <openssl/x509.h> -#include <openssl/pem.h> +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <string.h> +#include "apps.h" +#include "progs.h" +#include <openssl/bio.h> +#include <openssl/err.h> +#include <openssl/bn.h> +#include <openssl/dsa.h> +#include <openssl/x509.h> +#include <openssl/pem.h> static int dsa_cb(int p, int n, BN_GENCB *cb); @@ -40,9 +40,9 @@ const OPTIONS dsaparam_options[] = { {"noout", OPT_NOOUT, '-', "No output"}, {"genkey", OPT_GENKEY, '-', "Generate a DSA key"}, OPT_R_OPTIONS, -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"}, -#endif +#endif {NULL} }; diff --git a/contrib/libs/openssl/apps/ec.c b/contrib/libs/openssl/apps/ec.c index bc376c0850..0c8ed750cc 100644 --- a/contrib/libs/openssl/apps/ec.c +++ b/contrib/libs/openssl/apps/ec.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,15 +8,15 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "apps.h" -#include "progs.h" -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/evp.h> -#include <openssl/pem.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "apps.h" +#include "progs.h" +#include <openssl/bio.h> +#include <openssl/err.h> +#include <openssl/evp.h> +#include <openssl/pem.h> static OPT_PAIR conv_forms[] = { {"compressed", POINT_CONVERSION_COMPRESSED}, @@ -58,9 +58,9 @@ const OPTIONS ec_options[] = { "Specifies the way the ec parameters are encoded"}, {"conv_form", OPT_CONV_FORM, 's', "Specifies the point conversion form "}, {"", OPT_CIPHER, '-', "Any supported cipher"}, -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -#endif +#endif {NULL} }; diff --git a/contrib/libs/openssl/apps/ecparam.c b/contrib/libs/openssl/apps/ecparam.c index 350047f327..58fbeb95c9 100644 --- a/contrib/libs/openssl/apps/ecparam.c +++ b/contrib/libs/openssl/apps/ecparam.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -9,18 +9,18 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <string.h> -#include "apps.h" -#include "progs.h" -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/bn.h> -#include <openssl/ec.h> -#include <openssl/x509.h> -#include <openssl/pem.h> +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <string.h> +#include "apps.h" +#include "progs.h" +#include <openssl/bio.h> +#include <openssl/err.h> +#include <openssl/bn.h> +#include <openssl/ec.h> +#include <openssl/x509.h> +#include <openssl/pem.h> typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -51,9 +51,9 @@ const OPTIONS ecparam_options[] = { "Specifies the way the ec parameters are encoded"}, {"genkey", OPT_GENKEY, '-', "Generate ec key"}, OPT_R_OPTIONS, -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -#endif +#endif {NULL} }; diff --git a/contrib/libs/openssl/apps/enc.c b/contrib/libs/openssl/apps/enc.c index afbf3d4b0a..65710771a0 100644 --- a/contrib/libs/openssl/apps/enc.c +++ b/contrib/libs/openssl/apps/enc.c @@ -50,8 +50,8 @@ typedef enum OPTION_choice { const OPTIONS enc_options[] = { {"help", OPT_HELP, '-', "Display this summary"}, - {"list", OPT_LIST, '-', "List ciphers"}, - {"ciphers", OPT_LIST, '-', "Alias for -list"}, + {"list", OPT_LIST, '-', "List ciphers"}, + {"ciphers", OPT_LIST, '-', "Alias for -list"}, {"in", OPT_IN, '<', "Input file"}, {"out", OPT_OUT, '>', "Output file"}, {"pass", OPT_PASS, 's', "Passphrase source"}, diff --git a/contrib/libs/openssl/apps/engine.c b/contrib/libs/openssl/apps/engine.c index 486c163d89..746cace354 100644 --- a/contrib/libs/openssl/apps/engine.c +++ b/contrib/libs/openssl/apps/engine.c @@ -1,5 +1,5 @@ /* - * Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,15 +8,15 @@ */ #include <openssl/opensslconf.h> -#include "apps.h" -#include "progs.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <openssl/err.h> -#include <openssl/engine.h> -#include <openssl/ssl.h> -#include <openssl/store.h> +#include "apps.h" +#include "progs.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <openssl/err.h> +#include <openssl/engine.h> +#include <openssl/ssl.h> +#include <openssl/store.h> typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, diff --git a/contrib/libs/openssl/apps/gendsa.c b/contrib/libs/openssl/apps/gendsa.c index e81be66d91..ec57c92a94 100644 --- a/contrib/libs/openssl/apps/gendsa.c +++ b/contrib/libs/openssl/apps/gendsa.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,18 +8,18 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include "apps.h" -#include "progs.h" -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/bn.h> -#include <openssl/dsa.h> -#include <openssl/x509.h> -#include <openssl/pem.h> +#include <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include "apps.h" +#include "progs.h" +#include <openssl/bio.h> +#include <openssl/err.h> +#include <openssl/bn.h> +#include <openssl/dsa.h> +#include <openssl/x509.h> +#include <openssl/pem.h> typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -35,9 +35,9 @@ const OPTIONS gendsa_options[] = { {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, OPT_R_OPTIONS, {"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"}, -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -#endif +#endif {NULL} }; diff --git a/contrib/libs/openssl/apps/genrsa.c b/contrib/libs/openssl/apps/genrsa.c index d74f4e3360..e34a2f7ab9 100644 --- a/contrib/libs/openssl/apps/genrsa.c +++ b/contrib/libs/openssl/apps/genrsa.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,23 +8,23 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include "apps.h" -#include "progs.h" -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/bn.h> -#include <openssl/rsa.h> -#include <openssl/evp.h> -#include <openssl/x509.h> -#include <openssl/pem.h> -#include <openssl/rand.h> - -#define DEFBITS 2048 -#define DEFPRIMES 2 +#include <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include "apps.h" +#include "progs.h" +#include <openssl/bio.h> +#include <openssl/err.h> +#include <openssl/bn.h> +#include <openssl/rsa.h> +#include <openssl/evp.h> +#include <openssl/x509.h> +#include <openssl/pem.h> +#include <openssl/rand.h> + +#define DEFBITS 2048 +#define DEFPRIMES 2 static int genrsa_cb(int p, int n, BN_GENCB *cb); @@ -44,9 +44,9 @@ const OPTIONS genrsa_options[] = { OPT_R_OPTIONS, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, {"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"}, -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -#endif +#endif {"primes", OPT_PRIMES, 'p', "Specify number of primes"}, {NULL} }; diff --git a/contrib/libs/openssl/apps/ocsp.c b/contrib/libs/openssl/apps/ocsp.c index 6a48c60f9b..27ec94fa6b 100644 --- a/contrib/libs/openssl/apps/ocsp.c +++ b/contrib/libs/openssl/apps/ocsp.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -9,62 +9,62 @@ #include <openssl/opensslconf.h> -#ifdef OPENSSL_SYS_VMS -# define _XOPEN_SOURCE_EXTENDED/* So fd_set and friends get properly defined +#ifdef OPENSSL_SYS_VMS +# define _XOPEN_SOURCE_EXTENDED/* So fd_set and friends get properly defined * on OpenVMS */ -#endif +#endif -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <ctype.h> /* Needs to be included before the openssl headers */ -#include "apps.h" -#include "progs.h" -#include "internal/sockets.h" -#include <openssl/e_os2.h> -#include <openssl/crypto.h> -#include <openssl/err.h> -#include <openssl/ssl.h> -#include <openssl/evp.h> -#include <openssl/bn.h> -#include <openssl/x509v3.h> -#include <openssl/rand.h> +#include "apps.h" +#include "progs.h" +#include "internal/sockets.h" +#include <openssl/e_os2.h> +#include <openssl/crypto.h> +#include <openssl/err.h> +#include <openssl/ssl.h> +#include <openssl/evp.h> +#include <openssl/bn.h> +#include <openssl/x509v3.h> +#include <openssl/rand.h> #ifndef HAVE_FORK -#if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS) -# define HAVE_FORK 0 -#else -# define HAVE_FORK 1 +#if defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_WINDOWS) +# define HAVE_FORK 0 +#else +# define HAVE_FORK 1 +#endif #endif -#endif #if HAVE_FORK -#undef NO_FORK +#undef NO_FORK #else -#define NO_FORK +#define NO_FORK #endif -#if !defined(NO_FORK) && !defined(OPENSSL_NO_SOCK) \ +#if !defined(NO_FORK) && !defined(OPENSSL_NO_SOCK) \ && !defined(OPENSSL_NO_POSIX_IO) -# define OCSP_DAEMON -# include <sys/types.h> -# include <sys/wait.h> -# include <syslog.h> -# include <signal.h> -# define MAXERRLEN 1000 /* limit error text sent to syslog to 1000 bytes */ -#else -# undef LOG_INFO -# undef LOG_WARNING -# undef LOG_ERR -# define LOG_INFO 0 -# define LOG_WARNING 1 -# define LOG_ERR 2 -#endif - -#if defined(OPENSSL_SYS_VXWORKS) +# define OCSP_DAEMON +# include <sys/types.h> +# include <sys/wait.h> +# include <syslog.h> +# include <signal.h> +# define MAXERRLEN 1000 /* limit error text sent to syslog to 1000 bytes */ +#else +# undef LOG_INFO +# undef LOG_WARNING +# undef LOG_ERR +# define LOG_INFO 0 +# define LOG_WARNING 1 +# define LOG_ERR 2 +#endif + +#if defined(OPENSSL_SYS_VXWORKS) /* not supported */ int setpgid(pid_t pid, pid_t pgid) { @@ -77,9 +77,9 @@ pid_t fork(void) errno = ENOSYS; return (pid_t) -1; } -#endif +#endif /* Maximum leeway in validity period: default 5 minutes */ -#define MAX_VALIDITY_PERIOD (5 * 60) +#define MAX_VALIDITY_PERIOD (5 * 60) static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, const EVP_MD *cert_id_md, X509 *issuer, @@ -106,20 +106,20 @@ static void log_message(int level, const char *fmt, ...); static char *prog; static int multi = 0; -#ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON static int acfd = (int) INVALID_SOCKET; static int index_changed(CA_DB *); static void spawn_loop(void); static int print_syslog(const char *str, size_t len, void *levPtr); -static void socket_timeout(int signum); -#endif +static void socket_timeout(int signum); +#endif -#ifndef OPENSSL_NO_SOCK +#ifndef OPENSSL_NO_SOCK static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host, const char *path, const STACK_OF(CONF_VALUE) *headers, OCSP_REQUEST *req, int req_timeout); -#endif +#endif typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -157,9 +157,9 @@ const OPTIONS ocsp_options[] = { "Don't include any certificates in response"}, {"resp_key_id", OPT_RESP_KEY_ID, '-', "Identify response by signing certificate key ID"}, -#ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON {"multi", OPT_MULTI, 'p', "run multiple responder processes"}, -#endif +#endif {"no_certs", OPT_NO_CERTS, '-', "Don't include any certificates in signed request"}, {"no_signature_verify", OPT_NO_SIGNATURE_VERIFY, '-', @@ -508,9 +508,9 @@ int ocsp_main(int argc, char **argv) trailing_md = 1; break; case OPT_MULTI: -#ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON multi = atoi(opt_arg()); -#endif +#endif break; } } @@ -590,11 +590,11 @@ int ocsp_main(int argc, char **argv) } } -#ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON if (multi && acbio != NULL) spawn_loop(); if (acbio != NULL && req_timeout > 0) - signal(SIGALRM, socket_timeout); + signal(SIGALRM, socket_timeout); #endif if (acbio != NULL) @@ -603,7 +603,7 @@ int ocsp_main(int argc, char **argv) redo_accept: if (acbio != NULL) { -#ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON if (index_changed(rdb)) { CA_DB *newrdb = load_index(ridx_filename, NULL); @@ -616,7 +616,7 @@ redo_accept: ridx_filename); } } -#endif +#endif req = NULL; if (!do_responder(&req, &cbio, acbio, req_timeout)) @@ -685,16 +685,16 @@ redo_accept: if (cbio != NULL) send_ocsp_response(cbio, resp); } else if (host != NULL) { -#ifndef OPENSSL_NO_SOCK +#ifndef OPENSSL_NO_SOCK resp = process_responder(req, host, path, port, use_ssl, headers, req_timeout); if (resp == NULL) goto end; -#else +#else BIO_printf(bio_err, "Error creating connect BIO - sockets not supported.\n"); goto end; -#endif +#endif } else if (respin != NULL) { derbio = bio_open_default(respin, 'r', FORMAT_ASN1); if (derbio == NULL) @@ -837,7 +837,7 @@ log_message(int level, const char *fmt, ...) va_list ap; va_start(ap, fmt); -#ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON if (multi) { char buf[1024]; if (vsnprintf(buf, sizeof(buf), fmt, ap) > 0) { @@ -846,7 +846,7 @@ log_message(int level, const char *fmt, ...) if (level >= LOG_ERR) ERR_print_errors_cb(print_syslog, &level); } -#endif +#endif if (!multi) { BIO_printf(bio_err, "%s: ", prog); BIO_vprintf(bio_err, fmt, ap); @@ -855,7 +855,7 @@ log_message(int level, const char *fmt, ...) va_end(ap); } -#ifdef OCSP_DAEMON +#ifdef OCSP_DAEMON static int print_syslog(const char *str, size_t len, void *levPtr) { @@ -1008,7 +1008,7 @@ static void spawn_loop(void) syslog(LOG_INFO, "terminating on signal: %d", termsig); killall(0, kidpids); } -#endif +#endif static int add_ocsp_cert(OCSP_REQUEST **req, X509 *cert, const EVP_MD *cert_id_md, X509 *issuer, @@ -1288,11 +1288,11 @@ static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser) static BIO *init_responder(const char *port) { -#ifdef OPENSSL_NO_SOCK +#ifdef OPENSSL_NO_SOCK BIO_printf(bio_err, "Error setting up accept BIO - sockets not supported.\n"); return NULL; -#else +#else BIO *acbio = NULL, *bufbio = NULL; bufbio = BIO_new(BIO_f_buffer()); @@ -1319,10 +1319,10 @@ static BIO *init_responder(const char *port) BIO_free_all(acbio); BIO_free(bufbio); return NULL; -#endif +#endif } -#ifndef OPENSSL_NO_SOCK +#ifndef OPENSSL_NO_SOCK /* * Decode %xx URL-decoding in-place. Ignores mal-formed sequences. */ @@ -1346,22 +1346,22 @@ static int urldecode(char *p) *out = '\0'; return (int)(out - save); } -#endif +#endif -#ifdef OCSP_DAEMON -static void socket_timeout(int signum) +#ifdef OCSP_DAEMON +static void socket_timeout(int signum) { if (acfd != (int)INVALID_SOCKET) (void)shutdown(acfd, SHUT_RD); } -#endif +#endif static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, int timeout) { -#ifdef OPENSSL_NO_SOCK +#ifdef OPENSSL_NO_SOCK return 0; -#else +#else int len; OCSP_REQUEST *req = NULL; char inbuf[2048], reqbuf[2048]; @@ -1379,12 +1379,12 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, *pcbio = cbio; client = BIO_get_peer_name(cbio); -# ifdef OCSP_DAEMON +# ifdef OCSP_DAEMON if (timeout > 0) { (void) BIO_get_fd(cbio, &acfd); alarm(timeout); } -# endif +# endif /* Read the request line. */ len = BIO_gets(cbio, reqbuf, sizeof(reqbuf)); @@ -1447,11 +1447,11 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, break; } -# ifdef OCSP_DAEMON +# ifdef OCSP_DAEMON /* Clear alarm before we close the client socket */ alarm(0); timeout = 0; -# endif +# endif /* Try to read OCSP request */ if (getbio != NULL) { @@ -1467,13 +1467,13 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio, *preq = req; out: -# ifdef OCSP_DAEMON +# ifdef OCSP_DAEMON if (timeout > 0) alarm(0); acfd = (int)INVALID_SOCKET; -# endif +# endif return 1; -#endif +#endif } static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp) @@ -1489,7 +1489,7 @@ static int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp) return 1; } -#ifndef OPENSSL_NO_SOCK +#ifndef OPENSSL_NO_SOCK static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host, const char *path, const STACK_OF(CONF_VALUE) *headers, diff --git a/contrib/libs/openssl/apps/openssl.c b/contrib/libs/openssl/apps/openssl.c index b04985c356..ff7b759a40 100644 --- a/contrib/libs/openssl/apps/openssl.c +++ b/contrib/libs/openssl/apps/openssl.c @@ -164,13 +164,13 @@ int main(int argc, char *argv[]) } prog = prog_init(); - if (prog == NULL) { - BIO_printf(bio_err, - "FATAL: Startup failure (dev note: prog_init() failed)\n"); - ERR_print_errors(bio_err); - ret = 1; - goto end; - } + if (prog == NULL) { + BIO_printf(bio_err, + "FATAL: Startup failure (dev note: prog_init() failed)\n"); + ERR_print_errors(bio_err); + ret = 1; + goto end; + } pname = opt_progname(argv[0]); /* first check the program name */ diff --git a/contrib/libs/openssl/apps/passwd.c b/contrib/libs/openssl/apps/passwd.c index 7fe4f60822..d741d05335 100644 --- a/contrib/libs/openssl/apps/passwd.c +++ b/contrib/libs/openssl/apps/passwd.c @@ -807,7 +807,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p, (*salt_p)[i] = cov_2char[(*salt_p)[i] & 0x3f]; /* 6 bits */ (*salt_p)[i] = 0; # ifdef CHARSET_EBCDIC - /* The password encryption function will convert back to ASCII */ + /* The password encryption function will convert back to ASCII */ ascii2ebcdic(*salt_p, *salt_p, saltlen); # endif } diff --git a/contrib/libs/openssl/apps/pkcs12.c b/contrib/libs/openssl/apps/pkcs12.c index 875b5152dc..8c5d963b8c 100644 --- a/contrib/libs/openssl/apps/pkcs12.c +++ b/contrib/libs/openssl/apps/pkcs12.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,21 +8,21 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "apps.h" -#include "progs.h" -#include <openssl/crypto.h> -#include <openssl/err.h> -#include <openssl/pem.h> -#include <openssl/pkcs12.h> - -#define NOKEYS 0x1 -#define NOCERTS 0x2 -#define INFO 0x4 -#define CLCERTS 0x8 -#define CACERTS 0x10 +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "apps.h" +#include "progs.h" +#include <openssl/crypto.h> +#include <openssl/err.h> +#include <openssl/pem.h> +#include <openssl/pkcs12.h> + +#define NOKEYS 0x1 +#define NOCERTS 0x2 +#define INFO 0x4 +#define CLCERTS 0x8 +#define CACERTS 0x10 #define PASSWD_BUF_SIZE 2048 @@ -37,7 +37,7 @@ int dump_certs_pkeys_bags(BIO *out, const STACK_OF(PKCS12_SAFEBAG) *bags, int dump_certs_pkeys_bag(BIO *out, const PKCS12_SAFEBAG *bags, const char *pass, int passlen, int options, char *pempass, const EVP_CIPHER *enc); -void print_attribute(BIO *out, const ASN1_TYPE *av); +void print_attribute(BIO *out, const ASN1_TYPE *av); int print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst, const char *name); void hex_prin(BIO *out, unsigned char *buf, int len); @@ -70,15 +70,15 @@ const OPTIONS pkcs12_options[] = { {"chain", OPT_CHAIN, '-', "Add certificate chain"}, {"twopass", OPT_TWOPASS, '-', "Separate MAC, encryption passwords"}, {"nomacver", OPT_NOMACVER, '-', "Don't verify MAC"}, -#ifndef OPENSSL_NO_RC2 +#ifndef OPENSSL_NO_RC2 {"descert", OPT_DESCERT, '-', "Encrypt output with 3DES (default RC2-40)"}, {"certpbe", OPT_CERTPBE, 's', "Certificate PBE algorithm (default RC2-40)"}, -#else +#else {"descert", OPT_DESCERT, '-', "Encrypt output with 3DES (the default)"}, {"certpbe", OPT_CERTPBE, 's', "Certificate PBE algorithm (default 3DES)"}, -#endif +#endif {"export", OPT_EXPORT, '-', "Output PKCS12 file"}, {"noiter", OPT_NOITER, '-', "Don't use encryption iteration"}, {"maciter", OPT_MACITER, '-', "Use MAC iteration"}, @@ -109,9 +109,9 @@ const OPTIONS pkcs12_options[] = { {"no-CApath", OPT_NOCAPATH, '-', "Do not load certificates from the default certificates directory"}, {"", OPT_CIPHER, '-', "Any supported cipher"}, -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -#endif +#endif {NULL} }; @@ -122,11 +122,11 @@ int pkcs12_main(int argc, char **argv) char pass[PASSWD_BUF_SIZE] = "", macpass[PASSWD_BUF_SIZE] = ""; int export_cert = 0, options = 0, chain = 0, twopass = 0, keytype = 0; int iter = PKCS12_DEFAULT_ITER, maciter = PKCS12_DEFAULT_ITER; -#ifndef OPENSSL_NO_RC2 +#ifndef OPENSSL_NO_RC2 int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC; -#else +#else int cert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; -#endif +#endif int key_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC; int ret = 1, macver = 1, add_lmk = 0, private = 0; int noprompt = 0; @@ -875,38 +875,38 @@ int cert_load(BIO *in, STACK_OF(X509) *sk) return ret; } -/* Generalised x509 attribute value print */ - -void print_attribute(BIO *out, const ASN1_TYPE *av) -{ - char *value; - - switch (av->type) { - case V_ASN1_BMPSTRING: - value = OPENSSL_uni2asc(av->value.bmpstring->data, - av->value.bmpstring->length); - BIO_printf(out, "%s\n", value); - OPENSSL_free(value); - break; - - case V_ASN1_OCTET_STRING: - hex_prin(out, av->value.octet_string->data, - av->value.octet_string->length); - BIO_printf(out, "\n"); - break; - - case V_ASN1_BIT_STRING: - hex_prin(out, av->value.bit_string->data, - av->value.bit_string->length); - BIO_printf(out, "\n"); - break; - - default: - BIO_printf(out, "<Unsupported tag %d>\n", av->type); - break; - } -} - +/* Generalised x509 attribute value print */ + +void print_attribute(BIO *out, const ASN1_TYPE *av) +{ + char *value; + + switch (av->type) { + case V_ASN1_BMPSTRING: + value = OPENSSL_uni2asc(av->value.bmpstring->data, + av->value.bmpstring->length); + BIO_printf(out, "%s\n", value); + OPENSSL_free(value); + break; + + case V_ASN1_OCTET_STRING: + hex_prin(out, av->value.octet_string->data, + av->value.octet_string->length); + BIO_printf(out, "\n"); + break; + + case V_ASN1_BIT_STRING: + hex_prin(out, av->value.bit_string->data, + av->value.bit_string->length); + BIO_printf(out, "\n"); + break; + + default: + BIO_printf(out, "<Unsupported tag %d>\n", av->type); + break; + } +} + /* Generalised attribute print: handle PKCS#8 and bag attributes */ int print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst, @@ -914,7 +914,7 @@ int print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst, { X509_ATTRIBUTE *attr; ASN1_TYPE *av; - int i, j, attr_nid; + int i, j, attr_nid; if (!attrlst) { BIO_printf(out, "%s: <No Attributes>\n", name); return 1; @@ -938,10 +938,10 @@ int print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst, } if (X509_ATTRIBUTE_count(attr)) { - for (j = 0; j < X509_ATTRIBUTE_count(attr); j++) - { - av = X509_ATTRIBUTE_get0_type(attr, j); - print_attribute(out, av); + for (j = 0; j < X509_ATTRIBUTE_count(attr); j++) + { + av = X509_ATTRIBUTE_get0_type(attr, j); + print_attribute(out, av); } } else { BIO_printf(out, "<No Values>\n"); diff --git a/contrib/libs/openssl/apps/pkeyutl.c b/contrib/libs/openssl/apps/pkeyutl.c index a055a92503..831e14dab4 100644 --- a/contrib/libs/openssl/apps/pkeyutl.c +++ b/contrib/libs/openssl/apps/pkeyutl.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -299,7 +299,7 @@ int pkeyutl_main(int argc, char **argv) /* Sanity check the input */ if (buf_inlen > EVP_MAX_MD_SIZE && (pkey_op == EVP_PKEY_OP_SIGN - || pkey_op == EVP_PKEY_OP_VERIFY)) { + || pkey_op == EVP_PKEY_OP_VERIFY)) { BIO_printf(bio_err, "Error: The input data looks too long to be a hash\n"); goto end; diff --git a/contrib/libs/openssl/apps/rehash.c b/contrib/libs/openssl/apps/rehash.c index fd53baf4f0..fc1dffe974 100644 --- a/contrib/libs/openssl/apps/rehash.c +++ b/contrib/libs/openssl/apps/rehash.c @@ -1,5 +1,5 @@ /* - * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2013-2014 Timo Teräs <timo.teras@gmail.com> * * Licensed under the OpenSSL license (the "License"). You may not use @@ -274,19 +274,19 @@ static int do_file(const char *filename, const char *fullpath, enum Hash h) if (x->x509 != NULL) { type = TYPE_CERT; name = X509_get_subject_name(x->x509); - if (!X509_digest(x->x509, evpmd, digest, NULL)) { - BIO_printf(bio_err, "out of memory\n"); - ++errs; - goto end; - } + if (!X509_digest(x->x509, evpmd, digest, NULL)) { + BIO_printf(bio_err, "out of memory\n"); + ++errs; + goto end; + } } else if (x->crl != NULL) { type = TYPE_CRL; name = X509_CRL_get_issuer(x->crl); - if (!X509_CRL_digest(x->crl, evpmd, digest, NULL)) { - BIO_printf(bio_err, "out of memory\n"); - ++errs; - goto end; - } + if (!X509_CRL_digest(x->crl, evpmd, digest, NULL)) { + BIO_printf(bio_err, "out of memory\n"); + ++errs; + goto end; + } } else { ++errs; goto end; diff --git a/contrib/libs/openssl/apps/req.c b/contrib/libs/openssl/apps/req.c index 61fc72e311..a603907cd5 100644 --- a/contrib/libs/openssl/apps/req.c +++ b/contrib/libs/openssl/apps/req.c @@ -200,12 +200,12 @@ static int duplicated(LHASH_OF(OPENSSL_STRING) *addexts, char *kv) *p = '\0'; /* Finally have a clean "key"; see if it's there [by attempt to add it]. */ - p = (char *)lh_OPENSSL_STRING_insert(addexts, (OPENSSL_STRING*)kv); - if (p != NULL) { - OPENSSL_free(p); - return 1; - } else if (lh_OPENSSL_STRING_error(addexts)) { - OPENSSL_free(kv); + p = (char *)lh_OPENSSL_STRING_insert(addexts, (OPENSSL_STRING*)kv); + if (p != NULL) { + OPENSSL_free(p); + return 1; + } else if (lh_OPENSSL_STRING_error(addexts)) { + OPENSSL_free(kv); return -1; } @@ -438,14 +438,14 @@ int req_main(int argc, char **argv) if (verbose) BIO_printf(bio_err, "Using configuration from %s\n", template); - if ((req_conf = app_load_config(template)) == NULL) - goto end; + if ((req_conf = app_load_config(template)) == NULL) + goto end; if (addext_bio) { if (verbose) BIO_printf(bio_err, "Using additional configuration from command line\n"); - if ((addext_conf = app_load_config_bio(addext_bio, NULL)) == NULL) - goto end; + if ((addext_conf = app_load_config_bio(addext_bio, NULL)) == NULL) + goto end; } if (template != default_config_file && !app_load_modules(req_conf)) goto end; diff --git a/contrib/libs/openssl/apps/rsa.c b/contrib/libs/openssl/apps/rsa.c index 7cde90b750..aeda917cc7 100644 --- a/contrib/libs/openssl/apps/rsa.c +++ b/contrib/libs/openssl/apps/rsa.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,19 +8,19 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include "apps.h" -#include "progs.h" -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/rsa.h> -#include <openssl/evp.h> -#include <openssl/x509.h> -#include <openssl/pem.h> -#include <openssl/bn.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include "apps.h" +#include "progs.h" +#include <openssl/bio.h> +#include <openssl/err.h> +#include <openssl/rsa.h> +#include <openssl/evp.h> +#include <openssl/x509.h> +#include <openssl/pem.h> +#include <openssl/bn.h> typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -49,14 +49,14 @@ const OPTIONS rsa_options[] = { {"modulus", OPT_MODULUS, '-', "Print the RSA key modulus"}, {"check", OPT_CHECK, '-', "Verify key consistency"}, {"", OPT_CIPHER, '-', "Any supported cipher"}, -#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) +#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) {"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"}, {"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"}, {"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"}, -#endif -#ifndef OPENSSL_NO_ENGINE +#endif +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -#endif +#endif {NULL} }; @@ -71,9 +71,9 @@ int rsa_main(int argc, char **argv) int i, private = 0; int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, check = 0; int noout = 0, modulus = 0, pubin = 0, pubout = 0, ret = 1; -#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) +#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) int pvk_encr = 2; -#endif +#endif OPTION_CHOICE o; prog = opt_init(argc, argv, rsa_options); @@ -126,9 +126,9 @@ int rsa_main(int argc, char **argv) case OPT_PVK_STRONG: /* pvk_encr:= 2 */ case OPT_PVK_WEAK: /* pvk_encr:= 1 */ case OPT_PVK_NONE: /* pvk_encr:= 0 */ -#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) +#if !defined(OPENSSL_NO_DSA) && !defined(OPENSSL_NO_RC4) pvk_encr = (o - OPT_PVK_NONE); -#endif +#endif break; case OPT_NOOUT: noout = 1; @@ -261,7 +261,7 @@ int rsa_main(int argc, char **argv) i = PEM_write_bio_RSAPrivateKey(out, rsa, enc, NULL, 0, NULL, passout); } -#ifndef OPENSSL_NO_DSA +#ifndef OPENSSL_NO_DSA } else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) { EVP_PKEY *pk; pk = EVP_PKEY_new(); @@ -276,13 +276,13 @@ int rsa_main(int argc, char **argv) goto end; } assert(private); -# ifdef OPENSSL_NO_RC4 +# ifdef OPENSSL_NO_RC4 BIO_printf(bio_err, "PVK format not supported\n"); EVP_PKEY_free(pk); goto end; -# else +# else i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout); -# endif +# endif } else if (pubin || pubout) { i = i2b_PublicKey_bio(out, pk); } else { @@ -290,7 +290,7 @@ int rsa_main(int argc, char **argv) i = i2b_PrivateKey_bio(out, pk); } EVP_PKEY_free(pk); -#endif +#endif } else { BIO_printf(bio_err, "bad output format specified for outfile\n"); goto end; diff --git a/contrib/libs/openssl/apps/rsautl.c b/contrib/libs/openssl/apps/rsautl.c index 5686e0170f..0c0fa8eba3 100644 --- a/contrib/libs/openssl/apps/rsautl.c +++ b/contrib/libs/openssl/apps/rsautl.c @@ -1,5 +1,5 @@ /* - * Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,21 +8,21 @@ */ #include <openssl/opensslconf.h> -#include "apps.h" -#include "progs.h" -#include <string.h> -#include <openssl/err.h> -#include <openssl/pem.h> -#include <openssl/rsa.h> +#include "apps.h" +#include "progs.h" +#include <string.h> +#include <openssl/err.h> +#include <openssl/pem.h> +#include <openssl/rsa.h> -#define RSA_SIGN 1 -#define RSA_VERIFY 2 -#define RSA_ENCRYPT 3 -#define RSA_DECRYPT 4 +#define RSA_SIGN 1 +#define RSA_VERIFY 2 +#define RSA_ENCRYPT 3 +#define RSA_DECRYPT 4 -#define KEY_PRIVKEY 1 -#define KEY_PUBKEY 2 -#define KEY_CERT 3 +#define KEY_PRIVKEY 1 +#define KEY_PUBKEY 2 +#define KEY_CERT 3 typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, @@ -56,9 +56,9 @@ const OPTIONS rsautl_options[] = { {"decrypt", OPT_DECRYPT, '-', "Decrypt with private key"}, {"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, OPT_R_OPTIONS, -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -#endif +#endif {NULL} }; diff --git a/contrib/libs/openssl/apps/s_cb.c b/contrib/libs/openssl/apps/s_cb.c index fef2b25ace..dee1b2e5b4 100644 --- a/contrib/libs/openssl/apps/s_cb.c +++ b/contrib/libs/openssl/apps/s_cb.c @@ -188,7 +188,7 @@ static STRINT_PAIR cert_type_list[] = { {"RSA fixed ECDH", TLS_CT_RSA_FIXED_ECDH}, {"ECDSA fixed ECDH", TLS_CT_ECDSA_FIXED_ECDH}, {"GOST01 Sign", TLS_CT_GOST01_SIGN}, - {"GOST12 Sign", TLS_CT_GOST12_SIGN}, + {"GOST12 Sign", TLS_CT_GOST12_SIGN}, {NULL} }; diff --git a/contrib/libs/openssl/apps/s_server.c b/contrib/libs/openssl/apps/s_server.c index e372e32e02..938e244222 100644 --- a/contrib/libs/openssl/apps/s_server.c +++ b/contrib/libs/openssl/apps/s_server.c @@ -1915,7 +1915,7 @@ int s_server_main(int argc, char *argv[]) BIO_printf(bio_s_out, "Setting secondary ctx parameters\n"); if (sdebug) - ssl_ctx_security_debug(ctx2, sdebug); + ssl_ctx_security_debug(ctx2, sdebug); if (session_id_prefix) { if (strlen(session_id_prefix) >= 32) @@ -3216,12 +3216,12 @@ static int www_body(int s, int stype, int prot, unsigned char *context) if (e[0] == ' ') break; - if (e[0] == ':') { - /* Windows drive. We treat this the same way as ".." */ - dot = -1; - break; - } - + if (e[0] == ':') { + /* Windows drive. We treat this the same way as ".." */ + dot = -1; + break; + } + switch (dot) { case 1: dot = (e[0] == '.') ? 2 : 0; @@ -3230,11 +3230,11 @@ static int www_body(int s, int stype, int prot, unsigned char *context) dot = (e[0] == '.') ? 3 : 0; break; case 3: - dot = (e[0] == '/' || e[0] == '\\') ? -1 : 0; + dot = (e[0] == '/' || e[0] == '\\') ? -1 : 0; break; } if (dot == 0) - dot = (e[0] == '/' || e[0] == '\\') ? 1 : 0; + dot = (e[0] == '/' || e[0] == '\\') ? 1 : 0; } dot = (dot == 3) || (dot == -1); /* filename contains ".." * component */ @@ -3248,11 +3248,11 @@ static int www_body(int s, int stype, int prot, unsigned char *context) if (dot) { BIO_puts(io, text); - BIO_printf(io, "'%s' contains '..' or ':'\r\n", p); + BIO_printf(io, "'%s' contains '..' or ':'\r\n", p); break; } - if (*p == '/' || *p == '\\') { + if (*p == '/' || *p == '\\') { BIO_puts(io, text); BIO_printf(io, "'%s' is an invalid path\r\n", p); break; diff --git a/contrib/libs/openssl/apps/s_time.c b/contrib/libs/openssl/apps/s_time.c index 1935725c2f..1235e545c2 100644 --- a/contrib/libs/openssl/apps/s_time.c +++ b/contrib/libs/openssl/apps/s_time.c @@ -62,7 +62,7 @@ const OPTIONS s_time_options[] = { {"key", OPT_KEY, '<', "File with key, PEM; default is -cert file"}, {"CApath", OPT_CAPATH, '/', "PEM format directory of CA's"}, {"cafile", OPT_CAFILE, '<', "PEM format file of CA's"}, - {"CAfile", OPT_CAFILE, '<', "PEM format file of CA's"}, + {"CAfile", OPT_CAFILE, '<', "PEM format file of CA's"}, {"no-CAfile", OPT_NOCAFILE, '-', "Do not load the default certificates file"}, {"no-CApath", OPT_NOCAPATH, '-', diff --git a/contrib/libs/openssl/apps/speed.c b/contrib/libs/openssl/apps/speed.c index 0aa380c47b..d4ae7ab7bf 100644 --- a/contrib/libs/openssl/apps/speed.c +++ b/contrib/libs/openssl/apps/speed.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -2410,7 +2410,7 @@ int speed_main(int argc, char **argv) print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][testnum], lengths[testnum], seconds.sym); Time_F(START); - for (count = 0; COND(c[D_CBC_128_CML][testnum]); count++) + for (count = 0; COND(c[D_CBC_128_CML][testnum]); count++) Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, (size_t)lengths[testnum], &camellia_ks1, iv, CAMELLIA_ENCRYPT); @@ -2432,7 +2432,7 @@ int speed_main(int argc, char **argv) exit(1); } Time_F(START); - for (count = 0; COND(c[D_CBC_192_CML][testnum]); count++) + for (count = 0; COND(c[D_CBC_192_CML][testnum]); count++) Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, (size_t)lengths[testnum], &camellia_ks2, iv, CAMELLIA_ENCRYPT); @@ -2450,7 +2450,7 @@ int speed_main(int argc, char **argv) print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][testnum], lengths[testnum], seconds.sym); Time_F(START); - for (count = 0; COND(c[D_CBC_256_CML][testnum]); count++) + for (count = 0; COND(c[D_CBC_256_CML][testnum]); count++) Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, (size_t)lengths[testnum], &camellia_ks3, iv, CAMELLIA_ENCRYPT); @@ -2470,7 +2470,7 @@ int speed_main(int argc, char **argv) print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][testnum], lengths[testnum], seconds.sym); Time_F(START); - for (count = 0; COND(c[D_CBC_IDEA][testnum]); count++) + for (count = 0; COND(c[D_CBC_IDEA][testnum]); count++) IDEA_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, (size_t)lengths[testnum], &idea_ks, iv, IDEA_ENCRYPT); @@ -2490,7 +2490,7 @@ int speed_main(int argc, char **argv) print_message(names[D_CBC_SEED], c[D_CBC_SEED][testnum], lengths[testnum], seconds.sym); Time_F(START); - for (count = 0; COND(c[D_CBC_SEED][testnum]); count++) + for (count = 0; COND(c[D_CBC_SEED][testnum]); count++) SEED_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, (size_t)lengths[testnum], &seed_ks, iv, 1); d = Time_F(STOP); @@ -2513,7 +2513,7 @@ int speed_main(int argc, char **argv) exit(1); } Time_F(START); - for (count = 0; COND(c[D_CBC_RC2][testnum]); count++) + for (count = 0; COND(c[D_CBC_RC2][testnum]); count++) RC2_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, (size_t)lengths[testnum], &rc2_ks, iv, RC2_ENCRYPT); @@ -2537,7 +2537,7 @@ int speed_main(int argc, char **argv) exit(1); } Time_F(START); - for (count = 0; COND(c[D_CBC_RC5][testnum]); count++) + for (count = 0; COND(c[D_CBC_RC5][testnum]); count++) RC5_32_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, (size_t)lengths[testnum], &rc5_ks, iv, RC5_ENCRYPT); @@ -2557,7 +2557,7 @@ int speed_main(int argc, char **argv) print_message(names[D_CBC_BF], c[D_CBC_BF][testnum], lengths[testnum], seconds.sym); Time_F(START); - for (count = 0; COND(c[D_CBC_BF][testnum]); count++) + for (count = 0; COND(c[D_CBC_BF][testnum]); count++) BF_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, (size_t)lengths[testnum], &bf_ks, iv, BF_ENCRYPT); @@ -2577,7 +2577,7 @@ int speed_main(int argc, char **argv) print_message(names[D_CBC_CAST], c[D_CBC_CAST][testnum], lengths[testnum], seconds.sym); Time_F(START); - for (count = 0; COND(c[D_CBC_CAST][testnum]); count++) + for (count = 0; COND(c[D_CBC_CAST][testnum]); count++) CAST_cbc_encrypt(loopargs[0].buf, loopargs[0].buf, (size_t)lengths[testnum], &cast_ks, iv, CAST_ENCRYPT); @@ -3004,7 +3004,7 @@ int speed_main(int argc, char **argv) pctx = NULL; } if (kctx == NULL || /* keygen ctx is not null */ - EVP_PKEY_keygen_init(kctx) <= 0/* init keygen ctx */ ) { + EVP_PKEY_keygen_init(kctx) <= 0/* init keygen ctx */ ) { ecdh_checks = 0; BIO_printf(bio_err, "ECDH keygen failure.\n"); ERR_print_errors(bio_err); @@ -3012,12 +3012,12 @@ int speed_main(int argc, char **argv) break; } - if (EVP_PKEY_keygen(kctx, &key_A) <= 0 || /* generate secret key A */ - EVP_PKEY_keygen(kctx, &key_B) <= 0 || /* generate secret key B */ + if (EVP_PKEY_keygen(kctx, &key_A) <= 0 || /* generate secret key A */ + EVP_PKEY_keygen(kctx, &key_B) <= 0 || /* generate secret key B */ !(ctx = EVP_PKEY_CTX_new(key_A, NULL)) || /* derivation ctx from skeyA */ - EVP_PKEY_derive_init(ctx) <= 0 || /* init derivation ctx */ - EVP_PKEY_derive_set_peer(ctx, key_B) <= 0 || /* set peer pubkey in ctx */ - EVP_PKEY_derive(ctx, NULL, &outlen) <= 0 || /* determine max length */ + EVP_PKEY_derive_init(ctx) <= 0 || /* init derivation ctx */ + EVP_PKEY_derive_set_peer(ctx, key_B) <= 0 || /* set peer pubkey in ctx */ + EVP_PKEY_derive(ctx, NULL, &outlen) <= 0 || /* determine max length */ outlen == 0 || /* ensure outlen is a valid size */ outlen > MAX_ECDH_SIZE /* avoid buffer overflow */ ) { ecdh_checks = 0; @@ -3104,8 +3104,8 @@ int speed_main(int argc, char **argv) if ((ed_pctx = EVP_PKEY_CTX_new_id(test_ed_curves[testnum].nid, NULL)) == NULL - || EVP_PKEY_keygen_init(ed_pctx) <= 0 - || EVP_PKEY_keygen(ed_pctx, &ed_pkey) <= 0) { + || EVP_PKEY_keygen_init(ed_pctx) <= 0 + || EVP_PKEY_keygen(ed_pctx, &ed_pkey) <= 0) { st = 0; EVP_PKEY_CTX_free(ed_pctx); break; @@ -3393,7 +3393,7 @@ static void print_message(const char *s, long num, int length, int tm) mr ? "+DT:%s:%d:%d\n" : "Doing %s for %ds on %d size blocks: ", s, tm, length); (void)BIO_flush(bio_err); - run = 1; + run = 1; alarm(tm); #else BIO_printf(bio_err, @@ -3411,7 +3411,7 @@ static void pkey_print_message(const char *str, const char *str2, long num, mr ? "+DTP:%d:%s:%s:%d\n" : "Doing %u bits %s %s's for %ds: ", bits, str, str2, tm); (void)BIO_flush(bio_err); - run = 1; + run = 1; alarm(tm); #else BIO_printf(bio_err, @@ -3584,7 +3584,7 @@ static int do_multi(int multi, int size_num) p = buf + 4; k = atoi(sstrsep(&p, sep)); sstrsep(&p, sep); - sstrsep(&p, sep); + sstrsep(&p, sep); d = atof(sstrsep(&p, sep)); eddsa_results[k][0] += d; @@ -3642,7 +3642,7 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher, int lengths_single, for (j = 0; j < num; j++) { print_message(alg_name, 0, mblengths[j], seconds->sym); Time_F(START); - for (count = 0; run && count < 0x7fffffff; count++) { + for (count = 0; run && count < 0x7fffffff; count++) { unsigned char aad[EVP_AEAD_TLS1_AAD_LEN]; EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM mb_param; size_t len = mblengths[j]; diff --git a/contrib/libs/openssl/apps/srp.c b/contrib/libs/openssl/apps/srp.c index a1ed9ba231..6c58173879 100644 --- a/contrib/libs/openssl/apps/srp.c +++ b/contrib/libs/openssl/apps/srp.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2004-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2004, EdelKey Project. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use @@ -12,24 +12,24 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <openssl/conf.h> -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/txt_db.h> -#include <openssl/buffer.h> -#include <openssl/srp.h> -#include "apps.h" -#include "progs.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <openssl/conf.h> +#include <openssl/bio.h> +#include <openssl/err.h> +#include <openssl/txt_db.h> +#include <openssl/buffer.h> +#include <openssl/srp.h> +#include "apps.h" +#include "progs.h" -#define BASE_SECTION "srp" -#define CONFIG_FILE "openssl.cnf" +#define BASE_SECTION "srp" +#define CONFIG_FILE "openssl.cnf" -#define ENV_DATABASE "srpvfile" -#define ENV_DEFAULT_SRP "default_srp" +#define ENV_DATABASE "srpvfile" +#define ENV_DEFAULT_SRP "default_srp" static int get_index(CA_DB *db, char *id, char type) { @@ -208,9 +208,9 @@ const OPTIONS srp_options[] = { {"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passout", OPT_PASSOUT, 's', "Output file pass phrase source"}, OPT_R_OPTIONS, -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -#endif +#endif {NULL} }; diff --git a/contrib/libs/openssl/apps/timeouts.h b/contrib/libs/openssl/apps/timeouts.h index c18f6439ed..7e606cba0b 100644 --- a/contrib/libs/openssl/apps/timeouts.h +++ b/contrib/libs/openssl/apps/timeouts.h @@ -7,11 +7,11 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_APPS_TIMEOUTS_H -# define OSSL_APPS_TIMEOUTS_H +#ifndef OSSL_APPS_TIMEOUTS_H +# define OSSL_APPS_TIMEOUTS_H /* numbers in us */ # define DGRAM_RCV_TIMEOUT 250000 # define DGRAM_SND_TIMEOUT 250000 -#endif /* ! OSSL_APPS_TIMEOUTS_H */ +#endif /* ! OSSL_APPS_TIMEOUTS_H */ diff --git a/contrib/libs/openssl/apps/ts.c b/contrib/libs/openssl/apps/ts.c index 92a5163bb7..66a0c810e0 100644 --- a/contrib/libs/openssl/apps/ts.c +++ b/contrib/libs/openssl/apps/ts.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,26 +8,26 @@ */ #include <openssl/opensslconf.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "apps.h" -#include "progs.h" -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/pem.h> -#include <openssl/rand.h> -#include <openssl/ts.h> -#include <openssl/bn.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "apps.h" +#include "progs.h" +#include <openssl/bio.h> +#include <openssl/err.h> +#include <openssl/pem.h> +#include <openssl/rand.h> +#include <openssl/ts.h> +#include <openssl/bn.h> /* Request nonce length, in bits (must be a multiple of 8). */ -#define NONCE_LENGTH 64 +#define NONCE_LENGTH 64 /* Name of config entry that defines the OID file. */ -#define ENV_OID_FILE "oid_file" +#define ENV_OID_FILE "oid_file" /* Is |EXACTLY_ONE| of three pointers set? */ -#define EXACTLY_ONE(a, b, c) \ +#define EXACTLY_ONE(a, b, c) \ (( a && !b && !c) || \ ( b && !a && !c) || \ ( c && !a && !b)) @@ -111,9 +111,9 @@ const OPTIONS ts_options[] = { {"CAfile", OPT_CAFILE, '<', "File with trusted CA certs"}, {"untrusted", OPT_UNTRUSTED, '<', "File with untrusted certs"}, {"", OPT_MD, '-', "Any supported digest"}, -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, -#endif +#endif {OPT_HELP_STR, 1, '-', "\nOptions specific to 'ts -verify': \n"}, OPT_V_OPTIONS, {OPT_HELP_STR, 1, '-', "\n"}, @@ -134,11 +134,11 @@ static char* opt_helplist[] = { " [-signer tsa_cert.pem] [-inkey private_key.pem]", " [-chain certs_file.pem] [-tspolicy oid]", " [-in file] [-token_in] [-out file] [-token_out]", -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE " [-text] [-engine id]", -#else +#else " [-text]", -#endif +#endif " or", "ts -verify -CApath dir -CAfile file.pem -untrusted file.pem", " [-data file] [-digest hexstring]", @@ -279,8 +279,8 @@ int ts_main(int argc, char **argv) goto end; } - if ((conf = load_config_file(configfile)) == NULL) - goto end; + if ((conf = load_config_file(configfile)) == NULL) + goto end; if (configfile != default_config_file && !app_load_modules(conf)) goto end; @@ -679,10 +679,10 @@ static TS_RESP *create_response(CONF *conf, const char *section, const char *eng goto end; if (!TS_CONF_set_serial(conf, section, serial_cb, resp_ctx)) goto end; -#ifndef OPENSSL_NO_ENGINE +#ifndef OPENSSL_NO_ENGINE if (!TS_CONF_set_crypto_device(conf, section, engine)) goto end; -#endif +#endif if (!TS_CONF_set_signer_cert(conf, section, signer, resp_ctx)) goto end; if (!TS_CONF_set_certs(conf, section, chain, resp_ctx)) diff --git a/contrib/libs/openssl/apps/vms_term_sock.c b/contrib/libs/openssl/apps/vms_term_sock.c index 53c7fa747e..1dc4b155aa 100644 --- a/contrib/libs/openssl/apps/vms_term_sock.c +++ b/contrib/libs/openssl/apps/vms_term_sock.c @@ -37,7 +37,7 @@ # include <starlet.h> # include <iodef.h> # ifdef __alpha -# error #include <iosbdef.h> +# error #include <iosbdef.h> # else typedef struct _iosb { /* Copied from IOSBDEF.H for Alpha */ # pragma __nomember_alignment @@ -82,7 +82,7 @@ typedef struct _iosb { /* Copied from IOSBDEF.H for Alpha */ # endif /* End of IOSBDEF */ -# error #include <efndef.h> +# error #include <efndef.h> # include <stdlib.h> # include <ssdef.h> # include <time.h> diff --git a/contrib/libs/openssl/apps/vms_term_sock.h b/contrib/libs/openssl/apps/vms_term_sock.h index b5a1a00fcd..e092b18eaa 100644 --- a/contrib/libs/openssl/apps/vms_term_sock.h +++ b/contrib/libs/openssl/apps/vms_term_sock.h @@ -8,8 +8,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_APPS_VMS_TERM_SOCK_H -# define OSSL_APPS_VMS_TERM_SOCK_H +#ifndef OSSL_APPS_VMS_TERM_SOCK_H +# define OSSL_APPS_VMS_TERM_SOCK_H /* ** Terminal Socket Function Codes diff --git a/contrib/libs/openssl/apps/x509.c b/contrib/libs/openssl/apps/x509.c index 8cb2edc1e0..1043eba0c8 100644 --- a/contrib/libs/openssl/apps/x509.c +++ b/contrib/libs/openssl/apps/x509.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -72,7 +72,7 @@ const OPTIONS x509_options[] = { {"outform", OPT_OUTFORM, 'f', "Output format - default PEM (one of DER or PEM)"}, {"out", OPT_OUT, '>', "Output file - default stdout"}, - {"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"}, + {"keyform", OPT_KEYFORM, 'E', "Private key format - default PEM"}, {"passin", OPT_PASSIN, 's', "Private key password/pass-phrase source"}, {"serial", OPT_SERIAL, '-', "Print serial number value"}, {"subject_hash", OPT_HASH, '-', "Print subject hash value"}, @@ -107,7 +107,7 @@ const OPTIONS x509_options[] = { {"checkend", OPT_CHECKEND, 'M', "Check whether the cert expires in the next arg seconds"}, {OPT_MORE_STR, 1, 1, "Exit 1 if so, 0 if not"}, - {"signkey", OPT_SIGNKEY, 's', "Self sign cert with arg"}, + {"signkey", OPT_SIGNKEY, 's', "Self sign cert with arg"}, {"x509toreq", OPT_X509TOREQ, '-', "Output a certification request object"}, {"req", OPT_REQ, '-', "Input is a certificate request, sign and output"}, @@ -130,7 +130,7 @@ const OPTIONS x509_options[] = { {"checkemail", OPT_CHECKEMAIL, 's', "Check certificate matches email"}, {"checkip", OPT_CHECKIP, 's', "Check certificate matches ipaddr"}, {"CAform", OPT_CAFORM, 'F', "CA format - default PEM"}, - {"CAkeyform", OPT_CAKEYFORM, 'E', "CA key format - default PEM"}, + {"CAkeyform", OPT_CAKEYFORM, 'E', "CA key format - default PEM"}, {"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"}, {"force_pubkey", OPT_FORCE_PUBKEY, '<', "Force the Key to put inside certificate"}, {"next_serial", OPT_NEXT_SERIAL, '-', "Increment current certificate serial number"}, @@ -217,7 +217,7 @@ int x509_main(int argc, char **argv) goto opthelp; break; case OPT_KEYFORM: - if (!opt_format(opt_arg(), OPT_FMT_PDE, &keyformat)) + if (!opt_format(opt_arg(), OPT_FMT_PDE, &keyformat)) goto opthelp; break; case OPT_CAFORM: @@ -225,7 +225,7 @@ int x509_main(int argc, char **argv) goto opthelp; break; case OPT_CAKEYFORM: - if (!opt_format(opt_arg(), OPT_FMT_PDE, &CAkeyformat)) + if (!opt_format(opt_arg(), OPT_FMT_PDE, &CAkeyformat)) goto opthelp; break; case OPT_OUT: diff --git a/contrib/libs/openssl/apps/ya.make b/contrib/libs/openssl/apps/ya.make index a2c994d2d9..e6b81c6b18 100644 --- a/contrib/libs/openssl/apps/ya.make +++ b/contrib/libs/openssl/apps/ya.make @@ -14,7 +14,7 @@ LICENSE_TEXTS(.yandex_meta/licenses.list.txt) PEERDIR( contrib/libs/openssl - contrib/libs/openssl/crypto + contrib/libs/openssl/crypto ) ADDINCL( @@ -23,23 +23,23 @@ ADDINCL( contrib/libs/openssl/include ) -NO_COMPILER_WARNINGS() - -NO_RUNTIME() - +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + CFLAGS( - -DAESNI_ASM + -DAESNI_ASM -DECP_NISTZ256_ASM -DKECCAK1600_ASM -DOPENSSL_BN_ASM_MONT -DOPENSSL_CPUID_OBJ - -DOPENSSL_PIC + -DOPENSSL_PIC -DPOLY1305_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DVPAES_ASM - -DZLIB + -DZLIB ) IF (OS_DARWIN AND ARCH_X86_64 OR OS_LINUX AND ARCH_AARCH64 OR OS_LINUX AND ARCH_X86_64) diff --git a/contrib/libs/openssl/asm/linux/crypto/aes/aesni-sha1-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/aes/aesni-sha1-x86_64.s index b383f1689d..a38e21f048 100644 --- a/contrib/libs/openssl/asm/linux/crypto/aes/aesni-sha1-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/aes/aesni-sha1-x86_64.s @@ -5,7 +5,7 @@ .type aesni_cbc_sha1_enc,@function .align 32 aesni_cbc_sha1_enc: -.cfi_startproc +.cfi_startproc movl OPENSSL_ia32cap_P+0(%rip),%r10d movq OPENSSL_ia32cap_P+4(%rip),%r11 @@ -18,7 +18,7 @@ aesni_cbc_sha1_enc: je aesni_cbc_sha1_enc_avx jmp aesni_cbc_sha1_enc_ssse3 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size aesni_cbc_sha1_enc,.-aesni_cbc_sha1_enc .type aesni_cbc_sha1_enc_ssse3,@function .align 32 @@ -2732,7 +2732,7 @@ K_XX_XX: .type aesni_cbc_sha1_enc_shaext,@function .align 32 aesni_cbc_sha1_enc_shaext: -.cfi_startproc +.cfi_startproc movq 8(%rsp),%r10 movdqu (%r9),%xmm8 movd 16(%r9),%xmm9 @@ -3031,5 +3031,5 @@ aesni_cbc_sha1_enc_shaext: movdqu %xmm8,(%r9) movd %xmm9,16(%r9) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size aesni_cbc_sha1_enc_shaext,.-aesni_cbc_sha1_enc_shaext diff --git a/contrib/libs/openssl/asm/linux/crypto/aes/aesni-sha256-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/aes/aesni-sha256-x86_64.s index 0b9041cc45..3e56a82578 100644 --- a/contrib/libs/openssl/asm/linux/crypto/aes/aesni-sha256-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/aes/aesni-sha256-x86_64.s @@ -5,7 +5,7 @@ .type aesni_cbc_sha256_enc,@function .align 16 aesni_cbc_sha256_enc: -.cfi_startproc +.cfi_startproc leaq OPENSSL_ia32cap_P(%rip),%r11 movl $1,%eax cmpq $0,%rdi @@ -31,7 +31,7 @@ aesni_cbc_sha256_enc: ud2 .Lprobe: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size aesni_cbc_sha256_enc,.-aesni_cbc_sha256_enc .align 64 @@ -2530,15 +2530,15 @@ aesni_cbc_sha256_enc_avx2: vmovdqa %ymm4,0(%rsp) xorl %r14d,%r14d vmovdqa %ymm5,32(%rsp) - - movq 120(%rsp),%rsi -.cfi_def_cfa %rsi,8 + + movq 120(%rsp),%rsi +.cfi_def_cfa %rsi,8 leaq -64(%rsp),%rsp - - - - movq %rsi,-8(%rsp) -.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 + + + + movq %rsi,-8(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 movl %ebx,%esi vmovdqa %ymm6,0(%rsp) xorl %ecx,%esi @@ -2552,12 +2552,12 @@ aesni_cbc_sha256_enc_avx2: vmovdqu (%r13),%xmm9 vpinsrq $0,%r13,%xmm15,%xmm15 leaq -64(%rsp),%rsp -.cfi_escape 0x0f,0x05,0x77,0x38,0x06,0x23,0x08 - - pushq 64-8(%rsp) -.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 - leaq 8(%rsp),%rsp -.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 +.cfi_escape 0x0f,0x05,0x77,0x38,0x06,0x23,0x08 + + pushq 64-8(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 + leaq 8(%rsp),%rsp +.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 vpalignr $4,%ymm0,%ymm1,%ymm4 addl 0+128(%rsp),%r11d andl %r8d,%r12d @@ -2832,12 +2832,12 @@ aesni_cbc_sha256_enc_avx2: movl %r9d,%r12d vmovdqa %ymm6,32(%rsp) leaq -64(%rsp),%rsp -.cfi_escape 0x0f,0x05,0x77,0x38,0x06,0x23,0x08 - - pushq 64-8(%rsp) -.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 - leaq 8(%rsp),%rsp -.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 +.cfi_escape 0x0f,0x05,0x77,0x38,0x06,0x23,0x08 + + pushq 64-8(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 + leaq 8(%rsp),%rsp +.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 vpalignr $4,%ymm2,%ymm3,%ymm4 addl 0+128(%rsp),%r11d andl %r8d,%r12d @@ -4051,12 +4051,12 @@ aesni_cbc_sha256_enc_avx2: jbe .Loop_avx2 leaq (%rsp),%rbp - -.cfi_escape 0x0f,0x06,0x76,0xf8,0x00,0x06,0x23,0x08 - + +.cfi_escape 0x0f,0x06,0x76,0xf8,0x00,0x06,0x23,0x08 + .Ldone_avx2: - movq 64+32(%rbp),%r8 - movq 64+56(%rbp),%rsi + movq 64+32(%rbp),%r8 + movq 64+56(%rbp),%rsi .cfi_def_cfa %rsi,8 vmovdqu %xmm8,(%r8) vzeroall @@ -4081,7 +4081,7 @@ aesni_cbc_sha256_enc_avx2: .type aesni_cbc_sha256_enc_shaext,@function .align 32 aesni_cbc_sha256_enc_shaext: -.cfi_startproc +.cfi_startproc movq 8(%rsp),%r10 leaq K256+128(%rip),%rax movdqu (%r9),%xmm1 @@ -4431,5 +4431,5 @@ aesni_cbc_sha256_enc_shaext: movdqu %xmm1,(%r9) movdqu %xmm2,16(%r9) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size aesni_cbc_sha256_enc_shaext,.-aesni_cbc_sha256_enc_shaext diff --git a/contrib/libs/openssl/asm/linux/crypto/aes/aesni-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/aes/aesni-x86_64.s index 5f25c1c81f..1a4b22e7b8 100644 --- a/contrib/libs/openssl/asm/linux/crypto/aes/aesni-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/aes/aesni-x86_64.s @@ -861,7 +861,7 @@ aesni_ecb_encrypt: .type aesni_ccm64_encrypt_blocks,@function .align 16 aesni_ccm64_encrypt_blocks: -.cfi_startproc +.cfi_startproc movl 240(%rcx),%eax movdqu (%r8),%xmm6 movdqa .Lincrement64(%rip),%xmm9 @@ -920,13 +920,13 @@ aesni_ccm64_encrypt_blocks: pxor %xmm8,%xmm8 pxor %xmm6,%xmm6 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size aesni_ccm64_encrypt_blocks,.-aesni_ccm64_encrypt_blocks .globl aesni_ccm64_decrypt_blocks .type aesni_ccm64_decrypt_blocks,@function .align 16 aesni_ccm64_decrypt_blocks: -.cfi_startproc +.cfi_startproc movl 240(%rcx),%eax movups (%r8),%xmm6 movdqu (%r9),%xmm3 @@ -1019,7 +1019,7 @@ aesni_ccm64_decrypt_blocks: pxor %xmm8,%xmm8 pxor %xmm6,%xmm6 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size aesni_ccm64_decrypt_blocks,.-aesni_ccm64_decrypt_blocks .globl aesni_ctr32_encrypt_blocks .type aesni_ctr32_encrypt_blocks,@function @@ -2794,7 +2794,7 @@ aesni_ocb_encrypt: .type __ocb_encrypt6,@function .align 32 __ocb_encrypt6: -.cfi_startproc +.cfi_startproc pxor %xmm9,%xmm15 movdqu (%rbx,%r12,1),%xmm11 movdqa %xmm10,%xmm12 @@ -2892,13 +2892,13 @@ __ocb_encrypt6: .byte 102,65,15,56,221,246 .byte 102,65,15,56,221,255 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __ocb_encrypt6,.-__ocb_encrypt6 .type __ocb_encrypt4,@function .align 32 __ocb_encrypt4: -.cfi_startproc +.cfi_startproc pxor %xmm9,%xmm15 movdqu (%rbx,%r12,1),%xmm11 movdqa %xmm10,%xmm12 @@ -2963,13 +2963,13 @@ __ocb_encrypt4: .byte 102,65,15,56,221,228 .byte 102,65,15,56,221,237 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __ocb_encrypt4,.-__ocb_encrypt4 .type __ocb_encrypt1,@function .align 32 __ocb_encrypt1: -.cfi_startproc +.cfi_startproc pxor %xmm15,%xmm7 pxor %xmm9,%xmm7 pxor %xmm2,%xmm8 @@ -3000,7 +3000,7 @@ __ocb_encrypt1: .byte 102,15,56,221,215 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __ocb_encrypt1,.-__ocb_encrypt1 .globl aesni_ocb_decrypt @@ -3243,7 +3243,7 @@ aesni_ocb_decrypt: .type __ocb_decrypt6,@function .align 32 __ocb_decrypt6: -.cfi_startproc +.cfi_startproc pxor %xmm9,%xmm15 movdqu (%rbx,%r12,1),%xmm11 movdqa %xmm10,%xmm12 @@ -3335,13 +3335,13 @@ __ocb_decrypt6: .byte 102,65,15,56,223,246 .byte 102,65,15,56,223,255 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __ocb_decrypt6,.-__ocb_decrypt6 .type __ocb_decrypt4,@function .align 32 __ocb_decrypt4: -.cfi_startproc +.cfi_startproc pxor %xmm9,%xmm15 movdqu (%rbx,%r12,1),%xmm11 movdqa %xmm10,%xmm12 @@ -3402,13 +3402,13 @@ __ocb_decrypt4: .byte 102,65,15,56,223,228 .byte 102,65,15,56,223,237 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __ocb_decrypt4,.-__ocb_decrypt4 .type __ocb_decrypt1,@function .align 32 __ocb_decrypt1: -.cfi_startproc +.cfi_startproc pxor %xmm15,%xmm7 pxor %xmm9,%xmm7 pxor %xmm7,%xmm2 @@ -3438,7 +3438,7 @@ __ocb_decrypt1: .byte 102,15,56,223,215 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __ocb_decrypt1,.-__ocb_decrypt1 .globl aesni_cbc_encrypt .type aesni_cbc_encrypt,@function @@ -4447,7 +4447,7 @@ __aesni_set_encrypt_key: shufps $170,%xmm1,%xmm1 xorps %xmm1,%xmm2 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size aesni_set_encrypt_key,.-aesni_set_encrypt_key .size __aesni_set_encrypt_key,.-__aesni_set_encrypt_key .align 64 diff --git a/contrib/libs/openssl/asm/linux/crypto/bn/rsaz-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/bn/rsaz-x86_64.s index f1037a427c..d5025b23cd 100644 --- a/contrib/libs/openssl/asm/linux/crypto/bn/rsaz-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/bn/rsaz-x86_64.s @@ -29,7 +29,7 @@ rsaz_512_sqr: subq $128+24,%rsp .cfi_adjust_cfa_offset 128+24 .Lsqr_body: -.byte 102,72,15,110,202 +.byte 102,72,15,110,202 movq (%rsi),%rdx movq 8(%rsi),%rax movq %rcx,128(%rsp) @@ -44,7 +44,7 @@ rsaz_512_sqr: movl %r8d,128+8(%rsp) movq %rdx,%rbx - movq %rax,%rbp + movq %rax,%rbp mulq %rdx movq %rax,%r8 movq 16(%rsi),%rax @@ -83,29 +83,29 @@ rsaz_512_sqr: mulq %rbx addq %rax,%r14 movq %rbx,%rax - adcq $0,%rdx + adcq $0,%rdx - xorq %rcx,%rcx + xorq %rcx,%rcx addq %r8,%r8 - movq %rdx,%r15 - adcq $0,%rcx + movq %rdx,%r15 + adcq $0,%rcx mulq %rax - addq %r8,%rdx - adcq $0,%rcx - + addq %r8,%rdx + adcq $0,%rcx + movq %rax,(%rsp) - movq %rdx,8(%rsp) + movq %rdx,8(%rsp) movq 16(%rsi),%rax - mulq %rbp + mulq %rbp addq %rax,%r10 movq 24(%rsi),%rax movq %rdx,%rbx adcq $0,%rbx - mulq %rbp + mulq %rbp addq %rax,%r11 movq 32(%rsi),%rax adcq $0,%rdx @@ -113,7 +113,7 @@ rsaz_512_sqr: movq %rdx,%rbx adcq $0,%rbx - mulq %rbp + mulq %rbp addq %rax,%r12 movq 40(%rsi),%rax adcq $0,%rdx @@ -121,7 +121,7 @@ rsaz_512_sqr: movq %rdx,%rbx adcq $0,%rbx - mulq %rbp + mulq %rbp addq %rax,%r13 movq 48(%rsi),%rax adcq $0,%rdx @@ -129,7 +129,7 @@ rsaz_512_sqr: movq %rdx,%rbx adcq $0,%rbx - mulq %rbp + mulq %rbp addq %rax,%r14 movq 56(%rsi),%rax adcq $0,%rdx @@ -137,39 +137,39 @@ rsaz_512_sqr: movq %rdx,%rbx adcq $0,%rbx - mulq %rbp + mulq %rbp addq %rax,%r15 - movq %rbp,%rax + movq %rbp,%rax adcq $0,%rdx addq %rbx,%r15 - adcq $0,%rdx - - xorq %rbx,%rbx - addq %r9,%r9 + adcq $0,%rdx + + xorq %rbx,%rbx + addq %r9,%r9 movq %rdx,%r8 - adcq %r10,%r10 - adcq $0,%rbx + adcq %r10,%r10 + adcq $0,%rbx - mulq %rax + mulq %rax - addq %rcx,%rax - movq 16(%rsi),%rbp + addq %rcx,%rax + movq 16(%rsi),%rbp addq %rax,%r9 - movq 24(%rsi),%rax + movq 24(%rsi),%rax adcq %rdx,%r10 - adcq $0,%rbx + adcq $0,%rbx movq %r9,16(%rsp) movq %r10,24(%rsp) - mulq %rbp + mulq %rbp addq %rax,%r12 movq 32(%rsi),%rax movq %rdx,%rcx adcq $0,%rcx - mulq %rbp + mulq %rbp addq %rax,%r13 movq 40(%rsi),%rax adcq $0,%rdx @@ -177,7 +177,7 @@ rsaz_512_sqr: movq %rdx,%rcx adcq $0,%rcx - mulq %rbp + mulq %rbp addq %rax,%r14 movq 48(%rsi),%rax adcq $0,%rdx @@ -185,7 +185,7 @@ rsaz_512_sqr: movq %rdx,%rcx adcq $0,%rcx - mulq %rbp + mulq %rbp addq %rax,%r15 movq 56(%rsi),%rax adcq $0,%rdx @@ -193,40 +193,40 @@ rsaz_512_sqr: movq %rdx,%rcx adcq $0,%rcx - mulq %rbp + mulq %rbp addq %rax,%r8 - movq %rbp,%rax + movq %rbp,%rax adcq $0,%rdx addq %rcx,%r8 - adcq $0,%rdx - - xorq %rcx,%rcx - addq %r11,%r11 + adcq $0,%rdx + + xorq %rcx,%rcx + addq %r11,%r11 movq %rdx,%r9 - adcq %r12,%r12 - adcq $0,%rcx + adcq %r12,%r12 + adcq $0,%rcx - mulq %rax + mulq %rax - addq %rbx,%rax - movq 24(%rsi),%r10 + addq %rbx,%rax + movq 24(%rsi),%r10 addq %rax,%r11 - movq 32(%rsi),%rax + movq 32(%rsi),%rax adcq %rdx,%r12 - adcq $0,%rcx + adcq $0,%rcx movq %r11,32(%rsp) movq %r12,40(%rsp) - movq %rax,%r11 + movq %rax,%r11 mulq %r10 addq %rax,%r14 movq 40(%rsi),%rax movq %rdx,%rbx adcq $0,%rbx - movq %rax,%r12 + movq %rax,%r12 mulq %r10 addq %rax,%r15 movq 48(%rsi),%rax @@ -235,7 +235,7 @@ rsaz_512_sqr: movq %rdx,%rbx adcq $0,%rbx - movq %rax,%rbp + movq %rax,%rbp mulq %r10 addq %rax,%r8 movq 56(%rsi),%rax @@ -249,21 +249,21 @@ rsaz_512_sqr: movq %r10,%rax adcq $0,%rdx addq %rbx,%r9 - adcq $0,%rdx - - xorq %rbx,%rbx - addq %r13,%r13 + adcq $0,%rdx + + xorq %rbx,%rbx + addq %r13,%r13 movq %rdx,%r10 - adcq %r14,%r14 - adcq $0,%rbx + adcq %r14,%r14 + adcq $0,%rbx - mulq %rax + mulq %rax - addq %rcx,%rax + addq %rcx,%rax addq %rax,%r13 - movq %r12,%rax + movq %r12,%rax adcq %rdx,%r14 - adcq $0,%rbx + adcq $0,%rbx movq %r13,48(%rsp) movq %r14,56(%rsp) @@ -271,7 +271,7 @@ rsaz_512_sqr: mulq %r11 addq %rax,%r8 - movq %rbp,%rax + movq %rbp,%rax movq %rdx,%rcx adcq $0,%rcx @@ -283,27 +283,27 @@ rsaz_512_sqr: movq %rdx,%rcx adcq $0,%rcx - movq %rax,%r14 + movq %rax,%r14 mulq %r11 addq %rax,%r10 movq %r11,%rax adcq $0,%rdx addq %rcx,%r10 - adcq $0,%rdx - - xorq %rcx,%rcx - addq %r15,%r15 + adcq $0,%rdx + + xorq %rcx,%rcx + addq %r15,%r15 movq %rdx,%r11 - adcq %r8,%r8 - adcq $0,%rcx + adcq %r8,%r8 + adcq $0,%rcx - mulq %rax + mulq %rax - addq %rbx,%rax + addq %rbx,%rax addq %rax,%r15 - movq %rbp,%rax + movq %rbp,%rax adcq %rdx,%r8 - adcq $0,%rcx + adcq $0,%rcx movq %r15,64(%rsp) movq %r8,72(%rsp) @@ -311,7 +311,7 @@ rsaz_512_sqr: mulq %r12 addq %rax,%r10 - movq %r14,%rax + movq %r14,%rax movq %rdx,%rbx adcq $0,%rbx @@ -320,58 +320,58 @@ rsaz_512_sqr: movq %r12,%rax adcq $0,%rdx addq %rbx,%r11 - adcq $0,%rdx - - xorq %rbx,%rbx - addq %r9,%r9 + adcq $0,%rdx + + xorq %rbx,%rbx + addq %r9,%r9 movq %rdx,%r12 - adcq %r10,%r10 - adcq $0,%rbx + adcq %r10,%r10 + adcq $0,%rbx - mulq %rax + mulq %rax - addq %rcx,%rax + addq %rcx,%rax addq %rax,%r9 - movq %r14,%rax + movq %r14,%rax adcq %rdx,%r10 - adcq $0,%rbx + adcq $0,%rbx movq %r9,80(%rsp) movq %r10,88(%rsp) - mulq %rbp + mulq %rbp addq %rax,%r12 - movq %rbp,%rax - adcq $0,%rdx - - xorq %rcx,%rcx - addq %r11,%r11 + movq %rbp,%rax + adcq $0,%rdx + + xorq %rcx,%rcx + addq %r11,%r11 movq %rdx,%r13 adcq %r12,%r12 - adcq $0,%rcx + adcq $0,%rcx mulq %rax - - addq %rbx,%rax + + addq %rbx,%rax addq %rax,%r11 - movq %r14,%rax + movq %r14,%rax adcq %rdx,%r12 - adcq $0,%rcx + adcq $0,%rcx movq %r11,96(%rsp) movq %r12,104(%rsp) - xorq %rbx,%rbx - addq %r13,%r13 - adcq $0,%rbx - + xorq %rbx,%rbx + addq %r13,%r13 + adcq $0,%rbx + mulq %rax - addq %rcx,%rax - addq %r13,%rax - adcq %rbx,%rdx + addq %rcx,%rax + addq %r13,%rax + adcq %rbx,%rdx movq (%rsp),%r8 movq 8(%rsp),%r9 @@ -381,11 +381,11 @@ rsaz_512_sqr: movq 40(%rsp),%r13 movq 48(%rsp),%r14 movq 56(%rsp),%r15 -.byte 102,72,15,126,205 +.byte 102,72,15,126,205 + + movq %rax,112(%rsp) + movq %rdx,120(%rsp) - movq %rax,112(%rsp) - movq %rdx,120(%rsp) - call __rsaz_512_reduce addq 64(%rsp),%r8 @@ -415,7 +415,7 @@ rsaz_512_sqr: .byte 102,72,15,110,199 mulxq %rax,%r8,%r9 - movq %rax,%rbx + movq %rax,%rbx mulxq 16(%rsi),%rcx,%r10 xorq %rbp,%rbp @@ -423,39 +423,39 @@ rsaz_512_sqr: mulxq 24(%rsi),%rax,%r11 adcxq %rcx,%r9 -.byte 0xc4,0x62,0xf3,0xf6,0xa6,0x20,0x00,0x00,0x00 +.byte 0xc4,0x62,0xf3,0xf6,0xa6,0x20,0x00,0x00,0x00 adcxq %rax,%r10 -.byte 0xc4,0x62,0xfb,0xf6,0xae,0x28,0x00,0x00,0x00 +.byte 0xc4,0x62,0xfb,0xf6,0xae,0x28,0x00,0x00,0x00 adcxq %rcx,%r11 - mulxq 48(%rsi),%rcx,%r14 + mulxq 48(%rsi),%rcx,%r14 adcxq %rax,%r12 adcxq %rcx,%r13 - mulxq 56(%rsi),%rax,%r15 + mulxq 56(%rsi),%rax,%r15 adcxq %rax,%r14 adcxq %rbp,%r15 - mulxq %rdx,%rax,%rdi - movq %rbx,%rdx - xorq %rcx,%rcx - adoxq %r8,%r8 - adcxq %rdi,%r8 - adoxq %rbp,%rcx - adcxq %rbp,%rcx + mulxq %rdx,%rax,%rdi + movq %rbx,%rdx + xorq %rcx,%rcx + adoxq %r8,%r8 + adcxq %rdi,%r8 + adoxq %rbp,%rcx + adcxq %rbp,%rcx movq %rax,(%rsp) movq %r8,8(%rsp) -.byte 0xc4,0xe2,0xfb,0xf6,0x9e,0x10,0x00,0x00,0x00 +.byte 0xc4,0xe2,0xfb,0xf6,0x9e,0x10,0x00,0x00,0x00 adoxq %rax,%r10 adcxq %rbx,%r11 - mulxq 24(%rsi),%rdi,%r8 + mulxq 24(%rsi),%rdi,%r8 adoxq %rdi,%r11 -.byte 0x66 +.byte 0x66 adcxq %r8,%r12 mulxq 32(%rsi),%rax,%rbx @@ -473,25 +473,25 @@ rsaz_512_sqr: .byte 0xc4,0x62,0xc3,0xf6,0x86,0x38,0x00,0x00,0x00 adoxq %rdi,%r15 adcxq %rbp,%r8 - mulxq %rdx,%rax,%rdi + mulxq %rdx,%rax,%rdi adoxq %rbp,%r8 -.byte 0x48,0x8b,0x96,0x10,0x00,0x00,0x00 +.byte 0x48,0x8b,0x96,0x10,0x00,0x00,0x00 - xorq %rbx,%rbx - adoxq %r9,%r9 + xorq %rbx,%rbx + adoxq %r9,%r9 - adcxq %rcx,%rax - adoxq %r10,%r10 + adcxq %rcx,%rax + adoxq %r10,%r10 adcxq %rax,%r9 - adoxq %rbp,%rbx - adcxq %rdi,%r10 - adcxq %rbp,%rbx + adoxq %rbp,%rbx + adcxq %rdi,%r10 + adcxq %rbp,%rbx movq %r9,16(%rsp) .byte 0x4c,0x89,0x94,0x24,0x18,0x00,0x00,0x00 - mulxq 24(%rsi),%rdi,%r9 + mulxq 24(%rsi),%rdi,%r9 adoxq %rdi,%r12 adcxq %r9,%r13 @@ -499,7 +499,7 @@ rsaz_512_sqr: adoxq %rax,%r13 adcxq %rcx,%r14 -.byte 0xc4,0x62,0xc3,0xf6,0x8e,0x28,0x00,0x00,0x00 +.byte 0xc4,0x62,0xc3,0xf6,0x8e,0x28,0x00,0x00,0x00 adoxq %rdi,%r14 adcxq %r9,%r15 @@ -507,28 +507,28 @@ rsaz_512_sqr: adoxq %rax,%r15 adcxq %rcx,%r8 - mulxq 56(%rsi),%rdi,%r9 + mulxq 56(%rsi),%rdi,%r9 adoxq %rdi,%r8 adcxq %rbp,%r9 - mulxq %rdx,%rax,%rdi + mulxq %rdx,%rax,%rdi adoxq %rbp,%r9 - movq 24(%rsi),%rdx + movq 24(%rsi),%rdx - xorq %rcx,%rcx - adoxq %r11,%r11 + xorq %rcx,%rcx + adoxq %r11,%r11 - adcxq %rbx,%rax - adoxq %r12,%r12 + adcxq %rbx,%rax + adoxq %r12,%r12 adcxq %rax,%r11 - adoxq %rbp,%rcx - adcxq %rdi,%r12 - adcxq %rbp,%rcx + adoxq %rbp,%rcx + adcxq %rdi,%r12 + adcxq %rbp,%rcx movq %r11,32(%rsp) - movq %r12,40(%rsp) + movq %r12,40(%rsp) - mulxq 32(%rsi),%rax,%rbx + mulxq 32(%rsi),%rax,%rbx adoxq %rax,%r14 adcxq %rbx,%r15 @@ -543,25 +543,25 @@ rsaz_512_sqr: mulxq 56(%rsi),%rdi,%r10 adoxq %rdi,%r9 adcxq %rbp,%r10 - mulxq %rdx,%rax,%rdi + mulxq %rdx,%rax,%rdi adoxq %rbp,%r10 - movq 32(%rsi),%rdx + movq 32(%rsi),%rdx - xorq %rbx,%rbx - adoxq %r13,%r13 + xorq %rbx,%rbx + adoxq %r13,%r13 - adcxq %rcx,%rax - adoxq %r14,%r14 + adcxq %rcx,%rax + adoxq %r14,%r14 adcxq %rax,%r13 - adoxq %rbp,%rbx - adcxq %rdi,%r14 - adcxq %rbp,%rbx + adoxq %rbp,%rbx + adcxq %rdi,%r14 + adcxq %rbp,%rbx movq %r13,48(%rsp) movq %r14,56(%rsp) - mulxq 40(%rsi),%rdi,%r11 + mulxq 40(%rsi),%rdi,%r11 adoxq %rdi,%r8 adcxq %r11,%r9 @@ -572,19 +572,19 @@ rsaz_512_sqr: mulxq 56(%rsi),%rdi,%r11 adoxq %rdi,%r10 adcxq %rbp,%r11 - mulxq %rdx,%rax,%rdi - movq 40(%rsi),%rdx + mulxq %rdx,%rax,%rdi + movq 40(%rsi),%rdx adoxq %rbp,%r11 - xorq %rcx,%rcx - adoxq %r15,%r15 + xorq %rcx,%rcx + adoxq %r15,%r15 - adcxq %rbx,%rax - adoxq %r8,%r8 + adcxq %rbx,%rax + adoxq %r8,%r8 adcxq %rax,%r15 - adoxq %rbp,%rcx - adcxq %rdi,%r8 - adcxq %rbp,%rcx + adoxq %rbp,%rcx + adcxq %rdi,%r8 + adcxq %rbp,%rcx movq %r15,64(%rsp) movq %r8,72(%rsp) @@ -597,19 +597,19 @@ rsaz_512_sqr: .byte 0xc4,0x62,0xc3,0xf6,0xa6,0x38,0x00,0x00,0x00 adoxq %rdi,%r11 adcxq %rbp,%r12 - mulxq %rdx,%rax,%rdi + mulxq %rdx,%rax,%rdi adoxq %rbp,%r12 - movq 48(%rsi),%rdx + movq 48(%rsi),%rdx - xorq %rbx,%rbx - adoxq %r9,%r9 + xorq %rbx,%rbx + adoxq %r9,%r9 - adcxq %rcx,%rax - adoxq %r10,%r10 + adcxq %rcx,%rax + adoxq %r10,%r10 adcxq %rax,%r9 - adcxq %rdi,%r10 - adoxq %rbp,%rbx - adcxq %rbp,%rbx + adcxq %rdi,%r10 + adoxq %rbp,%rbx + adcxq %rbp,%rbx movq %r9,80(%rsp) movq %r10,88(%rsp) @@ -619,30 +619,30 @@ rsaz_512_sqr: adoxq %rax,%r12 adoxq %rbp,%r13 - mulxq %rdx,%rax,%rdi - xorq %rcx,%rcx - movq 56(%rsi),%rdx - adoxq %r11,%r11 + mulxq %rdx,%rax,%rdi + xorq %rcx,%rcx + movq 56(%rsi),%rdx + adoxq %r11,%r11 - adcxq %rbx,%rax - adoxq %r12,%r12 + adcxq %rbx,%rax + adoxq %r12,%r12 adcxq %rax,%r11 - adoxq %rbp,%rcx - adcxq %rdi,%r12 - adcxq %rbp,%rcx + adoxq %rbp,%rcx + adcxq %rdi,%r12 + adcxq %rbp,%rcx .byte 0x4c,0x89,0x9c,0x24,0x60,0x00,0x00,0x00 .byte 0x4c,0x89,0xa4,0x24,0x68,0x00,0x00,0x00 mulxq %rdx,%rax,%rdx - xorq %rbx,%rbx - adoxq %r13,%r13 + xorq %rbx,%rbx + adoxq %r13,%r13 - adcxq %rcx,%rax - adoxq %rbp,%rbx - adcxq %r13,%rax - adcxq %rdx,%rbx + adcxq %rcx,%rax + adoxq %rbp,%rbx + adcxq %r13,%rax + adcxq %rdx,%rbx .byte 102,72,15,126,199 .byte 102,72,15,126,205 @@ -657,9 +657,9 @@ rsaz_512_sqr: movq 48(%rsp),%r14 movq 56(%rsp),%r15 - movq %rax,112(%rsp) - movq %rbx,120(%rsp) - + movq %rax,112(%rsp) + movq %rbx,120(%rsp) + call __rsaz_512_reducex addq 64(%rsp),%r8 @@ -1453,7 +1453,7 @@ rsaz_512_mul_by_one: .type __rsaz_512_reduce,@function .align 32 __rsaz_512_reduce: -.cfi_startproc +.cfi_startproc movq %r8,%rbx imulq 128+8(%rsp),%rbx movq 0(%rbp),%rax @@ -1533,12 +1533,12 @@ __rsaz_512_reduce: jne .Lreduction_loop .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __rsaz_512_reduce,.-__rsaz_512_reduce .type __rsaz_512_reducex,@function .align 32 __rsaz_512_reducex: -.cfi_startproc +.cfi_startproc imulq %r8,%rdx xorq %rsi,%rsi @@ -1591,12 +1591,12 @@ __rsaz_512_reducex: jne .Lreduction_loopx .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __rsaz_512_reducex,.-__rsaz_512_reducex .type __rsaz_512_subtract,@function .align 32 __rsaz_512_subtract: -.cfi_startproc +.cfi_startproc movq %r8,(%rdi) movq %r9,8(%rdi) movq %r10,16(%rdi) @@ -1650,12 +1650,12 @@ __rsaz_512_subtract: movq %r15,56(%rdi) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __rsaz_512_subtract,.-__rsaz_512_subtract .type __rsaz_512_mul,@function .align 32 __rsaz_512_mul: -.cfi_startproc +.cfi_startproc leaq 8(%rsp),%rdi movq (%rsi),%rax @@ -1794,12 +1794,12 @@ __rsaz_512_mul: movq %r15,56(%rdi) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __rsaz_512_mul,.-__rsaz_512_mul .type __rsaz_512_mulx,@function .align 32 __rsaz_512_mulx: -.cfi_startproc +.cfi_startproc mulxq (%rsi),%rbx,%r8 movq $-6,%rcx @@ -1916,13 +1916,13 @@ __rsaz_512_mulx: movq %r15,8+64+56(%rsp) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __rsaz_512_mulx,.-__rsaz_512_mulx .globl rsaz_512_scatter4 .type rsaz_512_scatter4,@function .align 16 rsaz_512_scatter4: -.cfi_startproc +.cfi_startproc leaq (%rdi,%rdx,8),%rdi movl $8,%r9d jmp .Loop_scatter @@ -1935,14 +1935,14 @@ rsaz_512_scatter4: decl %r9d jnz .Loop_scatter .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size rsaz_512_scatter4,.-rsaz_512_scatter4 .globl rsaz_512_gather4 .type rsaz_512_gather4,@function .align 16 rsaz_512_gather4: -.cfi_startproc +.cfi_startproc movd %edx,%xmm8 movdqa .Linc+16(%rip),%xmm1 movdqa .Linc(%rip),%xmm0 @@ -2006,7 +2006,7 @@ rsaz_512_gather4: jnz .Loop_gather .byte 0xf3,0xc3 .LSEH_end_rsaz_512_gather4: -.cfi_endproc +.cfi_endproc .size rsaz_512_gather4,.-rsaz_512_gather4 .align 64 diff --git a/contrib/libs/openssl/asm/linux/crypto/bn/x86_64-mont5.s b/contrib/libs/openssl/asm/linux/crypto/bn/x86_64-mont5.s index 7e3471358b..ab93b02d8c 100644 --- a/contrib/libs/openssl/asm/linux/crypto/bn/x86_64-mont5.s +++ b/contrib/libs/openssl/asm/linux/crypto/bn/x86_64-mont5.s @@ -550,7 +550,7 @@ bn_mul4x_mont_gather5: .type mul4x_internal,@function .align 32 mul4x_internal: -.cfi_startproc +.cfi_startproc shlq $5,%r9 movd 8(%rax),%xmm5 leaq .Linc(%rip),%rax @@ -1072,7 +1072,7 @@ mul4x_internal: movq 16(%rbp),%r14 movq 24(%rbp),%r15 jmp .Lsqr4x_sub_entry -.cfi_endproc +.cfi_endproc .size mul4x_internal,.-mul4x_internal .globl bn_power5 .type bn_power5,@function @@ -1215,7 +1215,7 @@ bn_power5: .align 32 bn_sqr8x_internal: __bn_sqr8x_internal: -.cfi_startproc +.cfi_startproc @@ -1990,12 +1990,12 @@ __bn_sqr8x_reduction: cmpq %rdx,%rdi jb .L8x_reduction_loop .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size bn_sqr8x_internal,.-bn_sqr8x_internal .type __bn_post4x_internal,@function .align 32 __bn_post4x_internal: -.cfi_startproc +.cfi_startproc movq 0(%rbp),%r12 leaq (%rdi,%r9,1),%rbx movq %r9,%rcx @@ -2046,18 +2046,18 @@ __bn_post4x_internal: movq %r9,%r10 negq %r9 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __bn_post4x_internal,.-__bn_post4x_internal .globl bn_from_montgomery .type bn_from_montgomery,@function .align 32 bn_from_montgomery: -.cfi_startproc +.cfi_startproc testl $7,%r9d jz bn_from_mont8x xorl %eax,%eax .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size bn_from_montgomery,.-bn_from_montgomery .type bn_from_mont8x,@function @@ -2341,7 +2341,7 @@ bn_mulx4x_mont_gather5: .type mulx4x_internal,@function .align 32 mulx4x_internal: -.cfi_startproc +.cfi_startproc movq %r9,8(%rsp) movq %r9,%r10 negq %r9 @@ -2760,7 +2760,7 @@ mulx4x_internal: movq 16(%rbp),%r14 movq 24(%rbp),%r15 jmp .Lsqrx4x_sub_entry -.cfi_endproc +.cfi_endproc .size mulx4x_internal,.-mulx4x_internal .type bn_powerx5,@function .align 32 @@ -3519,7 +3519,7 @@ __bn_sqrx8x_reduction: .size bn_sqrx8x_internal,.-bn_sqrx8x_internal .align 32 __bn_postx4x_internal: -.cfi_startproc +.cfi_startproc movq 0(%rbp),%r12 movq %rcx,%r10 movq %rcx,%r9 @@ -3567,13 +3567,13 @@ __bn_postx4x_internal: negq %r9 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __bn_postx4x_internal,.-__bn_postx4x_internal .globl bn_get_bits5 .type bn_get_bits5,@function .align 16 bn_get_bits5: -.cfi_startproc +.cfi_startproc leaq 0(%rdi),%r10 leaq 1(%rdi),%r11 movl %esi,%ecx @@ -3587,14 +3587,14 @@ bn_get_bits5: shrl %cl,%eax andl $31,%eax .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size bn_get_bits5,.-bn_get_bits5 .globl bn_scatter5 .type bn_scatter5,@function .align 16 bn_scatter5: -.cfi_startproc +.cfi_startproc cmpl $0,%esi jz .Lscatter_epilogue leaq (%rdx,%rcx,8),%rdx @@ -3607,7 +3607,7 @@ bn_scatter5: jnz .Lscatter .Lscatter_epilogue: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size bn_scatter5,.-bn_scatter5 .globl bn_gather5 @@ -3615,7 +3615,7 @@ bn_scatter5: .align 32 bn_gather5: .LSEH_begin_bn_gather5: -.cfi_startproc +.cfi_startproc .byte 0x4c,0x8d,0x14,0x24 .byte 0x48,0x81,0xec,0x08,0x01,0x00,0x00 @@ -3773,7 +3773,7 @@ bn_gather5: leaq (%r10),%rsp .byte 0xf3,0xc3 .LSEH_end_bn_gather5: -.cfi_endproc +.cfi_endproc .size bn_gather5,.-bn_gather5 .align 64 .Linc: diff --git a/contrib/libs/openssl/asm/linux/crypto/camellia/cmll-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/camellia/cmll-x86_64.s index 14c3ed985f..92056f8b1e 100644 --- a/contrib/libs/openssl/asm/linux/crypto/camellia/cmll-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/camellia/cmll-x86_64.s @@ -5,13 +5,13 @@ .type Camellia_EncryptBlock,@function .align 16 Camellia_EncryptBlock: -.cfi_startproc +.cfi_startproc movl $128,%eax subl %edi,%eax movl $3,%edi adcl $0,%edi jmp .Lenc_rounds -.cfi_endproc +.cfi_endproc .size Camellia_EncryptBlock,.-Camellia_EncryptBlock .globl Camellia_EncryptBlock_Rounds @@ -85,7 +85,7 @@ Camellia_EncryptBlock_Rounds: .type _x86_64_Camellia_encrypt,@function .align 16 _x86_64_Camellia_encrypt: -.cfi_startproc +.cfi_startproc xorl 0(%r14),%r9d xorl 4(%r14),%r8d xorl 8(%r14),%r11d @@ -288,7 +288,7 @@ _x86_64_Camellia_encrypt: movl %edx,%r11d .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size _x86_64_Camellia_encrypt,.-_x86_64_Camellia_encrypt @@ -296,13 +296,13 @@ _x86_64_Camellia_encrypt: .type Camellia_DecryptBlock,@function .align 16 Camellia_DecryptBlock: -.cfi_startproc +.cfi_startproc movl $128,%eax subl %edi,%eax movl $3,%edi adcl $0,%edi jmp .Ldec_rounds -.cfi_endproc +.cfi_endproc .size Camellia_DecryptBlock,.-Camellia_DecryptBlock .globl Camellia_DecryptBlock_Rounds @@ -376,7 +376,7 @@ Camellia_DecryptBlock_Rounds: .type _x86_64_Camellia_decrypt,@function .align 16 _x86_64_Camellia_decrypt: -.cfi_startproc +.cfi_startproc xorl 0(%r14),%r9d xorl 4(%r14),%r8d xorl 8(%r14),%r11d @@ -580,7 +580,7 @@ _x86_64_Camellia_decrypt: movl %ebx,%r11d .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size _x86_64_Camellia_decrypt,.-_x86_64_Camellia_decrypt .globl Camellia_Ekeygen .type Camellia_Ekeygen,@function diff --git a/contrib/libs/openssl/asm/linux/crypto/ec/ecp_nistz256-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/ec/ecp_nistz256-x86_64.s index 3729201221..80569cae04 100644 --- a/contrib/libs/openssl/asm/linux/crypto/ec/ecp_nistz256-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/ec/ecp_nistz256-x86_64.s @@ -3874,12 +3874,12 @@ ecp_nistz256_ord_sqr_montx: .type ecp_nistz256_to_mont,@function .align 32 ecp_nistz256_to_mont: -.cfi_startproc +.cfi_startproc movl $0x80100,%ecx andl OPENSSL_ia32cap_P+8(%rip),%ecx leaq .LRR(%rip),%rdx jmp .Lmul_mont -.cfi_endproc +.cfi_endproc .size ecp_nistz256_to_mont,.-ecp_nistz256_to_mont @@ -4823,7 +4823,7 @@ ecp_nistz256_from_mont: .type ecp_nistz256_scatter_w5,@function .align 32 ecp_nistz256_scatter_w5: -.cfi_startproc +.cfi_startproc leal -3(%rdx,%rdx,2),%edx movdqa 0(%rsi),%xmm0 shll $5,%edx @@ -4840,7 +4840,7 @@ ecp_nistz256_scatter_w5: movdqa %xmm5,80(%rdi,%rdx,1) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size ecp_nistz256_scatter_w5,.-ecp_nistz256_scatter_w5 @@ -4914,7 +4914,7 @@ ecp_nistz256_gather_w5: .type ecp_nistz256_scatter_w7,@function .align 32 ecp_nistz256_scatter_w7: -.cfi_startproc +.cfi_startproc movdqu 0(%rsi),%xmm0 shll $6,%edx movdqu 16(%rsi),%xmm1 @@ -4926,7 +4926,7 @@ ecp_nistz256_scatter_w7: movdqa %xmm3,48(%rdi,%rdx,1) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size ecp_nistz256_scatter_w7,.-ecp_nistz256_scatter_w7 @@ -5663,12 +5663,12 @@ ecp_nistz256_point_add: .byte 102,73,15,126,208 .byte 102,73,15,126,217 - - orq %r8,%r12 - orq %r9,%r12 - - -.byte 0x3e + + orq %r8,%r12 + orq %r9,%r12 + + +.byte 0x3e jnz .Ladd_proceedq .Ladd_doubleq: @@ -6772,12 +6772,12 @@ ecp_nistz256_point_addx: .byte 102,73,15,126,208 .byte 102,73,15,126,217 - - orq %r8,%r12 - orq %r9,%r12 - - -.byte 0x3e + + orq %r8,%r12 + orq %r9,%r12 + + +.byte 0x3e jnz .Ladd_proceedx .Ladd_doublex: diff --git a/contrib/libs/openssl/asm/linux/crypto/ec/x25519-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/ec/x25519-x86_64.s index 6247dc89d0..8fd319c83c 100644 --- a/contrib/libs/openssl/asm/linux/crypto/ec/x25519-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/ec/x25519-x86_64.s @@ -400,14 +400,14 @@ x25519_fe51_mul121666: .type x25519_fe64_eligible,@function .align 32 x25519_fe64_eligible: -.cfi_startproc +.cfi_startproc movl OPENSSL_ia32cap_P+8(%rip),%ecx xorl %eax,%eax andl $0x80100,%ecx cmpl $0x80100,%ecx cmovel %ecx,%eax .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size x25519_fe64_eligible,.-x25519_fe64_eligible .globl x25519_fe64_mul @@ -650,7 +650,7 @@ x25519_fe64_sqr: .align 32 x25519_fe64_mul121666: .Lfe64_mul121666_body: -.cfi_startproc +.cfi_startproc movl $121666,%edx mulxq 0(%rsi),%r8,%rcx mulxq 8(%rsi),%r9,%rax @@ -679,7 +679,7 @@ x25519_fe64_mul121666: .Lfe64_mul121666_epilogue: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size x25519_fe64_mul121666,.-x25519_fe64_mul121666 .globl x25519_fe64_add @@ -687,7 +687,7 @@ x25519_fe64_mul121666: .align 32 x25519_fe64_add: .Lfe64_add_body: -.cfi_startproc +.cfi_startproc movq 0(%rsi),%r8 movq 8(%rsi),%r9 movq 16(%rsi),%r10 @@ -716,7 +716,7 @@ x25519_fe64_add: .Lfe64_add_epilogue: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size x25519_fe64_add,.-x25519_fe64_add .globl x25519_fe64_sub @@ -724,7 +724,7 @@ x25519_fe64_add: .align 32 x25519_fe64_sub: .Lfe64_sub_body: -.cfi_startproc +.cfi_startproc movq 0(%rsi),%r8 movq 8(%rsi),%r9 movq 16(%rsi),%r10 @@ -753,7 +753,7 @@ x25519_fe64_sub: .Lfe64_sub_epilogue: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size x25519_fe64_sub,.-x25519_fe64_sub .globl x25519_fe64_tobytes @@ -761,7 +761,7 @@ x25519_fe64_sub: .align 32 x25519_fe64_tobytes: .Lfe64_to_body: -.cfi_startproc +.cfi_startproc movq 0(%rsi),%r8 movq 8(%rsi),%r9 movq 16(%rsi),%r10 @@ -797,6 +797,6 @@ x25519_fe64_tobytes: .Lfe64_to_epilogue: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size x25519_fe64_tobytes,.-x25519_fe64_tobytes .byte 88,50,53,53,49,57,32,112,114,105,109,105,116,105,118,101,115,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 diff --git a/contrib/libs/openssl/asm/linux/crypto/modes/aesni-gcm-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/modes/aesni-gcm-x86_64.s index 3a3b864f84..bf508aff6f 100644 --- a/contrib/libs/openssl/asm/linux/crypto/modes/aesni-gcm-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/modes/aesni-gcm-x86_64.s @@ -3,7 +3,7 @@ .type _aesni_ctr32_ghash_6x,@function .align 32 _aesni_ctr32_ghash_6x: -.cfi_startproc +.cfi_startproc vmovdqu 32(%r11),%xmm2 subq $6,%rdx vpxor %xmm4,%xmm4,%xmm4 @@ -311,7 +311,7 @@ _aesni_ctr32_ghash_6x: vpxor %xmm4,%xmm8,%xmm8 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size _aesni_ctr32_ghash_6x,.-_aesni_ctr32_ghash_6x .globl aesni_gcm_decrypt .type aesni_gcm_decrypt,@function @@ -418,7 +418,7 @@ aesni_gcm_decrypt: .type _aesni_ctr32_6x,@function .align 32 _aesni_ctr32_6x: -.cfi_startproc +.cfi_startproc vmovdqu 0-128(%rcx),%xmm4 vmovdqu 32(%r11),%xmm2 leaq -1(%rbp),%r13 @@ -505,7 +505,7 @@ _aesni_ctr32_6x: vpshufb %xmm0,%xmm1,%xmm1 vpxor %xmm4,%xmm14,%xmm14 jmp .Loop_ctr32 -.cfi_endproc +.cfi_endproc .size _aesni_ctr32_6x,.-_aesni_ctr32_6x .globl aesni_gcm_encrypt diff --git a/contrib/libs/openssl/asm/linux/crypto/poly1305/poly1305-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/poly1305/poly1305-x86_64.s index 2b127b33cb..9bb9be4632 100644 --- a/contrib/libs/openssl/asm/linux/crypto/poly1305/poly1305-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/poly1305/poly1305-x86_64.s @@ -12,7 +12,7 @@ .type poly1305_init,@function .align 32 poly1305_init: -.cfi_startproc +.cfi_startproc xorq %rax,%rax movq %rax,0(%rdi) movq %rax,8(%rdi) @@ -48,7 +48,7 @@ poly1305_init: movl $1,%eax .Lno_key: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size poly1305_init,.-poly1305_init .type poly1305_blocks,@function @@ -169,7 +169,7 @@ poly1305_blocks: .type poly1305_emit,@function .align 32 poly1305_emit: -.cfi_startproc +.cfi_startproc .Lemit: movq 0(%rdi),%r8 movq 8(%rdi),%r9 @@ -190,12 +190,12 @@ poly1305_emit: movq %rcx,8(%rsi) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size poly1305_emit,.-poly1305_emit .type __poly1305_block,@function .align 32 __poly1305_block: -.cfi_startproc +.cfi_startproc mulq %r14 movq %rax,%r9 movq %r11,%rax @@ -235,13 +235,13 @@ __poly1305_block: adcq $0,%rbx adcq $0,%rbp .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __poly1305_block,.-__poly1305_block .type __poly1305_init_avx,@function .align 32 __poly1305_init_avx: -.cfi_startproc +.cfi_startproc movq %r11,%r14 movq %r12,%rbx xorq %rbp,%rbp @@ -399,7 +399,7 @@ __poly1305_init_avx: leaq -48-64(%rdi),%rdi .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __poly1305_init_avx,.-__poly1305_init_avx .type poly1305_blocks_avx,@function @@ -1240,7 +1240,7 @@ poly1305_blocks_avx: .type poly1305_emit_avx,@function .align 32 poly1305_emit_avx: -.cfi_startproc +.cfi_startproc cmpl $0,20(%rdi) je .Lemit @@ -1291,7 +1291,7 @@ poly1305_emit_avx: movq %rcx,8(%rsi) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size poly1305_emit_avx,.-poly1305_emit_avx .type poly1305_blocks_avx2,@function .align 32 @@ -2488,7 +2488,7 @@ poly1305_blocks_avx512: .type poly1305_init_base2_44,@function .align 32 poly1305_init_base2_44: -.cfi_startproc +.cfi_startproc xorq %rax,%rax movq %rax,0(%rdi) movq %rax,8(%rdi) @@ -2522,12 +2522,12 @@ poly1305_init_base2_44: movq %r11,8(%rdx) movl $1,%eax .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size poly1305_init_base2_44,.-poly1305_init_base2_44 .type poly1305_blocks_vpmadd52,@function .align 32 poly1305_blocks_vpmadd52: -.cfi_startproc +.cfi_startproc shrq $4,%rdx jz .Lno_data_vpmadd52 @@ -2634,12 +2634,12 @@ poly1305_blocks_vpmadd52: .Lno_data_vpmadd52: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size poly1305_blocks_vpmadd52,.-poly1305_blocks_vpmadd52 .type poly1305_blocks_vpmadd52_4x,@function .align 32 poly1305_blocks_vpmadd52_4x: -.cfi_startproc +.cfi_startproc shrq $4,%rdx jz .Lno_data_vpmadd52_4x @@ -3064,12 +3064,12 @@ poly1305_blocks_vpmadd52_4x: .Lno_data_vpmadd52_4x: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size poly1305_blocks_vpmadd52_4x,.-poly1305_blocks_vpmadd52_4x .type poly1305_blocks_vpmadd52_8x,@function .align 32 poly1305_blocks_vpmadd52_8x: -.cfi_startproc +.cfi_startproc shrq $4,%rdx jz .Lno_data_vpmadd52_8x @@ -3410,12 +3410,12 @@ poly1305_blocks_vpmadd52_8x: .Lno_data_vpmadd52_8x: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size poly1305_blocks_vpmadd52_8x,.-poly1305_blocks_vpmadd52_8x .type poly1305_emit_base2_44,@function .align 32 poly1305_emit_base2_44: -.cfi_startproc +.cfi_startproc movq 0(%rdi),%r8 movq 8(%rdi),%r9 movq 16(%rdi),%r10 @@ -3446,7 +3446,7 @@ poly1305_emit_base2_44: movq %rcx,8(%rsi) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size poly1305_emit_base2_44,.-poly1305_emit_base2_44 .align 64 .Lconst: @@ -3485,7 +3485,7 @@ poly1305_emit_base2_44: .type xor128_encrypt_n_pad,@function .align 16 xor128_encrypt_n_pad: -.cfi_startproc +.cfi_startproc subq %rdx,%rsi subq %rdx,%rdi movq %rcx,%r10 @@ -3527,14 +3527,14 @@ xor128_encrypt_n_pad: .Ldone_enc: movq %rdx,%rax .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size xor128_encrypt_n_pad,.-xor128_encrypt_n_pad .globl xor128_decrypt_n_pad .type xor128_decrypt_n_pad,@function .align 16 xor128_decrypt_n_pad: -.cfi_startproc +.cfi_startproc subq %rdx,%rsi subq %rdx,%rdi movq %rcx,%r10 @@ -3580,5 +3580,5 @@ xor128_decrypt_n_pad: .Ldone_dec: movq %rdx,%rax .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size xor128_decrypt_n_pad,.-xor128_decrypt_n_pad diff --git a/contrib/libs/openssl/asm/linux/crypto/rc4/rc4-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/rc4/rc4-x86_64.s index 6d64f841d1..d1d1eece70 100644 --- a/contrib/libs/openssl/asm/linux/crypto/rc4/rc4-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/rc4/rc4-x86_64.s @@ -4,9 +4,9 @@ .globl RC4 .type RC4,@function .align 16 -RC4: -.cfi_startproc - orq %rsi,%rsi +RC4: +.cfi_startproc + orq %rsi,%rsi jne .Lentry .byte 0xf3,0xc3 .Lentry: @@ -534,7 +534,7 @@ RC4: .type RC4_set_key,@function .align 16 RC4_set_key: -.cfi_startproc +.cfi_startproc leaq 8(%rdi),%rdi leaq (%rdx,%rsi,1),%rdx negq %rsi @@ -601,14 +601,14 @@ RC4_set_key: movl %eax,-8(%rdi) movl %eax,-4(%rdi) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size RC4_set_key,.-RC4_set_key .globl RC4_options .type RC4_options,@function .align 16 RC4_options: -.cfi_startproc +.cfi_startproc leaq .Lopts(%rip),%rax movl OPENSSL_ia32cap_P(%rip),%edx btl $20,%edx @@ -621,7 +621,7 @@ RC4_options: addq $12,%rax .Ldone: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .align 64 .Lopts: .byte 114,99,52,40,56,120,44,105,110,116,41,0 diff --git a/contrib/libs/openssl/asm/linux/crypto/sha/keccak1600-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/sha/keccak1600-x86_64.s index 6e90445a67..11f26e933d 100644 --- a/contrib/libs/openssl/asm/linux/crypto/sha/keccak1600-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/sha/keccak1600-x86_64.s @@ -3,7 +3,7 @@ .type __KeccakF1600,@function .align 32 __KeccakF1600: -.cfi_startproc +.cfi_startproc movq 60(%rdi),%rax movq 68(%rdi),%rbx movq 76(%rdi),%rcx @@ -256,7 +256,7 @@ __KeccakF1600: leaq -192(%r15),%r15 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size __KeccakF1600,.-__KeccakF1600 .type KeccakF1600,@function diff --git a/contrib/libs/openssl/asm/linux/crypto/sha/sha1-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/sha/sha1-x86_64.s index daa461635e..d4efc7206f 100644 --- a/contrib/libs/openssl/asm/linux/crypto/sha/sha1-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/sha/sha1-x86_64.s @@ -1421,7 +1421,7 @@ _shaext_shortcut: pshufd $27,%xmm1,%xmm1 movdqu %xmm0,(%rdi) movd %xmm1,16(%rdi) - .byte 0xf3,0xc3 + .byte 0xf3,0xc3 .cfi_endproc .size sha1_block_data_order_shaext,.-sha1_block_data_order_shaext .type sha1_block_data_order_ssse3,@function diff --git a/contrib/libs/openssl/asm/linux/crypto/sha/sha256-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/sha/sha256-x86_64.s index 3ee0605cc7..a7b60900fd 100644 --- a/contrib/libs/openssl/asm/linux/crypto/sha/sha256-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/sha/sha256-x86_64.s @@ -1775,7 +1775,7 @@ K256: .align 64 sha256_block_data_order_shaext: _shaext_shortcut: -.cfi_startproc +.cfi_startproc leaq K256+128(%rip),%rcx movdqu (%rdi),%xmm1 movdqu 16(%rdi),%xmm2 @@ -1978,7 +1978,7 @@ _shaext_shortcut: movdqu %xmm1,(%rdi) movdqu %xmm2,16(%rdi) .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size sha256_block_data_order_shaext,.-sha256_block_data_order_shaext .type sha256_block_data_order_ssse3,@function .align 64 @@ -4240,15 +4240,15 @@ sha256_block_data_order_avx2: vmovdqa %ymm4,0(%rsp) xorl %r14d,%r14d vmovdqa %ymm5,32(%rsp) - - movq 88(%rsp),%rdi -.cfi_def_cfa %rdi,8 + + movq 88(%rsp),%rdi +.cfi_def_cfa %rdi,8 leaq -64(%rsp),%rsp - - - - movq %rdi,-8(%rsp) -.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 + + + + movq %rdi,-8(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 movl %ebx,%edi vmovdqa %ymm6,0(%rsp) xorl %ecx,%edi @@ -4260,12 +4260,12 @@ sha256_block_data_order_avx2: .align 16 .Lavx2_00_47: leaq -64(%rsp),%rsp -.cfi_escape 0x0f,0x05,0x77,0x38,0x06,0x23,0x08 - - pushq 64-8(%rsp) -.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 - leaq 8(%rsp),%rsp -.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 +.cfi_escape 0x0f,0x05,0x77,0x38,0x06,0x23,0x08 + + pushq 64-8(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 + leaq 8(%rsp),%rsp +.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 vpalignr $4,%ymm0,%ymm1,%ymm4 addl 0+128(%rsp),%r11d andl %r8d,%r12d @@ -4521,12 +4521,12 @@ sha256_block_data_order_avx2: movl %r9d,%r12d vmovdqa %ymm6,32(%rsp) leaq -64(%rsp),%rsp -.cfi_escape 0x0f,0x05,0x77,0x38,0x06,0x23,0x08 - - pushq 64-8(%rsp) -.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 - leaq 8(%rsp),%rsp -.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 +.cfi_escape 0x0f,0x05,0x77,0x38,0x06,0x23,0x08 + + pushq 64-8(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 + leaq 8(%rsp),%rsp +.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 vpalignr $4,%ymm2,%ymm3,%ymm4 addl 0+128(%rsp),%r11d andl %r8d,%r12d @@ -5402,8 +5402,8 @@ sha256_block_data_order_avx2: leaq 448(%rsp),%rsp -.cfi_escape 0x0f,0x06,0x77,0xd8,0x00,0x06,0x23,0x08 - +.cfi_escape 0x0f,0x06,0x77,0xd8,0x00,0x06,0x23,0x08 + addl 0(%rdi),%eax addl 4(%rdi),%ebx addl 8(%rdi),%ecx @@ -5429,11 +5429,11 @@ sha256_block_data_order_avx2: jbe .Loop_avx2 leaq (%rsp),%rbp - -.cfi_escape 0x0f,0x06,0x76,0xd8,0x00,0x06,0x23,0x08 - + +.cfi_escape 0x0f,0x06,0x76,0xd8,0x00,0x06,0x23,0x08 + .Ldone_avx2: - movq 88(%rbp),%rsi + movq 88(%rbp),%rsi .cfi_def_cfa %rsi,8 vzeroupper movq -48(%rsi),%r15 diff --git a/contrib/libs/openssl/asm/linux/crypto/sha/sha512-x86_64.s b/contrib/libs/openssl/asm/linux/crypto/sha/sha512-x86_64.s index 89874b7deb..939f1ca71c 100644 --- a/contrib/libs/openssl/asm/linux/crypto/sha/sha512-x86_64.s +++ b/contrib/libs/openssl/asm/linux/crypto/sha/sha512-x86_64.s @@ -4165,15 +4165,15 @@ sha512_block_data_order_avx2: vmovdqa %ymm10,64(%rsp) vpaddq 64(%rbp),%ymm6,%ymm10 vmovdqa %ymm11,96(%rsp) - - movq 152(%rsp),%rdi -.cfi_def_cfa %rdi,8 + + movq 152(%rsp),%rdi +.cfi_def_cfa %rdi,8 leaq -128(%rsp),%rsp - - - - movq %rdi,-8(%rsp) -.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 + + + + movq %rdi,-8(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 vpaddq 96(%rbp),%ymm7,%ymm11 vmovdqa %ymm8,0(%rsp) xorq %r14,%r14 @@ -4189,12 +4189,12 @@ sha512_block_data_order_avx2: .align 16 .Lavx2_00_47: leaq -128(%rsp),%rsp -.cfi_escape 0x0f,0x06,0x77,0xf8,0x00,0x06,0x23,0x08 - - pushq 128-8(%rsp) -.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 - leaq 8(%rsp),%rsp -.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 +.cfi_escape 0x0f,0x06,0x77,0xf8,0x00,0x06,0x23,0x08 + + pushq 128-8(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 + leaq 8(%rsp),%rsp +.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 vpalignr $8,%ymm0,%ymm1,%ymm8 addq 0+256(%rsp),%r11 andq %r8,%r12 @@ -4488,12 +4488,12 @@ sha512_block_data_order_avx2: movq %r9,%r12 vmovdqa %ymm10,96(%rsp) leaq -128(%rsp),%rsp -.cfi_escape 0x0f,0x06,0x77,0xf8,0x00,0x06,0x23,0x08 - - pushq 128-8(%rsp) -.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 - leaq 8(%rsp),%rsp -.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 +.cfi_escape 0x0f,0x06,0x77,0xf8,0x00,0x06,0x23,0x08 + + pushq 128-8(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x00,0x06,0x23,0x08 + leaq 8(%rsp),%rsp +.cfi_escape 0x0f,0x05,0x77,0x78,0x06,0x23,0x08 vpalignr $8,%ymm4,%ymm5,%ymm8 addq 0+256(%rsp),%r11 andq %r8,%r12 @@ -5407,8 +5407,8 @@ sha512_block_data_order_avx2: leaq 1152(%rsp),%rsp -.cfi_escape 0x0f,0x06,0x77,0x98,0x01,0x06,0x23,0x08 - +.cfi_escape 0x0f,0x06,0x77,0x98,0x01,0x06,0x23,0x08 + addq 0(%rdi),%rax addq 8(%rdi),%rbx addq 16(%rdi),%rcx @@ -5434,11 +5434,11 @@ sha512_block_data_order_avx2: jbe .Loop_avx2 leaq (%rsp),%rbp - -.cfi_escape 0x0f,0x06,0x76,0x98,0x01,0x06,0x23,0x08 - + +.cfi_escape 0x0f,0x06,0x76,0x98,0x01,0x06,0x23,0x08 + .Ldone_avx2: - movq 152(%rbp),%rsi + movq 152(%rbp),%rsi .cfi_def_cfa %rsi,8 vzeroupper movq -48(%rsi),%r15 diff --git a/contrib/libs/openssl/asm/linux/crypto/x86_64cpuid.s b/contrib/libs/openssl/asm/linux/crypto/x86_64cpuid.s index 425245734b..748e6d161f 100644 --- a/contrib/libs/openssl/asm/linux/crypto/x86_64cpuid.s +++ b/contrib/libs/openssl/asm/linux/crypto/x86_64cpuid.s @@ -12,7 +12,7 @@ .type OPENSSL_atomic_add,@function .align 16 OPENSSL_atomic_add: -.cfi_startproc +.cfi_startproc movl (%rdi),%eax .Lspin: leaq (%rsi,%rax,1),%r8 .byte 0xf0 @@ -21,19 +21,19 @@ OPENSSL_atomic_add: movl %r8d,%eax .byte 0x48,0x98 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size OPENSSL_atomic_add,.-OPENSSL_atomic_add .globl OPENSSL_rdtsc .type OPENSSL_rdtsc,@function .align 16 OPENSSL_rdtsc: -.cfi_startproc +.cfi_startproc rdtsc shlq $32,%rdx orq %rdx,%rax .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size OPENSSL_rdtsc,.-OPENSSL_rdtsc .globl OPENSSL_ia32_cpuid @@ -209,7 +209,7 @@ OPENSSL_ia32_cpuid: .type OPENSSL_cleanse,@function .align 16 OPENSSL_cleanse: -.cfi_startproc +.cfi_startproc xorq %rax,%rax cmpq $15,%rsi jae .Lot @@ -239,14 +239,14 @@ OPENSSL_cleanse: cmpq $0,%rsi jne .Little .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size OPENSSL_cleanse,.-OPENSSL_cleanse .globl CRYPTO_memcmp .type CRYPTO_memcmp,@function .align 16 CRYPTO_memcmp: -.cfi_startproc +.cfi_startproc xorq %rax,%rax xorq %r10,%r10 cmpq $0,%rdx @@ -275,13 +275,13 @@ CRYPTO_memcmp: shrq $63,%rax .Lno_data: .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size CRYPTO_memcmp,.-CRYPTO_memcmp .globl OPENSSL_wipe_cpu .type OPENSSL_wipe_cpu,@function .align 16 OPENSSL_wipe_cpu: -.cfi_startproc +.cfi_startproc pxor %xmm0,%xmm0 pxor %xmm1,%xmm1 pxor %xmm2,%xmm2 @@ -308,13 +308,13 @@ OPENSSL_wipe_cpu: xorq %r11,%r11 leaq 8(%rsp),%rax .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu .globl OPENSSL_instrument_bus .type OPENSSL_instrument_bus,@function .align 16 OPENSSL_instrument_bus: -.cfi_startproc +.cfi_startproc movq %rdi,%r10 movq %rsi,%rcx movq %rsi,%r11 @@ -341,14 +341,14 @@ OPENSSL_instrument_bus: movq %r11,%rax .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size OPENSSL_instrument_bus,.-OPENSSL_instrument_bus .globl OPENSSL_instrument_bus2 .type OPENSSL_instrument_bus2,@function .align 16 OPENSSL_instrument_bus2: -.cfi_startproc +.cfi_startproc movq %rdi,%r10 movq %rsi,%rcx movq %rdx,%r11 @@ -391,13 +391,13 @@ OPENSSL_instrument_bus2: movq 8(%rsp),%rax subq %rcx,%rax .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2 .globl OPENSSL_ia32_rdrand_bytes .type OPENSSL_ia32_rdrand_bytes,@function .align 16 OPENSSL_ia32_rdrand_bytes: -.cfi_startproc +.cfi_startproc xorq %rax,%rax cmpq $0,%rsi je .Ldone_rdrand_bytes @@ -434,13 +434,13 @@ OPENSSL_ia32_rdrand_bytes: .Ldone_rdrand_bytes: xorq %r10,%r10 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size OPENSSL_ia32_rdrand_bytes,.-OPENSSL_ia32_rdrand_bytes .globl OPENSSL_ia32_rdseed_bytes .type OPENSSL_ia32_rdseed_bytes,@function .align 16 OPENSSL_ia32_rdseed_bytes: -.cfi_startproc +.cfi_startproc xorq %rax,%rax cmpq $0,%rsi je .Ldone_rdseed_bytes @@ -477,5 +477,5 @@ OPENSSL_ia32_rdseed_bytes: .Ldone_rdseed_bytes: xorq %r10,%r10 .byte 0xf3,0xc3 -.cfi_endproc +.cfi_endproc .size OPENSSL_ia32_rdseed_bytes,.-OPENSSL_ia32_rdseed_bytes diff --git a/contrib/libs/openssl/crypto/LPdir_unix.c b/contrib/libs/openssl/crypto/LPdir_unix.c index d58ccfea64..bbbec0aee1 100644 --- a/contrib/libs/openssl/crypto/LPdir_unix.c +++ b/contrib/libs/openssl/crypto/LPdir_unix.c @@ -131,8 +131,8 @@ const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory) return 0; } - OPENSSL_strlcpy((*ctx)->entry_name, direntry->d_name, - sizeof((*ctx)->entry_name)); + OPENSSL_strlcpy((*ctx)->entry_name, direntry->d_name, + sizeof((*ctx)->entry_name)); #ifdef __VMS if ((*ctx)->expect_file_generations) { char *p = (*ctx)->entry_name + strlen((*ctx)->entry_name); diff --git a/contrib/libs/openssl/crypto/aes/aes_core.c b/contrib/libs/openssl/crypto/aes/aes_core.c index 5676b3eef0..ad00c729e7 100644 --- a/contrib/libs/openssl/crypto/aes/aes_core.c +++ b/contrib/libs/openssl/crypto/aes/aes_core.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -41,639 +41,639 @@ #include <stdlib.h> #include <openssl/crypto.h> #include <openssl/aes.h> -#include "aes_local.h" - -#if defined(OPENSSL_AES_CONST_TIME) && !defined(AES_ASM) -typedef union { - unsigned char b[8]; - u32 w[2]; - u64 d; -} uni; - -/* - * Compute w := (w * x) mod (x^8 + x^4 + x^3 + x^1 + 1) - * Therefore the name "xtime". - */ -static void XtimeWord(u32 *w) -{ - u32 a, b; - - a = *w; - b = a & 0x80808080u; - a ^= b; - b -= b >> 7; - b &= 0x1B1B1B1Bu; - b ^= a << 1; - *w = b; -} - -static void XtimeLong(u64 *w) -{ - u64 a, b; - - a = *w; - b = a & 0x8080808080808080uLL; - a ^= b; - b -= b >> 7; - b &= 0x1B1B1B1B1B1B1B1BuLL; - b ^= a << 1; - *w = b; -} - -/* - * This computes w := S * w ^ -1 + c, where c = {01100011}. - * Instead of using GF(2^8) mod (x^8+x^4+x^3+x+1} we do the inversion - * in GF(GF(GF(2^2)^2)^2) mod (X^2+X+8) - * and GF(GF(2^2)^2) mod (X^2+X+2) - * and GF(2^2) mod (X^2+X+1) - * The first part of the algorithm below transfers the coordinates - * {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80} => - * {1,Y,Y^2,Y^3,Y^4,Y^5,Y^6,Y^7} with Y=0x41: - * {0x01,0x41,0x66,0x6c,0x56,0x9a,0x58,0xc4} - * The last part undoes the coordinate transfer and the final affine - * transformation S: - * b[i] = b[i] + b[(i+4)%8] + b[(i+5)%8] + b[(i+6)%8] + b[(i+7)%8] + c[i] - * in one step. - * The multiplication in GF(2^2^2^2) is done in ordinary coords: - * A = (a0*1 + a1*x^4) - * B = (b0*1 + b1*x^4) - * AB = ((a0*b0 + 8*a1*b1)*1 + (a1*b0 + (a0+a1)*b1)*x^4) - * When A = (a0,a1) is given we want to solve AB = 1: - * (a) 1 = a0*b0 + 8*a1*b1 - * (b) 0 = a1*b0 + (a0+a1)*b1 - * => multiply (a) by a1 and (b) by a0 - * (c) a1 = a1*a0*b0 + (8*a1*a1)*b1 - * (d) 0 = a1*a0*b0 + (a0*a0+a1*a0)*b1 - * => add (c) + (d) - * (e) a1 = (a0*a0 + a1*a0 + 8*a1*a1)*b1 - * => therefore - * b1 = (a0*a0 + a1*a0 + 8*a1*a1)^-1 * a1 - * => and adding (a1*b0) to (b) we get - * (f) a1*b0 = (a0+a1)*b1 - * => therefore - * b0 = (a0*a0 + a1*a0 + 8*a1*a1)^-1 * (a0+a1) - * Note this formula also works for the case - * (a0+a1)*a0 + 8*a1*a1 = 0 - * if the inverse element for 0^-1 is mapped to 0. - * Repeat the same for GF(2^2^2) and GF(2^2). - * We get the following algorithm: - * inv8(a0,a1): - * x0 = a0^a1 - * [y0,y1] = mul4([x0,a1],[a0,a1]); (*) - * y1 = mul4(8,y1); - * t = inv4(y0^y1); - * [b0,b1] = mul4([x0,a1],[t,t]); (*) - * return [b0,b1]; - * The non-linear multiplies (*) can be done in parallel at no extra cost. - */ -static void SubWord(u32 *w) -{ - u32 x, y, a1, a2, a3, a4, a5, a6; - - x = *w; - y = ((x & 0xFEFEFEFEu) >> 1) | ((x & 0x01010101u) << 7); - x &= 0xDDDDDDDDu; - x ^= y & 0x57575757u; - y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); - x ^= y & 0x1C1C1C1Cu; - y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); - x ^= y & 0x4A4A4A4Au; - y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); - x ^= y & 0x42424242u; - y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); - x ^= y & 0x64646464u; - y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); - x ^= y & 0xE0E0E0E0u; - a1 = x; - a1 ^= (x & 0xF0F0F0F0u) >> 4; - a2 = ((x & 0xCCCCCCCCu) >> 2) | ((x & 0x33333333u) << 2); - a3 = x & a1; - a3 ^= (a3 & 0xAAAAAAAAu) >> 1; - a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAu; - a4 = a2 & a1; - a4 ^= (a4 & 0xAAAAAAAAu) >> 1; - a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAu; - a5 = (a3 & 0xCCCCCCCCu) >> 2; - a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCu; - a4 = a5 & 0x22222222u; - a4 |= a4 >> 1; - a4 ^= (a5 << 1) & 0x22222222u; - a3 ^= a4; - a5 = a3 & 0xA0A0A0A0u; - a5 |= a5 >> 1; - a5 ^= (a3 << 1) & 0xA0A0A0A0u; - a4 = a5 & 0xC0C0C0C0u; - a6 = a4 >> 2; - a4 ^= (a5 << 2) & 0xC0C0C0C0u; - a5 = a6 & 0x20202020u; - a5 |= a5 >> 1; - a5 ^= (a6 << 1) & 0x20202020u; - a4 |= a5; - a3 ^= a4 >> 4; - a3 &= 0x0F0F0F0Fu; - a2 = a3; - a2 ^= (a3 & 0x0C0C0C0Cu) >> 2; - a4 = a3 & a2; - a4 ^= (a4 & 0x0A0A0A0A0Au) >> 1; - a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0Au; - a5 = a4 & 0x08080808u; - a5 |= a5 >> 1; - a5 ^= (a4 << 1) & 0x08080808u; - a4 ^= a5 >> 2; - a4 &= 0x03030303u; - a4 ^= (a4 & 0x02020202u) >> 1; - a4 |= a4 << 2; - a3 = a2 & a4; - a3 ^= (a3 & 0x0A0A0A0Au) >> 1; - a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0Au; - a3 |= a3 << 4; - a2 = ((a1 & 0xCCCCCCCCu) >> 2) | ((a1 & 0x33333333u) << 2); - x = a1 & a3; - x ^= (x & 0xAAAAAAAAu) >> 1; - x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAu; - a4 = a2 & a3; - a4 ^= (a4 & 0xAAAAAAAAu) >> 1; - a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAu; - a5 = (x & 0xCCCCCCCCu) >> 2; - x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCu; - a4 = a5 & 0x22222222u; - a4 |= a4 >> 1; - a4 ^= (a5 << 1) & 0x22222222u; - x ^= a4; - y = ((x & 0xFEFEFEFEu) >> 1) | ((x & 0x01010101u) << 7); - x &= 0x39393939u; - x ^= y & 0x3F3F3F3Fu; - y = ((y & 0xFCFCFCFCu) >> 2) | ((y & 0x03030303u) << 6); - x ^= y & 0x97979797u; - y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); - x ^= y & 0x9B9B9B9Bu; - y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); - x ^= y & 0x3C3C3C3Cu; - y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); - x ^= y & 0xDDDDDDDDu; - y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); - x ^= y & 0x72727272u; - x ^= 0x63636363u; - *w = x; -} - -static void SubLong(u64 *w) -{ - u64 x, y, a1, a2, a3, a4, a5, a6; - - x = *w; - y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); - x &= 0xDDDDDDDDDDDDDDDDuLL; - x ^= y & 0x5757575757575757uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x1C1C1C1C1C1C1C1CuLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x4A4A4A4A4A4A4A4AuLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x4242424242424242uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x6464646464646464uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0xE0E0E0E0E0E0E0E0uLL; - a1 = x; - a1 ^= (x & 0xF0F0F0F0F0F0F0F0uLL) >> 4; - a2 = ((x & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((x & 0x3333333333333333uLL) << 2); - a3 = x & a1; - a3 ^= (a3 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; - a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAAAAAAAAAuLL; - a4 = a2 & a1; - a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; - a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; - a5 = (a3 & 0xCCCCCCCCCCCCCCCCuLL) >> 2; - a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; - a4 = a5 & 0x2222222222222222uLL; - a4 |= a4 >> 1; - a4 ^= (a5 << 1) & 0x2222222222222222uLL; - a3 ^= a4; - a5 = a3 & 0xA0A0A0A0A0A0A0A0uLL; - a5 |= a5 >> 1; - a5 ^= (a3 << 1) & 0xA0A0A0A0A0A0A0A0uLL; - a4 = a5 & 0xC0C0C0C0C0C0C0C0uLL; - a6 = a4 >> 2; - a4 ^= (a5 << 2) & 0xC0C0C0C0C0C0C0C0uLL; - a5 = a6 & 0x2020202020202020uLL; - a5 |= a5 >> 1; - a5 ^= (a6 << 1) & 0x2020202020202020uLL; - a4 |= a5; - a3 ^= a4 >> 4; - a3 &= 0x0F0F0F0F0F0F0F0FuLL; - a2 = a3; - a2 ^= (a3 & 0x0C0C0C0C0C0C0C0CuLL) >> 2; - a4 = a3 & a2; - a4 ^= (a4 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; - a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0A0A0A0A0AuLL; - a5 = a4 & 0x0808080808080808uLL; - a5 |= a5 >> 1; - a5 ^= (a4 << 1) & 0x0808080808080808uLL; - a4 ^= a5 >> 2; - a4 &= 0x0303030303030303uLL; - a4 ^= (a4 & 0x0202020202020202uLL) >> 1; - a4 |= a4 << 2; - a3 = a2 & a4; - a3 ^= (a3 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; - a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0A0A0A0A0AuLL; - a3 |= a3 << 4; - a2 = ((a1 & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((a1 & 0x3333333333333333uLL) << 2); - x = a1 & a3; - x ^= (x & 0xAAAAAAAAAAAAAAAAuLL) >> 1; - x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAAAAAAAAAuLL; - a4 = a2 & a3; - a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; - a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; - a5 = (x & 0xCCCCCCCCCCCCCCCCuLL) >> 2; - x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; - a4 = a5 & 0x2222222222222222uLL; - a4 |= a4 >> 1; - a4 ^= (a5 << 1) & 0x2222222222222222uLL; - x ^= a4; - y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); - x &= 0x3939393939393939uLL; - x ^= y & 0x3F3F3F3F3F3F3F3FuLL; - y = ((y & 0xFCFCFCFCFCFCFCFCuLL) >> 2) | ((y & 0x0303030303030303uLL) << 6); - x ^= y & 0x9797979797979797uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x9B9B9B9B9B9B9B9BuLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x3C3C3C3C3C3C3C3CuLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0xDDDDDDDDDDDDDDDDuLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x7272727272727272uLL; - x ^= 0x6363636363636363uLL; - *w = x; -} - -/* - * This computes w := (S^-1 * (w + c))^-1 - */ -static void InvSubLong(u64 *w) -{ - u64 x, y, a1, a2, a3, a4, a5, a6; - - x = *w; - x ^= 0x6363636363636363uLL; - y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); - x &= 0xFDFDFDFDFDFDFDFDuLL; - x ^= y & 0x5E5E5E5E5E5E5E5EuLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0xF3F3F3F3F3F3F3F3uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0xF5F5F5F5F5F5F5F5uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x7878787878787878uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x7777777777777777uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x1515151515151515uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0xA5A5A5A5A5A5A5A5uLL; - a1 = x; - a1 ^= (x & 0xF0F0F0F0F0F0F0F0uLL) >> 4; - a2 = ((x & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((x & 0x3333333333333333uLL) << 2); - a3 = x & a1; - a3 ^= (a3 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; - a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAAAAAAAAAuLL; - a4 = a2 & a1; - a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; - a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; - a5 = (a3 & 0xCCCCCCCCCCCCCCCCuLL) >> 2; - a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; - a4 = a5 & 0x2222222222222222uLL; - a4 |= a4 >> 1; - a4 ^= (a5 << 1) & 0x2222222222222222uLL; - a3 ^= a4; - a5 = a3 & 0xA0A0A0A0A0A0A0A0uLL; - a5 |= a5 >> 1; - a5 ^= (a3 << 1) & 0xA0A0A0A0A0A0A0A0uLL; - a4 = a5 & 0xC0C0C0C0C0C0C0C0uLL; - a6 = a4 >> 2; - a4 ^= (a5 << 2) & 0xC0C0C0C0C0C0C0C0uLL; - a5 = a6 & 0x2020202020202020uLL; - a5 |= a5 >> 1; - a5 ^= (a6 << 1) & 0x2020202020202020uLL; - a4 |= a5; - a3 ^= a4 >> 4; - a3 &= 0x0F0F0F0F0F0F0F0FuLL; - a2 = a3; - a2 ^= (a3 & 0x0C0C0C0C0C0C0C0CuLL) >> 2; - a4 = a3 & a2; - a4 ^= (a4 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; - a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0A0A0A0A0AuLL; - a5 = a4 & 0x0808080808080808uLL; - a5 |= a5 >> 1; - a5 ^= (a4 << 1) & 0x0808080808080808uLL; - a4 ^= a5 >> 2; - a4 &= 0x0303030303030303uLL; - a4 ^= (a4 & 0x0202020202020202uLL) >> 1; - a4 |= a4 << 2; - a3 = a2 & a4; - a3 ^= (a3 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; - a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0A0A0A0A0AuLL; - a3 |= a3 << 4; - a2 = ((a1 & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((a1 & 0x3333333333333333uLL) << 2); - x = a1 & a3; - x ^= (x & 0xAAAAAAAAAAAAAAAAuLL) >> 1; - x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAAAAAAAAAuLL; - a4 = a2 & a3; - a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; - a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; - a5 = (x & 0xCCCCCCCCCCCCCCCCuLL) >> 2; - x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; - a4 = a5 & 0x2222222222222222uLL; - a4 |= a4 >> 1; - a4 ^= (a5 << 1) & 0x2222222222222222uLL; - x ^= a4; - y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); - x &= 0xB5B5B5B5B5B5B5B5uLL; - x ^= y & 0x4040404040404040uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x8080808080808080uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x1616161616161616uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0xEBEBEBEBEBEBEBEBuLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x9797979797979797uLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0xFBFBFBFBFBFBFBFBuLL; - y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); - x ^= y & 0x7D7D7D7D7D7D7D7DuLL; - *w = x; -} - -static void ShiftRows(u64 *state) -{ - unsigned char s[4]; - unsigned char *s0; - int r; - - s0 = (unsigned char *)state; - for (r = 0; r < 4; r++) { - s[0] = s0[0*4 + r]; - s[1] = s0[1*4 + r]; - s[2] = s0[2*4 + r]; - s[3] = s0[3*4 + r]; - s0[0*4 + r] = s[(r+0) % 4]; - s0[1*4 + r] = s[(r+1) % 4]; - s0[2*4 + r] = s[(r+2) % 4]; - s0[3*4 + r] = s[(r+3) % 4]; - } -} - -static void InvShiftRows(u64 *state) -{ - unsigned char s[4]; - unsigned char *s0; - int r; - - s0 = (unsigned char *)state; - for (r = 0; r < 4; r++) { - s[0] = s0[0*4 + r]; - s[1] = s0[1*4 + r]; - s[2] = s0[2*4 + r]; - s[3] = s0[3*4 + r]; - s0[0*4 + r] = s[(4-r) % 4]; - s0[1*4 + r] = s[(5-r) % 4]; - s0[2*4 + r] = s[(6-r) % 4]; - s0[3*4 + r] = s[(7-r) % 4]; - } -} - -static void MixColumns(u64 *state) -{ - uni s1; - uni s; - int c; - - for (c = 0; c < 2; c++) { - s1.d = state[c]; - s.d = s1.d; - s.d ^= ((s.d & 0xFFFF0000FFFF0000uLL) >> 16) - | ((s.d & 0x0000FFFF0000FFFFuLL) << 16); - s.d ^= ((s.d & 0xFF00FF00FF00FF00uLL) >> 8) - | ((s.d & 0x00FF00FF00FF00FFuLL) << 8); - s.d ^= s1.d; - XtimeLong(&s1.d); - s.d ^= s1.d; - s.b[0] ^= s1.b[1]; - s.b[1] ^= s1.b[2]; - s.b[2] ^= s1.b[3]; - s.b[3] ^= s1.b[0]; - s.b[4] ^= s1.b[5]; - s.b[5] ^= s1.b[6]; - s.b[6] ^= s1.b[7]; - s.b[7] ^= s1.b[4]; - state[c] = s.d; - } -} - -static void InvMixColumns(u64 *state) -{ - uni s1; - uni s; - int c; - - for (c = 0; c < 2; c++) { - s1.d = state[c]; - s.d = s1.d; - s.d ^= ((s.d & 0xFFFF0000FFFF0000uLL) >> 16) - | ((s.d & 0x0000FFFF0000FFFFuLL) << 16); - s.d ^= ((s.d & 0xFF00FF00FF00FF00uLL) >> 8) - | ((s.d & 0x00FF00FF00FF00FFuLL) << 8); - s.d ^= s1.d; - XtimeLong(&s1.d); - s.d ^= s1.d; - s.b[0] ^= s1.b[1]; - s.b[1] ^= s1.b[2]; - s.b[2] ^= s1.b[3]; - s.b[3] ^= s1.b[0]; - s.b[4] ^= s1.b[5]; - s.b[5] ^= s1.b[6]; - s.b[6] ^= s1.b[7]; - s.b[7] ^= s1.b[4]; - XtimeLong(&s1.d); - s1.d ^= ((s1.d & 0xFFFF0000FFFF0000uLL) >> 16) - | ((s1.d & 0x0000FFFF0000FFFFuLL) << 16); - s.d ^= s1.d; - XtimeLong(&s1.d); - s1.d ^= ((s1.d & 0xFF00FF00FF00FF00uLL) >> 8) - | ((s1.d & 0x00FF00FF00FF00FFuLL) << 8); - s.d ^= s1.d; - state[c] = s.d; - } -} - -static void AddRoundKey(u64 *state, const u64 *w) -{ - state[0] ^= w[0]; - state[1] ^= w[1]; -} - -static void Cipher(const unsigned char *in, unsigned char *out, - const u64 *w, int nr) -{ - u64 state[2]; - int i; - - memcpy(state, in, 16); - - AddRoundKey(state, w); - - for (i = 1; i < nr; i++) { - SubLong(&state[0]); - SubLong(&state[1]); - ShiftRows(state); - MixColumns(state); - AddRoundKey(state, w + i*2); - } - - SubLong(&state[0]); - SubLong(&state[1]); - ShiftRows(state); - AddRoundKey(state, w + nr*2); - - memcpy(out, state, 16); -} - -static void InvCipher(const unsigned char *in, unsigned char *out, - const u64 *w, int nr) - -{ - u64 state[2]; - int i; - - memcpy(state, in, 16); - - AddRoundKey(state, w + nr*2); - - for (i = nr - 1; i > 0; i--) { - InvShiftRows(state); - InvSubLong(&state[0]); - InvSubLong(&state[1]); - AddRoundKey(state, w + i*2); - InvMixColumns(state); - } - - InvShiftRows(state); - InvSubLong(&state[0]); - InvSubLong(&state[1]); - AddRoundKey(state, w); - - memcpy(out, state, 16); -} - -static void RotWord(u32 *x) -{ - unsigned char *w0; - unsigned char tmp; - - w0 = (unsigned char *)x; - tmp = w0[0]; - w0[0] = w0[1]; - w0[1] = w0[2]; - w0[2] = w0[3]; - w0[3] = tmp; -} - -static void KeyExpansion(const unsigned char *key, u64 *w, - int nr, int nk) -{ - u32 rcon; - uni prev; - u32 temp; - int i, n; - - memcpy(w, key, nk*4); - memcpy(&rcon, "\1\0\0\0", 4); - n = nk/2; - prev.d = w[n-1]; - for (i = n; i < (nr+1)*2; i++) { - temp = prev.w[1]; - if (i % n == 0) { - RotWord(&temp); - SubWord(&temp); - temp ^= rcon; - XtimeWord(&rcon); - } else if (nk > 6 && i % n == 2) { - SubWord(&temp); - } - prev.d = w[i-n]; - prev.w[0] ^= temp; - prev.w[1] ^= prev.w[0]; - w[i] = prev.d; - } -} - -/** - * Expand the cipher key into the encryption key schedule. - */ -int AES_set_encrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key) -{ - u64 *rk; - - if (!userKey || !key) - return -1; - if (bits != 128 && bits != 192 && bits != 256) - return -2; - - rk = (u64*)key->rd_key; - - if (bits == 128) - key->rounds = 10; - else if (bits == 192) - key->rounds = 12; - else - key->rounds = 14; - - KeyExpansion(userKey, rk, key->rounds, bits/32); - return 0; -} - -/** - * Expand the cipher key into the decryption key schedule. - */ -int AES_set_decrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key) -{ - return AES_set_encrypt_key(userKey, bits, key); -} - -/* - * Encrypt a single block - * in and out can overlap - */ -void AES_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key) -{ - const u64 *rk; - - assert(in && out && key); - rk = (u64*)key->rd_key; - - Cipher(in, out, rk, key->rounds); -} - -/* - * Decrypt a single block - * in and out can overlap - */ -void AES_decrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key) -{ - const u64 *rk; - - assert(in && out && key); - rk = (u64*)key->rd_key; - - InvCipher(in, out, rk, key->rounds); -} -#elif !defined(AES_ASM) +#include "aes_local.h" + +#if defined(OPENSSL_AES_CONST_TIME) && !defined(AES_ASM) +typedef union { + unsigned char b[8]; + u32 w[2]; + u64 d; +} uni; + +/* + * Compute w := (w * x) mod (x^8 + x^4 + x^3 + x^1 + 1) + * Therefore the name "xtime". + */ +static void XtimeWord(u32 *w) +{ + u32 a, b; + + a = *w; + b = a & 0x80808080u; + a ^= b; + b -= b >> 7; + b &= 0x1B1B1B1Bu; + b ^= a << 1; + *w = b; +} + +static void XtimeLong(u64 *w) +{ + u64 a, b; + + a = *w; + b = a & 0x8080808080808080uLL; + a ^= b; + b -= b >> 7; + b &= 0x1B1B1B1B1B1B1B1BuLL; + b ^= a << 1; + *w = b; +} + +/* + * This computes w := S * w ^ -1 + c, where c = {01100011}. + * Instead of using GF(2^8) mod (x^8+x^4+x^3+x+1} we do the inversion + * in GF(GF(GF(2^2)^2)^2) mod (X^2+X+8) + * and GF(GF(2^2)^2) mod (X^2+X+2) + * and GF(2^2) mod (X^2+X+1) + * The first part of the algorithm below transfers the coordinates + * {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80} => + * {1,Y,Y^2,Y^3,Y^4,Y^5,Y^6,Y^7} with Y=0x41: + * {0x01,0x41,0x66,0x6c,0x56,0x9a,0x58,0xc4} + * The last part undoes the coordinate transfer and the final affine + * transformation S: + * b[i] = b[i] + b[(i+4)%8] + b[(i+5)%8] + b[(i+6)%8] + b[(i+7)%8] + c[i] + * in one step. + * The multiplication in GF(2^2^2^2) is done in ordinary coords: + * A = (a0*1 + a1*x^4) + * B = (b0*1 + b1*x^4) + * AB = ((a0*b0 + 8*a1*b1)*1 + (a1*b0 + (a0+a1)*b1)*x^4) + * When A = (a0,a1) is given we want to solve AB = 1: + * (a) 1 = a0*b0 + 8*a1*b1 + * (b) 0 = a1*b0 + (a0+a1)*b1 + * => multiply (a) by a1 and (b) by a0 + * (c) a1 = a1*a0*b0 + (8*a1*a1)*b1 + * (d) 0 = a1*a0*b0 + (a0*a0+a1*a0)*b1 + * => add (c) + (d) + * (e) a1 = (a0*a0 + a1*a0 + 8*a1*a1)*b1 + * => therefore + * b1 = (a0*a0 + a1*a0 + 8*a1*a1)^-1 * a1 + * => and adding (a1*b0) to (b) we get + * (f) a1*b0 = (a0+a1)*b1 + * => therefore + * b0 = (a0*a0 + a1*a0 + 8*a1*a1)^-1 * (a0+a1) + * Note this formula also works for the case + * (a0+a1)*a0 + 8*a1*a1 = 0 + * if the inverse element for 0^-1 is mapped to 0. + * Repeat the same for GF(2^2^2) and GF(2^2). + * We get the following algorithm: + * inv8(a0,a1): + * x0 = a0^a1 + * [y0,y1] = mul4([x0,a1],[a0,a1]); (*) + * y1 = mul4(8,y1); + * t = inv4(y0^y1); + * [b0,b1] = mul4([x0,a1],[t,t]); (*) + * return [b0,b1]; + * The non-linear multiplies (*) can be done in parallel at no extra cost. + */ +static void SubWord(u32 *w) +{ + u32 x, y, a1, a2, a3, a4, a5, a6; + + x = *w; + y = ((x & 0xFEFEFEFEu) >> 1) | ((x & 0x01010101u) << 7); + x &= 0xDDDDDDDDu; + x ^= y & 0x57575757u; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x1C1C1C1Cu; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x4A4A4A4Au; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x42424242u; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x64646464u; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0xE0E0E0E0u; + a1 = x; + a1 ^= (x & 0xF0F0F0F0u) >> 4; + a2 = ((x & 0xCCCCCCCCu) >> 2) | ((x & 0x33333333u) << 2); + a3 = x & a1; + a3 ^= (a3 & 0xAAAAAAAAu) >> 1; + a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAu; + a4 = a2 & a1; + a4 ^= (a4 & 0xAAAAAAAAu) >> 1; + a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAu; + a5 = (a3 & 0xCCCCCCCCu) >> 2; + a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCu; + a4 = a5 & 0x22222222u; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x22222222u; + a3 ^= a4; + a5 = a3 & 0xA0A0A0A0u; + a5 |= a5 >> 1; + a5 ^= (a3 << 1) & 0xA0A0A0A0u; + a4 = a5 & 0xC0C0C0C0u; + a6 = a4 >> 2; + a4 ^= (a5 << 2) & 0xC0C0C0C0u; + a5 = a6 & 0x20202020u; + a5 |= a5 >> 1; + a5 ^= (a6 << 1) & 0x20202020u; + a4 |= a5; + a3 ^= a4 >> 4; + a3 &= 0x0F0F0F0Fu; + a2 = a3; + a2 ^= (a3 & 0x0C0C0C0Cu) >> 2; + a4 = a3 & a2; + a4 ^= (a4 & 0x0A0A0A0A0Au) >> 1; + a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0Au; + a5 = a4 & 0x08080808u; + a5 |= a5 >> 1; + a5 ^= (a4 << 1) & 0x08080808u; + a4 ^= a5 >> 2; + a4 &= 0x03030303u; + a4 ^= (a4 & 0x02020202u) >> 1; + a4 |= a4 << 2; + a3 = a2 & a4; + a3 ^= (a3 & 0x0A0A0A0Au) >> 1; + a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0Au; + a3 |= a3 << 4; + a2 = ((a1 & 0xCCCCCCCCu) >> 2) | ((a1 & 0x33333333u) << 2); + x = a1 & a3; + x ^= (x & 0xAAAAAAAAu) >> 1; + x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAu; + a4 = a2 & a3; + a4 ^= (a4 & 0xAAAAAAAAu) >> 1; + a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAu; + a5 = (x & 0xCCCCCCCCu) >> 2; + x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCu; + a4 = a5 & 0x22222222u; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x22222222u; + x ^= a4; + y = ((x & 0xFEFEFEFEu) >> 1) | ((x & 0x01010101u) << 7); + x &= 0x39393939u; + x ^= y & 0x3F3F3F3Fu; + y = ((y & 0xFCFCFCFCu) >> 2) | ((y & 0x03030303u) << 6); + x ^= y & 0x97979797u; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x9B9B9B9Bu; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x3C3C3C3Cu; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0xDDDDDDDDu; + y = ((y & 0xFEFEFEFEu) >> 1) | ((y & 0x01010101u) << 7); + x ^= y & 0x72727272u; + x ^= 0x63636363u; + *w = x; +} + +static void SubLong(u64 *w) +{ + u64 x, y, a1, a2, a3, a4, a5, a6; + + x = *w; + y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); + x &= 0xDDDDDDDDDDDDDDDDuLL; + x ^= y & 0x5757575757575757uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x1C1C1C1C1C1C1C1CuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x4A4A4A4A4A4A4A4AuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x4242424242424242uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x6464646464646464uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xE0E0E0E0E0E0E0E0uLL; + a1 = x; + a1 ^= (x & 0xF0F0F0F0F0F0F0F0uLL) >> 4; + a2 = ((x & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((x & 0x3333333333333333uLL) << 2); + a3 = x & a1; + a3 ^= (a3 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAAAAAAAAAuLL; + a4 = a2 & a1; + a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; + a5 = (a3 & 0xCCCCCCCCCCCCCCCCuLL) >> 2; + a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; + a4 = a5 & 0x2222222222222222uLL; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x2222222222222222uLL; + a3 ^= a4; + a5 = a3 & 0xA0A0A0A0A0A0A0A0uLL; + a5 |= a5 >> 1; + a5 ^= (a3 << 1) & 0xA0A0A0A0A0A0A0A0uLL; + a4 = a5 & 0xC0C0C0C0C0C0C0C0uLL; + a6 = a4 >> 2; + a4 ^= (a5 << 2) & 0xC0C0C0C0C0C0C0C0uLL; + a5 = a6 & 0x2020202020202020uLL; + a5 |= a5 >> 1; + a5 ^= (a6 << 1) & 0x2020202020202020uLL; + a4 |= a5; + a3 ^= a4 >> 4; + a3 &= 0x0F0F0F0F0F0F0F0FuLL; + a2 = a3; + a2 ^= (a3 & 0x0C0C0C0C0C0C0C0CuLL) >> 2; + a4 = a3 & a2; + a4 ^= (a4 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; + a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0A0A0A0A0AuLL; + a5 = a4 & 0x0808080808080808uLL; + a5 |= a5 >> 1; + a5 ^= (a4 << 1) & 0x0808080808080808uLL; + a4 ^= a5 >> 2; + a4 &= 0x0303030303030303uLL; + a4 ^= (a4 & 0x0202020202020202uLL) >> 1; + a4 |= a4 << 2; + a3 = a2 & a4; + a3 ^= (a3 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; + a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0A0A0A0A0AuLL; + a3 |= a3 << 4; + a2 = ((a1 & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((a1 & 0x3333333333333333uLL) << 2); + x = a1 & a3; + x ^= (x & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAAAAAAAAAuLL; + a4 = a2 & a3; + a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; + a5 = (x & 0xCCCCCCCCCCCCCCCCuLL) >> 2; + x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; + a4 = a5 & 0x2222222222222222uLL; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x2222222222222222uLL; + x ^= a4; + y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); + x &= 0x3939393939393939uLL; + x ^= y & 0x3F3F3F3F3F3F3F3FuLL; + y = ((y & 0xFCFCFCFCFCFCFCFCuLL) >> 2) | ((y & 0x0303030303030303uLL) << 6); + x ^= y & 0x9797979797979797uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x9B9B9B9B9B9B9B9BuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x3C3C3C3C3C3C3C3CuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xDDDDDDDDDDDDDDDDuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x7272727272727272uLL; + x ^= 0x6363636363636363uLL; + *w = x; +} + +/* + * This computes w := (S^-1 * (w + c))^-1 + */ +static void InvSubLong(u64 *w) +{ + u64 x, y, a1, a2, a3, a4, a5, a6; + + x = *w; + x ^= 0x6363636363636363uLL; + y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); + x &= 0xFDFDFDFDFDFDFDFDuLL; + x ^= y & 0x5E5E5E5E5E5E5E5EuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xF3F3F3F3F3F3F3F3uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xF5F5F5F5F5F5F5F5uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x7878787878787878uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x7777777777777777uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x1515151515151515uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xA5A5A5A5A5A5A5A5uLL; + a1 = x; + a1 ^= (x & 0xF0F0F0F0F0F0F0F0uLL) >> 4; + a2 = ((x & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((x & 0x3333333333333333uLL) << 2); + a3 = x & a1; + a3 ^= (a3 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a3 ^= (((x << 1) & a1) ^ ((a1 << 1) & x)) & 0xAAAAAAAAAAAAAAAAuLL; + a4 = a2 & a1; + a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a4 ^= (((a2 << 1) & a1) ^ ((a1 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; + a5 = (a3 & 0xCCCCCCCCCCCCCCCCuLL) >> 2; + a3 ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; + a4 = a5 & 0x2222222222222222uLL; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x2222222222222222uLL; + a3 ^= a4; + a5 = a3 & 0xA0A0A0A0A0A0A0A0uLL; + a5 |= a5 >> 1; + a5 ^= (a3 << 1) & 0xA0A0A0A0A0A0A0A0uLL; + a4 = a5 & 0xC0C0C0C0C0C0C0C0uLL; + a6 = a4 >> 2; + a4 ^= (a5 << 2) & 0xC0C0C0C0C0C0C0C0uLL; + a5 = a6 & 0x2020202020202020uLL; + a5 |= a5 >> 1; + a5 ^= (a6 << 1) & 0x2020202020202020uLL; + a4 |= a5; + a3 ^= a4 >> 4; + a3 &= 0x0F0F0F0F0F0F0F0FuLL; + a2 = a3; + a2 ^= (a3 & 0x0C0C0C0C0C0C0C0CuLL) >> 2; + a4 = a3 & a2; + a4 ^= (a4 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; + a4 ^= (((a3 << 1) & a2) ^ ((a2 << 1) & a3)) & 0x0A0A0A0A0A0A0A0AuLL; + a5 = a4 & 0x0808080808080808uLL; + a5 |= a5 >> 1; + a5 ^= (a4 << 1) & 0x0808080808080808uLL; + a4 ^= a5 >> 2; + a4 &= 0x0303030303030303uLL; + a4 ^= (a4 & 0x0202020202020202uLL) >> 1; + a4 |= a4 << 2; + a3 = a2 & a4; + a3 ^= (a3 & 0x0A0A0A0A0A0A0A0AuLL) >> 1; + a3 ^= (((a2 << 1) & a4) ^ ((a4 << 1) & a2)) & 0x0A0A0A0A0A0A0A0AuLL; + a3 |= a3 << 4; + a2 = ((a1 & 0xCCCCCCCCCCCCCCCCuLL) >> 2) | ((a1 & 0x3333333333333333uLL) << 2); + x = a1 & a3; + x ^= (x & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + x ^= (((a1 << 1) & a3) ^ ((a3 << 1) & a1)) & 0xAAAAAAAAAAAAAAAAuLL; + a4 = a2 & a3; + a4 ^= (a4 & 0xAAAAAAAAAAAAAAAAuLL) >> 1; + a4 ^= (((a2 << 1) & a3) ^ ((a3 << 1) & a2)) & 0xAAAAAAAAAAAAAAAAuLL; + a5 = (x & 0xCCCCCCCCCCCCCCCCuLL) >> 2; + x ^= ((a4 << 2) ^ a4) & 0xCCCCCCCCCCCCCCCCuLL; + a4 = a5 & 0x2222222222222222uLL; + a4 |= a4 >> 1; + a4 ^= (a5 << 1) & 0x2222222222222222uLL; + x ^= a4; + y = ((x & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((x & 0x0101010101010101uLL) << 7); + x &= 0xB5B5B5B5B5B5B5B5uLL; + x ^= y & 0x4040404040404040uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x8080808080808080uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x1616161616161616uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xEBEBEBEBEBEBEBEBuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x9797979797979797uLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0xFBFBFBFBFBFBFBFBuLL; + y = ((y & 0xFEFEFEFEFEFEFEFEuLL) >> 1) | ((y & 0x0101010101010101uLL) << 7); + x ^= y & 0x7D7D7D7D7D7D7D7DuLL; + *w = x; +} + +static void ShiftRows(u64 *state) +{ + unsigned char s[4]; + unsigned char *s0; + int r; + + s0 = (unsigned char *)state; + for (r = 0; r < 4; r++) { + s[0] = s0[0*4 + r]; + s[1] = s0[1*4 + r]; + s[2] = s0[2*4 + r]; + s[3] = s0[3*4 + r]; + s0[0*4 + r] = s[(r+0) % 4]; + s0[1*4 + r] = s[(r+1) % 4]; + s0[2*4 + r] = s[(r+2) % 4]; + s0[3*4 + r] = s[(r+3) % 4]; + } +} + +static void InvShiftRows(u64 *state) +{ + unsigned char s[4]; + unsigned char *s0; + int r; + + s0 = (unsigned char *)state; + for (r = 0; r < 4; r++) { + s[0] = s0[0*4 + r]; + s[1] = s0[1*4 + r]; + s[2] = s0[2*4 + r]; + s[3] = s0[3*4 + r]; + s0[0*4 + r] = s[(4-r) % 4]; + s0[1*4 + r] = s[(5-r) % 4]; + s0[2*4 + r] = s[(6-r) % 4]; + s0[3*4 + r] = s[(7-r) % 4]; + } +} + +static void MixColumns(u64 *state) +{ + uni s1; + uni s; + int c; + + for (c = 0; c < 2; c++) { + s1.d = state[c]; + s.d = s1.d; + s.d ^= ((s.d & 0xFFFF0000FFFF0000uLL) >> 16) + | ((s.d & 0x0000FFFF0000FFFFuLL) << 16); + s.d ^= ((s.d & 0xFF00FF00FF00FF00uLL) >> 8) + | ((s.d & 0x00FF00FF00FF00FFuLL) << 8); + s.d ^= s1.d; + XtimeLong(&s1.d); + s.d ^= s1.d; + s.b[0] ^= s1.b[1]; + s.b[1] ^= s1.b[2]; + s.b[2] ^= s1.b[3]; + s.b[3] ^= s1.b[0]; + s.b[4] ^= s1.b[5]; + s.b[5] ^= s1.b[6]; + s.b[6] ^= s1.b[7]; + s.b[7] ^= s1.b[4]; + state[c] = s.d; + } +} + +static void InvMixColumns(u64 *state) +{ + uni s1; + uni s; + int c; + + for (c = 0; c < 2; c++) { + s1.d = state[c]; + s.d = s1.d; + s.d ^= ((s.d & 0xFFFF0000FFFF0000uLL) >> 16) + | ((s.d & 0x0000FFFF0000FFFFuLL) << 16); + s.d ^= ((s.d & 0xFF00FF00FF00FF00uLL) >> 8) + | ((s.d & 0x00FF00FF00FF00FFuLL) << 8); + s.d ^= s1.d; + XtimeLong(&s1.d); + s.d ^= s1.d; + s.b[0] ^= s1.b[1]; + s.b[1] ^= s1.b[2]; + s.b[2] ^= s1.b[3]; + s.b[3] ^= s1.b[0]; + s.b[4] ^= s1.b[5]; + s.b[5] ^= s1.b[6]; + s.b[6] ^= s1.b[7]; + s.b[7] ^= s1.b[4]; + XtimeLong(&s1.d); + s1.d ^= ((s1.d & 0xFFFF0000FFFF0000uLL) >> 16) + | ((s1.d & 0x0000FFFF0000FFFFuLL) << 16); + s.d ^= s1.d; + XtimeLong(&s1.d); + s1.d ^= ((s1.d & 0xFF00FF00FF00FF00uLL) >> 8) + | ((s1.d & 0x00FF00FF00FF00FFuLL) << 8); + s.d ^= s1.d; + state[c] = s.d; + } +} + +static void AddRoundKey(u64 *state, const u64 *w) +{ + state[0] ^= w[0]; + state[1] ^= w[1]; +} + +static void Cipher(const unsigned char *in, unsigned char *out, + const u64 *w, int nr) +{ + u64 state[2]; + int i; + + memcpy(state, in, 16); + + AddRoundKey(state, w); + + for (i = 1; i < nr; i++) { + SubLong(&state[0]); + SubLong(&state[1]); + ShiftRows(state); + MixColumns(state); + AddRoundKey(state, w + i*2); + } + + SubLong(&state[0]); + SubLong(&state[1]); + ShiftRows(state); + AddRoundKey(state, w + nr*2); + + memcpy(out, state, 16); +} + +static void InvCipher(const unsigned char *in, unsigned char *out, + const u64 *w, int nr) + +{ + u64 state[2]; + int i; + + memcpy(state, in, 16); + + AddRoundKey(state, w + nr*2); + + for (i = nr - 1; i > 0; i--) { + InvShiftRows(state); + InvSubLong(&state[0]); + InvSubLong(&state[1]); + AddRoundKey(state, w + i*2); + InvMixColumns(state); + } + + InvShiftRows(state); + InvSubLong(&state[0]); + InvSubLong(&state[1]); + AddRoundKey(state, w); + + memcpy(out, state, 16); +} + +static void RotWord(u32 *x) +{ + unsigned char *w0; + unsigned char tmp; + + w0 = (unsigned char *)x; + tmp = w0[0]; + w0[0] = w0[1]; + w0[1] = w0[2]; + w0[2] = w0[3]; + w0[3] = tmp; +} + +static void KeyExpansion(const unsigned char *key, u64 *w, + int nr, int nk) +{ + u32 rcon; + uni prev; + u32 temp; + int i, n; + + memcpy(w, key, nk*4); + memcpy(&rcon, "\1\0\0\0", 4); + n = nk/2; + prev.d = w[n-1]; + for (i = n; i < (nr+1)*2; i++) { + temp = prev.w[1]; + if (i % n == 0) { + RotWord(&temp); + SubWord(&temp); + temp ^= rcon; + XtimeWord(&rcon); + } else if (nk > 6 && i % n == 2) { + SubWord(&temp); + } + prev.d = w[i-n]; + prev.w[0] ^= temp; + prev.w[1] ^= prev.w[0]; + w[i] = prev.d; + } +} + +/** + * Expand the cipher key into the encryption key schedule. + */ +int AES_set_encrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key) +{ + u64 *rk; + + if (!userKey || !key) + return -1; + if (bits != 128 && bits != 192 && bits != 256) + return -2; + + rk = (u64*)key->rd_key; + + if (bits == 128) + key->rounds = 10; + else if (bits == 192) + key->rounds = 12; + else + key->rounds = 14; + + KeyExpansion(userKey, rk, key->rounds, bits/32); + return 0; +} + +/** + * Expand the cipher key into the decryption key schedule. + */ +int AES_set_decrypt_key(const unsigned char *userKey, const int bits, + AES_KEY *key) +{ + return AES_set_encrypt_key(userKey, bits, key); +} + +/* + * Encrypt a single block + * in and out can overlap + */ +void AES_encrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key) +{ + const u64 *rk; + + assert(in && out && key); + rk = (u64*)key->rd_key; + + Cipher(in, out, rk, key->rounds); +} + +/* + * Decrypt a single block + * in and out can overlap + */ +void AES_decrypt(const unsigned char *in, unsigned char *out, + const AES_KEY *key) +{ + const u64 *rk; + + assert(in && out && key); + rk = (u64*)key->rd_key; + + InvCipher(in, out, rk, key->rounds); +} +#elif !defined(AES_ASM) /*- Te0[x] = S [x].[02, 01, 01, 03]; Te1[x] = S [x].[03, 02, 01, 01]; diff --git a/contrib/libs/openssl/crypto/aes/aes_ecb.c b/contrib/libs/openssl/crypto/aes/aes_ecb.c index acf2deeadb..4fa360ca8b 100644 --- a/contrib/libs/openssl/crypto/aes/aes_ecb.c +++ b/contrib/libs/openssl/crypto/aes/aes_ecb.c @@ -10,7 +10,7 @@ #include <assert.h> #include <openssl/aes.h> -#include "aes_local.h" +#include "aes_local.h" void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, const AES_KEY *key, const int enc) diff --git a/contrib/libs/openssl/crypto/aes/aes_ige.c b/contrib/libs/openssl/crypto/aes/aes_ige.c index ac390bfabe..804b3a723d 100644 --- a/contrib/libs/openssl/crypto/aes/aes_ige.c +++ b/contrib/libs/openssl/crypto/aes/aes_ige.c @@ -10,7 +10,7 @@ #include "internal/cryptlib.h" #include <openssl/aes.h> -#include "aes_local.h" +#include "aes_local.h" /* XXX: probably some better way to do this */ #if defined(__i386__) || defined(__x86_64__) diff --git a/contrib/libs/openssl/crypto/aes/aes_local.h b/contrib/libs/openssl/crypto/aes/aes_local.h index c9f277e7a3..a9c0059e52 100644 --- a/contrib/libs/openssl/crypto/aes/aes_local.h +++ b/contrib/libs/openssl/crypto/aes/aes_local.h @@ -1,43 +1,43 @@ -/* - * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_AES_LOCAL_H -# define OSSL_CRYPTO_AES_LOCAL_H - -# include <openssl/e_os2.h> -# include <stdio.h> -# include <stdlib.h> -# include <string.h> - -# if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) -# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) -# define GETU32(p) SWAP(*((u32 *)(p))) -# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); } -# else -# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) -# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } -# endif - -typedef unsigned long long u64; -# ifdef AES_LONG -typedef unsigned long u32; -# else -typedef unsigned int u32; -# endif -typedef unsigned short u16; -typedef unsigned char u8; - -# define MAXKC (256/32) -# define MAXKB (256/8) -# define MAXNR 14 - -/* This controls loop-unrolling in aes_core.c */ -# undef FULL_UNROLL - -#endif /* !OSSL_CRYPTO_AES_LOCAL_H */ +/* + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_AES_LOCAL_H +# define OSSL_CRYPTO_AES_LOCAL_H + +# include <openssl/e_os2.h> +# include <stdio.h> +# include <stdlib.h> +# include <string.h> + +# if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) +# define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00) +# define GETU32(p) SWAP(*((u32 *)(p))) +# define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); } +# else +# define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) +# define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } +# endif + +typedef unsigned long long u64; +# ifdef AES_LONG +typedef unsigned long u32; +# else +typedef unsigned int u32; +# endif +typedef unsigned short u16; +typedef unsigned char u8; + +# define MAXKC (256/32) +# define MAXKB (256/8) +# define MAXNR 14 + +/* This controls loop-unrolling in aes_core.c */ +# undef FULL_UNROLL + +#endif /* !OSSL_CRYPTO_AES_LOCAL_H */ diff --git a/contrib/libs/openssl/crypto/aes/aes_misc.c b/contrib/libs/openssl/crypto/aes/aes_misc.c index 65d089101c..e0edc72ba7 100644 --- a/contrib/libs/openssl/crypto/aes/aes_misc.c +++ b/contrib/libs/openssl/crypto/aes/aes_misc.c @@ -9,7 +9,7 @@ #include <openssl/opensslv.h> #include <openssl/aes.h> -#include "aes_local.h" +#include "aes_local.h" const char *AES_options(void) { diff --git a/contrib/libs/openssl/crypto/aes/aes_x86core.c b/contrib/libs/openssl/crypto/aes/aes_x86core.c index 9f2b6ab972..50b53abc12 100644 --- a/contrib/libs/openssl/crypto/aes/aes_x86core.c +++ b/contrib/libs/openssl/crypto/aes/aes_x86core.c @@ -46,7 +46,7 @@ #include <stdlib.h> #include <openssl/aes.h> -#include "aes_local.h" +#include "aes_local.h" /* * These two parameters control which table, 256-byte or 2KB, is diff --git a/contrib/libs/openssl/crypto/aria/aria.c b/contrib/libs/openssl/crypto/aria/aria.c index e30c82720c..ce55d52664 100644 --- a/contrib/libs/openssl/crypto/aria/aria.c +++ b/contrib/libs/openssl/crypto/aria/aria.c @@ -19,7 +19,7 @@ */ #include <openssl/e_os2.h> -#include "crypto/aria.h" +#include "crypto/aria.h" #include <assert.h> #include <string.h> diff --git a/contrib/libs/openssl/crypto/arm_arch.h b/contrib/libs/openssl/crypto/arm_arch.h index 37f6236914..8b7105571d 100644 --- a/contrib/libs/openssl/crypto/arm_arch.h +++ b/contrib/libs/openssl/crypto/arm_arch.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_ARM_ARCH_H -# define OSSL_CRYPTO_ARM_ARCH_H +#ifndef OSSL_CRYPTO_ARM_ARCH_H +# define OSSL_CRYPTO_ARM_ARCH_H # if !defined(__ARM_ARCH__) # if defined(__CC_ARM) diff --git a/contrib/libs/openssl/crypto/asn1/a_bitstr.c b/contrib/libs/openssl/crypto/asn1/a_bitstr.c index 8b4ce931a9..f462dd1073 100644 --- a/contrib/libs/openssl/crypto/asn1/a_bitstr.c +++ b/contrib/libs/openssl/crypto/asn1/a_bitstr.c @@ -11,7 +11,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/asn1.h> -#include "asn1_local.h" +#include "asn1_local.h" int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len) { diff --git a/contrib/libs/openssl/crypto/asn1/a_d2i_fp.c b/contrib/libs/openssl/crypto/asn1/a_d2i_fp.c index abb791633c..a452b3deba 100644 --- a/contrib/libs/openssl/crypto/asn1/a_d2i_fp.c +++ b/contrib/libs/openssl/crypto/asn1/a_d2i_fp.c @@ -13,7 +13,7 @@ #include "internal/numbers.h" #include <openssl/buffer.h> #include <openssl/asn1.h> -#include "crypto/asn1.h" +#include "crypto/asn1.h" #ifndef NO_OLD_ASN1 # ifndef OPENSSL_NO_STDIO diff --git a/contrib/libs/openssl/crypto/asn1/a_gentm.c b/contrib/libs/openssl/crypto/asn1/a_gentm.c index c850260dc5..133bbb1581 100644 --- a/contrib/libs/openssl/crypto/asn1/a_gentm.c +++ b/contrib/libs/openssl/crypto/asn1/a_gentm.c @@ -15,7 +15,7 @@ #include <time.h> #include "internal/cryptlib.h" #include <openssl/asn1.h> -#include "asn1_local.h" +#include "asn1_local.h" /* This is the primary function used to parse ASN1_GENERALIZEDTIME */ int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d) diff --git a/contrib/libs/openssl/crypto/asn1/a_int.c b/contrib/libs/openssl/crypto/asn1/a_int.c index 319ce054f4..9c1a9f52b5 100644 --- a/contrib/libs/openssl/crypto/asn1/a_int.c +++ b/contrib/libs/openssl/crypto/asn1/a_int.c @@ -13,7 +13,7 @@ #include <limits.h> #include <openssl/asn1.h> #include <openssl/bn.h> -#include "asn1_local.h" +#include "asn1_local.h" ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x) { diff --git a/contrib/libs/openssl/crypto/asn1/a_mbstr.c b/contrib/libs/openssl/crypto/asn1/a_mbstr.c index fbeef38e92..bdb697ab30 100644 --- a/contrib/libs/openssl/crypto/asn1/a_mbstr.c +++ b/contrib/libs/openssl/crypto/asn1/a_mbstr.c @@ -8,7 +8,7 @@ */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/cryptlib.h" #include <openssl/asn1.h> diff --git a/contrib/libs/openssl/crypto/asn1/a_object.c b/contrib/libs/openssl/crypto/asn1/a_object.c index 98da34771c..8ade9e50a7 100644 --- a/contrib/libs/openssl/crypto/asn1/a_object.c +++ b/contrib/libs/openssl/crypto/asn1/a_object.c @@ -9,14 +9,14 @@ #include <stdio.h> #include <limits.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/cryptlib.h" #include <openssl/buffer.h> #include <openssl/asn1.h> #include <openssl/objects.h> #include <openssl/bn.h> -#include "crypto/asn1.h" -#include "asn1_local.h" +#include "crypto/asn1.h" +#include "asn1_local.h" int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp) { diff --git a/contrib/libs/openssl/crypto/asn1/a_print.c b/contrib/libs/openssl/crypto/asn1/a_print.c index 928cce3306..85a631a27a 100644 --- a/contrib/libs/openssl/crypto/asn1/a_print.c +++ b/contrib/libs/openssl/crypto/asn1/a_print.c @@ -8,7 +8,7 @@ */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/cryptlib.h" #include <openssl/asn1.h> diff --git a/contrib/libs/openssl/crypto/asn1/a_sign.c b/contrib/libs/openssl/crypto/asn1/a_sign.c index 43f85b0681..72381b6655 100644 --- a/contrib/libs/openssl/crypto/asn1/a_sign.c +++ b/contrib/libs/openssl/crypto/asn1/a_sign.c @@ -18,8 +18,8 @@ #include <openssl/x509.h> #include <openssl/objects.h> #include <openssl/buffer.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" #ifndef NO_ASN1_OLD diff --git a/contrib/libs/openssl/crypto/asn1/a_strex.c b/contrib/libs/openssl/crypto/asn1/a_strex.c index 0925935c86..284dde274c 100644 --- a/contrib/libs/openssl/crypto/asn1/a_strex.c +++ b/contrib/libs/openssl/crypto/asn1/a_strex.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <string.h> #include "internal/cryptlib.h" -#include "crypto/asn1.h" +#include "crypto/asn1.h" #include <openssl/crypto.h> #include <openssl/x509.h> #include <openssl/asn1.h> diff --git a/contrib/libs/openssl/crypto/asn1/a_time.c b/contrib/libs/openssl/crypto/asn1/a_time.c index d5c319755d..54e0de1931 100644 --- a/contrib/libs/openssl/crypto/asn1/a_time.c +++ b/contrib/libs/openssl/crypto/asn1/a_time.c @@ -16,10 +16,10 @@ #include <stdio.h> #include <time.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/cryptlib.h" #include <openssl/asn1t.h> -#include "asn1_local.h" +#include "asn1_local.h" IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME) diff --git a/contrib/libs/openssl/crypto/asn1/a_type.c b/contrib/libs/openssl/crypto/asn1/a_type.c index af3c36a823..4a96315df0 100644 --- a/contrib/libs/openssl/crypto/asn1/a_type.c +++ b/contrib/libs/openssl/crypto/asn1/a_type.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include <openssl/asn1t.h> #include <openssl/objects.h> -#include "asn1_local.h" +#include "asn1_local.h" int ASN1_TYPE_get(const ASN1_TYPE *a) { diff --git a/contrib/libs/openssl/crypto/asn1/a_utctm.c b/contrib/libs/openssl/crypto/asn1/a_utctm.c index e9b2ce3751..0ff37b16c5 100644 --- a/contrib/libs/openssl/crypto/asn1/a_utctm.c +++ b/contrib/libs/openssl/crypto/asn1/a_utctm.c @@ -11,7 +11,7 @@ #include <time.h> #include "internal/cryptlib.h" #include <openssl/asn1.h> -#include "asn1_local.h" +#include "asn1_local.h" /* This is the primary function used to parse ASN1_UTCTIME */ int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d) diff --git a/contrib/libs/openssl/crypto/asn1/a_verify.c b/contrib/libs/openssl/crypto/asn1/a_verify.c index 83cd5a12be..4b5f54234f 100644 --- a/contrib/libs/openssl/crypto/asn1/a_verify.c +++ b/contrib/libs/openssl/crypto/asn1/a_verify.c @@ -18,8 +18,8 @@ #include <openssl/objects.h> #include <openssl/buffer.h> #include <openssl/evp.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" #ifndef NO_ASN1_OLD diff --git a/contrib/libs/openssl/crypto/asn1/ameth_lib.c b/contrib/libs/openssl/crypto/asn1/ameth_lib.c index 3ab7269681..5e8c3ed1d5 100644 --- a/contrib/libs/openssl/crypto/asn1/ameth_lib.c +++ b/contrib/libs/openssl/crypto/asn1/ameth_lib.c @@ -13,8 +13,8 @@ #include <openssl/asn1t.h> #include <openssl/x509.h> #include <openssl/engine.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" #include "standard_methods.h" diff --git a/contrib/libs/openssl/crypto/asn1/asn1_lib.c b/contrib/libs/openssl/crypto/asn1/asn1_lib.c index c1aa40ca06..3d99d1383d 100644 --- a/contrib/libs/openssl/crypto/asn1/asn1_lib.c +++ b/contrib/libs/openssl/crypto/asn1/asn1_lib.c @@ -11,7 +11,7 @@ #include <limits.h> #include "internal/cryptlib.h" #include <openssl/asn1.h> -#include "asn1_local.h" +#include "asn1_local.h" static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, long max); @@ -268,29 +268,29 @@ ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *str) return ret; } -int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) +int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len_in) { unsigned char *c; const char *data = _data; - size_t len; + size_t len; - if (len_in < 0) { + if (len_in < 0) { if (data == NULL) return 0; - len = strlen(data); - } else { - len = (size_t)len_in; + len = strlen(data); + } else { + len = (size_t)len_in; + } + /* + * Verify that the length fits within an integer for assignment to + * str->length below. The additional 1 is subtracted to allow for the + * '\0' terminator even though this isn't strictly necessary. + */ + if (len > INT_MAX - 1) { + ASN1err(0, ASN1_R_TOO_LARGE); + return 0; } - /* - * Verify that the length fits within an integer for assignment to - * str->length below. The additional 1 is subtracted to allow for the - * '\0' terminator even though this isn't strictly necessary. - */ - if (len > INT_MAX - 1) { - ASN1err(0, ASN1_R_TOO_LARGE); - return 0; - } - if ((size_t)str->length <= len || str->data == NULL) { + if ((size_t)str->length <= len || str->data == NULL) { c = str->data; #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION /* No NUL terminator in fuzzing builds */ diff --git a/contrib/libs/openssl/crypto/asn1/asn1_local.h b/contrib/libs/openssl/crypto/asn1/asn1_local.h index 5553e4d1ca..cec141721b 100644 --- a/contrib/libs/openssl/crypto/asn1/asn1_local.h +++ b/contrib/libs/openssl/crypto/asn1/asn1_local.h @@ -1,83 +1,83 @@ -/* - * Copyright 2005-2017 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* Internal ASN1 structures and functions: not for application use */ - -int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d); -int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d); -int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d); - -/* ASN1 scan context structure */ - -struct asn1_sctx_st { - /* The ASN1_ITEM associated with this field */ - const ASN1_ITEM *it; - /* If ASN1_TEMPLATE associated with this field */ - const ASN1_TEMPLATE *tt; - /* Various flags associated with field and context */ - unsigned long flags; - /* If SEQUENCE OF or SET OF, field index */ - int skidx; - /* ASN1 depth of field */ - int depth; - /* Structure and field name */ - const char *sname, *fname; - /* If a primitive type the type of underlying field */ - int prim_type; - /* The field value itself */ - ASN1_VALUE **field; - /* Callback to pass information to */ - int (*scan_cb) (ASN1_SCTX *ctx); - /* Context specific application data */ - void *app_data; -} /* ASN1_SCTX */ ; - -typedef struct mime_param_st MIME_PARAM; -DEFINE_STACK_OF(MIME_PARAM) -typedef struct mime_header_st MIME_HEADER; -DEFINE_STACK_OF(MIME_HEADER) - -void asn1_string_embed_free(ASN1_STRING *a, int embed); - -int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_set_choice_selector(ASN1_VALUE **pval, int value, - const ASN1_ITEM *it); - -ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); - -const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, - int nullerr); - -int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); - -void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); -void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); -int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, - const ASN1_ITEM *it); -int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, - const ASN1_ITEM *it); - -void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); -void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); -void asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); - -ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, - long length); -int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp); -ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, - const unsigned char **pp, long length); -int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp); -ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, - long length); - -/* Internal functions used by x_int64.c */ -int c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, long len); -int i2c_uint64_int(unsigned char *p, uint64_t r, int neg); - -ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type); +/* + * Copyright 2005-2017 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* Internal ASN1 structures and functions: not for application use */ + +int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d); +int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d); +int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d); + +/* ASN1 scan context structure */ + +struct asn1_sctx_st { + /* The ASN1_ITEM associated with this field */ + const ASN1_ITEM *it; + /* If ASN1_TEMPLATE associated with this field */ + const ASN1_TEMPLATE *tt; + /* Various flags associated with field and context */ + unsigned long flags; + /* If SEQUENCE OF or SET OF, field index */ + int skidx; + /* ASN1 depth of field */ + int depth; + /* Structure and field name */ + const char *sname, *fname; + /* If a primitive type the type of underlying field */ + int prim_type; + /* The field value itself */ + ASN1_VALUE **field; + /* Callback to pass information to */ + int (*scan_cb) (ASN1_SCTX *ctx); + /* Context specific application data */ + void *app_data; +} /* ASN1_SCTX */ ; + +typedef struct mime_param_st MIME_PARAM; +DEFINE_STACK_OF(MIME_PARAM) +typedef struct mime_header_st MIME_HEADER; +DEFINE_STACK_OF(MIME_HEADER) + +void asn1_string_embed_free(ASN1_STRING *a, int embed); + +int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_set_choice_selector(ASN1_VALUE **pval, int value, + const ASN1_ITEM *it); + +ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); + +const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt, + int nullerr); + +int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it); + +void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it); +void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it); +int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, + const ASN1_ITEM *it); +int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen, + const ASN1_ITEM *it); + +void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); +void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); +void asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); + +ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, + long length); +int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp); +ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, + const unsigned char **pp, long length); +int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp); +ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, + long length); + +/* Internal functions used by x_int64.c */ +int c2i_uint64_int(uint64_t *ret, int *neg, const unsigned char **pp, long len); +int i2c_uint64_int(unsigned char *p, uint64_t r, int neg); + +ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type); diff --git a/contrib/libs/openssl/crypto/asn1/asn1_par.c b/contrib/libs/openssl/crypto/asn1/asn1_par.c index 7b77e66b05..a32fa47f22 100644 --- a/contrib/libs/openssl/crypto/asn1/asn1_par.c +++ b/contrib/libs/openssl/crypto/asn1/asn1_par.c @@ -75,8 +75,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int nl, hl, j, r; ASN1_OBJECT *o = NULL; ASN1_OCTET_STRING *os = NULL; - ASN1_INTEGER *ai = NULL; - ASN1_ENUMERATED *ae = NULL; + ASN1_INTEGER *ai = NULL; + ASN1_ENUMERATED *ae = NULL; /* ASN1_BMPSTRING *bmp=NULL; */ int dump_indent, dump_cont = 0; @@ -255,18 +255,18 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, int i; opp = op; - ai = d2i_ASN1_INTEGER(NULL, &opp, len + hl); - if (ai != NULL) { + ai = d2i_ASN1_INTEGER(NULL, &opp, len + hl); + if (ai != NULL) { if (BIO_write(bp, ":", 1) <= 0) goto end; - if (ai->type == V_ASN1_NEG_INTEGER) + if (ai->type == V_ASN1_NEG_INTEGER) if (BIO_write(bp, "-", 1) <= 0) goto end; - for (i = 0; i < ai->length; i++) { - if (BIO_printf(bp, "%02X", ai->data[i]) <= 0) + for (i = 0; i < ai->length; i++) { + if (BIO_printf(bp, "%02X", ai->data[i]) <= 0) goto end; } - if (ai->length == 0) { + if (ai->length == 0) { if (BIO_write(bp, "00", 2) <= 0) goto end; } @@ -275,24 +275,24 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, goto end; dump_cont = 1; } - ASN1_INTEGER_free(ai); - ai = NULL; + ASN1_INTEGER_free(ai); + ai = NULL; } else if (tag == V_ASN1_ENUMERATED) { int i; opp = op; - ae = d2i_ASN1_ENUMERATED(NULL, &opp, len + hl); - if (ae != NULL) { + ae = d2i_ASN1_ENUMERATED(NULL, &opp, len + hl); + if (ae != NULL) { if (BIO_write(bp, ":", 1) <= 0) goto end; - if (ae->type == V_ASN1_NEG_ENUMERATED) + if (ae->type == V_ASN1_NEG_ENUMERATED) if (BIO_write(bp, "-", 1) <= 0) goto end; - for (i = 0; i < ae->length; i++) { - if (BIO_printf(bp, "%02X", ae->data[i]) <= 0) + for (i = 0; i < ae->length; i++) { + if (BIO_printf(bp, "%02X", ae->data[i]) <= 0) goto end; } - if (ae->length == 0) { + if (ae->length == 0) { if (BIO_write(bp, "00", 2) <= 0) goto end; } @@ -301,8 +301,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, goto end; dump_cont = 1; } - ASN1_ENUMERATED_free(ae); - ae = NULL; + ASN1_ENUMERATED_free(ae); + ae = NULL; } else if (len > 0 && dump) { if (!nl) { if (BIO_write(bp, "\n", 1) <= 0) @@ -344,8 +344,8 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length, end: ASN1_OBJECT_free(o); ASN1_OCTET_STRING_free(os); - ASN1_INTEGER_free(ai); - ASN1_ENUMERATED_free(ae); + ASN1_INTEGER_free(ai); + ASN1_ENUMERATED_free(ae); *pp = p; return ret; } diff --git a/contrib/libs/openssl/crypto/asn1/asn_mime.c b/contrib/libs/openssl/crypto/asn1/asn_mime.c index c85d67d358..38735cd86f 100644 --- a/contrib/libs/openssl/crypto/asn1/asn_mime.c +++ b/contrib/libs/openssl/crypto/asn1/asn_mime.c @@ -1,5 +1,5 @@ /* - * Copyright 2008-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2008-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,15 +8,15 @@ */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/cryptlib.h" #include <openssl/rand.h> #include <openssl/x509.h> #include <openssl/asn1.h> #include <openssl/asn1t.h> -#include "crypto/evp.h" +#include "crypto/evp.h" #include "internal/bio.h" -#include "asn1_local.h" +#include "asn1_local.h" /* * Generalised MIME like utilities for streaming ASN1. Although many have a @@ -198,14 +198,14 @@ static int asn1_write_micalg(BIO *out, STACK_OF(X509_ALGOR) *mdalgs) BIO_puts(out, "gostr3411-94"); goto err; - case NID_id_GostR3411_2012_256: - BIO_puts(out, "gostr3411-2012-256"); - goto err; - - case NID_id_GostR3411_2012_512: - BIO_puts(out, "gostr3411-2012-512"); - goto err; - + case NID_id_GostR3411_2012_256: + BIO_puts(out, "gostr3411-2012-256"); + goto err; + + case NID_id_GostR3411_2012_512: + BIO_puts(out, "gostr3411-2012-512"); + goto err; + default: if (have_unknown) write_comma = 0; diff --git a/contrib/libs/openssl/crypto/asn1/asn_moid.c b/contrib/libs/openssl/crypto/asn1/asn_moid.c index f34f2fc2b3..732ce972aa 100644 --- a/contrib/libs/openssl/crypto/asn1/asn_moid.c +++ b/contrib/libs/openssl/crypto/asn1/asn_moid.c @@ -8,13 +8,13 @@ */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include <openssl/crypto.h> #include "internal/cryptlib.h" #include <openssl/conf.h> #include <openssl/x509.h> -#include "crypto/asn1.h" -#include "crypto/objects.h" +#include "crypto/asn1.h" +#include "crypto/objects.h" /* Simple ASN1 OID module: add all objects in a given section */ diff --git a/contrib/libs/openssl/crypto/asn1/d2i_pr.c b/contrib/libs/openssl/crypto/asn1/d2i_pr.c index 71adc3be3f..2094963036 100644 --- a/contrib/libs/openssl/crypto/asn1/d2i_pr.c +++ b/contrib/libs/openssl/crypto/asn1/d2i_pr.c @@ -15,8 +15,8 @@ #include <openssl/engine.h> #include <openssl/x509.h> #include <openssl/asn1.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) diff --git a/contrib/libs/openssl/crypto/asn1/d2i_pu.c b/contrib/libs/openssl/crypto/asn1/d2i_pu.c index 22ad27a090..8327ac16ca 100644 --- a/contrib/libs/openssl/crypto/asn1/d2i_pu.c +++ b/contrib/libs/openssl/crypto/asn1/d2i_pu.c @@ -17,7 +17,7 @@ #include <openssl/dsa.h> #include <openssl/ec.h> -#include "crypto/evp.h" +#include "crypto/evp.h" EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, long length) diff --git a/contrib/libs/openssl/crypto/asn1/f_int.c b/contrib/libs/openssl/crypto/asn1/f_int.c index 66cc4a68ba..3a18381173 100644 --- a/contrib/libs/openssl/crypto/asn1/f_int.c +++ b/contrib/libs/openssl/crypto/asn1/f_int.c @@ -8,7 +8,7 @@ */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/cryptlib.h" #include <openssl/buffer.h> #include <openssl/asn1.h> diff --git a/contrib/libs/openssl/crypto/asn1/f_string.c b/contrib/libs/openssl/crypto/asn1/f_string.c index 71270b9e71..53dfec71b5 100644 --- a/contrib/libs/openssl/crypto/asn1/f_string.c +++ b/contrib/libs/openssl/crypto/asn1/f_string.c @@ -8,7 +8,7 @@ */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/cryptlib.h" #include <openssl/buffer.h> #include <openssl/asn1.h> diff --git a/contrib/libs/openssl/crypto/asn1/i2d_pr.c b/contrib/libs/openssl/crypto/asn1/i2d_pr.c index 7d939c94ea..0374c0bfbd 100644 --- a/contrib/libs/openssl/crypto/asn1/i2d_pr.c +++ b/contrib/libs/openssl/crypto/asn1/i2d_pr.c @@ -11,8 +11,8 @@ #include "internal/cryptlib.h" #include <openssl/evp.h> #include <openssl/x509.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp) { diff --git a/contrib/libs/openssl/crypto/asn1/p8_pkey.c b/contrib/libs/openssl/crypto/asn1/p8_pkey.c index 8c0a6db6d4..ab509b1ac9 100644 --- a/contrib/libs/openssl/crypto/asn1/p8_pkey.c +++ b/contrib/libs/openssl/crypto/asn1/p8_pkey.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include <openssl/asn1t.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" /* Minor tweak to operation: zero private key data */ static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, diff --git a/contrib/libs/openssl/crypto/asn1/t_pkey.c b/contrib/libs/openssl/crypto/asn1/t_pkey.c index bd1ade1ede..651622aedc 100644 --- a/contrib/libs/openssl/crypto/asn1/t_pkey.c +++ b/contrib/libs/openssl/crypto/asn1/t_pkey.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include <openssl/objects.h> #include <openssl/buffer.h> -#include "crypto/bn.h" +#include "crypto/bn.h" /* Number of octets per line */ #define ASN1_BUF_PRINT_WIDTH 15 diff --git a/contrib/libs/openssl/crypto/asn1/tasn_dec.c b/contrib/libs/openssl/crypto/asn1/tasn_dec.c index e8f9f13858..82577b1ede 100644 --- a/contrib/libs/openssl/crypto/asn1/tasn_dec.c +++ b/contrib/libs/openssl/crypto/asn1/tasn_dec.c @@ -15,7 +15,7 @@ #include <openssl/buffer.h> #include <openssl/err.h> #include "internal/numbers.h" -#include "asn1_local.h" +#include "asn1_local.h" /* diff --git a/contrib/libs/openssl/crypto/asn1/tasn_enc.c b/contrib/libs/openssl/crypto/asn1/tasn_enc.c index a774d1af1a..bcc96337bc 100644 --- a/contrib/libs/openssl/crypto/asn1/tasn_enc.c +++ b/contrib/libs/openssl/crypto/asn1/tasn_enc.c @@ -13,8 +13,8 @@ #include <openssl/asn1.h> #include <openssl/asn1t.h> #include <openssl/objects.h> -#include "crypto/asn1.h" -#include "asn1_local.h" +#include "crypto/asn1.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); diff --git a/contrib/libs/openssl/crypto/asn1/tasn_fre.c b/contrib/libs/openssl/crypto/asn1/tasn_fre.c index 8a18f84c41..2916bef786 100644 --- a/contrib/libs/openssl/crypto/asn1/tasn_fre.c +++ b/contrib/libs/openssl/crypto/asn1/tasn_fre.c @@ -11,7 +11,7 @@ #include <openssl/asn1.h> #include <openssl/asn1t.h> #include <openssl/objects.h> -#include "asn1_local.h" +#include "asn1_local.h" /* Free up an ASN1 structure */ diff --git a/contrib/libs/openssl/crypto/asn1/tasn_new.c b/contrib/libs/openssl/crypto/asn1/tasn_new.c index e10107bcdb..287f2af33b 100644 --- a/contrib/libs/openssl/crypto/asn1/tasn_new.c +++ b/contrib/libs/openssl/crypto/asn1/tasn_new.c @@ -13,7 +13,7 @@ #include <openssl/err.h> #include <openssl/asn1t.h> #include <string.h> -#include "asn1_local.h" +#include "asn1_local.h" static int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed); diff --git a/contrib/libs/openssl/crypto/asn1/tasn_prn.c b/contrib/libs/openssl/crypto/asn1/tasn_prn.c index f9f8cdcb62..56d5ea0f39 100644 --- a/contrib/libs/openssl/crypto/asn1/tasn_prn.c +++ b/contrib/libs/openssl/crypto/asn1/tasn_prn.c @@ -15,8 +15,8 @@ #include <openssl/buffer.h> #include <openssl/err.h> #include <openssl/x509v3.h> -#include "crypto/asn1.h" -#include "asn1_local.h" +#include "crypto/asn1.h" +#include "asn1_local.h" /* * Print routines. diff --git a/contrib/libs/openssl/crypto/asn1/tasn_scn.c b/contrib/libs/openssl/crypto/asn1/tasn_scn.c index 9c60de3392..f0f218ae8b 100644 --- a/contrib/libs/openssl/crypto/asn1/tasn_scn.c +++ b/contrib/libs/openssl/crypto/asn1/tasn_scn.c @@ -15,7 +15,7 @@ #include <openssl/buffer.h> #include <openssl/err.h> #include <openssl/x509v3.h> -#include "asn1_local.h" +#include "asn1_local.h" /* * General ASN1 structure recursive scanner: iterate through all fields diff --git a/contrib/libs/openssl/crypto/asn1/tasn_utl.c b/contrib/libs/openssl/crypto/asn1/tasn_utl.c index 51766a9fcb..a448685e19 100644 --- a/contrib/libs/openssl/crypto/asn1/tasn_utl.c +++ b/contrib/libs/openssl/crypto/asn1/tasn_utl.c @@ -15,7 +15,7 @@ #include <openssl/asn1t.h> #include <openssl/objects.h> #include <openssl/err.h> -#include "asn1_local.h" +#include "asn1_local.h" /* Utility functions for manipulating fields and offsets */ diff --git a/contrib/libs/openssl/crypto/asn1/x_algor.c b/contrib/libs/openssl/crypto/asn1/x_algor.c index 288e56d1ee..c9a8f1e9d1 100644 --- a/contrib/libs/openssl/crypto/asn1/x_algor.c +++ b/contrib/libs/openssl/crypto/asn1/x_algor.c @@ -11,7 +11,7 @@ #include <openssl/x509.h> #include <openssl/asn1.h> #include <openssl/asn1t.h> -#include "crypto/evp.h" +#include "crypto/evp.h" ASN1_SEQUENCE(X509_ALGOR) = { ASN1_SIMPLE(X509_ALGOR, algorithm, ASN1_OBJECT), diff --git a/contrib/libs/openssl/crypto/asn1/x_bignum.c b/contrib/libs/openssl/crypto/asn1/x_bignum.c index ebdf67deeb..c6b3accd3a 100644 --- a/contrib/libs/openssl/crypto/asn1/x_bignum.c +++ b/contrib/libs/openssl/crypto/asn1/x_bignum.c @@ -82,7 +82,7 @@ static int bn_secure_new(ASN1_VALUE **pval, const ASN1_ITEM *it) static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it) { - if (*pval == NULL) + if (*pval == NULL) return; if (it->size & BN_SENSITIVE) BN_clear_free((BIGNUM *)*pval); @@ -96,7 +96,7 @@ static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, { BIGNUM *bn; int pad; - if (*pval == NULL) + if (*pval == NULL) return -1; bn = (BIGNUM *)*pval; /* If MSB set in an octet we need a padding byte */ @@ -133,7 +133,7 @@ static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int ret; BIGNUM *bn; - if (*pval == NULL && !bn_secure_new(pval, it)) + if (*pval == NULL && !bn_secure_new(pval, it)) return 0; ret = bn_c2i(pval, cont, len, utype, free_cont, it); diff --git a/contrib/libs/openssl/crypto/asn1/x_int64.c b/contrib/libs/openssl/crypto/asn1/x_int64.c index 2b5ca59adc..96c1a259e1 100644 --- a/contrib/libs/openssl/crypto/asn1/x_int64.c +++ b/contrib/libs/openssl/crypto/asn1/x_int64.c @@ -12,7 +12,7 @@ #include "internal/numbers.h" #include <openssl/asn1t.h> #include <openssl/bn.h> -#include "asn1_local.h" +#include "asn1_local.h" /* * Custom primitive types for handling int32_t, int64_t, uint32_t, uint64_t. diff --git a/contrib/libs/openssl/crypto/asn1/x_sig.c b/contrib/libs/openssl/crypto/asn1/x_sig.c index 4972232df1..fb24e240cb 100644 --- a/contrib/libs/openssl/crypto/asn1/x_sig.c +++ b/contrib/libs/openssl/crypto/asn1/x_sig.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include <openssl/asn1t.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" ASN1_SEQUENCE(X509_SIG) = { ASN1_SIMPLE(X509_SIG, algor, X509_ALGOR), diff --git a/contrib/libs/openssl/crypto/async/arch/async_null.c b/contrib/libs/openssl/crypto/async/arch/async_null.c index b38a70b147..26801f8731 100644 --- a/contrib/libs/openssl/crypto/async/arch/async_null.c +++ b/contrib/libs/openssl/crypto/async/arch/async_null.c @@ -8,7 +8,7 @@ */ /* This must be the first #include file */ -#include "../async_local.h" +#include "../async_local.h" #ifdef ASYNC_NULL int ASYNC_is_capable(void) diff --git a/contrib/libs/openssl/crypto/async/arch/async_posix.c b/contrib/libs/openssl/crypto/async/arch/async_posix.c index 785756f8aa..95678d4fa6 100644 --- a/contrib/libs/openssl/crypto/async/arch/async_posix.c +++ b/contrib/libs/openssl/crypto/async/arch/async_posix.c @@ -8,7 +8,7 @@ */ /* This must be the first #include file */ -#include "../async_local.h" +#include "../async_local.h" #ifdef ASYNC_POSIX diff --git a/contrib/libs/openssl/crypto/async/arch/async_posix.h b/contrib/libs/openssl/crypto/async/arch/async_posix.h index ac8f82e3a5..873c0316dd 100644 --- a/contrib/libs/openssl/crypto/async/arch/async_posix.h +++ b/contrib/libs/openssl/crypto/async/arch/async_posix.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_ASYNC_POSIX_H -#define OSSL_CRYPTO_ASYNC_POSIX_H +#ifndef OSSL_CRYPTO_ASYNC_POSIX_H +#define OSSL_CRYPTO_ASYNC_POSIX_H #include <openssl/e_os2.h> #if defined(OPENSSL_SYS_UNIX) \ @@ -55,4 +55,4 @@ void async_fibre_free(async_fibre *fibre); # endif #endif -#endif /* OSSL_CRYPTO_ASYNC_POSIX_H */ +#endif /* OSSL_CRYPTO_ASYNC_POSIX_H */ diff --git a/contrib/libs/openssl/crypto/async/arch/async_win.c b/contrib/libs/openssl/crypto/async/arch/async_win.c index 37784fce76..1f360d895b 100644 --- a/contrib/libs/openssl/crypto/async/arch/async_win.c +++ b/contrib/libs/openssl/crypto/async/arch/async_win.c @@ -8,7 +8,7 @@ */ /* This must be the first #include file */ -#include "../async_local.h" +#include "../async_local.h" #ifdef ASYNC_WIN diff --git a/contrib/libs/openssl/crypto/async/async.c b/contrib/libs/openssl/crypto/async/async.c index 2a650a0c34..326015c605 100644 --- a/contrib/libs/openssl/crypto/async/async.c +++ b/contrib/libs/openssl/crypto/async/async.c @@ -16,10 +16,10 @@ #undef _FORTIFY_SOURCE /* This must be the first #include file */ -#include "async_local.h" +#include "async_local.h" #include <openssl/err.h> -#include "crypto/cryptlib.h" +#include "crypto/cryptlib.h" #include <string.h> #define ASYNC_JOB_RUNNING 0 diff --git a/contrib/libs/openssl/crypto/async/async_local.h b/contrib/libs/openssl/crypto/async/async_local.h index b45ec148c7..dd1a85e026 100644 --- a/contrib/libs/openssl/crypto/async/async_local.h +++ b/contrib/libs/openssl/crypto/async/async_local.h @@ -1,77 +1,77 @@ -/* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * Must do this before including any header files, because on MacOS/X <stlib.h> - * includes <signal.h> which includes <ucontext.h> - */ -#if defined(__APPLE__) && defined(__MACH__) && !defined(_XOPEN_SOURCE) -# define _XOPEN_SOURCE /* Otherwise incomplete ucontext_t structure */ -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif - -#if defined(_WIN32) -# include <windows.h> -#endif - -#include "crypto/async.h" -#include <openssl/crypto.h> - -typedef struct async_ctx_st async_ctx; -typedef struct async_pool_st async_pool; - -#include "arch/async_win.h" -#include "arch/async_posix.h" -#include "arch/async_null.h" - -struct async_ctx_st { - async_fibre dispatcher; - ASYNC_JOB *currjob; - unsigned int blocked; -}; - -struct async_job_st { - async_fibre fibrectx; - int (*func) (void *); - void *funcargs; - int ret; - int status; - ASYNC_WAIT_CTX *waitctx; -}; - -struct fd_lookup_st { - const void *key; - OSSL_ASYNC_FD fd; - void *custom_data; - void (*cleanup)(ASYNC_WAIT_CTX *, const void *, OSSL_ASYNC_FD, void *); - int add; - int del; - struct fd_lookup_st *next; -}; - -struct async_wait_ctx_st { - struct fd_lookup_st *fds; - size_t numadd; - size_t numdel; -}; - -DEFINE_STACK_OF(ASYNC_JOB) - -struct async_pool_st { - STACK_OF(ASYNC_JOB) *jobs; - size_t curr_size; - size_t max_size; -}; - -void async_local_cleanup(void); -void async_start_func(void); -async_ctx *async_get_ctx(void); - -void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx); - +/* + * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * Must do this before including any header files, because on MacOS/X <stlib.h> + * includes <signal.h> which includes <ucontext.h> + */ +#if defined(__APPLE__) && defined(__MACH__) && !defined(_XOPEN_SOURCE) +# define _XOPEN_SOURCE /* Otherwise incomplete ucontext_t structure */ +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + +#if defined(_WIN32) +# include <windows.h> +#endif + +#include "crypto/async.h" +#include <openssl/crypto.h> + +typedef struct async_ctx_st async_ctx; +typedef struct async_pool_st async_pool; + +#include "arch/async_win.h" +#include "arch/async_posix.h" +#include "arch/async_null.h" + +struct async_ctx_st { + async_fibre dispatcher; + ASYNC_JOB *currjob; + unsigned int blocked; +}; + +struct async_job_st { + async_fibre fibrectx; + int (*func) (void *); + void *funcargs; + int ret; + int status; + ASYNC_WAIT_CTX *waitctx; +}; + +struct fd_lookup_st { + const void *key; + OSSL_ASYNC_FD fd; + void *custom_data; + void (*cleanup)(ASYNC_WAIT_CTX *, const void *, OSSL_ASYNC_FD, void *); + int add; + int del; + struct fd_lookup_st *next; +}; + +struct async_wait_ctx_st { + struct fd_lookup_st *fds; + size_t numadd; + size_t numdel; +}; + +DEFINE_STACK_OF(ASYNC_JOB) + +struct async_pool_st { + STACK_OF(ASYNC_JOB) *jobs; + size_t curr_size; + size_t max_size; +}; + +void async_local_cleanup(void); +void async_start_func(void); +async_ctx *async_get_ctx(void); + +void async_wait_ctx_reset_counts(ASYNC_WAIT_CTX *ctx); + diff --git a/contrib/libs/openssl/crypto/async/async_wait.c b/contrib/libs/openssl/crypto/async/async_wait.c index 2485c64695..7723f949a6 100644 --- a/contrib/libs/openssl/crypto/async/async_wait.c +++ b/contrib/libs/openssl/crypto/async/async_wait.c @@ -8,7 +8,7 @@ */ /* This must be the first #include file */ -#include "async_local.h" +#include "async_local.h" #include <openssl/err.h> diff --git a/contrib/libs/openssl/crypto/bf/bf_cfb64.c b/contrib/libs/openssl/crypto/bf/bf_cfb64.c index cec54d2da4..12332c540d 100644 --- a/contrib/libs/openssl/crypto/bf/bf_cfb64.c +++ b/contrib/libs/openssl/crypto/bf/bf_cfb64.c @@ -8,7 +8,7 @@ */ #include <openssl/blowfish.h> -#include "bf_local.h" +#include "bf_local.h" /* * The input and output encrypted as though 64bit cfb mode is being used. diff --git a/contrib/libs/openssl/crypto/bf/bf_ecb.c b/contrib/libs/openssl/crypto/bf/bf_ecb.c index 277263d7ff..38e784cc2d 100644 --- a/contrib/libs/openssl/crypto/bf/bf_ecb.c +++ b/contrib/libs/openssl/crypto/bf/bf_ecb.c @@ -8,7 +8,7 @@ */ #include <openssl/blowfish.h> -#include "bf_local.h" +#include "bf_local.h" #include <openssl/opensslv.h> /* diff --git a/contrib/libs/openssl/crypto/bf/bf_enc.c b/contrib/libs/openssl/crypto/bf/bf_enc.c index 11d0014f3a..423a4697a5 100644 --- a/contrib/libs/openssl/crypto/bf/bf_enc.c +++ b/contrib/libs/openssl/crypto/bf/bf_enc.c @@ -8,7 +8,7 @@ */ #include <openssl/blowfish.h> -#include "bf_local.h" +#include "bf_local.h" /* * Blowfish as implemented from 'Blowfish: Springer-Verlag paper' (From diff --git a/contrib/libs/openssl/crypto/bf/bf_local.h b/contrib/libs/openssl/crypto/bf/bf_local.h index 89a7bb2950..8c76976fa4 100644 --- a/contrib/libs/openssl/crypto/bf/bf_local.h +++ b/contrib/libs/openssl/crypto/bf/bf_local.h @@ -1,84 +1,84 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_BF_LOCAL_H -# define OSSL_CRYPTO_BF_LOCAL_H -# include <openssl/opensslconf.h> - -/* NOTE - c is not incremented as per n2l */ -# define n2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c)))) ; \ - /* fall thru */ \ - case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ - /* fall thru */ \ - case 6: l2|=((unsigned long)(*(--(c))))<<16; \ - /* fall thru */ \ - case 5: l2|=((unsigned long)(*(--(c))))<<24; \ - /* fall thru */ \ - case 4: l1 =((unsigned long)(*(--(c)))) ; \ - /* fall thru */ \ - case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ - /* fall thru */ \ - case 2: l1|=((unsigned long)(*(--(c))))<<16; \ - /* fall thru */ \ - case 1: l1|=((unsigned long)(*(--(c))))<<24; \ - } \ - } - -/* NOTE - c is not incremented as per l2n */ -# define l2nn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ - /* fall thru */ \ - case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - /* fall thru */ \ - case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - /* fall thru */ \ - case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - /* fall thru */ \ - case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ - /* fall thru */ \ - case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - /* fall thru */ \ - case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - /* fall thru */ \ - case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - } \ - } - -# undef n2l -# define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))) - -# undef l2n -# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -/* - * This is actually a big endian algorithm, the most significant byte is used - * to lookup array 0 - */ - -# define BF_ENC(LL,R,S,P) ( \ - LL^=P, \ - LL^=((( S[ ((R>>24)&0xff)] + \ - S[0x0100+((R>>16)&0xff)])^ \ - S[0x0200+((R>> 8)&0xff)])+ \ - S[0x0300+((R )&0xff)])&0xffffffffU \ - ) - -#endif +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_BF_LOCAL_H +# define OSSL_CRYPTO_BF_LOCAL_H +# include <openssl/opensslconf.h> + +/* NOTE - c is not incremented as per n2l */ +# define n2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c)))) ; \ + /* fall thru */ \ + case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ + /* fall thru */ \ + case 6: l2|=((unsigned long)(*(--(c))))<<16; \ + /* fall thru */ \ + case 5: l2|=((unsigned long)(*(--(c))))<<24; \ + /* fall thru */ \ + case 4: l1 =((unsigned long)(*(--(c)))) ; \ + /* fall thru */ \ + case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ + /* fall thru */ \ + case 2: l1|=((unsigned long)(*(--(c))))<<16; \ + /* fall thru */ \ + case 1: l1|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +/* NOTE - c is not incremented as per l2n */ +# define l2nn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ + /* fall thru */ \ + case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + /* fall thru */ \ + case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + /* fall thru */ \ + case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + /* fall thru */ \ + case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ + /* fall thru */ \ + case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + /* fall thru */ \ + case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + /* fall thru */ \ + case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + } \ + } + +# undef n2l +# define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))) + +# undef l2n +# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +/* + * This is actually a big endian algorithm, the most significant byte is used + * to lookup array 0 + */ + +# define BF_ENC(LL,R,S,P) ( \ + LL^=P, \ + LL^=((( S[ ((R>>24)&0xff)] + \ + S[0x0100+((R>>16)&0xff)])^ \ + S[0x0200+((R>> 8)&0xff)])+ \ + S[0x0300+((R )&0xff)])&0xffffffffU \ + ) + +#endif diff --git a/contrib/libs/openssl/crypto/bf/bf_ofb64.c b/contrib/libs/openssl/crypto/bf/bf_ofb64.c index f7a36b0782..5d75401fcc 100644 --- a/contrib/libs/openssl/crypto/bf/bf_ofb64.c +++ b/contrib/libs/openssl/crypto/bf/bf_ofb64.c @@ -8,7 +8,7 @@ */ #include <openssl/blowfish.h> -#include "bf_local.h" +#include "bf_local.h" /* * The input and output encrypted as though 64bit ofb mode is being used. diff --git a/contrib/libs/openssl/crypto/bf/bf_skey.c b/contrib/libs/openssl/crypto/bf/bf_skey.c index 3aba09154d..ed29cf9153 100644 --- a/contrib/libs/openssl/crypto/bf/bf_skey.c +++ b/contrib/libs/openssl/crypto/bf/bf_skey.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <string.h> #include <openssl/blowfish.h> -#include "bf_local.h" +#include "bf_local.h" #include "bf_pi.h" void BF_set_key(BF_KEY *key, int len, const unsigned char *data) diff --git a/contrib/libs/openssl/crypto/bio/b_addr.c b/contrib/libs/openssl/crypto/bio/b_addr.c index 4194269300..8ea32bce40 100644 --- a/contrib/libs/openssl/crypto/bio/b_addr.c +++ b/contrib/libs/openssl/crypto/bio/b_addr.c @@ -14,7 +14,7 @@ #include <assert.h> #include <string.h> -#include "bio_local.h" +#include "bio_local.h" #include <openssl/crypto.h> #ifndef OPENSSL_NO_SOCK @@ -26,7 +26,7 @@ CRYPTO_RWLOCK *bio_lookup_lock; static CRYPTO_ONCE bio_lookup_init = CRYPTO_ONCE_STATIC_INIT; /* - * Throughout this file and bio_local.h, the existence of the macro + * Throughout this file and bio_local.h, the existence of the macro * AI_PASSIVE is used to detect the availability of struct addrinfo, * getnameinfo() and getaddrinfo(). If that macro doesn't exist, * we use our own implementation instead, using gethostbyname, @@ -698,11 +698,11 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type, hints.ai_flags |= AI_PASSIVE; /* Note that |res| SHOULD be a 'struct addrinfo **' thanks to - * macro magic in bio_local.h + * macro magic in bio_local.h */ -# if defined(AI_ADDRCONFIG) && defined(AI_NUMERICHOST) +# if defined(AI_ADDRCONFIG) && defined(AI_NUMERICHOST) retry: -# endif +# endif switch ((gai_ret = getaddrinfo(host, service, &hints, res))) { # ifdef EAI_SYSTEM case EAI_SYSTEM: diff --git a/contrib/libs/openssl/crypto/bio/b_dump.c b/contrib/libs/openssl/crypto/bio/b_dump.c index 4aff77b31c..f175e244b2 100644 --- a/contrib/libs/openssl/crypto/bio/b_dump.c +++ b/contrib/libs/openssl/crypto/bio/b_dump.c @@ -12,7 +12,7 @@ */ #include <stdio.h> -#include "bio_local.h" +#include "bio_local.h" #define DUMP_WIDTH 16 #define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH - ((i - (i > 6 ? 6 : i) + 3) / 4)) @@ -36,8 +36,8 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), if (indent < 0) indent = 0; - else if (indent > 64) - indent = 64; + else if (indent > 64) + indent = 64; dump_width = DUMP_WIDTH_LESS_INDENT(indent); rows = len / dump_width; diff --git a/contrib/libs/openssl/crypto/bio/b_print.c b/contrib/libs/openssl/crypto/bio/b_print.c index 43335c593b..41b7f5e2f6 100644 --- a/contrib/libs/openssl/crypto/bio/b_print.c +++ b/contrib/libs/openssl/crypto/bio/b_print.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <string.h> #include "internal/cryptlib.h" -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/numbers.h" #include <openssl/bio.h> diff --git a/contrib/libs/openssl/crypto/bio/b_sock.c b/contrib/libs/openssl/crypto/bio/b_sock.c index 69f41cba5e..df431e6d52 100644 --- a/contrib/libs/openssl/crypto/bio/b_sock.c +++ b/contrib/libs/openssl/crypto/bio/b_sock.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <stdlib.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #ifndef OPENSSL_NO_SOCK # define SOCKET_PROTOCOL IPPROTO_TCP # ifdef SO_MAXCONN diff --git a/contrib/libs/openssl/crypto/bio/b_sock2.c b/contrib/libs/openssl/crypto/bio/b_sock2.c index 5c970b4ed2..104ff31b0d 100644 --- a/contrib/libs/openssl/crypto/bio/b_sock2.c +++ b/contrib/libs/openssl/crypto/bio/b_sock2.c @@ -11,7 +11,7 @@ #include <stdlib.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #include <openssl/err.h> diff --git a/contrib/libs/openssl/crypto/bio/bf_buff.c b/contrib/libs/openssl/crypto/bio/bf_buff.c index 32c0d94805..51ae1f918d 100644 --- a/contrib/libs/openssl/crypto/bio/bf_buff.c +++ b/contrib/libs/openssl/crypto/bio/bf_buff.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #include "internal/cryptlib.h" static int buffer_write(BIO *h, const char *buf, int num); diff --git a/contrib/libs/openssl/crypto/bio/bf_lbuf.c b/contrib/libs/openssl/crypto/bio/bf_lbuf.c index 4c636f84cb..72f9901813 100644 --- a/contrib/libs/openssl/crypto/bio/bf_lbuf.c +++ b/contrib/libs/openssl/crypto/bio/bf_lbuf.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #include "internal/cryptlib.h" #include <openssl/evp.h> diff --git a/contrib/libs/openssl/crypto/bio/bf_nbio.c b/contrib/libs/openssl/crypto/bio/bf_nbio.c index 0503367444..dd7011ab66 100644 --- a/contrib/libs/openssl/crypto/bio/bf_nbio.c +++ b/contrib/libs/openssl/crypto/bio/bf_nbio.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #include "internal/cryptlib.h" #include <openssl/rand.h> diff --git a/contrib/libs/openssl/crypto/bio/bf_null.c b/contrib/libs/openssl/crypto/bio/bf_null.c index 209b11f4d3..48c6be692a 100644 --- a/contrib/libs/openssl/crypto/bio/bf_null.c +++ b/contrib/libs/openssl/crypto/bio/bf_null.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #include "internal/cryptlib.h" /* diff --git a/contrib/libs/openssl/crypto/bio/bio_cb.c b/contrib/libs/openssl/crypto/bio/bio_cb.c index e47ceb6d2a..a153100a88 100644 --- a/contrib/libs/openssl/crypto/bio/bio_cb.c +++ b/contrib/libs/openssl/crypto/bio/bio_cb.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> -#include "bio_local.h" +#include "bio_local.h" #include "internal/cryptlib.h" #include <openssl/err.h> diff --git a/contrib/libs/openssl/crypto/bio/bio_lib.c b/contrib/libs/openssl/crypto/bio/bio_lib.c index 04b5b166c0..d2202e537b 100644 --- a/contrib/libs/openssl/crypto/bio/bio_lib.c +++ b/contrib/libs/openssl/crypto/bio/bio_lib.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <errno.h> #include <openssl/crypto.h> -#include "bio_local.h" +#include "bio_local.h" #include "internal/cryptlib.h" diff --git a/contrib/libs/openssl/crypto/bio/bio_local.h b/contrib/libs/openssl/crypto/bio/bio_local.h index 6eb7966544..8b21221293 100644 --- a/contrib/libs/openssl/crypto/bio/bio_local.h +++ b/contrib/libs/openssl/crypto/bio/bio_local.h @@ -1,190 +1,190 @@ -/* - * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include "e_os.h" -#include "internal/sockets.h" -#include "internal/refcount.h" - -/* BEGIN BIO_ADDRINFO/BIO_ADDR stuff. */ - -#ifndef OPENSSL_NO_SOCK -/* - * Throughout this file and b_addr.c, the existence of the macro - * AI_PASSIVE is used to detect the availability of struct addrinfo, - * getnameinfo() and getaddrinfo(). If that macro doesn't exist, - * we use our own implementation instead. - */ - -/* - * It's imperative that these macros get defined before openssl/bio.h gets - * included. Otherwise, the AI_PASSIVE hack will not work properly. - * For clarity, we check for internal/cryptlib.h since it's a common header - * that also includes bio.h. - */ -# ifdef OSSL_INTERNAL_CRYPTLIB_H -# error internal/cryptlib.h included before bio_local.h -# endif -# ifdef HEADER_BIO_H -# error openssl/bio.h included before bio_local.h -# endif - -/* - * Undefine AF_UNIX on systems that define it but don't support it. - */ -# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_VMS) -# undef AF_UNIX -# endif - -# ifdef AI_PASSIVE - -/* - * There's a bug in VMS C header file netdb.h, where struct addrinfo - * always is the P32 variant, but the functions that handle that structure, - * such as getaddrinfo() and freeaddrinfo() adapt to the initial pointer - * size. The easiest workaround is to force struct addrinfo to be the - * 64-bit variant when compiling in P64 mode. - */ -# if defined(OPENSSL_SYS_VMS) && __INITIAL_POINTER_SIZE == 64 -# define addrinfo __addrinfo64 -# endif - -# define bio_addrinfo_st addrinfo -# define bai_family ai_family -# define bai_socktype ai_socktype -# define bai_protocol ai_protocol -# define bai_addrlen ai_addrlen -# define bai_addr ai_addr -# define bai_next ai_next -# else -struct bio_addrinfo_st { - int bai_family; - int bai_socktype; - int bai_protocol; - size_t bai_addrlen; - struct sockaddr *bai_addr; - struct bio_addrinfo_st *bai_next; -}; -# endif - -union bio_addr_st { - struct sockaddr sa; -# ifdef AF_INET6 - struct sockaddr_in6 s_in6; -# endif - struct sockaddr_in s_in; -# ifdef AF_UNIX - struct sockaddr_un s_un; -# endif -}; -#endif - -/* END BIO_ADDRINFO/BIO_ADDR stuff. */ - -#include "internal/cryptlib.h" -#include "internal/bio.h" - -typedef struct bio_f_buffer_ctx_struct { - /*- - * Buffers are setup like this: - * - * <---------------------- size -----------------------> - * +---------------------------------------------------+ - * | consumed | remaining | free space | - * +---------------------------------------------------+ - * <-- off --><------- len -------> - */ - /*- BIO *bio; *//* - * this is now in the BIO struct - */ - int ibuf_size; /* how big is the input buffer */ - int obuf_size; /* how big is the output buffer */ - char *ibuf; /* the char array */ - int ibuf_len; /* how many bytes are in it */ - int ibuf_off; /* write/read offset */ - char *obuf; /* the char array */ - int obuf_len; /* how many bytes are in it */ - int obuf_off; /* write/read offset */ -} BIO_F_BUFFER_CTX; - -struct bio_st { - const BIO_METHOD *method; - /* bio, mode, argp, argi, argl, ret */ - BIO_callback_fn callback; - BIO_callback_fn_ex callback_ex; - char *cb_arg; /* first argument for the callback */ - int init; - int shutdown; - int flags; /* extra storage */ - int retry_reason; - int num; - void *ptr; - struct bio_st *next_bio; /* used by filter BIOs */ - struct bio_st *prev_bio; /* used by filter BIOs */ - CRYPTO_REF_COUNT references; - uint64_t num_read; - uint64_t num_write; - CRYPTO_EX_DATA ex_data; - CRYPTO_RWLOCK *lock; -}; - -#ifndef OPENSSL_NO_SOCK -# ifdef OPENSSL_SYS_VMS -typedef unsigned int socklen_t; -# endif - -extern CRYPTO_RWLOCK *bio_lookup_lock; - -int BIO_ADDR_make(BIO_ADDR *ap, const struct sockaddr *sa); -const struct sockaddr *BIO_ADDR_sockaddr(const BIO_ADDR *ap); -struct sockaddr *BIO_ADDR_sockaddr_noconst(BIO_ADDR *ap); -socklen_t BIO_ADDR_sockaddr_size(const BIO_ADDR *ap); -socklen_t BIO_ADDRINFO_sockaddr_size(const BIO_ADDRINFO *bai); -const struct sockaddr *BIO_ADDRINFO_sockaddr(const BIO_ADDRINFO *bai); -#endif - -extern CRYPTO_RWLOCK *bio_type_lock; - -void bio_sock_cleanup_int(void); - -#if BIO_FLAGS_UPLINK==0 -/* Shortcut UPLINK calls on most platforms... */ -# define UP_stdin stdin -# define UP_stdout stdout -# define UP_stderr stderr -# define UP_fprintf fprintf -# define UP_fgets fgets -# define UP_fread fread -# define UP_fwrite fwrite -# undef UP_fsetmod -# define UP_feof feof -# define UP_fclose fclose - -# define UP_fopen fopen -# define UP_fseek fseek -# define UP_ftell ftell -# define UP_fflush fflush -# define UP_ferror ferror -# ifdef _WIN32 -# define UP_fileno _fileno -# define UP_open _open -# define UP_read _read -# define UP_write _write -# define UP_lseek _lseek -# define UP_close _close -# else -# define UP_fileno fileno -# define UP_open open -# define UP_read read -# define UP_write write -# define UP_lseek lseek -# define UP_close close -# endif - -#endif - +/* + * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "e_os.h" +#include "internal/sockets.h" +#include "internal/refcount.h" + +/* BEGIN BIO_ADDRINFO/BIO_ADDR stuff. */ + +#ifndef OPENSSL_NO_SOCK +/* + * Throughout this file and b_addr.c, the existence of the macro + * AI_PASSIVE is used to detect the availability of struct addrinfo, + * getnameinfo() and getaddrinfo(). If that macro doesn't exist, + * we use our own implementation instead. + */ + +/* + * It's imperative that these macros get defined before openssl/bio.h gets + * included. Otherwise, the AI_PASSIVE hack will not work properly. + * For clarity, we check for internal/cryptlib.h since it's a common header + * that also includes bio.h. + */ +# ifdef OSSL_INTERNAL_CRYPTLIB_H +# error internal/cryptlib.h included before bio_local.h +# endif +# ifdef HEADER_BIO_H +# error openssl/bio.h included before bio_local.h +# endif + +/* + * Undefine AF_UNIX on systems that define it but don't support it. + */ +# if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_VMS) +# undef AF_UNIX +# endif + +# ifdef AI_PASSIVE + +/* + * There's a bug in VMS C header file netdb.h, where struct addrinfo + * always is the P32 variant, but the functions that handle that structure, + * such as getaddrinfo() and freeaddrinfo() adapt to the initial pointer + * size. The easiest workaround is to force struct addrinfo to be the + * 64-bit variant when compiling in P64 mode. + */ +# if defined(OPENSSL_SYS_VMS) && __INITIAL_POINTER_SIZE == 64 +# define addrinfo __addrinfo64 +# endif + +# define bio_addrinfo_st addrinfo +# define bai_family ai_family +# define bai_socktype ai_socktype +# define bai_protocol ai_protocol +# define bai_addrlen ai_addrlen +# define bai_addr ai_addr +# define bai_next ai_next +# else +struct bio_addrinfo_st { + int bai_family; + int bai_socktype; + int bai_protocol; + size_t bai_addrlen; + struct sockaddr *bai_addr; + struct bio_addrinfo_st *bai_next; +}; +# endif + +union bio_addr_st { + struct sockaddr sa; +# ifdef AF_INET6 + struct sockaddr_in6 s_in6; +# endif + struct sockaddr_in s_in; +# ifdef AF_UNIX + struct sockaddr_un s_un; +# endif +}; +#endif + +/* END BIO_ADDRINFO/BIO_ADDR stuff. */ + +#include "internal/cryptlib.h" +#include "internal/bio.h" + +typedef struct bio_f_buffer_ctx_struct { + /*- + * Buffers are setup like this: + * + * <---------------------- size -----------------------> + * +---------------------------------------------------+ + * | consumed | remaining | free space | + * +---------------------------------------------------+ + * <-- off --><------- len -------> + */ + /*- BIO *bio; *//* + * this is now in the BIO struct + */ + int ibuf_size; /* how big is the input buffer */ + int obuf_size; /* how big is the output buffer */ + char *ibuf; /* the char array */ + int ibuf_len; /* how many bytes are in it */ + int ibuf_off; /* write/read offset */ + char *obuf; /* the char array */ + int obuf_len; /* how many bytes are in it */ + int obuf_off; /* write/read offset */ +} BIO_F_BUFFER_CTX; + +struct bio_st { + const BIO_METHOD *method; + /* bio, mode, argp, argi, argl, ret */ + BIO_callback_fn callback; + BIO_callback_fn_ex callback_ex; + char *cb_arg; /* first argument for the callback */ + int init; + int shutdown; + int flags; /* extra storage */ + int retry_reason; + int num; + void *ptr; + struct bio_st *next_bio; /* used by filter BIOs */ + struct bio_st *prev_bio; /* used by filter BIOs */ + CRYPTO_REF_COUNT references; + uint64_t num_read; + uint64_t num_write; + CRYPTO_EX_DATA ex_data; + CRYPTO_RWLOCK *lock; +}; + +#ifndef OPENSSL_NO_SOCK +# ifdef OPENSSL_SYS_VMS +typedef unsigned int socklen_t; +# endif + +extern CRYPTO_RWLOCK *bio_lookup_lock; + +int BIO_ADDR_make(BIO_ADDR *ap, const struct sockaddr *sa); +const struct sockaddr *BIO_ADDR_sockaddr(const BIO_ADDR *ap); +struct sockaddr *BIO_ADDR_sockaddr_noconst(BIO_ADDR *ap); +socklen_t BIO_ADDR_sockaddr_size(const BIO_ADDR *ap); +socklen_t BIO_ADDRINFO_sockaddr_size(const BIO_ADDRINFO *bai); +const struct sockaddr *BIO_ADDRINFO_sockaddr(const BIO_ADDRINFO *bai); +#endif + +extern CRYPTO_RWLOCK *bio_type_lock; + +void bio_sock_cleanup_int(void); + +#if BIO_FLAGS_UPLINK==0 +/* Shortcut UPLINK calls on most platforms... */ +# define UP_stdin stdin +# define UP_stdout stdout +# define UP_stderr stderr +# define UP_fprintf fprintf +# define UP_fgets fgets +# define UP_fread fread +# define UP_fwrite fwrite +# undef UP_fsetmod +# define UP_feof feof +# define UP_fclose fclose + +# define UP_fopen fopen +# define UP_fseek fseek +# define UP_ftell ftell +# define UP_fflush fflush +# define UP_ferror ferror +# ifdef _WIN32 +# define UP_fileno _fileno +# define UP_open _open +# define UP_read _read +# define UP_write _write +# define UP_lseek _lseek +# define UP_close _close +# else +# define UP_fileno fileno +# define UP_open open +# define UP_read read +# define UP_write write +# define UP_lseek lseek +# define UP_close close +# endif + +#endif + diff --git a/contrib/libs/openssl/crypto/bio/bio_meth.c b/contrib/libs/openssl/crypto/bio/bio_meth.c index 744be4c77e..da11646192 100644 --- a/contrib/libs/openssl/crypto/bio/bio_meth.c +++ b/contrib/libs/openssl/crypto/bio/bio_meth.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "bio_local.h" +#include "bio_local.h" #include "internal/thread_once.h" CRYPTO_RWLOCK *bio_type_lock = NULL; diff --git a/contrib/libs/openssl/crypto/bio/bss_acpt.c b/contrib/libs/openssl/crypto/bio/bss_acpt.c index c33ce27311..4461eae233 100644 --- a/contrib/libs/openssl/crypto/bio/bss_acpt.c +++ b/contrib/libs/openssl/crypto/bio/bss_acpt.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -9,7 +9,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #ifndef OPENSSL_NO_SOCK @@ -222,10 +222,10 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c) break; case ACPT_S_CREATE_SOCKET: - s = BIO_socket(BIO_ADDRINFO_family(c->addr_iter), - BIO_ADDRINFO_socktype(c->addr_iter), - BIO_ADDRINFO_protocol(c->addr_iter), 0); - if (s == (int)INVALID_SOCKET) { + s = BIO_socket(BIO_ADDRINFO_family(c->addr_iter), + BIO_ADDRINFO_socktype(c->addr_iter), + BIO_ADDRINFO_protocol(c->addr_iter), 0); + if (s == (int)INVALID_SOCKET) { SYSerr(SYS_F_SOCKET, get_last_socket_error()); ERR_add_error_data(4, "hostname=", c->param_addr, @@ -233,10 +233,10 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c) BIOerr(BIO_F_ACPT_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET); goto exit_loop; } - c->accept_sock = s; - b->num = s; + c->accept_sock = s; + b->num = s; c->state = ACPT_S_LISTEN; - s = -1; + s = -1; break; case ACPT_S_LISTEN: @@ -530,12 +530,12 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) break; case BIO_CTRL_DUP: break; - case BIO_CTRL_EOF: - if (b->next_bio == NULL) - ret = 0; - else - ret = BIO_ctrl(b->next_bio, cmd, num, ptr); - break; + case BIO_CTRL_EOF: + if (b->next_bio == NULL) + ret = 0; + else + ret = BIO_ctrl(b->next_bio, cmd, num, ptr); + break; default: ret = 0; break; diff --git a/contrib/libs/openssl/crypto/bio/bss_bio.c b/contrib/libs/openssl/crypto/bio/bss_bio.c index 3f9cae7282..c97349e432 100644 --- a/contrib/libs/openssl/crypto/bio/bss_bio.c +++ b/contrib/libs/openssl/crypto/bio/bss_bio.c @@ -21,7 +21,7 @@ #include <stdlib.h> #include <string.h> -#include "bio_local.h" +#include "bio_local.h" #include <openssl/err.h> #include <openssl/crypto.h> diff --git a/contrib/libs/openssl/crypto/bio/bss_conn.c b/contrib/libs/openssl/crypto/bio/bss_conn.c index 26ae2b0126..807a82b23b 100644 --- a/contrib/libs/openssl/crypto/bio/bss_conn.c +++ b/contrib/libs/openssl/crypto/bio/bss_conn.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -10,7 +10,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #ifndef OPENSSL_NO_SOCK @@ -54,7 +54,7 @@ void BIO_CONNECT_free(BIO_CONNECT *a); #define BIO_CONN_S_CONNECT 4 #define BIO_CONN_S_OK 5 #define BIO_CONN_S_BLOCKED_CONNECT 6 -#define BIO_CONN_S_CONNECT_ERROR 7 +#define BIO_CONN_S_CONNECT_ERROR 7 static const BIO_METHOD methods_connectp = { BIO_TYPE_CONNECT, @@ -175,8 +175,8 @@ static int conn_state(BIO *b, BIO_CONNECT *c) ERR_add_error_data(4, "hostname=", c->param_hostname, " service=", c->param_service); - c->state = BIO_CONN_S_CONNECT_ERROR; - break; + c->state = BIO_CONN_S_CONNECT_ERROR; + break; } goto exit_loop; } else { @@ -208,11 +208,11 @@ static int conn_state(BIO *b, BIO_CONNECT *c) c->state = BIO_CONN_S_OK; break; - case BIO_CONN_S_CONNECT_ERROR: - BIOerr(BIO_F_CONN_STATE, BIO_R_CONNECT_ERROR); - ret = 0; - goto exit_loop; - + case BIO_CONN_S_CONNECT_ERROR: + BIOerr(BIO_F_CONN_STATE, BIO_R_CONNECT_ERROR); + ret = 0; + goto exit_loop; + case BIO_CONN_S_OK: ret = 1; goto exit_loop; @@ -325,8 +325,8 @@ static int conn_read(BIO *b, char *out, int outl) if (ret <= 0) { if (BIO_sock_should_retry(ret)) BIO_set_retry_read(b); - else if (ret == 0) - b->flags |= BIO_FLAGS_IN_EOF; + else if (ret == 0) + b->flags |= BIO_FLAGS_IN_EOF; } } return ret; @@ -517,9 +517,9 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr) *fptr = data->info_callback; } break; - case BIO_CTRL_EOF: - ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; - break; + case BIO_CTRL_EOF: + ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; + break; default: ret = 0; break; diff --git a/contrib/libs/openssl/crypto/bio/bss_dgram.c b/contrib/libs/openssl/crypto/bio/bss_dgram.c index 9fe70142bf..942fd8b514 100644 --- a/contrib/libs/openssl/crypto/bio/bss_dgram.c +++ b/contrib/libs/openssl/crypto/bio/bss_dgram.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #ifndef OPENSSL_NO_DGRAM # ifndef OPENSSL_NO_SCTP diff --git a/contrib/libs/openssl/crypto/bio/bss_fd.c b/contrib/libs/openssl/crypto/bio/bss_fd.c index 3e1973b303..ccbe1626ba 100644 --- a/contrib/libs/openssl/crypto/bio/bss_fd.c +++ b/contrib/libs/openssl/crypto/bio/bss_fd.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -10,7 +10,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #if defined(OPENSSL_NO_POSIX_IO) /* @@ -123,8 +123,8 @@ static int fd_read(BIO *b, char *out, int outl) if (ret <= 0) { if (BIO_fd_should_retry(ret)) BIO_set_retry_read(b); - else if (ret == 0) - b->flags |= BIO_FLAGS_IN_EOF; + else if (ret == 0) + b->flags |= BIO_FLAGS_IN_EOF; } } return ret; @@ -188,9 +188,9 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_CTRL_FLUSH: ret = 1; break; - case BIO_CTRL_EOF: - ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; - break; + case BIO_CTRL_EOF: + ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; + break; default: ret = 0; break; diff --git a/contrib/libs/openssl/crypto/bio/bss_file.c b/contrib/libs/openssl/crypto/bio/bss_file.c index 121fbce44e..1a70ce7994 100644 --- a/contrib/libs/openssl/crypto/bio/bss_file.c +++ b/contrib/libs/openssl/crypto/bio/bss_file.c @@ -27,7 +27,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #include <openssl/err.h> #if !defined(OPENSSL_NO_STDIO) diff --git a/contrib/libs/openssl/crypto/bio/bss_log.c b/contrib/libs/openssl/crypto/bio/bss_log.c index 015d5391a4..b9579faaa2 100644 --- a/contrib/libs/openssl/crypto/bio/bss_log.c +++ b/contrib/libs/openssl/crypto/bio/bss_log.c @@ -19,7 +19,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #include "internal/cryptlib.h" #if defined(OPENSSL_SYS_WINCE) diff --git a/contrib/libs/openssl/crypto/bio/bss_mem.c b/contrib/libs/openssl/crypto/bio/bss_mem.c index 5003c9980d..7cb4a57813 100644 --- a/contrib/libs/openssl/crypto/bio/bss_mem.c +++ b/contrib/libs/openssl/crypto/bio/bss_mem.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #include "internal/cryptlib.h" static int mem_write(BIO *h, const char *buf, int num); diff --git a/contrib/libs/openssl/crypto/bio/bss_null.c b/contrib/libs/openssl/crypto/bio/bss_null.c index 0b11056f17..e73ce7841d 100644 --- a/contrib/libs/openssl/crypto/bio/bss_null.c +++ b/contrib/libs/openssl/crypto/bio/bss_null.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #include "internal/cryptlib.h" static int null_write(BIO *h, const char *buf, int num); diff --git a/contrib/libs/openssl/crypto/bio/bss_sock.c b/contrib/libs/openssl/crypto/bio/bss_sock.c index aeadb52c70..6251f3d46a 100644 --- a/contrib/libs/openssl/crypto/bio/bss_sock.c +++ b/contrib/libs/openssl/crypto/bio/bss_sock.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -9,7 +9,7 @@ #include <stdio.h> #include <errno.h> -#include "bio_local.h" +#include "bio_local.h" #include "internal/cryptlib.h" #ifndef OPENSSL_NO_SOCK @@ -101,8 +101,8 @@ static int sock_read(BIO *b, char *out, int outl) if (ret <= 0) { if (BIO_sock_should_retry(ret)) BIO_set_retry_read(b); - else if (ret == 0) - b->flags |= BIO_FLAGS_IN_EOF; + else if (ret == 0) + b->flags |= BIO_FLAGS_IN_EOF; } } return ret; @@ -153,9 +153,9 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_CTRL_FLUSH: ret = 1; break; - case BIO_CTRL_EOF: - ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; - break; + case BIO_CTRL_EOF: + ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; + break; default: ret = 0; break; diff --git a/contrib/libs/openssl/crypto/blake2/blake2_local.h b/contrib/libs/openssl/crypto/blake2/blake2_local.h index a738de3431..926bae944c 100644 --- a/contrib/libs/openssl/crypto/blake2/blake2_local.h +++ b/contrib/libs/openssl/crypto/blake2/blake2_local.h @@ -1,90 +1,90 @@ -/* - * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * Derived from the BLAKE2 reference implementation written by Samuel Neves. - * Copyright 2012, Samuel Neves <sneves@dei.uc.pt> - * More information about the BLAKE2 hash function and its implementations - * can be found at https://blake2.net. - */ - -#include <stddef.h> - -#define BLAKE2S_BLOCKBYTES 64 -#define BLAKE2S_OUTBYTES 32 -#define BLAKE2S_KEYBYTES 32 -#define BLAKE2S_SALTBYTES 8 -#define BLAKE2S_PERSONALBYTES 8 - -#define BLAKE2B_BLOCKBYTES 128 -#define BLAKE2B_OUTBYTES 64 -#define BLAKE2B_KEYBYTES 64 -#define BLAKE2B_SALTBYTES 16 -#define BLAKE2B_PERSONALBYTES 16 - -struct blake2s_param_st { - uint8_t digest_length; /* 1 */ - uint8_t key_length; /* 2 */ - uint8_t fanout; /* 3 */ - uint8_t depth; /* 4 */ - uint8_t leaf_length[4];/* 8 */ - uint8_t node_offset[6];/* 14 */ - uint8_t node_depth; /* 15 */ - uint8_t inner_length; /* 16 */ - uint8_t salt[BLAKE2S_SALTBYTES]; /* 24 */ - uint8_t personal[BLAKE2S_PERSONALBYTES]; /* 32 */ -}; - -typedef struct blake2s_param_st BLAKE2S_PARAM; - -struct blake2s_ctx_st { - uint32_t h[8]; - uint32_t t[2]; - uint32_t f[2]; - uint8_t buf[BLAKE2S_BLOCKBYTES]; - size_t buflen; -}; - -struct blake2b_param_st { - uint8_t digest_length; /* 1 */ - uint8_t key_length; /* 2 */ - uint8_t fanout; /* 3 */ - uint8_t depth; /* 4 */ - uint8_t leaf_length[4];/* 8 */ - uint8_t node_offset[8];/* 16 */ - uint8_t node_depth; /* 17 */ - uint8_t inner_length; /* 18 */ - uint8_t reserved[14]; /* 32 */ - uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */ - uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */ -}; - -typedef struct blake2b_param_st BLAKE2B_PARAM; - -struct blake2b_ctx_st { - uint64_t h[8]; - uint64_t t[2]; - uint64_t f[2]; - uint8_t buf[BLAKE2B_BLOCKBYTES]; - size_t buflen; -}; - -#define BLAKE2B_DIGEST_LENGTH 64 -#define BLAKE2S_DIGEST_LENGTH 32 - -typedef struct blake2s_ctx_st BLAKE2S_CTX; -typedef struct blake2b_ctx_st BLAKE2B_CTX; - -int BLAKE2b_Init(BLAKE2B_CTX *c); -int BLAKE2b_Update(BLAKE2B_CTX *c, const void *data, size_t datalen); -int BLAKE2b_Final(unsigned char *md, BLAKE2B_CTX *c); - -int BLAKE2s_Init(BLAKE2S_CTX *c); -int BLAKE2s_Update(BLAKE2S_CTX *c, const void *data, size_t datalen); -int BLAKE2s_Final(unsigned char *md, BLAKE2S_CTX *c); +/* + * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * Derived from the BLAKE2 reference implementation written by Samuel Neves. + * Copyright 2012, Samuel Neves <sneves@dei.uc.pt> + * More information about the BLAKE2 hash function and its implementations + * can be found at https://blake2.net. + */ + +#include <stddef.h> + +#define BLAKE2S_BLOCKBYTES 64 +#define BLAKE2S_OUTBYTES 32 +#define BLAKE2S_KEYBYTES 32 +#define BLAKE2S_SALTBYTES 8 +#define BLAKE2S_PERSONALBYTES 8 + +#define BLAKE2B_BLOCKBYTES 128 +#define BLAKE2B_OUTBYTES 64 +#define BLAKE2B_KEYBYTES 64 +#define BLAKE2B_SALTBYTES 16 +#define BLAKE2B_PERSONALBYTES 16 + +struct blake2s_param_st { + uint8_t digest_length; /* 1 */ + uint8_t key_length; /* 2 */ + uint8_t fanout; /* 3 */ + uint8_t depth; /* 4 */ + uint8_t leaf_length[4];/* 8 */ + uint8_t node_offset[6];/* 14 */ + uint8_t node_depth; /* 15 */ + uint8_t inner_length; /* 16 */ + uint8_t salt[BLAKE2S_SALTBYTES]; /* 24 */ + uint8_t personal[BLAKE2S_PERSONALBYTES]; /* 32 */ +}; + +typedef struct blake2s_param_st BLAKE2S_PARAM; + +struct blake2s_ctx_st { + uint32_t h[8]; + uint32_t t[2]; + uint32_t f[2]; + uint8_t buf[BLAKE2S_BLOCKBYTES]; + size_t buflen; +}; + +struct blake2b_param_st { + uint8_t digest_length; /* 1 */ + uint8_t key_length; /* 2 */ + uint8_t fanout; /* 3 */ + uint8_t depth; /* 4 */ + uint8_t leaf_length[4];/* 8 */ + uint8_t node_offset[8];/* 16 */ + uint8_t node_depth; /* 17 */ + uint8_t inner_length; /* 18 */ + uint8_t reserved[14]; /* 32 */ + uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */ + uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */ +}; + +typedef struct blake2b_param_st BLAKE2B_PARAM; + +struct blake2b_ctx_st { + uint64_t h[8]; + uint64_t t[2]; + uint64_t f[2]; + uint8_t buf[BLAKE2B_BLOCKBYTES]; + size_t buflen; +}; + +#define BLAKE2B_DIGEST_LENGTH 64 +#define BLAKE2S_DIGEST_LENGTH 32 + +typedef struct blake2s_ctx_st BLAKE2S_CTX; +typedef struct blake2b_ctx_st BLAKE2B_CTX; + +int BLAKE2b_Init(BLAKE2B_CTX *c); +int BLAKE2b_Update(BLAKE2B_CTX *c, const void *data, size_t datalen); +int BLAKE2b_Final(unsigned char *md, BLAKE2B_CTX *c); + +int BLAKE2s_Init(BLAKE2S_CTX *c); +int BLAKE2s_Update(BLAKE2S_CTX *c, const void *data, size_t datalen); +int BLAKE2s_Final(unsigned char *md, BLAKE2S_CTX *c); diff --git a/contrib/libs/openssl/crypto/blake2/blake2b.c b/contrib/libs/openssl/crypto/blake2/blake2b.c index b080ddc18e..fc6e5f1a3f 100644 --- a/contrib/libs/openssl/crypto/blake2/blake2b.c +++ b/contrib/libs/openssl/crypto/blake2/blake2b.c @@ -18,7 +18,7 @@ #include <string.h> #include <openssl/crypto.h> -#include "blake2_local.h" +#include "blake2_local.h" #include "blake2_impl.h" static const uint64_t blake2b_IV[8] = diff --git a/contrib/libs/openssl/crypto/blake2/blake2s.c b/contrib/libs/openssl/crypto/blake2/blake2s.c index b52dd80e58..d072e05ca3 100644 --- a/contrib/libs/openssl/crypto/blake2/blake2s.c +++ b/contrib/libs/openssl/crypto/blake2/blake2s.c @@ -18,7 +18,7 @@ #include <string.h> #include <openssl/crypto.h> -#include "blake2_local.h" +#include "blake2_local.h" #include "blake2_impl.h" static const uint32_t blake2s_IV[8] = diff --git a/contrib/libs/openssl/crypto/blake2/m_blake2b.c b/contrib/libs/openssl/crypto/blake2/m_blake2b.c index a1280f190a..ce4d8f9565 100644 --- a/contrib/libs/openssl/crypto/blake2/m_blake2b.c +++ b/contrib/libs/openssl/crypto/blake2/m_blake2b.c @@ -20,8 +20,8 @@ # include <openssl/evp.h> # include <openssl/objects.h> -# include "blake2_local.h" -# include "crypto/evp.h" +# include "blake2_local.h" +# include "crypto/evp.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/blake2/m_blake2s.c b/contrib/libs/openssl/crypto/blake2/m_blake2s.c index e225cae50c..b8fb048b30 100644 --- a/contrib/libs/openssl/crypto/blake2/m_blake2s.c +++ b/contrib/libs/openssl/crypto/blake2/m_blake2s.c @@ -20,8 +20,8 @@ # include <openssl/evp.h> # include <openssl/objects.h> -# include "blake2_local.h" -# include "crypto/evp.h" +# include "blake2_local.h" +# include "crypto/evp.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/bn/asm/x86_64-gcc.c b/contrib/libs/openssl/crypto/bn/asm/x86_64-gcc.c index f58b7276aa..e6fdaadf0e 100644 --- a/contrib/libs/openssl/crypto/bn/asm/x86_64-gcc.c +++ b/contrib/libs/openssl/crypto/bn/asm/x86_64-gcc.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "../bn_local.h" +#include "../bn_local.h" #if !(defined(__GNUC__) && __GNUC__>=2) # include "../bn_asm.c" /* kind of dirty hack for Sun Studio */ #else diff --git a/contrib/libs/openssl/crypto/bn/bn_add.c b/contrib/libs/openssl/crypto/bn/bn_add.c index a7316dee68..8ffe49618a 100644 --- a/contrib/libs/openssl/crypto/bn/bn_add.c +++ b/contrib/libs/openssl/crypto/bn/bn_add.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" /* signed add of b to a. */ int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) diff --git a/contrib/libs/openssl/crypto/bn/bn_asm.c b/contrib/libs/openssl/crypto/bn/bn_asm.c index 0cf20c597d..4d83a8cf11 100644 --- a/contrib/libs/openssl/crypto/bn/bn_asm.c +++ b/contrib/libs/openssl/crypto/bn/bn_asm.c @@ -10,7 +10,7 @@ #include <assert.h> #include <openssl/crypto.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" #if defined(BN_LLONG) || defined(BN_UMULT_HIGH) diff --git a/contrib/libs/openssl/crypto/bn/bn_blind.c b/contrib/libs/openssl/crypto/bn/bn_blind.c index 4fa510dadb..76fc7ebcff 100644 --- a/contrib/libs/openssl/crypto/bn/bn_blind.c +++ b/contrib/libs/openssl/crypto/bn/bn_blind.c @@ -9,7 +9,7 @@ #include <openssl/opensslconf.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" #define BN_BLINDING_COUNTER 32 diff --git a/contrib/libs/openssl/crypto/bn/bn_ctx.c b/contrib/libs/openssl/crypto/bn/bn_ctx.c index 8ccc9ccf14..042cb247d3 100644 --- a/contrib/libs/openssl/crypto/bn/bn_ctx.c +++ b/contrib/libs/openssl/crypto/bn/bn_ctx.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" /*- * TODO list diff --git a/contrib/libs/openssl/crypto/bn/bn_depr.c b/contrib/libs/openssl/crypto/bn/bn_depr.c index 361de165d4..b60269cd57 100644 --- a/contrib/libs/openssl/crypto/bn/bn_depr.c +++ b/contrib/libs/openssl/crypto/bn/bn_depr.c @@ -20,7 +20,7 @@ NON_EMPTY_TRANSLATION_UNIT # include <stdio.h> # include <time.h> # include "internal/cryptlib.h" -# include "bn_local.h" +# include "bn_local.h" BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add, const BIGNUM *rem, diff --git a/contrib/libs/openssl/crypto/bn/bn_dh.c b/contrib/libs/openssl/crypto/bn/bn_dh.c index 3cdcd78133..58c44f0b17 100644 --- a/contrib/libs/openssl/crypto/bn/bn_dh.c +++ b/contrib/libs/openssl/crypto/bn/bn_dh.c @@ -7,12 +7,12 @@ * https://www.openssl.org/source/license.html */ -#include "bn_local.h" +#include "bn_local.h" #include "internal/nelem.h" #ifndef OPENSSL_NO_DH #include <openssl/dh.h> -#include "crypto/bn_dh.h" +#include "crypto/bn_dh.h" /* DH parameters from RFC5114 */ # if BN_BITS2 == 64 diff --git a/contrib/libs/openssl/crypto/bn/bn_div.c b/contrib/libs/openssl/crypto/bn/bn_div.c index 03cbb416fd..0da9f39b31 100644 --- a/contrib/libs/openssl/crypto/bn/bn_div.c +++ b/contrib/libs/openssl/crypto/bn/bn_div.c @@ -10,7 +10,7 @@ #include <assert.h> #include <openssl/bn.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" /* The old slow way */ #if 0 diff --git a/contrib/libs/openssl/crypto/bn/bn_exp.c b/contrib/libs/openssl/crypto/bn/bn_exp.c index ea10cb3e13..9531acfc3c 100644 --- a/contrib/libs/openssl/crypto/bn/bn_exp.c +++ b/contrib/libs/openssl/crypto/bn/bn_exp.c @@ -8,8 +8,8 @@ */ #include "internal/cryptlib.h" -#include "internal/constant_time.h" -#include "bn_local.h" +#include "internal/constant_time.h" +#include "bn_local.h" #include <stdlib.h> #ifdef _WIN32 diff --git a/contrib/libs/openssl/crypto/bn/bn_exp2.c b/contrib/libs/openssl/crypto/bn/bn_exp2.c index 5c179e684b..e542abe46f 100644 --- a/contrib/libs/openssl/crypto/bn/bn_exp2.c +++ b/contrib/libs/openssl/crypto/bn/bn_exp2.c @@ -9,7 +9,7 @@ #include <stdio.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" #define TABLE_SIZE 32 diff --git a/contrib/libs/openssl/crypto/bn/bn_gcd.c b/contrib/libs/openssl/crypto/bn/bn_gcd.c index d0b2c376d2..0941f7b97f 100644 --- a/contrib/libs/openssl/crypto/bn/bn_gcd.c +++ b/contrib/libs/openssl/crypto/bn/bn_gcd.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" /* * bn_mod_inverse_no_branch is a special version of BN_mod_inverse. It does @@ -531,115 +531,115 @@ BIGNUM *BN_mod_inverse(BIGNUM *in, BN_CTX_free(new_ctx); return rv; } - -/*- - * This function is based on the constant-time GCD work by Bernstein and Yang: - * https://eprint.iacr.org/2019/266 - * Generalized fast GCD function to allow even inputs. - * The algorithm first finds the shared powers of 2 between - * the inputs, and removes them, reducing at least one of the - * inputs to an odd value. Then it proceeds to calculate the GCD. - * Before returning the resulting GCD, we take care of adding - * back the powers of two removed at the beginning. - * Note 1: we assume the bit length of both inputs is public information, - * since access to top potentially leaks this information. - */ -int BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) -{ - BIGNUM *g, *temp = NULL; - BN_ULONG mask = 0; - int i, j, top, rlen, glen, m, bit = 1, delta = 1, cond = 0, shifts = 0, ret = 0; - - /* Note 2: zero input corner cases are not constant-time since they are - * handled immediately. An attacker can run an attack under this - * assumption without the need of side-channel information. */ - if (BN_is_zero(in_b)) { - ret = BN_copy(r, in_a) != NULL; - r->neg = 0; - return ret; - } - if (BN_is_zero(in_a)) { - ret = BN_copy(r, in_b) != NULL; - r->neg = 0; - return ret; - } - - bn_check_top(in_a); - bn_check_top(in_b); - - BN_CTX_start(ctx); - temp = BN_CTX_get(ctx); - g = BN_CTX_get(ctx); - - /* make r != 0, g != 0 even, so BN_rshift is not a potential nop */ - if (g == NULL - || !BN_lshift1(g, in_b) - || !BN_lshift1(r, in_a)) - goto err; - - /* find shared powers of two, i.e. "shifts" >= 1 */ - for (i = 0; i < r->dmax && i < g->dmax; i++) { - mask = ~(r->d[i] | g->d[i]); - for (j = 0; j < BN_BITS2; j++) { - bit &= mask; - shifts += bit; - mask >>= 1; - } - } - - /* subtract shared powers of two; shifts >= 1 */ - if (!BN_rshift(r, r, shifts) - || !BN_rshift(g, g, shifts)) - goto err; - - /* expand to biggest nword, with room for a possible extra word */ - top = 1 + ((r->top >= g->top) ? r->top : g->top); - if (bn_wexpand(r, top) == NULL - || bn_wexpand(g, top) == NULL - || bn_wexpand(temp, top) == NULL) - goto err; - - /* re arrange inputs s.t. r is odd */ - BN_consttime_swap((~r->d[0]) & 1, r, g, top); - - /* compute the number of iterations */ - rlen = BN_num_bits(r); - glen = BN_num_bits(g); - m = 4 + 3 * ((rlen >= glen) ? rlen : glen); - - for (i = 0; i < m; i++) { - /* conditionally flip signs if delta is positive and g is odd */ - cond = (-delta >> (8 * sizeof(delta) - 1)) & g->d[0] & 1 - /* make sure g->top > 0 (i.e. if top == 0 then g == 0 always) */ - & (~((g->top - 1) >> (sizeof(g->top) * 8 - 1))); - delta = (-cond & -delta) | ((cond - 1) & delta); - r->neg ^= cond; - /* swap */ - BN_consttime_swap(cond, r, g, top); - - /* elimination step */ - delta++; - if (!BN_add(temp, g, r)) - goto err; - BN_consttime_swap(g->d[0] & 1 /* g is odd */ - /* make sure g->top > 0 (i.e. if top == 0 then g == 0 always) */ - & (~((g->top - 1) >> (sizeof(g->top) * 8 - 1))), - g, temp, top); - if (!BN_rshift1(g, g)) - goto err; - } - - /* remove possible negative sign */ - r->neg = 0; - /* add powers of 2 removed, then correct the artificial shift */ - if (!BN_lshift(r, r, shifts) - || !BN_rshift1(r, r)) - goto err; - - ret = 1; - - err: - BN_CTX_end(ctx); - bn_check_top(r); - return ret; -} + +/*- + * This function is based on the constant-time GCD work by Bernstein and Yang: + * https://eprint.iacr.org/2019/266 + * Generalized fast GCD function to allow even inputs. + * The algorithm first finds the shared powers of 2 between + * the inputs, and removes them, reducing at least one of the + * inputs to an odd value. Then it proceeds to calculate the GCD. + * Before returning the resulting GCD, we take care of adding + * back the powers of two removed at the beginning. + * Note 1: we assume the bit length of both inputs is public information, + * since access to top potentially leaks this information. + */ +int BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) +{ + BIGNUM *g, *temp = NULL; + BN_ULONG mask = 0; + int i, j, top, rlen, glen, m, bit = 1, delta = 1, cond = 0, shifts = 0, ret = 0; + + /* Note 2: zero input corner cases are not constant-time since they are + * handled immediately. An attacker can run an attack under this + * assumption without the need of side-channel information. */ + if (BN_is_zero(in_b)) { + ret = BN_copy(r, in_a) != NULL; + r->neg = 0; + return ret; + } + if (BN_is_zero(in_a)) { + ret = BN_copy(r, in_b) != NULL; + r->neg = 0; + return ret; + } + + bn_check_top(in_a); + bn_check_top(in_b); + + BN_CTX_start(ctx); + temp = BN_CTX_get(ctx); + g = BN_CTX_get(ctx); + + /* make r != 0, g != 0 even, so BN_rshift is not a potential nop */ + if (g == NULL + || !BN_lshift1(g, in_b) + || !BN_lshift1(r, in_a)) + goto err; + + /* find shared powers of two, i.e. "shifts" >= 1 */ + for (i = 0; i < r->dmax && i < g->dmax; i++) { + mask = ~(r->d[i] | g->d[i]); + for (j = 0; j < BN_BITS2; j++) { + bit &= mask; + shifts += bit; + mask >>= 1; + } + } + + /* subtract shared powers of two; shifts >= 1 */ + if (!BN_rshift(r, r, shifts) + || !BN_rshift(g, g, shifts)) + goto err; + + /* expand to biggest nword, with room for a possible extra word */ + top = 1 + ((r->top >= g->top) ? r->top : g->top); + if (bn_wexpand(r, top) == NULL + || bn_wexpand(g, top) == NULL + || bn_wexpand(temp, top) == NULL) + goto err; + + /* re arrange inputs s.t. r is odd */ + BN_consttime_swap((~r->d[0]) & 1, r, g, top); + + /* compute the number of iterations */ + rlen = BN_num_bits(r); + glen = BN_num_bits(g); + m = 4 + 3 * ((rlen >= glen) ? rlen : glen); + + for (i = 0; i < m; i++) { + /* conditionally flip signs if delta is positive and g is odd */ + cond = (-delta >> (8 * sizeof(delta) - 1)) & g->d[0] & 1 + /* make sure g->top > 0 (i.e. if top == 0 then g == 0 always) */ + & (~((g->top - 1) >> (sizeof(g->top) * 8 - 1))); + delta = (-cond & -delta) | ((cond - 1) & delta); + r->neg ^= cond; + /* swap */ + BN_consttime_swap(cond, r, g, top); + + /* elimination step */ + delta++; + if (!BN_add(temp, g, r)) + goto err; + BN_consttime_swap(g->d[0] & 1 /* g is odd */ + /* make sure g->top > 0 (i.e. if top == 0 then g == 0 always) */ + & (~((g->top - 1) >> (sizeof(g->top) * 8 - 1))), + g, temp, top); + if (!BN_rshift1(g, g)) + goto err; + } + + /* remove possible negative sign */ + r->neg = 0; + /* add powers of 2 removed, then correct the artificial shift */ + if (!BN_lshift(r, r, shifts) + || !BN_rshift1(r, r)) + goto err; + + ret = 1; + + err: + BN_CTX_end(ctx); + bn_check_top(r); + return ret; +} diff --git a/contrib/libs/openssl/crypto/bn/bn_gf2m.c b/contrib/libs/openssl/crypto/bn/bn_gf2m.c index 3d725c66f3..a2ea867551 100644 --- a/contrib/libs/openssl/crypto/bn/bn_gf2m.c +++ b/contrib/libs/openssl/crypto/bn/bn_gf2m.c @@ -12,7 +12,7 @@ #include <limits.h> #include <stdio.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" #ifndef OPENSSL_NO_EC2M diff --git a/contrib/libs/openssl/crypto/bn/bn_intern.c b/contrib/libs/openssl/crypto/bn/bn_intern.c index 58101fc20f..147b4fa022 100644 --- a/contrib/libs/openssl/crypto/bn/bn_intern.c +++ b/contrib/libs/openssl/crypto/bn/bn_intern.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" /* * Determine the modified width-(w+1) Non-Adjacent Form (wNAF) of 'scalar'. diff --git a/contrib/libs/openssl/crypto/bn/bn_kron.c b/contrib/libs/openssl/crypto/bn/bn_kron.c index dcd0bc72ff..c1e09d2721 100644 --- a/contrib/libs/openssl/crypto/bn/bn_kron.c +++ b/contrib/libs/openssl/crypto/bn/bn_kron.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" /* least significant word */ #define BN_lsw(n) (((n)->top == 0) ? (BN_ULONG) 0 : (n)->d[0]) diff --git a/contrib/libs/openssl/crypto/bn/bn_lib.c b/contrib/libs/openssl/crypto/bn/bn_lib.c index d66eb1ba2c..eb4a31849b 100644 --- a/contrib/libs/openssl/crypto/bn/bn_lib.c +++ b/contrib/libs/openssl/crypto/bn/bn_lib.c @@ -10,9 +10,9 @@ #include <assert.h> #include <limits.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" #include <openssl/opensslconf.h> -#include "internal/constant_time.h" +#include "internal/constant_time.h" /* This stuff appears to be completely unused, so is deprecated */ #if OPENSSL_API_COMPAT < 0x00908000L diff --git a/contrib/libs/openssl/crypto/bn/bn_local.h b/contrib/libs/openssl/crypto/bn/bn_local.h index adf52da2e0..8ad69ccd36 100644 --- a/contrib/libs/openssl/crypto/bn/bn_local.h +++ b/contrib/libs/openssl/crypto/bn/bn_local.h @@ -1,668 +1,668 @@ -/* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_BN_LOCAL_H -# define OSSL_CRYPTO_BN_LOCAL_H - -/* - * The EDK2 build doesn't use bn_conf.h; it sets THIRTY_TWO_BIT or - * SIXTY_FOUR_BIT in its own environment since it doesn't re-run our - * Configure script and needs to support both 32-bit and 64-bit. - */ -# include <openssl/opensslconf.h> - -# if !defined(OPENSSL_SYS_UEFI) -# include "crypto/bn_conf.h" -# endif - -# include "crypto/bn.h" - -/* - * 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 -# define BN_RECURSION -# endif - -/* - * This next option uses the C libraries (2 word)/(1 word) function. If it is - * not defined, I use my C version (which is slower). The reason for this - * flag is that when the particular C compiler library routine is used, and - * the library is linked with a different compiler, the library is missing. - * This mostly happens when the library is built with gcc and then linked - * using normal cc. This would be a common occurrence because gcc normally - * produces code that is 2 times faster than system compilers for the big - * number stuff. For machines with only one compiler (or shared libraries), - * this should be on. Again this in only really a problem on machines using - * "long long's", are 32bit, and are not using my assembler code. - */ -# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ - defined(OPENSSL_SYS_WIN32) || defined(linux) -# define BN_DIV2W -# endif - -/* - * 64-bit processor with LP64 ABI - */ -# ifdef SIXTY_FOUR_BIT_LONG -# define BN_ULLONG unsigned long long -# define BN_BITS4 32 -# define BN_MASK2 (0xffffffffffffffffL) -# define BN_MASK2l (0xffffffffL) -# define BN_MASK2h (0xffffffff00000000L) -# define BN_MASK2h1 (0xffffffff80000000L) -# define BN_DEC_CONV (10000000000000000000UL) -# define BN_DEC_NUM 19 -# define BN_DEC_FMT1 "%lu" -# define BN_DEC_FMT2 "%019lu" -# endif - -/* - * 64-bit processor other than LP64 ABI - */ -# ifdef SIXTY_FOUR_BIT -# undef BN_LLONG -# undef BN_ULLONG -# define BN_BITS4 32 -# define BN_MASK2 (0xffffffffffffffffLL) -# define BN_MASK2l (0xffffffffL) -# define BN_MASK2h (0xffffffff00000000LL) -# define BN_MASK2h1 (0xffffffff80000000LL) -# define BN_DEC_CONV (10000000000000000000ULL) -# define BN_DEC_NUM 19 -# define BN_DEC_FMT1 "%llu" -# define BN_DEC_FMT2 "%019llu" -# endif - -# ifdef THIRTY_TWO_BIT -# ifdef BN_LLONG -# if defined(_WIN32) && !defined(__GNUC__) -# define BN_ULLONG unsigned __int64 -# else -# define BN_ULLONG unsigned long long -# endif -# endif -# define BN_BITS4 16 -# define BN_MASK2 (0xffffffffL) -# define BN_MASK2l (0xffff) -# define BN_MASK2h1 (0xffff8000L) -# define BN_MASK2h (0xffff0000L) -# define BN_DEC_CONV (1000000000L) -# define BN_DEC_NUM 9 -# define BN_DEC_FMT1 "%u" -# define BN_DEC_FMT2 "%09u" -# endif - - -/*- - * 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 -/* - * The new BN_FLG_FIXED_TOP flag marks vectors that were not treated with - * bn_correct_top, in other words such vectors are permitted to have zeros - * in most significant limbs. Such vectors are used internally to achieve - * execution time invariance for critical operations with private keys. - * It's BN_DEBUG-only flag, because user application is not supposed to - * observe it anyway. Moreover, optimizing compiler would actually remove - * all operations manipulating the bit in question in non-BN_DEBUG build. - */ -# define BN_FLG_FIXED_TOP 0x10000 -# 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(_not_const)); \ - RAND_bytes(&_tmp_char, 1); /* Debug only - safe to ignore error return */\ - memset(_not_const + _bnum1->top, _tmp_char, \ - sizeof(*_not_const) * (_bnum1->dmax - _bnum1->top)); \ - } \ - } while(0) -# else -# define bn_pollute(a) -# endif -# define bn_check_top(a) \ - do { \ - const BIGNUM *_bnum2 = (a); \ - if (_bnum2 != NULL) { \ - int _top = _bnum2->top; \ - (void)ossl_assert((_top == 0 && !_bnum2->neg) || \ - (_top && ((_bnum2->flags & BN_FLG_FIXED_TOP) \ - || _bnum2->d[_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); \ - /* avoid unused variable warning with NDEBUG */ \ - (void)(_bnum2); \ - } while(0) - -# else /* !BN_DEBUG */ - -# define BN_FLG_FIXED_TOP 0 -# 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) - -# endif - -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); - -struct bignum_st { - BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit - * chunks. */ - int top; /* Index of last used d +1. */ - /* The next are internal book keeping for bn_expand. */ - int dmax; /* Size of the d array. */ - int neg; /* one if the number is negative */ - 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, - possibly zero-padded */ - 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 flags; -}; - -/* - * Used for reciprocal division/mod functions It cannot be shared between - * threads - */ -struct bn_recp_ctx_st { - BIGNUM N; /* the divisor */ - BIGNUM Nr; /* the reciprocal */ - int num_bits; - int shift; - int flags; -}; - -/* Used for slow "generation" functions. */ -struct bn_gencb_st { - unsigned int ver; /* To handle binary (in)compatibility */ - void *arg; /* callback-specific data */ - union { - /* if (ver==1) - handles old style callbacks */ - void (*cb_1) (int, int, void *); - /* if (ver==2) - new callback style */ - int (*cb_2) (int, int, BN_GENCB *); - } cb; -}; - -/*- - * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions - * - * - * For window size 'w' (w >= 2) and a random 'b' bits exponent, - * the number of multiplications is a constant plus on average - * - * 2^(w-1) + (b-w)/(w+1); - * - * here 2^(w-1) is for precomputing the table (we actually need - * entries only for windows that have the lowest bit set), and - * (b-w)/(w+1) is an approximation for the expected number of - * w-bit windows, not counting the first one. - * - * Thus we should use - * - * w >= 6 if b > 671 - * w = 5 if 671 > b > 239 - * w = 4 if 239 > b > 79 - * w = 3 if 79 > b > 23 - * w <= 2 if 23 > b - * - * (with draws in between). Very small exponents are often selected - * with low Hamming weight, so we use w = 1 for b <= 23. - */ -# define BN_window_bits_for_exponent_size(b) \ - ((b) > 671 ? 6 : \ - (b) > 239 ? 5 : \ - (b) > 79 ? 4 : \ - (b) > 23 ? 3 : 1) - -/* - * BN_mod_exp_mont_consttime is based on the assumption that the L1 data cache - * line width of the target processor is at least the following value. - */ -# define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH ( 64 ) -# define MOD_EXP_CTIME_MIN_CACHE_LINE_MASK (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - 1) - -/* - * Window sizes optimized for fixed window size modular exponentiation - * algorithm (BN_mod_exp_mont_consttime). To achieve the security goals of - * BN_mode_exp_mont_consttime, the maximum size of the window must not exceed - * log_2(MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH). Window size thresholds are - * defined for cache line sizes of 32 and 64, cache line sizes where - * log_2(32)=5 and log_2(64)=6 respectively. A window size of 7 should only be - * used on processors that have a 128 byte or greater cache line size. - */ -# if MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 64 - -# define BN_window_bits_for_ctime_exponent_size(b) \ - ((b) > 937 ? 6 : \ - (b) > 306 ? 5 : \ - (b) > 89 ? 4 : \ - (b) > 22 ? 3 : 1) -# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (6) - -# elif MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 32 - -# define BN_window_bits_for_ctime_exponent_size(b) \ - ((b) > 306 ? 5 : \ - (b) > 89 ? 4 : \ - (b) > 22 ? 3 : 1) -# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (5) - -# endif - -/* Pentium pro 16,16,16,32,64 */ -/* Alpha 16,16,16,16.64 */ -# define BN_MULL_SIZE_NORMAL (16)/* 32 */ -# define BN_MUL_RECURSIVE_SIZE_NORMAL (16)/* 32 less than */ -# define BN_SQR_RECURSIVE_SIZE_NORMAL (16)/* 32 */ -# define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32)/* 32 */ -# define BN_MONT_CTX_SET_SIZE_WORD (64)/* 32 */ - -/* - * 2011-02-22 SMS. In various places, a size_t variable or a type cast to - * size_t was used to perform integer-only operations on pointers. This - * failed on VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t - * is still only 32 bits. What's needed in these cases is an integer type - * with the same size as a pointer, which size_t is not certain to be. The - * only fix here is VMS-specific. - */ -# if defined(OPENSSL_SYS_VMS) -# if __INITIAL_POINTER_SIZE == 64 -# define PTR_SIZE_INT long long -# else /* __INITIAL_POINTER_SIZE == 64 */ -# define PTR_SIZE_INT int -# endif /* __INITIAL_POINTER_SIZE == 64 [else] */ -# elif !defined(PTR_SIZE_INT) /* defined(OPENSSL_SYS_VMS) */ -# define PTR_SIZE_INT size_t -# endif /* defined(OPENSSL_SYS_VMS) [else] */ - -# if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) -/* - * BN_UMULT_HIGH section. - * 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 (e.g., - * PowerPC, Alpha, and IA-64) 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:-) Note that more recent compilers do - * support 2*64 integer type, which is also used here. - */ -# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 && \ - (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)) -# 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; }) -# elif defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT)) -# if defined(__DECC) -# include <c_asm.h> -# define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b)) -# elif defined(__GNUC__) && __GNUC__>=2 -# define BN_UMULT_HIGH(a,b) ({ \ - register BN_ULONG ret; \ - asm ("umulh %1,%2,%0" \ - : "=r"(ret) \ - : "r"(a), "r"(b)); \ - ret; }) -# endif /* compiler */ -# elif defined(_ARCH_PPC64) && defined(SIXTY_FOUR_BIT_LONG) -# if defined(__GNUC__) && __GNUC__>=2 -# define BN_UMULT_HIGH(a,b) ({ \ - register 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(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT)) -# if defined(__GNUC__) && __GNUC__>=2 -# define BN_UMULT_HIGH(a,b) ({ \ - register 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(_M_AMD64) || defined(_M_X64)) && defined(SIXTY_FOUR_BIT) -# if defined(_MSC_VER) && _MSC_VER>=1400 -unsigned __int64 __umulh(unsigned __int64 a, unsigned __int64 b); -unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b, - unsigned __int64 *h); -# pragma intrinsic(__umulh,_umul128) -# define BN_UMULT_HIGH(a,b) __umulh((a),(b)) -# define BN_UMULT_LOHI(low,high,a,b) ((low)=_umul128((a),(b),&(high))) -# endif -# elif defined(__mips) && (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)) -# if defined(__GNUC__) && __GNUC__>=2 -# define BN_UMULT_HIGH(a,b) ({ \ - register 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 -# elif defined(__aarch64__) && defined(SIXTY_FOUR_BIT_LONG) -# if defined(__GNUC__) && __GNUC__>=2 -# define BN_UMULT_HIGH(a,b) ({ \ - register BN_ULONG ret; \ - asm ("umulh %0,%1,%2" \ - : "=r"(ret) \ - : "r"(a), "r"(b)); \ - ret; }) -# endif -# endif /* cpu */ -# endif /* OPENSSL_NO_ASM */ - -# 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 -/******************************************************************* - * Using the long long type, has to be twice as wide as BN_ULONG... - */ -# define Lw(t) (((BN_ULONG)(t))&BN_MASK2) -# define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2) - -# 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<low)?1:0; \ - (r) = ret; \ - } - -# define mul(r,a,w,c) { \ - BN_ULONG high,low,ret,ta=(a); \ - BN_UMULT_LOHI(low,high,w,ta); \ - ret = low + (c); \ - (c) = high; \ - (c) += (ret<low)?1:0; \ - (r) = ret; \ - } - -# define sqr(r0,r1,a) { \ - BN_ULONG tmp=(a); \ - BN_UMULT_LOHI(r0,r1,tmp,tmp); \ - } - -# elif defined(BN_UMULT_HIGH) -# define mul_add(r,a,w,c) { \ - BN_ULONG high,low,ret,tmp=(a); \ - ret = (r); \ - high= BN_UMULT_HIGH(w,tmp); \ - ret += (c); \ - low = (w) * tmp; \ - (c) = (ret<(c))?1:0; \ - (c) += high; \ - ret += low; \ - (c) += (ret<low)?1:0; \ - (r) = ret; \ - } - -# define mul(r,a,w,c) { \ - BN_ULONG high,low,ret,ta=(a); \ - low = (w) * ta; \ - high= BN_UMULT_HIGH(w,ta); \ - ret = low + (c); \ - (c) = high; \ - (c) += (ret<low)?1:0; \ - (r) = ret; \ - } - -# define sqr(r0,r1,a) { \ - BN_ULONG tmp=(a); \ - (r0) = tmp * tmp; \ - (r1) = BN_UMULT_HIGH(tmp,tmp); \ - } - -# else -/************************************************************* - * No long long type - */ - -# define LBITS(a) ((a)&BN_MASK2l) -# define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l) -# define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2) - -# define LLBITS(a) ((a)&BN_MASKl) -# define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl) -# define LL2HBITS(a) ((BN_ULLONG)((a)&BN_MASKl)<<BN_BITS2) - -# define mul64(l,h,bl,bh) \ - { \ - BN_ULONG m,m1,lt,ht; \ - \ - lt=l; \ - ht=h; \ - m =(bh)*(lt); \ - lt=(bl)*(lt); \ - m1=(bl)*(ht); \ - ht =(bh)*(ht); \ - m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \ - ht+=HBITS(m); \ - m1=L2HBITS(m); \ - lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \ - (l)=lt; \ - (h)=ht; \ - } - -# define sqr64(lo,ho,in) \ - { \ - BN_ULONG l,h,m; \ - \ - h=(in); \ - l=LBITS(h); \ - h=HBITS(h); \ - m =(l)*(h); \ - l*=l; \ - h*=h; \ - h+=(m&BN_MASK2h1)>>(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 */ - -void BN_RECP_CTX_init(BN_RECP_CTX *recp); -void BN_MONT_CTX_init(BN_MONT_CTX *ctx); - -void bn_init(BIGNUM *a); -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_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); -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); -void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, - int dna, int dnb, BN_ULONG *t); -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); -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); - -BIGNUM *int_bn_mod_inverse(BIGNUM *in, - const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx, - int *noinv); - -static ossl_inline 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); -} - -#endif +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_BN_LOCAL_H +# define OSSL_CRYPTO_BN_LOCAL_H + +/* + * The EDK2 build doesn't use bn_conf.h; it sets THIRTY_TWO_BIT or + * SIXTY_FOUR_BIT in its own environment since it doesn't re-run our + * Configure script and needs to support both 32-bit and 64-bit. + */ +# include <openssl/opensslconf.h> + +# if !defined(OPENSSL_SYS_UEFI) +# include "crypto/bn_conf.h" +# endif + +# include "crypto/bn.h" + +/* + * 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 +# define BN_RECURSION +# endif + +/* + * This next option uses the C libraries (2 word)/(1 word) function. If it is + * not defined, I use my C version (which is slower). The reason for this + * flag is that when the particular C compiler library routine is used, and + * the library is linked with a different compiler, the library is missing. + * This mostly happens when the library is built with gcc and then linked + * using normal cc. This would be a common occurrence because gcc normally + * produces code that is 2 times faster than system compilers for the big + * number stuff. For machines with only one compiler (or shared libraries), + * this should be on. Again this in only really a problem on machines using + * "long long's", are 32bit, and are not using my assembler code. + */ +# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ + defined(OPENSSL_SYS_WIN32) || defined(linux) +# define BN_DIV2W +# endif + +/* + * 64-bit processor with LP64 ABI + */ +# ifdef SIXTY_FOUR_BIT_LONG +# define BN_ULLONG unsigned long long +# define BN_BITS4 32 +# define BN_MASK2 (0xffffffffffffffffL) +# define BN_MASK2l (0xffffffffL) +# define BN_MASK2h (0xffffffff00000000L) +# define BN_MASK2h1 (0xffffffff80000000L) +# define BN_DEC_CONV (10000000000000000000UL) +# define BN_DEC_NUM 19 +# define BN_DEC_FMT1 "%lu" +# define BN_DEC_FMT2 "%019lu" +# endif + +/* + * 64-bit processor other than LP64 ABI + */ +# ifdef SIXTY_FOUR_BIT +# undef BN_LLONG +# undef BN_ULLONG +# define BN_BITS4 32 +# define BN_MASK2 (0xffffffffffffffffLL) +# define BN_MASK2l (0xffffffffL) +# define BN_MASK2h (0xffffffff00000000LL) +# define BN_MASK2h1 (0xffffffff80000000LL) +# define BN_DEC_CONV (10000000000000000000ULL) +# define BN_DEC_NUM 19 +# define BN_DEC_FMT1 "%llu" +# define BN_DEC_FMT2 "%019llu" +# endif + +# ifdef THIRTY_TWO_BIT +# ifdef BN_LLONG +# if defined(_WIN32) && !defined(__GNUC__) +# define BN_ULLONG unsigned __int64 +# else +# define BN_ULLONG unsigned long long +# endif +# endif +# define BN_BITS4 16 +# define BN_MASK2 (0xffffffffL) +# define BN_MASK2l (0xffff) +# define BN_MASK2h1 (0xffff8000L) +# define BN_MASK2h (0xffff0000L) +# define BN_DEC_CONV (1000000000L) +# define BN_DEC_NUM 9 +# define BN_DEC_FMT1 "%u" +# define BN_DEC_FMT2 "%09u" +# endif + + +/*- + * 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 +/* + * The new BN_FLG_FIXED_TOP flag marks vectors that were not treated with + * bn_correct_top, in other words such vectors are permitted to have zeros + * in most significant limbs. Such vectors are used internally to achieve + * execution time invariance for critical operations with private keys. + * It's BN_DEBUG-only flag, because user application is not supposed to + * observe it anyway. Moreover, optimizing compiler would actually remove + * all operations manipulating the bit in question in non-BN_DEBUG build. + */ +# define BN_FLG_FIXED_TOP 0x10000 +# 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(_not_const)); \ + RAND_bytes(&_tmp_char, 1); /* Debug only - safe to ignore error return */\ + memset(_not_const + _bnum1->top, _tmp_char, \ + sizeof(*_not_const) * (_bnum1->dmax - _bnum1->top)); \ + } \ + } while(0) +# else +# define bn_pollute(a) +# endif +# define bn_check_top(a) \ + do { \ + const BIGNUM *_bnum2 = (a); \ + if (_bnum2 != NULL) { \ + int _top = _bnum2->top; \ + (void)ossl_assert((_top == 0 && !_bnum2->neg) || \ + (_top && ((_bnum2->flags & BN_FLG_FIXED_TOP) \ + || _bnum2->d[_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); \ + /* avoid unused variable warning with NDEBUG */ \ + (void)(_bnum2); \ + } while(0) + +# else /* !BN_DEBUG */ + +# define BN_FLG_FIXED_TOP 0 +# 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) + +# endif + +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); + +struct bignum_st { + BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit + * chunks. */ + int top; /* Index of last used d +1. */ + /* The next are internal book keeping for bn_expand. */ + int dmax; /* Size of the d array. */ + int neg; /* one if the number is negative */ + 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, + possibly zero-padded */ + 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 flags; +}; + +/* + * Used for reciprocal division/mod functions It cannot be shared between + * threads + */ +struct bn_recp_ctx_st { + BIGNUM N; /* the divisor */ + BIGNUM Nr; /* the reciprocal */ + int num_bits; + int shift; + int flags; +}; + +/* Used for slow "generation" functions. */ +struct bn_gencb_st { + unsigned int ver; /* To handle binary (in)compatibility */ + void *arg; /* callback-specific data */ + union { + /* if (ver==1) - handles old style callbacks */ + void (*cb_1) (int, int, void *); + /* if (ver==2) - new callback style */ + int (*cb_2) (int, int, BN_GENCB *); + } cb; +}; + +/*- + * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions + * + * + * For window size 'w' (w >= 2) and a random 'b' bits exponent, + * the number of multiplications is a constant plus on average + * + * 2^(w-1) + (b-w)/(w+1); + * + * here 2^(w-1) is for precomputing the table (we actually need + * entries only for windows that have the lowest bit set), and + * (b-w)/(w+1) is an approximation for the expected number of + * w-bit windows, not counting the first one. + * + * Thus we should use + * + * w >= 6 if b > 671 + * w = 5 if 671 > b > 239 + * w = 4 if 239 > b > 79 + * w = 3 if 79 > b > 23 + * w <= 2 if 23 > b + * + * (with draws in between). Very small exponents are often selected + * with low Hamming weight, so we use w = 1 for b <= 23. + */ +# define BN_window_bits_for_exponent_size(b) \ + ((b) > 671 ? 6 : \ + (b) > 239 ? 5 : \ + (b) > 79 ? 4 : \ + (b) > 23 ? 3 : 1) + +/* + * BN_mod_exp_mont_consttime is based on the assumption that the L1 data cache + * line width of the target processor is at least the following value. + */ +# define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH ( 64 ) +# define MOD_EXP_CTIME_MIN_CACHE_LINE_MASK (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - 1) + +/* + * Window sizes optimized for fixed window size modular exponentiation + * algorithm (BN_mod_exp_mont_consttime). To achieve the security goals of + * BN_mode_exp_mont_consttime, the maximum size of the window must not exceed + * log_2(MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH). Window size thresholds are + * defined for cache line sizes of 32 and 64, cache line sizes where + * log_2(32)=5 and log_2(64)=6 respectively. A window size of 7 should only be + * used on processors that have a 128 byte or greater cache line size. + */ +# if MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 64 + +# define BN_window_bits_for_ctime_exponent_size(b) \ + ((b) > 937 ? 6 : \ + (b) > 306 ? 5 : \ + (b) > 89 ? 4 : \ + (b) > 22 ? 3 : 1) +# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (6) + +# elif MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 32 + +# define BN_window_bits_for_ctime_exponent_size(b) \ + ((b) > 306 ? 5 : \ + (b) > 89 ? 4 : \ + (b) > 22 ? 3 : 1) +# define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (5) + +# endif + +/* Pentium pro 16,16,16,32,64 */ +/* Alpha 16,16,16,16.64 */ +# define BN_MULL_SIZE_NORMAL (16)/* 32 */ +# define BN_MUL_RECURSIVE_SIZE_NORMAL (16)/* 32 less than */ +# define BN_SQR_RECURSIVE_SIZE_NORMAL (16)/* 32 */ +# define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32)/* 32 */ +# define BN_MONT_CTX_SET_SIZE_WORD (64)/* 32 */ + +/* + * 2011-02-22 SMS. In various places, a size_t variable or a type cast to + * size_t was used to perform integer-only operations on pointers. This + * failed on VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t + * is still only 32 bits. What's needed in these cases is an integer type + * with the same size as a pointer, which size_t is not certain to be. The + * only fix here is VMS-specific. + */ +# if defined(OPENSSL_SYS_VMS) +# if __INITIAL_POINTER_SIZE == 64 +# define PTR_SIZE_INT long long +# else /* __INITIAL_POINTER_SIZE == 64 */ +# define PTR_SIZE_INT int +# endif /* __INITIAL_POINTER_SIZE == 64 [else] */ +# elif !defined(PTR_SIZE_INT) /* defined(OPENSSL_SYS_VMS) */ +# define PTR_SIZE_INT size_t +# endif /* defined(OPENSSL_SYS_VMS) [else] */ + +# if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) +/* + * BN_UMULT_HIGH section. + * 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 (e.g., + * PowerPC, Alpha, and IA-64) 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:-) Note that more recent compilers do + * support 2*64 integer type, which is also used here. + */ +# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 && \ + (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)) +# 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; }) +# elif defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT)) +# if defined(__DECC) +# include <c_asm.h> +# define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b)) +# elif defined(__GNUC__) && __GNUC__>=2 +# define BN_UMULT_HIGH(a,b) ({ \ + register BN_ULONG ret; \ + asm ("umulh %1,%2,%0" \ + : "=r"(ret) \ + : "r"(a), "r"(b)); \ + ret; }) +# endif /* compiler */ +# elif defined(_ARCH_PPC64) && defined(SIXTY_FOUR_BIT_LONG) +# if defined(__GNUC__) && __GNUC__>=2 +# define BN_UMULT_HIGH(a,b) ({ \ + register 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(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT)) +# if defined(__GNUC__) && __GNUC__>=2 +# define BN_UMULT_HIGH(a,b) ({ \ + register 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(_M_AMD64) || defined(_M_X64)) && defined(SIXTY_FOUR_BIT) +# if defined(_MSC_VER) && _MSC_VER>=1400 +unsigned __int64 __umulh(unsigned __int64 a, unsigned __int64 b); +unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b, + unsigned __int64 *h); +# pragma intrinsic(__umulh,_umul128) +# define BN_UMULT_HIGH(a,b) __umulh((a),(b)) +# define BN_UMULT_LOHI(low,high,a,b) ((low)=_umul128((a),(b),&(high))) +# endif +# elif defined(__mips) && (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG)) +# if defined(__GNUC__) && __GNUC__>=2 +# define BN_UMULT_HIGH(a,b) ({ \ + register 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 +# elif defined(__aarch64__) && defined(SIXTY_FOUR_BIT_LONG) +# if defined(__GNUC__) && __GNUC__>=2 +# define BN_UMULT_HIGH(a,b) ({ \ + register BN_ULONG ret; \ + asm ("umulh %0,%1,%2" \ + : "=r"(ret) \ + : "r"(a), "r"(b)); \ + ret; }) +# endif +# endif /* cpu */ +# endif /* OPENSSL_NO_ASM */ + +# 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 +/******************************************************************* + * Using the long long type, has to be twice as wide as BN_ULONG... + */ +# define Lw(t) (((BN_ULONG)(t))&BN_MASK2) +# define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2) + +# 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<low)?1:0; \ + (r) = ret; \ + } + +# define mul(r,a,w,c) { \ + BN_ULONG high,low,ret,ta=(a); \ + BN_UMULT_LOHI(low,high,w,ta); \ + ret = low + (c); \ + (c) = high; \ + (c) += (ret<low)?1:0; \ + (r) = ret; \ + } + +# define sqr(r0,r1,a) { \ + BN_ULONG tmp=(a); \ + BN_UMULT_LOHI(r0,r1,tmp,tmp); \ + } + +# elif defined(BN_UMULT_HIGH) +# define mul_add(r,a,w,c) { \ + BN_ULONG high,low,ret,tmp=(a); \ + ret = (r); \ + high= BN_UMULT_HIGH(w,tmp); \ + ret += (c); \ + low = (w) * tmp; \ + (c) = (ret<(c))?1:0; \ + (c) += high; \ + ret += low; \ + (c) += (ret<low)?1:0; \ + (r) = ret; \ + } + +# define mul(r,a,w,c) { \ + BN_ULONG high,low,ret,ta=(a); \ + low = (w) * ta; \ + high= BN_UMULT_HIGH(w,ta); \ + ret = low + (c); \ + (c) = high; \ + (c) += (ret<low)?1:0; \ + (r) = ret; \ + } + +# define sqr(r0,r1,a) { \ + BN_ULONG tmp=(a); \ + (r0) = tmp * tmp; \ + (r1) = BN_UMULT_HIGH(tmp,tmp); \ + } + +# else +/************************************************************* + * No long long type + */ + +# define LBITS(a) ((a)&BN_MASK2l) +# define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l) +# define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2) + +# define LLBITS(a) ((a)&BN_MASKl) +# define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl) +# define LL2HBITS(a) ((BN_ULLONG)((a)&BN_MASKl)<<BN_BITS2) + +# define mul64(l,h,bl,bh) \ + { \ + BN_ULONG m,m1,lt,ht; \ + \ + lt=l; \ + ht=h; \ + m =(bh)*(lt); \ + lt=(bl)*(lt); \ + m1=(bl)*(ht); \ + ht =(bh)*(ht); \ + m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \ + ht+=HBITS(m); \ + m1=L2HBITS(m); \ + lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \ + (l)=lt; \ + (h)=ht; \ + } + +# define sqr64(lo,ho,in) \ + { \ + BN_ULONG l,h,m; \ + \ + h=(in); \ + l=LBITS(h); \ + h=HBITS(h); \ + m =(l)*(h); \ + l*=l; \ + h*=h; \ + h+=(m&BN_MASK2h1)>>(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 */ + +void BN_RECP_CTX_init(BN_RECP_CTX *recp); +void BN_MONT_CTX_init(BN_MONT_CTX *ctx); + +void bn_init(BIGNUM *a); +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_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); +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); +void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, + int dna, int dnb, BN_ULONG *t); +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); +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); + +BIGNUM *int_bn_mod_inverse(BIGNUM *in, + const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx, + int *noinv); + +static ossl_inline 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); +} + +#endif diff --git a/contrib/libs/openssl/crypto/bn/bn_mod.c b/contrib/libs/openssl/crypto/bn/bn_mod.c index d7677fdbfd..f7d2e2650e 100644 --- a/contrib/libs/openssl/crypto/bn/bn_mod.c +++ b/contrib/libs/openssl/crypto/bn/bn_mod.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/bn/bn_mont.c b/contrib/libs/openssl/crypto/bn/bn_mont.c index 107deb4b86..1e5045a010 100644 --- a/contrib/libs/openssl/crypto/bn/bn_mont.c +++ b/contrib/libs/openssl/crypto/bn/bn_mont.c @@ -15,7 +15,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" #define MONT_WORD /* use the faster word-based algorithm */ diff --git a/contrib/libs/openssl/crypto/bn/bn_mpi.c b/contrib/libs/openssl/crypto/bn/bn_mpi.c index 14d9688d42..0902da5d07 100644 --- a/contrib/libs/openssl/crypto/bn/bn_mpi.c +++ b/contrib/libs/openssl/crypto/bn/bn_mpi.c @@ -9,7 +9,7 @@ #include <stdio.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" int BN_bn2mpi(const BIGNUM *a, unsigned char *d) { diff --git a/contrib/libs/openssl/crypto/bn/bn_mul.c b/contrib/libs/openssl/crypto/bn/bn_mul.c index 28e84b5a70..6743e7be81 100644 --- a/contrib/libs/openssl/crypto/bn/bn_mul.c +++ b/contrib/libs/openssl/crypto/bn/bn_mul.c @@ -9,7 +9,7 @@ #include <assert.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" #if defined(OPENSSL_NO_ASM) || !defined(OPENSSL_BN_ASM_PART_WORDS) /* diff --git a/contrib/libs/openssl/crypto/bn/bn_nist.c b/contrib/libs/openssl/crypto/bn/bn_nist.c index b831d28fc0..325dc22849 100644 --- a/contrib/libs/openssl/crypto/bn/bn_nist.c +++ b/contrib/libs/openssl/crypto/bn/bn_nist.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "bn_local.h" +#include "bn_local.h" #include "internal/cryptlib.h" #define BN_NIST_192_TOP (192+BN_BITS2-1)/BN_BITS2 diff --git a/contrib/libs/openssl/crypto/bn/bn_prime.c b/contrib/libs/openssl/crypto/bn/bn_prime.c index 0a78bed9b7..d0cf3779fa 100644 --- a/contrib/libs/openssl/crypto/bn/bn_prime.c +++ b/contrib/libs/openssl/crypto/bn/bn_prime.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -10,7 +10,7 @@ #include <stdio.h> #include <time.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" /* * The quick sieve algorithm approach to weeding out primes is Philip @@ -22,13 +22,13 @@ 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, int safe, prime_t *mods); -static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods, - const BIGNUM *add, const BIGNUM *rem, - BN_CTX *ctx); +static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods); +static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods, + const BIGNUM *add, const BIGNUM *rem, + BN_CTX *ctx); + +#define square(x) ((BN_ULONG)(x) * (BN_ULONG)(x)) -#define square(x) ((BN_ULONG)(x) * (BN_ULONG)(x)) - int BN_GENCB_call(BN_GENCB *cb, int a, int b) { /* No callback means continue */ @@ -89,11 +89,11 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, loop: /* make a random number and set the top and bottom bits */ if (add == NULL) { - if (!probable_prime(ret, bits, safe, mods)) + if (!probable_prime(ret, bits, safe, mods)) goto err; } else { - if (!probable_prime_dh(ret, bits, safe, mods, add, rem, ctx)) - goto err; + if (!probable_prime_dh(ret, bits, safe, mods, add, rem, ctx)) + goto err; } if (!BN_GENCB_call(cb, 0, c1++)) @@ -269,7 +269,7 @@ static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1, return 1; } -static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods) +static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods) { int i; BN_ULONG delta; @@ -279,8 +279,8 @@ static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods) /* TODO: Not all primes are private */ if (!BN_priv_rand(rnd, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ODD)) return 0; - if (safe && !BN_set_bit(rnd, 1)) - return 0; + if (safe && !BN_set_bit(rnd, 1)) + return 0; /* we now have a random number 'rnd' to test. */ for (i = 1; i < NUMPRIMES; i++) { BN_ULONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]); @@ -290,23 +290,23 @@ static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods) } delta = 0; loop: - for (i = 1; i < NUMPRIMES; i++) { - /* - * check that rnd is a prime and also that - * gcd(rnd-1,primes) == 1 (except for 2) - * do the second check only if we are interested in safe primes - * in the case that the candidate prime is a single word then - * we check only the primes up to sqrt(rnd) + for (i = 1; i < NUMPRIMES; i++) { + /* + * check that rnd is a prime and also that + * gcd(rnd-1,primes) == 1 (except for 2) + * do the second check only if we are interested in safe primes + * in the case that the candidate prime is a single word then + * we check only the primes up to sqrt(rnd) */ - if (bits <= 31 && delta <= 0x7fffffff - && square(primes[i]) > BN_get_word(rnd) + delta) - break; - if (safe ? (mods[i] + delta) % primes[i] <= 1 - : (mods[i] + delta) % primes[i] == 0) { - delta += safe ? 4 : 2; - if (delta > maxdelta) - goto again; - goto loop; + if (bits <= 31 && delta <= 0x7fffffff + && square(primes[i]) > BN_get_word(rnd) + delta) + break; + if (safe ? (mods[i] + delta) % primes[i] <= 1 + : (mods[i] + delta) % primes[i] == 0) { + delta += safe ? 4 : 2; + if (delta > maxdelta) + goto again; + goto loop; } } if (!BN_add_word(rnd, delta)) @@ -317,23 +317,23 @@ static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods) return 1; } -static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods, - const BIGNUM *add, const BIGNUM *rem, - BN_CTX *ctx) +static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods, + const BIGNUM *add, const BIGNUM *rem, + BN_CTX *ctx) { int i, ret = 0; BIGNUM *t1; - BN_ULONG delta; - BN_ULONG maxdelta = BN_MASK2 - primes[NUMPRIMES - 1]; + BN_ULONG delta; + BN_ULONG maxdelta = BN_MASK2 - primes[NUMPRIMES - 1]; BN_CTX_start(ctx); if ((t1 = BN_CTX_get(ctx)) == NULL) goto err; - if (maxdelta > BN_MASK2 - BN_get_word(add)) - maxdelta = BN_MASK2 - BN_get_word(add); - - again: + if (maxdelta > BN_MASK2 - BN_get_word(add)) + maxdelta = BN_MASK2 - BN_get_word(add); + + again: if (!BN_rand(rnd, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD)) goto err; @@ -344,48 +344,48 @@ static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods, if (!BN_sub(rnd, rnd, t1)) goto err; if (rem == NULL) { - if (!BN_add_word(rnd, safe ? 3u : 1u)) + if (!BN_add_word(rnd, safe ? 3u : 1u)) goto err; } else { if (!BN_add(rnd, rnd, rem)) goto err; } - if (BN_num_bits(rnd) < bits - || BN_get_word(rnd) < (safe ? 5u : 3u)) { - if (!BN_add(rnd, rnd, add)) - goto err; - } + if (BN_num_bits(rnd) < bits + || BN_get_word(rnd) < (safe ? 5u : 3u)) { + if (!BN_add(rnd, rnd, add)) + goto err; + } - /* we now have a random number 'rnd' to test. */ + /* we now have a random number 'rnd' to test. */ for (i = 1; i < NUMPRIMES; i++) { BN_ULONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]); if (mod == (BN_ULONG)-1) goto err; - mods[i] = (prime_t) mod; + mods[i] = (prime_t) mod; } - delta = 0; + delta = 0; loop: for (i = 1; i < NUMPRIMES; i++) { - /* check that rnd is a prime */ - if (bits <= 31 && delta <= 0x7fffffff - && square(primes[i]) > BN_get_word(rnd) + delta) - break; - /* rnd mod p == 1 implies q = (rnd-1)/2 is divisible by p */ - if (safe ? (mods[i] + delta) % primes[i] <= 1 - : (mods[i] + delta) % primes[i] == 0) { - delta += BN_get_word(add); - if (delta > maxdelta) - goto again; + /* check that rnd is a prime */ + if (bits <= 31 && delta <= 0x7fffffff + && square(primes[i]) > BN_get_word(rnd) + delta) + break; + /* rnd mod p == 1 implies q = (rnd-1)/2 is divisible by p */ + if (safe ? (mods[i] + delta) % primes[i] <= 1 + : (mods[i] + delta) % primes[i] == 0) { + delta += BN_get_word(add); + if (delta > maxdelta) + goto again; goto loop; } } - if (!BN_add_word(rnd, delta)) - goto err; + if (!BN_add_word(rnd, delta)) + goto err; ret = 1; err: BN_CTX_end(ctx); - bn_check_top(rnd); + bn_check_top(rnd); return ret; } diff --git a/contrib/libs/openssl/crypto/bn/bn_print.c b/contrib/libs/openssl/crypto/bn/bn_print.c index 1ec2def823..69749a9fa7 100644 --- a/contrib/libs/openssl/crypto/bn/bn_print.c +++ b/contrib/libs/openssl/crypto/bn/bn_print.c @@ -8,11 +8,11 @@ */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include <limits.h> #include "internal/cryptlib.h" #include <openssl/buffer.h> -#include "bn_local.h" +#include "bn_local.h" static const char Hex[] = "0123456789ABCDEF"; diff --git a/contrib/libs/openssl/crypto/bn/bn_rand.c b/contrib/libs/openssl/crypto/bn/bn_rand.c index f7e9ba8d50..6b4b50a068 100644 --- a/contrib/libs/openssl/crypto/bn/bn_rand.c +++ b/contrib/libs/openssl/crypto/bn/bn_rand.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <time.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" #include <openssl/rand.h> #include <openssl/sha.h> diff --git a/contrib/libs/openssl/crypto/bn/bn_recp.c b/contrib/libs/openssl/crypto/bn/bn_recp.c index f0529fbfa8..e822313341 100644 --- a/contrib/libs/openssl/crypto/bn/bn_recp.c +++ b/contrib/libs/openssl/crypto/bn/bn_recp.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" void BN_RECP_CTX_init(BN_RECP_CTX *recp) { diff --git a/contrib/libs/openssl/crypto/bn/bn_shift.c b/contrib/libs/openssl/crypto/bn/bn_shift.c index d475574bf9..210a83f586 100644 --- a/contrib/libs/openssl/crypto/bn/bn_shift.c +++ b/contrib/libs/openssl/crypto/bn/bn_shift.c @@ -9,7 +9,7 @@ #include <assert.h> #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" int BN_lshift1(BIGNUM *r, const BIGNUM *a) { @@ -34,10 +34,10 @@ int BN_lshift1(BIGNUM *r, const BIGNUM *a) for (i = 0; i < a->top; i++) { t = *(ap++); *(rp++) = ((t << 1) | c) & BN_MASK2; - c = t >> (BN_BITS2 - 1); + c = t >> (BN_BITS2 - 1); } - *rp = c; - r->top += c; + *rp = c; + r->top += c; bn_check_top(r); return 1; } @@ -45,7 +45,7 @@ int BN_lshift1(BIGNUM *r, const BIGNUM *a) int BN_rshift1(BIGNUM *r, const BIGNUM *a) { BN_ULONG *ap, *rp, t, c; - int i; + int i; bn_check_top(r); bn_check_top(a); @@ -57,20 +57,20 @@ int BN_rshift1(BIGNUM *r, const BIGNUM *a) i = a->top; ap = a->d; if (a != r) { - if (bn_wexpand(r, i) == NULL) + if (bn_wexpand(r, i) == NULL) return 0; r->neg = a->neg; } rp = r->d; - r->top = i; + r->top = i; t = ap[--i]; - rp[i] = t >> 1; - c = t << (BN_BITS2 - 1); - r->top -= (t == 1); + rp[i] = t >> 1; + c = t << (BN_BITS2 - 1); + r->top -= (t == 1); while (i > 0) { t = ap[--i]; rp[i] = ((t >> 1) & BN_MASK2) | c; - c = t << (BN_BITS2 - 1); + c = t << (BN_BITS2 - 1); } if (!r->top) r->neg = 0; /* don't allow negative zero */ @@ -149,19 +149,19 @@ int bn_lshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n) int BN_rshift(BIGNUM *r, const BIGNUM *a, int n) { - int ret = 0; + int ret = 0; if (n < 0) { BNerr(BN_F_BN_RSHIFT, BN_R_INVALID_SHIFT); return 0; } - ret = bn_rshift_fixed_top(r, a, n); + ret = bn_rshift_fixed_top(r, a, n); - bn_correct_top(r); - bn_check_top(r); + bn_correct_top(r); + bn_check_top(r); - return ret; + return ret; } /* diff --git a/contrib/libs/openssl/crypto/bn/bn_sqr.c b/contrib/libs/openssl/crypto/bn/bn_sqr.c index fbe301ebc8..7f3a179177 100644 --- a/contrib/libs/openssl/crypto/bn/bn_sqr.c +++ b/contrib/libs/openssl/crypto/bn/bn_sqr.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" /* r must not be a */ /* diff --git a/contrib/libs/openssl/crypto/bn/bn_sqrt.c b/contrib/libs/openssl/crypto/bn/bn_sqrt.c index 8cb93ff4ed..1723d5ded5 100644 --- a/contrib/libs/openssl/crypto/bn/bn_sqrt.c +++ b/contrib/libs/openssl/crypto/bn/bn_sqrt.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) /* diff --git a/contrib/libs/openssl/crypto/bn/bn_srp.c b/contrib/libs/openssl/crypto/bn/bn_srp.c index aad60c67aa..820757be60 100644 --- a/contrib/libs/openssl/crypto/bn/bn_srp.c +++ b/contrib/libs/openssl/crypto/bn/bn_srp.c @@ -7,13 +7,13 @@ * https://www.openssl.org/source/license.html */ -#include "bn_local.h" +#include "bn_local.h" #include "internal/nelem.h" #ifndef OPENSSL_NO_SRP #include <openssl/srp.h> -#include "crypto/bn_srp.h" +#include "crypto/bn_srp.h" # if (BN_BYTES == 8) # if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) diff --git a/contrib/libs/openssl/crypto/bn/bn_word.c b/contrib/libs/openssl/crypto/bn/bn_word.c index 7aedd69f9a..18fb3030a8 100644 --- a/contrib/libs/openssl/crypto/bn/bn_word.c +++ b/contrib/libs/openssl/crypto/bn/bn_word.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "bn_local.h" +#include "bn_local.h" BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w) { diff --git a/contrib/libs/openssl/crypto/bn/bn_x931p.c b/contrib/libs/openssl/crypto/bn/bn_x931p.c index ae676fc51e..009950259d 100644 --- a/contrib/libs/openssl/crypto/bn/bn_x931p.c +++ b/contrib/libs/openssl/crypto/bn/bn_x931p.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <openssl/bn.h> -#include "bn_local.h" +#include "bn_local.h" /* X9.31 routines for prime derivation */ diff --git a/contrib/libs/openssl/crypto/bn/rsaz_exp.h b/contrib/libs/openssl/crypto/bn/rsaz_exp.h index ad718aa1d5..88f65a4bae 100644 --- a/contrib/libs/openssl/crypto/bn/rsaz_exp.h +++ b/contrib/libs/openssl/crypto/bn/rsaz_exp.h @@ -12,8 +12,8 @@ * (2) University of Haifa, Israel */ -#ifndef OSSL_CRYPTO_BN_RSAZ_EXP_H -# define OSSL_CRYPTO_BN_RSAZ_EXP_H +#ifndef OSSL_CRYPTO_BN_RSAZ_EXP_H +# define OSSL_CRYPTO_BN_RSAZ_EXP_H # undef RSAZ_ENABLED # if defined(OPENSSL_BN_ASM_MONT) && \ diff --git a/contrib/libs/openssl/crypto/buildinf-linux.h b/contrib/libs/openssl/crypto/buildinf-linux.h index 1b49c2cc99..b3f3abffd4 100644 --- a/contrib/libs/openssl/crypto/buildinf-linux.h +++ b/contrib/libs/openssl/crypto/buildinf-linux.h @@ -19,29 +19,29 @@ * literal */ static const char compiler_flags[] = { - 'c','o','m','p','i','l','e','r',':',' ','g','c','c',' ','-','f', - 'P','I','C',' ','-','p','t','h','r','e','a','d',' ','-','m','6', - '4',' ','-','W','a',',','-','-','n','o','e','x','e','c','s','t', - 'a','c','k',' ','-','W','a','l','l',' ','-','O','3',' ','-','D', - 'O','P','E','N','S','S','L','_','U','S','E','_','N','O','D','E', - 'L','E','T','E',' ','-','D','L','_','E','N','D','I','A','N',' ', - '-','D','O','P','E','N','S','S','L','_','P','I','C',' ','-','D', - 'O','P','E','N','S','S','L','_','C','P','U','I','D','_','O','B', - 'J',' ','-','D','O','P','E','N','S','S','L','_','I','A','3','2', - '_','S','S','E','2',' ','-','D','O','P','E','N','S','S','L','_', - 'B','N','_','A','S','M','_','M','O','N','T',' ','-','D','O','P', - 'E','N','S','S','L','_','B','N','_','A','S','M','_','M','O','N', - 'T','5',' ','-','D','O','P','E','N','S','S','L','_','B','N','_', - 'A','S','M','_','G','F','2','m',' ','-','D','S','H','A','1','_', - 'A','S','M',' ','-','D','S','H','A','2','5','6','_','A','S','M', - ' ','-','D','S','H','A','5','1','2','_','A','S','M',' ','-','D', - 'K','E','C','C','A','K','1','6','0','0','_','A','S','M',' ','-', - 'D','R','C','4','_','A','S','M',' ','-','D','M','D','5','_','A', - 'S','M',' ','-','D','A','E','S','N','I','_','A','S','M',' ','-', - 'D','V','P','A','E','S','_','A','S','M',' ','-','D','G','H','A', - 'S','H','_','A','S','M',' ','-','D','E','C','P','_','N','I','S', - 'T','Z','2','5','6','_','A','S','M',' ','-','D','X','2','5','5', - '1','9','_','A','S','M',' ','-','D','P','O','L','Y','1','3','0', - '5','_','A','S','M',' ','-','D','Z','L','I','B',' ','-','D','N', - 'D','E','B','U','G','\0' + 'c','o','m','p','i','l','e','r',':',' ','g','c','c',' ','-','f', + 'P','I','C',' ','-','p','t','h','r','e','a','d',' ','-','m','6', + '4',' ','-','W','a',',','-','-','n','o','e','x','e','c','s','t', + 'a','c','k',' ','-','W','a','l','l',' ','-','O','3',' ','-','D', + 'O','P','E','N','S','S','L','_','U','S','E','_','N','O','D','E', + 'L','E','T','E',' ','-','D','L','_','E','N','D','I','A','N',' ', + '-','D','O','P','E','N','S','S','L','_','P','I','C',' ','-','D', + 'O','P','E','N','S','S','L','_','C','P','U','I','D','_','O','B', + 'J',' ','-','D','O','P','E','N','S','S','L','_','I','A','3','2', + '_','S','S','E','2',' ','-','D','O','P','E','N','S','S','L','_', + 'B','N','_','A','S','M','_','M','O','N','T',' ','-','D','O','P', + 'E','N','S','S','L','_','B','N','_','A','S','M','_','M','O','N', + 'T','5',' ','-','D','O','P','E','N','S','S','L','_','B','N','_', + 'A','S','M','_','G','F','2','m',' ','-','D','S','H','A','1','_', + 'A','S','M',' ','-','D','S','H','A','2','5','6','_','A','S','M', + ' ','-','D','S','H','A','5','1','2','_','A','S','M',' ','-','D', + 'K','E','C','C','A','K','1','6','0','0','_','A','S','M',' ','-', + 'D','R','C','4','_','A','S','M',' ','-','D','M','D','5','_','A', + 'S','M',' ','-','D','A','E','S','N','I','_','A','S','M',' ','-', + 'D','V','P','A','E','S','_','A','S','M',' ','-','D','G','H','A', + 'S','H','_','A','S','M',' ','-','D','E','C','P','_','N','I','S', + 'T','Z','2','5','6','_','A','S','M',' ','-','D','X','2','5','5', + '1','9','_','A','S','M',' ','-','D','P','O','L','Y','1','3','0', + '5','_','A','S','M',' ','-','D','Z','L','I','B',' ','-','D','N', + 'D','E','B','U','G','\0' }; diff --git a/contrib/libs/openssl/crypto/camellia/camellia.c b/contrib/libs/openssl/crypto/camellia/camellia.c index 459ed6d340..f623864bc4 100644 --- a/contrib/libs/openssl/crypto/camellia/camellia.c +++ b/contrib/libs/openssl/crypto/camellia/camellia.c @@ -40,7 +40,7 @@ */ #include <openssl/camellia.h> -#include "cmll_local.h" +#include "cmll_local.h" #include <string.h> #include <stdlib.h> diff --git a/contrib/libs/openssl/crypto/camellia/cmll_ecb.c b/contrib/libs/openssl/crypto/camellia/cmll_ecb.c index 777d6d7ed0..5760d1ed35 100644 --- a/contrib/libs/openssl/crypto/camellia/cmll_ecb.c +++ b/contrib/libs/openssl/crypto/camellia/cmll_ecb.c @@ -8,7 +8,7 @@ */ #include <openssl/camellia.h> -#include "cmll_local.h" +#include "cmll_local.h" void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, const CAMELLIA_KEY *key, const int enc) diff --git a/contrib/libs/openssl/crypto/camellia/cmll_local.h b/contrib/libs/openssl/crypto/camellia/cmll_local.h index cb33130cdb..d16baa55fa 100644 --- a/contrib/libs/openssl/crypto/camellia/cmll_local.h +++ b/contrib/libs/openssl/crypto/camellia/cmll_local.h @@ -1,43 +1,43 @@ -/* - * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* ==================================================================== - * Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) . - * ALL RIGHTS RESERVED. - * - * Intellectual Property information for Camellia: - * http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html - * - * News Release for Announcement of Camellia open source: - * http://www.ntt.co.jp/news/news06e/0604/060413a.html - * - * The Camellia Code included herein is developed by - * NTT (Nippon Telegraph and Telephone Corporation), and is contributed - * to the OpenSSL project. - */ - -#ifndef OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H -# define OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H - -typedef unsigned int u32; -typedef unsigned char u8; - -int Camellia_Ekeygen(int keyBitLength, const u8 *rawKey, - KEY_TABLE_TYPE keyTable); -void Camellia_EncryptBlock_Rounds(int grandRounds, const u8 plaintext[], - const KEY_TABLE_TYPE keyTable, - u8 ciphertext[]); -void Camellia_DecryptBlock_Rounds(int grandRounds, const u8 ciphertext[], - const KEY_TABLE_TYPE keyTable, - u8 plaintext[]); -void Camellia_EncryptBlock(int keyBitLength, const u8 plaintext[], - const KEY_TABLE_TYPE keyTable, u8 ciphertext[]); -void Camellia_DecryptBlock(int keyBitLength, const u8 ciphertext[], - const KEY_TABLE_TYPE keyTable, u8 plaintext[]); -#endif /* #ifndef OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H */ +/* + * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* ==================================================================== + * Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) . + * ALL RIGHTS RESERVED. + * + * Intellectual Property information for Camellia: + * http://info.isl.ntt.co.jp/crypt/eng/info/chiteki.html + * + * News Release for Announcement of Camellia open source: + * http://www.ntt.co.jp/news/news06e/0604/060413a.html + * + * The Camellia Code included herein is developed by + * NTT (Nippon Telegraph and Telephone Corporation), and is contributed + * to the OpenSSL project. + */ + +#ifndef OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H +# define OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H + +typedef unsigned int u32; +typedef unsigned char u8; + +int Camellia_Ekeygen(int keyBitLength, const u8 *rawKey, + KEY_TABLE_TYPE keyTable); +void Camellia_EncryptBlock_Rounds(int grandRounds, const u8 plaintext[], + const KEY_TABLE_TYPE keyTable, + u8 ciphertext[]); +void Camellia_DecryptBlock_Rounds(int grandRounds, const u8 ciphertext[], + const KEY_TABLE_TYPE keyTable, + u8 plaintext[]); +void Camellia_EncryptBlock(int keyBitLength, const u8 plaintext[], + const KEY_TABLE_TYPE keyTable, u8 ciphertext[]); +void Camellia_DecryptBlock(int keyBitLength, const u8 ciphertext[], + const KEY_TABLE_TYPE keyTable, u8 plaintext[]); +#endif /* #ifndef OSSL_CRYPTO_CAMELLIA_CMLL_LOCAL_H */ diff --git a/contrib/libs/openssl/crypto/camellia/cmll_misc.c b/contrib/libs/openssl/crypto/camellia/cmll_misc.c index 269784e136..d8fc3738c4 100644 --- a/contrib/libs/openssl/crypto/camellia/cmll_misc.c +++ b/contrib/libs/openssl/crypto/camellia/cmll_misc.c @@ -9,7 +9,7 @@ #include <openssl/opensslv.h> #include <openssl/camellia.h> -#include "cmll_local.h" +#include "cmll_local.h" int Camellia_set_key(const unsigned char *userKey, const int bits, CAMELLIA_KEY *key) diff --git a/contrib/libs/openssl/crypto/cast/c_cfb64.c b/contrib/libs/openssl/crypto/cast/c_cfb64.c index 2cb3c3f639..7222159538 100644 --- a/contrib/libs/openssl/crypto/cast/c_cfb64.c +++ b/contrib/libs/openssl/crypto/cast/c_cfb64.c @@ -8,7 +8,7 @@ */ #include <openssl/cast.h> -#include "cast_local.h" +#include "cast_local.h" /* * The input and output encrypted as though 64bit cfb mode is being used. diff --git a/contrib/libs/openssl/crypto/cast/c_ecb.c b/contrib/libs/openssl/crypto/cast/c_ecb.c index f0ff1fde8c..6fe093f75b 100644 --- a/contrib/libs/openssl/crypto/cast/c_ecb.c +++ b/contrib/libs/openssl/crypto/cast/c_ecb.c @@ -8,7 +8,7 @@ */ #include <openssl/cast.h> -#include "cast_local.h" +#include "cast_local.h" #include <openssl/opensslv.h> void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, diff --git a/contrib/libs/openssl/crypto/cast/c_enc.c b/contrib/libs/openssl/crypto/cast/c_enc.c index b68bc297c7..d27d1fc0a5 100644 --- a/contrib/libs/openssl/crypto/cast/c_enc.c +++ b/contrib/libs/openssl/crypto/cast/c_enc.c @@ -8,7 +8,7 @@ */ #include <openssl/cast.h> -#include "cast_local.h" +#include "cast_local.h" void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key) { diff --git a/contrib/libs/openssl/crypto/cast/c_ofb64.c b/contrib/libs/openssl/crypto/cast/c_ofb64.c index 44caab5797..49c0cfade5 100644 --- a/contrib/libs/openssl/crypto/cast/c_ofb64.c +++ b/contrib/libs/openssl/crypto/cast/c_ofb64.c @@ -8,7 +8,7 @@ */ #include <openssl/cast.h> -#include "cast_local.h" +#include "cast_local.h" /* * The input and output encrypted as though 64bit ofb mode is being used. diff --git a/contrib/libs/openssl/crypto/cast/c_skey.c b/contrib/libs/openssl/crypto/cast/c_skey.c index 2350d5a88c..0311482d20 100644 --- a/contrib/libs/openssl/crypto/cast/c_skey.c +++ b/contrib/libs/openssl/crypto/cast/c_skey.c @@ -8,7 +8,7 @@ */ #include <openssl/cast.h> -#include "cast_local.h" +#include "cast_local.h" #include "cast_s.h" #define CAST_exp(l,A,a,n) \ diff --git a/contrib/libs/openssl/crypto/cast/cast_local.h b/contrib/libs/openssl/crypto/cast/cast_local.h index 23202f1a15..35e89930a8 100644 --- a/contrib/libs/openssl/crypto/cast/cast_local.h +++ b/contrib/libs/openssl/crypto/cast/cast_local.h @@ -1,188 +1,188 @@ -/* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifdef OPENSSL_SYS_WIN32 -# include <stdlib.h> -#endif - -#undef c2l -#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<<24L) - -/* NOTE - c is not incremented as per c2l */ -#undef c2ln -#define c2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ - case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ - case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ - case 5: l2|=((unsigned long)(*(--(c)))); \ - case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ - case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ - case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ - case 1: l1|=((unsigned long)(*(--(c)))); \ - } \ - } - -#undef l2c -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24L)&0xff)) - -/* NOTE - c is not incremented as per l2c */ -#undef l2cn -#define l2cn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ - } \ - } - -/* NOTE - c is not incremented as per n2l */ -#define n2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c)))) ; \ - /* fall thru */ \ - case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ - /* fall thru */ \ - case 6: l2|=((unsigned long)(*(--(c))))<<16; \ - /* fall thru */ \ - case 5: l2|=((unsigned long)(*(--(c))))<<24; \ - /* fall thru */ \ - case 4: l1 =((unsigned long)(*(--(c)))) ; \ - /* fall thru */ \ - case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ - /* fall thru */ \ - case 2: l1|=((unsigned long)(*(--(c))))<<16; \ - /* fall thru */ \ - case 1: l1|=((unsigned long)(*(--(c))))<<24; \ - } \ - } - -/* NOTE - c is not incremented as per l2n */ -#define l2nn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ - /* fall thru */ \ - case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - /* fall thru */ \ - case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - /* fall thru */ \ - case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - /* fall thru */ \ - case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ - /* fall thru */ \ - case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - /* fall thru */ \ - case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - /* fall thru */ \ - case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - } \ - } - -#undef n2l -#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))) - -#undef l2n -#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) -# define ROTL(a,n) (_lrotl(a,n)) -#else -# define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>((32-(n))&31))) -#endif - -#define C_M 0x3fc -#define C_0 22L -#define C_1 14L -#define C_2 6L -#define C_3 2L /* left shift */ - -/* The rotate has an extra 16 added to it to help the x86 asm */ -#if defined(CAST_PTR) -# define E_CAST(n,key,L,R,OP1,OP2,OP3) \ - { \ - int i; \ - t=(key[n*2] OP1 R)&0xffffffffL; \ - i=key[n*2+1]; \ - t=ROTL(t,i); \ - L^= (((((*(CAST_LONG *)((unsigned char *) \ - CAST_S_table0+((t>>C_2)&C_M)) OP2 \ - *(CAST_LONG *)((unsigned char *) \ - CAST_S_table1+((t<<C_3)&C_M)))&0xffffffffL) OP3 \ - *(CAST_LONG *)((unsigned char *) \ - CAST_S_table2+((t>>C_0)&C_M)))&0xffffffffL) OP1 \ - *(CAST_LONG *)((unsigned char *) \ - CAST_S_table3+((t>>C_1)&C_M)))&0xffffffffL; \ - } -#elif defined(CAST_PTR2) -# define E_CAST(n,key,L,R,OP1,OP2,OP3) \ - { \ - int i; \ - CAST_LONG u,v,w; \ - w=(key[n*2] OP1 R)&0xffffffffL; \ - i=key[n*2+1]; \ - w=ROTL(w,i); \ - u=w>>C_2; \ - v=w<<C_3; \ - u&=C_M; \ - v&=C_M; \ - t= *(CAST_LONG *)((unsigned char *)CAST_S_table0+u); \ - u=w>>C_0; \ - t=(t OP2 *(CAST_LONG *)((unsigned char *)CAST_S_table1+v))&0xffffffffL;\ - v=w>>C_1; \ - u&=C_M; \ - v&=C_M; \ - t=(t OP3 *(CAST_LONG *)((unsigned char *)CAST_S_table2+u)&0xffffffffL);\ - t=(t OP1 *(CAST_LONG *)((unsigned char *)CAST_S_table3+v)&0xffffffffL);\ - L^=(t&0xffffffff); \ - } -#else -# define E_CAST(n,key,L,R,OP1,OP2,OP3) \ - { \ - CAST_LONG a,b,c,d; \ - t=(key[n*2] OP1 R)&0xffffffff; \ - t=ROTL(t,(key[n*2+1])); \ - a=CAST_S_table0[(t>> 8)&0xff]; \ - b=CAST_S_table1[(t )&0xff]; \ - c=CAST_S_table2[(t>>24)&0xff]; \ - d=CAST_S_table3[(t>>16)&0xff]; \ - L^=(((((a OP2 b)&0xffffffffL) OP3 c)&0xffffffffL) OP1 d)&0xffffffffL; \ - } -#endif - -extern const CAST_LONG CAST_S_table0[256]; -extern const CAST_LONG CAST_S_table1[256]; -extern const CAST_LONG CAST_S_table2[256]; -extern const CAST_LONG CAST_S_table3[256]; -extern const CAST_LONG CAST_S_table4[256]; -extern const CAST_LONG CAST_S_table5[256]; -extern const CAST_LONG CAST_S_table6[256]; -extern const CAST_LONG CAST_S_table7[256]; +/* + * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifdef OPENSSL_SYS_WIN32 +# include <stdlib.h> +#endif + +#undef c2l +#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#undef c2ln +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ + case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ + case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ + case 5: l2|=((unsigned long)(*(--(c)))); \ + case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ + case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ + case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ + case 1: l1|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#undef l2cn +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +/* NOTE - c is not incremented as per n2l */ +#define n2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c)))) ; \ + /* fall thru */ \ + case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ + /* fall thru */ \ + case 6: l2|=((unsigned long)(*(--(c))))<<16; \ + /* fall thru */ \ + case 5: l2|=((unsigned long)(*(--(c))))<<24; \ + /* fall thru */ \ + case 4: l1 =((unsigned long)(*(--(c)))) ; \ + /* fall thru */ \ + case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ + /* fall thru */ \ + case 2: l1|=((unsigned long)(*(--(c))))<<16; \ + /* fall thru */ \ + case 1: l1|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +/* NOTE - c is not incremented as per l2n */ +#define l2nn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ + /* fall thru */ \ + case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + /* fall thru */ \ + case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + /* fall thru */ \ + case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + /* fall thru */ \ + case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ + /* fall thru */ \ + case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + /* fall thru */ \ + case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + /* fall thru */ \ + case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + } \ + } + +#undef n2l +#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))) + +#undef l2n +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) +# define ROTL(a,n) (_lrotl(a,n)) +#else +# define ROTL(a,n) ((((a)<<(n))&0xffffffffL)|((a)>>((32-(n))&31))) +#endif + +#define C_M 0x3fc +#define C_0 22L +#define C_1 14L +#define C_2 6L +#define C_3 2L /* left shift */ + +/* The rotate has an extra 16 added to it to help the x86 asm */ +#if defined(CAST_PTR) +# define E_CAST(n,key,L,R,OP1,OP2,OP3) \ + { \ + int i; \ + t=(key[n*2] OP1 R)&0xffffffffL; \ + i=key[n*2+1]; \ + t=ROTL(t,i); \ + L^= (((((*(CAST_LONG *)((unsigned char *) \ + CAST_S_table0+((t>>C_2)&C_M)) OP2 \ + *(CAST_LONG *)((unsigned char *) \ + CAST_S_table1+((t<<C_3)&C_M)))&0xffffffffL) OP3 \ + *(CAST_LONG *)((unsigned char *) \ + CAST_S_table2+((t>>C_0)&C_M)))&0xffffffffL) OP1 \ + *(CAST_LONG *)((unsigned char *) \ + CAST_S_table3+((t>>C_1)&C_M)))&0xffffffffL; \ + } +#elif defined(CAST_PTR2) +# define E_CAST(n,key,L,R,OP1,OP2,OP3) \ + { \ + int i; \ + CAST_LONG u,v,w; \ + w=(key[n*2] OP1 R)&0xffffffffL; \ + i=key[n*2+1]; \ + w=ROTL(w,i); \ + u=w>>C_2; \ + v=w<<C_3; \ + u&=C_M; \ + v&=C_M; \ + t= *(CAST_LONG *)((unsigned char *)CAST_S_table0+u); \ + u=w>>C_0; \ + t=(t OP2 *(CAST_LONG *)((unsigned char *)CAST_S_table1+v))&0xffffffffL;\ + v=w>>C_1; \ + u&=C_M; \ + v&=C_M; \ + t=(t OP3 *(CAST_LONG *)((unsigned char *)CAST_S_table2+u)&0xffffffffL);\ + t=(t OP1 *(CAST_LONG *)((unsigned char *)CAST_S_table3+v)&0xffffffffL);\ + L^=(t&0xffffffff); \ + } +#else +# define E_CAST(n,key,L,R,OP1,OP2,OP3) \ + { \ + CAST_LONG a,b,c,d; \ + t=(key[n*2] OP1 R)&0xffffffff; \ + t=ROTL(t,(key[n*2+1])); \ + a=CAST_S_table0[(t>> 8)&0xff]; \ + b=CAST_S_table1[(t )&0xff]; \ + c=CAST_S_table2[(t>>24)&0xff]; \ + d=CAST_S_table3[(t>>16)&0xff]; \ + L^=(((((a OP2 b)&0xffffffffL) OP3 c)&0xffffffffL) OP1 d)&0xffffffffL; \ + } +#endif + +extern const CAST_LONG CAST_S_table0[256]; +extern const CAST_LONG CAST_S_table1[256]; +extern const CAST_LONG CAST_S_table2[256]; +extern const CAST_LONG CAST_S_table3[256]; +extern const CAST_LONG CAST_S_table4[256]; +extern const CAST_LONG CAST_S_table5[256]; +extern const CAST_LONG CAST_S_table6[256]; +extern const CAST_LONG CAST_S_table7[256]; diff --git a/contrib/libs/openssl/crypto/chacha/chacha_enc.c b/contrib/libs/openssl/crypto/chacha/chacha_enc.c index 8917b603c8..18251eac08 100644 --- a/contrib/libs/openssl/crypto/chacha/chacha_enc.c +++ b/contrib/libs/openssl/crypto/chacha/chacha_enc.c @@ -11,8 +11,8 @@ #include <string.h> -#include "crypto/chacha.h" -#include "crypto/ctype.h" +#include "crypto/chacha.h" +#include "crypto/ctype.h" typedef unsigned int u32; typedef unsigned char u8; @@ -79,18 +79,18 @@ void ChaCha20_ctr32(unsigned char *out, const unsigned char *inp, size_t todo, i; /* sigma constant "expand 32-byte k" in little-endian encoding */ - input[0] = ((u32)ossl_toascii('e')) | ((u32)ossl_toascii('x') << 8) - | ((u32)ossl_toascii('p') << 16) - | ((u32)ossl_toascii('a') << 24); - input[1] = ((u32)ossl_toascii('n')) | ((u32)ossl_toascii('d') << 8) - | ((u32)ossl_toascii(' ') << 16) - | ((u32)ossl_toascii('3') << 24); - input[2] = ((u32)ossl_toascii('2')) | ((u32)ossl_toascii('-') << 8) - | ((u32)ossl_toascii('b') << 16) - | ((u32)ossl_toascii('y') << 24); - input[3] = ((u32)ossl_toascii('t')) | ((u32)ossl_toascii('e') << 8) - | ((u32)ossl_toascii(' ') << 16) - | ((u32)ossl_toascii('k') << 24); + input[0] = ((u32)ossl_toascii('e')) | ((u32)ossl_toascii('x') << 8) + | ((u32)ossl_toascii('p') << 16) + | ((u32)ossl_toascii('a') << 24); + input[1] = ((u32)ossl_toascii('n')) | ((u32)ossl_toascii('d') << 8) + | ((u32)ossl_toascii(' ') << 16) + | ((u32)ossl_toascii('3') << 24); + input[2] = ((u32)ossl_toascii('2')) | ((u32)ossl_toascii('-') << 8) + | ((u32)ossl_toascii('b') << 16) + | ((u32)ossl_toascii('y') << 24); + input[3] = ((u32)ossl_toascii('t')) | ((u32)ossl_toascii('e') << 8) + | ((u32)ossl_toascii(' ') << 16) + | ((u32)ossl_toascii('k') << 24); input[4] = key[0]; input[5] = key[1]; diff --git a/contrib/libs/openssl/crypto/cmac/cm_ameth.c b/contrib/libs/openssl/crypto/cmac/cm_ameth.c index 087fb3dcfe..82adf18c80 100644 --- a/contrib/libs/openssl/crypto/cmac/cm_ameth.c +++ b/contrib/libs/openssl/crypto/cmac/cm_ameth.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include <openssl/evp.h> #include <openssl/cmac.h> -#include "crypto/asn1.h" +#include "crypto/asn1.h" /* * CMAC "ASN1" method. This is just here to indicate the maximum CMAC output diff --git a/contrib/libs/openssl/crypto/cmac/cm_pmeth.c b/contrib/libs/openssl/crypto/cmac/cm_pmeth.c index ee652b76cb..5574f25be8 100644 --- a/contrib/libs/openssl/crypto/cmac/cm_pmeth.c +++ b/contrib/libs/openssl/crypto/cmac/cm_pmeth.c @@ -13,7 +13,7 @@ #include <openssl/x509v3.h> #include <openssl/evp.h> #include <openssl/cmac.h> -#include "crypto/evp.h" +#include "crypto/evp.h" /* The context structure and "key" is simply a CMAC_CTX */ diff --git a/contrib/libs/openssl/crypto/cms/cms_asn1.c b/contrib/libs/openssl/crypto/cms/cms_asn1.c index 0935d71799..08069d72a2 100644 --- a/contrib/libs/openssl/crypto/cms/cms_asn1.c +++ b/contrib/libs/openssl/crypto/cms/cms_asn1.c @@ -11,7 +11,7 @@ #include <openssl/pem.h> #include <openssl/x509v3.h> #include <openssl/cms.h> -#include "cms_local.h" +#include "cms_local.h" ASN1_SEQUENCE(CMS_IssuerAndSerialNumber) = { diff --git a/contrib/libs/openssl/crypto/cms/cms_att.c b/contrib/libs/openssl/crypto/cms/cms_att.c index ecf89235cc..4f71661919 100644 --- a/contrib/libs/openssl/crypto/cms/cms_att.c +++ b/contrib/libs/openssl/crypto/cms/cms_att.c @@ -12,7 +12,7 @@ #include <openssl/x509v3.h> #include <openssl/err.h> #include <openssl/cms.h> -#include "cms_local.h" +#include "cms_local.h" #include "internal/nelem.h" /*- diff --git a/contrib/libs/openssl/crypto/cms/cms_cd.c b/contrib/libs/openssl/crypto/cms/cms_cd.c index 300e9821dc..45365b8ba2 100644 --- a/contrib/libs/openssl/crypto/cms/cms_cd.c +++ b/contrib/libs/openssl/crypto/cms/cms_cd.c @@ -15,7 +15,7 @@ #include <openssl/cms.h> #include <openssl/bio.h> #include <openssl/comp.h> -#include "cms_local.h" +#include "cms_local.h" #ifdef ZLIB diff --git a/contrib/libs/openssl/crypto/cms/cms_dd.c b/contrib/libs/openssl/crypto/cms/cms_dd.c index 85384d281c..0df2e698c2 100644 --- a/contrib/libs/openssl/crypto/cms/cms_dd.c +++ b/contrib/libs/openssl/crypto/cms/cms_dd.c @@ -13,7 +13,7 @@ #include <openssl/x509v3.h> #include <openssl/err.h> #include <openssl/cms.h> -#include "cms_local.h" +#include "cms_local.h" /* CMS DigestedData Utilities */ diff --git a/contrib/libs/openssl/crypto/cms/cms_enc.c b/contrib/libs/openssl/crypto/cms/cms_enc.c index 1c48c8ab82..fc490303d4 100644 --- a/contrib/libs/openssl/crypto/cms/cms_enc.c +++ b/contrib/libs/openssl/crypto/cms/cms_enc.c @@ -14,7 +14,7 @@ #include <openssl/err.h> #include <openssl/cms.h> #include <openssl/rand.h> -#include "cms_local.h" +#include "cms_local.h" /* CMS EncryptedData Utilities */ diff --git a/contrib/libs/openssl/crypto/cms/cms_env.c b/contrib/libs/openssl/crypto/cms/cms_env.c index da0ef7591b..04940146fd 100644 --- a/contrib/libs/openssl/crypto/cms/cms_env.c +++ b/contrib/libs/openssl/crypto/cms/cms_env.c @@ -14,9 +14,9 @@ #include <openssl/err.h> #include <openssl/cms.h> #include <openssl/aes.h> -#include "cms_local.h" -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "cms_local.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" /* CMS EnvelopedData Utilities */ diff --git a/contrib/libs/openssl/crypto/cms/cms_ess.c b/contrib/libs/openssl/crypto/cms/cms_ess.c index 424cd5ee4e..a21c443ae8 100644 --- a/contrib/libs/openssl/crypto/cms/cms_ess.c +++ b/contrib/libs/openssl/crypto/cms/cms_ess.c @@ -14,7 +14,7 @@ #include <openssl/x509v3.h> #include <openssl/err.h> #include <openssl/cms.h> -#include "cms_local.h" +#include "cms_local.h" IMPLEMENT_ASN1_FUNCTIONS(CMS_ReceiptRequest) diff --git a/contrib/libs/openssl/crypto/cms/cms_io.c b/contrib/libs/openssl/crypto/cms/cms_io.c index 7ca68ba060..b37e485f5a 100644 --- a/contrib/libs/openssl/crypto/cms/cms_io.c +++ b/contrib/libs/openssl/crypto/cms/cms_io.c @@ -12,7 +12,7 @@ #include <openssl/err.h> #include <openssl/pem.h> #include <openssl/cms.h> -#include "cms_local.h" +#include "cms_local.h" int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) { diff --git a/contrib/libs/openssl/crypto/cms/cms_kari.c b/contrib/libs/openssl/crypto/cms/cms_kari.c index 3f1c4279f2..cafc3040ac 100644 --- a/contrib/libs/openssl/crypto/cms/cms_kari.c +++ b/contrib/libs/openssl/crypto/cms/cms_kari.c @@ -14,8 +14,8 @@ #include <openssl/err.h> #include <openssl/cms.h> #include <openssl/aes.h> -#include "cms_local.h" -#include "crypto/asn1.h" +#include "cms_local.h" +#include "crypto/asn1.h" /* Key Agreement Recipient Info (KARI) routines */ @@ -162,7 +162,7 @@ int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk) if (!pk) return 1; pctx = EVP_PKEY_CTX_new(pk, NULL); - if (!pctx || EVP_PKEY_derive_init(pctx) <= 0) + if (!pctx || EVP_PKEY_derive_init(pctx) <= 0) goto err; kari->pctx = pctx; return 1; diff --git a/contrib/libs/openssl/crypto/cms/cms_lib.c b/contrib/libs/openssl/crypto/cms/cms_lib.c index 58dc8039f9..be4c2c703f 100644 --- a/contrib/libs/openssl/crypto/cms/cms_lib.c +++ b/contrib/libs/openssl/crypto/cms/cms_lib.c @@ -14,7 +14,7 @@ #include <openssl/bio.h> #include <openssl/asn1.h> #include <openssl/cms.h> -#include "cms_local.h" +#include "cms_local.h" IMPLEMENT_ASN1_FUNCTIONS(CMS_ContentInfo) IMPLEMENT_ASN1_PRINT_FUNCTION(CMS_ContentInfo) diff --git a/contrib/libs/openssl/crypto/cms/cms_local.h b/contrib/libs/openssl/crypto/cms/cms_local.h index c23a4547ae..a0ce4448f6 100644 --- a/contrib/libs/openssl/crypto/cms/cms_local.h +++ b/contrib/libs/openssl/crypto/cms/cms_local.h @@ -1,438 +1,438 @@ -/* - * Copyright 2008-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_CMS_LOCAL_H -# define OSSL_CRYPTO_CMS_LOCAL_H - -# include <openssl/x509.h> - -/* - * Cryptographic message syntax (CMS) structures: taken from RFC3852 - */ - -/* Forward references */ - -typedef struct CMS_IssuerAndSerialNumber_st CMS_IssuerAndSerialNumber; -typedef struct CMS_EncapsulatedContentInfo_st CMS_EncapsulatedContentInfo; -typedef struct CMS_SignerIdentifier_st CMS_SignerIdentifier; -typedef struct CMS_SignedData_st CMS_SignedData; -typedef struct CMS_OtherRevocationInfoFormat_st CMS_OtherRevocationInfoFormat; -typedef struct CMS_OriginatorInfo_st CMS_OriginatorInfo; -typedef struct CMS_EncryptedContentInfo_st CMS_EncryptedContentInfo; -typedef struct CMS_EnvelopedData_st CMS_EnvelopedData; -typedef struct CMS_DigestedData_st CMS_DigestedData; -typedef struct CMS_EncryptedData_st CMS_EncryptedData; -typedef struct CMS_AuthenticatedData_st CMS_AuthenticatedData; -typedef struct CMS_CompressedData_st CMS_CompressedData; -typedef struct CMS_OtherCertificateFormat_st CMS_OtherCertificateFormat; -typedef struct CMS_KeyTransRecipientInfo_st CMS_KeyTransRecipientInfo; -typedef struct CMS_OriginatorPublicKey_st CMS_OriginatorPublicKey; -typedef struct CMS_OriginatorIdentifierOrKey_st CMS_OriginatorIdentifierOrKey; -typedef struct CMS_KeyAgreeRecipientInfo_st CMS_KeyAgreeRecipientInfo; -typedef struct CMS_RecipientKeyIdentifier_st CMS_RecipientKeyIdentifier; -typedef struct CMS_KeyAgreeRecipientIdentifier_st - CMS_KeyAgreeRecipientIdentifier; -typedef struct CMS_KEKIdentifier_st CMS_KEKIdentifier; -typedef struct CMS_KEKRecipientInfo_st CMS_KEKRecipientInfo; -typedef struct CMS_PasswordRecipientInfo_st CMS_PasswordRecipientInfo; -typedef struct CMS_OtherRecipientInfo_st CMS_OtherRecipientInfo; -typedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom; - -struct CMS_ContentInfo_st { - ASN1_OBJECT *contentType; - union { - ASN1_OCTET_STRING *data; - CMS_SignedData *signedData; - CMS_EnvelopedData *envelopedData; - CMS_DigestedData *digestedData; - CMS_EncryptedData *encryptedData; - CMS_AuthenticatedData *authenticatedData; - CMS_CompressedData *compressedData; - ASN1_TYPE *other; - /* Other types ... */ - void *otherData; - } d; -}; - -DEFINE_STACK_OF(CMS_CertificateChoices) - -struct CMS_SignedData_st { - int32_t version; - STACK_OF(X509_ALGOR) *digestAlgorithms; - CMS_EncapsulatedContentInfo *encapContentInfo; - STACK_OF(CMS_CertificateChoices) *certificates; - STACK_OF(CMS_RevocationInfoChoice) *crls; - STACK_OF(CMS_SignerInfo) *signerInfos; -}; - -struct CMS_EncapsulatedContentInfo_st { - ASN1_OBJECT *eContentType; - ASN1_OCTET_STRING *eContent; - /* Set to 1 if incomplete structure only part set up */ - int partial; -}; - -struct CMS_SignerInfo_st { - int32_t version; - CMS_SignerIdentifier *sid; - X509_ALGOR *digestAlgorithm; - STACK_OF(X509_ATTRIBUTE) *signedAttrs; - X509_ALGOR *signatureAlgorithm; - ASN1_OCTET_STRING *signature; - STACK_OF(X509_ATTRIBUTE) *unsignedAttrs; - /* Signing certificate and key */ - X509 *signer; - EVP_PKEY *pkey; - /* Digest and public key context for alternative parameters */ - EVP_MD_CTX *mctx; - EVP_PKEY_CTX *pctx; -}; - -struct CMS_SignerIdentifier_st { - int type; - union { - CMS_IssuerAndSerialNumber *issuerAndSerialNumber; - ASN1_OCTET_STRING *subjectKeyIdentifier; - } d; -}; - -struct CMS_EnvelopedData_st { - int32_t version; - CMS_OriginatorInfo *originatorInfo; - STACK_OF(CMS_RecipientInfo) *recipientInfos; - CMS_EncryptedContentInfo *encryptedContentInfo; - STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs; -}; - -struct CMS_OriginatorInfo_st { - STACK_OF(CMS_CertificateChoices) *certificates; - STACK_OF(CMS_RevocationInfoChoice) *crls; -}; - -struct CMS_EncryptedContentInfo_st { - ASN1_OBJECT *contentType; - X509_ALGOR *contentEncryptionAlgorithm; - ASN1_OCTET_STRING *encryptedContent; - /* Content encryption algorithm and key */ - const EVP_CIPHER *cipher; - unsigned char *key; - size_t keylen; - /* Set to 1 if we are debugging decrypt and don't fake keys for MMA */ - int debug; - /* Set to 1 if we have no cert and need extra safety measures for MMA */ - int havenocert; -}; - -struct CMS_RecipientInfo_st { - int type; - union { - CMS_KeyTransRecipientInfo *ktri; - CMS_KeyAgreeRecipientInfo *kari; - CMS_KEKRecipientInfo *kekri; - CMS_PasswordRecipientInfo *pwri; - CMS_OtherRecipientInfo *ori; - } d; -}; - -typedef CMS_SignerIdentifier CMS_RecipientIdentifier; - -struct CMS_KeyTransRecipientInfo_st { - int32_t version; - CMS_RecipientIdentifier *rid; - X509_ALGOR *keyEncryptionAlgorithm; - ASN1_OCTET_STRING *encryptedKey; - /* Recipient Key and cert */ - X509 *recip; - EVP_PKEY *pkey; - /* Public key context for this operation */ - EVP_PKEY_CTX *pctx; -}; - -struct CMS_KeyAgreeRecipientInfo_st { - int32_t version; - CMS_OriginatorIdentifierOrKey *originator; - ASN1_OCTET_STRING *ukm; - X509_ALGOR *keyEncryptionAlgorithm; - STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys; - /* Public key context associated with current operation */ - EVP_PKEY_CTX *pctx; - /* Cipher context for CEK wrapping */ - EVP_CIPHER_CTX *ctx; -}; - -struct CMS_OriginatorIdentifierOrKey_st { - int type; - union { - CMS_IssuerAndSerialNumber *issuerAndSerialNumber; - ASN1_OCTET_STRING *subjectKeyIdentifier; - CMS_OriginatorPublicKey *originatorKey; - } d; -}; - -struct CMS_OriginatorPublicKey_st { - X509_ALGOR *algorithm; - ASN1_BIT_STRING *publicKey; -}; - -struct CMS_RecipientEncryptedKey_st { - CMS_KeyAgreeRecipientIdentifier *rid; - ASN1_OCTET_STRING *encryptedKey; - /* Public key associated with this recipient */ - EVP_PKEY *pkey; -}; - -struct CMS_KeyAgreeRecipientIdentifier_st { - int type; - union { - CMS_IssuerAndSerialNumber *issuerAndSerialNumber; - CMS_RecipientKeyIdentifier *rKeyId; - } d; -}; - -struct CMS_RecipientKeyIdentifier_st { - ASN1_OCTET_STRING *subjectKeyIdentifier; - ASN1_GENERALIZEDTIME *date; - CMS_OtherKeyAttribute *other; -}; - -struct CMS_KEKRecipientInfo_st { - int32_t version; - CMS_KEKIdentifier *kekid; - X509_ALGOR *keyEncryptionAlgorithm; - ASN1_OCTET_STRING *encryptedKey; - /* Extra info: symmetric key to use */ - unsigned char *key; - size_t keylen; -}; - -struct CMS_KEKIdentifier_st { - ASN1_OCTET_STRING *keyIdentifier; - ASN1_GENERALIZEDTIME *date; - CMS_OtherKeyAttribute *other; -}; - -struct CMS_PasswordRecipientInfo_st { - int32_t version; - X509_ALGOR *keyDerivationAlgorithm; - X509_ALGOR *keyEncryptionAlgorithm; - ASN1_OCTET_STRING *encryptedKey; - /* Extra info: password to use */ - unsigned char *pass; - size_t passlen; -}; - -struct CMS_OtherRecipientInfo_st { - ASN1_OBJECT *oriType; - ASN1_TYPE *oriValue; -}; - -struct CMS_DigestedData_st { - int32_t version; - X509_ALGOR *digestAlgorithm; - CMS_EncapsulatedContentInfo *encapContentInfo; - ASN1_OCTET_STRING *digest; -}; - -struct CMS_EncryptedData_st { - int32_t version; - CMS_EncryptedContentInfo *encryptedContentInfo; - STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs; -}; - -struct CMS_AuthenticatedData_st { - int32_t version; - CMS_OriginatorInfo *originatorInfo; - STACK_OF(CMS_RecipientInfo) *recipientInfos; - X509_ALGOR *macAlgorithm; - X509_ALGOR *digestAlgorithm; - CMS_EncapsulatedContentInfo *encapContentInfo; - STACK_OF(X509_ATTRIBUTE) *authAttrs; - ASN1_OCTET_STRING *mac; - STACK_OF(X509_ATTRIBUTE) *unauthAttrs; -}; - -struct CMS_CompressedData_st { - int32_t version; - X509_ALGOR *compressionAlgorithm; - STACK_OF(CMS_RecipientInfo) *recipientInfos; - CMS_EncapsulatedContentInfo *encapContentInfo; -}; - -struct CMS_RevocationInfoChoice_st { - int type; - union { - X509_CRL *crl; - CMS_OtherRevocationInfoFormat *other; - } d; -}; - -# define CMS_REVCHOICE_CRL 0 -# define CMS_REVCHOICE_OTHER 1 - -struct CMS_OtherRevocationInfoFormat_st { - ASN1_OBJECT *otherRevInfoFormat; - ASN1_TYPE *otherRevInfo; -}; - -struct CMS_CertificateChoices { - int type; - union { - X509 *certificate; - ASN1_STRING *extendedCertificate; /* Obsolete */ - ASN1_STRING *v1AttrCert; /* Left encoded for now */ - ASN1_STRING *v2AttrCert; /* Left encoded for now */ - CMS_OtherCertificateFormat *other; - } d; -}; - -# define CMS_CERTCHOICE_CERT 0 -# define CMS_CERTCHOICE_EXCERT 1 -# define CMS_CERTCHOICE_V1ACERT 2 -# define CMS_CERTCHOICE_V2ACERT 3 -# define CMS_CERTCHOICE_OTHER 4 - -struct CMS_OtherCertificateFormat_st { - ASN1_OBJECT *otherCertFormat; - ASN1_TYPE *otherCert; -}; - -/* - * This is also defined in pkcs7.h but we duplicate it to allow the CMS code - * to be independent of PKCS#7 - */ - -struct CMS_IssuerAndSerialNumber_st { - X509_NAME *issuer; - ASN1_INTEGER *serialNumber; -}; - -struct CMS_OtherKeyAttribute_st { - ASN1_OBJECT *keyAttrId; - ASN1_TYPE *keyAttr; -}; - -/* ESS structures */ - -struct CMS_ReceiptRequest_st { - ASN1_OCTET_STRING *signedContentIdentifier; - CMS_ReceiptsFrom *receiptsFrom; - STACK_OF(GENERAL_NAMES) *receiptsTo; -}; - -struct CMS_ReceiptsFrom_st { - int type; - union { - int32_t allOrFirstTier; - STACK_OF(GENERAL_NAMES) *receiptList; - } d; -}; - -struct CMS_Receipt_st { - int32_t version; - ASN1_OBJECT *contentType; - ASN1_OCTET_STRING *signedContentIdentifier; - ASN1_OCTET_STRING *originatorSignatureValue; -}; - -DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) -DECLARE_ASN1_ITEM(CMS_SignerInfo) -DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber) -DECLARE_ASN1_ITEM(CMS_Attributes_Sign) -DECLARE_ASN1_ITEM(CMS_Attributes_Verify) -DECLARE_ASN1_ITEM(CMS_RecipientInfo) -DECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo) -DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber) - -# define CMS_SIGNERINFO_ISSUER_SERIAL 0 -# define CMS_SIGNERINFO_KEYIDENTIFIER 1 - -# define CMS_RECIPINFO_ISSUER_SERIAL 0 -# define CMS_RECIPINFO_KEYIDENTIFIER 1 - -# define CMS_REK_ISSUER_SERIAL 0 -# define CMS_REK_KEYIDENTIFIER 1 - -# define CMS_OIK_ISSUER_SERIAL 0 -# define CMS_OIK_KEYIDENTIFIER 1 -# define CMS_OIK_PUBKEY 2 - -BIO *cms_content_bio(CMS_ContentInfo *cms); - -CMS_ContentInfo *cms_Data_create(void); - -CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md); -BIO *cms_DigestedData_init_bio(CMS_ContentInfo *cms); -int cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify); - -BIO *cms_SignedData_init_bio(CMS_ContentInfo *cms); -int cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain); -int cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert, - int type); -int cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid, - ASN1_OCTET_STRING **keyid, - X509_NAME **issuer, - ASN1_INTEGER **sno); -int cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert); - -CMS_ContentInfo *cms_CompressedData_create(int comp_nid); -BIO *cms_CompressedData_init_bio(CMS_ContentInfo *cms); - -BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm); -int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain, - X509_ALGOR *mdalg); - -int cms_ias_cert_cmp(CMS_IssuerAndSerialNumber *ias, X509 *cert); -int cms_keyid_cert_cmp(ASN1_OCTET_STRING *keyid, X509 *cert); -int cms_set1_ias(CMS_IssuerAndSerialNumber **pias, X509 *cert); -int cms_set1_keyid(ASN1_OCTET_STRING **pkeyid, X509 *cert); - -BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec); -BIO *cms_EncryptedData_init_bio(CMS_ContentInfo *cms); -int cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec, - const EVP_CIPHER *cipher, - const unsigned char *key, size_t keylen); - -int cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms); -int cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src); -ASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si); - -BIO *cms_EnvelopedData_init_bio(CMS_ContentInfo *cms); -CMS_EnvelopedData *cms_get0_enveloped(CMS_ContentInfo *cms); -int cms_env_asn1_ctrl(CMS_RecipientInfo *ri, int cmd); -int cms_pkey_get_ri_type(EVP_PKEY *pk); -/* KARI routines */ -int cms_RecipientInfo_kari_init(CMS_RecipientInfo *ri, X509 *recip, - EVP_PKEY *pk, unsigned int flags); -int cms_RecipientInfo_kari_encrypt(CMS_ContentInfo *cms, - CMS_RecipientInfo *ri); - -/* PWRI routines */ -int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, - int en_de); -/* SignerInfo routines */ -int CMS_si_check_attributes(const CMS_SignerInfo *si); - -DECLARE_ASN1_ITEM(CMS_CertificateChoices) -DECLARE_ASN1_ITEM(CMS_DigestedData) -DECLARE_ASN1_ITEM(CMS_EncryptedData) -DECLARE_ASN1_ITEM(CMS_EnvelopedData) -DECLARE_ASN1_ITEM(CMS_KEKRecipientInfo) -DECLARE_ASN1_ITEM(CMS_KeyAgreeRecipientInfo) -DECLARE_ASN1_ITEM(CMS_KeyTransRecipientInfo) -DECLARE_ASN1_ITEM(CMS_OriginatorPublicKey) -DECLARE_ASN1_ITEM(CMS_OtherKeyAttribute) -DECLARE_ASN1_ITEM(CMS_Receipt) -DECLARE_ASN1_ITEM(CMS_ReceiptRequest) -DECLARE_ASN1_ITEM(CMS_RecipientEncryptedKey) -DECLARE_ASN1_ITEM(CMS_RecipientKeyIdentifier) -DECLARE_ASN1_ITEM(CMS_RevocationInfoChoice) -DECLARE_ASN1_ITEM(CMS_SignedData) -DECLARE_ASN1_ITEM(CMS_CompressedData) - -#endif +/* + * Copyright 2008-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_CMS_LOCAL_H +# define OSSL_CRYPTO_CMS_LOCAL_H + +# include <openssl/x509.h> + +/* + * Cryptographic message syntax (CMS) structures: taken from RFC3852 + */ + +/* Forward references */ + +typedef struct CMS_IssuerAndSerialNumber_st CMS_IssuerAndSerialNumber; +typedef struct CMS_EncapsulatedContentInfo_st CMS_EncapsulatedContentInfo; +typedef struct CMS_SignerIdentifier_st CMS_SignerIdentifier; +typedef struct CMS_SignedData_st CMS_SignedData; +typedef struct CMS_OtherRevocationInfoFormat_st CMS_OtherRevocationInfoFormat; +typedef struct CMS_OriginatorInfo_st CMS_OriginatorInfo; +typedef struct CMS_EncryptedContentInfo_st CMS_EncryptedContentInfo; +typedef struct CMS_EnvelopedData_st CMS_EnvelopedData; +typedef struct CMS_DigestedData_st CMS_DigestedData; +typedef struct CMS_EncryptedData_st CMS_EncryptedData; +typedef struct CMS_AuthenticatedData_st CMS_AuthenticatedData; +typedef struct CMS_CompressedData_st CMS_CompressedData; +typedef struct CMS_OtherCertificateFormat_st CMS_OtherCertificateFormat; +typedef struct CMS_KeyTransRecipientInfo_st CMS_KeyTransRecipientInfo; +typedef struct CMS_OriginatorPublicKey_st CMS_OriginatorPublicKey; +typedef struct CMS_OriginatorIdentifierOrKey_st CMS_OriginatorIdentifierOrKey; +typedef struct CMS_KeyAgreeRecipientInfo_st CMS_KeyAgreeRecipientInfo; +typedef struct CMS_RecipientKeyIdentifier_st CMS_RecipientKeyIdentifier; +typedef struct CMS_KeyAgreeRecipientIdentifier_st + CMS_KeyAgreeRecipientIdentifier; +typedef struct CMS_KEKIdentifier_st CMS_KEKIdentifier; +typedef struct CMS_KEKRecipientInfo_st CMS_KEKRecipientInfo; +typedef struct CMS_PasswordRecipientInfo_st CMS_PasswordRecipientInfo; +typedef struct CMS_OtherRecipientInfo_st CMS_OtherRecipientInfo; +typedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom; + +struct CMS_ContentInfo_st { + ASN1_OBJECT *contentType; + union { + ASN1_OCTET_STRING *data; + CMS_SignedData *signedData; + CMS_EnvelopedData *envelopedData; + CMS_DigestedData *digestedData; + CMS_EncryptedData *encryptedData; + CMS_AuthenticatedData *authenticatedData; + CMS_CompressedData *compressedData; + ASN1_TYPE *other; + /* Other types ... */ + void *otherData; + } d; +}; + +DEFINE_STACK_OF(CMS_CertificateChoices) + +struct CMS_SignedData_st { + int32_t version; + STACK_OF(X509_ALGOR) *digestAlgorithms; + CMS_EncapsulatedContentInfo *encapContentInfo; + STACK_OF(CMS_CertificateChoices) *certificates; + STACK_OF(CMS_RevocationInfoChoice) *crls; + STACK_OF(CMS_SignerInfo) *signerInfos; +}; + +struct CMS_EncapsulatedContentInfo_st { + ASN1_OBJECT *eContentType; + ASN1_OCTET_STRING *eContent; + /* Set to 1 if incomplete structure only part set up */ + int partial; +}; + +struct CMS_SignerInfo_st { + int32_t version; + CMS_SignerIdentifier *sid; + X509_ALGOR *digestAlgorithm; + STACK_OF(X509_ATTRIBUTE) *signedAttrs; + X509_ALGOR *signatureAlgorithm; + ASN1_OCTET_STRING *signature; + STACK_OF(X509_ATTRIBUTE) *unsignedAttrs; + /* Signing certificate and key */ + X509 *signer; + EVP_PKEY *pkey; + /* Digest and public key context for alternative parameters */ + EVP_MD_CTX *mctx; + EVP_PKEY_CTX *pctx; +}; + +struct CMS_SignerIdentifier_st { + int type; + union { + CMS_IssuerAndSerialNumber *issuerAndSerialNumber; + ASN1_OCTET_STRING *subjectKeyIdentifier; + } d; +}; + +struct CMS_EnvelopedData_st { + int32_t version; + CMS_OriginatorInfo *originatorInfo; + STACK_OF(CMS_RecipientInfo) *recipientInfos; + CMS_EncryptedContentInfo *encryptedContentInfo; + STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs; +}; + +struct CMS_OriginatorInfo_st { + STACK_OF(CMS_CertificateChoices) *certificates; + STACK_OF(CMS_RevocationInfoChoice) *crls; +}; + +struct CMS_EncryptedContentInfo_st { + ASN1_OBJECT *contentType; + X509_ALGOR *contentEncryptionAlgorithm; + ASN1_OCTET_STRING *encryptedContent; + /* Content encryption algorithm and key */ + const EVP_CIPHER *cipher; + unsigned char *key; + size_t keylen; + /* Set to 1 if we are debugging decrypt and don't fake keys for MMA */ + int debug; + /* Set to 1 if we have no cert and need extra safety measures for MMA */ + int havenocert; +}; + +struct CMS_RecipientInfo_st { + int type; + union { + CMS_KeyTransRecipientInfo *ktri; + CMS_KeyAgreeRecipientInfo *kari; + CMS_KEKRecipientInfo *kekri; + CMS_PasswordRecipientInfo *pwri; + CMS_OtherRecipientInfo *ori; + } d; +}; + +typedef CMS_SignerIdentifier CMS_RecipientIdentifier; + +struct CMS_KeyTransRecipientInfo_st { + int32_t version; + CMS_RecipientIdentifier *rid; + X509_ALGOR *keyEncryptionAlgorithm; + ASN1_OCTET_STRING *encryptedKey; + /* Recipient Key and cert */ + X509 *recip; + EVP_PKEY *pkey; + /* Public key context for this operation */ + EVP_PKEY_CTX *pctx; +}; + +struct CMS_KeyAgreeRecipientInfo_st { + int32_t version; + CMS_OriginatorIdentifierOrKey *originator; + ASN1_OCTET_STRING *ukm; + X509_ALGOR *keyEncryptionAlgorithm; + STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys; + /* Public key context associated with current operation */ + EVP_PKEY_CTX *pctx; + /* Cipher context for CEK wrapping */ + EVP_CIPHER_CTX *ctx; +}; + +struct CMS_OriginatorIdentifierOrKey_st { + int type; + union { + CMS_IssuerAndSerialNumber *issuerAndSerialNumber; + ASN1_OCTET_STRING *subjectKeyIdentifier; + CMS_OriginatorPublicKey *originatorKey; + } d; +}; + +struct CMS_OriginatorPublicKey_st { + X509_ALGOR *algorithm; + ASN1_BIT_STRING *publicKey; +}; + +struct CMS_RecipientEncryptedKey_st { + CMS_KeyAgreeRecipientIdentifier *rid; + ASN1_OCTET_STRING *encryptedKey; + /* Public key associated with this recipient */ + EVP_PKEY *pkey; +}; + +struct CMS_KeyAgreeRecipientIdentifier_st { + int type; + union { + CMS_IssuerAndSerialNumber *issuerAndSerialNumber; + CMS_RecipientKeyIdentifier *rKeyId; + } d; +}; + +struct CMS_RecipientKeyIdentifier_st { + ASN1_OCTET_STRING *subjectKeyIdentifier; + ASN1_GENERALIZEDTIME *date; + CMS_OtherKeyAttribute *other; +}; + +struct CMS_KEKRecipientInfo_st { + int32_t version; + CMS_KEKIdentifier *kekid; + X509_ALGOR *keyEncryptionAlgorithm; + ASN1_OCTET_STRING *encryptedKey; + /* Extra info: symmetric key to use */ + unsigned char *key; + size_t keylen; +}; + +struct CMS_KEKIdentifier_st { + ASN1_OCTET_STRING *keyIdentifier; + ASN1_GENERALIZEDTIME *date; + CMS_OtherKeyAttribute *other; +}; + +struct CMS_PasswordRecipientInfo_st { + int32_t version; + X509_ALGOR *keyDerivationAlgorithm; + X509_ALGOR *keyEncryptionAlgorithm; + ASN1_OCTET_STRING *encryptedKey; + /* Extra info: password to use */ + unsigned char *pass; + size_t passlen; +}; + +struct CMS_OtherRecipientInfo_st { + ASN1_OBJECT *oriType; + ASN1_TYPE *oriValue; +}; + +struct CMS_DigestedData_st { + int32_t version; + X509_ALGOR *digestAlgorithm; + CMS_EncapsulatedContentInfo *encapContentInfo; + ASN1_OCTET_STRING *digest; +}; + +struct CMS_EncryptedData_st { + int32_t version; + CMS_EncryptedContentInfo *encryptedContentInfo; + STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs; +}; + +struct CMS_AuthenticatedData_st { + int32_t version; + CMS_OriginatorInfo *originatorInfo; + STACK_OF(CMS_RecipientInfo) *recipientInfos; + X509_ALGOR *macAlgorithm; + X509_ALGOR *digestAlgorithm; + CMS_EncapsulatedContentInfo *encapContentInfo; + STACK_OF(X509_ATTRIBUTE) *authAttrs; + ASN1_OCTET_STRING *mac; + STACK_OF(X509_ATTRIBUTE) *unauthAttrs; +}; + +struct CMS_CompressedData_st { + int32_t version; + X509_ALGOR *compressionAlgorithm; + STACK_OF(CMS_RecipientInfo) *recipientInfos; + CMS_EncapsulatedContentInfo *encapContentInfo; +}; + +struct CMS_RevocationInfoChoice_st { + int type; + union { + X509_CRL *crl; + CMS_OtherRevocationInfoFormat *other; + } d; +}; + +# define CMS_REVCHOICE_CRL 0 +# define CMS_REVCHOICE_OTHER 1 + +struct CMS_OtherRevocationInfoFormat_st { + ASN1_OBJECT *otherRevInfoFormat; + ASN1_TYPE *otherRevInfo; +}; + +struct CMS_CertificateChoices { + int type; + union { + X509 *certificate; + ASN1_STRING *extendedCertificate; /* Obsolete */ + ASN1_STRING *v1AttrCert; /* Left encoded for now */ + ASN1_STRING *v2AttrCert; /* Left encoded for now */ + CMS_OtherCertificateFormat *other; + } d; +}; + +# define CMS_CERTCHOICE_CERT 0 +# define CMS_CERTCHOICE_EXCERT 1 +# define CMS_CERTCHOICE_V1ACERT 2 +# define CMS_CERTCHOICE_V2ACERT 3 +# define CMS_CERTCHOICE_OTHER 4 + +struct CMS_OtherCertificateFormat_st { + ASN1_OBJECT *otherCertFormat; + ASN1_TYPE *otherCert; +}; + +/* + * This is also defined in pkcs7.h but we duplicate it to allow the CMS code + * to be independent of PKCS#7 + */ + +struct CMS_IssuerAndSerialNumber_st { + X509_NAME *issuer; + ASN1_INTEGER *serialNumber; +}; + +struct CMS_OtherKeyAttribute_st { + ASN1_OBJECT *keyAttrId; + ASN1_TYPE *keyAttr; +}; + +/* ESS structures */ + +struct CMS_ReceiptRequest_st { + ASN1_OCTET_STRING *signedContentIdentifier; + CMS_ReceiptsFrom *receiptsFrom; + STACK_OF(GENERAL_NAMES) *receiptsTo; +}; + +struct CMS_ReceiptsFrom_st { + int type; + union { + int32_t allOrFirstTier; + STACK_OF(GENERAL_NAMES) *receiptList; + } d; +}; + +struct CMS_Receipt_st { + int32_t version; + ASN1_OBJECT *contentType; + ASN1_OCTET_STRING *signedContentIdentifier; + ASN1_OCTET_STRING *originatorSignatureValue; +}; + +DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) +DECLARE_ASN1_ITEM(CMS_SignerInfo) +DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber) +DECLARE_ASN1_ITEM(CMS_Attributes_Sign) +DECLARE_ASN1_ITEM(CMS_Attributes_Verify) +DECLARE_ASN1_ITEM(CMS_RecipientInfo) +DECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo) +DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber) + +# define CMS_SIGNERINFO_ISSUER_SERIAL 0 +# define CMS_SIGNERINFO_KEYIDENTIFIER 1 + +# define CMS_RECIPINFO_ISSUER_SERIAL 0 +# define CMS_RECIPINFO_KEYIDENTIFIER 1 + +# define CMS_REK_ISSUER_SERIAL 0 +# define CMS_REK_KEYIDENTIFIER 1 + +# define CMS_OIK_ISSUER_SERIAL 0 +# define CMS_OIK_KEYIDENTIFIER 1 +# define CMS_OIK_PUBKEY 2 + +BIO *cms_content_bio(CMS_ContentInfo *cms); + +CMS_ContentInfo *cms_Data_create(void); + +CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md); +BIO *cms_DigestedData_init_bio(CMS_ContentInfo *cms); +int cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify); + +BIO *cms_SignedData_init_bio(CMS_ContentInfo *cms); +int cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain); +int cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert, + int type); +int cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid, + ASN1_OCTET_STRING **keyid, + X509_NAME **issuer, + ASN1_INTEGER **sno); +int cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert); + +CMS_ContentInfo *cms_CompressedData_create(int comp_nid); +BIO *cms_CompressedData_init_bio(CMS_ContentInfo *cms); + +BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm); +int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain, + X509_ALGOR *mdalg); + +int cms_ias_cert_cmp(CMS_IssuerAndSerialNumber *ias, X509 *cert); +int cms_keyid_cert_cmp(ASN1_OCTET_STRING *keyid, X509 *cert); +int cms_set1_ias(CMS_IssuerAndSerialNumber **pias, X509 *cert); +int cms_set1_keyid(ASN1_OCTET_STRING **pkeyid, X509 *cert); + +BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec); +BIO *cms_EncryptedData_init_bio(CMS_ContentInfo *cms); +int cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec, + const EVP_CIPHER *cipher, + const unsigned char *key, size_t keylen); + +int cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms); +int cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src); +ASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si); + +BIO *cms_EnvelopedData_init_bio(CMS_ContentInfo *cms); +CMS_EnvelopedData *cms_get0_enveloped(CMS_ContentInfo *cms); +int cms_env_asn1_ctrl(CMS_RecipientInfo *ri, int cmd); +int cms_pkey_get_ri_type(EVP_PKEY *pk); +/* KARI routines */ +int cms_RecipientInfo_kari_init(CMS_RecipientInfo *ri, X509 *recip, + EVP_PKEY *pk, unsigned int flags); +int cms_RecipientInfo_kari_encrypt(CMS_ContentInfo *cms, + CMS_RecipientInfo *ri); + +/* PWRI routines */ +int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, + int en_de); +/* SignerInfo routines */ +int CMS_si_check_attributes(const CMS_SignerInfo *si); + +DECLARE_ASN1_ITEM(CMS_CertificateChoices) +DECLARE_ASN1_ITEM(CMS_DigestedData) +DECLARE_ASN1_ITEM(CMS_EncryptedData) +DECLARE_ASN1_ITEM(CMS_EnvelopedData) +DECLARE_ASN1_ITEM(CMS_KEKRecipientInfo) +DECLARE_ASN1_ITEM(CMS_KeyAgreeRecipientInfo) +DECLARE_ASN1_ITEM(CMS_KeyTransRecipientInfo) +DECLARE_ASN1_ITEM(CMS_OriginatorPublicKey) +DECLARE_ASN1_ITEM(CMS_OtherKeyAttribute) +DECLARE_ASN1_ITEM(CMS_Receipt) +DECLARE_ASN1_ITEM(CMS_ReceiptRequest) +DECLARE_ASN1_ITEM(CMS_RecipientEncryptedKey) +DECLARE_ASN1_ITEM(CMS_RecipientKeyIdentifier) +DECLARE_ASN1_ITEM(CMS_RevocationInfoChoice) +DECLARE_ASN1_ITEM(CMS_SignedData) +DECLARE_ASN1_ITEM(CMS_CompressedData) + +#endif diff --git a/contrib/libs/openssl/crypto/cms/cms_pwri.c b/contrib/libs/openssl/crypto/cms/cms_pwri.c index 9a10553edb..d741488339 100644 --- a/contrib/libs/openssl/crypto/cms/cms_pwri.c +++ b/contrib/libs/openssl/crypto/cms/cms_pwri.c @@ -15,8 +15,8 @@ #include <openssl/cms.h> #include <openssl/rand.h> #include <openssl/aes.h> -#include "cms_local.h" -#include "crypto/asn1.h" +#include "cms_local.h" +#include "crypto/asn1.h" int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, unsigned char *pass, ossl_ssize_t passlen) diff --git a/contrib/libs/openssl/crypto/cms/cms_sd.c b/contrib/libs/openssl/crypto/cms/cms_sd.c index de85df1de2..3f2a782565 100644 --- a/contrib/libs/openssl/crypto/cms/cms_sd.c +++ b/contrib/libs/openssl/crypto/cms/cms_sd.c @@ -14,9 +14,9 @@ #include <openssl/x509v3.h> #include <openssl/err.h> #include <openssl/cms.h> -#include "cms_local.h" -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "cms_local.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" /* CMS SignedData Utilities */ diff --git a/contrib/libs/openssl/crypto/cms/cms_smime.c b/contrib/libs/openssl/crypto/cms/cms_smime.c index b3f76f7429..6e7dbc4da1 100644 --- a/contrib/libs/openssl/crypto/cms/cms_smime.c +++ b/contrib/libs/openssl/crypto/cms/cms_smime.c @@ -13,8 +13,8 @@ #include <openssl/x509v3.h> #include <openssl/err.h> #include <openssl/cms.h> -#include "cms_local.h" -#include "crypto/asn1.h" +#include "cms_local.h" +#include "crypto/asn1.h" static BIO *cms_get_text_bio(BIO *out, unsigned int flags) { diff --git a/contrib/libs/openssl/crypto/comp/c_zlib.c b/contrib/libs/openssl/crypto/comp/c_zlib.c index 016c932ab1..b819337913 100644 --- a/contrib/libs/openssl/crypto/comp/c_zlib.c +++ b/contrib/libs/openssl/crypto/comp/c_zlib.c @@ -13,9 +13,9 @@ #include <openssl/objects.h> #include "internal/comp.h" #include <openssl/err.h> -#include "crypto/cryptlib.h" +#include "crypto/cryptlib.h" #include "internal/bio.h" -#include "comp_local.h" +#include "comp_local.h" COMP_METHOD *COMP_zlib(void); @@ -598,28 +598,28 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr) BIO_copy_next_retry(b); break; - case BIO_CTRL_WPENDING: - if (ctx->obuf == NULL) - return 0; - - if (ctx->odone) { - ret = ctx->ocount; - } else { - ret = ctx->ocount; - if (ret == 0) - /* Unknown amount pending but we are not finished */ - ret = 1; - } - if (ret == 0) - ret = BIO_ctrl(next, cmd, num, ptr); - break; - - case BIO_CTRL_PENDING: - ret = ctx->zin.avail_in; - if (ret == 0) - ret = BIO_ctrl(next, cmd, num, ptr); - break; - + case BIO_CTRL_WPENDING: + if (ctx->obuf == NULL) + return 0; + + if (ctx->odone) { + ret = ctx->ocount; + } else { + ret = ctx->ocount; + if (ret == 0) + /* Unknown amount pending but we are not finished */ + ret = 1; + } + if (ret == 0) + ret = BIO_ctrl(next, cmd, num, ptr); + break; + + case BIO_CTRL_PENDING: + ret = ctx->zin.avail_in; + if (ret == 0) + ret = BIO_ctrl(next, cmd, num, ptr); + break; + default: ret = BIO_ctrl(next, cmd, num, ptr); break; diff --git a/contrib/libs/openssl/crypto/comp/comp_lib.c b/contrib/libs/openssl/crypto/comp/comp_lib.c index 7782ea5458..56920e1cca 100644 --- a/contrib/libs/openssl/crypto/comp/comp_lib.c +++ b/contrib/libs/openssl/crypto/comp/comp_lib.c @@ -13,7 +13,7 @@ #include <openssl/objects.h> #include <openssl/comp.h> #include <openssl/err.h> -#include "comp_local.h" +#include "comp_local.h" COMP_CTX *COMP_CTX_new(COMP_METHOD *meth) { diff --git a/contrib/libs/openssl/crypto/comp/comp_local.h b/contrib/libs/openssl/crypto/comp/comp_local.h index a791838ece..aa45fca238 100644 --- a/contrib/libs/openssl/crypto/comp/comp_local.h +++ b/contrib/libs/openssl/crypto/comp/comp_local.h @@ -1,30 +1,30 @@ -/* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -struct comp_method_st { - int type; /* NID for compression library */ - const char *name; /* A text string to identify the library */ - int (*init) (COMP_CTX *ctx); - void (*finish) (COMP_CTX *ctx); - int (*compress) (COMP_CTX *ctx, - unsigned char *out, unsigned int olen, - unsigned char *in, unsigned int ilen); - int (*expand) (COMP_CTX *ctx, - unsigned char *out, unsigned int olen, - unsigned char *in, unsigned int ilen); -}; - -struct comp_ctx_st { - struct comp_method_st *meth; - unsigned long compress_in; - unsigned long compress_out; - unsigned long expand_in; - unsigned long expand_out; - void* data; -}; +/* + * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +struct comp_method_st { + int type; /* NID for compression library */ + const char *name; /* A text string to identify the library */ + int (*init) (COMP_CTX *ctx); + void (*finish) (COMP_CTX *ctx); + int (*compress) (COMP_CTX *ctx, + unsigned char *out, unsigned int olen, + unsigned char *in, unsigned int ilen); + int (*expand) (COMP_CTX *ctx, + unsigned char *out, unsigned int olen, + unsigned char *in, unsigned int ilen); +}; + +struct comp_ctx_st { + struct comp_method_st *meth; + unsigned long compress_in; + unsigned long compress_out; + unsigned long expand_in; + unsigned long expand_out; + void* data; +}; diff --git a/contrib/libs/openssl/crypto/conf/conf_def.c b/contrib/libs/openssl/crypto/conf/conf_def.c index fdc8bf8a2a..31c02cc49e 100644 --- a/contrib/libs/openssl/crypto/conf/conf_def.c +++ b/contrib/libs/openssl/crypto/conf/conf_def.c @@ -719,9 +719,9 @@ static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx, static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx) { const char *filename; - size_t pathlen; + size_t pathlen; - pathlen = strlen(path); + pathlen = strlen(path); while ((filename = OPENSSL_DIR_read(dirctx, path)) != NULL) { size_t namelen; @@ -734,7 +734,7 @@ static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx) char *newpath; BIO *bio; - newlen = pathlen + namelen + 2; + newlen = pathlen + namelen + 2; newpath = OPENSSL_zalloc(newlen); if (newpath == NULL) { CONFerr(CONF_F_GET_NEXT_FILE, ERR_R_MALLOC_FAILURE); @@ -745,11 +745,11 @@ static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx) * If the given path isn't clear VMS syntax, * we treat it as on Unix. */ - if (path[pathlen - 1] == ']' - || path[pathlen - 1] == '>' - || path[pathlen - 1] == ':') { - /* Clear VMS directory syntax, just copy as is */ - OPENSSL_strlcpy(newpath, path, newlen); + if (path[pathlen - 1] == ']' + || path[pathlen - 1] == '>' + || path[pathlen - 1] == ':') { + /* Clear VMS directory syntax, just copy as is */ + OPENSSL_strlcpy(newpath, path, newlen); } #endif if (newpath[0] == '\0') { diff --git a/contrib/libs/openssl/crypto/conf/conf_lib.c b/contrib/libs/openssl/crypto/conf/conf_lib.c index 7a05422fc8..add1dfa1c1 100644 --- a/contrib/libs/openssl/crypto/conf/conf_lib.c +++ b/contrib/libs/openssl/crypto/conf/conf_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -11,7 +11,7 @@ #include <stdio.h> #include <string.h> #include "internal/conf.h" -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include <openssl/crypto.h> #include <openssl/err.h> #include <openssl/conf.h> @@ -356,10 +356,10 @@ OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void) { OPENSSL_INIT_SETTINGS *ret = malloc(sizeof(*ret)); - if (ret == NULL) - return NULL; - - memset(ret, 0, sizeof(*ret)); + if (ret == NULL) + return NULL; + + memset(ret, 0, sizeof(*ret)); ret->flags = DEFAULT_CONF_MFLAGS; return ret; diff --git a/contrib/libs/openssl/crypto/conf/conf_local.h b/contrib/libs/openssl/crypto/conf/conf_local.h index d9ae116d8c..6e1f7fe00d 100644 --- a/contrib/libs/openssl/crypto/conf/conf_local.h +++ b/contrib/libs/openssl/crypto/conf/conf_local.h @@ -1,11 +1,11 @@ -/* - * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -void conf_add_ssl_module(void); - +/* + * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +void conf_add_ssl_module(void); + diff --git a/contrib/libs/openssl/crypto/conf/conf_mall.c b/contrib/libs/openssl/crypto/conf/conf_mall.c index ce9ab1f20f..d7eaa8509b 100644 --- a/contrib/libs/openssl/crypto/conf/conf_mall.c +++ b/contrib/libs/openssl/crypto/conf/conf_mall.c @@ -14,7 +14,7 @@ #include <openssl/x509.h> #include <openssl/asn1.h> #include <openssl/engine.h> -#include "conf_local.h" +#include "conf_local.h" /* Load all OpenSSL builtin modules */ diff --git a/contrib/libs/openssl/crypto/conf/conf_ssl.c b/contrib/libs/openssl/crypto/conf/conf_ssl.c index 7cd5905f6d..4bd8117d36 100644 --- a/contrib/libs/openssl/crypto/conf/conf_ssl.c +++ b/contrib/libs/openssl/crypto/conf/conf_ssl.c @@ -12,7 +12,7 @@ #include <openssl/conf.h> #include <openssl/err.h> #include "internal/sslconf.h" -#include "conf_local.h" +#include "conf_local.h" /* * SSL library configuration module placeholder. We load it here but defer diff --git a/contrib/libs/openssl/crypto/cryptlib.c b/contrib/libs/openssl/crypto/cryptlib.c index bb627987de..1f36b20c86 100644 --- a/contrib/libs/openssl/crypto/cryptlib.c +++ b/contrib/libs/openssl/crypto/cryptlib.c @@ -9,7 +9,7 @@ */ #include "e_os.h" -#include "crypto/cryptlib.h" +#include "crypto/cryptlib.h" #include <openssl/safestack.h> #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ @@ -49,7 +49,7 @@ typedef char variant_char; # define ossl_getenv getenv # endif -# include "crypto/ctype.h" +# include "crypto/ctype.h" static int todigit(variant_char c) { diff --git a/contrib/libs/openssl/crypto/ct/ct_b64.c b/contrib/libs/openssl/crypto/ct/ct_b64.c index e12ed8d0de..4abe11ca29 100644 --- a/contrib/libs/openssl/crypto/ct/ct_b64.c +++ b/contrib/libs/openssl/crypto/ct/ct_b64.c @@ -14,7 +14,7 @@ #include <openssl/err.h> #include <openssl/evp.h> -#include "ct_local.h" +#include "ct_local.h" /* * Decodes the base64 string |in| into |out|. diff --git a/contrib/libs/openssl/crypto/ct/ct_local.h b/contrib/libs/openssl/crypto/ct/ct_local.h index 4d099cfa0c..9f983c91be 100644 --- a/contrib/libs/openssl/crypto/ct/ct_local.h +++ b/contrib/libs/openssl/crypto/ct/ct_local.h @@ -1,216 +1,216 @@ -/* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <stddef.h> -#include <openssl/ct.h> -#include <openssl/evp.h> -#include <openssl/x509.h> -#include <openssl/x509v3.h> -#include <openssl/safestack.h> - -/* - * From RFC6962: opaque SerializedSCT<1..2^16-1>; struct { SerializedSCT - * sct_list <1..2^16-1>; } SignedCertificateTimestampList; - */ -# define MAX_SCT_SIZE 65535 -# define MAX_SCT_LIST_SIZE MAX_SCT_SIZE - -/* - * Macros to read and write integers in network-byte order. - */ - -#define n2s(c,s) ((s=(((unsigned int)((c)[0]))<< 8)| \ - (((unsigned int)((c)[1])) )),c+=2) - -#define s2n(s,c) ((c[0]=(unsigned char)(((s)>> 8)&0xff), \ - c[1]=(unsigned char)(((s) )&0xff)),c+=2) - -#define l2n3(l,c) ((c[0]=(unsigned char)(((l)>>16)&0xff), \ - c[1]=(unsigned char)(((l)>> 8)&0xff), \ - c[2]=(unsigned char)(((l) )&0xff)),c+=3) - -#define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \ - l|=((uint64_t)(*((c)++)))<<48, \ - l|=((uint64_t)(*((c)++)))<<40, \ - l|=((uint64_t)(*((c)++)))<<32, \ - l|=((uint64_t)(*((c)++)))<<24, \ - l|=((uint64_t)(*((c)++)))<<16, \ - l|=((uint64_t)(*((c)++)))<< 8, \ - l|=((uint64_t)(*((c)++)))) - -#define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \ - *((c)++)=(unsigned char)(((l)>>48)&0xff), \ - *((c)++)=(unsigned char)(((l)>>40)&0xff), \ - *((c)++)=(unsigned char)(((l)>>32)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -/* Signed Certificate Timestamp */ -struct sct_st { - sct_version_t version; - /* If version is not SCT_VERSION_V1, this contains the encoded SCT */ - unsigned char *sct; - size_t sct_len; - /* If version is SCT_VERSION_V1, fields below contain components of the SCT */ - unsigned char *log_id; - size_t log_id_len; - /* - * Note, we cannot distinguish between an unset timestamp, and one - * that is set to 0. However since CT didn't exist in 1970, no real - * SCT should ever be set as such. - */ - uint64_t timestamp; - unsigned char *ext; - size_t ext_len; - unsigned char hash_alg; - unsigned char sig_alg; - unsigned char *sig; - size_t sig_len; - /* Log entry type */ - ct_log_entry_type_t entry_type; - /* Where this SCT was found, e.g. certificate, OCSP response, etc. */ - sct_source_t source; - /* The result of the last attempt to validate this SCT. */ - sct_validation_status_t validation_status; -}; - -/* Miscellaneous data that is useful when verifying an SCT */ -struct sct_ctx_st { - /* Public key */ - EVP_PKEY *pkey; - /* Hash of public key */ - unsigned char *pkeyhash; - size_t pkeyhashlen; - /* For pre-certificate: issuer public key hash */ - unsigned char *ihash; - size_t ihashlen; - /* certificate encoding */ - unsigned char *certder; - size_t certderlen; - /* pre-certificate encoding */ - unsigned char *preder; - size_t prederlen; - /* milliseconds since epoch (to check that the SCT isn't from the future) */ - uint64_t epoch_time_in_ms; -}; - -/* Context when evaluating whether a Certificate Transparency policy is met */ -struct ct_policy_eval_ctx_st { - X509 *cert; - X509 *issuer; - CTLOG_STORE *log_store; - /* milliseconds since epoch (to check that SCTs aren't from the future) */ - uint64_t epoch_time_in_ms; -}; - -/* - * Creates a new context for verifying an SCT. - */ -SCT_CTX *SCT_CTX_new(void); -/* - * Deletes an SCT verification context. - */ -void SCT_CTX_free(SCT_CTX *sctx); - -/* - * Sets the certificate that the SCT was created for. - * If *cert does not have a poison extension, presigner must be NULL. - * If *cert does not have a poison extension, it may have a single SCT - * (NID_ct_precert_scts) extension. - * If either *cert or *presigner have an AKID (NID_authority_key_identifier) - * extension, both must have one. - * Returns 1 on success, 0 on failure. - */ -__owur int SCT_CTX_set1_cert(SCT_CTX *sctx, X509 *cert, X509 *presigner); - -/* - * Sets the issuer of the certificate that the SCT was created for. - * This is just a convenience method to save extracting the public key and - * calling SCT_CTX_set1_issuer_pubkey(). - * Issuer must not be NULL. - * Returns 1 on success, 0 on failure. - */ -__owur int SCT_CTX_set1_issuer(SCT_CTX *sctx, const X509 *issuer); - -/* - * Sets the public key of the issuer of the certificate that the SCT was created - * for. - * The public key must not be NULL. - * Returns 1 on success, 0 on failure. - */ -__owur int SCT_CTX_set1_issuer_pubkey(SCT_CTX *sctx, X509_PUBKEY *pubkey); - -/* - * Sets the public key of the CT log that the SCT is from. - * Returns 1 on success, 0 on failure. - */ -__owur int SCT_CTX_set1_pubkey(SCT_CTX *sctx, X509_PUBKEY *pubkey); - -/* - * Sets the time to evaluate the SCT against, in milliseconds since the Unix - * epoch. If the SCT's timestamp is after this time, it will be interpreted as - * having been issued in the future. RFC6962 states that "TLS clients MUST - * reject SCTs whose timestamp is in the future", so an SCT will not validate - * in this case. - */ -void SCT_CTX_set_time(SCT_CTX *sctx, uint64_t time_in_ms); - -/* - * Verifies an SCT with the given context. - * Returns 1 if the SCT verifies successfully; any other value indicates - * failure. See EVP_DigestVerifyFinal() for the meaning of those values. - */ -__owur int SCT_CTX_verify(const SCT_CTX *sctx, const SCT *sct); - -/* - * Does this SCT have the minimum fields populated to be usable? - * Returns 1 if so, 0 otherwise. - */ -__owur int SCT_is_complete(const SCT *sct); - -/* - * Does this SCT have the signature-related fields populated? - * Returns 1 if so, 0 otherwise. - * This checks that the signature and hash algorithms are set to supported - * values and that the signature field is set. - */ -__owur int SCT_signature_is_complete(const SCT *sct); - -/* - * TODO(RJPercival): Create an SCT_signature struct and make i2o_SCT_signature - * and o2i_SCT_signature conform to the i2d/d2i conventions. - */ - -/* -* Serialize (to TLS format) an |sct| signature and write it to |out|. -* If |out| is null, no signature will be output but the length will be returned. -* If |out| points to a null pointer, a string will be allocated to hold the -* TLS-format signature. It is the responsibility of the caller to free it. -* If |out| points to an allocated string, the signature will be written to it. -* The length of the signature in TLS format will be returned. -*/ -__owur int i2o_SCT_signature(const SCT *sct, unsigned char **out); - -/* -* Parses an SCT signature in TLS format and populates the |sct| with it. -* |in| should be a pointer to a string containing the TLS-format signature. -* |in| will be advanced to the end of the signature if parsing succeeds. -* |len| should be the length of the signature in |in|. -* Returns the number of bytes parsed, or a negative integer if an error occurs. -* If an error occurs, the SCT's signature NID may be updated whilst the -* signature field itself remains unset. -*/ -__owur int o2i_SCT_signature(SCT *sct, const unsigned char **in, size_t len); - -/* - * Handlers for Certificate Transparency X509v3/OCSP extensions - */ -extern const X509V3_EXT_METHOD v3_ct_scts[3]; +/* + * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <stddef.h> +#include <openssl/ct.h> +#include <openssl/evp.h> +#include <openssl/x509.h> +#include <openssl/x509v3.h> +#include <openssl/safestack.h> + +/* + * From RFC6962: opaque SerializedSCT<1..2^16-1>; struct { SerializedSCT + * sct_list <1..2^16-1>; } SignedCertificateTimestampList; + */ +# define MAX_SCT_SIZE 65535 +# define MAX_SCT_LIST_SIZE MAX_SCT_SIZE + +/* + * Macros to read and write integers in network-byte order. + */ + +#define n2s(c,s) ((s=(((unsigned int)((c)[0]))<< 8)| \ + (((unsigned int)((c)[1])) )),c+=2) + +#define s2n(s,c) ((c[0]=(unsigned char)(((s)>> 8)&0xff), \ + c[1]=(unsigned char)(((s) )&0xff)),c+=2) + +#define l2n3(l,c) ((c[0]=(unsigned char)(((l)>>16)&0xff), \ + c[1]=(unsigned char)(((l)>> 8)&0xff), \ + c[2]=(unsigned char)(((l) )&0xff)),c+=3) + +#define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \ + l|=((uint64_t)(*((c)++)))<<48, \ + l|=((uint64_t)(*((c)++)))<<40, \ + l|=((uint64_t)(*((c)++)))<<32, \ + l|=((uint64_t)(*((c)++)))<<24, \ + l|=((uint64_t)(*((c)++)))<<16, \ + l|=((uint64_t)(*((c)++)))<< 8, \ + l|=((uint64_t)(*((c)++)))) + +#define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \ + *((c)++)=(unsigned char)(((l)>>48)&0xff), \ + *((c)++)=(unsigned char)(((l)>>40)&0xff), \ + *((c)++)=(unsigned char)(((l)>>32)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +/* Signed Certificate Timestamp */ +struct sct_st { + sct_version_t version; + /* If version is not SCT_VERSION_V1, this contains the encoded SCT */ + unsigned char *sct; + size_t sct_len; + /* If version is SCT_VERSION_V1, fields below contain components of the SCT */ + unsigned char *log_id; + size_t log_id_len; + /* + * Note, we cannot distinguish between an unset timestamp, and one + * that is set to 0. However since CT didn't exist in 1970, no real + * SCT should ever be set as such. + */ + uint64_t timestamp; + unsigned char *ext; + size_t ext_len; + unsigned char hash_alg; + unsigned char sig_alg; + unsigned char *sig; + size_t sig_len; + /* Log entry type */ + ct_log_entry_type_t entry_type; + /* Where this SCT was found, e.g. certificate, OCSP response, etc. */ + sct_source_t source; + /* The result of the last attempt to validate this SCT. */ + sct_validation_status_t validation_status; +}; + +/* Miscellaneous data that is useful when verifying an SCT */ +struct sct_ctx_st { + /* Public key */ + EVP_PKEY *pkey; + /* Hash of public key */ + unsigned char *pkeyhash; + size_t pkeyhashlen; + /* For pre-certificate: issuer public key hash */ + unsigned char *ihash; + size_t ihashlen; + /* certificate encoding */ + unsigned char *certder; + size_t certderlen; + /* pre-certificate encoding */ + unsigned char *preder; + size_t prederlen; + /* milliseconds since epoch (to check that the SCT isn't from the future) */ + uint64_t epoch_time_in_ms; +}; + +/* Context when evaluating whether a Certificate Transparency policy is met */ +struct ct_policy_eval_ctx_st { + X509 *cert; + X509 *issuer; + CTLOG_STORE *log_store; + /* milliseconds since epoch (to check that SCTs aren't from the future) */ + uint64_t epoch_time_in_ms; +}; + +/* + * Creates a new context for verifying an SCT. + */ +SCT_CTX *SCT_CTX_new(void); +/* + * Deletes an SCT verification context. + */ +void SCT_CTX_free(SCT_CTX *sctx); + +/* + * Sets the certificate that the SCT was created for. + * If *cert does not have a poison extension, presigner must be NULL. + * If *cert does not have a poison extension, it may have a single SCT + * (NID_ct_precert_scts) extension. + * If either *cert or *presigner have an AKID (NID_authority_key_identifier) + * extension, both must have one. + * Returns 1 on success, 0 on failure. + */ +__owur int SCT_CTX_set1_cert(SCT_CTX *sctx, X509 *cert, X509 *presigner); + +/* + * Sets the issuer of the certificate that the SCT was created for. + * This is just a convenience method to save extracting the public key and + * calling SCT_CTX_set1_issuer_pubkey(). + * Issuer must not be NULL. + * Returns 1 on success, 0 on failure. + */ +__owur int SCT_CTX_set1_issuer(SCT_CTX *sctx, const X509 *issuer); + +/* + * Sets the public key of the issuer of the certificate that the SCT was created + * for. + * The public key must not be NULL. + * Returns 1 on success, 0 on failure. + */ +__owur int SCT_CTX_set1_issuer_pubkey(SCT_CTX *sctx, X509_PUBKEY *pubkey); + +/* + * Sets the public key of the CT log that the SCT is from. + * Returns 1 on success, 0 on failure. + */ +__owur int SCT_CTX_set1_pubkey(SCT_CTX *sctx, X509_PUBKEY *pubkey); + +/* + * Sets the time to evaluate the SCT against, in milliseconds since the Unix + * epoch. If the SCT's timestamp is after this time, it will be interpreted as + * having been issued in the future. RFC6962 states that "TLS clients MUST + * reject SCTs whose timestamp is in the future", so an SCT will not validate + * in this case. + */ +void SCT_CTX_set_time(SCT_CTX *sctx, uint64_t time_in_ms); + +/* + * Verifies an SCT with the given context. + * Returns 1 if the SCT verifies successfully; any other value indicates + * failure. See EVP_DigestVerifyFinal() for the meaning of those values. + */ +__owur int SCT_CTX_verify(const SCT_CTX *sctx, const SCT *sct); + +/* + * Does this SCT have the minimum fields populated to be usable? + * Returns 1 if so, 0 otherwise. + */ +__owur int SCT_is_complete(const SCT *sct); + +/* + * Does this SCT have the signature-related fields populated? + * Returns 1 if so, 0 otherwise. + * This checks that the signature and hash algorithms are set to supported + * values and that the signature field is set. + */ +__owur int SCT_signature_is_complete(const SCT *sct); + +/* + * TODO(RJPercival): Create an SCT_signature struct and make i2o_SCT_signature + * and o2i_SCT_signature conform to the i2d/d2i conventions. + */ + +/* +* Serialize (to TLS format) an |sct| signature and write it to |out|. +* If |out| is null, no signature will be output but the length will be returned. +* If |out| points to a null pointer, a string will be allocated to hold the +* TLS-format signature. It is the responsibility of the caller to free it. +* If |out| points to an allocated string, the signature will be written to it. +* The length of the signature in TLS format will be returned. +*/ +__owur int i2o_SCT_signature(const SCT *sct, unsigned char **out); + +/* +* Parses an SCT signature in TLS format and populates the |sct| with it. +* |in| should be a pointer to a string containing the TLS-format signature. +* |in| will be advanced to the end of the signature if parsing succeeds. +* |len| should be the length of the signature in |in|. +* Returns the number of bytes parsed, or a negative integer if an error occurs. +* If an error occurs, the SCT's signature NID may be updated whilst the +* signature field itself remains unset. +*/ +__owur int o2i_SCT_signature(SCT *sct, const unsigned char **in, size_t len); + +/* + * Handlers for Certificate Transparency X509v3/OCSP extensions + */ +extern const X509V3_EXT_METHOD v3_ct_scts[3]; diff --git a/contrib/libs/openssl/crypto/ct/ct_oct.c b/contrib/libs/openssl/crypto/ct/ct_oct.c index d95fe4f630..d4b6645af4 100644 --- a/contrib/libs/openssl/crypto/ct/ct_oct.c +++ b/contrib/libs/openssl/crypto/ct/ct_oct.c @@ -19,7 +19,7 @@ #include <openssl/ct.h> #include <openssl/err.h> -#include "ct_local.h" +#include "ct_local.h" int o2i_SCT_signature(SCT *sct, const unsigned char **in, size_t len) { diff --git a/contrib/libs/openssl/crypto/ct/ct_policy.c b/contrib/libs/openssl/crypto/ct/ct_policy.c index 47cba02178..df66e8a494 100644 --- a/contrib/libs/openssl/crypto/ct/ct_policy.c +++ b/contrib/libs/openssl/crypto/ct/ct_policy.c @@ -15,7 +15,7 @@ #include <openssl/err.h> #include <time.h> -#include "ct_local.h" +#include "ct_local.h" /* * Number of seconds in the future that an SCT timestamp can be, by default, diff --git a/contrib/libs/openssl/crypto/ct/ct_prn.c b/contrib/libs/openssl/crypto/ct/ct_prn.c index b6b16703d1..e6584b57f3 100644 --- a/contrib/libs/openssl/crypto/ct/ct_prn.c +++ b/contrib/libs/openssl/crypto/ct/ct_prn.c @@ -14,7 +14,7 @@ #include <openssl/asn1.h> #include <openssl/bio.h> -#include "ct_local.h" +#include "ct_local.h" static void SCT_signature_algorithms_print(const SCT *sct, BIO *out) { diff --git a/contrib/libs/openssl/crypto/ct/ct_sct.c b/contrib/libs/openssl/crypto/ct/ct_sct.c index 023601d301..4ff36e2fbd 100644 --- a/contrib/libs/openssl/crypto/ct/ct_sct.c +++ b/contrib/libs/openssl/crypto/ct/ct_sct.c @@ -17,7 +17,7 @@ #include <openssl/tls1.h> #include <openssl/x509.h> -#include "ct_local.h" +#include "ct_local.h" SCT *SCT_new(void) { diff --git a/contrib/libs/openssl/crypto/ct/ct_sct_ctx.c b/contrib/libs/openssl/crypto/ct/ct_sct_ctx.c index 218239df5d..841e768033 100644 --- a/contrib/libs/openssl/crypto/ct/ct_sct_ctx.c +++ b/contrib/libs/openssl/crypto/ct/ct_sct_ctx.c @@ -18,7 +18,7 @@ #include <openssl/obj_mac.h> #include <openssl/x509.h> -#include "ct_local.h" +#include "ct_local.h" SCT_CTX *SCT_CTX_new(void) { diff --git a/contrib/libs/openssl/crypto/ct/ct_vfy.c b/contrib/libs/openssl/crypto/ct/ct_vfy.c index 90ff7075bb..74fd34f415 100644 --- a/contrib/libs/openssl/crypto/ct/ct_vfy.c +++ b/contrib/libs/openssl/crypto/ct/ct_vfy.c @@ -14,7 +14,7 @@ #include <openssl/evp.h> #include <openssl/x509.h> -#include "ct_local.h" +#include "ct_local.h" typedef enum sct_signature_type_t { SIGNATURE_TYPE_NOT_SET = -1, diff --git a/contrib/libs/openssl/crypto/ct/ct_x509v3.c b/contrib/libs/openssl/crypto/ct/ct_x509v3.c index b339e9a581..19c2a852d2 100644 --- a/contrib/libs/openssl/crypto/ct/ct_x509v3.c +++ b/contrib/libs/openssl/crypto/ct/ct_x509v3.c @@ -11,7 +11,7 @@ # error "CT is disabled" #endif -#include "ct_local.h" +#include "ct_local.h" static char *i2s_poison(const X509V3_EXT_METHOD *method, void *val) { diff --git a/contrib/libs/openssl/crypto/ctype.c b/contrib/libs/openssl/crypto/ctype.c index d12354c92f..b7f1183f9c 100644 --- a/contrib/libs/openssl/crypto/ctype.c +++ b/contrib/libs/openssl/crypto/ctype.c @@ -9,7 +9,7 @@ #include <string.h> #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "openssl/ebcdic.h" /* diff --git a/contrib/libs/openssl/crypto/des/cbc_cksm.c b/contrib/libs/openssl/crypto/des/cbc_cksm.c index 9995bca8e7..c5e2e017b8 100644 --- a/contrib/libs/openssl/crypto/des/cbc_cksm.c +++ b/contrib/libs/openssl/crypto/des/cbc_cksm.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "des_local.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/contrib/libs/openssl/crypto/des/cfb64ede.c b/contrib/libs/openssl/crypto/des/cfb64ede.c index f8f5683431..490d925f46 100644 --- a/contrib/libs/openssl/crypto/des/cfb64ede.c +++ b/contrib/libs/openssl/crypto/des/cfb64ede.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "des_local.h" +#include "des_local.h" /* * The input and output encrypted as though 64bit cfb mode is being used. diff --git a/contrib/libs/openssl/crypto/des/cfb64enc.c b/contrib/libs/openssl/crypto/des/cfb64enc.c index 3b049bc4d1..ca0e821648 100644 --- a/contrib/libs/openssl/crypto/des/cfb64enc.c +++ b/contrib/libs/openssl/crypto/des/cfb64enc.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "des_local.h" +#include "des_local.h" /* * The input and output encrypted as though 64bit cfb mode is being used. diff --git a/contrib/libs/openssl/crypto/des/cfb_enc.c b/contrib/libs/openssl/crypto/des/cfb_enc.c index 2d2ebcd1c4..17018420e6 100644 --- a/contrib/libs/openssl/crypto/des/cfb_enc.c +++ b/contrib/libs/openssl/crypto/des/cfb_enc.c @@ -8,7 +8,7 @@ */ #include "e_os.h" -#include "des_local.h" +#include "des_local.h" #include <assert.h> /* diff --git a/contrib/libs/openssl/crypto/des/des_enc.c b/contrib/libs/openssl/crypto/des/des_enc.c index d4e743c254..45eec615d8 100644 --- a/contrib/libs/openssl/crypto/des/des_enc.c +++ b/contrib/libs/openssl/crypto/des/des_enc.c @@ -8,7 +8,7 @@ */ #include <openssl/crypto.h> -#include "des_local.h" +#include "des_local.h" #include "spr.h" void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) diff --git a/contrib/libs/openssl/crypto/des/des_local.h b/contrib/libs/openssl/crypto/des/des_local.h index c9018239d9..0f58a1c9ae 100644 --- a/contrib/libs/openssl/crypto/des/des_local.h +++ b/contrib/libs/openssl/crypto/des/des_local.h @@ -1,226 +1,226 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_DES_LOCAL_H -# define OSSL_CRYPTO_DES_LOCAL_H - -# include <openssl/e_os2.h> - -# include <stdio.h> -# include <stdlib.h> -# include <string.h> - -# include <openssl/des.h> - -# ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -# endif - -# define ITERATIONS 16 -# define HALF_ITERATIONS 8 - -# define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ - l|=((DES_LONG)(*((c)++)))<< 8L, \ - l|=((DES_LONG)(*((c)++)))<<16L, \ - l|=((DES_LONG)(*((c)++)))<<24L) - -/* NOTE - c is not incremented as per c2l */ -# define c2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \ - /* fall thru */ \ - case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \ - /* fall thru */ \ - case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \ - /* fall thru */ \ - case 5: l2|=((DES_LONG)(*(--(c)))); \ - /* fall thru */ \ - case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \ - /* fall thru */ \ - case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \ - /* fall thru */ \ - case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \ - /* fall thru */ \ - case 1: l1|=((DES_LONG)(*(--(c)))); \ - } \ - } - -# define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24L)&0xff)) - -/* - * replacements for htonl and ntohl since I have no idea what to do when - * faced with machines with 8 byte longs. - */ - -# define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \ - l|=((DES_LONG)(*((c)++)))<<16L, \ - l|=((DES_LONG)(*((c)++)))<< 8L, \ - l|=((DES_LONG)(*((c)++)))) - -# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -/* NOTE - c is not incremented as per l2c */ -# define l2cn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ - /* fall thru */ \ - case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ - /* fall thru */ \ - case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ - /* fall thru */ \ - case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ - /* fall thru */ \ - case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ - /* fall thru */ \ - case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ - /* fall thru */ \ - case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ - /* fall thru */ \ - case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ - } \ - } - -# if defined(_MSC_VER) -# define ROTATE(a,n) (_lrotr(a,n)) -# elif defined(__ICC) -# define ROTATE(a,n) (_rotr(a,n)) -# elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) -# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) -# define ROTATE(a,n) ({ register unsigned int ret; \ - asm ("rorl %1,%0" \ - : "=r"(ret) \ - : "I"(n),"0"(a) \ - : "cc"); \ - ret; \ - }) -# endif -# endif -# ifndef ROTATE -# define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) -# endif - -/* - * Don't worry about the LOAD_DATA() stuff, that is used by fcrypt() to add - * it's little bit to the front - */ - -# ifdef DES_FCRYPT - -# define LOAD_DATA_tmp(R,S,u,t,E0,E1) \ - { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); } - -# define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ - t=R^(R>>16L); \ - u=t&E0; t&=E1; \ - tmp=(u<<16); u^=R^s[S ]; u^=tmp; \ - tmp=(t<<16); t^=R^s[S+1]; t^=tmp -# else -# define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g) -# define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ - u=R^s[S ]; \ - t=R^s[S+1] -# endif - -/* - * It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there is no reason - * to not xor all the sub items together. This potentially saves a register - * since things can be xored directly into L - */ - -# define D_ENCRYPT(LL,R,S) { \ - LOAD_DATA_tmp(R,S,u,t,E0,E1); \ - t=ROTATE(t,4); \ - LL^= \ - DES_SPtrans[0][(u>> 2L)&0x3f]^ \ - DES_SPtrans[2][(u>>10L)&0x3f]^ \ - DES_SPtrans[4][(u>>18L)&0x3f]^ \ - DES_SPtrans[6][(u>>26L)&0x3f]^ \ - DES_SPtrans[1][(t>> 2L)&0x3f]^ \ - DES_SPtrans[3][(t>>10L)&0x3f]^ \ - DES_SPtrans[5][(t>>18L)&0x3f]^ \ - DES_SPtrans[7][(t>>26L)&0x3f]; } - - /*- - * IP and FP - * The problem is more of a geometric problem that random bit fiddling. - 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6 - 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4 - 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2 - 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0 - - 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7 - 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5 - 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3 - 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1 - - The output has been subject to swaps of the form - 0 1 -> 3 1 but the odd and even bits have been put into - 2 3 2 0 - different words. The main trick is to remember that - t=((l>>size)^r)&(mask); - r^=t; - l^=(t<<size); - can be used to swap and move bits between words. - - So l = 0 1 2 3 r = 16 17 18 19 - 4 5 6 7 20 21 22 23 - 8 9 10 11 24 25 26 27 - 12 13 14 15 28 29 30 31 - becomes (for size == 2 and mask == 0x3333) - t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19 - 6^20 7^21 -- -- 4 5 20 21 6 7 22 23 - 10^24 11^25 -- -- 8 9 24 25 10 11 24 25 - 14^28 15^29 -- -- 12 13 28 29 14 15 28 29 - - Thanks for hints from Richard Outerbridge - he told me IP&FP - could be done in 15 xor, 10 shifts and 5 ands. - When I finally started to think of the problem in 2D - I first got ~42 operations without xors. When I remembered - how to use xors :-) I got it to its final state. - */ -# define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ - (b)^=(t),\ - (a)^=((t)<<(n))) - -# define IP(l,r) \ - { \ - register DES_LONG tt; \ - PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \ - PERM_OP(l,r,tt,16,0x0000ffffL); \ - PERM_OP(r,l,tt, 2,0x33333333L); \ - PERM_OP(l,r,tt, 8,0x00ff00ffL); \ - PERM_OP(r,l,tt, 1,0x55555555L); \ - } - -# define FP(l,r) \ - { \ - register DES_LONG tt; \ - PERM_OP(l,r,tt, 1,0x55555555L); \ - PERM_OP(r,l,tt, 8,0x00ff00ffL); \ - PERM_OP(l,r,tt, 2,0x33333333L); \ - PERM_OP(r,l,tt,16,0x0000ffffL); \ - PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ - } - -extern const DES_LONG DES_SPtrans[8][64]; - -void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, - DES_LONG Eswap0, DES_LONG Eswap1); - -#endif +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_DES_LOCAL_H +# define OSSL_CRYPTO_DES_LOCAL_H + +# include <openssl/e_os2.h> + +# include <stdio.h> +# include <stdlib.h> +# include <string.h> + +# include <openssl/des.h> + +# ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +# endif + +# define ITERATIONS 16 +# define HALF_ITERATIONS 8 + +# define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \ + l|=((DES_LONG)(*((c)++)))<< 8L, \ + l|=((DES_LONG)(*((c)++)))<<16L, \ + l|=((DES_LONG)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +# define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \ + /* fall thru */ \ + case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \ + /* fall thru */ \ + case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \ + /* fall thru */ \ + case 5: l2|=((DES_LONG)(*(--(c)))); \ + /* fall thru */ \ + case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \ + /* fall thru */ \ + case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \ + /* fall thru */ \ + case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \ + /* fall thru */ \ + case 1: l1|=((DES_LONG)(*(--(c)))); \ + } \ + } + +# define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* + * replacements for htonl and ntohl since I have no idea what to do when + * faced with machines with 8 byte longs. + */ + +# define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \ + l|=((DES_LONG)(*((c)++)))<<16L, \ + l|=((DES_LONG)(*((c)++)))<< 8L, \ + l|=((DES_LONG)(*((c)++)))) + +# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +/* NOTE - c is not incremented as per l2c */ +# define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + /* fall thru */ \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + /* fall thru */ \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + /* fall thru */ \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + /* fall thru */ \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + /* fall thru */ \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + /* fall thru */ \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + /* fall thru */ \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +# if defined(_MSC_VER) +# define ROTATE(a,n) (_lrotr(a,n)) +# elif defined(__ICC) +# define ROTATE(a,n) (_rotr(a,n)) +# elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) +# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) +# define ROTATE(a,n) ({ register unsigned int ret; \ + asm ("rorl %1,%0" \ + : "=r"(ret) \ + : "I"(n),"0"(a) \ + : "cc"); \ + ret; \ + }) +# endif +# endif +# ifndef ROTATE +# define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) +# endif + +/* + * Don't worry about the LOAD_DATA() stuff, that is used by fcrypt() to add + * it's little bit to the front + */ + +# ifdef DES_FCRYPT + +# define LOAD_DATA_tmp(R,S,u,t,E0,E1) \ + { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); } + +# define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ + t=R^(R>>16L); \ + u=t&E0; t&=E1; \ + tmp=(u<<16); u^=R^s[S ]; u^=tmp; \ + tmp=(t<<16); t^=R^s[S+1]; t^=tmp +# else +# define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g) +# define LOAD_DATA(R,S,u,t,E0,E1,tmp) \ + u=R^s[S ]; \ + t=R^s[S+1] +# endif + +/* + * It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there is no reason + * to not xor all the sub items together. This potentially saves a register + * since things can be xored directly into L + */ + +# define D_ENCRYPT(LL,R,S) { \ + LOAD_DATA_tmp(R,S,u,t,E0,E1); \ + t=ROTATE(t,4); \ + LL^= \ + DES_SPtrans[0][(u>> 2L)&0x3f]^ \ + DES_SPtrans[2][(u>>10L)&0x3f]^ \ + DES_SPtrans[4][(u>>18L)&0x3f]^ \ + DES_SPtrans[6][(u>>26L)&0x3f]^ \ + DES_SPtrans[1][(t>> 2L)&0x3f]^ \ + DES_SPtrans[3][(t>>10L)&0x3f]^ \ + DES_SPtrans[5][(t>>18L)&0x3f]^ \ + DES_SPtrans[7][(t>>26L)&0x3f]; } + + /*- + * IP and FP + * The problem is more of a geometric problem that random bit fiddling. + 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6 + 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4 + 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2 + 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0 + + 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7 + 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5 + 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3 + 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1 + + The output has been subject to swaps of the form + 0 1 -> 3 1 but the odd and even bits have been put into + 2 3 2 0 + different words. The main trick is to remember that + t=((l>>size)^r)&(mask); + r^=t; + l^=(t<<size); + can be used to swap and move bits between words. + + So l = 0 1 2 3 r = 16 17 18 19 + 4 5 6 7 20 21 22 23 + 8 9 10 11 24 25 26 27 + 12 13 14 15 28 29 30 31 + becomes (for size == 2 and mask == 0x3333) + t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19 + 6^20 7^21 -- -- 4 5 20 21 6 7 22 23 + 10^24 11^25 -- -- 8 9 24 25 10 11 24 25 + 14^28 15^29 -- -- 12 13 28 29 14 15 28 29 + + Thanks for hints from Richard Outerbridge - he told me IP&FP + could be done in 15 xor, 10 shifts and 5 ands. + When I finally started to think of the problem in 2D + I first got ~42 operations without xors. When I remembered + how to use xors :-) I got it to its final state. + */ +# define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\ + (b)^=(t),\ + (a)^=((t)<<(n))) + +# define IP(l,r) \ + { \ + register DES_LONG tt; \ + PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \ + PERM_OP(l,r,tt,16,0x0000ffffL); \ + PERM_OP(r,l,tt, 2,0x33333333L); \ + PERM_OP(l,r,tt, 8,0x00ff00ffL); \ + PERM_OP(r,l,tt, 1,0x55555555L); \ + } + +# define FP(l,r) \ + { \ + register DES_LONG tt; \ + PERM_OP(l,r,tt, 1,0x55555555L); \ + PERM_OP(r,l,tt, 8,0x00ff00ffL); \ + PERM_OP(l,r,tt, 2,0x33333333L); \ + PERM_OP(r,l,tt,16,0x0000ffffL); \ + PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ + } + +extern const DES_LONG DES_SPtrans[8][64]; + +void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, + DES_LONG Eswap0, DES_LONG Eswap1); + +#endif diff --git a/contrib/libs/openssl/crypto/des/ecb3_enc.c b/contrib/libs/openssl/crypto/des/ecb3_enc.c index 9a1286f8ed..7afa8eaadd 100644 --- a/contrib/libs/openssl/crypto/des/ecb3_enc.c +++ b/contrib/libs/openssl/crypto/des/ecb3_enc.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "des_local.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/contrib/libs/openssl/crypto/des/ecb_enc.c b/contrib/libs/openssl/crypto/des/ecb_enc.c index afba573f34..513c65e116 100644 --- a/contrib/libs/openssl/crypto/des/ecb_enc.c +++ b/contrib/libs/openssl/crypto/des/ecb_enc.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "des_local.h" +#include "des_local.h" #include <openssl/opensslv.h> #include <openssl/bio.h> diff --git a/contrib/libs/openssl/crypto/des/fcrypt.c b/contrib/libs/openssl/crypto/des/fcrypt.c index 7ca8f77f5e..e83cf76b61 100644 --- a/contrib/libs/openssl/crypto/des/fcrypt.c +++ b/contrib/libs/openssl/crypto/des/fcrypt.c @@ -19,7 +19,7 @@ #endif #include <openssl/crypto.h> -#include "des_local.h" +#include "des_local.h" /* * Added more values to handle illegal salt values the way normal crypt() diff --git a/contrib/libs/openssl/crypto/des/fcrypt_b.c b/contrib/libs/openssl/crypto/des/fcrypt_b.c index 92d5f104c7..22f967b8c6 100644 --- a/contrib/libs/openssl/crypto/des/fcrypt_b.c +++ b/contrib/libs/openssl/crypto/des/fcrypt_b.c @@ -10,7 +10,7 @@ #include <stdio.h> #define DES_FCRYPT -#include "des_local.h" +#include "des_local.h" #undef DES_FCRYPT #undef PERM_OP diff --git a/contrib/libs/openssl/crypto/des/ncbc_enc.c b/contrib/libs/openssl/crypto/des/ncbc_enc.c index f3c151339e..cd4b071a3d 100644 --- a/contrib/libs/openssl/crypto/des/ncbc_enc.c +++ b/contrib/libs/openssl/crypto/des/ncbc_enc.c @@ -13,7 +13,7 @@ * des_enc.c (DES_ncbc_encrypt) */ -#include "des_local.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/contrib/libs/openssl/crypto/des/ofb64ede.c b/contrib/libs/openssl/crypto/des/ofb64ede.c index f105e201d3..68cf2dc557 100644 --- a/contrib/libs/openssl/crypto/des/ofb64ede.c +++ b/contrib/libs/openssl/crypto/des/ofb64ede.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "des_local.h" +#include "des_local.h" /* * The input and output encrypted as though 64bit ofb mode is being used. diff --git a/contrib/libs/openssl/crypto/des/ofb64enc.c b/contrib/libs/openssl/crypto/des/ofb64enc.c index ae221f65d7..5796980c18 100644 --- a/contrib/libs/openssl/crypto/des/ofb64enc.c +++ b/contrib/libs/openssl/crypto/des/ofb64enc.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "des_local.h" +#include "des_local.h" /* * The input and output encrypted as though 64bit ofb mode is being used. diff --git a/contrib/libs/openssl/crypto/des/ofb_enc.c b/contrib/libs/openssl/crypto/des/ofb_enc.c index 7bba21d27e..2b0498994b 100644 --- a/contrib/libs/openssl/crypto/des/ofb_enc.c +++ b/contrib/libs/openssl/crypto/des/ofb_enc.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "des_local.h" +#include "des_local.h" /* * The input and output are loaded in multiples of 8 bits. What this means is diff --git a/contrib/libs/openssl/crypto/des/pcbc_enc.c b/contrib/libs/openssl/crypto/des/pcbc_enc.c index 492eb773a3..3490592741 100644 --- a/contrib/libs/openssl/crypto/des/pcbc_enc.c +++ b/contrib/libs/openssl/crypto/des/pcbc_enc.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "des_local.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/contrib/libs/openssl/crypto/des/qud_cksm.c b/contrib/libs/openssl/crypto/des/qud_cksm.c index bc9366e683..10b6abf69e 100644 --- a/contrib/libs/openssl/crypto/des/qud_cksm.c +++ b/contrib/libs/openssl/crypto/des/qud_cksm.c @@ -13,7 +13,7 @@ * only based on the code in this paper and is almost definitely not the same * as the MIT implementation. */ -#include "des_local.h" +#include "des_local.h" #define Q_B0(a) (((DES_LONG)(a))) #define Q_B1(a) (((DES_LONG)(a))<<8) diff --git a/contrib/libs/openssl/crypto/des/set_key.c b/contrib/libs/openssl/crypto/des/set_key.c index 2a4cd810be..cbcb616cb2 100644 --- a/contrib/libs/openssl/crypto/des/set_key.c +++ b/contrib/libs/openssl/crypto/des/set_key.c @@ -16,7 +16,7 @@ * 1.0 First working version */ #include <openssl/crypto.h> -#include "des_local.h" +#include "des_local.h" /* defaults to false */ OPENSSL_IMPLEMENT_GLOBAL(int, DES_check_key, 0) diff --git a/contrib/libs/openssl/crypto/des/str2key.c b/contrib/libs/openssl/crypto/des/str2key.c index b2d4a2f3ed..61db605125 100644 --- a/contrib/libs/openssl/crypto/des/str2key.c +++ b/contrib/libs/openssl/crypto/des/str2key.c @@ -8,7 +8,7 @@ */ #include <openssl/crypto.h> -#include "des_local.h" +#include "des_local.h" void DES_string_to_key(const char *str, DES_cblock *key) { diff --git a/contrib/libs/openssl/crypto/des/xcbc_enc.c b/contrib/libs/openssl/crypto/des/xcbc_enc.c index 55775ce7f8..fb3fd5292c 100644 --- a/contrib/libs/openssl/crypto/des/xcbc_enc.c +++ b/contrib/libs/openssl/crypto/des/xcbc_enc.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "des_local.h" +#include "des_local.h" /* RSA's DESX */ diff --git a/contrib/libs/openssl/crypto/dh/dh_ameth.c b/contrib/libs/openssl/crypto/dh/dh_ameth.c index d7df859592..d53004080d 100644 --- a/contrib/libs/openssl/crypto/dh/dh_ameth.c +++ b/contrib/libs/openssl/crypto/dh/dh_ameth.c @@ -11,10 +11,10 @@ #include "internal/cryptlib.h" #include <openssl/x509.h> #include <openssl/asn1.h> -#include "dh_local.h" +#include "dh_local.h" #include <openssl/bn.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" #include <openssl/cms.h> /* @@ -901,7 +901,7 @@ static int dh_cms_encrypt(CMS_RecipientInfo *ri) err: OPENSSL_free(penc); X509_ALGOR_free(wrap_alg); - OPENSSL_free(dukm); + OPENSSL_free(dukm); return rv; } diff --git a/contrib/libs/openssl/crypto/dh/dh_asn1.c b/contrib/libs/openssl/crypto/dh/dh_asn1.c index 5bde16e134..e37f0904e5 100644 --- a/contrib/libs/openssl/crypto/dh/dh_asn1.c +++ b/contrib/libs/openssl/crypto/dh/dh_asn1.c @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/bn.h> -#include "dh_local.h" +#include "dh_local.h" #include <openssl/objects.h> #include <openssl/asn1t.h> diff --git a/contrib/libs/openssl/crypto/dh/dh_check.c b/contrib/libs/openssl/crypto/dh/dh_check.c index 086eb8ae4b..4ac169e75c 100644 --- a/contrib/libs/openssl/crypto/dh/dh_check.c +++ b/contrib/libs/openssl/crypto/dh/dh_check.c @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/bn.h> -#include "dh_local.h" +#include "dh_local.h" # define DH_NUMBER_ITERATIONS_FOR_PRIME 64 diff --git a/contrib/libs/openssl/crypto/dh/dh_gen.c b/contrib/libs/openssl/crypto/dh/dh_gen.c index 89ef86c88f..ab82ab58bd 100644 --- a/contrib/libs/openssl/crypto/dh/dh_gen.c +++ b/contrib/libs/openssl/crypto/dh/dh_gen.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -15,7 +15,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/bn.h> -#include "dh_local.h" +#include "dh_local.h" static int dh_builtin_genparams(DH *ret, int prime_len, int generator, BN_GENCB *cb); @@ -54,7 +54,7 @@ int DH_generate_parameters_ex(DH *ret, int prime_len, int generator, * for 3, p mod 12 == 11 * for 5, p mod 60 == 59 * - * However for compatibility with previous versions we use: + * However for compatibility with previous versions we use: * for 2, p mod 24 == 11 * for 5, p mod 60 == 23 */ diff --git a/contrib/libs/openssl/crypto/dh/dh_key.c b/contrib/libs/openssl/crypto/dh/dh_key.c index 3d4d164485..117f2fa883 100644 --- a/contrib/libs/openssl/crypto/dh/dh_key.c +++ b/contrib/libs/openssl/crypto/dh/dh_key.c @@ -9,8 +9,8 @@ #include <stdio.h> #include "internal/cryptlib.h" -#include "dh_local.h" -#include "crypto/bn.h" +#include "dh_local.h" +#include "crypto/bn.h" static int generate_key(DH *dh); static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); diff --git a/contrib/libs/openssl/crypto/dh/dh_lib.c b/contrib/libs/openssl/crypto/dh/dh_lib.c index 873394cecc..04b79d355c 100644 --- a/contrib/libs/openssl/crypto/dh/dh_lib.c +++ b/contrib/libs/openssl/crypto/dh/dh_lib.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include "internal/refcount.h" #include <openssl/bn.h> -#include "dh_local.h" +#include "dh_local.h" #include <openssl/engine.h> int DH_set_method(DH *dh, const DH_METHOD *meth) diff --git a/contrib/libs/openssl/crypto/dh/dh_local.h b/contrib/libs/openssl/crypto/dh/dh_local.h index b4f1ac926e..0a8391a6c0 100644 --- a/contrib/libs/openssl/crypto/dh/dh_local.h +++ b/contrib/libs/openssl/crypto/dh/dh_local.h @@ -1,57 +1,57 @@ -/* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <openssl/dh.h> -#include "internal/refcount.h" - -struct dh_st { - /* - * This first argument is used to pick up errors when a DH is passed - * instead of a EVP_PKEY - */ - int pad; - int version; - BIGNUM *p; - BIGNUM *g; - int32_t length; /* optional */ - BIGNUM *pub_key; /* g^x % p */ - BIGNUM *priv_key; /* x */ - int flags; - BN_MONT_CTX *method_mont_p; - /* Place holders if we want to do X9.42 DH */ - BIGNUM *q; - BIGNUM *j; - unsigned char *seed; - int seedlen; - BIGNUM *counter; - CRYPTO_REF_COUNT references; - CRYPTO_EX_DATA ex_data; - const DH_METHOD *meth; - ENGINE *engine; - CRYPTO_RWLOCK *lock; -}; - -struct dh_method { - char *name; - /* Methods here */ - int (*generate_key) (DH *dh); - int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh); - - /* Can be null */ - int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a, - const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *m_ctx); - int (*init) (DH *dh); - int (*finish) (DH *dh); - int flags; - char *app_data; - /* If this is non-NULL, it will be used to generate parameters */ - int (*generate_params) (DH *dh, int prime_len, int generator, - BN_GENCB *cb); -}; +/* + * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <openssl/dh.h> +#include "internal/refcount.h" + +struct dh_st { + /* + * This first argument is used to pick up errors when a DH is passed + * instead of a EVP_PKEY + */ + int pad; + int version; + BIGNUM *p; + BIGNUM *g; + int32_t length; /* optional */ + BIGNUM *pub_key; /* g^x % p */ + BIGNUM *priv_key; /* x */ + int flags; + BN_MONT_CTX *method_mont_p; + /* Place holders if we want to do X9.42 DH */ + BIGNUM *q; + BIGNUM *j; + unsigned char *seed; + int seedlen; + BIGNUM *counter; + CRYPTO_REF_COUNT references; + CRYPTO_EX_DATA ex_data; + const DH_METHOD *meth; + ENGINE *engine; + CRYPTO_RWLOCK *lock; +}; + +struct dh_method { + char *name; + /* Methods here */ + int (*generate_key) (DH *dh); + int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh); + + /* Can be null */ + int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a, + const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *m_ctx); + int (*init) (DH *dh); + int (*finish) (DH *dh); + int flags; + char *app_data; + /* If this is non-NULL, it will be used to generate parameters */ + int (*generate_params) (DH *dh, int prime_len, int generator, + BN_GENCB *cb); +}; diff --git a/contrib/libs/openssl/crypto/dh/dh_meth.c b/contrib/libs/openssl/crypto/dh/dh_meth.c index 5fb1c2c2ee..8a54a8108f 100644 --- a/contrib/libs/openssl/crypto/dh/dh_meth.c +++ b/contrib/libs/openssl/crypto/dh/dh_meth.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "dh_local.h" +#include "dh_local.h" #include <string.h> #include <openssl/err.h> diff --git a/contrib/libs/openssl/crypto/dh/dh_pmeth.c b/contrib/libs/openssl/crypto/dh/dh_pmeth.c index 0528c71b4e..1fd94deb47 100644 --- a/contrib/libs/openssl/crypto/dh/dh_pmeth.c +++ b/contrib/libs/openssl/crypto/dh/dh_pmeth.c @@ -12,11 +12,11 @@ #include <openssl/asn1t.h> #include <openssl/x509.h> #include <openssl/evp.h> -#include "dh_local.h" +#include "dh_local.h" #include <openssl/bn.h> #include <openssl/dsa.h> #include <openssl/objects.h> -#include "crypto/evp.h" +#include "crypto/evp.h" /* DH pkey context structure */ diff --git a/contrib/libs/openssl/crypto/dh/dh_rfc5114.c b/contrib/libs/openssl/crypto/dh/dh_rfc5114.c index cbc800ba82..e3603a05a3 100644 --- a/contrib/libs/openssl/crypto/dh/dh_rfc5114.c +++ b/contrib/libs/openssl/crypto/dh/dh_rfc5114.c @@ -9,9 +9,9 @@ #include <stdio.h> #include "internal/cryptlib.h" -#include "dh_local.h" +#include "dh_local.h" #include <openssl/bn.h> -#include "crypto/bn_dh.h" +#include "crypto/bn_dh.h" /* * Macro to make a DH structure from BIGNUM data. NB: although just copying diff --git a/contrib/libs/openssl/crypto/dh/dh_rfc7919.c b/contrib/libs/openssl/crypto/dh/dh_rfc7919.c index 37167b358b..03d30a1f5d 100644 --- a/contrib/libs/openssl/crypto/dh/dh_rfc7919.c +++ b/contrib/libs/openssl/crypto/dh/dh_rfc7919.c @@ -9,10 +9,10 @@ #include <stdio.h> #include "internal/cryptlib.h" -#include "dh_local.h" +#include "dh_local.h" #include <openssl/bn.h> #include <openssl/objects.h> -#include "crypto/bn_dh.h" +#include "crypto/bn_dh.h" static DH *dh_param_init(const BIGNUM *p, int32_t nbits) { diff --git a/contrib/libs/openssl/crypto/dllmain.c b/contrib/libs/openssl/crypto/dllmain.c index 38f973ae29..e8217893b9 100644 --- a/contrib/libs/openssl/crypto/dllmain.c +++ b/contrib/libs/openssl/crypto/dllmain.c @@ -8,7 +8,7 @@ */ #include "e_os.h" -#include "crypto/cryptlib.h" +#include "crypto/cryptlib.h" #if defined(_WIN32) || defined(__CYGWIN__) # ifdef __CYGWIN__ diff --git a/contrib/libs/openssl/crypto/dsa/dsa_ameth.c b/contrib/libs/openssl/crypto/dsa/dsa_ameth.c index 822ae471d6..2dcaa0815f 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_ameth.c +++ b/contrib/libs/openssl/crypto/dsa/dsa_ameth.c @@ -11,11 +11,11 @@ #include "internal/cryptlib.h" #include <openssl/x509.h> #include <openssl/asn1.h> -#include "dsa_local.h" +#include "dsa_local.h" #include <openssl/bn.h> #include <openssl/cms.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" static int dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) { diff --git a/contrib/libs/openssl/crypto/dsa/dsa_asn1.c b/contrib/libs/openssl/crypto/dsa/dsa_asn1.c index aa7dbe2073..9cafd5ca8a 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_asn1.c +++ b/contrib/libs/openssl/crypto/dsa/dsa_asn1.c @@ -9,7 +9,7 @@ #include <stdio.h> #include "internal/cryptlib.h" -#include "dsa_local.h" +#include "dsa_local.h" #include <openssl/asn1.h> #include <openssl/asn1t.h> #include <openssl/rand.h> diff --git a/contrib/libs/openssl/crypto/dsa/dsa_gen.c b/contrib/libs/openssl/crypto/dsa/dsa_gen.c index 589e5c5966..5d066a06c5 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_gen.c +++ b/contrib/libs/openssl/crypto/dsa/dsa_gen.c @@ -21,7 +21,7 @@ #include <openssl/bn.h> #include <openssl/rand.h> #include <openssl/sha.h> -#include "dsa_local.h" +#include "dsa_local.h" int DSA_generate_parameters_ex(DSA *ret, int bits, const unsigned char *seed_in, int seed_len, diff --git a/contrib/libs/openssl/crypto/dsa/dsa_key.c b/contrib/libs/openssl/crypto/dsa/dsa_key.c index 1aa5782098..bdeddd4f61 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_key.c +++ b/contrib/libs/openssl/crypto/dsa/dsa_key.c @@ -11,7 +11,7 @@ #include <time.h> #include "internal/cryptlib.h" #include <openssl/bn.h> -#include "dsa_local.h" +#include "dsa_local.h" static int dsa_builtin_keygen(DSA *dsa); diff --git a/contrib/libs/openssl/crypto/dsa/dsa_lib.c b/contrib/libs/openssl/crypto/dsa/dsa_lib.c index cd5527939b..f98af5853d 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_lib.c +++ b/contrib/libs/openssl/crypto/dsa/dsa_lib.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include "internal/refcount.h" #include <openssl/bn.h> -#include "dsa_local.h" +#include "dsa_local.h" #include <openssl/asn1.h> #include <openssl/engine.h> #include <openssl/dh.h> diff --git a/contrib/libs/openssl/crypto/dsa/dsa_local.h b/contrib/libs/openssl/crypto/dsa/dsa_local.h index 7d7db176ca..a81a4b4978 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_local.h +++ b/contrib/libs/openssl/crypto/dsa/dsa_local.h @@ -1,77 +1,77 @@ -/* - * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <openssl/dsa.h> -#include "internal/refcount.h" - -struct dsa_st { - /* - * This first variable is used to pick up errors where a DSA is passed - * instead of of a EVP_PKEY - */ - int pad; - int32_t version; - BIGNUM *p; - BIGNUM *q; /* == 20 */ - BIGNUM *g; - BIGNUM *pub_key; /* y public key */ - BIGNUM *priv_key; /* x private key */ - int flags; - /* Normally used to cache montgomery values */ - BN_MONT_CTX *method_mont_p; - CRYPTO_REF_COUNT references; - CRYPTO_EX_DATA ex_data; - const DSA_METHOD *meth; - /* functional reference if 'meth' is ENGINE-provided */ - ENGINE *engine; - CRYPTO_RWLOCK *lock; -}; - -struct DSA_SIG_st { - BIGNUM *r; - BIGNUM *s; -}; - -struct dsa_method { - char *name; - DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa); - int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, - BIGNUM **rp); - int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len, - DSA_SIG *sig, DSA *dsa); - int (*dsa_mod_exp) (DSA *dsa, 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); - /* Can be null */ - int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); - int (*init) (DSA *dsa); - int (*finish) (DSA *dsa); - int flags; - void *app_data; - /* If this is non-NULL, it is used to generate DSA parameters */ - int (*dsa_paramgen) (DSA *dsa, int bits, - const unsigned char *seed, int seed_len, - int *counter_ret, unsigned long *h_ret, - BN_GENCB *cb); - /* If this is non-NULL, it is used to generate DSA keys */ - int (*dsa_keygen) (DSA *dsa); -}; - -int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, - const EVP_MD *evpmd, const unsigned char *seed_in, - size_t seed_len, unsigned char *seed_out, - int *counter_ret, unsigned long *h_ret, - BN_GENCB *cb); - -int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N, - const EVP_MD *evpmd, const unsigned char *seed_in, - size_t seed_len, int idx, unsigned char *seed_out, - int *counter_ret, unsigned long *h_ret, - BN_GENCB *cb); +/* + * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <openssl/dsa.h> +#include "internal/refcount.h" + +struct dsa_st { + /* + * This first variable is used to pick up errors where a DSA is passed + * instead of of a EVP_PKEY + */ + int pad; + int32_t version; + BIGNUM *p; + BIGNUM *q; /* == 20 */ + BIGNUM *g; + BIGNUM *pub_key; /* y public key */ + BIGNUM *priv_key; /* x private key */ + int flags; + /* Normally used to cache montgomery values */ + BN_MONT_CTX *method_mont_p; + CRYPTO_REF_COUNT references; + CRYPTO_EX_DATA ex_data; + const DSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + CRYPTO_RWLOCK *lock; +}; + +struct DSA_SIG_st { + BIGNUM *r; + BIGNUM *s; +}; + +struct dsa_method { + char *name; + DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa); + int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp); + int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len, + DSA_SIG *sig, DSA *dsa); + int (*dsa_mod_exp) (DSA *dsa, 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); + /* Can be null */ + int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); + int (*init) (DSA *dsa); + int (*finish) (DSA *dsa); + int flags; + void *app_data; + /* If this is non-NULL, it is used to generate DSA parameters */ + int (*dsa_paramgen) (DSA *dsa, int bits, + const unsigned char *seed, int seed_len, + int *counter_ret, unsigned long *h_ret, + BN_GENCB *cb); + /* If this is non-NULL, it is used to generate DSA keys */ + int (*dsa_keygen) (DSA *dsa); +}; + +int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, + const EVP_MD *evpmd, const unsigned char *seed_in, + size_t seed_len, unsigned char *seed_out, + int *counter_ret, unsigned long *h_ret, + BN_GENCB *cb); + +int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N, + const EVP_MD *evpmd, const unsigned char *seed_in, + size_t seed_len, int idx, unsigned char *seed_out, + int *counter_ret, unsigned long *h_ret, + BN_GENCB *cb); diff --git a/contrib/libs/openssl/crypto/dsa/dsa_meth.c b/contrib/libs/openssl/crypto/dsa/dsa_meth.c index 55cee9df8e..1e6ee2f4ed 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_meth.c +++ b/contrib/libs/openssl/crypto/dsa/dsa_meth.c @@ -15,7 +15,7 @@ * or in the file LICENSE in the source distribution. */ -#include "dsa_local.h" +#include "dsa_local.h" #include <string.h> #include <openssl/err.h> diff --git a/contrib/libs/openssl/crypto/dsa/dsa_ossl.c b/contrib/libs/openssl/crypto/dsa/dsa_ossl.c index fd1d476861..a983def64e 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_ossl.c +++ b/contrib/libs/openssl/crypto/dsa/dsa_ossl.c @@ -9,10 +9,10 @@ #include <stdio.h> #include "internal/cryptlib.h" -#include "crypto/bn.h" +#include "crypto/bn.h" #include <openssl/bn.h> #include <openssl/sha.h> -#include "dsa_local.h" +#include "dsa_local.h" #include <openssl/asn1.h> static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); diff --git a/contrib/libs/openssl/crypto/dsa/dsa_pmeth.c b/contrib/libs/openssl/crypto/dsa/dsa_pmeth.c index 2440fd0387..4ca3747a46 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_pmeth.c +++ b/contrib/libs/openssl/crypto/dsa/dsa_pmeth.c @@ -13,8 +13,8 @@ #include <openssl/x509.h> #include <openssl/evp.h> #include <openssl/bn.h> -#include "crypto/evp.h" -#include "dsa_local.h" +#include "crypto/evp.h" +#include "dsa_local.h" /* DSA pkey context structure */ @@ -178,7 +178,7 @@ static int pkey_dsa_ctrl_str(EVP_PKEY_CTX *ctx, } if (strcmp(type, "dsa_paramgen_q_bits") == 0) { int qbits = atoi(value); - return EVP_PKEY_CTX_set_dsa_paramgen_q_bits(ctx, qbits); + return EVP_PKEY_CTX_set_dsa_paramgen_q_bits(ctx, qbits); } if (strcmp(type, "dsa_paramgen_md") == 0) { const EVP_MD *md = EVP_get_digestbyname(value); @@ -187,7 +187,7 @@ static int pkey_dsa_ctrl_str(EVP_PKEY_CTX *ctx, DSAerr(DSA_F_PKEY_DSA_CTRL_STR, DSA_R_INVALID_DIGEST_TYPE); return 0; } - return EVP_PKEY_CTX_set_dsa_paramgen_md(ctx, md); + return EVP_PKEY_CTX_set_dsa_paramgen_md(ctx, md); } return -2; } diff --git a/contrib/libs/openssl/crypto/dsa/dsa_sign.c b/contrib/libs/openssl/crypto/dsa/dsa_sign.c index 452d86f8b2..51c7754b93 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_sign.c +++ b/contrib/libs/openssl/crypto/dsa/dsa_sign.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "dsa_local.h" +#include "dsa_local.h" #include <openssl/bn.h> DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) diff --git a/contrib/libs/openssl/crypto/dsa/dsa_vrf.c b/contrib/libs/openssl/crypto/dsa/dsa_vrf.c index e4b934e304..6f80a4aab7 100644 --- a/contrib/libs/openssl/crypto/dsa/dsa_vrf.c +++ b/contrib/libs/openssl/crypto/dsa/dsa_vrf.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "dsa_local.h" +#include "dsa_local.h" int DSA_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig, DSA *dsa) diff --git a/contrib/libs/openssl/crypto/dso/dso_dl.c b/contrib/libs/openssl/crypto/dso/dso_dl.c index 3f4d11b353..3bbb10e5ca 100644 --- a/contrib/libs/openssl/crypto/dso/dso_dl.c +++ b/contrib/libs/openssl/crypto/dso/dso_dl.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "dso_local.h" +#include "dso_local.h" #ifdef DSO_DL diff --git a/contrib/libs/openssl/crypto/dso/dso_dlfcn.c b/contrib/libs/openssl/crypto/dso/dso_dlfcn.c index 430553438f..b926cb3021 100644 --- a/contrib/libs/openssl/crypto/dso/dso_dlfcn.c +++ b/contrib/libs/openssl/crypto/dso/dso_dlfcn.c @@ -16,7 +16,7 @@ # define _GNU_SOURCE /* make sure dladdr is declared */ #endif -#include "dso_local.h" +#include "dso_local.h" #include "e_os.h" #ifdef DSO_DLFCN @@ -324,7 +324,7 @@ static int dladdr(void *address, Dl_info *dl) * Base Operating System and Extensions, Volume 1 and 2 * https://www.ibm.com/support/knowledgecenter/ssw_aix_72/com.ibm.aix.base/technicalreferences.htm */ -# error #include <sys/ldr.h> +# error #include <sys/ldr.h> # include <errno.h> /* ~ 64 * (sizeof(struct ld_info) + _XOPEN_PATH_MAX + _XOPEN_NAME_MAX) */ # define DLFCN_LDINFO_SIZE 86976 diff --git a/contrib/libs/openssl/crypto/dso/dso_lib.c b/contrib/libs/openssl/crypto/dso/dso_lib.c index 1d5bdee4a5..50a39bb7d5 100644 --- a/contrib/libs/openssl/crypto/dso/dso_lib.c +++ b/contrib/libs/openssl/crypto/dso/dso_lib.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "dso_local.h" +#include "dso_local.h" #include "internal/refcount.h" static DSO_METHOD *default_DSO_meth = NULL; diff --git a/contrib/libs/openssl/crypto/dso/dso_local.h b/contrib/libs/openssl/crypto/dso/dso_local.h index 209e5bcb04..43b7df9d78 100644 --- a/contrib/libs/openssl/crypto/dso/dso_local.h +++ b/contrib/libs/openssl/crypto/dso/dso_local.h @@ -1,107 +1,107 @@ -/* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <stdio.h> -#include "internal/cryptlib.h" -#include "internal/dso.h" -#include "crypto/dso_conf.h" -#include "internal/refcount.h" - -/**********************************************************************/ -/* The low-level handle type used to refer to a loaded shared library */ - -struct dso_st { - DSO_METHOD *meth; - /* - * Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS doesn't use - * anything but will need to cache the filename for use in the dso_bind - * handler. All in all, let each method control its own destiny. - * "Handles" and such go in a STACK. - */ - STACK_OF(void) *meth_data; - CRYPTO_REF_COUNT references; - int flags; - /* - * For use by applications etc ... use this for your bits'n'pieces, don't - * touch meth_data! - */ - CRYPTO_EX_DATA ex_data; - /* - * If this callback function pointer is set to non-NULL, then it will be - * used in DSO_load() in place of meth->dso_name_converter. NB: This - * should normally set using DSO_set_name_converter(). - */ - DSO_NAME_CONVERTER_FUNC name_converter; - /* - * If this callback function pointer is set to non-NULL, then it will be - * used in DSO_load() in place of meth->dso_merger. NB: This should - * normally set using DSO_set_merger(). - */ - DSO_MERGER_FUNC merger; - /* - * This is populated with (a copy of) the platform-independent filename - * used for this DSO. - */ - char *filename; - /* - * This is populated with (a copy of) the translated filename by which - * the DSO was actually loaded. It is NULL iff the DSO is not currently - * loaded. NB: This is here because the filename translation process may - * involve a callback being invoked more than once not only to convert to - * a platform-specific form, but also to try different filenames in the - * process of trying to perform a load. As such, this variable can be - * used to indicate (a) whether this DSO structure corresponds to a - * loaded library or not, and (b) the filename with which it was actually - * loaded. - */ - char *loaded_filename; - CRYPTO_RWLOCK *lock; -}; - -struct dso_meth_st { - const char *name; - /* - * Loads a shared library, NB: new DSO_METHODs must ensure that a - * successful load populates the loaded_filename field, and likewise a - * successful unload OPENSSL_frees and NULLs it out. - */ - int (*dso_load) (DSO *dso); - /* Unloads a shared library */ - int (*dso_unload) (DSO *dso); - /* - * Binds a function - assumes a return type of DSO_FUNC_TYPE. This should - * be cast to the real function prototype by the caller. Platforms that - * don't have compatible representations for different prototypes (this - * is possible within ANSI C) are highly unlikely to have shared - * libraries at all, let alone a DSO_METHOD implemented for them. - */ - DSO_FUNC_TYPE (*dso_bind_func) (DSO *dso, const char *symname); - /* - * The generic (yuck) "ctrl()" function. NB: Negative return values - * (rather than zero) indicate errors. - */ - long (*dso_ctrl) (DSO *dso, int cmd, long larg, void *parg); - /* - * The default DSO_METHOD-specific function for converting filenames to a - * canonical native form. - */ - DSO_NAME_CONVERTER_FUNC dso_name_converter; - /* - * The default DSO_METHOD-specific function for converting filenames to a - * canonical native form. - */ - DSO_MERGER_FUNC dso_merger; - /* [De]Initialisation handlers. */ - int (*init) (DSO *dso); - int (*finish) (DSO *dso); - /* Return pathname of the module containing location */ - int (*pathbyaddr) (void *addr, char *path, int sz); - /* Perform global symbol lookup, i.e. among *all* modules */ - void *(*globallookup) (const char *symname); -}; +/* + * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <stdio.h> +#include "internal/cryptlib.h" +#include "internal/dso.h" +#include "crypto/dso_conf.h" +#include "internal/refcount.h" + +/**********************************************************************/ +/* The low-level handle type used to refer to a loaded shared library */ + +struct dso_st { + DSO_METHOD *meth; + /* + * Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS doesn't use + * anything but will need to cache the filename for use in the dso_bind + * handler. All in all, let each method control its own destiny. + * "Handles" and such go in a STACK. + */ + STACK_OF(void) *meth_data; + CRYPTO_REF_COUNT references; + int flags; + /* + * For use by applications etc ... use this for your bits'n'pieces, don't + * touch meth_data! + */ + CRYPTO_EX_DATA ex_data; + /* + * If this callback function pointer is set to non-NULL, then it will be + * used in DSO_load() in place of meth->dso_name_converter. NB: This + * should normally set using DSO_set_name_converter(). + */ + DSO_NAME_CONVERTER_FUNC name_converter; + /* + * If this callback function pointer is set to non-NULL, then it will be + * used in DSO_load() in place of meth->dso_merger. NB: This should + * normally set using DSO_set_merger(). + */ + DSO_MERGER_FUNC merger; + /* + * This is populated with (a copy of) the platform-independent filename + * used for this DSO. + */ + char *filename; + /* + * This is populated with (a copy of) the translated filename by which + * the DSO was actually loaded. It is NULL iff the DSO is not currently + * loaded. NB: This is here because the filename translation process may + * involve a callback being invoked more than once not only to convert to + * a platform-specific form, but also to try different filenames in the + * process of trying to perform a load. As such, this variable can be + * used to indicate (a) whether this DSO structure corresponds to a + * loaded library or not, and (b) the filename with which it was actually + * loaded. + */ + char *loaded_filename; + CRYPTO_RWLOCK *lock; +}; + +struct dso_meth_st { + const char *name; + /* + * Loads a shared library, NB: new DSO_METHODs must ensure that a + * successful load populates the loaded_filename field, and likewise a + * successful unload OPENSSL_frees and NULLs it out. + */ + int (*dso_load) (DSO *dso); + /* Unloads a shared library */ + int (*dso_unload) (DSO *dso); + /* + * Binds a function - assumes a return type of DSO_FUNC_TYPE. This should + * be cast to the real function prototype by the caller. Platforms that + * don't have compatible representations for different prototypes (this + * is possible within ANSI C) are highly unlikely to have shared + * libraries at all, let alone a DSO_METHOD implemented for them. + */ + DSO_FUNC_TYPE (*dso_bind_func) (DSO *dso, const char *symname); + /* + * The generic (yuck) "ctrl()" function. NB: Negative return values + * (rather than zero) indicate errors. + */ + long (*dso_ctrl) (DSO *dso, int cmd, long larg, void *parg); + /* + * The default DSO_METHOD-specific function for converting filenames to a + * canonical native form. + */ + DSO_NAME_CONVERTER_FUNC dso_name_converter; + /* + * The default DSO_METHOD-specific function for converting filenames to a + * canonical native form. + */ + DSO_MERGER_FUNC dso_merger; + /* [De]Initialisation handlers. */ + int (*init) (DSO *dso); + int (*finish) (DSO *dso); + /* Return pathname of the module containing location */ + int (*pathbyaddr) (void *addr, char *path, int sz); + /* Perform global symbol lookup, i.e. among *all* modules */ + void *(*globallookup) (const char *symname); +}; diff --git a/contrib/libs/openssl/crypto/dso/dso_openssl.c b/contrib/libs/openssl/crypto/dso/dso_openssl.c index a456706e00..c76a04db23 100644 --- a/contrib/libs/openssl/crypto/dso/dso_openssl.c +++ b/contrib/libs/openssl/crypto/dso/dso_openssl.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "dso_local.h" +#include "dso_local.h" #ifdef DSO_NONE diff --git a/contrib/libs/openssl/crypto/dso/dso_vms.c b/contrib/libs/openssl/crypto/dso/dso_vms.c index 945544708e..9d1066f915 100644 --- a/contrib/libs/openssl/crypto/dso/dso_vms.c +++ b/contrib/libs/openssl/crypto/dso/dso_vms.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "dso_local.h" +#include "dso_local.h" #ifdef OPENSSL_SYS_VMS diff --git a/contrib/libs/openssl/crypto/dso/dso_win32.c b/contrib/libs/openssl/crypto/dso/dso_win32.c index 2dfd9de70b..af1e559d76 100644 --- a/contrib/libs/openssl/crypto/dso/dso_win32.c +++ b/contrib/libs/openssl/crypto/dso/dso_win32.c @@ -8,7 +8,7 @@ */ #include "e_os.h" -#include "dso_local.h" +#include "dso_local.h" #if defined(DSO_WIN32) diff --git a/contrib/libs/openssl/crypto/ec/curve25519.c b/contrib/libs/openssl/crypto/ec/curve25519.c index e6e336f216..952da0e653 100644 --- a/contrib/libs/openssl/crypto/ec/curve25519.c +++ b/contrib/libs/openssl/crypto/ec/curve25519.c @@ -8,7 +8,7 @@ */ #include <string.h> -#include "ec_local.h" +#include "ec_local.h" #include <openssl/sha.h> #if defined(X25519_ASM) && (defined(__x86_64) || defined(__x86_64__) || \ diff --git a/contrib/libs/openssl/crypto/ec/curve448/arch_32/arch_intrinsics.h b/contrib/libs/openssl/crypto/ec/curve448/arch_32/arch_intrinsics.h index 5366aaee82..5f6389863d 100644 --- a/contrib/libs/openssl/crypto/ec/curve448/arch_32/arch_intrinsics.h +++ b/contrib/libs/openssl/crypto/ec/curve448/arch_32/arch_intrinsics.h @@ -10,10 +10,10 @@ * Originally written by Mike Hamburg */ -#ifndef OSSL_CRYPTO_EC_CURVE448_ARCH_32_INTRINSICS_H -# define OSSL_CRYPTO_EC_CURVE448_ARCH_32_INTRINSICS_H +#ifndef OSSL_CRYPTO_EC_CURVE448_ARCH_32_INTRINSICS_H +# define OSSL_CRYPTO_EC_CURVE448_ARCH_32_INTRINSICS_H -#include "internal/constant_time.h" +#include "internal/constant_time.h" # define ARCH_WORD_BITS 32 @@ -24,4 +24,4 @@ static ossl_inline uint64_t widemul(uint32_t a, uint32_t b) return ((uint64_t)a) * b; } -#endif /* OSSL_CRYPTO_EC_CURVE448_ARCH_32_INTRINSICS_H */ +#endif /* OSSL_CRYPTO_EC_CURVE448_ARCH_32_INTRINSICS_H */ diff --git a/contrib/libs/openssl/crypto/ec/curve448/arch_32/f_impl.h b/contrib/libs/openssl/crypto/ec/curve448/arch_32/f_impl.h index 5436df76fe..e1ddddaee0 100644 --- a/contrib/libs/openssl/crypto/ec/curve448/arch_32/f_impl.h +++ b/contrib/libs/openssl/crypto/ec/curve448/arch_32/f_impl.h @@ -10,8 +10,8 @@ * Originally written by Mike Hamburg */ -#ifndef OSSL_CRYPTO_EC_CURVE448_ARCH_32_F_IMPL_H -# define OSSL_CRYPTO_EC_CURVE448_ARCH_32_F_IMPL_H +#ifndef OSSL_CRYPTO_EC_CURVE448_ARCH_32_F_IMPL_H +# define OSSL_CRYPTO_EC_CURVE448_ARCH_32_F_IMPL_H # define GF_HEADROOM 2 # define LIMB(x) ((x) & ((1 << 28) - 1)), ((x) >> 28) @@ -57,4 +57,4 @@ void gf_weak_reduce(gf a) a->limb[0] = (a->limb[0] & mask) + tmp; } -#endif /* OSSL_CRYPTO_EC_CURVE448_ARCH_32_F_IMPL_H */ +#endif /* OSSL_CRYPTO_EC_CURVE448_ARCH_32_F_IMPL_H */ diff --git a/contrib/libs/openssl/crypto/ec/curve448/curve448.c b/contrib/libs/openssl/crypto/ec/curve448/curve448.c index 90ae3f1513..12d97f0679 100644 --- a/contrib/libs/openssl/crypto/ec/curve448/curve448.c +++ b/contrib/libs/openssl/crypto/ec/curve448/curve448.c @@ -15,7 +15,7 @@ #include "point_448.h" #include "ed448.h" -#include "curve448_local.h" +#include "curve448_local.h" #define COFACTOR 4 diff --git a/contrib/libs/openssl/crypto/ec/curve448/curve448_local.h b/contrib/libs/openssl/crypto/ec/curve448/curve448_local.h index 84fa706ae1..b27770661f 100644 --- a/contrib/libs/openssl/crypto/ec/curve448/curve448_local.h +++ b/contrib/libs/openssl/crypto/ec/curve448/curve448_local.h @@ -1,38 +1,38 @@ -/* - * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ -#ifndef OSSL_CRYPTO_EC_CURVE448_LOCAL_H -# define OSSL_CRYPTO_EC_CURVE448_LOCAL_H -# include "curve448utils.h" - -int X448(uint8_t out_shared_key[56], const uint8_t private_key[56], - const uint8_t peer_public_value[56]); - -void X448_public_from_private(uint8_t out_public_value[56], - const uint8_t private_key[56]); - -int ED448_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, - const uint8_t public_key[57], const uint8_t private_key[57], - const uint8_t *context, size_t context_len); - -int ED448_verify(const uint8_t *message, size_t message_len, - const uint8_t signature[114], const uint8_t public_key[57], - const uint8_t *context, size_t context_len); - -int ED448ph_sign(uint8_t *out_sig, const uint8_t hash[64], - const uint8_t public_key[57], const uint8_t private_key[57], - const uint8_t *context, size_t context_len); - -int ED448ph_verify(const uint8_t hash[64], const uint8_t signature[114], - const uint8_t public_key[57], const uint8_t *context, - size_t context_len); - -int ED448_public_from_private(uint8_t out_public_key[57], - const uint8_t private_key[57]); - -#endif /* OSSL_CRYPTO_EC_CURVE448_LOCAL_H */ +/* + * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ +#ifndef OSSL_CRYPTO_EC_CURVE448_LOCAL_H +# define OSSL_CRYPTO_EC_CURVE448_LOCAL_H +# include "curve448utils.h" + +int X448(uint8_t out_shared_key[56], const uint8_t private_key[56], + const uint8_t peer_public_value[56]); + +void X448_public_from_private(uint8_t out_public_value[56], + const uint8_t private_key[56]); + +int ED448_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, + const uint8_t public_key[57], const uint8_t private_key[57], + const uint8_t *context, size_t context_len); + +int ED448_verify(const uint8_t *message, size_t message_len, + const uint8_t signature[114], const uint8_t public_key[57], + const uint8_t *context, size_t context_len); + +int ED448ph_sign(uint8_t *out_sig, const uint8_t hash[64], + const uint8_t public_key[57], const uint8_t private_key[57], + const uint8_t *context, size_t context_len); + +int ED448ph_verify(const uint8_t hash[64], const uint8_t signature[114], + const uint8_t public_key[57], const uint8_t *context, + size_t context_len); + +int ED448_public_from_private(uint8_t out_public_key[57], + const uint8_t private_key[57]); + +#endif /* OSSL_CRYPTO_EC_CURVE448_LOCAL_H */ diff --git a/contrib/libs/openssl/crypto/ec/curve448/curve448utils.h b/contrib/libs/openssl/crypto/ec/curve448/curve448utils.h index a7f2b7d163..86c258e745 100644 --- a/contrib/libs/openssl/crypto/ec/curve448/curve448utils.h +++ b/contrib/libs/openssl/crypto/ec/curve448/curve448utils.h @@ -10,8 +10,8 @@ * Originally written by Mike Hamburg */ -#ifndef OSSL_CRYPTO_EC_CURVE448UTILS_H -# define OSSL_CRYPTO_EC_CURVE448UTILS_H +#ifndef OSSL_CRYPTO_EC_CURVE448UTILS_H +# define OSSL_CRYPTO_EC_CURVE448UTILS_H # include <openssl/e_os2.h> diff --git a/contrib/libs/openssl/crypto/ec/curve448/ed448.h b/contrib/libs/openssl/crypto/ec/curve448/ed448.h index dab849b3dc..c1e5c2832f 100644 --- a/contrib/libs/openssl/crypto/ec/curve448/ed448.h +++ b/contrib/libs/openssl/crypto/ec/curve448/ed448.h @@ -10,8 +10,8 @@ * Originally written by Mike Hamburg */ -#ifndef OSSL_CRYPTO_EC_CURVE448_ED448_H -# define OSSL_CRYPTO_EC_CURVE448_ED448_H +#ifndef OSSL_CRYPTO_EC_CURVE448_ED448_H +# define OSSL_CRYPTO_EC_CURVE448_ED448_H # include "point_448.h" @@ -192,4 +192,4 @@ c448_error_t c448_ed448_convert_private_key_to_x448( uint8_t x[X448_PRIVATE_BYTES], const uint8_t ed[EDDSA_448_PRIVATE_BYTES]); -#endif /* OSSL_CRYPTO_EC_CURVE448_ED448_H */ +#endif /* OSSL_CRYPTO_EC_CURVE448_ED448_H */ diff --git a/contrib/libs/openssl/crypto/ec/curve448/eddsa.c b/contrib/libs/openssl/crypto/ec/curve448/eddsa.c index f03f11012c..82741f5435 100644 --- a/contrib/libs/openssl/crypto/ec/curve448/eddsa.c +++ b/contrib/libs/openssl/crypto/ec/curve448/eddsa.c @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright 2015-2016 Cryptography Research, Inc. * * Licensed under the OpenSSL license (the "License"). You may not use @@ -12,7 +12,7 @@ #include <string.h> #include <openssl/crypto.h> #include <openssl/evp.h> -#include "curve448_local.h" +#include "curve448_local.h" #include "word.h" #include "ed448.h" #include "internal/numbers.h" @@ -50,12 +50,12 @@ static c448_error_t hash_init_with_dom(EVP_MD_CTX *hashctx, uint8_t prehashed, const uint8_t *context, size_t context_len) { -#ifdef CHARSET_EBCDIC - const char dom_s[] = {0x53, 0x69, 0x67, 0x45, - 0x64, 0x34, 0x34, 0x38, 0x00}; -#else - const char dom_s[] = "SigEd448"; -#endif +#ifdef CHARSET_EBCDIC + const char dom_s[] = {0x53, 0x69, 0x67, 0x45, + 0x64, 0x34, 0x34, 0x38, 0x00}; +#else + const char dom_s[] = "SigEd448"; +#endif uint8_t dom[2]; if (context_len > UINT8_MAX) diff --git a/contrib/libs/openssl/crypto/ec/curve448/field.h b/contrib/libs/openssl/crypto/ec/curve448/field.h index 6696784dcc..ccd04482d2 100644 --- a/contrib/libs/openssl/crypto/ec/curve448/field.h +++ b/contrib/libs/openssl/crypto/ec/curve448/field.h @@ -10,10 +10,10 @@ * Originally written by Mike Hamburg */ -#ifndef OSSL_CRYPTO_EC_CURVE448_FIELD_H -# define OSSL_CRYPTO_EC_CURVE448_FIELD_H +#ifndef OSSL_CRYPTO_EC_CURVE448_FIELD_H +# define OSSL_CRYPTO_EC_CURVE448_FIELD_H -# include "internal/constant_time.h" +# include "internal/constant_time.h" # include <string.h> # include <assert.h> # include "word.h" @@ -165,4 +165,4 @@ static ossl_inline void gf_cond_swap(gf x, gf_s * RESTRICT y, mask_t swap) } } -#endif /* OSSL_CRYPTO_EC_CURVE448_FIELD_H */ +#endif /* OSSL_CRYPTO_EC_CURVE448_FIELD_H */ diff --git a/contrib/libs/openssl/crypto/ec/curve448/point_448.h b/contrib/libs/openssl/crypto/ec/curve448/point_448.h index 8347a2c8e0..93e715fd9c 100644 --- a/contrib/libs/openssl/crypto/ec/curve448/point_448.h +++ b/contrib/libs/openssl/crypto/ec/curve448/point_448.h @@ -10,8 +10,8 @@ * Originally written by Mike Hamburg */ -#ifndef OSSL_CRYPTO_EC_CURVE448_POINT_448_H -# define OSSL_CRYPTO_EC_CURVE448_POINT_448_H +#ifndef OSSL_CRYPTO_EC_CURVE448_POINT_448_H +# define OSSL_CRYPTO_EC_CURVE448_POINT_448_H # include "curve448utils.h" # include "field.h" @@ -298,4 +298,4 @@ void curve448_scalar_destroy(curve448_scalar_t scalar); /* Overwrite point with zeros. */ void curve448_point_destroy(curve448_point_t point); -#endif /* OSSL_CRYPTO_EC_CURVE448_POINT_448_H */ +#endif /* OSSL_CRYPTO_EC_CURVE448_POINT_448_H */ diff --git a/contrib/libs/openssl/crypto/ec/curve448/word.h b/contrib/libs/openssl/crypto/ec/curve448/word.h index 8550a01aef..237cc9b631 100644 --- a/contrib/libs/openssl/crypto/ec/curve448/word.h +++ b/contrib/libs/openssl/crypto/ec/curve448/word.h @@ -10,8 +10,8 @@ * Originally written by Mike Hamburg */ -#ifndef OSSL_CRYPTO_EC_CURVE448_WORD_H -# define OSSL_CRYPTO_EC_CURVE448_WORD_H +#ifndef OSSL_CRYPTO_EC_CURVE448_WORD_H +# define OSSL_CRYPTO_EC_CURVE448_WORD_H # include <string.h> # include <assert.h> @@ -78,4 +78,4 @@ static ossl_inline mask_t bool_to_mask(c448_bool_t m) return ret; } -#endif /* OSSL_CRYPTO_EC_CURVE448_WORD_H */ +#endif /* OSSL_CRYPTO_EC_CURVE448_WORD_H */ diff --git a/contrib/libs/openssl/crypto/ec/ec2_oct.c b/contrib/libs/openssl/crypto/ec/ec2_oct.c index fc31d36407..788e6501fb 100644 --- a/contrib/libs/openssl/crypto/ec/ec2_oct.c +++ b/contrib/libs/openssl/crypto/ec/ec2_oct.c @@ -10,7 +10,7 @@ #include <openssl/err.h> -#include "ec_local.h" +#include "ec_local.h" #ifndef OPENSSL_NO_EC2M diff --git a/contrib/libs/openssl/crypto/ec/ec2_smpl.c b/contrib/libs/openssl/crypto/ec/ec2_smpl.c index 3b1e92f2f7..84e5537a03 100644 --- a/contrib/libs/openssl/crypto/ec/ec2_smpl.c +++ b/contrib/libs/openssl/crypto/ec/ec2_smpl.c @@ -10,8 +10,8 @@ #include <openssl/err.h> -#include "crypto/bn.h" -#include "ec_local.h" +#include "crypto/bn.h" +#include "ec_local.h" #ifndef OPENSSL_NO_EC2M diff --git a/contrib/libs/openssl/crypto/ec/ec_ameth.c b/contrib/libs/openssl/crypto/ec/ec_ameth.c index 7c75db57d4..5098bd7a66 100644 --- a/contrib/libs/openssl/crypto/ec/ec_ameth.c +++ b/contrib/libs/openssl/crypto/ec/ec_ameth.c @@ -14,9 +14,9 @@ #include <openssl/bn.h> #include <openssl/cms.h> #include <openssl/asn1t.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" -#include "ec_local.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" +#include "ec_local.h" #ifndef OPENSSL_NO_CMS static int ecdh_cms_decrypt(CMS_RecipientInfo *ri); diff --git a/contrib/libs/openssl/crypto/ec/ec_asn1.c b/contrib/libs/openssl/crypto/ec/ec_asn1.c index 080b93e9be..c8ee1e6f17 100644 --- a/contrib/libs/openssl/crypto/ec/ec_asn1.c +++ b/contrib/libs/openssl/crypto/ec/ec_asn1.c @@ -8,7 +8,7 @@ */ #include <string.h> -#include "ec_local.h" +#include "ec_local.h" #include <openssl/err.h> #include <openssl/asn1t.h> #include <openssl/objects.h> @@ -452,7 +452,7 @@ ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, unsigned char *buffer = NULL; const EC_POINT *point = NULL; point_conversion_form_t form; - ASN1_INTEGER *orig; + ASN1_INTEGER *orig; if (params == NULL) { if ((ret = ECPARAMETERS_new()) == NULL) { @@ -503,9 +503,9 @@ ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_EC_LIB); goto err; } - ret->order = BN_to_ASN1_INTEGER(tmp, orig = ret->order); + ret->order = BN_to_ASN1_INTEGER(tmp, orig = ret->order); if (ret->order == NULL) { - ret->order = orig; + ret->order = orig; ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_ASN1_LIB); goto err; } @@ -513,9 +513,9 @@ ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, /* set the cofactor (optional) */ tmp = EC_GROUP_get0_cofactor(group); if (tmp != NULL) { - ret->cofactor = BN_to_ASN1_INTEGER(tmp, orig = ret->cofactor); + ret->cofactor = BN_to_ASN1_INTEGER(tmp, orig = ret->cofactor); if (ret->cofactor == NULL) { - ret->cofactor = orig; + ret->cofactor = orig; ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_ASN1_LIB); goto err; } @@ -866,20 +866,20 @@ EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) * serialized using explicit parameters by default. */ EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_EXPLICIT_CURVE); - - /* - * If the input params do not contain the optional seed field we make - * sure it is not added to the returned group. - * - * The seed field is not really used inside libcrypto anyway, and - * adding it to parsed explicit parameter keys would alter their DER - * encoding output (because of the extra field) which could impact - * applications fingerprinting keys by their DER encoding. - */ - if (params->curve->seed == NULL) { - if (EC_GROUP_set_seed(ret, NULL, 0) != 1) - goto err; - } + + /* + * If the input params do not contain the optional seed field we make + * sure it is not added to the returned group. + * + * The seed field is not really used inside libcrypto anyway, and + * adding it to parsed explicit parameter keys would alter their DER + * encoding output (because of the extra field) which could impact + * applications fingerprinting keys by their DER encoding. + */ + if (params->curve->seed == NULL) { + if (EC_GROUP_set_seed(ret, NULL, 0) != 1) + goto err; + } } ok = 1; @@ -1322,7 +1322,7 @@ int ECDSA_size(const EC_KEY *r) i = i2d_ASN1_INTEGER(&bs, NULL); i += i; /* r and s */ ret = ASN1_object_size(1, i, V_ASN1_SEQUENCE); - if (ret < 0) - return 0; + if (ret < 0) + return 0; return ret; } diff --git a/contrib/libs/openssl/crypto/ec/ec_check.c b/contrib/libs/openssl/crypto/ec/ec_check.c index 0bddac6142..d0706d2857 100644 --- a/contrib/libs/openssl/crypto/ec/ec_check.c +++ b/contrib/libs/openssl/crypto/ec/ec_check.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "ec_local.h" +#include "ec_local.h" #include <openssl/err.h> int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx) diff --git a/contrib/libs/openssl/crypto/ec/ec_curve.c b/contrib/libs/openssl/crypto/ec/ec_curve.c index 0268af0258..8de486cbd7 100644 --- a/contrib/libs/openssl/crypto/ec/ec_curve.c +++ b/contrib/libs/openssl/crypto/ec/ec_curve.c @@ -9,7 +9,7 @@ */ #include <string.h> -#include "ec_local.h" +#include "ec_local.h" #include <openssl/err.h> #include <openssl/obj_mac.h> #include <openssl/opensslconf.h> diff --git a/contrib/libs/openssl/crypto/ec/ec_cvt.c b/contrib/libs/openssl/crypto/ec/ec_cvt.c index 4db3e0cf1b..944e317d9d 100644 --- a/contrib/libs/openssl/crypto/ec/ec_cvt.c +++ b/contrib/libs/openssl/crypto/ec/ec_cvt.c @@ -9,7 +9,7 @@ */ #include <openssl/err.h> -#include "ec_local.h" +#include "ec_local.h" EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) diff --git a/contrib/libs/openssl/crypto/ec/ec_key.c b/contrib/libs/openssl/crypto/ec/ec_key.c index a89d79b053..23efbd015c 100644 --- a/contrib/libs/openssl/crypto/ec/ec_key.c +++ b/contrib/libs/openssl/crypto/ec/ec_key.c @@ -10,7 +10,7 @@ #include "internal/cryptlib.h" #include <string.h> -#include "ec_local.h" +#include "ec_local.h" #include "internal/refcount.h" #include <openssl/err.h> #include <openssl/engine.h> diff --git a/contrib/libs/openssl/crypto/ec/ec_kmeth.c b/contrib/libs/openssl/crypto/ec/ec_kmeth.c index 86681864c9..53a4a92952 100644 --- a/contrib/libs/openssl/crypto/ec/ec_kmeth.c +++ b/contrib/libs/openssl/crypto/ec/ec_kmeth.c @@ -11,7 +11,7 @@ #include <openssl/ec.h> #include <openssl/engine.h> #include <openssl/err.h> -#include "ec_local.h" +#include "ec_local.h" static const EC_KEY_METHOD openssl_ec_key_method = { diff --git a/contrib/libs/openssl/crypto/ec/ec_lib.c b/contrib/libs/openssl/crypto/ec/ec_lib.c index 8201483f4c..08db89fcee 100644 --- a/contrib/libs/openssl/crypto/ec/ec_lib.c +++ b/contrib/libs/openssl/crypto/ec/ec_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -13,7 +13,7 @@ #include <openssl/err.h> #include <openssl/opensslv.h> -#include "ec_local.h" +#include "ec_local.h" /* functions for EC_GROUP objects */ @@ -1012,10 +1012,10 @@ int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, ECerr(EC_F_EC_POINTS_MUL, EC_R_INCOMPATIBLE_OBJECTS); return 0; } - - if (scalar == NULL && num == 0) - return EC_POINT_set_to_infinity(group, r); - + + if (scalar == NULL && num == 0) + return EC_POINT_set_to_infinity(group, r); + for (i = 0; i < num; i++) { if (!ec_point_is_compat(points[i], group)) { ECerr(EC_F_EC_POINTS_MUL, EC_R_INCOMPATIBLE_OBJECTS); diff --git a/contrib/libs/openssl/crypto/ec/ec_local.h b/contrib/libs/openssl/crypto/ec/ec_local.h index 48e855c068..64725a9c92 100644 --- a/contrib/libs/openssl/crypto/ec/ec_local.h +++ b/contrib/libs/openssl/crypto/ec/ec_local.h @@ -1,741 +1,741 @@ -/* +/* * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <stdlib.h> - -#include <openssl/obj_mac.h> -#include <openssl/ec.h> -#include <openssl/bn.h> -#include "internal/refcount.h" -#include "crypto/ec.h" - -#if defined(__SUNPRO_C) -# if __SUNPRO_C >= 0x520 -# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) -# endif -#endif - -/* Use default functions for poin2oct, oct2point and compressed coordinates */ -#define EC_FLAGS_DEFAULT_OCT 0x1 - -/* Use custom formats for EC_GROUP, EC_POINT and EC_KEY */ -#define EC_FLAGS_CUSTOM_CURVE 0x2 - -/* Curve does not support signing operations */ -#define EC_FLAGS_NO_SIGN 0x4 - -/* - * 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 */ - /* - * 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_set_curve, EC_GROUP_get_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 *); - /* used by EC_GROUP_get_degree: */ - int (*group_get_degree) (const EC_GROUP *); - 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_GFp, - * EC_POINT_get_Jprojective_coordinates_GFp, - * 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_GFp) (const EC_GROUP *, - EC_POINT *, const BIGNUM *x, - const BIGNUM *y, - const BIGNUM *z, BN_CTX *); - int (*point_get_Jprojective_coordinates_GFp) (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 *); - int (*point_get_affine_coordinates) (const EC_GROUP *, const EC_POINT *, - BIGNUM *x, BIGNUM *y, BN_CTX *); - int (*point_set_compressed_coordinates) (const EC_GROUP *, EC_POINT *, - 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 *); - /* 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 (*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 *); - /* 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 (default implementations are used if the - * 'mul' pointer is 0): - */ - /*- - * mul() calculates the value - * - * r := generator * scalar - * + points[0] * scalars[0] - * + ... - * + points[num-1] * scalars[num-1]. - * - * For a fixed point multiplication (scalar != NULL, num == 0) - * or a variable point multiplication (scalar == NULL, num == 1), - * mul() must use a constant time algorithm: in both cases callers - * should provide an input scalar (either scalar or scalars[0]) - * in the range [0, ec_group_order); for robustness, implementers - * should handle the case when the scalar has not been reduced, but - * may treat it as an unusual input, without any constant-timeness - * guarantee. - */ - int (*mul) (const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, - size_t num, const EC_POINT *points[], const BIGNUM *scalars[], - BN_CTX *); - int (*precompute_mult) (EC_GROUP *group, BN_CTX *); - int (*have_precompute_mult) (const EC_GROUP *group); - /* 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 *); - /*- - * 'field_inv' computes the multiplicative inverse of a in the field, - * storing the result in r. - * - * If 'a' is zero (or equivalent), you'll get an EC_R_CANNOT_INVERT error. - */ - int (*field_inv) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); - /* e.g. to Montgomery */ - int (*field_encode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, - BN_CTX *); - /* e.g. from Montgomery */ - int (*field_decode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, - BN_CTX *); - int (*field_set_to_one) (const EC_GROUP *, BIGNUM *r, BN_CTX *); - /* private key operations */ - size_t (*priv2oct)(const EC_KEY *eckey, unsigned char *buf, size_t len); - int (*oct2priv)(EC_KEY *eckey, const unsigned char *buf, size_t len); - int (*set_private)(EC_KEY *eckey, const BIGNUM *priv_key); - int (*keygen)(EC_KEY *eckey); - int (*keycheck)(const EC_KEY *eckey); - int (*keygenpub)(EC_KEY *eckey); - int (*keycopy)(EC_KEY *dst, const EC_KEY *src); - void (*keyfinish)(EC_KEY *eckey); - /* custom ECDH operation */ - int (*ecdh_compute_key)(unsigned char **pout, size_t *poutlen, - const EC_POINT *pub_key, const EC_KEY *ecdh); - /* Inverse modulo order */ - int (*field_inverse_mod_ord)(const EC_GROUP *, BIGNUM *r, - const BIGNUM *x, BN_CTX *); - int (*blind_coordinates)(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx); - int (*ladder_pre)(const EC_GROUP *group, - EC_POINT *r, EC_POINT *s, - EC_POINT *p, BN_CTX *ctx); - int (*ladder_step)(const EC_GROUP *group, - EC_POINT *r, EC_POINT *s, - EC_POINT *p, BN_CTX *ctx); - int (*ladder_post)(const EC_GROUP *group, - EC_POINT *r, EC_POINT *s, - EC_POINT *p, BN_CTX *ctx); -}; - -/* - * Types and functions to manipulate pre-computed values. - */ -typedef struct nistp224_pre_comp_st NISTP224_PRE_COMP; -typedef struct nistp256_pre_comp_st NISTP256_PRE_COMP; -typedef struct nistp521_pre_comp_st NISTP521_PRE_COMP; -typedef struct nistz256_pre_comp_st NISTZ256_PRE_COMP; -typedef struct ec_pre_comp_st EC_PRE_COMP; - -struct ec_group_st { - const EC_METHOD *meth; - EC_POINT *generator; /* optional */ - BIGNUM *order, *cofactor; - int curve_name; /* optional NID for named curve */ - int asn1_flag; /* flag to control the asn1 encoding */ + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <stdlib.h> + +#include <openssl/obj_mac.h> +#include <openssl/ec.h> +#include <openssl/bn.h> +#include "internal/refcount.h" +#include "crypto/ec.h" + +#if defined(__SUNPRO_C) +# if __SUNPRO_C >= 0x520 +# pragma error_messages (off,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) +# endif +#endif + +/* Use default functions for poin2oct, oct2point and compressed coordinates */ +#define EC_FLAGS_DEFAULT_OCT 0x1 + +/* Use custom formats for EC_GROUP, EC_POINT and EC_KEY */ +#define EC_FLAGS_CUSTOM_CURVE 0x2 + +/* Curve does not support signing operations */ +#define EC_FLAGS_NO_SIGN 0x4 + +/* + * 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 */ + /* + * 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_set_curve, EC_GROUP_get_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 *); + /* used by EC_GROUP_get_degree: */ + int (*group_get_degree) (const EC_GROUP *); + 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_GFp, + * EC_POINT_get_Jprojective_coordinates_GFp, + * 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_GFp) (const EC_GROUP *, + EC_POINT *, const BIGNUM *x, + const BIGNUM *y, + const BIGNUM *z, BN_CTX *); + int (*point_get_Jprojective_coordinates_GFp) (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 *); + int (*point_get_affine_coordinates) (const EC_GROUP *, const EC_POINT *, + BIGNUM *x, BIGNUM *y, BN_CTX *); + int (*point_set_compressed_coordinates) (const EC_GROUP *, EC_POINT *, + 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 *); + /* 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 (*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 *); + /* 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 (default implementations are used if the + * 'mul' pointer is 0): + */ + /*- + * mul() calculates the value + * + * r := generator * scalar + * + points[0] * scalars[0] + * + ... + * + points[num-1] * scalars[num-1]. + * + * For a fixed point multiplication (scalar != NULL, num == 0) + * or a variable point multiplication (scalar == NULL, num == 1), + * mul() must use a constant time algorithm: in both cases callers + * should provide an input scalar (either scalar or scalars[0]) + * in the range [0, ec_group_order); for robustness, implementers + * should handle the case when the scalar has not been reduced, but + * may treat it as an unusual input, without any constant-timeness + * guarantee. + */ + int (*mul) (const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, + size_t num, const EC_POINT *points[], const BIGNUM *scalars[], + BN_CTX *); + int (*precompute_mult) (EC_GROUP *group, BN_CTX *); + int (*have_precompute_mult) (const EC_GROUP *group); + /* 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 *); + /*- + * 'field_inv' computes the multiplicative inverse of a in the field, + * storing the result in r. + * + * If 'a' is zero (or equivalent), you'll get an EC_R_CANNOT_INVERT error. + */ + int (*field_inv) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); + /* e.g. to Montgomery */ + int (*field_encode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, + BN_CTX *); + /* e.g. from Montgomery */ + int (*field_decode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, + BN_CTX *); + int (*field_set_to_one) (const EC_GROUP *, BIGNUM *r, BN_CTX *); + /* private key operations */ + size_t (*priv2oct)(const EC_KEY *eckey, unsigned char *buf, size_t len); + int (*oct2priv)(EC_KEY *eckey, const unsigned char *buf, size_t len); + int (*set_private)(EC_KEY *eckey, const BIGNUM *priv_key); + int (*keygen)(EC_KEY *eckey); + int (*keycheck)(const EC_KEY *eckey); + int (*keygenpub)(EC_KEY *eckey); + int (*keycopy)(EC_KEY *dst, const EC_KEY *src); + void (*keyfinish)(EC_KEY *eckey); + /* custom ECDH operation */ + int (*ecdh_compute_key)(unsigned char **pout, size_t *poutlen, + const EC_POINT *pub_key, const EC_KEY *ecdh); + /* Inverse modulo order */ + int (*field_inverse_mod_ord)(const EC_GROUP *, BIGNUM *r, + const BIGNUM *x, BN_CTX *); + int (*blind_coordinates)(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx); + int (*ladder_pre)(const EC_GROUP *group, + EC_POINT *r, EC_POINT *s, + EC_POINT *p, BN_CTX *ctx); + int (*ladder_step)(const EC_GROUP *group, + EC_POINT *r, EC_POINT *s, + EC_POINT *p, BN_CTX *ctx); + int (*ladder_post)(const EC_GROUP *group, + EC_POINT *r, EC_POINT *s, + EC_POINT *p, BN_CTX *ctx); +}; + +/* + * Types and functions to manipulate pre-computed values. + */ +typedef struct nistp224_pre_comp_st NISTP224_PRE_COMP; +typedef struct nistp256_pre_comp_st NISTP256_PRE_COMP; +typedef struct nistp521_pre_comp_st NISTP521_PRE_COMP; +typedef struct nistz256_pre_comp_st NISTZ256_PRE_COMP; +typedef struct ec_pre_comp_st EC_PRE_COMP; + +struct ec_group_st { + const EC_METHOD *meth; + EC_POINT *generator; /* optional */ + BIGNUM *order, *cofactor; + int curve_name; /* optional NID for named curve */ + int asn1_flag; /* flag to control the asn1 encoding */ int decoded_from_explicit_params; /* set if decoded from explicit * curve parameters encoding */ - point_conversion_form_t asn1_form; - unsigned char *seed; /* optional seed for parameters (appears in - * ASN1) */ - size_t seed_len; - /* - * The following members are handled by the method functions, even if - * they appear generic - */ - /* - * 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. - */ - BIGNUM *field; - /* - * 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. - */ - int poly[6]; - /* - * 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. - */ - BIGNUM *a, *b; - /* enable optimized point arithmetics for special case */ - int a_is_minus3; - /* method-specific (e.g., Montgomery structure) */ - void *field_data1; - /* method-specific */ - void *field_data2; - /* method-specific */ - int (*field_mod_func) (BIGNUM *, const BIGNUM *, const BIGNUM *, - BN_CTX *); - /* data for ECDSA inverse */ - BN_MONT_CTX *mont_data; - - /* - * Precomputed values for speed. The PCT_xxx names match the - * pre_comp.xxx union names; see the SETPRECOMP and HAVEPRECOMP - * macros, below. - */ - enum { - PCT_none, - PCT_nistp224, PCT_nistp256, PCT_nistp521, PCT_nistz256, - PCT_ec - } pre_comp_type; - union { - NISTP224_PRE_COMP *nistp224; - NISTP256_PRE_COMP *nistp256; - NISTP521_PRE_COMP *nistp521; - NISTZ256_PRE_COMP *nistz256; - EC_PRE_COMP *ec; - } pre_comp; -}; - -#define SETPRECOMP(g, type, pre) \ - g->pre_comp_type = PCT_##type, g->pre_comp.type = pre -#define HAVEPRECOMP(g, type) \ - g->pre_comp_type == PCT_##type && g->pre_comp.type != NULL - -struct ec_key_st { - const EC_KEY_METHOD *meth; - ENGINE *engine; - int version; - EC_GROUP *group; - EC_POINT *pub_key; - BIGNUM *priv_key; - unsigned int enc_flag; - point_conversion_form_t conv_form; - CRYPTO_REF_COUNT references; - int flags; - CRYPTO_EX_DATA ex_data; - CRYPTO_RWLOCK *lock; -}; - -struct ec_point_st { - const EC_METHOD *meth; - /* NID for the curve if known */ - int curve_name; - /* - * All members except 'meth' are handled by the method functions, even if - * they appear generic - */ - BIGNUM *X; - BIGNUM *Y; - BIGNUM *Z; /* Jacobian projective coordinates: * (X, Y, - * Z) represents (X/Z^2, Y/Z^3) if Z != 0 */ - int Z_is_one; /* enable optimized point arithmetics for - * special case */ -}; - -static ossl_inline int ec_point_is_compat(const EC_POINT *point, - const EC_GROUP *group) -{ - if (group->meth != point->meth - || (group->curve_name != 0 - && point->curve_name != 0 - && group->curve_name != point->curve_name)) - return 0; - - return 1; -} - -NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *); -NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *); -NISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *); -NISTZ256_PRE_COMP *EC_nistz256_pre_comp_dup(NISTZ256_PRE_COMP *); -NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *); -EC_PRE_COMP *EC_ec_pre_comp_dup(EC_PRE_COMP *); - -void EC_pre_comp_free(EC_GROUP *group); -void EC_nistp224_pre_comp_free(NISTP224_PRE_COMP *); -void EC_nistp256_pre_comp_free(NISTP256_PRE_COMP *); -void EC_nistp521_pre_comp_free(NISTP521_PRE_COMP *); -void EC_nistz256_pre_comp_free(NISTZ256_PRE_COMP *); -void EC_ec_pre_comp_free(EC_PRE_COMP *); - -/* - * method functions in ec_mult.c (ec_lib.c uses these as defaults if - * group->method->mul is 0) - */ -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 *); -int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *); -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 *); -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_GFp(const EC_GROUP *, - EC_POINT *, const BIGNUM *x, - const BIGNUM *y, - const BIGNUM *z, BN_CTX *); -int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *, - const EC_POINT *, BIGNUM *x, - BIGNUM *y, BIGNUM *z, - BN_CTX *); -int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, - const BIGNUM *y, BN_CTX *); -int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *, - const EC_POINT *, BIGNUM *x, - BIGNUM *y, BN_CTX *); -int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *, - const BIGNUM *x, int y_bit, - BN_CTX *); -size_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *, - point_conversion_form_t form, - unsigned char *buf, size_t len, BN_CTX *); -int ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *, - const unsigned char *buf, size_t len, BN_CTX *); -int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, - const EC_POINT *b, BN_CTX *); -int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, - BN_CTX *); -int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); -int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *); -int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); -int ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, - BN_CTX *); -int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); -int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num, - EC_POINT *[], BN_CTX *); -int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, - const BIGNUM *b, BN_CTX *); -int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, - BN_CTX *); -int ec_GFp_simple_field_inv(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, - BN_CTX *); -int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p, - BN_CTX *ctx); -int ec_GFp_simple_ladder_pre(const EC_GROUP *group, - EC_POINT *r, EC_POINT *s, - EC_POINT *p, BN_CTX *ctx); -int ec_GFp_simple_ladder_step(const EC_GROUP *group, - EC_POINT *r, EC_POINT *s, - EC_POINT *p, BN_CTX *ctx); -int ec_GFp_simple_ladder_post(const EC_GROUP *group, - EC_POINT *r, EC_POINT *s, - EC_POINT *p, BN_CTX *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_inv(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 *); - -/* 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 *); - -#ifndef OPENSSL_NO_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); - -/* 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 -int ec_group_simple_order_bits(const EC_GROUP *group); - -#ifdef ECP_NISTZ256_ASM -/** Returns GFp methods using montgomery multiplication, with x86-64 optimized - * P256. See http://eprint.iacr.org/2013/816. - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_nistz256_method(void); -#endif - -size_t ec_key_simple_priv2oct(const EC_KEY *eckey, - unsigned char *buf, size_t len); -int ec_key_simple_oct2priv(EC_KEY *eckey, const unsigned char *buf, size_t len); -int ec_key_simple_generate_key(EC_KEY *eckey); -int ec_key_simple_generate_public_key(EC_KEY *eckey); -int ec_key_simple_check_key(const EC_KEY *eckey); - -int ec_curve_nid_from_params(const EC_GROUP *group, BN_CTX *ctx); - -/* EC_METHOD definitions */ - -struct ec_key_method_st { - const char *name; - int32_t flags; - int (*init)(EC_KEY *key); - void (*finish)(EC_KEY *key); - int (*copy)(EC_KEY *dest, const EC_KEY *src); - int (*set_group)(EC_KEY *key, const EC_GROUP *grp); - int (*set_private)(EC_KEY *key, const BIGNUM *priv_key); - int (*set_public)(EC_KEY *key, const EC_POINT *pub_key); - int (*keygen)(EC_KEY *key); - int (*compute_key)(unsigned char **pout, size_t *poutlen, - const EC_POINT *pub_key, const EC_KEY *ecdh); - int (*sign)(int type, const unsigned char *dgst, int dlen, unsigned char - *sig, unsigned int *siglen, const BIGNUM *kinv, - const BIGNUM *r, EC_KEY *eckey); - int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, - BIGNUM **rp); - ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, int dgst_len, - const BIGNUM *in_kinv, const BIGNUM *in_r, - EC_KEY *eckey); - - int (*verify)(int type, const unsigned char *dgst, int dgst_len, - const unsigned char *sigbuf, int sig_len, EC_KEY *eckey); - int (*verify_sig)(const unsigned char *dgst, int dgst_len, - const ECDSA_SIG *sig, EC_KEY *eckey); -}; - -#define EC_KEY_METHOD_DYNAMIC 1 - -int ossl_ec_key_gen(EC_KEY *eckey); -int ossl_ecdh_compute_key(unsigned char **pout, size_t *poutlen, - const EC_POINT *pub_key, const EC_KEY *ecdh); -int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen, - const EC_POINT *pub_key, const EC_KEY *ecdh); - -struct ECDSA_SIG_st { - BIGNUM *r; - BIGNUM *s; -}; - -int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, - BIGNUM **rp); -int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen, - unsigned char *sig, unsigned int *siglen, - const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey); -ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len, - const BIGNUM *in_kinv, const BIGNUM *in_r, - EC_KEY *eckey); -int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len, - const unsigned char *sigbuf, int sig_len, EC_KEY *eckey); -int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, - const ECDSA_SIG *sig, EC_KEY *eckey); - -int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, - const uint8_t public_key[32], const uint8_t private_key[32]); -int ED25519_verify(const uint8_t *message, size_t message_len, - const uint8_t signature[64], const uint8_t public_key[32]); -void ED25519_public_from_private(uint8_t out_public_key[32], - const uint8_t private_key[32]); - -int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32], - const uint8_t peer_public_value[32]); -void X25519_public_from_private(uint8_t out_public_value[32], - const uint8_t private_key[32]); - -/*- - * This functions computes a single point multiplication over the EC group, - * using, at a high level, a Montgomery ladder with conditional swaps, with - * various timing attack defenses. - * - * It performs either a fixed point multiplication - * (scalar * generator) - * when point is NULL, or a variable point multiplication - * (scalar * point) - * when point is not NULL. - * - * `scalar` cannot be NULL and should be in the range [0,n) otherwise all - * constant time bets are off (where n is the cardinality of the EC group). - * - * This function expects `group->order` and `group->cardinality` to be well - * defined and non-zero: it fails with an error code otherwise. - * - * NB: This says nothing about the constant-timeness of the ladder step - * implementation (i.e., the default implementation is based on EC_POINT_add and - * EC_POINT_dbl, which of course are not constant time themselves) or the - * underlying multiprecision arithmetic. - * - * The product is stored in `r`. - * - * This is an internal function: callers are in charge of ensuring that the - * input parameters `group`, `r`, `scalar` and `ctx` are not NULL. - * - * Returns 1 on success, 0 otherwise. - */ -int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r, - const BIGNUM *scalar, const EC_POINT *point, - BN_CTX *ctx); - -int ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx); - -static ossl_inline int ec_point_ladder_pre(const EC_GROUP *group, - EC_POINT *r, EC_POINT *s, - EC_POINT *p, BN_CTX *ctx) -{ - if (group->meth->ladder_pre != NULL) - return group->meth->ladder_pre(group, r, s, p, ctx); - - if (!EC_POINT_copy(s, p) - || !EC_POINT_dbl(group, r, s, ctx)) - return 0; - - return 1; -} - -static ossl_inline int ec_point_ladder_step(const EC_GROUP *group, - EC_POINT *r, EC_POINT *s, - EC_POINT *p, BN_CTX *ctx) -{ - if (group->meth->ladder_step != NULL) - return group->meth->ladder_step(group, r, s, p, ctx); - - if (!EC_POINT_add(group, s, r, s, ctx) - || !EC_POINT_dbl(group, r, r, ctx)) - return 0; - - return 1; - -} - -static ossl_inline int ec_point_ladder_post(const EC_GROUP *group, - EC_POINT *r, EC_POINT *s, - EC_POINT *p, BN_CTX *ctx) -{ - if (group->meth->ladder_post != NULL) - return group->meth->ladder_post(group, r, s, p, ctx); - - return 1; -} + point_conversion_form_t asn1_form; + unsigned char *seed; /* optional seed for parameters (appears in + * ASN1) */ + size_t seed_len; + /* + * The following members are handled by the method functions, even if + * they appear generic + */ + /* + * 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. + */ + BIGNUM *field; + /* + * 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. + */ + int poly[6]; + /* + * 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. + */ + BIGNUM *a, *b; + /* enable optimized point arithmetics for special case */ + int a_is_minus3; + /* method-specific (e.g., Montgomery structure) */ + void *field_data1; + /* method-specific */ + void *field_data2; + /* method-specific */ + int (*field_mod_func) (BIGNUM *, const BIGNUM *, const BIGNUM *, + BN_CTX *); + /* data for ECDSA inverse */ + BN_MONT_CTX *mont_data; + + /* + * Precomputed values for speed. The PCT_xxx names match the + * pre_comp.xxx union names; see the SETPRECOMP and HAVEPRECOMP + * macros, below. + */ + enum { + PCT_none, + PCT_nistp224, PCT_nistp256, PCT_nistp521, PCT_nistz256, + PCT_ec + } pre_comp_type; + union { + NISTP224_PRE_COMP *nistp224; + NISTP256_PRE_COMP *nistp256; + NISTP521_PRE_COMP *nistp521; + NISTZ256_PRE_COMP *nistz256; + EC_PRE_COMP *ec; + } pre_comp; +}; + +#define SETPRECOMP(g, type, pre) \ + g->pre_comp_type = PCT_##type, g->pre_comp.type = pre +#define HAVEPRECOMP(g, type) \ + g->pre_comp_type == PCT_##type && g->pre_comp.type != NULL + +struct ec_key_st { + const EC_KEY_METHOD *meth; + ENGINE *engine; + int version; + EC_GROUP *group; + EC_POINT *pub_key; + BIGNUM *priv_key; + unsigned int enc_flag; + point_conversion_form_t conv_form; + CRYPTO_REF_COUNT references; + int flags; + CRYPTO_EX_DATA ex_data; + CRYPTO_RWLOCK *lock; +}; + +struct ec_point_st { + const EC_METHOD *meth; + /* NID for the curve if known */ + int curve_name; + /* + * All members except 'meth' are handled by the method functions, even if + * they appear generic + */ + BIGNUM *X; + BIGNUM *Y; + BIGNUM *Z; /* Jacobian projective coordinates: * (X, Y, + * Z) represents (X/Z^2, Y/Z^3) if Z != 0 */ + int Z_is_one; /* enable optimized point arithmetics for + * special case */ +}; + +static ossl_inline int ec_point_is_compat(const EC_POINT *point, + const EC_GROUP *group) +{ + if (group->meth != point->meth + || (group->curve_name != 0 + && point->curve_name != 0 + && group->curve_name != point->curve_name)) + return 0; + + return 1; +} + +NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *); +NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *); +NISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *); +NISTZ256_PRE_COMP *EC_nistz256_pre_comp_dup(NISTZ256_PRE_COMP *); +NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *); +EC_PRE_COMP *EC_ec_pre_comp_dup(EC_PRE_COMP *); + +void EC_pre_comp_free(EC_GROUP *group); +void EC_nistp224_pre_comp_free(NISTP224_PRE_COMP *); +void EC_nistp256_pre_comp_free(NISTP256_PRE_COMP *); +void EC_nistp521_pre_comp_free(NISTP521_PRE_COMP *); +void EC_nistz256_pre_comp_free(NISTZ256_PRE_COMP *); +void EC_ec_pre_comp_free(EC_PRE_COMP *); + +/* + * method functions in ec_mult.c (ec_lib.c uses these as defaults if + * group->method->mul is 0) + */ +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 *); +int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *); +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 *); +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_GFp(const EC_GROUP *, + EC_POINT *, const BIGNUM *x, + const BIGNUM *y, + const BIGNUM *z, BN_CTX *); +int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *, + const EC_POINT *, BIGNUM *x, + BIGNUM *y, BIGNUM *z, + BN_CTX *); +int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, + const BIGNUM *y, BN_CTX *); +int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *, + const EC_POINT *, BIGNUM *x, + BIGNUM *y, BN_CTX *); +int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *, + const BIGNUM *x, int y_bit, + BN_CTX *); +size_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *, + point_conversion_form_t form, + unsigned char *buf, size_t len, BN_CTX *); +int ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *, + const unsigned char *buf, size_t len, BN_CTX *); +int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, + const EC_POINT *b, BN_CTX *); +int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, + BN_CTX *); +int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); +int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *); +int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); +int ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, + BN_CTX *); +int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); +int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num, + EC_POINT *[], BN_CTX *); +int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, + const BIGNUM *b, BN_CTX *); +int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, + BN_CTX *); +int ec_GFp_simple_field_inv(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, + BN_CTX *); +int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p, + BN_CTX *ctx); +int ec_GFp_simple_ladder_pre(const EC_GROUP *group, + EC_POINT *r, EC_POINT *s, + EC_POINT *p, BN_CTX *ctx); +int ec_GFp_simple_ladder_step(const EC_GROUP *group, + EC_POINT *r, EC_POINT *s, + EC_POINT *p, BN_CTX *ctx); +int ec_GFp_simple_ladder_post(const EC_GROUP *group, + EC_POINT *r, EC_POINT *s, + EC_POINT *p, BN_CTX *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_inv(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 *); + +/* 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 *); + +#ifndef OPENSSL_NO_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); + +/* 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 +int ec_group_simple_order_bits(const EC_GROUP *group); + +#ifdef ECP_NISTZ256_ASM +/** Returns GFp methods using montgomery multiplication, with x86-64 optimized + * P256. See http://eprint.iacr.org/2013/816. + * \return EC_METHOD object + */ +const EC_METHOD *EC_GFp_nistz256_method(void); +#endif + +size_t ec_key_simple_priv2oct(const EC_KEY *eckey, + unsigned char *buf, size_t len); +int ec_key_simple_oct2priv(EC_KEY *eckey, const unsigned char *buf, size_t len); +int ec_key_simple_generate_key(EC_KEY *eckey); +int ec_key_simple_generate_public_key(EC_KEY *eckey); +int ec_key_simple_check_key(const EC_KEY *eckey); + +int ec_curve_nid_from_params(const EC_GROUP *group, BN_CTX *ctx); + +/* EC_METHOD definitions */ + +struct ec_key_method_st { + const char *name; + int32_t flags; + int (*init)(EC_KEY *key); + void (*finish)(EC_KEY *key); + int (*copy)(EC_KEY *dest, const EC_KEY *src); + int (*set_group)(EC_KEY *key, const EC_GROUP *grp); + int (*set_private)(EC_KEY *key, const BIGNUM *priv_key); + int (*set_public)(EC_KEY *key, const EC_POINT *pub_key); + int (*keygen)(EC_KEY *key); + int (*compute_key)(unsigned char **pout, size_t *poutlen, + const EC_POINT *pub_key, const EC_KEY *ecdh); + int (*sign)(int type, const unsigned char *dgst, int dlen, unsigned char + *sig, unsigned int *siglen, const BIGNUM *kinv, + const BIGNUM *r, EC_KEY *eckey); + int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp); + ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, int dgst_len, + const BIGNUM *in_kinv, const BIGNUM *in_r, + EC_KEY *eckey); + + int (*verify)(int type, const unsigned char *dgst, int dgst_len, + const unsigned char *sigbuf, int sig_len, EC_KEY *eckey); + int (*verify_sig)(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY *eckey); +}; + +#define EC_KEY_METHOD_DYNAMIC 1 + +int ossl_ec_key_gen(EC_KEY *eckey); +int ossl_ecdh_compute_key(unsigned char **pout, size_t *poutlen, + const EC_POINT *pub_key, const EC_KEY *ecdh); +int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen, + const EC_POINT *pub_key, const EC_KEY *ecdh); + +struct ECDSA_SIG_st { + BIGNUM *r; + BIGNUM *s; +}; + +int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, + BIGNUM **rp); +int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen, + unsigned char *sig, unsigned int *siglen, + const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey); +ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len, + const BIGNUM *in_kinv, const BIGNUM *in_r, + EC_KEY *eckey); +int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len, + const unsigned char *sigbuf, int sig_len, EC_KEY *eckey); +int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, + const ECDSA_SIG *sig, EC_KEY *eckey); + +int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, + const uint8_t public_key[32], const uint8_t private_key[32]); +int ED25519_verify(const uint8_t *message, size_t message_len, + const uint8_t signature[64], const uint8_t public_key[32]); +void ED25519_public_from_private(uint8_t out_public_key[32], + const uint8_t private_key[32]); + +int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32], + const uint8_t peer_public_value[32]); +void X25519_public_from_private(uint8_t out_public_value[32], + const uint8_t private_key[32]); + +/*- + * This functions computes a single point multiplication over the EC group, + * using, at a high level, a Montgomery ladder with conditional swaps, with + * various timing attack defenses. + * + * It performs either a fixed point multiplication + * (scalar * generator) + * when point is NULL, or a variable point multiplication + * (scalar * point) + * when point is not NULL. + * + * `scalar` cannot be NULL and should be in the range [0,n) otherwise all + * constant time bets are off (where n is the cardinality of the EC group). + * + * This function expects `group->order` and `group->cardinality` to be well + * defined and non-zero: it fails with an error code otherwise. + * + * NB: This says nothing about the constant-timeness of the ladder step + * implementation (i.e., the default implementation is based on EC_POINT_add and + * EC_POINT_dbl, which of course are not constant time themselves) or the + * underlying multiprecision arithmetic. + * + * The product is stored in `r`. + * + * This is an internal function: callers are in charge of ensuring that the + * input parameters `group`, `r`, `scalar` and `ctx` are not NULL. + * + * Returns 1 on success, 0 otherwise. + */ +int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r, + const BIGNUM *scalar, const EC_POINT *point, + BN_CTX *ctx); + +int ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx); + +static ossl_inline int ec_point_ladder_pre(const EC_GROUP *group, + EC_POINT *r, EC_POINT *s, + EC_POINT *p, BN_CTX *ctx) +{ + if (group->meth->ladder_pre != NULL) + return group->meth->ladder_pre(group, r, s, p, ctx); + + if (!EC_POINT_copy(s, p) + || !EC_POINT_dbl(group, r, s, ctx)) + return 0; + + return 1; +} + +static ossl_inline int ec_point_ladder_step(const EC_GROUP *group, + EC_POINT *r, EC_POINT *s, + EC_POINT *p, BN_CTX *ctx) +{ + if (group->meth->ladder_step != NULL) + return group->meth->ladder_step(group, r, s, p, ctx); + + if (!EC_POINT_add(group, s, r, s, ctx) + || !EC_POINT_dbl(group, r, r, ctx)) + return 0; + + return 1; + +} + +static ossl_inline int ec_point_ladder_post(const EC_GROUP *group, + EC_POINT *r, EC_POINT *s, + EC_POINT *p, BN_CTX *ctx) +{ + if (group->meth->ladder_post != NULL) + return group->meth->ladder_post(group, r, s, p, ctx); + + return 1; +} diff --git a/contrib/libs/openssl/crypto/ec/ec_mult.c b/contrib/libs/openssl/crypto/ec/ec_mult.c index f4d7bca383..9a1e3974ed 100644 --- a/contrib/libs/openssl/crypto/ec/ec_mult.c +++ b/contrib/libs/openssl/crypto/ec/ec_mult.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -12,8 +12,8 @@ #include <openssl/err.h> #include "internal/cryptlib.h" -#include "crypto/bn.h" -#include "ec_local.h" +#include "crypto/bn.h" +#include "ec_local.h" #include "internal/refcount.h" /* @@ -260,10 +260,10 @@ int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r, goto err; } - /* ensure input point is in affine coords for ladder step efficiency */ - if (!p->Z_is_one && !EC_POINT_make_affine(group, p, ctx)) { - ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_EC_LIB); - goto err; + /* ensure input point is in affine coords for ladder step efficiency */ + if (!p->Z_is_one && !EC_POINT_make_affine(group, p, ctx)) { + ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_EC_LIB); + goto err; } /* Initialize the Montgomery ladder */ @@ -740,20 +740,20 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, if (r_is_at_infinity) { if (!EC_POINT_copy(r, val_sub[i][digit >> 1])) goto err; - - /*- - * Apply coordinate blinding for EC_POINT. - * - * The underlying EC_METHOD can optionally implement this function: - * ec_point_blind_coordinates() returns 0 in case of errors or 1 on - * success or if coordinate blinding is not implemented for this - * group. - */ - if (!ec_point_blind_coordinates(group, r, ctx)) { - ECerr(EC_F_EC_WNAF_MUL, EC_R_POINT_COORDINATES_BLIND_FAILURE); - goto err; - } - + + /*- + * Apply coordinate blinding for EC_POINT. + * + * The underlying EC_METHOD can optionally implement this function: + * ec_point_blind_coordinates() returns 0 in case of errors or 1 on + * success or if coordinate blinding is not implemented for this + * group. + */ + if (!ec_point_blind_coordinates(group, r, ctx)) { + ECerr(EC_F_EC_WNAF_MUL, EC_R_POINT_COORDINATES_BLIND_FAILURE); + goto err; + } + r_is_at_infinity = 0; } else { if (!EC_POINT_add diff --git a/contrib/libs/openssl/crypto/ec/ec_oct.c b/contrib/libs/openssl/crypto/ec/ec_oct.c index 145886ad6b..7ddc86b047 100644 --- a/contrib/libs/openssl/crypto/ec/ec_oct.c +++ b/contrib/libs/openssl/crypto/ec/ec_oct.c @@ -13,7 +13,7 @@ #include <openssl/err.h> #include <openssl/opensslv.h> -#include "ec_local.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) diff --git a/contrib/libs/openssl/crypto/ec/ec_pmeth.c b/contrib/libs/openssl/crypto/ec/ec_pmeth.c index 01aa12123b..64d2cc93a6 100644 --- a/contrib/libs/openssl/crypto/ec/ec_pmeth.c +++ b/contrib/libs/openssl/crypto/ec/ec_pmeth.c @@ -12,9 +12,9 @@ #include <openssl/asn1t.h> #include <openssl/x509.h> #include <openssl/ec.h> -#include "ec_local.h" +#include "ec_local.h" #include <openssl/evp.h> -#include "crypto/evp.h" +#include "crypto/evp.h" /* EC pkey context structure */ diff --git a/contrib/libs/openssl/crypto/ec/ec_print.c b/contrib/libs/openssl/crypto/ec/ec_print.c index 0eeded3799..660fc400fb 100644 --- a/contrib/libs/openssl/crypto/ec/ec_print.c +++ b/contrib/libs/openssl/crypto/ec/ec_print.c @@ -9,7 +9,7 @@ #include <openssl/crypto.h> #include <openssl/err.h> -#include "ec_local.h" +#include "ec_local.h" BIGNUM *EC_POINT_point2bn(const EC_GROUP *group, const EC_POINT *point, @@ -39,13 +39,13 @@ EC_POINT *EC_POINT_bn2point(const EC_GROUP *group, EC_POINT *ret; if ((buf_len = BN_num_bytes(bn)) == 0) - buf_len = 1; + buf_len = 1; if ((buf = OPENSSL_malloc(buf_len)) == NULL) { ECerr(EC_F_EC_POINT_BN2POINT, ERR_R_MALLOC_FAILURE); return NULL; } - if (!BN_bn2binpad(bn, buf, buf_len)) { + if (!BN_bn2binpad(bn, buf, buf_len)) { OPENSSL_free(buf); return NULL; } diff --git a/contrib/libs/openssl/crypto/ec/ecdh_kdf.c b/contrib/libs/openssl/crypto/ec/ecdh_kdf.c index bb55ec0fb8..96efac62f6 100644 --- a/contrib/libs/openssl/crypto/ec/ecdh_kdf.c +++ b/contrib/libs/openssl/crypto/ec/ecdh_kdf.c @@ -10,7 +10,7 @@ #include <string.h> #include <openssl/ec.h> #include <openssl/evp.h> -#include "ec_local.h" +#include "ec_local.h" /* Key derivation function from X9.63/SECG */ /* Way more than we will ever need */ diff --git a/contrib/libs/openssl/crypto/ec/ecdh_ossl.c b/contrib/libs/openssl/crypto/ec/ecdh_ossl.c index adc1675421..0be00d43da 100644 --- a/contrib/libs/openssl/crypto/ec/ecdh_ossl.c +++ b/contrib/libs/openssl/crypto/ec/ecdh_ossl.c @@ -17,7 +17,7 @@ #include <openssl/bn.h> #include <openssl/objects.h> #include <openssl/ec.h> -#include "ec_local.h" +#include "ec_local.h" int ossl_ecdh_compute_key(unsigned char **psec, size_t *pseclen, const EC_POINT *pub_key, const EC_KEY *ecdh) diff --git a/contrib/libs/openssl/crypto/ec/ecdsa_ossl.c b/contrib/libs/openssl/crypto/ec/ecdsa_ossl.c index b87cb122ee..1da87bfb5e 100644 --- a/contrib/libs/openssl/crypto/ec/ecdsa_ossl.c +++ b/contrib/libs/openssl/crypto/ec/ecdsa_ossl.c @@ -11,8 +11,8 @@ #include <openssl/err.h> #include <openssl/obj_mac.h> #include <openssl/rand.h> -#include "crypto/bn.h" -#include "ec_local.h" +#include "crypto/bn.h" +#include "ec_local.h" int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, unsigned int *siglen, @@ -309,7 +309,7 @@ int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len, goto err; ret = ECDSA_do_verify(dgst, dgst_len, s, eckey); err: - OPENSSL_free(der); + OPENSSL_free(der); ECDSA_SIG_free(s); return ret; } diff --git a/contrib/libs/openssl/crypto/ec/ecdsa_sign.c b/contrib/libs/openssl/crypto/ec/ecdsa_sign.c index b42b9f7324..dc79c8c8e3 100644 --- a/contrib/libs/openssl/crypto/ec/ecdsa_sign.c +++ b/contrib/libs/openssl/crypto/ec/ecdsa_sign.c @@ -8,7 +8,7 @@ */ #include <openssl/ec.h> -#include "ec_local.h" +#include "ec_local.h" #include <openssl/err.h> ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) diff --git a/contrib/libs/openssl/crypto/ec/ecdsa_vrf.c b/contrib/libs/openssl/crypto/ec/ecdsa_vrf.c index e76caa836a..ff597bdc14 100644 --- a/contrib/libs/openssl/crypto/ec/ecdsa_vrf.c +++ b/contrib/libs/openssl/crypto/ec/ecdsa_vrf.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,7 +8,7 @@ */ #include <openssl/ec.h> -#include "ec_local.h" +#include "ec_local.h" #include <openssl/err.h> /*- @@ -23,7 +23,7 @@ int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, if (eckey->meth->verify_sig != NULL) return eckey->meth->verify_sig(dgst, dgst_len, sig, eckey); ECerr(EC_F_ECDSA_DO_VERIFY, EC_R_OPERATION_NOT_SUPPORTED); - return -1; + return -1; } /*- @@ -39,5 +39,5 @@ int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len, return eckey->meth->verify(type, dgst, dgst_len, sigbuf, sig_len, eckey); ECerr(EC_F_ECDSA_VERIFY, EC_R_OPERATION_NOT_SUPPORTED); - return -1; + return -1; } diff --git a/contrib/libs/openssl/crypto/ec/ecp_mont.c b/contrib/libs/openssl/crypto/ec/ecp_mont.c index 4a345e4c44..bdc39d5efb 100644 --- a/contrib/libs/openssl/crypto/ec/ecp_mont.c +++ b/contrib/libs/openssl/crypto/ec/ecp_mont.c @@ -10,7 +10,7 @@ #include <openssl/err.h> -#include "ec_local.h" +#include "ec_local.h" const EC_METHOD *EC_GFp_mont_method(void) { diff --git a/contrib/libs/openssl/crypto/ec/ecp_nist.c b/contrib/libs/openssl/crypto/ec/ecp_nist.c index 59a5e45e81..9fd01279a8 100644 --- a/contrib/libs/openssl/crypto/ec/ecp_nist.c +++ b/contrib/libs/openssl/crypto/ec/ecp_nist.c @@ -12,7 +12,7 @@ #include <openssl/err.h> #include <openssl/obj_mac.h> -#include "ec_local.h" +#include "ec_local.h" const EC_METHOD *EC_GFp_nist_method(void) { diff --git a/contrib/libs/openssl/crypto/ec/ecp_nistp224.c b/contrib/libs/openssl/crypto/ec/ecp_nistp224.c index 578f616da6..6f7d66c8be 100644 --- a/contrib/libs/openssl/crypto/ec/ecp_nistp224.c +++ b/contrib/libs/openssl/crypto/ec/ecp_nistp224.c @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -38,7 +38,7 @@ NON_EMPTY_TRANSLATION_UNIT # include <stdint.h> # include <string.h> # include <openssl/err.h> -# include "ec_local.h" +# include "ec_local.h" # if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 /* even with gcc, the typedef won't work for 32-bit platforms */ @@ -908,7 +908,7 @@ static void point_add(felem x3, felem y3, felem z3, felem ftmp, ftmp2, ftmp3, ftmp4, ftmp5, x_out, y_out, z_out; widefelem tmp, tmp2; limb z1_is_zero, z2_is_zero, x_equal, y_equal; - limb points_equal; + limb points_equal; if (!mixed) { /* ftmp2 = z2^2 */ @@ -965,41 +965,41 @@ static void point_add(felem x3, felem y3, felem z3, felem_reduce(ftmp, tmp); /* - * The formulae are incorrect if the points are equal, in affine coordinates - * (X_1, Y_1) == (X_2, Y_2), so we check for this and do doubling if this - * happens. - * - * We use bitwise operations to avoid potential side-channels introduced by - * the short-circuiting behaviour of boolean operators. + * The formulae are incorrect if the points are equal, in affine coordinates + * (X_1, Y_1) == (X_2, Y_2), so we check for this and do doubling if this + * happens. + * + * We use bitwise operations to avoid potential side-channels introduced by + * the short-circuiting behaviour of boolean operators. */ x_equal = felem_is_zero(ftmp); y_equal = felem_is_zero(ftmp3); - /* - * The special case of either point being the point at infinity (z1 and/or - * z2 are zero), is handled separately later on in this function, so we - * avoid jumping to point_double here in those special cases. - */ + /* + * The special case of either point being the point at infinity (z1 and/or + * z2 are zero), is handled separately later on in this function, so we + * avoid jumping to point_double here in those special cases. + */ z1_is_zero = felem_is_zero(z1); z2_is_zero = felem_is_zero(z2); - - /* - * Compared to `ecp_nistp256.c` and `ecp_nistp521.c`, in this - * specific implementation `felem_is_zero()` returns truth as `0x1` - * (rather than `0xff..ff`). - * - * This implies that `~true` in this implementation becomes - * `0xff..fe` (rather than `0x0`): for this reason, to be used in - * the if expression, we mask out only the last bit in the next - * line. - */ - points_equal = (x_equal & y_equal & (~z1_is_zero) & (~z2_is_zero)) & 1; - - if (points_equal) { - /* - * This is obviously not constant-time but, as mentioned before, this - * case never happens during single point multiplication, so there is no - * timing leak for ECDH or ECDSA signing. - */ + + /* + * Compared to `ecp_nistp256.c` and `ecp_nistp521.c`, in this + * specific implementation `felem_is_zero()` returns truth as `0x1` + * (rather than `0xff..ff`). + * + * This implies that `~true` in this implementation becomes + * `0xff..fe` (rather than `0x0`): for this reason, to be used in + * the if expression, we mask out only the last bit in the next + * line. + */ + points_equal = (x_equal & y_equal & (~z1_is_zero) & (~z2_is_zero)) & 1; + + if (points_equal) { + /* + * This is obviously not constant-time but, as mentioned before, this + * case never happens during single point multiplication, so there is no + * timing leak for ECDH or ECDSA signing. + */ point_double(x3, y3, z3, x1, y1, z1); return; } diff --git a/contrib/libs/openssl/crypto/ec/ecp_nistp256.c b/contrib/libs/openssl/crypto/ec/ecp_nistp256.c index cf89a085ec..e23e9d2a0b 100644 --- a/contrib/libs/openssl/crypto/ec/ecp_nistp256.c +++ b/contrib/libs/openssl/crypto/ec/ecp_nistp256.c @@ -1,5 +1,5 @@ /* - * Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -39,7 +39,7 @@ NON_EMPTY_TRANSLATION_UNIT # include <stdint.h> # include <string.h> # include <openssl/err.h> -# include "ec_local.h" +# include "ec_local.h" # if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 /* even with gcc, the typedef won't work for 32-bit platforms */ @@ -74,8 +74,8 @@ static const felem_bytearray nistp256_curve_params[5] = { {0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, /* a = -3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc}, - {0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, /* b */ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc}, + {0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, /* b */ 0xb3, 0xeb, 0xbd, 0x55, 0x76, 0x98, 0x86, 0xbc, 0x65, 0x1d, 0x06, 0xb0, 0xcc, 0x53, 0xb0, 0xf6, 0x3b, 0xce, 0x3c, 0x3e, 0x27, 0xd2, 0x60, 0x4b}, @@ -1241,7 +1241,7 @@ static void point_add(felem x3, felem y3, felem z3, longfelem tmp, tmp2; smallfelem small1, small2, small3, small4, small5; limb x_equal, y_equal, z1_is_zero, z2_is_zero; - limb points_equal; + limb points_equal; felem_shrink(small3, z1); @@ -1341,26 +1341,26 @@ static void point_add(felem x3, felem y3, felem z3, felem_shrink(small1, ftmp5); y_equal = smallfelem_is_zero(small1); - /* - * The formulae are incorrect if the points are equal, in affine coordinates - * (X_1, Y_1) == (X_2, Y_2), so we check for this and do doubling if this - * happens. - * - * We use bitwise operations to avoid potential side-channels introduced by - * the short-circuiting behaviour of boolean operators. - * - * The special case of either point being the point at infinity (z1 and/or - * z2 are zero), is handled separately later on in this function, so we - * avoid jumping to point_double here in those special cases. - */ - points_equal = (x_equal & y_equal & (~z1_is_zero) & (~z2_is_zero)); - - if (points_equal) { - /* - * This is obviously not constant-time but, as mentioned before, this - * case never happens during single point multiplication, so there is no - * timing leak for ECDH or ECDSA signing. - */ + /* + * The formulae are incorrect if the points are equal, in affine coordinates + * (X_1, Y_1) == (X_2, Y_2), so we check for this and do doubling if this + * happens. + * + * We use bitwise operations to avoid potential side-channels introduced by + * the short-circuiting behaviour of boolean operators. + * + * The special case of either point being the point at infinity (z1 and/or + * z2 are zero), is handled separately later on in this function, so we + * avoid jumping to point_double here in those special cases. + */ + points_equal = (x_equal & y_equal & (~z1_is_zero) & (~z2_is_zero)); + + if (points_equal) { + /* + * This is obviously not constant-time but, as mentioned before, this + * case never happens during single point multiplication, so there is no + * timing leak for ECDH or ECDSA signing. + */ point_double(x3, y3, z3, x1, y1, z1); return; } diff --git a/contrib/libs/openssl/crypto/ec/ecp_nistp521.c b/contrib/libs/openssl/crypto/ec/ecp_nistp521.c index 38cfcfe3f3..08b3278729 100644 --- a/contrib/libs/openssl/crypto/ec/ecp_nistp521.c +++ b/contrib/libs/openssl/crypto/ec/ecp_nistp521.c @@ -1,5 +1,5 @@ /* - * Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -38,7 +38,7 @@ NON_EMPTY_TRANSLATION_UNIT # include <string.h> # include <openssl/err.h> -# include "ec_local.h" +# include "ec_local.h" # if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 /* even with gcc, the typedef won't work for 32-bit platforms */ @@ -1159,7 +1159,7 @@ static void point_add(felem x3, felem y3, felem z3, felem ftmp, ftmp2, ftmp3, ftmp4, ftmp5, ftmp6, x_out, y_out, z_out; largefelem tmp, tmp2; limb x_equal, y_equal, z1_is_zero, z2_is_zero; - limb points_equal; + limb points_equal; z1_is_zero = felem_is_zero(z1); z2_is_zero = felem_is_zero(z2); @@ -1244,24 +1244,24 @@ static void point_add(felem x3, felem y3, felem z3, felem_scalar64(ftmp5, 2); /* ftmp5[i] < 2^61 */ - /* - * The formulae are incorrect if the points are equal, in affine coordinates - * (X_1, Y_1) == (X_2, Y_2), so we check for this and do doubling if this - * happens. - * - * We use bitwise operations to avoid potential side-channels introduced by - * the short-circuiting behaviour of boolean operators. - * - * The special case of either point being the point at infinity (z1 and/or - * z2 are zero), is handled separately later on in this function, so we - * avoid jumping to point_double here in those special cases. - * - * Notice the comment below on the implications of this branching for timing - * leaks and why it is considered practically irrelevant. - */ - points_equal = (x_equal & y_equal & (~z1_is_zero) & (~z2_is_zero)); - - if (points_equal) { + /* + * The formulae are incorrect if the points are equal, in affine coordinates + * (X_1, Y_1) == (X_2, Y_2), so we check for this and do doubling if this + * happens. + * + * We use bitwise operations to avoid potential side-channels introduced by + * the short-circuiting behaviour of boolean operators. + * + * The special case of either point being the point at infinity (z1 and/or + * z2 are zero), is handled separately later on in this function, so we + * avoid jumping to point_double here in those special cases. + * + * Notice the comment below on the implications of this branching for timing + * leaks and why it is considered practically irrelevant. + */ + points_equal = (x_equal & y_equal & (~z1_is_zero) & (~z2_is_zero)); + + if (points_equal) { /* * This is obviously not constant-time but it will almost-never happen * for ECDH / ECDSA. The case where it can happen is during scalar-mult diff --git a/contrib/libs/openssl/crypto/ec/ecp_nistputil.c b/contrib/libs/openssl/crypto/ec/ecp_nistputil.c index 4171c35f5c..60e1325c34 100644 --- a/contrib/libs/openssl/crypto/ec/ecp_nistputil.c +++ b/contrib/libs/openssl/crypto/ec/ecp_nistputil.c @@ -33,7 +33,7 @@ NON_EMPTY_TRANSLATION_UNIT */ # include <stddef.h> -# include "ec_local.h" +# include "ec_local.h" /* * Convert an array of points into affine coordinates. (If the point at diff --git a/contrib/libs/openssl/crypto/ec/ecp_nistz256.c b/contrib/libs/openssl/crypto/ec/ecp_nistz256.c index 46a015bff1..4c4839cc13 100644 --- a/contrib/libs/openssl/crypto/ec/ecp_nistz256.c +++ b/contrib/libs/openssl/crypto/ec/ecp_nistz256.c @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2014, Intel Corporation. All Rights Reserved. * Copyright (c) 2015, CloudFlare, Inc. * @@ -21,8 +21,8 @@ #include <string.h> #include "internal/cryptlib.h" -#include "crypto/bn.h" -#include "ec_local.h" +#include "crypto/bn.h" +#include "ec_local.h" #include "internal/refcount.h" #include "sanitizers.h" @@ -359,47 +359,47 @@ static void ecp_nistz256_point_add(P256_POINT *r, ecp_nistz256_sub(H, U2, U1); /* H = U2 - U1 */ /* - * The formulae are incorrect if the points are equal so we check for - * this and do doubling if this happens. - * - * Points here are in Jacobian projective coordinates (Xi, Yi, Zi) - * that are bound to the affine coordinates (xi, yi) by the following - * equations: - * - xi = Xi / (Zi)^2 - * - y1 = Yi / (Zi)^3 - * - * For the sake of optimization, the algorithm operates over - * intermediate variables U1, U2 and S1, S2 that are derived from - * the projective coordinates: - * - U1 = X1 * (Z2)^2 ; U2 = X2 * (Z1)^2 - * - S1 = Y1 * (Z2)^3 ; S2 = Y2 * (Z1)^3 - * - * It is easy to prove that is_equal(U1, U2) implies that the affine - * x-coordinates are equal, or either point is at infinity. - * Likewise is_equal(S1, S2) implies that the affine y-coordinates are - * equal, or either point is at infinity. - * - * The special case of either point being the point at infinity (Z1 or Z2 - * is zero), is handled separately later on in this function, so we avoid - * jumping to point_double here in those special cases. - * - * When both points are inverse of each other, we know that the affine - * x-coordinates are equal, and the y-coordinates have different sign. - * Therefore since U1 = U2, we know H = 0, and therefore Z3 = H*Z1*Z2 - * will equal 0, thus the result is infinity, if we simply let this - * function continue normally. - * - * We use bitwise operations to avoid potential side-channels introduced by - * the short-circuiting behaviour of boolean operators. + * The formulae are incorrect if the points are equal so we check for + * this and do doubling if this happens. + * + * Points here are in Jacobian projective coordinates (Xi, Yi, Zi) + * that are bound to the affine coordinates (xi, yi) by the following + * equations: + * - xi = Xi / (Zi)^2 + * - y1 = Yi / (Zi)^3 + * + * For the sake of optimization, the algorithm operates over + * intermediate variables U1, U2 and S1, S2 that are derived from + * the projective coordinates: + * - U1 = X1 * (Z2)^2 ; U2 = X2 * (Z1)^2 + * - S1 = Y1 * (Z2)^3 ; S2 = Y2 * (Z1)^3 + * + * It is easy to prove that is_equal(U1, U2) implies that the affine + * x-coordinates are equal, or either point is at infinity. + * Likewise is_equal(S1, S2) implies that the affine y-coordinates are + * equal, or either point is at infinity. + * + * The special case of either point being the point at infinity (Z1 or Z2 + * is zero), is handled separately later on in this function, so we avoid + * jumping to point_double here in those special cases. + * + * When both points are inverse of each other, we know that the affine + * x-coordinates are equal, and the y-coordinates have different sign. + * Therefore since U1 = U2, we know H = 0, and therefore Z3 = H*Z1*Z2 + * will equal 0, thus the result is infinity, if we simply let this + * function continue normally. + * + * We use bitwise operations to avoid potential side-channels introduced by + * the short-circuiting behaviour of boolean operators. */ - if (is_equal(U1, U2) & ~in1infty & ~in2infty & is_equal(S1, S2)) { - /* - * This is obviously not constant-time but it should never happen during - * single point multiplication, so there is no timing leak for ECDH or - * ECDSA signing. - */ - ecp_nistz256_point_double(r, a); - return; + if (is_equal(U1, U2) & ~in1infty & ~in2infty & is_equal(S1, S2)) { + /* + * This is obviously not constant-time but it should never happen during + * single point multiplication, so there is no timing leak for ECDH or + * ECDSA signing. + */ + ecp_nistz256_point_double(r, a); + return; } ecp_nistz256_sqr_mont(Rsqr, R); /* R^2 */ diff --git a/contrib/libs/openssl/crypto/ec/ecp_oct.c b/contrib/libs/openssl/crypto/ec/ecp_oct.c index b4c61a1ed2..9460763256 100644 --- a/contrib/libs/openssl/crypto/ec/ecp_oct.c +++ b/contrib/libs/openssl/crypto/ec/ecp_oct.c @@ -11,7 +11,7 @@ #include <openssl/err.h> #include <openssl/symhacks.h> -#include "ec_local.h" +#include "ec_local.h" int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point, diff --git a/contrib/libs/openssl/crypto/ec/ecp_smpl.c b/contrib/libs/openssl/crypto/ec/ecp_smpl.c index 6eba0ee39b..b3110ec89d 100644 --- a/contrib/libs/openssl/crypto/ec/ecp_smpl.c +++ b/contrib/libs/openssl/crypto/ec/ecp_smpl.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -11,7 +11,7 @@ #include <openssl/err.h> #include <openssl/symhacks.h> -#include "ec_local.h" +#include "ec_local.h" const EC_METHOD *EC_GFp_simple_method(void) { @@ -1372,7 +1372,7 @@ int ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, * Computes the multiplicative inverse of a in GF(p), storing the result in r. * If a is zero (or equivalent), you'll get a EC_R_CANNOT_INVERT error. * Since we don't have a Mont structure here, SCA hardening is with blinding. - * NB: "a" must be in _decoded_ form. (i.e. field_decode must precede.) + * NB: "a" must be in _decoded_ form. (i.e. field_decode must precede.) */ int ec_GFp_simple_field_inv(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) @@ -1432,108 +1432,108 @@ int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p, temp = BN_CTX_get(ctx); if (temp == NULL) { ECerr(EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES, ERR_R_MALLOC_FAILURE); - goto end; + goto end; } - /*- - * Make sure lambda is not zero. - * If the RNG fails, we cannot blind but nevertheless want - * code to continue smoothly and not clobber the error stack. - */ + /*- + * Make sure lambda is not zero. + * If the RNG fails, we cannot blind but nevertheless want + * code to continue smoothly and not clobber the error stack. + */ do { - ERR_set_mark(); - ret = BN_priv_rand_range(lambda, group->field); - ERR_pop_to_mark(); - if (ret == 0) { - ret = 1; - goto end; + ERR_set_mark(); + ret = BN_priv_rand_range(lambda, group->field); + ERR_pop_to_mark(); + if (ret == 0) { + ret = 1; + goto end; } } while (BN_is_zero(lambda)); /* if field_encode defined convert between representations */ - if ((group->meth->field_encode != NULL - && !group->meth->field_encode(group, lambda, lambda, ctx)) - || !group->meth->field_mul(group, p->Z, p->Z, lambda, ctx) - || !group->meth->field_sqr(group, temp, lambda, ctx) - || !group->meth->field_mul(group, p->X, p->X, temp, ctx) - || !group->meth->field_mul(group, temp, temp, lambda, ctx) - || !group->meth->field_mul(group, p->Y, p->Y, temp, ctx)) - goto end; - + if ((group->meth->field_encode != NULL + && !group->meth->field_encode(group, lambda, lambda, ctx)) + || !group->meth->field_mul(group, p->Z, p->Z, lambda, ctx) + || !group->meth->field_sqr(group, temp, lambda, ctx) + || !group->meth->field_mul(group, p->X, p->X, temp, ctx) + || !group->meth->field_mul(group, temp, temp, lambda, ctx) + || !group->meth->field_mul(group, p->Y, p->Y, temp, ctx)) + goto end; + p->Z_is_one = 0; ret = 1; - end: + end: BN_CTX_end(ctx); return ret; } /*- - * Input: - * - p: affine coordinates + * Input: + * - p: affine coordinates + * + * Output: + * - s := p, r := 2p: blinded projective (homogeneous) coordinates * - * Output: - * - s := p, r := 2p: blinded projective (homogeneous) coordinates - * * For doubling we use Formula 3 from Izu-Takagi "A fast parallel elliptic curve - * multiplication resistant against side channel attacks" appendix, described at + * multiplication resistant against side channel attacks" appendix, described at * https://hyperelliptic.org/EFD/g1p/auto-shortw-xz.html#doubling-dbl-2002-it-2 - * simplified for Z1=1. + * simplified for Z1=1. * - * Blinding uses the equivalence relation (\lambda X, \lambda Y, \lambda Z) - * for any non-zero \lambda that holds for projective (homogeneous) coords. + * Blinding uses the equivalence relation (\lambda X, \lambda Y, \lambda Z) + * for any non-zero \lambda that holds for projective (homogeneous) coords. */ int ec_GFp_simple_ladder_pre(const EC_GROUP *group, EC_POINT *r, EC_POINT *s, EC_POINT *p, BN_CTX *ctx) { - BIGNUM *t1, *t2, *t3, *t4, *t5 = NULL; + BIGNUM *t1, *t2, *t3, *t4, *t5 = NULL; - t1 = s->Z; - t2 = r->Z; + t1 = s->Z; + t2 = r->Z; t3 = s->X; t4 = r->X; t5 = s->Y; - if (!p->Z_is_one /* r := 2p */ - || !group->meth->field_sqr(group, t3, p->X, ctx) - || !BN_mod_sub_quick(t4, t3, group->a, group->field) - || !group->meth->field_sqr(group, t4, t4, ctx) - || !group->meth->field_mul(group, t5, p->X, group->b, ctx) - || !BN_mod_lshift_quick(t5, t5, 3, group->field) + if (!p->Z_is_one /* r := 2p */ + || !group->meth->field_sqr(group, t3, p->X, ctx) + || !BN_mod_sub_quick(t4, t3, group->a, group->field) + || !group->meth->field_sqr(group, t4, t4, ctx) + || !group->meth->field_mul(group, t5, p->X, group->b, ctx) + || !BN_mod_lshift_quick(t5, t5, 3, group->field) /* r->X coord output */ - || !BN_mod_sub_quick(r->X, t4, t5, group->field) - || !BN_mod_add_quick(t1, t3, group->a, group->field) - || !group->meth->field_mul(group, t2, p->X, t1, ctx) - || !BN_mod_add_quick(t2, group->b, t2, group->field) + || !BN_mod_sub_quick(r->X, t4, t5, group->field) + || !BN_mod_add_quick(t1, t3, group->a, group->field) + || !group->meth->field_mul(group, t2, p->X, t1, ctx) + || !BN_mod_add_quick(t2, group->b, t2, group->field) /* r->Z coord output */ - || !BN_mod_lshift_quick(r->Z, t2, 2, group->field)) + || !BN_mod_lshift_quick(r->Z, t2, 2, group->field)) + return 0; + + /* make sure lambda (r->Y here for storage) is not zero */ + do { + if (!BN_priv_rand_range(r->Y, group->field)) + return 0; + } while (BN_is_zero(r->Y)); + + /* make sure lambda (s->Z here for storage) is not zero */ + do { + if (!BN_priv_rand_range(s->Z, group->field)) + return 0; + } while (BN_is_zero(s->Z)); + + /* if field_encode defined convert between representations */ + if (group->meth->field_encode != NULL + && (!group->meth->field_encode(group, r->Y, r->Y, ctx) + || !group->meth->field_encode(group, s->Z, s->Z, ctx))) + return 0; + + /* blind r and s independently */ + if (!group->meth->field_mul(group, r->Z, r->Z, r->Y, ctx) + || !group->meth->field_mul(group, r->X, r->X, r->Y, ctx) + || !group->meth->field_mul(group, s->X, p->X, s->Z, ctx)) /* s := p */ return 0; - /* make sure lambda (r->Y here for storage) is not zero */ - do { - if (!BN_priv_rand_range(r->Y, group->field)) - return 0; - } while (BN_is_zero(r->Y)); - - /* make sure lambda (s->Z here for storage) is not zero */ - do { - if (!BN_priv_rand_range(s->Z, group->field)) - return 0; - } while (BN_is_zero(s->Z)); - - /* if field_encode defined convert between representations */ - if (group->meth->field_encode != NULL - && (!group->meth->field_encode(group, r->Y, r->Y, ctx) - || !group->meth->field_encode(group, s->Z, s->Z, ctx))) - return 0; - - /* blind r and s independently */ - if (!group->meth->field_mul(group, r->Z, r->Z, r->Y, ctx) - || !group->meth->field_mul(group, r->X, r->X, r->Y, ctx) - || !group->meth->field_mul(group, s->X, p->X, s->Z, ctx)) /* s := p */ - return 0; - r->Z_is_one = 0; s->Z_is_one = 0; @@ -1541,24 +1541,24 @@ int ec_GFp_simple_ladder_pre(const EC_GROUP *group, } /*- - * Input: - * - s, r: projective (homogeneous) coordinates - * - p: affine coordinates - * - * Output: - * - s := r + s, r := 2r: projective (homogeneous) coordinates - * - * Differential addition-and-doubling using Eq. (9) and (10) from Izu-Takagi + * Input: + * - s, r: projective (homogeneous) coordinates + * - p: affine coordinates + * + * Output: + * - s := r + s, r := 2r: projective (homogeneous) coordinates + * + * Differential addition-and-doubling using Eq. (9) and (10) from Izu-Takagi * "A fast parallel elliptic curve multiplication resistant against side channel * attacks", as described at - * https://hyperelliptic.org/EFD/g1p/auto-shortw-xz.html#ladder-mladd-2002-it-4 + * https://hyperelliptic.org/EFD/g1p/auto-shortw-xz.html#ladder-mladd-2002-it-4 */ int ec_GFp_simple_ladder_step(const EC_GROUP *group, EC_POINT *r, EC_POINT *s, EC_POINT *p, BN_CTX *ctx) { int ret = 0; - BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6 = NULL; + BIGNUM *t0, *t1, *t2, *t3, *t4, *t5, *t6 = NULL; BN_CTX_start(ctx); t0 = BN_CTX_get(ctx); @@ -1569,46 +1569,46 @@ int ec_GFp_simple_ladder_step(const EC_GROUP *group, t5 = BN_CTX_get(ctx); t6 = BN_CTX_get(ctx); - if (t6 == NULL - || !group->meth->field_mul(group, t6, r->X, s->X, ctx) - || !group->meth->field_mul(group, t0, r->Z, s->Z, ctx) - || !group->meth->field_mul(group, t4, r->X, s->Z, ctx) + if (t6 == NULL + || !group->meth->field_mul(group, t6, r->X, s->X, ctx) + || !group->meth->field_mul(group, t0, r->Z, s->Z, ctx) + || !group->meth->field_mul(group, t4, r->X, s->Z, ctx) || !group->meth->field_mul(group, t3, r->Z, s->X, ctx) - || !group->meth->field_mul(group, t5, group->a, t0, ctx) - || !BN_mod_add_quick(t5, t6, t5, group->field) - || !BN_mod_add_quick(t6, t3, t4, group->field) - || !group->meth->field_mul(group, t5, t6, t5, ctx) - || !group->meth->field_sqr(group, t0, t0, ctx) - || !BN_mod_lshift_quick(t2, group->b, 2, group->field) - || !group->meth->field_mul(group, t0, t2, t0, ctx) - || !BN_mod_lshift1_quick(t5, t5, group->field) - || !BN_mod_sub_quick(t3, t4, t3, group->field) - /* s->Z coord output */ - || !group->meth->field_sqr(group, s->Z, t3, ctx) - || !group->meth->field_mul(group, t4, s->Z, p->X, ctx) - || !BN_mod_add_quick(t0, t0, t5, group->field) - /* s->X coord output */ - || !BN_mod_sub_quick(s->X, t0, t4, group->field) - || !group->meth->field_sqr(group, t4, r->X, ctx) - || !group->meth->field_sqr(group, t5, r->Z, ctx) - || !group->meth->field_mul(group, t6, t5, group->a, ctx) - || !BN_mod_add_quick(t1, r->X, r->Z, group->field) + || !group->meth->field_mul(group, t5, group->a, t0, ctx) + || !BN_mod_add_quick(t5, t6, t5, group->field) + || !BN_mod_add_quick(t6, t3, t4, group->field) + || !group->meth->field_mul(group, t5, t6, t5, ctx) + || !group->meth->field_sqr(group, t0, t0, ctx) + || !BN_mod_lshift_quick(t2, group->b, 2, group->field) + || !group->meth->field_mul(group, t0, t2, t0, ctx) + || !BN_mod_lshift1_quick(t5, t5, group->field) + || !BN_mod_sub_quick(t3, t4, t3, group->field) + /* s->Z coord output */ + || !group->meth->field_sqr(group, s->Z, t3, ctx) + || !group->meth->field_mul(group, t4, s->Z, p->X, ctx) + || !BN_mod_add_quick(t0, t0, t5, group->field) + /* s->X coord output */ + || !BN_mod_sub_quick(s->X, t0, t4, group->field) + || !group->meth->field_sqr(group, t4, r->X, ctx) + || !group->meth->field_sqr(group, t5, r->Z, ctx) + || !group->meth->field_mul(group, t6, t5, group->a, ctx) + || !BN_mod_add_quick(t1, r->X, r->Z, group->field) || !group->meth->field_sqr(group, t1, t1, ctx) - || !BN_mod_sub_quick(t1, t1, t4, group->field) - || !BN_mod_sub_quick(t1, t1, t5, group->field) - || !BN_mod_sub_quick(t3, t4, t6, group->field) - || !group->meth->field_sqr(group, t3, t3, ctx) - || !group->meth->field_mul(group, t0, t5, t1, ctx) - || !group->meth->field_mul(group, t0, t2, t0, ctx) + || !BN_mod_sub_quick(t1, t1, t4, group->field) + || !BN_mod_sub_quick(t1, t1, t5, group->field) + || !BN_mod_sub_quick(t3, t4, t6, group->field) + || !group->meth->field_sqr(group, t3, t3, ctx) + || !group->meth->field_mul(group, t0, t5, t1, ctx) + || !group->meth->field_mul(group, t0, t2, t0, ctx) /* r->X coord output */ - || !BN_mod_sub_quick(r->X, t3, t0, group->field) - || !BN_mod_add_quick(t3, t4, t6, group->field) - || !group->meth->field_sqr(group, t4, t5, ctx) - || !group->meth->field_mul(group, t4, t4, t2, ctx) - || !group->meth->field_mul(group, t1, t1, t3, ctx) - || !BN_mod_lshift1_quick(t1, t1, group->field) + || !BN_mod_sub_quick(r->X, t3, t0, group->field) + || !BN_mod_add_quick(t3, t4, t6, group->field) + || !group->meth->field_sqr(group, t4, t5, ctx) + || !group->meth->field_mul(group, t4, t4, t2, ctx) + || !group->meth->field_mul(group, t1, t1, t3, ctx) + || !BN_mod_lshift1_quick(t1, t1, group->field) /* r->Z coord output */ - || !BN_mod_add_quick(r->Z, t4, t1, group->field)) + || !BN_mod_add_quick(r->Z, t4, t1, group->field)) goto err; ret = 1; @@ -1619,21 +1619,21 @@ int ec_GFp_simple_ladder_step(const EC_GROUP *group, } /*- - * Input: - * - s, r: projective (homogeneous) coordinates - * - p: affine coordinates - * - * Output: - * - r := (x,y): affine coordinates - * + * Input: + * - s, r: projective (homogeneous) coordinates + * - p: affine coordinates + * + * Output: + * - r := (x,y): affine coordinates + * * Recovers the y-coordinate of r using Eq. (8) from Brier-Joye, "Weierstrass - * Elliptic Curves and Side-Channel Attacks", modified to work in mixed - * projective coords, i.e. p is affine and (r,s) in projective (homogeneous) - * coords, and return r in affine coordinates. + * Elliptic Curves and Side-Channel Attacks", modified to work in mixed + * projective coords, i.e. p is affine and (r,s) in projective (homogeneous) + * coords, and return r in affine coordinates. * - * X4 = two*Y1*X2*Z3*Z2; - * Y4 = two*b*Z3*SQR(Z2) + Z3*(a*Z2+X1*X2)*(X1*Z2+X2) - X3*SQR(X1*Z2-X2); - * Z4 = two*Y1*Z3*SQR(Z2); + * X4 = two*Y1*X2*Z3*Z2; + * Y4 = two*b*Z3*SQR(Z2) + Z3*(a*Z2+X1*X2)*(X1*Z2+X2) - X3*SQR(X1*Z2-X2); + * Z4 = two*Y1*Z3*SQR(Z2); * * Z4 != 0 because: * - Z2==0 implies r is at infinity (handled by the BN_is_zero(r->Z) branch); @@ -1652,7 +1652,7 @@ int ec_GFp_simple_ladder_post(const EC_GROUP *group, return EC_POINT_set_to_infinity(group, r); if (BN_is_zero(s->Z)) { - if (!EC_POINT_copy(r, p) + if (!EC_POINT_copy(r, p) || !EC_POINT_invert(group, r, ctx)) return 0; return 1; @@ -1668,46 +1668,46 @@ int ec_GFp_simple_ladder_post(const EC_GROUP *group, t6 = BN_CTX_get(ctx); if (t6 == NULL - || !BN_mod_lshift1_quick(t4, p->Y, group->field) - || !group->meth->field_mul(group, t6, r->X, t4, ctx) - || !group->meth->field_mul(group, t6, s->Z, t6, ctx) - || !group->meth->field_mul(group, t5, r->Z, t6, ctx) - || !BN_mod_lshift1_quick(t1, group->b, group->field) - || !group->meth->field_mul(group, t1, s->Z, t1, ctx) + || !BN_mod_lshift1_quick(t4, p->Y, group->field) + || !group->meth->field_mul(group, t6, r->X, t4, ctx) + || !group->meth->field_mul(group, t6, s->Z, t6, ctx) + || !group->meth->field_mul(group, t5, r->Z, t6, ctx) + || !BN_mod_lshift1_quick(t1, group->b, group->field) + || !group->meth->field_mul(group, t1, s->Z, t1, ctx) || !group->meth->field_sqr(group, t3, r->Z, ctx) - || !group->meth->field_mul(group, t2, t3, t1, ctx) - || !group->meth->field_mul(group, t6, r->Z, group->a, ctx) - || !group->meth->field_mul(group, t1, p->X, r->X, ctx) - || !BN_mod_add_quick(t1, t1, t6, group->field) - || !group->meth->field_mul(group, t1, s->Z, t1, ctx) - || !group->meth->field_mul(group, t0, p->X, r->Z, ctx) - || !BN_mod_add_quick(t6, r->X, t0, group->field) - || !group->meth->field_mul(group, t6, t6, t1, ctx) - || !BN_mod_add_quick(t6, t6, t2, group->field) - || !BN_mod_sub_quick(t0, t0, r->X, group->field) - || !group->meth->field_sqr(group, t0, t0, ctx) - || !group->meth->field_mul(group, t0, t0, s->X, ctx) - || !BN_mod_sub_quick(t0, t6, t0, group->field) - || !group->meth->field_mul(group, t1, s->Z, t4, ctx) - || !group->meth->field_mul(group, t1, t3, t1, ctx) - || (group->meth->field_decode != NULL - && !group->meth->field_decode(group, t1, t1, ctx)) - || !group->meth->field_inv(group, t1, t1, ctx) - || (group->meth->field_encode != NULL - && !group->meth->field_encode(group, t1, t1, ctx)) - || !group->meth->field_mul(group, r->X, t5, t1, ctx) - || !group->meth->field_mul(group, r->Y, t0, t1, ctx)) + || !group->meth->field_mul(group, t2, t3, t1, ctx) + || !group->meth->field_mul(group, t6, r->Z, group->a, ctx) + || !group->meth->field_mul(group, t1, p->X, r->X, ctx) + || !BN_mod_add_quick(t1, t1, t6, group->field) + || !group->meth->field_mul(group, t1, s->Z, t1, ctx) + || !group->meth->field_mul(group, t0, p->X, r->Z, ctx) + || !BN_mod_add_quick(t6, r->X, t0, group->field) + || !group->meth->field_mul(group, t6, t6, t1, ctx) + || !BN_mod_add_quick(t6, t6, t2, group->field) + || !BN_mod_sub_quick(t0, t0, r->X, group->field) + || !group->meth->field_sqr(group, t0, t0, ctx) + || !group->meth->field_mul(group, t0, t0, s->X, ctx) + || !BN_mod_sub_quick(t0, t6, t0, group->field) + || !group->meth->field_mul(group, t1, s->Z, t4, ctx) + || !group->meth->field_mul(group, t1, t3, t1, ctx) + || (group->meth->field_decode != NULL + && !group->meth->field_decode(group, t1, t1, ctx)) + || !group->meth->field_inv(group, t1, t1, ctx) + || (group->meth->field_encode != NULL + && !group->meth->field_encode(group, t1, t1, ctx)) + || !group->meth->field_mul(group, r->X, t5, t1, ctx) + || !group->meth->field_mul(group, r->Y, t0, t1, ctx)) goto err; - if (group->meth->field_set_to_one != NULL) { - if (!group->meth->field_set_to_one(group, r->Z, ctx)) - goto err; - } else { - if (!BN_one(r->Z)) - goto err; - } - - r->Z_is_one = 1; + if (group->meth->field_set_to_one != NULL) { + if (!group->meth->field_set_to_one(group, r->Z, ctx)) + goto err; + } else { + if (!BN_one(r->Z)) + goto err; + } + + r->Z_is_one = 1; ret = 1; err: diff --git a/contrib/libs/openssl/crypto/ec/ecx_meth.c b/contrib/libs/openssl/crypto/ec/ecx_meth.c index e554d68923..9dc5259e4a 100644 --- a/contrib/libs/openssl/crypto/ec/ecx_meth.c +++ b/contrib/libs/openssl/crypto/ec/ecx_meth.c @@ -12,10 +12,10 @@ #include <openssl/x509.h> #include <openssl/ec.h> #include <openssl/rand.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" -#include "ec_local.h" -#include "curve448/curve448_local.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" +#include "ec_local.h" +#include "curve448/curve448_local.h" #define X25519_BITS 253 #define X25519_SECURITY_BITS 128 @@ -191,7 +191,7 @@ static int ecx_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) } rv = ecx_key_op(pkey, pkey->ameth->pkey_id, palg, p, plen, KEY_OP_PRIVATE); - ASN1_STRING_clear_free(oct); + ASN1_STRING_clear_free(oct); return rv; } diff --git a/contrib/libs/openssl/crypto/engine/eng_all.c b/contrib/libs/openssl/crypto/engine/eng_all.c index c97e9c49aa..b675ed7892 100644 --- a/contrib/libs/openssl/crypto/engine/eng_all.c +++ b/contrib/libs/openssl/crypto/engine/eng_all.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "eng_local.h" +#include "eng_local.h" void ENGINE_load_builtin_engines(void) { diff --git a/contrib/libs/openssl/crypto/engine/eng_cnf.c b/contrib/libs/openssl/crypto/engine/eng_cnf.c index 8e6d575a59..df00df6acd 100644 --- a/contrib/libs/openssl/crypto/engine/eng_cnf.c +++ b/contrib/libs/openssl/crypto/engine/eng_cnf.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" #include <openssl/conf.h> /* #define ENGINE_CONF_DEBUG */ diff --git a/contrib/libs/openssl/crypto/engine/eng_ctrl.c b/contrib/libs/openssl/crypto/engine/eng_ctrl.c index 2f2ae0ee35..e65e78447b 100644 --- a/contrib/libs/openssl/crypto/engine/eng_ctrl.c +++ b/contrib/libs/openssl/crypto/engine/eng_ctrl.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" /* * When querying a ENGINE-specific control command's 'description', this diff --git a/contrib/libs/openssl/crypto/engine/eng_devcrypto.c b/contrib/libs/openssl/crypto/engine/eng_devcrypto.c index c7a81d6e76..84a3b7dbec 100644 --- a/contrib/libs/openssl/crypto/engine/eng_devcrypto.c +++ b/contrib/libs/openssl/crypto/engine/eng_devcrypto.c @@ -22,7 +22,7 @@ #include <openssl/objects.h> #include <crypto/cryptodev.h> -#include "crypto/engine.h" +#include "crypto/engine.h" /* #define ENGINE_DEVCRYPTO_DEBUG */ diff --git a/contrib/libs/openssl/crypto/engine/eng_dyn.c b/contrib/libs/openssl/crypto/engine/eng_dyn.c index 4a90fab9b2..06e677290a 100644 --- a/contrib/libs/openssl/crypto/engine/eng_dyn.c +++ b/contrib/libs/openssl/crypto/engine/eng_dyn.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" #include "internal/dso.h" #include <openssl/crypto.h> diff --git a/contrib/libs/openssl/crypto/engine/eng_fat.c b/contrib/libs/openssl/crypto/engine/eng_fat.c index c2bc5e24d7..fe231a65f6 100644 --- a/contrib/libs/openssl/crypto/engine/eng_fat.c +++ b/contrib/libs/openssl/crypto/engine/eng_fat.c @@ -8,7 +8,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" #include <openssl/conf.h> int ENGINE_set_default(ENGINE *e, unsigned int flags) diff --git a/contrib/libs/openssl/crypto/engine/eng_init.c b/contrib/libs/openssl/crypto/engine/eng_init.c index af403545f4..6c9063f8f6 100644 --- a/contrib/libs/openssl/crypto/engine/eng_init.c +++ b/contrib/libs/openssl/crypto/engine/eng_init.c @@ -8,7 +8,7 @@ */ #include "e_os.h" -#include "eng_local.h" +#include "eng_local.h" /* * Initialise a engine type for use (or up its functional reference count if diff --git a/contrib/libs/openssl/crypto/engine/eng_lib.c b/contrib/libs/openssl/crypto/engine/eng_lib.c index 18481005b1..5bd584c599 100644 --- a/contrib/libs/openssl/crypto/engine/eng_lib.c +++ b/contrib/libs/openssl/crypto/engine/eng_lib.c @@ -8,7 +8,7 @@ */ #include "e_os.h" -#include "eng_local.h" +#include "eng_local.h" #include <openssl/rand.h> #include "internal/refcount.h" diff --git a/contrib/libs/openssl/crypto/engine/eng_list.c b/contrib/libs/openssl/crypto/engine/eng_list.c index b10a4d85a1..1352fb7c96 100644 --- a/contrib/libs/openssl/crypto/engine/eng_list.c +++ b/contrib/libs/openssl/crypto/engine/eng_list.c @@ -8,7 +8,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" /* * The linked-list of pointers to engine types. engine_list_head incorporates diff --git a/contrib/libs/openssl/crypto/engine/eng_local.h b/contrib/libs/openssl/crypto/engine/eng_local.h index 2aaebcf131..8ef7172b9f 100644 --- a/contrib/libs/openssl/crypto/engine/eng_local.h +++ b/contrib/libs/openssl/crypto/engine/eng_local.h @@ -1,171 +1,171 @@ -/* - * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_ENGINE_ENG_LOCAL_H -# define OSSL_CRYPTO_ENGINE_ENG_LOCAL_H - -# include "internal/cryptlib.h" -# include "crypto/engine.h" -# include "internal/thread_once.h" -# include "internal/refcount.h" - -extern CRYPTO_RWLOCK *global_engine_lock; - -/* - * If we compile with this symbol defined, then both reference counts in the - * ENGINE structure will be monitored with a line of output on stderr for - * each change. This prints the engine's pointer address (truncated to - * unsigned int), "struct" or "funct" to indicate the reference type, the - * before and after reference count, and the file:line-number pair. The - * "engine_ref_debug" statements must come *after* the change. - */ -# ifdef ENGINE_REF_COUNT_DEBUG - -# define engine_ref_debug(e, isfunct, diff) \ - fprintf(stderr, "engine: %08x %s from %d to %d (%s:%d)\n", \ - (unsigned int)(e), (isfunct ? "funct" : "struct"), \ - ((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \ - ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \ - (OPENSSL_FILE), (OPENSSL_LINE)) - -# else - -# define engine_ref_debug(e, isfunct, diff) - -# endif - -/* - * Any code that will need cleanup operations should use these functions to - * register callbacks. engine_cleanup_int() will call all registered - * callbacks in order. NB: both the "add" functions assume the engine lock to - * already be held (in "write" mode). - */ -typedef void (ENGINE_CLEANUP_CB) (void); -typedef struct st_engine_cleanup_item { - ENGINE_CLEANUP_CB *cb; -} ENGINE_CLEANUP_ITEM; -DEFINE_STACK_OF(ENGINE_CLEANUP_ITEM) -void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb); -void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb); - -/* We need stacks of ENGINEs for use in eng_table.c */ -DEFINE_STACK_OF(ENGINE) - -/* - * If this symbol is defined then engine_table_select(), the function that is - * used by RSA, DSA (etc) code to select registered ENGINEs, cache defaults - * and functional references (etc), will display debugging summaries to - * stderr. - */ -/* #define ENGINE_TABLE_DEBUG */ - -/* - * This represents an implementation table. Dependent code should instantiate - * it as a (ENGINE_TABLE *) pointer value set initially to NULL. - */ -typedef struct st_engine_table ENGINE_TABLE; -int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, - ENGINE *e, const int *nids, int num_nids, - int setdefault); -void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e); -void engine_table_cleanup(ENGINE_TABLE **table); -# ifndef ENGINE_TABLE_DEBUG -ENGINE *engine_table_select(ENGINE_TABLE **table, int nid); -# else -ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, - int l); -# define engine_table_select(t,n) engine_table_select_tmp(t,n,OPENSSL_FILE,OPENSSL_LINE) -# endif -typedef void (engine_table_doall_cb) (int nid, STACK_OF(ENGINE) *sk, - ENGINE *def, void *arg); -void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, - void *arg); - -/* - * Internal versions of API functions that have control over locking. These - * are used between C files when functionality needs to be shared but the - * caller may already be controlling of the engine lock. - */ -int engine_unlocked_init(ENGINE *e); -int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers); -int engine_free_util(ENGINE *e, int not_locked); - -/* - * This function will reset all "set"able values in an ENGINE to NULL. This - * won't touch reference counts or ex_data, but is equivalent to calling all - * the ENGINE_set_***() functions with a NULL value. - */ -void engine_set_all_null(ENGINE *e); - -/* - * NB: Bitwise OR-able values for the "flags" variable in ENGINE are now - * exposed in engine.h. - */ - -/* Free up dynamically allocated public key methods associated with ENGINE */ - -void engine_pkey_meths_free(ENGINE *e); -void engine_pkey_asn1_meths_free(ENGINE *e); - -/* Once initialisation function */ -extern CRYPTO_ONCE engine_lock_init; -DECLARE_RUN_ONCE(do_engine_lock_init) - -/* - * This is a structure for storing implementations of various crypto - * algorithms and functions. - */ -struct engine_st { - const char *id; - const char *name; - const RSA_METHOD *rsa_meth; - const DSA_METHOD *dsa_meth; - const DH_METHOD *dh_meth; - const EC_KEY_METHOD *ec_meth; - const RAND_METHOD *rand_meth; - /* Cipher handling is via this callback */ - ENGINE_CIPHERS_PTR ciphers; - /* Digest handling is via this callback */ - ENGINE_DIGESTS_PTR digests; - /* Public key handling via this callback */ - ENGINE_PKEY_METHS_PTR pkey_meths; - /* ASN1 public key handling via this callback */ - ENGINE_PKEY_ASN1_METHS_PTR pkey_asn1_meths; - ENGINE_GEN_INT_FUNC_PTR destroy; - ENGINE_GEN_INT_FUNC_PTR init; - ENGINE_GEN_INT_FUNC_PTR finish; - ENGINE_CTRL_FUNC_PTR ctrl; - ENGINE_LOAD_KEY_PTR load_privkey; - ENGINE_LOAD_KEY_PTR load_pubkey; - ENGINE_SSL_CLIENT_CERT_PTR load_ssl_client_cert; - const ENGINE_CMD_DEFN *cmd_defns; - int flags; - /* reference count on the structure itself */ - CRYPTO_REF_COUNT struct_ref; - /* - * reference count on usability of the engine type. NB: This controls the - * loading and initialisation of any functionality required by this - * engine, whereas the previous count is simply to cope with - * (de)allocation of this structure. Hence, running_ref <= struct_ref at - * all times. - */ - int funct_ref; - /* A place to store per-ENGINE data */ - CRYPTO_EX_DATA ex_data; - /* Used to maintain the linked-list of engines. */ - struct engine_st *prev; - struct engine_st *next; -}; - -typedef struct st_engine_pile ENGINE_PILE; - -DEFINE_LHASH_OF(ENGINE_PILE); - -#endif /* OSSL_CRYPTO_ENGINE_ENG_LOCAL_H */ +/* + * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_ENGINE_ENG_LOCAL_H +# define OSSL_CRYPTO_ENGINE_ENG_LOCAL_H + +# include "internal/cryptlib.h" +# include "crypto/engine.h" +# include "internal/thread_once.h" +# include "internal/refcount.h" + +extern CRYPTO_RWLOCK *global_engine_lock; + +/* + * If we compile with this symbol defined, then both reference counts in the + * ENGINE structure will be monitored with a line of output on stderr for + * each change. This prints the engine's pointer address (truncated to + * unsigned int), "struct" or "funct" to indicate the reference type, the + * before and after reference count, and the file:line-number pair. The + * "engine_ref_debug" statements must come *after* the change. + */ +# ifdef ENGINE_REF_COUNT_DEBUG + +# define engine_ref_debug(e, isfunct, diff) \ + fprintf(stderr, "engine: %08x %s from %d to %d (%s:%d)\n", \ + (unsigned int)(e), (isfunct ? "funct" : "struct"), \ + ((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \ + ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \ + (OPENSSL_FILE), (OPENSSL_LINE)) + +# else + +# define engine_ref_debug(e, isfunct, diff) + +# endif + +/* + * Any code that will need cleanup operations should use these functions to + * register callbacks. engine_cleanup_int() will call all registered + * callbacks in order. NB: both the "add" functions assume the engine lock to + * already be held (in "write" mode). + */ +typedef void (ENGINE_CLEANUP_CB) (void); +typedef struct st_engine_cleanup_item { + ENGINE_CLEANUP_CB *cb; +} ENGINE_CLEANUP_ITEM; +DEFINE_STACK_OF(ENGINE_CLEANUP_ITEM) +void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb); +void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb); + +/* We need stacks of ENGINEs for use in eng_table.c */ +DEFINE_STACK_OF(ENGINE) + +/* + * If this symbol is defined then engine_table_select(), the function that is + * used by RSA, DSA (etc) code to select registered ENGINEs, cache defaults + * and functional references (etc), will display debugging summaries to + * stderr. + */ +/* #define ENGINE_TABLE_DEBUG */ + +/* + * This represents an implementation table. Dependent code should instantiate + * it as a (ENGINE_TABLE *) pointer value set initially to NULL. + */ +typedef struct st_engine_table ENGINE_TABLE; +int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, + ENGINE *e, const int *nids, int num_nids, + int setdefault); +void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e); +void engine_table_cleanup(ENGINE_TABLE **table); +# ifndef ENGINE_TABLE_DEBUG +ENGINE *engine_table_select(ENGINE_TABLE **table, int nid); +# else +ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, + int l); +# define engine_table_select(t,n) engine_table_select_tmp(t,n,OPENSSL_FILE,OPENSSL_LINE) +# endif +typedef void (engine_table_doall_cb) (int nid, STACK_OF(ENGINE) *sk, + ENGINE *def, void *arg); +void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, + void *arg); + +/* + * Internal versions of API functions that have control over locking. These + * are used between C files when functionality needs to be shared but the + * caller may already be controlling of the engine lock. + */ +int engine_unlocked_init(ENGINE *e); +int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers); +int engine_free_util(ENGINE *e, int not_locked); + +/* + * This function will reset all "set"able values in an ENGINE to NULL. This + * won't touch reference counts or ex_data, but is equivalent to calling all + * the ENGINE_set_***() functions with a NULL value. + */ +void engine_set_all_null(ENGINE *e); + +/* + * NB: Bitwise OR-able values for the "flags" variable in ENGINE are now + * exposed in engine.h. + */ + +/* Free up dynamically allocated public key methods associated with ENGINE */ + +void engine_pkey_meths_free(ENGINE *e); +void engine_pkey_asn1_meths_free(ENGINE *e); + +/* Once initialisation function */ +extern CRYPTO_ONCE engine_lock_init; +DECLARE_RUN_ONCE(do_engine_lock_init) + +/* + * This is a structure for storing implementations of various crypto + * algorithms and functions. + */ +struct engine_st { + const char *id; + const char *name; + const RSA_METHOD *rsa_meth; + const DSA_METHOD *dsa_meth; + const DH_METHOD *dh_meth; + const EC_KEY_METHOD *ec_meth; + const RAND_METHOD *rand_meth; + /* Cipher handling is via this callback */ + ENGINE_CIPHERS_PTR ciphers; + /* Digest handling is via this callback */ + ENGINE_DIGESTS_PTR digests; + /* Public key handling via this callback */ + ENGINE_PKEY_METHS_PTR pkey_meths; + /* ASN1 public key handling via this callback */ + ENGINE_PKEY_ASN1_METHS_PTR pkey_asn1_meths; + ENGINE_GEN_INT_FUNC_PTR destroy; + ENGINE_GEN_INT_FUNC_PTR init; + ENGINE_GEN_INT_FUNC_PTR finish; + ENGINE_CTRL_FUNC_PTR ctrl; + ENGINE_LOAD_KEY_PTR load_privkey; + ENGINE_LOAD_KEY_PTR load_pubkey; + ENGINE_SSL_CLIENT_CERT_PTR load_ssl_client_cert; + const ENGINE_CMD_DEFN *cmd_defns; + int flags; + /* reference count on the structure itself */ + CRYPTO_REF_COUNT struct_ref; + /* + * reference count on usability of the engine type. NB: This controls the + * loading and initialisation of any functionality required by this + * engine, whereas the previous count is simply to cope with + * (de)allocation of this structure. Hence, running_ref <= struct_ref at + * all times. + */ + int funct_ref; + /* A place to store per-ENGINE data */ + CRYPTO_EX_DATA ex_data; + /* Used to maintain the linked-list of engines. */ + struct engine_st *prev; + struct engine_st *next; +}; + +typedef struct st_engine_pile ENGINE_PILE; + +DEFINE_LHASH_OF(ENGINE_PILE); + +#endif /* OSSL_CRYPTO_ENGINE_ENG_LOCAL_H */ diff --git a/contrib/libs/openssl/crypto/engine/eng_openssl.c b/contrib/libs/openssl/crypto/engine/eng_openssl.c index a4e1432df9..25631fb879 100644 --- a/contrib/libs/openssl/crypto/engine/eng_openssl.c +++ b/contrib/libs/openssl/crypto/engine/eng_openssl.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -11,7 +11,7 @@ #include <stdio.h> #include <openssl/crypto.h> #include "internal/cryptlib.h" -#include "crypto/engine.h" +#include "crypto/engine.h" #include <openssl/pem.h> #include <openssl/evp.h> #include <openssl/rand.h> @@ -167,7 +167,7 @@ static int bind_fn(ENGINE *e, const char *id) } IMPLEMENT_DYNAMIC_CHECK_FN() -IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) +IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) #endif /* ENGINE_DYNAMIC_SUPPORT */ #ifdef TEST_ENG_OPENSSL_RC4 /*- diff --git a/contrib/libs/openssl/crypto/engine/eng_pkey.c b/contrib/libs/openssl/crypto/engine/eng_pkey.c index f19b9bb98c..e813bc6db0 100644 --- a/contrib/libs/openssl/crypto/engine/eng_pkey.c +++ b/contrib/libs/openssl/crypto/engine/eng_pkey.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" /* Basic get/set stuff */ diff --git a/contrib/libs/openssl/crypto/engine/eng_rdrand.c b/contrib/libs/openssl/crypto/engine/eng_rdrand.c index 97fe074b72..9dceb16710 100644 --- a/contrib/libs/openssl/crypto/engine/eng_rdrand.c +++ b/contrib/libs/openssl/crypto/engine/eng_rdrand.c @@ -11,7 +11,7 @@ #include <stdio.h> #include <string.h> -#include "crypto/engine.h" +#include "crypto/engine.h" #include <openssl/rand.h> #include <openssl/err.h> #include <openssl/crypto.h> diff --git a/contrib/libs/openssl/crypto/engine/eng_table.c b/contrib/libs/openssl/crypto/engine/eng_table.c index fe4266d707..72f393dbe1 100644 --- a/contrib/libs/openssl/crypto/engine/eng_table.c +++ b/contrib/libs/openssl/crypto/engine/eng_table.c @@ -10,7 +10,7 @@ #include "internal/cryptlib.h" #include <openssl/evp.h> #include <openssl/lhash.h> -#include "eng_local.h" +#include "eng_local.h" /* The type of the items in the table */ struct st_engine_pile { @@ -26,7 +26,7 @@ struct st_engine_pile { int uptodate; }; -/* The type exposed in eng_local.h */ +/* The type exposed in eng_local.h */ struct st_engine_table { LHASH_OF(ENGINE_PILE) piles; }; /* ENGINE_TABLE */ @@ -76,7 +76,7 @@ static int int_table_check(ENGINE_TABLE **t, int create) } /* - * Privately exposed (via eng_local.h) functions for adding and/or removing + * Privately exposed (via eng_local.h) functions for adding and/or removing * ENGINEs from the implementation table */ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, diff --git a/contrib/libs/openssl/crypto/engine/tb_asnmth.c b/contrib/libs/openssl/crypto/engine/tb_asnmth.c index 266f75ee5a..72850b9398 100644 --- a/contrib/libs/openssl/crypto/engine/tb_asnmth.c +++ b/contrib/libs/openssl/crypto/engine/tb_asnmth.c @@ -8,9 +8,9 @@ */ #include "e_os.h" -#include "eng_local.h" +#include "eng_local.h" #include <openssl/evp.h> -#include "crypto/asn1.h" +#include "crypto/asn1.h" /* * If this symbol is defined then ENGINE_get_pkey_asn1_meth_engine(), the @@ -147,8 +147,8 @@ const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, nidcount = e->pkey_asn1_meths(e, NULL, &nids, 0); for (i = 0; i < nidcount; i++) { e->pkey_asn1_meths(e, &ameth, NULL, nids[i]); - if (ameth != NULL - && ((int)strlen(ameth->pem_str) == len) + if (ameth != NULL + && ((int)strlen(ameth->pem_str) == len) && strncasecmp(ameth->pem_str, str, len) == 0) return ameth; } diff --git a/contrib/libs/openssl/crypto/engine/tb_cipher.c b/contrib/libs/openssl/crypto/engine/tb_cipher.c index c275295770..236da346cd 100644 --- a/contrib/libs/openssl/crypto/engine/tb_cipher.c +++ b/contrib/libs/openssl/crypto/engine/tb_cipher.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" static ENGINE_TABLE *cipher_table = NULL; diff --git a/contrib/libs/openssl/crypto/engine/tb_dh.c b/contrib/libs/openssl/crypto/engine/tb_dh.c index a7d1172353..a13a139500 100644 --- a/contrib/libs/openssl/crypto/engine/tb_dh.c +++ b/contrib/libs/openssl/crypto/engine/tb_dh.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" static ENGINE_TABLE *dh_table = NULL; static const int dummy_nid = 1; diff --git a/contrib/libs/openssl/crypto/engine/tb_digest.c b/contrib/libs/openssl/crypto/engine/tb_digest.c index dfc3e8f417..a6e6337a01 100644 --- a/contrib/libs/openssl/crypto/engine/tb_digest.c +++ b/contrib/libs/openssl/crypto/engine/tb_digest.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" static ENGINE_TABLE *digest_table = NULL; diff --git a/contrib/libs/openssl/crypto/engine/tb_dsa.c b/contrib/libs/openssl/crypto/engine/tb_dsa.c index 15fd9db026..2c77f0f3e1 100644 --- a/contrib/libs/openssl/crypto/engine/tb_dsa.c +++ b/contrib/libs/openssl/crypto/engine/tb_dsa.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" static ENGINE_TABLE *dsa_table = NULL; static const int dummy_nid = 1; diff --git a/contrib/libs/openssl/crypto/engine/tb_eckey.c b/contrib/libs/openssl/crypto/engine/tb_eckey.c index f7a136b56d..907d55ae8c 100644 --- a/contrib/libs/openssl/crypto/engine/tb_eckey.c +++ b/contrib/libs/openssl/crypto/engine/tb_eckey.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" static ENGINE_TABLE *dh_table = NULL; static const int dummy_nid = 1; diff --git a/contrib/libs/openssl/crypto/engine/tb_pkmeth.c b/contrib/libs/openssl/crypto/engine/tb_pkmeth.c index 9293d08d4f..c5c001c5cb 100644 --- a/contrib/libs/openssl/crypto/engine/tb_pkmeth.c +++ b/contrib/libs/openssl/crypto/engine/tb_pkmeth.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" #include <openssl/evp.h> static ENGINE_TABLE *pkey_meth_table = NULL; diff --git a/contrib/libs/openssl/crypto/engine/tb_rand.c b/contrib/libs/openssl/crypto/engine/tb_rand.c index 7e6cb44e10..92f61c5a88 100644 --- a/contrib/libs/openssl/crypto/engine/tb_rand.c +++ b/contrib/libs/openssl/crypto/engine/tb_rand.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" static ENGINE_TABLE *rand_table = NULL; static const int dummy_nid = 1; diff --git a/contrib/libs/openssl/crypto/engine/tb_rsa.c b/contrib/libs/openssl/crypto/engine/tb_rsa.c index 96d4e70599..43e865e6d6 100644 --- a/contrib/libs/openssl/crypto/engine/tb_rsa.c +++ b/contrib/libs/openssl/crypto/engine/tb_rsa.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "eng_local.h" +#include "eng_local.h" static ENGINE_TABLE *rsa_table = NULL; static const int dummy_nid = 1; diff --git a/contrib/libs/openssl/crypto/err/err.c b/contrib/libs/openssl/crypto/err/err.c index 8911f99e6c..1372d52f80 100644 --- a/contrib/libs/openssl/crypto/err/err.c +++ b/contrib/libs/openssl/crypto/err/err.c @@ -10,17 +10,17 @@ #include <stdio.h> #include <stdarg.h> #include <string.h> -#include "crypto/cryptlib.h" +#include "crypto/cryptlib.h" #include "internal/err.h" -#include "crypto/err.h" +#include "crypto/err.h" #include <openssl/err.h> #include <openssl/crypto.h> #include <openssl/buffer.h> #include <openssl/bio.h> #include <openssl/opensslconf.h> #include "internal/thread_once.h" -#include "crypto/ctype.h" -#include "internal/constant_time.h" +#include "crypto/ctype.h" +#include "internal/constant_time.h" #include "e_os.h" static int err_load_strings(const ERR_STRING_DATA *str); diff --git a/contrib/libs/openssl/crypto/err/err_all.c b/contrib/libs/openssl/crypto/err/err_all.c index 7780c52762..7c0a5f0b9c 100644 --- a/contrib/libs/openssl/crypto/err/err_all.c +++ b/contrib/libs/openssl/crypto/err/err_all.c @@ -8,7 +8,7 @@ */ #include <stdio.h> -#include "crypto/err.h" +#include "crypto/err.h" #include <openssl/asn1err.h> #include <openssl/bnerr.h> #include <openssl/ecerr.h> diff --git a/contrib/libs/openssl/crypto/evp/bio_md.c b/contrib/libs/openssl/crypto/evp/bio_md.c index 1919874bf8..fed4cf1eb1 100644 --- a/contrib/libs/openssl/crypto/evp/bio_md.c +++ b/contrib/libs/openssl/crypto/evp/bio_md.c @@ -12,8 +12,8 @@ #include "internal/cryptlib.h" #include <openssl/buffer.h> #include <openssl/evp.h> -#include "crypto/evp.h" -#include "evp_local.h" +#include "crypto/evp.h" +#include "evp_local.h" #include "internal/bio.h" /* diff --git a/contrib/libs/openssl/crypto/evp/bio_ok.c b/contrib/libs/openssl/crypto/evp/bio_ok.c index 722b2e2a15..9610f3c1ef 100644 --- a/contrib/libs/openssl/crypto/evp/bio_ok.c +++ b/contrib/libs/openssl/crypto/evp/bio_ok.c @@ -76,7 +76,7 @@ #include "internal/bio.h" #include <openssl/evp.h> #include <openssl/rand.h> -#include "crypto/evp.h" +#include "crypto/evp.h" static int ok_write(BIO *h, const char *buf, int num); static int ok_read(BIO *h, char *buf, int size); diff --git a/contrib/libs/openssl/crypto/evp/c_allc.c b/contrib/libs/openssl/crypto/evp/c_allc.c index dd6b36830f..22fdcc409c 100644 --- a/contrib/libs/openssl/crypto/evp/c_allc.c +++ b/contrib/libs/openssl/crypto/evp/c_allc.c @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/evp.h> -#include "crypto/evp.h" +#include "crypto/evp.h" #include <openssl/pkcs12.h> #include <openssl/objects.h> diff --git a/contrib/libs/openssl/crypto/evp/c_alld.c b/contrib/libs/openssl/crypto/evp/c_alld.c index b5e4765055..16ac1b67f4 100644 --- a/contrib/libs/openssl/crypto/evp/c_alld.c +++ b/contrib/libs/openssl/crypto/evp/c_alld.c @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/evp.h> -#include "crypto/evp.h" +#include "crypto/evp.h" #include <openssl/pkcs12.h> #include <openssl/objects.h> diff --git a/contrib/libs/openssl/crypto/evp/cmeth_lib.c b/contrib/libs/openssl/crypto/evp/cmeth_lib.c index b1f9551fed..272e48249e 100644 --- a/contrib/libs/openssl/crypto/evp/cmeth_lib.c +++ b/contrib/libs/openssl/crypto/evp/cmeth_lib.c @@ -10,8 +10,8 @@ #include <string.h> #include <openssl/evp.h> -#include "crypto/evp.h" -#include "evp_local.h" +#include "crypto/evp.h" +#include "evp_local.h" EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len) { diff --git a/contrib/libs/openssl/crypto/evp/digest.c b/contrib/libs/openssl/crypto/evp/digest.c index c9ba501780..d1bfa274ca 100644 --- a/contrib/libs/openssl/crypto/evp/digest.c +++ b/contrib/libs/openssl/crypto/evp/digest.c @@ -12,8 +12,8 @@ #include <openssl/objects.h> #include <openssl/evp.h> #include <openssl/engine.h> -#include "crypto/evp.h" -#include "evp_local.h" +#include "crypto/evp.h" +#include "evp_local.h" /* This call frees resources associated with the context */ int EVP_MD_CTX_reset(EVP_MD_CTX *ctx) diff --git a/contrib/libs/openssl/crypto/evp/e_aes.c b/contrib/libs/openssl/crypto/evp/e_aes.c index 021f82fa9f..2c2812fdf1 100644 --- a/contrib/libs/openssl/crypto/evp/e_aes.c +++ b/contrib/libs/openssl/crypto/evp/e_aes.c @@ -14,10 +14,10 @@ #include <string.h> #include <assert.h> #include <openssl/aes.h> -#include "crypto/evp.h" -#include "modes_local.h" +#include "crypto/evp.h" +#include "modes_local.h" #include <openssl/rand.h> -#include "evp_local.h" +#include "evp_local.h" #include "sanitizers.h" typedef struct { @@ -177,7 +177,7 @@ static void ctr64_inc(unsigned char *counter) # define HWAES_xts_decrypt aes_p8_xts_decrypt #endif -#if defined(OPENSSL_CPUID_OBJ) && ( \ +#if defined(OPENSSL_CPUID_OBJ) && ( \ ((defined(__i386) || defined(__i386__) || \ defined(_M_IX86)) && defined(OPENSSL_IA32_SSE2))|| \ defined(__x86_64) || defined(__x86_64__) || \ @@ -1130,7 +1130,7 @@ typedef struct { } icv; unsigned char k[32]; } kmac_param; - /* KMAC-AES parameter block - end */ + /* KMAC-AES parameter block - end */ union { unsigned long long g[2]; @@ -1433,7 +1433,7 @@ static int s390x_aes_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, (OPENSSL_s390xcap_P.kma[0] & \ S390X_CAPBIT(S390X_AES_256))) -/* iv + padding length for iv lengths != 12 */ +/* iv + padding length for iv lengths != 12 */ # define S390X_gcm_ivpadlen(i) ((((i) + 15) >> 4 << 4) + 16) /*- diff --git a/contrib/libs/openssl/crypto/evp/e_aes_cbc_hmac_sha1.c b/contrib/libs/openssl/crypto/evp/e_aes_cbc_hmac_sha1.c index cdaabbd1f5..27c36b46e7 100644 --- a/contrib/libs/openssl/crypto/evp/e_aes_cbc_hmac_sha1.c +++ b/contrib/libs/openssl/crypto/evp/e_aes_cbc_hmac_sha1.c @@ -17,9 +17,9 @@ #include <openssl/aes.h> #include <openssl/sha.h> #include <openssl/rand.h> -#include "modes_local.h" -#include "crypto/evp.h" -#include "internal/constant_time.h" +#include "modes_local.h" +#include "crypto/evp.h" +#include "internal/constant_time.h" typedef struct { AES_KEY ks; @@ -33,7 +33,7 @@ typedef struct { #define NO_PAYLOAD_LENGTH ((size_t)-1) -#if defined(AESNI_ASM) && ( \ +#if defined(AESNI_ASM) && ( \ defined(__x86_64) || defined(__x86_64__) || \ defined(_M_AMD64) || defined(_M_X64) ) diff --git a/contrib/libs/openssl/crypto/evp/e_aes_cbc_hmac_sha256.c b/contrib/libs/openssl/crypto/evp/e_aes_cbc_hmac_sha256.c index 3cfeacbc7e..cc622b6faa 100644 --- a/contrib/libs/openssl/crypto/evp/e_aes_cbc_hmac_sha256.c +++ b/contrib/libs/openssl/crypto/evp/e_aes_cbc_hmac_sha256.c @@ -18,9 +18,9 @@ #include <openssl/aes.h> #include <openssl/sha.h> #include <openssl/rand.h> -#include "modes_local.h" -#include "internal/constant_time.h" -#include "crypto/evp.h" +#include "modes_local.h" +#include "internal/constant_time.h" +#include "crypto/evp.h" typedef struct { AES_KEY ks; @@ -34,7 +34,7 @@ typedef struct { # define NO_PAYLOAD_LENGTH ((size_t)-1) -#if defined(AESNI_ASM) && ( \ +#if defined(AESNI_ASM) && ( \ defined(__x86_64) || defined(__x86_64__) || \ defined(_M_AMD64) || defined(_M_X64) ) @@ -947,4 +947,4 @@ const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void) { return NULL; } -#endif /* AESNI_ASM */ +#endif /* AESNI_ASM */ diff --git a/contrib/libs/openssl/crypto/evp/e_aria.c b/contrib/libs/openssl/crypto/evp/e_aria.c index 5193a6518f..1cc6dd91a9 100644 --- a/contrib/libs/openssl/crypto/evp/e_aria.c +++ b/contrib/libs/openssl/crypto/evp/e_aria.c @@ -14,10 +14,10 @@ # include <openssl/modes.h> # include <openssl/rand.h> # include <openssl/rand_drbg.h> -# include "crypto/aria.h" -# include "crypto/evp.h" -# include "modes_local.h" -# include "evp_local.h" +# include "crypto/aria.h" +# include "crypto/evp.h" +# include "modes_local.h" +# include "evp_local.h" /* ARIA subkey Structure */ typedef struct { @@ -709,11 +709,11 @@ static int aria_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, CRYPTO_ccm128_aad(ccm, in, len); return len; } - - /* The tag must be set before actually decrypting data */ - if (!EVP_CIPHER_CTX_encrypting(ctx) && !cctx->tag_set) - return -1; - + + /* The tag must be set before actually decrypting data */ + if (!EVP_CIPHER_CTX_encrypting(ctx) && !cctx->tag_set) + return -1; + /* If not set length yet do it */ if (!cctx->len_set) { if (CRYPTO_ccm128_setiv(ccm, EVP_CIPHER_CTX_iv_noconst(ctx), diff --git a/contrib/libs/openssl/crypto/evp/e_bf.c b/contrib/libs/openssl/crypto/evp/e_bf.c index e1717686bb..9a065582c6 100644 --- a/contrib/libs/openssl/crypto/evp/e_bf.c +++ b/contrib/libs/openssl/crypto/evp/e_bf.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #ifndef OPENSSL_NO_BF # include <openssl/evp.h> -# include "crypto/evp.h" +# include "crypto/evp.h" # include <openssl/objects.h> # include <openssl/blowfish.h> diff --git a/contrib/libs/openssl/crypto/evp/e_camellia.c b/contrib/libs/openssl/crypto/evp/e_camellia.c index eeba3a7b2a..f8c0198012 100644 --- a/contrib/libs/openssl/crypto/evp/e_camellia.c +++ b/contrib/libs/openssl/crypto/evp/e_camellia.c @@ -17,8 +17,8 @@ NON_EMPTY_TRANSLATION_UNIT # include <string.h> # include <assert.h> # include <openssl/camellia.h> -# include "crypto/evp.h" -# include "modes_local.h" +# include "crypto/evp.h" +# include "modes_local.h" static int camellia_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); diff --git a/contrib/libs/openssl/crypto/evp/e_cast.c b/contrib/libs/openssl/crypto/evp/e_cast.c index 3117a17bb7..df9f445bd0 100644 --- a/contrib/libs/openssl/crypto/evp/e_cast.c +++ b/contrib/libs/openssl/crypto/evp/e_cast.c @@ -13,7 +13,7 @@ #ifndef OPENSSL_NO_CAST # include <openssl/evp.h> # include <openssl/objects.h> -# include "crypto/evp.h" +# include "crypto/evp.h" # include <openssl/cast.h> static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, diff --git a/contrib/libs/openssl/crypto/evp/e_chacha20_poly1305.c b/contrib/libs/openssl/crypto/evp/e_chacha20_poly1305.c index 70009ef303..bdc406bb69 100644 --- a/contrib/libs/openssl/crypto/evp/e_chacha20_poly1305.c +++ b/contrib/libs/openssl/crypto/evp/e_chacha20_poly1305.c @@ -14,9 +14,9 @@ # include <openssl/evp.h> # include <openssl/objects.h> -# include "evp_local.h" -# include "crypto/evp.h" -# include "crypto/chacha.h" +# include "evp_local.h" +# include "crypto/evp.h" +# include "crypto/chacha.h" typedef struct { union { @@ -146,7 +146,7 @@ const EVP_CIPHER *EVP_chacha20(void) } # ifndef OPENSSL_NO_POLY1305 -# include "crypto/poly1305.h" +# include "crypto/poly1305.h" typedef struct { EVP_CHACHA_KEY key; diff --git a/contrib/libs/openssl/crypto/evp/e_des.c b/contrib/libs/openssl/crypto/evp/e_des.c index 848e6b6fd1..6d6e919af6 100644 --- a/contrib/libs/openssl/crypto/evp/e_des.c +++ b/contrib/libs/openssl/crypto/evp/e_des.c @@ -12,7 +12,7 @@ #ifndef OPENSSL_NO_DES # include <openssl/evp.h> # include <openssl/objects.h> -# include "crypto/evp.h" +# include "crypto/evp.h" # include <openssl/des.h> # include <openssl/rand.h> diff --git a/contrib/libs/openssl/crypto/evp/e_des3.c b/contrib/libs/openssl/crypto/evp/e_des3.c index 3b6e7ae301..2a5597fee5 100644 --- a/contrib/libs/openssl/crypto/evp/e_des3.c +++ b/contrib/libs/openssl/crypto/evp/e_des3.c @@ -12,10 +12,10 @@ #ifndef OPENSSL_NO_DES # include <openssl/evp.h> # include <openssl/objects.h> -# include "crypto/evp.h" +# include "crypto/evp.h" # include <openssl/des.h> # include <openssl/rand.h> -# include "evp_local.h" +# include "evp_local.h" typedef struct { union { diff --git a/contrib/libs/openssl/crypto/evp/e_idea.c b/contrib/libs/openssl/crypto/evp/e_idea.c index e32f02a0d8..1068378ddc 100644 --- a/contrib/libs/openssl/crypto/evp/e_idea.c +++ b/contrib/libs/openssl/crypto/evp/e_idea.c @@ -13,7 +13,7 @@ #ifndef OPENSSL_NO_IDEA # include <openssl/evp.h> # include <openssl/objects.h> -# include "crypto/evp.h" +# include "crypto/evp.h" # include <openssl/idea.h> /* Can't use IMPLEMENT_BLOCK_CIPHER because IDEA_ecb_encrypt is different */ diff --git a/contrib/libs/openssl/crypto/evp/e_null.c b/contrib/libs/openssl/crypto/evp/e_null.c index d8f822add1..0725454a3a 100644 --- a/contrib/libs/openssl/crypto/evp/e_null.c +++ b/contrib/libs/openssl/crypto/evp/e_null.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include <openssl/evp.h> #include <openssl/objects.h> -#include "crypto/evp.h" +#include "crypto/evp.h" static int null_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); diff --git a/contrib/libs/openssl/crypto/evp/e_rc2.c b/contrib/libs/openssl/crypto/evp/e_rc2.c index 473b336148..4d8a0ee4b0 100644 --- a/contrib/libs/openssl/crypto/evp/e_rc2.c +++ b/contrib/libs/openssl/crypto/evp/e_rc2.c @@ -14,7 +14,7 @@ # include <openssl/evp.h> # include <openssl/objects.h> -# include "crypto/evp.h" +# include "crypto/evp.h" # include <openssl/rc2.h> static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, diff --git a/contrib/libs/openssl/crypto/evp/e_rc4.c b/contrib/libs/openssl/crypto/evp/e_rc4.c index 8e288bbefd..c24bc8fe59 100644 --- a/contrib/libs/openssl/crypto/evp/e_rc4.c +++ b/contrib/libs/openssl/crypto/evp/e_rc4.c @@ -16,7 +16,7 @@ # include <openssl/objects.h> # include <openssl/rc4.h> -# include "crypto/evp.h" +# include "crypto/evp.h" typedef struct { RC4_KEY ks; /* working key */ diff --git a/contrib/libs/openssl/crypto/evp/e_rc4_hmac_md5.c b/contrib/libs/openssl/crypto/evp/e_rc4_hmac_md5.c index 73b66946aa..201ce44343 100644 --- a/contrib/libs/openssl/crypto/evp/e_rc4_hmac_md5.c +++ b/contrib/libs/openssl/crypto/evp/e_rc4_hmac_md5.c @@ -19,7 +19,7 @@ # include <openssl/objects.h> # include <openssl/rc4.h> # include <openssl/md5.h> -# include "crypto/evp.h" +# include "crypto/evp.h" typedef struct { RC4_KEY ks; diff --git a/contrib/libs/openssl/crypto/evp/e_rc5.c b/contrib/libs/openssl/crypto/evp/e_rc5.c index ed7fa28b4e..c86e87b65a 100644 --- a/contrib/libs/openssl/crypto/evp/e_rc5.c +++ b/contrib/libs/openssl/crypto/evp/e_rc5.c @@ -13,9 +13,9 @@ #ifndef OPENSSL_NO_RC5 # include <openssl/evp.h> -# include "crypto/evp.h" +# include "crypto/evp.h" # include <openssl/objects.h> -# include "evp_local.h" +# include "evp_local.h" # include <openssl/rc5.h> static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, diff --git a/contrib/libs/openssl/crypto/evp/e_seed.c b/contrib/libs/openssl/crypto/evp/e_seed.c index 9acb9cb787..aeb2363bea 100644 --- a/contrib/libs/openssl/crypto/evp/e_seed.c +++ b/contrib/libs/openssl/crypto/evp/e_seed.c @@ -16,7 +16,7 @@ NON_EMPTY_TRANSLATION_UNIT # include <string.h> # include <assert.h> # include <openssl/seed.h> -# include "crypto/evp.h" +# include "crypto/evp.h" static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc); diff --git a/contrib/libs/openssl/crypto/evp/e_sm4.c b/contrib/libs/openssl/crypto/evp/e_sm4.c index 77d86efe39..fce32794fc 100644 --- a/contrib/libs/openssl/crypto/evp/e_sm4.c +++ b/contrib/libs/openssl/crypto/evp/e_sm4.c @@ -13,8 +13,8 @@ #ifndef OPENSSL_NO_SM4 # include <openssl/evp.h> # include <openssl/modes.h> -# include "crypto/sm4.h" -# include "crypto/evp.h" +# include "crypto/sm4.h" +# include "crypto/evp.h" typedef struct { SM4_KEY ks; diff --git a/contrib/libs/openssl/crypto/evp/e_xcbc_d.c b/contrib/libs/openssl/crypto/evp/e_xcbc_d.c index 111dee932b..b730775422 100644 --- a/contrib/libs/openssl/crypto/evp/e_xcbc_d.c +++ b/contrib/libs/openssl/crypto/evp/e_xcbc_d.c @@ -14,7 +14,7 @@ # include <openssl/evp.h> # include <openssl/objects.h> -# include "crypto/evp.h" +# include "crypto/evp.h" # include <openssl/des.h> static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, diff --git a/contrib/libs/openssl/crypto/evp/encode.c b/contrib/libs/openssl/crypto/evp/encode.c index 4096ffac8d..85926434c3 100644 --- a/contrib/libs/openssl/crypto/evp/encode.c +++ b/contrib/libs/openssl/crypto/evp/encode.c @@ -11,8 +11,8 @@ #include <limits.h> #include "internal/cryptlib.h" #include <openssl/evp.h> -#include "evp_local.h" -#include "crypto/evp.h" +#include "evp_local.h" +#include "crypto/evp.h" static unsigned char conv_ascii2bin(unsigned char a, const unsigned char *table); diff --git a/contrib/libs/openssl/crypto/evp/evp_enc.c b/contrib/libs/openssl/crypto/evp/evp_enc.c index 720b532df2..e3c165d48e 100644 --- a/contrib/libs/openssl/crypto/evp/evp_enc.c +++ b/contrib/libs/openssl/crypto/evp/evp_enc.c @@ -16,8 +16,8 @@ #include <openssl/rand.h> #include <openssl/rand_drbg.h> #include <openssl/engine.h> -#include "crypto/evp.h" -#include "evp_local.h" +#include "crypto/evp.h" +#include "evp_local.h" int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c) { @@ -306,17 +306,17 @@ static int evp_EncryptDecryptUpdate(EVP_CIPHER_CTX *ctx, bl = ctx->cipher->block_size; - /* - * CCM mode needs to know about the case where inl == 0 && in == NULL - it - * means the plaintext/ciphertext length is 0 - */ - if (inl < 0 - || (inl == 0 - && EVP_CIPHER_mode(ctx->cipher) != EVP_CIPH_CCM_MODE)) { - *outl = 0; - return inl == 0; - } - + /* + * CCM mode needs to know about the case where inl == 0 && in == NULL - it + * means the plaintext/ciphertext length is 0 + */ + if (inl < 0 + || (inl == 0 + && EVP_CIPHER_mode(ctx->cipher) != EVP_CIPH_CCM_MODE)) { + *outl = 0; + return inl == 0; + } + if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { /* If block size > 1 then the cipher will have to do this check */ if (bl == 1 && is_partially_overlapping(out, in, cmpl)) { @@ -478,17 +478,17 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, if (EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS)) cmpl = (cmpl + 7) / 8; - /* - * CCM mode needs to know about the case where inl == 0 - it means the - * plaintext/ciphertext length is 0 - */ - if (inl < 0 - || (inl == 0 - && EVP_CIPHER_mode(ctx->cipher) != EVP_CIPH_CCM_MODE)) { - *outl = 0; - return inl == 0; - } - + /* + * CCM mode needs to know about the case where inl == 0 - it means the + * plaintext/ciphertext length is 0 + */ + if (inl < 0 + || (inl == 0 + && EVP_CIPHER_mode(ctx->cipher) != EVP_CIPH_CCM_MODE)) { + *outl = 0; + return inl == 0; + } + if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { if (b == 1 && is_partially_overlapping(out, in, cmpl)) { EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING); diff --git a/contrib/libs/openssl/crypto/evp/evp_err.c b/contrib/libs/openssl/crypto/evp/evp_err.c index bf229f7de6..32ac0125de 100644 --- a/contrib/libs/openssl/crypto/evp/evp_err.c +++ b/contrib/libs/openssl/crypto/evp/evp_err.c @@ -213,7 +213,7 @@ static const ERR_STRING_DATA EVP_str_reasons[] = { "input not initialized"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_INVALID_DIGEST), "invalid digest"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_INVALID_FIPS_MODE), "invalid fips mode"}, - {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_INVALID_IV_LENGTH), "invalid iv length"}, + {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_INVALID_IV_LENGTH), "invalid iv length"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_INVALID_KEY), "invalid key"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_INVALID_KEY_LENGTH), "invalid key length"}, {ERR_PACK(ERR_LIB_EVP, 0, EVP_R_INVALID_OPERATION), "invalid operation"}, diff --git a/contrib/libs/openssl/crypto/evp/evp_lib.c b/contrib/libs/openssl/crypto/evp/evp_lib.c index b5526a7f26..45cde0da8b 100644 --- a/contrib/libs/openssl/crypto/evp/evp_lib.c +++ b/contrib/libs/openssl/crypto/evp/evp_lib.c @@ -11,8 +11,8 @@ #include "internal/cryptlib.h" #include <openssl/evp.h> #include <openssl/objects.h> -#include "crypto/evp.h" -#include "evp_local.h" +#include "crypto/evp.h" +#include "evp_local.h" int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) { diff --git a/contrib/libs/openssl/crypto/evp/evp_local.h b/contrib/libs/openssl/crypto/evp/evp_local.h index 020a6f4c00..f1589d6828 100644 --- a/contrib/libs/openssl/crypto/evp/evp_local.h +++ b/contrib/libs/openssl/crypto/evp/evp_local.h @@ -1,68 +1,68 @@ -/* - * Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* EVP_MD_CTX related stuff */ - -struct evp_md_ctx_st { - const EVP_MD *digest; - ENGINE *engine; /* functional reference if 'digest' is - * ENGINE-provided */ - unsigned long flags; - void *md_data; - /* Public key context for sign/verify */ - EVP_PKEY_CTX *pctx; - /* Update function: usually copied from EVP_MD */ - int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count); -} /* EVP_MD_CTX */ ; - -struct evp_cipher_ctx_st { - const EVP_CIPHER *cipher; - ENGINE *engine; /* functional reference if 'cipher' is - * ENGINE-provided */ - int encrypt; /* encrypt or decrypt */ - int buf_len; /* number we have left */ - unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ - unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ - unsigned char buf[EVP_MAX_BLOCK_LENGTH]; /* saved partial block */ - int num; /* used by cfb/ofb/ctr mode */ - /* FIXME: Should this even exist? It appears unused */ - void *app_data; /* application stuff */ - int key_len; /* May change for variable length cipher */ - unsigned long flags; /* Various flags */ - void *cipher_data; /* per EVP data */ - int final_used; - int block_mask; - unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */ -} /* EVP_CIPHER_CTX */ ; - -int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, - int passlen, ASN1_TYPE *param, - const EVP_CIPHER *c, const EVP_MD *md, - int en_de); - -struct evp_Encode_Ctx_st { - /* number saved in a partial encode/decode */ - int num; - /* - * The length is either the output line length (in input bytes) or the - * shortest input line length that is ok. Once decoding begins, the - * length is adjusted up each time a longer line is decoded - */ - int length; - /* data to encode */ - unsigned char enc_data[80]; - /* number read on current line */ - int line_num; - unsigned int flags; -}; - -typedef struct evp_pbe_st EVP_PBE_CTL; -DEFINE_STACK_OF(EVP_PBE_CTL) - -int is_partially_overlapping(const void *ptr1, const void *ptr2, int len); +/* + * Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* EVP_MD_CTX related stuff */ + +struct evp_md_ctx_st { + const EVP_MD *digest; + ENGINE *engine; /* functional reference if 'digest' is + * ENGINE-provided */ + unsigned long flags; + void *md_data; + /* Public key context for sign/verify */ + EVP_PKEY_CTX *pctx; + /* Update function: usually copied from EVP_MD */ + int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count); +} /* EVP_MD_CTX */ ; + +struct evp_cipher_ctx_st { + const EVP_CIPHER *cipher; + ENGINE *engine; /* functional reference if 'cipher' is + * ENGINE-provided */ + int encrypt; /* encrypt or decrypt */ + int buf_len; /* number we have left */ + unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ + unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ + unsigned char buf[EVP_MAX_BLOCK_LENGTH]; /* saved partial block */ + int num; /* used by cfb/ofb/ctr mode */ + /* FIXME: Should this even exist? It appears unused */ + void *app_data; /* application stuff */ + int key_len; /* May change for variable length cipher */ + unsigned long flags; /* Various flags */ + void *cipher_data; /* per EVP data */ + int final_used; + int block_mask; + unsigned char final[EVP_MAX_BLOCK_LENGTH]; /* possible final block */ +} /* EVP_CIPHER_CTX */ ; + +int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, + int passlen, ASN1_TYPE *param, + const EVP_CIPHER *c, const EVP_MD *md, + int en_de); + +struct evp_Encode_Ctx_st { + /* number saved in a partial encode/decode */ + int num; + /* + * The length is either the output line length (in input bytes) or the + * shortest input line length that is ok. Once decoding begins, the + * length is adjusted up each time a longer line is decoded + */ + int length; + /* data to encode */ + unsigned char enc_data[80]; + /* number read on current line */ + int line_num; + unsigned int flags; +}; + +typedef struct evp_pbe_st EVP_PBE_CTL; +DEFINE_STACK_OF(EVP_PBE_CTL) + +int is_partially_overlapping(const void *ptr1, const void *ptr2, int len); diff --git a/contrib/libs/openssl/crypto/evp/evp_pbe.c b/contrib/libs/openssl/crypto/evp/evp_pbe.c index 62f8396f6d..967203f373 100644 --- a/contrib/libs/openssl/crypto/evp/evp_pbe.c +++ b/contrib/libs/openssl/crypto/evp/evp_pbe.c @@ -12,7 +12,7 @@ #include <openssl/evp.h> #include <openssl/pkcs12.h> #include <openssl/x509.h> -#include "evp_local.h" +#include "evp_local.h" /* Password based encryption (PBE) functions */ diff --git a/contrib/libs/openssl/crypto/evp/evp_pkey.c b/contrib/libs/openssl/crypto/evp/evp_pkey.c index 68cc2018a0..586b74605c 100644 --- a/contrib/libs/openssl/crypto/evp/evp_pkey.c +++ b/contrib/libs/openssl/crypto/evp/evp_pkey.c @@ -12,9 +12,9 @@ #include "internal/cryptlib.h" #include <openssl/x509.h> #include <openssl/rand.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" -#include "crypto/x509.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" +#include "crypto/x509.h" /* Extract a private key from a PKCS8 structure */ diff --git a/contrib/libs/openssl/crypto/evp/m_md2.c b/contrib/libs/openssl/crypto/evp/m_md2.c index a790b3ef68..1aec518523 100644 --- a/contrib/libs/openssl/crypto/evp/m_md2.c +++ b/contrib/libs/openssl/crypto/evp/m_md2.c @@ -18,7 +18,7 @@ # include <openssl/md2.h> # include <openssl/rsa.h> -#include "crypto/evp.h" +#include "crypto/evp.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/evp/m_md4.c b/contrib/libs/openssl/crypto/evp/m_md4.c index 8cd2c7e697..45d2cafee1 100644 --- a/contrib/libs/openssl/crypto/evp/m_md4.c +++ b/contrib/libs/openssl/crypto/evp/m_md4.c @@ -17,7 +17,7 @@ # include <openssl/x509.h> # include <openssl/md4.h> # include <openssl/rsa.h> -# include "crypto/evp.h" +# include "crypto/evp.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/evp/m_md5.c b/contrib/libs/openssl/crypto/evp/m_md5.c index 463b8423f1..d26b5a4d31 100644 --- a/contrib/libs/openssl/crypto/evp/m_md5.c +++ b/contrib/libs/openssl/crypto/evp/m_md5.c @@ -17,7 +17,7 @@ # include <openssl/x509.h> # include <openssl/md5.h> # include <openssl/rsa.h> -# include "crypto/evp.h" +# include "crypto/evp.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/evp/m_md5_sha1.c b/contrib/libs/openssl/crypto/evp/m_md5_sha1.c index e2d042d218..eeec2b13e9 100644 --- a/contrib/libs/openssl/crypto/evp/m_md5_sha1.c +++ b/contrib/libs/openssl/crypto/evp/m_md5_sha1.c @@ -15,7 +15,7 @@ # include <openssl/md5.h> # include <openssl/sha.h> # include "internal/cryptlib.h" -# include "crypto/evp.h" +# include "crypto/evp.h" # include <openssl/rsa.h> struct md5_sha1_ctx { diff --git a/contrib/libs/openssl/crypto/evp/m_mdc2.c b/contrib/libs/openssl/crypto/evp/m_mdc2.c index 47f9b7cbb9..fffa751efd 100644 --- a/contrib/libs/openssl/crypto/evp/m_mdc2.c +++ b/contrib/libs/openssl/crypto/evp/m_mdc2.c @@ -17,7 +17,7 @@ # include <openssl/x509.h> # include <openssl/mdc2.h> # include <openssl/rsa.h> -# include "crypto/evp.h" +# include "crypto/evp.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/evp/m_null.c b/contrib/libs/openssl/crypto/evp/m_null.c index d11ee79ef7..0847139df1 100644 --- a/contrib/libs/openssl/crypto/evp/m_null.c +++ b/contrib/libs/openssl/crypto/evp/m_null.c @@ -12,7 +12,7 @@ #include <openssl/evp.h> #include <openssl/objects.h> #include <openssl/x509.h> -#include "crypto/evp.h" +#include "crypto/evp.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/evp/m_ripemd.c b/contrib/libs/openssl/crypto/evp/m_ripemd.c index 00babc7d50..d93ad24fe5 100644 --- a/contrib/libs/openssl/crypto/evp/m_ripemd.c +++ b/contrib/libs/openssl/crypto/evp/m_ripemd.c @@ -17,7 +17,7 @@ # include <openssl/objects.h> # include <openssl/x509.h> # include <openssl/rsa.h> -# include "crypto/evp.h" +# include "crypto/evp.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/evp/m_sha1.c b/contrib/libs/openssl/crypto/evp/m_sha1.c index 4e719ecd65..22b9bbc7d8 100644 --- a/contrib/libs/openssl/crypto/evp/m_sha1.c +++ b/contrib/libs/openssl/crypto/evp/m_sha1.c @@ -14,8 +14,8 @@ #include <openssl/objects.h> #include <openssl/sha.h> #include <openssl/rsa.h> -#include "crypto/evp.h" -#include "crypto/sha.h" +#include "crypto/evp.h" +#include "crypto/sha.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/evp/m_sha3.c b/contrib/libs/openssl/crypto/evp/m_sha3.c index 010f2c8350..54c592a3cc 100644 --- a/contrib/libs/openssl/crypto/evp/m_sha3.c +++ b/contrib/libs/openssl/crypto/evp/m_sha3.c @@ -12,8 +12,8 @@ #include <openssl/evp.h> #include <openssl/objects.h> -#include "crypto/evp.h" -#include "evp_local.h" +#include "crypto/evp.h" +#include "evp_local.h" size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len, size_t r); diff --git a/contrib/libs/openssl/crypto/evp/m_sigver.c b/contrib/libs/openssl/crypto/evp/m_sigver.c index 8e8365451b..04643acc88 100644 --- a/contrib/libs/openssl/crypto/evp/m_sigver.c +++ b/contrib/libs/openssl/crypto/evp/m_sigver.c @@ -12,8 +12,8 @@ #include <openssl/evp.h> #include <openssl/objects.h> #include <openssl/x509.h> -#include "crypto/evp.h" -#include "evp_local.h" +#include "crypto/evp.h" +#include "evp_local.h" static int update(EVP_MD_CTX *ctx, const void *data, size_t datalen) { diff --git a/contrib/libs/openssl/crypto/evp/m_wp.c b/contrib/libs/openssl/crypto/evp/m_wp.c index e12661c1e5..5ce15d2d5e 100644 --- a/contrib/libs/openssl/crypto/evp/m_wp.c +++ b/contrib/libs/openssl/crypto/evp/m_wp.c @@ -16,7 +16,7 @@ # include <openssl/objects.h> # include <openssl/x509.h> # include <openssl/whrlpool.h> -# include "crypto/evp.h" +# include "crypto/evp.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/evp/names.c b/contrib/libs/openssl/crypto/evp/names.c index fc7eaae1c5..90c7b73b7a 100644 --- a/contrib/libs/openssl/crypto/evp/names.c +++ b/contrib/libs/openssl/crypto/evp/names.c @@ -10,9 +10,9 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/evp.h> -#include "crypto/objects.h" +#include "crypto/objects.h" #include <openssl/x509.h> -#include "crypto/evp.h" +#include "crypto/evp.h" int EVP_add_cipher(const EVP_CIPHER *c) { diff --git a/contrib/libs/openssl/crypto/evp/p5_crpt.c b/contrib/libs/openssl/crypto/evp/p5_crpt.c index d54de47ded..6c5f45f733 100644 --- a/contrib/libs/openssl/crypto/evp/p5_crpt.c +++ b/contrib/libs/openssl/crypto/evp/p5_crpt.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -28,7 +28,7 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, EVP_MD_CTX *ctx; unsigned char md_tmp[EVP_MAX_MD_SIZE]; unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; - int i, ivl, kl; + int i, ivl, kl; PBEPARAM *pbe; int saltlen, iter; unsigned char *salt; @@ -48,19 +48,19 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, return 0; } - ivl = EVP_CIPHER_iv_length(cipher); - if (ivl < 0 || ivl > 16) { - EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, EVP_R_INVALID_IV_LENGTH); - PBEPARAM_free(pbe); - return 0; - } - kl = EVP_CIPHER_key_length(cipher); - if (kl < 0 || kl > (int)sizeof(md_tmp)) { - EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, EVP_R_INVALID_KEY_LENGTH); - PBEPARAM_free(pbe); - return 0; - } - + ivl = EVP_CIPHER_iv_length(cipher); + if (ivl < 0 || ivl > 16) { + EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, EVP_R_INVALID_IV_LENGTH); + PBEPARAM_free(pbe); + return 0; + } + kl = EVP_CIPHER_key_length(cipher); + if (kl < 0 || kl > (int)sizeof(md_tmp)) { + EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, EVP_R_INVALID_KEY_LENGTH); + PBEPARAM_free(pbe); + return 0; + } + if (!pbe->iter) iter = 1; else @@ -86,7 +86,7 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, if (!EVP_DigestUpdate(ctx, salt, saltlen)) goto err; PBEPARAM_free(pbe); - pbe = NULL; + pbe = NULL; if (!EVP_DigestFinal_ex(ctx, md_tmp, NULL)) goto err; mdsize = EVP_MD_size(md); @@ -100,8 +100,8 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, if (!EVP_DigestFinal_ex(ctx, md_tmp, NULL)) goto err; } - memcpy(key, md_tmp, kl); - memcpy(iv, md_tmp + (16 - ivl), ivl); + memcpy(key, md_tmp, kl); + memcpy(iv, md_tmp + (16 - ivl), ivl); if (!EVP_CipherInit_ex(cctx, cipher, NULL, key, iv, en_de)) goto err; OPENSSL_cleanse(md_tmp, EVP_MAX_MD_SIZE); @@ -109,7 +109,7 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH); rv = 1; err: - PBEPARAM_free(pbe); + PBEPARAM_free(pbe); EVP_MD_CTX_free(ctx); return rv; } diff --git a/contrib/libs/openssl/crypto/evp/p5_crpt2.c b/contrib/libs/openssl/crypto/evp/p5_crpt2.c index 6bae87c8a9..7f625b3d57 100644 --- a/contrib/libs/openssl/crypto/evp/p5_crpt2.c +++ b/contrib/libs/openssl/crypto/evp/p5_crpt2.c @@ -13,7 +13,7 @@ # include <openssl/x509.h> # include <openssl/evp.h> # include <openssl/hmac.h> -# include "evp_local.h" +# include "evp_local.h" /* set this to print out info about the keygen algorithm */ /* #define OPENSSL_DEBUG_PKCS5V2 */ diff --git a/contrib/libs/openssl/crypto/evp/p_lib.c b/contrib/libs/openssl/crypto/evp/p_lib.c index a25e2dd7f7..9f1a485a5b 100644 --- a/contrib/libs/openssl/crypto/evp/p_lib.c +++ b/contrib/libs/openssl/crypto/evp/p_lib.c @@ -21,8 +21,8 @@ #include <openssl/cmac.h> #include <openssl/engine.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" static void EVP_PKEY_free_it(EVP_PKEY *x); @@ -102,7 +102,7 @@ int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey) { - if (pkey != NULL && pkey->ameth && pkey->ameth->param_missing) + if (pkey != NULL && pkey->ameth && pkey->ameth->param_missing) return pkey->ameth->param_missing(pkey); return 0; } @@ -465,7 +465,7 @@ int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key) RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey) { - if (pkey->type != EVP_PKEY_RSA && pkey->type != EVP_PKEY_RSA_PSS) { + if (pkey->type != EVP_PKEY_RSA && pkey->type != EVP_PKEY_RSA_PSS) { EVPerr(EVP_F_EVP_PKEY_GET0_RSA, EVP_R_EXPECTING_AN_RSA_KEY); return NULL; } @@ -540,9 +540,9 @@ EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey) int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key) { - int type = DH_get0_q(key) == NULL ? EVP_PKEY_DH : EVP_PKEY_DHX; - int ret = EVP_PKEY_assign(pkey, type, key); - + int type = DH_get0_q(key) == NULL ? EVP_PKEY_DH : EVP_PKEY_DHX; + int ret = EVP_PKEY_assign(pkey, type, key); + if (ret) DH_up_ref(key); return ret; diff --git a/contrib/libs/openssl/crypto/evp/p_sign.c b/contrib/libs/openssl/crypto/evp/p_sign.c index 1ecbd5422d..0383294a87 100644 --- a/contrib/libs/openssl/crypto/evp/p_sign.c +++ b/contrib/libs/openssl/crypto/evp/p_sign.c @@ -12,7 +12,7 @@ #include <openssl/evp.h> #include <openssl/objects.h> #include <openssl/x509.h> -#include "crypto/evp.h" +#include "crypto/evp.h" int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, EVP_PKEY *pkey) diff --git a/contrib/libs/openssl/crypto/evp/p_verify.c b/contrib/libs/openssl/crypto/evp/p_verify.c index 4c239a84cf..e27196f7c2 100644 --- a/contrib/libs/openssl/crypto/evp/p_verify.c +++ b/contrib/libs/openssl/crypto/evp/p_verify.c @@ -12,7 +12,7 @@ #include <openssl/evp.h> #include <openssl/objects.h> #include <openssl/x509.h> -#include "crypto/evp.h" +#include "crypto/evp.h" int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, unsigned int siglen, EVP_PKEY *pkey) diff --git a/contrib/libs/openssl/crypto/evp/pmeth_fn.c b/contrib/libs/openssl/crypto/evp/pmeth_fn.c index e3f22e2f36..02f4093461 100644 --- a/contrib/libs/openssl/crypto/evp/pmeth_fn.c +++ b/contrib/libs/openssl/crypto/evp/pmeth_fn.c @@ -12,7 +12,7 @@ #include "internal/cryptlib.h" #include <openssl/objects.h> #include <openssl/evp.h> -#include "crypto/evp.h" +#include "crypto/evp.h" #define M_check_autoarg(ctx, arg, arglen, err) \ if (ctx->pmeth->flags & EVP_PKEY_FLAG_AUTOARGLEN) { \ diff --git a/contrib/libs/openssl/crypto/evp/pmeth_gn.c b/contrib/libs/openssl/crypto/evp/pmeth_gn.c index 76930a6b44..3ad6d5c7c7 100644 --- a/contrib/libs/openssl/crypto/evp/pmeth_gn.c +++ b/contrib/libs/openssl/crypto/evp/pmeth_gn.c @@ -12,9 +12,9 @@ #include "internal/cryptlib.h" #include <openssl/objects.h> #include <openssl/evp.h> -#include "crypto/bn.h" -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/bn.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/evp/pmeth_lib.c b/contrib/libs/openssl/crypto/evp/pmeth_lib.c index 0010c95b53..603ccd8352 100644 --- a/contrib/libs/openssl/crypto/evp/pmeth_lib.c +++ b/contrib/libs/openssl/crypto/evp/pmeth_lib.c @@ -13,8 +13,8 @@ #include <openssl/engine.h> #include <openssl/evp.h> #include <openssl/x509v3.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" #include "internal/numbers.h" typedef int sk_cmp_fn_type(const char *const *a, const char *const *b); @@ -642,21 +642,21 @@ void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, pmeth->ctrl_str = ctrl_str; } -void EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth, - int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, - const unsigned char *tbs, size_t tbslen)) -{ - pmeth->digestsign = digestsign; -} - -void EVP_PKEY_meth_set_digestverify(EVP_PKEY_METHOD *pmeth, - int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig, - size_t siglen, const unsigned char *tbs, - size_t tbslen)) -{ - pmeth->digestverify = digestverify; -} - +void EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth, + int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen)) +{ + pmeth->digestsign = digestsign; +} + +void EVP_PKEY_meth_set_digestverify(EVP_PKEY_METHOD *pmeth, + int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen, const unsigned char *tbs, + size_t tbslen)) +{ + pmeth->digestverify = digestverify; +} + void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth, int (*check) (EVP_PKEY *pkey)) { @@ -849,23 +849,23 @@ void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth, *pctrl_str = pmeth->ctrl_str; } -void EVP_PKEY_meth_get_digestsign(EVP_PKEY_METHOD *pmeth, - int (**digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, - const unsigned char *tbs, size_t tbslen)) -{ - if (digestsign) - *digestsign = pmeth->digestsign; -} - -void EVP_PKEY_meth_get_digestverify(EVP_PKEY_METHOD *pmeth, - int (**digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig, - size_t siglen, const unsigned char *tbs, - size_t tbslen)) -{ - if (digestverify) - *digestverify = pmeth->digestverify; -} - +void EVP_PKEY_meth_get_digestsign(EVP_PKEY_METHOD *pmeth, + int (**digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen)) +{ + if (digestsign) + *digestsign = pmeth->digestsign; +} + +void EVP_PKEY_meth_get_digestverify(EVP_PKEY_METHOD *pmeth, + int (**digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig, + size_t siglen, const unsigned char *tbs, + size_t tbslen)) +{ + if (digestverify) + *digestverify = pmeth->digestverify; +} + void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth, int (**pcheck) (EVP_PKEY *pkey)) { diff --git a/contrib/libs/openssl/crypto/ex_data.c b/contrib/libs/openssl/crypto/ex_data.c index 672c1954ff..0f5a929505 100644 --- a/contrib/libs/openssl/crypto/ex_data.c +++ b/contrib/libs/openssl/crypto/ex_data.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "crypto/cryptlib.h" +#include "crypto/cryptlib.h" #include "internal/thread_once.h" /* @@ -235,7 +235,7 @@ int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad) return 0; } for (i = 0; i < mx; i++) { - if (storage[i] != NULL && storage[i]->new_func != NULL) { + if (storage[i] != NULL && storage[i]->new_func != NULL) { ptr = CRYPTO_get_ex_data(ad, i); storage[i]->new_func(obj, ptr, ad, i, storage[i]->argl, storage[i]->argp); @@ -299,7 +299,7 @@ int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, for (i = 0; i < mx; i++) { ptr = CRYPTO_get_ex_data(from, i); - if (storage[i] != NULL && storage[i]->dup_func != NULL) + if (storage[i] != NULL && storage[i]->dup_func != NULL) if (!storage[i]->dup_func(to, from, &ptr, i, storage[i]->argl, storage[i]->argp)) goto err; diff --git a/contrib/libs/openssl/crypto/hmac/hm_ameth.c b/contrib/libs/openssl/crypto/hmac/hm_ameth.c index 43d7bbb7ef..f871e4fe71 100644 --- a/contrib/libs/openssl/crypto/hmac/hm_ameth.c +++ b/contrib/libs/openssl/crypto/hmac/hm_ameth.c @@ -10,8 +10,8 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/evp.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" /* * HMAC "ASN1" method. This is just here to indicate the maximum HMAC output diff --git a/contrib/libs/openssl/crypto/hmac/hm_pmeth.c b/contrib/libs/openssl/crypto/hmac/hm_pmeth.c index a8f4c70f38..56f98707f5 100644 --- a/contrib/libs/openssl/crypto/hmac/hm_pmeth.c +++ b/contrib/libs/openssl/crypto/hmac/hm_pmeth.c @@ -14,7 +14,7 @@ #include <openssl/evp.h> #include <openssl/hmac.h> #include <openssl/err.h> -#include "crypto/evp.h" +#include "crypto/evp.h" /* HMAC pkey context structure */ diff --git a/contrib/libs/openssl/crypto/hmac/hmac.c b/contrib/libs/openssl/crypto/hmac/hmac.c index 84efbce50d..5e087bf92f 100644 --- a/contrib/libs/openssl/crypto/hmac/hmac.c +++ b/contrib/libs/openssl/crypto/hmac/hmac.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -13,16 +13,16 @@ #include "internal/cryptlib.h" #include <openssl/hmac.h> #include <openssl/opensslconf.h> -#include "hmac_local.h" +#include "hmac_local.h" int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md, ENGINE *impl) { - int rv = 0, reset = 0; - int i, j; + int rv = 0, reset = 0; + int i, j; unsigned char pad[HMAC_MAX_MD_CBLOCK_SIZE]; - unsigned int keytmp_length; - unsigned char keytmp[HMAC_MAX_MD_CBLOCK_SIZE]; + unsigned int keytmp_length; + unsigned char keytmp[HMAC_MAX_MD_CBLOCK_SIZE]; /* If we are changing MD then we must have a key */ if (md != NULL && md != ctx->md && (key == NULL || len < 0)) @@ -45,34 +45,34 @@ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, if (key != NULL) { reset = 1; - + j = EVP_MD_block_size(md); - if (!ossl_assert(j <= (int)sizeof(keytmp))) + if (!ossl_assert(j <= (int)sizeof(keytmp))) return 0; if (j < len) { if (!EVP_DigestInit_ex(ctx->md_ctx, md, impl) || !EVP_DigestUpdate(ctx->md_ctx, key, len) - || !EVP_DigestFinal_ex(ctx->md_ctx, keytmp, - &keytmp_length)) + || !EVP_DigestFinal_ex(ctx->md_ctx, keytmp, + &keytmp_length)) return 0; } else { - if (len < 0 || len > (int)sizeof(keytmp)) + if (len < 0 || len > (int)sizeof(keytmp)) return 0; - memcpy(keytmp, key, len); - keytmp_length = len; + memcpy(keytmp, key, len); + keytmp_length = len; } - if (keytmp_length != HMAC_MAX_MD_CBLOCK_SIZE) - memset(&keytmp[keytmp_length], 0, - HMAC_MAX_MD_CBLOCK_SIZE - keytmp_length); + if (keytmp_length != HMAC_MAX_MD_CBLOCK_SIZE) + memset(&keytmp[keytmp_length], 0, + HMAC_MAX_MD_CBLOCK_SIZE - keytmp_length); for (i = 0; i < HMAC_MAX_MD_CBLOCK_SIZE; i++) - pad[i] = 0x36 ^ keytmp[i]; + pad[i] = 0x36 ^ keytmp[i]; if (!EVP_DigestInit_ex(ctx->i_ctx, md, impl) || !EVP_DigestUpdate(ctx->i_ctx, pad, EVP_MD_block_size(md))) goto err; for (i = 0; i < HMAC_MAX_MD_CBLOCK_SIZE; i++) - pad[i] = 0x5c ^ keytmp[i]; + pad[i] = 0x5c ^ keytmp[i]; if (!EVP_DigestInit_ex(ctx->o_ctx, md, impl) || !EVP_DigestUpdate(ctx->o_ctx, pad, EVP_MD_block_size(md))) goto err; @@ -81,10 +81,10 @@ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, goto err; rv = 1; err: - if (reset) { - OPENSSL_cleanse(keytmp, sizeof(keytmp)); + if (reset) { + OPENSSL_cleanse(keytmp, sizeof(keytmp)); OPENSSL_cleanse(pad, sizeof(pad)); - } + } return rv; } diff --git a/contrib/libs/openssl/crypto/hmac/hmac_local.h b/contrib/libs/openssl/crypto/hmac/hmac_local.h index 9704fdd913..8bcc55817a 100644 --- a/contrib/libs/openssl/crypto/hmac/hmac_local.h +++ b/contrib/libs/openssl/crypto/hmac/hmac_local.h @@ -1,23 +1,23 @@ -/* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_HMAC_LOCAL_H -# define OSSL_CRYPTO_HMAC_LOCAL_H - -/* The current largest case is for SHA3-224 */ -#define HMAC_MAX_MD_CBLOCK_SIZE 144 - -struct hmac_ctx_st { - const EVP_MD *md; - EVP_MD_CTX *md_ctx; - EVP_MD_CTX *i_ctx; - EVP_MD_CTX *o_ctx; -}; - -#endif +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_HMAC_LOCAL_H +# define OSSL_CRYPTO_HMAC_LOCAL_H + +/* The current largest case is for SHA3-224 */ +#define HMAC_MAX_MD_CBLOCK_SIZE 144 + +struct hmac_ctx_st { + const EVP_MD *md; + EVP_MD_CTX *md_ctx; + EVP_MD_CTX *i_ctx; + EVP_MD_CTX *o_ctx; +}; + +#endif diff --git a/contrib/libs/openssl/crypto/idea/i_cbc.c b/contrib/libs/openssl/crypto/idea/i_cbc.c index e0f3b4e8a5..4eff467111 100644 --- a/contrib/libs/openssl/crypto/idea/i_cbc.c +++ b/contrib/libs/openssl/crypto/idea/i_cbc.c @@ -8,7 +8,7 @@ */ #include <openssl/idea.h> -#include "idea_local.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, diff --git a/contrib/libs/openssl/crypto/idea/i_cfb64.c b/contrib/libs/openssl/crypto/idea/i_cfb64.c index 359bb17853..61c723015b 100644 --- a/contrib/libs/openssl/crypto/idea/i_cfb64.c +++ b/contrib/libs/openssl/crypto/idea/i_cfb64.c @@ -8,7 +8,7 @@ */ #include <openssl/idea.h> -#include "idea_local.h" +#include "idea_local.h" /* * The input and output encrypted as though 64bit cfb mode is being used. diff --git a/contrib/libs/openssl/crypto/idea/i_ecb.c b/contrib/libs/openssl/crypto/idea/i_ecb.c index f301f12441..cb724e1a6c 100644 --- a/contrib/libs/openssl/crypto/idea/i_ecb.c +++ b/contrib/libs/openssl/crypto/idea/i_ecb.c @@ -8,7 +8,7 @@ */ #include <openssl/idea.h> -#include "idea_local.h" +#include "idea_local.h" #include <openssl/opensslv.h> const char *IDEA_options(void) diff --git a/contrib/libs/openssl/crypto/idea/i_ofb64.c b/contrib/libs/openssl/crypto/idea/i_ofb64.c index 6095bbb47f..f000ced586 100644 --- a/contrib/libs/openssl/crypto/idea/i_ofb64.c +++ b/contrib/libs/openssl/crypto/idea/i_ofb64.c @@ -8,7 +8,7 @@ */ #include <openssl/idea.h> -#include "idea_local.h" +#include "idea_local.h" /* * The input and output encrypted as though 64bit ofb mode is being used. diff --git a/contrib/libs/openssl/crypto/idea/i_skey.c b/contrib/libs/openssl/crypto/idea/i_skey.c index 816a1cfb26..230338d7e3 100644 --- a/contrib/libs/openssl/crypto/idea/i_skey.c +++ b/contrib/libs/openssl/crypto/idea/i_skey.c @@ -8,7 +8,7 @@ */ #include <openssl/idea.h> -#include "idea_local.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/contrib/libs/openssl/crypto/idea/idea_local.h b/contrib/libs/openssl/crypto/idea/idea_local.h index 449c142165..50f81dfd8d 100644 --- a/contrib/libs/openssl/crypto/idea/idea_local.h +++ b/contrib/libs/openssl/crypto/idea/idea_local.h @@ -1,102 +1,102 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#define idea_mul(r,a,b,ul) \ -ul=(unsigned long)a*b; \ -if (ul != 0) \ - { \ - r=(ul&0xffff)-(ul>>16); \ - r-=((r)>>16); \ - } \ -else \ - r=(-(int)a-b+1); /* assuming a or b is 0 and in range */ - -/* NOTE - c is not incremented as per n2l */ -#define n2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c)))) ; \ - /* fall thru */ \ - case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ - /* fall thru */ \ - case 6: l2|=((unsigned long)(*(--(c))))<<16; \ - /* fall thru */ \ - case 5: l2|=((unsigned long)(*(--(c))))<<24; \ - /* fall thru */ \ - case 4: l1 =((unsigned long)(*(--(c)))) ; \ - /* fall thru */ \ - case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ - /* fall thru */ \ - case 2: l1|=((unsigned long)(*(--(c))))<<16; \ - /* fall thru */ \ - case 1: l1|=((unsigned long)(*(--(c))))<<24; \ - } \ - } - -/* NOTE - c is not incremented as per l2n */ -#define l2nn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ - /* fall thru */ \ - case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - /* fall thru */ \ - case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - /* fall thru */ \ - case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - /* fall thru */ \ - case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ - /* fall thru */ \ - case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - /* fall thru */ \ - case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - /* fall thru */ \ - case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - } \ - } - -#undef n2l -#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))) - -#undef l2n -#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -#undef s2n -#define s2n(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff)) - -#undef n2s -#define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \ - l|=((IDEA_INT)(*((c)++))) ) - - -#define E_IDEA(num) \ - x1&=0xffff; \ - idea_mul(x1,x1,*p,ul); p++; \ - x2+= *(p++); \ - x3+= *(p++); \ - x4&=0xffff; \ - idea_mul(x4,x4,*p,ul); p++; \ - t0=(x1^x3)&0xffff; \ - idea_mul(t0,t0,*p,ul); p++; \ - t1=(t0+(x2^x4))&0xffff; \ - idea_mul(t1,t1,*p,ul); p++; \ - t0+=t1; \ - x1^=t1; \ - x4^=t0; \ - ul=x2^t0; /* do the swap to x3 */ \ - x2=x3^t1; \ - x3=ul; +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#define idea_mul(r,a,b,ul) \ +ul=(unsigned long)a*b; \ +if (ul != 0) \ + { \ + r=(ul&0xffff)-(ul>>16); \ + r-=((r)>>16); \ + } \ +else \ + r=(-(int)a-b+1); /* assuming a or b is 0 and in range */ + +/* NOTE - c is not incremented as per n2l */ +#define n2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c)))) ; \ + /* fall thru */ \ + case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ + /* fall thru */ \ + case 6: l2|=((unsigned long)(*(--(c))))<<16; \ + /* fall thru */ \ + case 5: l2|=((unsigned long)(*(--(c))))<<24; \ + /* fall thru */ \ + case 4: l1 =((unsigned long)(*(--(c)))) ; \ + /* fall thru */ \ + case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ + /* fall thru */ \ + case 2: l1|=((unsigned long)(*(--(c))))<<16; \ + /* fall thru */ \ + case 1: l1|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +/* NOTE - c is not incremented as per l2n */ +#define l2nn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ + /* fall thru */ \ + case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + /* fall thru */ \ + case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + /* fall thru */ \ + case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + /* fall thru */ \ + case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ + /* fall thru */ \ + case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + /* fall thru */ \ + case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + /* fall thru */ \ + case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + } \ + } + +#undef n2l +#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))) + +#undef l2n +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +#undef s2n +#define s2n(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff)) + +#undef n2s +#define n2s(c,l) (l =((IDEA_INT)(*((c)++)))<< 8L, \ + l|=((IDEA_INT)(*((c)++))) ) + + +#define E_IDEA(num) \ + x1&=0xffff; \ + idea_mul(x1,x1,*p,ul); p++; \ + x2+= *(p++); \ + x3+= *(p++); \ + x4&=0xffff; \ + idea_mul(x4,x4,*p,ul); p++; \ + t0=(x1^x3)&0xffff; \ + idea_mul(t0,t0,*p,ul); p++; \ + t1=(t0+(x2^x4))&0xffff; \ + idea_mul(t1,t1,*p,ul); p++; \ + t0+=t1; \ + x1^=t1; \ + x4^=t0; \ + ul=x2^t0; /* do the swap to x3 */ \ + x2=x3^t1; \ + x3=ul; diff --git a/contrib/libs/openssl/crypto/init.c b/contrib/libs/openssl/crypto/init.c index 31edf51b42..1b0d523bea 100644 --- a/contrib/libs/openssl/crypto/init.c +++ b/contrib/libs/openssl/crypto/init.c @@ -8,25 +8,25 @@ */ #include "e_os.h" -#include "crypto/cryptlib.h" +#include "crypto/cryptlib.h" #include <openssl/err.h> -#include "crypto/rand.h" +#include "crypto/rand.h" #include "internal/bio.h" #include <openssl/evp.h> -#include "crypto/evp.h" +#include "crypto/evp.h" #include "internal/conf.h" -#include "crypto/async.h" -#include "crypto/engine.h" +#include "crypto/async.h" +#include "crypto/engine.h" #include "internal/comp.h" #include "internal/err.h" -#include "crypto/err.h" -#include "crypto/objects.h" +#include "crypto/err.h" +#include "crypto/objects.h" #include <stdlib.h> #include <assert.h> #include "internal/thread_once.h" -#include "crypto/dso_conf.h" +#include "crypto/dso_conf.h" #include "internal/dso.h" -#include "crypto/store.h" +#include "crypto/store.h" static int stopped = 0; diff --git a/contrib/libs/openssl/crypto/kdf/hkdf.c b/contrib/libs/openssl/crypto/kdf/hkdf.c index ec1d8b6689..25bf4b729f 100644 --- a/contrib/libs/openssl/crypto/kdf/hkdf.c +++ b/contrib/libs/openssl/crypto/kdf/hkdf.c @@ -13,7 +13,7 @@ #include <openssl/kdf.h> #include <openssl/evp.h> #include "internal/cryptlib.h" -#include "crypto/evp.h" +#include "crypto/evp.h" #define HKDF_MAXBUF 1024 diff --git a/contrib/libs/openssl/crypto/kdf/scrypt.c b/contrib/libs/openssl/crypto/kdf/scrypt.c index ee59ffe838..68606ac00a 100644 --- a/contrib/libs/openssl/crypto/kdf/scrypt.c +++ b/contrib/libs/openssl/crypto/kdf/scrypt.c @@ -13,7 +13,7 @@ #include <openssl/kdf.h> #include <openssl/evp.h> #include "internal/cryptlib.h" -#include "crypto/evp.h" +#include "crypto/evp.h" #ifndef OPENSSL_NO_SCRYPT diff --git a/contrib/libs/openssl/crypto/kdf/tls1_prf.c b/contrib/libs/openssl/crypto/kdf/tls1_prf.c index 790b58b0db..e9ca8e1278 100644 --- a/contrib/libs/openssl/crypto/kdf/tls1_prf.c +++ b/contrib/libs/openssl/crypto/kdf/tls1_prf.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include <openssl/kdf.h> #include <openssl/evp.h> -#include "crypto/evp.h" +#include "crypto/evp.h" static int tls1_prf_alg(const EVP_MD *md, const unsigned char *sec, size_t slen, diff --git a/contrib/libs/openssl/crypto/lhash/lh_stats.c b/contrib/libs/openssl/crypto/lhash/lh_stats.c index 8fca783ec9..45f1b10555 100644 --- a/contrib/libs/openssl/crypto/lhash/lh_stats.c +++ b/contrib/libs/openssl/crypto/lhash/lh_stats.c @@ -18,7 +18,7 @@ #include <openssl/bio.h> #include <openssl/lhash.h> -#include "lhash_local.h" +#include "lhash_local.h" # ifndef OPENSSL_NO_STDIO void OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp) diff --git a/contrib/libs/openssl/crypto/lhash/lhash.c b/contrib/libs/openssl/crypto/lhash/lhash.c index ed647715b3..9dc887d91e 100644 --- a/contrib/libs/openssl/crypto/lhash/lhash.c +++ b/contrib/libs/openssl/crypto/lhash/lhash.c @@ -13,9 +13,9 @@ #include <openssl/crypto.h> #include <openssl/lhash.h> #include <openssl/err.h> -#include "crypto/ctype.h" -#include "crypto/lhash.h" -#include "lhash_local.h" +#include "crypto/ctype.h" +#include "crypto/lhash.h" +#include "lhash_local.h" /* * A hashing implementation that appears to be based on the linear hashing diff --git a/contrib/libs/openssl/crypto/lhash/lhash_local.h b/contrib/libs/openssl/crypto/lhash/lhash_local.h index 60b179da59..678224acd5 100644 --- a/contrib/libs/openssl/crypto/lhash/lhash_local.h +++ b/contrib/libs/openssl/crypto/lhash/lhash_local.h @@ -1,44 +1,44 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ -#include <openssl/crypto.h> - -#include "internal/tsan_assist.h" - -struct lhash_node_st { - void *data; - struct lhash_node_st *next; - unsigned long hash; -}; - -struct lhash_st { - OPENSSL_LH_NODE **b; - OPENSSL_LH_COMPFUNC comp; - OPENSSL_LH_HASHFUNC hash; - unsigned int num_nodes; - unsigned int num_alloc_nodes; - unsigned int p; - unsigned int pmax; - unsigned long up_load; /* load times 256 */ - unsigned long down_load; /* load times 256 */ - unsigned long num_items; - unsigned long num_expands; - unsigned long num_expand_reallocs; - unsigned long num_contracts; - unsigned long num_contract_reallocs; - TSAN_QUALIFIER unsigned long num_hash_calls; - TSAN_QUALIFIER unsigned long num_comp_calls; - unsigned long num_insert; - unsigned long num_replace; - unsigned long num_delete; - unsigned long num_no_delete; - TSAN_QUALIFIER unsigned long num_retrieve; - TSAN_QUALIFIER unsigned long num_retrieve_miss; - TSAN_QUALIFIER unsigned long num_hash_comps; - int error; -}; +/* + * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ +#include <openssl/crypto.h> + +#include "internal/tsan_assist.h" + +struct lhash_node_st { + void *data; + struct lhash_node_st *next; + unsigned long hash; +}; + +struct lhash_st { + OPENSSL_LH_NODE **b; + OPENSSL_LH_COMPFUNC comp; + OPENSSL_LH_HASHFUNC hash; + unsigned int num_nodes; + unsigned int num_alloc_nodes; + unsigned int p; + unsigned int pmax; + unsigned long up_load; /* load times 256 */ + unsigned long down_load; /* load times 256 */ + unsigned long num_items; + unsigned long num_expands; + unsigned long num_expand_reallocs; + unsigned long num_contracts; + unsigned long num_contract_reallocs; + TSAN_QUALIFIER unsigned long num_hash_calls; + TSAN_QUALIFIER unsigned long num_comp_calls; + unsigned long num_insert; + unsigned long num_replace; + unsigned long num_delete; + unsigned long num_no_delete; + TSAN_QUALIFIER unsigned long num_retrieve; + TSAN_QUALIFIER unsigned long num_retrieve_miss; + TSAN_QUALIFIER unsigned long num_hash_comps; + int error; +}; diff --git a/contrib/libs/openssl/crypto/md4/md4_dgst.c b/contrib/libs/openssl/crypto/md4/md4_dgst.c index 2147db693f..29b6b252ba 100644 --- a/contrib/libs/openssl/crypto/md4/md4_dgst.c +++ b/contrib/libs/openssl/crypto/md4/md4_dgst.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <openssl/opensslv.h> -#include "md4_local.h" +#include "md4_local.h" /* * Implemented from RFC1186 The MD4 Message-Digest Algorithm @@ -39,7 +39,7 @@ void md4_block_data_order(MD4_CTX *c, const void *data_, size_t num) const unsigned char *data = data_; register unsigned MD32_REG_T A, B, C, D, l; # ifndef MD32_XARRAY - /* See comment in crypto/sha/sha_local.h for details. */ + /* See comment in crypto/sha/sha_local.h for details. */ unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; # define X(i) XX##i diff --git a/contrib/libs/openssl/crypto/md4/md4_local.h b/contrib/libs/openssl/crypto/md4/md4_local.h index 000598be42..5f05720e97 100644 --- a/contrib/libs/openssl/crypto/md4/md4_local.h +++ b/contrib/libs/openssl/crypto/md4/md4_local.h @@ -1,60 +1,60 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <stdlib.h> -#include <string.h> -#include <openssl/opensslconf.h> -#include <openssl/md4.h> - -void md4_block_data_order(MD4_CTX *c, const void *p, size_t num); - -#define DATA_ORDER_IS_LITTLE_ENDIAN - -#define HASH_LONG MD4_LONG -#define HASH_CTX MD4_CTX -#define HASH_CBLOCK MD4_CBLOCK -#define HASH_UPDATE MD4_Update -#define HASH_TRANSFORM MD4_Transform -#define HASH_FINAL MD4_Final -#define HASH_MAKE_STRING(c,s) do { \ - unsigned long ll; \ - ll=(c)->A; (void)HOST_l2c(ll,(s)); \ - ll=(c)->B; (void)HOST_l2c(ll,(s)); \ - ll=(c)->C; (void)HOST_l2c(ll,(s)); \ - ll=(c)->D; (void)HOST_l2c(ll,(s)); \ - } while (0) -#define HASH_BLOCK_DATA_ORDER md4_block_data_order - -#include "crypto/md32_common.h" - -/*- -#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) -#define G(x,y,z) (((x) & (y)) | ((x) & ((z))) | ((y) & ((z)))) -*/ - -/* - * As pointed out by Wei Dai, the above can be simplified to the code - * below. Wei attributes these optimizations to Peter Gutmann's SHS code, - * and he attributes it to Rich Schroeppel. - */ -#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) -#define G(b,c,d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) -#define H(b,c,d) ((b) ^ (c) ^ (d)) - -#define R0(a,b,c,d,k,s,t) { \ - a+=((k)+(t)+F((b),(c),(d))); \ - a=ROTATE(a,s); }; - -#define R1(a,b,c,d,k,s,t) { \ - a+=((k)+(t)+G((b),(c),(d))); \ - a=ROTATE(a,s); }; - -#define R2(a,b,c,d,k,s,t) { \ - a+=((k)+(t)+H((b),(c),(d))); \ - a=ROTATE(a,s); }; +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <stdlib.h> +#include <string.h> +#include <openssl/opensslconf.h> +#include <openssl/md4.h> + +void md4_block_data_order(MD4_CTX *c, const void *p, size_t num); + +#define DATA_ORDER_IS_LITTLE_ENDIAN + +#define HASH_LONG MD4_LONG +#define HASH_CTX MD4_CTX +#define HASH_CBLOCK MD4_CBLOCK +#define HASH_UPDATE MD4_Update +#define HASH_TRANSFORM MD4_Transform +#define HASH_FINAL MD4_Final +#define HASH_MAKE_STRING(c,s) do { \ + unsigned long ll; \ + ll=(c)->A; (void)HOST_l2c(ll,(s)); \ + ll=(c)->B; (void)HOST_l2c(ll,(s)); \ + ll=(c)->C; (void)HOST_l2c(ll,(s)); \ + ll=(c)->D; (void)HOST_l2c(ll,(s)); \ + } while (0) +#define HASH_BLOCK_DATA_ORDER md4_block_data_order + +#include "crypto/md32_common.h" + +/*- +#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) +#define G(x,y,z) (((x) & (y)) | ((x) & ((z))) | ((y) & ((z)))) +*/ + +/* + * As pointed out by Wei Dai, the above can be simplified to the code + * below. Wei attributes these optimizations to Peter Gutmann's SHS code, + * and he attributes it to Rich Schroeppel. + */ +#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) +#define G(b,c,d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) +#define H(b,c,d) ((b) ^ (c) ^ (d)) + +#define R0(a,b,c,d,k,s,t) { \ + a+=((k)+(t)+F((b),(c),(d))); \ + a=ROTATE(a,s); }; + +#define R1(a,b,c,d,k,s,t) { \ + a+=((k)+(t)+G((b),(c),(d))); \ + a=ROTATE(a,s); }; + +#define R2(a,b,c,d,k,s,t) { \ + a+=((k)+(t)+H((b),(c),(d))); \ + a=ROTATE(a,s); }; diff --git a/contrib/libs/openssl/crypto/md5/md5_dgst.c b/contrib/libs/openssl/crypto/md5/md5_dgst.c index 56328ca1b6..d84cba37ae 100644 --- a/contrib/libs/openssl/crypto/md5/md5_dgst.c +++ b/contrib/libs/openssl/crypto/md5/md5_dgst.c @@ -8,7 +8,7 @@ */ #include <stdio.h> -#include "md5_local.h" +#include "md5_local.h" #include <openssl/opensslv.h> /* @@ -39,7 +39,7 @@ void md5_block_data_order(MD5_CTX *c, const void *data_, size_t num) const unsigned char *data = data_; register unsigned MD32_REG_T A, B, C, D, l; # ifndef MD32_XARRAY - /* See comment in crypto/sha/sha_local.h for details. */ + /* See comment in crypto/sha/sha_local.h for details. */ unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; # define X(i) XX##i diff --git a/contrib/libs/openssl/crypto/md5/md5_local.h b/contrib/libs/openssl/crypto/md5/md5_local.h index 1ccc6aa2ee..b0087bea81 100644 --- a/contrib/libs/openssl/crypto/md5/md5_local.h +++ b/contrib/libs/openssl/crypto/md5/md5_local.h @@ -1,80 +1,80 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <stdlib.h> -#include <string.h> -#include <openssl/e_os2.h> -#include <openssl/md5.h> - -#ifdef MD5_ASM -# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ - defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) -# define md5_block_data_order md5_block_asm_data_order -# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) -# define md5_block_data_order md5_block_asm_data_order -# elif defined(__sparc) || defined(__sparc__) -# define md5_block_data_order md5_block_asm_data_order -# endif -#endif - -void md5_block_data_order(MD5_CTX *c, const void *p, size_t num); - -#define DATA_ORDER_IS_LITTLE_ENDIAN - -#define HASH_LONG MD5_LONG -#define HASH_CTX MD5_CTX -#define HASH_CBLOCK MD5_CBLOCK -#define HASH_UPDATE MD5_Update -#define HASH_TRANSFORM MD5_Transform -#define HASH_FINAL MD5_Final -#define HASH_MAKE_STRING(c,s) do { \ - unsigned long ll; \ - ll=(c)->A; (void)HOST_l2c(ll,(s)); \ - ll=(c)->B; (void)HOST_l2c(ll,(s)); \ - ll=(c)->C; (void)HOST_l2c(ll,(s)); \ - ll=(c)->D; (void)HOST_l2c(ll,(s)); \ - } while (0) -#define HASH_BLOCK_DATA_ORDER md5_block_data_order - -#include "crypto/md32_common.h" - -/*- -#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) -#define G(x,y,z) (((x) & (z)) | ((y) & (~(z)))) -*/ - -/* - * As pointed out by Wei Dai, the above can be simplified to the code - * below. Wei attributes these optimizations to Peter Gutmann's - * SHS code, and he attributes it to Rich Schroeppel. - */ -#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) -#define G(b,c,d) ((((b) ^ (c)) & (d)) ^ (c)) -#define H(b,c,d) ((b) ^ (c) ^ (d)) -#define I(b,c,d) (((~(d)) | (b)) ^ (c)) - -#define R0(a,b,c,d,k,s,t) { \ - a+=((k)+(t)+F((b),(c),(d))); \ - a=ROTATE(a,s); \ - a+=b; }; - -#define R1(a,b,c,d,k,s,t) { \ - a+=((k)+(t)+G((b),(c),(d))); \ - a=ROTATE(a,s); \ - a+=b; }; - -#define R2(a,b,c,d,k,s,t) { \ - a+=((k)+(t)+H((b),(c),(d))); \ - a=ROTATE(a,s); \ - a+=b; }; - -#define R3(a,b,c,d,k,s,t) { \ - a+=((k)+(t)+I((b),(c),(d))); \ - a=ROTATE(a,s); \ - a+=b; }; +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <stdlib.h> +#include <string.h> +#include <openssl/e_os2.h> +#include <openssl/md5.h> + +#ifdef MD5_ASM +# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ + defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) +# define md5_block_data_order md5_block_asm_data_order +# elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) +# define md5_block_data_order md5_block_asm_data_order +# elif defined(__sparc) || defined(__sparc__) +# define md5_block_data_order md5_block_asm_data_order +# endif +#endif + +void md5_block_data_order(MD5_CTX *c, const void *p, size_t num); + +#define DATA_ORDER_IS_LITTLE_ENDIAN + +#define HASH_LONG MD5_LONG +#define HASH_CTX MD5_CTX +#define HASH_CBLOCK MD5_CBLOCK +#define HASH_UPDATE MD5_Update +#define HASH_TRANSFORM MD5_Transform +#define HASH_FINAL MD5_Final +#define HASH_MAKE_STRING(c,s) do { \ + unsigned long ll; \ + ll=(c)->A; (void)HOST_l2c(ll,(s)); \ + ll=(c)->B; (void)HOST_l2c(ll,(s)); \ + ll=(c)->C; (void)HOST_l2c(ll,(s)); \ + ll=(c)->D; (void)HOST_l2c(ll,(s)); \ + } while (0) +#define HASH_BLOCK_DATA_ORDER md5_block_data_order + +#include "crypto/md32_common.h" + +/*- +#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) +#define G(x,y,z) (((x) & (z)) | ((y) & (~(z)))) +*/ + +/* + * As pointed out by Wei Dai, the above can be simplified to the code + * below. Wei attributes these optimizations to Peter Gutmann's + * SHS code, and he attributes it to Rich Schroeppel. + */ +#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) +#define G(b,c,d) ((((b) ^ (c)) & (d)) ^ (c)) +#define H(b,c,d) ((b) ^ (c) ^ (d)) +#define I(b,c,d) (((~(d)) | (b)) ^ (c)) + +#define R0(a,b,c,d,k,s,t) { \ + a+=((k)+(t)+F((b),(c),(d))); \ + a=ROTATE(a,s); \ + a+=b; }; + +#define R1(a,b,c,d,k,s,t) { \ + a+=((k)+(t)+G((b),(c),(d))); \ + a=ROTATE(a,s); \ + a+=b; }; + +#define R2(a,b,c,d,k,s,t) { \ + a+=((k)+(t)+H((b),(c),(d))); \ + a=ROTATE(a,s); \ + a+=b; }; + +#define R3(a,b,c,d,k,s,t) { \ + a+=((k)+(t)+I((b),(c),(d))); \ + a=ROTATE(a,s); \ + a+=b; }; diff --git a/contrib/libs/openssl/crypto/mem.c b/contrib/libs/openssl/crypto/mem.c index 8c292111d0..2b39ca3a10 100644 --- a/contrib/libs/openssl/crypto/mem.c +++ b/contrib/libs/openssl/crypto/mem.c @@ -9,7 +9,7 @@ #include "e_os.h" #include "internal/cryptlib.h" -#include "crypto/cryptlib.h" +#include "crypto/cryptlib.h" #include <stdio.h> #include <stdlib.h> #include <limits.h> diff --git a/contrib/libs/openssl/crypto/mips_arch.h b/contrib/libs/openssl/crypto/mips_arch.h index 3091f66c3a..4ae1a1a933 100644 --- a/contrib/libs/openssl/crypto/mips_arch.h +++ b/contrib/libs/openssl/crypto/mips_arch.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_MIPS_ARCH_H -# define OSSL_CRYPTO_MIPS_ARCH_H +#ifndef OSSL_CRYPTO_MIPS_ARCH_H +# define OSSL_CRYPTO_MIPS_ARCH_H # if (defined(__mips_smartmips) || defined(_MIPS_ARCH_MIPS32R3) || \ defined(_MIPS_ARCH_MIPS32R5) || defined(_MIPS_ARCH_MIPS32R6)) \ diff --git a/contrib/libs/openssl/crypto/modes/cbc128.c b/contrib/libs/openssl/crypto/modes/cbc128.c index 4a39b9f331..15a14be708 100644 --- a/contrib/libs/openssl/crypto/modes/cbc128.c +++ b/contrib/libs/openssl/crypto/modes/cbc128.c @@ -8,7 +8,7 @@ */ #include <openssl/crypto.h> -#include "modes_local.h" +#include "modes_local.h" #include <string.h> #if !defined(STRICT_ALIGNMENT) && !defined(PEDANTIC) diff --git a/contrib/libs/openssl/crypto/modes/ccm128.c b/contrib/libs/openssl/crypto/modes/ccm128.c index 1ef6c7d080..655b103502 100644 --- a/contrib/libs/openssl/crypto/modes/ccm128.c +++ b/contrib/libs/openssl/crypto/modes/ccm128.c @@ -8,7 +8,7 @@ */ #include <openssl/crypto.h> -#include "modes_local.h" +#include "modes_local.h" #include <string.h> #ifndef STRICT_ALIGNMENT diff --git a/contrib/libs/openssl/crypto/modes/cfb128.c b/contrib/libs/openssl/crypto/modes/cfb128.c index 900448b928..b2530007b6 100644 --- a/contrib/libs/openssl/crypto/modes/cfb128.c +++ b/contrib/libs/openssl/crypto/modes/cfb128.c @@ -8,7 +8,7 @@ */ #include <openssl/crypto.h> -#include "modes_local.h" +#include "modes_local.h" #include <string.h> #if defined(__GNUC__) && !defined(STRICT_ALIGNMENT) diff --git a/contrib/libs/openssl/crypto/modes/ctr128.c b/contrib/libs/openssl/crypto/modes/ctr128.c index 95554381ed..1ed7decedf 100644 --- a/contrib/libs/openssl/crypto/modes/ctr128.c +++ b/contrib/libs/openssl/crypto/modes/ctr128.c @@ -8,7 +8,7 @@ */ #include <openssl/crypto.h> -#include "modes_local.h" +#include "modes_local.h" #include <string.h> #if defined(__GNUC__) && !defined(STRICT_ALIGNMENT) diff --git a/contrib/libs/openssl/crypto/modes/cts128.c b/contrib/libs/openssl/crypto/modes/cts128.c index d2220ccd92..9052e85776 100644 --- a/contrib/libs/openssl/crypto/modes/cts128.c +++ b/contrib/libs/openssl/crypto/modes/cts128.c @@ -8,7 +8,7 @@ */ #include <openssl/crypto.h> -#include "modes_local.h" +#include "modes_local.h" #include <string.h> /* diff --git a/contrib/libs/openssl/crypto/modes/gcm128.c b/contrib/libs/openssl/crypto/modes/gcm128.c index 8feb468cec..8304efff48 100644 --- a/contrib/libs/openssl/crypto/modes/gcm128.c +++ b/contrib/libs/openssl/crypto/modes/gcm128.c @@ -8,7 +8,7 @@ */ #include <openssl/crypto.h> -#include "modes_local.h" +#include "modes_local.h" #include <string.h> #if defined(__GNUC__) && !defined(STRICT_ALIGNMENT) diff --git a/contrib/libs/openssl/crypto/modes/modes_local.h b/contrib/libs/openssl/crypto/modes/modes_local.h index 61d9ae8b22..888141681e 100644 --- a/contrib/libs/openssl/crypto/modes/modes_local.h +++ b/contrib/libs/openssl/crypto/modes/modes_local.h @@ -1,42 +1,42 @@ -/* +/* * Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <openssl/modes.h> - -#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) -typedef __int64 i64; -typedef unsigned __int64 u64; -# define U64(C) C##UI64 -#elif defined(__arch64__) -typedef long i64; -typedef unsigned long u64; -# define U64(C) C##UL -#else -typedef long long i64; -typedef unsigned long long u64; -# define U64(C) C##ULL -#endif - -typedef unsigned int u32; -typedef unsigned char u8; - -#define STRICT_ALIGNMENT 1 -#ifndef PEDANTIC -# if defined(__i386) || defined(__i386__) || \ - defined(__x86_64) || defined(__x86_64__) || \ - defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \ - defined(__aarch64__) || \ - defined(__s390__) || defined(__s390x__) -# undef STRICT_ALIGNMENT -# endif -#endif - + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <openssl/modes.h> + +#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) +typedef __int64 i64; +typedef unsigned __int64 u64; +# define U64(C) C##UI64 +#elif defined(__arch64__) +typedef long i64; +typedef unsigned long u64; +# define U64(C) C##UL +#else +typedef long long i64; +typedef unsigned long long u64; +# define U64(C) C##ULL +#endif + +typedef unsigned int u32; +typedef unsigned char u8; + +#define STRICT_ALIGNMENT 1 +#ifndef PEDANTIC +# if defined(__i386) || defined(__i386__) || \ + defined(__x86_64) || defined(__x86_64__) || \ + defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \ + defined(__aarch64__) || \ + defined(__s390__) || defined(__s390x__) +# undef STRICT_ALIGNMENT +# endif +#endif + #ifndef STRICT_ALIGNMENT # ifdef __GNUC__ typedef u32 u32_a1 __attribute((__aligned__(1))); @@ -45,157 +45,157 @@ typedef u32 u32_a1; # endif #endif -#if !defined(PEDANTIC) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) -# if defined(__GNUC__) && __GNUC__>=2 -# if defined(__x86_64) || defined(__x86_64__) -# define BSWAP8(x) ({ u64 ret_=(x); \ - asm ("bswapq %0" \ - : "+r"(ret_)); ret_; }) -# define BSWAP4(x) ({ u32 ret_=(x); \ - asm ("bswapl %0" \ - : "+r"(ret_)); ret_; }) -# elif (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY) -# define BSWAP8(x) ({ u32 lo_=(u64)(x)>>32,hi_=(x); \ - asm ("bswapl %0; bswapl %1" \ - : "+r"(hi_),"+r"(lo_)); \ - (u64)hi_<<32|lo_; }) -# define BSWAP4(x) ({ u32 ret_=(x); \ - asm ("bswapl %0" \ - : "+r"(ret_)); ret_; }) -# elif defined(__aarch64__) +#if !defined(PEDANTIC) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) +# if defined(__GNUC__) && __GNUC__>=2 +# if defined(__x86_64) || defined(__x86_64__) +# define BSWAP8(x) ({ u64 ret_=(x); \ + asm ("bswapq %0" \ + : "+r"(ret_)); ret_; }) +# define BSWAP4(x) ({ u32 ret_=(x); \ + asm ("bswapl %0" \ + : "+r"(ret_)); ret_; }) +# elif (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY) +# define BSWAP8(x) ({ u32 lo_=(u64)(x)>>32,hi_=(x); \ + asm ("bswapl %0; bswapl %1" \ + : "+r"(hi_),"+r"(lo_)); \ + (u64)hi_<<32|lo_; }) +# define BSWAP4(x) ({ u32 ret_=(x); \ + asm ("bswapl %0" \ + : "+r"(ret_)); ret_; }) +# elif defined(__aarch64__) # if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__ # define BSWAP8(x) ({ u64 ret_; \ - asm ("rev %0,%1" \ - : "=r"(ret_) : "r"(x)); ret_; }) + asm ("rev %0,%1" \ + : "=r"(ret_) : "r"(x)); ret_; }) # define BSWAP4(x) ({ u32 ret_; \ - asm ("rev %w0,%w1" \ - : "=r"(ret_) : "r"(x)); ret_; }) + asm ("rev %w0,%w1" \ + : "=r"(ret_) : "r"(x)); ret_; }) # endif -# elif (defined(__arm__) || defined(__arm)) && !defined(STRICT_ALIGNMENT) -# define BSWAP8(x) ({ u32 lo_=(u64)(x)>>32,hi_=(x); \ - asm ("rev %0,%0; rev %1,%1" \ - : "+r"(hi_),"+r"(lo_)); \ - (u64)hi_<<32|lo_; }) -# define BSWAP4(x) ({ u32 ret_; \ - asm ("rev %0,%1" \ - : "=r"(ret_) : "r"((u32)(x))); \ - ret_; }) -# endif -# elif defined(_MSC_VER) -# if _MSC_VER>=1300 -# include <stdlib.h> -# pragma intrinsic(_byteswap_uint64,_byteswap_ulong) -# define BSWAP8(x) _byteswap_uint64((u64)(x)) -# define BSWAP4(x) _byteswap_ulong((u32)(x)) -# elif defined(_M_IX86) -__inline u32 _bswap4(u32 val) -{ -_asm mov eax, val _asm bswap eax} -# define BSWAP4(x) _bswap4(x) -# endif -# endif -#endif -#if defined(BSWAP4) && !defined(STRICT_ALIGNMENT) +# elif (defined(__arm__) || defined(__arm)) && !defined(STRICT_ALIGNMENT) +# define BSWAP8(x) ({ u32 lo_=(u64)(x)>>32,hi_=(x); \ + asm ("rev %0,%0; rev %1,%1" \ + : "+r"(hi_),"+r"(lo_)); \ + (u64)hi_<<32|lo_; }) +# define BSWAP4(x) ({ u32 ret_; \ + asm ("rev %0,%1" \ + : "=r"(ret_) : "r"((u32)(x))); \ + ret_; }) +# endif +# elif defined(_MSC_VER) +# if _MSC_VER>=1300 +# include <stdlib.h> +# pragma intrinsic(_byteswap_uint64,_byteswap_ulong) +# define BSWAP8(x) _byteswap_uint64((u64)(x)) +# define BSWAP4(x) _byteswap_ulong((u32)(x)) +# elif defined(_M_IX86) +__inline u32 _bswap4(u32 val) +{ +_asm mov eax, val _asm bswap eax} +# define BSWAP4(x) _bswap4(x) +# endif +# endif +#endif +#if defined(BSWAP4) && !defined(STRICT_ALIGNMENT) # define GETU32(p) BSWAP4(*(const u32_a1 *)(p)) # define PUTU32(p,v) *(u32_a1 *)(p) = BSWAP4(v) -#else -# define GETU32(p) ((u32)(p)[0]<<24|(u32)(p)[1]<<16|(u32)(p)[2]<<8|(u32)(p)[3]) -# define PUTU32(p,v) ((p)[0]=(u8)((v)>>24),(p)[1]=(u8)((v)>>16),(p)[2]=(u8)((v)>>8),(p)[3]=(u8)(v)) -#endif -/*- GCM definitions */ typedef struct { - u64 hi, lo; -} u128; - -#ifdef TABLE_BITS -# undef TABLE_BITS -#endif -/* - * Even though permitted values for TABLE_BITS are 8, 4 and 1, it should - * never be set to 8 [or 1]. For further information see gcm128.c. - */ -#define TABLE_BITS 4 - -struct gcm128_context { - /* Following 6 names follow names in GCM specification */ - union { - u64 u[2]; - u32 d[4]; - u8 c[16]; - size_t t[16 / sizeof(size_t)]; - } Yi, EKi, EK0, len, Xi, H; - /* - * Relative position of Xi, H and pre-computed Htable is used in some - * assembler modules, i.e. don't change the order! - */ -#if TABLE_BITS==8 - u128 Htable[256]; -#else - u128 Htable[16]; - void (*gmult) (u64 Xi[2], const u128 Htable[16]); - void (*ghash) (u64 Xi[2], const u128 Htable[16], const u8 *inp, - size_t len); -#endif - unsigned int mres, ares; - block128_f block; - void *key; -#if !defined(OPENSSL_SMALL_FOOTPRINT) - unsigned char Xn[48]; -#endif -}; - -struct xts128_context { - void *key1, *key2; - block128_f block1, block2; -}; - -struct ccm128_context { - union { - u64 u[2]; - u8 c[16]; - } nonce, cmac; - u64 blocks; - block128_f block; - void *key; -}; - -#ifndef OPENSSL_NO_OCB - -typedef union { - u64 a[2]; - unsigned char c[16]; -} OCB_BLOCK; -# define ocb_block16_xor(in1,in2,out) \ - ( (out)->a[0]=(in1)->a[0]^(in2)->a[0], \ - (out)->a[1]=(in1)->a[1]^(in2)->a[1] ) -# if STRICT_ALIGNMENT -# define ocb_block16_xor_misaligned(in1,in2,out) \ - ocb_block_xor((in1)->c,(in2)->c,16,(out)->c) -# else -# define ocb_block16_xor_misaligned ocb_block16_xor -# endif - -struct ocb128_context { - /* Need both encrypt and decrypt key schedules for decryption */ - block128_f encrypt; - block128_f decrypt; - void *keyenc; - void *keydec; - ocb128_f stream; /* direction dependent */ - /* Key dependent variables. Can be reused if key remains the same */ - size_t l_index; - size_t max_l_index; - OCB_BLOCK l_star; - OCB_BLOCK l_dollar; - OCB_BLOCK *l; - /* Must be reset for each session */ - struct { - u64 blocks_hashed; - u64 blocks_processed; - OCB_BLOCK offset_aad; - OCB_BLOCK sum; - OCB_BLOCK offset; - OCB_BLOCK checksum; - } sess; -}; -#endif /* OPENSSL_NO_OCB */ +#else +# define GETU32(p) ((u32)(p)[0]<<24|(u32)(p)[1]<<16|(u32)(p)[2]<<8|(u32)(p)[3]) +# define PUTU32(p,v) ((p)[0]=(u8)((v)>>24),(p)[1]=(u8)((v)>>16),(p)[2]=(u8)((v)>>8),(p)[3]=(u8)(v)) +#endif +/*- GCM definitions */ typedef struct { + u64 hi, lo; +} u128; + +#ifdef TABLE_BITS +# undef TABLE_BITS +#endif +/* + * Even though permitted values for TABLE_BITS are 8, 4 and 1, it should + * never be set to 8 [or 1]. For further information see gcm128.c. + */ +#define TABLE_BITS 4 + +struct gcm128_context { + /* Following 6 names follow names in GCM specification */ + union { + u64 u[2]; + u32 d[4]; + u8 c[16]; + size_t t[16 / sizeof(size_t)]; + } Yi, EKi, EK0, len, Xi, H; + /* + * Relative position of Xi, H and pre-computed Htable is used in some + * assembler modules, i.e. don't change the order! + */ +#if TABLE_BITS==8 + u128 Htable[256]; +#else + u128 Htable[16]; + void (*gmult) (u64 Xi[2], const u128 Htable[16]); + void (*ghash) (u64 Xi[2], const u128 Htable[16], const u8 *inp, + size_t len); +#endif + unsigned int mres, ares; + block128_f block; + void *key; +#if !defined(OPENSSL_SMALL_FOOTPRINT) + unsigned char Xn[48]; +#endif +}; + +struct xts128_context { + void *key1, *key2; + block128_f block1, block2; +}; + +struct ccm128_context { + union { + u64 u[2]; + u8 c[16]; + } nonce, cmac; + u64 blocks; + block128_f block; + void *key; +}; + +#ifndef OPENSSL_NO_OCB + +typedef union { + u64 a[2]; + unsigned char c[16]; +} OCB_BLOCK; +# define ocb_block16_xor(in1,in2,out) \ + ( (out)->a[0]=(in1)->a[0]^(in2)->a[0], \ + (out)->a[1]=(in1)->a[1]^(in2)->a[1] ) +# if STRICT_ALIGNMENT +# define ocb_block16_xor_misaligned(in1,in2,out) \ + ocb_block_xor((in1)->c,(in2)->c,16,(out)->c) +# else +# define ocb_block16_xor_misaligned ocb_block16_xor +# endif + +struct ocb128_context { + /* Need both encrypt and decrypt key schedules for decryption */ + block128_f encrypt; + block128_f decrypt; + void *keyenc; + void *keydec; + ocb128_f stream; /* direction dependent */ + /* Key dependent variables. Can be reused if key remains the same */ + size_t l_index; + size_t max_l_index; + OCB_BLOCK l_star; + OCB_BLOCK l_dollar; + OCB_BLOCK *l; + /* Must be reset for each session */ + struct { + u64 blocks_hashed; + u64 blocks_processed; + OCB_BLOCK offset_aad; + OCB_BLOCK sum; + OCB_BLOCK offset; + OCB_BLOCK checksum; + } sess; +}; +#endif /* OPENSSL_NO_OCB */ diff --git a/contrib/libs/openssl/crypto/modes/ocb128.c b/contrib/libs/openssl/crypto/modes/ocb128.c index 07286239ec..b39a55a1a1 100644 --- a/contrib/libs/openssl/crypto/modes/ocb128.c +++ b/contrib/libs/openssl/crypto/modes/ocb128.c @@ -10,7 +10,7 @@ #include <string.h> #include <openssl/crypto.h> #include <openssl/err.h> -#include "modes_local.h" +#include "modes_local.h" #ifndef OPENSSL_NO_OCB diff --git a/contrib/libs/openssl/crypto/modes/ofb128.c b/contrib/libs/openssl/crypto/modes/ofb128.c index c3cccb9dd2..a3469712b2 100644 --- a/contrib/libs/openssl/crypto/modes/ofb128.c +++ b/contrib/libs/openssl/crypto/modes/ofb128.c @@ -8,7 +8,7 @@ */ #include <openssl/crypto.h> -#include "modes_local.h" +#include "modes_local.h" #include <string.h> #if defined(__GNUC__) && !defined(STRICT_ALIGNMENT) diff --git a/contrib/libs/openssl/crypto/modes/xts128.c b/contrib/libs/openssl/crypto/modes/xts128.c index 8560449f9e..fe1626c62e 100644 --- a/contrib/libs/openssl/crypto/modes/xts128.c +++ b/contrib/libs/openssl/crypto/modes/xts128.c @@ -8,7 +8,7 @@ */ #include <openssl/crypto.h> -#include "modes_local.h" +#include "modes_local.h" #include <string.h> #ifndef STRICT_ALIGNMENT diff --git a/contrib/libs/openssl/crypto/objects/o_names.c b/contrib/libs/openssl/crypto/objects/o_names.c index ede7454cd5..979d83577c 100644 --- a/contrib/libs/openssl/crypto/objects/o_names.c +++ b/contrib/libs/openssl/crypto/objects/o_names.c @@ -17,8 +17,8 @@ #include <openssl/safestack.h> #include <openssl/e_os2.h> #include "internal/thread_once.h" -#include "crypto/lhash.h" -#include "obj_local.h" +#include "crypto/lhash.h" +#include "obj_local.h" #include "e_os.h" /* diff --git a/contrib/libs/openssl/crypto/objects/obj_dat.c b/contrib/libs/openssl/crypto/objects/obj_dat.c index 7a2ee127f2..46006fe6cf 100644 --- a/contrib/libs/openssl/crypto/objects/obj_dat.c +++ b/contrib/libs/openssl/crypto/objects/obj_dat.c @@ -8,15 +8,15 @@ */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include <limits.h> #include "internal/cryptlib.h" #include <openssl/lhash.h> #include <openssl/asn1.h> -#include "crypto/objects.h" +#include "crypto/objects.h" #include <openssl/bn.h> -#include "crypto/asn1.h" -#include "obj_local.h" +#include "crypto/asn1.h" +#include "obj_local.h" /* obj_dat.h is generated from objects.h by obj_dat.pl */ #include "obj_dat.h" diff --git a/contrib/libs/openssl/crypto/objects/obj_dat.h b/contrib/libs/openssl/crypto/objects/obj_dat.h index 6eb3a2661c..24b49a2df2 100644 --- a/contrib/libs/openssl/crypto/objects/obj_dat.h +++ b/contrib/libs/openssl/crypto/objects/obj_dat.h @@ -1728,8 +1728,8 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = { {"ITU-T", "itu-t", NID_itu_t}, {"JOINT-ISO-ITU-T", "joint-iso-itu-t", NID_joint_iso_itu_t}, {"international-organizations", "International Organizations", NID_international_organizations, 1, &so[4439]}, - {"msSmartcardLogin", "Microsoft Smartcard Login", NID_ms_smartcard_login, 10, &so[4440]}, - {"msUPN", "Microsoft User Principal Name", NID_ms_upn, 10, &so[4450]}, + {"msSmartcardLogin", "Microsoft Smartcard Login", NID_ms_smartcard_login, 10, &so[4440]}, + {"msUPN", "Microsoft User Principal Name", NID_ms_upn, 10, &so[4450]}, {"AES-128-CFB1", "aes-128-cfb1", NID_aes_128_cfb1}, {"AES-192-CFB1", "aes-192-cfb1", NID_aes_192_cfb1}, {"AES-256-CFB1", "aes-256-cfb1", NID_aes_256_cfb1}, @@ -3578,9 +3578,9 @@ static const unsigned int ln_objs[NUM_LN] = { 134, /* "Microsoft Individual Code Signing" */ 856, /* "Microsoft Local Key set" */ 137, /* "Microsoft Server Gated Crypto" */ - 648, /* "Microsoft Smartcard Login" */ + 648, /* "Microsoft Smartcard Login" */ 136, /* "Microsoft Trust List Signing" */ - 649, /* "Microsoft User Principal Name" */ + 649, /* "Microsoft User Principal Name" */ 393, /* "NULL" */ 404, /* "NULL" */ 72, /* "Netscape Base Url" */ diff --git a/contrib/libs/openssl/crypto/objects/obj_lib.c b/contrib/libs/openssl/crypto/objects/obj_lib.c index ec95a1db36..456a1598ce 100644 --- a/contrib/libs/openssl/crypto/objects/obj_lib.c +++ b/contrib/libs/openssl/crypto/objects/obj_lib.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include <openssl/objects.h> #include <openssl/buffer.h> -#include "crypto/asn1.h" +#include "crypto/asn1.h" ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o) { diff --git a/contrib/libs/openssl/crypto/objects/obj_local.h b/contrib/libs/openssl/crypto/objects/obj_local.h index a3e0252efb..a417f7c46e 100644 --- a/contrib/libs/openssl/crypto/objects/obj_local.h +++ b/contrib/libs/openssl/crypto/objects/obj_local.h @@ -1,14 +1,14 @@ -/* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -typedef struct name_funcs_st NAME_FUNCS; -DEFINE_STACK_OF(NAME_FUNCS) -DEFINE_LHASH_OF(OBJ_NAME); -typedef struct added_obj_st ADDED_OBJ; -DEFINE_LHASH_OF(ADDED_OBJ); +/* + * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +typedef struct name_funcs_st NAME_FUNCS; +DEFINE_STACK_OF(NAME_FUNCS) +DEFINE_LHASH_OF(OBJ_NAME); +typedef struct added_obj_st ADDED_OBJ; +DEFINE_LHASH_OF(ADDED_OBJ); diff --git a/contrib/libs/openssl/crypto/ocsp/ocsp_asn.c b/contrib/libs/openssl/crypto/ocsp/ocsp_asn.c index adc7b7ca8e..a869e32bc8 100644 --- a/contrib/libs/openssl/crypto/ocsp/ocsp_asn.c +++ b/contrib/libs/openssl/crypto/ocsp/ocsp_asn.c @@ -10,7 +10,7 @@ #include <openssl/asn1.h> #include <openssl/asn1t.h> #include <openssl/ocsp.h> -#include "ocsp_local.h" +#include "ocsp_local.h" ASN1_SEQUENCE(OCSP_SIGNATURE) = { ASN1_EMBED(OCSP_SIGNATURE, signatureAlgorithm, X509_ALGOR), diff --git a/contrib/libs/openssl/crypto/ocsp/ocsp_cl.c b/contrib/libs/openssl/crypto/ocsp/ocsp_cl.c index e23c2bc4d3..55ffd45c6e 100644 --- a/contrib/libs/openssl/crypto/ocsp/ocsp_cl.c +++ b/contrib/libs/openssl/crypto/ocsp/ocsp_cl.c @@ -16,7 +16,7 @@ #include <openssl/pem.h> #include <openssl/x509v3.h> #include <openssl/ocsp.h> -#include "ocsp_local.h" +#include "ocsp_local.h" /* * Utility functions related to sending OCSP requests and extracting relevant diff --git a/contrib/libs/openssl/crypto/ocsp/ocsp_ext.c b/contrib/libs/openssl/crypto/ocsp/ocsp_ext.c index 14e0219427..f6c387ffb7 100644 --- a/contrib/libs/openssl/crypto/ocsp/ocsp_ext.c +++ b/contrib/libs/openssl/crypto/ocsp/ocsp_ext.c @@ -12,7 +12,7 @@ #include <openssl/objects.h> #include <openssl/x509.h> #include <openssl/ocsp.h> -#include "ocsp_local.h" +#include "ocsp_local.h" #include <openssl/rand.h> #include <openssl/x509v3.h> diff --git a/contrib/libs/openssl/crypto/ocsp/ocsp_ht.c b/contrib/libs/openssl/crypto/ocsp/ocsp_ht.c index 0a6de04b53..ba408bc86f 100644 --- a/contrib/libs/openssl/crypto/ocsp/ocsp_ht.c +++ b/contrib/libs/openssl/crypto/ocsp/ocsp_ht.c @@ -10,7 +10,7 @@ #include "e_os.h" #include <stdio.h> #include <stdlib.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include <string.h> #include <openssl/asn1.h> #include <openssl/ocsp.h> diff --git a/contrib/libs/openssl/crypto/ocsp/ocsp_lib.c b/contrib/libs/openssl/crypto/ocsp/ocsp_lib.c index aada03b421..37ac6c03fd 100644 --- a/contrib/libs/openssl/crypto/ocsp/ocsp_lib.c +++ b/contrib/libs/openssl/crypto/ocsp/ocsp_lib.c @@ -14,7 +14,7 @@ #include <openssl/pem.h> #include <openssl/x509v3.h> #include <openssl/ocsp.h> -#include "ocsp_local.h" +#include "ocsp_local.h" #include <openssl/asn1t.h> /* Convert a certificate and its issuer to an OCSP_CERTID */ diff --git a/contrib/libs/openssl/crypto/ocsp/ocsp_local.h b/contrib/libs/openssl/crypto/ocsp/ocsp_local.h index ea185f7360..36646fdfc9 100644 --- a/contrib/libs/openssl/crypto/ocsp/ocsp_local.h +++ b/contrib/libs/openssl/crypto/ocsp/ocsp_local.h @@ -1,236 +1,236 @@ -/* - * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/*- CertID ::= SEQUENCE { - * hashAlgorithm AlgorithmIdentifier, - * issuerNameHash OCTET STRING, -- Hash of Issuer's DN - * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields) - * serialNumber CertificateSerialNumber } - */ -struct ocsp_cert_id_st { - X509_ALGOR hashAlgorithm; - ASN1_OCTET_STRING issuerNameHash; - ASN1_OCTET_STRING issuerKeyHash; - ASN1_INTEGER serialNumber; -}; - -/*- Request ::= SEQUENCE { - * reqCert CertID, - * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL } - */ -struct ocsp_one_request_st { - OCSP_CERTID *reqCert; - STACK_OF(X509_EXTENSION) *singleRequestExtensions; -}; - -/*- TBSRequest ::= SEQUENCE { - * version [0] EXPLICIT Version DEFAULT v1, - * requestorName [1] EXPLICIT GeneralName OPTIONAL, - * requestList SEQUENCE OF Request, - * requestExtensions [2] EXPLICIT Extensions OPTIONAL } - */ -struct ocsp_req_info_st { - ASN1_INTEGER *version; - GENERAL_NAME *requestorName; - STACK_OF(OCSP_ONEREQ) *requestList; - STACK_OF(X509_EXTENSION) *requestExtensions; -}; - -/*- Signature ::= SEQUENCE { - * signatureAlgorithm AlgorithmIdentifier, - * signature BIT STRING, - * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } - */ -struct ocsp_signature_st { - X509_ALGOR signatureAlgorithm; - ASN1_BIT_STRING *signature; - STACK_OF(X509) *certs; -}; - -/*- OCSPRequest ::= SEQUENCE { - * tbsRequest TBSRequest, - * optionalSignature [0] EXPLICIT Signature OPTIONAL } - */ -struct ocsp_request_st { - OCSP_REQINFO tbsRequest; - OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */ -}; - -/*- OCSPResponseStatus ::= ENUMERATED { - * successful (0), --Response has valid confirmations - * malformedRequest (1), --Illegal confirmation request - * internalError (2), --Internal error in issuer - * tryLater (3), --Try again later - * --(4) is not used - * sigRequired (5), --Must sign the request - * unauthorized (6) --Request unauthorized - * } - */ - -/*- ResponseBytes ::= SEQUENCE { - * responseType OBJECT IDENTIFIER, - * response OCTET STRING } - */ -struct ocsp_resp_bytes_st { - ASN1_OBJECT *responseType; - ASN1_OCTET_STRING *response; -}; - -/*- OCSPResponse ::= SEQUENCE { - * responseStatus OCSPResponseStatus, - * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL } - */ -struct ocsp_response_st { - ASN1_ENUMERATED *responseStatus; - OCSP_RESPBYTES *responseBytes; -}; - -/*- ResponderID ::= CHOICE { - * byName [1] Name, - * byKey [2] KeyHash } - */ -struct ocsp_responder_id_st { - int type; - union { - X509_NAME *byName; - ASN1_OCTET_STRING *byKey; - } value; -}; - -/*- KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key - * --(excluding the tag and length fields) - */ - -/*- RevokedInfo ::= SEQUENCE { - * revocationTime GeneralizedTime, - * revocationReason [0] EXPLICIT CRLReason OPTIONAL } - */ -struct ocsp_revoked_info_st { - ASN1_GENERALIZEDTIME *revocationTime; - ASN1_ENUMERATED *revocationReason; -}; - -/*- CertStatus ::= CHOICE { - * good [0] IMPLICIT NULL, - * revoked [1] IMPLICIT RevokedInfo, - * unknown [2] IMPLICIT UnknownInfo } - */ -struct ocsp_cert_status_st { - int type; - union { - ASN1_NULL *good; - OCSP_REVOKEDINFO *revoked; - ASN1_NULL *unknown; - } value; -}; - -/*- SingleResponse ::= SEQUENCE { - * certID CertID, - * certStatus CertStatus, - * thisUpdate GeneralizedTime, - * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, - * singleExtensions [1] EXPLICIT Extensions OPTIONAL } - */ -struct ocsp_single_response_st { - OCSP_CERTID *certId; - OCSP_CERTSTATUS *certStatus; - ASN1_GENERALIZEDTIME *thisUpdate; - ASN1_GENERALIZEDTIME *nextUpdate; - STACK_OF(X509_EXTENSION) *singleExtensions; -}; - -/*- ResponseData ::= SEQUENCE { - * version [0] EXPLICIT Version DEFAULT v1, - * responderID ResponderID, - * producedAt GeneralizedTime, - * responses SEQUENCE OF SingleResponse, - * responseExtensions [1] EXPLICIT Extensions OPTIONAL } - */ -struct ocsp_response_data_st { - ASN1_INTEGER *version; - OCSP_RESPID responderId; - ASN1_GENERALIZEDTIME *producedAt; - STACK_OF(OCSP_SINGLERESP) *responses; - STACK_OF(X509_EXTENSION) *responseExtensions; -}; - -/*- BasicOCSPResponse ::= SEQUENCE { - * tbsResponseData ResponseData, - * signatureAlgorithm AlgorithmIdentifier, - * signature BIT STRING, - * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } - */ - /* - * Note 1: The value for "signature" is specified in the OCSP rfc2560 as - * follows: "The value for the signature SHALL be computed on the hash of - * the DER encoding ResponseData." This means that you must hash the - * DER-encoded tbsResponseData, and then run it through a crypto-signing - * function, which will (at least w/RSA) do a hash-'n'-private-encrypt - * operation. This seems a bit odd, but that's the spec. Also note that - * the data structures do not leave anywhere to independently specify the - * algorithm used for the initial hash. So, we look at the - * signature-specification algorithm, and try to do something intelligent. - * -- Kathy Weinhold, CertCo - */ - /* - * Note 2: It seems that the mentioned passage from RFC 2560 (section - * 4.2.1) is open for interpretation. I've done tests against another - * responder, and found that it doesn't do the double hashing that the RFC - * seems to say one should. Therefore, all relevant functions take a flag - * saying which variant should be used. -- Richard Levitte, OpenSSL team - * and CeloCom - */ -struct ocsp_basic_response_st { - OCSP_RESPDATA tbsResponseData; - X509_ALGOR signatureAlgorithm; - ASN1_BIT_STRING *signature; - STACK_OF(X509) *certs; -}; - -/*- - * CrlID ::= SEQUENCE { - * crlUrl [0] EXPLICIT IA5String OPTIONAL, - * crlNum [1] EXPLICIT INTEGER OPTIONAL, - * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL } - */ -struct ocsp_crl_id_st { - ASN1_IA5STRING *crlUrl; - ASN1_INTEGER *crlNum; - ASN1_GENERALIZEDTIME *crlTime; -}; - -/*- - * ServiceLocator ::= SEQUENCE { - * issuer Name, - * locator AuthorityInfoAccessSyntax OPTIONAL } - */ -struct ocsp_service_locator_st { - X509_NAME *issuer; - STACK_OF(ACCESS_DESCRIPTION) *locator; -}; - -# define OCSP_REQUEST_sign(o,pkey,md) \ - ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\ - &(o)->optionalSignature->signatureAlgorithm,NULL,\ - (o)->optionalSignature->signature,&(o)->tbsRequest,pkey,md) - -# define OCSP_BASICRESP_sign(o,pkey,md,d) \ - ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),&(o)->signatureAlgorithm,\ - NULL,(o)->signature,&(o)->tbsResponseData,pkey,md) - -# define OCSP_BASICRESP_sign_ctx(o,ctx,d) \ - ASN1_item_sign_ctx(ASN1_ITEM_rptr(OCSP_RESPDATA),&(o)->signatureAlgorithm,\ - NULL,(o)->signature,&(o)->tbsResponseData,ctx) - -# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\ - &(a)->optionalSignature->signatureAlgorithm,\ - (a)->optionalSignature->signature,&(a)->tbsRequest,r) - -# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\ - &(a)->signatureAlgorithm,(a)->signature,&(a)->tbsResponseData,r) +/* + * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/*- CertID ::= SEQUENCE { + * hashAlgorithm AlgorithmIdentifier, + * issuerNameHash OCTET STRING, -- Hash of Issuer's DN + * issuerKeyHash OCTET STRING, -- Hash of Issuers public key (excluding the tag & length fields) + * serialNumber CertificateSerialNumber } + */ +struct ocsp_cert_id_st { + X509_ALGOR hashAlgorithm; + ASN1_OCTET_STRING issuerNameHash; + ASN1_OCTET_STRING issuerKeyHash; + ASN1_INTEGER serialNumber; +}; + +/*- Request ::= SEQUENCE { + * reqCert CertID, + * singleRequestExtensions [0] EXPLICIT Extensions OPTIONAL } + */ +struct ocsp_one_request_st { + OCSP_CERTID *reqCert; + STACK_OF(X509_EXTENSION) *singleRequestExtensions; +}; + +/*- TBSRequest ::= SEQUENCE { + * version [0] EXPLICIT Version DEFAULT v1, + * requestorName [1] EXPLICIT GeneralName OPTIONAL, + * requestList SEQUENCE OF Request, + * requestExtensions [2] EXPLICIT Extensions OPTIONAL } + */ +struct ocsp_req_info_st { + ASN1_INTEGER *version; + GENERAL_NAME *requestorName; + STACK_OF(OCSP_ONEREQ) *requestList; + STACK_OF(X509_EXTENSION) *requestExtensions; +}; + +/*- Signature ::= SEQUENCE { + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING, + * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + */ +struct ocsp_signature_st { + X509_ALGOR signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; +}; + +/*- OCSPRequest ::= SEQUENCE { + * tbsRequest TBSRequest, + * optionalSignature [0] EXPLICIT Signature OPTIONAL } + */ +struct ocsp_request_st { + OCSP_REQINFO tbsRequest; + OCSP_SIGNATURE *optionalSignature; /* OPTIONAL */ +}; + +/*- OCSPResponseStatus ::= ENUMERATED { + * successful (0), --Response has valid confirmations + * malformedRequest (1), --Illegal confirmation request + * internalError (2), --Internal error in issuer + * tryLater (3), --Try again later + * --(4) is not used + * sigRequired (5), --Must sign the request + * unauthorized (6) --Request unauthorized + * } + */ + +/*- ResponseBytes ::= SEQUENCE { + * responseType OBJECT IDENTIFIER, + * response OCTET STRING } + */ +struct ocsp_resp_bytes_st { + ASN1_OBJECT *responseType; + ASN1_OCTET_STRING *response; +}; + +/*- OCSPResponse ::= SEQUENCE { + * responseStatus OCSPResponseStatus, + * responseBytes [0] EXPLICIT ResponseBytes OPTIONAL } + */ +struct ocsp_response_st { + ASN1_ENUMERATED *responseStatus; + OCSP_RESPBYTES *responseBytes; +}; + +/*- ResponderID ::= CHOICE { + * byName [1] Name, + * byKey [2] KeyHash } + */ +struct ocsp_responder_id_st { + int type; + union { + X509_NAME *byName; + ASN1_OCTET_STRING *byKey; + } value; +}; + +/*- KeyHash ::= OCTET STRING --SHA-1 hash of responder's public key + * --(excluding the tag and length fields) + */ + +/*- RevokedInfo ::= SEQUENCE { + * revocationTime GeneralizedTime, + * revocationReason [0] EXPLICIT CRLReason OPTIONAL } + */ +struct ocsp_revoked_info_st { + ASN1_GENERALIZEDTIME *revocationTime; + ASN1_ENUMERATED *revocationReason; +}; + +/*- CertStatus ::= CHOICE { + * good [0] IMPLICIT NULL, + * revoked [1] IMPLICIT RevokedInfo, + * unknown [2] IMPLICIT UnknownInfo } + */ +struct ocsp_cert_status_st { + int type; + union { + ASN1_NULL *good; + OCSP_REVOKEDINFO *revoked; + ASN1_NULL *unknown; + } value; +}; + +/*- SingleResponse ::= SEQUENCE { + * certID CertID, + * certStatus CertStatus, + * thisUpdate GeneralizedTime, + * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, + * singleExtensions [1] EXPLICIT Extensions OPTIONAL } + */ +struct ocsp_single_response_st { + OCSP_CERTID *certId; + OCSP_CERTSTATUS *certStatus; + ASN1_GENERALIZEDTIME *thisUpdate; + ASN1_GENERALIZEDTIME *nextUpdate; + STACK_OF(X509_EXTENSION) *singleExtensions; +}; + +/*- ResponseData ::= SEQUENCE { + * version [0] EXPLICIT Version DEFAULT v1, + * responderID ResponderID, + * producedAt GeneralizedTime, + * responses SEQUENCE OF SingleResponse, + * responseExtensions [1] EXPLICIT Extensions OPTIONAL } + */ +struct ocsp_response_data_st { + ASN1_INTEGER *version; + OCSP_RESPID responderId; + ASN1_GENERALIZEDTIME *producedAt; + STACK_OF(OCSP_SINGLERESP) *responses; + STACK_OF(X509_EXTENSION) *responseExtensions; +}; + +/*- BasicOCSPResponse ::= SEQUENCE { + * tbsResponseData ResponseData, + * signatureAlgorithm AlgorithmIdentifier, + * signature BIT STRING, + * certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL } + */ + /* + * Note 1: The value for "signature" is specified in the OCSP rfc2560 as + * follows: "The value for the signature SHALL be computed on the hash of + * the DER encoding ResponseData." This means that you must hash the + * DER-encoded tbsResponseData, and then run it through a crypto-signing + * function, which will (at least w/RSA) do a hash-'n'-private-encrypt + * operation. This seems a bit odd, but that's the spec. Also note that + * the data structures do not leave anywhere to independently specify the + * algorithm used for the initial hash. So, we look at the + * signature-specification algorithm, and try to do something intelligent. + * -- Kathy Weinhold, CertCo + */ + /* + * Note 2: It seems that the mentioned passage from RFC 2560 (section + * 4.2.1) is open for interpretation. I've done tests against another + * responder, and found that it doesn't do the double hashing that the RFC + * seems to say one should. Therefore, all relevant functions take a flag + * saying which variant should be used. -- Richard Levitte, OpenSSL team + * and CeloCom + */ +struct ocsp_basic_response_st { + OCSP_RESPDATA tbsResponseData; + X509_ALGOR signatureAlgorithm; + ASN1_BIT_STRING *signature; + STACK_OF(X509) *certs; +}; + +/*- + * CrlID ::= SEQUENCE { + * crlUrl [0] EXPLICIT IA5String OPTIONAL, + * crlNum [1] EXPLICIT INTEGER OPTIONAL, + * crlTime [2] EXPLICIT GeneralizedTime OPTIONAL } + */ +struct ocsp_crl_id_st { + ASN1_IA5STRING *crlUrl; + ASN1_INTEGER *crlNum; + ASN1_GENERALIZEDTIME *crlTime; +}; + +/*- + * ServiceLocator ::= SEQUENCE { + * issuer Name, + * locator AuthorityInfoAccessSyntax OPTIONAL } + */ +struct ocsp_service_locator_st { + X509_NAME *issuer; + STACK_OF(ACCESS_DESCRIPTION) *locator; +}; + +# define OCSP_REQUEST_sign(o,pkey,md) \ + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\ + &(o)->optionalSignature->signatureAlgorithm,NULL,\ + (o)->optionalSignature->signature,&(o)->tbsRequest,pkey,md) + +# define OCSP_BASICRESP_sign(o,pkey,md,d) \ + ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),&(o)->signatureAlgorithm,\ + NULL,(o)->signature,&(o)->tbsResponseData,pkey,md) + +# define OCSP_BASICRESP_sign_ctx(o,ctx,d) \ + ASN1_item_sign_ctx(ASN1_ITEM_rptr(OCSP_RESPDATA),&(o)->signatureAlgorithm,\ + NULL,(o)->signature,&(o)->tbsResponseData,ctx) + +# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\ + &(a)->optionalSignature->signatureAlgorithm,\ + (a)->optionalSignature->signature,&(a)->tbsRequest,r) + +# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\ + &(a)->signatureAlgorithm,(a)->signature,&(a)->tbsResponseData,r) diff --git a/contrib/libs/openssl/crypto/ocsp/ocsp_prn.c b/contrib/libs/openssl/crypto/ocsp/ocsp_prn.c index c4f952f2af..1965f2a183 100644 --- a/contrib/libs/openssl/crypto/ocsp/ocsp_prn.c +++ b/contrib/libs/openssl/crypto/ocsp/ocsp_prn.c @@ -10,7 +10,7 @@ #include <openssl/bio.h> #include <openssl/err.h> #include <openssl/ocsp.h> -#include "ocsp_local.h" +#include "ocsp_local.h" #include "internal/cryptlib.h" #include <openssl/pem.h> diff --git a/contrib/libs/openssl/crypto/ocsp/ocsp_srv.c b/contrib/libs/openssl/crypto/ocsp/ocsp_srv.c index a50b276154..e35fc52fd9 100644 --- a/contrib/libs/openssl/crypto/ocsp/ocsp_srv.c +++ b/contrib/libs/openssl/crypto/ocsp/ocsp_srv.c @@ -14,7 +14,7 @@ #include <openssl/pem.h> #include <openssl/x509v3.h> #include <openssl/ocsp.h> -#include "ocsp_local.h" +#include "ocsp_local.h" /* * Utility functions related to sending OCSP responses and extracting diff --git a/contrib/libs/openssl/crypto/ocsp/ocsp_vfy.c b/contrib/libs/openssl/crypto/ocsp/ocsp_vfy.c index dacab13144..e87b71c0c7 100644 --- a/contrib/libs/openssl/crypto/ocsp/ocsp_vfy.c +++ b/contrib/libs/openssl/crypto/ocsp/ocsp_vfy.c @@ -8,7 +8,7 @@ */ #include <openssl/ocsp.h> -#include "ocsp_local.h" +#include "ocsp_local.h" #include <openssl/err.h> #include <string.h> diff --git a/contrib/libs/openssl/crypto/ocsp/v3_ocsp.c b/contrib/libs/openssl/crypto/ocsp/v3_ocsp.c index 18b18ce7ec..a174ce15a6 100644 --- a/contrib/libs/openssl/crypto/ocsp/v3_ocsp.c +++ b/contrib/libs/openssl/crypto/ocsp/v3_ocsp.c @@ -12,7 +12,7 @@ # include <openssl/conf.h> # include <openssl/asn1.h> # include <openssl/ocsp.h> -# include "ocsp_local.h" +# include "ocsp_local.h" # include <openssl/x509v3.h> # include "../x509v3/ext_dat.h" diff --git a/contrib/libs/openssl/crypto/pem/pem_all.c b/contrib/libs/openssl/crypto/pem/pem_all.c index 9dd3966af4..9d57ee7cc2 100644 --- a/contrib/libs/openssl/crypto/pem/pem_all.c +++ b/contrib/libs/openssl/crypto/pem/pem_all.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -84,8 +84,8 @@ IMPLEMENT_PEM_write_cb_const(RSAPrivateKey, RSA, PEM_STRING_RSA, IMPLEMENT_PEM_rw_const(RSAPublicKey, RSA, PEM_STRING_RSA_PUBLIC, - RSAPublicKey) -IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY) + RSAPublicKey) +IMPLEMENT_PEM_rw(RSA_PUBKEY, RSA, PEM_STRING_PUBLIC, RSA_PUBKEY) #endif #ifndef OPENSSL_NO_DSA static DSA *pkey_get_dsa(EVP_PKEY *key, DSA **dsa) @@ -114,7 +114,7 @@ DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **dsa, pem_password_cb *cb, IMPLEMENT_PEM_write_cb_const(DSAPrivateKey, DSA, PEM_STRING_DSA, DSAPrivateKey) -IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) +IMPLEMENT_PEM_rw(DSA_PUBKEY, DSA, PEM_STRING_PUBLIC, DSA_PUBKEY) # ifndef OPENSSL_NO_STDIO DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **dsa, pem_password_cb *cb, void *u) { @@ -175,6 +175,6 @@ EC_KEY *PEM_read_ECPrivateKey(FILE *fp, EC_KEY **eckey, pem_password_cb *cb, #ifndef OPENSSL_NO_DH IMPLEMENT_PEM_write_const(DHparams, DH, PEM_STRING_DHPARAMS, DHparams) -IMPLEMENT_PEM_write_const(DHxparams, DH, PEM_STRING_DHXPARAMS, DHxparams) +IMPLEMENT_PEM_write_const(DHxparams, DH, PEM_STRING_DHXPARAMS, DHxparams) #endif IMPLEMENT_PEM_rw(PUBKEY, EVP_PKEY, PEM_STRING_PUBLIC, PUBKEY) diff --git a/contrib/libs/openssl/crypto/pem/pem_lib.c b/contrib/libs/openssl/crypto/pem/pem_lib.c index 92aacbe034..a26322119a 100644 --- a/contrib/libs/openssl/crypto/pem/pem_lib.c +++ b/contrib/libs/openssl/crypto/pem/pem_lib.c @@ -8,7 +8,7 @@ */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include <string.h> #include "internal/cryptlib.h" #include <openssl/buffer.h> @@ -18,7 +18,7 @@ #include <openssl/x509.h> #include <openssl/pem.h> #include <openssl/pkcs12.h> -#include "crypto/asn1.h" +#include "crypto/asn1.h" #include <openssl/des.h> #include <openssl/engine.h> diff --git a/contrib/libs/openssl/crypto/pem/pem_pkey.c b/contrib/libs/openssl/crypto/pem/pem_pkey.c index f5617936b9..4a94927244 100644 --- a/contrib/libs/openssl/crypto/pem/pem_pkey.c +++ b/contrib/libs/openssl/crypto/pem/pem_pkey.c @@ -17,8 +17,8 @@ #include <openssl/pem.h> #include <openssl/engine.h> #include <openssl/dh.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" int pem_check_suffix(const char *pem_str, const char *suffix); diff --git a/contrib/libs/openssl/crypto/pem/pvkfmt.c b/contrib/libs/openssl/crypto/pem/pvkfmt.c index 8ac41791d3..a933b7c181 100644 --- a/contrib/libs/openssl/crypto/pem/pvkfmt.c +++ b/contrib/libs/openssl/crypto/pem/pvkfmt.c @@ -844,9 +844,9 @@ static int i2b_PVK(unsigned char **out, EVP_PKEY *pk, int enclevel, if (!EVP_EncryptInit_ex(cctx, EVP_rc4(), NULL, keybuf, NULL)) goto error; OPENSSL_cleanse(keybuf, 20); - if (!EVP_EncryptUpdate(cctx, p, &enctmplen, p, pklen - 8)) + if (!EVP_EncryptUpdate(cctx, p, &enctmplen, p, pklen - 8)) goto error; - if (!EVP_EncryptFinal_ex(cctx, p + enctmplen, &enctmplen)) + if (!EVP_EncryptFinal_ex(cctx, p + enctmplen, &enctmplen)) goto error; } diff --git a/contrib/libs/openssl/crypto/pkcs12/p12_add.c b/contrib/libs/openssl/crypto/pkcs12/p12_add.c index 2586e45c0e..af184c86af 100644 --- a/contrib/libs/openssl/crypto/pkcs12/p12_add.c +++ b/contrib/libs/openssl/crypto/pkcs12/p12_add.c @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/pkcs12.h> -#include "p12_local.h" +#include "p12_local.h" /* Pack an object into an OCTET STRING and turn into a safebag */ diff --git a/contrib/libs/openssl/crypto/pkcs12/p12_asn.c b/contrib/libs/openssl/crypto/pkcs12/p12_asn.c index b3c42d03c9..88f145890c 100644 --- a/contrib/libs/openssl/crypto/pkcs12/p12_asn.c +++ b/contrib/libs/openssl/crypto/pkcs12/p12_asn.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include <openssl/asn1t.h> #include <openssl/pkcs12.h> -#include "p12_local.h" +#include "p12_local.h" /* PKCS#12 ASN1 module */ diff --git a/contrib/libs/openssl/crypto/pkcs12/p12_attr.c b/contrib/libs/openssl/crypto/pkcs12/p12_attr.c index 7551f7f742..a958fdf346 100644 --- a/contrib/libs/openssl/crypto/pkcs12/p12_attr.c +++ b/contrib/libs/openssl/crypto/pkcs12/p12_attr.c @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/pkcs12.h> -#include "p12_local.h" +#include "p12_local.h" /* Add a local keyid to a safebag */ diff --git a/contrib/libs/openssl/crypto/pkcs12/p12_crt.c b/contrib/libs/openssl/crypto/pkcs12/p12_crt.c index 883f140424..bfcae3f697 100644 --- a/contrib/libs/openssl/crypto/pkcs12/p12_crt.c +++ b/contrib/libs/openssl/crypto/pkcs12/p12_crt.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/pkcs12.h> -#include "p12_local.h" +#include "p12_local.h" static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags, PKCS12_SAFEBAG *bag); @@ -62,8 +62,8 @@ PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 * if (pkey && cert) { if (!X509_check_private_key(cert, pkey)) return NULL; - if (!X509_digest(cert, EVP_sha1(), keyid, &keyidlen)) - return NULL; + if (!X509_digest(cert, EVP_sha1(), keyid, &keyidlen)) + return NULL; } if (cert) { diff --git a/contrib/libs/openssl/crypto/pkcs12/p12_init.c b/contrib/libs/openssl/crypto/pkcs12/p12_init.c index 9d0a76ac66..7ecc29ec0c 100644 --- a/contrib/libs/openssl/crypto/pkcs12/p12_init.c +++ b/contrib/libs/openssl/crypto/pkcs12/p12_init.c @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/pkcs12.h> -#include "p12_local.h" +#include "p12_local.h" /* Initialise a PKCS12 structure to take data */ diff --git a/contrib/libs/openssl/crypto/pkcs12/p12_local.h b/contrib/libs/openssl/crypto/pkcs12/p12_local.h index 19240d70eb..0b52f1e1fe 100644 --- a/contrib/libs/openssl/crypto/pkcs12/p12_local.h +++ b/contrib/libs/openssl/crypto/pkcs12/p12_local.h @@ -1,43 +1,43 @@ -/* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -struct PKCS12_MAC_DATA_st { - X509_SIG *dinfo; - ASN1_OCTET_STRING *salt; - ASN1_INTEGER *iter; /* defaults to 1 */ -}; - -struct PKCS12_st { - ASN1_INTEGER *version; - PKCS12_MAC_DATA *mac; - PKCS7 *authsafes; -}; - -struct PKCS12_SAFEBAG_st { - ASN1_OBJECT *type; - union { - struct pkcs12_bag_st *bag; /* secret, crl and certbag */ - struct pkcs8_priv_key_info_st *keybag; /* keybag */ - X509_SIG *shkeybag; /* shrouded key bag */ - STACK_OF(PKCS12_SAFEBAG) *safes; - ASN1_TYPE *other; - } value; - STACK_OF(X509_ATTRIBUTE) *attrib; -}; - -struct pkcs12_bag_st { - ASN1_OBJECT *type; - union { - ASN1_OCTET_STRING *x509cert; - ASN1_OCTET_STRING *x509crl; - ASN1_OCTET_STRING *octet; - ASN1_IA5STRING *sdsicert; - ASN1_TYPE *other; /* Secret or other bag */ - } value; -}; +/* + * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +struct PKCS12_MAC_DATA_st { + X509_SIG *dinfo; + ASN1_OCTET_STRING *salt; + ASN1_INTEGER *iter; /* defaults to 1 */ +}; + +struct PKCS12_st { + ASN1_INTEGER *version; + PKCS12_MAC_DATA *mac; + PKCS7 *authsafes; +}; + +struct PKCS12_SAFEBAG_st { + ASN1_OBJECT *type; + union { + struct pkcs12_bag_st *bag; /* secret, crl and certbag */ + struct pkcs8_priv_key_info_st *keybag; /* keybag */ + X509_SIG *shkeybag; /* shrouded key bag */ + STACK_OF(PKCS12_SAFEBAG) *safes; + ASN1_TYPE *other; + } value; + STACK_OF(X509_ATTRIBUTE) *attrib; +}; + +struct pkcs12_bag_st { + ASN1_OBJECT *type; + union { + ASN1_OCTET_STRING *x509cert; + ASN1_OCTET_STRING *x509crl; + ASN1_OCTET_STRING *octet; + ASN1_IA5STRING *sdsicert; + ASN1_TYPE *other; /* Secret or other bag */ + } value; +}; diff --git a/contrib/libs/openssl/crypto/pkcs12/p12_mutl.c b/contrib/libs/openssl/crypto/pkcs12/p12_mutl.c index 268f8db218..3658003fe5 100644 --- a/contrib/libs/openssl/crypto/pkcs12/p12_mutl.c +++ b/contrib/libs/openssl/crypto/pkcs12/p12_mutl.c @@ -13,7 +13,7 @@ #include <openssl/hmac.h> #include <openssl/rand.h> #include <openssl/pkcs12.h> -#include "p12_local.h" +#include "p12_local.h" int PKCS12_mac_present(const PKCS12 *p12) { diff --git a/contrib/libs/openssl/crypto/pkcs12/p12_npas.c b/contrib/libs/openssl/crypto/pkcs12/p12_npas.c index 3af6ad3e7f..0334289a89 100644 --- a/contrib/libs/openssl/crypto/pkcs12/p12_npas.c +++ b/contrib/libs/openssl/crypto/pkcs12/p12_npas.c @@ -13,7 +13,7 @@ #include <openssl/pem.h> #include <openssl/err.h> #include <openssl/pkcs12.h> -#include "p12_local.h" +#include "p12_local.h" /* PKCS#12 password change routine */ diff --git a/contrib/libs/openssl/crypto/pkcs12/p12_p8e.c b/contrib/libs/openssl/crypto/pkcs12/p12_p8e.c index 4919a595d9..05fc388a99 100644 --- a/contrib/libs/openssl/crypto/pkcs12/p12_p8e.c +++ b/contrib/libs/openssl/crypto/pkcs12/p12_p8e.c @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/pkcs12.h> -#include "crypto/x509.h" +#include "crypto/x509.h" X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, const char *pass, int passlen, diff --git a/contrib/libs/openssl/crypto/pkcs12/p12_sbag.c b/contrib/libs/openssl/crypto/pkcs12/p12_sbag.c index 1b7b53aef1..7cf522786b 100644 --- a/contrib/libs/openssl/crypto/pkcs12/p12_sbag.c +++ b/contrib/libs/openssl/crypto/pkcs12/p12_sbag.c @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/pkcs12.h> -#include "p12_local.h" +#include "p12_local.h" #if OPENSSL_API_COMPAT < 0x10100000L ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, int attr_nid) diff --git a/contrib/libs/openssl/crypto/pkcs7/pk7_lib.c b/contrib/libs/openssl/crypto/pkcs7/pk7_lib.c index 3ba6ff9f43..ec4d9abd58 100644 --- a/contrib/libs/openssl/crypto/pkcs7/pk7_lib.c +++ b/contrib/libs/openssl/crypto/pkcs7/pk7_lib.c @@ -11,8 +11,8 @@ #include "internal/cryptlib.h" #include <openssl/objects.h> #include <openssl/x509.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg) { diff --git a/contrib/libs/openssl/crypto/poly1305/poly1305.c b/contrib/libs/openssl/crypto/poly1305/poly1305.c index 3194ef0d4a..e7f5b92c8f 100644 --- a/contrib/libs/openssl/crypto/poly1305/poly1305.c +++ b/contrib/libs/openssl/crypto/poly1305/poly1305.c @@ -11,7 +11,7 @@ #include <string.h> #include <openssl/crypto.h> -#include "crypto/poly1305.h" +#include "crypto/poly1305.h" #include "poly1305_local.h" size_t Poly1305_ctx_size(void) @@ -89,7 +89,7 @@ static void poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, u32 padbit); /* - * Type-agnostic "rip-off" from constant_time.h + * Type-agnostic "rip-off" from constant_time.h */ # define CONSTANT_TIME_CARRY(a,b) ( \ (a ^ ((a ^ b) | ((a - b) ^ b))) >> (sizeof(a) * 8 - 1) \ diff --git a/contrib/libs/openssl/crypto/poly1305/poly1305_ameth.c b/contrib/libs/openssl/crypto/poly1305/poly1305_ameth.c index 44c2e03b51..0dddf79626 100644 --- a/contrib/libs/openssl/crypto/poly1305/poly1305_ameth.c +++ b/contrib/libs/openssl/crypto/poly1305/poly1305_ameth.c @@ -10,10 +10,10 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/evp.h> -#include "crypto/asn1.h" -#include "crypto/poly1305.h" +#include "crypto/asn1.h" +#include "crypto/poly1305.h" #include "poly1305_local.h" -#include "crypto/evp.h" +#include "crypto/evp.h" /* * POLY1305 "ASN1" method. This is just here to indicate the maximum diff --git a/contrib/libs/openssl/crypto/poly1305/poly1305_pmeth.c b/contrib/libs/openssl/crypto/poly1305/poly1305_pmeth.c index 3f409eacf8..49a799a12f 100644 --- a/contrib/libs/openssl/crypto/poly1305/poly1305_pmeth.c +++ b/contrib/libs/openssl/crypto/poly1305/poly1305_pmeth.c @@ -13,9 +13,9 @@ #include <openssl/x509v3.h> #include <openssl/evp.h> #include <openssl/err.h> -#include "crypto/poly1305.h" +#include "crypto/poly1305.h" #include "poly1305_local.h" -#include "crypto/evp.h" +#include "crypto/evp.h" /* POLY1305 pkey context structure */ diff --git a/contrib/libs/openssl/crypto/ppc_arch.h b/contrib/libs/openssl/crypto/ppc_arch.h index d4af451e1a..e3845e9394 100644 --- a/contrib/libs/openssl/crypto/ppc_arch.h +++ b/contrib/libs/openssl/crypto/ppc_arch.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_PPC_ARCH_H -# define OSSL_CRYPTO_PPC_ARCH_H +#ifndef OSSL_CRYPTO_PPC_ARCH_H +# define OSSL_CRYPTO_PPC_ARCH_H extern unsigned int OPENSSL_ppccap_P; diff --git a/contrib/libs/openssl/crypto/ppccap.c b/contrib/libs/openssl/crypto/ppccap.c index a94ad356d9..eeaa47cc6b 100644 --- a/contrib/libs/openssl/crypto/ppccap.c +++ b/contrib/libs/openssl/crypto/ppccap.c @@ -29,8 +29,8 @@ #include <openssl/crypto.h> #include <openssl/bn.h> #include <internal/cryptlib.h> -#include <crypto/chacha.h> -#include "bn/bn_local.h" +#include <crypto/chacha.h> +#include "bn/bn_local.h" #include "ppc_arch.h" diff --git a/contrib/libs/openssl/crypto/rand/drbg_ctr.c b/contrib/libs/openssl/crypto/rand/drbg_ctr.c index cadd402a91..c8b3bd79bb 100644 --- a/contrib/libs/openssl/crypto/rand/drbg_ctr.c +++ b/contrib/libs/openssl/crypto/rand/drbg_ctr.c @@ -1,5 +1,5 @@ /* - * Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -12,26 +12,26 @@ #include <openssl/crypto.h> #include <openssl/err.h> #include <openssl/rand.h> -#include "modes_local.h" +#include "modes_local.h" #include "internal/thread_once.h" -#include "rand_local.h" +#include "rand_local.h" #include "sanitizers.h" - + /* * Implementation of NIST SP 800-90A CTR DRBG. */ static void inc_128(RAND_DRBG_CTR *ctr) { - unsigned char *p = &ctr->V[0]; - u32 n = 16, c = 1; - - do { - --n; - c += p[n]; - p[n] = (u8)c; - c >>= 8; - } while (n); + unsigned char *p = &ctr->V[0]; + u32 n = 16, c = 1; + + do { + --n; + c += p[n]; + p[n] = (u8)c; + c >>= 8; + } while (n); } static void ctr_XOR(RAND_DRBG_CTR *ctr, const unsigned char *in, size_t inlen) diff --git a/contrib/libs/openssl/crypto/rand/drbg_lib.c b/contrib/libs/openssl/crypto/rand/drbg_lib.c index 68bb1d12dd..8c7c28c970 100644 --- a/contrib/libs/openssl/crypto/rand/drbg_lib.c +++ b/contrib/libs/openssl/crypto/rand/drbg_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -11,10 +11,10 @@ #include <openssl/crypto.h> #include <openssl/err.h> #include <openssl/rand.h> -#include "rand_local.h" +#include "rand_local.h" #include "internal/thread_once.h" -#include "crypto/rand.h" -#include "crypto/cryptlib.h" +#include "crypto/rand.h" +#include "crypto/cryptlib.h" /* * Support framework for NIST SP 800-90A DRBG @@ -1040,7 +1040,7 @@ static int drbg_add(const void *buf, int num, double randomness) return ret; #else /* - * If an os entropy source is available then we declare the buffer content + * If an os entropy source is available then we declare the buffer content * as additional data by setting randomness to zero and trigger a regular * reseeding. */ diff --git a/contrib/libs/openssl/crypto/rand/rand_err.c b/contrib/libs/openssl/crypto/rand/rand_err.c index 9ca23cfff5..a3ae5f53c2 100644 --- a/contrib/libs/openssl/crypto/rand/rand_err.c +++ b/contrib/libs/openssl/crypto/rand/rand_err.c @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -14,8 +14,8 @@ #ifndef OPENSSL_NO_ERR static const ERR_STRING_DATA RAND_str_functs[] = { - {ERR_PACK(ERR_LIB_RAND, RAND_F_DATA_COLLECT_METHOD, 0), - "data_collect_method"}, + {ERR_PACK(ERR_LIB_RAND, RAND_F_DATA_COLLECT_METHOD, 0), + "data_collect_method"}, {ERR_PACK(ERR_LIB_RAND, RAND_F_DRBG_BYTES, 0), "drbg_bytes"}, {ERR_PACK(ERR_LIB_RAND, RAND_F_DRBG_GET_ENTROPY, 0), "drbg_get_entropy"}, {ERR_PACK(ERR_LIB_RAND, RAND_F_DRBG_SETUP, 0), "drbg_setup"}, @@ -51,7 +51,7 @@ static const ERR_STRING_DATA RAND_str_functs[] = { "rand_pool_bytes_needed"}, {ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_POOL_GROW, 0), "rand_pool_grow"}, {ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_POOL_NEW, 0), "rand_pool_new"}, - {ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_PSEUDO_BYTES, 0), "RAND_pseudo_bytes"}, + {ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_PSEUDO_BYTES, 0), "RAND_pseudo_bytes"}, {ERR_PACK(ERR_LIB_RAND, RAND_F_RAND_WRITE_FILE, 0), "RAND_write_file"}, {0, NULL} }; diff --git a/contrib/libs/openssl/crypto/rand/rand_lib.c b/contrib/libs/openssl/crypto/rand/rand_lib.c index 8a8a672774..5c72fad8ca 100644 --- a/contrib/libs/openssl/crypto/rand/rand_lib.c +++ b/contrib/libs/openssl/crypto/rand/rand_lib.c @@ -11,10 +11,10 @@ #include <time.h> #include "internal/cryptlib.h" #include <openssl/opensslconf.h> -#include "crypto/rand.h" +#include "crypto/rand.h" #include <openssl/engine.h> #include "internal/thread_once.h" -#include "rand_local.h" +#include "rand_local.h" #include "e_os.h" #ifndef OPENSSL_NO_ENGINE @@ -384,9 +384,9 @@ int RAND_poll(void) const RAND_METHOD *meth = RAND_get_rand_method(); - if (meth == NULL) - return 0; - + if (meth == NULL) + return 0; + if (meth == RAND_OpenSSL()) { /* fill random pool and seed the master DRBG */ RAND_DRBG *drbg = RAND_DRBG_get0_master(); @@ -770,7 +770,7 @@ int rand_pool_add(RAND_POOL *pool, * is returned without producing an error message. * * After updating the buffer, rand_pool_add_end() needs to be called - * to finish the update operation (see next comment). + * to finish the update operation (see next comment). */ unsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len) { @@ -901,7 +901,7 @@ void RAND_seed(const void *buf, int num) { const RAND_METHOD *meth = RAND_get_rand_method(); - if (meth != NULL && meth->seed != NULL) + if (meth != NULL && meth->seed != NULL) meth->seed(buf, num); } @@ -909,7 +909,7 @@ void RAND_add(const void *buf, int num, double randomness) { const RAND_METHOD *meth = RAND_get_rand_method(); - if (meth != NULL && meth->add != NULL) + if (meth != NULL && meth->add != NULL) meth->add(buf, num, randomness); } @@ -923,21 +923,21 @@ int RAND_priv_bytes(unsigned char *buf, int num) const RAND_METHOD *meth = RAND_get_rand_method(); RAND_DRBG *drbg; - if (meth != NULL && meth != RAND_OpenSSL()) + if (meth != NULL && meth != RAND_OpenSSL()) return RAND_bytes(buf, num); drbg = RAND_DRBG_get0_private(); - if (drbg != NULL) - return RAND_DRBG_bytes(drbg, buf, num); + if (drbg != NULL) + return RAND_DRBG_bytes(drbg, buf, num); - return 0; + return 0; } int RAND_bytes(unsigned char *buf, int num) { const RAND_METHOD *meth = RAND_get_rand_method(); - if (meth != NULL && meth->bytes != NULL) + if (meth != NULL && meth->bytes != NULL) return meth->bytes(buf, num); RANDerr(RAND_F_RAND_BYTES, RAND_R_FUNC_NOT_IMPLEMENTED); return -1; @@ -948,9 +948,9 @@ int RAND_pseudo_bytes(unsigned char *buf, int num) { const RAND_METHOD *meth = RAND_get_rand_method(); - if (meth != NULL && meth->pseudorand != NULL) + if (meth != NULL && meth->pseudorand != NULL) return meth->pseudorand(buf, num); - RANDerr(RAND_F_RAND_PSEUDO_BYTES, RAND_R_FUNC_NOT_IMPLEMENTED); + RANDerr(RAND_F_RAND_PSEUDO_BYTES, RAND_R_FUNC_NOT_IMPLEMENTED); return -1; } #endif @@ -959,7 +959,7 @@ int RAND_status(void) { const RAND_METHOD *meth = RAND_get_rand_method(); - if (meth != NULL && meth->status != NULL) + if (meth != NULL && meth->status != NULL) return meth->status(); return 0; } diff --git a/contrib/libs/openssl/crypto/rand/rand_local.h b/contrib/libs/openssl/crypto/rand/rand_local.h index a71f1cc9a9..a5de5252dc 100644 --- a/contrib/libs/openssl/crypto/rand/rand_local.h +++ b/contrib/libs/openssl/crypto/rand/rand_local.h @@ -1,306 +1,306 @@ -/* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_RAND_LOCAL_H -# define OSSL_CRYPTO_RAND_LOCAL_H - -# include <openssl/aes.h> -# include <openssl/evp.h> -# include <openssl/sha.h> -# include <openssl/hmac.h> -# include <openssl/ec.h> -# include <openssl/rand_drbg.h> -# include "internal/tsan_assist.h" - -# include "internal/numbers.h" - -/* How many times to read the TSC as a randomness source. */ -# define TSC_READ_COUNT 4 - -/* Maximum reseed intervals */ -# define MAX_RESEED_INTERVAL (1 << 24) -# define MAX_RESEED_TIME_INTERVAL (1 << 20) /* approx. 12 days */ - -/* Default reseed intervals */ -# define MASTER_RESEED_INTERVAL (1 << 8) -# define SLAVE_RESEED_INTERVAL (1 << 16) -# define MASTER_RESEED_TIME_INTERVAL (60*60) /* 1 hour */ -# define SLAVE_RESEED_TIME_INTERVAL (7*60) /* 7 minutes */ - - - -/* - * Maximum input size for the DRBG (entropy, nonce, personalization string) - * - * NIST SP800 90Ar1 allows a maximum of (1 << 35) bits i.e., (1 << 32) bytes. - * - * We lower it to 'only' INT32_MAX bytes, which is equivalent to 2 gigabytes. - */ -# define DRBG_MAX_LENGTH INT32_MAX - - -/* - * Maximum allocation size for RANDOM_POOL buffers - * - * The max_len value for the buffer provided to the rand_drbg_get_entropy() - * callback is currently 2^31 bytes (2 gigabytes), if a derivation function - * is used. Since this is much too large to be allocated, the rand_pool_new() - * function chooses more modest values as default pool length, bounded - * by RAND_POOL_MIN_LENGTH and RAND_POOL_MAX_LENGTH - * - * The choice of the RAND_POOL_FACTOR is large enough such that the - * RAND_POOL can store a random input which has a lousy entropy rate of - * 8/256 (= 0.03125) bits per byte. This input will be sent through the - * derivation function which 'compresses' the low quality input into a - * high quality output. - * - * The factor 1.5 below is the pessimistic estimate for the extra amount - * of entropy required when no get_nonce() callback is defined. - */ -# define RAND_POOL_FACTOR 256 -# define RAND_POOL_MAX_LENGTH (RAND_POOL_FACTOR * \ - 3 * (RAND_DRBG_STRENGTH / 16)) -/* - * = (RAND_POOL_FACTOR * \ - * 1.5 * (RAND_DRBG_STRENGTH / 8)) - */ - -/* - * Initial allocation minimum. - * - * There is a distinction between the secure and normal allocation minimums. - * Ideally, the secure allocation size should be a power of two. The normal - * allocation size doesn't have any such restriction. - * - * The secure value is based on 128 bits of secure material, which is 16 bytes. - * Typically, the DRBGs will set a minimum larger than this so optimal - * allocation ought to take place (for full quality seed material). - * - * The normal value has been chosen by noticing that the rand_drbg_get_nonce - * function is usually the largest of the built in allocation (twenty four - * bytes and then appending another sixteen bytes). This means the buffer ends - * with 40 bytes. The value of forty eight is comfortably above this which - * allows some slack in the platform specific values used. - */ -# define RAND_POOL_MIN_ALLOCATION(secure) ((secure) ? 16 : 48) - -/* DRBG status values */ -typedef enum drbg_status_e { - DRBG_UNINITIALISED, - DRBG_READY, - DRBG_ERROR -} DRBG_STATUS; - - -/* instantiate */ -typedef int (*RAND_DRBG_instantiate_fn)(RAND_DRBG *ctx, - const unsigned char *ent, - size_t entlen, - const unsigned char *nonce, - size_t noncelen, - const unsigned char *pers, - size_t perslen); -/* reseed */ -typedef int (*RAND_DRBG_reseed_fn)(RAND_DRBG *ctx, - const unsigned char *ent, - size_t entlen, - const unsigned char *adin, - size_t adinlen); -/* generate output */ -typedef int (*RAND_DRBG_generate_fn)(RAND_DRBG *ctx, - unsigned char *out, - size_t outlen, - const unsigned char *adin, - size_t adinlen); -/* uninstantiate */ -typedef int (*RAND_DRBG_uninstantiate_fn)(RAND_DRBG *ctx); - - -/* - * The DRBG methods - */ - -typedef struct rand_drbg_method_st { - RAND_DRBG_instantiate_fn instantiate; - RAND_DRBG_reseed_fn reseed; - RAND_DRBG_generate_fn generate; - RAND_DRBG_uninstantiate_fn uninstantiate; -} RAND_DRBG_METHOD; - - -/* - * The state of a DRBG AES-CTR. - */ -typedef struct rand_drbg_ctr_st { +/* + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_RAND_LOCAL_H +# define OSSL_CRYPTO_RAND_LOCAL_H + +# include <openssl/aes.h> +# include <openssl/evp.h> +# include <openssl/sha.h> +# include <openssl/hmac.h> +# include <openssl/ec.h> +# include <openssl/rand_drbg.h> +# include "internal/tsan_assist.h" + +# include "internal/numbers.h" + +/* How many times to read the TSC as a randomness source. */ +# define TSC_READ_COUNT 4 + +/* Maximum reseed intervals */ +# define MAX_RESEED_INTERVAL (1 << 24) +# define MAX_RESEED_TIME_INTERVAL (1 << 20) /* approx. 12 days */ + +/* Default reseed intervals */ +# define MASTER_RESEED_INTERVAL (1 << 8) +# define SLAVE_RESEED_INTERVAL (1 << 16) +# define MASTER_RESEED_TIME_INTERVAL (60*60) /* 1 hour */ +# define SLAVE_RESEED_TIME_INTERVAL (7*60) /* 7 minutes */ + + + +/* + * Maximum input size for the DRBG (entropy, nonce, personalization string) + * + * NIST SP800 90Ar1 allows a maximum of (1 << 35) bits i.e., (1 << 32) bytes. + * + * We lower it to 'only' INT32_MAX bytes, which is equivalent to 2 gigabytes. + */ +# define DRBG_MAX_LENGTH INT32_MAX + + +/* + * Maximum allocation size for RANDOM_POOL buffers + * + * The max_len value for the buffer provided to the rand_drbg_get_entropy() + * callback is currently 2^31 bytes (2 gigabytes), if a derivation function + * is used. Since this is much too large to be allocated, the rand_pool_new() + * function chooses more modest values as default pool length, bounded + * by RAND_POOL_MIN_LENGTH and RAND_POOL_MAX_LENGTH + * + * The choice of the RAND_POOL_FACTOR is large enough such that the + * RAND_POOL can store a random input which has a lousy entropy rate of + * 8/256 (= 0.03125) bits per byte. This input will be sent through the + * derivation function which 'compresses' the low quality input into a + * high quality output. + * + * The factor 1.5 below is the pessimistic estimate for the extra amount + * of entropy required when no get_nonce() callback is defined. + */ +# define RAND_POOL_FACTOR 256 +# define RAND_POOL_MAX_LENGTH (RAND_POOL_FACTOR * \ + 3 * (RAND_DRBG_STRENGTH / 16)) +/* + * = (RAND_POOL_FACTOR * \ + * 1.5 * (RAND_DRBG_STRENGTH / 8)) + */ + +/* + * Initial allocation minimum. + * + * There is a distinction between the secure and normal allocation minimums. + * Ideally, the secure allocation size should be a power of two. The normal + * allocation size doesn't have any such restriction. + * + * The secure value is based on 128 bits of secure material, which is 16 bytes. + * Typically, the DRBGs will set a minimum larger than this so optimal + * allocation ought to take place (for full quality seed material). + * + * The normal value has been chosen by noticing that the rand_drbg_get_nonce + * function is usually the largest of the built in allocation (twenty four + * bytes and then appending another sixteen bytes). This means the buffer ends + * with 40 bytes. The value of forty eight is comfortably above this which + * allows some slack in the platform specific values used. + */ +# define RAND_POOL_MIN_ALLOCATION(secure) ((secure) ? 16 : 48) + +/* DRBG status values */ +typedef enum drbg_status_e { + DRBG_UNINITIALISED, + DRBG_READY, + DRBG_ERROR +} DRBG_STATUS; + + +/* instantiate */ +typedef int (*RAND_DRBG_instantiate_fn)(RAND_DRBG *ctx, + const unsigned char *ent, + size_t entlen, + const unsigned char *nonce, + size_t noncelen, + const unsigned char *pers, + size_t perslen); +/* reseed */ +typedef int (*RAND_DRBG_reseed_fn)(RAND_DRBG *ctx, + const unsigned char *ent, + size_t entlen, + const unsigned char *adin, + size_t adinlen); +/* generate output */ +typedef int (*RAND_DRBG_generate_fn)(RAND_DRBG *ctx, + unsigned char *out, + size_t outlen, + const unsigned char *adin, + size_t adinlen); +/* uninstantiate */ +typedef int (*RAND_DRBG_uninstantiate_fn)(RAND_DRBG *ctx); + + +/* + * The DRBG methods + */ + +typedef struct rand_drbg_method_st { + RAND_DRBG_instantiate_fn instantiate; + RAND_DRBG_reseed_fn reseed; + RAND_DRBG_generate_fn generate; + RAND_DRBG_uninstantiate_fn uninstantiate; +} RAND_DRBG_METHOD; + + +/* + * The state of a DRBG AES-CTR. + */ +typedef struct rand_drbg_ctr_st { EVP_CIPHER_CTX *ctx_ecb; EVP_CIPHER_CTX *ctx_ctr; - EVP_CIPHER_CTX *ctx_df; + EVP_CIPHER_CTX *ctx_df; const EVP_CIPHER *cipher_ecb; const EVP_CIPHER *cipher_ctr; - size_t keylen; - unsigned char K[32]; - unsigned char V[16]; - /* Temporary block storage used by ctr_df */ - unsigned char bltmp[16]; - size_t bltmp_pos; - unsigned char KX[48]; -} RAND_DRBG_CTR; - - -/* - * The 'random pool' acts as a dumb container for collecting random - * input from various entropy sources. The pool has no knowledge about - * whether its randomness is fed into a legacy RAND_METHOD via RAND_add() - * or into a new style RAND_DRBG. It is the callers duty to 1) initialize the - * random pool, 2) pass it to the polling callbacks, 3) seed the RNG, and - * 4) cleanup the random pool again. - * - * The random pool contains no locking mechanism because its scope and - * lifetime is intended to be restricted to a single stack frame. - */ -struct rand_pool_st { - unsigned char *buffer; /* points to the beginning of the random pool */ - size_t len; /* current number of random bytes contained in the pool */ - - int attached; /* true pool was attached to existing buffer */ - int secure; /* 1: allocated on the secure heap, 0: otherwise */ - - size_t min_len; /* minimum number of random bytes requested */ - size_t max_len; /* maximum number of random bytes (allocated buffer size) */ - size_t alloc_len; /* current number of bytes allocated */ - size_t entropy; /* current entropy count in bits */ - size_t entropy_requested; /* requested entropy count in bits */ -}; - -/* - * The state of all types of DRBGs, even though we only have CTR mode - * right now. - */ -struct rand_drbg_st { - CRYPTO_RWLOCK *lock; - RAND_DRBG *parent; - int secure; /* 1: allocated on the secure heap, 0: otherwise */ - int type; /* the nid of the underlying algorithm */ - /* - * Stores the return value of openssl_get_fork_id() as of when we last - * reseeded. The DRBG reseeds automatically whenever drbg->fork_id != - * openssl_get_fork_id(). Used to provide fork-safety and reseed this - * DRBG in the child process. - */ - int fork_id; - unsigned short flags; /* various external flags */ - - /* - * The random_data is used by RAND_add()/drbg_add() to attach random - * data to the global drbg, such that the rand_drbg_get_entropy() callback - * can pull it during instantiation and reseeding. This is necessary to - * reconcile the different philosophies of the RAND and the RAND_DRBG - * with respect to how randomness is added to the RNG during reseeding - * (see PR #4328). - */ - struct rand_pool_st *seed_pool; - - /* - * Auxiliary pool for additional data. - */ - struct rand_pool_st *adin_pool; - - /* - * The following parameters are setup by the per-type "init" function. - * - * Currently the only type is CTR_DRBG, its init function is drbg_ctr_init(). - * - * The parameters are closely related to the ones described in - * section '10.2.1 CTR_DRBG' of [NIST SP 800-90Ar1], with one - * crucial difference: In the NIST standard, all counts are given - * in bits, whereas in OpenSSL entropy counts are given in bits - * and buffer lengths are given in bytes. - * - * Since this difference has lead to some confusion in the past, - * (see [GitHub Issue #2443], formerly [rt.openssl.org #4055]) - * the 'len' suffix has been added to all buffer sizes for - * clarification. - */ - - int strength; - size_t max_request; - size_t min_entropylen, max_entropylen; - size_t min_noncelen, max_noncelen; - size_t max_perslen, max_adinlen; - - /* Counts the number of generate requests since the last reseed. */ + size_t keylen; + unsigned char K[32]; + unsigned char V[16]; + /* Temporary block storage used by ctr_df */ + unsigned char bltmp[16]; + size_t bltmp_pos; + unsigned char KX[48]; +} RAND_DRBG_CTR; + + +/* + * The 'random pool' acts as a dumb container for collecting random + * input from various entropy sources. The pool has no knowledge about + * whether its randomness is fed into a legacy RAND_METHOD via RAND_add() + * or into a new style RAND_DRBG. It is the callers duty to 1) initialize the + * random pool, 2) pass it to the polling callbacks, 3) seed the RNG, and + * 4) cleanup the random pool again. + * + * The random pool contains no locking mechanism because its scope and + * lifetime is intended to be restricted to a single stack frame. + */ +struct rand_pool_st { + unsigned char *buffer; /* points to the beginning of the random pool */ + size_t len; /* current number of random bytes contained in the pool */ + + int attached; /* true pool was attached to existing buffer */ + int secure; /* 1: allocated on the secure heap, 0: otherwise */ + + size_t min_len; /* minimum number of random bytes requested */ + size_t max_len; /* maximum number of random bytes (allocated buffer size) */ + size_t alloc_len; /* current number of bytes allocated */ + size_t entropy; /* current entropy count in bits */ + size_t entropy_requested; /* requested entropy count in bits */ +}; + +/* + * The state of all types of DRBGs, even though we only have CTR mode + * right now. + */ +struct rand_drbg_st { + CRYPTO_RWLOCK *lock; + RAND_DRBG *parent; + int secure; /* 1: allocated on the secure heap, 0: otherwise */ + int type; /* the nid of the underlying algorithm */ + /* + * Stores the return value of openssl_get_fork_id() as of when we last + * reseeded. The DRBG reseeds automatically whenever drbg->fork_id != + * openssl_get_fork_id(). Used to provide fork-safety and reseed this + * DRBG in the child process. + */ + int fork_id; + unsigned short flags; /* various external flags */ + + /* + * The random_data is used by RAND_add()/drbg_add() to attach random + * data to the global drbg, such that the rand_drbg_get_entropy() callback + * can pull it during instantiation and reseeding. This is necessary to + * reconcile the different philosophies of the RAND and the RAND_DRBG + * with respect to how randomness is added to the RNG during reseeding + * (see PR #4328). + */ + struct rand_pool_st *seed_pool; + + /* + * Auxiliary pool for additional data. + */ + struct rand_pool_st *adin_pool; + + /* + * The following parameters are setup by the per-type "init" function. + * + * Currently the only type is CTR_DRBG, its init function is drbg_ctr_init(). + * + * The parameters are closely related to the ones described in + * section '10.2.1 CTR_DRBG' of [NIST SP 800-90Ar1], with one + * crucial difference: In the NIST standard, all counts are given + * in bits, whereas in OpenSSL entropy counts are given in bits + * and buffer lengths are given in bytes. + * + * Since this difference has lead to some confusion in the past, + * (see [GitHub Issue #2443], formerly [rt.openssl.org #4055]) + * the 'len' suffix has been added to all buffer sizes for + * clarification. + */ + + int strength; + size_t max_request; + size_t min_entropylen, max_entropylen; + size_t min_noncelen, max_noncelen; + size_t max_perslen, max_adinlen; + + /* Counts the number of generate requests since the last reseed. */ unsigned int generate_counter; - /* - * Maximum number of generate requests until a reseed is required. - * This value is ignored if it is zero. - */ - unsigned int reseed_interval; - /* Stores the time when the last reseeding occurred */ - time_t reseed_time; - /* - * Specifies the maximum time interval (in seconds) between reseeds. - * This value is ignored if it is zero. - */ - time_t reseed_time_interval; - - /* + /* + * Maximum number of generate requests until a reseed is required. + * This value is ignored if it is zero. + */ + unsigned int reseed_interval; + /* Stores the time when the last reseeding occurred */ + time_t reseed_time; + /* + * Specifies the maximum time interval (in seconds) between reseeds. + * This value is ignored if it is zero. + */ + time_t reseed_time_interval; + + /* * Enables reseed propagation (see following comment) */ unsigned int enable_reseed_propagation; /* - * Counts the number of reseeds since instantiation. + * Counts the number of reseeds since instantiation. * This value is ignored if enable_reseed_propagation is zero. - * - * This counter is used only for seed propagation from the <master> DRBG - * to its two children, the <public> and <private> DRBG. This feature is - * very special and its sole purpose is to ensure that any randomness which - * is added by RAND_add() or RAND_seed() will have an immediate effect on - * the output of RAND_bytes() resp. RAND_priv_bytes(). - */ + * + * This counter is used only for seed propagation from the <master> DRBG + * to its two children, the <public> and <private> DRBG. This feature is + * very special and its sole purpose is to ensure that any randomness which + * is added by RAND_add() or RAND_seed() will have an immediate effect on + * the output of RAND_bytes() resp. RAND_priv_bytes(). + */ TSAN_QUALIFIER unsigned int reseed_counter; - - size_t seedlen; - DRBG_STATUS state; - - /* Application data, mainly used in the KATs. */ - CRYPTO_EX_DATA ex_data; - - /* Implementation specific data (currently only one implementation) */ - union { - RAND_DRBG_CTR ctr; - } data; - - /* Implementation specific methods */ - RAND_DRBG_METHOD *meth; - - /* Callback functions. See comments in rand_lib.c */ - RAND_DRBG_get_entropy_fn get_entropy; - RAND_DRBG_cleanup_entropy_fn cleanup_entropy; - RAND_DRBG_get_nonce_fn get_nonce; - RAND_DRBG_cleanup_nonce_fn cleanup_nonce; -}; - -/* The global RAND method, and the global buffer and DRBG instance. */ -extern RAND_METHOD rand_meth; - -/* DRBG helpers */ -int rand_drbg_restart(RAND_DRBG *drbg, - const unsigned char *buffer, size_t len, size_t entropy); -size_t rand_drbg_seedlen(RAND_DRBG *drbg); -/* locking api */ -int rand_drbg_lock(RAND_DRBG *drbg); -int rand_drbg_unlock(RAND_DRBG *drbg); -int rand_drbg_enable_locking(RAND_DRBG *drbg); - - -/* initializes the AES-CTR DRBG implementation */ -int drbg_ctr_init(RAND_DRBG *drbg); - -#endif + + size_t seedlen; + DRBG_STATUS state; + + /* Application data, mainly used in the KATs. */ + CRYPTO_EX_DATA ex_data; + + /* Implementation specific data (currently only one implementation) */ + union { + RAND_DRBG_CTR ctr; + } data; + + /* Implementation specific methods */ + RAND_DRBG_METHOD *meth; + + /* Callback functions. See comments in rand_lib.c */ + RAND_DRBG_get_entropy_fn get_entropy; + RAND_DRBG_cleanup_entropy_fn cleanup_entropy; + RAND_DRBG_get_nonce_fn get_nonce; + RAND_DRBG_cleanup_nonce_fn cleanup_nonce; +}; + +/* The global RAND method, and the global buffer and DRBG instance. */ +extern RAND_METHOD rand_meth; + +/* DRBG helpers */ +int rand_drbg_restart(RAND_DRBG *drbg, + const unsigned char *buffer, size_t len, size_t entropy); +size_t rand_drbg_seedlen(RAND_DRBG *drbg); +/* locking api */ +int rand_drbg_lock(RAND_DRBG *drbg); +int rand_drbg_unlock(RAND_DRBG *drbg); +int rand_drbg_enable_locking(RAND_DRBG *drbg); + + +/* initializes the AES-CTR DRBG implementation */ +int drbg_ctr_init(RAND_DRBG *drbg); + +#endif diff --git a/contrib/libs/openssl/crypto/rand/rand_unix.c b/contrib/libs/openssl/crypto/rand/rand_unix.c index e28b67daf2..5766e5abe7 100644 --- a/contrib/libs/openssl/crypto/rand/rand_unix.c +++ b/contrib/libs/openssl/crypto/rand/rand_unix.c @@ -15,8 +15,8 @@ #include "internal/cryptlib.h" #include <openssl/rand.h> #include <openssl/crypto.h> -#include "rand_local.h" -#include "crypto/rand.h" +#include "rand_local.h" +#include "crypto/rand.h" #include <stdio.h> #include "internal/dso.h" #ifdef __linux @@ -83,8 +83,8 @@ static uint64_t get_timer_bits(void); # define OSSL_POSIX_TIMER_OKAY # endif # endif -#endif /* (defined(OPENSSL_SYS_UNIX) && !defined(OPENSSL_SYS_VXWORKS)) - || defined(__DJGPP__) */ +#endif /* (defined(OPENSSL_SYS_UNIX) && !defined(OPENSSL_SYS_VXWORKS)) + || defined(__DJGPP__) */ #if defined(OPENSSL_RAND_SEED_NONE) /* none means none. this simplifies the following logic */ @@ -288,58 +288,58 @@ static ssize_t sysctl_random(char *buf, size_t buflen) # if defined(OPENSSL_RAND_SEED_GETRANDOM) # if defined(__linux) && !defined(__NR_getrandom) -# if defined(__arm__) +# if defined(__arm__) # define __NR_getrandom (__NR_SYSCALL_BASE+384) # elif defined(__i386__) # define __NR_getrandom 355 -# elif defined(__x86_64__) -# if defined(__ILP32__) -# define __NR_getrandom (__X32_SYSCALL_BIT + 318) -# else -# define __NR_getrandom 318 -# endif -# elif defined(__xtensa__) -# define __NR_getrandom 338 -# elif defined(__s390__) || defined(__s390x__) -# define __NR_getrandom 349 -# elif defined(__bfin__) -# define __NR_getrandom 389 -# elif defined(__powerpc__) -# define __NR_getrandom 359 -# elif defined(__mips__) || defined(__mips64) -# if _MIPS_SIM == _MIPS_SIM_ABI32 -# define __NR_getrandom (__NR_Linux + 353) -# elif _MIPS_SIM == _MIPS_SIM_ABI64 -# define __NR_getrandom (__NR_Linux + 313) -# elif _MIPS_SIM == _MIPS_SIM_NABI32 -# define __NR_getrandom (__NR_Linux + 317) -# endif -# elif defined(__hppa__) -# define __NR_getrandom (__NR_Linux + 339) -# elif defined(__sparc__) -# define __NR_getrandom 347 -# elif defined(__ia64__) -# define __NR_getrandom 1339 -# elif defined(__alpha__) -# define __NR_getrandom 511 -# elif defined(__sh__) -# if defined(__SH5__) -# define __NR_getrandom 373 -# else -# define __NR_getrandom 384 -# endif -# elif defined(__avr32__) -# define __NR_getrandom 317 -# elif defined(__microblaze__) -# define __NR_getrandom 385 -# elif defined(__m68k__) -# define __NR_getrandom 352 -# elif defined(__cris__) -# define __NR_getrandom 356 -# elif defined(__aarch64__) -# define __NR_getrandom 278 -# else /* generic */ -# define __NR_getrandom 278 +# elif defined(__x86_64__) +# if defined(__ILP32__) +# define __NR_getrandom (__X32_SYSCALL_BIT + 318) +# else +# define __NR_getrandom 318 +# endif +# elif defined(__xtensa__) +# define __NR_getrandom 338 +# elif defined(__s390__) || defined(__s390x__) +# define __NR_getrandom 349 +# elif defined(__bfin__) +# define __NR_getrandom 389 +# elif defined(__powerpc__) +# define __NR_getrandom 359 +# elif defined(__mips__) || defined(__mips64) +# if _MIPS_SIM == _MIPS_SIM_ABI32 +# define __NR_getrandom (__NR_Linux + 353) +# elif _MIPS_SIM == _MIPS_SIM_ABI64 +# define __NR_getrandom (__NR_Linux + 313) +# elif _MIPS_SIM == _MIPS_SIM_NABI32 +# define __NR_getrandom (__NR_Linux + 317) +# endif +# elif defined(__hppa__) +# define __NR_getrandom (__NR_Linux + 339) +# elif defined(__sparc__) +# define __NR_getrandom 347 +# elif defined(__ia64__) +# define __NR_getrandom 1339 +# elif defined(__alpha__) +# define __NR_getrandom 511 +# elif defined(__sh__) +# if defined(__SH5__) +# define __NR_getrandom 373 +# else +# define __NR_getrandom 384 +# endif +# elif defined(__avr32__) +# define __NR_getrandom 317 +# elif defined(__microblaze__) +# define __NR_getrandom 385 +# elif defined(__m68k__) +# define __NR_getrandom 352 +# elif defined(__cris__) +# define __NR_getrandom 356 +# elif defined(__aarch64__) +# define __NR_getrandom 278 +# else /* generic */ +# define __NR_getrandom 278 # endif # endif @@ -879,5 +879,5 @@ static uint64_t get_timer_bits(void) # endif return time(NULL); } -#endif /* (defined(OPENSSL_SYS_UNIX) && !defined(OPENSSL_SYS_VXWORKS)) - || defined(__DJGPP__) */ +#endif /* (defined(OPENSSL_SYS_UNIX) && !defined(OPENSSL_SYS_VXWORKS)) + || defined(__DJGPP__) */ diff --git a/contrib/libs/openssl/crypto/rand/rand_vms.c b/contrib/libs/openssl/crypto/rand/rand_vms.c index 349f5dd301..b1e9f7974e 100644 --- a/contrib/libs/openssl/crypto/rand/rand_vms.c +++ b/contrib/libs/openssl/crypto/rand/rand_vms.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -13,42 +13,42 @@ # define __NEW_STARLET 1 /* New starlet definitions since VMS 7.0 */ # include <unistd.h> # include "internal/cryptlib.h" -# include <openssl/bio.h> -# include <openssl/err.h> +# include <openssl/bio.h> +# include <openssl/err.h> # include <openssl/rand.h> -# include "crypto/rand.h" -# include "rand_local.h" +# include "crypto/rand.h" +# include "rand_local.h" # include <descrip.h> # include <dvidef.h> # include <jpidef.h> -# error #include <rmidef.h> +# error #include <rmidef.h> # include <syidef.h> # include <ssdef.h> # include <starlet.h> -# error #include <efndef.h> +# error #include <efndef.h> # include <gen64def.h> -# error #include <iosbdef.h> +# error #include <iosbdef.h> # include <iledef.h> # include <lib$routines.h> # ifdef __DECC # pragma message disable DOLLARID # endif -# include <dlfcn.h> /* SYS$GET_ENTROPY presence */ - +# include <dlfcn.h> /* SYS$GET_ENTROPY presence */ + # ifndef OPENSSL_RAND_SEED_OS # error "Unsupported seeding method configured; must be os" # endif -/* - * DATA COLLECTION METHOD - * ====================== - * - * This is a method to get low quality entropy. - * It works by collecting all kinds of statistical data that - * VMS offers and using them as random seed. - */ - +/* + * DATA COLLECTION METHOD + * ====================== + * + * This is a method to get low quality entropy. + * It works by collecting all kinds of statistical data that + * VMS offers and using them as random seed. + */ + /* We need to make sure we have the right size pointer in some cases */ # if __INITIAL_POINTER_SIZE == 64 # pragma pointer_size save @@ -343,7 +343,7 @@ static void massage_JPI(ILE3 *items) */ #define ENTROPY_FACTOR 20 -size_t data_collect_method(RAND_POOL *pool) +size_t data_collect_method(RAND_POOL *pool) { ILE3 JPI_items_64bit[OSSL_NELEM(JPI_item_data_64bit) + 1]; ILE3 RMI_items_64bit[OSSL_NELEM(RMI_item_data_64bit) + 1]; @@ -458,12 +458,12 @@ size_t data_collect_method(RAND_POOL *pool) * If we can't feed the requirements from the caller, we're in deep trouble. */ if (!ossl_assert(total_length >= bytes_needed)) { - char buf[100]; /* That should be enough */ + char buf[100]; /* That should be enough */ - BIO_snprintf(buf, sizeof(buf), "Needed: %zu, Available: %zu", - bytes_needed, total_length); - RANDerr(RAND_F_DATA_COLLECT_METHOD, RAND_R_RANDOM_POOL_UNDERFLOW); - ERR_add_error_data(1, buf); + BIO_snprintf(buf, sizeof(buf), "Needed: %zu, Available: %zu", + bytes_needed, total_length); + RANDerr(RAND_F_DATA_COLLECT_METHOD, RAND_R_RANDOM_POOL_UNDERFLOW); + ERR_add_error_data(1, buf); return 0; } @@ -490,7 +490,7 @@ int rand_pool_add_nonce_data(RAND_POOL *pool) /* * Add process id, thread id, and a high resolution timestamp * (where available, which is OpenVMS v8.4 and up) to ensure that - * the nonce is unique with high probability for different process + * the nonce is unique with high probability for different process * instances. */ data.pid = getpid(); @@ -504,80 +504,80 @@ int rand_pool_add_nonce_data(RAND_POOL *pool) return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0); } -/* - * SYS$GET_ENTROPY METHOD - * ====================== - * - * This is a high entropy method based on a new system service that is - * based on getentropy() from FreeBSD 12. It's only used if available, - * and its availability is detected at run-time. - * - * We assume that this function provides full entropy random output. - */ -#define PUBLIC_VECTORS "SYS$LIBRARY:SYS$PUBLIC_VECTORS.EXE" -#define GET_ENTROPY "SYS$GET_ENTROPY" - -static int get_entropy_address_flag = 0; -static int (*get_entropy_address)(void *buffer, size_t buffer_size) = NULL; -static int init_get_entropy_address(void) -{ - if (get_entropy_address_flag == 0) - get_entropy_address = dlsym(dlopen(PUBLIC_VECTORS, 0), GET_ENTROPY); - get_entropy_address_flag = 1; - return get_entropy_address != NULL; -} - -size_t get_entropy_method(RAND_POOL *pool) -{ - /* - * The documentation says that SYS$GET_ENTROPY will give a maximum of - * 256 bytes of data. - */ - unsigned char buffer[256]; - size_t bytes_needed; - size_t bytes_to_get = 0; - uint32_t status; - - for (bytes_needed = rand_pool_bytes_needed(pool, 1); - bytes_needed > 0; - bytes_needed -= bytes_to_get) { - bytes_to_get = - bytes_needed > sizeof(buffer) ? sizeof(buffer) : bytes_needed; - - status = get_entropy_address(buffer, bytes_to_get); - if (status == SS$_RETRY) { - /* Set to zero so the loop doesn't diminish |bytes_needed| */ - bytes_to_get = 0; - /* Should sleep some amount of time */ - continue; - } - - if (status != SS$_NORMAL) { - lib$signal(status); - return 0; - } - - rand_pool_add(pool, buffer, bytes_to_get, 8 * bytes_to_get); - } - - return rand_pool_entropy_available(pool); -} - -/* - * MAIN ENTROPY ACQUISITION FUNCTIONS - * ================================== - * - * These functions are called by the RAND / DRBG functions - */ - -size_t rand_pool_acquire_entropy(RAND_POOL *pool) -{ - if (init_get_entropy_address()) - return get_entropy_method(pool); - return data_collect_method(pool); -} - - +/* + * SYS$GET_ENTROPY METHOD + * ====================== + * + * This is a high entropy method based on a new system service that is + * based on getentropy() from FreeBSD 12. It's only used if available, + * and its availability is detected at run-time. + * + * We assume that this function provides full entropy random output. + */ +#define PUBLIC_VECTORS "SYS$LIBRARY:SYS$PUBLIC_VECTORS.EXE" +#define GET_ENTROPY "SYS$GET_ENTROPY" + +static int get_entropy_address_flag = 0; +static int (*get_entropy_address)(void *buffer, size_t buffer_size) = NULL; +static int init_get_entropy_address(void) +{ + if (get_entropy_address_flag == 0) + get_entropy_address = dlsym(dlopen(PUBLIC_VECTORS, 0), GET_ENTROPY); + get_entropy_address_flag = 1; + return get_entropy_address != NULL; +} + +size_t get_entropy_method(RAND_POOL *pool) +{ + /* + * The documentation says that SYS$GET_ENTROPY will give a maximum of + * 256 bytes of data. + */ + unsigned char buffer[256]; + size_t bytes_needed; + size_t bytes_to_get = 0; + uint32_t status; + + for (bytes_needed = rand_pool_bytes_needed(pool, 1); + bytes_needed > 0; + bytes_needed -= bytes_to_get) { + bytes_to_get = + bytes_needed > sizeof(buffer) ? sizeof(buffer) : bytes_needed; + + status = get_entropy_address(buffer, bytes_to_get); + if (status == SS$_RETRY) { + /* Set to zero so the loop doesn't diminish |bytes_needed| */ + bytes_to_get = 0; + /* Should sleep some amount of time */ + continue; + } + + if (status != SS$_NORMAL) { + lib$signal(status); + return 0; + } + + rand_pool_add(pool, buffer, bytes_to_get, 8 * bytes_to_get); + } + + return rand_pool_entropy_available(pool); +} + +/* + * MAIN ENTROPY ACQUISITION FUNCTIONS + * ================================== + * + * These functions are called by the RAND / DRBG functions + */ + +size_t rand_pool_acquire_entropy(RAND_POOL *pool) +{ + if (init_get_entropy_address()) + return get_entropy_method(pool); + return data_collect_method(pool); +} + + int rand_pool_add_additional_data(RAND_POOL *pool) { struct { diff --git a/contrib/libs/openssl/crypto/rand/rand_win.c b/contrib/libs/openssl/crypto/rand/rand_win.c index 24cfd3ac39..9036546008 100644 --- a/contrib/libs/openssl/crypto/rand/rand_win.c +++ b/contrib/libs/openssl/crypto/rand/rand_win.c @@ -9,8 +9,8 @@ #include "internal/cryptlib.h" #include <openssl/rand.h> -#include "rand_local.h" -#include "crypto/rand.h" +#include "rand_local.h" +#include "crypto/rand.h" #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) # ifndef OPENSSL_RAND_SEED_OS @@ -130,7 +130,7 @@ int rand_pool_add_nonce_data(RAND_POOL *pool) /* * Add process id, thread id, and a high resolution timestamp to - * ensure that the nonce is unique with high probability for + * ensure that the nonce is unique with high probability for * different process instances. */ data.pid = GetCurrentProcessId(); diff --git a/contrib/libs/openssl/crypto/rc2/rc2_cbc.c b/contrib/libs/openssl/crypto/rc2/rc2_cbc.c index 8aef6d1de4..17e86f690e 100644 --- a/contrib/libs/openssl/crypto/rc2/rc2_cbc.c +++ b/contrib/libs/openssl/crypto/rc2/rc2_cbc.c @@ -8,7 +8,7 @@ */ #include <openssl/rc2.h> -#include "rc2_local.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/contrib/libs/openssl/crypto/rc2/rc2_ecb.c b/contrib/libs/openssl/crypto/rc2/rc2_ecb.c index dc917d7d2d..8d9927cd58 100644 --- a/contrib/libs/openssl/crypto/rc2/rc2_ecb.c +++ b/contrib/libs/openssl/crypto/rc2/rc2_ecb.c @@ -8,7 +8,7 @@ */ #include <openssl/rc2.h> -#include "rc2_local.h" +#include "rc2_local.h" #include <openssl/opensslv.h> /*- diff --git a/contrib/libs/openssl/crypto/rc2/rc2_local.h b/contrib/libs/openssl/crypto/rc2/rc2_local.h index f4cb02e7d2..e4dad94787 100644 --- a/contrib/libs/openssl/crypto/rc2/rc2_local.h +++ b/contrib/libs/openssl/crypto/rc2/rc2_local.h @@ -1,134 +1,134 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#undef c2l -#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<<24L) - -/* NOTE - c is not incremented as per c2l */ -#undef c2ln -#define c2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ - /* fall thru */ \ - case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ - /* fall thru */ \ - case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ - /* fall thru */ \ - case 5: l2|=((unsigned long)(*(--(c)))); \ - /* fall thru */ \ - case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ - /* fall thru */ \ - case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ - /* fall thru */ \ - case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ - /* fall thru */ \ - case 1: l1|=((unsigned long)(*(--(c)))); \ - } \ - } - -#undef l2c -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24L)&0xff)) - -/* NOTE - c is not incremented as per l2c */ -#undef l2cn -#define l2cn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ - /* fall thru */ \ - case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ - /* fall thru */ \ - case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ - /* fall thru */ \ - case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ - /* fall thru */ \ - case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ - /* fall thru */ \ - case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ - /* fall thru */ \ - case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ - /* fall thru */ \ - case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ - } \ - } - -/* NOTE - c is not incremented as per n2l */ -#define n2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c)))) ; \ - /* fall thru */ \ - case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ - /* fall thru */ \ - case 6: l2|=((unsigned long)(*(--(c))))<<16; \ - /* fall thru */ \ - case 5: l2|=((unsigned long)(*(--(c))))<<24; \ - /* fall thru */ \ - case 4: l1 =((unsigned long)(*(--(c)))) ; \ - /* fall thru */ \ - case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ - /* fall thru */ \ - case 2: l1|=((unsigned long)(*(--(c))))<<16; \ - /* fall thru */ \ - case 1: l1|=((unsigned long)(*(--(c))))<<24; \ - } \ - } - -/* NOTE - c is not incremented as per l2n */ -#define l2nn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ - /* fall thru */ \ - case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - /* fall thru */ \ - case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - /* fall thru */ \ - case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - /* fall thru */ \ - case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ - /* fall thru */ \ - case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - /* fall thru */ \ - case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - /* fall thru */ \ - case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - } \ - } - -#undef n2l -#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))) - -#undef l2n -#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -#define C_RC2(n) \ - t=(x0+(x1& ~x3)+(x2&x3)+ *(p0++))&0xffff; \ - x0=(t<<1)|(t>>15); \ - t=(x1+(x2& ~x0)+(x3&x0)+ *(p0++))&0xffff; \ - x1=(t<<2)|(t>>14); \ - t=(x2+(x3& ~x1)+(x0&x1)+ *(p0++))&0xffff; \ - x2=(t<<3)|(t>>13); \ - t=(x3+(x0& ~x2)+(x1&x2)+ *(p0++))&0xffff; \ - x3=(t<<5)|(t>>11); +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#undef c2l +#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#undef c2ln +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ + /* fall thru */ \ + case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ + /* fall thru */ \ + case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ + /* fall thru */ \ + case 5: l2|=((unsigned long)(*(--(c)))); \ + /* fall thru */ \ + case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ + /* fall thru */ \ + case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ + /* fall thru */ \ + case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ + /* fall thru */ \ + case 1: l1|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#undef l2cn +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + /* fall thru */ \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + /* fall thru */ \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + /* fall thru */ \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + /* fall thru */ \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + /* fall thru */ \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + /* fall thru */ \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + /* fall thru */ \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +/* NOTE - c is not incremented as per n2l */ +#define n2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c)))) ; \ + /* fall thru */ \ + case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ + /* fall thru */ \ + case 6: l2|=((unsigned long)(*(--(c))))<<16; \ + /* fall thru */ \ + case 5: l2|=((unsigned long)(*(--(c))))<<24; \ + /* fall thru */ \ + case 4: l1 =((unsigned long)(*(--(c)))) ; \ + /* fall thru */ \ + case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ + /* fall thru */ \ + case 2: l1|=((unsigned long)(*(--(c))))<<16; \ + /* fall thru */ \ + case 1: l1|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +/* NOTE - c is not incremented as per l2n */ +#define l2nn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ + /* fall thru */ \ + case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + /* fall thru */ \ + case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + /* fall thru */ \ + case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + /* fall thru */ \ + case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ + /* fall thru */ \ + case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + /* fall thru */ \ + case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + /* fall thru */ \ + case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + } \ + } + +#undef n2l +#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))) + +#undef l2n +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +#define C_RC2(n) \ + t=(x0+(x1& ~x3)+(x2&x3)+ *(p0++))&0xffff; \ + x0=(t<<1)|(t>>15); \ + t=(x1+(x2& ~x0)+(x3&x0)+ *(p0++))&0xffff; \ + x1=(t<<2)|(t>>14); \ + t=(x2+(x3& ~x1)+(x0&x1)+ *(p0++))&0xffff; \ + x2=(t<<3)|(t>>13); \ + t=(x3+(x0& ~x2)+(x1&x2)+ *(p0++))&0xffff; \ + x3=(t<<5)|(t>>11); diff --git a/contrib/libs/openssl/crypto/rc2/rc2_skey.c b/contrib/libs/openssl/crypto/rc2/rc2_skey.c index 7ae3506512..60ebd42f26 100644 --- a/contrib/libs/openssl/crypto/rc2/rc2_skey.c +++ b/contrib/libs/openssl/crypto/rc2/rc2_skey.c @@ -8,7 +8,7 @@ */ #include <openssl/rc2.h> -#include "rc2_local.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/contrib/libs/openssl/crypto/rc2/rc2cfb64.c b/contrib/libs/openssl/crypto/rc2/rc2cfb64.c index 9eee503da3..8d1c3a4d8f 100644 --- a/contrib/libs/openssl/crypto/rc2/rc2cfb64.c +++ b/contrib/libs/openssl/crypto/rc2/rc2cfb64.c @@ -8,7 +8,7 @@ */ #include <openssl/rc2.h> -#include "rc2_local.h" +#include "rc2_local.h" /* * The input and output encrypted as though 64bit cfb mode is being used. diff --git a/contrib/libs/openssl/crypto/rc2/rc2ofb64.c b/contrib/libs/openssl/crypto/rc2/rc2ofb64.c index cf1e5b9400..61b2c56434 100644 --- a/contrib/libs/openssl/crypto/rc2/rc2ofb64.c +++ b/contrib/libs/openssl/crypto/rc2/rc2ofb64.c @@ -8,7 +8,7 @@ */ #include <openssl/rc2.h> -#include "rc2_local.h" +#include "rc2_local.h" /* * The input and output encrypted as though 64bit ofb mode is being used. diff --git a/contrib/libs/openssl/crypto/rc4/rc4_enc.c b/contrib/libs/openssl/crypto/rc4/rc4_enc.c index 5703c8d1eb..09ef6a896f 100644 --- a/contrib/libs/openssl/crypto/rc4/rc4_enc.c +++ b/contrib/libs/openssl/crypto/rc4/rc4_enc.c @@ -8,7 +8,7 @@ */ #include <openssl/rc4.h> -#include "rc4_local.h" +#include "rc4_local.h" /*- * RC4 as implemented from a posting from diff --git a/contrib/libs/openssl/crypto/rc4/rc4_local.h b/contrib/libs/openssl/crypto/rc4/rc4_local.h index 16b980edf9..e739be4be7 100644 --- a/contrib/libs/openssl/crypto/rc4/rc4_local.h +++ b/contrib/libs/openssl/crypto/rc4/rc4_local.h @@ -1,16 +1,16 @@ -/* - * Copyright 1998-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_RC4_LOCAL_H -# define OSSL_CRYPTO_RC4_LOCAL_H - -# include <openssl/opensslconf.h> -# include "internal/cryptlib.h" - -#endif +/* + * Copyright 1998-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_RC4_LOCAL_H +# define OSSL_CRYPTO_RC4_LOCAL_H + +# include <openssl/opensslconf.h> +# include "internal/cryptlib.h" + +#endif diff --git a/contrib/libs/openssl/crypto/rc4/rc4_skey.c b/contrib/libs/openssl/crypto/rc4/rc4_skey.c index 925c439a20..100eb79c2a 100644 --- a/contrib/libs/openssl/crypto/rc4/rc4_skey.c +++ b/contrib/libs/openssl/crypto/rc4/rc4_skey.c @@ -8,7 +8,7 @@ */ #include <openssl/rc4.h> -#include "rc4_local.h" +#include "rc4_local.h" #include <openssl/opensslv.h> const char *RC4_options(void) diff --git a/contrib/libs/openssl/crypto/rc5/rc5_ecb.c b/contrib/libs/openssl/crypto/rc5/rc5_ecb.c index 8c2c397914..94ec646390 100644 --- a/contrib/libs/openssl/crypto/rc5/rc5_ecb.c +++ b/contrib/libs/openssl/crypto/rc5/rc5_ecb.c @@ -8,7 +8,7 @@ */ #include <openssl/rc5.h> -#include "rc5_local.h" +#include "rc5_local.h" #include <openssl/opensslv.h> void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out, diff --git a/contrib/libs/openssl/crypto/rc5/rc5_enc.c b/contrib/libs/openssl/crypto/rc5/rc5_enc.c index 6ef54623d0..75ddeb2eaf 100644 --- a/contrib/libs/openssl/crypto/rc5/rc5_enc.c +++ b/contrib/libs/openssl/crypto/rc5/rc5_enc.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <openssl/rc5.h> -#include "rc5_local.h" +#include "rc5_local.h" void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, RC5_32_KEY *ks, unsigned char *iv, diff --git a/contrib/libs/openssl/crypto/rc5/rc5_local.h b/contrib/libs/openssl/crypto/rc5/rc5_local.h index 44bf6e5289..41130fe33b 100644 --- a/contrib/libs/openssl/crypto/rc5/rc5_local.h +++ b/contrib/libs/openssl/crypto/rc5/rc5_local.h @@ -1,186 +1,186 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <stdlib.h> - -#undef c2l -#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<<24L) - -/* NOTE - c is not incremented as per c2l */ -#undef c2ln -#define c2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ - /* fall thru */ \ - case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ - /* fall thru */ \ - case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ - /* fall thru */ \ - case 5: l2|=((unsigned long)(*(--(c)))); \ - /* fall thru */ \ - case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ - /* fall thru */ \ - case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ - /* fall thru */ \ - case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ - /* fall thru */ \ - case 1: l1|=((unsigned long)(*(--(c)))); \ - } \ - } - -#undef l2c -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24L)&0xff)) - -/* NOTE - c is not incremented as per l2c */ -#undef l2cn -#define l2cn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ - /* fall thru */ \ - case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ - /* fall thru */ \ - case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ - /* fall thru */ \ - case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ - /* fall thru */ \ - case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ - /* fall thru */ \ - case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ - /* fall thru */ \ - case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ - /* fall thru */ \ - case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ - } \ - } - -/* NOTE - c is not incremented as per n2l */ -#define n2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c)))) ; \ - /* fall thru */ \ - case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ - /* fall thru */ \ - case 6: l2|=((unsigned long)(*(--(c))))<<16; \ - /* fall thru */ \ - case 5: l2|=((unsigned long)(*(--(c))))<<24; \ - /* fall thru */ \ - case 4: l1 =((unsigned long)(*(--(c)))) ; \ - /* fall thru */ \ - case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ - /* fall thru */ \ - case 2: l1|=((unsigned long)(*(--(c))))<<16; \ - /* fall thru */ \ - case 1: l1|=((unsigned long)(*(--(c))))<<24; \ - } \ - } - -/* NOTE - c is not incremented as per l2n */ -#define l2nn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ - /* fall thru */ \ - case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - /* fall thru */ \ - case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - /* fall thru */ \ - case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - /* fall thru */ \ - case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ - /* fall thru */ \ - case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - /* fall thru */ \ - case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - /* fall thru */ \ - case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - } \ - } - -#undef n2l -#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ - l|=((unsigned long)(*((c)++)))<<16L, \ - l|=((unsigned long)(*((c)++)))<< 8L, \ - l|=((unsigned long)(*((c)++)))) - -#undef l2n -#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -#if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)) -# define ROTATE_l32(a,n) _lrotl(a,n) -# define ROTATE_r32(a,n) _lrotr(a,n) -#elif defined(__ICC) -# define ROTATE_l32(a,n) _rotl(a,n) -# define ROTATE_r32(a,n) _rotr(a,n) -#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) -# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) -# define ROTATE_l32(a,n) ({ register unsigned int ret; \ - asm ("roll %%cl,%0" \ - : "=r"(ret) \ - : "c"(n),"0"((unsigned int)(a)) \ - : "cc"); \ - ret; \ - }) -# define ROTATE_r32(a,n) ({ register unsigned int ret; \ - asm ("rorl %%cl,%0" \ - : "=r"(ret) \ - : "c"(n),"0"((unsigned int)(a)) \ - : "cc"); \ - ret; \ - }) -# endif -#endif -#ifndef ROTATE_l32 -# define ROTATE_l32(a,n) (((a)<<(n&0x1f))|(((a)&0xffffffff)>>((32-n)&0x1f))) -#endif -#ifndef ROTATE_r32 -# define ROTATE_r32(a,n) (((a)<<((32-n)&0x1f))|(((a)&0xffffffff)>>(n&0x1f))) -#endif - -#define RC5_32_MASK 0xffffffffL - -#define RC5_16_P 0xB7E1 -#define RC5_16_Q 0x9E37 -#define RC5_32_P 0xB7E15163L -#define RC5_32_Q 0x9E3779B9L -#define RC5_64_P 0xB7E151628AED2A6BLL -#define RC5_64_Q 0x9E3779B97F4A7C15LL - -#define E_RC5_32(a,b,s,n) \ - a^=b; \ - a=ROTATE_l32(a,b); \ - a+=s[n]; \ - a&=RC5_32_MASK; \ - b^=a; \ - b=ROTATE_l32(b,a); \ - b+=s[n+1]; \ - b&=RC5_32_MASK; - -#define D_RC5_32(a,b,s,n) \ - b-=s[n+1]; \ - b&=RC5_32_MASK; \ - b=ROTATE_r32(b,a); \ - b^=a; \ - a-=s[n]; \ - a&=RC5_32_MASK; \ - a=ROTATE_r32(a,b); \ - a^=b; +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <stdlib.h> + +#undef c2l +#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<<24L) + +/* NOTE - c is not incremented as per c2l */ +#undef c2ln +#define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c))))<<24L; \ + /* fall thru */ \ + case 7: l2|=((unsigned long)(*(--(c))))<<16L; \ + /* fall thru */ \ + case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \ + /* fall thru */ \ + case 5: l2|=((unsigned long)(*(--(c)))); \ + /* fall thru */ \ + case 4: l1 =((unsigned long)(*(--(c))))<<24L; \ + /* fall thru */ \ + case 3: l1|=((unsigned long)(*(--(c))))<<16L; \ + /* fall thru */ \ + case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \ + /* fall thru */ \ + case 1: l1|=((unsigned long)(*(--(c)))); \ + } \ + } + +#undef l2c +#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24L)&0xff)) + +/* NOTE - c is not incremented as per l2c */ +#undef l2cn +#define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \ + /* fall thru */ \ + case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \ + /* fall thru */ \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \ + /* fall thru */ \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + /* fall thru */ \ + case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \ + /* fall thru */ \ + case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \ + /* fall thru */ \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \ + /* fall thru */ \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +/* NOTE - c is not incremented as per n2l */ +#define n2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c)))) ; \ + /* fall thru */ \ + case 7: l2|=((unsigned long)(*(--(c))))<< 8; \ + /* fall thru */ \ + case 6: l2|=((unsigned long)(*(--(c))))<<16; \ + /* fall thru */ \ + case 5: l2|=((unsigned long)(*(--(c))))<<24; \ + /* fall thru */ \ + case 4: l1 =((unsigned long)(*(--(c)))) ; \ + /* fall thru */ \ + case 3: l1|=((unsigned long)(*(--(c))))<< 8; \ + /* fall thru */ \ + case 2: l1|=((unsigned long)(*(--(c))))<<16; \ + /* fall thru */ \ + case 1: l1|=((unsigned long)(*(--(c))))<<24; \ + } \ + } + +/* NOTE - c is not incremented as per l2n */ +#define l2nn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \ + /* fall thru */ \ + case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + /* fall thru */ \ + case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + /* fall thru */ \ + case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + /* fall thru */ \ + case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \ + /* fall thru */ \ + case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + /* fall thru */ \ + case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + /* fall thru */ \ + case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + } \ + } + +#undef n2l +#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \ + l|=((unsigned long)(*((c)++)))<<16L, \ + l|=((unsigned long)(*((c)++)))<< 8L, \ + l|=((unsigned long)(*((c)++)))) + +#undef l2n +#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16L)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +#if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)) +# define ROTATE_l32(a,n) _lrotl(a,n) +# define ROTATE_r32(a,n) _lrotr(a,n) +#elif defined(__ICC) +# define ROTATE_l32(a,n) _rotl(a,n) +# define ROTATE_r32(a,n) _rotr(a,n) +#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC) +# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) +# define ROTATE_l32(a,n) ({ register unsigned int ret; \ + asm ("roll %%cl,%0" \ + : "=r"(ret) \ + : "c"(n),"0"((unsigned int)(a)) \ + : "cc"); \ + ret; \ + }) +# define ROTATE_r32(a,n) ({ register unsigned int ret; \ + asm ("rorl %%cl,%0" \ + : "=r"(ret) \ + : "c"(n),"0"((unsigned int)(a)) \ + : "cc"); \ + ret; \ + }) +# endif +#endif +#ifndef ROTATE_l32 +# define ROTATE_l32(a,n) (((a)<<(n&0x1f))|(((a)&0xffffffff)>>((32-n)&0x1f))) +#endif +#ifndef ROTATE_r32 +# define ROTATE_r32(a,n) (((a)<<((32-n)&0x1f))|(((a)&0xffffffff)>>(n&0x1f))) +#endif + +#define RC5_32_MASK 0xffffffffL + +#define RC5_16_P 0xB7E1 +#define RC5_16_Q 0x9E37 +#define RC5_32_P 0xB7E15163L +#define RC5_32_Q 0x9E3779B9L +#define RC5_64_P 0xB7E151628AED2A6BLL +#define RC5_64_Q 0x9E3779B97F4A7C15LL + +#define E_RC5_32(a,b,s,n) \ + a^=b; \ + a=ROTATE_l32(a,b); \ + a+=s[n]; \ + a&=RC5_32_MASK; \ + b^=a; \ + b=ROTATE_l32(b,a); \ + b+=s[n+1]; \ + b&=RC5_32_MASK; + +#define D_RC5_32(a,b,s,n) \ + b-=s[n+1]; \ + b&=RC5_32_MASK; \ + b=ROTATE_r32(b,a); \ + b^=a; \ + a-=s[n]; \ + a&=RC5_32_MASK; \ + a=ROTATE_r32(a,b); \ + a^=b; diff --git a/contrib/libs/openssl/crypto/rc5/rc5_skey.c b/contrib/libs/openssl/crypto/rc5/rc5_skey.c index 06a1bc6318..b2e6bbb1af 100644 --- a/contrib/libs/openssl/crypto/rc5/rc5_skey.c +++ b/contrib/libs/openssl/crypto/rc5/rc5_skey.c @@ -8,7 +8,7 @@ */ #include <openssl/rc5.h> -#include "rc5_local.h" +#include "rc5_local.h" void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, int rounds) diff --git a/contrib/libs/openssl/crypto/rc5/rc5cfb64.c b/contrib/libs/openssl/crypto/rc5/rc5cfb64.c index 27f392d8ee..cfce7ec1e8 100644 --- a/contrib/libs/openssl/crypto/rc5/rc5cfb64.c +++ b/contrib/libs/openssl/crypto/rc5/rc5cfb64.c @@ -8,7 +8,7 @@ */ #include <openssl/rc5.h> -#include "rc5_local.h" +#include "rc5_local.h" /* * The input and output encrypted as though 64bit cfb mode is being used. diff --git a/contrib/libs/openssl/crypto/rc5/rc5ofb64.c b/contrib/libs/openssl/crypto/rc5/rc5ofb64.c index aca9b3e793..224eb96857 100644 --- a/contrib/libs/openssl/crypto/rc5/rc5ofb64.c +++ b/contrib/libs/openssl/crypto/rc5/rc5ofb64.c @@ -8,7 +8,7 @@ */ #include <openssl/rc5.h> -#include "rc5_local.h" +#include "rc5_local.h" /* * The input and output encrypted as though 64bit ofb mode is being used. diff --git a/contrib/libs/openssl/crypto/ripemd/rmd_dgst.c b/contrib/libs/openssl/crypto/ripemd/rmd_dgst.c index aab740d276..e9e440f18c 100644 --- a/contrib/libs/openssl/crypto/ripemd/rmd_dgst.c +++ b/contrib/libs/openssl/crypto/ripemd/rmd_dgst.c @@ -8,7 +8,7 @@ */ #include <stdio.h> -#include "rmd_local.h" +#include "rmd_local.h" #include <openssl/opensslv.h> #ifdef RMD160_ASM @@ -39,7 +39,7 @@ void ripemd160_block_data_order(RIPEMD160_CTX *ctx, const void *p, size_t num) register unsigned MD32_REG_T A, B, C, D, E; unsigned MD32_REG_T a, b, c, d, e, l; # ifndef MD32_XARRAY - /* See comment in crypto/sha/sha_local.h for details. */ + /* See comment in crypto/sha/sha_local.h for details. */ unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; # define X(i) XX##i diff --git a/contrib/libs/openssl/crypto/ripemd/rmd_local.h b/contrib/libs/openssl/crypto/ripemd/rmd_local.h index 91fb5ba4d4..f3604e3490 100644 --- a/contrib/libs/openssl/crypto/ripemd/rmd_local.h +++ b/contrib/libs/openssl/crypto/ripemd/rmd_local.h @@ -1,87 +1,87 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <stdlib.h> -#include <string.h> -#include <openssl/opensslconf.h> -#include <openssl/ripemd.h> - -/* - * DO EXAMINE COMMENTS IN crypto/md5/md5_local.h & crypto/md5/md5_dgst.c - * FOR EXPLANATIONS ON FOLLOWING "CODE." - */ -#ifdef RMD160_ASM -# if defined(__i386) || defined(__i386__) || defined(_M_IX86) -# define ripemd160_block_data_order ripemd160_block_asm_data_order -# endif -#endif - -void ripemd160_block_data_order(RIPEMD160_CTX *c, const void *p, size_t num); - -#define DATA_ORDER_IS_LITTLE_ENDIAN - -#define HASH_LONG RIPEMD160_LONG -#define HASH_CTX RIPEMD160_CTX -#define HASH_CBLOCK RIPEMD160_CBLOCK -#define HASH_UPDATE RIPEMD160_Update -#define HASH_TRANSFORM RIPEMD160_Transform -#define HASH_FINAL RIPEMD160_Final -#define HASH_MAKE_STRING(c,s) do { \ - unsigned long ll; \ - ll=(c)->A; (void)HOST_l2c(ll,(s)); \ - ll=(c)->B; (void)HOST_l2c(ll,(s)); \ - ll=(c)->C; (void)HOST_l2c(ll,(s)); \ - ll=(c)->D; (void)HOST_l2c(ll,(s)); \ - ll=(c)->E; (void)HOST_l2c(ll,(s)); \ - } while (0) -#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order - -#include "crypto/md32_common.h" - -/* - * Transformed F2 and F4 are courtesy of Wei Dai - */ -#define F1(x,y,z) ((x) ^ (y) ^ (z)) -#define F2(x,y,z) ((((y) ^ (z)) & (x)) ^ (z)) -#define F3(x,y,z) (((~(y)) | (x)) ^ (z)) -#define F4(x,y,z) ((((x) ^ (y)) & (z)) ^ (y)) -#define F5(x,y,z) (((~(z)) | (y)) ^ (x)) - -#define RIPEMD160_A 0x67452301L -#define RIPEMD160_B 0xEFCDAB89L -#define RIPEMD160_C 0x98BADCFEL -#define RIPEMD160_D 0x10325476L -#define RIPEMD160_E 0xC3D2E1F0L - -#include "rmdconst.h" - -#define RIP1(a,b,c,d,e,w,s) { \ - a+=F1(b,c,d)+X(w); \ - a=ROTATE(a,s)+e; \ - c=ROTATE(c,10); } - -#define RIP2(a,b,c,d,e,w,s,K) { \ - a+=F2(b,c,d)+X(w)+K; \ - a=ROTATE(a,s)+e; \ - c=ROTATE(c,10); } - -#define RIP3(a,b,c,d,e,w,s,K) { \ - a+=F3(b,c,d)+X(w)+K; \ - a=ROTATE(a,s)+e; \ - c=ROTATE(c,10); } - -#define RIP4(a,b,c,d,e,w,s,K) { \ - a+=F4(b,c,d)+X(w)+K; \ - a=ROTATE(a,s)+e; \ - c=ROTATE(c,10); } - -#define RIP5(a,b,c,d,e,w,s,K) { \ - a+=F5(b,c,d)+X(w)+K; \ - a=ROTATE(a,s)+e; \ - c=ROTATE(c,10); } +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <stdlib.h> +#include <string.h> +#include <openssl/opensslconf.h> +#include <openssl/ripemd.h> + +/* + * DO EXAMINE COMMENTS IN crypto/md5/md5_local.h & crypto/md5/md5_dgst.c + * FOR EXPLANATIONS ON FOLLOWING "CODE." + */ +#ifdef RMD160_ASM +# if defined(__i386) || defined(__i386__) || defined(_M_IX86) +# define ripemd160_block_data_order ripemd160_block_asm_data_order +# endif +#endif + +void ripemd160_block_data_order(RIPEMD160_CTX *c, const void *p, size_t num); + +#define DATA_ORDER_IS_LITTLE_ENDIAN + +#define HASH_LONG RIPEMD160_LONG +#define HASH_CTX RIPEMD160_CTX +#define HASH_CBLOCK RIPEMD160_CBLOCK +#define HASH_UPDATE RIPEMD160_Update +#define HASH_TRANSFORM RIPEMD160_Transform +#define HASH_FINAL RIPEMD160_Final +#define HASH_MAKE_STRING(c,s) do { \ + unsigned long ll; \ + ll=(c)->A; (void)HOST_l2c(ll,(s)); \ + ll=(c)->B; (void)HOST_l2c(ll,(s)); \ + ll=(c)->C; (void)HOST_l2c(ll,(s)); \ + ll=(c)->D; (void)HOST_l2c(ll,(s)); \ + ll=(c)->E; (void)HOST_l2c(ll,(s)); \ + } while (0) +#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order + +#include "crypto/md32_common.h" + +/* + * Transformed F2 and F4 are courtesy of Wei Dai + */ +#define F1(x,y,z) ((x) ^ (y) ^ (z)) +#define F2(x,y,z) ((((y) ^ (z)) & (x)) ^ (z)) +#define F3(x,y,z) (((~(y)) | (x)) ^ (z)) +#define F4(x,y,z) ((((x) ^ (y)) & (z)) ^ (y)) +#define F5(x,y,z) (((~(z)) | (y)) ^ (x)) + +#define RIPEMD160_A 0x67452301L +#define RIPEMD160_B 0xEFCDAB89L +#define RIPEMD160_C 0x98BADCFEL +#define RIPEMD160_D 0x10325476L +#define RIPEMD160_E 0xC3D2E1F0L + +#include "rmdconst.h" + +#define RIP1(a,b,c,d,e,w,s) { \ + a+=F1(b,c,d)+X(w); \ + a=ROTATE(a,s)+e; \ + c=ROTATE(c,10); } + +#define RIP2(a,b,c,d,e,w,s,K) { \ + a+=F2(b,c,d)+X(w)+K; \ + a=ROTATE(a,s)+e; \ + c=ROTATE(c,10); } + +#define RIP3(a,b,c,d,e,w,s,K) { \ + a+=F3(b,c,d)+X(w)+K; \ + a=ROTATE(a,s)+e; \ + c=ROTATE(c,10); } + +#define RIP4(a,b,c,d,e,w,s,K) { \ + a+=F4(b,c,d)+X(w)+K; \ + a=ROTATE(a,s)+e; \ + c=ROTATE(c,10); } + +#define RIP5(a,b,c,d,e,w,s,K) { \ + a+=F5(b,c,d)+X(w)+K; \ + a=ROTATE(a,s)+e; \ + c=ROTATE(c,10); } diff --git a/contrib/libs/openssl/crypto/rsa/rsa_ameth.c b/contrib/libs/openssl/crypto/rsa/rsa_ameth.c index d9be23806c..fb045544a8 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_ameth.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_ameth.c @@ -13,9 +13,9 @@ #include <openssl/x509.h> #include <openssl/bn.h> #include <openssl/cms.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" -#include "rsa_local.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" +#include "rsa_local.h" #ifndef OPENSSL_NO_CMS static int rsa_cms_sign(CMS_SignerInfo *si); diff --git a/contrib/libs/openssl/crypto/rsa/rsa_asn1.c b/contrib/libs/openssl/crypto/rsa/rsa_asn1.c index d7b460b12c..e8df8d762e 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_asn1.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_asn1.c @@ -12,7 +12,7 @@ #include <openssl/bn.h> #include <openssl/x509.h> #include <openssl/asn1t.h> -#include "rsa_local.h" +#include "rsa_local.h" /* * Override the default free and new methods, diff --git a/contrib/libs/openssl/crypto/rsa/rsa_chk.c b/contrib/libs/openssl/crypto/rsa/rsa_chk.c index bce4a58aef..b4ba7fce3f 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_chk.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_chk.c @@ -9,7 +9,7 @@ #include <openssl/bn.h> #include <openssl/err.h> -#include "rsa_local.h" +#include "rsa_local.h" int RSA_check_key(const RSA *key) { diff --git a/contrib/libs/openssl/crypto/rsa/rsa_crpt.c b/contrib/libs/openssl/crypto/rsa/rsa_crpt.c index ddf2f77b59..f1131ce9e0 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_crpt.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_crpt.c @@ -10,9 +10,9 @@ #include <stdio.h> #include <openssl/crypto.h> #include "internal/cryptlib.h" -#include "crypto/bn.h" +#include "crypto/bn.h" #include <openssl/rand.h> -#include "rsa_local.h" +#include "rsa_local.h" int RSA_bits(const RSA *r) { diff --git a/contrib/libs/openssl/crypto/rsa/rsa_gen.c b/contrib/libs/openssl/crypto/rsa/rsa_gen.c index 2efebce424..29056a62a1 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_gen.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_gen.c @@ -17,7 +17,7 @@ #include <time.h> #include "internal/cryptlib.h" #include <openssl/bn.h> -#include "rsa_local.h" +#include "rsa_local.h" static int rsa_builtin_keygen(RSA *rsa, int bits, int primes, BIGNUM *e_value, BN_GENCB *cb); diff --git a/contrib/libs/openssl/crypto/rsa/rsa_lib.c b/contrib/libs/openssl/crypto/rsa/rsa_lib.c index 565483d3be..63fd1a6db4 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_lib.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_lib.c @@ -11,11 +11,11 @@ #include <openssl/crypto.h> #include "internal/cryptlib.h" #include "internal/refcount.h" -#include "crypto/bn.h" +#include "crypto/bn.h" #include <openssl/engine.h> #include <openssl/evp.h> -#include "crypto/evp.h" -#include "rsa_local.h" +#include "crypto/evp.h" +#include "rsa_local.h" RSA *RSA_new(void) { @@ -451,11 +451,11 @@ const BIGNUM *RSA_get0_iqmp(const RSA *r) return r->iqmp; } -const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r) -{ - return r->pss; -} - +const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r) +{ + return r->pss; +} + void RSA_clear_flags(RSA *r, int flags) { r->flags &= ~flags; diff --git a/contrib/libs/openssl/crypto/rsa/rsa_local.h b/contrib/libs/openssl/crypto/rsa/rsa_local.h index 1bbf22c597..2b94462a94 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_local.h +++ b/contrib/libs/openssl/crypto/rsa/rsa_local.h @@ -1,132 +1,132 @@ -/* - * Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <openssl/rsa.h> -#include "internal/refcount.h" - -#define RSA_MAX_PRIME_NUM 5 -#define RSA_MIN_MODULUS_BITS 512 - -typedef struct rsa_prime_info_st { - BIGNUM *r; - BIGNUM *d; - BIGNUM *t; - /* save product of primes prior to this one */ - BIGNUM *pp; - BN_MONT_CTX *m; -} RSA_PRIME_INFO; - -DECLARE_ASN1_ITEM(RSA_PRIME_INFO) -DEFINE_STACK_OF(RSA_PRIME_INFO) - -struct rsa_st { - /* - * The first parameter is used to pickup errors where this is passed - * instead of an EVP_PKEY, it is set to 0 - */ - int pad; - int32_t version; - const RSA_METHOD *meth; - /* functional reference if 'meth' is ENGINE-provided */ - ENGINE *engine; - BIGNUM *n; - BIGNUM *e; - BIGNUM *d; - BIGNUM *p; - BIGNUM *q; - BIGNUM *dmp1; - BIGNUM *dmq1; - BIGNUM *iqmp; - /* for multi-prime RSA, defined in RFC 8017 */ - STACK_OF(RSA_PRIME_INFO) *prime_infos; - /* If a PSS only key this contains the parameter restrictions */ - RSA_PSS_PARAMS *pss; - /* be careful using this if the RSA structure is shared */ - CRYPTO_EX_DATA ex_data; - CRYPTO_REF_COUNT references; - int flags; - /* Used to cache montgomery values */ - BN_MONT_CTX *_method_mod_n; - BN_MONT_CTX *_method_mod_p; - BN_MONT_CTX *_method_mod_q; - /* - * all BIGNUM values are actually in the following data, if it is not - * NULL - */ - char *bignum_data; - BN_BLINDING *blinding; - BN_BLINDING *mt_blinding; - CRYPTO_RWLOCK *lock; -}; - -struct rsa_meth_st { - char *name; - int (*rsa_pub_enc) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); - int (*rsa_pub_dec) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); - int (*rsa_priv_enc) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); - int (*rsa_priv_dec) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); - /* Can be null */ - int (*rsa_mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); - /* Can be null */ - int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); - /* called at new */ - int (*init) (RSA *rsa); - /* called at free */ - int (*finish) (RSA *rsa); - /* RSA_METHOD_FLAG_* things */ - int flags; - /* may be needed! */ - char *app_data; - /* - * New sign and verify functions: some libraries don't allow arbitrary - * data to be signed/verified: this allows them to be used. Note: for - * this to work the RSA_public_decrypt() and RSA_private_encrypt() should - * *NOT* be used RSA_sign(), RSA_verify() should be used instead. - */ - int (*rsa_sign) (int type, - const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, - const RSA *rsa); - int (*rsa_verify) (int dtype, const unsigned char *m, - unsigned int m_length, const unsigned char *sigbuf, - unsigned int siglen, const RSA *rsa); - /* - * If this callback is NULL, the builtin software RSA key-gen will be - * used. This is for behavioural compatibility whilst the code gets - * rewired, but one day it would be nice to assume there are no such - * things as "builtin software" implementations. - */ - int (*rsa_keygen) (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); - int (*rsa_multi_prime_keygen) (RSA *rsa, int bits, int primes, - BIGNUM *e, BN_GENCB *cb); -}; - -extern int int_rsa_verify(int dtype, const unsigned char *m, - unsigned int m_len, unsigned char *rm, - size_t *prm_len, const unsigned char *sigbuf, - size_t siglen, RSA *rsa); -/* Macros to test if a pkey or ctx is for a PSS key */ -#define pkey_is_pss(pkey) (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS) -#define pkey_ctx_is_pss(ctx) (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS) - -RSA_PSS_PARAMS *rsa_pss_params_create(const EVP_MD *sigmd, - const EVP_MD *mgf1md, int saltlen); -int rsa_pss_get_param(const RSA_PSS_PARAMS *pss, const EVP_MD **pmd, - const EVP_MD **pmgf1md, int *psaltlen); -/* internal function to clear and free multi-prime parameters */ -void rsa_multip_info_free_ex(RSA_PRIME_INFO *pinfo); -void rsa_multip_info_free(RSA_PRIME_INFO *pinfo); -RSA_PRIME_INFO *rsa_multip_info_new(void); -int rsa_multip_calc_product(RSA *rsa); -int rsa_multip_cap(int bits); +/* + * Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <openssl/rsa.h> +#include "internal/refcount.h" + +#define RSA_MAX_PRIME_NUM 5 +#define RSA_MIN_MODULUS_BITS 512 + +typedef struct rsa_prime_info_st { + BIGNUM *r; + BIGNUM *d; + BIGNUM *t; + /* save product of primes prior to this one */ + BIGNUM *pp; + BN_MONT_CTX *m; +} RSA_PRIME_INFO; + +DECLARE_ASN1_ITEM(RSA_PRIME_INFO) +DEFINE_STACK_OF(RSA_PRIME_INFO) + +struct rsa_st { + /* + * The first parameter is used to pickup errors where this is passed + * instead of an EVP_PKEY, it is set to 0 + */ + int pad; + int32_t version; + const RSA_METHOD *meth; + /* functional reference if 'meth' is ENGINE-provided */ + ENGINE *engine; + BIGNUM *n; + BIGNUM *e; + BIGNUM *d; + BIGNUM *p; + BIGNUM *q; + BIGNUM *dmp1; + BIGNUM *dmq1; + BIGNUM *iqmp; + /* for multi-prime RSA, defined in RFC 8017 */ + STACK_OF(RSA_PRIME_INFO) *prime_infos; + /* If a PSS only key this contains the parameter restrictions */ + RSA_PSS_PARAMS *pss; + /* be careful using this if the RSA structure is shared */ + CRYPTO_EX_DATA ex_data; + CRYPTO_REF_COUNT references; + int flags; + /* Used to cache montgomery values */ + BN_MONT_CTX *_method_mod_n; + BN_MONT_CTX *_method_mod_p; + BN_MONT_CTX *_method_mod_q; + /* + * all BIGNUM values are actually in the following data, if it is not + * NULL + */ + char *bignum_data; + BN_BLINDING *blinding; + BN_BLINDING *mt_blinding; + CRYPTO_RWLOCK *lock; +}; + +struct rsa_meth_st { + char *name; + int (*rsa_pub_enc) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, int padding); + int (*rsa_pub_dec) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, int padding); + int (*rsa_priv_enc) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, int padding); + int (*rsa_priv_dec) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, int padding); + /* Can be null */ + int (*rsa_mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); + /* Can be null */ + int (*bn_mod_exp) (BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); + /* called at new */ + int (*init) (RSA *rsa); + /* called at free */ + int (*finish) (RSA *rsa); + /* RSA_METHOD_FLAG_* things */ + int flags; + /* may be needed! */ + char *app_data; + /* + * New sign and verify functions: some libraries don't allow arbitrary + * data to be signed/verified: this allows them to be used. Note: for + * this to work the RSA_public_decrypt() and RSA_private_encrypt() should + * *NOT* be used RSA_sign(), RSA_verify() should be used instead. + */ + int (*rsa_sign) (int type, + const unsigned char *m, unsigned int m_length, + unsigned char *sigret, unsigned int *siglen, + const RSA *rsa); + int (*rsa_verify) (int dtype, const unsigned char *m, + unsigned int m_length, const unsigned char *sigbuf, + unsigned int siglen, const RSA *rsa); + /* + * If this callback is NULL, the builtin software RSA key-gen will be + * used. This is for behavioural compatibility whilst the code gets + * rewired, but one day it would be nice to assume there are no such + * things as "builtin software" implementations. + */ + int (*rsa_keygen) (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); + int (*rsa_multi_prime_keygen) (RSA *rsa, int bits, int primes, + BIGNUM *e, BN_GENCB *cb); +}; + +extern int int_rsa_verify(int dtype, const unsigned char *m, + unsigned int m_len, unsigned char *rm, + size_t *prm_len, const unsigned char *sigbuf, + size_t siglen, RSA *rsa); +/* Macros to test if a pkey or ctx is for a PSS key */ +#define pkey_is_pss(pkey) (pkey->ameth->pkey_id == EVP_PKEY_RSA_PSS) +#define pkey_ctx_is_pss(ctx) (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS) + +RSA_PSS_PARAMS *rsa_pss_params_create(const EVP_MD *sigmd, + const EVP_MD *mgf1md, int saltlen); +int rsa_pss_get_param(const RSA_PSS_PARAMS *pss, const EVP_MD **pmd, + const EVP_MD **pmgf1md, int *psaltlen); +/* internal function to clear and free multi-prime parameters */ +void rsa_multip_info_free_ex(RSA_PRIME_INFO *pinfo); +void rsa_multip_info_free(RSA_PRIME_INFO *pinfo); +RSA_PRIME_INFO *rsa_multip_info_new(void); +int rsa_multip_calc_product(RSA *rsa); +int rsa_multip_cap(int bits); diff --git a/contrib/libs/openssl/crypto/rsa/rsa_meth.c b/contrib/libs/openssl/crypto/rsa/rsa_meth.c index 3159602fde..2845b79db8 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_meth.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_meth.c @@ -8,7 +8,7 @@ */ #include <string.h> -#include "rsa_local.h" +#include "rsa_local.h" #include <openssl/err.h> RSA_METHOD *RSA_meth_new(const char *name, int flags) diff --git a/contrib/libs/openssl/crypto/rsa/rsa_mp.c b/contrib/libs/openssl/crypto/rsa/rsa_mp.c index b71ce77bb9..44dda8f800 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_mp.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_mp.c @@ -10,7 +10,7 @@ #include <openssl/bn.h> #include <openssl/err.h> -#include "rsa_local.h" +#include "rsa_local.h" void rsa_multip_info_free_ex(RSA_PRIME_INFO *pinfo) { diff --git a/contrib/libs/openssl/crypto/rsa/rsa_oaep.c b/contrib/libs/openssl/crypto/rsa/rsa_oaep.c index ca72893053..302360a964 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_oaep.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_oaep.c @@ -20,7 +20,7 @@ * one-wayness. For the RSA function, this is an equivalent notion. */ -#include "internal/constant_time.h" +#include "internal/constant_time.h" #include <stdio.h> #include "internal/cryptlib.h" @@ -28,7 +28,7 @@ #include <openssl/evp.h> #include <openssl/rand.h> #include <openssl/sha.h> -#include "rsa_local.h" +#include "rsa_local.h" int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, const unsigned char *from, int flen, diff --git a/contrib/libs/openssl/crypto/rsa/rsa_ossl.c b/contrib/libs/openssl/crypto/rsa/rsa_ossl.c index 3cafc8e6c5..b52a66f6a6 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_ossl.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_ossl.c @@ -8,9 +8,9 @@ */ #include "internal/cryptlib.h" -#include "crypto/bn.h" -#include "rsa_local.h" -#include "internal/constant_time.h" +#include "crypto/bn.h" +#include "rsa_local.h" +#include "internal/constant_time.h" static int rsa_ossl_public_encrypt(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding); diff --git a/contrib/libs/openssl/crypto/rsa/rsa_pk1.c b/contrib/libs/openssl/crypto/rsa/rsa_pk1.c index a52e91f717..a3d0b7cef8 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_pk1.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_pk1.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "internal/constant_time.h" +#include "internal/constant_time.h" #include <stdio.h> #include "internal/cryptlib.h" @@ -57,7 +57,7 @@ int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, * D - data. */ - if (num < RSA_PKCS1_PADDING_SIZE) + if (num < RSA_PKCS1_PADDING_SIZE) return -1; /* Accept inputs with and without the leading 0-byte. */ @@ -120,7 +120,7 @@ int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, int i, j; unsigned char *p; - if (flen > (tlen - RSA_PKCS1_PADDING_SIZE)) { + if (flen > (tlen - RSA_PKCS1_PADDING_SIZE)) { RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); return 0; @@ -169,7 +169,7 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, * section 7.2.2. */ - if (flen > num || num < RSA_PKCS1_PADDING_SIZE) { + if (flen > num || num < RSA_PKCS1_PADDING_SIZE) { RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2, RSA_R_PKCS_DECODING_ERROR); return -1; @@ -226,8 +226,8 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, good &= constant_time_ge(tlen, mlen); /* - * Move the result in-place by |num|-RSA_PKCS1_PADDING_SIZE-|mlen| bytes to the left. - * Then if |good| move |mlen| bytes from |em|+RSA_PKCS1_PADDING_SIZE to |to|. + * Move the result in-place by |num|-RSA_PKCS1_PADDING_SIZE-|mlen| bytes to the left. + * Then if |good| move |mlen| bytes from |em|+RSA_PKCS1_PADDING_SIZE to |to|. * Otherwise leave |to| unchanged. * Copy the memory back in a way that does not reveal the size of * the data being copied via a timing side channel. This requires copying @@ -235,16 +235,16 @@ int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, * length. Clear bits do a non-copy with identical access pattern. * The loop below has overall complexity of O(N*log(N)). */ - tlen = constant_time_select_int(constant_time_lt(num - RSA_PKCS1_PADDING_SIZE, tlen), - num - RSA_PKCS1_PADDING_SIZE, tlen); - for (msg_index = 1; msg_index < num - RSA_PKCS1_PADDING_SIZE; msg_index <<= 1) { - mask = ~constant_time_eq(msg_index & (num - RSA_PKCS1_PADDING_SIZE - mlen), 0); - for (i = RSA_PKCS1_PADDING_SIZE; i < num - msg_index; i++) + tlen = constant_time_select_int(constant_time_lt(num - RSA_PKCS1_PADDING_SIZE, tlen), + num - RSA_PKCS1_PADDING_SIZE, tlen); + for (msg_index = 1; msg_index < num - RSA_PKCS1_PADDING_SIZE; msg_index <<= 1) { + mask = ~constant_time_eq(msg_index & (num - RSA_PKCS1_PADDING_SIZE - mlen), 0); + for (i = RSA_PKCS1_PADDING_SIZE; i < num - msg_index; i++) em[i] = constant_time_select_8(mask, em[i + msg_index], em[i]); } for (i = 0; i < tlen; i++) { mask = good & constant_time_lt(i, mlen); - to[i] = constant_time_select_8(mask, em[i + RSA_PKCS1_PADDING_SIZE], to[i]); + to[i] = constant_time_select_8(mask, em[i + RSA_PKCS1_PADDING_SIZE], to[i]); } OPENSSL_clear_free(em, num); diff --git a/contrib/libs/openssl/crypto/rsa/rsa_pmeth.c b/contrib/libs/openssl/crypto/rsa/rsa_pmeth.c index b66199b94f..0eb21c8af9 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_pmeth.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_pmeth.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "internal/constant_time.h" +#include "internal/constant_time.h" #include <stdio.h> #include "internal/cryptlib.h" @@ -18,8 +18,8 @@ #include <openssl/evp.h> #include <openssl/x509v3.h> #include <openssl/cms.h> -#include "crypto/evp.h" -#include "rsa_local.h" +#include "crypto/evp.h" +#include "rsa_local.h" /* RSA pkey context structure */ diff --git a/contrib/libs/openssl/crypto/rsa/rsa_pss.c b/contrib/libs/openssl/crypto/rsa/rsa_pss.c index 58261d937a..40ce1c4d37 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_pss.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_pss.c @@ -14,7 +14,7 @@ #include <openssl/evp.h> #include <openssl/rand.h> #include <openssl/sha.h> -#include "rsa_local.h" +#include "rsa_local.h" static const unsigned char zeroes[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; diff --git a/contrib/libs/openssl/crypto/rsa/rsa_sign.c b/contrib/libs/openssl/crypto/rsa/rsa_sign.c index d807d27f4d..7fc69361bf 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_sign.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_sign.c @@ -13,8 +13,8 @@ #include <openssl/rsa.h> #include <openssl/objects.h> #include <openssl/x509.h> -#include "crypto/x509.h" -#include "rsa_local.h" +#include "crypto/x509.h" +#include "rsa_local.h" /* Size of an SSL signature: MD5+SHA1 */ #define SSL_SIG_LENGTH 36 diff --git a/contrib/libs/openssl/crypto/rsa/rsa_ssl.c b/contrib/libs/openssl/crypto/rsa/rsa_ssl.c index a390e5198a..e1c755ae46 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_ssl.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_ssl.c @@ -12,7 +12,7 @@ #include <openssl/bn.h> #include <openssl/rsa.h> #include <openssl/rand.h> -#include "internal/constant_time.h" +#include "internal/constant_time.h" int RSA_padding_add_SSLv23(unsigned char *to, int tlen, const unsigned char *from, int flen) @@ -20,7 +20,7 @@ int RSA_padding_add_SSLv23(unsigned char *to, int tlen, int i, j; unsigned char *p; - if (flen > (tlen - RSA_PKCS1_PADDING_SIZE)) { + if (flen > (tlen - RSA_PKCS1_PADDING_SIZE)) { RSAerr(RSA_F_RSA_PADDING_ADD_SSLV23, RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); return 0; @@ -70,7 +70,7 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, if (tlen <= 0 || flen <= 0) return -1; - if (flen > num || num < RSA_PKCS1_PADDING_SIZE) { + if (flen > num || num < RSA_PKCS1_PADDING_SIZE) { RSAerr(RSA_F_RSA_PADDING_CHECK_SSLV23, RSA_R_DATA_TOO_SMALL); return -1; } @@ -147,8 +147,8 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, err = constant_time_select_int(mask | good, err, RSA_R_DATA_TOO_LARGE); /* - * Move the result in-place by |num|-RSA_PKCS1_PADDING_SIZE-|mlen| bytes to the left. - * Then if |good| move |mlen| bytes from |em|+RSA_PKCS1_PADDING_SIZE to |to|. + * Move the result in-place by |num|-RSA_PKCS1_PADDING_SIZE-|mlen| bytes to the left. + * Then if |good| move |mlen| bytes from |em|+RSA_PKCS1_PADDING_SIZE to |to|. * Otherwise leave |to| unchanged. * Copy the memory back in a way that does not reveal the size of * the data being copied via a timing side channel. This requires copying @@ -156,16 +156,16 @@ int RSA_padding_check_SSLv23(unsigned char *to, int tlen, * length. Clear bits do a non-copy with identical access pattern. * The loop below has overall complexity of O(N*log(N)). */ - tlen = constant_time_select_int(constant_time_lt(num - RSA_PKCS1_PADDING_SIZE, tlen), - num - RSA_PKCS1_PADDING_SIZE, tlen); - for (msg_index = 1; msg_index < num - RSA_PKCS1_PADDING_SIZE; msg_index <<= 1) { - mask = ~constant_time_eq(msg_index & (num - RSA_PKCS1_PADDING_SIZE - mlen), 0); - for (i = RSA_PKCS1_PADDING_SIZE; i < num - msg_index; i++) + tlen = constant_time_select_int(constant_time_lt(num - RSA_PKCS1_PADDING_SIZE, tlen), + num - RSA_PKCS1_PADDING_SIZE, tlen); + for (msg_index = 1; msg_index < num - RSA_PKCS1_PADDING_SIZE; msg_index <<= 1) { + mask = ~constant_time_eq(msg_index & (num - RSA_PKCS1_PADDING_SIZE - mlen), 0); + for (i = RSA_PKCS1_PADDING_SIZE; i < num - msg_index; i++) em[i] = constant_time_select_8(mask, em[i + msg_index], em[i]); } for (i = 0; i < tlen; i++) { mask = good & constant_time_lt(i, mlen); - to[i] = constant_time_select_8(mask, em[i + RSA_PKCS1_PADDING_SIZE], to[i]); + to[i] = constant_time_select_8(mask, em[i + RSA_PKCS1_PADDING_SIZE], to[i]); } OPENSSL_clear_free(em, num); diff --git a/contrib/libs/openssl/crypto/rsa/rsa_x931g.c b/contrib/libs/openssl/crypto/rsa/rsa_x931g.c index a1828466d0..322cd14a84 100644 --- a/contrib/libs/openssl/crypto/rsa/rsa_x931g.c +++ b/contrib/libs/openssl/crypto/rsa/rsa_x931g.c @@ -12,7 +12,7 @@ #include <time.h> #include <openssl/err.h> #include <openssl/bn.h> -#include "rsa_local.h" +#include "rsa_local.h" /* X9.31 RSA key derivation and generation */ diff --git a/contrib/libs/openssl/crypto/s390x_arch.h b/contrib/libs/openssl/crypto/s390x_arch.h index dab6aeb2be..4d2cc02eb3 100644 --- a/contrib/libs/openssl/crypto/s390x_arch.h +++ b/contrib/libs/openssl/crypto/s390x_arch.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_S390X_ARCH_H -# define OSSL_CRYPTO_S390X_ARCH_H +#ifndef OSSL_CRYPTO_S390X_ARCH_H +# define OSSL_CRYPTO_S390X_ARCH_H # ifndef __ASSEMBLER__ diff --git a/contrib/libs/openssl/crypto/seed/seed.c b/contrib/libs/openssl/crypto/seed/seed.c index 95e71cc898..c3a1f183a5 100644 --- a/contrib/libs/openssl/crypto/seed/seed.c +++ b/contrib/libs/openssl/crypto/seed/seed.c @@ -42,7 +42,7 @@ # endif # include <openssl/seed.h> -# include "seed_local.h" +# include "seed_local.h" # ifdef SS /* can get defined on Solaris by inclusion of * <stdlib.h> */ diff --git a/contrib/libs/openssl/crypto/seed/seed_local.h b/contrib/libs/openssl/crypto/seed/seed_local.h index 036fcceba8..e3681f8bd4 100644 --- a/contrib/libs/openssl/crypto/seed/seed_local.h +++ b/contrib/libs/openssl/crypto/seed/seed_local.h @@ -1,112 +1,112 @@ -/* - * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * Copyright (c) 2007 KISA(Korea Information Security Agency). 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. Neither the name of author nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``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 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. - * - */ -#ifndef OSSL_CRYPTO_SEED_LOCAL_H -# define OSSL_CRYPTO_SEED_LOCAL_H - -# include "openssl/e_os2.h" -# include <openssl/seed.h> - -# ifdef SEED_LONG /* need 32-bit type */ -typedef unsigned long seed_word; -# else -typedef unsigned int seed_word; -# endif - - -# define char2word(c, i) \ - (i) = ((((seed_word)(c)[0]) << 24) | (((seed_word)(c)[1]) << 16) | (((seed_word)(c)[2]) << 8) | ((seed_word)(c)[3])) - -# define word2char(l, c) \ - *((c)+0) = (unsigned char)((l)>>24) & 0xff; \ - *((c)+1) = (unsigned char)((l)>>16) & 0xff; \ - *((c)+2) = (unsigned char)((l)>> 8) & 0xff; \ - *((c)+3) = (unsigned char)((l)) & 0xff - -# define KEYSCHEDULE_UPDATE0(T0, T1, X1, X2, X3, X4, KC) \ - (T0) = (X3); \ - (X3) = (((X3)<<8) ^ ((X4)>>24)) & 0xffffffff; \ - (X4) = (((X4)<<8) ^ ((T0)>>24)) & 0xffffffff; \ - (T0) = ((X1) + (X3) - (KC)) & 0xffffffff; \ - (T1) = ((X2) + (KC) - (X4)) & 0xffffffff - -# define KEYSCHEDULE_UPDATE1(T0, T1, X1, X2, X3, X4, KC) \ - (T0) = (X1); \ - (X1) = (((X1)>>8) ^ ((X2)<<24)) & 0xffffffff; \ - (X2) = (((X2)>>8) ^ ((T0)<<24)) & 0xffffffff; \ - (T0) = ((X1) + (X3) - (KC)) & 0xffffffff; \ - (T1) = ((X2) + (KC) - (X4)) & 0xffffffff - -# define KEYUPDATE_TEMP(T0, T1, K) \ - (K)[0] = G_FUNC((T0)); \ - (K)[1] = G_FUNC((T1)) - -# define XOR_SEEDBLOCK(DST, SRC) \ - ((DST))[0] ^= ((SRC))[0]; \ - ((DST))[1] ^= ((SRC))[1]; \ - ((DST))[2] ^= ((SRC))[2]; \ - ((DST))[3] ^= ((SRC))[3] - -# define MOV_SEEDBLOCK(DST, SRC) \ - ((DST))[0] = ((SRC))[0]; \ - ((DST))[1] = ((SRC))[1]; \ - ((DST))[2] = ((SRC))[2]; \ - ((DST))[3] = ((SRC))[3] - -# define CHAR2WORD(C, I) \ - char2word((C), (I)[0]); \ - char2word((C+4), (I)[1]); \ - char2word((C+8), (I)[2]); \ - char2word((C+12), (I)[3]) - -# define WORD2CHAR(I, C) \ - word2char((I)[0], (C)); \ - word2char((I)[1], (C+4)); \ - word2char((I)[2], (C+8)); \ - word2char((I)[3], (C+12)) - -# define E_SEED(T0, T1, X1, X2, X3, X4, rbase) \ - (T0) = (X3) ^ (ks->data)[(rbase)]; \ - (T1) = (X4) ^ (ks->data)[(rbase)+1]; \ - (T1) ^= (T0); \ - (T1) = G_FUNC((T1)); \ - (T0) = ((T0) + (T1)) & 0xffffffff; \ - (T0) = G_FUNC((T0)); \ - (T1) = ((T1) + (T0)) & 0xffffffff; \ - (T1) = G_FUNC((T1)); \ - (T0) = ((T0) + (T1)) & 0xffffffff; \ - (X1) ^= (T0); \ - (X2) ^= (T1) - -#endif /* OSSL_CRYPTO_SEED_LOCAL_H */ +/* + * Copyright 2007-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * Copyright (c) 2007 KISA(Korea Information Security Agency). 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. Neither the name of author nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``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 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. + * + */ +#ifndef OSSL_CRYPTO_SEED_LOCAL_H +# define OSSL_CRYPTO_SEED_LOCAL_H + +# include "openssl/e_os2.h" +# include <openssl/seed.h> + +# ifdef SEED_LONG /* need 32-bit type */ +typedef unsigned long seed_word; +# else +typedef unsigned int seed_word; +# endif + + +# define char2word(c, i) \ + (i) = ((((seed_word)(c)[0]) << 24) | (((seed_word)(c)[1]) << 16) | (((seed_word)(c)[2]) << 8) | ((seed_word)(c)[3])) + +# define word2char(l, c) \ + *((c)+0) = (unsigned char)((l)>>24) & 0xff; \ + *((c)+1) = (unsigned char)((l)>>16) & 0xff; \ + *((c)+2) = (unsigned char)((l)>> 8) & 0xff; \ + *((c)+3) = (unsigned char)((l)) & 0xff + +# define KEYSCHEDULE_UPDATE0(T0, T1, X1, X2, X3, X4, KC) \ + (T0) = (X3); \ + (X3) = (((X3)<<8) ^ ((X4)>>24)) & 0xffffffff; \ + (X4) = (((X4)<<8) ^ ((T0)>>24)) & 0xffffffff; \ + (T0) = ((X1) + (X3) - (KC)) & 0xffffffff; \ + (T1) = ((X2) + (KC) - (X4)) & 0xffffffff + +# define KEYSCHEDULE_UPDATE1(T0, T1, X1, X2, X3, X4, KC) \ + (T0) = (X1); \ + (X1) = (((X1)>>8) ^ ((X2)<<24)) & 0xffffffff; \ + (X2) = (((X2)>>8) ^ ((T0)<<24)) & 0xffffffff; \ + (T0) = ((X1) + (X3) - (KC)) & 0xffffffff; \ + (T1) = ((X2) + (KC) - (X4)) & 0xffffffff + +# define KEYUPDATE_TEMP(T0, T1, K) \ + (K)[0] = G_FUNC((T0)); \ + (K)[1] = G_FUNC((T1)) + +# define XOR_SEEDBLOCK(DST, SRC) \ + ((DST))[0] ^= ((SRC))[0]; \ + ((DST))[1] ^= ((SRC))[1]; \ + ((DST))[2] ^= ((SRC))[2]; \ + ((DST))[3] ^= ((SRC))[3] + +# define MOV_SEEDBLOCK(DST, SRC) \ + ((DST))[0] = ((SRC))[0]; \ + ((DST))[1] = ((SRC))[1]; \ + ((DST))[2] = ((SRC))[2]; \ + ((DST))[3] = ((SRC))[3] + +# define CHAR2WORD(C, I) \ + char2word((C), (I)[0]); \ + char2word((C+4), (I)[1]); \ + char2word((C+8), (I)[2]); \ + char2word((C+12), (I)[3]) + +# define WORD2CHAR(I, C) \ + word2char((I)[0], (C)); \ + word2char((I)[1], (C+4)); \ + word2char((I)[2], (C+8)); \ + word2char((I)[3], (C+12)) + +# define E_SEED(T0, T1, X1, X2, X3, X4, rbase) \ + (T0) = (X3) ^ (ks->data)[(rbase)]; \ + (T1) = (X4) ^ (ks->data)[(rbase)+1]; \ + (T1) ^= (T0); \ + (T1) = G_FUNC((T1)); \ + (T0) = ((T0) + (T1)) & 0xffffffff; \ + (T0) = G_FUNC((T0)); \ + (T1) = ((T1) + (T0)) & 0xffffffff; \ + (T1) = G_FUNC((T1)); \ + (T0) = ((T0) + (T1)) & 0xffffffff; \ + (X1) ^= (T0); \ + (X2) ^= (T1) + +#endif /* OSSL_CRYPTO_SEED_LOCAL_H */ diff --git a/contrib/libs/openssl/crypto/sha/sha1dgst.c b/contrib/libs/openssl/crypto/sha/sha1dgst.c index aa773caf67..7965829e64 100644 --- a/contrib/libs/openssl/crypto/sha/sha1dgst.c +++ b/contrib/libs/openssl/crypto/sha/sha1dgst.c @@ -14,4 +14,4 @@ /* The implementation is in ../md32_common.h */ -# include "sha_local.h" +# include "sha_local.h" diff --git a/contrib/libs/openssl/crypto/sha/sha256.c b/contrib/libs/openssl/crypto/sha/sha256.c index 3e82607652..11050ba547 100644 --- a/contrib/libs/openssl/crypto/sha/sha256.c +++ b/contrib/libs/openssl/crypto/sha/sha256.c @@ -128,7 +128,7 @@ static #endif void sha256_block_data_order(SHA256_CTX *ctx, const void *in, size_t num); -#include "crypto/md32_common.h" +#include "crypto/md32_common.h" #ifndef SHA256_ASM static const SHA_LONG K256[64] = { diff --git a/contrib/libs/openssl/crypto/sha/sha512.c b/contrib/libs/openssl/crypto/sha/sha512.c index 3204a20059..ca1f387a64 100644 --- a/contrib/libs/openssl/crypto/sha/sha512.c +++ b/contrib/libs/openssl/crypto/sha/sha512.c @@ -50,7 +50,7 @@ #include <openssl/opensslv.h> #include "internal/cryptlib.h" -#include "crypto/sha.h" +#include "crypto/sha.h" #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || \ diff --git a/contrib/libs/openssl/crypto/sha/sha_local.h b/contrib/libs/openssl/crypto/sha/sha_local.h index f7246c755d..6edb9ef1d2 100644 --- a/contrib/libs/openssl/crypto/sha/sha_local.h +++ b/contrib/libs/openssl/crypto/sha/sha_local.h @@ -1,424 +1,424 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <stdlib.h> -#include <string.h> - -#include <openssl/opensslconf.h> -#include <openssl/sha.h> - -#define DATA_ORDER_IS_BIG_ENDIAN - -#define HASH_LONG SHA_LONG -#define HASH_CTX SHA_CTX -#define HASH_CBLOCK SHA_CBLOCK -#define HASH_MAKE_STRING(c,s) do { \ - unsigned long ll; \ - ll=(c)->h0; (void)HOST_l2c(ll,(s)); \ - ll=(c)->h1; (void)HOST_l2c(ll,(s)); \ - ll=(c)->h2; (void)HOST_l2c(ll,(s)); \ - ll=(c)->h3; (void)HOST_l2c(ll,(s)); \ - ll=(c)->h4; (void)HOST_l2c(ll,(s)); \ - } while (0) - -#define HASH_UPDATE SHA1_Update -#define HASH_TRANSFORM SHA1_Transform -#define HASH_FINAL SHA1_Final -#define HASH_INIT SHA1_Init -#define HASH_BLOCK_DATA_ORDER sha1_block_data_order -#define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \ - ix=(a)=ROTATE((a),1) \ - ) - -#ifndef SHA1_ASM -static void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num); -#else -void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num); -#endif - -#include "crypto/md32_common.h" - -#define INIT_DATA_h0 0x67452301UL -#define INIT_DATA_h1 0xefcdab89UL -#define INIT_DATA_h2 0x98badcfeUL -#define INIT_DATA_h3 0x10325476UL -#define INIT_DATA_h4 0xc3d2e1f0UL - -int HASH_INIT(SHA_CTX *c) -{ - memset(c, 0, sizeof(*c)); - c->h0 = INIT_DATA_h0; - c->h1 = INIT_DATA_h1; - c->h2 = INIT_DATA_h2; - c->h3 = INIT_DATA_h3; - c->h4 = INIT_DATA_h4; - return 1; -} - -#define K_00_19 0x5a827999UL -#define K_20_39 0x6ed9eba1UL -#define K_40_59 0x8f1bbcdcUL -#define K_60_79 0xca62c1d6UL - -/* - * As pointed out by Wei Dai, F() below can be simplified to the code in - * F_00_19. Wei attributes these optimizations to Peter Gutmann's SHS code, - * and he attributes it to Rich Schroeppel. - * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) - * I've just become aware of another tweak to be made, again from Wei Dai, - * in F_40_59, (x&a)|(y&a) -> (x|y)&a - */ -#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) -#define F_20_39(b,c,d) ((b) ^ (c) ^ (d)) -#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d))) -#define F_60_79(b,c,d) F_20_39(b,c,d) - -#ifndef OPENSSL_SMALL_FOOTPRINT - -# define BODY_00_15(i,a,b,c,d,e,f,xi) \ - (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ - (b)=ROTATE((b),30); - -# define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \ - Xupdate(f,xi,xa,xb,xc,xd); \ - (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ - (b)=ROTATE((b),30); - -# define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \ - Xupdate(f,xi,xa,xb,xc,xd); \ - (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ - (b)=ROTATE((b),30); - -# define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \ - Xupdate(f,xa,xa,xb,xc,xd); \ - (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ - (b)=ROTATE((b),30); - -# define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \ - Xupdate(f,xa,xa,xb,xc,xd); \ - (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \ - (b)=ROTATE((b),30); - -# define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \ - Xupdate(f,xa,xa,xb,xc,xd); \ - (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ - (b)=ROTATE((b),30); - -# ifdef X -# undef X -# endif -# ifndef MD32_XARRAY - /* - * Originally X was an array. As it's automatic it's natural - * to expect RISC compiler to accommodate at least part of it in - * the register bank, isn't it? Unfortunately not all compilers - * "find" this expectation reasonable:-( On order to make such - * compilers generate better code I replace X[] with a bunch of - * X0, X1, etc. See the function body below... - */ -# define X(i) XX##i -# else - /* - * However! Some compilers (most notably HP C) get overwhelmed by - * that many local variables so that we have to have the way to - * fall down to the original behavior. - */ -# define X(i) XX[i] -# endif - -# if !defined(SHA1_ASM) -static void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num) -{ - const unsigned char *data = p; - register unsigned MD32_REG_T A, B, C, D, E, T, l; -# ifndef MD32_XARRAY - unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, - XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; -# else - SHA_LONG XX[16]; -# endif - - A = c->h0; - B = c->h1; - C = c->h2; - D = c->h3; - E = c->h4; - - for (;;) { - const union { - long one; - char little; - } is_endian = { - 1 - }; - - if (!is_endian.little && sizeof(SHA_LONG) == 4 - && ((size_t)p % 4) == 0) { - const SHA_LONG *W = (const SHA_LONG *)data; - - X(0) = W[0]; - X(1) = W[1]; - BODY_00_15(0, A, B, C, D, E, T, X(0)); - X(2) = W[2]; - BODY_00_15(1, T, A, B, C, D, E, X(1)); - X(3) = W[3]; - BODY_00_15(2, E, T, A, B, C, D, X(2)); - X(4) = W[4]; - BODY_00_15(3, D, E, T, A, B, C, X(3)); - X(5) = W[5]; - BODY_00_15(4, C, D, E, T, A, B, X(4)); - X(6) = W[6]; - BODY_00_15(5, B, C, D, E, T, A, X(5)); - X(7) = W[7]; - BODY_00_15(6, A, B, C, D, E, T, X(6)); - X(8) = W[8]; - BODY_00_15(7, T, A, B, C, D, E, X(7)); - X(9) = W[9]; - BODY_00_15(8, E, T, A, B, C, D, X(8)); - X(10) = W[10]; - BODY_00_15(9, D, E, T, A, B, C, X(9)); - X(11) = W[11]; - BODY_00_15(10, C, D, E, T, A, B, X(10)); - X(12) = W[12]; - BODY_00_15(11, B, C, D, E, T, A, X(11)); - X(13) = W[13]; - BODY_00_15(12, A, B, C, D, E, T, X(12)); - X(14) = W[14]; - BODY_00_15(13, T, A, B, C, D, E, X(13)); - X(15) = W[15]; - BODY_00_15(14, E, T, A, B, C, D, X(14)); - BODY_00_15(15, D, E, T, A, B, C, X(15)); - - data += SHA_CBLOCK; - } else { - (void)HOST_c2l(data, l); - X(0) = l; - (void)HOST_c2l(data, l); - X(1) = l; - BODY_00_15(0, A, B, C, D, E, T, X(0)); - (void)HOST_c2l(data, l); - X(2) = l; - BODY_00_15(1, T, A, B, C, D, E, X(1)); - (void)HOST_c2l(data, l); - X(3) = l; - BODY_00_15(2, E, T, A, B, C, D, X(2)); - (void)HOST_c2l(data, l); - X(4) = l; - BODY_00_15(3, D, E, T, A, B, C, X(3)); - (void)HOST_c2l(data, l); - X(5) = l; - BODY_00_15(4, C, D, E, T, A, B, X(4)); - (void)HOST_c2l(data, l); - X(6) = l; - BODY_00_15(5, B, C, D, E, T, A, X(5)); - (void)HOST_c2l(data, l); - X(7) = l; - BODY_00_15(6, A, B, C, D, E, T, X(6)); - (void)HOST_c2l(data, l); - X(8) = l; - BODY_00_15(7, T, A, B, C, D, E, X(7)); - (void)HOST_c2l(data, l); - X(9) = l; - BODY_00_15(8, E, T, A, B, C, D, X(8)); - (void)HOST_c2l(data, l); - X(10) = l; - BODY_00_15(9, D, E, T, A, B, C, X(9)); - (void)HOST_c2l(data, l); - X(11) = l; - BODY_00_15(10, C, D, E, T, A, B, X(10)); - (void)HOST_c2l(data, l); - X(12) = l; - BODY_00_15(11, B, C, D, E, T, A, X(11)); - (void)HOST_c2l(data, l); - X(13) = l; - BODY_00_15(12, A, B, C, D, E, T, X(12)); - (void)HOST_c2l(data, l); - X(14) = l; - BODY_00_15(13, T, A, B, C, D, E, X(13)); - (void)HOST_c2l(data, l); - X(15) = l; - BODY_00_15(14, E, T, A, B, C, D, X(14)); - BODY_00_15(15, D, E, T, A, B, C, X(15)); - } - - BODY_16_19(16, C, D, E, T, A, B, X(0), X(0), X(2), X(8), X(13)); - BODY_16_19(17, B, C, D, E, T, A, X(1), X(1), X(3), X(9), X(14)); - BODY_16_19(18, A, B, C, D, E, T, X(2), X(2), X(4), X(10), X(15)); - BODY_16_19(19, T, A, B, C, D, E, X(3), X(3), X(5), X(11), X(0)); - - BODY_20_31(20, E, T, A, B, C, D, X(4), X(4), X(6), X(12), X(1)); - BODY_20_31(21, D, E, T, A, B, C, X(5), X(5), X(7), X(13), X(2)); - BODY_20_31(22, C, D, E, T, A, B, X(6), X(6), X(8), X(14), X(3)); - BODY_20_31(23, B, C, D, E, T, A, X(7), X(7), X(9), X(15), X(4)); - BODY_20_31(24, A, B, C, D, E, T, X(8), X(8), X(10), X(0), X(5)); - BODY_20_31(25, T, A, B, C, D, E, X(9), X(9), X(11), X(1), X(6)); - BODY_20_31(26, E, T, A, B, C, D, X(10), X(10), X(12), X(2), X(7)); - BODY_20_31(27, D, E, T, A, B, C, X(11), X(11), X(13), X(3), X(8)); - BODY_20_31(28, C, D, E, T, A, B, X(12), X(12), X(14), X(4), X(9)); - BODY_20_31(29, B, C, D, E, T, A, X(13), X(13), X(15), X(5), X(10)); - BODY_20_31(30, A, B, C, D, E, T, X(14), X(14), X(0), X(6), X(11)); - BODY_20_31(31, T, A, B, C, D, E, X(15), X(15), X(1), X(7), X(12)); - - BODY_32_39(32, E, T, A, B, C, D, X(0), X(2), X(8), X(13)); - BODY_32_39(33, D, E, T, A, B, C, X(1), X(3), X(9), X(14)); - BODY_32_39(34, C, D, E, T, A, B, X(2), X(4), X(10), X(15)); - BODY_32_39(35, B, C, D, E, T, A, X(3), X(5), X(11), X(0)); - BODY_32_39(36, A, B, C, D, E, T, X(4), X(6), X(12), X(1)); - BODY_32_39(37, T, A, B, C, D, E, X(5), X(7), X(13), X(2)); - BODY_32_39(38, E, T, A, B, C, D, X(6), X(8), X(14), X(3)); - BODY_32_39(39, D, E, T, A, B, C, X(7), X(9), X(15), X(4)); - - BODY_40_59(40, C, D, E, T, A, B, X(8), X(10), X(0), X(5)); - BODY_40_59(41, B, C, D, E, T, A, X(9), X(11), X(1), X(6)); - BODY_40_59(42, A, B, C, D, E, T, X(10), X(12), X(2), X(7)); - BODY_40_59(43, T, A, B, C, D, E, X(11), X(13), X(3), X(8)); - BODY_40_59(44, E, T, A, B, C, D, X(12), X(14), X(4), X(9)); - BODY_40_59(45, D, E, T, A, B, C, X(13), X(15), X(5), X(10)); - BODY_40_59(46, C, D, E, T, A, B, X(14), X(0), X(6), X(11)); - BODY_40_59(47, B, C, D, E, T, A, X(15), X(1), X(7), X(12)); - BODY_40_59(48, A, B, C, D, E, T, X(0), X(2), X(8), X(13)); - BODY_40_59(49, T, A, B, C, D, E, X(1), X(3), X(9), X(14)); - BODY_40_59(50, E, T, A, B, C, D, X(2), X(4), X(10), X(15)); - BODY_40_59(51, D, E, T, A, B, C, X(3), X(5), X(11), X(0)); - BODY_40_59(52, C, D, E, T, A, B, X(4), X(6), X(12), X(1)); - BODY_40_59(53, B, C, D, E, T, A, X(5), X(7), X(13), X(2)); - BODY_40_59(54, A, B, C, D, E, T, X(6), X(8), X(14), X(3)); - BODY_40_59(55, T, A, B, C, D, E, X(7), X(9), X(15), X(4)); - BODY_40_59(56, E, T, A, B, C, D, X(8), X(10), X(0), X(5)); - BODY_40_59(57, D, E, T, A, B, C, X(9), X(11), X(1), X(6)); - BODY_40_59(58, C, D, E, T, A, B, X(10), X(12), X(2), X(7)); - BODY_40_59(59, B, C, D, E, T, A, X(11), X(13), X(3), X(8)); - - BODY_60_79(60, A, B, C, D, E, T, X(12), X(14), X(4), X(9)); - BODY_60_79(61, T, A, B, C, D, E, X(13), X(15), X(5), X(10)); - BODY_60_79(62, E, T, A, B, C, D, X(14), X(0), X(6), X(11)); - BODY_60_79(63, D, E, T, A, B, C, X(15), X(1), X(7), X(12)); - BODY_60_79(64, C, D, E, T, A, B, X(0), X(2), X(8), X(13)); - BODY_60_79(65, B, C, D, E, T, A, X(1), X(3), X(9), X(14)); - BODY_60_79(66, A, B, C, D, E, T, X(2), X(4), X(10), X(15)); - BODY_60_79(67, T, A, B, C, D, E, X(3), X(5), X(11), X(0)); - BODY_60_79(68, E, T, A, B, C, D, X(4), X(6), X(12), X(1)); - BODY_60_79(69, D, E, T, A, B, C, X(5), X(7), X(13), X(2)); - BODY_60_79(70, C, D, E, T, A, B, X(6), X(8), X(14), X(3)); - BODY_60_79(71, B, C, D, E, T, A, X(7), X(9), X(15), X(4)); - BODY_60_79(72, A, B, C, D, E, T, X(8), X(10), X(0), X(5)); - BODY_60_79(73, T, A, B, C, D, E, X(9), X(11), X(1), X(6)); - BODY_60_79(74, E, T, A, B, C, D, X(10), X(12), X(2), X(7)); - BODY_60_79(75, D, E, T, A, B, C, X(11), X(13), X(3), X(8)); - BODY_60_79(76, C, D, E, T, A, B, X(12), X(14), X(4), X(9)); - BODY_60_79(77, B, C, D, E, T, A, X(13), X(15), X(5), X(10)); - BODY_60_79(78, A, B, C, D, E, T, X(14), X(0), X(6), X(11)); - BODY_60_79(79, T, A, B, C, D, E, X(15), X(1), X(7), X(12)); - - c->h0 = (c->h0 + E) & 0xffffffffL; - c->h1 = (c->h1 + T) & 0xffffffffL; - c->h2 = (c->h2 + A) & 0xffffffffL; - c->h3 = (c->h3 + B) & 0xffffffffL; - c->h4 = (c->h4 + C) & 0xffffffffL; - - if (--num == 0) - break; - - A = c->h0; - B = c->h1; - C = c->h2; - D = c->h3; - E = c->h4; - - } -} -# endif - -#else /* OPENSSL_SMALL_FOOTPRINT */ - -# define BODY_00_15(xi) do { \ - T=E+K_00_19+F_00_19(B,C,D); \ - E=D, D=C, C=ROTATE(B,30), B=A; \ - A=ROTATE(A,5)+T+xi; } while(0) - -# define BODY_16_19(xa,xb,xc,xd) do { \ - Xupdate(T,xa,xa,xb,xc,xd); \ - T+=E+K_00_19+F_00_19(B,C,D); \ - E=D, D=C, C=ROTATE(B,30), B=A; \ - A=ROTATE(A,5)+T; } while(0) - -# define BODY_20_39(xa,xb,xc,xd) do { \ - Xupdate(T,xa,xa,xb,xc,xd); \ - T+=E+K_20_39+F_20_39(B,C,D); \ - E=D, D=C, C=ROTATE(B,30), B=A; \ - A=ROTATE(A,5)+T; } while(0) - -# define BODY_40_59(xa,xb,xc,xd) do { \ - Xupdate(T,xa,xa,xb,xc,xd); \ - T+=E+K_40_59+F_40_59(B,C,D); \ - E=D, D=C, C=ROTATE(B,30), B=A; \ - A=ROTATE(A,5)+T; } while(0) - -# define BODY_60_79(xa,xb,xc,xd) do { \ - Xupdate(T,xa,xa,xb,xc,xd); \ - T=E+K_60_79+F_60_79(B,C,D); \ - E=D, D=C, C=ROTATE(B,30), B=A; \ - A=ROTATE(A,5)+T+xa; } while(0) - -# if !defined(SHA1_ASM) -static void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num) -{ - const unsigned char *data = p; - register unsigned MD32_REG_T A, B, C, D, E, T, l; - int i; - SHA_LONG X[16]; - - A = c->h0; - B = c->h1; - C = c->h2; - D = c->h3; - E = c->h4; - - for (;;) { - for (i = 0; i < 16; i++) { - (void)HOST_c2l(data, l); - X[i] = l; - BODY_00_15(X[i]); - } - for (i = 0; i < 4; i++) { - BODY_16_19(X[i], X[i + 2], X[i + 8], X[(i + 13) & 15]); - } - for (; i < 24; i++) { - BODY_20_39(X[i & 15], X[(i + 2) & 15], X[(i + 8) & 15], - X[(i + 13) & 15]); - } - for (i = 0; i < 20; i++) { - BODY_40_59(X[(i + 8) & 15], X[(i + 10) & 15], X[i & 15], - X[(i + 5) & 15]); - } - for (i = 4; i < 24; i++) { - BODY_60_79(X[(i + 8) & 15], X[(i + 10) & 15], X[i & 15], - X[(i + 5) & 15]); - } - - c->h0 = (c->h0 + A) & 0xffffffffL; - c->h1 = (c->h1 + B) & 0xffffffffL; - c->h2 = (c->h2 + C) & 0xffffffffL; - c->h3 = (c->h3 + D) & 0xffffffffL; - c->h4 = (c->h4 + E) & 0xffffffffL; - - if (--num == 0) - break; - - A = c->h0; - B = c->h1; - C = c->h2; - D = c->h3; - E = c->h4; - - } -} -# endif - -#endif +/* + * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <stdlib.h> +#include <string.h> + +#include <openssl/opensslconf.h> +#include <openssl/sha.h> + +#define DATA_ORDER_IS_BIG_ENDIAN + +#define HASH_LONG SHA_LONG +#define HASH_CTX SHA_CTX +#define HASH_CBLOCK SHA_CBLOCK +#define HASH_MAKE_STRING(c,s) do { \ + unsigned long ll; \ + ll=(c)->h0; (void)HOST_l2c(ll,(s)); \ + ll=(c)->h1; (void)HOST_l2c(ll,(s)); \ + ll=(c)->h2; (void)HOST_l2c(ll,(s)); \ + ll=(c)->h3; (void)HOST_l2c(ll,(s)); \ + ll=(c)->h4; (void)HOST_l2c(ll,(s)); \ + } while (0) + +#define HASH_UPDATE SHA1_Update +#define HASH_TRANSFORM SHA1_Transform +#define HASH_FINAL SHA1_Final +#define HASH_INIT SHA1_Init +#define HASH_BLOCK_DATA_ORDER sha1_block_data_order +#define Xupdate(a,ix,ia,ib,ic,id) ( (a)=(ia^ib^ic^id), \ + ix=(a)=ROTATE((a),1) \ + ) + +#ifndef SHA1_ASM +static void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num); +#else +void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num); +#endif + +#include "crypto/md32_common.h" + +#define INIT_DATA_h0 0x67452301UL +#define INIT_DATA_h1 0xefcdab89UL +#define INIT_DATA_h2 0x98badcfeUL +#define INIT_DATA_h3 0x10325476UL +#define INIT_DATA_h4 0xc3d2e1f0UL + +int HASH_INIT(SHA_CTX *c) +{ + memset(c, 0, sizeof(*c)); + c->h0 = INIT_DATA_h0; + c->h1 = INIT_DATA_h1; + c->h2 = INIT_DATA_h2; + c->h3 = INIT_DATA_h3; + c->h4 = INIT_DATA_h4; + return 1; +} + +#define K_00_19 0x5a827999UL +#define K_20_39 0x6ed9eba1UL +#define K_40_59 0x8f1bbcdcUL +#define K_60_79 0xca62c1d6UL + +/* + * As pointed out by Wei Dai, F() below can be simplified to the code in + * F_00_19. Wei attributes these optimizations to Peter Gutmann's SHS code, + * and he attributes it to Rich Schroeppel. + * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) + * I've just become aware of another tweak to be made, again from Wei Dai, + * in F_40_59, (x&a)|(y&a) -> (x|y)&a + */ +#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d)) +#define F_20_39(b,c,d) ((b) ^ (c) ^ (d)) +#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d))) +#define F_60_79(b,c,d) F_20_39(b,c,d) + +#ifndef OPENSSL_SMALL_FOOTPRINT + +# define BODY_00_15(i,a,b,c,d,e,f,xi) \ + (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +# define BODY_16_19(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \ + Xupdate(f,xi,xa,xb,xc,xd); \ + (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ + (b)=ROTATE((b),30); + +# define BODY_20_31(i,a,b,c,d,e,f,xi,xa,xb,xc,xd) \ + Xupdate(f,xi,xa,xb,xc,xd); \ + (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +# define BODY_32_39(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,xa,xa,xb,xc,xd); \ + (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ + (b)=ROTATE((b),30); + +# define BODY_40_59(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,xa,xa,xb,xc,xd); \ + (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \ + (b)=ROTATE((b),30); + +# define BODY_60_79(i,a,b,c,d,e,f,xa,xb,xc,xd) \ + Xupdate(f,xa,xa,xb,xc,xd); \ + (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ + (b)=ROTATE((b),30); + +# ifdef X +# undef X +# endif +# ifndef MD32_XARRAY + /* + * Originally X was an array. As it's automatic it's natural + * to expect RISC compiler to accommodate at least part of it in + * the register bank, isn't it? Unfortunately not all compilers + * "find" this expectation reasonable:-( On order to make such + * compilers generate better code I replace X[] with a bunch of + * X0, X1, etc. See the function body below... + */ +# define X(i) XX##i +# else + /* + * However! Some compilers (most notably HP C) get overwhelmed by + * that many local variables so that we have to have the way to + * fall down to the original behavior. + */ +# define X(i) XX[i] +# endif + +# if !defined(SHA1_ASM) +static void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num) +{ + const unsigned char *data = p; + register unsigned MD32_REG_T A, B, C, D, E, T, l; +# ifndef MD32_XARRAY + unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, + XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; +# else + SHA_LONG XX[16]; +# endif + + A = c->h0; + B = c->h1; + C = c->h2; + D = c->h3; + E = c->h4; + + for (;;) { + const union { + long one; + char little; + } is_endian = { + 1 + }; + + if (!is_endian.little && sizeof(SHA_LONG) == 4 + && ((size_t)p % 4) == 0) { + const SHA_LONG *W = (const SHA_LONG *)data; + + X(0) = W[0]; + X(1) = W[1]; + BODY_00_15(0, A, B, C, D, E, T, X(0)); + X(2) = W[2]; + BODY_00_15(1, T, A, B, C, D, E, X(1)); + X(3) = W[3]; + BODY_00_15(2, E, T, A, B, C, D, X(2)); + X(4) = W[4]; + BODY_00_15(3, D, E, T, A, B, C, X(3)); + X(5) = W[5]; + BODY_00_15(4, C, D, E, T, A, B, X(4)); + X(6) = W[6]; + BODY_00_15(5, B, C, D, E, T, A, X(5)); + X(7) = W[7]; + BODY_00_15(6, A, B, C, D, E, T, X(6)); + X(8) = W[8]; + BODY_00_15(7, T, A, B, C, D, E, X(7)); + X(9) = W[9]; + BODY_00_15(8, E, T, A, B, C, D, X(8)); + X(10) = W[10]; + BODY_00_15(9, D, E, T, A, B, C, X(9)); + X(11) = W[11]; + BODY_00_15(10, C, D, E, T, A, B, X(10)); + X(12) = W[12]; + BODY_00_15(11, B, C, D, E, T, A, X(11)); + X(13) = W[13]; + BODY_00_15(12, A, B, C, D, E, T, X(12)); + X(14) = W[14]; + BODY_00_15(13, T, A, B, C, D, E, X(13)); + X(15) = W[15]; + BODY_00_15(14, E, T, A, B, C, D, X(14)); + BODY_00_15(15, D, E, T, A, B, C, X(15)); + + data += SHA_CBLOCK; + } else { + (void)HOST_c2l(data, l); + X(0) = l; + (void)HOST_c2l(data, l); + X(1) = l; + BODY_00_15(0, A, B, C, D, E, T, X(0)); + (void)HOST_c2l(data, l); + X(2) = l; + BODY_00_15(1, T, A, B, C, D, E, X(1)); + (void)HOST_c2l(data, l); + X(3) = l; + BODY_00_15(2, E, T, A, B, C, D, X(2)); + (void)HOST_c2l(data, l); + X(4) = l; + BODY_00_15(3, D, E, T, A, B, C, X(3)); + (void)HOST_c2l(data, l); + X(5) = l; + BODY_00_15(4, C, D, E, T, A, B, X(4)); + (void)HOST_c2l(data, l); + X(6) = l; + BODY_00_15(5, B, C, D, E, T, A, X(5)); + (void)HOST_c2l(data, l); + X(7) = l; + BODY_00_15(6, A, B, C, D, E, T, X(6)); + (void)HOST_c2l(data, l); + X(8) = l; + BODY_00_15(7, T, A, B, C, D, E, X(7)); + (void)HOST_c2l(data, l); + X(9) = l; + BODY_00_15(8, E, T, A, B, C, D, X(8)); + (void)HOST_c2l(data, l); + X(10) = l; + BODY_00_15(9, D, E, T, A, B, C, X(9)); + (void)HOST_c2l(data, l); + X(11) = l; + BODY_00_15(10, C, D, E, T, A, B, X(10)); + (void)HOST_c2l(data, l); + X(12) = l; + BODY_00_15(11, B, C, D, E, T, A, X(11)); + (void)HOST_c2l(data, l); + X(13) = l; + BODY_00_15(12, A, B, C, D, E, T, X(12)); + (void)HOST_c2l(data, l); + X(14) = l; + BODY_00_15(13, T, A, B, C, D, E, X(13)); + (void)HOST_c2l(data, l); + X(15) = l; + BODY_00_15(14, E, T, A, B, C, D, X(14)); + BODY_00_15(15, D, E, T, A, B, C, X(15)); + } + + BODY_16_19(16, C, D, E, T, A, B, X(0), X(0), X(2), X(8), X(13)); + BODY_16_19(17, B, C, D, E, T, A, X(1), X(1), X(3), X(9), X(14)); + BODY_16_19(18, A, B, C, D, E, T, X(2), X(2), X(4), X(10), X(15)); + BODY_16_19(19, T, A, B, C, D, E, X(3), X(3), X(5), X(11), X(0)); + + BODY_20_31(20, E, T, A, B, C, D, X(4), X(4), X(6), X(12), X(1)); + BODY_20_31(21, D, E, T, A, B, C, X(5), X(5), X(7), X(13), X(2)); + BODY_20_31(22, C, D, E, T, A, B, X(6), X(6), X(8), X(14), X(3)); + BODY_20_31(23, B, C, D, E, T, A, X(7), X(7), X(9), X(15), X(4)); + BODY_20_31(24, A, B, C, D, E, T, X(8), X(8), X(10), X(0), X(5)); + BODY_20_31(25, T, A, B, C, D, E, X(9), X(9), X(11), X(1), X(6)); + BODY_20_31(26, E, T, A, B, C, D, X(10), X(10), X(12), X(2), X(7)); + BODY_20_31(27, D, E, T, A, B, C, X(11), X(11), X(13), X(3), X(8)); + BODY_20_31(28, C, D, E, T, A, B, X(12), X(12), X(14), X(4), X(9)); + BODY_20_31(29, B, C, D, E, T, A, X(13), X(13), X(15), X(5), X(10)); + BODY_20_31(30, A, B, C, D, E, T, X(14), X(14), X(0), X(6), X(11)); + BODY_20_31(31, T, A, B, C, D, E, X(15), X(15), X(1), X(7), X(12)); + + BODY_32_39(32, E, T, A, B, C, D, X(0), X(2), X(8), X(13)); + BODY_32_39(33, D, E, T, A, B, C, X(1), X(3), X(9), X(14)); + BODY_32_39(34, C, D, E, T, A, B, X(2), X(4), X(10), X(15)); + BODY_32_39(35, B, C, D, E, T, A, X(3), X(5), X(11), X(0)); + BODY_32_39(36, A, B, C, D, E, T, X(4), X(6), X(12), X(1)); + BODY_32_39(37, T, A, B, C, D, E, X(5), X(7), X(13), X(2)); + BODY_32_39(38, E, T, A, B, C, D, X(6), X(8), X(14), X(3)); + BODY_32_39(39, D, E, T, A, B, C, X(7), X(9), X(15), X(4)); + + BODY_40_59(40, C, D, E, T, A, B, X(8), X(10), X(0), X(5)); + BODY_40_59(41, B, C, D, E, T, A, X(9), X(11), X(1), X(6)); + BODY_40_59(42, A, B, C, D, E, T, X(10), X(12), X(2), X(7)); + BODY_40_59(43, T, A, B, C, D, E, X(11), X(13), X(3), X(8)); + BODY_40_59(44, E, T, A, B, C, D, X(12), X(14), X(4), X(9)); + BODY_40_59(45, D, E, T, A, B, C, X(13), X(15), X(5), X(10)); + BODY_40_59(46, C, D, E, T, A, B, X(14), X(0), X(6), X(11)); + BODY_40_59(47, B, C, D, E, T, A, X(15), X(1), X(7), X(12)); + BODY_40_59(48, A, B, C, D, E, T, X(0), X(2), X(8), X(13)); + BODY_40_59(49, T, A, B, C, D, E, X(1), X(3), X(9), X(14)); + BODY_40_59(50, E, T, A, B, C, D, X(2), X(4), X(10), X(15)); + BODY_40_59(51, D, E, T, A, B, C, X(3), X(5), X(11), X(0)); + BODY_40_59(52, C, D, E, T, A, B, X(4), X(6), X(12), X(1)); + BODY_40_59(53, B, C, D, E, T, A, X(5), X(7), X(13), X(2)); + BODY_40_59(54, A, B, C, D, E, T, X(6), X(8), X(14), X(3)); + BODY_40_59(55, T, A, B, C, D, E, X(7), X(9), X(15), X(4)); + BODY_40_59(56, E, T, A, B, C, D, X(8), X(10), X(0), X(5)); + BODY_40_59(57, D, E, T, A, B, C, X(9), X(11), X(1), X(6)); + BODY_40_59(58, C, D, E, T, A, B, X(10), X(12), X(2), X(7)); + BODY_40_59(59, B, C, D, E, T, A, X(11), X(13), X(3), X(8)); + + BODY_60_79(60, A, B, C, D, E, T, X(12), X(14), X(4), X(9)); + BODY_60_79(61, T, A, B, C, D, E, X(13), X(15), X(5), X(10)); + BODY_60_79(62, E, T, A, B, C, D, X(14), X(0), X(6), X(11)); + BODY_60_79(63, D, E, T, A, B, C, X(15), X(1), X(7), X(12)); + BODY_60_79(64, C, D, E, T, A, B, X(0), X(2), X(8), X(13)); + BODY_60_79(65, B, C, D, E, T, A, X(1), X(3), X(9), X(14)); + BODY_60_79(66, A, B, C, D, E, T, X(2), X(4), X(10), X(15)); + BODY_60_79(67, T, A, B, C, D, E, X(3), X(5), X(11), X(0)); + BODY_60_79(68, E, T, A, B, C, D, X(4), X(6), X(12), X(1)); + BODY_60_79(69, D, E, T, A, B, C, X(5), X(7), X(13), X(2)); + BODY_60_79(70, C, D, E, T, A, B, X(6), X(8), X(14), X(3)); + BODY_60_79(71, B, C, D, E, T, A, X(7), X(9), X(15), X(4)); + BODY_60_79(72, A, B, C, D, E, T, X(8), X(10), X(0), X(5)); + BODY_60_79(73, T, A, B, C, D, E, X(9), X(11), X(1), X(6)); + BODY_60_79(74, E, T, A, B, C, D, X(10), X(12), X(2), X(7)); + BODY_60_79(75, D, E, T, A, B, C, X(11), X(13), X(3), X(8)); + BODY_60_79(76, C, D, E, T, A, B, X(12), X(14), X(4), X(9)); + BODY_60_79(77, B, C, D, E, T, A, X(13), X(15), X(5), X(10)); + BODY_60_79(78, A, B, C, D, E, T, X(14), X(0), X(6), X(11)); + BODY_60_79(79, T, A, B, C, D, E, X(15), X(1), X(7), X(12)); + + c->h0 = (c->h0 + E) & 0xffffffffL; + c->h1 = (c->h1 + T) & 0xffffffffL; + c->h2 = (c->h2 + A) & 0xffffffffL; + c->h3 = (c->h3 + B) & 0xffffffffL; + c->h4 = (c->h4 + C) & 0xffffffffL; + + if (--num == 0) + break; + + A = c->h0; + B = c->h1; + C = c->h2; + D = c->h3; + E = c->h4; + + } +} +# endif + +#else /* OPENSSL_SMALL_FOOTPRINT */ + +# define BODY_00_15(xi) do { \ + T=E+K_00_19+F_00_19(B,C,D); \ + E=D, D=C, C=ROTATE(B,30), B=A; \ + A=ROTATE(A,5)+T+xi; } while(0) + +# define BODY_16_19(xa,xb,xc,xd) do { \ + Xupdate(T,xa,xa,xb,xc,xd); \ + T+=E+K_00_19+F_00_19(B,C,D); \ + E=D, D=C, C=ROTATE(B,30), B=A; \ + A=ROTATE(A,5)+T; } while(0) + +# define BODY_20_39(xa,xb,xc,xd) do { \ + Xupdate(T,xa,xa,xb,xc,xd); \ + T+=E+K_20_39+F_20_39(B,C,D); \ + E=D, D=C, C=ROTATE(B,30), B=A; \ + A=ROTATE(A,5)+T; } while(0) + +# define BODY_40_59(xa,xb,xc,xd) do { \ + Xupdate(T,xa,xa,xb,xc,xd); \ + T+=E+K_40_59+F_40_59(B,C,D); \ + E=D, D=C, C=ROTATE(B,30), B=A; \ + A=ROTATE(A,5)+T; } while(0) + +# define BODY_60_79(xa,xb,xc,xd) do { \ + Xupdate(T,xa,xa,xb,xc,xd); \ + T=E+K_60_79+F_60_79(B,C,D); \ + E=D, D=C, C=ROTATE(B,30), B=A; \ + A=ROTATE(A,5)+T+xa; } while(0) + +# if !defined(SHA1_ASM) +static void HASH_BLOCK_DATA_ORDER(SHA_CTX *c, const void *p, size_t num) +{ + const unsigned char *data = p; + register unsigned MD32_REG_T A, B, C, D, E, T, l; + int i; + SHA_LONG X[16]; + + A = c->h0; + B = c->h1; + C = c->h2; + D = c->h3; + E = c->h4; + + for (;;) { + for (i = 0; i < 16; i++) { + (void)HOST_c2l(data, l); + X[i] = l; + BODY_00_15(X[i]); + } + for (i = 0; i < 4; i++) { + BODY_16_19(X[i], X[i + 2], X[i + 8], X[(i + 13) & 15]); + } + for (; i < 24; i++) { + BODY_20_39(X[i & 15], X[(i + 2) & 15], X[(i + 8) & 15], + X[(i + 13) & 15]); + } + for (i = 0; i < 20; i++) { + BODY_40_59(X[(i + 8) & 15], X[(i + 10) & 15], X[i & 15], + X[(i + 5) & 15]); + } + for (i = 4; i < 24; i++) { + BODY_60_79(X[(i + 8) & 15], X[(i + 10) & 15], X[i & 15], + X[(i + 5) & 15]); + } + + c->h0 = (c->h0 + A) & 0xffffffffL; + c->h1 = (c->h1 + B) & 0xffffffffL; + c->h2 = (c->h2 + C) & 0xffffffffL; + c->h3 = (c->h3 + D) & 0xffffffffL; + c->h4 = (c->h4 + E) & 0xffffffffL; + + if (--num == 0) + break; + + A = c->h0; + B = c->h1; + C = c->h2; + D = c->h3; + E = c->h4; + + } +} +# endif + +#endif diff --git a/contrib/libs/openssl/crypto/siphash/siphash.c b/contrib/libs/openssl/crypto/siphash/siphash.c index 62e2f31aa0..07d94c1e6e 100644 --- a/contrib/libs/openssl/crypto/siphash/siphash.c +++ b/contrib/libs/openssl/crypto/siphash/siphash.c @@ -27,7 +27,7 @@ #include <string.h> #include <openssl/crypto.h> -#include "crypto/siphash.h" +#include "crypto/siphash.h" #include "siphash_local.h" /* default: SipHash-2-4 */ diff --git a/contrib/libs/openssl/crypto/siphash/siphash_ameth.c b/contrib/libs/openssl/crypto/siphash/siphash_ameth.c index f010c77a5b..7fce76390e 100644 --- a/contrib/libs/openssl/crypto/siphash/siphash_ameth.c +++ b/contrib/libs/openssl/crypto/siphash/siphash_ameth.c @@ -10,10 +10,10 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/evp.h> -#include "crypto/asn1.h" -#include "crypto/siphash.h" +#include "crypto/asn1.h" +#include "crypto/siphash.h" #include "siphash_local.h" -#include "crypto/evp.h" +#include "crypto/evp.h" /* * SIPHASH "ASN1" method. This is just here to indicate the maximum diff --git a/contrib/libs/openssl/crypto/siphash/siphash_pmeth.c b/contrib/libs/openssl/crypto/siphash/siphash_pmeth.c index 92db3bbc52..0c7d2c6190 100644 --- a/contrib/libs/openssl/crypto/siphash/siphash_pmeth.c +++ b/contrib/libs/openssl/crypto/siphash/siphash_pmeth.c @@ -13,9 +13,9 @@ #include <openssl/x509v3.h> #include <openssl/evp.h> #include <openssl/err.h> -#include "crypto/siphash.h" +#include "crypto/siphash.h" #include "siphash_local.h" -#include "crypto/evp.h" +#include "crypto/evp.h" /* SIPHASH pkey context structure */ diff --git a/contrib/libs/openssl/crypto/sm2/sm2_crypt.c b/contrib/libs/openssl/crypto/sm2/sm2_crypt.c index d7ae8d6bc7..83b97f4edc 100644 --- a/contrib/libs/openssl/crypto/sm2/sm2_crypt.c +++ b/contrib/libs/openssl/crypto/sm2/sm2_crypt.c @@ -9,9 +9,9 @@ * https://www.openssl.org/source/license.html */ -#include "crypto/sm2.h" -#include "crypto/sm2err.h" -#include "crypto/ec.h" /* ecdh_KDF_X9_63() */ +#include "crypto/sm2.h" +#include "crypto/sm2err.h" +#include "crypto/ec.h" /* ecdh_KDF_X9_63() */ #include <openssl/err.h> #include <openssl/evp.h> #include <openssl/bn.h> diff --git a/contrib/libs/openssl/crypto/sm2/sm2_err.c b/contrib/libs/openssl/crypto/sm2/sm2_err.c index 810d8b4d5a..e5973e9c71 100644 --- a/contrib/libs/openssl/crypto/sm2/sm2_err.c +++ b/contrib/libs/openssl/crypto/sm2/sm2_err.c @@ -9,7 +9,7 @@ */ #include <openssl/err.h> -#include "crypto/sm2err.h" +#include "crypto/sm2err.h" #ifndef OPENSSL_NO_ERR diff --git a/contrib/libs/openssl/crypto/sm2/sm2_pmeth.c b/contrib/libs/openssl/crypto/sm2/sm2_pmeth.c index 20753aaf25..0e722b910b 100644 --- a/contrib/libs/openssl/crypto/sm2/sm2_pmeth.c +++ b/contrib/libs/openssl/crypto/sm2/sm2_pmeth.c @@ -11,9 +11,9 @@ #include <openssl/asn1t.h> #include <openssl/ec.h> #include <openssl/evp.h> -#include "crypto/evp.h" -#include "crypto/sm2.h" -#include "crypto/sm2err.h" +#include "crypto/evp.h" +#include "crypto/sm2.h" +#include "crypto/sm2err.h" /* EC pkey context structure */ @@ -220,10 +220,10 @@ static int pkey_sm2_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) *(size_t *)p2 = smctx->id_len; return 1; - case EVP_PKEY_CTRL_DIGESTINIT: - /* nothing to be inited, this is to suppress the error... */ - return 1; - + case EVP_PKEY_CTRL_DIGESTINIT: + /* nothing to be inited, this is to suppress the error... */ + return 1; + default: return -2; } diff --git a/contrib/libs/openssl/crypto/sm2/sm2_sign.c b/contrib/libs/openssl/crypto/sm2/sm2_sign.c index e7ff39958e..683f03f935 100644 --- a/contrib/libs/openssl/crypto/sm2/sm2_sign.c +++ b/contrib/libs/openssl/crypto/sm2/sm2_sign.c @@ -9,9 +9,9 @@ * https://www.openssl.org/source/license.html */ -#include "crypto/sm2.h" -#include "crypto/sm2err.h" -#include "crypto/ec.h" /* ec_group_do_inverse_ord() */ +#include "crypto/sm2.h" +#include "crypto/sm2err.h" +#include "crypto/ec.h" /* ec_group_do_inverse_ord() */ #include "internal/numbers.h" #include <openssl/err.h> #include <openssl/evp.h> diff --git a/contrib/libs/openssl/crypto/sm3/m_sm3.c b/contrib/libs/openssl/crypto/sm3/m_sm3.c index f4b3367dcd..7e54f42984 100644 --- a/contrib/libs/openssl/crypto/sm3/m_sm3.c +++ b/contrib/libs/openssl/crypto/sm3/m_sm3.c @@ -12,8 +12,8 @@ #ifndef OPENSSL_NO_SM3 # include <openssl/evp.h> -# include "crypto/evp.h" -# include "crypto/sm3.h" +# include "crypto/evp.h" +# include "crypto/sm3.h" static int init(EVP_MD_CTX *ctx) { diff --git a/contrib/libs/openssl/crypto/sm3/sm3.c b/contrib/libs/openssl/crypto/sm3/sm3.c index ef4371359e..d78292b4c5 100644 --- a/contrib/libs/openssl/crypto/sm3/sm3.c +++ b/contrib/libs/openssl/crypto/sm3/sm3.c @@ -10,7 +10,7 @@ */ #include <openssl/e_os2.h> -#include "sm3_local.h" +#include "sm3_local.h" int sm3_init(SM3_CTX *c) { diff --git a/contrib/libs/openssl/crypto/sm3/sm3_local.h b/contrib/libs/openssl/crypto/sm3/sm3_local.h index b3658aeb22..7171de510d 100644 --- a/contrib/libs/openssl/crypto/sm3/sm3_local.h +++ b/contrib/libs/openssl/crypto/sm3/sm3_local.h @@ -1,79 +1,79 @@ -/* - * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. - * Copyright 2017 Ribose Inc. All Rights Reserved. - * Ported from Ribose contributions from Botan. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <string.h> -#include "crypto/sm3.h" - -#define DATA_ORDER_IS_BIG_ENDIAN - -#define HASH_LONG SM3_WORD -#define HASH_CTX SM3_CTX -#define HASH_CBLOCK SM3_CBLOCK -#define HASH_UPDATE sm3_update -#define HASH_TRANSFORM sm3_transform -#define HASH_FINAL sm3_final -#define HASH_MAKE_STRING(c, s) \ - do { \ - unsigned long ll; \ - ll=(c)->A; (void)HOST_l2c(ll, (s)); \ - ll=(c)->B; (void)HOST_l2c(ll, (s)); \ - ll=(c)->C; (void)HOST_l2c(ll, (s)); \ - ll=(c)->D; (void)HOST_l2c(ll, (s)); \ - ll=(c)->E; (void)HOST_l2c(ll, (s)); \ - ll=(c)->F; (void)HOST_l2c(ll, (s)); \ - ll=(c)->G; (void)HOST_l2c(ll, (s)); \ - ll=(c)->H; (void)HOST_l2c(ll, (s)); \ - } while (0) -#define HASH_BLOCK_DATA_ORDER sm3_block_data_order - -void sm3_transform(SM3_CTX *c, const unsigned char *data); - -#include "crypto/md32_common.h" - -#define P0(X) (X ^ ROTATE(X, 9) ^ ROTATE(X, 17)) -#define P1(X) (X ^ ROTATE(X, 15) ^ ROTATE(X, 23)) - -#define FF0(X,Y,Z) (X ^ Y ^ Z) -#define GG0(X,Y,Z) (X ^ Y ^ Z) - -#define FF1(X,Y,Z) ((X & Y) | ((X | Y) & Z)) -#define GG1(X,Y,Z) ((Z ^ (X & (Y ^ Z)))) - -#define EXPAND(W0,W7,W13,W3,W10) \ - (P1(W0 ^ W7 ^ ROTATE(W13, 15)) ^ ROTATE(W3, 7) ^ W10) - -#define RND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF, GG) \ - do { \ - const SM3_WORD A12 = ROTATE(A, 12); \ - const SM3_WORD A12_SM = A12 + E + TJ; \ - const SM3_WORD SS1 = ROTATE(A12_SM, 7); \ - const SM3_WORD TT1 = FF(A, B, C) + D + (SS1 ^ A12) + (Wj); \ - const SM3_WORD TT2 = GG(E, F, G) + H + SS1 + Wi; \ - B = ROTATE(B, 9); \ - D = TT1; \ - F = ROTATE(F, 19); \ - H = P0(TT2); \ - } while(0) - -#define R1(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \ - RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF0,GG0) - -#define R2(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \ - RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF1,GG1) - -#define SM3_A 0x7380166fUL -#define SM3_B 0x4914b2b9UL -#define SM3_C 0x172442d7UL -#define SM3_D 0xda8a0600UL -#define SM3_E 0xa96f30bcUL -#define SM3_F 0x163138aaUL -#define SM3_G 0xe38dee4dUL -#define SM3_H 0xb0fb0e4eUL +/* + * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2017 Ribose Inc. All Rights Reserved. + * Ported from Ribose contributions from Botan. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <string.h> +#include "crypto/sm3.h" + +#define DATA_ORDER_IS_BIG_ENDIAN + +#define HASH_LONG SM3_WORD +#define HASH_CTX SM3_CTX +#define HASH_CBLOCK SM3_CBLOCK +#define HASH_UPDATE sm3_update +#define HASH_TRANSFORM sm3_transform +#define HASH_FINAL sm3_final +#define HASH_MAKE_STRING(c, s) \ + do { \ + unsigned long ll; \ + ll=(c)->A; (void)HOST_l2c(ll, (s)); \ + ll=(c)->B; (void)HOST_l2c(ll, (s)); \ + ll=(c)->C; (void)HOST_l2c(ll, (s)); \ + ll=(c)->D; (void)HOST_l2c(ll, (s)); \ + ll=(c)->E; (void)HOST_l2c(ll, (s)); \ + ll=(c)->F; (void)HOST_l2c(ll, (s)); \ + ll=(c)->G; (void)HOST_l2c(ll, (s)); \ + ll=(c)->H; (void)HOST_l2c(ll, (s)); \ + } while (0) +#define HASH_BLOCK_DATA_ORDER sm3_block_data_order + +void sm3_transform(SM3_CTX *c, const unsigned char *data); + +#include "crypto/md32_common.h" + +#define P0(X) (X ^ ROTATE(X, 9) ^ ROTATE(X, 17)) +#define P1(X) (X ^ ROTATE(X, 15) ^ ROTATE(X, 23)) + +#define FF0(X,Y,Z) (X ^ Y ^ Z) +#define GG0(X,Y,Z) (X ^ Y ^ Z) + +#define FF1(X,Y,Z) ((X & Y) | ((X | Y) & Z)) +#define GG1(X,Y,Z) ((Z ^ (X & (Y ^ Z)))) + +#define EXPAND(W0,W7,W13,W3,W10) \ + (P1(W0 ^ W7 ^ ROTATE(W13, 15)) ^ ROTATE(W3, 7) ^ W10) + +#define RND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF, GG) \ + do { \ + const SM3_WORD A12 = ROTATE(A, 12); \ + const SM3_WORD A12_SM = A12 + E + TJ; \ + const SM3_WORD SS1 = ROTATE(A12_SM, 7); \ + const SM3_WORD TT1 = FF(A, B, C) + D + (SS1 ^ A12) + (Wj); \ + const SM3_WORD TT2 = GG(E, F, G) + H + SS1 + Wi; \ + B = ROTATE(B, 9); \ + D = TT1; \ + F = ROTATE(F, 19); \ + H = P0(TT2); \ + } while(0) + +#define R1(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \ + RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF0,GG0) + +#define R2(A,B,C,D,E,F,G,H,TJ,Wi,Wj) \ + RND(A,B,C,D,E,F,G,H,TJ,Wi,Wj,FF1,GG1) + +#define SM3_A 0x7380166fUL +#define SM3_B 0x4914b2b9UL +#define SM3_C 0x172442d7UL +#define SM3_D 0xda8a0600UL +#define SM3_E 0xa96f30bcUL +#define SM3_F 0x163138aaUL +#define SM3_G 0xe38dee4dUL +#define SM3_H 0xb0fb0e4eUL diff --git a/contrib/libs/openssl/crypto/sm4/sm4.c b/contrib/libs/openssl/crypto/sm4/sm4.c index 07d50f2579..5750e76331 100644 --- a/contrib/libs/openssl/crypto/sm4/sm4.c +++ b/contrib/libs/openssl/crypto/sm4/sm4.c @@ -10,7 +10,7 @@ */ #include <openssl/e_os2.h> -#include "crypto/sm4.h" +#include "crypto/sm4.h" static const uint8_t SM4_S[256] = { 0xD6, 0x90, 0xE9, 0xFE, 0xCC, 0xE1, 0x3D, 0xB7, 0x16, 0xB6, 0x14, 0xC2, diff --git a/contrib/libs/openssl/crypto/sparc_arch.h b/contrib/libs/openssl/crypto/sparc_arch.h index cadbf51130..c74063be2f 100644 --- a/contrib/libs/openssl/crypto/sparc_arch.h +++ b/contrib/libs/openssl/crypto/sparc_arch.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_SPARC_ARCH_H -# define OSSL_CRYPTO_SPARC_ARCH_H +#ifndef OSSL_CRYPTO_SPARC_ARCH_H +# define OSSL_CRYPTO_SPARC_ARCH_H # define SPARCV9_TICK_PRIVILEGED (1<<0) # define SPARCV9_PREFER_FPU (1<<1) @@ -115,4 +115,4 @@ mov tmp, %o7; # endif -#endif /* OSSL_CRYPTO_SPARC_ARCH_H */ +#endif /* OSSL_CRYPTO_SPARC_ARCH_H */ diff --git a/contrib/libs/openssl/crypto/sparcv9cap.c b/contrib/libs/openssl/crypto/sparcv9cap.c index 85ee8931cf..b3cb3d4be9 100644 --- a/contrib/libs/openssl/crypto/sparcv9cap.c +++ b/contrib/libs/openssl/crypto/sparcv9cap.c @@ -269,7 +269,7 @@ void OPENSSL_cpuid_setup(void) /* * In wait for better solution _sparcv9_rdcfr is masked by - * VIS3 flag, because it goes to uninterruptible endless + * VIS3 flag, because it goes to uninterruptible endless * loop on UltraSPARC II running Solaris. Things might be * different on Linux... */ diff --git a/contrib/libs/openssl/crypto/srp/srp_lib.c b/contrib/libs/openssl/crypto/srp/srp_lib.c index 6fb52e898f..ce3504825c 100644 --- a/contrib/libs/openssl/crypto/srp/srp_lib.c +++ b/contrib/libs/openssl/crypto/srp/srp_lib.c @@ -16,7 +16,7 @@ # include <openssl/sha.h> # include <openssl/srp.h> # include <openssl/evp.h> -# include "crypto/bn_srp.h" +# include "crypto/bn_srp.h" /* calculate = SHA1(PAD(x) || PAD(y)) */ diff --git a/contrib/libs/openssl/crypto/srp/srp_vfy.c b/contrib/libs/openssl/crypto/srp/srp_vfy.c index 90e8b57297..394e1180df 100644 --- a/contrib/libs/openssl/crypto/srp/srp_vfy.c +++ b/contrib/libs/openssl/crypto/srp/srp_vfy.c @@ -13,7 +13,7 @@ #ifndef OPENSSL_NO_SRP # include "internal/cryptlib.h" -# include "crypto/evp.h" +# include "crypto/evp.h" # include <openssl/sha.h> # include <openssl/srp.h> # include <openssl/evp.h> diff --git a/contrib/libs/openssl/crypto/store/loader_file.c b/contrib/libs/openssl/crypto/store/loader_file.c index 4e93d9129a..32e7b9f65a 100644 --- a/contrib/libs/openssl/crypto/store/loader_file.c +++ b/contrib/libs/openssl/crypto/store/loader_file.c @@ -24,12 +24,12 @@ #include <openssl/store.h> #include <openssl/ui.h> #include <openssl/x509.h> /* For the PKCS8 stuff o.O */ -#include "crypto/asn1.h" -#include "crypto/ctype.h" +#include "crypto/asn1.h" +#include "crypto/ctype.h" #include "internal/o_dir.h" #include "internal/cryptlib.h" -#include "crypto/store.h" -#include "store_local.h" +#include "crypto/store.h" +#include "store_local.h" #ifdef _WIN32 # define stat _stat diff --git a/contrib/libs/openssl/crypto/store/store_init.c b/contrib/libs/openssl/crypto/store/store_init.c index 231cdc64f6..0103c8db8a 100644 --- a/contrib/libs/openssl/crypto/store/store_init.c +++ b/contrib/libs/openssl/crypto/store/store_init.c @@ -8,8 +8,8 @@ */ #include <openssl/err.h> -#include "crypto/store.h" -#include "store_local.h" +#include "crypto/store.h" +#include "store_local.h" static CRYPTO_ONCE store_init = CRYPTO_ONCE_STATIC_INIT; DEFINE_RUN_ONCE_STATIC(do_store_init) diff --git a/contrib/libs/openssl/crypto/store/store_lib.c b/contrib/libs/openssl/crypto/store/store_lib.c index ad25eb74c9..fb71f84725 100644 --- a/contrib/libs/openssl/crypto/store/store_lib.c +++ b/contrib/libs/openssl/crypto/store/store_lib.c @@ -18,8 +18,8 @@ #include <openssl/err.h> #include <openssl/store.h> #include "internal/thread_once.h" -#include "crypto/store.h" -#include "store_local.h" +#include "crypto/store.h" +#include "store_local.h" struct ossl_store_ctx_st { const OSSL_STORE_LOADER *loader; diff --git a/contrib/libs/openssl/crypto/store/store_local.h b/contrib/libs/openssl/crypto/store/store_local.h index 3c4b76bdc7..369dcb33f2 100644 --- a/contrib/libs/openssl/crypto/store/store_local.h +++ b/contrib/libs/openssl/crypto/store/store_local.h @@ -1,132 +1,132 @@ -/* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include "internal/thread_once.h" -#include <openssl/dsa.h> -#include <openssl/engine.h> -#include <openssl/evp.h> -#include <openssl/lhash.h> -#include <openssl/x509.h> -#include <openssl/store.h> - -/*- - * OSSL_STORE_INFO stuff - * --------------------- - */ - -struct ossl_store_info_st { - int type; - union { - void *data; /* used internally as generic pointer */ - - struct { - BUF_MEM *blob; - char *pem_name; - } embedded; /* when type == OSSL_STORE_INFO_EMBEDDED */ - - struct { - char *name; - char *desc; - } name; /* when type == OSSL_STORE_INFO_NAME */ - - EVP_PKEY *params; /* when type == OSSL_STORE_INFO_PARAMS */ - EVP_PKEY *pkey; /* when type == OSSL_STORE_INFO_PKEY */ - X509 *x509; /* when type == OSSL_STORE_INFO_CERT */ - X509_CRL *crl; /* when type == OSSL_STORE_INFO_CRL */ - } _; -}; - -DEFINE_STACK_OF(OSSL_STORE_INFO) - -/* - * EMBEDDED is a special type of OSSL_STORE_INFO, specially for the file - * handlers. It should never reach a calling application or any engine. - * However, it can be used by a FILE_HANDLER's try_decode function to signal - * that it has decoded the incoming blob into a new blob, and that the - * attempted decoding should be immediately restarted with the new blob, using - * the new PEM name. - */ -/* - * Because this is an internal type, we don't make it public. - */ -#define OSSL_STORE_INFO_EMBEDDED -1 -OSSL_STORE_INFO *ossl_store_info_new_EMBEDDED(const char *new_pem_name, - BUF_MEM *embedded); -BUF_MEM *ossl_store_info_get0_EMBEDDED_buffer(OSSL_STORE_INFO *info); -char *ossl_store_info_get0_EMBEDDED_pem_name(OSSL_STORE_INFO *info); - -/*- - * OSSL_STORE_SEARCH stuff - * ----------------------- - */ - -struct ossl_store_search_st { - int search_type; - - /* - * Used by OSSL_STORE_SEARCH_BY_NAME and - * OSSL_STORE_SEARCH_BY_ISSUER_SERIAL - */ - X509_NAME *name; - - /* Used by OSSL_STORE_SEARCH_BY_ISSUER_SERIAL */ - const ASN1_INTEGER *serial; - - /* Used by OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT */ - const EVP_MD *digest; - - /* - * Used by OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT and - * OSSL_STORE_SEARCH_BY_ALIAS - */ - const unsigned char *string; - size_t stringlength; -}; - -/*- - * OSSL_STORE_LOADER stuff - * ----------------------- - */ - -int ossl_store_register_loader_int(OSSL_STORE_LOADER *loader); -OSSL_STORE_LOADER *ossl_store_unregister_loader_int(const char *scheme); - -/* loader stuff */ -struct ossl_store_loader_st { - const char *scheme; - ENGINE *engine; - OSSL_STORE_open_fn open; - OSSL_STORE_ctrl_fn ctrl; - OSSL_STORE_expect_fn expect; - OSSL_STORE_find_fn find; - OSSL_STORE_load_fn load; - OSSL_STORE_eof_fn eof; - OSSL_STORE_error_fn error; - OSSL_STORE_close_fn close; -}; -DEFINE_LHASH_OF(OSSL_STORE_LOADER); - -const OSSL_STORE_LOADER *ossl_store_get0_loader_int(const char *scheme); -void ossl_store_destroy_loaders_int(void); - -/*- - * OSSL_STORE init stuff - * --------------------- - */ - -int ossl_store_init_once(void); -int ossl_store_file_loader_init(void); - -/*- - * 'file' scheme stuff - * ------------------- - */ - -OSSL_STORE_LOADER_CTX *ossl_store_file_attach_pem_bio_int(BIO *bp); -int ossl_store_file_detach_pem_bio_int(OSSL_STORE_LOADER_CTX *ctx); +/* + * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "internal/thread_once.h" +#include <openssl/dsa.h> +#include <openssl/engine.h> +#include <openssl/evp.h> +#include <openssl/lhash.h> +#include <openssl/x509.h> +#include <openssl/store.h> + +/*- + * OSSL_STORE_INFO stuff + * --------------------- + */ + +struct ossl_store_info_st { + int type; + union { + void *data; /* used internally as generic pointer */ + + struct { + BUF_MEM *blob; + char *pem_name; + } embedded; /* when type == OSSL_STORE_INFO_EMBEDDED */ + + struct { + char *name; + char *desc; + } name; /* when type == OSSL_STORE_INFO_NAME */ + + EVP_PKEY *params; /* when type == OSSL_STORE_INFO_PARAMS */ + EVP_PKEY *pkey; /* when type == OSSL_STORE_INFO_PKEY */ + X509 *x509; /* when type == OSSL_STORE_INFO_CERT */ + X509_CRL *crl; /* when type == OSSL_STORE_INFO_CRL */ + } _; +}; + +DEFINE_STACK_OF(OSSL_STORE_INFO) + +/* + * EMBEDDED is a special type of OSSL_STORE_INFO, specially for the file + * handlers. It should never reach a calling application or any engine. + * However, it can be used by a FILE_HANDLER's try_decode function to signal + * that it has decoded the incoming blob into a new blob, and that the + * attempted decoding should be immediately restarted with the new blob, using + * the new PEM name. + */ +/* + * Because this is an internal type, we don't make it public. + */ +#define OSSL_STORE_INFO_EMBEDDED -1 +OSSL_STORE_INFO *ossl_store_info_new_EMBEDDED(const char *new_pem_name, + BUF_MEM *embedded); +BUF_MEM *ossl_store_info_get0_EMBEDDED_buffer(OSSL_STORE_INFO *info); +char *ossl_store_info_get0_EMBEDDED_pem_name(OSSL_STORE_INFO *info); + +/*- + * OSSL_STORE_SEARCH stuff + * ----------------------- + */ + +struct ossl_store_search_st { + int search_type; + + /* + * Used by OSSL_STORE_SEARCH_BY_NAME and + * OSSL_STORE_SEARCH_BY_ISSUER_SERIAL + */ + X509_NAME *name; + + /* Used by OSSL_STORE_SEARCH_BY_ISSUER_SERIAL */ + const ASN1_INTEGER *serial; + + /* Used by OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT */ + const EVP_MD *digest; + + /* + * Used by OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT and + * OSSL_STORE_SEARCH_BY_ALIAS + */ + const unsigned char *string; + size_t stringlength; +}; + +/*- + * OSSL_STORE_LOADER stuff + * ----------------------- + */ + +int ossl_store_register_loader_int(OSSL_STORE_LOADER *loader); +OSSL_STORE_LOADER *ossl_store_unregister_loader_int(const char *scheme); + +/* loader stuff */ +struct ossl_store_loader_st { + const char *scheme; + ENGINE *engine; + OSSL_STORE_open_fn open; + OSSL_STORE_ctrl_fn ctrl; + OSSL_STORE_expect_fn expect; + OSSL_STORE_find_fn find; + OSSL_STORE_load_fn load; + OSSL_STORE_eof_fn eof; + OSSL_STORE_error_fn error; + OSSL_STORE_close_fn close; +}; +DEFINE_LHASH_OF(OSSL_STORE_LOADER); + +const OSSL_STORE_LOADER *ossl_store_get0_loader_int(const char *scheme); +void ossl_store_destroy_loaders_int(void); + +/*- + * OSSL_STORE init stuff + * --------------------- + */ + +int ossl_store_init_once(void); +int ossl_store_file_loader_init(void); + +/*- + * 'file' scheme stuff + * ------------------- + */ + +OSSL_STORE_LOADER_CTX *ossl_store_file_attach_pem_bio_int(BIO *bp); +int ossl_store_file_detach_pem_bio_int(OSSL_STORE_LOADER_CTX *ctx); diff --git a/contrib/libs/openssl/crypto/store/store_register.c b/contrib/libs/openssl/crypto/store/store_register.c index 66abb97dab..3631d9b506 100644 --- a/contrib/libs/openssl/crypto/store/store_register.c +++ b/contrib/libs/openssl/crypto/store/store_register.c @@ -8,12 +8,12 @@ */ #include <string.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include <assert.h> #include <openssl/err.h> #include <openssl/lhash.h> -#include "store_local.h" +#include "store_local.h" static CRYPTO_RWLOCK *registry_lock; static CRYPTO_ONCE registry_init = CRYPTO_ONCE_STATIC_INIT; diff --git a/contrib/libs/openssl/crypto/threads_none.c b/contrib/libs/openssl/crypto/threads_none.c index 35d5610648..aaaaae872a 100644 --- a/contrib/libs/openssl/crypto/threads_none.c +++ b/contrib/libs/openssl/crypto/threads_none.c @@ -143,7 +143,7 @@ int openssl_get_fork_id(void) # if defined(OPENSSL_SYS_UNIX) return getpid(); # else - return 0; + return 0; # endif } #endif diff --git a/contrib/libs/openssl/crypto/threads_win.c b/contrib/libs/openssl/crypto/threads_win.c index 89f86f4eb4..83dccb84fb 100644 --- a/contrib/libs/openssl/crypto/threads_win.c +++ b/contrib/libs/openssl/crypto/threads_win.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -24,15 +24,15 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void) return NULL; } -# if !defined(_WIN32_WCE) +# if !defined(_WIN32_WCE) /* 0x400 is the spin count value suggested in the documentation */ if (!InitializeCriticalSectionAndSpinCount(lock, 0x400)) { OPENSSL_free(lock); return NULL; } -# else +# else InitializeCriticalSection(lock); -# endif +# endif return lock; } @@ -155,7 +155,7 @@ int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b) int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock) { - *ret = (int)InterlockedExchangeAdd((long volatile *)val, (long)amount) + amount; + *ret = (int)InterlockedExchangeAdd((long volatile *)val, (long)amount) + amount; return 1; } diff --git a/contrib/libs/openssl/crypto/ts/ts_asn1.c b/contrib/libs/openssl/crypto/ts/ts_asn1.c index dd8eaa20e9..2840f5858a 100644 --- a/contrib/libs/openssl/crypto/ts/ts_asn1.c +++ b/contrib/libs/openssl/crypto/ts/ts_asn1.c @@ -10,7 +10,7 @@ #include <openssl/ts.h> #include <openssl/err.h> #include <openssl/asn1t.h> -#include "ts_local.h" +#include "ts_local.h" ASN1_SEQUENCE(TS_MSG_IMPRINT) = { ASN1_SIMPLE(TS_MSG_IMPRINT, hash_algo, X509_ALGOR), diff --git a/contrib/libs/openssl/crypto/ts/ts_lib.c b/contrib/libs/openssl/crypto/ts/ts_lib.c index 64ad851451..bfe981364b 100644 --- a/contrib/libs/openssl/crypto/ts/ts_lib.c +++ b/contrib/libs/openssl/crypto/ts/ts_lib.c @@ -14,7 +14,7 @@ #include <openssl/x509.h> #include <openssl/x509v3.h> #include <openssl/ts.h> -#include "ts_local.h" +#include "ts_local.h" int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num) { diff --git a/contrib/libs/openssl/crypto/ts/ts_local.h b/contrib/libs/openssl/crypto/ts/ts_local.h index 06a146c15b..771784fef7 100644 --- a/contrib/libs/openssl/crypto/ts/ts_local.h +++ b/contrib/libs/openssl/crypto/ts/ts_local.h @@ -1,211 +1,211 @@ -/* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/*- - * MessageImprint ::= SEQUENCE { - * hashAlgorithm AlgorithmIdentifier, - * hashedMessage OCTET STRING } - */ -struct TS_msg_imprint_st { - X509_ALGOR *hash_algo; - ASN1_OCTET_STRING *hashed_msg; -}; - -/*- - * TimeStampResp ::= SEQUENCE { - * status PKIStatusInfo, - * timeStampToken TimeStampToken OPTIONAL } - */ -struct TS_resp_st { - TS_STATUS_INFO *status_info; - PKCS7 *token; - TS_TST_INFO *tst_info; -}; - -/*- - * TimeStampReq ::= SEQUENCE { - * version INTEGER { v1(1) }, - * messageImprint MessageImprint, - * --a hash algorithm OID and the hash value of the data to be - * --time-stamped - * reqPolicy TSAPolicyId OPTIONAL, - * nonce INTEGER OPTIONAL, - * certReq BOOLEAN DEFAULT FALSE, - * extensions [0] IMPLICIT Extensions OPTIONAL } - */ -struct TS_req_st { - ASN1_INTEGER *version; - TS_MSG_IMPRINT *msg_imprint; - ASN1_OBJECT *policy_id; - ASN1_INTEGER *nonce; - ASN1_BOOLEAN cert_req; - STACK_OF(X509_EXTENSION) *extensions; -}; - -/*- - * Accuracy ::= SEQUENCE { - * seconds INTEGER OPTIONAL, - * millis [0] INTEGER (1..999) OPTIONAL, - * micros [1] INTEGER (1..999) OPTIONAL } - */ -struct TS_accuracy_st { - ASN1_INTEGER *seconds; - ASN1_INTEGER *millis; - ASN1_INTEGER *micros; -}; - -/*- - * TSTInfo ::= SEQUENCE { - * version INTEGER { v1(1) }, - * policy TSAPolicyId, - * messageImprint MessageImprint, - * -- MUST have the same value as the similar field in - * -- TimeStampReq - * serialNumber INTEGER, - * -- Time-Stamping users MUST be ready to accommodate integers - * -- up to 160 bits. - * genTime GeneralizedTime, - * accuracy Accuracy OPTIONAL, - * ordering BOOLEAN DEFAULT FALSE, - * nonce INTEGER OPTIONAL, - * -- MUST be present if the similar field was present - * -- in TimeStampReq. In that case it MUST have the same value. - * tsa [0] GeneralName OPTIONAL, - * extensions [1] IMPLICIT Extensions OPTIONAL } - */ -struct TS_tst_info_st { - ASN1_INTEGER *version; - ASN1_OBJECT *policy_id; - TS_MSG_IMPRINT *msg_imprint; - ASN1_INTEGER *serial; - ASN1_GENERALIZEDTIME *time; - TS_ACCURACY *accuracy; - ASN1_BOOLEAN ordering; - ASN1_INTEGER *nonce; - GENERAL_NAME *tsa; - STACK_OF(X509_EXTENSION) *extensions; -}; - -struct TS_status_info_st { - ASN1_INTEGER *status; - STACK_OF(ASN1_UTF8STRING) *text; - ASN1_BIT_STRING *failure_info; -}; - -/*- - * IssuerSerial ::= SEQUENCE { - * issuer GeneralNames, - * serialNumber CertificateSerialNumber - * } - */ -struct ESS_issuer_serial { - STACK_OF(GENERAL_NAME) *issuer; - ASN1_INTEGER *serial; -}; - -/*- - * ESSCertID ::= SEQUENCE { - * certHash Hash, - * issuerSerial IssuerSerial OPTIONAL - * } - */ -struct ESS_cert_id { - ASN1_OCTET_STRING *hash; /* Always SHA-1 digest. */ - ESS_ISSUER_SERIAL *issuer_serial; -}; - -/*- - * SigningCertificate ::= SEQUENCE { - * certs SEQUENCE OF ESSCertID, - * policies SEQUENCE OF PolicyInformation OPTIONAL - * } - */ -struct ESS_signing_cert { - STACK_OF(ESS_CERT_ID) *cert_ids; - STACK_OF(POLICYINFO) *policy_info; -}; - -/*- - * ESSCertIDv2 ::= SEQUENCE { - * hashAlgorithm AlgorithmIdentifier - * DEFAULT {algorithm id-sha256}, - * certHash Hash, - * issuerSerial IssuerSerial OPTIONAL - * } - */ - -struct ESS_cert_id_v2_st { - X509_ALGOR *hash_alg; /* Default: SHA-256 */ - ASN1_OCTET_STRING *hash; - ESS_ISSUER_SERIAL *issuer_serial; -}; - -/*- - * SigningCertificateV2 ::= SEQUENCE { - * certs SEQUENCE OF ESSCertIDv2, - * policies SEQUENCE OF PolicyInformation OPTIONAL - * } - */ - -struct ESS_signing_cert_v2_st { - STACK_OF(ESS_CERT_ID_V2) *cert_ids; - STACK_OF(POLICYINFO) *policy_info; -}; - - -struct TS_resp_ctx { - X509 *signer_cert; - EVP_PKEY *signer_key; - const EVP_MD *signer_md; - const EVP_MD *ess_cert_id_digest; - STACK_OF(X509) *certs; /* Certs to include in signed data. */ - STACK_OF(ASN1_OBJECT) *policies; /* Acceptable policies. */ - ASN1_OBJECT *default_policy; /* It may appear in policies, too. */ - STACK_OF(EVP_MD) *mds; /* Acceptable message digests. */ - ASN1_INTEGER *seconds; /* accuracy, 0 means not specified. */ - ASN1_INTEGER *millis; /* accuracy, 0 means not specified. */ - ASN1_INTEGER *micros; /* accuracy, 0 means not specified. */ - unsigned clock_precision_digits; /* fraction of seconds in time stamp - * token. */ - unsigned flags; /* Optional info, see values above. */ - /* Callback functions. */ - TS_serial_cb serial_cb; - void *serial_cb_data; /* User data for serial_cb. */ - TS_time_cb time_cb; - void *time_cb_data; /* User data for time_cb. */ - TS_extension_cb extension_cb; - void *extension_cb_data; /* User data for extension_cb. */ - /* These members are used only while creating the response. */ - TS_REQ *request; - TS_RESP *response; - TS_TST_INFO *tst_info; -}; - -struct TS_verify_ctx { - /* Set this to the union of TS_VFY_... flags you want to carry out. */ - unsigned flags; - /* Must be set only with TS_VFY_SIGNATURE. certs is optional. */ - X509_STORE *store; - STACK_OF(X509) *certs; - /* Must be set only with TS_VFY_POLICY. */ - ASN1_OBJECT *policy; - /* - * Must be set only with TS_VFY_IMPRINT. If md_alg is NULL, the - * algorithm from the response is used. - */ - X509_ALGOR *md_alg; - unsigned char *imprint; - unsigned imprint_len; - /* Must be set only with TS_VFY_DATA. */ - BIO *data; - /* Must be set only with TS_VFY_TSA_NAME. */ - ASN1_INTEGER *nonce; - /* Must be set only with TS_VFY_TSA_NAME. */ - GENERAL_NAME *tsa_name; -}; +/* + * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/*- + * MessageImprint ::= SEQUENCE { + * hashAlgorithm AlgorithmIdentifier, + * hashedMessage OCTET STRING } + */ +struct TS_msg_imprint_st { + X509_ALGOR *hash_algo; + ASN1_OCTET_STRING *hashed_msg; +}; + +/*- + * TimeStampResp ::= SEQUENCE { + * status PKIStatusInfo, + * timeStampToken TimeStampToken OPTIONAL } + */ +struct TS_resp_st { + TS_STATUS_INFO *status_info; + PKCS7 *token; + TS_TST_INFO *tst_info; +}; + +/*- + * TimeStampReq ::= SEQUENCE { + * version INTEGER { v1(1) }, + * messageImprint MessageImprint, + * --a hash algorithm OID and the hash value of the data to be + * --time-stamped + * reqPolicy TSAPolicyId OPTIONAL, + * nonce INTEGER OPTIONAL, + * certReq BOOLEAN DEFAULT FALSE, + * extensions [0] IMPLICIT Extensions OPTIONAL } + */ +struct TS_req_st { + ASN1_INTEGER *version; + TS_MSG_IMPRINT *msg_imprint; + ASN1_OBJECT *policy_id; + ASN1_INTEGER *nonce; + ASN1_BOOLEAN cert_req; + STACK_OF(X509_EXTENSION) *extensions; +}; + +/*- + * Accuracy ::= SEQUENCE { + * seconds INTEGER OPTIONAL, + * millis [0] INTEGER (1..999) OPTIONAL, + * micros [1] INTEGER (1..999) OPTIONAL } + */ +struct TS_accuracy_st { + ASN1_INTEGER *seconds; + ASN1_INTEGER *millis; + ASN1_INTEGER *micros; +}; + +/*- + * TSTInfo ::= SEQUENCE { + * version INTEGER { v1(1) }, + * policy TSAPolicyId, + * messageImprint MessageImprint, + * -- MUST have the same value as the similar field in + * -- TimeStampReq + * serialNumber INTEGER, + * -- Time-Stamping users MUST be ready to accommodate integers + * -- up to 160 bits. + * genTime GeneralizedTime, + * accuracy Accuracy OPTIONAL, + * ordering BOOLEAN DEFAULT FALSE, + * nonce INTEGER OPTIONAL, + * -- MUST be present if the similar field was present + * -- in TimeStampReq. In that case it MUST have the same value. + * tsa [0] GeneralName OPTIONAL, + * extensions [1] IMPLICIT Extensions OPTIONAL } + */ +struct TS_tst_info_st { + ASN1_INTEGER *version; + ASN1_OBJECT *policy_id; + TS_MSG_IMPRINT *msg_imprint; + ASN1_INTEGER *serial; + ASN1_GENERALIZEDTIME *time; + TS_ACCURACY *accuracy; + ASN1_BOOLEAN ordering; + ASN1_INTEGER *nonce; + GENERAL_NAME *tsa; + STACK_OF(X509_EXTENSION) *extensions; +}; + +struct TS_status_info_st { + ASN1_INTEGER *status; + STACK_OF(ASN1_UTF8STRING) *text; + ASN1_BIT_STRING *failure_info; +}; + +/*- + * IssuerSerial ::= SEQUENCE { + * issuer GeneralNames, + * serialNumber CertificateSerialNumber + * } + */ +struct ESS_issuer_serial { + STACK_OF(GENERAL_NAME) *issuer; + ASN1_INTEGER *serial; +}; + +/*- + * ESSCertID ::= SEQUENCE { + * certHash Hash, + * issuerSerial IssuerSerial OPTIONAL + * } + */ +struct ESS_cert_id { + ASN1_OCTET_STRING *hash; /* Always SHA-1 digest. */ + ESS_ISSUER_SERIAL *issuer_serial; +}; + +/*- + * SigningCertificate ::= SEQUENCE { + * certs SEQUENCE OF ESSCertID, + * policies SEQUENCE OF PolicyInformation OPTIONAL + * } + */ +struct ESS_signing_cert { + STACK_OF(ESS_CERT_ID) *cert_ids; + STACK_OF(POLICYINFO) *policy_info; +}; + +/*- + * ESSCertIDv2 ::= SEQUENCE { + * hashAlgorithm AlgorithmIdentifier + * DEFAULT {algorithm id-sha256}, + * certHash Hash, + * issuerSerial IssuerSerial OPTIONAL + * } + */ + +struct ESS_cert_id_v2_st { + X509_ALGOR *hash_alg; /* Default: SHA-256 */ + ASN1_OCTET_STRING *hash; + ESS_ISSUER_SERIAL *issuer_serial; +}; + +/*- + * SigningCertificateV2 ::= SEQUENCE { + * certs SEQUENCE OF ESSCertIDv2, + * policies SEQUENCE OF PolicyInformation OPTIONAL + * } + */ + +struct ESS_signing_cert_v2_st { + STACK_OF(ESS_CERT_ID_V2) *cert_ids; + STACK_OF(POLICYINFO) *policy_info; +}; + + +struct TS_resp_ctx { + X509 *signer_cert; + EVP_PKEY *signer_key; + const EVP_MD *signer_md; + const EVP_MD *ess_cert_id_digest; + STACK_OF(X509) *certs; /* Certs to include in signed data. */ + STACK_OF(ASN1_OBJECT) *policies; /* Acceptable policies. */ + ASN1_OBJECT *default_policy; /* It may appear in policies, too. */ + STACK_OF(EVP_MD) *mds; /* Acceptable message digests. */ + ASN1_INTEGER *seconds; /* accuracy, 0 means not specified. */ + ASN1_INTEGER *millis; /* accuracy, 0 means not specified. */ + ASN1_INTEGER *micros; /* accuracy, 0 means not specified. */ + unsigned clock_precision_digits; /* fraction of seconds in time stamp + * token. */ + unsigned flags; /* Optional info, see values above. */ + /* Callback functions. */ + TS_serial_cb serial_cb; + void *serial_cb_data; /* User data for serial_cb. */ + TS_time_cb time_cb; + void *time_cb_data; /* User data for time_cb. */ + TS_extension_cb extension_cb; + void *extension_cb_data; /* User data for extension_cb. */ + /* These members are used only while creating the response. */ + TS_REQ *request; + TS_RESP *response; + TS_TST_INFO *tst_info; +}; + +struct TS_verify_ctx { + /* Set this to the union of TS_VFY_... flags you want to carry out. */ + unsigned flags; + /* Must be set only with TS_VFY_SIGNATURE. certs is optional. */ + X509_STORE *store; + STACK_OF(X509) *certs; + /* Must be set only with TS_VFY_POLICY. */ + ASN1_OBJECT *policy; + /* + * Must be set only with TS_VFY_IMPRINT. If md_alg is NULL, the + * algorithm from the response is used. + */ + X509_ALGOR *md_alg; + unsigned char *imprint; + unsigned imprint_len; + /* Must be set only with TS_VFY_DATA. */ + BIO *data; + /* Must be set only with TS_VFY_TSA_NAME. */ + ASN1_INTEGER *nonce; + /* Must be set only with TS_VFY_TSA_NAME. */ + GENERAL_NAME *tsa_name; +}; diff --git a/contrib/libs/openssl/crypto/ts/ts_req_print.c b/contrib/libs/openssl/crypto/ts/ts_req_print.c index 084e7324d4..4eba5cf018 100644 --- a/contrib/libs/openssl/crypto/ts/ts_req_print.c +++ b/contrib/libs/openssl/crypto/ts/ts_req_print.c @@ -13,7 +13,7 @@ #include <openssl/bn.h> #include <openssl/x509v3.h> #include <openssl/ts.h> -#include "ts_local.h" +#include "ts_local.h" int TS_REQ_print_bio(BIO *bio, TS_REQ *a) { diff --git a/contrib/libs/openssl/crypto/ts/ts_req_utils.c b/contrib/libs/openssl/crypto/ts/ts_req_utils.c index 2f6019fa03..a4568e3b77 100644 --- a/contrib/libs/openssl/crypto/ts/ts_req_utils.c +++ b/contrib/libs/openssl/crypto/ts/ts_req_utils.c @@ -12,7 +12,7 @@ #include <openssl/objects.h> #include <openssl/x509v3.h> #include <openssl/ts.h> -#include "ts_local.h" +#include "ts_local.h" int TS_REQ_set_version(TS_REQ *a, long version) { diff --git a/contrib/libs/openssl/crypto/ts/ts_rsp_print.c b/contrib/libs/openssl/crypto/ts/ts_rsp_print.c index 82e5402ecf..a2451aaa8d 100644 --- a/contrib/libs/openssl/crypto/ts/ts_rsp_print.c +++ b/contrib/libs/openssl/crypto/ts/ts_rsp_print.c @@ -13,7 +13,7 @@ #include <openssl/bn.h> #include <openssl/x509v3.h> #include <openssl/ts.h> -#include "ts_local.h" +#include "ts_local.h" struct status_map_st { int bit; diff --git a/contrib/libs/openssl/crypto/ts/ts_rsp_sign.c b/contrib/libs/openssl/crypto/ts/ts_rsp_sign.c index 9d1ab8b8f2..342582f024 100644 --- a/contrib/libs/openssl/crypto/ts/ts_rsp_sign.c +++ b/contrib/libs/openssl/crypto/ts/ts_rsp_sign.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -14,7 +14,7 @@ #include <openssl/ts.h> #include <openssl/pkcs7.h> #include <openssl/crypto.h> -#include "ts_local.h" +#include "ts_local.h" static ASN1_INTEGER *def_serial_cb(struct TS_resp_ctx *, void *); static int def_time_cb(struct TS_resp_ctx *, void *, long *sec, long *usec); @@ -773,8 +773,8 @@ static ESS_CERT_ID *ess_CERT_ID_new_init(X509 *cert, int issuer_needed) X509_check_purpose(cert, -1, 0); if ((cid = ESS_CERT_ID_new()) == NULL) goto err; - if (!X509_digest(cert, EVP_sha1(), cert_sha1, NULL)) - goto err; + if (!X509_digest(cert, EVP_sha1(), cert_sha1, NULL)) + goto err; if (!ASN1_OCTET_STRING_set(cid->hash, cert_sha1, SHA_DIGEST_LENGTH)) goto err; diff --git a/contrib/libs/openssl/crypto/ts/ts_rsp_utils.c b/contrib/libs/openssl/crypto/ts/ts_rsp_utils.c index 45b89ee967..3fa0dbd0f0 100644 --- a/contrib/libs/openssl/crypto/ts/ts_rsp_utils.c +++ b/contrib/libs/openssl/crypto/ts/ts_rsp_utils.c @@ -12,7 +12,7 @@ #include <openssl/objects.h> #include <openssl/ts.h> #include <openssl/pkcs7.h> -#include "ts_local.h" +#include "ts_local.h" int TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *status_info) { diff --git a/contrib/libs/openssl/crypto/ts/ts_rsp_verify.c b/contrib/libs/openssl/crypto/ts/ts_rsp_verify.c index 5ffc28749b..7fe3d27e74 100644 --- a/contrib/libs/openssl/crypto/ts/ts_rsp_verify.c +++ b/contrib/libs/openssl/crypto/ts/ts_rsp_verify.c @@ -12,7 +12,7 @@ #include <openssl/objects.h> #include <openssl/ts.h> #include <openssl/pkcs7.h> -#include "ts_local.h" +#include "ts_local.h" static int ts_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted, X509 *signer, STACK_OF(X509) **chain); @@ -292,9 +292,9 @@ static int ts_find_cert(STACK_OF(ESS_CERT_ID) *cert_ids, X509 *cert) /* Recompute SHA1 hash of certificate if necessary (side effect). */ X509_check_purpose(cert, -1, 0); - if (!X509_digest(cert, EVP_sha1(), cert_sha1, NULL)) - return -1; - + if (!X509_digest(cert, EVP_sha1(), cert_sha1, NULL)) + return -1; + /* Look for cert in the cert_ids vector. */ for (i = 0; i < sk_ESS_CERT_ID_num(cert_ids); ++i) { ESS_CERT_ID *cid = sk_ESS_CERT_ID_value(cert_ids, i); @@ -327,8 +327,8 @@ static int ts_find_cert_v2(STACK_OF(ESS_CERT_ID_V2) *cert_ids, X509 *cert) else md = EVP_sha256(); - if (!X509_digest(cert, md, cert_digest, &len)) - return -1; + if (!X509_digest(cert, md, cert_digest, &len)) + return -1; if (cid->hash->length != (int)len) return -1; diff --git a/contrib/libs/openssl/crypto/ts/ts_verify_ctx.c b/contrib/libs/openssl/crypto/ts/ts_verify_ctx.c index b3bd6abab6..32cd2f542b 100644 --- a/contrib/libs/openssl/crypto/ts/ts_verify_ctx.c +++ b/contrib/libs/openssl/crypto/ts/ts_verify_ctx.c @@ -10,7 +10,7 @@ #include "internal/cryptlib.h" #include <openssl/objects.h> #include <openssl/ts.h> -#include "ts_local.h" +#include "ts_local.h" TS_VERIFY_CTX *TS_VERIFY_CTX_new(void) { diff --git a/contrib/libs/openssl/crypto/ui/ui_lib.c b/contrib/libs/openssl/crypto/ui/ui_lib.c index 4161d26030..49cc45057c 100644 --- a/contrib/libs/openssl/crypto/ui/ui_lib.c +++ b/contrib/libs/openssl/crypto/ui/ui_lib.c @@ -13,7 +13,7 @@ #include <openssl/buffer.h> #include <openssl/ui.h> #include <openssl/err.h> -#include "ui_local.h" +#include "ui_local.h" UI *UI_new(void) { diff --git a/contrib/libs/openssl/crypto/ui/ui_local.h b/contrib/libs/openssl/crypto/ui/ui_local.h index b80dfc3094..8a7dbda147 100644 --- a/contrib/libs/openssl/crypto/ui/ui_local.h +++ b/contrib/libs/openssl/crypto/ui/ui_local.h @@ -1,109 +1,109 @@ -/* - * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_UI_LOCAL_H -# define OSSL_CRYPTO_UI_LOCAL_H - -# include <openssl/ui.h> -# include <openssl/crypto.h> - -# ifdef _ -# undef _ -# endif - -struct ui_method_st { - char *name; - /* - * All the functions return 1 or non-NULL for success and 0 or NULL for - * failure - */ - /* - * Open whatever channel for this, be it the console, an X window or - * whatever. This function should use the ex_data structure to save - * intermediate data. - */ - int (*ui_open_session) (UI *ui); - int (*ui_write_string) (UI *ui, UI_STRING *uis); - /* - * Flush the output. If a GUI dialog box is used, this function can be - * used to actually display it. - */ - int (*ui_flush) (UI *ui); - int (*ui_read_string) (UI *ui, UI_STRING *uis); - int (*ui_close_session) (UI *ui); - /* - * Duplicate the ui_data that often comes alongside a ui_method. This - * allows some backends to save away UI information for later use. - */ - void *(*ui_duplicate_data) (UI *ui, void *ui_data); - void (*ui_destroy_data) (UI *ui, void *ui_data); - /* - * Construct a prompt in a user-defined manner. object_desc is a textual - * short description of the object, for example "pass phrase", and - * object_name is the name of the object (might be a card name or a file - * name. The returned string shall always be allocated on the heap with - * OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). - */ - char *(*ui_construct_prompt) (UI *ui, const char *object_desc, - const char *object_name); - /* - * UI_METHOD specific application data. - */ - CRYPTO_EX_DATA ex_data; -}; - -struct ui_string_st { - enum UI_string_types type; /* Input */ - const char *out_string; /* Input */ - int input_flags; /* Flags from the user */ - /* - * The following parameters are completely irrelevant for UIT_INFO, and - * can therefore be set to 0 or NULL - */ - char *result_buf; /* Input and Output: If not NULL, - * user-defined with size in result_maxsize. - * Otherwise, it may be allocated by the UI - * routine, meaning result_minsize is going - * to be overwritten. */ - size_t result_len; - union { - struct { - int result_minsize; /* Input: minimum required size of the - * result. */ - int result_maxsize; /* Input: maximum permitted size of the - * result */ - const char *test_buf; /* Input: test string to verify against */ - } string_data; - struct { - const char *action_desc; /* Input */ - const char *ok_chars; /* Input */ - const char *cancel_chars; /* Input */ - } boolean_data; - } _; - -# define OUT_STRING_FREEABLE 0x01 - int flags; /* flags for internal use */ -}; - -struct ui_st { - const UI_METHOD *meth; - STACK_OF(UI_STRING) *strings; /* We might want to prompt for more than - * one thing at a time, and with different - * echoing status. */ - void *user_data; - CRYPTO_EX_DATA ex_data; -# define UI_FLAG_REDOABLE 0x0001 -# define UI_FLAG_DUPL_DATA 0x0002 /* user_data was duplicated */ -# define UI_FLAG_PRINT_ERRORS 0x0100 - int flags; - - CRYPTO_RWLOCK *lock; -}; - -#endif +/* + * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_UI_LOCAL_H +# define OSSL_CRYPTO_UI_LOCAL_H + +# include <openssl/ui.h> +# include <openssl/crypto.h> + +# ifdef _ +# undef _ +# endif + +struct ui_method_st { + char *name; + /* + * All the functions return 1 or non-NULL for success and 0 or NULL for + * failure + */ + /* + * Open whatever channel for this, be it the console, an X window or + * whatever. This function should use the ex_data structure to save + * intermediate data. + */ + int (*ui_open_session) (UI *ui); + int (*ui_write_string) (UI *ui, UI_STRING *uis); + /* + * Flush the output. If a GUI dialog box is used, this function can be + * used to actually display it. + */ + int (*ui_flush) (UI *ui); + int (*ui_read_string) (UI *ui, UI_STRING *uis); + int (*ui_close_session) (UI *ui); + /* + * Duplicate the ui_data that often comes alongside a ui_method. This + * allows some backends to save away UI information for later use. + */ + void *(*ui_duplicate_data) (UI *ui, void *ui_data); + void (*ui_destroy_data) (UI *ui, void *ui_data); + /* + * Construct a prompt in a user-defined manner. object_desc is a textual + * short description of the object, for example "pass phrase", and + * object_name is the name of the object (might be a card name or a file + * name. The returned string shall always be allocated on the heap with + * OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). + */ + char *(*ui_construct_prompt) (UI *ui, const char *object_desc, + const char *object_name); + /* + * UI_METHOD specific application data. + */ + CRYPTO_EX_DATA ex_data; +}; + +struct ui_string_st { + enum UI_string_types type; /* Input */ + const char *out_string; /* Input */ + int input_flags; /* Flags from the user */ + /* + * The following parameters are completely irrelevant for UIT_INFO, and + * can therefore be set to 0 or NULL + */ + char *result_buf; /* Input and Output: If not NULL, + * user-defined with size in result_maxsize. + * Otherwise, it may be allocated by the UI + * routine, meaning result_minsize is going + * to be overwritten. */ + size_t result_len; + union { + struct { + int result_minsize; /* Input: minimum required size of the + * result. */ + int result_maxsize; /* Input: maximum permitted size of the + * result */ + const char *test_buf; /* Input: test string to verify against */ + } string_data; + struct { + const char *action_desc; /* Input */ + const char *ok_chars; /* Input */ + const char *cancel_chars; /* Input */ + } boolean_data; + } _; + +# define OUT_STRING_FREEABLE 0x01 + int flags; /* flags for internal use */ +}; + +struct ui_st { + const UI_METHOD *meth; + STACK_OF(UI_STRING) *strings; /* We might want to prompt for more than + * one thing at a time, and with different + * echoing status. */ + void *user_data; + CRYPTO_EX_DATA ex_data; +# define UI_FLAG_REDOABLE 0x0001 +# define UI_FLAG_DUPL_DATA 0x0002 /* user_data was duplicated */ +# define UI_FLAG_PRINT_ERRORS 0x0100 + int flags; + + CRYPTO_RWLOCK *lock; +}; + +#endif diff --git a/contrib/libs/openssl/crypto/ui/ui_null.c b/contrib/libs/openssl/crypto/ui/ui_null.c index d7c3a7bbb9..9ab00e0a7c 100644 --- a/contrib/libs/openssl/crypto/ui/ui_null.c +++ b/contrib/libs/openssl/crypto/ui/ui_null.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "ui_local.h" +#include "ui_local.h" static const UI_METHOD ui_null = { "OpenSSL NULL UI", diff --git a/contrib/libs/openssl/crypto/ui/ui_openssl.c b/contrib/libs/openssl/crypto/ui/ui_openssl.c index 6c6177f6aa..9526c16536 100644 --- a/contrib/libs/openssl/crypto/ui/ui_openssl.c +++ b/contrib/libs/openssl/crypto/ui/ui_openssl.c @@ -53,7 +53,7 @@ # endif # endif -# include "ui_local.h" +# include "ui_local.h" # include "internal/cryptlib.h" # ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */ diff --git a/contrib/libs/openssl/crypto/ui/ui_util.c b/contrib/libs/openssl/crypto/ui/ui_util.c index 3212ea3d23..32a3c4e38d 100644 --- a/contrib/libs/openssl/crypto/ui/ui_util.c +++ b/contrib/libs/openssl/crypto/ui/ui_util.c @@ -8,9 +8,9 @@ */ #include <string.h> -#include <openssl/pem.h> /* PEM_def_callback() */ +#include <openssl/pem.h> /* PEM_def_callback() */ #include "internal/thread_once.h" -#include "ui_local.h" +#include "ui_local.h" #ifndef BUFSIZ #define BUFSIZ 256 @@ -157,7 +157,7 @@ UI_METHOD *UI_UTIL_wrap_read_pem_callback(pem_password_cb *cb, int rwflag) return NULL; } data->rwflag = rwflag; - data->cb = cb != NULL ? cb : PEM_def_callback; + data->cb = cb != NULL ? cb : PEM_def_callback; return ui_method; } diff --git a/contrib/libs/openssl/crypto/whrlpool/wp_block.c b/contrib/libs/openssl/crypto/whrlpool/wp_block.c index 204e5f2add..39ad009c01 100644 --- a/contrib/libs/openssl/crypto/whrlpool/wp_block.c +++ b/contrib/libs/openssl/crypto/whrlpool/wp_block.c @@ -36,7 +36,7 @@ * */ -#include "wp_local.h" +#include "wp_local.h" #include <string.h> typedef unsigned char u8; diff --git a/contrib/libs/openssl/crypto/whrlpool/wp_dgst.c b/contrib/libs/openssl/crypto/whrlpool/wp_dgst.c index 7e3e275e1d..e8a3392268 100644 --- a/contrib/libs/openssl/crypto/whrlpool/wp_dgst.c +++ b/contrib/libs/openssl/crypto/whrlpool/wp_dgst.c @@ -53,7 +53,7 @@ */ #include <openssl/crypto.h> -#include "wp_local.h" +#include "wp_local.h" #include <string.h> int WHIRLPOOL_Init(WHIRLPOOL_CTX *c) diff --git a/contrib/libs/openssl/crypto/whrlpool/wp_local.h b/contrib/libs/openssl/crypto/whrlpool/wp_local.h index 441dc3a205..3a81cfd58c 100644 --- a/contrib/libs/openssl/crypto/whrlpool/wp_local.h +++ b/contrib/libs/openssl/crypto/whrlpool/wp_local.h @@ -1,12 +1,12 @@ -/* - * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <openssl/whrlpool.h> - -void whirlpool_block(WHIRLPOOL_CTX *, const void *, size_t); +/* + * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <openssl/whrlpool.h> + +void whirlpool_block(WHIRLPOOL_CTX *, const void *, size_t); diff --git a/contrib/libs/openssl/crypto/x509/by_dir.c b/contrib/libs/openssl/crypto/x509/by_dir.c index 8da9fc4313..238c2519a6 100644 --- a/contrib/libs/openssl/crypto/x509/by_dir.c +++ b/contrib/libs/openssl/crypto/x509/by_dir.c @@ -19,8 +19,8 @@ #endif #include <openssl/x509.h> -#include "crypto/x509.h" -#include "x509_local.h" +#include "crypto/x509.h" +#include "x509_local.h" struct lookup_dir_hashes_st { unsigned long hash; diff --git a/contrib/libs/openssl/crypto/x509/by_file.c b/contrib/libs/openssl/crypto/x509/by_file.c index b058309808..237b362e27 100644 --- a/contrib/libs/openssl/crypto/x509/by_file.c +++ b/contrib/libs/openssl/crypto/x509/by_file.c @@ -15,7 +15,7 @@ #include <openssl/buffer.h> #include <openssl/x509.h> #include <openssl/pem.h> -#include "x509_local.h" +#include "x509_local.h" static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl, char **ret); diff --git a/contrib/libs/openssl/crypto/x509/t_x509.c b/contrib/libs/openssl/crypto/x509/t_x509.c index b330a68699..ece987a6bd 100644 --- a/contrib/libs/openssl/crypto/x509/t_x509.c +++ b/contrib/libs/openssl/crypto/x509/t_x509.c @@ -14,7 +14,7 @@ #include <openssl/objects.h> #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "crypto/asn1.h" +#include "crypto/asn1.h" #ifndef OPENSSL_NO_STDIO int X509_print_fp(FILE *fp, X509 *x) diff --git a/contrib/libs/openssl/crypto/x509/x509_att.c b/contrib/libs/openssl/crypto/x509/x509_att.c index 93db322cec..cc9f9d1909 100644 --- a/contrib/libs/openssl/crypto/x509/x509_att.c +++ b/contrib/libs/openssl/crypto/x509/x509_att.c @@ -15,7 +15,7 @@ #include <openssl/evp.h> #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "x509_local.h" +#include "x509_local.h" int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x) { diff --git a/contrib/libs/openssl/crypto/x509/x509_cmp.c b/contrib/libs/openssl/crypto/x509/x509_cmp.c index 4e6cdc2ab2..1d8d2d7b28 100644 --- a/contrib/libs/openssl/crypto/x509/x509_cmp.c +++ b/contrib/libs/openssl/crypto/x509/x509_cmp.c @@ -13,7 +13,7 @@ #include <openssl/objects.h> #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b) { @@ -136,7 +136,7 @@ unsigned long X509_subject_name_hash_old(X509 *x) int X509_cmp(const X509 *a, const X509 *b) { int rv = 0; - + if (a == b) /* for efficiency */ return 0; diff --git a/contrib/libs/openssl/crypto/x509/x509_ext.c b/contrib/libs/openssl/crypto/x509/x509_ext.c index 59ce5278a3..4cdab724ea 100644 --- a/contrib/libs/openssl/crypto/x509/x509_ext.c +++ b/contrib/libs/openssl/crypto/x509/x509_ext.c @@ -13,7 +13,7 @@ #include <openssl/objects.h> #include <openssl/evp.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include <openssl/x509v3.h> int X509_CRL_get_ext_count(const X509_CRL *x) diff --git a/contrib/libs/openssl/crypto/x509/x509_local.h b/contrib/libs/openssl/crypto/x509/x509_local.h index 7eb251bff1..10807e1def 100644 --- a/contrib/libs/openssl/crypto/x509/x509_local.h +++ b/contrib/libs/openssl/crypto/x509/x509_local.h @@ -1,149 +1,149 @@ -/* +/* * Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include "internal/refcount.h" - -/* - * This structure holds all parameters associated with a verify operation by - * including an X509_VERIFY_PARAM structure in related structures the - * parameters used can be customized - */ - -struct X509_VERIFY_PARAM_st { - char *name; - time_t check_time; /* Time to use */ - uint32_t inh_flags; /* Inheritance flags */ - unsigned long flags; /* Various verify flags */ - int purpose; /* purpose to check untrusted certificates */ - int trust; /* trust setting to check */ - int depth; /* Verify depth */ - int auth_level; /* Security level for chain verification */ - STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ - /* Peer identity details */ - STACK_OF(OPENSSL_STRING) *hosts; /* Set of acceptable names */ - unsigned int hostflags; /* Flags to control matching features */ - char *peername; /* Matching hostname in peer certificate */ - char *email; /* If not NULL email address to match */ - size_t emaillen; - unsigned char *ip; /* If not NULL IP address to match */ - size_t iplen; /* Length of IP address */ -}; - -/* No error callback if depth < 0 */ -int x509_check_cert_time(X509_STORE_CTX *ctx, X509 *x, int depth); - -/* a sequence of these are used */ -struct x509_attributes_st { - ASN1_OBJECT *object; - STACK_OF(ASN1_TYPE) *set; -}; - -struct X509_extension_st { - ASN1_OBJECT *object; - ASN1_BOOLEAN critical; - ASN1_OCTET_STRING value; -}; - -/* - * Method to handle CRL access. In general a CRL could be very large (several - * Mb) and can consume large amounts of resources if stored in memory by - * multiple processes. This method allows general CRL operations to be - * redirected to more efficient callbacks: for example a CRL entry database. - */ - -#define X509_CRL_METHOD_DYNAMIC 1 - -struct x509_crl_method_st { - int flags; - int (*crl_init) (X509_CRL *crl); - int (*crl_free) (X509_CRL *crl); - int (*crl_lookup) (X509_CRL *crl, X509_REVOKED **ret, - ASN1_INTEGER *ser, X509_NAME *issuer); - int (*crl_verify) (X509_CRL *crl, EVP_PKEY *pk); -}; - -struct x509_lookup_method_st { - char *name; - int (*new_item) (X509_LOOKUP *ctx); - void (*free) (X509_LOOKUP *ctx); - int (*init) (X509_LOOKUP *ctx); - int (*shutdown) (X509_LOOKUP *ctx); - int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl, - char **ret); - int (*get_by_subject) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - X509_NAME *name, X509_OBJECT *ret); - int (*get_by_issuer_serial) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - X509_NAME *name, ASN1_INTEGER *serial, - X509_OBJECT *ret); - int (*get_by_fingerprint) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - const unsigned char *bytes, int len, - X509_OBJECT *ret); - int (*get_by_alias) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - const char *str, int len, X509_OBJECT *ret); -}; - -/* This is the functions plus an instance of the local variables. */ -struct x509_lookup_st { - int init; /* have we been started */ - int skip; /* don't use us. */ - X509_LOOKUP_METHOD *method; /* the functions */ - void *method_data; /* method data */ - X509_STORE *store_ctx; /* who owns us */ -}; - -/* - * This is used to hold everything. It is used for all certificate - * validation. Once we have a certificate chain, the 'verify' function is - * then called to actually check the cert chain. - */ -struct x509_store_st { - /* The following is a cache of trusted certs */ - int cache; /* if true, stash any hits */ - STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */ - /* These are external lookup methods */ - STACK_OF(X509_LOOKUP) *get_cert_methods; - X509_VERIFY_PARAM *param; - /* Callbacks for various operations */ - /* called to verify a certificate */ - int (*verify) (X509_STORE_CTX *ctx); - /* error callback */ - int (*verify_cb) (int ok, X509_STORE_CTX *ctx); - /* get issuers cert from ctx */ - int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x); - /* check issued */ - int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer); - /* Check revocation status of chain */ - int (*check_revocation) (X509_STORE_CTX *ctx); - /* retrieve CRL */ - int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); - /* Check CRL validity */ - int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl); - /* Check certificate against CRL */ - int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); - /* Check policy status of the chain */ - int (*check_policy) (X509_STORE_CTX *ctx); - STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm); - STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm); - int (*cleanup) (X509_STORE_CTX *ctx); - CRYPTO_EX_DATA ex_data; - CRYPTO_REF_COUNT references; - CRYPTO_RWLOCK *lock; -}; - -typedef struct lookup_dir_hashes_st BY_DIR_HASH; -typedef struct lookup_dir_entry_st BY_DIR_ENTRY; -DEFINE_STACK_OF(BY_DIR_HASH) -DEFINE_STACK_OF(BY_DIR_ENTRY) -typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY; -DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY) - -void x509_set_signature_info(X509_SIG_INFO *siginf, const X509_ALGOR *alg, - const ASN1_STRING *sig); + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "internal/refcount.h" + +/* + * This structure holds all parameters associated with a verify operation by + * including an X509_VERIFY_PARAM structure in related structures the + * parameters used can be customized + */ + +struct X509_VERIFY_PARAM_st { + char *name; + time_t check_time; /* Time to use */ + uint32_t inh_flags; /* Inheritance flags */ + unsigned long flags; /* Various verify flags */ + int purpose; /* purpose to check untrusted certificates */ + int trust; /* trust setting to check */ + int depth; /* Verify depth */ + int auth_level; /* Security level for chain verification */ + STACK_OF(ASN1_OBJECT) *policies; /* Permissible policies */ + /* Peer identity details */ + STACK_OF(OPENSSL_STRING) *hosts; /* Set of acceptable names */ + unsigned int hostflags; /* Flags to control matching features */ + char *peername; /* Matching hostname in peer certificate */ + char *email; /* If not NULL email address to match */ + size_t emaillen; + unsigned char *ip; /* If not NULL IP address to match */ + size_t iplen; /* Length of IP address */ +}; + +/* No error callback if depth < 0 */ +int x509_check_cert_time(X509_STORE_CTX *ctx, X509 *x, int depth); + +/* a sequence of these are used */ +struct x509_attributes_st { + ASN1_OBJECT *object; + STACK_OF(ASN1_TYPE) *set; +}; + +struct X509_extension_st { + ASN1_OBJECT *object; + ASN1_BOOLEAN critical; + ASN1_OCTET_STRING value; +}; + +/* + * Method to handle CRL access. In general a CRL could be very large (several + * Mb) and can consume large amounts of resources if stored in memory by + * multiple processes. This method allows general CRL operations to be + * redirected to more efficient callbacks: for example a CRL entry database. + */ + +#define X509_CRL_METHOD_DYNAMIC 1 + +struct x509_crl_method_st { + int flags; + int (*crl_init) (X509_CRL *crl); + int (*crl_free) (X509_CRL *crl); + int (*crl_lookup) (X509_CRL *crl, X509_REVOKED **ret, + ASN1_INTEGER *ser, X509_NAME *issuer); + int (*crl_verify) (X509_CRL *crl, EVP_PKEY *pk); +}; + +struct x509_lookup_method_st { + char *name; + int (*new_item) (X509_LOOKUP *ctx); + void (*free) (X509_LOOKUP *ctx); + int (*init) (X509_LOOKUP *ctx); + int (*shutdown) (X509_LOOKUP *ctx); + int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl, + char **ret); + int (*get_by_subject) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + X509_NAME *name, X509_OBJECT *ret); + int (*get_by_issuer_serial) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + X509_NAME *name, ASN1_INTEGER *serial, + X509_OBJECT *ret); + int (*get_by_fingerprint) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const unsigned char *bytes, int len, + X509_OBJECT *ret); + int (*get_by_alias) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, + const char *str, int len, X509_OBJECT *ret); +}; + +/* This is the functions plus an instance of the local variables. */ +struct x509_lookup_st { + int init; /* have we been started */ + int skip; /* don't use us. */ + X509_LOOKUP_METHOD *method; /* the functions */ + void *method_data; /* method data */ + X509_STORE *store_ctx; /* who owns us */ +}; + +/* + * This is used to hold everything. It is used for all certificate + * validation. Once we have a certificate chain, the 'verify' function is + * then called to actually check the cert chain. + */ +struct x509_store_st { + /* The following is a cache of trusted certs */ + int cache; /* if true, stash any hits */ + STACK_OF(X509_OBJECT) *objs; /* Cache of all objects */ + /* These are external lookup methods */ + STACK_OF(X509_LOOKUP) *get_cert_methods; + X509_VERIFY_PARAM *param; + /* Callbacks for various operations */ + /* called to verify a certificate */ + int (*verify) (X509_STORE_CTX *ctx); + /* error callback */ + int (*verify_cb) (int ok, X509_STORE_CTX *ctx); + /* get issuers cert from ctx */ + int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x); + /* check issued */ + int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer); + /* Check revocation status of chain */ + int (*check_revocation) (X509_STORE_CTX *ctx); + /* retrieve CRL */ + int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); + /* Check CRL validity */ + int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl); + /* Check certificate against CRL */ + int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); + /* Check policy status of the chain */ + int (*check_policy) (X509_STORE_CTX *ctx); + STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm); + STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm); + int (*cleanup) (X509_STORE_CTX *ctx); + CRYPTO_EX_DATA ex_data; + CRYPTO_REF_COUNT references; + CRYPTO_RWLOCK *lock; +}; + +typedef struct lookup_dir_hashes_st BY_DIR_HASH; +typedef struct lookup_dir_entry_st BY_DIR_ENTRY; +DEFINE_STACK_OF(BY_DIR_HASH) +DEFINE_STACK_OF(BY_DIR_ENTRY) +typedef STACK_OF(X509_NAME_ENTRY) STACK_OF_X509_NAME_ENTRY; +DEFINE_STACK_OF(STACK_OF_X509_NAME_ENTRY) + +void x509_set_signature_info(X509_SIG_INFO *siginf, const X509_ALGOR *alg, + const ASN1_STRING *sig); int x509_likely_issued(X509 *issuer, X509 *subject); int x509_signing_allowed(const X509 *issuer, const X509 *subject); diff --git a/contrib/libs/openssl/crypto/x509/x509_lu.c b/contrib/libs/openssl/crypto/x509/x509_lu.c index bbb51cc195..641a41c35c 100644 --- a/contrib/libs/openssl/crypto/x509/x509_lu.c +++ b/contrib/libs/openssl/crypto/x509/x509_lu.c @@ -11,9 +11,9 @@ #include "internal/cryptlib.h" #include "internal/refcount.h" #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include <openssl/x509v3.h> -#include "x509_local.h" +#include "x509_local.h" X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method) { diff --git a/contrib/libs/openssl/crypto/x509/x509_meth.c b/contrib/libs/openssl/crypto/x509/x509_meth.c index 0a736a96c9..9348cc8eb7 100644 --- a/contrib/libs/openssl/crypto/x509/x509_meth.c +++ b/contrib/libs/openssl/crypto/x509/x509_meth.c @@ -15,7 +15,7 @@ #include <openssl/asn1.h> #include <openssl/x509.h> #include <openssl/ossl_typ.h> -#include "x509_local.h" +#include "x509_local.h" X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name) { diff --git a/contrib/libs/openssl/crypto/x509/x509_obj.c b/contrib/libs/openssl/crypto/x509/x509_obj.c index af12404092..f54d483cc4 100644 --- a/contrib/libs/openssl/crypto/x509/x509_obj.c +++ b/contrib/libs/openssl/crypto/x509/x509_obj.c @@ -12,7 +12,7 @@ #include <openssl/objects.h> #include <openssl/x509.h> #include <openssl/buffer.h> -#include "crypto/x509.h" +#include "crypto/x509.h" /* * Limit to ensure we don't overflow: much greater than diff --git a/contrib/libs/openssl/crypto/x509/x509_r2x.c b/contrib/libs/openssl/crypto/x509/x509_r2x.c index 6f5f2f8bce..6b1623feac 100644 --- a/contrib/libs/openssl/crypto/x509/x509_r2x.c +++ b/contrib/libs/openssl/crypto/x509/x509_r2x.c @@ -13,7 +13,7 @@ #include <openssl/evp.h> #include <openssl/asn1.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include <openssl/objects.h> #include <openssl/buffer.h> diff --git a/contrib/libs/openssl/crypto/x509/x509_req.c b/contrib/libs/openssl/crypto/x509/x509_req.c index d2614a7f51..dd674926dd 100644 --- a/contrib/libs/openssl/crypto/x509/x509_req.c +++ b/contrib/libs/openssl/crypto/x509/x509_req.c @@ -14,7 +14,7 @@ #include <openssl/asn1.h> #include <openssl/asn1t.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include <openssl/objects.h> #include <openssl/buffer.h> #include <openssl/pem.h> diff --git a/contrib/libs/openssl/crypto/x509/x509_set.c b/contrib/libs/openssl/crypto/x509/x509_set.c index d46b4ef175..164b4e2be1 100644 --- a/contrib/libs/openssl/crypto/x509/x509_set.c +++ b/contrib/libs/openssl/crypto/x509/x509_set.c @@ -15,9 +15,9 @@ #include <openssl/evp.h> #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "crypto/asn1.h" -#include "crypto/x509.h" -#include "x509_local.h" +#include "crypto/asn1.h" +#include "crypto/x509.h" +#include "x509_local.h" int X509_set_version(X509 *x, long version) { diff --git a/contrib/libs/openssl/crypto/x509/x509_trs.c b/contrib/libs/openssl/crypto/x509/x509_trs.c index a00ce5d809..a10d437735 100644 --- a/contrib/libs/openssl/crypto/x509/x509_trs.c +++ b/contrib/libs/openssl/crypto/x509/x509_trs.c @@ -1,5 +1,5 @@ /* - * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" static int tr_cmp(const X509_TRUST *const *a, const X509_TRUST *const *b); static void trtable_free(X509_TRUST *p); @@ -240,9 +240,9 @@ static int trust_1oid(X509_TRUST *trust, X509 *x, int flags) static int trust_compat(X509_TRUST *trust, X509 *x, int flags) { /* Call for side-effect of computing hash and caching extensions */ - if (X509_check_purpose(x, -1, 0) != 1) - return X509_TRUST_UNTRUSTED; - if ((flags & X509_TRUST_NO_SS_COMPAT) == 0 && (x->ex_flags & EXFLAG_SS)) + if (X509_check_purpose(x, -1, 0) != 1) + return X509_TRUST_UNTRUSTED; + if ((flags & X509_TRUST_NO_SS_COMPAT) == 0 && (x->ex_flags & EXFLAG_SS)) return X509_TRUST_TRUSTED; else return X509_TRUST_UNTRUSTED; diff --git a/contrib/libs/openssl/crypto/x509/x509_v3.c b/contrib/libs/openssl/crypto/x509/x509_v3.c index 24f09f0644..c787602330 100644 --- a/contrib/libs/openssl/crypto/x509/x509_v3.c +++ b/contrib/libs/openssl/crypto/x509/x509_v3.c @@ -15,7 +15,7 @@ #include <openssl/evp.h> #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "x509_local.h" +#include "x509_local.h" int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x) { diff --git a/contrib/libs/openssl/crypto/x509/x509_vfy.c b/contrib/libs/openssl/crypto/x509/x509_vfy.c index 856dcc529a..20a36e763c 100644 --- a/contrib/libs/openssl/crypto/x509/x509_vfy.c +++ b/contrib/libs/openssl/crypto/x509/x509_vfy.c @@ -12,7 +12,7 @@ #include <errno.h> #include <limits.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/cryptlib.h" #include <openssl/crypto.h> #include <openssl/buffer.h> @@ -22,8 +22,8 @@ #include <openssl/x509v3.h> #include <openssl/objects.h> #include "internal/dane.h" -#include "crypto/x509.h" -#include "x509_local.h" +#include "crypto/x509.h" +#include "x509_local.h" /* CRL score values */ @@ -113,8 +113,8 @@ static int null_callback(int ok, X509_STORE_CTX *e) */ static int cert_self_signed(X509 *x) { - if (X509_check_purpose(x, -1, 0) != 1) - return 0; + if (X509_check_purpose(x, -1, 0) != 1) + return 0; if (x->ex_flags & EXFLAG_SS) return 1; else @@ -537,11 +537,11 @@ static int check_chain_extensions(X509_STORE_CTX *ctx) } if (ret > 0 && (x->ex_flags & EXFLAG_CA) == 0 - && x->ex_pathlen != -1 - && (ctx->param->flags & X509_V_FLAG_X509_STRICT)) { - ctx->error = X509_V_ERR_INVALID_EXTENSION; - ret = 0; - } + && x->ex_pathlen != -1 + && (ctx->param->flags & X509_V_FLAG_X509_STRICT)) { + ctx->error = X509_V_ERR_INVALID_EXTENSION; + ret = 0; + } if (ret == 0 && !verify_cb_cert(ctx, x, i, X509_V_OK)) return 0; /* check_purpose() makes the callback as needed */ diff --git a/contrib/libs/openssl/crypto/x509/x509_vpm.c b/contrib/libs/openssl/crypto/x509/x509_vpm.c index 551edfdee9..535f169a29 100644 --- a/contrib/libs/openssl/crypto/x509/x509_vpm.c +++ b/contrib/libs/openssl/crypto/x509/x509_vpm.c @@ -14,9 +14,9 @@ #include <openssl/buffer.h> #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" -#include "x509_local.h" +#include "x509_local.h" /* X509_VERIFY_PARAM functions */ diff --git a/contrib/libs/openssl/crypto/x509/x509cset.c b/contrib/libs/openssl/crypto/x509/x509cset.c index 613a126514..6c08509138 100644 --- a/contrib/libs/openssl/crypto/x509/x509cset.c +++ b/contrib/libs/openssl/crypto/x509/x509cset.c @@ -14,7 +14,7 @@ #include <openssl/objects.h> #include <openssl/evp.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" int X509_CRL_set_version(X509_CRL *x, long version) { diff --git a/contrib/libs/openssl/crypto/x509/x509name.c b/contrib/libs/openssl/crypto/x509/x509name.c index 2b1dea6235..c86d8e7914 100644 --- a/contrib/libs/openssl/crypto/x509/x509name.c +++ b/contrib/libs/openssl/crypto/x509/x509name.c @@ -14,7 +14,7 @@ #include <openssl/objects.h> #include <openssl/evp.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len) { diff --git a/contrib/libs/openssl/crypto/x509/x509rset.c b/contrib/libs/openssl/crypto/x509/x509rset.c index 98c4186944..9da3f2ee27 100644 --- a/contrib/libs/openssl/crypto/x509/x509rset.c +++ b/contrib/libs/openssl/crypto/x509/x509rset.c @@ -13,7 +13,7 @@ #include <openssl/objects.h> #include <openssl/evp.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" int X509_REQ_set_version(X509_REQ *x, long version) { diff --git a/contrib/libs/openssl/crypto/x509/x_all.c b/contrib/libs/openssl/crypto/x509/x_all.c index 04c34cfffb..a4e9cdaee8 100644 --- a/contrib/libs/openssl/crypto/x509/x_all.c +++ b/contrib/libs/openssl/crypto/x509/x_all.c @@ -13,7 +13,7 @@ #include <openssl/asn1.h> #include <openssl/evp.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include <openssl/ocsp.h> #include <openssl/rsa.h> #include <openssl/dsa.h> @@ -362,7 +362,7 @@ int X509_pubkey_digest(const X509 *data, const EVP_MD *type, int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { - if (type == EVP_sha1() && (data->ex_flags & EXFLAG_SET) != 0 + if (type == EVP_sha1() && (data->ex_flags & EXFLAG_SET) != 0 && (data->ex_flags & EXFLAG_NO_FINGERPRINT) == 0) { /* Asking for SHA1 and we already computed it. */ if (len != NULL) @@ -377,8 +377,8 @@ int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { - if (type == EVP_sha1() && (data->flags & EXFLAG_SET) != 0 - && (data->flags & EXFLAG_INVALID) == 0) { + if (type == EVP_sha1() && (data->flags & EXFLAG_SET) != 0 + && (data->flags & EXFLAG_INVALID) == 0) { /* Asking for SHA1; always computed in CRL d2i. */ if (len != NULL) *len = sizeof(data->sha1_hash); diff --git a/contrib/libs/openssl/crypto/x509/x_attrib.c b/contrib/libs/openssl/crypto/x509/x_attrib.c index c260d7dbb3..7342c4f6bc 100644 --- a/contrib/libs/openssl/crypto/x509/x_attrib.c +++ b/contrib/libs/openssl/crypto/x509/x_attrib.c @@ -12,7 +12,7 @@ #include <openssl/objects.h> #include <openssl/asn1t.h> #include <openssl/x509.h> -#include "x509_local.h" +#include "x509_local.h" /*- * X509_ATTRIBUTE: this has the following form: diff --git a/contrib/libs/openssl/crypto/x509/x_crl.c b/contrib/libs/openssl/crypto/x509/x_crl.c index 10c0345d4e..c9762f9e23 100644 --- a/contrib/libs/openssl/crypto/x509/x_crl.c +++ b/contrib/libs/openssl/crypto/x509/x_crl.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -11,13 +11,13 @@ #include "internal/cryptlib.h" #include <openssl/asn1t.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include <openssl/x509v3.h> -#include "x509_local.h" +#include "x509_local.h" static int X509_REVOKED_cmp(const X509_REVOKED *const *a, const X509_REVOKED *const *b); -static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp); +static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp); ASN1_SEQUENCE(X509_REVOKED) = { ASN1_EMBED(X509_REVOKED,serialNumber, ASN1_INTEGER), @@ -155,7 +155,7 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, X509_CRL *crl = (X509_CRL *)*pval; STACK_OF(X509_EXTENSION) *exts; X509_EXTENSION *ext; - int idx, i; + int idx, i; switch (operation) { case ASN1_OP_D2I_PRE: @@ -184,35 +184,35 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, break; case ASN1_OP_D2I_POST: - if (!X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL)) - crl->flags |= EXFLAG_INVALID; + if (!X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL)) + crl->flags |= EXFLAG_INVALID; crl->idp = X509_CRL_get_ext_d2i(crl, - NID_issuing_distribution_point, &i, + NID_issuing_distribution_point, &i, NULL); - if (crl->idp != NULL) { - if (!setup_idp(crl, crl->idp)) - crl->flags |= EXFLAG_INVALID; - } - else if (i != -1) { - crl->flags |= EXFLAG_INVALID; - } + if (crl->idp != NULL) { + if (!setup_idp(crl, crl->idp)) + crl->flags |= EXFLAG_INVALID; + } + else if (i != -1) { + crl->flags |= EXFLAG_INVALID; + } crl->akid = X509_CRL_get_ext_d2i(crl, - NID_authority_key_identifier, &i, + NID_authority_key_identifier, &i, NULL); - if (crl->akid == NULL && i != -1) - crl->flags |= EXFLAG_INVALID; + if (crl->akid == NULL && i != -1) + crl->flags |= EXFLAG_INVALID; crl->crl_number = X509_CRL_get_ext_d2i(crl, - NID_crl_number, &i, NULL); - if (crl->crl_number == NULL && i != -1) - crl->flags |= EXFLAG_INVALID; + NID_crl_number, &i, NULL); + if (crl->crl_number == NULL && i != -1) + crl->flags |= EXFLAG_INVALID; crl->base_crl_number = X509_CRL_get_ext_d2i(crl, - NID_delta_crl, &i, + NID_delta_crl, &i, NULL); - if (crl->base_crl_number == NULL && i != -1) - crl->flags |= EXFLAG_INVALID; + if (crl->base_crl_number == NULL && i != -1) + crl->flags |= EXFLAG_INVALID; /* Delta CRLs must have CRL number */ if (crl->base_crl_number && !crl->crl_number) crl->flags |= EXFLAG_INVALID; @@ -271,10 +271,10 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, /* Convert IDP into a more convenient form */ -static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp) +static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp) { int idp_only = 0; - + /* Set various flags according to IDP */ crl->idp_flags |= IDP_PRESENT; if (idp->onlyuser > 0) { @@ -305,7 +305,7 @@ static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp) crl->idp_reasons &= CRLDP_ALL_REASONS; } - return DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl)); + return DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl)); } ASN1_SEQUENCE_ref(X509_CRL, crl_cb) = { diff --git a/contrib/libs/openssl/crypto/x509/x_exten.c b/contrib/libs/openssl/crypto/x509/x_exten.c index ab91326768..bd7518ef12 100644 --- a/contrib/libs/openssl/crypto/x509/x_exten.c +++ b/contrib/libs/openssl/crypto/x509/x_exten.c @@ -11,7 +11,7 @@ #include <openssl/x509.h> #include <openssl/asn1.h> #include <openssl/asn1t.h> -#include "x509_local.h" +#include "x509_local.h" ASN1_SEQUENCE(X509_EXTENSION) = { ASN1_SIMPLE(X509_EXTENSION, object, ASN1_OBJECT), diff --git a/contrib/libs/openssl/crypto/x509/x_name.c b/contrib/libs/openssl/crypto/x509/x_name.c index c34c78d840..aa7f4722b6 100644 --- a/contrib/libs/openssl/crypto/x509/x_name.c +++ b/contrib/libs/openssl/crypto/x509/x_name.c @@ -8,13 +8,13 @@ */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/cryptlib.h" #include <openssl/asn1t.h> #include <openssl/x509.h> -#include "crypto/x509.h" -#include "crypto/asn1.h" -#include "x509_local.h" +#include "crypto/x509.h" +#include "crypto/asn1.h" +#include "x509_local.h" /* * Maximum length of X509_NAME: much larger than anything we should diff --git a/contrib/libs/openssl/crypto/x509/x_pubkey.c b/contrib/libs/openssl/crypto/x509/x_pubkey.c index 6067505133..9be7e92865 100644 --- a/contrib/libs/openssl/crypto/x509/x_pubkey.c +++ b/contrib/libs/openssl/crypto/x509/x_pubkey.c @@ -11,9 +11,9 @@ #include "internal/cryptlib.h" #include <openssl/asn1t.h> #include <openssl/x509.h> -#include "crypto/asn1.h" -#include "crypto/evp.h" -#include "crypto/x509.h" +#include "crypto/asn1.h" +#include "crypto/evp.h" +#include "crypto/x509.h" #include <openssl/rsa.h> #include <openssl/dsa.h> diff --git a/contrib/libs/openssl/crypto/x509/x_req.c b/contrib/libs/openssl/crypto/x509/x_req.c index 25031031cf..d2b02f6dae 100644 --- a/contrib/libs/openssl/crypto/x509/x_req.c +++ b/contrib/libs/openssl/crypto/x509/x_req.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include <openssl/asn1t.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" /*- * X509_REQ_INFO is handled in an unusual way to get round diff --git a/contrib/libs/openssl/crypto/x509/x_x509.c b/contrib/libs/openssl/crypto/x509/x_x509.c index c15d53368c..7aa8b77ae7 100644 --- a/contrib/libs/openssl/crypto/x509/x_x509.c +++ b/contrib/libs/openssl/crypto/x509/x_x509.c @@ -13,7 +13,7 @@ #include <openssl/asn1t.h> #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" ASN1_SEQUENCE_enc(X509_CINF, enc, 0) = { ASN1_EXP_OPT(X509_CINF, version, ASN1_INTEGER, 0), diff --git a/contrib/libs/openssl/crypto/x509/x_x509a.c b/contrib/libs/openssl/crypto/x509/x_x509a.c index 319f016268..c5175faef7 100644 --- a/contrib/libs/openssl/crypto/x509/x_x509a.c +++ b/contrib/libs/openssl/crypto/x509/x_x509a.c @@ -12,7 +12,7 @@ #include <openssl/evp.h> #include <openssl/asn1t.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" /* * X509_CERT_AUX routines. These are used to encode additional user diff --git a/contrib/libs/openssl/crypto/x509v3/pcy_cache.c b/contrib/libs/openssl/crypto/x509v3/pcy_cache.c index f8a152f901..04401bace8 100644 --- a/contrib/libs/openssl/crypto/x509v3/pcy_cache.c +++ b/contrib/libs/openssl/crypto/x509v3/pcy_cache.c @@ -10,9 +10,9 @@ #include "internal/cryptlib.h" #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" -#include "pcy_local.h" +#include "pcy_local.h" static int policy_data_cmp(const X509_POLICY_DATA *const *a, const X509_POLICY_DATA *const *b); diff --git a/contrib/libs/openssl/crypto/x509v3/pcy_data.c b/contrib/libs/openssl/crypto/x509v3/pcy_data.c index 7588925f41..8c7bc69576 100644 --- a/contrib/libs/openssl/crypto/x509v3/pcy_data.c +++ b/contrib/libs/openssl/crypto/x509v3/pcy_data.c @@ -11,7 +11,7 @@ #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "pcy_local.h" +#include "pcy_local.h" /* Policy Node routines */ diff --git a/contrib/libs/openssl/crypto/x509v3/pcy_lib.c b/contrib/libs/openssl/crypto/x509v3/pcy_lib.c index 194e966c51..2e196b838c 100644 --- a/contrib/libs/openssl/crypto/x509v3/pcy_lib.c +++ b/contrib/libs/openssl/crypto/x509v3/pcy_lib.c @@ -11,7 +11,7 @@ #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "pcy_local.h" +#include "pcy_local.h" /* accessor functions */ diff --git a/contrib/libs/openssl/crypto/x509v3/pcy_local.h b/contrib/libs/openssl/crypto/x509v3/pcy_local.h index 621da11719..5daf78de45 100644 --- a/contrib/libs/openssl/crypto/x509v3/pcy_local.h +++ b/contrib/libs/openssl/crypto/x509v3/pcy_local.h @@ -1,167 +1,167 @@ -/* - * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -typedef struct X509_POLICY_DATA_st X509_POLICY_DATA; - -DEFINE_STACK_OF(X509_POLICY_DATA) - -/* Internal structures */ - -/* - * This structure and the field names correspond to the Policy 'node' of - * RFC3280. NB this structure contains no pointers to parent or child data: - * X509_POLICY_NODE contains that. This means that the main policy data can - * be kept static and cached with the certificate. - */ - -struct X509_POLICY_DATA_st { - unsigned int flags; - /* Policy OID and qualifiers for this data */ - ASN1_OBJECT *valid_policy; - STACK_OF(POLICYQUALINFO) *qualifier_set; - STACK_OF(ASN1_OBJECT) *expected_policy_set; -}; - -/* X509_POLICY_DATA flags values */ - -/* - * This flag indicates the structure has been mapped using a policy mapping - * extension. If policy mapping is not active its references get deleted. - */ - -#define POLICY_DATA_FLAG_MAPPED 0x1 - -/* - * This flag indicates the data doesn't correspond to a policy in Certificate - * Policies: it has been mapped to any policy. - */ - -#define POLICY_DATA_FLAG_MAPPED_ANY 0x2 - -/* AND with flags to see if any mapping has occurred */ - -#define POLICY_DATA_FLAG_MAP_MASK 0x3 - -/* qualifiers are shared and shouldn't be freed */ - -#define POLICY_DATA_FLAG_SHARED_QUALIFIERS 0x4 - -/* Parent node is an extra node and should be freed */ - -#define POLICY_DATA_FLAG_EXTRA_NODE 0x8 - -/* Corresponding CertificatePolicies is critical */ - -#define POLICY_DATA_FLAG_CRITICAL 0x10 - -/* This structure is cached with a certificate */ - -struct X509_POLICY_CACHE_st { - /* anyPolicy data or NULL if no anyPolicy */ - X509_POLICY_DATA *anyPolicy; - /* other policy data */ - STACK_OF(X509_POLICY_DATA) *data; - /* If InhibitAnyPolicy present this is its value or -1 if absent. */ - long any_skip; - /* - * If policyConstraints and requireExplicitPolicy present this is its - * value or -1 if absent. - */ - long explicit_skip; - /* - * If policyConstraints and policyMapping present this is its value or -1 - * if absent. - */ - long map_skip; -}; - -/* - * #define POLICY_CACHE_FLAG_CRITICAL POLICY_DATA_FLAG_CRITICAL - */ - -/* This structure represents the relationship between nodes */ - -struct X509_POLICY_NODE_st { - /* node data this refers to */ - const X509_POLICY_DATA *data; - /* Parent node */ - X509_POLICY_NODE *parent; - /* Number of child nodes */ - int nchild; -}; - -struct X509_POLICY_LEVEL_st { - /* Cert for this level */ - X509 *cert; - /* nodes at this level */ - STACK_OF(X509_POLICY_NODE) *nodes; - /* anyPolicy node */ - X509_POLICY_NODE *anyPolicy; - /* Extra data */ - /* - * STACK_OF(X509_POLICY_DATA) *extra_data; - */ - unsigned int flags; -}; - -struct X509_POLICY_TREE_st { - /* This is the tree 'level' data */ - X509_POLICY_LEVEL *levels; - int nlevel; - /* - * Extra policy data when additional nodes (not from the certificate) are - * required. - */ - STACK_OF(X509_POLICY_DATA) *extra_data; - /* This is the authority constrained policy set */ - STACK_OF(X509_POLICY_NODE) *auth_policies; - STACK_OF(X509_POLICY_NODE) *user_policies; - unsigned int flags; -}; - -/* Set if anyPolicy present in user policies */ -#define POLICY_FLAG_ANY_POLICY 0x2 - -/* Useful macros */ - -#define node_data_critical(data) (data->flags & POLICY_DATA_FLAG_CRITICAL) -#define node_critical(node) node_data_critical(node->data) - -/* Internal functions */ - -X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, const ASN1_OBJECT *id, - int crit); -void policy_data_free(X509_POLICY_DATA *data); - -X509_POLICY_DATA *policy_cache_find_data(const X509_POLICY_CACHE *cache, - const ASN1_OBJECT *id); -int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps); - -STACK_OF(X509_POLICY_NODE) *policy_node_cmp_new(void); - -void policy_cache_init(void); - -void policy_cache_free(X509_POLICY_CACHE *cache); - -X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level, - const X509_POLICY_NODE *parent, - const ASN1_OBJECT *id); - -X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk, - const ASN1_OBJECT *id); - -X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level, - X509_POLICY_DATA *data, - X509_POLICY_NODE *parent, - X509_POLICY_TREE *tree); -void policy_node_free(X509_POLICY_NODE *node); -int policy_node_match(const X509_POLICY_LEVEL *lvl, - const X509_POLICY_NODE *node, const ASN1_OBJECT *oid); - -const X509_POLICY_CACHE *policy_cache_set(X509 *x); +/* + * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +typedef struct X509_POLICY_DATA_st X509_POLICY_DATA; + +DEFINE_STACK_OF(X509_POLICY_DATA) + +/* Internal structures */ + +/* + * This structure and the field names correspond to the Policy 'node' of + * RFC3280. NB this structure contains no pointers to parent or child data: + * X509_POLICY_NODE contains that. This means that the main policy data can + * be kept static and cached with the certificate. + */ + +struct X509_POLICY_DATA_st { + unsigned int flags; + /* Policy OID and qualifiers for this data */ + ASN1_OBJECT *valid_policy; + STACK_OF(POLICYQUALINFO) *qualifier_set; + STACK_OF(ASN1_OBJECT) *expected_policy_set; +}; + +/* X509_POLICY_DATA flags values */ + +/* + * This flag indicates the structure has been mapped using a policy mapping + * extension. If policy mapping is not active its references get deleted. + */ + +#define POLICY_DATA_FLAG_MAPPED 0x1 + +/* + * This flag indicates the data doesn't correspond to a policy in Certificate + * Policies: it has been mapped to any policy. + */ + +#define POLICY_DATA_FLAG_MAPPED_ANY 0x2 + +/* AND with flags to see if any mapping has occurred */ + +#define POLICY_DATA_FLAG_MAP_MASK 0x3 + +/* qualifiers are shared and shouldn't be freed */ + +#define POLICY_DATA_FLAG_SHARED_QUALIFIERS 0x4 + +/* Parent node is an extra node and should be freed */ + +#define POLICY_DATA_FLAG_EXTRA_NODE 0x8 + +/* Corresponding CertificatePolicies is critical */ + +#define POLICY_DATA_FLAG_CRITICAL 0x10 + +/* This structure is cached with a certificate */ + +struct X509_POLICY_CACHE_st { + /* anyPolicy data or NULL if no anyPolicy */ + X509_POLICY_DATA *anyPolicy; + /* other policy data */ + STACK_OF(X509_POLICY_DATA) *data; + /* If InhibitAnyPolicy present this is its value or -1 if absent. */ + long any_skip; + /* + * If policyConstraints and requireExplicitPolicy present this is its + * value or -1 if absent. + */ + long explicit_skip; + /* + * If policyConstraints and policyMapping present this is its value or -1 + * if absent. + */ + long map_skip; +}; + +/* + * #define POLICY_CACHE_FLAG_CRITICAL POLICY_DATA_FLAG_CRITICAL + */ + +/* This structure represents the relationship between nodes */ + +struct X509_POLICY_NODE_st { + /* node data this refers to */ + const X509_POLICY_DATA *data; + /* Parent node */ + X509_POLICY_NODE *parent; + /* Number of child nodes */ + int nchild; +}; + +struct X509_POLICY_LEVEL_st { + /* Cert for this level */ + X509 *cert; + /* nodes at this level */ + STACK_OF(X509_POLICY_NODE) *nodes; + /* anyPolicy node */ + X509_POLICY_NODE *anyPolicy; + /* Extra data */ + /* + * STACK_OF(X509_POLICY_DATA) *extra_data; + */ + unsigned int flags; +}; + +struct X509_POLICY_TREE_st { + /* This is the tree 'level' data */ + X509_POLICY_LEVEL *levels; + int nlevel; + /* + * Extra policy data when additional nodes (not from the certificate) are + * required. + */ + STACK_OF(X509_POLICY_DATA) *extra_data; + /* This is the authority constrained policy set */ + STACK_OF(X509_POLICY_NODE) *auth_policies; + STACK_OF(X509_POLICY_NODE) *user_policies; + unsigned int flags; +}; + +/* Set if anyPolicy present in user policies */ +#define POLICY_FLAG_ANY_POLICY 0x2 + +/* Useful macros */ + +#define node_data_critical(data) (data->flags & POLICY_DATA_FLAG_CRITICAL) +#define node_critical(node) node_data_critical(node->data) + +/* Internal functions */ + +X509_POLICY_DATA *policy_data_new(POLICYINFO *policy, const ASN1_OBJECT *id, + int crit); +void policy_data_free(X509_POLICY_DATA *data); + +X509_POLICY_DATA *policy_cache_find_data(const X509_POLICY_CACHE *cache, + const ASN1_OBJECT *id); +int policy_cache_set_mapping(X509 *x, POLICY_MAPPINGS *maps); + +STACK_OF(X509_POLICY_NODE) *policy_node_cmp_new(void); + +void policy_cache_init(void); + +void policy_cache_free(X509_POLICY_CACHE *cache); + +X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level, + const X509_POLICY_NODE *parent, + const ASN1_OBJECT *id); + +X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk, + const ASN1_OBJECT *id); + +X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level, + X509_POLICY_DATA *data, + X509_POLICY_NODE *parent, + X509_POLICY_TREE *tree); +void policy_node_free(X509_POLICY_NODE *node); +int policy_node_match(const X509_POLICY_LEVEL *lvl, + const X509_POLICY_NODE *node, const ASN1_OBJECT *oid); + +const X509_POLICY_CACHE *policy_cache_set(X509 *x); diff --git a/contrib/libs/openssl/crypto/x509v3/pcy_map.c b/contrib/libs/openssl/crypto/x509v3/pcy_map.c index 9da649d2df..ae2a62c977 100644 --- a/contrib/libs/openssl/crypto/x509v3/pcy_map.c +++ b/contrib/libs/openssl/crypto/x509v3/pcy_map.c @@ -10,9 +10,9 @@ #include "internal/cryptlib.h" #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" -#include "pcy_local.h" +#include "pcy_local.h" /* * Set policy mapping entries in cache. Note: this modifies the passed diff --git a/contrib/libs/openssl/crypto/x509v3/pcy_node.c b/contrib/libs/openssl/crypto/x509v3/pcy_node.c index 0efa18c5b9..e2d7b15322 100644 --- a/contrib/libs/openssl/crypto/x509v3/pcy_node.c +++ b/contrib/libs/openssl/crypto/x509v3/pcy_node.c @@ -12,7 +12,7 @@ #include <openssl/x509v3.h> #include <openssl/err.h> -#include "pcy_local.h" +#include "pcy_local.h" static int node_cmp(const X509_POLICY_NODE *const *a, const X509_POLICY_NODE *const *b) diff --git a/contrib/libs/openssl/crypto/x509v3/pcy_tree.c b/contrib/libs/openssl/crypto/x509v3/pcy_tree.c index bb60f4ef50..6e8322cbc5 100644 --- a/contrib/libs/openssl/crypto/x509v3/pcy_tree.c +++ b/contrib/libs/openssl/crypto/x509v3/pcy_tree.c @@ -11,7 +11,7 @@ #include <openssl/x509.h> #include <openssl/x509v3.h> -#include "pcy_local.h" +#include "pcy_local.h" /* * Enable this to print out the complete policy tree at various point during diff --git a/contrib/libs/openssl/crypto/x509v3/v3_addr.c b/contrib/libs/openssl/crypto/x509v3/v3_addr.c index 3dfcac60cf..4258dbc40c 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_addr.c +++ b/contrib/libs/openssl/crypto/x509v3/v3_addr.c @@ -20,7 +20,7 @@ #include <openssl/asn1t.h> #include <openssl/buffer.h> #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include "ext_dat.h" #ifndef OPENSSL_NO_RFC3779 diff --git a/contrib/libs/openssl/crypto/x509v3/v3_admis.h b/contrib/libs/openssl/crypto/x509v3/v3_admis.h index 5b196267ff..ea7632b370 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_admis.h +++ b/contrib/libs/openssl/crypto/x509v3/v3_admis.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_X509V3_V3_ADMIS_H -# define OSSL_CRYPTO_X509V3_V3_ADMIS_H +#ifndef OSSL_CRYPTO_X509V3_V3_ADMIS_H +# define OSSL_CRYPTO_X509V3_V3_ADMIS_H struct NamingAuthority_st { ASN1_OBJECT* namingAuthorityId; diff --git a/contrib/libs/openssl/crypto/x509v3/v3_alt.c b/contrib/libs/openssl/crypto/x509v3/v3_alt.c index 85998676de..7c32d4031d 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_alt.c +++ b/contrib/libs/openssl/crypto/x509v3/v3_alt.c @@ -53,24 +53,24 @@ STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, { int i; GENERAL_NAME *gen; - STACK_OF(CONF_VALUE) *tmpret = NULL, *origret = ret; - + STACK_OF(CONF_VALUE) *tmpret = NULL, *origret = ret; + for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) { gen = sk_GENERAL_NAME_value(gens, i); - /* - * i2v_GENERAL_NAME allocates ret if it is NULL. If something goes - * wrong we need to free the stack - but only if it was empty when we - * originally entered this function. - */ - tmpret = i2v_GENERAL_NAME(method, gen, ret); - if (tmpret == NULL) { - if (origret == NULL) - sk_CONF_VALUE_pop_free(ret, X509V3_conf_free); - return NULL; - } - ret = tmpret; + /* + * i2v_GENERAL_NAME allocates ret if it is NULL. If something goes + * wrong we need to free the stack - but only if it was empty when we + * originally entered this function. + */ + tmpret = i2v_GENERAL_NAME(method, gen, ret); + if (tmpret == NULL) { + if (origret == NULL) + sk_CONF_VALUE_pop_free(ret, X509V3_conf_free); + return NULL; + } + ret = tmpret; } - if (ret == NULL) + if (ret == NULL) return sk_CONF_VALUE_new_null(); return ret; } diff --git a/contrib/libs/openssl/crypto/x509v3/v3_asid.c b/contrib/libs/openssl/crypto/x509v3/v3_asid.c index 5778b890c8..ac68572672 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_asid.c +++ b/contrib/libs/openssl/crypto/x509v3/v3_asid.c @@ -20,7 +20,7 @@ #include <openssl/asn1t.h> #include <openssl/x509v3.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include <openssl/bn.h> #include "ext_dat.h" @@ -256,7 +256,7 @@ static int extract_min_max(ASIdOrRange *aor, static int ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice) { ASN1_INTEGER *a_max_plus_one = NULL; - ASN1_INTEGER *orig; + ASN1_INTEGER *orig; BIGNUM *bn = NULL; int i, ret = 0; @@ -299,20 +299,20 @@ static int ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice) */ if ((bn == NULL && (bn = BN_new()) == NULL) || ASN1_INTEGER_to_BN(a_max, bn) == NULL || - !BN_add_word(bn, 1)) { + !BN_add_word(bn, 1)) { + X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL, + ERR_R_MALLOC_FAILURE); + goto done; + } + + if ((a_max_plus_one = + BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) { + a_max_plus_one = orig; X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL, ERR_R_MALLOC_FAILURE); goto done; } - if ((a_max_plus_one = - BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) { - a_max_plus_one = orig; - X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL, - ERR_R_MALLOC_FAILURE); - goto done; - } - /* * Punt if adjacent or overlapping. */ @@ -358,7 +358,7 @@ int X509v3_asid_is_canonical(ASIdentifiers *asid) static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) { ASN1_INTEGER *a_max_plus_one = NULL; - ASN1_INTEGER *orig; + ASN1_INTEGER *orig; BIGNUM *bn = NULL; int i, ret = 0; @@ -424,20 +424,20 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice) */ if ((bn == NULL && (bn = BN_new()) == NULL) || ASN1_INTEGER_to_BN(a_max, bn) == NULL || - !BN_add_word(bn, 1)) { + !BN_add_word(bn, 1)) { + X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, + ERR_R_MALLOC_FAILURE); + goto done; + } + + if ((a_max_plus_one = + BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) { + a_max_plus_one = orig; X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, ERR_R_MALLOC_FAILURE); goto done; } - if ((a_max_plus_one = - BN_to_ASN1_INTEGER(bn, orig = a_max_plus_one)) == NULL) { - a_max_plus_one = orig; - X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, - ERR_R_MALLOC_FAILURE); - goto done; - } - /* * If a and b are adjacent, merge them. */ diff --git a/contrib/libs/openssl/crypto/x509v3/v3_conf.c b/contrib/libs/openssl/crypto/x509v3/v3_conf.c index b5c68257c6..e93de34546 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_conf.c +++ b/contrib/libs/openssl/crypto/x509v3/v3_conf.c @@ -10,11 +10,11 @@ /* extension creation utilities */ #include <stdio.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include "internal/cryptlib.h" #include <openssl/conf.h> #include <openssl/x509.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include <openssl/x509v3.h> static int v3_check_critical(const char **value); diff --git a/contrib/libs/openssl/crypto/x509v3/v3_cpols.c b/contrib/libs/openssl/crypto/x509v3/v3_cpols.c index ab8e24a87b..09804b5848 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_cpols.c +++ b/contrib/libs/openssl/crypto/x509v3/v3_cpols.c @@ -14,7 +14,7 @@ #include <openssl/asn1t.h> #include <openssl/x509v3.h> -#include "pcy_local.h" +#include "pcy_local.h" #include "ext_dat.h" /* Certificate policies extension support: this one is a bit complex... */ diff --git a/contrib/libs/openssl/crypto/x509v3/v3_crld.c b/contrib/libs/openssl/crypto/x509v3/v3_crld.c index 5197867376..4854748ffb 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_crld.c +++ b/contrib/libs/openssl/crypto/x509v3/v3_crld.c @@ -14,7 +14,7 @@ #include <openssl/asn1t.h> #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include "ext_dat.h" static void *v2i_crld(const X509V3_EXT_METHOD *method, diff --git a/contrib/libs/openssl/crypto/x509v3/v3_ncons.c b/contrib/libs/openssl/crypto/x509v3/v3_ncons.c index 438f3ae541..d985aa91da 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_ncons.c +++ b/contrib/libs/openssl/crypto/x509v3/v3_ncons.c @@ -10,12 +10,12 @@ #include "internal/cryptlib.h" #include "internal/numbers.h" #include <stdio.h> -#include "crypto/asn1.h" +#include "crypto/asn1.h" #include <openssl/asn1t.h> #include <openssl/conf.h> #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include "ext_dat.h" static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method, diff --git a/contrib/libs/openssl/crypto/x509v3/v3_purp.c b/contrib/libs/openssl/crypto/x509v3/v3_purp.c index 646c95aac7..a1aeb4e4c6 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_purp.c +++ b/contrib/libs/openssl/crypto/x509v3/v3_purp.c @@ -12,7 +12,7 @@ #include "internal/numbers.h" #include <openssl/x509v3.h> #include <openssl/x509_vfy.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include "../x509/x509_local.h" /* for x509_signing_allowed() */ #include "internal/tsan_assist.h" @@ -82,8 +82,8 @@ int X509_check_purpose(X509 *x, int id, int ca) const X509_PURPOSE *pt; x509v3_cache_extensions(x); - if (x->ex_flags & EXFLAG_INVALID) - return -1; + if (x->ex_flags & EXFLAG_INVALID) + return -1; /* Return if side-effect only call */ if (id == -1) @@ -303,11 +303,11 @@ int X509_supported_extension(X509_EXTENSION *ex) return 0; } -static int setup_dp(X509 *x, DIST_POINT *dp) +static int setup_dp(X509 *x, DIST_POINT *dp) { X509_NAME *iname = NULL; int i; - + if (dp->reasons) { if (dp->reasons->length > 0) dp->dp_reasons = dp->reasons->data[0]; @@ -317,7 +317,7 @@ static int setup_dp(X509 *x, DIST_POINT *dp) } else dp->dp_reasons = CRLDP_ALL_REASONS; if (!dp->distpoint || (dp->distpoint->type != 1)) - return 1; + return 1; for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++) { GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i); if (gen->type == GEN_DIRNAME) { @@ -328,21 +328,21 @@ static int setup_dp(X509 *x, DIST_POINT *dp) if (!iname) iname = X509_get_issuer_name(x); - return DIST_POINT_set_dpname(dp->distpoint, iname); + return DIST_POINT_set_dpname(dp->distpoint, iname); } -static int setup_crldp(X509 *x) +static int setup_crldp(X509 *x) { int i; - - x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, &i, NULL); - if (x->crldp == NULL && i != -1) - return 0; - for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++) { - if (!setup_dp(x, sk_DIST_POINT_value(x->crldp, i))) - return 0; - } - return 1; + + x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, &i, NULL); + if (x->crldp == NULL && i != -1) + return 0; + for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++) { + if (!setup_dp(x, sk_DIST_POINT_value(x->crldp, i))) + return 0; + } + return 1; } /* Check that issuer public key algorithm matches subject signature algorithm */ @@ -393,36 +393,36 @@ static void x509v3_cache_extensions(X509 *x) return; } - if (!X509_digest(x, EVP_sha1(), x->sha1_hash, NULL)) + if (!X509_digest(x, EVP_sha1(), x->sha1_hash, NULL)) x->ex_flags |= (EXFLAG_NO_FINGERPRINT | EXFLAG_INVALID); /* V1 should mean no extensions ... */ if (!X509_get_version(x)) x->ex_flags |= EXFLAG_V1; /* Handle basic constraints */ - if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, &i, NULL))) { + if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, &i, NULL))) { if (bs->ca) x->ex_flags |= EXFLAG_CA; if (bs->pathlen) { - if (bs->pathlen->type == V_ASN1_NEG_INTEGER) { + if (bs->pathlen->type == V_ASN1_NEG_INTEGER) { x->ex_flags |= EXFLAG_INVALID; x->ex_pathlen = 0; - } else { + } else { x->ex_pathlen = ASN1_INTEGER_get(bs->pathlen); - if (!bs->ca && x->ex_pathlen != 0) { - x->ex_flags |= EXFLAG_INVALID; - x->ex_pathlen = 0; - } - } + if (!bs->ca && x->ex_pathlen != 0) { + x->ex_flags |= EXFLAG_INVALID; + x->ex_pathlen = 0; + } + } } else x->ex_pathlen = -1; BASIC_CONSTRAINTS_free(bs); x->ex_flags |= EXFLAG_BCONS; - } else if (i != -1) { - x->ex_flags |= EXFLAG_INVALID; + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } /* Handle proxy certificates */ - if ((pci = X509_get_ext_d2i(x, NID_proxyCertInfo, &i, NULL))) { + if ((pci = X509_get_ext_d2i(x, NID_proxyCertInfo, &i, NULL))) { if (x->ex_flags & EXFLAG_CA || X509_get_ext_by_NID(x, NID_subject_alt_name, -1) >= 0 || X509_get_ext_by_NID(x, NID_issuer_alt_name, -1) >= 0) { @@ -434,11 +434,11 @@ static void x509v3_cache_extensions(X509 *x) x->ex_pcpathlen = -1; PROXY_CERT_INFO_EXTENSION_free(pci); x->ex_flags |= EXFLAG_PROXY; - } else if (i != -1) { - x->ex_flags |= EXFLAG_INVALID; + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } /* Handle key usage */ - if ((usage = X509_get_ext_d2i(x, NID_key_usage, &i, NULL))) { + if ((usage = X509_get_ext_d2i(x, NID_key_usage, &i, NULL))) { if (usage->length > 0) { x->ex_kusage = usage->data[0]; if (usage->length > 1) @@ -447,11 +447,11 @@ static void x509v3_cache_extensions(X509 *x) x->ex_kusage = 0; x->ex_flags |= EXFLAG_KUSAGE; ASN1_BIT_STRING_free(usage); - } else if (i != -1) { - x->ex_flags |= EXFLAG_INVALID; + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } x->ex_xkusage = 0; - if ((extusage = X509_get_ext_d2i(x, NID_ext_key_usage, &i, NULL))) { + if ((extusage = X509_get_ext_d2i(x, NID_ext_key_usage, &i, NULL))) { x->ex_flags |= EXFLAG_XKUSAGE; for (i = 0; i < sk_ASN1_OBJECT_num(extusage); i++) { switch (OBJ_obj2nid(sk_ASN1_OBJECT_value(extusage, i))) { @@ -494,26 +494,26 @@ static void x509v3_cache_extensions(X509 *x) } } sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free); - } else if (i != -1) { - x->ex_flags |= EXFLAG_INVALID; + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } - if ((ns = X509_get_ext_d2i(x, NID_netscape_cert_type, &i, NULL))) { + if ((ns = X509_get_ext_d2i(x, NID_netscape_cert_type, &i, NULL))) { if (ns->length > 0) x->ex_nscert = ns->data[0]; else x->ex_nscert = 0; x->ex_flags |= EXFLAG_NSCERT; ASN1_BIT_STRING_free(ns); - } else if (i != -1) { - x->ex_flags |= EXFLAG_INVALID; + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } - x->skid = X509_get_ext_d2i(x, NID_subject_key_identifier, &i, NULL); - if (x->skid == NULL && i != -1) - x->ex_flags |= EXFLAG_INVALID; - x->akid = X509_get_ext_d2i(x, NID_authority_key_identifier, &i, NULL); - if (x->akid == NULL && i != -1) - x->ex_flags |= EXFLAG_INVALID; + x->skid = X509_get_ext_d2i(x, NID_subject_key_identifier, &i, NULL); + if (x->skid == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; + x->akid = X509_get_ext_d2i(x, NID_authority_key_identifier, &i, NULL); + if (x->akid == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; /* Does subject name match issuer ? */ if (!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x))) { x->ex_flags |= EXFLAG_SI; /* cert is self-issued */ @@ -522,22 +522,22 @@ static void x509v3_cache_extensions(X509 *x) && check_sig_alg_match(X509_get0_pubkey(x), x) == X509_V_OK) x->ex_flags |= EXFLAG_SS; /* indicate self-signed */ } - x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, &i, NULL); - if (x->altname == NULL && i != -1) - x->ex_flags |= EXFLAG_INVALID; + x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, &i, NULL); + if (x->altname == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; x->nc = X509_get_ext_d2i(x, NID_name_constraints, &i, NULL); - if (x->nc == NULL && i != -1) + if (x->nc == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; + if (!setup_crldp(x)) x->ex_flags |= EXFLAG_INVALID; - if (!setup_crldp(x)) - x->ex_flags |= EXFLAG_INVALID; #ifndef OPENSSL_NO_RFC3779 - x->rfc3779_addr = X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, &i, NULL); - if (x->rfc3779_addr == NULL && i != -1) - x->ex_flags |= EXFLAG_INVALID; - x->rfc3779_asid = X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, &i, NULL); - if (x->rfc3779_asid == NULL && i != -1) - x->ex_flags |= EXFLAG_INVALID; + x->rfc3779_addr = X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, &i, NULL); + if (x->rfc3779_addr == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; + x->rfc3779_asid = X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, &i, NULL); + if (x->rfc3779_asid == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; #endif for (i = 0; i < X509_get_ext_count(x); i++) { ex = X509_get_ext(x, i); @@ -569,11 +569,11 @@ static void x509v3_cache_extensions(X509 *x) * return codes: * 0 not a CA * 1 is a CA - * 2 Only possible in older versions of openSSL when basicConstraints are absent - * new versions will not return this value. May be a CA + * 2 Only possible in older versions of openSSL when basicConstraints are absent + * new versions will not return this value. May be a CA * 3 basicConstraints absent but self signed V1. * 4 basicConstraints absent but keyUsage present and keyCertSign asserted. - * 5 Netscape specific CA Flags present + * 5 Netscape specific CA Flags present */ static int check_ca(const X509 *x) @@ -860,11 +860,11 @@ int x509_likely_issued(X509 *issuer, X509 *subject) return X509_V_ERR_SUBJECT_ISSUER_MISMATCH; x509v3_cache_extensions(issuer); - if (issuer->ex_flags & EXFLAG_INVALID) - return X509_V_ERR_UNSPECIFIED; + if (issuer->ex_flags & EXFLAG_INVALID) + return X509_V_ERR_UNSPECIFIED; x509v3_cache_extensions(subject); - if (subject->ex_flags & EXFLAG_INVALID) - return X509_V_ERR_UNSPECIFIED; + if (subject->ex_flags & EXFLAG_INVALID) + return X509_V_ERR_UNSPECIFIED; if (subject->akid) { int ret = X509_check_akid(issuer, subject->akid); @@ -925,8 +925,8 @@ uint32_t X509_get_extension_flags(X509 *x) uint32_t X509_get_key_usage(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - if (X509_check_purpose(x, -1, -1) != 1) - return 0; + if (X509_check_purpose(x, -1, -1) != 1) + return 0; if (x->ex_flags & EXFLAG_KUSAGE) return x->ex_kusage; return UINT32_MAX; @@ -935,8 +935,8 @@ uint32_t X509_get_key_usage(X509 *x) uint32_t X509_get_extended_key_usage(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - if (X509_check_purpose(x, -1, -1) != 1) - return 0; + if (X509_check_purpose(x, -1, -1) != 1) + return 0; if (x->ex_flags & EXFLAG_XKUSAGE) return x->ex_xkusage; return UINT32_MAX; @@ -945,32 +945,32 @@ uint32_t X509_get_extended_key_usage(X509 *x) const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - if (X509_check_purpose(x, -1, -1) != 1) - return NULL; + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return x->skid; } const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - if (X509_check_purpose(x, -1, -1) != 1) - return NULL; + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return (x->akid != NULL ? x->akid->keyid : NULL); } const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - if (X509_check_purpose(x, -1, -1) != 1) - return NULL; + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return (x->akid != NULL ? x->akid->issuer : NULL); } const ASN1_INTEGER *X509_get0_authority_serial(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - if (X509_check_purpose(x, -1, -1) != 1) - return NULL; + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return (x->akid != NULL ? x->akid->serial : NULL); } diff --git a/contrib/libs/openssl/crypto/x509v3/v3_skey.c b/contrib/libs/openssl/crypto/x509v3/v3_skey.c index 7371e97052..c2e8204568 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_skey.c +++ b/contrib/libs/openssl/crypto/x509v3/v3_skey.c @@ -10,7 +10,7 @@ #include <stdio.h> #include "internal/cryptlib.h" #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include "ext_dat.h" static ASN1_OCTET_STRING *s2i_skey_id(X509V3_EXT_METHOD *method, diff --git a/contrib/libs/openssl/crypto/x509v3/v3_utl.c b/contrib/libs/openssl/crypto/x509v3/v3_utl.c index c4633dca74..f41c699b5a 100644 --- a/contrib/libs/openssl/crypto/x509v3/v3_utl.c +++ b/contrib/libs/openssl/crypto/x509v3/v3_utl.c @@ -13,11 +13,11 @@ #include "internal/cryptlib.h" #include <stdio.h> #include <string.h> -#include "crypto/ctype.h" +#include "crypto/ctype.h" #include <openssl/conf.h> #include <openssl/crypto.h> #include <openssl/x509v3.h> -#include "crypto/x509.h" +#include "crypto/x509.h" #include <openssl/bn.h> #include "ext_dat.h" diff --git a/contrib/libs/openssl/crypto/ya.make b/contrib/libs/openssl/crypto/ya.make index 199c044fe7..3acfb0cac7 100644 --- a/contrib/libs/openssl/crypto/ya.make +++ b/contrib/libs/openssl/crypto/ya.make @@ -77,17 +77,17 @@ IF (OS_DARWIN AND ARCH_ARM64) SET(DARWIN_ARM64 yes) ENDIF() -NO_COMPILER_WARNINGS() - -NO_RUNTIME() - +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + CFLAGS( -DOPENSSL_BN_ASM_MONT -DOPENSSL_CPUID_OBJ -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM - -DZLIB + -DZLIB ) IF (NOT IOS_ARM64 AND NOT DARWIN_ARM64) diff --git a/contrib/libs/openssl/e_os.h b/contrib/libs/openssl/e_os.h index d3a8501df2..9af7f3758d 100644 --- a/contrib/libs/openssl/e_os.h +++ b/contrib/libs/openssl/e_os.h @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_E_OS_H -# define OSSL_E_OS_H +#ifndef OSSL_E_OS_H +# define OSSL_E_OS_H # include <limits.h> # include <openssl/opensslconf.h> @@ -42,7 +42,7 @@ # endif /* * Some operating systems do not permit select(2) on their random devices, - * defining this to zero will force the use of read(2) to extract one byte + * defining this to zero will force the use of read(2) to extract one byte * from /dev/random. */ # ifndef DEVRANDM_WAIT_USE_SELECT diff --git a/contrib/libs/openssl/engines/e_afalg.c b/contrib/libs/openssl/engines/e_afalg.c index d6a6c132fe..4b17228461 100644 --- a/contrib/libs/openssl/engines/e_afalg.c +++ b/contrib/libs/openssl/engines/e_afalg.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -456,7 +456,7 @@ static int afalg_start_cipher_sk(afalg_ctx *actx, const unsigned char *in, /* * vmsplice and splice are used to pin the user space input buffer for - * kernel space processing avoiding copies from user to kernel space + * kernel space processing avoiding copies from user to kernel space */ ret = vmsplice(actx->zc_pipe[1], &iov, 1, SPLICE_F_GIFT); if (ret < 0) { diff --git a/contrib/libs/openssl/engines/e_afalg.h b/contrib/libs/openssl/engines/e_afalg.h index c36c973089..3323c898c6 100644 --- a/contrib/libs/openssl/engines/e_afalg.h +++ b/contrib/libs/openssl/engines/e_afalg.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_ENGINES_E_AFALG_H -# define OSSL_ENGINES_E_AFALG_H +#ifndef OSSL_ENGINES_E_AFALG_H +# define OSSL_ENGINES_E_AFALG_H # if defined(__GNUC__) && __GNUC__ >= 4 && \ (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) diff --git a/contrib/libs/openssl/engines/e_afalg_err.h b/contrib/libs/openssl/engines/e_afalg_err.h index 9c9de56a7a..3036443f44 100644 --- a/contrib/libs/openssl/engines/e_afalg_err.h +++ b/contrib/libs/openssl/engines/e_afalg_err.h @@ -8,8 +8,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_ENGINES_E_AFALG_ERR_H -# define OSSL_ENGINES_E_AFALG_ERR_H +#ifndef OSSL_ENGINES_E_AFALG_ERR_H +# define OSSL_ENGINES_E_AFALG_ERR_H # define AFALGerr(f, r) ERR_AFALG_error((f), (r), OPENSSL_FILE, OPENSSL_LINE) diff --git a/contrib/libs/openssl/engines/e_capi_err.h b/contrib/libs/openssl/engines/e_capi_err.h index b7517a6d42..e3a927aa73 100644 --- a/contrib/libs/openssl/engines/e_capi_err.h +++ b/contrib/libs/openssl/engines/e_capi_err.h @@ -8,8 +8,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_ENGINES_E_CAPI_ERR_H -# define OSSL_ENGINES_E_CAPI_ERR_H +#ifndef OSSL_ENGINES_E_CAPI_ERR_H +# define OSSL_ENGINES_E_CAPI_ERR_H # define CAPIerr(f, r) ERR_CAPI_error((f), (r), OPENSSL_FILE, OPENSSL_LINE) diff --git a/contrib/libs/openssl/engines/e_dasync_err.h b/contrib/libs/openssl/engines/e_dasync_err.h index 6b663a1061..5b74d8be25 100644 --- a/contrib/libs/openssl/engines/e_dasync_err.h +++ b/contrib/libs/openssl/engines/e_dasync_err.h @@ -8,8 +8,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_ENGINES_E_DASYNC_ERR_H -# define OSSL_ENGINES_E_DASYNC_ERR_H +#ifndef OSSL_ENGINES_E_DASYNC_ERR_H +# define OSSL_ENGINES_E_DASYNC_ERR_H # define DASYNCerr(f, r) ERR_DASYNC_error((f), (r), OPENSSL_FILE, OPENSSL_LINE) diff --git a/contrib/libs/openssl/engines/e_ossltest_err.h b/contrib/libs/openssl/engines/e_ossltest_err.h index 07c7f2faf6..8e6535b76c 100644 --- a/contrib/libs/openssl/engines/e_ossltest_err.h +++ b/contrib/libs/openssl/engines/e_ossltest_err.h @@ -8,8 +8,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_ENGINES_E_OSSLTEST_ERR_H -# define OSSL_ENGINES_E_OSSLTEST_ERR_H +#ifndef OSSL_ENGINES_E_OSSLTEST_ERR_H +# define OSSL_ENGINES_E_OSSLTEST_ERR_H # define OSSLTESTerr(f, r) ERR_OSSLTEST_error((f), (r), OPENSSL_FILE, OPENSSL_LINE) diff --git a/contrib/libs/openssl/include/crypto/aria.h b/contrib/libs/openssl/include/crypto/aria.h index 2ee2ec2f6b..03a62950ae 100644 --- a/contrib/libs/openssl/include/crypto/aria.h +++ b/contrib/libs/openssl/include/crypto/aria.h @@ -10,8 +10,8 @@ /* Copyright (c) 2017 National Security Research Institute. All rights reserved. */ -#ifndef OSSL_CRYPTO_ARIA_H -# define OSSL_CRYPTO_ARIA_H +#ifndef OSSL_CRYPTO_ARIA_H +# define OSSL_CRYPTO_ARIA_H # include <openssl/opensslconf.h> diff --git a/contrib/libs/openssl/include/crypto/asn1.h b/contrib/libs/openssl/include/crypto/asn1.h index e237ab80f7..9c9b4d8974 100644 --- a/contrib/libs/openssl/include/crypto/asn1.h +++ b/contrib/libs/openssl/include/crypto/asn1.h @@ -1,113 +1,113 @@ -/* - * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* Internal ASN1 structures and functions: not for application use */ - -/* ASN1 public key method structure */ - -struct evp_pkey_asn1_method_st { - int pkey_id; - int pkey_base_id; - unsigned long pkey_flags; - char *pem_str; - char *info; - int (*pub_decode) (EVP_PKEY *pk, X509_PUBKEY *pub); - int (*pub_encode) (X509_PUBKEY *pub, const EVP_PKEY *pk); - int (*pub_cmp) (const EVP_PKEY *a, const EVP_PKEY *b); - int (*pub_print) (BIO *out, const EVP_PKEY *pkey, int indent, - ASN1_PCTX *pctx); - int (*priv_decode) (EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf); - int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk); - int (*priv_print) (BIO *out, const EVP_PKEY *pkey, int indent, - ASN1_PCTX *pctx); - int (*pkey_size) (const EVP_PKEY *pk); - int (*pkey_bits) (const EVP_PKEY *pk); - int (*pkey_security_bits) (const EVP_PKEY *pk); - int (*param_decode) (EVP_PKEY *pkey, - const unsigned char **pder, int derlen); - int (*param_encode) (const EVP_PKEY *pkey, unsigned char **pder); - int (*param_missing) (const EVP_PKEY *pk); - int (*param_copy) (EVP_PKEY *to, const EVP_PKEY *from); - int (*param_cmp) (const EVP_PKEY *a, const EVP_PKEY *b); - int (*param_print) (BIO *out, const EVP_PKEY *pkey, int indent, - ASN1_PCTX *pctx); - int (*sig_print) (BIO *out, - const X509_ALGOR *sigalg, const ASN1_STRING *sig, - int indent, ASN1_PCTX *pctx); - void (*pkey_free) (EVP_PKEY *pkey); - int (*pkey_ctrl) (EVP_PKEY *pkey, int op, long arg1, void *arg2); - /* Legacy functions for old PEM */ - int (*old_priv_decode) (EVP_PKEY *pkey, - const unsigned char **pder, int derlen); - int (*old_priv_encode) (const EVP_PKEY *pkey, unsigned char **pder); - /* Custom ASN1 signature verification */ - int (*item_verify) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, - X509_ALGOR *a, ASN1_BIT_STRING *sig, EVP_PKEY *pkey); - int (*item_sign) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, - X509_ALGOR *alg1, X509_ALGOR *alg2, - ASN1_BIT_STRING *sig); - int (*siginf_set) (X509_SIG_INFO *siginf, const X509_ALGOR *alg, - const ASN1_STRING *sig); - /* Check */ - int (*pkey_check) (const EVP_PKEY *pk); - int (*pkey_public_check) (const EVP_PKEY *pk); - int (*pkey_param_check) (const EVP_PKEY *pk); - /* Get/set raw private/public key data */ - int (*set_priv_key) (EVP_PKEY *pk, const unsigned char *priv, size_t len); - int (*set_pub_key) (EVP_PKEY *pk, const unsigned char *pub, size_t len); - int (*get_priv_key) (const EVP_PKEY *pk, unsigned char *priv, size_t *len); - int (*get_pub_key) (const EVP_PKEY *pk, unsigned char *pub, size_t *len); -} /* EVP_PKEY_ASN1_METHOD */ ; - -DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD) - -extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD dhx_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[5]; -extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD ed448_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD sm2_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD poly1305_asn1_meth; - -extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[2]; -extern const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth; -extern const EVP_PKEY_ASN1_METHOD siphash_asn1_meth; - -/* - * These are used internally in the ASN1_OBJECT to keep track of whether the - * names and data need to be free()ed - */ -# define ASN1_OBJECT_FLAG_DYNAMIC 0x01/* internal use */ -# define ASN1_OBJECT_FLAG_CRITICAL 0x02/* critical x509v3 object id */ -# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */ -# define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08/* internal use */ -struct asn1_object_st { - const char *sn, *ln; - int nid; - int length; - const unsigned char *data; /* data remains const after init */ - int flags; /* Should we free this one */ -}; - -/* ASN1 print context structure */ - -struct asn1_pctx_st { - unsigned long flags; - unsigned long nm_flags; - unsigned long cert_flags; - unsigned long oid_flags; - unsigned long str_flags; -} /* ASN1_PCTX */ ; - -int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb); +/* + * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* Internal ASN1 structures and functions: not for application use */ + +/* ASN1 public key method structure */ + +struct evp_pkey_asn1_method_st { + int pkey_id; + int pkey_base_id; + unsigned long pkey_flags; + char *pem_str; + char *info; + int (*pub_decode) (EVP_PKEY *pk, X509_PUBKEY *pub); + int (*pub_encode) (X509_PUBKEY *pub, const EVP_PKEY *pk); + int (*pub_cmp) (const EVP_PKEY *a, const EVP_PKEY *b); + int (*pub_print) (BIO *out, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx); + int (*priv_decode) (EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf); + int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk); + int (*priv_print) (BIO *out, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx); + int (*pkey_size) (const EVP_PKEY *pk); + int (*pkey_bits) (const EVP_PKEY *pk); + int (*pkey_security_bits) (const EVP_PKEY *pk); + int (*param_decode) (EVP_PKEY *pkey, + const unsigned char **pder, int derlen); + int (*param_encode) (const EVP_PKEY *pkey, unsigned char **pder); + int (*param_missing) (const EVP_PKEY *pk); + int (*param_copy) (EVP_PKEY *to, const EVP_PKEY *from); + int (*param_cmp) (const EVP_PKEY *a, const EVP_PKEY *b); + int (*param_print) (BIO *out, const EVP_PKEY *pkey, int indent, + ASN1_PCTX *pctx); + int (*sig_print) (BIO *out, + const X509_ALGOR *sigalg, const ASN1_STRING *sig, + int indent, ASN1_PCTX *pctx); + void (*pkey_free) (EVP_PKEY *pkey); + int (*pkey_ctrl) (EVP_PKEY *pkey, int op, long arg1, void *arg2); + /* Legacy functions for old PEM */ + int (*old_priv_decode) (EVP_PKEY *pkey, + const unsigned char **pder, int derlen); + int (*old_priv_encode) (const EVP_PKEY *pkey, unsigned char **pder); + /* Custom ASN1 signature verification */ + int (*item_verify) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, + X509_ALGOR *a, ASN1_BIT_STRING *sig, EVP_PKEY *pkey); + int (*item_sign) (EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, + X509_ALGOR *alg1, X509_ALGOR *alg2, + ASN1_BIT_STRING *sig); + int (*siginf_set) (X509_SIG_INFO *siginf, const X509_ALGOR *alg, + const ASN1_STRING *sig); + /* Check */ + int (*pkey_check) (const EVP_PKEY *pk); + int (*pkey_public_check) (const EVP_PKEY *pk); + int (*pkey_param_check) (const EVP_PKEY *pk); + /* Get/set raw private/public key data */ + int (*set_priv_key) (EVP_PKEY *pk, const unsigned char *priv, size_t len); + int (*set_pub_key) (EVP_PKEY *pk, const unsigned char *pub, size_t len); + int (*get_priv_key) (const EVP_PKEY *pk, unsigned char *priv, size_t *len); + int (*get_pub_key) (const EVP_PKEY *pk, unsigned char *pub, size_t *len); +} /* EVP_PKEY_ASN1_METHOD */ ; + +DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD) + +extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD dh_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD dhx_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[5]; +extern const EVP_PKEY_ASN1_METHOD eckey_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ecx25519_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ecx448_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ed25519_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD ed448_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD sm2_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD poly1305_asn1_meth; + +extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[2]; +extern const EVP_PKEY_ASN1_METHOD rsa_pss_asn1_meth; +extern const EVP_PKEY_ASN1_METHOD siphash_asn1_meth; + +/* + * These are used internally in the ASN1_OBJECT to keep track of whether the + * names and data need to be free()ed + */ +# define ASN1_OBJECT_FLAG_DYNAMIC 0x01/* internal use */ +# define ASN1_OBJECT_FLAG_CRITICAL 0x02/* critical x509v3 object id */ +# define ASN1_OBJECT_FLAG_DYNAMIC_STRINGS 0x04/* internal use */ +# define ASN1_OBJECT_FLAG_DYNAMIC_DATA 0x08/* internal use */ +struct asn1_object_st { + const char *sn, *ln; + int nid; + int length; + const unsigned char *data; /* data remains const after init */ + int flags; /* Should we free this one */ +}; + +/* ASN1 print context structure */ + +struct asn1_pctx_st { + unsigned long flags; + unsigned long nm_flags; + unsigned long cert_flags; + unsigned long oid_flags; + unsigned long str_flags; +} /* ASN1_PCTX */ ; + +int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb); diff --git a/contrib/libs/openssl/include/crypto/bn.h b/contrib/libs/openssl/include/crypto/bn.h index f6f890e923..60afda1dad 100644 --- a/contrib/libs/openssl/include/crypto/bn.h +++ b/contrib/libs/openssl/include/crypto/bn.h @@ -1,90 +1,90 @@ -/* - * Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_BN_H -# define OSSL_CRYPTO_BN_H - -# include <openssl/bn.h> -# include <limits.h> - -BIGNUM *bn_wexpand(BIGNUM *a, int words); -BIGNUM *bn_expand2(BIGNUM *a, int words); - -void bn_correct_top(BIGNUM *a); - -/* - * Determine the modified width-(w+1) Non-Adjacent Form (wNAF) of 'scalar'. - * This is an array r[] of values that are either zero or odd with an - * absolute value less than 2^w satisfying scalar = \sum_j r[j]*2^j where at - * most one of any w+1 consecutive digits is non-zero with the exception that - * the most significant digit may be only w-1 zeros away from that next - * non-zero digit. - */ -signed char *bn_compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len); - -int bn_get_top(const BIGNUM *a); - -int bn_get_dmax(const BIGNUM *a); - -/* Set all words to zero */ -void bn_set_all_zero(BIGNUM *a); - -/* - * Copy the internal BIGNUM words into out which holds size elements (and size - * must be bigger than top) - */ -int bn_copy_words(BN_ULONG *out, const BIGNUM *in, int size); - -BN_ULONG *bn_get_words(const BIGNUM *a); - -/* - * Set the internal data words in a to point to words which contains size - * elements. The BN_FLG_STATIC_DATA flag is set - */ -void bn_set_static_words(BIGNUM *a, const BN_ULONG *words, int size); - -/* - * Copy words into the BIGNUM |a|, reallocating space as necessary. - * The negative flag of |a| is not modified. - * Returns 1 on success and 0 on failure. - */ -/* - * |num_words| is int because bn_expand2 takes an int. This is an internal - * function so we simply trust callers not to pass negative values. - */ -int bn_set_words(BIGNUM *a, const BN_ULONG *words, int num_words); - -/* - * Some BIGNUM functions assume most significant limb to be non-zero, which - * is customarily arranged by bn_correct_top. Output from below functions - * is not processed with bn_correct_top, and for this reason it may not be - * returned out of public API. It may only be passed internally into other - * functions known to support non-minimal or zero-padded BIGNUMs. Even - * though the goal is to facilitate constant-time-ness, not each subroutine - * is constant-time by itself. They all have pre-conditions, consult source - * code... - */ -int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - BN_MONT_CTX *mont, BN_CTX *ctx); -int bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, - BN_CTX *ctx); -int bn_from_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, - BN_CTX *ctx); -int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m); -int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m); -int bn_mul_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); -int bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx); -int bn_lshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n); -int bn_rshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n); -int bn_div_fixed_top(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, - const BIGNUM *d, BN_CTX *ctx); - -#endif +/* + * Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_BN_H +# define OSSL_CRYPTO_BN_H + +# include <openssl/bn.h> +# include <limits.h> + +BIGNUM *bn_wexpand(BIGNUM *a, int words); +BIGNUM *bn_expand2(BIGNUM *a, int words); + +void bn_correct_top(BIGNUM *a); + +/* + * Determine the modified width-(w+1) Non-Adjacent Form (wNAF) of 'scalar'. + * This is an array r[] of values that are either zero or odd with an + * absolute value less than 2^w satisfying scalar = \sum_j r[j]*2^j where at + * most one of any w+1 consecutive digits is non-zero with the exception that + * the most significant digit may be only w-1 zeros away from that next + * non-zero digit. + */ +signed char *bn_compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len); + +int bn_get_top(const BIGNUM *a); + +int bn_get_dmax(const BIGNUM *a); + +/* Set all words to zero */ +void bn_set_all_zero(BIGNUM *a); + +/* + * Copy the internal BIGNUM words into out which holds size elements (and size + * must be bigger than top) + */ +int bn_copy_words(BN_ULONG *out, const BIGNUM *in, int size); + +BN_ULONG *bn_get_words(const BIGNUM *a); + +/* + * Set the internal data words in a to point to words which contains size + * elements. The BN_FLG_STATIC_DATA flag is set + */ +void bn_set_static_words(BIGNUM *a, const BN_ULONG *words, int size); + +/* + * Copy words into the BIGNUM |a|, reallocating space as necessary. + * The negative flag of |a| is not modified. + * Returns 1 on success and 0 on failure. + */ +/* + * |num_words| is int because bn_expand2 takes an int. This is an internal + * function so we simply trust callers not to pass negative values. + */ +int bn_set_words(BIGNUM *a, const BN_ULONG *words, int num_words); + +/* + * Some BIGNUM functions assume most significant limb to be non-zero, which + * is customarily arranged by bn_correct_top. Output from below functions + * is not processed with bn_correct_top, and for this reason it may not be + * returned out of public API. It may only be passed internally into other + * functions known to support non-minimal or zero-padded BIGNUMs. Even + * though the goal is to facilitate constant-time-ness, not each subroutine + * is constant-time by itself. They all have pre-conditions, consult source + * code... + */ +int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + BN_MONT_CTX *mont, BN_CTX *ctx); +int bn_to_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, + BN_CTX *ctx); +int bn_from_mont_fixed_top(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, + BN_CTX *ctx); +int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m); +int bn_mod_sub_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, + const BIGNUM *m); +int bn_mul_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); +int bn_sqr_fixed_top(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx); +int bn_lshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n); +int bn_rshift_fixed_top(BIGNUM *r, const BIGNUM *a, int n); +int bn_div_fixed_top(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, + const BIGNUM *d, BN_CTX *ctx); + +#endif diff --git a/contrib/libs/openssl/include/crypto/bn_conf-osx-linux_aarch64-osx_arm64-linux.h b/contrib/libs/openssl/include/crypto/bn_conf-osx-linux_aarch64-osx_arm64-linux.h index c0f5a05032..0bacac0ee3 100644 --- a/contrib/libs/openssl/include/crypto/bn_conf-osx-linux_aarch64-osx_arm64-linux.h +++ b/contrib/libs/openssl/include/crypto/bn_conf-osx-linux_aarch64-osx_arm64-linux.h @@ -9,8 +9,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_BN_CONF_H -# define OSSL_CRYPTO_BN_CONF_H +#ifndef OSSL_CRYPTO_BN_CONF_H +# define OSSL_CRYPTO_BN_CONF_H /* * The contents of this file are not used in the UEFI build, as diff --git a/contrib/libs/openssl/include/crypto/chacha.h b/contrib/libs/openssl/include/crypto/chacha.h index bccffd4816..4029400a67 100644 --- a/contrib/libs/openssl/include/crypto/chacha.h +++ b/contrib/libs/openssl/include/crypto/chacha.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_CHACHA_H -#define OSSL_CRYPTO_CHACHA_H +#ifndef OSSL_CRYPTO_CHACHA_H +#define OSSL_CRYPTO_CHACHA_H #include <stddef.h> diff --git a/contrib/libs/openssl/include/crypto/cryptlib.h b/contrib/libs/openssl/include/crypto/cryptlib.h index 01932314c2..38b5dac9a3 100644 --- a/contrib/libs/openssl/include/crypto/cryptlib.h +++ b/contrib/libs/openssl/include/crypto/cryptlib.h @@ -1,35 +1,35 @@ -/* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include "internal/cryptlib.h" - -/* This file is not scanned by mkdef.pl, whereas cryptlib.h is */ - -struct thread_local_inits_st { - int async; - int err_state; - int rand; -}; - -int ossl_init_thread_start(uint64_t opts); - -/* - * OPENSSL_INIT flags. The primary list of these is in crypto.h. Flags below - * are those omitted from crypto.h because they are "reserved for internal - * use". - */ -# define OPENSSL_INIT_ZLIB 0x00010000L -# define OPENSSL_INIT_BASE_ONLY 0x00040000L - -/* OPENSSL_INIT_THREAD flags */ -# define OPENSSL_INIT_THREAD_ASYNC 0x01 -# define OPENSSL_INIT_THREAD_ERR_STATE 0x02 -# define OPENSSL_INIT_THREAD_RAND 0x04 - -void ossl_malloc_setup_failures(void); +/* + * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "internal/cryptlib.h" + +/* This file is not scanned by mkdef.pl, whereas cryptlib.h is */ + +struct thread_local_inits_st { + int async; + int err_state; + int rand; +}; + +int ossl_init_thread_start(uint64_t opts); + +/* + * OPENSSL_INIT flags. The primary list of these is in crypto.h. Flags below + * are those omitted from crypto.h because they are "reserved for internal + * use". + */ +# define OPENSSL_INIT_ZLIB 0x00010000L +# define OPENSSL_INIT_BASE_ONLY 0x00040000L + +/* OPENSSL_INIT_THREAD flags */ +# define OPENSSL_INIT_THREAD_ASYNC 0x01 +# define OPENSSL_INIT_THREAD_ERR_STATE 0x02 +# define OPENSSL_INIT_THREAD_RAND 0x04 + +void ossl_malloc_setup_failures(void); diff --git a/contrib/libs/openssl/include/crypto/ctype.h b/contrib/libs/openssl/include/crypto/ctype.h index 56d219fb23..81ef8f5cf7 100644 --- a/contrib/libs/openssl/include/crypto/ctype.h +++ b/contrib/libs/openssl/include/crypto/ctype.h @@ -18,8 +18,8 @@ * throughout the rest of the source code. Refer to issue #4154 for * details. */ -#ifndef OSSL_CRYPTO_CTYPE_H -# define OSSL_CRYPTO_CTYPE_H +#ifndef OSSL_CRYPTO_CTYPE_H +# define OSSL_CRYPTO_CTYPE_H # define CTYPE_MASK_lower 0x1 # define CTYPE_MASK_upper 0x2 diff --git a/contrib/libs/openssl/include/crypto/dso_conf-osx-linux_aarch64-linux.h b/contrib/libs/openssl/include/crypto/dso_conf-osx-linux_aarch64-linux.h index 1a4d46c17b..8cc3aaf172 100644 --- a/contrib/libs/openssl/include/crypto/dso_conf-osx-linux_aarch64-linux.h +++ b/contrib/libs/openssl/include/crypto/dso_conf-osx-linux_aarch64-linux.h @@ -1,7 +1,7 @@ /* WARNING: do not edit! */ -/* Generated by Makefile from include/crypto/dso_conf.h.in */ +/* Generated by Makefile from include/crypto/dso_conf.h.in */ /* - * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -9,8 +9,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_DSO_CONF_H -# define OSSL_CRYPTO_DSO_CONF_H -# define DSO_NONE -# define DSO_EXTENSION ".so" +#ifndef OSSL_CRYPTO_DSO_CONF_H +# define OSSL_CRYPTO_DSO_CONF_H +# define DSO_NONE +# define DSO_EXTENSION ".so" #endif diff --git a/contrib/libs/openssl/include/crypto/ec.h b/contrib/libs/openssl/include/crypto/ec.h index f377def708..fe52ae704b 100644 --- a/contrib/libs/openssl/include/crypto/ec.h +++ b/contrib/libs/openssl/include/crypto/ec.h @@ -1,53 +1,53 @@ -/* - * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* Internal EC functions for other submodules: not for application use */ - -#ifndef OSSL_CRYPTO_EC_H -# define OSSL_CRYPTO_EC_H -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_EC - -# include <openssl/ec.h> - -/*- - * Computes the multiplicative inverse of x in the range - * [1,EC_GROUP::order), where EC_GROUP::order is the cardinality of the - * subgroup generated by the generator G: - * - * res := x^(-1) (mod EC_GROUP::order). - * - * This function expects the following two conditions to hold: - * - the EC_GROUP order is prime, and - * - x is included in the range [1, EC_GROUP::order). - * - * This function returns 1 on success, 0 on error. - * - * If the EC_GROUP order is even, this function explicitly returns 0 as - * an error. - * In case any of the two conditions stated above is not satisfied, - * the correctness of its output is not guaranteed, even if the return - * value could still be 1 (as primality testing and a conditional modular - * reduction round on the input can be omitted by the underlying - * implementations for better SCA properties on regular input values). - */ -__owur int ec_group_do_inverse_ord(const EC_GROUP *group, BIGNUM *res, - const BIGNUM *x, BN_CTX *ctx); - -/*- - * ECDH Key Derivation Function as defined in ANSI X9.63 - */ -int ecdh_KDF_X9_63(unsigned char *out, size_t outlen, - const unsigned char *Z, size_t Zlen, - const unsigned char *sinfo, size_t sinfolen, - const EVP_MD *md); - -# endif /* OPENSSL_NO_EC */ -#endif +/* + * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* Internal EC functions for other submodules: not for application use */ + +#ifndef OSSL_CRYPTO_EC_H +# define OSSL_CRYPTO_EC_H +# include <openssl/opensslconf.h> + +# ifndef OPENSSL_NO_EC + +# include <openssl/ec.h> + +/*- + * Computes the multiplicative inverse of x in the range + * [1,EC_GROUP::order), where EC_GROUP::order is the cardinality of the + * subgroup generated by the generator G: + * + * res := x^(-1) (mod EC_GROUP::order). + * + * This function expects the following two conditions to hold: + * - the EC_GROUP order is prime, and + * - x is included in the range [1, EC_GROUP::order). + * + * This function returns 1 on success, 0 on error. + * + * If the EC_GROUP order is even, this function explicitly returns 0 as + * an error. + * In case any of the two conditions stated above is not satisfied, + * the correctness of its output is not guaranteed, even if the return + * value could still be 1 (as primality testing and a conditional modular + * reduction round on the input can be omitted by the underlying + * implementations for better SCA properties on regular input values). + */ +__owur int ec_group_do_inverse_ord(const EC_GROUP *group, BIGNUM *res, + const BIGNUM *x, BN_CTX *ctx); + +/*- + * ECDH Key Derivation Function as defined in ANSI X9.63 + */ +int ecdh_KDF_X9_63(unsigned char *out, size_t outlen, + const unsigned char *Z, size_t Zlen, + const unsigned char *sinfo, size_t sinfolen, + const EVP_MD *md); + +# endif /* OPENSSL_NO_EC */ +#endif diff --git a/contrib/libs/openssl/include/crypto/err.h b/contrib/libs/openssl/include/crypto/err.h index eba474897c..8ab0e5baaa 100644 --- a/contrib/libs/openssl/include/crypto/err.h +++ b/contrib/libs/openssl/include/crypto/err.h @@ -1,19 +1,19 @@ -/* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_CRYPTO_ERR_H -# define OSSL_CRYPTO_ERR_H - -int err_load_crypto_strings_int(void); -void err_cleanup(void); -void err_delete_thread_state(void); -int err_shelve_state(void **); -void err_unshelve_state(void *); - -#endif +/* + * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_CRYPTO_ERR_H +# define OSSL_CRYPTO_ERR_H + +int err_load_crypto_strings_int(void); +void err_cleanup(void); +void err_delete_thread_state(void); +int err_shelve_state(void **); +void err_unshelve_state(void *); + +#endif diff --git a/contrib/libs/openssl/include/crypto/evp.h b/contrib/libs/openssl/include/crypto/evp.h index 94587f1ebb..d86aed36f0 100644 --- a/contrib/libs/openssl/include/crypto/evp.h +++ b/contrib/libs/openssl/include/crypto/evp.h @@ -1,442 +1,442 @@ -/* - * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <openssl/evp.h> -#include "internal/refcount.h" - -/* - * Don't free up md_ctx->pctx in EVP_MD_CTX_reset, use the reserved flag - * values in evp.h - */ -#define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX 0x0400 - -struct evp_pkey_ctx_st { - /* Method associated with this operation */ - const EVP_PKEY_METHOD *pmeth; - /* Engine that implements this method or NULL if builtin */ - ENGINE *engine; - /* Key: may be NULL */ - EVP_PKEY *pkey; - /* Peer key for key agreement, may be NULL */ - EVP_PKEY *peerkey; - /* Actual operation */ - int operation; - /* Algorithm specific data */ - void *data; - /* Application specific data */ - void *app_data; - /* Keygen callback */ - EVP_PKEY_gen_cb *pkey_gencb; - /* implementation specific keygen data */ - int *keygen_info; - int keygen_info_count; -} /* EVP_PKEY_CTX */ ; - -#define EVP_PKEY_FLAG_DYNAMIC 1 - -struct evp_pkey_method_st { - int pkey_id; - int flags; - int (*init) (EVP_PKEY_CTX *ctx); - int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src); - void (*cleanup) (EVP_PKEY_CTX *ctx); - int (*paramgen_init) (EVP_PKEY_CTX *ctx); - int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); - int (*keygen_init) (EVP_PKEY_CTX *ctx); - int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); - int (*sign_init) (EVP_PKEY_CTX *ctx); - int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, - const unsigned char *tbs, size_t tbslen); - int (*verify_init) (EVP_PKEY_CTX *ctx); - int (*verify) (EVP_PKEY_CTX *ctx, - const unsigned char *sig, size_t siglen, - const unsigned char *tbs, size_t tbslen); - int (*verify_recover_init) (EVP_PKEY_CTX *ctx); - int (*verify_recover) (EVP_PKEY_CTX *ctx, - unsigned char *rout, size_t *routlen, - const unsigned char *sig, size_t siglen); - int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); - int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, - EVP_MD_CTX *mctx); - int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); - int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, - EVP_MD_CTX *mctx); - int (*encrypt_init) (EVP_PKEY_CTX *ctx); - int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen); - int (*decrypt_init) (EVP_PKEY_CTX *ctx); - int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen); - int (*derive_init) (EVP_PKEY_CTX *ctx); - int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); - 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); - - int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); -} /* EVP_PKEY_METHOD */ ; - -DEFINE_STACK_OF_CONST(EVP_PKEY_METHOD) - -void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx); - -extern const EVP_PKEY_METHOD cmac_pkey_meth; -extern const EVP_PKEY_METHOD dh_pkey_meth; -extern const EVP_PKEY_METHOD dhx_pkey_meth; -extern const EVP_PKEY_METHOD dsa_pkey_meth; -extern const EVP_PKEY_METHOD ec_pkey_meth; -extern const EVP_PKEY_METHOD sm2_pkey_meth; -extern const EVP_PKEY_METHOD ecx25519_pkey_meth; -extern const EVP_PKEY_METHOD ecx448_pkey_meth; -extern const EVP_PKEY_METHOD ed25519_pkey_meth; -extern const EVP_PKEY_METHOD ed448_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 scrypt_pkey_meth; -extern const EVP_PKEY_METHOD tls1_prf_pkey_meth; -extern const EVP_PKEY_METHOD hkdf_pkey_meth; -extern const EVP_PKEY_METHOD poly1305_pkey_meth; -extern const EVP_PKEY_METHOD siphash_pkey_meth; - -struct evp_md_st { - int type; - int pkey_type; - int md_size; - unsigned long flags; - int (*init) (EVP_MD_CTX *ctx); - int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count); - int (*final) (EVP_MD_CTX *ctx, unsigned char *md); - int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from); - int (*cleanup) (EVP_MD_CTX *ctx); - int block_size; - int ctx_size; /* how big does the ctx->md_data need to be */ - /* control function */ - int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2); -} /* EVP_MD */ ; - -struct evp_cipher_st { - int nid; - int block_size; - /* Default value for variable length ciphers */ - int key_len; - int iv_len; - /* Various flags */ - unsigned long flags; - /* init key */ - int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key, - const unsigned char *iv, int enc); - /* encrypt/decrypt data */ - int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, size_t inl); - /* cleanup ctx */ - int (*cleanup) (EVP_CIPHER_CTX *); - /* how big ctx->cipher_data needs to be */ - int ctx_size; - /* Populate a ASN1_TYPE with parameters */ - int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *); - /* Get parameters from a ASN1_TYPE */ - int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *); - /* Miscellaneous operations */ - int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr); - /* Application data */ - void *app_data; -} /* EVP_CIPHER */ ; - -/* Macros to code block cipher wrappers */ - -/* Wrapper functions for each cipher mode */ - -#define EVP_C_DATA(kstruct, ctx) \ - ((kstruct *)EVP_CIPHER_CTX_get_cipher_data(ctx)) - -#define BLOCK_CIPHER_ecb_loop() \ - size_t i, bl; \ - bl = EVP_CIPHER_CTX_cipher(ctx)->block_size; \ - if (inl < bl) return 1;\ - inl -= bl; \ - for (i=0; i <= inl; i+=bl) - -#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ -static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ -{\ - BLOCK_CIPHER_ecb_loop() \ - cprefix##_ecb_encrypt(in + i, out + i, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_encrypting(ctx)); \ - return 1;\ -} - -#define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2)) - -#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ - static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ -{\ - while(inl>=EVP_MAXCHUNK) {\ - int num = EVP_CIPHER_CTX_num(ctx);\ - cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \ - EVP_CIPHER_CTX_set_num(ctx, num);\ - inl-=EVP_MAXCHUNK;\ - in +=EVP_MAXCHUNK;\ - out+=EVP_MAXCHUNK;\ - }\ - if (inl) {\ - int num = EVP_CIPHER_CTX_num(ctx);\ - cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \ - EVP_CIPHER_CTX_set_num(ctx, num);\ - }\ - return 1;\ -} - -#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ -static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ -{\ - while(inl>=EVP_MAXCHUNK) \ - {\ - cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\ - inl-=EVP_MAXCHUNK;\ - in +=EVP_MAXCHUNK;\ - out+=EVP_MAXCHUNK;\ - }\ - if (inl)\ - cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\ - return 1;\ -} - -#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ -static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ -{\ - size_t chunk = EVP_MAXCHUNK;\ - if (cbits == 1) chunk >>= 3;\ - if (inl < chunk) chunk = inl;\ - while (inl && inl >= chunk)\ - {\ - int num = EVP_CIPHER_CTX_num(ctx);\ - cprefix##_cfb##cbits##_encrypt(in, out, (long) \ - ((cbits == 1) \ - && !EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS) \ - ? chunk*8 : chunk), \ - &EVP_C_DATA(kstruct, ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx),\ - &num, EVP_CIPHER_CTX_encrypting(ctx));\ - EVP_CIPHER_CTX_set_num(ctx, num);\ - inl -= chunk;\ - in += chunk;\ - out += chunk;\ - if (inl < chunk) chunk = inl;\ - }\ - return 1;\ -} - -#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ - BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ - BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ - BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ - BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) - -#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \ - key_len, iv_len, flags, init_key, cleanup, \ - set_asn1, get_asn1, ctrl) \ -static const EVP_CIPHER cname##_##mode = { \ - nid##_##nmode, block_size, key_len, iv_len, \ - flags | EVP_CIPH_##MODE##_MODE, \ - init_key, \ - cname##_##mode##_cipher, \ - cleanup, \ - sizeof(kstruct), \ - set_asn1, get_asn1,\ - ctrl, \ - NULL \ -}; \ -const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } - -#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \ - iv_len, flags, init_key, cleanup, set_asn1, \ - get_asn1, ctrl) \ -BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \ - iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) - -#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \ - iv_len, cbits, flags, init_key, cleanup, \ - set_asn1, get_asn1, ctrl) \ -BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \ - key_len, iv_len, flags, init_key, cleanup, set_asn1, \ - get_asn1, ctrl) - -#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \ - iv_len, cbits, flags, init_key, cleanup, \ - set_asn1, get_asn1, ctrl) \ -BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \ - key_len, iv_len, flags, init_key, cleanup, set_asn1, \ - get_asn1, ctrl) - -#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \ - flags, init_key, cleanup, set_asn1, \ - get_asn1, ctrl) \ -BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \ - 0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) - -#define BLOCK_CIPHER_defs(cname, kstruct, \ - nid, block_size, key_len, iv_len, cbits, flags, \ - init_key, cleanup, set_asn1, get_asn1, ctrl) \ -BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \ - init_key, cleanup, set_asn1, get_asn1, ctrl) \ -BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \ - flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ -BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \ - flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ -BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \ - init_key, cleanup, set_asn1, get_asn1, ctrl) - -/*- -#define BLOCK_CIPHER_defs(cname, kstruct, \ - nid, block_size, key_len, iv_len, flags,\ - init_key, cleanup, set_asn1, get_asn1, ctrl)\ -static const EVP_CIPHER cname##_cbc = {\ - nid##_cbc, block_size, key_len, iv_len, \ - flags | EVP_CIPH_CBC_MODE,\ - init_key,\ - cname##_cbc_cipher,\ - cleanup,\ - sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ - sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ - set_asn1, get_asn1,\ - ctrl, \ - NULL \ -};\ -const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\ -static const EVP_CIPHER cname##_cfb = {\ - nid##_cfb64, 1, key_len, iv_len, \ - flags | EVP_CIPH_CFB_MODE,\ - init_key,\ - cname##_cfb_cipher,\ - cleanup,\ - sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ - sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ - set_asn1, get_asn1,\ - ctrl,\ - NULL \ -};\ -const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\ -static const EVP_CIPHER cname##_ofb = {\ - nid##_ofb64, 1, key_len, iv_len, \ - flags | EVP_CIPH_OFB_MODE,\ - init_key,\ - cname##_ofb_cipher,\ - cleanup,\ - sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ - sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ - set_asn1, get_asn1,\ - ctrl,\ - NULL \ -};\ -const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\ -static const EVP_CIPHER cname##_ecb = {\ - nid##_ecb, block_size, key_len, iv_len, \ - flags | EVP_CIPH_ECB_MODE,\ - init_key,\ - cname##_ecb_cipher,\ - cleanup,\ - sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ - sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ - set_asn1, get_asn1,\ - ctrl,\ - NULL \ -};\ -const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; } -*/ - -#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \ - block_size, key_len, iv_len, cbits, \ - flags, init_key, \ - cleanup, set_asn1, get_asn1, ctrl) \ - BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ - BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \ - cbits, flags, init_key, cleanup, set_asn1, \ - get_asn1, ctrl) - -#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \ - BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \ - BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \ - NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \ - (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \ - cipher##_init_key, NULL, NULL, NULL, NULL) - - -# ifndef OPENSSL_NO_EC - -#define X25519_KEYLEN 32 -#define X448_KEYLEN 56 -#define ED448_KEYLEN 57 - -#define MAX_KEYLEN ED448_KEYLEN - -typedef struct { - unsigned char pubkey[MAX_KEYLEN]; - unsigned char *privkey; -} ECX_KEY; - -#endif - -/* - * Type needs to be a bit field Sub-type needs to be for variations on the - * method, as in, can it do arbitrary encryption.... - */ -struct evp_pkey_st { - int type; - int save_type; - CRYPTO_REF_COUNT references; - const EVP_PKEY_ASN1_METHOD *ameth; - ENGINE *engine; - ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */ - union { - void *ptr; -# ifndef OPENSSL_NO_RSA - struct rsa_st *rsa; /* RSA */ -# endif -# ifndef OPENSSL_NO_DSA - struct dsa_st *dsa; /* DSA */ -# endif -# ifndef OPENSSL_NO_DH - struct dh_st *dh; /* DH */ -# endif -# ifndef OPENSSL_NO_EC - struct ec_key_st *ec; /* ECC */ - ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */ -# endif - } pkey; - int save_parameters; - STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ - CRYPTO_RWLOCK *lock; -} /* EVP_PKEY */ ; - - -void openssl_add_all_ciphers_int(void); -void openssl_add_all_digests_int(void); -void evp_cleanup_int(void); -void evp_app_cleanup_int(void); - -/* Pulling defines out of C source files */ - -#define EVP_RC4_KEY_SIZE 16 -#ifndef TLS1_1_VERSION -# define TLS1_1_VERSION 0x0302 -#endif - -void evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags); - -/* EVP_ENCODE_CTX flags */ -/* Don't generate new lines when encoding */ -#define EVP_ENCODE_CTX_NO_NEWLINES 1 -/* Use the SRP base64 alphabet instead of the standard one */ -#define EVP_ENCODE_CTX_USE_SRP_ALPHABET 2 +/* + * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include <openssl/evp.h> +#include "internal/refcount.h" + +/* + * Don't free up md_ctx->pctx in EVP_MD_CTX_reset, use the reserved flag + * values in evp.h + */ +#define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX 0x0400 + +struct evp_pkey_ctx_st { + /* Method associated with this operation */ + const EVP_PKEY_METHOD *pmeth; + /* Engine that implements this method or NULL if builtin */ + ENGINE *engine; + /* Key: may be NULL */ + EVP_PKEY *pkey; + /* Peer key for key agreement, may be NULL */ + EVP_PKEY *peerkey; + /* Actual operation */ + int operation; + /* Algorithm specific data */ + void *data; + /* Application specific data */ + void *app_data; + /* Keygen callback */ + EVP_PKEY_gen_cb *pkey_gencb; + /* implementation specific keygen data */ + int *keygen_info; + int keygen_info_count; +} /* EVP_PKEY_CTX */ ; + +#define EVP_PKEY_FLAG_DYNAMIC 1 + +struct evp_pkey_method_st { + int pkey_id; + int flags; + int (*init) (EVP_PKEY_CTX *ctx); + int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src); + void (*cleanup) (EVP_PKEY_CTX *ctx); + int (*paramgen_init) (EVP_PKEY_CTX *ctx); + int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); + int (*keygen_init) (EVP_PKEY_CTX *ctx); + int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); + int (*sign_init) (EVP_PKEY_CTX *ctx); + int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + const unsigned char *tbs, size_t tbslen); + int (*verify_init) (EVP_PKEY_CTX *ctx); + int (*verify) (EVP_PKEY_CTX *ctx, + const unsigned char *sig, size_t siglen, + const unsigned char *tbs, size_t tbslen); + int (*verify_recover_init) (EVP_PKEY_CTX *ctx); + int (*verify_recover) (EVP_PKEY_CTX *ctx, + unsigned char *rout, size_t *routlen, + const unsigned char *sig, size_t siglen); + int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); + int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, + EVP_MD_CTX *mctx); + int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); + int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, + EVP_MD_CTX *mctx); + int (*encrypt_init) (EVP_PKEY_CTX *ctx); + int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen); + int (*decrypt_init) (EVP_PKEY_CTX *ctx); + int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, + const unsigned char *in, size_t inlen); + int (*derive_init) (EVP_PKEY_CTX *ctx); + int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); + 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); + + int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); +} /* EVP_PKEY_METHOD */ ; + +DEFINE_STACK_OF_CONST(EVP_PKEY_METHOD) + +void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx); + +extern const EVP_PKEY_METHOD cmac_pkey_meth; +extern const EVP_PKEY_METHOD dh_pkey_meth; +extern const EVP_PKEY_METHOD dhx_pkey_meth; +extern const EVP_PKEY_METHOD dsa_pkey_meth; +extern const EVP_PKEY_METHOD ec_pkey_meth; +extern const EVP_PKEY_METHOD sm2_pkey_meth; +extern const EVP_PKEY_METHOD ecx25519_pkey_meth; +extern const EVP_PKEY_METHOD ecx448_pkey_meth; +extern const EVP_PKEY_METHOD ed25519_pkey_meth; +extern const EVP_PKEY_METHOD ed448_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 scrypt_pkey_meth; +extern const EVP_PKEY_METHOD tls1_prf_pkey_meth; +extern const EVP_PKEY_METHOD hkdf_pkey_meth; +extern const EVP_PKEY_METHOD poly1305_pkey_meth; +extern const EVP_PKEY_METHOD siphash_pkey_meth; + +struct evp_md_st { + int type; + int pkey_type; + int md_size; + unsigned long flags; + int (*init) (EVP_MD_CTX *ctx); + int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count); + int (*final) (EVP_MD_CTX *ctx, unsigned char *md); + int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from); + int (*cleanup) (EVP_MD_CTX *ctx); + int block_size; + int ctx_size; /* how big does the ctx->md_data need to be */ + /* control function */ + int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2); +} /* EVP_MD */ ; + +struct evp_cipher_st { + int nid; + int block_size; + /* Default value for variable length ciphers */ + int key_len; + int iv_len; + /* Various flags */ + unsigned long flags; + /* init key */ + int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key, + const unsigned char *iv, int enc); + /* encrypt/decrypt data */ + int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out, + const unsigned char *in, size_t inl); + /* cleanup ctx */ + int (*cleanup) (EVP_CIPHER_CTX *); + /* how big ctx->cipher_data needs to be */ + int ctx_size; + /* Populate a ASN1_TYPE with parameters */ + int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *); + /* Get parameters from a ASN1_TYPE */ + int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *); + /* Miscellaneous operations */ + int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr); + /* Application data */ + void *app_data; +} /* EVP_CIPHER */ ; + +/* Macros to code block cipher wrappers */ + +/* Wrapper functions for each cipher mode */ + +#define EVP_C_DATA(kstruct, ctx) \ + ((kstruct *)EVP_CIPHER_CTX_get_cipher_data(ctx)) + +#define BLOCK_CIPHER_ecb_loop() \ + size_t i, bl; \ + bl = EVP_CIPHER_CTX_cipher(ctx)->block_size; \ + if (inl < bl) return 1;\ + inl -= bl; \ + for (i=0; i <= inl; i+=bl) + +#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ +static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ +{\ + BLOCK_CIPHER_ecb_loop() \ + cprefix##_ecb_encrypt(in + i, out + i, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_encrypting(ctx)); \ + return 1;\ +} + +#define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2)) + +#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ + static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ +{\ + while(inl>=EVP_MAXCHUNK) {\ + int num = EVP_CIPHER_CTX_num(ctx);\ + cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \ + EVP_CIPHER_CTX_set_num(ctx, num);\ + inl-=EVP_MAXCHUNK;\ + in +=EVP_MAXCHUNK;\ + out+=EVP_MAXCHUNK;\ + }\ + if (inl) {\ + int num = EVP_CIPHER_CTX_num(ctx);\ + cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \ + EVP_CIPHER_CTX_set_num(ctx, num);\ + }\ + return 1;\ +} + +#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ +static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ +{\ + while(inl>=EVP_MAXCHUNK) \ + {\ + cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\ + inl-=EVP_MAXCHUNK;\ + in +=EVP_MAXCHUNK;\ + out+=EVP_MAXCHUNK;\ + }\ + if (inl)\ + cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\ + return 1;\ +} + +#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ +static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ +{\ + size_t chunk = EVP_MAXCHUNK;\ + if (cbits == 1) chunk >>= 3;\ + if (inl < chunk) chunk = inl;\ + while (inl && inl >= chunk)\ + {\ + int num = EVP_CIPHER_CTX_num(ctx);\ + cprefix##_cfb##cbits##_encrypt(in, out, (long) \ + ((cbits == 1) \ + && !EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS) \ + ? chunk*8 : chunk), \ + &EVP_C_DATA(kstruct, ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx),\ + &num, EVP_CIPHER_CTX_encrypting(ctx));\ + EVP_CIPHER_CTX_set_num(ctx, num);\ + inl -= chunk;\ + in += chunk;\ + out += chunk;\ + if (inl < chunk) chunk = inl;\ + }\ + return 1;\ +} + +#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ + BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ + BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ + BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ + BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) + +#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \ + key_len, iv_len, flags, init_key, cleanup, \ + set_asn1, get_asn1, ctrl) \ +static const EVP_CIPHER cname##_##mode = { \ + nid##_##nmode, block_size, key_len, iv_len, \ + flags | EVP_CIPH_##MODE##_MODE, \ + init_key, \ + cname##_##mode##_cipher, \ + cleanup, \ + sizeof(kstruct), \ + set_asn1, get_asn1,\ + ctrl, \ + NULL \ +}; \ +const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } + +#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \ + iv_len, flags, init_key, cleanup, set_asn1, \ + get_asn1, ctrl) \ +BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \ + iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) + +#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \ + iv_len, cbits, flags, init_key, cleanup, \ + set_asn1, get_asn1, ctrl) \ +BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \ + key_len, iv_len, flags, init_key, cleanup, set_asn1, \ + get_asn1, ctrl) + +#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \ + iv_len, cbits, flags, init_key, cleanup, \ + set_asn1, get_asn1, ctrl) \ +BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \ + key_len, iv_len, flags, init_key, cleanup, set_asn1, \ + get_asn1, ctrl) + +#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \ + flags, init_key, cleanup, set_asn1, \ + get_asn1, ctrl) \ +BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \ + 0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) + +#define BLOCK_CIPHER_defs(cname, kstruct, \ + nid, block_size, key_len, iv_len, cbits, flags, \ + init_key, cleanup, set_asn1, get_asn1, ctrl) \ +BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \ + init_key, cleanup, set_asn1, get_asn1, ctrl) \ +BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \ + flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ +BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \ + flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ +BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \ + init_key, cleanup, set_asn1, get_asn1, ctrl) + +/*- +#define BLOCK_CIPHER_defs(cname, kstruct, \ + nid, block_size, key_len, iv_len, flags,\ + init_key, cleanup, set_asn1, get_asn1, ctrl)\ +static const EVP_CIPHER cname##_cbc = {\ + nid##_cbc, block_size, key_len, iv_len, \ + flags | EVP_CIPH_CBC_MODE,\ + init_key,\ + cname##_cbc_cipher,\ + cleanup,\ + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ + set_asn1, get_asn1,\ + ctrl, \ + NULL \ +};\ +const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\ +static const EVP_CIPHER cname##_cfb = {\ + nid##_cfb64, 1, key_len, iv_len, \ + flags | EVP_CIPH_CFB_MODE,\ + init_key,\ + cname##_cfb_cipher,\ + cleanup,\ + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ + set_asn1, get_asn1,\ + ctrl,\ + NULL \ +};\ +const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\ +static const EVP_CIPHER cname##_ofb = {\ + nid##_ofb64, 1, key_len, iv_len, \ + flags | EVP_CIPH_OFB_MODE,\ + init_key,\ + cname##_ofb_cipher,\ + cleanup,\ + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ + set_asn1, get_asn1,\ + ctrl,\ + NULL \ +};\ +const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\ +static const EVP_CIPHER cname##_ecb = {\ + nid##_ecb, block_size, key_len, iv_len, \ + flags | EVP_CIPH_ECB_MODE,\ + init_key,\ + cname##_ecb_cipher,\ + cleanup,\ + sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ + sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ + set_asn1, get_asn1,\ + ctrl,\ + NULL \ +};\ +const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; } +*/ + +#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \ + block_size, key_len, iv_len, cbits, \ + flags, init_key, \ + cleanup, set_asn1, get_asn1, ctrl) \ + BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ + BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \ + cbits, flags, init_key, cleanup, set_asn1, \ + get_asn1, ctrl) + +#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \ + BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \ + BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \ + NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \ + (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \ + cipher##_init_key, NULL, NULL, NULL, NULL) + + +# ifndef OPENSSL_NO_EC + +#define X25519_KEYLEN 32 +#define X448_KEYLEN 56 +#define ED448_KEYLEN 57 + +#define MAX_KEYLEN ED448_KEYLEN + +typedef struct { + unsigned char pubkey[MAX_KEYLEN]; + unsigned char *privkey; +} ECX_KEY; + +#endif + +/* + * Type needs to be a bit field Sub-type needs to be for variations on the + * method, as in, can it do arbitrary encryption.... + */ +struct evp_pkey_st { + int type; + int save_type; + CRYPTO_REF_COUNT references; + const EVP_PKEY_ASN1_METHOD *ameth; + ENGINE *engine; + ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */ + union { + void *ptr; +# ifndef OPENSSL_NO_RSA + struct rsa_st *rsa; /* RSA */ +# endif +# ifndef OPENSSL_NO_DSA + struct dsa_st *dsa; /* DSA */ +# endif +# ifndef OPENSSL_NO_DH + struct dh_st *dh; /* DH */ +# endif +# ifndef OPENSSL_NO_EC + struct ec_key_st *ec; /* ECC */ + ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */ +# endif + } pkey; + int save_parameters; + STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ + CRYPTO_RWLOCK *lock; +} /* EVP_PKEY */ ; + + +void openssl_add_all_ciphers_int(void); +void openssl_add_all_digests_int(void); +void evp_cleanup_int(void); +void evp_app_cleanup_int(void); + +/* Pulling defines out of C source files */ + +#define EVP_RC4_KEY_SIZE 16 +#ifndef TLS1_1_VERSION +# define TLS1_1_VERSION 0x0302 +#endif + +void evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags); + +/* EVP_ENCODE_CTX flags */ +/* Don't generate new lines when encoding */ +#define EVP_ENCODE_CTX_NO_NEWLINES 1 +/* Use the SRP base64 alphabet instead of the standard one */ +#define EVP_ENCODE_CTX_USE_SRP_ALPHABET 2 diff --git a/contrib/libs/openssl/include/crypto/lhash.h b/contrib/libs/openssl/include/crypto/lhash.h index d8f917af06..ab060cce74 100644 --- a/contrib/libs/openssl/include/crypto/lhash.h +++ b/contrib/libs/openssl/include/crypto/lhash.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_LHASH_H -# define OSSL_CRYPTO_LHASH_H +#ifndef OSSL_CRYPTO_LHASH_H +# define OSSL_CRYPTO_LHASH_H unsigned long openssl_lh_strcasehash(const char *); diff --git a/contrib/libs/openssl/include/crypto/rand.h b/contrib/libs/openssl/include/crypto/rand.h index 75a2cdcf5e..5350d3a931 100644 --- a/contrib/libs/openssl/include/crypto/rand.h +++ b/contrib/libs/openssl/include/crypto/rand.h @@ -1,134 +1,134 @@ -/* - * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * Licensed under the OpenSSL licenses, (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * https://www.openssl.org/source/license.html - * or in the file LICENSE in the source distribution. - */ - -#ifndef OSSL_CRYPTO_RAND_H -# define OSSL_CRYPTO_RAND_H - -# include <openssl/rand.h> - -/* forward declaration */ -typedef struct rand_pool_st RAND_POOL; - -void rand_cleanup_int(void); -void rand_drbg_cleanup_int(void); -void drbg_delete_thread_state(void); - -/* Hardware-based seeding functions. */ -size_t rand_acquire_entropy_from_tsc(RAND_POOL *pool); -size_t rand_acquire_entropy_from_cpu(RAND_POOL *pool); - -/* DRBG entropy callbacks. */ -size_t rand_drbg_get_entropy(RAND_DRBG *drbg, - unsigned char **pout, - int entropy, size_t min_len, size_t max_len, - int prediction_resistance); -void rand_drbg_cleanup_entropy(RAND_DRBG *drbg, - unsigned char *out, size_t outlen); -size_t rand_drbg_get_nonce(RAND_DRBG *drbg, - unsigned char **pout, - int entropy, size_t min_len, size_t max_len); -void rand_drbg_cleanup_nonce(RAND_DRBG *drbg, - unsigned char *out, size_t outlen); - -size_t rand_drbg_get_additional_data(RAND_POOL *pool, unsigned char **pout); - -void rand_drbg_cleanup_additional_data(RAND_POOL *pool, unsigned char *out); - -/* - * RAND_POOL functions - */ -RAND_POOL *rand_pool_new(int entropy_requested, int secure, - size_t min_len, size_t max_len); -RAND_POOL *rand_pool_attach(const unsigned char *buffer, size_t len, - size_t entropy); -void rand_pool_free(RAND_POOL *pool); - -const unsigned char *rand_pool_buffer(RAND_POOL *pool); -unsigned char *rand_pool_detach(RAND_POOL *pool); -void rand_pool_reattach(RAND_POOL *pool, unsigned char *buffer); - -size_t rand_pool_entropy(RAND_POOL *pool); -size_t rand_pool_length(RAND_POOL *pool); - -size_t rand_pool_entropy_available(RAND_POOL *pool); -size_t rand_pool_entropy_needed(RAND_POOL *pool); -/* |entropy_factor| expresses how many bits of data contain 1 bit of entropy */ -size_t rand_pool_bytes_needed(RAND_POOL *pool, unsigned int entropy_factor); -size_t rand_pool_bytes_remaining(RAND_POOL *pool); - -int rand_pool_add(RAND_POOL *pool, - const unsigned char *buffer, size_t len, size_t entropy); -unsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len); -int rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy); - - -/* - * Add random bytes to the pool to acquire requested amount of entropy - * - * This function is platform specific and tries to acquire the requested - * amount of entropy by polling platform specific entropy sources. - * - * If the function succeeds in acquiring at least |entropy_requested| bits - * of entropy, the total entropy count is returned. If it fails, it returns - * an entropy count of 0. - */ -size_t rand_pool_acquire_entropy(RAND_POOL *pool); - -/* - * Add some application specific nonce data - * - * This function is platform specific and adds some application specific - * data to the nonce used for instantiating the drbg. - * - * This data currently consists of the process and thread id, and a high - * resolution timestamp. The data does not include an atomic counter, - * because that is added by the calling function rand_drbg_get_nonce(). - * - * Returns 1 on success and 0 on failure. - */ -int rand_pool_add_nonce_data(RAND_POOL *pool); - - -/* - * Add some platform specific additional data - * - * This function is platform specific and adds some random noise to the - * additional data used for generating random bytes and for reseeding - * the drbg. - * - * Returns 1 on success and 0 on failure. - */ -int rand_pool_add_additional_data(RAND_POOL *pool); - -/* - * Initialise the random pool reseeding sources. - * - * Returns 1 on success and 0 on failure. - */ -int rand_pool_init(void); - -/* - * Finalise the random pool reseeding sources. - */ -void rand_pool_cleanup(void); - -/* - * Control the random pool use of open file descriptors. - */ -void rand_pool_keep_random_devices_open(int keep); - -#endif +/* + * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/* + * Licensed under the OpenSSL licenses, (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * https://www.openssl.org/source/license.html + * or in the file LICENSE in the source distribution. + */ + +#ifndef OSSL_CRYPTO_RAND_H +# define OSSL_CRYPTO_RAND_H + +# include <openssl/rand.h> + +/* forward declaration */ +typedef struct rand_pool_st RAND_POOL; + +void rand_cleanup_int(void); +void rand_drbg_cleanup_int(void); +void drbg_delete_thread_state(void); + +/* Hardware-based seeding functions. */ +size_t rand_acquire_entropy_from_tsc(RAND_POOL *pool); +size_t rand_acquire_entropy_from_cpu(RAND_POOL *pool); + +/* DRBG entropy callbacks. */ +size_t rand_drbg_get_entropy(RAND_DRBG *drbg, + unsigned char **pout, + int entropy, size_t min_len, size_t max_len, + int prediction_resistance); +void rand_drbg_cleanup_entropy(RAND_DRBG *drbg, + unsigned char *out, size_t outlen); +size_t rand_drbg_get_nonce(RAND_DRBG *drbg, + unsigned char **pout, + int entropy, size_t min_len, size_t max_len); +void rand_drbg_cleanup_nonce(RAND_DRBG *drbg, + unsigned char *out, size_t outlen); + +size_t rand_drbg_get_additional_data(RAND_POOL *pool, unsigned char **pout); + +void rand_drbg_cleanup_additional_data(RAND_POOL *pool, unsigned char *out); + +/* + * RAND_POOL functions + */ +RAND_POOL *rand_pool_new(int entropy_requested, int secure, + size_t min_len, size_t max_len); +RAND_POOL *rand_pool_attach(const unsigned char *buffer, size_t len, + size_t entropy); +void rand_pool_free(RAND_POOL *pool); + +const unsigned char *rand_pool_buffer(RAND_POOL *pool); +unsigned char *rand_pool_detach(RAND_POOL *pool); +void rand_pool_reattach(RAND_POOL *pool, unsigned char *buffer); + +size_t rand_pool_entropy(RAND_POOL *pool); +size_t rand_pool_length(RAND_POOL *pool); + +size_t rand_pool_entropy_available(RAND_POOL *pool); +size_t rand_pool_entropy_needed(RAND_POOL *pool); +/* |entropy_factor| expresses how many bits of data contain 1 bit of entropy */ +size_t rand_pool_bytes_needed(RAND_POOL *pool, unsigned int entropy_factor); +size_t rand_pool_bytes_remaining(RAND_POOL *pool); + +int rand_pool_add(RAND_POOL *pool, + const unsigned char *buffer, size_t len, size_t entropy); +unsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len); +int rand_pool_add_end(RAND_POOL *pool, size_t len, size_t entropy); + + +/* + * Add random bytes to the pool to acquire requested amount of entropy + * + * This function is platform specific and tries to acquire the requested + * amount of entropy by polling platform specific entropy sources. + * + * If the function succeeds in acquiring at least |entropy_requested| bits + * of entropy, the total entropy count is returned. If it fails, it returns + * an entropy count of 0. + */ +size_t rand_pool_acquire_entropy(RAND_POOL *pool); + +/* + * Add some application specific nonce data + * + * This function is platform specific and adds some application specific + * data to the nonce used for instantiating the drbg. + * + * This data currently consists of the process and thread id, and a high + * resolution timestamp. The data does not include an atomic counter, + * because that is added by the calling function rand_drbg_get_nonce(). + * + * Returns 1 on success and 0 on failure. + */ +int rand_pool_add_nonce_data(RAND_POOL *pool); + + +/* + * Add some platform specific additional data + * + * This function is platform specific and adds some random noise to the + * additional data used for generating random bytes and for reseeding + * the drbg. + * + * Returns 1 on success and 0 on failure. + */ +int rand_pool_add_additional_data(RAND_POOL *pool); + +/* + * Initialise the random pool reseeding sources. + * + * Returns 1 on success and 0 on failure. + */ +int rand_pool_init(void); + +/* + * Finalise the random pool reseeding sources. + */ +void rand_pool_cleanup(void); + +/* + * Control the random pool use of open file descriptors. + */ +void rand_pool_keep_random_devices_open(int keep); + +#endif diff --git a/contrib/libs/openssl/include/crypto/sha.h b/contrib/libs/openssl/include/crypto/sha.h index 9c2ad6916b..6d15edb9e5 100644 --- a/contrib/libs/openssl/include/crypto/sha.h +++ b/contrib/libs/openssl/include/crypto/sha.h @@ -8,8 +8,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_SHA_H -# define OSSL_CRYPTO_SHA_H +#ifndef OSSL_CRYPTO_SHA_H +# define OSSL_CRYPTO_SHA_H # include <openssl/opensslconf.h> diff --git a/contrib/libs/openssl/include/crypto/sm2.h b/contrib/libs/openssl/include/crypto/sm2.h index e7de8dec24..a7f5548c08 100644 --- a/contrib/libs/openssl/include/crypto/sm2.h +++ b/contrib/libs/openssl/include/crypto/sm2.h @@ -9,8 +9,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_SM2_H -# define OSSL_CRYPTO_SM2_H +#ifndef OSSL_CRYPTO_SM2_H +# define OSSL_CRYPTO_SM2_H # include <openssl/opensslconf.h> # ifndef OPENSSL_NO_SM2 diff --git a/contrib/libs/openssl/include/crypto/sm2err.h b/contrib/libs/openssl/include/crypto/sm2err.h index bc18fd7cba..d1c0ee2591 100644 --- a/contrib/libs/openssl/include/crypto/sm2err.h +++ b/contrib/libs/openssl/include/crypto/sm2err.h @@ -8,8 +8,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_SM2ERR_H -# define OSSL_CRYPTO_SM2ERR_H +#ifndef OSSL_CRYPTO_SM2ERR_H +# define OSSL_CRYPTO_SM2ERR_H # ifndef HEADER_SYMHACKS_H # include <openssl/symhacks.h> diff --git a/contrib/libs/openssl/include/crypto/sm3.h b/contrib/libs/openssl/include/crypto/sm3.h index 33f6c3acde..97e7460333 100644 --- a/contrib/libs/openssl/include/crypto/sm3.h +++ b/contrib/libs/openssl/include/crypto/sm3.h @@ -8,8 +8,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_SM3_H -# define OSSL_CRYPTO_SM3_H +#ifndef OSSL_CRYPTO_SM3_H +# define OSSL_CRYPTO_SM3_H # include <openssl/opensslconf.h> diff --git a/contrib/libs/openssl/include/crypto/sm4.h b/contrib/libs/openssl/include/crypto/sm4.h index 07975047c6..abe28f385e 100644 --- a/contrib/libs/openssl/include/crypto/sm4.h +++ b/contrib/libs/openssl/include/crypto/sm4.h @@ -8,8 +8,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_SM4_H -# define OSSL_CRYPTO_SM4_H +#ifndef OSSL_CRYPTO_SM4_H +# define OSSL_CRYPTO_SM4_H # include <openssl/opensslconf.h> # include <openssl/e_os2.h> diff --git a/contrib/libs/openssl/include/crypto/store.h b/contrib/libs/openssl/include/crypto/store.h index 5ac228ccdb..428d3c60e1 100644 --- a/contrib/libs/openssl/include/crypto/store.h +++ b/contrib/libs/openssl/include/crypto/store.h @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,22 +7,22 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_CRYPTO_STORE_H -# define OSSL_CRYPTO_STORE_H - -# include <openssl/bio.h> -# include <openssl/store.h> -# include <openssl/ui.h> - -/* - * Two functions to read PEM data off an already opened BIO. To be used - * instead of OSSLSTORE_open() and OSSLSTORE_close(). Everything is done - * as usual with OSSLSTORE_load() and OSSLSTORE_eof(). - */ -OSSL_STORE_CTX *ossl_store_attach_pem_bio(BIO *bp, const UI_METHOD *ui_method, - void *ui_data); -int ossl_store_detach_pem_bio(OSSL_STORE_CTX *ctx); - +#ifndef OSSL_CRYPTO_STORE_H +# define OSSL_CRYPTO_STORE_H + +# include <openssl/bio.h> +# include <openssl/store.h> +# include <openssl/ui.h> + +/* + * Two functions to read PEM data off an already opened BIO. To be used + * instead of OSSLSTORE_open() and OSSLSTORE_close(). Everything is done + * as usual with OSSLSTORE_load() and OSSLSTORE_eof(). + */ +OSSL_STORE_CTX *ossl_store_attach_pem_bio(BIO *bp, const UI_METHOD *ui_method, + void *ui_data); +int ossl_store_detach_pem_bio(OSSL_STORE_CTX *ctx); + void ossl_store_cleanup_int(void); - -#endif + +#endif diff --git a/contrib/libs/openssl/include/crypto/x509.h b/contrib/libs/openssl/include/crypto/x509.h index 23f8423be3..243ea74f6f 100644 --- a/contrib/libs/openssl/include/crypto/x509.h +++ b/contrib/libs/openssl/include/crypto/x509.h @@ -1,291 +1,291 @@ -/* +/* * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include "internal/refcount.h" + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#include "internal/refcount.h" #include <openssl/x509.h> #include <openssl/conf.h> - -/* Internal X509 structures and functions: not for application use */ - -/* Note: unless otherwise stated a field pointer is mandatory and should - * never be set to NULL: the ASN.1 code and accessors rely on mandatory - * fields never being NULL. - */ - -/* - * name entry structure, equivalent to AttributeTypeAndValue defined - * in RFC5280 et al. - */ -struct X509_name_entry_st { - ASN1_OBJECT *object; /* AttributeType */ - ASN1_STRING *value; /* AttributeValue */ - int set; /* index of RDNSequence for this entry */ - int size; /* temp variable */ -}; - -/* Name from RFC 5280. */ -struct X509_name_st { - STACK_OF(X509_NAME_ENTRY) *entries; /* DN components */ - int modified; /* true if 'bytes' needs to be built */ - BUF_MEM *bytes; /* cached encoding: cannot be NULL */ - /* canonical encoding used for rapid Name comparison */ - unsigned char *canon_enc; - int canon_enclen; -} /* X509_NAME */ ; - -/* Signature info structure */ - -struct x509_sig_info_st { - /* NID of message digest */ - int mdnid; - /* NID of public key algorithm */ - int pknid; - /* Security bits */ - int secbits; - /* Various flags */ - uint32_t flags; -}; - -/* PKCS#10 certificate request */ - -struct X509_req_info_st { - ASN1_ENCODING enc; /* cached encoding of signed part */ - ASN1_INTEGER *version; /* version, defaults to v1(0) so can be NULL */ - X509_NAME *subject; /* certificate request DN */ - X509_PUBKEY *pubkey; /* public key of request */ - /* - * Zero or more attributes. - * NB: although attributes is a mandatory field some broken - * encodings omit it so this may be NULL in that case. - */ - STACK_OF(X509_ATTRIBUTE) *attributes; -}; - -struct X509_req_st { - X509_REQ_INFO req_info; /* signed certificate request data */ - X509_ALGOR sig_alg; /* signature algorithm */ - ASN1_BIT_STRING *signature; /* signature */ - CRYPTO_REF_COUNT references; - CRYPTO_RWLOCK *lock; -}; - -struct X509_crl_info_st { - ASN1_INTEGER *version; /* version: defaults to v1(0) so may be NULL */ - X509_ALGOR sig_alg; /* signature algorithm */ - X509_NAME *issuer; /* CRL issuer name */ - ASN1_TIME *lastUpdate; /* lastUpdate field */ - ASN1_TIME *nextUpdate; /* nextUpdate field: optional */ - STACK_OF(X509_REVOKED) *revoked; /* revoked entries: optional */ - STACK_OF(X509_EXTENSION) *extensions; /* extensions: optional */ - ASN1_ENCODING enc; /* encoding of signed portion of CRL */ -}; - -struct X509_crl_st { - X509_CRL_INFO crl; /* signed CRL data */ - X509_ALGOR sig_alg; /* CRL signature algorithm */ - ASN1_BIT_STRING signature; /* CRL signature */ - CRYPTO_REF_COUNT references; - int flags; - /* - * Cached copies of decoded extension values, since extensions - * are optional any of these can be NULL. - */ - AUTHORITY_KEYID *akid; - ISSUING_DIST_POINT *idp; - /* Convenient breakdown of IDP */ - int idp_flags; - int idp_reasons; - /* CRL and base CRL numbers for delta processing */ - ASN1_INTEGER *crl_number; - ASN1_INTEGER *base_crl_number; - STACK_OF(GENERAL_NAMES) *issuers; - /* hash of CRL */ - unsigned char sha1_hash[SHA_DIGEST_LENGTH]; - /* alternative method to handle this CRL */ - const X509_CRL_METHOD *meth; - void *meth_data; - CRYPTO_RWLOCK *lock; -}; - -struct x509_revoked_st { - ASN1_INTEGER serialNumber; /* revoked entry serial number */ - ASN1_TIME *revocationDate; /* revocation date */ - STACK_OF(X509_EXTENSION) *extensions; /* CRL entry extensions: optional */ - /* decoded value of CRLissuer extension: set if indirect CRL */ - STACK_OF(GENERAL_NAME) *issuer; - /* revocation reason: set to CRL_REASON_NONE if reason extension absent */ - int reason; - /* - * CRL entries are reordered for faster lookup of serial numbers. This - * field contains the original load sequence for this entry. - */ - int sequence; -}; - -/* - * This stuff is certificate "auxiliary info": it contains details which are - * useful in certificate stores and databases. When used this is tagged onto - * the end of the certificate itself. OpenSSL specific structure not defined - * in any RFC. - */ - -struct x509_cert_aux_st { - STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */ - STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */ - ASN1_UTF8STRING *alias; /* "friendly name" */ - ASN1_OCTET_STRING *keyid; /* key id of private key */ - STACK_OF(X509_ALGOR) *other; /* other unspecified info */ -}; - -struct x509_cinf_st { - ASN1_INTEGER *version; /* [ 0 ] default of v1 */ - ASN1_INTEGER serialNumber; - X509_ALGOR signature; - X509_NAME *issuer; - X509_VAL validity; - X509_NAME *subject; - X509_PUBKEY *key; - ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ - ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ - STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ - ASN1_ENCODING enc; -}; - -struct x509_st { - X509_CINF cert_info; - X509_ALGOR sig_alg; - ASN1_BIT_STRING signature; - X509_SIG_INFO siginf; - CRYPTO_REF_COUNT references; - CRYPTO_EX_DATA ex_data; - /* These contain copies of various extension values */ - long ex_pathlen; - long ex_pcpathlen; - uint32_t ex_flags; - uint32_t ex_kusage; - uint32_t ex_xkusage; - uint32_t ex_nscert; - ASN1_OCTET_STRING *skid; - AUTHORITY_KEYID *akid; - X509_POLICY_CACHE *policy_cache; - STACK_OF(DIST_POINT) *crldp; - STACK_OF(GENERAL_NAME) *altname; - NAME_CONSTRAINTS *nc; -#ifndef OPENSSL_NO_RFC3779 - STACK_OF(IPAddressFamily) *rfc3779_addr; - struct ASIdentifiers_st *rfc3779_asid; -# endif - unsigned char sha1_hash[SHA_DIGEST_LENGTH]; - X509_CERT_AUX *aux; - CRYPTO_RWLOCK *lock; - volatile int ex_cached; -} /* X509 */ ; - -/* - * This is a used when verifying cert chains. Since the gathering of the - * cert chain can take some time (and have to be 'retried', this needs to be - * kept and passed around. - */ -struct x509_store_ctx_st { /* X509_STORE_CTX */ - X509_STORE *ctx; - /* The following are set by the caller */ - /* The cert to check */ - X509 *cert; - /* chain of X509s - untrusted - passed in */ - STACK_OF(X509) *untrusted; - /* set of CRLs passed in */ - STACK_OF(X509_CRL) *crls; - X509_VERIFY_PARAM *param; - /* Other info for use with get_issuer() */ - void *other_ctx; - /* Callbacks for various operations */ - /* called to verify a certificate */ - int (*verify) (X509_STORE_CTX *ctx); - /* error callback */ - int (*verify_cb) (int ok, X509_STORE_CTX *ctx); - /* get issuers cert from ctx */ - int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x); - /* check issued */ - int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer); - /* Check revocation status of chain */ - int (*check_revocation) (X509_STORE_CTX *ctx); - /* retrieve CRL */ - int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); - /* Check CRL validity */ - int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl); - /* Check certificate against CRL */ - int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); - /* Check policy status of the chain */ - int (*check_policy) (X509_STORE_CTX *ctx); - STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm); - STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm); - int (*cleanup) (X509_STORE_CTX *ctx); - /* The following is built up */ - /* if 0, rebuild chain */ - int valid; - /* number of untrusted certs */ - int num_untrusted; - /* chain of X509s - built up and trusted */ - STACK_OF(X509) *chain; - /* Valid policy tree */ - X509_POLICY_TREE *tree; - /* Require explicit policy value */ - int explicit_policy; - /* When something goes wrong, this is why */ - int error_depth; - int error; - X509 *current_cert; - /* cert currently being tested as valid issuer */ - X509 *current_issuer; - /* current CRL */ - X509_CRL *current_crl; - /* score of current CRL */ - int current_crl_score; - /* Reason mask */ - unsigned int current_reasons; - /* For CRL path validation: parent context */ - X509_STORE_CTX *parent; - CRYPTO_EX_DATA ex_data; - SSL_DANE *dane; - /* signed via bare TA public key, rather than CA certificate */ - int bare_ta_signed; -}; - -/* PKCS#8 private key info structure */ - -struct pkcs8_priv_key_info_st { - ASN1_INTEGER *version; - X509_ALGOR *pkeyalg; - ASN1_OCTET_STRING *pkey; - STACK_OF(X509_ATTRIBUTE) *attributes; -}; - -struct X509_sig_st { - X509_ALGOR *algor; - ASN1_OCTET_STRING *digest; -}; - -struct x509_object_st { - /* one of the above types */ - X509_LOOKUP_TYPE type; - union { - char *ptr; - X509 *x509; - X509_CRL *crl; - EVP_PKEY *pkey; - } data; -}; - -int a2i_ipadd(unsigned char *ipout, const char *ipasc); -int x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm); - -void x509_init_sig_info(X509 *x); + +/* Internal X509 structures and functions: not for application use */ + +/* Note: unless otherwise stated a field pointer is mandatory and should + * never be set to NULL: the ASN.1 code and accessors rely on mandatory + * fields never being NULL. + */ + +/* + * name entry structure, equivalent to AttributeTypeAndValue defined + * in RFC5280 et al. + */ +struct X509_name_entry_st { + ASN1_OBJECT *object; /* AttributeType */ + ASN1_STRING *value; /* AttributeValue */ + int set; /* index of RDNSequence for this entry */ + int size; /* temp variable */ +}; + +/* Name from RFC 5280. */ +struct X509_name_st { + STACK_OF(X509_NAME_ENTRY) *entries; /* DN components */ + int modified; /* true if 'bytes' needs to be built */ + BUF_MEM *bytes; /* cached encoding: cannot be NULL */ + /* canonical encoding used for rapid Name comparison */ + unsigned char *canon_enc; + int canon_enclen; +} /* X509_NAME */ ; + +/* Signature info structure */ + +struct x509_sig_info_st { + /* NID of message digest */ + int mdnid; + /* NID of public key algorithm */ + int pknid; + /* Security bits */ + int secbits; + /* Various flags */ + uint32_t flags; +}; + +/* PKCS#10 certificate request */ + +struct X509_req_info_st { + ASN1_ENCODING enc; /* cached encoding of signed part */ + ASN1_INTEGER *version; /* version, defaults to v1(0) so can be NULL */ + X509_NAME *subject; /* certificate request DN */ + X509_PUBKEY *pubkey; /* public key of request */ + /* + * Zero or more attributes. + * NB: although attributes is a mandatory field some broken + * encodings omit it so this may be NULL in that case. + */ + STACK_OF(X509_ATTRIBUTE) *attributes; +}; + +struct X509_req_st { + X509_REQ_INFO req_info; /* signed certificate request data */ + X509_ALGOR sig_alg; /* signature algorithm */ + ASN1_BIT_STRING *signature; /* signature */ + CRYPTO_REF_COUNT references; + CRYPTO_RWLOCK *lock; +}; + +struct X509_crl_info_st { + ASN1_INTEGER *version; /* version: defaults to v1(0) so may be NULL */ + X509_ALGOR sig_alg; /* signature algorithm */ + X509_NAME *issuer; /* CRL issuer name */ + ASN1_TIME *lastUpdate; /* lastUpdate field */ + ASN1_TIME *nextUpdate; /* nextUpdate field: optional */ + STACK_OF(X509_REVOKED) *revoked; /* revoked entries: optional */ + STACK_OF(X509_EXTENSION) *extensions; /* extensions: optional */ + ASN1_ENCODING enc; /* encoding of signed portion of CRL */ +}; + +struct X509_crl_st { + X509_CRL_INFO crl; /* signed CRL data */ + X509_ALGOR sig_alg; /* CRL signature algorithm */ + ASN1_BIT_STRING signature; /* CRL signature */ + CRYPTO_REF_COUNT references; + int flags; + /* + * Cached copies of decoded extension values, since extensions + * are optional any of these can be NULL. + */ + AUTHORITY_KEYID *akid; + ISSUING_DIST_POINT *idp; + /* Convenient breakdown of IDP */ + int idp_flags; + int idp_reasons; + /* CRL and base CRL numbers for delta processing */ + ASN1_INTEGER *crl_number; + ASN1_INTEGER *base_crl_number; + STACK_OF(GENERAL_NAMES) *issuers; + /* hash of CRL */ + unsigned char sha1_hash[SHA_DIGEST_LENGTH]; + /* alternative method to handle this CRL */ + const X509_CRL_METHOD *meth; + void *meth_data; + CRYPTO_RWLOCK *lock; +}; + +struct x509_revoked_st { + ASN1_INTEGER serialNumber; /* revoked entry serial number */ + ASN1_TIME *revocationDate; /* revocation date */ + STACK_OF(X509_EXTENSION) *extensions; /* CRL entry extensions: optional */ + /* decoded value of CRLissuer extension: set if indirect CRL */ + STACK_OF(GENERAL_NAME) *issuer; + /* revocation reason: set to CRL_REASON_NONE if reason extension absent */ + int reason; + /* + * CRL entries are reordered for faster lookup of serial numbers. This + * field contains the original load sequence for this entry. + */ + int sequence; +}; + +/* + * This stuff is certificate "auxiliary info": it contains details which are + * useful in certificate stores and databases. When used this is tagged onto + * the end of the certificate itself. OpenSSL specific structure not defined + * in any RFC. + */ + +struct x509_cert_aux_st { + STACK_OF(ASN1_OBJECT) *trust; /* trusted uses */ + STACK_OF(ASN1_OBJECT) *reject; /* rejected uses */ + ASN1_UTF8STRING *alias; /* "friendly name" */ + ASN1_OCTET_STRING *keyid; /* key id of private key */ + STACK_OF(X509_ALGOR) *other; /* other unspecified info */ +}; + +struct x509_cinf_st { + ASN1_INTEGER *version; /* [ 0 ] default of v1 */ + ASN1_INTEGER serialNumber; + X509_ALGOR signature; + X509_NAME *issuer; + X509_VAL validity; + X509_NAME *subject; + X509_PUBKEY *key; + ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */ + ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */ + STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */ + ASN1_ENCODING enc; +}; + +struct x509_st { + X509_CINF cert_info; + X509_ALGOR sig_alg; + ASN1_BIT_STRING signature; + X509_SIG_INFO siginf; + CRYPTO_REF_COUNT references; + CRYPTO_EX_DATA ex_data; + /* These contain copies of various extension values */ + long ex_pathlen; + long ex_pcpathlen; + uint32_t ex_flags; + uint32_t ex_kusage; + uint32_t ex_xkusage; + uint32_t ex_nscert; + ASN1_OCTET_STRING *skid; + AUTHORITY_KEYID *akid; + X509_POLICY_CACHE *policy_cache; + STACK_OF(DIST_POINT) *crldp; + STACK_OF(GENERAL_NAME) *altname; + NAME_CONSTRAINTS *nc; +#ifndef OPENSSL_NO_RFC3779 + STACK_OF(IPAddressFamily) *rfc3779_addr; + struct ASIdentifiers_st *rfc3779_asid; +# endif + unsigned char sha1_hash[SHA_DIGEST_LENGTH]; + X509_CERT_AUX *aux; + CRYPTO_RWLOCK *lock; + volatile int ex_cached; +} /* X509 */ ; + +/* + * This is a used when verifying cert chains. Since the gathering of the + * cert chain can take some time (and have to be 'retried', this needs to be + * kept and passed around. + */ +struct x509_store_ctx_st { /* X509_STORE_CTX */ + X509_STORE *ctx; + /* The following are set by the caller */ + /* The cert to check */ + X509 *cert; + /* chain of X509s - untrusted - passed in */ + STACK_OF(X509) *untrusted; + /* set of CRLs passed in */ + STACK_OF(X509_CRL) *crls; + X509_VERIFY_PARAM *param; + /* Other info for use with get_issuer() */ + void *other_ctx; + /* Callbacks for various operations */ + /* called to verify a certificate */ + int (*verify) (X509_STORE_CTX *ctx); + /* error callback */ + int (*verify_cb) (int ok, X509_STORE_CTX *ctx); + /* get issuers cert from ctx */ + int (*get_issuer) (X509 **issuer, X509_STORE_CTX *ctx, X509 *x); + /* check issued */ + int (*check_issued) (X509_STORE_CTX *ctx, X509 *x, X509 *issuer); + /* Check revocation status of chain */ + int (*check_revocation) (X509_STORE_CTX *ctx); + /* retrieve CRL */ + int (*get_crl) (X509_STORE_CTX *ctx, X509_CRL **crl, X509 *x); + /* Check CRL validity */ + int (*check_crl) (X509_STORE_CTX *ctx, X509_CRL *crl); + /* Check certificate against CRL */ + int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x); + /* Check policy status of the chain */ + int (*check_policy) (X509_STORE_CTX *ctx); + STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm); + STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm); + int (*cleanup) (X509_STORE_CTX *ctx); + /* The following is built up */ + /* if 0, rebuild chain */ + int valid; + /* number of untrusted certs */ + int num_untrusted; + /* chain of X509s - built up and trusted */ + STACK_OF(X509) *chain; + /* Valid policy tree */ + X509_POLICY_TREE *tree; + /* Require explicit policy value */ + int explicit_policy; + /* When something goes wrong, this is why */ + int error_depth; + int error; + X509 *current_cert; + /* cert currently being tested as valid issuer */ + X509 *current_issuer; + /* current CRL */ + X509_CRL *current_crl; + /* score of current CRL */ + int current_crl_score; + /* Reason mask */ + unsigned int current_reasons; + /* For CRL path validation: parent context */ + X509_STORE_CTX *parent; + CRYPTO_EX_DATA ex_data; + SSL_DANE *dane; + /* signed via bare TA public key, rather than CA certificate */ + int bare_ta_signed; +}; + +/* PKCS#8 private key info structure */ + +struct pkcs8_priv_key_info_st { + ASN1_INTEGER *version; + X509_ALGOR *pkeyalg; + ASN1_OCTET_STRING *pkey; + STACK_OF(X509_ATTRIBUTE) *attributes; +}; + +struct X509_sig_st { + X509_ALGOR *algor; + ASN1_OCTET_STRING *digest; +}; + +struct x509_object_st { + /* one of the above types */ + X509_LOOKUP_TYPE type; + union { + char *ptr; + X509 *x509; + X509_CRL *crl; + EVP_PKEY *pkey; + } data; +}; + +int a2i_ipadd(unsigned char *ipout, const char *ipasc); +int x509_set1_time(ASN1_TIME **ptm, const ASN1_TIME *tm); + +void x509_init_sig_info(X509 *x); int x509v3_add_len_value_uchar(const char *name, const unsigned char *value, size_t vallen, STACK_OF(CONF_VALUE) **extlist); diff --git a/contrib/libs/openssl/include/internal/conf.h b/contrib/libs/openssl/include/internal/conf.h index 0f14e14632..163fea8de4 100644 --- a/contrib/libs/openssl/include/internal/conf.h +++ b/contrib/libs/openssl/include/internal/conf.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_CONF_H -# define OSSL_INTERNAL_CONF_H +#ifndef OSSL_INTERNAL_CONF_H +# define OSSL_INTERNAL_CONF_H #include <openssl/conf.h> diff --git a/contrib/libs/openssl/include/internal/constant_time.h b/contrib/libs/openssl/include/internal/constant_time.h index fd52ac5d26..6600a1d72a 100644 --- a/contrib/libs/openssl/include/internal/constant_time.h +++ b/contrib/libs/openssl/include/internal/constant_time.h @@ -1,387 +1,387 @@ -/* - * Copyright 2014-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_INTERNAL_CONSTANT_TIME_H -# define OSSL_INTERNAL_CONSTANT_TIME_H - -# include <stdlib.h> -# include <string.h> -# include <openssl/e_os2.h> /* For 'ossl_inline' */ - -/*- - * The boolean methods return a bitmask of all ones (0xff...f) for true - * and 0 for false. This is useful for choosing a value based on the result - * of a conditional in constant time. For example, - * if (a < b) { - * c = a; - * } else { - * c = b; - * } - * can be written as - * unsigned int lt = constant_time_lt(a, b); - * c = constant_time_select(lt, a, b); - */ - -/* Returns the given value with the MSB copied to all the other bits. */ -static ossl_inline unsigned int constant_time_msb(unsigned int a); -/* Convenience method for uint32_t. */ -static ossl_inline uint32_t constant_time_msb_32(uint32_t a); -/* Convenience method for uint64_t. */ -static ossl_inline uint64_t constant_time_msb_64(uint64_t a); - -/* Returns 0xff..f if a < b and 0 otherwise. */ -static ossl_inline unsigned int constant_time_lt(unsigned int a, - unsigned int b); -/* Convenience method for getting an 8-bit mask. */ -static ossl_inline unsigned char constant_time_lt_8(unsigned int a, - unsigned int b); -/* Convenience method for uint64_t. */ -static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b); - -/* Returns 0xff..f if a >= b and 0 otherwise. */ -static ossl_inline unsigned int constant_time_ge(unsigned int a, - unsigned int b); -/* Convenience method for getting an 8-bit mask. */ -static ossl_inline unsigned char constant_time_ge_8(unsigned int a, - unsigned int b); - -/* Returns 0xff..f if a == 0 and 0 otherwise. */ -static ossl_inline unsigned int constant_time_is_zero(unsigned int a); -/* Convenience method for getting an 8-bit mask. */ -static ossl_inline unsigned char constant_time_is_zero_8(unsigned int a); -/* Convenience method for getting a 32-bit mask. */ -static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a); - -/* Returns 0xff..f if a == b and 0 otherwise. */ -static ossl_inline unsigned int constant_time_eq(unsigned int a, - unsigned int b); -/* Convenience method for getting an 8-bit mask. */ -static ossl_inline unsigned char constant_time_eq_8(unsigned int a, - unsigned int b); -/* Signed integers. */ -static ossl_inline unsigned int constant_time_eq_int(int a, int b); -/* Convenience method for getting an 8-bit mask. */ -static ossl_inline unsigned char constant_time_eq_int_8(int a, int b); - -/*- - * Returns (mask & a) | (~mask & b). - * - * When |mask| is all 1s or all 0s (as returned by the methods above), - * the select methods return either |a| (if |mask| is nonzero) or |b| - * (if |mask| is zero). - */ -static ossl_inline unsigned int constant_time_select(unsigned int mask, - unsigned int a, - unsigned int b); -/* Convenience method for unsigned chars. */ -static ossl_inline unsigned char constant_time_select_8(unsigned char mask, - unsigned char a, - unsigned char b); - -/* Convenience method for uint32_t. */ -static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a, - uint32_t b); - -/* Convenience method for uint64_t. */ -static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, - uint64_t b); -/* Convenience method for signed integers. */ -static ossl_inline int constant_time_select_int(unsigned int mask, int a, - int b); - - -static ossl_inline unsigned int constant_time_msb(unsigned int a) -{ - return 0 - (a >> (sizeof(a) * 8 - 1)); -} - - -static ossl_inline uint32_t constant_time_msb_32(uint32_t a) -{ - return 0 - (a >> 31); -} - -static ossl_inline uint64_t constant_time_msb_64(uint64_t a) -{ - return 0 - (a >> 63); -} - -static ossl_inline size_t constant_time_msb_s(size_t a) -{ - return 0 - (a >> (sizeof(a) * 8 - 1)); -} - -static ossl_inline unsigned int constant_time_lt(unsigned int a, - unsigned int b) -{ - return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b))); -} - -static ossl_inline size_t constant_time_lt_s(size_t a, size_t b) -{ - return constant_time_msb_s(a ^ ((a ^ b) | ((a - b) ^ b))); -} - -static ossl_inline unsigned char constant_time_lt_8(unsigned int a, - unsigned int b) -{ - return (unsigned char)constant_time_lt(a, b); -} - -static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b) -{ - return constant_time_msb_64(a ^ ((a ^ b) | ((a - b) ^ b))); -} - -static ossl_inline unsigned int constant_time_ge(unsigned int a, - unsigned int b) -{ - return ~constant_time_lt(a, b); -} - -static ossl_inline size_t constant_time_ge_s(size_t a, size_t b) -{ - return ~constant_time_lt_s(a, b); -} - -static ossl_inline unsigned char constant_time_ge_8(unsigned int a, - unsigned int b) -{ - return (unsigned char)constant_time_ge(a, b); -} - -static ossl_inline unsigned char constant_time_ge_8_s(size_t a, size_t b) -{ - return (unsigned char)constant_time_ge_s(a, b); -} - -static ossl_inline unsigned int constant_time_is_zero(unsigned int a) -{ - return constant_time_msb(~a & (a - 1)); -} - -static ossl_inline size_t constant_time_is_zero_s(size_t a) -{ - return constant_time_msb_s(~a & (a - 1)); -} - -static ossl_inline unsigned char constant_time_is_zero_8(unsigned int a) -{ - return (unsigned char)constant_time_is_zero(a); -} - -static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a) -{ - return constant_time_msb_32(~a & (a - 1)); -} - -static ossl_inline unsigned int constant_time_eq(unsigned int a, - unsigned int b) -{ - return constant_time_is_zero(a ^ b); -} - -static ossl_inline size_t constant_time_eq_s(size_t a, size_t b) -{ - return constant_time_is_zero_s(a ^ b); -} - -static ossl_inline unsigned char constant_time_eq_8(unsigned int a, - unsigned int b) -{ - return (unsigned char)constant_time_eq(a, b); -} - -static ossl_inline unsigned char constant_time_eq_8_s(size_t a, size_t b) -{ - return (unsigned char)constant_time_eq_s(a, b); -} - -static ossl_inline unsigned int constant_time_eq_int(int a, int b) -{ - return constant_time_eq((unsigned)(a), (unsigned)(b)); -} - -static ossl_inline unsigned char constant_time_eq_int_8(int a, int b) -{ - return constant_time_eq_8((unsigned)(a), (unsigned)(b)); -} - -/* - * Returns the value unmodified, but avoids optimizations. - * The barriers prevent the compiler from narrowing down the - * possible value range of the mask and ~mask in the select - * statements, which avoids the recognition of the select - * and turning it into a conditional load or branch. - */ -static ossl_inline unsigned int value_barrier(unsigned int a) -{ -#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) - unsigned int r; - __asm__("" : "=r"(r) : "0"(a)); -#else - volatile unsigned int r = a; -#endif - return r; -} - -/* Convenience method for uint32_t. */ -static ossl_inline uint32_t value_barrier_32(uint32_t a) -{ -#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) - uint32_t r; - __asm__("" : "=r"(r) : "0"(a)); -#else - volatile uint32_t r = a; -#endif - return r; -} - -/* Convenience method for uint64_t. */ -static ossl_inline uint64_t value_barrier_64(uint64_t a) -{ -#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) - uint64_t r; - __asm__("" : "=r"(r) : "0"(a)); -#else - volatile uint64_t r = a; -#endif - return r; -} - -/* Convenience method for size_t. */ -static ossl_inline size_t value_barrier_s(size_t a) -{ -#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) - size_t r; - __asm__("" : "=r"(r) : "0"(a)); -#else - volatile size_t r = a; -#endif - return r; -} - -static ossl_inline unsigned int constant_time_select(unsigned int mask, - unsigned int a, - unsigned int b) -{ - return (value_barrier(mask) & a) | (value_barrier(~mask) & b); -} - -static ossl_inline size_t constant_time_select_s(size_t mask, - size_t a, - size_t b) -{ - return (value_barrier_s(mask) & a) | (value_barrier_s(~mask) & b); -} - -static ossl_inline unsigned char constant_time_select_8(unsigned char mask, - unsigned char a, - unsigned char b) -{ - return (unsigned char)constant_time_select(mask, a, b); -} - -static ossl_inline int constant_time_select_int(unsigned int mask, int a, - int b) -{ - return (int)constant_time_select(mask, (unsigned)(a), (unsigned)(b)); -} - -static ossl_inline int constant_time_select_int_s(size_t mask, int a, int b) -{ - return (int)constant_time_select((unsigned)mask, (unsigned)(a), - (unsigned)(b)); -} - -static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a, - uint32_t b) -{ - return (value_barrier_32(mask) & a) | (value_barrier_32(~mask) & b); -} - -static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, - uint64_t b) -{ - return (value_barrier_64(mask) & a) | (value_barrier_64(~mask) & b); -} - -/* - * mask must be 0xFFFFFFFF or 0x00000000. - * - * if (mask) { - * uint32_t tmp = *a; - * - * *a = *b; - * *b = tmp; - * } - */ -static ossl_inline void constant_time_cond_swap_32(uint32_t mask, uint32_t *a, - uint32_t *b) -{ - uint32_t xor = *a ^ *b; - - xor &= mask; - *a ^= xor; - *b ^= xor; -} - -/* - * mask must be 0xFFFFFFFF or 0x00000000. - * - * if (mask) { - * uint64_t tmp = *a; - * - * *a = *b; - * *b = tmp; - * } - */ -static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a, - uint64_t *b) -{ - uint64_t xor = *a ^ *b; - - xor &= mask; - *a ^= xor; - *b ^= xor; -} - -/* - * table is a two dimensional array of bytes. Each row has rowsize elements. - * Copies row number idx into out. rowsize and numrows are not considered - * private. - */ -static ossl_inline void constant_time_lookup(void *out, - const void *table, - size_t rowsize, - size_t numrows, - size_t idx) -{ - size_t i, j; - const unsigned char *tablec = (const unsigned char *)table; - unsigned char *outc = (unsigned char *)out; - unsigned char mask; - - memset(out, 0, rowsize); - - /* Note idx may underflow - but that is well defined */ - for (i = 0; i < numrows; i++, idx--) { - mask = (unsigned char)constant_time_is_zero_s(idx); - for (j = 0; j < rowsize; j++) - *(outc + j) |= constant_time_select_8(mask, *(tablec++), 0); - } -} - -/* - * Expected usage pattern is to unconditionally set error and then - * wipe it if there was no actual error. |clear| is 1 or 0. - */ -void err_clear_last_constant_time(int clear); - -#endif /* OSSL_INTERNAL_CONSTANT_TIME_H */ +/* + * Copyright 2014-2019 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_INTERNAL_CONSTANT_TIME_H +# define OSSL_INTERNAL_CONSTANT_TIME_H + +# include <stdlib.h> +# include <string.h> +# include <openssl/e_os2.h> /* For 'ossl_inline' */ + +/*- + * The boolean methods return a bitmask of all ones (0xff...f) for true + * and 0 for false. This is useful for choosing a value based on the result + * of a conditional in constant time. For example, + * if (a < b) { + * c = a; + * } else { + * c = b; + * } + * can be written as + * unsigned int lt = constant_time_lt(a, b); + * c = constant_time_select(lt, a, b); + */ + +/* Returns the given value with the MSB copied to all the other bits. */ +static ossl_inline unsigned int constant_time_msb(unsigned int a); +/* Convenience method for uint32_t. */ +static ossl_inline uint32_t constant_time_msb_32(uint32_t a); +/* Convenience method for uint64_t. */ +static ossl_inline uint64_t constant_time_msb_64(uint64_t a); + +/* Returns 0xff..f if a < b and 0 otherwise. */ +static ossl_inline unsigned int constant_time_lt(unsigned int a, + unsigned int b); +/* Convenience method for getting an 8-bit mask. */ +static ossl_inline unsigned char constant_time_lt_8(unsigned int a, + unsigned int b); +/* Convenience method for uint64_t. */ +static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b); + +/* Returns 0xff..f if a >= b and 0 otherwise. */ +static ossl_inline unsigned int constant_time_ge(unsigned int a, + unsigned int b); +/* Convenience method for getting an 8-bit mask. */ +static ossl_inline unsigned char constant_time_ge_8(unsigned int a, + unsigned int b); + +/* Returns 0xff..f if a == 0 and 0 otherwise. */ +static ossl_inline unsigned int constant_time_is_zero(unsigned int a); +/* Convenience method for getting an 8-bit mask. */ +static ossl_inline unsigned char constant_time_is_zero_8(unsigned int a); +/* Convenience method for getting a 32-bit mask. */ +static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a); + +/* Returns 0xff..f if a == b and 0 otherwise. */ +static ossl_inline unsigned int constant_time_eq(unsigned int a, + unsigned int b); +/* Convenience method for getting an 8-bit mask. */ +static ossl_inline unsigned char constant_time_eq_8(unsigned int a, + unsigned int b); +/* Signed integers. */ +static ossl_inline unsigned int constant_time_eq_int(int a, int b); +/* Convenience method for getting an 8-bit mask. */ +static ossl_inline unsigned char constant_time_eq_int_8(int a, int b); + +/*- + * Returns (mask & a) | (~mask & b). + * + * When |mask| is all 1s or all 0s (as returned by the methods above), + * the select methods return either |a| (if |mask| is nonzero) or |b| + * (if |mask| is zero). + */ +static ossl_inline unsigned int constant_time_select(unsigned int mask, + unsigned int a, + unsigned int b); +/* Convenience method for unsigned chars. */ +static ossl_inline unsigned char constant_time_select_8(unsigned char mask, + unsigned char a, + unsigned char b); + +/* Convenience method for uint32_t. */ +static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a, + uint32_t b); + +/* Convenience method for uint64_t. */ +static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, + uint64_t b); +/* Convenience method for signed integers. */ +static ossl_inline int constant_time_select_int(unsigned int mask, int a, + int b); + + +static ossl_inline unsigned int constant_time_msb(unsigned int a) +{ + return 0 - (a >> (sizeof(a) * 8 - 1)); +} + + +static ossl_inline uint32_t constant_time_msb_32(uint32_t a) +{ + return 0 - (a >> 31); +} + +static ossl_inline uint64_t constant_time_msb_64(uint64_t a) +{ + return 0 - (a >> 63); +} + +static ossl_inline size_t constant_time_msb_s(size_t a) +{ + return 0 - (a >> (sizeof(a) * 8 - 1)); +} + +static ossl_inline unsigned int constant_time_lt(unsigned int a, + unsigned int b) +{ + return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b))); +} + +static ossl_inline size_t constant_time_lt_s(size_t a, size_t b) +{ + return constant_time_msb_s(a ^ ((a ^ b) | ((a - b) ^ b))); +} + +static ossl_inline unsigned char constant_time_lt_8(unsigned int a, + unsigned int b) +{ + return (unsigned char)constant_time_lt(a, b); +} + +static ossl_inline uint64_t constant_time_lt_64(uint64_t a, uint64_t b) +{ + return constant_time_msb_64(a ^ ((a ^ b) | ((a - b) ^ b))); +} + +static ossl_inline unsigned int constant_time_ge(unsigned int a, + unsigned int b) +{ + return ~constant_time_lt(a, b); +} + +static ossl_inline size_t constant_time_ge_s(size_t a, size_t b) +{ + return ~constant_time_lt_s(a, b); +} + +static ossl_inline unsigned char constant_time_ge_8(unsigned int a, + unsigned int b) +{ + return (unsigned char)constant_time_ge(a, b); +} + +static ossl_inline unsigned char constant_time_ge_8_s(size_t a, size_t b) +{ + return (unsigned char)constant_time_ge_s(a, b); +} + +static ossl_inline unsigned int constant_time_is_zero(unsigned int a) +{ + return constant_time_msb(~a & (a - 1)); +} + +static ossl_inline size_t constant_time_is_zero_s(size_t a) +{ + return constant_time_msb_s(~a & (a - 1)); +} + +static ossl_inline unsigned char constant_time_is_zero_8(unsigned int a) +{ + return (unsigned char)constant_time_is_zero(a); +} + +static ossl_inline uint32_t constant_time_is_zero_32(uint32_t a) +{ + return constant_time_msb_32(~a & (a - 1)); +} + +static ossl_inline unsigned int constant_time_eq(unsigned int a, + unsigned int b) +{ + return constant_time_is_zero(a ^ b); +} + +static ossl_inline size_t constant_time_eq_s(size_t a, size_t b) +{ + return constant_time_is_zero_s(a ^ b); +} + +static ossl_inline unsigned char constant_time_eq_8(unsigned int a, + unsigned int b) +{ + return (unsigned char)constant_time_eq(a, b); +} + +static ossl_inline unsigned char constant_time_eq_8_s(size_t a, size_t b) +{ + return (unsigned char)constant_time_eq_s(a, b); +} + +static ossl_inline unsigned int constant_time_eq_int(int a, int b) +{ + return constant_time_eq((unsigned)(a), (unsigned)(b)); +} + +static ossl_inline unsigned char constant_time_eq_int_8(int a, int b) +{ + return constant_time_eq_8((unsigned)(a), (unsigned)(b)); +} + +/* + * Returns the value unmodified, but avoids optimizations. + * The barriers prevent the compiler from narrowing down the + * possible value range of the mask and ~mask in the select + * statements, which avoids the recognition of the select + * and turning it into a conditional load or branch. + */ +static ossl_inline unsigned int value_barrier(unsigned int a) +{ +#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) + unsigned int r; + __asm__("" : "=r"(r) : "0"(a)); +#else + volatile unsigned int r = a; +#endif + return r; +} + +/* Convenience method for uint32_t. */ +static ossl_inline uint32_t value_barrier_32(uint32_t a) +{ +#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) + uint32_t r; + __asm__("" : "=r"(r) : "0"(a)); +#else + volatile uint32_t r = a; +#endif + return r; +} + +/* Convenience method for uint64_t. */ +static ossl_inline uint64_t value_barrier_64(uint64_t a) +{ +#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) + uint64_t r; + __asm__("" : "=r"(r) : "0"(a)); +#else + volatile uint64_t r = a; +#endif + return r; +} + +/* Convenience method for size_t. */ +static ossl_inline size_t value_barrier_s(size_t a) +{ +#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) + size_t r; + __asm__("" : "=r"(r) : "0"(a)); +#else + volatile size_t r = a; +#endif + return r; +} + +static ossl_inline unsigned int constant_time_select(unsigned int mask, + unsigned int a, + unsigned int b) +{ + return (value_barrier(mask) & a) | (value_barrier(~mask) & b); +} + +static ossl_inline size_t constant_time_select_s(size_t mask, + size_t a, + size_t b) +{ + return (value_barrier_s(mask) & a) | (value_barrier_s(~mask) & b); +} + +static ossl_inline unsigned char constant_time_select_8(unsigned char mask, + unsigned char a, + unsigned char b) +{ + return (unsigned char)constant_time_select(mask, a, b); +} + +static ossl_inline int constant_time_select_int(unsigned int mask, int a, + int b) +{ + return (int)constant_time_select(mask, (unsigned)(a), (unsigned)(b)); +} + +static ossl_inline int constant_time_select_int_s(size_t mask, int a, int b) +{ + return (int)constant_time_select((unsigned)mask, (unsigned)(a), + (unsigned)(b)); +} + +static ossl_inline uint32_t constant_time_select_32(uint32_t mask, uint32_t a, + uint32_t b) +{ + return (value_barrier_32(mask) & a) | (value_barrier_32(~mask) & b); +} + +static ossl_inline uint64_t constant_time_select_64(uint64_t mask, uint64_t a, + uint64_t b) +{ + return (value_barrier_64(mask) & a) | (value_barrier_64(~mask) & b); +} + +/* + * mask must be 0xFFFFFFFF or 0x00000000. + * + * if (mask) { + * uint32_t tmp = *a; + * + * *a = *b; + * *b = tmp; + * } + */ +static ossl_inline void constant_time_cond_swap_32(uint32_t mask, uint32_t *a, + uint32_t *b) +{ + uint32_t xor = *a ^ *b; + + xor &= mask; + *a ^= xor; + *b ^= xor; +} + +/* + * mask must be 0xFFFFFFFF or 0x00000000. + * + * if (mask) { + * uint64_t tmp = *a; + * + * *a = *b; + * *b = tmp; + * } + */ +static ossl_inline void constant_time_cond_swap_64(uint64_t mask, uint64_t *a, + uint64_t *b) +{ + uint64_t xor = *a ^ *b; + + xor &= mask; + *a ^= xor; + *b ^= xor; +} + +/* + * table is a two dimensional array of bytes. Each row has rowsize elements. + * Copies row number idx into out. rowsize and numrows are not considered + * private. + */ +static ossl_inline void constant_time_lookup(void *out, + const void *table, + size_t rowsize, + size_t numrows, + size_t idx) +{ + size_t i, j; + const unsigned char *tablec = (const unsigned char *)table; + unsigned char *outc = (unsigned char *)out; + unsigned char mask; + + memset(out, 0, rowsize); + + /* Note idx may underflow - but that is well defined */ + for (i = 0; i < numrows; i++, idx--) { + mask = (unsigned char)constant_time_is_zero_s(idx); + for (j = 0; j < rowsize; j++) + *(outc + j) |= constant_time_select_8(mask, *(tablec++), 0); + } +} + +/* + * Expected usage pattern is to unconditionally set error and then + * wipe it if there was no actual error. |clear| is 1 or 0. + */ +void err_clear_last_constant_time(int clear); + +#endif /* OSSL_INTERNAL_CONSTANT_TIME_H */ diff --git a/contrib/libs/openssl/include/internal/cryptlib.h b/contrib/libs/openssl/include/internal/cryptlib.h index 31028e67da..6e7291ae41 100644 --- a/contrib/libs/openssl/include/internal/cryptlib.h +++ b/contrib/libs/openssl/include/internal/cryptlib.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_CRYPTLIB_H -# define OSSL_INTERNAL_CRYPTLIB_H +#ifndef OSSL_INTERNAL_CRYPTLIB_H +# define OSSL_INTERNAL_CRYPTLIB_H # include <stdlib.h> # include <string.h> diff --git a/contrib/libs/openssl/include/internal/dane.h b/contrib/libs/openssl/include/internal/dane.h index 09c7acdf1c..7a39bd7d7d 100644 --- a/contrib/libs/openssl/include/internal/dane.h +++ b/contrib/libs/openssl/include/internal/dane.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_DANE_H -#define OSSL_INTERNAL_DANE_H +#ifndef OSSL_INTERNAL_DANE_H +#define OSSL_INTERNAL_DANE_H #include <openssl/safestack.h> @@ -100,4 +100,4 @@ struct ssl_dane_st { #define DANETLS_HAS_DANE_TA(dane) ((dane)&&((dane)->umask & DANETLS_DANE_TA_MASK)) #define DANETLS_HAS_DANE_EE(dane) ((dane)&&((dane)->umask & DANETLS_DANE_EE_MASK)) -#endif /* OSSL_INTERNAL_DANE_H */ +#endif /* OSSL_INTERNAL_DANE_H */ diff --git a/contrib/libs/openssl/include/internal/dso.h b/contrib/libs/openssl/include/internal/dso.h index cf805a842f..c57c0c4075 100644 --- a/contrib/libs/openssl/include/internal/dso.h +++ b/contrib/libs/openssl/include/internal/dso.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_DSO_H -# define OSSL_INTERNAL_DSO_H +#ifndef OSSL_INTERNAL_DSO_H +# define OSSL_INTERNAL_DSO_H # include <openssl/crypto.h> # include "internal/dsoerr.h" diff --git a/contrib/libs/openssl/include/internal/dsoerr.h b/contrib/libs/openssl/include/internal/dsoerr.h index 2a71950dc9..94d642a22d 100644 --- a/contrib/libs/openssl/include/internal/dsoerr.h +++ b/contrib/libs/openssl/include/internal/dsoerr.h @@ -8,8 +8,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_DSOERR_H -# define OSSL_INTERNAL_DSOERR_H +#ifndef OSSL_INTERNAL_DSOERR_H +# define OSSL_INTERNAL_DSOERR_H # ifndef HEADER_SYMHACKS_H # include <openssl/symhacks.h> diff --git a/contrib/libs/openssl/include/internal/err.h b/contrib/libs/openssl/include/internal/err.h index 95b1db46a7..88dde70591 100644 --- a/contrib/libs/openssl/include/internal/err.h +++ b/contrib/libs/openssl/include/internal/err.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_ERR_H -# define OSSL_INTERNAL_ERR_H +#ifndef OSSL_INTERNAL_ERR_H +# define OSSL_INTERNAL_ERR_H void err_free_strings_int(void); diff --git a/contrib/libs/openssl/include/internal/nelem.h b/contrib/libs/openssl/include/internal/nelem.h index c3633680cb..699ef88ee5 100644 --- a/contrib/libs/openssl/include/internal/nelem.h +++ b/contrib/libs/openssl/include/internal/nelem.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_NELEM_H -# define OSSL_INTERNAL_NELEM_H +#ifndef OSSL_INTERNAL_NELEM_H +# define OSSL_INTERNAL_NELEM_H # define OSSL_NELEM(x) (sizeof(x)/sizeof((x)[0])) #endif diff --git a/contrib/libs/openssl/include/internal/numbers.h b/contrib/libs/openssl/include/internal/numbers.h index c9efcc8dba..f5ade5226e 100644 --- a/contrib/libs/openssl/include/internal/numbers.h +++ b/contrib/libs/openssl/include/internal/numbers.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_NUMBERS_H -# define OSSL_INTERNAL_NUMBERS_H +#ifndef OSSL_INTERNAL_NUMBERS_H +# define OSSL_INTERNAL_NUMBERS_H # include <limits.h> diff --git a/contrib/libs/openssl/include/internal/o_dir.h b/contrib/libs/openssl/include/internal/o_dir.h index bd10056053..dafc8dd2e7 100644 --- a/contrib/libs/openssl/include/internal/o_dir.h +++ b/contrib/libs/openssl/include/internal/o_dir.h @@ -36,8 +36,8 @@ * SUCH DAMAGE. */ -#ifndef OSSL_INTERNAL_O_DIR_H -# define OSSL_INTERNAL_O_DIR_H +#ifndef OSSL_INTERNAL_O_DIR_H +# define OSSL_INTERNAL_O_DIR_H typedef struct OPENSSL_dir_context_st OPENSSL_DIR_CTX; diff --git a/contrib/libs/openssl/include/internal/o_str.h b/contrib/libs/openssl/include/internal/o_str.h index d5f1479a06..15c12e820d 100644 --- a/contrib/libs/openssl/include/internal/o_str.h +++ b/contrib/libs/openssl/include/internal/o_str.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_O_STR_H -# define OSSL_INTERNAL_O_STR_H +#ifndef OSSL_INTERNAL_O_STR_H +# define OSSL_INTERNAL_O_STR_H # include <stddef.h> /* to get size_t */ diff --git a/contrib/libs/openssl/include/internal/refcount.h b/contrib/libs/openssl/include/internal/refcount.h index 81f9c7e2a2..8fb536eadc 100644 --- a/contrib/libs/openssl/include/internal/refcount.h +++ b/contrib/libs/openssl/include/internal/refcount.h @@ -6,8 +6,8 @@ * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_REFCOUNT_H -# define OSSL_INTERNAL_REFCOUNT_H +#ifndef OSSL_INTERNAL_REFCOUNT_H +# define OSSL_INTERNAL_REFCOUNT_H /* Used to checking reference counts, most while doing perl5 stuff :-) */ # if defined(OPENSSL_NO_STDIO) diff --git a/contrib/libs/openssl/include/internal/sockets.h b/contrib/libs/openssl/include/internal/sockets.h index 704a0ffece..39186efef2 100644 --- a/contrib/libs/openssl/include/internal/sockets.h +++ b/contrib/libs/openssl/include/internal/sockets.h @@ -8,8 +8,8 @@ */ -#ifndef OSSL_INTERNAL_SOCKETS_H -# define OSSL_INTERNAL_SOCKETS_H +#ifndef OSSL_INTERNAL_SOCKETS_H +# define OSSL_INTERNAL_SOCKETS_H # if defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) # define NO_SYS_PARAM_H diff --git a/contrib/libs/openssl/include/internal/sslconf.h b/contrib/libs/openssl/include/internal/sslconf.h index ab55af16a8..92c8941d02 100644 --- a/contrib/libs/openssl/include/internal/sslconf.h +++ b/contrib/libs/openssl/include/internal/sslconf.h @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#ifndef OSSL_INTERNAL_SSLCONF_H -# define OSSL_INTERNAL_SSLCONF_H +#ifndef OSSL_INTERNAL_SSLCONF_H +# define OSSL_INTERNAL_SSLCONF_H typedef struct ssl_conf_cmd_st SSL_CONF_CMD; diff --git a/contrib/libs/openssl/include/openssl/bio.h b/contrib/libs/openssl/include/openssl/bio.h index 2968671f19..ae559a5105 100644 --- a/contrib/libs/openssl/include/openssl/bio.h +++ b/contrib/libs/openssl/include/openssl/bio.h @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -169,7 +169,7 @@ extern "C" { */ # define BIO_FLAGS_MEM_RDONLY 0x200 # define BIO_FLAGS_NONCLEAR_RST 0x400 -# define BIO_FLAGS_IN_EOF 0x800 +# define BIO_FLAGS_IN_EOF 0x800 typedef union bio_addr_st BIO_ADDR; typedef struct bio_addrinfo_st BIO_ADDRINFO; diff --git a/contrib/libs/openssl/include/openssl/dsa.h b/contrib/libs/openssl/include/openssl/dsa.h index 83a65214a0..6d8a18a4ad 100644 --- a/contrib/libs/openssl/include/openssl/dsa.h +++ b/contrib/libs/openssl/include/openssl/dsa.h @@ -162,12 +162,12 @@ DH *DSA_dup_DH(const DSA *r); # define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL) -# define EVP_PKEY_CTX_set_dsa_paramgen_q_bits(ctx, qbits) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, qbits, NULL) -# define EVP_PKEY_CTX_set_dsa_paramgen_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)(md)) +# define EVP_PKEY_CTX_set_dsa_paramgen_q_bits(ctx, qbits) \ + EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ + EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, qbits, NULL) +# define EVP_PKEY_CTX_set_dsa_paramgen_md(ctx, md) \ + EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ + EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)(md)) # define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1) # define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2) diff --git a/contrib/libs/openssl/include/openssl/dtls1.h b/contrib/libs/openssl/include/openssl/dtls1.h index ade0f24893..d55ca9c332 100644 --- a/contrib/libs/openssl/include/openssl/dtls1.h +++ b/contrib/libs/openssl/include/openssl/dtls1.h @@ -43,7 +43,7 @@ extern "C" { # define DTLS1_AL_HEADER_LENGTH 2 -/* Timeout multipliers */ +/* Timeout multipliers */ # define DTLS1_TMO_READ_COUNT 2 # define DTLS1_TMO_WRITE_COUNT 2 diff --git a/contrib/libs/openssl/include/openssl/evp.h b/contrib/libs/openssl/include/openssl/evp.h index 5b928eb110..a411f3f2f9 100644 --- a/contrib/libs/openssl/include/openssl/evp.h +++ b/contrib/libs/openssl/include/openssl/evp.h @@ -180,7 +180,7 @@ int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd, * if the following flag is set. */ # define EVP_MD_CTX_FLAG_FINALISE 0x0200 -/* NOTE: 0x0400 is reserved for internal usage */ +/* NOTE: 0x0400 is reserved for internal usage */ 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); @@ -1512,20 +1512,20 @@ void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, const char *type, const char *value)); -void EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth, - int (*digestsign) (EVP_MD_CTX *ctx, - unsigned char *sig, - size_t *siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_set_digestverify(EVP_PKEY_METHOD *pmeth, - int (*digestverify) (EVP_MD_CTX *ctx, - const unsigned char *sig, - size_t siglen, - const unsigned char *tbs, - size_t tbslen)); - +void EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth, + int (*digestsign) (EVP_MD_CTX *ctx, + unsigned char *sig, + size_t *siglen, + const unsigned char *tbs, + size_t tbslen)); + +void EVP_PKEY_meth_set_digestverify(EVP_PKEY_METHOD *pmeth, + int (*digestverify) (EVP_MD_CTX *ctx, + const unsigned char *sig, + size_t siglen, + const unsigned char *tbs, + size_t tbslen)); + void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth, int (*check) (EVP_PKEY *pkey)); @@ -1631,20 +1631,20 @@ void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth, const char *type, const char *value)); -void EVP_PKEY_meth_get_digestsign(EVP_PKEY_METHOD *pmeth, - int (**digestsign) (EVP_MD_CTX *ctx, - unsigned char *sig, - size_t *siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_get_digestverify(EVP_PKEY_METHOD *pmeth, - int (**digestverify) (EVP_MD_CTX *ctx, - const unsigned char *sig, - size_t siglen, - const unsigned char *tbs, - size_t tbslen)); - +void EVP_PKEY_meth_get_digestsign(EVP_PKEY_METHOD *pmeth, + int (**digestsign) (EVP_MD_CTX *ctx, + unsigned char *sig, + size_t *siglen, + const unsigned char *tbs, + size_t tbslen)); + +void EVP_PKEY_meth_get_digestverify(EVP_PKEY_METHOD *pmeth, + int (**digestverify) (EVP_MD_CTX *ctx, + const unsigned char *sig, + size_t siglen, + const unsigned char *tbs, + size_t tbslen)); + void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth, int (**pcheck) (EVP_PKEY *pkey)); diff --git a/contrib/libs/openssl/include/openssl/evperr.h b/contrib/libs/openssl/include/openssl/evperr.h index d15030619a..b4ea90ae9d 100644 --- a/contrib/libs/openssl/include/openssl/evperr.h +++ b/contrib/libs/openssl/include/openssl/evperr.h @@ -158,7 +158,7 @@ int ERR_load_EVP_strings(void); # define EVP_R_INPUT_NOT_INITIALIZED 111 # define EVP_R_INVALID_DIGEST 152 # define EVP_R_INVALID_FIPS_MODE 168 -# define EVP_R_INVALID_IV_LENGTH 194 +# define EVP_R_INVALID_IV_LENGTH 194 # define EVP_R_INVALID_KEY 163 # define EVP_R_INVALID_KEY_LENGTH 130 # define EVP_R_INVALID_OPERATION 148 diff --git a/contrib/libs/openssl/include/openssl/lhash.h b/contrib/libs/openssl/include/openssl/lhash.h index 42fc83859a..2e42d727d4 100644 --- a/contrib/libs/openssl/include/openssl/lhash.h +++ b/contrib/libs/openssl/include/openssl/lhash.h @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -120,8 +120,8 @@ void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out); # define DEFINE_LHASH_OF(type) \ LHASH_OF(type) { union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; }; \ - static ossl_unused ossl_inline LHASH_OF(type) *lh_##type##_new(unsigned long (*hfn)(const type *), \ - int (*cfn)(const type *, const type *)) \ + static ossl_unused ossl_inline LHASH_OF(type) *lh_##type##_new(unsigned long (*hfn)(const type *), \ + int (*cfn)(const type *, const type *)) \ { \ return (LHASH_OF(type) *) \ OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn); \ diff --git a/contrib/libs/openssl/include/openssl/obj_mac.h b/contrib/libs/openssl/include/openssl/obj_mac.h index 35d0d39a7f..eb812ed18d 100644 --- a/contrib/libs/openssl/include/openssl/obj_mac.h +++ b/contrib/libs/openssl/include/openssl/obj_mac.h @@ -1290,12 +1290,12 @@ #define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L #define SN_ms_smartcard_login "msSmartcardLogin" -#define LN_ms_smartcard_login "Microsoft Smartcard Login" +#define LN_ms_smartcard_login "Microsoft Smartcard Login" #define NID_ms_smartcard_login 648 #define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L #define SN_ms_upn "msUPN" -#define LN_ms_upn "Microsoft User Principal Name" +#define LN_ms_upn "Microsoft User Principal Name" #define NID_ms_upn 649 #define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L diff --git a/contrib/libs/openssl/include/openssl/ocsp.h b/contrib/libs/openssl/include/openssl/ocsp.h index 7e5a768045..4d759a49de 100644 --- a/contrib/libs/openssl/include/openssl/ocsp.h +++ b/contrib/libs/openssl/include/openssl/ocsp.h @@ -123,7 +123,7 @@ typedef struct ocsp_service_locator_st OCSP_SERVICELOC; (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST, \ bp,(char **)(x),cb,NULL) -# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb) (OCSP_RESPONSE *)PEM_ASN1_read_bio(\ +# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb) (OCSP_RESPONSE *)PEM_ASN1_read_bio(\ (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE, \ bp,(char **)(x),cb,NULL) diff --git a/contrib/libs/openssl/include/openssl/opensslconf-linux.h b/contrib/libs/openssl/include/openssl/opensslconf-linux.h index 9840b4b4bc..e5e3a76622 100644 --- a/contrib/libs/openssl/include/openssl/opensslconf-linux.h +++ b/contrib/libs/openssl/include/openssl/opensslconf-linux.h @@ -85,9 +85,9 @@ extern "C" { # endif #endif -#ifndef OPENSSL_NO_TESTS -# define OPENSSL_NO_TESTS -#endif +#ifndef OPENSSL_NO_TESTS +# define OPENSSL_NO_TESTS +#endif #ifndef OPENSSL_NO_UBSAN # define OPENSSL_NO_UBSAN #endif diff --git a/contrib/libs/openssl/include/openssl/opensslconf.h b/contrib/libs/openssl/include/openssl/opensslconf.h index 99b5a7a5d9..ecc930a39f 100644 --- a/contrib/libs/openssl/include/openssl/opensslconf.h +++ b/contrib/libs/openssl/include/openssl/opensslconf.h @@ -11,13 +11,13 @@ #elif defined(__APPLE__) && defined(__x86_64__) # include "opensslconf-osx.h" #elif defined(__ANDROID__) && defined(__x86_64__) -# include "opensslconf-android-x86_64.h" +# include "opensslconf-android-x86_64.h" #elif defined(__ANDROID__) && defined(__i686__) -# include "opensslconf-android-i686.h" +# include "opensslconf-android-i686.h" #elif defined(__ANDROID__) && defined(__aarch64__) -# include "opensslconf-android-arm64.h" +# include "opensslconf-android-arm64.h" #elif defined(__ANDROID__) && defined(__arm__) -# include "opensslconf-android-arm.h" +# include "opensslconf-android-arm.h" #elif defined(__linux__) && defined(__aarch64__) # include "opensslconf-linux_aarch64.h" #elif defined(__linux__) && defined(__arm__) diff --git a/contrib/libs/openssl/include/openssl/ossl_typ.h b/contrib/libs/openssl/include/openssl/ossl_typ.h index 3d924206fb..e0edfaaf47 100644 --- a/contrib/libs/openssl/include/openssl/ossl_typ.h +++ b/contrib/libs/openssl/include/openssl/ossl_typ.h @@ -109,7 +109,7 @@ typedef struct dsa_method DSA_METHOD; typedef struct rsa_st RSA; typedef struct rsa_meth_st RSA_METHOD; -typedef struct rsa_pss_params_st RSA_PSS_PARAMS; +typedef struct rsa_pss_params_st RSA_PSS_PARAMS; typedef struct ec_key_st EC_KEY; typedef struct ec_key_method_st EC_KEY_METHOD; diff --git a/contrib/libs/openssl/include/openssl/randerr.h b/contrib/libs/openssl/include/openssl/randerr.h index 4a36fe9e33..79d57905e3 100644 --- a/contrib/libs/openssl/include/openssl/randerr.h +++ b/contrib/libs/openssl/include/openssl/randerr.h @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -21,7 +21,7 @@ int ERR_load_RAND_strings(void); /* * RAND function codes. */ -# define RAND_F_DATA_COLLECT_METHOD 127 +# define RAND_F_DATA_COLLECT_METHOD 127 # define RAND_F_DRBG_BYTES 101 # define RAND_F_DRBG_GET_ENTROPY 105 # define RAND_F_DRBG_SETUP 117 @@ -47,7 +47,7 @@ int ERR_load_RAND_strings(void); # define RAND_F_RAND_POOL_BYTES_NEEDED 115 # define RAND_F_RAND_POOL_GROW 125 # define RAND_F_RAND_POOL_NEW 116 -# define RAND_F_RAND_PSEUDO_BYTES 126 +# define RAND_F_RAND_PSEUDO_BYTES 126 # define RAND_F_RAND_WRITE_FILE 112 /* diff --git a/contrib/libs/openssl/include/openssl/rsa.h b/contrib/libs/openssl/include/openssl/rsa.h index 4ca62ffc50..5e76365c0d 100644 --- a/contrib/libs/openssl/include/openssl/rsa.h +++ b/contrib/libs/openssl/include/openssl/rsa.h @@ -224,7 +224,7 @@ const BIGNUM *RSA_get0_q(const RSA *d); const BIGNUM *RSA_get0_dmp1(const RSA *r); const BIGNUM *RSA_get0_dmq1(const RSA *r); const BIGNUM *RSA_get0_iqmp(const RSA *r); -const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r); +const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r); void RSA_clear_flags(RSA *r, int flags); int RSA_test_flags(const RSA *r, int flags); void RSA_set_flags(RSA *r, int flags); @@ -280,14 +280,14 @@ int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2); DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey) DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey) -struct rsa_pss_params_st { +struct rsa_pss_params_st { X509_ALGOR *hashAlgorithm; X509_ALGOR *maskGenAlgorithm; ASN1_INTEGER *saltLength; ASN1_INTEGER *trailerField; /* Decoded hash algorithm from maskGenAlgorithm */ X509_ALGOR *maskHash; -}; +}; DECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS) diff --git a/contrib/libs/openssl/include/openssl/sslerr.h b/contrib/libs/openssl/include/openssl/sslerr.h index b842c9bb90..701d61c6e9 100644 --- a/contrib/libs/openssl/include/openssl/sslerr.h +++ b/contrib/libs/openssl/include/openssl/sslerr.h @@ -89,7 +89,7 @@ int ERR_load_SSL_strings(void); # define SSL_F_OSSL_STATEM_SERVER_CONSTRUCT_MESSAGE 431 # define SSL_F_OSSL_STATEM_SERVER_POST_PROCESS_MESSAGE 601 # define SSL_F_OSSL_STATEM_SERVER_POST_WORK 602 -# define SSL_F_OSSL_STATEM_SERVER_PRE_WORK 640 +# define SSL_F_OSSL_STATEM_SERVER_PRE_WORK 640 # define SSL_F_OSSL_STATEM_SERVER_PROCESS_MESSAGE 603 # define SSL_F_OSSL_STATEM_SERVER_READ_TRANSITION 418 # define SSL_F_OSSL_STATEM_SERVER_WRITE_TRANSITION 604 diff --git a/contrib/libs/openssl/libcrypto.map b/contrib/libs/openssl/libcrypto.map index 6af700b435..2098f96ab7 100644 --- a/contrib/libs/openssl/libcrypto.map +++ b/contrib/libs/openssl/libcrypto.map @@ -1,4457 +1,4457 @@ -OPENSSL_1_1_0 { - global: - ACCESS_DESCRIPTION_free; - ACCESS_DESCRIPTION_new; - AES_bi_ige_encrypt; - AES_cbc_encrypt; - AES_cfb128_encrypt; - AES_cfb1_encrypt; - AES_cfb8_encrypt; - AES_decrypt; - AES_ecb_encrypt; - AES_encrypt; - AES_ige_encrypt; - AES_ofb128_encrypt; - AES_options; - AES_set_decrypt_key; - AES_set_encrypt_key; - AES_unwrap_key; - AES_wrap_key; - ASIdOrRange_free; - ASIdOrRange_new; - ASIdentifierChoice_free; - ASIdentifierChoice_new; - ASIdentifiers_free; - ASIdentifiers_new; - ASN1_BIT_STRING_check; - ASN1_BIT_STRING_free; - ASN1_BIT_STRING_get_bit; - ASN1_BIT_STRING_name_print; - ASN1_BIT_STRING_new; - ASN1_BIT_STRING_num_asc; - ASN1_BIT_STRING_set; - ASN1_BIT_STRING_set_asc; - ASN1_BIT_STRING_set_bit; - ASN1_BMPSTRING_free; - ASN1_BMPSTRING_new; - ASN1_ENUMERATED_free; - ASN1_ENUMERATED_get; - ASN1_ENUMERATED_get_int64; - ASN1_ENUMERATED_new; - ASN1_ENUMERATED_set; - ASN1_ENUMERATED_set_int64; - ASN1_ENUMERATED_to_BN; - ASN1_GENERALIZEDTIME_adj; - ASN1_GENERALIZEDTIME_check; - ASN1_GENERALIZEDTIME_free; - ASN1_GENERALIZEDTIME_new; - ASN1_GENERALIZEDTIME_print; - ASN1_GENERALIZEDTIME_set; - ASN1_GENERALIZEDTIME_set_string; - ASN1_GENERALSTRING_free; - ASN1_GENERALSTRING_new; - ASN1_IA5STRING_free; - ASN1_IA5STRING_new; - ASN1_INTEGER_cmp; - ASN1_INTEGER_dup; - ASN1_INTEGER_free; - ASN1_INTEGER_get; - ASN1_INTEGER_get_int64; - ASN1_INTEGER_get_uint64; - ASN1_INTEGER_new; - ASN1_INTEGER_set; - ASN1_INTEGER_set_int64; - ASN1_INTEGER_set_uint64; - ASN1_INTEGER_to_BN; - ASN1_NULL_free; - ASN1_NULL_new; - ASN1_OBJECT_create; - ASN1_OBJECT_free; - ASN1_OBJECT_new; - ASN1_OCTET_STRING_cmp; - ASN1_OCTET_STRING_dup; - ASN1_OCTET_STRING_free; - ASN1_OCTET_STRING_new; - ASN1_OCTET_STRING_set; - ASN1_PCTX_free; - ASN1_PCTX_get_cert_flags; - ASN1_PCTX_get_flags; - ASN1_PCTX_get_nm_flags; - ASN1_PCTX_get_oid_flags; - ASN1_PCTX_get_str_flags; - ASN1_PCTX_new; - ASN1_PCTX_set_cert_flags; - ASN1_PCTX_set_flags; - ASN1_PCTX_set_nm_flags; - ASN1_PCTX_set_oid_flags; - ASN1_PCTX_set_str_flags; - ASN1_PRINTABLESTRING_free; - ASN1_PRINTABLESTRING_new; - ASN1_PRINTABLE_free; - ASN1_PRINTABLE_new; - ASN1_PRINTABLE_type; - ASN1_SCTX_free; - ASN1_SCTX_get_app_data; - ASN1_SCTX_get_flags; - ASN1_SCTX_get_item; - ASN1_SCTX_get_template; - ASN1_SCTX_new; - ASN1_SCTX_set_app_data; - ASN1_STRING_TABLE_add; - ASN1_STRING_TABLE_cleanup; - ASN1_STRING_TABLE_get; - ASN1_STRING_clear_free; - ASN1_STRING_cmp; - ASN1_STRING_copy; - ASN1_STRING_data; - ASN1_STRING_dup; - ASN1_STRING_free; - ASN1_STRING_get0_data; - ASN1_STRING_get_default_mask; - ASN1_STRING_length; - ASN1_STRING_length_set; - ASN1_STRING_new; - ASN1_STRING_print; - ASN1_STRING_print_ex; - ASN1_STRING_print_ex_fp; - ASN1_STRING_set0; - ASN1_STRING_set; - ASN1_STRING_set_by_NID; - ASN1_STRING_set_default_mask; - ASN1_STRING_set_default_mask_asc; - ASN1_STRING_to_UTF8; - ASN1_STRING_type; - ASN1_STRING_type_new; - ASN1_T61STRING_free; - ASN1_T61STRING_new; - ASN1_TIME_adj; - ASN1_TIME_check; - ASN1_TIME_diff; - ASN1_TIME_free; - ASN1_TIME_new; - ASN1_TIME_print; - ASN1_TIME_set; - ASN1_TIME_set_string; - ASN1_TIME_to_generalizedtime; - ASN1_TYPE_cmp; - ASN1_TYPE_free; - ASN1_TYPE_get; - ASN1_TYPE_get_int_octetstring; - ASN1_TYPE_get_octetstring; - ASN1_TYPE_new; - ASN1_TYPE_pack_sequence; - ASN1_TYPE_set1; - ASN1_TYPE_set; - ASN1_TYPE_set_int_octetstring; - ASN1_TYPE_set_octetstring; - ASN1_TYPE_unpack_sequence; - ASN1_UNIVERSALSTRING_free; - ASN1_UNIVERSALSTRING_new; - ASN1_UNIVERSALSTRING_to_string; - ASN1_UTCTIME_adj; - ASN1_UTCTIME_check; - ASN1_UTCTIME_cmp_time_t; - ASN1_UTCTIME_free; - ASN1_UTCTIME_new; - ASN1_UTCTIME_print; - ASN1_UTCTIME_set; - ASN1_UTCTIME_set_string; - ASN1_UTF8STRING_free; - ASN1_UTF8STRING_new; - ASN1_VISIBLESTRING_free; - ASN1_VISIBLESTRING_new; - ASN1_add_oid_module; - ASN1_add_stable_module; - ASN1_bn_print; - ASN1_buf_print; - ASN1_check_infinite_end; - ASN1_const_check_infinite_end; - ASN1_d2i_bio; - ASN1_d2i_fp; - ASN1_digest; - ASN1_dup; - ASN1_generate_nconf; - ASN1_generate_v3; - ASN1_get_object; - ASN1_i2d_bio; - ASN1_i2d_fp; - ASN1_item_d2i; - ASN1_item_d2i_bio; - ASN1_item_d2i_fp; - ASN1_item_digest; - ASN1_item_dup; - ASN1_item_ex_d2i; - ASN1_item_ex_free; - ASN1_item_ex_i2d; - ASN1_item_ex_new; - ASN1_item_free; - ASN1_item_i2d; - ASN1_item_i2d_bio; - ASN1_item_i2d_fp; - ASN1_item_ndef_i2d; - ASN1_item_new; - ASN1_item_pack; - ASN1_item_print; - ASN1_item_sign; - ASN1_item_sign_ctx; - ASN1_item_unpack; - ASN1_item_verify; - ASN1_mbstring_copy; - ASN1_mbstring_ncopy; - ASN1_object_size; - ASN1_parse; - ASN1_parse_dump; - ASN1_put_eoc; - ASN1_put_object; - ASN1_sign; - ASN1_str2mask; - ASN1_tag2bit; - ASN1_tag2str; - ASN1_verify; - ASRange_free; - ASRange_new; - ASYNC_WAIT_CTX_clear_fd; - ASYNC_WAIT_CTX_free; - ASYNC_WAIT_CTX_get_all_fds; - ASYNC_WAIT_CTX_get_changed_fds; - ASYNC_WAIT_CTX_get_fd; - ASYNC_WAIT_CTX_new; - ASYNC_WAIT_CTX_set_wait_fd; - ASYNC_block_pause; - ASYNC_cleanup_thread; - ASYNC_get_current_job; - ASYNC_get_wait_ctx; - ASYNC_init_thread; - ASYNC_is_capable; - ASYNC_pause_job; - ASYNC_start_job; - ASYNC_unblock_pause; - AUTHORITY_INFO_ACCESS_free; - AUTHORITY_INFO_ACCESS_new; - AUTHORITY_KEYID_free; - AUTHORITY_KEYID_new; - BASIC_CONSTRAINTS_free; - BASIC_CONSTRAINTS_new; - BF_cbc_encrypt; - BF_cfb64_encrypt; - BF_decrypt; - BF_ecb_encrypt; - BF_encrypt; - BF_ofb64_encrypt; - BF_options; - BF_set_key; - BIO_ADDRINFO_address; - BIO_ADDRINFO_family; - BIO_ADDRINFO_free; - BIO_ADDRINFO_next; - BIO_ADDRINFO_protocol; - BIO_ADDRINFO_socktype; - BIO_ADDR_clear; - BIO_ADDR_family; - BIO_ADDR_free; - BIO_ADDR_hostname_string; - BIO_ADDR_new; - BIO_ADDR_path_string; - BIO_ADDR_rawaddress; - BIO_ADDR_rawmake; - BIO_ADDR_rawport; - BIO_ADDR_service_string; - BIO_accept; - BIO_accept_ex; - BIO_asn1_get_prefix; - BIO_asn1_get_suffix; - BIO_asn1_set_prefix; - BIO_asn1_set_suffix; - BIO_callback_ctrl; - BIO_clear_flags; - BIO_closesocket; - BIO_connect; - BIO_copy_next_retry; - BIO_ctrl; - BIO_ctrl_get_read_request; - BIO_ctrl_get_write_guarantee; - BIO_ctrl_pending; - BIO_ctrl_reset_read_request; - BIO_ctrl_wpending; - BIO_debug_callback; - BIO_dgram_non_fatal_error; - BIO_dump; - BIO_dump_cb; - BIO_dump_fp; - BIO_dump_indent; - BIO_dump_indent_cb; - BIO_dump_indent_fp; - BIO_dup_chain; - BIO_f_asn1; - BIO_f_base64; - BIO_f_buffer; - BIO_f_cipher; - BIO_f_linebuffer; - BIO_f_md; - BIO_f_nbio_test; - BIO_f_null; - BIO_f_reliable; - BIO_f_zlib; - BIO_fd_non_fatal_error; - BIO_fd_should_retry; - BIO_find_type; - BIO_free; - BIO_free_all; - BIO_get_accept_socket; - BIO_get_callback; - BIO_get_callback_arg; - BIO_get_data; - BIO_get_ex_data; - BIO_get_host_ip; - BIO_get_init; - BIO_get_new_index; - BIO_get_port; - BIO_get_retry_BIO; - BIO_get_retry_reason; - BIO_get_shutdown; - BIO_gethostbyname; - BIO_gets; - BIO_hex_string; - BIO_indent; - BIO_int_ctrl; - BIO_listen; - BIO_lookup; - BIO_meth_free; - BIO_meth_get_callback_ctrl; - BIO_meth_get_create; - BIO_meth_get_ctrl; - BIO_meth_get_destroy; - BIO_meth_get_gets; - BIO_meth_get_puts; - BIO_meth_get_read; - BIO_meth_get_write; - BIO_meth_new; - BIO_meth_set_callback_ctrl; - BIO_meth_set_create; - BIO_meth_set_ctrl; - BIO_meth_set_destroy; - BIO_meth_set_gets; - BIO_meth_set_puts; - BIO_meth_set_read; - BIO_meth_set_write; - BIO_method_name; - BIO_method_type; - BIO_new; - BIO_new_CMS; - BIO_new_NDEF; - BIO_new_PKCS7; - BIO_new_accept; - BIO_new_bio_pair; - BIO_new_connect; - BIO_new_dgram; - BIO_new_fd; - BIO_new_file; - BIO_new_fp; - BIO_new_mem_buf; - BIO_new_socket; - BIO_next; - BIO_nread0; - BIO_nread; - BIO_number_read; - BIO_number_written; - BIO_nwrite0; - BIO_nwrite; - BIO_parse_hostserv; - BIO_pop; - BIO_printf; - BIO_ptr_ctrl; - BIO_push; - BIO_puts; - BIO_read; - BIO_s_accept; - BIO_s_bio; - BIO_s_connect; - BIO_s_datagram; - BIO_s_fd; - BIO_s_file; - BIO_s_log; - BIO_s_mem; - BIO_s_null; - BIO_s_secmem; - BIO_s_socket; - BIO_set_callback; - BIO_set_callback_arg; - BIO_set_cipher; - BIO_set_data; - BIO_set_ex_data; - BIO_set_flags; - BIO_set_init; - BIO_set_next; - BIO_set_retry_reason; - BIO_set_shutdown; - BIO_set_tcp_ndelay; - BIO_snprintf; - BIO_sock_error; - BIO_sock_info; - BIO_sock_init; - BIO_sock_non_fatal_error; - BIO_sock_should_retry; - BIO_socket; - BIO_socket_ioctl; - BIO_socket_nbio; - BIO_test_flags; - BIO_up_ref; - BIO_vfree; - BIO_vprintf; - BIO_vsnprintf; - BIO_write; - BN_BLINDING_convert; - BN_BLINDING_convert_ex; - BN_BLINDING_create_param; - BN_BLINDING_free; - BN_BLINDING_get_flags; - BN_BLINDING_invert; - BN_BLINDING_invert_ex; - BN_BLINDING_is_current_thread; - BN_BLINDING_lock; - BN_BLINDING_new; - BN_BLINDING_set_current_thread; - BN_BLINDING_set_flags; - BN_BLINDING_unlock; - BN_BLINDING_update; - BN_CTX_end; - BN_CTX_free; - BN_CTX_get; - BN_CTX_new; - BN_CTX_secure_new; - BN_CTX_start; - BN_GENCB_call; - BN_GENCB_free; - BN_GENCB_get_arg; - BN_GENCB_new; - BN_GENCB_set; - BN_GENCB_set_old; - BN_GF2m_add; - BN_GF2m_arr2poly; - BN_GF2m_mod; - BN_GF2m_mod_arr; - BN_GF2m_mod_div; - BN_GF2m_mod_div_arr; - BN_GF2m_mod_exp; - BN_GF2m_mod_exp_arr; - BN_GF2m_mod_inv; - BN_GF2m_mod_inv_arr; - BN_GF2m_mod_mul; - BN_GF2m_mod_mul_arr; - BN_GF2m_mod_solve_quad; - BN_GF2m_mod_solve_quad_arr; - BN_GF2m_mod_sqr; - BN_GF2m_mod_sqr_arr; - BN_GF2m_mod_sqrt; - BN_GF2m_mod_sqrt_arr; - BN_GF2m_poly2arr; - BN_MONT_CTX_copy; - BN_MONT_CTX_free; - BN_MONT_CTX_new; - BN_MONT_CTX_set; - BN_MONT_CTX_set_locked; - BN_RECP_CTX_free; - BN_RECP_CTX_new; - BN_RECP_CTX_set; - BN_X931_derive_prime_ex; - BN_X931_generate_Xpq; - BN_X931_generate_prime_ex; - BN_abs_is_word; - BN_add; - BN_add_word; - BN_asc2bn; - BN_bin2bn; - BN_bn2bin; - BN_bn2binpad; - BN_bn2dec; - BN_bn2hex; - BN_bn2lebinpad; - BN_bn2mpi; - BN_bntest_rand; - BN_clear; - BN_clear_bit; - BN_clear_free; - BN_cmp; - BN_consttime_swap; - BN_copy; - BN_dec2bn; - BN_div; - BN_div_recp; - BN_div_word; - BN_dup; - BN_exp; - BN_free; - BN_from_montgomery; - BN_gcd; - BN_generate_dsa_nonce; - BN_generate_prime; - BN_generate_prime_ex; - BN_get0_nist_prime_192; - BN_get0_nist_prime_224; - BN_get0_nist_prime_256; - BN_get0_nist_prime_384; - BN_get0_nist_prime_521; - BN_get_flags; - BN_get_params; - BN_get_rfc2409_prime_1024; - BN_get_rfc2409_prime_768; - BN_get_rfc3526_prime_1536; - BN_get_rfc3526_prime_2048; - BN_get_rfc3526_prime_3072; - BN_get_rfc3526_prime_4096; - BN_get_rfc3526_prime_6144; - BN_get_rfc3526_prime_8192; - BN_get_word; - BN_hex2bn; - BN_is_bit_set; - BN_is_negative; - BN_is_odd; - BN_is_one; - BN_is_prime; - BN_is_prime_ex; - BN_is_prime_fasttest; - BN_is_prime_fasttest_ex; - BN_is_word; - BN_is_zero; - BN_kronecker; - BN_lebin2bn; - BN_lshift1; - BN_lshift; - BN_mask_bits; - BN_mod_add; - BN_mod_add_quick; - BN_mod_exp2_mont; - BN_mod_exp; - BN_mod_exp_mont; - BN_mod_exp_mont_consttime; - BN_mod_exp_mont_word; - BN_mod_exp_recp; - BN_mod_exp_simple; - BN_mod_inverse; - BN_mod_lshift1; - BN_mod_lshift1_quick; - BN_mod_lshift; - BN_mod_lshift_quick; - BN_mod_mul; - BN_mod_mul_montgomery; - BN_mod_mul_reciprocal; - BN_mod_sqr; - BN_mod_sqrt; - BN_mod_sub; - BN_mod_sub_quick; - BN_mod_word; - BN_mpi2bn; - BN_mul; - BN_mul_word; - BN_new; - BN_nist_mod_192; - BN_nist_mod_224; - BN_nist_mod_256; - BN_nist_mod_384; - BN_nist_mod_521; - BN_nist_mod_func; - BN_nnmod; - BN_num_bits; - BN_num_bits_word; - BN_options; - BN_print; - BN_print_fp; - BN_pseudo_rand; - BN_pseudo_rand_range; - BN_rand; - BN_rand_range; - BN_reciprocal; - BN_rshift1; - BN_rshift; - BN_secure_new; - BN_security_bits; - BN_set_bit; - BN_set_flags; - BN_set_negative; - BN_set_params; - BN_set_word; - BN_sqr; - BN_sub; - BN_sub_word; - BN_swap; - BN_to_ASN1_ENUMERATED; - BN_to_ASN1_INTEGER; - BN_to_montgomery; - BN_uadd; - BN_ucmp; - BN_usub; - BN_value_one; - BN_with_flags; - BN_zero_ex; - BUF_MEM_free; - BUF_MEM_grow; - BUF_MEM_grow_clean; - BUF_MEM_new; - BUF_MEM_new_ex; - BUF_reverse; - CAST_cbc_encrypt; - CAST_cfb64_encrypt; - CAST_decrypt; - CAST_ecb_encrypt; - CAST_encrypt; - CAST_ofb64_encrypt; - CAST_set_key; - CERTIFICATEPOLICIES_free; - CERTIFICATEPOLICIES_new; - CMAC_CTX_cleanup; - CMAC_CTX_copy; - CMAC_CTX_free; - CMAC_CTX_get0_cipher_ctx; - CMAC_CTX_new; - CMAC_Final; - CMAC_Init; - CMAC_Update; - CMAC_resume; - CMS_ContentInfo_free; - CMS_ContentInfo_new; - CMS_ContentInfo_print_ctx; - CMS_EncryptedData_decrypt; - CMS_EncryptedData_encrypt; - CMS_EncryptedData_set1_key; - CMS_EnvelopedData_create; - CMS_ReceiptRequest_create0; - CMS_ReceiptRequest_free; - CMS_ReceiptRequest_get0_values; - CMS_ReceiptRequest_new; - CMS_RecipientEncryptedKey_cert_cmp; - CMS_RecipientEncryptedKey_get0_id; - CMS_RecipientInfo_decrypt; - CMS_RecipientInfo_encrypt; - CMS_RecipientInfo_get0_pkey_ctx; - CMS_RecipientInfo_kari_decrypt; - CMS_RecipientInfo_kari_get0_alg; - CMS_RecipientInfo_kari_get0_ctx; - CMS_RecipientInfo_kari_get0_orig_id; - CMS_RecipientInfo_kari_get0_reks; - CMS_RecipientInfo_kari_orig_id_cmp; - CMS_RecipientInfo_kari_set0_pkey; - CMS_RecipientInfo_kekri_get0_id; - CMS_RecipientInfo_kekri_id_cmp; - CMS_RecipientInfo_ktri_cert_cmp; - CMS_RecipientInfo_ktri_get0_algs; - CMS_RecipientInfo_ktri_get0_signer_id; - CMS_RecipientInfo_set0_key; - CMS_RecipientInfo_set0_password; - CMS_RecipientInfo_set0_pkey; - CMS_RecipientInfo_type; - CMS_SharedInfo_encode; - CMS_SignedData_init; - CMS_SignerInfo_cert_cmp; - CMS_SignerInfo_get0_algs; - CMS_SignerInfo_get0_md_ctx; - CMS_SignerInfo_get0_pkey_ctx; - CMS_SignerInfo_get0_signature; - CMS_SignerInfo_get0_signer_id; - CMS_SignerInfo_set1_signer_cert; - CMS_SignerInfo_sign; - CMS_SignerInfo_verify; - CMS_SignerInfo_verify_content; - CMS_add0_CertificateChoices; - CMS_add0_RevocationInfoChoice; - CMS_add0_cert; - CMS_add0_crl; - CMS_add0_recipient_key; - CMS_add0_recipient_password; - CMS_add1_ReceiptRequest; - CMS_add1_cert; - CMS_add1_crl; - CMS_add1_recipient_cert; - CMS_add1_signer; - CMS_add_simple_smimecap; - CMS_add_smimecap; - CMS_add_standard_smimecap; - CMS_compress; - CMS_dataFinal; - CMS_dataInit; - CMS_data; - CMS_data_create; - CMS_decrypt; - CMS_decrypt_set1_key; - CMS_decrypt_set1_password; - CMS_decrypt_set1_pkey; - CMS_digest_create; - CMS_digest_verify; - CMS_encrypt; - CMS_final; - CMS_get0_RecipientInfos; - CMS_get0_SignerInfos; - CMS_get0_content; - CMS_get0_eContentType; - CMS_get0_signers; - CMS_get0_type; - CMS_get1_ReceiptRequest; - CMS_get1_certs; - CMS_get1_crls; - CMS_is_detached; - CMS_set1_eContentType; - CMS_set1_signers_certs; - CMS_set_detached; - CMS_sign; - CMS_sign_receipt; - CMS_signed_add1_attr; - CMS_signed_add1_attr_by_NID; - CMS_signed_add1_attr_by_OBJ; - CMS_signed_add1_attr_by_txt; - CMS_signed_delete_attr; - CMS_signed_get0_data_by_OBJ; - CMS_signed_get_attr; - CMS_signed_get_attr_by_NID; - CMS_signed_get_attr_by_OBJ; - CMS_signed_get_attr_count; - CMS_stream; - CMS_uncompress; - CMS_unsigned_add1_attr; - CMS_unsigned_add1_attr_by_NID; - CMS_unsigned_add1_attr_by_OBJ; - CMS_unsigned_add1_attr_by_txt; - CMS_unsigned_delete_attr; - CMS_unsigned_get0_data_by_OBJ; - CMS_unsigned_get_attr; - CMS_unsigned_get_attr_by_NID; - CMS_unsigned_get_attr_by_OBJ; - CMS_unsigned_get_attr_count; - CMS_verify; - CMS_verify_receipt; - COMP_CTX_free; - COMP_CTX_get_method; - COMP_CTX_get_type; - COMP_CTX_new; - COMP_compress_block; - COMP_expand_block; - COMP_get_name; - COMP_get_type; - COMP_zlib; - CONF_dump_bio; - CONF_dump_fp; - CONF_free; - CONF_get1_default_config_file; - CONF_get_number; - CONF_get_section; - CONF_get_string; - CONF_imodule_get_flags; - CONF_imodule_get_module; - CONF_imodule_get_name; - CONF_imodule_get_usr_data; - CONF_imodule_get_value; - CONF_imodule_set_flags; - CONF_imodule_set_usr_data; - CONF_load; - CONF_load_bio; - CONF_load_fp; - CONF_module_add; - CONF_module_get_usr_data; - CONF_module_set_usr_data; - CONF_modules_finish; - CONF_modules_load; - CONF_modules_load_file; - CONF_modules_unload; - CONF_parse_list; - CONF_set_default_method; - CONF_set_nconf; - CRL_DIST_POINTS_free; - CRL_DIST_POINTS_new; - CRYPTO_128_unwrap; - CRYPTO_128_unwrap_pad; - CRYPTO_128_wrap; - CRYPTO_128_wrap_pad; - CRYPTO_THREAD_cleanup_local; - CRYPTO_THREAD_compare_id; - CRYPTO_THREAD_get_current_id; - CRYPTO_THREAD_get_local; - CRYPTO_THREAD_init_local; - CRYPTO_THREAD_lock_free; - CRYPTO_THREAD_lock_new; - CRYPTO_THREAD_read_lock; - CRYPTO_THREAD_run_once; - CRYPTO_THREAD_set_local; - CRYPTO_THREAD_unlock; - CRYPTO_THREAD_write_lock; - CRYPTO_atomic_add; - CRYPTO_cbc128_decrypt; - CRYPTO_cbc128_encrypt; - CRYPTO_ccm128_aad; - CRYPTO_ccm128_decrypt; - CRYPTO_ccm128_decrypt_ccm64; - CRYPTO_ccm128_encrypt; - CRYPTO_ccm128_encrypt_ccm64; - CRYPTO_ccm128_init; - CRYPTO_ccm128_setiv; - CRYPTO_ccm128_tag; - CRYPTO_cfb128_1_encrypt; - CRYPTO_cfb128_8_encrypt; - CRYPTO_cfb128_encrypt; - CRYPTO_clear_free; - CRYPTO_clear_realloc; - CRYPTO_ctr128_encrypt; - CRYPTO_ctr128_encrypt_ctr32; - CRYPTO_cts128_decrypt; - CRYPTO_cts128_decrypt_block; - CRYPTO_cts128_encrypt; - CRYPTO_cts128_encrypt_block; - CRYPTO_dup_ex_data; - CRYPTO_free; - CRYPTO_free_ex_data; - CRYPTO_free_ex_index; - CRYPTO_gcm128_aad; - CRYPTO_gcm128_decrypt; - CRYPTO_gcm128_decrypt_ctr32; - CRYPTO_gcm128_encrypt; - CRYPTO_gcm128_encrypt_ctr32; - CRYPTO_gcm128_finish; - CRYPTO_gcm128_init; - CRYPTO_gcm128_new; - CRYPTO_gcm128_release; - CRYPTO_gcm128_setiv; - CRYPTO_gcm128_tag; - CRYPTO_get_ex_data; - CRYPTO_get_ex_new_index; - CRYPTO_get_mem_functions; - CRYPTO_malloc; - CRYPTO_mem_ctrl; - CRYPTO_memcmp; - CRYPTO_memdup; - CRYPTO_new_ex_data; - CRYPTO_nistcts128_decrypt; - CRYPTO_nistcts128_decrypt_block; - CRYPTO_nistcts128_encrypt; - CRYPTO_nistcts128_encrypt_block; - CRYPTO_ocb128_aad; - CRYPTO_ocb128_cleanup; - CRYPTO_ocb128_copy_ctx; - CRYPTO_ocb128_decrypt; - CRYPTO_ocb128_encrypt; - CRYPTO_ocb128_finish; - CRYPTO_ocb128_init; - CRYPTO_ocb128_new; - CRYPTO_ocb128_setiv; - CRYPTO_ocb128_tag; - CRYPTO_ofb128_encrypt; - CRYPTO_realloc; - CRYPTO_secure_actual_size; - CRYPTO_secure_allocated; - CRYPTO_secure_free; - CRYPTO_secure_malloc; - CRYPTO_secure_malloc_done; - CRYPTO_secure_malloc_init; - CRYPTO_secure_malloc_initialized; - CRYPTO_secure_used; - CRYPTO_secure_zalloc; - CRYPTO_set_ex_data; - CRYPTO_set_mem_debug; - CRYPTO_set_mem_functions; - CRYPTO_strdup; - CRYPTO_strndup; - CRYPTO_xts128_encrypt; - CRYPTO_zalloc; - CTLOG_STORE_free; - CTLOG_STORE_get0_log_by_id; - CTLOG_STORE_load_default_file; - CTLOG_STORE_load_file; - CTLOG_STORE_new; - CTLOG_free; - CTLOG_get0_log_id; - CTLOG_get0_name; - CTLOG_get0_public_key; - CTLOG_new; - CTLOG_new_from_base64; - CT_POLICY_EVAL_CTX_free; - CT_POLICY_EVAL_CTX_get0_cert; - CT_POLICY_EVAL_CTX_get0_issuer; - CT_POLICY_EVAL_CTX_get0_log_store; - CT_POLICY_EVAL_CTX_new; - CT_POLICY_EVAL_CTX_set1_cert; - CT_POLICY_EVAL_CTX_set1_issuer; - CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE; - Camellia_cbc_encrypt; - Camellia_cfb128_encrypt; - Camellia_cfb1_encrypt; - Camellia_cfb8_encrypt; - Camellia_ctr128_encrypt; - Camellia_decrypt; - Camellia_ecb_encrypt; - Camellia_encrypt; - Camellia_ofb128_encrypt; - Camellia_set_key; - DES_cbc_cksum; - DES_cbc_encrypt; - DES_cfb64_encrypt; - DES_cfb_encrypt; - DES_check_key_parity; - DES_crypt; - DES_decrypt3; - DES_ecb3_encrypt; - DES_ecb_encrypt; - DES_ede3_cbc_encrypt; - DES_ede3_cfb64_encrypt; - DES_ede3_cfb_encrypt; - DES_ede3_ofb64_encrypt; - DES_encrypt1; - DES_encrypt2; - DES_encrypt3; - DES_fcrypt; - DES_is_weak_key; - DES_key_sched; - DES_ncbc_encrypt; - DES_ofb64_encrypt; - DES_ofb_encrypt; - DES_options; - DES_pcbc_encrypt; - DES_quad_cksum; - DES_random_key; - DES_set_key; - DES_set_key_checked; - DES_set_key_unchecked; - DES_set_odd_parity; - DES_string_to_2keys; - DES_string_to_key; - DES_xcbc_encrypt; - DH_KDF_X9_42; - DH_OpenSSL; - DH_bits; - DH_check; - DH_check_pub_key; - DH_clear_flags; - DH_compute_key; - DH_compute_key_padded; - DH_free; - DH_generate_key; - DH_generate_parameters; - DH_generate_parameters_ex; - DH_get0_engine; - DH_get0_key; - DH_get0_pqg; - DH_get_1024_160; - DH_get_2048_224; - DH_get_2048_256; - DH_get_default_method; - DH_get_ex_data; - DH_get_length; - DH_meth_dup; - DH_meth_free; - DH_meth_get0_app_data; - DH_meth_get0_name; - DH_meth_get_bn_mod_exp; - DH_meth_get_compute_key; - DH_meth_get_finish; - DH_meth_get_flags; - DH_meth_get_generate_key; - DH_meth_get_generate_params; - DH_meth_get_init; - DH_meth_new; - DH_meth_set0_app_data; - DH_meth_set1_name; - DH_meth_set_bn_mod_exp; - DH_meth_set_compute_key; - DH_meth_set_finish; - DH_meth_set_flags; - DH_meth_set_generate_key; - DH_meth_set_generate_params; - DH_meth_set_init; - DH_new; - DH_new_method; - DH_security_bits; - DH_set0_key; - DH_set0_pqg; - DH_set_default_method; - DH_set_ex_data; - DH_set_flags; - DH_set_length; - DH_set_method; - DH_size; - DH_test_flags; - DH_up_ref; - DHparams_dup; - DHparams_print; - DHparams_print_fp; - DIRECTORYSTRING_free; - DIRECTORYSTRING_new; - DISPLAYTEXT_free; - DISPLAYTEXT_new; - DIST_POINT_NAME_free; - DIST_POINT_NAME_new; - DIST_POINT_free; - DIST_POINT_new; - DIST_POINT_set_dpname; - DSA_OpenSSL; - DSA_SIG_free; - DSA_SIG_get0; - DSA_SIG_new; - DSA_SIG_set0; - DSA_bits; - DSA_clear_flags; - DSA_do_sign; - DSA_do_verify; - DSA_dup_DH; - DSA_free; - DSA_generate_key; - DSA_generate_parameters; - DSA_generate_parameters_ex; - DSA_get0_engine; - DSA_get0_key; - DSA_get0_pqg; - DSA_get_default_method; - DSA_get_ex_data; - DSA_get_method; - DSA_meth_dup; - DSA_meth_free; - DSA_meth_get0_app_data; - DSA_meth_get0_name; - DSA_meth_get_bn_mod_exp; - DSA_meth_get_finish; - DSA_meth_get_flags; - DSA_meth_get_init; - DSA_meth_get_keygen; - DSA_meth_get_mod_exp; - DSA_meth_get_paramgen; - DSA_meth_get_sign; - DSA_meth_get_sign_setup; - DSA_meth_get_verify; - DSA_meth_new; - DSA_meth_set0_app_data; - DSA_meth_set1_name; - DSA_meth_set_bn_mod_exp; - DSA_meth_set_finish; - DSA_meth_set_flags; - DSA_meth_set_init; - DSA_meth_set_keygen; - DSA_meth_set_mod_exp; - DSA_meth_set_paramgen; - DSA_meth_set_sign; - DSA_meth_set_sign_setup; - DSA_meth_set_verify; - DSA_new; - DSA_new_method; - DSA_print; - DSA_print_fp; - DSA_security_bits; - DSA_set0_key; - DSA_set0_pqg; - DSA_set_default_method; - DSA_set_ex_data; - DSA_set_flags; - DSA_set_method; - DSA_sign; - DSA_sign_setup; - DSA_size; - DSA_test_flags; - DSA_up_ref; - DSA_verify; - DSAparams_dup; - DSAparams_print; - DSAparams_print_fp; - DSO_METHOD_openssl; - DSO_bind_func; - DSO_convert_filename; - DSO_ctrl; - DSO_flags; - DSO_free; - DSO_get_filename; - DSO_global_lookup; - DSO_load; - DSO_merge; - DSO_new; - DSO_set_filename; - DSO_up_ref; - ECDH_KDF_X9_62; - ECDH_compute_key; - ECDSA_SIG_free; - ECDSA_SIG_get0; - ECDSA_SIG_new; - ECDSA_SIG_set0; - ECDSA_do_sign; - ECDSA_do_sign_ex; - ECDSA_do_verify; - ECDSA_sign; - ECDSA_sign_ex; - ECDSA_sign_setup; - ECDSA_size; - ECDSA_verify; - ECPARAMETERS_free; - ECPARAMETERS_new; - ECPKPARAMETERS_free; - ECPKPARAMETERS_new; - ECPKParameters_print; - ECPKParameters_print_fp; - ECParameters_print; - ECParameters_print_fp; - EC_GF2m_simple_method; - EC_GFp_mont_method; - EC_GFp_nist_method; - EC_GFp_nistp224_method; - EC_GFp_nistp256_method; - EC_GFp_nistp521_method; - EC_GFp_simple_method; - EC_GROUP_check; - EC_GROUP_check_discriminant; - EC_GROUP_clear_free; - EC_GROUP_cmp; - EC_GROUP_copy; - EC_GROUP_dup; - EC_GROUP_free; - EC_GROUP_get0_cofactor; - EC_GROUP_get0_generator; - EC_GROUP_get0_order; - EC_GROUP_get0_seed; - EC_GROUP_get_asn1_flag; - EC_GROUP_get_basis_type; - EC_GROUP_get_cofactor; - EC_GROUP_get_curve_GF2m; - EC_GROUP_get_curve_GFp; - EC_GROUP_get_curve_name; - EC_GROUP_get_degree; - EC_GROUP_get_ecparameters; - EC_GROUP_get_ecpkparameters; - EC_GROUP_get_mont_data; - EC_GROUP_get_order; - EC_GROUP_get_pentanomial_basis; - EC_GROUP_get_point_conversion_form; - EC_GROUP_get_seed_len; - EC_GROUP_get_trinomial_basis; - EC_GROUP_have_precompute_mult; - EC_GROUP_method_of; - EC_GROUP_new; - EC_GROUP_new_by_curve_name; - EC_GROUP_new_curve_GF2m; - EC_GROUP_new_curve_GFp; - EC_GROUP_new_from_ecparameters; - EC_GROUP_new_from_ecpkparameters; - EC_GROUP_order_bits; - EC_GROUP_precompute_mult; - EC_GROUP_set_asn1_flag; - EC_GROUP_set_curve_GF2m; - EC_GROUP_set_curve_GFp; - EC_GROUP_set_curve_name; - EC_GROUP_set_generator; - EC_GROUP_set_point_conversion_form; - EC_GROUP_set_seed; - EC_KEY_METHOD_free; - EC_KEY_METHOD_get_compute_key; - EC_KEY_METHOD_get_init; - EC_KEY_METHOD_get_keygen; - EC_KEY_METHOD_get_sign; - EC_KEY_METHOD_get_verify; - EC_KEY_METHOD_new; - EC_KEY_METHOD_set_compute_key; - EC_KEY_METHOD_set_init; - EC_KEY_METHOD_set_keygen; - EC_KEY_METHOD_set_sign; - EC_KEY_METHOD_set_verify; - EC_KEY_OpenSSL; - EC_KEY_can_sign; - EC_KEY_check_key; - EC_KEY_clear_flags; - EC_KEY_copy; - EC_KEY_dup; - EC_KEY_free; - EC_KEY_generate_key; - EC_KEY_get0_group; - EC_KEY_get0_private_key; - EC_KEY_get0_public_key; - EC_KEY_get_conv_form; - EC_KEY_get_default_method; - EC_KEY_get_enc_flags; - EC_KEY_get_ex_data; - EC_KEY_get_flags; - EC_KEY_get_method; - EC_KEY_key2buf; - EC_KEY_new; - EC_KEY_new_by_curve_name; - EC_KEY_new_method; - EC_KEY_oct2key; - EC_KEY_oct2priv; - EC_KEY_precompute_mult; - EC_KEY_print; - EC_KEY_print_fp; - EC_KEY_priv2buf; - EC_KEY_priv2oct; - EC_KEY_set_asn1_flag; - EC_KEY_set_conv_form; - EC_KEY_set_default_method; - EC_KEY_set_enc_flags; - EC_KEY_set_ex_data; - EC_KEY_set_flags; - EC_KEY_set_group; - EC_KEY_set_method; - EC_KEY_set_private_key; - EC_KEY_set_public_key; - EC_KEY_set_public_key_affine_coordinates; - EC_KEY_up_ref; - EC_METHOD_get_field_type; - EC_POINT_add; - EC_POINT_bn2point; - EC_POINT_clear_free; - EC_POINT_cmp; - EC_POINT_copy; - EC_POINT_dbl; - EC_POINT_dup; - EC_POINT_free; - EC_POINT_get_Jprojective_coordinates_GFp; - EC_POINT_get_affine_coordinates_GF2m; - EC_POINT_get_affine_coordinates_GFp; - EC_POINT_hex2point; - EC_POINT_invert; - EC_POINT_is_at_infinity; - EC_POINT_is_on_curve; - EC_POINT_make_affine; - EC_POINT_method_of; - EC_POINT_mul; - EC_POINT_new; - EC_POINT_oct2point; - EC_POINT_point2bn; - EC_POINT_point2buf; - EC_POINT_point2hex; - EC_POINT_point2oct; - EC_POINT_set_Jprojective_coordinates_GFp; - EC_POINT_set_affine_coordinates_GF2m; - EC_POINT_set_affine_coordinates_GFp; - EC_POINT_set_compressed_coordinates_GF2m; - EC_POINT_set_compressed_coordinates_GFp; - EC_POINT_set_to_infinity; - EC_POINTs_make_affine; - EC_POINTs_mul; - EC_curve_nid2nist; - EC_curve_nist2nid; - EC_get_builtin_curves; - EDIPARTYNAME_free; - EDIPARTYNAME_new; - ENGINE_add; - ENGINE_add_conf_module; - ENGINE_by_id; - ENGINE_cmd_is_executable; - ENGINE_ctrl; - ENGINE_ctrl_cmd; - ENGINE_ctrl_cmd_string; - ENGINE_finish; - ENGINE_free; - ENGINE_get_DH; - ENGINE_get_DSA; - ENGINE_get_EC; - ENGINE_get_RAND; - ENGINE_get_RSA; - ENGINE_get_cipher; - ENGINE_get_cipher_engine; - ENGINE_get_ciphers; - ENGINE_get_cmd_defns; - ENGINE_get_ctrl_function; - ENGINE_get_default_DH; - ENGINE_get_default_DSA; - ENGINE_get_default_EC; - ENGINE_get_default_RAND; - ENGINE_get_default_RSA; - ENGINE_get_destroy_function; - ENGINE_get_digest; - ENGINE_get_digest_engine; - ENGINE_get_digests; - ENGINE_get_ex_data; - ENGINE_get_finish_function; - ENGINE_get_first; - ENGINE_get_flags; - ENGINE_get_id; - ENGINE_get_init_function; - ENGINE_get_last; - ENGINE_get_load_privkey_function; - ENGINE_get_load_pubkey_function; - ENGINE_get_name; - ENGINE_get_next; - ENGINE_get_pkey_asn1_meth; - ENGINE_get_pkey_asn1_meth_engine; - ENGINE_get_pkey_asn1_meth_str; - ENGINE_get_pkey_asn1_meths; - ENGINE_get_pkey_meth; - ENGINE_get_pkey_meth_engine; - ENGINE_get_pkey_meths; - ENGINE_get_prev; - ENGINE_get_ssl_client_cert_function; - ENGINE_get_static_state; - ENGINE_get_table_flags; - ENGINE_init; - ENGINE_load_builtin_engines; - ENGINE_load_private_key; - ENGINE_load_public_key; - ENGINE_load_ssl_client_cert; - ENGINE_new; - ENGINE_pkey_asn1_find_str; - ENGINE_register_DH; - ENGINE_register_DSA; - ENGINE_register_EC; - ENGINE_register_RAND; - ENGINE_register_RSA; - ENGINE_register_all_DH; - ENGINE_register_all_DSA; - ENGINE_register_all_EC; - ENGINE_register_all_RAND; - ENGINE_register_all_RSA; - ENGINE_register_all_ciphers; - ENGINE_register_all_complete; - ENGINE_register_all_digests; - ENGINE_register_all_pkey_asn1_meths; - ENGINE_register_all_pkey_meths; - ENGINE_register_ciphers; - ENGINE_register_complete; - ENGINE_register_digests; - ENGINE_register_pkey_asn1_meths; - ENGINE_register_pkey_meths; - ENGINE_remove; - ENGINE_set_DH; - ENGINE_set_DSA; - ENGINE_set_EC; - ENGINE_set_RAND; - ENGINE_set_RSA; - ENGINE_set_ciphers; - ENGINE_set_cmd_defns; - ENGINE_set_ctrl_function; - ENGINE_set_default; - ENGINE_set_default_DH; - ENGINE_set_default_DSA; - ENGINE_set_default_EC; - ENGINE_set_default_RAND; - ENGINE_set_default_RSA; - ENGINE_set_default_ciphers; - ENGINE_set_default_digests; - ENGINE_set_default_pkey_asn1_meths; - ENGINE_set_default_pkey_meths; - ENGINE_set_default_string; - ENGINE_set_destroy_function; - ENGINE_set_digests; - ENGINE_set_ex_data; - ENGINE_set_finish_function; - ENGINE_set_flags; - ENGINE_set_id; - ENGINE_set_init_function; - ENGINE_set_load_privkey_function; - ENGINE_set_load_pubkey_function; - ENGINE_set_load_ssl_client_cert_function; - ENGINE_set_name; - ENGINE_set_pkey_asn1_meths; - ENGINE_set_pkey_meths; - ENGINE_set_table_flags; - ENGINE_unregister_DH; - ENGINE_unregister_DSA; - ENGINE_unregister_EC; - ENGINE_unregister_RAND; - ENGINE_unregister_RSA; - ENGINE_unregister_ciphers; - ENGINE_unregister_digests; - ENGINE_unregister_pkey_asn1_meths; - ENGINE_unregister_pkey_meths; - ENGINE_up_ref; - ERR_add_error_data; - ERR_add_error_vdata; - ERR_clear_error; - ERR_error_string; - ERR_error_string_n; - ERR_func_error_string; - ERR_get_error; - ERR_get_error_line; - ERR_get_error_line_data; - ERR_get_next_error_library; - ERR_get_state; - ERR_lib_error_string; - ERR_load_ASN1_strings; - ERR_load_ASYNC_strings; - ERR_load_BIO_strings; - ERR_load_BN_strings; - ERR_load_BUF_strings; - ERR_load_CMS_strings; - ERR_load_COMP_strings; - ERR_load_CONF_strings; - ERR_load_CRYPTO_strings; - ERR_load_CT_strings; - ERR_load_DH_strings; - ERR_load_DSA_strings; - ERR_load_DSO_strings; - ERR_load_EC_strings; - ERR_load_ENGINE_strings; - ERR_load_ERR_strings; - ERR_load_EVP_strings; - ERR_load_KDF_strings; - ERR_load_OBJ_strings; - ERR_load_OCSP_strings; - ERR_load_PEM_strings; - ERR_load_PKCS12_strings; - ERR_load_PKCS7_strings; - ERR_load_RAND_strings; - ERR_load_RSA_strings; - ERR_load_TS_strings; - ERR_load_UI_strings; - ERR_load_X509V3_strings; - ERR_load_X509_strings; - ERR_load_strings; - ERR_peek_error; - ERR_peek_error_line; - ERR_peek_error_line_data; - ERR_peek_last_error; - ERR_peek_last_error_line; - ERR_peek_last_error_line_data; - ERR_pop_to_mark; - ERR_print_errors; - ERR_print_errors_cb; - ERR_print_errors_fp; - ERR_put_error; - ERR_reason_error_string; - ERR_remove_state; - ERR_remove_thread_state; - ERR_set_error_data; - ERR_set_mark; - ERR_unload_strings; - ESS_CERT_ID_dup; - ESS_CERT_ID_free; - ESS_CERT_ID_new; - ESS_ISSUER_SERIAL_dup; - ESS_ISSUER_SERIAL_free; - ESS_ISSUER_SERIAL_new; - ESS_SIGNING_CERT_dup; - ESS_SIGNING_CERT_free; - ESS_SIGNING_CERT_new; - EVP_BytesToKey; - EVP_CIPHER_CTX_block_size; - EVP_CIPHER_CTX_buf_noconst; - EVP_CIPHER_CTX_cipher; - EVP_CIPHER_CTX_clear_flags; - EVP_CIPHER_CTX_copy; - EVP_CIPHER_CTX_ctrl; - EVP_CIPHER_CTX_encrypting; - EVP_CIPHER_CTX_free; - EVP_CIPHER_CTX_get_app_data; - EVP_CIPHER_CTX_get_cipher_data; - EVP_CIPHER_CTX_iv; - EVP_CIPHER_CTX_iv_length; - EVP_CIPHER_CTX_iv_noconst; - EVP_CIPHER_CTX_key_length; - EVP_CIPHER_CTX_new; - EVP_CIPHER_CTX_nid; - EVP_CIPHER_CTX_num; - EVP_CIPHER_CTX_original_iv; - EVP_CIPHER_CTX_rand_key; - EVP_CIPHER_CTX_reset; - EVP_CIPHER_CTX_set_app_data; - EVP_CIPHER_CTX_set_cipher_data; - EVP_CIPHER_CTX_set_flags; - EVP_CIPHER_CTX_set_key_length; - EVP_CIPHER_CTX_set_num; - EVP_CIPHER_CTX_set_padding; - EVP_CIPHER_CTX_test_flags; - EVP_CIPHER_asn1_to_param; - EVP_CIPHER_block_size; - EVP_CIPHER_do_all; - EVP_CIPHER_do_all_sorted; - EVP_CIPHER_flags; - EVP_CIPHER_get_asn1_iv; - EVP_CIPHER_impl_ctx_size; - EVP_CIPHER_iv_length; - EVP_CIPHER_key_length; - EVP_CIPHER_meth_dup; - EVP_CIPHER_meth_free; - EVP_CIPHER_meth_get_cleanup; - EVP_CIPHER_meth_get_ctrl; - EVP_CIPHER_meth_get_do_cipher; - EVP_CIPHER_meth_get_get_asn1_params; - EVP_CIPHER_meth_get_init; - EVP_CIPHER_meth_get_set_asn1_params; - 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; - EVP_CIPHER_type; - EVP_CipherFinal; - EVP_CipherFinal_ex; - EVP_CipherInit; - EVP_CipherInit_ex; - EVP_CipherUpdate; - EVP_Cipher; - EVP_DecodeBlock; - EVP_DecodeFinal; - EVP_DecodeInit; - EVP_DecodeUpdate; - EVP_DecryptFinal; - EVP_DecryptFinal_ex; - EVP_DecryptInit; - EVP_DecryptInit_ex; - EVP_DecryptUpdate; - EVP_DigestFinal; - EVP_DigestFinal_ex; - EVP_DigestInit; - EVP_DigestInit_ex; - EVP_DigestSignFinal; - EVP_DigestSignInit; - EVP_DigestUpdate; - EVP_DigestVerifyFinal; - EVP_DigestVerifyInit; - EVP_Digest; - EVP_ENCODE_CTX_copy; - EVP_ENCODE_CTX_free; - EVP_ENCODE_CTX_new; - EVP_ENCODE_CTX_num; - EVP_EncodeBlock; - EVP_EncodeFinal; - EVP_EncodeInit; - EVP_EncodeUpdate; - EVP_EncryptFinal; - EVP_EncryptFinal_ex; - EVP_EncryptInit; - EVP_EncryptInit_ex; - EVP_EncryptUpdate; - EVP_MD_CTX_clear_flags; - EVP_MD_CTX_copy; - EVP_MD_CTX_copy_ex; - EVP_MD_CTX_ctrl; - EVP_MD_CTX_free; - EVP_MD_CTX_md; - EVP_MD_CTX_md_data; - EVP_MD_CTX_new; - EVP_MD_CTX_pkey_ctx; - EVP_MD_CTX_reset; - EVP_MD_CTX_set_flags; - EVP_MD_CTX_set_update_fn; - EVP_MD_CTX_test_flags; - EVP_MD_CTX_update_fn; - EVP_MD_block_size; - EVP_MD_do_all; - EVP_MD_do_all_sorted; - EVP_MD_flags; - EVP_MD_meth_dup; - EVP_MD_meth_free; - EVP_MD_meth_get_app_datasize; - EVP_MD_meth_get_cleanup; - EVP_MD_meth_get_copy; - EVP_MD_meth_get_ctrl; - EVP_MD_meth_get_final; - EVP_MD_meth_get_flags; - EVP_MD_meth_get_init; - EVP_MD_meth_get_input_blocksize; - EVP_MD_meth_get_result_size; - EVP_MD_meth_get_update; - EVP_MD_meth_new; - EVP_MD_meth_set_app_datasize; - EVP_MD_meth_set_cleanup; - EVP_MD_meth_set_copy; - EVP_MD_meth_set_ctrl; - EVP_MD_meth_set_final; - EVP_MD_meth_set_flags; - EVP_MD_meth_set_init; - EVP_MD_meth_set_input_blocksize; - EVP_MD_meth_set_result_size; - EVP_MD_meth_set_update; - EVP_MD_pkey_type; - EVP_MD_size; - EVP_MD_type; - EVP_OpenFinal; - EVP_OpenInit; - EVP_PBE_CipherInit; - EVP_PBE_alg_add; - EVP_PBE_alg_add_type; - EVP_PBE_cleanup; - EVP_PBE_find; - EVP_PBE_get; - EVP_PBE_scrypt; - EVP_PKCS82PKEY; - EVP_PKEY2PKCS8; - EVP_PKEY_CTX_ctrl; - EVP_PKEY_CTX_ctrl_str; - EVP_PKEY_CTX_dup; - EVP_PKEY_CTX_free; - EVP_PKEY_CTX_get0_peerkey; - EVP_PKEY_CTX_get0_pkey; - EVP_PKEY_CTX_get_app_data; - EVP_PKEY_CTX_get_cb; - EVP_PKEY_CTX_get_data; - EVP_PKEY_CTX_get_keygen_info; - EVP_PKEY_CTX_get_operation; - EVP_PKEY_CTX_hex2ctrl; - EVP_PKEY_CTX_new; - EVP_PKEY_CTX_new_id; - EVP_PKEY_CTX_set0_keygen_info; - EVP_PKEY_CTX_set_app_data; - EVP_PKEY_CTX_set_cb; - EVP_PKEY_CTX_set_data; - EVP_PKEY_CTX_str2ctrl; - EVP_PKEY_add1_attr; - EVP_PKEY_add1_attr_by_NID; - EVP_PKEY_add1_attr_by_OBJ; - EVP_PKEY_add1_attr_by_txt; - EVP_PKEY_asn1_add0; - EVP_PKEY_asn1_add_alias; - EVP_PKEY_asn1_copy; - EVP_PKEY_asn1_find; - EVP_PKEY_asn1_find_str; - EVP_PKEY_asn1_free; - EVP_PKEY_asn1_get0; - EVP_PKEY_asn1_get0_info; - EVP_PKEY_asn1_get_count; - EVP_PKEY_asn1_new; - EVP_PKEY_asn1_set_ctrl; - EVP_PKEY_asn1_set_free; - EVP_PKEY_asn1_set_item; - EVP_PKEY_asn1_set_param; - EVP_PKEY_asn1_set_private; - EVP_PKEY_asn1_set_public; - EVP_PKEY_asn1_set_security_bits; - EVP_PKEY_assign; - EVP_PKEY_base_id; - EVP_PKEY_bits; - EVP_PKEY_cmp; - EVP_PKEY_cmp_parameters; - EVP_PKEY_copy_parameters; - EVP_PKEY_decrypt; - EVP_PKEY_decrypt_init; - EVP_PKEY_decrypt_old; - EVP_PKEY_delete_attr; - EVP_PKEY_derive; - EVP_PKEY_derive_init; - EVP_PKEY_derive_set_peer; - EVP_PKEY_encrypt; - EVP_PKEY_encrypt_init; - EVP_PKEY_encrypt_old; - EVP_PKEY_free; - EVP_PKEY_get0; - EVP_PKEY_get0_DH; - EVP_PKEY_get0_DSA; - EVP_PKEY_get0_EC_KEY; - EVP_PKEY_get0_RSA; - EVP_PKEY_get0_asn1; - EVP_PKEY_get0_hmac; - EVP_PKEY_get1_DH; - EVP_PKEY_get1_DSA; - EVP_PKEY_get1_EC_KEY; - EVP_PKEY_get1_RSA; - EVP_PKEY_get1_tls_encodedpoint; - EVP_PKEY_get_attr; - EVP_PKEY_get_attr_by_NID; - EVP_PKEY_get_attr_by_OBJ; - EVP_PKEY_get_attr_count; - EVP_PKEY_get_default_digest_nid; - EVP_PKEY_id; - EVP_PKEY_keygen; - EVP_PKEY_keygen_init; - EVP_PKEY_meth_add0; - EVP_PKEY_meth_copy; - EVP_PKEY_meth_find; - EVP_PKEY_meth_free; - EVP_PKEY_meth_get0_info; - EVP_PKEY_meth_get_cleanup; - EVP_PKEY_meth_get_copy; - EVP_PKEY_meth_get_ctrl; - EVP_PKEY_meth_get_decrypt; - EVP_PKEY_meth_get_derive; - EVP_PKEY_meth_get_encrypt; - EVP_PKEY_meth_get_init; - EVP_PKEY_meth_get_keygen; - EVP_PKEY_meth_get_paramgen; - EVP_PKEY_meth_get_sign; - EVP_PKEY_meth_get_signctx; - EVP_PKEY_meth_get_verify; - EVP_PKEY_meth_get_verify_recover; - EVP_PKEY_meth_get_verifyctx; - EVP_PKEY_meth_new; - EVP_PKEY_meth_set_cleanup; - EVP_PKEY_meth_set_copy; - EVP_PKEY_meth_set_ctrl; - EVP_PKEY_meth_set_decrypt; - EVP_PKEY_meth_set_derive; - EVP_PKEY_meth_set_encrypt; - EVP_PKEY_meth_set_init; - EVP_PKEY_meth_set_keygen; - EVP_PKEY_meth_set_paramgen; - EVP_PKEY_meth_set_sign; - EVP_PKEY_meth_set_signctx; - EVP_PKEY_meth_set_verify; - EVP_PKEY_meth_set_verify_recover; - EVP_PKEY_meth_set_verifyctx; - EVP_PKEY_missing_parameters; - EVP_PKEY_new; - EVP_PKEY_new_mac_key; - EVP_PKEY_paramgen; - EVP_PKEY_paramgen_init; - EVP_PKEY_print_params; - EVP_PKEY_print_private; - EVP_PKEY_print_public; - EVP_PKEY_save_parameters; - EVP_PKEY_security_bits; - EVP_PKEY_set1_DH; - EVP_PKEY_set1_DSA; - EVP_PKEY_set1_EC_KEY; - EVP_PKEY_set1_RSA; - EVP_PKEY_set1_tls_encodedpoint; - EVP_PKEY_set_type; - EVP_PKEY_set_type_str; - EVP_PKEY_sign; - EVP_PKEY_sign_init; - EVP_PKEY_size; - EVP_PKEY_type; - EVP_PKEY_up_ref; - EVP_PKEY_verify; - EVP_PKEY_verify_init; - EVP_PKEY_verify_recover; - EVP_PKEY_verify_recover_init; - EVP_SealFinal; - EVP_SealInit; - EVP_SignFinal; - EVP_VerifyFinal; - EVP_add_alg_module; - EVP_add_cipher; - EVP_add_digest; - EVP_aes_128_cbc; - EVP_aes_128_cbc_hmac_sha1; - EVP_aes_128_cbc_hmac_sha256; - EVP_aes_128_ccm; - EVP_aes_128_cfb128; - EVP_aes_128_cfb1; - EVP_aes_128_cfb8; - EVP_aes_128_ctr; - EVP_aes_128_ecb; - EVP_aes_128_gcm; - EVP_aes_128_ocb; - EVP_aes_128_ofb; - EVP_aes_128_wrap; - EVP_aes_128_wrap_pad; - EVP_aes_128_xts; - EVP_aes_192_cbc; - EVP_aes_192_ccm; - EVP_aes_192_cfb128; - EVP_aes_192_cfb1; - EVP_aes_192_cfb8; - EVP_aes_192_ctr; - EVP_aes_192_ecb; - EVP_aes_192_gcm; - EVP_aes_192_ocb; - EVP_aes_192_ofb; - EVP_aes_192_wrap; - EVP_aes_192_wrap_pad; - EVP_aes_256_cbc; - EVP_aes_256_cbc_hmac_sha1; - EVP_aes_256_cbc_hmac_sha256; - EVP_aes_256_ccm; - EVP_aes_256_cfb128; - EVP_aes_256_cfb1; - EVP_aes_256_cfb8; - EVP_aes_256_ctr; - EVP_aes_256_ecb; - EVP_aes_256_gcm; - EVP_aes_256_ocb; - EVP_aes_256_ofb; - EVP_aes_256_wrap; - EVP_aes_256_wrap_pad; - EVP_aes_256_xts; - EVP_bf_cbc; - EVP_bf_cfb64; - EVP_bf_ecb; - EVP_bf_ofb; - EVP_blake2b512; - EVP_blake2s256; - EVP_camellia_128_cbc; - EVP_camellia_128_cfb128; - EVP_camellia_128_cfb1; - EVP_camellia_128_cfb8; - EVP_camellia_128_ctr; - EVP_camellia_128_ecb; - EVP_camellia_128_ofb; - EVP_camellia_192_cbc; - EVP_camellia_192_cfb128; - EVP_camellia_192_cfb1; - EVP_camellia_192_cfb8; - EVP_camellia_192_ctr; - EVP_camellia_192_ecb; - EVP_camellia_192_ofb; - EVP_camellia_256_cbc; - EVP_camellia_256_cfb128; - EVP_camellia_256_cfb1; - EVP_camellia_256_cfb8; - EVP_camellia_256_ctr; - EVP_camellia_256_ecb; - EVP_camellia_256_ofb; - EVP_cast5_cbc; - EVP_cast5_cfb64; - EVP_cast5_ecb; - EVP_cast5_ofb; - EVP_chacha20; - EVP_chacha20_poly1305; - EVP_des_cbc; - EVP_des_cfb1; - EVP_des_cfb64; - EVP_des_cfb8; - EVP_des_ecb; - EVP_des_ede3; - EVP_des_ede3_cbc; - EVP_des_ede3_cfb1; - EVP_des_ede3_cfb64; - EVP_des_ede3_cfb8; - EVP_des_ede3_ecb; - EVP_des_ede3_ofb; - EVP_des_ede3_wrap; - EVP_des_ede; - EVP_des_ede_cbc; - EVP_des_ede_cfb64; - EVP_des_ede_ecb; - EVP_des_ede_ofb; - EVP_des_ofb; - EVP_desx_cbc; - EVP_enc_null; - EVP_get_cipherbyname; - EVP_get_digestbyname; - EVP_get_pw_prompt; - EVP_idea_cbc; - EVP_idea_cfb64; - EVP_idea_ecb; - EVP_idea_ofb; - EVP_md4; - EVP_md5; - EVP_md5_sha1; - EVP_md_null; - EVP_mdc2; - EVP_rc2_40_cbc; - EVP_rc2_64_cbc; - EVP_rc2_cbc; - EVP_rc2_cfb64; - EVP_rc2_ecb; - EVP_rc2_ofb; - EVP_rc4; - EVP_rc4_40; - EVP_rc4_hmac_md5; - EVP_read_pw_string; - EVP_read_pw_string_min; - EVP_ripemd160; - EVP_seed_cbc; - EVP_seed_cfb128; - EVP_seed_ecb; - EVP_seed_ofb; - EVP_set_pw_prompt; - EVP_sha1; - EVP_sha224; - EVP_sha256; - EVP_sha384; - EVP_sha512; - EVP_whirlpool; - EXTENDED_KEY_USAGE_free; - EXTENDED_KEY_USAGE_new; - FIPS_mode; - FIPS_mode_set; - GENERAL_NAMES_free; - GENERAL_NAMES_new; - GENERAL_NAME_cmp; - GENERAL_NAME_dup; - GENERAL_NAME_free; - GENERAL_NAME_get0_otherName; - GENERAL_NAME_get0_value; - GENERAL_NAME_new; - GENERAL_NAME_print; - GENERAL_NAME_set0_othername; - GENERAL_NAME_set0_value; - GENERAL_SUBTREE_free; - GENERAL_SUBTREE_new; - HMAC; - HMAC_CTX_copy; - HMAC_CTX_free; - HMAC_CTX_get_md; - HMAC_CTX_new; - HMAC_CTX_reset; - HMAC_CTX_set_flags; - HMAC_Final; - HMAC_Init; - HMAC_Init_ex; - HMAC_Update; - HMAC_size; - IDEA_cbc_encrypt; - IDEA_cfb64_encrypt; - IDEA_ecb_encrypt; - IDEA_encrypt; - IDEA_ofb64_encrypt; - IDEA_options; - IDEA_set_decrypt_key; - IDEA_set_encrypt_key; - IPAddressChoice_free; - IPAddressChoice_new; - IPAddressFamily_free; - IPAddressFamily_new; - IPAddressOrRange_free; - IPAddressOrRange_new; - IPAddressRange_free; - IPAddressRange_new; - ISSUING_DIST_POINT_free; - ISSUING_DIST_POINT_new; - MD4; - MD4_Final; - MD4_Init; - MD4_Transform; - MD4_Update; - MD5; - MD5_Final; - MD5_Init; - MD5_Transform; - MD5_Update; - MDC2; - MDC2_Final; - MDC2_Init; - MDC2_Update; - NAME_CONSTRAINTS_check; - NAME_CONSTRAINTS_check_CN; - NAME_CONSTRAINTS_free; - NAME_CONSTRAINTS_new; - NCONF_WIN32; - NCONF_default; - NCONF_dump_bio; - NCONF_dump_fp; - NCONF_free; - NCONF_free_data; - NCONF_get_number_e; - NCONF_get_section; - NCONF_get_string; - NCONF_load; - NCONF_load_bio; - NCONF_load_fp; - NCONF_new; - NETSCAPE_CERT_SEQUENCE_free; - NETSCAPE_CERT_SEQUENCE_new; - NETSCAPE_SPKAC_free; - NETSCAPE_SPKAC_new; - NETSCAPE_SPKI_b64_decode; - NETSCAPE_SPKI_b64_encode; - NETSCAPE_SPKI_free; - NETSCAPE_SPKI_get_pubkey; - NETSCAPE_SPKI_new; - NETSCAPE_SPKI_print; - NETSCAPE_SPKI_set_pubkey; - NETSCAPE_SPKI_sign; - NETSCAPE_SPKI_verify; - NOTICEREF_free; - NOTICEREF_new; - OBJ_NAME_add; - OBJ_NAME_cleanup; - OBJ_NAME_do_all; - OBJ_NAME_do_all_sorted; - OBJ_NAME_get; - OBJ_NAME_init; - OBJ_NAME_new_index; - OBJ_NAME_remove; - OBJ_add_object; - OBJ_add_sigid; - OBJ_bsearch_; - OBJ_bsearch_ex_; - OBJ_cmp; - OBJ_create; - OBJ_create_objects; - OBJ_dup; - OBJ_find_sigid_algs; - OBJ_find_sigid_by_algs; - OBJ_get0_data; - OBJ_length; - OBJ_ln2nid; - OBJ_new_nid; - OBJ_nid2ln; - OBJ_nid2obj; - OBJ_nid2sn; - OBJ_obj2nid; - OBJ_obj2txt; - OBJ_sigid_free; - OBJ_sn2nid; - OBJ_txt2nid; - OBJ_txt2obj; - OCSP_BASICRESP_add1_ext_i2d; - OCSP_BASICRESP_add_ext; - OCSP_BASICRESP_delete_ext; - OCSP_BASICRESP_free; - OCSP_BASICRESP_get1_ext_d2i; - OCSP_BASICRESP_get_ext; - OCSP_BASICRESP_get_ext_by_NID; - OCSP_BASICRESP_get_ext_by_OBJ; - OCSP_BASICRESP_get_ext_by_critical; - OCSP_BASICRESP_get_ext_count; - OCSP_BASICRESP_new; - OCSP_CERTID_dup; - OCSP_CERTID_free; - OCSP_CERTID_new; - OCSP_CERTSTATUS_free; - OCSP_CERTSTATUS_new; - OCSP_CRLID_free; - OCSP_CRLID_new; - OCSP_ONEREQ_add1_ext_i2d; - OCSP_ONEREQ_add_ext; - OCSP_ONEREQ_delete_ext; - OCSP_ONEREQ_free; - OCSP_ONEREQ_get1_ext_d2i; - OCSP_ONEREQ_get_ext; - OCSP_ONEREQ_get_ext_by_NID; - OCSP_ONEREQ_get_ext_by_OBJ; - OCSP_ONEREQ_get_ext_by_critical; - OCSP_ONEREQ_get_ext_count; - OCSP_ONEREQ_new; - OCSP_REQINFO_free; - OCSP_REQINFO_new; - OCSP_REQUEST_add1_ext_i2d; - OCSP_REQUEST_add_ext; - OCSP_REQUEST_delete_ext; - OCSP_REQUEST_free; - OCSP_REQUEST_get1_ext_d2i; - OCSP_REQUEST_get_ext; - OCSP_REQUEST_get_ext_by_NID; - OCSP_REQUEST_get_ext_by_OBJ; - OCSP_REQUEST_get_ext_by_critical; - OCSP_REQUEST_get_ext_count; - OCSP_REQUEST_new; - OCSP_REQUEST_print; - OCSP_REQ_CTX_add1_header; - OCSP_REQ_CTX_free; - OCSP_REQ_CTX_get0_mem_bio; - OCSP_REQ_CTX_http; - OCSP_REQ_CTX_i2d; - OCSP_REQ_CTX_nbio; - OCSP_REQ_CTX_nbio_d2i; - OCSP_REQ_CTX_new; - OCSP_REQ_CTX_set1_req; - OCSP_RESPBYTES_free; - OCSP_RESPBYTES_new; - OCSP_RESPDATA_free; - OCSP_RESPDATA_new; - OCSP_RESPID_free; - OCSP_RESPID_new; - OCSP_RESPONSE_free; - OCSP_RESPONSE_new; - OCSP_RESPONSE_print; - OCSP_REVOKEDINFO_free; - OCSP_REVOKEDINFO_new; - OCSP_SERVICELOC_free; - OCSP_SERVICELOC_new; - OCSP_SIGNATURE_free; - OCSP_SIGNATURE_new; - OCSP_SINGLERESP_add1_ext_i2d; - OCSP_SINGLERESP_add_ext; - OCSP_SINGLERESP_delete_ext; - OCSP_SINGLERESP_free; - OCSP_SINGLERESP_get0_id; - OCSP_SINGLERESP_get1_ext_d2i; - OCSP_SINGLERESP_get_ext; - OCSP_SINGLERESP_get_ext_by_NID; - OCSP_SINGLERESP_get_ext_by_OBJ; - OCSP_SINGLERESP_get_ext_by_critical; - OCSP_SINGLERESP_get_ext_count; - OCSP_SINGLERESP_new; - OCSP_accept_responses_new; - OCSP_archive_cutoff_new; - OCSP_basic_add1_cert; - OCSP_basic_add1_nonce; - OCSP_basic_add1_status; - OCSP_basic_sign; - OCSP_basic_verify; - OCSP_cert_id_new; - OCSP_cert_status_str; - OCSP_cert_to_id; - OCSP_check_nonce; - OCSP_check_validity; - OCSP_copy_nonce; - OCSP_crlID_new; - OCSP_crl_reason_str; - OCSP_id_cmp; - OCSP_id_get0_info; - OCSP_id_issuer_cmp; - OCSP_onereq_get0_id; - OCSP_parse_url; - OCSP_request_add0_id; - OCSP_request_add1_cert; - OCSP_request_add1_nonce; - OCSP_request_is_signed; - OCSP_request_onereq_count; - OCSP_request_onereq_get0; - OCSP_request_set1_name; - OCSP_request_sign; - OCSP_request_verify; - OCSP_resp_count; - OCSP_resp_find; - OCSP_resp_find_status; - OCSP_resp_get0; - OCSP_resp_get0_certs; - OCSP_resp_get0_id; - OCSP_resp_get0_produced_at; - OCSP_resp_get0_signature; - OCSP_response_create; - OCSP_response_get1_basic; - OCSP_response_status; - OCSP_response_status_str; - OCSP_sendreq_bio; - OCSP_sendreq_nbio; - OCSP_sendreq_new; - OCSP_set_max_response_length; - OCSP_single_get0_status; - OCSP_url_svcloc_new; - OPENSSL_DIR_end; - OPENSSL_DIR_read; - OPENSSL_INIT_free; - OPENSSL_INIT_new; - OPENSSL_INIT_set_config_appname; - OPENSSL_LH_delete; - OPENSSL_LH_doall; - OPENSSL_LH_doall_arg; - OPENSSL_LH_error; - OPENSSL_LH_free; - OPENSSL_LH_get_down_load; - OPENSSL_LH_insert; - OPENSSL_LH_new; - OPENSSL_LH_node_stats; - OPENSSL_LH_node_stats_bio; - OPENSSL_LH_node_usage_stats; - OPENSSL_LH_node_usage_stats_bio; - OPENSSL_LH_num_items; - OPENSSL_LH_retrieve; - OPENSSL_LH_set_down_load; - OPENSSL_LH_stats; - OPENSSL_LH_stats_bio; - OPENSSL_LH_strhash; - OPENSSL_asc2uni; - OPENSSL_atexit; - OPENSSL_buf2hexstr; - OPENSSL_cleanse; - OPENSSL_cleanup; - OPENSSL_config; - OPENSSL_die; - OPENSSL_gmtime; - OPENSSL_gmtime_adj; - OPENSSL_gmtime_diff; - OPENSSL_hexchar2int; - OPENSSL_hexstr2buf; - OPENSSL_init; - OPENSSL_init_crypto; - OPENSSL_isservice; - OPENSSL_issetugid; - OPENSSL_load_builtin_modules; - OPENSSL_memcmp; - OPENSSL_sk_deep_copy; - OPENSSL_sk_delete; - OPENSSL_sk_delete_ptr; - OPENSSL_sk_dup; - OPENSSL_sk_find; - OPENSSL_sk_find_ex; - OPENSSL_sk_free; - OPENSSL_sk_insert; - OPENSSL_sk_is_sorted; - OPENSSL_sk_new; - OPENSSL_sk_new_null; - OPENSSL_sk_num; - OPENSSL_sk_pop; - OPENSSL_sk_pop_free; - OPENSSL_sk_push; - OPENSSL_sk_set; - OPENSSL_sk_set_cmp_func; - OPENSSL_sk_shift; - OPENSSL_sk_sort; - OPENSSL_sk_unshift; - OPENSSL_sk_value; - OPENSSL_sk_zero; - OPENSSL_strlcat; - OPENSSL_strlcpy; - OPENSSL_strnlen; - OPENSSL_thread_stop; - OPENSSL_uni2asc; - OPENSSL_uni2utf8; - OPENSSL_utf82uni; - OTHERNAME_cmp; - OTHERNAME_free; - OTHERNAME_new; - OpenSSL_version; - OpenSSL_version_num; - PBE2PARAM_free; - PBE2PARAM_new; - PBEPARAM_free; - PBEPARAM_new; - PBKDF2PARAM_free; - PBKDF2PARAM_new; - PEM_ASN1_read; - PEM_ASN1_read_bio; - PEM_ASN1_write; - PEM_ASN1_write_bio; - PEM_SignFinal; - PEM_SignInit; - PEM_SignUpdate; - PEM_X509_INFO_read; - PEM_X509_INFO_read_bio; - PEM_X509_INFO_write_bio; - PEM_bytes_read_bio; - PEM_def_callback; - PEM_dek_info; - PEM_do_header; - PEM_get_EVP_CIPHER_INFO; - PEM_proc_type; - PEM_read; - PEM_read_CMS; - PEM_read_DHparams; - PEM_read_DSAPrivateKey; - PEM_read_DSA_PUBKEY; - PEM_read_DSAparams; - PEM_read_ECPKParameters; - PEM_read_ECPrivateKey; - PEM_read_EC_PUBKEY; - PEM_read_NETSCAPE_CERT_SEQUENCE; - PEM_read_PKCS7; - PEM_read_PKCS8; - PEM_read_PKCS8_PRIV_KEY_INFO; - PEM_read_PUBKEY; - PEM_read_PrivateKey; - PEM_read_RSAPrivateKey; - PEM_read_RSAPublicKey; - PEM_read_RSA_PUBKEY; - PEM_read_X509; - PEM_read_X509_AUX; - PEM_read_X509_CRL; - PEM_read_X509_REQ; - PEM_read_bio; - PEM_read_bio_CMS; - PEM_read_bio_DHparams; - PEM_read_bio_DSAPrivateKey; - PEM_read_bio_DSA_PUBKEY; - PEM_read_bio_DSAparams; - PEM_read_bio_ECPKParameters; - PEM_read_bio_ECPrivateKey; - PEM_read_bio_EC_PUBKEY; - PEM_read_bio_NETSCAPE_CERT_SEQUENCE; - PEM_read_bio_PKCS7; - PEM_read_bio_PKCS8; - PEM_read_bio_PKCS8_PRIV_KEY_INFO; - PEM_read_bio_PUBKEY; - PEM_read_bio_Parameters; - PEM_read_bio_PrivateKey; - PEM_read_bio_RSAPrivateKey; - PEM_read_bio_RSAPublicKey; - PEM_read_bio_RSA_PUBKEY; - PEM_read_bio_X509; - PEM_read_bio_X509_AUX; - PEM_read_bio_X509_CRL; - PEM_read_bio_X509_REQ; - PEM_write; - PEM_write_CMS; - PEM_write_DHparams; - PEM_write_DHxparams; - PEM_write_DSAPrivateKey; - PEM_write_DSA_PUBKEY; - PEM_write_DSAparams; - PEM_write_ECPKParameters; - PEM_write_ECPrivateKey; - PEM_write_EC_PUBKEY; - PEM_write_NETSCAPE_CERT_SEQUENCE; - PEM_write_PKCS7; - PEM_write_PKCS8PrivateKey; - PEM_write_PKCS8PrivateKey_nid; - PEM_write_PKCS8; - PEM_write_PKCS8_PRIV_KEY_INFO; - PEM_write_PUBKEY; - PEM_write_PrivateKey; - PEM_write_RSAPrivateKey; - PEM_write_RSAPublicKey; - PEM_write_RSA_PUBKEY; - PEM_write_X509; - PEM_write_X509_AUX; - PEM_write_X509_CRL; - PEM_write_X509_REQ; - PEM_write_X509_REQ_NEW; - PEM_write_bio; - PEM_write_bio_ASN1_stream; - PEM_write_bio_CMS; - PEM_write_bio_CMS_stream; - PEM_write_bio_DHparams; - PEM_write_bio_DHxparams; - PEM_write_bio_DSAPrivateKey; - PEM_write_bio_DSA_PUBKEY; - PEM_write_bio_DSAparams; - PEM_write_bio_ECPKParameters; - PEM_write_bio_ECPrivateKey; - PEM_write_bio_EC_PUBKEY; - PEM_write_bio_NETSCAPE_CERT_SEQUENCE; - PEM_write_bio_PKCS7; - PEM_write_bio_PKCS7_stream; - PEM_write_bio_PKCS8PrivateKey; - PEM_write_bio_PKCS8PrivateKey_nid; - PEM_write_bio_PKCS8; - PEM_write_bio_PKCS8_PRIV_KEY_INFO; - PEM_write_bio_PUBKEY; - PEM_write_bio_Parameters; - PEM_write_bio_PrivateKey; - PEM_write_bio_PrivateKey_traditional; - PEM_write_bio_RSAPrivateKey; - PEM_write_bio_RSAPublicKey; - PEM_write_bio_RSA_PUBKEY; - PEM_write_bio_X509; - PEM_write_bio_X509_AUX; - PEM_write_bio_X509_CRL; - PEM_write_bio_X509_REQ; - PEM_write_bio_X509_REQ_NEW; - PKCS12_BAGS_free; - PKCS12_BAGS_new; - PKCS12_MAC_DATA_free; - PKCS12_MAC_DATA_new; - PKCS12_PBE_add; - PKCS12_PBE_keyivgen; - PKCS12_SAFEBAG_create0_p8inf; - PKCS12_SAFEBAG_create0_pkcs8; - PKCS12_SAFEBAG_create_cert; - PKCS12_SAFEBAG_create_crl; - PKCS12_SAFEBAG_create_pkcs8_encrypt; - PKCS12_SAFEBAG_free; - PKCS12_SAFEBAG_get0_attr; - PKCS12_SAFEBAG_get0_attrs; - PKCS12_SAFEBAG_get0_p8inf; - PKCS12_SAFEBAG_get0_pkcs8; - PKCS12_SAFEBAG_get0_safes; - PKCS12_SAFEBAG_get0_type; - PKCS12_SAFEBAG_get1_cert; - PKCS12_SAFEBAG_get1_crl; - PKCS12_SAFEBAG_get_bag_nid; - PKCS12_SAFEBAG_get_nid; - PKCS12_SAFEBAG_new; - PKCS12_add_CSPName_asc; - PKCS12_add_cert; - PKCS12_add_friendlyname_asc; - PKCS12_add_friendlyname_uni; - PKCS12_add_friendlyname_utf8; - PKCS12_add_key; - PKCS12_add_localkeyid; - PKCS12_add_safe; - PKCS12_add_safes; - PKCS12_create; - PKCS12_decrypt_skey; - PKCS12_free; - PKCS12_gen_mac; - PKCS12_get0_mac; - PKCS12_get_attr; - PKCS12_get_attr_gen; - PKCS12_get_friendlyname; - PKCS12_init; - PKCS12_item_decrypt_d2i; - PKCS12_item_i2d_encrypt; - PKCS12_item_pack_safebag; - PKCS12_key_gen_asc; - PKCS12_key_gen_uni; - PKCS12_key_gen_utf8; - PKCS12_mac_present; - PKCS12_new; - PKCS12_newpass; - PKCS12_pack_authsafes; - PKCS12_pack_p7data; - PKCS12_pack_p7encdata; - PKCS12_parse; - PKCS12_pbe_crypt; - PKCS12_set_mac; - PKCS12_setup_mac; - PKCS12_unpack_authsafes; - PKCS12_unpack_p7data; - PKCS12_unpack_p7encdata; - PKCS12_verify_mac; - PKCS1_MGF1; - PKCS5_PBE_add; - PKCS5_PBE_keyivgen; - PKCS5_PBKDF2_HMAC; - PKCS5_PBKDF2_HMAC_SHA1; - PKCS5_pbe2_set; - PKCS5_pbe2_set_iv; - PKCS5_pbe2_set_scrypt; - PKCS5_pbe_set0_algor; - PKCS5_pbe_set; - PKCS5_pbkdf2_set; - PKCS5_v2_PBE_keyivgen; - PKCS5_v2_scrypt_keyivgen; - PKCS7_DIGEST_free; - PKCS7_DIGEST_new; - PKCS7_ENCRYPT_free; - PKCS7_ENCRYPT_new; - PKCS7_ENC_CONTENT_free; - PKCS7_ENC_CONTENT_new; - PKCS7_ENVELOPE_free; - PKCS7_ENVELOPE_new; - PKCS7_ISSUER_AND_SERIAL_digest; - PKCS7_ISSUER_AND_SERIAL_free; - PKCS7_ISSUER_AND_SERIAL_new; - PKCS7_RECIP_INFO_free; - PKCS7_RECIP_INFO_get0_alg; - PKCS7_RECIP_INFO_new; - PKCS7_RECIP_INFO_set; - PKCS7_SIGNED_free; - PKCS7_SIGNED_new; - PKCS7_SIGNER_INFO_free; - PKCS7_SIGNER_INFO_get0_algs; - PKCS7_SIGNER_INFO_new; - PKCS7_SIGNER_INFO_set; - PKCS7_SIGNER_INFO_sign; - PKCS7_SIGN_ENVELOPE_free; - PKCS7_SIGN_ENVELOPE_new; - PKCS7_add0_attrib_signing_time; - PKCS7_add1_attrib_digest; - PKCS7_add_attrib_content_type; - PKCS7_add_attrib_smimecap; - PKCS7_add_attribute; - PKCS7_add_certificate; - PKCS7_add_crl; - PKCS7_add_recipient; - PKCS7_add_recipient_info; - PKCS7_add_signature; - PKCS7_add_signed_attribute; - PKCS7_add_signer; - PKCS7_cert_from_signer_info; - PKCS7_content_new; - PKCS7_ctrl; - PKCS7_dataDecode; - PKCS7_dataFinal; - PKCS7_dataInit; - PKCS7_dataVerify; - PKCS7_decrypt; - PKCS7_digest_from_attributes; - PKCS7_dup; - PKCS7_encrypt; - PKCS7_final; - PKCS7_free; - PKCS7_get0_signers; - PKCS7_get_attribute; - PKCS7_get_issuer_and_serial; - PKCS7_get_signed_attribute; - PKCS7_get_signer_info; - PKCS7_get_smimecap; - PKCS7_new; - PKCS7_print_ctx; - PKCS7_set0_type_other; - PKCS7_set_attributes; - PKCS7_set_cipher; - PKCS7_set_content; - PKCS7_set_digest; - PKCS7_set_signed_attributes; - PKCS7_set_type; - PKCS7_sign; - PKCS7_sign_add_signer; - PKCS7_signatureVerify; - PKCS7_simple_smimecap; - PKCS7_stream; - PKCS7_to_TS_TST_INFO; - PKCS7_verify; - PKCS8_PRIV_KEY_INFO_free; - PKCS8_PRIV_KEY_INFO_new; - PKCS8_add_keyusage; - PKCS8_decrypt; - PKCS8_encrypt; - PKCS8_get_attr; - PKCS8_pkey_add1_attr_by_NID; - PKCS8_pkey_get0; - PKCS8_pkey_get0_attrs; - PKCS8_pkey_set0; - PKCS8_set0_pbe; - PKEY_USAGE_PERIOD_free; - PKEY_USAGE_PERIOD_new; - POLICYINFO_free; - POLICYINFO_new; - POLICYQUALINFO_free; - POLICYQUALINFO_new; - POLICY_CONSTRAINTS_free; - POLICY_CONSTRAINTS_new; - POLICY_MAPPING_free; - POLICY_MAPPING_new; - PROXY_CERT_INFO_EXTENSION_free; - PROXY_CERT_INFO_EXTENSION_new; - PROXY_POLICY_free; - PROXY_POLICY_new; - RAND_OpenSSL; - RAND_add; - RAND_bytes; - RAND_file_name; - RAND_get_rand_method; - RAND_load_file; - RAND_poll; - RAND_pseudo_bytes; - RAND_seed; - RAND_set_rand_engine; - RAND_set_rand_method; - RAND_status; - RAND_write_file; - RC2_cbc_encrypt; - RC2_cfb64_encrypt; - RC2_decrypt; - RC2_ecb_encrypt; - RC2_encrypt; - RC2_ofb64_encrypt; - RC2_set_key; - RC4; - RC4_options; - RC4_set_key; - RIPEMD160; - RIPEMD160_Final; - RIPEMD160_Init; - RIPEMD160_Transform; - RIPEMD160_Update; - RSAPrivateKey_dup; - RSAPublicKey_dup; - RSA_OAEP_PARAMS_free; - RSA_OAEP_PARAMS_new; - RSA_PKCS1_OpenSSL; - RSA_PSS_PARAMS_free; - RSA_PSS_PARAMS_new; - RSA_X931_derive_ex; - RSA_X931_generate_key_ex; - RSA_X931_hash_id; - RSA_bits; - RSA_blinding_off; - RSA_blinding_on; - RSA_check_key; - RSA_check_key_ex; - RSA_clear_flags; - RSA_flags; - RSA_free; - RSA_generate_key; - RSA_generate_key_ex; - RSA_get0_crt_params; - RSA_get0_engine; - RSA_get0_factors; - RSA_get0_key; - RSA_get_default_method; - RSA_get_ex_data; - RSA_get_method; - RSA_meth_dup; - RSA_meth_free; - RSA_meth_get0_app_data; - RSA_meth_get0_name; - RSA_meth_get_bn_mod_exp; - RSA_meth_get_finish; - RSA_meth_get_flags; - RSA_meth_get_init; - RSA_meth_get_keygen; - RSA_meth_get_mod_exp; - RSA_meth_get_priv_dec; - RSA_meth_get_priv_enc; - RSA_meth_get_pub_dec; - RSA_meth_get_pub_enc; - RSA_meth_get_sign; - RSA_meth_get_verify; - RSA_meth_new; - RSA_meth_set0_app_data; - RSA_meth_set1_name; - RSA_meth_set_bn_mod_exp; - RSA_meth_set_finish; - RSA_meth_set_flags; - RSA_meth_set_init; - RSA_meth_set_keygen; - RSA_meth_set_mod_exp; - RSA_meth_set_priv_dec; - RSA_meth_set_priv_enc; - RSA_meth_set_pub_dec; - RSA_meth_set_pub_enc; - RSA_meth_set_sign; - RSA_meth_set_verify; - RSA_new; - RSA_new_method; - RSA_null_method; - RSA_padding_add_PKCS1_OAEP; - RSA_padding_add_PKCS1_OAEP_mgf1; - RSA_padding_add_PKCS1_PSS; - RSA_padding_add_PKCS1_PSS_mgf1; - RSA_padding_add_PKCS1_type_1; - RSA_padding_add_PKCS1_type_2; - RSA_padding_add_SSLv23; - RSA_padding_add_X931; - RSA_padding_add_none; - RSA_padding_check_PKCS1_OAEP; - RSA_padding_check_PKCS1_OAEP_mgf1; - RSA_padding_check_PKCS1_type_1; - RSA_padding_check_PKCS1_type_2; - RSA_padding_check_SSLv23; - RSA_padding_check_X931; - RSA_padding_check_none; - RSA_print; - RSA_print_fp; - RSA_private_decrypt; - RSA_private_encrypt; - RSA_public_decrypt; - RSA_public_encrypt; - RSA_security_bits; - RSA_set0_crt_params; - RSA_set0_factors; - RSA_set0_key; - RSA_set_default_method; - RSA_set_ex_data; - RSA_set_flags; - RSA_set_method; - RSA_setup_blinding; - RSA_sign; - RSA_sign_ASN1_OCTET_STRING; - RSA_size; - RSA_test_flags; - RSA_up_ref; - RSA_verify; - RSA_verify_ASN1_OCTET_STRING; - RSA_verify_PKCS1_PSS; - RSA_verify_PKCS1_PSS_mgf1; - SCT_LIST_free; - SCT_LIST_print; - SCT_LIST_validate; - SCT_free; - SCT_get0_extensions; - SCT_get0_log_id; - SCT_get0_signature; - SCT_get_log_entry_type; - SCT_get_signature_nid; - SCT_get_source; - SCT_get_timestamp; - SCT_get_validation_status; - SCT_get_version; - SCT_new; - SCT_new_from_base64; - SCT_print; - SCT_set0_extensions; - SCT_set0_log_id; - SCT_set0_signature; - SCT_set1_extensions; - SCT_set1_log_id; - SCT_set1_signature; - SCT_set_log_entry_type; - SCT_set_signature_nid; - SCT_set_source; - SCT_set_timestamp; - SCT_set_version; - SCT_validate; - SCT_validation_status_string; - SEED_cbc_encrypt; - SEED_cfb128_encrypt; - SEED_decrypt; - SEED_ecb_encrypt; - SEED_encrypt; - SEED_ofb128_encrypt; - SEED_set_key; - SHA1; - SHA1_Final; - SHA1_Init; - SHA1_Transform; - SHA1_Update; - SHA224; - SHA224_Final; - SHA224_Init; - SHA224_Update; - SHA256; - SHA256_Final; - SHA256_Init; - SHA256_Transform; - SHA256_Update; - SHA384; - SHA384_Final; - SHA384_Init; - SHA384_Update; - SHA512; - SHA512_Final; - SHA512_Init; - SHA512_Transform; - SHA512_Update; - SMIME_crlf_copy; - SMIME_read_ASN1; - SMIME_read_CMS; - SMIME_read_PKCS7; - SMIME_text; - SMIME_write_ASN1; - SMIME_write_CMS; - SMIME_write_PKCS7; - SRP_Calc_A; - SRP_Calc_B; - SRP_Calc_client_key; - SRP_Calc_server_key; - SRP_Calc_u; - SRP_Calc_x; - SRP_VBASE_free; - SRP_VBASE_get1_by_user; - SRP_VBASE_get_by_user; - SRP_VBASE_init; - SRP_VBASE_new; - SRP_Verify_A_mod_N; - SRP_Verify_B_mod_N; - SRP_check_known_gN_param; - SRP_create_verifier; - SRP_create_verifier_BN; - SRP_get_default_gN; - SRP_user_pwd_free; - SXNETID_free; - SXNETID_new; - SXNET_add_id_INTEGER; - SXNET_add_id_asc; - SXNET_add_id_ulong; - SXNET_free; - SXNET_get_id_INTEGER; - SXNET_get_id_asc; - SXNET_get_id_ulong; - SXNET_new; - TLS_FEATURE_free; - TLS_FEATURE_new; - TS_ACCURACY_dup; - TS_ACCURACY_free; - TS_ACCURACY_get_micros; - TS_ACCURACY_get_millis; - TS_ACCURACY_get_seconds; - TS_ACCURACY_new; - TS_ACCURACY_set_micros; - TS_ACCURACY_set_millis; - TS_ACCURACY_set_seconds; - TS_ASN1_INTEGER_print_bio; - TS_CONF_get_tsa_section; - TS_CONF_load_cert; - TS_CONF_load_certs; - TS_CONF_load_key; - TS_CONF_set_accuracy; - TS_CONF_set_certs; - TS_CONF_set_clock_precision_digits; - TS_CONF_set_crypto_device; - TS_CONF_set_def_policy; - TS_CONF_set_default_engine; - TS_CONF_set_digests; - TS_CONF_set_ess_cert_id_chain; - TS_CONF_set_ordering; - TS_CONF_set_policies; - TS_CONF_set_serial; - TS_CONF_set_signer_cert; - TS_CONF_set_signer_digest; - TS_CONF_set_signer_key; - TS_CONF_set_tsa_name; - TS_MSG_IMPRINT_dup; - TS_MSG_IMPRINT_free; - TS_MSG_IMPRINT_get_algo; - TS_MSG_IMPRINT_get_msg; - TS_MSG_IMPRINT_new; - TS_MSG_IMPRINT_print_bio; - TS_MSG_IMPRINT_set_algo; - TS_MSG_IMPRINT_set_msg; - TS_OBJ_print_bio; - TS_REQ_add_ext; - TS_REQ_delete_ext; - TS_REQ_dup; - TS_REQ_ext_free; - TS_REQ_free; - TS_REQ_get_cert_req; - TS_REQ_get_ext; - TS_REQ_get_ext_by_NID; - TS_REQ_get_ext_by_OBJ; - TS_REQ_get_ext_by_critical; - TS_REQ_get_ext_count; - TS_REQ_get_ext_d2i; - TS_REQ_get_exts; - TS_REQ_get_msg_imprint; - TS_REQ_get_nonce; - TS_REQ_get_policy_id; - TS_REQ_get_version; - TS_REQ_new; - TS_REQ_print_bio; - TS_REQ_set_cert_req; - TS_REQ_set_msg_imprint; - TS_REQ_set_nonce; - TS_REQ_set_policy_id; - TS_REQ_set_version; - TS_REQ_to_TS_VERIFY_CTX; - TS_RESP_CTX_add_failure_info; - TS_RESP_CTX_add_flags; - TS_RESP_CTX_add_md; - TS_RESP_CTX_add_policy; - TS_RESP_CTX_free; - TS_RESP_CTX_get_request; - TS_RESP_CTX_get_tst_info; - TS_RESP_CTX_new; - TS_RESP_CTX_set_accuracy; - TS_RESP_CTX_set_certs; - TS_RESP_CTX_set_clock_precision_digits; - TS_RESP_CTX_set_def_policy; - TS_RESP_CTX_set_extension_cb; - TS_RESP_CTX_set_serial_cb; - TS_RESP_CTX_set_signer_cert; - TS_RESP_CTX_set_signer_digest; - TS_RESP_CTX_set_signer_key; - TS_RESP_CTX_set_status_info; - TS_RESP_CTX_set_status_info_cond; - TS_RESP_CTX_set_time_cb; - TS_RESP_create_response; - TS_RESP_dup; - TS_RESP_free; - TS_RESP_get_status_info; - TS_RESP_get_token; - TS_RESP_get_tst_info; - TS_RESP_new; - TS_RESP_print_bio; - TS_RESP_set_status_info; - TS_RESP_set_tst_info; - TS_RESP_verify_response; - TS_RESP_verify_signature; - TS_RESP_verify_token; - TS_STATUS_INFO_dup; - TS_STATUS_INFO_free; - TS_STATUS_INFO_get0_failure_info; - TS_STATUS_INFO_get0_status; - TS_STATUS_INFO_get0_text; - TS_STATUS_INFO_new; - TS_STATUS_INFO_print_bio; - TS_STATUS_INFO_set_status; - TS_TST_INFO_add_ext; - TS_TST_INFO_delete_ext; - TS_TST_INFO_dup; - TS_TST_INFO_ext_free; - TS_TST_INFO_free; - TS_TST_INFO_get_accuracy; - TS_TST_INFO_get_ext; - TS_TST_INFO_get_ext_by_NID; - TS_TST_INFO_get_ext_by_OBJ; - TS_TST_INFO_get_ext_by_critical; - TS_TST_INFO_get_ext_count; - TS_TST_INFO_get_ext_d2i; - TS_TST_INFO_get_exts; - TS_TST_INFO_get_msg_imprint; - TS_TST_INFO_get_nonce; - TS_TST_INFO_get_ordering; - TS_TST_INFO_get_policy_id; - TS_TST_INFO_get_serial; - TS_TST_INFO_get_time; - TS_TST_INFO_get_tsa; - TS_TST_INFO_get_version; - TS_TST_INFO_new; - TS_TST_INFO_print_bio; - TS_TST_INFO_set_accuracy; - TS_TST_INFO_set_msg_imprint; - TS_TST_INFO_set_nonce; - TS_TST_INFO_set_ordering; - TS_TST_INFO_set_policy_id; - TS_TST_INFO_set_serial; - TS_TST_INFO_set_time; - TS_TST_INFO_set_tsa; - TS_TST_INFO_set_version; - TS_VERIFY_CTS_set_certs; - TS_VERIFY_CTX_add_flags; - TS_VERIFY_CTX_cleanup; - TS_VERIFY_CTX_free; - TS_VERIFY_CTX_init; - TS_VERIFY_CTX_new; - TS_VERIFY_CTX_set_data; - TS_VERIFY_CTX_set_flags; - TS_VERIFY_CTX_set_imprint; - TS_VERIFY_CTX_set_store; - TS_X509_ALGOR_print_bio; - TS_ext_print_bio; - TXT_DB_create_index; - TXT_DB_free; - TXT_DB_get_by_index; - TXT_DB_insert; - TXT_DB_read; - TXT_DB_write; - UI_OpenSSL; - UI_UTIL_read_pw; - UI_UTIL_read_pw_string; - UI_add_error_string; - UI_add_info_string; - UI_add_input_boolean; - UI_add_input_string; - UI_add_user_data; - UI_add_verify_string; - UI_construct_prompt; - UI_create_method; - UI_ctrl; - UI_destroy_method; - UI_dup_error_string; - UI_dup_info_string; - UI_dup_input_boolean; - UI_dup_input_string; - UI_dup_verify_string; - UI_free; - UI_get0_action_string; - UI_get0_output_string; - UI_get0_result; - UI_get0_result_string; - UI_get0_test_string; - UI_get0_user_data; - UI_get_default_method; - UI_get_ex_data; - UI_get_input_flags; - UI_get_method; - UI_get_result_maxsize; - UI_get_result_minsize; - UI_get_string_type; - UI_method_get_closer; - UI_method_get_flusher; - UI_method_get_opener; - UI_method_get_prompt_constructor; - UI_method_get_reader; - UI_method_get_writer; - UI_method_set_closer; - UI_method_set_flusher; - UI_method_set_opener; - UI_method_set_prompt_constructor; - UI_method_set_reader; - UI_method_set_writer; - UI_new; - UI_new_method; - UI_process; - UI_set_default_method; - UI_set_ex_data; - UI_set_method; - UI_set_result; - USERNOTICE_free; - USERNOTICE_new; - UTF8_getc; - UTF8_putc; - WHIRLPOOL; - WHIRLPOOL_BitUpdate; - WHIRLPOOL_Final; - WHIRLPOOL_Init; - WHIRLPOOL_Update; - X509V3_EXT_CRL_add_conf; - X509V3_EXT_CRL_add_nconf; - X509V3_EXT_REQ_add_conf; - X509V3_EXT_REQ_add_nconf; - X509V3_EXT_add; - X509V3_EXT_add_alias; - X509V3_EXT_add_conf; - X509V3_EXT_add_list; - X509V3_EXT_add_nconf; - X509V3_EXT_add_nconf_sk; - X509V3_EXT_cleanup; - X509V3_EXT_conf; - X509V3_EXT_conf_nid; - X509V3_EXT_d2i; - X509V3_EXT_get; - X509V3_EXT_get_nid; - X509V3_EXT_i2d; - X509V3_EXT_nconf; - X509V3_EXT_nconf_nid; - X509V3_EXT_print; - X509V3_EXT_print_fp; - X509V3_EXT_val_prn; - X509V3_NAME_from_section; - X509V3_add1_i2d; - X509V3_add_standard_extensions; - X509V3_add_value; - X509V3_add_value_bool; - X509V3_add_value_bool_nf; - X509V3_add_value_int; - X509V3_add_value_uchar; - X509V3_conf_free; - X509V3_extensions_print; - X509V3_get_d2i; - X509V3_get_section; - X509V3_get_string; - X509V3_get_value_bool; - X509V3_get_value_int; - X509V3_parse_list; - X509V3_section_free; - X509V3_set_conf_lhash; - X509V3_set_ctx; - X509V3_set_nconf; - X509V3_string_free; - X509_ALGOR_cmp; - X509_ALGOR_dup; - X509_ALGOR_free; - X509_ALGOR_get0; - X509_ALGOR_new; - X509_ALGOR_set0; - X509_ALGOR_set_md; - X509_ATTRIBUTE_count; - X509_ATTRIBUTE_create; - X509_ATTRIBUTE_create_by_NID; - X509_ATTRIBUTE_create_by_OBJ; - X509_ATTRIBUTE_create_by_txt; - X509_ATTRIBUTE_dup; - X509_ATTRIBUTE_free; - X509_ATTRIBUTE_get0_data; - X509_ATTRIBUTE_get0_object; - X509_ATTRIBUTE_get0_type; - X509_ATTRIBUTE_new; - X509_ATTRIBUTE_set1_data; - X509_ATTRIBUTE_set1_object; - X509_CERT_AUX_free; - X509_CERT_AUX_new; - X509_CINF_free; - X509_CINF_new; - X509_CRL_INFO_free; - X509_CRL_INFO_new; - X509_CRL_METHOD_free; - X509_CRL_METHOD_new; - X509_CRL_add0_revoked; - X509_CRL_add1_ext_i2d; - X509_CRL_add_ext; - X509_CRL_check_suiteb; - X509_CRL_cmp; - X509_CRL_delete_ext; - X509_CRL_diff; - X509_CRL_digest; - X509_CRL_dup; - X509_CRL_free; - X509_CRL_get0_by_cert; - X509_CRL_get0_by_serial; - X509_CRL_get0_extensions; - X509_CRL_get0_lastUpdate; - X509_CRL_get0_nextUpdate; - X509_CRL_get0_signature; - X509_CRL_get_REVOKED; - X509_CRL_get_ext; - X509_CRL_get_ext_by_NID; - X509_CRL_get_ext_by_OBJ; - X509_CRL_get_ext_by_critical; - X509_CRL_get_ext_count; - X509_CRL_get_ext_d2i; - X509_CRL_get_issuer; - X509_CRL_get_lastUpdate; - X509_CRL_get_meth_data; - X509_CRL_get_nextUpdate; - X509_CRL_get_signature_nid; - X509_CRL_get_version; - X509_CRL_http_nbio; - X509_CRL_match; - X509_CRL_new; - X509_CRL_print; - X509_CRL_print_fp; - X509_CRL_set1_lastUpdate; - X509_CRL_set1_nextUpdate; - X509_CRL_set_default_method; - X509_CRL_set_issuer_name; - X509_CRL_set_meth_data; - X509_CRL_set_version; - X509_CRL_sign; - X509_CRL_sign_ctx; - X509_CRL_sort; - X509_CRL_up_ref; - X509_CRL_verify; - X509_EXTENSION_create_by_NID; - X509_EXTENSION_create_by_OBJ; - X509_EXTENSION_dup; - X509_EXTENSION_free; - X509_EXTENSION_get_critical; - X509_EXTENSION_get_data; - X509_EXTENSION_get_object; - X509_EXTENSION_new; - X509_EXTENSION_set_critical; - X509_EXTENSION_set_data; - X509_EXTENSION_set_object; - X509_INFO_free; - X509_INFO_new; - X509_LOOKUP_by_alias; - X509_LOOKUP_by_fingerprint; - X509_LOOKUP_by_issuer_serial; - X509_LOOKUP_by_subject; - X509_LOOKUP_ctrl; - X509_LOOKUP_file; - X509_LOOKUP_free; - X509_LOOKUP_hash_dir; - X509_LOOKUP_init; - X509_LOOKUP_new; - X509_LOOKUP_shutdown; - X509_NAME_ENTRY_create_by_NID; - X509_NAME_ENTRY_create_by_OBJ; - X509_NAME_ENTRY_create_by_txt; - X509_NAME_ENTRY_dup; - X509_NAME_ENTRY_free; - X509_NAME_ENTRY_get_data; - X509_NAME_ENTRY_get_object; - X509_NAME_ENTRY_new; - X509_NAME_ENTRY_set; - X509_NAME_ENTRY_set_data; - X509_NAME_ENTRY_set_object; - X509_NAME_add_entry; - X509_NAME_add_entry_by_NID; - X509_NAME_add_entry_by_OBJ; - X509_NAME_add_entry_by_txt; - X509_NAME_cmp; - X509_NAME_delete_entry; - X509_NAME_digest; - X509_NAME_dup; - X509_NAME_entry_count; - X509_NAME_free; - X509_NAME_get0_der; - X509_NAME_get_entry; - X509_NAME_get_index_by_NID; - X509_NAME_get_index_by_OBJ; - X509_NAME_get_text_by_NID; - X509_NAME_get_text_by_OBJ; - X509_NAME_hash; - X509_NAME_hash_old; - X509_NAME_new; - X509_NAME_oneline; - X509_NAME_print; - X509_NAME_print_ex; - X509_NAME_print_ex_fp; - X509_NAME_set; - X509_OBJECT_free; - X509_OBJECT_get0_X509; - X509_OBJECT_get0_X509_CRL; - X509_OBJECT_get_type; - X509_OBJECT_idx_by_subject; - X509_OBJECT_new; - X509_OBJECT_retrieve_by_subject; - X509_OBJECT_retrieve_match; - X509_OBJECT_up_ref_count; - X509_PKEY_free; - X509_PKEY_new; - X509_POLICY_NODE_print; - X509_PUBKEY_free; - X509_PUBKEY_get0; - X509_PUBKEY_get0_param; - X509_PUBKEY_get; - X509_PUBKEY_new; - X509_PUBKEY_set0_param; - X509_PUBKEY_set; - X509_PURPOSE_add; - X509_PURPOSE_cleanup; - X509_PURPOSE_get0; - X509_PURPOSE_get0_name; - X509_PURPOSE_get0_sname; - X509_PURPOSE_get_by_id; - X509_PURPOSE_get_by_sname; - X509_PURPOSE_get_count; - X509_PURPOSE_get_id; - X509_PURPOSE_get_trust; - X509_PURPOSE_set; - X509_REQ_INFO_free; - X509_REQ_INFO_new; - X509_REQ_add1_attr; - X509_REQ_add1_attr_by_NID; - X509_REQ_add1_attr_by_OBJ; - X509_REQ_add1_attr_by_txt; - X509_REQ_add_extensions; - X509_REQ_add_extensions_nid; - X509_REQ_check_private_key; - X509_REQ_delete_attr; - X509_REQ_digest; - X509_REQ_dup; - X509_REQ_extension_nid; - X509_REQ_free; - X509_REQ_get0_pubkey; - X509_REQ_get0_signature; - X509_REQ_get1_email; - X509_REQ_get_X509_PUBKEY; - X509_REQ_get_attr; - X509_REQ_get_attr_by_NID; - X509_REQ_get_attr_by_OBJ; - X509_REQ_get_attr_count; - X509_REQ_get_extension_nids; - X509_REQ_get_extensions; - X509_REQ_get_pubkey; - X509_REQ_get_signature_nid; - X509_REQ_get_subject_name; - X509_REQ_get_version; - X509_REQ_new; - X509_REQ_print; - X509_REQ_print_ex; - X509_REQ_print_fp; - X509_REQ_set_extension_nids; - X509_REQ_set_pubkey; - X509_REQ_set_subject_name; - X509_REQ_set_version; - X509_REQ_sign; - X509_REQ_sign_ctx; - X509_REQ_to_X509; - X509_REQ_verify; - X509_REVOKED_add1_ext_i2d; - X509_REVOKED_add_ext; - X509_REVOKED_delete_ext; - X509_REVOKED_dup; - X509_REVOKED_free; - X509_REVOKED_get0_extensions; - X509_REVOKED_get0_revocationDate; - X509_REVOKED_get0_serialNumber; - X509_REVOKED_get_ext; - X509_REVOKED_get_ext_by_NID; - X509_REVOKED_get_ext_by_OBJ; - X509_REVOKED_get_ext_by_critical; - X509_REVOKED_get_ext_count; - X509_REVOKED_get_ext_d2i; - X509_REVOKED_new; - X509_REVOKED_set_revocationDate; - X509_REVOKED_set_serialNumber; - X509_SIG_free; - X509_SIG_get0; - X509_SIG_getm; - X509_SIG_new; - X509_STORE_CTX_cleanup; - X509_STORE_CTX_free; - X509_STORE_CTX_get0_cert; - X509_STORE_CTX_get0_chain; - X509_STORE_CTX_get0_current_crl; - X509_STORE_CTX_get0_current_issuer; - X509_STORE_CTX_get0_param; - X509_STORE_CTX_get0_parent_ctx; - X509_STORE_CTX_get0_policy_tree; - X509_STORE_CTX_get0_store; - X509_STORE_CTX_get0_untrusted; - X509_STORE_CTX_get1_certs; - X509_STORE_CTX_get1_chain; - X509_STORE_CTX_get1_crls; - X509_STORE_CTX_get1_issuer; - X509_STORE_CTX_get_by_subject; - X509_STORE_CTX_get_cert_crl; - X509_STORE_CTX_get_check_crl; - X509_STORE_CTX_get_check_issued; - X509_STORE_CTX_get_check_policy; - X509_STORE_CTX_get_check_revocation; - X509_STORE_CTX_get_cleanup; - X509_STORE_CTX_get_current_cert; - X509_STORE_CTX_get_error; - X509_STORE_CTX_get_error_depth; - X509_STORE_CTX_get_ex_data; - X509_STORE_CTX_get_explicit_policy; - X509_STORE_CTX_get_get_crl; - X509_STORE_CTX_get_get_issuer; - X509_STORE_CTX_get_lookup_certs; - X509_STORE_CTX_get_lookup_crls; - X509_STORE_CTX_get_num_untrusted; - X509_STORE_CTX_get_obj_by_subject; - X509_STORE_CTX_get_verify; - X509_STORE_CTX_get_verify_cb; - X509_STORE_CTX_init; - X509_STORE_CTX_new; - X509_STORE_CTX_purpose_inherit; - X509_STORE_CTX_set0_crls; - X509_STORE_CTX_set0_dane; - X509_STORE_CTX_set0_param; - X509_STORE_CTX_set0_trusted_stack; - X509_STORE_CTX_set0_untrusted; - X509_STORE_CTX_set0_verified_chain; - X509_STORE_CTX_set_cert; - X509_STORE_CTX_set_current_cert; - X509_STORE_CTX_set_default; - X509_STORE_CTX_set_depth; - X509_STORE_CTX_set_error; - X509_STORE_CTX_set_error_depth; - X509_STORE_CTX_set_ex_data; - X509_STORE_CTX_set_flags; - X509_STORE_CTX_set_purpose; - X509_STORE_CTX_set_time; - X509_STORE_CTX_set_trust; - X509_STORE_CTX_set_verify; - X509_STORE_CTX_set_verify_cb; - X509_STORE_add_cert; - X509_STORE_add_crl; - X509_STORE_add_lookup; - X509_STORE_free; - X509_STORE_get0_objects; - X509_STORE_get0_param; - X509_STORE_get_cert_crl; - X509_STORE_get_check_crl; - X509_STORE_get_check_issued; - X509_STORE_get_check_policy; - X509_STORE_get_check_revocation; - X509_STORE_get_cleanup; - X509_STORE_get_ex_data; - X509_STORE_get_get_crl; - X509_STORE_get_get_issuer; - X509_STORE_get_lookup_certs; - X509_STORE_get_lookup_crls; - X509_STORE_get_verify; - X509_STORE_get_verify_cb; - X509_STORE_load_locations; - X509_STORE_lock; - X509_STORE_new; - X509_STORE_set1_param; - X509_STORE_set_cert_crl; - X509_STORE_set_check_crl; - X509_STORE_set_check_issued; - X509_STORE_set_check_policy; - X509_STORE_set_check_revocation; - X509_STORE_set_cleanup; - X509_STORE_set_default_paths; - X509_STORE_set_depth; - X509_STORE_set_ex_data; - X509_STORE_set_flags; - X509_STORE_set_get_crl; - X509_STORE_set_get_issuer; - X509_STORE_set_lookup_certs; - X509_STORE_set_lookup_crls; - X509_STORE_set_purpose; - X509_STORE_set_trust; - X509_STORE_set_verify; - X509_STORE_set_verify_cb; - X509_STORE_unlock; - X509_STORE_up_ref; - X509_TRUST_add; - X509_TRUST_cleanup; - X509_TRUST_get0; - X509_TRUST_get0_name; - X509_TRUST_get_by_id; - X509_TRUST_get_count; - X509_TRUST_get_flags; - X509_TRUST_get_trust; - X509_TRUST_set; - X509_TRUST_set_default; - X509_VAL_free; - X509_VAL_new; - X509_VERIFY_PARAM_add0_policy; - X509_VERIFY_PARAM_add0_table; - X509_VERIFY_PARAM_add1_host; - X509_VERIFY_PARAM_clear_flags; - X509_VERIFY_PARAM_free; - X509_VERIFY_PARAM_get0; - X509_VERIFY_PARAM_get0_name; - X509_VERIFY_PARAM_get0_peername; - X509_VERIFY_PARAM_get_auth_level; - X509_VERIFY_PARAM_get_count; - X509_VERIFY_PARAM_get_depth; - X509_VERIFY_PARAM_get_flags; - X509_VERIFY_PARAM_inherit; - X509_VERIFY_PARAM_lookup; - X509_VERIFY_PARAM_move_peername; - X509_VERIFY_PARAM_new; - X509_VERIFY_PARAM_set1; - X509_VERIFY_PARAM_set1_email; - X509_VERIFY_PARAM_set1_host; - X509_VERIFY_PARAM_set1_ip; - X509_VERIFY_PARAM_set1_ip_asc; - X509_VERIFY_PARAM_set1_name; - X509_VERIFY_PARAM_set1_policies; - X509_VERIFY_PARAM_set_auth_level; - X509_VERIFY_PARAM_set_depth; - X509_VERIFY_PARAM_set_flags; - X509_VERIFY_PARAM_set_hostflags; - X509_VERIFY_PARAM_set_purpose; - X509_VERIFY_PARAM_set_time; - X509_VERIFY_PARAM_set_trust; - X509_VERIFY_PARAM_table_cleanup; - X509_add1_ext_i2d; - X509_add1_reject_object; - X509_add1_trust_object; - X509_add_ext; - X509_alias_get0; - X509_alias_set1; - X509_aux_print; - X509_certificate_type; - X509_chain_check_suiteb; - X509_chain_up_ref; - X509_check_akid; - X509_check_ca; - X509_check_email; - X509_check_host; - X509_check_ip; - X509_check_ip_asc; - X509_check_issued; - X509_check_private_key; - X509_check_purpose; - X509_check_trust; - X509_cmp; - X509_cmp_current_time; - X509_cmp_time; - X509_delete_ext; - X509_digest; - X509_dup; - X509_email_free; - X509_find_by_issuer_and_serial; - X509_find_by_subject; - X509_free; - X509_get0_extensions; - X509_get0_notAfter; - X509_get0_notBefore; - X509_get0_pubkey; - X509_get0_pubkey_bitstr; - X509_get0_reject_objects; - X509_get0_serialNumber; - X509_get0_signature; - X509_get0_subject_key_id; - X509_get0_tbs_sigalg; - X509_get0_trust_objects; - X509_get0_uids; - X509_get1_email; - X509_get1_ocsp; - X509_get_X509_PUBKEY; - X509_get_default_cert_area; - X509_get_default_cert_dir; - X509_get_default_cert_dir_env; - X509_get_default_cert_file; - X509_get_default_cert_file_env; - X509_get_default_private_dir; - X509_get_ex_data; - X509_get_ext; - X509_get_ext_by_NID; - X509_get_ext_by_OBJ; - X509_get_ext_by_critical; - X509_get_ext_count; - X509_get_ext_d2i; - X509_get_extended_key_usage; - X509_get_extension_flags; - X509_get_issuer_name; - X509_get_key_usage; - X509_get_pathlen; - X509_get_proxy_pathlen; - X509_get_pubkey; - X509_get_pubkey_parameters; - X509_get_serialNumber; - X509_get_signature_nid; - X509_get_signature_type; - X509_get_subject_name; - X509_get_version; - X509_getm_notAfter; - X509_getm_notBefore; - X509_gmtime_adj; - X509_http_nbio; - X509_issuer_and_serial_cmp; - X509_issuer_and_serial_hash; - X509_issuer_name_cmp; - X509_issuer_name_hash; - X509_issuer_name_hash_old; - X509_keyid_get0; - X509_keyid_set1; - X509_load_cert_crl_file; - X509_load_cert_file; - X509_load_crl_file; - X509_new; - X509_ocspid_print; - X509_policy_check; - X509_policy_level_get0_node; - X509_policy_level_node_count; - X509_policy_node_get0_parent; - X509_policy_node_get0_policy; - X509_policy_node_get0_qualifiers; - X509_policy_tree_free; - X509_policy_tree_get0_level; - X509_policy_tree_get0_policies; - X509_policy_tree_get0_user_policies; - X509_policy_tree_level_count; - X509_print; - X509_print_ex; - X509_print_ex_fp; - X509_print_fp; - X509_pubkey_digest; - X509_reject_clear; - X509_set1_notAfter; - X509_set1_notBefore; - X509_set_ex_data; - X509_set_issuer_name; - X509_set_proxy_flag; - X509_set_proxy_pathlen; - X509_set_pubkey; - X509_set_serialNumber; - X509_set_subject_name; - X509_set_version; - X509_sign; - X509_sign_ctx; - X509_signature_dump; - X509_signature_print; - X509_subject_name_cmp; - X509_subject_name_hash; - X509_subject_name_hash_old; - X509_supported_extension; - X509_time_adj; - X509_time_adj_ex; - X509_to_X509_REQ; - X509_trust_clear; - X509_trusted; - X509_up_ref; - X509_verify; - X509_verify_cert; - X509_verify_cert_error_string; - X509at_add1_attr; - X509at_add1_attr_by_NID; - X509at_add1_attr_by_OBJ; - X509at_add1_attr_by_txt; - X509at_delete_attr; - X509at_get0_data_by_OBJ; - X509at_get_attr; - X509at_get_attr_by_NID; - X509at_get_attr_by_OBJ; - X509at_get_attr_count; - X509v3_add_ext; - X509v3_addr_add_inherit; - X509v3_addr_add_prefix; - X509v3_addr_add_range; - X509v3_addr_canonize; - X509v3_addr_get_afi; - X509v3_addr_get_range; - X509v3_addr_inherits; - X509v3_addr_is_canonical; - X509v3_addr_subset; - X509v3_addr_validate_path; - X509v3_addr_validate_resource_set; - X509v3_asid_add_id_or_range; - X509v3_asid_add_inherit; - X509v3_asid_canonize; - X509v3_asid_inherits; - X509v3_asid_is_canonical; - X509v3_asid_subset; - X509v3_asid_validate_path; - X509v3_asid_validate_resource_set; - X509v3_delete_ext; - X509v3_get_ext; - X509v3_get_ext_by_NID; - X509v3_get_ext_by_OBJ; - X509v3_get_ext_by_critical; - X509v3_get_ext_count; - a2d_ASN1_OBJECT; - a2i_ASN1_ENUMERATED; - a2i_ASN1_INTEGER; - a2i_ASN1_STRING; - a2i_GENERAL_NAME; - a2i_IPADDRESS; - a2i_IPADDRESS_NC; - b2i_PVK_bio; - b2i_PrivateKey; - b2i_PrivateKey_bio; - b2i_PublicKey; - b2i_PublicKey_bio; - d2i_ACCESS_DESCRIPTION; - d2i_ASIdOrRange; - d2i_ASIdentifierChoice; - d2i_ASIdentifiers; - d2i_ASN1_BIT_STRING; - d2i_ASN1_BMPSTRING; - d2i_ASN1_ENUMERATED; - d2i_ASN1_GENERALIZEDTIME; - d2i_ASN1_GENERALSTRING; - d2i_ASN1_IA5STRING; - d2i_ASN1_INTEGER; - d2i_ASN1_NULL; - d2i_ASN1_OBJECT; - d2i_ASN1_OCTET_STRING; - d2i_ASN1_PRINTABLESTRING; - d2i_ASN1_PRINTABLE; - d2i_ASN1_SEQUENCE_ANY; - d2i_ASN1_SET_ANY; - d2i_ASN1_T61STRING; - d2i_ASN1_TIME; - d2i_ASN1_TYPE; - d2i_ASN1_UINTEGER; - d2i_ASN1_UNIVERSALSTRING; - d2i_ASN1_UTCTIME; - d2i_ASN1_UTF8STRING; - d2i_ASN1_VISIBLESTRING; - d2i_ASRange; - d2i_AUTHORITY_INFO_ACCESS; - d2i_AUTHORITY_KEYID; - d2i_AutoPrivateKey; - d2i_BASIC_CONSTRAINTS; - d2i_CERTIFICATEPOLICIES; - d2i_CMS_ContentInfo; - d2i_CMS_ReceiptRequest; - d2i_CMS_bio; - d2i_CRL_DIST_POINTS; - d2i_DHparams; - d2i_DHxparams; - d2i_DIRECTORYSTRING; - d2i_DISPLAYTEXT; - d2i_DIST_POINT; - d2i_DIST_POINT_NAME; - d2i_DSAPrivateKey; - d2i_DSAPrivateKey_bio; - d2i_DSAPrivateKey_fp; - d2i_DSAPublicKey; - d2i_DSA_PUBKEY; - d2i_DSA_PUBKEY_bio; - d2i_DSA_PUBKEY_fp; - d2i_DSA_SIG; - d2i_DSAparams; - d2i_ECDSA_SIG; - d2i_ECPKParameters; - d2i_ECParameters; - d2i_ECPrivateKey; - d2i_ECPrivateKey_bio; - d2i_ECPrivateKey_fp; - d2i_EC_PUBKEY; - d2i_EC_PUBKEY_bio; - d2i_EC_PUBKEY_fp; - d2i_EDIPARTYNAME; - d2i_ESS_CERT_ID; - d2i_ESS_ISSUER_SERIAL; - d2i_ESS_SIGNING_CERT; - d2i_EXTENDED_KEY_USAGE; - d2i_GENERAL_NAMES; - d2i_GENERAL_NAME; - d2i_IPAddressChoice; - d2i_IPAddressFamily; - d2i_IPAddressOrRange; - d2i_IPAddressRange; - d2i_ISSUING_DIST_POINT; - d2i_NETSCAPE_CERT_SEQUENCE; - d2i_NETSCAPE_SPKAC; - d2i_NETSCAPE_SPKI; - d2i_NOTICEREF; - d2i_OCSP_BASICRESP; - d2i_OCSP_CERTID; - d2i_OCSP_CERTSTATUS; - d2i_OCSP_CRLID; - d2i_OCSP_ONEREQ; - d2i_OCSP_REQINFO; - d2i_OCSP_REQUEST; - d2i_OCSP_RESPBYTES; - d2i_OCSP_RESPDATA; - d2i_OCSP_RESPID; - d2i_OCSP_RESPONSE; - d2i_OCSP_REVOKEDINFO; - d2i_OCSP_SERVICELOC; - d2i_OCSP_SIGNATURE; - d2i_OCSP_SINGLERESP; - d2i_OTHERNAME; - d2i_PBE2PARAM; - d2i_PBEPARAM; - d2i_PBKDF2PARAM; - d2i_PKCS12; - d2i_PKCS12_BAGS; - d2i_PKCS12_MAC_DATA; - d2i_PKCS12_SAFEBAG; - d2i_PKCS12_bio; - d2i_PKCS12_fp; - d2i_PKCS7; - d2i_PKCS7_DIGEST; - d2i_PKCS7_ENCRYPT; - d2i_PKCS7_ENC_CONTENT; - d2i_PKCS7_ENVELOPE; - d2i_PKCS7_ISSUER_AND_SERIAL; - d2i_PKCS7_RECIP_INFO; - d2i_PKCS7_SIGNED; - d2i_PKCS7_SIGNER_INFO; - d2i_PKCS7_SIGN_ENVELOPE; - d2i_PKCS7_bio; - d2i_PKCS7_fp; - d2i_PKCS8PrivateKey_bio; - d2i_PKCS8PrivateKey_fp; - d2i_PKCS8_PRIV_KEY_INFO; - d2i_PKCS8_PRIV_KEY_INFO_bio; - d2i_PKCS8_PRIV_KEY_INFO_fp; - d2i_PKCS8_bio; - d2i_PKCS8_fp; - d2i_PKEY_USAGE_PERIOD; - d2i_POLICYINFO; - d2i_POLICYQUALINFO; - d2i_PROXY_CERT_INFO_EXTENSION; - d2i_PROXY_POLICY; - d2i_PUBKEY; - d2i_PUBKEY_bio; - d2i_PUBKEY_fp; - d2i_PrivateKey; - d2i_PrivateKey_bio; - d2i_PrivateKey_fp; - d2i_PublicKey; - d2i_RSAPrivateKey; - d2i_RSAPrivateKey_bio; - d2i_RSAPrivateKey_fp; - d2i_RSAPublicKey; - d2i_RSAPublicKey_bio; - d2i_RSAPublicKey_fp; - d2i_RSA_OAEP_PARAMS; - d2i_RSA_PSS_PARAMS; - d2i_RSA_PUBKEY; - d2i_RSA_PUBKEY_bio; - d2i_RSA_PUBKEY_fp; - d2i_SCT_LIST; - d2i_SXNETID; - d2i_SXNET; - d2i_TS_ACCURACY; - d2i_TS_MSG_IMPRINT; - d2i_TS_MSG_IMPRINT_bio; - d2i_TS_MSG_IMPRINT_fp; - d2i_TS_REQ; - d2i_TS_REQ_bio; - d2i_TS_REQ_fp; - d2i_TS_RESP; - d2i_TS_RESP_bio; - d2i_TS_RESP_fp; - d2i_TS_STATUS_INFO; - d2i_TS_TST_INFO; - d2i_TS_TST_INFO_bio; - d2i_TS_TST_INFO_fp; - d2i_USERNOTICE; - d2i_X509; - d2i_X509_ALGORS; - d2i_X509_ALGOR; - d2i_X509_ATTRIBUTE; - d2i_X509_AUX; - d2i_X509_CERT_AUX; - d2i_X509_CINF; - d2i_X509_CRL; - d2i_X509_CRL_INFO; - d2i_X509_CRL_bio; - d2i_X509_CRL_fp; - d2i_X509_EXTENSIONS; - d2i_X509_EXTENSION; - d2i_X509_NAME; - d2i_X509_NAME_ENTRY; - d2i_X509_PUBKEY; - d2i_X509_REQ; - d2i_X509_REQ_INFO; - d2i_X509_REQ_bio; - d2i_X509_REQ_fp; - d2i_X509_REVOKED; - d2i_X509_SIG; - d2i_X509_VAL; - d2i_X509_bio; - d2i_X509_fp; - err_free_strings_int; - i2a_ACCESS_DESCRIPTION; - i2a_ASN1_ENUMERATED; - i2a_ASN1_INTEGER; - i2a_ASN1_OBJECT; - i2a_ASN1_STRING; - i2b_PVK_bio; - i2b_PrivateKey_bio; - i2b_PublicKey_bio; - i2d_ACCESS_DESCRIPTION; - i2d_ASIdOrRange; - i2d_ASIdentifierChoice; - i2d_ASIdentifiers; - i2d_ASN1_BIT_STRING; - i2d_ASN1_BMPSTRING; - i2d_ASN1_ENUMERATED; - i2d_ASN1_GENERALIZEDTIME; - i2d_ASN1_GENERALSTRING; - i2d_ASN1_IA5STRING; - i2d_ASN1_INTEGER; - i2d_ASN1_NULL; - i2d_ASN1_OBJECT; - i2d_ASN1_OCTET_STRING; - i2d_ASN1_PRINTABLESTRING; - i2d_ASN1_PRINTABLE; - i2d_ASN1_SEQUENCE_ANY; - i2d_ASN1_SET_ANY; - i2d_ASN1_T61STRING; - i2d_ASN1_TIME; - i2d_ASN1_TYPE; - i2d_ASN1_UNIVERSALSTRING; - i2d_ASN1_UTCTIME; - i2d_ASN1_UTF8STRING; - i2d_ASN1_VISIBLESTRING; - i2d_ASN1_bio_stream; - i2d_ASRange; - i2d_AUTHORITY_INFO_ACCESS; - i2d_AUTHORITY_KEYID; - i2d_BASIC_CONSTRAINTS; - i2d_CERTIFICATEPOLICIES; - i2d_CMS_ContentInfo; - i2d_CMS_ReceiptRequest; - i2d_CMS_bio; - i2d_CMS_bio_stream; - i2d_CRL_DIST_POINTS; - i2d_DHparams; - i2d_DHxparams; - i2d_DIRECTORYSTRING; - i2d_DISPLAYTEXT; - i2d_DIST_POINT; - i2d_DIST_POINT_NAME; - i2d_DSAPrivateKey; - i2d_DSAPrivateKey_bio; - i2d_DSAPrivateKey_fp; - i2d_DSAPublicKey; - i2d_DSA_PUBKEY; - i2d_DSA_PUBKEY_bio; - i2d_DSA_PUBKEY_fp; - i2d_DSA_SIG; - i2d_DSAparams; - i2d_ECDSA_SIG; - i2d_ECPKParameters; - i2d_ECParameters; - i2d_ECPrivateKey; - i2d_ECPrivateKey_bio; - i2d_ECPrivateKey_fp; - i2d_EC_PUBKEY; - i2d_EC_PUBKEY_bio; - i2d_EC_PUBKEY_fp; - i2d_EDIPARTYNAME; - i2d_ESS_CERT_ID; - i2d_ESS_ISSUER_SERIAL; - i2d_ESS_SIGNING_CERT; - i2d_EXTENDED_KEY_USAGE; - i2d_GENERAL_NAMES; - i2d_GENERAL_NAME; - i2d_IPAddressChoice; - i2d_IPAddressFamily; - i2d_IPAddressOrRange; - i2d_IPAddressRange; - i2d_ISSUING_DIST_POINT; - i2d_NETSCAPE_CERT_SEQUENCE; - i2d_NETSCAPE_SPKAC; - i2d_NETSCAPE_SPKI; - i2d_NOTICEREF; - i2d_OCSP_BASICRESP; - i2d_OCSP_CERTID; - i2d_OCSP_CERTSTATUS; - i2d_OCSP_CRLID; - i2d_OCSP_ONEREQ; - i2d_OCSP_REQINFO; - i2d_OCSP_REQUEST; - i2d_OCSP_RESPBYTES; - i2d_OCSP_RESPDATA; - i2d_OCSP_RESPID; - i2d_OCSP_RESPONSE; - i2d_OCSP_REVOKEDINFO; - i2d_OCSP_SERVICELOC; - i2d_OCSP_SIGNATURE; - i2d_OCSP_SINGLERESP; - i2d_OTHERNAME; - i2d_PBE2PARAM; - i2d_PBEPARAM; - i2d_PBKDF2PARAM; - i2d_PKCS12; - i2d_PKCS12_BAGS; - i2d_PKCS12_MAC_DATA; - i2d_PKCS12_SAFEBAG; - i2d_PKCS12_bio; - i2d_PKCS12_fp; - i2d_PKCS7; - i2d_PKCS7_DIGEST; - i2d_PKCS7_ENCRYPT; - i2d_PKCS7_ENC_CONTENT; - i2d_PKCS7_ENVELOPE; - i2d_PKCS7_ISSUER_AND_SERIAL; - i2d_PKCS7_NDEF; - i2d_PKCS7_RECIP_INFO; - i2d_PKCS7_SIGNED; - i2d_PKCS7_SIGNER_INFO; - i2d_PKCS7_SIGN_ENVELOPE; - i2d_PKCS7_bio; - i2d_PKCS7_bio_stream; - i2d_PKCS7_fp; - i2d_PKCS8PrivateKeyInfo_bio; - i2d_PKCS8PrivateKeyInfo_fp; - i2d_PKCS8PrivateKey_bio; - i2d_PKCS8PrivateKey_fp; - i2d_PKCS8PrivateKey_nid_bio; - i2d_PKCS8PrivateKey_nid_fp; - i2d_PKCS8_PRIV_KEY_INFO; - i2d_PKCS8_PRIV_KEY_INFO_bio; - i2d_PKCS8_PRIV_KEY_INFO_fp; - i2d_PKCS8_bio; - i2d_PKCS8_fp; - i2d_PKEY_USAGE_PERIOD; - i2d_POLICYINFO; - i2d_POLICYQUALINFO; - i2d_PROXY_CERT_INFO_EXTENSION; - i2d_PROXY_POLICY; - i2d_PUBKEY; - i2d_PUBKEY_bio; - i2d_PUBKEY_fp; - i2d_PrivateKey; - i2d_PrivateKey_bio; - i2d_PrivateKey_fp; - i2d_PublicKey; - i2d_RSAPrivateKey; - i2d_RSAPrivateKey_bio; - i2d_RSAPrivateKey_fp; - i2d_RSAPublicKey; - i2d_RSAPublicKey_bio; - i2d_RSAPublicKey_fp; - i2d_RSA_OAEP_PARAMS; - i2d_RSA_PSS_PARAMS; - i2d_RSA_PUBKEY; - i2d_RSA_PUBKEY_bio; - i2d_RSA_PUBKEY_fp; - i2d_SCT_LIST; - i2d_SXNETID; - i2d_SXNET; - i2d_TS_ACCURACY; - i2d_TS_MSG_IMPRINT; - i2d_TS_MSG_IMPRINT_bio; - i2d_TS_MSG_IMPRINT_fp; - i2d_TS_REQ; - i2d_TS_REQ_bio; - i2d_TS_REQ_fp; - i2d_TS_RESP; - i2d_TS_RESP_bio; - i2d_TS_RESP_fp; - i2d_TS_STATUS_INFO; - i2d_TS_TST_INFO; - i2d_TS_TST_INFO_bio; - i2d_TS_TST_INFO_fp; - i2d_USERNOTICE; - i2d_X509; - i2d_X509_ALGORS; - i2d_X509_ALGOR; - i2d_X509_ATTRIBUTE; - i2d_X509_AUX; - i2d_X509_CERT_AUX; - i2d_X509_CINF; - i2d_X509_CRL; - i2d_X509_CRL_INFO; - i2d_X509_CRL_bio; - i2d_X509_CRL_fp; - i2d_X509_EXTENSIONS; - i2d_X509_EXTENSION; - i2d_X509_NAME; - i2d_X509_NAME_ENTRY; - i2d_X509_PUBKEY; - i2d_X509_REQ; - i2d_X509_REQ_INFO; - i2d_X509_REQ_bio; - i2d_X509_REQ_fp; - i2d_X509_REVOKED; - i2d_X509_SIG; - i2d_X509_VAL; - i2d_X509_bio; - i2d_X509_fp; - i2d_re_X509_CRL_tbs; - i2d_re_X509_REQ_tbs; - i2d_re_X509_tbs; - i2o_ECPublicKey; - i2o_SCT; - i2o_SCT_LIST; - i2s_ASN1_ENUMERATED; - i2s_ASN1_ENUMERATED_TABLE; - i2s_ASN1_IA5STRING; - i2s_ASN1_INTEGER; - i2s_ASN1_OCTET_STRING; - i2t_ASN1_OBJECT; - i2v_ASN1_BIT_STRING; - i2v_GENERAL_NAMES; - i2v_GENERAL_NAME; - o2i_ECPublicKey; - o2i_SCT; - o2i_SCT_LIST; - s2i_ASN1_IA5STRING; - s2i_ASN1_INTEGER; - s2i_ASN1_OCTET_STRING; - v2i_ASN1_BIT_STRING; - v2i_GENERAL_NAMES; - v2i_GENERAL_NAME; - v2i_GENERAL_NAME_ex; - ACCESS_DESCRIPTION_it; - ASIdOrRange_it; - ASIdentifierChoice_it; - ASIdentifiers_it; - ASN1_ANY_it; - ASN1_BIT_STRING_it; - ASN1_BMPSTRING_it; - ASN1_BOOLEAN_it; - ASN1_ENUMERATED_it; - ASN1_FBOOLEAN_it; - ASN1_GENERALIZEDTIME_it; - ASN1_GENERALSTRING_it; - ASN1_IA5STRING_it; - ASN1_INTEGER_it; - ASN1_NULL_it; - ASN1_OBJECT_it; - ASN1_OCTET_STRING_NDEF_it; - ASN1_OCTET_STRING_it; - ASN1_PRINTABLESTRING_it; - ASN1_PRINTABLE_it; - ASN1_SEQUENCE_ANY_it; - ASN1_SEQUENCE_it; - ASN1_SET_ANY_it; - ASN1_T61STRING_it; - ASN1_TBOOLEAN_it; - ASN1_TIME_it; - ASN1_UNIVERSALSTRING_it; - ASN1_UTCTIME_it; - ASN1_UTF8STRING_it; - ASN1_VISIBLESTRING_it; - ASRange_it; - AUTHORITY_INFO_ACCESS_it; - AUTHORITY_KEYID_it; - BASIC_CONSTRAINTS_it; - BIGNUM_it; - CBIGNUM_it; - CERTIFICATEPOLICIES_it; - CMS_ContentInfo_it; - CMS_ReceiptRequest_it; - CRL_DIST_POINTS_it; - DHparams_it; - DIRECTORYSTRING_it; - DISPLAYTEXT_it; - DIST_POINT_NAME_it; - DIST_POINT_it; - ECPARAMETERS_it; - ECPKPARAMETERS_it; - EDIPARTYNAME_it; - EXTENDED_KEY_USAGE_it; - GENERAL_NAMES_it; - GENERAL_NAME_it; - GENERAL_SUBTREE_it; - IPAddressChoice_it; - IPAddressFamily_it; - IPAddressOrRange_it; - IPAddressRange_it; - ISSUING_DIST_POINT_it; - LONG_it; - NAME_CONSTRAINTS_it; - NETSCAPE_CERT_SEQUENCE_it; - NETSCAPE_SPKAC_it; - NETSCAPE_SPKI_it; - NOTICEREF_it; - OCSP_BASICRESP_it; - OCSP_CERTID_it; - OCSP_CERTSTATUS_it; - OCSP_CRLID_it; - OCSP_ONEREQ_it; - OCSP_REQINFO_it; - OCSP_REQUEST_it; - OCSP_RESPBYTES_it; - OCSP_RESPDATA_it; - OCSP_RESPID_it; - OCSP_RESPONSE_it; - OCSP_REVOKEDINFO_it; - OCSP_SERVICELOC_it; - OCSP_SIGNATURE_it; - OCSP_SINGLERESP_it; - OTHERNAME_it; - PBE2PARAM_it; - PBEPARAM_it; - PBKDF2PARAM_it; - PKCS12_AUTHSAFES_it; - PKCS12_BAGS_it; - PKCS12_MAC_DATA_it; - PKCS12_SAFEBAGS_it; - PKCS12_SAFEBAG_it; - PKCS12_it; - PKCS7_ATTR_SIGN_it; - PKCS7_ATTR_VERIFY_it; - PKCS7_DIGEST_it; - PKCS7_ENCRYPT_it; - PKCS7_ENC_CONTENT_it; - PKCS7_ENVELOPE_it; - PKCS7_ISSUER_AND_SERIAL_it; - PKCS7_RECIP_INFO_it; - PKCS7_SIGNED_it; - PKCS7_SIGNER_INFO_it; - PKCS7_SIGN_ENVELOPE_it; - PKCS7_it; - PKCS8_PRIV_KEY_INFO_it; - PKEY_USAGE_PERIOD_it; - POLICYINFO_it; - POLICYQUALINFO_it; - POLICY_CONSTRAINTS_it; - POLICY_MAPPINGS_it; - POLICY_MAPPING_it; - PROXY_CERT_INFO_EXTENSION_it; - PROXY_POLICY_it; - RSAPrivateKey_it; - RSAPublicKey_it; - RSA_OAEP_PARAMS_it; - RSA_PSS_PARAMS_it; - SXNETID_it; - SXNET_it; - USERNOTICE_it; - X509_ALGORS_it; - X509_ALGOR_it; - X509_ATTRIBUTE_it; - X509_CERT_AUX_it; - X509_CINF_it; - X509_CRL_INFO_it; - X509_CRL_it; - X509_EXTENSIONS_it; - X509_EXTENSION_it; - X509_NAME_ENTRY_it; - X509_NAME_it; - X509_PUBKEY_it; - X509_REQ_INFO_it; - X509_REQ_it; - X509_REVOKED_it; - X509_SIG_it; - X509_VAL_it; - X509_it; - ZLONG_it; - _shadow_DES_check_key; -}; - -OPENSSL_1_1_0a { - global: - OCSP_RESPID_match; - OCSP_RESPID_set_by_key; - OCSP_RESPID_set_by_name; -} OPENSSL_1_1_0; - -OPENSSL_1_1_0c { - global: - DSO_dsobyaddr; - DSO_pathbyaddr; -} OPENSSL_1_1_0a; - -OPENSSL_1_1_0d { - global: - CT_POLICY_EVAL_CTX_get_time; - CT_POLICY_EVAL_CTX_set_time; - DH_check_params; - X509_VERIFY_PARAM_get_inh_flags; - X509_VERIFY_PARAM_get_time; - X509_VERIFY_PARAM_set_inh_flags; -} OPENSSL_1_1_0c; - -OPENSSL_1_1_0f { - global: - INT32_it; - INT64_it; - UINT32_it; - UINT64_it; - ZINT32_it; - ZINT64_it; - ZUINT32_it; - ZUINT64_it; -} OPENSSL_1_1_0d; - -OPENSSL_1_1_0g { - global: - CRYPTO_secure_clear_free; - EVP_PKEY_set1_engine; -} OPENSSL_1_1_0f; - -OPENSSL_1_1_0h { - global: - OCSP_resp_get0_signer; - X509_get0_authority_key_id; -} OPENSSL_1_1_0g; - -OPENSSL_1_1_0i { - global: - X509_LOOKUP_get_method_data; - X509_LOOKUP_get_store; - X509_LOOKUP_meth_free; - X509_LOOKUP_meth_get_ctrl; - X509_LOOKUP_meth_get_free; - X509_LOOKUP_meth_get_get_by_alias; - X509_LOOKUP_meth_get_get_by_fingerprint; - X509_LOOKUP_meth_get_get_by_issuer_serial; - X509_LOOKUP_meth_get_get_by_subject; - X509_LOOKUP_meth_get_init; - X509_LOOKUP_meth_get_new_item; - X509_LOOKUP_meth_get_shutdown; - X509_LOOKUP_meth_new; - X509_LOOKUP_meth_set_ctrl; - X509_LOOKUP_meth_set_free; - X509_LOOKUP_meth_set_get_by_alias; - X509_LOOKUP_meth_set_get_by_fingerprint; - X509_LOOKUP_meth_set_get_by_issuer_serial; - X509_LOOKUP_meth_set_get_by_subject; - X509_LOOKUP_meth_set_init; - X509_LOOKUP_meth_set_new_item; - X509_LOOKUP_meth_set_shutdown; - X509_LOOKUP_set_method_data; - X509_OBJECT_set1_X509; - X509_OBJECT_set1_X509_CRL; - X509_VERIFY_PARAM_get_hostflags; - conf_ssl_get; - conf_ssl_get_cmd; - conf_ssl_name_find; -} OPENSSL_1_1_0h; - -OPENSSL_1_1_0j { - global: - OCSP_resp_get0_respdata; - OCSP_resp_get0_tbs_sigalg; -} OPENSSL_1_1_0i; - -OPENSSL_1_1_1 { - global: - ADMISSIONS_free; - ADMISSIONS_get0_admissionAuthority; - ADMISSIONS_get0_namingAuthority; - ADMISSIONS_get0_professionInfos; - ADMISSIONS_new; - ADMISSIONS_set0_admissionAuthority; - ADMISSIONS_set0_namingAuthority; - ADMISSIONS_set0_professionInfos; - ADMISSION_SYNTAX_free; - ADMISSION_SYNTAX_get0_admissionAuthority; - ADMISSION_SYNTAX_get0_contentsOfAdmissions; - ADMISSION_SYNTAX_new; - ADMISSION_SYNTAX_set0_admissionAuthority; - ADMISSION_SYNTAX_set0_contentsOfAdmissions; - ASN1_ITEM_get; - ASN1_ITEM_lookup; - ASN1_TIME_cmp_time_t; - ASN1_TIME_compare; - ASN1_TIME_normalize; - ASN1_TIME_set_string_X509; - ASN1_TIME_to_tm; - BIO_bind; - BIO_get_callback_ex; - BIO_lookup_ex; - BIO_meth_get_read_ex; - BIO_meth_get_write_ex; - BIO_meth_set_read_ex; - BIO_meth_set_write_ex; - BIO_read_ex; - BIO_set_callback_ex; - BIO_write_ex; - BN_priv_rand; - BN_priv_rand_range; - DH_check_ex; - DH_check_params_ex; - DH_check_pub_key_ex; - DH_get0_g; - DH_get0_p; - DH_get0_priv_key; - DH_get0_pub_key; - DH_get0_q; - DH_get_nid; - DH_new_by_nid; - DSA_get0_g; - DSA_get0_p; - DSA_get0_priv_key; - DSA_get0_pub_key; - DSA_get0_q; - ECDSA_SIG_get0_r; - ECDSA_SIG_get0_s; - EC_GROUP_get_curve; - EC_GROUP_set_curve; - EC_KEY_get0_engine; - EC_POINT_get_affine_coordinates; - EC_POINT_set_affine_coordinates; - EC_POINT_set_compressed_coordinates; - ERR_clear_last_mark; - ERR_load_OSSL_STORE_strings; - ERR_load_strings_const; - ESS_CERT_ID_V2_dup; - ESS_CERT_ID_V2_free; - ESS_CERT_ID_V2_new; - ESS_SIGNING_CERT_V2_dup; - ESS_SIGNING_CERT_V2_free; - ESS_SIGNING_CERT_V2_new; - EVP_DigestFinalXOF; - EVP_DigestSign; - EVP_DigestVerify; - EVP_MD_CTX_set_pkey_ctx; - EVP_PKEY_CTX_ctrl_uint64; - EVP_PKEY_CTX_md; - EVP_PKEY_asn1_set_check; - EVP_PKEY_asn1_set_get_priv_key; - EVP_PKEY_asn1_set_get_pub_key; - EVP_PKEY_asn1_set_param_check; - EVP_PKEY_asn1_set_public_check; - EVP_PKEY_asn1_set_set_priv_key; - EVP_PKEY_asn1_set_set_pub_key; - EVP_PKEY_asn1_set_siginf; - EVP_PKEY_check; - EVP_PKEY_get0_poly1305; - EVP_PKEY_get0_siphash; - EVP_PKEY_get_raw_private_key; - EVP_PKEY_get_raw_public_key; - EVP_PKEY_meth_get0; - EVP_PKEY_meth_get_check; - EVP_PKEY_meth_get_count; - EVP_PKEY_meth_get_digest_custom; - EVP_PKEY_meth_get_param_check; - EVP_PKEY_meth_get_public_check; - EVP_PKEY_meth_remove; - EVP_PKEY_meth_set_check; - EVP_PKEY_meth_set_digest_custom; - EVP_PKEY_meth_set_param_check; - EVP_PKEY_meth_set_public_check; - EVP_PKEY_new_CMAC_key; - EVP_PKEY_new_raw_private_key; - EVP_PKEY_new_raw_public_key; - EVP_PKEY_param_check; - EVP_PKEY_public_check; - EVP_PKEY_set_alias_type; - EVP_aria_128_cbc; - EVP_aria_128_ccm; - EVP_aria_128_cfb128; - EVP_aria_128_cfb1; - EVP_aria_128_cfb8; - EVP_aria_128_ctr; - EVP_aria_128_ecb; - EVP_aria_128_gcm; - EVP_aria_128_ofb; - EVP_aria_192_cbc; - EVP_aria_192_ccm; - EVP_aria_192_cfb128; - EVP_aria_192_cfb1; - EVP_aria_192_cfb8; - EVP_aria_192_ctr; - EVP_aria_192_ecb; - EVP_aria_192_gcm; - EVP_aria_192_ofb; - EVP_aria_256_cbc; - EVP_aria_256_ccm; - EVP_aria_256_cfb128; - EVP_aria_256_cfb1; - EVP_aria_256_cfb8; - EVP_aria_256_ctr; - EVP_aria_256_ecb; - EVP_aria_256_gcm; - EVP_aria_256_ofb; - EVP_sha3_224; - EVP_sha3_256; - EVP_sha3_384; - EVP_sha3_512; - EVP_sha512_224; - EVP_sha512_256; - EVP_shake128; - EVP_shake256; - EVP_sm3; - EVP_sm4_cbc; - EVP_sm4_cfb128; - EVP_sm4_ctr; - EVP_sm4_ecb; - EVP_sm4_ofb; - NAMING_AUTHORITY_free; - NAMING_AUTHORITY_get0_authorityId; - NAMING_AUTHORITY_get0_authorityText; - NAMING_AUTHORITY_get0_authorityURL; - NAMING_AUTHORITY_new; - NAMING_AUTHORITY_set0_authorityId; - NAMING_AUTHORITY_set0_authorityText; - NAMING_AUTHORITY_set0_authorityURL; - OCSP_basic_sign_ctx; - OCSP_resp_get1_id; - OPENSSL_fork_child; - OPENSSL_fork_parent; - OPENSSL_fork_prepare; - OPENSSL_sk_new_reserve; - OPENSSL_sk_reserve; - OSSL_STORE_INFO_free; - OSSL_STORE_INFO_get0_CERT; - OSSL_STORE_INFO_get0_CRL; - OSSL_STORE_INFO_get0_NAME; - OSSL_STORE_INFO_get0_NAME_description; - OSSL_STORE_INFO_get0_PARAMS; - OSSL_STORE_INFO_get0_PKEY; - OSSL_STORE_INFO_get1_CERT; - OSSL_STORE_INFO_get1_CRL; - OSSL_STORE_INFO_get1_NAME; - OSSL_STORE_INFO_get1_NAME_description; - OSSL_STORE_INFO_get1_PARAMS; - OSSL_STORE_INFO_get1_PKEY; - OSSL_STORE_INFO_get_type; - OSSL_STORE_INFO_new_CERT; - OSSL_STORE_INFO_new_CRL; - OSSL_STORE_INFO_new_NAME; - OSSL_STORE_INFO_new_PARAMS; - OSSL_STORE_INFO_new_PKEY; - OSSL_STORE_INFO_set0_NAME_description; - OSSL_STORE_INFO_type_string; - OSSL_STORE_LOADER_free; - OSSL_STORE_LOADER_get0_engine; - OSSL_STORE_LOADER_get0_scheme; - OSSL_STORE_LOADER_new; - OSSL_STORE_LOADER_set_close; - OSSL_STORE_LOADER_set_ctrl; - OSSL_STORE_LOADER_set_eof; - OSSL_STORE_LOADER_set_error; - OSSL_STORE_LOADER_set_expect; - OSSL_STORE_LOADER_set_find; - OSSL_STORE_LOADER_set_load; - OSSL_STORE_LOADER_set_open; - OSSL_STORE_SEARCH_by_alias; - OSSL_STORE_SEARCH_by_issuer_serial; - OSSL_STORE_SEARCH_by_key_fingerprint; - OSSL_STORE_SEARCH_by_name; - OSSL_STORE_SEARCH_free; - OSSL_STORE_SEARCH_get0_bytes; - OSSL_STORE_SEARCH_get0_digest; - OSSL_STORE_SEARCH_get0_name; - OSSL_STORE_SEARCH_get0_serial; - OSSL_STORE_SEARCH_get0_string; - OSSL_STORE_SEARCH_get_type; - OSSL_STORE_close; - OSSL_STORE_ctrl; - OSSL_STORE_do_all_loaders; - OSSL_STORE_eof; - OSSL_STORE_error; - OSSL_STORE_expect; - OSSL_STORE_find; - OSSL_STORE_load; - OSSL_STORE_open; - OSSL_STORE_register_loader; - OSSL_STORE_supports_search; - OSSL_STORE_unregister_loader; - OSSL_STORE_vctrl; - PEM_bytes_read_bio_secmem; - PEM_read_bio_ex; - PROFESSION_INFO_free; - PROFESSION_INFO_get0_addProfessionInfo; - PROFESSION_INFO_get0_namingAuthority; - PROFESSION_INFO_get0_professionItems; - PROFESSION_INFO_get0_professionOIDs; - PROFESSION_INFO_get0_registrationNumber; - PROFESSION_INFO_new; - PROFESSION_INFO_set0_addProfessionInfo; - PROFESSION_INFO_set0_namingAuthority; - PROFESSION_INFO_set0_professionItems; - PROFESSION_INFO_set0_professionOIDs; - PROFESSION_INFO_set0_registrationNumber; - RAND_DRBG_bytes; - RAND_DRBG_free; - RAND_DRBG_generate; - RAND_DRBG_get0_master; - RAND_DRBG_get0_private; - RAND_DRBG_get0_public; - RAND_DRBG_get_ex_data; - RAND_DRBG_instantiate; - RAND_DRBG_new; - RAND_DRBG_reseed; - RAND_DRBG_secure_new; - RAND_DRBG_set; - RAND_DRBG_set_callbacks; - RAND_DRBG_set_defaults; - RAND_DRBG_set_ex_data; - RAND_DRBG_set_reseed_defaults; - RAND_DRBG_set_reseed_interval; - RAND_DRBG_set_reseed_time_interval; - RAND_DRBG_uninstantiate; - RAND_keep_random_devices_open; - RAND_priv_bytes; - RSA_generate_multi_prime_key; - RSA_get0_d; - RSA_get0_dmp1; - RSA_get0_dmq1; - RSA_get0_e; - RSA_get0_iqmp; - RSA_get0_multi_prime_crt_params; - RSA_get0_multi_prime_factors; - RSA_get0_n; - RSA_get0_p; - RSA_get0_q; - RSA_get_multi_prime_extra_count; - RSA_get_version; - RSA_meth_get_multi_prime_keygen; - RSA_meth_set_multi_prime_keygen; - RSA_pkey_ctx_ctrl; - RSA_set0_multi_prime_params; - SCRYPT_PARAMS_free; - SCRYPT_PARAMS_new; - TS_CONF_set_ess_cert_id_digest; - TS_RESP_CTX_set_ess_cert_id_digest; - UI_UTIL_wrap_read_pem_callback; - UI_dup_user_data; - UI_get_result_length; - UI_get_result_string_length; - UI_method_get_data_destructor; - UI_method_get_data_duplicator; - UI_method_get_ex_data; - UI_method_set_data_duplicator; - UI_method_set_ex_data; - UI_null; - UI_set_result_ex; - X509_CRL_print_ex; - X509_SIG_INFO_get; - X509_SIG_INFO_set; - X509_get_signature_info; - d2i_ADMISSIONS; - d2i_ADMISSION_SYNTAX; - d2i_ESS_CERT_ID_V2; - d2i_ESS_SIGNING_CERT_V2; - d2i_NAMING_AUTHORITY; - d2i_PROFESSION_INFO; - d2i_SCRYPT_PARAMS; - i2d_ADMISSIONS; - i2d_ADMISSION_SYNTAX; - i2d_ESS_CERT_ID_V2; - i2d_ESS_SIGNING_CERT_V2; - i2d_NAMING_AUTHORITY; - i2d_PROFESSION_INFO; - i2d_SCRYPT_PARAMS; - ADMISSIONS_it; - ADMISSION_SYNTAX_it; - NAMING_AUTHORITY_it; - PROFESSION_INFO_it; - SCRYPT_PARAMS_it; -} OPENSSL_1_1_0j; - -OPENSSL_1_1_1b { - global: - OPENSSL_INIT_set_config_file_flags; - OPENSSL_INIT_set_config_filename; -} OPENSSL_1_1_1; - -OPENSSL_1_1_1c { - global: - EVP_PKEY_get0_engine; -} OPENSSL_1_1_1b; - -OPENSSL_1_1_1d { - global: - X509_get0_authority_issuer; - X509_get0_authority_serial; -} OPENSSL_1_1_1c; - -OPENSSL_1_1_1e { - global: - EVP_PKEY_meth_get_digestsign; - EVP_PKEY_meth_get_digestverify; - EVP_PKEY_meth_set_digestsign; - EVP_PKEY_meth_set_digestverify; - RSA_get0_pss_params; -} OPENSSL_1_1_1d; - +OPENSSL_1_1_0 { + global: + ACCESS_DESCRIPTION_free; + ACCESS_DESCRIPTION_new; + AES_bi_ige_encrypt; + AES_cbc_encrypt; + AES_cfb128_encrypt; + AES_cfb1_encrypt; + AES_cfb8_encrypt; + AES_decrypt; + AES_ecb_encrypt; + AES_encrypt; + AES_ige_encrypt; + AES_ofb128_encrypt; + AES_options; + AES_set_decrypt_key; + AES_set_encrypt_key; + AES_unwrap_key; + AES_wrap_key; + ASIdOrRange_free; + ASIdOrRange_new; + ASIdentifierChoice_free; + ASIdentifierChoice_new; + ASIdentifiers_free; + ASIdentifiers_new; + ASN1_BIT_STRING_check; + ASN1_BIT_STRING_free; + ASN1_BIT_STRING_get_bit; + ASN1_BIT_STRING_name_print; + ASN1_BIT_STRING_new; + ASN1_BIT_STRING_num_asc; + ASN1_BIT_STRING_set; + ASN1_BIT_STRING_set_asc; + ASN1_BIT_STRING_set_bit; + ASN1_BMPSTRING_free; + ASN1_BMPSTRING_new; + ASN1_ENUMERATED_free; + ASN1_ENUMERATED_get; + ASN1_ENUMERATED_get_int64; + ASN1_ENUMERATED_new; + ASN1_ENUMERATED_set; + ASN1_ENUMERATED_set_int64; + ASN1_ENUMERATED_to_BN; + ASN1_GENERALIZEDTIME_adj; + ASN1_GENERALIZEDTIME_check; + ASN1_GENERALIZEDTIME_free; + ASN1_GENERALIZEDTIME_new; + ASN1_GENERALIZEDTIME_print; + ASN1_GENERALIZEDTIME_set; + ASN1_GENERALIZEDTIME_set_string; + ASN1_GENERALSTRING_free; + ASN1_GENERALSTRING_new; + ASN1_IA5STRING_free; + ASN1_IA5STRING_new; + ASN1_INTEGER_cmp; + ASN1_INTEGER_dup; + ASN1_INTEGER_free; + ASN1_INTEGER_get; + ASN1_INTEGER_get_int64; + ASN1_INTEGER_get_uint64; + ASN1_INTEGER_new; + ASN1_INTEGER_set; + ASN1_INTEGER_set_int64; + ASN1_INTEGER_set_uint64; + ASN1_INTEGER_to_BN; + ASN1_NULL_free; + ASN1_NULL_new; + ASN1_OBJECT_create; + ASN1_OBJECT_free; + ASN1_OBJECT_new; + ASN1_OCTET_STRING_cmp; + ASN1_OCTET_STRING_dup; + ASN1_OCTET_STRING_free; + ASN1_OCTET_STRING_new; + ASN1_OCTET_STRING_set; + ASN1_PCTX_free; + ASN1_PCTX_get_cert_flags; + ASN1_PCTX_get_flags; + ASN1_PCTX_get_nm_flags; + ASN1_PCTX_get_oid_flags; + ASN1_PCTX_get_str_flags; + ASN1_PCTX_new; + ASN1_PCTX_set_cert_flags; + ASN1_PCTX_set_flags; + ASN1_PCTX_set_nm_flags; + ASN1_PCTX_set_oid_flags; + ASN1_PCTX_set_str_flags; + ASN1_PRINTABLESTRING_free; + ASN1_PRINTABLESTRING_new; + ASN1_PRINTABLE_free; + ASN1_PRINTABLE_new; + ASN1_PRINTABLE_type; + ASN1_SCTX_free; + ASN1_SCTX_get_app_data; + ASN1_SCTX_get_flags; + ASN1_SCTX_get_item; + ASN1_SCTX_get_template; + ASN1_SCTX_new; + ASN1_SCTX_set_app_data; + ASN1_STRING_TABLE_add; + ASN1_STRING_TABLE_cleanup; + ASN1_STRING_TABLE_get; + ASN1_STRING_clear_free; + ASN1_STRING_cmp; + ASN1_STRING_copy; + ASN1_STRING_data; + ASN1_STRING_dup; + ASN1_STRING_free; + ASN1_STRING_get0_data; + ASN1_STRING_get_default_mask; + ASN1_STRING_length; + ASN1_STRING_length_set; + ASN1_STRING_new; + ASN1_STRING_print; + ASN1_STRING_print_ex; + ASN1_STRING_print_ex_fp; + ASN1_STRING_set0; + ASN1_STRING_set; + ASN1_STRING_set_by_NID; + ASN1_STRING_set_default_mask; + ASN1_STRING_set_default_mask_asc; + ASN1_STRING_to_UTF8; + ASN1_STRING_type; + ASN1_STRING_type_new; + ASN1_T61STRING_free; + ASN1_T61STRING_new; + ASN1_TIME_adj; + ASN1_TIME_check; + ASN1_TIME_diff; + ASN1_TIME_free; + ASN1_TIME_new; + ASN1_TIME_print; + ASN1_TIME_set; + ASN1_TIME_set_string; + ASN1_TIME_to_generalizedtime; + ASN1_TYPE_cmp; + ASN1_TYPE_free; + ASN1_TYPE_get; + ASN1_TYPE_get_int_octetstring; + ASN1_TYPE_get_octetstring; + ASN1_TYPE_new; + ASN1_TYPE_pack_sequence; + ASN1_TYPE_set1; + ASN1_TYPE_set; + ASN1_TYPE_set_int_octetstring; + ASN1_TYPE_set_octetstring; + ASN1_TYPE_unpack_sequence; + ASN1_UNIVERSALSTRING_free; + ASN1_UNIVERSALSTRING_new; + ASN1_UNIVERSALSTRING_to_string; + ASN1_UTCTIME_adj; + ASN1_UTCTIME_check; + ASN1_UTCTIME_cmp_time_t; + ASN1_UTCTIME_free; + ASN1_UTCTIME_new; + ASN1_UTCTIME_print; + ASN1_UTCTIME_set; + ASN1_UTCTIME_set_string; + ASN1_UTF8STRING_free; + ASN1_UTF8STRING_new; + ASN1_VISIBLESTRING_free; + ASN1_VISIBLESTRING_new; + ASN1_add_oid_module; + ASN1_add_stable_module; + ASN1_bn_print; + ASN1_buf_print; + ASN1_check_infinite_end; + ASN1_const_check_infinite_end; + ASN1_d2i_bio; + ASN1_d2i_fp; + ASN1_digest; + ASN1_dup; + ASN1_generate_nconf; + ASN1_generate_v3; + ASN1_get_object; + ASN1_i2d_bio; + ASN1_i2d_fp; + ASN1_item_d2i; + ASN1_item_d2i_bio; + ASN1_item_d2i_fp; + ASN1_item_digest; + ASN1_item_dup; + ASN1_item_ex_d2i; + ASN1_item_ex_free; + ASN1_item_ex_i2d; + ASN1_item_ex_new; + ASN1_item_free; + ASN1_item_i2d; + ASN1_item_i2d_bio; + ASN1_item_i2d_fp; + ASN1_item_ndef_i2d; + ASN1_item_new; + ASN1_item_pack; + ASN1_item_print; + ASN1_item_sign; + ASN1_item_sign_ctx; + ASN1_item_unpack; + ASN1_item_verify; + ASN1_mbstring_copy; + ASN1_mbstring_ncopy; + ASN1_object_size; + ASN1_parse; + ASN1_parse_dump; + ASN1_put_eoc; + ASN1_put_object; + ASN1_sign; + ASN1_str2mask; + ASN1_tag2bit; + ASN1_tag2str; + ASN1_verify; + ASRange_free; + ASRange_new; + ASYNC_WAIT_CTX_clear_fd; + ASYNC_WAIT_CTX_free; + ASYNC_WAIT_CTX_get_all_fds; + ASYNC_WAIT_CTX_get_changed_fds; + ASYNC_WAIT_CTX_get_fd; + ASYNC_WAIT_CTX_new; + ASYNC_WAIT_CTX_set_wait_fd; + ASYNC_block_pause; + ASYNC_cleanup_thread; + ASYNC_get_current_job; + ASYNC_get_wait_ctx; + ASYNC_init_thread; + ASYNC_is_capable; + ASYNC_pause_job; + ASYNC_start_job; + ASYNC_unblock_pause; + AUTHORITY_INFO_ACCESS_free; + AUTHORITY_INFO_ACCESS_new; + AUTHORITY_KEYID_free; + AUTHORITY_KEYID_new; + BASIC_CONSTRAINTS_free; + BASIC_CONSTRAINTS_new; + BF_cbc_encrypt; + BF_cfb64_encrypt; + BF_decrypt; + BF_ecb_encrypt; + BF_encrypt; + BF_ofb64_encrypt; + BF_options; + BF_set_key; + BIO_ADDRINFO_address; + BIO_ADDRINFO_family; + BIO_ADDRINFO_free; + BIO_ADDRINFO_next; + BIO_ADDRINFO_protocol; + BIO_ADDRINFO_socktype; + BIO_ADDR_clear; + BIO_ADDR_family; + BIO_ADDR_free; + BIO_ADDR_hostname_string; + BIO_ADDR_new; + BIO_ADDR_path_string; + BIO_ADDR_rawaddress; + BIO_ADDR_rawmake; + BIO_ADDR_rawport; + BIO_ADDR_service_string; + BIO_accept; + BIO_accept_ex; + BIO_asn1_get_prefix; + BIO_asn1_get_suffix; + BIO_asn1_set_prefix; + BIO_asn1_set_suffix; + BIO_callback_ctrl; + BIO_clear_flags; + BIO_closesocket; + BIO_connect; + BIO_copy_next_retry; + BIO_ctrl; + BIO_ctrl_get_read_request; + BIO_ctrl_get_write_guarantee; + BIO_ctrl_pending; + BIO_ctrl_reset_read_request; + BIO_ctrl_wpending; + BIO_debug_callback; + BIO_dgram_non_fatal_error; + BIO_dump; + BIO_dump_cb; + BIO_dump_fp; + BIO_dump_indent; + BIO_dump_indent_cb; + BIO_dump_indent_fp; + BIO_dup_chain; + BIO_f_asn1; + BIO_f_base64; + BIO_f_buffer; + BIO_f_cipher; + BIO_f_linebuffer; + BIO_f_md; + BIO_f_nbio_test; + BIO_f_null; + BIO_f_reliable; + BIO_f_zlib; + BIO_fd_non_fatal_error; + BIO_fd_should_retry; + BIO_find_type; + BIO_free; + BIO_free_all; + BIO_get_accept_socket; + BIO_get_callback; + BIO_get_callback_arg; + BIO_get_data; + BIO_get_ex_data; + BIO_get_host_ip; + BIO_get_init; + BIO_get_new_index; + BIO_get_port; + BIO_get_retry_BIO; + BIO_get_retry_reason; + BIO_get_shutdown; + BIO_gethostbyname; + BIO_gets; + BIO_hex_string; + BIO_indent; + BIO_int_ctrl; + BIO_listen; + BIO_lookup; + BIO_meth_free; + BIO_meth_get_callback_ctrl; + BIO_meth_get_create; + BIO_meth_get_ctrl; + BIO_meth_get_destroy; + BIO_meth_get_gets; + BIO_meth_get_puts; + BIO_meth_get_read; + BIO_meth_get_write; + BIO_meth_new; + BIO_meth_set_callback_ctrl; + BIO_meth_set_create; + BIO_meth_set_ctrl; + BIO_meth_set_destroy; + BIO_meth_set_gets; + BIO_meth_set_puts; + BIO_meth_set_read; + BIO_meth_set_write; + BIO_method_name; + BIO_method_type; + BIO_new; + BIO_new_CMS; + BIO_new_NDEF; + BIO_new_PKCS7; + BIO_new_accept; + BIO_new_bio_pair; + BIO_new_connect; + BIO_new_dgram; + BIO_new_fd; + BIO_new_file; + BIO_new_fp; + BIO_new_mem_buf; + BIO_new_socket; + BIO_next; + BIO_nread0; + BIO_nread; + BIO_number_read; + BIO_number_written; + BIO_nwrite0; + BIO_nwrite; + BIO_parse_hostserv; + BIO_pop; + BIO_printf; + BIO_ptr_ctrl; + BIO_push; + BIO_puts; + BIO_read; + BIO_s_accept; + BIO_s_bio; + BIO_s_connect; + BIO_s_datagram; + BIO_s_fd; + BIO_s_file; + BIO_s_log; + BIO_s_mem; + BIO_s_null; + BIO_s_secmem; + BIO_s_socket; + BIO_set_callback; + BIO_set_callback_arg; + BIO_set_cipher; + BIO_set_data; + BIO_set_ex_data; + BIO_set_flags; + BIO_set_init; + BIO_set_next; + BIO_set_retry_reason; + BIO_set_shutdown; + BIO_set_tcp_ndelay; + BIO_snprintf; + BIO_sock_error; + BIO_sock_info; + BIO_sock_init; + BIO_sock_non_fatal_error; + BIO_sock_should_retry; + BIO_socket; + BIO_socket_ioctl; + BIO_socket_nbio; + BIO_test_flags; + BIO_up_ref; + BIO_vfree; + BIO_vprintf; + BIO_vsnprintf; + BIO_write; + BN_BLINDING_convert; + BN_BLINDING_convert_ex; + BN_BLINDING_create_param; + BN_BLINDING_free; + BN_BLINDING_get_flags; + BN_BLINDING_invert; + BN_BLINDING_invert_ex; + BN_BLINDING_is_current_thread; + BN_BLINDING_lock; + BN_BLINDING_new; + BN_BLINDING_set_current_thread; + BN_BLINDING_set_flags; + BN_BLINDING_unlock; + BN_BLINDING_update; + BN_CTX_end; + BN_CTX_free; + BN_CTX_get; + BN_CTX_new; + BN_CTX_secure_new; + BN_CTX_start; + BN_GENCB_call; + BN_GENCB_free; + BN_GENCB_get_arg; + BN_GENCB_new; + BN_GENCB_set; + BN_GENCB_set_old; + BN_GF2m_add; + BN_GF2m_arr2poly; + BN_GF2m_mod; + BN_GF2m_mod_arr; + BN_GF2m_mod_div; + BN_GF2m_mod_div_arr; + BN_GF2m_mod_exp; + BN_GF2m_mod_exp_arr; + BN_GF2m_mod_inv; + BN_GF2m_mod_inv_arr; + BN_GF2m_mod_mul; + BN_GF2m_mod_mul_arr; + BN_GF2m_mod_solve_quad; + BN_GF2m_mod_solve_quad_arr; + BN_GF2m_mod_sqr; + BN_GF2m_mod_sqr_arr; + BN_GF2m_mod_sqrt; + BN_GF2m_mod_sqrt_arr; + BN_GF2m_poly2arr; + BN_MONT_CTX_copy; + BN_MONT_CTX_free; + BN_MONT_CTX_new; + BN_MONT_CTX_set; + BN_MONT_CTX_set_locked; + BN_RECP_CTX_free; + BN_RECP_CTX_new; + BN_RECP_CTX_set; + BN_X931_derive_prime_ex; + BN_X931_generate_Xpq; + BN_X931_generate_prime_ex; + BN_abs_is_word; + BN_add; + BN_add_word; + BN_asc2bn; + BN_bin2bn; + BN_bn2bin; + BN_bn2binpad; + BN_bn2dec; + BN_bn2hex; + BN_bn2lebinpad; + BN_bn2mpi; + BN_bntest_rand; + BN_clear; + BN_clear_bit; + BN_clear_free; + BN_cmp; + BN_consttime_swap; + BN_copy; + BN_dec2bn; + BN_div; + BN_div_recp; + BN_div_word; + BN_dup; + BN_exp; + BN_free; + BN_from_montgomery; + BN_gcd; + BN_generate_dsa_nonce; + BN_generate_prime; + BN_generate_prime_ex; + BN_get0_nist_prime_192; + BN_get0_nist_prime_224; + BN_get0_nist_prime_256; + BN_get0_nist_prime_384; + BN_get0_nist_prime_521; + BN_get_flags; + BN_get_params; + BN_get_rfc2409_prime_1024; + BN_get_rfc2409_prime_768; + BN_get_rfc3526_prime_1536; + BN_get_rfc3526_prime_2048; + BN_get_rfc3526_prime_3072; + BN_get_rfc3526_prime_4096; + BN_get_rfc3526_prime_6144; + BN_get_rfc3526_prime_8192; + BN_get_word; + BN_hex2bn; + BN_is_bit_set; + BN_is_negative; + BN_is_odd; + BN_is_one; + BN_is_prime; + BN_is_prime_ex; + BN_is_prime_fasttest; + BN_is_prime_fasttest_ex; + BN_is_word; + BN_is_zero; + BN_kronecker; + BN_lebin2bn; + BN_lshift1; + BN_lshift; + BN_mask_bits; + BN_mod_add; + BN_mod_add_quick; + BN_mod_exp2_mont; + BN_mod_exp; + BN_mod_exp_mont; + BN_mod_exp_mont_consttime; + BN_mod_exp_mont_word; + BN_mod_exp_recp; + BN_mod_exp_simple; + BN_mod_inverse; + BN_mod_lshift1; + BN_mod_lshift1_quick; + BN_mod_lshift; + BN_mod_lshift_quick; + BN_mod_mul; + BN_mod_mul_montgomery; + BN_mod_mul_reciprocal; + BN_mod_sqr; + BN_mod_sqrt; + BN_mod_sub; + BN_mod_sub_quick; + BN_mod_word; + BN_mpi2bn; + BN_mul; + BN_mul_word; + BN_new; + BN_nist_mod_192; + BN_nist_mod_224; + BN_nist_mod_256; + BN_nist_mod_384; + BN_nist_mod_521; + BN_nist_mod_func; + BN_nnmod; + BN_num_bits; + BN_num_bits_word; + BN_options; + BN_print; + BN_print_fp; + BN_pseudo_rand; + BN_pseudo_rand_range; + BN_rand; + BN_rand_range; + BN_reciprocal; + BN_rshift1; + BN_rshift; + BN_secure_new; + BN_security_bits; + BN_set_bit; + BN_set_flags; + BN_set_negative; + BN_set_params; + BN_set_word; + BN_sqr; + BN_sub; + BN_sub_word; + BN_swap; + BN_to_ASN1_ENUMERATED; + BN_to_ASN1_INTEGER; + BN_to_montgomery; + BN_uadd; + BN_ucmp; + BN_usub; + BN_value_one; + BN_with_flags; + BN_zero_ex; + BUF_MEM_free; + BUF_MEM_grow; + BUF_MEM_grow_clean; + BUF_MEM_new; + BUF_MEM_new_ex; + BUF_reverse; + CAST_cbc_encrypt; + CAST_cfb64_encrypt; + CAST_decrypt; + CAST_ecb_encrypt; + CAST_encrypt; + CAST_ofb64_encrypt; + CAST_set_key; + CERTIFICATEPOLICIES_free; + CERTIFICATEPOLICIES_new; + CMAC_CTX_cleanup; + CMAC_CTX_copy; + CMAC_CTX_free; + CMAC_CTX_get0_cipher_ctx; + CMAC_CTX_new; + CMAC_Final; + CMAC_Init; + CMAC_Update; + CMAC_resume; + CMS_ContentInfo_free; + CMS_ContentInfo_new; + CMS_ContentInfo_print_ctx; + CMS_EncryptedData_decrypt; + CMS_EncryptedData_encrypt; + CMS_EncryptedData_set1_key; + CMS_EnvelopedData_create; + CMS_ReceiptRequest_create0; + CMS_ReceiptRequest_free; + CMS_ReceiptRequest_get0_values; + CMS_ReceiptRequest_new; + CMS_RecipientEncryptedKey_cert_cmp; + CMS_RecipientEncryptedKey_get0_id; + CMS_RecipientInfo_decrypt; + CMS_RecipientInfo_encrypt; + CMS_RecipientInfo_get0_pkey_ctx; + CMS_RecipientInfo_kari_decrypt; + CMS_RecipientInfo_kari_get0_alg; + CMS_RecipientInfo_kari_get0_ctx; + CMS_RecipientInfo_kari_get0_orig_id; + CMS_RecipientInfo_kari_get0_reks; + CMS_RecipientInfo_kari_orig_id_cmp; + CMS_RecipientInfo_kari_set0_pkey; + CMS_RecipientInfo_kekri_get0_id; + CMS_RecipientInfo_kekri_id_cmp; + CMS_RecipientInfo_ktri_cert_cmp; + CMS_RecipientInfo_ktri_get0_algs; + CMS_RecipientInfo_ktri_get0_signer_id; + CMS_RecipientInfo_set0_key; + CMS_RecipientInfo_set0_password; + CMS_RecipientInfo_set0_pkey; + CMS_RecipientInfo_type; + CMS_SharedInfo_encode; + CMS_SignedData_init; + CMS_SignerInfo_cert_cmp; + CMS_SignerInfo_get0_algs; + CMS_SignerInfo_get0_md_ctx; + CMS_SignerInfo_get0_pkey_ctx; + CMS_SignerInfo_get0_signature; + CMS_SignerInfo_get0_signer_id; + CMS_SignerInfo_set1_signer_cert; + CMS_SignerInfo_sign; + CMS_SignerInfo_verify; + CMS_SignerInfo_verify_content; + CMS_add0_CertificateChoices; + CMS_add0_RevocationInfoChoice; + CMS_add0_cert; + CMS_add0_crl; + CMS_add0_recipient_key; + CMS_add0_recipient_password; + CMS_add1_ReceiptRequest; + CMS_add1_cert; + CMS_add1_crl; + CMS_add1_recipient_cert; + CMS_add1_signer; + CMS_add_simple_smimecap; + CMS_add_smimecap; + CMS_add_standard_smimecap; + CMS_compress; + CMS_dataFinal; + CMS_dataInit; + CMS_data; + CMS_data_create; + CMS_decrypt; + CMS_decrypt_set1_key; + CMS_decrypt_set1_password; + CMS_decrypt_set1_pkey; + CMS_digest_create; + CMS_digest_verify; + CMS_encrypt; + CMS_final; + CMS_get0_RecipientInfos; + CMS_get0_SignerInfos; + CMS_get0_content; + CMS_get0_eContentType; + CMS_get0_signers; + CMS_get0_type; + CMS_get1_ReceiptRequest; + CMS_get1_certs; + CMS_get1_crls; + CMS_is_detached; + CMS_set1_eContentType; + CMS_set1_signers_certs; + CMS_set_detached; + CMS_sign; + CMS_sign_receipt; + CMS_signed_add1_attr; + CMS_signed_add1_attr_by_NID; + CMS_signed_add1_attr_by_OBJ; + CMS_signed_add1_attr_by_txt; + CMS_signed_delete_attr; + CMS_signed_get0_data_by_OBJ; + CMS_signed_get_attr; + CMS_signed_get_attr_by_NID; + CMS_signed_get_attr_by_OBJ; + CMS_signed_get_attr_count; + CMS_stream; + CMS_uncompress; + CMS_unsigned_add1_attr; + CMS_unsigned_add1_attr_by_NID; + CMS_unsigned_add1_attr_by_OBJ; + CMS_unsigned_add1_attr_by_txt; + CMS_unsigned_delete_attr; + CMS_unsigned_get0_data_by_OBJ; + CMS_unsigned_get_attr; + CMS_unsigned_get_attr_by_NID; + CMS_unsigned_get_attr_by_OBJ; + CMS_unsigned_get_attr_count; + CMS_verify; + CMS_verify_receipt; + COMP_CTX_free; + COMP_CTX_get_method; + COMP_CTX_get_type; + COMP_CTX_new; + COMP_compress_block; + COMP_expand_block; + COMP_get_name; + COMP_get_type; + COMP_zlib; + CONF_dump_bio; + CONF_dump_fp; + CONF_free; + CONF_get1_default_config_file; + CONF_get_number; + CONF_get_section; + CONF_get_string; + CONF_imodule_get_flags; + CONF_imodule_get_module; + CONF_imodule_get_name; + CONF_imodule_get_usr_data; + CONF_imodule_get_value; + CONF_imodule_set_flags; + CONF_imodule_set_usr_data; + CONF_load; + CONF_load_bio; + CONF_load_fp; + CONF_module_add; + CONF_module_get_usr_data; + CONF_module_set_usr_data; + CONF_modules_finish; + CONF_modules_load; + CONF_modules_load_file; + CONF_modules_unload; + CONF_parse_list; + CONF_set_default_method; + CONF_set_nconf; + CRL_DIST_POINTS_free; + CRL_DIST_POINTS_new; + CRYPTO_128_unwrap; + CRYPTO_128_unwrap_pad; + CRYPTO_128_wrap; + CRYPTO_128_wrap_pad; + CRYPTO_THREAD_cleanup_local; + CRYPTO_THREAD_compare_id; + CRYPTO_THREAD_get_current_id; + CRYPTO_THREAD_get_local; + CRYPTO_THREAD_init_local; + CRYPTO_THREAD_lock_free; + CRYPTO_THREAD_lock_new; + CRYPTO_THREAD_read_lock; + CRYPTO_THREAD_run_once; + CRYPTO_THREAD_set_local; + CRYPTO_THREAD_unlock; + CRYPTO_THREAD_write_lock; + CRYPTO_atomic_add; + CRYPTO_cbc128_decrypt; + CRYPTO_cbc128_encrypt; + CRYPTO_ccm128_aad; + CRYPTO_ccm128_decrypt; + CRYPTO_ccm128_decrypt_ccm64; + CRYPTO_ccm128_encrypt; + CRYPTO_ccm128_encrypt_ccm64; + CRYPTO_ccm128_init; + CRYPTO_ccm128_setiv; + CRYPTO_ccm128_tag; + CRYPTO_cfb128_1_encrypt; + CRYPTO_cfb128_8_encrypt; + CRYPTO_cfb128_encrypt; + CRYPTO_clear_free; + CRYPTO_clear_realloc; + CRYPTO_ctr128_encrypt; + CRYPTO_ctr128_encrypt_ctr32; + CRYPTO_cts128_decrypt; + CRYPTO_cts128_decrypt_block; + CRYPTO_cts128_encrypt; + CRYPTO_cts128_encrypt_block; + CRYPTO_dup_ex_data; + CRYPTO_free; + CRYPTO_free_ex_data; + CRYPTO_free_ex_index; + CRYPTO_gcm128_aad; + CRYPTO_gcm128_decrypt; + CRYPTO_gcm128_decrypt_ctr32; + CRYPTO_gcm128_encrypt; + CRYPTO_gcm128_encrypt_ctr32; + CRYPTO_gcm128_finish; + CRYPTO_gcm128_init; + CRYPTO_gcm128_new; + CRYPTO_gcm128_release; + CRYPTO_gcm128_setiv; + CRYPTO_gcm128_tag; + CRYPTO_get_ex_data; + CRYPTO_get_ex_new_index; + CRYPTO_get_mem_functions; + CRYPTO_malloc; + CRYPTO_mem_ctrl; + CRYPTO_memcmp; + CRYPTO_memdup; + CRYPTO_new_ex_data; + CRYPTO_nistcts128_decrypt; + CRYPTO_nistcts128_decrypt_block; + CRYPTO_nistcts128_encrypt; + CRYPTO_nistcts128_encrypt_block; + CRYPTO_ocb128_aad; + CRYPTO_ocb128_cleanup; + CRYPTO_ocb128_copy_ctx; + CRYPTO_ocb128_decrypt; + CRYPTO_ocb128_encrypt; + CRYPTO_ocb128_finish; + CRYPTO_ocb128_init; + CRYPTO_ocb128_new; + CRYPTO_ocb128_setiv; + CRYPTO_ocb128_tag; + CRYPTO_ofb128_encrypt; + CRYPTO_realloc; + CRYPTO_secure_actual_size; + CRYPTO_secure_allocated; + CRYPTO_secure_free; + CRYPTO_secure_malloc; + CRYPTO_secure_malloc_done; + CRYPTO_secure_malloc_init; + CRYPTO_secure_malloc_initialized; + CRYPTO_secure_used; + CRYPTO_secure_zalloc; + CRYPTO_set_ex_data; + CRYPTO_set_mem_debug; + CRYPTO_set_mem_functions; + CRYPTO_strdup; + CRYPTO_strndup; + CRYPTO_xts128_encrypt; + CRYPTO_zalloc; + CTLOG_STORE_free; + CTLOG_STORE_get0_log_by_id; + CTLOG_STORE_load_default_file; + CTLOG_STORE_load_file; + CTLOG_STORE_new; + CTLOG_free; + CTLOG_get0_log_id; + CTLOG_get0_name; + CTLOG_get0_public_key; + CTLOG_new; + CTLOG_new_from_base64; + CT_POLICY_EVAL_CTX_free; + CT_POLICY_EVAL_CTX_get0_cert; + CT_POLICY_EVAL_CTX_get0_issuer; + CT_POLICY_EVAL_CTX_get0_log_store; + CT_POLICY_EVAL_CTX_new; + CT_POLICY_EVAL_CTX_set1_cert; + CT_POLICY_EVAL_CTX_set1_issuer; + CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE; + Camellia_cbc_encrypt; + Camellia_cfb128_encrypt; + Camellia_cfb1_encrypt; + Camellia_cfb8_encrypt; + Camellia_ctr128_encrypt; + Camellia_decrypt; + Camellia_ecb_encrypt; + Camellia_encrypt; + Camellia_ofb128_encrypt; + Camellia_set_key; + DES_cbc_cksum; + DES_cbc_encrypt; + DES_cfb64_encrypt; + DES_cfb_encrypt; + DES_check_key_parity; + DES_crypt; + DES_decrypt3; + DES_ecb3_encrypt; + DES_ecb_encrypt; + DES_ede3_cbc_encrypt; + DES_ede3_cfb64_encrypt; + DES_ede3_cfb_encrypt; + DES_ede3_ofb64_encrypt; + DES_encrypt1; + DES_encrypt2; + DES_encrypt3; + DES_fcrypt; + DES_is_weak_key; + DES_key_sched; + DES_ncbc_encrypt; + DES_ofb64_encrypt; + DES_ofb_encrypt; + DES_options; + DES_pcbc_encrypt; + DES_quad_cksum; + DES_random_key; + DES_set_key; + DES_set_key_checked; + DES_set_key_unchecked; + DES_set_odd_parity; + DES_string_to_2keys; + DES_string_to_key; + DES_xcbc_encrypt; + DH_KDF_X9_42; + DH_OpenSSL; + DH_bits; + DH_check; + DH_check_pub_key; + DH_clear_flags; + DH_compute_key; + DH_compute_key_padded; + DH_free; + DH_generate_key; + DH_generate_parameters; + DH_generate_parameters_ex; + DH_get0_engine; + DH_get0_key; + DH_get0_pqg; + DH_get_1024_160; + DH_get_2048_224; + DH_get_2048_256; + DH_get_default_method; + DH_get_ex_data; + DH_get_length; + DH_meth_dup; + DH_meth_free; + DH_meth_get0_app_data; + DH_meth_get0_name; + DH_meth_get_bn_mod_exp; + DH_meth_get_compute_key; + DH_meth_get_finish; + DH_meth_get_flags; + DH_meth_get_generate_key; + DH_meth_get_generate_params; + DH_meth_get_init; + DH_meth_new; + DH_meth_set0_app_data; + DH_meth_set1_name; + DH_meth_set_bn_mod_exp; + DH_meth_set_compute_key; + DH_meth_set_finish; + DH_meth_set_flags; + DH_meth_set_generate_key; + DH_meth_set_generate_params; + DH_meth_set_init; + DH_new; + DH_new_method; + DH_security_bits; + DH_set0_key; + DH_set0_pqg; + DH_set_default_method; + DH_set_ex_data; + DH_set_flags; + DH_set_length; + DH_set_method; + DH_size; + DH_test_flags; + DH_up_ref; + DHparams_dup; + DHparams_print; + DHparams_print_fp; + DIRECTORYSTRING_free; + DIRECTORYSTRING_new; + DISPLAYTEXT_free; + DISPLAYTEXT_new; + DIST_POINT_NAME_free; + DIST_POINT_NAME_new; + DIST_POINT_free; + DIST_POINT_new; + DIST_POINT_set_dpname; + DSA_OpenSSL; + DSA_SIG_free; + DSA_SIG_get0; + DSA_SIG_new; + DSA_SIG_set0; + DSA_bits; + DSA_clear_flags; + DSA_do_sign; + DSA_do_verify; + DSA_dup_DH; + DSA_free; + DSA_generate_key; + DSA_generate_parameters; + DSA_generate_parameters_ex; + DSA_get0_engine; + DSA_get0_key; + DSA_get0_pqg; + DSA_get_default_method; + DSA_get_ex_data; + DSA_get_method; + DSA_meth_dup; + DSA_meth_free; + DSA_meth_get0_app_data; + DSA_meth_get0_name; + DSA_meth_get_bn_mod_exp; + DSA_meth_get_finish; + DSA_meth_get_flags; + DSA_meth_get_init; + DSA_meth_get_keygen; + DSA_meth_get_mod_exp; + DSA_meth_get_paramgen; + DSA_meth_get_sign; + DSA_meth_get_sign_setup; + DSA_meth_get_verify; + DSA_meth_new; + DSA_meth_set0_app_data; + DSA_meth_set1_name; + DSA_meth_set_bn_mod_exp; + DSA_meth_set_finish; + DSA_meth_set_flags; + DSA_meth_set_init; + DSA_meth_set_keygen; + DSA_meth_set_mod_exp; + DSA_meth_set_paramgen; + DSA_meth_set_sign; + DSA_meth_set_sign_setup; + DSA_meth_set_verify; + DSA_new; + DSA_new_method; + DSA_print; + DSA_print_fp; + DSA_security_bits; + DSA_set0_key; + DSA_set0_pqg; + DSA_set_default_method; + DSA_set_ex_data; + DSA_set_flags; + DSA_set_method; + DSA_sign; + DSA_sign_setup; + DSA_size; + DSA_test_flags; + DSA_up_ref; + DSA_verify; + DSAparams_dup; + DSAparams_print; + DSAparams_print_fp; + DSO_METHOD_openssl; + DSO_bind_func; + DSO_convert_filename; + DSO_ctrl; + DSO_flags; + DSO_free; + DSO_get_filename; + DSO_global_lookup; + DSO_load; + DSO_merge; + DSO_new; + DSO_set_filename; + DSO_up_ref; + ECDH_KDF_X9_62; + ECDH_compute_key; + ECDSA_SIG_free; + ECDSA_SIG_get0; + ECDSA_SIG_new; + ECDSA_SIG_set0; + ECDSA_do_sign; + ECDSA_do_sign_ex; + ECDSA_do_verify; + ECDSA_sign; + ECDSA_sign_ex; + ECDSA_sign_setup; + ECDSA_size; + ECDSA_verify; + ECPARAMETERS_free; + ECPARAMETERS_new; + ECPKPARAMETERS_free; + ECPKPARAMETERS_new; + ECPKParameters_print; + ECPKParameters_print_fp; + ECParameters_print; + ECParameters_print_fp; + EC_GF2m_simple_method; + EC_GFp_mont_method; + EC_GFp_nist_method; + EC_GFp_nistp224_method; + EC_GFp_nistp256_method; + EC_GFp_nistp521_method; + EC_GFp_simple_method; + EC_GROUP_check; + EC_GROUP_check_discriminant; + EC_GROUP_clear_free; + EC_GROUP_cmp; + EC_GROUP_copy; + EC_GROUP_dup; + EC_GROUP_free; + EC_GROUP_get0_cofactor; + EC_GROUP_get0_generator; + EC_GROUP_get0_order; + EC_GROUP_get0_seed; + EC_GROUP_get_asn1_flag; + EC_GROUP_get_basis_type; + EC_GROUP_get_cofactor; + EC_GROUP_get_curve_GF2m; + EC_GROUP_get_curve_GFp; + EC_GROUP_get_curve_name; + EC_GROUP_get_degree; + EC_GROUP_get_ecparameters; + EC_GROUP_get_ecpkparameters; + EC_GROUP_get_mont_data; + EC_GROUP_get_order; + EC_GROUP_get_pentanomial_basis; + EC_GROUP_get_point_conversion_form; + EC_GROUP_get_seed_len; + EC_GROUP_get_trinomial_basis; + EC_GROUP_have_precompute_mult; + EC_GROUP_method_of; + EC_GROUP_new; + EC_GROUP_new_by_curve_name; + EC_GROUP_new_curve_GF2m; + EC_GROUP_new_curve_GFp; + EC_GROUP_new_from_ecparameters; + EC_GROUP_new_from_ecpkparameters; + EC_GROUP_order_bits; + EC_GROUP_precompute_mult; + EC_GROUP_set_asn1_flag; + EC_GROUP_set_curve_GF2m; + EC_GROUP_set_curve_GFp; + EC_GROUP_set_curve_name; + EC_GROUP_set_generator; + EC_GROUP_set_point_conversion_form; + EC_GROUP_set_seed; + EC_KEY_METHOD_free; + EC_KEY_METHOD_get_compute_key; + EC_KEY_METHOD_get_init; + EC_KEY_METHOD_get_keygen; + EC_KEY_METHOD_get_sign; + EC_KEY_METHOD_get_verify; + EC_KEY_METHOD_new; + EC_KEY_METHOD_set_compute_key; + EC_KEY_METHOD_set_init; + EC_KEY_METHOD_set_keygen; + EC_KEY_METHOD_set_sign; + EC_KEY_METHOD_set_verify; + EC_KEY_OpenSSL; + EC_KEY_can_sign; + EC_KEY_check_key; + EC_KEY_clear_flags; + EC_KEY_copy; + EC_KEY_dup; + EC_KEY_free; + EC_KEY_generate_key; + EC_KEY_get0_group; + EC_KEY_get0_private_key; + EC_KEY_get0_public_key; + EC_KEY_get_conv_form; + EC_KEY_get_default_method; + EC_KEY_get_enc_flags; + EC_KEY_get_ex_data; + EC_KEY_get_flags; + EC_KEY_get_method; + EC_KEY_key2buf; + EC_KEY_new; + EC_KEY_new_by_curve_name; + EC_KEY_new_method; + EC_KEY_oct2key; + EC_KEY_oct2priv; + EC_KEY_precompute_mult; + EC_KEY_print; + EC_KEY_print_fp; + EC_KEY_priv2buf; + EC_KEY_priv2oct; + EC_KEY_set_asn1_flag; + EC_KEY_set_conv_form; + EC_KEY_set_default_method; + EC_KEY_set_enc_flags; + EC_KEY_set_ex_data; + EC_KEY_set_flags; + EC_KEY_set_group; + EC_KEY_set_method; + EC_KEY_set_private_key; + EC_KEY_set_public_key; + EC_KEY_set_public_key_affine_coordinates; + EC_KEY_up_ref; + EC_METHOD_get_field_type; + EC_POINT_add; + EC_POINT_bn2point; + EC_POINT_clear_free; + EC_POINT_cmp; + EC_POINT_copy; + EC_POINT_dbl; + EC_POINT_dup; + EC_POINT_free; + EC_POINT_get_Jprojective_coordinates_GFp; + EC_POINT_get_affine_coordinates_GF2m; + EC_POINT_get_affine_coordinates_GFp; + EC_POINT_hex2point; + EC_POINT_invert; + EC_POINT_is_at_infinity; + EC_POINT_is_on_curve; + EC_POINT_make_affine; + EC_POINT_method_of; + EC_POINT_mul; + EC_POINT_new; + EC_POINT_oct2point; + EC_POINT_point2bn; + EC_POINT_point2buf; + EC_POINT_point2hex; + EC_POINT_point2oct; + EC_POINT_set_Jprojective_coordinates_GFp; + EC_POINT_set_affine_coordinates_GF2m; + EC_POINT_set_affine_coordinates_GFp; + EC_POINT_set_compressed_coordinates_GF2m; + EC_POINT_set_compressed_coordinates_GFp; + EC_POINT_set_to_infinity; + EC_POINTs_make_affine; + EC_POINTs_mul; + EC_curve_nid2nist; + EC_curve_nist2nid; + EC_get_builtin_curves; + EDIPARTYNAME_free; + EDIPARTYNAME_new; + ENGINE_add; + ENGINE_add_conf_module; + ENGINE_by_id; + ENGINE_cmd_is_executable; + ENGINE_ctrl; + ENGINE_ctrl_cmd; + ENGINE_ctrl_cmd_string; + ENGINE_finish; + ENGINE_free; + ENGINE_get_DH; + ENGINE_get_DSA; + ENGINE_get_EC; + ENGINE_get_RAND; + ENGINE_get_RSA; + ENGINE_get_cipher; + ENGINE_get_cipher_engine; + ENGINE_get_ciphers; + ENGINE_get_cmd_defns; + ENGINE_get_ctrl_function; + ENGINE_get_default_DH; + ENGINE_get_default_DSA; + ENGINE_get_default_EC; + ENGINE_get_default_RAND; + ENGINE_get_default_RSA; + ENGINE_get_destroy_function; + ENGINE_get_digest; + ENGINE_get_digest_engine; + ENGINE_get_digests; + ENGINE_get_ex_data; + ENGINE_get_finish_function; + ENGINE_get_first; + ENGINE_get_flags; + ENGINE_get_id; + ENGINE_get_init_function; + ENGINE_get_last; + ENGINE_get_load_privkey_function; + ENGINE_get_load_pubkey_function; + ENGINE_get_name; + ENGINE_get_next; + ENGINE_get_pkey_asn1_meth; + ENGINE_get_pkey_asn1_meth_engine; + ENGINE_get_pkey_asn1_meth_str; + ENGINE_get_pkey_asn1_meths; + ENGINE_get_pkey_meth; + ENGINE_get_pkey_meth_engine; + ENGINE_get_pkey_meths; + ENGINE_get_prev; + ENGINE_get_ssl_client_cert_function; + ENGINE_get_static_state; + ENGINE_get_table_flags; + ENGINE_init; + ENGINE_load_builtin_engines; + ENGINE_load_private_key; + ENGINE_load_public_key; + ENGINE_load_ssl_client_cert; + ENGINE_new; + ENGINE_pkey_asn1_find_str; + ENGINE_register_DH; + ENGINE_register_DSA; + ENGINE_register_EC; + ENGINE_register_RAND; + ENGINE_register_RSA; + ENGINE_register_all_DH; + ENGINE_register_all_DSA; + ENGINE_register_all_EC; + ENGINE_register_all_RAND; + ENGINE_register_all_RSA; + ENGINE_register_all_ciphers; + ENGINE_register_all_complete; + ENGINE_register_all_digests; + ENGINE_register_all_pkey_asn1_meths; + ENGINE_register_all_pkey_meths; + ENGINE_register_ciphers; + ENGINE_register_complete; + ENGINE_register_digests; + ENGINE_register_pkey_asn1_meths; + ENGINE_register_pkey_meths; + ENGINE_remove; + ENGINE_set_DH; + ENGINE_set_DSA; + ENGINE_set_EC; + ENGINE_set_RAND; + ENGINE_set_RSA; + ENGINE_set_ciphers; + ENGINE_set_cmd_defns; + ENGINE_set_ctrl_function; + ENGINE_set_default; + ENGINE_set_default_DH; + ENGINE_set_default_DSA; + ENGINE_set_default_EC; + ENGINE_set_default_RAND; + ENGINE_set_default_RSA; + ENGINE_set_default_ciphers; + ENGINE_set_default_digests; + ENGINE_set_default_pkey_asn1_meths; + ENGINE_set_default_pkey_meths; + ENGINE_set_default_string; + ENGINE_set_destroy_function; + ENGINE_set_digests; + ENGINE_set_ex_data; + ENGINE_set_finish_function; + ENGINE_set_flags; + ENGINE_set_id; + ENGINE_set_init_function; + ENGINE_set_load_privkey_function; + ENGINE_set_load_pubkey_function; + ENGINE_set_load_ssl_client_cert_function; + ENGINE_set_name; + ENGINE_set_pkey_asn1_meths; + ENGINE_set_pkey_meths; + ENGINE_set_table_flags; + ENGINE_unregister_DH; + ENGINE_unregister_DSA; + ENGINE_unregister_EC; + ENGINE_unregister_RAND; + ENGINE_unregister_RSA; + ENGINE_unregister_ciphers; + ENGINE_unregister_digests; + ENGINE_unregister_pkey_asn1_meths; + ENGINE_unregister_pkey_meths; + ENGINE_up_ref; + ERR_add_error_data; + ERR_add_error_vdata; + ERR_clear_error; + ERR_error_string; + ERR_error_string_n; + ERR_func_error_string; + ERR_get_error; + ERR_get_error_line; + ERR_get_error_line_data; + ERR_get_next_error_library; + ERR_get_state; + ERR_lib_error_string; + ERR_load_ASN1_strings; + ERR_load_ASYNC_strings; + ERR_load_BIO_strings; + ERR_load_BN_strings; + ERR_load_BUF_strings; + ERR_load_CMS_strings; + ERR_load_COMP_strings; + ERR_load_CONF_strings; + ERR_load_CRYPTO_strings; + ERR_load_CT_strings; + ERR_load_DH_strings; + ERR_load_DSA_strings; + ERR_load_DSO_strings; + ERR_load_EC_strings; + ERR_load_ENGINE_strings; + ERR_load_ERR_strings; + ERR_load_EVP_strings; + ERR_load_KDF_strings; + ERR_load_OBJ_strings; + ERR_load_OCSP_strings; + ERR_load_PEM_strings; + ERR_load_PKCS12_strings; + ERR_load_PKCS7_strings; + ERR_load_RAND_strings; + ERR_load_RSA_strings; + ERR_load_TS_strings; + ERR_load_UI_strings; + ERR_load_X509V3_strings; + ERR_load_X509_strings; + ERR_load_strings; + ERR_peek_error; + ERR_peek_error_line; + ERR_peek_error_line_data; + ERR_peek_last_error; + ERR_peek_last_error_line; + ERR_peek_last_error_line_data; + ERR_pop_to_mark; + ERR_print_errors; + ERR_print_errors_cb; + ERR_print_errors_fp; + ERR_put_error; + ERR_reason_error_string; + ERR_remove_state; + ERR_remove_thread_state; + ERR_set_error_data; + ERR_set_mark; + ERR_unload_strings; + ESS_CERT_ID_dup; + ESS_CERT_ID_free; + ESS_CERT_ID_new; + ESS_ISSUER_SERIAL_dup; + ESS_ISSUER_SERIAL_free; + ESS_ISSUER_SERIAL_new; + ESS_SIGNING_CERT_dup; + ESS_SIGNING_CERT_free; + ESS_SIGNING_CERT_new; + EVP_BytesToKey; + EVP_CIPHER_CTX_block_size; + EVP_CIPHER_CTX_buf_noconst; + EVP_CIPHER_CTX_cipher; + EVP_CIPHER_CTX_clear_flags; + EVP_CIPHER_CTX_copy; + EVP_CIPHER_CTX_ctrl; + EVP_CIPHER_CTX_encrypting; + EVP_CIPHER_CTX_free; + EVP_CIPHER_CTX_get_app_data; + EVP_CIPHER_CTX_get_cipher_data; + EVP_CIPHER_CTX_iv; + EVP_CIPHER_CTX_iv_length; + EVP_CIPHER_CTX_iv_noconst; + EVP_CIPHER_CTX_key_length; + EVP_CIPHER_CTX_new; + EVP_CIPHER_CTX_nid; + EVP_CIPHER_CTX_num; + EVP_CIPHER_CTX_original_iv; + EVP_CIPHER_CTX_rand_key; + EVP_CIPHER_CTX_reset; + EVP_CIPHER_CTX_set_app_data; + EVP_CIPHER_CTX_set_cipher_data; + EVP_CIPHER_CTX_set_flags; + EVP_CIPHER_CTX_set_key_length; + EVP_CIPHER_CTX_set_num; + EVP_CIPHER_CTX_set_padding; + EVP_CIPHER_CTX_test_flags; + EVP_CIPHER_asn1_to_param; + EVP_CIPHER_block_size; + EVP_CIPHER_do_all; + EVP_CIPHER_do_all_sorted; + EVP_CIPHER_flags; + EVP_CIPHER_get_asn1_iv; + EVP_CIPHER_impl_ctx_size; + EVP_CIPHER_iv_length; + EVP_CIPHER_key_length; + EVP_CIPHER_meth_dup; + EVP_CIPHER_meth_free; + EVP_CIPHER_meth_get_cleanup; + EVP_CIPHER_meth_get_ctrl; + EVP_CIPHER_meth_get_do_cipher; + EVP_CIPHER_meth_get_get_asn1_params; + EVP_CIPHER_meth_get_init; + EVP_CIPHER_meth_get_set_asn1_params; + 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; + EVP_CIPHER_type; + EVP_CipherFinal; + EVP_CipherFinal_ex; + EVP_CipherInit; + EVP_CipherInit_ex; + EVP_CipherUpdate; + EVP_Cipher; + EVP_DecodeBlock; + EVP_DecodeFinal; + EVP_DecodeInit; + EVP_DecodeUpdate; + EVP_DecryptFinal; + EVP_DecryptFinal_ex; + EVP_DecryptInit; + EVP_DecryptInit_ex; + EVP_DecryptUpdate; + EVP_DigestFinal; + EVP_DigestFinal_ex; + EVP_DigestInit; + EVP_DigestInit_ex; + EVP_DigestSignFinal; + EVP_DigestSignInit; + EVP_DigestUpdate; + EVP_DigestVerifyFinal; + EVP_DigestVerifyInit; + EVP_Digest; + EVP_ENCODE_CTX_copy; + EVP_ENCODE_CTX_free; + EVP_ENCODE_CTX_new; + EVP_ENCODE_CTX_num; + EVP_EncodeBlock; + EVP_EncodeFinal; + EVP_EncodeInit; + EVP_EncodeUpdate; + EVP_EncryptFinal; + EVP_EncryptFinal_ex; + EVP_EncryptInit; + EVP_EncryptInit_ex; + EVP_EncryptUpdate; + EVP_MD_CTX_clear_flags; + EVP_MD_CTX_copy; + EVP_MD_CTX_copy_ex; + EVP_MD_CTX_ctrl; + EVP_MD_CTX_free; + EVP_MD_CTX_md; + EVP_MD_CTX_md_data; + EVP_MD_CTX_new; + EVP_MD_CTX_pkey_ctx; + EVP_MD_CTX_reset; + EVP_MD_CTX_set_flags; + EVP_MD_CTX_set_update_fn; + EVP_MD_CTX_test_flags; + EVP_MD_CTX_update_fn; + EVP_MD_block_size; + EVP_MD_do_all; + EVP_MD_do_all_sorted; + EVP_MD_flags; + EVP_MD_meth_dup; + EVP_MD_meth_free; + EVP_MD_meth_get_app_datasize; + EVP_MD_meth_get_cleanup; + EVP_MD_meth_get_copy; + EVP_MD_meth_get_ctrl; + EVP_MD_meth_get_final; + EVP_MD_meth_get_flags; + EVP_MD_meth_get_init; + EVP_MD_meth_get_input_blocksize; + EVP_MD_meth_get_result_size; + EVP_MD_meth_get_update; + EVP_MD_meth_new; + EVP_MD_meth_set_app_datasize; + EVP_MD_meth_set_cleanup; + EVP_MD_meth_set_copy; + EVP_MD_meth_set_ctrl; + EVP_MD_meth_set_final; + EVP_MD_meth_set_flags; + EVP_MD_meth_set_init; + EVP_MD_meth_set_input_blocksize; + EVP_MD_meth_set_result_size; + EVP_MD_meth_set_update; + EVP_MD_pkey_type; + EVP_MD_size; + EVP_MD_type; + EVP_OpenFinal; + EVP_OpenInit; + EVP_PBE_CipherInit; + EVP_PBE_alg_add; + EVP_PBE_alg_add_type; + EVP_PBE_cleanup; + EVP_PBE_find; + EVP_PBE_get; + EVP_PBE_scrypt; + EVP_PKCS82PKEY; + EVP_PKEY2PKCS8; + EVP_PKEY_CTX_ctrl; + EVP_PKEY_CTX_ctrl_str; + EVP_PKEY_CTX_dup; + EVP_PKEY_CTX_free; + EVP_PKEY_CTX_get0_peerkey; + EVP_PKEY_CTX_get0_pkey; + EVP_PKEY_CTX_get_app_data; + EVP_PKEY_CTX_get_cb; + EVP_PKEY_CTX_get_data; + EVP_PKEY_CTX_get_keygen_info; + EVP_PKEY_CTX_get_operation; + EVP_PKEY_CTX_hex2ctrl; + EVP_PKEY_CTX_new; + EVP_PKEY_CTX_new_id; + EVP_PKEY_CTX_set0_keygen_info; + EVP_PKEY_CTX_set_app_data; + EVP_PKEY_CTX_set_cb; + EVP_PKEY_CTX_set_data; + EVP_PKEY_CTX_str2ctrl; + EVP_PKEY_add1_attr; + EVP_PKEY_add1_attr_by_NID; + EVP_PKEY_add1_attr_by_OBJ; + EVP_PKEY_add1_attr_by_txt; + EVP_PKEY_asn1_add0; + EVP_PKEY_asn1_add_alias; + EVP_PKEY_asn1_copy; + EVP_PKEY_asn1_find; + EVP_PKEY_asn1_find_str; + EVP_PKEY_asn1_free; + EVP_PKEY_asn1_get0; + EVP_PKEY_asn1_get0_info; + EVP_PKEY_asn1_get_count; + EVP_PKEY_asn1_new; + EVP_PKEY_asn1_set_ctrl; + EVP_PKEY_asn1_set_free; + EVP_PKEY_asn1_set_item; + EVP_PKEY_asn1_set_param; + EVP_PKEY_asn1_set_private; + EVP_PKEY_asn1_set_public; + EVP_PKEY_asn1_set_security_bits; + EVP_PKEY_assign; + EVP_PKEY_base_id; + EVP_PKEY_bits; + EVP_PKEY_cmp; + EVP_PKEY_cmp_parameters; + EVP_PKEY_copy_parameters; + EVP_PKEY_decrypt; + EVP_PKEY_decrypt_init; + EVP_PKEY_decrypt_old; + EVP_PKEY_delete_attr; + EVP_PKEY_derive; + EVP_PKEY_derive_init; + EVP_PKEY_derive_set_peer; + EVP_PKEY_encrypt; + EVP_PKEY_encrypt_init; + EVP_PKEY_encrypt_old; + EVP_PKEY_free; + EVP_PKEY_get0; + EVP_PKEY_get0_DH; + EVP_PKEY_get0_DSA; + EVP_PKEY_get0_EC_KEY; + EVP_PKEY_get0_RSA; + EVP_PKEY_get0_asn1; + EVP_PKEY_get0_hmac; + EVP_PKEY_get1_DH; + EVP_PKEY_get1_DSA; + EVP_PKEY_get1_EC_KEY; + EVP_PKEY_get1_RSA; + EVP_PKEY_get1_tls_encodedpoint; + EVP_PKEY_get_attr; + EVP_PKEY_get_attr_by_NID; + EVP_PKEY_get_attr_by_OBJ; + EVP_PKEY_get_attr_count; + EVP_PKEY_get_default_digest_nid; + EVP_PKEY_id; + EVP_PKEY_keygen; + EVP_PKEY_keygen_init; + EVP_PKEY_meth_add0; + EVP_PKEY_meth_copy; + EVP_PKEY_meth_find; + EVP_PKEY_meth_free; + EVP_PKEY_meth_get0_info; + EVP_PKEY_meth_get_cleanup; + EVP_PKEY_meth_get_copy; + EVP_PKEY_meth_get_ctrl; + EVP_PKEY_meth_get_decrypt; + EVP_PKEY_meth_get_derive; + EVP_PKEY_meth_get_encrypt; + EVP_PKEY_meth_get_init; + EVP_PKEY_meth_get_keygen; + EVP_PKEY_meth_get_paramgen; + EVP_PKEY_meth_get_sign; + EVP_PKEY_meth_get_signctx; + EVP_PKEY_meth_get_verify; + EVP_PKEY_meth_get_verify_recover; + EVP_PKEY_meth_get_verifyctx; + EVP_PKEY_meth_new; + EVP_PKEY_meth_set_cleanup; + EVP_PKEY_meth_set_copy; + EVP_PKEY_meth_set_ctrl; + EVP_PKEY_meth_set_decrypt; + EVP_PKEY_meth_set_derive; + EVP_PKEY_meth_set_encrypt; + EVP_PKEY_meth_set_init; + EVP_PKEY_meth_set_keygen; + EVP_PKEY_meth_set_paramgen; + EVP_PKEY_meth_set_sign; + EVP_PKEY_meth_set_signctx; + EVP_PKEY_meth_set_verify; + EVP_PKEY_meth_set_verify_recover; + EVP_PKEY_meth_set_verifyctx; + EVP_PKEY_missing_parameters; + EVP_PKEY_new; + EVP_PKEY_new_mac_key; + EVP_PKEY_paramgen; + EVP_PKEY_paramgen_init; + EVP_PKEY_print_params; + EVP_PKEY_print_private; + EVP_PKEY_print_public; + EVP_PKEY_save_parameters; + EVP_PKEY_security_bits; + EVP_PKEY_set1_DH; + EVP_PKEY_set1_DSA; + EVP_PKEY_set1_EC_KEY; + EVP_PKEY_set1_RSA; + EVP_PKEY_set1_tls_encodedpoint; + EVP_PKEY_set_type; + EVP_PKEY_set_type_str; + EVP_PKEY_sign; + EVP_PKEY_sign_init; + EVP_PKEY_size; + EVP_PKEY_type; + EVP_PKEY_up_ref; + EVP_PKEY_verify; + EVP_PKEY_verify_init; + EVP_PKEY_verify_recover; + EVP_PKEY_verify_recover_init; + EVP_SealFinal; + EVP_SealInit; + EVP_SignFinal; + EVP_VerifyFinal; + EVP_add_alg_module; + EVP_add_cipher; + EVP_add_digest; + EVP_aes_128_cbc; + EVP_aes_128_cbc_hmac_sha1; + EVP_aes_128_cbc_hmac_sha256; + EVP_aes_128_ccm; + EVP_aes_128_cfb128; + EVP_aes_128_cfb1; + EVP_aes_128_cfb8; + EVP_aes_128_ctr; + EVP_aes_128_ecb; + EVP_aes_128_gcm; + EVP_aes_128_ocb; + EVP_aes_128_ofb; + EVP_aes_128_wrap; + EVP_aes_128_wrap_pad; + EVP_aes_128_xts; + EVP_aes_192_cbc; + EVP_aes_192_ccm; + EVP_aes_192_cfb128; + EVP_aes_192_cfb1; + EVP_aes_192_cfb8; + EVP_aes_192_ctr; + EVP_aes_192_ecb; + EVP_aes_192_gcm; + EVP_aes_192_ocb; + EVP_aes_192_ofb; + EVP_aes_192_wrap; + EVP_aes_192_wrap_pad; + EVP_aes_256_cbc; + EVP_aes_256_cbc_hmac_sha1; + EVP_aes_256_cbc_hmac_sha256; + EVP_aes_256_ccm; + EVP_aes_256_cfb128; + EVP_aes_256_cfb1; + EVP_aes_256_cfb8; + EVP_aes_256_ctr; + EVP_aes_256_ecb; + EVP_aes_256_gcm; + EVP_aes_256_ocb; + EVP_aes_256_ofb; + EVP_aes_256_wrap; + EVP_aes_256_wrap_pad; + EVP_aes_256_xts; + EVP_bf_cbc; + EVP_bf_cfb64; + EVP_bf_ecb; + EVP_bf_ofb; + EVP_blake2b512; + EVP_blake2s256; + EVP_camellia_128_cbc; + EVP_camellia_128_cfb128; + EVP_camellia_128_cfb1; + EVP_camellia_128_cfb8; + EVP_camellia_128_ctr; + EVP_camellia_128_ecb; + EVP_camellia_128_ofb; + EVP_camellia_192_cbc; + EVP_camellia_192_cfb128; + EVP_camellia_192_cfb1; + EVP_camellia_192_cfb8; + EVP_camellia_192_ctr; + EVP_camellia_192_ecb; + EVP_camellia_192_ofb; + EVP_camellia_256_cbc; + EVP_camellia_256_cfb128; + EVP_camellia_256_cfb1; + EVP_camellia_256_cfb8; + EVP_camellia_256_ctr; + EVP_camellia_256_ecb; + EVP_camellia_256_ofb; + EVP_cast5_cbc; + EVP_cast5_cfb64; + EVP_cast5_ecb; + EVP_cast5_ofb; + EVP_chacha20; + EVP_chacha20_poly1305; + EVP_des_cbc; + EVP_des_cfb1; + EVP_des_cfb64; + EVP_des_cfb8; + EVP_des_ecb; + EVP_des_ede3; + EVP_des_ede3_cbc; + EVP_des_ede3_cfb1; + EVP_des_ede3_cfb64; + EVP_des_ede3_cfb8; + EVP_des_ede3_ecb; + EVP_des_ede3_ofb; + EVP_des_ede3_wrap; + EVP_des_ede; + EVP_des_ede_cbc; + EVP_des_ede_cfb64; + EVP_des_ede_ecb; + EVP_des_ede_ofb; + EVP_des_ofb; + EVP_desx_cbc; + EVP_enc_null; + EVP_get_cipherbyname; + EVP_get_digestbyname; + EVP_get_pw_prompt; + EVP_idea_cbc; + EVP_idea_cfb64; + EVP_idea_ecb; + EVP_idea_ofb; + EVP_md4; + EVP_md5; + EVP_md5_sha1; + EVP_md_null; + EVP_mdc2; + EVP_rc2_40_cbc; + EVP_rc2_64_cbc; + EVP_rc2_cbc; + EVP_rc2_cfb64; + EVP_rc2_ecb; + EVP_rc2_ofb; + EVP_rc4; + EVP_rc4_40; + EVP_rc4_hmac_md5; + EVP_read_pw_string; + EVP_read_pw_string_min; + EVP_ripemd160; + EVP_seed_cbc; + EVP_seed_cfb128; + EVP_seed_ecb; + EVP_seed_ofb; + EVP_set_pw_prompt; + EVP_sha1; + EVP_sha224; + EVP_sha256; + EVP_sha384; + EVP_sha512; + EVP_whirlpool; + EXTENDED_KEY_USAGE_free; + EXTENDED_KEY_USAGE_new; + FIPS_mode; + FIPS_mode_set; + GENERAL_NAMES_free; + GENERAL_NAMES_new; + GENERAL_NAME_cmp; + GENERAL_NAME_dup; + GENERAL_NAME_free; + GENERAL_NAME_get0_otherName; + GENERAL_NAME_get0_value; + GENERAL_NAME_new; + GENERAL_NAME_print; + GENERAL_NAME_set0_othername; + GENERAL_NAME_set0_value; + GENERAL_SUBTREE_free; + GENERAL_SUBTREE_new; + HMAC; + HMAC_CTX_copy; + HMAC_CTX_free; + HMAC_CTX_get_md; + HMAC_CTX_new; + HMAC_CTX_reset; + HMAC_CTX_set_flags; + HMAC_Final; + HMAC_Init; + HMAC_Init_ex; + HMAC_Update; + HMAC_size; + IDEA_cbc_encrypt; + IDEA_cfb64_encrypt; + IDEA_ecb_encrypt; + IDEA_encrypt; + IDEA_ofb64_encrypt; + IDEA_options; + IDEA_set_decrypt_key; + IDEA_set_encrypt_key; + IPAddressChoice_free; + IPAddressChoice_new; + IPAddressFamily_free; + IPAddressFamily_new; + IPAddressOrRange_free; + IPAddressOrRange_new; + IPAddressRange_free; + IPAddressRange_new; + ISSUING_DIST_POINT_free; + ISSUING_DIST_POINT_new; + MD4; + MD4_Final; + MD4_Init; + MD4_Transform; + MD4_Update; + MD5; + MD5_Final; + MD5_Init; + MD5_Transform; + MD5_Update; + MDC2; + MDC2_Final; + MDC2_Init; + MDC2_Update; + NAME_CONSTRAINTS_check; + NAME_CONSTRAINTS_check_CN; + NAME_CONSTRAINTS_free; + NAME_CONSTRAINTS_new; + NCONF_WIN32; + NCONF_default; + NCONF_dump_bio; + NCONF_dump_fp; + NCONF_free; + NCONF_free_data; + NCONF_get_number_e; + NCONF_get_section; + NCONF_get_string; + NCONF_load; + NCONF_load_bio; + NCONF_load_fp; + NCONF_new; + NETSCAPE_CERT_SEQUENCE_free; + NETSCAPE_CERT_SEQUENCE_new; + NETSCAPE_SPKAC_free; + NETSCAPE_SPKAC_new; + NETSCAPE_SPKI_b64_decode; + NETSCAPE_SPKI_b64_encode; + NETSCAPE_SPKI_free; + NETSCAPE_SPKI_get_pubkey; + NETSCAPE_SPKI_new; + NETSCAPE_SPKI_print; + NETSCAPE_SPKI_set_pubkey; + NETSCAPE_SPKI_sign; + NETSCAPE_SPKI_verify; + NOTICEREF_free; + NOTICEREF_new; + OBJ_NAME_add; + OBJ_NAME_cleanup; + OBJ_NAME_do_all; + OBJ_NAME_do_all_sorted; + OBJ_NAME_get; + OBJ_NAME_init; + OBJ_NAME_new_index; + OBJ_NAME_remove; + OBJ_add_object; + OBJ_add_sigid; + OBJ_bsearch_; + OBJ_bsearch_ex_; + OBJ_cmp; + OBJ_create; + OBJ_create_objects; + OBJ_dup; + OBJ_find_sigid_algs; + OBJ_find_sigid_by_algs; + OBJ_get0_data; + OBJ_length; + OBJ_ln2nid; + OBJ_new_nid; + OBJ_nid2ln; + OBJ_nid2obj; + OBJ_nid2sn; + OBJ_obj2nid; + OBJ_obj2txt; + OBJ_sigid_free; + OBJ_sn2nid; + OBJ_txt2nid; + OBJ_txt2obj; + OCSP_BASICRESP_add1_ext_i2d; + OCSP_BASICRESP_add_ext; + OCSP_BASICRESP_delete_ext; + OCSP_BASICRESP_free; + OCSP_BASICRESP_get1_ext_d2i; + OCSP_BASICRESP_get_ext; + OCSP_BASICRESP_get_ext_by_NID; + OCSP_BASICRESP_get_ext_by_OBJ; + OCSP_BASICRESP_get_ext_by_critical; + OCSP_BASICRESP_get_ext_count; + OCSP_BASICRESP_new; + OCSP_CERTID_dup; + OCSP_CERTID_free; + OCSP_CERTID_new; + OCSP_CERTSTATUS_free; + OCSP_CERTSTATUS_new; + OCSP_CRLID_free; + OCSP_CRLID_new; + OCSP_ONEREQ_add1_ext_i2d; + OCSP_ONEREQ_add_ext; + OCSP_ONEREQ_delete_ext; + OCSP_ONEREQ_free; + OCSP_ONEREQ_get1_ext_d2i; + OCSP_ONEREQ_get_ext; + OCSP_ONEREQ_get_ext_by_NID; + OCSP_ONEREQ_get_ext_by_OBJ; + OCSP_ONEREQ_get_ext_by_critical; + OCSP_ONEREQ_get_ext_count; + OCSP_ONEREQ_new; + OCSP_REQINFO_free; + OCSP_REQINFO_new; + OCSP_REQUEST_add1_ext_i2d; + OCSP_REQUEST_add_ext; + OCSP_REQUEST_delete_ext; + OCSP_REQUEST_free; + OCSP_REQUEST_get1_ext_d2i; + OCSP_REQUEST_get_ext; + OCSP_REQUEST_get_ext_by_NID; + OCSP_REQUEST_get_ext_by_OBJ; + OCSP_REQUEST_get_ext_by_critical; + OCSP_REQUEST_get_ext_count; + OCSP_REQUEST_new; + OCSP_REQUEST_print; + OCSP_REQ_CTX_add1_header; + OCSP_REQ_CTX_free; + OCSP_REQ_CTX_get0_mem_bio; + OCSP_REQ_CTX_http; + OCSP_REQ_CTX_i2d; + OCSP_REQ_CTX_nbio; + OCSP_REQ_CTX_nbio_d2i; + OCSP_REQ_CTX_new; + OCSP_REQ_CTX_set1_req; + OCSP_RESPBYTES_free; + OCSP_RESPBYTES_new; + OCSP_RESPDATA_free; + OCSP_RESPDATA_new; + OCSP_RESPID_free; + OCSP_RESPID_new; + OCSP_RESPONSE_free; + OCSP_RESPONSE_new; + OCSP_RESPONSE_print; + OCSP_REVOKEDINFO_free; + OCSP_REVOKEDINFO_new; + OCSP_SERVICELOC_free; + OCSP_SERVICELOC_new; + OCSP_SIGNATURE_free; + OCSP_SIGNATURE_new; + OCSP_SINGLERESP_add1_ext_i2d; + OCSP_SINGLERESP_add_ext; + OCSP_SINGLERESP_delete_ext; + OCSP_SINGLERESP_free; + OCSP_SINGLERESP_get0_id; + OCSP_SINGLERESP_get1_ext_d2i; + OCSP_SINGLERESP_get_ext; + OCSP_SINGLERESP_get_ext_by_NID; + OCSP_SINGLERESP_get_ext_by_OBJ; + OCSP_SINGLERESP_get_ext_by_critical; + OCSP_SINGLERESP_get_ext_count; + OCSP_SINGLERESP_new; + OCSP_accept_responses_new; + OCSP_archive_cutoff_new; + OCSP_basic_add1_cert; + OCSP_basic_add1_nonce; + OCSP_basic_add1_status; + OCSP_basic_sign; + OCSP_basic_verify; + OCSP_cert_id_new; + OCSP_cert_status_str; + OCSP_cert_to_id; + OCSP_check_nonce; + OCSP_check_validity; + OCSP_copy_nonce; + OCSP_crlID_new; + OCSP_crl_reason_str; + OCSP_id_cmp; + OCSP_id_get0_info; + OCSP_id_issuer_cmp; + OCSP_onereq_get0_id; + OCSP_parse_url; + OCSP_request_add0_id; + OCSP_request_add1_cert; + OCSP_request_add1_nonce; + OCSP_request_is_signed; + OCSP_request_onereq_count; + OCSP_request_onereq_get0; + OCSP_request_set1_name; + OCSP_request_sign; + OCSP_request_verify; + OCSP_resp_count; + OCSP_resp_find; + OCSP_resp_find_status; + OCSP_resp_get0; + OCSP_resp_get0_certs; + OCSP_resp_get0_id; + OCSP_resp_get0_produced_at; + OCSP_resp_get0_signature; + OCSP_response_create; + OCSP_response_get1_basic; + OCSP_response_status; + OCSP_response_status_str; + OCSP_sendreq_bio; + OCSP_sendreq_nbio; + OCSP_sendreq_new; + OCSP_set_max_response_length; + OCSP_single_get0_status; + OCSP_url_svcloc_new; + OPENSSL_DIR_end; + OPENSSL_DIR_read; + OPENSSL_INIT_free; + OPENSSL_INIT_new; + OPENSSL_INIT_set_config_appname; + OPENSSL_LH_delete; + OPENSSL_LH_doall; + OPENSSL_LH_doall_arg; + OPENSSL_LH_error; + OPENSSL_LH_free; + OPENSSL_LH_get_down_load; + OPENSSL_LH_insert; + OPENSSL_LH_new; + OPENSSL_LH_node_stats; + OPENSSL_LH_node_stats_bio; + OPENSSL_LH_node_usage_stats; + OPENSSL_LH_node_usage_stats_bio; + OPENSSL_LH_num_items; + OPENSSL_LH_retrieve; + OPENSSL_LH_set_down_load; + OPENSSL_LH_stats; + OPENSSL_LH_stats_bio; + OPENSSL_LH_strhash; + OPENSSL_asc2uni; + OPENSSL_atexit; + OPENSSL_buf2hexstr; + OPENSSL_cleanse; + OPENSSL_cleanup; + OPENSSL_config; + OPENSSL_die; + OPENSSL_gmtime; + OPENSSL_gmtime_adj; + OPENSSL_gmtime_diff; + OPENSSL_hexchar2int; + OPENSSL_hexstr2buf; + OPENSSL_init; + OPENSSL_init_crypto; + OPENSSL_isservice; + OPENSSL_issetugid; + OPENSSL_load_builtin_modules; + OPENSSL_memcmp; + OPENSSL_sk_deep_copy; + OPENSSL_sk_delete; + OPENSSL_sk_delete_ptr; + OPENSSL_sk_dup; + OPENSSL_sk_find; + OPENSSL_sk_find_ex; + OPENSSL_sk_free; + OPENSSL_sk_insert; + OPENSSL_sk_is_sorted; + OPENSSL_sk_new; + OPENSSL_sk_new_null; + OPENSSL_sk_num; + OPENSSL_sk_pop; + OPENSSL_sk_pop_free; + OPENSSL_sk_push; + OPENSSL_sk_set; + OPENSSL_sk_set_cmp_func; + OPENSSL_sk_shift; + OPENSSL_sk_sort; + OPENSSL_sk_unshift; + OPENSSL_sk_value; + OPENSSL_sk_zero; + OPENSSL_strlcat; + OPENSSL_strlcpy; + OPENSSL_strnlen; + OPENSSL_thread_stop; + OPENSSL_uni2asc; + OPENSSL_uni2utf8; + OPENSSL_utf82uni; + OTHERNAME_cmp; + OTHERNAME_free; + OTHERNAME_new; + OpenSSL_version; + OpenSSL_version_num; + PBE2PARAM_free; + PBE2PARAM_new; + PBEPARAM_free; + PBEPARAM_new; + PBKDF2PARAM_free; + PBKDF2PARAM_new; + PEM_ASN1_read; + PEM_ASN1_read_bio; + PEM_ASN1_write; + PEM_ASN1_write_bio; + PEM_SignFinal; + PEM_SignInit; + PEM_SignUpdate; + PEM_X509_INFO_read; + PEM_X509_INFO_read_bio; + PEM_X509_INFO_write_bio; + PEM_bytes_read_bio; + PEM_def_callback; + PEM_dek_info; + PEM_do_header; + PEM_get_EVP_CIPHER_INFO; + PEM_proc_type; + PEM_read; + PEM_read_CMS; + PEM_read_DHparams; + PEM_read_DSAPrivateKey; + PEM_read_DSA_PUBKEY; + PEM_read_DSAparams; + PEM_read_ECPKParameters; + PEM_read_ECPrivateKey; + PEM_read_EC_PUBKEY; + PEM_read_NETSCAPE_CERT_SEQUENCE; + PEM_read_PKCS7; + PEM_read_PKCS8; + PEM_read_PKCS8_PRIV_KEY_INFO; + PEM_read_PUBKEY; + PEM_read_PrivateKey; + PEM_read_RSAPrivateKey; + PEM_read_RSAPublicKey; + PEM_read_RSA_PUBKEY; + PEM_read_X509; + PEM_read_X509_AUX; + PEM_read_X509_CRL; + PEM_read_X509_REQ; + PEM_read_bio; + PEM_read_bio_CMS; + PEM_read_bio_DHparams; + PEM_read_bio_DSAPrivateKey; + PEM_read_bio_DSA_PUBKEY; + PEM_read_bio_DSAparams; + PEM_read_bio_ECPKParameters; + PEM_read_bio_ECPrivateKey; + PEM_read_bio_EC_PUBKEY; + PEM_read_bio_NETSCAPE_CERT_SEQUENCE; + PEM_read_bio_PKCS7; + PEM_read_bio_PKCS8; + PEM_read_bio_PKCS8_PRIV_KEY_INFO; + PEM_read_bio_PUBKEY; + PEM_read_bio_Parameters; + PEM_read_bio_PrivateKey; + PEM_read_bio_RSAPrivateKey; + PEM_read_bio_RSAPublicKey; + PEM_read_bio_RSA_PUBKEY; + PEM_read_bio_X509; + PEM_read_bio_X509_AUX; + PEM_read_bio_X509_CRL; + PEM_read_bio_X509_REQ; + PEM_write; + PEM_write_CMS; + PEM_write_DHparams; + PEM_write_DHxparams; + PEM_write_DSAPrivateKey; + PEM_write_DSA_PUBKEY; + PEM_write_DSAparams; + PEM_write_ECPKParameters; + PEM_write_ECPrivateKey; + PEM_write_EC_PUBKEY; + PEM_write_NETSCAPE_CERT_SEQUENCE; + PEM_write_PKCS7; + PEM_write_PKCS8PrivateKey; + PEM_write_PKCS8PrivateKey_nid; + PEM_write_PKCS8; + PEM_write_PKCS8_PRIV_KEY_INFO; + PEM_write_PUBKEY; + PEM_write_PrivateKey; + PEM_write_RSAPrivateKey; + PEM_write_RSAPublicKey; + PEM_write_RSA_PUBKEY; + PEM_write_X509; + PEM_write_X509_AUX; + PEM_write_X509_CRL; + PEM_write_X509_REQ; + PEM_write_X509_REQ_NEW; + PEM_write_bio; + PEM_write_bio_ASN1_stream; + PEM_write_bio_CMS; + PEM_write_bio_CMS_stream; + PEM_write_bio_DHparams; + PEM_write_bio_DHxparams; + PEM_write_bio_DSAPrivateKey; + PEM_write_bio_DSA_PUBKEY; + PEM_write_bio_DSAparams; + PEM_write_bio_ECPKParameters; + PEM_write_bio_ECPrivateKey; + PEM_write_bio_EC_PUBKEY; + PEM_write_bio_NETSCAPE_CERT_SEQUENCE; + PEM_write_bio_PKCS7; + PEM_write_bio_PKCS7_stream; + PEM_write_bio_PKCS8PrivateKey; + PEM_write_bio_PKCS8PrivateKey_nid; + PEM_write_bio_PKCS8; + PEM_write_bio_PKCS8_PRIV_KEY_INFO; + PEM_write_bio_PUBKEY; + PEM_write_bio_Parameters; + PEM_write_bio_PrivateKey; + PEM_write_bio_PrivateKey_traditional; + PEM_write_bio_RSAPrivateKey; + PEM_write_bio_RSAPublicKey; + PEM_write_bio_RSA_PUBKEY; + PEM_write_bio_X509; + PEM_write_bio_X509_AUX; + PEM_write_bio_X509_CRL; + PEM_write_bio_X509_REQ; + PEM_write_bio_X509_REQ_NEW; + PKCS12_BAGS_free; + PKCS12_BAGS_new; + PKCS12_MAC_DATA_free; + PKCS12_MAC_DATA_new; + PKCS12_PBE_add; + PKCS12_PBE_keyivgen; + PKCS12_SAFEBAG_create0_p8inf; + PKCS12_SAFEBAG_create0_pkcs8; + PKCS12_SAFEBAG_create_cert; + PKCS12_SAFEBAG_create_crl; + PKCS12_SAFEBAG_create_pkcs8_encrypt; + PKCS12_SAFEBAG_free; + PKCS12_SAFEBAG_get0_attr; + PKCS12_SAFEBAG_get0_attrs; + PKCS12_SAFEBAG_get0_p8inf; + PKCS12_SAFEBAG_get0_pkcs8; + PKCS12_SAFEBAG_get0_safes; + PKCS12_SAFEBAG_get0_type; + PKCS12_SAFEBAG_get1_cert; + PKCS12_SAFEBAG_get1_crl; + PKCS12_SAFEBAG_get_bag_nid; + PKCS12_SAFEBAG_get_nid; + PKCS12_SAFEBAG_new; + PKCS12_add_CSPName_asc; + PKCS12_add_cert; + PKCS12_add_friendlyname_asc; + PKCS12_add_friendlyname_uni; + PKCS12_add_friendlyname_utf8; + PKCS12_add_key; + PKCS12_add_localkeyid; + PKCS12_add_safe; + PKCS12_add_safes; + PKCS12_create; + PKCS12_decrypt_skey; + PKCS12_free; + PKCS12_gen_mac; + PKCS12_get0_mac; + PKCS12_get_attr; + PKCS12_get_attr_gen; + PKCS12_get_friendlyname; + PKCS12_init; + PKCS12_item_decrypt_d2i; + PKCS12_item_i2d_encrypt; + PKCS12_item_pack_safebag; + PKCS12_key_gen_asc; + PKCS12_key_gen_uni; + PKCS12_key_gen_utf8; + PKCS12_mac_present; + PKCS12_new; + PKCS12_newpass; + PKCS12_pack_authsafes; + PKCS12_pack_p7data; + PKCS12_pack_p7encdata; + PKCS12_parse; + PKCS12_pbe_crypt; + PKCS12_set_mac; + PKCS12_setup_mac; + PKCS12_unpack_authsafes; + PKCS12_unpack_p7data; + PKCS12_unpack_p7encdata; + PKCS12_verify_mac; + PKCS1_MGF1; + PKCS5_PBE_add; + PKCS5_PBE_keyivgen; + PKCS5_PBKDF2_HMAC; + PKCS5_PBKDF2_HMAC_SHA1; + PKCS5_pbe2_set; + PKCS5_pbe2_set_iv; + PKCS5_pbe2_set_scrypt; + PKCS5_pbe_set0_algor; + PKCS5_pbe_set; + PKCS5_pbkdf2_set; + PKCS5_v2_PBE_keyivgen; + PKCS5_v2_scrypt_keyivgen; + PKCS7_DIGEST_free; + PKCS7_DIGEST_new; + PKCS7_ENCRYPT_free; + PKCS7_ENCRYPT_new; + PKCS7_ENC_CONTENT_free; + PKCS7_ENC_CONTENT_new; + PKCS7_ENVELOPE_free; + PKCS7_ENVELOPE_new; + PKCS7_ISSUER_AND_SERIAL_digest; + PKCS7_ISSUER_AND_SERIAL_free; + PKCS7_ISSUER_AND_SERIAL_new; + PKCS7_RECIP_INFO_free; + PKCS7_RECIP_INFO_get0_alg; + PKCS7_RECIP_INFO_new; + PKCS7_RECIP_INFO_set; + PKCS7_SIGNED_free; + PKCS7_SIGNED_new; + PKCS7_SIGNER_INFO_free; + PKCS7_SIGNER_INFO_get0_algs; + PKCS7_SIGNER_INFO_new; + PKCS7_SIGNER_INFO_set; + PKCS7_SIGNER_INFO_sign; + PKCS7_SIGN_ENVELOPE_free; + PKCS7_SIGN_ENVELOPE_new; + PKCS7_add0_attrib_signing_time; + PKCS7_add1_attrib_digest; + PKCS7_add_attrib_content_type; + PKCS7_add_attrib_smimecap; + PKCS7_add_attribute; + PKCS7_add_certificate; + PKCS7_add_crl; + PKCS7_add_recipient; + PKCS7_add_recipient_info; + PKCS7_add_signature; + PKCS7_add_signed_attribute; + PKCS7_add_signer; + PKCS7_cert_from_signer_info; + PKCS7_content_new; + PKCS7_ctrl; + PKCS7_dataDecode; + PKCS7_dataFinal; + PKCS7_dataInit; + PKCS7_dataVerify; + PKCS7_decrypt; + PKCS7_digest_from_attributes; + PKCS7_dup; + PKCS7_encrypt; + PKCS7_final; + PKCS7_free; + PKCS7_get0_signers; + PKCS7_get_attribute; + PKCS7_get_issuer_and_serial; + PKCS7_get_signed_attribute; + PKCS7_get_signer_info; + PKCS7_get_smimecap; + PKCS7_new; + PKCS7_print_ctx; + PKCS7_set0_type_other; + PKCS7_set_attributes; + PKCS7_set_cipher; + PKCS7_set_content; + PKCS7_set_digest; + PKCS7_set_signed_attributes; + PKCS7_set_type; + PKCS7_sign; + PKCS7_sign_add_signer; + PKCS7_signatureVerify; + PKCS7_simple_smimecap; + PKCS7_stream; + PKCS7_to_TS_TST_INFO; + PKCS7_verify; + PKCS8_PRIV_KEY_INFO_free; + PKCS8_PRIV_KEY_INFO_new; + PKCS8_add_keyusage; + PKCS8_decrypt; + PKCS8_encrypt; + PKCS8_get_attr; + PKCS8_pkey_add1_attr_by_NID; + PKCS8_pkey_get0; + PKCS8_pkey_get0_attrs; + PKCS8_pkey_set0; + PKCS8_set0_pbe; + PKEY_USAGE_PERIOD_free; + PKEY_USAGE_PERIOD_new; + POLICYINFO_free; + POLICYINFO_new; + POLICYQUALINFO_free; + POLICYQUALINFO_new; + POLICY_CONSTRAINTS_free; + POLICY_CONSTRAINTS_new; + POLICY_MAPPING_free; + POLICY_MAPPING_new; + PROXY_CERT_INFO_EXTENSION_free; + PROXY_CERT_INFO_EXTENSION_new; + PROXY_POLICY_free; + PROXY_POLICY_new; + RAND_OpenSSL; + RAND_add; + RAND_bytes; + RAND_file_name; + RAND_get_rand_method; + RAND_load_file; + RAND_poll; + RAND_pseudo_bytes; + RAND_seed; + RAND_set_rand_engine; + RAND_set_rand_method; + RAND_status; + RAND_write_file; + RC2_cbc_encrypt; + RC2_cfb64_encrypt; + RC2_decrypt; + RC2_ecb_encrypt; + RC2_encrypt; + RC2_ofb64_encrypt; + RC2_set_key; + RC4; + RC4_options; + RC4_set_key; + RIPEMD160; + RIPEMD160_Final; + RIPEMD160_Init; + RIPEMD160_Transform; + RIPEMD160_Update; + RSAPrivateKey_dup; + RSAPublicKey_dup; + RSA_OAEP_PARAMS_free; + RSA_OAEP_PARAMS_new; + RSA_PKCS1_OpenSSL; + RSA_PSS_PARAMS_free; + RSA_PSS_PARAMS_new; + RSA_X931_derive_ex; + RSA_X931_generate_key_ex; + RSA_X931_hash_id; + RSA_bits; + RSA_blinding_off; + RSA_blinding_on; + RSA_check_key; + RSA_check_key_ex; + RSA_clear_flags; + RSA_flags; + RSA_free; + RSA_generate_key; + RSA_generate_key_ex; + RSA_get0_crt_params; + RSA_get0_engine; + RSA_get0_factors; + RSA_get0_key; + RSA_get_default_method; + RSA_get_ex_data; + RSA_get_method; + RSA_meth_dup; + RSA_meth_free; + RSA_meth_get0_app_data; + RSA_meth_get0_name; + RSA_meth_get_bn_mod_exp; + RSA_meth_get_finish; + RSA_meth_get_flags; + RSA_meth_get_init; + RSA_meth_get_keygen; + RSA_meth_get_mod_exp; + RSA_meth_get_priv_dec; + RSA_meth_get_priv_enc; + RSA_meth_get_pub_dec; + RSA_meth_get_pub_enc; + RSA_meth_get_sign; + RSA_meth_get_verify; + RSA_meth_new; + RSA_meth_set0_app_data; + RSA_meth_set1_name; + RSA_meth_set_bn_mod_exp; + RSA_meth_set_finish; + RSA_meth_set_flags; + RSA_meth_set_init; + RSA_meth_set_keygen; + RSA_meth_set_mod_exp; + RSA_meth_set_priv_dec; + RSA_meth_set_priv_enc; + RSA_meth_set_pub_dec; + RSA_meth_set_pub_enc; + RSA_meth_set_sign; + RSA_meth_set_verify; + RSA_new; + RSA_new_method; + RSA_null_method; + RSA_padding_add_PKCS1_OAEP; + RSA_padding_add_PKCS1_OAEP_mgf1; + RSA_padding_add_PKCS1_PSS; + RSA_padding_add_PKCS1_PSS_mgf1; + RSA_padding_add_PKCS1_type_1; + RSA_padding_add_PKCS1_type_2; + RSA_padding_add_SSLv23; + RSA_padding_add_X931; + RSA_padding_add_none; + RSA_padding_check_PKCS1_OAEP; + RSA_padding_check_PKCS1_OAEP_mgf1; + RSA_padding_check_PKCS1_type_1; + RSA_padding_check_PKCS1_type_2; + RSA_padding_check_SSLv23; + RSA_padding_check_X931; + RSA_padding_check_none; + RSA_print; + RSA_print_fp; + RSA_private_decrypt; + RSA_private_encrypt; + RSA_public_decrypt; + RSA_public_encrypt; + RSA_security_bits; + RSA_set0_crt_params; + RSA_set0_factors; + RSA_set0_key; + RSA_set_default_method; + RSA_set_ex_data; + RSA_set_flags; + RSA_set_method; + RSA_setup_blinding; + RSA_sign; + RSA_sign_ASN1_OCTET_STRING; + RSA_size; + RSA_test_flags; + RSA_up_ref; + RSA_verify; + RSA_verify_ASN1_OCTET_STRING; + RSA_verify_PKCS1_PSS; + RSA_verify_PKCS1_PSS_mgf1; + SCT_LIST_free; + SCT_LIST_print; + SCT_LIST_validate; + SCT_free; + SCT_get0_extensions; + SCT_get0_log_id; + SCT_get0_signature; + SCT_get_log_entry_type; + SCT_get_signature_nid; + SCT_get_source; + SCT_get_timestamp; + SCT_get_validation_status; + SCT_get_version; + SCT_new; + SCT_new_from_base64; + SCT_print; + SCT_set0_extensions; + SCT_set0_log_id; + SCT_set0_signature; + SCT_set1_extensions; + SCT_set1_log_id; + SCT_set1_signature; + SCT_set_log_entry_type; + SCT_set_signature_nid; + SCT_set_source; + SCT_set_timestamp; + SCT_set_version; + SCT_validate; + SCT_validation_status_string; + SEED_cbc_encrypt; + SEED_cfb128_encrypt; + SEED_decrypt; + SEED_ecb_encrypt; + SEED_encrypt; + SEED_ofb128_encrypt; + SEED_set_key; + SHA1; + SHA1_Final; + SHA1_Init; + SHA1_Transform; + SHA1_Update; + SHA224; + SHA224_Final; + SHA224_Init; + SHA224_Update; + SHA256; + SHA256_Final; + SHA256_Init; + SHA256_Transform; + SHA256_Update; + SHA384; + SHA384_Final; + SHA384_Init; + SHA384_Update; + SHA512; + SHA512_Final; + SHA512_Init; + SHA512_Transform; + SHA512_Update; + SMIME_crlf_copy; + SMIME_read_ASN1; + SMIME_read_CMS; + SMIME_read_PKCS7; + SMIME_text; + SMIME_write_ASN1; + SMIME_write_CMS; + SMIME_write_PKCS7; + SRP_Calc_A; + SRP_Calc_B; + SRP_Calc_client_key; + SRP_Calc_server_key; + SRP_Calc_u; + SRP_Calc_x; + SRP_VBASE_free; + SRP_VBASE_get1_by_user; + SRP_VBASE_get_by_user; + SRP_VBASE_init; + SRP_VBASE_new; + SRP_Verify_A_mod_N; + SRP_Verify_B_mod_N; + SRP_check_known_gN_param; + SRP_create_verifier; + SRP_create_verifier_BN; + SRP_get_default_gN; + SRP_user_pwd_free; + SXNETID_free; + SXNETID_new; + SXNET_add_id_INTEGER; + SXNET_add_id_asc; + SXNET_add_id_ulong; + SXNET_free; + SXNET_get_id_INTEGER; + SXNET_get_id_asc; + SXNET_get_id_ulong; + SXNET_new; + TLS_FEATURE_free; + TLS_FEATURE_new; + TS_ACCURACY_dup; + TS_ACCURACY_free; + TS_ACCURACY_get_micros; + TS_ACCURACY_get_millis; + TS_ACCURACY_get_seconds; + TS_ACCURACY_new; + TS_ACCURACY_set_micros; + TS_ACCURACY_set_millis; + TS_ACCURACY_set_seconds; + TS_ASN1_INTEGER_print_bio; + TS_CONF_get_tsa_section; + TS_CONF_load_cert; + TS_CONF_load_certs; + TS_CONF_load_key; + TS_CONF_set_accuracy; + TS_CONF_set_certs; + TS_CONF_set_clock_precision_digits; + TS_CONF_set_crypto_device; + TS_CONF_set_def_policy; + TS_CONF_set_default_engine; + TS_CONF_set_digests; + TS_CONF_set_ess_cert_id_chain; + TS_CONF_set_ordering; + TS_CONF_set_policies; + TS_CONF_set_serial; + TS_CONF_set_signer_cert; + TS_CONF_set_signer_digest; + TS_CONF_set_signer_key; + TS_CONF_set_tsa_name; + TS_MSG_IMPRINT_dup; + TS_MSG_IMPRINT_free; + TS_MSG_IMPRINT_get_algo; + TS_MSG_IMPRINT_get_msg; + TS_MSG_IMPRINT_new; + TS_MSG_IMPRINT_print_bio; + TS_MSG_IMPRINT_set_algo; + TS_MSG_IMPRINT_set_msg; + TS_OBJ_print_bio; + TS_REQ_add_ext; + TS_REQ_delete_ext; + TS_REQ_dup; + TS_REQ_ext_free; + TS_REQ_free; + TS_REQ_get_cert_req; + TS_REQ_get_ext; + TS_REQ_get_ext_by_NID; + TS_REQ_get_ext_by_OBJ; + TS_REQ_get_ext_by_critical; + TS_REQ_get_ext_count; + TS_REQ_get_ext_d2i; + TS_REQ_get_exts; + TS_REQ_get_msg_imprint; + TS_REQ_get_nonce; + TS_REQ_get_policy_id; + TS_REQ_get_version; + TS_REQ_new; + TS_REQ_print_bio; + TS_REQ_set_cert_req; + TS_REQ_set_msg_imprint; + TS_REQ_set_nonce; + TS_REQ_set_policy_id; + TS_REQ_set_version; + TS_REQ_to_TS_VERIFY_CTX; + TS_RESP_CTX_add_failure_info; + TS_RESP_CTX_add_flags; + TS_RESP_CTX_add_md; + TS_RESP_CTX_add_policy; + TS_RESP_CTX_free; + TS_RESP_CTX_get_request; + TS_RESP_CTX_get_tst_info; + TS_RESP_CTX_new; + TS_RESP_CTX_set_accuracy; + TS_RESP_CTX_set_certs; + TS_RESP_CTX_set_clock_precision_digits; + TS_RESP_CTX_set_def_policy; + TS_RESP_CTX_set_extension_cb; + TS_RESP_CTX_set_serial_cb; + TS_RESP_CTX_set_signer_cert; + TS_RESP_CTX_set_signer_digest; + TS_RESP_CTX_set_signer_key; + TS_RESP_CTX_set_status_info; + TS_RESP_CTX_set_status_info_cond; + TS_RESP_CTX_set_time_cb; + TS_RESP_create_response; + TS_RESP_dup; + TS_RESP_free; + TS_RESP_get_status_info; + TS_RESP_get_token; + TS_RESP_get_tst_info; + TS_RESP_new; + TS_RESP_print_bio; + TS_RESP_set_status_info; + TS_RESP_set_tst_info; + TS_RESP_verify_response; + TS_RESP_verify_signature; + TS_RESP_verify_token; + TS_STATUS_INFO_dup; + TS_STATUS_INFO_free; + TS_STATUS_INFO_get0_failure_info; + TS_STATUS_INFO_get0_status; + TS_STATUS_INFO_get0_text; + TS_STATUS_INFO_new; + TS_STATUS_INFO_print_bio; + TS_STATUS_INFO_set_status; + TS_TST_INFO_add_ext; + TS_TST_INFO_delete_ext; + TS_TST_INFO_dup; + TS_TST_INFO_ext_free; + TS_TST_INFO_free; + TS_TST_INFO_get_accuracy; + TS_TST_INFO_get_ext; + TS_TST_INFO_get_ext_by_NID; + TS_TST_INFO_get_ext_by_OBJ; + TS_TST_INFO_get_ext_by_critical; + TS_TST_INFO_get_ext_count; + TS_TST_INFO_get_ext_d2i; + TS_TST_INFO_get_exts; + TS_TST_INFO_get_msg_imprint; + TS_TST_INFO_get_nonce; + TS_TST_INFO_get_ordering; + TS_TST_INFO_get_policy_id; + TS_TST_INFO_get_serial; + TS_TST_INFO_get_time; + TS_TST_INFO_get_tsa; + TS_TST_INFO_get_version; + TS_TST_INFO_new; + TS_TST_INFO_print_bio; + TS_TST_INFO_set_accuracy; + TS_TST_INFO_set_msg_imprint; + TS_TST_INFO_set_nonce; + TS_TST_INFO_set_ordering; + TS_TST_INFO_set_policy_id; + TS_TST_INFO_set_serial; + TS_TST_INFO_set_time; + TS_TST_INFO_set_tsa; + TS_TST_INFO_set_version; + TS_VERIFY_CTS_set_certs; + TS_VERIFY_CTX_add_flags; + TS_VERIFY_CTX_cleanup; + TS_VERIFY_CTX_free; + TS_VERIFY_CTX_init; + TS_VERIFY_CTX_new; + TS_VERIFY_CTX_set_data; + TS_VERIFY_CTX_set_flags; + TS_VERIFY_CTX_set_imprint; + TS_VERIFY_CTX_set_store; + TS_X509_ALGOR_print_bio; + TS_ext_print_bio; + TXT_DB_create_index; + TXT_DB_free; + TXT_DB_get_by_index; + TXT_DB_insert; + TXT_DB_read; + TXT_DB_write; + UI_OpenSSL; + UI_UTIL_read_pw; + UI_UTIL_read_pw_string; + UI_add_error_string; + UI_add_info_string; + UI_add_input_boolean; + UI_add_input_string; + UI_add_user_data; + UI_add_verify_string; + UI_construct_prompt; + UI_create_method; + UI_ctrl; + UI_destroy_method; + UI_dup_error_string; + UI_dup_info_string; + UI_dup_input_boolean; + UI_dup_input_string; + UI_dup_verify_string; + UI_free; + UI_get0_action_string; + UI_get0_output_string; + UI_get0_result; + UI_get0_result_string; + UI_get0_test_string; + UI_get0_user_data; + UI_get_default_method; + UI_get_ex_data; + UI_get_input_flags; + UI_get_method; + UI_get_result_maxsize; + UI_get_result_minsize; + UI_get_string_type; + UI_method_get_closer; + UI_method_get_flusher; + UI_method_get_opener; + UI_method_get_prompt_constructor; + UI_method_get_reader; + UI_method_get_writer; + UI_method_set_closer; + UI_method_set_flusher; + UI_method_set_opener; + UI_method_set_prompt_constructor; + UI_method_set_reader; + UI_method_set_writer; + UI_new; + UI_new_method; + UI_process; + UI_set_default_method; + UI_set_ex_data; + UI_set_method; + UI_set_result; + USERNOTICE_free; + USERNOTICE_new; + UTF8_getc; + UTF8_putc; + WHIRLPOOL; + WHIRLPOOL_BitUpdate; + WHIRLPOOL_Final; + WHIRLPOOL_Init; + WHIRLPOOL_Update; + X509V3_EXT_CRL_add_conf; + X509V3_EXT_CRL_add_nconf; + X509V3_EXT_REQ_add_conf; + X509V3_EXT_REQ_add_nconf; + X509V3_EXT_add; + X509V3_EXT_add_alias; + X509V3_EXT_add_conf; + X509V3_EXT_add_list; + X509V3_EXT_add_nconf; + X509V3_EXT_add_nconf_sk; + X509V3_EXT_cleanup; + X509V3_EXT_conf; + X509V3_EXT_conf_nid; + X509V3_EXT_d2i; + X509V3_EXT_get; + X509V3_EXT_get_nid; + X509V3_EXT_i2d; + X509V3_EXT_nconf; + X509V3_EXT_nconf_nid; + X509V3_EXT_print; + X509V3_EXT_print_fp; + X509V3_EXT_val_prn; + X509V3_NAME_from_section; + X509V3_add1_i2d; + X509V3_add_standard_extensions; + X509V3_add_value; + X509V3_add_value_bool; + X509V3_add_value_bool_nf; + X509V3_add_value_int; + X509V3_add_value_uchar; + X509V3_conf_free; + X509V3_extensions_print; + X509V3_get_d2i; + X509V3_get_section; + X509V3_get_string; + X509V3_get_value_bool; + X509V3_get_value_int; + X509V3_parse_list; + X509V3_section_free; + X509V3_set_conf_lhash; + X509V3_set_ctx; + X509V3_set_nconf; + X509V3_string_free; + X509_ALGOR_cmp; + X509_ALGOR_dup; + X509_ALGOR_free; + X509_ALGOR_get0; + X509_ALGOR_new; + X509_ALGOR_set0; + X509_ALGOR_set_md; + X509_ATTRIBUTE_count; + X509_ATTRIBUTE_create; + X509_ATTRIBUTE_create_by_NID; + X509_ATTRIBUTE_create_by_OBJ; + X509_ATTRIBUTE_create_by_txt; + X509_ATTRIBUTE_dup; + X509_ATTRIBUTE_free; + X509_ATTRIBUTE_get0_data; + X509_ATTRIBUTE_get0_object; + X509_ATTRIBUTE_get0_type; + X509_ATTRIBUTE_new; + X509_ATTRIBUTE_set1_data; + X509_ATTRIBUTE_set1_object; + X509_CERT_AUX_free; + X509_CERT_AUX_new; + X509_CINF_free; + X509_CINF_new; + X509_CRL_INFO_free; + X509_CRL_INFO_new; + X509_CRL_METHOD_free; + X509_CRL_METHOD_new; + X509_CRL_add0_revoked; + X509_CRL_add1_ext_i2d; + X509_CRL_add_ext; + X509_CRL_check_suiteb; + X509_CRL_cmp; + X509_CRL_delete_ext; + X509_CRL_diff; + X509_CRL_digest; + X509_CRL_dup; + X509_CRL_free; + X509_CRL_get0_by_cert; + X509_CRL_get0_by_serial; + X509_CRL_get0_extensions; + X509_CRL_get0_lastUpdate; + X509_CRL_get0_nextUpdate; + X509_CRL_get0_signature; + X509_CRL_get_REVOKED; + X509_CRL_get_ext; + X509_CRL_get_ext_by_NID; + X509_CRL_get_ext_by_OBJ; + X509_CRL_get_ext_by_critical; + X509_CRL_get_ext_count; + X509_CRL_get_ext_d2i; + X509_CRL_get_issuer; + X509_CRL_get_lastUpdate; + X509_CRL_get_meth_data; + X509_CRL_get_nextUpdate; + X509_CRL_get_signature_nid; + X509_CRL_get_version; + X509_CRL_http_nbio; + X509_CRL_match; + X509_CRL_new; + X509_CRL_print; + X509_CRL_print_fp; + X509_CRL_set1_lastUpdate; + X509_CRL_set1_nextUpdate; + X509_CRL_set_default_method; + X509_CRL_set_issuer_name; + X509_CRL_set_meth_data; + X509_CRL_set_version; + X509_CRL_sign; + X509_CRL_sign_ctx; + X509_CRL_sort; + X509_CRL_up_ref; + X509_CRL_verify; + X509_EXTENSION_create_by_NID; + X509_EXTENSION_create_by_OBJ; + X509_EXTENSION_dup; + X509_EXTENSION_free; + X509_EXTENSION_get_critical; + X509_EXTENSION_get_data; + X509_EXTENSION_get_object; + X509_EXTENSION_new; + X509_EXTENSION_set_critical; + X509_EXTENSION_set_data; + X509_EXTENSION_set_object; + X509_INFO_free; + X509_INFO_new; + X509_LOOKUP_by_alias; + X509_LOOKUP_by_fingerprint; + X509_LOOKUP_by_issuer_serial; + X509_LOOKUP_by_subject; + X509_LOOKUP_ctrl; + X509_LOOKUP_file; + X509_LOOKUP_free; + X509_LOOKUP_hash_dir; + X509_LOOKUP_init; + X509_LOOKUP_new; + X509_LOOKUP_shutdown; + X509_NAME_ENTRY_create_by_NID; + X509_NAME_ENTRY_create_by_OBJ; + X509_NAME_ENTRY_create_by_txt; + X509_NAME_ENTRY_dup; + X509_NAME_ENTRY_free; + X509_NAME_ENTRY_get_data; + X509_NAME_ENTRY_get_object; + X509_NAME_ENTRY_new; + X509_NAME_ENTRY_set; + X509_NAME_ENTRY_set_data; + X509_NAME_ENTRY_set_object; + X509_NAME_add_entry; + X509_NAME_add_entry_by_NID; + X509_NAME_add_entry_by_OBJ; + X509_NAME_add_entry_by_txt; + X509_NAME_cmp; + X509_NAME_delete_entry; + X509_NAME_digest; + X509_NAME_dup; + X509_NAME_entry_count; + X509_NAME_free; + X509_NAME_get0_der; + X509_NAME_get_entry; + X509_NAME_get_index_by_NID; + X509_NAME_get_index_by_OBJ; + X509_NAME_get_text_by_NID; + X509_NAME_get_text_by_OBJ; + X509_NAME_hash; + X509_NAME_hash_old; + X509_NAME_new; + X509_NAME_oneline; + X509_NAME_print; + X509_NAME_print_ex; + X509_NAME_print_ex_fp; + X509_NAME_set; + X509_OBJECT_free; + X509_OBJECT_get0_X509; + X509_OBJECT_get0_X509_CRL; + X509_OBJECT_get_type; + X509_OBJECT_idx_by_subject; + X509_OBJECT_new; + X509_OBJECT_retrieve_by_subject; + X509_OBJECT_retrieve_match; + X509_OBJECT_up_ref_count; + X509_PKEY_free; + X509_PKEY_new; + X509_POLICY_NODE_print; + X509_PUBKEY_free; + X509_PUBKEY_get0; + X509_PUBKEY_get0_param; + X509_PUBKEY_get; + X509_PUBKEY_new; + X509_PUBKEY_set0_param; + X509_PUBKEY_set; + X509_PURPOSE_add; + X509_PURPOSE_cleanup; + X509_PURPOSE_get0; + X509_PURPOSE_get0_name; + X509_PURPOSE_get0_sname; + X509_PURPOSE_get_by_id; + X509_PURPOSE_get_by_sname; + X509_PURPOSE_get_count; + X509_PURPOSE_get_id; + X509_PURPOSE_get_trust; + X509_PURPOSE_set; + X509_REQ_INFO_free; + X509_REQ_INFO_new; + X509_REQ_add1_attr; + X509_REQ_add1_attr_by_NID; + X509_REQ_add1_attr_by_OBJ; + X509_REQ_add1_attr_by_txt; + X509_REQ_add_extensions; + X509_REQ_add_extensions_nid; + X509_REQ_check_private_key; + X509_REQ_delete_attr; + X509_REQ_digest; + X509_REQ_dup; + X509_REQ_extension_nid; + X509_REQ_free; + X509_REQ_get0_pubkey; + X509_REQ_get0_signature; + X509_REQ_get1_email; + X509_REQ_get_X509_PUBKEY; + X509_REQ_get_attr; + X509_REQ_get_attr_by_NID; + X509_REQ_get_attr_by_OBJ; + X509_REQ_get_attr_count; + X509_REQ_get_extension_nids; + X509_REQ_get_extensions; + X509_REQ_get_pubkey; + X509_REQ_get_signature_nid; + X509_REQ_get_subject_name; + X509_REQ_get_version; + X509_REQ_new; + X509_REQ_print; + X509_REQ_print_ex; + X509_REQ_print_fp; + X509_REQ_set_extension_nids; + X509_REQ_set_pubkey; + X509_REQ_set_subject_name; + X509_REQ_set_version; + X509_REQ_sign; + X509_REQ_sign_ctx; + X509_REQ_to_X509; + X509_REQ_verify; + X509_REVOKED_add1_ext_i2d; + X509_REVOKED_add_ext; + X509_REVOKED_delete_ext; + X509_REVOKED_dup; + X509_REVOKED_free; + X509_REVOKED_get0_extensions; + X509_REVOKED_get0_revocationDate; + X509_REVOKED_get0_serialNumber; + X509_REVOKED_get_ext; + X509_REVOKED_get_ext_by_NID; + X509_REVOKED_get_ext_by_OBJ; + X509_REVOKED_get_ext_by_critical; + X509_REVOKED_get_ext_count; + X509_REVOKED_get_ext_d2i; + X509_REVOKED_new; + X509_REVOKED_set_revocationDate; + X509_REVOKED_set_serialNumber; + X509_SIG_free; + X509_SIG_get0; + X509_SIG_getm; + X509_SIG_new; + X509_STORE_CTX_cleanup; + X509_STORE_CTX_free; + X509_STORE_CTX_get0_cert; + X509_STORE_CTX_get0_chain; + X509_STORE_CTX_get0_current_crl; + X509_STORE_CTX_get0_current_issuer; + X509_STORE_CTX_get0_param; + X509_STORE_CTX_get0_parent_ctx; + X509_STORE_CTX_get0_policy_tree; + X509_STORE_CTX_get0_store; + X509_STORE_CTX_get0_untrusted; + X509_STORE_CTX_get1_certs; + X509_STORE_CTX_get1_chain; + X509_STORE_CTX_get1_crls; + X509_STORE_CTX_get1_issuer; + X509_STORE_CTX_get_by_subject; + X509_STORE_CTX_get_cert_crl; + X509_STORE_CTX_get_check_crl; + X509_STORE_CTX_get_check_issued; + X509_STORE_CTX_get_check_policy; + X509_STORE_CTX_get_check_revocation; + X509_STORE_CTX_get_cleanup; + X509_STORE_CTX_get_current_cert; + X509_STORE_CTX_get_error; + X509_STORE_CTX_get_error_depth; + X509_STORE_CTX_get_ex_data; + X509_STORE_CTX_get_explicit_policy; + X509_STORE_CTX_get_get_crl; + X509_STORE_CTX_get_get_issuer; + X509_STORE_CTX_get_lookup_certs; + X509_STORE_CTX_get_lookup_crls; + X509_STORE_CTX_get_num_untrusted; + X509_STORE_CTX_get_obj_by_subject; + X509_STORE_CTX_get_verify; + X509_STORE_CTX_get_verify_cb; + X509_STORE_CTX_init; + X509_STORE_CTX_new; + X509_STORE_CTX_purpose_inherit; + X509_STORE_CTX_set0_crls; + X509_STORE_CTX_set0_dane; + X509_STORE_CTX_set0_param; + X509_STORE_CTX_set0_trusted_stack; + X509_STORE_CTX_set0_untrusted; + X509_STORE_CTX_set0_verified_chain; + X509_STORE_CTX_set_cert; + X509_STORE_CTX_set_current_cert; + X509_STORE_CTX_set_default; + X509_STORE_CTX_set_depth; + X509_STORE_CTX_set_error; + X509_STORE_CTX_set_error_depth; + X509_STORE_CTX_set_ex_data; + X509_STORE_CTX_set_flags; + X509_STORE_CTX_set_purpose; + X509_STORE_CTX_set_time; + X509_STORE_CTX_set_trust; + X509_STORE_CTX_set_verify; + X509_STORE_CTX_set_verify_cb; + X509_STORE_add_cert; + X509_STORE_add_crl; + X509_STORE_add_lookup; + X509_STORE_free; + X509_STORE_get0_objects; + X509_STORE_get0_param; + X509_STORE_get_cert_crl; + X509_STORE_get_check_crl; + X509_STORE_get_check_issued; + X509_STORE_get_check_policy; + X509_STORE_get_check_revocation; + X509_STORE_get_cleanup; + X509_STORE_get_ex_data; + X509_STORE_get_get_crl; + X509_STORE_get_get_issuer; + X509_STORE_get_lookup_certs; + X509_STORE_get_lookup_crls; + X509_STORE_get_verify; + X509_STORE_get_verify_cb; + X509_STORE_load_locations; + X509_STORE_lock; + X509_STORE_new; + X509_STORE_set1_param; + X509_STORE_set_cert_crl; + X509_STORE_set_check_crl; + X509_STORE_set_check_issued; + X509_STORE_set_check_policy; + X509_STORE_set_check_revocation; + X509_STORE_set_cleanup; + X509_STORE_set_default_paths; + X509_STORE_set_depth; + X509_STORE_set_ex_data; + X509_STORE_set_flags; + X509_STORE_set_get_crl; + X509_STORE_set_get_issuer; + X509_STORE_set_lookup_certs; + X509_STORE_set_lookup_crls; + X509_STORE_set_purpose; + X509_STORE_set_trust; + X509_STORE_set_verify; + X509_STORE_set_verify_cb; + X509_STORE_unlock; + X509_STORE_up_ref; + X509_TRUST_add; + X509_TRUST_cleanup; + X509_TRUST_get0; + X509_TRUST_get0_name; + X509_TRUST_get_by_id; + X509_TRUST_get_count; + X509_TRUST_get_flags; + X509_TRUST_get_trust; + X509_TRUST_set; + X509_TRUST_set_default; + X509_VAL_free; + X509_VAL_new; + X509_VERIFY_PARAM_add0_policy; + X509_VERIFY_PARAM_add0_table; + X509_VERIFY_PARAM_add1_host; + X509_VERIFY_PARAM_clear_flags; + X509_VERIFY_PARAM_free; + X509_VERIFY_PARAM_get0; + X509_VERIFY_PARAM_get0_name; + X509_VERIFY_PARAM_get0_peername; + X509_VERIFY_PARAM_get_auth_level; + X509_VERIFY_PARAM_get_count; + X509_VERIFY_PARAM_get_depth; + X509_VERIFY_PARAM_get_flags; + X509_VERIFY_PARAM_inherit; + X509_VERIFY_PARAM_lookup; + X509_VERIFY_PARAM_move_peername; + X509_VERIFY_PARAM_new; + X509_VERIFY_PARAM_set1; + X509_VERIFY_PARAM_set1_email; + X509_VERIFY_PARAM_set1_host; + X509_VERIFY_PARAM_set1_ip; + X509_VERIFY_PARAM_set1_ip_asc; + X509_VERIFY_PARAM_set1_name; + X509_VERIFY_PARAM_set1_policies; + X509_VERIFY_PARAM_set_auth_level; + X509_VERIFY_PARAM_set_depth; + X509_VERIFY_PARAM_set_flags; + X509_VERIFY_PARAM_set_hostflags; + X509_VERIFY_PARAM_set_purpose; + X509_VERIFY_PARAM_set_time; + X509_VERIFY_PARAM_set_trust; + X509_VERIFY_PARAM_table_cleanup; + X509_add1_ext_i2d; + X509_add1_reject_object; + X509_add1_trust_object; + X509_add_ext; + X509_alias_get0; + X509_alias_set1; + X509_aux_print; + X509_certificate_type; + X509_chain_check_suiteb; + X509_chain_up_ref; + X509_check_akid; + X509_check_ca; + X509_check_email; + X509_check_host; + X509_check_ip; + X509_check_ip_asc; + X509_check_issued; + X509_check_private_key; + X509_check_purpose; + X509_check_trust; + X509_cmp; + X509_cmp_current_time; + X509_cmp_time; + X509_delete_ext; + X509_digest; + X509_dup; + X509_email_free; + X509_find_by_issuer_and_serial; + X509_find_by_subject; + X509_free; + X509_get0_extensions; + X509_get0_notAfter; + X509_get0_notBefore; + X509_get0_pubkey; + X509_get0_pubkey_bitstr; + X509_get0_reject_objects; + X509_get0_serialNumber; + X509_get0_signature; + X509_get0_subject_key_id; + X509_get0_tbs_sigalg; + X509_get0_trust_objects; + X509_get0_uids; + X509_get1_email; + X509_get1_ocsp; + X509_get_X509_PUBKEY; + X509_get_default_cert_area; + X509_get_default_cert_dir; + X509_get_default_cert_dir_env; + X509_get_default_cert_file; + X509_get_default_cert_file_env; + X509_get_default_private_dir; + X509_get_ex_data; + X509_get_ext; + X509_get_ext_by_NID; + X509_get_ext_by_OBJ; + X509_get_ext_by_critical; + X509_get_ext_count; + X509_get_ext_d2i; + X509_get_extended_key_usage; + X509_get_extension_flags; + X509_get_issuer_name; + X509_get_key_usage; + X509_get_pathlen; + X509_get_proxy_pathlen; + X509_get_pubkey; + X509_get_pubkey_parameters; + X509_get_serialNumber; + X509_get_signature_nid; + X509_get_signature_type; + X509_get_subject_name; + X509_get_version; + X509_getm_notAfter; + X509_getm_notBefore; + X509_gmtime_adj; + X509_http_nbio; + X509_issuer_and_serial_cmp; + X509_issuer_and_serial_hash; + X509_issuer_name_cmp; + X509_issuer_name_hash; + X509_issuer_name_hash_old; + X509_keyid_get0; + X509_keyid_set1; + X509_load_cert_crl_file; + X509_load_cert_file; + X509_load_crl_file; + X509_new; + X509_ocspid_print; + X509_policy_check; + X509_policy_level_get0_node; + X509_policy_level_node_count; + X509_policy_node_get0_parent; + X509_policy_node_get0_policy; + X509_policy_node_get0_qualifiers; + X509_policy_tree_free; + X509_policy_tree_get0_level; + X509_policy_tree_get0_policies; + X509_policy_tree_get0_user_policies; + X509_policy_tree_level_count; + X509_print; + X509_print_ex; + X509_print_ex_fp; + X509_print_fp; + X509_pubkey_digest; + X509_reject_clear; + X509_set1_notAfter; + X509_set1_notBefore; + X509_set_ex_data; + X509_set_issuer_name; + X509_set_proxy_flag; + X509_set_proxy_pathlen; + X509_set_pubkey; + X509_set_serialNumber; + X509_set_subject_name; + X509_set_version; + X509_sign; + X509_sign_ctx; + X509_signature_dump; + X509_signature_print; + X509_subject_name_cmp; + X509_subject_name_hash; + X509_subject_name_hash_old; + X509_supported_extension; + X509_time_adj; + X509_time_adj_ex; + X509_to_X509_REQ; + X509_trust_clear; + X509_trusted; + X509_up_ref; + X509_verify; + X509_verify_cert; + X509_verify_cert_error_string; + X509at_add1_attr; + X509at_add1_attr_by_NID; + X509at_add1_attr_by_OBJ; + X509at_add1_attr_by_txt; + X509at_delete_attr; + X509at_get0_data_by_OBJ; + X509at_get_attr; + X509at_get_attr_by_NID; + X509at_get_attr_by_OBJ; + X509at_get_attr_count; + X509v3_add_ext; + X509v3_addr_add_inherit; + X509v3_addr_add_prefix; + X509v3_addr_add_range; + X509v3_addr_canonize; + X509v3_addr_get_afi; + X509v3_addr_get_range; + X509v3_addr_inherits; + X509v3_addr_is_canonical; + X509v3_addr_subset; + X509v3_addr_validate_path; + X509v3_addr_validate_resource_set; + X509v3_asid_add_id_or_range; + X509v3_asid_add_inherit; + X509v3_asid_canonize; + X509v3_asid_inherits; + X509v3_asid_is_canonical; + X509v3_asid_subset; + X509v3_asid_validate_path; + X509v3_asid_validate_resource_set; + X509v3_delete_ext; + X509v3_get_ext; + X509v3_get_ext_by_NID; + X509v3_get_ext_by_OBJ; + X509v3_get_ext_by_critical; + X509v3_get_ext_count; + a2d_ASN1_OBJECT; + a2i_ASN1_ENUMERATED; + a2i_ASN1_INTEGER; + a2i_ASN1_STRING; + a2i_GENERAL_NAME; + a2i_IPADDRESS; + a2i_IPADDRESS_NC; + b2i_PVK_bio; + b2i_PrivateKey; + b2i_PrivateKey_bio; + b2i_PublicKey; + b2i_PublicKey_bio; + d2i_ACCESS_DESCRIPTION; + d2i_ASIdOrRange; + d2i_ASIdentifierChoice; + d2i_ASIdentifiers; + d2i_ASN1_BIT_STRING; + d2i_ASN1_BMPSTRING; + d2i_ASN1_ENUMERATED; + d2i_ASN1_GENERALIZEDTIME; + d2i_ASN1_GENERALSTRING; + d2i_ASN1_IA5STRING; + d2i_ASN1_INTEGER; + d2i_ASN1_NULL; + d2i_ASN1_OBJECT; + d2i_ASN1_OCTET_STRING; + d2i_ASN1_PRINTABLESTRING; + d2i_ASN1_PRINTABLE; + d2i_ASN1_SEQUENCE_ANY; + d2i_ASN1_SET_ANY; + d2i_ASN1_T61STRING; + d2i_ASN1_TIME; + d2i_ASN1_TYPE; + d2i_ASN1_UINTEGER; + d2i_ASN1_UNIVERSALSTRING; + d2i_ASN1_UTCTIME; + d2i_ASN1_UTF8STRING; + d2i_ASN1_VISIBLESTRING; + d2i_ASRange; + d2i_AUTHORITY_INFO_ACCESS; + d2i_AUTHORITY_KEYID; + d2i_AutoPrivateKey; + d2i_BASIC_CONSTRAINTS; + d2i_CERTIFICATEPOLICIES; + d2i_CMS_ContentInfo; + d2i_CMS_ReceiptRequest; + d2i_CMS_bio; + d2i_CRL_DIST_POINTS; + d2i_DHparams; + d2i_DHxparams; + d2i_DIRECTORYSTRING; + d2i_DISPLAYTEXT; + d2i_DIST_POINT; + d2i_DIST_POINT_NAME; + d2i_DSAPrivateKey; + d2i_DSAPrivateKey_bio; + d2i_DSAPrivateKey_fp; + d2i_DSAPublicKey; + d2i_DSA_PUBKEY; + d2i_DSA_PUBKEY_bio; + d2i_DSA_PUBKEY_fp; + d2i_DSA_SIG; + d2i_DSAparams; + d2i_ECDSA_SIG; + d2i_ECPKParameters; + d2i_ECParameters; + d2i_ECPrivateKey; + d2i_ECPrivateKey_bio; + d2i_ECPrivateKey_fp; + d2i_EC_PUBKEY; + d2i_EC_PUBKEY_bio; + d2i_EC_PUBKEY_fp; + d2i_EDIPARTYNAME; + d2i_ESS_CERT_ID; + d2i_ESS_ISSUER_SERIAL; + d2i_ESS_SIGNING_CERT; + d2i_EXTENDED_KEY_USAGE; + d2i_GENERAL_NAMES; + d2i_GENERAL_NAME; + d2i_IPAddressChoice; + d2i_IPAddressFamily; + d2i_IPAddressOrRange; + d2i_IPAddressRange; + d2i_ISSUING_DIST_POINT; + d2i_NETSCAPE_CERT_SEQUENCE; + d2i_NETSCAPE_SPKAC; + d2i_NETSCAPE_SPKI; + d2i_NOTICEREF; + d2i_OCSP_BASICRESP; + d2i_OCSP_CERTID; + d2i_OCSP_CERTSTATUS; + d2i_OCSP_CRLID; + d2i_OCSP_ONEREQ; + d2i_OCSP_REQINFO; + d2i_OCSP_REQUEST; + d2i_OCSP_RESPBYTES; + d2i_OCSP_RESPDATA; + d2i_OCSP_RESPID; + d2i_OCSP_RESPONSE; + d2i_OCSP_REVOKEDINFO; + d2i_OCSP_SERVICELOC; + d2i_OCSP_SIGNATURE; + d2i_OCSP_SINGLERESP; + d2i_OTHERNAME; + d2i_PBE2PARAM; + d2i_PBEPARAM; + d2i_PBKDF2PARAM; + d2i_PKCS12; + d2i_PKCS12_BAGS; + d2i_PKCS12_MAC_DATA; + d2i_PKCS12_SAFEBAG; + d2i_PKCS12_bio; + d2i_PKCS12_fp; + d2i_PKCS7; + d2i_PKCS7_DIGEST; + d2i_PKCS7_ENCRYPT; + d2i_PKCS7_ENC_CONTENT; + d2i_PKCS7_ENVELOPE; + d2i_PKCS7_ISSUER_AND_SERIAL; + d2i_PKCS7_RECIP_INFO; + d2i_PKCS7_SIGNED; + d2i_PKCS7_SIGNER_INFO; + d2i_PKCS7_SIGN_ENVELOPE; + d2i_PKCS7_bio; + d2i_PKCS7_fp; + d2i_PKCS8PrivateKey_bio; + d2i_PKCS8PrivateKey_fp; + d2i_PKCS8_PRIV_KEY_INFO; + d2i_PKCS8_PRIV_KEY_INFO_bio; + d2i_PKCS8_PRIV_KEY_INFO_fp; + d2i_PKCS8_bio; + d2i_PKCS8_fp; + d2i_PKEY_USAGE_PERIOD; + d2i_POLICYINFO; + d2i_POLICYQUALINFO; + d2i_PROXY_CERT_INFO_EXTENSION; + d2i_PROXY_POLICY; + d2i_PUBKEY; + d2i_PUBKEY_bio; + d2i_PUBKEY_fp; + d2i_PrivateKey; + d2i_PrivateKey_bio; + d2i_PrivateKey_fp; + d2i_PublicKey; + d2i_RSAPrivateKey; + d2i_RSAPrivateKey_bio; + d2i_RSAPrivateKey_fp; + d2i_RSAPublicKey; + d2i_RSAPublicKey_bio; + d2i_RSAPublicKey_fp; + d2i_RSA_OAEP_PARAMS; + d2i_RSA_PSS_PARAMS; + d2i_RSA_PUBKEY; + d2i_RSA_PUBKEY_bio; + d2i_RSA_PUBKEY_fp; + d2i_SCT_LIST; + d2i_SXNETID; + d2i_SXNET; + d2i_TS_ACCURACY; + d2i_TS_MSG_IMPRINT; + d2i_TS_MSG_IMPRINT_bio; + d2i_TS_MSG_IMPRINT_fp; + d2i_TS_REQ; + d2i_TS_REQ_bio; + d2i_TS_REQ_fp; + d2i_TS_RESP; + d2i_TS_RESP_bio; + d2i_TS_RESP_fp; + d2i_TS_STATUS_INFO; + d2i_TS_TST_INFO; + d2i_TS_TST_INFO_bio; + d2i_TS_TST_INFO_fp; + d2i_USERNOTICE; + d2i_X509; + d2i_X509_ALGORS; + d2i_X509_ALGOR; + d2i_X509_ATTRIBUTE; + d2i_X509_AUX; + d2i_X509_CERT_AUX; + d2i_X509_CINF; + d2i_X509_CRL; + d2i_X509_CRL_INFO; + d2i_X509_CRL_bio; + d2i_X509_CRL_fp; + d2i_X509_EXTENSIONS; + d2i_X509_EXTENSION; + d2i_X509_NAME; + d2i_X509_NAME_ENTRY; + d2i_X509_PUBKEY; + d2i_X509_REQ; + d2i_X509_REQ_INFO; + d2i_X509_REQ_bio; + d2i_X509_REQ_fp; + d2i_X509_REVOKED; + d2i_X509_SIG; + d2i_X509_VAL; + d2i_X509_bio; + d2i_X509_fp; + err_free_strings_int; + i2a_ACCESS_DESCRIPTION; + i2a_ASN1_ENUMERATED; + i2a_ASN1_INTEGER; + i2a_ASN1_OBJECT; + i2a_ASN1_STRING; + i2b_PVK_bio; + i2b_PrivateKey_bio; + i2b_PublicKey_bio; + i2d_ACCESS_DESCRIPTION; + i2d_ASIdOrRange; + i2d_ASIdentifierChoice; + i2d_ASIdentifiers; + i2d_ASN1_BIT_STRING; + i2d_ASN1_BMPSTRING; + i2d_ASN1_ENUMERATED; + i2d_ASN1_GENERALIZEDTIME; + i2d_ASN1_GENERALSTRING; + i2d_ASN1_IA5STRING; + i2d_ASN1_INTEGER; + i2d_ASN1_NULL; + i2d_ASN1_OBJECT; + i2d_ASN1_OCTET_STRING; + i2d_ASN1_PRINTABLESTRING; + i2d_ASN1_PRINTABLE; + i2d_ASN1_SEQUENCE_ANY; + i2d_ASN1_SET_ANY; + i2d_ASN1_T61STRING; + i2d_ASN1_TIME; + i2d_ASN1_TYPE; + i2d_ASN1_UNIVERSALSTRING; + i2d_ASN1_UTCTIME; + i2d_ASN1_UTF8STRING; + i2d_ASN1_VISIBLESTRING; + i2d_ASN1_bio_stream; + i2d_ASRange; + i2d_AUTHORITY_INFO_ACCESS; + i2d_AUTHORITY_KEYID; + i2d_BASIC_CONSTRAINTS; + i2d_CERTIFICATEPOLICIES; + i2d_CMS_ContentInfo; + i2d_CMS_ReceiptRequest; + i2d_CMS_bio; + i2d_CMS_bio_stream; + i2d_CRL_DIST_POINTS; + i2d_DHparams; + i2d_DHxparams; + i2d_DIRECTORYSTRING; + i2d_DISPLAYTEXT; + i2d_DIST_POINT; + i2d_DIST_POINT_NAME; + i2d_DSAPrivateKey; + i2d_DSAPrivateKey_bio; + i2d_DSAPrivateKey_fp; + i2d_DSAPublicKey; + i2d_DSA_PUBKEY; + i2d_DSA_PUBKEY_bio; + i2d_DSA_PUBKEY_fp; + i2d_DSA_SIG; + i2d_DSAparams; + i2d_ECDSA_SIG; + i2d_ECPKParameters; + i2d_ECParameters; + i2d_ECPrivateKey; + i2d_ECPrivateKey_bio; + i2d_ECPrivateKey_fp; + i2d_EC_PUBKEY; + i2d_EC_PUBKEY_bio; + i2d_EC_PUBKEY_fp; + i2d_EDIPARTYNAME; + i2d_ESS_CERT_ID; + i2d_ESS_ISSUER_SERIAL; + i2d_ESS_SIGNING_CERT; + i2d_EXTENDED_KEY_USAGE; + i2d_GENERAL_NAMES; + i2d_GENERAL_NAME; + i2d_IPAddressChoice; + i2d_IPAddressFamily; + i2d_IPAddressOrRange; + i2d_IPAddressRange; + i2d_ISSUING_DIST_POINT; + i2d_NETSCAPE_CERT_SEQUENCE; + i2d_NETSCAPE_SPKAC; + i2d_NETSCAPE_SPKI; + i2d_NOTICEREF; + i2d_OCSP_BASICRESP; + i2d_OCSP_CERTID; + i2d_OCSP_CERTSTATUS; + i2d_OCSP_CRLID; + i2d_OCSP_ONEREQ; + i2d_OCSP_REQINFO; + i2d_OCSP_REQUEST; + i2d_OCSP_RESPBYTES; + i2d_OCSP_RESPDATA; + i2d_OCSP_RESPID; + i2d_OCSP_RESPONSE; + i2d_OCSP_REVOKEDINFO; + i2d_OCSP_SERVICELOC; + i2d_OCSP_SIGNATURE; + i2d_OCSP_SINGLERESP; + i2d_OTHERNAME; + i2d_PBE2PARAM; + i2d_PBEPARAM; + i2d_PBKDF2PARAM; + i2d_PKCS12; + i2d_PKCS12_BAGS; + i2d_PKCS12_MAC_DATA; + i2d_PKCS12_SAFEBAG; + i2d_PKCS12_bio; + i2d_PKCS12_fp; + i2d_PKCS7; + i2d_PKCS7_DIGEST; + i2d_PKCS7_ENCRYPT; + i2d_PKCS7_ENC_CONTENT; + i2d_PKCS7_ENVELOPE; + i2d_PKCS7_ISSUER_AND_SERIAL; + i2d_PKCS7_NDEF; + i2d_PKCS7_RECIP_INFO; + i2d_PKCS7_SIGNED; + i2d_PKCS7_SIGNER_INFO; + i2d_PKCS7_SIGN_ENVELOPE; + i2d_PKCS7_bio; + i2d_PKCS7_bio_stream; + i2d_PKCS7_fp; + i2d_PKCS8PrivateKeyInfo_bio; + i2d_PKCS8PrivateKeyInfo_fp; + i2d_PKCS8PrivateKey_bio; + i2d_PKCS8PrivateKey_fp; + i2d_PKCS8PrivateKey_nid_bio; + i2d_PKCS8PrivateKey_nid_fp; + i2d_PKCS8_PRIV_KEY_INFO; + i2d_PKCS8_PRIV_KEY_INFO_bio; + i2d_PKCS8_PRIV_KEY_INFO_fp; + i2d_PKCS8_bio; + i2d_PKCS8_fp; + i2d_PKEY_USAGE_PERIOD; + i2d_POLICYINFO; + i2d_POLICYQUALINFO; + i2d_PROXY_CERT_INFO_EXTENSION; + i2d_PROXY_POLICY; + i2d_PUBKEY; + i2d_PUBKEY_bio; + i2d_PUBKEY_fp; + i2d_PrivateKey; + i2d_PrivateKey_bio; + i2d_PrivateKey_fp; + i2d_PublicKey; + i2d_RSAPrivateKey; + i2d_RSAPrivateKey_bio; + i2d_RSAPrivateKey_fp; + i2d_RSAPublicKey; + i2d_RSAPublicKey_bio; + i2d_RSAPublicKey_fp; + i2d_RSA_OAEP_PARAMS; + i2d_RSA_PSS_PARAMS; + i2d_RSA_PUBKEY; + i2d_RSA_PUBKEY_bio; + i2d_RSA_PUBKEY_fp; + i2d_SCT_LIST; + i2d_SXNETID; + i2d_SXNET; + i2d_TS_ACCURACY; + i2d_TS_MSG_IMPRINT; + i2d_TS_MSG_IMPRINT_bio; + i2d_TS_MSG_IMPRINT_fp; + i2d_TS_REQ; + i2d_TS_REQ_bio; + i2d_TS_REQ_fp; + i2d_TS_RESP; + i2d_TS_RESP_bio; + i2d_TS_RESP_fp; + i2d_TS_STATUS_INFO; + i2d_TS_TST_INFO; + i2d_TS_TST_INFO_bio; + i2d_TS_TST_INFO_fp; + i2d_USERNOTICE; + i2d_X509; + i2d_X509_ALGORS; + i2d_X509_ALGOR; + i2d_X509_ATTRIBUTE; + i2d_X509_AUX; + i2d_X509_CERT_AUX; + i2d_X509_CINF; + i2d_X509_CRL; + i2d_X509_CRL_INFO; + i2d_X509_CRL_bio; + i2d_X509_CRL_fp; + i2d_X509_EXTENSIONS; + i2d_X509_EXTENSION; + i2d_X509_NAME; + i2d_X509_NAME_ENTRY; + i2d_X509_PUBKEY; + i2d_X509_REQ; + i2d_X509_REQ_INFO; + i2d_X509_REQ_bio; + i2d_X509_REQ_fp; + i2d_X509_REVOKED; + i2d_X509_SIG; + i2d_X509_VAL; + i2d_X509_bio; + i2d_X509_fp; + i2d_re_X509_CRL_tbs; + i2d_re_X509_REQ_tbs; + i2d_re_X509_tbs; + i2o_ECPublicKey; + i2o_SCT; + i2o_SCT_LIST; + i2s_ASN1_ENUMERATED; + i2s_ASN1_ENUMERATED_TABLE; + i2s_ASN1_IA5STRING; + i2s_ASN1_INTEGER; + i2s_ASN1_OCTET_STRING; + i2t_ASN1_OBJECT; + i2v_ASN1_BIT_STRING; + i2v_GENERAL_NAMES; + i2v_GENERAL_NAME; + o2i_ECPublicKey; + o2i_SCT; + o2i_SCT_LIST; + s2i_ASN1_IA5STRING; + s2i_ASN1_INTEGER; + s2i_ASN1_OCTET_STRING; + v2i_ASN1_BIT_STRING; + v2i_GENERAL_NAMES; + v2i_GENERAL_NAME; + v2i_GENERAL_NAME_ex; + ACCESS_DESCRIPTION_it; + ASIdOrRange_it; + ASIdentifierChoice_it; + ASIdentifiers_it; + ASN1_ANY_it; + ASN1_BIT_STRING_it; + ASN1_BMPSTRING_it; + ASN1_BOOLEAN_it; + ASN1_ENUMERATED_it; + ASN1_FBOOLEAN_it; + ASN1_GENERALIZEDTIME_it; + ASN1_GENERALSTRING_it; + ASN1_IA5STRING_it; + ASN1_INTEGER_it; + ASN1_NULL_it; + ASN1_OBJECT_it; + ASN1_OCTET_STRING_NDEF_it; + ASN1_OCTET_STRING_it; + ASN1_PRINTABLESTRING_it; + ASN1_PRINTABLE_it; + ASN1_SEQUENCE_ANY_it; + ASN1_SEQUENCE_it; + ASN1_SET_ANY_it; + ASN1_T61STRING_it; + ASN1_TBOOLEAN_it; + ASN1_TIME_it; + ASN1_UNIVERSALSTRING_it; + ASN1_UTCTIME_it; + ASN1_UTF8STRING_it; + ASN1_VISIBLESTRING_it; + ASRange_it; + AUTHORITY_INFO_ACCESS_it; + AUTHORITY_KEYID_it; + BASIC_CONSTRAINTS_it; + BIGNUM_it; + CBIGNUM_it; + CERTIFICATEPOLICIES_it; + CMS_ContentInfo_it; + CMS_ReceiptRequest_it; + CRL_DIST_POINTS_it; + DHparams_it; + DIRECTORYSTRING_it; + DISPLAYTEXT_it; + DIST_POINT_NAME_it; + DIST_POINT_it; + ECPARAMETERS_it; + ECPKPARAMETERS_it; + EDIPARTYNAME_it; + EXTENDED_KEY_USAGE_it; + GENERAL_NAMES_it; + GENERAL_NAME_it; + GENERAL_SUBTREE_it; + IPAddressChoice_it; + IPAddressFamily_it; + IPAddressOrRange_it; + IPAddressRange_it; + ISSUING_DIST_POINT_it; + LONG_it; + NAME_CONSTRAINTS_it; + NETSCAPE_CERT_SEQUENCE_it; + NETSCAPE_SPKAC_it; + NETSCAPE_SPKI_it; + NOTICEREF_it; + OCSP_BASICRESP_it; + OCSP_CERTID_it; + OCSP_CERTSTATUS_it; + OCSP_CRLID_it; + OCSP_ONEREQ_it; + OCSP_REQINFO_it; + OCSP_REQUEST_it; + OCSP_RESPBYTES_it; + OCSP_RESPDATA_it; + OCSP_RESPID_it; + OCSP_RESPONSE_it; + OCSP_REVOKEDINFO_it; + OCSP_SERVICELOC_it; + OCSP_SIGNATURE_it; + OCSP_SINGLERESP_it; + OTHERNAME_it; + PBE2PARAM_it; + PBEPARAM_it; + PBKDF2PARAM_it; + PKCS12_AUTHSAFES_it; + PKCS12_BAGS_it; + PKCS12_MAC_DATA_it; + PKCS12_SAFEBAGS_it; + PKCS12_SAFEBAG_it; + PKCS12_it; + PKCS7_ATTR_SIGN_it; + PKCS7_ATTR_VERIFY_it; + PKCS7_DIGEST_it; + PKCS7_ENCRYPT_it; + PKCS7_ENC_CONTENT_it; + PKCS7_ENVELOPE_it; + PKCS7_ISSUER_AND_SERIAL_it; + PKCS7_RECIP_INFO_it; + PKCS7_SIGNED_it; + PKCS7_SIGNER_INFO_it; + PKCS7_SIGN_ENVELOPE_it; + PKCS7_it; + PKCS8_PRIV_KEY_INFO_it; + PKEY_USAGE_PERIOD_it; + POLICYINFO_it; + POLICYQUALINFO_it; + POLICY_CONSTRAINTS_it; + POLICY_MAPPINGS_it; + POLICY_MAPPING_it; + PROXY_CERT_INFO_EXTENSION_it; + PROXY_POLICY_it; + RSAPrivateKey_it; + RSAPublicKey_it; + RSA_OAEP_PARAMS_it; + RSA_PSS_PARAMS_it; + SXNETID_it; + SXNET_it; + USERNOTICE_it; + X509_ALGORS_it; + X509_ALGOR_it; + X509_ATTRIBUTE_it; + X509_CERT_AUX_it; + X509_CINF_it; + X509_CRL_INFO_it; + X509_CRL_it; + X509_EXTENSIONS_it; + X509_EXTENSION_it; + X509_NAME_ENTRY_it; + X509_NAME_it; + X509_PUBKEY_it; + X509_REQ_INFO_it; + X509_REQ_it; + X509_REVOKED_it; + X509_SIG_it; + X509_VAL_it; + X509_it; + ZLONG_it; + _shadow_DES_check_key; +}; + +OPENSSL_1_1_0a { + global: + OCSP_RESPID_match; + OCSP_RESPID_set_by_key; + OCSP_RESPID_set_by_name; +} OPENSSL_1_1_0; + +OPENSSL_1_1_0c { + global: + DSO_dsobyaddr; + DSO_pathbyaddr; +} OPENSSL_1_1_0a; + +OPENSSL_1_1_0d { + global: + CT_POLICY_EVAL_CTX_get_time; + CT_POLICY_EVAL_CTX_set_time; + DH_check_params; + X509_VERIFY_PARAM_get_inh_flags; + X509_VERIFY_PARAM_get_time; + X509_VERIFY_PARAM_set_inh_flags; +} OPENSSL_1_1_0c; + +OPENSSL_1_1_0f { + global: + INT32_it; + INT64_it; + UINT32_it; + UINT64_it; + ZINT32_it; + ZINT64_it; + ZUINT32_it; + ZUINT64_it; +} OPENSSL_1_1_0d; + +OPENSSL_1_1_0g { + global: + CRYPTO_secure_clear_free; + EVP_PKEY_set1_engine; +} OPENSSL_1_1_0f; + +OPENSSL_1_1_0h { + global: + OCSP_resp_get0_signer; + X509_get0_authority_key_id; +} OPENSSL_1_1_0g; + +OPENSSL_1_1_0i { + global: + X509_LOOKUP_get_method_data; + X509_LOOKUP_get_store; + X509_LOOKUP_meth_free; + X509_LOOKUP_meth_get_ctrl; + X509_LOOKUP_meth_get_free; + X509_LOOKUP_meth_get_get_by_alias; + X509_LOOKUP_meth_get_get_by_fingerprint; + X509_LOOKUP_meth_get_get_by_issuer_serial; + X509_LOOKUP_meth_get_get_by_subject; + X509_LOOKUP_meth_get_init; + X509_LOOKUP_meth_get_new_item; + X509_LOOKUP_meth_get_shutdown; + X509_LOOKUP_meth_new; + X509_LOOKUP_meth_set_ctrl; + X509_LOOKUP_meth_set_free; + X509_LOOKUP_meth_set_get_by_alias; + X509_LOOKUP_meth_set_get_by_fingerprint; + X509_LOOKUP_meth_set_get_by_issuer_serial; + X509_LOOKUP_meth_set_get_by_subject; + X509_LOOKUP_meth_set_init; + X509_LOOKUP_meth_set_new_item; + X509_LOOKUP_meth_set_shutdown; + X509_LOOKUP_set_method_data; + X509_OBJECT_set1_X509; + X509_OBJECT_set1_X509_CRL; + X509_VERIFY_PARAM_get_hostflags; + conf_ssl_get; + conf_ssl_get_cmd; + conf_ssl_name_find; +} OPENSSL_1_1_0h; + +OPENSSL_1_1_0j { + global: + OCSP_resp_get0_respdata; + OCSP_resp_get0_tbs_sigalg; +} OPENSSL_1_1_0i; + +OPENSSL_1_1_1 { + global: + ADMISSIONS_free; + ADMISSIONS_get0_admissionAuthority; + ADMISSIONS_get0_namingAuthority; + ADMISSIONS_get0_professionInfos; + ADMISSIONS_new; + ADMISSIONS_set0_admissionAuthority; + ADMISSIONS_set0_namingAuthority; + ADMISSIONS_set0_professionInfos; + ADMISSION_SYNTAX_free; + ADMISSION_SYNTAX_get0_admissionAuthority; + ADMISSION_SYNTAX_get0_contentsOfAdmissions; + ADMISSION_SYNTAX_new; + ADMISSION_SYNTAX_set0_admissionAuthority; + ADMISSION_SYNTAX_set0_contentsOfAdmissions; + ASN1_ITEM_get; + ASN1_ITEM_lookup; + ASN1_TIME_cmp_time_t; + ASN1_TIME_compare; + ASN1_TIME_normalize; + ASN1_TIME_set_string_X509; + ASN1_TIME_to_tm; + BIO_bind; + BIO_get_callback_ex; + BIO_lookup_ex; + BIO_meth_get_read_ex; + BIO_meth_get_write_ex; + BIO_meth_set_read_ex; + BIO_meth_set_write_ex; + BIO_read_ex; + BIO_set_callback_ex; + BIO_write_ex; + BN_priv_rand; + BN_priv_rand_range; + DH_check_ex; + DH_check_params_ex; + DH_check_pub_key_ex; + DH_get0_g; + DH_get0_p; + DH_get0_priv_key; + DH_get0_pub_key; + DH_get0_q; + DH_get_nid; + DH_new_by_nid; + DSA_get0_g; + DSA_get0_p; + DSA_get0_priv_key; + DSA_get0_pub_key; + DSA_get0_q; + ECDSA_SIG_get0_r; + ECDSA_SIG_get0_s; + EC_GROUP_get_curve; + EC_GROUP_set_curve; + EC_KEY_get0_engine; + EC_POINT_get_affine_coordinates; + EC_POINT_set_affine_coordinates; + EC_POINT_set_compressed_coordinates; + ERR_clear_last_mark; + ERR_load_OSSL_STORE_strings; + ERR_load_strings_const; + ESS_CERT_ID_V2_dup; + ESS_CERT_ID_V2_free; + ESS_CERT_ID_V2_new; + ESS_SIGNING_CERT_V2_dup; + ESS_SIGNING_CERT_V2_free; + ESS_SIGNING_CERT_V2_new; + EVP_DigestFinalXOF; + EVP_DigestSign; + EVP_DigestVerify; + EVP_MD_CTX_set_pkey_ctx; + EVP_PKEY_CTX_ctrl_uint64; + EVP_PKEY_CTX_md; + EVP_PKEY_asn1_set_check; + EVP_PKEY_asn1_set_get_priv_key; + EVP_PKEY_asn1_set_get_pub_key; + EVP_PKEY_asn1_set_param_check; + EVP_PKEY_asn1_set_public_check; + EVP_PKEY_asn1_set_set_priv_key; + EVP_PKEY_asn1_set_set_pub_key; + EVP_PKEY_asn1_set_siginf; + EVP_PKEY_check; + EVP_PKEY_get0_poly1305; + EVP_PKEY_get0_siphash; + EVP_PKEY_get_raw_private_key; + EVP_PKEY_get_raw_public_key; + EVP_PKEY_meth_get0; + EVP_PKEY_meth_get_check; + EVP_PKEY_meth_get_count; + EVP_PKEY_meth_get_digest_custom; + EVP_PKEY_meth_get_param_check; + EVP_PKEY_meth_get_public_check; + EVP_PKEY_meth_remove; + EVP_PKEY_meth_set_check; + EVP_PKEY_meth_set_digest_custom; + EVP_PKEY_meth_set_param_check; + EVP_PKEY_meth_set_public_check; + EVP_PKEY_new_CMAC_key; + EVP_PKEY_new_raw_private_key; + EVP_PKEY_new_raw_public_key; + EVP_PKEY_param_check; + EVP_PKEY_public_check; + EVP_PKEY_set_alias_type; + EVP_aria_128_cbc; + EVP_aria_128_ccm; + EVP_aria_128_cfb128; + EVP_aria_128_cfb1; + EVP_aria_128_cfb8; + EVP_aria_128_ctr; + EVP_aria_128_ecb; + EVP_aria_128_gcm; + EVP_aria_128_ofb; + EVP_aria_192_cbc; + EVP_aria_192_ccm; + EVP_aria_192_cfb128; + EVP_aria_192_cfb1; + EVP_aria_192_cfb8; + EVP_aria_192_ctr; + EVP_aria_192_ecb; + EVP_aria_192_gcm; + EVP_aria_192_ofb; + EVP_aria_256_cbc; + EVP_aria_256_ccm; + EVP_aria_256_cfb128; + EVP_aria_256_cfb1; + EVP_aria_256_cfb8; + EVP_aria_256_ctr; + EVP_aria_256_ecb; + EVP_aria_256_gcm; + EVP_aria_256_ofb; + EVP_sha3_224; + EVP_sha3_256; + EVP_sha3_384; + EVP_sha3_512; + EVP_sha512_224; + EVP_sha512_256; + EVP_shake128; + EVP_shake256; + EVP_sm3; + EVP_sm4_cbc; + EVP_sm4_cfb128; + EVP_sm4_ctr; + EVP_sm4_ecb; + EVP_sm4_ofb; + NAMING_AUTHORITY_free; + NAMING_AUTHORITY_get0_authorityId; + NAMING_AUTHORITY_get0_authorityText; + NAMING_AUTHORITY_get0_authorityURL; + NAMING_AUTHORITY_new; + NAMING_AUTHORITY_set0_authorityId; + NAMING_AUTHORITY_set0_authorityText; + NAMING_AUTHORITY_set0_authorityURL; + OCSP_basic_sign_ctx; + OCSP_resp_get1_id; + OPENSSL_fork_child; + OPENSSL_fork_parent; + OPENSSL_fork_prepare; + OPENSSL_sk_new_reserve; + OPENSSL_sk_reserve; + OSSL_STORE_INFO_free; + OSSL_STORE_INFO_get0_CERT; + OSSL_STORE_INFO_get0_CRL; + OSSL_STORE_INFO_get0_NAME; + OSSL_STORE_INFO_get0_NAME_description; + OSSL_STORE_INFO_get0_PARAMS; + OSSL_STORE_INFO_get0_PKEY; + OSSL_STORE_INFO_get1_CERT; + OSSL_STORE_INFO_get1_CRL; + OSSL_STORE_INFO_get1_NAME; + OSSL_STORE_INFO_get1_NAME_description; + OSSL_STORE_INFO_get1_PARAMS; + OSSL_STORE_INFO_get1_PKEY; + OSSL_STORE_INFO_get_type; + OSSL_STORE_INFO_new_CERT; + OSSL_STORE_INFO_new_CRL; + OSSL_STORE_INFO_new_NAME; + OSSL_STORE_INFO_new_PARAMS; + OSSL_STORE_INFO_new_PKEY; + OSSL_STORE_INFO_set0_NAME_description; + OSSL_STORE_INFO_type_string; + OSSL_STORE_LOADER_free; + OSSL_STORE_LOADER_get0_engine; + OSSL_STORE_LOADER_get0_scheme; + OSSL_STORE_LOADER_new; + OSSL_STORE_LOADER_set_close; + OSSL_STORE_LOADER_set_ctrl; + OSSL_STORE_LOADER_set_eof; + OSSL_STORE_LOADER_set_error; + OSSL_STORE_LOADER_set_expect; + OSSL_STORE_LOADER_set_find; + OSSL_STORE_LOADER_set_load; + OSSL_STORE_LOADER_set_open; + OSSL_STORE_SEARCH_by_alias; + OSSL_STORE_SEARCH_by_issuer_serial; + OSSL_STORE_SEARCH_by_key_fingerprint; + OSSL_STORE_SEARCH_by_name; + OSSL_STORE_SEARCH_free; + OSSL_STORE_SEARCH_get0_bytes; + OSSL_STORE_SEARCH_get0_digest; + OSSL_STORE_SEARCH_get0_name; + OSSL_STORE_SEARCH_get0_serial; + OSSL_STORE_SEARCH_get0_string; + OSSL_STORE_SEARCH_get_type; + OSSL_STORE_close; + OSSL_STORE_ctrl; + OSSL_STORE_do_all_loaders; + OSSL_STORE_eof; + OSSL_STORE_error; + OSSL_STORE_expect; + OSSL_STORE_find; + OSSL_STORE_load; + OSSL_STORE_open; + OSSL_STORE_register_loader; + OSSL_STORE_supports_search; + OSSL_STORE_unregister_loader; + OSSL_STORE_vctrl; + PEM_bytes_read_bio_secmem; + PEM_read_bio_ex; + PROFESSION_INFO_free; + PROFESSION_INFO_get0_addProfessionInfo; + PROFESSION_INFO_get0_namingAuthority; + PROFESSION_INFO_get0_professionItems; + PROFESSION_INFO_get0_professionOIDs; + PROFESSION_INFO_get0_registrationNumber; + PROFESSION_INFO_new; + PROFESSION_INFO_set0_addProfessionInfo; + PROFESSION_INFO_set0_namingAuthority; + PROFESSION_INFO_set0_professionItems; + PROFESSION_INFO_set0_professionOIDs; + PROFESSION_INFO_set0_registrationNumber; + RAND_DRBG_bytes; + RAND_DRBG_free; + RAND_DRBG_generate; + RAND_DRBG_get0_master; + RAND_DRBG_get0_private; + RAND_DRBG_get0_public; + RAND_DRBG_get_ex_data; + RAND_DRBG_instantiate; + RAND_DRBG_new; + RAND_DRBG_reseed; + RAND_DRBG_secure_new; + RAND_DRBG_set; + RAND_DRBG_set_callbacks; + RAND_DRBG_set_defaults; + RAND_DRBG_set_ex_data; + RAND_DRBG_set_reseed_defaults; + RAND_DRBG_set_reseed_interval; + RAND_DRBG_set_reseed_time_interval; + RAND_DRBG_uninstantiate; + RAND_keep_random_devices_open; + RAND_priv_bytes; + RSA_generate_multi_prime_key; + RSA_get0_d; + RSA_get0_dmp1; + RSA_get0_dmq1; + RSA_get0_e; + RSA_get0_iqmp; + RSA_get0_multi_prime_crt_params; + RSA_get0_multi_prime_factors; + RSA_get0_n; + RSA_get0_p; + RSA_get0_q; + RSA_get_multi_prime_extra_count; + RSA_get_version; + RSA_meth_get_multi_prime_keygen; + RSA_meth_set_multi_prime_keygen; + RSA_pkey_ctx_ctrl; + RSA_set0_multi_prime_params; + SCRYPT_PARAMS_free; + SCRYPT_PARAMS_new; + TS_CONF_set_ess_cert_id_digest; + TS_RESP_CTX_set_ess_cert_id_digest; + UI_UTIL_wrap_read_pem_callback; + UI_dup_user_data; + UI_get_result_length; + UI_get_result_string_length; + UI_method_get_data_destructor; + UI_method_get_data_duplicator; + UI_method_get_ex_data; + UI_method_set_data_duplicator; + UI_method_set_ex_data; + UI_null; + UI_set_result_ex; + X509_CRL_print_ex; + X509_SIG_INFO_get; + X509_SIG_INFO_set; + X509_get_signature_info; + d2i_ADMISSIONS; + d2i_ADMISSION_SYNTAX; + d2i_ESS_CERT_ID_V2; + d2i_ESS_SIGNING_CERT_V2; + d2i_NAMING_AUTHORITY; + d2i_PROFESSION_INFO; + d2i_SCRYPT_PARAMS; + i2d_ADMISSIONS; + i2d_ADMISSION_SYNTAX; + i2d_ESS_CERT_ID_V2; + i2d_ESS_SIGNING_CERT_V2; + i2d_NAMING_AUTHORITY; + i2d_PROFESSION_INFO; + i2d_SCRYPT_PARAMS; + ADMISSIONS_it; + ADMISSION_SYNTAX_it; + NAMING_AUTHORITY_it; + PROFESSION_INFO_it; + SCRYPT_PARAMS_it; +} OPENSSL_1_1_0j; + +OPENSSL_1_1_1b { + global: + OPENSSL_INIT_set_config_file_flags; + OPENSSL_INIT_set_config_filename; +} OPENSSL_1_1_1; + +OPENSSL_1_1_1c { + global: + EVP_PKEY_get0_engine; +} OPENSSL_1_1_1b; + +OPENSSL_1_1_1d { + global: + X509_get0_authority_issuer; + X509_get0_authority_serial; +} OPENSSL_1_1_1c; + +OPENSSL_1_1_1e { + global: + EVP_PKEY_meth_get_digestsign; + EVP_PKEY_meth_get_digestverify; + EVP_PKEY_meth_set_digestsign; + EVP_PKEY_meth_set_digestverify; + RSA_get0_pss_params; +} OPENSSL_1_1_1d; + OPENSSL_1_1_1h { global: EC_KEY_decoded_from_explicit_params; @@ -4460,5 +4460,5 @@ OPENSSL_1_1_1h { X509_REQ_set1_signature_algo; local: *; } OPENSSL_1_1_1e; - + diff --git a/contrib/libs/openssl/libssl.map b/contrib/libs/openssl/libssl.map index 67b4c7f3e5..bf624d3612 100644 --- a/contrib/libs/openssl/libssl.map +++ b/contrib/libs/openssl/libssl.map @@ -1,513 +1,513 @@ -OPENSSL_1_1_0 { - global: - BIO_f_ssl; - BIO_new_buffer_ssl_connect; - BIO_new_ssl; - BIO_new_ssl_connect; - BIO_ssl_copy_session_id; - BIO_ssl_shutdown; - DTLS_client_method; - DTLS_method; - DTLS_server_method; - DTLSv1_2_client_method; - DTLSv1_2_method; - DTLSv1_2_server_method; - DTLSv1_client_method; - DTLSv1_listen; - 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; - SRP_Calc_A_param; - SSL_CIPHER_description; - SSL_CIPHER_find; - SSL_CIPHER_get_auth_nid; - SSL_CIPHER_get_bits; - SSL_CIPHER_get_cipher_nid; - SSL_CIPHER_get_digest_nid; - SSL_CIPHER_get_id; - SSL_CIPHER_get_kx_nid; - SSL_CIPHER_get_name; - SSL_CIPHER_get_version; - SSL_CIPHER_is_aead; - SSL_CIPHER_standard_name; - SSL_COMP_add_compression_method; - SSL_COMP_get_compression_methods; - SSL_COMP_get_name; - SSL_COMP_set0_compression_methods; - SSL_CONF_CTX_clear_flags; - SSL_CONF_CTX_finish; - SSL_CONF_CTX_free; - SSL_CONF_CTX_new; - SSL_CONF_CTX_set1_prefix; - SSL_CONF_CTX_set_flags; - SSL_CONF_CTX_set_ssl; - SSL_CONF_CTX_set_ssl_ctx; - SSL_CONF_cmd; - SSL_CONF_cmd_argv; - SSL_CONF_cmd_value_type; - SSL_CTX_SRP_CTX_free; - SSL_CTX_SRP_CTX_init; - SSL_CTX_add_client_CA; - SSL_CTX_add_client_custom_ext; - SSL_CTX_add_server_custom_ext; - SSL_CTX_add_session; - SSL_CTX_callback_ctrl; - SSL_CTX_check_private_key; - SSL_CTX_clear_options; - SSL_CTX_config; - SSL_CTX_ct_is_enabled; - SSL_CTX_ctrl; - SSL_CTX_dane_clear_flags; - SSL_CTX_dane_enable; - SSL_CTX_dane_mtype_set; - SSL_CTX_dane_set_flags; - SSL_CTX_enable_ct; - SSL_CTX_flush_sessions; - SSL_CTX_free; - SSL_CTX_get0_certificate; - SSL_CTX_get0_ctlog_store; - SSL_CTX_get0_param; - SSL_CTX_get0_privatekey; - SSL_CTX_get0_security_ex_data; - SSL_CTX_get_cert_store; - SSL_CTX_get_ciphers; - SSL_CTX_get_client_CA_list; - SSL_CTX_get_client_cert_cb; - SSL_CTX_get_default_passwd_cb; - SSL_CTX_get_default_passwd_cb_userdata; - SSL_CTX_get_ex_data; - SSL_CTX_get_info_callback; - SSL_CTX_get_options; - SSL_CTX_get_quiet_shutdown; - SSL_CTX_get_security_callback; - SSL_CTX_get_security_level; - SSL_CTX_get_ssl_method; - SSL_CTX_get_timeout; - SSL_CTX_get_verify_callback; - SSL_CTX_get_verify_depth; - SSL_CTX_get_verify_mode; - SSL_CTX_has_client_custom_ext; - SSL_CTX_load_verify_locations; - SSL_CTX_new; - SSL_CTX_remove_session; - SSL_CTX_sess_get_get_cb; - SSL_CTX_sess_get_new_cb; - SSL_CTX_sess_get_remove_cb; - SSL_CTX_sess_set_get_cb; - SSL_CTX_sess_set_new_cb; - SSL_CTX_sess_set_remove_cb; - SSL_CTX_sessions; - SSL_CTX_set0_ctlog_store; - SSL_CTX_set0_security_ex_data; - SSL_CTX_set1_param; - SSL_CTX_set_alpn_protos; - SSL_CTX_set_alpn_select_cb; - SSL_CTX_set_cert_cb; - SSL_CTX_set_cert_store; - SSL_CTX_set_cert_verify_callback; - SSL_CTX_set_cipher_list; - SSL_CTX_set_client_CA_list; - SSL_CTX_set_client_cert_cb; - SSL_CTX_set_client_cert_engine; - SSL_CTX_set_cookie_generate_cb; - SSL_CTX_set_cookie_verify_cb; - SSL_CTX_set_ct_validation_callback; - SSL_CTX_set_ctlog_list_file; - SSL_CTX_set_default_ctlog_list_file; - SSL_CTX_set_default_passwd_cb; - SSL_CTX_set_default_passwd_cb_userdata; - SSL_CTX_set_default_read_buffer_len; - SSL_CTX_set_default_verify_dir; - SSL_CTX_set_default_verify_file; - SSL_CTX_set_default_verify_paths; - SSL_CTX_set_ex_data; - SSL_CTX_set_generate_session_id; - SSL_CTX_set_info_callback; - SSL_CTX_set_msg_callback; - SSL_CTX_set_next_proto_select_cb; - SSL_CTX_set_next_protos_advertised_cb; - SSL_CTX_set_not_resumable_session_callback; - SSL_CTX_set_options; - SSL_CTX_set_psk_client_callback; - SSL_CTX_set_psk_server_callback; - SSL_CTX_set_purpose; - SSL_CTX_set_quiet_shutdown; - SSL_CTX_set_security_callback; - SSL_CTX_set_security_level; - SSL_CTX_set_session_id_context; - SSL_CTX_set_srp_cb_arg; - SSL_CTX_set_srp_client_pwd_callback; - SSL_CTX_set_srp_password; - SSL_CTX_set_srp_strength; - SSL_CTX_set_srp_username; - SSL_CTX_set_srp_username_callback; - SSL_CTX_set_srp_verify_param_callback; - SSL_CTX_set_ssl_version; - SSL_CTX_set_timeout; - SSL_CTX_set_tlsext_use_srtp; - SSL_CTX_set_tmp_dh_callback; - SSL_CTX_set_trust; - SSL_CTX_set_verify; - SSL_CTX_set_verify_depth; - SSL_CTX_up_ref; - SSL_CTX_use_PrivateKey; - SSL_CTX_use_PrivateKey_ASN1; - SSL_CTX_use_PrivateKey_file; - SSL_CTX_use_RSAPrivateKey; - SSL_CTX_use_RSAPrivateKey_ASN1; - SSL_CTX_use_RSAPrivateKey_file; - SSL_CTX_use_certificate; - SSL_CTX_use_certificate_ASN1; - SSL_CTX_use_certificate_chain_file; - SSL_CTX_use_certificate_file; - SSL_CTX_use_psk_identity_hint; - SSL_CTX_use_serverinfo; - SSL_CTX_use_serverinfo_file; - SSL_SESSION_free; - SSL_SESSION_get0_cipher; - SSL_SESSION_get0_hostname; - SSL_SESSION_get0_id_context; - SSL_SESSION_get0_peer; - SSL_SESSION_get0_ticket; - SSL_SESSION_get_compress_id; - SSL_SESSION_get_ex_data; - SSL_SESSION_get_id; - SSL_SESSION_get_master_key; - SSL_SESSION_get_protocol_version; - SSL_SESSION_get_ticket_lifetime_hint; - SSL_SESSION_get_time; - SSL_SESSION_get_timeout; - SSL_SESSION_has_ticket; - SSL_SESSION_new; - SSL_SESSION_print; - SSL_SESSION_print_fp; - SSL_SESSION_print_keylog; - SSL_SESSION_set1_id; - SSL_SESSION_set1_id_context; - SSL_SESSION_set_ex_data; - SSL_SESSION_set_time; - SSL_SESSION_set_timeout; - SSL_SESSION_up_ref; - SSL_SRP_CTX_free; - SSL_SRP_CTX_init; - SSL_accept; - SSL_add1_host; - SSL_add_client_CA; - SSL_add_dir_cert_subjects_to_stack; - SSL_add_file_cert_subjects_to_stack; - SSL_add_ssl_module; - SSL_alert_desc_string; - SSL_alert_desc_string_long; - SSL_alert_type_string; - SSL_alert_type_string_long; - SSL_callback_ctrl; - SSL_certs_clear; - SSL_check_chain; - SSL_check_private_key; - SSL_clear; - SSL_clear_options; - SSL_client_version; - SSL_config; - SSL_connect; - SSL_copy_session_id; - SSL_ct_is_enabled; - SSL_ctrl; - SSL_dane_clear_flags; - SSL_dane_enable; - SSL_dane_set_flags; - SSL_dane_tlsa_add; - SSL_do_handshake; - SSL_dup; - SSL_dup_CA_list; - SSL_enable_ct; - SSL_export_keying_material; - SSL_extension_supported; - SSL_free; - SSL_get0_alpn_selected; - SSL_get0_dane; - SSL_get0_dane_authority; - SSL_get0_dane_tlsa; - SSL_get0_next_proto_negotiated; - SSL_get0_param; - SSL_get0_peer_scts; - SSL_get0_peername; - SSL_get0_security_ex_data; - SSL_get0_verified_chain; - SSL_get1_session; - SSL_get1_supported_ciphers; - SSL_get_SSL_CTX; - SSL_get_all_async_fds; - SSL_get_certificate; - SSL_get_changed_async_fds; - SSL_get_cipher_list; - SSL_get_ciphers; - SSL_get_client_CA_list; - SSL_get_client_ciphers; - SSL_get_client_random; - SSL_get_current_cipher; - SSL_get_current_compression; - SSL_get_current_expansion; - SSL_get_default_passwd_cb; - SSL_get_default_passwd_cb_userdata; - SSL_get_default_timeout; - SSL_get_error; - SSL_get_ex_data; - SSL_get_ex_data_X509_STORE_CTX_idx; - SSL_get_fd; - SSL_get_finished; - SSL_get_info_callback; - SSL_get_options; - SSL_get_peer_cert_chain; - SSL_get_peer_certificate; - SSL_get_peer_finished; - SSL_get_privatekey; - SSL_get_psk_identity; - SSL_get_psk_identity_hint; - SSL_get_quiet_shutdown; - SSL_get_rbio; - SSL_get_read_ahead; - SSL_get_rfd; - SSL_get_security_callback; - SSL_get_security_level; - SSL_get_selected_srtp_profile; - SSL_get_server_random; - SSL_get_servername; - SSL_get_servername_type; - SSL_get_session; - SSL_get_shared_ciphers; - SSL_get_shared_sigalgs; - SSL_get_shutdown; - SSL_get_sigalgs; - SSL_get_srp_N; - SSL_get_srp_g; - SSL_get_srp_userinfo; - SSL_get_srp_username; - SSL_get_srtp_profiles; - SSL_get_ssl_method; - SSL_get_state; - SSL_get_verify_callback; - SSL_get_verify_depth; - SSL_get_verify_mode; - SSL_get_verify_result; - SSL_get_version; - SSL_get_wbio; - SSL_get_wfd; - SSL_has_matching_session_id; - SSL_has_pending; - SSL_in_before; - SSL_in_init; - SSL_is_dtls; - SSL_is_init_finished; - SSL_is_server; - SSL_load_client_CA_file; - SSL_new; - SSL_peek; - SSL_pending; - SSL_read; - SSL_renegotiate; - SSL_renegotiate_abbreviated; - SSL_renegotiate_pending; - SSL_rstate_string; - SSL_rstate_string_long; - SSL_select_next_proto; - SSL_session_reused; - SSL_set0_rbio; - SSL_set0_security_ex_data; - SSL_set0_wbio; - SSL_set1_host; - SSL_set1_param; - SSL_set_SSL_CTX; - SSL_set_accept_state; - SSL_set_alpn_protos; - SSL_set_bio; - SSL_set_cert_cb; - SSL_set_cipher_list; - SSL_set_client_CA_list; - SSL_set_connect_state; - SSL_set_ct_validation_callback; - SSL_set_debug; - SSL_set_default_passwd_cb; - SSL_set_default_passwd_cb_userdata; - SSL_set_default_read_buffer_len; - SSL_set_ex_data; - SSL_set_fd; - SSL_set_generate_session_id; - SSL_set_hostflags; - SSL_set_info_callback; - SSL_set_msg_callback; - SSL_set_not_resumable_session_callback; - SSL_set_options; - SSL_set_psk_client_callback; - SSL_set_psk_server_callback; - SSL_set_purpose; - SSL_set_quiet_shutdown; - SSL_set_read_ahead; - SSL_set_rfd; - SSL_set_security_callback; - SSL_set_security_level; - SSL_set_session; - SSL_set_session_id_context; - SSL_set_session_secret_cb; - SSL_set_session_ticket_ext; - SSL_set_session_ticket_ext_cb; - SSL_set_shutdown; - SSL_set_srp_server_param; - SSL_set_srp_server_param_pw; - SSL_set_ssl_method; - SSL_set_tlsext_use_srtp; - SSL_set_tmp_dh_callback; - SSL_set_trust; - SSL_set_verify; - SSL_set_verify_depth; - SSL_set_verify_result; - SSL_set_wfd; - SSL_shutdown; - SSL_srp_server_param_with_username; - SSL_state_string; - SSL_state_string_long; - SSL_up_ref; - SSL_use_PrivateKey; - SSL_use_PrivateKey_ASN1; - SSL_use_PrivateKey_file; - SSL_use_RSAPrivateKey; - SSL_use_RSAPrivateKey_ASN1; - SSL_use_RSAPrivateKey_file; - SSL_use_certificate; - SSL_use_certificate_ASN1; - SSL_use_certificate_chain_file; - SSL_use_certificate_file; - SSL_use_psk_identity_hint; - SSL_version; - SSL_waiting_for_async; - SSL_want; - SSL_write; - 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; -}; - -OPENSSL_1_1_0d { - global: - SSL_COMP_get0_name; - SSL_COMP_get_id; -} OPENSSL_1_1_0; - -OPENSSL_1_1_1 { - global: - DTLS_get_data_mtu; - DTLS_set_timer_cb; - OPENSSL_cipher_name; - SSL_CIPHER_get_handshake_digest; - SSL_CIPHER_get_protocol_id; - SSL_CTX_add1_to_CA_list; - SSL_CTX_add_custom_ext; - SSL_CTX_get0_CA_list; - SSL_CTX_get_keylog_callback; - SSL_CTX_get_max_early_data; - SSL_CTX_get_num_tickets; - SSL_CTX_get_record_padding_callback_arg; - SSL_CTX_get_recv_max_early_data; - SSL_CTX_set0_CA_list; - SSL_CTX_set1_cert_store; - SSL_CTX_set_allow_early_data_cb; - SSL_CTX_set_block_padding; - SSL_CTX_set_ciphersuites; - SSL_CTX_set_client_hello_cb; - SSL_CTX_set_keylog_callback; - SSL_CTX_set_max_early_data; - SSL_CTX_set_num_tickets; - SSL_CTX_set_post_handshake_auth; - SSL_CTX_set_psk_find_session_callback; - SSL_CTX_set_psk_use_session_callback; - SSL_CTX_set_record_padding_callback; - SSL_CTX_set_record_padding_callback_arg; - SSL_CTX_set_recv_max_early_data; - SSL_CTX_set_session_ticket_cb; - SSL_CTX_set_stateless_cookie_generate_cb; - SSL_CTX_set_stateless_cookie_verify_cb; - SSL_CTX_set_tlsext_max_fragment_length; - SSL_CTX_use_cert_and_key; - SSL_CTX_use_serverinfo_ex; - SSL_SESSION_dup; - SSL_SESSION_get0_alpn_selected; - SSL_SESSION_get0_ticket_appdata; - SSL_SESSION_get_max_early_data; - SSL_SESSION_get_max_fragment_length; - SSL_SESSION_is_resumable; - SSL_SESSION_set1_alpn_selected; - SSL_SESSION_set1_hostname; - SSL_SESSION_set1_master_key; - SSL_SESSION_set1_ticket_appdata; - SSL_SESSION_set_cipher; - SSL_SESSION_set_max_early_data; - SSL_SESSION_set_protocol_version; - SSL_add1_to_CA_list; - SSL_alloc_buffers; - SSL_bytes_to_cipher_list; - SSL_client_hello_get0_ciphers; - SSL_client_hello_get0_compression_methods; - SSL_client_hello_get0_ext; - SSL_client_hello_get0_legacy_version; - SSL_client_hello_get0_random; - SSL_client_hello_get0_session_id; - SSL_client_hello_get1_extensions_present; - SSL_client_hello_isv2; - SSL_export_keying_material_early; - SSL_free_buffers; - SSL_get0_CA_list; - SSL_get0_peer_CA_list; - SSL_get_early_data_status; - SSL_get_key_update_type; - SSL_get_max_early_data; - SSL_get_num_tickets; - SSL_get_peer_signature_type_nid; - SSL_get_pending_cipher; - SSL_get_record_padding_callback_arg; - SSL_get_recv_max_early_data; - SSL_key_update; - SSL_peek_ex; - SSL_read_early_data; - SSL_read_ex; - SSL_set0_CA_list; - SSL_set_allow_early_data_cb; - SSL_set_block_padding; - SSL_set_ciphersuites; - SSL_set_max_early_data; - SSL_set_num_tickets; - SSL_set_post_handshake_auth; - SSL_set_psk_find_session_callback; - SSL_set_psk_use_session_callback; - SSL_set_record_padding_callback; - SSL_set_record_padding_callback_arg; - SSL_set_recv_max_early_data; - SSL_set_tlsext_max_fragment_length; - SSL_stateless; - SSL_use_cert_and_key; - SSL_verify_client_post_handshake; - SSL_write_early_data; - SSL_write_ex; -} OPENSSL_1_1_0d; - -OPENSSL_1_1_1a { - global: - SSL_get_signature_type_nid; - local: *; -} OPENSSL_1_1_1; - - +OPENSSL_1_1_0 { + global: + BIO_f_ssl; + BIO_new_buffer_ssl_connect; + BIO_new_ssl; + BIO_new_ssl_connect; + BIO_ssl_copy_session_id; + BIO_ssl_shutdown; + DTLS_client_method; + DTLS_method; + DTLS_server_method; + DTLSv1_2_client_method; + DTLSv1_2_method; + DTLSv1_2_server_method; + DTLSv1_client_method; + DTLSv1_listen; + 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; + SRP_Calc_A_param; + SSL_CIPHER_description; + SSL_CIPHER_find; + SSL_CIPHER_get_auth_nid; + SSL_CIPHER_get_bits; + SSL_CIPHER_get_cipher_nid; + SSL_CIPHER_get_digest_nid; + SSL_CIPHER_get_id; + SSL_CIPHER_get_kx_nid; + SSL_CIPHER_get_name; + SSL_CIPHER_get_version; + SSL_CIPHER_is_aead; + SSL_CIPHER_standard_name; + SSL_COMP_add_compression_method; + SSL_COMP_get_compression_methods; + SSL_COMP_get_name; + SSL_COMP_set0_compression_methods; + SSL_CONF_CTX_clear_flags; + SSL_CONF_CTX_finish; + SSL_CONF_CTX_free; + SSL_CONF_CTX_new; + SSL_CONF_CTX_set1_prefix; + SSL_CONF_CTX_set_flags; + SSL_CONF_CTX_set_ssl; + SSL_CONF_CTX_set_ssl_ctx; + SSL_CONF_cmd; + SSL_CONF_cmd_argv; + SSL_CONF_cmd_value_type; + SSL_CTX_SRP_CTX_free; + SSL_CTX_SRP_CTX_init; + SSL_CTX_add_client_CA; + SSL_CTX_add_client_custom_ext; + SSL_CTX_add_server_custom_ext; + SSL_CTX_add_session; + SSL_CTX_callback_ctrl; + SSL_CTX_check_private_key; + SSL_CTX_clear_options; + SSL_CTX_config; + SSL_CTX_ct_is_enabled; + SSL_CTX_ctrl; + SSL_CTX_dane_clear_flags; + SSL_CTX_dane_enable; + SSL_CTX_dane_mtype_set; + SSL_CTX_dane_set_flags; + SSL_CTX_enable_ct; + SSL_CTX_flush_sessions; + SSL_CTX_free; + SSL_CTX_get0_certificate; + SSL_CTX_get0_ctlog_store; + SSL_CTX_get0_param; + SSL_CTX_get0_privatekey; + SSL_CTX_get0_security_ex_data; + SSL_CTX_get_cert_store; + SSL_CTX_get_ciphers; + SSL_CTX_get_client_CA_list; + SSL_CTX_get_client_cert_cb; + SSL_CTX_get_default_passwd_cb; + SSL_CTX_get_default_passwd_cb_userdata; + SSL_CTX_get_ex_data; + SSL_CTX_get_info_callback; + SSL_CTX_get_options; + SSL_CTX_get_quiet_shutdown; + SSL_CTX_get_security_callback; + SSL_CTX_get_security_level; + SSL_CTX_get_ssl_method; + SSL_CTX_get_timeout; + SSL_CTX_get_verify_callback; + SSL_CTX_get_verify_depth; + SSL_CTX_get_verify_mode; + SSL_CTX_has_client_custom_ext; + SSL_CTX_load_verify_locations; + SSL_CTX_new; + SSL_CTX_remove_session; + SSL_CTX_sess_get_get_cb; + SSL_CTX_sess_get_new_cb; + SSL_CTX_sess_get_remove_cb; + SSL_CTX_sess_set_get_cb; + SSL_CTX_sess_set_new_cb; + SSL_CTX_sess_set_remove_cb; + SSL_CTX_sessions; + SSL_CTX_set0_ctlog_store; + SSL_CTX_set0_security_ex_data; + SSL_CTX_set1_param; + SSL_CTX_set_alpn_protos; + SSL_CTX_set_alpn_select_cb; + SSL_CTX_set_cert_cb; + SSL_CTX_set_cert_store; + SSL_CTX_set_cert_verify_callback; + SSL_CTX_set_cipher_list; + SSL_CTX_set_client_CA_list; + SSL_CTX_set_client_cert_cb; + SSL_CTX_set_client_cert_engine; + SSL_CTX_set_cookie_generate_cb; + SSL_CTX_set_cookie_verify_cb; + SSL_CTX_set_ct_validation_callback; + SSL_CTX_set_ctlog_list_file; + SSL_CTX_set_default_ctlog_list_file; + SSL_CTX_set_default_passwd_cb; + SSL_CTX_set_default_passwd_cb_userdata; + SSL_CTX_set_default_read_buffer_len; + SSL_CTX_set_default_verify_dir; + SSL_CTX_set_default_verify_file; + SSL_CTX_set_default_verify_paths; + SSL_CTX_set_ex_data; + SSL_CTX_set_generate_session_id; + SSL_CTX_set_info_callback; + SSL_CTX_set_msg_callback; + SSL_CTX_set_next_proto_select_cb; + SSL_CTX_set_next_protos_advertised_cb; + SSL_CTX_set_not_resumable_session_callback; + SSL_CTX_set_options; + SSL_CTX_set_psk_client_callback; + SSL_CTX_set_psk_server_callback; + SSL_CTX_set_purpose; + SSL_CTX_set_quiet_shutdown; + SSL_CTX_set_security_callback; + SSL_CTX_set_security_level; + SSL_CTX_set_session_id_context; + SSL_CTX_set_srp_cb_arg; + SSL_CTX_set_srp_client_pwd_callback; + SSL_CTX_set_srp_password; + SSL_CTX_set_srp_strength; + SSL_CTX_set_srp_username; + SSL_CTX_set_srp_username_callback; + SSL_CTX_set_srp_verify_param_callback; + SSL_CTX_set_ssl_version; + SSL_CTX_set_timeout; + SSL_CTX_set_tlsext_use_srtp; + SSL_CTX_set_tmp_dh_callback; + SSL_CTX_set_trust; + SSL_CTX_set_verify; + SSL_CTX_set_verify_depth; + SSL_CTX_up_ref; + SSL_CTX_use_PrivateKey; + SSL_CTX_use_PrivateKey_ASN1; + SSL_CTX_use_PrivateKey_file; + SSL_CTX_use_RSAPrivateKey; + SSL_CTX_use_RSAPrivateKey_ASN1; + SSL_CTX_use_RSAPrivateKey_file; + SSL_CTX_use_certificate; + SSL_CTX_use_certificate_ASN1; + SSL_CTX_use_certificate_chain_file; + SSL_CTX_use_certificate_file; + SSL_CTX_use_psk_identity_hint; + SSL_CTX_use_serverinfo; + SSL_CTX_use_serverinfo_file; + SSL_SESSION_free; + SSL_SESSION_get0_cipher; + SSL_SESSION_get0_hostname; + SSL_SESSION_get0_id_context; + SSL_SESSION_get0_peer; + SSL_SESSION_get0_ticket; + SSL_SESSION_get_compress_id; + SSL_SESSION_get_ex_data; + SSL_SESSION_get_id; + SSL_SESSION_get_master_key; + SSL_SESSION_get_protocol_version; + SSL_SESSION_get_ticket_lifetime_hint; + SSL_SESSION_get_time; + SSL_SESSION_get_timeout; + SSL_SESSION_has_ticket; + SSL_SESSION_new; + SSL_SESSION_print; + SSL_SESSION_print_fp; + SSL_SESSION_print_keylog; + SSL_SESSION_set1_id; + SSL_SESSION_set1_id_context; + SSL_SESSION_set_ex_data; + SSL_SESSION_set_time; + SSL_SESSION_set_timeout; + SSL_SESSION_up_ref; + SSL_SRP_CTX_free; + SSL_SRP_CTX_init; + SSL_accept; + SSL_add1_host; + SSL_add_client_CA; + SSL_add_dir_cert_subjects_to_stack; + SSL_add_file_cert_subjects_to_stack; + SSL_add_ssl_module; + SSL_alert_desc_string; + SSL_alert_desc_string_long; + SSL_alert_type_string; + SSL_alert_type_string_long; + SSL_callback_ctrl; + SSL_certs_clear; + SSL_check_chain; + SSL_check_private_key; + SSL_clear; + SSL_clear_options; + SSL_client_version; + SSL_config; + SSL_connect; + SSL_copy_session_id; + SSL_ct_is_enabled; + SSL_ctrl; + SSL_dane_clear_flags; + SSL_dane_enable; + SSL_dane_set_flags; + SSL_dane_tlsa_add; + SSL_do_handshake; + SSL_dup; + SSL_dup_CA_list; + SSL_enable_ct; + SSL_export_keying_material; + SSL_extension_supported; + SSL_free; + SSL_get0_alpn_selected; + SSL_get0_dane; + SSL_get0_dane_authority; + SSL_get0_dane_tlsa; + SSL_get0_next_proto_negotiated; + SSL_get0_param; + SSL_get0_peer_scts; + SSL_get0_peername; + SSL_get0_security_ex_data; + SSL_get0_verified_chain; + SSL_get1_session; + SSL_get1_supported_ciphers; + SSL_get_SSL_CTX; + SSL_get_all_async_fds; + SSL_get_certificate; + SSL_get_changed_async_fds; + SSL_get_cipher_list; + SSL_get_ciphers; + SSL_get_client_CA_list; + SSL_get_client_ciphers; + SSL_get_client_random; + SSL_get_current_cipher; + SSL_get_current_compression; + SSL_get_current_expansion; + SSL_get_default_passwd_cb; + SSL_get_default_passwd_cb_userdata; + SSL_get_default_timeout; + SSL_get_error; + SSL_get_ex_data; + SSL_get_ex_data_X509_STORE_CTX_idx; + SSL_get_fd; + SSL_get_finished; + SSL_get_info_callback; + SSL_get_options; + SSL_get_peer_cert_chain; + SSL_get_peer_certificate; + SSL_get_peer_finished; + SSL_get_privatekey; + SSL_get_psk_identity; + SSL_get_psk_identity_hint; + SSL_get_quiet_shutdown; + SSL_get_rbio; + SSL_get_read_ahead; + SSL_get_rfd; + SSL_get_security_callback; + SSL_get_security_level; + SSL_get_selected_srtp_profile; + SSL_get_server_random; + SSL_get_servername; + SSL_get_servername_type; + SSL_get_session; + SSL_get_shared_ciphers; + SSL_get_shared_sigalgs; + SSL_get_shutdown; + SSL_get_sigalgs; + SSL_get_srp_N; + SSL_get_srp_g; + SSL_get_srp_userinfo; + SSL_get_srp_username; + SSL_get_srtp_profiles; + SSL_get_ssl_method; + SSL_get_state; + SSL_get_verify_callback; + SSL_get_verify_depth; + SSL_get_verify_mode; + SSL_get_verify_result; + SSL_get_version; + SSL_get_wbio; + SSL_get_wfd; + SSL_has_matching_session_id; + SSL_has_pending; + SSL_in_before; + SSL_in_init; + SSL_is_dtls; + SSL_is_init_finished; + SSL_is_server; + SSL_load_client_CA_file; + SSL_new; + SSL_peek; + SSL_pending; + SSL_read; + SSL_renegotiate; + SSL_renegotiate_abbreviated; + SSL_renegotiate_pending; + SSL_rstate_string; + SSL_rstate_string_long; + SSL_select_next_proto; + SSL_session_reused; + SSL_set0_rbio; + SSL_set0_security_ex_data; + SSL_set0_wbio; + SSL_set1_host; + SSL_set1_param; + SSL_set_SSL_CTX; + SSL_set_accept_state; + SSL_set_alpn_protos; + SSL_set_bio; + SSL_set_cert_cb; + SSL_set_cipher_list; + SSL_set_client_CA_list; + SSL_set_connect_state; + SSL_set_ct_validation_callback; + SSL_set_debug; + SSL_set_default_passwd_cb; + SSL_set_default_passwd_cb_userdata; + SSL_set_default_read_buffer_len; + SSL_set_ex_data; + SSL_set_fd; + SSL_set_generate_session_id; + SSL_set_hostflags; + SSL_set_info_callback; + SSL_set_msg_callback; + SSL_set_not_resumable_session_callback; + SSL_set_options; + SSL_set_psk_client_callback; + SSL_set_psk_server_callback; + SSL_set_purpose; + SSL_set_quiet_shutdown; + SSL_set_read_ahead; + SSL_set_rfd; + SSL_set_security_callback; + SSL_set_security_level; + SSL_set_session; + SSL_set_session_id_context; + SSL_set_session_secret_cb; + SSL_set_session_ticket_ext; + SSL_set_session_ticket_ext_cb; + SSL_set_shutdown; + SSL_set_srp_server_param; + SSL_set_srp_server_param_pw; + SSL_set_ssl_method; + SSL_set_tlsext_use_srtp; + SSL_set_tmp_dh_callback; + SSL_set_trust; + SSL_set_verify; + SSL_set_verify_depth; + SSL_set_verify_result; + SSL_set_wfd; + SSL_shutdown; + SSL_srp_server_param_with_username; + SSL_state_string; + SSL_state_string_long; + SSL_up_ref; + SSL_use_PrivateKey; + SSL_use_PrivateKey_ASN1; + SSL_use_PrivateKey_file; + SSL_use_RSAPrivateKey; + SSL_use_RSAPrivateKey_ASN1; + SSL_use_RSAPrivateKey_file; + SSL_use_certificate; + SSL_use_certificate_ASN1; + SSL_use_certificate_chain_file; + SSL_use_certificate_file; + SSL_use_psk_identity_hint; + SSL_version; + SSL_waiting_for_async; + SSL_want; + SSL_write; + 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; +}; + +OPENSSL_1_1_0d { + global: + SSL_COMP_get0_name; + SSL_COMP_get_id; +} OPENSSL_1_1_0; + +OPENSSL_1_1_1 { + global: + DTLS_get_data_mtu; + DTLS_set_timer_cb; + OPENSSL_cipher_name; + SSL_CIPHER_get_handshake_digest; + SSL_CIPHER_get_protocol_id; + SSL_CTX_add1_to_CA_list; + SSL_CTX_add_custom_ext; + SSL_CTX_get0_CA_list; + SSL_CTX_get_keylog_callback; + SSL_CTX_get_max_early_data; + SSL_CTX_get_num_tickets; + SSL_CTX_get_record_padding_callback_arg; + SSL_CTX_get_recv_max_early_data; + SSL_CTX_set0_CA_list; + SSL_CTX_set1_cert_store; + SSL_CTX_set_allow_early_data_cb; + SSL_CTX_set_block_padding; + SSL_CTX_set_ciphersuites; + SSL_CTX_set_client_hello_cb; + SSL_CTX_set_keylog_callback; + SSL_CTX_set_max_early_data; + SSL_CTX_set_num_tickets; + SSL_CTX_set_post_handshake_auth; + SSL_CTX_set_psk_find_session_callback; + SSL_CTX_set_psk_use_session_callback; + SSL_CTX_set_record_padding_callback; + SSL_CTX_set_record_padding_callback_arg; + SSL_CTX_set_recv_max_early_data; + SSL_CTX_set_session_ticket_cb; + SSL_CTX_set_stateless_cookie_generate_cb; + SSL_CTX_set_stateless_cookie_verify_cb; + SSL_CTX_set_tlsext_max_fragment_length; + SSL_CTX_use_cert_and_key; + SSL_CTX_use_serverinfo_ex; + SSL_SESSION_dup; + SSL_SESSION_get0_alpn_selected; + SSL_SESSION_get0_ticket_appdata; + SSL_SESSION_get_max_early_data; + SSL_SESSION_get_max_fragment_length; + SSL_SESSION_is_resumable; + SSL_SESSION_set1_alpn_selected; + SSL_SESSION_set1_hostname; + SSL_SESSION_set1_master_key; + SSL_SESSION_set1_ticket_appdata; + SSL_SESSION_set_cipher; + SSL_SESSION_set_max_early_data; + SSL_SESSION_set_protocol_version; + SSL_add1_to_CA_list; + SSL_alloc_buffers; + SSL_bytes_to_cipher_list; + SSL_client_hello_get0_ciphers; + SSL_client_hello_get0_compression_methods; + SSL_client_hello_get0_ext; + SSL_client_hello_get0_legacy_version; + SSL_client_hello_get0_random; + SSL_client_hello_get0_session_id; + SSL_client_hello_get1_extensions_present; + SSL_client_hello_isv2; + SSL_export_keying_material_early; + SSL_free_buffers; + SSL_get0_CA_list; + SSL_get0_peer_CA_list; + SSL_get_early_data_status; + SSL_get_key_update_type; + SSL_get_max_early_data; + SSL_get_num_tickets; + SSL_get_peer_signature_type_nid; + SSL_get_pending_cipher; + SSL_get_record_padding_callback_arg; + SSL_get_recv_max_early_data; + SSL_key_update; + SSL_peek_ex; + SSL_read_early_data; + SSL_read_ex; + SSL_set0_CA_list; + SSL_set_allow_early_data_cb; + SSL_set_block_padding; + SSL_set_ciphersuites; + SSL_set_max_early_data; + SSL_set_num_tickets; + SSL_set_post_handshake_auth; + SSL_set_psk_find_session_callback; + SSL_set_psk_use_session_callback; + SSL_set_record_padding_callback; + SSL_set_record_padding_callback_arg; + SSL_set_recv_max_early_data; + SSL_set_tlsext_max_fragment_length; + SSL_stateless; + SSL_use_cert_and_key; + SSL_verify_client_post_handshake; + SSL_write_early_data; + SSL_write_ex; +} OPENSSL_1_1_0d; + +OPENSSL_1_1_1a { + global: + SSL_get_signature_type_nid; + local: *; +} OPENSSL_1_1_1; + + diff --git a/contrib/libs/openssl/ssl/bio_ssl.c b/contrib/libs/openssl/ssl/bio_ssl.c index c477f07dec..c4239345b6 100644 --- a/contrib/libs/openssl/ssl/bio_ssl.c +++ b/contrib/libs/openssl/ssl/bio_ssl.c @@ -14,7 +14,7 @@ #include <openssl/crypto.h> #include "internal/bio.h" #include <openssl/err.h> -#include "ssl_local.h" +#include "ssl_local.h" static int ssl_write(BIO *h, const char *buf, size_t size, size_t *written); static int ssl_read(BIO *b, char *buf, size_t size, size_t *readbytes); diff --git a/contrib/libs/openssl/ssl/d1_lib.c b/contrib/libs/openssl/ssl/d1_lib.c index 9a6c456324..05b85c1078 100644 --- a/contrib/libs/openssl/ssl/d1_lib.c +++ b/contrib/libs/openssl/ssl/d1_lib.c @@ -11,7 +11,7 @@ #include <stdio.h> #include <openssl/objects.h> #include <openssl/rand.h> -#include "ssl_local.h" +#include "ssl_local.h" static void get_current_time(struct timeval *t); static int dtls1_handshake_write(SSL *s); diff --git a/contrib/libs/openssl/ssl/d1_msg.c b/contrib/libs/openssl/ssl/d1_msg.c index 3b7fa8ec83..8a31064ae1 100644 --- a/contrib/libs/openssl/ssl/d1_msg.c +++ b/contrib/libs/openssl/ssl/d1_msg.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "ssl_local.h" +#include "ssl_local.h" int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, size_t len, size_t *written) diff --git a/contrib/libs/openssl/ssl/d1_srtp.c b/contrib/libs/openssl/ssl/d1_srtp.c index 2d24b23d2e..c05a77e346 100644 --- a/contrib/libs/openssl/ssl/d1_srtp.c +++ b/contrib/libs/openssl/ssl/d1_srtp.c @@ -15,7 +15,7 @@ #include <stdio.h> #include <openssl/objects.h> -#include "ssl_local.h" +#include "ssl_local.h" #ifndef OPENSSL_NO_SRTP diff --git a/contrib/libs/openssl/ssl/methods.c b/contrib/libs/openssl/ssl/methods.c index 84800c2123..c5e8898364 100644 --- a/contrib/libs/openssl/ssl/methods.c +++ b/contrib/libs/openssl/ssl/methods.c @@ -9,7 +9,7 @@ #include <stdio.h> #include <openssl/objects.h> -#include "ssl_local.h" +#include "ssl_local.h" /*- * TLS/SSLv3 methods diff --git a/contrib/libs/openssl/ssl/packet.c b/contrib/libs/openssl/ssl/packet.c index bdc84ec26d..1ddde969f3 100644 --- a/contrib/libs/openssl/ssl/packet.c +++ b/contrib/libs/openssl/ssl/packet.c @@ -8,7 +8,7 @@ */ #include "internal/cryptlib.h" -#include "packet_local.h" +#include "packet_local.h" #include <openssl/sslerr.h> #define DEFAULT_BUF_SIZE 256 diff --git a/contrib/libs/openssl/ssl/packet_local.h b/contrib/libs/openssl/ssl/packet_local.h index c77abc3c3d..1b6c2fb9bc 100644 --- a/contrib/libs/openssl/ssl/packet_local.h +++ b/contrib/libs/openssl/ssl/packet_local.h @@ -1,874 +1,874 @@ -/* - * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_SSL_PACKET_LOCAL_H -# define OSSL_SSL_PACKET_LOCAL_H - -# include <string.h> -# include <openssl/bn.h> -# include <openssl/buffer.h> -# include <openssl/crypto.h> -# include <openssl/e_os2.h> - -# include "internal/numbers.h" - -typedef struct { - /* Pointer to where we are currently reading from */ - const unsigned char *curr; - /* Number of bytes remaining */ - size_t remaining; -} PACKET; - -/* Internal unchecked shorthand; don't use outside this file. */ -static ossl_inline void packet_forward(PACKET *pkt, size_t len) -{ - pkt->curr += len; - pkt->remaining -= len; -} - -/* - * Returns the number of bytes remaining to be read in the PACKET - */ -static ossl_inline size_t PACKET_remaining(const PACKET *pkt) -{ - return pkt->remaining; -} - -/* - * Returns a pointer to the first byte after the packet data. - * Useful for integrating with non-PACKET parsing code. - * Specifically, we use PACKET_end() to verify that a d2i_... call - * has consumed the entire packet contents. - */ -static ossl_inline const unsigned char *PACKET_end(const PACKET *pkt) -{ - return pkt->curr + pkt->remaining; -} - -/* - * Returns a pointer to the PACKET's current position. - * For use in non-PACKETized APIs. - */ -static ossl_inline const unsigned char *PACKET_data(const PACKET *pkt) -{ - return pkt->curr; -} - -/* - * Initialise a PACKET with |len| bytes held in |buf|. This does not make a - * copy of the data so |buf| must be present for the whole time that the PACKET - * is being used. - */ -__owur static ossl_inline int PACKET_buf_init(PACKET *pkt, - const unsigned char *buf, - size_t len) -{ - /* Sanity check for negative values. */ - if (len > (size_t)(SIZE_MAX / 2)) - return 0; - - pkt->curr = buf; - pkt->remaining = len; - return 1; -} - -/* Initialize a PACKET to hold zero bytes. */ -static ossl_inline void PACKET_null_init(PACKET *pkt) -{ - pkt->curr = NULL; - pkt->remaining = 0; -} - -/* - * Returns 1 if the packet has length |num| and its contents equal the |num| - * bytes read from |ptr|. Returns 0 otherwise (lengths or contents not equal). - * If lengths are equal, performs the comparison in constant time. - */ -__owur static ossl_inline int PACKET_equal(const PACKET *pkt, const void *ptr, - size_t num) -{ - if (PACKET_remaining(pkt) != num) - return 0; - return CRYPTO_memcmp(pkt->curr, ptr, num) == 0; -} - -/* - * Peek ahead and initialize |subpkt| with the next |len| bytes read from |pkt|. - * Data is not copied: the |subpkt| packet will share its underlying buffer with - * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. - */ -__owur static ossl_inline int PACKET_peek_sub_packet(const PACKET *pkt, - PACKET *subpkt, size_t len) -{ - if (PACKET_remaining(pkt) < len) - return 0; - - return PACKET_buf_init(subpkt, pkt->curr, len); -} - -/* - * Initialize |subpkt| with the next |len| bytes read from |pkt|. Data is not - * copied: the |subpkt| packet will share its underlying buffer with the - * original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. - */ -__owur static ossl_inline int PACKET_get_sub_packet(PACKET *pkt, - PACKET *subpkt, size_t len) -{ - if (!PACKET_peek_sub_packet(pkt, subpkt, len)) - return 0; - - packet_forward(pkt, len); - - return 1; -} - -/* - * Peek ahead at 2 bytes in network order from |pkt| and store the value in - * |*data| - */ -__owur static ossl_inline int PACKET_peek_net_2(const PACKET *pkt, - unsigned int *data) -{ - if (PACKET_remaining(pkt) < 2) - return 0; - - *data = ((unsigned int)(*pkt->curr)) << 8; - *data |= *(pkt->curr + 1); - - return 1; -} - -/* Equivalent of n2s */ -/* Get 2 bytes in network order from |pkt| and store the value in |*data| */ -__owur static ossl_inline int PACKET_get_net_2(PACKET *pkt, unsigned int *data) -{ - if (!PACKET_peek_net_2(pkt, data)) - return 0; - - packet_forward(pkt, 2); - - return 1; -} - -/* Same as PACKET_get_net_2() but for a size_t */ -__owur static ossl_inline int PACKET_get_net_2_len(PACKET *pkt, size_t *data) -{ - unsigned int i; - int ret = PACKET_get_net_2(pkt, &i); - - if (ret) - *data = (size_t)i; - - return ret; -} - -/* - * Peek ahead at 3 bytes in network order from |pkt| and store the value in - * |*data| - */ -__owur static ossl_inline int PACKET_peek_net_3(const PACKET *pkt, - unsigned long *data) -{ - if (PACKET_remaining(pkt) < 3) - return 0; - - *data = ((unsigned long)(*pkt->curr)) << 16; - *data |= ((unsigned long)(*(pkt->curr + 1))) << 8; - *data |= *(pkt->curr + 2); - - return 1; -} - -/* Equivalent of n2l3 */ -/* Get 3 bytes in network order from |pkt| and store the value in |*data| */ -__owur static ossl_inline int PACKET_get_net_3(PACKET *pkt, unsigned long *data) -{ - if (!PACKET_peek_net_3(pkt, data)) - return 0; - - packet_forward(pkt, 3); - - return 1; -} - -/* Same as PACKET_get_net_3() but for a size_t */ -__owur static ossl_inline int PACKET_get_net_3_len(PACKET *pkt, size_t *data) -{ - unsigned long i; - int ret = PACKET_get_net_3(pkt, &i); - - if (ret) - *data = (size_t)i; - - return ret; -} - -/* - * Peek ahead at 4 bytes in network order from |pkt| and store the value in - * |*data| - */ -__owur static ossl_inline int PACKET_peek_net_4(const PACKET *pkt, - unsigned long *data) -{ - if (PACKET_remaining(pkt) < 4) - return 0; - - *data = ((unsigned long)(*pkt->curr)) << 24; - *data |= ((unsigned long)(*(pkt->curr + 1))) << 16; - *data |= ((unsigned long)(*(pkt->curr + 2))) << 8; - *data |= *(pkt->curr + 3); - - return 1; -} - -/* Equivalent of n2l */ -/* Get 4 bytes in network order from |pkt| and store the value in |*data| */ -__owur static ossl_inline int PACKET_get_net_4(PACKET *pkt, unsigned long *data) -{ - if (!PACKET_peek_net_4(pkt, data)) - return 0; - - packet_forward(pkt, 4); - - return 1; -} - -/* Same as PACKET_get_net_4() but for a size_t */ -__owur static ossl_inline int PACKET_get_net_4_len(PACKET *pkt, size_t *data) -{ - unsigned long i; - int ret = PACKET_get_net_4(pkt, &i); - - if (ret) - *data = (size_t)i; - - return ret; -} - -/* Peek ahead at 1 byte from |pkt| and store the value in |*data| */ -__owur static ossl_inline int PACKET_peek_1(const PACKET *pkt, - unsigned int *data) -{ - if (!PACKET_remaining(pkt)) - return 0; - - *data = *pkt->curr; - - return 1; -} - -/* Get 1 byte from |pkt| and store the value in |*data| */ -__owur static ossl_inline int PACKET_get_1(PACKET *pkt, unsigned int *data) -{ - if (!PACKET_peek_1(pkt, data)) - return 0; - - packet_forward(pkt, 1); - - return 1; -} - -/* Same as PACKET_get_1() but for a size_t */ -__owur static ossl_inline int PACKET_get_1_len(PACKET *pkt, size_t *data) -{ - unsigned int i; - int ret = PACKET_get_1(pkt, &i); - - if (ret) - *data = (size_t)i; - - return ret; -} - -/* - * Peek ahead at 4 bytes in reverse network order from |pkt| and store the value - * in |*data| - */ -__owur static ossl_inline int PACKET_peek_4(const PACKET *pkt, - unsigned long *data) -{ - if (PACKET_remaining(pkt) < 4) - return 0; - - *data = *pkt->curr; - *data |= ((unsigned long)(*(pkt->curr + 1))) << 8; - *data |= ((unsigned long)(*(pkt->curr + 2))) << 16; - *data |= ((unsigned long)(*(pkt->curr + 3))) << 24; - - return 1; -} - -/* Equivalent of c2l */ -/* - * Get 4 bytes in reverse network order from |pkt| and store the value in - * |*data| - */ -__owur static ossl_inline int PACKET_get_4(PACKET *pkt, unsigned long *data) -{ - if (!PACKET_peek_4(pkt, data)) - return 0; - - packet_forward(pkt, 4); - - return 1; -} - -/* - * Peek ahead at |len| bytes from the |pkt| and store a pointer to them in - * |*data|. This just points at the underlying buffer that |pkt| is using. The - * caller should not free this data directly (it will be freed when the - * underlying buffer gets freed - */ -__owur static ossl_inline int PACKET_peek_bytes(const PACKET *pkt, - const unsigned char **data, - size_t len) -{ - if (PACKET_remaining(pkt) < len) - return 0; - - *data = pkt->curr; - - return 1; -} - -/* - * Read |len| bytes from the |pkt| and store a pointer to them in |*data|. This - * just points at the underlying buffer that |pkt| is using. The caller should - * not free this data directly (it will be freed when the underlying buffer gets - * freed - */ -__owur static ossl_inline int PACKET_get_bytes(PACKET *pkt, - const unsigned char **data, - size_t len) -{ - if (!PACKET_peek_bytes(pkt, data, len)) - return 0; - - packet_forward(pkt, len); - - return 1; -} - -/* Peek ahead at |len| bytes from |pkt| and copy them to |data| */ -__owur static ossl_inline int PACKET_peek_copy_bytes(const PACKET *pkt, - unsigned char *data, - size_t len) -{ - if (PACKET_remaining(pkt) < len) - return 0; - - memcpy(data, pkt->curr, len); - - return 1; -} - -/* - * Read |len| bytes from |pkt| and copy them to |data|. - * The caller is responsible for ensuring that |data| can hold |len| bytes. - */ -__owur static ossl_inline int PACKET_copy_bytes(PACKET *pkt, - unsigned char *data, size_t len) -{ - if (!PACKET_peek_copy_bytes(pkt, data, len)) - return 0; - - packet_forward(pkt, len); - - return 1; -} - -/* - * Copy packet data to |dest|, and set |len| to the number of copied bytes. - * If the packet has more than |dest_len| bytes, nothing is copied. - * Returns 1 if the packet data fits in |dest_len| bytes, 0 otherwise. - * Does not forward PACKET position (because it is typically the last thing - * done with a given PACKET). - */ -__owur static ossl_inline int PACKET_copy_all(const PACKET *pkt, - unsigned char *dest, - size_t dest_len, size_t *len) -{ - if (PACKET_remaining(pkt) > dest_len) { - *len = 0; - return 0; - } - *len = pkt->remaining; - memcpy(dest, pkt->curr, pkt->remaining); - return 1; -} - -/* - * Copy |pkt| bytes to a newly allocated buffer and store a pointer to the - * result in |*data|, and the length in |len|. - * If |*data| is not NULL, the old data is OPENSSL_free'd. - * If the packet is empty, or malloc fails, |*data| will be set to NULL. - * Returns 1 if the malloc succeeds and 0 otherwise. - * Does not forward PACKET position (because it is typically the last thing - * done with a given PACKET). - */ -__owur static ossl_inline int PACKET_memdup(const PACKET *pkt, - unsigned char **data, size_t *len) -{ - size_t length; - - OPENSSL_free(*data); - *data = NULL; - *len = 0; - - length = PACKET_remaining(pkt); - - if (length == 0) - return 1; - - *data = OPENSSL_memdup(pkt->curr, length); - if (*data == NULL) - return 0; - - *len = length; - return 1; -} - -/* - * Read a C string from |pkt| and copy to a newly allocated, NUL-terminated - * buffer. Store a pointer to the result in |*data|. - * If |*data| is not NULL, the old data is OPENSSL_free'd. - * If the data in |pkt| does not contain a NUL-byte, the entire data is - * copied and NUL-terminated. - * Returns 1 if the malloc succeeds and 0 otherwise. - * Does not forward PACKET position (because it is typically the last thing done - * with a given PACKET). - */ -__owur static ossl_inline int PACKET_strndup(const PACKET *pkt, char **data) -{ - OPENSSL_free(*data); - - /* This will succeed on an empty packet, unless pkt->curr == NULL. */ - *data = OPENSSL_strndup((const char *)pkt->curr, PACKET_remaining(pkt)); - return (*data != NULL); -} - -/* Returns 1 if |pkt| contains at least one 0-byte, 0 otherwise. */ -static ossl_inline int PACKET_contains_zero_byte(const PACKET *pkt) -{ - return memchr(pkt->curr, 0, pkt->remaining) != NULL; -} - -/* Move the current reading position forward |len| bytes */ -__owur static ossl_inline int PACKET_forward(PACKET *pkt, size_t len) -{ - if (PACKET_remaining(pkt) < len) - return 0; - - packet_forward(pkt, len); - - return 1; -} - -/* - * Reads a variable-length vector prefixed with a one-byte length, and stores - * the contents in |subpkt|. |pkt| can equal |subpkt|. - * Data is not copied: the |subpkt| packet will share its underlying buffer with - * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. - * Upon failure, the original |pkt| and |subpkt| are not modified. - */ -__owur static ossl_inline int PACKET_get_length_prefixed_1(PACKET *pkt, - PACKET *subpkt) -{ - unsigned int length; - const unsigned char *data; - PACKET tmp = *pkt; - if (!PACKET_get_1(&tmp, &length) || - !PACKET_get_bytes(&tmp, &data, (size_t)length)) { - return 0; - } - - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = length; - - return 1; -} - -/* - * Like PACKET_get_length_prefixed_1, but additionally, fails when there are - * leftover bytes in |pkt|. - */ -__owur static ossl_inline int PACKET_as_length_prefixed_1(PACKET *pkt, - PACKET *subpkt) -{ - unsigned int length; - const unsigned char *data; - PACKET tmp = *pkt; - if (!PACKET_get_1(&tmp, &length) || - !PACKET_get_bytes(&tmp, &data, (size_t)length) || - PACKET_remaining(&tmp) != 0) { - return 0; - } - - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = length; - - return 1; -} - -/* - * Reads a variable-length vector prefixed with a two-byte length, and stores - * the contents in |subpkt|. |pkt| can equal |subpkt|. - * Data is not copied: the |subpkt| packet will share its underlying buffer with - * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. - * Upon failure, the original |pkt| and |subpkt| are not modified. - */ -__owur static ossl_inline int PACKET_get_length_prefixed_2(PACKET *pkt, - PACKET *subpkt) -{ - unsigned int length; - const unsigned char *data; - PACKET tmp = *pkt; - - if (!PACKET_get_net_2(&tmp, &length) || - !PACKET_get_bytes(&tmp, &data, (size_t)length)) { - return 0; - } - - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = length; - - return 1; -} - -/* - * Like PACKET_get_length_prefixed_2, but additionally, fails when there are - * leftover bytes in |pkt|. - */ -__owur static ossl_inline int PACKET_as_length_prefixed_2(PACKET *pkt, - PACKET *subpkt) -{ - unsigned int length; - const unsigned char *data; - PACKET tmp = *pkt; - - if (!PACKET_get_net_2(&tmp, &length) || - !PACKET_get_bytes(&tmp, &data, (size_t)length) || - PACKET_remaining(&tmp) != 0) { - return 0; - } - - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = length; - - return 1; -} - -/* - * Reads a variable-length vector prefixed with a three-byte length, and stores - * the contents in |subpkt|. |pkt| can equal |subpkt|. - * Data is not copied: the |subpkt| packet will share its underlying buffer with - * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. - * Upon failure, the original |pkt| and |subpkt| are not modified. - */ -__owur static ossl_inline int PACKET_get_length_prefixed_3(PACKET *pkt, - PACKET *subpkt) -{ - unsigned long length; - const unsigned char *data; - PACKET tmp = *pkt; - if (!PACKET_get_net_3(&tmp, &length) || - !PACKET_get_bytes(&tmp, &data, (size_t)length)) { - return 0; - } - - *pkt = tmp; - subpkt->curr = data; - subpkt->remaining = length; - - return 1; -} - -/* Writeable packets */ - -typedef struct wpacket_sub WPACKET_SUB; -struct wpacket_sub { - /* The parent WPACKET_SUB if we have one or NULL otherwise */ - WPACKET_SUB *parent; - - /* - * Offset into the buffer where the length of this WPACKET goes. We use an - * offset in case the buffer grows and gets reallocated. - */ - size_t packet_len; - - /* Number of bytes in the packet_len or 0 if we don't write the length */ - size_t lenbytes; - - /* Number of bytes written to the buf prior to this packet starting */ - size_t pwritten; - - /* Flags for this sub-packet */ - unsigned int flags; -}; - -typedef struct wpacket_st WPACKET; -struct wpacket_st { - /* The buffer where we store the output data */ - BUF_MEM *buf; - - /* Fixed sized buffer which can be used as an alternative to buf */ - unsigned char *staticbuf; - - /* - * Offset into the buffer where we are currently writing. We use an offset - * in case the buffer grows and gets reallocated. - */ - size_t curr; - - /* Number of bytes written so far */ - size_t written; - - /* Maximum number of bytes we will allow to be written to this WPACKET */ - size_t maxsize; - - /* Our sub-packets (always at least one if not finished) */ - WPACKET_SUB *subs; -}; - -/* Flags */ - -/* Default */ -#define WPACKET_FLAGS_NONE 0 - -/* Error on WPACKET_close() if no data written to the WPACKET */ -#define WPACKET_FLAGS_NON_ZERO_LENGTH 1 - -/* - * Abandon all changes on WPACKET_close() if no data written to the WPACKET, - * i.e. this does not write out a zero packet length - */ -#define WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH 2 - - -/* - * Initialise a WPACKET with the buffer in |buf|. The buffer must exist - * for the whole time that the WPACKET is being used. Additionally |lenbytes| of - * data is preallocated at the start of the buffer to store the length of the - * WPACKET once we know it. - */ -int WPACKET_init_len(WPACKET *pkt, BUF_MEM *buf, size_t lenbytes); - -/* - * Same as WPACKET_init_len except there is no preallocation of the WPACKET - * length. - */ -int WPACKET_init(WPACKET *pkt, BUF_MEM *buf); - -/* - * Same as WPACKET_init_len except we do not use a growable BUF_MEM structure. - * A fixed buffer of memory |buf| of size |len| is used instead. A failure will - * occur if you attempt to write beyond the end of the buffer - */ -int WPACKET_init_static_len(WPACKET *pkt, unsigned char *buf, size_t len, - size_t lenbytes); -/* - * Set the flags to be applied to the current sub-packet - */ -int WPACKET_set_flags(WPACKET *pkt, unsigned int flags); - -/* - * Closes the most recent sub-packet. It also writes out the length of the - * packet to the required location (normally the start of the WPACKET) if - * appropriate. The top level WPACKET should be closed using WPACKET_finish() - * instead of this function. - */ -int WPACKET_close(WPACKET *pkt); - -/* - * The same as WPACKET_close() but only for the top most WPACKET. Additionally - * frees memory resources for this WPACKET. - */ -int WPACKET_finish(WPACKET *pkt); - -/* - * Iterate through all the sub-packets and write out their lengths as if they - * were being closed. The lengths will be overwritten with the final lengths - * when the sub-packets are eventually closed (which may be different if more - * data is added to the WPACKET). This function fails if a sub-packet is of 0 - * length and WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH is set. - */ -int WPACKET_fill_lengths(WPACKET *pkt); - -/* - * Initialise a new sub-packet. Additionally |lenbytes| of data is preallocated - * at the start of the sub-packet to store its length once we know it. Don't - * call this directly. Use the convenience macros below instead. - */ -int WPACKET_start_sub_packet_len__(WPACKET *pkt, size_t lenbytes); - -/* - * Convenience macros for calling WPACKET_start_sub_packet_len with different - * lengths - */ -#define WPACKET_start_sub_packet_u8(pkt) \ - WPACKET_start_sub_packet_len__((pkt), 1) -#define WPACKET_start_sub_packet_u16(pkt) \ - WPACKET_start_sub_packet_len__((pkt), 2) -#define WPACKET_start_sub_packet_u24(pkt) \ - WPACKET_start_sub_packet_len__((pkt), 3) -#define WPACKET_start_sub_packet_u32(pkt) \ - WPACKET_start_sub_packet_len__((pkt), 4) - -/* - * Same as WPACKET_start_sub_packet_len__() except no bytes are pre-allocated - * for the sub-packet length. - */ -int WPACKET_start_sub_packet(WPACKET *pkt); - -/* - * Allocate bytes in the WPACKET for the output. This reserves the bytes - * and counts them as "written", but doesn't actually do the writing. A pointer - * to the allocated bytes is stored in |*allocbytes|. |allocbytes| may be NULL. - * WARNING: the allocated bytes must be filled in immediately, without further - * WPACKET_* calls. If not then the underlying buffer may be realloc'd and - * change its location. - */ -int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, - unsigned char **allocbytes); - -/* - * The same as WPACKET_allocate_bytes() except additionally a new sub-packet is - * started for the allocated bytes, and then closed immediately afterwards. The - * number of length bytes for the sub-packet is in |lenbytes|. Don't call this - * directly. Use the convenience macros below instead. - */ -int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len, - unsigned char **allocbytes, size_t lenbytes); - -/* - * Convenience macros for calling WPACKET_sub_allocate_bytes with different - * lengths - */ -#define WPACKET_sub_allocate_bytes_u8(pkt, len, bytes) \ - WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 1) -#define WPACKET_sub_allocate_bytes_u16(pkt, len, bytes) \ - WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 2) -#define WPACKET_sub_allocate_bytes_u24(pkt, len, bytes) \ - WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 3) -#define WPACKET_sub_allocate_bytes_u32(pkt, len, bytes) \ - WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 4) - -/* - * The same as WPACKET_allocate_bytes() except the reserved bytes are not - * actually counted as written. Typically this will be for when we don't know - * how big arbitrary data is going to be up front, but we do know what the - * maximum size will be. If this function is used, then it should be immediately - * followed by a WPACKET_allocate_bytes() call before any other WPACKET - * functions are called (unless the write to the allocated bytes is abandoned). - * - * For example: If we are generating a signature, then the size of that - * signature may not be known in advance. We can use WPACKET_reserve_bytes() to - * handle this: - * - * if (!WPACKET_sub_reserve_bytes_u16(&pkt, EVP_PKEY_size(pkey), &sigbytes1) - * || EVP_SignFinal(md_ctx, sigbytes1, &siglen, pkey) <= 0 - * || !WPACKET_sub_allocate_bytes_u16(&pkt, siglen, &sigbytes2) - * || sigbytes1 != sigbytes2) - * goto err; - */ -int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes); - -/* - * The "reserve_bytes" equivalent of WPACKET_sub_allocate_bytes__() - */ -int WPACKET_sub_reserve_bytes__(WPACKET *pkt, size_t len, - unsigned char **allocbytes, size_t lenbytes); - -/* - * Convenience macros for WPACKET_sub_reserve_bytes with different lengths - */ -#define WPACKET_sub_reserve_bytes_u8(pkt, len, bytes) \ - WPACKET_reserve_bytes__((pkt), (len), (bytes), 1) -#define WPACKET_sub_reserve_bytes_u16(pkt, len, bytes) \ - WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 2) -#define WPACKET_sub_reserve_bytes_u24(pkt, len, bytes) \ - WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 3) -#define WPACKET_sub_reserve_bytes_u32(pkt, len, bytes) \ - WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 4) - -/* - * Write the value stored in |val| into the WPACKET. The value will consume - * |bytes| amount of storage. An error will occur if |val| cannot be - * accommodated in |bytes| storage, e.g. attempting to write the value 256 into - * 1 byte will fail. Don't call this directly. Use the convenience macros below - * instead. - */ -int WPACKET_put_bytes__(WPACKET *pkt, unsigned int val, size_t bytes); - -/* - * Convenience macros for calling WPACKET_put_bytes with different - * lengths - */ -#define WPACKET_put_bytes_u8(pkt, val) \ - WPACKET_put_bytes__((pkt), (val), 1) -#define WPACKET_put_bytes_u16(pkt, val) \ - WPACKET_put_bytes__((pkt), (val), 2) -#define WPACKET_put_bytes_u24(pkt, val) \ - WPACKET_put_bytes__((pkt), (val), 3) -#define WPACKET_put_bytes_u32(pkt, val) \ - WPACKET_put_bytes__((pkt), (val), 4) - -/* Set a maximum size that we will not allow the WPACKET to grow beyond */ -int WPACKET_set_max_size(WPACKET *pkt, size_t maxsize); - -/* Copy |len| bytes of data from |*src| into the WPACKET. */ -int WPACKET_memcpy(WPACKET *pkt, const void *src, size_t len); - -/* Set |len| bytes of data to |ch| into the WPACKET. */ -int WPACKET_memset(WPACKET *pkt, int ch, size_t len); - -/* - * Copy |len| bytes of data from |*src| into the WPACKET and prefix with its - * length (consuming |lenbytes| of data for the length). Don't call this - * directly. Use the convenience macros below instead. - */ -int WPACKET_sub_memcpy__(WPACKET *pkt, const void *src, size_t len, - size_t lenbytes); - -/* Convenience macros for calling WPACKET_sub_memcpy with different lengths */ -#define WPACKET_sub_memcpy_u8(pkt, src, len) \ - WPACKET_sub_memcpy__((pkt), (src), (len), 1) -#define WPACKET_sub_memcpy_u16(pkt, src, len) \ - WPACKET_sub_memcpy__((pkt), (src), (len), 2) -#define WPACKET_sub_memcpy_u24(pkt, src, len) \ - WPACKET_sub_memcpy__((pkt), (src), (len), 3) -#define WPACKET_sub_memcpy_u32(pkt, src, len) \ - WPACKET_sub_memcpy__((pkt), (src), (len), 4) - -/* - * Return the total number of bytes written so far to the underlying buffer - * including any storage allocated for length bytes - */ -int WPACKET_get_total_written(WPACKET *pkt, size_t *written); - -/* - * Returns the length of the current sub-packet. This excludes any bytes - * allocated for the length itself. - */ -int WPACKET_get_length(WPACKET *pkt, size_t *len); - -/* - * Returns a pointer to the current write location, but does not allocate any - * bytes. - */ -unsigned char *WPACKET_get_curr(WPACKET *pkt); - -/* Release resources in a WPACKET if a failure has occurred. */ -void WPACKET_cleanup(WPACKET *pkt); - -#endif /* OSSL_SSL_PACKET_LOCAL_H */ +/* + * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_SSL_PACKET_LOCAL_H +# define OSSL_SSL_PACKET_LOCAL_H + +# include <string.h> +# include <openssl/bn.h> +# include <openssl/buffer.h> +# include <openssl/crypto.h> +# include <openssl/e_os2.h> + +# include "internal/numbers.h" + +typedef struct { + /* Pointer to where we are currently reading from */ + const unsigned char *curr; + /* Number of bytes remaining */ + size_t remaining; +} PACKET; + +/* Internal unchecked shorthand; don't use outside this file. */ +static ossl_inline void packet_forward(PACKET *pkt, size_t len) +{ + pkt->curr += len; + pkt->remaining -= len; +} + +/* + * Returns the number of bytes remaining to be read in the PACKET + */ +static ossl_inline size_t PACKET_remaining(const PACKET *pkt) +{ + return pkt->remaining; +} + +/* + * Returns a pointer to the first byte after the packet data. + * Useful for integrating with non-PACKET parsing code. + * Specifically, we use PACKET_end() to verify that a d2i_... call + * has consumed the entire packet contents. + */ +static ossl_inline const unsigned char *PACKET_end(const PACKET *pkt) +{ + return pkt->curr + pkt->remaining; +} + +/* + * Returns a pointer to the PACKET's current position. + * For use in non-PACKETized APIs. + */ +static ossl_inline const unsigned char *PACKET_data(const PACKET *pkt) +{ + return pkt->curr; +} + +/* + * Initialise a PACKET with |len| bytes held in |buf|. This does not make a + * copy of the data so |buf| must be present for the whole time that the PACKET + * is being used. + */ +__owur static ossl_inline int PACKET_buf_init(PACKET *pkt, + const unsigned char *buf, + size_t len) +{ + /* Sanity check for negative values. */ + if (len > (size_t)(SIZE_MAX / 2)) + return 0; + + pkt->curr = buf; + pkt->remaining = len; + return 1; +} + +/* Initialize a PACKET to hold zero bytes. */ +static ossl_inline void PACKET_null_init(PACKET *pkt) +{ + pkt->curr = NULL; + pkt->remaining = 0; +} + +/* + * Returns 1 if the packet has length |num| and its contents equal the |num| + * bytes read from |ptr|. Returns 0 otherwise (lengths or contents not equal). + * If lengths are equal, performs the comparison in constant time. + */ +__owur static ossl_inline int PACKET_equal(const PACKET *pkt, const void *ptr, + size_t num) +{ + if (PACKET_remaining(pkt) != num) + return 0; + return CRYPTO_memcmp(pkt->curr, ptr, num) == 0; +} + +/* + * Peek ahead and initialize |subpkt| with the next |len| bytes read from |pkt|. + * Data is not copied: the |subpkt| packet will share its underlying buffer with + * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. + */ +__owur static ossl_inline int PACKET_peek_sub_packet(const PACKET *pkt, + PACKET *subpkt, size_t len) +{ + if (PACKET_remaining(pkt) < len) + return 0; + + return PACKET_buf_init(subpkt, pkt->curr, len); +} + +/* + * Initialize |subpkt| with the next |len| bytes read from |pkt|. Data is not + * copied: the |subpkt| packet will share its underlying buffer with the + * original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. + */ +__owur static ossl_inline int PACKET_get_sub_packet(PACKET *pkt, + PACKET *subpkt, size_t len) +{ + if (!PACKET_peek_sub_packet(pkt, subpkt, len)) + return 0; + + packet_forward(pkt, len); + + return 1; +} + +/* + * Peek ahead at 2 bytes in network order from |pkt| and store the value in + * |*data| + */ +__owur static ossl_inline int PACKET_peek_net_2(const PACKET *pkt, + unsigned int *data) +{ + if (PACKET_remaining(pkt) < 2) + return 0; + + *data = ((unsigned int)(*pkt->curr)) << 8; + *data |= *(pkt->curr + 1); + + return 1; +} + +/* Equivalent of n2s */ +/* Get 2 bytes in network order from |pkt| and store the value in |*data| */ +__owur static ossl_inline int PACKET_get_net_2(PACKET *pkt, unsigned int *data) +{ + if (!PACKET_peek_net_2(pkt, data)) + return 0; + + packet_forward(pkt, 2); + + return 1; +} + +/* Same as PACKET_get_net_2() but for a size_t */ +__owur static ossl_inline int PACKET_get_net_2_len(PACKET *pkt, size_t *data) +{ + unsigned int i; + int ret = PACKET_get_net_2(pkt, &i); + + if (ret) + *data = (size_t)i; + + return ret; +} + +/* + * Peek ahead at 3 bytes in network order from |pkt| and store the value in + * |*data| + */ +__owur static ossl_inline int PACKET_peek_net_3(const PACKET *pkt, + unsigned long *data) +{ + if (PACKET_remaining(pkt) < 3) + return 0; + + *data = ((unsigned long)(*pkt->curr)) << 16; + *data |= ((unsigned long)(*(pkt->curr + 1))) << 8; + *data |= *(pkt->curr + 2); + + return 1; +} + +/* Equivalent of n2l3 */ +/* Get 3 bytes in network order from |pkt| and store the value in |*data| */ +__owur static ossl_inline int PACKET_get_net_3(PACKET *pkt, unsigned long *data) +{ + if (!PACKET_peek_net_3(pkt, data)) + return 0; + + packet_forward(pkt, 3); + + return 1; +} + +/* Same as PACKET_get_net_3() but for a size_t */ +__owur static ossl_inline int PACKET_get_net_3_len(PACKET *pkt, size_t *data) +{ + unsigned long i; + int ret = PACKET_get_net_3(pkt, &i); + + if (ret) + *data = (size_t)i; + + return ret; +} + +/* + * Peek ahead at 4 bytes in network order from |pkt| and store the value in + * |*data| + */ +__owur static ossl_inline int PACKET_peek_net_4(const PACKET *pkt, + unsigned long *data) +{ + if (PACKET_remaining(pkt) < 4) + return 0; + + *data = ((unsigned long)(*pkt->curr)) << 24; + *data |= ((unsigned long)(*(pkt->curr + 1))) << 16; + *data |= ((unsigned long)(*(pkt->curr + 2))) << 8; + *data |= *(pkt->curr + 3); + + return 1; +} + +/* Equivalent of n2l */ +/* Get 4 bytes in network order from |pkt| and store the value in |*data| */ +__owur static ossl_inline int PACKET_get_net_4(PACKET *pkt, unsigned long *data) +{ + if (!PACKET_peek_net_4(pkt, data)) + return 0; + + packet_forward(pkt, 4); + + return 1; +} + +/* Same as PACKET_get_net_4() but for a size_t */ +__owur static ossl_inline int PACKET_get_net_4_len(PACKET *pkt, size_t *data) +{ + unsigned long i; + int ret = PACKET_get_net_4(pkt, &i); + + if (ret) + *data = (size_t)i; + + return ret; +} + +/* Peek ahead at 1 byte from |pkt| and store the value in |*data| */ +__owur static ossl_inline int PACKET_peek_1(const PACKET *pkt, + unsigned int *data) +{ + if (!PACKET_remaining(pkt)) + return 0; + + *data = *pkt->curr; + + return 1; +} + +/* Get 1 byte from |pkt| and store the value in |*data| */ +__owur static ossl_inline int PACKET_get_1(PACKET *pkt, unsigned int *data) +{ + if (!PACKET_peek_1(pkt, data)) + return 0; + + packet_forward(pkt, 1); + + return 1; +} + +/* Same as PACKET_get_1() but for a size_t */ +__owur static ossl_inline int PACKET_get_1_len(PACKET *pkt, size_t *data) +{ + unsigned int i; + int ret = PACKET_get_1(pkt, &i); + + if (ret) + *data = (size_t)i; + + return ret; +} + +/* + * Peek ahead at 4 bytes in reverse network order from |pkt| and store the value + * in |*data| + */ +__owur static ossl_inline int PACKET_peek_4(const PACKET *pkt, + unsigned long *data) +{ + if (PACKET_remaining(pkt) < 4) + return 0; + + *data = *pkt->curr; + *data |= ((unsigned long)(*(pkt->curr + 1))) << 8; + *data |= ((unsigned long)(*(pkt->curr + 2))) << 16; + *data |= ((unsigned long)(*(pkt->curr + 3))) << 24; + + return 1; +} + +/* Equivalent of c2l */ +/* + * Get 4 bytes in reverse network order from |pkt| and store the value in + * |*data| + */ +__owur static ossl_inline int PACKET_get_4(PACKET *pkt, unsigned long *data) +{ + if (!PACKET_peek_4(pkt, data)) + return 0; + + packet_forward(pkt, 4); + + return 1; +} + +/* + * Peek ahead at |len| bytes from the |pkt| and store a pointer to them in + * |*data|. This just points at the underlying buffer that |pkt| is using. The + * caller should not free this data directly (it will be freed when the + * underlying buffer gets freed + */ +__owur static ossl_inline int PACKET_peek_bytes(const PACKET *pkt, + const unsigned char **data, + size_t len) +{ + if (PACKET_remaining(pkt) < len) + return 0; + + *data = pkt->curr; + + return 1; +} + +/* + * Read |len| bytes from the |pkt| and store a pointer to them in |*data|. This + * just points at the underlying buffer that |pkt| is using. The caller should + * not free this data directly (it will be freed when the underlying buffer gets + * freed + */ +__owur static ossl_inline int PACKET_get_bytes(PACKET *pkt, + const unsigned char **data, + size_t len) +{ + if (!PACKET_peek_bytes(pkt, data, len)) + return 0; + + packet_forward(pkt, len); + + return 1; +} + +/* Peek ahead at |len| bytes from |pkt| and copy them to |data| */ +__owur static ossl_inline int PACKET_peek_copy_bytes(const PACKET *pkt, + unsigned char *data, + size_t len) +{ + if (PACKET_remaining(pkt) < len) + return 0; + + memcpy(data, pkt->curr, len); + + return 1; +} + +/* + * Read |len| bytes from |pkt| and copy them to |data|. + * The caller is responsible for ensuring that |data| can hold |len| bytes. + */ +__owur static ossl_inline int PACKET_copy_bytes(PACKET *pkt, + unsigned char *data, size_t len) +{ + if (!PACKET_peek_copy_bytes(pkt, data, len)) + return 0; + + packet_forward(pkt, len); + + return 1; +} + +/* + * Copy packet data to |dest|, and set |len| to the number of copied bytes. + * If the packet has more than |dest_len| bytes, nothing is copied. + * Returns 1 if the packet data fits in |dest_len| bytes, 0 otherwise. + * Does not forward PACKET position (because it is typically the last thing + * done with a given PACKET). + */ +__owur static ossl_inline int PACKET_copy_all(const PACKET *pkt, + unsigned char *dest, + size_t dest_len, size_t *len) +{ + if (PACKET_remaining(pkt) > dest_len) { + *len = 0; + return 0; + } + *len = pkt->remaining; + memcpy(dest, pkt->curr, pkt->remaining); + return 1; +} + +/* + * Copy |pkt| bytes to a newly allocated buffer and store a pointer to the + * result in |*data|, and the length in |len|. + * If |*data| is not NULL, the old data is OPENSSL_free'd. + * If the packet is empty, or malloc fails, |*data| will be set to NULL. + * Returns 1 if the malloc succeeds and 0 otherwise. + * Does not forward PACKET position (because it is typically the last thing + * done with a given PACKET). + */ +__owur static ossl_inline int PACKET_memdup(const PACKET *pkt, + unsigned char **data, size_t *len) +{ + size_t length; + + OPENSSL_free(*data); + *data = NULL; + *len = 0; + + length = PACKET_remaining(pkt); + + if (length == 0) + return 1; + + *data = OPENSSL_memdup(pkt->curr, length); + if (*data == NULL) + return 0; + + *len = length; + return 1; +} + +/* + * Read a C string from |pkt| and copy to a newly allocated, NUL-terminated + * buffer. Store a pointer to the result in |*data|. + * If |*data| is not NULL, the old data is OPENSSL_free'd. + * If the data in |pkt| does not contain a NUL-byte, the entire data is + * copied and NUL-terminated. + * Returns 1 if the malloc succeeds and 0 otherwise. + * Does not forward PACKET position (because it is typically the last thing done + * with a given PACKET). + */ +__owur static ossl_inline int PACKET_strndup(const PACKET *pkt, char **data) +{ + OPENSSL_free(*data); + + /* This will succeed on an empty packet, unless pkt->curr == NULL. */ + *data = OPENSSL_strndup((const char *)pkt->curr, PACKET_remaining(pkt)); + return (*data != NULL); +} + +/* Returns 1 if |pkt| contains at least one 0-byte, 0 otherwise. */ +static ossl_inline int PACKET_contains_zero_byte(const PACKET *pkt) +{ + return memchr(pkt->curr, 0, pkt->remaining) != NULL; +} + +/* Move the current reading position forward |len| bytes */ +__owur static ossl_inline int PACKET_forward(PACKET *pkt, size_t len) +{ + if (PACKET_remaining(pkt) < len) + return 0; + + packet_forward(pkt, len); + + return 1; +} + +/* + * Reads a variable-length vector prefixed with a one-byte length, and stores + * the contents in |subpkt|. |pkt| can equal |subpkt|. + * Data is not copied: the |subpkt| packet will share its underlying buffer with + * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. + * Upon failure, the original |pkt| and |subpkt| are not modified. + */ +__owur static ossl_inline int PACKET_get_length_prefixed_1(PACKET *pkt, + PACKET *subpkt) +{ + unsigned int length; + const unsigned char *data; + PACKET tmp = *pkt; + if (!PACKET_get_1(&tmp, &length) || + !PACKET_get_bytes(&tmp, &data, (size_t)length)) { + return 0; + } + + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = length; + + return 1; +} + +/* + * Like PACKET_get_length_prefixed_1, but additionally, fails when there are + * leftover bytes in |pkt|. + */ +__owur static ossl_inline int PACKET_as_length_prefixed_1(PACKET *pkt, + PACKET *subpkt) +{ + unsigned int length; + const unsigned char *data; + PACKET tmp = *pkt; + if (!PACKET_get_1(&tmp, &length) || + !PACKET_get_bytes(&tmp, &data, (size_t)length) || + PACKET_remaining(&tmp) != 0) { + return 0; + } + + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = length; + + return 1; +} + +/* + * Reads a variable-length vector prefixed with a two-byte length, and stores + * the contents in |subpkt|. |pkt| can equal |subpkt|. + * Data is not copied: the |subpkt| packet will share its underlying buffer with + * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. + * Upon failure, the original |pkt| and |subpkt| are not modified. + */ +__owur static ossl_inline int PACKET_get_length_prefixed_2(PACKET *pkt, + PACKET *subpkt) +{ + unsigned int length; + const unsigned char *data; + PACKET tmp = *pkt; + + if (!PACKET_get_net_2(&tmp, &length) || + !PACKET_get_bytes(&tmp, &data, (size_t)length)) { + return 0; + } + + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = length; + + return 1; +} + +/* + * Like PACKET_get_length_prefixed_2, but additionally, fails when there are + * leftover bytes in |pkt|. + */ +__owur static ossl_inline int PACKET_as_length_prefixed_2(PACKET *pkt, + PACKET *subpkt) +{ + unsigned int length; + const unsigned char *data; + PACKET tmp = *pkt; + + if (!PACKET_get_net_2(&tmp, &length) || + !PACKET_get_bytes(&tmp, &data, (size_t)length) || + PACKET_remaining(&tmp) != 0) { + return 0; + } + + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = length; + + return 1; +} + +/* + * Reads a variable-length vector prefixed with a three-byte length, and stores + * the contents in |subpkt|. |pkt| can equal |subpkt|. + * Data is not copied: the |subpkt| packet will share its underlying buffer with + * the original |pkt|, so data wrapped by |pkt| must outlive the |subpkt|. + * Upon failure, the original |pkt| and |subpkt| are not modified. + */ +__owur static ossl_inline int PACKET_get_length_prefixed_3(PACKET *pkt, + PACKET *subpkt) +{ + unsigned long length; + const unsigned char *data; + PACKET tmp = *pkt; + if (!PACKET_get_net_3(&tmp, &length) || + !PACKET_get_bytes(&tmp, &data, (size_t)length)) { + return 0; + } + + *pkt = tmp; + subpkt->curr = data; + subpkt->remaining = length; + + return 1; +} + +/* Writeable packets */ + +typedef struct wpacket_sub WPACKET_SUB; +struct wpacket_sub { + /* The parent WPACKET_SUB if we have one or NULL otherwise */ + WPACKET_SUB *parent; + + /* + * Offset into the buffer where the length of this WPACKET goes. We use an + * offset in case the buffer grows and gets reallocated. + */ + size_t packet_len; + + /* Number of bytes in the packet_len or 0 if we don't write the length */ + size_t lenbytes; + + /* Number of bytes written to the buf prior to this packet starting */ + size_t pwritten; + + /* Flags for this sub-packet */ + unsigned int flags; +}; + +typedef struct wpacket_st WPACKET; +struct wpacket_st { + /* The buffer where we store the output data */ + BUF_MEM *buf; + + /* Fixed sized buffer which can be used as an alternative to buf */ + unsigned char *staticbuf; + + /* + * Offset into the buffer where we are currently writing. We use an offset + * in case the buffer grows and gets reallocated. + */ + size_t curr; + + /* Number of bytes written so far */ + size_t written; + + /* Maximum number of bytes we will allow to be written to this WPACKET */ + size_t maxsize; + + /* Our sub-packets (always at least one if not finished) */ + WPACKET_SUB *subs; +}; + +/* Flags */ + +/* Default */ +#define WPACKET_FLAGS_NONE 0 + +/* Error on WPACKET_close() if no data written to the WPACKET */ +#define WPACKET_FLAGS_NON_ZERO_LENGTH 1 + +/* + * Abandon all changes on WPACKET_close() if no data written to the WPACKET, + * i.e. this does not write out a zero packet length + */ +#define WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH 2 + + +/* + * Initialise a WPACKET with the buffer in |buf|. The buffer must exist + * for the whole time that the WPACKET is being used. Additionally |lenbytes| of + * data is preallocated at the start of the buffer to store the length of the + * WPACKET once we know it. + */ +int WPACKET_init_len(WPACKET *pkt, BUF_MEM *buf, size_t lenbytes); + +/* + * Same as WPACKET_init_len except there is no preallocation of the WPACKET + * length. + */ +int WPACKET_init(WPACKET *pkt, BUF_MEM *buf); + +/* + * Same as WPACKET_init_len except we do not use a growable BUF_MEM structure. + * A fixed buffer of memory |buf| of size |len| is used instead. A failure will + * occur if you attempt to write beyond the end of the buffer + */ +int WPACKET_init_static_len(WPACKET *pkt, unsigned char *buf, size_t len, + size_t lenbytes); +/* + * Set the flags to be applied to the current sub-packet + */ +int WPACKET_set_flags(WPACKET *pkt, unsigned int flags); + +/* + * Closes the most recent sub-packet. It also writes out the length of the + * packet to the required location (normally the start of the WPACKET) if + * appropriate. The top level WPACKET should be closed using WPACKET_finish() + * instead of this function. + */ +int WPACKET_close(WPACKET *pkt); + +/* + * The same as WPACKET_close() but only for the top most WPACKET. Additionally + * frees memory resources for this WPACKET. + */ +int WPACKET_finish(WPACKET *pkt); + +/* + * Iterate through all the sub-packets and write out their lengths as if they + * were being closed. The lengths will be overwritten with the final lengths + * when the sub-packets are eventually closed (which may be different if more + * data is added to the WPACKET). This function fails if a sub-packet is of 0 + * length and WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH is set. + */ +int WPACKET_fill_lengths(WPACKET *pkt); + +/* + * Initialise a new sub-packet. Additionally |lenbytes| of data is preallocated + * at the start of the sub-packet to store its length once we know it. Don't + * call this directly. Use the convenience macros below instead. + */ +int WPACKET_start_sub_packet_len__(WPACKET *pkt, size_t lenbytes); + +/* + * Convenience macros for calling WPACKET_start_sub_packet_len with different + * lengths + */ +#define WPACKET_start_sub_packet_u8(pkt) \ + WPACKET_start_sub_packet_len__((pkt), 1) +#define WPACKET_start_sub_packet_u16(pkt) \ + WPACKET_start_sub_packet_len__((pkt), 2) +#define WPACKET_start_sub_packet_u24(pkt) \ + WPACKET_start_sub_packet_len__((pkt), 3) +#define WPACKET_start_sub_packet_u32(pkt) \ + WPACKET_start_sub_packet_len__((pkt), 4) + +/* + * Same as WPACKET_start_sub_packet_len__() except no bytes are pre-allocated + * for the sub-packet length. + */ +int WPACKET_start_sub_packet(WPACKET *pkt); + +/* + * Allocate bytes in the WPACKET for the output. This reserves the bytes + * and counts them as "written", but doesn't actually do the writing. A pointer + * to the allocated bytes is stored in |*allocbytes|. |allocbytes| may be NULL. + * WARNING: the allocated bytes must be filled in immediately, without further + * WPACKET_* calls. If not then the underlying buffer may be realloc'd and + * change its location. + */ +int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, + unsigned char **allocbytes); + +/* + * The same as WPACKET_allocate_bytes() except additionally a new sub-packet is + * started for the allocated bytes, and then closed immediately afterwards. The + * number of length bytes for the sub-packet is in |lenbytes|. Don't call this + * directly. Use the convenience macros below instead. + */ +int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len, + unsigned char **allocbytes, size_t lenbytes); + +/* + * Convenience macros for calling WPACKET_sub_allocate_bytes with different + * lengths + */ +#define WPACKET_sub_allocate_bytes_u8(pkt, len, bytes) \ + WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 1) +#define WPACKET_sub_allocate_bytes_u16(pkt, len, bytes) \ + WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 2) +#define WPACKET_sub_allocate_bytes_u24(pkt, len, bytes) \ + WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 3) +#define WPACKET_sub_allocate_bytes_u32(pkt, len, bytes) \ + WPACKET_sub_allocate_bytes__((pkt), (len), (bytes), 4) + +/* + * The same as WPACKET_allocate_bytes() except the reserved bytes are not + * actually counted as written. Typically this will be for when we don't know + * how big arbitrary data is going to be up front, but we do know what the + * maximum size will be. If this function is used, then it should be immediately + * followed by a WPACKET_allocate_bytes() call before any other WPACKET + * functions are called (unless the write to the allocated bytes is abandoned). + * + * For example: If we are generating a signature, then the size of that + * signature may not be known in advance. We can use WPACKET_reserve_bytes() to + * handle this: + * + * if (!WPACKET_sub_reserve_bytes_u16(&pkt, EVP_PKEY_size(pkey), &sigbytes1) + * || EVP_SignFinal(md_ctx, sigbytes1, &siglen, pkey) <= 0 + * || !WPACKET_sub_allocate_bytes_u16(&pkt, siglen, &sigbytes2) + * || sigbytes1 != sigbytes2) + * goto err; + */ +int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes); + +/* + * The "reserve_bytes" equivalent of WPACKET_sub_allocate_bytes__() + */ +int WPACKET_sub_reserve_bytes__(WPACKET *pkt, size_t len, + unsigned char **allocbytes, size_t lenbytes); + +/* + * Convenience macros for WPACKET_sub_reserve_bytes with different lengths + */ +#define WPACKET_sub_reserve_bytes_u8(pkt, len, bytes) \ + WPACKET_reserve_bytes__((pkt), (len), (bytes), 1) +#define WPACKET_sub_reserve_bytes_u16(pkt, len, bytes) \ + WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 2) +#define WPACKET_sub_reserve_bytes_u24(pkt, len, bytes) \ + WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 3) +#define WPACKET_sub_reserve_bytes_u32(pkt, len, bytes) \ + WPACKET_sub_reserve_bytes__((pkt), (len), (bytes), 4) + +/* + * Write the value stored in |val| into the WPACKET. The value will consume + * |bytes| amount of storage. An error will occur if |val| cannot be + * accommodated in |bytes| storage, e.g. attempting to write the value 256 into + * 1 byte will fail. Don't call this directly. Use the convenience macros below + * instead. + */ +int WPACKET_put_bytes__(WPACKET *pkt, unsigned int val, size_t bytes); + +/* + * Convenience macros for calling WPACKET_put_bytes with different + * lengths + */ +#define WPACKET_put_bytes_u8(pkt, val) \ + WPACKET_put_bytes__((pkt), (val), 1) +#define WPACKET_put_bytes_u16(pkt, val) \ + WPACKET_put_bytes__((pkt), (val), 2) +#define WPACKET_put_bytes_u24(pkt, val) \ + WPACKET_put_bytes__((pkt), (val), 3) +#define WPACKET_put_bytes_u32(pkt, val) \ + WPACKET_put_bytes__((pkt), (val), 4) + +/* Set a maximum size that we will not allow the WPACKET to grow beyond */ +int WPACKET_set_max_size(WPACKET *pkt, size_t maxsize); + +/* Copy |len| bytes of data from |*src| into the WPACKET. */ +int WPACKET_memcpy(WPACKET *pkt, const void *src, size_t len); + +/* Set |len| bytes of data to |ch| into the WPACKET. */ +int WPACKET_memset(WPACKET *pkt, int ch, size_t len); + +/* + * Copy |len| bytes of data from |*src| into the WPACKET and prefix with its + * length (consuming |lenbytes| of data for the length). Don't call this + * directly. Use the convenience macros below instead. + */ +int WPACKET_sub_memcpy__(WPACKET *pkt, const void *src, size_t len, + size_t lenbytes); + +/* Convenience macros for calling WPACKET_sub_memcpy with different lengths */ +#define WPACKET_sub_memcpy_u8(pkt, src, len) \ + WPACKET_sub_memcpy__((pkt), (src), (len), 1) +#define WPACKET_sub_memcpy_u16(pkt, src, len) \ + WPACKET_sub_memcpy__((pkt), (src), (len), 2) +#define WPACKET_sub_memcpy_u24(pkt, src, len) \ + WPACKET_sub_memcpy__((pkt), (src), (len), 3) +#define WPACKET_sub_memcpy_u32(pkt, src, len) \ + WPACKET_sub_memcpy__((pkt), (src), (len), 4) + +/* + * Return the total number of bytes written so far to the underlying buffer + * including any storage allocated for length bytes + */ +int WPACKET_get_total_written(WPACKET *pkt, size_t *written); + +/* + * Returns the length of the current sub-packet. This excludes any bytes + * allocated for the length itself. + */ +int WPACKET_get_length(WPACKET *pkt, size_t *len); + +/* + * Returns a pointer to the current write location, but does not allocate any + * bytes. + */ +unsigned char *WPACKET_get_curr(WPACKET *pkt); + +/* Release resources in a WPACKET if a failure has occurred. */ +void WPACKET_cleanup(WPACKET *pkt); + +#endif /* OSSL_SSL_PACKET_LOCAL_H */ diff --git a/contrib/libs/openssl/ssl/pqueue.c b/contrib/libs/openssl/ssl/pqueue.c index 3858fde6d6..758440217d 100644 --- a/contrib/libs/openssl/ssl/pqueue.c +++ b/contrib/libs/openssl/ssl/pqueue.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "ssl_local.h" +#include "ssl_local.h" #include <openssl/bn.h> struct pqueue_st { diff --git a/contrib/libs/openssl/ssl/record/dtls1_bitmap.c b/contrib/libs/openssl/ssl/record/dtls1_bitmap.c index 69867fd322..8167b41834 100644 --- a/contrib/libs/openssl/ssl/record/dtls1_bitmap.c +++ b/contrib/libs/openssl/ssl/record/dtls1_bitmap.c @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#include "../ssl_local.h" -#include "record_local.h" +#include "../ssl_local.h" +#include "record_local.h" /* mod 128 saturating subtract of two 64-bit values in big-endian order */ static int satsub64be(const unsigned char *v1, const unsigned char *v2) diff --git a/contrib/libs/openssl/ssl/record/rec_layer_d1.c b/contrib/libs/openssl/ssl/record/rec_layer_d1.c index cf8100e89e..78d29594c6 100644 --- a/contrib/libs/openssl/ssl/record/rec_layer_d1.c +++ b/contrib/libs/openssl/ssl/record/rec_layer_d1.c @@ -9,11 +9,11 @@ #include <stdio.h> #include <errno.h> -#include "../ssl_local.h" +#include "../ssl_local.h" #include <openssl/evp.h> #include <openssl/buffer.h> -#include "record_local.h" -#include "../packet_local.h" +#include "record_local.h" +#include "../packet_local.h" #include "internal/cryptlib.h" int DTLS_RECORD_LAYER_new(RECORD_LAYER *rl) diff --git a/contrib/libs/openssl/ssl/record/rec_layer_s3.c b/contrib/libs/openssl/ssl/record/rec_layer_s3.c index c870472fc0..8249b4ace9 100644 --- a/contrib/libs/openssl/ssl/record/rec_layer_s3.c +++ b/contrib/libs/openssl/ssl/record/rec_layer_s3.c @@ -10,15 +10,15 @@ #include <stdio.h> #include <limits.h> #include <errno.h> -#include "../ssl_local.h" +#include "../ssl_local.h" #include <openssl/evp.h> #include <openssl/buffer.h> #include <openssl/rand.h> -#include "record_local.h" -#include "../packet_local.h" +#include "record_local.h" +#include "../packet_local.h" #if defined(OPENSSL_SMALL_FOOTPRINT) || \ - !( defined(AESNI_ASM) && ( \ + !( defined(AESNI_ASM) && ( \ defined(__x86_64) || defined(__x86_64__) || \ defined(_M_AMD64) || defined(_M_X64) ) \ ) diff --git a/contrib/libs/openssl/ssl/record/record_local.h b/contrib/libs/openssl/ssl/record/record_local.h index 893b44a048..5e8dd7f704 100644 --- a/contrib/libs/openssl/ssl/record/record_local.h +++ b/contrib/libs/openssl/ssl/record/record_local.h @@ -1,116 +1,116 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/***************************************************************************** - * * - * The following macros/functions are PRIVATE to the record layer. They * - * should NOT be used outside of the record layer. * - * * - *****************************************************************************/ - -#define MAX_WARN_ALERT_COUNT 5 - -/* Functions/macros provided by the RECORD_LAYER component */ - -#define RECORD_LAYER_get_rrec(rl) ((rl)->rrec) -#define RECORD_LAYER_set_packet(rl, p) ((rl)->packet = (p)) -#define RECORD_LAYER_reset_packet_length(rl) ((rl)->packet_length = 0) -#define RECORD_LAYER_get_rstate(rl) ((rl)->rstate) -#define RECORD_LAYER_set_rstate(rl, st) ((rl)->rstate = (st)) -#define RECORD_LAYER_get_read_sequence(rl) ((rl)->read_sequence) -#define RECORD_LAYER_get_write_sequence(rl) ((rl)->write_sequence) -#define RECORD_LAYER_get_numrpipes(rl) ((rl)->numrpipes) -#define RECORD_LAYER_set_numrpipes(rl, n) ((rl)->numrpipes = (n)) -#define RECORD_LAYER_inc_empty_record_count(rl) ((rl)->empty_record_count++) -#define RECORD_LAYER_reset_empty_record_count(rl) \ - ((rl)->empty_record_count = 0) -#define RECORD_LAYER_get_empty_record_count(rl) ((rl)->empty_record_count) -#define RECORD_LAYER_is_first_record(rl) ((rl)->is_first_record) -#define RECORD_LAYER_set_first_record(rl) ((rl)->is_first_record = 1) -#define RECORD_LAYER_clear_first_record(rl) ((rl)->is_first_record = 0) -#define DTLS_RECORD_LAYER_get_r_epoch(rl) ((rl)->d->r_epoch) - -__owur int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold, - size_t *readbytes); - -DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr, - unsigned int *is_next_epoch); -int dtls1_process_buffered_records(SSL *s); -int dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue); -int dtls1_buffer_record(SSL *s, record_pqueue *q, unsigned char *priority); -void ssl3_record_sequence_update(unsigned char *seq); - -/* Functions provided by the DTLS1_BITMAP component */ - -int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap); -void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap); - -/* Macros/functions provided by the SSL3_BUFFER component */ - -#define SSL3_BUFFER_get_buf(b) ((b)->buf) -#define SSL3_BUFFER_set_buf(b, n) ((b)->buf = (n)) -#define SSL3_BUFFER_get_len(b) ((b)->len) -#define SSL3_BUFFER_set_len(b, l) ((b)->len = (l)) -#define SSL3_BUFFER_get_left(b) ((b)->left) -#define SSL3_BUFFER_set_left(b, l) ((b)->left = (l)) -#define SSL3_BUFFER_sub_left(b, l) ((b)->left -= (l)) -#define SSL3_BUFFER_get_offset(b) ((b)->offset) -#define SSL3_BUFFER_set_offset(b, o) ((b)->offset = (o)) -#define SSL3_BUFFER_add_offset(b, o) ((b)->offset += (o)) -#define SSL3_BUFFER_is_initialised(b) ((b)->buf != NULL) -#define SSL3_BUFFER_set_default_len(b, l) ((b)->default_len = (l)) - -void SSL3_BUFFER_clear(SSL3_BUFFER *b); -void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, size_t n); -void SSL3_BUFFER_release(SSL3_BUFFER *b); -__owur int ssl3_setup_read_buffer(SSL *s); -__owur int ssl3_setup_write_buffer(SSL *s, size_t numwpipes, size_t len); -int ssl3_release_read_buffer(SSL *s); -int ssl3_release_write_buffer(SSL *s); - -/* Macros/functions provided by the SSL3_RECORD component */ - -#define SSL3_RECORD_get_type(r) ((r)->type) -#define SSL3_RECORD_set_type(r, t) ((r)->type = (t)) -#define SSL3_RECORD_set_rec_version(r, v) ((r)->rec_version = (v)) -#define SSL3_RECORD_get_length(r) ((r)->length) -#define SSL3_RECORD_set_length(r, l) ((r)->length = (l)) -#define SSL3_RECORD_add_length(r, l) ((r)->length += (l)) -#define SSL3_RECORD_sub_length(r, l) ((r)->length -= (l)) -#define SSL3_RECORD_get_data(r) ((r)->data) -#define SSL3_RECORD_set_data(r, d) ((r)->data = (d)) -#define SSL3_RECORD_get_input(r) ((r)->input) -#define SSL3_RECORD_set_input(r, i) ((r)->input = (i)) -#define SSL3_RECORD_reset_input(r) ((r)->input = (r)->data) -#define SSL3_RECORD_get_seq_num(r) ((r)->seq_num) -#define SSL3_RECORD_get_off(r) ((r)->off) -#define SSL3_RECORD_set_off(r, o) ((r)->off = (o)) -#define SSL3_RECORD_add_off(r, o) ((r)->off += (o)) -#define SSL3_RECORD_get_epoch(r) ((r)->epoch) -#define SSL3_RECORD_is_sslv2_record(r) \ - ((r)->rec_version == SSL2_VERSION) -#define SSL3_RECORD_is_read(r) ((r)->read) -#define SSL3_RECORD_set_read(r) ((r)->read = 1) - -void SSL3_RECORD_clear(SSL3_RECORD *r, size_t); -void SSL3_RECORD_release(SSL3_RECORD *r, size_t num_recs); -void SSL3_RECORD_set_seq_num(SSL3_RECORD *r, const unsigned char *seq_num); -int ssl3_get_record(SSL *s); -__owur int ssl3_do_compress(SSL *ssl, SSL3_RECORD *wr); -__owur int ssl3_do_uncompress(SSL *ssl, SSL3_RECORD *rr); -int ssl3_cbc_copy_mac(unsigned char *out, - const SSL3_RECORD *rec, size_t md_size); -__owur int ssl3_cbc_remove_padding(SSL3_RECORD *rec, - size_t block_size, size_t mac_size); -__owur int tls1_cbc_remove_padding(const SSL *s, - SSL3_RECORD *rec, - size_t block_size, size_t mac_size); -int dtls1_process_record(SSL *s, DTLS1_BITMAP *bitmap); -__owur int dtls1_get_record(SSL *s); -int early_data_count_ok(SSL *s, size_t length, size_t overhead, int send); +/* + * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/***************************************************************************** + * * + * The following macros/functions are PRIVATE to the record layer. They * + * should NOT be used outside of the record layer. * + * * + *****************************************************************************/ + +#define MAX_WARN_ALERT_COUNT 5 + +/* Functions/macros provided by the RECORD_LAYER component */ + +#define RECORD_LAYER_get_rrec(rl) ((rl)->rrec) +#define RECORD_LAYER_set_packet(rl, p) ((rl)->packet = (p)) +#define RECORD_LAYER_reset_packet_length(rl) ((rl)->packet_length = 0) +#define RECORD_LAYER_get_rstate(rl) ((rl)->rstate) +#define RECORD_LAYER_set_rstate(rl, st) ((rl)->rstate = (st)) +#define RECORD_LAYER_get_read_sequence(rl) ((rl)->read_sequence) +#define RECORD_LAYER_get_write_sequence(rl) ((rl)->write_sequence) +#define RECORD_LAYER_get_numrpipes(rl) ((rl)->numrpipes) +#define RECORD_LAYER_set_numrpipes(rl, n) ((rl)->numrpipes = (n)) +#define RECORD_LAYER_inc_empty_record_count(rl) ((rl)->empty_record_count++) +#define RECORD_LAYER_reset_empty_record_count(rl) \ + ((rl)->empty_record_count = 0) +#define RECORD_LAYER_get_empty_record_count(rl) ((rl)->empty_record_count) +#define RECORD_LAYER_is_first_record(rl) ((rl)->is_first_record) +#define RECORD_LAYER_set_first_record(rl) ((rl)->is_first_record = 1) +#define RECORD_LAYER_clear_first_record(rl) ((rl)->is_first_record = 0) +#define DTLS_RECORD_LAYER_get_r_epoch(rl) ((rl)->d->r_epoch) + +__owur int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold, + size_t *readbytes); + +DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr, + unsigned int *is_next_epoch); +int dtls1_process_buffered_records(SSL *s); +int dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue); +int dtls1_buffer_record(SSL *s, record_pqueue *q, unsigned char *priority); +void ssl3_record_sequence_update(unsigned char *seq); + +/* Functions provided by the DTLS1_BITMAP component */ + +int dtls1_record_replay_check(SSL *s, DTLS1_BITMAP *bitmap); +void dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap); + +/* Macros/functions provided by the SSL3_BUFFER component */ + +#define SSL3_BUFFER_get_buf(b) ((b)->buf) +#define SSL3_BUFFER_set_buf(b, n) ((b)->buf = (n)) +#define SSL3_BUFFER_get_len(b) ((b)->len) +#define SSL3_BUFFER_set_len(b, l) ((b)->len = (l)) +#define SSL3_BUFFER_get_left(b) ((b)->left) +#define SSL3_BUFFER_set_left(b, l) ((b)->left = (l)) +#define SSL3_BUFFER_sub_left(b, l) ((b)->left -= (l)) +#define SSL3_BUFFER_get_offset(b) ((b)->offset) +#define SSL3_BUFFER_set_offset(b, o) ((b)->offset = (o)) +#define SSL3_BUFFER_add_offset(b, o) ((b)->offset += (o)) +#define SSL3_BUFFER_is_initialised(b) ((b)->buf != NULL) +#define SSL3_BUFFER_set_default_len(b, l) ((b)->default_len = (l)) + +void SSL3_BUFFER_clear(SSL3_BUFFER *b); +void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, size_t n); +void SSL3_BUFFER_release(SSL3_BUFFER *b); +__owur int ssl3_setup_read_buffer(SSL *s); +__owur int ssl3_setup_write_buffer(SSL *s, size_t numwpipes, size_t len); +int ssl3_release_read_buffer(SSL *s); +int ssl3_release_write_buffer(SSL *s); + +/* Macros/functions provided by the SSL3_RECORD component */ + +#define SSL3_RECORD_get_type(r) ((r)->type) +#define SSL3_RECORD_set_type(r, t) ((r)->type = (t)) +#define SSL3_RECORD_set_rec_version(r, v) ((r)->rec_version = (v)) +#define SSL3_RECORD_get_length(r) ((r)->length) +#define SSL3_RECORD_set_length(r, l) ((r)->length = (l)) +#define SSL3_RECORD_add_length(r, l) ((r)->length += (l)) +#define SSL3_RECORD_sub_length(r, l) ((r)->length -= (l)) +#define SSL3_RECORD_get_data(r) ((r)->data) +#define SSL3_RECORD_set_data(r, d) ((r)->data = (d)) +#define SSL3_RECORD_get_input(r) ((r)->input) +#define SSL3_RECORD_set_input(r, i) ((r)->input = (i)) +#define SSL3_RECORD_reset_input(r) ((r)->input = (r)->data) +#define SSL3_RECORD_get_seq_num(r) ((r)->seq_num) +#define SSL3_RECORD_get_off(r) ((r)->off) +#define SSL3_RECORD_set_off(r, o) ((r)->off = (o)) +#define SSL3_RECORD_add_off(r, o) ((r)->off += (o)) +#define SSL3_RECORD_get_epoch(r) ((r)->epoch) +#define SSL3_RECORD_is_sslv2_record(r) \ + ((r)->rec_version == SSL2_VERSION) +#define SSL3_RECORD_is_read(r) ((r)->read) +#define SSL3_RECORD_set_read(r) ((r)->read = 1) + +void SSL3_RECORD_clear(SSL3_RECORD *r, size_t); +void SSL3_RECORD_release(SSL3_RECORD *r, size_t num_recs); +void SSL3_RECORD_set_seq_num(SSL3_RECORD *r, const unsigned char *seq_num); +int ssl3_get_record(SSL *s); +__owur int ssl3_do_compress(SSL *ssl, SSL3_RECORD *wr); +__owur int ssl3_do_uncompress(SSL *ssl, SSL3_RECORD *rr); +int ssl3_cbc_copy_mac(unsigned char *out, + const SSL3_RECORD *rec, size_t md_size); +__owur int ssl3_cbc_remove_padding(SSL3_RECORD *rec, + size_t block_size, size_t mac_size); +__owur int tls1_cbc_remove_padding(const SSL *s, + SSL3_RECORD *rec, + size_t block_size, size_t mac_size); +int dtls1_process_record(SSL *s, DTLS1_BITMAP *bitmap); +__owur int dtls1_get_record(SSL *s); +int early_data_count_ok(SSL *s, size_t length, size_t overhead, int send); diff --git a/contrib/libs/openssl/ssl/record/ssl3_buffer.c b/contrib/libs/openssl/ssl/record/ssl3_buffer.c index 306a8468bb..b9ba25e0c3 100644 --- a/contrib/libs/openssl/ssl/record/ssl3_buffer.c +++ b/contrib/libs/openssl/ssl/record/ssl3_buffer.c @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#include "../ssl_local.h" -#include "record_local.h" +#include "../ssl_local.h" +#include "record_local.h" void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, size_t n) { diff --git a/contrib/libs/openssl/ssl/record/ssl3_record.c b/contrib/libs/openssl/ssl/record/ssl3_record.c index 06f88c71b5..e6a8bbd710 100644 --- a/contrib/libs/openssl/ssl/record/ssl3_record.c +++ b/contrib/libs/openssl/ssl/record/ssl3_record.c @@ -7,10 +7,10 @@ * https://www.openssl.org/source/license.html */ -#include "../ssl_local.h" -#include "internal/constant_time.h" +#include "../ssl_local.h" +#include "internal/constant_time.h" #include <openssl/rand.h> -#include "record_local.h" +#include "record_local.h" #include "internal/cryptlib.h" static const unsigned char ssl3_pad_1[48] = { @@ -559,7 +559,7 @@ int ssl3_get_record(SSL *s) RECORD_LAYER_reset_read_sequence(&s->rlayer); return 1; } - SSLfatal(s, SSL_AD_BAD_RECORD_MAC, SSL_F_SSL3_GET_RECORD, + SSLfatal(s, SSL_AD_BAD_RECORD_MAC, SSL_F_SSL3_GET_RECORD, SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); return -1; } @@ -837,7 +837,7 @@ int ssl3_do_compress(SSL *ssl, SSL3_RECORD *wr) * SSLfatal() for internal errors, but not otherwise. * * Returns: - * 0: (in non-constant time) if the record is publicly invalid (i.e. too + * 0: (in non-constant time) if the record is publicly invalid (i.e. too * short etc). * 1: if the record's padding is valid / the encryption was successful. * -1: if the record's padding is invalid or, if sending, an internal error @@ -928,7 +928,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int sending) * internal errors, but not otherwise. * * Returns: - * 0: (in non-constant time) if the record is publicly invalid (i.e. too + * 0: (in non-constant time) if the record is publicly invalid (i.e. too * short etc). * 1: if the record's padding is valid / the encryption was successful. * -1: if the record's padding/AEAD-authenticator is invalid or, if sending, @@ -1075,7 +1075,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int sending) } else if ((bs != 1) && sending) { padnum = bs - (reclen[ctr] % bs); - /* Add weird padding of up to 256 bytes */ + /* Add weird padding of up to 256 bytes */ if (padnum > MAX_PADDING) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS1_ENC, @@ -1610,7 +1610,7 @@ int dtls1_process_record(SSL *s, DTLS1_BITMAP *bitmap) int imac_size; size_t mac_size; unsigned char md[EVP_MAX_MD_SIZE]; - size_t max_plain_length = SSL3_RT_MAX_PLAIN_LENGTH; + size_t max_plain_length = SSL3_RT_MAX_PLAIN_LENGTH; rr = RECORD_LAYER_get_rrec(&s->rlayer); sess = s->session; @@ -1670,7 +1670,7 @@ int dtls1_process_record(SSL *s, DTLS1_BITMAP *bitmap) enc_err = s->method->ssl3_enc->enc(s, rr, 1, 0); /*- * enc_err is: - * 0: (in non-constant time) if the record is publicly invalid. + * 0: (in non-constant time) if the record is publicly invalid. * 1: if the padding is valid * -1: if the padding is invalid */ @@ -1783,12 +1783,12 @@ int dtls1_process_record(SSL *s, DTLS1_BITMAP *bitmap) } } - /* use current Max Fragment Length setting if applicable */ - if (s->session != NULL && USE_MAX_FRAGMENT_LENGTH_EXT(s->session)) - max_plain_length = GET_MAX_FRAGMENT_LENGTH(s->session); - - /* send overflow if the plaintext is too long now it has passed MAC */ - if (rr->length > max_plain_length) { + /* use current Max Fragment Length setting if applicable */ + if (s->session != NULL && USE_MAX_FRAGMENT_LENGTH_EXT(s->session)) + max_plain_length = GET_MAX_FRAGMENT_LENGTH(s->session); + + /* send overflow if the plaintext is too long now it has passed MAC */ + if (rr->length > max_plain_length) { SSLfatal(s, SSL_AD_RECORD_OVERFLOW, SSL_F_DTLS1_PROCESS_RECORD, SSL_R_DATA_LENGTH_TOO_LONG); return 0; @@ -1932,7 +1932,7 @@ int dtls1_get_record(SSL *s) /* If received packet overflows own-client Max Fragment Length setting */ if (s->session != NULL && USE_MAX_FRAGMENT_LENGTH_EXT(s->session) - && rr->length > GET_MAX_FRAGMENT_LENGTH(s->session) + SSL3_RT_MAX_ENCRYPTED_OVERHEAD) { + && rr->length > GET_MAX_FRAGMENT_LENGTH(s->session) + SSL3_RT_MAX_ENCRYPTED_OVERHEAD) { /* record too long, silently discard it */ rr->length = 0; rr->read = 1; diff --git a/contrib/libs/openssl/ssl/record/ssl3_record_tls13.c b/contrib/libs/openssl/ssl/record/ssl3_record_tls13.c index 0a998cf7ee..ab50e37624 100644 --- a/contrib/libs/openssl/ssl/record/ssl3_record_tls13.c +++ b/contrib/libs/openssl/ssl/record/ssl3_record_tls13.c @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#include "../ssl_local.h" -#include "record_local.h" +#include "../ssl_local.h" +#include "record_local.h" #include "internal/cryptlib.h" /*- @@ -16,7 +16,7 @@ * internal errors, but not otherwise. * * Returns: - * 0: (in non-constant time) if the record is publicly invalid (i.e. too + * 0: (in non-constant time) if the record is publicly invalid (i.e. too * short etc). * 1: if the record encryption was successful. * -1: if the record's AEAD-authenticator is invalid or, if sending, diff --git a/contrib/libs/openssl/ssl/s3_cbc.c b/contrib/libs/openssl/ssl/s3_cbc.c index b7f4606577..aa7d63f84a 100644 --- a/contrib/libs/openssl/ssl/s3_cbc.c +++ b/contrib/libs/openssl/ssl/s3_cbc.c @@ -7,8 +7,8 @@ * https://www.openssl.org/source/license.html */ -#include "internal/constant_time.h" -#include "ssl_local.h" +#include "internal/constant_time.h" +#include "ssl_local.h" #include "internal/cryptlib.h" #include <openssl/md5.h> diff --git a/contrib/libs/openssl/ssl/s3_enc.c b/contrib/libs/openssl/ssl/s3_enc.c index 9bd8b17abf..8a89f512fe 100644 --- a/contrib/libs/openssl/ssl/s3_enc.c +++ b/contrib/libs/openssl/ssl/s3_enc.c @@ -9,7 +9,7 @@ */ #include <stdio.h> -#include "ssl_local.h" +#include "ssl_local.h" #include <openssl/evp.h> #include <openssl/md5.h> #include "internal/cryptlib.h" diff --git a/contrib/libs/openssl/ssl/s3_lib.c b/contrib/libs/openssl/ssl/s3_lib.c index a8f28edda8..b256a4b935 100644 --- a/contrib/libs/openssl/ssl/s3_lib.c +++ b/contrib/libs/openssl/ssl/s3_lib.c @@ -12,7 +12,7 @@ #include <stdio.h> #include <openssl/objects.h> #include "internal/nelem.h" -#include "ssl_local.h" +#include "ssl_local.h" #include <openssl/md5.h> #include <openssl/dh.h> #include <openssl/rand.h> @@ -4631,7 +4631,7 @@ int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen, s->s3->tmp.psk = NULL; s->s3->tmp.psklen = 0; if (!s->method->ssl3_enc->generate_master_secret(s, - s->session->master_key, pskpms, pskpmslen, + s->session->master_key, pskpms, pskpmslen, &s->session->master_key_length)) { OPENSSL_clear_free(pskpms, pskpmslen); /* SSLfatal() already called */ diff --git a/contrib/libs/openssl/ssl/s3_msg.c b/contrib/libs/openssl/ssl/s3_msg.c index 23c55e63f9..707e962d73 100644 --- a/contrib/libs/openssl/ssl/s3_msg.c +++ b/contrib/libs/openssl/ssl/s3_msg.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "ssl_local.h" +#include "ssl_local.h" int ssl3_do_change_cipher_spec(SSL *s) { diff --git a/contrib/libs/openssl/ssl/ssl_asn1.c b/contrib/libs/openssl/ssl/ssl_asn1.c index f365a39f88..799fee771b 100644 --- a/contrib/libs/openssl/ssl/ssl_asn1.c +++ b/contrib/libs/openssl/ssl/ssl_asn1.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <stdlib.h> -#include "ssl_local.h" +#include "ssl_local.h" #include <openssl/asn1t.h> #include <openssl/x509.h> diff --git a/contrib/libs/openssl/ssl/ssl_cert.c b/contrib/libs/openssl/ssl/ssl_cert.c index b695b64573..a592e3382f 100644 --- a/contrib/libs/openssl/ssl/ssl_cert.c +++ b/contrib/libs/openssl/ssl/ssl_cert.c @@ -20,7 +20,7 @@ #include <openssl/bn.h> #include <openssl/crypto.h> #include "internal/refcount.h" -#include "ssl_local.h" +#include "ssl_local.h" #include "ssl_cert_table.h" #include "internal/thread_once.h" diff --git a/contrib/libs/openssl/ssl/ssl_ciph.c b/contrib/libs/openssl/ssl/ssl_ciph.c index c04a879f15..735a483c64 100644 --- a/contrib/libs/openssl/ssl/ssl_ciph.c +++ b/contrib/libs/openssl/ssl/ssl_ciph.c @@ -17,7 +17,7 @@ #include <openssl/crypto.h> #include <openssl/conf.h> #include "internal/nelem.h" -#include "ssl_local.h" +#include "ssl_local.h" #include "internal/thread_once.h" #include "internal/cryptlib.h" @@ -92,7 +92,7 @@ static CRYPTO_ONCE ssl_load_builtin_comp_once = CRYPTO_ONCE_STATIC_INIT; /* * Constant SSL_MAX_DIGEST equal to size of digests array should be defined - * in the ssl_local.h + * in the ssl_local.h */ #define SSL_MD_NUM_IDX SSL_MAX_DIGEST diff --git a/contrib/libs/openssl/ssl/ssl_conf.c b/contrib/libs/openssl/ssl/ssl_conf.c index 175371ff3d..0a3fef7c8c 100644 --- a/contrib/libs/openssl/ssl/ssl_conf.c +++ b/contrib/libs/openssl/ssl/ssl_conf.c @@ -8,7 +8,7 @@ */ #include <stdio.h> -#include "ssl_local.h" +#include "ssl_local.h" #include <openssl/conf.h> #include <openssl/objects.h> #include <openssl/dh.h> diff --git a/contrib/libs/openssl/ssl/ssl_init.c b/contrib/libs/openssl/ssl/ssl_init.c index 2adcac2fa4..d083d95970 100644 --- a/contrib/libs/openssl/ssl/ssl_init.c +++ b/contrib/libs/openssl/ssl/ssl_init.c @@ -12,7 +12,7 @@ #include "internal/err.h" #include <openssl/crypto.h> #include <openssl/evp.h> -#include "ssl_local.h" +#include "ssl_local.h" #include "internal/thread_once.h" static int stopped; diff --git a/contrib/libs/openssl/ssl/ssl_lib.c b/contrib/libs/openssl/ssl/ssl_lib.c index 02ea466263..ffd0a0bc6d 100644 --- a/contrib/libs/openssl/ssl/ssl_lib.c +++ b/contrib/libs/openssl/ssl/ssl_lib.c @@ -10,7 +10,7 @@ */ #include <stdio.h> -#include "ssl_local.h" +#include "ssl_local.h" #include <openssl/objects.h> #include <openssl/x509v3.h> #include <openssl/rand.h> @@ -2636,85 +2636,85 @@ char *SSL_get_shared_ciphers(const SSL *s, char *buf, int size) return buf; } -/** - * Return the requested servername (SNI) value. Note that the behaviour varies - * depending on: - * - whether this is called by the client or the server, - * - if we are before or during/after the handshake, - * - if a resumption or normal handshake is being attempted/has occurred - * - whether we have negotiated TLSv1.2 (or below) or TLSv1.3 - * - * Note that only the host_name type is defined (RFC 3546). +/** + * Return the requested servername (SNI) value. Note that the behaviour varies + * depending on: + * - whether this is called by the client or the server, + * - if we are before or during/after the handshake, + * - if a resumption or normal handshake is being attempted/has occurred + * - whether we have negotiated TLSv1.2 (or below) or TLSv1.3 + * + * Note that only the host_name type is defined (RFC 3546). */ const char *SSL_get_servername(const SSL *s, const int type) { - /* - * If we don't know if we are the client or the server yet then we assume - * client. - */ - int server = s->handshake_func == NULL ? 0 : s->server; + /* + * If we don't know if we are the client or the server yet then we assume + * client. + */ + int server = s->handshake_func == NULL ? 0 : s->server; if (type != TLSEXT_NAMETYPE_host_name) return NULL; - if (server) { - /** - * Server side - * In TLSv1.3 on the server SNI is not associated with the session - * but in TLSv1.2 or below it is. - * - * Before the handshake: - * - return NULL - * - * During/after the handshake (TLSv1.2 or below resumption occurred): - * - If a servername was accepted by the server in the original - * handshake then it will return that servername, or NULL otherwise. - * - * During/after the handshake (TLSv1.2 or below resumption did not occur): - * - The function will return the servername requested by the client in - * this handshake or NULL if none was requested. - */ - if (s->hit && !SSL_IS_TLS13(s)) - return s->session->ext.hostname; - } else { - /** - * Client side - * - * Before the handshake: - * - If a servername has been set via a call to - * SSL_set_tlsext_host_name() then it will return that servername - * - If one has not been set, but a TLSv1.2 resumption is being - * attempted and the session from the original handshake had a - * servername accepted by the server then it will return that - * servername - * - Otherwise it returns NULL - * - * During/after the handshake (TLSv1.2 or below resumption occurred): + if (server) { + /** + * Server side + * In TLSv1.3 on the server SNI is not associated with the session + * but in TLSv1.2 or below it is. + * + * Before the handshake: + * - return NULL + * + * During/after the handshake (TLSv1.2 or below resumption occurred): + * - If a servername was accepted by the server in the original + * handshake then it will return that servername, or NULL otherwise. + * + * During/after the handshake (TLSv1.2 or below resumption did not occur): + * - The function will return the servername requested by the client in + * this handshake or NULL if none was requested. + */ + if (s->hit && !SSL_IS_TLS13(s)) + return s->session->ext.hostname; + } else { + /** + * Client side + * + * Before the handshake: + * - If a servername has been set via a call to + * SSL_set_tlsext_host_name() then it will return that servername + * - If one has not been set, but a TLSv1.2 resumption is being + * attempted and the session from the original handshake had a + * servername accepted by the server then it will return that + * servername + * - Otherwise it returns NULL + * + * During/after the handshake (TLSv1.2 or below resumption occurred): * - If the session from the original handshake had a servername accepted - * by the server then it will return that servername. - * - Otherwise it returns the servername set via - * SSL_set_tlsext_host_name() (or NULL if it was not called). - * - * During/after the handshake (TLSv1.2 or below resumption did not occur): - * - It will return the servername set via SSL_set_tlsext_host_name() - * (or NULL if it was not called). - */ - if (SSL_in_before(s)) { - if (s->ext.hostname == NULL - && s->session != NULL - && s->session->ssl_version != TLS1_3_VERSION) - return s->session->ext.hostname; - } else { - if (!SSL_IS_TLS13(s) && s->hit && s->session->ext.hostname != NULL) - return s->session->ext.hostname; - } - } - + * by the server then it will return that servername. + * - Otherwise it returns the servername set via + * SSL_set_tlsext_host_name() (or NULL if it was not called). + * + * During/after the handshake (TLSv1.2 or below resumption did not occur): + * - It will return the servername set via SSL_set_tlsext_host_name() + * (or NULL if it was not called). + */ + if (SSL_in_before(s)) { + if (s->ext.hostname == NULL + && s->session != NULL + && s->session->ssl_version != TLS1_3_VERSION) + return s->session->ext.hostname; + } else { + if (!SSL_IS_TLS13(s) && s->hit && s->session->ext.hostname != NULL) + return s->session->ext.hostname; + } + } + return s->ext.hostname; } int SSL_get_servername_type(const SSL *s) { - if (SSL_get_servername(s, TLSEXT_NAMETYPE_host_name) != NULL) + if (SSL_get_servername(s, TLSEXT_NAMETYPE_host_name) != NULL) return TLSEXT_NAMETYPE_host_name; return -1; } diff --git a/contrib/libs/openssl/ssl/ssl_local.h b/contrib/libs/openssl/ssl/ssl_local.h index 97364f4d38..f92472117a 100644 --- a/contrib/libs/openssl/ssl/ssl_local.h +++ b/contrib/libs/openssl/ssl/ssl_local.h @@ -1,2671 +1,2671 @@ -/* +/* * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * Copyright 2005 Nokia. All rights reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef OSSL_SSL_LOCAL_H -# define OSSL_SSL_LOCAL_H - -# include "e_os.h" /* struct timeval for DTLS */ -# include <stdlib.h> -# include <time.h> -# include <string.h> -# include <errno.h> - -# include <openssl/buffer.h> -# include <openssl/comp.h> -# include <openssl/bio.h> -# include <openssl/rsa.h> -# include <openssl/dsa.h> -# include <openssl/err.h> -# include <openssl/ssl.h> -# include <openssl/async.h> -# include <openssl/symhacks.h> -# include <openssl/ct.h> -# include "record/record.h" -# include "statem/statem.h" -# include "packet_local.h" -# include "internal/dane.h" -# include "internal/refcount.h" -# include "internal/tsan_assist.h" - -# ifdef OPENSSL_BUILD_SHLIBSSL -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -# endif - -# define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \ - l|=(((unsigned long)(*((c)++)))<< 8), \ - l|=(((unsigned long)(*((c)++)))<<16), \ - l|=(((unsigned long)(*((c)++)))<<24)) - -/* NOTE - c is not incremented as per c2l */ -# define c2ln(c,l1,l2,n) { \ - c+=n; \ - l1=l2=0; \ - switch (n) { \ - case 8: l2 =((unsigned long)(*(--(c))))<<24; \ - case 7: l2|=((unsigned long)(*(--(c))))<<16; \ - case 6: l2|=((unsigned long)(*(--(c))))<< 8; \ - case 5: l2|=((unsigned long)(*(--(c)))); \ - case 4: l1 =((unsigned long)(*(--(c))))<<24; \ - case 3: l1|=((unsigned long)(*(--(c))))<<16; \ - case 2: l1|=((unsigned long)(*(--(c))))<< 8; \ - case 1: l1|=((unsigned long)(*(--(c)))); \ - } \ - } - -# define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24)&0xff)) - -# define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24, \ - l|=((unsigned long)(*((c)++)))<<16, \ - l|=((unsigned long)(*((c)++)))<< 8, \ - l|=((unsigned long)(*((c)++)))) - -# define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \ - l|=((uint64_t)(*((c)++)))<<48, \ - l|=((uint64_t)(*((c)++)))<<40, \ - l|=((uint64_t)(*((c)++)))<<32, \ - l|=((uint64_t)(*((c)++)))<<24, \ - l|=((uint64_t)(*((c)++)))<<16, \ - l|=((uint64_t)(*((c)++)))<< 8, \ - l|=((uint64_t)(*((c)++)))) - - -# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -# define l2n6(l,c) (*((c)++)=(unsigned char)(((l)>>40)&0xff), \ - *((c)++)=(unsigned char)(((l)>>32)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -# define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \ - *((c)++)=(unsigned char)(((l)>>48)&0xff), \ - *((c)++)=(unsigned char)(((l)>>40)&0xff), \ - *((c)++)=(unsigned char)(((l)>>32)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l) )&0xff)) - -/* NOTE - c is not incremented as per l2c */ -# define l2cn(l1,l2,c,n) { \ - c+=n; \ - switch (n) { \ - case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ - case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ - case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ - case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ - case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ - case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ - case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ - case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ - } \ - } - -# define n2s(c,s) ((s=(((unsigned int)((c)[0]))<< 8)| \ - (((unsigned int)((c)[1])) )),(c)+=2) -# define s2n(s,c) (((c)[0]=(unsigned char)(((s)>> 8)&0xff), \ - (c)[1]=(unsigned char)(((s) )&0xff)),(c)+=2) - -# define n2l3(c,l) ((l =(((unsigned long)((c)[0]))<<16)| \ - (((unsigned long)((c)[1]))<< 8)| \ - (((unsigned long)((c)[2])) )),(c)+=3) - -# define l2n3(l,c) (((c)[0]=(unsigned char)(((l)>>16)&0xff), \ - (c)[1]=(unsigned char)(((l)>> 8)&0xff), \ - (c)[2]=(unsigned char)(((l) )&0xff)),(c)+=3) - -/* - * DTLS version numbers are strange because they're inverted. Except for - * DTLS1_BAD_VER, which should be considered "lower" than the rest. - */ -# define dtls_ver_ordinal(v1) (((v1) == DTLS1_BAD_VER) ? 0xff00 : (v1)) -# define DTLS_VERSION_GT(v1, v2) (dtls_ver_ordinal(v1) < dtls_ver_ordinal(v2)) -# define DTLS_VERSION_GE(v1, v2) (dtls_ver_ordinal(v1) <= dtls_ver_ordinal(v2)) -# define DTLS_VERSION_LT(v1, v2) (dtls_ver_ordinal(v1) > dtls_ver_ordinal(v2)) -# define DTLS_VERSION_LE(v1, v2) (dtls_ver_ordinal(v1) >= dtls_ver_ordinal(v2)) - - -/* - * Define the Bitmasks for SSL_CIPHER.algorithms. - * This bits are used packed as dense as possible. If new methods/ciphers - * etc will be added, the bits a likely to change, so this information - * is for internal library use only, even though SSL_CIPHER.algorithms - * can be publicly accessed. - * Use the according functions for cipher management instead. - * - * The bit mask handling in the selection and sorting scheme in - * ssl_create_cipher_list() has only limited capabilities, reflecting - * that the different entities within are mutually exclusive: - * ONLY ONE BIT PER MASK CAN BE SET AT A TIME. - */ - -/* Bits for algorithm_mkey (key exchange algorithm) */ -/* RSA key exchange */ -# define SSL_kRSA 0x00000001U -/* tmp DH key no DH cert */ -# define SSL_kDHE 0x00000002U -/* synonym */ -# define SSL_kEDH SSL_kDHE -/* ephemeral ECDH */ -# define SSL_kECDHE 0x00000004U -/* synonym */ -# define SSL_kEECDH SSL_kECDHE -/* PSK */ -# define SSL_kPSK 0x00000008U -/* GOST key exchange */ -# define SSL_kGOST 0x00000010U -/* SRP */ -# define SSL_kSRP 0x00000020U - -# define SSL_kRSAPSK 0x00000040U -# define SSL_kECDHEPSK 0x00000080U -# define SSL_kDHEPSK 0x00000100U - -/* all PSK */ - -# define SSL_PSK (SSL_kPSK | SSL_kRSAPSK | SSL_kECDHEPSK | SSL_kDHEPSK) - -/* Any appropriate key exchange algorithm (for TLS 1.3 ciphersuites) */ -# define SSL_kANY 0x00000000U - -/* Bits for algorithm_auth (server authentication) */ -/* RSA auth */ -# define SSL_aRSA 0x00000001U -/* DSS auth */ -# define SSL_aDSS 0x00000002U -/* no auth (i.e. use ADH or AECDH) */ -# define SSL_aNULL 0x00000004U -/* ECDSA auth*/ -# define SSL_aECDSA 0x00000008U -/* PSK auth */ -# define SSL_aPSK 0x00000010U -/* GOST R 34.10-2001 signature auth */ -# define SSL_aGOST01 0x00000020U -/* SRP auth */ -# define SSL_aSRP 0x00000040U -/* GOST R 34.10-2012 signature auth */ -# define SSL_aGOST12 0x00000080U -/* Any appropriate signature auth (for TLS 1.3 ciphersuites) */ -# define SSL_aANY 0x00000000U -/* All bits requiring a certificate */ -#define SSL_aCERT \ - (SSL_aRSA | SSL_aDSS | SSL_aECDSA | SSL_aGOST01 | SSL_aGOST12) - -/* Bits for algorithm_enc (symmetric encryption) */ -# define SSL_DES 0x00000001U -# define SSL_3DES 0x00000002U -# define SSL_RC4 0x00000004U -# define SSL_RC2 0x00000008U -# define SSL_IDEA 0x00000010U -# define SSL_eNULL 0x00000020U -# define SSL_AES128 0x00000040U -# define SSL_AES256 0x00000080U -# define SSL_CAMELLIA128 0x00000100U -# define SSL_CAMELLIA256 0x00000200U -# define SSL_eGOST2814789CNT 0x00000400U -# define SSL_SEED 0x00000800U -# define SSL_AES128GCM 0x00001000U -# define SSL_AES256GCM 0x00002000U -# define SSL_AES128CCM 0x00004000U -# define SSL_AES256CCM 0x00008000U -# define SSL_AES128CCM8 0x00010000U -# define SSL_AES256CCM8 0x00020000U -# define SSL_eGOST2814789CNT12 0x00040000U -# define SSL_CHACHA20POLY1305 0x00080000U -# define SSL_ARIA128GCM 0x00100000U -# define SSL_ARIA256GCM 0x00200000U - -# define SSL_AESGCM (SSL_AES128GCM | SSL_AES256GCM) -# define SSL_AESCCM (SSL_AES128CCM | SSL_AES256CCM | SSL_AES128CCM8 | SSL_AES256CCM8) -# define SSL_AES (SSL_AES128|SSL_AES256|SSL_AESGCM|SSL_AESCCM) -# define SSL_CAMELLIA (SSL_CAMELLIA128|SSL_CAMELLIA256) -# define SSL_CHACHA20 (SSL_CHACHA20POLY1305) -# define SSL_ARIAGCM (SSL_ARIA128GCM | SSL_ARIA256GCM) -# define SSL_ARIA (SSL_ARIAGCM) - -/* Bits for algorithm_mac (symmetric authentication) */ - -# define SSL_MD5 0x00000001U -# define SSL_SHA1 0x00000002U -# define SSL_GOST94 0x00000004U -# define SSL_GOST89MAC 0x00000008U -# define SSL_SHA256 0x00000010U -# define SSL_SHA384 0x00000020U -/* Not a real MAC, just an indication it is part of cipher */ -# define SSL_AEAD 0x00000040U -# define SSL_GOST12_256 0x00000080U -# define SSL_GOST89MAC12 0x00000100U -# define SSL_GOST12_512 0x00000200U - -/* - * When adding new digest in the ssl_ciph.c and increment SSL_MD_NUM_IDX make - * sure to update this constant too - */ - -# define SSL_MD_MD5_IDX 0 -# define SSL_MD_SHA1_IDX 1 -# define SSL_MD_GOST94_IDX 2 -# define SSL_MD_GOST89MAC_IDX 3 -# define SSL_MD_SHA256_IDX 4 -# define SSL_MD_SHA384_IDX 5 -# define SSL_MD_GOST12_256_IDX 6 -# define SSL_MD_GOST89MAC12_IDX 7 -# define SSL_MD_GOST12_512_IDX 8 -# define SSL_MD_MD5_SHA1_IDX 9 -# define SSL_MD_SHA224_IDX 10 -# define SSL_MD_SHA512_IDX 11 -# define SSL_MAX_DIGEST 12 - -/* Bits for algorithm2 (handshake digests and other extra flags) */ - -/* Bits 0-7 are handshake MAC */ -# define SSL_HANDSHAKE_MAC_MASK 0xFF -# define SSL_HANDSHAKE_MAC_MD5_SHA1 SSL_MD_MD5_SHA1_IDX -# define SSL_HANDSHAKE_MAC_SHA256 SSL_MD_SHA256_IDX -# define SSL_HANDSHAKE_MAC_SHA384 SSL_MD_SHA384_IDX -# define SSL_HANDSHAKE_MAC_GOST94 SSL_MD_GOST94_IDX -# define SSL_HANDSHAKE_MAC_GOST12_256 SSL_MD_GOST12_256_IDX -# define SSL_HANDSHAKE_MAC_GOST12_512 SSL_MD_GOST12_512_IDX -# define SSL_HANDSHAKE_MAC_DEFAULT SSL_HANDSHAKE_MAC_MD5_SHA1 - -/* Bits 8-15 bits are PRF */ -# define TLS1_PRF_DGST_SHIFT 8 -# define TLS1_PRF_SHA1_MD5 (SSL_MD_MD5_SHA1_IDX << TLS1_PRF_DGST_SHIFT) -# define TLS1_PRF_SHA256 (SSL_MD_SHA256_IDX << TLS1_PRF_DGST_SHIFT) -# define TLS1_PRF_SHA384 (SSL_MD_SHA384_IDX << TLS1_PRF_DGST_SHIFT) -# define TLS1_PRF_GOST94 (SSL_MD_GOST94_IDX << TLS1_PRF_DGST_SHIFT) -# define TLS1_PRF_GOST12_256 (SSL_MD_GOST12_256_IDX << TLS1_PRF_DGST_SHIFT) -# define TLS1_PRF_GOST12_512 (SSL_MD_GOST12_512_IDX << TLS1_PRF_DGST_SHIFT) -# define TLS1_PRF (SSL_MD_MD5_SHA1_IDX << TLS1_PRF_DGST_SHIFT) - -/* - * Stream MAC for GOST ciphersuites from cryptopro draft (currently this also - * goes into algorithm2) - */ -# define TLS1_STREAM_MAC 0x10000 - -# define SSL_STRONG_MASK 0x0000001FU -# define SSL_DEFAULT_MASK 0X00000020U - -# define SSL_STRONG_NONE 0x00000001U -# define SSL_LOW 0x00000002U -# define SSL_MEDIUM 0x00000004U -# define SSL_HIGH 0x00000008U -# define SSL_FIPS 0x00000010U -# define SSL_NOT_DEFAULT 0x00000020U - -/* we have used 0000003f - 26 bits left to go */ - -/* Flag used on OpenSSL ciphersuite ids to indicate they are for SSLv3+ */ -# define SSL3_CK_CIPHERSUITE_FLAG 0x03000000 - -/* Check if an SSL structure is using DTLS */ -# define SSL_IS_DTLS(s) (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS) - -/* Check if we are using TLSv1.3 */ -# define SSL_IS_TLS13(s) (!SSL_IS_DTLS(s) \ - && (s)->method->version >= TLS1_3_VERSION \ - && (s)->method->version != TLS_ANY_VERSION) - -# define SSL_TREAT_AS_TLS13(s) \ - (SSL_IS_TLS13(s) || (s)->early_data_state == SSL_EARLY_DATA_CONNECTING \ - || (s)->early_data_state == SSL_EARLY_DATA_CONNECT_RETRY \ - || (s)->early_data_state == SSL_EARLY_DATA_WRITING \ - || (s)->early_data_state == SSL_EARLY_DATA_WRITE_RETRY \ - || (s)->hello_retry_request == SSL_HRR_PENDING) - -# define SSL_IS_FIRST_HANDSHAKE(S) ((s)->s3->tmp.finish_md_len == 0 \ - || (s)->s3->tmp.peer_finish_md_len == 0) - -/* See if we need explicit IV */ -# define SSL_USE_EXPLICIT_IV(s) \ - (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_EXPLICIT_IV) -/* - * See if we use signature algorithms extension and signature algorithm - * before signatures. - */ -# define SSL_USE_SIGALGS(s) \ - (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SIGALGS) -/* - * Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2: may - * apply to others in future. - */ -# define SSL_USE_TLS1_2_CIPHERS(s) \ - (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_TLS1_2_CIPHERS) -/* - * Determine if a client can use TLS 1.2 ciphersuites: can't rely on method - * flags because it may not be set to correct version yet. - */ -# define SSL_CLIENT_USE_TLS1_2_CIPHERS(s) \ - ((!SSL_IS_DTLS(s) && s->client_version >= TLS1_2_VERSION) || \ - (SSL_IS_DTLS(s) && DTLS_VERSION_GE(s->client_version, DTLS1_2_VERSION))) -/* - * Determine if a client should send signature algorithms extension: - * as with TLS1.2 cipher we can't rely on method flags. - */ -# define SSL_CLIENT_USE_SIGALGS(s) \ - SSL_CLIENT_USE_TLS1_2_CIPHERS(s) - -# define IS_MAX_FRAGMENT_LENGTH_EXT_VALID(value) \ - (((value) >= TLSEXT_max_fragment_length_512) && \ - ((value) <= TLSEXT_max_fragment_length_4096)) -# define USE_MAX_FRAGMENT_LENGTH_EXT(session) \ - IS_MAX_FRAGMENT_LENGTH_EXT_VALID(session->ext.max_fragment_len_mode) -# define GET_MAX_FRAGMENT_LENGTH(session) \ - (512U << (session->ext.max_fragment_len_mode - 1)) - -# define SSL_READ_ETM(s) (s->s3->flags & TLS1_FLAGS_ENCRYPT_THEN_MAC_READ) -# define SSL_WRITE_ETM(s) (s->s3->flags & TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE) - -/* Mostly for SSLv3 */ -# define SSL_PKEY_RSA 0 -# define SSL_PKEY_RSA_PSS_SIGN 1 -# define SSL_PKEY_DSA_SIGN 2 -# define SSL_PKEY_ECC 3 -# define SSL_PKEY_GOST01 4 -# define SSL_PKEY_GOST12_256 5 -# define SSL_PKEY_GOST12_512 6 -# define SSL_PKEY_ED25519 7 -# define SSL_PKEY_ED448 8 -# define SSL_PKEY_NUM 9 - -/*- - * SSL_kRSA <- RSA_ENC - * SSL_kDH <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN) - * SSL_kDHE <- RSA_ENC | RSA_SIGN | DSA_SIGN - * SSL_aRSA <- RSA_ENC | RSA_SIGN - * SSL_aDSS <- DSA_SIGN - */ - -/*- -#define CERT_INVALID 0 -#define CERT_PUBLIC_KEY 1 -#define CERT_PRIVATE_KEY 2 -*/ - -/* Post-Handshake Authentication state */ -typedef enum { - SSL_PHA_NONE = 0, - SSL_PHA_EXT_SENT, /* client-side only: extension sent */ - SSL_PHA_EXT_RECEIVED, /* server-side only: extension received */ - SSL_PHA_REQUEST_PENDING, /* server-side only: request pending */ - SSL_PHA_REQUESTED /* request received by client, or sent by server */ -} SSL_PHA_STATE; - -/* CipherSuite length. SSLv3 and all TLS versions. */ -# define TLS_CIPHER_LEN 2 -/* used to hold info on the particular ciphers used */ -struct ssl_cipher_st { - uint32_t valid; - const char *name; /* text name */ - const char *stdname; /* RFC name */ - uint32_t id; /* id, 4 bytes, first is version */ - /* - * changed in 1.0.0: these four used to be portions of a single value - * 'algorithms' - */ - uint32_t algorithm_mkey; /* key exchange algorithm */ - uint32_t algorithm_auth; /* server authentication */ - uint32_t algorithm_enc; /* symmetric encryption */ - uint32_t algorithm_mac; /* symmetric authentication */ - int min_tls; /* minimum SSL/TLS protocol version */ - int max_tls; /* maximum SSL/TLS protocol version */ - int min_dtls; /* minimum DTLS protocol version */ - int max_dtls; /* maximum DTLS protocol version */ - uint32_t algo_strength; /* strength and export flags */ - uint32_t algorithm2; /* Extra flags */ - int32_t strength_bits; /* Number of bits really used */ - uint32_t alg_bits; /* Number of bits for algorithm */ -}; - -/* Used to hold SSL/TLS functions */ -struct ssl_method_st { - int version; - unsigned flags; - unsigned long mask; - int (*ssl_new) (SSL *s); - int (*ssl_clear) (SSL *s); - void (*ssl_free) (SSL *s); - int (*ssl_accept) (SSL *s); - int (*ssl_connect) (SSL *s); - int (*ssl_read) (SSL *s, void *buf, size_t len, size_t *readbytes); - int (*ssl_peek) (SSL *s, void *buf, size_t len, size_t *readbytes); - int (*ssl_write) (SSL *s, const void *buf, size_t len, size_t *written); - int (*ssl_shutdown) (SSL *s); - int (*ssl_renegotiate) (SSL *s); - int (*ssl_renegotiate_check) (SSL *s, int); - int (*ssl_read_bytes) (SSL *s, int type, int *recvd_type, - unsigned char *buf, size_t len, int peek, - size_t *readbytes); - int (*ssl_write_bytes) (SSL *s, int type, const void *buf_, size_t len, - size_t *written); - int (*ssl_dispatch_alert) (SSL *s); - long (*ssl_ctrl) (SSL *s, int cmd, long larg, void *parg); - long (*ssl_ctx_ctrl) (SSL_CTX *ctx, int cmd, long larg, void *parg); - const SSL_CIPHER *(*get_cipher_by_char) (const unsigned char *ptr); - int (*put_cipher_by_char) (const SSL_CIPHER *cipher, WPACKET *pkt, - size_t *len); - size_t (*ssl_pending) (const SSL *s); - int (*num_ciphers) (void); - const SSL_CIPHER *(*get_cipher) (unsigned ncipher); - long (*get_timeout) (void); - const struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ - int (*ssl_version) (void); - long (*ssl_callback_ctrl) (SSL *s, int cb_id, void (*fp) (void)); - long (*ssl_ctx_callback_ctrl) (SSL_CTX *s, int cb_id, void (*fp) (void)); -}; - -/* - * Matches the length of PSK_MAX_PSK_LEN. We keep it the same value for - * consistency, even in the event of OPENSSL_NO_PSK being defined. - */ -# define TLS13_MAX_RESUMPTION_PSK_LENGTH 256 - -/*- - * Lets make this into an ASN.1 type structure as follows - * SSL_SESSION_ID ::= SEQUENCE { - * version INTEGER, -- structure version number - * SSLversion INTEGER, -- SSL version number - * Cipher OCTET STRING, -- the 3 byte cipher ID - * Session_ID OCTET STRING, -- the Session ID - * Master_key OCTET STRING, -- the master key - * Key_Arg [ 0 ] IMPLICIT OCTET STRING, -- the optional Key argument - * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time - * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds - * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate - * Session_ID_context [ 4 ] EXPLICIT OCTET STRING, -- the Session ID context - * Verify_result [ 5 ] EXPLICIT INTEGER, -- X509_V_... code for `Peer' - * HostName [ 6 ] EXPLICIT OCTET STRING, -- optional HostName from servername TLS extension - * PSK_identity_hint [ 7 ] EXPLICIT OCTET STRING, -- optional PSK identity hint - * PSK_identity [ 8 ] EXPLICIT OCTET STRING, -- optional PSK identity - * Ticket_lifetime_hint [9] EXPLICIT INTEGER, -- server's lifetime hint for session ticket - * Ticket [10] EXPLICIT OCTET STRING, -- session ticket (clients only) - * Compression_meth [11] EXPLICIT OCTET STRING, -- optional compression method - * SRP_username [ 12 ] EXPLICIT OCTET STRING -- optional SRP username - * flags [ 13 ] EXPLICIT INTEGER -- optional flags - * } - * Look in ssl/ssl_asn1.c for more details - * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). - */ -struct ssl_session_st { - int ssl_version; /* what ssl version session info is being kept - * in here? */ - size_t master_key_length; - - /* TLSv1.3 early_secret used for external PSKs */ - unsigned char early_secret[EVP_MAX_MD_SIZE]; - /* - * For <=TLS1.2 this is the master_key. For TLS1.3 this is the resumption - * PSK - */ - unsigned char master_key[TLS13_MAX_RESUMPTION_PSK_LENGTH]; - /* session_id - valid? */ - size_t session_id_length; - unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; - /* - * this is used to determine whether the session is being reused in the - * appropriate context. It is up to the application to set this, via - * SSL_new - */ - size_t sid_ctx_length; - unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; -# ifndef OPENSSL_NO_PSK - char *psk_identity_hint; - char *psk_identity; -# endif - /* - * Used to indicate that session resumption is not allowed. Applications - * can also set this bit for a new session via not_resumable_session_cb - * to disable session caching and tickets. - */ - int not_resumable; - /* This is the cert and type for the other end. */ - X509 *peer; - /* Certificate chain peer sent. */ - STACK_OF(X509) *peer_chain; - /* - * when app_verify_callback accepts a session where the peer's - * certificate is not ok, we must remember the error for session reuse: - */ - long verify_result; /* only for servers */ - CRYPTO_REF_COUNT references; - long timeout; - long time; - unsigned int compress_meth; /* Need to lookup the method */ - const SSL_CIPHER *cipher; - unsigned long cipher_id; /* when ASN.1 loaded, this needs to be used to - * load the 'cipher' structure */ - CRYPTO_EX_DATA ex_data; /* application specific data */ - /* - * These are used to make removal of session-ids more efficient and to - * implement a maximum cache size. - */ - struct ssl_session_st *prev, *next; - - struct { - char *hostname; - /* RFC4507 info */ - unsigned char *tick; /* Session ticket */ - size_t ticklen; /* Session ticket length */ - /* Session lifetime hint in seconds */ - unsigned long tick_lifetime_hint; - uint32_t tick_age_add; - /* Max number of bytes that can be sent as early data */ - uint32_t max_early_data; - /* The ALPN protocol selected for this session */ - unsigned char *alpn_selected; - size_t alpn_selected_len; - /* - * Maximum Fragment Length as per RFC 4366. - * If this value does not contain RFC 4366 allowed values (1-4) then - * either the Maximum Fragment Length Negotiation failed or was not - * performed at all. - */ - uint8_t max_fragment_len_mode; - } ext; -# ifndef OPENSSL_NO_SRP - char *srp_username; -# endif - unsigned char *ticket_appdata; - size_t ticket_appdata_len; - uint32_t flags; - CRYPTO_RWLOCK *lock; -}; - -/* Extended master secret support */ -# define SSL_SESS_FLAG_EXTMS 0x1 - -# ifndef OPENSSL_NO_SRP - -typedef struct srp_ctx_st { - /* param for all the callbacks */ - void *SRP_cb_arg; - /* set client Hello login callback */ - int (*TLS_ext_srp_username_callback) (SSL *, int *, void *); - /* set SRP N/g param callback for verification */ - int (*SRP_verify_param_callback) (SSL *, void *); - /* set SRP client passwd callback */ - char *(*SRP_give_srp_client_pwd_callback) (SSL *, void *); - char *login; - BIGNUM *N, *g, *s, *B, *A; - BIGNUM *a, *b, *v; - char *info; - int strength; - unsigned long srp_Mask; -} SRP_CTX; - -# endif - -typedef enum { - SSL_EARLY_DATA_NONE = 0, - SSL_EARLY_DATA_CONNECT_RETRY, - SSL_EARLY_DATA_CONNECTING, - SSL_EARLY_DATA_WRITE_RETRY, - SSL_EARLY_DATA_WRITING, - SSL_EARLY_DATA_WRITE_FLUSH, - SSL_EARLY_DATA_UNAUTH_WRITING, - SSL_EARLY_DATA_FINISHED_WRITING, - SSL_EARLY_DATA_ACCEPT_RETRY, - SSL_EARLY_DATA_ACCEPTING, - SSL_EARLY_DATA_READ_RETRY, - SSL_EARLY_DATA_READING, - SSL_EARLY_DATA_FINISHED_READING -} SSL_EARLY_DATA_STATE; - -/* - * We check that the amount of unreadable early data doesn't exceed - * max_early_data. max_early_data is given in plaintext bytes. However if it is - * unreadable then we only know the number of ciphertext bytes. We also don't - * know how much the overhead should be because it depends on the ciphersuite. - * We make a small allowance. We assume 5 records of actual data plus the end - * of early data alert record. Each record has a tag and a content type byte. - * The longest tag length we know of is EVP_GCM_TLS_TAG_LEN. We don't count the - * content of the alert record either which is 2 bytes. - */ -# define EARLY_DATA_CIPHERTEXT_OVERHEAD ((6 * (EVP_GCM_TLS_TAG_LEN + 1)) + 2) - -/* - * The allowance we have between the client's calculated ticket age and our own. - * We allow for 10 seconds (units are in ms). If a ticket is presented and the - * client's age calculation is different by more than this than our own then we - * do not allow that ticket for early_data. - */ -# define TICKET_AGE_ALLOWANCE (10 * 1000) - -#define MAX_COMPRESSIONS_SIZE 255 - -struct ssl_comp_st { - int id; - const char *name; - COMP_METHOD *method; -}; - -typedef struct raw_extension_st { - /* Raw packet data for the extension */ - PACKET data; - /* Set to 1 if the extension is present or 0 otherwise */ - int present; - /* Set to 1 if we have already parsed the extension or 0 otherwise */ - int parsed; - /* The type of this extension, i.e. a TLSEXT_TYPE_* value */ - unsigned int type; - /* Track what order extensions are received in (0-based). */ - size_t received_order; -} RAW_EXTENSION; - -typedef struct { - unsigned int isv2; - unsigned int legacy_version; - unsigned char random[SSL3_RANDOM_SIZE]; - size_t session_id_len; - unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; - size_t dtls_cookie_len; - unsigned char dtls_cookie[DTLS1_COOKIE_LENGTH]; - PACKET ciphersuites; - size_t compressions_len; - unsigned char compressions[MAX_COMPRESSIONS_SIZE]; - PACKET extensions; - size_t pre_proc_exts_len; - RAW_EXTENSION *pre_proc_exts; -} CLIENTHELLO_MSG; - -/* - * Extension index values NOTE: Any updates to these defines should be mirrored - * with equivalent updates to ext_defs in extensions.c - */ -typedef enum tlsext_index_en { - TLSEXT_IDX_renegotiate, - TLSEXT_IDX_server_name, - TLSEXT_IDX_max_fragment_length, - TLSEXT_IDX_srp, - TLSEXT_IDX_ec_point_formats, - TLSEXT_IDX_supported_groups, - TLSEXT_IDX_session_ticket, - TLSEXT_IDX_status_request, - TLSEXT_IDX_next_proto_neg, - TLSEXT_IDX_application_layer_protocol_negotiation, - TLSEXT_IDX_use_srtp, - TLSEXT_IDX_encrypt_then_mac, - TLSEXT_IDX_signed_certificate_timestamp, - TLSEXT_IDX_extended_master_secret, - TLSEXT_IDX_signature_algorithms_cert, - TLSEXT_IDX_post_handshake_auth, - TLSEXT_IDX_signature_algorithms, - TLSEXT_IDX_supported_versions, - TLSEXT_IDX_psk_kex_modes, - TLSEXT_IDX_key_share, - TLSEXT_IDX_cookie, - TLSEXT_IDX_cryptopro_bug, - TLSEXT_IDX_early_data, - TLSEXT_IDX_certificate_authorities, - TLSEXT_IDX_padding, - TLSEXT_IDX_psk, - /* Dummy index - must always be the last entry */ - TLSEXT_IDX_num_builtins -} TLSEXT_INDEX; - -DEFINE_LHASH_OF(SSL_SESSION); -/* Needed in ssl_cert.c */ -DEFINE_LHASH_OF(X509_NAME); - -# define TLSEXT_KEYNAME_LENGTH 16 -# define TLSEXT_TICK_KEY_LENGTH 32 - -typedef struct ssl_ctx_ext_secure_st { - unsigned char tick_hmac_key[TLSEXT_TICK_KEY_LENGTH]; - unsigned char tick_aes_key[TLSEXT_TICK_KEY_LENGTH]; -} SSL_CTX_EXT_SECURE; - -struct ssl_ctx_st { - const SSL_METHOD *method; - STACK_OF(SSL_CIPHER) *cipher_list; - /* same as above but sorted for lookup */ - STACK_OF(SSL_CIPHER) *cipher_list_by_id; - /* TLSv1.3 specific ciphersuites */ - STACK_OF(SSL_CIPHER) *tls13_ciphersuites; - struct x509_store_st /* X509_STORE */ *cert_store; - LHASH_OF(SSL_SESSION) *sessions; - /* - * Most session-ids that will be cached, default is - * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. - */ - size_t session_cache_size; - struct ssl_session_st *session_cache_head; - struct ssl_session_st *session_cache_tail; - /* - * This can have one of 2 values, ored together, SSL_SESS_CACHE_CLIENT, - * SSL_SESS_CACHE_SERVER, Default is SSL_SESSION_CACHE_SERVER, which - * means only SSL_accept will cache SSL_SESSIONS. - */ - uint32_t session_cache_mode; - /* - * 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; - /* - * If this callback is not null, it will be called each time a session id - * is added to the cache. If this function returns 1, it means that the - * callback will do a SSL_SESSION_free() when it has finished using it. - * Otherwise, on 0, it means the callback has finished with it. If - * remove_session_cb is not null, it will be called when a session-id is - * removed from the cache. After the call, OpenSSL will - * SSL_SESSION_free() it. - */ - int (*new_session_cb) (struct ssl_st *ssl, SSL_SESSION *sess); - void (*remove_session_cb) (struct ssl_ctx_st *ctx, SSL_SESSION *sess); - SSL_SESSION *(*get_session_cb) (struct ssl_st *ssl, - const unsigned char *data, int len, - int *copy); - struct { - TSAN_QUALIFIER int sess_connect; /* SSL new conn - started */ - TSAN_QUALIFIER int sess_connect_renegotiate; /* SSL reneg - requested */ - TSAN_QUALIFIER int sess_connect_good; /* SSL new conne/reneg - finished */ - TSAN_QUALIFIER int sess_accept; /* SSL new accept - started */ - TSAN_QUALIFIER int sess_accept_renegotiate; /* SSL reneg - requested */ - TSAN_QUALIFIER int sess_accept_good; /* SSL accept/reneg - finished */ - TSAN_QUALIFIER int sess_miss; /* session lookup misses */ - TSAN_QUALIFIER int sess_timeout; /* reuse attempt on timeouted session */ - TSAN_QUALIFIER int sess_cache_full; /* session removed due to full cache */ - TSAN_QUALIFIER int sess_hit; /* session reuse actually done */ - TSAN_QUALIFIER int sess_cb_hit; /* session-id that was not in - * the cache was passed back via - * the callback. This indicates - * that the application is - * supplying session-id's from - * other processes - spooky - * :-) */ - } stats; - - CRYPTO_REF_COUNT references; - - /* if defined, these override the X509_verify_cert() calls */ - int (*app_verify_callback) (X509_STORE_CTX *, void *); - void *app_verify_arg; - /* - * before OpenSSL 0.9.7, 'app_verify_arg' was ignored - * ('app_verify_callback' was called with just one argument) - */ - - /* Default password callback. */ - pem_password_cb *default_passwd_callback; - - /* Default password callback user data. */ - void *default_passwd_callback_userdata; - - /* get client cert callback */ - int (*client_cert_cb) (SSL *ssl, X509 **x509, EVP_PKEY **pkey); - - /* cookie generate callback */ - int (*app_gen_cookie_cb) (SSL *ssl, unsigned char *cookie, - unsigned int *cookie_len); - - /* verify cookie callback */ - int (*app_verify_cookie_cb) (SSL *ssl, const unsigned char *cookie, - unsigned int cookie_len); - - /* TLS1.3 app-controlled cookie generate callback */ - int (*gen_stateless_cookie_cb) (SSL *ssl, unsigned char *cookie, - size_t *cookie_len); - - /* TLS1.3 verify app-controlled cookie callback */ - int (*verify_stateless_cookie_cb) (SSL *ssl, const unsigned char *cookie, - size_t cookie_len); - - CRYPTO_EX_DATA ex_data; - - const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */ - const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ - - STACK_OF(X509) *extra_certs; - STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */ - - /* Default values used when no per-SSL value is defined follow */ - - /* used if SSL's info_callback is NULL */ - void (*info_callback) (const SSL *ssl, int type, int val); - - /* - * What we put in certificate_authorities extension for TLS 1.3 - * (ClientHello and CertificateRequest) or just client cert requests for - * earlier versions. If client_ca_names is populated then it is only used - * for client cert requests, and in preference to ca_names. - */ - STACK_OF(X509_NAME) *ca_names; - STACK_OF(X509_NAME) *client_ca_names; - - /* - * Default values to use in SSL structures follow (these are copied by - * SSL_new) - */ - - uint32_t options; - uint32_t mode; - int min_proto_version; - int max_proto_version; - size_t max_cert_list; - - struct cert_st /* CERT */ *cert; - int read_ahead; - - /* callback that allows applications to peek at protocol messages */ - void (*msg_callback) (int write_p, int version, int content_type, - const void *buf, size_t len, SSL *ssl, void *arg); - void *msg_callback_arg; - - uint32_t verify_mode; - size_t sid_ctx_length; - unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; - /* called 'verify_callback' in the SSL */ - int (*default_verify_callback) (int ok, X509_STORE_CTX *ctx); - - /* Default generate session ID callback. */ - GEN_SESSION_CB generate_session_id; - - X509_VERIFY_PARAM *param; - - int quiet_shutdown; - -# ifndef OPENSSL_NO_CT - CTLOG_STORE *ctlog_store; /* CT Log Store */ - /* - * Validates that the SCTs (Signed Certificate Timestamps) are sufficient. - * If they are not, the connection should be aborted. - */ - ssl_ct_validation_cb ct_validation_callback; - void *ct_validation_callback_arg; -# endif - - /* - * If we're using more than one pipeline how should we divide the data - * up between the pipes? - */ - size_t split_send_fragment; - /* - * Maximum amount of data to send in one fragment. actual record size can - * be more than this due to padding and MAC overheads. - */ - size_t max_send_fragment; - - /* Up to how many pipelines should we use? If 0 then 1 is assumed */ - size_t max_pipelines; - - /* The default read buffer length to use (0 means not set) */ - size_t default_read_buf_len; - -# ifndef OPENSSL_NO_ENGINE - /* - * Engine to pass requests for client certs to - */ - ENGINE *client_cert_engine; -# endif - - /* ClientHello callback. Mostly for extensions, but not entirely. */ - SSL_client_hello_cb_fn client_hello_cb; - void *client_hello_cb_arg; - - /* TLS extensions. */ - struct { - /* TLS extensions servername callback */ - int (*servername_cb) (SSL *, int *, void *); - void *servername_arg; - /* RFC 4507 session ticket keys */ - unsigned char tick_key_name[TLSEXT_KEYNAME_LENGTH]; - SSL_CTX_EXT_SECURE *secure; - /* Callback to support customisation of ticket key setting */ - int (*ticket_key_cb) (SSL *ssl, - unsigned char *name, unsigned char *iv, - EVP_CIPHER_CTX *ectx, HMAC_CTX *hctx, int enc); - - /* certificate status request info */ - /* Callback for status request */ - int (*status_cb) (SSL *ssl, void *arg); - void *status_arg; - /* ext status type used for CSR extension (OCSP Stapling) */ - int status_type; - /* RFC 4366 Maximum Fragment Length Negotiation */ - uint8_t max_fragment_len_mode; - -# ifndef OPENSSL_NO_EC - /* EC extension values inherited by SSL structure */ - size_t ecpointformats_len; - unsigned char *ecpointformats; - size_t supportedgroups_len; - uint16_t *supportedgroups; -# endif /* OPENSSL_NO_EC */ - - /* - * ALPN information (we are in the process of transitioning from NPN to - * ALPN.) - */ - - /*- - * For a server, this contains a callback function that allows the - * server to select the protocol for the connection. - * out: on successful return, this must point to the raw protocol - * name (without the length prefix). - * outlen: on successful return, this contains the length of |*out|. - * in: points to the client's list of supported protocols in - * wire-format. - * inlen: the length of |in|. - */ - int (*alpn_select_cb) (SSL *s, - const unsigned char **out, - unsigned char *outlen, - const unsigned char *in, - unsigned int inlen, void *arg); - void *alpn_select_cb_arg; - - /* - * For a client, this contains the list of supported protocols in wire - * format. - */ - unsigned char *alpn; - size_t alpn_len; - -# ifndef OPENSSL_NO_NEXTPROTONEG - /* Next protocol negotiation information */ - - /* - * For a server, this contains a callback function by which the set of - * advertised protocols can be provided. - */ - SSL_CTX_npn_advertised_cb_func npn_advertised_cb; - void *npn_advertised_cb_arg; - /* - * For a client, this contains a callback function that selects the next - * protocol from the list provided by the server. - */ - SSL_CTX_npn_select_cb_func npn_select_cb; - void *npn_select_cb_arg; -# endif - - unsigned char cookie_hmac_key[SHA256_DIGEST_LENGTH]; - } ext; - -# ifndef OPENSSL_NO_PSK - SSL_psk_client_cb_func psk_client_callback; - SSL_psk_server_cb_func psk_server_callback; -# endif - SSL_psk_find_session_cb_func psk_find_session_cb; - SSL_psk_use_session_cb_func psk_use_session_cb; - -# ifndef OPENSSL_NO_SRP - SRP_CTX srp_ctx; /* ctx for SRP authentication */ -# endif - - /* Shared DANE context */ - struct dane_ctx_st dane; - -# ifndef OPENSSL_NO_SRTP - /* SRTP profiles we are willing to do from RFC 5764 */ - STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles; -# endif - /* - * Callback for disabling session caching and ticket support on a session - * basis, depending on the chosen cipher. - */ - int (*not_resumable_session_cb) (SSL *ssl, int is_forward_secure); - - CRYPTO_RWLOCK *lock; - - /* - * Callback for logging key material for use with debugging tools like - * Wireshark. The callback should log `line` followed by a newline. - */ - SSL_CTX_keylog_cb_func keylog_callback; - - /* - * The maximum number of bytes advertised in session tickets that can be - * sent as early data. - */ - uint32_t max_early_data; - - /* - * The maximum number of bytes of early data that a server will tolerate - * (which should be at least as much as max_early_data). - */ - uint32_t recv_max_early_data; - - /* TLS1.3 padding callback */ - size_t (*record_padding_cb)(SSL *s, int type, size_t len, void *arg); - void *record_padding_arg; - size_t block_padding; - - /* Session ticket appdata */ - SSL_CTX_generate_session_ticket_fn generate_ticket_cb; - SSL_CTX_decrypt_session_ticket_fn decrypt_ticket_cb; - void *ticket_cb_data; - - /* The number of TLS1.3 tickets to automatically send */ - size_t num_tickets; - - /* Callback to determine if early_data is acceptable or not */ - SSL_allow_early_data_cb_fn allow_early_data_cb; - void *allow_early_data_cb_data; - - /* Do we advertise Post-handshake auth support? */ - int pha_enabled; -}; - -struct ssl_st { - /* - * protocol version (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, - * DTLS1_VERSION) - */ - int version; - /* SSLv3 */ - const SSL_METHOD *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 - */ - /* used by SSL_read */ - BIO *rbio; - /* used by SSL_write */ - BIO *wbio; - /* used during session-id reuse to concatenate messages */ - BIO *bbio; - /* - * This holds a variable that indicates what we were doing when a 0 or -1 - * is returned. This is needed for non-blocking IO so we know what - * request needs re-doing when in SSL_accept or SSL_connect - */ - int rwstate; - int (*handshake_func) (SSL *); - /* - * Imagine that here's a boolean member "init" that is switched as soon - * as SSL_set_{accept/connect}_state is called for the first time, so - * that "state" and "handshake_func" are properly initialized. But as - * handshake_func is == 0 until then, we use this test instead of an - * "init" member. - */ - /* are we the server side? */ - int server; - /* - * Generate a new session or reuse an old one. - * NB: For servers, the 'new' session may actually be a previously - * cached session or even the previous session unless - * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set - */ - int new_session; - /* don't send shutdown packets */ - int quiet_shutdown; - /* we have shut things down, 0x01 sent, 0x02 for received */ - int shutdown; - /* where we are */ - OSSL_STATEM statem; - SSL_EARLY_DATA_STATE early_data_state; - BUF_MEM *init_buf; /* buffer used during init */ - void *init_msg; /* pointer to handshake message body, set by - * ssl3_get_message() */ - size_t init_num; /* amount read/written */ - size_t init_off; /* amount read/written */ - struct ssl3_state_st *s3; /* SSLv3 variables */ - struct dtls1_state_st *d1; /* DTLSv1 variables */ - /* callback that allows applications to peek at protocol messages */ - void (*msg_callback) (int write_p, int version, int content_type, - const void *buf, size_t len, SSL *ssl, void *arg); - void *msg_callback_arg; - int hit; /* reusing a previous session */ - X509_VERIFY_PARAM *param; - /* Per connection DANE state */ - SSL_DANE dane; - /* crypto */ - STACK_OF(SSL_CIPHER) *peer_ciphers; - STACK_OF(SSL_CIPHER) *cipher_list; - STACK_OF(SSL_CIPHER) *cipher_list_by_id; - /* TLSv1.3 specific ciphersuites */ - STACK_OF(SSL_CIPHER) *tls13_ciphersuites; - /* - * These are the ones being used, the ones in SSL_SESSION are the ones to - * be 'copied' into these ones - */ - uint32_t mac_flags; - /* - * The TLS1.3 secrets. - */ - unsigned char early_secret[EVP_MAX_MD_SIZE]; - unsigned char handshake_secret[EVP_MAX_MD_SIZE]; - unsigned char master_secret[EVP_MAX_MD_SIZE]; - unsigned char resumption_master_secret[EVP_MAX_MD_SIZE]; - unsigned char client_finished_secret[EVP_MAX_MD_SIZE]; - unsigned char server_finished_secret[EVP_MAX_MD_SIZE]; - unsigned char server_finished_hash[EVP_MAX_MD_SIZE]; - unsigned char handshake_traffic_hash[EVP_MAX_MD_SIZE]; - unsigned char client_app_traffic_secret[EVP_MAX_MD_SIZE]; - unsigned char server_app_traffic_secret[EVP_MAX_MD_SIZE]; - unsigned char exporter_master_secret[EVP_MAX_MD_SIZE]; - unsigned char early_exporter_master_secret[EVP_MAX_MD_SIZE]; - EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ - unsigned char read_iv[EVP_MAX_IV_LENGTH]; /* TLSv1.3 static read IV */ - EVP_MD_CTX *read_hash; /* used for mac generation */ - COMP_CTX *compress; /* compression */ - COMP_CTX *expand; /* uncompress */ - EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ - unsigned char write_iv[EVP_MAX_IV_LENGTH]; /* TLSv1.3 static write IV */ - EVP_MD_CTX *write_hash; /* used for mac generation */ - /* session info */ - /* client cert? */ - /* This is used to hold the server certificate used */ - struct cert_st /* CERT */ *cert; - - /* - * The hash of all messages prior to the CertificateVerify, and the length - * of that hash. - */ - unsigned char cert_verify_hash[EVP_MAX_MD_SIZE]; - size_t cert_verify_hash_len; - - /* Flag to indicate whether we should send a HelloRetryRequest or not */ - enum {SSL_HRR_NONE = 0, SSL_HRR_PENDING, SSL_HRR_COMPLETE} - hello_retry_request; - - /* - * 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; - /* TLSv1.3 PSK session */ - SSL_SESSION *psksession; - unsigned char *psksession_id; - size_t psksession_id_len; - /* Default generate session ID callback. */ - GEN_SESSION_CB generate_session_id; - /* - * The temporary TLSv1.3 session id. This isn't really a session id at all - * but is a random value sent in the legacy session id field. - */ - unsigned char tmp_session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; - size_t tmp_session_id_len; - /* Used in SSL3 */ - /* - * 0 don't care about verify failure. - * 1 fail if verify fails - */ - uint32_t verify_mode; - /* fail if callback returns 0 */ - int (*verify_callback) (int ok, X509_STORE_CTX *ctx); - /* optional informational callback */ - void (*info_callback) (const SSL *ssl, int type, int val); - /* error bytes to be written */ - int error; - /* actual code */ - int error_code; -# ifndef OPENSSL_NO_PSK - SSL_psk_client_cb_func psk_client_callback; - SSL_psk_server_cb_func psk_server_callback; -# endif - SSL_psk_find_session_cb_func psk_find_session_cb; - SSL_psk_use_session_cb_func psk_use_session_cb; - - SSL_CTX *ctx; - /* Verified chain of peer */ - STACK_OF(X509) *verified_chain; - long verify_result; - /* extra application data */ - CRYPTO_EX_DATA ex_data; - /* - * What we put in certificate_authorities extension for TLS 1.3 - * (ClientHello and CertificateRequest) or just client cert requests for - * earlier versions. If client_ca_names is populated then it is only used - * for client cert requests, and in preference to ca_names. - */ - STACK_OF(X509_NAME) *ca_names; - STACK_OF(X509_NAME) *client_ca_names; - CRYPTO_REF_COUNT references; - /* protocol behaviour */ - uint32_t options; - /* API behaviour */ - uint32_t mode; - int min_proto_version; - int max_proto_version; - size_t max_cert_list; - int first_packet; - /* - * What was passed in ClientHello.legacy_version. Used for RSA pre-master - * secret and SSLv3/TLS (<=1.2) rollback check - */ - int client_version; - /* - * If we're using more than one pipeline how should we divide the data - * up between the pipes? - */ - size_t split_send_fragment; - /* - * Maximum amount of data to send in one fragment. actual record size can - * be more than this due to padding and MAC overheads. - */ - size_t max_send_fragment; - /* Up to how many pipelines should we use? If 0 then 1 is assumed */ - size_t max_pipelines; - - struct { - /* Built-in extension flags */ - uint8_t extflags[TLSEXT_IDX_num_builtins]; - /* TLS extension debug callback */ - void (*debug_cb)(SSL *s, int client_server, int type, - const unsigned char *data, int len, void *arg); - void *debug_arg; - char *hostname; - /* certificate status request info */ - /* Status type or -1 if no status type */ - int status_type; - /* Raw extension data, if seen */ - unsigned char *scts; - /* Length of raw extension data, if seen */ - uint16_t scts_len; - /* Expect OCSP CertificateStatus message */ - int status_expected; - - struct { - /* OCSP status request only */ - STACK_OF(OCSP_RESPID) *ids; - X509_EXTENSIONS *exts; - /* OCSP response received or to be sent */ - unsigned char *resp; - size_t resp_len; - } ocsp; - - /* RFC4507 session ticket expected to be received or sent */ - int ticket_expected; -# ifndef OPENSSL_NO_EC - size_t ecpointformats_len; - /* our list */ - unsigned char *ecpointformats; - - size_t peer_ecpointformats_len; - /* peer's list */ - unsigned char *peer_ecpointformats; -# endif /* OPENSSL_NO_EC */ - size_t supportedgroups_len; - /* our list */ - uint16_t *supportedgroups; - - size_t peer_supportedgroups_len; - /* peer's list */ - uint16_t *peer_supportedgroups; - - /* TLS Session Ticket extension override */ - TLS_SESSION_TICKET_EXT *session_ticket; - /* TLS Session Ticket extension callback */ - tls_session_ticket_ext_cb_fn session_ticket_cb; - void *session_ticket_cb_arg; - /* TLS pre-shared secret session resumption */ - tls_session_secret_cb_fn session_secret_cb; - void *session_secret_cb_arg; - /* - * For a client, this contains the list of supported protocols in wire - * format. - */ - unsigned char *alpn; - size_t alpn_len; - /* - * Next protocol negotiation. For the client, this is the protocol that - * we sent in NextProtocol and is set when handling ServerHello - * extensions. For a server, this is the client's selected_protocol from - * NextProtocol and is set when handling the NextProtocol message, before - * the Finished message. - */ - unsigned char *npn; - size_t npn_len; - - /* The available PSK key exchange modes */ - int psk_kex_mode; - - /* Set to one if we have negotiated ETM */ - int use_etm; - - /* Are we expecting to receive early data? */ - int early_data; - /* Is the session suitable for early data? */ - int early_data_ok; - - /* May be sent by a server in HRR. Must be echoed back in ClientHello */ - unsigned char *tls13_cookie; - size_t tls13_cookie_len; - /* Have we received a cookie from the client? */ - int cookieok; - - /* - * Maximum Fragment Length as per RFC 4366. - * If this member contains one of the allowed values (1-4) - * then we should include Maximum Fragment Length Negotiation - * extension in Client Hello. - * Please note that value of this member does not have direct - * effect. The actual (binding) value is stored in SSL_SESSION, - * as this extension is optional on server side. - */ - uint8_t max_fragment_len_mode; - - /* - * On the client side the number of ticket identities we sent in the - * ClientHello. On the server side the identity of the ticket we - * selected. - */ - int tick_identity; - } ext; - - /* - * Parsed form of the ClientHello, kept around across client_hello_cb - * calls. - */ - CLIENTHELLO_MSG *clienthello; - - /*- - * no further mod of servername - * 0 : call the servername extension callback. - * 1 : prepare 2, allow last ack just after in server callback. - * 2 : don't call servername callback, no ack in server hello - */ - int servername_done; -# ifndef OPENSSL_NO_CT - /* - * Validates that the SCTs (Signed Certificate Timestamps) are sufficient. - * If they are not, the connection should be aborted. - */ - ssl_ct_validation_cb ct_validation_callback; - /* User-supplied argument that is passed to the ct_validation_callback */ - void *ct_validation_callback_arg; - /* - * Consolidated stack of SCTs from all sources. - * Lazily populated by CT_get_peer_scts(SSL*) - */ - STACK_OF(SCT) *scts; - /* Have we attempted to find/parse SCTs yet? */ - int scts_parsed; -# endif - SSL_CTX *session_ctx; /* initial ctx, used to store sessions */ -# ifndef OPENSSL_NO_SRTP - /* What we'll do */ - STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles; - /* What's been chosen */ - SRTP_PROTECTION_PROFILE *srtp_profile; -# endif - /*- - * 1 if we are renegotiating. - * 2 if we are a server and are inside a handshake - * (i.e. not just sending a HelloRequest) - */ - int renegotiate; - /* If sending a KeyUpdate is pending */ - int key_update; - /* Post-handshake authentication state */ - SSL_PHA_STATE post_handshake_auth; - int pha_enabled; - uint8_t* pha_context; - size_t pha_context_len; - int certreqs_sent; - EVP_MD_CTX *pha_dgst; /* this is just the digest through ClientFinished */ - -# ifndef OPENSSL_NO_SRP - /* ctx for SRP authentication */ - SRP_CTX srp_ctx; -# endif - /* - * Callback for disabling session caching and ticket support on a session - * basis, depending on the chosen cipher. - */ - int (*not_resumable_session_cb) (SSL *ssl, int is_forward_secure); - RECORD_LAYER rlayer; - /* Default password callback. */ - pem_password_cb *default_passwd_callback; - /* Default password callback user data. */ - void *default_passwd_callback_userdata; - /* Async Job info */ - ASYNC_JOB *job; - ASYNC_WAIT_CTX *waitctx; - size_t asyncrw; - - /* - * The maximum number of bytes advertised in session tickets that can be - * sent as early data. - */ - uint32_t max_early_data; - /* - * The maximum number of bytes of early data that a server will tolerate - * (which should be at least as much as max_early_data). - */ - uint32_t recv_max_early_data; - - /* - * The number of bytes of early data received so far. If we accepted early - * data then this is a count of the plaintext bytes. If we rejected it then - * this is a count of the ciphertext bytes. - */ - uint32_t early_data_count; - - /* TLS1.3 padding callback */ - size_t (*record_padding_cb)(SSL *s, int type, size_t len, void *arg); - void *record_padding_arg; - size_t block_padding; - - CRYPTO_RWLOCK *lock; - - /* The number of TLS1.3 tickets to automatically send */ - size_t num_tickets; - /* The number of TLS1.3 tickets actually sent so far */ - size_t sent_tickets; - /* The next nonce value to use when we send a ticket on this connection */ - uint64_t next_ticket_nonce; - - /* Callback to determine if early_data is acceptable or not */ - SSL_allow_early_data_cb_fn allow_early_data_cb; - void *allow_early_data_cb_data; - - /* - * Signature algorithms shared by client and server: cached because these - * are used most often. - */ - const struct sigalg_lookup_st **shared_sigalgs; - size_t shared_sigalgslen; -}; - -/* - * Structure containing table entry of values associated with the signature - * algorithms (signature scheme) extension -*/ -typedef struct sigalg_lookup_st { - /* TLS 1.3 signature scheme name */ - const char *name; - /* Raw value used in extension */ - uint16_t sigalg; - /* NID of hash algorithm or NID_undef if no hash */ - int hash; - /* Index of hash algorithm or -1 if no hash algorithm */ - int hash_idx; - /* NID of signature algorithm */ - int sig; - /* Index of signature algorithm */ - int sig_idx; - /* Combined hash and signature NID, if any */ - int sigandhash; - /* Required public key curve (ECDSA only) */ - int curve; -} SIGALG_LOOKUP; - -typedef struct tls_group_info_st { - int nid; /* Curve NID */ - int secbits; /* Bits of security (from SP800-57) */ - uint16_t flags; /* Flags: currently just group type */ -} TLS_GROUP_INFO; - -/* flags values */ -# define TLS_CURVE_TYPE 0x3 /* Mask for group type */ -# define TLS_CURVE_PRIME 0x0 -# define TLS_CURVE_CHAR2 0x1 -# define TLS_CURVE_CUSTOM 0x2 - -typedef struct cert_pkey_st CERT_PKEY; - -/* - * Structure containing table entry of certificate info corresponding to - * CERT_PKEY entries - */ -typedef struct { - int nid; /* NID of public key algorithm */ - uint32_t amask; /* authmask corresponding to key type */ -} SSL_CERT_LOOKUP; - -typedef struct ssl3_state_st { - long flags; - size_t read_mac_secret_size; - unsigned char read_mac_secret[EVP_MAX_MD_SIZE]; - size_t write_mac_secret_size; - unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; - unsigned char server_random[SSL3_RANDOM_SIZE]; - unsigned char client_random[SSL3_RANDOM_SIZE]; - /* flags for countermeasure against known-IV weakness */ - int need_empty_fragments; - int empty_fragment_done; - /* used during startup, digest all incoming/outgoing packets */ - BIO *handshake_buffer; - /* - * When handshake digest is determined, buffer is hashed and - * freed and MD_CTX for the required digest is stored here. - */ - EVP_MD_CTX *handshake_dgst; - /* - * Set whenever an expected ChangeCipherSpec message is processed. - * Unset when the peer's Finished message is received. - * Unexpected ChangeCipherSpec messages trigger a fatal alert. - */ - int change_cipher_spec; - int warn_alert; - int fatal_alert; - /* - * we allow one fatal and one warning alert to be outstanding, send close - * alert via the warning alert - */ - int alert_dispatch; - unsigned char send_alert[2]; - /* - * This flag is set when we should renegotiate ASAP, basically when there - * is no more data in the read or write buffers - */ - int renegotiate; - int total_renegotiations; - int num_renegotiations; - int in_read_app_data; - struct { - /* actually only need to be 16+20 for SSLv3 and 12 for TLS */ - unsigned char finish_md[EVP_MAX_MD_SIZE * 2]; - size_t finish_md_len; - unsigned char peer_finish_md[EVP_MAX_MD_SIZE * 2]; - size_t peer_finish_md_len; - size_t message_size; - int message_type; - /* used to hold the new cipher we are going to use */ - const SSL_CIPHER *new_cipher; -# if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) - EVP_PKEY *pkey; /* holds short lived DH/ECDH key */ -# endif - /* used for certificate requests */ - int cert_req; - /* Certificate types in certificate request message. */ - uint8_t *ctype; - size_t ctype_len; - /* Certificate authorities list peer sent */ - STACK_OF(X509_NAME) *peer_ca_names; - size_t key_block_length; - unsigned char *key_block; - const EVP_CIPHER *new_sym_enc; - const EVP_MD *new_hash; - int new_mac_pkey_type; - size_t new_mac_secret_size; -# ifndef OPENSSL_NO_COMP - const SSL_COMP *new_compression; -# else - char *new_compression; -# endif - int cert_request; - /* Raw values of the cipher list from a client */ - unsigned char *ciphers_raw; - size_t ciphers_rawlen; - /* Temporary storage for premaster secret */ - unsigned char *pms; - size_t pmslen; -# ifndef OPENSSL_NO_PSK - /* Temporary storage for PSK key */ - unsigned char *psk; - size_t psklen; -# endif - /* Signature algorithm we actually use */ - const SIGALG_LOOKUP *sigalg; - /* Pointer to certificate we use */ - CERT_PKEY *cert; - /* - * signature algorithms peer reports: e.g. supported signature - * algorithms extension for server or as part of a certificate - * request for client. - * Keep track of the algorithms for TLS and X.509 usage separately. - */ - uint16_t *peer_sigalgs; - uint16_t *peer_cert_sigalgs; - /* Size of above arrays */ - size_t peer_sigalgslen; - size_t peer_cert_sigalgslen; - /* Sigalg peer actually uses */ - const SIGALG_LOOKUP *peer_sigalg; - /* - * Set if corresponding CERT_PKEY can be used with current - * SSL session: e.g. appropriate curve, signature algorithms etc. - * If zero it can't be used at all. - */ - uint32_t valid_flags[SSL_PKEY_NUM]; - /* - * For servers the following masks are for the key and auth algorithms - * that are supported by the certs below. For clients they are masks of - * *disabled* algorithms based on the current session. - */ - uint32_t mask_k; - uint32_t mask_a; - /* - * The following are used by the client to see if a cipher is allowed or - * not. It contains the minimum and maximum version the client's using - * based on what it knows so far. - */ - int min_ver; - int max_ver; - } tmp; - - /* Connection binding to prevent renegotiation attacks */ - unsigned char previous_client_finished[EVP_MAX_MD_SIZE]; - size_t previous_client_finished_len; - unsigned char previous_server_finished[EVP_MAX_MD_SIZE]; - size_t previous_server_finished_len; - int send_connection_binding; /* TODOEKR */ - -# ifndef OPENSSL_NO_NEXTPROTONEG - /* - * Set if we saw the Next Protocol Negotiation extension from our peer. - */ - int npn_seen; -# endif - - /* - * ALPN information (we are in the process of transitioning from NPN to - * ALPN.) - */ - - /* - * In a server these point to the selected ALPN protocol after the - * ClientHello has been processed. In a client these contain the protocol - * that the server selected once the ServerHello has been processed. - */ - unsigned char *alpn_selected; - size_t alpn_selected_len; - /* used by the server to know what options were proposed */ - unsigned char *alpn_proposed; - size_t alpn_proposed_len; - /* used by the client to know if it actually sent alpn */ - int alpn_sent; - -# ifndef OPENSSL_NO_EC - /* - * This is set to true if we believe that this is a version of Safari - * running on OS X 10.6 or newer. We wish to know this because Safari on - * 10.8 .. 10.8.3 has broken ECDHE-ECDSA support. - */ - char is_probably_safari; -# endif /* !OPENSSL_NO_EC */ - - /* For clients: peer temporary key */ -# if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) - /* The group_id for the DH/ECDH key */ - uint16_t group_id; - EVP_PKEY *peer_tmp; -# endif - -} SSL3_STATE; - -/* DTLS structures */ - -# ifndef OPENSSL_NO_SCTP -# define DTLS1_SCTP_AUTH_LABEL "EXPORTER_DTLS_OVER_SCTP" -# endif - -/* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */ -# define DTLS1_MAX_MTU_OVERHEAD 48 - -/* - * Flag used in message reuse to indicate the buffer contains the record - * header as well as the handshake message header. - */ -# define DTLS1_SKIP_RECORD_HEADER 2 - -struct dtls1_retransmit_state { - EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ - EVP_MD_CTX *write_hash; /* used for mac generation */ - COMP_CTX *compress; /* compression */ - SSL_SESSION *session; - unsigned short epoch; -}; - -struct hm_header_st { - unsigned char type; - size_t msg_len; - unsigned short seq; - size_t frag_off; - size_t frag_len; - unsigned int is_ccs; - struct dtls1_retransmit_state saved_retransmit_state; -}; - -struct dtls1_timeout_st { - /* Number of read timeouts so far */ - unsigned int read_timeouts; - /* Number of write timeouts so far */ - unsigned int write_timeouts; - /* Number of alerts received so far */ - unsigned int num_alerts; -}; - -typedef struct hm_fragment_st { - struct hm_header_st msg_header; - unsigned char *fragment; - unsigned char *reassembly; -} hm_fragment; - -typedef struct pqueue_st pqueue; -typedef struct pitem_st pitem; - -struct pitem_st { - unsigned char priority[8]; /* 64-bit value in big-endian encoding */ - void *data; - pitem *next; -}; - -typedef struct pitem_st *piterator; - -pitem *pitem_new(unsigned char *prio64be, void *data); -void pitem_free(pitem *item); -pqueue *pqueue_new(void); -void pqueue_free(pqueue *pq); -pitem *pqueue_insert(pqueue *pq, pitem *item); -pitem *pqueue_peek(pqueue *pq); -pitem *pqueue_pop(pqueue *pq); -pitem *pqueue_find(pqueue *pq, unsigned char *prio64be); -pitem *pqueue_iterator(pqueue *pq); -pitem *pqueue_next(piterator *iter); -size_t pqueue_size(pqueue *pq); - -typedef struct dtls1_state_st { - unsigned char cookie[DTLS1_COOKIE_LENGTH]; - size_t cookie_len; - unsigned int cookie_verified; - /* handshake message numbers */ - unsigned short handshake_write_seq; - unsigned short next_handshake_write_seq; - unsigned short handshake_read_seq; - /* Buffered handshake messages */ - pqueue *buffered_messages; - /* Buffered (sent) handshake records */ - pqueue *sent_messages; - size_t link_mtu; /* max on-the-wire DTLS packet size */ - size_t mtu; /* max DTLS packet size */ - struct hm_header_st w_msg_hdr; - struct hm_header_st r_msg_hdr; - struct dtls1_timeout_st timeout; - /* - * Indicates when the last handshake msg sent will timeout - */ - struct timeval next_timeout; - /* Timeout duration */ - unsigned int timeout_duration_us; - - unsigned int retransmitting; -# ifndef OPENSSL_NO_SCTP - int shutdown_received; -# endif - - DTLS_timer_cb timer_cb; - -} DTLS1_STATE; - -# ifndef OPENSSL_NO_EC -/* - * From ECC-TLS draft, used in encoding the curve type in ECParameters - */ -# define EXPLICIT_PRIME_CURVE_TYPE 1 -# define EXPLICIT_CHAR2_CURVE_TYPE 2 -# define NAMED_CURVE_TYPE 3 -# endif /* OPENSSL_NO_EC */ - -struct cert_pkey_st { - X509 *x509; - EVP_PKEY *privatekey; - /* Chain for this certificate */ - STACK_OF(X509) *chain; - /*- - * serverinfo data for this certificate. The data is in TLS Extension - * wire format, specifically it's a series of records like: - * uint16_t extension_type; // (RFC 5246, 7.4.1.4, Extension) - * uint16_t length; - * uint8_t data[length]; - */ - unsigned char *serverinfo; - size_t serverinfo_length; -}; -/* Retrieve Suite B flags */ -# define tls1_suiteb(s) (s->cert->cert_flags & SSL_CERT_FLAG_SUITEB_128_LOS) -/* Uses to check strict mode: suite B modes are always strict */ -# define SSL_CERT_FLAGS_CHECK_TLS_STRICT \ - (SSL_CERT_FLAG_SUITEB_128_LOS|SSL_CERT_FLAG_TLS_STRICT) - -typedef enum { - ENDPOINT_CLIENT = 0, - ENDPOINT_SERVER, - ENDPOINT_BOTH -} ENDPOINT; - - -typedef struct { - unsigned short ext_type; - ENDPOINT role; - /* The context which this extension applies to */ - unsigned int context; - /* - * Per-connection flags relating to this extension type: not used if - * part of an SSL_CTX structure. - */ - uint32_t ext_flags; - SSL_custom_ext_add_cb_ex add_cb; - SSL_custom_ext_free_cb_ex free_cb; - void *add_arg; - SSL_custom_ext_parse_cb_ex parse_cb; - void *parse_arg; -} custom_ext_method; - -/* ext_flags values */ - -/* - * Indicates an extension has been received. Used to check for unsolicited or - * duplicate extensions. - */ -# define SSL_EXT_FLAG_RECEIVED 0x1 -/* - * Indicates an extension has been sent: used to enable sending of - * corresponding ServerHello extension. - */ -# define SSL_EXT_FLAG_SENT 0x2 - -typedef struct { - custom_ext_method *meths; - size_t meths_count; -} custom_ext_methods; - -typedef struct cert_st { - /* Current active set */ - /* - * ALWAYS points to an element of the pkeys array - * Probably it would make more sense to store - * an index, not a pointer. - */ - CERT_PKEY *key; -# ifndef OPENSSL_NO_DH - EVP_PKEY *dh_tmp; - DH *(*dh_tmp_cb) (SSL *ssl, int is_export, int keysize); - int dh_tmp_auto; -# endif - /* Flags related to certificates */ - uint32_t cert_flags; - CERT_PKEY pkeys[SSL_PKEY_NUM]; - /* Custom certificate types sent in certificate request message. */ - uint8_t *ctype; - size_t ctype_len; - /* - * supported signature algorithms. When set on a client this is sent in - * the client hello as the supported signature algorithms extension. For - * servers it represents the signature algorithms we are willing to use. - */ - uint16_t *conf_sigalgs; - /* Size of above array */ - size_t conf_sigalgslen; - /* - * Client authentication signature algorithms, if not set then uses - * conf_sigalgs. On servers these will be the signature algorithms sent - * to the client in a certificate request for TLS 1.2. On a client this - * represents the signature algorithms we are willing to use for client - * authentication. - */ - uint16_t *client_sigalgs; - /* Size of above array */ - size_t client_sigalgslen; - /* - * Certificate setup callback: if set is called whenever a certificate - * may be required (client or server). the callback can then examine any - * appropriate parameters and setup any certificates required. This - * allows advanced applications to select certificates on the fly: for - * example based on supported signature algorithms or curves. - */ - int (*cert_cb) (SSL *ssl, void *arg); - void *cert_cb_arg; - /* - * Optional X509_STORE for chain building or certificate validation If - * NULL the parent SSL_CTX store is used instead. - */ - X509_STORE *chain_store; - X509_STORE *verify_store; - /* Custom extensions */ - custom_ext_methods custext; - /* Security callback */ - int (*sec_cb) (const SSL *s, const SSL_CTX *ctx, int op, int bits, int nid, - void *other, void *ex); - /* Security level */ - int sec_level; - void *sec_ex; -# ifndef OPENSSL_NO_PSK - /* If not NULL psk identity hint to use for servers */ - char *psk_identity_hint; -# endif - CRYPTO_REF_COUNT references; /* >1 only if SSL_copy_session_id is used */ - CRYPTO_RWLOCK *lock; -} CERT; - -# define FP_ICC (int (*)(const void *,const void *)) - -/* - * This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff It is a bit - * of a mess of functions, but hell, think of it as an opaque structure :-) - */ -typedef struct ssl3_enc_method { - int (*enc) (SSL *, SSL3_RECORD *, size_t, int); - int (*mac) (SSL *, SSL3_RECORD *, unsigned char *, int); - int (*setup_key_block) (SSL *); - int (*generate_master_secret) (SSL *, unsigned char *, unsigned char *, - size_t, size_t *); - int (*change_cipher_state) (SSL *, int); - size_t (*final_finish_mac) (SSL *, const char *, size_t, unsigned char *); - const char *client_finished_label; - size_t client_finished_label_len; - const char *server_finished_label; - size_t server_finished_label_len; - int (*alert_value) (int); - int (*export_keying_material) (SSL *, unsigned char *, size_t, - const char *, size_t, - const unsigned char *, size_t, - int use_context); - /* Various flags indicating protocol version requirements */ - uint32_t enc_flags; - /* Set the handshake header */ - int (*set_handshake_header) (SSL *s, WPACKET *pkt, int type); - /* Close construction of the handshake message */ - int (*close_construct_packet) (SSL *s, WPACKET *pkt, int htype); - /* Write out handshake message */ - int (*do_write) (SSL *s); -} SSL3_ENC_METHOD; - -# define ssl_set_handshake_header(s, pkt, htype) \ - s->method->ssl3_enc->set_handshake_header((s), (pkt), (htype)) -# define ssl_close_construct_packet(s, pkt, htype) \ - s->method->ssl3_enc->close_construct_packet((s), (pkt), (htype)) -# define ssl_do_write(s) s->method->ssl3_enc->do_write(s) - -/* Values for enc_flags */ - -/* Uses explicit IV for CBC mode */ -# define SSL_ENC_FLAG_EXPLICIT_IV 0x1 -/* Uses signature algorithms extension */ -# define SSL_ENC_FLAG_SIGALGS 0x2 -/* Uses SHA256 default PRF */ -# define SSL_ENC_FLAG_SHA256_PRF 0x4 -/* Is DTLS */ -# define SSL_ENC_FLAG_DTLS 0x8 -/* - * Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2: may - * apply to others in future. - */ -# define SSL_ENC_FLAG_TLS1_2_CIPHERS 0x10 - -# ifndef OPENSSL_NO_COMP -/* Used for holding the relevant compression methods loaded into SSL_CTX */ -typedef struct ssl3_comp_st { - int comp_id; /* The identifier byte for this compression - * type */ - char *name; /* Text name used for the compression type */ - COMP_METHOD *method; /* The method :-) */ -} SSL3_COMP; -# endif - -typedef enum downgrade_en { - DOWNGRADE_NONE, - DOWNGRADE_TO_1_2, - DOWNGRADE_TO_1_1 -} DOWNGRADE; - -/* - * Dummy status type for the status_type extension. Indicates no status type - * set - */ -#define TLSEXT_STATUSTYPE_nothing -1 - -/* Sigalgs values */ -#define TLSEXT_SIGALG_ecdsa_secp256r1_sha256 0x0403 -#define TLSEXT_SIGALG_ecdsa_secp384r1_sha384 0x0503 -#define TLSEXT_SIGALG_ecdsa_secp521r1_sha512 0x0603 -#define TLSEXT_SIGALG_ecdsa_sha224 0x0303 -#define TLSEXT_SIGALG_ecdsa_sha1 0x0203 -#define TLSEXT_SIGALG_rsa_pss_rsae_sha256 0x0804 -#define TLSEXT_SIGALG_rsa_pss_rsae_sha384 0x0805 -#define TLSEXT_SIGALG_rsa_pss_rsae_sha512 0x0806 -#define TLSEXT_SIGALG_rsa_pss_pss_sha256 0x0809 -#define TLSEXT_SIGALG_rsa_pss_pss_sha384 0x080a -#define TLSEXT_SIGALG_rsa_pss_pss_sha512 0x080b -#define TLSEXT_SIGALG_rsa_pkcs1_sha256 0x0401 -#define TLSEXT_SIGALG_rsa_pkcs1_sha384 0x0501 -#define TLSEXT_SIGALG_rsa_pkcs1_sha512 0x0601 -#define TLSEXT_SIGALG_rsa_pkcs1_sha224 0x0301 -#define TLSEXT_SIGALG_rsa_pkcs1_sha1 0x0201 -#define TLSEXT_SIGALG_dsa_sha256 0x0402 -#define TLSEXT_SIGALG_dsa_sha384 0x0502 -#define TLSEXT_SIGALG_dsa_sha512 0x0602 -#define TLSEXT_SIGALG_dsa_sha224 0x0302 -#define TLSEXT_SIGALG_dsa_sha1 0x0202 -#define TLSEXT_SIGALG_gostr34102012_256_gostr34112012_256 0xeeee -#define TLSEXT_SIGALG_gostr34102012_512_gostr34112012_512 0xefef -#define TLSEXT_SIGALG_gostr34102001_gostr3411 0xeded - -#define TLSEXT_SIGALG_ed25519 0x0807 -#define TLSEXT_SIGALG_ed448 0x0808 - -/* Known PSK key exchange modes */ -#define TLSEXT_KEX_MODE_KE 0x00 -#define TLSEXT_KEX_MODE_KE_DHE 0x01 - -/* - * Internal representations of key exchange modes - */ -#define TLSEXT_KEX_MODE_FLAG_NONE 0 -#define TLSEXT_KEX_MODE_FLAG_KE 1 -#define TLSEXT_KEX_MODE_FLAG_KE_DHE 2 - -#define SSL_USE_PSS(s) (s->s3->tmp.peer_sigalg != NULL && \ - s->s3->tmp.peer_sigalg->sig == EVP_PKEY_RSA_PSS) - -/* A dummy signature value not valid for TLSv1.2 signature algs */ -#define TLSEXT_signature_rsa_pss 0x0101 - -/* TLSv1.3 downgrade protection sentinel values */ -extern const unsigned char tls11downgrade[8]; -extern const unsigned char tls12downgrade[8]; - -extern SSL3_ENC_METHOD ssl3_undef_enc_method; - -__owur const SSL_METHOD *ssl_bad_method(int ver); -__owur const SSL_METHOD *sslv3_method(void); -__owur const SSL_METHOD *sslv3_server_method(void); -__owur const SSL_METHOD *sslv3_client_method(void); -__owur const SSL_METHOD *tlsv1_method(void); -__owur const SSL_METHOD *tlsv1_server_method(void); -__owur const SSL_METHOD *tlsv1_client_method(void); -__owur const SSL_METHOD *tlsv1_1_method(void); -__owur const SSL_METHOD *tlsv1_1_server_method(void); -__owur const SSL_METHOD *tlsv1_1_client_method(void); -__owur const SSL_METHOD *tlsv1_2_method(void); -__owur const SSL_METHOD *tlsv1_2_server_method(void); -__owur const SSL_METHOD *tlsv1_2_client_method(void); -__owur const SSL_METHOD *tlsv1_3_method(void); -__owur const SSL_METHOD *tlsv1_3_server_method(void); -__owur const SSL_METHOD *tlsv1_3_client_method(void); -__owur const SSL_METHOD *dtlsv1_method(void); -__owur const SSL_METHOD *dtlsv1_server_method(void); -__owur const SSL_METHOD *dtlsv1_client_method(void); -__owur const SSL_METHOD *dtls_bad_ver_client_method(void); -__owur const SSL_METHOD *dtlsv1_2_method(void); -__owur const SSL_METHOD *dtlsv1_2_server_method(void); -__owur const SSL_METHOD *dtlsv1_2_client_method(void); - -extern const SSL3_ENC_METHOD TLSv1_enc_data; -extern const SSL3_ENC_METHOD TLSv1_1_enc_data; -extern const SSL3_ENC_METHOD TLSv1_2_enc_data; -extern const SSL3_ENC_METHOD TLSv1_3_enc_data; -extern const SSL3_ENC_METHOD SSLv3_enc_data; -extern const SSL3_ENC_METHOD DTLSv1_enc_data; -extern const SSL3_ENC_METHOD DTLSv1_2_enc_data; - -/* - * Flags for SSL methods - */ -# define SSL_METHOD_NO_FIPS (1U<<0) -# define SSL_METHOD_NO_SUITEB (1U<<1) - -# define IMPLEMENT_tls_meth_func(version, flags, mask, func_name, s_accept, \ - s_connect, enc_data) \ -const SSL_METHOD *func_name(void) \ - { \ - static const SSL_METHOD func_name##_data= { \ - version, \ - flags, \ - mask, \ - tls1_new, \ - tls1_clear, \ - tls1_free, \ - s_accept, \ - s_connect, \ - ssl3_read, \ - ssl3_peek, \ - ssl3_write, \ - ssl3_shutdown, \ - ssl3_renegotiate, \ - ssl3_renegotiate_check, \ - ssl3_read_bytes, \ - ssl3_write_bytes, \ - ssl3_dispatch_alert, \ - ssl3_ctrl, \ - ssl3_ctx_ctrl, \ - ssl3_get_cipher_by_char, \ - ssl3_put_cipher_by_char, \ - ssl3_pending, \ - ssl3_num_ciphers, \ - ssl3_get_cipher, \ - tls1_default_timeout, \ - &enc_data, \ - ssl_undefined_void_function, \ - ssl3_callback_ctrl, \ - ssl3_ctx_callback_ctrl, \ - }; \ - return &func_name##_data; \ - } - -# define IMPLEMENT_ssl3_meth_func(func_name, s_accept, s_connect) \ -const SSL_METHOD *func_name(void) \ - { \ - static const SSL_METHOD func_name##_data= { \ - SSL3_VERSION, \ - SSL_METHOD_NO_FIPS | SSL_METHOD_NO_SUITEB, \ - SSL_OP_NO_SSLv3, \ - ssl3_new, \ - ssl3_clear, \ - ssl3_free, \ - s_accept, \ - s_connect, \ - ssl3_read, \ - ssl3_peek, \ - ssl3_write, \ - ssl3_shutdown, \ - ssl3_renegotiate, \ - ssl3_renegotiate_check, \ - ssl3_read_bytes, \ - ssl3_write_bytes, \ - ssl3_dispatch_alert, \ - ssl3_ctrl, \ - ssl3_ctx_ctrl, \ - ssl3_get_cipher_by_char, \ - ssl3_put_cipher_by_char, \ - ssl3_pending, \ - ssl3_num_ciphers, \ - ssl3_get_cipher, \ - ssl3_default_timeout, \ - &SSLv3_enc_data, \ - ssl_undefined_void_function, \ - ssl3_callback_ctrl, \ - ssl3_ctx_callback_ctrl, \ - }; \ - return &func_name##_data; \ - } - -# define IMPLEMENT_dtls1_meth_func(version, flags, mask, func_name, s_accept, \ - s_connect, enc_data) \ -const SSL_METHOD *func_name(void) \ - { \ - static const SSL_METHOD func_name##_data= { \ - version, \ - flags, \ - mask, \ - dtls1_new, \ - dtls1_clear, \ - dtls1_free, \ - s_accept, \ - s_connect, \ - ssl3_read, \ - ssl3_peek, \ - ssl3_write, \ - dtls1_shutdown, \ - ssl3_renegotiate, \ - ssl3_renegotiate_check, \ - dtls1_read_bytes, \ - dtls1_write_app_data_bytes, \ - dtls1_dispatch_alert, \ - dtls1_ctrl, \ - ssl3_ctx_ctrl, \ - ssl3_get_cipher_by_char, \ - ssl3_put_cipher_by_char, \ - ssl3_pending, \ - ssl3_num_ciphers, \ - ssl3_get_cipher, \ - dtls1_default_timeout, \ - &enc_data, \ - ssl_undefined_void_function, \ - ssl3_callback_ctrl, \ - ssl3_ctx_callback_ctrl, \ - }; \ - return &func_name##_data; \ - } - -struct openssl_ssl_test_functions { - int (*p_ssl_init_wbio_buffer) (SSL *s); - int (*p_ssl3_setup_buffers) (SSL *s); -}; - -const char *ssl_protocol_to_string(int version); - -/* Returns true if certificate and private key for 'idx' are present */ -static ossl_inline int ssl_has_cert(const SSL *s, int idx) -{ - if (idx < 0 || idx >= SSL_PKEY_NUM) - return 0; - return s->cert->pkeys[idx].x509 != NULL - && s->cert->pkeys[idx].privatekey != NULL; -} - -static ossl_inline void tls1_get_peer_groups(SSL *s, const uint16_t **pgroups, - size_t *pgroupslen) -{ - *pgroups = s->ext.peer_supportedgroups; - *pgroupslen = s->ext.peer_supportedgroups_len; -} - -# ifndef OPENSSL_UNIT_TEST - -__owur int ssl_read_internal(SSL *s, void *buf, size_t num, size_t *readbytes); -__owur int ssl_write_internal(SSL *s, const void *buf, size_t num, size_t *written); -void ssl_clear_cipher_ctx(SSL *s); -int ssl_clear_bad_session(SSL *s); -__owur CERT *ssl_cert_new(void); -__owur CERT *ssl_cert_dup(CERT *cert); -void ssl_cert_clear_certs(CERT *c); -void ssl_cert_free(CERT *c); -__owur int ssl_generate_session_id(SSL *s, SSL_SESSION *ss); -__owur int ssl_get_new_session(SSL *s, int session); -__owur SSL_SESSION *lookup_sess_in_cache(SSL *s, const unsigned char *sess_id, - size_t sess_id_len); -__owur int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello); -__owur SSL_SESSION *ssl_session_dup(SSL_SESSION *src, int ticket); -__owur int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b); -DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, ssl_cipher_id); -__owur int ssl_cipher_ptr_id_cmp(const SSL_CIPHER *const *ap, - const SSL_CIPHER *const *bp); -__owur STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, - STACK_OF(SSL_CIPHER) *tls13_ciphersuites, - STACK_OF(SSL_CIPHER) **cipher_list, - STACK_OF(SSL_CIPHER) **cipher_list_by_id, - const char *rule_str, - CERT *c); -__owur int ssl_cache_cipherlist(SSL *s, PACKET *cipher_suites, int sslv2format); -__owur int bytes_to_cipher_list(SSL *s, PACKET *cipher_suites, - STACK_OF(SSL_CIPHER) **skp, - STACK_OF(SSL_CIPHER) **scsvs, int sslv2format, - int fatal); -void ssl_update_cache(SSL *s, int mode); -__owur int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, - const EVP_MD **md, int *mac_pkey_type, - size_t *mac_secret_size, SSL_COMP **comp, - int use_etm); -__owur int ssl_cipher_get_overhead(const SSL_CIPHER *c, size_t *mac_overhead, - size_t *int_overhead, size_t *blocksize, - size_t *ext_overhead); -__owur int ssl_cert_is_disabled(size_t idx); -__owur const SSL_CIPHER *ssl_get_cipher_by_char(SSL *ssl, - const unsigned char *ptr, - int all); -__owur int ssl_cert_set0_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain); -__owur int ssl_cert_set1_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain); -__owur int ssl_cert_add0_chain_cert(SSL *s, SSL_CTX *ctx, X509 *x); -__owur int ssl_cert_add1_chain_cert(SSL *s, SSL_CTX *ctx, X509 *x); -__owur int ssl_cert_select_current(CERT *c, X509 *x); -__owur int ssl_cert_set_current(CERT *c, long arg); -void ssl_cert_set_cert_cb(CERT *c, int (*cb) (SSL *ssl, void *arg), void *arg); - -__owur int ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *sk); -__owur int ssl_build_cert_chain(SSL *s, SSL_CTX *ctx, int flags); -__owur int ssl_cert_set_cert_store(CERT *c, X509_STORE *store, int chain, - int ref); - -__owur int ssl_security(const SSL *s, int op, int bits, int nid, void *other); -__owur int ssl_ctx_security(const SSL_CTX *ctx, int op, int bits, int nid, - void *other); + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved + * Copyright 2005 Nokia. All rights reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +#ifndef OSSL_SSL_LOCAL_H +# define OSSL_SSL_LOCAL_H + +# include "e_os.h" /* struct timeval for DTLS */ +# include <stdlib.h> +# include <time.h> +# include <string.h> +# include <errno.h> + +# include <openssl/buffer.h> +# include <openssl/comp.h> +# include <openssl/bio.h> +# include <openssl/rsa.h> +# include <openssl/dsa.h> +# include <openssl/err.h> +# include <openssl/ssl.h> +# include <openssl/async.h> +# include <openssl/symhacks.h> +# include <openssl/ct.h> +# include "record/record.h" +# include "statem/statem.h" +# include "packet_local.h" +# include "internal/dane.h" +# include "internal/refcount.h" +# include "internal/tsan_assist.h" + +# ifdef OPENSSL_BUILD_SHLIBSSL +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +# endif + +# define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \ + l|=(((unsigned long)(*((c)++)))<< 8), \ + l|=(((unsigned long)(*((c)++)))<<16), \ + l|=(((unsigned long)(*((c)++)))<<24)) + +/* NOTE - c is not incremented as per c2l */ +# define c2ln(c,l1,l2,n) { \ + c+=n; \ + l1=l2=0; \ + switch (n) { \ + case 8: l2 =((unsigned long)(*(--(c))))<<24; \ + case 7: l2|=((unsigned long)(*(--(c))))<<16; \ + case 6: l2|=((unsigned long)(*(--(c))))<< 8; \ + case 5: l2|=((unsigned long)(*(--(c)))); \ + case 4: l1 =((unsigned long)(*(--(c))))<<24; \ + case 3: l1|=((unsigned long)(*(--(c))))<<16; \ + case 2: l1|=((unsigned long)(*(--(c))))<< 8; \ + case 1: l1|=((unsigned long)(*(--(c)))); \ + } \ + } + +# define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24)&0xff)) + +# define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24, \ + l|=((unsigned long)(*((c)++)))<<16, \ + l|=((unsigned long)(*((c)++)))<< 8, \ + l|=((unsigned long)(*((c)++)))) + +# define n2l8(c,l) (l =((uint64_t)(*((c)++)))<<56, \ + l|=((uint64_t)(*((c)++)))<<48, \ + l|=((uint64_t)(*((c)++)))<<40, \ + l|=((uint64_t)(*((c)++)))<<32, \ + l|=((uint64_t)(*((c)++)))<<24, \ + l|=((uint64_t)(*((c)++)))<<16, \ + l|=((uint64_t)(*((c)++)))<< 8, \ + l|=((uint64_t)(*((c)++)))) + + +# define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +# define l2n6(l,c) (*((c)++)=(unsigned char)(((l)>>40)&0xff), \ + *((c)++)=(unsigned char)(((l)>>32)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +# define l2n8(l,c) (*((c)++)=(unsigned char)(((l)>>56)&0xff), \ + *((c)++)=(unsigned char)(((l)>>48)&0xff), \ + *((c)++)=(unsigned char)(((l)>>40)&0xff), \ + *((c)++)=(unsigned char)(((l)>>32)&0xff), \ + *((c)++)=(unsigned char)(((l)>>24)&0xff), \ + *((c)++)=(unsigned char)(((l)>>16)&0xff), \ + *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ + *((c)++)=(unsigned char)(((l) )&0xff)) + +/* NOTE - c is not incremented as per l2c */ +# define l2cn(l1,l2,c,n) { \ + c+=n; \ + switch (n) { \ + case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ + case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ + case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ + case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ + case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ + case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ + case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ + case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ + } \ + } + +# define n2s(c,s) ((s=(((unsigned int)((c)[0]))<< 8)| \ + (((unsigned int)((c)[1])) )),(c)+=2) +# define s2n(s,c) (((c)[0]=(unsigned char)(((s)>> 8)&0xff), \ + (c)[1]=(unsigned char)(((s) )&0xff)),(c)+=2) + +# define n2l3(c,l) ((l =(((unsigned long)((c)[0]))<<16)| \ + (((unsigned long)((c)[1]))<< 8)| \ + (((unsigned long)((c)[2])) )),(c)+=3) + +# define l2n3(l,c) (((c)[0]=(unsigned char)(((l)>>16)&0xff), \ + (c)[1]=(unsigned char)(((l)>> 8)&0xff), \ + (c)[2]=(unsigned char)(((l) )&0xff)),(c)+=3) + +/* + * DTLS version numbers are strange because they're inverted. Except for + * DTLS1_BAD_VER, which should be considered "lower" than the rest. + */ +# define dtls_ver_ordinal(v1) (((v1) == DTLS1_BAD_VER) ? 0xff00 : (v1)) +# define DTLS_VERSION_GT(v1, v2) (dtls_ver_ordinal(v1) < dtls_ver_ordinal(v2)) +# define DTLS_VERSION_GE(v1, v2) (dtls_ver_ordinal(v1) <= dtls_ver_ordinal(v2)) +# define DTLS_VERSION_LT(v1, v2) (dtls_ver_ordinal(v1) > dtls_ver_ordinal(v2)) +# define DTLS_VERSION_LE(v1, v2) (dtls_ver_ordinal(v1) >= dtls_ver_ordinal(v2)) + + +/* + * Define the Bitmasks for SSL_CIPHER.algorithms. + * This bits are used packed as dense as possible. If new methods/ciphers + * etc will be added, the bits a likely to change, so this information + * is for internal library use only, even though SSL_CIPHER.algorithms + * can be publicly accessed. + * Use the according functions for cipher management instead. + * + * The bit mask handling in the selection and sorting scheme in + * ssl_create_cipher_list() has only limited capabilities, reflecting + * that the different entities within are mutually exclusive: + * ONLY ONE BIT PER MASK CAN BE SET AT A TIME. + */ + +/* Bits for algorithm_mkey (key exchange algorithm) */ +/* RSA key exchange */ +# define SSL_kRSA 0x00000001U +/* tmp DH key no DH cert */ +# define SSL_kDHE 0x00000002U +/* synonym */ +# define SSL_kEDH SSL_kDHE +/* ephemeral ECDH */ +# define SSL_kECDHE 0x00000004U +/* synonym */ +# define SSL_kEECDH SSL_kECDHE +/* PSK */ +# define SSL_kPSK 0x00000008U +/* GOST key exchange */ +# define SSL_kGOST 0x00000010U +/* SRP */ +# define SSL_kSRP 0x00000020U + +# define SSL_kRSAPSK 0x00000040U +# define SSL_kECDHEPSK 0x00000080U +# define SSL_kDHEPSK 0x00000100U + +/* all PSK */ + +# define SSL_PSK (SSL_kPSK | SSL_kRSAPSK | SSL_kECDHEPSK | SSL_kDHEPSK) + +/* Any appropriate key exchange algorithm (for TLS 1.3 ciphersuites) */ +# define SSL_kANY 0x00000000U + +/* Bits for algorithm_auth (server authentication) */ +/* RSA auth */ +# define SSL_aRSA 0x00000001U +/* DSS auth */ +# define SSL_aDSS 0x00000002U +/* no auth (i.e. use ADH or AECDH) */ +# define SSL_aNULL 0x00000004U +/* ECDSA auth*/ +# define SSL_aECDSA 0x00000008U +/* PSK auth */ +# define SSL_aPSK 0x00000010U +/* GOST R 34.10-2001 signature auth */ +# define SSL_aGOST01 0x00000020U +/* SRP auth */ +# define SSL_aSRP 0x00000040U +/* GOST R 34.10-2012 signature auth */ +# define SSL_aGOST12 0x00000080U +/* Any appropriate signature auth (for TLS 1.3 ciphersuites) */ +# define SSL_aANY 0x00000000U +/* All bits requiring a certificate */ +#define SSL_aCERT \ + (SSL_aRSA | SSL_aDSS | SSL_aECDSA | SSL_aGOST01 | SSL_aGOST12) + +/* Bits for algorithm_enc (symmetric encryption) */ +# define SSL_DES 0x00000001U +# define SSL_3DES 0x00000002U +# define SSL_RC4 0x00000004U +# define SSL_RC2 0x00000008U +# define SSL_IDEA 0x00000010U +# define SSL_eNULL 0x00000020U +# define SSL_AES128 0x00000040U +# define SSL_AES256 0x00000080U +# define SSL_CAMELLIA128 0x00000100U +# define SSL_CAMELLIA256 0x00000200U +# define SSL_eGOST2814789CNT 0x00000400U +# define SSL_SEED 0x00000800U +# define SSL_AES128GCM 0x00001000U +# define SSL_AES256GCM 0x00002000U +# define SSL_AES128CCM 0x00004000U +# define SSL_AES256CCM 0x00008000U +# define SSL_AES128CCM8 0x00010000U +# define SSL_AES256CCM8 0x00020000U +# define SSL_eGOST2814789CNT12 0x00040000U +# define SSL_CHACHA20POLY1305 0x00080000U +# define SSL_ARIA128GCM 0x00100000U +# define SSL_ARIA256GCM 0x00200000U + +# define SSL_AESGCM (SSL_AES128GCM | SSL_AES256GCM) +# define SSL_AESCCM (SSL_AES128CCM | SSL_AES256CCM | SSL_AES128CCM8 | SSL_AES256CCM8) +# define SSL_AES (SSL_AES128|SSL_AES256|SSL_AESGCM|SSL_AESCCM) +# define SSL_CAMELLIA (SSL_CAMELLIA128|SSL_CAMELLIA256) +# define SSL_CHACHA20 (SSL_CHACHA20POLY1305) +# define SSL_ARIAGCM (SSL_ARIA128GCM | SSL_ARIA256GCM) +# define SSL_ARIA (SSL_ARIAGCM) + +/* Bits for algorithm_mac (symmetric authentication) */ + +# define SSL_MD5 0x00000001U +# define SSL_SHA1 0x00000002U +# define SSL_GOST94 0x00000004U +# define SSL_GOST89MAC 0x00000008U +# define SSL_SHA256 0x00000010U +# define SSL_SHA384 0x00000020U +/* Not a real MAC, just an indication it is part of cipher */ +# define SSL_AEAD 0x00000040U +# define SSL_GOST12_256 0x00000080U +# define SSL_GOST89MAC12 0x00000100U +# define SSL_GOST12_512 0x00000200U + +/* + * When adding new digest in the ssl_ciph.c and increment SSL_MD_NUM_IDX make + * sure to update this constant too + */ + +# define SSL_MD_MD5_IDX 0 +# define SSL_MD_SHA1_IDX 1 +# define SSL_MD_GOST94_IDX 2 +# define SSL_MD_GOST89MAC_IDX 3 +# define SSL_MD_SHA256_IDX 4 +# define SSL_MD_SHA384_IDX 5 +# define SSL_MD_GOST12_256_IDX 6 +# define SSL_MD_GOST89MAC12_IDX 7 +# define SSL_MD_GOST12_512_IDX 8 +# define SSL_MD_MD5_SHA1_IDX 9 +# define SSL_MD_SHA224_IDX 10 +# define SSL_MD_SHA512_IDX 11 +# define SSL_MAX_DIGEST 12 + +/* Bits for algorithm2 (handshake digests and other extra flags) */ + +/* Bits 0-7 are handshake MAC */ +# define SSL_HANDSHAKE_MAC_MASK 0xFF +# define SSL_HANDSHAKE_MAC_MD5_SHA1 SSL_MD_MD5_SHA1_IDX +# define SSL_HANDSHAKE_MAC_SHA256 SSL_MD_SHA256_IDX +# define SSL_HANDSHAKE_MAC_SHA384 SSL_MD_SHA384_IDX +# define SSL_HANDSHAKE_MAC_GOST94 SSL_MD_GOST94_IDX +# define SSL_HANDSHAKE_MAC_GOST12_256 SSL_MD_GOST12_256_IDX +# define SSL_HANDSHAKE_MAC_GOST12_512 SSL_MD_GOST12_512_IDX +# define SSL_HANDSHAKE_MAC_DEFAULT SSL_HANDSHAKE_MAC_MD5_SHA1 + +/* Bits 8-15 bits are PRF */ +# define TLS1_PRF_DGST_SHIFT 8 +# define TLS1_PRF_SHA1_MD5 (SSL_MD_MD5_SHA1_IDX << TLS1_PRF_DGST_SHIFT) +# define TLS1_PRF_SHA256 (SSL_MD_SHA256_IDX << TLS1_PRF_DGST_SHIFT) +# define TLS1_PRF_SHA384 (SSL_MD_SHA384_IDX << TLS1_PRF_DGST_SHIFT) +# define TLS1_PRF_GOST94 (SSL_MD_GOST94_IDX << TLS1_PRF_DGST_SHIFT) +# define TLS1_PRF_GOST12_256 (SSL_MD_GOST12_256_IDX << TLS1_PRF_DGST_SHIFT) +# define TLS1_PRF_GOST12_512 (SSL_MD_GOST12_512_IDX << TLS1_PRF_DGST_SHIFT) +# define TLS1_PRF (SSL_MD_MD5_SHA1_IDX << TLS1_PRF_DGST_SHIFT) + +/* + * Stream MAC for GOST ciphersuites from cryptopro draft (currently this also + * goes into algorithm2) + */ +# define TLS1_STREAM_MAC 0x10000 + +# define SSL_STRONG_MASK 0x0000001FU +# define SSL_DEFAULT_MASK 0X00000020U + +# define SSL_STRONG_NONE 0x00000001U +# define SSL_LOW 0x00000002U +# define SSL_MEDIUM 0x00000004U +# define SSL_HIGH 0x00000008U +# define SSL_FIPS 0x00000010U +# define SSL_NOT_DEFAULT 0x00000020U + +/* we have used 0000003f - 26 bits left to go */ + +/* Flag used on OpenSSL ciphersuite ids to indicate they are for SSLv3+ */ +# define SSL3_CK_CIPHERSUITE_FLAG 0x03000000 + +/* Check if an SSL structure is using DTLS */ +# define SSL_IS_DTLS(s) (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS) + +/* Check if we are using TLSv1.3 */ +# define SSL_IS_TLS13(s) (!SSL_IS_DTLS(s) \ + && (s)->method->version >= TLS1_3_VERSION \ + && (s)->method->version != TLS_ANY_VERSION) + +# define SSL_TREAT_AS_TLS13(s) \ + (SSL_IS_TLS13(s) || (s)->early_data_state == SSL_EARLY_DATA_CONNECTING \ + || (s)->early_data_state == SSL_EARLY_DATA_CONNECT_RETRY \ + || (s)->early_data_state == SSL_EARLY_DATA_WRITING \ + || (s)->early_data_state == SSL_EARLY_DATA_WRITE_RETRY \ + || (s)->hello_retry_request == SSL_HRR_PENDING) + +# define SSL_IS_FIRST_HANDSHAKE(S) ((s)->s3->tmp.finish_md_len == 0 \ + || (s)->s3->tmp.peer_finish_md_len == 0) + +/* See if we need explicit IV */ +# define SSL_USE_EXPLICIT_IV(s) \ + (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_EXPLICIT_IV) +/* + * See if we use signature algorithms extension and signature algorithm + * before signatures. + */ +# define SSL_USE_SIGALGS(s) \ + (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SIGALGS) +/* + * Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2: may + * apply to others in future. + */ +# define SSL_USE_TLS1_2_CIPHERS(s) \ + (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_TLS1_2_CIPHERS) +/* + * Determine if a client can use TLS 1.2 ciphersuites: can't rely on method + * flags because it may not be set to correct version yet. + */ +# define SSL_CLIENT_USE_TLS1_2_CIPHERS(s) \ + ((!SSL_IS_DTLS(s) && s->client_version >= TLS1_2_VERSION) || \ + (SSL_IS_DTLS(s) && DTLS_VERSION_GE(s->client_version, DTLS1_2_VERSION))) +/* + * Determine if a client should send signature algorithms extension: + * as with TLS1.2 cipher we can't rely on method flags. + */ +# define SSL_CLIENT_USE_SIGALGS(s) \ + SSL_CLIENT_USE_TLS1_2_CIPHERS(s) + +# define IS_MAX_FRAGMENT_LENGTH_EXT_VALID(value) \ + (((value) >= TLSEXT_max_fragment_length_512) && \ + ((value) <= TLSEXT_max_fragment_length_4096)) +# define USE_MAX_FRAGMENT_LENGTH_EXT(session) \ + IS_MAX_FRAGMENT_LENGTH_EXT_VALID(session->ext.max_fragment_len_mode) +# define GET_MAX_FRAGMENT_LENGTH(session) \ + (512U << (session->ext.max_fragment_len_mode - 1)) + +# define SSL_READ_ETM(s) (s->s3->flags & TLS1_FLAGS_ENCRYPT_THEN_MAC_READ) +# define SSL_WRITE_ETM(s) (s->s3->flags & TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE) + +/* Mostly for SSLv3 */ +# define SSL_PKEY_RSA 0 +# define SSL_PKEY_RSA_PSS_SIGN 1 +# define SSL_PKEY_DSA_SIGN 2 +# define SSL_PKEY_ECC 3 +# define SSL_PKEY_GOST01 4 +# define SSL_PKEY_GOST12_256 5 +# define SSL_PKEY_GOST12_512 6 +# define SSL_PKEY_ED25519 7 +# define SSL_PKEY_ED448 8 +# define SSL_PKEY_NUM 9 + +/*- + * SSL_kRSA <- RSA_ENC + * SSL_kDH <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN) + * SSL_kDHE <- RSA_ENC | RSA_SIGN | DSA_SIGN + * SSL_aRSA <- RSA_ENC | RSA_SIGN + * SSL_aDSS <- DSA_SIGN + */ + +/*- +#define CERT_INVALID 0 +#define CERT_PUBLIC_KEY 1 +#define CERT_PRIVATE_KEY 2 +*/ + +/* Post-Handshake Authentication state */ +typedef enum { + SSL_PHA_NONE = 0, + SSL_PHA_EXT_SENT, /* client-side only: extension sent */ + SSL_PHA_EXT_RECEIVED, /* server-side only: extension received */ + SSL_PHA_REQUEST_PENDING, /* server-side only: request pending */ + SSL_PHA_REQUESTED /* request received by client, or sent by server */ +} SSL_PHA_STATE; + +/* CipherSuite length. SSLv3 and all TLS versions. */ +# define TLS_CIPHER_LEN 2 +/* used to hold info on the particular ciphers used */ +struct ssl_cipher_st { + uint32_t valid; + const char *name; /* text name */ + const char *stdname; /* RFC name */ + uint32_t id; /* id, 4 bytes, first is version */ + /* + * changed in 1.0.0: these four used to be portions of a single value + * 'algorithms' + */ + uint32_t algorithm_mkey; /* key exchange algorithm */ + uint32_t algorithm_auth; /* server authentication */ + uint32_t algorithm_enc; /* symmetric encryption */ + uint32_t algorithm_mac; /* symmetric authentication */ + int min_tls; /* minimum SSL/TLS protocol version */ + int max_tls; /* maximum SSL/TLS protocol version */ + int min_dtls; /* minimum DTLS protocol version */ + int max_dtls; /* maximum DTLS protocol version */ + uint32_t algo_strength; /* strength and export flags */ + uint32_t algorithm2; /* Extra flags */ + int32_t strength_bits; /* Number of bits really used */ + uint32_t alg_bits; /* Number of bits for algorithm */ +}; + +/* Used to hold SSL/TLS functions */ +struct ssl_method_st { + int version; + unsigned flags; + unsigned long mask; + int (*ssl_new) (SSL *s); + int (*ssl_clear) (SSL *s); + void (*ssl_free) (SSL *s); + int (*ssl_accept) (SSL *s); + int (*ssl_connect) (SSL *s); + int (*ssl_read) (SSL *s, void *buf, size_t len, size_t *readbytes); + int (*ssl_peek) (SSL *s, void *buf, size_t len, size_t *readbytes); + int (*ssl_write) (SSL *s, const void *buf, size_t len, size_t *written); + int (*ssl_shutdown) (SSL *s); + int (*ssl_renegotiate) (SSL *s); + int (*ssl_renegotiate_check) (SSL *s, int); + int (*ssl_read_bytes) (SSL *s, int type, int *recvd_type, + unsigned char *buf, size_t len, int peek, + size_t *readbytes); + int (*ssl_write_bytes) (SSL *s, int type, const void *buf_, size_t len, + size_t *written); + int (*ssl_dispatch_alert) (SSL *s); + long (*ssl_ctrl) (SSL *s, int cmd, long larg, void *parg); + long (*ssl_ctx_ctrl) (SSL_CTX *ctx, int cmd, long larg, void *parg); + const SSL_CIPHER *(*get_cipher_by_char) (const unsigned char *ptr); + int (*put_cipher_by_char) (const SSL_CIPHER *cipher, WPACKET *pkt, + size_t *len); + size_t (*ssl_pending) (const SSL *s); + int (*num_ciphers) (void); + const SSL_CIPHER *(*get_cipher) (unsigned ncipher); + long (*get_timeout) (void); + const struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ + int (*ssl_version) (void); + long (*ssl_callback_ctrl) (SSL *s, int cb_id, void (*fp) (void)); + long (*ssl_ctx_callback_ctrl) (SSL_CTX *s, int cb_id, void (*fp) (void)); +}; + +/* + * Matches the length of PSK_MAX_PSK_LEN. We keep it the same value for + * consistency, even in the event of OPENSSL_NO_PSK being defined. + */ +# define TLS13_MAX_RESUMPTION_PSK_LENGTH 256 + +/*- + * Lets make this into an ASN.1 type structure as follows + * SSL_SESSION_ID ::= SEQUENCE { + * version INTEGER, -- structure version number + * SSLversion INTEGER, -- SSL version number + * Cipher OCTET STRING, -- the 3 byte cipher ID + * Session_ID OCTET STRING, -- the Session ID + * Master_key OCTET STRING, -- the master key + * Key_Arg [ 0 ] IMPLICIT OCTET STRING, -- the optional Key argument + * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time + * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds + * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate + * Session_ID_context [ 4 ] EXPLICIT OCTET STRING, -- the Session ID context + * Verify_result [ 5 ] EXPLICIT INTEGER, -- X509_V_... code for `Peer' + * HostName [ 6 ] EXPLICIT OCTET STRING, -- optional HostName from servername TLS extension + * PSK_identity_hint [ 7 ] EXPLICIT OCTET STRING, -- optional PSK identity hint + * PSK_identity [ 8 ] EXPLICIT OCTET STRING, -- optional PSK identity + * Ticket_lifetime_hint [9] EXPLICIT INTEGER, -- server's lifetime hint for session ticket + * Ticket [10] EXPLICIT OCTET STRING, -- session ticket (clients only) + * Compression_meth [11] EXPLICIT OCTET STRING, -- optional compression method + * SRP_username [ 12 ] EXPLICIT OCTET STRING -- optional SRP username + * flags [ 13 ] EXPLICIT INTEGER -- optional flags + * } + * Look in ssl/ssl_asn1.c for more details + * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). + */ +struct ssl_session_st { + int ssl_version; /* what ssl version session info is being kept + * in here? */ + size_t master_key_length; + + /* TLSv1.3 early_secret used for external PSKs */ + unsigned char early_secret[EVP_MAX_MD_SIZE]; + /* + * For <=TLS1.2 this is the master_key. For TLS1.3 this is the resumption + * PSK + */ + unsigned char master_key[TLS13_MAX_RESUMPTION_PSK_LENGTH]; + /* session_id - valid? */ + size_t session_id_length; + unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; + /* + * this is used to determine whether the session is being reused in the + * appropriate context. It is up to the application to set this, via + * SSL_new + */ + size_t sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; +# ifndef OPENSSL_NO_PSK + char *psk_identity_hint; + char *psk_identity; +# endif + /* + * Used to indicate that session resumption is not allowed. Applications + * can also set this bit for a new session via not_resumable_session_cb + * to disable session caching and tickets. + */ + int not_resumable; + /* This is the cert and type for the other end. */ + X509 *peer; + /* Certificate chain peer sent. */ + STACK_OF(X509) *peer_chain; + /* + * when app_verify_callback accepts a session where the peer's + * certificate is not ok, we must remember the error for session reuse: + */ + long verify_result; /* only for servers */ + CRYPTO_REF_COUNT references; + long timeout; + long time; + unsigned int compress_meth; /* Need to lookup the method */ + const SSL_CIPHER *cipher; + unsigned long cipher_id; /* when ASN.1 loaded, this needs to be used to + * load the 'cipher' structure */ + CRYPTO_EX_DATA ex_data; /* application specific data */ + /* + * These are used to make removal of session-ids more efficient and to + * implement a maximum cache size. + */ + struct ssl_session_st *prev, *next; + + struct { + char *hostname; + /* RFC4507 info */ + unsigned char *tick; /* Session ticket */ + size_t ticklen; /* Session ticket length */ + /* Session lifetime hint in seconds */ + unsigned long tick_lifetime_hint; + uint32_t tick_age_add; + /* Max number of bytes that can be sent as early data */ + uint32_t max_early_data; + /* The ALPN protocol selected for this session */ + unsigned char *alpn_selected; + size_t alpn_selected_len; + /* + * Maximum Fragment Length as per RFC 4366. + * If this value does not contain RFC 4366 allowed values (1-4) then + * either the Maximum Fragment Length Negotiation failed or was not + * performed at all. + */ + uint8_t max_fragment_len_mode; + } ext; +# ifndef OPENSSL_NO_SRP + char *srp_username; +# endif + unsigned char *ticket_appdata; + size_t ticket_appdata_len; + uint32_t flags; + CRYPTO_RWLOCK *lock; +}; + +/* Extended master secret support */ +# define SSL_SESS_FLAG_EXTMS 0x1 + +# ifndef OPENSSL_NO_SRP + +typedef struct srp_ctx_st { + /* param for all the callbacks */ + void *SRP_cb_arg; + /* set client Hello login callback */ + int (*TLS_ext_srp_username_callback) (SSL *, int *, void *); + /* set SRP N/g param callback for verification */ + int (*SRP_verify_param_callback) (SSL *, void *); + /* set SRP client passwd callback */ + char *(*SRP_give_srp_client_pwd_callback) (SSL *, void *); + char *login; + BIGNUM *N, *g, *s, *B, *A; + BIGNUM *a, *b, *v; + char *info; + int strength; + unsigned long srp_Mask; +} SRP_CTX; + +# endif + +typedef enum { + SSL_EARLY_DATA_NONE = 0, + SSL_EARLY_DATA_CONNECT_RETRY, + SSL_EARLY_DATA_CONNECTING, + SSL_EARLY_DATA_WRITE_RETRY, + SSL_EARLY_DATA_WRITING, + SSL_EARLY_DATA_WRITE_FLUSH, + SSL_EARLY_DATA_UNAUTH_WRITING, + SSL_EARLY_DATA_FINISHED_WRITING, + SSL_EARLY_DATA_ACCEPT_RETRY, + SSL_EARLY_DATA_ACCEPTING, + SSL_EARLY_DATA_READ_RETRY, + SSL_EARLY_DATA_READING, + SSL_EARLY_DATA_FINISHED_READING +} SSL_EARLY_DATA_STATE; + +/* + * We check that the amount of unreadable early data doesn't exceed + * max_early_data. max_early_data is given in plaintext bytes. However if it is + * unreadable then we only know the number of ciphertext bytes. We also don't + * know how much the overhead should be because it depends on the ciphersuite. + * We make a small allowance. We assume 5 records of actual data plus the end + * of early data alert record. Each record has a tag and a content type byte. + * The longest tag length we know of is EVP_GCM_TLS_TAG_LEN. We don't count the + * content of the alert record either which is 2 bytes. + */ +# define EARLY_DATA_CIPHERTEXT_OVERHEAD ((6 * (EVP_GCM_TLS_TAG_LEN + 1)) + 2) + +/* + * The allowance we have between the client's calculated ticket age and our own. + * We allow for 10 seconds (units are in ms). If a ticket is presented and the + * client's age calculation is different by more than this than our own then we + * do not allow that ticket for early_data. + */ +# define TICKET_AGE_ALLOWANCE (10 * 1000) + +#define MAX_COMPRESSIONS_SIZE 255 + +struct ssl_comp_st { + int id; + const char *name; + COMP_METHOD *method; +}; + +typedef struct raw_extension_st { + /* Raw packet data for the extension */ + PACKET data; + /* Set to 1 if the extension is present or 0 otherwise */ + int present; + /* Set to 1 if we have already parsed the extension or 0 otherwise */ + int parsed; + /* The type of this extension, i.e. a TLSEXT_TYPE_* value */ + unsigned int type; + /* Track what order extensions are received in (0-based). */ + size_t received_order; +} RAW_EXTENSION; + +typedef struct { + unsigned int isv2; + unsigned int legacy_version; + unsigned char random[SSL3_RANDOM_SIZE]; + size_t session_id_len; + unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; + size_t dtls_cookie_len; + unsigned char dtls_cookie[DTLS1_COOKIE_LENGTH]; + PACKET ciphersuites; + size_t compressions_len; + unsigned char compressions[MAX_COMPRESSIONS_SIZE]; + PACKET extensions; + size_t pre_proc_exts_len; + RAW_EXTENSION *pre_proc_exts; +} CLIENTHELLO_MSG; + +/* + * Extension index values NOTE: Any updates to these defines should be mirrored + * with equivalent updates to ext_defs in extensions.c + */ +typedef enum tlsext_index_en { + TLSEXT_IDX_renegotiate, + TLSEXT_IDX_server_name, + TLSEXT_IDX_max_fragment_length, + TLSEXT_IDX_srp, + TLSEXT_IDX_ec_point_formats, + TLSEXT_IDX_supported_groups, + TLSEXT_IDX_session_ticket, + TLSEXT_IDX_status_request, + TLSEXT_IDX_next_proto_neg, + TLSEXT_IDX_application_layer_protocol_negotiation, + TLSEXT_IDX_use_srtp, + TLSEXT_IDX_encrypt_then_mac, + TLSEXT_IDX_signed_certificate_timestamp, + TLSEXT_IDX_extended_master_secret, + TLSEXT_IDX_signature_algorithms_cert, + TLSEXT_IDX_post_handshake_auth, + TLSEXT_IDX_signature_algorithms, + TLSEXT_IDX_supported_versions, + TLSEXT_IDX_psk_kex_modes, + TLSEXT_IDX_key_share, + TLSEXT_IDX_cookie, + TLSEXT_IDX_cryptopro_bug, + TLSEXT_IDX_early_data, + TLSEXT_IDX_certificate_authorities, + TLSEXT_IDX_padding, + TLSEXT_IDX_psk, + /* Dummy index - must always be the last entry */ + TLSEXT_IDX_num_builtins +} TLSEXT_INDEX; + +DEFINE_LHASH_OF(SSL_SESSION); +/* Needed in ssl_cert.c */ +DEFINE_LHASH_OF(X509_NAME); + +# define TLSEXT_KEYNAME_LENGTH 16 +# define TLSEXT_TICK_KEY_LENGTH 32 + +typedef struct ssl_ctx_ext_secure_st { + unsigned char tick_hmac_key[TLSEXT_TICK_KEY_LENGTH]; + unsigned char tick_aes_key[TLSEXT_TICK_KEY_LENGTH]; +} SSL_CTX_EXT_SECURE; + +struct ssl_ctx_st { + const SSL_METHOD *method; + STACK_OF(SSL_CIPHER) *cipher_list; + /* same as above but sorted for lookup */ + STACK_OF(SSL_CIPHER) *cipher_list_by_id; + /* TLSv1.3 specific ciphersuites */ + STACK_OF(SSL_CIPHER) *tls13_ciphersuites; + struct x509_store_st /* X509_STORE */ *cert_store; + LHASH_OF(SSL_SESSION) *sessions; + /* + * Most session-ids that will be cached, default is + * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. + */ + size_t session_cache_size; + struct ssl_session_st *session_cache_head; + struct ssl_session_st *session_cache_tail; + /* + * This can have one of 2 values, ored together, SSL_SESS_CACHE_CLIENT, + * SSL_SESS_CACHE_SERVER, Default is SSL_SESSION_CACHE_SERVER, which + * means only SSL_accept will cache SSL_SESSIONS. + */ + uint32_t session_cache_mode; + /* + * 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; + /* + * If this callback is not null, it will be called each time a session id + * is added to the cache. If this function returns 1, it means that the + * callback will do a SSL_SESSION_free() when it has finished using it. + * Otherwise, on 0, it means the callback has finished with it. If + * remove_session_cb is not null, it will be called when a session-id is + * removed from the cache. After the call, OpenSSL will + * SSL_SESSION_free() it. + */ + int (*new_session_cb) (struct ssl_st *ssl, SSL_SESSION *sess); + void (*remove_session_cb) (struct ssl_ctx_st *ctx, SSL_SESSION *sess); + SSL_SESSION *(*get_session_cb) (struct ssl_st *ssl, + const unsigned char *data, int len, + int *copy); + struct { + TSAN_QUALIFIER int sess_connect; /* SSL new conn - started */ + TSAN_QUALIFIER int sess_connect_renegotiate; /* SSL reneg - requested */ + TSAN_QUALIFIER int sess_connect_good; /* SSL new conne/reneg - finished */ + TSAN_QUALIFIER int sess_accept; /* SSL new accept - started */ + TSAN_QUALIFIER int sess_accept_renegotiate; /* SSL reneg - requested */ + TSAN_QUALIFIER int sess_accept_good; /* SSL accept/reneg - finished */ + TSAN_QUALIFIER int sess_miss; /* session lookup misses */ + TSAN_QUALIFIER int sess_timeout; /* reuse attempt on timeouted session */ + TSAN_QUALIFIER int sess_cache_full; /* session removed due to full cache */ + TSAN_QUALIFIER int sess_hit; /* session reuse actually done */ + TSAN_QUALIFIER int sess_cb_hit; /* session-id that was not in + * the cache was passed back via + * the callback. This indicates + * that the application is + * supplying session-id's from + * other processes - spooky + * :-) */ + } stats; + + CRYPTO_REF_COUNT references; + + /* if defined, these override the X509_verify_cert() calls */ + int (*app_verify_callback) (X509_STORE_CTX *, void *); + void *app_verify_arg; + /* + * before OpenSSL 0.9.7, 'app_verify_arg' was ignored + * ('app_verify_callback' was called with just one argument) + */ + + /* Default password callback. */ + pem_password_cb *default_passwd_callback; + + /* Default password callback user data. */ + void *default_passwd_callback_userdata; + + /* get client cert callback */ + int (*client_cert_cb) (SSL *ssl, X509 **x509, EVP_PKEY **pkey); + + /* cookie generate callback */ + int (*app_gen_cookie_cb) (SSL *ssl, unsigned char *cookie, + unsigned int *cookie_len); + + /* verify cookie callback */ + int (*app_verify_cookie_cb) (SSL *ssl, const unsigned char *cookie, + unsigned int cookie_len); + + /* TLS1.3 app-controlled cookie generate callback */ + int (*gen_stateless_cookie_cb) (SSL *ssl, unsigned char *cookie, + size_t *cookie_len); + + /* TLS1.3 verify app-controlled cookie callback */ + int (*verify_stateless_cookie_cb) (SSL *ssl, const unsigned char *cookie, + size_t cookie_len); + + CRYPTO_EX_DATA ex_data; + + const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */ + const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ + + STACK_OF(X509) *extra_certs; + STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */ + + /* Default values used when no per-SSL value is defined follow */ + + /* used if SSL's info_callback is NULL */ + void (*info_callback) (const SSL *ssl, int type, int val); + + /* + * What we put in certificate_authorities extension for TLS 1.3 + * (ClientHello and CertificateRequest) or just client cert requests for + * earlier versions. If client_ca_names is populated then it is only used + * for client cert requests, and in preference to ca_names. + */ + STACK_OF(X509_NAME) *ca_names; + STACK_OF(X509_NAME) *client_ca_names; + + /* + * Default values to use in SSL structures follow (these are copied by + * SSL_new) + */ + + uint32_t options; + uint32_t mode; + int min_proto_version; + int max_proto_version; + size_t max_cert_list; + + struct cert_st /* CERT */ *cert; + int read_ahead; + + /* callback that allows applications to peek at protocol messages */ + void (*msg_callback) (int write_p, int version, int content_type, + const void *buf, size_t len, SSL *ssl, void *arg); + void *msg_callback_arg; + + uint32_t verify_mode; + size_t sid_ctx_length; + unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; + /* called 'verify_callback' in the SSL */ + int (*default_verify_callback) (int ok, X509_STORE_CTX *ctx); + + /* Default generate session ID callback. */ + GEN_SESSION_CB generate_session_id; + + X509_VERIFY_PARAM *param; + + int quiet_shutdown; + +# ifndef OPENSSL_NO_CT + CTLOG_STORE *ctlog_store; /* CT Log Store */ + /* + * Validates that the SCTs (Signed Certificate Timestamps) are sufficient. + * If they are not, the connection should be aborted. + */ + ssl_ct_validation_cb ct_validation_callback; + void *ct_validation_callback_arg; +# endif + + /* + * If we're using more than one pipeline how should we divide the data + * up between the pipes? + */ + size_t split_send_fragment; + /* + * Maximum amount of data to send in one fragment. actual record size can + * be more than this due to padding and MAC overheads. + */ + size_t max_send_fragment; + + /* Up to how many pipelines should we use? If 0 then 1 is assumed */ + size_t max_pipelines; + + /* The default read buffer length to use (0 means not set) */ + size_t default_read_buf_len; + +# ifndef OPENSSL_NO_ENGINE + /* + * Engine to pass requests for client certs to + */ + ENGINE *client_cert_engine; +# endif + + /* ClientHello callback. Mostly for extensions, but not entirely. */ + SSL_client_hello_cb_fn client_hello_cb; + void *client_hello_cb_arg; + + /* TLS extensions. */ + struct { + /* TLS extensions servername callback */ + int (*servername_cb) (SSL *, int *, void *); + void *servername_arg; + /* RFC 4507 session ticket keys */ + unsigned char tick_key_name[TLSEXT_KEYNAME_LENGTH]; + SSL_CTX_EXT_SECURE *secure; + /* Callback to support customisation of ticket key setting */ + int (*ticket_key_cb) (SSL *ssl, + unsigned char *name, unsigned char *iv, + EVP_CIPHER_CTX *ectx, HMAC_CTX *hctx, int enc); + + /* certificate status request info */ + /* Callback for status request */ + int (*status_cb) (SSL *ssl, void *arg); + void *status_arg; + /* ext status type used for CSR extension (OCSP Stapling) */ + int status_type; + /* RFC 4366 Maximum Fragment Length Negotiation */ + uint8_t max_fragment_len_mode; + +# ifndef OPENSSL_NO_EC + /* EC extension values inherited by SSL structure */ + size_t ecpointformats_len; + unsigned char *ecpointformats; + size_t supportedgroups_len; + uint16_t *supportedgroups; +# endif /* OPENSSL_NO_EC */ + + /* + * ALPN information (we are in the process of transitioning from NPN to + * ALPN.) + */ + + /*- + * For a server, this contains a callback function that allows the + * server to select the protocol for the connection. + * out: on successful return, this must point to the raw protocol + * name (without the length prefix). + * outlen: on successful return, this contains the length of |*out|. + * in: points to the client's list of supported protocols in + * wire-format. + * inlen: the length of |in|. + */ + int (*alpn_select_cb) (SSL *s, + const unsigned char **out, + unsigned char *outlen, + const unsigned char *in, + unsigned int inlen, void *arg); + void *alpn_select_cb_arg; + + /* + * For a client, this contains the list of supported protocols in wire + * format. + */ + unsigned char *alpn; + size_t alpn_len; + +# ifndef OPENSSL_NO_NEXTPROTONEG + /* Next protocol negotiation information */ + + /* + * For a server, this contains a callback function by which the set of + * advertised protocols can be provided. + */ + SSL_CTX_npn_advertised_cb_func npn_advertised_cb; + void *npn_advertised_cb_arg; + /* + * For a client, this contains a callback function that selects the next + * protocol from the list provided by the server. + */ + SSL_CTX_npn_select_cb_func npn_select_cb; + void *npn_select_cb_arg; +# endif + + unsigned char cookie_hmac_key[SHA256_DIGEST_LENGTH]; + } ext; + +# ifndef OPENSSL_NO_PSK + SSL_psk_client_cb_func psk_client_callback; + SSL_psk_server_cb_func psk_server_callback; +# endif + SSL_psk_find_session_cb_func psk_find_session_cb; + SSL_psk_use_session_cb_func psk_use_session_cb; + +# ifndef OPENSSL_NO_SRP + SRP_CTX srp_ctx; /* ctx for SRP authentication */ +# endif + + /* Shared DANE context */ + struct dane_ctx_st dane; + +# ifndef OPENSSL_NO_SRTP + /* SRTP profiles we are willing to do from RFC 5764 */ + STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles; +# endif + /* + * Callback for disabling session caching and ticket support on a session + * basis, depending on the chosen cipher. + */ + int (*not_resumable_session_cb) (SSL *ssl, int is_forward_secure); + + CRYPTO_RWLOCK *lock; + + /* + * Callback for logging key material for use with debugging tools like + * Wireshark. The callback should log `line` followed by a newline. + */ + SSL_CTX_keylog_cb_func keylog_callback; + + /* + * The maximum number of bytes advertised in session tickets that can be + * sent as early data. + */ + uint32_t max_early_data; + + /* + * The maximum number of bytes of early data that a server will tolerate + * (which should be at least as much as max_early_data). + */ + uint32_t recv_max_early_data; + + /* TLS1.3 padding callback */ + size_t (*record_padding_cb)(SSL *s, int type, size_t len, void *arg); + void *record_padding_arg; + size_t block_padding; + + /* Session ticket appdata */ + SSL_CTX_generate_session_ticket_fn generate_ticket_cb; + SSL_CTX_decrypt_session_ticket_fn decrypt_ticket_cb; + void *ticket_cb_data; + + /* The number of TLS1.3 tickets to automatically send */ + size_t num_tickets; + + /* Callback to determine if early_data is acceptable or not */ + SSL_allow_early_data_cb_fn allow_early_data_cb; + void *allow_early_data_cb_data; + + /* Do we advertise Post-handshake auth support? */ + int pha_enabled; +}; + +struct ssl_st { + /* + * protocol version (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION, + * DTLS1_VERSION) + */ + int version; + /* SSLv3 */ + const SSL_METHOD *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 + */ + /* used by SSL_read */ + BIO *rbio; + /* used by SSL_write */ + BIO *wbio; + /* used during session-id reuse to concatenate messages */ + BIO *bbio; + /* + * This holds a variable that indicates what we were doing when a 0 or -1 + * is returned. This is needed for non-blocking IO so we know what + * request needs re-doing when in SSL_accept or SSL_connect + */ + int rwstate; + int (*handshake_func) (SSL *); + /* + * Imagine that here's a boolean member "init" that is switched as soon + * as SSL_set_{accept/connect}_state is called for the first time, so + * that "state" and "handshake_func" are properly initialized. But as + * handshake_func is == 0 until then, we use this test instead of an + * "init" member. + */ + /* are we the server side? */ + int server; + /* + * Generate a new session or reuse an old one. + * NB: For servers, the 'new' session may actually be a previously + * cached session or even the previous session unless + * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set + */ + int new_session; + /* don't send shutdown packets */ + int quiet_shutdown; + /* we have shut things down, 0x01 sent, 0x02 for received */ + int shutdown; + /* where we are */ + OSSL_STATEM statem; + SSL_EARLY_DATA_STATE early_data_state; + BUF_MEM *init_buf; /* buffer used during init */ + void *init_msg; /* pointer to handshake message body, set by + * ssl3_get_message() */ + size_t init_num; /* amount read/written */ + size_t init_off; /* amount read/written */ + struct ssl3_state_st *s3; /* SSLv3 variables */ + struct dtls1_state_st *d1; /* DTLSv1 variables */ + /* callback that allows applications to peek at protocol messages */ + void (*msg_callback) (int write_p, int version, int content_type, + const void *buf, size_t len, SSL *ssl, void *arg); + void *msg_callback_arg; + int hit; /* reusing a previous session */ + X509_VERIFY_PARAM *param; + /* Per connection DANE state */ + SSL_DANE dane; + /* crypto */ + STACK_OF(SSL_CIPHER) *peer_ciphers; + STACK_OF(SSL_CIPHER) *cipher_list; + STACK_OF(SSL_CIPHER) *cipher_list_by_id; + /* TLSv1.3 specific ciphersuites */ + STACK_OF(SSL_CIPHER) *tls13_ciphersuites; + /* + * These are the ones being used, the ones in SSL_SESSION are the ones to + * be 'copied' into these ones + */ + uint32_t mac_flags; + /* + * The TLS1.3 secrets. + */ + unsigned char early_secret[EVP_MAX_MD_SIZE]; + unsigned char handshake_secret[EVP_MAX_MD_SIZE]; + unsigned char master_secret[EVP_MAX_MD_SIZE]; + unsigned char resumption_master_secret[EVP_MAX_MD_SIZE]; + unsigned char client_finished_secret[EVP_MAX_MD_SIZE]; + unsigned char server_finished_secret[EVP_MAX_MD_SIZE]; + unsigned char server_finished_hash[EVP_MAX_MD_SIZE]; + unsigned char handshake_traffic_hash[EVP_MAX_MD_SIZE]; + unsigned char client_app_traffic_secret[EVP_MAX_MD_SIZE]; + unsigned char server_app_traffic_secret[EVP_MAX_MD_SIZE]; + unsigned char exporter_master_secret[EVP_MAX_MD_SIZE]; + unsigned char early_exporter_master_secret[EVP_MAX_MD_SIZE]; + EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ + unsigned char read_iv[EVP_MAX_IV_LENGTH]; /* TLSv1.3 static read IV */ + EVP_MD_CTX *read_hash; /* used for mac generation */ + COMP_CTX *compress; /* compression */ + COMP_CTX *expand; /* uncompress */ + EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ + unsigned char write_iv[EVP_MAX_IV_LENGTH]; /* TLSv1.3 static write IV */ + EVP_MD_CTX *write_hash; /* used for mac generation */ + /* session info */ + /* client cert? */ + /* This is used to hold the server certificate used */ + struct cert_st /* CERT */ *cert; + + /* + * The hash of all messages prior to the CertificateVerify, and the length + * of that hash. + */ + unsigned char cert_verify_hash[EVP_MAX_MD_SIZE]; + size_t cert_verify_hash_len; + + /* Flag to indicate whether we should send a HelloRetryRequest or not */ + enum {SSL_HRR_NONE = 0, SSL_HRR_PENDING, SSL_HRR_COMPLETE} + hello_retry_request; + + /* + * 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; + /* TLSv1.3 PSK session */ + SSL_SESSION *psksession; + unsigned char *psksession_id; + size_t psksession_id_len; + /* Default generate session ID callback. */ + GEN_SESSION_CB generate_session_id; + /* + * The temporary TLSv1.3 session id. This isn't really a session id at all + * but is a random value sent in the legacy session id field. + */ + unsigned char tmp_session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; + size_t tmp_session_id_len; + /* Used in SSL3 */ + /* + * 0 don't care about verify failure. + * 1 fail if verify fails + */ + uint32_t verify_mode; + /* fail if callback returns 0 */ + int (*verify_callback) (int ok, X509_STORE_CTX *ctx); + /* optional informational callback */ + void (*info_callback) (const SSL *ssl, int type, int val); + /* error bytes to be written */ + int error; + /* actual code */ + int error_code; +# ifndef OPENSSL_NO_PSK + SSL_psk_client_cb_func psk_client_callback; + SSL_psk_server_cb_func psk_server_callback; +# endif + SSL_psk_find_session_cb_func psk_find_session_cb; + SSL_psk_use_session_cb_func psk_use_session_cb; + + SSL_CTX *ctx; + /* Verified chain of peer */ + STACK_OF(X509) *verified_chain; + long verify_result; + /* extra application data */ + CRYPTO_EX_DATA ex_data; + /* + * What we put in certificate_authorities extension for TLS 1.3 + * (ClientHello and CertificateRequest) or just client cert requests for + * earlier versions. If client_ca_names is populated then it is only used + * for client cert requests, and in preference to ca_names. + */ + STACK_OF(X509_NAME) *ca_names; + STACK_OF(X509_NAME) *client_ca_names; + CRYPTO_REF_COUNT references; + /* protocol behaviour */ + uint32_t options; + /* API behaviour */ + uint32_t mode; + int min_proto_version; + int max_proto_version; + size_t max_cert_list; + int first_packet; + /* + * What was passed in ClientHello.legacy_version. Used for RSA pre-master + * secret and SSLv3/TLS (<=1.2) rollback check + */ + int client_version; + /* + * If we're using more than one pipeline how should we divide the data + * up between the pipes? + */ + size_t split_send_fragment; + /* + * Maximum amount of data to send in one fragment. actual record size can + * be more than this due to padding and MAC overheads. + */ + size_t max_send_fragment; + /* Up to how many pipelines should we use? If 0 then 1 is assumed */ + size_t max_pipelines; + + struct { + /* Built-in extension flags */ + uint8_t extflags[TLSEXT_IDX_num_builtins]; + /* TLS extension debug callback */ + void (*debug_cb)(SSL *s, int client_server, int type, + const unsigned char *data, int len, void *arg); + void *debug_arg; + char *hostname; + /* certificate status request info */ + /* Status type or -1 if no status type */ + int status_type; + /* Raw extension data, if seen */ + unsigned char *scts; + /* Length of raw extension data, if seen */ + uint16_t scts_len; + /* Expect OCSP CertificateStatus message */ + int status_expected; + + struct { + /* OCSP status request only */ + STACK_OF(OCSP_RESPID) *ids; + X509_EXTENSIONS *exts; + /* OCSP response received or to be sent */ + unsigned char *resp; + size_t resp_len; + } ocsp; + + /* RFC4507 session ticket expected to be received or sent */ + int ticket_expected; +# ifndef OPENSSL_NO_EC + size_t ecpointformats_len; + /* our list */ + unsigned char *ecpointformats; + + size_t peer_ecpointformats_len; + /* peer's list */ + unsigned char *peer_ecpointformats; +# endif /* OPENSSL_NO_EC */ + size_t supportedgroups_len; + /* our list */ + uint16_t *supportedgroups; + + size_t peer_supportedgroups_len; + /* peer's list */ + uint16_t *peer_supportedgroups; + + /* TLS Session Ticket extension override */ + TLS_SESSION_TICKET_EXT *session_ticket; + /* TLS Session Ticket extension callback */ + tls_session_ticket_ext_cb_fn session_ticket_cb; + void *session_ticket_cb_arg; + /* TLS pre-shared secret session resumption */ + tls_session_secret_cb_fn session_secret_cb; + void *session_secret_cb_arg; + /* + * For a client, this contains the list of supported protocols in wire + * format. + */ + unsigned char *alpn; + size_t alpn_len; + /* + * Next protocol negotiation. For the client, this is the protocol that + * we sent in NextProtocol and is set when handling ServerHello + * extensions. For a server, this is the client's selected_protocol from + * NextProtocol and is set when handling the NextProtocol message, before + * the Finished message. + */ + unsigned char *npn; + size_t npn_len; + + /* The available PSK key exchange modes */ + int psk_kex_mode; + + /* Set to one if we have negotiated ETM */ + int use_etm; + + /* Are we expecting to receive early data? */ + int early_data; + /* Is the session suitable for early data? */ + int early_data_ok; + + /* May be sent by a server in HRR. Must be echoed back in ClientHello */ + unsigned char *tls13_cookie; + size_t tls13_cookie_len; + /* Have we received a cookie from the client? */ + int cookieok; + + /* + * Maximum Fragment Length as per RFC 4366. + * If this member contains one of the allowed values (1-4) + * then we should include Maximum Fragment Length Negotiation + * extension in Client Hello. + * Please note that value of this member does not have direct + * effect. The actual (binding) value is stored in SSL_SESSION, + * as this extension is optional on server side. + */ + uint8_t max_fragment_len_mode; + + /* + * On the client side the number of ticket identities we sent in the + * ClientHello. On the server side the identity of the ticket we + * selected. + */ + int tick_identity; + } ext; + + /* + * Parsed form of the ClientHello, kept around across client_hello_cb + * calls. + */ + CLIENTHELLO_MSG *clienthello; + + /*- + * no further mod of servername + * 0 : call the servername extension callback. + * 1 : prepare 2, allow last ack just after in server callback. + * 2 : don't call servername callback, no ack in server hello + */ + int servername_done; +# ifndef OPENSSL_NO_CT + /* + * Validates that the SCTs (Signed Certificate Timestamps) are sufficient. + * If they are not, the connection should be aborted. + */ + ssl_ct_validation_cb ct_validation_callback; + /* User-supplied argument that is passed to the ct_validation_callback */ + void *ct_validation_callback_arg; + /* + * Consolidated stack of SCTs from all sources. + * Lazily populated by CT_get_peer_scts(SSL*) + */ + STACK_OF(SCT) *scts; + /* Have we attempted to find/parse SCTs yet? */ + int scts_parsed; +# endif + SSL_CTX *session_ctx; /* initial ctx, used to store sessions */ +# ifndef OPENSSL_NO_SRTP + /* What we'll do */ + STACK_OF(SRTP_PROTECTION_PROFILE) *srtp_profiles; + /* What's been chosen */ + SRTP_PROTECTION_PROFILE *srtp_profile; +# endif + /*- + * 1 if we are renegotiating. + * 2 if we are a server and are inside a handshake + * (i.e. not just sending a HelloRequest) + */ + int renegotiate; + /* If sending a KeyUpdate is pending */ + int key_update; + /* Post-handshake authentication state */ + SSL_PHA_STATE post_handshake_auth; + int pha_enabled; + uint8_t* pha_context; + size_t pha_context_len; + int certreqs_sent; + EVP_MD_CTX *pha_dgst; /* this is just the digest through ClientFinished */ + +# ifndef OPENSSL_NO_SRP + /* ctx for SRP authentication */ + SRP_CTX srp_ctx; +# endif + /* + * Callback for disabling session caching and ticket support on a session + * basis, depending on the chosen cipher. + */ + int (*not_resumable_session_cb) (SSL *ssl, int is_forward_secure); + RECORD_LAYER rlayer; + /* Default password callback. */ + pem_password_cb *default_passwd_callback; + /* Default password callback user data. */ + void *default_passwd_callback_userdata; + /* Async Job info */ + ASYNC_JOB *job; + ASYNC_WAIT_CTX *waitctx; + size_t asyncrw; + + /* + * The maximum number of bytes advertised in session tickets that can be + * sent as early data. + */ + uint32_t max_early_data; + /* + * The maximum number of bytes of early data that a server will tolerate + * (which should be at least as much as max_early_data). + */ + uint32_t recv_max_early_data; + + /* + * The number of bytes of early data received so far. If we accepted early + * data then this is a count of the plaintext bytes. If we rejected it then + * this is a count of the ciphertext bytes. + */ + uint32_t early_data_count; + + /* TLS1.3 padding callback */ + size_t (*record_padding_cb)(SSL *s, int type, size_t len, void *arg); + void *record_padding_arg; + size_t block_padding; + + CRYPTO_RWLOCK *lock; + + /* The number of TLS1.3 tickets to automatically send */ + size_t num_tickets; + /* The number of TLS1.3 tickets actually sent so far */ + size_t sent_tickets; + /* The next nonce value to use when we send a ticket on this connection */ + uint64_t next_ticket_nonce; + + /* Callback to determine if early_data is acceptable or not */ + SSL_allow_early_data_cb_fn allow_early_data_cb; + void *allow_early_data_cb_data; + + /* + * Signature algorithms shared by client and server: cached because these + * are used most often. + */ + const struct sigalg_lookup_st **shared_sigalgs; + size_t shared_sigalgslen; +}; + +/* + * Structure containing table entry of values associated with the signature + * algorithms (signature scheme) extension +*/ +typedef struct sigalg_lookup_st { + /* TLS 1.3 signature scheme name */ + const char *name; + /* Raw value used in extension */ + uint16_t sigalg; + /* NID of hash algorithm or NID_undef if no hash */ + int hash; + /* Index of hash algorithm or -1 if no hash algorithm */ + int hash_idx; + /* NID of signature algorithm */ + int sig; + /* Index of signature algorithm */ + int sig_idx; + /* Combined hash and signature NID, if any */ + int sigandhash; + /* Required public key curve (ECDSA only) */ + int curve; +} SIGALG_LOOKUP; + +typedef struct tls_group_info_st { + int nid; /* Curve NID */ + int secbits; /* Bits of security (from SP800-57) */ + uint16_t flags; /* Flags: currently just group type */ +} TLS_GROUP_INFO; + +/* flags values */ +# define TLS_CURVE_TYPE 0x3 /* Mask for group type */ +# define TLS_CURVE_PRIME 0x0 +# define TLS_CURVE_CHAR2 0x1 +# define TLS_CURVE_CUSTOM 0x2 + +typedef struct cert_pkey_st CERT_PKEY; + +/* + * Structure containing table entry of certificate info corresponding to + * CERT_PKEY entries + */ +typedef struct { + int nid; /* NID of public key algorithm */ + uint32_t amask; /* authmask corresponding to key type */ +} SSL_CERT_LOOKUP; + +typedef struct ssl3_state_st { + long flags; + size_t read_mac_secret_size; + unsigned char read_mac_secret[EVP_MAX_MD_SIZE]; + size_t write_mac_secret_size; + unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; + unsigned char server_random[SSL3_RANDOM_SIZE]; + unsigned char client_random[SSL3_RANDOM_SIZE]; + /* flags for countermeasure against known-IV weakness */ + int need_empty_fragments; + int empty_fragment_done; + /* used during startup, digest all incoming/outgoing packets */ + BIO *handshake_buffer; + /* + * When handshake digest is determined, buffer is hashed and + * freed and MD_CTX for the required digest is stored here. + */ + EVP_MD_CTX *handshake_dgst; + /* + * Set whenever an expected ChangeCipherSpec message is processed. + * Unset when the peer's Finished message is received. + * Unexpected ChangeCipherSpec messages trigger a fatal alert. + */ + int change_cipher_spec; + int warn_alert; + int fatal_alert; + /* + * we allow one fatal and one warning alert to be outstanding, send close + * alert via the warning alert + */ + int alert_dispatch; + unsigned char send_alert[2]; + /* + * This flag is set when we should renegotiate ASAP, basically when there + * is no more data in the read or write buffers + */ + int renegotiate; + int total_renegotiations; + int num_renegotiations; + int in_read_app_data; + struct { + /* actually only need to be 16+20 for SSLv3 and 12 for TLS */ + unsigned char finish_md[EVP_MAX_MD_SIZE * 2]; + size_t finish_md_len; + unsigned char peer_finish_md[EVP_MAX_MD_SIZE * 2]; + size_t peer_finish_md_len; + size_t message_size; + int message_type; + /* used to hold the new cipher we are going to use */ + const SSL_CIPHER *new_cipher; +# if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) + EVP_PKEY *pkey; /* holds short lived DH/ECDH key */ +# endif + /* used for certificate requests */ + int cert_req; + /* Certificate types in certificate request message. */ + uint8_t *ctype; + size_t ctype_len; + /* Certificate authorities list peer sent */ + STACK_OF(X509_NAME) *peer_ca_names; + size_t key_block_length; + unsigned char *key_block; + const EVP_CIPHER *new_sym_enc; + const EVP_MD *new_hash; + int new_mac_pkey_type; + size_t new_mac_secret_size; +# ifndef OPENSSL_NO_COMP + const SSL_COMP *new_compression; +# else + char *new_compression; +# endif + int cert_request; + /* Raw values of the cipher list from a client */ + unsigned char *ciphers_raw; + size_t ciphers_rawlen; + /* Temporary storage for premaster secret */ + unsigned char *pms; + size_t pmslen; +# ifndef OPENSSL_NO_PSK + /* Temporary storage for PSK key */ + unsigned char *psk; + size_t psklen; +# endif + /* Signature algorithm we actually use */ + const SIGALG_LOOKUP *sigalg; + /* Pointer to certificate we use */ + CERT_PKEY *cert; + /* + * signature algorithms peer reports: e.g. supported signature + * algorithms extension for server or as part of a certificate + * request for client. + * Keep track of the algorithms for TLS and X.509 usage separately. + */ + uint16_t *peer_sigalgs; + uint16_t *peer_cert_sigalgs; + /* Size of above arrays */ + size_t peer_sigalgslen; + size_t peer_cert_sigalgslen; + /* Sigalg peer actually uses */ + const SIGALG_LOOKUP *peer_sigalg; + /* + * Set if corresponding CERT_PKEY can be used with current + * SSL session: e.g. appropriate curve, signature algorithms etc. + * If zero it can't be used at all. + */ + uint32_t valid_flags[SSL_PKEY_NUM]; + /* + * For servers the following masks are for the key and auth algorithms + * that are supported by the certs below. For clients they are masks of + * *disabled* algorithms based on the current session. + */ + uint32_t mask_k; + uint32_t mask_a; + /* + * The following are used by the client to see if a cipher is allowed or + * not. It contains the minimum and maximum version the client's using + * based on what it knows so far. + */ + int min_ver; + int max_ver; + } tmp; + + /* Connection binding to prevent renegotiation attacks */ + unsigned char previous_client_finished[EVP_MAX_MD_SIZE]; + size_t previous_client_finished_len; + unsigned char previous_server_finished[EVP_MAX_MD_SIZE]; + size_t previous_server_finished_len; + int send_connection_binding; /* TODOEKR */ + +# ifndef OPENSSL_NO_NEXTPROTONEG + /* + * Set if we saw the Next Protocol Negotiation extension from our peer. + */ + int npn_seen; +# endif + + /* + * ALPN information (we are in the process of transitioning from NPN to + * ALPN.) + */ + + /* + * In a server these point to the selected ALPN protocol after the + * ClientHello has been processed. In a client these contain the protocol + * that the server selected once the ServerHello has been processed. + */ + unsigned char *alpn_selected; + size_t alpn_selected_len; + /* used by the server to know what options were proposed */ + unsigned char *alpn_proposed; + size_t alpn_proposed_len; + /* used by the client to know if it actually sent alpn */ + int alpn_sent; + +# ifndef OPENSSL_NO_EC + /* + * This is set to true if we believe that this is a version of Safari + * running on OS X 10.6 or newer. We wish to know this because Safari on + * 10.8 .. 10.8.3 has broken ECDHE-ECDSA support. + */ + char is_probably_safari; +# endif /* !OPENSSL_NO_EC */ + + /* For clients: peer temporary key */ +# if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH) + /* The group_id for the DH/ECDH key */ + uint16_t group_id; + EVP_PKEY *peer_tmp; +# endif + +} SSL3_STATE; + +/* DTLS structures */ + +# ifndef OPENSSL_NO_SCTP +# define DTLS1_SCTP_AUTH_LABEL "EXPORTER_DTLS_OVER_SCTP" +# endif + +/* Max MTU overhead we know about so far is 40 for IPv6 + 8 for UDP */ +# define DTLS1_MAX_MTU_OVERHEAD 48 + +/* + * Flag used in message reuse to indicate the buffer contains the record + * header as well as the handshake message header. + */ +# define DTLS1_SKIP_RECORD_HEADER 2 + +struct dtls1_retransmit_state { + EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ + EVP_MD_CTX *write_hash; /* used for mac generation */ + COMP_CTX *compress; /* compression */ + SSL_SESSION *session; + unsigned short epoch; +}; + +struct hm_header_st { + unsigned char type; + size_t msg_len; + unsigned short seq; + size_t frag_off; + size_t frag_len; + unsigned int is_ccs; + struct dtls1_retransmit_state saved_retransmit_state; +}; + +struct dtls1_timeout_st { + /* Number of read timeouts so far */ + unsigned int read_timeouts; + /* Number of write timeouts so far */ + unsigned int write_timeouts; + /* Number of alerts received so far */ + unsigned int num_alerts; +}; + +typedef struct hm_fragment_st { + struct hm_header_st msg_header; + unsigned char *fragment; + unsigned char *reassembly; +} hm_fragment; + +typedef struct pqueue_st pqueue; +typedef struct pitem_st pitem; + +struct pitem_st { + unsigned char priority[8]; /* 64-bit value in big-endian encoding */ + void *data; + pitem *next; +}; + +typedef struct pitem_st *piterator; + +pitem *pitem_new(unsigned char *prio64be, void *data); +void pitem_free(pitem *item); +pqueue *pqueue_new(void); +void pqueue_free(pqueue *pq); +pitem *pqueue_insert(pqueue *pq, pitem *item); +pitem *pqueue_peek(pqueue *pq); +pitem *pqueue_pop(pqueue *pq); +pitem *pqueue_find(pqueue *pq, unsigned char *prio64be); +pitem *pqueue_iterator(pqueue *pq); +pitem *pqueue_next(piterator *iter); +size_t pqueue_size(pqueue *pq); + +typedef struct dtls1_state_st { + unsigned char cookie[DTLS1_COOKIE_LENGTH]; + size_t cookie_len; + unsigned int cookie_verified; + /* handshake message numbers */ + unsigned short handshake_write_seq; + unsigned short next_handshake_write_seq; + unsigned short handshake_read_seq; + /* Buffered handshake messages */ + pqueue *buffered_messages; + /* Buffered (sent) handshake records */ + pqueue *sent_messages; + size_t link_mtu; /* max on-the-wire DTLS packet size */ + size_t mtu; /* max DTLS packet size */ + struct hm_header_st w_msg_hdr; + struct hm_header_st r_msg_hdr; + struct dtls1_timeout_st timeout; + /* + * Indicates when the last handshake msg sent will timeout + */ + struct timeval next_timeout; + /* Timeout duration */ + unsigned int timeout_duration_us; + + unsigned int retransmitting; +# ifndef OPENSSL_NO_SCTP + int shutdown_received; +# endif + + DTLS_timer_cb timer_cb; + +} DTLS1_STATE; + +# ifndef OPENSSL_NO_EC +/* + * From ECC-TLS draft, used in encoding the curve type in ECParameters + */ +# define EXPLICIT_PRIME_CURVE_TYPE 1 +# define EXPLICIT_CHAR2_CURVE_TYPE 2 +# define NAMED_CURVE_TYPE 3 +# endif /* OPENSSL_NO_EC */ + +struct cert_pkey_st { + X509 *x509; + EVP_PKEY *privatekey; + /* Chain for this certificate */ + STACK_OF(X509) *chain; + /*- + * serverinfo data for this certificate. The data is in TLS Extension + * wire format, specifically it's a series of records like: + * uint16_t extension_type; // (RFC 5246, 7.4.1.4, Extension) + * uint16_t length; + * uint8_t data[length]; + */ + unsigned char *serverinfo; + size_t serverinfo_length; +}; +/* Retrieve Suite B flags */ +# define tls1_suiteb(s) (s->cert->cert_flags & SSL_CERT_FLAG_SUITEB_128_LOS) +/* Uses to check strict mode: suite B modes are always strict */ +# define SSL_CERT_FLAGS_CHECK_TLS_STRICT \ + (SSL_CERT_FLAG_SUITEB_128_LOS|SSL_CERT_FLAG_TLS_STRICT) + +typedef enum { + ENDPOINT_CLIENT = 0, + ENDPOINT_SERVER, + ENDPOINT_BOTH +} ENDPOINT; + + +typedef struct { + unsigned short ext_type; + ENDPOINT role; + /* The context which this extension applies to */ + unsigned int context; + /* + * Per-connection flags relating to this extension type: not used if + * part of an SSL_CTX structure. + */ + uint32_t ext_flags; + SSL_custom_ext_add_cb_ex add_cb; + SSL_custom_ext_free_cb_ex free_cb; + void *add_arg; + SSL_custom_ext_parse_cb_ex parse_cb; + void *parse_arg; +} custom_ext_method; + +/* ext_flags values */ + +/* + * Indicates an extension has been received. Used to check for unsolicited or + * duplicate extensions. + */ +# define SSL_EXT_FLAG_RECEIVED 0x1 +/* + * Indicates an extension has been sent: used to enable sending of + * corresponding ServerHello extension. + */ +# define SSL_EXT_FLAG_SENT 0x2 + +typedef struct { + custom_ext_method *meths; + size_t meths_count; +} custom_ext_methods; + +typedef struct cert_st { + /* Current active set */ + /* + * ALWAYS points to an element of the pkeys array + * Probably it would make more sense to store + * an index, not a pointer. + */ + CERT_PKEY *key; +# ifndef OPENSSL_NO_DH + EVP_PKEY *dh_tmp; + DH *(*dh_tmp_cb) (SSL *ssl, int is_export, int keysize); + int dh_tmp_auto; +# endif + /* Flags related to certificates */ + uint32_t cert_flags; + CERT_PKEY pkeys[SSL_PKEY_NUM]; + /* Custom certificate types sent in certificate request message. */ + uint8_t *ctype; + size_t ctype_len; + /* + * supported signature algorithms. When set on a client this is sent in + * the client hello as the supported signature algorithms extension. For + * servers it represents the signature algorithms we are willing to use. + */ + uint16_t *conf_sigalgs; + /* Size of above array */ + size_t conf_sigalgslen; + /* + * Client authentication signature algorithms, if not set then uses + * conf_sigalgs. On servers these will be the signature algorithms sent + * to the client in a certificate request for TLS 1.2. On a client this + * represents the signature algorithms we are willing to use for client + * authentication. + */ + uint16_t *client_sigalgs; + /* Size of above array */ + size_t client_sigalgslen; + /* + * Certificate setup callback: if set is called whenever a certificate + * may be required (client or server). the callback can then examine any + * appropriate parameters and setup any certificates required. This + * allows advanced applications to select certificates on the fly: for + * example based on supported signature algorithms or curves. + */ + int (*cert_cb) (SSL *ssl, void *arg); + void *cert_cb_arg; + /* + * Optional X509_STORE for chain building or certificate validation If + * NULL the parent SSL_CTX store is used instead. + */ + X509_STORE *chain_store; + X509_STORE *verify_store; + /* Custom extensions */ + custom_ext_methods custext; + /* Security callback */ + int (*sec_cb) (const SSL *s, const SSL_CTX *ctx, int op, int bits, int nid, + void *other, void *ex); + /* Security level */ + int sec_level; + void *sec_ex; +# ifndef OPENSSL_NO_PSK + /* If not NULL psk identity hint to use for servers */ + char *psk_identity_hint; +# endif + CRYPTO_REF_COUNT references; /* >1 only if SSL_copy_session_id is used */ + CRYPTO_RWLOCK *lock; +} CERT; + +# define FP_ICC (int (*)(const void *,const void *)) + +/* + * This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff It is a bit + * of a mess of functions, but hell, think of it as an opaque structure :-) + */ +typedef struct ssl3_enc_method { + int (*enc) (SSL *, SSL3_RECORD *, size_t, int); + int (*mac) (SSL *, SSL3_RECORD *, unsigned char *, int); + int (*setup_key_block) (SSL *); + int (*generate_master_secret) (SSL *, unsigned char *, unsigned char *, + size_t, size_t *); + int (*change_cipher_state) (SSL *, int); + size_t (*final_finish_mac) (SSL *, const char *, size_t, unsigned char *); + const char *client_finished_label; + size_t client_finished_label_len; + const char *server_finished_label; + size_t server_finished_label_len; + int (*alert_value) (int); + int (*export_keying_material) (SSL *, unsigned char *, size_t, + const char *, size_t, + const unsigned char *, size_t, + int use_context); + /* Various flags indicating protocol version requirements */ + uint32_t enc_flags; + /* Set the handshake header */ + int (*set_handshake_header) (SSL *s, WPACKET *pkt, int type); + /* Close construction of the handshake message */ + int (*close_construct_packet) (SSL *s, WPACKET *pkt, int htype); + /* Write out handshake message */ + int (*do_write) (SSL *s); +} SSL3_ENC_METHOD; + +# define ssl_set_handshake_header(s, pkt, htype) \ + s->method->ssl3_enc->set_handshake_header((s), (pkt), (htype)) +# define ssl_close_construct_packet(s, pkt, htype) \ + s->method->ssl3_enc->close_construct_packet((s), (pkt), (htype)) +# define ssl_do_write(s) s->method->ssl3_enc->do_write(s) + +/* Values for enc_flags */ + +/* Uses explicit IV for CBC mode */ +# define SSL_ENC_FLAG_EXPLICIT_IV 0x1 +/* Uses signature algorithms extension */ +# define SSL_ENC_FLAG_SIGALGS 0x2 +/* Uses SHA256 default PRF */ +# define SSL_ENC_FLAG_SHA256_PRF 0x4 +/* Is DTLS */ +# define SSL_ENC_FLAG_DTLS 0x8 +/* + * Allow TLS 1.2 ciphersuites: applies to DTLS 1.2 as well as TLS 1.2: may + * apply to others in future. + */ +# define SSL_ENC_FLAG_TLS1_2_CIPHERS 0x10 + +# ifndef OPENSSL_NO_COMP +/* Used for holding the relevant compression methods loaded into SSL_CTX */ +typedef struct ssl3_comp_st { + int comp_id; /* The identifier byte for this compression + * type */ + char *name; /* Text name used for the compression type */ + COMP_METHOD *method; /* The method :-) */ +} SSL3_COMP; +# endif + +typedef enum downgrade_en { + DOWNGRADE_NONE, + DOWNGRADE_TO_1_2, + DOWNGRADE_TO_1_1 +} DOWNGRADE; + +/* + * Dummy status type for the status_type extension. Indicates no status type + * set + */ +#define TLSEXT_STATUSTYPE_nothing -1 + +/* Sigalgs values */ +#define TLSEXT_SIGALG_ecdsa_secp256r1_sha256 0x0403 +#define TLSEXT_SIGALG_ecdsa_secp384r1_sha384 0x0503 +#define TLSEXT_SIGALG_ecdsa_secp521r1_sha512 0x0603 +#define TLSEXT_SIGALG_ecdsa_sha224 0x0303 +#define TLSEXT_SIGALG_ecdsa_sha1 0x0203 +#define TLSEXT_SIGALG_rsa_pss_rsae_sha256 0x0804 +#define TLSEXT_SIGALG_rsa_pss_rsae_sha384 0x0805 +#define TLSEXT_SIGALG_rsa_pss_rsae_sha512 0x0806 +#define TLSEXT_SIGALG_rsa_pss_pss_sha256 0x0809 +#define TLSEXT_SIGALG_rsa_pss_pss_sha384 0x080a +#define TLSEXT_SIGALG_rsa_pss_pss_sha512 0x080b +#define TLSEXT_SIGALG_rsa_pkcs1_sha256 0x0401 +#define TLSEXT_SIGALG_rsa_pkcs1_sha384 0x0501 +#define TLSEXT_SIGALG_rsa_pkcs1_sha512 0x0601 +#define TLSEXT_SIGALG_rsa_pkcs1_sha224 0x0301 +#define TLSEXT_SIGALG_rsa_pkcs1_sha1 0x0201 +#define TLSEXT_SIGALG_dsa_sha256 0x0402 +#define TLSEXT_SIGALG_dsa_sha384 0x0502 +#define TLSEXT_SIGALG_dsa_sha512 0x0602 +#define TLSEXT_SIGALG_dsa_sha224 0x0302 +#define TLSEXT_SIGALG_dsa_sha1 0x0202 +#define TLSEXT_SIGALG_gostr34102012_256_gostr34112012_256 0xeeee +#define TLSEXT_SIGALG_gostr34102012_512_gostr34112012_512 0xefef +#define TLSEXT_SIGALG_gostr34102001_gostr3411 0xeded + +#define TLSEXT_SIGALG_ed25519 0x0807 +#define TLSEXT_SIGALG_ed448 0x0808 + +/* Known PSK key exchange modes */ +#define TLSEXT_KEX_MODE_KE 0x00 +#define TLSEXT_KEX_MODE_KE_DHE 0x01 + +/* + * Internal representations of key exchange modes + */ +#define TLSEXT_KEX_MODE_FLAG_NONE 0 +#define TLSEXT_KEX_MODE_FLAG_KE 1 +#define TLSEXT_KEX_MODE_FLAG_KE_DHE 2 + +#define SSL_USE_PSS(s) (s->s3->tmp.peer_sigalg != NULL && \ + s->s3->tmp.peer_sigalg->sig == EVP_PKEY_RSA_PSS) + +/* A dummy signature value not valid for TLSv1.2 signature algs */ +#define TLSEXT_signature_rsa_pss 0x0101 + +/* TLSv1.3 downgrade protection sentinel values */ +extern const unsigned char tls11downgrade[8]; +extern const unsigned char tls12downgrade[8]; + +extern SSL3_ENC_METHOD ssl3_undef_enc_method; + +__owur const SSL_METHOD *ssl_bad_method(int ver); +__owur const SSL_METHOD *sslv3_method(void); +__owur const SSL_METHOD *sslv3_server_method(void); +__owur const SSL_METHOD *sslv3_client_method(void); +__owur const SSL_METHOD *tlsv1_method(void); +__owur const SSL_METHOD *tlsv1_server_method(void); +__owur const SSL_METHOD *tlsv1_client_method(void); +__owur const SSL_METHOD *tlsv1_1_method(void); +__owur const SSL_METHOD *tlsv1_1_server_method(void); +__owur const SSL_METHOD *tlsv1_1_client_method(void); +__owur const SSL_METHOD *tlsv1_2_method(void); +__owur const SSL_METHOD *tlsv1_2_server_method(void); +__owur const SSL_METHOD *tlsv1_2_client_method(void); +__owur const SSL_METHOD *tlsv1_3_method(void); +__owur const SSL_METHOD *tlsv1_3_server_method(void); +__owur const SSL_METHOD *tlsv1_3_client_method(void); +__owur const SSL_METHOD *dtlsv1_method(void); +__owur const SSL_METHOD *dtlsv1_server_method(void); +__owur const SSL_METHOD *dtlsv1_client_method(void); +__owur const SSL_METHOD *dtls_bad_ver_client_method(void); +__owur const SSL_METHOD *dtlsv1_2_method(void); +__owur const SSL_METHOD *dtlsv1_2_server_method(void); +__owur const SSL_METHOD *dtlsv1_2_client_method(void); + +extern const SSL3_ENC_METHOD TLSv1_enc_data; +extern const SSL3_ENC_METHOD TLSv1_1_enc_data; +extern const SSL3_ENC_METHOD TLSv1_2_enc_data; +extern const SSL3_ENC_METHOD TLSv1_3_enc_data; +extern const SSL3_ENC_METHOD SSLv3_enc_data; +extern const SSL3_ENC_METHOD DTLSv1_enc_data; +extern const SSL3_ENC_METHOD DTLSv1_2_enc_data; + +/* + * Flags for SSL methods + */ +# define SSL_METHOD_NO_FIPS (1U<<0) +# define SSL_METHOD_NO_SUITEB (1U<<1) + +# define IMPLEMENT_tls_meth_func(version, flags, mask, func_name, s_accept, \ + s_connect, enc_data) \ +const SSL_METHOD *func_name(void) \ + { \ + static const SSL_METHOD func_name##_data= { \ + version, \ + flags, \ + mask, \ + tls1_new, \ + tls1_clear, \ + tls1_free, \ + s_accept, \ + s_connect, \ + ssl3_read, \ + ssl3_peek, \ + ssl3_write, \ + ssl3_shutdown, \ + ssl3_renegotiate, \ + ssl3_renegotiate_check, \ + ssl3_read_bytes, \ + ssl3_write_bytes, \ + ssl3_dispatch_alert, \ + ssl3_ctrl, \ + ssl3_ctx_ctrl, \ + ssl3_get_cipher_by_char, \ + ssl3_put_cipher_by_char, \ + ssl3_pending, \ + ssl3_num_ciphers, \ + ssl3_get_cipher, \ + tls1_default_timeout, \ + &enc_data, \ + ssl_undefined_void_function, \ + ssl3_callback_ctrl, \ + ssl3_ctx_callback_ctrl, \ + }; \ + return &func_name##_data; \ + } + +# define IMPLEMENT_ssl3_meth_func(func_name, s_accept, s_connect) \ +const SSL_METHOD *func_name(void) \ + { \ + static const SSL_METHOD func_name##_data= { \ + SSL3_VERSION, \ + SSL_METHOD_NO_FIPS | SSL_METHOD_NO_SUITEB, \ + SSL_OP_NO_SSLv3, \ + ssl3_new, \ + ssl3_clear, \ + ssl3_free, \ + s_accept, \ + s_connect, \ + ssl3_read, \ + ssl3_peek, \ + ssl3_write, \ + ssl3_shutdown, \ + ssl3_renegotiate, \ + ssl3_renegotiate_check, \ + ssl3_read_bytes, \ + ssl3_write_bytes, \ + ssl3_dispatch_alert, \ + ssl3_ctrl, \ + ssl3_ctx_ctrl, \ + ssl3_get_cipher_by_char, \ + ssl3_put_cipher_by_char, \ + ssl3_pending, \ + ssl3_num_ciphers, \ + ssl3_get_cipher, \ + ssl3_default_timeout, \ + &SSLv3_enc_data, \ + ssl_undefined_void_function, \ + ssl3_callback_ctrl, \ + ssl3_ctx_callback_ctrl, \ + }; \ + return &func_name##_data; \ + } + +# define IMPLEMENT_dtls1_meth_func(version, flags, mask, func_name, s_accept, \ + s_connect, enc_data) \ +const SSL_METHOD *func_name(void) \ + { \ + static const SSL_METHOD func_name##_data= { \ + version, \ + flags, \ + mask, \ + dtls1_new, \ + dtls1_clear, \ + dtls1_free, \ + s_accept, \ + s_connect, \ + ssl3_read, \ + ssl3_peek, \ + ssl3_write, \ + dtls1_shutdown, \ + ssl3_renegotiate, \ + ssl3_renegotiate_check, \ + dtls1_read_bytes, \ + dtls1_write_app_data_bytes, \ + dtls1_dispatch_alert, \ + dtls1_ctrl, \ + ssl3_ctx_ctrl, \ + ssl3_get_cipher_by_char, \ + ssl3_put_cipher_by_char, \ + ssl3_pending, \ + ssl3_num_ciphers, \ + ssl3_get_cipher, \ + dtls1_default_timeout, \ + &enc_data, \ + ssl_undefined_void_function, \ + ssl3_callback_ctrl, \ + ssl3_ctx_callback_ctrl, \ + }; \ + return &func_name##_data; \ + } + +struct openssl_ssl_test_functions { + int (*p_ssl_init_wbio_buffer) (SSL *s); + int (*p_ssl3_setup_buffers) (SSL *s); +}; + +const char *ssl_protocol_to_string(int version); + +/* Returns true if certificate and private key for 'idx' are present */ +static ossl_inline int ssl_has_cert(const SSL *s, int idx) +{ + if (idx < 0 || idx >= SSL_PKEY_NUM) + return 0; + return s->cert->pkeys[idx].x509 != NULL + && s->cert->pkeys[idx].privatekey != NULL; +} + +static ossl_inline void tls1_get_peer_groups(SSL *s, const uint16_t **pgroups, + size_t *pgroupslen) +{ + *pgroups = s->ext.peer_supportedgroups; + *pgroupslen = s->ext.peer_supportedgroups_len; +} + +# ifndef OPENSSL_UNIT_TEST + +__owur int ssl_read_internal(SSL *s, void *buf, size_t num, size_t *readbytes); +__owur int ssl_write_internal(SSL *s, const void *buf, size_t num, size_t *written); +void ssl_clear_cipher_ctx(SSL *s); +int ssl_clear_bad_session(SSL *s); +__owur CERT *ssl_cert_new(void); +__owur CERT *ssl_cert_dup(CERT *cert); +void ssl_cert_clear_certs(CERT *c); +void ssl_cert_free(CERT *c); +__owur int ssl_generate_session_id(SSL *s, SSL_SESSION *ss); +__owur int ssl_get_new_session(SSL *s, int session); +__owur SSL_SESSION *lookup_sess_in_cache(SSL *s, const unsigned char *sess_id, + size_t sess_id_len); +__owur int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello); +__owur SSL_SESSION *ssl_session_dup(SSL_SESSION *src, int ticket); +__owur int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b); +DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER, ssl_cipher_id); +__owur int ssl_cipher_ptr_id_cmp(const SSL_CIPHER *const *ap, + const SSL_CIPHER *const *bp); +__owur STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, + STACK_OF(SSL_CIPHER) *tls13_ciphersuites, + STACK_OF(SSL_CIPHER) **cipher_list, + STACK_OF(SSL_CIPHER) **cipher_list_by_id, + const char *rule_str, + CERT *c); +__owur int ssl_cache_cipherlist(SSL *s, PACKET *cipher_suites, int sslv2format); +__owur int bytes_to_cipher_list(SSL *s, PACKET *cipher_suites, + STACK_OF(SSL_CIPHER) **skp, + STACK_OF(SSL_CIPHER) **scsvs, int sslv2format, + int fatal); +void ssl_update_cache(SSL *s, int mode); +__owur int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, + const EVP_MD **md, int *mac_pkey_type, + size_t *mac_secret_size, SSL_COMP **comp, + int use_etm); +__owur int ssl_cipher_get_overhead(const SSL_CIPHER *c, size_t *mac_overhead, + size_t *int_overhead, size_t *blocksize, + size_t *ext_overhead); +__owur int ssl_cert_is_disabled(size_t idx); +__owur const SSL_CIPHER *ssl_get_cipher_by_char(SSL *ssl, + const unsigned char *ptr, + int all); +__owur int ssl_cert_set0_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain); +__owur int ssl_cert_set1_chain(SSL *s, SSL_CTX *ctx, STACK_OF(X509) *chain); +__owur int ssl_cert_add0_chain_cert(SSL *s, SSL_CTX *ctx, X509 *x); +__owur int ssl_cert_add1_chain_cert(SSL *s, SSL_CTX *ctx, X509 *x); +__owur int ssl_cert_select_current(CERT *c, X509 *x); +__owur int ssl_cert_set_current(CERT *c, long arg); +void ssl_cert_set_cert_cb(CERT *c, int (*cb) (SSL *ssl, void *arg), void *arg); + +__owur int ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *sk); +__owur int ssl_build_cert_chain(SSL *s, SSL_CTX *ctx, int flags); +__owur int ssl_cert_set_cert_store(CERT *c, X509_STORE *store, int chain, + int ref); + +__owur int ssl_security(const SSL *s, int op, int bits, int nid, void *other); +__owur int ssl_ctx_security(const SSL_CTX *ctx, int op, int bits, int nid, + void *other); int ssl_get_security_level_bits(const SSL *s, const SSL_CTX *ctx, int *levelp); - -__owur int ssl_cert_lookup_by_nid(int nid, size_t *pidx); -__owur const SSL_CERT_LOOKUP *ssl_cert_lookup_by_pkey(const EVP_PKEY *pk, - size_t *pidx); -__owur const SSL_CERT_LOOKUP *ssl_cert_lookup_by_idx(size_t idx); - -int ssl_undefined_function(SSL *s); -__owur int ssl_undefined_void_function(void); -__owur int ssl_undefined_const_function(const SSL *s); -__owur int ssl_get_server_cert_serverinfo(SSL *s, - const unsigned char **serverinfo, - size_t *serverinfo_length); -void ssl_set_masks(SSL *s); -__owur STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s); -__owur int ssl_x509err2alert(int type); -void ssl_sort_cipher_list(void); -int ssl_load_ciphers(void); -__owur int ssl_fill_hello_random(SSL *s, int server, unsigned char *field, - size_t len, DOWNGRADE dgrd); -__owur int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen, - int free_pms); -__owur EVP_PKEY *ssl_generate_pkey(EVP_PKEY *pm); -__owur int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey, - int genmaster); -__owur EVP_PKEY *ssl_dh_to_pkey(DH *dh); -__owur unsigned int ssl_get_max_send_fragment(const SSL *ssl); -__owur unsigned int ssl_get_split_send_fragment(const SSL *ssl); - -__owur const SSL_CIPHER *ssl3_get_cipher_by_id(uint32_t id); -__owur const SSL_CIPHER *ssl3_get_cipher_by_std_name(const char *stdname); -__owur const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); -__owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt, - size_t *len); -int ssl3_init_finished_mac(SSL *s); -__owur int ssl3_setup_key_block(SSL *s); -__owur int ssl3_change_cipher_state(SSL *s, int which); -void ssl3_cleanup_key_block(SSL *s); -__owur int ssl3_do_write(SSL *s, int type); -int ssl3_send_alert(SSL *s, int level, int desc); -__owur int ssl3_generate_master_secret(SSL *s, unsigned char *out, - unsigned char *p, size_t len, - size_t *secret_size); -__owur int ssl3_get_req_cert_type(SSL *s, WPACKET *pkt); -__owur int ssl3_num_ciphers(void); -__owur const SSL_CIPHER *ssl3_get_cipher(unsigned int u); -int ssl3_renegotiate(SSL *ssl); -int ssl3_renegotiate_check(SSL *ssl, int initok); -__owur int ssl3_dispatch_alert(SSL *s); -__owur size_t ssl3_final_finish_mac(SSL *s, const char *sender, size_t slen, - unsigned char *p); -__owur int ssl3_finish_mac(SSL *s, const unsigned char *buf, size_t len); -void ssl3_free_digest_list(SSL *s); -__owur unsigned long ssl3_output_cert_chain(SSL *s, WPACKET *pkt, - CERT_PKEY *cpk); -__owur const SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, - STACK_OF(SSL_CIPHER) *clnt, - STACK_OF(SSL_CIPHER) *srvr); -__owur int ssl3_digest_cached_records(SSL *s, int keep); -__owur int ssl3_new(SSL *s); -void ssl3_free(SSL *s); -__owur int ssl3_read(SSL *s, void *buf, size_t len, size_t *readbytes); -__owur int ssl3_peek(SSL *s, void *buf, size_t len, size_t *readbytes); -__owur int ssl3_write(SSL *s, const void *buf, size_t len, size_t *written); -__owur int ssl3_shutdown(SSL *s); -int ssl3_clear(SSL *s); -__owur long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg); -__owur long ssl3_ctx_ctrl(SSL_CTX *s, int cmd, long larg, void *parg); -__owur long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp) (void)); -__owur long ssl3_ctx_callback_ctrl(SSL_CTX *s, int cmd, void (*fp) (void)); - -__owur int ssl3_do_change_cipher_spec(SSL *ssl); -__owur long ssl3_default_timeout(void); - -__owur int ssl3_set_handshake_header(SSL *s, WPACKET *pkt, int htype); -__owur int tls_close_construct_packet(SSL *s, WPACKET *pkt, int htype); -__owur int tls_setup_handshake(SSL *s); -__owur int dtls1_set_handshake_header(SSL *s, WPACKET *pkt, int htype); -__owur int dtls1_close_construct_packet(SSL *s, WPACKET *pkt, int htype); -__owur int ssl3_handshake_write(SSL *s); - -__owur int ssl_allow_compression(SSL *s); - -__owur int ssl_version_supported(const SSL *s, int version, - const SSL_METHOD **meth); - -__owur int ssl_set_client_hello_version(SSL *s); -__owur int ssl_check_version_downgrade(SSL *s); -__owur int ssl_set_version_bound(int method_version, int version, int *bound); -__owur int ssl_choose_server_version(SSL *s, CLIENTHELLO_MSG *hello, - DOWNGRADE *dgrd); -__owur int ssl_choose_client_version(SSL *s, int version, - RAW_EXTENSION *extensions); -__owur int ssl_get_min_max_version(const SSL *s, int *min_version, - int *max_version, int *real_max); - -__owur long tls1_default_timeout(void); -__owur int dtls1_do_write(SSL *s, int type); -void dtls1_set_message_header(SSL *s, - unsigned char mt, - size_t len, - size_t frag_off, size_t frag_len); - -int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, size_t len, - size_t *written); - -__owur int dtls1_read_failed(SSL *s, int code); -__owur int dtls1_buffer_message(SSL *s, int ccs); -__owur int dtls1_retransmit_message(SSL *s, unsigned short seq, int *found); -__owur int dtls1_get_queue_priority(unsigned short seq, int is_ccs); -int dtls1_retransmit_buffered_messages(SSL *s); -void dtls1_clear_received_buffer(SSL *s); -void dtls1_clear_sent_buffer(SSL *s); -void dtls1_get_message_header(unsigned char *data, - struct hm_header_st *msg_hdr); -__owur long dtls1_default_timeout(void); -__owur struct timeval *dtls1_get_timeout(SSL *s, struct timeval *timeleft); -__owur int dtls1_check_timeout_num(SSL *s); -__owur int dtls1_handle_timeout(SSL *s); -void dtls1_start_timer(SSL *s); -void dtls1_stop_timer(SSL *s); -__owur int dtls1_is_timer_expired(SSL *s); -__owur int dtls_raw_hello_verify_request(WPACKET *pkt, unsigned char *cookie, - size_t cookie_len); -__owur size_t dtls1_min_mtu(SSL *s); -void dtls1_hm_fragment_free(hm_fragment *frag); -__owur int dtls1_query_mtu(SSL *s); - -__owur int tls1_new(SSL *s); -void tls1_free(SSL *s); -int tls1_clear(SSL *s); - -__owur int dtls1_new(SSL *s); -void dtls1_free(SSL *s); -int dtls1_clear(SSL *s); -long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg); -__owur int dtls1_shutdown(SSL *s); - -__owur int dtls1_dispatch_alert(SSL *s); - -__owur int ssl_init_wbio_buffer(SSL *s); -int ssl_free_wbio_buffer(SSL *s); - -__owur int tls1_change_cipher_state(SSL *s, int which); -__owur int tls1_setup_key_block(SSL *s); -__owur size_t tls1_final_finish_mac(SSL *s, const char *str, size_t slen, - unsigned char *p); -__owur int tls1_generate_master_secret(SSL *s, unsigned char *out, - unsigned char *p, size_t len, - size_t *secret_size); -__owur int tls13_setup_key_block(SSL *s); -__owur size_t tls13_final_finish_mac(SSL *s, const char *str, size_t slen, - unsigned char *p); -__owur int tls13_change_cipher_state(SSL *s, int which); -__owur int tls13_update_key(SSL *s, int send); -__owur int tls13_hkdf_expand(SSL *s, const EVP_MD *md, - const unsigned char *secret, - const unsigned char *label, size_t labellen, - const unsigned char *data, size_t datalen, - unsigned char *out, size_t outlen, int fatal); -__owur int tls13_derive_key(SSL *s, const EVP_MD *md, - const unsigned char *secret, unsigned char *key, - size_t keylen); -__owur int tls13_derive_iv(SSL *s, const EVP_MD *md, - const unsigned char *secret, unsigned char *iv, - size_t ivlen); -__owur int tls13_derive_finishedkey(SSL *s, const EVP_MD *md, - const unsigned char *secret, - unsigned char *fin, size_t finlen); -int tls13_generate_secret(SSL *s, const EVP_MD *md, - const unsigned char *prevsecret, - const unsigned char *insecret, - size_t insecretlen, - unsigned char *outsecret); -__owur int tls13_generate_handshake_secret(SSL *s, - const unsigned char *insecret, - size_t insecretlen); -__owur int tls13_generate_master_secret(SSL *s, unsigned char *out, - unsigned char *prev, size_t prevlen, - size_t *secret_size); -__owur 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); -__owur int tls13_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); -__owur int tls13_export_keying_material_early(SSL *s, unsigned char *out, - size_t olen, const char *label, - size_t llen, - const unsigned char *context, - size_t contextlen); -__owur int tls1_alert_code(int code); -__owur int tls13_alert_code(int code); -__owur int ssl3_alert_code(int code); - -# ifndef OPENSSL_NO_EC -__owur int ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL *s); -# endif - -SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n); - -# ifndef OPENSSL_NO_EC - -__owur const TLS_GROUP_INFO *tls1_group_id_lookup(uint16_t curve_id); -__owur int tls1_check_group_id(SSL *s, uint16_t group_id, int check_own_curves); -__owur uint16_t tls1_shared_group(SSL *s, int nmatch); -__owur int tls1_set_groups(uint16_t **pext, size_t *pextlen, - int *curves, size_t ncurves); -__owur int tls1_set_groups_list(uint16_t **pext, size_t *pextlen, - const char *str); -void tls1_get_formatlist(SSL *s, const unsigned char **pformats, - size_t *num_formats); -__owur int tls1_check_ec_tmp_key(SSL *s, unsigned long id); -__owur EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id); -__owur EVP_PKEY *ssl_generate_param_group(uint16_t id); -# endif /* OPENSSL_NO_EC */ - -__owur int tls_curve_allowed(SSL *s, uint16_t curve, int op); -void tls1_get_supported_groups(SSL *s, const uint16_t **pgroups, - size_t *pgroupslen); - -__owur int tls1_set_server_sigalgs(SSL *s); - -__owur SSL_TICKET_STATUS tls_get_ticket_from_client(SSL *s, CLIENTHELLO_MSG *hello, - SSL_SESSION **ret); -__owur SSL_TICKET_STATUS tls_decrypt_ticket(SSL *s, const unsigned char *etick, - size_t eticklen, - const unsigned char *sess_id, - size_t sesslen, SSL_SESSION **psess); - -__owur int tls_use_ticket(SSL *s); - -void ssl_set_sig_mask(uint32_t *pmask_a, SSL *s, int op); - -__owur int tls1_set_sigalgs_list(CERT *c, const char *str, int client); -__owur int tls1_set_raw_sigalgs(CERT *c, const uint16_t *psigs, size_t salglen, - int client); -__owur int tls1_set_sigalgs(CERT *c, const int *salg, size_t salglen, - int client); -int tls1_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain, - int idx); -void tls1_set_cert_validity(SSL *s); - -# ifndef OPENSSL_NO_CT -__owur int ssl_validate_ct(SSL *s); -# endif - -# ifndef OPENSSL_NO_DH -__owur DH *ssl_get_auto_dh(SSL *s); -# endif - -__owur int ssl_security_cert(SSL *s, SSL_CTX *ctx, X509 *x, int vfy, int is_ee); -__owur int ssl_security_cert_chain(SSL *s, STACK_OF(X509) *sk, X509 *ex, - int vfy); - -int tls_choose_sigalg(SSL *s, int fatalerrs); - -__owur EVP_MD_CTX *ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md); -void ssl_clear_hash_ctx(EVP_MD_CTX **hash); -__owur long ssl_get_algorithm2(SSL *s); -__owur int tls12_copy_sigalgs(SSL *s, WPACKET *pkt, - const uint16_t *psig, size_t psiglen); -__owur int tls1_save_u16(PACKET *pkt, uint16_t **pdest, size_t *pdestlen); -__owur int tls1_save_sigalgs(SSL *s, PACKET *pkt, int cert); -__owur int tls1_process_sigalgs(SSL *s); -__owur int tls1_set_peer_legacy_sigalg(SSL *s, const EVP_PKEY *pkey); -__owur int tls1_lookup_md(const SIGALG_LOOKUP *lu, const EVP_MD **pmd); -__owur size_t tls12_get_psigalgs(SSL *s, int sent, const uint16_t **psigs); -# ifndef OPENSSL_NO_EC -__owur int tls_check_sigalg_curve(const SSL *s, int curve); -# endif -__owur int tls12_check_peer_sigalg(SSL *s, uint16_t, EVP_PKEY *pkey); -__owur int ssl_set_client_disabled(SSL *s); -__owur int ssl_cipher_disabled(const SSL *s, const SSL_CIPHER *c, int op, int echde); - -__owur int ssl_handshake_hash(SSL *s, unsigned char *out, size_t outlen, - size_t *hashlen); -__owur const EVP_MD *ssl_md(int idx); -__owur const EVP_MD *ssl_handshake_md(SSL *s); -__owur const EVP_MD *ssl_prf_md(SSL *s); - -/* - * ssl_log_rsa_client_key_exchange logs |premaster| to the SSL_CTX associated - * with |ssl|, if logging is enabled. It returns one on success and zero on - * failure. The entry is identified by the first 8 bytes of - * |encrypted_premaster|. - */ -__owur int ssl_log_rsa_client_key_exchange(SSL *ssl, - const uint8_t *encrypted_premaster, - size_t encrypted_premaster_len, - const uint8_t *premaster, - size_t premaster_len); - -/* - * ssl_log_secret logs |secret| to the SSL_CTX associated with |ssl|, if - * logging is available. It returns one on success and zero on failure. It tags - * the entry with |label|. - */ -__owur int ssl_log_secret(SSL *ssl, const char *label, - const uint8_t *secret, size_t secret_len); - -#define MASTER_SECRET_LABEL "CLIENT_RANDOM" -#define CLIENT_EARLY_LABEL "CLIENT_EARLY_TRAFFIC_SECRET" -#define CLIENT_HANDSHAKE_LABEL "CLIENT_HANDSHAKE_TRAFFIC_SECRET" -#define SERVER_HANDSHAKE_LABEL "SERVER_HANDSHAKE_TRAFFIC_SECRET" -#define CLIENT_APPLICATION_LABEL "CLIENT_TRAFFIC_SECRET_0" -#define SERVER_APPLICATION_LABEL "SERVER_TRAFFIC_SECRET_0" -#define EARLY_EXPORTER_SECRET_LABEL "EARLY_EXPORTER_SECRET" -#define EXPORTER_SECRET_LABEL "EXPORTER_SECRET" - -/* s3_cbc.c */ -__owur char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx); -__owur int ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, - unsigned char *md_out, - size_t *md_out_size, - const unsigned char header[13], - const unsigned char *data, - size_t data_plus_mac_size, - size_t data_plus_mac_plus_padding_size, - const unsigned char *mac_secret, - size_t mac_secret_length, char is_sslv3); - -__owur int srp_generate_server_master_secret(SSL *s); -__owur int srp_generate_client_master_secret(SSL *s); -__owur int srp_verify_server_param(SSL *s); - -/* statem/statem_srvr.c */ - -__owur int send_certificate_request(SSL *s); - -/* statem/extensions_cust.c */ - -custom_ext_method *custom_ext_find(const custom_ext_methods *exts, - ENDPOINT role, unsigned int ext_type, - size_t *idx); - -void custom_ext_init(custom_ext_methods *meths); - -__owur int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type, - const unsigned char *ext_data, size_t ext_size, - X509 *x, size_t chainidx); -__owur int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, - size_t chainidx, int maxversion); - -__owur int custom_exts_copy(custom_ext_methods *dst, - const custom_ext_methods *src); -__owur int custom_exts_copy_flags(custom_ext_methods *dst, - const custom_ext_methods *src); -void custom_exts_free(custom_ext_methods *exts); - -void ssl_comp_free_compression_methods_int(void); - -/* ssl_mcnf.c */ -void ssl_ctx_system_config(SSL_CTX *ctx); - -# else /* OPENSSL_UNIT_TEST */ - -# define ssl_init_wbio_buffer SSL_test_functions()->p_ssl_init_wbio_buffer -# define ssl3_setup_buffers SSL_test_functions()->p_ssl3_setup_buffers - -# endif -#endif + +__owur int ssl_cert_lookup_by_nid(int nid, size_t *pidx); +__owur const SSL_CERT_LOOKUP *ssl_cert_lookup_by_pkey(const EVP_PKEY *pk, + size_t *pidx); +__owur const SSL_CERT_LOOKUP *ssl_cert_lookup_by_idx(size_t idx); + +int ssl_undefined_function(SSL *s); +__owur int ssl_undefined_void_function(void); +__owur int ssl_undefined_const_function(const SSL *s); +__owur int ssl_get_server_cert_serverinfo(SSL *s, + const unsigned char **serverinfo, + size_t *serverinfo_length); +void ssl_set_masks(SSL *s); +__owur STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s); +__owur int ssl_x509err2alert(int type); +void ssl_sort_cipher_list(void); +int ssl_load_ciphers(void); +__owur int ssl_fill_hello_random(SSL *s, int server, unsigned char *field, + size_t len, DOWNGRADE dgrd); +__owur int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen, + int free_pms); +__owur EVP_PKEY *ssl_generate_pkey(EVP_PKEY *pm); +__owur int ssl_derive(SSL *s, EVP_PKEY *privkey, EVP_PKEY *pubkey, + int genmaster); +__owur EVP_PKEY *ssl_dh_to_pkey(DH *dh); +__owur unsigned int ssl_get_max_send_fragment(const SSL *ssl); +__owur unsigned int ssl_get_split_send_fragment(const SSL *ssl); + +__owur const SSL_CIPHER *ssl3_get_cipher_by_id(uint32_t id); +__owur const SSL_CIPHER *ssl3_get_cipher_by_std_name(const char *stdname); +__owur const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); +__owur int ssl3_put_cipher_by_char(const SSL_CIPHER *c, WPACKET *pkt, + size_t *len); +int ssl3_init_finished_mac(SSL *s); +__owur int ssl3_setup_key_block(SSL *s); +__owur int ssl3_change_cipher_state(SSL *s, int which); +void ssl3_cleanup_key_block(SSL *s); +__owur int ssl3_do_write(SSL *s, int type); +int ssl3_send_alert(SSL *s, int level, int desc); +__owur int ssl3_generate_master_secret(SSL *s, unsigned char *out, + unsigned char *p, size_t len, + size_t *secret_size); +__owur int ssl3_get_req_cert_type(SSL *s, WPACKET *pkt); +__owur int ssl3_num_ciphers(void); +__owur const SSL_CIPHER *ssl3_get_cipher(unsigned int u); +int ssl3_renegotiate(SSL *ssl); +int ssl3_renegotiate_check(SSL *ssl, int initok); +__owur int ssl3_dispatch_alert(SSL *s); +__owur size_t ssl3_final_finish_mac(SSL *s, const char *sender, size_t slen, + unsigned char *p); +__owur int ssl3_finish_mac(SSL *s, const unsigned char *buf, size_t len); +void ssl3_free_digest_list(SSL *s); +__owur unsigned long ssl3_output_cert_chain(SSL *s, WPACKET *pkt, + CERT_PKEY *cpk); +__owur const SSL_CIPHER *ssl3_choose_cipher(SSL *ssl, + STACK_OF(SSL_CIPHER) *clnt, + STACK_OF(SSL_CIPHER) *srvr); +__owur int ssl3_digest_cached_records(SSL *s, int keep); +__owur int ssl3_new(SSL *s); +void ssl3_free(SSL *s); +__owur int ssl3_read(SSL *s, void *buf, size_t len, size_t *readbytes); +__owur int ssl3_peek(SSL *s, void *buf, size_t len, size_t *readbytes); +__owur int ssl3_write(SSL *s, const void *buf, size_t len, size_t *written); +__owur int ssl3_shutdown(SSL *s); +int ssl3_clear(SSL *s); +__owur long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg); +__owur long ssl3_ctx_ctrl(SSL_CTX *s, int cmd, long larg, void *parg); +__owur long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp) (void)); +__owur long ssl3_ctx_callback_ctrl(SSL_CTX *s, int cmd, void (*fp) (void)); + +__owur int ssl3_do_change_cipher_spec(SSL *ssl); +__owur long ssl3_default_timeout(void); + +__owur int ssl3_set_handshake_header(SSL *s, WPACKET *pkt, int htype); +__owur int tls_close_construct_packet(SSL *s, WPACKET *pkt, int htype); +__owur int tls_setup_handshake(SSL *s); +__owur int dtls1_set_handshake_header(SSL *s, WPACKET *pkt, int htype); +__owur int dtls1_close_construct_packet(SSL *s, WPACKET *pkt, int htype); +__owur int ssl3_handshake_write(SSL *s); + +__owur int ssl_allow_compression(SSL *s); + +__owur int ssl_version_supported(const SSL *s, int version, + const SSL_METHOD **meth); + +__owur int ssl_set_client_hello_version(SSL *s); +__owur int ssl_check_version_downgrade(SSL *s); +__owur int ssl_set_version_bound(int method_version, int version, int *bound); +__owur int ssl_choose_server_version(SSL *s, CLIENTHELLO_MSG *hello, + DOWNGRADE *dgrd); +__owur int ssl_choose_client_version(SSL *s, int version, + RAW_EXTENSION *extensions); +__owur int ssl_get_min_max_version(const SSL *s, int *min_version, + int *max_version, int *real_max); + +__owur long tls1_default_timeout(void); +__owur int dtls1_do_write(SSL *s, int type); +void dtls1_set_message_header(SSL *s, + unsigned char mt, + size_t len, + size_t frag_off, size_t frag_len); + +int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf_, size_t len, + size_t *written); + +__owur int dtls1_read_failed(SSL *s, int code); +__owur int dtls1_buffer_message(SSL *s, int ccs); +__owur int dtls1_retransmit_message(SSL *s, unsigned short seq, int *found); +__owur int dtls1_get_queue_priority(unsigned short seq, int is_ccs); +int dtls1_retransmit_buffered_messages(SSL *s); +void dtls1_clear_received_buffer(SSL *s); +void dtls1_clear_sent_buffer(SSL *s); +void dtls1_get_message_header(unsigned char *data, + struct hm_header_st *msg_hdr); +__owur long dtls1_default_timeout(void); +__owur struct timeval *dtls1_get_timeout(SSL *s, struct timeval *timeleft); +__owur int dtls1_check_timeout_num(SSL *s); +__owur int dtls1_handle_timeout(SSL *s); +void dtls1_start_timer(SSL *s); +void dtls1_stop_timer(SSL *s); +__owur int dtls1_is_timer_expired(SSL *s); +__owur int dtls_raw_hello_verify_request(WPACKET *pkt, unsigned char *cookie, + size_t cookie_len); +__owur size_t dtls1_min_mtu(SSL *s); +void dtls1_hm_fragment_free(hm_fragment *frag); +__owur int dtls1_query_mtu(SSL *s); + +__owur int tls1_new(SSL *s); +void tls1_free(SSL *s); +int tls1_clear(SSL *s); + +__owur int dtls1_new(SSL *s); +void dtls1_free(SSL *s); +int dtls1_clear(SSL *s); +long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg); +__owur int dtls1_shutdown(SSL *s); + +__owur int dtls1_dispatch_alert(SSL *s); + +__owur int ssl_init_wbio_buffer(SSL *s); +int ssl_free_wbio_buffer(SSL *s); + +__owur int tls1_change_cipher_state(SSL *s, int which); +__owur int tls1_setup_key_block(SSL *s); +__owur size_t tls1_final_finish_mac(SSL *s, const char *str, size_t slen, + unsigned char *p); +__owur int tls1_generate_master_secret(SSL *s, unsigned char *out, + unsigned char *p, size_t len, + size_t *secret_size); +__owur int tls13_setup_key_block(SSL *s); +__owur size_t tls13_final_finish_mac(SSL *s, const char *str, size_t slen, + unsigned char *p); +__owur int tls13_change_cipher_state(SSL *s, int which); +__owur int tls13_update_key(SSL *s, int send); +__owur int tls13_hkdf_expand(SSL *s, const EVP_MD *md, + const unsigned char *secret, + const unsigned char *label, size_t labellen, + const unsigned char *data, size_t datalen, + unsigned char *out, size_t outlen, int fatal); +__owur int tls13_derive_key(SSL *s, const EVP_MD *md, + const unsigned char *secret, unsigned char *key, + size_t keylen); +__owur int tls13_derive_iv(SSL *s, const EVP_MD *md, + const unsigned char *secret, unsigned char *iv, + size_t ivlen); +__owur int tls13_derive_finishedkey(SSL *s, const EVP_MD *md, + const unsigned char *secret, + unsigned char *fin, size_t finlen); +int tls13_generate_secret(SSL *s, const EVP_MD *md, + const unsigned char *prevsecret, + const unsigned char *insecret, + size_t insecretlen, + unsigned char *outsecret); +__owur int tls13_generate_handshake_secret(SSL *s, + const unsigned char *insecret, + size_t insecretlen); +__owur int tls13_generate_master_secret(SSL *s, unsigned char *out, + unsigned char *prev, size_t prevlen, + size_t *secret_size); +__owur 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); +__owur int tls13_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); +__owur int tls13_export_keying_material_early(SSL *s, unsigned char *out, + size_t olen, const char *label, + size_t llen, + const unsigned char *context, + size_t contextlen); +__owur int tls1_alert_code(int code); +__owur int tls13_alert_code(int code); +__owur int ssl3_alert_code(int code); + +# ifndef OPENSSL_NO_EC +__owur int ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL *s); +# endif + +SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n); + +# ifndef OPENSSL_NO_EC + +__owur const TLS_GROUP_INFO *tls1_group_id_lookup(uint16_t curve_id); +__owur int tls1_check_group_id(SSL *s, uint16_t group_id, int check_own_curves); +__owur uint16_t tls1_shared_group(SSL *s, int nmatch); +__owur int tls1_set_groups(uint16_t **pext, size_t *pextlen, + int *curves, size_t ncurves); +__owur int tls1_set_groups_list(uint16_t **pext, size_t *pextlen, + const char *str); +void tls1_get_formatlist(SSL *s, const unsigned char **pformats, + size_t *num_formats); +__owur int tls1_check_ec_tmp_key(SSL *s, unsigned long id); +__owur EVP_PKEY *ssl_generate_pkey_group(SSL *s, uint16_t id); +__owur EVP_PKEY *ssl_generate_param_group(uint16_t id); +# endif /* OPENSSL_NO_EC */ + +__owur int tls_curve_allowed(SSL *s, uint16_t curve, int op); +void tls1_get_supported_groups(SSL *s, const uint16_t **pgroups, + size_t *pgroupslen); + +__owur int tls1_set_server_sigalgs(SSL *s); + +__owur SSL_TICKET_STATUS tls_get_ticket_from_client(SSL *s, CLIENTHELLO_MSG *hello, + SSL_SESSION **ret); +__owur SSL_TICKET_STATUS tls_decrypt_ticket(SSL *s, const unsigned char *etick, + size_t eticklen, + const unsigned char *sess_id, + size_t sesslen, SSL_SESSION **psess); + +__owur int tls_use_ticket(SSL *s); + +void ssl_set_sig_mask(uint32_t *pmask_a, SSL *s, int op); + +__owur int tls1_set_sigalgs_list(CERT *c, const char *str, int client); +__owur int tls1_set_raw_sigalgs(CERT *c, const uint16_t *psigs, size_t salglen, + int client); +__owur int tls1_set_sigalgs(CERT *c, const int *salg, size_t salglen, + int client); +int tls1_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain, + int idx); +void tls1_set_cert_validity(SSL *s); + +# ifndef OPENSSL_NO_CT +__owur int ssl_validate_ct(SSL *s); +# endif + +# ifndef OPENSSL_NO_DH +__owur DH *ssl_get_auto_dh(SSL *s); +# endif + +__owur int ssl_security_cert(SSL *s, SSL_CTX *ctx, X509 *x, int vfy, int is_ee); +__owur int ssl_security_cert_chain(SSL *s, STACK_OF(X509) *sk, X509 *ex, + int vfy); + +int tls_choose_sigalg(SSL *s, int fatalerrs); + +__owur EVP_MD_CTX *ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md); +void ssl_clear_hash_ctx(EVP_MD_CTX **hash); +__owur long ssl_get_algorithm2(SSL *s); +__owur int tls12_copy_sigalgs(SSL *s, WPACKET *pkt, + const uint16_t *psig, size_t psiglen); +__owur int tls1_save_u16(PACKET *pkt, uint16_t **pdest, size_t *pdestlen); +__owur int tls1_save_sigalgs(SSL *s, PACKET *pkt, int cert); +__owur int tls1_process_sigalgs(SSL *s); +__owur int tls1_set_peer_legacy_sigalg(SSL *s, const EVP_PKEY *pkey); +__owur int tls1_lookup_md(const SIGALG_LOOKUP *lu, const EVP_MD **pmd); +__owur size_t tls12_get_psigalgs(SSL *s, int sent, const uint16_t **psigs); +# ifndef OPENSSL_NO_EC +__owur int tls_check_sigalg_curve(const SSL *s, int curve); +# endif +__owur int tls12_check_peer_sigalg(SSL *s, uint16_t, EVP_PKEY *pkey); +__owur int ssl_set_client_disabled(SSL *s); +__owur int ssl_cipher_disabled(const SSL *s, const SSL_CIPHER *c, int op, int echde); + +__owur int ssl_handshake_hash(SSL *s, unsigned char *out, size_t outlen, + size_t *hashlen); +__owur const EVP_MD *ssl_md(int idx); +__owur const EVP_MD *ssl_handshake_md(SSL *s); +__owur const EVP_MD *ssl_prf_md(SSL *s); + +/* + * ssl_log_rsa_client_key_exchange logs |premaster| to the SSL_CTX associated + * with |ssl|, if logging is enabled. It returns one on success and zero on + * failure. The entry is identified by the first 8 bytes of + * |encrypted_premaster|. + */ +__owur int ssl_log_rsa_client_key_exchange(SSL *ssl, + const uint8_t *encrypted_premaster, + size_t encrypted_premaster_len, + const uint8_t *premaster, + size_t premaster_len); + +/* + * ssl_log_secret logs |secret| to the SSL_CTX associated with |ssl|, if + * logging is available. It returns one on success and zero on failure. It tags + * the entry with |label|. + */ +__owur int ssl_log_secret(SSL *ssl, const char *label, + const uint8_t *secret, size_t secret_len); + +#define MASTER_SECRET_LABEL "CLIENT_RANDOM" +#define CLIENT_EARLY_LABEL "CLIENT_EARLY_TRAFFIC_SECRET" +#define CLIENT_HANDSHAKE_LABEL "CLIENT_HANDSHAKE_TRAFFIC_SECRET" +#define SERVER_HANDSHAKE_LABEL "SERVER_HANDSHAKE_TRAFFIC_SECRET" +#define CLIENT_APPLICATION_LABEL "CLIENT_TRAFFIC_SECRET_0" +#define SERVER_APPLICATION_LABEL "SERVER_TRAFFIC_SECRET_0" +#define EARLY_EXPORTER_SECRET_LABEL "EARLY_EXPORTER_SECRET" +#define EXPORTER_SECRET_LABEL "EXPORTER_SECRET" + +/* s3_cbc.c */ +__owur char ssl3_cbc_record_digest_supported(const EVP_MD_CTX *ctx); +__owur int ssl3_cbc_digest_record(const EVP_MD_CTX *ctx, + unsigned char *md_out, + size_t *md_out_size, + const unsigned char header[13], + const unsigned char *data, + size_t data_plus_mac_size, + size_t data_plus_mac_plus_padding_size, + const unsigned char *mac_secret, + size_t mac_secret_length, char is_sslv3); + +__owur int srp_generate_server_master_secret(SSL *s); +__owur int srp_generate_client_master_secret(SSL *s); +__owur int srp_verify_server_param(SSL *s); + +/* statem/statem_srvr.c */ + +__owur int send_certificate_request(SSL *s); + +/* statem/extensions_cust.c */ + +custom_ext_method *custom_ext_find(const custom_ext_methods *exts, + ENDPOINT role, unsigned int ext_type, + size_t *idx); + +void custom_ext_init(custom_ext_methods *meths); + +__owur int custom_ext_parse(SSL *s, unsigned int context, unsigned int ext_type, + const unsigned char *ext_data, size_t ext_size, + X509 *x, size_t chainidx); +__owur int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, + size_t chainidx, int maxversion); + +__owur int custom_exts_copy(custom_ext_methods *dst, + const custom_ext_methods *src); +__owur int custom_exts_copy_flags(custom_ext_methods *dst, + const custom_ext_methods *src); +void custom_exts_free(custom_ext_methods *exts); + +void ssl_comp_free_compression_methods_int(void); + +/* ssl_mcnf.c */ +void ssl_ctx_system_config(SSL_CTX *ctx); + +# else /* OPENSSL_UNIT_TEST */ + +# define ssl_init_wbio_buffer SSL_test_functions()->p_ssl_init_wbio_buffer +# define ssl3_setup_buffers SSL_test_functions()->p_ssl3_setup_buffers + +# endif +#endif diff --git a/contrib/libs/openssl/ssl/ssl_mcnf.c b/contrib/libs/openssl/ssl/ssl_mcnf.c index 6b4f004357..583df41669 100644 --- a/contrib/libs/openssl/ssl/ssl_mcnf.c +++ b/contrib/libs/openssl/ssl/ssl_mcnf.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <openssl/conf.h> #include <openssl/ssl.h> -#include "ssl_local.h" +#include "ssl_local.h" #include "internal/sslconf.h" /* SSL library configuration module. */ diff --git a/contrib/libs/openssl/ssl/ssl_rsa.c b/contrib/libs/openssl/ssl/ssl_rsa.c index 718ff31b33..6457c0c0ef 100644 --- a/contrib/libs/openssl/ssl/ssl_rsa.c +++ b/contrib/libs/openssl/ssl/ssl_rsa.c @@ -8,8 +8,8 @@ */ #include <stdio.h> -#include "ssl_local.h" -#include "packet_local.h" +#include "ssl_local.h" +#include "packet_local.h" #include <openssl/bio.h> #include <openssl/objects.h> #include <openssl/evp.h> diff --git a/contrib/libs/openssl/ssl/ssl_sess.c b/contrib/libs/openssl/ssl/ssl_sess.c index 3385099b3f..cda6b7cc5b 100644 --- a/contrib/libs/openssl/ssl/ssl_sess.c +++ b/contrib/libs/openssl/ssl/ssl_sess.c @@ -13,8 +13,8 @@ #include <openssl/engine.h> #include "internal/refcount.h" #include "internal/cryptlib.h" -#include "ssl_local.h" -#include "statem/statem_local.h" +#include "ssl_local.h" +#include "statem/statem_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); diff --git a/contrib/libs/openssl/ssl/ssl_stat.c b/contrib/libs/openssl/ssl/ssl_stat.c index aef65fa03c..ca51c0331c 100644 --- a/contrib/libs/openssl/ssl/ssl_stat.c +++ b/contrib/libs/openssl/ssl/ssl_stat.c @@ -9,7 +9,7 @@ */ #include <stdio.h> -#include "ssl_local.h" +#include "ssl_local.h" const char *SSL_state_string_long(const SSL *s) { diff --git a/contrib/libs/openssl/ssl/ssl_txt.c b/contrib/libs/openssl/ssl/ssl_txt.c index 22eb2edcdd..457bc8b3c2 100644 --- a/contrib/libs/openssl/ssl/ssl_txt.c +++ b/contrib/libs/openssl/ssl/ssl_txt.c @@ -10,7 +10,7 @@ #include <stdio.h> #include <openssl/buffer.h> -#include "ssl_local.h" +#include "ssl_local.h" #ifndef OPENSSL_NO_STDIO int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x) diff --git a/contrib/libs/openssl/ssl/ssl_utst.c b/contrib/libs/openssl/ssl/ssl_utst.c index 7e7a63f029..487f56e539 100644 --- a/contrib/libs/openssl/ssl/ssl_utst.c +++ b/contrib/libs/openssl/ssl/ssl_utst.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "ssl_local.h" +#include "ssl_local.h" #ifndef OPENSSL_NO_UNIT_TEST diff --git a/contrib/libs/openssl/ssl/statem/extensions.c b/contrib/libs/openssl/ssl/statem/extensions.c index 41fe990aa5..0f39275baa 100644 --- a/contrib/libs/openssl/ssl/statem/extensions.c +++ b/contrib/libs/openssl/ssl/statem/extensions.c @@ -10,8 +10,8 @@ #include <string.h> #include "internal/nelem.h" #include "internal/cryptlib.h" -#include "../ssl_local.h" -#include "statem_local.h" +#include "../ssl_local.h" +#include "statem_local.h" #include "internal/cryptlib.h" static int final_renegotiate(SSL *s, unsigned int context, int sent); @@ -96,7 +96,7 @@ typedef struct extensions_definition_st { /* * Definitions of all built-in extensions. NOTE: Changes in the number or order * of these extensions should be mirrored with equivalent changes to the - * indexes ( TLSEXT_IDX_* ) defined in ssl_local.h. + * indexes ( TLSEXT_IDX_* ) defined in ssl_local.h. * Each extension has an initialiser, a client and * server side parser and a finaliser. The initialiser is called (if the * extension is relevant to the given context) even if we did not see the @@ -953,7 +953,7 @@ static int final_server_name(SSL *s, unsigned int context, int sent) * was successful. */ if (s->server) { - if (sent && ret == SSL_TLSEXT_ERR_OK && !s->hit) { + if (sent && ret == SSL_TLSEXT_ERR_OK && !s->hit) { /* Only store the hostname in the session if we accepted it. */ OPENSSL_free(s->session->ext.hostname); s->session->ext.hostname = OPENSSL_strdup(s->ext.hostname); @@ -1015,7 +1015,7 @@ static int final_server_name(SSL *s, unsigned int context, int sent) /* TLSv1.3 doesn't have warning alerts so we suppress this */ if (!SSL_IS_TLS13(s)) ssl3_send_alert(s, SSL3_AL_WARNING, altmp); - s->servername_done = 0; + s->servername_done = 0; return 1; case SSL_TLSEXT_ERR_NOACK: @@ -1477,7 +1477,7 @@ int tls_psk_do_binder(SSL *s, const EVP_MD *md, const unsigned char *msgstart, unsigned char finishedkey[EVP_MAX_MD_SIZE], tmpbinder[EVP_MAX_MD_SIZE]; unsigned char *early_secret; #ifdef CHARSET_EBCDIC - static const unsigned char resumption_label[] = { 0x72, 0x65, 0x73, 0x20, 0x62, 0x69, 0x6E, 0x64, 0x65, 0x72, 0x00 }; + static const unsigned char resumption_label[] = { 0x72, 0x65, 0x73, 0x20, 0x62, 0x69, 0x6E, 0x64, 0x65, 0x72, 0x00 }; static const unsigned char external_label[] = { 0x65, 0x78, 0x74, 0x20, 0x62, 0x69, 0x6E, 0x64, 0x65, 0x72, 0x00 }; #else static const unsigned char resumption_label[] = "res binder"; diff --git a/contrib/libs/openssl/ssl/statem/extensions_clnt.c b/contrib/libs/openssl/ssl/statem/extensions_clnt.c index 3b02351294..ce8a75794c 100644 --- a/contrib/libs/openssl/ssl/statem/extensions_clnt.c +++ b/contrib/libs/openssl/ssl/statem/extensions_clnt.c @@ -8,9 +8,9 @@ */ #include <openssl/ocsp.h> -#include "../ssl_local.h" +#include "../ssl_local.h" #include "internal/cryptlib.h" -#include "statem_local.h" +#include "statem_local.h" EXT_RETURN tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, diff --git a/contrib/libs/openssl/ssl/statem/extensions_cust.c b/contrib/libs/openssl/ssl/statem/extensions_cust.c index 9bdc486e7b..a0ba18efa7 100644 --- a/contrib/libs/openssl/ssl/statem/extensions_cust.c +++ b/contrib/libs/openssl/ssl/statem/extensions_cust.c @@ -10,9 +10,9 @@ /* Custom extension utility functions */ #include <openssl/ct.h> -#include "../ssl_local.h" +#include "../ssl_local.h" #include "internal/cryptlib.h" -#include "statem_local.h" +#include "statem_local.h" typedef struct { void *add_arg; diff --git a/contrib/libs/openssl/ssl/statem/extensions_srvr.c b/contrib/libs/openssl/ssl/statem/extensions_srvr.c index 702ad7e45f..04f64f8106 100644 --- a/contrib/libs/openssl/ssl/statem/extensions_srvr.c +++ b/contrib/libs/openssl/ssl/statem/extensions_srvr.c @@ -8,8 +8,8 @@ */ #include <openssl/ocsp.h> -#include "../ssl_local.h" -#include "statem_local.h" +#include "../ssl_local.h" +#include "statem_local.h" #include "internal/cryptlib.h" #define COOKIE_STATE_FORMAT_VERSION 0 @@ -127,10 +127,10 @@ int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context, return 0; } - /* - * In TLSv1.2 and below the SNI is associated with the session. In TLSv1.3 - * we always use the SNI value from the handshake. - */ + /* + * In TLSv1.2 and below the SNI is associated with the session. In TLSv1.3 + * we always use the SNI value from the handshake. + */ if (!s->hit || SSL_IS_TLS13(s)) { if (PACKET_remaining(&hostname) > TLSEXT_MAXLEN_host_name) { SSLfatal(s, SSL_AD_UNRECOGNIZED_NAME, @@ -159,13 +159,13 @@ int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context, } s->servername_done = 1; - } else { + } else { + /* + * In TLSv1.2 and below we should check if the SNI is consistent between + * the initial handshake and the resumption. In TLSv1.3 SNI is not + * associated with the session. + */ /* - * In TLSv1.2 and below we should check if the SNI is consistent between - * the initial handshake and the resumption. In TLSv1.3 SNI is not - * associated with the session. - */ - /* * TODO(openssl-team): if the SNI doesn't match, we MUST * fall back to a full handshake. */ @@ -1335,16 +1335,16 @@ EXT_RETURN tls_construct_stoc_server_name(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, size_t chainidx) { - if (s->servername_done != 1) + if (s->servername_done != 1) + return EXT_RETURN_NOT_SENT; + + /* + * Prior to TLSv1.3 we ignore any SNI in the current handshake if resuming. + * We just use the servername from the initial handshake. + */ + if (s->hit && !SSL_IS_TLS13(s)) return EXT_RETURN_NOT_SENT; - /* - * Prior to TLSv1.3 we ignore any SNI in the current handshake if resuming. - * We just use the servername from the initial handshake. - */ - if (s->hit && !SSL_IS_TLS13(s)) - return EXT_RETURN_NOT_SENT; - if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_server_name) || !WPACKET_put_bytes_u16(pkt, 0)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_STOC_SERVER_NAME, diff --git a/contrib/libs/openssl/ssl/statem/statem.c b/contrib/libs/openssl/ssl/statem/statem.c index e9c93e11e3..20f5bd584e 100644 --- a/contrib/libs/openssl/ssl/statem/statem.c +++ b/contrib/libs/openssl/ssl/statem/statem.c @@ -9,8 +9,8 @@ #include "internal/cryptlib.h" #include <openssl/rand.h> -#include "../ssl_local.h" -#include "statem_local.h" +#include "../ssl_local.h" +#include "statem_local.h" #include <assert.h> /* diff --git a/contrib/libs/openssl/ssl/statem/statem_clnt.c b/contrib/libs/openssl/ssl/statem/statem_clnt.c index 22c3acb1a4..d1a3969812 100644 --- a/contrib/libs/openssl/ssl/statem/statem_clnt.c +++ b/contrib/libs/openssl/ssl/statem/statem_clnt.c @@ -12,8 +12,8 @@ #include <stdio.h> #include <time.h> #include <assert.h> -#include "../ssl_local.h" -#include "statem_local.h" +#include "../ssl_local.h" +#include "statem_local.h" #include <openssl/buffer.h> #include <openssl/rand.h> #include <openssl/objects.h> diff --git a/contrib/libs/openssl/ssl/statem/statem_dtls.c b/contrib/libs/openssl/ssl/statem/statem_dtls.c index e9177996bb..8e3fb686ee 100644 --- a/contrib/libs/openssl/ssl/statem/statem_dtls.c +++ b/contrib/libs/openssl/ssl/statem/statem_dtls.c @@ -10,8 +10,8 @@ #include <limits.h> #include <string.h> #include <stdio.h> -#include "../ssl_local.h" -#include "statem_local.h" +#include "../ssl_local.h" +#include "statem_local.h" #include "internal/cryptlib.h" #include <openssl/buffer.h> #include <openssl/objects.h> diff --git a/contrib/libs/openssl/ssl/statem/statem_lib.c b/contrib/libs/openssl/ssl/statem/statem_lib.c index 4f542ccfd9..c3b6f8f456 100644 --- a/contrib/libs/openssl/ssl/statem/statem_lib.c +++ b/contrib/libs/openssl/ssl/statem/statem_lib.c @@ -1,5 +1,5 @@ /* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * * Licensed under the OpenSSL license (the "License"). You may not use @@ -11,8 +11,8 @@ #include <limits.h> #include <string.h> #include <stdio.h> -#include "../ssl_local.h" -#include "statem_local.h" +#include "../ssl_local.h" +#include "statem_local.h" #include "internal/cryptlib.h" #include <openssl/buffer.h> #include <openssl/objects.h> @@ -169,17 +169,17 @@ static int get_cert_verify_tbs_data(SSL *s, unsigned char *tls13tbs, void **hdata, size_t *hdatalen) { #ifdef CHARSET_EBCDIC - static const char servercontext[] = { 0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, + static const char servercontext[] = { 0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x33, 0x2c, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x00 }; - static const char clientcontext[] = { 0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, + static const char clientcontext[] = { 0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x33, 0x2c, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x00 }; #else - static const char servercontext[] = "TLS 1.3, server CertificateVerify"; - static const char clientcontext[] = "TLS 1.3, client CertificateVerify"; + static const char servercontext[] = "TLS 1.3, server CertificateVerify"; + static const char clientcontext[] = "TLS 1.3, client CertificateVerify"; #endif if (SSL_IS_TLS13(s)) { size_t hashlen; @@ -844,11 +844,11 @@ MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt) return MSG_PROCESS_ERROR; } } else { - /* TLS 1.3 gets the secret size from the handshake md */ - size_t dummy; + /* TLS 1.3 gets the secret size from the handshake md */ + size_t dummy; if (!s->method->ssl3_enc->generate_master_secret(s, s->master_secret, s->handshake_secret, 0, - &dummy)) { + &dummy)) { /* SSLfatal() already called */ return MSG_PROCESS_ERROR; } @@ -1035,25 +1035,25 @@ WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, int stop) int cleanuphand = s->statem.cleanuphand; if (clearbufs) { - if (!SSL_IS_DTLS(s) -#ifndef OPENSSL_NO_SCTP + if (!SSL_IS_DTLS(s) +#ifndef OPENSSL_NO_SCTP /* - * RFC6083: SCTP provides a reliable and in-sequence transport service for DTLS - * messages that require it. Therefore, DTLS procedures for retransmissions - * MUST NOT be used. - * Hence the init_buf can be cleared when DTLS over SCTP as transport is used. - */ - || BIO_dgram_is_sctp(SSL_get_wbio(s)) -#endif - ) { - /* - * We don't do this in DTLS over UDP because we may still need the init_buf + * RFC6083: SCTP provides a reliable and in-sequence transport service for DTLS + * messages that require it. Therefore, DTLS procedures for retransmissions + * MUST NOT be used. + * Hence the init_buf can be cleared when DTLS over SCTP as transport is used. + */ + || BIO_dgram_is_sctp(SSL_get_wbio(s)) +#endif + ) { + /* + * We don't do this in DTLS over UDP because we may still need the init_buf * in case there are any unexpected retransmits */ BUF_MEM_free(s->init_buf); s->init_buf = NULL; } - + if (!ssl_free_wbio_buffer(s)) { SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_FINISH_HANDSHAKE, ERR_R_INTERNAL_ERROR); diff --git a/contrib/libs/openssl/ssl/statem/statem_local.h b/contrib/libs/openssl/ssl/statem/statem_local.h index aaac679b18..eae88053dc 100644 --- a/contrib/libs/openssl/ssl/statem/statem_local.h +++ b/contrib/libs/openssl/ssl/statem/statem_local.h @@ -1,422 +1,422 @@ -/* +/* * Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/***************************************************************************** - * * - * The following definitions are PRIVATE to the state machine. They should * - * NOT be used outside of the state machine. * - * * - *****************************************************************************/ - -/* Max message length definitions */ - -/* The spec allows for a longer length than this, but we limit it */ -#define HELLO_VERIFY_REQUEST_MAX_LENGTH 258 -#define END_OF_EARLY_DATA_MAX_LENGTH 0 -#define SERVER_HELLO_MAX_LENGTH 20000 -#define HELLO_RETRY_REQUEST_MAX_LENGTH 20000 -#define ENCRYPTED_EXTENSIONS_MAX_LENGTH 20000 + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +/***************************************************************************** + * * + * The following definitions are PRIVATE to the state machine. They should * + * NOT be used outside of the state machine. * + * * + *****************************************************************************/ + +/* Max message length definitions */ + +/* The spec allows for a longer length than this, but we limit it */ +#define HELLO_VERIFY_REQUEST_MAX_LENGTH 258 +#define END_OF_EARLY_DATA_MAX_LENGTH 0 +#define SERVER_HELLO_MAX_LENGTH 20000 +#define HELLO_RETRY_REQUEST_MAX_LENGTH 20000 +#define ENCRYPTED_EXTENSIONS_MAX_LENGTH 20000 #define SESSION_TICKET_MAX_LENGTH_TLS13 131338 #define SESSION_TICKET_MAX_LENGTH_TLS12 65541 -#define SERVER_KEY_EXCH_MAX_LENGTH 102400 -#define SERVER_HELLO_DONE_MAX_LENGTH 0 -#define KEY_UPDATE_MAX_LENGTH 1 -#define CCS_MAX_LENGTH 1 -/* Max should actually be 36 but we are generous */ -#define FINISHED_MAX_LENGTH 64 - -/* Dummy message type */ -#define SSL3_MT_DUMMY -1 - -extern const unsigned char hrrrandom[]; - -/* Message processing return codes */ -typedef enum { - /* Something bad happened */ - MSG_PROCESS_ERROR, - /* We've finished reading - swap to writing */ - MSG_PROCESS_FINISHED_READING, - /* - * We've completed the main processing of this message but there is some - * post processing to be done. - */ - MSG_PROCESS_CONTINUE_PROCESSING, - /* We've finished this message - read the next message */ - MSG_PROCESS_CONTINUE_READING -} MSG_PROCESS_RETURN; - -typedef int (*confunc_f) (SSL *s, WPACKET *pkt); - -int ssl3_take_mac(SSL *s); -int check_in_list(SSL *s, uint16_t group_id, const uint16_t *groups, - size_t num_groups, int checkallow); -int create_synthetic_message_hash(SSL *s, const unsigned char *hashval, - size_t hashlen, const unsigned char *hrr, - size_t hrrlen); -int parse_ca_names(SSL *s, PACKET *pkt); -const STACK_OF(X509_NAME) *get_ca_names(SSL *s); -int construct_ca_names(SSL *s, const STACK_OF(X509_NAME) *ca_sk, WPACKET *pkt); -size_t construct_key_exchange_tbs(SSL *s, unsigned char **ptbs, - const void *param, size_t paramlen); - -/* - * TLS/DTLS client state machine functions - */ -int ossl_statem_client_read_transition(SSL *s, int mt); -WRITE_TRAN ossl_statem_client_write_transition(SSL *s); -WORK_STATE ossl_statem_client_pre_work(SSL *s, WORK_STATE wst); -WORK_STATE ossl_statem_client_post_work(SSL *s, WORK_STATE wst); -int ossl_statem_client_construct_message(SSL *s, WPACKET *pkt, - confunc_f *confunc, int *mt); -size_t ossl_statem_client_max_message_size(SSL *s); -MSG_PROCESS_RETURN ossl_statem_client_process_message(SSL *s, PACKET *pkt); -WORK_STATE ossl_statem_client_post_process_message(SSL *s, WORK_STATE wst); - -/* - * TLS/DTLS server state machine functions - */ -int ossl_statem_server_read_transition(SSL *s, int mt); -WRITE_TRAN ossl_statem_server_write_transition(SSL *s); -WORK_STATE ossl_statem_server_pre_work(SSL *s, WORK_STATE wst); -WORK_STATE ossl_statem_server_post_work(SSL *s, WORK_STATE wst); -int ossl_statem_server_construct_message(SSL *s, WPACKET *pkt, - confunc_f *confunc,int *mt); -size_t ossl_statem_server_max_message_size(SSL *s); -MSG_PROCESS_RETURN ossl_statem_server_process_message(SSL *s, PACKET *pkt); -WORK_STATE ossl_statem_server_post_process_message(SSL *s, WORK_STATE wst); - -/* Functions for getting new message data */ -__owur int tls_get_message_header(SSL *s, int *mt); -__owur int tls_get_message_body(SSL *s, size_t *len); -__owur int dtls_get_message(SSL *s, int *mt, size_t *len); - -/* Message construction and processing functions */ -__owur int tls_process_initial_server_flight(SSL *s); -__owur MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt); -__owur int tls_construct_change_cipher_spec(SSL *s, WPACKET *pkt); -__owur int dtls_construct_change_cipher_spec(SSL *s, WPACKET *pkt); - -__owur int tls_construct_finished(SSL *s, WPACKET *pkt); -__owur int tls_construct_key_update(SSL *s, WPACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt); -__owur WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, - int stop); -__owur WORK_STATE dtls_wait_for_dry(SSL *s); - -/* some client-only functions */ -__owur int tls_construct_client_hello(SSL *s, WPACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_certificate_request(SSL *s, PACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt); -__owur int tls_process_cert_status_body(SSL *s, PACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt); -__owur int tls_construct_cert_verify(SSL *s, WPACKET *pkt); -__owur WORK_STATE tls_prepare_client_certificate(SSL *s, WORK_STATE wst); -__owur int tls_construct_client_certificate(SSL *s, WPACKET *pkt); -__owur int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey); -__owur int tls_construct_client_key_exchange(SSL *s, WPACKET *pkt); -__owur int tls_client_key_exchange_post_work(SSL *s); -__owur int tls_construct_cert_status_body(SSL *s, WPACKET *pkt); -__owur int tls_construct_cert_status(SSL *s, WPACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, PACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_server_certificate(SSL *s, PACKET *pkt); -__owur int ssl3_check_cert_and_algorithm(SSL *s); -#ifndef OPENSSL_NO_NEXTPROTONEG -__owur int tls_construct_next_proto(SSL *s, WPACKET *pkt); -#endif -__owur MSG_PROCESS_RETURN tls_process_hello_req(SSL *s, PACKET *pkt); -__owur MSG_PROCESS_RETURN dtls_process_hello_verify(SSL *s, PACKET *pkt); -__owur int tls_construct_end_of_early_data(SSL *s, WPACKET *pkt); - -/* some server-only functions */ -__owur MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt); -__owur WORK_STATE tls_post_process_client_hello(SSL *s, WORK_STATE wst); -__owur int tls_construct_server_hello(SSL *s, WPACKET *pkt); -__owur int dtls_construct_hello_verify_request(SSL *s, WPACKET *pkt); -__owur int tls_construct_server_certificate(SSL *s, WPACKET *pkt); -__owur int tls_construct_server_key_exchange(SSL *s, WPACKET *pkt); -__owur int tls_construct_certificate_request(SSL *s, WPACKET *pkt); -__owur int tls_construct_server_done(SSL *s, WPACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_client_certificate(SSL *s, PACKET *pkt); -__owur MSG_PROCESS_RETURN tls_process_client_key_exchange(SSL *s, PACKET *pkt); -__owur WORK_STATE tls_post_process_client_key_exchange(SSL *s, WORK_STATE wst); -__owur MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt); -#ifndef OPENSSL_NO_NEXTPROTONEG -__owur MSG_PROCESS_RETURN tls_process_next_proto(SSL *s, PACKET *pkt); -#endif -__owur int tls_construct_new_session_ticket(SSL *s, WPACKET *pkt); -MSG_PROCESS_RETURN tls_process_end_of_early_data(SSL *s, PACKET *pkt); - - -/* Extension processing */ - -typedef enum ext_return_en { - EXT_RETURN_FAIL, - EXT_RETURN_SENT, - EXT_RETURN_NOT_SENT -} EXT_RETURN; - -__owur int tls_validate_all_contexts(SSL *s, unsigned int thisctx, - RAW_EXTENSION *exts); -__owur int extension_is_relevant(SSL *s, unsigned int extctx, - unsigned int thisctx); -__owur int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context, - RAW_EXTENSION **res, size_t *len, int init); -__owur int tls_parse_extension(SSL *s, TLSEXT_INDEX idx, int context, - RAW_EXTENSION *exts, X509 *x, size_t chainidx); -__owur int tls_parse_all_extensions(SSL *s, int context, RAW_EXTENSION *exts, - X509 *x, size_t chainidx, int fin); -__owur int should_add_extension(SSL *s, unsigned int extctx, - unsigned int thisctx, int max_version); -__owur int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); - -__owur int tls_psk_do_binder(SSL *s, const EVP_MD *md, - const unsigned char *msgstart, - size_t binderoffset, const unsigned char *binderin, - unsigned char *binderout, - SSL_SESSION *sess, int sign, int external); - -/* Server Extension processing */ -int tls_parse_ctos_renegotiate(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -int tls_parse_ctos_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_SRP -int tls_parse_ctos_srp(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -#endif -int tls_parse_ctos_early_data(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_EC -int tls_parse_ctos_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidxl); -#endif -int tls_parse_ctos_session_ticket(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -int tls_parse_ctos_sig_algs_cert(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -int tls_parse_ctos_sig_algs(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -#ifndef OPENSSL_NO_OCSP -int tls_parse_ctos_status_request(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#endif -#ifndef OPENSSL_NO_NEXTPROTONEG -int tls_parse_ctos_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -#endif -int tls_parse_ctos_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -#ifndef OPENSSL_NO_SRTP -int tls_parse_ctos_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -#endif -int tls_parse_ctos_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -int tls_parse_ctos_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -int tls_parse_ctos_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -int tls_parse_ctos_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -int tls_parse_ctos_psk_kex_modes(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -int tls_parse_ctos_post_handshake_auth(SSL *, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); - -EXT_RETURN tls_construct_stoc_renegotiate(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_stoc_server_name(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_stoc_early_data(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_stoc_maxfragmentlen(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -#ifndef OPENSSL_NO_EC -EXT_RETURN tls_construct_stoc_ec_pt_formats(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -#endif -EXT_RETURN tls_construct_stoc_supported_groups(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_stoc_session_ticket(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -#ifndef OPENSSL_NO_OCSP -EXT_RETURN tls_construct_stoc_status_request(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -#endif -#ifndef OPENSSL_NO_NEXTPROTONEG -EXT_RETURN tls_construct_stoc_next_proto_neg(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -#endif -EXT_RETURN tls_construct_stoc_alpn(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_SRTP -EXT_RETURN tls_construct_stoc_use_srtp(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#endif -EXT_RETURN tls_construct_stoc_etm(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -EXT_RETURN tls_construct_stoc_ems(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -EXT_RETURN tls_construct_stoc_supported_versions(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_stoc_key_share(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_stoc_cookie(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -/* - * Not in public headers as this is not an official extension. Only used when - * SSL_OP_CRYPTOPRO_TLSEXT_BUG is set. - */ -#define TLSEXT_TYPE_cryptopro_bug 0xfde8 -EXT_RETURN tls_construct_stoc_cryptopro_bug(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_stoc_psk(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); - -/* Client Extension processing */ -EXT_RETURN tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -EXT_RETURN tls_construct_ctos_server_name(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -EXT_RETURN tls_construct_ctos_maxfragmentlen(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_SRP -EXT_RETURN tls_construct_ctos_srp(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -#endif -#ifndef OPENSSL_NO_EC -EXT_RETURN tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_ctos_supported_groups(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -#endif -EXT_RETURN tls_construct_ctos_early_data(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_ctos_session_ticket(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_ctos_sig_algs(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -#ifndef OPENSSL_NO_OCSP -EXT_RETURN tls_construct_ctos_status_request(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -#endif -#ifndef OPENSSL_NO_NEXTPROTONEG -EXT_RETURN tls_construct_ctos_npn(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#endif -EXT_RETURN tls_construct_ctos_alpn(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_SRTP -EXT_RETURN tls_construct_ctos_use_srtp(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#endif -EXT_RETURN tls_construct_ctos_etm(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_CT -EXT_RETURN tls_construct_ctos_sct(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#endif -EXT_RETURN tls_construct_ctos_ems(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -EXT_RETURN tls_construct_ctos_supported_versions(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_ctos_key_share(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_ctos_psk_kex_modes(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_ctos_cookie(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -EXT_RETURN tls_construct_ctos_padding(SSL *s, WPACKET *pkt, - unsigned int context, X509 *x, - size_t chainidx); -EXT_RETURN tls_construct_ctos_psk(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -EXT_RETURN tls_construct_ctos_post_handshake_auth(SSL *s, WPACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); - -int tls_parse_stoc_renegotiate(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -int tls_parse_stoc_server_name(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -int tls_parse_stoc_early_data(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -int tls_parse_stoc_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_EC -int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#endif -int tls_parse_stoc_session_ticket(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#ifndef OPENSSL_NO_OCSP -int tls_parse_stoc_status_request(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -#endif -#ifndef OPENSSL_NO_CT -int tls_parse_stoc_sct(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -#endif -#ifndef OPENSSL_NO_NEXTPROTONEG -int tls_parse_stoc_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -#endif -int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -#ifndef OPENSSL_NO_SRTP -int tls_parse_stoc_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -#endif -int tls_parse_stoc_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -int tls_parse_stoc_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -int tls_parse_stoc_supported_versions(SSL *s, PACKET *pkt, unsigned int context, - X509 *x, size_t chainidx); -int tls_parse_stoc_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -int tls_parse_stoc_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); -int tls_parse_stoc_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x, - size_t chainidx); - -int tls_handle_alpn(SSL *s); - -int tls13_save_handshake_digest_for_pha(SSL *s); -int tls13_restore_handshake_digest_for_pha(SSL *s); +#define SERVER_KEY_EXCH_MAX_LENGTH 102400 +#define SERVER_HELLO_DONE_MAX_LENGTH 0 +#define KEY_UPDATE_MAX_LENGTH 1 +#define CCS_MAX_LENGTH 1 +/* Max should actually be 36 but we are generous */ +#define FINISHED_MAX_LENGTH 64 + +/* Dummy message type */ +#define SSL3_MT_DUMMY -1 + +extern const unsigned char hrrrandom[]; + +/* Message processing return codes */ +typedef enum { + /* Something bad happened */ + MSG_PROCESS_ERROR, + /* We've finished reading - swap to writing */ + MSG_PROCESS_FINISHED_READING, + /* + * We've completed the main processing of this message but there is some + * post processing to be done. + */ + MSG_PROCESS_CONTINUE_PROCESSING, + /* We've finished this message - read the next message */ + MSG_PROCESS_CONTINUE_READING +} MSG_PROCESS_RETURN; + +typedef int (*confunc_f) (SSL *s, WPACKET *pkt); + +int ssl3_take_mac(SSL *s); +int check_in_list(SSL *s, uint16_t group_id, const uint16_t *groups, + size_t num_groups, int checkallow); +int create_synthetic_message_hash(SSL *s, const unsigned char *hashval, + size_t hashlen, const unsigned char *hrr, + size_t hrrlen); +int parse_ca_names(SSL *s, PACKET *pkt); +const STACK_OF(X509_NAME) *get_ca_names(SSL *s); +int construct_ca_names(SSL *s, const STACK_OF(X509_NAME) *ca_sk, WPACKET *pkt); +size_t construct_key_exchange_tbs(SSL *s, unsigned char **ptbs, + const void *param, size_t paramlen); + +/* + * TLS/DTLS client state machine functions + */ +int ossl_statem_client_read_transition(SSL *s, int mt); +WRITE_TRAN ossl_statem_client_write_transition(SSL *s); +WORK_STATE ossl_statem_client_pre_work(SSL *s, WORK_STATE wst); +WORK_STATE ossl_statem_client_post_work(SSL *s, WORK_STATE wst); +int ossl_statem_client_construct_message(SSL *s, WPACKET *pkt, + confunc_f *confunc, int *mt); +size_t ossl_statem_client_max_message_size(SSL *s); +MSG_PROCESS_RETURN ossl_statem_client_process_message(SSL *s, PACKET *pkt); +WORK_STATE ossl_statem_client_post_process_message(SSL *s, WORK_STATE wst); + +/* + * TLS/DTLS server state machine functions + */ +int ossl_statem_server_read_transition(SSL *s, int mt); +WRITE_TRAN ossl_statem_server_write_transition(SSL *s); +WORK_STATE ossl_statem_server_pre_work(SSL *s, WORK_STATE wst); +WORK_STATE ossl_statem_server_post_work(SSL *s, WORK_STATE wst); +int ossl_statem_server_construct_message(SSL *s, WPACKET *pkt, + confunc_f *confunc,int *mt); +size_t ossl_statem_server_max_message_size(SSL *s); +MSG_PROCESS_RETURN ossl_statem_server_process_message(SSL *s, PACKET *pkt); +WORK_STATE ossl_statem_server_post_process_message(SSL *s, WORK_STATE wst); + +/* Functions for getting new message data */ +__owur int tls_get_message_header(SSL *s, int *mt); +__owur int tls_get_message_body(SSL *s, size_t *len); +__owur int dtls_get_message(SSL *s, int *mt, size_t *len); + +/* Message construction and processing functions */ +__owur int tls_process_initial_server_flight(SSL *s); +__owur MSG_PROCESS_RETURN tls_process_change_cipher_spec(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_finished(SSL *s, PACKET *pkt); +__owur int tls_construct_change_cipher_spec(SSL *s, WPACKET *pkt); +__owur int dtls_construct_change_cipher_spec(SSL *s, WPACKET *pkt); + +__owur int tls_construct_finished(SSL *s, WPACKET *pkt); +__owur int tls_construct_key_update(SSL *s, WPACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_key_update(SSL *s, PACKET *pkt); +__owur WORK_STATE tls_finish_handshake(SSL *s, WORK_STATE wst, int clearbufs, + int stop); +__owur WORK_STATE dtls_wait_for_dry(SSL *s); + +/* some client-only functions */ +__owur int tls_construct_client_hello(SSL *s, WPACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_certificate_request(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt); +__owur int tls_process_cert_status_body(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_cert_status(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_server_done(SSL *s, PACKET *pkt); +__owur int tls_construct_cert_verify(SSL *s, WPACKET *pkt); +__owur WORK_STATE tls_prepare_client_certificate(SSL *s, WORK_STATE wst); +__owur int tls_construct_client_certificate(SSL *s, WPACKET *pkt); +__owur int ssl_do_client_cert_cb(SSL *s, X509 **px509, EVP_PKEY **ppkey); +__owur int tls_construct_client_key_exchange(SSL *s, WPACKET *pkt); +__owur int tls_client_key_exchange_post_work(SSL *s); +__owur int tls_construct_cert_status_body(SSL *s, WPACKET *pkt); +__owur int tls_construct_cert_status(SSL *s, WPACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_server_certificate(SSL *s, PACKET *pkt); +__owur int ssl3_check_cert_and_algorithm(SSL *s); +#ifndef OPENSSL_NO_NEXTPROTONEG +__owur int tls_construct_next_proto(SSL *s, WPACKET *pkt); +#endif +__owur MSG_PROCESS_RETURN tls_process_hello_req(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN dtls_process_hello_verify(SSL *s, PACKET *pkt); +__owur int tls_construct_end_of_early_data(SSL *s, WPACKET *pkt); + +/* some server-only functions */ +__owur MSG_PROCESS_RETURN tls_process_client_hello(SSL *s, PACKET *pkt); +__owur WORK_STATE tls_post_process_client_hello(SSL *s, WORK_STATE wst); +__owur int tls_construct_server_hello(SSL *s, WPACKET *pkt); +__owur int dtls_construct_hello_verify_request(SSL *s, WPACKET *pkt); +__owur int tls_construct_server_certificate(SSL *s, WPACKET *pkt); +__owur int tls_construct_server_key_exchange(SSL *s, WPACKET *pkt); +__owur int tls_construct_certificate_request(SSL *s, WPACKET *pkt); +__owur int tls_construct_server_done(SSL *s, WPACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_client_certificate(SSL *s, PACKET *pkt); +__owur MSG_PROCESS_RETURN tls_process_client_key_exchange(SSL *s, PACKET *pkt); +__owur WORK_STATE tls_post_process_client_key_exchange(SSL *s, WORK_STATE wst); +__owur MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt); +#ifndef OPENSSL_NO_NEXTPROTONEG +__owur MSG_PROCESS_RETURN tls_process_next_proto(SSL *s, PACKET *pkt); +#endif +__owur int tls_construct_new_session_ticket(SSL *s, WPACKET *pkt); +MSG_PROCESS_RETURN tls_process_end_of_early_data(SSL *s, PACKET *pkt); + + +/* Extension processing */ + +typedef enum ext_return_en { + EXT_RETURN_FAIL, + EXT_RETURN_SENT, + EXT_RETURN_NOT_SENT +} EXT_RETURN; + +__owur int tls_validate_all_contexts(SSL *s, unsigned int thisctx, + RAW_EXTENSION *exts); +__owur int extension_is_relevant(SSL *s, unsigned int extctx, + unsigned int thisctx); +__owur int tls_collect_extensions(SSL *s, PACKET *packet, unsigned int context, + RAW_EXTENSION **res, size_t *len, int init); +__owur int tls_parse_extension(SSL *s, TLSEXT_INDEX idx, int context, + RAW_EXTENSION *exts, X509 *x, size_t chainidx); +__owur int tls_parse_all_extensions(SSL *s, int context, RAW_EXTENSION *exts, + X509 *x, size_t chainidx, int fin); +__owur int should_add_extension(SSL *s, unsigned int extctx, + unsigned int thisctx, int max_version); +__owur int tls_construct_extensions(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); + +__owur int tls_psk_do_binder(SSL *s, const EVP_MD *md, + const unsigned char *msgstart, + size_t binderoffset, const unsigned char *binderin, + unsigned char *binderout, + SSL_SESSION *sess, int sign, int external); + +/* Server Extension processing */ +int tls_parse_ctos_renegotiate(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +int tls_parse_ctos_server_name(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +int tls_parse_ctos_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#ifndef OPENSSL_NO_SRP +int tls_parse_ctos_srp(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +#endif +int tls_parse_ctos_early_data(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#ifndef OPENSSL_NO_EC +int tls_parse_ctos_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +int tls_parse_ctos_supported_groups(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidxl); +#endif +int tls_parse_ctos_session_ticket(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +int tls_parse_ctos_sig_algs_cert(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +int tls_parse_ctos_sig_algs(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +#ifndef OPENSSL_NO_OCSP +int tls_parse_ctos_status_request(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#endif +#ifndef OPENSSL_NO_NEXTPROTONEG +int tls_parse_ctos_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +#endif +int tls_parse_ctos_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +#ifndef OPENSSL_NO_SRTP +int tls_parse_ctos_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +#endif +int tls_parse_ctos_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +int tls_parse_ctos_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +int tls_parse_ctos_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +int tls_parse_ctos_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +int tls_parse_ctos_psk_kex_modes(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +int tls_parse_ctos_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +int tls_parse_ctos_post_handshake_auth(SSL *, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); + +EXT_RETURN tls_construct_stoc_renegotiate(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_stoc_server_name(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_stoc_early_data(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_stoc_maxfragmentlen(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +#ifndef OPENSSL_NO_EC +EXT_RETURN tls_construct_stoc_ec_pt_formats(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +#endif +EXT_RETURN tls_construct_stoc_supported_groups(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_stoc_session_ticket(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +#ifndef OPENSSL_NO_OCSP +EXT_RETURN tls_construct_stoc_status_request(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +#endif +#ifndef OPENSSL_NO_NEXTPROTONEG +EXT_RETURN tls_construct_stoc_next_proto_neg(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +#endif +EXT_RETURN tls_construct_stoc_alpn(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#ifndef OPENSSL_NO_SRTP +EXT_RETURN tls_construct_stoc_use_srtp(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#endif +EXT_RETURN tls_construct_stoc_etm(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +EXT_RETURN tls_construct_stoc_ems(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +EXT_RETURN tls_construct_stoc_supported_versions(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_stoc_key_share(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_stoc_cookie(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +/* + * Not in public headers as this is not an official extension. Only used when + * SSL_OP_CRYPTOPRO_TLSEXT_BUG is set. + */ +#define TLSEXT_TYPE_cryptopro_bug 0xfde8 +EXT_RETURN tls_construct_stoc_cryptopro_bug(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_stoc_psk(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); + +/* Client Extension processing */ +EXT_RETURN tls_construct_ctos_renegotiate(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +EXT_RETURN tls_construct_ctos_server_name(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +EXT_RETURN tls_construct_ctos_maxfragmentlen(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#ifndef OPENSSL_NO_SRP +EXT_RETURN tls_construct_ctos_srp(SSL *s, WPACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +#endif +#ifndef OPENSSL_NO_EC +EXT_RETURN tls_construct_ctos_ec_pt_formats(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_ctos_supported_groups(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +#endif +EXT_RETURN tls_construct_ctos_early_data(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_ctos_session_ticket(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_ctos_sig_algs(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +#ifndef OPENSSL_NO_OCSP +EXT_RETURN tls_construct_ctos_status_request(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +#endif +#ifndef OPENSSL_NO_NEXTPROTONEG +EXT_RETURN tls_construct_ctos_npn(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#endif +EXT_RETURN tls_construct_ctos_alpn(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#ifndef OPENSSL_NO_SRTP +EXT_RETURN tls_construct_ctos_use_srtp(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#endif +EXT_RETURN tls_construct_ctos_etm(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#ifndef OPENSSL_NO_CT +EXT_RETURN tls_construct_ctos_sct(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#endif +EXT_RETURN tls_construct_ctos_ems(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +EXT_RETURN tls_construct_ctos_supported_versions(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_ctos_key_share(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_ctos_psk_kex_modes(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_ctos_cookie(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +EXT_RETURN tls_construct_ctos_padding(SSL *s, WPACKET *pkt, + unsigned int context, X509 *x, + size_t chainidx); +EXT_RETURN tls_construct_ctos_psk(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +EXT_RETURN tls_construct_ctos_post_handshake_auth(SSL *s, WPACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); + +int tls_parse_stoc_renegotiate(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +int tls_parse_stoc_server_name(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +int tls_parse_stoc_early_data(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +int tls_parse_stoc_maxfragmentlen(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#ifndef OPENSSL_NO_EC +int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#endif +int tls_parse_stoc_session_ticket(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#ifndef OPENSSL_NO_OCSP +int tls_parse_stoc_status_request(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +#endif +#ifndef OPENSSL_NO_CT +int tls_parse_stoc_sct(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +#endif +#ifndef OPENSSL_NO_NEXTPROTONEG +int tls_parse_stoc_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +#endif +int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +#ifndef OPENSSL_NO_SRTP +int tls_parse_stoc_use_srtp(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +#endif +int tls_parse_stoc_etm(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +int tls_parse_stoc_ems(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +int tls_parse_stoc_supported_versions(SSL *s, PACKET *pkt, unsigned int context, + X509 *x, size_t chainidx); +int tls_parse_stoc_key_share(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +int tls_parse_stoc_cookie(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); +int tls_parse_stoc_psk(SSL *s, PACKET *pkt, unsigned int context, X509 *x, + size_t chainidx); + +int tls_handle_alpn(SSL *s); + +int tls13_save_handshake_digest_for_pha(SSL *s); +int tls13_restore_handshake_digest_for_pha(SSL *s); diff --git a/contrib/libs/openssl/ssl/statem/statem_srvr.c b/contrib/libs/openssl/ssl/statem/statem_srvr.c index d448962c43..d701c46b43 100644 --- a/contrib/libs/openssl/ssl/statem/statem_srvr.c +++ b/contrib/libs/openssl/ssl/statem/statem_srvr.c @@ -10,9 +10,9 @@ */ #include <stdio.h> -#include "../ssl_local.h" -#include "statem_local.h" -#include "internal/constant_time.h" +#include "../ssl_local.h" +#include "statem_local.h" +#include "internal/constant_time.h" #include "internal/cryptlib.h" #include <openssl/buffer.h> #include <openssl/rand.h> @@ -23,24 +23,24 @@ #include <openssl/dh.h> #include <openssl/bn.h> #include <openssl/md5.h> -#include <openssl/asn1t.h> +#include <openssl/asn1t.h> #define TICKET_NONCE_SIZE 8 -typedef struct { - ASN1_TYPE *kxBlob; - ASN1_TYPE *opaqueBlob; -} GOST_KX_MESSAGE; - -DECLARE_ASN1_FUNCTIONS(GOST_KX_MESSAGE) - -ASN1_SEQUENCE(GOST_KX_MESSAGE) = { - ASN1_SIMPLE(GOST_KX_MESSAGE, kxBlob, ASN1_ANY), - ASN1_OPT(GOST_KX_MESSAGE, opaqueBlob, ASN1_ANY), -} ASN1_SEQUENCE_END(GOST_KX_MESSAGE) - -IMPLEMENT_ASN1_FUNCTIONS(GOST_KX_MESSAGE) - +typedef struct { + ASN1_TYPE *kxBlob; + ASN1_TYPE *opaqueBlob; +} GOST_KX_MESSAGE; + +DECLARE_ASN1_FUNCTIONS(GOST_KX_MESSAGE) + +ASN1_SEQUENCE(GOST_KX_MESSAGE) = { + ASN1_SIMPLE(GOST_KX_MESSAGE, kxBlob, ASN1_ANY), + ASN1_OPT(GOST_KX_MESSAGE, opaqueBlob, ASN1_ANY), +} ASN1_SEQUENCE_END(GOST_KX_MESSAGE) + +IMPLEMENT_ASN1_FUNCTIONS(GOST_KX_MESSAGE) + static int tls_construct_encrypted_extensions(SSL *s, WPACKET *pkt); /* @@ -743,15 +743,15 @@ WORK_STATE ossl_statem_server_pre_work(SSL *s, WORK_STATE wst) case TLS_ST_SW_CHANGE: if (SSL_IS_TLS13(s)) break; - /* Writes to s->session are only safe for initial handshakes */ - if (s->session->cipher == NULL) { - s->session->cipher = s->s3->tmp.new_cipher; - } else if (s->session->cipher != s->s3->tmp.new_cipher) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, - SSL_F_OSSL_STATEM_SERVER_PRE_WORK, - ERR_R_INTERNAL_ERROR); - return WORK_ERROR; - } + /* Writes to s->session are only safe for initial handshakes */ + if (s->session->cipher == NULL) { + s->session->cipher = s->s3->tmp.new_cipher; + } else if (s->session->cipher != s->s3->tmp.new_cipher) { + SSLfatal(s, SSL_AD_INTERNAL_ERROR, + SSL_F_OSSL_STATEM_SERVER_PRE_WORK, + ERR_R_INTERNAL_ERROR); + return WORK_ERROR; + } if (!s->method->ssl3_enc->setup_key_block(s)) { /* SSLfatal() already called */ return WORK_ERROR; @@ -955,11 +955,11 @@ WORK_STATE ossl_statem_server_post_work(SSL *s, WORK_STATE wst) } #endif if (SSL_IS_TLS13(s)) { - /* TLS 1.3 gets the secret size from the handshake md */ - size_t dummy; + /* TLS 1.3 gets the secret size from the handshake md */ + size_t dummy; if (!s->method->ssl3_enc->generate_master_secret(s, s->master_secret, s->handshake_secret, 0, - &dummy) + &dummy) || !s->method->ssl3_enc->change_cipher_state(s, SSL3_CC_APPLICATION | SSL3_CHANGE_CIPHER_SERVER_WRITE)) /* SSLfatal() already called */ @@ -3354,8 +3354,8 @@ static int tls_process_cke_gost(SSL *s, PACKET *pkt) const unsigned char *start; size_t outlen = 32, inlen; unsigned long alg_a; - GOST_KX_MESSAGE *pKX = NULL; - const unsigned char *ptr; + GOST_KX_MESSAGE *pKX = NULL; + const unsigned char *ptr; int ret = 0; /* Get our certificate private key */ @@ -3397,34 +3397,34 @@ static int tls_process_cke_gost(SSL *s, PACKET *pkt) if (EVP_PKEY_derive_set_peer(pkey_ctx, client_pub_pkey) <= 0) ERR_clear_error(); } - - ptr = PACKET_data(pkt); - /* Some implementations provide extra data in the opaqueBlob - * We have nothing to do with this blob so we just skip it */ - pKX = d2i_GOST_KX_MESSAGE(NULL, &ptr, PACKET_remaining(pkt)); - if (pKX == NULL - || pKX->kxBlob == NULL - || ASN1_TYPE_get(pKX->kxBlob) != V_ASN1_SEQUENCE) { - SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CKE_GOST, - SSL_R_DECRYPTION_FAILED); - goto err; - } - - if (!PACKET_forward(pkt, ptr - PACKET_data(pkt))) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CKE_GOST, + + ptr = PACKET_data(pkt); + /* Some implementations provide extra data in the opaqueBlob + * We have nothing to do with this blob so we just skip it */ + pKX = d2i_GOST_KX_MESSAGE(NULL, &ptr, PACKET_remaining(pkt)); + if (pKX == NULL + || pKX->kxBlob == NULL + || ASN1_TYPE_get(pKX->kxBlob) != V_ASN1_SEQUENCE) { + SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CKE_GOST, + SSL_R_DECRYPTION_FAILED); + goto err; + } + + if (!PACKET_forward(pkt, ptr - PACKET_data(pkt))) { + SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CKE_GOST, SSL_R_DECRYPTION_FAILED); goto err; } - if (PACKET_remaining(pkt) != 0) { - SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CKE_GOST, + if (PACKET_remaining(pkt) != 0) { + SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CKE_GOST, SSL_R_DECRYPTION_FAILED); goto err; } - inlen = pKX->kxBlob->value.sequence->length; - start = pKX->kxBlob->value.sequence->data; - + inlen = pKX->kxBlob->value.sequence->length; + start = pKX->kxBlob->value.sequence->data; + if (EVP_PKEY_decrypt(pkey_ctx, premaster_secret, &outlen, start, inlen) <= 0) { SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CKE_GOST, @@ -3445,7 +3445,7 @@ static int tls_process_cke_gost(SSL *s, PACKET *pkt) ret = 1; err: EVP_PKEY_CTX_free(pkey_ctx); - GOST_KX_MESSAGE_free(pKX); + GOST_KX_MESSAGE_free(pKX); return ret; #else /* Should never happen */ diff --git a/contrib/libs/openssl/ssl/t1_enc.c b/contrib/libs/openssl/ssl/t1_enc.c index 28708cf129..c85c0b0310 100644 --- a/contrib/libs/openssl/ssl/t1_enc.c +++ b/contrib/libs/openssl/ssl/t1_enc.c @@ -9,7 +9,7 @@ */ #include <stdio.h> -#include "ssl_local.h" +#include "ssl_local.h" #include <openssl/comp.h> #include <openssl/evp.h> #include <openssl/kdf.h> @@ -466,7 +466,7 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, unsigned char hash[EVP_MAX_MD_SIZE * 2]; size_t hashlen; /* - * Digest cached records keeping record buffer (if present): this won't + * Digest cached records keeping record buffer (if present): this won't * affect client auth because we're freezing the buffer at the same * point (after client key exchange and before certificate verify) */ diff --git a/contrib/libs/openssl/ssl/t1_lib.c b/contrib/libs/openssl/ssl/t1_lib.c index 31a7f3e45c..b1d3add187 100644 --- a/contrib/libs/openssl/ssl/t1_lib.c +++ b/contrib/libs/openssl/ssl/t1_lib.c @@ -18,11 +18,11 @@ #include <openssl/dh.h> #include <openssl/bn.h> #include "internal/nelem.h" -#include "ssl_local.h" +#include "ssl_local.h" #include <openssl/ct.h> static const SIGALG_LOOKUP *find_sig_alg(SSL *s, X509 *x, EVP_PKEY *pkey); -static int tls12_sigalg_allowed(const SSL *s, int op, const SIGALG_LOOKUP *lu); +static int tls12_sigalg_allowed(const SSL *s, int op, const SIGALG_LOOKUP *lu); SSL3_ENC_METHOD const TLSv1_enc_data = { tls1_enc, @@ -850,11 +850,11 @@ static int rsa_pss_check_min_key_size(const RSA *rsa, const SIGALG_LOOKUP *lu) } /* - * Returns a signature algorithm when the peer did not send a list of supported - * signature algorithms. The signature algorithm is fixed for the certificate - * type. |idx| is a certificate type index (SSL_PKEY_*). When |idx| is -1 the - * certificate type from |s| will be used. - * Returns the signature algorithm to use, or NULL on error. + * Returns a signature algorithm when the peer did not send a list of supported + * signature algorithms. The signature algorithm is fixed for the certificate + * type. |idx| is a certificate type index (SSL_PKEY_*). When |idx| is -1 the + * certificate type from |s| will be used. + * Returns the signature algorithm to use, or NULL on error. */ static const SIGALG_LOOKUP *tls1_get_legacy_sigalg(const SSL *s, int idx) { @@ -897,12 +897,12 @@ static const SIGALG_LOOKUP *tls1_get_legacy_sigalg(const SSL *s, int idx) if (!tls1_lookup_md(lu, NULL)) return NULL; - if (!tls12_sigalg_allowed(s, SSL_SECOP_SIGALG_SUPPORTED, lu)) - return NULL; + if (!tls12_sigalg_allowed(s, SSL_SECOP_SIGALG_SUPPORTED, lu)) + return NULL; return lu; } - if (!tls12_sigalg_allowed(s, SSL_SECOP_SIGALG_SUPPORTED, &legacy_rsa_sigalg)) - return NULL; + if (!tls12_sigalg_allowed(s, SSL_SECOP_SIGALG_SUPPORTED, &legacy_rsa_sigalg)) + return NULL; return &legacy_rsa_sigalg; } /* Set peer sigalg based key type */ @@ -992,31 +992,31 @@ int tls_check_sigalg_curve(const SSL *s, int curve) #endif /* - * Return the number of security bits for the signature algorithm, or 0 on - * error. - */ -static int sigalg_security_bits(const SIGALG_LOOKUP *lu) -{ - const EVP_MD *md = NULL; - int secbits = 0; - - if (!tls1_lookup_md(lu, &md)) - return 0; - if (md != NULL) - { - /* Security bits: half digest bits */ - secbits = EVP_MD_size(md) * 4; - } else { - /* Values from https://tools.ietf.org/html/rfc8032#section-8.5 */ - if (lu->sigalg == TLSEXT_SIGALG_ed25519) - secbits = 128; - else if (lu->sigalg == TLSEXT_SIGALG_ed448) - secbits = 224; - } - return secbits; -} - -/* + * Return the number of security bits for the signature algorithm, or 0 on + * error. + */ +static int sigalg_security_bits(const SIGALG_LOOKUP *lu) +{ + const EVP_MD *md = NULL; + int secbits = 0; + + if (!tls1_lookup_md(lu, &md)) + return 0; + if (md != NULL) + { + /* Security bits: half digest bits */ + secbits = EVP_MD_size(md) * 4; + } else { + /* Values from https://tools.ietf.org/html/rfc8032#section-8.5 */ + if (lu->sigalg == TLSEXT_SIGALG_ed25519) + secbits = 128; + else if (lu->sigalg == TLSEXT_SIGALG_ed448) + secbits = 224; + } + return secbits; +} + +/* * Check signature algorithm is consistent with sent supported signature * algorithms and if so set relevant digest and signature scheme in * s. @@ -1029,7 +1029,7 @@ int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey) size_t sent_sigslen, i, cidx; int pkeyid = EVP_PKEY_id(pkey); const SIGALG_LOOKUP *lu; - int secbits = 0; + int secbits = 0; /* Should never happen */ if (pkeyid == -1) @@ -1131,20 +1131,20 @@ int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey) SSL_R_UNKNOWN_DIGEST); return 0; } - /* - * Make sure security callback allows algorithm. For historical - * reasons we have to pass the sigalg as a two byte char array. - */ - sigalgstr[0] = (sig >> 8) & 0xff; - sigalgstr[1] = sig & 0xff; - secbits = sigalg_security_bits(lu); - if (secbits == 0 || - !ssl_security(s, SSL_SECOP_SIGALG_CHECK, secbits, - md != NULL ? EVP_MD_type(md) : NID_undef, - (void *)sigalgstr)) { - SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS12_CHECK_PEER_SIGALG, - SSL_R_WRONG_SIGNATURE_TYPE); - return 0; + /* + * Make sure security callback allows algorithm. For historical + * reasons we have to pass the sigalg as a two byte char array. + */ + sigalgstr[0] = (sig >> 8) & 0xff; + sigalgstr[1] = sig & 0xff; + secbits = sigalg_security_bits(lu); + if (secbits == 0 || + !ssl_security(s, SSL_SECOP_SIGALG_CHECK, secbits, + md != NULL ? EVP_MD_type(md) : NID_undef, + (void *)sigalgstr)) { + SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS12_CHECK_PEER_SIGALG, + SSL_R_WRONG_SIGNATURE_TYPE); + return 0; } /* Store the sigalg the peer uses */ s->s3->tmp.peer_sigalg = lu; @@ -1210,7 +1210,7 @@ int ssl_set_client_disabled(SSL *s) * * Returns 1 when it's disabled, 0 when enabled. */ -int ssl_cipher_disabled(const SSL *s, const SSL_CIPHER *c, int op, int ecdhe) +int ssl_cipher_disabled(const SSL *s, const SSL_CIPHER *c, int op, int ecdhe) { if (c->algorithm_mkey & s->s3->tmp.mask_k || c->algorithm_auth & s->s3->tmp.mask_a) @@ -1590,7 +1590,7 @@ SSL_TICKET_STATUS tls_decrypt_ticket(SSL *s, const unsigned char *etick, } /* Check to see if a signature algorithm is allowed */ -static int tls12_sigalg_allowed(const SSL *s, int op, const SIGALG_LOOKUP *lu) +static int tls12_sigalg_allowed(const SSL *s, int op, const SIGALG_LOOKUP *lu) { unsigned char sigalgstr[2]; int secbits; @@ -1652,7 +1652,7 @@ static int tls12_sigalg_allowed(const SSL *s, int op, const SIGALG_LOOKUP *lu) } /* Finally see if security callback allows it */ - secbits = sigalg_security_bits(lu); + secbits = sigalg_security_bits(lu); sigalgstr[0] = (lu->sigalg >> 8) & 0xff; sigalgstr[1] = lu->sigalg & 0xff; return ssl_security(s, op, secbits, lu->hash, (void *)sigalgstr); @@ -2130,7 +2130,7 @@ static int tls1_check_sig_alg(SSL *s, X509 *x, int default_nid) sigalg = use_pc_sigalgs ? tls1_lookup_sigalg(s->s3->tmp.peer_cert_sigalgs[i]) : s->shared_sigalgs[i]; - if (sigalg != NULL && sig_nid == sigalg->sigandhash) + if (sigalg != NULL && sig_nid == sigalg->sigandhash) return 1; } return 0; @@ -2814,26 +2814,26 @@ int tls_choose_sigalg(SSL *s, int fatalerrs) #endif break; } -#ifndef OPENSSL_NO_GOST - /* - * Some Windows-based implementations do not send GOST algorithms indication - * in supported_algorithms extension, so when we have GOST-based ciphersuite, - * we have to assume GOST support. - */ - if (i == s->shared_sigalgslen && s->s3->tmp.new_cipher->algorithm_auth & (SSL_aGOST01 | SSL_aGOST12)) { - if ((lu = tls1_get_legacy_sigalg(s, -1)) == NULL) { - if (!fatalerrs) - return 1; - SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, - SSL_F_TLS_CHOOSE_SIGALG, - SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM); - return 0; - } else { - i = 0; - sig_idx = lu->sig_idx; - } - } -#endif +#ifndef OPENSSL_NO_GOST + /* + * Some Windows-based implementations do not send GOST algorithms indication + * in supported_algorithms extension, so when we have GOST-based ciphersuite, + * we have to assume GOST support. + */ + if (i == s->shared_sigalgslen && s->s3->tmp.new_cipher->algorithm_auth & (SSL_aGOST01 | SSL_aGOST12)) { + if ((lu = tls1_get_legacy_sigalg(s, -1)) == NULL) { + if (!fatalerrs) + return 1; + SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, + SSL_F_TLS_CHOOSE_SIGALG, + SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM); + return 0; + } else { + i = 0; + sig_idx = lu->sig_idx; + } + } +#endif if (i == s->shared_sigalgslen) { if (!fatalerrs) return 1; diff --git a/contrib/libs/openssl/ssl/t1_trce.c b/contrib/libs/openssl/ssl/t1_trce.c index 2c90792719..e2c397b756 100644 --- a/contrib/libs/openssl/ssl/t1_trce.c +++ b/contrib/libs/openssl/ssl/t1_trce.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ -#include "ssl_local.h" +#include "ssl_local.h" #ifndef OPENSSL_NO_SSL_TRACE @@ -1251,9 +1251,9 @@ static int ssl_print_certificates(BIO *bio, const SSL *ssl, int server, while (clen > 0) { if (!ssl_print_certificate(bio, indent + 2, &msg, &clen)) return 0; - if (SSL_IS_TLS13(ssl) - && !ssl_print_extensions(bio, indent + 2, server, - SSL3_MT_CERTIFICATE, &msg, &clen)) + if (SSL_IS_TLS13(ssl) + && !ssl_print_extensions(bio, indent + 2, server, + SSL3_MT_CERTIFICATE, &msg, &clen)) return 0; } diff --git a/contrib/libs/openssl/ssl/tls13_enc.c b/contrib/libs/openssl/ssl/tls13_enc.c index b6e5dc64a3..b8fb07f210 100644 --- a/contrib/libs/openssl/ssl/tls13_enc.c +++ b/contrib/libs/openssl/ssl/tls13_enc.c @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,7 +8,7 @@ */ #include <stdlib.h> -#include "ssl_local.h" +#include "ssl_local.h" #include "internal/cryptlib.h" #include <openssl/evp.h> #include <openssl/kdf.h> @@ -44,7 +44,7 @@ int tls13_hkdf_expand(SSL *s, const EVP_MD *md, const unsigned char *secret, * prefix and label + bytes for the label itself + 1 byte length of hash * + bytes for the hash itself */ - unsigned char hkdflabel[sizeof(uint16_t) + sizeof(uint8_t) + unsigned char hkdflabel[sizeof(uint16_t) + sizeof(uint8_t) + (sizeof(label_prefix) - 1) + TLS13_MAX_LABEL_LEN + 1 + EVP_MAX_MD_SIZE]; WPACKET pkt; diff --git a/contrib/libs/openssl/ssl/tls_srp.c b/contrib/libs/openssl/ssl/tls_srp.c index 055a8d8aba..ede7427ff8 100644 --- a/contrib/libs/openssl/ssl/tls_srp.c +++ b/contrib/libs/openssl/ssl/tls_srp.c @@ -14,7 +14,7 @@ #include <openssl/crypto.h> #include <openssl/rand.h> #include <openssl/err.h> -#include "ssl_local.h" +#include "ssl_local.h" #ifndef OPENSSL_NO_SRP # include <openssl/srp.h> diff --git a/contrib/libs/openssl/ya.make b/contrib/libs/openssl/ya.make index e327e8530d..060d069785 100644 --- a/contrib/libs/openssl/ya.make +++ b/contrib/libs/openssl/ya.make @@ -24,7 +24,7 @@ PEERDIR( ) ADDINCL( - GLOBAL contrib/libs/openssl/include + GLOBAL contrib/libs/openssl/include contrib/libs/openssl ) @@ -70,12 +70,12 @@ IF (OS_WINDOWS) ENDIF() ENDIF() -NO_COMPILER_WARNINGS() - -NO_RUNTIME() - +NO_COMPILER_WARNINGS() + +NO_RUNTIME() + CFLAGS( - -DAESNI_ASM + -DAESNI_ASM -DOPENSSL_BN_ASM_MONT -DOPENSSL_CPUID_OBJ -DSHA1_ASM |