fn create_token(&mut self, ttl_seconds: u32) -> Result<Token, Error> {
        // Validate token time to live against bounds.
        if !TokenAuthority::check_ttl(ttl_seconds) {
            return Err(Error::InvalidTtlValue(ttl_seconds));
        }

        // Generate 12-byte random nonce.
        let mut iv = [0u8; IV_LEN];
        self.entropy_pool
            .read_exact(&mut iv)
            .map_err(Error::EntropyPool)?;

        // Compute expiration time in milliseconds from ttl.
        let expiry = TokenAuthority::compute_expiry(ttl_seconds);
        // Encrypt expiry using the nonce.
        let (payload, tag) = self.encrypt_expiry(expiry, iv.as_ref())?;

        Ok(Token::new(iv, payload, tag))
    }
/// Create a new Token structure to encrypt.
Create a new Token structure to encrypt.
Create a new Token structure to encrypt .
fn create_token(&mut self, ttl_seconds: u32) -> Result<Token, Error> {
        // Validate token time to live against bounds.
        if !TokenAuthority::check_ttl(ttl_seconds) {
            return Err(Error::InvalidTtlValue(ttl_seconds));
        }
        // Generate 12-byte random nonce.
        let mut iv = [0u8; IV_LEN];
        self.entropy_pool
            .read_exact(&mut iv)
            .map_err(Error::EntropyPool)?;
        // Compute expiration time in milliseconds from ttl.
        let expiry = TokenAuthority::compute_expiry(ttl_seconds);
        // Encrypt expiry using the nonce.
        let (payload, tag) = self.encrypt_expiry(expiry, iv.as_ref())?;
        Ok(Token::new(iv, payload, tag))
    }
fn create_token ( & mut self , ttl_seconds : u32 ) -> Result < Token , Error > { // Validate token time to live against bounds. if ! TokenAuthority :: check_ttl ( ttl_seconds ) { return Err ( Error :: InvalidTtlValue ( ttl_seconds ) ) ; } // Generate 12-byte random nonce. let mut iv = [ 0u8 ; IV_LEN ] ; self . entropy_pool . read_exact ( & mut iv ) . map_err ( Error :: EntropyPool ) ? ; // Compute expiration time in milliseconds from ttl. let expiry = TokenAuthority :: compute_expiry ( ttl_seconds ) ; // Encrypt expiry using the nonce. let ( payload , tag ) = self . encrypt_expiry ( expiry , iv . as_ref ( ) ) ? ; Ok ( Token :: new ( iv , payload , tag ) ) }
Create a new Token structure to encrypt.
Create a new Token structure to encrypt .
&mut self
ttl_seconds
u32
&mut self
ttl_seconds
u32