%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Copyright: 2010 Integrated Sytems Laboratory, ETH Zurich
%%            http://www.iis.ee.ethz.ch/~sha3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function S = SIMD_compress(IV,M,f)

W = MessageExpansion(M, f);

for i = 1:4,
    S(1,i) = bitxor(IV(1,i), M((i-1)*16+ 4)*2^24 + M((i-1)*16+ 3)*2^16 + M((i-1)*16+ 2)*2^8 + M((i-1)*16+ 1)*2^0);
    S(2,i) = bitxor(IV(2,i), M((i-1)*16+ 8)*2^24 + M((i-1)*16+ 7)*2^16 + M((i-1)*16+ 6)*2^8 + M((i-1)*16+ 5)*2^0);
    S(3,i) = bitxor(IV(3,i), M((i-1)*16+12)*2^24 + M((i-1)*16+11)*2^16 + M((i-1)*16+10)*2^8 + M((i-1)*16+ 9)*2^0);
    S(4,i) = bitxor(IV(4,i), M((i-1)*16+16)*2^24 + M((i-1)*16+15)*2^16 + M((i-1)*16+14)*2^8 + M((i-1)*16+13)*2^0);
end

S = Round(S, 0, [ 3, 23, 17, 27], W);
S = Round(S, 1, [28, 19, 22, 7], W);
S = Round(S, 2, [29, 9, 15, 5], W);
S = Round(S, 3, [ 4, 13, 10, 25], W);

S = Step(S, IV(:,1), 'IF', 4, 13, 32);
S = Step(S, IV(:,2), 'IF', 13, 10, 33);
S = Step(S, IV(:,3), 'IF', 10, 25, 34);
S = Step(S, IV(:,4), 'IF', 25, 4, 35);


Generated on Fri Sep 24 10:39:12 CEST 2010
Home