Description
The instrumented 3DES execution path (tdesInstrumented) produces different output from the standard implementation (tdesBlock) for the same plaintext, key, and configuration.
Since the CryptoViz visualizer uses the instrumented path, the intermediate values and final ciphertext shown to users can differ from the standard implementation.
Root Cause
The EDE (Encrypt–Decrypt–Encrypt) sequence inside tdesInstrumented() does not match the sequence implemented in tdesBlock().
During encryption, the encrypt/decrypt flags are inverted for each DES stage. During decryption, the DES keys are also applied in the wrong order.
As a result, both implementations generate different ciphertext for identical inputs.
Steps to Reproduce
- Open the 3DES visualizer.
- Encrypt the same plaintext using the instrumented path.
- Encrypt the same plaintext using the standard path.
- Compare the outputs.
Expected Behavior
Both implementations should produce identical ciphertext and identical intermediate operations.
Actual Behavior
The instrumented implementation produces different ciphertext, resulting in inconsistent visualization and incorrect intermediate cryptographic steps.
Affected File
lib/cipher/symmetric/3des.ts
Description
The instrumented 3DES execution path (
tdesInstrumented) produces different output from the standard implementation (tdesBlock) for the same plaintext, key, and configuration.Since the CryptoViz visualizer uses the instrumented path, the intermediate values and final ciphertext shown to users can differ from the standard implementation.
Root Cause
The EDE (Encrypt–Decrypt–Encrypt) sequence inside
tdesInstrumented()does not match the sequence implemented intdesBlock().During encryption, the encrypt/decrypt flags are inverted for each DES stage. During decryption, the DES keys are also applied in the wrong order.
As a result, both implementations generate different ciphertext for identical inputs.
Steps to Reproduce
Expected Behavior
Both implementations should produce identical ciphertext and identical intermediate operations.
Actual Behavior
The instrumented implementation produces different ciphertext, resulting in inconsistent visualization and incorrect intermediate cryptographic steps.
Affected File
lib/cipher/symmetric/3des.ts