Commit graph

215 commits

Author SHA1 Message Date
Isis Lovecruft
5458ebef88
Fix no_std issue with new error types. 2020-07-16 23:18:00 +00:00
Isis Lovecruft
d3a5b3bd81
Remove unsafe trait impls. 2020-07-16 23:02:27 +00:00
Isis Lovecruft
7243d7151d
Fix handling of external error types. 2020-07-16 22:19:40 +00:00
Isis Lovecruft
69004599c5
Fix misnamed error type. 2020-07-16 21:49:14 +00:00
Isis Lovecruft
b84f1df47b
Merge branch 'fix/ed25519ph-context' into develop 2020-07-15 17:44:54 +00:00
Isis Lovecruft
97787d3716
Remove impl of std::error::Error for SignatureError.
We're now aliasing SignatureError to the error type from the signature
crate.
2020-07-14 00:37:56 +00:00
Isis Lovecruft
989c5e4c18
Fix ed25519ph context length error handling in sign_prehashed().
RFC8032 specifies that the context cannot be greater than 255 octets,
but in the previous implementation in ed25519-dalek, this error would
only be caught by a debug_assert.  This changes the sign_prehashed()
function to return a Result so that the error can be handled at
runtime and the library no longer allows misuse by creating signatures
that other libraries cannot handle.
2020-07-14 00:25:40 +00:00
Isis Lovecruft
f1d8576f12
Impl std::error::Error for SignatureError. 2020-07-13 23:19:55 +00:00
Isis Lovecruft
84047448da
Merge remote-tracking branch 'tarcieri/ed25519-crate' into develop 2020-07-13 23:00:23 +00:00
isis agora lovecruft
005fc35f52
Merge pull request #116 from NikVolf/nv-fix-alloc
Fix alloc feature compilation
2020-06-30 22:51:07 +00:00
Isis Lovecruft
c5386c0df9
Merge branch 'master' into develop 2020-06-30 22:44:29 +00:00
isis agora lovecruft
6dfcc4ba27
Merge pull request #112 from jamesmunns/improve-deserialize
Add additional visitor methods for deserialization
2020-06-30 22:05:16 +00:00
Tony Arcieri
6e0667d429 Use ed25519 + signature interop crates
The `signature` crate provides `Signer` and `Verifier` traits generic
over signature types:

https://github.com/RustCrypto/traits/tree/master/signature

There's presently an open call to stabilize the parts of its API needed
by Ed25519 signatures and release a 1.0 version:

https://github.com/RustCrypto/traits/issues/78

The `ed25519` crate, based on the `signature` crate, provides an
`ed25519::Signature` type which can be shared across multiple Ed25519
crates (e.g. it is also used by the `yubihsm` crate):

https://github.com/RustCrypto/signatures/tree/master/ed25519

This commit integrates the `ed25519::Signature` type, and changes the
existing `sign` and `verify` methods (where applicable) to use the
`Signer` and `Verifier` traits from the `signature` crate. Additionally,
it replaces `SignatureError` with the `signature` crate's error type.

This has the drawback of requiring the `Signer` and/or `Verifier` traits
are in scope in order to create and/or verify signatures, but with the
benefit of supporting interoperability with other Ed25519 crates which
also make use of these traits.
2020-04-20 09:15:10 -07:00
phayes
2dad99a60e
Removing double 2020-02-23 07:32:45 -08:00
NikVolf
dedbb9b96a fix alloc feature 2020-02-22 15:10:21 +03:00
James Munns
3d9d11dcdf Add additional visitor methods for deserialization 2020-01-13 00:59:08 +01:00
Isis Lovecruft
8a2e9af9d6
Fix breakage on builds with the rand crate disabled.
* CLOSES https://github.com/dalek-cryptography/ed25519-dalek/issues/108
 * THANKS TO @tarcieri
