pub struct DecryptionKey(/* private fields */);Expand description
A public-encryption.decryption-key: the private half of asymmetric
encryption. decrypt and unwrap are
one-shot calls on the immutable key, over whole byte buffers (see
EncryptionKey for why nothing streams here).
Implementations§
Source§impl DecryptionKey
impl DecryptionKey
Sourcepub fn from_raw(raw: DecryptionKey) -> Self
pub fn from_raw(raw: DecryptionKey) -> Self
Wrap a raw decryption-key resource.
Sourcepub fn as_raw(&self) -> &DecryptionKey
pub fn as_raw(&self) -> &DecryptionKey
Borrow the raw decryption-key resource.
Sourcepub fn into_raw(self) -> DecryptionKey
pub fn into_raw(self) -> DecryptionKey
Unwrap into the raw decryption-key resource.
Source§impl DecryptionKey
impl DecryptionKey
Sourcepub async fn decrypt(
&self,
label: Option<&[u8]>,
ciphertext: impl Into<Vec<u8>>,
) -> Result<Vec<u8>, Error>
pub async fn decrypt( &self, label: Option<&[u8]>, ciphertext: impl Into<Vec<u8>>, ) -> Result<Vec<u8>, Error>
Decrypt a ciphertext produced by the matching public key under the
same label. Fails Error::NotPermitted without the
decrypt grant; every decryption
failure is the one detail-free Error::AuthenticationFailed — a
wrong-length ciphertext, damaged padding, and a mismatched label
are indistinguishable, as RFC 8017 requires.
Sourcepub async fn unwrap(
&self,
label: Option<&[u8]>,
ciphertext: impl Into<Vec<u8>>,
) -> Result<UnwrapInput, Error>
pub async fn unwrap( &self, label: Option<&[u8]>, ciphertext: impl Into<Vec<u8>>, ) -> Result<UnwrapInput, Error>
Decrypt a wrapped key into an UnwrapInput for a typed unwrap
mint: the material never reaches the caller. Fails
Error::NotPermitted without the
unwrap grant; failures are
otherwise as decrypt.
Sourcepub fn algorithm_name(&self) -> String
pub fn algorithm_name(&self) -> String
Sourcepub fn algorithm_hash(&self) -> Option<String>
pub fn algorithm_hash(&self) -> Option<String>
Sourcepub fn algorithm_length(&self) -> Option<u32>
pub fn algorithm_length(&self) -> Option<u32>
Sourcepub fn algorithm_public_exponent(&self) -> Option<Vec<u8>>
pub fn algorithm_public_exponent(&self) -> Option<Vec<u8>>
Sourcepub fn can_decrypt(&self) -> bool
pub fn can_decrypt(&self) -> bool
Whether the key permits decrypt — the usage
recorded at mint. A refused operation fails
Error::NotPermitted.
Sourcepub fn can_unwrap(&self) -> bool
pub fn can_unwrap(&self) -> bool
Whether the key permits unwrap. See
can_decrypt.
Sourcepub fn extractable(&self) -> bool
pub fn extractable(&self) -> bool
Whether the export functions may return this key’s material (see
Mac::extractable).
Sourcepub async fn export_key_jwk(&self) -> Result<String, Error>
pub async fn export_key_jwk(&self) -> Result<String, Error>
The private key as a JWK (JSON text); fails
Error::NotExtractable unless the key was minted extractable.
Sourcepub async fn export_key_pkcs8(&self) -> Result<Vec<u8>, Error>
pub async fn export_key_pkcs8(&self) -> Result<Vec<u8>, Error>
The private key as a PKCS#8 PrivateKeyInfo (DER), behind the same
extractability gate as export_key_jwk.
Sourcepub async fn to_wrap_input_jwk(&self) -> Result<WrapInput, Error>
pub async fn to_wrap_input_jwk(&self) -> Result<WrapInput, Error>
The private-key JWK serialization as a WrapInput, for wrapping
under another key. Behind the same extractability gate as
export_key_jwk.