|
|
@ -114,8 +114,7 @@ impl ESockSessionKey
|
|
|
|
.wrap_err(eyre!("Failed to encrypt session key with RSA public key"))
|
|
|
|
.wrap_err(eyre!("Failed to encrypt session key with RSA public key"))
|
|
|
|
.with_section(|| self.clone().header("Session key was"))
|
|
|
|
.with_section(|| self.clone().header("Session key was"))
|
|
|
|
.with_section({let temp = temp.len(); move || temp.header("Encoded data size was")})
|
|
|
|
.with_section({let temp = temp.len(); move || temp.header("Encoded data size was")})
|
|
|
|
.with_section(move || base64::encode(temp).header("Encoded data (base64) was"))
|
|
|
|
.with_section(move || base64::encode(temp).header("Encoded data (base64) was"))?;
|
|
|
|
?;
|
|
|
|
|
|
|
|
debug_assert_eq!(_wr, output.len());
|
|
|
|
debug_assert_eq!(_wr, output.len());
|
|
|
|
|
|
|
|
|
|
|
|
Ok(output)
|
|
|
|
Ok(output)
|
|
|
@ -126,8 +125,14 @@ impl ESockSessionKey
|
|
|
|
where <K as rsa::PublicKey>::KeyType: rsa::openssl::pkey::HasPrivate //ugh, why do we have to have this bound??? it should be implied ffs... :/
|
|
|
|
where <K as rsa::PublicKey>::KeyType: rsa::openssl::pkey::HasPrivate //ugh, why do we have to have this bound??? it should be implied ffs... :/
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let mut temp = SmallVec::<[u8; RSA_CIPHERTEXT_SIZE]>::new();
|
|
|
|
let mut temp = SmallVec::<[u8; RSA_CIPHERTEXT_SIZE]>::new();
|
|
|
|
rsa::decrypt_slice_sync(data, rsa_key, &mut temp)?;
|
|
|
|
rsa::decrypt_slice_sync(data, rsa_key, &mut temp)
|
|
|
|
Ok(serde_cbor::from_slice(&temp[..])?)
|
|
|
|
.wrap_err(eyre!("Failed to decrypt ciphertext to session key"))
|
|
|
|
|
|
|
|
.with_section({let data = data.len(); move || data.header("Ciphertext length was")})
|
|
|
|
|
|
|
|
.with_section(|| base64::encode(data).header("Ciphertext was"))?;
|
|
|
|
|
|
|
|
Ok(serde_cbor::from_slice(&temp[..])
|
|
|
|
|
|
|
|
.wrap_err(eyre!("Failed to decode CBOR data to session key object"))
|
|
|
|
|
|
|
|
.with_section({let temp = temp.len(); move || temp.header("Encoded data size was")})
|
|
|
|
|
|
|
|
.with_section(move || base64::encode(temp).header("Encoded data (base64) was"))?)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|