Ciphers

Block ciphers

DES to Serpent. UTF-8 bytes in and hex out. Published vectors pin every cipher and every mode.

The half with rounds, S-boxes and key schedules. These take the UTF-8 bytes of the whole text and hand back hex, so case, spaces and punctuation are just more bytes. Each one is pinned to published test vectors, from a standard, the original paper or another implementation, and its page says which. They're teaching code though, written to be read and checked, not constant time. Don't guard real data with them, use your platform's crypto for that.

ciphers ciphers --category block26 ciphers · registry order
OptionsKeyspace
AES (ECB)aesSP networkkey, bytes?2^128, 2^192 or 2^256
AES (CBC)aes-cbcSP networkkey, iv, bytes?2^128, 2^192 or 2^256
AES (CFB)aes-cfbSP networkkey, iv, segment?, bytes?2^128, 2^192 or 2^256
AES (OFB)aes-ofbSP networkkey, iv, bytes?2^128, 2^192 or 2^256
AES (CTR)aes-ctrSP networkkey, iv, bytes?2^128, 2^192 or 2^256
AES (CCM)aes-ccmSP networkkey, nonce, aad?, tagLength?, bytes?2^128, 2^192 or 2^256
AES (OCB)aes-ocbSP networkkey, nonce, aad?, tagLength?, bytes?2^128, 2^192 or 2^256
AES (LRW)aes-lrwSP networkkey, tweak?, bytes?2^256, 2^320 or 2^384
AES (XTS)aes-xtsSP networkkey, tweak?, bytes?2^256 or 2^512
AES (CBC-MAC)aes-cbc-macSP networkkey, bytes?2^128, 2^192 or 2^256
AES (passphrase)aes-passphraseSP networkkey, digest?, keyLength?, iterations?, salt?, bytes?set by the passphrase, not by keyLength
Rijndael (ECB)rijndaelSP networkkey, blockSize?, bytes?2^128 to 2^256
DES (ECB)desFeistelkey, bytes?2^56
DESX (ECB)desxFeistelkey, bytes?2^184
Triple DES (ECB)triple-desFeistelkey, bytes?2^112 or 2^168
Triple DES (CBC)triple-des-cbcFeistelkey, iv, bytes?2^112 or 2^168
Blowfish (ECB)blowfishFeistelkey, bytes?2^32 to 2^448
IDEA (ECB)ideaLai-Masseykey, bytes?2^128
Lucifer (ECB)luciferFeistelkey, bytes?2^128
MARS (ECB)marsFeistelkey, bytes?2^128 to 2^448
Serpent (ECB)serpentSP networkkey, bytes?2^128, 2^192 or 2^256
CAST5 (ECB)cast5Feistelkey, bytes?2^40 to 2^128
Camellia (ECB)camelliaFeistelkey, bytes?2^128, 2^192 or 2^256
ARIA (ECB)ariaSP networkkey, bytes?2^128, 2^192 or 2^256
SM4 (ECB)sm4Feistelkey, bytes?2^128
OpenPGP (passphrase)openpgpSP networkkey, algorithm?, digest?, count?, salt?, iv?, bytes?set by the passphrase, not by the algorithm
read from the registry in your browser / no networka name with ? is optional

Conventions they share

  • The key is hex, and so is every IV, nonce and tweak. Lengths are checked before the first block. The odd ones out take a password. aes-passphrase answers in the base64 CryptoJS writes, openpgp in the armor gpg --symmetric writes.
  • ECB, CBC and the MAC pad with PKCS#7. CFB, OFB, CTR, CCM, OCB and XTS need no padding, the ciphertext has as many bytes as the text. CBC-MAC pads with zeros for the tag and returns the text bytes as they are.
  • Text goes in as UTF-8. When the plaintext is a raw key, a compressed blob or another layer of ciphertext, bytes: "hex" reads it as hex and gives it back as hex. Without it a right key on binary plaintext throws, same as a wrong one. aes-passphrase and openpgp take it too.
  • CCM, OCB and CBC-MAC append a tag. Decoding with a wrong one throws, and no plaintext comes back at all.
  • preserveCase and stripNonAlpha don't apply. There are no letters here, only bytes.

Families

Substitution-permutation is rounds of byte substitution and mixing under a key: AES in every mode here, Rijndael with its wider blocks, and Serpent, which runs its 4-bit S-boxes bitslice. ARIA borrows the AES S-box, adds one of its own and mixes the bytes with a layer that undoes itself. Feistel splits the block in half and runs one half through a keyed function into the other, round after round. DES, DESX and Triple DES build on it, Blowfish grows its S-boxes from the key and pi, Lucifer is the IBM cipher DES was cut down from, and in MARS one of four words drives the other three each round. CAST5 rotates its half by a key, then looks it up in four S-boxes. Camellia keeps the block and keys of AES and slips an FL layer between every six rounds. SM4 cuts the block in four and lets three words drive the fourth, 32 times over. Lai-Massey splits the block too, but feeds the difference of the two halves through a keyed function and XORs the result into both. Its only member is IDEA, which gets by without a single table.