Commit Graph

1893 Commits (3cad38a1ca87fe794b726575d44b3e9d66b449e9)

Author SHA1 Message Date
Daniel Pouzzner 0da78a7ee2 move several MP error codes from wolfssl/wolfcrypt/sp_int.h, wolfssl/wolfcrypt/tfm.h, and wolfssl/wolfcrypt/integer.h, to wolfssl/wolfcrypt/error-crypt.h, harmonizing their names and numbers.
wolfssl/wolfcrypt/error-crypt.h: add WC_FIRST_E.

wolfcrypt/src/error.c: add MP error code strings.

wolfssl/error-ssl.h: add WOLFSSL_FIRST_E and WOLFSSL_LAST_E.

wolfcrypt/test/test.c: update error_test() for new error code layout, refactoring the "missing" check.

src/internal.c: use WC_FIRST_E and WC_LAST_E  in wolfSSL_ERR_reason_error_string().

src/ssl.c: fix wolfSSL_ERR_GET_REASON() to identify in-range error codes using WC_FIRST_E, WC_LAST_E, WOLFSSL_FIRST_E, and WOLFSSL_LAST_E.

sp_int.h: provide for WOLFSSL_DEBUG_TRACE_ERROR_CODES, and refactor MP error codes as enums, for consistency with other error codes.

wolfcrypt/src/ecc.c: fix 2 identicalInnerCondition's.
2024-08-20 14:09:06 -05:00
Daniel Pouzzner 14254e8a6e
Merge pull request #7862 from bigbrett/wc-test-nocryptocb
cryptocb test disable option
2024-08-14 23:18:02 -05:00
Andras Fekete f8c968d8d1 Fix possible memory overrun 2024-08-13 13:43:54 -04:00
Brett Nicholas 8df5d61179 add optional cryptocb test disable macro to wolfCrypt tests 2024-08-12 15:16:33 -06:00
Andras Fekete f419e2351b Remove NULL test with 'ptr = NULL' at the end 2024-08-06 10:55:37 -04:00
Andras Fekete d6a7187538 Programmatically remove NULL test with { XFREE() } 2024-08-06 10:37:43 -04:00
Andras Fekete d7a0f49906 Programmatically remove NULL test before XFREE 2024-08-06 10:20:45 -04:00
Daniel Pouzzner 9aa0742baa
Merge pull request #7798 from dgarske/asn_macros
ASN macro simplification

merged with github CI tests failing due to unrelated upstream changes (same tests all previously succeeded on this PR, with only 25d14f1937 added in the meantime).

supplementary testing with `wolfssl-multi-test.sh ... super-quick-check` after rebase on then-current `master` 15e99c8eff.
2024-08-02 16:36:50 -05:00
Sean Parkinson ebb49b6e68 RISC-V ChaCha20: assembly implementations
ChaCha20:
  scalar and vector implementations
  vector implementations doing 6, 4, 2, 1 block at a time.
  scalar implemetations using roriw and pack
  vector implementations using VROR_VI and roriw.

RISC-V SHA-256: avoid using s0 if it can be helped.
2024-08-01 17:51:59 +10:00
David Garske 548a2c6d8e Fixed issues building with nocrypt. Improved logic on `ASN_BER_TO_DER`. Improved logic on unknown extension callback (new `WC_ASN_UNKNOWN_EXT_CB` gate). 2024-07-31 09:42:46 -07:00
David Garske f9dc5e9f4d Fixes for uses of deprecated sprintf. If C89 remap XSNPRINTF to use sprintf. 2024-07-29 14:03:44 -07:00
David Garske 7f7d94abd5 Fixes for ASN original (old) to support checking int leading 0 and invalid OID. Disable invalid UTF8 test for old ASN (only supported with newer ASN template). 2024-07-24 12:35:37 -07:00
Daniel Pouzzner 367508f498 wolfcrypt/src/asn.c: in EccSpecifiedECDomainDecode(), in calls to DataToHexString(), cast curve->size to word32 to resolve -Wconversion.
wolfcrypt/src/dh.c: in GeneratePrivateDh186(), add explicit suppression of uninitvar for "cBuf" arg that isn't fully initialized.

wolfcrypt/test/test.c: in mp_test_param(), explicitly initialize "buffer" to avoid uninitvar warning.

configure.ac: in FIPS builds, don't include enable_cryptocb in --enable-all or --enable-all-crypto.  (they can still be enabled explicitly in FIPS builds with --enable-cryptocb, but the combination is not currently supported.)
2024-07-22 18:21:36 -05:00
Daniel Pouzzner 765231060e wolfcrypt/test/test.c: add missing PRIVATE_KEY_UNLOCK() for hpke_test(). 2024-07-19 18:31:01 -05:00
Sean Parkinson e6fcd488a6
Merge pull request #7685 from dgarske/renesas_rx_tsip
Renesas RX TSIP ECDSA support
2024-07-19 10:53:00 +10:00
Daniel Pouzzner c36ab59f24 fixes for defects identified by nightly testing:
* ecc.c: in wc_ecc_free(), fix gating around handling for key->sign_k to resolve memory leak, and in wc_ecc_gen_deterministic_k(), fix -Wconversion.

* test.c: add missing mp_free()s to ecdsa_test_deterministic_k_rs() and ecc521_test_deterministic_k().

* wc_HashType: change several occurrences of int to enum wc_HashType, including ecc_key.hashType and API wc_ecc_set_deterministic_ex(), to resolve C++ warnings.

