Commit Graph

8209 Commits (devin/1739920896-esp32-fixes)

Author SHA1 Message Date
jordan 622fc70d1e acert: fix holder entityName parsing, light cleanup, better testing. 2024-11-15 11:38:19 -06:00
Brett Nicholas 2207791aab removed DecodeAsymKeyXXX_Assign_ex function, functionality now included in original _Assign function 2024-11-15 10:25:10 -07:00
David Garske 5f06a7f732
Merge pull request #8188 from douzzer/20241114-wc_mp_sign_t
20241114-wc_mp_sign_t
2024-11-15 08:36:42 -08:00
David Garske fcfd3be160
Merge pull request #8186 from SparkiDev/tfm_mask_cast
TFM: explicit cast of -1 to fp_digit
2024-11-14 17:57:00 -08:00
David Garske 54bdb39454
Merge pull request #8176 from SparkiDev/x509_coverage
X509: improve testing coverage
2024-11-14 17:49:33 -08:00
David Garske 8b1e9211b1
Merge pull request #8149 from SparkiDev/asn_getshortint
Make GetShortInt available with WOLFSSL_ASN_EXTRA
2024-11-14 17:47:11 -08:00
Daniel Pouzzner 154c5f0b56 rename mp_sign_t to wc_mp_sign_t and mp_size_t to wc_mp_size_t. 2024-11-14 18:14:45 -06:00
Daniel Pouzzner dd9f6378cb rename WOLFSSL_GLOBAL to WC_THREADSHARED, and refactor mutex handling in src/sniffer.c for consistency and correctness, also adding gating on !SINGLE_THREADED for efficiency;
add wc_static_assert in wolfcrypt/test/test.h to assure that WC_TEST_RET_ENC() can correctly handle all error codes.
2024-11-14 16:35:04 -06:00
Sean Parkinson 9d8a3cc352 TFM: explicit cast of -1 to fp_digit
When -1 is needed as an fp_digit, as a mask. cast to fp_digit.
2024-11-15 08:25:44 +10:00
Brett Nicholas f672105d55 - Move automatic OID detection from Dilithium code into ASN code 2024-11-13 15:31:59 -07:00
Daniel Pouzzner 0ebd86d668 add second wolfCrypt error code span, and add DEADLOCK_AVERTED_E. 2024-11-13 13:01:00 -06:00
Sean Parkinson 86ad96ca29 X509: improve testing coverage 2024-11-13 09:10:22 +10:00
Brett Nicholas 6b1b6ece00 guard use of dilithium_key->params on WC implementation 2024-11-12 16:08:11 -07:00
Brett Nicholas 0e6ac11d15 - Add ability to obtain Dilithium security level (parameters) from a DER
encoded key based on the algorithm type OID
- Add test coverage for decoding DER keys without level specified
2024-11-12 14:19:12 -07:00
JacobBarthelmeh 4996aed166
Merge pull request #8117 from rizlik/static_mem_fix_types
memory: fix types in wc_LoadStaticMemory_ex()
2024-11-11 09:48:25 -07:00
Daniel Pouzzner 9361603d8b
Merge pull request #8071 from JacobBarthelmeh/static
display heap pointer with debug enabled
2024-11-09 00:20:32 -06:00
Daniel Pouzzner 165b4afbeb
Merge pull request #8143 from SparkiDev/kyber_plus_mlkem
Kyber/ML-KEM: make both available
2024-11-09 00:09:51 -06:00
Daniel Pouzzner 23f46a1c3e
Merge pull request #8140 from dgarske/wildcard
Fix for building sources (wildcard *.c). Add macro guard on new files.
2024-11-08 23:36:00 -06:00
Hideki Miyazaki 2831eb3ca7 Fix TSIP TLS. Call rsa_pad crypt cb in the case of TSIP 2024-11-09 14:23:57 +09:00
Daniel Pouzzner aa18bbca55 assorted cleanups and refactors for C89 conformance, codespell and check-source-text, and consistent heap shim usage.
.github/workflows/codespell.yml: remove */README_jp.txt from "skip" list.

IDE/Renesas/cs+/Projects/t4_demo/README_jp.txt: convert from SHIFT_JIS to UTF-8.

cmake/options.h.in: use "#cmakedefine HAVE_PTHREAD 1" to avoid conflict with config.h.

configure.ac: add --enable-c89, and remove !ENABLED_OPENSSLEXTRA dependency from AM_CONDITIONAL([BUILD_CRYPTONLY],...).

wolfcrypt/src/asn.c: refactor SetOthername() for efficiency, and add PRAGMA_GCC to suppress false positive -Wstringop-overflow associated with -fstack-protector.

wolfssl/wolfcrypt/rsa.h: add WC_ prefixes to RSA_PKCS1_PADDING_SIZE and RSA_PKCS1_OAEP_PADDING_SIZE, and define unprefixed compat aliases only if !OPENSSL_COEXIST.

wolfssl/wolfcrypt/types.h:

  #ifdef WOLF_C89, #define WC_BITFIELD unsigned;
  enhance WOLF_ENUM_DUMMY_LAST_ELEMENT() to include the line number, to construct unique labels given a per-filename argument, to accommodate anonymous enums.

examples/asn1/asn1.c:
examples/client/client.c:
examples/pem/pem.c:
examples/server/server.c:
wolfcrypt/src/sp_dsp32.c:
wolfcrypt/src/wc_port.c:
wolfssl/test.h:

  use XMALLOC/XREALLOC/XFREE consistently, not malloc/realloc/free.

wolfcrypt/benchmark/benchmark.c:
wolfcrypt/src/memory.c:
wolfcrypt/test/test.c:
wolfssl/wolfcrypt/mem_track.h:
wolfssl/wolfcrypt/settings.h:
wolfssl/wolfcrypt/types.h:

  annotate intentional native heap access with "/* native heap */".

wolfcrypt/src/asn.c:
wolfssl/callbacks.h:
wolfssl/openssl/ec.h:
wolfssl/openssl/ssl.h:
wolfssl/wolfcrypt/hpke.h:
wolfssl/wolfcrypt/types.h:

  fix enum trailing commas.

wolfssl/openssl/ec.h:
wolfssl/openssl/evp.h:
wolfssl/openssl/rsa.h:
wolfssl/openssl/ssl.h:

  use WC_BITFIELD in bitfield elements, not byte or word16, to allow for pedantic C89 conformant builds.

wolfssl/openssl/ec.h:
wolfssl/openssl/evp.h:
wolfssl/openssl/pem.h:
wolfssl/openssl/ssl.h:
wolfssl/wolfcrypt/logging.h:
avoid variadic macros wherever possible, and where unavoidable, #ifdef WOLF_NO_VARIADIC_MACROS, define them with empty arg lists, rather than ..., to support Watcom compiler.

wolfssl/wolfcrypt/settings.h: if defined(__WATCOMC__), define WOLF_NO_VARIADIC_MACROS.
2024-11-07 22:36:24 -06:00
Andrew Hutchings 1d2c78e3be Add support for Raspberry Pi Pico
This adds improved support for the Raspberry Pi Pico range of
microcontrollers.

Benchmark now compiles, and added support for the RNG functions of the
Pico SDK. This gives a ~2x RNG performance improvement on the RP2040 and
over 3x improvement on the RP2350.

The accelerated SHA256 in the RP2350 unfortunately cannot be used with
wolfSSL.
2024-11-07 17:26:51 +00:00
David Garske 43879f961d Fix RSA TSIP to return the actual cipher or plain length on success. Fix crypto callback to properly support PKCSv1.5 sign/verify and encrypt/decrypt based on padding info. 2024-11-06 10:37:03 -08:00
David Garske 3179a2ff00 Cleanup the import function declarations. 2024-11-05 14:14:25 -08:00
David Garske 6b02d7879a Add public decrypt and private encrypt. Cleanups. 2024-11-05 09:24:00 -08:00
Daniel Pouzzner 0f31f5bad9 codespell fixes. 2024-11-05 00:19:07 -06:00
Daniel Pouzzner 8ecf064314
Merge pull request #8098 from dgarske/x86_notwindows_2
More fixes for building x86 in Visual Studio for non-windows OS
2024-11-05 00:13:13 -06:00
David Garske 92f7e91655
Merge pull request #8120 from SparkiDev/asn_templ_doc
ASN template documentation: adding basics for decoding
2024-11-04 15:25:18 -08:00
Sean Parkinson 36515e8daf Make GetShortInt available with WOLFSSL_ASN_EXTRA
Customers may need to use GetShortInt when doing custom ASN.1 parsing.
Was only available when !NO_PWDBASED.
GetShortInt is still an internal API.
2024-11-05 08:46:34 +10:00
Daniel Pouzzner 95b47714d5
Merge pull request #8147 from bandi13/regenScripts
Regen scripts
2024-11-04 16:37:24 -06:00
Andras Fekete f7691febd3 Update generated code from scripts 2024-11-04 13:46:37 -05:00
Marco Oliverio dce9b2e7bd memory: fix types in static memory functions 2024-11-04 16:21:04 +00:00
Sean Parkinson 7d42ddae48 Kyber/ML-KEM: make both available
Make Kyber and ML-KEM individually available as well as at the same
time.
Modified TLS layer to support both Kyber and ML-KEM.
Added new identifiers in TLS layer for ML-KEM.
2024-11-04 23:51:51 +10:00
Daniel Pouzzner 6f7c968c56 rename MAX_CERT_VERIFY_SZ to WC_MAX_CERT_VERIFY_SZ, and move its setup from wolfssl/internal.h to wolfssl/wolfcrypt/asn.h.
rename WOLFSSL_MAX_RSA_BITS to WC_MAX_RSA_BITS, and move its setup from wolfssl/internal.h to wolfssl/wolfcrypt/asn.h, preceding setup for WC_MAX_CERT_VERIFY_SZ.

configure.ac: restore opensslextra-linuxkm assertion, with a twist: "--enable-opensslextra with --enable-linuxkm-pie and without --enable-cryptonly is incompatible with --enable-linuxkm."

wolfcrypt/src/asn.c: fix trailing comma in enum.

wolfcrypt/src/port/arm/armv8-aes.c: fix wc_AesCcmEncrypt() and wc_AesCcmDecrypt() for test_wolfssl_EVP_aes_ccm_zeroLen().
2024-11-02 23:50:34 -05:00
Daniel Pouzzner 6119c52802
Merge pull request #8043 from bandi13/addCodespell
Add Codespell test to PRs
2024-11-01 21:20:29 -05:00
David Garske 836b741402
Merge pull request #8132 from douzzer/20241024-opensslcoexist-opensslextra
20241024-opensslcoexist-opensslextra
2024-11-01 14:34:11 -07:00
David Garske 99daac3974 Improvement for `SAVE_VECTOR_REGISTERS` 2024-11-01 13:57:02 -07:00
David Garske f95c4d7b67 Fix for building sources (wildcard *.c). Add macro guard on new files. 2024-11-01 10:46:40 -07:00
Andras Fekete 0915012b72 Fix new spelling errors 2024-11-01 13:00:59 -04:00
Andras Fekete 8ecfe311d8 More spelling fixes 2024-11-01 12:59:01 -04:00
Andras Fekete 97998d0713 Spellcheck on assembly 2024-11-01 12:59:01 -04:00
Andras Fekete 631eafacb8 Fix some spelling 2024-11-01 12:59:01 -04:00
Daniel Pouzzner 6b78726f13
Merge pull request #8134 from dgarske/ge448
Fix GE448 conversion warning
2024-11-01 11:55:01 -05:00
Sean Parkinson 24003b265a
Merge pull request #8129 from bigbrett/curve25519-generic-keyparsing
Curve25519 generic keyparsing
2024-11-01 09:04:50 +10:00
David Garske 6e3f83d19e Sync with script. 2024-10-31 15:54:05 -07:00
Brett Nicholas 325221707c address review feedback 2024-10-31 13:02:21 -06:00
David Garske 0d495702e5 Fix GE448 conversion warning:
`error: conversion from ‘word32’ {aka ‘unsigned int’} to ‘byte’ {aka ‘unsigned char’} may change value`
2024-10-31 10:34:19 -07:00
Daniel Pouzzner a2bcbf7ecf additional fixes and peer review for -DOPENSSL_EXTRA -DOPENSSL_COEXIST: cover -DWOLFSSL_QUIC, fix -DNO_ASN, rename WOLFSSL_ASN1_TYPE_* to WOLFSSL_V_ASN1_*, completed nativization of NID_*, and switch to prefix WC_NID_ rather than wc_NID_. 2024-10-31 00:10:21 -05:00
Daniel Pouzzner cf95fdc071 Globally remap & refactor conflicting symbols to allow -DOPENSSL_EXTRA -DOPENSSL_COEXIST, or equivalently, --enable-opensslextra --enable-opensslcoexist.
No functional changes.

Several compat symbols that were formerly enums are now macros.

All library source is refactored to use only native symbols in all code gated in with --enable-all-crypto --enable-opensslextra.

wolfcrypt/test/test.c is similarly refactored to use only native symbols.

examples/ and tests/ are unmodified except for header setup to disable OPENSSL_COEXIST and TEST_OPENSSL_COEXIST.
2024-10-31 00:10:21 -05:00
Sean Parkinson dcd75df852 ASN template documentation: adding basics for decoding
First draft of ASN template documentation that helps with writing
parsing code.
2024-10-31 12:08:22 +10:00
Sean Parkinson 26312141d8 ASM: generated code not using uint*_t types
Don't use uint*_t types as they may not be available.
2024-10-31 10:14:00 +10:00
Sean Parkinson 614a0e3f09
Merge pull request #8123 from dgarske/armasm
Fix issue with error: conflicting types for 'BlockSha3'
2024-10-31 09:37:26 +10:00
David Garske 807975c864
Merge pull request #8127 from anhu/percentd
added a missing %d
2024-10-30 15:21:15 -07:00
JacobBarthelmeh bc56129ed8 display heap pointer with debug enabled 2024-10-30 14:39:12 -06:00
Anthony Hu 54dc8320d2 added a missing %d 2024-10-30 14:53:21 -04:00
David Garske 0669ba82c4 Avoid stdint types. 2024-10-30 10:28:45 -07:00
Brett Nicholas 97a370ed08 added generic curve25519 encode/decode functions that can handle combined keypairs 2024-10-30 09:37:16 -06:00
David Garske c557c6f2bd Fix issue with error: conflicting types for 'BlockSha3'.
```
[CC-AARCH64] lib/wolfssl/wolfcrypt/src/port/arm/armv8-sha3-asm_c.o
lib/wolfssl/wolfcrypt/src/port/arm/armv8-sha3-asm_c.c:212:6: error: conflicting types for 'BlockSha3'; have 'void(long unsigned int *)'
  212 | void BlockSha3(unsigned long* state)
      |      ^~~~~~~~~
In file included from lib/wolfssl/wolfcrypt/src/port/arm/armv8-sha3-asm_c.c:35:
lib/wolfssl/wolfssl/wolfcrypt/sha3.h:224:20: note: previous declaration of 'BlockSha3' with type 'void(word64 *)' {aka 'void(long long unsigned int *)'}
  224 | WOLFSSL_LOCAL void BlockSha3(word64 *s);
      |                    ^~~~~~~~~
```
2024-10-29 16:56:50 -07:00
Hideki Miyazaki b07a372b52 Fix spaces and tabs 2024-10-30 06:42:07 +09:00
JacobBarthelmeh 2b8d43cef2
Merge pull request #8119 from dgarske/async_20241028
Fixes for asynchronous release - SHA3/HMAC devId
2024-10-29 15:11:43 -06:00
David Garske 84b5d6613d More fixes for building x86 in Visual Studio for non-windows OS (Watcom C compiler). Followup to PR #7884. Fixes ZD 18465
* Consolidate the USE_WINDOWS_API to a single place.
* Expand the `WOLFSSL_NOT_WINDOWS_API` improvement for intrinsics and word sizes.
* Fix for macro variadic `...` when no variables are used (some compilers like Watcom C have issue with this).
* Fix for Watcom C compiler "long long" -> "__int64".
* Fix a couple of minor cast warnings reported from VS.
2024-10-29 11:50:24 -07:00
Hideki Miyazaki 32c1f8bbd7 implement TSIP RSA Public Enc/Private Dec 2024-10-29 20:09:22 +09:00
David Garske ea35b98005 Fixed SHA3 issue with possible uninitialized devId when building with async. Fixed HMAC set key issue with devId/heap getting lost. 2024-10-28 11:30:05 -07:00
Daniel Pouzzner 6f87f57d7a fixes for gating and ARM32 alignment defects:
wolfcrypt/src/port/arm/armv8-aes.c: in the WOLFSSL_ARMASM_NO_HW_CRYPTO version of wc_AesSetKey(), copy the supplied userKey to a properly aligned buffer if necessary before calling AES_set_encrypt_key();

