Skip to content

Commit

Permalink
cleanup: stated explicit lengths for Noise function parameters (where…
Browse files Browse the repository at this point in the history
… possible) in crypto_core.
  • Loading branch information
goldroom committed Mar 22, 2024
1 parent 4286d4b commit 21b9126
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions toxcore/crypto_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ void random_bytes(const Random *rng, uint8_t *bytes, size_t length)

/* Necessary functions for Noise, cf. https://noiseprotocol.org/noise.html (Revision 34) */

size_t encrypt_data_symmetric_xaead(const uint8_t *shared_key, const uint8_t *nonce,
size_t encrypt_data_symmetric_xaead(const uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE], const uint8_t nonce[CRYPTO_NONCE_SIZE],
const uint8_t *plain, size_t plain_length, uint8_t *encrypted,
const uint8_t *ad, size_t ad_length)
{
Expand All @@ -552,7 +552,7 @@ size_t encrypt_data_symmetric_xaead(const uint8_t *shared_key, const uint8_t *no
return encrypted_length;
}

size_t decrypt_data_symmetric_xaead(const uint8_t *shared_key, const uint8_t *nonce,
size_t decrypt_data_symmetric_xaead(const uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE], const uint8_t nonce[CRYPTO_NONCE_SIZE],
const uint8_t *encrypted, size_t encrypted_length, uint8_t *plain,
const uint8_t *ad, size_t ad_length)
{
Expand Down Expand Up @@ -657,7 +657,7 @@ int32_t noise_mix_key(uint8_t chaining_key[CRYPTO_SHA512_SIZE],
uint8_t dh_calculation[CRYPTO_PUBLIC_KEY_SIZE];
memset(dh_calculation, 0, CRYPTO_PUBLIC_KEY_SIZE);

// X25519 - returns plain DH result, afterwards hashed with HKDF
// X25519: returns plain DH result, afterwards hashed with HKDF
if (crypto_scalarmult_curve25519(dh_calculation, private_key, public_key) != 0) {
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions toxcore/crypto_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ void new_hmac_key(const Random *rng, uint8_t key[CRYPTO_HMAC_KEY_SIZE]);
* @return length of encrypted data if everything was fine.
*/
non_null(1, 2, 3, 5) nullable(6)
size_t encrypt_data_symmetric_xaead(const uint8_t *shared_key, const uint8_t *nonce, const uint8_t *plain, size_t plain_length,
size_t encrypt_data_symmetric_xaead(const uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE], const uint8_t nonce[CRYPTO_NONCE_SIZE], const uint8_t *plain, size_t plain_length,
uint8_t *encrypted, const uint8_t *ad, size_t ad_length);

/**
Expand All @@ -529,7 +529,7 @@ size_t encrypt_data_symmetric_xaead(const uint8_t *shared_key, const uint8_t *no
* @return length of plain data if everything was fine.
*/
non_null(1, 2, 3, 5) nullable(6)
size_t decrypt_data_symmetric_xaead(const uint8_t *shared_key, const uint8_t *nonce, const uint8_t *encrypted, size_t encrypted_length,
size_t decrypt_data_symmetric_xaead(const uint8_t shared_key[CRYPTO_SHARED_KEY_SIZE], const uint8_t nonce[CRYPTO_NONCE_SIZE], const uint8_t *encrypted, size_t encrypted_length,
uint8_t *plain, const uint8_t *ad, size_t ad_length);

/**
Expand Down
2 changes: 1 addition & 1 deletion toxcore/net_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -3196,7 +3196,7 @@ int accept_crypto_connection(Net_Crypto *c, const New_Connection *n_c)
return crypt_connection_id;
}

/** @brief Create a crypto connection. Currently independent of non-Noise/Noise handshake.
/** @brief Create a crypto connection. Currently supports both non-Noise and NoiseIK handshake.
* If one to that real public key already exists, return it.
*
* return -1 on failure.
Expand Down

0 comments on commit 21b9126

Please sign in to comment.