Skip to content

feat: add TEA and XTEA block ciphers#2225

Open
thomasxm wants to merge 2 commits intogchq:masterfrom
thomasxm:feat/tea-xtea
Open

feat: add TEA and XTEA block ciphers#2225
thomasxm wants to merge 2 commits intogchq:masterfrom
thomasxm:feat/tea-xtea

Conversation

@thomasxm
Copy link
Contributor

@thomasxm thomasxm commented Mar 7, 2026

Summary

Adds TEA and XTEA block cipher operations to CyberChef:

  • TEA (Tiny Encryption Algorithm) — Wheeler & Needham, 1994
  • XTEA (eXtended TEA) — Wheeler & Needham, 1997

Both are lightweight 64-bit block ciphers with 128-bit keys, widely encountered in malware analysis and CTF challenges.

New Operations

TEA

  • TEA Encrypt — Block encryption with fixed 32 cycles
  • TEA Decrypt — Block decryption with fixed 32 cycles
  • DELTA constant: 0x9E3779B9 (derived from the golden ratio)

XTEA

  • XTEA Encrypt — Block encryption with configurable rounds
  • XTEA Decrypt — Block decryption with configurable rounds
  • Improved key schedule using sum-dependent key word selection
  • Configurable rounds: 1–255 (default 32), matching the reference implementation by Wheeler & Needham

Common Features

  • Block size: 64 bits (8 bytes)
  • Key size: 128 bits (16 bytes)
  • Byte order: Big-endian (matching Go stdlib, Bouncy Castle, Ironclad)
  • Modes: ECB, CBC, CFB, OFB, CTR
  • Padding: PKCS5, NO, ZERO, RANDOM, BIT (ISO/IEC 7816-4)

Use Cases

  • Malware analysis (TEA/XTEA frequently used in malware for payload encryption)
  • CTF challenges
  • Embedded systems and IoT firmware analysis
  • Legacy protocol decryption
  • Educational purposes (studying Feistel cipher design)

Files Changed

File Action
src/core/lib/TEA.mjs NEW — Core TEA/XTEA library
src/core/operations/TEAEncrypt.mjs NEW
src/core/operations/TEADecrypt.mjs NEW
src/core/operations/XTEAEncrypt.mjs NEW
src/core/operations/XTEADecrypt.mjs NEW
src/core/config/Categories.json Added 4 operations
tests/operations/tests/TEA.mjs NEW — 28 test cases
tests/operations/index.mjs Registered tests

Testing

  • 28 test cases covering TEA and XTEA
  • Test vectors sourced from Go stdlib crypto/xtea (big-endian) and Ironclad
  • Round-trip encrypt/decrypt verification for all modes (ECB, CBC, CFB, OFB, CTR)
  • Non-default round count tests for XTEA (16 rounds vs 32 rounds)
  • All 1839 existing tests continue to pass (no regressions)

Implementation Notes

  • Pure JavaScript, no external dependencies
  • XTEA rounds parameter follows the same convention as RC6 (Rounds after Padding in the argument list)
  • Consistent API with existing CyberChef cipher operations (RC6, SM4, Blowfish, etc.)
  • TEA uses fixed 32 cycles as specified in the original paper (no configurable rounds, by design)

References

thomasxm added 2 commits March 7, 2026 09:51
Add a Rounds parameter (1-255, default 32) to XTEA Encrypt and Decrypt
operations, matching the reference implementation by Wheeler & Needham
which accepts a configurable round count. Follows the same convention as
RC6 for argument ordering (Rounds after Padding).
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