Squashed 'external/toxcore/c-toxcore/' changes from 1701691d5..640e6cace
640e6cace fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. 6f7f51554 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) 5047ae5a2 chore: make the source tarball exhibit the old behavior 14804a4b8 chore: Fix sonar-scan CI action. e2db7d946 cleanup: Exclude lan_discovery test from running on macos, instead of excluding it from the project. 3accade67 chore: Fix CI, disabling some tests that no longer run on CI. ef8d767e6 cleanup: Fix comment formatting errors. 34ec822da cleanup: Fix some clang-19 format warnings. 40b3f0b46 refactor: Use clang's nullability qualifiers instead of attributes. f81e30679 refactor: Use per-parameter nullability annotations. REVERT: 1701691d5 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) REVERT: a87505867 fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 640e6cace81b4412c45977b94eb9c41e53c54035
This commit is contained in:
@@ -48,7 +48,7 @@ static void test_save_friend(void)
|
||||
ck_assert(enc_data != nullptr);
|
||||
Tox_Err_Encryption error1;
|
||||
bool ret = tox_pass_encrypt(data, size, (const uint8_t *)"correcthorsebatterystaple", 25, enc_data, &error1);
|
||||
ck_assert_msg(ret, "failed to encrypted save: %d", error1);
|
||||
ck_assert_msg(ret, "failed to encrypted save: %u", error1);
|
||||
ck_assert_msg(tox_is_data_encrypted(enc_data), "magic number missing");
|
||||
|
||||
struct Tox_Options *options = tox_options_new(nullptr);
|
||||
@@ -58,17 +58,17 @@ static void test_save_friend(void)
|
||||
|
||||
Tox_Err_New err2;
|
||||
Tox *tox3 = tox_new_log(options, &err2, nullptr);
|
||||
ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %d. should fail with %d", err2,
|
||||
TOX_ERR_NEW_LOAD_ENCRYPTED);
|
||||
ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %u. should fail with %d", err2,
|
||||
(int)TOX_ERR_NEW_LOAD_ENCRYPTED);
|
||||
ck_assert_msg(tox3 == nullptr, "tox_new with error should return NULL");
|
||||
uint8_t *dec_data = (uint8_t *)malloc(size);
|
||||
ck_assert(dec_data != nullptr);
|
||||
Tox_Err_Decryption err3;
|
||||
ret = tox_pass_decrypt(enc_data, size2, (const uint8_t *)"correcthorsebatterystaple", 25, dec_data, &err3);
|
||||
ck_assert_msg(ret, "failed to decrypt save: %d", err3);
|
||||
ck_assert_msg(ret, "failed to decrypt save: %u", err3);
|
||||
tox_options_set_savedata_data(options, dec_data, size);
|
||||
tox3 = tox_new_log(options, &err2, nullptr);
|
||||
ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to load from decrypted data: %d", err2);
|
||||
ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to load from decrypted data: %u", err2);
|
||||
uint8_t address2[TOX_PUBLIC_KEY_SIZE];
|
||||
ret = tox_friend_get_public_key(tox3, 0, address2, nullptr);
|
||||
ck_assert_msg(ret, "no friends!");
|
||||
@@ -87,7 +87,7 @@ static void test_save_friend(void)
|
||||
uint8_t *encdata2 = (uint8_t *)malloc(size2);
|
||||
ck_assert(encdata2 != nullptr);
|
||||
ret = tox_pass_key_encrypt(key, data2, size, encdata2, &error1);
|
||||
ck_assert_msg(ret, "failed to key encrypt %d", error1);
|
||||
ck_assert_msg(ret, "failed to key encrypt %u", error1);
|
||||
ck_assert_msg(tox_is_data_encrypted(encdata2), "magic number the second missing");
|
||||
|
||||
uint8_t *out1 = (uint8_t *)malloc(size);
|
||||
@@ -95,9 +95,9 @@ static void test_save_friend(void)
|
||||
uint8_t *out2 = (uint8_t *)malloc(size);
|
||||
ck_assert(out2 != nullptr);
|
||||
ret = tox_pass_decrypt(encdata2, size2, (const uint8_t *)pw, pwlen, out1, &err3);
|
||||
ck_assert_msg(ret, "failed to pw decrypt %d", err3);
|
||||
ck_assert_msg(ret, "failed to pw decrypt %u", err3);
|
||||
ret = tox_pass_key_decrypt(key, encdata2, size2, out2, &err3);
|
||||
ck_assert_msg(ret, "failed to key decrypt %d", err3);
|
||||
ck_assert_msg(ret, "failed to key decrypt %u", err3);
|
||||
ck_assert_msg(memcmp(out1, out2, size) == 0, "differing output data");
|
||||
|
||||
// and now with the code in use (I only bothered with manually to debug this, and it seems a waste
|
||||
@@ -134,12 +134,12 @@ static void test_keys(void)
|
||||
Tox_Err_Key_Derivation keyerr;
|
||||
const uint8_t *key_char = (const uint8_t *)"123qweasdzxc";
|
||||
Tox_Pass_Key *key = tox_pass_key_derive(key_char, 12, &keyerr);
|
||||
ck_assert_msg(key != nullptr, "generic failure 1: %d", keyerr);
|
||||
ck_assert_msg(key != nullptr, "generic failure 1: %u", keyerr);
|
||||
const uint8_t *string = (const uint8_t *)"No Patrick, mayonnaise is not an instrument."; // 44
|
||||
|
||||
uint8_t encrypted[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||
bool ret = tox_pass_key_encrypt(key, string, 44, encrypted, &encerr);
|
||||
ck_assert_msg(ret, "generic failure 2: %d", encerr);
|
||||
ck_assert_msg(ret, "generic failure 2: %u", encerr);
|
||||
|
||||
// Testing how tox handles encryption of large messages.
|
||||
int size_large = 30 * 1024 * 1024;
|
||||
@@ -153,13 +153,13 @@ static void test_keys(void)
|
||||
ck_assert(rng != nullptr);
|
||||
random_bytes(rng, in_plaintext2a, plaintext_length2a);
|
||||
ret = tox_pass_encrypt(in_plaintext2a, plaintext_length2a, key_char, 12, encrypted2a, &encerr);
|
||||
ck_assert_msg(ret, "tox_pass_encrypt failure 2a: %d", encerr);
|
||||
ck_assert_msg(ret, "tox_pass_encrypt failure 2a: %u", encerr);
|
||||
|
||||
// Decryption of same message.
|
||||
uint8_t *out_plaintext2a = (uint8_t *)malloc(plaintext_length2a);
|
||||
ck_assert(out_plaintext2a != nullptr);
|
||||
ret = tox_pass_decrypt(encrypted2a, ciphertext_length2a, key_char, 12, out_plaintext2a, &decerr);
|
||||
ck_assert_msg(ret, "tox_pass_decrypt failure 2a: %d", decerr);
|
||||
ck_assert_msg(ret, "tox_pass_decrypt failure 2a: %u", decerr);
|
||||
ck_assert_msg(memcmp(in_plaintext2a, out_plaintext2a, plaintext_length2a) == 0, "Large message decryption failed");
|
||||
free(encrypted2a);
|
||||
free(in_plaintext2a);
|
||||
@@ -167,28 +167,28 @@ static void test_keys(void)
|
||||
|
||||
uint8_t encrypted2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||
ret = tox_pass_encrypt(string, 44, key_char, 12, encrypted2, &encerr);
|
||||
ck_assert_msg(ret, "generic failure 3: %d", encerr);
|
||||
ck_assert_msg(ret, "generic failure 3: %u", encerr);
|
||||
|
||||
uint8_t out1[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||
uint8_t out2[44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH];
|
||||
|
||||
ret = tox_pass_key_decrypt(key, encrypted, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, out1, &decerr);
|
||||
ck_assert_msg(ret, "generic failure 4: %d", decerr);
|
||||
ck_assert_msg(ret, "generic failure 4: %u", decerr);
|
||||
ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 1 failed");
|
||||
|
||||
ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, (const uint8_t *)"123qweasdzxc", 12, out2,
|
||||
&decerr);
|
||||
ck_assert_msg(ret, "generic failure 5: %d", decerr);
|
||||
ck_assert_msg(ret, "generic failure 5: %u", decerr);
|
||||
ck_assert_msg(memcmp(out2, string, 44) == 0, "decryption 2 failed");
|
||||
|
||||
ret = tox_pass_decrypt(encrypted2, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, nullptr, 0, out2, &decerr);
|
||||
ck_assert_msg(!ret, "Decrypt succeeded with wrong pass");
|
||||
ck_assert_msg(decerr != TOX_ERR_DECRYPTION_FAILED, "Bad error code %d", decerr);
|
||||
ck_assert_msg(decerr != TOX_ERR_DECRYPTION_FAILED, "Bad error code %u", decerr);
|
||||
|
||||
// test that pass_decrypt can decrypt things from pass_key_encrypt
|
||||
ret = tox_pass_decrypt(encrypted, 44 + TOX_PASS_ENCRYPTION_EXTRA_LENGTH, (const uint8_t *)"123qweasdzxc", 12, out1,
|
||||
&decerr);
|
||||
ck_assert_msg(ret, "generic failure 6: %d", decerr);
|
||||
ck_assert_msg(ret, "generic failure 6: %u", decerr);
|
||||
ck_assert_msg(memcmp(out1, string, 44) == 0, "decryption 3 failed");
|
||||
|
||||
uint8_t salt[TOX_PASS_SALT_LENGTH];
|
||||
@@ -196,7 +196,7 @@ static void test_keys(void)
|
||||
ck_assert_msg(tox_get_salt(encrypted, salt, &salt_err), "couldn't get salt");
|
||||
ck_assert_msg(salt_err == TOX_ERR_GET_SALT_OK, "get_salt returned an error");
|
||||
Tox_Pass_Key *key2 = tox_pass_key_derive_with_salt((const uint8_t *)"123qweasdzxc", 12, salt, &keyerr);
|
||||
ck_assert_msg(key2 != nullptr, "generic failure 7: %d", keyerr);
|
||||
ck_assert_msg(key2 != nullptr, "generic failure 7: %u", keyerr);
|
||||
ck_assert_msg(0 == memcmp(key, key2, TOX_PASS_KEY_LENGTH + TOX_PASS_SALT_LENGTH), "salt comparison failed");
|
||||
tox_pass_key_free(key2);
|
||||
tox_pass_key_free(key);
|
||||
|
Reference in New Issue
Block a user