2019-12-11 23:02:44 +00:00
Isis Lovecruft
af15a0e553
Merge remote-tracking branch 'dalek/develop' into develop 2019-12-11 22:49:06 +00:00
Isis Lovecruft
9363690191
Fix outdated docstring for verify_batch(). 2019-12-11 22:48:33 +00:00
Isis Lovecruft
8ca3be99e9
Switch to using zeroize rather than clear_on_drop. 2019-12-09 22:39:57 +00:00
Isis Lovecruft
1be2a65777
Maybe I should try compiling my code before showing other cryptographers?
lol
2019-11-26 22:57:24 +00:00
Isis Lovecruft
ec551145e9
Add message lengths into nonce generator protocol transcript. 2019-11-22 23:21:01 +00:00
Isis Lovecruft
bd6a897729
Actually use the transcript PRNG. 2019-11-22 23:40:46 +00:00
Isis Lovecruft
85a218ac40
Implement deterministic batch verification and synthetic nonce generation. 2019-11-22 23:29:14 +00:00
Isis Lovecruft
ee67f36ba9
Move verify_batch() to new batch module. 2019-11-21 00:31:10 +00:00
Isis Lovecruft
8f848793f3
Merge branch 'feature/no-panics' into develop 2019-11-21 00:09:32 +00:00
Isis Lovecruft
15d0a6596f
Document batch verification on docs.rs and fix false autolinking. 2019-11-14 22:01:34 +00:00
Isis Lovecruft
81f906ca30
Replace failure dependency with impls of std::error::Error. 2019-10-26 04:16:33 +00:00
Isis Lovecruft
fe782cd896
Merge remote-tracking branch 'mikelodder7/master' into develop 2019-10-25 21:50:57 +00:00
Michael Lodder
c3f4c7a67e Update to latest rand
Signed-off-by: Michael Lodder <redmike7@gmail.com>
2019-10-21 09:03:08 -06:00
Isis Lovecruft
f1d4c4a732
Remove panics from batch verification API in lieu of better error handling. 2019-10-18 20:20:34 +00:00
Isis Lovecruft
deca36d074
Add an optimisation to succeed fast for scalars whose 4th MSB is unset.
This is only done during signature verification.
2019-10-11 21:33:55 +00:00
Isis Lovecruft
de3eb13dcf
Merge branch 'feature/97-verify-strict_1' into develop 2019-10-11 21:24:34 +00:00
Isis Lovecruft
3773f56d15
Merge branch 'feature/rust-2018' into develop 2019-10-10 22:10:28 +00:00
Isis Lovecruft
a065bee381
Enable Rust 2018. 2019-10-07 23:01:10 +00:00
isis agora lovecruft
29622ec10b
Merge pull request #96 from Arnaz87/master
Drop the static lifetime for context in sign_prehashed
2019-10-07 20:06:48 +00:00
Isis Lovecruft
2d5fe86f30
Document anti-malleability features/functionality. 2019-10-07 19:03:15 +00:00
Isis Lovecruft
ce2260afab
Implement stricter scalar malleability checking for signatures.
Previously, we were checking that the highest 3 bits were unset, which still
leaves 2^253 - 2^252 + 27742317777372353535851937790883648493 potential scalars
for the `s` component of a signature which are not strictly mod \ell.

This change fixes that.

Note: This change makes ed25519-dalek incompatible with ed25519-donna in that
some signatures produced by donna will be verifiable by donna but NOT VERIFIABLE
by dalek.  On the other hand, libsodium exports a -DED25519_COMPAT feature,
which when enabled, means it is compatible with dalek with the
`legacy_compatibility` feature disabled.  Otherwise, libsodium's behaviour is
identical to the behaviour enabled by default in this patch.
2019-10-04 19:34:00 +00:00
Isis Lovecruft
28eed1cba0
Add PublicKey::verify_strict() and Keypair::verify_strict() methods. 2019-10-04 02:54:13 +00:00
Isis Lovecruft
7dd99afb67
Remove most of the rand_os crate, which is only used for testing. 2019-10-04 02:46:02 +00:00
Isis Lovecruft
1342e2a3a4
Fix no_std+alloc builds. 2019-10-04 02:05:20 +00:00
Isis Lovecruft
aa49b4cd8d
Fix two failing doctests. 2019-10-04 01:19:23 +00:00
Arnaud Castellanos Galea
1c9f484d97 Drop the static lifetime for context in sign_prehashed 2019-09-30 16:42:52 +08:00
Isis Lovecruft
d31df0aaa8
Remove sha2 dep; limit rand depends; fixes after PR#68 merge.
* ADD new "batch" feature for feature-gating ed25519 batch verification; off by
   default. The "batch" feature is the only thing which depends on all of the
   `rand` crate, since it requires the functionality of `rand::thread_rng()`.
   Without batch verification, the rest of ed25519-dalek only depends on
   `rand_os` and `rand_core`.
