I am passing a secret key (length of 16 ASCII chars = 128 bits) through Reed Solomon encoder which is operating over Galois field 16 (2^16).
My question is: should this key be considered as 128 bits or 256?
I got lost here because I know that ASCII character = 8 bits so 16 ASCII character = 128 bits.
I read an article where it says once you passed the key through GF(16) then it will be 256, not 128 and I should pass only a key with 8 ASCII character instead. is this correct? please see the function that I am using below where i used Matlab communication toolbox function code = errorCorrectingCode(data, LENGTH) % ERRORCORRECTINGCODE takes input data and runs it through Reed-Solomon Code % See the following link: % http://www.mathworks.com/help/comm/ref/encode.html % >>> example: rsdec(rsenc(gf([1 2 3 ; 4 5 6],3),7,3),7,3);
% Apply Reed-Solomon encoding operation to data to obtain ECCed code.
% convert to GF(2^16) elements:
% (two characters map to one element, so 16char = 8)
elements = keyToField(data);
msg = elements';
% create encoding:
code = rsenc(msg,LENGTH,length(msg));
end
function gfArray = keyToField(keystr)
% KEYTOFIELD takes a key string composed of N characters,
% converting every two characters to a field array in the
% field GF(2^16).
% define number of elements in gfArray as floor(N / 2):
numElts = floor(length(keystr) / 2);
% define flag that checks if keystr is odd or not:
oddLength = mod(length(keystr),2);
% initialize pre-output:
gfArray_bin = zeros((numElts + oddLength),16);
% loop thru pairs of chars in the key:
for idx=1:numElts
curr = 2 * idx;
gfArray_bin(idx,:) = [dec2bin(double(keystr(curr - 1)),8) dec2bin(double(keystr(curr)),8)] - 48;
end
% take care of last element if odd:
if (oddLength)
gfArray_bin(end,:) = dec2bin(double(keystr(end)),16) - 48;
end
% convert everything to decimal again:
gfArray_dec = zeros(size(gfArray_bin,1),1);
for jdx=1:size(gfArray_bin,1)
% shorthand for current row:
bitrow = gfArray_bin(jdx,:);
% convert from a row of 1's and 0's to decimal representation:
gfArray_dec(jdx) = sum(bitrow .* 2.^(numel(bitrow)-1:-1:0));
end
% generate output by wrapping gfArray_dec in field array:
gfArray = gf(gfArray_dec,16);
end