summaryrefslogtreecommitdiff
path: root/auto_tests/encryptsave_test.c
diff options
context:
space:
mode:
authorDubslow <bunslow@gmail.com>2015-02-28 12:55:40 -0600
committerDubslow <bunslow@gmail.com>2015-02-28 12:55:40 -0600
commit2d3077904ec9360eb1f753643a16a15f0fb739c5 (patch)
tree1ff446971c8770029762cf0fc923ae479df52e99 /auto_tests/encryptsave_test.c
parente632ef8a478ebb964b855c641e2ba14b279c78e1 (diff)
Update encryption autotest
Diffstat (limited to 'auto_tests/encryptsave_test.c')
-rw-r--r--auto_tests/encryptsave_test.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c
index 338c9ef1..9ff63a7d 100644
--- a/auto_tests/encryptsave_test.c
+++ b/auto_tests/encryptsave_test.c
@@ -55,6 +55,7 @@ END_TEST
55 55
56START_TEST(test_save_friend) 56START_TEST(test_save_friend)
57{ 57{
58 TOX_ERR_NEW err = TOX_ERR_NEW_OK;
58 Tox *tox1 = tox_new(0); 59 Tox *tox1 = tox_new(0);
59 Tox *tox2 = tox_new(0); 60 Tox *tox2 = tox_new(0);
60 ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances"); 61 ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances");
@@ -71,9 +72,8 @@ START_TEST(test_save_friend)
71 ck_assert_msg(test == 0, "failed to encrypted save"); 72 ck_assert_msg(test == 0, "failed to encrypted save");
72 ck_assert_msg(tox_is_save_encrypted(data) == 1, "magic number missing"); 73 ck_assert_msg(tox_is_save_encrypted(data) == 1, "magic number missing");
73 74
74 Tox *tox3 = tox_new(0); 75 Tox *tox3 = tox_encrypted_new(0, data, size, "correcthorsebatterystaple", 25, &err);
75 test = tox_encrypted_load(tox3, data, size, "correcthorsebatterystaple", 25); 76 ck_assert_msg(err == TOX_ERR_NEW_OK, "failed to encrypted new");
76 ck_assert_msg(test == 0, "failed to encrypted load");
77 uint8_t address2[TOX_CLIENT_ID_SIZE]; 77 uint8_t address2[TOX_CLIENT_ID_SIZE];
78 test = tox_get_client_id(tox3, 0, address2); 78 test = tox_get_client_id(tox3, 0, address2);
79 ck_assert_msg(test == 0, "no friends!"); 79 ck_assert_msg(test == 0, "no friends!");
@@ -88,18 +88,17 @@ START_TEST(test_save_friend)
88 ck_assert_msg(test == 0, "failed to encrypted save the second"); 88 ck_assert_msg(test == 0, "failed to encrypted save the second");
89 ck_assert_msg(tox_is_save_encrypted(data2) == 1, "magic number the second missing"); 89 ck_assert_msg(tox_is_save_encrypted(data2) == 1, "magic number the second missing");
90 90
91 // first test tox_encrypted_key_load 91 // first test tox_encrypted_key_new
92 Tox *tox4 = tox_new(0); 92 Tox *tox4 = tox_encrypted_key_new(0, data2, size, key, &err);
93 test = tox_encrypted_key_load(tox4, data2, size, key); 93 ck_assert_msg(err == TOX_ERR_NEW_OK, "failed to encrypted new the second");
94 ck_assert_msg(test == 0, "failed to encrypted load the second");
95 uint8_t address4[TOX_CLIENT_ID_SIZE]; 94 uint8_t address4[TOX_CLIENT_ID_SIZE];
96 test = tox_get_client_id(tox4, 0, address4); 95 test = tox_get_client_id(tox4, 0, address4);
97 ck_assert_msg(test == 0, "no friends! the second"); 96 ck_assert_msg(test == 0, "no friends! the second");
98 ck_assert_msg(memcmp(address, address2, TOX_CLIENT_ID_SIZE) == 0, "addresses don't match! the second"); 97 ck_assert_msg(memcmp(address, address2, TOX_CLIENT_ID_SIZE) == 0, "addresses don't match! the second");
99 98
100 // now test compaitibilty with tox_encrypted_load, first manually... 99 // now test compaitibilty with tox_encrypted_new, first manually...
101 uint8_t out1[size], out2[size]; 100 uint8_t out1[size], out2[size];
102 printf("Trying to decrypt from pw:\n"); 101 //printf("Trying to decrypt from pw:\n");
103 uint32_t sz1 = tox_pass_decrypt(data2, size, pw, pwlen, out1); 102 uint32_t sz1 = tox_pass_decrypt(data2, size, pw, pwlen, out1);
104 uint32_t sz2 = tox_pass_key_decrypt(data2, size, key, out2); 103 uint32_t sz2 = tox_pass_key_decrypt(data2, size, key, out2);
105 ck_assert_msg(sz1 == sz2, "differing output sizes"); 104 ck_assert_msg(sz1 == sz2, "differing output sizes");
@@ -107,9 +106,8 @@ START_TEST(test_save_friend)
107 106
108 // and now with the code in use (I only bothered with manually to debug this, and it seems a waste 107 // and now with the code in use (I only bothered with manually to debug this, and it seems a waste
109 // to remove the manual check now that it's there) 108 // to remove the manual check now that it's there)
110 Tox *tox5 = tox_new(0); 109 Tox *tox5 = tox_encrypted_new(0, data2, size, pw, pwlen, &err);
111 test = tox_encrypted_load(tox5, data2, size, pw, pwlen); 110 ck_assert_msg(err == TOX_ERR_NEW_OK, "failed to encrypted new the third");
112 ck_assert_msg(test == 0, "failed to encrypted load the third");
113 uint8_t address5[TOX_CLIENT_ID_SIZE]; 111 uint8_t address5[TOX_CLIENT_ID_SIZE];
114 test = tox_get_client_id(tox4, 0, address5); 112 test = tox_get_client_id(tox4, 0, address5);
115 ck_assert_msg(test == 0, "no friends! the third"); 113 ck_assert_msg(test == 0, "no friends! the third");