MATLAB Answers

How can i implement galois counter mode (GCM) in matlab?

9 views (last 30 days)
Darsana P M
Darsana P M on 18 Sep 2017
Commented: Zeeshan Abbas on 19 Jun 2019
The image above shows an algorithm to find the multiplication of 2 blocks using galois field.I tried implementing it,but got an error.Can somebody help me??
clc;
clear all;
close all;
x=01101101;
Z=00000000;
v=11001011;
for i=0:1:8
if x(i)== 0
Z(i+1)= Zi;
else xi == 1
Z(i+1)= xor(Zi,Vi);
end
end
The error was: Subscript indices must either be real positive integers or logicals.
Error in algo1 (line 8) if x(i)== 0

Accepted Answer

Ahmed Grera
Ahmed Grera on 18 Sep 2017
Edited: Ahmed Grera on 18 Sep 2017
Hi Darsana P M
You can retype it like this:
clc;
clear all;
close all;
x=[0 1 1 0 1 1 0 1];
Z=[0 0 0 0 0 0 0 0];
v=[1 1 0 0 1 0 1 1];
for i=1:1:8 %-----or use i=1:8------
if x(i)== 0
Z(i+1)= Z(i);
else x(i) == 1;
Z(i+1)= xor(Z(i),v(i));
end
end
Z
Greetings Eng. Ahmed G
Good luck
  4 Comments
Zeeshan Abbas
Zeeshan Abbas on 19 Jun 2019
Is it showing (nonce+counter) XOR (key)??
let say: x=nonce
v=key
z = output?
Am i right?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!