fork download
  1. '''
  2. In this project you will implement two encryption/decryption systems, one using AES in CBC mode and another using AES in counter mode (CTR). In both cases the 16-byte encryption IV is chosen at random and is prepended to the ciphertext. For CBC encryption we use the PKCS5 padding scheme discussed in class (13:50).
  3.  
  4. While we ask that you implement both encryption and decryption, we will only test the decryption function. In the following questions you are given an AES key and a ciphertext (both are hex encoded) and your goal is to recover the plaintext and enter it in the input boxes provided below.
  5.  
  6. For an implementation of AES you may use an existing crypto library such as PyCrypto (Python), Crypto++ (C++), or any other. While it is fine to use the built-in AES functions, we ask that as a learning experience you implement CBC and CTR modes yourself.
  7. '''
  8.  
  9. from Crypto.Cipher import AES
  10. import binascii
  11. import sys
  12.  
  13. def test(self):
  14. challenge = '37010000000000006C9EC947'.decode('hex')
  15. key = "2D43F84CFCE5DFA2821CD60912E390E4".decode('hex')
  16. access = 0x02
  17. userid = binascii.unhexlify("666D00")
  18. cipher = AES.new(key, AES.MODE_CBC, challenge)
  19. print("Here2")
  20. token = '6D66000000000000'.decode('hex')
  21. print("Here3")
  22.  
  23. print(token)
  24.  
  25.  
  26.  
Success #stdin #stdout 0.01s 7140KB
stdin
Standard input is empty
stdout
Standard output is empty