Commit Graph

2162 Commits (f87859a00e5f260fbba8da90a0ad5c1c4badf27c)

Author SHA1 Message Date
Juliusz Sosinowicz 63ba2f7b8f TLS 1.3: Check maximum records encrypted with one key set 2022-09-15 12:17:46 +02:00
Juliusz Sosinowicz 4e9106c355 Enforce maximum amount of failed decryptions in DTLS 1.3 2022-09-15 12:17:46 +02:00
Sean Parkinson 79d85f6c13 TLS cipher suite: improvements
wolfSSL_clear: check return from InitSSL_Suites() call.
TLS13: check ClientHello cipher suite length is even.
Silently remove duplicate cipher suites from user input.
Add tests of duplicate cipher suite removal.
2022-09-14 09:26:00 +10:00
Sean Parkinson 8c1e2c52e7 Kyber: Add option to build Kyber API
wolfSSL Kyber implementation not included.
Added tests and benchmarking.
2022-09-13 10:07:27 -04:00
Sean Parkinson 5e945f94b4 TLSv1.3 cipher suites: fixes
Handle multiple instances of the same cipher suite being in the server's
list.
Fix client order negotiation of cipher suite when doing pre-shared keys.
2022-09-13 17:25:11 +10:00
Sean Parkinson 38418b31f1
Merge pull request #5197 from JacobBarthelmeh/OCSP
RSA-PSS with OCSP and add simple OCSP response der verify test case
2022-09-13 15:10:00 +10:00
JacobBarthelmeh 757a18ab7e
Merge pull request #5496 from SKlimaRA/SKlimaRA/SetCipherListBytes
Support for setting cipher list with bytes
2022-09-09 13:42:51 -06:00
David Garske 23ba1e7e98 Minor cleanups. Gate these API's on `OPENSSL_EXTRA` or `WOLFSSL_SET_CIPHER_BYTES` to keep code size reduced. 2022-09-09 10:49:49 -07:00
JacobBarthelmeh 6526ffc5f8
Merge pull request #5567 from haydenroche5/hmac_sha1_fix
Fix HMAC compat layer function for SHA-1.
2022-09-09 09:45:21 -06:00
Juliusz Sosinowicz 7418ddcae6 Refactor nofail tests into test_wolfSSL_client_server_nofail 2022-09-09 16:04:30 +02:00
David Garske 52653c654d
Merge pull request #5571 from julek-wolfssl/sk-cmp-param-fix
Set correct types in wolfSSL_sk_*_new functions
2022-09-08 08:47:20 -07:00
David Garske 64376d4d9e
Merge pull request #5555 from julek-wolfssl/dtls-fragment-buckets
Don't over-allocate memory for DTLS fragments
2022-09-08 07:46:04 -07:00
Juliusz Sosinowicz 28af88788a Set correct types in wolfSSL_sk_*_new functions
- Use WOLF_SK_COMPARE_CB() to generate the correct types instead of using void* for the callback parameters.
- Remove WOLFSSL_STACK.comp entirely since it is not used anywhere. Ignore input parameters that used to set this member.
2022-09-08 11:55:32 +02:00
JacobBarthelmeh 9d6e157fc5 add asn template version 2022-09-07 16:15:19 -07:00
Hayden Roche 18450eb94b Fix HMAC compat layer function for SHA-1.
This function would only accept the string "SHA" for SHA-1-based HMAC, but it
should also accept "SHA1." This is similar to how wolfSSL_EVP_get_digestbyname
allows both "SHA" and "SHA1." We didn't have a test for this in api.c. I added
one, and it failed before my fix here.
2022-09-07 15:25:31 -07:00
JacobBarthelmeh 28a82237d9 RSA-PSS signed OCSP responses 2022-09-07 13:12:43 -07:00
Juliusz Sosinowicz 28895ed0cd Use a union and struct for padding in DtlsFragBucket
Zero length arrays are not allowed so `byte padding[0]` is not a valid member. Changed to use a union and struct instead.
2022-09-07 13:04:26 +02:00
Juliusz Sosinowicz 8bf3e0829e Don't over-allocate memory for DTLS fragments
Don't reserve the full message length of memory. Instead we only allocate memory for the fragments that we have already received. We also dynamically combine memory fragments when we receive overlap.
2022-09-07 13:04:06 +02:00
Stefan Eissing 9b319b3782 Remove dependency on POLY1305 on testing CHACHA20 only. 2022-09-06 10:06:02 +02:00
Stefan Eissing 9f47999002 Add ChaCha20 as available cipher in the EVP API.
- wire the wc_ChaCha_* implementation into the EVP API
  as `wolfSSL_EVP_chacha20`
- follow IV conversions of OpenSSL
- add test case
- have QUIC support use this for header protection when
  CHACHA20_POLY1305 has been negotiated in the handshake.
2022-09-06 10:06:02 +02:00
Stanislav Klima 38781bd7cf added testing for wolfSSL_set_cipher_list_bytes() 2022-09-05 16:57:07 +02:00
Sean Parkinson f807c70637 Ed make public key wasn't checking whether private key set
Ed25519 and Ed448 make public key APIs now check whether the private key
was set.
The private key and public key flags setting and clearing also updated.
Testing of unset private key and calling make public key added for
Ed25519 and Ed448.
2022-09-05 12:21:51 +10:00
Satoshi Yamaguchi 69ed2b56d4 Replace a variable of AES-128 key size to the constant AES_128_KEY_SIZE 2022-09-04 13:31:24 +09:00
David Garske 11bb8b3dc4
Merge pull request #5543 from SparkiDev/rsa_max_size_fix
RSA max key size checks
2022-09-02 09:26:19 -07:00
Sean Parkinson 3bf6baf596 RSA max key size checks
Detect when certificate's RSA public key size is too big and fail on
loading of certificate.
Fix unit test to only attempt to use 3072 bit RSA-PSS keys when
RSA_MAX_SIZE supports it.
2022-09-02 10:37:12 +10:00
Stefan Eissing 65ca72c5a2
Improve EVP support for CHACHA20_POLY1305 (#5527)
* Add test case for OpenSSLs capability to init a evp context partially in several calls.
* EVP handling of CHACHA20_POLY1305 improvment
- save key at ctx for Init()s without IV
- reuse stored key for Init()s with new IV, reusing ctx
- free and zero key on ctx clenaup
* Adding type cast to XMALLOC to force compiler compatibility.
* EVP: using same DYNAMIC_TYPE in alloc and free of chacha20_poly1305 key.
Co-authored-by: Stefan Eissing <stefan.eissing@greenbytes.de>
2022-09-01 13:23:42 -07:00
Satoshi Yamaguchi 85776f0069 Add wolfSSL_EVP_PKEY_new_CMAC_key to OpenSSL compatible API 2022-09-01 18:00:43 +09:00
Daniel Pouzzner ea3959f2f6 analyzer coddling:
in api.c test_wolfSSL_dtls12_fragments_spammer(), inhibit clang-analyzer-deadcode.DeadStores;

in asn.c ParseCRL_Extensions() old (!WOLFSSL_ASN_TEMPLATE) version, fix bounds check to prevent overshift;

in misc.c ctMaskCopy(), use `*(x + i)`, not x[i], to tiptoe around cppcheck-2.9 objectIndex bug.
2022-08-31 22:56:08 -05:00
David Garske 8722a46d52
Merge pull request #5503 from julek-wolfssl/dtls-fragments
DTLS limit fragments
2022-08-31 09:53:09 -07:00
Juliusz Sosinowicz 54bd786707 DTLS limit fragments
- Limit the amount of fragments we store per a DTLS connection
- Error out when we reach the DTLS fragment connection limit
2022-08-31 14:24:20 +02:00
JacobBarthelmeh 29f2dee991 handeling DER to internal of an OCSP response with no optional certificates 2022-08-29 15:25:50 -07:00
JacobBarthelmeh ac3cdb42b7 free structure in test case and return 0 from ocsp renew script 2022-08-29 15:25:50 -07:00
JacobBarthelmeh 5b5f673c51 add simple ocsp response der verify test case 2022-08-29 15:25:50 -07:00
David Garske a7f86f9473
Merge pull request #5517 from JacobBarthelmeh/Testing
misc. testing items from static analysis tools
2022-08-29 08:48:51 -07:00
Juliusz Sosinowicz 88deaf9b5c SNI can appear in ServerHello for TLS 1.2
Co-authored-by: Eric Blankenhorn <eric@wolfssl.com>
2022-08-29 14:22:10 +02:00
JacobBarthelmeh ad0fd15a0d static analysis fix from infer 2022-08-26 14:55:42 -07:00
Juliusz Sosinowicz 2fb3f58c03 Cleanup output object in wolfSSL_EVP_MD_CTX_copy_ex before copy 2022-08-26 13:07:45 +02:00
David Garske 1976601811
Merge pull request #5505 from julek-wolfssl/dtls-plaintext
Ignore plaintext on established connections
2022-08-25 07:25:03 -07:00
Hayden Roche 9f39ffdba7 Fix wolfSSL_GENERAL_NAMES_free memory leak.
This function was just freeing the stack object itself of GENERAL_NAMES with
wolfSSL_sk_free, but this doesn't free the data in the items of the stack. The
fix is to replace wolfSSL_sk_free with wolfSSL_sk_GENERAL_NAME_free.
2022-08-24 18:42:30 -07:00
Juliusz Sosinowicz 159a3c8b03 Ignore plaintext on established connections 2022-08-24 21:40:19 +02:00
Stanislav Klima c4a61af311 drafted test case 2022-08-24 20:45:54 +02:00
John Safranek 9b65f5819c
API Test Fixes for GCC/PowerPC Warnings
1. In api.c, change the name of the devId global to testDevId.
2. In api.c, for the SNI test, some of the pointers were multiply
   typecast eventually to `void **`. An older compiler didn't like
   that. Just use void pointer.
2022-08-24 11:30:56 -07:00
David Garske 48463f6d54
Merge pull request #5388 from lealem47/crlPrint
Adding X509_CRL_print() function
2022-08-22 17:16:19 -07:00
David Garske 1e5de8255e
Merge pull request #5472 from satoshiyamaguchi/trial3
Add/Extend PEM_read compatibility API's
2022-08-22 09:24:39 -07:00
Lealem Amedie 8f4b467f47 Fixing line lengths and SMALL_STACK code path 2022-08-22 09:17:23 -07:00
Lealem Amedie 2a65220527 Adding X509_CRL_print() function 2022-08-19 12:21:35 -07:00
David Garske 1d0e83bd1a
Merge pull request #5474 from julek-wolfssl/zd14644-2
Match OpenSSL self signed error return.
2022-08-19 06:46:26 -07:00
Satoshi Yamaguchi 61c7003520 Fix whitespace 2022-08-19 12:38:07 +09:00
Chris Conlon e830a0f613
Merge pull request #5434 from satoshiyamaguchi/trial4 2022-08-17 17:04:36 -06:00
Juliusz Sosinowicz 008e947fec Match OpenSSL self signed error return.
OpenSSL compat expects ASN_SELF_SIGNED_E when a self signed cert can't be verified. This is useful when translating the error with GetX509Error into a X509_V_ERR_* error.
2022-08-17 12:40:16 +02:00
Satoshi Yamaguchi 091fc71c74 Fix EVP_PKEY not freed and FILE pointer not closed 2022-08-17 01:03:09 +09:00
Satoshi Yamaguchi e1b3f14d35 Fix FILE pointer not closed in tests/api.c 2022-08-17 00:11:29 +09:00
Satoshi Yamaguchi fba534dce0 Add wolfSSL_PEM_read_RSA_PUBKEY to OpenSSL compatible API 2022-08-14 16:08:22 +09:00
Daniel Pouzzner e382905311 CMakeLists.txt: synchronize CMAKE_C_FLAGS with diagnostic flags set in autotools-generated Makefile (-Wall -Wextra -Wno-unused -Werror), and fix WOLFSSL_RSA_PSS to add -DWOLFSSL_PSS_LONG_SALT as needed by changes to test_wolfSSL_CertRsaPss() in fb531dacc2 (gating of those changes is also added in this commit). 2022-08-12 15:18:41 -05:00
David Garske 499b9c4f35
Merge pull request #5456 from SparkiDev/ssl_set1_curve_fix
wolfSSL_CTX_set1_curves_list: X25519 and X448 defines
2022-08-11 09:19:25 -07:00
Sean Parkinson 4d8a713783 wolfSSL_CTX_set1_curves_list: X25519 and X448 defines
Support wolfSSL_CTX_set1_curves_list being available when X25519 and/or
X448 only defined.
Don't recognize X25519 or X448 if corresponding define is not set.
Enable test in api.c.
2022-08-11 14:13:04 +10:00
Sean Parkinson fb531dacc2 Certs with RSA-PSS sig
Add support for parsing and verifying certificates with RSA-PSS
signatures. Including check PSS parameters in key with those in
signature algorithm.
Add support for parsing private RSA PSS key.
Add support for parsing public RSA PSS key.
2022-08-11 09:43:01 +10:00
David Garske 7004157869
Merge pull request #5387 from TakayukiMatsuo/tk14445
Suppress build errors when defining some disable macros
2022-08-07 20:09:41 -07:00
TakayukiMatsuo 79fb1783c4 Suppress build errors when defining some disable macros 2022-08-07 17:11:22 +09:00
David Garske 96fcc129ec
Merge pull request #5213 from JacobBarthelmeh/req
expand functions included in opensslextra and add REQ print out
2022-08-05 13:20:21 -07:00
David Garske 2c2a7750a4
Merge pull request #5414 from darktohka/feature/chacha20-poly1305-evp
Integrate chacha20-poly1305 into the EVP interface
2022-08-03 18:21:17 -07:00
David Garske 0c1add08e3
Merge pull request #5416 from darktohka/feature/chacha20-outl-bytes
Ensure ChaCha20 updates out length during cipher update
2022-08-03 07:26:02 -07:00
Satoshi Yamaguchi 013ad0d564 Add wolfSSL_PEM_read_RSAPrivateKey to OpenSSL compatible API 2022-08-03 00:02:40 +09:00
Jacob Barthelmeh 52b80ea52a expand functions included in opensslextra and add REQ print out 2022-08-01 09:21:43 -07:00
Disyer e3dd7677c8 Add tests for chacha20-poly1305 EVP integration 2022-07-28 18:21:12 +03:00
Disyer e8febaf414 Ensure ChaCha20 updates out length during cipher update 2022-07-28 18:06:41 +03:00
Sean Parkinson 460845ba49 Maths bit size: ensure size is right
Ensure WOLFSSL_MAX_RSA_BITS works.
Fix SP math size defines.
Regression testing maths implementations.
2022-07-27 18:58:30 +10:00
David Garske a98642ba61
Merge pull request #5383 from julek-wolfssl/negating-ciphersuites
Expand SetCipherList()
2022-07-25 08:26:47 -07:00
Juliusz Sosinowicz e7cd1562b4 Expand SetCipherList()
- support disabling ciphersuites starting from the default list
2022-07-25 11:14:16 +02:00
Sean Parkinson 8fa2449a63 Cert path length: add flag to indicate path length set
A path length is allowed to be 0.
Can't check path len for 0 to determine when value is set.
Added flag to indicate path length is set.
2022-07-25 09:07:14 +10:00
Hayden Roche daf5135642 Begin refactor of api.c.
- Modify all existing tests to return an int. This moves us in the direction of
being able to return error/success from a test rather than just calling abort
when something fails. Also, all tests now have the same signature, so they can
easily be members of an array of test cases.
- Wrap each test in a TEST_CASE struct, which just stores a pointer to the test
function and the name of the test, for now. In the future, other metadata can
be added (e.g. should this test be run/skipped) to TEST_CASE, if desired.
- Modify all tests to return 0 on success. Right now, this doesn't do us much
good because the failure mechanism isn't returning some value != 0, it's
abort.
- Add TestSetup and TestCleanup functions that run before and after each test,
respectively. The former does nothing right now, and the latter clears the
error queue, if the error queue is compiled in.
2022-07-21 10:12:26 -07:00
JacobBarthelmeh 1281d97b1e
Merge pull request #5373 from haydenroche5/error_queue_fix
Fix backwards behavior for various wolfSSL_ERR* functions.
2022-07-21 09:35:21 -06:00
Kareem 741d61574b Make wolfSSL_CTX_clear_options available without OPENSSL_EXTRA. 2022-07-20 12:24:47 -07:00
Hayden Roche e6da540fb3 Fix backwards behavior for various wolfSSL_ERR* functions.
wolfSSL_ERR_get_error and wolfSSL_ERR_peek_error_line_data should return the
earliest error in the queue (i.e. the error at the front), but prior to this
commit, they returned the latest/most recent one instead.

In DoAlert, we were adding an error to the queue for all alerts. However, a
close_notify isn't really an error. This commit makes it so DoAlert only adds
errors to the queue for non-close_notify alerts. In ReceiveData, similarly, we
were adding an error to the queue when the peer sent a close_notify, as
determined by ssl->error == ZERO_RETURN. Now, we don't add an error in this
case.
2022-07-20 08:56:48 -07:00
David Garske f4191a102b
Merge pull request #5304 from SKlimaRA/SKlimaRA/cert-pathlen
drafted pathlen for cert struct
2022-07-20 07:54:13 -07:00
David Garske aab2459d1f
Merge pull request #5372 from JacobBarthelmeh/copyright
update copyright year to 2022
2022-07-20 07:52:05 -07:00
David Garske c029b23043
Merge pull request #5308 from SparkiDev/ecies_gen_iv
ECIES: Google Pay generates IV and places it before msg
2022-07-20 06:46:14 -07:00
Stanislav Klima 66c5a947fd XSTRNCPY, fixed typos 2022-07-20 08:56:59 +02:00
Sean Parkinson 09bba3510f ECIES: Google Pay ECIES
Generates IV and places it before msg
Uses 12 byte IV with AES-CTR
Add API to explicitly set KDF salt.
2022-07-20 09:30:47 +10:00
Jacob Barthelmeh 8eaa85e412 update copyright year to 2022 2022-07-19 10:44:31 -06:00
Stanislav Klima 1a44bad8cc drafted test case for path len 2022-07-19 15:34:20 +02:00
Hayden Roche a1b7c29309 Make wolfSSL_(get|set)_options available outside compat layer.
Also make wolfSSL_CTX_get_options available.
2022-07-14 16:03:58 -07:00
David Garske 2d5bc72c9b Fixes for ED25519/ED448 private key with public key export (RFC8410). Added length only support. 2022-07-13 16:17:08 -07:00
Daniel Pouzzner ccc5952369 global fixup to check or explicitly ignore return values from failable library/system calls that weren't already being checked;
add wolfCrypt error codes IO_FAILED_E "Input/output failure" and SYSLIB_FAILED_E "System/library call failed";

tests/api.c and tests/unit.c: flush stdout for error message in Fail() macro, add fflush(stdout) after printf()s, print success message at end of unit_test(), and send several error messages to stderr instead of stdout;

wolfcrypt/test/test.c: add fallthrough macro definition of printf() that pairs it with fflush(stdout);

unit.h: in definition of macro AssertPtr(), add PRAGMA_GCC("GCC diagnostic ignored \"-Wpedantic\"");

sp_int.c: refactor several lingering instances of "if (0) { ... }" code pattern to #if 0 ... #endif.
2022-07-11 22:28:09 -05:00
David Garske 34c576d2a7 Fixes for possible NULL dereference for heap hint in pk.c Fix typo in api.c test for dynamic type. 2022-07-11 14:41:11 -07:00
David Garske 4892435004 Fix for `wc_ecc_get_curve_id_from_oid` with combinations of `HAVE_OID_ENCODING` and `HAVE_OID_DECODING`. Fix in `SetCurve` for unused `outSz` with `HAVE_OID_ENCODING`. 2022-07-08 13:00:09 -07:00
Daniel Pouzzner 48d3cf593e tests/api.c: fix bugprone-macro-parentheses in DUW_TEST(). 2022-07-08 07:57:29 -05:00
David Garske 4e1e1e922a
Merge pull request #5278 from ejohnstown/dtls-seq
Refactor DTLS Window Update (Fix #5211)
2022-07-07 10:22:21 -07:00
Juliusz Sosinowicz e295328436 Fix window handling around word32 boundary 2022-07-07 17:37:10 +02:00
John Safranek 8f3449ffea
Refactor DTLS Window Update (Fix #5211)
1. Rename _DtlsUpdateWindow() as wolfSSL_Dtls_UpdateWindow() and make
   it public so it may be tested.
2. Rename the internal functions DtlsWindowUpdate(), DtlsWindowCheck(),
   and DtlsUpdateWindowGTSeq() as _DtlsWindowUpdate() and
   _DtlsWindowCheck(), and _DtlsUpdateWindowGTSeq().
3. When updating the DTLS sequence window, and the next sequence
   number (lo) wraps to zero, increment the next sequence number (hi)
   by 1.
4. Fix an off-by-one error that wrapped around when saving the
   packet sequence number in the bit-field window.
5. Adding a test for wolfSSL_DtlsUpdateWindow() function. With many test
   cases. It is set up in a table format with running check values.
6. Change location of incrementing the difference when calculating the
   location for setting the bit.
7. Updated the check of the sequence difference in the GT scenario.
8. In the DTLS window update functions remove newDiff and just use diff.
9. Handle the cases where the DTLS window crosses the high order word
   sequence number change.
10. Add a debug option to print out the state of the DTLS sequence number
   window.
2022-07-06 18:20:06 -07:00
Daniel Pouzzner 19106a9510 configure.ac and tests/api.c: lock out compkey on FIPS 140-3 RC12 and ready, and add backward-compat code in test_wc_ecc_export_x963_ex() to allow RC12 compkey builds to pass unit.test. 2022-07-06 17:31:56 -05:00
David Garske a7fa7875e4
Merge pull request #5244 from julek-wolfssl/wpas-dpp
Support for new DPP and EAP-TEAP/EAP-FAST in wpa_supplicant
2022-07-06 11:35:52 -07:00
David Garske e92034cf6f
Merge pull request #5274 from JacobBarthelmeh/Certs
remove subject/issuer email from altEmailNames list
2022-07-06 10:48:21 -07:00
Jacob Barthelmeh 711b2bb17a add a test case 2022-07-06 09:39:03 -06:00
Juliusz Sosinowicz 144f2612e4 wc_ecc_export_x963_ex returns LENGTH_ONLY_E on a NULL output 2022-07-05 08:49:00 +02:00
Juliusz Sosinowicz 8e84560f71 CSR: confirm the signature when verify == VERIFY 2022-07-05 08:49:00 +02:00
Sean Parkinson 2c943282f0 Ed25519/Ed448: assume public key is not trusted
In defense against attack, assume the imported public key is not trusted
and check it matches the private key if set.
Added APIs that allow application to explicitly trust public key.
Original APIs default to not trusting public key.
2022-07-01 09:05:43 -07:00
David Garske 94e7eacc5f
Merge pull request #5072 from JacobBarthelmeh/Compatibility-Layer
add support for importing private only EC key to a WOLFSSL_EVP_PKEY s…
2022-06-27 12:34:00 -07:00
David Garske b84b808b1b
Merge pull request #5167 from ejohnstown/cac-ext
Add support for some FPKI certificate cases, UUID, FASC-N, PIV extension
2022-06-27 09:06:15 -07:00
Eric Blankenhorn 7fb17e0584 Fix build error with --enable-opensslextra=x509small --enable-debug 2022-06-23 11:26:57 -05:00
Jacob Barthelmeh 40dda7e80f fix XMALLOC in test and add filesystem macro guard 2022-06-21 17:24:14 -06:00
Chris Conlon 7dbf1a5154
Merge pull request #5262 from miyazakh/qt_unit_failure 2022-06-21 16:35:37 -06:00
Daniel Pouzzner 69ca1d37c0 fixes for defects identified by wolfssl-multi-test: whitespace, missing void in arg lists, and -Wunused-but-set-variable found by clang-15 (prerelease). 2022-06-20 10:54:55 -05:00
Hideki Miyazaki b5cac49be9 fix qt_unit_test_failure
add/remove spaces and line-feed to be the same as before
2022-06-18 10:04:10 +09:00
David Garske 390908bccc
Merge pull request #5236 from SparkiDev/mem_zero
Check memory is zeroized
2022-06-17 12:01:34 -07:00
Sean Parkinson 6a0682d422 i2d AIPs move pointer on when a pointer to a buffer is passed in
Restore behaviour to be compatible with OpenSSL.
Replace comparison of DER data using AsserStrEQ to use memcmp.
2022-06-17 12:36:06 +10:00
Sean Parkinson 2834c22ce0
Merge pull request #5204 from lealem47/basicConst
Encoding the X509 Basic Constraint when CA:FALSE
2022-06-17 08:33:57 +10:00
David Garske f2abf1892c
Merge pull request #5255 from lealem47/i2d_RSA
Call RSA_To_Der instead of RSA_To_Der_ex in i2dd_RSA key funcs
2022-06-16 14:43:58 -07:00
David Garske 1322c1a0b2
Merge pull request #5248 from lealem47/no_aes
Fix build failure caused by missing NO_AES macro guard
2022-06-16 13:18:09 -07:00
Lealem Amedie 911f361285 Call RSA_To_Der instead of RSA_To_Der_ex in i2d_RSA key funcs 2022-06-16 12:26:47 -07:00
Lealem Amedie 5e63740c6c Ensuring that X509 Basic Constraint is set when CA:FALSE 2022-06-16 08:46:52 -07:00
Sean Parkinson 1b29f7353a Check memory is zeroized
Add a define WOLFSSL_CHECK_MEM_ZERO to turn on code that checks that
memory that must be zeroized before going out of use is zero.
Everytime sensitive data is put into a allocated buffer or stack buffer;
the address, its length and a name is stored to be checked later.
Where the stack buffer is about to go out of use, a call is added to
check that the required parts are zero.

wc_MemZero_Add() adds an address with length and name to a table of
addressed to be checked later.
wc_MemZero_Check() checks that the memory associated with the address is
zeroized where required.
mp_memzero_add() adds mp_int's data pointer with length and name to
table.
mp_memzero_check() checks that the data pointer is zeroized where
required.

Freeing memory will check the address. The length was prepended on
allocation.
Realloction was changed for WOLFSSL_CHECK_MEM_ZERO to perform an
allocate, check, copy, free.
2022-06-16 10:22:32 +10:00
David Garske 7e1549c684 Cleanup the RSA consistency check. Should only be enabled for FIPS v2 (3389), FIPS v5 or later. Can be forcefully enabled for non-FIPS using `WOLFSSL_RSA_KEY_CHECK`. The existing `WOLFSSL_NO_RSA_KEY_CHECK` macro will also disable it. This change was introduced in PR #4359. 2022-06-15 14:46:23 -07:00
Lealem Amedie 9bcbd645d6 Fix build failure caused by missing NO_AES macro guard 2022-06-15 13:30:56 -07:00
David Garske 0b78961111
Merge pull request #5186 from SparkiDev/pk_c_rework_1
pk.c: rework
2022-06-13 08:35:09 -07:00
David Garske d600a4b887 Spelling and Whitespace cleanups. Fix issue with trying to build pk.c directly and always getting warn even with `WOLFSSL_IGNORE_FILE_WARN`. 2022-06-10 09:06:55 -07:00
David Garske 49008b169c
Merge pull request #5087 from haydenroche5/x509_print
Add support for more extensions to wolfSSL_X509_print_ex.
2022-06-10 08:19:23 -07:00
Sean Parkinson 890abfbefc pk.c: rework
Re-order RSA functions.
Add comments to RSA functions.
Rework RSA function implementations.
2022-06-10 09:54:32 +10:00
Hayden Roche f479600066 Add support for more extensions to wolfSSL_X509_print_ex.
- Key usage
- Extended key usage
- Subject alt name

Additionally, print out the criticality of the extensions.
2022-06-09 16:50:10 +02:00
JacobBarthelmeh 86023378f8 free decoded cert in test case and x509 2022-06-06 14:31:41 -07:00
Takashi Kojo 7bfe6aa127 Extend HEAP_HINT to all InitRsaKey in api.c 2022-06-05 09:12:49 +09:00
Takashi Kojo 1b9f922ec3 wc_MakeRsKey with static mem pool 2022-06-05 09:04:42 +09:00
Hayden Roche fb3c611275 Fix another AES-GCM EVP control command issue.
With PR 5170, I added logic that requires a EVP_CTRL_GCM_SET_IV_FIXED command be
issued before a EVP_CTRL_GCM_IV_GEN command. This matches OpenSSL's behavior.
However, OpenSSL also clears the flag enabling EVP_CTRL_GCM_IV_GEN after
EVP_CTRL_GCM_SET_IV_FIXED if EVP_CipherInit is called with a NULL key.
Otherwise, the flag retains its value. We didn't mirror this logic, and that
caused problems in OpenSSH unit testing. This commit aligns our logic with
OpenSSL's and adds a regression test to test_evp_cipher_aes_gcm for this case.
2022-06-02 12:32:59 -07:00
Sean Parkinson fb9f90b98b
Merge pull request #5200 from dgarske/qat_fsanitize
Fixes for buffers when testing with Intel QAT hardware
2022-06-02 08:35:24 +10:00
David Garske 5672e2a885 Fixes for buffers when testing with Intel QAT hardware and `fsanitize=address`:
* PKCS7 should use allocated buffer for RSA.
* PKCS7 small stack typo for `keyAlgArray` size in `wc_PKCS7_AddRecipient_KTRI`.
* Fix for use of `free`, which should be `XFREE` in api.c.
* Cleanup old RSA benchmarking MDK5/WINCE code no longer needed with `WC_DECLARE_ARRAY_DYNAMIC_DEC` and `WC_DECLARE_ARRAY_DYNAMIC_EXE`.
2022-06-01 12:07:57 -07:00
Daniel Pouzzner b212853bce evp.c: in EvpCipherAesGCM(), make sure ctx->gcmAuthIn is non-null before clearing it; fix whitespace. 2022-06-01 10:29:40 -05:00
Sean Parkinson 81cd1e652e
Merge pull request #5170 from haydenroche5/evp_cipher_aes_gcm
Fix EVP_CTRL_GCM_IV_GEN with AES-GCM.
2022-06-01 08:20:33 +10:00
Chris Conlon 0554b02215
Merge pull request #5177 from JacobBarthelmeh/PKCS7 2022-05-31 09:46:14 -06:00
David Garske fa80aa6505
Merge pull request #5132 from JacobBarthelmeh/req
Add support for additional CSR attributes
2022-05-25 13:35:46 -07:00
Hayden Roche 3cf636163b Fix EVP_CTRL_GCM_IV_GEN with AES-GCM.
Discovered the AES-GCM flow using this command didn't work in our OpenSSH port.
This commit makes the behavior match OpenSSL and adds testing using known
OpenSSL-generated test vectors to prevent regressions. This was one of those
problems where two ends of a connection would work fine if they were both using
wolfSSL but not if one was using OpenSSL (i.e. OpenSSH interop with AES-GCM
was broken).
2022-05-25 07:00:15 -07:00
JacobBarthelmeh a1fb385450 free recipent list in error cases 2022-05-24 15:12:39 -07:00
David Garske 74cbd08ff5
Merge pull request #5164 from cconlon/x509date
Remove WOLFSSL_ALT_NAMES restriction on notBefore/notAfter use in Cert struct
2022-05-24 12:41:00 -07:00
Chris Conlon 6a26dab73a X.509 cert validity for CertFromX509() and EncodeCert() shouldn't be protected by WOLFSSL_ALT_NAMES 2022-05-24 10:28:46 -06:00
JacobBarthelmeh 36db5ef929 add test case for UUID and FASC-N 2022-05-23 09:17:42 -07:00
David Garske b5d65b9579
Merge pull request #5159 from kareem-wolfssl/fipsv3HmacMd5
Allow using 3DES and MD5 with FIPS 140-3, as they fall outside of the FIPS boundary.
2022-05-20 18:40:29 -07:00
David Garske 9a74745246
Merge pull request #5163 from haydenroche5/evp_pkey_derive_guard
Remove unneeded FIPS guard on wolfSSL_EVP_PKEY_derive.
2022-05-20 17:12:24 -07:00
David Garske d80b282fdd
Merge pull request #5156 from anhu/HAVE_AES_GCM
Rename HAVE_AES_GCM guard to HAVE_AESGCM in the tests.
2022-05-20 15:03:57 -07:00
Hayden Roche a6b948ae59 Remove unneeded FIPS guard on wolfSSL_EVP_PKEY_derive. 2022-05-20 11:29:01 -07:00
Hayden Roche 6d9fbf7ab3 Provide access to "Finished" messages outside the compat layer.
Prior to this commit, if you wanted access to the Finished messages from a
handshake, you needed to turn on the compatibility layer, via one of
OPENSSL_ALL, WOLFSSL_HAPROXY, or WOLFSSL_WPAS. With this commit, defining any
of these causes WOLFSSL_HAVE_TLS_UNIQUE to be defined (a reference to the
tls-unique channel binding which these messages are used for) in settings.h.
This allows a user to define WOLFSSL_HAVE_TLS_UNIQUE to access the Finished
messages without bringing in the whole compat layer.
2022-05-19 16:34:13 -07:00
Kareem 832a7a40a6 Allow using 3DES and MD5 with FIPS 140-3, as they fall outside of the FIPS boundary. 2022-05-19 12:06:20 -07:00
Anthony Hu cf81ae79e4 HAVE_AESGCM 2022-05-19 11:30:58 -04:00
Anthony Hu 9c2903c176 Remove HAVE_AES_GCM guard as it is never defined. 2022-05-19 01:20:55 -04:00
John Safranek 40063f7487
Merge pull request #5109 from rizlik/dtls_peer_matching_fix
wolfio: dtls: fix incorrect peer matching check
2022-05-18 09:12:26 -07:00
David Garske c9ae021427
Merge pull request #5143 from julek-wolfssl/x509-ret-empty-name
Return subject and issuer X509_NAME obj even when not set
2022-05-17 09:16:54 -07:00
David Garske ec619e3f35
Merge pull request #5107 from julek-wolfssl/wpas-ex-data-leak
Call ctx->rem_sess_cb when a session is about to be invalid
2022-05-16 13:27:08 -07:00
Juliusz Sosinowicz 7f8f0dcffe Refactor cache ex_data update/retrieve into one function
- Add explicit pointer cast
2022-05-16 13:01:05 +02:00
Juliusz Sosinowicz d996086a6d Return subject and issuer X509_NAME obj even when not set
This allows the user to set the attributes of the subject and issuer name by calling X509_REQ_get_subject_name and adding attributes to it.
2022-05-16 12:49:34 +02:00
JacobBarthelmeh fb9b96d498 fix for index increment and change test case expected return values 2022-05-13 14:07:29 -07:00
David Garske 1a57e3065a Small cleanups. Missing `(void)`, spelling and formatting. Also fixes for variations of 25519/448 build. 2022-05-13 09:24:59 -07:00
Marco Oliverio 27e73818c5 tests: run test_wolfSSL_dtls_export() over UDP instead of TCP 2022-05-11 12:20:15 +02:00