Anonymous user
Main step of GOST 28147-89: Difference between revisions
Updated D entry
(Updated D entry) |
(Updated D entry) |
||
Line 124:
{{trans|C}}
{{trans|Go}}
<lang d>
uint rol(in uint x, in uint nBits) @safe pure nothrow {▼
/// Rotate uint left.
▲uint rol(in uint x, in uint nBits) @safe pure nothrow @nogc {
return (x << nBits) | (x >> (32 - nBits));
}
Line 132 ⟶ 134:
alias SBox = immutable Nibble[16][8];
private bool _validateSBox(in SBox data) @safe pure nothrow @nogc {
foreach (const ref row; data)
foreach (ub; row)
if (ub >= 16) // Verify it's a nibble.
Line 142 ⟶ 144:
struct GOST(s...) if (s.length == 1 && s[0]._validateSBox) {
private static generate(ubyte k)() @safe pure nothrow {
}
Line 158 ⟶ 156:
// Endianess problems?
private static uint f(in uint x) pure nothrow @nogc @safe {
immutable uint y = (k87[(x >> 24) & 0xFF] << 24) |
(k65[(x >> 16) & 0xFF] << 16) |
Line 167 ⟶ 165:
// This performs only a step of the encoding.
public void mainStep(in uint[2] input, in uint key)
pure nothrow @nogc @safe {
buffer[0] = f(key + input[0]) ^ input[1];
buffer[1] = input[0];
Line 174 ⟶ 173:
void main() {
// S-boxes used by the Central Bank of Russian Federation:
// http://en.wikipedia.org/wiki/GOST_28147-89
|