summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-08-01 15:49:32 -0400
committerirungentoo <irungentoo@gmail.com>2013-08-01 15:49:32 -0400
commitffd69a6525cc706fadbf5ad8d68400fc1d6fd5b4 (patch)
treea335646dc046b89f4a8d5723a8f04bc8c399e595 /core
parentf6c510b3ccd3b5850b714831c61d96baa58da4b5 (diff)
Possible timing problem fixed.
Diffstat (limited to 'core')
-rw-r--r--core/net_crypto.c10
1 files changed, 4 insertions, 6 deletions
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,
75 uint32_t i; 75 uint32_t i;
76 uint32_t check = 0; 76 uint32_t check = 0;
77 for(i = 0; i < crypto_box_BOXZEROBYTES; ++i) { 77 for(i = 0; i < crypto_box_BOXZEROBYTES; ++i) {
78 if (temp_encrypted[i] != 0) 78 check |= temp_plain[i] ^ 0;
79 check = 1;
80 } 79 }
81 if(check == 1) 80 if(check != 0)
82 return -1; 81 return -1;
83 82
84 /* unpad the encrypted message */ 83 /* unpad the encrypted message */
@@ -110,10 +109,9 @@ int decrypt_data(uint8_t *public_key, uint8_t *secret_key, uint8_t *nonce,
110 uint32_t i; 109 uint32_t i;
111 uint32_t check = 0; 110 uint32_t check = 0;
112 for(i = 0; i < crypto_box_ZEROBYTES; ++i) { 111 for(i = 0; i < crypto_box_ZEROBYTES; ++i) {
113 if (temp_plain[i] != 0) 112 check |= temp_plain[i] ^ 0;
114 check = 1;
115 } 113 }
116 if(check == 1) 114 if(check != 0)
117 return -1; 115 return -1;
118 116
119 /* unpad the plain message */ 117 /* unpad the plain message */