7340 Commits

Author SHA1 Message Date
Daniel Pouzzner
4180a650c8 fix clang-analyzer-deadcode.DeadStores in wolfcrypt/src/asn.c:SetOthername(). 2023-04-18 14:27:52 -05:00
Daniel Pouzzner
a4aef0e55d refinements from peer review for #6303. 2023-04-18 12:23:24 -05:00
Daniel Pouzzner
193919a276 add wc_strcasecmp() and wc_strncasecmp() to wc_port.c, and set up (USE_WOLF_STR[N]CASECMP) in types.h for targets lacking native implementations (including WOLF_C89);
define USE_WOLF_STRSEP if defined(WOLF_C89).
2023-04-18 12:23:24 -05:00
Daniel Pouzzner
4b9302cdb3 another batch of -Wconversion fixes. 2023-04-18 12:23:24 -05:00
gojimmypi
98b718f91b
wolfcrypt polish: init, checks, corrections (#6249)
* wolfcrypt polish: init, checks, corrections
2023-04-18 09:41:42 -07:00
jordan
8254112c9b Fix out-of-bounds write in fp_mod_2d. 2023-04-18 10:51:38 -05:00
JacobBarthelmeh
ff13a7cdc8
Merge pull request #6250 from julek-wolfssl/fix-wolfSSL_DES_ede3_cbc_encrypt
Write next IV in wolfSSL_DES_ede3_cbc_encrypt
2023-04-18 09:33:10 -06:00
Sean Parkinson
59c113d358 SP int: sp_mod check sp_div error before adding and replacing error
Fix to not overwrite error when sp_div fails in sp_mod.
2023-04-18 09:38:13 +10:00
Sean Parkinson
eddcf0c0ee ECC, ASN.1: DecodeECC_DSA_Sig didn't handle r and s being initialized
New creation of mp_ints r and s to be minimal size must not be
re-initialized.
Changes to ASN.1 code to handle r and s being initialized and to not
initialize again.
2023-04-18 09:37:23 +10:00
Sean Parkinson
04ae676629 ECC: wc_ecc_is_point - validate parameters
Public API wc_ecc_is_point() needs to validate the parameters.
Ensure that the x and y are in range [0, p-1] and z is one (affine
ordinates).

Made the API a wrapper around existing calculation code.
When x-ordinate is a large negative, then it will spend large amounts of
time adding the prime to a large negative intermediate value.
2023-04-18 09:35:22 +10:00
Anthony Hu
120d1f0d1a Support in the compatibility layer for UPN and SID. 2023-04-17 14:42:27 -04:00
Daniel Pouzzner
1bed740710 address peer review: make C89-compatible refactors in sakke_pairing() and sakke_modexp_loop(); add explanatory comment for WOLF_ENUM_DUMMY_LAST_ELEMENT() in types.h. 2023-04-14 15:07:05 -05:00
Daniel Pouzzner
ac85cfa3d5 fix "comma at end of enumerator list" warnings in wolfcrypt for C89 compatibility, mostly by just snipping out unneeded comma, but several using WOLF_ENUM_DUMMY_LAST_ELEMENT() to preserve gated enum values as-is. 2023-04-14 13:48:03 -05:00
Daniel Pouzzner
d5588af0a2 wolfcrypt/src/sakke.c: fixes for C89 "initializer element is not computable at load time". 2023-04-14 13:29:26 -05:00
Daniel Pouzzner
105714460c wolfcrypt/src/fe_448.c: fix declaration-after-statement in fe448_mul_8(). 2023-04-14 13:29:26 -05:00
Daniel Pouzzner
edf95dbcbd add WOLF_C89 clauses to the W64LIT() definitions in wolfssl/wolfcrypt/types.h, and wrap several long long numeric literals with W64LIT() in wolfcrypt/src/{aes.c,blake2b.c,siphash.c};
add WOLF_C89 handling to SP_ULONG_BITS and SP_ULLONG_BITS setup in wolfssl/wolfcrypt/sp_int.h.
2023-04-14 13:29:26 -05:00
JacobBarthelmeh
00aa061d77
Merge pull request #6300 from douzzer/20230413-fixes
20230413-fixes
2023-04-13 15:41:51 -06:00
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
JacobBarthelmeh
9a0934161d fix for wpas build with x509 small 2023-04-13 10:38:12 -07:00
JacobBarthelmeh
441b78e5a2
Merge pull request #6284 from douzzer/20230410-Wconversion-fixes
20230410-Wconversion-fixes
2023-04-12 17:07:24 -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
JacobBarthelmeh
2c26b068b2
Merge pull request #6239 from dgarske/stm32h5
Support for STM32H5
2023-04-12 14:33:25 -06: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
ed11669f3c more fixes for implicit casts, including asn=template. 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
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
edad8d1da8 avoid callback buffer overwrite with sha512_224 and remove min from wolfcaam_cmac 2023-04-11 09:06:39 -07: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
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
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
1bef3ec745
Merge pull request #6233 from embhorn/gh6209
Support HAVE_SESSION_TICKET without realloc
2023-04-05 15:17:58 -06:00
Eric Blankenhorn
d9bf93b49f Support HAVE_SESSION_TICKET without realloc 2023-04-05 11:33:06 -05:00
gojimmypi
bb32b6a927 mp_setneg(Z), not mpi 2023-04-05 17:10:37 +02:00
Juliusz Sosinowicz
171c217ae5 Add in-place support for DES_ede3_cbc_encrypt 2023-04-05 15:50:51 +02:00
Sean Parkinson
10c1009bbd
Merge pull request #6127 from JacobBarthelmeh/qnx
IMX6Q CAAM Port
2023-04-05 08:44:00 +10:00
David Garske
a4a6a05f06
Merge pull request #6251 from PrinceOfPuppers/master
updated zephyr includes
2023-04-03 16:25:32 -07:00
JacobBarthelmeh
f9f1347e8d third optimization pass with aes-ctr 2023-04-03 16:41:09 -06:00
JacobBarthelmeh
14b0f422c8 optimization pass through 2 2023-04-03 16:41:08 -06:00