src/dtls13.c: in Dtls13GetRnMask(), if defined(WOLFSSL_LINUXKM)), return retval of wc_AesEncryptDirect();

wolfcrypt/src/misc.c: add readUnalignedWord32(), writeUnalignedWord32(), readUnalignedWords32(), and writeUnalignedWords32();

wolfcrypt/src/siphash.c: use readUnalignedWord64(), readUnalignedWord32(), and writeUnalignedWord64(), to avoid unaligned access faults, and fix cast in byte-reversing version of GET_U32().
2024-10-25 23:52:32 -05:00
Daniel Pouzzner 82273094e0
Merge pull request #8107 from JacobBarthelmeh/aesgcm
fix for state of aes.gcm.H on re-use
2024-10-23 16:52:42 -05:00
JacobBarthelmeh d0f5778429 fix for state of aes.gcm.H on re-use 2024-10-23 15:04:06 -06:00
Kareem 8986a9dae0 Fix 256-bit ECC conditional in ecc_map_ex. 2024-10-23 11:12:48 -07:00
Daniel Pouzzner 3bbd00f918 wolfcrypt/src/asn.c: tweak retval handling in MakeSignature() CERTSIGN_STATE_DO section for the benefit of WOLFSSL_DEBUG_TRACE_ERROR_CODES. 2024-10-23 00:02:29 -05:00
Daniel Pouzzner bffcfb7efc wolfcrypt/src/ecc.c: in wc_ecc_get_curve_id_from_oid(), deconditionalize guard against zero-length len added in 03a6eed037, to fix test_wc_ecc_get_curve_id_from_oid() failing in cross-mingw-all-crypto. 2024-10-23 00:02:29 -05:00
David Garske 5a0bb3a3ed Fix issue with ARM ASM with AES CFB/OFB not initializing the "left" member. ZD 18841. 2024-10-22 14:30:54 -07:00
Daniel Pouzzner 805eaa90cc
Merge pull request #7797 from julek-wolfssl/softhsm
Init SoftHSMv2 support
2024-10-21 23:56:12 -05:00
jordan 35def11781 coverity: fix error, and cleanup. 2024-10-21 14:59:32 -05:00
JacobBarthelmeh 104c805b82
Merge pull request #8092 from douzzer/20241021-wc_FreeRsaKey-WOLFSSL_XILINX_CRYPT
20241021-wc_FreeRsaKey-WOLFSSL_XILINX_CRYPT
2024-10-21 13:26:55 -06:00
Daniel Pouzzner 25da3bfe5f
Merge pull request #8070 from JacobBarthelmeh/testing_static_memory
use heap hint with wolfSSL_CTX_check_private_key
2024-10-21 13:57:55 -05:00
Daniel Pouzzner f24b987f59 wolfcrypt/src/rsa.c: fix wc_FreeRsaKey() WOLFSSL_XILINX_CRYPT XFREE() call to pass key->heap as before. 2024-10-21 12:26:29 -05:00
gojimmypi 187a9b5b4d
Apply various Espressif compatibility updates 2024-10-21 09:20:32 -07:00
JacobBarthelmeh bc0a2c43e6 avoid warning for unused parameter with certain build configurations 2024-10-21 10:04:26 -06:00
JacobBarthelmeh efff8e096c
Merge pull request #8076 from gojimmypi/pr-update-espressif-examples
Update Espressif Examples
2024-10-21 09:57:29 -06:00
Juliusz Sosinowicz 901384e704 Init SoftHSMv2 support
- wolfSSL_EVP_PKEY_set1_DH: If both private and public present, output private key
- ToTraditionalInline_ex2: Add DH checking
- wc_ecc_get_curve_id: check index is not negative
- Fix i2d_PKCS8_PRIV_KEY_INFO to actually output pkcs8 instead of just der
- wolfSSL_EVP_PKEY2PKCS8: Create duplicate to avoid double free
- wolfSSL_DH_generate_key: Fix case where not enough buffer was allocated for 128 bit case
- pkcs8_encode: Add DSA and DH support
- wolfSSL_d2i_PKCS8_PKEY: Correctly advance buffer
- RSA_LOW_MEM: export all integers in compat layer
- Add softhsm action
- Define
  - OPENSSL_DH_MAX_MODULUS_BITS
  - OPENSSL_DSA_MAX_MODULUS_BITS
  - OPENSSL_RSA_MAX_MODULUS_BITS
- Implement
  - BN_mul_word
  - i2d_ECPKParameters
  - PEM_write_bio_PKCS8_PRIV_KEY_INFO
  - PEM_read_bio_PKCS8_PRIV_KEY_INFO
  - i2d_PKCS8_PRIV_KEY_INFO
  - RSA_padding_add_PKCS1_PSS_mgf1
  - RSA_verify_PKCS1_PSS_mgf1
2024-10-21 17:26:42 +02:00
JacobBarthelmeh 8fda4ce147 use heap hint with wolfSSL_CTX_check_private_key 2024-10-21 08:53:15 -06:00
Daniel Pouzzner 996986d0c1 refactor wc_AesDelete, wc_curve25519_delete, wc_ed25519_delete, wc_HashDelete, and wc_DeleteRsaKey to take two arguments, the first a required pointer to the object, the second an optional pointer to the pointer to be zeroed upon successful deletion, for the benefit of calling from C# without unsafe code.
wrapper/CSharp/wolfSSL_CSharp/wolfCrypt.cs: update for new calling conventions around wc_AesNew, wc_curve25519_new, wc_ed25519_new, wc_HashNew, and wc_NewRsaKey, and the corresponding delete functions.
2024-10-18 21:13:38 -05:00
Daniel Pouzzner f44d12026a wolfssl/wolfcrypt/{aes.h,curve25519.h,ed25519.h,hash.h,rsa.h}: remove unneeded .isAllocated member from struct definitions, and add int *result_code argument to constructor prototypes;
wolfssl/wolfcrypt/aes.h: add Aes.streamData_sz;

src/tls13.c: fix devId passed to wc_HmacInit() in CreateCookieExt() and TlsCheckCookie();

src/keys.c: in SetKeys(), call wc_HmacInit() on hmacs only if newly allocated;

wolfcrypt/src/aes.c:
* in wc_Gmac(), wc_GmacVerify(), and AesSivCipher(), use wc_AesNew() and wc_AesDelete();
* in wc_AesInit(), zero the object on entry, and remove superseded piecemeal initializations to zero;
* in wc_AesFree(), zero aes->streamData, and zero the entire object as final cleanup;

wolfcrypt/src/curve25519.c: in wc_curve25519_free(), zero the entire object rather than zeroing piecemeal;

wolfcrypt/test/test.c:
* add fallback implementations (for old FIPS) of wc_HashNew(), wc_HashDelete(), wc_curve25519_new(), wc_curve25519_delete(), wc_ed25519_new(), and wc_ed25519_delete();
* update constructor calls throughout for new semantics;
* refactor ed25519_test() for proper cleanup and error encoding.
2024-10-18 17:49:28 -05:00
Daniel Pouzzner 984d16b727 refactor wolfcrypt constructors:
add delete APIs, matching recently added wc_AesNew, wc_curve25519_new, wc_ed25519_new, wc_HashNew, and wc_NewRsaKey:
* wc_AesDelete()
* wc_HashDelete()
* wc_DeleteRsaKey()
* wc_curve25519_delete()
* wc_ed25519_delete()

* remove handling in corresponding preexisting free APIs for recently added .isAllocated member -- this restores preexisting semantics;

* add WC_NO_CONSTRUCTORS gate, and auto-activate it when NO_WOLFSSL_MEMORY && WOLFSSL_NO_MALLOC (unless preempted by XMALLOC_USER or XMALLOC_OVERRIDE);

* exclude recently added .isAllocated members from wolfcrypt structs when defined(WC_NO_CONSTRUCTORS);

