diff options
author | dubslow <bunslow@gmail.com> | 2014-10-23 04:19:18 -0500 |
---|---|---|
committer | dubslow <bunslow@gmail.com> | 2014-10-23 04:19:18 -0500 |
commit | d90ee9d4e447f7520fee899b7b6211125095242b (patch) | |
tree | ebcee2825fa850e92b5547e512d556ba82010328 /auto_tests/encryptsave_test.c | |
parent | cfac10fb82b27c80e2ba72f07a3ef0c10f16faa6 (diff) |
fix #1124 by adding salt manip functions
Also, all data now has the magic number prepended. This is incompatible
for all but the save/load functions, but I think nothing besides the one
experimental qTox branch used any of those, which is why I feel confident
about the change.
Diffstat (limited to 'auto_tests/encryptsave_test.c')
-rw-r--r-- | auto_tests/encryptsave_test.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c index 85952392..3045fbfa 100644 --- a/auto_tests/encryptsave_test.c +++ b/auto_tests/encryptsave_test.c | |||
@@ -99,8 +99,8 @@ START_TEST(test_save_friend) | |||
99 | // now test compaitibilty with tox_encrypted_load, first manually... | 99 | // now test compaitibilty with tox_encrypted_load, first manually... |
100 | uint8_t out1[size], out2[size]; | 100 | uint8_t out1[size], out2[size]; |
101 | printf("Trying to decrypt from pw:\n"); | 101 | printf("Trying to decrypt from pw:\n"); |
102 | uint32_t sz1 = tox_pass_decrypt(data2+TOX_ENC_SAVE_MAGIC_LENGTH, size-TOX_ENC_SAVE_MAGIC_LENGTH, pw, pwlen, out1); | 102 | uint32_t sz1 = tox_pass_decrypt(data2, size, pw, pwlen, out1); |
103 | uint32_t sz2 = tox_pass_key_decrypt(data2+TOX_ENC_SAVE_MAGIC_LENGTH, size-TOX_ENC_SAVE_MAGIC_LENGTH, key, out2); | 103 | uint32_t sz2 = tox_pass_key_decrypt(data2, size, key, out2); |
104 | ck_assert_msg(sz1 == sz2, "differing output sizes"); | 104 | ck_assert_msg(sz1 == sz2, "differing output sizes"); |
105 | ck_assert_msg(memcmp(out1, out2, sz1) == 0, "differing output data"); | 105 | ck_assert_msg(memcmp(out1, out2, sz1) == 0, "differing output data"); |
106 | 106 | ||
@@ -145,6 +145,12 @@ START_TEST(test_keys) | |||
145 | sz = tox_pass_decrypt(encrypted, 44+tox_pass_encryption_extra_length(), "123qweasdzxc", 12, out1); | 145 | sz = tox_pass_decrypt(encrypted, 44+tox_pass_encryption_extra_length(), "123qweasdzxc", 12, out1); |
146 | ck_assert_msg(sz == 44, "sz isn't right"); | 146 | ck_assert_msg(sz == 44, "sz isn't right"); |
147 | ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 3 failed"); | 147 | ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 3 failed"); |
148 | |||
149 | uint8_t salt[tox_pass_salt_length()]; | ||
150 | ck_assert_msg(0 == tox_get_salt(encrypted, salt), "couldn't get salt"); | ||
151 | uint8_t key2[tox_pass_key_length()]; | ||
152 | tox_derive_key_with_salt("123qweasdzxc", 12, salt, key2); | ||
153 | ck_assert_msg(0 == memcmp(key, key2, tox_pass_key_length()), "salt comparison failed"); | ||
148 | } | 154 | } |
149 | END_TEST | 155 | END_TEST |
150 | 156 | ||