```%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Copyright: 2010 Integrated Sytems Laboratory, ETH Zurich
%%            http://www.iis.ee.ethz.ch/~sha3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [o] = mixbytes(in)
%Mixbytes multplies input matrix in with constant circular matrix B
%over the finite F256 Rijndael Gallois Field
%Define fimath object
% F=fimath;
% F.OverflowMode='wrap';
% F.ProductWordLength=8;
% F.ProductMode='KeepLSB';
% F.SumWordLength=8;
% F.SumMode='KeepLSB';
% F.RoundMode='fix';
% %Define numerictype object
% T=numerictype(0,8,0);

B=[2,2,3,4,5,3,5,7];
B=[B;circshift(B,[0,1]);circshift(B,[0,2]);circshift(B,[0,3]);circshift(B,[0,4]);circshift(B,[0,5]);circshift(B,[0,6]);circshift(B,[0,7])];
% B=fi(B,T,F);
% o=fi(zeros(8,8),T,F);

o=zeros(8,8);

for i=1:8
for j=1:8
for k=1:8
a=B(i,k);
b=in(k,j);
%             p=fi(0,T,F);
p=0;
for l=1:8
if(bitget(b,1)==1)
p=bitxor(p,a);
end
hibit=bitget(a,8);
a=bitshift(a,1);
if(hibit==1)
%                     a=bitxor(a,fi(27,T,F));
a=bitxor(a,27);
end
b=bitshift(b,-1);
end
o(i,j)=bitxor(o(i,j),p);
end
end
end
end
```

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