encryptBlock method

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

Implementation

void encryptBlock(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 = 0; i <= 16; i += 4) {
    x10 =
        rotateWordLeft(x10 + (x32 & ~x76) + (x54 & x76) + workingKey![i], 1);
    x32 = rotateWordLeft(
        x32 + (x54 & ~x10) + (x76 & x10) + workingKey![i + 1], 2);
    x54 = rotateWordLeft(
        x54 + (x76 & ~x32) + (x10 & x32) + workingKey![i + 2], 3);
    x76 = rotateWordLeft(
        x76 + (x10 & ~x54) + (x32 & x54) + workingKey![i + 3], 5);
  }

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

  for (var i = 20; i <= 40; i += 4) {
    x10 =
        rotateWordLeft(x10 + (x32 & ~x76) + (x54 & x76) + workingKey![i], 1);
    x32 = rotateWordLeft(
        x32 + (x54 & ~x10) + (x76 & x10) + workingKey![i + 1], 2);
    x54 = rotateWordLeft(
        x54 + (x76 & ~x32) + (x10 & x32) + workingKey![i + 2], 3);
    x76 = rotateWordLeft(
        x76 + (x10 & ~x54) + (x32 & x54) + workingKey![i + 3], 5);
  }

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

  for (var i = 44; i < 64; i += 4) {
    x10 =
        rotateWordLeft(x10 + (x32 & ~x76) + (x54 & x76) + workingKey![i], 1);
    x32 = rotateWordLeft(
        x32 + (x54 & ~x10) + (x76 & x10) + workingKey![i + 1], 2);
    x54 = rotateWordLeft(
        x54 + (x76 & ~x32) + (x10 & x32) + workingKey![i + 2], 3);
    x76 = rotateWordLeft(
        x76 + (x10 & ~x54) + (x32 & x54) + workingKey![i + 3], 5);
  }

  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;
}