mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Update encryption autotest
This commit is contained in:
parent
e632ef8a47
commit
2d3077904e
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue
Block a user