Skip to main content

KwKey

Struct KwKey 

Source
pub struct KwKey { /* private fields */ }
Expand description

A key-wrapping key: an unforgeable capability, bound to one algorithm at creation. The extractability and getter contracts in README.md apply.

Implementations§

Source§

impl KwKey

Source

pub async fn wrap(&self, input: WrapInput) -> Result<Vec<u8>, Error>

Encrypt serialized key material. The minting interface documents the wrapped wire format and the algorithm’s input domain; material whose serialization falls outside that domain fails error.invalid-key.

input is consumed.

Requires can-wrap, else error.not-permitted.

Source§

impl KwKey

Source

pub async fn unwrap(&self, wrapped: Vec<u8>) -> Result<UnwrapInput, Error>

Decrypt and integrity-check wrapped key material, as produced by wrap under the same algorithm. The result awaits a typed mint (see unwrap-input, including the verification-timing latitude); the material never reaches the caller.

Security:

  • Any failure of the integrity check — including input that cannot carry the algorithm’s wrapped form (the minting interface documents the domain) — reports error.authentication-failed with no detail.

Requires can-unwrap, else error.not-permitted.

Source§

impl KwKey

Source

pub fn algorithm_name(&self) -> String

The registry name of the algorithm family this key is bound to, e.g. "AES-KW" (WebCrypto’s KeyAlgorithm.name). Parameters are separate getters, as for mac-key.algorithm-name.

Source§

impl KwKey

Source

pub fn algorithm_length(&self) -> u32

The key length in bits, e.g. 256 (WebCrypto’s AesKeyAlgorithm.length).

Source§

impl KwKey

Source

pub fn extractable(&self) -> bool

Whether the key material may be exported.

Source§

impl KwKey

Source

pub fn can_wrap(&self) -> bool

Whether this key permits wrap. A refused operation fails error.not-permitted.

Source§

impl KwKey

Source

pub fn can_unwrap(&self) -> bool

Whether this key permits unwrap. See can-wrap.

Source§

impl KwKey

Source

pub async fn export_key_raw(&self) -> Result<Vec<u8>, Error>

The raw key material. Fails with error.not-extractable unless the key was created with extractable true.

Source§

impl KwKey

Source

pub async fn export_key_jwk(&self) -> Result<String, Error>

The key as an RFC 7517 JSON Web Key, behind the same extractability gate as export-key-raw. See README.md, “JWK contract”.

Source§

impl KwKey

Source

pub async fn to_wrap_input_raw(&self) -> Result<WrapInput, Error>

This key’s raw material as a wrap-input, for wrapping under another key. Behind the same extractability gate as export-key-raw; the material itself never reaches the caller.

Source§

impl KwKey

Source

pub async fn to_wrap_input_jwk(&self) -> Result<WrapInput, Error>

The JWK serialization as a wrap-input, behind the same gate. See README.md, “JWK contract”.

Trait Implementations§

Source§

impl Debug for KwKey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<KwKey> for KwKey

Source§

fn from(raw: KwKey) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !Freeze for KwKey

§

impl RefUnwindSafe for KwKey

§

impl Send for KwKey

§

impl Sync for KwKey

§

impl Unpin for KwKey

§

impl UnsafeUnpin for KwKey

§

impl UnwindSafe for KwKey

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Resource for T
where T: 'static,

§

type Rep = Option<T>

The type which is actually stored in-memory for this resource. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.