Asymmetric (public-key) cryptography with mathematical foundations, including RSA, ECC, and key exchange protocols. Mathematical Foundation Public-Key Cryptosystem A public-key cryptosystem consists of: $$ \begin{aligned} (pk, sk) &\leftarrow KeyGen() \ C &= Encrypt(pk, M) \ M &= Decrypt(sk, C) …
Read MoreCryptographic hash functions with mathematical properties and practical implementations. Mathematical Definition A cryptographic hash function $H: {0,1}^* \to {0,1}^n$ maps arbitrary-length input to fixed-length output. $$ H(m) = h $$ Where: $m$: Message (arbitrary length) $h$: Hash digest (fixed length, e.g., 256 …
Read MoreDigital Signatures
Digital signature algorithms with mathematical foundations. Mathematical Definition A digital signature scheme consists of: $$ \begin{aligned} (pk, sk) &\leftarrow KeyGen() \ \sigma &= Sign(sk, M) \ {0,1} &= Verify(pk, M, \sigma) \end{aligned} $$ Properties: Authentication: Proves message from holder of …
Read MoreEncrypt and decrypt data using public/private key pairs and derive symmetric keys from ECC key pairs. RSA Encryption (OpenSSL) 1# Generate RSA key pair 2openssl genrsa -out private.pem 4096 3openssl rsa -in private.pem -pubout -out public.pem 4 5# Encrypt file with public key 6openssl rsautl -encrypt -pubin -inkey …
Read MoreGenerate public/private key pairs on Linux for various cryptographic purposes. SSH Keys (Ed25519 - Recommended) 1# Generate Ed25519 key pair 2ssh-keygen -t ed25519 -C "your_email@example.com" 3 4# Specify output file 5ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_custom -C "comment" 6 7# Without passphrase …
Read MoreHash and digitally sign text using public/private key pairs. Hash Text (OpenSSL) 1# SHA-256 hash 2echo -n "Hello, World!" | openssl dgst -sha256 3echo -n "Hello, World!" | openssl sha256 4 5# SHA-512 hash 6echo -n "Hello, World!" | openssl dgst -sha512 7 8# Hash file 9openssl dgst -sha256 …
Read MoreKey Derivation Functions (KDFs) for password hashing and key derivation. Password-Based KDFs PBKDF2 (Password-Based Key Derivation Function 2) $$ DK = PBKDF2(password, salt, iterations, dkLen) $$ Algorithm: $$ \begin{aligned} T_i &= F(password, salt, iterations, i) \ F(password, salt, c, i) &= U_1 \oplus U_2 …
Read MorePGP/GPG signature operations for files, emails, and git commits. Generate GPG Key 1# Interactive key generation 2gpg --full-generate-key 3 4# Quick generation (Ed25519) 5gpg --quick-generate-key "Your Name <email@example.com>" ed25519 sign,cert 2y 6 7# Batch generation 8cat > gpg-batch <<EOF …
Read MoreSetup GPG/PGP to automatically sign Git commits and tags. Generate GPG Key for Git 1# Generate GPG key (use same email as Git) 2gpg --full-generate-key 3 4# Select: 5# 1. RSA and RSA (or Ed25519) 6# 4096 bits (for RSA) 7# 2y expiration 8# Your name 9# Your Git email 10# Passphrase 11 12# Or quick generation 13gpg …
Read MoreSymmetric encryption algorithms with mathematical foundations and practical implementations. Mathematical Definition Symmetric encryption uses the same key for encryption and decryption: $$ \begin{aligned} C &= E_K(P) \quad \text{(Encryption)} \ P &= D_K(C) \quad \text{(Decryption)} \end{aligned} $$ Where: $P$: …
Read More