G method
Функция перемешивания G из спецификации BLAKE2b.
Выполняет одну операцию перемешивания над четырьмя ячейками внутреннего состояния. Является основным криптографическим примитивом алгоритма.
m1
, m2
- Входные слова сообщения.
posA
, posB
, posC
, posD
- Позиции ячеек в векторе состояния.
Implementation
void G(Register64 m1, Register64 m2, int posA, int posB, int posC, int posD) {
// This variable is faster as a local. The allocation is probably sunk.
final r = Register64();
_internalState[posA].sumReg(r
..set(_internalState[posB])
..sumReg(m1));
_internalState[posD]
..xor(_internalState[posA])
..rotr(32);
_internalState[posC].sumReg(_internalState[posD]);
_internalState[posB]
..xor(_internalState[posC])
..rotr(24);
_internalState[posA].sumReg(r
..set(_internalState[posB])
..sumReg(m2));
_internalState[posD]
..xor(_internalState[posA])
..rotr(16);
_internalState[posC].sumReg(_internalState[posD]);
_internalState[posB]
..xor(_internalState[posC])
..rotr(63);
}