cleanSavedState method

  1. @override
void cleanSavedState(
  1. HashState savedState
)
override

Cleans and resets a saved hash state, securely erasing sensitive data.

This method takes a savedState object and cleans it by wiping its internal state vectors, buffer, key (if present), counters, and flags. It ensures that any sensitive information in the saved state is securely erased.

Note: The savedState object must be of type Blake2bState.

Parameters:

  • savedState: The hash state to clean and reset securely.

Implementation

@override
void cleanSavedState(HashState savedState) {
  savedState as Blake2bState;
  zero(savedState.state);
  zero(savedState.buffer);
  zero(savedState.initialState);

  if (savedState.paddedKey != null) {
    zero(savedState.paddedKey!);
  }

  savedState.bufferLength = 0;
  zero(savedState.ctr);
  zero(savedState.flag);

  savedState.lastNode = false;
}