sbox property

Uint8List get sbox

Implementation

static Uint8List get sbox {
  final Uint8List? cached = _sbox;
  if (cached != null) return cached;
  final Uint8List table = Uint8List(256);
  final Uint8List inverse = Uint8List(256);
  int p = 1;
  int q = 1;
  do {
    p = (p ^ ((p << 1) & 0xFF) ^ ((p & 0x80) != 0 ? 0x1B : 0)) & 0xFF;
    q ^= (q << 1) & 0xFF;
    q ^= (q << 2) & 0xFF;
    q ^= (q << 4) & 0xFF;
    if ((q & 0x80) != 0) q ^= 0x09;
    q &= 0xFF;
    final int value = (q ^ _rotl8(q, 1) ^ _rotl8(q, 2) ^ _rotl8(q, 3) ^ _rotl8(q, 4) ^ 0x63) & 0xFF;
    table[p] = value;
    inverse[value] = p;
  } while (p != 1);
  table[0] = 0x63;
  inverse[0x63] = 0;
  _sbox = table;
  _inverse = inverse;
  return table;
}