Commit Graph

112 Commits

Author SHA1 Message Date
Tony Arcieri f01437c19d Merge pull request #56 from RustCrypto/ed25519/ensure-s-is-reduced
ed25519: Perform partial reduction check on `Signature`
2019-12-05 09:56:44 -08:00
Tony Arcieri 3862e12046 ed25519: Perform partial reduction check on Signature
Ensures that the three highest bits of the `s` scalar component of an
Ed25519 signature are unset.

This doesn't ensure that `s` is fully reduced (which would require a
full reduction check in the event that the 4th most significant bit is
set), however it will catch a number of invalid signatures relatively
cheaply.

Inspired by:

https://github.com/dalek-cryptography/ed25519-dalek/pull/99
2019-12-05 09:41:33 -08:00
Tony Arcieri 5fcb76b783 Merge pull request #54 from RustCrypto/ecdsa/v0.1.0
ecdsa v0.1.0
2019-10-29 09:47:49 -07:00
Tony Arcieri 9bf4734d7b ecdsa v0.1.0 ecdsa/v0.1.0 2019-10-29 09:34:53 -07:00
Tony Arcieri 8965e23282 Merge pull request #53 from RustCrypto/ecdsa/documentation-improvements
ecdsa: Improve documentation
2019-10-29 09:32:30 -07:00
Tony Arcieri 1b4d83d826 ecdsa: Improve documentation
Adds a README.md and improves comments throught the codebase.
2019-10-29 09:25:51 -07:00
Tony Arcieri c42dd45ba9 Merge pull request #52 from RustCrypto/ecdsa/uncompressed-points
ecdsa: Fix uncompressed point sizes
2019-10-29 08:55:09 -07:00
Tony Arcieri 02d85a9734 ecdsa: Fix uncompressed point sizes
They should be 2 * scalar size + 1-byte (0x04 tag)
2019-10-29 08:44:06 -07:00
Tony Arcieri 78a7eb76d2 Merge pull request #51 from RustCrypto/ecdsa/curve-points
ecdsa: elliptic curve points (compressed/uncompressed)
2019-10-28 19:08:09 -07:00
Tony Arcieri 515b673295 ecdsa: elliptic curve points (compressed/uncompressed)
Adds `CompressedCurvePoint` and `UncompressedCurvePoint` as
representations of bytestrings serialized according to the
`Elliptic-Curve-Point-to-Octet-String` encoding as defined in
section 2.3.3 of SEC 1: Elliptic Curve Cryptography (Version 2.0):

https://www.secg.org/sec1-v2.pdf
2019-10-28 18:40:51 -07:00
Tony Arcieri ba2854378f Merge pull request #50 from RustCrypto/ecdsa/test-vectors
ECDSA: add CAVP vectors for NIST curves (+ secp256k1)
2019-10-28 15:26:16 -07:00
Tony Arcieri e9036dc033 ECDSA: add CAVP vectors for NIST curves (+ secp256k1)
Adds the NIST CAVP vectors for P-256 and P-384, along with a
self-generated test vector for secp256k1.

When available, these are used to test the transcoding functionality.
2019-10-28 14:50:25 -07:00
Tony Arcieri ce034ba493 Merge pull request #49 from RustCrypto/ecdsa/signature-conversions
ecdsa: Asn1Signature <-> FixedSignature translation
2019-10-28 14:12:40 -07:00
Tony Arcieri 409cec8a07 ecdsa: Asn1Signature <-> FixedSignature translation
Adapts the following code from BearSSL to support translation between
ASN.1 DER encoded and fixed size (a.k.a. "raw") signatures.

This additionally allows eagerly checking that ASN.1 DER-encoded
signatures are well-formed.
2019-10-28 13:59:36 -07:00
Tony Arcieri b60c5f3ae4 Merge pull request #48 from RustCrypto/ecdsa/digest
ecdsa: Add `DigestSignature` impls
2019-10-28 13:12:43 -07:00
Tony Arcieri b58ef25a87 ecdsa: Add DigestSignature impls
...gated under a `digest` cargo feature.

These are useful when doing `derive(Signer)` or `derive(Verifier)` using
the `signature_derive` crate.
2019-10-28 13:04:09 -07:00
Tony Arcieri 1db1a5feee Merge pull request #47 from RustCrypto/ecdsa/asn1-signatures
ecdsa: Add Asn1Signature type
2019-10-28 12:47:58 -07:00
Tony Arcieri d4b3e706be ecdsa: Add Asn1Signature type
Support for ASN.1 DER-encoded signatures.

