%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Copyright: 2010 Integrated Sytems Laboratory, ETH Zurich
%%            http://www.iis.ee.ethz.ch/~sha3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [cns, c] = genconstant(c)
cns=zeros(1,2,'uint32');
if bitshift(c(1), -31)
    c(1)=bitxor(bitxor(bitshift(c(1), 1), bitshift(c(2), -31)), hex2dec('c4d6496c'));
    c(2)=bitxor(bitshift(c(2), 1), hex2dec('55c61c8d'));
else
    c(1)=bitxor(bitshift(c(1),1), bitshift(c(2), -31));
    c(2)=bitshift(c(2), 1);
end

cns(1)=c(1);
c(1)=c(2);
c(2)=cns(1);

if bitshift(c(1), -31)
    c(1)=bitxor(bitxor(bitshift(c(1), 1), bitshift(c(2), -31)), hex2dec('c4d6496c'));
    c(2)=bitxor(bitshift(c(2), 1), hex2dec('55c61c8d'));
else
    c(1)=bitxor(bitshift(c(1),1), bitshift(c(2), -31));
    c(2)=bitshift(c(2), 1);
end

cns(2)=c(1);
c(1)=c(2);
c(2)=cns(2);

end

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