%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Copyright: 2010 Integrated Sytems Laboratory, ETH Zurich
%%            http://www.iis.ee.ethz.ch/~sha3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [o] = addroundconstant(in, mode, round)
%AddRoundConstant transformation

% %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)
% 
% con=fi(zeros(8,8),T,F);

con=zeros(8,8);

%Use mode 0 for P permutations
if mode==0
    con_p=con;
    con_p(1,1)=round;
    o=bitxor(in,con_p);
%Use mode 1 for Q permutations
else
    con_q=con;
    con_q(8,1)=bitxor(round,hex2dec('ff'));
    o=bitxor(in,con_q);
end
end

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