diff --git a/Cargo.toml b/Cargo.toml index d2103ea..0e62863 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ ctr = "0.9.1" aes = "0.8.1" log = "0.4.14" rand_core = "0.6.3" -x25519-dalek = { version = "2.0.0-pre.1", optional = true } -curve25519-dalek = { version = "4.0.0-pre.2", optional = true } +x25519-dalek = { version = "2.0.1", features = ["static_secrets"], optional = true } +curve25519-dalek = { version = "4.1.2", optional = true } tokio = { version = "1.36", features = ["net", "io-util"] } tokio-util = { version = "0.7.10", features = ["codec"] } thiserror = "1" diff --git a/src/integrations/dalek.rs b/src/integrations/dalek.rs index 8dc22a6..73a5ee6 100644 --- a/src/integrations/dalek.rs +++ b/src/integrations/dalek.rs @@ -19,6 +19,7 @@ impl AdnlPublicKey for PublicKey { fn edwards_to_montgomery(public_key: &P) -> PublicKey { PublicKey::from( CompressedEdwardsY::from_slice(&public_key.edwards_repr()) + .unwrap() .decompress() .unwrap() .to_montgomery() diff --git a/src/tests.rs b/src/tests.rs index 5d11af5..72f3c14 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,7 +1,5 @@ extern crate alloc; -use std::error::Error; - use super::*; use alloc::vec::Vec; use futures::{SinkExt, StreamExt}; @@ -176,7 +174,7 @@ fn test_public_key_consistency() { #[tokio::test] async fn integrity_test() { - let server_private = StaticSecret::new(rand::thread_rng()); + let server_private = StaticSecret::random_from_rng(rand::thread_rng()); let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let port = listener.local_addr().unwrap().port(); let server_public = server_private.public(); @@ -201,4 +199,6 @@ async fn integrity_test() { // receive result let result = client.next().await.expect("packet must be received").expect("packet must be decoded properly"); + + assert_eq!(result, "hello".as_bytes()); } \ No newline at end of file diff --git a/src/wrappers/peer.rs b/src/wrappers/peer.rs index 3668361..806f5b2 100644 --- a/src/wrappers/peer.rs +++ b/src/wrappers/peer.rs @@ -3,10 +3,10 @@ use std::task::{Context, Poll}; use crate::{AdnlBuilder, AdnlError, AdnlHandshake, AdnlPrivateKey, AdnlPublicKey}; use pin_project::pin_project; -use tokio::io::{empty, AsyncRead, AsyncWrite, AsyncReadExt, AsyncWriteExt}; +use tokio::io::{AsyncRead, AsyncWrite, AsyncReadExt, AsyncWriteExt}; use tokio::net::{TcpStream, ToSocketAddrs}; use tokio_util::bytes::Bytes; -use tokio_util::codec::{Decoder, Encoder, Framed}; +use tokio_util::codec::{Decoder, Framed}; use x25519_dalek::StaticSecret; use futures::{Sink, SinkExt, Stream, StreamExt}; @@ -27,7 +27,7 @@ impl AdnlPeer { ls_addr: A, ) -> Result, AdnlError> { // generate private key - let local_secret = StaticSecret::new(rand::rngs::OsRng); + let local_secret = StaticSecret::random_from_rng(rand::rngs::OsRng); // use TcpStream as transport for our ADNL connection let transport = TcpStream::connect(ls_addr).await?;