diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-09-24 12:32:18 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-25 11:58:14 -0400 |
commit | c4337367341f0542a13990c55f0c6cdeca203659 (patch) | |
tree | 1eafa1c89c80c357ec13f9e0bc97bea91f7f8d75 | |
parent | 3b7d0ed08e13d5b806b86818acec00c9352cf1c5 (diff) | |
download | tor-c4337367341f0542a13990c55f0c6cdeca203659.tar.gz tor-c4337367341f0542a13990c55f0c6cdeca203659.zip |
Add tests for failing cases of crypto_pwbox
-rw-r--r-- | src/test/test_crypto.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c index 2af649c1e4..74b7a8eb31 100644 --- a/src/test/test_crypto.c +++ b/src/test/test_crypto.c @@ -1045,8 +1045,19 @@ test_crypto_pwbox(void *arg) tt_assert(decoded); tt_uint_op(dlen, ==, strlen(msg)); tt_mem_op(decoded, ==, msg, dlen); - tor_free(boxed); + tor_free(decoded); + + tt_int_op(UNPWBOX_BAD_SECRET, ==, crypto_unpwbox(&decoded, &dlen, boxed, len, + pw, strlen(pw)-1)); + boxed[len-1] ^= 1; + tt_int_op(UNPWBOX_BAD_SECRET, ==, crypto_unpwbox(&decoded, &dlen, boxed, len, + pw, strlen(pw))); + boxed[0] = 255; + tt_int_op(UNPWBOX_CORRUPTED, ==, crypto_unpwbox(&decoded, &dlen, boxed, len, + pw, strlen(pw))); + + tor_free(boxed); } done: |