summaryrefslogtreecommitdiff
path: root/core/net_crypto.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/net_crypto.h')
-rw-r--r--core/net_crypto.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/net_crypto.h b/core/net_crypto.h
index 66634d45..135e099d 100644
--- a/core/net_crypto.h
+++ b/core/net_crypto.h
@@ -36,6 +36,9 @@ extern uint8_t self_secret_key[crypto_box_SECRETKEYBYTES];
36 36
37#define ENCRYPTION_PADDING (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES) 37#define ENCRYPTION_PADDING (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES)
38 38
39/* returns zero if the buffer contains only zeros */
40uint8_t crypto_iszero(uint8_t* buffer, uint32_t blen);
41
39/* encrypts plain of length length to encrypted of length + 16 using the 42/* encrypts plain of length length to encrypted of length + 16 using the
40 public key(32 bytes) of the receiver and the secret key of the sender and a 24 byte nonce 43 public key(32 bytes) of the receiver and the secret key of the sender and a 24 byte nonce
41 return -1 if there was a problem. 44 return -1 if there was a problem.
@@ -51,6 +54,19 @@ int encrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce,
51int decrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce, 54int decrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce,
52 uint8_t *encrypted, uint32_t length, uint8_t *plain); 55 uint8_t *encrypted, uint32_t length, uint8_t *plain);
53 56
57/* Fast encrypt/decrypt operations. Use if this is not a one-time communication.
58 encrypt_precompute does the shared-key generation once so it does not have
59 to be preformed on every encrypt/decrypt. */
60void encrypt_precompute(uint8_t *public_key, uint8_t *secret_key, uint8_t *enc_key);
61
62/* Fast encrypt. Depends on enc_key from encrypt_precompute. */
63int encrypt_data_fast(uint8_t *enc_key, uint8_t *nonce,
64 uint8_t *plain, uint32_t length, uint8_t *encrypted);
65
66/* Fast decrypt. Depends on enc_ley from encrypt_precompute. */
67int decrypt_data_fast(uint8_t *enc_key, uint8_t *nonce,
68 uint8_t *encrypted, uint32_t length, uint8_t *plain);
69
54 70
55/* fill the given nonce with random bytes. */ 71/* fill the given nonce with random bytes. */
56void random_nonce(uint8_t *nonce); 72void random_nonce(uint8_t *nonce);