Skip to content

Commit 2718d22

Browse files
authored
Merge pull request #1152 from yubiuser/update/rsa
Update rsa
2 parents 7f6c126 + 453ef48 commit 2718d22

File tree

3 files changed

+33
-41
lines changed

3 files changed

+33
-41
lines changed

Cargo.lock

Lines changed: 28 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ priority-queue = "1.2"
4343
protobuf = "3"
4444
quick-xml = { version = "0.23", features = ["serialize"] }
4545
rand = "0.8"
46-
rsa = "0.6"
46+
rsa = "0.8.2"
4747
serde = { version = "1.0", features = ["derive"] }
4848
serde_json = "1.0"
49-
sha1 = "0.10"
49+
sha1 = { version = "0.10", features = ["oid"] }
5050
shannon = "0.2"
5151
sysinfo = { version = "0.28", default-features = false }
5252
thiserror = "1.0"

core/src/connection/handshake.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
44
use hmac::{Hmac, Mac};
55
use protobuf::{self, Message};
66
use rand::{thread_rng, RngCore};
7-
use rsa::{BigUint, PublicKey};
7+
use rsa::{BigUint, Pkcs1v15Sign, PublicKey};
88
use sha1::{Digest, Sha1};
99
use thiserror::Error;
1010
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
@@ -83,11 +83,9 @@ pub async fn handshake<T: AsyncRead + AsyncWrite + Unpin>(
8383
})?;
8484

8585
let hash = Sha1::digest(&remote_key);
86-
let padding = PaddingScheme(rsa::padding::PaddingScheme::new_pkcs1v15_sign(Some(
87-
rsa::hash::Hash::SHA1,
88-
)));
86+
let padding = Pkcs1v15Sign::new::<Sha1>();
8987
public_key
90-
.verify(padding.0, &hash, &remote_signature)
88+
.verify(padding, &hash, &remote_signature)
9189
.map_err(|_| {
9290
io::Error::new(
9391
io::ErrorKind::InvalidData,
@@ -105,13 +103,6 @@ pub async fn handshake<T: AsyncRead + AsyncWrite + Unpin>(
105103
Ok(codec.framed(connection))
106104
}
107105

108-
// Workaround for https://github.com/RustCrypto/RSA/issues/214
109-
struct PaddingScheme(rsa::padding::PaddingScheme);
110-
111-
/// # Safety
112-
/// The `rsa::padding::PaddingScheme` variant we use is actually `Send`.
113-
unsafe impl Send for PaddingScheme {}
114-
115106
async fn client_hello<T>(connection: &mut T, gc: Vec<u8>) -> io::Result<Vec<u8>>
116107
where
117108
T: AsyncWrite + Unpin,

0 commit comments

Comments
 (0)