Skip to content

dsa: capture error #941

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

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ecdsa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ elliptic-curve = { version = "0.14.0-rc.1", default-features = false, features =
signature = { version = "=3.0.0-pre", default-features = false, features = ["rand_core"] }

# optional dependencies
der = { version = "0.8.0-rc.1", optional = true }
der = { version = "0.8.0-rc.2", optional = true }
digest = { version = "=0.11.0-pre.10", optional = true, default-features = false, features = ["oid"] }
rfc6979 = { version = "=0.5.0-pre.4", optional = true }
serdect = { version = "0.3", optional = true, default-features = false, features = ["alloc"] }
Expand Down
27 changes: 9 additions & 18 deletions ecdsa/src/der.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,31 +420,22 @@ mod tests {
#[test]
fn test_asn1_too_short_signature() {
assert!(Signature::from_der(&[]).is_err());
assert!(Signature::from_der(&[der::Tag::Sequence.into()]).is_err());
assert!(Signature::from_der(&[der::Tag::Sequence.into(), 0x00]).is_err());
assert!(
Signature::from_der(&[
der::Tag::Sequence.into(),
0x03,
der::Tag::Integer.into(),
0x01,
0x01
])
.is_err()
);
assert!(Signature::from_der(&[0x30]).is_err());
assert!(Signature::from_der(&[0x30, 0x00]).is_err());
assert!(Signature::from_der(&[0x30, 0x03, 0x02, 0x01, 0x01]).is_err());
}

#[test]
fn test_asn1_non_der_signature() {
// A minimal 8-byte ASN.1 signature parses OK.
assert!(
Signature::from_der(&[
der::Tag::Sequence.into(),
0x30, // Tag::Sequence,
0x06, // length of below
der::Tag::Integer.into(),
0x02, // Tag::Integer,
0x01, // length of value
0x01, // value=1
der::Tag::Integer.into(),
0x02, // Tag::Integer,
0x01, // length of value
0x01, // value=1
])
Expand All @@ -456,13 +447,13 @@ mod tests {
// https://github.com/google/wycheproof/blob/2196000605e4/testvectors/ecdsa_secp256k1_sha256_test.json#L57-L66
assert!(
Signature::from_der(&[
der::Tag::Sequence.into(),
0x30, // Tag::Sequence
0x81, // extended length: 1 length byte to come
0x06, // length of below
der::Tag::Integer.into(),
0x02, // Tag::Integer
0x01, // length of value
0x01, // value=1
der::Tag::Integer.into(),
0x02, // Tag::Integer
0x01, // length of value
0x01, // value=1
])
Expand Down