Skip to content

Conversation

@thomasxm
Copy link

Summary

Adds two new block cipher implementations to CyberChef:

  1. PRESENT - ISO/IEC 29192-2:2019 ultra-lightweight block cipher
  2. Twofish - AES finalist by Bruce Schneier et al.

New Operations

PRESENT (ISO/IEC 29192-2:2019)

  • PRESENT Encrypt - 64-bit block encryption with 80/128-bit keys
  • PRESENT Decrypt - 64-bit block decryption with 80/128-bit keys
  • Modes: ECB, CBC
  • 31 rounds, SP-network structure

Twofish (AES Finalist)

  • Twofish Encrypt - 128-bit block encryption with 128/192/256-bit keys
  • Twofish Decrypt - 128-bit block decryption with 128/192/256-bit keys
  • Modes: ECB, CBC, CFB, OFB, CTR
  • 16 rounds, Feistel network structure

Padding Options (Both Ciphers)

  • PKCS5 (PKCS#7)
  • NO (none - requires block-aligned input)
  • ZERO
  • RANDOM
  • BIT (ISO/IEC 7816-4)

Use Cases

  • PRESENT: RFID tags, sensor networks, IoT devices, constrained environments
  • Twofish: General-purpose encryption, legacy system compatibility, AES alternative

Files Changed

File Action
src/core/lib/Present.mjs NEW
src/core/lib/Twofish.mjs NEW
src/core/operations/PRESENTEncrypt.mjs NEW
src/core/operations/PRESENTDecrypt.mjs NEW
src/core/operations/TwofishEncrypt.mjs NEW
src/core/operations/TwofishDecrypt.mjs NEW
src/core/config/Categories.json Added all operations
tests/operations/tests/PRESENT.mjs NEW
tests/operations/tests/Twofish.mjs NEW
tests/operations/index.mjs Registered tests

Testing

  • All 1760 tests pass
  • Official CHES 2007 test vectors for PRESENT (Table 3)
  • Official Schneier test vectors for Twofish

PRESENT Test Vectors (CHES 2007)

Key Size Key Plaintext Ciphertext
80-bit 00000000000000000000 0000000000000000 5579c1387b228445
80-bit ffffffffffffffffffff 0000000000000000 e72c46c0f5945049
128-bit 00000000000000000000000000000000 0000000000000000 96db702a2e6900af

Twofish Test Vectors (Schneier)

Key Size Key Plaintext Ciphertext
128-bit 0000...0000 (32 hex) 0000...0000 (32 hex) 9f589f5cf6122c32b6bfec2f2ae8c35a
192-bit 0000...0000 (48 hex) 0000...0000 (32 hex) efa71f788965bd4453f860178fc19101
256-bit 0000...0000 (64 hex) 0000...0000 (32 hex) 57ff739d4dc92c1bd7fc01700cc8216f

Implementation Notes

  • Pure JavaScript implementations (no external dependencies)
  • Uses BigInt for 64-bit and 128-bit operations
  • Consistent API with existing CyberChef cipher operations (SM4, Blowfish, GOST)

References

Screenshot 2026-01-11 at 01 16 17 Screenshot 2026-01-11 at 01 16 17 Screenshot 2026-01-11 at 01 15 50 Screenshot 2026-01-11 at 01 15 34 Screenshot 2026-01-11 at 01 15 18 Screenshot 2026-01-11 at 01 14 03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant