From 2d3077904ec9360eb1f753643a16a15f0fb739c5 Mon Sep 17 00:00:00 2001 From: Dubslow Date: Sat, 28 Feb 2015 12:55:40 -0600 Subject: [PATCH] Update encryption autotest --- auto_tests/encryptsave_test.c | 22 ++++++++++------------ 1 file 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 START_TEST(test_save_friend) { + TOX_ERR_NEW err = TOX_ERR_NEW_OK; Tox *tox1 = tox_new(0); Tox *tox2 = tox_new(0); ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances"); @@ -71,9 +72,8 @@ START_TEST(test_save_friend) ck_assert_msg(test == 0, "failed to encrypted save"); ck_assert_msg(tox_is_save_encrypted(data) == 1, "magic number missing"); - Tox *tox3 = tox_new(0); - test = tox_encrypted_load(tox3, data, size, "correcthorsebatterystaple", 25); - ck_assert_msg(test == 0, "failed to encrypted load"); + Tox *tox3 = tox_encrypted_new(0, data, size, "correcthorsebatterystaple", 25, &err); + ck_assert_msg(err == TOX_ERR_NEW_OK, "failed to encrypted new"); uint8_t address2[TOX_CLIENT_ID_SIZE]; test = tox_get_client_id(tox3, 0, address2); ck_assert_msg(test == 0, "no friends!"); @@ -88,18 +88,17 @@ START_TEST(test_save_friend) ck_assert_msg(test == 0, "failed to encrypted save the second"); ck_assert_msg(tox_is_save_encrypted(data2) == 1, "magic number the second missing"); - // first test tox_encrypted_key_load - Tox *tox4 = tox_new(0); - test = tox_encrypted_key_load(tox4, data2, size, key); - ck_assert_msg(test == 0, "failed to encrypted load the second"); + // first test tox_encrypted_key_new + Tox *tox4 = tox_encrypted_key_new(0, data2, size, key, &err); + ck_assert_msg(err == TOX_ERR_NEW_OK, "failed to encrypted new the second"); uint8_t address4[TOX_CLIENT_ID_SIZE]; test = tox_get_client_id(tox4, 0, address4); ck_assert_msg(test == 0, "no friends! the second"); ck_assert_msg(memcmp(address, address2, TOX_CLIENT_ID_SIZE) == 0, "addresses don't match! the second"); - // now test compaitibilty with tox_encrypted_load, first manually... + // now test compaitibilty with tox_encrypted_new, first manually... uint8_t out1[size], out2[size]; - printf("Trying to decrypt from pw:\n"); + //printf("Trying to decrypt from pw:\n"); uint32_t sz1 = tox_pass_decrypt(data2, size, pw, pwlen, out1); uint32_t sz2 = tox_pass_key_decrypt(data2, size, key, out2); ck_assert_msg(sz1 == sz2, "differing output sizes"); @@ -107,9 +106,8 @@ START_TEST(test_save_friend) // and now with the code in use (I only bothered with manually to debug this, and it seems a waste // to remove the manual check now that it's there) - Tox *tox5 = tox_new(0); - test = tox_encrypted_load(tox5, data2, size, pw, pwlen); - ck_assert_msg(test == 0, "failed to encrypted load the third"); + Tox *tox5 = tox_encrypted_new(0, data2, size, pw, pwlen, &err); + ck_assert_msg(err == TOX_ERR_NEW_OK, "failed to encrypted new the third"); uint8_t address5[TOX_CLIENT_ID_SIZE]; test = tox_get_client_id(tox4, 0, address5); ck_assert_msg(test == 0, "no friends! the third");