From ffd69a6525cc706fadbf5ad8d68400fc1d6fd5b4 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Thu, 1 Aug 2013 15:49:32 -0400 Subject: Possible timing problem fixed. --- core/net_crypto.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/net_crypto.c b/core/net_crypto.c index 83cb20a2..34d481ca 100644 --- a/core/net_crypto.c +++ b/core/net_crypto.c @@ -75,10 +75,9 @@ int encrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce, uint32_t i; uint32_t check = 0; for(i = 0; i < crypto_box_BOXZEROBYTES; ++i) { - if (temp_encrypted[i] != 0) - check = 1; + check |= temp_plain[i] ^ 0; } - if(check == 1) + if(check != 0) return -1; /* unpad the encrypted message */ @@ -110,10 +109,9 @@ int decrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce, uint32_t i; uint32_t check = 0; for(i = 0; i < crypto_box_ZEROBYTES; ++i) { - if (temp_plain[i] != 0) - check = 1; + check |= temp_plain[i] ^ 0; } - if(check == 1) + if(check != 0) return -1; /* unpad the plain message */ -- cgit v1.2.3