mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
core: workaround for Session::connect() future being !Send
rsa::padding::PaddingScheme is !Send, making it impossible to call Session::connect() with an executor requiring Send futures, such as Rocket. Fix #1065
This commit is contained in:
parent
29ec49b74c
commit
1a48bc87c8
1 changed files with 11 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue