summaryrefslogtreecommitdiff
path: root/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h')
-rw-r--r--protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h50
1 files changed, 20 insertions, 30 deletions
diff --git a/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h b/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h
index 90d8255eec..b9691551c7 100644
--- a/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h
+++ b/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h
@@ -14,7 +14,6 @@
#include <stddef.h>
#include <stdint.h>
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -46,8 +45,6 @@ extern "C" {
*
******************************************************************************/
-
-
/**
* The size of the salt part of a pass-key.
*/
@@ -91,7 +88,6 @@ typedef enum Tox_Err_Key_Derivation {
} Tox_Err_Key_Derivation;
-
typedef enum Tox_Err_Encryption {
/**
@@ -118,7 +114,6 @@ typedef enum Tox_Err_Encryption {
} Tox_Err_Encryption;
-
typedef enum Tox_Err_Decryption {
/**
@@ -157,8 +152,6 @@ typedef enum Tox_Err_Decryption {
} Tox_Err_Decryption;
-
-
/*******************************************************************************
*
* BEGIN PART 1
@@ -169,8 +162,6 @@ typedef enum Tox_Err_Decryption {
*
******************************************************************************/
-
-
/**
* Encrypts the given data with the given passphrase.
*
@@ -186,8 +177,8 @@ typedef enum Tox_Err_Decryption {
*
* @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);
/**
* Decrypts the given data with the given passphrase.
@@ -203,9 +194,8 @@ bool tox_pass_encrypt(const uint8_t *plaintext, size_t plaintext_len, const uint
*
* @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);
/*******************************************************************************
*
@@ -216,8 +206,6 @@ bool tox_pass_decrypt(const uint8_t *ciphertext, size_t ciphertext_len, const ui
*
******************************************************************************/
-
-
/**
* This type represents a pass-key.
*
@@ -255,8 +243,9 @@ void tox_pass_key_free(Tox_Pass_Key *key);
*
* @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);
/**
* Same as above, except use the given salt for deterministic key derivation.
@@ -267,8 +256,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);
/**
* Encrypt a plain text with a key produced by tox_pass_key_derive or tox_pass_key_derive_with_salt.
@@ -282,8 +272,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[/*! plaintext_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH */], Tox_Err_Encryption *error);
/**
* This is the inverse of tox_pass_key_encrypt, also using only keys produced by
@@ -295,8 +285,8 @@ bool tox_pass_key_encrypt(const Tox_Pass_Key *key, const uint8_t *plaintext, siz
*
* @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[/*! ciphertext_len - TOX_PASS_ENCRYPTION_EXTRA_LENGTH */], Tox_Err_Decryption *error);
typedef enum Tox_Err_Get_Salt {
@@ -318,7 +308,6 @@ typedef enum Tox_Err_Get_Salt {
} Tox_Err_Get_Salt;
-
/**
* Retrieves the salt used to encrypt the given data.
*
@@ -338,7 +327,9 @@ typedef enum Tox_Err_Get_Salt {
*
* @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);
/**
* Determines whether or not the given data is encrypted by this module.
@@ -354,11 +345,10 @@ bool tox_get_salt(const uint8_t *ciphertext, uint8_t *salt, Tox_Err_Get_Salt *er
*
* @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]);
#ifdef __cplusplus
-}
+} /* extern "C" */
#endif
//!TOKSTYLE-
@@ -370,4 +360,4 @@ typedef Tox_Err_Get_Salt TOX_ERR_GET_SALT;
//!TOKSTYLE+
-#endif // C_TOXCORE_TOXENCRYPTSAVE_TOXENCRYPTSAVE_H
+#endif /* C_TOXCORE_TOXENCRYPTSAVE_TOXENCRYPTSAVE_H */