summaryrefslogtreecommitdiff
path: root/src/or/test.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-07 03:11:42 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-07 03:11:42 +0000
commitce3162d03510c9e87c508d4b854757bb501f8461 (patch)
treea404418b94b5b4a6a97d5be9f9e4fc5d8dce39d3 /src/or/test.c
parent2bba65148bd8b427bf3bb5753c371da8395552fc (diff)
downloadtor-ce3162d03510c9e87c508d4b854757bb501f8461.tar.gz
tor-ce3162d03510c9e87c508d4b854757bb501f8461.zip
Make base-64-encoded DER work, including workaround for ugly openssl misfeature that makes base64 decoding fail when you strip out the newlines.
svn:r2423
Diffstat (limited to 'src/or/test.c')
-rw-r--r--src/or/test.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/or/test.c b/src/or/test.c
index 800ad72cb0..48a30cec64 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -365,6 +365,20 @@ test_crypto()
test_assert(! crypto_pk_write_public_key_to_string(pk1, &cp, &i));
test_assert(! crypto_pk_read_public_key_from_string(pk2, cp, i));
test_eq(0, crypto_pk_cmp_keys(pk1, pk2));
+ tor_free(cp);
+
+ /* Check DER encoding */
+ i=crypto_pk_DER64_encode_public_key(pk1, &cp);
+ test_assert(i>0);
+ test_assert(cp);
+ test_assert(!strchr(cp, ' '));
+ test_assert(!strchr(cp, '\n'));
+ test_eq(0, crypto_pk_cmp_keys(pk1, pk1));
+ crypto_free_pk_env(pk2);
+ pk2 = crypto_pk_DER64_decode_public_key(cp);
+ test_assert(pk2);
+ test_eq(0, crypto_pk_cmp_keys(pk1, pk2));
+ tor_free(cp);
test_eq(128, crypto_pk_keysize(pk1));
test_eq(128, crypto_pk_keysize(pk2));
@@ -1095,6 +1109,7 @@ main(int c, char**v){
// puts("========================== Buffers =========================");
// test_buffers();
puts("\n========================== Crypto ==========================");
+ // add_stream_log(LOG_DEBUG, LOG_ERR, "<stdout>", stdout);
test_crypto();
test_crypto_dh();
puts("\n========================= Util ============================");
@@ -1105,7 +1120,6 @@ main(int c, char**v){
test_onion();
test_onion_handshake();
puts("\n========================= Directory Formats ===============");
- /* add_stream_log(LOG_DEBUG, LOG_ERR, "<stdout>", stdout); */
test_dir_format();
puts("\n========================= Rendezvous functionality ========");
test_rend_fns();