]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add tests for failing cases of crypto_pwbox
authorNick Mathewson <nickm@torproject.org>
Wed, 24 Sep 2014 16:32:18 +0000 (12:32 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 25 Sep 2014 15:58:14 +0000 (11:58 -0400)
src/test/test_crypto.c

index 2af649c1e4d69634aef6245ef8ec176d89030665..74b7a8eb31914b0805df781479b4156b76e8c02f 100644 (file)
@@ -1045,8 +1045,19 @@ test_crypto_pwbox(void *arg)
     tt_assert(decoded);
     tt_uint_op(dlen, ==, strlen(msg));
     tt_mem_op(decoded, ==, msg, dlen);
-    tor_free(boxed);
+
     tor_free(decoded);
+
+    tt_int_op(UNPWBOX_BAD_SECRET, ==, crypto_unpwbox(&decoded, &dlen, boxed, len,
+                                                     pw, strlen(pw)-1));
+    boxed[len-1] ^= 1;
+    tt_int_op(UNPWBOX_BAD_SECRET, ==, crypto_unpwbox(&decoded, &dlen, boxed, len,
+                                                     pw, strlen(pw)));
+    boxed[0] = 255;
+    tt_int_op(UNPWBOX_CORRUPTED, ==, crypto_unpwbox(&decoded, &dlen, boxed, len,
+                                                    pw, strlen(pw)));
+
+    tor_free(boxed);
   }
 
  done: