diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-09-23 14:34:59 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-25 11:58:14 -0400 |
commit | d0f5d2b662c3d24f1e704d55d598c43c8d1df0db (patch) | |
tree | 181d7c2af051c2c5fd1385059381686ceaa74d41 /src/test/test_crypto.c | |
parent | 05a6439f1f2265a22ea6c52ba10c86925e72d2ac (diff) | |
download | tor-d0f5d2b662c3d24f1e704d55d598c43c8d1df0db.tar.gz tor-d0f5d2b662c3d24f1e704d55d598c43c8d1df0db.zip |
Test a full array of s2k flags with pwbox test.
Suggested by yawning.
Diffstat (limited to 'src/test/test_crypto.c')
-rw-r--r-- | src/test/test_crypto.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c index 3672684952..2af649c1e4 100644 --- a/src/test/test_crypto.c +++ b/src/test/test_crypto.c @@ -1019,25 +1019,35 @@ test_crypto_pwbox(void *arg) { uint8_t *boxed=NULL, *decoded=NULL; size_t len, dlen; + unsigned i; const char msg[] = "This bunny reminds you that you still have a " "salamander in your sylladex. She is holding the bunny Dave got you. " "It’s sort of uncanny how similar they are, aside from the knitted " "enhancements. Seriously, what are the odds?? So weird."; const char pw[] = "I'm a night owl and a wise bird too"; + const unsigned flags[] = { 0, + S2K_FLAG_NO_SCRYPT, + S2K_FLAG_LOW_MEM, + S2K_FLAG_NO_SCRYPT|S2K_FLAG_LOW_MEM, + S2K_FLAG_USE_PBKDF2 }; (void)arg; - tt_int_op(0, ==, crypto_pwbox(&boxed, &len, (const uint8_t*)msg, strlen(msg), - pw, strlen(pw), 0)); - tt_assert(boxed); - tt_assert(len > 128+32); + for (i = 0; i < ARRAY_LENGTH(flags); ++i) { + tt_int_op(0, ==, crypto_pwbox(&boxed, &len, (const uint8_t*)msg, strlen(msg), + pw, strlen(pw), flags[i])); + tt_assert(boxed); + tt_assert(len > 128+32); - tt_int_op(0, ==, crypto_unpwbox(&decoded, &dlen, boxed, len, - pw, strlen(pw))); + tt_int_op(0, ==, crypto_unpwbox(&decoded, &dlen, boxed, len, + pw, strlen(pw))); - tt_assert(decoded); - tt_uint_op(dlen, ==, strlen(msg)); - tt_mem_op(decoded, ==, msg, dlen); + tt_assert(decoded); + tt_uint_op(dlen, ==, strlen(msg)); + tt_mem_op(decoded, ==, msg, dlen); + tor_free(boxed); + tor_free(decoded); + } done: tor_free(boxed); |