[tor-commits] [tor/master] Add tests for failing cases of crypto_pwbox
nickm at torproject.org
nickm at torproject.org
Thu Sep 25 16:06:16 UTC 2014
commit c4337367341f0542a13990c55f0c6cdeca203659
Author: Nick Mathewson <nickm at torproject.org>
Date: Wed Sep 24 12:32:18 2014 -0400
Add tests for failing cases of crypto_pwbox
---
src/test/test_crypto.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index 2af649c..74b7a8e 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:
More information about the tor-commits
mailing list