0% found this document useful (0 votes)
67 views2 pages

Decrypting AES with MATLAB Lab 6

This document provides instructions for a lab session where students will use MATLAB to decrypt a ciphertext message encrypted with a symmetric block cipher algorithm. The ciphertext was encrypted using cipher block chaining. Students are given the ciphertext blocks and told the key is less than 64. They must determine the key, then decrypt each subsequent block by XORing it with the previous ciphertext block before decryption. No report is required - students must show their decrypted plaintext and code to the lab supervisor.

Uploaded by

Zahin Rahman
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views2 pages

Decrypting AES with MATLAB Lab 6

This document provides instructions for a lab session where students will use MATLAB to decrypt a ciphertext message encrypted with a symmetric block cipher algorithm. The ciphertext was encrypted using cipher block chaining. Students are given the ciphertext blocks and told the key is less than 64. They must determine the key, then decrypt each subsequent block by XORing it with the previous ciphertext block before decryption. No report is required - students must show their decrypted plaintext and code to the lab supervisor.

Uploaded by

Zahin Rahman
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Laboratory Session 6

1. Introduction
In this lab you will use MATLAB to break a symmetric key, block algorithm that uses some
of the transforms used in AES. The encryption algorithm was used with cipher block
chaining. The purpose of the lab is for you to determine the plaintext from a given ciphertext
message encrypted with an unknown, but short key.
MATLAB can be found by:
Start >MATLAB
You may wish to refer to the previous lab to revise MATLAB.

2. Method
You are to decrypt the following message c which you know was encrypted with the code in
encrypt.m and using cipher block chaining where each block of cipher text is XOR ed
with the previous block of cipher text. The routine decrypt.m is available to carry out
decryption. The routine encrypt.m is included for interested students to examine, but is
not required for the lab.

1. Install the routine decrypt.m in the work directory. This can be done by dragging
the file from the desktop directly into the left-hand panel as shown below:

2. Determine the key that was used to encrypt the message. The key is greater than 0
and less than 64.
This can be done by trying different key values on the first block of cipher text ct1.
3. Once the key is determined, decrypt the remaining blocks. Cipher block chaining
was used to encrypt blocks 2 to 7. This means that each block of cipher text was
XOR ed with the previous block of cipher text after the plain text was encrypted. For
example ct2 = encrypted plain text XOR ct1.
4. Ct1 is XORed with an initialisation vector. The initialisation vector in this case is all
0s.
Laboratory Session 6

5. To recover blocks 2 to 7 it is necessary to XOR them with the previous cipher text
block before applying the decryption routine. The MATLAB routine bitxor will
be useful.

3. Cipher text
The cipher text is available in the file [Link] but can also be copied from here.
ct1 = [ 29 21 51 23 35 17 34 51 57 51 34 44 21 21 51 39]
ct2 = [ 12 38 20 63 16 50 4 23 30 23 54 5 55 2 38 54]
ct3 = [ 63 55 60 42 35 35 16 29 58 36 32 32 34 49 49 13]
ct4 = [ 46 21 15 13 3 54 5 46 24 0 12 53 17 21 25 52]
ct5 = [ 59 51 26 62 39 18 45 63 13 21 63 23 54 38 61 32]
ct6 = [ 24 0 12 43 5 33 57 28 62 41 42 37 26 55 31 43]
ct7 = [ 43 30 41 13 56 8 27 55 13 26 25 22 41 4 44 24]

4. Assessment
No report is required for this lab. Show the lab supervisor the plain text and your code
and explain how it works.

Common questions

Powered by AI

Decrypting a ciphertext with an unknown short key presents challenges such as determining the correct key within potentially many possibilities and ensuring correct implementation of decryption logic, especially when dealing with cipher block chaining. In this lab, challenges are mitigated by narrowing the key search to a defined range of values (between 1 and 63), which makes a brute force approach feasible. Additionally, the provided 'decrypt.m' routine facilitates correct implementation of decryption operations, while guidance on using functions like 'bitxor' ensures that cipher block chaining is properly managed during decryption .

