@Override
  protected byte[] engineDoFinal() {
    try {
      ensureKeystoreOperationInitialized();
    } catch (InvalidKeyException e) {
      throw new ProviderException("Failed to reinitialize MAC", e);
    }

    byte[] result;
    try {
      result =
          mChunkedStreamer.doFinal(
              null,
              0,
              0,
              null, // no signature provided -- this invocation will generate one
              null // no additional entropy needed -- HMAC is deterministic
              );
    } catch (KeyStoreException e) {
      throw new ProviderException("Keystore operation failed", e);
    }

    resetWhilePreservingInitState();
    return result;
  }