%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Copyright: 2010 Integrated Sytems Laboratory, ETH Zurich
%%            http://www.iis.ee.ethz.ch/~sha3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [x] = groestl_256(m,h,r)
% %Intialize

% %Using fixed-point toolbox

% %Define fimath object

% F=fimath;

% F.OverflowMode='wrap'; %Most realistic

% F.ProductWordLength=8;

% F.ProductMode='KeepLSB';

% F.SumWordLength=8;

% F.SumMode='KeepLSB';

% F.RoundMode='fix'; %Important for bitshift operations

% %Define numerictype object

% T=numerictype(0,8,0); %numerictype(sign, wordlength, fractionlength)

% 

% %Create fi matrixes of inputs

% m=fi(m,T,F);

% h=fi(h,T,F);


%Set matrixes p and q

p=bitxor(h,m);
q=m;

%Execute the Rounds

for i=1:r,
    p=addroundconstant(p,0,i-1);
    q=addroundconstant(q,1,i-1);
    
    p=subshiftbytes(p);
    q=subshiftbytes(q);
    
    p=mixbytes(p);
    q=mixbytes(q);
end
%x=P(h+m) +Q(m)+h

x=bitxor(p,q);
x=bitxor(x,h);
end

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