Cipher block chaining (CBC) is a method of encrypting data where each block of plaintext is XORed with the previous ciphertext block before being encrypted. This makes each ciphertext block dependent on all previous plaintext blocks, increasing security by ensuring that identical plaintext blocks produce different ciphertext. In decryption, the same process must be reversed. Each ciphertext block must be XORed with the preceding ciphertext block (or an initialization vector for the first block) after decryption to retrieve the plaintext. This dependency on previous blocks makes the decryption more complex and necessitates this specific step .

Cipher block chaining (CBC) offers advantages in terms of data integrity and security by ensuring that identical plaintext blocks encrypt to different ciphertext blocks, thereby preventing certain types of attack patterns, such as simple block replay attacks. CBC ensures that any change to a single plaintext block affects its ciphertext and potentially all subsequent ciphertext blocks, making unauthorized modifications detectable. This chaining, while complicating decryption due to its interdependent structure, enhances encryption strength through diffusion across blocks, unlike simpler electronic codebook methods where similar blocks yield similar encrypted outputs .

Trying different key values within the specified range (greater than 0 and less than 64) for the first block of ciphertext is crucial because it is a brute force method to determine the correct encryption key used. This process reveals that the key is both short and limited in range. By decrypting the first block with each possible key value, one can identify the key that transforms the ciphertext into a recognizable plaintext. This method leverages the constraints of the key length and value range to simplify the decryption process .

The MATLAB function 'bitxor' performs a bitwise exclusive OR (XOR) operation between two matrices of the same size. In the context of this lab, 'bitxor' is used to reverse the XOR operations applied during encryption under cipher block chaining (CBC). Specifically, after obtaining the intermediate plaintext through decryption, each subsequent block of ciphertext must be XORed with the preceding ciphertext block to reveal the actual plaintext message. By applying 'bitxor' to these blocks, we can systematically untangle the dependency introduced by CBC during encryption, allowing for successful decryption .

The successful decryption of ciphertext in this lab follows a specific sequence: first, install the 'decrypt.m' routine; use ‘bitxor’ to calculate the decryption key by applying different values to ct1 with the known initialization vector of zeros; decrypt the remaining blocks in sequence while XORing each with the previous ciphertext block. This order is significant because it systematically addresses each encryption step: brute force key determination, methodical decryption, and reliable application of XOR operations, maintaining the structure imposed by cipher block chaining for coherent, correct plaintext recovery .

Using MATLAB for this decryption exercise educates students on contemporary encryption algorithms like AES by providing hands-on experience with core cryptographic principles such as XOR operations, key testing, and chaining methods. By involving learners in the active process of deciphering encrypted data, it enhances understanding of key algorithmic transformation processes, complexities in data encryption security, and the practical limitations of computational tools. Exposure to MATLAB’s environment further solidifies technical competencies critical in both academic research and industry applications involving advanced cryptography .

Once the encryption key is determined, the strategic approach to recover plaintext for blocks 2 to 7 involves using the cipher block chaining methodology in reverse. After decrypting a block with 'decrypt.m', each ciphertext block should be XORed with the previous ciphertext block to recover the plaintext. This approach efficiently reverses the encryption process by taking advantage of the established order and dependency among blocks created by the initial cipher block chaining scheme .

An initialization vector (IV) of all zeros means that the first block of plaintext was encrypted without any initial randomization or perturbation. During decryption, this means that the first ciphertext block (ct1) can be directly XORed with the decrypted result to retrieve the actual plaintext, without the need to reverse an additional IV step. Essentially, the IV being all zeros simplifies the inverse process by only requiring a straightforward XOR operation on the first block during decryption, as there is no additional transformation impact from the IV .

Being able to directly manipulate the MATLAB workspace and files is crucial in this decryption lab because it allows for efficient installation and management of the necessary scripts, such as 'decrypt.m'. This capability facilitates quick adaptation and iterative testing of different keys and decryption processes. It also enhances responsiveness when making slight modifications or debugging issues during decryption, which is essential for effectively applying the lab instructions and achieving the intended outcome .

You might also like