

Implement a system that uses AES to encrypt data and RSA to protect AES keys. You willneed to write one program to generate RSA keys, and a second one that uses the RSA keys to perform theencryption and decryption of messages.
- generate Bob/Alice key pair(private and public key) alice.pub and alice.prv
- Encrypt message.txt file using AES and also encrypt AES key using RSA 2049
- Store the cipher text in message.cip
python AESTest.py -e alice.pub message.txt message.cip
- Decrypt message.cip file using alice.prv to message.txt file
python AESTest.py -d alice.prv message.cip message.txt
Uses: mukesh@localhost in ~/Downloads/CSCI531_HW_3 on master [!?$]$ python genkeys.py bob********* generating p prime...........********* generating q prime..................Storing......... bob.pubStoring.......... bob.prvmukesh@localhost in ~/Downloads/CSCI531_HW_3 on master [!?$]$ python genkeys.py alice********* generating p prime...........********* generating q prime..................Storing......... alice.pubStoring.......... alice.prvmukesh@localhost in ~/Downloads/CSCI531_HW_3 on master [!?$]$ cat message.txt This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh mukesh@localhost in ~/Downloads/CSCI531_HW_3 on master [!?$]$ python crypt.py -e bob.pub message.txt message.cipEncryption of message.txt file is done. cipher text is present in message.cip file Process is done mukesh@localhost in ~/Downloads/CSCI531_HW_3 on master [!?$]$ python crypt.py -d bob.prv message.cip message.txtplaintext This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh Decryption of message.cip file is done. plain text is in message.txt file Process is done mukesh@localhost in ~/Downloads/CSCI531_HW_3 on master [!?$]$ cat message.txtThis is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh This is Mukesh Using Alice Key with message2.txtmukesh@localhost in ~/Downloads/CSCI531_HW_3 on master [!?$]$ cat message2.txt I have strong grasp of technology as well as business skills. Since in my previous role i had interacted with business leads and the country manager of our Asia pacific business as well as their technology teams.mukesh@localhost in ~/Downloads/CSCI531_HW_3 on master [!?$]$ python crypt.py -e alice.pub message2.txt message2.cipEncryption of message.txt file is done. cipher text is present in message.cip file Process is done mukesh@localhost in ~/Downloads/CSCI531_HW_3 on master [!?$]$ python crypt.py -d alice.prv message2.cip message2.txtplaintext I have strong grasp of technology as well as business skills. Since in my previous role i had interacted with business leads and the country manager of our Asia pacific business as well as their technology teams.Decryption of message2.cip file is done. plain text is in message.txt file Process is done mukesh@localhost in ~/Downloads/CSCI531_HW_3 on master [!?$]$ cat message2.txt I have strong grasp of technology as well as business skills. Since in my previous role i had interacted with business leads and the country manager of our Asia pacific business as well as their technology teams.
To complete the project, you will need to write two Python programs:-[x] 1. genkeys.py — generate RSA public and private keys. The program takes a single command line argument: the name of the user for whom the keys willbe generated. For test purposes, use the user names alice and bob.
The program must be runnable directly from the command shell, e.g., ./genkeys.py alice
The program must generate an RSA public/private key pair using your own code (you cannotimport RSA code from another module such as PyCrypto). It must use random.SystemRandom oros.urandom() as the source of pseudo-random bytes. The keys must be of practical cryptographicsize.
The program must produce two output files, one containing the RSA private key (e.g., alice.prv)and the other one containing the RSA public key (e.g., alice.pub). The format of the key files isup to you.
You will need to write code to compute modular inverse and to test whether a number is prime.2. crypt.py — encrypt and decrypt data using AES-128 and RSA.
The program takes four command line arguments: a single flag (-e or -d) indicating whether theprogram will encrypt or decrypt a message, the name of the public or private key file to use(generated by keygen.py), the name of the file to encrypt or decrypt, and the name of the outputfile. For example, the following command will encrypt the file secret.txt using Alice’s public keyfile alice.pub to produce the cipher text file secret.cip:
./crypt.py -e alice.pub secret.txt secret.cip
Then the following command would decrypt the file secret.cip:./crypt.py -d alice.prv secret.cip secret.txt
Some random number examples (p,q):
104087 104089 104107 104113 104119 104123 104147 104149 104161 104173104179 104183 104207 104231 104233 104239 104243 104281 104287 104297104309 104311 104323 104327 104347 104369 104381 104383 104393 104399104417 104459 104471 104473 104479 104491 104513 104527 104537 104543104549 104551 104561 104579 104593 104597 104623 104639 104651 104659104677 104681 104683 104693 104701 104707 104711 104717 104723 104729
To encrypt a file, the program must generate a random key K for AES-128 usingrandom.SystemRandom or os.urandom(), use the key K with AES-128 to encrypt the data fromthe input file, use RSA with the public key file specified on the command line to encrypt K (werefer to the encrypted K as K’ in the following), and write the encrypted data and K’ to the outputfile. The format of the output file (how to store K’ along with the encrypted data) is your choice.
To decrypt a file, the program must read the encrypted data and K’ from the input file, RSAdecrypt K’ to recover the key K, use K with AES-128 to decrypt the data, and write the decrypteddata to the output file.
You must write the RSA code; you may not import RSA code from another module such asPyCrypto.
You must choose an appropriate mode of operation for AES-128.In addition to the two Python programs, you must provide a written description of the design of yourprograms and a screen capture of a session demonstrating that your programs work. For example, a screencapture of the following sequence of commands would be sufficient (this assumes the files message.txtand message2.txt already exist):
./genkeys.pyalice./genkeys.pybobcatmessage.txt./crypt.py-ebob.pubmessage.txtmessage.cipcatmessage.cip./crypt.py-dbob.prvmessage.cipmessage.txtcatmessage.txtcatmessage2.txt./crypt-ealice.pubmessage2.txtmessage2.cipcatmessage2.cip./crypt-dalice.prvmessage2.cipmessage2.txtcatmessage2.txt