Commit Graph

21096 Commits

Author SHA1 Message Date
Daniel Pouzzner
347a17f7cf wolfcrypt/src/aes_asm.asm: fix missed _AESNI suffixing. 2023-11-17 10:15:03 -06:00
Daniel Pouzzner
a10260ca5f refactor AESNI implementations and *VECTOR_REGISTERS* macros to allow dynamic as-needed fallback to pure C, via WC_AES_C_DYNAMIC_FALLBACK.
wolfssl/wolfcrypt/aes.h: add key_C_fallback[] to struct Aes, and remove comment that "AESNI needs key first, rounds 2nd, not sure why yet" now that AES_128_Key_Expansion_AESNI no longer writes rounds after the expanded key.

wolfcrypt/src/aes.c:
* add _AESNI or _aesni suffixes/infixes to AESNI implementations that were missing them: AES_CBC_encrypt(), AES_CBC_decrypt_by*(), AES_ECB_encrypt(), AES_*_Key_Expansion(), AES_set_encrypt_key(), AES_set_decrypt_key(), AES_GCM_encrypt(), AES_GCM_decrypt(), AES_XTS_encrypt(), and AES_XTS_decrypt().
* move key size check from to start of wc_AesSetKeyLocal().
* refactor pure-C AES setkey and cipher implementations to use aes->key_C_fallback when defined(WC_AES_C_DYNAMIC_FALLBACK).
* refactor wc_AesSetKeyLocal() to set up both AESNI and pure-C expanded keys when defined(WC_AES_C_DYNAMIC_FALLBACK).
* refactor all (haveAESNI && aes->use_aesni) conditions to just (aes->use_aesni).
* add macros VECTOR_REGISTERS_PUSH and VECTOR_REGISTERS_POP, which do nothing but push a brace level when !defined(WC_AES_C_DYNAMIC_FALLBACK), but when defined(WC_AES_C_DYNAMIC_FALLBACK), they call SAVE_VECTOR_REGISTERS2() and on failure, temporarily clear aes->use_aesni and restore at _POP().
* refactor all invocations of SAVE_VECTOR_REGISTERS() and RESTORE_VECTOR_REGISTERS() to VECTOR_REGISTERS_PUSH and VECTOR_REGISTERS_POP, except in wc_AesSetKeyLocal(), wc_AesXtsEncrypt(), and wc_AesXtsDecrypt(), which are refactored to use SAVE_VECTOR_REGISTERS2(), with graceful failure concealment if defined(WC_AES_C_DYNAMIC_FALLBACK).
* orthogonalize cleanup code in wc_AesCbcEncrypt(),  wc_AesCcmEncrypt() and wc_AesCcmDecrypt().
* streamline fallthrough software definitions of wc_AesEncryptDirect() and wc_AesDecryptDirect(), and remove special-casing for defined(WOLFSSL_LINUXKM)&&defined(WOLFSSL_AESNI).

wolfcrypt/src/aes_asm.{S,asm}:
* remove errant "movl $10, 240(%rsi)" from AES_128_Key_Expansion_AESNI.
* add _AESNI suffixes/infixes to implementations that needed them.

wolfcrypt/src/{aes_gcm_asm.{S,asm},aes_xts_asm.S}: regenerate from revisions in scripts#357 -- adds _aesni suffixes to implementations that were missing them.

wolfssl/wolfcrypt/types.h: remove DEBUG_VECTOR_REGISTER_ACCESS macros, and add dummy fallthrough definitions for SAVE_VECTOR_REGISTERS2 and WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL.

wolfssl/wolfcrypt/memory.h: adopt DEBUG_VECTOR_REGISTER_ACCESS code from types.h, and add definitions for WC_DEBUG_VECTOR_REGISTERS_RETVAL_INITVAL and WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL.

linuxkm/linuxkm_wc_port.h: add arch-specific macro definitions for SAVE_VECTOR_REGISTERS2().

wolfcrypt/benchmark/benchmark.c: add missing gates around calls to RESTORE_VECTOR_REGISTERS().