2019-04-02 01:46:23 +00:00
Isis Lovecruft
1bec256418
Merge remote-tracking branch 'newpavlov/rand_core' into develop 2019-03-12 22:22:19 +00:00
Nicolas Stalder
1dfe00b79d Fix rand dependency, deal with unusedness warnings 2019-01-27 03:06:18 +01:00
Isis Lovecruft
ae8764fbef
Update copyright year to 2019 and destroy capitalism. 2019-01-18 04:59:12 +00:00
Артём Павлов [Artyom Pavlov]
762eb0c470 use rand_core 2019-01-05 15:58:59 +03:00
Isis Lovecruft
0ddf39e443
Revise some module descriptions. 2018-12-30 04:27:40 +00:00
Isis Lovecruft
8b30d4084a
Run rustfmt on src/ed25519.rs. 2018-12-30 04:16:03 +00:00
Isis Lovecruft
fa726cfdcc
Run rustfmt on src/lib.rs. 2018-12-30 04:12:33 +00:00
Isis Lovecruft
ad49d31bbc
Run rustfmt on src/errors.rs. 2018-12-30 04:10:59 +00:00
Isis Lovecruft
811793ba2b
Run rustfmt on src/secret.rs. 2018-12-30 04:10:09 +00:00
Isis Lovecruft
d853856c36
Run rustfmt on src/public.rs. 2018-12-30 04:07:50 +00:00
Isis Lovecruft
a141863542
Run rustfmt on src/signature.rs. 2018-12-30 04:05:20 +00:00
Isis Lovecruft
e6528bd683
Create new module for public key code. 2018-12-30 03:53:42 +00:00
Isis Lovecruft
e3d7c16aac
Make errors module private. 2018-12-30 03:53:42 +00:00
Isis Lovecruft
6fea2e1ea0
Realphabetise extern crates. 2018-12-30 03:53:42 +00:00
Isis Lovecruft
f6ec28c077
Create module for secret key types. 2018-12-30 03:53:42 +00:00
Isis Lovecruft
1cf581d67d
Add lints (and fix warnings) for Rust 2018 code. 2018-12-30 03:27:01 +00:00
Isis Lovecruft
ce857a50e7
Remove unnecessary #![allow(unused_features)] lint. 2018-12-30 03:11:28 +00:00
Isis Lovecruft
d748a41894
Create new module for Signature type. 2018-12-30 03:03:40 +00:00
Isis Lovecruft
80e72db677
Create new module for constants. 2018-12-30 02:36:49 +00:00
Isis Lovecruft
e88da5ea85
Move integration tests to their own directory. 2018-12-30 02:32:21 +00:00
Isis Lovecruft
4ee77b915e
Avoid using deprecated import path for rand::rngs::OsRng. 2018-12-30 02:31:47 +00:00
Isis Lovecruft
486f23f1ad
Fix some inconsistent terminology in docstrings. 2018-12-30 02:31:47 +00:00
Isis Lovecruft
d81d43e3ae
Hardcode use of sha2::Sha512 in most cases.
This implements https://github.com/dalek-cryptography/ed25519-dalek/issues/64

You can still choose the "prehash" algorithm, as long as it has 64 bytes of
output.  Otherwise, everything is hardcoded to use sha2::Sha512.  To use a
different implementation you'll need a [patch.crates-io] section in cargo
config.
2018-12-30 00:40:01 +00:00
Isis Lovecruft
7877a7fa00
WARNING: Remove #[repr(C)] from all types. 2018-12-23 12:00:59 +00:00
Isis Lovecruft
8dbaf9a8d2
Move PublicKey point decompression into initialisation.
This caches the public key internally so that we effectively get a free
speedup on key reuse in regular signature verification, similar to that in
batch verification.  (However, this also "speeds up"¹ batch verifications.)

