```%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Copyright: 2010 Integrated Sytems Laboratory, ETH Zurich
%%            http://www.iis.ee.ethz.ch/~sha3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function state = mi(state, statewidth, data)
t=zeros(1,8*statewidth);
for i=1:8
for j=0:statewidth-1
t(i)=bitxor(t(i), state(i+8*j));
end
end

t=mult2(t);

for j=0:statewidth-1
for i=1:8
state(i+8*j)=bitxor(state(i+8*j), t(i));
end
end

if statewidth >= 5
for j=0:statewidth-1
for i=1:8
t(i+8*j)=state(i+8*j);
end
state(8*j+1:8*(j+1))=mult2(state(8*j+1:8*(j+1)));
end

for j=0:statewidth-1
for i=1:8
state(8*j+i)=bitxor(state(8*j+i), t(8*mod(j+1, statewidth)+i));
end
end
end

if statewidth >= 4
for j=0:statewidth-1
for i=1:8
t(i+8*j)=state(i+8*j);
end
state(8*j+1:8*(j+1))=mult2(state(8*j+1:8*(j+1)));
end

for j=0:statewidth-1
for i=1:8
state(8*j+i)=bitxor(state(8*j+i), t(8*mod(j-1+statewidth, statewidth)+i));
end
end
end

for j=0:statewidth-1
for i=1:8
state(i+8*j)=bitxor(state(i+8*j), data(i));
end
data=mult2(data);
end
end
```

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