configure.ac:
* cover various interdependencies in enable-all/enable-all-crypto, for better behavior in combination with --disable-aesgcm, --disable-ecc, --disable-ocsp, --disable-hmac, --disable-chacha, --disable-ed25519, and --disable-ed448.
* inhibit aesgcm_stream in enable-all/enable-all-crypto when ENABLED_LINUXKM_DEFAULTS, because it is currently incompatible with WC_AES_C_DYNAMIC_FALLBACK.
* add -DWC_AES_C_DYNAMIC_FALLBACK when ENABLED_LINUXKM_DEFAULTS.
* add 3 new interdependency checks: "ECCSI requires ECC.", "SAKKE requires ECC.", "WOLFSSH requires HMAC."

wolfcrypt/src/asn.c: tweak gating to accommodate defined(NO_RSA) && !defined(HAVE_ECC).

wolfcrypt/src/evp.c: tweak gating to accommodate defined(NO_HMAC).

wolfcrypt/src/logging.c: remove DEBUG_VECTOR_REGISTER_ACCESS code (moved to memory.c).

wolfcrypt/src/memory.c: change #include of settings.h to types.h; adopt DEBUG_VECTOR_REGISTER_ACCESS code from logging.c; add implementation of SAVE_VECTOR_REGISTERS2_fuzzer().

wolfcrypt/src/pwdbased.c: add explanatory #error scrypt requires HMAC.

wolfcrypt/test/test.c:
* add DEBUG_VECTOR_REGISTER_ACCESS clauses to aes_xts_128_test(), aesecb_test(), aesctr_test(), aes_test() CBC section, aes256_test() CBC section, and aesgcm_default_test_helper()
* remove duplicate wc_AesEcbDecrypt() in aesecb_test().
* add gating for pbkdf2_test().
* fix cleanup code in dsa_test().
* fix gating in pkcs7authenveloped_run_vectors() to accommodate !defined(HAVE_AESGCM).
* fix gating in cryptocb_test() to accommodate defined(NO_HMAC).

wolfssl/wolfcrypt/cryptocb.h: remove gates around "pk" sub-struct of struct wc_CryptoInfo -- wc_CryptoInfo.pk.type (an int) is used unconditionally when --enable-debug, and is used with DH.

