Main step of GOST 28147-89: Difference between revisions
m
missing r32() call
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: back-whack not needed) |
m (missing r32() call) |
||
Line 667:
sequence res = repeat(0,256)
for i=1 to length(res) do
ldx = and_bits(i-1,#F)+1
res[i] = or_bits(cbrf[k][hdx]*#10,cbrf[k-1][ldx])
end for
return res
end function
constant k87 = generate(8),
k65 = generate(6),
k43 = generate(4),
k21 = generate(2)
function r32(atom a)
if a<0 then a+=#100000000 end if
return remainder(a,#100000000)
end function
function mainstep(sequence input, atom key)
atom s = r32(input[1]+key)
s = r32(or_all({k87[and_bits(floor(s/#1000000),#FF)+1]*#1000000,
k65[and_bits(floor(s/#
k43[and_bits(floor(s/#
k21[and_bits(floor(s/#0000001),#FF)+1]*#0000001}))
s = r32(s*power(2,11))+floor(s/power(2,32-11))
s = xor_bits(s,input[2])
return {s,input[1]}
end function
printf(1,"%08x %08x\n",mainstep({#043B0421, #04320430}, #E2C104F9))</lang>
{{out}}
<pre>
</pre>
|