summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-08-19 20:03:40 -0400
committerNick Mathewson <nickm@torproject.org>2009-10-15 15:17:12 -0400
commit8d41e6c47126fb467858f98b06ab7460dcc6647b (patch)
tree3ffc6a5c8561892069abbb3a54fa4cbc4e043947 /src/test
parent5ef97ddd42dfd51fc296bb51b612780aec09c5c7 (diff)
downloadtor-8d41e6c47126fb467858f98b06ab7460dcc6647b.tar.gz
tor-8d41e6c47126fb467858f98b06ab7460dcc6647b.zip
Support for encoding and decoding 256-bit digests in base64
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_crypto.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index d235520d09..2edb8035bb 100644
--- a/src/test/test_crypto.c
+++ b/src/test/test_crypto.c
@@ -472,6 +472,17 @@ test_crypto_formats(void)
test_assert(digest_from_base64(data3, "###") < 0);
+ /* Encoding SHA256 */
+ crypto_rand(data2, DIGEST256_LEN);
+ memset(data2, 100, 1024);
+ digest256_to_base64(data2, data1);
+ test_eq(BASE64_DIGEST256_LEN, strlen(data2));
+ test_eq(100, data2[BASE64_DIGEST256_LEN+2]);
+ memset(data3, 99, 1024);
+ test_eq(digest256_from_base64(data3, data2), 0);
+ test_memeq(data1, data3, DIGEST256_LEN);
+ test_eq(99, data3[DIGEST256_LEN+1]);
+
/* Base32 tests */
strlcpy(data1, "5chrs", 1024);
/* bit pattern is: [35 63 68 72 73] ->