* adjust wolfcrypt/test/test.c for consistency with the above, and fix cleanup codes/dynamics in several tests.
2024-10-17 18:48:07 -05:00
Daniel Pouzzner 8803f3dd70
Merge pull request #8085 from philljj/fix_coverity
Fix coverity errors
2024-10-16 17:18:31 -05:00
Daniel Pouzzner cc421ddace
Merge pull request #8075 from night1rider/MAX-HW-SHA-FIX
Fixing CB needing HAVE_AES_ECB and SHA struct issue for MAX32666/5 port
2024-10-16 17:17:01 -05:00
Daniel Pouzzner 0c640eb3c5
Merge pull request #8081 from SparkiDev/arm32_thumb2_asm_fix
Thumb2 ASM: indicated by WOLFSSL_ARMASM_THUMB2
2024-10-16 17:00:01 -05:00
Daniel Pouzzner 49ad2d5c46
Merge pull request #8079 from SparkiDev/arm32_asm_regen
ARM32 ASM: regeneration after scripts changes
2024-10-16 16:45:28 -05:00
Daniel Pouzzner 4ed3c00b29
Merge pull request #8078 from SparkiDev/sp_c_cast_and
SP C: cast after and with constant
2024-10-16 16:30:15 -05:00
jordan 554ebc2e9e coverity: fix double free of encryptedContent. 2024-10-16 16:27:44 -05:00
Sean Parkinson 1ce90cc8a5 Thumb2 ASM: indicated by WOLFSSL_ARMASM_THUMB2
Detecting ARM or Thumb2 is not simple so making our own define that will
work: WOLFSSL_ARMASM_THUMB2 to indicate to use Thumb2 assembly code.
2024-10-16 13:56:44 +10:00
gojimmypi a13f48aea0
Update Espressif Examples 2024-10-15 18:36:28 -07:00
Sean Parkinson fb8d2fc42f ARM32 ASM: regeneration after scripts changes
Scripts changed to make generated code not go over 80 characters per
line but SP not updated.
Fix input register formatting in all ARM32 C assembly code.
2024-10-16 10:25:16 +10:00
Sean Parkinson a81aa287a5 SP C: cast after and with constant
Always cast to sp_digit after and with a constant that would convert
value to integer.
2024-10-16 09:48:10 +10:00
Daniel Pouzzner ffc07215a4 clean up wolfcrypt code base for -std=c89 -pedantic: add WC_BITFIELD macro to avoid -Wpedantics for "type of bit-field ... is a GCC extension", with overrideable default definition "byte", and replace parent types of all bitfields with WC_BITFIELD;
fix numerous trailing commas in enums, mostly by removing them, but one (in asn.h, enum Extensions_Sum) using WOLF_ENUM_DUMMY_LAST_ELEMENT();

rearrange bitfields in struct ed25519_key for contiguity;

always define WOLFSSL_SP_NO_DYN_STACK when defined(WOLF_C89).
2024-10-15 18:24:03 -05:00
Daniel Pouzzner 4fd33b6b5d
Merge pull request #8014 from SparkiDev/lms_sha256_192
LMS: SHA-256/192 parameters
2024-10-15 17:24:46 -05:00
Sean Parkinson ae46f52a66 LMS: SHA-256/192 parameters
Add support for parameter sets with SHA-256/192.
2024-10-16 07:15:18 +10:00
philljj 6cde74436e
Merge pull request #8065 from douzzer/20241010-WOLFSSL_NO_MALLOC
20241010-WOLFSSL_NO_MALLOC
2024-10-15 17:03:25 -04:00
night1rider 1449f4f4d7 Fixing CB needing HAVE_AES_ECB and SHA struct issue for MAX3266X Hardware 2024-10-15 14:18:07 -06:00
jordan f5074772da infer: fix more uninitialized value errors. 2024-10-15 12:41:09 -05:00
Daniel Pouzzner 0d5d05d44d more WOLFSSL_NO_MALLOC fixes:
wolfcrypt/src/dh.c: in wc_DhGenerateParams(), use named constant for buf size, and only XFREE it if !WOLFSSL_NO_MALLOC;

wolfcrypt/src/ecc.c and wolfssl/wolfcrypt/ecc.h: in wc_ecc_new_point_ex(), remove !WOLFSSL_NO_MALLOC gate around XMALLOC(), and if XMALLOC()ed, set ecc_point.isAllocated, then in wc_ecc_del_point_ex, XFREE() iff ecc_point.isAllocated;

wolfcrypt/src/pkcs7.c: in wc_PKCS7_RsaVerify(), when WOLFSSL_NO_MALLOC, jumbo-size the digest buffer to cope with in-place dynamics in RsaUnPad();

wolfcrypt/test/test.c: add !WOLFSSL_NO_MALLOC gates around various XFREE()s of objects that are on the stack in WOLFSSL_NO_MALLOC builds;

wolfssl/wolfcrypt/types.h: add an unconditional include of memory.h (itself guarded against multiple inclusion) to assure availability of WC_DEBUG_CIPHER_LIFECYCLE prototypes/macros.
2024-10-14 14:21:29 -05:00
Daniel Pouzzner 0665ff9de7 wolfcrypt/src/asn.c: revert earlier WOLFSSL_NO_MALLOC changes (not needed, after proper gating in test.c). 2024-10-14 14:21:29 -05:00
Daniel Pouzzner 551eb3f44b wolfcrypt/src/ed25519.c and wolfcrypt/src/hash.c: remove gating around isAllocated XFREE()s in wc_ed25519_free() and wc_HashFree(). 2024-10-14 14:21:28 -05:00
Daniel Pouzzner dc2a8118de Revert "Allow compiling aes.c with WOLFSSL_NO_MALLOC"
This reverts commit 56a96ba609.
2024-10-14 14:21:28 -05:00
Daniel Pouzzner ee92f38f88 Revert "fix unused variables"
This reverts commit 06195a2e2a.
2024-10-14 14:21:28 -05:00
Daniel Pouzzner 886ebb6ec0 fixes for enable-all-crypto enable-cryptonly WOLFSSL_NO_MALLOC:
wolfcrypt/src//asn.c: add stack buffer codepaths in ParseKeyUsageStr(), SetKeyIdFromPublicKey(), and EncodePolicyOID;

wolfcrypt/src/dh.c: add stack buffer codepath in wc_DhGenerateParams();

wolfcrypt/src/ecc.c: add always-fail codepath to find_hole() to preempt heap allocation attempts;

wolfcrypt/test/test.c: gate out several heap-dependent subtests when defined(WOLFSSL_NO_MALLOC), and add a stack buffer codepath in ed448_test();

wolfssl/wolfcrypt/types.h: harmonize macro definitions of XFREE() to use do { ... } while (0) wrappers to assure syntactic indivisibility.
2024-10-14 14:21:28 -05:00
Juliusz Sosinowicz 743a78dc85
Merge pull request #8046 from embhorn/zd18758
Clear ctx in wolfSSL_EVP_DigestInit
2024-10-14 14:35:20 +02:00
Daniel Pouzzner caf920100c
Merge pull request #8051 from cconlon/eccOidCacheLock
Add lock around static ECC ecc_oid_cache
2024-10-11 17:34:54 -05:00
Daniel Pouzzner dfd8ead95e
Merge pull request #8050 from philljj/fix_acert_defines
Fix acert defines, add more tests, cleanup.
2024-10-11 16:22:34 -05:00
Sean Parkinson 65742c4a7a ARM32 ASM: regenerated with fixes
Fix thumb interwork def check to be consistent and update #endif.
Remove duplicate check in generated C files.
2024-10-11 09:07:57 +02:00
Sean Parkinson 9c4960f3fa
Merge pull request #8035 from danielinux/armv8-armasm-ARMv7-A
Allow armv8-asm on ARMv7-A with -mthumb-interwork
2024-10-11 09:49:31 +10:00
Chris Conlon 7b805d7a7d Add lock around static ECC ecc_oid_cache 2024-10-09 14:35:14 -06:00
Daniele Lacamera 06195a2e2a fix unused variables 2024-10-09 14:06:38 +02:00
Daniele Lacamera 56a96ba609 Allow compiling aes.c with WOLFSSL_NO_MALLOC 2024-10-09 13:55:42 +02:00
Daniele Lacamera 43574e2255 Allow building with WOLFSSL_NO_MALLOC again 2024-10-09 13:44:03 +02:00
Daniele Lacamera a23d384e06 Improve guards to build with -mthumb-interwork 2024-10-09 12:41:55 +02:00
jordan 052cf77233 acert: fix defines, cleanup, more testing. 2024-10-08 16:11:46 -05:00
David Garske e4f4274b4a Fix AesSivCipher heap hint on cleanup. 2024-10-08 12:11:15 -07:00
David Garske 4753e1c32e Use `byte` for `isAllocated` bit-field. Cleanup some of the "heap" hint logic. 2024-10-08 10:37:45 -07:00
Eric Blankenhorn cd5ddeb1c5 Clear ctx in wolfSSL_EVP_DigestInit 2024-10-07 14:20:50 -05:00
David Garske 59389a0ef5 Fix possible AES leaks detected with sanitizer and clang-tidy. 2024-10-05 11:52:22 -07:00
David Garske dbd3484fdc Fix for issue with `wc_HashAlg` being a union. 2024-10-05 11:44:59 -07:00
David Garske 0bb41e1eb4 Resolve hash new leak due to improper heap hint check. Make sure isAllocated is initialized to 0. 2024-10-05 11:44:58 -07:00
Aidan Garske e10c943bf3 wolfCrypt CSharp Wrapper:
* Adds RNG, ECC(ECIES and ECDHE), RSA, ED25519/Curve25519, AES-GCM, and Hashing to the CSharp wrapper.
* Adds GitHub action for building the CSharp wrapper solution and running wolfCrypt test and a TLS server/client example.
* Adds "new" API's for wolfCrypt for platforms that cannot tolerate the structs directly.
* Fixes for several scan-build warnings.
2024-10-05 11:44:58 -07:00
Daniel Pouzzner e944967731 wolfssl/wolfcrypt/types.h: add WC_NO_STATIC_ASSERT path, and add C89-compatible live fallback definition for wc_static_assert().
wolfssl/internal.h: refactor WOLFSSL_ASSERT_EQ() and WOLFSSL_ASSERT_SIZEOF_GE() to use wc_static_assert(), and drop unused WOLFSSL_ASSERT_TEST() and WOLFSSL_ASSERT_SIZEOF_TEST().

