wrap method

Uint8List wrap(
  1. Uint8List data
)

Implementation

Uint8List wrap(Uint8List data) {
  var n = data.length ~/ 8;

  var r = Uint8List.fromList(data);

  var a = Uint8List(16);

  var b = Uint8List(16);
  var b64 = ByteData.view(b.buffer);

  a.setAll(0, _iv);

  for (var j = 0; j <= 5; j++) {
    for (var i = 0; i < n; i++) {
      var t = n * j + i + 1;

      a.setAll(8, r.skip(i * 8).take(8));

      _underlyingCipher.processBlock(a, 0, b, 0);

      b64.setUint32(0, b64.getUint32(0) ^ (t << 32));
      b64.setUint32(4, b64.getUint32(4) ^ (t & 0xffffffff));

      a.setAll(0, b.take(8));
      r.setAll(i * 8, b.skip(8));
    }
  }

  var c = Uint8List(n * 8 + 8);
  c.setAll(0, a.take(8));
  c.setAll(8, r);

  return c;
}