pub struct OtpGenerator { /* private fields */ }Expand description
Generates cryptographically random OTP tokens.
Uses OsRng (FIPS-approved on supported platforms) to produce
tokens with at least 128 bits of entropy (RHELBU-3536 R7).
Implementations§
Source§impl OtpGenerator
impl OtpGenerator
Sourcepub fn new(config: OtpGeneratorConfig) -> OtpResult<Self>
pub fn new(config: OtpGeneratorConfig) -> OtpResult<Self>
Create a generator with the given configuration.
§Errors
Returns OtpError::GenerationError if entropy_bytes < 16
(below the 128-bit minimum required by RHELBU-3536 R7).
Sourcepub fn generate(
&self,
entity_id: &str,
label: &str,
profile: &str,
) -> OtpResult<GeneratedOtp>
pub fn generate( &self, entity_id: &str, label: &str, profile: &str, ) -> OtpResult<GeneratedOtp>
Generate a new OTP for the given entity and profile.
Returns a GeneratedOtp containing the plaintext token (for
delivery to the enrollee) and the SHA-256 hash (for storage).
The plaintext must not be persisted by the caller.
Sourcepub fn generate_with_options(
&self,
entity_id: &str,
label: &str,
profile: &str,
ttl_seconds: i64,
max_uses: u32,
) -> OtpResult<GeneratedOtp>
pub fn generate_with_options( &self, entity_id: &str, label: &str, profile: &str, ttl_seconds: i64, max_uses: u32, ) -> OtpResult<GeneratedOtp>
Generate an OTP with explicit TTL and max-use overrides.
Auto Trait Implementations§
impl Freeze for OtpGenerator
impl RefUnwindSafe for OtpGenerator
impl Send for OtpGenerator
impl Sync for OtpGenerator
impl Unpin for OtpGenerator
impl UnsafeUnpin for OtpGenerator
impl UnwindSafe for OtpGenerator
Blanket Implementations§
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
Mutably borrows from an owned value. Read more