src/ssl_crypto.c and wolfcrypt/src/evp.c: refactor ad hoc asserts in wolfSSL_DES_ecb_encrypt(), wolfSSL_CRYPTO_cts128_decrypt(), and wolfSSL_EVP_DigestInit(), to use wc_static_assert().
2024-10-04 21:11:25 -05:00
Daniel Pouzzner 2e539ef70c
Merge pull request #7983 from philljj/tiny_dilithium_cleanup
dilithium: small cleanup to support wolfboot.
2024-10-03 23:37:11 -05:00
Sean Parkinson f7afc47d98 Kyber ARM32 ASM: add assembly using base instructions
Support ARMv4 up to ARMv8.
Base instructions only - faster implemenation will use NEON.
2024-10-04 11:06:18 +10:00
jordan c3410f2cb8 dilithium: support building dilithium with wolfboot. 2024-10-03 16:38:12 -05:00
David Garske d0d802a2df
Merge pull request #8038 from SparkiDev/sp_math_ppc_li_fix
SP Maths: PowerPC ASM fix
2024-10-03 11:03:31 -07:00
David Garske afe5209427
Merge pull request #7706 from SparkiDev/kyber_thumb2_asm
Kyber ASM ARMv7E-M/ARMv7-M: added assembly code
2024-10-03 10:56:42 -07:00
Sean Parkinson d2047986d9 Kyber ASM ARMv7E-M/ARMv7-M: added assembly code
Improved performance by reworking kyber_ntt, kyber_invtt,
kyber_basemul_mont, kyber_basemul_mont_add, kyber_rej_uniform_c to be
in assembly.
Replace WOLFSSL_SP_NO_UMAAL with WOLFSSL_ARM_ARCH_7M
2024-10-03 18:11:31 +10:00
Sean Parkinson 695914ed33 SP Maths: PowerPC ASM fix
The instruction 'li' is a pseduo instruction for 'load immediate'.
With some compilers, the immediate was interpretted R0[0].
Change to use XOR instead.
2024-10-03 09:00:06 +10:00
Daniel Pouzzner e814d1baea
Merge pull request #8016 from SparkiDev/dilithium_draft_final_fix
Dilithium: Final and draft available in one build
2024-10-02 14:02:00 -05:00
Sean Parkinson 50bbdbbe42 Dilithium: Final and draft available in one build
Make draft version of ML-DSA compiled in with final.
Use WC_ML_DSA_44_DRAFT, WC_ML_DSA_65_DRAFT and WC_ML_DSA_87_DRAFT for
the level to get the draft implementation.
2024-10-02 22:23:25 +10:00
gojimmypi 75a676bc7e
Espressif _thread_local_start and _thread_local_end fix 2024-10-01 03:19:31 -07:00
JacobBarthelmeh ee7f02bbd6
Merge pull request #8004 from SparkiDev/dilithium_fixes_1
Dilithium: fixes
2024-09-30 10:01:16 -06:00
JacobBarthelmeh 113a61c11e
Merge pull request #8025 from douzzer/20240927-fixes2
20240927-fixes2
2024-09-30 09:43:12 -06:00
David Garske 2db2bedd5f
Merge pull request #8027 from SparkiDev/kyber_original_fix
Kyber original: fix to work
2024-09-30 07:58:30 -07:00
David Garske 47add7e9e2
Merge pull request #8020 from SparkiDev/arm32_base_chacha20_poly1305
ARM32 ChaCha20, Poly1305: assembly code
2024-09-30 06:53:37 -07:00
Sean Parkinson bb67069e4a Kyber original: fix to work
Encapsulate the message (hash of rand) for original.
Final of FIPS 203 uses rand.
2024-09-30 22:05:26 +10:00
Sean Parkinson e4301bc554 ARM32 generated files: fix line lengths
Generated ARM32 assembly files no longer have lines with more than 80
characters.
2024-09-30 08:50:31 +10:00
Daniel Pouzzner 60c2499602 wolfssl/wolfcrypt/types.h: when defining fallback do-nothing SAVE_VECTOR_REGISTERS2(), also define SAVE_VECTOR_REGISTERS2_DOES_NOTHING, and likewise for fallback CAN_SAVE_VECTOR_REGISTERS, define CAN_SAVE_VECTOR_REGISTERS_ALWAYS_TRUE;
wolfcrypt/src/aes.c:
* when SAVE_VECTOR_REGISTERS2_DOES_NOTHING, define do-nothing VECTOR_REGISTERS_PUSH and VECTOR_REGISTERS_POP, to mollify Coverity CONSTANT_EXPRESSION_RESULT;
* in AesGcmDecryptUpdate_aesni(), omit " && (c != NULL)" clause from computation of endA argument to AesGcmAadUpdate_aesni(), to mollify Coverity FORWARD_NULL (impermissible nullness is already checked and BAD_FUNC_ARGed by the sole caller, wc_AesGcmDecryptUpdate());

wolfcrypt/src/misc.c: add readUnalignedWord64(), writeUnalignedWord64(), readUnalignedWords64(), and writeUnalignedWords64(), for safe word64 access to possibly-unaligned data;

wolfcrypt/src/wc_kyber_poly.c: use readUnalignedWords64() and readUnalignedWord64() to mitigate sanitizer-reported "load of misaligned address".
2024-09-27 17:15:53 -05:00
JacobBarthelmeh b96e73f9ed
Merge pull request #7936 from gojimmypi/pr-add-espressif-esp-tls-cert-bundle
Add wolfSSL esp-tls and Certificate Bundle Support
2024-09-27 15:22:49 -06:00
Daniel Pouzzner 794f0d8d19 src/pk.c: add missing "keySz = padded_keySz" in _DH_compute_key() ct cleanup path.
wolfcrypt/src/wc_kyber_poly.c: add SAVE_VECTOR_REGISTERS2()...RESTORE_VECTOR_REGISTERS() wrappers for AVX2 implementations.

