2751 Commits

Author SHA1 Message Date
Sean Parkinson
9f6ef65e8f
Merge pull request #6557 from julek-wolfssl/zd/16332
Don't allow a resumption handshake inside of a SCR
2023-07-10 13:51:29 +10:00
JacobBarthelmeh
9d3a95a287 account for error return in test case when building without pkcs7 streaming 2023-07-09 12:42:29 -07:00
JacobBarthelmeh
0e2749eeb4 adjust test case for asn=original 2023-07-08 07:37:26 -07:00
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
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
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
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
ca77da92e5 Implement pthreads threading 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
David Garske
23c60b7b9c
Merge pull request #6530 from SparkiDev/tests_api_expect_5
Test api.c: change more tests to use Expect instead of Assert
2023-06-26 16:10:52 -07: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
gojimmypi
6b240fa41a
Refactor HAVE_PTHREAD and _POSIX_THREADS (#6536)
* HAVE_PTHREAD gate in test.h
* add config.h and settings.h to test.h
* added config.h and settings.h to other test.h in wolfcrypt/test
* settings #ifdef _POSIX_THREADS HAVE_PTHREAD
* cyassl settings _POSIX_THREADS HAVE_PTHREAD
* undo cyassl _POSIX_THREADS HAVE_PTHREAD
* move settings.h #include in both test.h
* add !defined(SINGLE_THREADED) logic
* refactor  HAVE_PTHREAD, _POSIX_THREADS
2023-06-26 07:32:20 -07: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