mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Merge branch 'release/0.4.3'
This commit is contained in:
commit
608f63d0eb
5 changed files with 53 additions and 31 deletions
10
Cargo.toml
10
Cargo.toml
|
|
@ -1,9 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ed25519-dalek"
|
name = "ed25519-dalek"
|
||||||
version = "0.4.2"
|
version = "0.4.3"
|
||||||
authors = ["Isis Lovecruft <isis@torproject.org>"]
|
authors = ["Isis Lovecruft <isis@torproject.org>"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "CC0-1.0"
|
license = "BSD-3-Clause"
|
||||||
repository = "https://github.com/isislovecruft/ed25519-dalek"
|
repository = "https://github.com/isislovecruft/ed25519-dalek"
|
||||||
homepage = "https://code.ciph.re/isis/ed25519-dalek"
|
homepage = "https://code.ciph.re/isis/ed25519-dalek"
|
||||||
documentation = "https://docs.rs/ed25519-dalek"
|
documentation = "https://docs.rs/ed25519-dalek"
|
||||||
|
|
@ -19,11 +19,11 @@ travis-ci = { repository = "isislovecruft/ed25519-dalek", branch = "master"}
|
||||||
arrayref = "0.3.4"
|
arrayref = "0.3.4"
|
||||||
|
|
||||||
[dependencies.curve25519-dalek]
|
[dependencies.curve25519-dalek]
|
||||||
version = "^0.11"
|
version = "^0.12"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.subtle]
|
[dependencies.subtle]
|
||||||
version = "^0.2"
|
version = "^0.3"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.rand]
|
[dependencies.rand]
|
||||||
|
|
@ -38,7 +38,7 @@ version = "^0.6"
|
||||||
version = "^0.8"
|
version = "^0.8"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rustc-serialize = "0.3"
|
hex = "0.2"
|
||||||
sha2 = "^0.6"
|
sha2 = "^0.6"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
||||||
28
LICENSE
Normal file
28
LICENSE
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
Copyright (c) 2017 Isis Agora Lovecruft. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# ed25519-dalek   
|
# ed25519-dalek [](https://crates.io/crates/ed25519-dalek) [](https://docs.rs/ed25519-dalek) [](https://travis-ci.org/isislovecruft/ed25519-dalek?branch=master)
|
||||||
|
|
||||||
Fast and efficient Rust implementation of ed25519 key generation, signing, and
|
Fast and efficient Rust implementation of ed25519 key generation, signing, and
|
||||||
verification in Rust.
|
verification in Rust.
|
||||||
|
|
@ -74,7 +74,7 @@ included in the SUPERCOP benchmarking suite (albeit their numbers are for the
|
||||||
older Nehalem microarchitecture).
|
older Nehalem microarchitecture).
|
||||||
|
|
||||||
Additionally, thanks to Rust, this implementation has both type and memory
|
Additionally, thanks to Rust, this implementation has both type and memory
|
||||||
safety. It's also easily readable a much larger set of people than those who
|
safety. It's also easily readable by a much larger set of people than those who
|
||||||
can read qhasm, making it more readily and more easily auditable. We're of
|
can read qhasm, making it more readily and more easily auditable. We're of
|
||||||
the opinion that, ultimately, these features—combined with speed—are more
|
the opinion that, ultimately, these features—combined with speed—are more
|
||||||
valuable than simply cycle counts alone.
|
valuable than simply cycle counts alone.
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
// -*- mode: rust; -*-
|
// -*- mode: rust; -*-
|
||||||
//
|
//
|
||||||
// To the extent possible under law, the authors have waived all copyright and
|
// This file is part of ed25519-dalek.
|
||||||
// related or neighboring rights to curve25519-dalek, using the Creative
|
// Copyright (c) 2017 Isis Lovecruft
|
||||||
// Commons "CC0" public domain dedication. See
|
// See LICENSE for licensing information.
|
||||||
// <http://creativecommons.org/publicdomain/zero/.0/> for full details.
|
|
||||||
//
|
//
|
||||||
// Authors:
|
// Authors:
|
||||||
// - Isis Agora Lovecruft <isis@patternsinthevoid.net>
|
// - Isis Agora Lovecruft <isis@patternsinthevoid.net>
|
||||||
|
|
@ -298,7 +297,7 @@ impl PublicKey {
|
||||||
digest[31] &= 127;
|
digest[31] &= 127;
|
||||||
digest[31] |= 64;
|
digest[31] |= 64;
|
||||||
|
|
||||||
pk = (&Scalar(*digest) * &constants::ED25519_BASEPOINT_TABLE).compress_edwards().to_bytes();
|
pk = (&Scalar(*digest) * &constants::ED25519_BASEPOINT_TABLE).compress().to_bytes();
|
||||||
|
|
||||||
PublicKey(CompressedEdwardsY(pk))
|
PublicKey(CompressedEdwardsY(pk))
|
||||||
}
|
}
|
||||||
|
|
@ -345,11 +344,7 @@ impl PublicKey {
|
||||||
digest_reduced = Scalar::reduce(&digest);
|
digest_reduced = Scalar::reduce(&digest);
|
||||||
r = vartime::double_scalar_mult_basepoint(&digest_reduced, &a, &Scalar(*top_half));
|
r = vartime::double_scalar_mult_basepoint(&digest_reduced, &a, &Scalar(*top_half));
|
||||||
|
|
||||||
if slices_equal(bottom_half, &r.compress_edwards().to_bytes()) == 1 {
|
slices_equal(bottom_half, &r.compress().to_bytes()) == 1
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -464,7 +459,7 @@ impl Keypair {
|
||||||
r = &mesg_digest * &constants::ED25519_BASEPOINT_TABLE;
|
r = &mesg_digest * &constants::ED25519_BASEPOINT_TABLE;
|
||||||
|
|
||||||
h = D::default();
|
h = D::default();
|
||||||
h.input(&r.compress_edwards().to_bytes()[..]);
|
h.input(&r.compress().to_bytes()[..]);
|
||||||
h.input(public_key);
|
h.input(public_key);
|
||||||
h.input(&message);
|
h.input(&message);
|
||||||
hash.copy_from_slice(h.fixed_result().as_slice());
|
hash.copy_from_slice(h.fixed_result().as_slice());
|
||||||
|
|
@ -472,7 +467,7 @@ impl Keypair {
|
||||||
hram_digest = Scalar::reduce(&hash);
|
hram_digest = Scalar::reduce(&hash);
|
||||||
|
|
||||||
s = Scalar::multiply_add(&hram_digest, &expanded_key_secret, &mesg_digest);
|
s = Scalar::multiply_add(&hram_digest, &expanded_key_secret, &mesg_digest);
|
||||||
t = r.compress_edwards();
|
t = r.compress();
|
||||||
|
|
||||||
signature_bytes[..32].copy_from_slice(&t.0);
|
signature_bytes[..32].copy_from_slice(&t.0);
|
||||||
signature_bytes[32..64].copy_from_slice(&s.0);
|
signature_bytes[32..64].copy_from_slice(&s.0);
|
||||||
|
|
@ -495,7 +490,7 @@ mod test {
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use curve25519_dalek::edwards::ExtendedPoint;
|
use curve25519_dalek::edwards::ExtendedPoint;
|
||||||
use rand::OsRng;
|
use rand::OsRng;
|
||||||
use rustc_serialize::hex::FromHex;
|
use hex::FromHex;
|
||||||
use sha2::Sha512;
|
use sha2::Sha512;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|
@ -519,7 +514,7 @@ mod test {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public = PublicKey(a.compress_edwards());
|
public = PublicKey(a.compress());
|
||||||
|
|
||||||
assert!(keypair.public.0 == public.0);
|
assert!(keypair.public.0 == public.0);
|
||||||
}
|
}
|
||||||
|
|
@ -573,14 +568,14 @@ mod test {
|
||||||
let parts: Vec<&str> = line.split(':').collect();
|
let parts: Vec<&str> = line.split(':').collect();
|
||||||
assert_eq!(parts.len(), 5, "wrong number of fields in line {}", lineno);
|
assert_eq!(parts.len(), 5, "wrong number of fields in line {}", lineno);
|
||||||
|
|
||||||
let sec_bytes: &[u8] = &parts[0].from_hex().unwrap();
|
let sec_bytes: Vec<u8>= FromHex::from_hex(&parts[0]).unwrap();
|
||||||
let pub_bytes: &[u8] = &parts[1].from_hex().unwrap();
|
let pub_bytes: Vec<u8> = FromHex::from_hex(&parts[1]).unwrap();
|
||||||
let message: &[u8] = &parts[2].from_hex().unwrap();
|
let message: Vec<u8> = FromHex::from_hex(&parts[2]).unwrap();
|
||||||
let sig_bytes: &[u8] = &parts[3].from_hex().unwrap();
|
let sig_bytes: Vec<u8> = FromHex::from_hex(&parts[3]).unwrap();
|
||||||
|
|
||||||
// The signatures in the test vectors also include the message
|
// The signatures in the test vectors also include the message
|
||||||
// at the end, but we just want R and S.
|
// at the end, but we just want R and S.
|
||||||
let sig1: Signature = Signature::from_bytes(sig_bytes);
|
let sig1: Signature = Signature::from_bytes(sig_bytes.as_ref());
|
||||||
|
|
||||||
let keypair: Keypair = Keypair::from_bytes(
|
let keypair: Keypair = Keypair::from_bytes(
|
||||||
array_ref!(*pub_bytes, 0, PUBLIC_KEY_LENGTH),
|
array_ref!(*pub_bytes, 0, PUBLIC_KEY_LENGTH),
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
// -*- mode: rust; -*-
|
// -*- mode: rust; -*-
|
||||||
//
|
//
|
||||||
// To the extent possible under law, the authors have waived all copyright and
|
// This file is part of ed25519-dalek.
|
||||||
// related or neighboring rights to curve25519-dalek, using the Creative
|
// Copyright (c) 2017 Isis Lovecruft
|
||||||
// Commons "CC0" public domain dedication. See
|
// See LICENSE for licensing information.
|
||||||
// <http://creativecommons.org/publicdomain/zero/.0/> for full details.
|
|
||||||
//
|
//
|
||||||
// Authors:
|
// Authors:
|
||||||
// - Isis Agora Lovecruft <isis@patternsinthevoid.net>
|
// - Isis Agora Lovecruft <isis@patternsinthevoid.net>
|
||||||
|
|
@ -128,7 +127,7 @@ extern crate std;
|
||||||
extern crate sha2;
|
extern crate sha2;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
extern crate rustc_serialize;
|
extern crate hex;
|
||||||
|
|
||||||
#[cfg(all(test, feature = "bench"))]
|
#[cfg(all(test, feature = "bench"))]
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue