From 12b454a9a1a13d6f83de6fcfc2c092dec96e8866 Mon Sep 17 00:00:00 2001 From: Paul Grandperrin Date: Wed, 3 Feb 2021 21:44:23 +0100 Subject: [PATCH] Use curve25519_dalek_ng instead of curve25519_dalek See https://github.com/dalek-cryptography/curve25519-dalek/pull/338#issuecomment-772059572 --- Cargo.lock | 22 ++++++++++++---------- Cargo.toml | 8 +++----- benches/oprf.rs | 2 +- examples/digital_locker.rs | 6 +++--- examples/simple_login.rs | 6 +++--- src/group.rs | 2 +- src/keypair.rs | 2 +- src/lib.rs | 30 +++++++++++++++--------------- src/map_to_curve.rs | 2 +- src/opaque.rs | 16 ++++++++-------- src/oprf.rs | 2 +- src/serialization/tests.rs | 2 +- src/tests/full_test.rs | 2 +- src/tests/opaque_test_vectors.rs | 2 +- src/tests/voprf_test_vectors.rs | 2 +- 15 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 98d3d270..e7068ca8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -289,14 +289,15 @@ dependencies = [ ] [[package]] -name = "curve25519-dalek" -version = "3.0.2" -source = "git+https://github.com/PaulGrandperrin/curve25519-dalek.git?branch=patch-1#d0dacb2699fbf166ca7ae5c68518cb5f44e633e7" +name = "curve25519-dalek-ng" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "574d8b2cd0bae5434fd50d53280f8299d95557a978686555880aaf5b8f4f81e9" dependencies = [ "byteorder", "digest", "rand_core 0.6.1", - "subtle", + "subtle-ng", "zeroize", ] @@ -576,7 +577,7 @@ dependencies = [ "base64", "chacha20poly1305", "criterion", - "curve25519-dalek", + "curve25519-dalek-ng", "digest", "displaydoc", "generic-array", @@ -1019,6 +1020,12 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" +[[package]] +name = "subtle-ng" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8049cf85f0e715d6af38dde439cb0ccb91f67fb9f5f63c80f8b43e48356e1a3f" + [[package]] name = "syn" version = "1.0.60" @@ -1261,8 +1268,3 @@ name = "zeroize" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" - -[[patch.unused]] -name = "x25519-dalek" -version = "1.1.0" -source = "git+https://github.com/PaulGrandperrin/x25519-dalek.git?branch=patch-1#050034c98c84bfc6ed185147f3e769d0c38c702b" diff --git a/Cargo.toml b/Cargo.toml index 747b0e2d..46de99ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,11 +13,11 @@ readme = "README.md" default = ["u64_backend"] slow-hash = ["scrypt"] bench = [] -u64_backend = ["curve25519-dalek/u64_backend"] -u32_backend = ["curve25519-dalek/u32_backend"] +u64_backend = ["curve25519-dalek-ng/u64_backend"] +u32_backend = ["curve25519-dalek-ng/u32_backend"] [dependencies] -curve25519-dalek = { version = "3.0.0", default-features = false, features = ["std"] } +curve25519-dalek-ng = { version = "4", default-features = false, features = ["std"] } digest = "0.9.0" displaydoc = "0.1.7" generic-array = "0.14.4" @@ -51,6 +51,4 @@ required-features = ["bench"] # TEMPORARY, DO NOT MERGE [patch.crates-io] -x25519-dalek = { git = "https://github.com/PaulGrandperrin/x25519-dalek.git", branch="patch-1" } -curve25519-dalek = { git = "https://github.com/PaulGrandperrin/curve25519-dalek.git", branch="patch-1" } proptest = { git = "https://github.com/PaulGrandperrin/proptest.git", branch="master" } diff --git a/benches/oprf.rs b/benches/oprf.rs index 56e86426..0ceb47ba 100644 --- a/benches/oprf.rs +++ b/benches/oprf.rs @@ -7,7 +7,7 @@ extern crate criterion; use criterion::Criterion; -use curve25519_dalek::ristretto::RistrettoPoint; +use curve25519_dalek_ng::ristretto::RistrettoPoint; use generic_array::arr; use opaque_ke::{ group::Group, diff --git a/examples/digital_locker.rs b/examples/digital_locker.rs index 36f7036d..0b556e91 100644 --- a/examples/digital_locker.rs +++ b/examples/digital_locker.rs @@ -44,7 +44,7 @@ use opaque_ke::{ #[allow(dead_code)] struct Default; impl CipherSuite for Default { - type Group = curve25519_dalek::ristretto::RistrettoPoint; + type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; type Hash = sha2::Sha512; type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -81,7 +81,7 @@ fn decrypt(key: &[u8], ciphertext: &[u8]) -> Vec { // Password-based registration and encryption of client secret message between a client and server fn register_locker( - server_kp: &opaque_ke::keypair::KeyPair, + server_kp: &opaque_ke::keypair::KeyPair, password: String, secret_message: String, ) -> Locker { @@ -134,7 +134,7 @@ fn register_locker( // Open the contents of a locker with a password between a client and server fn open_locker( - server_kp: &opaque_ke::keypair::KeyPair, + server_kp: &opaque_ke::keypair::KeyPair, password: String, locker: &Locker, ) -> Result { diff --git a/examples/simple_login.rs b/examples/simple_login.rs index bf258d3c..ec1e8960 100644 --- a/examples/simple_login.rs +++ b/examples/simple_login.rs @@ -39,7 +39,7 @@ use opaque_ke::{ #[allow(dead_code)] struct Default; impl CipherSuite for Default { - type Group = curve25519_dalek::ristretto::RistrettoPoint; + type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; type Hash = sha2::Sha512; type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -47,7 +47,7 @@ impl CipherSuite for Default { // Password-based registration between a client and server fn account_registration( - server_kp: &opaque_ke::keypair::KeyPair, + server_kp: &opaque_ke::keypair::KeyPair, password: String, ) -> Vec { let mut client_rng = OsRng; @@ -89,7 +89,7 @@ fn account_registration( // Password-based login between a client and server fn account_login( - server_kp: &opaque_ke::keypair::KeyPair, + server_kp: &opaque_ke::keypair::KeyPair, password: String, password_file_bytes: &[u8], ) -> bool { diff --git a/src/group.rs b/src/group.rs index 3a7af8f0..c3ff0853 100644 --- a/src/group.rs +++ b/src/group.rs @@ -8,7 +8,7 @@ use crate::errors::InternalPakeError; -use curve25519_dalek::{ +use curve25519_dalek_ng::{ constants::RISTRETTO_BASEPOINT_POINT, ristretto::{CompressedRistretto, RistrettoPoint}, scalar::Scalar, diff --git a/src/keypair.rs b/src/keypair.rs index 25b7b2a3..684f0d96 100644 --- a/src/keypair.rs +++ b/src/keypair.rs @@ -147,7 +147,7 @@ impl SizedBytes for Key { #[cfg(test)] mod tests { use super::*; - use curve25519_dalek::ristretto::RistrettoPoint; + use curve25519_dalek_ng::ristretto::RistrettoPoint; proptest! { #[test] diff --git a/src/lib.rs b/src/lib.rs index 9b7c8dbc..6fdbf846 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,7 @@ //! use opaque_ke::ciphersuite::CipherSuite; //! struct Default; //! impl CipherSuite for Default { -//! type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! type Hash = sha2::Sha512; //! type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -43,7 +43,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -75,7 +75,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -105,7 +105,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -142,7 +142,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -180,7 +180,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -221,7 +221,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -254,7 +254,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -303,7 +303,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -350,7 +350,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -426,7 +426,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -503,7 +503,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -568,7 +568,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -603,7 +603,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -651,7 +651,7 @@ //! # use opaque_ke::ciphersuite::CipherSuite; //! # struct Default; //! # impl CipherSuite for Default { -//! # type Group = curve25519_dalek::ristretto::RistrettoPoint; +//! # type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; //! # type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; //! # type Hash = sha2::Sha512; //! # type SlowHash = opaque_ke::slow_hash::NoOpHash; diff --git a/src/map_to_curve.rs b/src/map_to_curve.rs index f3c55642..ba1d9884 100644 --- a/src/map_to_curve.rs +++ b/src/map_to_curve.rs @@ -10,7 +10,7 @@ use crate::errors::InternalPakeError; use crate::group::Group; use crate::hash::Hash; use crate::serialization::i2osp; -use curve25519_dalek::ristretto::RistrettoPoint; +use curve25519_dalek_ng::ristretto::RistrettoPoint; use digest::{BlockInput, Digest}; use generic_array::typenum::Unsigned; use generic_array::GenericArray; diff --git a/src/opaque.rs b/src/opaque.rs index b21e4ea5..2d1e4a5b 100644 --- a/src/opaque.rs +++ b/src/opaque.rs @@ -116,7 +116,7 @@ impl ClientRegistration { /// use opaque_ke::ciphersuite::CipherSuite; /// struct Default; /// impl CipherSuite for Default { - /// type Group = curve25519_dalek::ristretto::RistrettoPoint; + /// type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; /// type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; /// type Hash = sha2::Sha512; /// type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -164,7 +164,7 @@ impl ClientRegistration { /// use opaque_ke::ciphersuite::CipherSuite; /// struct Default; /// impl CipherSuite for Default { - /// type Group = curve25519_dalek::ristretto::RistrettoPoint; + /// type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; /// type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; /// type Hash = sha2::Sha512; /// type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -322,7 +322,7 @@ impl ServerRegistration { /// use opaque_ke::ciphersuite::CipherSuite; /// struct Default; /// impl CipherSuite for Default { - /// type Group = curve25519_dalek::ristretto::RistrettoPoint; + /// type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; /// type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; /// type Hash = sha2::Sha512; /// type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -373,7 +373,7 @@ impl ServerRegistration { /// use opaque_ke::ciphersuite::CipherSuite; /// struct Default; /// impl CipherSuite for Default { - /// type Group = curve25519_dalek::ristretto::RistrettoPoint; + /// type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; /// type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; /// type Hash = sha2::Sha512; /// type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -522,7 +522,7 @@ impl ClientLogin { /// use opaque_ke::ciphersuite::CipherSuite; /// struct Default; /// impl CipherSuite for Default { - /// type Group = curve25519_dalek::ristretto::RistrettoPoint; + /// type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; /// type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; /// type Hash = sha2::Sha512; /// type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -572,7 +572,7 @@ impl ClientLogin { /// use opaque_ke::ciphersuite::CipherSuite; /// struct Default; /// impl CipherSuite for Default { - /// type Group = curve25519_dalek::ristretto::RistrettoPoint; + /// type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; /// type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; /// type Hash = sha2::Sha512; /// type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -727,7 +727,7 @@ impl ServerLogin { /// use opaque_ke::ciphersuite::CipherSuite; /// struct Default; /// impl CipherSuite for Default { - /// type Group = curve25519_dalek::ristretto::RistrettoPoint; + /// type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; /// type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; /// type Hash = sha2::Sha512; /// type SlowHash = opaque_ke::slow_hash::NoOpHash; @@ -832,7 +832,7 @@ impl ServerLogin { /// use opaque_ke::ciphersuite::CipherSuite; /// struct Default; /// impl CipherSuite for Default { - /// type Group = curve25519_dalek::ristretto::RistrettoPoint; + /// type Group = curve25519_dalek_ng::ristretto::RistrettoPoint; /// type KeyExchange = opaque_ke::key_exchange::tripledh::TripleDH; /// type Hash = sha2::Sha512; /// type SlowHash = opaque_ke::slow_hash::NoOpHash; diff --git a/src/oprf.rs b/src/oprf.rs index 70272779..a730209c 100644 --- a/src/oprf.rs +++ b/src/oprf.rs @@ -115,7 +115,7 @@ pub fn unblind_and_finalize_shim( mod tests { use super::*; use crate::group::Group; - use curve25519_dalek::ristretto::RistrettoPoint; + use curve25519_dalek_ng::ristretto::RistrettoPoint; use generic_array::{arr, GenericArray}; use rand_core::OsRng; use sha2::Sha512; diff --git a/src/serialization/tests.rs b/src/serialization/tests.rs index f0aa69fa..f8c755a4 100644 --- a/src/serialization/tests.rs +++ b/src/serialization/tests.rs @@ -16,7 +16,7 @@ use crate::{ *, }; -use curve25519_dalek::ristretto::RistrettoPoint; +use curve25519_dalek_ng::ristretto::RistrettoPoint; use generic_array::typenum::Unsigned; use generic_bytes::SizedBytes; use proptest::{collection::vec, prelude::*}; diff --git a/src/tests/full_test.rs b/src/tests/full_test.rs index 533ed97c..32537360 100644 --- a/src/tests/full_test.rs +++ b/src/tests/full_test.rs @@ -14,7 +14,7 @@ use crate::{ tests::mock_rng::CycleRng, *, }; -use curve25519_dalek::ristretto::RistrettoPoint; +use curve25519_dalek_ng::ristretto::RistrettoPoint; use generic_array::typenum::Unsigned; use generic_bytes::SizedBytes; use rand_core::{OsRng, RngCore}; diff --git a/src/tests/opaque_test_vectors.rs b/src/tests/opaque_test_vectors.rs index c5454f0f..27bd9c56 100644 --- a/src/tests/opaque_test_vectors.rs +++ b/src/tests/opaque_test_vectors.rs @@ -7,7 +7,7 @@ use crate::{ ciphersuite::CipherSuite, errors::*, key_exchange::tripledh::TripleDH, keypair::Key, opaque::*, slow_hash::NoOpHash, tests::mock_rng::CycleRng, *, }; -use curve25519_dalek::ristretto::RistrettoPoint; +use curve25519_dalek_ng::ristretto::RistrettoPoint; use rand_core::OsRng; use serde_json::Value; use std::convert::TryFrom; diff --git a/src/tests/voprf_test_vectors.rs b/src/tests/voprf_test_vectors.rs index 56f634b6..069d5d56 100644 --- a/src/tests/voprf_test_vectors.rs +++ b/src/tests/voprf_test_vectors.rs @@ -5,7 +5,7 @@ use crate::tests::mock_rng::CycleRng; use crate::{errors::*, group::Group, oprf}; -use curve25519_dalek::ristretto::RistrettoPoint; +use curve25519_dalek_ng::ristretto::RistrettoPoint; use generic_array::GenericArray; use serde_json::Value; use sha2::Sha512;