summaryrefslogtreecommitdiffstats
path: root/ssl
AgeCommit message (Collapse)Author
2023-09-19Copyright year updatesRichard Levitte
Reviewed-by: Matt Caswell <matt@openssl.org> Release: yes
2023-09-18Enhance code safety and readability in SSL_get_shared_ciphers()Sumitra Sharma
This commit introduces two key improvements: 1. Improve code safety by replacing the conditional statement with `if (n >= size)` and using OPENSSL_strnlen() instead of strlen(). This change ensures proper buffer size handling and adheres to secure coding practices. 2. Enhance code readability by substituting `strcpy(p, c->name)` with `memcpy(p, c->name, n)`. This adjustment prioritizes code clarity and maintenance, even while mitigating a minimal buffer overflow risk. These enhancements bolster the code's robustness and comprehensibility, aligning with secure coding principles and best practices. Fixes #19837 Signed-off-by: Sumitra Sharma <sumitraartsy@gmail.com> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21934) (cherry picked from commit 2743594d73e65c38375c619e89ec62579e2c24a9)
2023-08-04Resolves some magic values that has a hello_retry_request enum type.Frederik Wedel-Heinen
CLA: trivial Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21636) (cherry picked from commit 5ac7ee4d5a38e4f163ed6a7c9c283d45038625a8)
2023-08-02A null pointer dereference occurs when memory allocation failsyangyangtiantianlonglong
Fixes #21605 Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21606) (cherry picked from commit a8da305fa3dd6e34ba5aab3978281f652fd12883)
2023-08-01Copyright year updatesMatt Caswell
Reviewed-by: Tomas Mraz <tomas@openssl.org> Release: yes
2023-07-17Fix ssl3_do_write() to correctly handle retriesMatt Caswell
A BIO is documented to return -1 on write retry - but sometimes they return 0. ssl3_do_write() was incorrectly handling a 0 response. Fixes #21422 Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21435) (cherry picked from commit 034ea1d00e5816f35c3e4799d5c122e198e14b59)
2023-06-29Fix supported_groups handing in TLSv1.2Matt Caswell
In TLSv1.2 we should not attempt to use a supported_group value that is intended for use with TLSv1.3 - even if both the server and the client support it, e.g. the ffdhe groups are supported by OpenSSL for TLSv1.3 but not for TLSv1.2. Fixes #21081 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Viktor Dukhovni <viktor@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21295) (cherry picked from commit 01e765f0547eb67631820647a0cfeb9b3741491a)
2023-06-23Don't ask for an invalid group in an HRRMatt Caswell
If the client sends us a group in a key_share that is in our supported_groups list but is otherwise not suitable (e.g. not compatible with TLSv1.3) we reject it. We should not ask for that same group again in a subsequent HRR. Fixes #21157 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> (Merged from https://github.com/openssl/openssl/pull/21163) (cherry picked from commit 7a949ae5f1799a6629cf6deb44ae0f38455a73dd)
2023-05-30Update copyright yearTomas Mraz
Reviewed-by: Richard Levitte <levitte@openssl.org> Release: yes
2023-05-12Clear ownership when duplicating sessionsWatson Ladd
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Todd Short <todd.short@me.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20848) (cherry picked from commit 9fdf9a44bbe3827fe653165a07281ccae8ab0947)
2023-04-25Fix regression of no-posix-io buildsTomas Mraz
Instead of using stat() to check if a file is a directory we just skip . and .. as a workaround. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/20786) (cherry picked from commit 3155b5a90e6ad9c7369d09e70e81686f4b321a73)
2023-03-31Handle app data records from the next epochMatt Caswell
It is possible that DTLS records are received out of order such that records from the next epoch arrive before we have finished processing the current epoch. We are supposed to buffer such records but for some reason we only did that for handshake and alert records. This is incorrect since it is perfectly possible for app data records to arrive early too. Fixes #20597 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20638)
2023-03-24tls1_set_groups_list: freeing *pext before overwritingPeter Kaestle
calling SSL_CTX_set1_groups_list() twice on one SSL_CTX* caused a memory leak visible in valgrind: 4 bytes in 1 blocks are definitely lost in loss record 1 of 1 at 0x4841888: malloc (vg_replace_malloc.c:381) by 0x4B1EE96: CRYPTO_memdup (in libcrypto.so.3) by 0x48993A0: tls1_set_groups_list (in libssl.so.3) by 0x487AA7E: ssl3_ctx_ctrl (in libssl.so.3) by 0x1091EA: main (mem_leak.c:10) LEAK SUMMARY: definitely lost: 4 bytes in 1 blocks Freeing *pext to fix it. CLA: trivial Signed-off-by: Peter Kaestle <peter.kaestle@nokia.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20317)
2023-03-15Remove spurious error queue entries on early dataMatt Caswell
Early data decryption is expected to fail sometimes. If it does we should not leave spurious error entries on the queue. Fixes #20377 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/20442) (cherry picked from commit d015b50dc9af0640c7c019a693368c3488d692d8)
2023-02-24Do not have more data in a pipeline than the split_send_fragmentMatt Caswell
We shouldn't be putting more data into a pipeline than the value of split_send_fragment. This is a backport of a fix which was included in a much larger commit in master (c6186792b98) related to moving the pipelining code into the new record layer that exists there. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20208) (cherry picked from commit 2c4b1c7b7b09c0e3f9f4246e8d6747678ea90363)
2023-02-24Fix read pipeliningMatt Caswell
During read pipelining we must ensure that the buffer is sufficiently large to read enough data to fill our pipelines. We also remove some code that moved data to the start of the packet if we can. This was unnecessary because of later code which would end up moving it anyway. The earlier move was also incorrect in the case that |clearold| was 0. This would cause the read pipelining code to fail with sufficiently large records. Fixes #20197 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20208) (cherry picked from commit 1d06598f0e9d9e39f9c206a2520777e696150257)
2023-02-24Pipeline output/input buf arrays must live until the EVP_Cipher is calledMatt Caswell
The pipeline input/output buf arrays must remain accessible to the EVP_CIPHER_CTX until EVP_Cipher is subsequently called. This fixes an asan error discovered by the newly added pipeline test. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20208) (cherry picked from commit df9c7ceefef59cc870c80346906471fabec62494)
2023-02-23Skip subdirectories in SSL_add_dir_cert_subjects_to_stack()olszomal
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20312) (cherry picked from commit 1dc35d44f355a7371a1ff8a457586938cc7b168a)
2023-02-07Update copyright yearRichard Levitte
Reviewed-by: Tomas Mraz <tomas@openssl.org> Release: yes
2023-01-24Ensure our buffer allocation allows for the Explicit IVMatt Caswell
Some ciphers/protocol versions have an explicit IV. We need to make sure we have sufficient room for it in the underlying buffer. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20086) (cherry picked from commit 3be93f1b264d35ad93ceb71affacdef1b930c3c6)
2023-01-04Avoid possible divide by zeroTomas Mraz
Backport of commit 624efd2 Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19967) (cherry picked from commit 8c29e5ebfd5f19442422ba43fea4c95816417e34)
2022-12-13Make error reason for disallowed legacy sigalg more specificTomas Mraz
The internal error reason is confusing and indicating an error in OpenSSL and not a configuration problem. Fixes #19867 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19875) (cherry picked from commit 97b8db1af2f71059ecea986e4d12fc6a23699a74)
2022-12-05Fix the check of BIO_set_write_buffer_size and BIO_set_read_buffer_sizePeiwei Hu
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19819) (cherry picked from commit 25d02f333b9a5531fa88db294f69a8347f275858)
2022-11-14Use the same encryption growth macro consistentlyMatt Caswell
We had two different macros for calculating the potential growth due to encryption. The macro we use for allocating the underlying buffer should be the same one that we use for reserving bytes for encryption growth. Also if we are adding the MAC independently of the cipher algorithm then the encryption growth will not include that MAC so we should remove it from the amount of bytes that we reserve for that growth. Otherwise we might exceed our buffer size and the WPACKET_reserve operation will fail. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19264) (cherry picked from commit 3d004cefec5135a3b080dc898d7f7d5452ef309f)
2022-11-02Fix the ceiling on how much encryption growth we can haveMatt Caswell
Stitched ciphersuites can grow by more during encryption than the code allowed for. We fix the calculation and add an assert to check we go it right. Note that this is not a security issue. Even though we can overflow the amount of bytes reserved in the WPACKET for the encryption, the underlying buffer is still big enough. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19517) (cherry picked from commit eaa206007322ab0b1eaf9f83485e56deafc9df80)
2022-10-26ssl_cipher_process_rulestr: don't read outside rule_str bufferTodd C. Miller
If rule_str ended in a "-", "l" was incremented one byte past the end of the buffer. This resulted in an out-of-bounds read when "l" is dereferenced at the end of the loop. It is safest to just return early in this case since the condition occurs inside a nested loop. CLA: trivial Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19166) (cherry picked from commit 428511ca66670e169a0e1b12e7540714b0be4cf8)
2022-10-21stack: Do not add error if pop/shift/value accesses outside of the stackTomas Mraz
This partially reverts commit 30eba7f35983a917f1007bce45040c0af3442e42. This is legitimate use of the stack functions and no error should be reported apart from the NULL return value. Fixes #19389 Reviewed-by: Todd Short <todd.short@me.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19400) (cherry picked from commit a8086e6bfc37355626393751a94bc5c92df7e9d3)
2022-10-19Ensure that the key share group is allowed for our protocol versionMatt Caswell
We should never send or accept a key share group that is not in the supported groups list or a group that isn't suitable for use in TLSv1.3 Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19404)
2022-10-11Update copyright yearMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org> Release: yes (Merged from https://github.com/openssl/openssl/pull/19382)
2022-09-28Test TLS extension orderingTodd Short
Adding extensions is fragile, with the TLSEXT_TYPE entry needing to be located at TLSEXT_IDX in the array. This adds a test to ensure extensions are in the correct order. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19269) (cherry picked from commit ac44deaf00ad24fd18b9d74de4a23d98a2b75c8d)
2022-09-27ssl_log_secret call in tls13_key_updatevisbjn
Newly computed traffic secrets are now logged upon key update Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19241) (cherry picked from commit 2f7e61b8b21ed472a3667b8922843851f94a3d93)
2022-09-27If a ticket key callback returns 0 in TLSv1.3 don't send a ticketMatt Caswell
If we can't construct the ticket don't send one. This requires a change to the TLS state machine to be able to a handle a construction function deciding not to send a message after all. Fixes #18977 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Viktor Dukhovni <viktor@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19249)
2022-09-22Correctly handle a retransmitted ClientHelloMatt Caswell
If we receive a ClientHello and send back a HelloVerifyRequest, we need to be able to handle the scenario where the HelloVerifyRequest gets lost and we receive another ClientHello with the message sequence number set to 0. Fixes #18635 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18654) (cherry picked from commit 81926c91567cd5d11eec38b9980438f45b276d72)
2022-09-16stack.c: add missing direct error reporting and improve coding styleDr. David von Oheimb
Doing so, had to fix sloppiness in using the stack API in crypto/conf/conf_def.c, ssl/ssl_ciph.c, ssl/statem/statem_srvr.c, and mostly in test/helpers/ssltestlib.c. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/18918) (cherry picked from commit 30eba7f35983a917f1007bce45040c0af3442e42)
2022-09-06Coverity 1513478: negative returnPauli
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19126) (cherry picked from commit 1d1537067304b8c8d87b2df393363b40370ad640)
2022-08-26Convert serverinfo in SSL_CTX_use_serverinfo() to v2.Daniel Fiala
Fixes openssl#18183. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18614) (cherry picked from commit 555dd9390ba56f1c400d3f067a2dfe7b00fbf7d3)
2022-08-22Coverity 1508506: misuse of time_tPauli
Fixes a bug in the cookie code which would have caused problems for ten minutes before and after the lower 32 bits of time_t rolled over. Reviewed-by: Ben Kaduk <kaduk@mit.edu> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19023)
2022-08-19Coverity 1508534 & 1508540: misuses of time_tPauli
Avoid problems when the lower 32 bits of time_t roll over by delaying the cast to integer until after the time delta has been computed. Reviewed-by: Ben Kaduk <kaduk@mit.edu> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19004) (cherry picked from commit e8a557dc3c1ed16faff4aeb39268f8f5a3f8b81d)
2022-08-17Fix SSL_pending() and SSL_has_pending() with DTLSMatt Caswell
If app data is received before a Finished message in DTLS then we buffer it to return later. The function SSL_pending() is supposed to tell you how much processed app data we have already buffered, and SSL_has_pending() is supposed to tell you if we have any data buffered (whether processed or not, and whether app data or not). Neither SSL_pending() or SSL_has_pending() were taking account of this DTLS specific app data buffer. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18975)
2022-08-02Check that IV length is not less than zeroDmitry Belyavskiy
As EVP_CIPHER_CTX_get_iv_length indicates failure with -1, this error should be processed. Also the result of this function shouldn't be assigned to an unsigned variable. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> Signed-off-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18922)
2022-08-01Free up space in the session cache before adding.Todd Short
Fixes #18690 In some circumstances, it's possible that when using an external database for the session cache, that pulling in an entry from that cache to the internal cache will cause the newly added entry to be deleted from the internal cache. This is likely to happen when the internal cache is set to have a small size, and the newly added entry's timeout places it at the end of the cache list. This could be fixed by updating the timestamp of the session (via `SSL_SESSION_set_time()` or `SSL_SESSION_set_timeout()`) before adding to the cache. But that may not be desireable. Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18905) (cherry picked from commit 4842a27b902660b672d72d2ed23e941461ca481c)
2022-07-13Check for EVP_MD being NULL inside ssl.slontis
Fix multiple places that could potentially segfault if memory allocations fail. e.g. ssl_load_ciphers() could fail while calling ssl_evp_md_fetch(). Found by #18355 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/18784) (cherry picked from commit b740012f77aed97cb4b3cd8a4f1fb2f668542795)
2022-07-08ssl/tls_srp.c: Add check for BN_dupJiasheng Jiang
As the potential failure of the BN_dup, it should be better to check the return value in order to guarantee the success. Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Todd Short <todd.short@me.com> (Merged from https://github.com/openssl/openssl/pull/18699) (cherry picked from commit 12e488367d34657a5c0e1bc322e66c48463d2a0c)
2022-06-22Improve diagnostics on setting groupsDmitry Belyavskiy
- If keymgmmt is not available, it's not an error but the error message persists in stack - when setting groups, it's worth saying which group is not available Fixes #18585 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18591) (cherry picked from commit ce8822b7e5f4fdf836677faee336a5cf996d4363)
2022-06-21Update copyright yearMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org> Release: yes
2022-06-10add_provider_groups: Clean up algorithm pointer on failureTomas Mraz
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18494) (cherry picked from commit a7863f994955c45fb7ce29e30b81a6206994c3dd)
2022-06-03Fix strict client chain check with TLS-1.3Tomas Mraz
When TLS-1.3 is used and the server does not send any CA names the ca_dn will be NULL. sk_X509_NAME_num() returns -1 on null argument. Reviewed-by: Todd Short <todd.short@me.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17986) (cherry picked from commit 89dd85430770d39cbfb15eb586c921958ca7687f)
2022-06-02Fix the erroneous checks of EVP_PKEY_CTX_set_group_namePeiwei Hu
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18399) (cherry picked from commit 56876ae952b96b4a83266f6b2ec1393f599015d6)
2022-05-27The -no_legacy_server_connect option applies to clientTomas Mraz
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Ben Kaduk <kaduk@mit.edu> (Merged from https://github.com/openssl/openssl/pull/18296) (cherry picked from commit d1b3b6741380a1d7607da671b97f3fe5f54fa657)
2022-05-27Actually implement UnsafeLegacyServerConnect as documentedTomas Mraz
Fixes #18295 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Ben Kaduk <kaduk@mit.edu> (Merged from https://github.com/openssl/openssl/pull/18296) (cherry picked from commit 65b2bb9ca0cff5e65938dc0d9dcd71c251bd67db)