Skip to content

Sign detached signatures over raw bytes with openssl -binary - #20

Merged
majorsilence merged 1 commit into
TownSuite:mainfrom
majorsilence:main
Aug 25, 2026
Merged

majorsilence merged 1 commit into
TownSuite:mainfrom
majorsilence:main

Conversation

@majorsilence

Copy link
Copy Markdown
Member

15081

The cms -sign invocation in OpenSslOptions omitted -binary, so openssl ran the content through SMIME_crlf_copy and digested a CRLF-rewritten copy rather than the bytes on disk. This is OpenSSL library behaviour, not host behaviour.

The manifest is only the visible symptom. Text canonicalization also rewrites every lone LF inside a zip, dll or exe before hashing, so detached signatures over binaries have never covered the shipped bytes either. The verify command documented in Readme.md passes -binary and therefore could not have succeeded against these signatures for any real archive. Two things kept that hidden: the client's HasValidDetachedSignature was reduced to a structural check because the canonicalized digest could not be reproduced in .NET, and the one test that did verify byte-exactly fell back to asserting the .sig merely exists and is non-empty whenever validation failed.

Adds -binary to the service and test-harness templates, restores the client check to a real CheckSignature(verifySignatureOnly: true) against the raw bytes, drops the fallback assertion, and adds LF/CRLF cases that fail without the flag. Signatures issued before this change verify only without -binary and ones issued after only with it.

15081

The cms -sign invocation in OpenSslOptions omitted -binary, so openssl ran the
content through SMIME_crlf_copy and digested a CRLF-rewritten copy rather than
the bytes on disk. This is OpenSSL library behaviour, not host behaviour.

The manifest is only the visible symptom. Text canonicalization also rewrites
every lone LF inside a zip, dll or exe before hashing, so detached signatures
over binaries have never covered the shipped bytes either. The verify command
documented in Readme.md passes -binary and therefore could not have succeeded
against these signatures for any real archive. Two things kept that hidden: the
client's HasValidDetachedSignature was reduced to a structural check because the
canonicalized digest could not be reproduced in .NET, and the one test that did
verify byte-exactly fell back to asserting the .sig merely exists and is
non-empty whenever validation failed.

Adds -binary to the service and test-harness templates, restores the client
check to a real CheckSignature(verifySignatureOnly: true) against the raw bytes,
drops the fallback assertion, and adds LF/CRLF cases that fail without the flag.
Signatures issued before this change verify only without -binary and ones issued
after only with it.
@majorsilence
majorsilence merged commit 6846676 into TownSuite:main Aug 25, 2026
3 checks 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