* fixes for various C++ warnings/errors in crypto and TLS layers and test and benchmark code -- implicit casts, negative initializers for unsigned type, jumped initializers, and missing enums in switch()es.
2024-07-17 18:07:08 -05:00
Sean Parkinson 0f3ebedba0
Merge pull request #7700 from aidangarske/ECDSA_deterministic_k
ecc.c and test.c changes to add support in ecc_sign_determinsitic.c
2024-07-17 09:12:32 +10:00
David Garske d5016d451f
Merge pull request #7714 from JacobBarthelmeh/coverity
Coverity issues reported
2024-07-05 13:49:20 -07:00
kaleb-himes f42fb587a5 Address coverity issue 394706 2024-07-05 13:54:23 -06:00
JacobBarthelmeh c880fcf822 add check on padSz return, coverity issue 394711 2024-07-05 12:07:42 -06:00
JacobBarthelmeh 50a7243486 fix for coverity issue 394670 possible overflow 2024-07-05 11:53:19 -06:00
Sean Parkinson 1fd9f2af91 KYBER/ML-KEM: make ML-KEM available
Added ML-KEM instead of Kyber implementation with WOLFSSL_ML_KEM.
Tests added from NIST for ML-KEM operations.
2024-07-04 23:51:23 +10:00
David Garske 9ec29e9ad9 Reduced duplicate code in deterministic test. 2024-07-01 10:35:03 -07:00
David Garske ac7f44b0dc Fix the async tests for deterministic sign. The _ex versions cannot be called again. Fix possible leak with async and deterministic sign. 2024-07-01 10:13:28 -07:00
aidan garske c07e7f1e58 Fixed async test for test.c deterministic K. 2024-07-01 09:51:07 -07:00
aidan garske b5b0e17587 ecc.c and test.c changes to add support in ecc_sign_determinsitic.c for SHA256, SHA384, and SHA512 for SECP256R1, SECP384R1, SECP521R1. 2024-07-01 08:43:32 -07:00
David Garske 2fd7a2e4ae Fix for test.c `memcb_test` and missing XREALLOC. 2024-06-28 15:25:01 -07:00
David Garske 2a86ca43f8 Fixes for building the compatibility layer with `WOLFSSL_NO_REALLOC`. Tested using `./configure --enable-opensslextra CFLAGS="-DWOLFSSL_NO_REALLOC"`.
Improve benchmark FreeRTOS default tick rate logic. For example Xilinx FreeRTOS uses 10ms tick (not default 1ms), so include `configTICK_RATE_HZ` in calculation if available.
Fix test.c warning around too many parens with no realloc.
2024-06-27 16:02:28 -07:00
David Garske e81e18859b Support for Renesas RX TSIP with ECDSA and Crypto Callbacks.
Fix building ECC with NO_ASN (`./configure --enable-cryptonly --disable-rsa --disable-asn --disable-examples`).
2024-06-25 17:43:16 -07:00
Sean Parkinson a094831e1a Dilithium: C code optimized
Changes to get best out of 32-bit ARM chips.
Fixes come compile errors when cutting out functions.
WOLFSSL_DILITHIUM_SIGN_CHECK_Y and WOLFSSL_DILITHIUM_SIGN_CHECK_W0 added
to speed up signing. No longer specification conformat when either used.
2024-06-24 16:37:43 +10:00
Daniel Pouzzner b4e15d028c WOLF_CRYPTO_CB && WOLFSSL_SHA3: add FIPS gating to wc_CryptoCb_Sha3Hash() and test routine myCryptoDevCb(). 2024-06-22 11:20:53 -05:00
aidan garske 1ef9a8fe7c Added crypto callback for SHA3 and extended the test.c tests for it in cryptocb_test. 2024-06-20 14:15:28 -07:00
Daniel Pouzzner 38c7327660
Merge pull request #7622 from SparkiDev/ml-dsa
Dilithium/ML-DSA: Implementation of ML-DSA-44/65/87
2024-06-19 13:32:35 -04:00
Sean Parkinson 3e3a00dafd Dilithium/ML-DSA: Implementation of ML-DSA-44/65/87
Impemented FIPS 204 (Draft) Module-Lattice-Based Signature Standard.
Implementation include making a key, signing and verification.
Make key API added.
Updated liboqs calls to use ML-DSA implementation instead of Dilithium.
2024-06-19 21:27:01 +10:00
JacobBarthelmeh 24291b4147
Merge pull request #7600 from SparkiDev/wc_ecc_mulmod_zero_z1
ECC: when multiplying by zero, set z to 1
2024-06-18 16:36:35 -06:00
Sean Parkinson fbd69f9b48 ECC: when multiplying by zero, set z to 1
Make sure zero times a point is infinity but z is 1 as it is assumed
later on.
2024-06-18 11:30:57 +10:00
Sean Parkinson 8d77df15ef SM2: change to official test vector
Change create digest to official test vector.
2024-06-18 10:40:47 +10:00
David Garske b69482ffac
Merge pull request #7569 from SparkiDev/riscv_aes_asm
AES RISC-V 64-bit ASM: ECB/CBC/CTR/GCM/CCM
2024-06-06 08:11:31 -07:00
Sean Parkinson acd604db3d AES RISC-V 64-bit ASM: ECB/CBC/CTR/GCM/CCM
Add implementations of AES for ECB/CBC/CTR/GCM/CCM for RISC-V using
assembly.
Assembly with standard/scalar cryptography/vector cryptographt
instructions.
2024-06-06 13:16:00 +10:00
Chris Conlon 70d317ec79
Merge pull request #7571 from rlm2002/internship
Test case for wc_HpkeGenerateKeyPair() NULL argument
2024-06-05 10:57:19 -06:00
Sean Parkinson 4b77d4caa1
Merge pull request #7589 from rizlik/sp800_56c
wolfcrypt: support NIST 800-56C Option 1 KDF
2024-05-31 11:55:12 +10:00
JacobBarthelmeh ebdc8b9a32 rename of macros, add descriptions, minor fixes 2024-05-30 14:48:52 -06:00
Marco Oliverio 174456437e wolcrypt: NIST_SP_800_56C address reviewer's comments 2024-05-30 11:39:49 +02:00
JacobBarthelmeh 288fe430f5 tying in lean staticmemory build with --enable-staticmemory=small 2024-05-29 15:50:11 -06:00
Marco Oliverio 8d41e68d1f fix: minor typos 2024-05-28 22:59:01 +02:00
Marco Oliverio 5306a85465 wolfcrypt: support NIST 800-56C Option 1 KDF 2024-05-28 14:40:52 +02:00
David Garske 3b5517692e
Merge pull request #7582 from aidangarske/hpke_test_fix
Revert change from PR #7570
2024-05-24 07:35:39 -07:00
David Garske 51f19f42c6
Merge pull request #7574 from douzzer/20240522-quantum-safe-linuxkm
20240522-quantum-safe-linuxkm
2024-05-24 07:35:01 -07:00
Ruby Martin 078fb66b29 Negative tests for all NULL arguments 2024-05-23 14:16:17 -06:00
Ruby Martin b8838dca44 Tests all NULL argument cases 2024-05-23 13:36:48 -06:00
aidan garske 3670bfb9ae Revert change from PR #7570 2024-05-23 12:34:59 -07:00
Chris Conlon e05dbd531e
Merge pull request #7570 from jackctj117/test
Code Coverage for hpke.c test case HAVE_CURVE448 using test.c
2024-05-23 11:49:37 -06:00
Daniel Pouzzner 5c497c62e7 initial linuxkm compatibility (no asm yet) for wc_kyber, wc_xmss, and wc_lms, and smallstack refactors for kyber512_kat(), kyber768_kat(), kyber1024_kat(), and kyber_test(). 2024-05-23 00:15:32 -05:00
Ruby Martin f2492da6a4 include negative test comment and BAD_FUNC_ARG 2024-05-22 16:20:20 -06:00
Jack Tjaden 14068fb7f3 Removed returns & check next case for ret 2024-05-22 15:58:09 -06:00
Ruby Martin 159981f442 include negative test comment and BAD_FUNC_ARG 2024-05-22 15:23:38 -06:00
aidan garske fe5cc9589b Add HPKE Curve448 test case, however HPKE does not support 448 yet, so expect bad function argument return code. 2024-05-22 12:49:56 -07:00
Jack Tjaden 1a000ef94c single_test and BAD_FUNC_ARG fix 2024-05-22 13:13:56 -06:00
Jack Tjaden 52b6c361f9 test.c code coverage test hpke.c 2024-05-22 11:51:44 -06:00
Ruby Martin fe9882769e Test case for wc_HpkeGenerateKeyPair() NULL argument 2024-05-22 09:13:31 -06:00
Daniel Pouzzner d0e73783f1 wolfcrypt/src/aes.c and wolfssl/wolfcrypt/aes.h: add FIPS_AES_XTS_MAX_BYTES_PER_TWEAK and struct XtsAesStreamData, with improved error checking on streaming AES-XTS APIs;
wolfcrypt/test/test.c and linuxkm/lkcapi_glue.c: update AES-XTS streaming calls to use struct XtsAesStreamData;

