processBlock method

void processBlock()

Implementation

void processBlock() {
  // TODO Calculation varied between web and native.
  if (currentBlockOffset < BLOCK_SIZE) {
    currentBlock[currentBlockOffset] = 1;
    for (var i = currentBlockOffset + 1; i < BLOCK_SIZE; i++) {
      currentBlock[i] = 0;
    }
  }

  final t0 = unpack32(currentBlock, 0, Endian.little);
  final t1 = unpack32(currentBlock, 4, Endian.little);
  final t2 = unpack32(currentBlock, 8, Endian.little);
  final t3 = unpack32(currentBlock, 12, Endian.little);

  h0 += t0 & 0x3ffffff;
  h1 += uRS((t1 << 32) | t0, 26) & 0x3ffffff;
  h2 += uRS((t2 << 32) | t1, 20) & 0x3ffffff;
  h3 += uRS((t3 << 32) | t2, 14) & 0x3ffffff;
  h4 += uRS(t3, 8);

  if (currentBlockOffset == BLOCK_SIZE) {
    h4 += shiftl32(1, 24);
  }

  var tp0 = h0 * r0 + h1 * s4 + h2 * s3 + h3 * s2 + h4 * s1;
  var tp1 = h0 * r1 + h1 * r0 + h2 * s4 + h3 * s3 + h4 * s2;
  var tp2 = h0 * r2 + h1 * r1 + h2 * r0 + h3 * s4 + h4 * s3;
  var tp3 = h0 * r3 + h1 * r2 + h2 * r1 + h3 * r0 + h4 * s4;
  var tp4 = h0 * r4 + h1 * r3 + h2 * r2 + h3 * r1 + h4 * r0;

  h0 = (tp0 & 0xffffffff) & 0x3ffffff;
  tp1 += uRS(tp0, 26);
  h1 = (tp1 & 0xffffffff) & 0x3ffffff;
  tp2 += uRS(tp1, 26);
  h2 = (tp2 & 0xffffffff) & 0x3ffffff;
  tp3 += uRS(tp2, 26);
  h3 = (tp3 & 0xffffffff) & 0x3ffffff;
  tp4 += uRS(tp3, 26);
  h4 = (tp4 & 0xffffffff) & 0x3ffffff;

  h0 += (uRS(tp4, 26) & 0xffffffff) * 5;
  h1 += cshiftr32(h0, 26);
  h0 &= 0x3ffffff;
}