Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::pair<std::uint32_t, std::uint32_t> gost::oneStepCrypto(std::pair<std::uint32_t, std::uint32_t> buf, size_t &round)
- {
- std::uint32_t lower, high; //Блок входных данных, разбитых на две половины
- unsigned char* byteBuffer;//Указатель для побайтовой работы с таблицей
- lower = buf.first;
- high = buf.second;
- if (this->mode == SIMPLECRYPT) //Режим шифрования
- lower = (lower + (round < 24 ? key[round % 8] : key[31 - round])) % 4294967296;
- else if (this->mode == SIMPLEENCRYPT)//Режим дешифровки
- lower = (lower + (round < 8? key[round] : key[7 - (round - 8) % 8])) % 4294967296;
- byteBuffer = reinterpret_cast<unsigned char*>(&lower);
- for (size_t i = 0; i < 4; i++)
- byteBuffer[i] = (((table[2 * i][byteBuffer[i] >> 4]) << 4) | (table[2 * i + 1][byteBuffer[i] & 0x0F]));
- lower = rol(lower,11);
- lower = high ^ lower;
- round++;
- return (round != 31 ? std::make_pair(lower, buf.first): std::make_pair(buf.first, lower));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement