[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r18095: {tor} Do the tor_assert hack everywhere in test_crypto_aes_iv. (tor/trunk/src/or)



Author: nickm
Date: 2009-01-13 09:43:46 -0500 (Tue, 13 Jan 2009)
New Revision: 18095

Modified:
   tor/trunk/src/or/test.c
Log:
Do the tor_assert hack everywhere in test_crypto_aes_iv.

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2009-01-13 14:43:43 UTC (rev 18094)
+++ tor/trunk/src/or/test.c	2009-01-13 14:43:46 UTC (rev 18095)
@@ -4290,16 +4290,20 @@
   /* Encrypt and decrypt with the same key. */
   cipher = crypto_create_init_cipher(key1, 1);
   encrypted_size = crypto_cipher_encrypt_with_iv(cipher, encrypted1, 16 + 4095,
-                                             plain, 4095);
+                                                 plain, 4095);
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(encrypted_size, 16 + 4095);
+  tor_assert(encrypted_size > 0); /* This is obviously true, since 17 is
+                                   * greater than 0, but its truth is not
+                                   * obvious to all analysis tools. */
   cipher = crypto_create_init_cipher(key1, 0);
   decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted1, 4095,
                                              encrypted1, encrypted_size);
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(decrypted_size, 4095);
+  tor_assert(decrypted_size > 0);
   test_memeq(plain, decrypted1, 4095);
   /* Encrypt a second time (with a new random initialization vector). */
   cipher = crypto_create_init_cipher(key1, 1);
@@ -4308,12 +4312,14 @@
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(encrypted_size, 16 + 4095);
+  tor_assert(encrypted_size > 0);
   cipher = crypto_create_init_cipher(key1, 0);
   decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted2, 4095,
                                              encrypted2, encrypted_size);
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(decrypted_size, 4095);
+  tor_assert(decrypted_size > 0);
   test_memeq(plain, decrypted2, 4095);
   test_memneq(encrypted1, encrypted2, encrypted_size);
   /* Decrypt with the wrong key. */
@@ -4338,15 +4344,14 @@
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(encrypted_size, 16 + 1);
-  tor_assert(encrypted_size > 0); /* This is obviously true, since 17 is
-                                   * greater than 0, but its truth is not
-                                   * obvious to all analysis tools. */
+  tor_assert(encrypted_size > 0);
   cipher = crypto_create_init_cipher(key1, 0);
   decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted1, 1,
                                              encrypted1, encrypted_size);
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(decrypted_size, 1);
+  tor_assert(decrypted_size > 0);
   test_memeq(plain_1, decrypted1, 1);
   /* Special length case: 15. */
   cipher = crypto_create_init_cipher(key1, 1);
@@ -4355,12 +4360,14 @@
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(encrypted_size, 16 + 15);
+  tor_assert(encrypted_size > 0);
   cipher = crypto_create_init_cipher(key1, 0);
   decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted1, 15,
                                              encrypted1, encrypted_size);
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(decrypted_size, 15);
+  tor_assert(decrypted_size > 0);
   test_memeq(plain_15, decrypted1, 15);
   /* Special length case: 16. */
   cipher = crypto_create_init_cipher(key1, 1);
@@ -4369,12 +4376,14 @@
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(encrypted_size, 16 + 16);
+  tor_assert(encrypted_size > 0);
   cipher = crypto_create_init_cipher(key1, 0);
   decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted1, 16,
                                              encrypted1, encrypted_size);
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(decrypted_size, 16);
+  tor_assert(decrypted_size > 0);
   test_memeq(plain_16, decrypted1, 16);
   /* Special length case: 17. */
   cipher = crypto_create_init_cipher(key1, 1);
@@ -4383,10 +4392,12 @@
   crypto_free_cipher_env(cipher);
   cipher = NULL;
   test_eq(encrypted_size, 16 + 17);
+  tor_assert(encrypted_size > 0);
   cipher = crypto_create_init_cipher(key1, 0);
   decrypted_size = crypto_cipher_decrypt_with_iv(cipher, decrypted1, 17,
                                              encrypted1, encrypted_size);
   test_eq(decrypted_size, 17);
+  tor_assert(decrypted_size > 0);
   test_memeq(plain_17, decrypted1, 17);
 
  done: