Commit Graph

2566 Commits (aa19d8221e3ad0d0268c8610118b6163f8da5ca0)

Author SHA1 Message Date
JacobBarthelmeh 7866a40d06 resolve kari decode without recipient certificate 2023-07-08 07:37:26 -07:00
JacobBarthelmeh f0354b4cbe parse ASN1 only with SMIME_read_PKCS7 2023-07-08 07:36:10 -07:00
David Garske 770590a3be Rebase fix to add back set_verify call in CertManagerLoadCA. Fix API tests for bad date check. Various spelling fixes. 2023-07-07 15:08:08 -07:00
Sean Parkinson 3af87f6f93 Moved CertManager APIs into own file
Split out certificate manager APIs into ssl_certman.c.
ssl.c includes ssl_certman.c
Better test coverage.
Minor fixes.
wolfSSL_X509_chain_up_ref calls XFREE with name->heap but name may be
NULL. Check for NULL first.
2023-07-07 15:08:08 -07:00
David Garske 91fb24161b
Merge pull request #6515 from julek-wolfssl/nginx-1.25.0
Add support for nginx-1.25.0
2023-07-07 09:29:23 -07:00
Juliusz Sosinowicz 0abaa89787 Add support for nginx-1.25.0
- nginx: add necessary defines and function
- Implement Certificate Authorities for TLS 1.3
- Implement secret logging for TLS 1.3. Can be used for example with:
  ./configure CPPFLAGS="-DWOLFSSL_SSLKEYLOGFILE -DSHOW_SECRETS -DHAVE_SECRET_CALLBACK -DWOLFSSL_SSLKEYLOGFILE_OUTPUT='\"/tmp/secrets\"'"
- Implement session context checking for tickets
- Check for authorized responder in OCSP basic response
- Fix handling call to ocsp->statusCb
- compat: Translate SOCKET_PEER_CLOSED_E to WOLFSSL_ERROR_SYSCALL
- Fix wolfSSL_CTX_set_session_cache_mode
  - WOLFSSL_SESS_CACHE_OFF means nothing should be on
  - WOLFSSL_SESS_CACHE_NO_INTERNAL turns off only the internal cache
- Respect ssl->options.internalCacheOff
- Implement SSL_SESSION_set_time
- wolfSSL_SSL_in_init: fix detection for TLS 1.3
- Fix handling call to ssl->alpnSelect
- SendTls13NewSessionTicket: always generate new ID
  - When we send a new ticket for the same session (for example we resumed a connection and are sending a new ticket so that the client can resume in the future), we need to generate a new ID so that we don't overwrite the old session in the cache. Overwriting the session results in the `diff` calculation in `DoClientTicketCheck()` producing the wrong value and failing to resume.
Add nginx github action test
- Fix memory leaks
- wolfSSL_OCSP_basic_verify: implement OCSP_TRUSTOTHER flag
- AKID: implement matching on issuer name and serial number
- ocsp: check for a chain match for OCSP responder
- Split CreateTicket into CreateTicket and SetupTicket
- SendCertificateStatus: free response.buffer
- Use heap hint when allocating responseBuffer
- Remove responseBuffer from internal API's that don't use it anywhere
2023-07-07 11:22:58 +02:00
Juliusz Sosinowicz 57e53d1a43 Don't allow a resumption handshake inside of a SCR 2023-07-06 15:13:56 -07:00
Andras Fekete 266307da6c Add in ARIA wrappers
Address PR comments + other cleanup


Addressing PR comments


Minor change


Make sure the last line gets output as well


Add in ARIA SHA256 session to internal structure


Add in ARIA SHA384 session to internal structure


Add necessary function for ARIA to extract key


Fix unit tests


Rename HAVE_ARIAGCM to HAVE_ARIA


Move aria.* to wolfcrypt/port/aria


Separate out aria-crypt init functions


Adding in ECC+SHA callbacks


Avoid using AC_CHECK_FILE


Rename Aria to wc_Aria


Don't need special cases


Addressing PR comments


Code cleanup


C89 support


Remove TODO


Add documentation about buffer size


Clean up header files


Use ARIA_DEVID by default if available


Dummy update call to make MagicCrypto happy


Fix for detecting what algo type to use


Documentation


Use the appropriate sign/verify


Collect MagicCrypto functions together (and avoid leaks)


Fall back on other implementations on failure


Fix issue when compiling without CRYPTOCB


Addressing PR comments


Better cleanup


Addressing PR comments


Cleaner exit in case of error
2023-07-06 16:09:23 -04:00
Juliusz Sosinowicz d2642e329d Properly enforce the pathLenConstraint of the BasicConstraints extension
- move the testsuite file helps into a new tests/utils.c file so that they can be used across all tests
- dump the raw TLS stream when WOLFSSL_DUMP_MEMIO_STREAM is defined so that it can be examined in Wireshark
2023-07-06 19:00:11 +02:00
Daniel Pouzzner 1912f1bc2a fixes for clang-analyzer-core.NullDereference, clang-analyzer-core.NonNullParamChecker, clang-analyzer-deadcode.DeadStores, readability-redundant-preprocessor, clang-diagnostic-unreachable-code-break, -Werror=sign-conversion, bugprone-macro-parentheses, "Call to 'malloc' has an allocation size of 0 bytes", clang-diagnostic-declaration-after-statement re tests/unit.h:ExpectPtr() pragmas. 2023-07-06 00:53:37 -05:00
David Garske f00b5c3a1e
Merge pull request #6537 from SparkiDev/sm
SM2/SM3/SM4: Chinese cipher support
2023-07-04 10:03:37 -07:00
David Garske b682c2c4bb
Merge pull request #6437 from julek-wolfssl/windows-crl-monitor
Implement CRL monitor for Windows
2023-07-04 10:03:14 -07:00
Dimitri Papadopoulos 50752f5a2b
Fix typos found by codespell 2023-07-04 07:21:27 +02:00
Sean Parkinson e2424e6744 SM2/SM3/SM4: Chinese cipher support
Add support for:
 - SM2 elliptic curve and SM2 sign/verify
 - SM3 digest
 - SM4 cipher with modes ECB/CBC/CTR/GCM/CCM

Add APIs for SM3 and SM4.
Add SM2 sign and verify APIs.
Add support for SM3 in wc_Hash and wc_Hmac API.
Add support for SM3 and SM4 through EVP layer.
Add support for SM2-SM3 certificates. Support key ID and name hash being
with SHA-1/256 or SM3.
Add support for TLS 1.3 cipher suites: TLS-SM4-GCM-SM3, TLS-SM4-CCM-SM3
Add support for TLS 1.2 SM cipher suite: ECDHE-ECDSA-SM4-CBC-SM3
Add support for SM3 in wc_PRF_TLS.
Add SM2-SM3 certificates and keys. Generated with GmSSL-3.0.0 and
OpenSSL.
2023-07-04 13:36:28 +10:00
Daniel Pouzzner 214f9f55c4 fixes for bugprone-suspicious-missing-comma, clang-analyzer-core.NullDereference, and readability-redundant-preprocessor. 2023-07-03 11:30:08 -05:00
Juliusz Sosinowicz 3d68bcd6f7 Jenkins fixes 2023-07-03 14:02:51 +02:00
Juliusz Sosinowicz 8ab0050801 Init windows CRL monitor 2023-07-03 14:02:51 +02:00
David Garske 6052e01879 Fixes for SNI test with static memory enabled. Fixes for other minor static memory build combinations. 2023-06-30 13:04:05 -07:00
David Garske 95675c7e34
Merge pull request #6455 from lealem47/INIT_SSL_NO_CTX_KEY
Allow option to create SSL without key/cert in ctx
2023-06-30 10:35:52 -07:00
Sean Parkinson a1939d22b9 wolfBot fixes
Importing an EC point ordinate with one being zero will result in
different errors based on different implementations. Check both known
error codes.

Benchmark usage fixed.
2023-06-30 09:07:46 +10:00
Lealem Amedie 7720dac545 Allow option to create SSL without key/cert in ctx 2023-06-29 13:57:40 -06:00
David Garske 048083cfe3
Merge pull request #6329 from tmael/crl_off
Add support for enabling and disabling CRLs.
2023-06-28 16:03:25 -07:00
Sean Parkinson d029ba4d46
Merge pull request #6415 from julek-wolfssl/issue/6408
Ignore session ID's shorter than 32 bytes instead of erroring out
2023-06-29 08:20:48 +10:00
David Garske 145ca4ae9d
Merge pull request #6542 from SparkiDev/api_fixes_1
Tests api.c: fixes
2023-06-27 10:00:07 -07:00
Tesfa Mael 03e5d109c7 Add test_wolfSSL_dup_CA_list 2023-06-27 08:29:13 -07:00
Tesfa Mael fd17fa3e9c Implement the option to disable CRL check
Do leaf CRL check by default
Correct wolfSSL_sk_X509_NAME_push return check
Update OpenSSL compatibility errors for HAProxy
Change X509_V to literal constant values
Fix the compat layer with TLS session ticket reuse
Fix for tls1_2 session resume and cache miss
Save intitial wolfSSL ctx
Check for OpenSSL CRL error code 23
2023-06-27 08:26:02 -07:00
Juliusz Sosinowicz 291c538e5f Ignore session ID's shorter than 32 bytes instead of erroring out 2023-06-27 14:51:46 +02:00
Sean Parkinson 578f56e60c Test api.c: change more tests to use Expect instead of Assert
bio.c:
  wolfSSL_BIO_flush(): check allocation to bio->ip succeeded.

