permutation method

  1. @visibleForTesting
void permutation(
  1. Uint32List data,
  2. int i0,
  3. int i1,
  4. int i2,
  5. int i3,
  6. int i4,
  7. int i5,
  8. int i6,
  9. int i7,
)

RFC 9106 function P(v0,...,v7).

In the RFC, arguments are 128-bit values. In our implementation, they are Uint32List indices.

Implementation

@visibleForTesting
void permutation(
  Uint32List data,
  int i0,
  int i1,
  int i2,
  int i3,
  int i4,
  int i5,
  int i6,
  int i7,
) {
  // The 8 x 128-bit arguments are broken down to two 4x4 matrix of 64-bit
  // integers.
  final x0 = i0 + 0;
  final x1 = i0 + 2;
  final x2 = i1 + 0;
  final x3 = i1 + 2;
  final x4 = i2 + 0;
  final x5 = i2 + 2;
  final x6 = i3 + 0;
  final x7 = i3 + 2;
  final x8 = i4 + 0;
  final x9 = i4 + 2;
  final x10 = i5 + 0;
  final x11 = i5 + 2;
  final x12 = i6 + 0;
  final x13 = i6 + 2;
  final x14 = i7 + 0;
  final x15 = i7 + 2;

  gb(data, x0, x4, x8, x12);
  gb(data, x1, x5, x9, x13);
  gb(data, x2, x6, x10, x14);
  gb(data, x3, x7, x11, x15);

  gb(data, x0, x5, x10, x15);
  gb(data, x1, x6, x11, x12);
  gb(data, x2, x7, x8, x13);
  gb(data, x3, x4, x9, x14);
}