Comprehensive test suite for AAD binding, salt randomness, and IV collision resistance
0
Total Tests
0
Passed ✅
0
Failed ❌
0%
Progress
1. AAD Tampering Detection CRITICAL
Tests that header tampering is detected via AAD binding. Any modification to the header should cause decryption to fail.
Test 1.1: Header IV Tampering
Encrypt data, then modify the IV in the header. Decryption should fail with authentication error.
Test 1.2: Header Algorithm Tampering
Encrypt data, then modify the algorithm field in header. Decryption should fail.
Test 1.3: Header PRF Salt Tampering
Encrypt data, then modify the prfSalt field. Decryption should fail.
2. Salt Randomness Verification CRITICAL
Verifies that all salts are truly random and never repeat across multiple encryptions.
Test 2.1: PRF Salt Uniqueness
Encrypt same data 100 times, verify all prfSalts are unique (no collisions).
Test 2.2: Wrap Salt Uniqueness
Encrypt with multiple recipients, verify all wrapSalts are unique.
Test 2.3: Salt Entropy Test
Statistical test: verify salt has high entropy (χ² test for randomness).
3. IV Collision Resistance IMPORTANT
Tests the collision-resistant IV generation (8-byte prefix + 4-byte counter).
Test 3.1: IV Uniqueness
Generate 10,000 IVs from same scope, verify all are unique.
Test 3.2: IV Counter Increment
Verify that counter increments monotonically within same prefix.
Test 3.3: IV Overflow Handling
Simulate counter overflow (2^32), verify new prefix is generated.
4. Functional Roundtrip Tests FUNCTIONAL
End-to-end encryption/decryption tests to ensure everything works correctly.
Test 4.1: Simple Encrypt/Decrypt
Encrypt small text data, decrypt, verify matches original.
Test 4.2: Large File Roundtrip
Encrypt 10MB random data, decrypt, verify integrity with sampling.
Test 4.3: Filename Encryption
Encrypt with filename encryption enabled, verify filename recovery.
Test 4.4: Parallel PBKDF2 Key Derivation
Derive 4 encryption keys in parallel using PBKDF2 (100k iterations). Demonstrates Web Worker performance gain for CPU-intensive operations.
Note: Browser optimization differences: Safari achieves ~3.5x speedup (88% efficiency), while Chrome's highly optimized PBKDF2 makes workers less beneficial (~0.7x due to overhead). This demonstrates that parallelization benefits vary significantly across browsers.
5. Helper Module Unit Tests UNIT TESTS
Unit tests for iv.ts and aad.ts helper modules.
Test 5.1: Canonical JSON Stability
Verify that canonicalize() produces same output for same input regardless of key order.
Test 5.2: AAD Generation Consistency
Same header should always produce same AAD bytes.
Test 5.3: IV Scope Isolation
Different scopes should have independent IV state.