Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
how to modify AES code?
조회 수: 3 (최근 30일)
이전 댓글 표시
hello,
I need help regarding the following code:
function Out = Cipher(key, In)
%AES-128,192,256 cipher
%Impliments FIBS-197, key is a 128, 292, or 256-bit hexidecimal input,
%message (In) is 128-bit hexidecimal. Application does not check lengths of
%keys or message input but will error if they are not of the correct
%length.
%David Hill
%Version 1.0.4
%1-25-2021
Nk=length(key)/8;
In=hex2dec(reshape(In,2,[])');%converts hex bytes into decimal
w=KeyExpansion(key,Nk);%key expansion per standard
state=reshape(In,4,[]);%reshapes input into state matrix
state=AddRoundKey(state,w(:,1:4));%conducts first round
for k=2:(Nk+6)%conducts follow-on rounds
state=SubBytes(state);%per standard
state=ShiftRows(state);%per standard
state=MixColumns(state);%per standard
state=AddRoundKey(state,w(:,4*(k-1)+1:4*k));%per standard
end
state=SubBytes(state);
state=ShiftRows(state);
state=AddRoundKey(state,w(:,4*(Nk+6)+1:4*(Nk+7)));
Out=state(:);%changes output to column vector
Out=lower(dec2hex(Out(1:length(In)))');%converts output to hex
Out=Out(:)';%converts output to row vector
end
The question is: Modify the AES routines you have managed to get working, within functions that you can call at a later date. Comment appropriately so you will remember their functionality.
댓글 수: 1
Rik
2023년 1월 27일
You can find guidelines for posting homework on this forum here. If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks). If your main issue is with understanding the underlying concept, you may consider re-reading the material you teacher provided and ask them for further clarification.
Also, due to a legal quirk, discussion of any non-trivial cryptography is not allowed. While a Ceasar cypher should be ok, AES is definately not.
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!