Project import generated by Copybara.

GitOrigin-RevId: b6ca065e6fc9504c3ff07067ef2da184afaf0c78
Change-Id: Ie3b3a5835bf622e679fd21e0a9149dd85da59aca
diff --git a/nearby/crypto/crypto_provider_rustcrypto/Cargo.toml b/nearby/crypto/crypto_provider_rustcrypto/Cargo.toml
index ad5a4b8..2ab5354 100644
--- a/nearby/crypto/crypto_provider_rustcrypto/Cargo.toml
+++ b/nearby/crypto/crypto_provider_rustcrypto/Cargo.toml
@@ -14,9 +14,8 @@
 x25519-dalek.workspace = true
 p256 = { workspace = true, features = ["ecdh"], default-features = false }
 sec1.workspace = true
-ed25519-dalek = { workspace = true, default-features = false }
+ed25519-dalek = { workspace = true, default-features = false, features = ["rand_core"] }
 rand = { workspace = true, default-features = false }
-rand_core_05_adapter.workspace = true
 rand_core.workspace = true
 subtle.workspace = true
 aes.workspace = true
diff --git a/nearby/crypto/crypto_provider_rustcrypto/src/ed25519.rs b/nearby/crypto/crypto_provider_rustcrypto/src/ed25519.rs
index 874aa82..df5c5de 100644
--- a/nearby/crypto/crypto_provider_rustcrypto/src/ed25519.rs
+++ b/nearby/crypto/crypto_provider_rustcrypto/src/ed25519.rs
@@ -12,30 +12,33 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+use ed25519_dalek::Signer;
+
 use crypto_provider::ed25519::{
     InvalidBytes, InvalidSignature, Signature as _, SignatureError, KEY_LENGTH, KEY_PAIR_LENGTH,
     SIGNATURE_LENGTH,
 };
-use ed25519_dalek::Signer;
 
 pub struct Ed25519;
+
 impl crypto_provider::ed25519::Ed25519Provider for Ed25519 {
     type KeyPair = KeyPair;
     type PublicKey = PublicKey;
     type Signature = Signature;
 }
 
-pub struct KeyPair(ed25519_dalek::Keypair);
+pub struct KeyPair(ed25519_dalek::SigningKey);
+
 impl crypto_provider::ed25519::KeyPair for KeyPair {
     type PublicKey = PublicKey;
     type Signature = Signature;
 
     fn to_bytes(&self) -> [u8; KEY_PAIR_LENGTH] {
-        self.0.to_bytes()
+        self.0.to_keypair_bytes()
     }
 
     fn from_bytes(bytes: [u8; KEY_PAIR_LENGTH]) -> Result<Self, InvalidBytes> {
-        ed25519_dalek::Keypair::from_bytes(&bytes)
+        ed25519_dalek::SigningKey::from_keypair_bytes(&bytes)
             .map(Self)
             .map_err(|_| InvalidBytes)
     }
@@ -51,23 +54,22 @@
     #[cfg(feature = "std")]
     fn generate() -> Self {
         let mut csprng = rand::rngs::ThreadRng::default();
-        Self(ed25519_dalek::Keypair::generate(
-            &mut rand_core_05_adapter::RandWrapper::from(&mut csprng),
-        ))
+        Self(ed25519_dalek::SigningKey::generate(&mut csprng))
     }
 
     fn public(&self) -> Self::PublicKey {
-        PublicKey(self.0.public)
+        PublicKey(self.0.verifying_key())
     }
 }
 
 pub struct Signature(ed25519_dalek::Signature);
+
 impl crypto_provider::ed25519::Signature for Signature {
     fn from_bytes(bytes: &[u8]) -> Result<Self, InvalidSignature> {
         if bytes.len() != SIGNATURE_LENGTH {
             return Err(InvalidSignature);
         }
-        ed25519_dalek::Signature::from_bytes(bytes)
+        ed25519_dalek::Signature::from_slice(bytes)
             .map(Self)
             .map_err(|_| InvalidSignature)
     }
@@ -77,7 +79,8 @@
     }
 }
 
