Sunteți pe pagina 1din 7

University of Pittsburgh: School of Information Sciences

Graduate Program in Telecommunications and Networking

TELE 2820 Cryptography.


AES Lab
Version 1.0, Last edited 03.02.2005

Student’s name: ____________________________________


Group Members: ____________________________________
____________________________________
____________________________________
____________________________________

Date of the Experiment: ________________________

AES Lab 1
University of Pittsburgh: School of Information Sciences
Graduate Program in Telecommunications and Networking

Part I: Introduction
AES is the advanced encryption standard that is replacing DES and 3-DES. The purpose
of this lab is to use Advanced Encryption Standard (AES) encryption and decryption
routines in Matlab to revisit some concepts studied in class. For this purpose, we are
using Matlab routines written by Prof. Jörg J. Buchholz. In particular we will look at the
following concepts:
a) Randomness of output and the avalanche effect
b) Triple encryption using two keys
c) Brute force attack with partial knowledge of the key
The estimated time for completing this lab is three hours.

Part II: Lab Requirements


1. Matlab programming
2. Read the paper AES.pdf (http://buchholz.hs-bremen.de/aes/AES.pdf) and try to
understand the Matlab functions used in this lab.
3. You will need an account on paradox if you don’t have a copy of Matlab
4. Download the Matlab files at:
http://buchholz.hs-bremen.de/aes/AES.zip
In these Matlab files, you can change the plaintext and the key as follows:

Information Which File


Plaintext aes_demo.m
Key aes_init.m
Ciphertext Display output

Part III: Lab setup

• Log in to your paradox account.


• Download the AES.zip file from the web and save it in your account.
• To unzip a zip file, type in:
>> unzip AES.zip
• Change the directory to AES by using the command:
>> cd AES
• To see files in the directory, type in:
>> ls –l
• To access MATLAB, type in:
>> matlab
and wait for this program to load and then you are in the Matlab prompt.

AES Lab 2
University of Pittsburgh: School of Information Sciences
Graduate Program in Telecommunications and Networking

Note: The Matlab program should be run under the AES directory.
• To run the matlab file called aes_demo.m, in the Matlab prompt use:
>> aes_demo

Notes:
• You may use “pico” or “vi” or other editors to edit a Matlab file. (“pico” is easier to
use.)
• The above procedure in the lab is an option. You can use other procedures to get the
solution for this lab exercise but it is required that the given Matlab files are used.

1. Randomness of output and avalanche effect

Edit the “aes_demo.m” file and change the plaintext to the following:

Plaintext: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f

Note : In order to see the ciphertext only, the “re_plaintext” line should be
commented out by using “%” sign in front of the line. Otherwise decryption is also
done that will take additional time.

Save the change in “aes_demo1.m.”


Edit the “aes_init.m” file and change the key to the following:

Key: ab 11 ba 22 bc 33 cb 44 cd 55 dc 66 de 77 ed 88

Save with the same file name. Run aes_demo1.m and determine the ciphertext.
Note: It takes a few minutes to run the program. Record it here:

Ciphertext:
Ad

Avalanche effect:

Change the first two characters of the plaintext to “01”. Determine the new
ciphertext and record it here.

AES Lab 3
University of Pittsburgh: School of Information Sciences
Graduate Program in Telecommunications and Networking

Next change the first two characters in the original ciphertext to “ff”. Use the
same key to decrypt the ciphertext. Record the plaintext here:

Note: You can decrypt using the following steps:


Edit “aes_demo1.m”
Comment out “plaintext_hex”
“plaintext”
“ciphertext”
Add:

“ ciphertext = [ hex2dec('[1]') hex2dec('[2]') hex2dec('[3]') hex2dec('[4]')


hex2dec('[5]') hex2dec('[6]') hex2dec('[7]') hex2dec('[8]')
hex2dec('[9]') hex2dec('[10]') hex2dec('[11]') hex2dec('[12]’)
hex2dec('[13]') hex2dec('[14]') hex2dec('[15]') hex2dec('[16]')]; ”

Here [1], [2], …[16] are number at the positions in the ciphertext matrix as follow:

⎡ [1] [2] [3] [4] ⎤


⎢ [5] [6] [7] [8] ⎥
⎢ ⎥
⎢ [9] [10] [11] [12]⎥
⎢ ⎥
⎣[13] [14] [15] [16]⎦
For example:
If the number at position [1] is “aa”, the number that you should put in the
ciphertext is hex2dec(‘aa’) and so on.

Remove the comment on “re_plaintext”. Save the file.

At the matlab prompt type:


>> aes_demo

Comment on the results here:


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

AES Lab 4
University of Pittsburgh: School of Information Sciences
Graduate Program in Telecommunications and Networking

________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

2. Triple-AES Encryption

For the following sets of parameters:


Plaintext (x): 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f

Key1 (k1): ab 11 ba 22 bc 33 cb 44 cd 55 dc 66 de 77 ed 88

Key2 (k2): 00 ff 11 ee 22 dd 33 cc 44 bb 55 aa 66 99 77 88

Determine:
a) y1 = ek1 (d k 2 (ek1 ( x))) . Record it here.

b) y2 = ek1 (d k1 (ek1 ( x))) . Record it here.

c) x1 = d k1 ( y1 ) . Record it here.

d) x2 = d k1 ( y2 ) . Record it here.

AES Lab 5
University of Pittsburgh: School of Information Sciences
Graduate Program in Telecommunications and Networking

Comment on the results here:


________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________
________________________________________________________________________

3. Bruteforce Attack on AES

Given Plaintext: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f

Given Ciphertext:
30 4d 6c e0
43 0a cb 44
91 ef 6d cf
b3 eb d5 31

Given partial key:

12 23 34 45 56 67 78 89 9a ab bc cd de ef f0

Find the remaining key by writing a Matlab program, which is modified from the original
aes_demo.m file. For simplicity, you know most of the key except for the given range of
the last part of the key (from 0 – 63 (decimal)). Submit the Matlab program as well.

Note: This Matlab program can do approximately 1 encryption / minute. So it should


take you an hour or so to get the key. You may be asked to demonstrate your program.

The complete key is:

AES Lab 6
University of Pittsburgh: School of Information Sciences
Graduate Program in Telecommunications and Networking

12 23 34 45 56 67 78 89 9a ab bc cd de ef f0

The Matlab program is:

AES Lab 7

S-ar putea să vă placă și