Skip to content

Abort sending when message authentication fails#980

Merged
schollz merged 1 commit intoschollz:mainfrom
Ozoniuss:close-croc-if-code-error
Oct 16, 2025
Merged

Abort sending when message authentication fails#980
schollz merged 1 commit intoschollz:mainfrom
Ozoniuss:close-croc-if-code-error

Conversation

@Ozoniuss
Copy link
Copy Markdown
Contributor

@Ozoniuss Ozoniuss commented Oct 13, 2025

Note: I'm reopening this PR in case you missed it last time. Let me know if there was something wrong with the previous one. I also realized that maybe the problem this was solving is not clear, I attached a video now that shows the previous bug still exists on main.

This either means that the TCP connection did not use the proper key to encrypt (which should never happen when running properly) or the receiver wrote a key which starts with the same 4 characters, but does not match the sender's code. If the latter, regardless if the user attempts to read the message by correcting the key, it will always receive an error after the first failure. However, the sender will not be closed, making it difficult to detect what happened and why the transfer does not succeed. This change also closes the sender when the receiver uses a key that starts with the same characters, but is a different one.

In the video, note that a mistype will let the sender open, even though the receiver can no longer receive the message.

Screencast.From.2025-10-13.12-15-18.mp4

This either means that the TCP connection did not use the proper key to
encrypt (which should never happen when running properly) or the receiver
wrote a key which starts with the same 4 characters, but does not match the
sender's code. If the latter, regardless if the user attempts to read the
message by correcting the key, it will always receive an error after the first
failure. However, the sender will not be closed, making it difficult to detect
what happened and why the transfer does not succeed. This change also forces the
sender to close when the receiver uses a key that starts with the same characters,
but is a different one
@Ozoniuss
Copy link
Copy Markdown
Contributor Author

Perhaps, a better approach would be to keep the sender open, but try and fix the bug when the correct secret is used will no longer work?

@schollz
Copy link
Copy Markdown
Owner

schollz commented Oct 16, 2025

Looks good!!

@schollz schollz merged commit 872c4bf into schollz:main Oct 16, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants