Short answer: ECDH agrees on a shared point. Each side multiplies the public base point by its own scalar and publishes the result. Each side then multiplies the other side’s point by its own scalar. The two products are the same point, because scalar multiplication commutes. The fragment uses…
Category: Cryptography
How DSA signs a hash in a prime-order subgroup
Short answer: DSA signs a hash with an exponent in a prime-order subgroup. The public parameters are a prime p, a prime q dividing p – 1, and a base g of order q. The private key x is in 1 through q – 1, and the public key…
How DES encrypts a block with sixteen Feistel rounds
Short answer: DES encrypts an 8-byte block with sixteen Feistel rounds. PC-1 drops the parity bits of a 64-bit key and leaves a 56-bit schedule. Each round expands the right half to 48 bits, xors a subkey, splits the result into eight 6-bit pieces, and replaces each piece by…
How counter mode turns AES into a keystream
Short answer: Counter mode encrypts a counter block and xors the result with the plaintext. The fragment increments the last four bytes as a big-endian integer, which is the NIST SP 800-38A counter. Decryption is the same xor. The plaintext does not pass through the block cipher. What the…
How ChaCha20 expands a key into a keystream block
Short answer: ChaCha20 turns a 32-byte key, a 12-byte nonce, and a 32-bit block counter into a 64-byte keystream block. The state is sixteen little-endian words: the constant expand 32-byte k, the key, the counter, and the nonce. Ten double-rounds mix it. Each double-round is four column quarter-rounds and…
How CBC chains ciphertext into the next plaintext block
Short answer: Cipher block chaining xors each plaintext block with the previous ciphertext block, then applies the block cipher. The first block is xored with an initialization vector. The fragment uses AES-128, the SP 800-38A key 2b7e151628aed2a6abf7158809cf4f3c, the IV 000102030405060708090a0b0c0d0e0f, and one plaintext block. Decryption applies the inverse cipher…
How Blowfish builds its state from the digits of pi
Short answer: Blowfish is a 16-round Feistel cipher on 8-byte blocks. Eighteen P-words and four S-boxes of 256 words start as the fractional hexadecimal digits of pi. The key is xored into the P-array, and the cipher then encrypts a running block to replace every P-word and every S-box…
How AES encrypts one block in ten rounds
Short answer: AES encrypts a 16-byte block. AES-128 expands a 16-byte key into eleven round keys and runs ten rounds. Each of the first nine rounds is SubBytes, ShiftRows, MixColumns, and AddRoundKey. The last round skips MixColumns. The FIPS 197 key 000102030405060708090a0b0c0d0e0f and plaintext 00112233445566778899aabbccddeeff encrypt to 69c4e0d86a7b0430d8cdb78070b4c55a. What…
How RSA encrypts with a public exponent
Short answer: RSA builds a public modulus n as a product of two secret primes and a public exponent e that is coprime to λ(n), the Carmichael function of n. The private exponent d is the modular inverse of e modulo λ(n). Encryption of an integer m in 0…
How Diffie-Hellman agrees on a shared secret
Short answer: Diffie-Hellman lets two parties derive the same secret from a public generator. They agree on a group. Each party samples a secret exponent, sends the generator raised to that exponent, and raises the value it receives to its own exponent. Both compute g raised to the product…
