1 function [RK,Sbox,Pbox]=Dynamickeygenerationnew(Secretkey,counter,strh,h)
\r
2 x=java.security.MessageDigest.getInstance(strh);
\r
3 x.update(bitxor(Secretkey,counter));
\r
4 DK=double(typecast(x.digest,'uint8'));
\r
6 %%%%%%%%%%%% Creation of P-box (blocks permutation)%%%%%%%%%%%%%%%%%%%%%%%%
\r
7 % construction of P-box
\r
9 %Pbox=PermutationCat(Keyp,M);
\r
13 Keyp=reshape((DK(1:1:16)),1,[]);
\r
14 Keyp=mod(Keyp,Qp)+1;
\r
16 Pbox=supboxvector2(Ap,Qp,Keyp)
\r
20 % construction of S-box
\r
23 KS=reshape(DK(17:32),1,[]);
\r
24 Sbox=supboxvector2(A,Q,KS)-1;
\r
26 %%%%%%%%%%%%%%%% Construction of round keys%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
28 X=reshape(DK(33:48),1,[]);
\r
29 X=double(typecast(uint8(X),'uint32'))
\r
30 P=reshape(DK(49:end),1,[]);
\r
31 P=double(typecast(uint8(P),'uint32'))
\r
34 RK= roundKeyiterations(X,P,N,r,Sbox,m);
\r
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
38 % %%%%%%%%%%%%% creation of IV (block of h bits) can be employ for CBC, CFB, OFB, CTR mode %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
39 % s_rk=rc4key(DK(17:1:32));
\r
40 % IV=reshape(prga( s_rk,h^2),h,h);
\r
41 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
42 % %%%%%%%%%%%%%%%%%%%%creation of the diffusion matrix%%%%%%%%%%%%%%%%%%%%%%%
\r
43 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\r
44 % sc2=rc4key(DK(end-16:end));
\r
45 % outd=prga( sc2,(h^2)/4);
\r
46 % A=reshape(outd,h/2,h/2);
\r
49 % G=[A A+In; A-In A ];
\r
52 % G=[A bitxor(A,In) ; bitxor(A,In) A];
\r