CSL759: Assignment 2, Task 2 [10 points]

You will need use the java API for cryptography. Please go through this link and familiarize with the basics.


Mr. Cryptix is a budding cryptographer who has just studied block ciphers. After spending lot of time building and executing attacks on block ciphers like DES and AES, he is now convinced that DES and AES are secure PRFs. Intuitively, this means that the output of these block ciphers appears random. He now has an interesting idea for encrypting png images. He does the following:
  1. First, he converts the given image to a grayscale image. A grayscale image is described by a 2D array of pixels, where each pixel is an integer between 0 and 255 (0 denotes black and 255 denotes white). Let this 2D array be denoted by I.
  2. He then constructs a 1D array A of bytes from this 2D array I of grayscale values in the following manner: A[i] = I[i/width][i%width].
  3. He then considers 8 byte chunks (comprising of 64 bits) of this array A and encrypts these chunks by applying DES (using the 56 bit DES key that it shares with Mr. Receivix to whom Mr. Cryptix wants to send the encrypted image). We know that Mr. Cryptix unknowingly is using ECB mode of operation. Let the encrypted byte array be denoted by B.
  4. He converts this 1D array B to a 2D array EI as follows: EI[i][j] = B[width * i + j].
  5. Finally, he sends a png image by copying the grayscale value to all the RGB components (he ends up getting a grayscale image)
Mr. Cryptix has not yet studied symmetric encryption using block ciphers and its security properties. Hence, he does not know that the ECB mode of operation is not very secure. He thinks that since each encoded block appears random the entire image should appear random and hence the sniffing Mr. Evilix will not be able to figure out the secret word that Mr. Cryptix has embedded in the image. However, to make things more interesting, he writes the secret word in funny fonts. He uses his method to encrypt the following image on the left and obtains the cipher image on the right.

imagecipher
Image and its encryption using the ECB mode

To his surprise, Mr. Cryptix finds that the encrypted image is not secure at all! This exercise exposes to him the structural weakness of the ECB mode of operation. Mr. Cryptix being still unaware of secure modes of operation such as CBC$ and CTRC, tries a different technique. Just before step 3 above, he adds a randomly chosen 0/1 value to each byte of A. This means that for each index i of the array A, he picks a value b[i] which is 0 with probability 1/2 and 1 with probability 1/2, and then updates A[i] = (A[i] + b[i])%256. He figures that he just needs to send size additional bits to Mr. Receivix, where size is the number of pixels in the image. For the above image this is 786432 bits = 96 KB. Since the image requires 132KB of space anyways this is not going to be a significant overhead.

After encrypting the image with this newly designed technique, he implements it and finds that the encrypted images indeed look extremely random. However, he does not try to formally study the security properties of his scheme but is thinking about deploying his technique. Mr. Cryptix is a bit skeptical about deploying his technique and wants to make sure that there is no easy attack on his scheme. To ensure that there is no easy attack, he devises a challenge. For each student in this course, he has created a different image with different secret codes embedded in different images. The secret code is a 10 digit number. He is interested in knowing whether someone could figure out these secret codes.

Here is what you have to do for the assignment:
You are given an encrypted image that is encrypted using Mr. Cryptix's final scheme. You have to figure out the secret 10 digit number and send it to me. You do not get the your key or the random values (b[i]'s) that Mr. Cryptix uses in his scheme. You encrypted image is in the table below.

Here is some code you may use for image manipulation.

Name
Encrypted Images
Abhishek Gupta (EE)
cipher-1
Rishab Goyal
cipher-2
Abhishek Kumar
cipher-3
Ankita
cipher-4
Ashwini Choudhary
cipher-5
Himanshu Shekhar
cipher-6
Soniya Goyal
cipher-7
Abhishek Sinha
cipher-8
Manish Yadav
cipher-9
Deepak Sharma
cipher-10
Shashank Verma
cipher-11
Abhishek Gupta (CSE)
cipher-12
Rajat Agarwal
cipher-13
Ashish Gaurav
cipher-14
Utkarsh Ohm
cipher-15
Suyash Roongta
cipher-16
Abhishek Aggarwal
cipher-17
Sushant Saxena
cipher-18
Mehul Kumar
cipher-19
Prince
cipher-20
Ramanshu Mahaur
cipher-21
Siddhant Ujjain
cipher-22
Chandrika Bharadwaj
cipher-23
Abhay Gupta
cipher-24
Abhinn Kothari
cipher-25
Alok Singh
cipher-26
Naveen Kumar
cipher-27
Parth Jaiswal
cipher-28
Gaurav Ashok
cipher-29
Ruchin Kukreja
cipher-30
Mayank Singh Gurjar
cipher-31
Nikhil Kumar
cipher-32
Soumyaranjan Majhi
cipher-33