Post

Cryptography

Methodology

  1. Description and hints/try to determine topic

Scripts

Tools

Practice

Links

Topics

Ciphers

Hashes

SHA1

XOR

Symmetric

ECB

CBC

CTR

GCM

Asymmetric

Modular arithmetic

RSA

  • encrypt: c = pow(m, e, n)
  • decrypt: m = pow(c, modinv(e, (p - 1) * (q - 1)), n)
  • RSA Examples
  • Featherduster
  • RSACtfTool
  • RSA Attacks
    • factorize primes (FactorDB)
    • weiner (d is small)
    • no padding
    • small primes
    • small e
    • multiple messages with same e
    • adjacent primes
  • If N == p^2, the totient calculation is p(p - 1)

Broadcast attack

Chinese Remainder Theorem

DSA

Rabin

Linear Congruential Generator (LCG)

Keys

PEM

1
2
3
4
5
6
# Print values from PEM
from Crypto.PublicKey import RSA
print(RSA.importKey(open("a.pem", "rb").read()).d)

# ssh-keygen convert to PEM
ssh-keygen -f key.pub -e -m pem

OpenSSL

  • Cheatsheet
  • openssl rsa -in private.key -text -noout
  • openssl rsa -pubin -noout -text < public.key
This post is licensed under CC BY 4.0 by the author.