This document contains a full reference implementation of M-XXTEA based on Ragab et al. (2021), "M-XXTEA: A Modified XXTEA Block Cipher with Enhanced Security". [DOI link]
1) Implementation (HTML Demo)
M-XXTEA Demo (Ragab et al. 2021)
M-XXTEA Encryption Demo
Ciphertext (Base64):
2) Compliance Statements (Ragab et al., 2021)
Nonlinear layer (S-Box): Uses the AES S-Box exactly as listed in Table 5 of the paper. The inverse table is generated automatically to avoid transcription errors.
Single-round equation: For each round r and word index i, the update is V[i] = V[i] + f(V[i-1], V[i+1], r, k), realized via MX(prev,next,sum,i,k) where prev = V[i-1], next = V[i+1], sum encodes the round counter, and k comes from the chaotic key schedule.
Chaotic key schedule: 128-bit key words derived from a logistic map (parameter r=3.99) seeded by key ⊕ nonce-dependent values; the schedule is recomputed per encryption using the provided nonce.
Rounds: Default 32 (consistent with 6 + 52/n for n=2 words). The demo exposes a rounds input so testers may choose other counts.
Padding: PKCS#7-style to 8-byte boundary; strict validation during unpadding to detect tampering or corruption.
Nonce handling: A user-specified nonce field is provided. If left empty, a fresh random nonce is generated per encryption and embedded (IEEE-754 Float64) into the first 8 bytes of the ciphertext container; decryption recovers it automatically.
Invertibility: Decryption iterates rounds in reverse and subtracts the same MX contribution, ensuring bit-exact inversion.
I/O encoding: UTF‑8 for text; ciphertext is Base64 of a byte container [nonce(8 bytes) || payload].
3) Usage Notes
For reproducible tests, set a fixed nonce (e.g., 0.5). For security demonstrations, leave nonce blank to randomize each run.
For production use, add integrity protection (HMAC over the container) or move to an AEAD mode to mitigate padding oracles.
When interoperating with other implementations, ensure the same S-Box (Table 5) and the same endian/packing conventions (little-endian 32-bit words) are used.
Field ranges:
Plaintext: empty up to ~2 GB (practical: a few MBs in browser).