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
impl KwKey
Sourcepub async fn wrap(&self, input: WrapInput) -> Result<Vec<u8>, Error>
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
impl KwKey
Sourcepub async fn unwrap(&self, wrapped: Vec<u8>) -> Result<UnwrapInput, Error>
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-failedwith no detail.
Requires can-unwrap, else error.not-permitted.
Source§impl KwKey
impl KwKey
Sourcepub fn algorithm_name(&self) -> String
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
impl KwKey
Sourcepub fn algorithm_length(&self) -> u32
pub fn algorithm_length(&self) -> u32
The key length in bits, e.g. 256 (WebCrypto’s
AesKeyAlgorithm.length).
Source§impl KwKey
impl KwKey
Sourcepub fn can_unwrap(&self) -> bool
pub fn can_unwrap(&self) -> bool
Whether this key permits unwrap. See can-wrap.
Source§impl KwKey
impl KwKey
Sourcepub async fn export_key_jwk(&self) -> Result<String, Error>
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”.