@@ -79,7 +79,9 @@ void tox_pass_key_free(Tox_Pass_Key *key)
7979 *
8080 * @return true on success.
8181 */
82- bool tox_get_salt (const uint8_t * ciphertext , uint8_t * salt , Tox_Err_Get_Salt * error )
82+ bool tox_get_salt (
83+ const uint8_t ciphertext [TOX_PASS_ENCRYPTION_EXTRA_LENGTH ],
84+ uint8_t salt [TOX_PASS_SALT_LENGTH ], Tox_Err_Get_Salt * error )
8385{
8486 if (ciphertext == nullptr || salt == nullptr ) {
8587 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
112114 *
113115 * @return new symmetric key on success, NULL on failure.
114116 */
115- Tox_Pass_Key * tox_pass_key_derive (const uint8_t * passphrase , size_t passphrase_len ,
116- Tox_Err_Key_Derivation * error )
117+ Tox_Pass_Key * tox_pass_key_derive (
118+ const uint8_t passphrase [], size_t passphrase_len ,
119+ Tox_Err_Key_Derivation * error )
117120{
118121 const Random * rng = system_random ();
119122
@@ -136,8 +139,9 @@ Tox_Pass_Key *tox_pass_key_derive(const uint8_t *passphrase, size_t passphrase_l
136139 *
137140 * @return new symmetric key on success, NULL on failure.
138141 */
139- Tox_Pass_Key * tox_pass_key_derive_with_salt (const uint8_t * passphrase , size_t passphrase_len ,
140- const uint8_t * salt , Tox_Err_Key_Derivation * error )
142+ Tox_Pass_Key * tox_pass_key_derive_with_salt (
143+ const uint8_t passphrase [], size_t passphrase_len ,
144+ const uint8_t salt [TOX_PASS_SALT_LENGTH ], Tox_Err_Key_Derivation * error )
141145{
142146 if (salt == nullptr || (passphrase == nullptr && passphrase_len != 0 )) {
143147 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
189193 *
190194 * @return true on success.
191195 */
192- bool tox_pass_key_encrypt (const Tox_Pass_Key * key , const uint8_t * plaintext , size_t plaintext_len ,
193- uint8_t * ciphertext , Tox_Err_Encryption * error )
196+ bool tox_pass_key_encrypt (const Tox_Pass_Key * key , const uint8_t plaintext [] , size_t plaintext_len ,
197+ uint8_t ciphertext [] , Tox_Err_Encryption * error )
194198{
195199 const Random * rng = system_random ();
196200
@@ -250,8 +254,8 @@ bool tox_pass_key_encrypt(const Tox_Pass_Key *key, const uint8_t *plaintext, siz
250254 *
251255 * @return true on success.
252256 */
253- bool tox_pass_encrypt (const uint8_t * plaintext , size_t plaintext_len , const uint8_t * passphrase , size_t passphrase_len ,
254- uint8_t * ciphertext , Tox_Err_Encryption * error )
257+ bool tox_pass_encrypt (const uint8_t plaintext [] , size_t plaintext_len , const uint8_t passphrase [] , size_t passphrase_len ,
258+ uint8_t ciphertext [] , Tox_Err_Encryption * error )
255259{
256260 Tox_Err_Key_Derivation err ;
257261 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
281285 *
282286 * @return true on success.
283287 */
284- bool tox_pass_key_decrypt (const Tox_Pass_Key * key , const uint8_t * ciphertext , size_t ciphertext_len ,
285- uint8_t * plaintext , Tox_Err_Decryption * error )
288+ bool tox_pass_key_decrypt (const Tox_Pass_Key * key , const uint8_t ciphertext [] , size_t ciphertext_len ,
289+ uint8_t plaintext [] , Tox_Err_Decryption * error )
286290{
287291 if (ciphertext_len <= TOX_PASS_ENCRYPTION_EXTRA_LENGTH ) {
288292 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
333337 *
334338 * @return true on success.
335339 */
336- bool tox_pass_decrypt (const uint8_t * ciphertext , size_t ciphertext_len , const uint8_t * passphrase ,
337- size_t passphrase_len , uint8_t * plaintext , Tox_Err_Decryption * error )
340+ bool tox_pass_decrypt (const uint8_t ciphertext [] , size_t ciphertext_len , const uint8_t passphrase [] ,
341+ size_t passphrase_len , uint8_t plaintext [] , Tox_Err_Decryption * error )
338342{
339343 if (ciphertext_len <= TOX_PASS_ENCRYPTION_EXTRA_LENGTH ) {
340344 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
382386 *
383387 * @return true if the data is encrypted by this module.
384388 */
385- bool tox_is_data_encrypted (const uint8_t * data )
389+ bool tox_is_data_encrypted (const uint8_t data [ TOX_PASS_ENCRYPTION_EXTRA_LENGTH ] )
386390{
387391 return memcmp (data , TOX_ENC_SAVE_MAGIC_NUMBER , TOX_ENC_SAVE_MAGIC_LENGTH ) == 0 ;
388392}
0 commit comments