src/bio.c and src/ssl.c: add several missing WC_NO_ERR_TRACE()s, and tweak several returns to generate error traces.
2024-09-27 00:28:45 -05:00
Colton Willey 3d9a4ccddc Use GetShortInt instead for CRL number extension parsing 2024-09-26 15:43:30 -07:00
David Garske 2285c02f1c
Merge pull request #7998 from SparkiDev/kyber_aarch64_asm
Kyber Aarch64: assembly implementations of functions
2024-09-26 11:59:06 -07:00
Sean Parkinson 2323a5cf59 ARM32 ChaCha20, Poly1305: assembly code
Add assembly code for ChaCha20 and Poly1305 on ARM32 when no NEON
available.
2024-09-26 20:24:58 +10:00
gojimmypi 2a354905cb
Add wolfSSL esp-tls and Certificate Bundle Support, improve esp32_mp RSA 2024-09-25 19:42:21 -07:00
Sean Parkinson de657787cf Kyber Aarch64: assembly implementations of functions
Aarch64 assembly implementation of Kyber functions.
SHA-3 assembly implementations when not hardware crypto.
2024-09-26 09:10:05 +10:00
JacobBarthelmeh 45b88048c2 make macro unique to wolfSSL 2024-09-25 15:59:57 -06:00
JacobBarthelmeh d72c0b372c
Merge pull request #7990 from buchstabenwurst/master
Add support for (DevkitPro)libnds
2024-09-25 15:52:34 -06:00
JacobBarthelmeh 67b0c4d03f
Merge pull request #8009 from philljj/asn_cleanup
asn: cleanup around edPubKeyASN.
2024-09-25 10:09:40 -06:00
Brett Nicholas 7592241a46
Merge pull request #8007 from billphipps/fix_cmac_cryptocb
Update to separate CMAC and AES conditional compiles.  Correct update.
2024-09-25 08:43:27 -06:00
Bill Phipps 60dbe38226
Update cmac.c to eliminate extra spaces 2024-09-24 18:34:19 -04:00
Bill Phipps 13b26bc46b
Update cryptocb.c to fix comment 2024-09-24 18:27:58 -04:00
Brett Nicholas 967dc443fa
remove trailing whitespace 2024-09-24 12:58:01 -06:00
jordan c6124d573a asn: tiny peer review cleanup. 2024-09-24 13:01:13 -05:00
Bill Phipps 8aa63e3aad One more time to quiet clang tidy 2024-09-24 13:43:56 -04:00
Bill Phipps 5e1db686e1 Update logic to avoid clang-tidy warning. 2024-09-24 13:14:00 -04:00
Bill Phipps 35442d27b5 Fixed overlong lines. Thanks clang-tidy 2024-09-24 12:48:54 -04:00
John Safranek 17261467a6 Revert "FP SmallStack Fix"
This reverts commit 47e51400bb.

Turns out we don't want to put those fp_ints on the stack unless
absolutely necessary.
2024-09-24 09:19:43 -07:00
Bill Phipps 0d158fc663 Updates due to peer review 2024-09-24 12:06:19 -04:00
jordan 0f646b6e4b asn: cleanup around edPubKeyASN. 2024-09-23 23:24:36 -05:00
Bill Phipps c16ebaeb47 Update to seperate CMAC and AES conditional compiles. Correct update. 2024-09-23 15:33:52 -04:00
Colton Willey e5022e3ef0 Fix broken endif 2024-09-23 12:11:04 -07:00
Colton Willey 183aef241c CRL improvements, add parsing for CRL number, do not allow CRL duplicates, add callback for when CRL entry is updated. 2024-09-23 11:52:39 -07:00
Sean Parkinson 67528f91b3 Dilithium: fixes
Fixes to hint error dectection.
Fix public key decode to fail when DER length is zero for the public key
data.
2024-09-23 09:05:17 +10:00
Daniel Pouzzner bc6881974d
Merge pull request #8001 from ejohnstown/ecc-test-fix
ECC Test Fix
2024-09-20 20:53:28 -05:00
John Safranek 735c0f6b3a ECC Test Fix
The ECC key generation test was failing due not using large enough of a
buffer. Fixed to use a better size.

1. Set the shared digest/sig buffer size in
   _ecc_pairwise_consistency_test() to the maximum possible based on the
   math in wc_ecc_sig_sz().
2024-09-20 17:25:21 -07:00
David Garske a9cc880f65
Merge pull request #7993 from miyazakh/renesas_rx65n_rsk_update
Update TSIP driver version to v1.21 for RX65N RSK
2024-09-20 17:07:21 -07:00
David Garske 3c67abc664
Merge pull request #7954 from JacobBarthelmeh/pkcs7
add option to set custom SKID with PKCS7 bundle creation
2024-09-20 17:05:44 -07:00
JacobBarthelmeh 554d52b069
Merge pull request #7777 from night1rider/MAX32666-port
MAX32665 and MAX32666 TPU HW and ARM ASM Crypto Callback Support
2024-09-20 17:14:34 -06:00
Hideki Miyazaki 3f0a17b331 Update TSIP driver version to v1.21
Use ASN_TEMPLATE
Extracting YEAR and MONTH from __DATE__
2024-09-21 06:23:59 +09:00
Daniel Pouzzner 55cd8a800f FIPS v5 gating fixes:
configure.ac:
* fix logic in "Forcing off" test expressions, first flubbed in 19106a9510;
* fix auto-enable of compkey to exclude v5 even if v5-dev.

src/tls13.c: fix gating for HKDF _ex() variants (>=6.0, not >=5.3).

wolfcrypt/src/error.c: snip out stray spaces at start of several ECC error message strings.

wolfcrypt/test/test.c:
* in render_error_message(), use wolfSSL_ERR_reason_error_string() if available rather than wc_GetErrorString(), to render non-wolfcrypt error strings;
* in ecc_test_deterministic_k(), ecc384_test_deterministic_k(), ecc521_test_deterministic_k(), on FIPS <6.0, gate out SHA384 and SHA512 tests (FIPS v5 only supports SHA256 in wc_ecc_gen_deterministic_k());
* in cmac_test(), gate use of wc_AesCmacGenerate_ex() and wc_AesCmacVerify_ex() on >=6.0, not >=5.3.
2024-09-20 13:53:36 -05:00
ZackLabPC 9881edfabe Crypto Callback Support for ARM ASM: AES-ECB/CBC, SHA-1/256/384/512 + Fix SP SHA CB Bug 2024-09-20 09:42:53 -06:00
night1rider 1cb324affa Expanding mutexing and Adding in AES Callbacks for HW 2024-09-20 09:42:53 -06:00
night1rider 8f8b4e6665 Addressing Feedback, Adding Null Checks and Mutex Around TRNG 2024-09-20 09:42:53 -06:00
night1rider fe7987f241 Adding SHA-384/512 support, Null Checks, RNG Health Test for HW, and MAA call update for MAX3266X Port. 2024-09-20 09:42:52 -06:00
night1rider d714e55a2b Addressing PR comments typos and cleanup and support HAVE_AES_ECB, Sha1, and Sha224 2024-09-20 09:42:52 -06:00
msi-debian 2e8cf39feb Initial PR for MAX32665 and MAX32666 TPU HW Support 2024-09-20 09:42:52 -06:00
JacobBarthelmeh 8017c816bb check on RNG init return with test, and make input const 2024-09-20 08:34:28 -07:00
JacobBarthelmeh 5adad7d869 fix for sanity check of null input 2024-09-20 08:34:28 -07:00
JacobBarthelmeh ca3b1a1412 add test case 2024-09-20 08:34:28 -07:00
JacobBarthelmeh 7a23cff27f add PKCS7 set custom SKID 2024-09-20 08:34:28 -07:00
JacobBarthelmeh bddb83b62a
Merge pull request #7992 from ejohnstown/ecc-pct-ss
Small Stack ECC Pairwise Consistency Test
2024-09-20 09:13:21 -06:00
András Fekete bbbc40dacc
Merge pull request #7996 from julek-wolfssl/move-mymemmem
memmem is only being used in testing so move it there

Failing test is disabled in: 5be198fa0e
2024-09-20 09:08:44 -04:00
Daniel Pouzzner 212708e3b4 wolfssl/wolfcrypt/ecc.h and wolfcrypt/src/ecc.c: refactor ecc_sets and ecc_sets_count using accessor functions, to fix linker relocation errors in Fedora packaging test. 2024-09-19 17:03:07 -05:00
Juliusz Sosinowicz d7303664b5 memmem is only being used in testing so move it there 2024-09-19 15:54:20 +02:00
John Safranek a81efc0f6f Small Stack ECC Pairwise Consistency Test
1. Update the ECC PCT to use the key's heap to allocate any buffers for
   the test. This is similar to how RSA does it.
