Squashed 'external/toxcore/c-toxcore/' changes from f1df709b87..8f0d505f9a
8f0d505f9a feat: add ngc events 9b8216e70c refactor: Make event dispatch ordered by receive time. 814c12a6f4 cleanup: Add dynamically derived array sizes to the API. 226b23be12 cleanup: Add explicit array sizes to toxencryptsave. ef33cb4de0 cleanup: Add Toxav alias for ToxAV. 1da723b34d cleanup: Make Tox_Options a typedef. b148a2afff chore: Simplify msvc build using vcpkg. 5cac6d7eb1 cleanup: Move `tox_get_system` out of the public API. c9ca4007e3 refactor: Align group message sending with other send functions. 6c6c0b1b1b cleanup: Make setters take non-const `Tox *`. a76f758d70 cleanup: Mark arrays in the tox API as `[]` instead of `*`. baf6d1f6cf cleanup: Make array params in toxav `[]` instead of `*`. 79f55bd06a cleanup: Put the size of fixed arrays into the API types. 1e73698db2 cleanup: Add typedefs for public API int identifiers. cac074c57f chore: Add fetch-sha256 script to update bootstrap node hash. 32576656bb Make the comment capitalization uniform aff4dda17c Spellcheck tox-bootstrapd 40b5fbbe9d chore: Remove settings.yml in favour of hs-github-tools. ebafd51be7 chore: Use GPL license with https. 0e42752f0f cleanup: Move all vptr-to-ptr casts to the beginning of a function. 5407384211 cleanup: Use github actions matrix to simplify CI. 82d8265688 fix: Use QueryPerformanceCounter on windows for monotonic time. 1224e656e3 chore: Add `net_(new|kill)_strerror` to cppcheck's allocators. 6a90ddfe4e cleanup: Run clang-tidy on headers, as well. bd930cc80a cleanup: Make TCP connection failures a warning instead of error. fad6e4e173 cleanup: Make all .c files include the headers they need. ef4897a898 cleanup: Upgrade to clang-tidy-17 and fix some warnings. REVERT: f1df709b87 feat: add ngc events REVERT: 1b6c907235 refactor: Make event dispatch ordered by receive time. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 8f0d505f9a598cc41c682178e1589bcc01efe9cb
This commit is contained in:
@ -79,7 +79,9 @@ void tox_pass_key_free(Tox_Pass_Key *key)
|
||||
*
|
||||
* @return true on success.
|
||||
*/
|
||||
bool tox_get_salt(const uint8_t *ciphertext, uint8_t *salt, Tox_Err_Get_Salt *error)
|
||||
bool tox_get_salt(
|
||||
const uint8_t ciphertext[TOX_PASS_ENCRYPTION_EXTRA_LENGTH],
|
||||
uint8_t salt[TOX_PASS_SALT_LENGTH], Tox_Err_Get_Salt *error)
|
||||
{
|
||||
if (ciphertext == nullptr || salt == nullptr) {
|
||||
SET_ERROR_PARAMETER(error, TOX_ERR_GET_SALT_NULL);
|
||||
@ -112,8 +114,9 @@ bool tox_get_salt(const uint8_t *ciphertext, uint8_t *salt, Tox_Err_Get_Salt *er
|
||||
*
|
||||
* @return new symmetric key on success, NULL on failure.
|
||||
*/
|
||||
Tox_Pass_Key *tox_pass_key_derive(const uint8_t *passphrase, size_t passphrase_len,
|
||||
Tox_Err_Key_Derivation *error)
|
||||
Tox_Pass_Key *tox_pass_key_derive(
|
||||
const uint8_t passphrase[], size_t passphrase_len,
|
||||
Tox_Err_Key_Derivation *error)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
|
||||
@ -136,8 +139,9 @@ Tox_Pass_Key *tox_pass_key_derive(const uint8_t *passphrase, size_t passphrase_l
|
||||
*
|
||||
* @return new symmetric key on success, NULL on failure.
|
||||
*/
|
||||
Tox_Pass_Key *tox_pass_key_derive_with_salt(const uint8_t *passphrase, size_t passphrase_len,
|
||||
const uint8_t *salt, Tox_Err_Key_Derivation *error)
|
||||
Tox_Pass_Key *tox_pass_key_derive_with_salt(
|
||||
const uint8_t passphrase[], size_t passphrase_len,
|
||||
const uint8_t salt[TOX_PASS_SALT_LENGTH], Tox_Err_Key_Derivation *error)
|
||||
{
|
||||
if (salt == nullptr || (passphrase == nullptr && passphrase_len != 0)) {
|
||||
SET_ERROR_PARAMETER(error, TOX_ERR_KEY_DERIVATION_NULL);
|
||||
@ -189,8 +193,8 @@ Tox_Pass_Key *tox_pass_key_derive_with_salt(const uint8_t *passphrase, size_t pa
|
||||
*
|
||||
* @return true on success.
|
||||
*/
|
||||
bool tox_pass_key_encrypt(const Tox_Pass_Key *key, const uint8_t *plaintext, size_t plaintext_len,
|
||||
uint8_t *ciphertext, Tox_Err_Encryption *error)
|
||||
bool tox_pass_key_encrypt(const Tox_Pass_Key *key, const uint8_t plaintext[], size_t plaintext_len,
|
||||
uint8_t ciphertext[], Tox_Err_Encryption *error)
|
||||
{
|
||||
const Random *rng = system_random();
|
||||
|
||||
@ -250,8 +254,8 @@ bool tox_pass_key_encrypt(const Tox_Pass_Key *key, const uint8_t *plaintext, siz
|
||||
*
|
||||
* @return true on success.
|
||||
*/
|
||||
bool tox_pass_encrypt(const uint8_t *plaintext, size_t plaintext_len, const uint8_t *passphrase, size_t passphrase_len,
|
||||
uint8_t *ciphertext, Tox_Err_Encryption *error)
|
||||
bool tox_pass_encrypt(const uint8_t plaintext[], size_t plaintext_len, const uint8_t passphrase[], size_t passphrase_len,
|
||||
uint8_t ciphertext[/*! plaintext_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH */], Tox_Err_Encryption *error)
|
||||
{
|
||||
Tox_Err_Key_Derivation err;
|
||||
Tox_Pass_Key *key = tox_pass_key_derive(passphrase, passphrase_len, &err);
|
||||
@ -281,8 +285,8 @@ bool tox_pass_encrypt(const uint8_t *plaintext, size_t plaintext_len, const uint
|
||||
*
|
||||
* @return true on success.
|
||||
*/
|
||||
bool tox_pass_key_decrypt(const Tox_Pass_Key *key, const uint8_t *ciphertext, size_t ciphertext_len,
|
||||
uint8_t *plaintext, Tox_Err_Decryption *error)
|
||||
bool tox_pass_key_decrypt(const Tox_Pass_Key *key, const uint8_t ciphertext[], size_t ciphertext_len,
|
||||
uint8_t plaintext[], Tox_Err_Decryption *error)
|
||||
{
|
||||
if (ciphertext_len <= TOX_PASS_ENCRYPTION_EXTRA_LENGTH) {
|
||||
SET_ERROR_PARAMETER(error, TOX_ERR_DECRYPTION_INVALID_LENGTH);
|
||||
@ -333,8 +337,8 @@ bool tox_pass_key_decrypt(const Tox_Pass_Key *key, const uint8_t *ciphertext, si
|
||||
*
|
||||
* @return true on success.
|
||||
*/
|
||||
bool tox_pass_decrypt(const uint8_t *ciphertext, size_t ciphertext_len, const uint8_t *passphrase,
|
||||
size_t passphrase_len, uint8_t *plaintext, Tox_Err_Decryption *error)
|
||||
bool tox_pass_decrypt(const uint8_t ciphertext[], size_t ciphertext_len, const uint8_t passphrase[],
|
||||
size_t passphrase_len, uint8_t plaintext[/*! ciphertext_len - TOX_PASS_ENCRYPTION_EXTRA_LENGTH */], Tox_Err_Decryption *error)
|
||||
{
|
||||
if (ciphertext_len <= TOX_PASS_ENCRYPTION_EXTRA_LENGTH) {
|
||||
SET_ERROR_PARAMETER(error, TOX_ERR_DECRYPTION_INVALID_LENGTH);
|
||||
@ -382,7 +386,7 @@ bool tox_pass_decrypt(const uint8_t *ciphertext, size_t ciphertext_len, const ui
|
||||
*
|
||||
* @return true if the data is encrypted by this module.
|
||||
*/
|
||||
bool tox_is_data_encrypted(const uint8_t *data)
|
||||
bool tox_is_data_encrypted(const uint8_t data[TOX_PASS_ENCRYPTION_EXTRA_LENGTH])
|
||||
{
|
||||
return memcmp(data, TOX_ENC_SAVE_MAGIC_NUMBER, TOX_ENC_SAVE_MAGIC_LENGTH) == 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user