padBlock method
void
padBlock(})
override
Implementation
void padBlock(int blockSize, Iterable<int> block, ByteData output,
{List<int>? labelHash, /* String | List<int> */ label}) {
if (labelHash == null) {
if (label == null) label = <int>[];
labelHash = hasher.convert(label).bytes;
}
final ps = List<int>.generate(
blockSize - block.length - (2 * labelHash.length) - 2, (_) => 0);
final db = <int>[...labelHash, ...ps, 0x01, ...block];
final seed =
List<int>.generate(labelHash.length, (_) => random.nextInt(255));
final dbMask = mgf.encode(blockSize - labelHash.length - 1, seed);
final maskedDb = List<int>.generate(
blockSize - labelHash.length - 1, (i) => db[i] ^ dbMask[i]);
final seedMask = mgf.encode(labelHash.length, maskedDb);
final maskedSeed =
List<int>.generate(labelHash.length, (i) => seed[i] ^ seedMask[i]);
int index = 0;
output.setUint8(index++, 0);
for (int i = 0; i < maskedSeed.length; i++) {
output.setUint8(index++, maskedSeed[i]);
}
for (int i = 0; i < maskedDb.length; i++) {
output.setUint8(index++, maskedDb[i]);
}
}