2. Put the buffers on the stack if not using small stack option.
2024-09-18 15:14:52 -07:00
Daniel Pouzzner 072c5311a5 m4/ax_atomic.m4: fixes for C++ compatibility.
wolfssl/wolfcrypt/wc_port.h: add WOLFSSL_API attribute to wolfSSL_Atomic_Int_Init, wolfSSL_Atomic_Int_FetchAdd, and wolfSSL_Atomic_Int_FetchAdd, and add fallback definitions for them, allowing elimination of SINGLE_THREADED implementations of wolfSSL_Ref*(), and allowing ungated use of wolfSSL_Atomic_* calls in api.c.

wolfcrypt/src/dh.c: in wc_DhAgree_ct(), remove frivolous XMEMSET() and stray semicolon.

wolfcrypt/benchmark/benchmark.c: fix bench_rsaKeyGen() to skip tests of key sizes below RSA_MIN_SIZE, and add 4096 bit benchmark if RSA_MAX_SIZE is big enough.

tests/unit.h:
* adopt definitions of TEST_FAIL, TEST_SUCCESS, and TEST_SKIPPED from unit.c, remap TEST_SKIPPED from -7777 to 3, and add TEST_SUCCESS_NO_MSGS, TEST_SKIPPED_NO_MSGS, EXPECT_DECLS_NO_MSGS(), and EXPECT_FAILURE_CODEPOINT_ID, to support existing and future expected-particular-failure test cases without log noise.
* rename outer gate from CyaSSL_UNIT_H to TESTS_UNIT_H.

tests/api.c:
* use EXPECT_DECLS_NO_MSGS() in test_ssl_memio_setup(), test_ssl_memio_read_write(), and test_wolfSSL_client_server_nofail_memio(), and globally update affected expected error codes to correspond.
* use atomics for {client,server}SessRemCount{Malloc,free} to fix races in SessRemCtxCb() and SessRemSslSetupCb().
2024-09-18 16:25:26 -05:00
Joshua Okeleke 337456cc1e Add support for (DevkitPro)libnds 2024-09-18 21:27:53 +02:00
JacobBarthelmeh ffd0fb23f7
Merge pull request #7979 from SparkiDev/sp_x86_64_no_avx_fix
SP x86_64 asm: check for AVX2 support
2024-09-18 10:23:12 -06:00
Juliusz Sosinowicz 1e75a2367c Address code review 2024-09-18 10:35:29 +02:00
Juliusz Sosinowicz 8ce6f17144 Add dtls 1.3 cid api test 2024-09-18 10:35:29 +02:00
John Safranek 47e51400bb FP SmallStack Fix
The function _fp_exptmod_nct() is using WOLFSSL_NO_MALLOC to guard
using stack allocation vs malloc. It's twin function _fp_exptmod_ct()
is using WOLFSSL_SMALL_STACK for this. This is causing inappropriate use
of malloc() in a small stack environment. The no-malloc case will also
be kept so static memory and no-malloc fix still works.

1. Change the guards for `#ifndef WOLFSSL_NO_MALLOC` in the function
   `_fp_exptmod_nct()` to `#if defined(WOLFSSL_SMALL_STACK) &&
   !defined(WOLFSSL_NO_MALLOC)`.
2024-09-17 10:55:11 -07:00
Sean Parkinson aa41e09937 SP x86_64 asm: check for AVX2 support
Check for AVX2 as well as BMI2 and ADX.
Some virtual machines may not have AVX2 with the others.
2024-09-17 14:14:27 +10:00
Daniel Pouzzner 04c781ad9b wolfcrypt/src/dh.c: in wc_DhAgree_ct(), implement failsafe constant-time key size fixup, to work around sp-math constant-time key clamping.
also fix a -Wunused in src/ssl_load.c:DataToDerBuffer() teased out by configuration permutations.
2024-09-16 17:33:25 -05:00
Daniel Pouzzner 52030f182b
Merge pull request #7972 from miyazakh/renesas_tsip_update_
Renesas TSIP version update
2024-09-14 00:41:19 -05:00
Daniel Pouzzner 990d38a068
Merge pull request #7974 from dgarske/noasn
Support for NO_ASN when wildcard *.c is used
2024-09-14 00:34:15 -05:00
Daniel Pouzzner 80f3b0d3d8
Merge pull request #7926 from philljj/x509_acert_support
x509 attribute cert support
2024-09-14 00:30:29 -05:00
Daniel Pouzzner 4545a9b4a2
Merge pull request #7960 from night1rider/mmcau-DesEcb
DES ECB using mmcau HW Library, and DES ECB basic test
2024-09-14 00:07:18 -05:00
Daniel Pouzzner 84f0800b96 configure.ac:
* set DEFAULT_ENABLED_ALL_ASM=no if enable_afalg or ENABLED_32BIT;
* omit enable_srtp_kdf from enable-all-crypto if enable_afalg.

linuxkm: add GetCAByAKID to wolfssl_linuxkm_pie_redirect_table.

src/x509.c: in GenerateDNSEntryIPString(), use XMEMSET() to initialize tmpName, not = {0}, to avoid unmaskable compiler emission of memset() call.

wolfssl/openssl/ssl.h: add OPENSSL_EXTRA to an existing OPENSSL_ALL-gated section, consistent with gating of correspinding section in wolfssl/ssl.h.