wolfssl/wolfcrypt/error-crypt.h: fix whitespace.
2023-11-17 01:15:28 -06:00
Daniel Pouzzner
e395aad84b Merge pull request #6958 from embhorn/zd16866
Add XGMTIME validation
2023-11-16 21:28:27 -05:00
JacobBarthelmeh
957a0ce300 Merge pull request #6964 from lealem47/zd16470
Parse explicit parameters in StoreEccKey()
2023-11-16 15:59:21 -07:00
JacobBarthelmeh
6945093221 Merge pull request #6935 from SparkiDev/ssl_crypto_extract
ssl.c: Move out crypto compat APIs
2023-11-16 11:58:14 -07:00
David Garske
8e05b5a9ab Merge pull request #6975 from lealem47/gh6969
Add STM32H725 to default_conf.ftl
2023-11-15 21:15:36 -08:00
JacobBarthelmeh
bb73c233fc Merge pull request #6973 from douzzer/20231115-misc-fixits
20231115-misc-fixits
2023-11-15 15:27:25 -07:00
lealem47
3576db8976 Merge pull request #6977 from JacobBarthelmeh/cmake
add wolfcrypt test and unit test to ctest
2023-11-15 14:47:49 -07:00
JacobBarthelmeh
9fa5d8872c Merge pull request #6948 from SparkiDev/ecc_curve_koblitz
ECC double point: SECP112R2 and SEC128R2 are Koblitz curves
2023-11-15 14:23:42 -07:00
Daniel Pouzzner
263973bde9 src/wolfio.c: fix stack allocations for cookie digests on NO_SHA builds;
configure.ac: fix dependencies for enable_dsa vs enable_sha in enable-all, enable-all-crypto, and ENABLED_DSA setup.
2023-11-15 14:43:23 -06:00
JacobBarthelmeh
ada085390b add wolfcrypt test and unit test to ctest 2023-11-15 10:38:49 -07:00
Lealem Amedie
cd1e9e9974 Add STM32H725 to default_conf.ftl 2023-11-15 10:30:01 -07:00
JacobBarthelmeh
7daac20d24 Merge pull request #6952 from julek-wolfssl/dtls13-pqc-tests
Add dtls 1.3 PQC suites tests
2023-11-15 09:34:36 -07:00
Daniel Pouzzner
eaa66dc117 configure.ac: in enable-all, enable QUIC only if !ENABLED_LINUXKM_DEFAULTS, and enable aesgcm_stream only if enable_aesgcm. 2023-11-15 01:47:46 -06:00
Daniel Pouzzner
748b058dde wolfcrypt/src/aes.c: fix for -Wrestrict in wc_AesCbcDecrypt() when WOLFSSL_AESNI. 2023-11-15 00:51:21 -06:00
Sean Parkinson
26a9435f5c ECC point double: when z ordinate is 0 point is infinity
Recognize z == 0 as infinity in result of double.
2023-11-15 16:43:06 +10:00
Daniel Pouzzner
7569cfdff8 src/internal.c,src/wolfio.c: fallback to SHA256 when NO_SHA, in LoadCertByIssuer(), MicriumGenerateCookie(), uIPGenerateCookie(), and GNRC_GenerateCookie();
tests/api.c: when NO_SHA, omit test_wolfSSL_CertManagerCheckOCSPResponse() and test_wolfSSL_CheckOCSPResponse() (both use static artifacts with SHA1 name and key hashes).
2023-11-15 00:09:22 -06:00
Daniel Pouzzner
6a3451ca54 wolfcrypt/test/test.c: add WC_MAYBE_UNUSED attribute to declaration of max_relative_stack, to accommodate compilation settings when subsumed within testsuite. 2023-11-15 00:09:22 -06:00
Daniel Pouzzner
7e99ccc782 wolfcrypt/src/wc_port.c, wolfssl/wolfcrypt/wc_port.h: refactor WOLFSSL_GMTIME gmtime() into gmtime_r(), and always define HAVE_GMTIME_R when defined(WOLFSSL_GMTIME). 2023-11-15 00:09:22 -06:00
Sean Parkinson
2213306386 ECC double point: SECP112R2 and SEC128R2 are Koblitz curves
SECP112r2 and SECP128R2 are Koblitz curves, so don't compile them in
unless HAVE_ECC_KOBLITZ is defined. This requires custom curves which
enables point doubling to support A != -3.
2023-11-15 13:30:45 +10:00
JacobBarthelmeh
8f7adb2c16 Merge pull request #6967 from SparkiDev/aes_gcm_aarch64_hw_crypto
AES GCM ARM64: Replace hardware crypto assembly with generated code
2023-11-14 13:55:43 -07:00
Sean Parkinson
c4677927bc AES GCM ARM64: Replace hardware crypto assembly with generated code
Optimized assembly of AES GCM for ARM64 using hardware crypto
instructions.
Code replaced between "START..." and "END...".
2023-11-14 09:24:05 +10:00
JacobBarthelmeh
1b55e20d5a Merge pull request #6966 from SparkiDev/aes_bitsliced_armasm_fix
AES bitsliced, ARMASM: config needs WOLFSSL_AES_DIRECT defined
2023-11-13 10:09:08 -07:00
Sean Parkinson
7eaff41e61 AES bitsliced, ARMASM: config needs WOLFSSL_AES_DIRECT defined
AES bitsliced needs WOLFSSL_AES_DIRECT defined when compiling for ARMASM
as there are different APIs used.
2023-11-13 07:40:40 +10:00
David Garske
7c24b2d4bd Merge pull request #6965 from ejohnstown/uint128-cmake
uint128 and CMake
2023-11-10 20:57:46 -08:00
JacobBarthelmeh
c903a8c4a6 Merge pull request #6854 from SparkiDev/aes_bit_sliced
AES bitsliced implementation added
2023-11-10 17:10:19 -07:00
Kaleb Himes
a04eb81e95 Merge pull request #6959 from SparkiDev/sp_c_rsa_pub_e_64bits
SP C: support e up to 64-bits
2023-11-10 16:33:12 -07:00
David Garske
12878fccae Merge pull request #6957 from lealem47/expandDistro
Add --enable-quic to --enable-all
2023-11-10 15:32:05 -08:00
John Safranek
d34d77681a uint128 and CMake
1. Add to the check for HAVE___UINT128_T adding it to the list of items
   that get dumped into the options.h file.
