Skip to content

3DES instrumented execution path produces different output than the standard implementation #222

Description

@krishna28004

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

  1. Open the 3DES visualizer.
  2. Encrypt the same plaintext using the instrumented path.
  3. Encrypt the same plaintext using the standard path.
  4. 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

Metadata

Metadata

Assignees

Labels

ECSoC26Elite Coders Summer of Code 2026

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions