Commit Graph

19590 Commits

Author SHA1 Message Date
Daniel Pouzzner
358af4ef05 fix for cppcheck/zerodivcond in wolfcrypt/src/pkcs7.c:wc_PKCS7_DecodeAuthEnvelopedData();
fixes for clang-tidy/bugprone-macro-parentheses in wolfssl/wolfcrypt/sp_int.{c,h} and wolfcrypt/src/ecc.c;

fix for clang-analyzer-deadcode.DeadStores in olfcrypt/src/asn.c.
2023-04-13 14:51:29 -05:00
David Garske
419a1f0a01 Merge pull request #6294 from douzzer/20230412-WC_ASN_NAME_MAX-bump-for-MULTI_ATTRIB
20230412-WC_ASN_NAME_MAX-bump-for-MULTI_ATTRIB
2023-04-12 16:21:33 -07:00
JacobBarthelmeh
441b78e5a2 Merge pull request #6284 from douzzer/20230410-Wconversion-fixes
20230410-Wconversion-fixes
2023-04-12 17:07:24 -06:00
JacobBarthelmeh
d4b92cb65c Merge pull request #6295 from dgarske/stm32_20230412
Fixes for STM32 U5/H5/H7 hash and PKA sign build error
2023-04-12 16:36:43 -06:00
Daniel Pouzzner
c41030663e wolfcrypt/src/pkcs7.c: correct fix for clang-analyzer-core.DivideZero in wc_PKCS7_DecodeAuthEnvelopedData(). 2023-04-12 16:37:20 -05:00
David Garske
b7ff375ac6 Fix PKA build error with SP sign. Fix U5/H5/H7 hashing, which require a workaround to write an extra 32-bit to flush FIFO before save/restore. 2023-04-12 13:45:29 -07:00
David Garske
e1ca478356 Added STM32G0 benchmarks. 2023-04-12 13:45:28 -07:00
JacobBarthelmeh
2c26b068b2 Merge pull request #6239 from dgarske/stm32h5
Support for STM32H5
2023-04-12 14:33:25 -06:00
Daniel Pouzzner
97ffdfa9b8 wolfssl/wolfcrypt/asn.h: if defined(WOLFSSL_MULTI_ATTRIB), bump predefined WC_ASN_NAME_MAX, to fix rsa_certgen_test() with config --enable-testcert --enable-asn=original CPPFLAGS='-DWOLFSSL_CERT_GEN -DWOLFSSL_MULTI_ATTRIB'. 2023-04-12 13:48:03 -05:00
Daniel Pouzzner
4b59588cf3 more fixes for implicit casts, mostly asn=original. 2023-04-12 02:17:18 -05:00
Daniel Pouzzner
fe2acb53af wolfcrypt/src/ecc.c:fix overstringent arg check in wc_ecc_gen_k(). 2023-04-12 01:37:09 -05:00
Daniel Pouzzner
7155c5748e fix overlong lines. 2023-04-12 01:37:09 -05:00
Daniel Pouzzner
99ffd7726f wolfcrypt/src/pkcs7.c:wc_PKCS7_DecodeAuthEnvelopedData(): fix clang-analyzer-core.DivideZero (expBlockSz not properly set before use as a denominator in a mod op). 2023-04-12 01:37:09 -05:00
Daniel Pouzzner
bd8f97f315 Revert "Resolve issue with C89 compliance with "commas at the end of enumerator lists"."
This reverts commit 68acfd51dca1e0e11e2e7bd0e6ab956b8def6473.
2023-04-12 01:37:09 -05:00
Daniel Pouzzner
41818bf6f8 Revert "Fix enum KeyWrap_Sum impossible combinations (note: ugly code)."
This reverts commit 2bac48a290e5243337f661c70eb582e55ceb2c39.
2023-04-12 01:37:09 -05:00
Daniel Pouzzner
ed11669f3c more fixes for implicit casts, including asn=template. 2023-04-12 01:37:09 -05:00
David Garske
ee50d95b0b Fix enum KeyWrap_Sum impossible combinations (note: ugly code). 2023-04-12 01:37:09 -05:00
David Garske
72c6429276 Better fixes for pedantic to resolve (error: comparison of unsigned expression >= 0 is always true). Also overlong lines. 2023-04-12 01:37:09 -05:00
David Garske
f3eee4bc99 Resolve issue with C89 compliance with "commas at the end of enumerator lists".
Tested with `./configure --disable-asm --enable-32bit --enable-asn --enable-cryptonly CFLAGS="-Wall -ansi -pedantic-errors -Wshadow -g" && make`
2023-04-12 01:37:09 -05:00
David Garske
6418e3cbfe Fixes for implicit casts.
Tested with `./configure --disable-asm --enable-32bit --enable-asn=original --enable-cryptonly CFLAGS="-Wconversion -pedantic" && make`. Some progress with ASN template, but not complete.
2023-04-12 01:37:09 -05:00
JacobBarthelmeh
6a89464176 Merge pull request #6231 from billphipps/15785-CorrectFreeDuringEarlyConnectFail
Track SetDigest usage to avoid invalid free under error conditions.
2023-04-11 09:49:51 -06:00
billphipps
0013be9027 15451 correct padding for pkcs7 (#6260)
* Update to ensure full blocks for crypto in En/DecodeAuthEnvelopedData.

* Corrected spacing and comments

* Set plain to NULL after free on non-error path.
2023-04-10 14:08:52 -07:00
David Garske
f2ae066797 Merge pull request #6281 from JacobBarthelmeh/ECC
- fix ECC performance regression
2023-04-10 14:08:43 -07:00
JacobBarthelmeh
8bb0b2ef3f fix for ECC sign with nonblocking only 2023-04-10 12:53:40 -07:00
David Garske
6b862a1440 Merge pull request #6272 from gojimmypi/wolfcrypt-mpi-fix
mp_setneg(Z), not mpi
2023-04-10 11:58:04 -07:00
Bill Phipps
2430f2377f Corrected spacing and comments 2023-04-10 17:15:22 +00:00
Jacob Barthelmeh
582d8a70f5 fix ECC performance regression 2023-04-09 00:08:01 -06:00
JacobBarthelmeh
12e285434b Merge pull request #6275 from douzzer/20230406-XREWIND-fixes-contd
20230406-XREWIND-fixes-contd
2023-04-06 15:22:48 -06:00
Daniel Pouzzner
7c15131db5 wolfcrypt/src/asn.c: in wc_PemCertToDer_ex() and wc_PemPubKeyToDer_ex(), work around false positive -Wmaybe-uninitialized from scan-build. 2023-04-06 15:15:26 -05:00
JacobBarthelmeh
012f0e0779 Merge pull request #6262 from SparkiDev/mp_int_mem_usage
SP int: improve use of stack
2023-04-06 14:06:08 -06:00
Daniel Pouzzner
3468750bae wolfcrypt/src/asn.c:
* refactor error-checking cascade in wc_PemCertToDer_ex() as in wc_PemPubKeyToDer_ex(),
 * refactor staticBuffer gating/dynamics in wc_PemPubKeyToDer_ex() as in wc_PemCertToDer_ex(),
 * and use IO_FAILED_E, not BUFFER_E, for I/O errors on the file handles, in both routines;

fix smallstack null pointer dereferences in src/pk.c:wolfSSL_RSA_GenAdd() and src/ssl.c:set_curves_list().
2023-04-06 14:31:53 -05:00
Chris Conlon
bd02b9c29c Merge pull request #6254 from miyazakh/fix_favouriteDrink 2023-04-06 09:39:23 -06:00
Sean Parkinson
67624628c2 Merge pull request #6274 from douzzer/20230405-fixes
20230405-fixes
2023-04-06 14:27:37 +10:00
Daniel Pouzzner
dcc8b5d7d5 eliminate XREWIND() macro, add XSEEK_SET definitions, and refactor all XREWIND()s to XFSEEK()s, to fix clang-tidy-17 bugprone-unsafe-functions warning on rewind();
add BENCH_DEVID_COLUMN_HEADER in wolfcrypt/benchmark/benchmark.c:bench_stats_sym_finish() to resolve clang-diagnostic-embedded-directive.
2023-04-05 20:28:51 -05:00
Sean Parkinson
8065139050 SP int: improve use of stack
Minimize use of stack.
Make very large stack allocations dynamic memory allocations unless
WOLFSSL_SP_NO_MALLOC.

ProcessBufferTryDecode() split up into a function for each type.
ProcessBufferTryDecodeRsa() decodes the data and gets key size rather
than having or allocating an RsaKey.
Added wc_RsaPrivateKeyValidate() that only validates the encoding is an
RSA key and returns the key size in bytes.

For SP int, only create sp_ints of required size in RSA and ECC
implementation. For WOLFSSL_SMALL_STACK, memory is allocated to have
just enough bytes and size is set to maximum supported. Otherwise,
relies on dynamic stack variables.
For ECC, MAX_ECC_BITS_USE used when dynamic stack variables not
supported. Significantly reduces memory usage when RSA/DH is also built.

Add macros to sp_int.h, tfm.h and integer.h to support declaring,
allocating, initializing and freeing mp_ints.
For integer.h, mp_int is always static as size is no more than 32 bytes.
For tfm.h, WOLFSSL_SMALL_STACK has a full mp_int allocated, otherwise
the full mp_int is put on the stack.
For sp_int.h  with new macros, dynamically allocate sp_int to minimal
size when WOLFSSL_SMALL_STACK, or when dynamic stack variables, declare
them to be of minimal size or otherwise declare with a fixed max.
Added mp_bitsused(), for all implementations, to get the number of bits
available based on used. Included for RSA to get the size of the
modulus.

SP int now always uses dynamic stack variables if possible rather than
for builds with WOLFSSL_SP_SMALL.
Moved code out into separate functions so that stack allocations don't
happen when not going down code path.
2023-04-06 10:04:39 +10:00
JacobBarthelmeh
8c0a20fc32 Merge pull request #6212 from embhorn/gh6211
RIOT-OS does support writev
2023-04-05 15:26:07 -06:00
JacobBarthelmeh
caf2749c8a Merge pull request #6269 from julek-wolfssl/fix-test_wolfSSL_CTX_add_session
Fix intermittent failures in test_wolfSSL_CTX_add_session
2023-04-05 15:19:36 -06:00
JacobBarthelmeh
1bef3ec745 Merge pull request #6233 from embhorn/gh6209
Support HAVE_SESSION_TICKET without realloc
2023-04-05 15:17:58 -06:00
JacobBarthelmeh
3c90eb25c8 Merge pull request #6271 from anhu/XSTAT
Allow user to override XSTAT
2023-04-05 14:44:09 -06:00
JacobBarthelmeh
9c368d0a0e Merge pull request #6273 from anhu/wolfSSL_get_chain_cert
Documentation fixup for wolfSSL_get_chain_cert();
2023-04-05 14:33:29 -06:00
billphipps
599cf9356f Merge branch 'wolfSSL:master' into 15785-CorrectFreeDuringEarlyConnectFail 2023-04-05 15:24:30 -04:00
Anthony Hu
3e58e47856 Documentation fixup for wolfSSL_get_chain_cert(); 2023-04-05 15:12:43 -04:00
Daniel Pouzzner
cf173e7b7d Merge pull request #6270 from julek-wolfssl/fix-test_wolfSSL_dtls_stateless_HashWOLFSSL
Ignore staticBuffer in test_wolfSSL_dtls_stateless_HashWOLFSSL
2023-04-05 12:53:11 -05:00
Eric Blankenhorn
d9bf93b49f Support HAVE_SESSION_TICKET without realloc 2023-04-05 11:33:06 -05:00
András Fekete
3b934b858e Merge pull request #6268 from SparkiDev/asn1_test_0_len
ASN.1 testing: restore 0 length BIO failure tests
2023-04-05 11:14:50 -04:00
gojimmypi
bb32b6a927 mp_setneg(Z), not mpi 2023-04-05 17:10:37 +02:00
JacobBarthelmeh
6a52c727f6 Merge pull request #6267 from SparkiDev/openssl_cryptonly
OpenSSL API and cryptonly: fix to compile
2023-04-05 09:08:32 -06:00
Anthony Hu
c9e467b734 Allow user to override XSTAT 2023-04-05 10:39:16 -04:00
Juliusz Sosinowicz
c5f03e43cf Ignore staticBuffer in test_wolfSSL_dtls_stateless_HashWOLFSSL 2023-04-05 14:23:19 +02:00
Juliusz Sosinowicz
a51daf1bfa Fix intermittent failures in test_wolfSSL_CTX_add_session 2023-04-05 13:57:10 +02:00