update method

Poly1305 update(
  1. List<int> data
)

Updates the Poly1305 authentication state with additional data from the given List<int>.

This method incorporates more data into the Poly1305 authentication process, allowing it to be computed incrementally.

Parameters:

  • data: A List<int> containing the additional data to be included in the authentication calculation.

Returns: A reference to the Poly1305 instance, enabling method chaining for convenience.

This method extends the Poly1305 authentication state with the provided data from data.

Implementation

Poly1305 update(List<int> data) {
  int mpos = 0;
  int bytes = data.length;
  int want;
  if (_leftover != 0) {
    want = (16 - _leftover);
    if (want > bytes) {
      want = bytes;
    }
    for (int i = 0; i < want; i++) {
      _buffer[_leftover + i] = data[mpos + i] & mask8;
    }
    bytes -= want;
    mpos += want;
    _leftover += want;
    if (_leftover < 16) {
      return this;
    }
    _blocks(_buffer, 0, 16);
    _leftover = 0;
  }

  if (bytes >= 16) {
    want = bytes - (bytes % 16);
    _blocks(data, mpos, want);
    mpos += want;
    bytes -= want;
  }

  if (bytes > 0) {
    for (int i = 0; i < bytes; i++) {
      _buffer[_leftover + i] = data[mpos + i] & mask8;
    }
    _leftover += bytes;
  }

  return this;
}