From 79aa715514e7d587695ce0182fdf97537d9d9b85 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Fri, 12 Jul 2013 16:27:19 -0400 Subject: First part of DHT hardening done. Added crypto to the DHT communications. This defeats completely the first attack mentioned in docs/DHT_hardening. Also updated the build system to build the latest test (it links it with libsodium) --- core/net_crypto.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/net_crypto.h') diff --git a/core/net_crypto.h b/core/net_crypto.h index fe655c92..4c3b53de 100644 --- a/core/net_crypto.h +++ b/core/net_crypto.h @@ -32,8 +32,9 @@ #endif //Our public key. extern uint8_t self_public_key[crypto_box_PUBLICKEYBYTES]; +extern uint8_t self_secret_key[crypto_box_SECRETKEYBYTES]; - +#define ENCRYPTION_PADDING (crypto_box_ZEROBYTES - crypto_box_BOXZEROBYTES) //encrypts plain of length length to encrypted of length + 16 using the //public key(32 bytes) of the receiver and the secret key of the sender and a 24 byte nonce @@ -51,6 +52,10 @@ int decrypt_data(uint8_t * public_key, uint8_t * secret_key, uint8_t * nonce, uint8_t * encrypted, uint32_t length, uint8_t * plain); +//fill the given nonce with random bytes. +void random_nonce(uint8_t * nonce); + + //return 0 if there is no received data in the buffer //return -1 if the packet was discarded. //return length of received data if successful -- cgit v1.2.3