Merge pull request #1066 from gdesmott/send-workaround

core: workaround for Session::connect() future being !Send
This commit is contained in:
Roderick van Domburg 2022-10-26 22:20:33 +02:00 committed by GitHub
commit b1e1e61a94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,9 +77,11 @@ pub async fn handshake<T: AsyncRead + AsyncWrite + Unpin>(
})?;
let hash = Sha1::digest(&remote_key);
let padding = rsa::padding::PaddingScheme::new_pkcs1v15_sign(Some(rsa::hash::Hash::SHA1));
let padding = PaddingScheme(rsa::padding::PaddingScheme::new_pkcs1v15_sign(Some(
rsa::hash::Hash::SHA1,
)));
public_key
.verify(padding, &hash, &remote_signature)
.verify(padding.0, &hash, &remote_signature)
.map_err(|_| {
io::Error::new(
io::ErrorKind::InvalidData,
@ -97,6 +99,13 @@ pub async fn handshake<T: AsyncRead + AsyncWrite + Unpin>(
Ok(codec.framed(connection))
}
// Workaround for https://github.com/RustCrypto/RSA/issues/214
struct PaddingScheme(rsa::padding::PaddingScheme);
/// # Safety
/// The `rsa::padding::PaddingScheme` variant we use is actually `Send`.
unsafe impl Send for PaddingScheme {}
async fn client_hello<T>(connection: &mut T, gc: Vec<u8>) -> io::Result<Vec<u8>>
where
T: AsyncWrite + Unpin,