pub struct SecretProtectedKeyEnvelope {
cose_encrypt: CoseEncrypt,
}Expand description
A secret-protected key envelope can seal a symmetric key, and protect it with a high-entropy secret of arbitrary length.
Unlike the crate::safe::PasswordProtectedKeyEnvelope, which is meant for low-entropy secrets such as PINs and uses a compute-hard or memory-hard KDF, this envelope assumes the secret is high-entropy and thus uses a cheap KDF (HKDF). The KDF salt is stored in the envelope and does not have to be provided.
Internally, HKDF-SHA256 is used as the KDF and AES-256-GCM is used to encrypt the key.
Fields§
§cose_encrypt: CoseEncryptImplementations§
Source§impl SecretProtectedKeyEnvelope
impl SecretProtectedKeyEnvelope
Sourcepub fn seal<Ids: KeySlotIds>(
key_to_seal: Ids::Symmetric,
secret: &HighEntropySecret,
namespace: SecretProtectedKeyEnvelopeNamespace,
ctx: &KeyStoreContext<'_, Ids>,
) -> Result<Self, SecretProtectedKeyEnvelopeError>
pub fn seal<Ids: KeySlotIds>( key_to_seal: Ids::Symmetric, secret: &HighEntropySecret, namespace: SecretProtectedKeyEnvelopeNamespace, ctx: &KeyStoreContext<'_, Ids>, ) -> Result<Self, SecretProtectedKeyEnvelopeError>
Seals a symmetric key with a HighEntropySecret, using a random salt.
The secret is guaranteed to be high-entropy by the HighEntropySecret type, which the
cheap KDF used here relies on, since it cannot defend a low-entropy secret against
brute-forcing.
This should never fail, except for memory allocation error, when running the KDF.
Sourcefn seal_ref(
key_to_seal: &SymmetricCryptoKey,
secret: &HighEntropySecret,
namespace: SecretProtectedKeyEnvelopeNamespace,
) -> Result<Self, SecretProtectedKeyEnvelopeError>
fn seal_ref( key_to_seal: &SymmetricCryptoKey, secret: &HighEntropySecret, namespace: SecretProtectedKeyEnvelopeNamespace, ) -> Result<Self, SecretProtectedKeyEnvelopeError>
Seals a key reference with a secret. This function is not public since callers are expected to only work with key store references.
Sourcefn seal_ref_with_settings(
key_to_seal: &SymmetricCryptoKey,
secret: &HighEntropySecret,
hkdf_settings: &HkdfSettings,
namespace: SecretProtectedKeyEnvelopeNamespace,
) -> Result<Self, SecretProtectedKeyEnvelopeError>
fn seal_ref_with_settings( key_to_seal: &SymmetricCryptoKey, secret: &HighEntropySecret, hkdf_settings: &HkdfSettings, namespace: SecretProtectedKeyEnvelopeNamespace, ) -> Result<Self, SecretProtectedKeyEnvelopeError>
Seals a key reference with a secret and custom provided settings. This function is not public since callers are expected to only work with key store references.
Sourcepub fn unseal<Ids: KeySlotIds>(
&self,
secret: &HighEntropySecret,
namespace: SecretProtectedKeyEnvelopeNamespace,
ctx: &mut KeyStoreContext<'_, Ids>,
) -> Result<Ids::Symmetric, SecretProtectedKeyEnvelopeError>
pub fn unseal<Ids: KeySlotIds>( &self, secret: &HighEntropySecret, namespace: SecretProtectedKeyEnvelopeNamespace, ctx: &mut KeyStoreContext<'_, Ids>, ) -> Result<Ids::Symmetric, SecretProtectedKeyEnvelopeError>
Unseals a symmetric key from the secret-protected envelope, and stores it in the key store context.
fn unseal_ref( &self, secret: &HighEntropySecret, content_namespace: SecretProtectedKeyEnvelopeNamespace, ) -> Result<SymmetricCryptoKey, SecretProtectedKeyEnvelopeError>
Sourcepub fn reseal(
&self,
secret: &HighEntropySecret,
new_secret: &HighEntropySecret,
namespace: SecretProtectedKeyEnvelopeNamespace,
) -> Result<Self, SecretProtectedKeyEnvelopeError>
pub fn reseal( &self, secret: &HighEntropySecret, new_secret: &HighEntropySecret, namespace: SecretProtectedKeyEnvelopeNamespace, ) -> Result<Self, SecretProtectedKeyEnvelopeError>
Re-seals the key with a new salt, and a new secret
Sourcepub fn contained_key_id(
&self,
) -> Result<Option<KeyId>, SecretProtectedKeyEnvelopeError>
pub fn contained_key_id( &self, ) -> Result<Option<KeyId>, SecretProtectedKeyEnvelopeError>
Get the key ID of the contained key, if the key ID is stored on the envelope headers. Only COSE keys have a key ID, legacy keys do not.
Trait Implementations§
Source§impl Clone for SecretProtectedKeyEnvelope
impl Clone for SecretProtectedKeyEnvelope
Source§fn clone(&self) -> SecretProtectedKeyEnvelope
fn clone(&self) -> SecretProtectedKeyEnvelope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SecretProtectedKeyEnvelope
impl Debug for SecretProtectedKeyEnvelope
Source§impl<'de> Deserialize<'de> for SecretProtectedKeyEnvelope
impl<'de> Deserialize<'de> for SecretProtectedKeyEnvelope
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl From<&SecretProtectedKeyEnvelope> for Vec<u8>
impl From<&SecretProtectedKeyEnvelope> for Vec<u8>
Source§fn from(val: &SecretProtectedKeyEnvelope) -> Self
fn from(val: &SecretProtectedKeyEnvelope) -> Self
Source§impl From<SecretProtectedKeyEnvelope> for String
impl From<SecretProtectedKeyEnvelope> for String
Source§fn from(val: SecretProtectedKeyEnvelope) -> Self
fn from(val: SecretProtectedKeyEnvelope) -> Self
Source§impl FromStr for SecretProtectedKeyEnvelope
impl FromStr for SecretProtectedKeyEnvelope
Source§impl FromWasmAbi for SecretProtectedKeyEnvelope
Available on crate feature wasm only.
impl FromWasmAbi for SecretProtectedKeyEnvelope
wasm only.Source§impl IntoWasmAbi for SecretProtectedKeyEnvelope
Available on crate feature wasm only.
impl IntoWasmAbi for SecretProtectedKeyEnvelope
wasm only.Source§impl OptionFromWasmAbi for SecretProtectedKeyEnvelope
Available on crate feature wasm only.
impl OptionFromWasmAbi for SecretProtectedKeyEnvelope
wasm only.Source§impl TryFrom<JsValue> for SecretProtectedKeyEnvelope
Available on crate feature wasm only.
impl TryFrom<JsValue> for SecretProtectedKeyEnvelope
wasm only.Source§impl WasmDescribe for SecretProtectedKeyEnvelope
Available on crate feature wasm only.
impl WasmDescribe for SecretProtectedKeyEnvelope
wasm only.Auto Trait Implementations§
impl Freeze for SecretProtectedKeyEnvelope
impl RefUnwindSafe for SecretProtectedKeyEnvelope
impl Send for SecretProtectedKeyEnvelope
impl Sync for SecretProtectedKeyEnvelope
impl Unpin for SecretProtectedKeyEnvelope
impl UnsafeUnpin for SecretProtectedKeyEnvelope
impl UnwindSafe for SecretProtectedKeyEnvelope
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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 more§impl<I> IntoResettable<String> for I
impl<I> IntoResettable<String> for I
§fn into_resettable(self) -> Resettable<String>
fn into_resettable(self) -> Resettable<String>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
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.