processByte method

  1. @override
int processByte(
  1. int inp,
  2. Uint8List out,
  3. int outOff
)
override

Implementation

@override
int processByte(int inp, Uint8List out, int outOff) {
  checkData();

  switch (_state) {
    case State.DEC_DATA:
      {
        _buf[_bufPos] = inp;
        if (++_bufPos == _buf.length) {
          poly1305.update(_buf, 0, BUF_SIZE);
          processData(_buf, 0, BUF_SIZE, out, outOff);
          utils.arrayCopy(_buf, BUF_SIZE, _buf, 0, MAC_SIZE);
          _bufPos = MAC_SIZE;
          return BUF_SIZE;
        }

        return 0;
      }
    case State.ENC_DATA:
      {
        _buf[_bufPos] = inp;
        if (++_bufPos == BUF_SIZE) {
          processData(_buf, 0, BUF_SIZE, out, outOff);
          poly1305.update(out, outOff, BUF_SIZE);
          _bufPos = 0;
          return BUF_SIZE;
        }

        return 0;
      }
    default:
      throw StateError('');
  }
}