fn check_encryption_count(&mut self) -> Result<(), Error> {
        // Make sure no more than 2^32 - 1 tokens are encrypted under
        // the same encryption key.
        if self.num_encrypted_tokens == u32::MAX {
            // Reinitialize the cipher entity under a new key when limit is exceeded.
            // As a result, all valid tokens created under the previous key are invalidated.
            // By design, we don't retain the cipher used to encrypt previous tokens,
            // because reaching the limit is very unlikely and should not happen under
            // healthy interactions with MMDS. However, if it happens, we expect the
            // customer code to have a retry mechanism in place and regenerate the
            // session token if the previous ones become invalid.
            self.cipher = TokenAuthority::create_cipher(&mut self.entropy_pool)?;
            // Reset encrypted tokens count.
            self.num_encrypted_tokens = 0;
            warn!(
                "The limit of tokens generated under current MMDS token authority
                has been reached. MMDS's token authority entity has been reseeded
                and all previously created tokens are now invalid."
            );
        }

        Ok(())
    }
/// Make sure to reinitialize the cipher under a new key before reaching
/// a count of 2^32 encrypted tokens under the same cipher entity.
Make sure to reinitialize the cipher under a new key before reaching
a count of 2^32 encrypted tokens under the same cipher entity.
Make sure to reinitialize the cipher under a new key before reaching a count of 2^32 encrypted tokens under the same cipher entity .
fn check_encryption_count(&mut self) -> Result<(), Error> {
        // Make sure no more than 2^32 - 1 tokens are encrypted under
        // the same encryption key.
        if self.num_encrypted_tokens == u32::MAX {
            // Reinitialize the cipher entity under a new key when limit is exceeded.
            // As a result, all valid tokens created under the previous key are invalidated.
            // By design, we don't retain the cipher used to encrypt previous tokens,
            // because reaching the limit is very unlikely and should not happen under
            // healthy interactions with MMDS. However, if it happens, we expect the
            // customer code to have a retry mechanism in place and regenerate the
            // session token if the previous ones become invalid.
            self.cipher = TokenAuthority::create_cipher(&mut self.entropy_pool)?;
            // Reset encrypted tokens count.
            self.num_encrypted_tokens = 0;
            warn!(
                "The limit of tokens generated under current MMDS token authority
                has been reached. MMDS's token authority entity has been reseeded
                and all previously created tokens are now invalid."
            );
        }
        Ok(())
    }
fn check_encryption_count ( & mut self ) -> Result < ( ) , Error > { // Make sure no more than 2^32 - 1 tokens are encrypted under // the same encryption key. if self . num_encrypted_tokens == u32 :: MAX { // Reinitialize the cipher entity under a new key when limit is exceeded. // As a result, all valid tokens created under the previous key are invalidated. // By design, we don't retain the cipher used to encrypt previous tokens, // because reaching the limit is very unlikely and should not happen under // healthy interactions with MMDS. However, if it happens, we expect the // customer code to have a retry mechanism in place and regenerate the // session token if the previous ones become invalid. self . cipher = TokenAuthority :: create_cipher ( & mut self . entropy_pool ) ? ; // Reset encrypted tokens count. self . num_encrypted_tokens = 0 ; warn ! ( " " ) ; } Ok ( ( ) ) }
Make sure to reinitialize the cipher under a new key before reaching
a count of 2^32 encrypted tokens under the same cipher entity.
Make sure to reinitialize the cipher under a new key before reaching a count of 2^32 encrypted tokens under the same cipher entity .
&mut self
&mut self