2023-11-10 14:59:41 -08:00
Lealem Amedie
04ea4da6fd Parse explicit parameters in StoreEccKey() 2023-11-10 15:11:08 -07:00
JacobBarthelmeh
63c27219a8 Merge pull request #6962 from julek-wolfssl/dtls13-no-hrr-docs
Add info on how to use WOLFSSL_DTLS13_NO_HRR_ON_RESUME
2023-11-10 14:26:46 -07:00
Juliusz Sosinowicz
b8d5ac83eb Add info on how to use WOLFSSL_DTLS13_NO_HRR_ON_RESUME 2023-11-10 10:43:26 +01:00
Sean Parkinson
3ab0fc1ba4 SP C: support e up to 64-bits
SP C code only supported one digit worth of e which is less than 64 or
32.
Change is to support up to 64 bit of e using sp_uint64 to hold value.
2023-11-10 09:58:51 +10:00
Eric Blankenhorn
a4bf774e1c Add XGMTIME validation 2023-11-09 16:06:37 -06:00
Lealem Amedie
e2bbacd548 Add QUIC to --enable-all 2023-11-09 14:44:02 -07:00
JacobBarthelmeh
49a219e0d1 Merge pull request #6930 from Frauschi/zephyr_fix
Fixes for the Zephyr port
2023-11-09 12:56:34 -07:00
JacobBarthelmeh
73d3277b74 Merge pull request #6947 from SparkiDev/sp_arm64_mont_red_4_fix
SP ARM64 asm: fix Montgomery reduction by 4
2023-11-09 08:39:52 -07:00
Juliusz Sosinowicz
a666c39b65 zephyr 3.5 github action 2023-11-09 10:41:54 +01:00
Tobias Frauenschläger
081b34919c Zephyr: improve order of random seed sources
When using Zephyr, we also want to use the proper wc_GenerateSeed
method. However, if one of the defines is set (e.g., NO_STM32_RNG), the
Zephyr option is ignored, although it would work. Hence, we have to
change the order in which these settings for the source of a random seed
are evaluated.

Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
2023-11-09 10:41:54 +01:00
Tobias Frauenschläger
182eaa0b63 Zephyr: add support for RTC time
For ASN date validation, the actual wall clock time is needed from an
RTC. This commit adds support to read the RTC time in case it is
available in the Zephyr system. If the RTC is not available or an error
occurs during the readout, we fallback to the old implementation which
only supports relative time since boot.

Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
2023-11-09 10:41:54 +01:00
Tobias Frauenschläger
4d8bbd7091 Zephyr: fix POSIX time include
The sys/time.h header causes redefinition errors regarding the fd_set
type and the select call inside socket_select.h. We want to include the
regular time.h header anyway, as done in random.c.

Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>

tmp
2023-11-09 10:41:54 +01:00
Tobias Frauenschläger
9d880fe161 Zephyr: Fix deprecation warning for rand32.h
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
2023-11-09 10:41:54 +01:00
JacobBarthelmeh
2b1c61a013 Merge pull request #6949 from bigbrett/zd16925
fix WOLFSSL_CALLBACK memory error
2023-11-08 23:35:32 -07:00
JacobBarthelmeh
3332b036d5 Merge pull request #6950 from SparkiDev/srtp_kdf_fix
SRTP KDF: Don't use i outside loop
2023-11-08 23:13:40 -07:00
JacobBarthelmeh
04c1e94e29 Merge pull request #6954 from SparkiDev/sp_cortexm_iar_branch_long
SP Cortex-M: branch long explicitly for IAR
2023-11-08 23:01:45 -07:00
JacobBarthelmeh
68b6bc87c7 Merge pull request #6916 from philljj/add_EXTENDED_KEY_USAGE_free
Add EXTENDED_KEY_USAGE_free to OpenSSL compat layer.
2023-11-08 22:07:40 -07:00
Sean Parkinson
168747615c SP Cortex-M: branch long explicitly for IAR
GCC doesn't like explicit wide branch instruction but will use
appropriate instruction implicitly.
IAR won't widen branch instruction unless explicitly told.
2023-11-09 08:27:42 +10:00
jordan
be24d68e5d Add EXTENDED_KEY_USAGE_free to OpenSSL compat layer. 2023-11-08 15:26:24 -06:00
Sean Parkinson
54f2d56300 ssl.c: Move out crypto compat APIs
ssl_crypto.c contains OpenSSL compatibility APIS for:
 - MD4, MD5, SHA/SHA-1, SHA2, SHA3
 - HMAC, CMAC
 - DES, DES3, AES, RC4
API implementations reworked.
Tests added for coverage.
TODOs for future enhancements.
2023-11-08 19:43:18 +10:00
Juliusz Sosinowicz
8bc79a0b43 Add dtls 1.3 PQC suites tests 2023-11-08 10:29:35 +01:00