Skip to content
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
36 changes: 1 addition & 35 deletions Cargo.lock

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

5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
members = ["ecdsa", "ed25519"]

[patch.crates-io]
elliptic-curve = { git = "https://github.com/RustCrypto/elliptic-curves" }
k256 = { git = "https://github.com/RustCrypto/elliptic-curves" }
p256 = { git = "https://github.com/RustCrypto/elliptic-curves" }
p384 = { git = "https://github.com/RustCrypto/elliptic-curves" }
elliptic-curve = { git = "https://github.com/RustCrypto/traits" }
23 changes: 2 additions & 21 deletions ecdsa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@ version = "0.4"
default-features = false
features = ["weierstrass"]

[dependencies.k256]
version = "0.3"
optional = true
default-features = false

[dependencies.p256]
version = "0.3"
optional = true
default-features = false

[dependencies.p384]
version = "0.2"
optional = true
default-features = false

[dependencies.sha2]
version = "0.9"
optional = true
Expand All @@ -44,14 +29,10 @@ version = ">= 1.1.0, < 1.2.0"
default-features = false

[features]
default = ["digest", "std", "zeroize"]
default = ["digest", "std"]
digest = ["signature/digest-preview", "sha2"]
secp256k1 = ["k256"]
secp256k1-arithmetic = ["k256/arithmetic", "secp256k1"]
hazmat = []
std = ["elliptic-curve/std", "signature/std"]
zeroize = ["elliptic-curve/zeroize"]
test-vectors = []

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
2 changes: 1 addition & 1 deletion ecdsa/src/asn1_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use crate::{
convert::ScalarPair,
curve::Curve,
generic_array::{typenum::Unsigned, ArrayLength, GenericArray},
Error,
};
Expand All @@ -11,6 +10,7 @@ use core::{
fmt::{self, Debug},
ops::Add,
};
use elliptic_curve::weierstrass::Curve;

/// Maximum overhead of an ASN.1 DER-encoded ECDSA signature for a given curve:
/// 9-bytes.
Expand Down
35 changes: 24 additions & 11 deletions ecdsa/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,22 +301,35 @@ where

#[cfg(all(test, feature = "test-vectors"))]
mod tests {
use crate::{
curve::nistp256::{Asn1Signature, FixedSignature},
test_vectors::nistp256::SHA256_FIXED_SIZE_TEST_VECTORS,
};
use elliptic_curve::{consts::U32, weierstrass::Curve};
use signature::Signature;

#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)]
pub struct ExampleCurve;

impl Curve for ExampleCurve {
type ScalarSize = U32;
}

type Asn1Signature = crate::Asn1Signature<ExampleCurve>;
type FixedSignature = crate::FixedSignature<ExampleCurve>;

const EXAMPLE_SIGNATURE: [u8; 64] = [
0xf3, 0xac, 0x80, 0x61, 0xb5, 0x14, 0x79, 0x5b, 0x88, 0x43, 0xe3, 0xd6, 0x62, 0x95, 0x27,
0xed, 0x2a, 0xfd, 0x6b, 0x1f, 0x6a, 0x55, 0x5a, 0x7a, 0xca, 0xbb, 0x5e, 0x6f, 0x79, 0xc8,
0xc2, 0xac, 0x8b, 0xf7, 0x78, 0x19, 0xca, 0x5, 0xa6, 0xb2, 0x78, 0x6c, 0x76, 0x26, 0x2b,
0xf7, 0x37, 0x1c, 0xef, 0x97, 0xb2, 0x18, 0xe9, 0x6f, 0x17, 0x5a, 0x3c, 0xcd, 0xda, 0x2a,
0xcc, 0x5, 0x89, 0x3,
];

#[test]
fn test_fixed_to_asn1_signature_roundtrip() {
for vector in SHA256_FIXED_SIZE_TEST_VECTORS {
let fixed_signature = FixedSignature::from_bytes(&vector.sig).unwrap();
let fixed_signature = FixedSignature::from_bytes(&EXAMPLE_SIGNATURE).unwrap();

// Convert to DER and back
let asn1_signature = Asn1Signature::from(&fixed_signature);
let fixed_signature2 = FixedSignature::from(&asn1_signature);
// Convert to DER and back
let asn1_signature = Asn1Signature::from(&fixed_signature);
let fixed_signature2 = FixedSignature::from(&asn1_signature);

assert_eq!(fixed_signature, fixed_signature2);
}
assert_eq!(fixed_signature, fixed_signature2);
}
}
33 changes: 0 additions & 33 deletions ecdsa/src/curve.rs

This file was deleted.

19 changes: 0 additions & 19 deletions ecdsa/src/curve/nistp256.rs

This file was deleted.

19 changes: 0 additions & 19 deletions ecdsa/src/curve/nistp384.rs

This file was deleted.

54 changes: 0 additions & 54 deletions ecdsa/src/curve/secp256k1.rs

This file was deleted.

Loading