summaryrefslogtreecommitdiff
path: root/auto_tests/crypto_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'auto_tests/crypto_test.c')
-rw-r--r--auto_tests/crypto_test.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/auto_tests/crypto_test.c b/auto_tests/crypto_test.c
index 9d3e2e82..806ea7b8 100644
--- a/auto_tests/crypto_test.c
+++ b/auto_tests/crypto_test.c
@@ -95,8 +95,8 @@ START_TEST(test_known)
95 unsigned char m[131]; 95 unsigned char m[131];
96 int clen, mlen; 96 int clen, mlen;
97 97
98 ck_assert_msg(sizeof(c) == sizeof(m) + ENCRYPTION_PADDING * sizeof(unsigned char), 98 ck_assert_msg(sizeof(c) == sizeof(m) + crypto_box_MACBYTES * sizeof(unsigned char),
99 "cyphertext should be ENCRYPTION_PADDING bytes longer than plaintext"); 99 "cyphertext should be crypto_box_MACBYTES bytes longer than plaintext");
100 ck_assert_msg(sizeof(test_c) == sizeof(c), "sanity check failed"); 100 ck_assert_msg(sizeof(test_c) == sizeof(c), "sanity check failed");
101 ck_assert_msg(sizeof(test_m) == sizeof(m), "sanity check failed"); 101 ck_assert_msg(sizeof(test_m) == sizeof(m), "sanity check failed");
102 102
@@ -121,8 +121,8 @@ START_TEST(test_fast_known)
121 121
122 encrypt_precompute(bobpk, alicesk, k); 122 encrypt_precompute(bobpk, alicesk, k);
123 123
124 ck_assert_msg(sizeof(c) == sizeof(m) + ENCRYPTION_PADDING * sizeof(unsigned char), 124 ck_assert_msg(sizeof(c) == sizeof(m) + crypto_box_MACBYTES * sizeof(unsigned char),
125 "cyphertext should be ENCRYPTION_PADDING bytes longer than plaintext"); 125 "cyphertext should be crypto_box_MACBYTES bytes longer than plaintext");
126 ck_assert_msg(sizeof(test_c) == sizeof(c), "sanity check failed"); 126 ck_assert_msg(sizeof(test_c) == sizeof(c), "sanity check failed");
127 ck_assert_msg(sizeof(test_m) == sizeof(m), "sanity check failed"); 127 ck_assert_msg(sizeof(test_m) == sizeof(m), "sanity check failed");
128 128
@@ -151,10 +151,10 @@ START_TEST(test_endtoend)
151 unsigned char n[crypto_box_NONCEBYTES]; 151 unsigned char n[crypto_box_NONCEBYTES];
152 152
153 unsigned char m[500]; 153 unsigned char m[500];
154 unsigned char c1[sizeof(m) + ENCRYPTION_PADDING]; 154 unsigned char c1[sizeof(m) + crypto_box_MACBYTES];
155 unsigned char c2[sizeof(m) + ENCRYPTION_PADDING]; 155 unsigned char c2[sizeof(m) + crypto_box_MACBYTES];
156 unsigned char c3[sizeof(m) + ENCRYPTION_PADDING]; 156 unsigned char c3[sizeof(m) + crypto_box_MACBYTES];
157 unsigned char c4[sizeof(m) + ENCRYPTION_PADDING]; 157 unsigned char c4[sizeof(m) + crypto_box_MACBYTES];
158 unsigned char m1[sizeof(m)]; 158 unsigned char m1[sizeof(m)];
159 unsigned char m2[sizeof(m)]; 159 unsigned char m2[sizeof(m)];
160 unsigned char m3[sizeof(m)]; 160 unsigned char m3[sizeof(m)];
@@ -190,7 +190,7 @@ START_TEST(test_endtoend)
190 c4len = encrypt_data_fast(k2, n, m, mlen, c4); 190 c4len = encrypt_data_fast(k2, n, m, mlen, c4);
191 191
192 ck_assert_msg(c1len == c2len && c1len == c3len && c1len == c4len, "cyphertext lengths differ"); 192 ck_assert_msg(c1len == c2len && c1len == c3len && c1len == c4len, "cyphertext lengths differ");
193 ck_assert_msg(c1len == mlen + (int)ENCRYPTION_PADDING, "wrong cyphertext length"); 193 ck_assert_msg(c1len == mlen + (int)crypto_box_MACBYTES, "wrong cyphertext length");
194 ck_assert_msg(memcmp(c1, c2, c1len) == 0 && memcmp(c1, c3, c1len) == 0 194 ck_assert_msg(memcmp(c1, c2, c1len) == 0 && memcmp(c1, c3, c1len) == 0
195 && memcmp(c1, c4, c1len) == 0, "crypertexts differ"); 195 && memcmp(c1, c4, c1len) == 0, "crypertexts differ");
196 196
@@ -215,12 +215,12 @@ START_TEST(test_large_data)
215 215
216 unsigned char n[crypto_box_NONCEBYTES]; 216 unsigned char n[crypto_box_NONCEBYTES];
217 217
218 unsigned char m1[MAX_DATA_SIZE - ENCRYPTION_PADDING]; 218 unsigned char m1[MAX_DATA_SIZE - crypto_box_MACBYTES];
219 unsigned char c1[sizeof(m1) + ENCRYPTION_PADDING]; 219 unsigned char c1[sizeof(m1) + crypto_box_MACBYTES];
220 unsigned char m1prime[sizeof(m1)]; 220 unsigned char m1prime[sizeof(m1)];
221 221
222 unsigned char m2[MAX_DATA_SIZE]; 222 unsigned char m2[MAX_DATA_SIZE];
223 unsigned char c2[sizeof(m2) + ENCRYPTION_PADDING]; 223 unsigned char c2[sizeof(m2) + crypto_box_MACBYTES];
224 224
225 int c1len, c2len; 225 int c1len, c2len;
226 int m1plen; 226 int m1plen;
@@ -236,7 +236,7 @@ START_TEST(test_large_data)
236 c1len = encrypt_data_fast(k, n, m1, sizeof(m1), c1); 236 c1len = encrypt_data_fast(k, n, m1, sizeof(m1), c1);
237 c2len = encrypt_data_fast(k, n, m2, sizeof(m2), c2); 237 c2len = encrypt_data_fast(k, n, m2, sizeof(m2), c2);
238 238
239 ck_assert_msg(c1len == sizeof(m1) + ENCRYPTION_PADDING, "could not encrypt max size"); 239 ck_assert_msg(c1len == sizeof(m1) + crypto_box_MACBYTES, "could not encrypt max size");
240 ck_assert_msg(c2len == -1, "incorrectly succeeded encrypting massive size"); 240 ck_assert_msg(c2len == -1, "incorrectly succeeded encrypting massive size");
241 241
242 m1plen = decrypt_data_fast(k, n, c1, c1len, m1prime); 242 m1plen = decrypt_data_fast(k, n, c1, c1len, m1prime);