Question: 1 . ( 2 5 points ) In this problem, you will use AES to encrypt and decrypt PGM image files. Since these files will

1.(25 points) In this problem, you will use AES to encrypt and decrypt PGM image files. Since these files will have large sizes, you will implement the ECB mode of operation. For this problem, you need to implement the following methods in ImageCipher.java: bitsToHexString(), stateToBits(), readBlock(), writeBlock(), processHeader(), encryptECB(), and decryptECB(). To encrypt a file, you will first copy the header from the input file to the output file during the encryption/decryption process. Then you will encrypt the integer pixel values (each one of which occupies a single byte) sixteen at a time, since AES processes blocks of size 128 bits. The test files for this assignment will always contain a total number of pixels that is a multiple of 16. Therefore, you will never have to worry about padding the last block. Once you have encrypted or decrypted a block, you will have to break it up again into 16 bytes, convert each one to a decimal number (between 0 and 255 ; no negative values!) and write to the output file this integer in its ASCII representation. Make sure that each printed integer occupies EXACTLY 3 characters (with white space padding in front if needed) and is followed by a single newline character. This is to guarantee that the output file will always have exactly the same size as the input file. In the end, the output (encrypted or decrypted) file will be a valid .pgm file but with different pixel values resulting from the block-by-block encryption/decryption dictated by AES and the mode of operation you are implementing.
Once you have implemented all of the incomplete methods listed above (whose specification is given within the source file), you can test your program with a sequence of commands like these:
```
> ls -l checker*.pgm
> java ImageCipher -e -ECB checker 00112233445566778899AABBCCDDEEFF
> ls -l checker*.pgm
> display checker_ECB.pgm
> java ImageCipher -d -ECB checker_ECB 00112233445566778899AABBCCDDEEFF
> ls -l checker*.pgm
> diff checker.pgm checker_ECB_dec.pgm
```
2.(25 points) In this problem, you will use AES to encrypt and decrypt PGM image files. Since these files will have large sizes, you will implement the CBC mode of operation. For this problem, you need to implement the following methods in ImageCipher.java: hexStringToBits(), xor(), encryptCBC(), and decryptCBC(). The rest of this problem's description is identical to the one given above.
Once you have implemented all of the incomplete methods listed above (whose specification is given within the source file), you can test your program with a sequence of commands like these:
```
> ls -l checker*.pgm
> java ImageCipher -e -CBC checker 00112233445566778899AABBCCDDEEFF 0123456789ABCDEFFEDCBA9876543210
> ls -l checker*.pgm
> display checker_CBC.pgm
> java ImageCipher -d -CBC checker_CBC 00112233445566778899AABBCCDDEEFF 0123456789ABCDEFFEDCBA9876543210
> ls -l checker*.pgm
> diff checker.pgm checker_CBC_dec.pgm
```
3.(25 points) In this problem, you will use AES to encrypt and decrypt PGM image files. Since these files will have large sizes, you will implement the CTR mode of operation. For this problem, you need to implement the following methods in ImageCipher.java: encryptCTR()) and decryptCTR(). For this problem, you may want to use the BigInteger class in the Java library in order to handle the 128-bit integer values used for the counter. The rest of this problem's description is identical to the one given above.
Once you have implemented all of the incomplete methods listed above (whose specification is given within the source file), you can test your program with a sequence of commands like these:
```
> ls -l checker*.pgm
> java ImageCipher -e -CTR checker 00112233445566778899AABBCCDDEEFF 0123456789ABCDEFFEDCBA9876543210
> ls -l checker*.pgm
> display checker_CTR.pgm
> java ImageCipher -d -CTR checker_CTR 00112233445566778899AABBCCDDEEFF 0123456789ABCDEFFEDCBA9876543210
> ls -l checker*.pgm
```1.(25 points) In this problem, you will use AES to encrypt and decrypt PGM image files. Since these files will have large sizes, you will implement the ECB mode of operation. For this problem, you need to implement the following methods in ImageCipher.java: bitsToHexString(), stateToBits(), readBlock(), writeBlock(), processHeader(), encryptECB(), and decryptECB(). To encrypt a file, you will first copy the header from the input file to the output file during the encryption/decryption process. Then you will encrypt the integer pixel values (each one of which occupies a single byte) sixteen at a time, since AES processes blocks of size 128 bits. The test files for this assignment will always contain a total number of pixels that is a multiple of 16. Therefore, you will never have to worry about padding the last block. Once you have encrypted or decrypted a block, you will have to break it up again into 16 bytes, convert each one to a decimal number (between 0 and 255 ; no negative values!) and write to the output file this integer in its ASCII representation. Make sure that each printed integer occupies EXACTLY 3 characters (with w
1 . ( 2 5 points ) In this problem, you will use

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!