wolfssl/wolfcrypt/settings.h: adopt setup for WOLFSSL_SP_NO_UMAAL from wolfssl/wolfcrypt/sp_int.h now that it's used by wolfcrypt/src/port/arm/thumb2-poly1305-asm.S.
2024-09-13 18:01:11 -05:00
David Garske 8cea8283db Support for NO_ASN when wildcard *.c is used. Added `STM32H743xx` support. 2024-09-13 13:52:21 -07:00
jordan 7df446bf4e cleanup: fix cast warning, and small cleanup. 2024-09-13 09:26:19 -05:00
jordan 7faed6cded X509 attribute cert (acert) support. 2024-09-13 08:03:55 -05:00
Hideki Miyazaki c49f1e22bd Update TSIP version for RX72N and GR-ROSE
fix readme
2024-09-13 14:12:39 +09:00
Sean Parkinson 4fa20cb770
Merge pull request #7965 from ColtonWilley/pkcs12_use_indef_len
Use context specific for PKCS7 encrypted data encoding
2024-09-13 12:17:08 +10:00
Colton Willey b0ddccc802 Change PKCS7 encrypted content encoding to use ASN_CONTEXT_SPECIFIC 2024-09-12 16:46:35 -07:00
Sean Parkinson 171ab4b13a
Merge pull request #7967 from douzzer/20240910-configure-enable-all-asm-and-sp-cleanup
20240910-configure-enable-all-asm-and-sp-cleanup
2024-09-13 09:18:37 +10:00
Daniel Pouzzner f6d40ad229
Merge pull request #7955 from gojimmypi/pr-espressif-port-updates
Update Espressif sha, util, mem, time helpers
2024-09-12 18:15:25 -05:00
Daniel Pouzzner eb53a95f57 wolfcrypt/src/asn.c:DecodeSingleResponse(): fix gating for "at" working var, by refactoring gating for WOLFSSL_OCSP_PARSE_STATUS sections for clarity. 2024-09-12 14:38:50 -05:00
Daniel Pouzzner 53c4c0095a wolfcrypt/src/sp_cortexm.c: update from scripts#423. 2024-09-12 13:29:02 -05:00
Daniel Pouzzner 8d0047fedf SP: fixes for several bugprone-macro-parentheses and -Wconversions. 2024-09-12 13:29:01 -05:00
Daniel Pouzzner e227b2ad7d wolfcrypt/src/sp_int.c: fix bugprone-too-small-loop-variable in _sp_mul(). 2024-09-12 13:29:01 -05:00
Daniel Pouzzner 5b8e9e692f wolfcrypt/src/siphash.c: fixes for bugprone-macro-parentheses. 2024-09-12 13:29:01 -05:00
David Garske 20e2e33e25
Merge pull request #7939 from SparkiDev/thumb2_poly1305
undefined
2024-09-12 11:15:53 -07:00
Siert Wieringa 9e2a7b3653
Feature/multiple aes siv ads (#7911)
* Proposed new interface for AesSivEncrypt with number of ADs != 1.

* Implement AES SIV S2V computation with a number of ADs not equal to 1.

* Add Example A.1 from RFC5297 to AES SIV test vectors.

* Add tests for new AES SIV interface, and add test vectors for examples given in RFC5297.

* Include the nonce in count of maximum number of ADs.

* Addressing review comments.

* Addressing review comments: Use uppercase 'U' suffix on unsigned constant.

* Rename local variables named 'ad0' to 'ad', since the zero makes no sense, especially since in the RFC 5297 document they're actually counting the ADs from 1.
2024-09-12 07:55:29 -07:00
Sean Parkinson 27033c225f Thumb-2 ChaCha, Poly1305: implemention in assembly
Implementation of ChaCha algorithm for ARM Thumb-2.
Implementation of Poly1305 algorithm for ARM Thumb-2.
2024-09-12 10:59:01 +10:00
Sean Parkinson d23bfd2eb9
Merge pull request #7963 from anhu/p11nopin
Check for PIN before saving it.
2024-09-12 10:20:47 +10:00
Colton Willey 88d1ed7393 Modify pkcs8 pbe encryption to use indefinite length encoding, making it consistent with both old ASN code and openssl 2024-09-11 15:55:05 -07:00
Anthony Hu 246228e410 Check for PIN before saving it. 2024-09-11 14:39:03 -04:00
Sean Parkinson 1c8f1e6921
Merge pull request #7802 from douzzer/20240725-wc_DhAgree_ct
20240725-wc_DhAgree_ct
2024-09-11 08:06:58 +10:00
Sean Parkinson 10c1fa2088
Merge pull request #7931 from barracuda156/powerpc-darwin
Fixes for PowerPC
2024-09-10 10:34:09 +10:00
Sean Parkinson 500a3b41e4
Merge pull request #7932 from barracuda156/dispatch
Fixes for earlier macOS
2024-09-10 10:29:45 +10:00
night1rider e912aff7e5 DES ECB using mmcau HW Library, and DES ECB basic test 2024-09-09 15:32:21 -06:00
Daniel Pouzzner 49a680540c add constant time DH key agreement APIs:
* adds wc_DhAgree_ct().
* adds wolfSSL_DH_compute_key_padded(), using wc_DhAgree_ct() if available, with fallback fixup code.
* adds unit test coverage in api.c:test_wolfSSL_DH() for expected-success calls to wolfSSL_DH_compute_key() and wolfSSL_DH_compute_key_padded().
2024-09-09 16:24:07 -05:00
Daniel Pouzzner c81c9be9ce error code fixes:
* fix TLS layer to consistently use WOLFSSL_FATAL_ERROR for error retvals, rather than literal -1.
* add WC_NO_ERR_TRACE() wrapper around LENGTH_ONLY_E (it does not signify an error condition).
* refactor errcode handling for traceability in wolfSSL_DSA_do_sign(), wolfSSL_DH_size(), wolfSSL_EC_KEY_get_conv_form(), wolfSSL_d2i_DSA_SIG(), wolfSSL_DSA_do_sign(), SetDhInternal(), and wolfSSL_EC_KEY_get_conv_form().
2024-09-06 19:33:48 -05:00
gojimmypi b57fcd0bd8
Update Espressif sha, util, mem, time helpers 2024-09-06 16:33:04 -07:00
David Garske 80a63a3fce
Merge pull request #7924 from anhu/pqm4_purge
Get rid of pqm4 in favour our own Kyber/MLDSA implementation
2024-09-06 12:00:26 -07:00
Sean Parkinson 5f40f9a140 Thumb-2 ChaCha: implemention in assembly
Implementation of ChaCha algorithm for ARM Thumb-2.
2024-09-06 10:16:45 +10:00
Sean Parkinson 96e2c51f07
Merge pull request #7907 from ColtonWilley/rsa_pad_crypto_cb
Add new crypto callback for RSA with padding.
2024-09-06 08:48:36 +10:00
Sean Parkinson 6fc9dcae07
Merge pull request #7947 from douzzer/20240905-mp_sign_t
20240905-mp_sign_t
2024-09-06 08:46:23 +10:00
Daniel Pouzzner dcaff9dff4
Merge pull request #7944 from JacobBarthelmeh/pkcs12
add parsing over optional PKCS8 attributes
2024-09-05 16:55:44 -05:00
David Garske 887c5abcb1
Merge pull request #7949 from douzzer/20240905-whitespace-and-utf8-cleanup
20240905-whitespace-and-utf8-cleanup
2024-09-05 14:38:19 -07:00
Daniel Pouzzner 9f6a75cdfd
Merge pull request #7934 from rizlik/ocsp-get-ca-keyhash-fix
ocsp: search CA by key hash instead of ext key id
2024-09-05 15:03:54 -05:00
Daniel Pouzzner a3fb5029f8 clean up trailing whitespace and misplaced CRLFs, add missing final newlines, remove stray UTF8 nonprintables (BOMs) and ASCIIfy stray homoglyphs (spaces and apostrophes), guided by expanded coverage in wolfssl-multi-test check-source-text. 2024-09-05 14:52:18 -05:00
Daniel Pouzzner 603c03c0be MPI: add mp_sign_t and sp_sign_t. 2024-09-05 10:37:02 -05:00
JacobBarthelmeh 9a8573afc9 touch up pkcs8 create function and test case warning 2024-09-04 15:48:44 -06:00
JacobBarthelmeh 2a1165460e add parsing over optional PKCS8 attributes 2024-09-04 15:15:53 -06:00
Daniel Pouzzner a31733db85
Merge pull request #7909 from SparkiDev/dilithium_fips204_draft
Dilithium: Support FIPS 204 Draft
2024-09-04 14:34:59 -05:00
Daniel Pouzzner c9ff15da21
Merge pull request #7901 from SparkiDev/memusage_8
Memory usage improvements
2024-09-04 12:34:44 -05:00
David Garske 7c7de235d8
Merge pull request #7937 from douzzer/20240903-missing-WC_NO_ERR_TRACEs
20240903-missing-WC_NO_ERR_TRACEs
2024-09-04 08:07:19 -07:00
Sean Parkinson 88c3e0af22 Memory usage improvements
kdf.c: wc_PRF() - No need for previous, reuse current.
sha256.c: Transform_Sha256() - Add slow but small version for many
register implementation.
sp_int.h: Change 'used' and 'size' fields to 16-bit types when possible.
sp_int.c: Fixes for 16-bit used.
2024-09-04 22:51:31 +10:00
Daniel Pouzzner b26fa6cf59
Merge pull request #7918 from SparkiDev/type_conversion_fixes_3
Type conversion fixes
2024-09-03 20:18:00 -05:00
Daniel Pouzzner 121b8c52f8
Merge pull request #7869 from julek-wolfssl/libspdm-x509
libspdm x509 parts
2024-09-03 20:09:31 -05:00
Daniel Pouzzner 806df85477 backfill more missing WC_NO_ERR_TRACE()s on error code operands, and refactor away the obsolete GEN_MEM_ERR macro mechanism in wolfcrypt/src/ecc.c. 2024-09-03 17:44:11 -05:00
David Garske b7a6c6c314 Fixes for building RISCV ASM with enable-all.
* Fix type warning for SHA512 ByteReverseWords call
* Fix issue with riscv-asm and xchacha.
2024-09-03 09:37:01 -07:00
Marco Oliverio 293719c168 ocsp: search CA by key hash instead of ext key id 2024-09-02 15:25:53 +00:00
Sean Parkinson ed7beb4e0e Type conversion fixes
Changes to get compilation with -Wconversion passing on the files.
2024-09-02 19:19:23 +10:00
Juliusz Sosinowicz 2c9a3c5c1c Missing libspdm features
- RsaFunctionPrivate: detect when only n,e,d are available
- wolfSSL_EVP_add_digest: return success
- wolfSSL_EVP_add_cipher: return success
- wolfSSL_BN_bin2bn: accept NULL data if len is 0 (checked in mp_read_unsigned_bin)
- wolfssl_read_bio: advance correct bio
- wolfSSL_X509_set_ext: return raw extension data for BASIC_CA_OID
- Implement
  - sk_X509_EXTENSION_free
  - d2i_EC_PUBKEY_bio
  - d2i_RSA_PUBKEY_bio
  - d2i_X509_REQ_INFO
  - X509_REQ_INFO_free
  - ASN1_TIME_set_string_X509
2024-09-02 10:01:12 +02:00
Sergey Fedorov 2ddfe15c4f Fix libdispatch usage condition 2024-09-01 21:03:18 +08:00
Sergey Fedorov ef2424336c sp_int.c: fix ppc asm for macOS 2024-09-01 20:17:11 +08:00