Repository navigation
Generate and verify digital signatures - #107
Open
deltadecay wants to merge 5 commits into
Open
deltadecay wants to merge 5 commits into
deltadecay wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #107 +/- ##
==========================================
+ Coverage 81.91% 83.67% +1.76%
==========================================
Files 2 2
Lines 1244 1415 +171
==========================================
+ Hits 1019 1184 +165
- Misses 225 231 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
real symbols instead.
Contributor
There was a problem hiding this comment.
[comment generated via AI]
Thanks! Signing and verifying round-trip for RSA and P-256 here (OpenSSL_jll 3.5.4), and changed data, another key or a mismatched digest all give false. A few things before merging:
- Malformed ECDSA signatures throw instead of returning
false.EVP_DigestVerifyFinalreturns -1 when an ECDSA signature isn't valid DER. So a truncated or empty signature, or one with its first byte flipped, throwsOpenSSLError, twice with an empty message. The same inputs givefalsewith an RSA key. Since the signature usually comes from the other party, coulddigest_verifyreturnfalsefor any result other than 1, and throw only when init or update fails? - A failed verify leaves its errors on OpenSSL's per-thread error queue. After one, the queue holds "bad signature" / "padding check failed" (RSA) or "provider signature failure" (EC). The next unrelated
OpenSSLError()on that thread then reports them. Callingclear_errors!()before returningfalseavoids that. - The tests only check the
truecase. Adigest_verifythat always returnedtruewould pass them. Could you add checks that changed data, another key, and a modified or truncated signature givefalse? - The
EC_KEY_set_asn1_flagline inec_generate_keyseems unneeded. Named curves are already the default since OpenSSL 1.1.0: the P-256 public key is the same 91-byte SPKI with or without the line. Unless you saw a case that needed it, I'd drop it from this PR. - Nit: in
digest_sign_final,out_lengthcan go toccallasRef{Csize_t}, withoutpointer_from_objref.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added methods digest_sign and digest_verify to generate and verify
digital signatures.
Tests added with both RSA and EC key signing and verification.