Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Good Morning everyone, I'm presently working onTwofish and got stock in generating the Subkey S and Subkeys K. How to i perform matrix multiplication over Galois Field in binary?... Here is my code
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
load('key.mat');
%Divide key to four equal part of 32bit each
M0=key(1:32); M1=key(33:64); M2=key(65:96); M3=key(97:128);
%further divide the key to 16equal part of 8bit each
m0=M0(1:8); m1=M0(9:16); m2=M0(17:24); m3=M0(25:32); m4=M1(1:8); m5=M1(9:16); m6=M1(17:24); m7=M1(25:32); m8=M2(1:8); m9=M2(9:16); m10=M2(17:24); m11=M2(25:32); m12=M3(1:8); m13=M3(9:16); m14=M3(17:24); m15=M3(25:32);
%% martix multiplication using Reed Solomon
%RS Matrix
% RS=[01 A4 55 87 5A 58 DB 9E;
% A4 56 82 F3 1E C6 68 E5;
% 02 A1 FC C1 47 AE 3D 19;
% A4 55 87 5A 58 DB 9E 03];
A=dec2bin(01,8); A=logical(A(:)'-'0');
B=dec2bin(hex2dec('A4'),8); B=logical(B(:)'-'0');
C=dec2bin(55,8); C=logical(C(:)'-'0');
D=dec2bin(87,8); D=logical(D(:)'-'0');
E=dec2bin(hex2dec('5A'),8); E=logical(E(:)'-'0');
F=dec2bin(58,8); F=logical(F(:)'-'0');
G=dec2bin(hex2dec('DB'),8); G=logical(G(:)'-'0');
H=dec2bin(hex2dec('9E'),8); H=logical(H(:)'-'0');
I=dec2bin(56,8); I=logical(I(:)'-'0');
J=dec2bin(82,8); J=logical(J(:)'-'0');
K=dec2bin(hex2dec('F3'),8); K=logical(K(:)'-'0');
L=dec2bin(hex2dec('1E'),8); L=logical(L(:)'-'0');
M=dec2bin(hex2dec('C6'),8); M=logical(M(:)'-'0');
N=dec2bin(68,8); N=logical(N(:)'-'0');
O=dec2bin(hex2dec('E5'),8); O=logical(O(:)'-'0');
P=dec2bin(02,8); P=logical(P(:)'-'0');
Q=dec2bin(hex2dec('A1'),8); Q=logical(Q(:)'-'0');
R=dec2bin(hex2dec('FC'),8); R=logical(R(:)'-'0');
S=dec2bin(hex2dec('C1'),8); S=logical(S(:)'-'0');
T=dec2bin(47,8); T=logical(T(:)'-'0');
U=dec2bin(hex2dec('AE'),8); U=logical(U(:)'-'0');
V=dec2bin(hex2dec('3D'),8); V=logical(V(:)'-'0');
W=dec2bin(19,8); W=logical(W(:)'-'0');
X=dec2bin(03,8); X=logical(X(:)'-'0');
RS1=[A; B; P; B]; RS2=[B; I; Q; C]; RS3=[C; J; R; D];
RS4=[D; K; S; E]; RS5=[E; L; T; F]; RS6=[F; M; U; G];
RS7=[G; N; V; H]; RS8=[H; O; W; X];
RS=gf([RS1 RS2 RS3 RS4 RS5 RS6 RS7 RS8],1);
Me=gf([m0; m1; m2; m3; m4; m5; m6; m7],1);
S0=RS*Me;
here is the error display on the command window
Error using gf_mex
Sizes of x, y don't match
Error in * (line 31)
z=gf(gf_mex(x.x,y.x,x.m,'mtimes',x.prim_poly,GF_TABLE1,GF_TABLE2),x.m,...
Error in Sample_Key_Schedule (line 82)
S0=RS*Me
Thanks...anticipating your response soonest.
0 Commenti
Risposte (0)
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!