Task 7 - Padding Attack - CS 6035
Task 7 - Padding Attack - CS 6035
CS 6035
Projects / Cryptography / Task 7: Padding Attack
For this task we will be working with an attack known as the padding oracle attack. The padding
oracle works under the idea that the server is leaking information about the padding. With this
information it is possible to both decrypt and encrypt messages.
https://github.gatech.edu/pages/cs6035-tools/cs6035-tools.github.io/Projects/RSA_Cryptography/CBC_oracle.html 1/3
3/23/25, 12:23 PM Task 7: Padding Attack | CS 6035
For this one section of the assignment you will be asked to use a library outside of the standard. In
this task you will use the pycryptodome library. This can be manually downloaded from this link
https://github.com/Legrandin/pycryptodome. Alternatively it can be downloaded through pip with
the following command:
pip install pycryptodome
c = 0
return b64encode(c).decode("utf-8")
Step 2 of this task is to write a function that can decrypt a short message. You may use
pycryptodome’s built in decrypt function.
def cbc_decrypt_128(key: bytes, IV: bytes, c: bytes) -> str:
m = 0
return m
https://github.gatech.edu/pages/cs6035-tools/cs6035-tools.github.io/Projects/RSA_Cryptography/CBC_oracle.html 2/3
3/23/25, 12:23 PM Task 7: Padding Attack | CS 6035
Step 3 of this task is to write one of the core functions of an oracle which will test if the padding
follows pkcs guidelines. This check is often the information that the oracle can leak. For this task
you must assume that there will always be at least 1 byte of padding, but there does not always
have to be a message attached.
def check_padding(padding) -> bool:
return is_pkcs_padded
These steps can all be tested using the test_task_cbc_ python files. You can do so with the
following commands:
python test_task_cbc_decrypt.py
python test_task_cbc_encrypt.py
python test_task_cbc_pkcs.py
Resources
https://en.wikipedia.org/wiki/Padding_oracle_attack
https://www.pycryptodome.org/
Submission Details
You will write your code in the specified function stub(s) found in the provided
project_cryptography.py file. When ready, submit this file to the Project Cryptography
autograder in Gradescope.
Disclaimer: You are responsible for the information on this website. The content is subject to change at any time. © 2024 Georgia Institute
of Technology. All rights reserved.
https://github.gatech.edu/pages/cs6035-tools/cs6035-tools.github.io/Projects/RSA_Cryptography/CBC_oracle.html 3/3