aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Warner <warner@lothar.com>2017-12-05 23:09:36 -0800
committerBrian Warner <warner@lothar.com>2017-12-05 23:09:36 -0800
commit3e322cb85003f7bca198da316148b19face7e59d (patch)
tree42d49c7206abf2ead6221b5bb493b77c6f0b9198
parent4448ccfe5a66ec2a2fa510f2750ca0507511c0b4 (diff)
downloadPAKEs-3e322cb85003f7bca198da316148b19face7e59d.tar.xz
update to curve25519-dalek-0.14
-rw-r--r--Cargo.toml2
-rw-r--r--src/spake2.rs16
2 files changed, 9 insertions, 9 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 944e995..fb3673d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,7 +16,7 @@ exclude = [
travis-ci = { repository = "warner/spake2.rs" }
[dependencies]
-curve25519-dalek = "0.13"
+curve25519-dalek = "0.14"
rand = "0.3"
sha2 = "0.7"
hkdf = "0.3"
diff --git a/src/spake2.rs b/src/spake2.rs
index c746232..e92f1c1 100644
--- a/src/spake2.rs
+++ b/src/spake2.rs
@@ -129,9 +129,9 @@ impl Group for Ed25519Group {
fn decimal_to_scalar(d: &[u8]) -> c2_Scalar {
let bytes = BigUint::parse_bytes(d, 10).unwrap().to_bytes_le();
assert_eq!(bytes.len(), 32);
- let mut s = c2_Scalar([0u8; 32]);
- s.0.copy_from_slice(&bytes);
- s
+ let mut b2 = [0u8; 32];
+ b2.copy_from_slice(&bytes);
+ c2_Scalar::from_bytes_mod_order(b2)
}
fn ed25519_hash_to_scalar(s: &[u8]) -> c2_Scalar {
@@ -149,7 +149,7 @@ fn ed25519_hash_to_scalar(s: &[u8]) -> c2_Scalar {
reducible[32+16-1-i] = *x;
}
//println!("reducible: {}", reducible.iter().to_hex());
- c2_Scalar::reduce(&reducible)
+ c2_Scalar::from_bytes_mod_order_wide(&reducible)
//let reduced = c2_Scalar::reduce(&reducible);
//println!("reduced: {}", reduced.as_bytes().to_hex());
//println!("done");
@@ -413,7 +413,6 @@ mod test {
deterministic RNG (used only for tests, of course) into the per-Group
"random_scalar()" function, which results in some particular scalar.
*/
- use curve25519_dalek::scalar::Scalar;
use curve25519_dalek::constants::ED25519_BASEPOINT_POINT;
use spake2::{SPAKE2, Ed25519Group};
use hex;
@@ -427,12 +426,13 @@ mod test {
fn test_convert() {
let t1_decimal = b"2238329342913194256032495932344128051776374960164957527413114840482143558222";
let t1_scalar = decimal_to_scalar(t1_decimal);
- let expected: Scalar = Scalar(
+ let t1_bytes = t1_scalar.to_bytes();
+ let expected =
[0x4e, 0x5a, 0xb4, 0x34, 0x5d, 0x47, 0x08, 0x84,
0x59, 0x13, 0xb4, 0x64, 0x1b, 0xc2, 0x7d, 0x52,
0x52, 0xa5, 0x85, 0x10, 0x1b, 0xcc, 0x42, 0x44,
- 0xd4, 0x49, 0xf4, 0xa8, 0x79, 0xd9, 0xf2, 0x04]);
- assert_eq!(t1_scalar, expected);
+ 0xd4, 0x49, 0xf4, 0xa8, 0x79, 0xd9, 0xf2, 0x04];
+ assert_eq!(t1_bytes, expected);
//println!("t1_scalar is {:?}", t1_scalar);
}