iop=cat(4,CIPH,TAGG'); I got this error:
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in encryyyy (line 239)
iop=cat(4,CIPH,TAGG');
I would like to combine: CIPH and TAG
whos TAG
Name Size Bytes Class Attributes
TAG 16x2 64 char
>> whos CIPH
Name Size Bytes Class Attributes
CIPH 4-D 7296 cell
How to solve this?
I am working on cryptography, AES-GCM algorithm. As output, I get cipher text and tag. I want to combine them at output. I found this operation 'cat to combine texts. What is the other alternative to do this?

1 comentario

Rik
Rik el 25 de Mzo. de 2018
What you want is not possible. How should Matlab concatenate two variables of totally different dimensions and even different file types?
The question is why you want to do this. Maybe we can help you solve that problem.

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 25 de Mzo. de 2018

0 votos

Depends on what you want. You could assign it to a field in a structure. You could write them to a character array. You could put them into cells of a cell array. You could write the variables to a .mat file, etc.

10 comentarios

Darsana P M
Darsana P M el 25 de Mzo. de 2018
I would like to combine them: Suppose CIPH={'10' '11' '00'} and TAG={'1D' '10'} and I want to combine them, like, J={'10' '11' '00' '1D' '10'}. I used cat operation,but got an error? How to solve this?
Image Analyst
Image Analyst el 25 de Mzo. de 2018
Editada: Image Analyst el 25 de Mzo. de 2018
CIPH = {'10' '11' '00'}
TAG = {'1D' '10'}
J = [CIPH, TAG]
OR
J = cat(2, CIPH, TAG)
Darsana P M
Darsana P M el 25 de Mzo. de 2018
I tried this step,I have two inputs CIPH and TAG CIPH
CIPH(:,:,1,1) =
Columns 1 through 9
'6' 'D' 'B' '9' '0' '3' '3' '6' 'F'
Columns 10 through 16
'A' 'C' 'B' '5' '0' '3' '4'
CIPH(:,:,1,2) =
Columns 1 through 9
'1' '0' 'E' '6' '0' 'D' 'E' '9' '4'
Columns 10 through 16
'D' '7' 'D' 'F' '3' 'A' '7'
CIPH(:,:,1,3) =
Columns 1 through 9
'6' 'A' '1' 'E' '6' '6' '6' '7' 'F'
Columns 10 through 16
'E' 'A' '8' '5' '6' '6' 'D'
CIPH(:,:,1,4) =
Columns 1 through 9
'0' 'A' '4' '4' '8' '6' '3' 'E' '4'
Columns 10 through 16
'3' '1' 'E' 'E' '7' '8' 'C'
TAG: TAGG
TAGG =
'B' '3'
'3' '9'
'2' '9'
'7' 'B'
'7' '6'
'3' '6'
'6' '1'
'A' 'F'
'9' 'C'
'8' 'D'
'3' 'B'
'3' '4'
'B' 'E'
'9' '2'
'5' 'C'
'2' 'E'
I tried cat(2,CIPH,TAGG); but got an error:
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Image Analyst
Image Analyst el 25 de Mzo. de 2018
That's not what you told me. Now you have CIPH as a 4-D array, but TAGG as a 2-D, N by 2 array. How exactly do you want to combine the 4-D array with a 2-D array? Give me code to create some sample CIPH and TAGG so we can create the solution for you.
Darsana P M
Darsana P M el 25 de Mzo. de 2018
I am actually working on AES-GCM a cryptographic algorithm. So when I give inputs: plaintext, key; I get outputs: ciphertext and tag.
Thus for decryption, I need to send them together.
Image Analyst
Image Analyst el 25 de Mzo. de 2018
Try a structure
str.ciphertext = ciphertext;
str.tag= tag;
Now both variables are together in the same structure variable.
Darsana P M
Darsana P M el 25 de Mzo. de 2018
oh is it. Can you help me out with a code.How to call the structure? i do not know the working of structures.
Image Analyst
Image Analyst el 25 de Mzo. de 2018
To get the fields back out in some other code, basically reverse the assignment.
% Load ciphertext into "ct1" and the tag into "t1":
ct1 = str.ciphertext;
t1 = str.tag;
Darsana P M
Darsana P M el 25 de Mzo. de 2018
Can I now combine them after making then as structures??
Image Analyst
Image Analyst el 26 de Mzo. de 2018
I'm not sure how you want to combine then. You can combine different structures, but you can't combine two totally different things. Let's say the 4-D things is a video, in other words a series of multiple 3-D images. They are 3-D because they are color, and 4D because at each point in time we have a new/different RGB image. Now let's say you have a gray scale 2-D image and you want to "combine it". Well how? Do you want to add it as a frame to the end of the video? You can't, unless you turn it into a 3-D array, like an RGB image. If you do THAT you can do it, but otherwise you can't. It's basically the same for your situation. You can't combine a 2-D array with a 4-D array directly. You need to do something to allow the concatenation/combination, but you have not said HOW. You can't just do it without saying how to do it.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Encryption / Cryptography en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 25 de Mzo. de 2018

Comentada:

el 26 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by