wasi-crypto: forgot to erase ctx indirection

This commit is contained in:
Pat Hickey
2021-01-29 19:52:26 -08:00
parent 6ed8638559
commit b5f3a4a6db
6 changed files with 36 additions and 102 deletions

View File

@@ -10,14 +10,14 @@ impl super::wasi_ephemeral_crypto_common::WasiEphemeralCryptoCommon for WasiCryp
&self,
options_type: guest_types::AlgorithmType,
) -> Result<guest_types::Options, guest_types::CryptoErrno> {
Ok(self.ctx.options_open(options_type.into())?.into())
Ok(self.options_open(options_type.into())?.into())
}
fn options_close(
&self,
options_handle: guest_types::Options,
) -> Result<(), guest_types::CryptoErrno> {
Ok(self.ctx.options_close(options_handle.into())?)
Ok(self.options_close(options_handle.into())?)
}
fn options_set(
@@ -29,9 +29,7 @@ impl super::wasi_ephemeral_crypto_common::WasiEphemeralCryptoCommon for WasiCryp
) -> Result<(), guest_types::CryptoErrno> {
let name_str: &str = &*name_str.as_str()?;
let value: &[u8] = { &*value_ptr.as_array(value_len).as_slice()? };
Ok(self
.ctx
.options_set(options_handle.into(), name_str, value)?)
Ok(self.options_set(options_handle.into(), name_str, value)?)
}
fn options_set_guest_buffer(
@@ -44,9 +42,7 @@ impl super::wasi_ephemeral_crypto_common::WasiEphemeralCryptoCommon for WasiCryp
let name_str: &str = &*name_str.as_str()?;
let buffer: &'static mut [u8] =
unsafe { std::mem::transmute(&mut *buffer_ptr.as_array(buffer_len).as_slice_mut()?) };
Ok(self
.ctx
.options_set_guest_buffer(options_handle.into(), name_str, buffer)?)
Ok(self.options_set_guest_buffer(options_handle.into(), name_str, buffer)?)
}
fn options_set_u64(
@@ -56,9 +52,7 @@ impl super::wasi_ephemeral_crypto_common::WasiEphemeralCryptoCommon for WasiCryp
value: u64,
) -> Result<(), guest_types::CryptoErrno> {
let name_str: &str = &*name_str.as_str()?;
Ok(self
.ctx
.options_set_u64(options_handle.into(), name_str, value)?)
Ok(self.options_set_u64(options_handle.into(), name_str, value)?)
}
// --- array
@@ -68,7 +62,6 @@ impl super::wasi_ephemeral_crypto_common::WasiEphemeralCryptoCommon for WasiCryp
array_output_handle: guest_types::ArrayOutput,
) -> Result<guest_types::Size, guest_types::CryptoErrno> {
Ok(self
.ctx
.array_output_len(array_output_handle.into())?
.try_into()?)
}
@@ -81,7 +74,6 @@ impl super::wasi_ephemeral_crypto_common::WasiEphemeralCryptoCommon for WasiCryp
) -> Result<guest_types::Size, guest_types::CryptoErrno> {
let buf: &mut [u8] = { &mut *buf_ptr.as_array(buf_len).as_slice_mut()? };
Ok(self
.ctx
.array_output_pull(array_output_handle.into(), buf)?
.try_into()?)
}
@@ -97,7 +89,6 @@ impl super::wasi_ephemeral_crypto_common::WasiEphemeralCryptoCommon for WasiCryp
guest_types::OptOptions::None => None,
};
Ok(self
.ctx
.secrets_manager_open(options_handle.map(Into::into))?
.into())
}
@@ -106,9 +97,7 @@ impl super::wasi_ephemeral_crypto_common::WasiEphemeralCryptoCommon for WasiCryp
&self,
secrets_manager_handle: guest_types::SecretsManager,
) -> Result<(), guest_types::CryptoErrno> {
Ok(self
.ctx
.secrets_manager_close(secrets_manager_handle.into())?)
Ok(self.secrets_manager_close(secrets_manager_handle.into())?)
}
fn secrets_manager_invalidate(
@@ -119,7 +108,7 @@ impl super::wasi_ephemeral_crypto_common::WasiEphemeralCryptoCommon for WasiCryp
key_version: guest_types::Version,
) -> Result<(), guest_types::CryptoErrno> {
let key_id: &[u8] = { &*key_id_ptr.as_array(key_id_len).as_slice()? };
Ok(self.ctx.secrets_manager_invalidate(
Ok(self.secrets_manager_invalidate(
secrets_manager_handle.into(),
key_id,
key_version.into(),