summaryrefslogtreecommitdiff
path: root/toxcore/crypto_core.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2017-01-20 21:16:55 +0000
committeriphydf <iphydf@users.noreply.github.com>2017-01-28 20:49:12 +0000
commit6ae33c16cf9e37fda85d70c78b3c2779eb8ca21a (patch)
tree99c3a8c26e02039b515bb6f57d2797d1cdf77c1d /toxcore/crypto_core.c
parent895de7ef26e7617769f2271345e414545c2581f8 (diff)
Add VLA compatibility macro for C89-ish compilers.
Diffstat (limited to 'toxcore/crypto_core.c')
-rw-r--r--toxcore/crypto_core.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/toxcore/crypto_core.c b/toxcore/crypto_core.c
index e114b44f..03150396 100644
--- a/toxcore/crypto_core.c
+++ b/toxcore/crypto_core.c
@@ -127,8 +127,8 @@ int32_t encrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce,
127 return -1; 127 return -1;
128 } 128 }
129 129
130 uint8_t temp_plain[length + crypto_box_ZEROBYTES]; 130 VLA(uint8_t, temp_plain, length + crypto_box_ZEROBYTES);
131 uint8_t temp_encrypted[length + crypto_box_MACBYTES + crypto_box_BOXZEROBYTES]; 131 VLA(uint8_t, temp_encrypted, length + crypto_box_MACBYTES + crypto_box_BOXZEROBYTES);
132 132
133 memset(temp_plain, 0, crypto_box_ZEROBYTES); 133 memset(temp_plain, 0, crypto_box_ZEROBYTES);
134 memcpy(temp_plain + crypto_box_ZEROBYTES, plain, length); // Pad the message with 32 0 bytes. 134 memcpy(temp_plain + crypto_box_ZEROBYTES, plain, length); // Pad the message with 32 0 bytes.
@@ -149,8 +149,8 @@ int32_t decrypt_data_symmetric(const uint8_t *secret_key, const uint8_t *nonce,
149 return -1; 149 return -1;
150 } 150 }
151 151
152 uint8_t temp_plain[length + crypto_box_ZEROBYTES]; 152 VLA(uint8_t, temp_plain, length + crypto_box_ZEROBYTES);
153 uint8_t temp_encrypted[length + crypto_box_BOXZEROBYTES]; 153 VLA(uint8_t, temp_encrypted, length + crypto_box_BOXZEROBYTES);
154 154
155 memset(temp_encrypted, 0, crypto_box_BOXZEROBYTES); 155 memset(temp_encrypted, 0, crypto_box_BOXZEROBYTES);
156 memcpy(temp_encrypted + crypto_box_BOXZEROBYTES, encrypted, length); // Pad the message with 16 0 bytes. 156 memcpy(temp_encrypted + crypto_box_BOXZEROBYTES, encrypted, length); // Pad the message with 16 0 bytes.