pub struct KeyCandidateBudget { /* private fields */ }Expand description
Aggregate key-candidate work allowance for one cryptographic operation.
Resolver implementations must consume one unit before each key lookup or unwrap attempt. A single budget is shared across direct and recipient keys.
Implementations§
Source§impl KeyCandidateBudget
impl KeyCandidateBudget
Sourcepub fn for_operation() -> Self
pub fn for_operation() -> Self
Create the fixed implementation-wide budget for one operation.
Sourcepub fn with_limit(maximum: usize) -> Self
pub fn with_limit(maximum: usize) -> Self
Create a budget from a validated operation policy ceiling.
Sourcepub const fn remaining(&self) -> usize
pub const fn remaining(&self) -> usize
Number of candidate attempts still available to this operation.
Sourcepub fn derive_key(
&mut self,
provider: &dyn CryptoProvider,
policy: &DecryptionPolicy,
parameters: &KdfParameters<'_>,
secret: &[u8],
) -> Result<Zeroizing<Vec<u8>>, XmlEncError>
pub fn derive_key( &mut self, provider: &dyn CryptoProvider, policy: &DecryptionPolicy, parameters: &KdfParameters<'_>, secret: &[u8], ) -> Result<Zeroizing<Vec<u8>>, XmlEncError>
Derive a key against the caller’s operation snapshot, retaining all KDF reservations in this same budget across nested sources and retries. Resolvers must forward the snapshot received by their policy-aware entry point; they must never choose a profile from document content.
Sourcepub fn agree_and_derive(
&mut self,
provider: &dyn CryptoProvider,
policy: &DecryptionPolicy,
key: &dyn KeyAgreementKey,
agreement: &KeyAgreementParameters<'_>,
parameters: &KdfParameters<'_>,
) -> Result<Zeroizing<Vec<u8>>, XmlEncError>
pub fn agree_and_derive( &mut self, provider: &dyn CryptoProvider, policy: &DecryptionPolicy, key: &dyn KeyAgreementKey, agreement: &KeyAgreementParameters<'_>, parameters: &KdfParameters<'_>, ) -> Result<Zeroizing<Vec<u8>>, XmlEncError>
Establish a shared secret and derive its consuming key after reserving both outputs and checking both permissions before either provider call. Candidate allowance includes scalar multiplication and derivation.