Skip to content

Repository files navigation

Cryptography Problem Set

License: MIT Python

Three applied cryptography challenges, each broken down with a write-up of the approach (descriptionN.txt) and a working Python solution (solutionN.py).

1. Decrypt AES-CBC using only AES-ECB primitives

description1.txt / solution1.py

Implements CBC-mode decryption by hand using only an AES-ECB cipher object: decrypt each 16-byte block with ECB, then XOR the result with the previous ciphertext block (or the IV, for the first block), and finally strip PKCS7 padding.

2. Break a reused keystream

description2.txt / solution2.py

Exploits the classic "two-time pad" flaw: when the same key/IV (and therefore the same keystream) encrypts two different messages, XORing one ciphertext with its known plaintext recovers the keystream, which can then be XORed against the other ciphertext to recover its plaintext.

3. Find a hash collision

description3.txt / solution3.py

Brute-forces a collision in a small custom hash function (ds_hash): randomly generate 256-character messages, hash them, and check for two different messages that map to the same hash.

Requirements

pip install cryptography

(solution2.py and solution3.py use only the standard library.)

About

Python solutions to applied cryptography problems: AES-CBC decryption from ECB primitives, a keystream reuse attack, and a hash collision search.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages