pub struct SecureWasmAeadContext { /* private fields */ }Expand description
Secure WASM AEAD Context
This context provides secure AEAD operations with:
- Consistent error handling using Result<T, JsValue>
- Security validation for all inputs
- Protection against timing attacks
- Memory safety with automatic cleanup
Implementations§
Source§impl SecureWasmAeadContext
impl SecureWasmAeadContext
Sourcepub fn new() -> Result<SecureWasmAeadContext, JsValue>
pub fn new() -> Result<SecureWasmAeadContext, JsValue>
Create a new secure WASM AEAD context
Sourcepub fn encrypt(
&mut self,
algorithm: &str,
key: &Uint8Array,
nonce: &Uint8Array,
plaintext: &Uint8Array,
associated_data: Option<Uint8Array>,
) -> Result<JsValue, JsValue>
pub fn encrypt( &mut self, algorithm: &str, key: &Uint8Array, nonce: &Uint8Array, plaintext: &Uint8Array, associated_data: Option<Uint8Array>, ) -> Result<JsValue, JsValue>
Encrypt data
Sourcepub fn decrypt(
&self,
algorithm: &str,
key: &Uint8Array,
nonce: &Uint8Array,
ciphertext: &Uint8Array,
associated_data: Option<Uint8Array>,
) -> Result<JsValue, JsValue>
pub fn decrypt( &self, algorithm: &str, key: &Uint8Array, nonce: &Uint8Array, ciphertext: &Uint8Array, associated_data: Option<Uint8Array>, ) -> Result<JsValue, JsValue>
Decrypt data (Layer A Result ABI only; see crate::AeadDecryptSemantic for Layer B).
Sourcepub fn get_supported_algorithms(&self) -> Result<JsValue, JsValue>
pub fn get_supported_algorithms(&self) -> Result<JsValue, JsValue>
Get supported algorithms
Trait Implementations§
Source§impl From<SecureWasmAeadContext> for JsValue
impl From<SecureWasmAeadContext> for JsValue
Source§fn from(value: SecureWasmAeadContext) -> JsValue
fn from(value: SecureWasmAeadContext) -> JsValue
Converts to this type from the input type.
Source§impl FromWasmAbi for SecureWasmAeadContext
impl FromWasmAbi for SecureWasmAeadContext
Source§type Abi = WasmPtr<WasmRefCell<SecureWasmAeadContext>>
type Abi = WasmPtr<WasmRefCell<SecureWasmAeadContext>>
The Wasm ABI type that this converts from when coming back out from the
ABI boundary.
Source§unsafe fn from_abi(
js: <SecureWasmAeadContext as FromWasmAbi>::Abi,
) -> SecureWasmAeadContext
unsafe fn from_abi( js: <SecureWasmAeadContext as FromWasmAbi>::Abi, ) -> SecureWasmAeadContext
Source§impl IntoWasmAbi for SecureWasmAeadContext
impl IntoWasmAbi for SecureWasmAeadContext
Source§type Abi = WasmPtr<WasmRefCell<SecureWasmAeadContext>>
type Abi = WasmPtr<WasmRefCell<SecureWasmAeadContext>>
The Wasm ABI type that this converts into when crossing the ABI
boundary.
Source§fn into_abi(self) -> <SecureWasmAeadContext as IntoWasmAbi>::Abi
fn into_abi(self) -> <SecureWasmAeadContext as IntoWasmAbi>::Abi
Convert
self into Self::Abi so that it can be sent across the wasm
ABI boundary.Source§impl LongRefFromWasmAbi for SecureWasmAeadContext
impl LongRefFromWasmAbi for SecureWasmAeadContext
Source§type Abi = WasmPtr<WasmRefCell<SecureWasmAeadContext>>
type Abi = WasmPtr<WasmRefCell<SecureWasmAeadContext>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRef<SecureWasmAeadContext>
type Anchor = RcRef<SecureWasmAeadContext>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(
js: <SecureWasmAeadContext as LongRefFromWasmAbi>::Abi,
) -> <SecureWasmAeadContext as LongRefFromWasmAbi>::Anchor
unsafe fn long_ref_from_abi( js: <SecureWasmAeadContext as LongRefFromWasmAbi>::Abi, ) -> <SecureWasmAeadContext as LongRefFromWasmAbi>::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl OptionFromWasmAbi for SecureWasmAeadContext
impl OptionFromWasmAbi for SecureWasmAeadContext
Source§fn is_none(abi: &<SecureWasmAeadContext as FromWasmAbi>::Abi) -> bool
fn is_none(abi: &<SecureWasmAeadContext as FromWasmAbi>::Abi) -> bool
Tests whether the argument is a “none” instance. If so it will be
deserialized as
None, and otherwise it will be passed to
FromWasmAbi.Source§impl OptionIntoWasmAbi for SecureWasmAeadContext
impl OptionIntoWasmAbi for SecureWasmAeadContext
Source§fn none() -> <SecureWasmAeadContext as IntoWasmAbi>::Abi
fn none() -> <SecureWasmAeadContext as IntoWasmAbi>::Abi
Returns an ABI instance indicating “none”, which JS will interpret as
the
None branch of this option. Read moreSource§impl RefFromWasmAbi for SecureWasmAeadContext
impl RefFromWasmAbi for SecureWasmAeadContext
Source§type Abi = WasmPtr<WasmRefCell<SecureWasmAeadContext>>
type Abi = WasmPtr<WasmRefCell<SecureWasmAeadContext>>
The Wasm ABI type references to
Self are recovered from.Source§type Anchor = RcRef<SecureWasmAeadContext>
type Anchor = RcRef<SecureWasmAeadContext>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§unsafe fn ref_from_abi(
js: <SecureWasmAeadContext as RefFromWasmAbi>::Abi,
) -> <SecureWasmAeadContext as RefFromWasmAbi>::Anchor
unsafe fn ref_from_abi( js: <SecureWasmAeadContext as RefFromWasmAbi>::Abi, ) -> <SecureWasmAeadContext as RefFromWasmAbi>::Anchor
Source§impl RefMutFromWasmAbi for SecureWasmAeadContext
impl RefMutFromWasmAbi for SecureWasmAeadContext
Source§type Abi = WasmPtr<WasmRefCell<SecureWasmAeadContext>>
type Abi = WasmPtr<WasmRefCell<SecureWasmAeadContext>>
Same as
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<SecureWasmAeadContext>
type Anchor = RcRefMut<SecureWasmAeadContext>
Same as
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(
js: <SecureWasmAeadContext as RefMutFromWasmAbi>::Abi,
) -> <SecureWasmAeadContext as RefMutFromWasmAbi>::Anchor
unsafe fn ref_mut_from_abi( js: <SecureWasmAeadContext as RefMutFromWasmAbi>::Abi, ) -> <SecureWasmAeadContext as RefMutFromWasmAbi>::Anchor
Same as
RefFromWasmAbi::ref_from_abiSource§impl TryFromJsValue for SecureWasmAeadContext
impl TryFromJsValue for SecureWasmAeadContext
Source§fn try_from_js_value(value: JsValue) -> Result<SecureWasmAeadContext, JsValue>
fn try_from_js_value(value: JsValue) -> Result<SecureWasmAeadContext, JsValue>
Performs the conversion.
Source§fn try_from_js_value_ref(value: &JsValue) -> Option<SecureWasmAeadContext>
fn try_from_js_value_ref(value: &JsValue) -> Option<SecureWasmAeadContext>
Performs the conversion.
Source§impl VectorFromWasmAbi for SecureWasmAeadContext
impl VectorFromWasmAbi for SecureWasmAeadContext
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi( js: <SecureWasmAeadContext as VectorFromWasmAbi>::Abi, ) -> Box<[SecureWasmAeadContext]>
Source§impl VectorIntoWasmAbi for SecureWasmAeadContext
impl VectorIntoWasmAbi for SecureWasmAeadContext
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi( vector: Box<[SecureWasmAeadContext]>, ) -> <SecureWasmAeadContext as VectorIntoWasmAbi>::Abi
Auto Trait Implementations§
impl Freeze for SecureWasmAeadContext
impl !RefUnwindSafe for SecureWasmAeadContext
impl Send for SecureWasmAeadContext
impl Sync for SecureWasmAeadContext
impl Unpin for SecureWasmAeadContext
impl UnsafeUnpin for SecureWasmAeadContext
impl !UnwindSafe for SecureWasmAeadContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.