internal.c:
  InitSSL_Ctx(): set ctx->heap to heap if value passed in
ProcessPeerCerts(): check for error MEMORY_E too as a fatal parsing
error

ssl.c:
wolfSSL_shutdown(): SOCKET_ERROR_E is also an indication that the
socket is done, MEMORY_E is a fatal error
  wolfSSL_Cleanup(): move free of memory fail couting to wolfSSL API
  SessionTicketNoncePrealloc(): eror return must be non-zero
AddSessionToCache(): XFREE checks for NULL no need to do it before
call
wolfSSL_set_psk_use_session_callback(): ensure ssl is not NULL before
dereferencing
wolfSSL_SMIME_read_PKCS7(): check for error return from
wolfSSL_BIO_gets()

asn.c:
  wc_MIME_parse_headers(): check allocation succeeded into nextHdr

compress.c:
  wc_DeCompressDynamic(): free tmp on inflateInit2 failure

memory.c: rework where memory allocation failure counting code for when
WOFLSSL_STATIC_MEMORY is defined

wc_port.c:
wolfCrypt_Cleanup(): only call wc_MemFailCount_Free() when no
wolfSSL_Cleanup()
2023-06-27 08:01:33 +10:00
Sean Parkinson b7332e33c7 Tests api.c: fixes
NULL dereference.
Uninitialized variable use.
2023-06-26 16:04:24 +10:00
David Garske 6697181081
Merge pull request #6500 from SparkiDev/tests_api_expect_4
Test api.c: change more tests to use Expect instead of Assert
2023-06-21 17:17:37 -07:00
Sean Parkinson e467112a93 Test api.c: change more tests to use Expect instead of Assert
Changed EXPECT_DECL to start of as TEST_SKIPPED.
Modified other EXPECT macros appropriately.
Change test functions to not use 'res' when EXPECT_DECL is used.

memory.c:
  wc_MemFailCount_Init(): don't declare variable after a statement

conf.c:
wolfSSL_TXT_DB_read(): free the whole WOLFSSL_TXT_DB on failure
instead of just the memory
wolfSSL_CONF_add_string(): pop the value added into section->value
(sk) if it can't be pushed onto conf->data
  wolfSSL_NCONF_load(): free the new value if it wasn't able to be added

ocsp.c:
  wolfSSL_OCSP_cert_to_id():
free the decoded certificate if parsing failed (is freed after use
otherwise)
free the certificate id on failure and make it NULL and continue
freeing other variables

pk.c:
wolfSSL_RSA_set0_crt_params(): set dmp1, dmq1 and iqmp fields to NULL
if setting the internal failed - returns error and caller needs to free
the passed in BNs
wolfSSL_RSA_set0_factors(): set p and q fields to NULL if setting the
internal failed - returns error and caller needs to free the passed in
BNs
wolfSSL_RSA_set0_key(): set n, e abd d fields to NULL if setting the
internal failed - returns error and caller needs to free the passed in
BNs

x509.c:
wolfSSL_X509_set_serialNumber(): explicit NULL
checkwolfSSL_X509_REQ_add1_attr_by_NID(): check whether push succeeded
and on failure free attribute

asn.c:
ConfirmSignature(): for DSA, allocate separately to ensure no leak on
memory allocation failure.

dh.c:
wc_DhGenerateParams(): ensure tmp and tmp2 are able to be cleared on
error

evp.c:
wolfSSL_EVP_PKEY_CTX_add1_hkdf_info(): fix realloc use to no leak on
failure
  wolfSSL_EVP_CIPHER_CTX_iv_length(): handle ctx being NULL.
2023-06-22 08:21:17 +10:00
JacobBarthelmeh 0a860c793f adjust test case to handle error of peer closing down 2023-06-14 12:21:52 -07:00
John Safranek 7b0283fa04
Implicit Type Conversion Fix
1. Typecast the return of strlen() to int for the variable used.
2023-06-09 11:13:44 -07:00
Sean Parkinson e5bb09f281 Coverity fixes: api.c
Fixes from coverity scan in the file api.c.
2023-06-08 22:18:05 +10:00
JacobBarthelmeh 8583cc65fa
Merge pull request #6471 from SparkiDev/tests_api_expect_3
Test api.c: change more tests to use Expect instead of Assert
2023-06-07 11:22:23 -06:00
JacobBarthelmeh 1445a6a832
Merge pull request #6482 from SparkiDev/regression_fixes_7
Regression testing fixes
2023-06-07 11:18:36 -06:00
JacobBarthelmeh 2b054e223b
Merge pull request #6483 from SparkiDev/cppcheck_fixes_10
cppcheck: fixes from scan
2023-06-07 11:13:53 -06:00
Sean Parkinson ed01b14356 cppcheck: fixes from scan
wolfssl_sce_unit_test.c:
  sce_crypt_Sha_AesCbcGcm_multitest(): duplicate condition
ssl_asn1.c:
  wolfSSL_i2t_ASN1_OBJECT(): done is not needed
  MonthStr(): fix bounds check on i
woolfcrypt_test.c, test_main.c, wolfssl_tsip_unit_test.c, devices.c,
aes.c, des3.c:
  Variable not used.
asn.c:
DecodeSubjKeyId(): sz is unsigned - check for less than zero does
nothing
kcapi_rsa.c:
  KcapiRsa_Decrypt(): fix ret check by using else
  KcapiRsa_Encrypt(): make same change for consistency
kcapi_hash.c:
  KcapiHashFinal(): move ret into #ifdef where it is needed
stm32.c:
wc_Stm32_Hash_GetDigest(): i redeclared with different type - use ii
instead
bio.c, conf.c:
  XFREE checks for NULL

Reduce scope of varialbes.
Condition same.
2023-06-07 17:27:51 +10:00
Sean Parkinson b07c5d7ce8 Regression testing fixes
Fix: ./configure --disable-shared  --enable-smallstack --enable-all
CFLAGS=-DNO_ASN_TIME

Don't compile mp_test when compiling for SP Math All and RSA
verification only - very few functions available.

ssl.c:
wolfSSL_Rehandshake(): wolfSSL_UseSessionTicket only available when
not NO_WOLFSSL_CLIENT
api.c:
  test_wolfSSL_ticket_keys(): meant to be tested on server
2023-06-07 14:26:45 +10:00
Sean Parkinson e542e51d9f Test api.c: change more tests to use Expect instead of Assert
bio.c:
  wolfSSL_BIO_push(): handles NULL for top and append.

crl.c:
InitCRL_Entry(): set toBeSigned to NULL after freeing when allocation
fails.
  AddCRL(): free CRL entry properly on error.
wolfSSL_X509_STORE_add_crl(): check for NULL after
wolfSSL_X509_crl_new call.

ssl.c:
wolfSSL_CertManagerGetCerts(): free the certificate if it didn't get
pushed onto stack
  wolfSSL_RAND_Init(): returns success if global already initialized.

ssl_asn1.c: wolfSSL_ASN1_TYPE_set now avaiable when OPENSSL_EXTRA
defined for function wolfssl_dns_entry_othername_to_gn().

x509.c:
Added support for creating a valid General Name of type GEN_OTHERNAME.
Extracted some code out into wolfssl_x509_alt_names_to_gn().
  wolfSSL_X509_set_ext(): free data correctly on errors
wolfSSL_X509_PUBKEY_set(): free str if DSA parameters cannot be
retrieved; wolfSSL_OBJ_nid2obj() called separately to handle when
returning NULL.
wolfSSL_X509_NAME_copy(): check for failure when
wolfSSL_X509_NAME_add_entry() is called.

x509_str.c:
wolfSSL_X509_STORE_CTX_new(): check for error from calling
wolfSSL_X509_STORE_CTX_init().
wolfSSL_X509_STORE_get0_objects(): don't double free x509; free memory
correctly on error
2023-06-07 14:10:42 +10:00
Hideki Miyazaki 5624df95b5
fix uninit var 2023-06-07 07:43:02 +09:00
Daniel Pouzzner 6c4cc2a931 tests/api.c: fix a likely-spurious maybe-uninitialized from gcc-11 -m32 (all-sp-m32) in test_wolfSSL_PEM_PrivateKey(). 2023-06-03 10:41:15 -05:00
Daniel Pouzzner 291be53524 tests/api.c: fixes for clang-diagnostic-embedded-directive (also warned by gcc), clang-analyzer-core.UndefinedBinaryOperatorResult, and clang-analyzer-deadcode.DeadStores. 2023-06-02 11:06:16 -05:00
JacobBarthelmeh 35e59a3569
Merge pull request #6456 from SparkiDev/tests_api_expect_2
Test api.c: change more tests to use Expect instead of Assert
2023-06-01 10:29:52 -06:00
Chris Conlon 806c75d28b
Merge pull request #6450 from miyazakh/fix_jenkins_android
fix to cast diff type, int and uint
2023-06-01 08:33:02 -06:00
Sean Parkinson 7259351a3f Test api.c: change more tests to use Expect instead of Assert
Added a new version of 'nofail' handshaking that doesn't use threads.
More tests can be run in single threaded.

Changed tests over to use test_wolfSSL_client_server_nofail() or
test_wolfSSL_client_server_nofail_memio() to simplfy test cases.

Changed tests to use Expect.

CRL:
BufferLoadCRL wasn't freeing allocated data when currentEntry
couldn't be allocated.

ssl.c:
DecodeToX509(): Needs to call FreeDecodedCert even if
ParseCertRelative fails.
wolfSSL_PEM_read_PUBKEY(): Need to check result of
wolfSSL_d2i_PUBKEY is NULL rather than the passed in WOLFSSL_EVP_PKEY.

X509:
wolfSSL_X509_set_ext(): Must free allocated WOLFSSL_X509_EXTENSION
if not pushed on to stack regardless of stack being NULL.
wolfSSL_X509V3_EXT_i2d(): Don't free asn1str on error as it is the
data passed in.
wolfSSL_i2d_X509_NAME_canon(): free names and cano_data when call to
wolfSSL_ASN1_STRING_canon() fails.

PKCS7:
    wc_PKCS7_InitWithCert(): Check memory allocation of cert for NULL.
2023-06-01 14:22:00 +10:00
Daniel Pouzzner c45efd79af api.c: fix 3 missed EXPECT_RESULT() == WOLFSSL_SUCCESSes to use the succincter EXPECT_SUCCESS(). 2023-05-31 18:26:27 -05:00
Daniel Pouzzner 64c9026c77 wolfssl/wolfcrypt/types.h: add PRAGMA_DIAG_PUSH, PRAGMA(), and PRAGMA_DIAG_POP(), using the gcc or clang variants as applicable, to facilitate pragmas to be used on both gcc and clang;
tests/unit.h: fix ExpectPtr() to inhibit pedantic warnings on both gcc and clang;

wolfssl/test.h: in myVerify(), explicitly check for nullness when printing issuer/subject, to avoid cppcheck null-deref warning;

tests/api.c: fixes for:

* myriad "embedding a directive within macro arguments is not portable"
* an "ISO C forbids conversion of object pointer to function pointer type"
* some "stringop-overflow"s
* a clang-analyzer-core.uninitialized.Assign
* a clang-analyzer-core.CallAndMessage "2nd function call argument is an uninitialized value"
* a nullPointerRedundantCheck
* several clang-diagnostic-declaration-after-statement
* a spurious gcc sanitizer maybe-uninitialized in test_wolfSSL_CheckOCSPResponse()
2023-05-31 15:19:15 -05:00
JacobBarthelmeh 80311975ce
Merge pull request #6452 from anhu/no_rsa_sigalgs
For NO_RSA, don't advertise support for RSA.
2023-05-31 13:41:56 -06:00
Hideki Miyazaki 554e6472b5
addressed review comments 2023-05-31 06:54:14 +09:00
Chris Conlon 769c488d18
Merge pull request #6444 from night1rider/wolfssl-Onboarding
added test case for wolfSSL_configure_args
2023-05-30 13:03:05 -06:00
Anthony Hu ea6155c924 For NO_RSA, don't advertise support for RSA. 2023-05-30 12:34:23 -04:00
Hideki Miyazaki 63a5fe3229
fix to cast diff type, int and uint 2023-05-30 17:32:42 +09:00
Sean Parkinson 541ea51ad5 Tests api.c: rework for malloc failure testing
Modified number of tests to not crash on failure and cleanup allocations
on failure.
Added memory fail count option to set which memory allocation to start
failing on.
Fix issues found from testing.

bio.c:
BIO_new() move ref count up so that calls to wolfSSL_BIO_free()
work.
internal.c:
ImportCipherSpecState wasn't checking SetKeySide for failure. Crash
when pointer is NULL and accessed directly.
ocsp.c:
wolfSSL_OCSP_response_get1_basic() doesn't need to free vs->source
as it is freed in WOLFSSL_OCSP_RESPONSE_free().
ssl.c:
ProcessBuffer() Don't strip PKCS#8 header if failed to create DER.
Crasged as directly accessing 'der' which was NULL.
ssl_asn.c:
wolfssl_asn1_integer_require_len was checking wrong variable to see
if allocation failed.
x509,c:
wolfSSL_X509_ALGOR_set0 needs to set aobj only when no failure
possible.
wolfSSL_X509_chain_up_ref needs to call cleanup to ensure everything
is freed.
2023-05-30 12:01:21 +10:00
Sean Parkinson 37c03e3f11
Merge pull request #6442 from embedded-specialties/int-sequence
ASN.1 Integer sequence
2023-05-30 09:37:55 +10:00
Joe Hamman d340587035 Added valid ASN.1 integer value to test_asn1 2023-05-28 21:18:45 -04:00
dell5060 c0116d6026 added test case for wolfSSL_configure_args and added fix
new fix

removing redundant () in code
2023-05-26 16:45:13 -06:00
Anthony Hu 87bbcbb96a Fix a syntax error.
Tested with:
    ./configure --enable-debug --enable-all CFLAGS=-DDEBUG_WOLFSSL_VERBOSE
2023-05-26 16:12:14 -04:00
Joe Hamman 8bd3850e58 Added ASN.1 Integer sequencing 2023-05-24 17:28:53 -04:00
JacobBarthelmeh 1218cfb7f2
Merge pull request #6087 from rizlik/embed_recv_from_fix_peer
dtls: improve different peer recvfrom and better error reporting on ipv6
2023-05-24 13:54:40 -06:00
JacobBarthelmeh 188a99bd5a
Merge pull request #6438 from anhu/ext_cache
Without HAVE_EXT_CACHE session dup is not compiled in
2023-05-24 11:15:00 -06:00
Anthony Hu 87a7af05dd Without HAVE_EXT_CACHE session dup is not compiled in 2023-05-24 12:14:02 -04:00
Marco Oliverio f21c34b08d tests: EmbedRecvFrom/EmbedSendTo error if ipv6 w/o ipv6 compiled in 2023-05-22 15:33:06 +00:00
Marco Oliverio b4542ed270 tests: add dtls ignoring different peer test 2023-05-22 15:32:57 +00:00
Marco Oliverio 5f293bf736 tests: add test_wolfssl_client_server_no_fail(_ex) to set client cb 2023-05-22 15:31:58 +00:00
Marco Oliverio cff580b4f0 tests: api: error out on read error in test_server_nofail 2023-05-22 15:31:58 +00:00
JacobBarthelmeh a06bd777c0
Merge pull request #6423 from cconlon/pkcs7NoStream
Fix PKCS#7 build with NO_PKCS7_STREAM
2023-05-19 10:32:49 -06:00
Marco Oliverio 35185e1a59 tests: add dtls13 null cipher test 2023-05-19 08:10:26 +00:00
Chris Conlon 6ef580ca59 fix PKCS#7 build when using NO_PKCS7_STREAM 2023-05-18 14:50:03 -06:00
JacobBarthelmeh 53ef26bf3a
Merge pull request #6392 from rizlik/dtls13-fix-ch-epoch
DTLS v1.3: fix epoch 0 check on plaintext message
2023-05-16 10:07:14 -06:00
Lealem Amedie 3f795f2f47 Fixes for wolfcrypt test without ECC SECP 2023-05-15 14:12:24 -06:00
Kareem f1ad37919d Add test case for ASN1_TIME_to_tm fix. 2023-05-12 14:30:55 -07:00
Marco Oliverio 5773252e33 test: add check that CH with epoch != 0 are ignored 2023-05-10 13:54:25 +00:00
JacobBarthelmeh cdeba4e1b0
Merge pull request #6364 from anhu/compat_unknown_oid
Allow for unknown OIDs in extensions in wolfSSL_X509_set_ext()
2023-05-08 14:51:35 -06:00
Sean Parkinson d2afe9e5e0 Memory usage improvements
ECC: make private key field 'k' able to be smaller when ALT_ECC_SIZE is
defined.
WOLFSSL_SMALL_STACK_CACHE: allocate temps using new macros.
2023-05-04 10:26:57 +10:00
Anthony Hu 0ebe5819d0 Allow for unknown OIDs in extensions in wolfSSL_X509_set_ext()
...and add some testing to show we properly inserted the extensions.
2023-05-02 12:43:14 -04:00
Marco Oliverio 3e4b95eb4b test: fix test AEAD limit server set fds as nonblock 2023-05-02 16:34:01 +00:00
David Garske 52a20fc2b5
Merge pull request #6328 from julek-wolfssl/zd/16000
Allow cert callback to override skipAddCA
2023-04-28 10:25:13 -07:00
Juliusz Sosinowicz bf2c66a1cb Allow cert callback to override skipAddCA 2023-04-27 10:07:04 +02:00
TakayukiMatsuo 4c47934562 Fix issues in test_wolfSSL_dtls_fragments 2023-04-27 17:00:29 +09:00
JacobBarthelmeh 5c97dfbb4c
Merge pull request #6334 from SparkiDev/openssl_ec_set_priv_key_check
OpenSSL EC API: fix setting private key
2023-04-25 16:32:53 -06:00
Sean Parkinson 673d72a2dc OpenSSL EC API: fix setting private key
wolfSSL_EC_KEY_set_private_key() should fail on obvious bad private key
values.
2023-04-24 17:59:32 +10:00
Sean Parkinson 6634ec198e BN_to_ASN1_INTEGER: fix handling of padding
Incorrect calculation of when padding byte needed and consequently
adding byte manually when properly handled by SetASNInt().
2023-04-24 09:30:38 +10:00
tmael 1106e5ff0e
TLS v1.3: Support a stateful ticket and test HAVE_EXT_CACHE (#5960)
* Add TLSv1.3 stateful support
Fix internal and external session cache

* session cache fixes

* Refactor

- implement wolfSSL_CTX_flush_sessions
- use wolfSSL_CTX_flush_sessions to make test_wolfSSL_CTX_add_session_ext deterministic
- add dtls to test_wolfSSL_CTX_add_session_ext
- DoClientTicket_ex does not modify ssl object
- only call session remove callback on:
  - timeout
  - session is being overwritten/removed from the cache

* Session fixes

- restore bogus ID on session duplicate
- don't evict on overwrite
- use memmove instead on memcpy as `ssl->session == session` is possible
- ignore ClientSession parameter in AddSessionToCache on NO_SESSION_CACHE_REF
- use sessionID when altSessionID not present

* Session fixes

- DoClientTicketFinalize: always copy in the ID as teh altSessionID
- don't overwrite ex_data when overwriting cacheSession and cacheSession owns it

* Callback wants to retain a copy

* wolfSSL_GetSessionClient: ssl->ctx->get_sess_cb does not apply here

* test_wolfSSL_CTX_add_session_ext 

gate expected results on WOLFSSL_DTLS_NO_HVR_ON_RESUME

* TlsSessionIdIsValid: copy return can't be ignored

* Silence unused parameter

* test_wolfSSL_CTX_add_session_ext: handle async case

* Gate wolfSSL_SSL_CTX_remove_session on NO_SESSION_CACHE

* ssl.c: style fixes

* Add twcase_get_sessionCb_cleanup to free external cache

* Remove hard tab

* Correct build error in wolfSSL_CTX_flush_sessions

* Jenkins fixes:

- altSessionID only available with WOLFSSL_TICKET_HAVE_ID
- slim out psk_sess_free_cb_ctx

* Stateful dtls case has 2 accesses. Stateless just one.

* Add version numbering to hostap logs

* Import internal.h for test_wolfSSL_SESSION_get_ex_new_index

* wolfSSL_SetSession: don't check SslSessionCacheOff for session setting

* wolfSSL_SetSession: fully set expired session for OpenSSL compatibility

* wolfSSL_SetSession: check if setting same object

* AddSession: always populate the session object to allow re-use

* Add logging to wolfSSL_NewSession and wolfSSL_FreeSession

* Always setup session object

* Check if session has been setup before setting it

* Print errors in async test

* Make SetupSession available outside NO_SESSION_CACHE

* Review comments

* Fix ticBuf leak and TlsSessionIdIsValid logic

* Fix unmatched curly brackets

* TlsSessionIdIsValid: always need to check copy var

* TlsResumptionIsValid: set resume to FALSE default

* wolfSSL_SetSession: remove now variable since only used in one place

* Move internalCacheLookupOff into HAVE_EXT_CACHE block

---------

Co-authored-by: Juliusz Sosinowicz <juliusz@wolfssl.com>
2023-04-21 06:46:08 -07:00
Anthony Hu b0e90b6ffe Should not be an error to call wolfSSL_X509_REQ_add_extensions with empty stack. 2023-04-18 12:27:54 -04:00
Anthony Hu 120d1f0d1a Support in the compatibility layer for UPN and SID. 2023-04-17 14:42:27 -04:00
JacobBarthelmeh 36a9b9944c fix guard on ECC export 2023-04-13 16:12:08 -07:00
Chris Conlon bd02b9c29c
Merge pull request #6254 from miyazakh/fix_favouriteDrink 2023-04-06 09:39:23 -06: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
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
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
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
Sean Parkinson 9eac521521 ASN.1 testing: restore 0 length BIO failure tests
Create a fixed buffer BIO of length 1 and then write one byte into it so
that there is 0 length to write into.
Test cases removed as setting fixed buffer BIO to length 0 allocated 0
length buffer that is sometimes returning NULL.
2023-04-05 10:29:46 +10:00
Hideki Miyazaki 9eb3c4d31a
fix unitest failure 2023-04-05 07:25:25 +09:00
JacobBarthelmeh cb422bfaf7
Merge pull request #6242 from julek-wolfssl/harden-tls
Implement TLS recommendations from RFC 9325
2023-04-04 10:13:27 -06:00
Daniel Pouzzner c08878ac94 configure.ac: include both -I. and -I$srcdir for "circular dependency" test, so that ${build_pwd}/wolfssl/options.h is found in out-of-tree builds; streamline scripting that dynamically sets $TRIM;
linuxkm/module_exports.c.template: include wolfssl/wolfcrypt/wolfmath.h, to bring in wc_GetMathInfo() prototype;

src/ssl.c: move "Global pointer to constant BN on" to src/ssl_bn.c; and in wolfSSL_Cleanup(), call the new wolfSSL_BN_free_one() rather than using ad hoc cleanup logic;

src/ssl_bn.c: add bn_one and wolfSSL_BN_free_one();

src/ssl_asn1.c: fix bugprone-macro-parentheses in bufLenOrNull(); refactor wolfSSL_ASN1_TIME_diff() to avoid floating point math; use intermediate tm_year variable in wolfssl_asn1_time_to_tm() to avoid target-specific type conflicts on tm->tm_year; use "FALL_THROUGH", not "/* fall-through */", in wolfSSL_ASN1_TYPE_set (clang-diagnostic-implicit-fallthrough);

wolfcrypt/src/ecc.c: fix identicalInnerCondition in ecc_mul2add();

wolfcrypt/src/integer.c: refactor OPT_CAST()s in mp_grow() to unconditional casts as elsewhere, to mollify a confused cppcheck-all-intmath;

tests/api.c: reformat some overlong lines.
2023-04-03 15:49:39 -05:00
Andras Fekete c56e58db5b Remove TODO+bad tests 2023-03-31 15:51:28 -04:00
Andras Fekete 18f4b45129 Fix object size 2023-03-31 15:44:25 -04:00
Andras Fekete 80a0fb548a Zero buffer size test should be implemented another way 2023-03-31 15:44:13 -04:00
Hideki Miyazaki 27f5f3a3e8
fix overwriting serialnum by favouriteDrink 2023-03-31 15:56:31 +09:00
Sean Parkinson 8489095057 Move ASN.1 APIs out to separate file: ssl_asn1.c
Implementations of ASN.1 APIs reworked.

Added tests.

Added wolfssl_bn_set_neg for ASN.1 code.
Added wolfssl_sk_new_type() and wolfssl_sk_pop_type() to generically
handle creating and popping a stack of elements of a type.

No longer freeing pathlen field of ASN1 OBJECT in
wolfSSL_X509_EXTENSION_free(). This is happening in
wolfSSL_ASN1_OBJECT_free().
Stop wolfSSL_i2d_X509_NAME_canon from double freeing ASN.1 STRING's data
field.

Fixed up GetFormattedTime() to be better code.
Added ASN_CLASS_MASK to mask off the class part of an ASN.1 tag.
NO_ASN_TIME means no implementation to get the current time. Disable
features that won'r work without time.
2023-03-31 09:36:01 +10:00
David Garske 22a5a5c45e Add introspection for math build and math cleanups:
* Add introspection for math build.
* Raise build error if more than one multi-precision math library used.
* Fix ESP32 to support using any multi-precision math option.
* Refactor math headers to use `wolfmath.h`
* Refactor of the opaque math variable type `MATH_INT_T` used by crypto hardware (QuickAssist, SE050, ESP32 and STM32).
* Cleanups for building with `WOLFCRYPT_ONLY` and `NO_BIG_INT`.
* Stop forcing use of fast math by default for platforms in settings.h. Note: For users that still want to use fast math (tfm.c) they will need to add USE_FAST_MATH to their build settings.

Applies To:
```
WOLFSSL_ESPWROOM32
WOLFSSL_ESPWROOM32SE
MICROCHIP_PIC32
WOLFSSL_PICOTCP_DEMO
WOLFSSL_UTASKER
WOLFSSL_NRF5x
FREERTOS_TCP
WOLFSSL_TIRTOS
EBSNET
FREESCALE_COMMON
FREESCALE_KSDK_BM
WOLFSSL_DEOS
MICRIUM
WOLFSSL_SGX
```
2023-03-30 14:42:55 -07:00
Lealem Amedie 8e730534d5 Free in drbg test when appropriate 2023-03-29 10:26:59 -06:00
Lealem Amedie 65f97482f3 Missed free's in api.c 2023-03-29 10:16:29 -06:00
Juliusz Sosinowicz f0ad01f552 Send secure renegotiation extension by default
- Add test for terminating the connection
- Add ProcessReplyEx(ssl, 1) to wolfSSL_accept
2023-03-28 12:43:53 +02:00
JacobBarthelmeh 7e8d027a17
Merge pull request #6217 from douzzer/20230321-fixes
20230321-fixes
2023-03-22 10:23:07 -06:00
Daniel Pouzzner 49cd3ff872 wolfssl/internal.h: fixes for -Wpedantic "redefinition of typedef" around typedef ... TLSX and Options;
src/internal.c: fix for -Wdeclaration-after-statement and clang-diagnostic-unreachable-code-break;

tests/api.c: fix for -Wunused-variable and clang-analyzer-deadcode.DeadStores;

olfcrypt/src/pkcs12.c: fixes for cppcheck uselessAssignmentPtrArg and arrayIndexThenCheck, and clang-tidy clang-analyzer-deadcode.DeadStores and clang-analyzer-core.NonNullParamChecker;

wolfssl/src/tls.c: fix for clang-analyzer-deadcode.DeadStores;

wolfcrypt/src/tfm.c: fix for clang-diagnostic-newline-eof;

src/tls13.c: fix for clang-analyzer-core.NonNullParamChecker.
2023-03-21 22:52:56 -05:00
JacobBarthelmeh 147395476f
Merge pull request #6213 from SparkiDev/regression_fixes_6
Regression testing fixes
2023-03-21 20:17:30 -06:00
Sean Parkinson 9ec742b11f Regression testing fixes
HAVE_ECH only used by TLS 1.3 add protection around all code.
ssl->options.onlyPskDheKe only available when HAVE_SUPPORTED_CURVES.
CleanupClientTickets() defined when HAVE_SUPPORTED_CURVES.
TLSX_KeyShare_DeriveSecret only defined when HAVE_SUPPORTED_CURVES.
DecodeResponseData - initialize variable single.
New OpenSSL compatibility BN code requires mp_read_radix - turn on in
integer.c, sp_int.c when OPENSSL_EXTRA defined.
rsa.c:_CheckProbablePrime - make sure tmp1 and tmp2 are initialized
before error handling jumps to freeing them.

test_remove_hs_message uses 1024-bit DH key which is not supported when
using SP math with SP.
2023-03-22 08:57:20 +10:00
Sean Parkinson 17e20b8c36 Server ID - long id, TLS 1.3 - cache client session for tickets
Long server IDs were being truncated. Hash long IDs instead.
TLS 1.3 session ticket on client side no longer added session to client
cache. Explicit call added.
2023-03-21 15:29:07 +10:00
JacobBarthelmeh 0e431c3eaa add given name test case 2023-03-17 13:07:15 -07:00
JacobBarthelmeh 06d970c999
Merge pull request #6181 from kareem-wolfssl/zd15767
Fix not ignoring date errors when VERIFY_SKIP_DATE is set
2023-03-17 10:53:41 -06:00
JacobBarthelmeh 042ceff08e
Merge pull request #6160 from lealem47/indefPKCS12
Adding support for indefinite length PKCS12
2023-03-17 10:45:46 -06:00
Sean Parkinson 21c5ecc371
Merge pull request #6179 from tim-weller-wolfssl/zd14527-pemtoder-return-size
zd14527 - Update `PubKey` and `Key` PEM-to-DER APIs to support return of needed DER size
2023-03-17 08:37:51 +10:00
Kareem cc51b2d52e Add additional fix for absolute URN issue from PR #5964 and add test. 2023-03-16 14:56:44 -07:00
Kareem 28f39f6b3d Fix unit test failure when building OPENSSL_EXTRA without HAVE_EXT_CACHE. 2023-03-16 14:25:42 -07:00
Marco Oliverio 94d983f94a tests: add WOLFSSL_EXTRA_ALERTS tests 2023-03-14 13:27:40 +00:00
tim-weller-wolfssl 52105a10c9 Add means to get size of DER buffer size needed for PEM-to-DER conversion to Key and PubKey APis 2023-03-14 06:33:12 -05:00
JacobBarthelmeh 694b527e67
Merge pull request #5910 from julek-wolfssl/dtls13-stateless
DTLS 1.3 stateless server ClientHello parsing
2023-03-13 09:22:58 -06:00
Lealem Amedie 1c9fa5c5ae Set some freed data to NULL 2023-03-10 13:40:25 -07:00
Chris Conlon d03347d79c fix GetAsnTimeString() to correctly increment data_ptr, fixes PKCS#7 signedData signingTime attribute 2023-03-08 16:39:49 -07:00
Juliusz Sosinowicz 335722c586 Async fixes 2023-03-07 12:04:54 +01:00
Juliusz Sosinowicz f5f67f43d7 Reset DTLS sequence number 2023-03-07 12:04:54 +01:00
Juliusz Sosinowicz b0d7656ad2 Rebase fixes 2023-03-07 12:04:54 +01:00
Juliusz Sosinowicz 885cca67fe Check for shared ctx in all configs 2023-03-07 12:04:54 +01:00
Juliusz Sosinowicz 5f39c594aa TLS 1.3: hold decrypted ticket to check which ciphersuite matches
DTLS 1.3: Move stateless ticket decoding to FindPskSuiteFromExt
2023-03-07 12:04:54 +01:00
Juliusz Sosinowicz aa9dcca624 Rebase and Jenkins fixes 2023-03-07 12:02:54 +01:00
Juliusz Sosinowicz 984d709db0 dtls 1.3: Stateless ClientHello parsing 2023-03-07 12:02:54 +01:00
Chris Conlon 9bc3b867e0
Merge pull request #6157 from miyazakh/add_favouriteDrinkNID 2023-03-06 16:45:14 -07:00
David Garske 86e1b0d8ab
Merge pull request #6165 from SparkiDev/bn_move
BN compatibility API: move implementation out to separate API
2023-03-06 09:27:24 -08:00
Sean Parkinson e4c2386b61 BN compatibility API: move implementation out to separate API
BN APIs from ssl.c have been moved out to ssl_bn.c that is included in
ssl.c.
Added defines for BN_rand() and BN_pseudo_rand() to indicate which bits
are to be set.
'internal' field now always maps to the ;mpi' field that is a MP
integer.
SetIndividualInternal/External renamed to wolfssl_bn_get/set_value.
Fixed BN APIs to work as closely to OpenSSL as possible.
Added tests.
Moved wolfssl_make_rng out to ssl.c as BN APIs are using it now.
SP int and TFM now check trials are in a valid range for
mp_prime_is_prime_ex().
2023-03-06 14:32:10 +10:00
Hideki Miyazaki 05b0796361
add favourite drink pilot attibute type to get it from the encoding 2023-03-04 14:20:48 +09:00
Daniel Pouzzner ab71f6fd4c extend C89 build to whole codebase including examples:
configure.ac: remove implied --disable-examples when --disable-inline;

tests/api.c: always include wolfcrypt/src/misc.c;

wolfcrypt/src/misc.c: use WC_MISC_STATIC to designate staticness of the misc functions;

wolfssl/wolfcrypt/misc.h: define WC_MISC_STATIC to empty or static depending on #ifdef NO_INLINE or not (respectively);

wolfssl/wolfcrypt/types.h: #ifdef NO_INLINE, #define WC_INLINE WC_MAYBE_UNUSED, and move the definitions of WARN_UNUSED_RESULT and WC_MAYBE_UNUSED above the definition of WC_INLINE for clarity;

wolfssl/wolfcrypt/mem_track.h: always declare TrackMalloc() et al static (no functional change, because the state and callback bindings were and remain unconditionally static, but previously #ifdef NO_INLINE the functions were globals, leading to multiple definitions.
2023-03-03 22:30:08 -06:00
Hideki Miyazaki 0693b66c44 fix init var in for-loop 2023-03-03 17:51:34 +09:00
Andras Fekete aff4d4a7d3 The size of the packet could vary by up to 5 bytes 2023-02-28 17:04:40 -05:00
Anthony Hu c2daca1393 Fixes for encoding/decoding ecc public keys. 2023-02-23 13:56:48 -05:00
tim-weller-wolfssl dea123f88e Minimal changes to avoid Out-of-Bounds write in ASN.1 parsing logic. Add unit tests for ParseCert() API passing badly formed ASN data (should error out gracefully). 2023-02-16 07:49:08 -06:00
David Garske 18bee3142d Fix to use the right cert/key in the API unit test if overridden. 2023-02-15 14:57:43 -08:00
David Garske 47801107da Fix to make sure API unit test always calls init/cleanup when not running all tests. 2023-02-15 14:24:22 -08:00
Juliusz Sosinowicz 0cedc4e1ac
stunnel 5.67 support (#6020)
* stunnel 5.67 support

- ssl->session->ticketAdd may be set when parsing a ticket before PSK
- PSK binders should be calculated based on ciphersuite associated with PSK
- Add option to prioritise PSK order instead of ciphersuite order
- Update ctx->method->version when using Set_CTX_max_proto_version API
- Simplify wolfSSL_parse_cipher_list
  - Keep copy of old list and then add in the previous ciphersuites depending on whether we are doing only TLS 1.3 ciphersuites or not
- Specify CRL revocation in alert
  - Match reason string to match OpenSSL
- Add support for external data callbacks for WOLFSSL_SESSION

* Upref the session for stunnel instead of duplicating it

* Add small stack option for wolfSSL_parse_cipher_list
2023-02-14 09:38:28 -08:00
tmael c4fa013800
Fix for BIO_reset() (#5887)
* Fix for BIO_reset
* Introduced BIO_FLAGS_MEM_RDONLY
2023-02-14 08:54:25 -08:00
Sean Parkinson 2fe34facba
Merge pull request #6084 from philljj/zd15607
Check keyLen matches cipher in wolfSSL_CMAC_Init.
2023-02-14 12:51:20 +10:00
Sean Parkinson 0a8753d2b2 ASN template, DSA: Clear the mp_int before re-reading data
Make sure the mp_int is cleared so that any exisiting bigint is freed.
Tidy up api.c code.
2023-02-13 11:08:18 +10:00
jordan 909aa86d2d Check keyLen matches cipher in wolfSSL_CMAC_Init.
Fixes ZD15607.
2023-02-12 18:26:40 -06:00
David Garske 7f9b764eb5
Merge pull request #6054 from anhu/d2i_publickey_fix
Ensure that i2d APIs for public keys gives appropriate data.
2023-02-08 14:44:29 -08:00
Anthony Hu 7a6ed68f2d Ensure that i2d APIs for public keys gives appropriate data. 2023-02-08 09:54:28 -05:00
Sean Parkinson 1912aaf91b EC OpenSSL compat: validate point after setting
wolfSSL_EC_POINT_set_affine_coordinates_GFp wasn't checking the point is
valid for the curve. Added call to check point when setting.
Made check available for opensslextra.
Fixed test to have valid ordinates to set.
2023-02-07 18:17:39 -05:00
David Garske 2448adf68b
Merge pull request #6051 from philljj/zd15531
Fix wolfSSL_ASN1_INTEGER_to_BN for negative values
2023-02-06 12:46:21 -08:00
David Garske 8a212ec351
Merge pull request #6042 from SparkiDev/ec_point_set
EC OpenSSL compat: validate point after setting
2023-02-06 07:14:19 -08:00
Sean Parkinson c9fefe660f EC OpenSSL compat: validate point after setting
wolfSSL_EC_POINT_set_affine_coordinates_GFp wasn't checking the point is
valid for the curve. Added call to check point when setting.
Made check available for opensslextra.
Fixed test to have valid ordinates to set.
2023-02-06 12:22:17 +10:00
David Garske a4ffe085a0
Merge pull request #6052 from rizlik/fix_ret_create
fix: propagate WOLFSSL_TICKET_RET_CREATE from DoDecryptTicket()
2023-02-03 17:32:26 -08:00
Marco Oliverio a9ffbae7af test: add test to check new ticket is created when resuming 2023-02-03 22:16:06 +00:00
JacobBarthelmeh f55f9bfd36 fix DTLS test case for when able to read peers close notify alert 2023-02-03 11:05:56 -08:00
jordan f61dce8746 Fix wolfSSL_ASN1_INTEGER_to_BN for negative values
Added mp_setneg for ZD#15531.
2023-02-03 08:51:46 -06:00
Sean Parkinson 3455e726f9 SP int: make used and size fields unsigned
used and size have no reason to be negative - change type.
Change code to match unsigned change. Mostly change variables to be
unsigned where possible.
integer.c: Only have mp_rand_prime available when needed and
mp_prime_is_prime_ex is available.
Fixes from regression testing.
2023-02-03 17:09:56 +10:00
Daniel Pouzzner 38c057a084 fix resource leak (missing calls to wc_AesFree()) in wolfSSL_EVP_CIPHER_CTX_cleanup();
fix file descriptor leaks in AF_ALG code, and fix return codes (WC_AFALG_SOCK_E, not -1) in afalg_aes.c;

fixes for sanitizer-detected forbidden null pointer args in AfalgHashUpdate() and AfalgHashCopy();

fixes for resource leaks in api.c test_wolfSSL_AES_cbc_encrypt() (missing wc_AesFree()s);

fixes for resource leaks in test.c openssl_test() (missing wolfSSL_EVP_CIPHER_CTX_cleanup());

also some local fixes for bugprone-signed-char-misuse, readability-redundant-preprocessor, and clang-diagnostic-strict-prototypes, in src/pk.c and src/ssl.c.
2023-02-01 00:49:34 -06:00
David Garske 934d8e274f
Merge pull request #5926 from SparkiDev/openssl_ec_api_rework
EC OpenSSL compat: rework EC API
2023-01-31 09:08:26 -08:00
Sean Parkinson 7691cd4b45 EC OpenSSL compat: rework EC API
Reworked the implementations of the EC APIs including:
wolfSSL_EC_curve, wolfSSL_EC_METHOD, wolfSSL_EC_GROUP,
wolfSSL_EC_POINT, wolfSSL_EC_KEY, wolfSSL_ECDSA_SIG, wolfSSL_ECDSA and
wolfSSL_ECDH.

Added support for EC parameters to PEM decoding.

EccEnumToNID() moved out of wolfCrypt - it maps NIDs defined in
wolfssl/openssl/ec.h to those in wolfssl/wolfcrypt/ecc.h.
Moved wc_OBJ_sn2nid() out of wolfCrypt - implementation uses
EccEnumToNID().

Changed reference counding to use wolfSSL_Ref.

Added tests to api.c that increase coverage of EC APIs.
2023-01-31 10:19:57 +10:00
Kareem c70ca25282 Fix building NO_ASN_TIME with cert gen and OpenSSL Extra enabled. 2023-01-27 16:09:04 -07:00
Kareem 4542eb0df1 Fix NO_ASN_TIME support for ASN template, also fix expired certificate unit tests with NO_ASN_TIME defined. 2023-01-27 12:39:53 -07:00
David Garske 06509021ff
Merge pull request #6013 from douzzer/20230125-various-fixes
20230125-various-fixes
2023-01-26 15:10:18 -08:00
Daniel Pouzzner 84a5bb67f2 tests/api.c: in test_tls13_apis(), conditionalize expected return value of wolfSSL_CTX_set_max_early_data() on WOLFSSL_ERROR_CODE_OPENSSL (only affects !OPENSSL_EXTRA paths). 2023-01-26 14:56:50 -06:00
David Garske 10529e6199 Add `user_settings.h` template for wolfTPM 2023-01-26 10:40:59 -08:00
Sean Parkinson 53dfcd00e2 Ref count: change to use wolfSSL_Ref
Data structures changed:
WOLFSSL_CERT_MANAGER, WOLFSSL_CTX, WOLFSSL_SESSION, WOLFSSL_X509,
WOLFSSL_X509, WOLFSSL_EVP_PKEY, WOLFSSL_BIO, WOLFSSL_X509_STORE
2023-01-23 16:29:12 +10:00
tim-weller-wolfssl cf9b865e33 Update AES-GCM stream decryption setup to allow long IV values (already allowed by encryption APIs) 2023-01-20 20:35:39 +00:00
JacobBarthelmeh fc19aed8c8
Merge pull request #5623 from dgarske/hpke
Adds support for TLS v1.3 Encrypted Client Hello (ECH) and HPKE (Hybrid Public Key Encryption)
2023-01-19 10:03:28 -07:00
David Garske 6b6ad38e4f Adds support for TLS v1.3 Encrypted Client Hello (ECH) draft-ietf-tls-esni) and HPKE (Hybrid Public Key Encryption) RFC9180. 2023-01-18 11:37:27 -08:00
David Garske 41c35b1249 Fix line length and whitespace issues. Fix macro argument missing parentheses. 2023-01-18 11:10:19 -08:00
Juliusz Sosinowicz 1cb4615435 Add SCR reconnect test 2023-01-18 09:55:32 -08:00
Juliusz Sosinowicz e431688ca6 ssl->suites: use ssl->ctx->suites when possible
- Allocate ssl->suites when necessary for the WOLFSSL object to have its own instance. Use AllocateSuites() to allocate the object.
- Move cipher negotiation options from Suites into Options

ZD15346
2023-01-18 09:55:32 -08:00
Sean Parkinson b15bc3d236
Merge pull request #5977 from dgarske/kcapi_opensslextra
Fixes for building KCAPI with opensslextra enabled
2023-01-17 02:13:50 +10:00
David Garske fec4fe6095 Fixes for building KCAPI with opensslextra enabled. 2023-01-13 16:33:55 -08:00
jordan 4f4819bd19 EVP_EncryptUpdate should update outl on empty input 2023-01-13 11:32:15 -06:00
David Garske b2d8b1c2fd
Merge pull request #5954 from JacobBarthelmeh/Compatibility-Layer
very basic support for public key types in cipher list string with '+'
2023-01-09 15:46:50 -08:00
John Safranek 86aa3cc836
Merge pull request #5942 from bandi13/evpaesccm
Evpaesccm
2023-01-06 11:25:37 -08:00
JacobBarthelmeh 99a489dec3 improve test and handling of public key type cipher suite string 2023-01-06 09:53:51 -08:00
Andras Fekete 8436f82540 Adding in @ejohnstown's suggested patch for line lengths 2023-01-06 12:23:30 -05:00
Anthony Hu 5de817b0c1 Add wolfSSL_CertManagerLoadCABuffer_ex()
Also add unit tests.
2023-01-05 15:34:13 -05:00
Andras Fekete 124c04b01a A bit more consistent naming for structure variables 2023-01-04 21:04:58 -05:00
Andras Fekete 51f3386d60 Shorten variable names 2023-01-04 20:29:14 -05:00
JacobBarthelmeh a3e085f204 very basic support for public key types in cipher list string with '+' 2023-01-04 10:49:18 -08:00
Andras Fekete 0ec0c05eda Change variable names to protect the innocent 2023-01-04 10:23:42 -05:00
Juliusz Sosinowicz 8d59f61b9b Fix test_wolfSSL_dtls_stateless_resume test case 2023-01-04 13:04:45 +01:00
David Garske 023db01aca * Fixed some build configuration variations.
* Fixed `PEM_BUFSIZE` macro redefined when building with coexist.
* Updated the `user_settings_all.h` and `user_settings_wolfboot_keytools.h` to include latest options.
* Improved API unit test error case checking where `TEST_RES_CHECK` is not used.
* Changed `TEST_SKIPPED` to unique value.
* Added CI tests for enable-all, small stack, and user setting templates.
2023-01-03 10:59:59 -08:00
Jacob Barthelmeh 9dcc48c8f7 update copyright to 2023 2022-12-30 17:12:11 -07:00
Andras Fekete f734f5037d Add similar trick to GCM routines so our code is more uniform 2022-12-30 13:11:26 -05:00
Andras Fekete a00abb0f88 Fix compilation issue when AESCCM is not enabled 2022-12-30 13:10:24 -05:00
Jacob Barthelmeh aab12fc14b check DTLS method for test case 2022-12-29 15:49:46 -07:00
Andras Fekete 1132579dd1 Add in zero length test 2022-12-29 17:02:43 -05:00
Andras Fekete 1192d41f0e First successful implementation of EVP_aes_*_ccm 2022-12-29 17:02:43 -05:00
Eric Blankenhorn 004705b38f Fix unguarded XFPRINTF calls 2022-12-28 12:23:40 -06:00
Daniel Pouzzner 455e76873c peer review fixes re: minor fixes to accommodate --disable-sha in combination with --enable-all-crypto. 2022-12-20 10:43:33 -06:00
Daniel Pouzzner 91869f6028 minor fixes to accommodate --disable-sha in combination with --enable-all-crypto. 2022-12-20 00:42:05 -06:00
JacobBarthelmeh c6aaa1310e end of year certificate update 2022-12-16 13:32:37 -08:00
Sean Parkinson 4434d898a1
Merge pull request #5894 from kaleb-himes/fix-leak
Fix a quick leak in the test apps
2022-12-16 08:04:50 +10:00
kaleb-himes b23db16ff8 Refactor the double-free fix 2022-12-15 12:21:08 -07:00
kaleb-himes 46c47e4adc Fix a quick leak in the test apps
Fix a double-free scenario also
2022-12-15 09:13:45 -07:00
Stefan Eissing 78fd5d7dbc Fix wolfSSL_set_SSL_CTX() to be usable during handshake.
This method requires some explanation. Its sibling is
  int SetSSL_CTX(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
which re-inits the WOLFSSL* with all settings in the new CTX.
That one is the right one to use *before* a handshake is started.

This method was added by OpenSSL to be used *during* the handshake, e.g.
when a server inspects the SNI in a ClientHello callback and
decides which set of certificates to use.

Since, at the time the SNI callback is run, some decisions on
Extensions or the ServerHello might already have been taken, this
method is very restricted in what it does:
 - changing the server certificate(s)
 - changing the server id for session handling
and everything else in WOLFSSL* needs to remain untouched.
2022-12-15 09:33:01 +01:00
David Garske d0c9ec6681
Merge pull request #5854 from JacobBarthelmeh/Certs
fix other name san parsing and add RID cert to test parsing
2022-12-12 14:44:07 -08:00
David Garske a1e883b43d
Merge pull request #5875 from JacobBarthelmeh/Compatibility-Layer
fix for handling DEFAULT:... cipher suite list
2022-12-12 14:43:50 -08:00
David Garske f87859a00e Whitespace cleanups. Use `const` for `test_tls_ext_duplicate`. 2022-12-12 08:59:53 -08:00
Sean Parkinson b4b1739783 API test: Report time taken to perform test
API test now displays timing taken to perform a test case to help
identify ones that are doing too much work.
2022-12-12 12:24:38 +10:00
David Garske 50c5d61998
Merge pull request #5872 from SparkiDev/tls_ext_no_dup
TLS: detect duplicate known extensions
2022-12-11 16:53:38 -08:00
Sean Parkinson 9ab8867b42 TLS: detect duplicate known extensions
TLS specification requires that there not be more than one extension of
the same type in a given extension block. E.g. ClientHello
2022-12-12 08:35:04 +10:00
JacobBarthelmeh f974bd4ad6 move test function call into macro guard 2022-12-10 15:45:14 -08:00
JacobBarthelmeh 8b296877ab fix for handling DEFAULT:... cipher suite list 2022-12-10 14:53:43 -08:00
David Garske 52c6710783 Fix `test_wc_ecc_import_raw` to handle `ECC_INF_E` or `MP_VAL` on point failures. SP math returns `MP_VAL` in `sp_256_ecc_is_point_4`. 2022-12-09 10:32:46 -08:00
Anthony Hu cdaa4d8aa0 Add proper gating on !NO_WOLFSSL_SERVER
Found with the following configuration:

--enable-dtls --enable-dtls13 --enable-dtls-mtu CFLAGS="-DNO_WOLFSSL_SERVER"
2022-12-08 14:20:17 -05:00
Anthony Hu 937d247c7d Don't create a key if we don't support the curve.
Found with the following configuration:

./configure --enable-tls13 --disable-oldtls --enable-static --enable-singlethreaded --enable-dtls --enable-dtls13 --enable-dtls-mtu --enable-sp=yes,4096 --disable-shared --disable-sha3 --disable-dh --enable-curve25519 --enable-secure-renegotiation --enable-debug --enable-opensslextra 'CFLAGS=-DWOLFSSL_DTLS_ALLOW_FUTURE -DWOLFSSL_MIN_RSA_BITS=2048 -DWOLFSSL_MIN_ECC_BITS=256 -DFP_MAX_BITS=8192 -fomit-frame-pointer'
2022-12-08 12:13:12 -05:00
JacobBarthelmeh eb69ccb22c
Merge pull request #5856 from icing/errq-improvements
Improvements in OpenSSL Compat ERR Queue handling.
2022-12-08 09:28:05 -07:00
Jacob Barthelmeh 94212e68e5 map SSL_CTX_get_session_cache_mode compat API 2022-12-07 11:35:48 -07:00
Stefan Eissing 45f9ef5dd9 Improvements in OpenSSL Compat ERR Queue handling.
Configuration
- thread-local storaoge is selected when available
- '--enable-error-queue-per-thread' and '--disable-error-queue-per-thread' can
  be used as before to explicitly en-/disable the feature.

Implementation:
- with thread-local-storage, error queue is realized in one struct without
  allocations. Queue size is restricted to 16 entries (per thread), which
  is the same limit in OpenSSL 1.1.x.
- without thread-local-storage, all error queue operations are mutex locked
- wc_PeekErrorNodeLineData() and wc_GetErrorNodeErr() added for use by SSL
  functions to allow locked queue iterations/manipulations.
2022-12-07 18:14:45 +01:00
Sean Parkinson e5d03cf5ad
Merge pull request #5848 from philljj/fix_mingw64_build
Fix mingw-w64 build issues on windows.
2022-12-07 08:57:07 +10:00
Anthony Hu 7935a11b3e Fixups for problems discovered while testing for DTLS 1.3 2022-12-06 11:30:23 -05:00
JacobBarthelmeh f1daa2d356 fix other name san parsing and add RID cert to test parsing 2022-12-05 15:51:33 -08:00
Anthony Hu 312b488582 Remove double free 2022-12-05 15:39:14 -05:00
Anthony Hu 65a5ea7cae Make sure certs are identical in tests. 2022-12-05 13:57:53 -05:00
jordan 87113cc88d Fix mingw-w64 build issues on windows. 2022-12-03 17:00:44 -06:00
Anthony Hu f58f3bd986 Don't regenerate in test_wolfSSL_PEM_write_bio_X509(). We don't have the private key. 2022-12-02 16:41:24 -05:00
Marco Oliverio abbba4815e tests: add tests for stateless dtls v1.2 cookie 2022-12-01 16:47:37 +00:00
David Garske b2f9838af4 Fix DSA public decode to allow extra buffer (in case private key is passed in). Fixes for clang-tidy "value stored never read". Allow showing line number and conditional with `DEBUG_WOLFSSL_VERBOSE` on `TEST_RES_CHECK`. 2022-11-29 14:58:52 -08:00
David Garske 7310eb102f Whitespace and line length cleanups. 2022-11-29 09:52:11 -08:00
Sean Parkinson e4e53ab7ca Unit test: rework to be able to run API tests individually
Change API test cases to return a result.
Test success is now TEST_SUCCESS (1).
Test result can be returned with use of macro TEST_RES_CHECK().
Always print the id, name of the test and the result (skipped or
otherwise) before and after running the test case.

Changed test case output to go to stderr.
Fixed some formatting.

Add option to take index and/or name of test case to run.
Added option to list all API tests.
Added option to only run API tests.
Added options to show usage.
2022-11-29 12:37:20 +10:00
Anthony Hu 7c576de914 Fixes from testing 2022-11-25 16:00:09 -05:00
Anthony Hu 0bfa5c9836 Purge NTRU and SABER. Not going to be standardized. 2022-11-25 14:54:08 -05:00
JacobBarthelmeh 143dac64a3 account for 'pulled' error nodes 2022-11-17 14:51:37 -08:00
jordan 17105606b1 Cleanup format and typos, and use WOLFSSL_FILETYPE. 2022-11-15 11:45:11 -06:00
jordan 81ed2a60b4 Support ASN1/DER CRLs in LoadCertByIssuer.
This fixes hash based dir lookup of ASN1/DER CRLs in OpenSSL
compatible API. The function wolfSSL_X509_load_crl_file is
called with entry->dir_type, rather than hardcoded filetype.

A new test crl was added, and existing crl 0fdb2da4.r0 was
reorganized to a new dir.

Also, completes the stub wolfSSL_X509_LOOKUP_add_dir. A new
test function test_X509_LOOKUP_add_dir was added to tests/api.c
2022-11-11 15:13:00 -06:00
tim-weller-wolfssl 3bc3ec25b8 Add link of newly created x509 store's certificate manager to self by default 2022-11-09 17:17:30 -06:00
David Garske eac3b4e189
Merge pull request #5752 from julek-wolfssl/alt-name-str-type
Set alt name type to V_ASN1_IA5STRING
2022-11-08 15:42:39 -08:00
Daniel Pouzzner 48ba365fd6 fixes for defects:
clang-analyzer-deadcode.DeadStores in examples/server/server.c;

-Werror=use-after-free and LeakSanitizer Direct leak in tests/api.c;

nullPointerRedundantCheck in src/pk.c which identified a semantically consequential flub.
2022-11-08 14:04:16 -06:00
Sean Parkinson bd83345c02
Merge pull request #5773 from dgarske/async_v5.5.3
Fixes for various tests that do not properly handle `WC_PENDING_E`
2022-11-08 14:47:23 +10:00
David Garske 1ee3a78e4a Fixes for various tests that do not properly handle `WC_PENDING_E`. 2022-11-04 14:56:40 -07:00
Hayden Roche 5d70f3efce
Merge pull request #5730 from philljj/zd15040 2022-11-04 13:32:48 -07:00
Hayden Roche 4a917219f7
Merge pull request #5608 from SparkiDev/pk_c_rework_2 2022-11-04 13:32:36 -07:00
JacobBarthelmeh 8225d3642b save next status with OCSP response verify 2022-11-03 22:39:47 -07:00
Juliusz Sosinowicz 8bbbdfa3f9 Set alt name type to V_ASN1_IA5STRING 2022-10-28 19:58:01 +02:00
JacobBarthelmeh 7366a9edbd
Merge pull request #5744 from SparkiDev/regression_fixes_4
Regresssion testing fixes
2022-10-27 11:49:52 -06:00
Sean Parkinson fd7544ca19 Regresssion testing fixes
Ed25519 and Ed448 need to enable certs.

If no system CA certs can't be parsed,
wolfSSL_CTX_load_system_CA_certs() will fail. Don't try test if RSA and
ECC are not enabled.

Fix benchmark.c so that e is defined when WOLFSSL_BENCHMARK_ALL defined.

MAX_LENGTH_SZ is 4 and supports lengths up to 2^24 - one byte for length
and 3 bytes of length.
(new gcc compiler fix)
2022-10-27 17:47:48 +10:00
Hayden Roche 294a26ba0c
Merge pull request #5708 from JacobBarthelmeh/OCSP 2022-10-26 15:43:15 -07:00
Jacob Barthelmeh 8d6ee0b26a minor warning fixes 2022-10-26 10:48:51 -06:00
JacobBarthelmeh a26b89f66b fix leak with multiple entries 2022-10-26 09:29:06 -07:00
Sean Parkinson 5db2d53d54 Fixes from review part 2 2022-10-26 16:04:05 +10:00
Sean Parkinson dad62fc182 pk.c: rework DH API and improve PEM read/write
Reorganized the DH APIs into groups.
Reworked all DH APIs.
Improved testing of DH API.

Implemented wolfSSL_PEM_read_RSAPublicKey() and
wolfSSL_PEM_write_RSA_PUBKEY().
Fix public key PEM write implementations to use the correct
header/footer names.
Added support for "RSA PUBLIC KEY" in header and footer in DerToPemEx().

Reworked PEM read/write APIs to be independent. No longer create an EVP
to use common function - common functionality refectored out.
Similarly file APIs don't create a BIO and call the partner APIs.

Improved testing of PEM read/write APIs.

Generic read BIO from memory BIO now returns the buffer instead of
allocating memory and reading.
No longer reading chunks when a file BIO.

Added wolfssl_make_rng() to create or get get global random. All RSA and
DH APIs now use this. DH_generate_parameters() creates a random object
and use global on error rather than just using global random.

Changed implementations to use BIO_new_fp() instead of create a new BIO
and setting file pointer.
2022-10-26 10:28:20 +10:00
Daniel Pouzzner baa19c1092 tests/api.c: fix 3 clang-analyzer-deadcode.DeadStores. 2022-10-25 18:17:22 -05:00
JacobBarthelmeh 29a5c04c2e add test case 2022-10-25 15:35:37 -07:00
jordan 8b7668f771 Fix X509 subject and issuer name_hash mismatch
Fix api test and cleanup.
2022-10-25 13:00:22 -05:00
Hayden Roche e7a121325b
Merge pull request #5720 from julek-wolfssl/nid-defines 2022-10-25 10:34:59 -07:00
Hayden Roche 2b72a50688
Merge pull request #5662 from Uriah-wolfSSL/haproxy-update-2.6.0 2022-10-25 07:47:54 -07:00