[or-cvs] Add unit test for openpgp s2k
Nick Mathewson
nickm at seul.org
Sat Jun 4 13:43:05 UTC 2005
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv26586/src/or
Modified Files:
test.c
Log Message:
Add unit test for openpgp s2k
Index: test.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/test.c,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -d -r1.177 -r1.178
--- test.c 14 May 2005 00:13:17 -0000 1.177
+++ test.c 4 Jun 2005 13:43:03 -0000 1.178
@@ -565,6 +565,35 @@
}
static void
+test_crypto_s2k(void)
+{
+ char buf[29];
+ char buf2[29];
+ char *buf3;
+ int i;
+
+ memset(buf, 0, sizeof(buf));
+ memset(buf2, 0, sizeof(buf2));
+ buf3 = tor_malloc(65536);
+ memset(buf3, 0, 65536);
+
+ secret_to_key(buf+9, 20, "", 0, buf);
+ crypto_digest(buf2+9, buf3, 1024);
+ test_memeq(buf, buf2, 29);
+
+ memcpy(buf,"vrbacrda",8);
+ memcpy(buf2,"vrbacrda",8);
+ buf[8] = 96;
+ buf2[8] = 96;
+ secret_to_key(buf+9, 20, "12345678", 8, buf);
+ for (i = 0; i < 65536; i += 16) {
+ memcpy(buf3+i, "vrbacrda12345678", 16);
+ }
+ crypto_digest(buf2+9, buf3, 65536);
+ test_memeq(buf, buf2, 29);
+}
+
+static void
test_util(void) {
struct timeval start, end;
struct tm a_time;
@@ -1411,6 +1440,7 @@
// add_stream_log(LOG_DEBUG, LOG_ERR, "<stdout>", stdout);
test_crypto();
test_crypto_dh();
+ test_crypto_s2k();
puts("\n========================= Util ============================");
test_gzip();
test_util();
More information about the tor-commits
mailing list