Uses a GenericArray to store the variable-width signature, calculating
maximum DER framing overhead using typenum's type-level arithmetic.
2019-10-28 12:40:00 -07:00
Tony Arcieri a244d36bfe Merge pull request #46 from RustCrypto/ecdsa/reorganize-bounds
ecdsa: Reorganize size-related trait bounds
2019-10-28 11:59:57 -07:00
Tony Arcieri f628823261 ecdsa: Reorganize size-related trait bounds
Moves all trait bounds related to `FixedSignature` from the `Curve`
trait to the `FixedSignature` type.

This avoids compounding the complexity of the trait bounds on `Curve`
when ASN.1 DER signatures are added.
2019-10-28 11:52:08 -07:00
Tony Arcieri 7ba9092de1 Merge pull request #45 from RustCrypto/ecdsa/fixed-signatures
ecdsa: Add FixedSignature type
2019-10-28 11:05:07 -07:00
Tony Arcieri 31becf412c ecdsa: Add FixedSignature type
Type for representing fixed-sized (a.k.a. "raw") ECDSA signatures
2019-10-28 10:54:06 -07:00
Tony Arcieri 25e9d348f4 Merge pull request #44 from RustCrypto/test-all-crates-for-no-std-and-wasm
.travis.yml: Test all crates for no_std and WASM compatibility
2019-10-27 13:20:57 -07:00
Tony Arcieri 93a3122979 .travis.yml: Test all crates for no_std and WASM compatibility
Previously only the `signature` crate was being tested
2019-10-27 13:14:34 -07:00
Tony Arcieri d0962c2521 Merge pull request #43 from RustCrypto/ecdsa/curves
ecdsa: Initial curves (NIST P-256/384, secp256k1)
2019-10-27 12:40:18 -07:00
Tony Arcieri a3ca6bb73e ecdsa: Initial curves (NIST P-256/384, secp256k1)
Adds a `Curve` trait representing short Weirstrass curves suitable for
use with ECDSA, along with an initial set of curves and their associated
private scalar size.
2019-10-27 12:30:46 -07:00
Tony Arcieri fd69da3e85 Merge pull request #42 from RustCrypto/ed25519/v1.0.0-pre.1
ed25519 v1.0.0-pre.1
2019-10-27 10:59:26 -07:00
Tony Arcieri c50876ba1e ed25519 v1.0.0-pre.1 ed25519/v1.0.0-pre.1 2019-10-27 10:26:19 -07:00
Tony Arcieri a16f41b0ab Merge pull request #41 from RustCrypto/signature/1.0.0-pre.1
signature 1.0.0-pre.1
2019-10-27 10:21:44 -07:00
Tony Arcieri 90b6599a57 signature 1.0.0-pre.1 2019-10-27 10:14:29 -07:00
Tony Arcieri 7cb19268fd Merge pull request #40 from RustCrypto/ed25519/serde
ed25519: optional serde support
2019-10-27 10:02:08 -07:00
Tony Arcieri 26e21c8a4f ed25519: optional serde support
Serializes and deserializes Ed25519 signatures as 64-byte "octet strings"
2019-10-27 09:54:03 -07:00
Tony Arcieri 6b759c387a Merge pull request #39 from RustCrypto/ed25519/try-from
ed25519: Add `TryFrom` impl for `Signature`
2019-10-27 08:46:52 -07:00
Tony Arcieri 9fb6720117 ed25519: Add TryFrom impl for Signature 2019-10-27 08:34:43 -07:00
Tony Arcieri d5bb9b984a Merge pull request #38 from RustCrypto/remove-alloc-feature-msrv-1-31
signature: Remove `alloc` feature; MSRV 1.31+
2019-10-26 09:31:21 -07:00
Tony Arcieri 3a67e63545 signature: Remove alloc feature; MSRV 1.31+
The only thing the `signature` crate uses `alloc` for is the
`Signature::to_vec` method, which is trivially accomplished otherwise as
`sig.as_ref().to_vec()` or various other ways.

By getting rid of it, we can completely get rid of the `alloc` feature,
and with that reduce the MSRV back to 1.31.

