blocks method

poly1305 blocks(
  1. Uint8List m,
  2. int mpos,
  3. int bytes
)

Implementation

poly1305 blocks(Uint8List m, int mpos, int bytes) {
  int hibit = _fin != 0 ? 0 : (1 << 11);
  Int32 t0, t1, t2, t3, t4, t5, t6, t7, c;
  Int32 d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;

  Int32 h0 = _h[0],
      h1 = _h[1],
      h2 = _h[2],
      h3 = _h[3],
      h4 = _h[4],
      h5 = _h[5],
      h6 = _h[6],
      h7 = _h[7],
      h8 = _h[8],
      h9 = _h[9];

  int r0 = _r[0].toInt(),
      r1 = _r[1].toInt(),
      r2 = _r[2].toInt(),
      r3 = _r[3].toInt(),
      r4 = _r[4].toInt(),
      r5 = _r[5].toInt(),
      r6 = _r[6].toInt(),
      r7 = _r[7].toInt(),
      r8 = _r[8].toInt(),
      r9 = _r[9].toInt();

  while (bytes >= 16) {
    t0 = Int32(m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8); h0 = Int32(h0.toInt() + (t0.toInt() & 0x1fff));
    t1 = Int32(m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8); h1 = Int32(h1.toInt() + (((t0.shiftRightUnsigned(13)) | (t1 <<  3)).toInt() & 0x1fff));
    t2 = Int32(m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8); h2 = Int32(h2.toInt() + (((t1.shiftRightUnsigned(10)) | (t2 <<  6)).toInt() & 0x1fff));
    t3 = Int32(m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8); h3 = Int32(h3.toInt() + (((t2.shiftRightUnsigned( 7)) | (t3 <<  9)).toInt() & 0x1fff));
    t4 = Int32(m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8); h4 = Int32(h4.toInt() + (((t3.shiftRightUnsigned( 4)) | (t4 << 12)).toInt() & 0x1fff));
    h5 = Int32(h5.toInt() + (((t4.shiftRightUnsigned( 1))).toInt() & 0x1fff));
    t5 = Int32(m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8); h6 = Int32(h6.toInt() + (((t4.shiftRightUnsigned(14)) | (t5 <<  2)).toInt() & 0x1fff));
    t6 = Int32(m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8); h7 = Int32(h7.toInt() + (((t5.shiftRightUnsigned(11)) | (t6 <<  5)).toInt() & 0x1fff));
    t7 = Int32(m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8); h8 = Int32(h8.toInt() + (((t6.shiftRightUnsigned( 8)) | (t7 <<  8)).toInt() & 0x1fff));
    h9 = Int32(h9.toInt() + (((t7.shiftRightUnsigned(5))).toInt() | hibit));

    c = Int32(0);

    d0 = c;
    d0 = Int32(d0.toInt() + h0.toInt() * r0);
    d0 = Int32(d0.toInt() + h1.toInt() * (5 * r9));
    d0 = Int32(d0.toInt() + h2.toInt() * (5 * r8));
    d0 = Int32(d0.toInt() + h3.toInt() * (5 * r7));
    d0 = Int32(d0.toInt() + h4.toInt() * (5 * r6));
    c = (d0.shiftRightUnsigned(13)); d0 &= 0x1fff;
    d0 = Int32(d0.toInt() + h5.toInt() * (5 * r5));
    d0 = Int32(d0.toInt() + h6.toInt() * (5 * r4));
    d0 = Int32(d0.toInt() + h7.toInt() * (5 * r3));
    d0 = Int32(d0.toInt() + h8.toInt() * (5 * r2));
    d0 = Int32(d0.toInt() + h9.toInt() * (5 * r1));
    c = Int32(c.toInt() + d0.shiftRightUnsigned(13).toInt()); d0 &= 0x1fff;

    d1 = c;
    d1 = Int32(d1.toInt() + h0.toInt() * r1);
    d1 = Int32(d1.toInt() + h1.toInt() * r0);
    d1 = Int32(d1.toInt() + h2.toInt() * (5 * r9));
    d1 = Int32(d1.toInt() + h3.toInt() * (5 * r8));
    d1 = Int32(d1.toInt() + h4.toInt() * (5 * r7));
    c = (d1.shiftRightUnsigned(13)); d1 &= 0x1fff;
    d1 = Int32(d1.toInt() + h5.toInt() * (5 * r6));
    d1 = Int32(d1.toInt() + h6.toInt() * (5 * r5));
    d1 = Int32(d1.toInt() + h7.toInt() * (5 * r4));
    d1 = Int32(d1.toInt() + h8.toInt() * (5 * r3));
    d1 = Int32(d1.toInt() + h9.toInt() * (5 * r2));
    c = Int32(c.toInt() + (d1.shiftRightUnsigned(13)).toInt()); d1 &= 0x1fff;

    d2 = c;
    d2 = Int32(d2.toInt() + h0.toInt() * r2);
    d2 = Int32(d2.toInt() + h1.toInt() * r1);
    d2 = Int32(d2.toInt() + h2.toInt() * r0);
    d2 = Int32(d2.toInt() + h3.toInt() * (5 * r9));
    d2 = Int32(d2.toInt() + h4.toInt() * (5 * r8));
    c = (d2.shiftRightUnsigned(13)); d2 &= 0x1fff;
    d2 = Int32(d2.toInt() + h5.toInt() * (5 * r7));
    d2 = Int32(d2.toInt() + h6.toInt() * (5 * r6));
    d2 = Int32(d2.toInt() + h7.toInt() * (5 * r5));
    d2 = Int32(d2.toInt() + h8.toInt() * (5 * r4));
    d2 = Int32(d2.toInt() + h9.toInt() * (5 * r3));
    c = Int32(c.toInt() + (d2.shiftRightUnsigned(13)).toInt()); d2 &= 0x1fff;

    d3 = c;
    d3 = Int32(d3.toInt() + h0.toInt() * r3);
    d3 = Int32(d3.toInt() + h1.toInt() * r2);
    d3 = Int32(d3.toInt() + h2.toInt() * r1);
    d3 = Int32(d3.toInt() + h3.toInt() * r0);
    d3 = Int32(d3.toInt() + h4.toInt() * (5 * r9));
    c = (d3.shiftRightUnsigned(13)); d3 &= 0x1fff;
    d3 = Int32(d3.toInt() + h5.toInt() * (5 * r8));
    d3 = Int32(d3.toInt() + h6.toInt() * (5 * r7));
    d3 = Int32(d3.toInt() + h7.toInt() * (5 * r6));
    d3 = Int32(d3.toInt() + h8.toInt() * (5 * r5));
    d3 = Int32(d3.toInt() + h9.toInt() * (5 * r4));
    c = Int32(c.toInt() + (d3.shiftRightUnsigned(13)).toInt()); d3 &= 0x1fff;

    d4 = c;
    d4 = Int32(d4.toInt() + h0.toInt() * r4);
    d4 = Int32(d4.toInt() + h1.toInt() * r3);
    d4 = Int32(d4.toInt() + h2.toInt() * r2);
    d4 = Int32(d4.toInt() + h3.toInt() * r1);
    d4 = Int32(d4.toInt() + h4.toInt() * r0);
    c = (d4.shiftRightUnsigned(13)); d4 &= 0x1fff;
    d4 = Int32(d4.toInt() + h5.toInt() * (5 * r9));
    d4 = Int32(d4.toInt() + h6.toInt() * (5 * r8));
    d4 = Int32(d4.toInt() + h7.toInt() * (5 * r7));
    d4 = Int32(d4.toInt() + h8.toInt() * (5 * r6));
    d4 = Int32(d4.toInt() + h9.toInt() * (5 * r5));
    c = Int32(c.toInt() + (d4.shiftRightUnsigned(13)).toInt()); d4 &= 0x1fff;

    d5 = c;
    d5 = Int32(d5.toInt() + h0.toInt() * r5);
    d5 = Int32(d5.toInt() + h1.toInt() * r4);
    d5 = Int32(d5.toInt() + h2.toInt() * r3);
    d5 = Int32(d5.toInt() + h3.toInt() * r2);
    d5 = Int32(d5.toInt() + h4.toInt() * r1);
    c = (d5.shiftRightUnsigned(13)); d5 &= 0x1fff;
    d5 = Int32(d5.toInt() + h5.toInt() * r0);
    d5 = Int32(d5.toInt() + h6.toInt() * (5 * r9));
    d5 = Int32(d5.toInt() + h7.toInt() * (5 * r8));
    d5 = Int32(d5.toInt() + h8.toInt() * (5 * r7));
    d5 = Int32(d5.toInt() + h9.toInt() * (5 * r6));
    c = Int32(c.toInt() + (d5.shiftRightUnsigned(13)).toInt()); d5 &= 0x1fff;

    d6 = c;
    d6 = Int32(d6.toInt() + h0.toInt() * r6);
    d6 = Int32(d6.toInt() + h1.toInt() * r5);
    d6 = Int32(d6.toInt() + h2.toInt() * r4);
    d6 = Int32(d6.toInt() + h3.toInt() * r3);
    d6 = Int32(d6.toInt() + h4.toInt() * r2);
    c = (d6.shiftRightUnsigned(13)); d6 &= 0x1fff;
    d6 = Int32(d6.toInt() + h5.toInt() * r1);
    d6 = Int32(d6.toInt() + h6.toInt() * r0);
    d6 = Int32(d6.toInt() + h7.toInt() * (5 * r9));
    d6 = Int32(d6.toInt() + h8.toInt() * (5 * r8));
    d6 = Int32(d6.toInt() + h9.toInt() * (5 * r7));
    c = Int32(c.toInt() + (d6.shiftRightUnsigned(13)).toInt()); d6 &= 0x1fff;

    d7 = c;
    d7 = Int32(d7.toInt() + h0.toInt() * r7);
    d7 = Int32(d7.toInt() + h1.toInt() * r6);
    d7 = Int32(d7.toInt() + h2.toInt() * r5);
    d7 = Int32(d7.toInt() + h3.toInt() * r4);
    d7 = Int32(d7.toInt() + h4.toInt() * r3);
    c = (d7.shiftRightUnsigned(13)); d7 &= 0x1fff;
    d7 = Int32(d7.toInt() + h5.toInt() * r2);
    d7 = Int32(d7.toInt() + h6.toInt() * r1);
    d7 = Int32(d7.toInt() + h7.toInt() * r0);
    d7 = Int32(d7.toInt() + h8.toInt() * (5 * r9));
    d7 = Int32(d7.toInt() + h9.toInt() * (5 * r8));
    c = Int32(c.toInt() + (d7.shiftRightUnsigned(13)).toInt()); d7 &= 0x1fff;

    d8 = c;
    d8 = Int32(d8.toInt() + h0.toInt() * r8);
    d8 = Int32(d8.toInt() + h1.toInt() * r7);
    d8 = Int32(d8.toInt() + h2.toInt() * r6);
    d8 = Int32(d8.toInt() + h3.toInt() * r5);
    d8 = Int32(d8.toInt() + h4.toInt() * r4);
    c = (d8.shiftRightUnsigned(13)); d8 &= 0x1fff;
    d8 = Int32(d8.toInt() + h5.toInt() * r3);
    d8 = Int32(d8.toInt() + h6.toInt() * r2);
    d8 = Int32(d8.toInt() + h7.toInt() * r1);
    d8 = Int32(d8.toInt() + h8.toInt() * r0);
    d8 = Int32(d8.toInt() + h9.toInt() * (5 * r9));
    c = Int32(c.toInt() + (d8.shiftRightUnsigned(13)).toInt()); d8 &= 0x1fff;

    d9 = c;
    d9 = Int32(d9.toInt() + h0.toInt() * r9);
    d9 = Int32(d9.toInt() + h1.toInt() * r8);
    d9 = Int32(d9.toInt() + h2.toInt() * r7);
    d9 = Int32(d9.toInt() + h3.toInt() * r6);
    d9 = Int32(d9.toInt() + h4.toInt() * r5);
    c = (d9.shiftRightUnsigned(13)); d9 &= 0x1fff;
    d9 = Int32(d9.toInt() + h5.toInt() * r4);
    d9 = Int32(d9.toInt() + h6.toInt() * r3);
    d9 = Int32(d9.toInt() + h7.toInt() * r2);
    d9 = Int32(d9.toInt() + h8.toInt() * r1);
    d9 = Int32(d9.toInt() + h9.toInt() * r0);
    c = Int32(c.toInt() + (d9.shiftRightUnsigned(13)).toInt()); d9 &= 0x1fff;

    c = Int32(((c << 2).toInt() + c.toInt()) | 0);
    c = Int32((c.toInt() + d0.toInt()) | 0);
    d0 = c & 0x1fff;
    c = (c.shiftRightUnsigned(13));
    d1 = Int32(d1.toInt() + c.toInt());

    h0 = d0;
    h1 = d1;
    h2 = d2;
    h3 = d3;
    h4 = d4;
    h5 = d5;
    h6 = d6;
    h7 = d7;
    h8 = d8;
    h9 = d9;

    mpos += 16;
    bytes -= 16;
  }
  _h[0] = h0;
  _h[1] = h1;
  _h[2] = h2;
  _h[3] = h3;
  _h[4] = h4;
  _h[5] = h5;
  _h[6] = h6;
  _h[7] = h7;
  _h[8] = h8;
  _h[9] = h9;

  return this;
}