linuxkm/lkcapi_glue.c: add handling for CONFIG_CRYPTO_MANAGER*.
2024-05-18 22:00:00 -05:00
Daniel Pouzzner 6d0f611ab5 AES-XTS: add wc_AesXtsEncryptFinal() and wc_AesXtsDecryptFinal() for API consistency, and add error-checking (block alignment check) to wc_AesXtsEncryptUpdate() and wc_AesXtsDecryptUpdate(). 2024-05-16 15:20:37 -05:00
kaleb-himes fa08e2cb62 Fix a long line in pbkdf2 test 2024-05-15 14:02:44 -04:00
kaleb-himes 49e9c06679 (Has dependency PR) API Service update HmacSizeByType 2024-05-15 14:02:43 -04:00
David Garske ac7aea9674
Merge pull request #7478 from JacobBarthelmeh/staticmemory
add global heap hint setter function
2024-05-15 10:43:15 -07:00
David Garske 9c4c9234b1
Merge pull request #7532 from SparkiDev/wc_ecc_mulmod_zero
ECC: handle zero in wc_ecc_mulmod()
2024-05-15 09:02:02 -07:00
Daniel Pouzzner 1469aab109 linuxkm/lkcapi_glue.c: add native test coverage for WOLFSSL_AESXTS_STREAM.
wolfcrypt/test/test.c:
* add WOLFSSL_AESXTS_STREAM testing to the LARGE_XTS_SZ exercise in aes_xts_128_test().
* add the LARGE_XTS_SZ exercise to aes_xts_256_test().
* add aes_xts_192_test().
* fix -Werror=frame-larger-than=2048 in ed25519_test().
2024-05-15 00:45:51 -05:00
Daniel Pouzzner 2fe366cc74 wolfcrypt/test/test.c: add test coverage for WOLFSSL_AESXTS_STREAM.
linuxkm/lkcapi_glue.c: typographic cleanups, and failsafe error return constructs when skcipher_walk_virt() returns zero walk.nbytes.

wolfcrypt/src/aes.c: additional comments and inline documentation.

.github/workflows/openvpn.yml: disable test on master branch.
2024-05-14 19:11:39 -05:00
Sean Parkinson b63f308812 fixup 2024-05-15 09:07:04 +10:00
Sean Parkinson 36754683d6 ECC: handle zero in wc_ecc_mulmod()
Public API needs to handle multiplying by zero as the underlying code
doesn't and needn't.
2024-05-15 09:05:31 +10:00
David Garske 28bd4ebeea
Merge pull request #7520 from bandi13/fixConversion
Fix conversion
2024-05-14 11:26:37 -07:00
David Garske 7526f527d1
Merge pull request #7526 from lealem47/addCast
Fix for type conversion error
2024-05-14 10:30:08 -07:00
Andras Fekete a59a3d109f Explicit cast 2024-05-14 11:03:20 -04:00
Sean Parkinson e1274013d8 AES: NO_AES_DECRYPT defined
Allow code to compile with NO_AES_DECRYPT with AES modes enabled and
disabled.
2024-05-14 16:27:36 +10:00
Daniel Pouzzner 009ea6640b
Merge pull request #7493 from SparkiDev/sm3_benchmark_fix
Benchmark, SM3: fix full hash testing
2024-05-13 19:22:22 -04:00
Lealem Amedie f4275d53c4 Fix for type conversion error 2024-05-13 16:32:12 -06:00
David Garske a9164293c2
Merge pull request #7513 from julek-wolfssl/gh/7510
ed25519: check that the signature is smaller than the order
2024-05-13 09:16:17 -07:00
Daniel Pouzzner 1faa70c128 wolfcrypt/test/test.c:
* fix unconditional memory leak in pkcs12_test().
* refactor pkcs12_test() to fix error-conditional memory leaks.
* fix various old-style return codes in sm4_ccm_test(), pkcs12_test(), prf_test(), tls12_kdf_test(), xmss_test(), xmss_test_verify_only(), lms_test(), and lms_test_verify_only().
2024-05-12 14:13:06 -05:00
JacobBarthelmeh d68f3cf63c add macro guard around test case 2024-05-10 11:08:45 -06:00
JacobBarthelmeh 98a19f9fdd add debug log and adjust set global heap hint function 2024-05-10 11:08:43 -06:00
JacobBarthelmeh de3d1a488d add global heap hint setter function 2024-05-10 11:08:01 -06:00
Sean Parkinson add7428d1c TLS, SM2: fixes to get SM handshakes working
Pass around the algorithm id from the private key so that the WOLFSSL or
WOLFSSL_CTX get the correct key format set.
Use different verification context when self-signed certificate with SM2
and SM3 signature but public key OID is ECC.
2024-05-10 10:15:47 +10:00
Daniel Pouzzner f7e1e370a0
Merge pull request #7438 from julek-wolfssl/zephr-no-malloc
zephyr no malloc
2024-05-09 02:57:20 -04:00
Daniel Pouzzner 5a784c818d
Merge pull request #7319 from SparkiDev/chacha_poly1305_asm_msvc
ChaCha20, Poly1305 ASM for MSVC
2024-05-08 19:03:56 -04:00
Juliusz Sosinowicz 2508c9e1f4 ed25519: check that the signature is smaller than the order 2024-05-08 17:54:37 +02:00
Juliusz Sosinowicz 14ce8ce198 Jenkins fixes 2024-05-07 11:46:36 +02:00
Juliusz Sosinowicz 8d8f4d4e1e fixup! zephyr no malloc 2024-05-07 10:38:01 +02:00
Juliusz Sosinowicz 7ed5e0b3ba zephyr no malloc
- cert gen
- csr gen
- pkcs12
- Compiles for Zephyr 3.4.0 and 2.7.4
- Add support for CONFIG_POSIX_API
2024-05-07 10:38:01 +02:00
John Safranek 195bbcc315 Generic Memory Pools Fix
1. Add some expository comments describing the purpose of:
   * WOLFMEM_MAX_BUCKETS
   * WOLFMEM_DEF_BUCKETS
   * WOLFMEM_BUCKETS
   * WOLFMEM_DIST