It might be worth considering a 1.0 release with a higher MSRV so we can
leverage `TryFrom`, but for now, this provides wider compatibility by
removing a single (mis)feature.
2019-10-26 09:22:02 -07:00
Tony Arcieri 301c1091f7 Merge pull request #37 from RustCrypto/rust-1-30-error-handling
signature: Use `Error::source` instead of `::cause`
2019-10-26 09:01:15 -07:00
Tony Arcieri fc835cd182 signature: Use Error::source instead of ::cause
This upgrades to the `std::error::Error` features for boxed,
downcastable error sources introduced in Rust 1.30, namely switching
from `Error::cause` to `Error::source`, which adds a `'static` bound and
therefore allows it to support downcasting.

Additionally, it defines a `BoxError` type incorporating those bounds
along with `Send + Sync`, ensuring that `signature::Error` itself is
`Send + Sync`, which should improve the ergonomics.
2019-10-26 08:44:51 -07:00
Tony Arcieri aa74a320b5 Merge pull request #36 from RustCrypto/readme/fix-link
README.md: Fix link
2019-10-11 11:12:37 -07:00
Tony Arcieri ce3372ae6a README.md: Fix link 2019-10-11 11:02:35 -07:00
Tony Arcieri 56bbcce71b Merge pull request #35 from RustCrypto/ed25519/1.0.0-pre.0
ed25519 1.0.0-pre.0
2019-10-11 11:01:12 -07:00
Tony Arcieri e47830d381 ed25519 1.0.0-pre.0 ed25519/v1.0.0-pre.0 2019-10-11 10:50:27 -07:00
Tony Arcieri 9edb86a20b Merge pull request #34 from RustCrypto/signature-crate/1.0.0-pre.0
signature 1.0.0-pre.0
2019-10-11 10:07:07 -07:00
Tony Arcieri 833ba72276 signature 1.0.0-pre.0 2019-10-11 09:58:08 -07:00
Tony Arcieri e1c8919ba9 Merge pull request #32 from RustCrypto/signature-crate/1.0-stabilization-proposal
signature crate: 1.0 stabilization proposal
2019-10-11 09:52:05 -07:00
Tony Arcieri b229861ef0 signature crate: 1.0 stabilization proposal
The motivation for 1.0 stabilization of the `signature` crate is the
upcoming 1.0 release of `ed25519-dalek`. In order to promote Ed25519
interoperability, it would be great if `ed25519-dalek` could use the
traits from this crate along with the `ed25519::Signature` type from the
`ed25519` crate.

To get there, I think we need to do a 1.0 release of this crate, as well
as the `ed25519` crate.

The main impediment towards doing so is the `digest` crate is presently
stuck at v0.8. It would be nice to be able to continue upgrading it,
especially to a 1.0 release, but that would otherwise be a semver
breaking change.

To allow agility around `digest`, and `signatory_derive` which depends
on it, this commit places access to both under the `digest-preview` and
`derive-preview` Cargo features respectively, and calls them out as
not covered under SemVer and subject to change, but breaking changes
will be done with a minor version bump.
2019-10-11 09:33:55 -07:00
Tony Arcieri bc54784f27 Merge pull request #33 from RustCrypto/revert-removal-of-digest-signature
Revert removal of DigestSignature
2019-10-11 09:31:55 -07:00
Tony Arcieri 87f0b1b2f1 DigestSignature: update description
Updates the description to note the `DigestSignature` marker trait is
useful for custom derive support as the blanket impl was removed.
2019-10-11 09:20:46 -07:00
Tony Arcieri 13674773a5 Revert "signature-crate: Replace DigestSignature with derive attr"
This reverts commit 48e33d8758.

After updating my downstream consumers to try to use this, I encountered
an important case where this falls down: deriving `Signer` and
`Verifier` on generic types where the `Digest` *can only* be generically
specified as an associated type, as the `yubihsm` crate is doing here:

https://github.com/tendermint/yubihsm-rs/blob/develop/src/ecdsa/signer.rs#L22

The goal of switching to a derive attribute was to make this
functionality more flexible and eliminate the need for a marker trate,
but in this particular case (one I personally consider very important)
it had the opposite effect.
2019-10-11 09:13:50 -07:00
Tony Arcieri 0284decb3f Merge pull request #31 from RustCrypto/improve-toplevel-readme
Toplevel README.md improvements
2019-10-10 09:29:21 -07:00