¹ Less of a speed up than moving the computation elsewhere, but the speed up
on reuse still also applies to key reuse for batch verification.
2018-12-23 12:00:59 +00:00
Isis Lovecruft
3d697bf27a
Fix doctests which relied on the sha2 feature being enabled. 2018-12-22 13:13:21 +00:00
Isis Lovecruft
a9e5410f69
Fix serialised size assumptions from #48.
Unfortunately the serialised size is likely never going to be the same
as the type's size in memory, as most serialisation formats define
additional headers for parsing safety reasons, such as buffer lengths
and type information.
2018-12-22 13:13:21 +00:00
Isis Lovecruft
80ae5d0683
Cleanup RNG usage after merging #57. 2018-12-22 12:20:59 +00:00
isis agora lovecruft
85285576a7
Merge pull request #57 from IronCoreLabs/rand-0.6
Rand 0.6 version bump
2018-12-18 01:33:57 +00:00
Isis Lovecruft
0dab8943a1
Merge remote-tracking branch 'garious/add-as-ref' into develop 2018-12-18 01:13:13 +00:00
isis agora lovecruft
26e017df7c
Revert "Add AsRef instances for PublicKey and SecretKey" 2018-12-18 01:09:00 +00:00
isis agora lovecruft
60dea0b3b1
Merge pull request #48 from garious/serialized-size
Add tests for upgraded generic_array
2018-12-18 00:46:05 +00:00
Colt Frederickson
42b5d6ada9 Rand 0.6 version bump 2018-11-14 17:08:32 -07:00
Greg Fitzgerald
680f68be31 Add tests for generic_array serialized size
generic_array v0.12 no longer serializes GenericArray as a Vec,
which reduces the serialized size of PublicKey, Signature, and
SecretKey by 8 bytes. Now that generic_array has been upgraded,
these tests simply ensure the serialization size doesn't change
in the future.
2018-11-09 10:16:14 -07:00
Greg Fitzgerald
a3cfc7e294 Add AsRef instances for PublicKey and SecretKey
This just makes it a little easier to migrate to this library from
alternatives such as 'ring'.
2018-11-09 10:13:16 -07:00
Greg Fitzgerald
82948f0dd6 Fix serde doc tests
And let latest rustfmt reorder imports.
2018-11-09 10:12:32 -07:00
Isis Lovecruft
b97fa08900
Update curve25519-dalek dependency to 1.0.0-pre.0. 2018-11-06 01:40:21 +00:00
Henry de Valence
1e8b9f962b Remove unused features 2018-09-26 11:38:41 -07:00
isis agora lovecruft
da8e609dc2
Merge pull request #36 from sunhuachuang/develop
fix doc code
2018-09-14 19:04:51 +00:00
Isis Lovecruft
49ebfa13de
Implement From<ExpandedSecretKey> for PublicKey.
* CLOSES https://github.com/dalek-cryptography/ed25519-dalek/issues/39
2018-09-14 18:28:16 +00:00
sun
0ea12f922e fix doc code 2018-08-24 11:27:15 +08:00
Isis Lovecruft
3ad616a23c
Remove unused csprng parameter from verify_batch() function. 2018-07-27 17:30:57 +00:00
Isis Lovecruft
e35323412d
Merge remote-tracking branch 'hdevalence/feature/27-batch' into develop 2018-07-27 17:24:37 +00:00
Henry de Valence
4c838decd8 Use 128-bit scalars 2018-07-26 21:09:52 -07:00
Henry de Valence
f60987dee5 Try optional_multiscalar_mul 2018-07-26 20:58:11 -07:00
Isis Lovecruft
318898fac1
Merge branch 'feature/drop-with-clear' into develop 2018-07-27 03:56:13 +00:00
Isis Lovecruft
a92a5b73a1
It's 2018 and nothing's gotten any better outside. 2018-07-27 03:48:37 +00:00
Isis Lovecruft
81a3d3298b
Leave a comment explaining why we derive Default. 2018-07-26 20:15:13 +00:00
Isis Lovecruft
6513d4980a
Implement Drop for secret key material using clear_on_drop. 2018-07-20 23:08:08 +00:00
Isis Lovecruft
d896886691
Overwrite secret key material with zeroes on drop. 2018-07-20 20:20:40 +00:00
Isis Lovecruft
ce46a12d92
Implement batch verification.
The API for this isn't the greatest and I apologise for that.  Suggestions for
improvement welcome.  One thing which @hdevalence and I considered was to
change the function signature to:

    pub fn verify_batch<D, C, M, S, K>(messages: M,
                                       signatures: S,
                                       public_keys: K,
                                       csprng: &mut C) -> Result<(), SignatureError>
        where D: Digest<OutputSize = U64> + Default,
              C: Rng + CryptoRng,
              M: IntoIterator<Item = &[u8]>,
              S: IntoIterator,
              S::Item: Borrow<Signature>,
              K: IntoIterator,
              K::Item: Borrow<Signature>,

The other improvement which could be made is to implement 128-bit scalars for
the randomnesses.

 * CLOSES #27
2018-07-17 19:03:46 +00:00
Isis Lovecruft
b32e39c801
Fix match statements on public key decompression. 2018-07-15 22:21:32 +00:00
Isis Lovecruft
cdebf245cc
Merge branch 'feature/cleanup-sig-code' into develop 2018-07-15 22:13:37 +00:00
Isis Lovecruft
2e5363c679
Cleanup verification variable declarations. 2018-07-15 22:04:55 +00:00
Isis Lovecruft
cdbc302da7
Fix a couple docstrings which mentioned r instead of R. 2018-07-15 21:51:23 +00:00
Isis Lovecruft
5c26349b6c
Derive Eq, PartialEq for Signature. 2018-07-15 21:50:20 +00:00