-pub struct PublicKey(ed25519_dalek::PublicKey);
+pub struct PublicKey(ed25519_dalek::VerifyingKey);
+
 impl crypto_provider::ed25519::PublicKey for PublicKey {
     type Signature = Signature;
 
@@ -85,7 +88,7 @@
     where
         Self: Sized,
     {
-        ed25519_dalek::PublicKey::from_bytes(&bytes)
+        ed25519_dalek::VerifyingKey::from_bytes(&bytes)
             .map(PublicKey)
             .map_err(|_| InvalidBytes)
     }
@@ -107,9 +110,10 @@
 
 #[cfg(test)]
 mod tests {
-    use crate::ed25519::Ed25519;
     use crypto_provider::ed25519::testing::{run_rfc_test_vectors, run_wycheproof_test_vectors};
 
+    use crate::ed25519::Ed25519;
+
     #[test]
     fn wycheproof_test_ed25519_rustcrypto() {
         run_wycheproof_test_vectors::<Ed25519>()
diff --git a/nearby/crypto/crypto_provider_rustcrypto/src/hkdf_rc.rs b/nearby/crypto/crypto_provider_rustcrypto/src/hkdf_rc.rs
index d6ca687..8ff5d7b 100644
--- a/nearby/crypto/crypto_provider_rustcrypto/src/hkdf_rc.rs
+++ b/nearby/crypto/crypto_provider_rustcrypto/src/hkdf_rc.rs
@@ -22,7 +22,6 @@
 use hmac::digest::{HashMarker, OutputSizeUser};
 
 /// RustCrypto based hkdf implementation
-#[derive(Clone)]
 pub struct Hkdf<D>
 where
     D: OutputSizeUser,
@@ -72,3 +71,15 @@
         self.hkdf_impl.expand(info, okm).map_err(|_| InvalidLength)
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use crate::RustCrypto;
+    use core::marker::PhantomData;
+    use crypto_provider::hkdf::testing::*;
+
+    #[apply(hkdf_test_cases)]
+    fn hkdf_tests(testcase: CryptoProviderTestCase<RustCrypto>) {
+        testcase(PhantomData);
+    }
+}
diff --git a/nearby/crypto/crypto_provider_rustcrypto/src/hmac_rc.rs b/nearby/crypto/crypto_provider_rustcrypto/src/hmac_rc.rs
index e31b815..95254a5 100644
--- a/nearby/crypto/crypto_provider_rustcrypto/src/hmac_rc.rs
+++ b/nearby/crypto/crypto_provider_rustcrypto/src/hmac_rc.rs
@@ -112,3 +112,15 @@
             .map_err(|_| MacError)
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use crate::RustCrypto;
+    use core::marker::PhantomData;
+    use crypto_provider::hmac::testing::*;
+
+    #[apply(hmac_test_cases)]
+    fn hmac_tests(testcase: CryptoProviderTestCase<RustCrypto>) {
+        testcase(PhantomData);
+    }
+}
diff --git a/nearby/crypto/crypto_provider_rustcrypto/src/lib.rs b/nearby/crypto/crypto_provider_rustcrypto/src/lib.rs
index 9807f81..9145233 100644
--- a/nearby/crypto/crypto_provider_rustcrypto/src/lib.rs
+++ b/nearby/crypto/crypto_provider_rustcrypto/src/lib.rs
@@ -65,7 +65,7 @@
 }
 
 impl<R: CryptoRng + SeedableRng + RngCore> RustCryptoImpl<R> {
-    ///
+    /// Create a new instance of RustCrypto
     pub fn new() -> Self {
         Self {
             _marker: Default::default(),
diff --git a/nearby/crypto/crypto_provider_rustcrypto/src/x25519.rs b/nearby/crypto/crypto_provider_rustcrypto/src/x25519.rs
index a184d44..794d780 100644
--- a/nearby/crypto/crypto_provider_rustcrypto/src/x25519.rs
+++ b/nearby/crypto/crypto_provider_rustcrypto/src/x25519.rs
@@ -48,7 +48,7 @@
 
     fn generate_random(rng: &mut Self::Rng) -> Self {
         Self {
-            secret: x25519_dalek::EphemeralSecret::new(&mut rng.0),
+            secret: x25519_dalek::EphemeralSecret::random_from_rng(&mut rng.0),
             marker: Default::default(),
         }
     }
@@ -76,9 +76,11 @@
         _public_key: &X25519PublicKey,
     ) -> Result<Self, Self::Error> {
         Ok(Self {
-            secret: x25519_dalek::EphemeralSecret::new(&mut crate::testing::MockCryptoRng {
-                values: private_bytes.iter(),
-            }),
+            secret: x25519_dalek::EphemeralSecret::random_from_rng(
+                &mut crate::testing::MockCryptoRng {
+                    values: private_bytes.iter(),
+                },
+            ),
             marker: Default::default(),
         })
     }