2. Switch the API test for LoadStaticMemory() to named constants.
3. Delete redundant test case. Add a new test case.
4. In the wolfCrypt test for the memory constants, check the sizes of
   the WOLFMEM_BUCKETS and WOLFMEM_DIST lists against
   WOLFMEM_DEF_BUCKETS which should be their length. Check that
   WOLFMEM_DEF_BUCKETS is not greater than WOLFMEM_MAX_BUCKETS.
5. Default for WOLFMEM_MAX_BUCKETS should be WOLFMEM_DEF_BUCKETS, set it
   to what is specified. Add a warning if MAX is less than DEF.
6. Separate the definition of the constant LARGEST_MEM_BUCKET so it is
   dependent on config and not if WOLFMEM_BUCKETS isn't set.
2024-05-03 16:15:38 -07:00
Daniel Pouzzner fa30d3ae0b wolfcrypt/benchmark/benchmark.c: fixes for clang-analyzer-deadcode.DeadStores in bench_xmss_sign_verify();
wolfcrypt/test/test.c: fix for invalidPrintfArgType_sint in xmss_test_verify_only().
2024-04-30 22:48:48 -05:00
Sean Parkinson aab97fe9e2 ChaCha20, Poly1305 ASM for MSVC
Make ChaCha20 and Poly1305 asm available for MSVC.
2024-05-01 13:44:25 +10:00
Daniel Pouzzner 7260cc124c smallstack refactors of wolfcrypt/src/evp.c:wolfssl_evp_digest_pk_final() and wolfcrypt/test/test.c:openssl_test(). 2024-04-27 12:35:23 -05:00
Daniel Pouzzner 4cc27fa58b rename WC_AES_C_DYNAMIC_FALLBACK to WC_C_DYNAMIC_FALLBACK. 2024-04-27 12:35:23 -05:00
Daniel Pouzzner 460991a6f0 wolfcrypt/test/test.c: fix invalidPrintfArgType_sint in lms_test_verify_only(). 2024-04-25 22:09:28 -05:00
Sean Parkinson 6e49aa7543
Merge pull request #7421 from philljj/update_lms_parms
Update enum wc_LmsParm for wolfboot support.
2024-04-24 16:39:10 +10:00
Colton Willey 7f19be05bd Modify HMAC oversized key tests to consistently use test vectors from RFC. 2024-04-23 15:23:51 -07:00
jordan 094ddb62c2 Add wc_LmsKey_ExportPubRaw to wolfcrypt test. 2024-04-23 10:48:53 -05:00
David Garske 3a89c452b3
Merge pull request #7454 from lealem47/stm32AesCtr
Fix for AES CTR on STM32
2024-04-22 10:04:06 -07:00
kaleb-himes 4b1edc78bb Add test case 2024-04-19 13:16:19 -06:00
Lealem Amedie acc6ff84d8 Move rng seed cb call to wolfcrypt_test 2024-04-19 12:36:20 -06:00
JacobBarthelmeh 69be7a7c54
Merge pull request #7431 from lealem47/aes_cfb
Fix for AES-CFB1 encrypt/decrypt on size (8*x-1) bits
2024-04-19 10:55:27 -06:00
JacobBarthelmeh ef153101b7
Merge pull request #7433 from SparkiDev/eddsa_fips_checks
EdDSA FIPS checks on public key
2024-04-18 14:34:31 -06:00
Lealem Amedie 295033441c Fix for AES-CFB1 encrypt/decrypt on size (8*x-1) bits 2024-04-18 11:31:28 -06:00
Daniel Pouzzner 436efb0078 wolfcrypt/test/test.c: in aes_xts_128_test(), change DEBUG_VECTOR_REGISTER_ACCESS gates to DEBUG_VECTOR_REGISTER_ACCESS_AESXTS (currently unused), after refactor of AES-XTS C fallback in 9f55dba2f2. (per-call fallback is no longer supported for AES-XTS.) 2024-04-18 00:59:03 -05:00
Sean Parkinson c590fe514f EdDSA FIPS checks on public key
Check that the Ed25519 and Ed448 public key is valid even without
private key.
Perform pairwise consistency test, only in FIPS, when making a key i
Ed25519 and Ed448.
2024-04-17 17:50:33 +10:00
Daniel Pouzzner 281c2a431e wolfcrypt/test/test.c: fix return code in pbkdf2_test(), add DEBUG_WOLFSSL gates on keysize report in ecc_test_curve(), and add missing PRIVATE_KEY_UNLOCK()s in cryptocb_test() for fips-dev coverage. 2024-04-15 14:11:21 -05:00
Daniel Pouzzner 6e0a90190f fixes for v5 and v6+ FIPS builds, including linuxkm v6+ builds. 2024-04-15 14:11:21 -05:00
kaleb-himes b8d31b042f Windows support 2024-04-09 13:55:05 -06:00
kaleb-himes a3413ad009 Address Jenkins caught item 2024-04-09 09:48:33 -06:00
kaleb-himes ef2a636610 Expose additional features of opensslall in a compliant way 2024-04-09 09:48:33 -06:00
kaleb-himes 8092104396 Address a flush-left in test.c and gt 80 column limit in settings.h 2024-04-09 09:48:33 -06:00
kaleb-himes 84f5b4e5bf Touchup a few more edge cases caught by Jenkins 2024-04-09 09:48:33 -06:00
kaleb-himes 829d028d98 Add configure for wolfEngine with new module 2024-04-09 09:48:33 -06:00
kaleb_himes 81f5ac7f6c SRTP-KDF FS Preview 2024-04-09 09:48:33 -06:00
jordan 4a069ee5c1 Small cleanup for review. 2024-04-08 21:41:33 -05:00
jordan d0802335a8 Add wc_XmssKey_ExportPubRaw to wolfcrypt test. 2024-04-05 12:09:04 -05:00
Daniel Pouzzner d930825a92
Merge pull request #7362 from jpbland1/rsa-make-key-no-malloc
fix wc_MakeRsaKey and wc_RsaKeyToDer to work with WOLFSSL_NO_MALLOC
2024-03-30 03:19:27 -04:00
Daniel Pouzzner 03d7eac9c4
Merge pull request #7337 from gojimmypi/PR-test-certbuf-256
wolfcrypt tests: improve file system gating for USE_CERT_BUFFERS
2024-03-30 00:43:20 -04:00
John Bland 7c0423eb65 reduce der buffer size 2024-03-28 12:56:26 -04:00
Andras Fekete 4cb176ffff Fix sanitizer complaint 2024-03-28 11:44:12 -04:00
John Bland 6cc32e90b0 trim down buffer size 2024-03-28 03:01:46 -04:00
John Bland 9cd614fcac update rsa test to support no malloc 2024-03-28 02:54:49 -04:00
Daniel Pouzzner 716870cbc2
Merge pull request #7370 from anhu/quickie
sizeof(oriType) ---> sizeof(asnDataOid)
2024-03-28 01:58:01 -04:00
Anthony Hu 28a88d1c7c sizeof(oriType) ---> sizeof(asnDataOid) 2024-03-27 17:05:25 -04:00
gojimmypi bf9775831f Improve wolfcrypt test NO_FILESYSTEM checks 2024-03-22 13:00:25 -07:00
Sean Parkinson d4b1995a2c ASN.1 testing: add tests of bad DER encodings
Certificates with bad DER encoded ASN.1 added to testing.
Fix comment in asn.c.
2024-03-22 08:51:17 +10:00
Sean Parkinson 638d0b1a9f Regression test fixes
pkcs7.c: pkcs7->stream must be restored or there will be a leak.
test.c: when compiled for compression, compiler warning about const
2024-03-18 09:57:22 +10:00
Sean Parkinson d1b16f2c7b Regression testing fixes
api.c: z and ret no longer only when !NO_ASN_TIME.
benchmark.c: rsaKey array type has changed and unusual code path needsed
updating.
cmac.c: Zeroization test failed when checkSz was zero as called function
didn't zero out cmac. checkSz is invalid.
test.c: rsaCaCertDerFile used even when NO_ASN_TIME.
test.h: --enable-sp-math only supports DH of 2048 bits and above. Change
default DH parameters to be 2048 bits.
2024-03-15 13:24:40 +10:00
Daniel Pouzzner 3fd6af0cd2
Merge pull request #7283 from SparkiDev/lms
LMS: initial implementation
2024-03-14 01:48:57 -04:00
Sean Parkinson 6c8df33191 LMS: initial implementation
Initial wolfSSL implementation of LMS.
Changed LMS benchmarking to time making a key and reloading.
SHA-256:
  Added wc_Sha256HashBlock to make hashing a block fast.
Fixed assembly code to be able to hash a block from an external
buffer.
  Simplified code were possible.
Moved byte reversal decision logic to one place instead of replicating
length checks.
2024-03-07 11:43:16 +10:00
Daniel Pouzzner 321a72c906 misc fixes:
wolfcrypt/test/test.c: fix gating for verify4 in scrypt_test(), and fix WOLFSSL_SMALL_STACK -Wframe-larger-than=2048 warnings in sha256_test() and sha512_test().

src/ssl.c: fix for true-but-benign nullPointerRedundantCheck in ProcessBufferTryDecodeEd25519().

tests/api.c: fix for -Wmaybe-uninitialized in test_wc_PKCS7_VerifySignedData_RSA() identified via cross-m68k-all-asm.
2024-03-05 17:44:33 -06:00
Sean Parkinson ee39a8f17f
Merge pull request #7262 from gojimmypi/PR-SHA-Interleave
Introduce SHA256/SHA512 interleave testing, HAVE_DSA; revised ERROR_OUT
2024-03-05 10:13:10 +10:00
Brett Nicholas 55421a11b9 review: removed WOLFSSL_ABI from and refactored args for wc_rng_new_ex, updated tests 2024-02-27 10:17:24 -07:00
gojimmypi 0775baa2e1 Introduce SHA256/SHA512 interleave, HAVE_DSA; revised ERROR_OUT, cleanup 2024-02-23 17:52:20 -08:00
Brett Nicholas 1a5064cf8c add full support to wolfcrypt tests for random.c cryptocbs 2024-02-23 13:02:05 -07:00
JacobBarthelmeh 88e7d47930
Merge pull request #7230 from anhu/tests_gating
Fixup some gating in the tests.
2024-02-22 01:24:55 +07:00
Anthony Hu 00c3f5be2e A fixup 2024-02-20 21:50:03 -05:00
Sean Parkinson af2b2dddb4
Merge pull request #7253 from julek-wolfssl/zd/17507
wc_ecc_shared_secret_ssh fix
2024-02-20 06:56:28 +10:00
Daniel Pouzzner 8d894fb01b wolfssl/wolfcrypt/types.h: add WC_ARRAY_ARG() and WC_HEAP_ARRAY_ARG() constructors, for passing arrays declared by WC_DECLARE_ARRAY() and WC_DECLARE_HEAP_ARRAY(). used this to refactor bench_rsa_helper() arg list, fixing a cppcheck argumentSize warning.
wolfcrypt/test/test.c: revert overeager constification of xmss_msg and xmss_sig.
2024-02-17 15:24:55 -06:00
Daniel Pouzzner 44e0ee1ecd wolfssl/wolfcrypt/types.h:
* fix overallocation in WC_DECLARE_ARRAY() macro in the !WOLFSSL_SMALL_STACK path.
* rename WC_INIT_ARRAY() to WC_ALLOC_ARRAY() for clarity (it doesn't initialize any memory).
* rename WC_DECLARE_ARRAY_DYNAMIC_DEC(), WC_DECLARE_ARRAY_DYNAMIC_EXE(), and WC_FREE_ARRAY_DYNAMIC() to WC_DECLARE_HEAP_ARRAY(), WC_ALLOC_HEAP_ARRAY(), and WC_FREE_HEAP_ARRAY(), respectively, also for clarity, and refactor out the duplicate definitions.
* add WC_ALLOC_VAR(), and move the XMALLOC() in smallstack WC_DECLARE_VAR() into it.  smallstack WC_DECLARE_VAR() now initializes the pointer to NULL, like smallstack WC_DECLARE_ARRAY(), assuring all pointers are valid upon shortcircuit to cleanup for a failed allocation (see WC_ALLOC_DO_ON_FAILURE below).
* add a new hook "WC_ALLOC_DO_ON_FAILURE" in WC_ALLOC_VAR(), WC_ALLOC_ARRAY(), and WC_DECLARE_ARRAY_DYNAMIC_EXE(), which is invoked when an allocation fails.  by default the hook is defined to WC_DO_NOTHING.
* add basic safety to WC_*_HEAP_ARRAY() by recording/detecting allocation state via idx##VAR_NAME.
* add macros WC_ARRAY_OK() and WC_HEAP_ARRAY_OK() to test if allocation succeeded.
* add macros WC_CALLOC_ARRAY() and WC_CALLOC_HEAP_ARRAY() which zero the objects.
* add macro WC_CALLOC_VAR() which zeros the object.

ED448: smallstack refactor of ge448_scalarmult_base().

src/tls.c tests/api.c wolfcrypt/test/test.c: update WC_DECLARE_VAR()s with now-required matching WC_ALLOC_VAR()s.

wolfcrypt/benchmark/benchmark.c:
* no functional changes in default error-free behavior.
* add definition of WC_ALLOC_DO_ON_FAILURE() that prints error message, sets ret, and does goto exit.
* add BENCH_NTIMES and BENCH_AGREETIMES overrideeable macros, to allow fast sanitizer runs and slow high-precision runs.
* smallstack refactor of all declarations of stack arrays of the form foo[BENCH_MAX_PENDING], using WC_DECLARE_ARRAY() (35 in all).
* additional smallstack refactors, using WC_DECLARE_VAR(), for bench_aesxts(), bench_ed448KeyGen(), bench_eccsi*(), and bench_sakke*().
* fixes for various unhandled error conditions around malloc failures.

wolfcrypt/test/test.c: opportunistically constify several (42) static constants, moving them to the readonly data segment.

linuxkm/Makefile: if ENABLED_LINUXKM_BENCHMARKS, add wolfcrypt/benchmark/benchmark.o to WOLFSSL_OBJ_FILES.

linuxkm/Kbuild: enable FPU for benchmark.o, and remove enablement for module_hooks.o.

linuxkm/module_hooks.c: remove inline include of benchmark.c.
2024-02-16 10:26:21 -06:00
Juliusz Sosinowicz 469760e186 wc_ecc_shared_secret_ssh fix
- wc_ecc_shared_secret_ssh should either be declared or not. Having two different signatures for the same function is error prone.
- Don't use wc_ecc_shared_secret_ssh in our code. Use wc_ecc_shared_secret directly.
2024-02-16 13:38:35 +01:00
Daniel Pouzzner 9b7decada0 wolfcrypt/test/test.c: fix Aes init/free lifecycle in aes192_test() and aes256_test(). 2024-02-13 01:23:11 -06:00
Daniel Pouzzner 63fe12efe3 wolfcrypt/src/aes.c: fix WOLFSSL_AESGCM_STREAM && WC_AES_C_DYNAMIC_FALLBACK: establish AESNI status dynamically at time of wc_AesGcmSetKey(), and stick to it (or return failure) until the next wc_AesGcmSetKey(). this matches the semantics of the Linux kernel in-tree implementation, allowing safe registration of the wolfCrypt AESNI implementation with the LKCAPI.
configure.ac: move enable_aesgcm_stream=yes clauses in enable-all and enable-all-crypto to the main section, from the !ENABLED_LINUXKM_DEFAULTS section, and in ENABLED_LINUXKM_LKCAPI_REGISTER setup, remove the !ENABLED_AESNI from the condition for forcing on ENABLED_AESGCM_STREAM.

linuxkm/lkcapi_glue.c:
* remove all special-casing for AES-GCM with AESNI.
* add support for a LINUXKM_LKCAPI_PRIORITY_ALLOW_MASKING macro.

wolfssl/wolfcrypt/memory.h: add missing definition of SAVE_VECTOR_REGISTERS2() when DEBUG_VECTOR_REGISTER_ACCESS_FUZZING && !DEBUG_VECTOR_REGISTER_ACCESS.

wolfcrypt/src/memory.c:
* define SAVE_VECTOR_REGISTERS2_fuzzer() if DEBUG_VECTOR_REGISTER_ACCESS_FUZZING, regardless of DEBUG_VECTOR_REGISTER_ACCESS.
* add a DEBUG_VECTOR_REGISTER_ACCESS clause to the !HAVE_THREAD_LS version of SAVE_VECTOR_REGISTERS2_fuzzer().

wolfcrypt/test/test.c: remove several errant wc_AesFree()s in aes256_test().
2024-02-10 01:09:15 -06:00
Daniel Pouzzner 91681f378f configure.ac:
* add srtp to enable-all
* add srtp-kdf to enable-all-crypto
* fix typo in enable-all[-crypto] where ENABLED_FIPS was used when FIPS_VERSION was needed.
* in enable-all[-crypto], conditionalize aesxts on !FIPS || FIPS_VERSION == dev.
* move AES-XTS CFLAG setup after FIPS settings, to allow non-dev FIPS to force it off, and add clause to FIPS v5 setup to do that.
* in FIPS v5 setup, add AES-XTS to the list of modes that forces -DWOLFSSL_AES_DIRECT -DHAVE_AES_ECB.

wolfcrypt/src/kdf.c: fix several benign -Wconversions.

wolfcrypt/test/test.c: add aes_cfb_test() and aes_xts_test() as top-level tests with separate "pass" messages, for transparency that those modes have indeed been tested in builds that activate them.
2024-02-09 00:46:54 -06:00
Anthony Hu d0fd0a287b Fixup some gating in the tests.
Found with:

./configure --enable-wolfclu --enable-asn=template 'CFLAGS=-DNO_ASN_TIME -DWOLFSSL_CUSTOM_OID -DHAVE_OID_ENCODING'
2024-02-08 16:14:43 -05:00
Daniel Pouzzner 851f059023
Merge pull request #7203 from julek-wolfssl/openssh-9.6
openssh 9.6p1 fixes
2024-02-02 19:51:55 -05:00
David Garske 32aecf4c35
Merge pull request #7180 from douzzer/20240126-LINUXKM_LKCAPI_REGISTER
20240126-LINUXKM_LKCAPI_REGISTER
2024-02-02 11:12:35 -08:00
Juliusz Sosinowicz 7ebb8cd007 Update radix tests 2024-02-02 12:09:50 +01:00
Daniel Pouzzner f228a85cee AES-XTS: fix FIPS gating to use defined(HAVE_FIPS), not defined(HAVE_FIPS_VERSION). 2024-01-30 17:16:37 -06:00
jordan 7ddf20851d Fix WOLFSSL_NO_MALLOC build. 2024-01-30 09:00:02 -06:00
Daniel Pouzzner 6261108d49 linuxkm: fix line lengths throughout; in linuxkm/lkcapi_glue.c: fix/harmonize error catching, reporting, and error codes; further address peer review feedback. 2024-01-29 17:48:31 -06:00
Daniel Pouzzner 1fc67183a5 linuxkm: address peer review:
* support AES_ENCRYPTION_AND_DECRYPTION only if WC_AES_XTS_SUPPORT_SIMULTANEOUS_ENC_AND_DEC_KEYS is defined, and define it in linuxkm_wc_port.h if LINUXKM_LKCAPI_REGISTER.
* fix a typo in km_AesInitCommon().
* remove #if 0 code in lkcapi_glue.c.
2024-01-28 23:58:46 -06:00
Daniel Pouzzner b1e5d0f9bb linuxkm: completion and stabilization of LKCAPI integration for AES-CBC, AES-CFB, AES-GCM, and AES-XTS:
linuxkm/lkcapi_glue.c (added in earlier commit):
implement linuxkm_lkcapi_register() and linuxkm_lkcapi_unregister() with idempotency.
add AES-XTS algorithm glue and self-test implementations.
add per-algorithm gating: LINUXKM_LKCAPI_REGISTER_AESCBC, _AESCFB, _AESGCM, and _AESXTS.
carry forward philljj's implementations for AES-CBC, AES-CFB, and AES-GCM, with various cleanups.

linuxkm/module_hooks.c:
print the "wolfCrypt container hashes" message only if DEBUG_LINUXKM_PIE_SUPPORT is set.
render the FIPS version for the self-test success message using the HAVE_FIPS_VERSION* macros.
add a "skipping full wolfcrypt_test() ..." message for --disable-crypttests builds.
add CONFIG_FORTIFY_SOURCE gates.

configure.ac:
add support for --enable-linuxkm-lkcapi-register;
add AES-XTS to output config summary;
rename --enable-xts to --enable-aesxts (retaining old option for backward compatibility).

linuxkm/linuxkm_wc_port.h: add support for CONFIG_FORTIFY_SOURCE.

linuxkm/linuxkm_memory.c:
fix retvals in save_vector_registers_x86() (wc-style MEMORY_E, not sys-style ENOMEM).
add __my_fortify_panic() implementation.

linuxkm/Kbuild: for ENABLED_LINUXKM_PIE in rename-pie-text-and-data-sections recipe, create an .rodata.wolfcrypt section.

linuxkm/include.am: add linuxkm/lkcapi_glue.c to EXTRA_DIST.

wolfcrypt/test/test.c:
when defined(HAVE_FIPS_VERSION), inhibit a test clause in aes_xts_128_test() disallowed by FIPS ("FIPS AES-XTS main and tweak keys must differ").
fix out-of-order user message in ecc_test().
2024-01-26 20:01:19 -06:00
Sean Parkinson a5961907b0 XMSS implementation
Supporting code for wolfSSL C implementation of XMSS.
2024-01-25 11:21:39 +10:00
David Garske 7a77d64d56
Merge pull request #7059 from bigbrett/cryptocb-oneshot-cmac
Add cryptoCb hook to one-shot CMAC functions
2024-01-16 12:17:05 -08:00
Brett Nicholas abbf9f2b77 Add cryptoCb hooks to one-shot CMAC functions; add CMAC coverage to cryptoCb tests; add context argument to CMAC generate_ex 2024-01-15 11:52:17 -07:00
David Garske 06a32d3437
Merge pull request #7097 from lealem47/removeUserCrypto
Remove user-crypto functionality and Intel IPP support
2024-01-09 17:33:28 -08:00
jordan e175004f85 Fix Infer Uninitialized Values. 2024-01-02 12:16:20 -06:00
John Bland 34d7229d4e add functions for using an hpke context multiple times 2023-12-29 16:15:54 -05:00
Daniel Pouzzner b17ec3b4bc cppcheck-2.13.0 mitigations peer review:
* add explanation in DoSessionTicket() re autoVariables.
* re-refactor ECC_KEY_MAX_BITS() in ecc.c to use two separate macros, ECC_KEY_MAX_BITS() with same definition as before, and ECC_KEY_MAX_BITS_NONULLCHECK().
* in rsip_vprintf() use XVSNPRINTF() not vsnprintf().
* in types.h, fix fallthrough definition of WC_INLINE macro in !NO_INLINE cascade to be WC_MAYBE_UNUSED as it is when NO_INLINE.
2023-12-28 16:38:47 -06:00
Daniel Pouzzner 44b18de704 fixes for cppcheck-2.13.0 --force:
* fix null pointer derefs in wc_InitRsaKey_Id() and wc_InitRsaKey_Label() (nullPointerRedundantCheck).
* fix use of wrong printf variant in rsip_vprintf() (wrongPrintfScanfArgNum).
* fix wrong printf format in bench_xmss_sign_verify() (invalidPrintfArgType_sint).
* add missing WOLFSSL_XFREE_NO_NULLNESS_CHECK variants of XFREE() (WOLFSSL_LINUXKM, FREESCALE_MQX, FREESCALE_KSDK_MQX).
* suppress false-positive uninitvar on "limit" in CheckTLS13AEADSendLimit().
* suppress true-but-benign-positive autoVariables in DoClientHello().
* in wolfcrypt/src/ecc.c, refactor ECC_KEY_MAX_BITS() as a local function to resolve true-but-benign-positive identicalInnerCondition.
* refactor flow in wc_ecc_sign_hash_ex() to resolve true-but-benign-positive identicalInnerCondition.
2023-12-28 15:06:21 -06:00
Daniel Pouzzner 457188f55e
Merge pull request #7070 from dgarske/cryptocb_moreinfo
Fixes for TLS with crypto callbacks
2023-12-27 18:55:56 -05:00
Lealem Amedie 837452b1ca Remove user-crypto functionality and Intel IPP support 2023-12-27 12:24:19 -07:00
Sean Parkinson f77f7c70d3
Merge pull request #7018 from dgarske/ti_aes
Fixes for TI AES and SHA
2023-12-22 07:55:00 +10:00
David Garske 00f196d497 Fix for invalid `dh_ffdhe_test` test with even P when using Intel QuickAssist. 2023-12-20 11:30:17 -08:00
David Garske d5e83310b6 Fix typo with HMAC determination of update/final. 2023-12-18 17:11:33 -08:00
Daniel Pouzzner ef14176b7f SRTP fixes:
* in wolfssl/ssl.h, add missing arg names to wolfSSL_CTX_set_tlsext_use_srtp(), wolfSSL_set_tlsext_use_srtp(), and wolfSSL_export_dtls_srtp_keying_material();
* in wolfcrypt/src/kdf.c, call wc_AesFree if and only if wc_AesInit() succeeded;
* in src/ssl.c:DtlsSrtpSelProfiles(), fix bugprone-inc-dec-in-conditions;
* in tests/suites.c:execute_test_case(), fix several -Wdeclaration-after-statement and -Wmissing-field-initializers;
* in wolfcrypt/test/test.c, fix a shiftTooManyBitsSigned warning in srtpkdf_test(), and fix a typo (kaSz/ksSz).
2023-12-15 14:06:36 -06:00
Chris Conlon 27c6ee4d05
Merge pull request #7068 from SparkiDev/srtp_kdf_label
SRTP/SRTCP KDF: add APIs that derives one key from a label
2023-12-14 14:54:58 -07:00
Chris Conlon fb6b022f42
Merge pull request #7020 from SparkiDev/ecc_gen_k_by_reject
ECC: generate values in range of order by rejection
2023-12-14 14:54:39 -07:00
Sean Parkinson 659a245b27 SRTP/SRTCP KDF: add APIs that derives one key from a label
Added more generic APIs that derive a single key with a label.
Added defines for label values and index lengths.
2023-12-14 14:45:35 +10:00
Sean Parkinson 21f53f37a1 ECC: generate values in range of order by rejection
When generating private key and nonce for ECDSA, use rejection sampling.
Note: SP uses this algorithm
2023-12-12 14:55:56 +10:00
David Garske 058ffad657 Fix cast warnings on test with -1. 2023-12-11 16:25:47 -08:00
David Garske 68cfaa76fc Fix for TI-RTOS time. Cleanup forced settings.h for `WOLFSSL_TIRTOS`. Compiler warning cleanups. 2023-12-11 15:57:26 -08:00
Daniel Pouzzner c1b5135918 wolfcrypt/src/evp.c and wolfcrypt/test/test.c: in FIPS builds <5.3, gate out AES-XTS functionality that depends on new APIs added in #7031 (b14aba48af and 931ac4e568) (AES-XTS is non-FIPS in FIPS <5.3). 2023-12-11 12:14:29 -06:00
JacobBarthelmeh ac447d1afb
Merge pull request #7031 from douzzer/20231201-openssl-compat-fixes
20231201-openssl-compat-fixes
2023-12-08 17:25:53 -07:00
Eric Blankenhorn 27e93276de Check for neg size in fp_read_unsigned_bin 2023-12-07 14:26:12 -06:00
Daniel Pouzzner 931ac4e568 add documentation for wc_AesXtsInit(), wc_AesXtsSetKeyNoInit(), wc_CmacFinalNoFree(), and wc_CmacFree();
rename wc_AesXtsSetKey_NoInit() to wc_AesXtsSetKeyNoInit() for morphological consistency;

refactor wc_AesXtsSetKey() to call wc_AesXtsSetKeyNoInit() and clean up on failure;

readability tweak in wolfSSL_EVP_CipherFinal().
2023-12-06 19:26:46 -06:00
Daniel Pouzzner 689a82a622 fix AES-related code, in both crypto and TLS layers, for various uninitialized data and resource leak defects around wc_AesInit() and wc_AesFree():
* followup to https://github.com/wolfSSL/wolfssl/pull/7009 "20231128-misc-fixes" and  https://github.com/wolfSSL/wolfssl/pull/7011 "Add missing wc_AesInit calls."

* adds WC_DEBUG_CIPHER_LIFECYCLE, which embeds asserts in low-level AES implementations for proper usage of wc_AesInit() and wc_AesFree().

* fixes native CMAC, AES-EAX, and AES-XTS implementations to assure resource release.

* adds missing wc_AesXtsInit() API, and adds a new wc_AesXtsSetKey_NoInit().

* fixes misspellings in EVP that unconditionally gated out AES-OFB and AES-XTS.

* fixes misspellings in EVP that unconditionally gated out AES-CBC and AES-CFB code in wolfSSL_EVP_CIPHER_CTX_cleanup_cipher().

* openssl compat AES low level cipher API has no counterpart to wc_AesFree(), so these compat APIs will now be gated out in configurations where they would otherwise leak memory or file descriptors (WOLFSSL_AFALG, WOLFSSL_DEVCRYPTO, WOLF_CRYPTO_CB, etc.).  A new macro, WC_AESFREE_IS_MANDATORY, is defined in wolfcrypt/aes.h to streamline this dependency.

* fixes 40 missing EVP_CIPHER_CTX_cleanup()s and 11 wc_AesFree()s in src/ssl.c, src/ssl_crypto.c, tests/api.c, and wolfcrypt/test/test.c.
2023-12-05 15:58:09 -06:00
JacobBarthelmeh c4ab1e6d47
Merge pull request #7017 from SparkiDev/asn_tmpl_ecc_raw_to_sig_fix
ASN template: StoreECC_DSA_Sig_Bin
2023-12-01 16:11:15 -07:00
Sean Parkinson 02f8735abf Test DSA: fix unused variables
test.c: fix #if protection around unused variables
2023-12-01 11:04:53 +10:00
JacobBarthelmeh a7e5c6c721
Merge pull request #7011 from philljj/add_missing_aesinit
Add missing wc_AesInit calls.
2023-11-30 11:01:02 -07:00
Sean Parkinson 21f662c7d1 ASN template: StoreECC_DSA_Sig_Bin
Strip leading zeros from R and S before encoding in ASN.1.
2023-11-30 20:31:29 +10:00
jordan 3158e04863 Add missing wc_AesInit calls. 2023-11-29 12:54:28 -06:00
Daniel Pouzzner 93ab397c56 wolfcrypt/test/test.c: fix memory leak in dsa_test(). 2023-11-29 12:28:39 -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
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
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
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 c903a8c4a6
Merge pull request #6854 from SparkiDev/aes_bit_sliced
AES bitsliced implementation added
2023-11-10 17:10:19 -07: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
Daniel Pouzzner 9cb6243357 wolfcrypt/test/test.c: add all initializers in wolfcrypt_test_main() for args for C++ legality (C-style initializer added in e58fafcf3d). 2023-11-07 19:33:18 -06:00
JacobBarthelmeh d751029c07
Merge pull request #6945 from gojimmypi/PR-goto-alternate
introduce WARNING_OUT, when goto is not a hard error during tests
2023-11-07 10:17:53 -07:00
JacobBarthelmeh 8921a720a1
Merge pull request #6888 from SparkiDev/srtp_kdf
SRTP/SRTCP KDF: add implementation
2023-11-07 10:11:43 -07:00
gojimmypi e58fafcf3d introduce WARNING_OUT, optional WOLFSSL_ESPIDF_ERROR_PAUSE 2023-11-07 08:52:34 +01:00
Sean Parkinson 8c3e1dbf48 SRTP/SRTCP KDF: add implementation
Add implementation of SRTP KDF and SRTCP KDF.
One shot APIs compatible with SP 800-135 and ACVP testing.
Tests added to test.c.
Benchmarking added.
Doxygen added.
2023-11-07 10:33:14 +10:00
Sean Parkinson 5b863dcb12 AES bitsliced implementation added
AES bitsliced implementation that is cache attack safe.
Configure with:
  --enable-aes-bitslice
or define:
  WC_AES_BITSLICE
  HAVE_AES_ECB
  HAVE_AES_DIRECT
Very slow for CBC, CFB, OFB and any mode that uses a previous encrypt
block to calculate current.
CTR, GCM, XTS can parallelize the data and be much faster.

Added AES-ECB test to test.c.
2023-11-03 14:19:58 +10:00
David Garske 33e12e3537 Support for the STM32WL55 and PKA improvements for ECC parameters. Fixes #6386 and Fixes #6396. 2023-11-01 13:55:31 -07:00
JacobBarthelmeh d35112064b
Merge pull request #6840 from philljj/xmss_hooks_support
Add XMSS/XMSSMT wolfCrypt hooks.
2023-10-16 10:58:12 -06:00
jordan 46b1a030a7 XMSS/XMSSMT hooks support: fix g++ warnings, and small cleanup for review. 2023-10-13 18:01:07 -05:00
JacobBarthelmeh 79a6e1eb04
Merge pull request #6808 from SparkiDev/sp_sm2
SP updates for SM2
2023-10-13 10:17:17 -06:00