Ciphers

Stream ciphers

Rabbit for now. A key and an IV grow a keystream and the keystream is XORed into the text. UTF-8 bytes in and hex out.

No blocks, no padding, no modes. A stream cipher turns the key and the IV into a long run of bytes that look random, the keystream, and XORs it into the text byte by byte. Decrypting is the same XOR again. So the ciphertext is exactly as long as the text, and the whole cipher is really one question: how do you grow good keystream out of a short key?

AES-CTR, OFB and CFB answer it with a block cipher inside. The ciphers here answer it on their own, without a block cipher anywhere in sight.

ciphers ciphers --category stream1 cipher · registry order
OptionsKeyspace
RabbitrabbitARXkey, iv?, endian?2^128
read from the registry in your browser / no networka name with ? is optional

Conventions they share

  • The key is hex, and so is the IV. Lengths are checked before the first byte.
  • Text goes in as UTF-8 and comes out as lowercase hex. decode wants hex back, any whole number of bytes.
  • Nothing checks integrity. A flipped ciphertext bit flips the same plaintext bit and nobody notices.
  • One key and one IV give one keystream. Encrypt two texts with both the same and the XOR of the ciphertexts is the XOR of the texts, no key needed.
  • preserveCase and stripNonAlpha don't apply. Bytes, not letters.

Families

ARX mixes 32-bit words with addition, rotation and XOR, and nothing else that needs a table. Rabbit adds one more thing to the mix, a squaring, and gets by without a single S-box.