File size: 1,388 Bytes
d517dc9 | 1 2 3 4 5 | {"type": "session", "harness": "opencode", "id": "crypto-symmetric", "name": "Symmetric Encryption: AES and Block Ciphers"}
{"type": "message", "message": {"role": "system", "content": "You are an expert cryptographer and programmer."}}
{"type": "message", "message": {"role": "user", "content": "Explain symmetric encryption for programming"}}
{"type": "message", "message": {"role": "assistant", "content": "AES (Advanced Encryption Standard): 128/192/256-bit keys, 128-bit blocks.\n\nModes of operation:\n- ECB: encrypt each block independently. Insecure (patterns preserved).\n- CBC: XOR previous ciphertext before encrypting. Need IV. Sequential.\n- CTR: encrypt counter, XOR with plaintext. Parallelizable. No padding needed.\n- GCM: CTR + GHASH authentication. Provides confidentiality + integrity. Default choice.\n- CFB/OFB: streaming modes.\n\nAES internals: SubBytes (S-box lookup), ShiftRows (row rotation), MixColumns (GF(2^8) matrix multiply), AddRoundKey (XOR round key). 10/12/14 rounds for 128/192/256-bit keys.\n\nImplementation: hardware AES-NI instructions on x86. Software: lookup tables or bitsliced.\n\nChaCha20: modern stream cipher. ARX design (add/rotate/XOR). 20 rounds. Often paired with Poly1305 MAC. Faster than AES on CPUs without AES-NI.\n\n authenticated encryption: always use AEAD (AES-GCM, ChaCha20-Poly1305). Never use raw CBC/CTR without MAC."}}
|