tanzislam / cryptopals

:closed_lock_with_key: My answers to challenges in https://cryptopals.com
GNU General Public License v3.0
8 stars 5 forks source link

Flaky test in ForgeAdminProfileCbc.CreatesForgedAdminProfile #28

Closed tanzislam closed 4 years ago

tanzislam commented 4 years ago

Example: https://travis-ci.org/github/tanzislam/cryptopals/jobs/679871545

[ FAILED ] 1 test, listed below: [ FAILED ] ForgeAdminProfileCbc.CreatesForgedAdminProfile

1 FAILED TEST The command "$shell ./test --gtest_color=yes" exited with 1.

tanzislam commented 4 years ago

As an example, this reproduces if key and initVector are both "d4f34f04b75fe54fb641b38ffbcc14f6". In that case, the prefix in the decrypted cookie ended up having an extra ; that wasn't matched by a = before we get to the ;admin=true;. This caused the key-value parser to treat the ;admin=true; as part of a key name.

The fix is to inject another = immediately before the ;admin=true; to reset the parser state.