17419 Commits

Author SHA1 Message Date
Marco Oliverio
12a3efeca8 client/server: tolerate WANT_WRITE errors 2022-06-15 10:46:43 -07:00
Marco Oliverio
4e112419f5 examples: client/server: support DTLSv1.3 (-u -v4)
This commits add some new options to examples/[server,client] to support testing
of DTLS v1.3.

client: add waitTicket option

If this option is used, the client will wait until it receives a sessionTicket
from the server. This is useful when testing DTLS retransmission.

client: add waitKeyUpdate option

When this option is set, the client waits until the UpdateKey message is
acknowledged by the server. This is useful to test DTLS retransmission logic
2022-06-15 10:46:43 -07:00
Marco Oliverio
c1dc90d9b0 server: request cert only once if doing post-handshake auth 2022-06-15 10:46:43 -07:00
Marco Oliverio
ca05ad2dc0 dtls13: introduce wolfSSL_dtls_13_has_pending_msg() API 2022-06-15 10:46:43 -07:00
Marco Oliverio
e2abdf23a7 internal: return from wolfSSL_Peek() with sz 0 if we don't have data
This way we can use wolfSSL_Peek() invoked with sz == 0 to process pending
records and, if none of this records is an application data record, we will not
block.
2022-06-15 10:46:43 -07:00
Marco Oliverio
dfc9873c0f dtls13: support KeyUpdate messages 2022-06-15 10:46:43 -07:00
Marco Oliverio
d1924928c0 dtls13: support retransmission
Introduce ACK and retransmission logic, encapsulated in a Dtls13RtxFsm
object. The retransmission or the sending of an ACK is scheduled by setting the
appropriate flag inside the Dtls13RtxFSM object but the actual writing on the
socket is deferred and done in wolfSSL_Accept/Connect.

* Retransmission

Each sent message is encapsulated in a Dtl13RtxRecord and saved on a list. If we
receive an ACK for at record, we remove it from the list so it will be not
retransmitted further, then we will retransmit the remaining
ones. Retransmission is throttled: beside link congestion, this also avoid too
many sequence numbers bounded with a record.

* ACK

For each received record we save the record sequence number, so we can send an
ACK if needed. We send an ACK either if explicitly needed by the flight or if we
detect a disruption.

Co-authored-by: Juliusz Sosinowicz <juliusz@wolfssl.com>
2022-06-15 10:46:43 -07:00
Marco Oliverio
d079662765 dtls13: support fragmentation, sending and receiving
This commit implements the core of the header parsing, building, and the sending
and receiving routines that handle fragmentation and defragmentation.

* In DTLSv1.3 the header used for protected messages is a variable-length header,
and it is described RFC9147 Section 4.

* Fragmentation happens after building the full message, if necessary. If the
underlying I/O can't send a fragment because of a WANT_WRITE error, the sending
of fragments will continue in the next invocation of
wolfSSL_connect/wolfSSL_accept/wolfSSL_write. In this case the message is saved
in a buffer inside the WolfSSL object.

* Defragmentation works like DTLSv1.2 defragmentation, and re-use
most of the same code.

* The Dtls13AddHeaders() function does not add the record layer header, but it
lefts space for it. It is eventually placed by BuildTls13Message() to allow
easier management of sequence numbers.
2022-06-15 10:46:43 -07:00
Marco Oliverio
173077b142 dtls: refactor DtlsUpdateWindow() window
split the DtlsUpdateWindow() function, so part of the code can be reused by
DTLSv1.3 code.
2022-06-15 10:46:43 -07:00
Marco Oliverio
30fb664163 internal.c: add runProcessingOneRecord section
DTLSv1.3 needs to do some operation per-record, this commit adds an appropriate
section to ProcessReplyEx.
2022-06-15 10:46:43 -07:00
Marco Oliverio
2696c3cdd3 dtls13: change encryption keys dynamically based on the epoch
In DTLSv1.3, because of retransmission and reordering, we may need to encrypt or
decrypt records with older keys. As an example, if the server finished message
is lost, the server will need to retransmit that message using handshake traffic
keys, even if he already used the traffic0 ones (as, for example, to send
NewSessionTicket just after the finished message).

This commit implements a way to save the key bound to a DTLS epoch and setting
the right key/epoch when needed.
2022-06-15 10:46:43 -07:00
Marco Oliverio
de04973051 dtls13: record number encryption and decryption 2022-06-15 10:46:43 -07:00
Marco Oliverio
60834ba516 dtls13: new methods and version negotiation 2022-06-15 10:46:42 -07:00
Marco Oliverio
9d22e11776 misc.c: introduce w64wrapper to handle 64bit numbers
as word64 is not always available, introduce an abstract type and companion
operations. They use a word64 if available and fallback on word32[2] otherwise.
2022-06-15 10:46:42 -07:00
Marco Oliverio
7586851734 dtls13: export functions
They will be used by DTLSv1.3 code
2022-06-15 10:46:42 -07:00
Marco Oliverio
d8ac35579c dtls13: add autotools, cmake build options and vstudio paths 2022-06-15 10:46:42 -07:00
John Safranek
d51ba35ff9
Merge pull request #5246 from rizlik/dtls_header_fixes
dtls: handshake header parsing fixes
2022-06-15 09:33:41 -07:00
Marco Oliverio
6630a83182 dtls: handshake header parsing fixes 2022-06-15 12:00:26 +02:00
Sean Parkinson
e073500e8e SP ARM32 ASM: Improve performance of P-256 mont mul/sqr 2022-06-15 16:39:13 +10:00
Sean Parkinson
af4fff80db SP ARM32: support for arch with no ldrd/strd and clz
Defined WOLFSSL_SP_ARM_ARCH to be less than 7 to use alternative
instructions.
2022-06-15 12:07:49 +10:00
Sean Parkinson
f1ce0cc95d Memory zeroization fixes
Zeroize secrets in stack buffers and allocated memory.
mp_forcezero to ensure private MP integers are zeroized.
Fix whitespace and add some comments.
2022-06-15 11:26:11 +10:00
Sean Parkinson
9656963f61
Merge pull request #5231 from dgarske/glitch_harden
Added sanity check on TLS encrypt to trap against glitching
2022-06-15 09:48:18 +10:00
Sean Parkinson
ed5470c991
Merge pull request #5239 from dgarske/asn_decode_ext
Fix for ASN template parsing of extended key usage
2022-06-15 09:29:44 +10:00
David Garske
0cac6cef39
Merge pull request #5237 from anhu/bench_psk
Support psk ciphersuites in benchmarks.
2022-06-14 16:12:15 -07:00
David Garske
ed6c9639d6
Merge pull request #5243 from douzzer/20220614-multi-test-fixups
20220614-multi-test-fixups
2022-06-14 16:11:44 -07:00
Daniel Pouzzner
f414e65d4b linuxkm: eliminate duplicative WOLFSSL_KTHREADS macro (just use WOLFSSL_LINUXKM). 2022-06-14 12:45:30 -05:00
David Garske
2f4864cab2 Added sanity check on TLS encrypt to trap against glitching. 2022-06-14 09:37:44 -07:00
David Garske
7a25b9cd85
Merge pull request #5241 from SparkiDev/wycheproof_sp_arm64_asm
SP ASM: fixes for Wycheproof tests
2022-06-14 09:08:15 -07:00
Anthony Hu
22eee3206d Fixups from review by dgarske 2022-06-14 11:13:28 -04:00
Daniel Pouzzner
a22da10956 linuxkm: tweak setup of wolfSSL_Mutex to assure complete type availability in applications (client modules). 2022-06-14 09:45:33 -05:00
Daniel Pouzzner
5a8c130040 fix whitespace 2022-06-14 09:43:05 -05:00
David Garske
fb10c90935 Fix for Cube HAL v2 back-to-back DES/DES3. Whitespace. Enable the new FIFO 16 block logic for all hardware that supports it. 2022-06-14 11:48:51 +02:00
David Garske
c52c2e5dfb Fixes for STM32H7 hash and crypto. 2022-06-14 11:48:51 +02:00
David Garske
ad3f7e1de2 The STM32U5 does not support DES3 or AES 192-bit (only 128/256 bit) 2022-06-14 11:48:51 +02:00
David Garske
502cbc3847 Fix for STM32U5 hash/crypto support. ZD 14305. 2022-06-14 11:48:51 +02:00
Sean Parkinson
013066ca06 SP ASM: fixes for Wycheproof tests
ARM64 ASM: Fix P256 Montogomery Reduce.
Fix div to handle large dividend word.
2022-06-14 16:11:46 +10:00
David Garske
c0f49b57e1 Fix for ASN template parsing of DecodeExtKeyUsage. ZD 14344. 2022-06-13 16:50:20 -07:00
David Garske
af3a55a94c
Merge pull request #5220 from kaleb-himes/ZD14318
Resolves inter-library API conflict reported in ZD14318
2022-06-13 14:28:13 -07:00
David Garske
f401a3b53d
Merge pull request #5232 from cconlon/june10
test/benchmark.c: rename Android tag, reset vars in memcb_test()
2022-06-13 14:24:17 -07:00
Anthony Hu
4d4ee3b2db Support psk ciphersuites in benchmarks.
Also fixed some small errors during shutdown in benchmarks.

Tested with:

./configure --enable-psk CFLAGS=-DWOLFSSL_STATIC_PSK
make all check
./examples/benchmark/tls_bench
2022-06-13 13:33:51 -04:00
Chris Conlon
364bf482eb adjust wolfCrypt test/benchmark Android log TAG name, reset malloc/free counts in memcb_test() 2022-06-13 09:42:02 -06:00
David Garske
0b78961111
Merge pull request #5186 from SparkiDev/pk_c_rework_1
pk.c: rework
2022-06-13 08:35:09 -07:00
David Garske
5018da7f9f
Merge pull request #5234 from gojimmypi/PR_Espressif_Version_README
Add note regarding ESP-IDF Version
2022-06-13 08:34:25 -07:00
David Garske
9ee1833bd2
Merge pull request #5235 from SparkiDev/sess_sec_cb_fixup
Improve SessionSecret_callback code.
2022-06-13 08:21:45 -07:00
Sean Parkinson
1de54ed8d7 Improve SessionSecret_callback code. 2022-06-13 10:43:09 +10:00
Sean Parkinson
8899112456
Merge pull request #5230 from dgarske/tls_bench
Fix for TLS v1.1 length sanity check for large messages
2022-06-13 09:38:03 +10:00
gojimmypi
f35eb20954 Add note regarding ESP-IDF Version 2022-06-12 12:39:04 -07:00
David Garske
d5791d5c74 Fixes for TLS benchmarking app (tls_bench) for shutdown and formatting brace cleanups. 2022-06-10 13:48:46 -07:00
David Garske
cafe5646b6 Fix for TLS v1.1 length sanity check for large messages. 2022-06-10 13:35:06 -07:00
David Garske
afc63a3bfa
Merge pull request #5199 from embhorn/zd12999
Add doc for wolfSSL_dtls_retransmit
2022-06-10 10:57:17 -07:00