Lines Matching refs:crypto
16 //! This module is used to manage crypto in cache.
26 use crate::crypto::Crypto;
30 /// Manages the crypto that required user authentication.
46 /// Add the crypto to manager.
47 pub fn add(&mut self, crypto: Crypto) -> Result<()> {
52 self.cryptos.push(crypto);
57 /// Find the crypto with the specified alias and challenge slice from manager.
60 for crypto in self.cryptos.iter() {
61 if crypto.challenge().eq(challenge) && crypto.calling_info().eq(calling_info) {
62 return Ok(crypto);
65 log_throw_error!(ErrCode::NotFound, "The crypto expires or does not exist. Call the preQuery first.")
68 /// Remove the crypto from manager.
70 self.cryptos.retain(|crypto| crypto.calling_info() != calling_info || !crypto.challenge().eq(challenge));
73 /// Remove the crypto by calling info.
75 self.cryptos.retain(|crypto| crypto.calling_info() != calling_info);
80 self.cryptos.retain(|crypto| !crypto.key().need_device_unlock());
83 /// Get last crypto expire time.
87 for crypto in &self.cryptos {
88 max_time = max(crypto.valid_time() as u64 - crypto.start_time().elapsed().as_secs(), max_time)
94 self.cryptos.retain(|crypto| crypto.start_time().elapsed().as_secs() <= crypto.valid_time() as u64);