killchain-compendium/crypto/rsa.md

1.1 KiB

RSA

possible_e = []
for i in range (2, phi):
    if gcd(n, i) == 1 and gcd(phi, i) == 1:
        possible_e.append() 
  • Decryption, private key d --> \( d * e mod \phi = 1 \)
possible_d = []
for i in range (phi + 1, phi + foo):
    if i * e mod phi == 1 :
       possible_d.append()
  • \( Cipher = msg ** d mod \phi \)
  • \( Cleartext = cipher ** e mod \phi )

Euklid

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)