pub struct WasmAeadContext { /* private fields */ }Expand description
WASM-compatible AEAD context wrapper
This wrapper provides JavaScript-compatible bindings for AEAD operations:
- Integrates with the new modular architecture
- Includes security validation
- Provides consistent error handling
- Supports all AEAD algorithms
Implementations§
Source§impl WasmAeadContext
impl WasmAeadContext
Sourcepub fn new() -> WasmAeadContext
pub fn new() -> WasmAeadContext
Create a WASM AEAD context with no crypto provider configured.
For AEAD backed by lib-q-aead, use the lib-q crate’s wasm::create_aead_context, or
Self::from_aead_context / Self::with_provider.
Sourcepub fn from_aead_context(inner: AeadContext) -> WasmAeadContext
pub fn from_aead_context(inner: AeadContext) -> WasmAeadContext
Wrap a Rust AeadContext (for example one built with AeadContext::with_aead_operations).
Source§impl WasmAeadContext
impl WasmAeadContext
Sourcepub fn with_provider(provider: &WasmCryptoProvider) -> WasmAeadContext
pub fn with_provider(provider: &WasmCryptoProvider) -> WasmAeadContext
Create a new WASM AEAD context with custom provider
Sourcepub fn encrypt(
&mut self,
algorithm: &str,
key: &Uint8Array,
nonce: &Uint8Array,
plaintext: &Uint8Array,
aad: Option<Uint8Array>,
) -> Result<Vec<u8>, JsValue>
pub fn encrypt( &mut self, algorithm: &str, key: &Uint8Array, nonce: &Uint8Array, plaintext: &Uint8Array, aad: Option<Uint8Array>, ) -> Result<Vec<u8>, JsValue>
Encrypt data using the specified algorithm
Sourcepub fn decrypt(
&self,
algorithm: &str,
key: &Uint8Array,
nonce: &Uint8Array,
ciphertext: &Uint8Array,
aad: Option<Uint8Array>,
) -> Result<Vec<u8>, JsValue>
pub fn decrypt( &self, algorithm: &str, key: &Uint8Array, nonce: &Uint8Array, ciphertext: &Uint8Array, aad: Option<Uint8Array>, ) -> Result<Vec<u8>, JsValue>
Decrypt data using the specified algorithm.
This WASM binding stays on Layer A (crate::traits::Aead / crate::api::AeadOperations):
only Result-style success versus error is exposed. Semantic decrypt
(crate::AeadDecryptSemantic) is not wired here to avoid silent ABI changes; use Rust
types directly when Layer B is required.
Sourcepub fn security_level(&self) -> u32
pub fn security_level(&self) -> u32
Get the security level of the context
Sourcepub fn is_algorithm_supported(&self, algorithm: &str) -> bool
pub fn is_algorithm_supported(&self, algorithm: &str) -> bool
Check if an algorithm is supported
Sourcepub fn supported_algorithms(&self) -> String
pub fn supported_algorithms(&self) -> String
Get supported algorithms
Trait Implementations§
Source§impl Default for WasmAeadContext
impl Default for WasmAeadContext
Source§impl From<WasmAeadContext> for JsValue
impl From<WasmAeadContext> for JsValue
Source§fn from(value: WasmAeadContext) -> Self
fn from(value: WasmAeadContext) -> Self
Source§impl FromWasmAbi for WasmAeadContext
impl FromWasmAbi for WasmAeadContext
Source§impl IntoWasmAbi for WasmAeadContext
impl IntoWasmAbi for WasmAeadContext
Source§impl LongRefFromWasmAbi for WasmAeadContext
impl LongRefFromWasmAbi for WasmAeadContext
Source§type Abi = WasmPtr<WasmRefCell<WasmAeadContext>>
type Abi = WasmPtr<WasmRefCell<WasmAeadContext>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<WasmAeadContext>
type Anchor = RcRef<WasmAeadContext>
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl OptionFromWasmAbi for WasmAeadContext
impl OptionFromWasmAbi for WasmAeadContext
Source§impl OptionIntoWasmAbi for WasmAeadContext
impl OptionIntoWasmAbi for WasmAeadContext
Source§impl RefFromWasmAbi for WasmAeadContext
impl RefFromWasmAbi for WasmAeadContext
Source§type Abi = WasmPtr<WasmRefCell<WasmAeadContext>>
type Abi = WasmPtr<WasmRefCell<WasmAeadContext>>
Self are recovered from.Source§type Anchor = RcRef<WasmAeadContext>
type Anchor = RcRef<WasmAeadContext>
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§impl RefMutFromWasmAbi for WasmAeadContext
impl RefMutFromWasmAbi for WasmAeadContext
Source§type Abi = WasmPtr<WasmRefCell<WasmAeadContext>>
type Abi = WasmPtr<WasmRefCell<WasmAeadContext>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<WasmAeadContext>
type Anchor = RcRefMut<WasmAeadContext>
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl TryFromJsValue for WasmAeadContext
impl TryFromJsValue for WasmAeadContext
Source§impl VectorFromWasmAbi for WasmAeadContext
impl VectorFromWasmAbi for WasmAeadContext
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WasmAeadContext]>
Source§impl VectorIntoWasmAbi for WasmAeadContext
impl VectorIntoWasmAbi for WasmAeadContext
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WasmAeadContext]>) -> Self::Abi
Source§impl WasmDescribeVector for WasmAeadContext
impl WasmDescribeVector for WasmAeadContext
impl SupportsConstructor for WasmAeadContext
impl SupportsInstanceProperty for WasmAeadContext
impl SupportsStaticProperty for WasmAeadContext
Auto Trait Implementations§
impl Freeze for WasmAeadContext
impl !RefUnwindSafe for WasmAeadContext
impl Send for WasmAeadContext
impl Sync for WasmAeadContext
impl Unpin for WasmAeadContext
impl UnsafeUnpin for WasmAeadContext
impl !UnwindSafe for WasmAeadContext
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
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
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.