Implement RFC 11: Redesigning Wasmtime's APIs (#2897)
Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more information it's best to read the RFC thread and the PR thread.
This commit is contained in:
@@ -4,26 +4,27 @@ impl super::wasi_ephemeral_crypto_kx::WasiEphemeralCryptoKx for WasiCryptoCtx {
|
||||
// --- key exchange
|
||||
|
||||
fn kx_dh(
|
||||
&self,
|
||||
&mut self,
|
||||
pk_handle: guest_types::Publickey,
|
||||
sk_handle: guest_types::Secretkey,
|
||||
) -> Result<guest_types::ArrayOutput, guest_types::CryptoErrno> {
|
||||
Ok(self.kx_dh(pk_handle.into(), sk_handle.into())?.into())
|
||||
Ok((&*self).kx_dh(pk_handle.into(), sk_handle.into())?.into())
|
||||
}
|
||||
|
||||
// --- Key encapsulation
|
||||
|
||||
fn kx_encapsulate(
|
||||
&self,
|
||||
&mut self,
|
||||
pk_handle: guest_types::Publickey,
|
||||
) -> Result<(guest_types::ArrayOutput, guest_types::ArrayOutput), guest_types::CryptoErrno>
|
||||
{
|
||||
let (secret_handle, encapsulated_secret_handle) = self.kx_encapsulate(pk_handle.into())?;
|
||||
let (secret_handle, encapsulated_secret_handle) =
|
||||
(&*self).kx_encapsulate(pk_handle.into())?;
|
||||
Ok((secret_handle.into(), encapsulated_secret_handle.into()))
|
||||
}
|
||||
|
||||
fn kx_decapsulate(
|
||||
&self,
|
||||
&mut self,
|
||||
sk_handle: guest_types::Secretkey,
|
||||
encapsulated_secret_ptr: &wiggle::GuestPtr<'_, u8>,
|
||||
encapsulated_secret_len: guest_types::Size,
|
||||
@@ -31,7 +32,7 @@ impl super::wasi_ephemeral_crypto_kx::WasiEphemeralCryptoKx for WasiCryptoCtx {
|
||||
let encapsulated_secret = &*encapsulated_secret_ptr
|
||||
.as_array(encapsulated_secret_len)
|
||||
.as_slice()?;
|
||||
Ok(self
|
||||
Ok((&*self)
|
||||
.kx_decapsulate(sk_handle.into(), encapsulated_secret)?
|
||||
.into())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user