%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Copyright: 2010 Integrated Sytems Laboratory, ETH Zurich
%%            http://www.iis.ee.ethz.ch/~sha3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [s2] = AddEl(j)

    global qnt32 Mb Hb;

    a = bin2num(qnt32,sprintf('%-1d', circshift(Mb(mod(j,16)+1,:),[0 -(mod(j,16)+1)])));
    b = bin2num(qnt32,sprintf('%-1d', circshift(Mb(mod(j+3,16)+1,:),[0 -(mod(j+3,16)+1)])));
    c = bin2num(qnt32,sprintf('%-1d', circshift(Mb(mod(j+10,16)+1,:),[0 -(mod(j+10,16)+1)])));      % WARNING: those mods are OK (see Reference Implementation)
    d = hex2dec('05555555') * (j+16);
    
    s = num2bin(qnt32, mod(a+b-c+d, 2^32));
    s = str2num(s(:));
    
    s2 = bin2num(qnt32,sprintf('%-1d', xor(s',Hb(mod(j+7,16)+1,:))));



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