Repository navigation
Conversation
Fix ECDSA384P1Public.sig_len() returning 103 instead of 104 bytes. In ASN.1 DER encoding, each P-384 integer takes up to 51 bytes (2-byte header + 1-byte 0x00 pad + 48-byte value) plus the 2-byte sequence header (0x30 + 1-byte sequence length). It finally requires up to 104 bytes = 2 + 51 + 51. imgtool: scripts: test: keys: add tests for unpadded ECDSA signatures _test_sig validates ASN.1 DER length, checks signatures against cryptography oracle, and verifies both private and public keys rejects modified payloads, corrupted signatures, mismatched keys. imgtool: scripts: test: keys: add tests for padded ECDSA signatures _test_pad_sig exercises all three variable DER lengths up to sig_len (confirming padding), oracle rejection of unstripped bytes, and padding removal in verify() across valid and corrupted inputs. Signed-off-by: Ben Lombard <161700065+a6-a9-ai@users.noreply.github.com> # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch test/ecdsa-pad-sig # Changes to be committed: # modified: scripts/imgtool/keys/ecdsa.py # modified: scripts/tests/keys/test_ecdsa.py # # Untracked files: # commit_msg.txt # test_ecdsa_key.pem # test_ed25519_key.pem #
This branch has not been deployed
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.
Fix ECDSA384P1Public.sig_len() returning 103 instead of 104 bytes. In ASN.1 DER encoding, each P-384 integer takes up to 51 bytes (2-byte header + 1-byte 0x00 pad + 48-byte value) plus the 2-byte sequence header (0x30 + 1-byte sequence length). It finally requires up to 104 bytes = 2 + 51 + 51.
imgtool: scripts: test: keys: add tests for unpadded ECDSA signatures
_test_sig validates ASN.1 DER length, checks signatures against cryptography oracle, and verifies both private and public keys rejects modified payloads, corrupted signatures, mismatched keys.
imgtool: scripts: test: keys: add tests for padded ECDSA signatures
_test_pad_sig exercises all three variable DER lengths up to sig_len (confirming padding), oracle rejection of unstripped bytes, and padding removal in verify() across valid and corrupted inputs.
Signed-off-by: Ben Lombard <a5a8ahaiac@proton.me>