decryptCbcNoPadding method

Uint8List decryptCbcNoPadding(
  1. Uint8List data,
  2. Uint8List iv
)

Implementation

Uint8List decryptCbcNoPadding(Uint8List data, Uint8List iv) {
  final int blocks = data.length ~/ 16;
  final Uint8List out = Uint8List(blocks * 16);
  final Uint8List previous = Uint8List.fromList(iv);
  for (int block = 0; block < blocks; block++) {
    final Uint8List cipher = Uint8List.sublistView(data, block * 16, block * 16 + 16);
    final Uint8List state = Uint8List.fromList(cipher);
    _decryptBlock(state);
    for (int i = 0; i < 16; i++) {
      out[block * 16 + i] = state[i] ^ previous[i];
    }
    previous.setAll(0, cipher);
  }
  return out;
}