Information Assurance - F19

CSE 365

Assignment 3

Assignment 3 is due 10/7/19 on or before 11:59:59pm MST.

Part 1 — Julius’s Test (40 points)

You’ve discovered the encoded ciphertext, now it’s time to break the ciphertext and recover the key.

Your agents have found that the following Python 2 encryption algorithm is used (in this cryptosystem, encryption is the same operation as decryption):

1
2
3
4
5
6
7
8
9
10
11
12
13
import base64

def encode(text):
    return base64.encodestring(text)

def decode(text):
    return base64.decodestring(text)

def encrypt(cleartext, key):
    to_return = bytearray(len(cleartext))
    for i in xrange(len(cleartext)):
        to_return[i] = ord(cleartext[i]) ^ key
    return to_return

Analysis of the encryption function shows that it can output non-printable characters (confirm this for yourself), therefore all output is encoded using Base64 Encoding using the encode and decode functions.

For example, the string “test” encrypted with the key 0x80 (128 decimal) is:

1
2
print(encode(encrypt("test", 0x80)))
9OXz9A==

We can verify that encrypting 9OXz9A== with the key 0x80 results is “test”:

1
2
print(encrypt(decode("9OXz9A=="), 0x80))
test

Your spies have also converted this code to a Java class and C code.

Your goal is to break the encryption and recover the key.

Submission Instructions

You will need to submit a README file, the key, and all the code you used to break the ciphertext.

Your README file should contain your name, ASU ID, the plaintext, where the plaintext came from, how to use the code that you used to break the ciphertext, and a description of how you broke the encryption.

The key must be submitted in hexadecimal (starting with “0x”).

Part 2 — Alan’s Test (60 points)

You’ve discovered another ciphertext, now it’s time to break the ciphertext and recover the key.

Your agents have found that the following Python 2 encryption algorithm is used (same encoding as in part 1):

1
2
3
4
5
6
7
8
9
10
11
12
import base64
def encode(text):
    return base64.encodestring(text)

def decode(text):
    return base64.decodestring(text)

def encrypt(cleartext, key):
    to_return = bytearray(len(cleartext))
    for i in xrange(len(cleartext)):
        to_return[i] = ord(cleartext[i]) ^ ord(key[i % len(key)])
    return str(to_return)

For example, the string “this is a test” encrypted with the key “12” is:

1
2
print(encode(encrypt("this is a test", "12")))
RVpYQRFbQhJQEkVXQkY=

We can verify that encrypting RVpYQRFbQhJQEkVXQkY= with the key “12” results in “this is a test”:

1
2
print(encrypt(decode("RVpYQRFbQhJQEkVXQkY="), "12"))
this is a test

Your spies have also converted this code to a Java class and C code.

Break the encryption and recover the key.

Submission Instructions

You will need to submit a README file, the key, and all the code you used to break the ciphertext.

Your README file should contain your name, ASU ID, and a description of how you broke the encryption.

The key should be submitted as a string.

Submission Site

Create an account to submit your homework on the course submisison site.