Cryptography Fundamentals
Basics
Understanding cryptography is essential for identifying weaknesses. This guide covers the foundational concepts needed to attack cryptographic implementations.
Cryptographic Primitives
Symmetric Encryption
- • Same key for encrypt/decrypt
- • AES (128/256-bit), ChaCha20
- • Block ciphers vs stream ciphers
- • Modes: ECB, CBC, GCM, CTR
Asymmetric Encryption
- • Public/private key pairs
- • RSA, ECC, Diffie-Hellman
- • Digital signatures
- • Key exchange protocols
Hash Functions
- • One-way, fixed output
- • SHA-256, SHA-3, BLAKE3
- • Collision resistance
- • Pre-image resistance
MACs & Signatures
- • HMAC, CMAC
- • RSA signatures, ECDSA
- • Authenticated encryption
- • Message integrity
Identifying Crypto in the Wild
bash
# Identify encrypted data by entropy
ent encrypted_file.bin
# Base64 patterns
# Padding: = or == at end
# Characters: A-Za-z0-9+/
# Hex encoding
# Characters: 0-9a-f
# Length doubles
# Common ciphertext lengths
# AES: multiples of 16 bytes
# RSA-2048: 256 bytes
# SHA-256: 32 bytes (64 hex chars)
# Look for crypto libraries in code
grep -rn "crypto|cipher|encrypt|AES|RSA" .
# CyberChef for quick analysis
# https://gchq.github.io/CyberChef/