[tor-commits] [tor/master] Whoops; make that unit test actually pass :/

nickm at torproject.org nickm at torproject.org
Thu Jan 3 17:47:01 UTC 2013


commit dffc8e359bcfeb00813a3afde6aa2328f6a6a476
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Jan 3 12:45:50 2013 -0500

    Whoops; make that unit test actually pass :/
---
 src/test/test_crypto.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index 9c69f31..67d2b83 100644
--- a/src/test/test_crypto.c
+++ b/src/test/test_crypto.c
@@ -1016,6 +1016,7 @@ test_crypto_curve25519_persist(void *arg)
   char *content = NULL;
   const char *cp;
   struct stat st;
+  size_t taglen;
 
   (void)arg;
 
@@ -1034,9 +1035,11 @@ test_crypto_curve25519_persist(void *arg)
 
   content = read_file_to_str(fname, RFTS_BIN, &st);
   tt_assert(content);
-  tt_assert(!strcmpstart(content, "== c25519v1: testing =="));
-  cp = content + strlen("== c25519v1: testing ==");
-  tt_int_op(st.st_size, ==, 64 + strlen("== c25519v1: testing =="));
+  taglen = strlen("== c25519v1: testing ==");
+  tt_int_op(st.st_size, ==, 32+CURVE25519_PUBKEY_LEN+CURVE25519_SECKEY_LEN);
+  tt_assert(fast_memeq(content, "== c25519v1: testing ==", taglen));
+  tt_assert(tor_mem_is_zero(content+taglen, 32-taglen));
+  cp = content + 32;
   test_memeq(keypair.seckey.secret_key,
              cp,
              CURVE25519_SECKEY_LEN);
@@ -1050,7 +1053,7 @@ test_crypto_curve25519_persist(void *arg)
 
   tt_int_op(-1, ==, curve25519_keypair_read_from_file(&keypair2, &tag, fname));
 
-  content[64] ^= 0xff;
+  content[69] ^= 0xff;
   tt_int_op(0, ==, write_bytes_to_file(fname, content, st.st_size, 1));
   tt_int_op(-1, ==, curve25519_keypair_read_from_file(&keypair2, &tag, fname));
 



More information about the tor-commits mailing list