aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-06-04 13:43:03 +0000
committerNick Mathewson <nickm@torproject.org>2005-06-04 13:43:03 +0000
commit3c58cdf2800d19a56529bb10da3c0638e02f3734 (patch)
tree2600cfffccc6f93b40ef580058abe75725f753a5 /src
parentb3f9c9332c162e4a50039289a06575455d342348 (diff)
downloadtor-3c58cdf2800d19a56529bb10da3c0638e02f3734.tar.gz
tor-3c58cdf2800d19a56529bb10da3c0638e02f3734.zip
Add unit test for openpgp s2k
svn:r4306
Diffstat (limited to 'src')
-rw-r--r--src/or/test.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/or/test.c b/src/or/test.c
index d9dea858cd..6bc162463c 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -565,6 +565,35 @@ test_crypto(void)
}
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 @@ main(int c, char**v) {
// add_stream_log(LOG_DEBUG, LOG_ERR, "<stdout>", stdout);
test_crypto();
test_crypto_dh();
+ test_crypto_s2k();
puts("\n========================= Util ============================");
test_gzip();
test_util();