Commit 1aab369
committed
tests/encrypt: fix flaky test_encrypt_decrypt_base64 bad-password check
AES-CBC with EVP_BytesToKey has no MAC, so wolfssl enc -d detects a wrong
password only by validating PKCS#7 padding of the garbage plaintext. With
a random salt, the last byte(s) may satisfy valid padding by chance
(measured ~0.4% / ~1 in 256 over 2000 trials), causing rc==0 and the
assertNotEqual(rc, 0) check to fire.
Also verify the output file does not match the original plaintext: random
garbage will not collide with the source, so the assertion is deterministic
regardless of padding luck. Verified stable over 2000 trials (0 false
passes) vs 5/2000 with the old assertion.1 parent 22dfb6a commit 1aab369
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
89 | 96 | | |
90 | 97 | | |
91 | 98 | | |
| |||
0 commit comments