clean method

CTR clean()

Clears internal state and data in the Counter (CTR) mode instance for security and memory management.

This method securely zeros the internal encrypted block buffer, the counter, and resets the buffer position and cipher reference to their initial states. It is essential for maintaining the security of the CTR mode instance after use and ensuring that no sensitive data remains in memory.

Returns:

  • The same CTR instance after cleaning for method chaining.

Note: Properly cleaning the CTR mode instance is crucial for security and memory management to prevent potential data leaks.

Implementation

CTR clean() {
  zero(_buffer); // Securely zero the encrypted block buffer
  zero(_counter); // Securely zero the counter
  _bufpos = _buffer.length; // Reset the buffer position
  _cipher = null; // Clear the cipher reference
  return this;
}