16317 Commits

Author SHA1 Message Date
Daniel Pouzzner
74408e3ee3 fixes for whitespace, C++ warnings, and LLVM 15 clang-tidy defects/carps:
* whitespace in src/ssl.c, tests/api.c, wolfssl/openssl/fips_rand.h.

* clang-analyzer-core.StackAddressEscape from llvm-15 clang-tidy, in tests/suites.c:execute_test_case().

* bugprone-suspicious-memory-comparison from llvm-15 clang-tidy, in src/internal.c:DoSessionTicket() and src/ssl.c:wolfSSL_sk_push().
2022-02-08 15:20:22 -06:00
David Garske
ed1fc9fc51
Merge pull request #4833 from SparkiDev/sha3_arm_crypto
SHA-3, ARM64: add assembly support for crypto instructions
2022-02-08 11:05:35 -08:00
Daniel Pouzzner
3ee6e93590
Merge pull request #4838 from SparkiDev/g++_fix_4
Rework functions to avoid warning with g++
2022-02-08 10:20:58 -06:00
Daniel Pouzzner
1f69c52ce8
Merge pull request #4830 from dgarske/no_hmac
Fixes for building without HMAC
2022-02-07 22:26:38 -06:00
Sean Parkinson
d2307186d9 Rework functions to avoid warning with g++ 2022-02-08 12:36:36 +10:00
Sean Parkinson
0042a2594c SHA-3, ARM64: add assembly support for crypto instructions
Add ability to compile ARM assembly from inline C code.
2022-02-08 12:21:38 +10:00
David Garske
d0246a280d
Merge pull request #4834 from anhu/guard_wc_PKCS7_SetPassword
Fix tests to properly gate on ! NO_PWDBASED && ! NO_SHA
2022-02-07 15:12:22 -08:00
David Garske
56c562a516 Fixes for building with ./configure --enable-opensslextra --enable-cryptonly CFLAGS="-DNO_HMAC" && make. Found this testing a customers configuration with latest. Also fixes some trailing whitespace. 2022-02-07 15:10:21 -08:00
David Garske
d085984103
Merge pull request #4829 from kosmas-valianos/kTLS
Expose Sequence Numbers so that Linux TLS (kTLS) can be configured
2022-02-07 14:55:07 -08:00
Anthony Hu
e47dd675af Fix tests to properly gate on ! NO_PWDBASED && ! NO_SHA 2022-02-07 14:44:26 -05:00
David Garske
dd2e0064b2
Merge pull request #4827 from SparkiDev/sp_int_dw_asm
SP math, Aarch64, ARM32: div word asm fixup
2022-02-07 11:32:14 -08:00
David Garske
54e7db0a9a
Merge pull request #4739 from rizlik/psa
support Platform Security Architecture (PSA) API
2022-02-07 10:40:21 -08:00
Chris Conlon
4c8f0709fc
Merge pull request #4720 from dgarske/fips_compat 2022-02-07 09:56:24 -07:00
David Garske
3d85a9690f
Merge pull request #4819 from lealem47/hashMismatch
Fix for OpenSSL x509_NAME_hash mismatch
2022-02-07 08:08:49 -08:00
Kosmas Valianos
30b35acd39
Expose Sequence Numbers so that Linux TLS (kTLS) can be configured 2022-02-07 09:30:59 +01:00
Sean Parkinson
f6d79ff598
Merge pull request #4813 from dgarske/zd13571
Fix for mutual authentication to prevent mismatch of certificate and sigalgo
2022-02-07 11:00:04 +10:00
Lealem Amedie
f9ff551992 Fix for OpenSSL x509_NAME_hash mismatch 2022-02-04 16:59:51 -08:00
David Garske
1f8ff7d9fe
Merge pull request #4822 from embhorn/zd13613
Fix warnings in VS
2022-02-04 15:37:31 -08:00
Marco Oliverio
2077184953 psa: add compile-time error if builded with crypto cb 2022-02-04 21:45:38 +01:00
Marco Oliverio
b8635efda7 psa: add README.md and doxygen header 2022-02-04 21:45:38 +01:00
Marco Oliverio
0cb2cc1705 psa: support pk callbacks for ECDSA, ECDH, HKDF 2022-02-04 21:45:38 +01:00
Marco Oliverio
630b244cee psa: introduce global lock 2022-02-04 21:45:38 +01:00
Marco Oliverio
a7165907da psa: support AES 2022-02-04 21:45:38 +01:00
Marco Oliverio
9ccfc81f26 psa: support PSA SHA1/SHA256/SHA224 2022-02-04 21:45:38 +01:00
Marco Oliverio
06915b6fa3 psa: support PSA random generator 2022-02-04 21:45:38 +01:00
David Garske
08047b2d95 Add checking to make sure key is present in all cases. Explicitly set validSigAlgo to zero with comment to clarify the default assumption. 2022-02-04 11:47:06 -08:00
David Garske
2d184348fb
Merge pull request #4825 from embhorn/gh4815
Fix wolfSSL_PEM_X509_INFO_read with NO_FILESYSTEM
2022-02-04 10:42:40 -08:00
David Garske
327e35fc25
Merge pull request #4826 from haydenroche5/evp_aes_gcm_iv_bug
Fix IV length bug in EVP AES-GCM code.
2022-02-04 10:38:02 -08:00
Hayden Roche
d1ca8fc673
Merge pull request #4821 from elms/cmake/help_cleanup 2022-02-04 09:37:39 -08:00
Marco Oliverio
08fbcf5eae autoconf: add PSA options 2022-02-04 12:12:04 +01:00
Sean Parkinson
bd1b58dd7f SP math, Aarch64, ARM32: div word asm fixup
ASM code is dividing by top half of divisor. If this value is very small
then bad results are calculated.
Moved the divisor up by a quarter of the width if top quarter of divisor
is 0.
2022-02-04 11:59:31 +10:00
Hayden Roche
b850cc89b0 Fix IV length bug in EVP AES-GCM code.
In `wolfSSL_EVP_CipherInit`, `ctx`'s `ivSz` field isn't being accounted for.
A common OpenSSL EVP AES-GCM flow looks like this:

- `EVP_CIPHER_CTX_new`
- `EVP_EncryptInit_ex`
- `EVP_CIPHER_CTX_ctrl` with command `EVP_CTRL_GCM_SET_IVLEN` to set the IV
length to 16 (AES block size) instead of the default 12
- `EVP_EncryptInit_ex` again to set the key and IV
- `EVP_EncryptUpdate` however many times
- `EVP_EncryptFinal`

In fact, we test this flow in our unit test `test_wolfssl_EVP_aes_gcm`. However,
in our implementation, the second call to `EVP_EncryptInit_ex` unconditionally
resets the IV length back to 12. This doesn't cause a test failure because
decryption has the same problem, so both sides of the equation have the same
wrong view of the IV.

The solution is to preserve the IV length in wolfSSL_EVP_CipherInit if ctx->ivSz
is non-zero. Otherwise, use the default of 12 (`GCM_NONCE_MID_SZ`).

This was discovered by a user migrating to the compatibility layer. As I
mentioned, it isn't exposed by our testing. It is exposed if you try to use the
same key and IV with OpenSSL and compare the resulting ciphertext with wolfSSL.
They won't be the same and thus won't interoperate.
2022-02-03 17:40:26 -08:00
Eric Blankenhorn
a0444bf72f Fix wolfSSL_PEM_X509_INFO_read with NO_FILESYSTEM 2022-02-03 16:52:08 -06:00
Eric Blankenhorn
7b2e457d04 Fix VS unreachable code warning 2022-02-03 15:53:35 -06:00
David Garske
53e64b55e1
Merge pull request #4823 from haydenroche5/alpn_bug
Fix bug in TLSX_ALPN_ParseAndSet when using ALPN select callback.
2022-02-03 13:16:13 -08:00
Hayden Roche
fab2e99bff Fix bug in TLSX_ALPN_ParseAndSet when using ALPN select callback.
At the start of this function, it attempts to find an ALPN extension in the
ssl object's extensions with `TLSX_Find`. If an ALPN select callback has been
set (i.e. via `wolfSSL_CTX_set_alpn_select_cb`), that gets called next. If that
callback finds a match, it removes all existing ALPN extensions found in the
ssl object. It then uses the new protocol name like this:

