Skip to content

DTLS: add api to enforce records do not span datagrams #8642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rizlik
Copy link
Contributor

@rizlik rizlik commented Apr 7, 2025

Description

DTLS records should not span UDP datagrams, this PR adds an API to enforce it.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • doc/dox_comments/header_files/ssl.h: Language not supported

WOLFSSL_CTX *ctx_c = NULL, *ctx_s = NULL;
WOLFSSL *ssl_c = NULL, *ssl_s = NULL;
struct test_memio_ctx test_ctx;
char * readBuf[50];
Copy link
Preview

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The declaration of 'readBuf' as an array of char pointers is likely incorrect for use with wolfSSL_read, which expects a contiguous byte buffer. Consider changing it to 'unsigned char readBuf[50];' or 'char readBuf[50];' if signedness is not an issue.

Suggested change
char * readBuf[50];
unsigned char readBuf[50];

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

WOLFSSL_CTX *ctx_c = NULL, *ctx_s = NULL;
WOLFSSL *ssl_c = NULL, *ssl_s = NULL;
struct test_memio_ctx test_ctx;
char * readBuf[50];
Copy link
Preview

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The declaration of 'readBuf' as an array of char pointers is likely unintended here, as wolfSSL_read is expected to write raw bytes into a contiguous buffer. Consider using 'unsigned char readBuf[50];' or 'char readBuf[50];' to avoid potential memory issues.

Suggested change
char * readBuf[50];
unsigned char readBuf[50];

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

@rizlik rizlik force-pushed the dtls_no_span_records branch 4 times, most recently from c818750 to b8c12fb Compare April 7, 2025 13:57
@rizlik
Copy link
Contributor Author

rizlik commented Apr 8, 2025

retest this

- 0: Records cannot span datagrams.
- 1: Records can span datagrams (default behavior).
*/
int wolfSSL_dtls_set_records_can_span_datagrams(WOLFSSL* ssl, int value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the RFC explicitly prohibits this, I would make this a compile time const. Its not something that users are going to be changing dynamically.

Each DTLS record MUST fit within a single datagram.

https://www.rfc-editor.org/rfc/rfc9147.html#section-4.3

@julek-wolfssl julek-wolfssl removed their assignment Apr 9, 2025
@gojimmypi
Copy link
Contributor

Jenkins retest this please

for long-running job

@rizlik rizlik force-pushed the dtls_no_span_records branch 2 times, most recently from cbab2d0 to 7147388 Compare April 22, 2025 14:07
rizlik added 4 commits April 22, 2025 15:53
changes:
- alert is sent if SanityCheckCipherText fails, with or without
  `WOLFSSL_EXTRA_ALERTS` defined
- HandleDTLSDecryptFailed is invoked if `SanityCheckCipherText` fails
@rizlik rizlik force-pushed the dtls_no_span_records branch from 7147388 to 72a3693 Compare April 22, 2025 15:55
@rizlik
Copy link
Contributor Author

rizlik commented Apr 22, 2025

retest this please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants