Skip to main content
Challenges AES key from shared secret
Cryptography Medium DH + AES Solves: 6

AES key from shared secret

Author: CyberSamSU
Points
50

Diffie-Hellman itself does not encrypt the message — it only generates a shared number. In practice, this number is not used directly as a key: it is first passed through a hash function to obtain a key of a specific length. This step is called KDF (Key Derivation Function).

In our session, the key was derived like this and the message was encrypted with AES-256-CBC:

import hashlib
def kdf(s: int) -> bytes:
    return hashlib.sha256(str(s).encode()).digest()   # 32 bayt

from Crypto.Cipher import AES
from Crypto.Util.Padding import pad

s = pow(B, a, p)                       # DH umumiy sir
kalit = kdf(s)                         # 32 bayt -> AES-256
shifr = AES.new(kalit, AES.MODE_CBC, iv).encrypt(pad(xabar, 16))

Alice's secret number a was recovered due to a weak random number generator, and it is provided in the sessiya.txt file along with other parameters. Decrypt the message.

The PyCryptodome library will be needed: pip install pycryptodome

Attached files
sessiya.txt Log in to download
SHA-256 checksums
sessiya.txt: bf3653dbcb6c27504ec696ee4c8894f0bb17944fe34370b5186f6ebb1ad752d7
Hints 3
Opening a hint reduces the points you get for solving this challenge.
Hint 1 −5 pts Log in
Hint 2 −10 pts Log in
Hint 3 −15 pts Log in
To submit a flag, log in.

First solvers

1. Faxriddin Oripov 02.10.2026
2. Лазиз 04.10.2026
3. testrejim 09.10.2026
4. Mirjaxon Qaxxarov 27.10.2026
5. Odam 05.11.2026
6. arcanum 11.11.2026