```
if (TLSX_UseALPN(&ssl->extensions, (char*)out, outLen, 0, ssl->heap)
                                                           == WOLFSSL_SUCCESS) {
    if (extension == NULL) {
        extension = TLSX_Find(ssl->extensions,
                              TLSX_APPLICATION_LAYER_PROTOCOL);
    }
}
```

The bug is exposed if `extension` is not NULL, i.e. it was found on that initial
`TLSX_Find` call. `extension` is not NULL but it now points to garbage because
all the old ALPN extensions were just removed. It won't have it's value assigned
to the new extension that just got pushed via `TLSX_UseALPN` because of this
NULL check. This results in a segfault later in the function.

The solution is to remove the NULL check and always update `extension` after the
`TLSX_UseALPN` call.

This bug was discovered by a customer when using nginx + wolfSSL. I was able to
reproduce locally with curl acting as the client
2022-02-03 09:36:18 -08:00
Eric Blankenhorn
f0b953ce0c Fix warnings in VS 2022-02-03 07:19:43 -06:00
Elms
fab8eca2fd cmake: Check for valid voerride values
Also remove trailing whitespace
2022-02-02 16:32:00 -08:00
Elms
9b4289c751 cmake: Add KEYGEN option. Cleanup help messages.
Add `WOLFSSL_KEYGEN` option and override enable when `WOLFTPM` is
enabled

Also major reduction of variables for help messages. Override only
updates `VALUE`
2022-02-02 16:15:47 -08:00
David Garske
d3e3f57b77
Merge pull request #4818 from julek-wolfssl/guido-13454
`object` and `value` need to be `free`'ed
2022-02-02 16:04:39 -08:00
David Garske
17eee2ba0c
Merge pull request #4817 from julek-wolfssl/ZD13495
ZD13495
2022-02-02 15:54:08 -08:00
Juliusz Sosinowicz
97dd974a94 object and value need to be free'ed 2022-02-02 23:13:59 +01:00
David Garske
e13861bcde Fix for mutual authentication to prevent mismatch of certificate and sig algo. Work from Sean P. ZD 13571 2022-02-02 12:20:02 -08:00
David Garske
28d3292a16
Merge pull request #4811 from haydenroche5/dh_get_2048_256
Add DH_get_2048_256 to compatibility layer.
2022-02-02 12:12:34 -08:00
David Garske
0618b69b6d
Merge pull request #4816 from julek-wolfssl/ok-error
For `0` OpenSSL prints "ok"
2022-02-02 12:10:35 -08:00
David Garske
9efb791abc
Merge pull request #4814 from SparkiDev/bio_dump_iter
wolfSSL_BIO_dump: fix output format and make iterative
2022-02-02 12:02:07 -08:00
Juliusz Sosinowicz
d5b294edc4 ZD13495
- `wolfSSLeay_version` now returns the version of wolfSSL
- `wolfssl/openssl/crypto.h` was not enveloped in a `extern "C"` wrapper
2022-02-02 17:38:36 +01:00
Hayden Roche
c629c3fcaa Add DH_get_2048_256 to compatibility layer. 2022-02-02 07:59:17 -08:00
Juliusz Sosinowicz
1552e89810 For 0 OpenSSL prints "ok" 2022-02-02 15:54:21 +01:00
Marco Oliverio
cebb127ac3 test: don't free AesXts struct in-between tests that reuse the key 2022-02-02 10:46:40 +01:00