Files
ctfkit/templates/crypto_skeleton.py
T

27 lines
784 B
Python

"""
CRYPTO skeleton — copy & fill. (p4-team style: read source, do the math)
For RSA challenges, start by importing lib.crypto_utils and try the recipes:
recover_n_from_keys, common_modulus_attack, wiener, hastad_broadcast
"""
import lib.crypto_utils as cu
from Crypto.Util.number import long_to_bytes, bytes_to_long, getPrime, inverse
def main():
# 1) Read the challenge output / source. Example: RSA with weird params.
e = 0x10001
# ... load n, c, etc from the provided data ...
# 2) Try the right recipe. Example (from 'lost_modulus'):
# p, q = cu.recover_n_from_keys(e, d, ipmq, iqmp)
# n = p * q
# m = pow(c, d, n)
# print(long_to_bytes(m))
raise NotImplementedError("fill in the crypto math")
if __name__ == "__main__":
main()