decryptBlock method

void decryptBlock(
  1. Uint8List input,
  2. int inOff,
  3. Uint8List out,
  4. int outOff,
)

Implementation

void decryptBlock(Uint8List input, int inOff, Uint8List out, int outOff) {
  int x76, x54, x32, x10;

  x76 = ((input[inOff + 7] & 0xff) << 8) + (input[inOff + 6] & 0xff);
  x54 = ((input[inOff + 5] & 0xff) << 8) + (input[inOff + 4] & 0xff);
  x32 = ((input[inOff + 3] & 0xff) << 8) + (input[inOff + 2] & 0xff);
  x10 = ((input[inOff + 1] & 0xff) << 8) + (input[inOff + 0] & 0xff);

  for (var i = 60; i >= 44; i -= 4) {
    x76 = rotateWordLeft(x76, 11) -
        ((x10 & ~x54) + (x32 & x54) + workingKey![i + 3]);
    x54 = rotateWordLeft(x54, 13) -
        ((x76 & ~x32) + (x10 & x32) + workingKey![i + 2]);
    x32 = rotateWordLeft(x32, 14) -
        ((x54 & ~x10) + (x76 & x10) + workingKey![i + 1]);
    x10 = rotateWordLeft(x10, 15) -
        ((x32 & ~x76) + (x54 & x76) + workingKey![i]);
  }

  x76 -= workingKey![x54 & 63];
  x54 -= workingKey![x32 & 63];
  x32 -= workingKey![x10 & 63];
  x10 -= workingKey![x76 & 63];

  for (var i = 40; i >= 20; i -= 4) {
    x76 = rotateWordLeft(x76, 11) -
        ((x10 & ~x54) + (x32 & x54) + workingKey![i + 3]);
    x54 = rotateWordLeft(x54, 13) -
        ((x76 & ~x32) + (x10 & x32) + workingKey![i + 2]);
    x32 = rotateWordLeft(x32, 14) -
        ((x54 & ~x10) + (x76 & x10) + workingKey![i + 1]);
    x10 = rotateWordLeft(x10, 15) -
        ((x32 & ~x76) + (x54 & x76) + workingKey![i]);
  }

  x76 -= workingKey![x54 & 63];
  x54 -= workingKey![x32 & 63];
  x32 -= workingKey![x10 & 63];
  x10 -= workingKey![x76 & 63];

  for (var i = 16; i >= 0; i -= 4) {
    x76 = rotateWordLeft(x76, 11) -
        ((x10 & ~x54) + (x32 & x54) + workingKey![i + 3]);
    x54 = rotateWordLeft(x54, 13) -
        ((x76 & ~x32) + (x10 & x32) + workingKey![i + 2]);
    x32 = rotateWordLeft(x32, 14) -
        ((x54 & ~x10) + (x76 & x10) + workingKey![i + 1]);
    x10 = rotateWordLeft(x10, 15) -
        ((x32 & ~x76) + (x54 & x76) + workingKey![i]);
  }

  out[outOff + 0] = x10;
  out[outOff + 1] = x10 >> 8;
  out[outOff + 2] = x32;
  out[outOff + 3] = x32 >> 8;
  out[outOff + 4] = x54;
  out[outOff + 5] = x54 >> 8;
  out[outOff + 6] = x76;
  out[outOff + 7] = x76 >> 8;
}